Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 0/2] USB:ehci:fix the no SRBN register problem
@ 2021-04-08 13:49 Longfang Liu
  2021-04-08 13:49 ` [PATCH v2 1/2] USB:ehci:Add a whitelist for EHCI controllers Longfang Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Longfang Liu @ 2021-04-08 13:49 UTC (permalink / raw)
  To: gregkh, mathias.nyman, stern, liudongdong3
  Cc: linux-usb, linux-kernel, liulongfang, kong.kongxinwei, yisen.zhuang

(1) Add a whitelist for EHCI devices without SBRN registers.
(2) Add Kunpeng920's EHCI device to the whitelist.

Changes in v2:
	- Fix some code style issues.
	- Update function name.

Longfang Liu (2):
  USB:ehci:Add a whitelist for EHCI controllers
  USB:ehci:fix Kunpeng920 ehci hardware problem

 drivers/usb/host/ehci-pci.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

-- 
2.8.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/2] USB:ehci:Add a whitelist for EHCI controllers
  2021-04-08 13:49 [PATCH v2 0/2] USB:ehci:fix the no SRBN register problem Longfang Liu
@ 2021-04-08 13:49 ` Longfang Liu
  2021-04-08 14:53   ` Greg KH
                     ` (2 more replies)
  2021-04-08 13:49 ` [PATCH v2 2/2] USB:ehci:fix Kunpeng920 ehci hardware problem Longfang Liu
  2021-04-08 14:53 ` [PATCH v2 0/2] USB:ehci:fix the no SRBN register problem Alan Stern
  2 siblings, 3 replies; 9+ messages in thread
From: Longfang Liu @ 2021-04-08 13:49 UTC (permalink / raw)
  To: gregkh, mathias.nyman, stern, liudongdong3
  Cc: linux-usb, linux-kernel, liulongfang, kong.kongxinwei, yisen.zhuang

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 <liulongfang@huawei.com>
---
 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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 2/2] USB:ehci:fix Kunpeng920 ehci hardware problem
  2021-04-08 13:49 [PATCH v2 0/2] USB:ehci:fix the no SRBN register problem Longfang Liu
  2021-04-08 13:49 ` [PATCH v2 1/2] USB:ehci:Add a whitelist for EHCI controllers Longfang Liu
@ 2021-04-08 13:49 ` Longfang Liu
  2021-04-08 14:53 ` [PATCH v2 0/2] USB:ehci:fix the no SRBN register problem Alan Stern
  2 siblings, 0 replies; 9+ messages in thread
From: Longfang Liu @ 2021-04-08 13:49 UTC (permalink / raw)
  To: gregkh, mathias.nyman, stern, liudongdong3
  Cc: linux-usb, linux-kernel, liulongfang, kong.kongxinwei, yisen.zhuang

Kunpeng920's EHCI controller does not have SBRN register.
Reading the SBRN register when the controller driver is
initialized will get 0.

When rebooting the EHCI driver, ehci_shutdown() will be called.
if the sbrn flag is 0, ehci_shutdown() will return directly.
The sbrn flag being 0 will cause the EHCI interrupt signal to
not be turned off after reboot. this interrupt that is not closed
will cause an exception to the device sharing the interrupt.

Therefore, the EHCI controller of kunpeng920 needs to be added
to the whitelist without SBRN register.

Signed-off-by: Longfang Liu <liulongfang@huawei.com>
---
 drivers/usb/host/ehci-pci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 534e906..7bd075c 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -53,6 +53,8 @@ static const struct usb_nosbrn_whitelist_entry {
 } usb_nosbrn_whitelist[] = {
 	/* STMICRO ConneXT has no sbrn register */
 	{PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST},
+	/* HUAWEI Kunpeng920 HiSilicon USB EHCI has no sbrn register */
+	{PCI_VENDOR_ID_HUAWEI, 0xa239},
 	/* End of list */
 	{NULL, NULL}
 };
-- 
2.8.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/2] USB:ehci:Add a whitelist for EHCI controllers
  2021-04-08 13:49 ` [PATCH v2 1/2] USB:ehci:Add a whitelist for EHCI controllers Longfang Liu
