33fbf34c4f44df7bcebd3ba541011ccc2fc72ca7
[openwrt/staging/wigyori.git] / target / linux / generic / pending-4.9 / 811-pci_disable_usb_common_quirks.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Subject: debloat: disable common USB quirks
3
4 Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 ---
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(-)
10
11 Index: linux-4.9.40/drivers/usb/host/pci-quirks.c
12 ===================================================================
13 --- linux-4.9.40.orig/drivers/usb/host/pci-quirks.c
14 +++ linux-4.9.40/drivers/usb/host/pci-quirks.c
15 @@ -106,6 +106,8 @@ struct amd_chipset_type {
16 u8 rev;
17 };
18
19 +#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
20 +
21 static struct amd_chipset_info {
22 struct pci_dev *nb_dev;
23 struct pci_dev *smbus_dev;
24 @@ -503,6 +505,10 @@ void usb_amd_dev_put(void)
25 }
26 EXPORT_SYMBOL_GPL(usb_amd_dev_put);
27
28 +#endif /* CONFIG_PCI_DISABLE_COMMON_QUIRKS */
29 +
30 +#if IS_ENABLED(CONFIG_USB_UHCI_HCD)
31 +
32 /*
33 * Make sure the controller is completely inactive, unable to
34 * generate interrupts or do DMA.
35 @@ -582,8 +588,17 @@ reset_needed:
36 uhci_reset_hc(pdev, base);
37 return 1;
38 }
39 +#else
40 +int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base)
41 +{
42 + return 0;
43 +}
44 +
45 +#endif
46 EXPORT_SYMBOL_GPL(uhci_check_and_reset_hc);
47
48 +#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
49 +
50 static inline int io_type_enabled(struct pci_dev *pdev, unsigned int mask)
51 {
52 u16 cmd;
53 @@ -1150,3 +1165,4 @@ static void quirk_usb_early_handoff(stru
54 }
55 DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
56 PCI_CLASS_SERIAL_USB, 8, quirk_usb_early_handoff);
57 +#endif
58 Index: linux-4.9.40/drivers/usb/host/pci-quirks.h
59 ===================================================================
60 --- linux-4.9.40.orig/drivers/usb/host/pci-quirks.h
61 +++ linux-4.9.40/drivers/usb/host/pci-quirks.h
62 @@ -4,6 +4,9 @@
63 #ifdef CONFIG_PCI
64 void uhci_reset_hc(struct pci_dev *pdev, unsigned long base);
65 int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base);
66 +#endif /* CONFIG_PCI */
67 +
68 +#if defined(CONFIG_PCI) && !defined(CONFIG_PCI_DISABLE_COMMON_QUIRKS)
69 int usb_amd_find_chipset_info(void);
70 int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *pdev);
71 bool usb_amd_hang_symptom_quirk(void);
72 @@ -17,12 +20,25 @@ void usb_disable_xhci_ports(struct pci_d
73 void sb800_prefetch(struct device *dev, int on);
74 #else
75 struct pci_dev;
76 +static inline int usb_amd_find_chipset_info(void)
77 +{
78 + return 0;
79 +}
80 +static inline bool usb_amd_hang_symptom_quirk(void)
81 +{
82 + return false;
83 +}
84 +static inline bool usb_amd_prefetch_quirk(void)
85 +{
86 + return false;
87 +}
88 static inline void usb_amd_quirk_pll_disable(void) {}
89 static inline void usb_amd_quirk_pll_enable(void) {}
90 static inline void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev) {}
91 static inline void usb_amd_dev_put(void) {}
92 static inline void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) {}
93 static inline void sb800_prefetch(struct device *dev, int on) {}
94 +static inline void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev) {}
95 #endif /* CONFIG_PCI */
96
97 #endif /* __LINUX_USB_PCI_QUIRKS_H */
98 Index: linux-4.9.40/include/linux/usb/hcd.h
99 ===================================================================
100 --- linux-4.9.40.orig/include/linux/usb/hcd.h
101 +++ linux-4.9.40/include/linux/usb/hcd.h
102 @@ -461,7 +461,14 @@ extern int usb_hcd_pci_probe(struct pci_
103 extern void usb_hcd_pci_remove(struct pci_dev *dev);
104 extern void usb_hcd_pci_shutdown(struct pci_dev *dev);
105
106 +#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
107 extern int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *dev);
108 +#else
109 +static inline int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *dev)
110 +{
111 + return 0;
112 +}
113 +#endif
114
115 #ifdef CONFIG_PM
116 extern const struct dev_pm_ops usb_hcd_pci_pm_ops;