Commit graph

872,947 commits

Author SHA1 Message Date
qctecmdr
86ec4007dd Merge "soc: qcom: add secure processor subsystem (spss) utils driver" 2019-10-29 02:53:30 -07:00
qctecmdr
a9f0122404 Merge "net: qrtr: Fix wakeup_source_register" 2019-10-29 02:03:39 -07:00
qctecmdr
3f1accfe27 Merge "coresight: csr: Add msr support" 2019-10-28 23:37:42 -07:00
qctecmdr
9c547ab7a9 Merge "usb: gadget: Add snapshot of USB QDSS function driver" 2019-10-28 22:56:33 -07:00
qctecmdr
b7c7d57e85 Merge "soc: qcom: Add snapshot of IPC IRQ bridge driver" 2019-10-28 22:18:20 -07:00
qctecmdr
eabf380163 Merge "usb: dwc3: Stop active transfer on control endpoints" 2019-10-28 21:31:48 -07:00
qctecmdr
ccc11220e7 Merge "usb: dwc3: Disable the irq before clearing run_stop bit" 2019-10-28 20:52:45 -07:00
qctecmdr
df67e52b3a Merge "dwc3: gadget: Take copy of dwc->gadget_driver before releasing lock" 2019-10-28 20:16:02 -07:00
qctecmdr
f79c5887a7 Merge "usb: dwc3: gadget: Enable SUSPEND event after CONNECT DONE" 2019-10-28 19:37:38 -07:00
qctecmdr
b8e7366b19 Merge "usb: dwc3: Check return value for debugfs_create_dir()" 2019-10-28 19:01:56 -07:00
qctecmdr
08baf0afb0 Merge "usb: dwc3: gadget: Ensure no control transfers in progress when stopping" 2019-10-28 18:27:33 -07:00
qctecmdr
f8d14ce83a Merge "usb: dwc3: gadget: Fix runtime PM vote from pull_up handler" 2019-10-28 17:50:56 -07:00
qctecmdr
79600075fb Merge "usb: dwc3: Avoid NULL pointer access" 2019-10-28 17:12:01 -07:00
qctecmdr
dd5ffe4e30 Merge "usb: dwc3: request 2mA VBUS current when suspending" 2019-10-28 16:23:05 -07:00
qctecmdr
ca12b166a0 Merge "usb: dwc3: Add support for PM suspend and hibernation in host mode" 2019-10-28 15:41:38 -07:00
qctecmdr
10004e7945 Merge "usb: dwc3: ep0: Fail enqueue() when racing with vbus_sess disconnect" 2019-10-28 15:02:03 -07:00
qctecmdr
9c6f55fcd1 Merge "dwc3: gadget: Don't queue USB request if pull up is getting disabled" 2019-10-28 14:27:55 -07:00
qctecmdr
310a5c3075 Merge "usb: dwc3: Fix USB gadget initialization sequence" 2019-10-28 13:39:03 -07:00
qctecmdr
6d73fbad77 Merge "usb: dwc3: Avoid NULL pointer access in dwc3_calc_trbs_left" 2019-10-28 13:03:02 -07:00
qctecmdr
8d79cb85f0 Merge "usb: dwc3: Do not traverse list using list_for_each_safe" 2019-10-28 12:27:37 -07:00
qctecmdr
3c7ed8087d Merge "usb: dwc3: gadget: delay clearing run/stop when setup just arrived" 2019-10-28 11:47:22 -07:00
qctecmdr
dc87488bd4 Merge "dwc3: gadget: Stop active transfer pending on ep0 out/in during reset" 2019-10-28 11:08:09 -07:00
qctecmdr
c2e15eef58 Merge "usb: dwc3: Fix incorrect ep0 state on reset" 2019-10-28 10:32:57 -07:00
qctecmdr
a7d5a85aa0 Merge "usb: dwc3: resize txfifo of IN/INT endpoint before enabling it" 2019-10-28 09:55:51 -07:00
qctecmdr
4c196dd091 Merge "usb: dwc3: Add QTI MSM platform specific feature and other changes" 2019-10-28 09:24:14 -07:00
Konstantin Dorfman
d50cfdc312 soc: qcom: add secure processor subsystem (spss) utils driver
The spss-util driver provides utilities required for the Secure
Processor Subsystem (SPSS). It provides the fuse state for key selection
and the SPSS HW version.