@ 2021-04-08 14:53   ` Greg KH
  2021-04-08 17:30   ` kernel test robot
  2021-04-08 20:34   ` kernel test robot
  2 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2021-04-08 14:53 UTC (permalink / raw)
  To: Longfang Liu
  Cc: mathias.nyman, stern, liudongdong3, linux-usb, linux-kernel,
	kong.kongxinwei, yisen.zhuang

On Thu, Apr 08, 2021 at 09:49:19PM +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 <liulongfang@huawei.com>
> ---
>  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 {

Again, please do not use the term "whitelist", it is vague and you can
pick a better term for this.

How about:
	struct ehci_nosbrn;

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/2] USB:ehci:fix the no SRBN register problem
  2021-04-08 13:49 [PATCH v2 0/2] USB:ehci:fix the no SRBN register problem Longfang Liu
  2021-04-08 13:49 ` [PATCH v2 1/2] USB:ehci:Add a whitelist for EHCI controllers Longfang Liu
  2021-04-08 13:49 ` [PATCH v2 2/2] USB:ehci:fix Kunpeng920 ehci hardware problem Longfang Liu
@ 2021-04-08 14:53 ` Alan Stern
  2021-04-09  2:42   ` liulongfang
  2 siblings, 1 reply; 9+ messages in thread
From: Alan Stern @ 2021-04-08 14:53 UTC (permalink / raw)
  To: Longfang Liu
  Cc: gregkh, mathias.nyman, liudongdong3, linux-usb, linux-kernel,
	kong.kongxinwei, yisen.zhuang

On Thu, Apr 08, 2021 at 09:49:18PM +0800, Longfang Liu wrote:
> (1) Add a whitelist for EHCI devices without SBRN registers.
> (2) Add Kunpeng920's EHCI device to the whitelist.
> 
> Changes in v2:
> 	- Fix some code style issues.
> 	- Update function name.
> 
> Longfang Liu (2):
>   USB:ehci:Add a whitelist for EHCI controllers
>   USB:ehci:fix Kunpeng920 ehci hardware problem
> 
>  drivers/usb/host/ehci-pci.c | 30 ++++++++++++++++++++++++++----
>  1 file changed, 26 insertions(+), 4 deletions(-)

I don't think we need a whole list, along with an associated lookup 
routine, when there are only two entries.  The total amount of code will 
be smaller if you just add a check for the Kunpeng920 controller to
the existing check for the STMICRO controller.

Alan Stern

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/2] USB:ehci:Add a whitelist for EHCI controllers
  2021-04-08 13:49 ` [PATCH v2 1/2] USB:ehci:Add a whitelist for EHCI controllers Longfang Liu
  2021-04-08 14:53   ` Greg KH
@ 2021-04-08 17:30   ` kernel test robot
  2021-04-08 20:34   ` kernel test robot
  2 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2021-04-08 17:30 UTC (permalink / raw)
  To: Longfang Liu, gregkh, mathias.nyman, stern, liudongdong3
  Cc: kbuild-all, linux-usb, linux-kernel, liulongfang,
	kong.kongxinwei, yisen.zhuang


[-- Attachment #1: Type: text/plain, Size: 2513 bytes --]

Hi Longfang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on usb/usb-testing]
[also build test WARNING on v5.12-rc6 next-20210408]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Longfang-Liu/USB-ehci-fix-the-no-SRBN-register-problem/20210408-215249
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: x86_64-randconfig-s022-20210408 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-279-g6d5d9b42-dirty
        # https://github.com/0day-ci/linux/commit/01b93fbbf8fb6137c7779062232c0fe8c1592940
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Longfang-Liu/USB-ehci-fix-the-no-SRBN-register-problem/20210408-215249
        git checkout 01b93fbbf8fb6137c7779062232c0fe8c1592940
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
>> drivers/usb/host/ehci-pci.c:57:10: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned short [usertype] vendor @@     got void * @@
   drivers/usb/host/ehci-pci.c:57:10: sparse:     expected unsigned short [usertype] vendor
   drivers/usb/host/ehci-pci.c:57:10: sparse:     got void *
>> drivers/usb/host/ehci-pci.c:57:16: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned short [usertype] device @@     got void * @@
   drivers/usb/host/ehci-pci.c:57:16: sparse:     expected unsigned short [usertype] device
   drivers/usb/host/ehci-pci.c:57:16: sparse:     got void *

vim +57 drivers/usb/host/ehci-pci.c

    49	
    50	static const struct usb_nosbrn_whitelist_entry {
    51		u16 vendor;
    52		u16 device;
    53	} usb_nosbrn_whitelist[] = {
    54		/* STMICRO ConneXT has no sbrn register */
    55		{PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST},
    56		/* End of list */
  > 57		{NULL, NULL}
    58	};
    59	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32530 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/2] USB:ehci:Add a whitelist for EHCI controllers
  2021-04-08 13:49 ` [PATCH v2 1/2] USB:ehci:Add a whitelist for EHCI controllers Longfang Liu
  2021-04-08 14:53   ` Greg KH
  2021-04-08 17:30   ` kernel test robot
