All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] usb: core: hub: improve port over-current alert msg
@ 2021-10-05 15:16 Flavio Suligoi
  2021-10-05 15:38 ` Greg Kroah-Hartman
  2021-10-06  9:59   ` kernel test robot
  0 siblings, 2 replies; 5+ messages in thread
From: Flavio Suligoi @ 2021-10-05 15:16 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Alan Stern, Thinh Nguyen, Mathias Nyman,
	Bjorn Helgaas, Bixuan Cui, Andrew Lunn, Chris Chiu, Rajat Jain
  Cc: linux-usb, linux-kernel, Flavio Suligoi

At the moment the port over-current message is
displayed only if the over-current condition is permanent.

But in case of permanent short-circuit or
over-current, some USB power-distribution switches
(such as the TPS20xx, etc.), after the over-current
detection and the consequent shutdown, return
in the normal state.

So, in these cases, the over-current error message
never appears.

To overcome this problem, the "over-current condition"
message is displayed even after some over-current events.

Signed-off-by: Flavio Suligoi <f.suligoi@asem.it>
---
 arch/arm64/boot/dts/Makefile | 1 +
 drivers/usb/core/hub.c       | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/Makefile b/arch/arm64/boot/dts/Makefile
index 639e01a4d855..bf26ce60d78a 100644
--- a/arch/arm64/boot/dts/Makefile
+++ b/arch/arm64/boot/dts/Makefile
@@ -8,6 +8,7 @@ subdir-y += amlogic
 subdir-y += apm
 subdir-y += apple
 subdir-y += arm
+subdir-y += asem
 subdir-y += bitmain
 subdir-y += broadcom
 subdir-y += cavium
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 86658a81d284..ff6c8e0e2673 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -5577,7 +5577,8 @@ static void port_event(struct usb_hub *hub, int port1)
 		msleep(100);	/* Cool down */
 		hub_power_on(hub, true);
 		hub_port_status(hub, port1, &status, &unused);
-		if (status & USB_PORT_STAT_OVERCURRENT)
+		if ((status & USB_PORT_STAT_OVERCURRENT) ||
+		    !(port_dev->over_current_count % 15))
 			dev_err(&port_dev->dev, "over-current condition\n");
 	}
 
@@ -5738,7 +5739,7 @@ static void hub_event(struct work_struct *work)
 			u16 status = 0;
 			u16 unused;
 
-			dev_dbg(hub_dev, "over-current change\n");
+			dev_info(hub_dev, "over-current change\n");
 			clear_hub_feature(hdev, C_HUB_OVER_CURRENT);
 			msleep(500);	/* Cool down */
 			hub_power_on(hub, true);
-- 
2.25.1


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

* Re: [PATCH v1] usb: core: hub: improve port over-current alert msg
  2021-10-05 15:16 [PATCH v1] usb: core: hub: improve port over-current alert msg Flavio Suligoi
@ 2021-10-05 15:38 ` Greg Kroah-Hartman
  2021-10-06  9:47   ` Flavio Suligoi
  2021-10-06  9:59   ` kernel test robot
  1 sibling, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2021-10-05 15:38 UTC (permalink / raw)
  To: Flavio Suligoi
  Cc: Alan Stern, Thinh Nguyen, Mathias Nyman, Bjorn Helgaas,
	Bixuan Cui, Andrew Lunn, Chris Chiu, Rajat Jain, linux-usb,
	linux-kernel

On Tue, Oct 05, 2021 at 05:16:44PM +0200, Flavio Suligoi wrote:
> At the moment the port over-current message is
> displayed only if the over-current condition is permanent.
> 
> But in case of permanent short-circuit or
> over-current, some USB power-distribution switches
> (such as the TPS20xx, etc.), after the over-current
> detection and the consequent shutdown, return
> in the normal state.

Please use the full 72 columns of the changelog text.


> 
> So, in these cases, the over-current error message
> never appears.
> 
> To overcome this problem, the "over-current condition"
> message is displayed even after some over-current events.
> 
> Signed-off-by: Flavio Suligoi <f.suligoi@asem.it>
> ---
>  arch/arm64/boot/dts/Makefile | 1 +
>  drivers/usb/core/hub.c       | 5 +++--
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/boot/dts/Makefile b/arch/arm64/boot/dts/Makefile
> index 639e01a4d855..bf26ce60d78a 100644
> --- a/arch/arm64/boot/dts/Makefile
> +++ b/arch/arm64/boot/dts/Makefile
> @@ -8,6 +8,7 @@ subdir-y += amlogic
>  subdir-y += apm
>  subdir-y += apple
>  subdir-y += arm
> +subdir-y += asem
>  subdir-y += bitmain
>  subdir-y += broadcom
>  subdir-y += cavium

I do not think this change is part of this :(

> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index 86658a81d284..ff6c8e0e2673 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -5577,7 +5577,8 @@ static void port_event(struct usb_hub *hub, int port1)
>  		msleep(100);	/* Cool down */
>  		hub_power_on(hub, true);
>  		hub_port_status(hub, port1, &status, &unused);
> -		if (status & USB_PORT_STAT_OVERCURRENT)
> +		if ((status & USB_PORT_STAT_OVERCURRENT) ||
> +		    !(port_dev->over_current_count % 15))

What is 15?

>  			dev_err(&port_dev->dev, "over-current condition\n");
>  	}
>  
> @@ -5738,7 +5739,7 @@ static void hub_event(struct work_struct *work)
>  			u16 status = 0;
>  			u16 unused;
>  
> -			dev_dbg(hub_dev, "over-current change\n");
> +			dev_info(hub_dev, "over-current change\n");

This is just going to be noisy, what can a user do with this?

thanks,

greg k-h

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

* RE: [PATCH v1] usb: core: hub: improve port over-current alert msg
  2021-10-05 15:38 ` Greg Kroah-Hartman
