Skip to contentSkip to conversation

usb: xhci: avoid renesas_usb_fw.mem when it's unusable

PATCH Superseded Greg Thelen 2 participants 4 messages Jul 2, 2021

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

PATCH 1/1 usb: xhci: avoid renesas_usb_fw.mem when it's unusable

Commit a66d21d7dba8 ("usb: xhci: Add support for Renesas controller with memory") added renesas_usb_fw.mem firmware reference to xhci-pci. Thus modinfo indicates xhci-pci.ko has "firmware: renesas_usb_fw.mem". But the firmware is only actually used with CONFIG_USB_XHCI_PCI_RENESAS. An unusable firmware reference can trigger safety checkers which look for drivers with unmet firmware dependencies.

Avoid referring to renesas_usb_fw.mem in circumstances when it cannot be loaded (when CONFIG_USB_XHCI_PCI_RENESAS isn't set).

---
 drivers/usb/host/xhci-pci.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/usb/host/xhci-pci.c +8 -0
index 18c2bbddf080..cb148da7a789 100644
@@ -618,8 +618,10 @@ static void xhci_pci_shutdown(struct usb_hcd *hcd)
 /*-------------------------------------------------------------------------*/
 
 static const struct xhci_driver_data reneses_data = {
+#if IS_ENABLED(CONFIG_USB_XHCI_PCI_RENESAS)
 	.quirks  = XHCI_RENESAS_FW_QUIRK,
 	.firmware = "renesas_usb_fw.mem",
+#endif
 };
 
 /* PCI driver selection metadata; PCI hotplugging uses this */
@@ -636,7 +638,13 @@ static const struct pci_device_id pci_ids[] = {
 	{ /* end: all zeroes */ }
 };
 MODULE_DEVICE_TABLE(pci, pci_ids);
+/*
+ * Without CONFIG_USB_XHCI_PCI_RENESAS renesas_xhci_check_request_fw() won't
+ * load firmware, so don't encumber the xhci-pci driver with it.
+ */
+#if IS_ENABLED(CONFIG_USB_XHCI_PCI_RENESAS)
 MODULE_FIRMWARE("renesas_usb_fw.mem");
+#endif
 
 /* pci driver glue; this is a "new style" PCI driver module */
 static struct pci_driver xhci_pci_driver = {
Signature · 1 line
2.32.0.93.g670b81a890-goog
#1 lore raw
Quoted 20 lines · Greg Thelen

Commit a66d21d7dba8 ("usb: xhci: Add support for Renesas controller with memory") added renesas_usb_fw.mem firmware reference to xhci-pci. Thus modinfo indicates xhci-pci.ko has "firmware: renesas_usb_fw.mem". But the firmware is only actually used with CONFIG_USB_XHCI_PCI_RENESAS. An unusable firmware reference can trigger safety checkers which look for drivers with unmet firmware dependencies.

Avoid referring to renesas_usb_fw.mem in circumstances when it cannot be loaded (when CONFIG_USB_XHCI_PCI_RENESAS isn't set).

---
 drivers/usb/host/xhci-pci.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/usb/host/xhci-pci.c +0 -0
index 18c2bbddf080..cb148da7a789 100644

drivers/usb/host/xhci-pci.c static void xhci_pci_shutdown(struct usb_hcd *hcd) · line 621

Quoted 4 lines
drivers/usb/host/xhci-pci.c +1 -0
@@ -618,8 +618,10 @@ static void xhci_pci_shutdown(struct usb_hcd *hcd)
 /*-------------------------------------------------------------------------*/
 
 static const struct xhci_driver_data reneses_data = {
+#if IS_ENABLED(CONFIG_USB_XHCI_PCI_RENESAS)

If this is not enabled, why is the whole structure needed?

Quoted 7 lines
drivers/usb/host/xhci-pci.c +1 -0
 	.quirks  = XHCI_RENESAS_FW_QUIRK,
 	.firmware = "renesas_usb_fw.mem",
+#endif
 };
 
 /* PCI driver selection metadata; PCI hotplugging uses this */

drivers/usb/host/xhci-pci.c static const struct pci_device_id pci_ids[] = { · line 647

Quoted 10 lines
drivers/usb/host/xhci-pci.c +6 -0
@@ -636,7 +638,13 @@ static const struct pci_device_id pci_ids[] = {
 	{ /* end: all zeroes */ }
 };
 MODULE_DEVICE_TABLE(pci, pci_ids);
+/*
+ * Without CONFIG_USB_XHCI_PCI_RENESAS renesas_xhci_check_request_fw() won't
+ * load firmware, so don't encumber the xhci-pci driver with it.
+ */
+#if IS_ENABLED(CONFIG_USB_XHCI_PCI_RENESAS)
 MODULE_FIRMWARE("renesas_usb_fw.mem");
+#endif

Why not just have this one chunk, why is the first chunk needed?

And a blank line please before your comment?

And can you add a Fixes: line to the changelog text when you resend?

thanks,

greg k-h

#2 lore raw
Quoted 23 lines · Greg Kroah-Hartman
Quoted 22 lines · Greg Thelen

Commit a66d21d7dba8 ("usb: xhci: Add support for Renesas controller with memory") added renesas_usb_fw.mem firmware reference to xhci-pci. Thus modinfo indicates xhci-pci.ko has "firmware: renesas_usb_fw.mem". But the firmware is only actually used with CONFIG_USB_XHCI_PCI_RENESAS. An unusable firmware reference can trigger safety checkers which look for drivers with unmet firmware dependencies.

Avoid referring to renesas_usb_fw.mem in circumstances when it cannot be loaded (when CONFIG_USB_XHCI_PCI_RENESAS isn't set).

---
 drivers/usb/host/xhci-pci.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/usb/host/xhci-pci.c +0 -0
index 18c2bbddf080..cb148da7a789 100644
@@ -618,8 +618,10 @@ static void xhci_pci_shutdown(struct usb_hcd *hcd)
 /*-------------------------------------------------------------------------*/
 
Quoted 4 lines

drivers/usb/host/xhci-pci.c static void xhci_pci_shutdown(struct usb_hcd *hcd) · line 621

Quoted 2 lines
drivers/usb/host/xhci-pci.c +1 -0
 static const struct xhci_driver_data reneses_data = {
+#if IS_ENABLED(CONFIG_USB_XHCI_PCI_RENESAS)

If this is not enabled, why is the whole structure needed?

Removing the struct meant 2 more #if guards needed below to initialize pci_ids, which exceeded my taste.

Quoted 5 lines
Quoted 5 lines
drivers/usb/host/xhci-pci.c +1 -0
 	.quirks  = XHCI_RENESAS_FW_QUIRK,
 	.firmware = "renesas_usb_fw.mem",
+#endif
 };
 
Quoted 14 lines

drivers/usb/host/xhci-pci.c static const struct pci_device_id pci_ids[] = { · line 647

Quoted 12 lines
drivers/usb/host/xhci-pci.c +6 -0
 /* PCI driver selection metadata; PCI hotplugging uses this */
@@ -636,7 +638,13 @@ static const struct pci_device_id pci_ids[] = {
 	{ /* end: all zeroes */ }
 };
 MODULE_DEVICE_TABLE(pci, pci_ids);
+/*
+ * Without CONFIG_USB_XHCI_PCI_RENESAS renesas_xhci_check_request_fw() won't
+ * load firmware, so don't encumber the xhci-pci driver with it.
+ */
+#if IS_ENABLED(CONFIG_USB_XHCI_PCI_RENESAS)
 MODULE_FIRMWARE("renesas_usb_fw.mem");
+#endif

Why not just have this one chunk, why is the first chunk needed?

It seemed cleaner to remove both renesas_usb_fw.mem references rather than leave one unusable one in reneses_data above. But a simpler patch is appealing, especially given the number of #if guards needed to remove reneses_data. Patch V2 will just go with this 1-hunk approach.

Quoted 1 line

And a blank line please before your comment?

Will do.

Quoted 1 line

And can you add a Fixes: line to the changelog text when you resend?

Will do.

Quoted 3 lines

thanks,

greg k-h

#3 lore raw

PATCH v2 1/1 usb: xhci: avoid renesas_usb_fw.mem when it's unusable

Commit a66d21d7dba8 ("usb: xhci: Add support for Renesas controller with memory") added renesas_usb_fw.mem firmware reference to xhci-pci. Thus modinfo indicates xhci-pci.ko has "firmware: renesas_usb_fw.mem". But the firmware is only actually used with CONFIG_USB_XHCI_PCI_RENESAS. An unusable firmware reference can trigger safety checkers which look for drivers with unmet firmware dependencies.

Avoid referring to renesas_usb_fw.mem in circumstances when it cannot be loaded (when CONFIG_USB_XHCI_PCI_RENESAS isn't set).

Fixes a66d21d7dba8 ("usb: xhci: Add support for Renesas controller with memory")

---
Changelog since v1:
- Smaller patch, only filters out MODULE_FIRMWARE()
- Added blank line
- Added Fixes footer to commit log

drivers/usb/host/xhci-pci.c | 7 +++++++

 1 file changed, 7 insertions(+)
drivers/usb/host/xhci-pci.c +7 -0
index 18c2bbddf080..1c9a7957c45c 100644
@@ -636,7 +636,14 @@ static const struct pci_device_id pci_ids[] = {
 	{ /* end: all zeroes */ }
 };
 MODULE_DEVICE_TABLE(pci, pci_ids);
+
+/*
+ * Without CONFIG_USB_XHCI_PCI_RENESAS renesas_xhci_check_request_fw() won't
+ * load firmware, so don't encumber the xhci-pci driver with it.
+ */
+#if IS_ENABLED(CONFIG_USB_XHCI_PCI_RENESAS)
 MODULE_FIRMWARE("renesas_usb_fw.mem");
+#endif
 
 /* pci driver glue; this is a "new style" PCI driver module */
 static struct pci_driver xhci_pci_driver = {
Signature · 1 line
2.32.0.93.g670b81a890-goog