This patch set fixes and improves the Partial Power Down mode for dwc2 core. It adds support for the following cases 1. Entering and exiting partial power down when a port is suspended, resumed, port reset is asserted. 2. Exiting the partial power down mode before removing driver. 3. Exiting partial power down in wakeup detected interrupt handler. 4. Exiting from partial power down mode when connector ID. status changes to "connId B
It updates and fixes the implementation of dwc2 entering and exiting partial power down mode when the system (PC) is suspended.
The patch set also improves the implementation of function handlers for entering and exiting host or device partial power down.
NOTE: This is the second patch set in the power saving mode fixes series. This patch set is part of multiple series and is continuation of the "usb: dwc2: Fix and improve power saving modes" patch set. (Patch set link: https://marc.info/?l=linux-usb&m=160379622403975&w=2). The patches that were included in the "usb: dwc2: Fix and improve power saving modes" which was submitted earlier was too large and needed to be split up into smaller patch sets.
Artur Petrosyan (14): usb: dwc2: Add device partial power down functions usb: dwc2: Add host partial power down functions usb: dwc2: Update enter and exit partial power down functions usb: dwc2: Add partial power down exit flow in wakeup intr. usb: dwc2: Update port suspend/resume function definitions. usb: dwc2: Add enter partial power down when port is suspended usb: dwc2: Add exit partial power down when port is resumed usb: dwc2: Add exit partial power down when port reset is asserted usb: dwc2: Add part. power down exit from dwc2_conn_id_status_change(). usb: dwc2: Allow exit partial power down in urb enqueue usb: dwc2: Fix session request interrupt handler usb: dwc2: Update partial power down entering by system suspend usb: dwc2: Fix partial power down exiting by system resume usb: dwc2: Add exit partial power down before removing driver
drivers/usb/dwc2/core.c | 113 ++------- drivers/usb/dwc2/core.h | 27 ++- drivers/usb/dwc2/core_intr.c | 46 ++-- drivers/usb/dwc2/gadget.c | 148 ++++++++++- drivers/usb/dwc2/hcd.c | 458 +++++++++++++++++++++++++---------- drivers/usb/dwc2/hw.h | 1 + drivers/usb/dwc2/platform.c | 11 +- 7 files changed, 558 insertions(+), 246 deletions(-)
base-commit: e9fcb07704fcef6fa6d0333fd2b3a62442eaf45b
Fixes the implementation of exiting from partial power down power saving mode when PC is resumed.
Added port connection status checking which prevents exiting from Partial Power Down mode from _dwc2_hcd_resume() if not in Partial Power Down mode.
Rearranged the implementation to get rid of many "if" statements.
NOTE: Switch case statement is used for hibernation partial power down and clock gating mode determination. In this patch only Partial Power Down is implemented the Hibernation and clock gating implementations are planned to be added.
Cc: stable@vger.kernel.org Fixes: 6f6d70597c15 ("usb: dwc2: bus suspend/resume for hosts with DWC2_POWER_DOWN_PARAM_NONE") Signed-off-by: Artur Petrosyan Arthur.Petrosyan@synopsys.com --- drivers/usb/dwc2/hcd.c | 90 +++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 44 deletions(-)
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 34030bafdff4..f096006df96f 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4427,7 +4427,7 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) { struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); unsigned long flags; - u32 pcgctl; + u32 hprt0; int ret = 0;
spin_lock_irqsave(&hsotg->lock, flags); @@ -4438,11 +4438,40 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) if (hsotg->lx_state != DWC2_L2) goto unlock;
- if (hsotg->params.power_down > DWC2_POWER_DOWN_PARAM_PARTIAL) { + hprt0 = dwc2_read_hprt0(hsotg); + + /* + * Added port connection status checking which prevents exiting from + * Partial Power Down mode from _dwc2_hcd_resume() if not in Partial + * Power Down mode. + */ + if (hprt0 & HPRT0_CONNSTS) { + hsotg->lx_state = DWC2_L0; + goto unlock; + } + + switch (hsotg->params.power_down) { + case DWC2_POWER_DOWN_PARAM_PARTIAL: + ret = dwc2_exit_partial_power_down(hsotg, 0, true); + if (ret) + dev_err(hsotg->dev, + "exit partial_power_down failed\n"); + /* + * Set HW accessible bit before powering on the controller + * since an interrupt may rise. + */ + set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); + break; + case DWC2_POWER_DOWN_PARAM_HIBERNATION: + case DWC2_POWER_DOWN_PARAM_NONE: + default: hsotg->lx_state = DWC2_L0; goto unlock; }
+ /* Change Root port status, as port status change occurred after resume.*/ + hsotg->flags.b.port_suspend_change = 1; + /* * Enable power if not already done. * This must not be spinlocked since duration @@ -4454,52 +4483,25 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) spin_lock_irqsave(&hsotg->lock, flags); }
- if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_PARTIAL) { - /* - * Set HW accessible bit before powering on the controller - * since an interrupt may rise. - */ - set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); - - - /* Exit partial_power_down */ - ret = dwc2_exit_partial_power_down(hsotg, 0, true); - if (ret && (ret != -ENOTSUPP)) - dev_err(hsotg->dev, "exit partial_power_down failed\n"); - } else { - pcgctl = readl(hsotg->regs + PCGCTL); - pcgctl &= ~PCGCTL_STOPPCLK; - writel(pcgctl, hsotg->regs + PCGCTL); - } - - hsotg->lx_state = DWC2_L0; - + /* Enable external vbus supply after resuming the port. */ spin_unlock_irqrestore(&hsotg->lock, flags); + dwc2_vbus_supply_init(hsotg);
- if (hsotg->bus_suspended) { - spin_lock_irqsave(&hsotg->lock, flags); - hsotg->flags.b.port_suspend_change = 1; - spin_unlock_irqrestore(&hsotg->lock, flags); - dwc2_port_resume(hsotg); - } else { - if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_PARTIAL) { - dwc2_vbus_supply_init(hsotg); - - /* Wait for controller to correctly update D+/D- level */ - usleep_range(3000, 5000); - } + /* Wait for controller to correctly update D+/D- level */ + usleep_range(3000, 5000); + spin_lock_irqsave(&hsotg->lock, flags);
- /* - * Clear Port Enable and Port Status changes. - * Enable Port Power. - */ - dwc2_writel(hsotg, HPRT0_PWR | HPRT0_CONNDET | - HPRT0_ENACHG, HPRT0); - /* Wait for controller to detect Port Connect */ - usleep_range(5000, 7000); - } + /* + * Clear Port Enable and Port Status changes. + * Enable Port Power. + */ + dwc2_writel(hsotg, HPRT0_PWR | HPRT0_CONNDET | + HPRT0_ENACHG, HPRT0);
- return ret; + /* Wait for controller to detect Port Connect */ + spin_unlock_irqrestore(&hsotg->lock, flags); + usleep_range(5000, 7000); + spin_lock_irqsave(&hsotg->lock, flags); unlock: spin_unlock_irqrestore(&hsotg->lock, flags);
Hi Greg,
On 4/7/2021 14:00, Artur Petrosyan wrote:
This patch set fixes and improves the Partial Power Down mode for dwc2 core. It adds support for the following cases 1. Entering and exiting partial power down when a port is suspended, resumed, port reset is asserted. 2. Exiting the partial power down mode before removing driver. 3. Exiting partial power down in wakeup detected interrupt handler. 4. Exiting from partial power down mode when connector ID. status changes to "connId B
It updates and fixes the implementation of dwc2 entering and exiting partial power down mode when the system (PC) is suspended.
The patch set also improves the implementation of function handlers for entering and exiting host or device partial power down.
NOTE: This is the second patch set in the power saving mode fixes series. This patch set is part of multiple series and is continuation of the "usb: dwc2: Fix and improve power saving modes" patch set. (Patch set link: https://marc.info/?l=linux-usb&m=160379622403975&w=2). The patches that were included in the "usb: dwc2: Fix and improve power saving modes" which was submitted earlier was too large and needed to be split up into smaller patch sets.
Artur Petrosyan (14): usb: dwc2: Add device partial power down functions usb: dwc2: Add host partial power down functions usb: dwc2: Update enter and exit partial power down functions usb: dwc2: Add partial power down exit flow in wakeup intr. usb: dwc2: Update port suspend/resume function definitions. usb: dwc2: Add enter partial power down when port is suspended usb: dwc2: Add exit partial power down when port is resumed usb: dwc2: Add exit partial power down when port reset is asserted usb: dwc2: Add part. power down exit from dwc2_conn_id_status_change(). usb: dwc2: Allow exit partial power down in urb enqueue usb: dwc2: Fix session request interrupt handler usb: dwc2: Update partial power down entering by system suspend usb: dwc2: Fix partial power down exiting by system resume usb: dwc2: Add exit partial power down before removing driver
drivers/usb/dwc2/core.c | 113 ++------- drivers/usb/dwc2/core.h | 27 ++- drivers/usb/dwc2/core_intr.c | 46 ++-- drivers/usb/dwc2/gadget.c | 148 ++++++++++- drivers/usb/dwc2/hcd.c | 458 +++++++++++++++++++++++++---------- drivers/usb/dwc2/hw.h | 1 + drivers/usb/dwc2/platform.c | 11 +- 7 files changed, 558 insertions(+), 246 deletions(-)
base-commit: e9fcb07704fcef6fa6d0333fd2b3a62442eaf45b
I have submitted this patch set yesterday. It contains 14 patches. But only 2 of those patches were received by LKML only the cover letter and the 13th patch. (https://lore.kernel.org/linux-usb/cover.1617782102.git.Arthur.Petrosyan@syno...)
I checked here at Synopsys, Minas did receive all the patches as his email is in To list. Could this be an issue of vger.kernel.org mailing server?
Because I checked every local possibility that could result to such behavior. The patch 13 which was received by LKML has the similar content as the other patches.
The mailing tool that was used is ssmtp, checked all the configurations everything is fine.
Could you please suggest what should I do in this situation?
Regards, Artur
On Thu, Apr 08, 2021 at 05:57:57AM +0000, Artur Petrosyan wrote:
Hi Greg,
On 4/7/2021 14:00, Artur Petrosyan wrote:
This patch set fixes and improves the Partial Power Down mode for dwc2 core. It adds support for the following cases 1. Entering and exiting partial power down when a port is suspended, resumed, port reset is asserted. 2. Exiting the partial power down mode before removing driver. 3. Exiting partial power down in wakeup detected interrupt handler. 4. Exiting from partial power down mode when connector ID. status changes to "connId B
It updates and fixes the implementation of dwc2 entering and exiting partial power down mode when the system (PC) is suspended.
The patch set also improves the implementation of function handlers for entering and exiting host or device partial power down.
NOTE: This is the second patch set in the power saving mode fixes series. This patch set is part of multiple series and is continuation of the "usb: dwc2: Fix and improve power saving modes" patch set. (Patch set link: https://marc.info/?l=linux-usb&m=160379622403975&w=2). The patches that were included in the "usb: dwc2: Fix and improve power saving modes" which was submitted earlier was too large and needed to be split up into smaller patch sets.
Artur Petrosyan (14): usb: dwc2: Add device partial power down functions usb: dwc2: Add host partial power down functions usb: dwc2: Update enter and exit partial power down functions usb: dwc2: Add partial power down exit flow in wakeup intr. usb: dwc2: Update port suspend/resume function definitions. usb: dwc2: Add enter partial power down when port is suspended usb: dwc2: Add exit partial power down when port is resumed usb: dwc2: Add exit partial power down when port reset is asserted usb: dwc2: Add part. power down exit from dwc2_conn_id_status_change(). usb: dwc2: Allow exit partial power down in urb enqueue usb: dwc2: Fix session request interrupt handler usb: dwc2: Update partial power down entering by system suspend usb: dwc2: Fix partial power down exiting by system resume usb: dwc2: Add exit partial power down before removing driver
drivers/usb/dwc2/core.c | 113 ++------- drivers/usb/dwc2/core.h | 27 ++- drivers/usb/dwc2/core_intr.c | 46 ++-- drivers/usb/dwc2/gadget.c | 148 ++++++++++- drivers/usb/dwc2/hcd.c | 458 +++++++++++++++++++++++++---------- drivers/usb/dwc2/hw.h | 1 + drivers/usb/dwc2/platform.c | 11 +- 7 files changed, 558 insertions(+), 246 deletions(-)
base-commit: e9fcb07704fcef6fa6d0333fd2b3a62442eaf45b
I have submitted this patch set yesterday. It contains 14 patches. But only 2 of those patches were received by LKML only the cover letter and the 13th patch. (https://lore.kernel.org/linux-usb/cover.1617782102.git.Arthur.Petrosyan@syno...)
I checked here at Synopsys, Minas did receive all the patches as his email is in To list. Could this be an issue of vger.kernel.org mailing server?
Because I checked every local possibility that could result to such behavior. The patch 13 which was received by LKML has the similar content as the other patches.
The mailing tool that was used is ssmtp, checked all the configurations everything is fine.
Could you please suggest what should I do in this situation?
Odd, I got them here, but lore seems to not have them :(
Can you just resend them as a "v2" series so we know which to review and let's see if that works better...
thanks,
greg k-h
This patch set fixes and improves the Partial Power Down mode for dwc2 core. It adds support for the following cases 1. Entering and exiting partial power down when a port is suspended, resumed, port reset is asserted. 2. Exiting the partial power down mode before removing driver. 3. Exiting partial power down in wakeup detected interrupt handler. 4. Exiting from partial power down mode when connector ID. status changes to "connId B
It updates and fixes the implementation of dwc2 entering and exiting partial power down mode when the system (PC) is suspended.
The patch set also improves the implementation of function handlers for entering and exiting host or device partial power down.
NOTE: This is the second patch set in the power saving mode fixes series. This patch set is part of multiple series and is continuation of the "usb: dwc2: Fix and improve power saving modes" patch set. (Patch set link: https://marc.info/?l=linux-usb&m=160379622403975&w=2). The patches that were included in the "usb: dwc2: Fix and improve power saving modes" which was submitted earlier was too large and needed to be split up into smaller patch sets.
Changes since V1: No changes in the patches or the source code. Sending the second version of the patch set because the first version was not received by vger.kernel.org.
Artur Petrosyan (14): usb: dwc2: Add device partial power down functions usb: dwc2: Add host partial power down functions usb: dwc2: Update enter and exit partial power down functions usb: dwc2: Add partial power down exit flow in wakeup intr. usb: dwc2: Update port suspend/resume function definitions. usb: dwc2: Add enter partial power down when port is suspended usb: dwc2: Add exit partial power down when port is resumed usb: dwc2: Add exit partial power down when port reset is asserted usb: dwc2: Add part. power down exit from dwc2_conn_id_status_change(). usb: dwc2: Allow exit partial power down in urb enqueue usb: dwc2: Fix session request interrupt handler usb: dwc2: Update partial power down entering by system suspend usb: dwc2: Fix partial power down exiting by system resume usb: dwc2: Add exit partial power down before removing driver
drivers/usb/dwc2/core.c | 113 ++------- drivers/usb/dwc2/core.h | 27 ++- drivers/usb/dwc2/core_intr.c | 46 ++-- drivers/usb/dwc2/gadget.c | 148 ++++++++++- drivers/usb/dwc2/hcd.c | 458 +++++++++++++++++++++++++---------- drivers/usb/dwc2/hw.h | 1 + drivers/usb/dwc2/platform.c | 11 +- 7 files changed, 558 insertions(+), 246 deletions(-)
base-commit: e9fcb07704fcef6fa6d0333fd2b3a62442eaf45b
Hi Greg,
On 4/8/2021 11:28, Artur Petrosyan wrote:
This patch set fixes and improves the Partial Power Down mode for dwc2 core. It adds support for the following cases 1. Entering and exiting partial power down when a port is suspended, resumed, port reset is asserted. 2. Exiting the partial power down mode before removing driver. 3. Exiting partial power down in wakeup detected interrupt handler. 4. Exiting from partial power down mode when connector ID. status changes to "connId B
It updates and fixes the implementation of dwc2 entering and exiting partial power down mode when the system (PC) is suspended.
The patch set also improves the implementation of function handlers for entering and exiting host or device partial power down.
NOTE: This is the second patch set in the power saving mode fixes series. This patch set is part of multiple series and is continuation of the "usb: dwc2: Fix and improve power saving modes" patch set. (Patch set link: https://marc.info/?l=linux-usb&m=160379622403975&w=2). The patches that were included in the "usb: dwc2: Fix and improve power saving modes" which was submitted earlier was too large and needed to be split up into smaller patch sets.
Changes since V1: No changes in the patches or the source code. Sending the second version of the patch set because the first version was not received by vger.kernel.org.
Artur Petrosyan (14): usb: dwc2: Add device partial power down functions usb: dwc2: Add host partial power down functions usb: dwc2: Update enter and exit partial power down functions usb: dwc2: Add partial power down exit flow in wakeup intr. usb: dwc2: Update port suspend/resume function definitions. usb: dwc2: Add enter partial power down when port is suspended usb: dwc2: Add exit partial power down when port is resumed usb: dwc2: Add exit partial power down when port reset is asserted usb: dwc2: Add part. power down exit from dwc2_conn_id_status_change(). usb: dwc2: Allow exit partial power down in urb enqueue usb: dwc2: Fix session request interrupt handler usb: dwc2: Update partial power down entering by system suspend usb: dwc2: Fix partial power down exiting by system resume usb: dwc2: Add exit partial power down before removing driver
drivers/usb/dwc2/core.c | 113 ++------- drivers/usb/dwc2/core.h | 27 ++- drivers/usb/dwc2/core_intr.c | 46 ++-- drivers/usb/dwc2/gadget.c | 148 ++++++++++- drivers/usb/dwc2/hcd.c | 458 +++++++++++++++++++++++++---------- drivers/usb/dwc2/hw.h | 1 + drivers/usb/dwc2/platform.c | 11 +- 7 files changed, 558 insertions(+), 246 deletions(-)
base-commit: e9fcb07704fcef6fa6d0333fd2b3a62442eaf45b
Re sending as a "v2" did not work :(. The patches are not in lore again.
Could the issue be with a comma in the end of To: or Cc: list? Let me remove the comma in the end of those lists and try sending as "v3".
Regards, Artur
Hi Greg,
On 4/8/2021 13:17, Artur Petrosyan wrote:
Hi Greg,
On 4/8/2021 11:28, Artur Petrosyan wrote:
This patch set fixes and improves the Partial Power Down mode for dwc2 core. It adds support for the following cases 1. Entering and exiting partial power down when a port is suspended, resumed, port reset is asserted. 2. Exiting the partial power down mode before removing driver. 3. Exiting partial power down in wakeup detected interrupt handler. 4. Exiting from partial power down mode when connector ID. status changes to "connId B
It updates and fixes the implementation of dwc2 entering and exiting partial power down mode when the system (PC) is suspended.
The patch set also improves the implementation of function handlers for entering and exiting host or device partial power down.
NOTE: This is the second patch set in the power saving mode fixes series. This patch set is part of multiple series and is continuation of the "usb: dwc2: Fix and improve power saving modes" patch set. (Patch set link: https://urldefense.com/v3/__https://marc.info/?l=linux-usb&m=16037962240... ). The patches that were included in the "usb: dwc2: Fix and improve power saving modes" which was submitted earlier was too large and needed to be split up into smaller patch sets.
Changes since V1: No changes in the patches or the source code. Sending the second version of the patch set because the first version was not received by vger.kernel.org.
Artur Petrosyan (14): usb: dwc2: Add device partial power down functions usb: dwc2: Add host partial power down functions usb: dwc2: Update enter and exit partial power down functions usb: dwc2: Add partial power down exit flow in wakeup intr. usb: dwc2: Update port suspend/resume function definitions. usb: dwc2: Add enter partial power down when port is suspended usb: dwc2: Add exit partial power down when port is resumed usb: dwc2: Add exit partial power down when port reset is asserted usb: dwc2: Add part. power down exit from dwc2_conn_id_status_change(). usb: dwc2: Allow exit partial power down in urb enqueue usb: dwc2: Fix session request interrupt handler usb: dwc2: Update partial power down entering by system suspend usb: dwc2: Fix partial power down exiting by system resume usb: dwc2: Add exit partial power down before removing driver
drivers/usb/dwc2/core.c | 113 ++------- drivers/usb/dwc2/core.h | 27 ++- drivers/usb/dwc2/core_intr.c | 46 ++-- drivers/usb/dwc2/gadget.c | 148 ++++++++++- drivers/usb/dwc2/hcd.c | 458 +++++++++++++++++++++++++---------- drivers/usb/dwc2/hw.h | 1 + drivers/usb/dwc2/platform.c | 11 +- 7 files changed, 558 insertions(+), 246 deletions(-)
base-commit: e9fcb07704fcef6fa6d0333fd2b3a62442eaf45b
Re sending as a "v2" did not work :(. The patches are not in lore again.
Could the issue be with a comma in the end of To: or Cc: list? Let me remove the comma in the end of those lists and try sending as "v3".
Regards, Artur
I just removed the comma in the end of those lists and resent the patch set as a "v3" and they are already seen in lore. There is one strange thing though on lore. Some patch titles are not fully visible.
For sure the issue was comma in the end of To: or Cc: lists. Not working example. To: Greg Kroah-Hartman gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Working example. To: Greg Kroah-Hartman gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
If the comma is at least in the end of one of those lists (To: or Cc:) vger.kernel.org mailing server will not accept them.
Regards, Artur
On Thu, Apr 08, 2021 at 10:09:20AM +0000, Artur Petrosyan wrote:
Hi Greg,
On 4/8/2021 13:17, Artur Petrosyan wrote:
Hi Greg,
On 4/8/2021 11:28, Artur Petrosyan wrote:
This patch set fixes and improves the Partial Power Down mode for dwc2 core. It adds support for the following cases 1. Entering and exiting partial power down when a port is suspended, resumed, port reset is asserted. 2. Exiting the partial power down mode before removing driver. 3. Exiting partial power down in wakeup detected interrupt handler. 4. Exiting from partial power down mode when connector ID. status changes to "connId B
It updates and fixes the implementation of dwc2 entering and exiting partial power down mode when the system (PC) is suspended.
The patch set also improves the implementation of function handlers for entering and exiting host or device partial power down.
NOTE: This is the second patch set in the power saving mode fixes series. This patch set is part of multiple series and is continuation of the "usb: dwc2: Fix and improve power saving modes" patch set. (Patch set link: https://urldefense.com/v3/__https://marc.info/?l=linux-usb&m=16037962240... ). The patches that were included in the "usb: dwc2: Fix and improve power saving modes" which was submitted earlier was too large and needed to be split up into smaller patch sets.
Changes since V1: No changes in the patches or the source code. Sending the second version of the patch set because the first version was not received by vger.kernel.org.
Artur Petrosyan (14): usb: dwc2: Add device partial power down functions usb: dwc2: Add host partial power down functions usb: dwc2: Update enter and exit partial power down functions usb: dwc2: Add partial power down exit flow in wakeup intr. usb: dwc2: Update port suspend/resume function definitions. usb: dwc2: Add enter partial power down when port is suspended usb: dwc2: Add exit partial power down when port is resumed usb: dwc2: Add exit partial power down when port reset is asserted usb: dwc2: Add part. power down exit from dwc2_conn_id_status_change(). usb: dwc2: Allow exit partial power down in urb enqueue usb: dwc2: Fix session request interrupt handler usb: dwc2: Update partial power down entering by system suspend usb: dwc2: Fix partial power down exiting by system resume usb: dwc2: Add exit partial power down before removing driver
drivers/usb/dwc2/core.c | 113 ++------- drivers/usb/dwc2/core.h | 27 ++- drivers/usb/dwc2/core_intr.c | 46 ++-- drivers/usb/dwc2/gadget.c | 148 ++++++++++- drivers/usb/dwc2/hcd.c | 458 +++++++++++++++++++++++++---------- drivers/usb/dwc2/hw.h | 1 + drivers/usb/dwc2/platform.c | 11 +- 7 files changed, 558 insertions(+), 246 deletions(-)
base-commit: e9fcb07704fcef6fa6d0333fd2b3a62442eaf45b
Re sending as a "v2" did not work :(. The patches are not in lore again.
Could the issue be with a comma in the end of To: or Cc: list? Let me remove the comma in the end of those lists and try sending as "v3".
Regards, Artur
I just removed the comma in the end of those lists and resent the patch set as a "v3" and they are already seen in lore. There is one strange thing though on lore. Some patch titles are not fully visible.
For sure the issue was comma in the end of To: or Cc: lists. Not working example. To: Greg Kroah-Hartman gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
That's an invalid To: line for email.
Working example. To: Greg Kroah-Hartman gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
That's a correct line.
If the comma is at least in the end of one of those lists (To: or Cc:) vger.kernel.org mailing server will not accept them.
I recommend using 'git send-email' with the --to="foo@bar.com" type options so that you don't have to hand-edit the lines to try to get stuff like this correct, as it is easy to get wrong.
thanks,
greg k-h
Fixes the implementation of exiting from partial power down power saving mode when PC is resumed.
Added port connection status checking which prevents exiting from Partial Power Down mode from _dwc2_hcd_resume() if not in Partial Power Down mode.
Rearranged the implementation to get rid of many "if" statements.
NOTE: Switch case statement is used for hibernation partial power down and clock gating mode determination. In this patch only Partial Power Down is implemented the Hibernation and clock gating implementations are planned to be added.
Cc: stable@vger.kernel.org Fixes: 6f6d70597c15 ("usb: dwc2: bus suspend/resume for hosts with DWC2_POWER_DOWN_PARAM_NONE") Signed-off-by: Artur Petrosyan Arthur.Petrosyan@synopsys.com --- Changes in v2: - None
drivers/usb/dwc2/hcd.c | 90 +++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 44 deletions(-)
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 34030bafdff4..f096006df96f 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4427,7 +4427,7 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) { struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); unsigned long flags; - u32 pcgctl; + u32 hprt0; int ret = 0;
spin_lock_irqsave(&hsotg->lock, flags); @@ -4438,11 +4438,40 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) if (hsotg->lx_state != DWC2_L2) goto unlock;
- if (hsotg->params.power_down > DWC2_POWER_DOWN_PARAM_PARTIAL) { + hprt0 = dwc2_read_hprt0(hsotg); + + /* + * Added port connection status checking which prevents exiting from + * Partial Power Down mode from _dwc2_hcd_resume() if not in Partial + * Power Down mode. + */ + if (hprt0 & HPRT0_CONNSTS) { + hsotg->lx_state = DWC2_L0; + goto unlock; + } + + switch (hsotg->params.power_down) { + case DWC2_POWER_DOWN_PARAM_PARTIAL: + ret = dwc2_exit_partial_power_down(hsotg, 0, true); + if (ret) + dev_err(hsotg->dev, + "exit partial_power_down failed\n"); + /* + * Set HW accessible bit before powering on the controller + * since an interrupt may rise. + */ + set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); + break; + case DWC2_POWER_DOWN_PARAM_HIBERNATION: + case DWC2_POWER_DOWN_PARAM_NONE: + default: hsotg->lx_state = DWC2_L0; goto unlock; }
+ /* Change Root port status, as port status change occurred after resume.*/ + hsotg->flags.b.port_suspend_change = 1; + /* * Enable power if not already done. * This must not be spinlocked since duration @@ -4454,52 +4483,25 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) spin_lock_irqsave(&hsotg->lock, flags); }
- if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_PARTIAL) { - /* - * Set HW accessible bit before powering on the controller - * since an interrupt may rise. - */ - set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); - - - /* Exit partial_power_down */ - ret = dwc2_exit_partial_power_down(hsotg, 0, true); - if (ret && (ret != -ENOTSUPP)) - dev_err(hsotg->dev, "exit partial_power_down failed\n"); - } else { - pcgctl = readl(hsotg->regs + PCGCTL); - pcgctl &= ~PCGCTL_STOPPCLK; - writel(pcgctl, hsotg->regs + PCGCTL); - } - - hsotg->lx_state = DWC2_L0; - + /* Enable external vbus supply after resuming the port. */ spin_unlock_irqrestore(&hsotg->lock, flags); + dwc2_vbus_supply_init(hsotg);
- if (hsotg->bus_suspended) { - spin_lock_irqsave(&hsotg->lock, flags); - hsotg->flags.b.port_suspend_change = 1; - spin_unlock_irqrestore(&hsotg->lock, flags); - dwc2_port_resume(hsotg); - } else { - if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_PARTIAL) { - dwc2_vbus_supply_init(hsotg); - - /* Wait for controller to correctly update D+/D- level */ - usleep_range(3000, 5000); - } + /* Wait for controller to correctly update D+/D- level */ + usleep_range(3000, 5000); + spin_lock_irqsave(&hsotg->lock, flags);
- /* - * Clear Port Enable and Port Status changes. - * Enable Port Power. - */ - dwc2_writel(hsotg, HPRT0_PWR | HPRT0_CONNDET | - HPRT0_ENACHG, HPRT0); - /* Wait for controller to detect Port Connect */ - usleep_range(5000, 7000); - } + /* + * Clear Port Enable and Port Status changes. + * Enable Port Power. + */ + dwc2_writel(hsotg, HPRT0_PWR | HPRT0_CONNDET | + HPRT0_ENACHG, HPRT0);
- return ret; + /* Wait for controller to detect Port Connect */ + spin_unlock_irqrestore(&hsotg->lock, flags); + usleep_range(5000, 7000); + spin_lock_irqsave(&hsotg->lock, flags); unlock: spin_unlock_irqrestore(&hsotg->lock, flags);
This patch set fixes and improves the Partial Power Down mode for dwc2 core. It adds support for the following cases 1. Entering and exiting partial power down when a port is suspended, resumed, port reset is asserted. 2. Exiting the partial power down mode before removing driver. 3. Exiting partial power down in wakeup detected interrupt handler. 4. Exiting from partial power down mode when connector ID. status changes to "connId B
It updates and fixes the implementation of dwc2 entering and exiting partial power down mode when the system (PC) is suspended.
The patch set also improves the implementation of function handlers for entering and exiting host or device partial power down.
NOTE: This is the second patch set in the power saving mode fixes series. This patch set is part of multiple series and is continuation of the "usb: dwc2: Fix and improve power saving modes" patch set. (Patch set link: https://marc.info/?l=linux-usb&m=160379622403975&w=2). The patches that were included in the "usb: dwc2: Fix and improve power saving modes" which was submitted earlier was too large and needed to be split up into smaller patch sets.
Changes since V2: No changes in the patches or the source code. Assuming that the issue due to which the patches are not reaching to vger.kernel.org is a comma in the end of To: or Cc: lists removed commas in the end of those lists in each email of patches.
Artur Petrosyan (14): usb: dwc2: Add device partial power down functions usb: dwc2: Add host partial power down functions usb: dwc2: Update enter and exit partial power down functions usb: dwc2: Add partial power down exit flow in wakeup intr. usb: dwc2: Update port suspend/resume function definitions. usb: dwc2: Add enter partial power down when port is suspended usb: dwc2: Add exit partial power down when port is resumed usb: dwc2: Add exit partial power down when port reset is asserted usb: dwc2: Add part. power down exit from dwc2_conn_id_status_change(). usb: dwc2: Allow exit partial power down in urb enqueue usb: dwc2: Fix session request interrupt handler usb: dwc2: Update partial power down entering by system suspend usb: dwc2: Fix partial power down exiting by system resume usb: dwc2: Add exit partial power down before removing driver
drivers/usb/dwc2/core.c | 113 ++------- drivers/usb/dwc2/core.h | 27 ++- drivers/usb/dwc2/core_intr.c | 46 ++-- drivers/usb/dwc2/gadget.c | 148 ++++++++++- drivers/usb/dwc2/hcd.c | 458 +++++++++++++++++++++++++---------- drivers/usb/dwc2/hw.h | 1 + drivers/usb/dwc2/platform.c | 11 +- 7 files changed, 558 insertions(+), 246 deletions(-)
base-commit: e9fcb07704fcef6fa6d0333fd2b3a62442eaf45b
According to programming guide in host mode, port power must be turned on in session request interrupt handlers.
Cc: stable@vger.kernel.org Fixes: 21795c826a45 ("usb: dwc2: exit hibernation on session request") Signed-off-by: Artur Petrosyan Arthur.Petrosyan@synopsys.com Acked-by: Minas Harutyunyan Minas.Harutyunyan@synopsys.com --- drivers/usb/dwc2/core_intr.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c index 0a7f9330907f..8c0152b514be 100644 --- a/drivers/usb/dwc2/core_intr.c +++ b/drivers/usb/dwc2/core_intr.c @@ -307,6 +307,7 @@ static void dwc2_handle_conn_id_status_change_intr(struct dwc2_hsotg *hsotg) static void dwc2_handle_session_req_intr(struct dwc2_hsotg *hsotg) { int ret; + u32 hprt0;
/* Clear interrupt */ dwc2_writel(hsotg, GINTSTS_SESSREQINT, GINTSTS); @@ -328,6 +329,13 @@ static void dwc2_handle_session_req_intr(struct dwc2_hsotg *hsotg) * established */ dwc2_hsotg_disconnect(hsotg); + } else { + /* Turn on the port power bit. */ + hprt0 = dwc2_read_hprt0(hsotg); + hprt0 |= HPRT0_PWR; + dwc2_writel(hsotg, hprt0, HPRT0); + /* Connect hcd after port power is set. */ + dwc2_hcd_connect(hsotg); } }
Fixes the implementation of exiting from partial power down power saving mode when PC is resumed.
Added port connection status checking which prevents exiting from Partial Power Down mode from _dwc2_hcd_resume() if not in Partial Power Down mode.
Rearranged the implementation to get rid of many "if" statements.
NOTE: Switch case statement is used for hibernation partial power down and clock gating mode determination. In this patch only Partial Power Down is implemented the Hibernation and clock gating implementations are planned to be added.
Cc: stable@vger.kernel.org Fixes: 6f6d70597c15 ("usb: dwc2: bus suspend/resume for hosts with DWC2_POWER_DOWN_PARAM_NONE") Signed-off-by: Artur Petrosyan Arthur.Petrosyan@synopsys.com --- Changes in v3: - None Changes in v2: - None
drivers/usb/dwc2/hcd.c | 90 +++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 44 deletions(-)
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 34030bafdff4..f096006df96f 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4427,7 +4427,7 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) { struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); unsigned long flags; - u32 pcgctl; + u32 hprt0; int ret = 0;
spin_lock_irqsave(&hsotg->lock, flags); @@ -4438,11 +4438,40 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) if (hsotg->lx_state != DWC2_L2) goto unlock;
- if (hsotg->params.power_down > DWC2_POWER_DOWN_PARAM_PARTIAL) { + hprt0 = dwc2_read_hprt0(hsotg); + + /* + * Added port connection status checking which prevents exiting from + * Partial Power Down mode from _dwc2_hcd_resume() if not in Partial + * Power Down mode. + */ + if (hprt0 & HPRT0_CONNSTS) { + hsotg->lx_state = DWC2_L0; + goto unlock; + } + + switch (hsotg->params.power_down) { + case DWC2_POWER_DOWN_PARAM_PARTIAL: + ret = dwc2_exit_partial_power_down(hsotg, 0, true); + if (ret) + dev_err(hsotg->dev, + "exit partial_power_down failed\n"); + /* + * Set HW accessible bit before powering on the controller + * since an interrupt may rise. + */ + set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); + break; + case DWC2_POWER_DOWN_PARAM_HIBERNATION: + case DWC2_POWER_DOWN_PARAM_NONE: + default: hsotg->lx_state = DWC2_L0; goto unlock; }
+ /* Change Root port status, as port status change occurred after resume.*/ + hsotg->flags.b.port_suspend_change = 1; + /* * Enable power if not already done. * This must not be spinlocked since duration @@ -4454,52 +4483,25 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) spin_lock_irqsave(&hsotg->lock, flags); }
- if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_PARTIAL) { - /* - * Set HW accessible bit before powering on the controller - * since an interrupt may rise. - */ - set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); - - - /* Exit partial_power_down */ - ret = dwc2_exit_partial_power_down(hsotg, 0, true); - if (ret && (ret != -ENOTSUPP)) - dev_err(hsotg->dev, "exit partial_power_down failed\n"); - } else { - pcgctl = readl(hsotg->regs + PCGCTL); - pcgctl &= ~PCGCTL_STOPPCLK; - writel(pcgctl, hsotg->regs + PCGCTL); - } - - hsotg->lx_state = DWC2_L0; - + /* Enable external vbus supply after resuming the port. */ spin_unlock_irqrestore(&hsotg->lock, flags); + dwc2_vbus_supply_init(hsotg);
- if (hsotg->bus_suspended) { - spin_lock_irqsave(&hsotg->lock, flags); - hsotg->flags.b.port_suspend_change = 1; - spin_unlock_irqrestore(&hsotg->lock, flags); - dwc2_port_resume(hsotg); - } else { - if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_PARTIAL) { - dwc2_vbus_supply_init(hsotg); - - /* Wait for controller to correctly update D+/D- level */ - usleep_range(3000, 5000); - } + /* Wait for controller to correctly update D+/D- level */ + usleep_range(3000, 5000); + spin_lock_irqsave(&hsotg->lock, flags);
- /* - * Clear Port Enable and Port Status changes. - * Enable Port Power. - */ - dwc2_writel(hsotg, HPRT0_PWR | HPRT0_CONNDET | - HPRT0_ENACHG, HPRT0); - /* Wait for controller to detect Port Connect */ - usleep_range(5000, 7000); - } + /* + * Clear Port Enable and Port Status changes. + * Enable Port Power. + */ + dwc2_writel(hsotg, HPRT0_PWR | HPRT0_CONNDET | + HPRT0_ENACHG, HPRT0);
- return ret; + /* Wait for controller to detect Port Connect */ + spin_unlock_irqrestore(&hsotg->lock, flags); + usleep_range(5000, 7000); + spin_lock_irqsave(&hsotg->lock, flags); unlock: spin_unlock_irqrestore(&hsotg->lock, flags);
On 4/8/2021 1:46 PM, Artur Petrosyan wrote:
Fixes the implementation of exiting from partial power down power saving mode when PC is resumed.
Added port connection status checking which prevents exiting from Partial Power Down mode from _dwc2_hcd_resume() if not in Partial Power Down mode.
Rearranged the implementation to get rid of many "if" statements.
NOTE: Switch case statement is used for hibernation partial power down and clock gating mode determination. In this patch only Partial Power Down is implemented the Hibernation and clock gating implementations are planned to be added.
Cc: stable@vger.kernel.org Fixes: 6f6d70597c15 ("usb: dwc2: bus suspend/resume for hosts with DWC2_POWER_DOWN_PARAM_NONE") Signed-off-by: Artur Petrosyan Arthur.Petrosyan@synopsys.com
Acked-by: Minas Harutyunyan Minas.Harutyunyan@synopsys.com
Changes in v3:
- None
Changes in v2:
- None
drivers/usb/dwc2/hcd.c | 90 +++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 44 deletions(-)
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 34030bafdff4..f096006df96f 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4427,7 +4427,7 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) { struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); unsigned long flags;
- u32 pcgctl;
- u32 hprt0; int ret = 0;
spin_lock_irqsave(&hsotg->lock, flags); @@ -4438,11 +4438,40 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) if (hsotg->lx_state != DWC2_L2) goto unlock;
- if (hsotg->params.power_down > DWC2_POWER_DOWN_PARAM_PARTIAL) {
- hprt0 = dwc2_read_hprt0(hsotg);
- /*
* Added port connection status checking which prevents exiting from
* Partial Power Down mode from _dwc2_hcd_resume() if not in Partial
* Power Down mode.
*/
- if (hprt0 & HPRT0_CONNSTS) {
hsotg->lx_state = DWC2_L0;
goto unlock;
- }
- switch (hsotg->params.power_down) {
- case DWC2_POWER_DOWN_PARAM_PARTIAL:
ret = dwc2_exit_partial_power_down(hsotg, 0, true);
if (ret)
dev_err(hsotg->dev,
"exit partial_power_down failed\n");
/*
* Set HW accessible bit before powering on the controller
* since an interrupt may rise.
*/
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
break;
- case DWC2_POWER_DOWN_PARAM_HIBERNATION:
- case DWC2_POWER_DOWN_PARAM_NONE:
- default: hsotg->lx_state = DWC2_L0; goto unlock; }
- /* Change Root port status, as port status change occurred after resume.*/
- hsotg->flags.b.port_suspend_change = 1;
- /*
- Enable power if not already done.
- This must not be spinlocked since duration
@@ -4454,52 +4483,25 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) spin_lock_irqsave(&hsotg->lock, flags); }
- if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_PARTIAL) {
/*
* Set HW accessible bit before powering on the controller
* since an interrupt may rise.
*/
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
/* Exit partial_power_down */
ret = dwc2_exit_partial_power_down(hsotg, 0, true);
if (ret && (ret != -ENOTSUPP))
dev_err(hsotg->dev, "exit partial_power_down failed\n");
- } else {
pcgctl = readl(hsotg->regs + PCGCTL);
pcgctl &= ~PCGCTL_STOPPCLK;
writel(pcgctl, hsotg->regs + PCGCTL);
- }
- hsotg->lx_state = DWC2_L0;
- /* Enable external vbus supply after resuming the port. */ spin_unlock_irqrestore(&hsotg->lock, flags);
- dwc2_vbus_supply_init(hsotg);
- if (hsotg->bus_suspended) {
spin_lock_irqsave(&hsotg->lock, flags);
hsotg->flags.b.port_suspend_change = 1;
spin_unlock_irqrestore(&hsotg->lock, flags);
dwc2_port_resume(hsotg);
- } else {
if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_PARTIAL) {
dwc2_vbus_supply_init(hsotg);
/* Wait for controller to correctly update D+/D- level */
usleep_range(3000, 5000);
}
- /* Wait for controller to correctly update D+/D- level */
- usleep_range(3000, 5000);
- spin_lock_irqsave(&hsotg->lock, flags);
/*
* Clear Port Enable and Port Status changes.
* Enable Port Power.
*/
dwc2_writel(hsotg, HPRT0_PWR | HPRT0_CONNDET |
HPRT0_ENACHG, HPRT0);
/* Wait for controller to detect Port Connect */
usleep_range(5000, 7000);
- }
- /*
* Clear Port Enable and Port Status changes.
* Enable Port Power.
*/
- dwc2_writel(hsotg, HPRT0_PWR | HPRT0_CONNDET |
HPRT0_ENACHG, HPRT0);
- return ret;
- /* Wait for controller to detect Port Connect */
- spin_unlock_irqrestore(&hsotg->lock, flags);
- usleep_range(5000, 7000);
- spin_lock_irqsave(&hsotg->lock, flags); unlock: spin_unlock_irqrestore(&hsotg->lock, flags);
linux-stable-mirror@lists.linaro.org