@ 2021-10-06  9:47   ` Flavio Suligoi
  0 siblings, 0 replies; 5+ messages in thread
From: Flavio Suligoi @ 2021-10-06  9:47 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Alan Stern, Thinh Nguyen, Mathias Nyman, Bjorn Helgaas,
	Andrew Lunn, Chris Chiu, Rajat Jain, linux-usb, linux-kernel

Hi Greg,

> > (such as the TPS20xx, etc.), after the over-current
> > detection and the consequent shutdown, return
> > in the normal state.
> 
> Please use the full 72 columns of the changelog text.

Ok

> 
> 
> >
> > So, in these cases, the over-current error message
> > never appears.
> >
> > To overcome this problem, the "over-current condition"
> > message is displayed even after some over-current events.
> >
> > Signed-off-by: Flavio Suligoi <f.suligoi@asem.it>
> > ---
> >  arch/arm64/boot/dts/Makefile | 1 +
> >  drivers/usb/core/hub.c       | 5 +++--
> >  2 files changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm64/boot/dts/Makefile b/arch/arm64/boot/dts/Makefile
> > index 639e01a4d855..bf26ce60d78a 100644
> > --- a/arch/arm64/boot/dts/Makefile
> > +++ b/arch/arm64/boot/dts/Makefile
> > @@ -8,6 +8,7 @@ subdir-y += amlogic
> >  subdir-y += apm
> >  subdir-y += apple
> >  subdir-y += arm
> > +subdir-y += asem
> >  subdir-y += bitmain
> >  subdir-y += broadcom
> >  subdir-y += cavium
> 
> I do not think this change is part of this :(

right, my mistake, sorry!

> 
> > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> > index 86658a81d284..ff6c8e0e2673 100644
> > --- a/drivers/usb/core/hub.c
> > +++ b/drivers/usb/core/hub.c
> > @@ -5577,7 +5577,8 @@ static void port_event(struct usb_hub *hub, int
> port1)
> >  		msleep(100);	/* Cool down */
> >  		hub_power_on(hub, true);
> >  		hub_port_status(hub, port1, &status, &unused);
> > -		if (status & USB_PORT_STAT_OVERCURRENT)
> > +		if ((status & USB_PORT_STAT_OVERCURRENT) ||
> > +		    !(port_dev->over_current_count % 15))
> 
> What is 15?

It's an empiric value to have a message about every 1.5 - 2 seconds (100ms * 15).
Ok, this value is not clear; I can change this fixed number in something like this:
...
#define USB_OC_COOL_DOWN_TIME		100	/* ms */
#define USB_OC_REPEATED_MSG_DELAY	1500	/* ms */
...
...
msleep(COOLING_DOWN_TIME);	/* Cool down */
...
    if ((status & USB_PORT_STAT_OVERCURRENT) ||
        !(port_dev->over_current_count %
           (USB_OC_REPEATED_MSG_DELAY / USB_OC_COOL_DOWN_TIME)))
	dev_err(&port_dev->dev, "over-current condition\n");


> 
> >  			dev_err(&port_dev->dev, "over-current condition\n");
> >  	}
> >
> > @@ -5738,7 +5739,7 @@ static void hub_event(struct work_struct *work)
> >  			u16 status = 0;
> >  			u16 unused;
> >
> > -			dev_dbg(hub_dev, "over-current change\n");
> > +			dev_info(hub_dev, "over-current change\n");
> 
> This is just going to be noisy, what can a user do with this?

Right, it's a redundant information.

> 
> thanks,
> 
> greg k-h

Thanks for your time,

Flavio

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

* Re: [PATCH v1] usb: core: hub: improve port over-current alert msg
  2021-10-05 15:16 [PATCH v1] usb: core: hub: improve port over-current alert msg Flavio Suligoi
@ 2021-10-06  9:59   ` kernel test robot
  2021-10-06  9:59   ` kernel test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-10-06  9:59 UTC (permalink / raw)
  To: Flavio Suligoi, Greg Kroah-Hartman, Alan Stern, Thinh Nguyen,
	Mathias Nyman, Bjorn Helgaas, Bixuan Cui, Andrew Lunn,
	Chris Chiu, Rajat Jain
  Cc: kbuild-all, linux-usb

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

Hi Flavio,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on soc/for-next peter-chen-usb/for-usb-next balbi-usb/testing/next v5.15-rc3 next-20210922]
[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/Flavio-Suligoi/usb-core-hub-improve-port-over-current-alert-msg/20211005-232236
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: arm64-randconfig-r015-20211004 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 11.2.0
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
        # https://github.com/0day-ci/linux/commit/a1cd0a1a47ec25b14669f4827317e8b43822b1ee
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Flavio-Suligoi/usb-core-hub-improve-port-over-current-alert-msg/20211005-232236
        git checkout a1cd0a1a47ec25b14669f4827317e8b43822b1ee
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=arm64 

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

All errors (new ones prefixed by >>):

>> scripts/Makefile.build:44: arch/arm64/boot/dts/asem/Makefile: No such file or directory
>> make[3]: *** No rule to make target 'arch/arm64/boot/dts/asem/Makefile'.
   make[3]: Failed to remake makefile 'arch/arm64/boot/dts/asem/Makefile'.


vim +44 scripts/Makefile.build

20a468b51325b3 Sam Ravnborg   2006-01-22  40  
2a691470345a00 Sam Ravnborg   2005-07-25  41  # The filename Kbuild has precedence over Makefile
db8c1a7b2ca25f Sam Ravnborg   2005-07-27  42  kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
0c53c8e6eb456c Sam Ravnborg   2007-10-14  43  kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
0c53c8e6eb456c Sam Ravnborg   2007-10-14 @44  include $(kbuild-file)
^1da177e4c3f41 Linus Torvalds 2005-04-16  45  

---
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: 38024 bytes --]

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

* Re: [PATCH v1] usb: core: hub: improve port over-current alert msg
@ 2021-10-06  9:59   ` kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-10-06  9:59 UTC (permalink / raw)
  To: kbuild-all

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

