From d26df3b6ec96f236eeb1714a80a17dff1d6833bb Mon Sep 17 00:00:00 2001 From: hselasky Date: Tue, 29 Apr 2014 05:48:50 +0000 Subject: [PATCH] MFC r265015: Setting the IMOD value below 0x3F8 can cause IRQ lockups in the Intel LynxPoint USB 3.0 controllers found in MacBookPro 2013's. git-svn-id: svn://svn.freebsd.org/base/stable/8@265080 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/usb/controller/xhci.c | 6 +++++- sys/dev/usb/controller/xhci.h | 1 + sys/dev/usb/controller/xhci_pci.c | 1 + sys/dev/usb/controller/xhcireg.h | 3 ++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index 8bdde2501..06d6a1dc6 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -470,8 +470,12 @@ xhci_start_controller(struct xhci_softc *sc) XWRITE4(sc, runt, XHCI_ERSTSZ(0), XHCI_ERSTS_SET(temp)); + /* Check if we should use the default IMOD value */ + if (sc->sc_imod_default == 0) + sc->sc_imod_default = XHCI_IMOD_DEFAULT; + /* Setup interrupt rate */ - XWRITE4(sc, runt, XHCI_IMOD(0), XHCI_IMOD_DEFAULT); + XWRITE4(sc, runt, XHCI_IMOD(0), sc->sc_imod_default); usbd_get_page(&sc->sc_hw.root_pc, 0, &buf_res); diff --git a/sys/dev/usb/controller/xhci.h b/sys/dev/usb/controller/xhci.h index b9c7425f6..03441687c 100644 --- a/sys/dev/usb/controller/xhci.h +++ b/sys/dev/usb/controller/xhci.h @@ -470,6 +470,7 @@ struct xhci_softc { uint16_t sc_erst_max; uint16_t sc_event_idx; uint16_t sc_command_idx; + uint16_t sc_imod_default; uint8_t sc_event_ccs; uint8_t sc_command_ccs; diff --git a/sys/dev/usb/controller/xhci_pci.c b/sys/dev/usb/controller/xhci_pci.c index b704a263f..e8e9749f5 100644 --- a/sys/dev/usb/controller/xhci_pci.c +++ b/sys/dev/usb/controller/xhci_pci.c @@ -226,6 +226,7 @@ xhci_pci_attach(device_t self) case 0x1e318086: /* Panther Point */ case 0x8c318086: /* Lynx Point */ sc->sc_port_route = &xhci_pci_port_route; + sc->sc_imod_default = XHCI_IMOD_DEFAULT_LP; break; default: break; diff --git a/sys/dev/usb/controller/xhcireg.h b/sys/dev/usb/controller/xhcireg.h index a130f65b9..bd1d635cf 100644 --- a/sys/dev/usb/controller/xhcireg.h +++ b/sys/dev/usb/controller/xhcireg.h @@ -166,7 +166,8 @@ #define XHCI_IMOD_IVAL_SET(x) (((x) & 0xFFFF) << 0) /* 250ns unit */ #define XHCI_IMOD_ICNT_GET(x) (((x) >> 16) & 0xFFFF) /* 250ns unit */ #define XHCI_IMOD_ICNT_SET(x) (((x) & 0xFFFF) << 16) /* 250ns unit */ -#define XHCI_IMOD_DEFAULT 0x000001F4U /* 8000 IRQ/second */ +#define XHCI_IMOD_DEFAULT 0x000001F4U /* 8000 IRQs/second */ +#define XHCI_IMOD_DEFAULT_LP 0x000003F8U /* 4000 IRQs/second - LynxPoint */ #define XHCI_ERSTSZ(n) (0x0028 + (0x20 * (n))) /* XHCI event ring segment table size */ #define XHCI_ERSTS_GET(x) ((x) & 0xFFFF) #define XHCI_ERSTS_SET(x) ((x) & 0xFFFF) -- 2.45.0