Skip to contentSkip to conversation

xhci: re-initialize the HC during resume if HCE was set

PATCH Superseded Puma Hsu 3 participants 10 messages Dec 28, 2021 – Dec 29, 2021

Subsystems (2)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Puma Hsu

author
#0 lore raw

PATCH 1/1 xhci: re-initialize the HC during resume if HCE was set

When HCE(Host Controller Error) is set, it means an internal error condition has been detected. It needs to re-initialize the HC too.

---
 drivers/usb/host/xhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/host/xhci.c +2 -2
index dc357cabb265..c546d9533410 100644
@@ -1146,8 +1146,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
 		temp = readl(&xhci->op_regs->status);
 	}
 
-	/* If restore operation fails, re-initialize the HC during resume */
-	if ((temp & STS_SRE) || hibernated) {
+	/* If restore operation fails or HC error is detected, re-initialize the HC during resume */
+	if ((temp & STS_SRE) || (temp & STS_HCE) || hibernated) {
 
 		if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) &&
 				!(xhci_all_ports_seen_u0(xhci))) {
Signature · 1 line
2.34.1.448.ga2b2bfdf31-goog
maintainer
#1 lore raw
Quoted 27 lines · Puma Hsu

When HCE(Host Controller Error) is set, it means an internal error condition has been detected. It needs to re-initialize the HC too.

---
 drivers/usb/host/xhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/host/xhci.c +2 -2
index dc357cabb265..c546d9533410 100644
@@ -1146,8 +1146,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
 		temp = readl(&xhci->op_regs->status);
 	}
 
-	/* If restore operation fails, re-initialize the HC during resume */
-	if ((temp & STS_SRE) || hibernated) {
+	/* If restore operation fails or HC error is detected, re-initialize the HC during resume */
+	if ((temp & STS_SRE) || (temp & STS_HCE) || hibernated) {
 
 		if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) &&
 				!(xhci_all_ports_seen_u0(xhci))) {
Signature · 1 line
2.34.1.448.ga2b2bfdf31-goog

What commit does this fix? Does it need to be backported to older kernels as well?

thanks,

greg k-h

author
#2 lore raw

This commit is not used to fix a specific commit. We find a condition that when XHCI runs the resume process but the HCE flag is set, then the Run/Stop bit of USBCMD cannot be set so that HC would not be enabled. In fact, HC may already meet a problem at this moment. Besides, in xHCI requirements specification revision 1.2, Table 5-21 BIT(12) claims that Software should re-initialize the xHC when HCE is set. Therefore, I think this commit could be the error handling for HCE.

Thanks in advance.

Thanks in advance.

  •  Puma Hsu 許誌宏
  •  Software Engineer, Pixel Phone
  •  Tel: +886 2 8729 0870
  •  [email protected]
Quoted 36 lines · Greg KH
Quoted 25 lines · Puma Hsu

When HCE(Host Controller Error) is set, it means an internal error condition has been detected. It needs to re-initialize the HC too.

---
 drivers/usb/host/xhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/host/xhci.c +2 -3
index dc357cabb265..c546d9533410 100644
@@ -1146,8 +1146,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
              temp = readl(&xhci->op_regs->status);
      }
 
