|
|
|
[RFC v2] USB: Add a sysfs file to show LTM capabilities. | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
|
USB 3.0 devices can optionally support Latency Tolerance Messaging
(LTM). Add a new sysfs file in the device directory to show whether a
device is LTM capable. This file will be present for both USB 2.0 and
USB 3.0 devices.
Signed-off-by: Sarah Sharp <sarah.a.sharp@xxxxxxxxxxxxxxx>
---
v2: Add ABI documentation.
I think this is only change needed for the LPM bug fixes and LTM
patchset. I did want to change the "xhci" prefix on the first two
patches to "USB", since they touch the USB core and not the xHCI driver.
However, I don't think that warrants a second revision to the mailing
list.
Greg, let me know if the ABI documentation seems ok, and I'll send you a
pull request.
Sarah
Documentation/ABI/testing/sysfs-bus-usb | 12 ++++++++++++
drivers/usb/core/hub.c | 7 -------
drivers/usb/core/sysfs.c | 10 ++++++++++
include/linux/usb.h | 8 ++++++++
4 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/Documentation/ABI/testing/sysfs-bus-usb b/Documentation/ABI/testing/sysfs-bus-usb
index 6df4e6f..5f75f8f 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -208,3 +208,15 @@ Description:
such as ACPI. This file will read either "removable" or
"fixed" if the information is available, and "unknown"
otherwise.
+
+What: /sys/bus/usb/devices/.../ltm_capable
+Date: July 2012
+Contact: Sarah Sharp <sarah.a.sharp@xxxxxxxxxxxxxxx>
+Description:
+ USB 3.0 devices may optionally support Latency Tolerance
+ Messaging (LTM). They indicate their support by setting a bit
+ in the bmAttributes field of their SuperSpeed BOS descriptors.
+ If that bit is set for the device, ltm_capable will read "yes".
+ If the device doesn't support LTM, the file will read "no".
+ The file will be present for all speeds of USB devices, and will
+ always read "no" for USB 1.1 and USB 2.0 devices.
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 7ca94d7..1f09018 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2607,13 +2607,6 @@ static int check_port_resume_type(struct usb_device *udev,
return status;
}
-static bool usb_device_supports_ltm(struct usb_device *udev)
-{
- if (udev->speed != USB_SPEED_SUPER || !udev->bos || !udev->bos->ss_cap)
- return false;
- return udev->bos->ss_cap->bmAttributes & USB_LTM_SUPPORT;
-}
-
int usb_disable_ltm(struct usb_device *udev)
{
struct usb_hcd *hcd = bus_to_hcd(udev->bus);
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 777f03c..682e825 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -253,6 +253,15 @@ show_removable(struct device *dev, struct device_attribute *attr, char *buf)
}
static DEVICE_ATTR(removable, S_IRUGO, show_removable, NULL);
+static ssize_t
+show_ltm_capable(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ if (usb_device_supports_ltm(to_usb_device(dev)))
+ return sprintf(buf, "%s\n", "yes");
+ return sprintf(buf, "%s\n", "no");
+}
+static DEVICE_ATTR(ltm_capable, S_IRUGO, show_ltm_capable, NULL);
+
#ifdef CONFIG_PM
static ssize_t
@@ -649,6 +658,7 @@ static struct attribute *dev_attrs[] = {
&dev_attr_authorized.attr,
&dev_attr_remove.attr,
&dev_attr_removable.attr,
+ &dev_attr_ltm_capable.attr,
NULL,
};
static struct attribute_group dev_attr_grp = {
diff --git a/include/linux/usb.h b/include/linux/usb.h
index aaac9e4..29147ca 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -631,6 +631,14 @@ extern void usb_unlocked_enable_lpm(struct usb_device *udev);
extern int usb_disable_ltm(struct usb_device *udev);
extern void usb_enable_ltm(struct usb_device *udev);
+static inline bool usb_device_supports_ltm(struct usb_device *udev)
+{
+ if (udev->speed != USB_SPEED_SUPER || !udev->bos || !udev->bos->ss_cap)
+ return false;
+ return udev->bos->ss_cap->bmAttributes & USB_LTM_SUPPORT;
+}
+
+
/*-------------------------------------------------------------------------*/
/* for drivers using iso endpoints */
--
1.7.9
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html

[Linux Media] [Video for Linux] [Linux Input] [Linux Audio Users] [Photo] [Yosemite News] [Yosemite Photos] [Free Online Dating] [Linux Kernel] [Linux SCSI] [Old Linux USB Devel Archive] [More Archives]
![]() |
![]() |