Skip to contentSkip to conversation

ARM: multi_v7_defconfig: make USB_DWC3 as a module instead of built-in

PATCH In review Roger Quadros 3 participants 8 messages Apr 4, 2023 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: multi_v7_defconfig: make USB_DWC3 as a module instead of built-in

USB_DWC3 is not required for boot on most platforms make it as a module instead of built-in.

---
 arch/arm/configs/multi_v7_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/configs/multi_v7_defconfig +1 -1
index 084cc612ea23..755cc96f23c5 100644
@@ -855,7 +855,7 @@ CONFIG_USB_UX500_DMA=y
 CONFIG_USB_INVENTRA_DMA=y
 CONFIG_USB_TI_CPPI41_DMA=y
 CONFIG_USB_TUSB_OMAP_DMA=y
-CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3=m
 CONFIG_USB_DWC2=y
 CONFIG_USB_CHIPIDEA=y
 CONFIG_USB_CHIPIDEA_UDC=y
Signature · 1 line
2.34.1
#1 lore raw
Quoted 5 lines · Roger Quadros

USB_DWC3 is not required for boot on most platforms make it as a module instead of built-in.

---

Does this save a significant amount of vmlinux size? Since this is a fairly common USB driver, I think it does help to have it built-in for users booting from USB_STORAGE or nfsroot over USB_USBNET, which are both built-in and not uncommon.

Arnd

#2 lore raw
Quoted 11 lines · Arnd Bergmann
Quoted 5 lines · Roger Quadros

USB_DWC3 is not required for boot on most platforms make it as a module instead of built-in.

---

Does this save a significant amount of vmlinux size? Since this is a fairly common USB driver, I think it does help to have it built-in for users booting from USB_STORAGE or nfsroot over USB_USBNET, which are both built-in and not uncommon.

Especially that sometimes, at least for arm64 defconfig, we added as built-in less critical pieces (RENESAS_ETHER_SWITCH, MARVELL_10G_PHY, HTE_TEGRA194, SM_VIDEOCC_8250 and other non-core clock controllers). This change will require several systems to update their initrd to include USB.

Best regards,
Krzysztof

#3 lore raw
Quoted 9 lines · Krzysztof Kozlowski
Quoted 8 lines · Arnd Bergmann
Quoted 5 lines · Roger Quadros

USB_DWC3 is not required for boot on most platforms make it as a module instead of built-in.

---

Does this save a significant amount of vmlinux size? Since this

vmlinux size reduces by ~529KB

Quoted 3 lines
Quoted 3 lines

is a fairly common USB driver, I think it does help to have it built-in for users booting from USB_STORAGE or nfsroot over USB_USBNET, which are both built-in and not uncommon.

OK.

Quoted 6 lines

Especially that sometimes, at least for arm64 defconfig, we added as built-in less critical pieces (RENESAS_ETHER_SWITCH, MARVELL_10G_PHY, HTE_TEGRA194, SM_VIDEOCC_8250 and other non-core clock controllers). This change will require several systems to update their initrd to include USB.

OK. Please ignore this patch and the arm64 defconfig one as well. ;)

cheers,
-roger

#4 lore raw
Quoted 6 lines · Roger Quadros
Quoted 5 lines · Krzysztof Kozlowski
Quoted 4 lines · Arnd Bergmann
Quoted 3 lines · Roger Quadros

USB_DWC3 is not required for boot on most platforms make it as a module instead of built-in.

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

---

Does this save a significant amount of vmlinux size? Since this

vmlinux size reduces by ~529KB

That seems really high, so I had a look at what's going on.

Testing this on multi_v7_defconfig with gcc-13, I only see 163KB difference in (uncompressed) vmlinux file size, or 140KB in the output of 'size vmlinux'. This still seems high, and looking more closely I find that a lot of that is for either Gadget mode or debugfs, while the driver itself is not all that big (most of the host logic is in the xhci driver).

Turning off gadget mode altogether would save 248KB in 'size vmlinux' output, but would also prevent us from enabling gadget driver modules, which is not great either.

I tried setting CONFIG_USB_GADGET=m, but that makes DWC3 and DWC2 host-only and turns CHIPIDEA into a loadable module, so we probably don't want to do that either:

-CONFIG_USB_EHCI_HCD_OMAP=y
+CONFIG_USB_EHCI_HCD_OMAP=m
-CONFIG_USB_DWC3_DUAL_ROLE=y
+CONFIG_USB_DWC3_HOST=y
+CONFIG_USB_DWC2_HOST=y
-CONFIG_USB_DWC2_DUAL_ROLE=y
-CONFIG_USB_CHIPIDEA=y
+CONFIG_USB_CHIPIDEA=m
-CONFIG_USB_ISP1761_UDC=y
-CONFIG_USB_ISP1760_DUAL_ROLE=y
+CONFIG_USB_ISP1760_HOST_ROLE=y

Arnd

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#5 lore raw
Quoted 7 lines · Arnd Bergmann
Quoted 6 lines · Roger Quadros
Quoted 5 lines · Krzysztof Kozlowski
Quoted 4 lines · Arnd Bergmann
Quoted 3 lines · Roger Quadros

USB_DWC3 is not required for boot on most platforms make it as a module instead of built-in.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

---

Does this save a significant amount of vmlinux size? Since this

vmlinux size reduces by ~529KB

That seems really high, so I had a look at what's going on.

It was based on the configuration we are using at TI.

(as built-in)

$ size vmlinux
   text	   data	    bss	    dec	    hex	filename