-     /* If restore operation fails, re-initialize the HC during resume */
-     if ((temp & STS_SRE) || hibernated) {
+     /* If restore operation fails or HC error is detected, re-initialize the HC during resume */
+     if ((temp & STS_SRE) || (temp & STS_HCE) || hibernated) {
 
              if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) &&
                              !(xhci_all_ports_seen_u0(xhci))) {
--
Quoted 2 lines

2.34.1.448.ga2b2bfdf31-goog

What commit does this fix? Does it need to be backported to older kernels as well?

thanks,

greg k-h

maintainer
#3 lore raw

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

Quoted 8 lines · Puma Hsu

This commit is not used to fix a specific commit. We find a condition that when XHCI runs the resume process but the HCE flag is set, then the Run/Stop bit of USBCMD cannot be set so that HC would not be enabled. In fact, HC may already meet a problem at this moment. Besides, in xHCI requirements specification revision 1.2, Table 5-21 BIT(12) claims that Software should re-initialize the xHC when HCE is set. Therefore, I think this commit could be the error handling for HCE.

So this does not actually fix an issue that you have seen in any device or testing? So it is not relevant for older kernels but just "nice to have"?

How did you test this if you can not duplicate the problem?

thanks,

greg k-h

author
#4 lore raw
Quoted 23 lines · Greg KH

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

Quoted 8 lines · Puma Hsu

This commit is not used to fix a specific commit. We find a condition that when XHCI runs the resume process but the HCE flag is set, then the Run/Stop bit of USBCMD cannot be set so that HC would not be enabled. In fact, HC may already meet a problem at this moment. Besides, in xHCI requirements specification revision 1.2, Table 5-21 BIT(12) claims that Software should re-initialize the xHC when HCE is set. Therefore, I think this commit could be the error handling for HCE.

Quoted 6 lines

So this does not actually fix an issue that you have seen in any device or testing? So it is not relevant for older kernels but just "nice to have"?

How did you test this if you can not duplicate the problem?

Yes, we actually see that the HCE may be detected while running xhci_resume on our product platform, so I'm able to verify this commit can fix such a condition.
For older kernels, I'm not sure whether someone had ever met such issue, but I believe the Run/Stop bit of USBCMD cannot be set once HCE is raised.

Thanks.
Puma Hsu

Quoted 3 lines

thanks,

greg k-h

maintainer
#5 lore raw
Quoted 28 lines · Puma Hsu
Quoted 27 lines · Greg KH

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

Quoted 8 lines · Puma Hsu

This commit is not used to fix a specific commit. We find a condition that when XHCI runs the resume process but the HCE flag is set, then the Run/Stop bit of USBCMD cannot be set so that HC would not be enabled. In fact, HC may already meet a problem at this moment. Besides, in xHCI requirements specification revision 1.2, Table 5-21 BIT(12) claims that Software should re-initialize the xHC when HCE is set. Therefore, I think this commit could be the error handling for HCE.

So this does not actually fix an issue that you have seen in any device or testing? So it is not relevant for older kernels but just "nice to have"?

Quoted 6 lines
Quoted 2 lines

How did you test this if you can not duplicate the problem?

Yes, we actually see that the HCE may be detected while running xhci_resume on our product platform, so I'm able to verify this commit can fix such a condition.

Given that your product platform is an older kernel version than 5.17, I think that you also want this in the older kernel releases, so please mark it for stable backporting.

thanks,

greg k-h

author
#6 lore raw
Quoted 33 lines · Greg KH
Quoted 31 lines · Puma Hsu
Quoted 29 lines · Greg KH

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

Quoted 8 lines · Puma Hsu

This commit is not used to fix a specific commit. We find a condition that when XHCI runs the resume process but the HCE flag is set, then the Run/Stop bit of USBCMD cannot be set so that HC would not be enabled. In fact, HC may already meet a problem at this moment. Besides, in xHCI requirements specification revision 1.2, Table 5-21 BIT(12) claims that Software should re-initialize the xHC when HCE is set. Therefore, I think this commit could be the error handling for HCE.

So this does not actually fix an issue that you have seen in any device or testing? So it is not relevant for older kernels but just "nice to have"?

How did you test this if you can not duplicate the problem?

Quoted 8 lines
Quoted 3 lines

Yes, we actually see that the HCE may be detected while running xhci_resume on our product platform, so I'm able to verify this commit can fix such a condition.

Given that your product platform is an older kernel version than 5.17, I think that you also want this in the older kernel releases, so please mark it for stable backporting.

Thank you for advising.
Could I know how to do this? Just add "Cc: <[email protected]>" to the commit message?

Thanks.
Puma Hsu

maintainer
#7 lore raw
Quoted 38 lines · Puma Hsu
Quoted 37 lines · Greg KH
Quoted 34 lines · Puma Hsu
Quoted 23 lines · Greg KH

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

Quoted 8 lines · Puma Hsu

This commit is not used to fix a specific commit. We find a condition that when XHCI runs the resume process but the HCE flag is set, then the Run/Stop bit of USBCMD cannot be set so that HC would not be enabled. In fact, HC may already meet a problem at this moment. Besides, in xHCI requirements specification revision 1.2, Table 5-21 BIT(12) claims that Software should re-initialize the xHC when HCE is set. Therefore, I think this commit could be the error handling for HCE.

Quoted 6 lines

So this does not actually fix an issue that you have seen in any device or testing? So it is not relevant for older kernels but just "nice to have"?

How did you test this if you can not duplicate the problem?

Yes, we actually see that the HCE may be detected while running xhci_resume on our product platform, so I'm able to verify this commit can fix such a condition.

Quoted 7 lines
Quoted 4 lines

Given that your product platform is an older kernel version than 5.17, I think that you also want this in the older kernel releases, so please mark it for stable backporting.

Thank you for advising.
Could I know how to do this? Just add "Cc: <[email protected]>" to the commit message?

Yes, please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html

It should describe this well, if not, please let us know.

thanks,

greg k-h

#8 lore raw
In reply to Puma Hsu

Hello!

Quoted 14 lines · Puma Hsu

When HCE(Host Controller Error) is set, it means an internal error condition has been detected. It needs to re-initialize the HC too.

---
 drivers/usb/host/xhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/host/xhci.c +0 -0
index dc357cabb265..c546d9533410 100644

drivers/usb/host/xhci.c int xhci_resume(struct xhci_hcd *xhci, bool hibernated) · line 1150

Quoted 7 lines
drivers/usb/host/xhci.c +2 -2
@@ -1146,8 +1146,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
 		temp = readl(&xhci->op_regs->status);
 	}
 
-	/* If restore operation fails, re-initialize the HC during resume */
-	if ((temp & STS_SRE) || hibernated) {
+	/* If restore operation fails or HC error is detected, re-initialize the HC during resume */
+	if ((temp & STS_SRE) || (temp & STS_HCE) || hibernated) {
	if ((temp & (STS_SRE | STS_HCE)) || hibernated) {

[...]

MBR, Sergey

author
#9 lore raw
Quoted 29 lines · Sergey Shtylyov

Hello!

Quoted 14 lines · Puma Hsu

When HCE(Host Controller Error) is set, it means an internal error condition has been detected. It needs to re-initialize the HC too.

---
 drivers/usb/host/xhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/host/xhci.c +0 -0
index dc357cabb265..c546d9533410 100644

drivers/usb/host/xhci.c int xhci_resume(struct xhci_hcd *xhci, bool hibernated) · line 1150

Quoted 7 lines
drivers/usb/host/xhci.c +2 -2
@@ -1146,8 +1146,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
              temp = readl(&xhci->op_regs->status);
      }
 
-     /* If restore operation fails, re-initialize the HC during resume */
-     if ((temp & STS_SRE) || hibernated) {
+     /* If restore operation fails or HC error is detected, re-initialize the HC during resume */
+     if ((temp & STS_SRE) || (temp & STS_HCE) || hibernated) {
        if ((temp & (STS_SRE | STS_HCE)) || hibernated) {
Quoted 3 lines

[...]

MBR, Sergey

Thanks for advising, I will submit patch v2.