On 2020-03-08 12:15, [email protected] wrote:
Link info need 4 bits and they take bit 5 to bit 9, while  UPS_PORT_POWER  
takes bit 9.
So this will give wrong link state info in function uhub_suspend_resume_port 
when it check if need usbd_req_warm_reset_port.
Please review and kindly suggest how to fix this issue.

Hi,

You are absolutely right. Good catch.

I think we will just remove the POWER bit from the super speed RH. It is currently not needed for anything. Then the LINK state values won't be clobbered like you found.

Does the attached patch work for you?

--HPS
Index: sys/dev/usb/controller/xhci.c
===================================================================
--- sys/dev/usb/controller/xhci.c	(revision 358693)
+++ sys/dev/usb/controller/xhci.c	(working copy)
@@ -3591,13 +3591,10 @@
 			i |= UPS_OVERCURRENT_INDICATOR;
 		if (v & XHCI_PS_PR)
 			i |= UPS_RESET;
-		if (v & XHCI_PS_PP) {
-			/*
-			 * The USB 3.0 RH is using the
-			 * USB 2.0's power bit
-			 */
-			i |= UPS_PORT_POWER;
-		}
+#if 0
+		if (v & XHCI_PS_PP)
+			/* XXX undefined */
+#endif
 		USETW(sc->sc_hub_desc.ps.wPortStatus, i);
 
 		i = 0;
Index: sys/dev/usb/usb_hub.c
===================================================================
--- sys/dev/usb/usb_hub.c	(revision 358693)
+++ sys/dev/usb/usb_hub.c	(working copy)
@@ -660,7 +660,7 @@
 		break;
 	case USB_SPEED_SUPER:
 		if (udev->parent_hub == NULL)
-			power_mask = UPS_PORT_POWER;
+			power_mask = 0;	/* XXX undefined */
 		else
 			power_mask = UPS_PORT_POWER_SS;
 		break;
@@ -668,7 +668,7 @@
 		power_mask = 0;
 		break;
 	}
-	if (!(sc->sc_st.port_status & power_mask)) {
+	if ((sc->sc_st.port_status & power_mask) != power_mask) {
 		DPRINTF("WARNING: strange, connected port %d "
 		    "has no power\n", portno);
 	}
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "[email protected]"

Reply via email to