Modifyed mako_defconfig for inline
Add custom Mako Hotplug driver for onlining and offlining cores based on system load.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
mako_hotplug: fix some bugs, increase load levels by 10% each, queue the works in a dedicated workqueue, reduce the number of divisions every work call, fix a possible memory leak.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
usb: ks_bridge: Check for received data upon unlinking the urb

There is a possibility of runtime suspend in the middle of
data transfer on the rx data path of driver. This results in
the completion of data transfer on bulk IN endpoint with short
packet or integral multiple of 512 bytes. Hence for -ENOENT
transfer status check for non-zero data length and pass it to
the consumer in the userspace. Also, replace printk with
DBG-level message in driver suspend function and in rx
callback function for -EPROTO urb status.

CRs-Fixed: 394954
Change-Id: I26f4081869377000d163649b3a860386ff9c3806
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
usb: ks_bridge: Add support for autosuspend

ks bridge driver needs to add support for autosuspend
for 9008 PID. This change allows for the device to be
suspended when there is no active traffic, and USB
remote wakeup is used to signal a resume to the host.

CRs-Fixed: 397969
Change-Id: Id4f1083c7f136e027778c1d6b08f3b3a6048f7e7
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
usb: ks_bridge: Fix memory leak in tx data path

ks bridge is allocating urb to transmit data to mdm.
This urb is not getting freed after transmit completes.
Hence call usb_free_urb() after urb gets submitted
successfully. Urb will eventually be freed after tx
completion.

CRs-Fixed: 401536
Change-Id: I7e0bc7d1de74613f6b3b019d1513e22ad9765709
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
usb: ks_bridge: Fix bug in partial read on data buffer

If driver copies only partial data buffer to user space
it does not update the buffer pointer. In this case
buffer pointer is still pointing to the already read
buffer and will be copied again in next read request
from user space. This corrupts the contents of the
efs file or ram dump files. Hence update data buffer
pointer with length of memory read completed by user
space.

CRs-Fixed: 403250
Change-Id: I48217aeeb2ee5ad05089922c6a7793195b95ce0c
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
usb: ks_bridge: Synchronize disconnect with ongoing IO

Following scenarios possible for interface disconnect racing
with ongoing IO:-

1) Interface disconnect setting interface pointer to NULL and
rx work is executing on other core dereferencing interface
pointer, causing kernel panic. Cancel a work and wait for it
to finish during disconnect.

2) Interface disconnect setting interface pointer to NULL and
tx completion running on other core dereferencing interface
pointer while calling usb_autopm_put_interface_async() API.
Check for USB_DEV_CONNECTED flag(cleared at the time of
disconnect) before dereferencing the interface pointer.

3) Interface unbound and driver is accessing already freed
interface pointer in tx completion or usb device pointer to
re-submit rx urb in rx completion. Add rx and tx urb pending
counters and wait for them to become zero (or timeout) during
disconnect.

Change-Id: I75c0284136dda8b0e1b76c326e80e0c3efb41d5c
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>

&&

usb: ks_bridge: Fix memory leaks in the driver

This change addresses two memory leaks:-
1) misc device is not getting deregistered during device
disconnect. Hence call misc_deregister() in disconnect.

2) Driver returns without freeing previous instances of
the driver data structure if memory allocation fails. Hence
free up memory allocated for ks_bridge structure.

Change-Id: I90133a002aa9d38597de8d1b21d3aad621552d46
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
usb: ks_bridge: Free up stale buffers in probe

Driver can add data buffer to the link list of rx/tx
buffers after emptying the list during disconnect.
These stale buffers can confuse efs sync server when
mdm device connects back. Hence free up the rx/tx
buffers again during probe. Avoid further addition of
tx buffers after disconnect by checking device
connection status in write API. Also, move
misc_deregister() after cancelling the work in order
to remove device node early during disconnect to avoid
any write call further.

