PCI: Only override AMD USB controller if required
authorGuilherme G. Piccoli <gpiccoli@igalia.com>
Mon, 20 Nov 2023 16:04:36 +0000 (13:04 -0300)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 20 Nov 2023 22:15:48 +0000 (16:15 -0600)
By running a Van Gogh device (Steam Deck), the following message
was noticed in the kernel log:

  pci 0000:04:00.3: PCI class overridden (0x0c03fe -> 0x0c03fe) so dwc3 driver can claim this instead of xhci

Effectively this means the quirk executed but changed nothing, since the
class of this device was already the proper one (likely adjusted by newer
firmware versions).

Check and perform the override only if necessary.

Link: https://lore.kernel.org/r/20231120160531.361552-1-gpiccoli@igalia.com
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Huang Rui <ray.huang@amd.com>
Cc: Vicki Pfau <vi@endrift.com>
drivers/pci/quirks.c

index ea476252280abb348655f99a8e8e4a88371f6138..4e3bb1643b093599442333cf31c38c1f7d52d727 100644 (file)
@@ -702,10 +702,13 @@ static void quirk_amd_dwc_class(struct pci_dev *pdev)
 {
        u32 class = pdev->class;
 
-       /* Use "USB Device (not host controller)" class */
-       pdev->class = PCI_CLASS_SERIAL_USB_DEVICE;
-       pci_info(pdev, "PCI class overridden (%#08x -> %#08x) so dwc3 driver can claim this instead of xhci\n",
-                class, pdev->class);
+       if (class != PCI_CLASS_SERIAL_USB_DEVICE) {
+               /* Use "USB Device (not host controller)" class */
+               pdev->class = PCI_CLASS_SERIAL_USB_DEVICE;
+               pci_info(pdev,
+                       "PCI class overridden (%#08x -> %#08x) so dwc3 driver can claim this instead of xhci\n",
+                       class, pdev->class);
+       }
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB,
                quirk_amd_dwc_class);