14616949	5285870	 491776	20394595	1373263	vmlinux
$ ls -l vmlinux
-rwxrwxr-x 1 roger roger 120866544 Apr  4 15:54 vmlinux

(as module)

$ size vmlinux
   text	   data	    bss	    dec	    hex	filename
14550571	5258106	 491776	20300453	135c2a5	vmlinux
$ ls -l vmlinux
-rwxrwxr-x 1 roger roger 120324528 Apr  4 15:52 vmlinux
$ diff built-in-config module-config
5547c5547
< CONFIG_USB_XHCI_PLATFORM=y
---
Quoted 1 line

CONFIG_USB_XHCI_PLATFORM=m

5614c5614
< CONFIG_USB_DWC3=y
---

Quoted 23 lines

CONFIG_USB_DWC3=m

Testing this on multi_v7_defconfig with gcc-13, I only see 163KB difference in (uncompressed) vmlinux file size, or 140KB in the output of 'size vmlinux'. This still seems high, and looking more closely I find that a lot of that is for either Gadget mode or debugfs, while the driver itself is not all that big (most of the host logic is in the xhci driver).

Turning off gadget mode altogether would save 248KB in 'size vmlinux' output, but would also prevent us from enabling gadget driver modules, which is not great either.

I tried setting CONFIG_USB_GADGET=m, but that makes DWC3 and DWC2 host-only and turns CHIPIDEA into a loadable module, so we probably don't want to do that either:

(quoted diff) +1 -2
-CONFIG_USB_EHCI_HCD_OMAP=y
+CONFIG_USB_EHCI_HCD_OMAP=m
-CONFIG_USB_DWC3_DUAL_ROLE=y

Review

Quoted 10 lines
(quoted diff) +4 -4
+CONFIG_USB_DWC3_HOST=y
+CONFIG_USB_DWC2_HOST=y
-CONFIG_USB_DWC2_DUAL_ROLE=y
-CONFIG_USB_CHIPIDEA=y
+CONFIG_USB_CHIPIDEA=m
-CONFIG_USB_ISP1761_UDC=y
-CONFIG_USB_ISP1760_DUAL_ROLE=y
+CONFIG_USB_ISP1760_HOST_ROLE=y
 
    Arnd

cheers,
-roger

#6 lore raw
Quoted 23 lines · Roger Quadros
Quoted 2 lines · Arnd Bergmann

On Tue, Apr 4, 2023, at 13:46, Roger Quadros wrote:
That seems really high, so I had a look at what's going on.

It was based on the configuration we are using at TI.

(as built-in)

$ size vmlinux
   text	   data	    bss	    dec	    hex	filename
14616949	5285870	 491776	20394595	1373263	vmlinux
$ ls -l vmlinux
-rwxrwxr-x 1 roger roger 120866544 Apr  4 15:54 vmlinux

(as module)

$ size vmlinux
   text	   data	    bss	    dec	    hex	filename
14550571	5258106	 491776	20300453	135c2a5	vmlinux
$ ls -l vmlinux
-rwxrwxr-x 1 roger roger 120324528 Apr  4 15:52 vmlinux
Quoted 9 lines
$ diff built-in-config module-config
5547c5547
< CONFIG_USB_XHCI_PLATFORM=y
---
Quoted 1 line

CONFIG_USB_XHCI_PLATFORM=m

5614c5614
< CONFIG_USB_DWC3=y
---

Quoted 1 line

CONFIG_USB_DWC3=m

Ok, so the size difference here is only 94KB, presumably because have the non-TI variants as well as debugfs and/or gadget mode disabled. For the file size, my guess is that you have CONFIG_DEBUG_INFO enabled in your config, which drastically increases the size of the vmlinux file, but not the in-memory size, or the size of the stripped and compressed zImage.

Arnd

#7 lore raw
Quoted 32 lines · Arnd Bergmann
Quoted 31 lines · Roger Quadros
Quoted 2 lines · Arnd Bergmann

On Tue, Apr 4, 2023, at 13:46, Roger Quadros wrote:
That seems really high, so I had a look at what's going on.

It was based on the configuration we are using at TI.

(as built-in)

$ size vmlinux
   text	   data	    bss	    dec	    hex	filename
14616949	5285870	 491776	20394595	1373263	vmlinux
$ ls -l vmlinux
-rwxrwxr-x 1 roger roger 120866544 Apr  4 15:54 vmlinux

(as module)

$ size vmlinux
   text	   data	    bss	    dec	    hex	filename
14550571	5258106	 491776	20300453	135c2a5	vmlinux
$ ls -l vmlinux
-rwxrwxr-x 1 roger roger 120324528 Apr  4 15:52 vmlinux
$ diff built-in-config module-config
5547c5547
< CONFIG_USB_XHCI_PLATFORM=y
---
Quoted 1 line

CONFIG_USB_XHCI_PLATFORM=m

5614c5614
< CONFIG_USB_DWC3=y
---

Quoted 6 lines
Quoted 1 line
Quoted 1 line

CONFIG_USB_DWC3=m

Ok, so the size difference here is only 94KB, presumably because have the non-TI variants as well as debugfs and/or gadget mode disabled. For the file size, my guess is that you have CONFIG_DEBUG_INFO enabled in your config, which

That's right.

Quoted 3 lines

drastically increases the size of the vmlinux file, but not the in-memory size, or the size of the stripped and compressed zImage.

Image file diff is ~128K.
Image.gz diff is ~33K.

--
cheers,
-roger