Add snapshot for spss-util driver from msm-4.19 commit a7793b40172f
("soc: qcom: spss_utils: fix spss SSR when IAR not active").

Change-Id: I6531cae56cec9d062fa03c573bcd70207d10f1a2
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
2019-10-28 13:29:59 +02:00
qctecmdr
86cb2da52a Merge "ASoC: Add a debug message to track widget power up/down" 2019-10-27 20:51:11 -07:00
qctecmdr
f53b149a86 Merge "ASoC: Change info logs to debug" 2019-10-27 20:13:16 -07:00
Tingwei Zhang
79a2734194 coresight: csr: Add msr support
SWAO msr has been moved to SWAO csr. Add the support in driver
to program it.

Change-Id: Ied618265a117a5fcd385524e1ec9aa4ce4e84deb
Signed-off-by: Tingwei Zhang <tingwei@codeaurora.org>
2019-10-27 19:40:54 -07:00
qctecmdr
6c77d64802 Merge "msm: qdsp6v2: Add timestamp support for compress capture" 2019-10-27 19:32:59 -07:00
qctecmdr
18dc13d57e Merge "msm: ipa3: Query stats from Q6 NLO PROD/CONS" 2019-10-27 02:42:23 -07:00
Hemant Kumar
e189769e47 usb: dwc3: Stop active transfer on control endpoints
If cable disconnects before data stage completion dwc3_remove_requests()
gets called for ep0 in and out but dwc3_ep0_complete_data() does not
get called. dwc3_ep0_complete_data() function resets TRB enqueue count
to 0. As a result upon next cable connect start transfer is called with
wrong TRB address because trb_enqueue is set to 1. Since this TRB was
completed in the past, HWO bit is cleared for this TRB. This results into
usb enumeration failure due to control transfer stall. Fix this issue
by issuing end transfer command on control endpoints after ep0 requests
are removed for IN and OUT and reset trb_enqueue counters to 0.

Change-Id: Ic5364f11372d85ec7c133024dc48bbc5d848ebf4
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:03 -07:00
Chandana Kishori Chiluveru
8ef037cd20 usb: dwc3: Disable the irq before clearing run_stop bit
Consider a case of quick pull-up disable after pull-up is enabled.
If a SETUP packet comes after bus reset event followed by connection
done event, there is a possibility of race between
composite_dev_cleanup() freeing cdev->req called from
configfs_composite_unbind() and composite_setup() storing req pointer
to stack. This causes use after free of cdev->req. Fix this issue by
disabling the irq before clearing the run-stop bit so that interrupt
handling for setup packet is prevented. In order to prevent running
bottom half check pullups_connected flag in dwc3_interrupt and ack
the generated events and return. Also flush the bottom half work
if there was any work pending before disabling dwc3 irq.

Change-Id: I979da8536bd6766153e25cf6120f00f348427a72
Signed-off-by: Chandana Kishori Chiluveru <cchiluve@codeaurora.org>
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:03 -07:00
Mayank Rana
0f35545c3f dwc3: gadget: Take copy of dwc->gadget_driver before releasing lock
gadget_driver can become null if gadget_stop is called while any other
gadget callbacks are in progress. As gadget callbacks needs to release
spinlock before the callback, store the local copy of gadget_driver to
avoid the race with gadget_stop.

Change-Id: I7f0cbf9af3e3b286f2826647f08215f29f699de1
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:03 -07:00
Jack Pham
c36156c78d usb: dwc3: gadget: Enable SUSPEND event after CONNECT DONE
Spurious suspend event may arrive before CONNECT DONE, which
may unnecessarily notify to the charger to reduce current
draw to 2mA, only to revert back to 100mA on the subsequent
reset & connection. Instead, only enable the SUSPEND event
interrupt after the initial CONNECT DONE event is handled.

