Re: [PATCH v7 0/4] Introduce usb charger framework to deal with the usb gadget power negotation
On 7 January 2016 at 19:25, Alex Shiwrote: > Hi, Baolin, > > There is similar gadget/charger driver on QC msm tree, > git://codeaurora.org/quic/la/kernel/msm-3.10 msm-3.10 > You may check that as a reference. > OK. Thanks. -- Baolin.wang Best Regards -- 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] r8152: fix the wake event
When the autosuspend is enabled and occurs before system suspend, we should wake the device before running system syspend. Then, we could change the wake event for system suspend. Otherwise, the device would resume the system when receiving any packet. Signed-off-by: Hayes Wang--- drivers/net/usb/r8152.c | 40 +++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 2fb637a..ef9aab6 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -25,12 +25,13 @@ #include #include #include +#include /* Information for net-next */ #define NETNEXT_VERSION"08" /* Information for net */ -#define NET_VERSION"2" +#define NET_VERSION"3" #define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION #define DRIVER_AUTHOR "Realtek linux nic maintainers " @@ -604,6 +605,9 @@ struct r8152 { struct delayed_work schedule; struct mii_if_info mii; struct mutex control; /* use for hw setting */ +#ifdef CONFIG_PM_SLEEP + struct notifier_block pm_notifier; +#endif struct rtl_ops { void (*init)(struct r8152 *); @@ -3048,6 +3052,33 @@ out1: usb_autopm_put_interface(tp->intf); } +#ifdef CONFIG_PM_SLEEP +static int rtl_notifier(struct notifier_block *nb, unsigned long action, + void *data) +{ + struct r8152 *tp = container_of(nb, struct r8152, pm_notifier); + + switch (action) { + case PM_HIBERNATION_PREPARE: + case PM_SUSPEND_PREPARE: + usb_autopm_get_interface(tp->intf); + break; + + case PM_POST_HIBERNATION: + case PM_POST_SUSPEND: + usb_autopm_put_interface(tp->intf); + break; + + case PM_POST_RESTORE: + case PM_RESTORE_PREPARE: + default: + break; + } + + return NOTIFY_DONE; +} +#endif + static int rtl8152_open(struct net_device *netdev) { struct r8152 *tp = netdev_priv(netdev); @@ -3090,6 +3121,10 @@ static int rtl8152_open(struct net_device *netdev) mutex_unlock(>control); usb_autopm_put_interface(tp->intf); +#ifdef CONFIG_PM_SLEEP + tp->pm_notifier.notifier_call = rtl_notifier; + register_pm_notifier(>pm_notifier); +#endif out: return res; @@ -3100,6 +3135,9 @@ static int rtl8152_close(struct net_device *netdev) struct r8152 *tp = netdev_priv(netdev); int res = 0; +#ifdef CONFIG_PM_SLEEP + unregister_pm_notifier(>pm_notifier); +#endif napi_disable(>napi); clear_bit(WORK_ENABLE, >flags); usb_kill_urb(tp->intr_urb); -- 2.4.3 -- 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-next 0/2] r8152: code adjustment
Adjust test_bit(), clear_bit(), disable_aldps(), and enable_aldps(). Hayes Wang (2): r8152: use test_and_clear_bit r8152: adjust ALDPS function drivers/net/usb/r8152.c | 92 + 1 file changed, 40 insertions(+), 52 deletions(-) -- 2.4.3 -- 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-next 2/2] r8152: adjust ALDPS function
Replace disable_aldps() and enable_aldps() with aldps_en(). Signed-off-by: Hayes Wang--- drivers/net/usb/r8152.c | 72 +++-- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 4f0bb67..230c73c 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -2452,23 +2452,23 @@ static void r8153_teredo_off(struct r8152 *tp) ocp_write_dword(tp, MCU_TYPE_PLA, PLA_TEREDO_TIMER, 0); } -static void r8152b_disable_aldps(struct r8152 *tp) +static void r8152_aldps_en(struct r8152 *tp, bool enable) { - ocp_reg_write(tp, OCP_ALDPS_CONFIG, ENPDNPS | LINKENA | DIS_SDSAVE); - msleep(20); -} - -static inline void r8152b_enable_aldps(struct r8152 *tp) -{ - ocp_reg_write(tp, OCP_ALDPS_CONFIG, ENPWRSAVE | ENPDNPS | - LINKENA | DIS_SDSAVE); + if (enable) { + ocp_reg_write(tp, OCP_ALDPS_CONFIG, ENPWRSAVE | ENPDNPS | + LINKENA | DIS_SDSAVE); + } else { + ocp_reg_write(tp, OCP_ALDPS_CONFIG, ENPDNPS | LINKENA | + DIS_SDSAVE); + msleep(20); + } } static void rtl8152_disable(struct r8152 *tp) { - r8152b_disable_aldps(tp); + r8152_aldps_en(tp, false); rtl_disable(tp); - r8152b_enable_aldps(tp); + r8152_aldps_en(tp, true); } static void r8152b_hw_phy_cfg(struct r8152 *tp) @@ -2780,30 +2780,26 @@ static void r8153_enter_oob(struct r8152 *tp) ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); } -static void r8153_disable_aldps(struct r8152 *tp) +static void r8153_aldps_en(struct r8152 *tp, bool enable) { u16 data; data = ocp_reg_read(tp, OCP_POWER_CFG); - data &= ~EN_ALDPS; - ocp_reg_write(tp, OCP_POWER_CFG, data); - msleep(20); -} - -static void r8153_enable_aldps(struct r8152 *tp) -{ - u16 data; - - data = ocp_reg_read(tp, OCP_POWER_CFG); - data |= EN_ALDPS; - ocp_reg_write(tp, OCP_POWER_CFG, data); + if (enable) { + data |= EN_ALDPS; + ocp_reg_write(tp, OCP_POWER_CFG, data); + } else { + data &= ~EN_ALDPS; + ocp_reg_write(tp, OCP_POWER_CFG, data); + msleep(20); + } } static void rtl8153_disable(struct r8152 *tp) { - r8153_disable_aldps(tp); + r8153_aldps_en(tp, false); rtl_disable(tp); - r8153_enable_aldps(tp); + r8153_aldps_en(tp, true); usb_enable_lpm(tp->udev); } @@ -2900,9 +2896,9 @@ static void rtl8152_up(struct r8152 *tp) if (test_bit(RTL8152_UNPLUG, >flags)) return; - r8152b_disable_aldps(tp); + r8152_aldps_en(tp, false); r8152b_exit_oob(tp); - r8152b_enable_aldps(tp); + r8152_aldps_en(tp, true); } static void rtl8152_down(struct r8152 *tp) @@ -2913,9 +2909,9 @@ static void rtl8152_down(struct r8152 *tp) } r8152_power_cut_en(tp, false); - r8152b_disable_aldps(tp); + r8152_aldps_en(tp, false); r8152b_enter_oob(tp); - r8152b_enable_aldps(tp); + r8152_aldps_en(tp, true); } static void rtl8153_up(struct r8152 *tp) @@ -2924,9 +2920,9 @@ static void rtl8153_up(struct r8152 *tp) return; r8153_u1u2en(tp, false); - r8153_disable_aldps(tp); + r8153_aldps_en(tp, false); r8153_first_init(tp); - r8153_enable_aldps(tp); + r8153_aldps_en(tp, true); r8153_u2p3en(tp, true); r8153_u1u2en(tp, true); usb_enable_lpm(tp->udev); @@ -2942,9 +2938,9 @@ static void rtl8153_down(struct r8152 *tp) r8153_u1u2en(tp, false); r8153_u2p3en(tp, false); r8153_power_cut_en(tp, false); - r8153_disable_aldps(tp); + r8153_aldps_en(tp, false); r8153_enter_oob(tp); - r8153_enable_aldps(tp); + r8153_aldps_en(tp, true); } static bool rtl8152_in_nway(struct r8152 *tp) @@ -3230,7 +3226,7 @@ static void r8152b_init(struct r8152 *tp) if (test_bit(RTL8152_UNPLUG, >flags)) return; - r8152b_disable_aldps(tp); + r8152_aldps_en(tp, false); if (tp->version == RTL_VER_01) { ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE); @@ -3252,7 +3248,7 @@ static void r8152b_init(struct r8152 *tp) ocp_write_word(tp, MCU_TYPE_PLA, PLA_GPHY_INTR_IMR, ocp_data); r8152b_enable_eee(tp); - r8152b_enable_aldps(tp); + r8152_aldps_en(tp, true); r8152b_enable_fc(tp); rtl_tally_reset(tp); @@ -3270,7 +3266,7 @@ static void r8153_init(struct r8152 *tp) if (test_bit(RTL8152_UNPLUG, >flags)) return; - r8153_disable_aldps(tp); + r8153_aldps_en(tp, false);
[PATCH net-next 1/2] r8152: use test_and_clear_bit
Replace test_bit() followed by clear_bit() with test_and_clear_bit(). Signed-off-by: Hayes Wang--- drivers/net/usb/r8152.c | 20 ++-- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 975e917..4f0bb67 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -1938,7 +1938,6 @@ static void _rtl8152_set_rx_mode(struct net_device *netdev) __le32 tmp[2]; u32 ocp_data; - clear_bit(RTL8152_SET_RX_MODE, >flags); netif_stop_queue(netdev); ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); ocp_data &= ~RCR_ACPT_ALL; @@ -2424,8 +2423,6 @@ static void rtl_phy_reset(struct r8152 *tp) u16 data; int i; - clear_bit(PHY_RESET, >flags); - data = r8152_mdio_read(tp, MII_BMCR); /* don't reset again before the previous one complete */ @@ -2884,10 +2881,9 @@ static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex) r8152_mdio_write(tp, MII_ADVERTISE, anar); r8152_mdio_write(tp, MII_BMCR, bmcr); - if (test_bit(PHY_RESET, >flags)) { + if (test_and_clear_bit(PHY_RESET, >flags)) { int i; - clear_bit(PHY_RESET, >flags); for (i = 0; i < 50; i++) { msleep(20); if ((r8152_mdio_read(tp, MII_BMCR) & BMCR_RESET) == 0) @@ -2896,7 +2892,6 @@ static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex) } out: - return ret; } @@ -2983,7 +2978,6 @@ static void set_carrier(struct r8152 *tp) struct net_device *netdev = tp->netdev; u8 speed; - clear_bit(RTL8152_LINK_CHG, >flags); speed = rtl8152_get_speed(tp); if (speed & LINK_STATUS) { @@ -3026,20 +3020,18 @@ static void rtl_work_func_t(struct work_struct *work) goto out1; } - if (test_bit(RTL8152_LINK_CHG, >flags)) + if (test_and_clear_bit(RTL8152_LINK_CHG, >flags)) set_carrier(tp); - if (test_bit(RTL8152_SET_RX_MODE, >flags)) + if (test_and_clear_bit(RTL8152_SET_RX_MODE, >flags)) _rtl8152_set_rx_mode(tp->netdev); /* don't schedule napi before linking */ - if (test_bit(SCHEDULE_NAPI, >flags) && - netif_carrier_ok(tp->netdev)) { - clear_bit(SCHEDULE_NAPI, >flags); + if (test_and_clear_bit(SCHEDULE_NAPI, >flags) && + netif_carrier_ok(tp->netdev)) napi_schedule(>napi); - } - if (test_bit(PHY_RESET, >flags)) + if (test_and_clear_bit(PHY_RESET, >flags)) rtl_phy_reset(tp); mutex_unlock(>control); -- 2.4.3 -- 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: option.c: Fix Cinterion AHxx enumeration.
Hi Johan, Apologies for the late reply, I was out of office. Below is the 'lsusb -v' output for the AH3 modem. For the mailing lists: Please CC me directly, I did not sign up for the mailing lists. Thank you. Best regards // John Ernberg Bus 001 Device 002: ID 1e2d:0055 Device Descriptor: bLength18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 239 Miscellaneous Device bDeviceSubClass 2 ? bDeviceProtocol 1 Interface Association bMaxPacketSize064 idVendor 0x1e2d idProduct 0x0055 bcdDevice0.00 iManufacturer 4 Cinterion iProduct3 AHx iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 187 bNumInterfaces 6 bConfigurationValue 1 iConfiguration 2 Qualcomm Configuration bmAttributes 0xe0 Self Powered Remote Wakeup MaxPower 10mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber0 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass255 Vendor Specific Subclass bInterfaceProtocol255 Vendor Specific Protocol iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 32 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 32 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber1 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass255 Vendor Specific Subclass bInterfaceProtocol255 Vendor Specific Protocol iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 32 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 32 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber2 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass255 Vendor Specific Subclass bInterfaceProtocol255 Vendor Specific Protocol iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 32 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 32 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber3 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass255 Vendor Specific Subclass bInterfaceProtocol255 Vendor Specific Protocol iInterface 0
Re: [PATCH 4/5] usb-misc: sisusbvga: Remove kmalloc logs and fix error path
On Wed, Jan 06, 2016 at 09:28:41PM +0300, Sergei Shtylyov wrote: > Hello. > > On 1/5/2016 7:54 PM, Peter Senna Tschudin wrote: > > >From: Peter Senna Tschudin> > > >This patch remove four calls to dev_err() from sisusb_probe() as > >reporting memory allocation failures is redundant: > > > > - Remove a call to dev_err() that was reporting unsuccesful call to > >kzalloc(). > > > > - Remove two calls to dev_err() that were reporting unsuccesful calls > >to kmalloc(). > > > > - Remove a call to dev_err() that was reporting unsuccesful call to > >kmalloc(), and replace it by code that clean up previously allocated > >resources and abort the probe with -ENOMEM. Before this modification > >sisusb->SiS_Pr could be dereferenced even it was null. > >I think the bug fix should be in its own patch. Don't intermix fixes with > cleanups please. Ok, I'll resend the series with the following changes: - split patch 1: vertical and horizontal changes - split patch 4: cleanups and fix -- 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] usb: gadget: fix error handling
We are doing PTR_ERR() of NULL, and that will actually make ret = 0. So incase of both error and success we are actually returning the success code. Signed-off-by: Sudip Mukherjee--- drivers/usb/gadget/composite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 8b14c2a..17ce6b5 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -2017,14 +2017,14 @@ int composite_os_desc_req_prepare(struct usb_composite_dev *cdev, cdev->os_desc_req = usb_ep_alloc_request(ep0, GFP_KERNEL); if (!cdev->os_desc_req) { - ret = PTR_ERR(cdev->os_desc_req); + ret = -ENOMEM; goto end; } /* OS feature descriptor length <= 4kB */ cdev->os_desc_req->buf = kmalloc(4096, GFP_KERNEL); if (!cdev->os_desc_req->buf) { - ret = PTR_ERR(cdev->os_desc_req->buf); + ret = -ENOMEM; kfree(cdev->os_desc_req); goto end; } -- 1.9.1 -- 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 v12 0/4] Allow USB devices to remain runtime-suspended when sleeping
Hi, this is v12 of an attempt to make it easier for devices to remain in runtime PM when the system goes to sleep, mainly to reduce the time spent resuming devices. For this, we interpret the absence of all PM callback implementations as it being safe to do direct_complete, so their ancestors aren't prevented from remaining runtime-suspended. Additionally, the prepare() callback of USB devices will return 1 if runtime PM is enabled and the current wakeup settings are correct. With these changes, a uvcvideo device (for example) stays in runtime suspend when the system goes to sleep and is left in that state when the system resumes, not delaying it unnecessarily. Thanks, Tomeu Changes in v12: - Include linux/pm_domain.h in vga_switcheroo.c for dev_pm_domain_set() Changes in v11: - Move calls to dev_pm_domain_set() out from >power.lock as that isn't needed for dev->pm_domain. Changes in v10: - Remove superfluous call to pm_runtime_enabled() as suggested by Alan Changes in v9: - Add docs noting the need for the device lock to be held before calling device_is_bound() - Add docs noting the need for the device lock to be held before calling dev_pm_domain_set() - Move to CONFIG_PM_SLEEP as suggested by Rafael and Ulf. - Rename from device_check_pm_callbacks to device_pm_check_callbacks to follow with the naming convention of existing API. - Re-add calling to device_pm_check_callbacks from device registration and when updating the PM domain of a device. Changes in v8: - Add device_is_bound() - Add dev_pm_domain_set() and update code to use it - Move no_pm_callbacks field into CONFIG_PM_SLEEP - Call device_check_pm_callbacks only after a device is bound or unbound Changes in v7: - Reduce indentation by adding a label in device_prepare() Changes in v6: - Add stub for !CONFIG_PM. - Move implementation of device_check_pm_callbacks to power/main.c as it doesn't belong to CONFIG_PM_SLEEP. - Take dev->power.lock before modifying flag. Changes in v5: - Check for all dev_pm_ops instances associated to a device, updating a no_pm_callbacks flag at the times when that could change. Tomeu Vizoso (4): device core: add device_is_bound() PM / Domains: add setter for dev.pm_domain PM / sleep: Go direct_complete if driver has no callbacks USB / PM: Allow USB devices to remain runtime-suspended when sleeping arch/arm/mach-omap2/omap_device.c | 7 --- drivers/acpi/acpi_lpss.c | 5 - drivers/acpi/device_pm.c | 5 +++-- drivers/base/dd.c | 21 +++-- drivers/base/power/clock_ops.c| 5 +++-- drivers/base/power/common.c | 24 drivers/base/power/domain.c | 8 ++-- drivers/base/power/main.c | 35 +++ drivers/base/power/power.h| 3 +++ drivers/gpu/vga/vga_switcheroo.c | 11 ++- drivers/misc/mei/pci-me.c | 5 +++-- drivers/misc/mei/pci-txe.c| 5 +++-- drivers/usb/core/port.c | 6 ++ drivers/usb/core/usb.c| 8 +++- include/linux/device.h| 2 ++ include/linux/pm.h| 1 + include/linux/pm_domain.h | 3 +++ 17 files changed, 132 insertions(+), 22 deletions(-) -- 2.5.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: xhci regression for large transfers (commit e210c422b)
On Thu, Jan 07, 2016 at 05:38:09PM +0200, Mathias Nyman wrote: > Hi > > On 02.01.2016 08:32, Ron wrote: > > > >Hi, > > > >It appears the commit e210c422b6fdd2dc123bedc588f399aefd8bf9de > >"xhci: don't finish a TD if we get a short transfer event mid TD" > >is causing transfers larger than 16kB to be unreliable. > > > >If I limit transfers to be no larger than 16kB, then it also works as > >expected in an XHCI port with an unmodified build of Linus' current > >head (v4.4-rc7-76-g9c982e8), but transfers larger than that do not. > >I see an alternating cycle of a successful transfer, followed by two > >that will time out waiting in libusb (with a 5 second timeout set), > >before getting another successful transfer and the cycle repeating. > > > >I can run more tests and dig into this deeper if the reason for it > >isn't immediately obvious in hindsight. > > > > Thanks for the info, > I can't spot anything obvious, but my brain might still be in vacation mode. > > Could you reproduce it with the attached patch, it only adds extra debugging? > > We should either see no output, or the following sequence: > > 1. "mid bulk/intr SP, wait for last TRB event" > 2. "last trb has length set" > 3. "and last trb is SHORT_TX, OK" I guess one out of 3 ain't good ... all I see logged is: [ 60.015708] xhci_hcd :04:00.0: mid bulk/intr SP, wait for last TRB event [ 65.017374] xhci_hcd :04:00.0: mid bulk/intr SP, wait for last TRB event [ 70.455451] xhci_hcd :04:00.0: mid bulk/intr SP, wait for last TRB event [ 75.456248] xhci_hcd :04:00.0: mid bulk/intr SP, wait for last TRB event I'm passing 5 seconds to libusb as the requested timeout. Ron > From 1b9abc3d47f2c3fcb75209560b7226d99db7def9 Mon Sep 17 00:00:00 2001 > From: Mathias Nyman> Date: Thu, 7 Jan 2016 17:22:09 +0200 > Subject: [PATCH] xhci: FOR TESTING ONLY add verbose debugging for short bulk > transfers > > patch > e210c422b6fdd2dc123bedc588f399aefd8bf9de > "xhci: don't finish a TD if we get a short transfer event mid TD" > caused regression for 64k bulk tranfers. > > Tt wont return the URB in case we get a short transfer trb mid TD. > It waits for the last TRB which should be short as well. > > Add debugging for the short bulk tranfer case > > Signed-off-by: Mathias Nyman > --- > drivers/usb/host/xhci-ring.c | 16 +++- > 1 file changed, 11 insertions(+), 5 deletions(-) > > diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c > index eeaa6c6..ed6ac7e 100644 > --- a/drivers/usb/host/xhci-ring.c > +++ b/drivers/usb/host/xhci-ring.c > @@ -2192,10 +2192,16 @@ static int process_bulk_intr_td(struct xhci_hcd > *xhci, struct xhci_td *td, > } > /* Fast path - was this the last TRB in the TD for this URB? */ > } else if (event_trb == td->last_trb) { > - if (td->urb_length_set && trb_comp_code == COMP_SHORT_TX) > - return finish_td(xhci, td, event_trb, event, ep, > - status, false); > - > + if (td->urb_length_set) { > + xhci_warn(xhci, "last trb has length set\n"); > + if (trb_comp_code == COMP_SHORT_TX) { > + xhci_warn(xhci, "and last trb is SHORT_TX, > OK\n"); > + return finish_td(xhci, td, event_trb, event, ep, > + status, false); > + } else { > + xhci_warn(xhci, "FAIL, expected SHORT_TX last > trb\n"); > + } > + } > if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) { > td->urb->actual_length = > td->urb->transfer_buffer_length - > @@ -2249,7 +2255,7 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, > struct xhci_td *td, > EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); > > if (trb_comp_code == COMP_SHORT_TX) { > - xhci_dbg(xhci, "mid bulk/intr SP, wait for last TRB > event\n"); > + xhci_warn(xhci, "mid bulk/intr SP, wait for last TRB > event\n"); > td->urb_length_set = true; > return 0; > } > -- > 1.9.1 > -- 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: xhci regression for large transfers (commit e210c422b)
On Fri, Jan 08, 2016 at 02:52:28AM +1030, Ron wrote: > On Thu, Jan 07, 2016 at 05:38:09PM +0200, Mathias Nyman wrote: > > Hi > > > > On 02.01.2016 08:32, Ron wrote: > > > > > >Hi, > > > > > >It appears the commit e210c422b6fdd2dc123bedc588f399aefd8bf9de > > >"xhci: don't finish a TD if we get a short transfer event mid TD" > > >is causing transfers larger than 16kB to be unreliable. > > > > > >If I limit transfers to be no larger than 16kB, then it also works as > > >expected in an XHCI port with an unmodified build of Linus' current > > >head (v4.4-rc7-76-g9c982e8), but transfers larger than that do not. > > >I see an alternating cycle of a successful transfer, followed by two > > >that will time out waiting in libusb (with a 5 second timeout set), > > >before getting another successful transfer and the cycle repeating. > > > > > >I can run more tests and dig into this deeper if the reason for it > > >isn't immediately obvious in hindsight. > > > > > > > Thanks for the info, > > I can't spot anything obvious, but my brain might still be in vacation mode. > > > > Could you reproduce it with the attached patch, it only adds extra > > debugging? > > > > We should either see no output, or the following sequence: > > > > 1. "mid bulk/intr SP, wait for last TRB event" > > 2. "last trb has length set" > > 3. "and last trb is SHORT_TX, OK" > > > I guess one out of 3 ain't good ... all I see logged is: > > [ 60.015708] xhci_hcd :04:00.0: mid bulk/intr SP, wait for last TRB > event > [ 65.017374] xhci_hcd :04:00.0: mid bulk/intr SP, wait for last TRB > event > [ 70.455451] xhci_hcd :04:00.0: mid bulk/intr SP, wait for last TRB > event > [ 75.456248] xhci_hcd :04:00.0: mid bulk/intr SP, wait for last TRB > event > > I'm passing 5 seconds to libusb as the requested timeout. And if I limit the maximum transfer size to 16kB (the above was with 64kB transfers), then I see nothing logged at all. So if that code does indeed look sane, perhaps the issue is really in the code that's splitting large transfers doing something funny? Ron -- 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] drivers/usb: Skip auto handoff for TI and RENESAS usb controllers
I have never seen auto handoff working on TI and RENESAS cards. Eventually, we force handoff. This code forces the handoff unconditionally. It saves 5 seconds boot time for each card. Signed-off-by: Babu Moger--- drivers/usb/host/pci-quirks.c |7 +++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index f940056..b7ee895 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c @@ -1003,6 +1003,13 @@ static void quirk_usb_handoff_xhci(struct pci_dev *pdev) ext_cap_offset = xhci_find_next_cap_offset(base, ext_cap_offset); } while (1); + /* Auto handoff never worked for these devices. Force it and continue */ + if (pdev->vendor == PCI_VENDOR_ID_TI || + pdev->vendor == PCI_VENDOR_ID_RENESAS) { + val = (val | XHCI_HC_OS_OWNED) & ~XHCI_HC_BIOS_OWNED; + writel(val, base + ext_cap_offset); + } + /* If the BIOS owns the HC, signal that the OS wants it, and wait */ if (val & XHCI_HC_BIOS_OWNED) { writel(val | XHCI_HC_OS_OWNED, base + ext_cap_offset); -- 1.7.1 -- 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 v12 4/4] USB / PM: Allow USB devices to remain runtime-suspended when sleeping
Have dev_pm_ops.prepare return 1 for USB devices and ports so that USB devices can remain runtime-suspended when the system goes to a sleep state, if their wakeup state is correct and they have runtime PM enabled. Signed-off-by: Tomeu VizosoReviewed-by: Ulf Hansson Acked-by: Alan Stern --- Changes in v10: - Remove superfluous call to pm_runtime_enabled() as suggested by Alan drivers/usb/core/port.c | 6 ++ drivers/usb/core/usb.c | 8 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index 460c855be0d0..14718a9ffcfb 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -249,12 +249,18 @@ static int usb_port_runtime_suspend(struct device *dev) return retval; } + +static int usb_port_prepare(struct device *dev) +{ + return 1; +} #endif static const struct dev_pm_ops usb_port_pm_ops = { #ifdef CONFIG_PM .runtime_suspend = usb_port_runtime_suspend, .runtime_resume = usb_port_runtime_resume, + .prepare = usb_port_prepare, #endif }; diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 77e4c9bc0ab1..ebb29caa3fe4 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -311,7 +311,13 @@ static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env) static int usb_dev_prepare(struct device *dev) { - return 0; /* Implement eventually? */ + struct usb_device *udev = to_usb_device(dev); + + /* Return 0 if the current wakeup setting is wrong, otherwise 1 */ + if (udev->do_remote_wakeup != device_may_wakeup(dev)) + return 0; + + return 1; } static void usb_dev_complete(struct device *dev) -- 2.5.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