mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-04 22:16:40 +07:00
678539cfaa
In the old code, there was a race condition between the stop endpoint command and the URB submission process. When the stop endpoint command is handled by the event handler, the endpoint ring is assumed to be stopped. When a stop endpoint command is queued, URB submissions are to not ring the doorbell. The old code would check the number of pending URBs to be canceled, and would not ring the doorbell if it was non-zero. However, the following race condition could occur with the old code: 1. Cancel an URB, add it to the list of URBs to be canceled, queue the stop endpoint command, and increment ep->cancels_pending to 1. 2. The URB finishes on the HW, and an event is enqueued to the event ring (at the same time as 1). 3. The stop endpoint command finishes, and the endpoint is halted. An event is queued to the event ring. 4. The event handler sees the finished URB, notices it was to be canceled, decrements ep->cancels_pending to 0, and removes it from the to be canceled list. 5. The event handler drops the lock and gives back the URB. The completion handler requeues the URB (or a different driver enqueues a new URB). This causes the endpoint's doorbell to be rung, since ep->cancels_pending == 0. The endpoint is now running. 6. A second URB is canceled, and it's added to the canceled list. Since ep->cancels_pending == 0, a new stop endpoint command is queued, and ep->cancels_pending is incremented to 1. 7. The event handler then sees the completed stop endpoint command. The handler assumes the endpoint is stopped, but it isn't. It attempts to move the dequeue pointer or change TDs to cancel the second URB, while the hardware is actively accessing the endpoint ring. To eliminate this race condition, a new endpoint state bit is introduced, EP_HALT_PENDING. When this bit is set, a stop endpoint command has been queued, and the command handler has not begun to process the URB cancellation list yet. The endpoint doorbell should not be rung when this is set. Set this when a stop endpoint command is queued, clear it when the handler for that command runs, and check if it's set before ringing a doorbell. ep->cancels_pending is eliminated, because it is no longer used. Make sure to ring the doorbell for an endpoint when the stop endpoint command handler runs, even if the canceled URB list is empty. All canceled URBs could have completed and new URBs could have been enqueued without the doorbell being rung before the command was handled. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> |
||
---|---|---|
.. | ||
whci | ||
ehci-atmel.c | ||
ehci-au1xxx.c | ||
ehci-dbg.c | ||
ehci-fsl.c | ||
ehci-fsl.h | ||
ehci-hcd.c | ||
ehci-hub.c | ||
ehci-ixp4xx.c | ||
ehci-mem.c | ||
ehci-omap.c | ||
ehci-orion.c | ||
ehci-pci.c | ||
ehci-ppc-of.c | ||
ehci-ps3.c | ||
ehci-q.c | ||
ehci-sched.c | ||
ehci-w90x900.c | ||
ehci-xilinx-of.c | ||
ehci.h | ||
fhci-dbg.c | ||
fhci-hcd.c | ||
fhci-hub.c | ||
fhci-mem.c | ||
fhci-q.c | ||
fhci-sched.c | ||
fhci-tds.c | ||
fhci.h | ||
hwa-hc.c | ||
isp116x-hcd.c | ||
isp116x.h | ||
isp1362-hcd.c | ||
isp1362.h | ||
isp1760-hcd.c | ||
isp1760-hcd.h | ||
isp1760-if.c | ||
Kconfig | ||
Makefile | ||
ohci-at91.c | ||
ohci-au1xxx.c | ||
ohci-dbg.c | ||
ohci-ep93xx.c | ||
ohci-hcd.c | ||
ohci-hub.c | ||
ohci-lh7a404.c | ||
ohci-mem.c | ||
ohci-omap.c | ||
ohci-pci.c | ||
ohci-pnx4008.c | ||
ohci-pnx8550.c | ||
ohci-ppc-of.c | ||
ohci-ppc-soc.c | ||
ohci-ps3.c | ||
ohci-pxa27x.c | ||
ohci-q.c | ||
ohci-s3c2410.c | ||
ohci-sa1111.c | ||
ohci-sh.c | ||
ohci-sm501.c | ||
ohci-ssb.c | ||
ohci-tmio.c | ||
ohci.h | ||
oxu210hp-hcd.c | ||
oxu210hp.h | ||
pci-quirks.c | ||
pci-quirks.h | ||
r8a66597-hcd.c | ||
r8a66597.h | ||
sl811_cs.c | ||
sl811-hcd.c | ||
sl811.h | ||
u132-hcd.c | ||
uhci-debug.c | ||
uhci-hcd.c | ||
uhci-hcd.h | ||
uhci-hub.c | ||
uhci-q.c | ||
xhci-dbg.c | ||
xhci-ext-caps.h | ||
xhci-hcd.c | ||
xhci-hub.c | ||
xhci-mem.c | ||
xhci-pci.c | ||
xhci-ring.c | ||
xhci.h |