Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/3] USB: host: ohci-at91: tailor power consumption
@ 2019-09-11  6:41 Nicolas Ferre
  2019-09-11  6:41 ` [PATCH 1/3] USB: host: ohci-at91: completely shutdown the controller in at91_stop_hc() Nicolas Ferre
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Nicolas Ferre @ 2019-09-11  6:41 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, stern, gregkh
  Cc: Alexandre Belloni, Ludovic Desroches, Boris.Krasnovskiy,
	linux-usb, Nicolas Ferre

Following a set of experiments we found areas of improvement for OHCI power
consumption (and associated USB analog cells).
This enhances the shutdown of residual power consumption in case of Linux
suspend/resume and removal of the driver (when compiled as a module).

Best regards,
  Nicolas

Boris Krasnovskiy (2):
  USB: host: ohci-at91: completely shutdown the controller in
    at91_stop_hc()
  USB: host: ohci-at91: resume: balance the clock start call

Nicolas Ferre (1):
  USB: host: ohci-at91: suspend: delay needed before to stop clocks

 drivers/usb/host/ohci-at91.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

-- 
2.17.1


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

* [PATCH 1/3] USB: host: ohci-at91: completely shutdown the controller in at91_stop_hc()
  2019-09-11  6:41 [PATCH 0/3] USB: host: ohci-at91: tailor power consumption Nicolas Ferre
@ 2019-09-11  6:41 ` Nicolas Ferre
  2019-09-11  6:41 ` [PATCH 2/3] USB: host: ohci-at91: suspend: delay needed before to stop clocks Nicolas Ferre
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Nicolas Ferre @ 2019-09-11  6:41 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, stern, gregkh
  Cc: Alexandre Belloni, Ludovic Desroches, Boris.Krasnovskiy,
	linux-usb, Nicolas Ferre

From: Boris Krasnovskiy <Boris.Krasnovskiy@lairdconnect.com>

When removing the ohci-at91 module, the fact of not running complete shutdown
of all the ports was keeping additional analog cells consuming power for no
reason.
Doing Reset (OHCI_HCR) to HcCommandStatus register is the way to go, but using
the OHCI controller shutdown procedure is just perfect for this.

Signed-off-by: Boris Krasnovskiy <Boris.Krasnovskiy@lairdconnect.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
---
 drivers/usb/host/ohci-at91.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index fc35a7993b7b..cb63bcd5049a 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -123,7 +123,7 @@ static void at91_stop_hc(struct platform_device *pdev)
 	/*
 	 * Put the USB host controller into reset.
 	 */
-	writel(0, &regs->control);
+	usb_hcd_platform_shutdown(pdev);
 
 	/*
 	 * Stop the USB clocks.
-- 
2.17.1


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

* [PATCH 2/3] USB: host: ohci-at91: suspend: delay needed before to stop clocks
  2019-09-11  6:41 [PATCH 0/3] USB: host: ohci-at91: tailor power consumption Nicolas Ferre
  2019-09-11  6:41 ` [PATCH 1/3] USB: host: ohci-at91: completely shutdown the controller in at91_stop_hc() Nicolas Ferre
