sysfs: handle 'parent deleted before child added'

In scsi at least two cases of the parent device being deleted before the
child is added have been observed.

1/ scsi is performing async scans and the device is removed prior to the
   async can thread running (can happen with an in-opportune / unlikely
   unplug during initial scan).

2/ libsas discovery event running after the parent port has been torn
   down (this is a bug in libsas).

Result in crash signatures like:
 BUG: unable to handle kernel NULL pointer dereference at 0000000000000098
 IP: [<ffffffff8115e100>] sysfs_create_dir+0x32/0xb6
 ...
 Process scsi_scan_8 (pid: 5417, threadinfo ffff88080bd16000, task ffff880801b8a0b0)
 Stack:
  00000000fffffffe ffff880813470628 ffff88080bd17cd0 ffff88080614b7e8
  ffff88080b45c108 00000000fffffffe ffff88080bd17d20 ffffffff8125e4a8
  ffff88080bd17cf0 ffffffff81075149 ffff88080bd17d30 ffff88080614b7e8
 Call Trace:
  [<ffffffff8125e4a8>] kobject_add_internal+0x120/0x1e3
  [<ffffffff81075149>] ? trace_hardirqs_on+0xd/0xf
  [<ffffffff8125e641>] kobject_add_varg+0x41/0x50
  [<ffffffff8125e70b>] kobject_add+0x64/0x66
  [<ffffffff8131122b>] device_add+0x12d/0x63a

In this scenario the parent is still valid (because we have a
reference), but it has been device_del()'d which means its kobj->sd
pointer is NULL'd via:

 device_del()->kobject_del()->sysfs_remove_dir()

...and then sysfs_create_dir() (without this fix) goes ahead and
de-references parent_sd via sysfs_ns_type():

 return (sd->s_flags & SYSFS_NS_TYPE_MASK) >> SYSFS_NS_TYPE_SHIFT;

This scenario is being fixed in scsi/libsas, but if other subsystems
present the same ordering the system need not immediately crash.

Change-Id: Ifdf2471af0ba3f58f7403946a8d683fdfd26d322
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: James Bottomley <JBottomley@parallels.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
block: Add test-iosched scheduler

The test scheduler allows testing a block device by dispatching
specific requests according to the test case and declare PASS/FAIL
according to the requests completion error code

Change-Id: I03876fbb6359180aab9bbf691724931f9f1dc9c1
Signed-off-by: Maya Erez <merez@codeaurora.org>
(cherry picked from commit 6018155a6fc3ac65f929cecf04708f48f4af6aba)
msm: clock: Remove some clk_prepare/unprepare() warnings

Remove the warnings that the clk_enable() and clk_disable() APIs
print when drivers attempt to enable or disable clocks that are
not prepared. These warnings are currently harmless, but greatly
contribute to noise in the kernel logs.

This is safe because use of clk_prepare() and clk_unprepare() is
currently optional. They are placeholder APIs that do not
currently perform any operations. Their use will eventually be
required in future kernels, but never on this kernel branch.

Change-Id: I4239842c6f77b844e5dd8460229b80d8c51e99bb
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
msm: 7x27a: audio: set LPA mode for LPA session

New bit has been added in DSP to identify LPA session.
Changes to set LPA decode bit for LPA session.

Signed-off-by: Phani Kumar Allada <pallad@codeaurora.org>
(cherry picked from commit ae39d6d9c99de34d8b91dc9d83c8172517450726)

Change-Id: Ie039a6f218396b4d6b1d1e260d17a2a4b70fc893
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
Bluetooth: Use transmit window from config response for ack timing

This change addresses an L2CAP ERTM throughput problem when a remote
device does not fully utilize the available transmit window.

The L2CAP ERTM transmit window size determines the maximum number of
unacked frames that may be outstanding at any time. It is configured
separately for each direction of an ERTM connection. Each side sends a
configuration request with a tx_win field indicating how many unacked
frames it is capable of receiving before sending an ack. The
configuration response's tx_win field shows how many frames the
transmitter will actually send before waiting for an ack.

It's important to trace both the actual transmit window (to check for
validity of incoming frames) and the number of frames that the
transmitter will send before waiting (to send acks at the appropriate
time). Now there are separate tx_win and ack_win values. ack_win is
updated based on configuration responses, and is used to determine
when acks are sent.

CRs-fixed: 370909
Change-Id: I6d9ef55a2ff2f5f3d0117ad376a09e4cc26fe742
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
(cherry picked from commit da31824a3b52bde102a0f3c4ac621c3487ea88e1)
ASoC: WCD9304: Make sure slimbus port disconnected before opening port

During rapid open and close of slimbus ports, it may happen that when
port open is performed, the port is not disconnected from the previous
open. This will cause inconsistent state and may result in failure to
playback audio. Fix by waiting for the slimbus port disconnect to happen
before opening the port

CRs-fixed: 375689
Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
(cherry picked from commit 305b70e740dcafd58d71e5920c9a02e52388bfa1)

Conflicts:

	sound/soc/codecs/wcd9304.c

Change-Id: I2532afdbbfd5a3fee5f1c97acbb59c4af8b0cca4
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
ASoC: WCD9304: Vote for runtime pm off after slimbus port disconnect

