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: If035179fdb716c0690abea5b4d8480ba1af1b871
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: Srivalli Oguri <oguri@codeaurora.org>
tsif: workaround for stuck dma

During tsif stress tests it was reported that the dma flush caused by
calling action_close() is sometimes unrecoverable.  The root cause is
stopping the tsif while a read by the dma of the tsif FIFO is in
progress.  This workaround works by starving the tsif FIFO allowing
any in-flight transfers to complete, and thus ensuring a clean shutdown.

CRs-Fixed: 357934
CRs-Fixed: 358384
Signed-off-by: Joel Nider <jnider@codeaurora.org>
(cherry picked from commit 951b283d14378381633229113e3641d648f6ff22)

Conflicts:

	drivers/misc/tsif.c

Change-Id: Ia2dd693a250544f67fdf2c683d9cb615e424c3ed
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm_fb: HDMI: Update HPD logic to address HDMI PLL related issues

In the current implementation, the regulators pertaining to the
HDMI core are turned off/on as part of the configuration of the
HDP circuitry. As a result, the regulator that powers the HDMI
PLL is turned off before the HDMI clocks on the PLL are disabled.
This might lead to the PLL not getting locked when it is re-enabled.

This change turns on and off the regulators and clocks in proper
sequence.

CRs-Fixed: 360135
CRs-Fixed: 358598
Change-Id: Ie3630b543e78e83dc565edc32239935135ca4ca5
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
msm: display: Add MDP footswitch regulator control for HDMI PLL

Add support for enabling HDMI PLL regulator along with footswitch
enable/disable to avoid PLL lock detection failures during
suspend/resume

CRs-Fixed: 360135
CRs-Fixed: 358598
Change-Id: I9b161cab50d2b6c39de39b588e326f5ff97cbc65
Signed-off-by: Ravishangar Kalyanam <rkalya@codeaurora.org>
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
msm_fb: hdmi: Break infinite loop

Currently, if HDMI PLL lock fails, it will retry. It retries until
the PLL is locked. This may result in infinite loop. This change will
limit the retries to max 10.

CRs-Fixed: 360135
CRs-Fixed: 358598
Change-Id: I1745643cba7bbc5272f1252208759a83258e9fcb
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
msm: clock-dss-8960: Update HDMI PLL settings

Update the HDMI PLL register settings for all the supported
frequencies to address the issue of HDMI PLL not getting
locked sporadically.

CRs-Fixed: 360135
CRs-Fixed: 358598
Change-Id: I033f70f11f406a6be0de7e1a2286d9ad17cc0064
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
msm_fb: display: HPD rework for cleaner approach

Currently HPD is turned on and off with HDMI turn on and off
and turned on again after HDMI off so as to detect the cable
plugin.
With this change, HPD will be turned on when HDMI drvier is
initialized and turned off and on with suspend - resume. The
HPD handling during HDMI turn on and off has been removed.

CRs-Fixed: 368865
Change-Id: I1fb42b4587e58086d643b87a1600ecf09754423d
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
msm_fb: HDMI: Start HDCP authentication only on device open

Currently HDCP authentication is started for a default resolution
upon HPD connection event. With this change, HDCP authentication
is only triggered after the HDMI interface has been configured for
an appropriate resolution following the call to open the HDMI device.

CRs-Fixed: 368865
Change-Id: I7b9ce85aed989b78b448bff6a545a194dfed5b1d
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
msm_fb: HDMI: Do not add HPD state timer during probe

Currently all HDMI timers are initialized in the driver's
probe function with a maximum possible expiration value. However,
the 32-bit jiffies value is initialized in the kernel so as to
wrap 5 minutes after boot. This results in the HPD timer being
fired 5 minutes after boot even though cable  is not
connected. This change fixes this issue by not starting the HPD
timer during probe.

Change-Id: I9eeb8b892be2476e8debdd4ec5897a103cc34665
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
Signed-off-by: Abhishek Kharbanda <akharban@codeaurora.org>
Signed-off-by: Manoj Rao <manojraj@codeaurora.org>
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
msm_fb: HDMI: Removing unnecessary HPD detection code.

HPD read work is used to detect HPD at bootup which
is not required as HPD detection is taken care at
bootup by toggling the HPD circuit. So we can safely
remove this redundant code.

CRs-Fixed: 368865
Change-Id: I8eed00c4f5af2ed2ca37e86da622ab518e5eb887
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
msm: vidc: Perform cache flush only for non-secured
mode.

The cache flush for secure mode is not needed as
no memset is performed. Pass the correct parameter to
cache flush to avoid kernel panic.

Change-Id: I4308c184e42aeb32bf6cfd99c04d0d14f558b503
CRs-Fixed: 374719
Signed-off-by: Arun Menon <menon@codeaurora.org>
msm: audio: qdsp6v2: Resolve panic for voip call scenario

