msm_serial_hs: Rx discard flush timeout

While configuring the uart buadrate using set_termios
function, timeout is occuring for rx discard flush
operation. This is due to the driver is waiting for
less time for the DMA call back to occur after programing
the DMA register with the discard flush command.

To overcome this issue increased the timeout to 300ms.

Change-Id: I60db1f9eea8bb59fab4024e5f5dfcbcdcde253bb
Signed-off-by: Dilip Kota <c_dkota@codeaurora.org>

Conflicts:
	drivers/tty/serial/msm_serial_hs.c
diag: Bring diag up to date

diag on A-Family mainline is out of date. This change
brings the diag code up to date. This change includes
the following changes:

1. diag: dci: Add new Logs and Events API for DCI
2. diag: dci: Clear DCI Cleint Event/Log mask on Exit
3. diag: dci: Process DCI packet during USB disconnect
4. diag: Fix diag hdlc decoding support for messages starting with 0x7e
5. diag: dci: Remove Event Code from DCI Event
6. diag: Fix incorrect response for Log On Demand request
7. diag: Add concurrency protection to writes on smd data channels
8. diag: Add support for sending DIAG_CTRL_MSG_DIAG_MODE
9. diag: Add Support for Callback mode to communicate with remote processors

Change-Id: Ic61bd3408af4533e5d86d73da73100c3f6c5f215
Signed-off-by: Dixon Peterson <dixonp@codeaurora.org>
diag: Defer usb connect/disconnect processing

USB diag driver will be moving connect/disconnect
event notification from process context to interrupt
context. In order to incorporate that, defer usb
connect/disconnect processing in workqueue context.

CRs-Fixed: 475955
Change-Id: I72f9b5330ac81c78a112212d6bedbe27ddd274cb
Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
diag: Upgrade Diag code on this branch

Diag on A-Family mainline is out of data. This change
includes the following changes to bring diag code up to date.

1. Updated the msg SSIDs, log codes and event IDs
2. Fix concurrency issues when processing userspace inputs
3. Add notification that diag supports feature mask
4. Update SSIDs and log codes
5. Fix writing of error message for mode command
6. Bring diag control message support up to date
7. Updated the msg SSIDs, log codes and event IDs
8. Fix array out of bounds access

This includes a crash fix due to out of bounds access.

CRs-Fixed: 488175

Change-Id: I0b315b5f5da0fecdbbd0cf071e05f2cf3ffd9ccb

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
diag: Fix diag crash due to memory corruption

Diag allocates memory based on the count received from userspace.
Add check to validate the memory pointer before derefencing it.

CRs-Fixed: 487981
Change-Id: Ibfee22d02bb2312192de7c811d9917ecab728269
Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
diag: Add debug prints in error cases

In some error cases, returning error code without printing
any message which makes debugging difficult. Add more
extensive debugging prints in error cases.

Change-Id: I1bc147c4420942ecda953ab512f639f6683e511d
CRs-Fixed: 495436
Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
diag: Fix race condition in diagchar driver

diag driver maintains socket logging process in global driver
structure which is manipulated in switch_logging and in close
file_operation.
There is a possibility of race while clearing the socket logging
process in close operation and sending signal in switch_logging
operation. Adding lock to serialize the two operations.

CRs-Fixed: 495063
Change-Id: I0064509c9ace18a8ff40c5a744363546a9021612
Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
diag: Rate limit few error messages

Some diag error messages are printed with high frequency. This
is causing flooding of kernel logs. Rate limiting these messages
will help reading kernel logs.

Change-Id: Ica7c50cabff494f28de685f47d2cf234badb2e85
CRs-fixed: 511430
Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
diag: Command registration not happening properly

Some CM command registrations are not happening properly
on apps side. This could be because some smd events
for control type were getting missed. Make changes
in order to read pending SMD packets for control
type.

Change-Id: I0fe25455275f6169bee91d151d8657330081c104
CRs-Fixed: 516718
Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
usb: smd: Call smd_close API from workqueue context

smd_close API cannot be called from ATOMIC context, hence move
it from interrupt context to workqueue context.

Change-Id: I9e8ca633f170b48b82f1ead50068b8c7fde5ccff
CRs-Fixed: 419610
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
USB: diag_bridge: Fix a possible freed memory access

The platform device is freed in disconnect.  Don't access pdev
in diag_bridge_delete() which gets called after disconnect. Store
pdev->id in the corresponding driver's private structure.

CRs-Fixed: 470151
Change-Id: I2d97b508f227d6ccc3a87e03481293fa1054bbbc
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
usb: gadget: u_data_hsic: Use GFP_KERNEL where ever possible

