Hi,

the included patch might even, as it is designed to, allow swapping over a standard 
usb storage device.
As long as there's not too much network activity.

As requested this version works without an API change and duplicates code instead.

I have no device to test this and would appreciate any comment.
I only know it compiles.

        Regards
                Oliver

--------------------------------------------------------------------------------------------
diff -ur linuxvanilla/drivers/usb/storage/datafab.c 
linuxstorage/drivers/usb/storage/datafab.c
--- linuxvanilla/drivers/usb/storage/datafab.c  Mon Sep 10 23:39:59 2001
+++ linuxstorage/drivers/usb/storage/datafab.c  Mon Sep 24 21:36:19 2001
@@ -208,7 +208,7 @@

                if (use_sg) {
                        sg = (struct scatterlist *) dest;
-                       buffer = kmalloc(len, GFP_KERNEL);
+                       buffer = kmalloc(len, GFP_NOIO);
                        if (buffer == NULL)
                                return USB_STOR_TRANSPORT_ERROR;
                        ptr = buffer;
@@ -333,7 +333,7 @@

                if (use_sg) {
                        sg = (struct scatterlist *) src;
-                       buffer = kmalloc(len, GFP_KERNEL);
+                       buffer = kmalloc(len, GFP_NOIO);
                        if (buffer == NULL)
                                return USB_STOR_TRANSPORT_ERROR;
                        ptr = buffer;
@@ -665,7 +665,7 @@
        };

        if (!us->extra) {
-               us->extra = kmalloc(sizeof(struct datafab_info), GFP_KERNEL);
+               us->extra = kmalloc(sizeof(struct datafab_info), GFP_NOIO);
                if (!us->extra) {
                        US_DEBUGP("datafab_transport:  Gah! Can't allocate storage for 
Datafab info struct!\n");
                        return USB_STOR_TRANSPORT_ERROR;
diff -ur linuxvanilla/drivers/usb/storage/jumpshot.c 
linuxstorage/drivers/usb/storage/jumpshot.c
--- linuxvanilla/drivers/usb/storage/jumpshot.c Mon Sep 10 23:39:59 2001
+++ linuxstorage/drivers/usb/storage/jumpshot.c Mon Sep 24 21:36:19 2001
@@ -284,7 +284,7 @@

                 if (use_sg) {
                         sg = (struct scatterlist *) dest;
-                        buffer = kmalloc(len, GFP_KERNEL);
+                        buffer = kmalloc(len, GFP_NOIO);
                         if (buffer == NULL)
                                 return USB_STOR_TRANSPORT_ERROR;
                         ptr = buffer;
@@ -399,7 +399,7 @@

                 if (use_sg) {
                         sg = (struct scatterlist *) src;
-                        buffer = kmalloc(len, GFP_KERNEL);
+                        buffer = kmalloc(len, GFP_NOIO);
                         if (buffer == NULL)
                                 return USB_STOR_TRANSPORT_ERROR;
                         ptr = buffer;
@@ -665,7 +665,7 @@


        if (!us->extra) {
-               us->extra = kmalloc(sizeof(struct jumpshot_info), GFP_KERNEL);
+               us->extra = kmalloc(sizeof(struct jumpshot_info), GFP_NOIO);
                if (!us->extra) {
                        US_DEBUGP("jumpshot_transport:  Gah! Can't allocate storage 
for jumpshot info struct!\n");
                        return USB_STOR_TRANSPORT_ERROR;
diff -ur linuxvanilla/drivers/usb/storage/sddr09.c 
linuxstorage/drivers/usb/storage/sddr09.c
--- linuxvanilla/drivers/usb/storage/sddr09.c   Mon Sep 10 23:40:12 2001
+++ linuxstorage/drivers/usb/storage/sddr09.c   Mon Sep 24 21:36:19 2001
@@ -303,7 +303,7 @@
 
        if (use_sg) {
                sg = (struct scatterlist *)content;
-               buffer = kmalloc(len, GFP_KERNEL);
+               buffer = kmalloc(len, GFP_NOIO);
                if (buffer == NULL)
                        return USB_STOR_TRANSPORT_ERROR;
                ptr = buffer;
@@ -630,16 +630,16 @@

        alloc_blocks = (alloc_len + (1<<17) - 1) >> 17;
        sg = kmalloc(alloc_blocks*sizeof(struct scatterlist),
-               GFP_KERNEL);
+               GFP_NOIO);
        if (sg == NULL)
                return 0;
 
        for (i=0; i<alloc_blocks; i++) {
                if (i<alloc_blocks-1) {
-                       sg[i].address = kmalloc( (1<<17), GFP_KERNEL );
+                       sg[i].address = kmalloc( (1<<17), GFP_NOIO );
                        sg[i].length = (1<<17);
                } else {
-                       sg[i].address = kmalloc(alloc_len, GFP_KERNEL);
+                       sg[i].address = kmalloc(alloc_len, GFP_NOIO);
                        sg[i].length = alloc_len;
                }
                alloc_len -= sg[i].length;
@@ -670,8 +670,8 @@
                kfree(info->lba_to_pba);
        if (info->pba_to_lba)
                kfree(info->pba_to_lba);
-       info->lba_to_pba = kmalloc(numblocks*sizeof(int), GFP_KERNEL);
-       info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_KERNEL);
+       info->lba_to_pba = kmalloc(numblocks*sizeof(int), GFP_NOIO);
+       info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_NOIO);
 
        if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) {
                if (info->lba_to_pba != NULL)
@@ -840,7 +840,7 @@
 
        if (!us->extra) {
                us->extra = kmalloc(
-                       sizeof(struct sddr09_card_info), GFP_KERNEL);
+                       sizeof(struct sddr09_card_info), GFP_NOIO);
                if (!us->extra)
                        return USB_STOR_TRANSPORT_ERROR;
                memset(us->extra, 0, sizeof(struct sddr09_card_info));
diff -ur linuxvanilla/drivers/usb/storage/shuttle_usbat.c 
linuxstorage/drivers/usb/storage/shuttle_usbat.c
--- linuxvanilla/drivers/usb/storage/shuttle_usbat.c    Mon Sep 10 23:39:45 2001
+++ linuxstorage/drivers/usb/storage/shuttle_usbat.c    Mon Sep 24 21:36:19 2001
@@ -681,7 +681,7 @@
 
        len = (65535/srb->transfersize) * srb->transfersize;
        US_DEBUGP("Max read is %d bytes\n", len);
-       buffer = kmalloc(len, GFP_KERNEL);
+       buffer = kmalloc(len, GFP_NOIO);
        if (buffer == NULL) // bloody hell!
                return USB_STOR_TRANSPORT_FAILED;
        sector = short_pack(data[7+3], data[7+2]);
diff -ur linuxvanilla/drivers/usb/storage/transport.c 
linuxstorage/drivers/usb/storage/transport.c
--- linuxvanilla/drivers/usb/storage/transport.c        Mon Sep 10 23:40:12 2001
+++ linuxstorage/drivers/usb/storage/transport.c        Mon Sep 24 21:36:19 2001
@@ -388,9 +388,12 @@
        devrequest *dr;

        /* allocate the device request structure */
-       dr = kmalloc(sizeof(devrequest), GFP_KERNEL);
-       if (!dr)
-               return -ENOMEM;
+       dr = kmalloc(sizeof(devrequest), GFP_NOIO);
+       if (!dr) {
+               dr = kmalloc(sizeof(devrequest), GFP_ATOMIC);
+               if (!dr)
+                       return -ENOMEM;
+       }
 
        /* fill in the structure */
        dr->requesttype = requesttype;
diff -ur linuxvanilla/drivers/usb/storage/usb.c linuxstorage/drivers/usb/storage/usb.c
--- linuxvanilla/drivers/usb/storage/usb.c      Mon Sep 10 23:39:45 2001
+++ linuxstorage/drivers/usb/storage/usb.c      Mon Sep 24 21:53:51 2001
@@ -727,13 +727,14 @@
                /* New device -- allocate memory and initialize */
                US_DEBUGP("New GUID " GUID_FORMAT "\n", GUID_ARGS(guid));

-               if ((ss = (struct us_data *)kmalloc(sizeof(struct us_data), 
+               if ((ss = (struct us_data *)kmalloc(sizeof(struct us_data),
                                                    GFP_KERNEL)) == NULL) {
                        printk(KERN_WARNING USB_STORAGE "Out of memory\n");
                        usb_dec_dev_use(dev);
                        return NULL;
                }
                memset(ss, 0, sizeof(struct us_data));
+               dev->gfp_mask = GFP_NOIO;

                /* allocate the URB we're going to use */
                ss->current_urb = usb_alloc_urb(0);
diff -ur linuxvanilla/drivers/usb/usb-ohci.c linuxstorage/drivers/usb/usb-ohci.c
--- linuxvanilla/drivers/usb/usb-ohci.c Mon Sep 10 23:39:59 2001
+++ linuxstorage/drivers/usb/usb-ohci.c Mon Sep 24 21:52:37 2001
@@ -601,11 +601,14 @@
        }

        /* allocate the private part of the URB */
-       urb_priv = kmalloc (sizeof (urb_priv_t) + size * sizeof (td_t *),
-                                                       in_interrupt() ? GFP_ATOMIC : 
GFP_KERNEL);
+       urb_priv = kmalloc (sizeof (urb_priv_t) + size * sizeof (td_t *),
+                               in_interrupt() ? GFP_ATOMIC : urb->dev->gfp_mask);
        if (!urb_priv) {
-               usb_dec_dev_use (urb->dev);     
-               return -ENOMEM;
+               urb_priv = kmalloc (sizeof (urb_priv_t) + size * sizeof (td_t *), 
+GFP_ATOMIC);
+               if (!urb_priv) {
+                       usb_dec_dev_use (urb->dev);
+                       return -ENOMEM;
+               }
        }
        memset (urb_priv, 0, sizeof (urb_priv_t) + size * sizeof (td_t *));

@@ -800,7 +803,8 @@
 {
        struct ohci_device * dev;

-       dev = dev_alloc ((struct ohci *) usb_dev->bus->hcpriv, ALLOC_FLAGS);
+       dev = dev_alloc ((struct ohci *) usb_dev->bus->hcpriv,
+                               in_interrupt() ? GFP_ATOMIC : usb_dev->gfp_mask);
        if (!dev)
                return -ENOMEM;

diff -ur linuxvanilla/drivers/usb/usb.c linuxstorage/drivers/usb/usb.c
--- linuxvanilla/drivers/usb/usb.c      Mon Sep 10 23:40:12 2001
+++ linuxstorage/drivers/usb/usb.c      Mon Sep 24 22:02:47 2001
@@ -941,6 +941,7 @@
 
        dev->bus = bus;
        dev->parent = parent;
+       dev->gfp_mask = GFP_KERNEL;
        atomic_set(&dev->refcnt, 1);
        INIT_LIST_HEAD(&dev->inodes);
        INIT_LIST_HEAD(&dev->filelist);
@@ -1003,6 +1004,30 @@
        return urb;
 }
 
+urb_t *usb_alloc_urb_gfp(int iso_packets,int gfp)
+{
+       urb_t *urb;
+
+       urb = (urb_t *)kmalloc(sizeof(urb_t) + iso_packets * 
+sizeof(iso_packet_descriptor_t),
+                                       gfp);
+       if (!urb) {
+               if (gfp == GFP_NOIO)
+                       urb = (urb_t *)kmalloc(sizeof(urb_t) + iso_packets * 
+sizeof(iso_packet_descriptor_t),
+                                               GFP_ATOMIC);
+               if (!urb) {
+                       err("alloc_urb: kmalloc failed");
+                       return NULL;
+               }
+       }
+
+       memset(urb, 0, sizeof(*urb));
+
+       spin_lock_init(&urb->lock);
+
+       return urb;
+}
+
+
 /**
  *     usb_free_urb - frees the memory used by a urb
  *     @urb: pointer to the urb to free
@@ -1112,7 +1137,7 @@
        int retv;
        int length;

-       urb = usb_alloc_urb(0);
+       urb = usb_alloc_urb_gfp(0, usb_dev->gfp_mask);
        if (!urb)
                return -ENOMEM;
   
@@ -1201,7 +1226,7 @@
        if (len < 0)
                return -EINVAL;
 
-       urb=usb_alloc_urb(0);
+       urb=usb_alloc_urb_gfp(0, usb_dev->gfp_mask);
        if (!urb)
                return -ENOMEM;

diff -ur linuxvanilla/include/linux/usb.h linuxstorage/include/linux/usb.h
--- linuxvanilla/include/linux/usb.h    Mon Sep 10 23:40:14 2001
+++ linuxstorage/include/linux/usb.h    Mon Sep 24 22:10:13 2001
@@ -622,6 +622,7 @@
        struct usb_device_descriptor descriptor;/* Descriptor */
        struct usb_config_descriptor *config;   /* All of the configs */
        struct usb_config_descriptor *actconfig;/* the active configuration */
+       int gfp_mask;
 
        char **rawdescriptors;          /* Raw descriptors for each config */
 

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to