Skip to contentSkip to conversation

2.4.0-test10-pre6 fix usb initialization order

PATCH New Keith Owens 1 participant 1 message Oct 29, 2000

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.4.0-test10-pre6 fix usb initialization order

This patch against 2.4.0-test10-pre6 implements LINK_FIRST and LINK_LAST to fix the problem with usb initialization order. The patch *only* affects drivers/usb because that is the only Makefile that specifies LINK_FIRST. All the other Makefiles still rely on the kludge where the link order is implicit in the order that objects are declared. USB is a special case[*] and the kludge is no longer enough, it really does need LINK_FIRST. Comments before it goes to Linus?

[*]http://www.uwsg.indiana.edu/hypermail/linux/kernel/0010.3/0661.html

Do not change any other Makefiles to use LINK_FIRST/LAST unless you can guarantee that you know and have take care of all the side effects of changing link order. Given the lack of documentation on link order in most Makefiles, that means leave link order alone until 2.5 unless there is absolutely no other way of fixing the problem.

Index: 0-test10-pre6.1/drivers/usb/Makefile

drivers/usb/Makefile Sun, 29 Oct 2000 12:38:11 +1100 kaos (linux-2.4/n/b/19_Makefile 1.1.1.11 644) renamed from drivers/usb/Makefile Tue, 24 Oct 2000 14:20:12 +1100 kaos (linux-2.4/n/b/19_Makefile 1.1.1.11 644) +16 -0
@@ -18,6 +18,18 @@ O_OBJS		:=
 
 export-objs		:= usb.o
 
+# usb.o contains usb_init which is marked as __initcall (actually
+# module_init).  usb_init must be executed before all other usb __initcall
+# routines, otherwise the individual drivers will be initialized before the
+# hub driver is, causing the hub driver initialization sequence to
+# needlessly probe every USB driver with the root hub device.  This causes
+# a lot of unnecessary system log messages, a lot of user confusion, and
+# has been known to cause a incorrectly programmed USB device driver to
+# grab the root hub device improperly.
+#     Greg Kroah-Hartman, 27 Oct 2000
+
+LINK_FIRST := usb.o
+
 # Multipart objects.
 
 list-multi		:= usbcore.o
@@ -98,6 +110,10 @@ int-m		:= $(sort $(foreach m, $(multi-m)
 
 obj-m		:= $(filter-out $(obj-y), $(obj-m))
 int-m		:= $(filter-out $(int-y), $(int-m))
+
+# Take multi-part drivers out of obj-y and put components in.
+
+obj-y		:= $(filter-out $(list-multi), $(obj-y)) $(int-y)
 
 # Translate to Rules.make lists.
 

Index: 0-test10-pre6.1/Rules.make

Rules.make Sun, 29 Oct 2000 12:04:05 +1100 kaos (linux-2.4/B/c/24_Rules.make 1.2.1.4 644) renamed from Rules.make Tue, 19 Sep 2000 10:36:07 +1100 kaos (linux-2.4/B/c/24_Rules.make 1.2.1.4 644) +15 -1
@@ -31,6 +31,9 @@ unexport LX_OBJS
 unexport MX_OBJS
 unexport MIX_OBJS
 unexport SYMTAB_OBJS
+# Control link order, added 29 Oct 200 Keith Owens <[email protected]>
+unexport LINK_FIRST
+unexport LINK_LAST
 
 #
 # Get things started.
@@ -84,8 +87,19 @@ all_targets: $(O_TARGET) $(L_TARGET)
 #
 # Rule to compile a set of .o files into one .o file
 #
+# Note: if LINK_FIRST or LINK_LAST are specified, the rest of the
+# object files are sorted to remove duplicates.  Thus, if you use
+# LINK_FIRST/LAST, make sure they specify all ordering requirements.
+#
 ifdef O_TARGET
-ALL_O = $(OX_OBJS) $(O_OBJS)
+  ALL_O = $(OX_OBJS) $(O_OBJS)
+  ifneq ($(strip $(LINK_FIRST)$(LINK_LAST)),)
+    ALL_O := $(sort $(ALL_O))
+    ALL_O := \
+      $(filter $(ALL_O), $(LINK_FIRST)) \
+      $(filter-out $(LINK_FIRST) $(LINK_LAST), $(ALL_O)) \
+      $(filter $(ALL_O), $(LINK_LAST))
+  endif
 $(O_TARGET): $(ALL_O)
 	rm -f $@
     ifneq "$(strip $(ALL_O))" ""

Index: 0-test10-pre6.1/Documentation/kbuild/makefiles.txt

Documentation/kbuild/makefiles.txt Sun, 29 Oct 2000 13:39:06 +1100 kaos (linux-2.4/b/d/12_makefiles. 1.3 644) renamed from Documentation/kbuild/makefiles.txt Mon, 02 Oct 2000 15:28:44 +1100 kaos (linux-2.4/b/d/12_makefiles. 1.3 644) +55 -4

77 lines not on this page · raw message

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/