The USB requests are allocated using dma pool API.  The dma pool has
limited memory for non-sleeping use case.  The current code does not
free USB requests during subsystem restart.  The requests are freed
only after cable is disconnected.  If subsystem restart happens
multiple  times without disconnecting cable, system may run out of the
dma pool memory.  This is leading to URB submission failures.  Use
GFP_KERNEL where ever possible.

CRs-Fixed: 463423
Change-Id: I0fca533e460e7b4234fe771e048e0e50494cb1da
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
USB: Dump usb info during memory access violation

USB is accessing an invalid memory which results in EBI error.
To find the endpoint information and the address being accessed,
dump all the usb request info required for debugging memory access
violation issue from APP's proc using the trace framework.

CRs-Fixed: 430455
Change-Id: Ie99c31f43dfa9858a9ec2756903574888629e341
Signed-off-by: Chiranjeevi Velempati <cvelempa@codeaurora.org>
Signed-off-by: Rajkumar Raghupathy <raghup@codeaurora.org>
Revert "usb: gadget: rndis: Fix re-binding f_rndis"

This reverts commit 7f141c58da4a6c8920fd6d7051b832e3dec6b877.

This patch should not have been applied in the first place. The USB
string id index is limited to 255.  Function drivers are supposed
to allocate string id for the first time their bind is called.  There
is no API to release string id index.  If string id is reset in unbind,
we will run out of string id after multiple bind/unbind.

CRs-Fixed: 425501
Change-Id: Ia82a528f9e0af192063970a9227c9c739ed77f48
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
USB: android: Fix kernel panic during ACM enable

92fe88c8 commit (usb: gadget: Support multiple HSIC transport
instances for dun and rmnet) introduced a sysfs file called
"transport_names" for DUN and RMNET to accept transport names
from user space.  The transport names are used for registering
platform drivers.  Update ACM function too.  Otherwise NULL
string is used to register platform driver and kernel panics.

CRs-Fixed: 479434
Change-Id: I88b56f252f74bcfb2e664a6e37b64fe224739381
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
USB: gadget: diag: cleanup connect event processing

USB connect event is notified to DIAG in process context.  The
process context is achieved by scheduling a work in connect
interrupt.  But the disconnect event is notified from disconnect
interrupt context.  This is leading to synchronization problems
during fast cable connect and disconnect scenarios.

Notify the connect event from interrupt context.  Updating
product and serial number for every cable connect is redundant.
Move this to bind time and remove config work completely.

CRs-Fixed: 475955
Change-Id: I9d6685f64e0348a63dd88ea36297198ca1fd4596
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
usb: gadget: u_data_hsic: Fix NULL pointer dereference

The port->in and port->out are reset to NULL during disconnect.  The
connect work checks these variables before allocating requests.  Store
port->in and port->out in local variables to free the already allocated
requests before returning.

CRs-Fixed: 488044
Change-Id: Idcdc98e4237b646934c90077a1d58990e853e344
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
ci13xxx_udc: Draw 100mA of current in unconfigured state

As a part of usb enumeration, udc driver is currently notifying the pmic
to draw 0mA of current during usb reset. The pmic driver notifies the
charger driver that usb is in suspend state if <=2mA is notified.
In 8930 targets with real battery connected, USB-CV Enumeration tests
fail after some iterations. The failure logs show an error in SOF frame
number and unexpected chirp sequence.

As a part of USB Reset, instead of notifying PMIC to draw 0mA current,
if we notify to draw 100mA current, then the USB-CV Ch-9 Enumeration
failures are not seen. It seems there is some interference when PMIC stops
charging during USB reset and causing the unexpected chirp sequence
during USB Reset.

In any case, as a part of USB reset or unconfigured state, device can draw
upto 100mA of current from USB bus. Hence notify charging driver with
100mA current draw as a part of USB reset interrupt.

CRs-Fixed: 477655
Change-Id: I2658bd570c500c62705e0c07384d6b5c900f407d
Signed-off-by: Rajkumar Raghupathy <raghup@codeaurora.org>
USB: msm_otg: Allow low power mode with proprietary charger connected

When a proprietary (non-standard) charger is connected, enter low power
mode.  There is no requirement to pull DP to VDP_SRC.  Hence allow PHY
retention and power collapse. Enable PHY asynchronous interrupt for all
cases when PHY comparators are used.

CRs-Fixed: 482226
Change-Id: I54976cabceaa06737e1e5a22313910a3db79ab26
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
EHCI: HSIC: Abort system suspend if controller is outside LPM

98089c0d commit (USB: Prevent system suspend when HSIC device
is active) ensures that USB devices are auto suspended before
system suspend begins.  Apply the same policy to HSIC controller
platform device.  This will cover the corner case where controller
and root hub are resumed after root hub system suspend routine
returns success.

CRs-Fixed: 482498
Change-Id: I604b24775e1c2f52020161c236c44c20d579d5e0
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>