forked from Minki/linux
140e3026a5
Commit 9df89d85b4
"usbcore: set
lpm_capable field for LPM capable root hubs" was created under the
assumption that all USB host controllers should have USB 3.0 Link PM
enabled for all devices under the hosts.
Unfortunately, that's not the case. The xHCI driver relies on knowledge
of the host hardware scheduler to calculate the LPM U1/U2 timeout
values, and it only sets lpm_capable to one for Intel host controllers
(that have the XHCI_LPM_SUPPORT quirk set).
When LPM is enabled for some Fresco Logic hosts, it causes failures with
a AgeStar 3UBT USB 3.0 hard drive dock:
Jan 11 13:59:03 sg-laptop kernel: usb 3-1: new SuperSpeed USB device number 2 using xhci_hcd
Jan 11 13:59:03 sg-laptop kernel: usb 3-1: Set SEL for device-initiated U1 failed.
Jan 11 13:59:08 sg-laptop kernel: usb 3-1: Set SEL for device-initiated U2 failed.
Jan 11 13:59:08 sg-laptop kernel: usb-storage 3-1:1.0: USB Mass Storage device detected
Jan 11 13:59:08 sg-laptop mtp-probe[613]: checking bus 3, device 2: "/sys/devices/pci0000:00/0000:00:1c.3/0000:04:00.0/usb3/3-1"
Jan 11 13:59:08 sg-laptop mtp-probe[613]: bus: 3, device: 2 was not an MTP device
Jan 11 13:59:08 sg-laptop kernel: scsi6 : usb-storage 3-1:1.0
Jan 11 13:59:13 sg-laptop kernel: usb 3-1: Set SEL for device-initiated U1 failed.
Jan 11 13:59:18 sg-laptop kernel: usb 3-1: Set SEL for device-initiated U2 failed.
Jan 11 13:59:18 sg-laptop kernel: usbcore: registered new interface driver usb-storage
Jan 11 13:59:40 sg-laptop kernel: usb 3-1: reset SuperSpeed USB device number 2 using xhci_hcd
Jan 11 13:59:41 sg-laptop kernel: usb 3-1: device descriptor read/8, error -71
Jan 11 13:59:41 sg-laptop kernel: usb 3-1: reset SuperSpeed USB device number 2 using xhci_hcd
Jan 11 13:59:46 sg-laptop kernel: usb 3-1: device descriptor read/8, error -110
Jan 11 13:59:46 sg-laptop kernel: scsi 6:0:0:0: Device offlined - not ready after error recovery
Jan 11 13:59:46 sg-laptop kernel: usb 3-1: USB disconnect, device number 2
lspci for the affected host:
04:00.0 0c03: 1b73:1000 (rev 04) (prog-if 30 [XHCI])
Subsystem: 1043:1039
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 19
Region 0: Memory at dd200000 (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: 0000000000000000 Data: 0000
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
Kernel modules: xhci_hcd
The commit was backported to stable kernels, and will need to be
reverted there as well.
Signed-off-by: Sarah Sharp <sarah.a.sharp@intel.com>
Reported-by: Sergey Galanov <sergey.e.galanov@gmail.com>
Cc: stable@vger.kernel.org
198 lines
6.4 KiB
C
198 lines
6.4 KiB
C
#include <linux/pm.h>
|
|
#include <linux/acpi.h>
|
|
|
|
struct usb_hub_descriptor;
|
|
struct dev_state;
|
|
|
|
/* Functions local to drivers/usb/core/ */
|
|
|
|
extern int usb_create_sysfs_dev_files(struct usb_device *dev);
|
|
extern void usb_remove_sysfs_dev_files(struct usb_device *dev);
|
|
extern void usb_create_sysfs_intf_files(struct usb_interface *intf);
|
|
extern void usb_remove_sysfs_intf_files(struct usb_interface *intf);
|
|
extern int usb_create_ep_devs(struct device *parent,
|
|
struct usb_host_endpoint *endpoint,
|
|
struct usb_device *udev);
|
|
extern void usb_remove_ep_devs(struct usb_host_endpoint *endpoint);
|
|
|
|
extern void usb_enable_endpoint(struct usb_device *dev,
|
|
struct usb_host_endpoint *ep, bool reset_toggle);
|
|
extern void usb_enable_interface(struct usb_device *dev,
|
|
struct usb_interface *intf, bool reset_toggles);
|
|
extern void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr,
|
|
bool reset_hardware);
|
|
extern void usb_disable_interface(struct usb_device *dev,
|
|
struct usb_interface *intf, bool reset_hardware);
|
|
extern void usb_release_interface_cache(struct kref *ref);
|
|
extern void usb_disable_device(struct usb_device *dev, int skip_ep0);
|
|
extern int usb_deauthorize_device(struct usb_device *);
|
|
extern int usb_authorize_device(struct usb_device *);
|
|
extern void usb_detect_quirks(struct usb_device *udev);
|
|
extern void usb_detect_interface_quirks(struct usb_device *udev);
|
|
extern int usb_remove_device(struct usb_device *udev);
|
|
|
|
extern int usb_get_device_descriptor(struct usb_device *dev,
|
|
unsigned int size);
|
|
extern int usb_get_bos_descriptor(struct usb_device *dev);
|
|
extern void usb_release_bos_descriptor(struct usb_device *dev);
|
|
extern char *usb_cache_string(struct usb_device *udev, int index);
|
|
extern int usb_set_configuration(struct usb_device *dev, int configuration);
|
|
extern int usb_choose_configuration(struct usb_device *udev);
|
|
|
|
static inline unsigned usb_get_max_power(struct usb_device *udev,
|
|
struct usb_host_config *c)
|
|
{
|
|
/* SuperSpeed power is in 8 mA units; others are in 2 mA units */
|
|
unsigned mul = (udev->speed == USB_SPEED_SUPER ? 8 : 2);
|
|
|
|
return c->desc.bMaxPower * mul;
|
|
}
|
|
|
|
extern void usb_kick_khubd(struct usb_device *dev);
|
|
extern int usb_match_one_id_intf(struct usb_device *dev,
|
|
struct usb_host_interface *intf,
|
|
const struct usb_device_id *id);
|
|
extern int usb_match_device(struct usb_device *dev,
|
|
const struct usb_device_id *id);
|
|
extern void usb_forced_unbind_intf(struct usb_interface *intf);
|
|
extern void usb_rebind_intf(struct usb_interface *intf);
|
|
|
|
extern int usb_hub_claim_port(struct usb_device *hdev, unsigned port,
|
|
struct dev_state *owner);
|
|
extern int usb_hub_release_port(struct usb_device *hdev, unsigned port,
|
|
struct dev_state *owner);
|
|
extern void usb_hub_release_all_ports(struct usb_device *hdev,
|
|
struct dev_state *owner);
|
|
extern bool usb_device_is_owned(struct usb_device *udev);
|
|
|
|
extern int usb_hub_init(void);
|
|
extern void usb_hub_cleanup(void);
|
|
extern int usb_major_init(void);
|
|
extern void usb_major_cleanup(void);
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
extern int usb_suspend(struct device *dev, pm_message_t msg);
|
|
extern int usb_resume(struct device *dev, pm_message_t msg);
|
|
extern int usb_resume_complete(struct device *dev);
|
|
|
|
extern int usb_port_suspend(struct usb_device *dev, pm_message_t msg);
|
|
extern int usb_port_resume(struct usb_device *dev, pm_message_t msg);
|
|
|
|
#else
|
|
|
|
static inline int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline int usb_port_resume(struct usb_device *udev, pm_message_t msg)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PM_RUNTIME
|
|
|
|
extern void usb_autosuspend_device(struct usb_device *udev);
|
|
extern int usb_autoresume_device(struct usb_device *udev);
|
|
extern int usb_remote_wakeup(struct usb_device *dev);
|
|
extern int usb_runtime_suspend(struct device *dev);
|
|
extern int usb_runtime_resume(struct device *dev);
|
|
extern int usb_runtime_idle(struct device *dev);
|
|
extern int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable);
|
|
|
|
#else
|
|
|
|
#define usb_autosuspend_device(udev) do {} while (0)
|
|
static inline int usb_autoresume_device(struct usb_device *udev)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline int usb_remote_wakeup(struct usb_device *udev)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
extern struct bus_type usb_bus_type;
|
|
extern struct device_type usb_device_type;
|
|
extern struct device_type usb_if_device_type;
|
|
extern struct device_type usb_ep_device_type;
|
|
extern struct device_type usb_port_device_type;
|
|
extern struct usb_device_driver usb_generic_driver;
|
|
|
|
static inline int is_usb_device(const struct device *dev)
|
|
{
|
|
return dev->type == &usb_device_type;
|
|
}
|
|
|
|
static inline int is_usb_interface(const struct device *dev)
|
|
{
|
|
return dev->type == &usb_if_device_type;
|
|
}
|
|
|
|
static inline int is_usb_endpoint(const struct device *dev)
|
|
{
|
|
return dev->type == &usb_ep_device_type;
|
|
}
|
|
|
|
static inline int is_usb_port(const struct device *dev)
|
|
{
|
|
return dev->type == &usb_port_device_type;
|
|
}
|
|
|
|
/* Do the same for device drivers and interface drivers. */
|
|
|
|
static inline int is_usb_device_driver(struct device_driver *drv)
|
|
{
|
|
return container_of(drv, struct usbdrv_wrap, driver)->
|
|
for_devices;
|
|
}
|
|
|
|
/* for labeling diagnostics */
|
|
extern const char *usbcore_name;
|
|
|
|
/* sysfs stuff */
|
|
extern const struct attribute_group *usb_device_groups[];
|
|
extern const struct attribute_group *usb_interface_groups[];
|
|
|
|
/* usbfs stuff */
|
|
extern struct mutex usbfs_mutex;
|
|
extern struct usb_driver usbfs_driver;
|
|
extern const struct file_operations usbfs_devices_fops;
|
|
extern const struct file_operations usbdev_file_operations;
|
|
extern void usbfs_conn_disc_event(void);
|
|
|
|
extern int usb_devio_init(void);
|
|
extern void usb_devio_cleanup(void);
|
|
|
|
/* internal notify stuff */
|
|
extern void usb_notify_add_device(struct usb_device *udev);
|
|
extern void usb_notify_remove_device(struct usb_device *udev);
|
|
extern void usb_notify_add_bus(struct usb_bus *ubus);
|
|
extern void usb_notify_remove_bus(struct usb_bus *ubus);
|
|
extern enum usb_port_connect_type
|
|
usb_get_hub_port_connect_type(struct usb_device *hdev, int port1);
|
|
extern void usb_set_hub_port_connect_type(struct usb_device *hdev, int port1,
|
|
enum usb_port_connect_type type);
|
|
extern void usb_hub_adjust_deviceremovable(struct usb_device *hdev,
|
|
struct usb_hub_descriptor *desc);
|
|
|
|
#ifdef CONFIG_ACPI
|
|
extern int usb_acpi_register(void);
|
|
extern void usb_acpi_unregister(void);
|
|
extern acpi_handle usb_get_hub_port_acpi_handle(struct usb_device *hdev,
|
|
int port1);
|
|
#else
|
|
static inline int usb_acpi_register(void) { return 0; };
|
|
static inline void usb_acpi_unregister(void) { };
|
|
#endif
|