Skip to contentSkip to conversation

usb: dma bounce buffer support V4

PATCH In review Magnus Damm 1 participant 1 message Jan 23, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 usb: dma bounce buffer support V4

usb: dma bounce buffer support V4

This patch adds dma bounce buffer support to the usb core. These buffers can be enabled with the HCD_LOCAL_MEM flag, and they make sure that all data passed to the host controller is allocated using dma_alloc_coherent().

---

Only comment and checkpatch fixes since V3.

 drivers/usb/core/buffer.c |    9 +-
 drivers/usb/core/hcd.c    |  176 +++++++++++++++++++++++++++++++++++++++------
 drivers/usb/core/hcd.h    |    1 
 3 files changed, 163 insertions(+), 23 deletions(-)
drivers/usb/core/buffer.c +6 -3
@@ -53,7 +53,8 @@ int hcd_buffer_create(struct usb_hcd *hc
 	char		name[16];
 	int 		i, size;
 
-	if (!hcd->self.controller->dma_mask)
+	if (!hcd->self.controller->dma_mask &&
+	    !(hcd->driver->flags & HCD_LOCAL_MEM))
 		return 0;
 
 	for (i = 0; i < HCD_BUFFER_POOLS; i++) { 
@@ -107,7 +108,8 @@ void *hcd_buffer_alloc(
 	int 			i;
 
 	/* some USB hosts just use PIO */
-	if (!bus->controller->dma_mask) {
+	if (!bus->controller->dma_mask &&
+	    !(hcd->driver->flags & HCD_LOCAL_MEM)) {
 		*dma = ~(dma_addr_t) 0;
 		return kmalloc(size, mem_flags);
 	}
@@ -132,7 +134,8 @@ void hcd_buffer_free(
 	if (!addr)
 		return;
 
-	if (!bus->controller->dma_mask) {
+	if (!bus->controller->dma_mask &&
+	    !(hcd->driver->flags & HCD_LOCAL_MEM)) {
 		kfree(addr);
 		return;
 	}
drivers/usb/core/hcd.c +156 -20

223 lines not on this page · raw message

drivers/usb/core/hcd.h +1 -0
@@ -165,6 +165,7 @@ struct hc_driver {
 
 	int	flags;
 #define	HCD_MEMORY	0x0001		/* HC regs use memory (else I/O) */
+#define	HCD_LOCAL_MEM	0x0002		/* HC needs local memory */
 #define	HCD_USB11	0x0010		/* USB 1.1 */
 #define	HCD_USB2	0x0020		/* USB 2.0 */