2019-09-11 06:44:38

by Nicolas Ferre

[permalink] [raw]
Subject: [PATCH 0/3] USB: host: ohci-at91: tailor power consumption

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


2019-09-11 06:44:40

by Nicolas Ferre

[permalink] [raw]
Subject: [PATCH 1/3] USB: host: ohci-at91: completely shutdown the controller in at91_stop_hc()

From: Boris Krasnovskiy <[email protected]>

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 <[email protected]>
Signed-off-by: Nicolas Ferre <[email protected]>
---
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

2019-09-11 06:45:03

by Nicolas Ferre

[permalink] [raw]
Subject: [PATCH 2/3] USB: host: ohci-at91: suspend: delay needed before to stop clocks

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 <[email protected]>
Signed-off-by: Nicolas Ferre <[email protected]>
---
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

2019-09-11 06:45:22

by Nicolas Ferre

[permalink] [raw]
Subject: [PATCH 3/3] USB: host: ohci-at91: resume: balance the clock start call

From: Boris Krasnovskiy <[email protected]>

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 <[email protected]>
Signed-off-by: Nicolas Ferre <[email protected]>
---
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

2019-09-11 15:11:49

by Alan Stern

[permalink] [raw]
Subject: Re: [PATCH 0/3] USB: host: ohci-at91: tailor power consumption

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 <[email protected]>