From: Peter Chen <hzpeterchen@gmail.com>
To: Daewoong Kim <daewoong00.kim@lge.com>
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
allen.lkml@gmail.com, gustavoars@kernel.org,
a.darwish@linutronix.de, romain.perier@gmail.com,
dvyukov@google.com, andreyknvl@google.com,
mathias.nyman@intel.com, gregkh@linuxfoundation.org
Subject: Re: [PATCH 1/1] usb: xhci: setup packets don't need DMA mapping
Date: Thu, 14 Jan 2021 13:04:02 +0800 [thread overview]
Message-ID: <20210114050402.GA18650@b29397-desktop> (raw)
In-Reply-To: <1610593147-12511-1-git-send-email-daewoong00.kim@lge.com>
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;
if (xhci->quirks & XHCI_SG_TRB_CACHE_SIZE_QUIRK) {
@@ -1389,6 +1390,9 @@ static void xhci_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
struct xhci_hcd *xhci;
bool unmap_temp_buf = false;
+ if (usb_endpoint_xfer_control(&urb->ep->desc))
+ return;
+
xhci = hcd_to_xhci(hcd);
if (urb->num_sgs && (urb->transfer_flags & URB_DMA_MAP_SINGLE))
> Signed-off-by: Daewoong Kim <daewoong00.kim@lge.com>
> ---
> drivers/usb/core/hcd.c | 4 +++-
> drivers/usb/host/xhci.c | 1 +
> include/linux/usb.h | 4 ++++
> 3 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index ad5a0f405a75..b1f9eac93f0d 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -1411,7 +1411,9 @@ int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
> if (usb_endpoint_xfer_control(&urb->ep->desc)) {
> if (hcd->self.uses_pio_for_control)
> return ret;
> - if (hcd->localmem_pool) {
> + if (hcd->self.uses_pio_for_setup_pkt) {
> + ; /* do nothing */
> + } else if (hcd->localmem_pool) {
> ret = hcd_alloc_coherent(
> urb->dev->bus, mem_flags,
> &urb->setup_dma,
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index e86940571b4c..c263aee82dc0 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -643,6 +643,7 @@ int xhci_run(struct usb_hcd *hcd)
> */
>
> hcd->uses_new_polling = 1;
> + hcd->self.uses_pio_for_setup_pkt = 1;
> if (!usb_hcd_is_primary_hcd(hcd))
> return xhci_run_finished(xhci);
>
> diff --git a/include/linux/usb.h b/include/linux/usb.h
> index 7d72c4e0713c..76600e8de414 100644
> --- a/include/linux/usb.h
> +++ b/include/linux/usb.h
> @@ -430,6 +430,10 @@ struct usb_bus {
> * Does the host controller use PIO
> * for control transfers?
> */
> + u8 uses_pio_for_setup_pkt; /*
> + * Does the host controller use PIO
> + * for setup packets?
> + */
> u8 otg_port; /* 0, or number of OTG/HNP port */
> unsigned is_b_host:1; /* true during some HNP roleswitches */
> unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */
> --
> 2.17.1
>
--
Thanks,
Peter Chen
next prev parent reply other threads:[~2021-01-14 5:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-14 2:59 [PATCH 1/1] usb: xhci: setup packets don't need DMA mapping Daewoong Kim
2021-01-14 5:04 ` Peter Chen [this message]
2021-01-14 18:00 ` Alan Stern
2021-01-15 0:32 ` Peter Chen
2021-01-18 1:07 ` Daewoong Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210114050402.GA18650@b29397-desktop \
--to=hzpeterchen@gmail.com \
--cc=a.darwish@linutronix.de \
--cc=allen.lkml@gmail.com \
--cc=andreyknvl@google.com \
--cc=daewoong00.kim@lge.com \
--cc=dvyukov@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=gustavoars@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=romain.perier@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox