1 From: Felix Fietkau <nbd@nbd.name>
2 Subject: debloat: disable common USB quirks
4 Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 drivers/usb/host/pci-quirks.c | 16 ++++++++++++++++
7 drivers/usb/host/pci-quirks.h | 18 +++++++++++++++++-
8 include/linux/usb/hcd.h | 7 +++++++
9 3 files changed, 40 insertions(+), 1 deletion(-)
11 --- a/drivers/usb/host/pci-quirks.c
12 +++ b/drivers/usb/host/pci-quirks.c
13 @@ -107,6 +107,8 @@ struct amd_chipset_type {
17 +#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
19 static struct amd_chipset_info {
20 struct pci_dev *nb_dev;
21 struct pci_dev *smbus_dev;
22 @@ -511,6 +513,10 @@ void usb_amd_dev_put(void)
24 EXPORT_SYMBOL_GPL(usb_amd_dev_put);
26 +#endif /* CONFIG_PCI_DISABLE_COMMON_QUIRKS */
28 +#if IS_ENABLED(CONFIG_USB_UHCI_HCD)
31 * Make sure the controller is completely inactive, unable to
32 * generate interrupts or do DMA.
33 @@ -590,8 +596,17 @@ reset_needed:
34 uhci_reset_hc(pdev, base);
38 +int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base)
44 EXPORT_SYMBOL_GPL(uhci_check_and_reset_hc);
46 +#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
48 static inline int io_type_enabled(struct pci_dev *pdev, unsigned int mask)
51 @@ -1158,6 +1173,7 @@ static void quirk_usb_early_handoff(stru
53 DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
54 PCI_CLASS_SERIAL_USB, 8, quirk_usb_early_handoff);
57 bool usb_xhci_needs_pci_reset(struct pci_dev *pdev)
59 --- a/drivers/usb/host/pci-quirks.h
60 +++ b/drivers/usb/host/pci-quirks.h
63 void uhci_reset_hc(struct pci_dev *pdev, unsigned long base);
64 int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base);
65 +#endif /* CONFIG_USB_PCI */
67 +#if defined(CONFIG_USB_PCI) && !defined(CONFIG_PCI_DISABLE_COMMON_QUIRKS)
68 int usb_amd_find_chipset_info(void);
69 int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *pdev);
70 bool usb_amd_hang_symptom_quirk(void);
71 @@ -19,12 +22,25 @@ void sb800_prefetch(struct device *dev,
72 bool usb_xhci_needs_pci_reset(struct pci_dev *pdev);
75 +static inline int usb_amd_find_chipset_info(void)
79 +static inline bool usb_amd_hang_symptom_quirk(void)
83 +static inline bool usb_amd_prefetch_quirk(void)
87 static inline void usb_amd_quirk_pll_disable(void) {}
88 static inline void usb_amd_quirk_pll_enable(void) {}
89 static inline void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev) {}
90 static inline void usb_amd_dev_put(void) {}
91 static inline void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) {}
92 static inline void sb800_prefetch(struct device *dev, int on) {}
93 +static inline void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev) {}
94 #endif /* CONFIG_USB_PCI */
96 #endif /* __LINUX_USB_PCI_QUIRKS_H */
97 --- a/include/linux/usb/hcd.h
98 +++ b/include/linux/usb/hcd.h
99 @@ -465,7 +465,14 @@ extern int usb_hcd_pci_probe(struct pci_
100 extern void usb_hcd_pci_remove(struct pci_dev *dev);
101 extern void usb_hcd_pci_shutdown(struct pci_dev *dev);
103 +#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
104 extern int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *dev);
106 +static inline int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *dev)
113 extern const struct dev_pm_ops usb_hcd_pci_pm_ops;