@ 2021-04-08 20:34   ` kernel test robot
  2 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2021-04-08 20:34 UTC (permalink / raw)
  To: Longfang Liu, gregkh, mathias.nyman, stern, liudongdong3
  Cc: kbuild-all, clang-built-linux, linux-usb, linux-kernel,
	liulongfang, kong.kongxinwei, yisen.zhuang


[-- Attachment #1: Type: text/plain, Size: 2839 bytes --]

Hi Longfang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on usb/usb-testing]
[also build test WARNING on v5.12-rc6 next-20210408]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Longfang-Liu/USB-ehci-fix-the-no-SRBN-register-problem/20210408-215249
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: riscv-randconfig-r025-20210408 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 56ea2e2fdd691136d5e6631fa0e447173694b82c)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://github.com/0day-ci/linux/commit/01b93fbbf8fb6137c7779062232c0fe8c1592940
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Longfang-Liu/USB-ehci-fix-the-no-SRBN-register-problem/20210408-215249
        git checkout 01b93fbbf8fb6137c7779062232c0fe8c1592940
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/usb/host/ehci-pci.c:57:3: warning: incompatible pointer to integer conversion initializing 'u16' (aka 'unsigned short') with an expression of type 'void *' [-Wint-conversion]
           {NULL, NULL}
            ^~~~
   include/linux/stddef.h:8:14: note: expanded from macro 'NULL'
   #define NULL ((void *)0)
                ^~~~~~~~~~~
   drivers/usb/host/ehci-pci.c:57:9: warning: incompatible pointer to integer conversion initializing 'u16' (aka 'unsigned short') with an expression of type 'void *' [-Wint-conversion]
           {NULL, NULL}
                  ^~~~
   include/linux/stddef.h:8:14: note: expanded from macro 'NULL'
   #define NULL ((void *)0)
                ^~~~~~~~~~~
   2 warnings generated.


vim +57 drivers/usb/host/ehci-pci.c

    49	
    50	static const struct usb_nosbrn_whitelist_entry {
    51		u16 vendor;
    52		u16 device;
    53	} usb_nosbrn_whitelist[] = {
    54		/* STMICRO ConneXT has no sbrn register */
    55		{PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST},
    56		/* End of list */
  > 57		{NULL, NULL}
    58	};
    59	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 25897 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/2] USB:ehci:fix the no SRBN register problem
  2021-04-08 14:53 ` [PATCH v2 0/2] USB:ehci:fix the no SRBN register problem Alan Stern
