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

usb: pci-quirks: Correct AMD PLL quirk detection

The AMD PLL USB quirk is incorrectly enabled on newer Ryzen
chipsets. The logic in usb_amd_find_chipset_info currently checks
for unaffected chipsets rather than affected ones. This broke
once a new chipset was added in e788787ef. It makes more sense
to reverse the logic so it won't need to be updated as new
chipsets are added. Note that the core of the workaround in
usb_amd_quirk_pll does correctly check the chipset.

Signed-off-by: Ryan Kennedy <ryan5544@gmail.com>
Fixes: e788787ef4f9 ("usb:xhci:Add quirk for Certain failing HP keyboard on reset after resume")
Cc: stable <stable@vger.kernel.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20190704153529.9429-2-ryan5544@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ryan Kennedy and committed by
Greg Kroah-Hartman
f3dccdaa 5f9e832c

+19 -12
+19 -12
drivers/usb/host/pci-quirks.c
··· 205 205 { 206 206 unsigned long flags; 207 207 struct amd_chipset_info info; 208 - int ret; 208 + int need_pll_quirk = 0; 209 209 210 210 spin_lock_irqsave(&amd_lock, flags); 211 211 ··· 219 219 spin_unlock_irqrestore(&amd_lock, flags); 220 220 221 221 if (!amd_chipset_sb_type_init(&info)) { 222 - ret = 0; 223 222 goto commit; 224 223 } 225 224 226 - /* Below chipset generations needn't enable AMD PLL quirk */ 227 - if (info.sb_type.gen == AMD_CHIPSET_UNKNOWN || 228 - info.sb_type.gen == AMD_CHIPSET_SB600 || 229 - info.sb_type.gen == AMD_CHIPSET_YANGTZE || 230 - (info.sb_type.gen == AMD_CHIPSET_SB700 && 231 - info.sb_type.rev > 0x3b)) { 225 + switch (info.sb_type.gen) { 226 + case AMD_CHIPSET_SB700: 227 + need_pll_quirk = info.sb_type.rev <= 0x3B; 228 + break; 229 + case AMD_CHIPSET_SB800: 230 + case AMD_CHIPSET_HUDSON2: 231 + case AMD_CHIPSET_BOLTON: 232 + need_pll_quirk = 1; 233 + break; 234 + default: 235 + need_pll_quirk = 0; 236 + break; 237 + } 238 + 239 + if (!need_pll_quirk) { 232 240 if (info.smbus_dev) { 233 241 pci_dev_put(info.smbus_dev); 234 242 info.smbus_dev = NULL; 235 243 } 236 - ret = 0; 237 244 goto commit; 238 245 } 239 246 ··· 259 252 } 260 253 } 261 254 262 - ret = info.probe_result = 1; 255 + need_pll_quirk = info.probe_result = 1; 263 256 printk(KERN_DEBUG "QUIRK: Enable AMD PLL fix\n"); 264 257 265 258 commit: ··· 270 263 271 264 /* Mark that we where here */ 272 265 amd_chipset.probe_count++; 273 - ret = amd_chipset.probe_result; 266 + need_pll_quirk = amd_chipset.probe_result; 274 267 275 268 spin_unlock_irqrestore(&amd_lock, flags); 276 269 ··· 284 277 spin_unlock_irqrestore(&amd_lock, flags); 285 278 } 286 279 287 - return ret; 280 + return need_pll_quirk; 288 281 } 289 282 EXPORT_SYMBOL_GPL(usb_amd_find_chipset_info); 290 283