Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp469110pxf; Thu, 8 Apr 2021 06:53:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbURtYJoLNrVX7WxyZVOLNYVlulBIWzfqohNcbe47K/vAZuBpo/l2kLt7wHcwMihwEqgPs X-Received: by 2002:a17:906:71c4:: with SMTP id i4mr10607830ejk.134.1617890002331; Thu, 08 Apr 2021 06:53:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617890002; cv=none; d=google.com; s=arc-20160816; b=jqHahdj2hNdI3j+t1NNQBpEBznzwJGPWVsnH5UkWD9NKllWaSultHMc0LIDz39trQX Bnq8kZAKu5FRWg+Og8cwAqO7zDHQpiJC4mFNa8RW2rHD/AVgmjPEmppp20W7/sJn8Su7 TPUw4nkSlvCgIPOUFNXfbL3wcO055LTcyPTYdO1pyZX5/b++gyfhuBS12GD7qgZxi01A BgWlT/XZE3HoxgxCexkjsUESTKE2qZlOf/wnkR+7KFYjNcaN/QCI9NILypjn88zj7I5Z AkKjTjK3YBzHbCiX+zAOEQBuOsPK6ElyF6n8HEmAAALkG8HvdJm+amo6hFluF6QgV8a+ hySQ== 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=ajoiUCuZpMvnIAT77JLdwF2JH0EAOdIvjf5cP30xaxQ=; b=G5xolZPUuiRSDXzghnmr8ASUxYADlv3q0DZCu7gvfzLJ3rFlLx5xpPKrC21ji/tsH2 DN1Uh7CepoeuBBc4t5g2seXp1Qfk92Tz8xs6T3GyrpwU70Y4WsjfOIG6sytliXCO08Jf XEhQFhmcXZShvTz4a2RDGL21OnkFqUU4ynfxXtHcxr8S5HCXIijpP1KfHCSLHo5OwzmR fvu7AWlUMCMeXuV10knGgSG/rlOYMgNcrA5ckUSQ3LBaxYT+3z4qwBtR+ovmKkbKaU57 mhajcBxtlpoAWOLPnl17ez8r8/rXSTAfBx+YaQflYDsRiLNMuO2lOAPf0izj6mLB669k ZJSQ== 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 r20si8193711eju.671.2021.04.08.06.52.58; Thu, 08 Apr 2021 06:53:22 -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 S231676AbhDHNwP (ORCPT + 99 others); Thu, 8 Apr 2021 09:52:15 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:15631 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231557AbhDHNwP (ORCPT ); Thu, 8 Apr 2021 09:52:15 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FGN0T5t8qzpWdy; Thu, 8 Apr 2021 21:49:13 +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; Thu, 8 Apr 2021 21:51:54 +0800 From: Longfang Liu To: , , , CC: , , , , Subject: [PATCH v2 1/2] USB:ehci:Add a whitelist for EHCI controllers Date: Thu, 8 Apr 2021 21:49:19 +0800 Message-ID: <1617889760-17733-2-git-send-email-liulongfang@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1617889760-17733-1-git-send-email-liulongfang@huawei.com> References: <1617889760-17733-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 | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 3c3820a..534e906 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -47,6 +47,29 @@ 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 { + u16 vendor; + u16 device; +} usb_nosbrn_whitelist[] = { + /* STMICRO ConneXT has no sbrn register */ + {PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST}, + /* End of list */ + {NULL, NULL} +}; + +static bool usb_forbid_sbrn_read(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 +311,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