Skip to contentSkip to conversation

drivers/net: Makefile, fix netconsole link order

PATCH In review Lin Ming 2 participants 5 messages Sep 6, 2011 – Sep 10, 2011

Subsystems (3)
lore
Share & tools
lore

Lin Ming

author
#0 lore raw

PATCH 1/1 drivers/net: Makefile, fix netconsole link order

Commit 88491d8(drivers/net: Kconfig & Makefile cleanup) causes a regression that netconsole does not work if netconsole and network device driver are build into kernel, because netconsole is linked before network device driver.

Fixes it by moving netconsole.o after network device driver.

---
 drivers/net/Makefile |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/net/Makefile +6 -1
index fa877cd..ec15311 100644
@@ -14,7 +14,6 @@ obj-$(CONFIG_MACVTAP) += macvtap.o
 obj-$(CONFIG_MII) += mii.o
 obj-$(CONFIG_MDIO) += mdio.o
 obj-$(CONFIG_NET) += Space.o loopback.o
-obj-$(CONFIG_NETCONSOLE) += netconsole.o
 obj-$(CONFIG_PHYLIB) += phy/
 obj-$(CONFIG_RIONET) += rionet.o
 obj-$(CONFIG_TUN) += tun.o
@@ -66,3 +65,9 @@ obj-$(CONFIG_USB_USBNET)        += usb/
 obj-$(CONFIG_USB_ZD1201)        += usb/
 obj-$(CONFIG_USB_IPHETH)        += usb/
 obj-$(CONFIG_USB_CDC_PHONET)   += usb/
+
+#
+# If netconsole and network device driver are build-in,
+# netconsole must be linked after network device driver
+#
+obj-$(CONFIG_NETCONSOLE) += netconsole.o
Signature · 1 line
1.7.2.5
#1 lore raw
Quoted 25 lines · On Tue, 06 Sep 2011 16:35:29 +0800 Lin Ming <[email protected]> wrote:

Commit 88491d8(drivers/net: Kconfig & Makefile cleanup) causes a regression that netconsole does not work if netconsole and network device driver are build into kernel, because netconsole is linked before network device driver.

Fixes it by moving netconsole.o after network device driver.

---
 drivers/net/Makefile |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/net/Makefile +0 -1
index fa877cd..ec15311 100644
@@ -14,7 +14,6 @@ obj-$(CONFIG_MACVTAP) += macvtap.o
 obj-$(CONFIG_MII) += mii.o
 obj-$(CONFIG_MDIO) += mdio.o
 obj-$(CONFIG_NET) += Space.o loopback.o
-obj-$(CONFIG_NETCONSOLE) += netconsole.o
 obj-$(CONFIG_PHYLIB) += phy/
 obj-$(CONFIG_RIONET) += rionet.o
 obj-$(CONFIG_TUN) += tun.o

drivers/net/Makefile obj-$(CONFIG_USB_USBNET) += usb/ · line 73

Quoted 9 lines
drivers/net/Makefile +6 -0
@@ -66,3 +65,9 @@ obj-$(CONFIG_USB_USBNET)        += usb/
 obj-$(CONFIG_USB_ZD1201)        += usb/
 obj-$(CONFIG_USB_IPHETH)        += usb/
 obj-$(CONFIG_USB_CDC_PHONET)   += usb/
+
+#
+# If netconsole and network device driver are build-in,
+# netconsole must be linked after network device driver
+#
+obj-$(CONFIG_NETCONSOLE) += netconsole.o

It would be preferable to fix this with initcall ordering. Perhaps by switching init_netconsole() to subsys_initcall.

author
#2 lore raw
Quoted 32 lines · Andrew Morton
Quoted 29 lines · On Tue, 06 Sep 2011 16:35:29 +0800 Lin Ming <[email protected]> wrote:

Commit 88491d8(drivers/net: Kconfig & Makefile cleanup) causes a regression that netconsole does not work if netconsole and network device driver are build into kernel, because netconsole is linked before network device driver.

Fixes it by moving netconsole.o after network device driver.

---
 drivers/net/Makefile |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/net/Makefile +1 -1
index fa877cd..ec15311 100644
@@ -14,7 +14,6 @@ obj-$(CONFIG_MACVTAP) += macvtap.o
 obj-$(CONFIG_MII) += mii.o
 obj-$(CONFIG_MDIO) += mdio.o
 obj-$(CONFIG_NET) += Space.o loopback.o
-obj-$(CONFIG_NETCONSOLE) += netconsole.o
 obj-$(CONFIG_PHYLIB) += phy/
 obj-$(CONFIG_RIONET) += rionet.o
 obj-$(CONFIG_TUN) += tun.o
@@ -66,3 +65,9 @@ obj-$(CONFIG_USB_USBNET)        += usb/
 obj-$(CONFIG_USB_ZD1201)        += usb/
 obj-$(CONFIG_USB_IPHETH)        += usb/
 obj-$(CONFIG_USB_CDC_PHONET)   += usb/
+
Quoted 8 lines

drivers/net/Makefile obj-$(CONFIG_USB_USBNET) += usb/ · line 73

Quoted 5 lines
drivers/net/Makefile +5 -0
+#
+# If netconsole and network device driver are build-in,
+# netconsole must be linked after network device driver
+#
+obj-$(CONFIG_NETCONSOLE) += netconsole.o

It would be preferable to fix this with initcall ordering. Perhaps by switching init_netconsole() to subsys_initcall.

