Re: [RFC] xhci: Let completion handlers run before rings are restarted.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 4 Jun 2012, Sarah Sharp wrote:

> This patch changes the xHCI ring handling code to allow the URB
> completion handler to run before ringing the doorbell on an endpoint
> ring.  This means adding a new flag to prevent the doorbell ring
> (EP_STAY_HALTED), to avoid a race condition with the URB completion
> handler and a completing Set TR Dequeue Pointer command (which will
> restart the ring).  The new flag temporarily stops the ring until the
> URB completion function has a chance to cancel any pending URBs.  That
> will set a different cancellation pending flag, which will also halt the
> endpoint ring.
> 
> Make sure to set the new EP_STAY_HALTED flag before calling
> xhci_cleanup_halted_endpoint().  That function will queue a Set TR
> Dequeue command, which will ring the doorbell and restart the ring after
> it completes.  We need to make sure that the URB completion handlers
> have a chance to run before the ring is restarted.

I really don't understand the structure of your driver, but this sounds 
like it's more complicated than necessary.  The general approach for 
handling a stopped endpoint ring should be:

	Give back all the URBs that are complete;

	Clean up the ring;

	Restart it if any URBs remain queued.

As far as I can see, the only state you need to keep track of is 
whether the ring is active, stopping, or stopped.  There shouldn't be 
any need for an EP_STAY_HALTED flag.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux