Fix to khubd oops, hellooo?

From: Pete Zaitcev (zaitcev@redhat.com)
Date: Tue Mar 13 2001 - 15:44:58 EST


Is my fix to khubd going anywhere? Randy, David?
I have an actual, reproducible bug that I need to close.
Here's my message to linux-usb-devel with explanations:
  http://marc.theaimsgroup.com/?l=linux-usb-devel&m=98411157628404&w=2

-- Pete

diff -ur -X ../dontdiff linux-2.4.2-ac12/drivers/usb/hub.c linux-2.4.2-ac12-p3/drivers/usb/hub.c
--- linux-2.4.2-ac12/drivers/usb/hub.c Wed Mar 7 12:17:02 2001
+++ linux-2.4.2-ac12-p3/drivers/usb/hub.c Thu Mar 8 19:43:14 2001
@@ -357,6 +357,7 @@
 
         INIT_LIST_HEAD(&hub->event_list);
         hub->dev = dev;
+ init_MUTEX(&hub->khubd_sem);
 
         /* Record the new hub's existence */
         spin_lock_irqsave(&hub_event_lock, flags);
@@ -400,6 +399,9 @@
 
         spin_unlock_irqrestore(&hub_event_lock, flags);
 
+ down(&hub->khubd_sem); /* Wait for khubd to leave this hub alone. */
+ up(&hub->khubd_sem);
+
         if (hub->urb) {
                 usb_unlink_urb(hub->urb);
                 usb_free_urb(hub->urb);
@@ -709,7 +717,7 @@
                 spin_lock_irqsave(&hub_event_lock, flags);
 
                 if (list_empty(&hub_event_list))
- goto he_unlock;
+ break;
 
                 /* Grab the next entry from the beginning of the list */
                 tmp = hub_event_list.next;
@@ -720,6 +728,7 @@
                 list_del(tmp);
                 INIT_LIST_HEAD(tmp);
 
+ down(&hub->khubd_sem); /* never blocks, we were on list */
                 spin_unlock_irqrestore(&hub_event_lock, flags);
 
                 if (hub->error) {
@@ -728,6 +737,7 @@
                         if (usb_hub_reset(hub)) {
                                 err("error resetting hub %d - disconnecting", dev->devnum);
                                 usb_hub_disconnect(dev);
+ up(&hub->khubd_sem);
                                 continue;
                         }
 
@@ -742,6 +752,7 @@
                         ret = usb_get_port_status(dev, i + 1, &portsts);
                         if (ret < 0) {
                                 err("get_port_status failed (err = %d)", ret);
+ up(&hub->khubd_sem);
                                 continue;
                         }
 
@@ -803,9 +814,9 @@
                                 usb_hub_power_on(hub);
                         }
                 }
+ up(&hub->khubd_sem);
         } /* end while (1) */
 
-he_unlock:
         spin_unlock_irqrestore(&hub_event_lock, flags);
 }
 
diff -ur -X ../dontdiff linux-2.4.2-ac12/drivers/usb/hub.h linux-2.4.2-ac12-p3/drivers/usb/hub.h
--- linux-2.4.2-ac12/drivers/usb/hub.h Wed Mar 7 12:17:02 2001
+++ linux-2.4.2-ac12-p3/drivers/usb/hub.h Thu Mar 8 19:17:38 2001
@@ -134,6 +134,8 @@
         struct list_head event_list;
 
         struct usb_hub_descriptor *descriptor;
+
+ struct semaphore khubd_sem;
 };
 
 #endif /* __LINUX_HUB_H */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Mar 15 2001 - 21:00:15 EST