Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp252305pxf; Thu, 8 Apr 2021 02:13:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzZsxLA42qRPfq6fQit2ePGTIL0ulmb84OQVa4lcn8feEHPqV582W7oa0+OPtvJ/C6WtS0 X-Received: by 2002:a17:90a:ac02:: with SMTP id o2mr7574753pjq.101.1617873195487; Thu, 08 Apr 2021 02:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617873195; cv=none; d=google.com; s=arc-20160816; b=YDL7FUWyzNV96X26Uuzac0ed9uc5ILuT9nSJ4iolMQZ2lR5kvn9LOCa+ZGXcqAPkw+ L1jDFrgLXKc8tlSo0TsFonGuKo7Cj6EvzFQbLbGOQ2PcVYS1GM7NM4M8eeoIddTe8VEe MYCpOqJRv1zZMC7ZyI+vhqxtujVYU2DjLQF05UBTv/Zxo4uQqUwds+p90XZUaK8svM7F IwUM/d5CDAJlEOz11bTLcd2xfpH9CZX/SJsbI3oMJE6QR8I0IuPzcfqiDRKo8AACIJAW 5OuTMTn5ciqgCNXjQmJs2Yby32wkspBa396IHnutGc7A9tWCmfneZnVVhvjmj/gTCJH8 pcdw== 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=N0M6E9LZ/9CnQMF5t3lBNsM7APfWFLr4LBh8ZkGBqo04tkkluqlWUwxX5vwp05NV/D Fa81qirgVP6TISoMUBTozKIm2rbIibpSF2s4u/aUfg2u+bGFeq0aG0Luy3NxgKQ+3N4b YcnZXp2irWoBSuxWvzedAY6k+7BcZm80lCvX0i75jUUrp7CAsvzH36bJ7sbLu1Cid41h XEBxI+Pm0Lfg3z3uByp2K46G3t6LeaCpnXv9NWELnN9tkfQCO5TwQjvQ3+MMnhdHDhsO 9MSIOo/QF0h15L7S1X9g9M4WIzAXL62W1MfANkHGhxMeL+VV0lEInJlBDznPeHIoF2fO rqiw== 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 g24si9045374pji.108.2021.04.08.02.13.03; Thu, 08 Apr 2021 02:13:15 -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 S229837AbhDHJMl (ORCPT + 99 others); Thu, 8 Apr 2021 05:12:41 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:16084 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229618AbhDHJMl (ORCPT ); Thu, 8 Apr 2021 05:12:41 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FGFpc6Lcmz1BFsY; Thu, 8 Apr 2021 17:10:16 +0800 (CST) Received: from huawei.com (10.67.165.24) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Thu, 8 Apr 2021 17:12:20 +0800 From: Longfang Liu To: , , , CC: , , , , Subject: [PATCH 1/2] USB:ehci:Add a whitelist for EHCI controllers Date: Thu, 8 Apr 2021 17:09:43 +0800 Message-ID: <1617872985-42735-2-git-send-email-liulongfang@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1617872985-42735-1-git-send-email-liulongfang@huawei.com> References: <1617872985-42735-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