svn commit: r356545 - head/sys/dev/usb/controller
Hans Petter Selasky
hselasky at FreeBSD.org
Thu Jan 9 09:29:25 UTC 2020
Author: hselasky
Date: Thu Jan 9 09:29:24 2020
New Revision: 356545
URL: https://svnweb.freebsd.org/changeset/base/356545
Log:
Fix a XHCI driver issue with Intel's Gemini Lake SOC.
Do not configure any endpoint twice, but instead keep track of which
endpoints are configured on a per device basis, and use an evaluate
endpoint context command instead. When changing the configuration make
sure all endpoints get deconfigured and the configured endpoint mask
is reset.
This fixes an issue where an endpoint might stop working if there is
an error and the endpoint needs to be reconfigured as a part of the
error recovery mechanism in the FreeBSD USB stack.
Tested by: Shichun.Ma at dell.com
MFC after: 1 week
Sponsored by: Mellanox Technologies
Modified:
head/sys/dev/usb/controller/xhci.c
head/sys/dev/usb/controller/xhci.h
Modified: head/sys/dev/usb/controller/xhci.c
==============================================================================
--- head/sys/dev/usb/controller/xhci.c Thu Jan 9 09:14:54 2020 (r356544)
+++ head/sys/dev/usb/controller/xhci.c Thu Jan 9 09:29:24 2020 (r356545)
@@ -3838,6 +3838,7 @@ xhci_configure_reset_endpoint(struct usb_xfer *xfer)
struct usb_page_cache *pcinp;
usb_error_t err;
usb_stream_t stream_id;
+ uint32_t mask;
uint8_t index;
uint8_t epno;
@@ -3903,16 +3904,20 @@ xhci_configure_reset_endpoint(struct usb_xfer *xfer)
* endpoint context state diagram in the XHCI specification:
*/
- xhci_configure_mask(udev, (1U << epno) | 1U, 0);
+ mask = (1U << epno);
+ xhci_configure_mask(udev, mask | 1U, 0);
- if (epno > 1)
+ if (!(sc->sc_hw.devs[index].ep_configured & mask)) {
+ sc->sc_hw.devs[index].ep_configured |= mask;
err = xhci_cmd_configure_ep(sc, buf_inp.physaddr, 0, index);
- else
+ } else {
err = xhci_cmd_evaluate_ctx(sc, buf_inp.physaddr, index);
+ }
- if (err != 0)
- DPRINTF("Could not configure endpoint %u\n", epno);
-
+ if (err != 0) {
+ DPRINTF("Could not configure "
+ "endpoint %u at slot %u.\n", epno, index);
+ }
XHCI_CMD_UNLOCK(sc);
return (0);
@@ -4273,6 +4278,7 @@ xhci_device_state_change(struct usb_device *udev)
/* set default state */
sc->sc_hw.devs[index].state = XHCI_ST_DEFAULT;
+ sc->sc_hw.devs[index].ep_configured = 3U;
/* reset number of contexts */
sc->sc_hw.devs[index].context_num = 0;
@@ -4290,6 +4296,7 @@ xhci_device_state_change(struct usb_device *udev)
break;
sc->sc_hw.devs[index].state = XHCI_ST_ADDRESSED;
+ sc->sc_hw.devs[index].ep_configured = 3U;
/* set configure mask to slot only */
xhci_configure_mask(udev, 1, 0);
@@ -4304,11 +4311,19 @@ xhci_device_state_change(struct usb_device *udev)
break;
case USB_STATE_CONFIGURED:
- if (sc->sc_hw.devs[index].state == XHCI_ST_CONFIGURED)
- break;
+ if (sc->sc_hw.devs[index].state == XHCI_ST_CONFIGURED) {
+ /* deconfigure all endpoints, except EP0 */
+ err = xhci_cmd_configure_ep(sc, 0, 1, index);
+ if (err) {
+ DPRINTF("Failed to deconfigure "
+ "slot %u.\n", index);
+ }
+ }
+
/* set configured state */
sc->sc_hw.devs[index].state = XHCI_ST_CONFIGURED;
+ sc->sc_hw.devs[index].ep_configured = 3U;
/* reset number of contexts */
sc->sc_hw.devs[index].context_num = 0;
Modified: head/sys/dev/usb/controller/xhci.h
==============================================================================
--- head/sys/dev/usb/controller/xhci.h Thu Jan 9 09:14:54 2020 (r356544)
+++ head/sys/dev/usb/controller/xhci.h Thu Jan 9 09:29:24 2020 (r356545)
@@ -408,6 +408,8 @@ struct xhci_hw_dev {
struct xhci_endpoint_ext endp[XHCI_MAX_ENDPOINTS];
+ uint32_t ep_configured;
+
uint8_t state;
uint8_t nports;
uint8_t tt;
More information about the svn-src-all
mailing list