lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1610593147-12511-1-git-send-email-daewoong00.kim@lge.com>
Date:   Thu, 14 Jan 2021 11:59:07 +0900
From:   Daewoong Kim <daewoong00.kim@....com>
To:     linux-kernel@...r.kernel.org, linux-usb@...r.kernel.org
Cc:     allen.lkml@...il.com, gustavoars@...nel.org,
        a.darwish@...utronix.de, romain.perier@...il.com,
        dvyukov@...gle.com, andreyknvl@...gle.com, mathias.nyman@...el.com,
        gregkh@...uxfoundation.org, Daewoong Kim <daewoong00.kim@....com>
Subject: [PATCH 1/1] usb: xhci: setup packets don't need DMA mapping

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.

Signed-off-by: Daewoong Kim <daewoong00.kim@....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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