- While in a voip call, when receive another voip call
observe kernel panic in voice cal API.
- In this second call, even though first voip call
deregister memory but acdb block cal sizes are not
reset leading to overflow in size and panic at memcpy
in voice calibration API.
- While deregister memory in ACDB, reset the ACDB cal
sizes of all blocks to zero.

CRs-fixed: 373614
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
(cherry picked from commit a27992bc5c50d83d905c11058628d9153505f4bf)

Conflicts:

	arch/arm/mach-msm/qdsp6v2/audio_acdb.c

Change-Id: I1b762da92960804ec684c4c8cac748513fff71fc
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
wcnss: invoke subsystem restart from interrupt context

when subsystem restart is invoked from a workqueue context, there is
a small window of failure where in the APPS can go to suspend before
invoking subsystem restart.  So invoke subystem restart from the
interrupt context itself.

CRs-Fixed: 371744
Signed-off-by: Sameer Thalappil <sameert@codeaurora.org>
(cherry picked from commit 50d6290a009ba1adadd6fb9d584af612a35aba13)

Conflicts:

	arch/arm/mach-msm/wcnss-ssr-8960.c

Change-Id: If0f99c48a7af8ec58ec781f880d797c9d70c2b63
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: socinfo: Add new MSM IDs for 7127AA and 7125AB.

Move MSM IDs incorrectly added for 7127A and 7125A
to 7127AA and 7125AB respectively.

Signed-off-by: Kaushal Kumar <kaushalk@codeaurora.org>
(cherry picked from commit dc0beb9ff3faeb2ec2a0d9ed6a428f3a4964803a)

Change-Id: I2de01bc6922ad549871080d0ee1f33e35af6cbc2
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm_fb: display: use fs_mdp instead of vdd

Because of a merge issue, fs_mdp was wrongly replaced with vdd.
This change reinstalls fs_mdp.

Change-Id: Id27577a5f95ed3cc211e2bf78157d77e23453f90
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
Bluetooth: Fix ATT Indicate/Confirm handling

If due to timing issues out of our control, an outbound ATT Indicate
is delayed to the point that user space code does not receive
confirmation within it time-out period, both Client and Server
sockets must be torn down. We also must always respond to incoming
ATT Indicate pkt with a Confirmation, as the Error Response is an
illegal response for Indicate.

CRs-Fixed: 363355
Signed-off-by: Brian Gix <bgix@codeaurora.org>
(cherry picked from commit bcdb7e7ed7c6bd659f172d3c19d340947aa84a4b)

Change-Id: If47daa4556cc0f3aa7bda425aa8853d6c73bb4a5
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>

Conflicts:
	include/net/bluetooth/l2cap.h
	net/bluetooth/l2cap_core.c
	net/bluetooth/l2cap_sock.c
radio: tavarua: Add IOCTL to enable the FM TX Tone generator

Implement IOCTL to set the Internal FM TX Tone
generator values

CRs-Fixed: 356789
Signed-off-by: Ayaz Ahmad <aahmad@codeaurora.org>
(cherry picked from commit a0d56b574b8d217b5aecde623da475596db35918)

Change-Id: I92296f6cd867be952b1a0cef2edaa47ae2c10516
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: dsps: Revise handling of PPSS_PAUSE register.

Only modify the PPSS_PAUSE register if the apps processor controls
the DSPS power state. The Linux kernel shouldn't modify the register
if the DSPS is in control of its own power state.

Also move the definition of the PPSS_PAUSE_REG address to the devices
file, since it may be different on different platforms.

CRs-Fixed: 370236
Signed-off-by: Karthik Karuppasamy <kkaruppa@codeaurora.org>
(cherry picked from commit 9dac549aa64d2d86a156a075de1656cfd38fc60a)

Conflicts:

	arch/arm/mach-msm/devices-msm8x60.c
	arch/arm/mach-msm/include/mach/msm_dsps.h
	arch/arm/mach-msm/msm_dsps.c

Change-Id: I6141df35639d77103d94c13e437161b0afe573d6
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
camera: Correct parameter of wait_event_interruptible_timeout.

wait_event_interruptible_timeout takes timeout value in jiffies.

Change-Id: Idbf25653233b34d6105e544a411b49ca81a04a9f
CRs-Fixed: 373576
Signed-off-by: Shuzhen Wang <shuzhenw@codeaurora.org>
msm: pm-8x60: Check for SPM status in msm_pm_verify_cpu_pc

Verify that SPM is in sleep mode in msm_pm_verify_cpu_pc. If not, it is
possible that msm_pm_wait_cpu_shutdown could fail but acpuclock would
turn off the clocks based on the the return value of
msm_pm_verify_cpu_pc.

CRs-fixed: 376791
Change-Id: Id55019508ea9bc27106eb298e19988aecc055cac
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>