ChangeSet 1.1608.84.28, 2004/03/10 13:31:40-08:00, [EMAIL PROTECTED]

[PATCH] USB: usb buffer allocation shouldn't require DMA

Deepak's recent dma_pool changes accidentally assumed that
all HCDs use DMA.  The fix is simple:  use kmalloc/kfree
when there's no DMA.


 drivers/usb/core/buffer.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)


diff -Nru a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
--- a/drivers/usb/core/buffer.c Tue Mar 16 15:02:00 2004
+++ b/drivers/usb/core/buffer.c Tue Mar 16 15:02:00 2004
@@ -51,8 +51,8 @@
  * @hcd: the bus whose buffer pools are to be initialized
  * Context: !in_interrupt()
  *
- * Call this as part of initializing a host controller that uses the pci dma
- * memory allocators.  It initializes some pools of dma-consistent memory that
+ * Call this as part of initializing a host controller that uses the dma
+ * memory allocators.  It initializes some pools of dma-coherent memory that
  * will be shared by all drivers using that controller, or returns a negative
  * errno value on error.
  *
@@ -115,6 +115,12 @@
        struct usb_hcd          *hcd = bus->hcpriv;
        int                     i;
 
+       /* some USB hosts just use PIO */
+       if (!bus->controller->dma_mask) {
+               *dma = ~(dma_addr_t) 0;
+               return kmalloc (size, mem_flags);
+       }
+
        for (i = 0; i < HCD_BUFFER_POOLS; i++) {
                if (size <= pool_max [i])
                        return dma_pool_alloc (hcd->pool [i], mem_flags, dma);
@@ -134,6 +140,12 @@
 
        if (!addr)
                return;
+
+       if (!bus->controller->dma_mask) {
+               kfree (addr);
+               return;
+       }
+
        for (i = 0; i < HCD_BUFFER_POOLS; i++) {
                if (size <= pool_max [i]) {
                        dma_pool_free (hcd->pool [i], addr, dma);



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to