@ 2021-04-09  2:42   ` liulongfang
  2021-04-09  6:47     ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: liulongfang @ 2021-04-09  2:42 UTC (permalink / raw)
  To: Alan Stern
  Cc: gregkh, mathias.nyman, liudongdong3, linux-usb, linux-kernel,
	kong.kongxinwei, yisen.zhuang

On 2021/4/8 22:53, Alan Stern wrote:
> On Thu, Apr 08, 2021 at 09:49:18PM +0800, Longfang Liu wrote:
>> (1) Add a whitelist for EHCI devices without SBRN registers.
>> (2) Add Kunpeng920's EHCI device to the whitelist.
>>
>> Changes in v2:
>> 	- Fix some code style issues.
>> 	- Update function name.
>>
>> Longfang Liu (2):
>>   USB:ehci:Add a whitelist for EHCI controllers
>>   USB:ehci:fix Kunpeng920 ehci hardware problem
>>
>>  drivers/usb/host/ehci-pci.c | 30 ++++++++++++++++++++++++++----
>>  1 file changed, 26 insertions(+), 4 deletions(-)
> 
> I don't think we need a whole list, along with an associated lookup 
> routine, when there are only two entries.  The total amount of code will 
> be smaller if you just add a check for the Kunpeng920 controller to
> the existing check for the STMICRO controller.
> 
> Alan Stern
> .
> 
Now there are two EHCI controllers that do not have SBRN registers,
and there may be more in the future. This list is added for subsequent
compatibility if there are such controllers, instead of a series of if-else.
Thanks.
Longfang.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/2] USB:ehci:fix the no SRBN register problem
  2021-04-09  2:42   ` liulongfang
@ 2021-04-09  6:47     ` Greg KH
  0 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2021-04-09  6:47 UTC (permalink / raw)
  To: liulongfang
  Cc: Alan Stern, mathias.nyman, liudongdong3, linux-usb, linux-kernel,
	kong.kongxinwei, yisen.zhuang

On Fri, Apr 09, 2021 at 10:42:35AM +0800, liulongfang wrote:
> On 2021/4/8 22:53, Alan Stern wrote:
> > On Thu, Apr 08, 2021 at 09:49:18PM +0800, Longfang Liu wrote:
> >> (1) Add a whitelist for EHCI devices without SBRN registers.
> >> (2) Add Kunpeng920's EHCI device to the whitelist.
> >>
> >> Changes in v2:
> >> 	- Fix some code style issues.
> >> 	- Update function name.
> >>
> >> Longfang Liu (2):
> >>   USB:ehci:Add a whitelist for EHCI controllers
> >>   USB:ehci:fix Kunpeng920 ehci hardware problem
> >>
> >>  drivers/usb/host/ehci-pci.c | 30 ++++++++++++++++++++++++++----
> >>  1 file changed, 26 insertions(+), 4 deletions(-)
> > 
> > I don't think we need a whole list, along with an associated lookup 
> > routine, when there are only two entries.  The total amount of code will 
> > be smaller if you just add a check for the Kunpeng920 controller to
> > the existing check for the STMICRO controller.
> > 
> > Alan Stern
> > .
> > 
> Now there are two EHCI controllers that do not have SBRN registers,
> and there may be more in the future. This list is added for subsequent
> compatibility if there are such controllers, instead of a series of if-else.

Why would more people create new EHCI controllers these days with the
cheapness of USB 3 cores?  Anyway, let us worry about that if this list
gets "too long", a simple if statement is fine for now.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, back to index

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 13:49 [PATCH v2 0/2] USB:ehci:fix the no SRBN register problem Longfang Liu
2021-04-08 13:49 ` [PATCH v2 1/2] USB:ehci:Add a whitelist for EHCI controllers Longfang Liu
2021-04-08 14:53   ` Greg KH
2021-04-08 17:30   ` kernel test robot
2021-04-08 20:34   ` kernel test robot
2021-04-08 13:49 ` [PATCH v2 2/2] USB:ehci:fix Kunpeng920 ehci hardware problem Longfang Liu
2021-04-08 14:53 ` [PATCH v2 0/2] USB:ehci:fix the no SRBN register problem Alan Stern
2021-04-09  2:42   ` liulongfang
2021-04-09  6:47     ` Greg KH

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git