msm: acpuclock: Fix acpuclk_get_rate

acpuclk_get_rate() is broken, quick fix it by returning msm_cpufreq_get_freq
to avoid regressions.

Change-Id: I148bd9dd46aa34501c164abefa21623500cd5def
Revert "Linux 3.4.83"

This reverts commit 2645069478c7244342650251f8e0d5e3f3f0d7e1.
USB: msm_otg: Fix race between PM resume and charger detection

When device is in system suspend and USB charger is disconnected,
then due to VBUS clear IRQ from PMIC, the device will be PM resumed.
Now shortly if PMIC driver detects valid VBUS it will handle VBUS
set condition,notifies to msm_otg and msm_otg will kick in charger
detection mechanism. During PM resume, in dmp_complete() it will
call a pm_runtime_put_sync(), which will immediately kick off the
PM runtime idle and suspend routines.
dpm_complete()
  ->device_complete()
    ->pm_runtime_put_sync()
      ->rpm_idle()
        ->rpm_suspend()

The PM resume also runs in a separate worker queue, so it is not
guaranteed that it will finish executing before we finish the charger
detection stage. During this case there is a race if dpm_complete()
returns before charger detection starts. Return of dmp_cpmplete()
before charger detection will make USB to enter LPM. As USB will be
in LPM now and if charger detection starts then it will lead to
unclocked access.

Fixing the issue by handling the pm usage count using the variable
pm_done in msm_otg. When USB charger is disconnected and msm_otg
processes the disconnect event it marks the pm_done to true. Later
when USB charger is connected , mark the pm_done to false in
msm_otg_runtime_resume(). If pm_done is true increment the pm counter
using pm_runtime_get_sync. This handles the race case when PM resume
thread returns before the charger detection starts.

CRs-Fixed: 599143
Change-Id: I6de19fe850e24efa03ea71c7d14e388c15cf2f97
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
usb: f_qc_rndis: Correct SSUSB descriptor with IAD information

Currently SSUB descriptor is using rndis.c related descriptor
which is not being updated at binding time. Hence windows host
is not able to load RNDIS driver identifying both Control and
Data Interfaces. Update the same which is being updated and used
by qc_rndis.c file to resolve this issue.

Change-Id: I6788059bf247dc5f767970ef76a10351ed83dbb1
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
usb: misc: mdm_ctrl_bridge: Honor device polling interval

Driver is not using polling interval from device end point
descriptor. Instead driver is using hard coded value which
is inconsistent with the polling frequency required by the
endpoint of the device. If device requires polling interval
shorter than hard coded value it leads to latency to the
end to end communication. Hence use polling interval from
endpoint descriptor of attached device.

Change-Id: Ifdd7c8d6bf7c56c9285bbbd84cd447214b0cf242
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
usb: dwc3_otg: Turn on VBUS before starting host

Currently the VBUS regulator is enabled only after initializing
the xHCI host stack, which can result in enumeration failures
for certain devices. This is likely due to VBUS having a
finite rise time when it is turned on, especially when a load
is already attached. Mitigate this by enabling VBUS first before
starting the host stack.

CRs-Fixed: 599498
Change-Id: I9785ae4682d0a2dfbcec921b869fc03550e0db82
Signed-off-by: Jack Pham <jackp@codeaurora.org>
USB: dwc3: debugfs: Enable logging of control endpoint events by default

Enable logging of EP0 control events, which will be useful for analyzing
the USB issues like crash. Also add more required events wherever required.

Change-Id: I0fd3edfa2cd8711928cd480e99abbf8e6f907774
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
usb: gadget: mbim: protect packets queue corruption

The f_mbim usb function driver maintain a packets queue sent from the
host as encapsulated commands which need to be read by the QBI using the
mbim_read fops.

In case of excessive messages arriving from the host we end up with simple
race condition between the queue writer and queue reader which end up in
corruption of the queue and packet loss.

Simply add a missing lock protection upon reading (deleting) a packet from
queue.

CRs-Fixed: 576720
Change-Id: I8aff04745f02cbefd3d6b83d944cad9aa1726ebf
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
USB: msm_otg: Print warning message when not able to turn USB CLKs

This change prints warning message failures with call stack when
not able to turn ON USB core_clk and pclk in msm_otg_resume() and
msm_otg_link_clk_reset()

