xhci-pci: Make xhci-pci-renesas a proper modular driver
Subsystems (2)
PATCH 1/1 xhci-pci: Make xhci-pci-renesas a proper modular driver
If CONFIG_USB_XHCI_PCI_RENESAS is enabled, xhci-pci conditionally calls into the xhci-pci-renesas module, which means both modules must be loaded to use any xHCI PCI controller.
The MODULE_FIRMWARE declaration in the base xhci-pci module causes initramfs-tools to check for and warn about missing firmware for the Renesas xHCI controllers, when any xHCI PCI controller is present. And because of the previous oddity, simply moving this declaration to xhci-pci-renesas wouldn't help.
To fix this, reverse the relationship between the modules:
- Remove the quirk for the Renesas xHCIs, and the driver_data structure used only for them
- In xhci-pci:
- Rename xhci_pci_probe() to xhci_pci_common_probe()
- Export xhci_pci_common_probe() and xhci_pci_remove()
- Use a new probe function that rejects the Renesas xHCIs and then calls the common probe function
- In xhci-pci-renesas:
- Stop exporting renesas_xhci_check_request_fw()
- Add a probe function that calls renesas_xhci_check_request_fw() followed by xhci_pci_common_probe()
- Add and register a new pci_driver matching only the Renesas xHCIs and using its own probe function, but with other operations the same as in xhci-pci
- Make CONFIG_USB_XHCI_PCI_RENESAS depend on CONFIG_USB_XHCI_PCI, not the other way around
Finally, move the MODULE_FIRMWARE declaration to xhci-pci-renesas.
--- drivers/usb/host/Kconfig | 2 +- drivers/usb/host/xhci-pci-renesas.c | 47 +++++++++++++++++++++--- drivers/usb/host/xhci-pci.c | 57 ++++++++++------------------- drivers/usb/host/xhci-pci.h | 19 +--------- drivers/usb/host/xhci.h | 2 +- 5 files changed, 64 insertions(+), 63 deletions(-)
drivers/usb/host/Kconfig +1 -1
@@ -40,11 +40,11 @@ config USB_XHCI_DBGCAP config USB_XHCI_PCI tristate depends on USB_PCI - depends on USB_XHCI_PCI_RENESAS || !USB_XHCI_PCI_RENESAS default y config USB_XHCI_PCI_RENESAS tristate "Support for additional Renesas xHCI controller with firmware" + depends on USB_XHCI_PCI help Say 'Y' to enable the support for the Renesas xHCI controller with firmware. Make sure you have the firmware for the device and
drivers/usb/host/xhci-pci-renesas.c +41 -6
65 lines not on this page · raw message
drivers/usb/host/xhci-pci.c +19 -38
102 lines not on this page · raw message
drivers/usb/host/xhci-pci.h +2 -17
@@ -4,22 +4,7 @@#ifndef XHCI_PCI_H #define XHCI_PCI_H -#if IS_ENABLED (CONFIG_USB_XHCI_PCI_RENESAS ) -int renesas_xhci_check_request_fw (struct pci_dev *dev, -const struct pci_device_id *id); - -#else -static int renesas_xhci_check_request_fw (struct pci_dev *dev, -const struct pci_device_id *id) -{ -return 0 ; -} - -#endif - -struct xhci_driver_data { -u64 quirks; -const char *firmware; -}; +int xhci_pci_common_probe (struct pci_dev *dev,const struct pci_device_id *id); +void xhci_pci_remove (struct pci_dev *dev);#endif
drivers/usb/host/xhci.h +1 -1
@@ -1617,7 +1617,7 @@ struct xhci_hcd {#define XHCI_DEFAULT_PM_RUNTIME_ALLOW BIT_ULL(33)#define XHCI_RESET_PLL_ON_DISCONNECT BIT_ULL(34)#define XHCI_SNPS_BROKEN_SUSPEND BIT_ULL(35) -#define XHCI_RENESAS_FW_QUIRK BIT_ULL(36) +/* Reserved. It was XHCI_RENESAS_FW_QUIRK */ #define XHCI_SKIP_PHY_INIT BIT_ULL(37)#define XHCI_DISABLE_SPARSE BIT_ULL(38)#define XHCI_SG_TRB_CACHE_SIZE_QUIRK BIT_ULL(39)
Greg KH
maintainerQuoted 29 lines · Ben Hutchings
If
CONFIG_USB_XHCI_PCI_RENESASis enabled, xhci-pci conditionally calls into the xhci-pci-renesas module, which means both modules must be loaded to use any xHCI PCI controller.The
MODULE_FIRMWAREdeclaration in the base xhci-pci module causes initramfs-tools to check for and warn about missing firmware for the Renesas xHCI controllers, when any xHCI PCI controller is present. And because of the previous oddity, simply moving this declaration to xhci-pci-renesas wouldn't help.To fix this, reverse the relationship between the modules:
- Remove the quirk for the Renesas xHCIs, and the
driver_datastructure used only for them
- In xhci-pci:
- Renamexhci_pci_probe()toxhci_pci_common_probe()
- Exportxhci_pci_common_probe()andxhci_pci_remove()
- Use a new probe function that rejects the Renesas xHCIs and then calls the common probe function
- In xhci-pci-renesas:
- Stop exportingrenesas_xhci_check_request_fw()
- Add a probe function that callsrenesas_xhci_check_request_fw()followed byxhci_pci_common_probe()
- Add and register a newpci_drivermatching only the Renesas xHCIs and using its own probe function, but with other operations the same as in xhci-pci
- MakeCONFIG_USB_XHCI_PCI_RENESASdepend onCONFIG_USB_XHCI_PCI, not the other way around
Quoted 1 line
Finally, move the
MODULE_FIRMWAREdeclaration to xhci-pci-renesas.
Thanks for doing this, this has long bugged me, and "simple" fixes didn't seem to do it, but this looks nice. I'll queue it up after -rc1 is out.
greg k-h
Ben Hutchings <[email protected]> (2024-07-25):
Quoted 29 lines
If
CONFIG_USB_XHCI_PCI_RENESASis enabled, xhci-pci conditionally calls into the xhci-pci-renesas module, which means both modules must be loaded to use any xHCI PCI controller.The
MODULE_FIRMWAREdeclaration in the base xhci-pci module causes initramfs-tools to check for and warn about missing firmware for the Renesas xHCI controllers, when any xHCI PCI controller is present. And because of the previous oddity, simply moving this declaration to xhci-pci-renesas wouldn't help.To fix this, reverse the relationship between the modules:
- Remove the quirk for the Renesas xHCIs, and the
driver_datastructure used only for them
- In xhci-pci:
- Renamexhci_pci_probe()toxhci_pci_common_probe()
- Exportxhci_pci_common_probe()andxhci_pci_remove()
- Use a new probe function that rejects the Renesas xHCIs and then calls the common probe function
- In xhci-pci-renesas:
- Stop exportingrenesas_xhci_check_request_fw()
- Add a probe function that callsrenesas_xhci_check_request_fw()followed byxhci_pci_common_probe()
- Add and register a newpci_drivermatching only the Renesas xHCIs and using its own probe function, but with other operations the same as in xhci-pci
- MakeCONFIG_USB_XHCI_PCI_RENESASdepend onCONFIG_USB_XHCI_PCI, not the other way around
Quoted 3 lines
Finally, move the
MODULE_FIRMWAREdeclaration to xhci-pci-renesas.Signed-off-by Ben Hutchings <[email protected]>
On top of 16f3a28cf5f876a7f3550d8f4c870a7b41bcfaef, starting from a distribution-oriented .config (Debian's 6.10-1~exp1 arm64 package), default answers to oldconfig, adding CONFIG_USB_XHCI_PCI_RENESAS=m afterwards.
On the hardware side: Raspberry Pi CM4 Lite on a CM4 IO Board, with two (slightly) different Supahub PCIe-to-quad-USB cards (006 and 006S), everything is good with the firmware available. Otherwise this happens:
[ 7.965954] xhci-pci-renesas 0000:01:00.0: failed to load firmware renesas_usb_fw.mem, fallback to ROM
[ 7.975705] xhci-pci-renesas 0000:01:00.0: xHCI Host Controller
[ 7.981728] xhci-pci-renesas 0000:01:00.0: new USB bus registered, assigned bus number 1
[ 27.982001] xhci-pci-renesas 0000:01:00.0: can't setup: -110
[ 27.987787] xhci-pci-renesas 0000:01:00.0: USB bus 1 deregistered
[ 27.994007] xhci-pci-renesas 0000:01:00.0: init 0000:01:00.0 fail, -110
[ 28.000742] xhci-pci-renesas 0000:01:00.0: probe with driver xhci-pci-renesas failed with error -110(No onboard ROM on those.)
Thanks, Ben!
Cheers,
Signature · 2 lines
Cyril Brulebois ([email protected]) <https://debamax.com/> D-I release manager -- Release team member -- Freelance Consultant
Greg KH
maintainerQuoted 31 lines · Ben Hutchings
If
CONFIG_USB_XHCI_PCI_RENESASis enabled, xhci-pci conditionally calls into the xhci-pci-renesas module, which means both modules must be loaded to use any xHCI PCI controller.The
MODULE_FIRMWAREdeclaration in the base xhci-pci module causes initramfs-tools to check for and warn about missing firmware for the Renesas xHCI controllers, when any xHCI PCI controller is present. And because of the previous oddity, simply moving this declaration to xhci-pci-renesas wouldn't help.To fix this, reverse the relationship between the modules:
- Remove the quirk for the Renesas xHCIs, and the
driver_datastructure used only for them
- In xhci-pci:
- Renamexhci_pci_probe()toxhci_pci_common_probe()
- Exportxhci_pci_common_probe()andxhci_pci_remove()
- Use a new probe function that rejects the Renesas xHCIs and then calls the common probe function
- In xhci-pci-renesas:
- Stop exportingrenesas_xhci_check_request_fw()
- Add a probe function that callsrenesas_xhci_check_request_fw()followed byxhci_pci_common_probe()
- Add and register a newpci_drivermatching only the Renesas xHCIs and using its own probe function, but with other operations the same as in xhci-pci
- MakeCONFIG_USB_XHCI_PCI_RENESASdepend onCONFIG_USB_XHCI_PCI, not the other way aroundFinally, move the
MODULE_FIRMWAREdeclaration to xhci-pci-renesas.
Quoted 9 lines
Signed-off-by Ben Hutchings <[email protected]>--- drivers/usb/host/Kconfig | 2 +- drivers/usb/host/xhci-pci-renesas.c | 47 +++++++++++++++++++++--- drivers/usb/host/xhci-pci.c | 57 ++++++++++------------------- drivers/usb/host/xhci-pci.h | 19 +--------- drivers/usb/host/xhci.h | 2 +- 5 files changed, 64 insertions(+), 63 deletions(-)
I get the following error when building:
drivers/usb/host/xhci-pci.c:646:5: error: no previous prototype for ‘xhci_pci_probe’ [-Werror=missing-prototypes]
646 | int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
| ^~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Can you rebase against 6.11-rc1 and fix up and resend?
thanks,
greg k-h
PATCH v2 1/1 xhci-pci: Make xhci-pci-renesas a proper modular driver
If CONFIG_USB_XHCI_PCI_RENESAS is enabled, xhci-pci conditionally calls into the xhci-pci-renesas module, which means both modules must be loaded to use any xHCI PCI controller.
The MODULE_FIRMWARE declaration in the base xhci-pci module causes initramfs-tools to check for and warn about missing firmware for the Renesas xHCI controllers, when any xHCI PCI controller is present. And because of the previous oddity, simply moving this declaration to xhci-pci-renesas wouldn't help.
To fix this, reverse the relationship between the modules:
- Remove the quirk for the Renesas xHCIs, and the driver_data structure used only for them
- In xhci-pci:
- Rename xhci_pci_probe() to xhci_pci_common_probe()
- Export xhci_pci_common_probe() and xhci_pci_remove()
- Use a new probe function that rejects the Renesas xHCIs and then calls the common probe function
- In xhci-pci-renesas:
- Stop exporting renesas_xhci_check_request_fw()
- Add a probe function that calls renesas_xhci_check_request_fw() followed by xhci_pci_common_probe()
- Add and register a new pci_driver matching only the Renesas xHCIs and using its own probe function, but with other operations the same as in xhci-pci
- Make CONFIG_USB_XHCI_PCI_RENESAS depend on CONFIG_USB_XHCI_PCI, not the other way around
Finally, move the MODULE_FIRMWARE declaration to xhci-pci-renesas.
---
v2:
- Fix definition of xhci_pci_probe() to remain static
- Rebase onto v6.11-rc1
drivers/usb/host/Kconfig | 2 +- drivers/usb/host/xhci-pci-renesas.c | 48 ++++++++++++++++++++---- drivers/usb/host/xhci-pci.c | 57 ++++++++++------------------- drivers/usb/host/xhci-pci.h | 19 +--------- drivers/usb/host/xhci.h | 2 +- 5 files changed, 64 insertions(+), 64 deletions(-)
drivers/usb/host/Kconfig +1 -1
@@ -40,11 +40,11 @@ config USB_XHCI_DBGCAP config USB_XHCI_PCI tristate depends on USB_PCI - depends on USB_XHCI_PCI_RENESAS || !USB_XHCI_PCI_RENESAS default y config USB_XHCI_PCI_RENESAS tristate "Support for additional Renesas xHCI controller with firmware" + depends on USB_XHCI_PCI help Say 'Y' to enable the support for the Renesas xHCI controller with firmware. Make sure you have the firmware for the device and
drivers/usb/host/xhci-pci-renesas.c +41 -7
66 lines not on this page · raw message
drivers/usb/host/xhci-pci.c +19 -38
102 lines not on this page · raw message
drivers/usb/host/xhci-pci.h +2 -17
@@ -4,22 +4,7 @@#ifndef XHCI_PCI_H #define XHCI_PCI_H -#if IS_ENABLED (CONFIG_USB_XHCI_PCI_RENESAS ) -int renesas_xhci_check_request_fw (struct pci_dev *dev, -const struct pci_device_id *id); - -#else -static int renesas_xhci_check_request_fw (struct pci_dev *dev, -const struct pci_device_id *id) -{ -return 0 ; -} - -#endif - -struct xhci_driver_data { -u64 quirks; -const char *firmware; -}; +int xhci_pci_common_probe (struct pci_dev *dev,const struct pci_device_id *id); +void xhci_pci_remove (struct pci_dev *dev);#endif
drivers/usb/host/xhci.h +1 -1
@@ -1616,7 +1616,7 @@ struct xhci_hcd {#define XHCI_DEFAULT_PM_RUNTIME_ALLOW BIT_ULL(33)#define XHCI_RESET_PLL_ON_DISCONNECT BIT_ULL(34)#define XHCI_SNPS_BROKEN_SUSPEND BIT_ULL(35) -#define XHCI_RENESAS_FW_QUIRK BIT_ULL(36) +/* Reserved. It was XHCI_RENESAS_FW_QUIRK */ #define XHCI_SKIP_PHY_INIT BIT_ULL(37)#define XHCI_DISABLE_SPARSE BIT_ULL(38)#define XHCI_SG_TRB_CACHE_SIZE_QUIRK BIT_ULL(39)
Ben Hutchings <[email protected]> (2024-07-31):
Quoted 3 lines
v2:
- Fix definition ofxhci_pci_probe()to remain static
- Rebase onto v6.11-rc1
On top of 21b136cc63d2a9ddd60d4699552b69c214b32964, starting from a distribution-oriented .config (Debian's 6.10-1~exp1 arm64 package), default answers to oldconfig, adding CONFIG_USB_XHCI_PCI_RENESAS=m afterwards.
On the hardware side: Raspberry Pi CM4 Lite on a CM4 IO Board, with two (slightly) different Supahub PCIe-to-quad-USB cards (006 and 006S), everything is good with the firmware available. Otherwise this happens:
[ 8.037155] xhci-pci-renesas 0000:01:00.0: failed to load firmware renesas_usb_fw.mem, fallback to ROM [ 8.046687] xhci-pci-renesas 0000:01:00.0: xHCI Host Controller [ 8.052712] xhci-pci-renesas 0000:01:00.0: new USB bus registered, assigned bus number 1 [ 27.944117] xhci-pci-renesas 0000:01:00.0: can't setup: -110 [ 27.949903] xhci-pci-renesas 0000:01:00.0: USB bus 1 deregistered [ 27.956121] xhci-pci-renesas 0000:01:00.0: init 0000:01:00.0 fail, -110 [ 27.962837] xhci-pci-renesas 0000:01:00.0: probe with driver xhci-pci-renesas failed with error -110
(No onboard ROM on those.)
Thanks, Ben!
Cheers,
Signature · 2 lines
Cyril Brulebois ([email protected]) <https://debamax.com/> D-I release manager -- Release team member -- Freelance Consultant