Change-Id: I41e2ff5d9b693757e06059c98fbe8b3a3878abdd
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:03 -07:00
Hemant Kumar
6f78412e23 usb: dwc3: Check return value for debugfs_create_dir()
debugfs_create_dir() returns NULL when second directory is created
with same name gsi-epin. Without checking return value
dwc3_debugfs_create_endpoint_dir() creates endpoint files with parent
as NULL. This would create files in root dir /sys/kernel/debug which
remains there even after calling debugfs_remove_recursive() from
dwc3_debugfs_exit(). Due to probe deferral dwc3 endpoints get freed
up and re-allocated. As a result accessing endpoint files created in
root dir causes access to stale dwc3 endpoint pointer. Hence check
return value for debugfs_create_dir and do not create files for NULL
parent.

Change-Id: I44b65b77f35be1a52e71db2184a359887c25c8c9
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:03 -07:00
Jack Pham
6f3c403700 usb: dwc3: gadget: Ensure no control transfers in progress when stopping
When dwc3_gadget_pullup() is called to perform a device-initiated
disconnect, the driver must ensure that no transfers are in progress
before clearing the run/stop bit. Currently there is a check which
ensures ep0 is in EP0_SETUP_PHASE and if not simply waits for any
pending control transfer to conclude and return to that initial state.
However, since this is done before the dwc->lock is acquired, this
allows for a race in which a new ep0 transfer gets started and we
receive another SETUP packet from the host before proceeding to take
the lock.

To fix this, simply don't allow a new ep0 transfer to start if
dwc->softconnect is false.

Change-Id: Ie79c99bfa2b305ef44695d01b3f9395253aaf8f8
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:03 -07:00
Manu Gautam
90f8961b8a usb: dwc3: gadget: Fix runtime PM vote from pull_up handler
If gadget driver's request for removing pull_up fails due to
EP0 not in setup phase, then driver ends up bailing out
without removing it PM usage_count vote.
This will prevent DWC3 from entering low power mode and
subsequent start_peripheral/host would also won't be
allowed as LPM entry is mandatory for that.

Change-Id: Id1dde0dcf379a1f6b9567d63c0b1d31445c30d0d
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:02 -07:00
Pratham Pratap
1e3f5743e6 usb: dwc3: Avoid NULL pointer access
During Halt Endpoint CH9 test with RNDIS composition
NULL pointer dereference is occurring in
__dwc3_gadget_ep_set_halt function which is trying to
access trb_pool which is already freed. In this case
set_alt 0 is getting called before__dwc3_gadget_ep_set_halt.
As a part of set_alt, ipa_disconnect_handler is getting
called which is freeing the trbs. __dwc3_gadget_ep_set_halt
function is called as a part of std_request from Host side
to halt endpoint. This change adds a NULL check before accessing
trb_pool.

Change-Id: Id51494310f713b9c593e29449442661a1170ee6f
Signed-off-by: Pratham Pratap <prathampratap@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:02 -07:00
Jack Pham
2d5b401286 usb: dwc3: request 2mA VBUS current when suspending
In case a SUSPEND (L2 or U3) event is detected but the device is
not yet enumerated/configured, the device must still follow USB
power rules and limit its current draw to ISUSP (2.5mA). Notify
the gadget when this happens, which in turn will notify the
charger driver.

Change-Id: I10d890aabd78d841027b370eb62005d2e35e2a38
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:02 -07:00
Ajay Agarwal
1bc26ade8a usb: dwc3: Add support for PM suspend and hibernation in host mode
DWC3 driver uses wakeup_source and allows pm_suspend only after
entering low power mode as part of runtime suspend. This prevents
PM suspend in host mode if connected device's driver doesn't
support runtime or selective suspend.
For platforms such as automotive, add support in driver where
user can specify using dtsi attribute to not use wakeup source in
host mode. It will allow system to enter deep sleep or pm_suspend
irrespective of runtime PM state of XHCI. The connected devices
are also reset-resumed on PM resume.
On high level below are the changes in default behavior:
 -Do not use wakeup_source for DWC3 when operating in host mode.
 -For host mode, devices will suspend upon PM suspend and
  reset-resumed on PM resume.

