811-pci_disable_usb_common_quirks.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. From: Felix Fietkau <[email protected]>
  2. Subject: debloat: disable common USB quirks
  3. Signed-off-by: Felix Fietkau <[email protected]>
  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. @@ -107,6 +107,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. @@ -511,6 +513,10 @@ void usb_amd_dev_put(void)
  20. }
  21. EXPORT_SYMBOL_GPL(usb_amd_dev_put);
  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. @@ -590,8 +596,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. @@ -1158,3 +1173,4 @@ static void quirk_usb_early_handoff(stru
  47. }
  48. DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
  49. PCI_CLASS_SERIAL_USB, 8, quirk_usb_early_handoff);
  50. +#endif
  51. --- a/drivers/usb/host/pci-quirks.h
  52. +++ b/drivers/usb/host/pci-quirks.h
  53. @@ -4,6 +4,9 @@
  54. #ifdef CONFIG_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_PCI */
  58. +
  59. +#if defined(CONFIG_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. @@ -17,12 +20,25 @@ void usb_disable_xhci_ports(struct pci_d
  64. void sb800_prefetch(struct device *dev, int on);
  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. static inline void usb_amd_dev_put(void) {}
  83. static inline void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) {}
  84. static inline void sb800_prefetch(struct device *dev, int on) {}
  85. +static inline void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev) {}
  86. #endif /* CONFIG_PCI */
  87. #endif /* __LINUX_USB_PCI_QUIRKS_H */
  88. --- a/include/linux/usb/hcd.h
  89. +++ b/include/linux/usb/hcd.h
  90. @@ -461,7 +461,14 @@ extern int usb_hcd_pci_probe(struct pci_
  91. extern void usb_hcd_pci_remove(struct pci_dev *dev);
  92. extern void usb_hcd_pci_shutdown(struct pci_dev *dev);
  93. +#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
  94. extern int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *dev);
  95. +#else
  96. +static inline int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *dev)
  97. +{
  98. + return 0;
  99. +}
  100. +#endif
  101. #ifdef CONFIG_PM
  102. extern const struct dev_pm_ops usb_hcd_pci_pm_ops;