Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp253379pxf; Thu, 8 Apr 2021 02:14:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLfXB8J1HLXJUS9eLy3U08xaikzIzqzCe/sG+TbHmqCs5zA7j6Tpsq9kf/61Oa1tVDxObx X-Received: by 2002:a17:90a:db81:: with SMTP id h1mr7367790pjv.62.1617873290095; Thu, 08 Apr 2021 02:14:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617873290; cv=none; d=google.com; s=arc-20160816; b=fPSbYlf4zGxUNJCGM1ufXZg2sRiwWP4mBAtF+9DGOwHARqJB+YAO6e00GoUJvmtjV7 1/nVaJPg3H3brqxLpXgKJbnh4KXZOkEomhnLFaxYwxr1KJ7m2MKTDKre2X+ID7Q4YpjR hjtZF3uat71fFb7WqO9obp5KX6ikXBEowbd7GVun5Aew3Crm2Qd2IuFPpVRy9iBhKmZY W+qS5njopcDviYflTqN5mCzSAA4P7fTcii+9wxG+KOYU/gxXkgBVcdU1WT+e/ffaHTVq esxgG59QvD5E4A1SPvDtgg5AdWvn8aJz2m3DnONYQuFDaEiHnxHCRfv6LN+oU2IkM1Y3 ZiOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=XXo3Vi5EkxHmI0oSiQ9VmWkn5912brECRdPPnu4+H0w=; b=gwIppLGvPyl0iXAajAHN4x7raXZJzMGwV+2p38WQjF+K9RSeSvM265AoS/m6qGMjl6 K37nclTyY+i1dICOPXq1SumjtAkxMSGoJu6dhapfxW9gLkB7S4AKtO50XxJKa3e1FlD6 /GW6kL2h2oH5Q6psaZef6WA55jn4ItZz00Ghmnam7MEFFuWu7kNywR2CPcgZxPUeqVGQ rTJDrEU/Sunr4rCs9Cv3Z0DiApDRY/a/W87ketLX0RWVS11NaRWa4mEG+QIdpSVqjBLN GTE1CWsmTBx2wZoBDP7HlKDjOlLjpAkV89dip3sKLKywZiTi7966W2APHh3Qdml8ECJW 82xA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d21si26497673plr.236.2021.04.08.02.14.38; Thu, 08 Apr 2021 02:14:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230303AbhDHJOH (ORCPT + 99 others); Thu, 8 Apr 2021 05:14:07 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:16830 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229672AbhDHJOG (ORCPT ); Thu, 8 Apr 2021 05:14:06 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FGFrG3mDsz93fs; Thu, 8 Apr 2021 17:11:42 +0800 (CST) Received: from huawei.com (10.67.165.24) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.498.0; Thu, 8 Apr 2021 17:13:46 +0800 From: Longfang Liu To: , , , CC: , , , , Subject: [PATCH 1/2] USB:ehci:Add a whitelist for EHCI controllers Date: Thu, 8 Apr 2021 17:11:12 +0800 Message-ID: <1617873073-37371-2-git-send-email-liulongfang@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1617873073-37371-1-git-send-email-liulongfang@huawei.com> References: <1617873073-37371-1-git-send-email-liulongfang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some types of EHCI controllers do not have SBRN registers. By comparing the white list, the operation of reading the SBRN registers is skipped. Subsequent EHCI controller types without SBRN registers can be directly added to the white list. The current patch does not affect the drive function. Signed-off-by: Longfang Liu --- drivers/usb/host/ehci-pci.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 3c3820a..6a30afa 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -47,6 +47,28 @@ static inline bool is_bypassed_id(struct pci_dev *pdev) return !!pci_match_id(bypass_pci_id_table, pdev); } +static const struct usb_nosbrn_whitelist_entry { + unsigned short vendor; + unsigned short device; +} usb_nosbrn_whitelist[] = { + /* STMICRO ConneXT has no sbrn register */ + {PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST}, + {} +}; + +static bool usb_nosbrn_whitelist_check(struct pci_dev *pdev) +{ + const struct usb_nosbrn_whitelist_entry *entry; + + for (entry = usb_nosbrn_whitelist; entry->vendor; entry++) { + if (pdev->vendor == entry->vendor && + pdev->device == entry->device) + return true; + } + + return false; +} + /* * 0x84 is the offset of in/out threshold register, * and it is the same offset as the register of 'hostpc'. @@ -288,10 +310,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd) } /* Serial Bus Release Number is at PCI 0x60 offset */ - if (pdev->vendor == PCI_VENDOR_ID_STMICRO - && pdev->device == PCI_DEVICE_ID_STMICRO_USB_HOST) - ; /* ConneXT has no sbrn register */ - else + if (!usb_nosbrn_whitelist_check(pdev)) pci_read_config_byte(pdev, 0x60, &ehci->sbrn); /* Keep this around for a while just in case some EHCI -- 2.8.1