811-pci_disable_usb_common_quirks.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. From: Felix Fietkau <nbd@nbd.name>
  2. Subject: debloat: disable common USB quirks
  3. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  4. ---
  5. drivers/usb/host/pci-quirks.c | 16 ++++++++++++++++
  6. drivers/usb/host/pci-quirks.h | 18 +++++++++++++++++-
  7. include/linux/usb/hcd.h | 7 +++++++
  8. 3 files changed, 40 insertions(+), 1 deletion(-)
  9. --- a/drivers/usb/host/pci-quirks.c
  10. +++ b/drivers/usb/host/pci-quirks.c
  11. @@ -124,6 +124,8 @@ struct amd_chipset_type {
  12. u8 rev;
  13. };
  14. +#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
  15. +
  16. static struct amd_chipset_info {
  17. struct pci_dev *nb_dev;
  18. struct pci_dev *smbus_dev;
  19. @@ -620,6 +622,10 @@ bool usb_amd_pt_check_port(struct device
  20. }
  21. EXPORT_SYMBOL_GPL(usb_amd_pt_check_port);
  22. +#endif /* CONFIG_PCI_DISABLE_COMMON_QUIRKS */
  23. +
  24. +#if IS_ENABLED(CONFIG_USB_UHCI_HCD)
  25. +
  26. /*
  27. * Make sure the controller is completely inactive, unable to
  28. * generate interrupts or do DMA.
  29. @@ -699,8 +705,17 @@ reset_needed:
  30. uhci_reset_hc(pdev, base);
  31. return 1;
  32. }
  33. +#else
  34. +int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base)
  35. +{
  36. + return 0;
  37. +}
  38. +
  39. +#endif
  40. EXPORT_SYMBOL_GPL(uhci_check_and_reset_hc);
  41. +#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
  42. +
  43. static inline int io_type_enabled(struct pci_dev *pdev, unsigned int mask)
  44. {
  45. u16 cmd;
  46. @@ -1287,3 +1302,4 @@ bool usb_xhci_needs_pci_reset(struct pci
  47. return false;
  48. }
  49. EXPORT_SYMBOL_GPL(usb_xhci_needs_pci_reset);
  50. +#endif
  51. --- a/drivers/usb/host/pci-quirks.h
  52. +++ b/drivers/usb/host/pci-quirks.h
  53. @@ -5,6 +5,9 @@
  54. #ifdef CONFIG_USB_PCI
  55. void uhci_reset_hc(struct pci_dev *pdev, unsigned long base);
  56. int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base);
  57. +#endif /* CONFIG_USB_PCI */
  58. +
  59. +#if defined(CONFIG_USB_PCI) && !defined(CONFIG_PCI_DISABLE_COMMON_QUIRKS)
  60. int usb_amd_find_chipset_info(void);
  61. int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *pdev);
  62. bool usb_amd_hang_symptom_quirk(void);
  63. @@ -20,6 +23,18 @@ bool usb_xhci_needs_pci_reset(struct pci
  64. bool usb_amd_pt_check_port(struct device *device, int port);
  65. #else
  66. struct pci_dev;
  67. +static inline int usb_amd_find_chipset_info(void)
  68. +{
  69. + return 0;
  70. +}
  71. +static inline bool usb_amd_hang_symptom_quirk(void)
  72. +{
  73. + return false;
  74. +}
  75. +static inline bool usb_amd_prefetch_quirk(void)
  76. +{
  77. + return false;
  78. +}
  79. static inline void usb_amd_quirk_pll_disable(void) {}
  80. static inline void usb_amd_quirk_pll_enable(void) {}
  81. static inline void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev) {}
  82. @@ -30,6 +45,11 @@ static inline bool usb_amd_pt_check_port
  83. {
  84. return false;
  85. }
  86. +static inline void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev) {}
  87. +static inline bool usb_xhci_needs_pci_reset(struct pci_dev *pdev)
  88. +{
  89. + return false;
  90. +}
  91. #endif /* CONFIG_USB_PCI */
  92. #endif /* __LINUX_USB_PCI_QUIRKS_H */
  93. --- a/include/linux/usb/hcd.h
  94. +++ b/include/linux/usb/hcd.h
  95. @@ -465,7 +465,14 @@ extern int usb_hcd_pci_probe(struct pci_
  96. extern void usb_hcd_pci_remove(struct pci_dev *dev);
  97. extern void usb_hcd_pci_shutdown(struct pci_dev *dev);
  98. +#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
  99. extern int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *dev);
  100. +#else
  101. +static inline int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *dev)
  102. +{
  103. + return 0;
  104. +}
  105. +#endif
  106. #ifdef CONFIG_PM
  107. extern const struct dev_pm_ops usb_hcd_pci_pm_ops;