usb: pci-quirks: Correct AMD PLL quirk detection [Linux 4.4.187]

This Linux kernel change "usb: pci-quirks: Correct AMD PLL quirk detection" is included in the Linux 4.4.187 release. This change is authored by Ryan Kennedy <ryan5544 [at] gmail.com> on Thu Jul 4 11:35:28 2019 -0400. The commit for this change in Linux stable tree is 97b0259 (patch) which is from upstream commit f3dccda. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream f3dccda.

usb: pci-quirks: Correct AMD PLL quirk detection

commit f3dccdaade4118070a3a47bef6b18321431f9ac6 upstream.

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>

There are 31 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/usb/host/pci-quirks.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 89e9494..3ea435c 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -178,7 +178,7 @@ int usb_amd_find_chipset_info(void)
 {
    unsigned long flags;
    struct amd_chipset_info info;
-   int ret;
+   int need_pll_quirk = 0;

    spin_lock_irqsave(&amd_lock, flags);

@@ -192,21 +192,28 @@ int usb_amd_find_chipset_info(void)
    spin_unlock_irqrestore(&amd_lock, flags);

    if (!amd_chipset_sb_type_init(&info)) {
-       ret = 0;
        goto commit;
    }

-   /* Below chipset generations needn't enable AMD PLL quirk */
-   if (info.sb_type.gen == AMD_CHIPSET_UNKNOWN ||
-           info.sb_type.gen == AMD_CHIPSET_SB600 ||
-           info.sb_type.gen == AMD_CHIPSET_YANGTZE ||
-           (info.sb_type.gen == AMD_CHIPSET_SB700 &&
-           info.sb_type.rev > 0x3b)) {
+   switch (info.sb_type.gen) {
+   case AMD_CHIPSET_SB700:
+       need_pll_quirk = info.sb_type.rev <= 0x3B;
+       break;
+   case AMD_CHIPSET_SB800:
+   case AMD_CHIPSET_HUDSON2:
+   case AMD_CHIPSET_BOLTON:
+       need_pll_quirk = 1;
+       break;
+   default:
+       need_pll_quirk = 0;
+       break;
+   }
+
+   if (!need_pll_quirk) {
        if (info.smbus_dev) {
            pci_dev_put(info.smbus_dev);
            info.smbus_dev = NULL;
        }
-       ret = 0;
        goto commit;
    }

@@ -225,7 +232,7 @@ int usb_amd_find_chipset_info(void)
        }
    }

-   ret = info.probe_result = 1;
+   need_pll_quirk = info.probe_result = 1;
    printk(KERN_DEBUG "QUIRK: Enable AMD PLL fix\n");

 commit:
@@ -236,7 +243,7 @@ int usb_amd_find_chipset_info(void)

        /* Mark that we where here */
        amd_chipset.probe_count++;
-       ret = amd_chipset.probe_result;
+       need_pll_quirk = amd_chipset.probe_result;

        spin_unlock_irqrestore(&amd_lock, flags);

@@ -250,7 +257,7 @@ int usb_amd_find_chipset_info(void)
        spin_unlock_irqrestore(&amd_lock, flags);
    }

-   return ret;
+   return need_pll_quirk;
 }
 EXPORT_SYMBOL_GPL(usb_amd_find_chipset_info);

Leave a Reply

Your email address will not be published. Required fields are marked *