Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp425145pxf; Thu, 8 Apr 2021 06:06:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjvgJvE1QScJNsRt+sFi8QR4cRN3KBphoqOHL3KPd3HDxzwTPmdH/NEw7LeRRLpyvlYiQQ X-Received: by 2002:ac2:5f19:: with SMTP id 25mr6463252lfq.328.1617887209495; Thu, 08 Apr 2021 06:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617887209; cv=none; d=google.com; s=arc-20160816; b=Mf/H645nsinscJ8YFng3Fpt9PYuFDzNZt+0F6/NoXV2j9jlwdbf8sBONvtPNOgApVR b5YSLwVdXmt/y3BM32W1vSBxq2sex2tfYv5//kyiupDbxCiMh2DCKGfPIikQq+wpGFgj SDHmNrZAgQCja4YGI4juC+VNP+mDnkDgnu0sGoWSxumMAMWJ6IOTDqmHDPOnEj7mURqZ PZsZEhDiBfN0/ny54/lWMQGIlVrDWcZwqs61blK0XJE+h5NuL161SDb7sLkcxLRsnykC ecdxIe8kEzD3f/YGk0rwGJiSbF1jG/onNEN36nvNBycnvvM00bDSP1OUJl5AYyVVtiJ2 k0Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=pUx5i/TsOx654zYSerFcO/cll0buu2N90167nZQsoyY=; b=folA3VfvNBZ5Q5Fd03YxWQ2nhiX9ELn1JUoXrwm/jd6ZTALYutd2Er4QgpEejK9Eds ymd1fIZVcvgwpQTsFz/iAj/tuq+YvHAA0r1WMttuezEBNJG9q1ZqqK/b8dYpOGY0CKxu jrKlu6nF+HKI0nR7wp0QNEAkcXk6ajtkRrlNofYgq4pl6E8IzVLhRh+Wjl1ccguWhyqN 1qJN9e8jfsP5lAg4CQEq4z+oO0AXRNC9EzzeRa+sGND5TIT5Jj60cXtIrj5PeNaVgqBi NlyIMn0O0tmhsrbOjOYX9g7rzFxeI0q5GED3PtRMV5dIn4fpj0j6nyylCR+OZ6MU5UUr 508g== 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 g8si26102795ejm.206.2021.04.08.06.06.18; Thu, 08 Apr 2021 06:06:49 -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 S229751AbhDHNE4 (ORCPT + 99 others); Thu, 8 Apr 2021 09:04:56 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:16412 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229741AbhDHNEy (ORCPT ); Thu, 8 Apr 2021 09:04:54 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4FGLz11g8yzkjgH; Thu, 8 Apr 2021 21:02:53 +0800 (CST) Received: from [10.67.102.118] (10.67.102.118) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Thu, 8 Apr 2021 21:04:18 +0800 Subject: Re: [PATCH 1/2] USB:ehci:Add a whitelist for EHCI controllers To: Greg KH CC: , , , , , , References: <1617873073-37371-1-git-send-email-liulongfang@huawei.com> <1617873073-37371-2-git-send-email-liulongfang@huawei.com> From: liulongfang Message-ID: <13446834-afc5-e713-d232-36c771059712@huawei.com> Date: Thu, 8 Apr 2021 21:04:17 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.118] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/4/8 17:22, Greg KH Wrote: > On Thu, Apr 08, 2021 at 05:11:12PM +0800, Longfang Liu wrote: >> 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; > > u16 here please. > >> +} usb_nosbrn_whitelist[] = { >> + /* STMICRO ConneXT has no sbrn register */ >> + {PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST}, >> + {} > > trailing , please. > Is it necessary to add "," at the end here? >> +}; >> + >> +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)) > > Doing this as a "negative" is hard to understand. Should this just be: > forbid_sbrn_read() > or something like that? > > The term "whitelist" is not a good thing to use as it does not really > explain anything here. > > thanks, > > greg k-h > . > Thanks Longfang.