Hi,

here is an attempt at using the slab cache for urbs.
Could somebody with a 2.0 devices test this ?

        Regards
                Oliver

This BitKeeper patch contains the following changesets:
1.364

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: oliver
# Host: oenone.homelinux.org
# Root: /home/oliver/bk-trees/usb-2.5

#
#--- 1.54/drivers/usb/usb.c     Fri Feb 22 19:50:06 2002
#+++ 1.55/drivers/usb/usb.c     Fri Mar  1 16:03:48 2002
#@@ -60,6 +60,7 @@
# devfs_handle_t usb_devfs_handle;      /* /dev/usb dir. */
# 
# static struct usb_driver *usb_minors[16];
#+static kmem_cache_t *urb_cache;
# 
# /**
#  *    usb_register - register a USB driver
#@@ -840,17 +841,24 @@
# {
#       struct urb *urb;
# 
#-      urb = (struct urb *)kmalloc(sizeof(struct urb) + 
#-              iso_packets * sizeof(struct usb_iso_packet_descriptor),
#-              mem_flags);
#+      if (iso_packets) {
#+              urb = (struct urb *)kmalloc(sizeof(struct urb) +
#+                      iso_packets * sizeof(struct usb_iso_packet_descriptor),
#+                      mem_flags);
#+      } else {
#+              urb = kmem_cache_alloc(urb_cache, mem_flags);
#+      }
#+
#       if (!urb) {
#-              err("alloc_urb: kmalloc failed");
#+              err("alloc_urb: Out of memory\n");
#               return NULL;
#       }
# 
#       memset(urb, 0, sizeof(*urb));
#       urb->count = (atomic_t)ATOMIC_INIT(1);
#       spin_lock_init(&urb->lock);
#+      if (iso_packets)
#+              urb->is_iso = 1;
# 
#       return urb;
# }
#@@ -867,9 +875,15 @@
#  */
# void usb_free_urb(struct urb *urb)
# {
#-      if (urb)
#-              if (atomic_dec_and_test(&urb->count))
#-                      kfree(urb);
#+      if (urb) {
#+              if (atomic_dec_and_test(&urb->count)) {
#+                      if (urb->is_iso) {
#+                              kfree(urb);
#+                      } else {
#+                              kmem_cache_free(urb_cache, urb);
#+                      }
#+              }
#+      }
# }
# 
# /**
#@@ -890,8 +904,8 @@
#       } else
#               return NULL;
# }
#-              
#-              
#+
#+
# /*-------------------------------------------------------------------*/
# 
# /**
#@@ -2597,6 +2611,9 @@
#  */
# static int __init usb_init(void)
# {
#+      urb_cache = kmem_cache_create("simpleurbcache",
#+                                      sizeof(struct urb),
#+                                      0,0, NULL, NULL);
#       usb_major_init();
#       usbfs_init();
#       usb_hub_init();
#@@ -2612,6 +2629,7 @@
#       usb_major_cleanup();
#       usbfs_cleanup();
#       usb_hub_cleanup();
#+      kmem_cache_destroy(urb_cache);
# }
# 
# module_init(usb_init);
#
#--- 1.45/include/linux/usb.h   Fri Feb 22 19:50:06 2002
#+++ 1.46/include/linux/usb.h   Fri Mar  1 16:03:48 2002
#@@ -720,6 +720,7 @@
# {
#       spinlock_t lock;                /* lock for the URB */
#       atomic_t count;                 /* reference count of the URB */
#+      int is_iso;                     /* flag to handle as iso */
#       void *hcpriv;                   /* private data for host controller */
#       struct list_head urb_list;      /* list pointer to all active urbs */
#       struct urb *next;               /* (in) pointer to next URB */
#

# Diff checksum=5dd699e8


# Patch vers:   1.3
# Patch type:   REGULAR

== ChangeSet ==
[EMAIL PROTECTED]|ChangeSet|20011125035615|28334|160bd283d279fb69
[EMAIL PROTECTED]|ChangeSet|20020228060924|58599
D 1.364 02/03/01 16:04:56+01:00 [EMAIL PROTECTED] +2 -0
B [EMAIL PROTECTED]|ChangeSet|20011125035615|28334|160bd283d279fb69
C
c slab cache for urbs
K 60493
P ChangeSet
------------------------------------------------

0a0
> [EMAIL PROTECTED]|include/linux/usb.h|20011125040540|06447|d223d8d55f64361 
[EMAIL PROTECTED]|include/linux/usb.h|20020301150348|44968
> [EMAIL PROTECTED]|drivers/usb/usb.c|20011125040916|23454|c62ee58217cba305 
[EMAIL PROTECTED]|drivers/usb/usb.c|20020301150348|50801

== drivers/usb/usb.c ==
[EMAIL PROTECTED]|drivers/usb/usb.c|20011125040916|23454|c62ee58217cba305
[EMAIL PROTECTED]|drivers/usb/usb.c|20020222185006|21593
D 1.55 02/03/01 16:03:48+01:00 [EMAIL PROTECTED] +27 -9
B [EMAIL PROTECTED]|ChangeSet|20011125035615|28334|160bd283d279fb69
C
c allocate non iso urbs from a slab cache
K 50801
O -rw-rw-r--
P drivers/usb/usb.c
------------------------------------------------

I62 1
static kmem_cache_t *urb_cache;
D843 3
I845 8
        if (iso_packets) {
                urb = (struct urb *)kmalloc(sizeof(struct urb) +
                        iso_packets * sizeof(struct usb_iso_packet_descriptor),
                        mem_flags);
        } else {
                urb = kmem_cache_alloc(urb_cache, mem_flags);
        }
\
D847 1
I847 1
                err("alloc_urb: Out of memory\n");
I853 2
        if (iso_packets)
                urb->is_iso = 1;
D870 3
I872 9
        if (urb) {
                if (atomic_dec_and_test(&urb->count)) {
                        if (urb->is_iso) {
                                kfree(urb);
                        } else {
                                kmem_cache_free(urb_cache, urb);
                        }
                }
        }
D893 2
I894 2
\
\
I2599 3
        urb_cache = kmem_cache_create("simpleurbcache",
                                        sizeof(struct urb),
                                        0,0, NULL, NULL);
I2614 1
        kmem_cache_destroy(urb_cache);

== include/linux/usb.h ==
[EMAIL PROTECTED]|include/linux/usb.h|20011125040540|06447|d223d8d55f64361
[EMAIL PROTECTED]|include/linux/usb.h|20020222185006|41684
D 1.46 02/03/01 16:03:48+01:00 [EMAIL PROTECTED] +1 -0
B [EMAIL PROTECTED]|ChangeSet|20011125035615|28334|160bd283d279fb69
C
c flag to mark as iso
K 44968
O -rw-rw-r--
P include/linux/usb.h
------------------------------------------------

I722 1
        int is_iso;                     /* flag to handle as iso */

# Patch checksum=c2b09bf4

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

Reply via email to