If the vote for pm runtime is done while codec shutdown, it is possible
that the runtime pm vote occurs even before the slimbus port for tx/rx
audio channel is disconnected. This can cause problem in audio playback/
record. Fix by moving the vote for runtime pm after slimbus port has
been disconnected

Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
(cherry picked from commit 04bf691d6e9d1ec67b76a74fab06b7a39ae6cc46)

Change-Id: I7a6bd8dd83c94daa8efef190da36b9cad83b2e40
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
USB: msm_otg: Add debouncing logic for PMIC id line status handling

Currently reading PMIC ID line status immediately once PMIC interrupt
is triggered. This leads to returning wrong ID line state sometimes
and causes not detecting connected devices. Hence add debouncing time
of 5msec for PMIC ID line state to settle down before reading PMIC
ID status.

CRs-Fixed: 371552
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
(cherry picked from commit 68d55cfa2ed1de84966fae66329a3aeca4ecc3a2)

Conflicts:

	drivers/usb/otg/msm_otg.c

Change-Id: Idde02eb41abc50ab4dc37e1d5175a9214400f1d1
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
(cherry picked from commit da18d6a7d722122cb26ef94c2bce4f78a7a1ee14)

Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm: camera: Send camif error notification to user.

In case of CAMIF errors, notify the user so that it
can cleanup resources and exit gracefully.

CRs-Fixed: 371688
Change-Id: I5a50d895395e24f1590e4726b84b85f39b17f198
Signed-off-by: Kiran Kumar H N <hurlisal@codeaurora.org>
msm: dma: Update the clk gating timeout to 100msec from 1sec.

As part of LPAII, the power profiling showed that having 100msec timeout
is letting the AXI switch to low frequency as soon as the APROC collapses.
Having this timeout as 1 sec is pushing the AXI to stay high for longer
time hence causing more power drain. Hence with this change this time
out is updated to 100msec.

Signed-off-by: Krishna Vanka <kvanka@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/dma.c

Signed-off-by: Shirish Kumar Agarwal <shirisha@codeaurora.org>
(cherry picked from commit f49f54dcfe3033c17006aeabc924b8b0e6d70ca4)

Change-Id: Ic622041e17d76122bd52fe9d1c5af7c82dec1991
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
Merge "msm: 7x27a: audio: set LPA mode for LPA session" into ics_strawberry
bdi: use deferable timer for sync_supers task

sync_supers task currently wakes up periodically for superblock
writeback. This hurts power on battery driven devices. This patch
turns this housekeeping timer into a deferable timer so that it
does not fire when system is really idle.

CRs-Fixed: 353700
Signed-off-by: Yong Wang <yong.y.wang@intel.com>
Signed-off-by: Xia Wu <xia.wu@intel.com>
Signed-off-by: Krishna Vanka <kvanka@codeaurora.org>
(cherry picked from commit f398f30d1f34632d3c96758b5b19e65b056af072)

Change-Id: I6ec6310d66c0d014adf0f41e75cd4c48c233f83d
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm: board-msm7627a: De-feature FMEM suport

We are no longer supporting FMEM from MSMs. So, disable
FMEM from 7627a/8625

Change-Id: I894ad36c991023717112c38c803262af774674f4
Signed-off-by: Chintan Pandya <cpandya@codeaurora.org>
msm: mdm: increase the mdm2ap_status timeout value

In some cases the external modem may take longer to pull the
msm2ap_status gpio high after flashless boot has completed.

Change-Id: I1ed0ba64fe474e9757233c678a3acd8a682bb8da
Signed-off-by: Joel King <joelking@codeaurora.org>
Merge "USB: msm_otg: Add debouncing logic for PMIC id line status handling" into ics_strawberry
Merge "msm: dma: Update the clk gating timeout to 100msec from 1sec." into ics_strawberry
msm: Change semantics of cpu_is_msm8930()

Per revised design decisions, cpu_is_msm8930() shall only
return true on 8930, and not on the 8627 variant. Modify
the cpu_is_xxx functions to reflect this change, and update
call sites accordingly.

Change-Id: I2d489f2b0f97452931df5a84e9b47a92c5953113
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Signed-off-by: Eduardo Carrasco <cecarras@codeaurora.org>
msm: socinfo: Add support for MSM8930AA

Add the SoC ID and cpu_is wrapper for identifying the
MSM8930AA SoC.

Change-Id: Ibc36d07d93fcd3a10e467e17f93e4cbb035736d2
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Signed-off-by: Eduardo Carrasco <cecarras@codeaurora.org>
msm: Add support for MSM8930AA

Update the call sites of cpu_is_msm8930() to include checks
for the MSM8930AA() variant. Relevant drivers will be
updated for more driver-specific specific MSM8930AA checks
at a later time.

Change-Id: Ide6cbd0157544a777dbf237554d91519ee06a7b5
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Signed-off-by: Eduardo Carrasco <cecarras@codeaurora.org>
msm: socinfo: Add support for MSM8960AB

Add the SoC ID and cpu_is wrapper for identifying the
MSM8960AB SoC.

Change-Id: Ia0de786011774e89d3d54277ae4733458428c460
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Signed-off-by: Eduardo Carrasco <cecarras@codeaurora.org>