Change-Id: I8a3d744a1d9d714f17a0cfe4ff5b69b04d9f763f
Signed-off-by: Ajay Agarwal <ajaya@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:02 -07:00
Elson Roy Serrao
904ab34b54 usb: dwc3: ep0: Fail enqueue() when racing with vbus_sess disconnect
When the setup packet comes right before the disconnect notification
there is a possible race between clearing the run stop bit and
enqueuing the setup packet. This results in controller halt failure.
Add a vbus_active check before enqueuing the packet to fix this issue.

Change-Id: I3921a1fa92a0f5c6892f1cc3ffe9dda6366b72b1
Signed-off-by: Elson Roy Serrao <eserrao@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:02 -07:00
Mayank Rana
6e65b88e7d dwc3: gadget: Don't queue USB request if pull up is getting disabled
There is possible race between pull up disable vs ep_queue() API.
Pull up disable sends END transfer command to per endpoint, and give
back started request and pending request back to function driver.
dwc3_gadget_giveback() API does release spinlock which may allow
ep_queue() or completion handling to queue next request. This results
into TRB pending without invoking end transfer command, whereas request
is being given back to function driver and being freed. Hence on setting
next pull up enable, USB controller accesses previous stale TRB causing
unmapped page fault. Fix this issue by checking pull up disable or not
while handling ep_queue().

Change-Id: I391aed05cbfe183cd3e2fe2f1aa335e4fd9ec37c
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:02 -07:00
Mayank Rana
47636fc5a2 usb: dwc3: Fix USB gadget initialization sequence
This change fixes below issues:
1. registering UDC driver with udc core with dwc3 probe itself, so USB
composition script can find UDC device while trying to select UDC.
2. creation of required USB endpoints related debugfs entries useful for
debugging.
3. USB high speed only functionality fallback mechanism when USB super
speed phy is not initialized.

Change-Id: I893e6221ceb6af448695f5399e857be0c25f41b1
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:02 -07:00
Pratham Pratap
7972f5f996 usb: dwc3: Avoid NULL pointer access in dwc3_calc_trbs_left
dwc3_calc_trbs_left function is calling dwc3_ep_prev_trb
which can return NULL if trb pool is empty. This change adds
check for the return value of dwc3_ep_prev_trb function to
avoid NULL pointer dereference.

Change-Id: Id11d5ffd23da7c070d5e0b26842d8738b073b212
Signed-off-by: Pratham Pratap <prathampratap@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:02 -07:00
Hemant Kumar
bd1c66bfdb usb: dwc3: Do not traverse list using list_for_each_safe
There is a possibility of race between endpoint transfer
completion context and stop active transfer context. As
a result dwc3_gadget_ep_cleanup_completed_requests() iterates
over started_list using list_for_each_safe while
dwc3_remove_requests() is deleting req from started list.
While iterating over current list node list_for_each_safe caches
next list node. If the cached list node is getting deleted by
dwc3_remove_requests() then request for same list node would be
given back as part of endpoint transfer completion. This result
into list_del corruption because list node is getting deleted
twice. Fix this issue by iterating started_list using while loop
and always accessing first node from list head.

Change-Id: I64104a43ade015923deeb1f230a17dea08817052
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:02 -07:00
Jack Pham
44775a35a9 usb: dwc3: gadget: delay clearing run/stop when setup just arrived
There still exists a small window in which dwc3_gadget_pullup()
is called while a new control transfer setup packet had newly
arrived. In the case where it needs to be delegated to the gadget
driver, it releases dwc3->lock and allows pullup() to proceed to
call run_stop() to attempt to stop the controller. The lock will
get released again when calling dwc3_stop_active_transfers()
which allows the gadget driver to meanwhile call ep_queue() for
a three-stage control transfer and sneak in a Start Transfer. By
the time the DCTL register is written, the controller will fail
to halt due to having an outstanding transfer in progress.

