From patchwork Mon Nov 20 16:04:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guilherme G. Piccoli" X-Patchwork-Id: 13461560 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E355AC197A0 for ; Mon, 20 Nov 2023 16:06:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233176AbjKTQGA (ORCPT ); Mon, 20 Nov 2023 11:06:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233171AbjKTQF7 (ORCPT ); Mon, 20 Nov 2023 11:05:59 -0500 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBA3EAA for ; Mon, 20 Nov 2023 08:05:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=uJXLwyehp0lxE2TjY9S/gAjQUQ3QLZ80CgpLAdjxHh4=; b=FlFgFeO/8oRLccPdwMFtGugUYn tACchHYoyeN9POoy0TDSANNa41fsTgqmJGrfSQfHYIHn6vxlDvkG1OGgtYKLt0fAihiYfakPjUQKo HG6AcBjgBWoSFOCXMVGPKzavpLrPeDSrKwgfw40CJBhmDy3Y1eIOQ/DQQLVYMA6kGSNy3fkCMSGn+ JTEjHoIrhhQN68doZzVLPQ3yHMXqDS1XyiFWhrdCWfWBfgW/rS5Dp271LHA+dPVaA2ntNN5TKZeOT 715hazeAbw19/N1+8dE88q/gFQZiaLOC4gJltmXnTfJnGCX9ISkjZSGq62etyjdAo6rGDTB+nHzf7 CzOCfGNg==; Received: from 201-92-23-2.dsl.telesp.net.br ([201.92.23.2] helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1r56mR-005IKe-RE; Mon, 20 Nov 2023 17:05:48 +0100 From: "Guilherme G. Piccoli" To: linux-pci@vger.kernel.org Cc: bhelgaas@google.com, kernel@gpiccoli.net, kernel-dev@igalia.com, "Guilherme G. Piccoli" , Huang Rui , Vicki Pfau Subject: [PATCH] PCI: Only override AMD USB controller if required Date: Mon, 20 Nov 2023 13:04:36 -0300 Message-ID: <20231120160531.361552-1-gpiccoli@igalia.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org By running a Vangogh 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). Hence, let's just check and perform the override only if necessary. Cc: Huang Rui Cc: Vicki Pfau Signed-off-by: Guilherme G. Piccoli --- drivers/pci/quirks.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index ea476252280a..4e3bb1643b09 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -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);