Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: pci-quirks: Minor cleanup for AMD PLL quirk

usb_amd_find_chipset_info() is used for chipset detection for
several quirks. It is strange that its return value indicates
the need for the PLL quirk, which means it is often ignored.
This patch adds a function specifically for checking the PLL
quirk like the other ones. Additionally, rename probe_result to
something more appropriate.

Signed-off-by: Ryan Kennedy <ryan5544@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20190704153529.9429-3-ryan5544@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ryan Kennedy and committed by
Greg Kroah-Hartman
4fbb8aa7 f3dccdaa

+21 -19
+2 -2
drivers/usb/host/ehci-pci.c
··· 149 149 break; 150 150 case PCI_VENDOR_ID_AMD: 151 151 /* AMD PLL quirk */ 152 - if (usb_amd_find_chipset_info()) 152 + if (usb_amd_quirk_pll_check()) 153 153 ehci->amd_pll_fix = 1; 154 154 /* AMD8111 EHCI doesn't work, according to AMD errata */ 155 155 if (pdev->device == 0x7463) { ··· 186 186 break; 187 187 case PCI_VENDOR_ID_ATI: 188 188 /* AMD PLL quirk */ 189 - if (usb_amd_find_chipset_info()) 189 + if (usb_amd_quirk_pll_check()) 190 190 ehci->amd_pll_fix = 1; 191 191 192 192 /*
+1 -1
drivers/usb/host/ohci-pci.c
··· 152 152 { 153 153 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 154 154 155 - if (usb_amd_find_chipset_info()) 155 + if (usb_amd_quirk_pll_check()) 156 156 ohci->flags |= OHCI_QUIRK_AMD_PLL; 157 157 158 158 /* SB800 needs pre-fetch fix */
+16 -14
drivers/usb/host/pci-quirks.c
··· 132 132 struct amd_chipset_type sb_type; 133 133 int isoc_reqs; 134 134 int probe_count; 135 - int probe_result; 135 + bool need_pll_quirk; 136 136 } amd_chipset; 137 137 138 138 static DEFINE_SPINLOCK(amd_lock); ··· 201 201 } 202 202 EXPORT_SYMBOL_GPL(sb800_prefetch); 203 203 204 - int usb_amd_find_chipset_info(void) 204 + static void usb_amd_find_chipset_info(void) 205 205 { 206 206 unsigned long flags; 207 207 struct amd_chipset_info info; 208 - int need_pll_quirk = 0; 208 + info.need_pll_quirk = 0; 209 209 210 210 spin_lock_irqsave(&amd_lock, flags); 211 211 ··· 213 213 if (amd_chipset.probe_count > 0) { 214 214 amd_chipset.probe_count++; 215 215 spin_unlock_irqrestore(&amd_lock, flags); 216 - return amd_chipset.probe_result; 216 + return; 217 217 } 218 218 memset(&info, 0, sizeof(info)); 219 219 spin_unlock_irqrestore(&amd_lock, flags); ··· 224 224 225 225 switch (info.sb_type.gen) { 226 226 case AMD_CHIPSET_SB700: 227 - need_pll_quirk = info.sb_type.rev <= 0x3B; 227 + info.need_pll_quirk = info.sb_type.rev <= 0x3B; 228 228 break; 229 229 case AMD_CHIPSET_SB800: 230 230 case AMD_CHIPSET_HUDSON2: 231 231 case AMD_CHIPSET_BOLTON: 232 - need_pll_quirk = 1; 232 + info.need_pll_quirk = 1; 233 233 break; 234 234 default: 235 - need_pll_quirk = 0; 235 + info.need_pll_quirk = 0; 236 236 break; 237 237 } 238 238 239 - if (!need_pll_quirk) { 239 + if (!info.need_pll_quirk) { 240 240 if (info.smbus_dev) { 241 241 pci_dev_put(info.smbus_dev); 242 242 info.smbus_dev = NULL; ··· 259 259 } 260 260 } 261 261 262 - need_pll_quirk = info.probe_result = 1; 263 262 printk(KERN_DEBUG "QUIRK: Enable AMD PLL fix\n"); 264 263 265 264 commit: ··· 269 270 270 271 /* Mark that we where here */ 271 272 amd_chipset.probe_count++; 272 - need_pll_quirk = amd_chipset.probe_result; 273 273 274 274 spin_unlock_irqrestore(&amd_lock, flags); 275 275 ··· 281 283 amd_chipset = info; 282 284 spin_unlock_irqrestore(&amd_lock, flags); 283 285 } 284 - 285 - return need_pll_quirk; 286 286 } 287 - EXPORT_SYMBOL_GPL(usb_amd_find_chipset_info); 288 287 289 288 int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *pdev) 290 289 { ··· 316 321 return amd_chipset.sb_type.gen == AMD_CHIPSET_SB800; 317 322 } 318 323 EXPORT_SYMBOL_GPL(usb_amd_prefetch_quirk); 324 + 325 + bool usb_amd_quirk_pll_check(void) 326 + { 327 + usb_amd_find_chipset_info(); 328 + return amd_chipset.need_pll_quirk; 329 + } 330 + EXPORT_SYMBOL_GPL(usb_amd_quirk_pll_check); 319 331 320 332 /* 321 333 * The hardware normally enables the A-link power management feature, which ··· 529 527 amd_chipset.nb_type = 0; 530 528 memset(&amd_chipset.sb_type, 0, sizeof(amd_chipset.sb_type)); 531 529 amd_chipset.isoc_reqs = 0; 532 - amd_chipset.probe_result = 0; 530 + amd_chipset.need_pll_quirk = 0; 533 531 534 532 spin_unlock_irqrestore(&amd_lock, flags); 535 533
+1 -1
drivers/usb/host/pci-quirks.h
··· 5 5 #ifdef CONFIG_USB_PCI 6 6 void uhci_reset_hc(struct pci_dev *pdev, unsigned long base); 7 7 int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base); 8 - int usb_amd_find_chipset_info(void); 9 8 int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *pdev); 10 9 bool usb_amd_hang_symptom_quirk(void); 11 10 bool usb_amd_prefetch_quirk(void); 12 11 void usb_amd_dev_put(void); 12 + bool usb_amd_quirk_pll_check(void); 13 13 void usb_amd_quirk_pll_disable(void); 14 14 void usb_amd_quirk_pll_enable(void); 15 15 void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev);
+1 -1
drivers/usb/host/xhci-pci.c
··· 130 130 xhci->quirks |= XHCI_AMD_0x96_HOST; 131 131 132 132 /* AMD PLL quirk */ 133 - if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info()) 133 + if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_quirk_pll_check()) 134 134 xhci->quirks |= XHCI_AMD_PLL_FIX; 135 135 136 136 if (pdev->vendor == PCI_VENDOR_ID_AMD &&