CPU0                               CPU1
...dwc3->lock held...
dwc3_ep0_inspect_setup()           dwc3_gadget_pullup()
 dwc3_ep0_delegate_req()            spin_lock_irq_save()
  spin_unlock()                     ... unblocked
   composite_setup()                dwc3_gadget_run_stop()
    usb_ep_queue()                      dwc3_stop_active_transfers()
     dwc3_gadget_ep0_queue()          dwc3_gadget_remove_requests()
      spin_lock_irqsave()              dwc3_gadget_giveback()
      ... unblocked                     spin_unlock()
       __dwc3_ep0_do_control_data()     spin_lock()
        issues Start Transfer
      spin_unlock_irqrestore()          ... unblocked
  spin_lock()                        clear DCTL_RUN_STOP
  ...                                wait for DSTS_DEVCTRLHLT
                                     time out

This change attempts to fix the issue by additionally checking
the dwc->ep0_next_event state in dwc3_gadget_pullup() to catch
the case when a SETUP packet had just been received and handled
by dwc3_ep0_inspect_setup but is still waiting to proceed to
either a DATA or STATUS stage. This allows pullup() to wait for
completion of the transfer before moving on to clear run/stop.

Change-Id: Ib2da3c86213ade1a61fb82f95a1f7c9534d9df3f
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:02 -07:00
Vijayavardhan Vennapusa
d0acc50c66 dwc3: gadget: Stop active transfer pending on ep0 out/in during reset
if USB bus reset is received from Host in middle of control transfer
request, SW needs to complete pending control transfer and setup core
for next setup stage as per data book. Hence check ep0 state during
reset interrupt handling and make sure active transfers on ep0 out/in
endpoint are stopped by queuing ENDXFER command for that endpoint
and restart ep0 out again to receive next setup packet.

Change-Id: Idf8adf3c2416e7945d879bf88c321e1eea3c31d4
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:02 -07:00
Sriharsha Allenki
f7a9e06d4f usb: dwc3: Fix incorrect ep0 state on reset
According to the databook ep0 should be in setup
phase during reset. If host issues reset between
control transfers, ep0 will be  in an invalid state.
Fix this my issuing stall and restart on ep0 if it
is not in setup phase.

CRs-Fixed: 2136658
Change-Id: I6dc20c2735a6ce772533ccb5b63ba5d1b01f89d7
Signed-off-by: Sriharsha Allenki <sallenki@codeaurora.org>
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:01 -07:00
Mayank Rana
ec2321135d usb: dwc3: resize txfifo of IN/INT endpoint before enabling it
USB IN/INT endpoint stalls when performing TX FIFO resize functionality
when IN/INT endpoint is already active i.e. usb endpoint is enabled and
usb request is pending with it. Fix this issue by making sure that TX
FIFO resize is performed before enabling endpoint which shall happen
after set_alt(1) and before any function queues request with its
allocated USB endpoint.

This commit also squashes the following commits from previous kernels:

  Revert "usb: dwc3: drop FIFO resizing logic"
  dwc3: gadget: Improve TX FIFO resize functionality
  dwc3: gadget: Use default TX FIFO size as 1024 bytes with each IN eps
  usb: gadget: Use mult as 3 for GSI related USB IN endpoint always
  USB: dwc3: gadget: Fix TxFIFO resizing logic
  dwc3: Preserve TxFIFO of IN/INT EP for UDC without tx-fifo-resize
  dwc3: gadget: Use TXFIFO register based on used dwc3 version
  dwc3: gadget: Increase TXFIFO size as 6KB for GSI IN endpoint
  usb: dwc3: Change TXFIFO size for GSI IN EP based on controller
  usb: dwc3: gadget: Fix TXFIFO resize logic for non-zero EPs
  usb: dwc3: Increase the TxFIFO resize factor

Change-Id: I13a590f87ab8492f7c95a15b2da9f00c9c63c4f9
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2019-10-26 23:24:01 -07:00