Hi Flavio,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on soc/for-next peter-chen-usb/for-usb-next balbi-usb/testing/next v5.15-rc3 next-20210922]
[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/Flavio-Suligoi/usb-core-hub-improve-port-over-current-alert-msg/20211005-232236
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: arm64-randconfig-r015-20211004 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 11.2.0
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
        # https://github.com/0day-ci/linux/commit/a1cd0a1a47ec25b14669f4827317e8b43822b1ee
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Flavio-Suligoi/usb-core-hub-improve-port-over-current-alert-msg/20211005-232236
        git checkout a1cd0a1a47ec25b14669f4827317e8b43822b1ee
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=arm64 

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

All errors (new ones prefixed by >>):

>> scripts/Makefile.build:44: arch/arm64/boot/dts/asem/Makefile: No such file or directory
>> make[3]: *** No rule to make target 'arch/arm64/boot/dts/asem/Makefile'.
   make[3]: Failed to remake makefile 'arch/arm64/boot/dts/asem/Makefile'.


vim +44 scripts/Makefile.build

20a468b51325b3 Sam Ravnborg   2006-01-22  40  
2a691470345a00 Sam Ravnborg   2005-07-25  41  # The filename Kbuild has precedence over Makefile
db8c1a7b2ca25f Sam Ravnborg   2005-07-27  42  kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
0c53c8e6eb456c Sam Ravnborg   2007-10-14  43  kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
0c53c8e6eb456c Sam Ravnborg   2007-10-14 @44  include $(kbuild-file)
^1da177e4c3f41 Linus Torvalds 2005-04-16  45  

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

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

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

end of thread, other threads:[~2021-10-06 10:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05 15:16 [PATCH v1] usb: core: hub: improve port over-current alert msg Flavio Suligoi
2021-10-05 15:38 ` Greg Kroah-Hartman
2021-10-06  9:47   ` Flavio Suligoi
2021-10-06  9:59 ` kernel test robot
2021-10-06  9:59   ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.