Commit 9f7a33a7 authored by Alan Stern's avatar Alan Stern Committed by Linus Torvalds

[PATCH] USB: Make hub.c DMA-aware

This patch makes the hub status irq DMA-aware, by pre-allocating the
transfer buffer in consistent memory.  Unfortunately, there doesn't seem
to be an easy way to do the same for the status report buffers.
parent c20a2c35
...@@ -302,9 +302,10 @@ static int hub_configure(struct usb_hub *hub, ...@@ -302,9 +302,10 @@ static int hub_configure(struct usb_hub *hub,
int maxp, ret; int maxp, ret;
char *message; char *message;
hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL); hub->buffer = usb_buffer_alloc(dev, sizeof(*hub->buffer), GFP_KERNEL,
&hub->buffer_dma);
if (!hub->buffer) { if (!hub->buffer) {
message = "can't kmalloc hub irq buffer"; message = "can't allocate hub irq buffer";
ret = -ENOMEM; ret = -ENOMEM;
goto fail; goto fail;
} }
...@@ -459,6 +460,8 @@ static int hub_configure(struct usb_hub *hub, ...@@ -459,6 +460,8 @@ static int hub_configure(struct usb_hub *hub,
usb_fill_int_urb(hub->urb, dev, pipe, *hub->buffer, maxp, hub_irq, usb_fill_int_urb(hub->urb, dev, pipe, *hub->buffer, maxp, hub_irq,
hub, endpoint->bInterval); hub, endpoint->bInterval);
hub->urb->transfer_dma = hub->buffer_dma;
hub->urb->transfer_flags |= URB_NO_DMA_MAP;
ret = usb_submit_urb(hub->urb, GFP_KERNEL); ret = usb_submit_urb(hub->urb, GFP_KERNEL);
if (ret) { if (ret) {
message = "couldn't submit status urb"; message = "couldn't submit status urb";
...@@ -522,7 +525,9 @@ static void hub_disconnect(struct usb_interface *intf) ...@@ -522,7 +525,9 @@ static void hub_disconnect(struct usb_interface *intf)
} }
if (hub->buffer) { if (hub->buffer) {
kfree(hub->buffer); usb_buffer_free(interface_to_usbdev(intf),
sizeof(*hub->buffer), hub->buffer,
hub->buffer_dma);
hub->buffer = NULL; hub->buffer = NULL;
} }
......
...@@ -175,6 +175,7 @@ struct usb_hub { ...@@ -175,6 +175,7 @@ struct usb_hub {
/* buffer for urb ... 1 bit each for hub and children, rounded up */ /* buffer for urb ... 1 bit each for hub and children, rounded up */
char (*buffer)[(USB_MAXCHILDREN + 1 + 7) / 8]; char (*buffer)[(USB_MAXCHILDREN + 1 + 7) / 8];
dma_addr_t buffer_dma; /* DMA address for buffer */
union { union {
struct usb_hub_status hub; struct usb_hub_status hub;
struct usb_port_status port; struct usb_port_status port;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment