Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1017084pxf; Thu, 8 Apr 2021 20:06:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMhodCLRFY0hZnafvBtsCb9cHxvMI+MXedldzQou0Q9vU97te6bz2OI2ZJIo+97pYYk+3c X-Received: by 2002:a17:907:652:: with SMTP id wq18mr14092087ejb.14.1617937587552; Thu, 08 Apr 2021 20:06:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617937587; cv=none; d=google.com; s=arc-20160816; b=Ihzw6/epaMiBg8k/CMp3GwMGBzB5fhMIHNnlm1EeiSGuBtICH9F9B2+4d8Due6sCZt qo+byZiGVQ57jQZ2lk6fteS72yF+81woYGyP8WWEUpgUqc9PdXPVJdngQGbC5yaSrFfO Y575izsELwGgwIxGo7J51+VQs2UDQyLpPJwd5/I8CYDaCF2kw0tdTxyUi0KefsCiwNPa 0bIWXw2eIR8l2aeq9Bh3I2NPsHpog7PcJ1yqkdPMnPgoIH/P2/1kQJXVwBCyaE4J/HW9 bUL1HyGezWIieHqYKgq5QDXI7yXy4j5s0j5pscbjsLLzAfeMqqhEG94UUAtZiSdTRWTz +scA== 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=05tV35OZ/sYuDAJ8L8iV5GFikSNLkIOOvKWwW86Tzjc=; b=wCvx/PXvCdqHL4MEyvRcSQ3EGG80VbBPygvUGiOk84b2Pv31KrL9HbQdccNjN7Go80 n/fjQ8wTLIT5/x+TnBWyRZ56zRzOazh7WFb/AXd+uj3kArnzxG3sNSrAlms+a6ZnPVmW ItizGro9cLNmY9N26TEiqprbrkWh2lfLMaje+4AaM5lX9cxSveOHVdes+TKVivxTeW7A 2DHGK5U+7yO3rm0XqDCH9yYt5IxQBD6H2Lp1du4RiDdKTkeizH+baRKcN/ms8xZe36IT 7146irAx1T0ihgNTIXBg4hch1DE91CFZKLbN9WfI/8+6cRro5eCWm8EuPfLdMknnc89m e0OA== 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 a3si1177642edr.549.2021.04.08.20.06.04; Thu, 08 Apr 2021 20:06:27 -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 S233189AbhDIDDR (ORCPT + 99 others); Thu, 8 Apr 2021 23:03:17 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:15991 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233099AbhDIDDO (ORCPT ); Thu, 8 Apr 2021 23:03:14 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FGjYr5BCLzyP3n; Fri, 9 Apr 2021 11:00:48 +0800 (CST) Received: from huawei.com (10.67.165.24) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Fri, 9 Apr 2021 11:02:50 +0800 From: Longfang Liu To: , , , CC: , , , , Subject: [PATCH v3 1/2] USB:ehci:Add a whitelist for EHCI controllers Date: Fri, 9 Apr 2021 11:00:14 +0800 Message-ID: <1617937215-39035-2-git-send-email-liulongfang@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1617937215-39035-1-git-send-email-liulongfang@huawei.com> References: <1617937215-39035-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..f7f3156 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 ehci_nosbrn { + u16 vendor; + u16 device; +} ehci_nosbrn_table[] = { + /* STMICRO ConneXT has no sbrn register */ + {PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST}, + {}, +}; + +static bool usb_forbid_sbrn_read(struct pci_dev *pdev) +{ + const struct ehci_nosbrn *entry; + + for (entry = ehci_nosbrn_table; 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_forbid_sbrn_read(pdev)) pci_read_config_byte(pdev, 0x60, &ehci->sbrn); /* Keep this around for a while just in case some EHCI -- 2.8.1