2017-11-03 18:28:30 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2009-04-28 10:52:28 +08:00
|
|
|
/*
|
|
|
|
* xHCI host controller driver PCI Bus Glue.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Intel Corp.
|
|
|
|
*
|
|
|
|
* Author: Sarah Sharp
|
|
|
|
* Some code borrowed from the Linux EHCI driver.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/pci.h>
|
2011-04-25 23:54:28 +08:00
|
|
|
#include <linux/slab.h>
|
2011-07-04 04:09:31 +08:00
|
|
|
#include <linux/module.h>
|
2015-07-21 22:20:25 +08:00
|
|
|
#include <linux/acpi.h>
|
2009-04-28 10:52:28 +08:00
|
|
|
|
|
|
|
#include "xhci.h"
|
2013-08-06 12:52:45 +08:00
|
|
|
#include "xhci-trace.h"
|
2009-04-28 10:52:28 +08:00
|
|
|
|
2016-01-26 23:50:05 +08:00
|
|
|
#define SSIC_PORT_NUM 2
|
|
|
|
#define SSIC_PORT_CFG2 0x880c
|
|
|
|
#define SSIC_PORT_CFG2_OFFSET 0x30
|
2015-07-21 22:20:26 +08:00
|
|
|
#define PROG_DONE (1 << 30)
|
|
|
|
#define SSIC_PORT_UNUSED (1 << 31)
|
|
|
|
|
2009-08-08 05:04:55 +08:00
|
|
|
/* Device for a quirk */
|
|
|
|
#define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73
|
|
|
|
#define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000
|
2016-06-02 03:01:29 +08:00
|
|
|
#define PCI_DEVICE_ID_FRESCO_LOGIC_FL1009 0x1009
|
xhci: Extend Fresco Logic MSI quirk.
Ali reports that plugging a device into the Fresco Logic xHCI host with
PCI device ID 1400 produces an IRQ error:
do_IRQ: 3.176 No irq handler for vector (irq -1)
Other early Fresco Logic host revisions don't support MSI, even though
their PCI config space claims they do. Extend the quirk to disabling
MSI to this chipset revision. Also enable the short transfer quirk,
since it's likely this revision also has that quirk, and it should be
harmless to enable.
04:00.0 0c03: 1b73:1400 (rev 01) (prog-if 30 [XHCI])
Subsystem: 1d5c:1000
Physical Slot: 3
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 51
Region 0: Memory at d4600000 (32-bit, non-prefetchable) [size=64K]
Capabilities: [50] Power Management version 3
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold-)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [68] MSI: Enable+ Count=1/1 Maskable- 64bit+
Address: 00000000feeff00c Data: 41b1
Capabilities: [80] Express (v1) Endpoint, MSI 00
DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s <2us, L1 <32us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #0, Speed 2.5GT/s, Width x1, ASPM L0s L1, Latency L0 unlimited, L1 unlimited
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
Kernel driver in use: xhci_hcd
This patch should be backported to stable kernels as old as 2.6.36, that
contain the commit f5182b4155b9d686c5540a6822486400e34ddd98 "xhci:
Disable MSI for some Fresco Logic hosts."
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Reported-by: A Sh <smr.ash1991@gmail.com>
Tested-by: A Sh <smr.ash1991@gmail.com>
Cc: stable@vger.kernel.org
2012-10-18 04:44:06 +08:00
|
|
|
#define PCI_DEVICE_ID_FRESCO_LOGIC_FL1400 0x1400
|
2009-08-08 05:04:55 +08:00
|
|
|
|
2011-06-16 05:47:21 +08:00
|
|
|
#define PCI_VENDOR_ID_ETRON 0x1b6f
|
2014-07-26 04:01:19 +08:00
|
|
|
#define PCI_DEVICE_ID_EJ168 0x7023
|
2011-06-16 05:47:21 +08:00
|
|
|
|
2013-09-12 14:11:06 +08:00
|
|
|
#define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI 0x8c31
|
|
|
|
#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31
|
2016-10-20 23:09:18 +08:00
|
|
|
#define PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI 0x9cb1
|
2015-03-06 23:23:19 +08:00
|
|
|
#define PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI 0x22b5
|
|
|
|
#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f
|
|
|
|
#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f
|
2016-01-26 23:50:08 +08:00
|
|
|
#define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8
|
2016-04-08 21:25:05 +08:00
|
|
|
#define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8
|
2016-10-20 23:09:19 +08:00
|
|
|
#define PCI_DEVICE_ID_INTEL_APL_XHCI 0x5aa8
|
2017-05-17 23:32:00 +08:00
|
|
|
#define PCI_DEVICE_ID_INTEL_DNV_XHCI 0x19d0
|
2013-09-12 14:11:06 +08:00
|
|
|
|
2018-02-12 20:24:46 +08:00
|
|
|
#define PCI_DEVICE_ID_AMD_PROMONTORYA_4 0x43b9
|
|
|
|
#define PCI_DEVICE_ID_AMD_PROMONTORYA_3 0x43ba
|
|
|
|
#define PCI_DEVICE_ID_AMD_PROMONTORYA_2 0x43bb
|
|
|
|
#define PCI_DEVICE_ID_AMD_PROMONTORYA_1 0x43bc
|
2017-07-20 19:48:27 +08:00
|
|
|
#define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI 0x1142
|
|
|
|
|
2009-04-28 10:52:28 +08:00
|
|
|
static const char hcd_name[] = "xhci_hcd";
|
|
|
|
|
2014-10-03 16:35:26 +08:00
|
|
|
static struct hc_driver __read_mostly xhci_pci_hc_driver;
|
|
|
|
|
2015-05-29 22:01:46 +08:00
|
|
|
static int xhci_pci_setup(struct usb_hcd *hcd);
|
|
|
|
|
|
|
|
static const struct xhci_driver_overrides xhci_pci_overrides __initconst = {
|
|
|
|
.reset = xhci_pci_setup,
|
|
|
|
};
|
|
|
|
|
2009-04-28 10:52:28 +08:00
|
|
|
/* called after powerup, by probe or system-pm "wakeup" */
|
|
|
|
static int xhci_pci_reinit(struct xhci_hcd *xhci, struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* TODO: Implement finding debug ports later.
|
|
|
|
* TODO: see if there are any quirks that need to be added to handle
|
|
|
|
* new extended capabilities.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */
|
|
|
|
if (!pci_set_mwi(pdev))
|
|
|
|
xhci_dbg(xhci, "MWI active\n");
|
|
|
|
|
|
|
|
xhci_dbg(xhci, "Finished xhci_pci_reinit\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-09-24 05:20:00 +08:00
|
|
|
static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
|
|
|
|
{
|
|
|
|
struct pci_dev *pdev = to_pci_dev(dev);
|
|
|
|
|
2009-08-08 05:04:55 +08:00
|
|
|
/* Look for vendor-specific quirks */
|
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC &&
|
xhci: Extend Fresco Logic MSI quirk.
Ali reports that plugging a device into the Fresco Logic xHCI host with
PCI device ID 1400 produces an IRQ error:
do_IRQ: 3.176 No irq handler for vector (irq -1)
Other early Fresco Logic host revisions don't support MSI, even though
their PCI config space claims they do. Extend the quirk to disabling
MSI to this chipset revision. Also enable the short transfer quirk,
since it's likely this revision also has that quirk, and it should be
harmless to enable.
04:00.0 0c03: 1b73:1400 (rev 01) (prog-if 30 [XHCI])
Subsystem: 1d5c:1000
Physical Slot: 3
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 51
Region 0: Memory at d4600000 (32-bit, non-prefetchable) [size=64K]
Capabilities: [50] Power Management version 3
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold-)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [68] MSI: Enable+ Count=1/1 Maskable- 64bit+
Address: 00000000feeff00c Data: 41b1
Capabilities: [80] Express (v1) Endpoint, MSI 00
DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s <2us, L1 <32us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #0, Speed 2.5GT/s, Width x1, ASPM L0s L1, Latency L0 unlimited, L1 unlimited
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
Kernel driver in use: xhci_hcd
This patch should be backported to stable kernels as old as 2.6.36, that
contain the commit f5182b4155b9d686c5540a6822486400e34ddd98 "xhci:
Disable MSI for some Fresco Logic hosts."
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Reported-by: A Sh <smr.ash1991@gmail.com>
Tested-by: A Sh <smr.ash1991@gmail.com>
Cc: stable@vger.kernel.org
2012-10-18 04:44:06 +08:00
|
|
|
(pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK ||
|
|
|
|
pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1400)) {
|
|
|
|
if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK &&
|
|
|
|
pdev->revision == 0x0) {
|
2009-08-08 05:04:55 +08:00
|
|
|
xhci->quirks |= XHCI_RESET_EP_QUIRK;
|
2013-08-06 12:52:45 +08:00
|
|
|
xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
|
|
|
|
"QUIRK: Fresco Logic xHC needs configure"
|
|
|
|
" endpoint cmd after reset endpoint");
|
2011-06-03 02:33:02 +08:00
|
|
|
}
|
2013-09-30 21:50:54 +08:00
|
|
|
if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK &&
|
|
|
|
pdev->revision == 0x4) {
|
|
|
|
xhci->quirks |= XHCI_SLOW_SUSPEND;
|
|
|
|
xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
|
|
|
|
"QUIRK: Fresco Logic xHC revision %u"
|
|
|
|
"must be suspended extra slowly",
|
|
|
|
pdev->revision);
|
|
|
|
}
|
2014-12-05 18:11:28 +08:00
|
|
|
if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK)
|
|
|
|
xhci->quirks |= XHCI_BROKEN_STREAMS;
|
2011-06-03 02:33:02 +08:00
|
|
|
/* Fresco Logic confirms: all revisions of this chip do not
|
|
|
|
* support MSI, even though some of them claim to in their PCI
|
|
|
|
* capabilities.
|
|
|
|
*/
|
|
|
|
xhci->quirks |= XHCI_BROKEN_MSI;
|
2013-08-06 12:52:45 +08:00
|
|
|
xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
|
|
|
|
"QUIRK: Fresco Logic revision %u "
|
|
|
|
"has broken MSI implementation",
|
2011-06-03 02:33:02 +08:00
|
|
|
pdev->revision);
|
xhci: Add new short TX quirk for Fresco Logic host.
Sergio reported that when he recorded audio from a USB headset mic
plugged into the USB 3.0 port on his ASUS N53SV-DH72, the audio sounded
"robotic". When plugged into the USB 2.0 port under EHCI on the same
laptop, the audio sounded fine. The device is:
Bus 002 Device 004: ID 046d:0a0c Logitech, Inc. Clear Chat Comfort USB Headset
The problem was tracked down to the Fresco Logic xHCI host controller
not correctly reporting short transfers on isochronous IN endpoints.
The driver would submit a 96 byte transfer, the device would only send
88 or 90 bytes, and the xHCI host would report the transfer had a
"successful" completion code, with an untransferred buffer length of 8
or 6 bytes.
The successful completion code and non-zero untransferred length is a
contradiction. The xHCI host is supposed to only mark a transfer as
successful if all the bytes are transferred. Otherwise, the transfer
should be marked with a short packet completion code. Without the EHCI
bus trace, we wouldn't know whether the xHCI driver should trust the
completion code or the untransferred length. With it, we know to trust
the untransferred length.
Add a new xHCI quirk for the Fresco Logic host controller. If a
transfer is reported as successful, but the untransferred length is
non-zero, print a warning. For the Fresco Logic host, change the
completion code to COMP_SHORT_TX and process the transfer like a short
transfer.
This should be backported to stable kernels that contain the commit
f5182b4155b9d686c5540a6822486400e34ddd98 "xhci: Disable MSI for some
Fresco Logic hosts." That commit was marked for stable kernels as old
as 2.6.36.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Reported-by: Sergio Correia <lists@uece.net>
Tested-by: Sergio Correia <lists@uece.net>
Cc: stable@vger.kernel.org
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2012-05-09 00:22:49 +08:00
|
|
|
xhci->quirks |= XHCI_TRUST_TX_LENGTH;
|
2009-08-08 05:04:55 +08:00
|
|
|
}
|
2011-06-03 02:33:02 +08:00
|
|
|
|
2016-06-02 03:01:29 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC &&
|
|
|
|
pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1009)
|
|
|
|
xhci->quirks |= XHCI_BROKEN_STREAMS;
|
|
|
|
|
2010-05-25 04:25:28 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_NEC)
|
|
|
|
xhci->quirks |= XHCI_NEC_HOST;
|
2009-08-08 05:04:55 +08:00
|
|
|
|
xHCI: AMD isoc link TRB chain bit quirk
Setting the chain (CH) bit in the link TRB of isochronous transfer rings
is required by AMD 0.96 xHCI host controller to successfully transverse
multi-TRB TD that span through different memory segments.
When a Missed Service Error event occurs, if the chain bit is not set in
the link TRB and the host skips TDs which just across a link TRB, the
host may falsely recognize the link TRB as a normal TRB. You can see
this may cause big trouble - the host does not jump to the right address
which is pointed by the link TRB, but continue fetching the memory which
is after the link TRB address, which may not even belong to the host,
and the result cannot be predicted.
This causes some big problems. Without the former patch I sent: "xHCI:
prevent infinite loop when processing MSE event", the system may hang.
With that patch applied, system does not hang, but the host still access
wrong memory address and isoc transfer will fail. With this patch,
isochronous transfer works as expected.
This patch should be applied to kernels as old as 2.6.36, which was when
the first isochronous support was added for the xHCI host controller.
Signed-off-by: Andiry Xu <andiry.xu@amd.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-24 05:19:54 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_AMD && xhci->hci_version == 0x96)
|
|
|
|
xhci->quirks |= XHCI_AMD_0x96_HOST;
|
|
|
|
|
2011-03-22 17:08:14 +08:00
|
|
|
/* AMD PLL quirk */
|
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info())
|
|
|
|
xhci->quirks |= XHCI_AMD_PLL_FIX;
|
2014-08-19 20:17:57 +08:00
|
|
|
|
2018-03-08 23:17:17 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x43bb)
|
|
|
|
xhci->quirks |= XHCI_SUSPEND_DELAY;
|
|
|
|
|
2014-08-19 20:17:57 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_AMD)
|
|
|
|
xhci->quirks |= XHCI_TRUST_TX_LENGTH;
|
|
|
|
|
2018-02-12 20:24:46 +08:00
|
|
|
if ((pdev->vendor == PCI_VENDOR_ID_AMD) &&
|
|
|
|
((pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_4) ||
|
|
|
|
(pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_3) ||
|
|
|
|
(pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_2) ||
|
|
|
|
(pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_1)))
|
|
|
|
xhci->quirks |= XHCI_U2_DISABLE_WAKE;
|
|
|
|
|
2012-05-17 04:36:24 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
|
|
|
|
xhci->quirks |= XHCI_LPM_SUPPORT;
|
|
|
|
xhci->quirks |= XHCI_INTEL_HOST;
|
usb: xhci: apply XHCI_AVOID_BEI quirk to all Intel xHCI controllers
When a device with an isochronous endpoint is plugged into the Intel
xHCI host controller, and the driver submits multiple frames per URB,
the xHCI driver will set the Block Event Interrupt (BEI) flag on all
but the last TD for the URB. This causes the host controller to place
an event on the event ring, but not send an interrupt. When the last
TD for the URB completes, BEI is cleared, and we get an interrupt for
the whole URB.
However, under Intel xHCI host controllers, if the event ring is full
of events from transfers with BEI set, an "Event Ring is Full" event
will be posted to the last entry of the event ring, but no interrupt
is generated. Host will cease all transfer and command executions and
wait until software completes handling the pending events in the event
ring. That means xHC stops, but event of "event ring is full" is not
notified. As the result, the xHC looks like dead to user.
This patch is to apply XHCI_AVOID_BEI quirk to Intel xHC devices. And
it should be backported to kernels as old as 3.0, that contains the
commit 69e848c2090a ("Intel xhci: Support EHCI/xHCI port switching.").
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Tested-by: Alistair Grant <akgrant0710@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-24 00:27:42 +08:00
|
|
|
xhci->quirks |= XHCI_AVOID_BEI;
|
2012-05-17 04:36:24 +08:00
|
|
|
}
|
2011-05-26 01:43:56 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
|
|
|
|
pdev->device == PCI_DEVICE_ID_INTEL_PANTHERPOINT_XHCI) {
|
Intel xhci: Limit number of active endpoints to 64.
The Panther Point chipset has an xHCI host controller that has a limit to
the number of active endpoints it can handle. Ideally, it would signal
that it can't handle anymore endpoints by returning a Resource Error for
the Configure Endpoint command, but they don't. Instead it needs software
to keep track of the number of active endpoints, across configure endpoint
commands, reset device commands, disable slot commands, and address device
commands.
Add a new endpoint context counter, xhci_hcd->num_active_eps, and use it
to track the number of endpoints the xHC has active. This gets a little
tricky, because commands to change the number of active endpoints can
fail. This patch adds a new xHCI quirk for these Intel hosts, and the new
code should not have any effect on other xHCI host controllers.
Fail a new device allocation if we don't have room for the new default
control endpoint. Use the endpoint ring pointers to determine what
endpoints were active before a Reset Device command or a Disable Slot
command, and drop those once the command completes.
Fail a configure endpoint command if it would add too many new endpoints.
We have to be a bit over zealous here, and only count the number of new
endpoints to be added, without subtracting the number of dropped
endpoints. That's because a second configure endpoint command for a
different device could sneak in before we know if the first command is
completed. If the first command dropped resources, the host controller
fails the command for some reason, and we're nearing the limit of
endpoints, we could end up oversubscribing the host.
To fix this race condition, when evaluating whether a configure endpoint
command will fix in our bandwidth budget, only add the new endpoints to
xhci->num_active_eps, and don't subtract the dropped endpoints. Ignore
changed endpoints (ones that are dropped and then re-added), as that
shouldn't effect the host's endpoint resources. When the configure
endpoint command completes, subtract off the dropped endpoints.
This may mean some configuration changes may temporarily fail, but it's
always better to under-subscribe than over-subscribe resources.
(Originally my plan had been to push the resource allocation down into the
ring allocation functions. However, that would cause us to allocate
unnecessary resources when endpoints were changed, because the xHCI driver
allocates a new ring for the changed endpoint, and only deletes the old
ring once the Configure Endpoint command succeeds. A further complication
would have been dealing with the per-device endpoint ring cache.)
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2011-05-12 07:14:58 +08:00
|
|
|
xhci->quirks |= XHCI_EP_LIMIT_QUIRK;
|
|
|
|
xhci->limit_active_eps = 64;
|
2011-09-03 02:05:54 +08:00
|
|
|
xhci->quirks |= XHCI_SW_BW_CHECKING;
|
xhci: Switch PPT ports to EHCI on shutdown.
The Intel desktop boards DH77EB and DH77DF have a hardware issue that
can be worked around by BIOS. If the USB ports are switched to xHCI on
shutdown, the xHCI host will send a spurious interrupt, which will wake
the system. Some BIOS will work around this, but not all.
The bug can be avoided if the USB ports are switched back to EHCI on
shutdown. The Intel Windows driver switches the ports back to EHCI, so
change the Linux xHCI driver to do the same.
Unfortunately, we can't tell the two effected boards apart from other
working motherboards, because the vendors will change the DMI strings
for the DH77EB and DH77DF boards to their own custom names. One example
is Compulab's mini-desktop, the Intense-PC. Instead, key off the
Panther Point xHCI host PCI vendor and device ID, and switch the ports
over for all PPT xHCI hosts.
The only impact this will have on non-effected boards is to add a couple
hundred milliseconds delay on boot when the BIOS has to switch the ports
over from EHCI to xHCI.
This patch should be backported to kernels as old as 3.0, that contain
the commit 69e848c2090aebba5698a1620604c7dccb448684 "Intel xhci: Support
EHCI/xHCI port switching."
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Reported-by: Denis Turischev <denis@compulab.co.il>
Tested-by: Denis Turischev <denis@compulab.co.il>
Cc: stable@vger.kernel.org
2012-07-23 23:59:30 +08:00
|
|
|
/*
|
|
|
|
* PPT desktop boards DH77EB and DH77DF will power back on after
|
|
|
|
* a few seconds of being shutdown. The fix for this is to
|
|
|
|
* switch the ports from xHCI to EHCI on shutdown. We can't use
|
|
|
|
* DMI information to find those particular boards (since each
|
|
|
|
* vendor will change the board name), so we have to key off all
|
|
|
|
* PPT chipsets.
|
|
|
|
*/
|
|
|
|
xhci->quirks |= XHCI_SPURIOUS_REBOOT;
|
2011-05-26 01:43:56 +08:00
|
|
|
}
|
2014-05-20 19:00:42 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
|
2016-10-20 23:09:18 +08:00
|
|
|
(pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI ||
|
|
|
|
pdev->device == PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI)) {
|
2014-04-26 00:20:14 +08:00
|
|
|
xhci->quirks |= XHCI_SPURIOUS_REBOOT;
|
2015-10-12 16:30:13 +08:00
|
|
|
xhci->quirks |= XHCI_SPURIOUS_WAKEUP;
|
2013-09-12 14:11:06 +08:00
|
|
|
}
|
2015-03-06 23:23:19 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
|
|
|
|
(pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI ||
|
|
|
|
pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI ||
|
2016-01-26 23:50:08 +08:00
|
|
|
pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
|
2016-04-08 21:25:05 +08:00
|
|
|
pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI ||
|
2017-01-04 00:28:52 +08:00
|
|
|
pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI ||
|
2017-05-17 23:32:00 +08:00
|
|
|
pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI ||
|
|
|
|
pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI)) {
|
2015-03-06 23:23:19 +08:00
|
|
|
xhci->quirks |= XHCI_PME_STUCK_QUIRK;
|
|
|
|
}
|
2016-01-26 23:50:06 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
|
|
|
|
pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI) {
|
|
|
|
xhci->quirks |= XHCI_SSIC_PORT_UNUSED;
|
|
|
|
}
|
2016-10-20 23:09:19 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
|
|
|
|
(pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
|
2017-05-17 23:32:00 +08:00
|
|
|
pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI ||
|
|
|
|
pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI))
|
2016-10-20 23:09:19 +08:00
|
|
|
xhci->quirks |= XHCI_MISSING_CAS;
|
|
|
|
|
2011-06-16 05:47:21 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
|
2014-07-26 04:01:19 +08:00
|
|
|
pdev->device == PCI_DEVICE_ID_EJ168) {
|
2011-06-16 05:47:21 +08:00
|
|
|
xhci->quirks |= XHCI_RESET_ON_RESUME;
|
2012-07-03 04:36:23 +08:00
|
|
|
xhci->quirks |= XHCI_TRUST_TX_LENGTH;
|
2014-07-26 04:01:18 +08:00
|
|
|
xhci->quirks |= XHCI_BROKEN_STREAMS;
|
2011-06-16 05:47:21 +08:00
|
|
|
}
|
2017-12-21 21:06:15 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_RENESAS &&
|
|
|
|
pdev->device == 0x0014)
|
|
|
|
xhci->quirks |= XHCI_TRUST_TX_LENGTH;
|
2014-01-18 07:38:12 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_RENESAS &&
|
2014-04-26 00:20:15 +08:00
|
|
|
pdev->device == 0x0015)
|
2014-01-18 07:38:12 +08:00
|
|
|
xhci->quirks |= XHCI_RESET_ON_RESUME;
|
2012-03-29 15:47:50 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_VIA)
|
|
|
|
xhci->quirks |= XHCI_RESET_ON_RESUME;
|
2014-05-14 20:00:23 +08:00
|
|
|
|
2014-08-25 18:21:56 +08:00
|
|
|
/* See https://bugzilla.kernel.org/show_bug.cgi?id=79511 */
|
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_VIA &&
|
|
|
|
pdev->device == 0x3432)
|
|
|
|
xhci->quirks |= XHCI_BROKEN_STREAMS;
|
|
|
|
|
2014-10-28 18:05:29 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
|
|
|
|
pdev->device == 0x1042)
|
|
|
|
xhci->quirks |= XHCI_BROKEN_STREAMS;
|
2017-06-09 19:48:41 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
|
|
|
|
pdev->device == 0x1142)
|
|
|
|
xhci->quirks |= XHCI_TRUST_TX_LENGTH;
|
2014-10-28 18:05:29 +08:00
|
|
|
|
2017-07-20 19:48:27 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
|
|
|
|
pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI)
|
|
|
|
xhci->quirks |= XHCI_ASMEDIA_MODIFY_FLOWCONTROL;
|
|
|
|
|
2017-04-07 22:57:12 +08:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_TI && pdev->device == 0x8241)
|
|
|
|
xhci->quirks |= XHCI_LIMIT_ENDPOINT_INTERVAL_7;
|
|
|
|
|
2014-05-14 20:00:23 +08:00
|
|
|
if (xhci->quirks & XHCI_RESET_ON_RESUME)
|
|
|
|
xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
|
|
|
|
"QUIRK: Resetting on resume");
|
2011-09-24 05:20:00 +08:00
|
|
|
}
|
2011-03-22 17:08:14 +08:00
|
|
|
|
2015-07-21 22:20:25 +08:00
|
|
|
#ifdef CONFIG_ACPI
|
|
|
|
static void xhci_pme_acpi_rtd3_enable(struct pci_dev *dev)
|
|
|
|
{
|
2017-06-06 00:40:46 +08:00
|
|
|
static const guid_t intel_dsm_guid =
|
|
|
|
GUID_INIT(0xac340cb7, 0xe901, 0x45bf,
|
|
|
|
0xb7, 0xe6, 0x2b, 0x34, 0xec, 0x93, 0x1e, 0x23);
|
2015-12-04 21:53:42 +08:00
|
|
|
union acpi_object *obj;
|
|
|
|
|
2017-06-06 00:40:46 +08:00
|
|
|
obj = acpi_evaluate_dsm(ACPI_HANDLE(&dev->dev), &intel_dsm_guid, 3, 1,
|
2015-12-04 21:53:42 +08:00
|
|
|
NULL);
|
|
|
|
ACPI_FREE(obj);
|
2015-07-21 22:20:25 +08:00
|
|
|
}
|
|
|
|
#else
|
2015-12-04 21:53:42 +08:00
|
|
|
static void xhci_pme_acpi_rtd3_enable(struct pci_dev *dev) { }
|
2015-07-21 22:20:25 +08:00
|
|
|
#endif /* CONFIG_ACPI */
|
|
|
|
|
2011-09-24 05:20:00 +08:00
|
|
|
/* called during probe() after chip reset completes */
|
|
|
|
static int xhci_pci_setup(struct usb_hcd *hcd)
|
|
|
|
{
|
|
|
|
struct xhci_hcd *xhci;
|
|
|
|
struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
|
|
|
|
int retval;
|
2009-04-28 10:52:28 +08:00
|
|
|
|
2015-10-01 23:40:38 +08:00
|
|
|
xhci = hcd_to_xhci(hcd);
|
|
|
|
if (!xhci->sbrn)
|
|
|
|
pci_read_config_byte(pdev, XHCI_SBRN_OFFSET, &xhci->sbrn);
|
|
|
|
|
2017-12-08 23:59:13 +08:00
|
|
|
/* imod_interval is the interrupt moderation value in nanoseconds. */
|
|
|
|
xhci->imod_interval = 40000;
|
|
|
|
|
2011-09-24 05:20:00 +08:00
|
|
|
retval = xhci_gen_setup(hcd, xhci_pci_quirks);
|
2009-04-28 10:52:28 +08:00
|
|
|
if (retval)
|
2011-09-24 05:20:00 +08:00
|
|
|
return retval;
|
2010-07-30 13:13:22 +08:00
|
|
|
|
2011-09-24 05:20:00 +08:00
|
|
|
if (!usb_hcd_is_primary_hcd(hcd))
|
|
|
|
return 0;
|
2009-04-28 10:52:28 +08:00
|
|
|
|
|
|
|
xhci_dbg(xhci, "Got SBRN %u\n", (unsigned int) xhci->sbrn);
|
|
|
|
|
|
|
|
/* Find any debug ports */
|
2017-01-23 20:20:03 +08:00
|
|
|
return xhci_pci_reinit(xhci, pdev);
|
2010-10-27 02:03:44 +08:00
|
|
|
}
|
|
|
|
|
xhci: Register second xHCI roothub.
This patch changes the xHCI driver to allocate two roothubs. This touches
the driver initialization and shutdown paths, roothub emulation code, and
port status change event handlers. This is a rather large patch, but it
can't be broken up, or it would break git-bisect.
Make the xHCI driver register its own PCI probe function. This will call
the USB core to create the USB 2.0 roothub, and then create the USB 3.0
roothub. This gets the code for registering a shared roothub out of the
USB core, and allows other HCDs later to decide if and how many shared
roothubs they want to allocate.
Make sure the xHCI's reset method marks the xHCI host controller's primary
roothub as the USB 2.0 roothub. This ensures that the high speed bus will
be processed first when the PCI device is resumed, and any USB 3.0 devices
that have migrated over to high speed will migrate back after being reset.
This ensures that USB persist works with these odd devices.
The reset method will also mark the xHCI USB2 roothub as having an
integrated TT. Like EHCI host controllers with a "rate matching hub" the
xHCI USB 2.0 roothub doesn't have an OHCI or UHCI companion controller.
It doesn't really have a TT, but we'll lie and say it has an integrated
TT. We need to do this because the USB core will reject LS/FS devices
under a HS hub without a TT.
Other details:
-------------
The roothub emulation code is changed to return the correct number of
ports for the two roothubs. For the USB 3.0 roothub, it only reports the
USB 3.0 ports. For the USB 2.0 roothub, it reports all the LS/FS/HS
ports. The code to disable a port now checks the speed of the roothub,
and refuses to disable SuperSpeed ports under the USB 3.0 roothub.
The code for initializing a new device context must be changed to set the
proper roothub port number. Since we've split the xHCI host into two
roothubs, we can't just use the port number in the ancestor hub. Instead,
we loop through the array of hardware port status register speeds and find
the Nth port with a similar speed.
The port status change event handler is updated to figure out whether the
port that reported the change is a USB 3.0 port, or a non-SuperSpeed port.
Once it figures out the port speed, it kicks the proper roothub.
The function to find a slot ID based on the port index is updated to take
into account that the two roothubs will have over-lapping port indexes.
It checks that the virtual device with a matching port index is the same
speed as the passed in roothub.
There's also changes to the driver initialization and shutdown paths:
1. Make sure that the xhci_hcd pointer is shared across the two
usb_hcd structures. The xhci_hcd pointer is allocated and the
registers are mapped in when xhci_pci_setup() is called with the
primary HCD. When xhci_pci_setup() is called with the non-primary
HCD, the xhci_hcd pointer is stored.
2. Make sure to set the sg_tablesize for both usb_hcd structures. Set
the PCI DMA mask for the non-primary HCD to allow for 64-bit or 32-bit
DMA. (The PCI DMA mask is set from the primary HCD further down in
the xhci_pci_setup() function.)
3. Ensure that the host controller doesn't start kicking khubd in
response to port status changes before both usb_hcd structures are
registered. xhci_run() only starts the xHC running once it has been
called with the non-primary roothub. Similarly, the xhci_stop()
function only halts the host controller when it is called with the
non-primary HCD. Then on the second call, it resets and cleans up the
MSI-X irqs.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2010-12-17 03:21:10 +08:00
|
|
|
/*
|
|
|
|
* We need to register our own PCI probe function (instead of the USB core's
|
|
|
|
* function) in order to create a second roothub under xHCI.
|
|
|
|
*/
|
|
|
|
static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
struct xhci_hcd *xhci;
|
|
|
|
struct hc_driver *driver;
|
|
|
|
struct usb_hcd *hcd;
|
|
|
|
|
|
|
|
driver = (struct hc_driver *)id->driver_data;
|
2014-03-04 01:30:17 +08:00
|
|
|
|
2017-08-02 09:11:08 +08:00
|
|
|
/* For some HW implementation, a XHCI reset is just not enough... */
|
|
|
|
if (usb_xhci_needs_pci_reset(dev)) {
|
|
|
|
dev_info(&dev->dev, "Resetting\n");
|
|
|
|
if (pci_reset_function_locked(dev))
|
|
|
|
dev_warn(&dev->dev, "Reset failed");
|
|
|
|
}
|
|
|
|
|
2014-03-04 01:30:17 +08:00
|
|
|
/* Prevent runtime suspending between USB-2 and USB-3 initialization */
|
|
|
|
pm_runtime_get_noresume(&dev->dev);
|
|
|
|
|
xhci: Register second xHCI roothub.
This patch changes the xHCI driver to allocate two roothubs. This touches
the driver initialization and shutdown paths, roothub emulation code, and
port status change event handlers. This is a rather large patch, but it
can't be broken up, or it would break git-bisect.
Make the xHCI driver register its own PCI probe function. This will call
the USB core to create the USB 2.0 roothub, and then create the USB 3.0
roothub. This gets the code for registering a shared roothub out of the
USB core, and allows other HCDs later to decide if and how many shared
roothubs they want to allocate.
Make sure the xHCI's reset method marks the xHCI host controller's primary
roothub as the USB 2.0 roothub. This ensures that the high speed bus will
be processed first when the PCI device is resumed, and any USB 3.0 devices
that have migrated over to high speed will migrate back after being reset.
This ensures that USB persist works with these odd devices.
The reset method will also mark the xHCI USB2 roothub as having an
integrated TT. Like EHCI host controllers with a "rate matching hub" the
xHCI USB 2.0 roothub doesn't have an OHCI or UHCI companion controller.
It doesn't really have a TT, but we'll lie and say it has an integrated
TT. We need to do this because the USB core will reject LS/FS devices
under a HS hub without a TT.
Other details:
-------------
The roothub emulation code is changed to return the correct number of
ports for the two roothubs. For the USB 3.0 roothub, it only reports the
USB 3.0 ports. For the USB 2.0 roothub, it reports all the LS/FS/HS
ports. The code to disable a port now checks the speed of the roothub,
and refuses to disable SuperSpeed ports under the USB 3.0 roothub.
The code for initializing a new device context must be changed to set the
proper roothub port number. Since we've split the xHCI host into two
roothubs, we can't just use the port number in the ancestor hub. Instead,
we loop through the array of hardware port status register speeds and find
the Nth port with a similar speed.
The port status change event handler is updated to figure out whether the
port that reported the change is a USB 3.0 port, or a non-SuperSpeed port.
Once it figures out the port speed, it kicks the proper roothub.
The function to find a slot ID based on the port index is updated to take
into account that the two roothubs will have over-lapping port indexes.
It checks that the virtual device with a matching port index is the same
speed as the passed in roothub.
There's also changes to the driver initialization and shutdown paths:
1. Make sure that the xhci_hcd pointer is shared across the two
usb_hcd structures. The xhci_hcd pointer is allocated and the
registers are mapped in when xhci_pci_setup() is called with the
primary HCD. When xhci_pci_setup() is called with the non-primary
HCD, the xhci_hcd pointer is stored.
2. Make sure to set the sg_tablesize for both usb_hcd structures. Set
the PCI DMA mask for the non-primary HCD to allow for 64-bit or 32-bit
DMA. (The PCI DMA mask is set from the primary HCD further down in
the xhci_pci_setup() function.)
3. Ensure that the host controller doesn't start kicking khubd in
response to port status changes before both usb_hcd structures are
registered. xhci_run() only starts the xHC running once it has been
called with the non-primary roothub. Similarly, the xhci_stop()
function only halts the host controller when it is called with the
non-primary HCD. Then on the second call, it resets and cleans up the
MSI-X irqs.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2010-12-17 03:21:10 +08:00
|
|
|
/* Register the USB 2.0 roothub.
|
|
|
|
* FIXME: USB core must know to register the USB 2.0 roothub first.
|
|
|
|
* This is sort of silly, because we could just set the HCD driver flags
|
|
|
|
* to say USB 2.0, but I'm not sure what the implications would be in
|
|
|
|
* the other parts of the HCD code.
|
|
|
|
*/
|
|
|
|
retval = usb_hcd_pci_probe(dev, id);
|
|
|
|
|
|
|
|
if (retval)
|
2014-03-04 01:30:17 +08:00
|
|
|
goto put_runtime_pm;
|
xhci: Register second xHCI roothub.
This patch changes the xHCI driver to allocate two roothubs. This touches
the driver initialization and shutdown paths, roothub emulation code, and
port status change event handlers. This is a rather large patch, but it
can't be broken up, or it would break git-bisect.
Make the xHCI driver register its own PCI probe function. This will call
the USB core to create the USB 2.0 roothub, and then create the USB 3.0
roothub. This gets the code for registering a shared roothub out of the
USB core, and allows other HCDs later to decide if and how many shared
roothubs they want to allocate.
Make sure the xHCI's reset method marks the xHCI host controller's primary
roothub as the USB 2.0 roothub. This ensures that the high speed bus will
be processed first when the PCI device is resumed, and any USB 3.0 devices
that have migrated over to high speed will migrate back after being reset.
This ensures that USB persist works with these odd devices.
The reset method will also mark the xHCI USB2 roothub as having an
integrated TT. Like EHCI host controllers with a "rate matching hub" the
xHCI USB 2.0 roothub doesn't have an OHCI or UHCI companion controller.
It doesn't really have a TT, but we'll lie and say it has an integrated
TT. We need to do this because the USB core will reject LS/FS devices
under a HS hub without a TT.
Other details:
-------------
The roothub emulation code is changed to return the correct number of
ports for the two roothubs. For the USB 3.0 roothub, it only reports the
USB 3.0 ports. For the USB 2.0 roothub, it reports all the LS/FS/HS
ports. The code to disable a port now checks the speed of the roothub,
and refuses to disable SuperSpeed ports under the USB 3.0 roothub.
The code for initializing a new device context must be changed to set the
proper roothub port number. Since we've split the xHCI host into two
roothubs, we can't just use the port number in the ancestor hub. Instead,
we loop through the array of hardware port status register speeds and find
the Nth port with a similar speed.
The port status change event handler is updated to figure out whether the
port that reported the change is a USB 3.0 port, or a non-SuperSpeed port.
Once it figures out the port speed, it kicks the proper roothub.
The function to find a slot ID based on the port index is updated to take
into account that the two roothubs will have over-lapping port indexes.
It checks that the virtual device with a matching port index is the same
speed as the passed in roothub.
There's also changes to the driver initialization and shutdown paths:
1. Make sure that the xhci_hcd pointer is shared across the two
usb_hcd structures. The xhci_hcd pointer is allocated and the
registers are mapped in when xhci_pci_setup() is called with the
primary HCD. When xhci_pci_setup() is called with the non-primary
HCD, the xhci_hcd pointer is stored.
2. Make sure to set the sg_tablesize for both usb_hcd structures. Set
the PCI DMA mask for the non-primary HCD to allow for 64-bit or 32-bit
DMA. (The PCI DMA mask is set from the primary HCD further down in
the xhci_pci_setup() function.)
3. Ensure that the host controller doesn't start kicking khubd in
response to port status changes before both usb_hcd structures are
registered. xhci_run() only starts the xHC running once it has been
called with the non-primary roothub. Similarly, the xhci_stop()
function only halts the host controller when it is called with the
non-primary HCD. Then on the second call, it resets and cleans up the
MSI-X irqs.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2010-12-17 03:21:10 +08:00
|
|
|
|
|
|
|
/* USB 2.0 roothub is stored in the PCI device now. */
|
|
|
|
hcd = dev_get_drvdata(&dev->dev);
|
|
|
|
xhci = hcd_to_xhci(hcd);
|
|
|
|
xhci->shared_hcd = usb_create_shared_hcd(driver, &dev->dev,
|
|
|
|
pci_name(dev), hcd);
|
|
|
|
if (!xhci->shared_hcd) {
|
|
|
|
retval = -ENOMEM;
|
|
|
|
goto dealloc_usb2_hcd;
|
|
|
|
}
|
|
|
|
|
|
|
|
retval = usb_add_hcd(xhci->shared_hcd, dev->irq,
|
2011-09-07 16:10:52 +08:00
|
|
|
IRQF_SHARED);
|
xhci: Register second xHCI roothub.
This patch changes the xHCI driver to allocate two roothubs. This touches
the driver initialization and shutdown paths, roothub emulation code, and
port status change event handlers. This is a rather large patch, but it
can't be broken up, or it would break git-bisect.
Make the xHCI driver register its own PCI probe function. This will call
the USB core to create the USB 2.0 roothub, and then create the USB 3.0
roothub. This gets the code for registering a shared roothub out of the
USB core, and allows other HCDs later to decide if and how many shared
roothubs they want to allocate.
Make sure the xHCI's reset method marks the xHCI host controller's primary
roothub as the USB 2.0 roothub. This ensures that the high speed bus will
be processed first when the PCI device is resumed, and any USB 3.0 devices
that have migrated over to high speed will migrate back after being reset.
This ensures that USB persist works with these odd devices.
The reset method will also mark the xHCI USB2 roothub as having an
integrated TT. Like EHCI host controllers with a "rate matching hub" the
xHCI USB 2.0 roothub doesn't have an OHCI or UHCI companion controller.
It doesn't really have a TT, but we'll lie and say it has an integrated
TT. We need to do this because the USB core will reject LS/FS devices
under a HS hub without a TT.
Other details:
-------------
The roothub emulation code is changed to return the correct number of
ports for the two roothubs. For the USB 3.0 roothub, it only reports the
USB 3.0 ports. For the USB 2.0 roothub, it reports all the LS/FS/HS
ports. The code to disable a port now checks the speed of the roothub,
and refuses to disable SuperSpeed ports under the USB 3.0 roothub.
The code for initializing a new device context must be changed to set the
proper roothub port number. Since we've split the xHCI host into two
roothubs, we can't just use the port number in the ancestor hub. Instead,
we loop through the array of hardware port status register speeds and find
the Nth port with a similar speed.
The port status change event handler is updated to figure out whether the
port that reported the change is a USB 3.0 port, or a non-SuperSpeed port.
Once it figures out the port speed, it kicks the proper roothub.
The function to find a slot ID based on the port index is updated to take
into account that the two roothubs will have over-lapping port indexes.
It checks that the virtual device with a matching port index is the same
speed as the passed in roothub.
There's also changes to the driver initialization and shutdown paths:
1. Make sure that the xhci_hcd pointer is shared across the two
usb_hcd structures. The xhci_hcd pointer is allocated and the
registers are mapped in when xhci_pci_setup() is called with the
primary HCD. When xhci_pci_setup() is called with the non-primary
HCD, the xhci_hcd pointer is stored.
2. Make sure to set the sg_tablesize for both usb_hcd structures. Set
the PCI DMA mask for the non-primary HCD to allow for 64-bit or 32-bit
DMA. (The PCI DMA mask is set from the primary HCD further down in
the xhci_pci_setup() function.)
3. Ensure that the host controller doesn't start kicking khubd in
response to port status changes before both usb_hcd structures are
registered. xhci_run() only starts the xHC running once it has been
called with the non-primary roothub. Similarly, the xhci_stop()
function only halts the host controller when it is called with the
non-primary HCD. Then on the second call, it resets and cleans up the
MSI-X irqs.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2010-12-17 03:21:10 +08:00
|
|
|
if (retval)
|
|
|
|
goto put_usb3_hcd;
|
|
|
|
/* Roothub already marked as USB 3.0 speed */
|
xhci: Add infrastructure for host-specific LPM policies.
The choice of U1 and U2 timeouts for USB 3.0 Link Power Management (LPM)
is highly host controller specific. Here are a few examples of why it's
host specific:
1. Setting the U1/U2 timeout too short may cause the link to go into
U1/U2 in between service intervals, which some hosts may tolerate,
and some may not.
2. The host controller has to modify its bus schedule in order to take
into account the Maximum Exit Latency (MEL) to bring all the links
from the host to the device into U0. If the MEL is too big, and it
takes too long to bring the links into an active state, the host
controller may not be able to service periodic endpoints in time.
3. Host controllers may also have scheduling limitations that force
them to disable U1 or U2 if a USB device is behind too many tiers of
hubs.
We could take an educated guess at what U1/U2 timeouts may work for a
particular host controller. However, that would result in a binary
search on every new configuration or alt setting installation, with
multiple failed Evaluate Context commands. Worse, the host may blindly
accept the timeouts and just fail to update its schedule for U1/U2 exit
latencies, which could result in randomly delayed periodic transfers.
Since we don't want to cause jitter in periodic transfers, or delay
config/alt setting changes too much, lay down a framework that xHCI
vendors can extend in order to add their own U1/U2 timeout policies.
To extend the framework, they will need to:
- Modify the PCI init code to add a new xhci->quirk for their host, and
set the XHCI_LPM_SUPPORT quirk flag.
- Add their own vendor-specific hooks, like the ones that will be added
in xhci_call_host_update_timeout_for_endpoint() and
xhci_check_tier_policy()
- Make the LPM enable/disable methods call those functions based on the
xhci->quirk for their host.
An example will be provided for the Intel xHCI host controller in the
next patch.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2012-05-10 01:55:03 +08:00
|
|
|
|
2014-07-26 04:01:18 +08:00
|
|
|
if (!(xhci->quirks & XHCI_BROKEN_STREAMS) &&
|
|
|
|
HCC_MAX_PSA(xhci->hcc_params) >= 4)
|
2014-02-12 03:36:04 +08:00
|
|
|
xhci->shared_hcd->can_do_streams = 1;
|
|
|
|
|
2015-07-21 22:20:25 +08:00
|
|
|
if (xhci->quirks & XHCI_PME_STUCK_QUIRK)
|
|
|
|
xhci_pme_acpi_rtd3_enable(dev);
|
|
|
|
|
2014-03-04 01:30:17 +08:00
|
|
|
/* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */
|
|
|
|
pm_runtime_put_noidle(&dev->dev);
|
|
|
|
|
xhci: Register second xHCI roothub.
This patch changes the xHCI driver to allocate two roothubs. This touches
the driver initialization and shutdown paths, roothub emulation code, and
port status change event handlers. This is a rather large patch, but it
can't be broken up, or it would break git-bisect.
Make the xHCI driver register its own PCI probe function. This will call
the USB core to create the USB 2.0 roothub, and then create the USB 3.0
roothub. This gets the code for registering a shared roothub out of the
USB core, and allows other HCDs later to decide if and how many shared
roothubs they want to allocate.
Make sure the xHCI's reset method marks the xHCI host controller's primary
roothub as the USB 2.0 roothub. This ensures that the high speed bus will
be processed first when the PCI device is resumed, and any USB 3.0 devices
that have migrated over to high speed will migrate back after being reset.
This ensures that USB persist works with these odd devices.
The reset method will also mark the xHCI USB2 roothub as having an
integrated TT. Like EHCI host controllers with a "rate matching hub" the
xHCI USB 2.0 roothub doesn't have an OHCI or UHCI companion controller.
It doesn't really have a TT, but we'll lie and say it has an integrated
TT. We need to do this because the USB core will reject LS/FS devices
under a HS hub without a TT.
Other details:
-------------
The roothub emulation code is changed to return the correct number of
ports for the two roothubs. For the USB 3.0 roothub, it only reports the
USB 3.0 ports. For the USB 2.0 roothub, it reports all the LS/FS/HS
ports. The code to disable a port now checks the speed of the roothub,
and refuses to disable SuperSpeed ports under the USB 3.0 roothub.
The code for initializing a new device context must be changed to set the
proper roothub port number. Since we've split the xHCI host into two
roothubs, we can't just use the port number in the ancestor hub. Instead,
we loop through the array of hardware port status register speeds and find
the Nth port with a similar speed.
The port status change event handler is updated to figure out whether the
port that reported the change is a USB 3.0 port, or a non-SuperSpeed port.
Once it figures out the port speed, it kicks the proper roothub.
The function to find a slot ID based on the port index is updated to take
into account that the two roothubs will have over-lapping port indexes.
It checks that the virtual device with a matching port index is the same
speed as the passed in roothub.
There's also changes to the driver initialization and shutdown paths:
1. Make sure that the xhci_hcd pointer is shared across the two
usb_hcd structures. The xhci_hcd pointer is allocated and the
registers are mapped in when xhci_pci_setup() is called with the
primary HCD. When xhci_pci_setup() is called with the non-primary
HCD, the xhci_hcd pointer is stored.
2. Make sure to set the sg_tablesize for both usb_hcd structures. Set
the PCI DMA mask for the non-primary HCD to allow for 64-bit or 32-bit
DMA. (The PCI DMA mask is set from the primary HCD further down in
the xhci_pci_setup() function.)
3. Ensure that the host controller doesn't start kicking khubd in
response to port status changes before both usb_hcd structures are
registered. xhci_run() only starts the xHC running once it has been
called with the non-primary roothub. Similarly, the xhci_stop()
function only halts the host controller when it is called with the
non-primary HCD. Then on the second call, it resets and cleans up the
MSI-X irqs.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2010-12-17 03:21:10 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
put_usb3_hcd:
|
|
|
|
usb_put_hcd(xhci->shared_hcd);
|
|
|
|
dealloc_usb2_hcd:
|
|
|
|
usb_hcd_pci_remove(dev);
|
2014-03-04 01:30:17 +08:00
|
|
|
put_runtime_pm:
|
|
|
|
pm_runtime_put_noidle(&dev->dev);
|
xhci: Register second xHCI roothub.
This patch changes the xHCI driver to allocate two roothubs. This touches
the driver initialization and shutdown paths, roothub emulation code, and
port status change event handlers. This is a rather large patch, but it
can't be broken up, or it would break git-bisect.
Make the xHCI driver register its own PCI probe function. This will call
the USB core to create the USB 2.0 roothub, and then create the USB 3.0
roothub. This gets the code for registering a shared roothub out of the
USB core, and allows other HCDs later to decide if and how many shared
roothubs they want to allocate.
Make sure the xHCI's reset method marks the xHCI host controller's primary
roothub as the USB 2.0 roothub. This ensures that the high speed bus will
be processed first when the PCI device is resumed, and any USB 3.0 devices
that have migrated over to high speed will migrate back after being reset.
This ensures that USB persist works with these odd devices.
The reset method will also mark the xHCI USB2 roothub as having an
integrated TT. Like EHCI host controllers with a "rate matching hub" the
xHCI USB 2.0 roothub doesn't have an OHCI or UHCI companion controller.
It doesn't really have a TT, but we'll lie and say it has an integrated
TT. We need to do this because the USB core will reject LS/FS devices
under a HS hub without a TT.
Other details:
-------------
The roothub emulation code is changed to return the correct number of
ports for the two roothubs. For the USB 3.0 roothub, it only reports the
USB 3.0 ports. For the USB 2.0 roothub, it reports all the LS/FS/HS
ports. The code to disable a port now checks the speed of the roothub,
and refuses to disable SuperSpeed ports under the USB 3.0 roothub.
The code for initializing a new device context must be changed to set the
proper roothub port number. Since we've split the xHCI host into two
roothubs, we can't just use the port number in the ancestor hub. Instead,
we loop through the array of hardware port status register speeds and find
the Nth port with a similar speed.
The port status change event handler is updated to figure out whether the
port that reported the change is a USB 3.0 port, or a non-SuperSpeed port.
Once it figures out the port speed, it kicks the proper roothub.
The function to find a slot ID based on the port index is updated to take
into account that the two roothubs will have over-lapping port indexes.
It checks that the virtual device with a matching port index is the same
speed as the passed in roothub.
There's also changes to the driver initialization and shutdown paths:
1. Make sure that the xhci_hcd pointer is shared across the two
usb_hcd structures. The xhci_hcd pointer is allocated and the
registers are mapped in when xhci_pci_setup() is called with the
primary HCD. When xhci_pci_setup() is called with the non-primary
HCD, the xhci_hcd pointer is stored.
2. Make sure to set the sg_tablesize for both usb_hcd structures. Set
the PCI DMA mask for the non-primary HCD to allow for 64-bit or 32-bit
DMA. (The PCI DMA mask is set from the primary HCD further down in
the xhci_pci_setup() function.)
3. Ensure that the host controller doesn't start kicking khubd in
response to port status changes before both usb_hcd structures are
registered. xhci_run() only starts the xHC running once it has been
called with the non-primary roothub. Similarly, the xhci_stop()
function only halts the host controller when it is called with the
non-primary HCD. Then on the second call, it resets and cleans up the
MSI-X irqs.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2010-12-17 03:21:10 +08:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-10-27 02:03:44 +08:00
|
|
|
static void xhci_pci_remove(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
struct xhci_hcd *xhci;
|
|
|
|
|
|
|
|
xhci = hcd_to_xhci(pci_get_drvdata(dev));
|
2016-04-08 21:25:10 +08:00
|
|
|
xhci->xhc_state |= XHCI_STATE_REMOVING;
|
xhci: Register second xHCI roothub.
This patch changes the xHCI driver to allocate two roothubs. This touches
the driver initialization and shutdown paths, roothub emulation code, and
port status change event handlers. This is a rather large patch, but it
can't be broken up, or it would break git-bisect.
Make the xHCI driver register its own PCI probe function. This will call
the USB core to create the USB 2.0 roothub, and then create the USB 3.0
roothub. This gets the code for registering a shared roothub out of the
USB core, and allows other HCDs later to decide if and how many shared
roothubs they want to allocate.
Make sure the xHCI's reset method marks the xHCI host controller's primary
roothub as the USB 2.0 roothub. This ensures that the high speed bus will
be processed first when the PCI device is resumed, and any USB 3.0 devices
that have migrated over to high speed will migrate back after being reset.
This ensures that USB persist works with these odd devices.
The reset method will also mark the xHCI USB2 roothub as having an
integrated TT. Like EHCI host controllers with a "rate matching hub" the
xHCI USB 2.0 roothub doesn't have an OHCI or UHCI companion controller.
It doesn't really have a TT, but we'll lie and say it has an integrated
TT. We need to do this because the USB core will reject LS/FS devices
under a HS hub without a TT.
Other details:
-------------
The roothub emulation code is changed to return the correct number of
ports for the two roothubs. For the USB 3.0 roothub, it only reports the
USB 3.0 ports. For the USB 2.0 roothub, it reports all the LS/FS/HS
ports. The code to disable a port now checks the speed of the roothub,
and refuses to disable SuperSpeed ports under the USB 3.0 roothub.
The code for initializing a new device context must be changed to set the
proper roothub port number. Since we've split the xHCI host into two
roothubs, we can't just use the port number in the ancestor hub. Instead,
we loop through the array of hardware port status register speeds and find
the Nth port with a similar speed.
The port status change event handler is updated to figure out whether the
port that reported the change is a USB 3.0 port, or a non-SuperSpeed port.
Once it figures out the port speed, it kicks the proper roothub.
The function to find a slot ID based on the port index is updated to take
into account that the two roothubs will have over-lapping port indexes.
It checks that the virtual device with a matching port index is the same
speed as the passed in roothub.
There's also changes to the driver initialization and shutdown paths:
1. Make sure that the xhci_hcd pointer is shared across the two
usb_hcd structures. The xhci_hcd pointer is allocated and the
registers are mapped in when xhci_pci_setup() is called with the
primary HCD. When xhci_pci_setup() is called with the non-primary
HCD, the xhci_hcd pointer is stored.
2. Make sure to set the sg_tablesize for both usb_hcd structures. Set
the PCI DMA mask for the non-primary HCD to allow for 64-bit or 32-bit
DMA. (The PCI DMA mask is set from the primary HCD further down in
the xhci_pci_setup() function.)
3. Ensure that the host controller doesn't start kicking khubd in
response to port status changes before both usb_hcd structures are
registered. xhci_run() only starts the xHC running once it has been
called with the non-primary roothub. Similarly, the xhci_stop()
function only halts the host controller when it is called with the
non-primary HCD. Then on the second call, it resets and cleans up the
MSI-X irqs.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2010-12-17 03:21:10 +08:00
|
|
|
if (xhci->shared_hcd) {
|
|
|
|
usb_remove_hcd(xhci->shared_hcd);
|
|
|
|
usb_put_hcd(xhci->shared_hcd);
|
|
|
|
}
|
2013-09-12 14:11:06 +08:00
|
|
|
|
|
|
|
/* Workaround for spurious wakeups at shutdown with HSW */
|
|
|
|
if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
|
|
|
|
pci_set_power_state(dev, PCI_D3hot);
|
2016-08-16 15:18:06 +08:00
|
|
|
|
|
|
|
usb_hcd_pci_remove(dev);
|
2009-04-28 10:52:28 +08:00
|
|
|
}
|
|
|
|
|
2010-10-14 22:23:06 +08:00
|
|
|
#ifdef CONFIG_PM
|
2015-09-21 22:46:11 +08:00
|
|
|
/*
|
|
|
|
* In some Intel xHCI controllers, in order to get D3 working,
|
|
|
|
* through a vendor specific SSIC CONFIG register at offset 0x883c,
|
|
|
|
* SSIC PORT need to be marked as "unused" before putting xHCI
|
|
|
|
* into D3. After D3 exit, the SSIC port need to be marked as "used".
|
|
|
|
* Without this change, xHCI might not enter D3 state.
|
|
|
|
*/
|
2016-01-26 23:50:06 +08:00
|
|
|
static void xhci_ssic_port_unused_quirk(struct usb_hcd *hcd, bool suspend)
|
2015-09-21 22:46:11 +08:00
|
|
|
{
|
|
|
|
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
|
|
|
|
u32 val;
|
|
|
|
void __iomem *reg;
|
2016-01-26 23:50:05 +08:00
|
|
|
int i;
|
2015-09-21 22:46:11 +08:00
|
|
|
|
2016-01-26 23:50:06 +08:00
|
|
|
for (i = 0; i < SSIC_PORT_NUM; i++) {
|
|
|
|
reg = (void __iomem *) xhci->cap_regs +
|
|
|
|
SSIC_PORT_CFG2 +
|
|
|
|
i * SSIC_PORT_CFG2_OFFSET;
|
|
|
|
|
|
|
|
/* Notify SSIC that SSIC profile programming is not done. */
|
|
|
|
val = readl(reg) & ~PROG_DONE;
|
|
|
|
writel(val, reg);
|
|
|
|
|
|
|
|
/* Mark SSIC port as unused(suspend) or used(resume) */
|
|
|
|
val = readl(reg);
|
|
|
|
if (suspend)
|
|
|
|
val |= SSIC_PORT_UNUSED;
|
|
|
|
else
|
|
|
|
val &= ~SSIC_PORT_UNUSED;
|
|
|
|
writel(val, reg);
|
|
|
|
|
|
|
|
/* Notify SSIC that SSIC profile programming is done */
|
|
|
|
val = readl(reg) | PROG_DONE;
|
|
|
|
writel(val, reg);
|
|
|
|
readl(reg);
|
2015-09-21 22:46:11 +08:00
|
|
|
}
|
2016-01-26 23:50:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure PME works on some Intel xHCI controllers by writing 1 to clear
|
|
|
|
* the Internal PME flag bit in vendor specific PMCTRL register at offset 0x80a4
|
|
|
|
*/
|
|
|
|
static void xhci_pme_quirk(struct usb_hcd *hcd)
|
|
|
|
{
|
|
|
|
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
|
|
|
|
void __iomem *reg;
|
|
|
|
u32 val;
|
2015-09-21 22:46:11 +08:00
|
|
|
|
|
|
|
reg = (void __iomem *) xhci->cap_regs + 0x80a4;
|
|
|
|
val = readl(reg);
|
|
|
|
writel(val | BIT(28), reg);
|
|
|
|
readl(reg);
|
|
|
|
}
|
|
|
|
|
2010-10-14 22:23:06 +08:00
|
|
|
static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
|
|
|
|
{
|
|
|
|
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
|
xhci: Disable D3cold for buggy TI redrivers.
Some xHCI hosts contain a "redriver" from TI that silently drops port
status connect changes if the port slips into Compliance Mode. If the
port slips into compliance mode while the host is in D0, there will not
be a port status change event. If the port slips into compliance mode
while the host is in D3, the host will not send a PME. This includes
when the system is suspended (S3) or hibernated (S4).
If this happens when the system is in S3/S4, there is nothing software
can do. Other port status change events that would normally cause the
host to wake the system from S3/S4 may also be lost. This includes
remote wakeup, disconnects and connects on other ports, and overrcurrent
events. A decision was made to _NOT_ disable system suspend/hibernate
on these systems, since users are unlikely to enable wakeup from S3/S4
for the xHCI host.
Software can deal with this issue when the system is in S0. A work
around was put in to poll the port status registers for Compliance Mode.
The xHCI driver will continue to poll the registers while the host is
runtime suspended. Unfortunately, that means we can't allow the PCI
device to go into D3cold, because power will be removed from the host,
and the config space will read as all Fs.
Disable D3cold in the xHCI PCI runtime suspend function.
This patch should be backported to kernels as old as 3.2, that
contain the commit 71c731a296f1b08a3724bd1b514b64f1bda87a23 "usb: host:
xhci: Fix Compliance Mode on SN65LVPE502CP Hardware"
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: stable@vger.kernel.org
2013-04-19 01:02:03 +08:00
|
|
|
struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
|
2016-01-26 23:50:07 +08:00
|
|
|
int ret;
|
xhci: Disable D3cold for buggy TI redrivers.
Some xHCI hosts contain a "redriver" from TI that silently drops port
status connect changes if the port slips into Compliance Mode. If the
port slips into compliance mode while the host is in D0, there will not
be a port status change event. If the port slips into compliance mode
while the host is in D3, the host will not send a PME. This includes
when the system is suspended (S3) or hibernated (S4).
If this happens when the system is in S3/S4, there is nothing software
can do. Other port status change events that would normally cause the
host to wake the system from S3/S4 may also be lost. This includes
remote wakeup, disconnects and connects on other ports, and overrcurrent
events. A decision was made to _NOT_ disable system suspend/hibernate
on these systems, since users are unlikely to enable wakeup from S3/S4
for the xHCI host.
Software can deal with this issue when the system is in S0. A work
around was put in to poll the port status registers for Compliance Mode.
The xHCI driver will continue to poll the registers while the host is
runtime suspended. Unfortunately, that means we can't allow the PCI
device to go into D3cold, because power will be removed from the host,
and the config space will read as all Fs.
Disable D3cold in the xHCI PCI runtime suspend function.
This patch should be backported to kernels as old as 3.2, that
contain the commit 71c731a296f1b08a3724bd1b514b64f1bda87a23 "usb: host:
xhci: Fix Compliance Mode on SN65LVPE502CP Hardware"
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: stable@vger.kernel.org
2013-04-19 01:02:03 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Systems with the TI redriver that loses port status change events
|
|
|
|
* need to have the registers polled during D3, so avoid D3cold.
|
|
|
|
*/
|
2014-10-03 16:35:27 +08:00
|
|
|
if (xhci->quirks & XHCI_COMP_MODE_QUIRK)
|
2016-06-02 16:17:12 +08:00
|
|
|
pci_d3cold_disable(pdev);
|
2010-10-14 22:23:06 +08:00
|
|
|
|
2015-03-06 23:23:19 +08:00
|
|
|
if (xhci->quirks & XHCI_PME_STUCK_QUIRK)
|
2016-01-26 23:50:06 +08:00
|
|
|
xhci_pme_quirk(hcd);
|
|
|
|
|
|
|
|
if (xhci->quirks & XHCI_SSIC_PORT_UNUSED)
|
|
|
|
xhci_ssic_port_unused_quirk(hcd, true);
|
2015-03-06 23:23:19 +08:00
|
|
|
|
2016-01-26 23:50:07 +08:00
|
|
|
ret = xhci_suspend(xhci, do_wakeup);
|
|
|
|
if (ret && (xhci->quirks & XHCI_SSIC_PORT_UNUSED))
|
|
|
|
xhci_ssic_port_unused_quirk(hcd, false);
|
|
|
|
|
|
|
|
return ret;
|
2010-10-14 22:23:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
|
|
|
|
{
|
|
|
|
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
|
Intel xhci: Support EHCI/xHCI port switching.
The Intel Panther Point chipsets contain an EHCI and xHCI host controller
that shares some number of skew-dependent ports. These ports can be
switched from the EHCI to the xHCI host (and vice versa) by a hardware MUX
that is controlled by registers in the xHCI PCI configuration space. The
USB 3.0 SuperSpeed terminations on the xHCI ports can be controlled
separately from the USB 2.0 data wires.
This switchover mechanism is there to support users who do a custom
install of certain non-Linux operating systems that don't have official
USB 3.0 support. By default, the ports are under EHCI, SuperSpeed
terminations are off, and USB 3.0 devices will show up under the EHCI
controller at reduced speeds. (This was more palatable for the marketing
folks than having completely dead USB 3.0 ports if no xHCI drivers are
available.) Users should be able to turn on xHCI by default through a
BIOS option, but users are happiest when they don't have to change random
BIOS settings.
This patch introduces a driver method to switchover the ports from EHCI to
xHCI before the EHCI driver finishes PCI enumeration. We want to switch
the ports over before the USB core has the chance to enumerate devices
under EHCI, or boot from USB mass storage will fail if the boot device
connects under EHCI first, and then gets disconnected when the port
switches over to xHCI.
Add code to the xHCI PCI quirk to switch the ports from EHCI to xHCI. The
PCI quirks code will run before any other PCI probe function is called, so
this avoids the issue with boot devices.
Another issue is with BIOS behavior during system resume from hibernate.
If the BIOS doesn't support xHCI, it may switch the devices under EHCI to
allow use of the USB keyboard, mice, and mass storage devices. It's
supposed to remember the value of the port routing registers and switch
them back when the OS attempts to take control of the xHCI host controller,
but we all know not to trust BIOS writers.
Make both the xHCI driver and the EHCI driver attempt to switchover the
ports in their PCI resume functions. We can't guarantee which PCI device
will be resumed first, so this avoids any race conditions. Writing a '1'
to an already set port switchover bit or a '0' to a cleared port switchover
bit should have no effect.
The xHCI PCI configuration registers will be documented in the EDS-level
chipset spec, which is not public yet. I have permission from legal and
the Intel chipset group to release this patch early to allow good Linux
support at product launch. I've tried to document the registers as much
as possible, so please let me know if anything is unclear.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2011-02-23 01:57:15 +08:00
|
|
|
struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
|
2010-10-14 22:23:06 +08:00
|
|
|
int retval = 0;
|
|
|
|
|
Intel xhci: Support EHCI/xHCI port switching.
The Intel Panther Point chipsets contain an EHCI and xHCI host controller
that shares some number of skew-dependent ports. These ports can be
switched from the EHCI to the xHCI host (and vice versa) by a hardware MUX
that is controlled by registers in the xHCI PCI configuration space. The
USB 3.0 SuperSpeed terminations on the xHCI ports can be controlled
separately from the USB 2.0 data wires.
This switchover mechanism is there to support users who do a custom
install of certain non-Linux operating systems that don't have official
USB 3.0 support. By default, the ports are under EHCI, SuperSpeed
terminations are off, and USB 3.0 devices will show up under the EHCI
controller at reduced speeds. (This was more palatable for the marketing
folks than having completely dead USB 3.0 ports if no xHCI drivers are
available.) Users should be able to turn on xHCI by default through a
BIOS option, but users are happiest when they don't have to change random
BIOS settings.
This patch introduces a driver method to switchover the ports from EHCI to
xHCI before the EHCI driver finishes PCI enumeration. We want to switch
the ports over before the USB core has the chance to enumerate devices
under EHCI, or boot from USB mass storage will fail if the boot device
connects under EHCI first, and then gets disconnected when the port
switches over to xHCI.
Add code to the xHCI PCI quirk to switch the ports from EHCI to xHCI. The
PCI quirks code will run before any other PCI probe function is called, so
this avoids the issue with boot devices.
Another issue is with BIOS behavior during system resume from hibernate.
If the BIOS doesn't support xHCI, it may switch the devices under EHCI to
allow use of the USB keyboard, mice, and mass storage devices. It's
supposed to remember the value of the port routing registers and switch
them back when the OS attempts to take control of the xHCI host controller,
but we all know not to trust BIOS writers.
Make both the xHCI driver and the EHCI driver attempt to switchover the
ports in their PCI resume functions. We can't guarantee which PCI device
will be resumed first, so this avoids any race conditions. Writing a '1'
to an already set port switchover bit or a '0' to a cleared port switchover
bit should have no effect.
The xHCI PCI configuration registers will be documented in the EDS-level
chipset spec, which is not public yet. I have permission from legal and
the Intel chipset group to release this patch early to allow good Linux
support at product launch. I've tried to document the registers as much
as possible, so please let me know if anything is unclear.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2011-02-23 01:57:15 +08:00
|
|
|
/* The BIOS on systems with the Intel Panther Point chipset may or may
|
|
|
|
* not support xHCI natively. That means that during system resume, it
|
|
|
|
* may switch the ports back to EHCI so that users can use their
|
|
|
|
* keyboard to select a kernel from GRUB after resume from hibernate.
|
|
|
|
*
|
|
|
|
* The BIOS is supposed to remember whether the OS had xHCI ports
|
|
|
|
* enabled before resume, and switch the ports back to xHCI when the
|
|
|
|
* BIOS/OS semaphore is written, but we all know we can't trust BIOS
|
|
|
|
* writers.
|
|
|
|
*
|
|
|
|
* Unconditionally switch the ports back to xHCI after a system resume.
|
2013-07-23 16:35:47 +08:00
|
|
|
* It should not matter whether the EHCI or xHCI controller is
|
|
|
|
* resumed first. It's enough to do the switchover in xHCI because
|
|
|
|
* USB core won't notice anything as the hub driver doesn't start
|
|
|
|
* running again until after all the devices (including both EHCI and
|
|
|
|
* xHCI host controllers) have been resumed.
|
Intel xhci: Support EHCI/xHCI port switching.
The Intel Panther Point chipsets contain an EHCI and xHCI host controller
that shares some number of skew-dependent ports. These ports can be
switched from the EHCI to the xHCI host (and vice versa) by a hardware MUX
that is controlled by registers in the xHCI PCI configuration space. The
USB 3.0 SuperSpeed terminations on the xHCI ports can be controlled
separately from the USB 2.0 data wires.
This switchover mechanism is there to support users who do a custom
install of certain non-Linux operating systems that don't have official
USB 3.0 support. By default, the ports are under EHCI, SuperSpeed
terminations are off, and USB 3.0 devices will show up under the EHCI
controller at reduced speeds. (This was more palatable for the marketing
folks than having completely dead USB 3.0 ports if no xHCI drivers are
available.) Users should be able to turn on xHCI by default through a
BIOS option, but users are happiest when they don't have to change random
BIOS settings.
This patch introduces a driver method to switchover the ports from EHCI to
xHCI before the EHCI driver finishes PCI enumeration. We want to switch
the ports over before the USB core has the chance to enumerate devices
under EHCI, or boot from USB mass storage will fail if the boot device
connects under EHCI first, and then gets disconnected when the port
switches over to xHCI.
Add code to the xHCI PCI quirk to switch the ports from EHCI to xHCI. The
PCI quirks code will run before any other PCI probe function is called, so
this avoids the issue with boot devices.
Another issue is with BIOS behavior during system resume from hibernate.
If the BIOS doesn't support xHCI, it may switch the devices under EHCI to
allow use of the USB keyboard, mice, and mass storage devices. It's
supposed to remember the value of the port routing registers and switch
them back when the OS attempts to take control of the xHCI host controller,
but we all know not to trust BIOS writers.
Make both the xHCI driver and the EHCI driver attempt to switchover the
ports in their PCI resume functions. We can't guarantee which PCI device
will be resumed first, so this avoids any race conditions. Writing a '1'
to an already set port switchover bit or a '0' to a cleared port switchover
bit should have no effect.
The xHCI PCI configuration registers will be documented in the EDS-level
chipset spec, which is not public yet. I have permission from legal and
the Intel chipset group to release this patch early to allow good Linux
support at product launch. I've tried to document the registers as much
as possible, so please let me know if anything is unclear.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2011-02-23 01:57:15 +08:00
|
|
|
*/
|
2013-07-23 16:35:47 +08:00
|
|
|
|
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_INTEL)
|
|
|
|
usb_enable_intel_xhci_ports(pdev);
|
Intel xhci: Support EHCI/xHCI port switching.
The Intel Panther Point chipsets contain an EHCI and xHCI host controller
that shares some number of skew-dependent ports. These ports can be
switched from the EHCI to the xHCI host (and vice versa) by a hardware MUX
that is controlled by registers in the xHCI PCI configuration space. The
USB 3.0 SuperSpeed terminations on the xHCI ports can be controlled
separately from the USB 2.0 data wires.
This switchover mechanism is there to support users who do a custom
install of certain non-Linux operating systems that don't have official
USB 3.0 support. By default, the ports are under EHCI, SuperSpeed
terminations are off, and USB 3.0 devices will show up under the EHCI
controller at reduced speeds. (This was more palatable for the marketing
folks than having completely dead USB 3.0 ports if no xHCI drivers are
available.) Users should be able to turn on xHCI by default through a
BIOS option, but users are happiest when they don't have to change random
BIOS settings.
This patch introduces a driver method to switchover the ports from EHCI to
xHCI before the EHCI driver finishes PCI enumeration. We want to switch
the ports over before the USB core has the chance to enumerate devices
under EHCI, or boot from USB mass storage will fail if the boot device
connects under EHCI first, and then gets disconnected when the port
switches over to xHCI.
Add code to the xHCI PCI quirk to switch the ports from EHCI to xHCI. The
PCI quirks code will run before any other PCI probe function is called, so
this avoids the issue with boot devices.
Another issue is with BIOS behavior during system resume from hibernate.
If the BIOS doesn't support xHCI, it may switch the devices under EHCI to
allow use of the USB keyboard, mice, and mass storage devices. It's
supposed to remember the value of the port routing registers and switch
them back when the OS attempts to take control of the xHCI host controller,
but we all know not to trust BIOS writers.
Make both the xHCI driver and the EHCI driver attempt to switchover the
ports in their PCI resume functions. We can't guarantee which PCI device
will be resumed first, so this avoids any race conditions. Writing a '1'
to an already set port switchover bit or a '0' to a cleared port switchover
bit should have no effect.
The xHCI PCI configuration registers will be documented in the EDS-level
chipset spec, which is not public yet. I have permission from legal and
the Intel chipset group to release this patch early to allow good Linux
support at product launch. I've tried to document the registers as much
as possible, so please let me know if anything is unclear.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2011-02-23 01:57:15 +08:00
|
|
|
|
2016-01-26 23:50:06 +08:00
|
|
|
if (xhci->quirks & XHCI_SSIC_PORT_UNUSED)
|
|
|
|
xhci_ssic_port_unused_quirk(hcd, false);
|
|
|
|
|
2015-03-06 23:23:19 +08:00
|
|
|
if (xhci->quirks & XHCI_PME_STUCK_QUIRK)
|
2016-01-26 23:50:06 +08:00
|
|
|
xhci_pme_quirk(hcd);
|
2015-03-06 23:23:19 +08:00
|
|
|
|
2010-10-14 22:23:06 +08:00
|
|
|
retval = xhci_resume(xhci, hibernated);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PM */
|
|
|
|
|
2009-04-28 10:52:28 +08:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/* PCI driver selection metadata; PCI hotplugging uses this */
|
|
|
|
static const struct pci_device_id pci_ids[] = { {
|
|
|
|
/* handle any USB 3.0 xHCI controller */
|
|
|
|
PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_XHCI, ~0),
|
|
|
|
.driver_data = (unsigned long) &xhci_pci_hc_driver,
|
|
|
|
},
|
|
|
|
{ /* end: all zeroes */ }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pci, pci_ids);
|
|
|
|
|
|
|
|
/* pci driver glue; this is a "new style" PCI driver module */
|
|
|
|
static struct pci_driver xhci_pci_driver = {
|
|
|
|
.name = (char *) hcd_name,
|
|
|
|
.id_table = pci_ids,
|
|
|
|
|
xhci: Register second xHCI roothub.
This patch changes the xHCI driver to allocate two roothubs. This touches
the driver initialization and shutdown paths, roothub emulation code, and
port status change event handlers. This is a rather large patch, but it
can't be broken up, or it would break git-bisect.
Make the xHCI driver register its own PCI probe function. This will call
the USB core to create the USB 2.0 roothub, and then create the USB 3.0
roothub. This gets the code for registering a shared roothub out of the
USB core, and allows other HCDs later to decide if and how many shared
roothubs they want to allocate.
Make sure the xHCI's reset method marks the xHCI host controller's primary
roothub as the USB 2.0 roothub. This ensures that the high speed bus will
be processed first when the PCI device is resumed, and any USB 3.0 devices
that have migrated over to high speed will migrate back after being reset.
This ensures that USB persist works with these odd devices.
The reset method will also mark the xHCI USB2 roothub as having an
integrated TT. Like EHCI host controllers with a "rate matching hub" the
xHCI USB 2.0 roothub doesn't have an OHCI or UHCI companion controller.
It doesn't really have a TT, but we'll lie and say it has an integrated
TT. We need to do this because the USB core will reject LS/FS devices
under a HS hub without a TT.
Other details:
-------------
The roothub emulation code is changed to return the correct number of
ports for the two roothubs. For the USB 3.0 roothub, it only reports the
USB 3.0 ports. For the USB 2.0 roothub, it reports all the LS/FS/HS
ports. The code to disable a port now checks the speed of the roothub,
and refuses to disable SuperSpeed ports under the USB 3.0 roothub.
The code for initializing a new device context must be changed to set the
proper roothub port number. Since we've split the xHCI host into two
roothubs, we can't just use the port number in the ancestor hub. Instead,
we loop through the array of hardware port status register speeds and find
the Nth port with a similar speed.
The port status change event handler is updated to figure out whether the
port that reported the change is a USB 3.0 port, or a non-SuperSpeed port.
Once it figures out the port speed, it kicks the proper roothub.
The function to find a slot ID based on the port index is updated to take
into account that the two roothubs will have over-lapping port indexes.
It checks that the virtual device with a matching port index is the same
speed as the passed in roothub.
There's also changes to the driver initialization and shutdown paths:
1. Make sure that the xhci_hcd pointer is shared across the two
usb_hcd structures. The xhci_hcd pointer is allocated and the
registers are mapped in when xhci_pci_setup() is called with the
primary HCD. When xhci_pci_setup() is called with the non-primary
HCD, the xhci_hcd pointer is stored.
2. Make sure to set the sg_tablesize for both usb_hcd structures. Set
the PCI DMA mask for the non-primary HCD to allow for 64-bit or 32-bit
DMA. (The PCI DMA mask is set from the primary HCD further down in
the xhci_pci_setup() function.)
3. Ensure that the host controller doesn't start kicking khubd in
response to port status changes before both usb_hcd structures are
registered. xhci_run() only starts the xHC running once it has been
called with the non-primary roothub. Similarly, the xhci_stop()
function only halts the host controller when it is called with the
non-primary HCD. Then on the second call, it resets and cleans up the
MSI-X irqs.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
2010-12-17 03:21:10 +08:00
|
|
|
.probe = xhci_pci_probe,
|
2010-10-27 02:03:44 +08:00
|
|
|
.remove = xhci_pci_remove,
|
2009-04-28 10:52:28 +08:00
|
|
|
/* suspend and resume implemented later */
|
|
|
|
|
|
|
|
.shutdown = usb_hcd_pci_shutdown,
|
2013-09-25 03:45:25 +08:00
|
|
|
#ifdef CONFIG_PM
|
2010-10-14 22:23:06 +08:00
|
|
|
.driver = {
|
|
|
|
.pm = &usb_hcd_pci_pm_ops
|
|
|
|
},
|
|
|
|
#endif
|
2009-04-28 10:52:28 +08:00
|
|
|
};
|
|
|
|
|
2014-10-03 16:35:29 +08:00
|
|
|
static int __init xhci_pci_init(void)
|
2009-04-28 10:52:28 +08:00
|
|
|
{
|
2015-05-29 22:01:46 +08:00
|
|
|
xhci_init_driver(&xhci_pci_hc_driver, &xhci_pci_overrides);
|
2014-10-03 16:35:26 +08:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
xhci_pci_hc_driver.pci_suspend = xhci_pci_suspend;
|
|
|
|
xhci_pci_hc_driver.pci_resume = xhci_pci_resume;
|
|
|
|
#endif
|
2009-04-28 10:52:28 +08:00
|
|
|
return pci_register_driver(&xhci_pci_driver);
|
|
|
|
}
|
2014-10-03 16:35:29 +08:00
|
|
|
module_init(xhci_pci_init);
|
2009-04-28 10:52:28 +08:00
|
|
|
|
2014-10-03 16:35:29 +08:00
|
|
|
static void __exit xhci_pci_exit(void)
|
2009-04-28 10:52:28 +08:00
|
|
|
{
|
|
|
|
pci_unregister_driver(&xhci_pci_driver);
|
|
|
|
}
|
2014-10-03 16:35:29 +08:00
|
|
|
module_exit(xhci_pci_exit);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("xHCI PCI Host Controller Driver");
|
|
|
|
MODULE_LICENSE("GPL");
|