@ 2019-09-11  6:41 ` Nicolas Ferre
  2019-09-11  6:41 ` [PATCH 3/3] USB: host: ohci-at91: resume: balance the clock start call Nicolas Ferre
  2019-09-11 15:09 ` [PATCH 0/3] USB: host: ohci-at91: tailor power consumption Alan Stern
  3 siblings, 0 replies; 5+ messages in thread
From: Nicolas Ferre @ 2019-09-11  6:41 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, stern, gregkh
  Cc: Alexandre Belloni, Ludovic Desroches, Boris.Krasnovskiy,
	linux-usb, Nicolas Ferre

In order to completely remove marginal power consumption in PM suspend,
we need to let the controller settle down before being stopped.
In ohci_hcd_at91_drv_suspend() function, one additional delay is needed before
to stop the clocks.

Reported-by: Boris Krasnovskiy <Boris.Krasnovskiy@lairdconnect.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
---
 drivers/usb/host/ohci-at91.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index cb63bcd5049a..85d67fe42d59 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -628,6 +628,7 @@ ohci_hcd_at91_drv_suspend(struct device *dev)
 
 		/* flush the writes */
 		(void) ohci_readl (ohci, &ohci->regs->control);
+		msleep(1);
 		at91_stop_clock(ohci_at91);
 	}
 
-- 
2.17.1


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

* [PATCH 3/3] USB: host: ohci-at91: resume: balance the clock start call
  2019-09-11  6:41 [PATCH 0/3] USB: host: ohci-at91: tailor power consumption Nicolas Ferre
  2019-09-11  6:41 ` [PATCH 1/3] USB: host: ohci-at91: completely shutdown the controller in at91_stop_hc() Nicolas Ferre
  2019-09-11  6:41 ` [PATCH 2/3] USB: host: ohci-at91: suspend: delay needed before to stop clocks Nicolas Ferre
@ 2019-09-11  6:41 ` Nicolas Ferre
  2019-09-11 15:09 ` [PATCH 0/3] USB: host: ohci-at91: tailor power consumption Alan Stern
  3 siblings, 0 replies; 5+ messages in thread
From: Nicolas Ferre @ 2019-09-11  6:41 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, stern, gregkh
  Cc: Alexandre Belloni, Ludovic Desroches, Boris.Krasnovskiy,
	linux-usb, Nicolas Ferre

From: Boris Krasnovskiy <Boris.Krasnovskiy@lairdconnect.com>

There is a clock enable counter run away problem in resume ohci_at91. Code
enables clock that was never disabled in case of non wakeup interface. That
would make clock unstoppable in future.
Use proper alternative to start clocks only if they were stopped before.

Signed-off-by: Boris Krasnovskiy <Boris.Krasnovskiy@lairdconnect.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
---
 drivers/usb/host/ohci-at91.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 85d67fe42d59..513e48397743 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -643,8 +643,8 @@ ohci_hcd_at91_drv_resume(struct device *dev)
 
 	if (ohci_at91->wakeup)
 		disable_irq_wake(hcd->irq);
-
-	at91_start_clock(ohci_at91);
+	else
+		at91_start_clock(ohci_at91);
 
 	ohci_resume(hcd, false);
 
-- 
2.17.1


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

* Re: [PATCH 0/3] USB: host: ohci-at91: tailor power consumption
  2019-09-11  6:41 [PATCH 0/3] USB: host: ohci-at91: tailor power consumption Nicolas Ferre
                   ` (2 preceding siblings ...)
  2019-09-11  6:41 ` [PATCH 3/3] USB: host: ohci-at91: resume: balance the clock start call Nicolas Ferre
@ 2019-09-11 15:09 ` Alan Stern
  3 siblings, 0 replies; 5+ messages in thread
From: Alan Stern @ 2019-09-11 15:09 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: linux-kernel, linux-arm-kernel, gregkh, Alexandre Belloni,
	Ludovic Desroches, Boris.Krasnovskiy, linux-usb

On Wed, 11 Sep 2019, Nicolas Ferre wrote:

> Following a set of experiments we found areas of improvement for OHCI power
> consumption (and associated USB analog cells).
> This enhances the shutdown of residual power consumption in case of Linux
> suspend/resume and removal of the driver (when compiled as a module).
> 
> Best regards,
>   Nicolas
> 
> Boris Krasnovskiy (2):
>   USB: host: ohci-at91: completely shutdown the controller in
>     at91_stop_hc()
>   USB: host: ohci-at91: resume: balance the clock start call
> 
> Nicolas Ferre (1):
>   USB: host: ohci-at91: suspend: delay needed before to stop clocks
> 
>  drivers/usb/host/ohci-at91.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

For all three patches:

Acked-by: Alan Stern <stern@rowland.harvard.edu>


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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-11  6:41 [PATCH 0/3] USB: host: ohci-at91: tailor power consumption Nicolas Ferre
2019-09-11  6:41 ` [PATCH 1/3] USB: host: ohci-at91: completely shutdown the controller in at91_stop_hc() Nicolas Ferre
2019-09-11  6:41 ` [PATCH 2/3] USB: host: ohci-at91: suspend: delay needed before to stop clocks Nicolas Ferre
2019-09-11  6:41 ` [PATCH 3/3] USB: host: ohci-at91: resume: balance the clock start call Nicolas Ferre
2019-09-11 15:09 ` [PATCH 0/3] USB: host: ohci-at91: tailor power consumption Alan Stern

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 linux-usb@archiver.kernel.org
	public-inbox-index linux-usb


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