CRs-Fixed: 612896
Change-Id: I9f53751b9ff0254205231656e01ed84302067bef
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
USB: gadget: ether: Fix memory corruption issues with multi_pkt_xfers

If gadget xmits packets before host sends RNDIS_MSG_INIT to update
maximum packets supported per transfer, then there is a possibility
of using freed skb memory later from xmit function. Fix such
races which may arise between tx_complete and start_xmit routines
depending on when multi_pkt_transfers are enabled.
Other option is to defer starting TX transfers until RNDIS_MSG_INIT
is received, but then it makes it difficult to handle scenarios
where host doesn't support this message or just doesn't send it.

CRs-fixed: 595367
Change-Id: I181da831120b38840ae4b8b74c1dacce129d1ba6
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
USB: dwc3-msm: Add support for new ioctl for voltage request

Add support for new ioctls for userspace to let kernel driver
know about new voltage request being negogiated and also result
whether the request is successful or not, when HVDCP charger is
connected.

Change-Id: I9f36949fc7888274171aa1724da45a11704b7fec
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
USB: msm_otg: Add support for new ioctl for voltage request

Add support for new ioctls for userspace to let kernel driver
know about new voltage request being negogiated and also result
whether the request is successful or not, when HVDCP charger is
connected.

Change-Id: Ie7271cc2dea082ceb33d67f0b4d2959ed977b618
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
USB: dwc3-msm: Implement VOLTAGE_NOW property for usb power supply

Implement VOLTAGE_NOW property for power supply so that usb_in
value can be read at any time through this sysfs entry by
userspace.

To read usb_in value,
	cat /sys/class/power_supply/usb/voltage_now

CRs-Fixed: 599547
Change-Id: I106ce9219c7a04c2b7436221732a6fca0cc85245
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
USB: msm_otg: Implement VOLTAGE_NOW property for usb power supply

Implement VOLTAGE_NOW property for power supply so that usb_in
value can be read at any time through this sysfs entry by
userspace.

To read usb_in value,
	cat /sys/class/power_supply/usb/voltage_now

CRs-Fixed: 599547
Change-Id: I8f9bf4077282fbe32304b667793dab8009e68243
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>

Conflicts:
	drivers/usb/otg/msm_otg.c
slim_msm: ngd: Return success for channel removal during ADSP SSR

Slimbus master component resides on ADSP when this driver is used.
Wehn ADSP restarts, slimbus component goes down and bus is not
operational until it comes back up. During restart, slimbus clients
are notified since their device goes down, and the clients remove
channels and/or disconnect ports. Since bus is not operational,
return success for channel removal/port disconnection calls so that
the channel, port state is consistent with HW (not active, removed)

Change-Id: Ia2707ed9f3fc3573b5746c8e42fa7f229e0dea4f
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
slim_ngd: Return success for resource removal requests if HW restarts

Channel and ports are removed when HW restarts. Return success to
client channel removal, port disconnection requests when slimbus HW
is restarting.

Change-Id: Ifc9a3bb80023c823a7776a16fe32e5b59b181350
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
slim_ngd: Fix logical address notification mechanism

It's possible that multiple slaves report present and expect
corresponding notifications concurrently. Make sure notifications
are sent out in that case. Since notifications cannot be sent when
device doesn't have associated driver, make sure logical address
is not queried in that case.

Change-Id: I371c48d25a0953f5f1909c904e8fd80b599d16b3
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
slim_ngd: Handle runtime-pm resume error gracefully

Runtime-pm resume for satellite driver may fail if ADSP is going
through subsystem-restart. Handle that error, and set runtime-pm's
status to suspended if resume fails. Resume typically fails due to
failure to wake slimbus from pause_clock. Make sure another wakeup
can be tried later when ADSP comes back up

Change-Id: Ie9b798f5506de89a37491dbc3798acaa24b98808
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
slimbus: Manage channel slots only if framework manages bandwidth

If slimbus controller overrides bandwidth management, channel slots
should not be managed since controller is expected to do that.
Slimbus controller will go into idle mode due to this change when
channel setup/teardown is done. Make sure controller can transition
states correctly in runtime-pm suspend, and system-suspend case.

Change-Id: Id41aed822e3c98af8c1fe7db3a3527a1206739be
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
slim_msm: Rectify physical address type

Make sure physical address type is of correct type.

Change-Id: I9ec7a846e0fc14efd3627d141bb2228c8e56b2cc
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>