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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1369671187-24430-3-git-send-email-ming.lei@canonical.com>
Date:	Tue, 28 May 2013 00:13:07 +0800
From:	Ming Lei <ming.lei@...onical.com>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:	linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
	Ming Lei <ming.lei@...onical.com>,
	Alan Stern <stern@...land.harvard.edu>
Subject: [PATCH 2/2] USB: hcd: only unmap the actual completed DMA buffer

This patch only unmap the actual completed DMA buffer instead of
the whole transfer buffer.

It is common to see only part of DMA transfer is completed, especially
in case of DMA_FROM_DEVICE because the length of incoming traffic often
is unknown before submitting URB, so this patch may improve USB
DMA unmapping which runs in hard irq context.

The patch has been tested on ARMv7(Pandaboard), and it is observed that
at average ~25us is saved about ehci interrupt handling on below usbnet
test case:

	- Pandaboard: IP address is IP_A
	- on one x86 box, run below command:
		#ping -f -s 1472 IP_A
	- compute ehci interrupt handling time on Pandaboard during ping
	  test

Cc: Alan Stern <stern@...land.harvard.edu>
Signed-off-by: Ming Lei <ming.lei@...onical.com>
---
 drivers/usb/core/hcd.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 53baa87..2722487 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1374,12 +1374,12 @@ void usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
 	else if (urb->transfer_flags & URB_DMA_MAP_PAGE)
 		dma_unmap_page(hcd->self.controller,
 				urb->transfer_dma,
-				urb->transfer_buffer_length,
+				urb->actual_length,
 				dir);
 	else if (urb->transfer_flags & URB_DMA_MAP_SINGLE)
 		dma_unmap_single(hcd->self.controller,
 				urb->transfer_dma,
-				urb->transfer_buffer_length,
+				urb->actual_length,
 				dir);
 	else if (urb->transfer_flags & URB_MAP_LOCAL)
 		hcd_free_coherent(urb->dev->bus,
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