subsys_initcall is defined as __define_initcall("4",fn,4). In !MODULE case, device driver module_int() is defined as __define_initcall("6",fn,6)

If we use subsys_initcall for init_netconsole, it will still be called before network device driver is initialized.

How about late_initcall?

(Not tested yet)

Quoted 1 line

From 11f4f035e96ff430192d0a75552dd715acb5f3b8 Mon Sep 17 00:00:00 2001

From: Lin Ming <[email protected]>
Date: Sat, 10 Sep 2011 10:36:10 +0800
Subject: [PATCH] drivers/net: Makefile, fix netconsole link order

Commit 88491d8(drivers/net: Kconfig & Makefile cleanup) causes a regression that netconsole does not work if netconsole and network device driver are build into kernel, because netconsole is linked before network device driver.

Fixes it by switching init_netconsole() to late_initcall if it's build-in.

---
 drivers/net/netconsole.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/net/netconsole.c +4 -0
index dfc8272..914be29 100644
@@ -799,5 +799,9 @@ static void __exit cleanup_netconsole(void)
 	}
 }
 
+#ifdef MODULE
 module_init(init_netconsole);
 module_exit(cleanup_netconsole);
+#else
+late_initcall(init_netconsole);
+#endif /* !MODULE */
Signature · 1 line
1.7.2.3
#3 lore raw
Quoted 10 lines · On Sat, 10 Sep 2011 10:43:32 +0800 Lin Ming <[email protected]> wrote:
Quoted 4 lines · Andrew Morton
Quoted 1 line

+obj-$(CONFIG_NETCONSOLE) += netconsole.o

It would be preferable to fix this with initcall ordering. Perhaps by switching init_netconsole() to subsys_initcall.

subsys_initcall is defined as __define_initcall("4",fn,4). In !MODULE case, device driver module_int() is defined as __define_initcall("6",fn,6)

oop, yes, I am chronologically challenged.

Quoted 30 lines

If we use subsys_initcall for init_netconsole, it will still be called before network device driver is initialized.

How about late_initcall?

(Not tested yet)

Quoted 1 line

From 11f4f035e96ff430192d0a75552dd715acb5f3b8 Mon Sep 17 00:00:00 2001

From: Lin Ming <[email protected]>
Date: Sat, 10 Sep 2011 10:36:10 +0800
Subject: [PATCH] drivers/net: Makefile, fix netconsole link order

Commit 88491d8(drivers/net: Kconfig & Makefile cleanup) causes a regression that netconsole does not work if netconsole and network device driver are build into kernel, because netconsole is linked before network device driver.

Fixes it by switching init_netconsole() to late_initcall if it's build-in.

---
 drivers/net/netconsole.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/net/netconsole.c +0 -0
index dfc8272..914be29 100644

drivers/net/netconsole.c static void __exit cleanup_netconsole(void) · line 807

Quoted 9 lines
drivers/net/netconsole.c +4 -0
@@ -799,5 +799,9 @@ static void __exit cleanup_netconsole(void)
 	}
 }
 
+#ifdef MODULE
 module_init(init_netconsole);
 module_exit(cleanup_netconsole);
+#else
+late_initcall(init_netconsole);
+#endif /* !MODULE */

That should work, unless any net driver is weirdly also using late_initcall. But if there are such drivers, they would have failed with the old Makefile ordering.

author
#4 lore raw
Quoted 48 lines · Andrew Morton
Quoted 10 lines · On Sat, 10 Sep 2011 10:43:32 +0800 Lin Ming <[email protected]> wrote:
Quoted 4 lines · Andrew Morton
Quoted 1 line

+obj-$(CONFIG_NETCONSOLE) += netconsole.o

It would be preferable to fix this with initcall ordering. Perhaps by switching init_netconsole() to subsys_initcall.

subsys_initcall is defined as __define_initcall("4",fn,4). In !MODULE case, device driver module_int() is defined as __define_initcall("6",fn,6)

oop, yes, I am chronologically challenged.

Quoted 33 lines

If we use subsys_initcall for init_netconsole, it will still be called before network device driver is initialized.

How about late_initcall?

(Not tested yet)

Quoted 1 line

From 11f4f035e96ff430192d0a75552dd715acb5f3b8 Mon Sep 17 00:00:00 2001

From: Lin Ming <[email protected]>
Date: Sat, 10 Sep 2011 10:36:10 +0800
Subject: [PATCH] drivers/net: Makefile, fix netconsole link order

Commit 88491d8(drivers/net: Kconfig & Makefile cleanup) causes a regression that netconsole does not work if netconsole and network device driver are build into kernel, because netconsole is linked before network device driver.

Fixes it by switching init_netconsole() to late_initcall if it's build-in.

---
 drivers/net/netconsole.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/net/netconsole.c +0 -0
index dfc8272..914be29 100644
@@ -799,5 +799,9 @@ static void __exit cleanup_netconsole(void)
 	}
 }
 
Quoted 10 lines

drivers/net/netconsole.c static void __exit cleanup_netconsole(void) · line 807

Quoted 6 lines
drivers/net/netconsole.c +4 -0
+#ifdef MODULE
 module_init(init_netconsole);
 module_exit(cleanup_netconsole);
+#else
+late_initcall(init_netconsole);
+#endif /* !MODULE */

That should work, unless any net driver is weirdly also using late_initcall. But if there are such drivers, they would have failed with the old Makefile ordering.

Yes.

BTW, may I get your ACK after testing this patch?

Thanks.