Re: [PATCH 1/1] usb: xhci: setup packets don't need DMA mapping

From: Peter Chen
Date: Thu Jan 14 2021 - 19:33:52 EST


On 21-01-14 13:00:21, Alan Stern wrote:
> On Thu, Jan 14, 2021 at 01:04:02PM +0800, Peter Chen wrote:
> > On 21-01-14 11:59:07, Daewoong Kim wrote:
> > > DMA mapping of urb->setup_packet is not necessary for xHCI host
> > > controllers. The xHCI specification says that Setup Stage TRB includes
> > > whole Setup Data; therefore, urb->setup_dma will not be used in the xhci
> > > HCD code.
> > >
> >
> > How about bypass map/unmap operation for xHCI control transfer directly?
> >
> > diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> > index 91ab81c3fc79..0a0ab14b7638 100644
> > --- a/drivers/usb/host/xhci.c
> > +++ b/drivers/usb/host/xhci.c
> > @@ -1374,7 +1374,8 @@ static int xhci_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
> >
> > xhci = hcd_to_xhci(hcd);
> >
> > - if (xhci_urb_suitable_for_idt(urb))
> > + if (xhci_urb_suitable_for_idt(urb) ||
> > + (usb_endpoint_xfer_control(&urb->ep->desc)))
> > return 0;
>
> Would this affect the map/unmap operations for the DATA packets in a
> control transfer, along with the SETUP packet?
>

Oh, you are right, Alan. We do need map/unmap operation for DATA
packet in control transfer.

--

Thanks,
Peter Chen