Change-Id: I0641669afcf1e1aec36d7c619dc8922495f446d0
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
HSIC: Add support for product id 9075

Product Id 0x9075 includes DIAG, SER3(System monitor), SER4(EFS sync),
DUN, CSVT, NET1(Tethered RmNet) + NET2(Muxed Embedded RmNet) device
interfaces.

Change-Id: I75f61445af0ff9eab3d8f22bc2239011a9495e0e
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
usb: ks_bridge: Avoid allocating large buffers in atomic context

The current code allocates a new Rx buffer in Rx completion handler.
Rx buffers are freed after user space consumes them.  This results in
allocating larger buffers in atomic context which may fail some times.
Don't queue the Rx buffer immediately. Defer it till user space consumes
it and reuse the same buffer.  The test results indicate no throughput
degradation.  The Rx buffers will be freed when interface is suspended
or disconnected.

CRs-Fixed: 430595
Change-Id: I8e69e27df2e11b38497e0384a8edd87ecedcb24b
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
usb: ks_bridge: Add efs sync support for PID 0x9075

Driver needs to claim efs sync interface for PID 0x9075
at the time of driver probe.

Change-Id: Idd637aa04eab7babe509a4fbfc3671555dcca189
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
usb: ks_bridge: Limit write size to 16KB

The user space application writes in 1MB chunks while loading MDM
images.  The current code allocate as many bytes as user space
passed to write system call.  These allocations are failing under
memory fragmentation scenario.  Hence limit write size to 16KB.

CRs-Fixed: 434638
Change-Id: Ibfad0f13c1fb2c30342d2435114001c580143292
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
USB: ks_bridge: Fix PM usage counter mismatch

The runtime PM is disabled for a device during suspend.  It is
enabled again just before resuming  the device.  The resume method
of USB interface drivers are called while resuming a USB device.  As
USB device is the parent of an interface, the interface resume is
blocked till USB device resume is completed.  If interface driver
call any runtime PM API before interface runtime PM is enabled, it
fails with -EACCESS error.

The USB runtime wrapper usb_autopm_get_interface() decrements PM usage
counter when get_sync() is failed.  The current code is decrementing
the PM usage counter even when an error code is returned from
usb_autopm_get_interface().  Due to this double decrementing, the KS
bridge interface PM usage counter is becoming negative after several
suspend and resume cycles.  Once the PM usage counter becomes negative,
the interface runtime PM state will never become active.  That means,
USB device suspend can happen even when a Tx URB is pending from ks
bridge driver.

The fix is trivial.  Don't decrement PM usage counter when error code
is returned from usb_autopm_get_interface().

CRs-Fixed: 437214
Change-Id: Ib2ab8df6d62488bf9ffd659b39078de904e8d680
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
usb: ks_bridge: Add support for multiple instance of driver

ks bridver needs to get loaded for two mdm9x15 device enumeration
to support flashless boot and efs sync.

Change-Id: I4316fe74a311a26042e60787cb0b27fcd2df3cb9
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
USB: ks_bridge: Prevent freeing buffers while copy is in progress

The completed read buffers are added to to_ks_list in Rx URB
completion handler.  The buffer is deleted from this list by
reader process after copying to user space buffer.  If disconnect
happens during this copy, the buffer is freed from disconnect
context.  Hence detach the buffer from to_ks_list before copying
to user space buffer.

CRs-Fixed: 448142
Change-Id: Id5ec904da0c9db427feff5a0165f98660aed0dee
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
USB: ks_bridge: Enable autosuspend only for remote wakeup capable devices

USB core marks a device wakeup capable if it supports remote wakeup.
Check this wakeup capable flag before enabling autosuspend.

CRs-Fixed: 449097
Change-Id: I055bf5801859e4d83782916c71e0245c455becbf
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
mako_hotplug: online cpu1 on screen on to remove the lag, also merge the cpu max freq cap from the video driver to this driver. A bunch of other small fixes as well.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>