[RFC PATCH V2 0/6] usb: usb port power off mechanism
Change Since v1: (1) Add driver/usb/core/port.c file and move usb port related code into new file. (2) Modify usb port's runtime pm callback and set/clear PORT_POWER feature in the resume/suspend callback. (3) Power off port through suspend port device instead of setting/ clearing PORT_POWER feature. Existing problem: When pm qos flags is updating, pm core will do pm_runtime_get_sync(port_dev) and pm_runtime_put(port_dev). Currently port's runtime pm callback set/clear PORT_POWER feature. This will cause alwas port power off after port's pm qos flags being changed. This patchset is to add usb port power off mechanism. The main discussion is in the following link: http://marc.info/?l=linux-usb&m=134818340017208&w=2 The patchset is based on the pm qos flags patches on the linux-pm's next tree and pm-qos http://git.kernel.org/?p=linux/kernel/git/rafael/linux-pm.git;a=shortlog;h=refs/heads/pm-qos and patchset "usb: expose DeviceRemovable to user space via sysfs attribute" http://marc.info/?l=linux-usb&m=135234231804002&w=2 usb: add usb port's pm qos flags request to change NO_POWER_OFF flag usb: expose usb port's pm qos flags to user space usb: add usb port auto power off mechanism usb: add runtime pm support for usb port device usb: Add driver/usb/core/port.c file to fill usb port related code. usb: Register usb port's acpi power resources drivers/usb/core/Makefile |1 + drivers/usb/core/hub.c | 235 +++ drivers/usb/core/port.c | 142 ++ drivers/usb/core/usb-acpi.c | 22 + drivers/usb/core/usb.h | 11 + include/linux/usb.h | 23 ++ 6 files changed, 338 insertions(+), 96 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH v2 1/6] usb: Register usb port's acpi power resources
This patch is to register usb port's acpi power resources. Create link between usb port device and its acpi power resource. Signed-off-by: Lan Tianyu --- drivers/usb/core/hub.c |4 drivers/usb/core/usb-acpi.c | 22 ++ drivers/usb/core/usb.h |6 ++ 3 files changed, 32 insertions(+) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 55c086e..3c85fe1c 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1241,6 +1241,7 @@ static void usb_port_device_release(struct device *dev) { struct usb_port *port_dev = to_usb_port(dev); + usb_acpi_unregister_power_resources(dev); kfree(port_dev); } @@ -1276,6 +1277,9 @@ static int usb_hub_create_port_device(struct usb_hub *hub, retval = device_register(&port_dev->dev); if (retval) goto error_register; + + usb_acpi_register_power_resources(&port_dev->dev); + return 0; error_register: diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c index cef4252..c58ebc0 100644 --- a/drivers/usb/core/usb-acpi.c +++ b/drivers/usb/core/usb-acpi.c @@ -216,6 +216,28 @@ static struct acpi_bus_type usb_acpi_bus = { .find_device = usb_acpi_find_device, }; +int usb_acpi_register_power_resources(struct device *dev) +{ + acpi_handle port_handle = DEVICE_ACPI_HANDLE(dev); + + if (!port_handle) + return -ENODEV; + + if (acpi_power_resource_register_device(dev, port_handle) < 0) + return -ENODEV; + return 0; +} + +void usb_acpi_unregister_power_resources(struct device *dev) +{ + acpi_handle port_handle = DEVICE_ACPI_HANDLE(dev); + + if (!port_handle) + return; + + acpi_power_resource_register_device(dev, port_handle); +} + int usb_acpi_register(void) { return register_acpi_bus_type(&usb_acpi_bus); diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 1633f6e..38958fb 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -175,7 +175,13 @@ 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); +extern int usb_acpi_register_power_resources(struct device *dev); +extern void usb_acpi_unregister_power_resources(struct device *dev); #else static inline int usb_acpi_register(void) { return 0; }; static inline void usb_acpi_unregister(void) { }; +static inline int usb_acpi_register_power_resources(struct usb_device *udev) + { return 0; }; +static inline int usb_acpi_unregister_power_resources(struct usb_device *udev) + { }; #endif -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH v2 2/6] usb: Add driver/usb/core/port.c file to fill usb port related code.
This patch is to create driver/usb/core/port.c and move usb port related code into it. Signed-off-by: Lan Tianyu --- drivers/usb/core/Makefile |1 + drivers/usb/core/hub.c| 113 +++-- drivers/usb/core/port.c | 82 drivers/usb/core/usb.h|3 ++ include/linux/usb.h | 16 +++ 5 files changed, 118 insertions(+), 97 deletions(-) create mode 100644 drivers/usb/core/port.c diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile index 26059b9..5e847ad 100644 --- a/drivers/usb/core/Makefile +++ b/drivers/usb/core/Makefile @@ -7,6 +7,7 @@ ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG usbcore-y := usb.o hub.o hcd.o urb.o message.o driver.o usbcore-y += config.o file.o buffer.o sysfs.o endpoint.o usbcore-y += devio.o notify.o generic.o quirks.o devices.o +usbcore-y += port.o usbcore-$(CONFIG_PCI) += hcd-pci.o usbcore-$(CONFIG_ACPI) += usb-acpi.o diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 3c85fe1c..60746aa 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -42,13 +42,6 @@ #define USB_VENDOR_GENESYS_LOGIC 0x05e3 #define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND 0x01 -struct usb_port { - struct usb_device *child; - struct device dev; - struct dev_state *port_owner; - enum usb_port_connect_type connect_type; -}; - struct usb_hub { struct device *intfdev; /* the "interface" device */ struct usb_device *hdev; @@ -170,9 +163,6 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem); #define HUB_DEBOUNCE_STEP25 #define HUB_DEBOUNCE_STABLE 100 -#define to_usb_port(_dev) \ - container_of(_dev, struct usb_port, dev) - static int usb_reset_and_verify_device(struct usb_device *udev); static inline char *portspeed(struct usb_hub *hub, int portstatus) @@ -1237,57 +1227,12 @@ static int hub_post_reset(struct usb_interface *intf) return 0; } -static void usb_port_device_release(struct device *dev) -{ - struct usb_port *port_dev = to_usb_port(dev); - - usb_acpi_unregister_power_resources(dev); - kfree(port_dev); -} - static void usb_hub_remove_port_device(struct usb_hub *hub, int port1) { device_unregister(&hub->ports[port1 - 1]->dev); } -struct device_type usb_port_device_type = { - .name = "usb_port", - .release = usb_port_device_release, -}; - -static int usb_hub_create_port_device(struct usb_hub *hub, - int port1) -{ - struct usb_port *port_dev = NULL; - int retval; - - port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL); - if (!port_dev) { - retval = -ENOMEM; - goto exit; - } - - hub->ports[port1 - 1] = port_dev; - port_dev->dev.parent = hub->intfdev; - port_dev->dev.groups = port_dev_group; - port_dev->dev.type = &usb_port_device_type; - dev_set_name(&port_dev->dev, "port%d", port1); - - retval = device_register(&port_dev->dev); - if (retval) - goto error_register; - - usb_acpi_register_power_resources(&port_dev->dev); - - return 0; - -error_register: - put_device(&port_dev->dev); -exit: - return retval; -} - static int hub_configure(struct usb_hub *hub, struct usb_endpoint_descriptor *endpoint) { @@ -1548,10 +1493,24 @@ static int hub_configure(struct usb_hub *hub, if (hub->has_indicators && blinkenlights) hub->indicator [0] = INDICATOR_CYCLE; - for (i = 0; i < hdev->maxchild; i++) - if (usb_hub_create_port_device(hub, i + 1) < 0) + for (i = 0; i < hdev->maxchild; i++) { + struct usb_port *port_dev = NULL; + + port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL); + if (!port_dev) { + dev_err(hub->intfdev, + "couldn't create port%d device due to lack mem.\n", i + 1); + continue; + } + + hub->ports[i] = port_dev; + + if (usb_hub_create_port_device(hub->intfdev, i + 1, port_dev) < 0) { dev_err(hub->intfdev, "couldn't create port%d device.\n", i + 1); + hub->ports[i] = NULL; + } + } if (!hub_is_superspeed(hdev)) { for (i = 1; i <= hdev->maxchild; i++) @@ -4765,46 +4724,6 @@ static int hub_thread(void *__unused) return 0; } -static ssize_t show_port_connect_type(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct usb_port *port_dev = to_usb_port(dev); - char *result; - - switch (port_dev->connect_type) { - case USB_PORT_CONNECT_TYPE_HOT_PLUG: - result = "hotplug"; -
[RFC PATCH v2 3/6] usb: add runtime pm support for usb port device
This patch is to add runtime pm callback for usb port device. Set/clear PORT_POWER feature in the resume/suspend callbak. Add portnum for struct usb_port to record port number. Signed-off-by: Lan Tianyu --- drivers/usb/core/hub.c | 14 ++ drivers/usb/core/port.c | 39 +++ drivers/usb/core/usb.h |2 ++ include/linux/usb.h |2 ++ 4 files changed, 57 insertions(+) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 60746aa..2cb414e 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -765,6 +765,20 @@ static void hub_tt_work(struct work_struct *work) spin_unlock_irqrestore (&hub->tt.lock, flags); } +int usb_hub_set_port_power(struct usb_device *hdev, int port1, + bool set) +{ + int ret; + + if (set) + ret = set_port_feature(hdev, port1, + USB_PORT_FEAT_POWER); + else + ret = clear_port_feature(hdev, port1, + USB_PORT_FEAT_POWER); + return ret; +} + /** * usb_hub_clear_tt_buffer - clear control/bulk TT state in high speed hub * @urb: an URB associated with the failed or incomplete split transaction diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index 6523a03..1cda766 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -53,9 +53,45 @@ static void usb_port_device_release(struct device *dev) kfree(port_dev); } +static int usb_port_runtime_resume(struct device *dev) +{ + struct usb_port *port_dev = to_usb_port(dev); + struct usb_device *hdev = + to_usb_device(dev->parent->parent); + + return usb_hub_set_port_power(hdev, port_dev->portnum, + true); +} + +static int usb_port_runtime_suspend(struct device *dev) +{ + struct usb_port *port_dev = to_usb_port(dev); + struct usb_device *hdev = + to_usb_device(dev->parent->parent); + + return usb_hub_set_port_power(hdev, port_dev->portnum, + false); +} + +static int usb_port_runtime_idle(struct device *dev) +{ + struct usb_port *port_dev = to_usb_port(dev); + + return pm_runtime_suspend(&port_dev->dev); +} + +static const struct dev_pm_ops usb_port_pm_ops = { +#ifdef CONFIG_USB_SUSPEND +.runtime_suspend = usb_port_runtime_suspend, +.runtime_resume = usb_port_runtime_resume, +.runtime_idle =usb_port_runtime_idle, +#endif +}; + struct device_type usb_port_device_type = { .name = "usb_port", .release = usb_port_device_release, + .pm = &usb_port_pm_ops, }; int usb_hub_create_port_device(struct device *intfdev, @@ -63,6 +99,7 @@ int usb_hub_create_port_device(struct device *intfdev, { int retval; + port_dev->portnum = port1; port_dev->dev.parent = intfdev; port_dev->dev.groups = port_dev_group; port_dev->dev.type = &usb_port_device_type; @@ -72,6 +109,8 @@ int usb_hub_create_port_device(struct device *intfdev, if (retval) goto error_register; + pm_runtime_set_active(&port_dev->dev); + pm_runtime_enable(&port_dev->dev); usb_acpi_register_power_resources(&port_dev->dev); return 0; diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index de7434b..47d77d4 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -62,6 +62,8 @@ extern void usb_major_cleanup(void); extern int usb_hub_create_port_device(struct device *intfdev, int port1, struct usb_port *port_dev); +extern int usb_hub_set_port_power(struct usb_device *hdev, + int port1, bool set); #ifdef CONFIG_PM diff --git a/include/linux/usb.h b/include/linux/usb.h index c1f1346..71510bf 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -578,12 +578,14 @@ struct usb_device { * @dev: generic device interface * @port_owner: port's owner * @connect_type: port's connect type + * @portnum: port index num based one */ struct usb_port { struct usb_device *child; struct device dev; struct dev_state *port_owner; enum usb_port_connect_type connect_type; + u8 portnum; }; #define to_usb_port(_dev) \ container_of(_dev, struct usb_port, dev) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH v2 4/6] usb: add usb port auto power off mechanism
This patch is to add usb port auto power off mechanism. When usb device is suspending, usb core will suspend usb port and usb port runtime pm callback will clear PORT_POWER feature to power off port if all conditions were met.These conditions are remote wakeup disable, pm qos NO_POWER_OFF flag clear and persist enable. When device is suspended and power off, usb core will ignore port's connect and enable change event to keep the device not being disconnected. When it resumes, power on port again. Signed-off-by: Lan Tianyu --- drivers/usb/core/hub.c | 76 +-- drivers/usb/core/port.c |1 + include/linux/usb.h |2 ++ 3 files changed, 76 insertions(+), 3 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 2cb414e..267e9d7 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -159,11 +160,14 @@ MODULE_PARM_DESC(use_both_schemes, DECLARE_RWSEM(ehci_cf_port_reset_rwsem); EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem); +#define HUB_PORT_RECONNECT_TRIES 20 + #define HUB_DEBOUNCE_TIMEOUT 1500 #define HUB_DEBOUNCE_STEP25 #define HUB_DEBOUNCE_STABLE 100 static int usb_reset_and_verify_device(struct usb_device *udev); +static int hub_port_debounce(struct usb_hub *hub, int port1); static inline char *portspeed(struct usb_hub *hub, int portstatus) { @@ -855,7 +859,11 @@ static unsigned hub_power_on(struct usb_hub *hub, bool do_delay) dev_dbg(hub->intfdev, "trying to enable port power on " "non-switchable hub\n"); for (port1 = 1; port1 <= hub->descriptor->bNbrPorts; port1++) - set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); + if (hub->ports[port1 - 1]->power_on) + set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); + else + clear_port_feature(hub->hdev, port1, + USB_PORT_FEAT_POWER); /* Wait at least 100 msec for power to become stable */ delay = max(pgood_delay, (unsigned) 100); @@ -2852,6 +2860,7 @@ EXPORT_SYMBOL_GPL(usb_enable_ltm); int usb_port_suspend(struct usb_device *udev, pm_message_t msg) { struct usb_hub *hub = hdev_to_hub(udev->parent); + struct usb_port *port_dev = hub->ports[udev->portnum - 1]; int port1 = udev->portnum; int status; @@ -2946,6 +2955,19 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) udev->port_is_suspended = 1; msleep(10); } + + /* +* Check whether current status is meeting requirement of +* usb port power off mechanism +*/ + if (!udev->do_remote_wakeup + && (dev_pm_qos_flags(&port_dev->dev, + PM_QOS_FLAG_NO_POWER_OFF) != PM_QOS_FLAGS_ALL) + && udev->persist_enabled + && !status) + if (!pm_runtime_put_sync(&port_dev->dev)) + port_dev->power_on = false; + usb_mark_last_busy(hub->hdev); return status; } @@ -3029,6 +3051,25 @@ static int finish_port_resume(struct usb_device *udev) return status; } +static int usb_port_wait_for_connected(struct usb_hub *hub, int port1) +{ + int status, i; + + for (i = 0; i < HUB_PORT_RECONNECT_TRIES; i++) { + status = hub_port_debounce(hub, port1); + if (status & USB_PORT_STAT_CONNECTION) { + /* +* just clear enable-change feature since debounce +* has cleared connect-change feature. +*/ + clear_port_feature(hub->hdev, port1, + USB_PORT_FEAT_C_ENABLE); + return 0; + } + } + return -ETIMEDOUT; +} + /* * usb_port_resume - re-activate a suspended usb device's upstream port * @udev: device to re-activate, not a root hub @@ -3066,10 +3107,36 @@ static int finish_port_resume(struct usb_device *udev) int usb_port_resume(struct usb_device *udev, pm_message_t msg) { struct usb_hub *hub = hdev_to_hub(udev->parent); + struct usb_port *port_dev = hub->ports[udev->portnum - 1]; int port1 = udev->portnum; int status; u16 portchange, portstatus; + + set_bit(port1, hub->busy_bits); + + if (!port_dev->power_on) { + status = pm_runtime_get_sync(&port_dev->dev); + if (status) { + dev_dbg(&udev->dev, "can't resume usb port, status %d\n", + status); + return status; + } + + por
[RFC PATCH v2 5/6] usb: expose usb port's pm qos flags to user space
This patch is to expose usb port's pm qos flags(pm_qos_no_power_off, pm_qos_remote_wakeup) to user space. User can set pm_qos_no_power_off flag to prohibit the port from being power off. Signed-off-by: Lan Tianyu --- drivers/usb/core/port.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index b7388fd..5a7a833 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "usb.h" @@ -48,7 +49,7 @@ static const struct attribute_group *port_dev_group[] = { static void usb_port_device_release(struct device *dev) { struct usb_port *port_dev = to_usb_port(dev); - + dev_pm_qos_hide_flags(dev); usb_acpi_unregister_power_resources(dev); kfree(port_dev); } @@ -110,12 +111,19 @@ int usb_hub_create_port_device(struct device *intfdev, if (retval) goto error_register; + retval = dev_pm_qos_expose_flags(&port_dev->dev, + PM_QOS_FLAG_NO_POWER_OFF); + if (retval) + goto error_expose_pm_qos; + pm_runtime_set_active(&port_dev->dev); pm_runtime_enable(&port_dev->dev); usb_acpi_register_power_resources(&port_dev->dev); return 0; +error_expose_pm_qos: + device_del(&port_dev->dev); error_register: put_device(&port_dev->dev); return retval; -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH v2 6/6] usb: add usb port's pm qos flags request to change NO_POWER_OFF flag
Some usb devices can't be resumed correctly after power off. This patch is to add pm qos flags request to change NO_POWER_OFF and provide usb_device_allow_power_off() for device drivers to allow or prohibit usb core to power off the device. Signed-off-by: Lan Tianyu --- drivers/usb/core/hub.c | 36 drivers/usb/core/port.c | 12 include/linux/usb.h |3 +++ 3 files changed, 51 insertions(+) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 267e9d7..7aaac720 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -189,6 +189,42 @@ static struct usb_hub *hdev_to_hub(struct usb_device *hdev) return usb_get_intfdata(hdev->actconfig->interface[0]); } +/** + * usb_device_allow_power_off - Allow or prohibit power off device. + * @udev: target usb device + * @set: choice of allow or prohibit + * + * Clearing or setting usb port's pm qos flag PM_QOS_FLAG_NO_POWER_OFF + * to allow or prohibit target usb device to be power off. + */ +int usb_device_allow_power_off(struct usb_device *udev, bool set) +{ + struct usb_port *port_dev; + struct dev_pm_qos_request *pm_qos; + s32 value; + int ret; + + if (!udev->parent) + return -EINVAL; + + port_dev = + hdev_to_hub(udev->parent)->ports[udev->portnum - 1]; + pm_qos = &port_dev->pm_qos; + value = pm_qos->data.flr.flags; + + if (set) + value &= ~PM_QOS_FLAG_NO_POWER_OFF; + else + value |= PM_QOS_FLAG_NO_POWER_OFF; + + pm_runtime_get_sync(&port_dev->dev); + ret = dev_pm_qos_update_request(pm_qos, value); + pm_runtime_put(&port_dev->dev); + + return ret; +} +EXPORT_SYMBOL_GPL(usb_device_allow_power_off); + static int usb_device_supports_lpm(struct usb_device *udev) { /* USB 2.1 (and greater) devices indicate LPM support through diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index 5a7a833..077a494 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -49,6 +49,11 @@ static const struct attribute_group *port_dev_group[] = { static void usb_port_device_release(struct device *dev) { struct usb_port *port_dev = to_usb_port(dev); + + pm_runtime_get_sync(dev); + dev_pm_qos_remove_request(&port_dev->pm_qos); + pm_runtime_put(dev); + dev_pm_qos_hide_flags(dev); usb_acpi_unregister_power_resources(dev); kfree(port_dev); @@ -116,12 +121,19 @@ int usb_hub_create_port_device(struct device *intfdev, if (retval) goto error_expose_pm_qos; + retval = dev_pm_qos_add_request(&port_dev->dev, &port_dev->pm_qos, + DEV_PM_QOS_FLAGS, 0); + if (retval) + goto error_add_qos_request; + pm_runtime_set_active(&port_dev->dev); pm_runtime_enable(&port_dev->dev); usb_acpi_register_power_resources(&port_dev->dev); return 0; +error_add_qos_request: + pm_runtime_put(&port_dev->dev); error_expose_pm_qos: device_del(&port_dev->dev); error_register: diff --git a/include/linux/usb.h b/include/linux/usb.h index 8002640..aa201bd 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -21,6 +21,7 @@ #include/* for current && schedule_timeout */ #include/* for struct mutex */ #include /* for runtime PM */ +#include /* for PM Qos */ struct usb_device; struct usb_driver; @@ -577,6 +578,7 @@ struct usb_device { * @child: usb device attatched to the port * @dev: generic device interface * @port_owner: port's owner + * @pm_qos: port's pm qos flags request * @connect_type: port's connect type * @portnum: port index num based one * @power_on: port's power state @@ -585,6 +587,7 @@ struct usb_port { struct usb_device *child; struct device dev; struct dev_state *port_owner; + struct dev_pm_qos_request pm_qos; enum usb_port_connect_type connect_type; u8 portnum; bool power_on; -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[Resend PATCH V4 0/4] usb: expose DeviceRemovable to user space via sysfs attribute
Change since v1: [PATCH 3] Rename link file's name "child" to "device", add check of return value of sysfs_create_link() and handle error return value properly. Change since v2: [PATCH 1] fix a logic backward problem. Add changelog about change ehci root hub descriptors based on ACPI information. [PATCH 2] Add changelog about using ACPI inforatmion to set hub DeviceRemovable rather than xhci PORTSC. Change since v3 [PATCH 3] Add check of udev->parent before define "struct usb_port *port_dev" since if udev->parent is NULL, it would crash. This patchset is to set DeviceRemovable according ACPI information and create a new attribute "connect_type" under port device to expose port connect type to user space. Patch3 create two link files under port device and its child device to show their relationship under sysfs. Following patchset is based on the commit f7b1b18 "USB: EHCI: fix build error in ChipIdea host driver" USB: Set usb port's DeviceRemovable according acpi information in EHCI usb/xhci: set root hub's DeviceRemovable according to usb port connect type usb: Create link files between child device and usb port device. usb: Add "portX/connect_type" attribute to expose usb port's connect type Documentation/ABI/testing/sysfs-bus-usb |9 + drivers/usb/core/hub.c | 83 +++ drivers/usb/core/usb.h |4 drivers/usb/host/ehci-hub.c |9 + drivers/usb/host/xhci-hub.c | 19 +-- include/linux/usb.h |4 6 files changed, 122 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[Resend PATCH V4 1/4] USB: Set usb port's DeviceRemovable according acpi information in EHCI
ACPI provide "_PLD" and "_UPC" aml methods to describe usb port visibility and connectability. This patch is to use those information to change ehci root hub descriptors and set usb hub port's DeviceRemovable in the hub_configure(). When hub descriptor request is issued at first time, usb port device isn't created and usb port is not bound with acpi. So first hub descriptor request is not changed based on ACPI information. After usb port device being created, set hub port's DeviceRemovable according ACPI information and this also works for non-root hub. Signed-off-by: Lan Tianyu --- drivers/usb/core/hub.c | 23 +++ drivers/usb/core/usb.h |4 drivers/usb/host/ehci-hub.c |9 + include/linux/usb.h |4 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 90accde..706db5c 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1546,6 +1546,25 @@ static int hub_configure(struct usb_hub *hub, dev_err(hub->intfdev, "couldn't create port%d device.\n", i + 1); + if (!hub_is_superspeed(hdev)) { + for (i = 1; i <= hdev->maxchild; i++) + if (hub->ports[i - 1]->connect_type + == USB_PORT_CONNECT_TYPE_HARD_WIRED) + hub->descriptor->u.hs.DeviceRemovable[i/8] + |= 1 << (i%8); + } else { + u16 port_removable = + le16_to_cpu(hub->descriptor->u.ss.DeviceRemovable); + + for (i = 1; i <= hdev->maxchild; i++) + if (hub->ports[i - 1]->connect_type + == USB_PORT_CONNECT_TYPE_HARD_WIRED) + port_removable |= 1 << i; + + hub->descriptor->u.ss.DeviceRemovable = + cpu_to_le16(port_removable); + } + hub_activate(hub, HUB_INIT); return 0; @@ -5191,8 +5210,12 @@ usb_get_hub_port_connect_type(struct usb_device *hdev, int port1) { struct usb_hub *hub = hdev_to_hub(hdev); + if (!hub) + return USB_PORT_CONNECT_TYPE_UNKNOWN; + return hub->ports[port1 - 1]->connect_type; } +EXPORT_SYMBOL_GPL(usb_get_hub_port_connect_type); #ifdef CONFIG_ACPI /** diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 1c528c1..1633f6e 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -169,10 +169,6 @@ 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); #ifdef CONFIG_ACPI extern int usb_acpi_register(void); diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 4ccb97c..dd084b3 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c @@ -662,6 +662,7 @@ ehci_hub_descriptor ( struct usb_hub_descriptor *desc ) { int ports = HCS_N_PORTS (ehci->hcs_params); + int i; u16 temp; desc->bDescriptorType = 0x29; @@ -676,6 +677,14 @@ ehci_hub_descriptor ( memset(&desc->u.hs.DeviceRemovable[0], 0, temp); memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp); + for (i = 1; i <= ports; i++) { + if (usb_get_hub_port_connect_type( + ehci_to_hcd(ehci)->self.root_hub, i) + == USB_PORT_CONNECT_TYPE_HARD_WIRED) + desc->u.hs.DeviceRemovable[i/8] |= 1 << (i%8); + } + + temp = 0x0008; /* per-port overcurrent reporting */ if (HCS_PPC (ehci->hcs_params)) temp |= 0x0001; /* per-port power control */ diff --git a/include/linux/usb.h b/include/linux/usb.h index 689b14b..e996bb6 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -577,6 +577,10 @@ static inline struct usb_device *interface_to_usbdev(struct usb_interface *intf) return to_usb_device(intf->dev.parent); } +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 struct usb_device *usb_get_dev(struct usb_device *dev); extern void usb_put_dev(struct usb_device *dev); extern struct usb_device *usb_hub_find_child(struct usb_device *hdev, -- 1.7.9.5 -- To unsubscribe from this list: sen
[Resend PATCH V4 2/4] usb/xhci: set root hub's DeviceRemovable according to usb port connect type
This patch is to set xhci root hub's DeviceRemovable according to usb port's connect type which currently comes from ACPI information rather than xhci PORTSC register due to Windows prefers to ACPI information. If ACPI information was different with PORTSC, there would be a warning. Signed-off-by: Lan Tianyu --- drivers/usb/host/xhci-hub.c | 19 +-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index a686cf4..50a3c39 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -97,11 +97,18 @@ static void xhci_usb2_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, /* If a device is removable, PORTSC reports a 0, same as in the * hub descriptor DeviceRemovable bits. */ - if (portsc & PORT_DEV_REMOVE) + if (usb_get_hub_port_connect_type( + hcd->self.root_hub, i + 1) + == USB_PORT_CONNECT_TYPE_HARD_WIRED) { + if (!(portsc & PORT_DEV_REMOVE)) + xhci_warn(xhci, "usb2.0 port%d's connect type from ACPI is different with PORTSC register. ACPI returns hard-wired.\n", + i + 1); + /* This math is hairy because bit 0 of DeviceRemovable * is reserved, and bit 1 is for port 1, etc. */ port_removable[(i + 1) / 8] |= 1 << ((i + 1) % 8); + } } /* ch11.h defines a hub descriptor that has room for USB_MAXCHILDREN @@ -148,8 +155,16 @@ static void xhci_usb3_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, /* bit 0 is reserved, bit 1 is for port 1, etc. */ for (i = 0; i < ports; i++) { portsc = xhci_readl(xhci, xhci->usb3_ports[i]); - if (portsc & PORT_DEV_REMOVE) + + if (usb_get_hub_port_connect_type( + hcd->self.root_hub, i + 1) + == USB_PORT_CONNECT_TYPE_HARD_WIRED) { + if (!(portsc & PORT_DEV_REMOVE)) + xhci_warn(xhci, "usb3.0 port%d's connect type from ACPI is different with PORTSC register. ACPI returns hard-wired.\n", + i + 1); + port_removable |= 1 << (i + 1); + } } desc->u.ss.DeviceRemovable = cpu_to_le16(port_removable); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[Resend PATCH V4 4/4] usb: Add "portX/connect_type" attribute to expose usb port's connect type
Some platforms provide usb port connect types through ACPI. This patch is to add this new attribute to expose these information to user space. Signed-off-by: Lan Tianyu --- Documentation/ABI/testing/sysfs-bus-usb |9 +++ drivers/usb/core/hub.c | 43 +++ 2 files changed, 52 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-usb b/Documentation/ABI/testing/sysfs-bus-usb index b6fbe51..dad3533 100644 --- a/Documentation/ABI/testing/sysfs-bus-usb +++ b/Documentation/ABI/testing/sysfs-bus-usb @@ -227,3 +227,12 @@ Contact: Lan Tianyu Description: The /sys/bus/usb/devices/.../(hub interface)/portX is usb port device's sysfs directory. + +What: /sys/bus/usb/devices/.../(hub interface)/portX/connect_type +Date: November 2012 +Contact: Lan Tianyu +Description: + Some platforms provide usb port connect types through ACPI. + This attribute is to expose these information to user space. + The file will read "hotplug", "wired" and "not used" if the + information is available, and "unknown" otherwise. diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index e895bed..55c086e 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -98,6 +98,8 @@ struct usb_hub { struct usb_port **ports; }; +static const struct attribute_group *port_dev_group[]; + static inline int hub_is_superspeed(struct usb_device *hdev) { return (hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS); @@ -1267,6 +1269,7 @@ static int usb_hub_create_port_device(struct usb_hub *hub, hub->ports[port1 - 1] = port_dev; port_dev->dev.parent = hub->intfdev; + port_dev->dev.groups = port_dev_group; port_dev->dev.type = &usb_port_device_type; dev_set_name(&port_dev->dev, "port%d", port1); @@ -4758,6 +4761,46 @@ static int hub_thread(void *__unused) return 0; } +static ssize_t show_port_connect_type(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct usb_port *port_dev = to_usb_port(dev); + char *result; + + switch (port_dev->connect_type) { + case USB_PORT_CONNECT_TYPE_HOT_PLUG: + result = "hotplug"; + break; + case USB_PORT_CONNECT_TYPE_HARD_WIRED: + result = "hardwired"; + break; + case USB_PORT_NOT_USED: + result = "not used"; + break; + default: + result = "unknown"; + break; + } + + return sprintf(buf, "%s\n", result); +} +static DEVICE_ATTR(connect_type, S_IRUGO, show_port_connect_type, + NULL); + +static struct attribute *port_dev_attrs[] = { + &dev_attr_connect_type.attr, + NULL, +}; + +static struct attribute_group port_dev_attr_grp = { + .attrs = port_dev_attrs, +}; + +static const struct attribute_group *port_dev_group[] = { + &port_dev_attr_grp, + NULL, +}; + static const struct usb_device_id hub_id_table[] = { { .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_CLASS, -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[Resend PATCH V4 3/4] usb: Create link files between child device and usb port device.
To show the relationship between usb port and child device, add link file "port" under usb device's sysfs directoy and "device" under usb port device's sysfs directory. They are linked to each other. Signed-off-by: Lan Tianyu --- drivers/usb/core/hub.c | 26 ++ 1 file changed, 26 insertions(+) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 706db5c..e895bed 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -2041,6 +2041,14 @@ void usb_disconnect(struct usb_device **pdev) usb_disable_device(udev, 0); usb_hcd_synchronize_unlinks(udev); + if (udev->parent) { + struct usb_port *port_dev = + hdev_to_hub(udev->parent)->ports[udev->portnum - 1]; + + sysfs_remove_link(&udev->dev.kobj, "port"); + sysfs_remove_link(&port_dev->dev.kobj, "device"); + } + usb_remove_ep_devs(&udev->ep0); usb_unlock_device(udev); @@ -2333,6 +2341,24 @@ int usb_new_device(struct usb_device *udev) goto fail; } + /* Create link files between child device and usb port device. */ + if (udev->parent) { + struct usb_port *port_dev = + hdev_to_hub(udev->parent)->ports[udev->portnum - 1]; + + err = sysfs_create_link(&udev->dev.kobj, + &port_dev->dev.kobj, "port"); + if (err) + goto fail; + + err = sysfs_create_link(&port_dev->dev.kobj, + &udev->dev.kobj, "device"); + if (err) { + sysfs_remove_link(&udev->dev.kobj, "port"); + goto fail; + } + } + (void) usb_create_ep_devs(&udev->dev, &udev->ep0, udev); usb_mark_last_busy(udev); pm_runtime_put_sync_autosuspend(&udev->dev); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Sound+USB: deadlock problem
Hello, I've just plugged+unplugged+plugged my USB audio card and the audio subsystem got stuck: INFO: task khubd:440 blocked for more than 120 seconds. "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. khubd D 8801cbc92400 0 440 2 0x 8801c4ae3a38 0046 8801c49be270 8801c4ae3fd8 8801c4ae3fd8 8801c4ae3fd8 8801c4284830 8801c49be270 8801c4ae3a28 8801a7198758 8801a719875c 8801c49be270 Call Trace: [] schedule+0x29/0x70 [] schedule_preempt_disabled+0xe/0x10 [] __mutex_lock_slowpath+0xca/0x140 [] mutex_lock+0x2a/0x50 [] snd_pcm_dev_disconnect+0x46/0x1f0 [] snd_device_disconnect+0x62/0xa0 [] snd_device_disconnect_all+0x44/0x70 [] snd_card_disconnect+0x153/0x1d0 [] ? down_write+0x38/0x40 [] usb_audio_disconnect+0x88/0x1c0 [] usb_unbind_interface+0x60/0x1a0 [] __device_release_driver+0x7c/0xe0 [] device_release_driver+0x2c/0x40 [] bus_remove_device+0xee/0x160 [] device_del+0x11a/0x1b0 [] usb_disable_device+0xb0/0x270 [] usb_disconnect+0xad/0x160 [] hub_thread+0x6fe/0x1700 [] ? dequeue_task_fair+0xee/0x100 [] ? finish_wait+0x80/0x80 [] ? usb_remote_wakeup+0x70/0x70 [] kthread+0xc0/0xd0 [] ? kthread_create_on_node+0x130/0x130 [] ret_from_fork+0x7c/0xb0 [] ? kthread_create_on_node+0x130/0x130 INFO: task pulseaudio:4642 blocked for more than 120 seconds. "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. pulseaudio D 8801cbc12400 0 4642 1 0x 8801c1c39cf0 0082 8801c0d7d550 8801c1c39fd8 8801c1c39fd8 8801c1c39fd8 8801a7203480 8801c0d7d550 8801aa37b530 8801c0d7d550 8800ab118a48 fffe Call Trace: [] schedule+0x29/0x70 [] rwsem_down_failed_common+0xbd/0x150 [] rwsem_down_read_failed+0x15/0x17 [] call_rwsem_down_read_failed+0x14/0x30 [] ? down_read+0x24/0x2b [] snd_usb_hw_free+0x42/0x90 [] snd_pcm_release_substream+0x5b/0xc0 [] snd_pcm_release+0x48/0xb0 [] snd_disconnect_release+0x97/0xe0 [] __fput+0xec/0x230 [] fput+0xe/0x10 [] task_work_run+0xa7/0xe0 [] do_notify_resume+0x59/0x80 [] int_signal+0x12/0x17 INFO: task khubd:440 blocked for more than 120 seconds. "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. khubd D 8801cbc92400 0 440 2 0x 8801c4ae3a38 0046 8801c49be270 8801c4ae3fd8 8801c4ae3fd8 8801c4ae3fd8 8801c4284830 8801c49be270 8801c4ae3a28 8801a7198758 8801a719875c 8801c49be270 Call Trace: [] schedule+0x29/0x70 [] schedule_preempt_disabled+0xe/0x10 [] __mutex_lock_slowpath+0xca/0x140 [] mutex_lock+0x2a/0x50 [] snd_pcm_dev_disconnect+0x46/0x1f0 [] snd_device_disconnect+0x62/0xa0 [] snd_device_disconnect_all+0x44/0x70 [] snd_card_disconnect+0x153/0x1d0 [] ? down_write+0x38/0x40 [] usb_audio_disconnect+0x88/0x1c0 [] usb_unbind_interface+0x60/0x1a0 [] __device_release_driver+0x7c/0xe0 [] device_release_driver+0x2c/0x40 [] bus_remove_device+0xee/0x160 [] device_del+0x11a/0x1b0 [] usb_disable_device+0xb0/0x270 [] usb_disconnect+0xad/0x160 [] hub_thread+0x6fe/0x1700 [] ? dequeue_task_fair+0xee/0x100 [] ? finish_wait+0x80/0x80 [] ? usb_remote_wakeup+0x70/0x70 [] kthread+0xc0/0xd0 [] ? kthread_create_on_node+0x130/0x130 [] ret_from_fork+0x7c/0xb0 [] ? kthread_create_on_node+0x130/0x130 sadcD 8801cbc92400 0 7883 7870 0x0004 8801b9ab5d98 0082 8801087b0d20 8801b9ab5fd8 8801b9ab5fd8 8801b9ab5fd8 8801c487c830 8801087b0d20 8801c0ca5380 8801b99b08e8 8801b99b08ec 8801087b0d20 Call Trace: [] schedule+0x29/0x70 [] schedule_preempt_disabled+0xe/0x10 [] __mutex_lock_slowpath+0xca/0x140 [] mutex_lock+0x2a/0x50 [] show_manufacturer+0x2b/0x60 [] dev_attr_show+0x20/0x60 [] ? __get_free_pages+0x17/0x50 [] sysfs_read_file+0xa5/0x1c0 [] vfs_read+0xa9/0x180 [] sys_read+0x52/0xa0 [] system_call_fastpath+0x16/0x1b thanks, -- js suse labs -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Sound+USB: deadlock problem
At Tue, 13 Nov 2012 09:26:17 +0100, Jiri Slaby wrote: > > Hello, > > I've just plugged+unplugged+plugged my USB audio card and the audio > subsystem got stuck: Which kernel? If it's older than 3.7-rc5, could you try 3.7-rc5? Takashi > > INFO: task khubd:440 blocked for more than 120 seconds. > "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. > khubd D 8801cbc92400 0 440 2 0x > 8801c4ae3a38 0046 8801c49be270 8801c4ae3fd8 > 8801c4ae3fd8 8801c4ae3fd8 8801c4284830 8801c49be270 > 8801c4ae3a28 8801a7198758 8801a719875c 8801c49be270 > Call Trace: > [] schedule+0x29/0x70 > [] schedule_preempt_disabled+0xe/0x10 > [] __mutex_lock_slowpath+0xca/0x140 > [] mutex_lock+0x2a/0x50 > [] snd_pcm_dev_disconnect+0x46/0x1f0 > [] snd_device_disconnect+0x62/0xa0 > [] snd_device_disconnect_all+0x44/0x70 > [] snd_card_disconnect+0x153/0x1d0 > [] ? down_write+0x38/0x40 > [] usb_audio_disconnect+0x88/0x1c0 > [] usb_unbind_interface+0x60/0x1a0 > [] __device_release_driver+0x7c/0xe0 > [] device_release_driver+0x2c/0x40 > [] bus_remove_device+0xee/0x160 > [] device_del+0x11a/0x1b0 > [] usb_disable_device+0xb0/0x270 > [] usb_disconnect+0xad/0x160 > [] hub_thread+0x6fe/0x1700 > [] ? dequeue_task_fair+0xee/0x100 > [] ? finish_wait+0x80/0x80 > [] ? usb_remote_wakeup+0x70/0x70 > [] kthread+0xc0/0xd0 > [] ? kthread_create_on_node+0x130/0x130 > [] ret_from_fork+0x7c/0xb0 > [] ? kthread_create_on_node+0x130/0x130 > INFO: task pulseaudio:4642 blocked for more than 120 seconds. > "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. > pulseaudio D 8801cbc12400 0 4642 1 0x > 8801c1c39cf0 0082 8801c0d7d550 8801c1c39fd8 > 8801c1c39fd8 8801c1c39fd8 8801a7203480 8801c0d7d550 > 8801aa37b530 8801c0d7d550 8800ab118a48 fffe > Call Trace: > [] schedule+0x29/0x70 > [] rwsem_down_failed_common+0xbd/0x150 > [] rwsem_down_read_failed+0x15/0x17 > [] call_rwsem_down_read_failed+0x14/0x30 > [] ? down_read+0x24/0x2b > [] snd_usb_hw_free+0x42/0x90 > [] snd_pcm_release_substream+0x5b/0xc0 > [] snd_pcm_release+0x48/0xb0 > [] snd_disconnect_release+0x97/0xe0 > [] __fput+0xec/0x230 > [] fput+0xe/0x10 > [] task_work_run+0xa7/0xe0 > [] do_notify_resume+0x59/0x80 > [] int_signal+0x12/0x17 > INFO: task khubd:440 blocked for more than 120 seconds. > "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. > khubd D 8801cbc92400 0 440 2 0x > 8801c4ae3a38 0046 8801c49be270 8801c4ae3fd8 > 8801c4ae3fd8 8801c4ae3fd8 8801c4284830 8801c49be270 > 8801c4ae3a28 8801a7198758 8801a719875c 8801c49be270 > Call Trace: > [] schedule+0x29/0x70 > [] schedule_preempt_disabled+0xe/0x10 > [] __mutex_lock_slowpath+0xca/0x140 > [] mutex_lock+0x2a/0x50 > [] snd_pcm_dev_disconnect+0x46/0x1f0 > [] snd_device_disconnect+0x62/0xa0 > [] snd_device_disconnect_all+0x44/0x70 > [] snd_card_disconnect+0x153/0x1d0 > [] ? down_write+0x38/0x40 > [] usb_audio_disconnect+0x88/0x1c0 > [] usb_unbind_interface+0x60/0x1a0 > [] __device_release_driver+0x7c/0xe0 > [] device_release_driver+0x2c/0x40 > [] bus_remove_device+0xee/0x160 > [] device_del+0x11a/0x1b0 > [] usb_disable_device+0xb0/0x270 > [] usb_disconnect+0xad/0x160 > [] hub_thread+0x6fe/0x1700 > [] ? dequeue_task_fair+0xee/0x100 > [] ? finish_wait+0x80/0x80 > [] ? usb_remote_wakeup+0x70/0x70 > [] kthread+0xc0/0xd0 > [] ? kthread_create_on_node+0x130/0x130 > [] ret_from_fork+0x7c/0xb0 > [] ? kthread_create_on_node+0x130/0x130 > sadcD 8801cbc92400 0 7883 7870 0x0004 > 8801b9ab5d98 0082 8801087b0d20 8801b9ab5fd8 > 8801b9ab5fd8 8801b9ab5fd8 8801c487c830 8801087b0d20 > 8801c0ca5380 8801b99b08e8 8801b99b08ec 8801087b0d20 > Call Trace: > [] schedule+0x29/0x70 > [] schedule_preempt_disabled+0xe/0x10 > [] __mutex_lock_slowpath+0xca/0x140 > [] mutex_lock+0x2a/0x50 > [] show_manufacturer+0x2b/0x60 > [] dev_attr_show+0x20/0x60 > [] ? __get_free_pages+0x17/0x50 > [] sysfs_read_file+0xa5/0x1c0 > [] vfs_read+0xa9/0x180 > [] sys_read+0x52/0xa0 > [] system_call_fastpath+0x16/0x1b > > > thanks, > -- > js > suse labs > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Sound+USB: deadlock problem
On 11/13/2012 09:28 AM, Takashi Iwai wrote: > At Tue, 13 Nov 2012 09:26:17 +0100, > Jiri Slaby wrote: >> >> Hello, >> >> I've just plugged+unplugged+plugged my USB audio card and the audio >> subsystem got stuck: > > Which kernel? If it's older than 3.7-rc5, could you try 3.7-rc5? Oh, forgot to mention: 3.7.0-rc5-next-20121112_64+ thanks, -- js suse labs -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: autodetect USB MTP device characteristics without libusb_open()
Peter Stuge writes: > Bjørn Mork wrote: >> > The problem appear when you ask a device which is not MTP >> > for that descriptor, some of them just die, so I cannot do >> > that. >> >> Really? You ask for a string descriptor and the device dies? Won't >> those devices also die if they are connected to a Windows system? > > Yes, but only once. Windows stores an entry in the registry for every > device plugged into the system, and the MOD will only be requested > the very first time a given device is attached, *or* if the device > returned a MOD for a previous request. > > So the user unplugs and replugs (or reboots) and then the device works. OK, that seems like the sane way to handle anything like that, if you want to handle it at all. And there is absolutely no reason why Linux should do it differently. A userspace tool like the mtp tools could do the exact same by writing a new udev rule for the crashing device. There is no reason to hardcode these kind of really, really, really buggy device workarounds, making other devices suffer because you are afraid to request descriptors. Bjørn -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Sound+USB: deadlock problem
At Tue, 13 Nov 2012 09:30:10 +0100, Jiri Slaby wrote: > > On 11/13/2012 09:28 AM, Takashi Iwai wrote: > > At Tue, 13 Nov 2012 09:26:17 +0100, > > Jiri Slaby wrote: > >> > >> Hello, > >> > >> I've just plugged+unplugged+plugged my USB audio card and the audio > >> subsystem got stuck: > > > > Which kernel? If it's older than 3.7-rc5, could you try 3.7-rc5? > > Oh, forgot to mention: > 3.7.0-rc5-next-20121112_64+ Through a quick glance, one of mutex locks seems stuck. Just a blind short -- does the patch below cure the problem? thanks, Takashi --- diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 030102c..a66a7ca 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -1086,7 +1086,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) if (list_empty(&pcm->list)) goto unlock; - mutex_lock(&pcm->open_mutex); + /* mutex_lock(&pcm->open_mutex); */ wake_up(&pcm->open_wait); list_del_init(&pcm->list); for (cidx = 0; cidx < 2; cidx++) @@ -1118,7 +1118,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) pcm->streams[cidx].chmap_kctl = NULL; } } - mutex_unlock(&pcm->open_mutex); + /* mutex_unlock(&pcm->open_mutex); */ unlock: mutex_unlock(®ister_mutex); return 0; -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Sound+USB: deadlock problem
On 11/13/2012 09:45 AM, Takashi Iwai wrote: > At Tue, 13 Nov 2012 09:30:10 +0100, > Jiri Slaby wrote: >> >> On 11/13/2012 09:28 AM, Takashi Iwai wrote: >>> At Tue, 13 Nov 2012 09:26:17 +0100, >>> Jiri Slaby wrote: Hello, I've just plugged+unplugged+plugged my USB audio card and the audio subsystem got stuck: >>> >>> Which kernel? If it's older than 3.7-rc5, could you try 3.7-rc5? >> >> Oh, forgot to mention: >> 3.7.0-rc5-next-20121112_64+ > > Through a quick glance, one of mutex locks seems stuck. > Just a blind short -- does the patch below cure the problem? Yes, this helps. Adding a LOCKDEP splash _before_ applying the patch: == [ INFO: possible circular locking dependency detected ] 3.7.0-rc5-next-20121112_64-ldep+ #15 Not tainted --- khubd/446 is trying to acquire lock: (&pcm->open_mutex){+.+.+.}, at: [] snd_pcm_dev_disconnect+0x45/0x1f0 but task is already holding lock: (register_mutex#2){+.+.+.}, at: [] snd_pcm_dev_disconnect+0x23/0x1f0 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (register_mutex#2){+.+.+.}: [] lock_acquire+0x5a/0x70 [] mutex_lock_nested+0x69/0x3a0 [] snd_pcm_dev_disconnect+0x23/0x1f0 [] snd_device_disconnect+0x62/0xa0 [] snd_device_disconnect_all+0x3c/0x60 [] snd_card_disconnect+0x147/0x1d0 [] usb_audio_disconnect+0x98/0x1d0 [] usb_unbind_interface+0x5e/0x1a0 [] __device_release_driver+0x77/0xe0 [] device_release_driver+0x29/0x40 [] bus_remove_device+0xfa/0x170 [] device_del+0x127/0x1c0 [] usb_disable_device+0xb0/0x270 [] usb_disconnect+0xad/0x160 [] hub_thread+0x71c/0x1730 [] kthread+0xd6/0xe0 [] ret_from_fork+0x7c/0xb0 -> #1 (&chip->shutdown_rwsem){++}: [] lock_acquire+0x5a/0x70 [] down_read+0x47/0x5c [] snd_usb_autoresume+0x2c/0x60 [] snd_usb_pcm_open+0x20f/0x4a0 [] snd_usb_playback_open+0xb/0x10 [] snd_pcm_open_substream+0x4e/0x90 [] snd_pcm_open+0xb2/0x250 [] snd_pcm_playback_open+0x43/0x70 [] snd_open+0xba/0x200 [] chrdev_open+0x96/0x1c0 [] do_dentry_open.isra.16+0x1e6/0x280 [] finish_open+0x36/0x70 [] do_last.isra.64+0x2ce/0xcc0 [] path_openat.isra.65+0xb3/0x4d0 [] do_filp_open+0x3c/0x90 [] do_sys_open+0xef/0x1d0 [] sys_open+0x1c/0x20 [] system_call_fastpath+0x16/0x1b -> #0 (&pcm->open_mutex){+.+.+.}: [] __lock_acquire+0x1c38/0x1c40 [] lock_acquire+0x5a/0x70 [] mutex_lock_nested+0x69/0x3a0 [] snd_pcm_dev_disconnect+0x45/0x1f0 [] snd_device_disconnect+0x62/0xa0 [] snd_device_disconnect_all+0x3c/0x60 [] snd_card_disconnect+0x147/0x1d0 [] usb_audio_disconnect+0x98/0x1d0 [] usb_unbind_interface+0x5e/0x1a0 [] __device_release_driver+0x77/0xe0 [] device_release_driver+0x29/0x40 [] bus_remove_device+0xfa/0x170 [] device_del+0x127/0x1c0 [] usb_disable_device+0xb0/0x270 [] usb_disconnect+0xad/0x160 [] hub_thread+0x71c/0x1730 [] kthread+0xd6/0xe0 [] ret_from_fork+0x7c/0xb0 other info that might help us debug this: Chain exists of: &pcm->open_mutex --> &chip->shutdown_rwsem --> register_mutex#2 Possible unsafe locking scenario: CPU0CPU1 lock(register_mutex#2); lock(&chip->shutdown_rwsem); lock(register_mutex#2); lock(&pcm->open_mutex); *** DEADLOCK *** 6 locks held by khubd/446: #0: (&__lockdep_no_validate__){..}, at: [] hub_thread+0xde/0x1730 #1: (&__lockdep_no_validate__){..}, at: [] usb_disconnect+0x61/0x160 #2: (&__lockdep_no_validate__){..}, at: [] device_release_driver+0x21/0x40 #3: (register_mutex#5){+.+.+.}, at: [] usb_audio_disconnect+0x35/0x1d0 #4: (&chip->shutdown_rwsem){++}, at: [] usb_audio_disconnect+0x45/0x1d0 #5: (register_mutex#2){+.+.+.}, at: [] snd_pcm_dev_disconnect+0x23/0x1f0 stack backtrace: Pid: 446, comm: khubd Not tainted 3.7.0-rc5-next-20121112_64-ldep+ #15 Call Trace: [] print_circular_bug+0x1fb/0x20c [] __lock_acquire+0x1c38/0x1c40 [] ? snd_unregister_oss_device+0x9e/0x120 [] lock_acquire+0x5a/0x70 [] ? snd_pcm_dev_disconnect+0x45/0x1f0 [] mutex_lock_nested+0x69/0x3a0 [] ? snd_pcm_dev_disconnect+0x45/0x1f0 [] snd_pcm_dev_disconnect+0x45/0x1f0 [] snd_device_disconnect+0x62/0xa0 [] snd_device_disconnect_all+0x3c/0x60 [] snd_card_disconnect+0x147/0x1d0 [] usb_audio_disconnect+0x98/0x1d0 [] usb_unbind_interface+0x5e/0x1a0 [] __device_release_driver+0x77/0xe0 [] device_release_driver+0x29/0x40 [] bus_remove_device+0xfa/0x170 [] device_del+0x127/0x1c0 [] ? usb_disconnect+0x61/0x160 [] usb_disable_device+0xb0/0x270 []
[PATCH] usb: otg: twl4030: Change TWL4030_MODULE_* ids to TWL_MODULE_*
To facilitate upcoming cleanup in twl stack. No functional changes. Signed-off-by: Peter Ujfalusi --- drivers/usb/otg/twl4030-usb.c | 46 --- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c index f0d2e75..11b2a12 100644 --- a/drivers/usb/otg/twl4030-usb.c +++ b/drivers/usb/otg/twl4030-usb.c @@ -123,10 +123,10 @@ #define PHY_CLK_CTRL_STS 0xFF #define PHY_DPLL_CLK (1 << 0) -/* In module TWL4030_MODULE_PM_MASTER */ +/* In module TWL_MODULE_PM_MASTER */ #define STS_HW_CONDITIONS 0x0F -/* In module TWL4030_MODULE_PM_RECEIVER */ +/* In module TWL_MODULE_PM_RECEIVER */ #define VUSB_DEDICATED10x7D #define VUSB_DEDICATED20x7E #define VUSB1V5_DEV_GRP0x71 @@ -195,14 +195,14 @@ static int twl4030_i2c_write_u8_verify(struct twl4030_usb *twl, } #define twl4030_usb_write_verify(twl, address, data) \ - twl4030_i2c_write_u8_verify(twl, TWL4030_MODULE_USB, (data), (address)) + twl4030_i2c_write_u8_verify(twl, TWL_MODULE_USB, (data), (address)) static inline int twl4030_usb_write(struct twl4030_usb *twl, u8 address, u8 data) { int ret = 0; - ret = twl_i2c_write_u8(TWL4030_MODULE_USB, data, address); + ret = twl_i2c_write_u8(TWL_MODULE_USB, data, address); if (ret < 0) dev_dbg(twl->dev, "TWL4030:USB:Write[0x%x] Error %d\n", address, ret); @@ -227,7 +227,7 @@ static inline int twl4030_readb(struct twl4030_usb *twl, u8 module, u8 address) static inline int twl4030_usb_read(struct twl4030_usb *twl, u8 address) { - return twl4030_readb(twl, TWL4030_MODULE_USB, address); + return twl4030_readb(twl, TWL_MODULE_USB, address); } /*-*/ @@ -264,8 +264,7 @@ static enum omap_musb_vbus_id_status * signal is active, the OTG module is activated, and * its interrupt may be raised (may wake the system). */ - status = twl4030_readb(twl, TWL4030_MODULE_PM_MASTER, - STS_HW_CONDITIONS); + status = twl4030_readb(twl, TWL_MODULE_PM_MASTER, STS_HW_CONDITIONS); if (status < 0) dev_err(twl->dev, "USB link status err %d\n", status); else if (status & (BIT(7) | BIT(2))) { @@ -372,8 +371,7 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on) * SLEEP. We work around this by clearing the bit after usv3v1 * is re-activated. This ensures that VUSB3V1 is really active. */ - twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, - VUSB_DEDICATED2); + twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2); regulator_enable(twl->usb1v5); __twl4030_phy_power(twl, 1); twl4030_usb_write(twl, PHY_CLK_CTRL, @@ -419,50 +417,48 @@ static void twl4030_phy_resume(struct twl4030_usb *twl) static int twl4030_usb_ldo_init(struct twl4030_usb *twl) { /* Enable writing to power configuration registers */ - twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, - TWL4030_PM_MASTER_KEY_CFG1, - TWL4030_PM_MASTER_PROTECT_KEY); + twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1, +TWL4030_PM_MASTER_PROTECT_KEY); - twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, - TWL4030_PM_MASTER_KEY_CFG2, - TWL4030_PM_MASTER_PROTECT_KEY); + twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG2, +TWL4030_PM_MASTER_PROTECT_KEY); /* Keep VUSB3V1 LDO in sleep state until VBUS/ID change detected*/ - /*twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);*/ + /*twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);*/ /* input to VUSB3V1 LDO is from VBAT, not VBUS */ - twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1); + twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1); /* Initialize 3.1V regulator */ - twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP); + twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP); twl->usb3v1 = regulator_get(twl->dev, "usb3v1"); if (IS_ERR(twl->usb3v1)) return -ENODEV; - twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_TYPE); + twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB3V1_TYPE); /* Initialize 1.5V regulator */ - twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V5_DEV_GRP); + twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V5_DEV_GRP); twl
Re: [PATCH] usb: otg: twl4030: Change TWL4030_MODULE_* ids to TWL_MODULE_*
On Tue, Nov 13, 2012 at 10:43:38AM +0100, Peter Ujfalusi wrote: > To facilitate upcoming cleanup in twl stack. > No functional changes. > > Signed-off-by: Peter Ujfalusi I guess this one must go together with the rest of your series... Acked-by: Felipe Balbi > --- > drivers/usb/otg/twl4030-usb.c | 46 > --- > 1 file changed, 21 insertions(+), 25 deletions(-) > > diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c > index f0d2e75..11b2a12 100644 > --- a/drivers/usb/otg/twl4030-usb.c > +++ b/drivers/usb/otg/twl4030-usb.c > @@ -123,10 +123,10 @@ > #define PHY_CLK_CTRL_STS 0xFF > #define PHY_DPLL_CLK (1 << 0) > > -/* In module TWL4030_MODULE_PM_MASTER */ > +/* In module TWL_MODULE_PM_MASTER */ > #define STS_HW_CONDITIONS0x0F > > -/* In module TWL4030_MODULE_PM_RECEIVER */ > +/* In module TWL_MODULE_PM_RECEIVER */ > #define VUSB_DEDICATED1 0x7D > #define VUSB_DEDICATED2 0x7E > #define VUSB1V5_DEV_GRP 0x71 > @@ -195,14 +195,14 @@ static int twl4030_i2c_write_u8_verify(struct > twl4030_usb *twl, > } > > #define twl4030_usb_write_verify(twl, address, data) \ > - twl4030_i2c_write_u8_verify(twl, TWL4030_MODULE_USB, (data), (address)) > + twl4030_i2c_write_u8_verify(twl, TWL_MODULE_USB, (data), (address)) > > static inline int twl4030_usb_write(struct twl4030_usb *twl, > u8 address, u8 data) > { > int ret = 0; > > - ret = twl_i2c_write_u8(TWL4030_MODULE_USB, data, address); > + ret = twl_i2c_write_u8(TWL_MODULE_USB, data, address); > if (ret < 0) > dev_dbg(twl->dev, > "TWL4030:USB:Write[0x%x] Error %d\n", address, ret); > @@ -227,7 +227,7 @@ static inline int twl4030_readb(struct twl4030_usb *twl, > u8 module, u8 address) > > static inline int twl4030_usb_read(struct twl4030_usb *twl, u8 address) > { > - return twl4030_readb(twl, TWL4030_MODULE_USB, address); > + return twl4030_readb(twl, TWL_MODULE_USB, address); > } > > /*-*/ > @@ -264,8 +264,7 @@ static enum omap_musb_vbus_id_status >* signal is active, the OTG module is activated, and >* its interrupt may be raised (may wake the system). >*/ > - status = twl4030_readb(twl, TWL4030_MODULE_PM_MASTER, > - STS_HW_CONDITIONS); > + status = twl4030_readb(twl, TWL_MODULE_PM_MASTER, STS_HW_CONDITIONS); > if (status < 0) > dev_err(twl->dev, "USB link status err %d\n", status); > else if (status & (BIT(7) | BIT(2))) { > @@ -372,8 +371,7 @@ static void twl4030_phy_power(struct twl4030_usb *twl, > int on) >* SLEEP. We work around this by clearing the bit after usv3v1 >* is re-activated. This ensures that VUSB3V1 is really active. >*/ > - twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, > - VUSB_DEDICATED2); > + twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2); > regulator_enable(twl->usb1v5); > __twl4030_phy_power(twl, 1); > twl4030_usb_write(twl, PHY_CLK_CTRL, > @@ -419,50 +417,48 @@ static void twl4030_phy_resume(struct twl4030_usb *twl) > static int twl4030_usb_ldo_init(struct twl4030_usb *twl) > { > /* Enable writing to power configuration registers */ > - twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, > - TWL4030_PM_MASTER_KEY_CFG1, > - TWL4030_PM_MASTER_PROTECT_KEY); > + twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1, > + TWL4030_PM_MASTER_PROTECT_KEY); > > - twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, > - TWL4030_PM_MASTER_KEY_CFG2, > - TWL4030_PM_MASTER_PROTECT_KEY); > + twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG2, > + TWL4030_PM_MASTER_PROTECT_KEY); > > /* Keep VUSB3V1 LDO in sleep state until VBUS/ID change detected*/ > - /*twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);*/ > + /*twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);*/ > > /* input to VUSB3V1 LDO is from VBAT, not VBUS */ > - twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1); > + twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1); > > /* Initialize 3.1V regulator */ > - twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP); > + twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP); > > twl->usb3v1 = regulator_get(twl->dev, "usb3v1"); > if (IS_ERR(twl->usb3v1)) > return -ENODEV; > > - twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_TYPE); > + twl_
Re: Sound+USB: deadlock problem
At Tue, 13 Nov 2012 10:39:14 +0100, Jiri Slaby wrote: > > On 11/13/2012 09:45 AM, Takashi Iwai wrote: > > At Tue, 13 Nov 2012 09:30:10 +0100, > > Jiri Slaby wrote: > >> > >> On 11/13/2012 09:28 AM, Takashi Iwai wrote: > >>> At Tue, 13 Nov 2012 09:26:17 +0100, > >>> Jiri Slaby wrote: > > Hello, > > I've just plugged+unplugged+plugged my USB audio card and the audio > subsystem got stuck: > >>> > >>> Which kernel? If it's older than 3.7-rc5, could you try 3.7-rc5? > >> > >> Oh, forgot to mention: > >> 3.7.0-rc5-next-20121112_64+ > > > > Through a quick glance, one of mutex locks seems stuck. > > Just a blind short -- does the patch below cure the problem? > > Yes, this helps. > > Adding a LOCKDEP splash _before_ applying the patch: Thanks, this helps much for understanding the cause. It's a new rwsem in the usb-audio driver that deadlocks. Although the previous patch fixes the deadlock it opens the race again. Could you try the patch below instead? The rwsem above doesn't have to be taken for the whole operation, but just needs to protect for turning on the flag. The patch below should suffice for protecting races but avoids the deadlock. Takashi --- diff --git a/sound/usb/card.c b/sound/usb/card.c index 282f0fc..dbf7999 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -559,9 +559,11 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, return; card = chip->card; - mutex_lock(®ister_mutex); down_write(&chip->shutdown_rwsem); chip->shutdown = 1; + up_write(&chip->shutdown_rwsem); + + mutex_lock(®ister_mutex); chip->num_interfaces--; if (chip->num_interfaces <= 0) { snd_card_disconnect(card); @@ -582,11 +584,9 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, snd_usb_mixer_disconnect(p); } usb_chip[chip->index] = NULL; - up_write(&chip->shutdown_rwsem); mutex_unlock(®ister_mutex); snd_card_free_when_closed(card); } else { - up_write(&chip->shutdown_rwsem); mutex_unlock(®ister_mutex); } } -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: otg: twl4030: Change TWL4030_MODULE_* ids to TWL_MODULE_*
Hi Felipe, On 11/13/2012 10:47 AM, Felipe Balbi wrote: > On Tue, Nov 13, 2012 at 10:43:38AM +0100, Peter Ujfalusi wrote: >> To facilitate upcoming cleanup in twl stack. >> No functional changes. >> >> Signed-off-by: Peter Ujfalusi > > I guess this one must go together with the rest of your series... I made the split between the patches and they are good to go in their separate ways to avoid cross tree hassle. All of the defines were in place originally but they were used in non consistent ways. All of these will help in the future to clean up the twl core without breaking the child drivers. -- Péter > Acked-by: Felipe Balbi > >> --- >> drivers/usb/otg/twl4030-usb.c | 46 >> --- >> 1 file changed, 21 insertions(+), 25 deletions(-) >> >> diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c >> index f0d2e75..11b2a12 100644 >> --- a/drivers/usb/otg/twl4030-usb.c >> +++ b/drivers/usb/otg/twl4030-usb.c >> @@ -123,10 +123,10 @@ >> #define PHY_CLK_CTRL_STS0xFF >> #define PHY_DPLL_CLK(1 << 0) >> >> -/* In module TWL4030_MODULE_PM_MASTER */ >> +/* In module TWL_MODULE_PM_MASTER */ >> #define STS_HW_CONDITIONS 0x0F >> >> -/* In module TWL4030_MODULE_PM_RECEIVER */ >> +/* In module TWL_MODULE_PM_RECEIVER */ >> #define VUSB_DEDICATED1 0x7D >> #define VUSB_DEDICATED2 0x7E >> #define VUSB1V5_DEV_GRP 0x71 >> @@ -195,14 +195,14 @@ static int twl4030_i2c_write_u8_verify(struct >> twl4030_usb *twl, >> } >> >> #define twl4030_usb_write_verify(twl, address, data)\ >> -twl4030_i2c_write_u8_verify(twl, TWL4030_MODULE_USB, (data), (address)) >> +twl4030_i2c_write_u8_verify(twl, TWL_MODULE_USB, (data), (address)) >> >> static inline int twl4030_usb_write(struct twl4030_usb *twl, >> u8 address, u8 data) >> { >> int ret = 0; >> >> -ret = twl_i2c_write_u8(TWL4030_MODULE_USB, data, address); >> +ret = twl_i2c_write_u8(TWL_MODULE_USB, data, address); >> if (ret < 0) >> dev_dbg(twl->dev, >> "TWL4030:USB:Write[0x%x] Error %d\n", address, ret); >> @@ -227,7 +227,7 @@ static inline int twl4030_readb(struct twl4030_usb *twl, >> u8 module, u8 address) >> >> static inline int twl4030_usb_read(struct twl4030_usb *twl, u8 address) >> { >> -return twl4030_readb(twl, TWL4030_MODULE_USB, address); >> +return twl4030_readb(twl, TWL_MODULE_USB, address); >> } >> >> >> /*-*/ >> @@ -264,8 +264,7 @@ static enum omap_musb_vbus_id_status >> * signal is active, the OTG module is activated, and >> * its interrupt may be raised (may wake the system). >> */ >> -status = twl4030_readb(twl, TWL4030_MODULE_PM_MASTER, >> -STS_HW_CONDITIONS); >> +status = twl4030_readb(twl, TWL_MODULE_PM_MASTER, STS_HW_CONDITIONS); >> if (status < 0) >> dev_err(twl->dev, "USB link status err %d\n", status); >> else if (status & (BIT(7) | BIT(2))) { >> @@ -372,8 +371,7 @@ static void twl4030_phy_power(struct twl4030_usb *twl, >> int on) >> * SLEEP. We work around this by clearing the bit after usv3v1 >> * is re-activated. This ensures that VUSB3V1 is really active. >> */ >> -twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, >> -VUSB_DEDICATED2); >> +twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2); >> regulator_enable(twl->usb1v5); >> __twl4030_phy_power(twl, 1); >> twl4030_usb_write(twl, PHY_CLK_CTRL, >> @@ -419,50 +417,48 @@ static void twl4030_phy_resume(struct twl4030_usb *twl) >> static int twl4030_usb_ldo_init(struct twl4030_usb *twl) >> { >> /* Enable writing to power configuration registers */ >> -twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, >> -TWL4030_PM_MASTER_KEY_CFG1, >> -TWL4030_PM_MASTER_PROTECT_KEY); >> +twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1, >> + TWL4030_PM_MASTER_PROTECT_KEY); >> >> -twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, >> -TWL4030_PM_MASTER_KEY_CFG2, >> -TWL4030_PM_MASTER_PROTECT_KEY); >> +twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG2, >> + TWL4030_PM_MASTER_PROTECT_KEY); >> >> /* Keep VUSB3V1 LDO in sleep state until VBUS/ID change detected*/ >> -/*twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);*/ >> +/*twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);*/ >> >> /* input to VUSB3V1 LDO is from VBAT, not VBUS */ >> -twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1); >> +twl_i2c_write_u8(TWL_MODULE_
Re: [PATCH] usb: otg: twl4030: Change TWL4030_MODULE_* ids to TWL_MODULE_*
Hi, On Tue, Nov 13, 2012 at 11:28:15AM +0100, Peter Ujfalusi wrote: > Hi Felipe, > > On 11/13/2012 10:47 AM, Felipe Balbi wrote: > > On Tue, Nov 13, 2012 at 10:43:38AM +0100, Peter Ujfalusi wrote: > >> To facilitate upcoming cleanup in twl stack. > >> No functional changes. > >> > >> Signed-off-by: Peter Ujfalusi > > > > I guess this one must go together with the rest of your series... > > I made the split between the patches and they are good to go in their separate > ways to avoid cross tree hassle. > All of the defines were in place originally but they were used in non > consistent ways. > All of these will help in the future to clean up the twl core without breaking > the child drivers. ok good. Unfortunately I have already sent this merge window's pull request to Greg so I'd have to delay this until v3.9. If that's ok with you, I can take it through my tree. -- balbi signature.asc Description: Digital signature
Re: [PATCH] usb: otg: twl4030: Change TWL4030_MODULE_* ids to TWL_MODULE_*
On 11/13/2012 11:37 AM, Felipe Balbi wrote: > ok good. Unfortunately I have already sent this merge window's pull > request to Greg so I'd have to delay this until v3.9. If that's ok with > you, I can take it through my tree. I hoped that this can go with 3.8 since in 3.9 I'm planning to remove all of these TWL4030_MODULE_* defines which have TWL_MODULE_* counterpart. In this case I will introduce dummy defines to point to the correct place for the USB in 3.9 and we can get rid of the rest of these in 3.10. Oh well. This is going to take a bit longer than I have anticipated. I can't think of any other subsytem this can go through... -- Péter -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH v2 1/6] usb: Register usb port's acpi power resources
Hello. On 13-11-2012 12:00, Lan Tianyu wrote: This patch is to register usb port's acpi power resources. Create link between usb port device and its acpi power resource. Signed-off-by: Lan Tianyu [...] diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c index cef4252..c58ebc0 100644 --- a/drivers/usb/core/usb-acpi.c +++ b/drivers/usb/core/usb-acpi.c @@ -216,6 +216,28 @@ static struct acpi_bus_type usb_acpi_bus = { .find_device = usb_acpi_find_device, }; +int usb_acpi_register_power_resources(struct device *dev) +{ + acpi_handle port_handle = DEVICE_ACPI_HANDLE(dev); + + if (!port_handle) + return -ENODEV; + + if (acpi_power_resource_register_device(dev, port_handle) < 0) + return -ENODEV; + return 0; +} + +void usb_acpi_unregister_power_resources(struct device *dev) +{ + acpi_handle port_handle = DEVICE_ACPI_HANDLE(dev); + + if (!port_handle) + return; + + acpi_power_resource_register_device(dev, port_handle); I thinbk you have been askied already, but shouldn't it be acpi_power_resource_unregister_device()? WBR, Sergei -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: otg: twl4030: Change TWL4030_MODULE_* ids to TWL_MODULE_*
Hi, On Tue, Nov 13, 2012 at 11:57:13AM +0100, Peter Ujfalusi wrote: > On 11/13/2012 11:37 AM, Felipe Balbi wrote: > > ok good. Unfortunately I have already sent this merge window's pull > > request to Greg so I'd have to delay this until v3.9. If that's ok with > > you, I can take it through my tree. > > I hoped that this can go with 3.8 since in 3.9 I'm planning to remove all of > these TWL4030_MODULE_* defines which have TWL_MODULE_* counterpart. > In this case I will introduce dummy defines to point to the correct place for > the USB in 3.9 and we can get rid of the rest of these in 3.10. Oh well. This > is going to take a bit longer than I have anticipated. > I can't think of any other subsytem this can go through... Let's ask if Greg could take this patch directly without going through me. Greg, would it be ok to take this single patch without going through me? Or would you prefer if I made another tag just for this single patch ? cheers -- balbi signature.asc Description: Digital signature
[PATCH -next] usb: gadget: tcm_usb_gadge: fix to return error or 0 in tcm_usbg_drop_nexus()
From: Wei Yongjun In the error handling case of tcm_usbg_drop_nexus(), the error code is assigned to 'ret', but it is ingored. We'd better return 'ret' instead of always return 0. dpatch engine is used to auto generate this patch. (https://github.com/weiyj/dpatch) Signed-off-by: Wei Yongjun --- drivers/usb/gadget/tcm_usb_gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c index 4f7f76f..7cacd6a 100644 --- a/drivers/usb/gadget/tcm_usb_gadget.c +++ b/drivers/usb/gadget/tcm_usb_gadget.c @@ -1794,9 +1794,10 @@ static int tcm_usbg_drop_nexus(struct usbg_tpg *tpg) tpg->tpg_nexus = NULL; kfree(tv_nexus); + ret = 0; out: mutex_unlock(&tpg->tpg_mutex); - return 0; + return ret; } static ssize_t tcm_usbg_tpg_store_nexus( -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/4] usb: chipidea: add otg id switch and vbus connect/disconnect detect
Peter Chen writes: > The main design flow is the same with msm otg driver, that is the id and > vbus interrupt are handled at core driver, others are handled by > individual drivers. This looks good to me in general. Few comments below. > - At former design, when switch usb role from device->host, it will call > udc_stop, it will remove the gadget driver, so when switch role > from host->device, it can't add gadget driver any more. Well, it can, only you need to reload the gadget module for that, but that's more current gadget framework's shortcoming... > At new design, when role switch occurs, the gadget just calls > usb_gadget_vbus_disconnect/usb_gadget_vbus_connect as well as > reset controller, it will not free any device/gadget structure ...but I do agree that this is much better. One thing we need to address here is CI13XXX_PULLUP_ON_VBUS. Since we now handle vbus session in the core driver, we should just retire this flag. And this vbus_disconnect() method won't work if PULLUP_ON_VBUS is not set anyway, since vbus_session is a nop in that case. > - Add vbus connect and disconnect to core interrupt handler, it can > notify udc driver by calling > usb_gadget_vbus_disconnect/usb_gadget_vbus_connect. > > - Add otg.c to implement struct usb_otg, in that case, calling > otg_set_peripheral > will not be failed at udc.c. Besides, we enable id interrupt at > ci_hdrc_otg_init. Can you make this a separate patch? > - Add special case handling, like connecting to host during boot up at device > mode, usb device at the MicroB to A cable at host mode, etc. This can probably be a separate patch too, since it's kind of a separate issue. > Signed-off-by: Peter Chen > --- > drivers/usb/chipidea/Makefile |2 +- > drivers/usb/chipidea/bits.h | 10 ++ > drivers/usb/chipidea/ci.h |6 + > drivers/usb/chipidea/core.c | 217 > + > drivers/usb/chipidea/otg.c| 60 +++ > drivers/usb/chipidea/otg.h|6 + > drivers/usb/chipidea/udc.c|2 + > 7 files changed, 284 insertions(+), 19 deletions(-) > > diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile > index d92ca32..11f513c 100644 > --- a/drivers/usb/chipidea/Makefile > +++ b/drivers/usb/chipidea/Makefile > @@ -2,7 +2,7 @@ ccflags-$(CONFIG_USB_CHIPIDEA_DEBUG) := -DDEBUG > > obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc.o > > -ci_hdrc-y:= core.o > +ci_hdrc-y:= core.o otg.o > ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o > ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST) += host.o > ci_hdrc-$(CONFIG_USB_CHIPIDEA_DEBUG) += debug.o > diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h > index 050de85..4b6ae3e 100644 > --- a/drivers/usb/chipidea/bits.h > +++ b/drivers/usb/chipidea/bits.h > @@ -65,11 +65,21 @@ > #define OTGSC_ASVISBIT(18) > #define OTGSC_BSVISBIT(19) > #define OTGSC_BSEISBIT(20) > +#define OTGSC_1MSISBIT(21) > +#define OTGSC_DPIS BIT(22) > #define OTGSC_IDIE BIT(24) > #define OTGSC_AVVIEBIT(25) > #define OTGSC_ASVIEBIT(26) > #define OTGSC_BSVIEBIT(27) > #define OTGSC_BSEIEBIT(28) > +#define OTGSC_1MSIEBIT(29) > +#define OTGSC_DPIE BIT(30) > +#define OTGSC_INT_EN_BITS(BIT(24) | BIT(25) | BIT(26)\ > + | BIT(27) | BIT(28) | BIT(29) \ > + | BIT(30)) > +#define OTGSC_INT_STATUS_BITS(BIT(16) | BIT(17) | BIT(18)\ > + | BIT(19) | BIT(20) | BIT(21) \ > + | BIT(22)) Why not use the OTGSC_* defines instead of bit numbers? > > /* USBMODE */ > #define USBMODE_CM(0x03UL << 0) > diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h > index d738603..d32f932 100644 > --- a/drivers/usb/chipidea/ci.h > +++ b/drivers/usb/chipidea/ci.h > @@ -139,6 +139,7 @@ struct ci13xxx { > enum ci_rolerole; > boolis_otg; > struct work_struct work; > + struct delayed_work dwork; > struct workqueue_struct *wq; > > struct dma_pool *qh_pool; > @@ -164,6 +165,11 @@ struct ci13xxx { > boolglobal_phy; > struct usb_phy *transceiver; > struct usb_hcd *hcd; > + /* events handled at ci_role_work */ > +#define ID 0 > +#define B_SESS_VALID 1 > + unsigned long events; I would just use bools instead. > + struct usb_otg otg; > }; > > static inline struct ci_role_driver *ci_role(struct ci13xxx *ci) > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c > index f69d029..b50b77a 100644 > --- a/drivers/usb/chipidea/core.c > +++ b/drivers/usb/chipidea/core.c > @@ -73,6 +73,7 @@ > #include "b
Re: [RFC PATCH v2 1/6] usb: Register usb port's acpi power resources
于 2012/11/13 19:07, Sergei Shtylyov 写道: Hello. On 13-11-2012 12:00, Lan Tianyu wrote: This patch is to register usb port's acpi power resources. Create link between usb port device and its acpi power resource. Signed-off-by: Lan Tianyu [...] diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c index cef4252..c58ebc0 100644 --- a/drivers/usb/core/usb-acpi.c +++ b/drivers/usb/core/usb-acpi.c @@ -216,6 +216,28 @@ static struct acpi_bus_type usb_acpi_bus = { .find_device = usb_acpi_find_device, }; +int usb_acpi_register_power_resources(struct device *dev) +{ +acpi_handle port_handle = DEVICE_ACPI_HANDLE(dev); + +if (!port_handle) +return -ENODEV; + +if (acpi_power_resource_register_device(dev, port_handle) < 0) +return -ENODEV; +return 0; +} + +void usb_acpi_unregister_power_resources(struct device *dev) +{ +acpi_handle port_handle = DEVICE_ACPI_HANDLE(dev); + +if (!port_handle) +return; + +acpi_power_resource_register_device(dev, port_handle); I thinbk you have been askied already, but shouldn't it be acpi_power_resource_unregister_device()? Oh. Sorry. Too focus on the other modification. Thanks for your reminder. WBR, Sergei -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- Best regards Tianyu Lan -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] net: cdc_ncm: add Huawei devices
A number of Huawei 3G and LTE modems implement a CDC NCM function, including the necessary functional descriptors, but using a non standard interface layout and class/subclass/protocol codes. These devices can be handled by this driver with only a minor change to the probing logic, allowing a single combined control and data interface. This works because the devices - include a CDC Union descriptor labelling the combined interface as both master and slave, and - have an alternate setting #1 for the bulk endpoints on the combined interface. The 3G/LTE network connection is managed by vendor specific AT commands on a serial function in the same composite device. Handling the managment function is out of the scope of this driver. It will be handled by an appropriate USB serial driver. Reported-and-Tested-by: Olof Ermis Reported-and-Tested-by: Tommy Cheng Signed-off-by: Bjørn Mork --- Hello David, This patch had to touch more than just the device id table to deal with the combined NCM interface on these devices. The changes will not affect any currently supported devices because (ctx->data != ctx->control) always is true for those. I am therefore requesting that this patch is put in the stable queue like other device additons. I guess it may be too late for v3.7, but FWIW I have verified that the patch applies cleanly to both the current net-next/master and to net/master, and will not cause merge conflicts either way. I have also verified that it applies cleanly to the v3.6.6 stable release. Bjørn drivers/net/usb/cdc_ncm.c | 22 ++ 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 4cd582a..74fab1a 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -540,10 +540,12 @@ advance: (ctx->ether_desc == NULL) || (ctx->control != intf)) goto error; - /* claim interfaces, if any */ - temp = usb_driver_claim_interface(driver, ctx->data, dev); - if (temp) - goto error; + /* claim data interface, if different from control */ + if (ctx->data != ctx->control) { + temp = usb_driver_claim_interface(driver, ctx->data, dev); + if (temp) + goto error; + } iface_no = ctx->data->cur_altsetting->desc.bInterfaceNumber; @@ -623,6 +625,10 @@ static void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf) tasklet_kill(&ctx->bh); + /* handle devices with combined control and data interface */ + if (ctx->control == ctx->data) + ctx->data = NULL; + /* disconnect master --> disconnect slave */ if (intf == ctx->control && ctx->data) { usb_set_intfdata(ctx->data, NULL); @@ -1245,6 +1251,14 @@ static const struct usb_device_id cdc_devs[] = { .driver_info = (unsigned long) &wwan_info, }, + /* Huawei NCM devices disguised as vendor specific */ + { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x16), + .driver_info = (unsigned long)&wwan_info, + }, + { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x46), + .driver_info = (unsigned long)&wwan_info, + }, + /* Generic CDC-NCM devices */ { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE), -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] usb: chipidea: usbmisc: prepare driver to handle more than one soc
Hi Marc, On Thu, Sep 6, 2012 at 12:18 PM, Marc Kleine-Budde wrote: > On 09/06/2012 05:15 PM, Richard Zhao wrote: >> Hi Marc, >> >> usbmisc_imx6q.c is only for imx6x. And for a certain running kernel, >> there will be always one driver instance. > > It's currently only for imx6q, but I've patches[1] in queue for mx53. > And mx35 is about to be written. > > Marc > > [1] > http://git.pengutronix.de/?p=mkl/linux.git;a=commit;h=bdeff138ba8bb40856c9946b67df2604fdb4416b Have you had a chance to submit this patch? I think we should rename the file to usbmisc_imx.c so that it can support different SoCs. Regards, Fabio Estevam -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] usb: chipidea: usbmisc: prepare driver to handle more than one soc
On 11/13/2012 02:23 PM, Fabio Estevam wrote: > Hi Marc, > > On Thu, Sep 6, 2012 at 12:18 PM, Marc Kleine-Budde > wrote: >> On 09/06/2012 05:15 PM, Richard Zhao wrote: >>> Hi Marc, >>> >>> usbmisc_imx6q.c is only for imx6x. And for a certain running kernel, >>> there will be always one driver instance. >> >> It's currently only for imx6q, but I've patches[1] in queue for mx53. >> And mx35 is about to be written. >> >> Marc >> >> [1] >> http://git.pengutronix.de/?p=mkl/linux.git;a=commit;h=bdeff138ba8bb40856c9946b67df2604fdb4416b > > Have you had a chance to submit this patch? > > I think we should rename the file to usbmisc_imx.c so that it can > support different SoCs. Good point, Michael is preparing a series of patches to support the remaining imxes. That series contains an updated version of this patch. Marc -- Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions| Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917- | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de | signature.asc Description: OpenPGP digital signature
Re: [PATCH -next] usb: gadget: tcm_usb_gadge: fix to return error or 0 in tcm_usbg_drop_nexus()
Hi, On Tue, Nov 13, 2012 at 08:01:13PM +0800, Wei Yongjun wrote: > From: Wei Yongjun > > In the error handling case of tcm_usbg_drop_nexus(), the error code > is assigned to 'ret', but it is ingored. We'd better return 'ret' typo here: ignored. > instead of always return 0. > > dpatch engine is used to auto generate this patch. > (https://github.com/weiyj/dpatch) > > Signed-off-by: Wei Yongjun > --- > drivers/usb/gadget/tcm_usb_gadget.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/gadget/tcm_usb_gadget.c > b/drivers/usb/gadget/tcm_usb_gadget.c > index 4f7f76f..7cacd6a 100644 > --- a/drivers/usb/gadget/tcm_usb_gadget.c > +++ b/drivers/usb/gadget/tcm_usb_gadget.c > @@ -1794,9 +1794,10 @@ static int tcm_usbg_drop_nexus(struct usbg_tpg *tpg) > tpg->tpg_nexus = NULL; > > kfree(tv_nexus); > + ret = 0; > out: > mutex_unlock(&tpg->tpg_mutex); > - return 0; > + return ret; > } > > static ssize_t tcm_usbg_tpg_store_nexus( -- balbi signature.asc Description: Digital signature
Re: [PATCH 2/2] usb: chipidea: usbmisc: prepare driver to handle more than one soc
On Tue, Nov 13, 2012 at 11:23:31AM -0200, Fabio Estevam wrote: > On Thu, Sep 6, 2012 at 12:18 PM, Marc Kleine-Budde > wrote: > > On 09/06/2012 05:15 PM, Richard Zhao wrote: > >> Hi Marc, > >> > >> usbmisc_imx6q.c is only for imx6x. And for a certain running kernel, > >> there will be always one driver instance. > > > > It's currently only for imx6q, but I've patches[1] in queue for mx53. > > And mx35 is about to be written. > > > > Marc > > > > [1] > > http://git.pengutronix.de/?p=mkl/linux.git;a=commit;h=bdeff138ba8bb40856c9946b67df2604fdb4416b > > Have you had a chance to submit this patch? > > I think we should rename the file to usbmisc_imx.c so that it can > support different SoCs. I will put this filename changing into one first patch of my series. That patch will rename all functions and structs to one more generic usbmisc_imx aswell. Regards, Michael -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: problem with Roseweil eusb3 enclosure
On Fri, Nov 02, 2012 at 10:54:38AM -0700, Sarah Sharp wrote: > On Fri, Nov 02, 2012 at 01:38:26PM -0400, Alan Stern wrote: > > On Fri, 2 Nov 2012, Sarah Sharp wrote: > > > > > > I don't like that idea. It would be much simpler to put the port back > > > > into a useful state. For example, disable the port, then put it into > > > > RxDetect, then clear any change bits, and set the port's bit in > > > > hub->removed_bits. > > > > > > > > (hub->removed_bits was meant to help implement Windows' "Safely remove > > > > hardware" feature. When a port's bit is set, khubd will ignore any > > > > device attached to that port until it sees a connect-change.) Hi Alan, I've been working on the warm reset fix patch, and I've run into a couple questions. A draft patch is attached, but it's not in any way done. :) In hub_events, we check whether the hub port is in the Inactive or Compliance Mode state, and issue a warm port reset. If there was a device attached to that port, don't we need to call the driver's prereset hook before we reset the device? I'm wondering if we should just remove this bit of code in hub_events: /* Warm reset a USB3 protocol port if it's in -* SS.Inactive state. +* SS.Inactive state or Compliance Mode. */ if (hub_port_warm_reset_required(hub, portstatus)) { - dev_dbg(hub_dev, "warm reset port %d\n", i); - hub_port_reset(hub, i, NULL, + int status = hub_port_reset(hub, i, + hub->ports[i - 1]->child, HUB_BH_RESET_TIME, true); + /* XXX: Not sure if we should set device state. +* Should this be passed a 0 or 1? +*/ + if (status) + hub_port_disable(hub, i, 1); + connect_change = 1; } and just let hub_port_connect_change() issue the warm port reset, disconnect the device, etc. Also, if the warm rest fails, I'm also not sure if I should ask hub_port_disable to set the device state: + /* XXX: Not sure if we should set device state. +* Should this be passed a 0 or 1? +*/ + if (status) + hub_port_disable(hub, i, 1); I added some test code to the xHCI hub code to test the patch out, and I verified that when a port in Compliance Mode is detected, it will warm reset the port several times, and then fall back to disabling and re-enabling the port. A device connect after that port disable is detected and the device is enumerated. So the patch works, it just needs some cleanup/tweaking. Sarah Sharp >From 181a80f59f859a7b0f0b02e59ddaad63264e5eae Mon Sep 17 00:00:00 2001 From: Sarah Sharp Date: Thu, 1 Nov 2012 11:20:44 -0700 Subject: [PATCH] USB: Rework buggy warm reset support. When John Covici boots with a USB 3.0 device attached to his 0.96 xHCI host controller, the port goes into Compliance Mode during host controller initialization. Warm reset fails, and the USB core goes into an endless loop attempting to enumerate the device, because the warm reset completion code assumes the reset will always be successful. Fix this. First, extend the port reset timeout, because the NEC xHCI host seems to need a slightly longer timeout. The USB 3.0 spec says that the warm port reset should complete within 200ms, or the link state should transition to the Disconnected state. Two seconds should be more than enough. Next, clean up a bunch of bugs in the port reset code: - A hot reset can migrate to a warm reset, so hub_finish_port_reset needs to unconditionally clear the warm reset and link change bits. - Rip out the recursive call to hub_port_reset in hub_wait_port_reset. Instead, make hub_port_reset try a warm reset if the hot reset fails. - If the port link state is SS.Inactive or Compliance Mode, make hub_port_reset try several warm resets before giving up and reporting the disconnect event. - Make the USB core ignore the return value of the xHCI Reset Device command. If we need to reset the port multiple times in a row, the xHC will give us a context error starting with the second Reset Device command, since it considers the device to already be reset. When a warm port reset fails, make the USB core disable the port. Currently, we avoid disabling any USB 3.0 ports because a disabled USB 3.0 port will not report any new USB connections. The USB core expects a port status change event on a new connect (like with USB 2.0 hubs), which will never come. We need to be able to disable a USB 3.0 por
Re: [PATCH] net: cdc_ncm: add Huawei devices
From: Bjørn Mork Date: Tue, 13 Nov 2012 14:19:43 +0100 > A number of Huawei 3G and LTE modems implement a CDC NCM function, > including the necessary functional descriptors, but using a non > standard interface layout and class/subclass/protocol codes. > > These devices can be handled by this driver with only a minor > change to the probing logic, allowing a single combined control > and data interface. This works because the devices > - include a CDC Union descriptor labelling the combined > interface as both master and slave, and > - have an alternate setting #1 for the bulk endpoints on the > combined interface. > > The 3G/LTE network connection is managed by vendor specific AT > commands on a serial function in the same composite device. > Handling the managment function is out of the scope of this > driver. It will be handled by an appropriate USB serial > driver. > > Reported-and-Tested-by: Olof Ermis > Reported-and-Tested-by: Tommy Cheng > Signed-off-by: Bjørn Mork Applied to net, thanks. > I am therefore requesting that this patch is put in the stable > queue like other device additons. > > I guess it may be too late for v3.7, but FWIW I have verified > that the patch applies cleanly to both the current net-next/master > and to net/master, and will not cause merge conflicts either way. > I have also verified that it applies cleanly to the v3.6.6 stable > release. There were quite a few ID additions and I don't think most of them were actually queued up for -stable submission. Can you make a list of patches that still need to be submitted to -stable, including this one? Thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH v2 1/6] usb: Register usb port's acpi power resources
On Tuesday, November 13, 2012 08:36:15 PM Lan Tianyu wrote: > 于 2012/11/13 19:07, Sergei Shtylyov 写道: > > Hello. > > > > On 13-11-2012 12:00, Lan Tianyu wrote: > > > >> This patch is to register usb port's acpi power resources. Create > >> link between usb port device and its acpi power resource. > > > >> Signed-off-by: Lan Tianyu > > [...] > > > >> diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c > >> index cef4252..c58ebc0 100644 > >> --- a/drivers/usb/core/usb-acpi.c > >> +++ b/drivers/usb/core/usb-acpi.c > >> @@ -216,6 +216,28 @@ static struct acpi_bus_type usb_acpi_bus = { > >> .find_device = usb_acpi_find_device, > >> }; > >> > >> +int usb_acpi_register_power_resources(struct device *dev) > >> +{ > >> +acpi_handle port_handle = DEVICE_ACPI_HANDLE(dev); > >> + > >> +if (!port_handle) > >> +return -ENODEV; > >> + > >> +if (acpi_power_resource_register_device(dev, port_handle) < 0) > >> +return -ENODEV; > >> +return 0; > >> +} > >> + > >> +void usb_acpi_unregister_power_resources(struct device *dev) > >> +{ > >> +acpi_handle port_handle = DEVICE_ACPI_HANDLE(dev); > >> + > >> +if (!port_handle) > >> +return; > >> + > >> +acpi_power_resource_register_device(dev, port_handle); > > > > I thinbk you have been askied already, but shouldn't it be > > acpi_power_resource_unregister_device()? > > > Oh. Sorry. Too focus on the other modification. Thanks for your reminder. Besides, it would be a bit more natural to do if (port_handle) acpi_power_resource_unregister_device(dev, port_handle); instead of doing that return when port_handle is NULL. Thanks, Rafael -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH v2 2/6] usb: Add driver/usb/core/port.c file to fill usb port related code.
On Tuesday, November 13, 2012 04:00:01 PM Lan Tianyu wrote: > This patch is to create driver/usb/core/port.c and move usb port related > code into it. It does seem to make functional changes in addition to that, however. If I'm not mistaken and that really is the case, can you (briefly) describe those changes here too? Rafael > Signed-off-by: Lan Tianyu > --- > drivers/usb/core/Makefile |1 + > drivers/usb/core/hub.c| 113 > +++-- > drivers/usb/core/port.c | 82 > drivers/usb/core/usb.h|3 ++ > include/linux/usb.h | 16 +++ > 5 files changed, 118 insertions(+), 97 deletions(-) > create mode 100644 drivers/usb/core/port.c > > diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile > index 26059b9..5e847ad 100644 > --- a/drivers/usb/core/Makefile > +++ b/drivers/usb/core/Makefile > @@ -7,6 +7,7 @@ ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG > usbcore-y := usb.o hub.o hcd.o urb.o message.o driver.o > usbcore-y += config.o file.o buffer.o sysfs.o endpoint.o > usbcore-y += devio.o notify.o generic.o quirks.o devices.o > +usbcore-y += port.o > > usbcore-$(CONFIG_PCI)+= hcd-pci.o > usbcore-$(CONFIG_ACPI) += usb-acpi.o > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c > index 3c85fe1c..60746aa 100644 > --- a/drivers/usb/core/hub.c > +++ b/drivers/usb/core/hub.c > @@ -42,13 +42,6 @@ > #define USB_VENDOR_GENESYS_LOGIC 0x05e3 > #define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND 0x01 > > -struct usb_port { > - struct usb_device *child; > - struct device dev; > - struct dev_state *port_owner; > - enum usb_port_connect_type connect_type; > -}; > - > struct usb_hub { > struct device *intfdev; /* the "interface" device */ > struct usb_device *hdev; > @@ -170,9 +163,6 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem); > #define HUB_DEBOUNCE_STEP 25 > #define HUB_DEBOUNCE_STABLE 100 > > -#define to_usb_port(_dev) \ > - container_of(_dev, struct usb_port, dev) > - > static int usb_reset_and_verify_device(struct usb_device *udev); > > static inline char *portspeed(struct usb_hub *hub, int portstatus) > @@ -1237,57 +1227,12 @@ static int hub_post_reset(struct usb_interface *intf) > return 0; > } > > -static void usb_port_device_release(struct device *dev) > -{ > - struct usb_port *port_dev = to_usb_port(dev); > - > - usb_acpi_unregister_power_resources(dev); > - kfree(port_dev); > -} > - > static void usb_hub_remove_port_device(struct usb_hub *hub, > int port1) > { > device_unregister(&hub->ports[port1 - 1]->dev); > } > > -struct device_type usb_port_device_type = { > - .name = "usb_port", > - .release = usb_port_device_release, > -}; > - > -static int usb_hub_create_port_device(struct usb_hub *hub, > - int port1) > -{ > - struct usb_port *port_dev = NULL; > - int retval; > - > - port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL); > - if (!port_dev) { > - retval = -ENOMEM; > - goto exit; > - } > - > - hub->ports[port1 - 1] = port_dev; > - port_dev->dev.parent = hub->intfdev; > - port_dev->dev.groups = port_dev_group; > - port_dev->dev.type = &usb_port_device_type; > - dev_set_name(&port_dev->dev, "port%d", port1); > - > - retval = device_register(&port_dev->dev); > - if (retval) > - goto error_register; > - > - usb_acpi_register_power_resources(&port_dev->dev); > - > - return 0; > - > -error_register: > - put_device(&port_dev->dev); > -exit: > - return retval; > -} > - > static int hub_configure(struct usb_hub *hub, > struct usb_endpoint_descriptor *endpoint) > { > @@ -1548,10 +1493,24 @@ static int hub_configure(struct usb_hub *hub, > if (hub->has_indicators && blinkenlights) > hub->indicator [0] = INDICATOR_CYCLE; > > - for (i = 0; i < hdev->maxchild; i++) > - if (usb_hub_create_port_device(hub, i + 1) < 0) > + for (i = 0; i < hdev->maxchild; i++) { > + struct usb_port *port_dev = NULL; > + > + port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL); > + if (!port_dev) { > + dev_err(hub->intfdev, > + "couldn't create port%d device due to lack > mem.\n", i + 1); > + continue; > + } > + > + hub->ports[i] = port_dev; > + > + if (usb_hub_create_port_device(hub->intfdev, i + 1, port_dev) < > 0) { > dev_err(hub->intfdev, > "couldn't create port%d device.\n", i + 1); > + hub->ports[i] = NULL; > + } > + } > > if (!hub_is_superspeed(hdev)) { > for (i = 1; i <= hdev->maxchild; i++)
Re: [RFC PATCH v2 3/6] usb: add runtime pm support for usb port device
On Tuesday, November 13, 2012 04:00:02 PM Lan Tianyu wrote: > This patch is to add runtime pm callback for usb port device. > Set/clear PORT_POWER feature in the resume/suspend callbak. > Add portnum for struct usb_port to record port number. > > Signed-off-by: Lan Tianyu This one looks reasonable to me. From the PM side Acked-by: Rafael J. Wysocki > --- > drivers/usb/core/hub.c | 14 ++ > drivers/usb/core/port.c | 39 +++ > drivers/usb/core/usb.h |2 ++ > include/linux/usb.h |2 ++ > 4 files changed, 57 insertions(+) > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c > index 60746aa..2cb414e 100644 > --- a/drivers/usb/core/hub.c > +++ b/drivers/usb/core/hub.c > @@ -765,6 +765,20 @@ static void hub_tt_work(struct work_struct *work) > spin_unlock_irqrestore (&hub->tt.lock, flags); > } > > +int usb_hub_set_port_power(struct usb_device *hdev, int port1, > + bool set) > +{ > + int ret; > + > + if (set) > + ret = set_port_feature(hdev, port1, > + USB_PORT_FEAT_POWER); > + else > + ret = clear_port_feature(hdev, port1, > + USB_PORT_FEAT_POWER); > + return ret; > +} > + > /** > * usb_hub_clear_tt_buffer - clear control/bulk TT state in high speed hub > * @urb: an URB associated with the failed or incomplete split transaction > diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c > index 6523a03..1cda766 100644 > --- a/drivers/usb/core/port.c > +++ b/drivers/usb/core/port.c > @@ -53,9 +53,45 @@ static void usb_port_device_release(struct device *dev) > kfree(port_dev); > } > > +static int usb_port_runtime_resume(struct device *dev) > +{ > + struct usb_port *port_dev = to_usb_port(dev); > + struct usb_device *hdev = > + to_usb_device(dev->parent->parent); > + > + return usb_hub_set_port_power(hdev, port_dev->portnum, > + true); > +} > + > +static int usb_port_runtime_suspend(struct device *dev) > +{ > + struct usb_port *port_dev = to_usb_port(dev); > + struct usb_device *hdev = > + to_usb_device(dev->parent->parent); > + > + return usb_hub_set_port_power(hdev, port_dev->portnum, > + false); > +} > + > +static int usb_port_runtime_idle(struct device *dev) > +{ > + struct usb_port *port_dev = to_usb_port(dev); > + > + return pm_runtime_suspend(&port_dev->dev); > +} > + > +static const struct dev_pm_ops usb_port_pm_ops = { > +#ifdef CONFIG_USB_SUSPEND > +.runtime_suspend = usb_port_runtime_suspend, > +.runtime_resume =usb_port_runtime_resume, > +.runtime_idle = usb_port_runtime_idle, > +#endif > +}; > + > struct device_type usb_port_device_type = { > .name = "usb_port", > .release = usb_port_device_release, > + .pm = &usb_port_pm_ops, > }; > > int usb_hub_create_port_device(struct device *intfdev, > @@ -63,6 +99,7 @@ int usb_hub_create_port_device(struct device *intfdev, > { > int retval; > > + port_dev->portnum = port1; > port_dev->dev.parent = intfdev; > port_dev->dev.groups = port_dev_group; > port_dev->dev.type = &usb_port_device_type; > @@ -72,6 +109,8 @@ int usb_hub_create_port_device(struct device *intfdev, > if (retval) > goto error_register; > > + pm_runtime_set_active(&port_dev->dev); > + pm_runtime_enable(&port_dev->dev); > usb_acpi_register_power_resources(&port_dev->dev); > > return 0; > diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h > index de7434b..47d77d4 100644 > --- a/drivers/usb/core/usb.h > +++ b/drivers/usb/core/usb.h > @@ -62,6 +62,8 @@ extern void usb_major_cleanup(void); > > extern int usb_hub_create_port_device(struct device *intfdev, > int port1, struct usb_port *port_dev); > +extern int usb_hub_set_port_power(struct usb_device *hdev, > + int port1, bool set); > > #ifdef CONFIG_PM > > diff --git a/include/linux/usb.h b/include/linux/usb.h > index c1f1346..71510bf 100644 > --- a/include/linux/usb.h > +++ b/include/linux/usb.h > @@ -578,12 +578,14 @@ struct usb_device { > * @dev: generic device interface > * @port_owner: port's owner > * @connect_type: port's connect type > + * @portnum: port index num based one > */ > struct usb_port { > struct usb_device *child; > struct device dev; > struct dev_state *port_owner; > enum usb_port_connect_type connect_type; > + u8 portnum; > }; > #define to_usb_port(_dev) \ > container_of(_dev, struct usb_port, dev) > -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH v2 4/6] usb: add usb port auto power off mechanism
On Tuesday, November 13, 2012 04:00:03 PM Lan Tianyu wrote: > This patch is to add usb port auto power off mechanism. > When usb device is suspending, usb core will suspend usb port and > usb port runtime pm callback will clear PORT_POWER feature to > power off port if all conditions were met.These conditions are > remote wakeup disable, pm qos NO_POWER_OFF flag clear and persist > enable. When device is suspended and power off, usb core > will ignore port's connect and enable change event to keep the device > not being disconnected. When it resumes, power on port again. > > Signed-off-by: Lan Tianyu Again, from the PM side: Acked-by: Rafael J. Wysocki although as far as the USB internals are concerned, I'm far from being an expert. :-) Thanks, Rafael > --- > drivers/usb/core/hub.c | 76 > +-- > drivers/usb/core/port.c |1 + > include/linux/usb.h |2 ++ > 3 files changed, 76 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c > index 2cb414e..267e9d7 100644 > --- a/drivers/usb/core/hub.c > +++ b/drivers/usb/core/hub.c > @@ -26,6 +26,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -159,11 +160,14 @@ MODULE_PARM_DESC(use_both_schemes, > DECLARE_RWSEM(ehci_cf_port_reset_rwsem); > EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem); > > +#define HUB_PORT_RECONNECT_TRIES 20 > + > #define HUB_DEBOUNCE_TIMEOUT 1500 > #define HUB_DEBOUNCE_STEP 25 > #define HUB_DEBOUNCE_STABLE 100 > > static int usb_reset_and_verify_device(struct usb_device *udev); > +static int hub_port_debounce(struct usb_hub *hub, int port1); > > static inline char *portspeed(struct usb_hub *hub, int portstatus) > { > @@ -855,7 +859,11 @@ static unsigned hub_power_on(struct usb_hub *hub, bool > do_delay) > dev_dbg(hub->intfdev, "trying to enable port power on " > "non-switchable hub\n"); > for (port1 = 1; port1 <= hub->descriptor->bNbrPorts; port1++) > - set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); > + if (hub->ports[port1 - 1]->power_on) > + set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); > + else > + clear_port_feature(hub->hdev, port1, > + USB_PORT_FEAT_POWER); > > /* Wait at least 100 msec for power to become stable */ > delay = max(pgood_delay, (unsigned) 100); > @@ -2852,6 +2860,7 @@ EXPORT_SYMBOL_GPL(usb_enable_ltm); > int usb_port_suspend(struct usb_device *udev, pm_message_t msg) > { > struct usb_hub *hub = hdev_to_hub(udev->parent); > + struct usb_port *port_dev = hub->ports[udev->portnum - 1]; > int port1 = udev->portnum; > int status; > > @@ -2946,6 +2955,19 @@ int usb_port_suspend(struct usb_device *udev, > pm_message_t msg) > udev->port_is_suspended = 1; > msleep(10); > } > + > + /* > + * Check whether current status is meeting requirement of > + * usb port power off mechanism > + */ > + if (!udev->do_remote_wakeup > + && (dev_pm_qos_flags(&port_dev->dev, > + PM_QOS_FLAG_NO_POWER_OFF) != PM_QOS_FLAGS_ALL) > + && udev->persist_enabled > + && !status) > + if (!pm_runtime_put_sync(&port_dev->dev)) > + port_dev->power_on = false; > + > usb_mark_last_busy(hub->hdev); > return status; > } > @@ -3029,6 +3051,25 @@ static int finish_port_resume(struct usb_device *udev) > return status; > } > > +static int usb_port_wait_for_connected(struct usb_hub *hub, int port1) > +{ > + int status, i; > + > + for (i = 0; i < HUB_PORT_RECONNECT_TRIES; i++) { > + status = hub_port_debounce(hub, port1); > + if (status & USB_PORT_STAT_CONNECTION) { > + /* > + * just clear enable-change feature since debounce > + * has cleared connect-change feature. > + */ > + clear_port_feature(hub->hdev, port1, > + USB_PORT_FEAT_C_ENABLE); > + return 0; > + } > + } > + return -ETIMEDOUT; > +} > + > /* > * usb_port_resume - re-activate a suspended usb device's upstream port > * @udev: device to re-activate, not a root hub > @@ -3066,10 +3107,36 @@ static int finish_port_resume(struct usb_device *udev) > int usb_port_resume(struct usb_device *udev, pm_message_t msg) > { > struct usb_hub *hub = hdev_to_hub(udev->parent); > + struct usb_port *port_dev = hub->ports[udev->portnum - 1]; > int port1 = udev->portnum; > int status; > u16 portchange, portstatus; > > + > + set_bit(port
Re: [RFC PATCH v2 5/6] usb: expose usb port's pm qos flags to user space
On Tuesday, November 13, 2012 04:00:04 PM Lan Tianyu wrote: > This patch is to expose usb port's pm qos flags(pm_qos_no_power_off, > pm_qos_remote_wakeup) to user space. User can set pm_qos_no_power_off > flag to prohibit the port from being power off. > > Signed-off-by: Lan Tianyu > --- > drivers/usb/core/port.c | 10 +- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c > index b7388fd..5a7a833 100644 > --- a/drivers/usb/core/port.c > +++ b/drivers/usb/core/port.c > @@ -2,6 +2,7 @@ > #include > #include > #include > +#include > > #include "usb.h" > > @@ -48,7 +49,7 @@ static const struct attribute_group *port_dev_group[] = { > static void usb_port_device_release(struct device *dev) > { > struct usb_port *port_dev = to_usb_port(dev); > - > + dev_pm_qos_hide_flags(dev); > usb_acpi_unregister_power_resources(dev); > kfree(port_dev); > } > @@ -110,12 +111,19 @@ int usb_hub_create_port_device(struct device *intfdev, > if (retval) > goto error_register; > > + retval = dev_pm_qos_expose_flags(&port_dev->dev, > + PM_QOS_FLAG_NO_POWER_OFF); > + if (retval) > + goto error_expose_pm_qos; > + > pm_runtime_set_active(&port_dev->dev); > pm_runtime_enable(&port_dev->dev); > usb_acpi_register_power_resources(&port_dev->dev); > > return 0; > > +error_expose_pm_qos: > + device_del(&port_dev->dev); That seems to be a bit drastic. :-) Why don't you simply avoid enabling runtime PM in that case? Rafael > error_register: > put_device(&port_dev->dev); > return retval; > -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH v2 6/6] usb: add usb port's pm qos flags request to change NO_POWER_OFF flag
On Tuesday, November 13, 2012 04:00:05 PM Lan Tianyu wrote: > Some usb devices can't be resumed correctly after power off. This > patch is to add pm qos flags request to change NO_POWER_OFF and > provide usb_device_allow_power_off() for device drivers to allow or > prohibit usb core to power off the device. > > Signed-off-by: Lan Tianyu This looks reasonable to me. From the PM perspective: Acked-by: Rafael J. Wysocki > --- > drivers/usb/core/hub.c | 36 > drivers/usb/core/port.c | 12 > include/linux/usb.h |3 +++ > 3 files changed, 51 insertions(+) > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c > index 267e9d7..7aaac720 100644 > --- a/drivers/usb/core/hub.c > +++ b/drivers/usb/core/hub.c > @@ -189,6 +189,42 @@ static struct usb_hub *hdev_to_hub(struct usb_device > *hdev) > return usb_get_intfdata(hdev->actconfig->interface[0]); > } > > +/** > + * usb_device_allow_power_off - Allow or prohibit power off device. > + * @udev: target usb device > + * @set: choice of allow or prohibit > + * > + * Clearing or setting usb port's pm qos flag PM_QOS_FLAG_NO_POWER_OFF > + * to allow or prohibit target usb device to be power off. > + */ > +int usb_device_allow_power_off(struct usb_device *udev, bool set) > +{ > + struct usb_port *port_dev; > + struct dev_pm_qos_request *pm_qos; > + s32 value; > + int ret; > + > + if (!udev->parent) > + return -EINVAL; > + > + port_dev = > + hdev_to_hub(udev->parent)->ports[udev->portnum - 1]; > + pm_qos = &port_dev->pm_qos; > + value = pm_qos->data.flr.flags; > + > + if (set) > + value &= ~PM_QOS_FLAG_NO_POWER_OFF; > + else > + value |= PM_QOS_FLAG_NO_POWER_OFF; > + > + pm_runtime_get_sync(&port_dev->dev); > + ret = dev_pm_qos_update_request(pm_qos, value); > + pm_runtime_put(&port_dev->dev); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(usb_device_allow_power_off); > + > static int usb_device_supports_lpm(struct usb_device *udev) > { > /* USB 2.1 (and greater) devices indicate LPM support through > diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c > index 5a7a833..077a494 100644 > --- a/drivers/usb/core/port.c > +++ b/drivers/usb/core/port.c > @@ -49,6 +49,11 @@ static const struct attribute_group *port_dev_group[] = { > static void usb_port_device_release(struct device *dev) > { > struct usb_port *port_dev = to_usb_port(dev); > + > + pm_runtime_get_sync(dev); > + dev_pm_qos_remove_request(&port_dev->pm_qos); > + pm_runtime_put(dev); > + > dev_pm_qos_hide_flags(dev); > usb_acpi_unregister_power_resources(dev); > kfree(port_dev); > @@ -116,12 +121,19 @@ int usb_hub_create_port_device(struct device *intfdev, > if (retval) > goto error_expose_pm_qos; > > + retval = dev_pm_qos_add_request(&port_dev->dev, &port_dev->pm_qos, > + DEV_PM_QOS_FLAGS, 0); > + if (retval) > + goto error_add_qos_request; > + > pm_runtime_set_active(&port_dev->dev); > pm_runtime_enable(&port_dev->dev); > usb_acpi_register_power_resources(&port_dev->dev); > > return 0; > > +error_add_qos_request: > + pm_runtime_put(&port_dev->dev); > error_expose_pm_qos: > device_del(&port_dev->dev); > error_register: > diff --git a/include/linux/usb.h b/include/linux/usb.h > index 8002640..aa201bd 100644 > --- a/include/linux/usb.h > +++ b/include/linux/usb.h > @@ -21,6 +21,7 @@ > #include /* for current && schedule_timeout */ > #include /* for struct mutex */ > #include /* for runtime PM */ > +#include /* for PM Qos */ > > struct usb_device; > struct usb_driver; > @@ -577,6 +578,7 @@ struct usb_device { > * @child: usb device attatched to the port > * @dev: generic device interface > * @port_owner: port's owner > + * @pm_qos: port's pm qos flags request > * @connect_type: port's connect type > * @portnum: port index num based one > * @power_on: port's power state > @@ -585,6 +587,7 @@ struct usb_port { > struct usb_device *child; > struct device dev; > struct dev_state *port_owner; > + struct dev_pm_qos_request pm_qos; > enum usb_port_connect_type connect_type; > u8 portnum; > bool power_on; > -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Use SCSI read/write(16) with >2TB drives
From: "Jason J. Herne" Force large capacity (> 2TB) drives to use READ/WRITE(16) instead of READ/WRITE(10). Some(most/all?) USB enclosures do not like READ(10) commands when a large capacity drive is installed. Signed-off-by: Jason J. Herne --- drivers/scsi/sd.c |5 - include/scsi/scsi_device.h |1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 12f6fdf..0790f69 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -887,7 +887,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) SCpnt->cmnd[29] = (unsigned char) (this_count >> 16) & 0xff; SCpnt->cmnd[30] = (unsigned char) (this_count >> 8) & 0xff; SCpnt->cmnd[31] = (unsigned char) this_count & 0xff; - } else if (block > 0x) { + } else if (sdp->use_16_for_rw) { SCpnt->cmnd[0] += READ_16 - READ_6; SCpnt->cmnd[1] = protect | ((rq->cmd_flags & REQ_FUA) ? 0x8 : 0); SCpnt->cmnd[2] = sizeof(block) > 4 ? (unsigned char) (block >> 56) & 0xff : 0; @@ -2067,6 +2067,9 @@ got_data: blk_queue_physical_block_size(sdp->request_queue, sdkp->physical_block_size); sdkp->device->sector_size = sector_size; + + /* Use read/write(16) for > 2TB disks */ + sdp->use_16_for_rw = (sdkp->capacity > 0x); } /* called with buffer of length 512 */ diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 88fae8d..19ab8f1 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -135,6 +135,7 @@ struct scsi_device { * because we did a bus reset. */ unsigned use_10_for_rw:1; /* first try 10-byte read / write */ unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */ + unsigned use_16_for_rw:1; /* Use read/write(16) over read/write(10) */ unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */ unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */ unsigned skip_vpd_pages:1; /* do not read VPD pages */ -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Use SCSI read/write(16) with >2TB drives
Il 14/11/2012 01:54, Jason J. Herne ha scritto: > blk_queue_physical_block_size(sdp->request_queue, > sdkp->physical_block_size); > sdkp->device->sector_size = sector_size; > + > + /* Use read/write(16) for > 2TB disks */ > + sdp->use_16_for_rw = (sdkp->capacity > 0x); > } This needs to be done before this bit: /* Rescale capacity to 512-byte units */ if (sector_size == 4096) sdkp->capacity <<= 3; else if (sector_size == 2048) sdkp->capacity <<= 2; else if (sector_size == 1024) sdkp->capacity <<= 1; else if (sector_size == 256) sdkp->capacity >>= 1; For example, for a 4K-sector disk the "threshold" would be 16TB (2^12 * 2^32). Paolo -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
usb phy and usb otg
hi The USB controller in our SOC can support otg/ehci/udc, and there is a PHY around the controller. It means that when we want to enable otg or ehci or udc, we have to enable the PHY. Then i want to add a PHY driver, but the PHY does not bind to OTG. It means that if we want only udc fucntion, we still need the phy. The struct usb_phy has a pointer to usb_otg. To make use of the phy driver, can i have the following callings? 1. write a phy driver, and initialize phy->init and phy->shutdown. Then in probe function invoke usb_add_phy(phy, USB_PHY_TYPE_USB2) 2. in the udc driver in probe function, call usb_get_phy(USB_PHY_TYPE_USB2), and when want to start udc, call phy->init() to initialize the PHY, and when want to stop udc, call phy->shutdown to shutdown the phy when udc is started, and usally we will check whether phy->otg is NULL or not, if it is not NULL, invoke otg_set_peripheral to set the OTG to be device-B. It means that if we have otg enabled, the phy->otg will not be NULL, otherwise we only have udc supported. 3. in the otg driver in the probe function, initialize the otg(struct usb_otg), then call usb_get_phy(USB_PHY_TYPE_USB2), and set phy->otg = otg. 4. in the ehci driver in the probe function, call usb_get_phy(USB_PHY_TYPE_USB2), and when want to enable ehci, call phy->init first. when start ehci, we will check whether phy->otg is NULL or not, if it is not NULL, invoke otg_set_host to make otg be host-A. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH v2 1/6] usb: Register usb port's acpi power resources
On 2012年11月14日 07:56, Rafael J. Wysocki wrote: > On Tuesday, November 13, 2012 08:36:15 PM Lan Tianyu wrote: >> 于 2012/11/13 19:07, Sergei Shtylyov 写道: >>> Hello. >>> >>> On 13-11-2012 12:00, Lan Tianyu wrote: >>> This patch is to register usb port's acpi power resources. Create link between usb port device and its acpi power resource. >>> Signed-off-by: Lan Tianyu >>> [...] >>> diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c index cef4252..c58ebc0 100644 --- a/drivers/usb/core/usb-acpi.c +++ b/drivers/usb/core/usb-acpi.c @@ -216,6 +216,28 @@ static struct acpi_bus_type usb_acpi_bus = { .find_device = usb_acpi_find_device, }; +int usb_acpi_register_power_resources(struct device *dev) +{ +acpi_handle port_handle = DEVICE_ACPI_HANDLE(dev); + +if (!port_handle) +return -ENODEV; + +if (acpi_power_resource_register_device(dev, port_handle) < 0) +return -ENODEV; +return 0; +} + +void usb_acpi_unregister_power_resources(struct device *dev) +{ +acpi_handle port_handle = DEVICE_ACPI_HANDLE(dev); + +if (!port_handle) +return; + +acpi_power_resource_register_device(dev, port_handle); >>> >>> I thinbk you have been askied already, but shouldn't it be >>> acpi_power_resource_unregister_device()? >>> >> Oh. Sorry. Too focus on the other modification. Thanks for your reminder. > > Besides, it would be a bit more natural to do > > if (port_handle) > acpi_power_resource_unregister_device(dev, port_handle); > > instead of doing that return when port_handle is NULL. > Hi Rafael: Great thanks for your review. :) I get it and will update it at next version. > Thanks, > Rafael > > -- Best regards Tianyu Lan -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH v2 2/6] usb: Add driver/usb/core/port.c file to fill usb port related code.
On 2012年11月14日 08:04, Rafael J. Wysocki wrote: > On Tuesday, November 13, 2012 04:00:01 PM Lan Tianyu wrote: >> This patch is to create driver/usb/core/port.c and move usb port related >> code into it. > > It does seem to make functional changes in addition to that, however. > No functional change. But change the usb_hub_create_port_device() param. which original used struct usb_hub as param. Because struct usb_hub is private struct in the hub.c and now move usb_hub_create_port_device() to port.c. Will add changelog about this next version. > If I'm not mistaken and that really is the case, can you (briefly) > describe those changes here too? > > Rafael > > >> Signed-off-by: Lan Tianyu >> --- >> drivers/usb/core/Makefile |1 + >> drivers/usb/core/hub.c| 113 >> +++-- >> drivers/usb/core/port.c | 82 >> drivers/usb/core/usb.h|3 ++ >> include/linux/usb.h | 16 +++ >> 5 files changed, 118 insertions(+), 97 deletions(-) >> create mode 100644 drivers/usb/core/port.c >> >> diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile >> index 26059b9..5e847ad 100644 >> --- a/drivers/usb/core/Makefile >> +++ b/drivers/usb/core/Makefile >> @@ -7,6 +7,7 @@ ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG >> usbcore-y := usb.o hub.o hcd.o urb.o message.o driver.o >> usbcore-y += config.o file.o buffer.o sysfs.o endpoint.o >> usbcore-y += devio.o notify.o generic.o quirks.o devices.o >> +usbcore-y += port.o >> >> usbcore-$(CONFIG_PCI) += hcd-pci.o >> usbcore-$(CONFIG_ACPI) += usb-acpi.o >> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c >> index 3c85fe1c..60746aa 100644 >> --- a/drivers/usb/core/hub.c >> +++ b/drivers/usb/core/hub.c >> @@ -42,13 +42,6 @@ >> #define USB_VENDOR_GENESYS_LOGIC0x05e3 >> #define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND0x01 >> >> -struct usb_port { >> -struct usb_device *child; >> -struct device dev; >> -struct dev_state *port_owner; >> -enum usb_port_connect_type connect_type; >> -}; >> - >> struct usb_hub { >> struct device *intfdev; /* the "interface" device */ >> struct usb_device *hdev; >> @@ -170,9 +163,6 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem); >> #define HUB_DEBOUNCE_STEP 25 >> #define HUB_DEBOUNCE_STABLE 100 >> >> -#define to_usb_port(_dev) \ >> -container_of(_dev, struct usb_port, dev) >> - >> static int usb_reset_and_verify_device(struct usb_device *udev); >> >> static inline char *portspeed(struct usb_hub *hub, int portstatus) >> @@ -1237,57 +1227,12 @@ static int hub_post_reset(struct usb_interface *intf) >> return 0; >> } >> >> -static void usb_port_device_release(struct device *dev) >> -{ >> -struct usb_port *port_dev = to_usb_port(dev); >> - >> -usb_acpi_unregister_power_resources(dev); >> -kfree(port_dev); >> -} >> - >> static void usb_hub_remove_port_device(struct usb_hub *hub, >> int port1) >> { >> device_unregister(&hub->ports[port1 - 1]->dev); >> } >> >> -struct device_type usb_port_device_type = { >> -.name = "usb_port", >> -.release = usb_port_device_release, >> -}; >> - >> -static int usb_hub_create_port_device(struct usb_hub *hub, >> - int port1) >> -{ >> -struct usb_port *port_dev = NULL; >> -int retval; >> - >> -port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL); >> -if (!port_dev) { >> -retval = -ENOMEM; >> -goto exit; >> -} >> - >> -hub->ports[port1 - 1] = port_dev; >> -port_dev->dev.parent = hub->intfdev; >> -port_dev->dev.groups = port_dev_group; >> -port_dev->dev.type = &usb_port_device_type; >> -dev_set_name(&port_dev->dev, "port%d", port1); >> - >> -retval = device_register(&port_dev->dev); >> -if (retval) >> -goto error_register; >> - >> -usb_acpi_register_power_resources(&port_dev->dev); >> - >> -return 0; >> - >> -error_register: >> -put_device(&port_dev->dev); >> -exit: >> -return retval; >> -} >> - >> static int hub_configure(struct usb_hub *hub, >> struct usb_endpoint_descriptor *endpoint) >> { >> @@ -1548,10 +1493,24 @@ static int hub_configure(struct usb_hub *hub, >> if (hub->has_indicators && blinkenlights) >> hub->indicator [0] = INDICATOR_CYCLE; >> >> -for (i = 0; i < hdev->maxchild; i++) >> -if (usb_hub_create_port_device(hub, i + 1) < 0) >> +for (i = 0; i < hdev->maxchild; i++) { >> +struct usb_port *port_dev = NULL; >> + >> +port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL); >> +if (!port_dev) { >> +dev_err(hub->intfdev, >> +"couldn't create port%d device due to lack >> mem.\n", i + 1); >> +continue; >> +} >> + >> +hu
Re: [PATCH v7 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs
Hi, On Mon, Nov 12, 2012 at 10:11 AM, Kukjin Kim wrote: > Felipe Balbi wrote: >> >> Hi, >> > Hi :-) > > [...] > >> Sure, but I still need Kukjin's 'say-so' for the arch/arm/plat-samsung >> and arch/arm/mach-exynos part. >> > Basically, this approach looks OK to me. > > BTW, I have some comments and need to update... Thanks! I highly appreciate your comments. It would have been even better if I had got these before the closing bell. > > From 4th patch... > >> diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c b/arch/arm/mach- >> s3c64xx/mach-smdk6410.c > > [...] > >> @@ -72,6 +73,8 @@ >> #include >> #include >> #include >> +#include Well it comes from an older state where without this it was giving a build error. Although it shouldn't have been here. Will fix it. > > Why? In addition, this causes build error with s3c6400_defconfig. > > [...] > >> diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c >> index 03f654d..9cdb666 100644 > > [...] > >> @@ -1370,6 +1371,30 @@ struct platform_device s5p_device_mixer = { >> >> /* USB */ >> >> +#ifdef CONFIG_S3C_DEV_USB_HSOTG >> +/* USB PHY*/ >> +static struct resource samsung_usbphy_resource[] = { >> + [0] = { >> + .start = S3C_PA_USB_PHY, >> + .end = S3C_PA_USB_PHY + SZ_16 - 1, >> + .flags = IORESOURCE_MEM, >> + }, >> +}; > > +static struct resource samsung_usbphy_resource[] = { > + [0] = DEFINED_RES_MEM(S3C_PA_USB_PHY, SZ_16), > +}; > > [...] > > Happens build error with s5pv210_defconfig > > arch/arm/plat-samsung/devs.c:1375: error: 'S3C_PA_USB_PHY' undeclared here > (not in a function) > make[2]: *** [arch/arm/plat-samsung/devs.o] Error 1 > make[1]: *** [arch/arm/plat-samsung] Error 2 > make[1]: *** Waiting for unfinished jobs > > And another build error with exynos_defconfig... Will check for both the configs and resolve it. Thanks, Praveen > > arch/arm/mach-exynos/built-in.o: In function `.LANCHOR1': > setup-i2c0.c:(.data+0x8080): undefined reference to > `s5p_usb_phy_pmu_isolation' > > From 5th patch > > If possible, please to use 'ARM: [sub-arch dir name]: [subject]' format. > So I preferred to use 'ARM: EXYNOS: Enabling samsung-usbphy driver for > EXYNOS4210' on that. > > Please make sure your patch has no problem for kernel compilation before > submitting... > > Thanks. > > Best regards, > Kgene. > -- > Kukjin Kim , Senior Engineer, > SW Solution Development Team, Samsung Electronics Co., Ltd. > > -- > To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" > in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs
Hi Kukjin, Felipe, Since the issue is only with arch patches, which I am going to resolve asap, Will it be possible for you to consider taking only driver patches? I can resend arch patches separately to linux-samsung after updating if Kukjin is also fine with that? Thanks, Praveen On Wed, Nov 14, 2012 at 9:38 AM, Praveen Paneri wrote: > Hi, > > On Mon, Nov 12, 2012 at 10:11 AM, Kukjin Kim wrote: >> Felipe Balbi wrote: >>> >>> Hi, >>> >> Hi :-) >> >> [...] >> >>> Sure, but I still need Kukjin's 'say-so' for the arch/arm/plat-samsung >>> and arch/arm/mach-exynos part. >>> >> Basically, this approach looks OK to me. >> >> BTW, I have some comments and need to update... > Thanks! I highly appreciate your comments. It would have been even > better if I had got these before the closing bell. >> >> From 4th patch... >> >>> diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c b/arch/arm/mach- >>> s3c64xx/mach-smdk6410.c >> >> [...] >> >>> @@ -72,6 +73,8 @@ >>> #include >>> #include >>> #include >>> +#include > Well it comes from an older state where without this it was giving a > build error. Although it shouldn't have been here. Will fix it. >> >> Why? In addition, this causes build error with s3c6400_defconfig. >> >> [...] >> >>> diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c >>> index 03f654d..9cdb666 100644 >> >> [...] >> >>> @@ -1370,6 +1371,30 @@ struct platform_device s5p_device_mixer = { >>> >>> /* USB */ >>> >>> +#ifdef CONFIG_S3C_DEV_USB_HSOTG >>> +/* USB PHY*/ >>> +static struct resource samsung_usbphy_resource[] = { >>> + [0] = { >>> + .start = S3C_PA_USB_PHY, >>> + .end = S3C_PA_USB_PHY + SZ_16 - 1, >>> + .flags = IORESOURCE_MEM, >>> + }, >>> +}; >> >> +static struct resource samsung_usbphy_resource[] = { >> + [0] = DEFINED_RES_MEM(S3C_PA_USB_PHY, SZ_16), >> +}; >> >> [...] >> >> Happens build error with s5pv210_defconfig >> >> arch/arm/plat-samsung/devs.c:1375: error: 'S3C_PA_USB_PHY' undeclared here >> (not in a function) >> make[2]: *** [arch/arm/plat-samsung/devs.o] Error 1 >> make[1]: *** [arch/arm/plat-samsung] Error 2 >> make[1]: *** Waiting for unfinished jobs >> >> And another build error with exynos_defconfig... > Will check for both the configs and resolve it. > > Thanks, > Praveen >> >> arch/arm/mach-exynos/built-in.o: In function `.LANCHOR1': >> setup-i2c0.c:(.data+0x8080): undefined reference to >> `s5p_usb_phy_pmu_isolation' >> >> From 5th patch >> >> If possible, please to use 'ARM: [sub-arch dir name]: [subject]' format. >> So I preferred to use 'ARM: EXYNOS: Enabling samsung-usbphy driver for >> EXYNOS4210' on that. >> >> Please make sure your patch has no problem for kernel compilation before >> submitting... >> >> Thanks. >> >> Best regards, >> Kgene. >> -- >> Kukjin Kim , Senior Engineer, >> SW Solution Development Team, Samsung Electronics Co., Ltd. >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" >> in >> the body of a message to majord...@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Device detected as Digitalcamera (PTP?) instead of Portable Device (MTP?) - MS_COMP_MTP - WinXP
Karl Krach wrote: > Thanks a lot. It seams that the Android [1] has the 'Microsoft OS > Descriptors' implemented while Meego has not. Porting from the Android code > don't seems to be straightforward for me - do you know a better solution? Reimplement them? It shouldn't be terribly much work - it's one string descriptor and one type vendor recipient device control request. > According Brett [2] the 'Microsoft OS Descriptors' are required to get > MTP running on WinXP. They also say, that they are only requested if > using 'Vendor Class Codes' - otherwise PHP is used. I don't know about that. Please let me know if you do some tests though. Note that you'll need to clean your registry, or bump vidpid, or change USB port, each time you unplug/replug the device while testing. //Peter -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH -next v2] usb: gadget: tcm_usb_gadge: fix to return error or 0 in tcm_usbg_drop_nexus()
From: Wei Yongjun In the error handling case of tcm_usbg_drop_nexus(), the error code is assigned to 'ret', but it is ignored. We'd better return 'ret' instead of always return 0. dpatch engine is used to auto generate this patch. (https://github.com/weiyj/dpatch) Signed-off-by: Wei Yongjun --- v1 -> v2: s/ingored/ignored/ --- drivers/usb/gadget/tcm_usb_gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c index 4f7f76f..7cacd6a 100644 --- a/drivers/usb/gadget/tcm_usb_gadget.c +++ b/drivers/usb/gadget/tcm_usb_gadget.c @@ -1794,9 +1794,10 @@ static int tcm_usbg_drop_nexus(struct usbg_tpg *tpg) tpg->tpg_nexus = NULL; kfree(tv_nexus); + ret = 0; out: mutex_unlock(&tpg->tpg_mutex); - return 0; + return ret; } static ssize_t tcm_usbg_tpg_store_nexus( -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH -next v2] usb: gadget: tcm_usb_gadge: fix to return error or 0 in tcm_usbg_drop_nexus()
Hi, On Wed, Nov 14, 2012 at 01:47:23PM +0800, Wei Yongjun wrote: > From: Wei Yongjun > > In the error handling case of tcm_usbg_drop_nexus(), the error code > is assigned to 'ret', but it is ignored. We'd better return 'ret' > instead of always return 0. > > dpatch engine is used to auto generate this patch. > (https://github.com/weiyj/dpatch) > > Signed-off-by: Wei Yongjun Sebastian, is this ok for you ? > --- > v1 -> v2: s/ingored/ignored/ > --- > drivers/usb/gadget/tcm_usb_gadget.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/gadget/tcm_usb_gadget.c > b/drivers/usb/gadget/tcm_usb_gadget.c > index 4f7f76f..7cacd6a 100644 > --- a/drivers/usb/gadget/tcm_usb_gadget.c > +++ b/drivers/usb/gadget/tcm_usb_gadget.c > @@ -1794,9 +1794,10 @@ static int tcm_usbg_drop_nexus(struct usbg_tpg *tpg) > tpg->tpg_nexus = NULL; > > kfree(tv_nexus); > + ret = 0; > out: > mutex_unlock(&tpg->tpg_mutex); > - return 0; > + return ret; > } > > static ssize_t tcm_usbg_tpg_store_nexus( > > -- balbi signature.asc Description: Digital signature
[PATCH] Try #2: Use SCSI read/write(16) with >2TB drives
From: "Jason J. Herne" Force large capacity (> 2TB) drives to use READ/WRITE(16) instead of READ/WRITE(10). Some(most/all?) USB enclosures do not like READ(10) commands when a large capacity drive is installed. Signed-off-by: Jason J. Herne --- drivers/scsi/sd.c |5 - include/scsi/scsi_device.h |1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 12f6fdf..9611d6b 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -887,7 +887,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) SCpnt->cmnd[29] = (unsigned char) (this_count >> 16) & 0xff; SCpnt->cmnd[30] = (unsigned char) (this_count >> 8) & 0xff; SCpnt->cmnd[31] = (unsigned char) this_count & 0xff; - } else if (block > 0x) { + } else if (sdp->use_16_for_rw) { SCpnt->cmnd[0] += READ_16 - READ_6; SCpnt->cmnd[1] = protect | ((rq->cmd_flags & REQ_FUA) ? 0x8 : 0); SCpnt->cmnd[2] = sizeof(block) > 4 ? (unsigned char) (block >> 56) & 0xff : 0; @@ -2054,6 +2054,9 @@ got_data: } } + /* Use read/write(16) for > 2TB disks */ + sdp->use_16_for_rw = (sdkp->capacity > 0x); + /* Rescale capacity to 512-byte units */ if (sector_size == 4096) sdkp->capacity <<= 3; diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 88fae8d..19ab8f1 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -135,6 +135,7 @@ struct scsi_device { * because we did a bus reset. */ unsigned use_10_for_rw:1; /* first try 10-byte read / write */ unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */ + unsigned use_16_for_rw:1; /* Use read/write(16) over read/write(10) */ unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */ unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */ unsigned skip_vpd_pages:1; /* do not read VPD pages */ -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH v2 3/6] usb: add runtime pm support for usb port device
On 2012年11月14日 08:08, Rafael J. Wysocki wrote: > On Tuesday, November 13, 2012 04:00:02 PM Lan Tianyu wrote: >> This patch is to add runtime pm callback for usb port device. >> Set/clear PORT_POWER feature in the resume/suspend callbak. >> Add portnum for struct usb_port to record port number. >> >> Signed-off-by: Lan Tianyu > > This one looks reasonable to me. From the PM side > > Acked-by: Rafael J. Wysocki Hi Rafael and Alan: This patch has a collaboration problem with pm qos. Since pm core would pm_runtime_get_sync/put(port_dev) if pm qos flags was changed and port's suspend call_back() clear PORT_POWER feature without any check. This will cause PORT_POWER feather being cleared every time after pm qos flags being changed. I have an idea that add check in the port's runtime idle callback. Check NO_POWER_OFF flag firstly. If set return. Second, for port without device, suspend port directly and for port with device, increase child device's runtime usage without resume and do barrier to ensure all suspend process finish, at last check the child runtime status. If it was suspended, suspend port and if do nothing. static int usb_port_runtime_idle(struct device *dev) { struct usb_port *port_dev = to_usb_port(dev); int retval = 0; if (dev_pm_qos_flags(&port_dev->dev, PM_QOS_FLAG_NO_POWER_OFF) == PM_QOS_FLAGS_ALL) return 0; if (!port_dev->child) { retval = pm_runtime_suspend(&port_dev->dev); if (!retval) port_dev->power_on =false; } else { pm_runtime_get_noresume(&port_dev->child->dev); pm_runtime_barrier(&port_dev->child->dev); if (port_dev->child->dev.power.runtime_status == RPM_SUSPENDED) { retval = pm_runtime_suspend(&port_dev->dev); if (!retval) port_dev->power_on =false; } pm_runtime_put_noidle(&port_dev->child->dev); } return retval; } I'd like to see your opinion :) thanks. > >> --- >> drivers/usb/core/hub.c | 14 ++ >> drivers/usb/core/port.c | 39 +++ >> drivers/usb/core/usb.h |2 ++ >> include/linux/usb.h |2 ++ >> 4 files changed, 57 insertions(+) >> >> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c >> index 60746aa..2cb414e 100644 >> --- a/drivers/usb/core/hub.c >> +++ b/drivers/usb/core/hub.c >> @@ -765,6 +765,20 @@ static void hub_tt_work(struct work_struct *work) >> spin_unlock_irqrestore (&hub->tt.lock, flags); >> } >> >> +int usb_hub_set_port_power(struct usb_device *hdev, int port1, >> +bool set) >> +{ >> +int ret; >> + >> +if (set) >> +ret = set_port_feature(hdev, port1, >> +USB_PORT_FEAT_POWER); >> +else >> +ret = clear_port_feature(hdev, port1, >> +USB_PORT_FEAT_POWER); >> +return ret; >> +} >> + >> /** >> * usb_hub_clear_tt_buffer - clear control/bulk TT state in high speed hub >> * @urb: an URB associated with the failed or incomplete split transaction >> diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c >> index 6523a03..1cda766 100644 >> --- a/drivers/usb/core/port.c >> +++ b/drivers/usb/core/port.c >> @@ -53,9 +53,45 @@ static void usb_port_device_release(struct device *dev) >> kfree(port_dev); >> } >> >> +static int usb_port_runtime_resume(struct device *dev) >> +{ >> +struct usb_port *port_dev = to_usb_port(dev); >> +struct usb_device *hdev = >> +to_usb_device(dev->parent->parent); >> + >> +return usb_hub_set_port_power(hdev, port_dev->portnum, >> +true); >> +} >> + >> +static int usb_port_runtime_suspend(struct device *dev) >> +{ >> +struct usb_port *port_dev = to_usb_port(dev); >> +struct usb_device *hdev = >> +to_usb_device(dev->parent->parent); >> + >> +return usb_hub_set_port_power(hdev, port_dev->portnum, >> +false); >> +} >> + >> +static int usb_port_runtime_idle(struct device *dev) >> +{ >> +struct usb_port *port_dev = to_usb_port(dev); >> + >> +return pm_runtime_suspend(&port_dev->dev); >> +} >> + >> +static const struct dev_pm_ops usb_port_pm_ops = { >> +#ifdef CONFIG_USB_SUSPEND >> +.runtime_suspend = usb_port_runtime_suspend, >> +.runtime_resume = usb_port_runtime_resume, >> +.runtime_idle = usb_port_runtime_idle, >> +#endif >> +}; >> + >> struct device_type usb_port_device_type = { >> .name = "usb_port", >> .release = usb_port_device_release, >> +.pm = &usb_port_pm_ops, >> }; >> >> int usb_hub_create_port_device(struct device *intfdev, >> @@ -63,6 +99,7 @@ int usb_hub_create_port_device(struct device *intfdev, >> { >>