Переглянути джерело

[usb] Do not call usb_hotplug() when registering a new hub

The action of registering a new hub can itself happen in only two
ways: either a new USB hub has been created (in which case we are
already inside a call to usb_hotplug()), or a new root hub has been
created.

In the former case, we do not need to issue a further call to
usb_hotplug(), since the hub's ports will all be marked as changed and
so will be handled after the return from register_usb_hub() anyway.
Calling usb_hotplug() within register_usb_hub() leads to a confusing
order of events, such as:

- root hub port 1 detects a change
- root hub port 2 detects a change
- usb_hotplug() is called
  - root hub port 1 finds a USB hub
    - usb_hotplug() is called
      - this inner call to usb_hotplug() handles root hub port 2

Fix by calling usb_hotplug() only from usb_step() and from
register_usb_bus().  This avoids recursive calls to usb_hotplug() and
ensures that devices are enumerated in the order of detection.

Tested-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 роки тому
джерело
коміт
a2173fca45
1 змінених файлів з 3 додано та 3 видалено
  1. 3
    3
      src/drivers/bus/usb.c

+ 3
- 3
src/drivers/bus/usb.c Переглянути файл

@@ -1779,9 +1779,6 @@ int register_usb_hub ( struct usb_hub *hub ) {
1779 1779
 	 */
1780 1780
 	usb_poll ( bus );
1781 1781
 
1782
-	/* Attach any devices already present */
1783
-	usb_hotplug();
1784
-
1785 1782
 	return 0;
1786 1783
 
1787 1784
 	hub->driver->close ( hub );
@@ -1915,6 +1912,9 @@ int register_usb_bus ( struct usb_bus *bus ) {
1915 1912
 	if ( ( rc = register_usb_hub ( bus->hub ) ) != 0 )
1916 1913
 		goto err_register_hub;
1917 1914
 
1915
+	/* Attach any devices already present */
1916
+	usb_hotplug();
1917
+
1918 1918
 	return 0;
1919 1919
 
1920 1920
 	unregister_usb_hub ( bus->hub );

Завантаження…
Відмінити
Зберегти