Re: USB Bluetooth dongle stop response with timeout error
On Mi, 2018-10-31 at 12:32 +0800, Morikazu Fumita wrote: > > My test procedure is below (assuming Bluetooth devices are already paired). > > 1. Adding a network bridge for PAN using "brctl". > 2. Link the bridge up. > 3. Run "hciconfig hci0 up" to power the USB Bluetooth dongle up. > 4. Register "nap" service and the network bridge to > "org.bluez.NetworkServer1" > via d-bus using a Python script. > 5. Bluez makes "bnep0" virtual network interface automatically. > 6. Connect to the PAN-NAP server from the client. Network is working > fine at > this point. > (Note: The hang does not happen even if turning promiscuous mode off at > this > point by running "ip link set bnep0 promisc off") > 7. Disconnect PAN from the client or make the "bnep0" virtual network > adapter > down by running "ip link set bnep0 down". > 8. The hang happens with "Bluetooth: hci0: command 0x tx timeout" > errors. > 9. No response from the USB Bluetooth dongle anymore. > For example, running "discoverable on" from "bluetoothctl" fails with error > message of "Failed to set discoverable on: org.bluez.Error.Failed". > The timeout error is logged in "dmesg" as well. > > From this fact, I believe this issue is related to Bluez but not to USB. > What do you think? Hi, you are using a slightly less common HC, are you not? Anyway, it seems to me that you can narrow this down a bit further. You are using bridging. You can try to remove that. And after that you can take an usbmon trace right as you give the command that crashes the device. The procedure is described in the kernel's Documentation directory. That will allow to determine which exact command is the problem. HTH Oliver
Re: [PATCH 2/2] usb: dwc2: gadget: Accept LPM token when TxFIFO is not empty
Hi Sergei, On 10/30/2018 19:02, Sergei Shtylyov wrote: > Hello! > > On 10/30/2018 03:26 PM, Artur Petrosyan wrote: > >> To accept LPM token during ISOC transfers when TxFIFO >> is not empty. >> >> Signed-off-by: Artur Petrosyan >> Signed-off-by: Minas Harutyunyan >> --- >> drivers/usb/dwc2/gadget.c | 1 + >> drivers/usb/dwc2/hw.h | 3 +++ >> 2 files changed, 4 insertions(+) >> >> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c >> index 6bd4054e894d..63d53619fd21 100644 >> --- a/drivers/usb/dwc2/gadget.c >> +++ b/drivers/usb/dwc2/gadget.c >> @@ -5026,6 +5026,7 @@ void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg) >> val |= hsotg->params.lpm_clock_gating ? GLPMCFG_ENBLSLPM : 0; >> val |= hsotg->params.hird_threshold << GLPMCFG_HIRD_THRES_SHIFT; >> val |= hsotg->params.besl ? GLPMCFG_ENBESL : 0; >> +val |= GLPMCFG_RETRY_CNT_1; >> dwc2_writel(hsotg, val, GLPMCFG); >> dev_dbg(hsotg->dev, "GLPMCFG=0x%08x\n", dwc2_readl(hsotg, GLPMCFG)); >> >> diff --git a/drivers/usb/dwc2/hw.h b/drivers/usb/dwc2/hw.h >> index 2b1ea441b7d4..84d2b32f4831 100644 >> --- a/drivers/usb/dwc2/hw.h >> +++ b/drivers/usb/dwc2/hw.h >> @@ -333,6 +333,9 @@ >> #define GLPMCFG_SNDLPM BIT(24) >> #define GLPMCFG_RETRY_CNT_MASK (0x7 << 21) >> #define GLPMCFG_RETRY_CNT_SHIFT21 >> +#define GLPMCFG_RETRY_CNT_0 21 >> +#define GLPMCFG_RETRY_CNT_1 22 >> +#define GLPMCFG_RETRY_CNT_2 23 > > Not '(0|1|2 << 21)'? > > [...] > > MBR, Sergei > Thank you very much for your review. I will submit V2 patches to fix bit definitions,and also add Reviewed-by tag. Regards, Artur
[PATCH] Improve the accuracy of the baud rate generator by using round-to-closest instead of truncating when calculating baud rate divisors.
I have experienced that the ftdi_sio driver gives less-than-optimal baud rates as the driver truncates instead of rounds to nearest during baud rate divisor calculation. This patch improves on the baud rate generation. The generated baud rate corresponds to the optimal baud rate achievable with the chip. This is what the windows driver gives as well. Signed-off-by: Nikolaj Fogh --- drivers/usb/serial/ftdi_sio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 609198d9594c..0edbd3427548 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1130,7 +1130,7 @@ static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base) { unsigned short int divisor; /* divisor shifted 3 bits to the left */ - int divisor3 = base / 2 / baud; + int divisor3 = DIV_ROUND_CLOSEST(base, 2 * baud); if ((divisor3 & 0x7) == 7) divisor3++; /* round x.7/8 up to x+1 */ divisor = divisor3 >> 3; @@ -1156,7 +1156,7 @@ static u32 ftdi_232bm_baud_base_to_divisor(int baud, int base) static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 }; u32 divisor; /* divisor shifted 3 bits to the left */ - int divisor3 = base / 2 / baud; + int divisor3 = DIV_ROUND_CLOSEST(base, 2 * baud); divisor = divisor3 >> 3; divisor |= (u32)divfrac[divisor3 & 0x7] << 14; /* Deal with special cases for highest baud rates. */ @@ -1179,7 +1179,7 @@ static u32 ftdi_2232h_baud_base_to_divisor(int baud, int base) int divisor3; /* hi-speed baud rate is 10-bit sampling instead of 16-bit */ - divisor3 = base * 8 / (baud * 10); + divisor3 = DIV_ROUND_CLOSEST(base * 8, baud * 10); divisor = divisor3 >> 3; divisor |= (u32)divfrac[divisor3 & 0x7] << 14; -- 2.17.1
Re: [RESEND PATCH v2] usb: dwc2: disable power_down on rockchip for regression
On 10/29/18 4:02 AM, Minas Harutyunyan wrote: Hi Hal, On 10/26/2018 6:38 PM, Hal Emmerich wrote: From 04fbf78e4e569bf872f1ffcb0a6f9b89569dc913 Mon Sep 17 00:00:00 2001 From: Hal Emmerich Date: Thu, 19 Jul 2018 21:48:08 -0500 Subject: [PATCH] usb: dwc2: disable power_down on rockchip devices The bug would let the usb controller enter partial power down, which was formally known as hibernate, upon boot if nothing was plugged in to the port. Partial power down couldn't be exited properly, so any usb devices plugged in after boot would not be usable. Before the name change, params.hibernation was false by default, so _dwc2_hcd_suspend() would skip entering hibernation. With the rename, _dwc2_hcd_suspend() was changed to use params.power_down to decide whether or not to enter partial power down. Since params.power_down is non-zero by default, it needs to be set to 0 for rockchip devices to restore functionality. This bug was reported in the linux-usb thread: REGRESSION: usb: dwc2: USB device not seen after boot The commit that caused this regression is: 6d23ee9caa6790aea047f9aca7f3c03cb8d96eb6 Signed-off-by: Hal Emmerich Acked-by: Minas Harutyunyan --- drivers/usb/dwc2/params.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index bf7052e037d6..09292dc977e4 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -81,6 +81,7 @@ static void dwc2_set_rk_params(struct dwc2_hsotg *hsotg) p->host_perio_tx_fifo_size = 256; p->ahbcfg = GAHBCFG_HBSTLEN_INCR16 << GAHBCFG_HBSTLEN_SHIFT; + p->power_down = 0; } static void dwc2_set_ltq_params(struct dwc2_hsotg *hsotg) -- 2.11.0 Could you please elaborate. In subject mentioned that it's "v2" patch. But looks like its fully same as v1 patch. If not, then where new version patch updates description. Thanks, Minas Hey Minas, felipe.ba...@linux.intel.com mentioned that he was unable to apply the original patch so I remade the patch, and confirmed I could apply it cleanly to the current tree and marked it v2. He also mentioned that I should "collect" your ack, which I'm not familiar with. I added: >> Acked-by: Minas Harutyunyan which may or may not be the correct way of doing things. Let me know if I am doing that incorrectly. Sorry if I shouldn't have marked this v2. Also, just to let you know, my mailserver says that your mailserver refuses to collect my email. My servers not on any blocklists and seems to send mail elsewhere fine so I'm guessing your mailserver has mistakenly categorized me as spam on its own. Seems my mail still gets through to you from the list though, so not a big deal. Sorry if I'm not doing some part of this correctly. Thanks, Evan
Geschäfts- / Projektkredit 1,5%
-- Schönen Tag. Wir hoffen, Sie gut zu treffen. Benötigen Sie einen dringenden Kredit für ein Geschäft oder ein Projekt? Wir bieten Kredite zu 1,5% und wir können Ihre Transaktion innerhalb von 3 bis 5 Arbeitstagen abschließen. Wenn Sie ernsthaft an einem Kredit interessiert sind, empfehlen wir Ihnen, unten die Einzelheiten zur Bearbeitung Ihrer Transaktion anzugeben. Vollständiger Name:.. Darlehensbetrag: .. Darlehensdauer: .. Darlehen Zweck:.. Telefon:.. Wir erwarten Ihre Darlehensdaten wie oben beschrieben für die Abwicklung Ihrer Transaktion. Freundliche Grüße. Wilson Rog. Buchhalter / Berater
Re: [RESEND PATCH v2] usb: dwc2: disable power_down on rockchip for regression
Hi, On 10/26/2018 6:38 PM, Hal Emmerich wrote: > > From 04fbf78e4e569bf872f1ffcb0a6f9b89569dc913 Mon Sep 17 00:00:00 2001 > From: Hal Emmerich > Date: Thu, 19 Jul 2018 21:48:08 -0500 > Subject: [PATCH] usb: dwc2: disable power_down on rockchip devices > > The bug would let the usb controller enter partial power down, > which was formally known as hibernate, upon boot if nothing was plugged > in to the port. Partial power down couldn't be exited properly, so any > usb devices plugged in after boot would not be usable. > > Before the name change, params.hibernation was false by default, so > _dwc2_hcd_suspend() would skip entering hibernation. With the > rename, _dwc2_hcd_suspend() was changed to use params.power_down > to decide whether or not to enter partial power down. > > Since params.power_down is non-zero by default, it needs to be set > to 0 for rockchip devices to restore functionality. > > This bug was reported in the linux-usb thread: > REGRESSION: usb: dwc2: USB device not seen after boot > > The commit that caused this regression is: > 6d23ee9caa6790aea047f9aca7f3c03cb8d96eb6 > > Signed-off-by: Hal Emmerich > Acked-by: Minas Harutyunyan Acked-by: Minas Harutyunyan for v2 > --- > drivers/usb/dwc2/params.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c > index bf7052e037d6..09292dc977e4 100644 > --- a/drivers/usb/dwc2/params.c > +++ b/drivers/usb/dwc2/params.c > @@ -81,6 +81,7 @@ static void dwc2_set_rk_params(struct dwc2_hsotg *hsotg) > p->host_perio_tx_fifo_size = 256; > p->ahbcfg = GAHBCFG_HBSTLEN_INCR16 << > GAHBCFG_HBSTLEN_SHIFT; > + p->power_down = 0; > } > > static void dwc2_set_ltq_params(struct dwc2_hsotg *hsotg) > -- > 2.11.0 > >
[PATCH 4/4 v6] memstick: rtsx_usb_ms: Support runtime power management
In order to let host's parent device, rtsx_usb, to use USB remote wake up signaling to do card detection, it needs to be suspended. Hence it's necessary to add runtime PM support for the memstick host. To keep memstick host stays suspended when it's not in use, convert the card detection function from kthread to delayed_work, which can be scheduled when the host is resumed and can be canceled when the host is suspended. Put the device to suspend when there's no card and the power mode is MEMSTICK_POWER_OFF. Signed-off-by: Kai-Heng Feng --- drivers/memstick/host/rtsx_usb_ms.c | 167 +--- 1 file changed, 102 insertions(+), 65 deletions(-) diff --git a/drivers/memstick/host/rtsx_usb_ms.c b/drivers/memstick/host/rtsx_usb_ms.c index cd12f3d1c088..3800c24b084e 100644 --- a/drivers/memstick/host/rtsx_usb_ms.c +++ b/drivers/memstick/host/rtsx_usb_ms.c @@ -40,15 +40,14 @@ struct rtsx_usb_ms { struct mutexhost_mutex; struct work_struct handle_req; - - struct task_struct *detect_ms; - struct completion detect_ms_exit; + struct delayed_work poll_card; u8 ssc_depth; unsigned intclock; int power_mode; unsigned char ifmode; booleject; + boolsystem_suspending; }; static inline struct device *ms_dev(struct rtsx_usb_ms *host) @@ -545,7 +544,7 @@ static void rtsx_usb_ms_handle_req(struct work_struct *work) host->req->error); } } while (!rc); - pm_runtime_put(ms_dev(host)); + pm_runtime_put_sync(ms_dev(host)); } } @@ -585,14 +584,14 @@ static int rtsx_usb_ms_set_param(struct memstick_host *msh, break; if (value == MEMSTICK_POWER_ON) { - pm_runtime_get_sync(ms_dev(host)); + pm_runtime_get_noresume(ms_dev(host)); err = ms_power_on(host); + if (err) + pm_runtime_put_noidle(ms_dev(host)); } else if (value == MEMSTICK_POWER_OFF) { err = ms_power_off(host); - if (host->msh->card) + if (!err) pm_runtime_put_noidle(ms_dev(host)); - else - pm_runtime_put(ms_dev(host)); } else err = -EINVAL; if (!err) @@ -638,25 +637,44 @@ static int rtsx_usb_ms_set_param(struct memstick_host *msh, } out: mutex_unlock(&ucr->dev_mutex); - pm_runtime_put(ms_dev(host)); + pm_runtime_put_sync(ms_dev(host)); /* power-on delay */ - if (param == MEMSTICK_POWER && value == MEMSTICK_POWER_ON) + if (param == MEMSTICK_POWER && value == MEMSTICK_POWER_ON) { usleep_range(1, 12000); + if (!host->eject) + schedule_delayed_work(&host->poll_card, 100); + } + dev_dbg(ms_dev(host), "%s: return = %d\n", __func__, err); return err; } -#ifdef CONFIG_PM_SLEEP +#ifdef CONFIG_PM static int rtsx_usb_ms_suspend(struct device *dev) { struct rtsx_usb_ms *host = dev_get_drvdata(dev); struct memstick_host *msh = host->msh; - dev_dbg(ms_dev(host), "--> %s\n", __func__); + /* Since we use rtsx_usb's resume callback to runtime resume its +* children to implement remote wakeup signaling, this causes +* rtsx_usb_ms' runtime resume callback runs after its suspend +* callback: +* rtsx_usb_ms_suspend() +* rtsx_usb_resume() +* -> rtsx_usb_ms_runtime_resume() +* -> memstick_detect_change() +* +* rtsx_usb_suspend() +* +* To avoid this, skip runtime resume/suspend if system suspend is +* underway. +*/ + host->system_suspending = true; memstick_suspend_host(msh); + return 0; } @@ -665,58 +683,83 @@ static int rtsx_usb_ms_resume(struct device *dev) struct rtsx_usb_ms *host = dev_get_drvdata(dev); struct memstick_host *msh = host->msh; - dev_dbg(ms_dev(host), "--> %s\n", __func__); - memstick_resume_host(msh); + host->system_suspending = false; + return 0; } -#endif /* CONFIG_PM_SLEEP */ -/* - * Thread function of ms card slot detection. The thread starts right after - * successful host addition. It stops while the driver removal function sets - * host->eject true. - */ -static int rtsx_usb_detect_ms_card(void *__host) +static int rtsx_usb_ms_runtime_suspend(struct device *dev) +{ + struct rtsx_usb_ms *host = dev_get_drvdata(dev); + + if (host->system_suspending) + return
Re: [PATCH 4/4 v6] memstick: rtsx_usb_ms: Support runtime power management
On 31 October 2018 at 07:59, Kai-Heng Feng wrote: > In order to let host's parent device, rtsx_usb, to use USB remote wake > up signaling to do card detection, it needs to be suspended. Hence it's > necessary to add runtime PM support for the memstick host. > > To keep memstick host stays suspended when it's not in use, convert the > card detection function from kthread to delayed_work, which can be > scheduled when the host is resumed and can be canceled when the host is > suspended. > > Put the device to suspend when there's no card and the power mode is > MEMSTICK_POWER_OFF. > > Signed-off-by: Kai-Heng Feng > --- > drivers/memstick/host/rtsx_usb_ms.c | 167 +--- > 1 file changed, 102 insertions(+), 65 deletions(-) > > diff --git a/drivers/memstick/host/rtsx_usb_ms.c > b/drivers/memstick/host/rtsx_usb_ms.c > index cd12f3d1c088..3800c24b084e 100644 > --- a/drivers/memstick/host/rtsx_usb_ms.c > +++ b/drivers/memstick/host/rtsx_usb_ms.c > @@ -40,15 +40,14 @@ struct rtsx_usb_ms { > > struct mutexhost_mutex; > struct work_struct handle_req; > - > - struct task_struct *detect_ms; > - struct completion detect_ms_exit; > + struct delayed_work poll_card; > > u8 ssc_depth; > unsigned intclock; > int power_mode; > unsigned char ifmode; > booleject; > + boolsystem_suspending; > }; > > static inline struct device *ms_dev(struct rtsx_usb_ms *host) > @@ -545,7 +544,7 @@ static void rtsx_usb_ms_handle_req(struct work_struct > *work) > host->req->error); > } > } while (!rc); > - pm_runtime_put(ms_dev(host)); > + pm_runtime_put_sync(ms_dev(host)); > } > > } > @@ -585,14 +584,14 @@ static int rtsx_usb_ms_set_param(struct memstick_host > *msh, > break; > > if (value == MEMSTICK_POWER_ON) { > - pm_runtime_get_sync(ms_dev(host)); > + pm_runtime_get_noresume(ms_dev(host)); > err = ms_power_on(host); > + if (err) > + pm_runtime_put_noidle(ms_dev(host)); > } else if (value == MEMSTICK_POWER_OFF) { > err = ms_power_off(host); > - if (host->msh->card) > + if (!err) > pm_runtime_put_noidle(ms_dev(host)); > - else > - pm_runtime_put(ms_dev(host)); > } else > err = -EINVAL; > if (!err) > @@ -638,25 +637,44 @@ static int rtsx_usb_ms_set_param(struct memstick_host > *msh, > } > out: > mutex_unlock(&ucr->dev_mutex); > - pm_runtime_put(ms_dev(host)); > + pm_runtime_put_sync(ms_dev(host)); > > /* power-on delay */ > - if (param == MEMSTICK_POWER && value == MEMSTICK_POWER_ON) > + if (param == MEMSTICK_POWER && value == MEMSTICK_POWER_ON) { > usleep_range(1, 12000); > > + if (!host->eject) > + schedule_delayed_work(&host->poll_card, 100); > + } > + > dev_dbg(ms_dev(host), "%s: return = %d\n", __func__, err); > return err; > } > > -#ifdef CONFIG_PM_SLEEP > +#ifdef CONFIG_PM I think you should keep CONFIG_PM_SLEEP, else this triggers a warning about unused functions, when CONFIG_PM is set but CONFIG_PM_SLEEP is unset. > static int rtsx_usb_ms_suspend(struct device *dev) > { > struct rtsx_usb_ms *host = dev_get_drvdata(dev); > struct memstick_host *msh = host->msh; > > - dev_dbg(ms_dev(host), "--> %s\n", __func__); > + /* Since we use rtsx_usb's resume callback to runtime resume its > +* children to implement remote wakeup signaling, this causes > +* rtsx_usb_ms' runtime resume callback runs after its suspend > +* callback: > +* rtsx_usb_ms_suspend() > +* rtsx_usb_resume() > +* -> rtsx_usb_ms_runtime_resume() > +* -> memstick_detect_change() > +* > +* rtsx_usb_suspend() > +* > +* To avoid this, skip runtime resume/suspend if system suspend is > +* underway. > +*/ > > + host->system_suspending = true; > memstick_suspend_host(msh); > + > return 0; > } > > @@ -665,58 +683,83 @@ static int rtsx_usb_ms_resume(struct device *dev) > struct rtsx_usb_ms *host = dev_get_drvdata(dev); > struct memstick_host *msh = host->msh; > > - dev_dbg(ms_dev(host), "--> %s\n", __func__); > - > memstick_resume_host(msh); > + host->system_suspending = false; > + > return 0; > } > -#endif /* CON
RE: scsi_set_medium_removal timeout issue
On Wed, 31 Oct 2018, Zengtao (B) wrote: > Hi: > > >-Original Message- > >From: Alan Stern [mailto:st...@rowland.harvard.edu] > >Sent: Tuesday, October 30, 2018 10:08 PM > >To: Zengtao (B) > >Cc: j...@linux.vnet.ibm.com; martin.peter...@oracle.com; > >gre...@linuxfoundation.org; linux-s...@vger.kernel.org; > >linux-ker...@vger.kernel.org; linux-usb@vger.kernel.org; > >usb-stor...@lists.one-eyed-alien.net > >Subject: Re: scsi_set_medium_removal timeout issue > > > >On Tue, 30 Oct 2018, Zengtao (B) wrote: > > > >> Hi > >> > >> I have recently met a scsi_set_medium_removal timeout issue, and it's > >> related to both SCSI and USB MASS storage. > >> Since i am not an expert in either scsi or usb mass storage, i am > >> writing to report the issue and ask for a solution from you guys. > >> > >> My test scenario is as follow: > >> 1.Linux HOST-Linux mass storage gadget(the back store is a flash > >partition). > >> 2.Host mount the device. > >> 3.Host writes some data to the Mass storage device. > >> 4.Host Unmount the device. > >> Both Linux kernels(Host and Device) are Linux 4.9. > >> Some has reported the same issue a long time ago, but it remains there. > >> https://www.spinics.net/lists/linux-usb/msg53739.html > >> > >> For the issue itself, there is my observation: > >> In the step 4, the Host will issue an > >PREVENT_ALLOW_MEDIUM_REMOVAL scsi command. > >> and and timeout happens due to the device 's very slow > >fsg_lun_fsync_sub. > > > >Something is wrong here. Before sending PREVENT-ALLOW MEDIUM > >REMOVAL, the host should issue SYNCHRONIZE CACHE. This will force > >fsg_lun_fsync_sub to run, and the host should allow a long timeout for > >this command. Then when PREVENT-ALLOW MEDIUM REMOVAL is sent, > >nothing will need to be flushed. > > > > Definitely, I haven't seen the SYNCHRONIZE CACHE from the host, it directly > issued the PREVENT-ALLOW MEDIUM REMOVAL, so maybe something wrong > with the scsi layer or something wrong with the mass storage class driver? Or it could be something else. Can you please post the dmesg log from the host, showing what happens when the device is first plugged in? Alan Stern
[PATCH] usbnet: smsc95xx: disable carrier check while suspending
We need to make sure, that the carrier check polling is disabled while suspending. Otherwise we can end up with usbnet_read_cmd() being issued when only usbnet_read_cmd_nopm() is allowed. If this happens, read operations lock up. Fixes: d69d169493 ("usbnet: smsc95xx: fix link detection for disabled autonegotiation") Cc: Signed-off-by: Frieder Schrempf --- drivers/net/usb/smsc95xx.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 262e7a3..3bc9633 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -1592,6 +1592,8 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) u32 val, link_up; int ret; + cancel_delayed_work_sync(&pdata->carrier_check); + ret = usbnet_suspend(intf, message); if (ret < 0) { netdev_warn(dev->net, "usbnet_suspend error\n"); @@ -1840,6 +1842,11 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) */ if (ret && PMSG_IS_AUTO(message)) usbnet_resume(intf); + + if (ret) + schedule_delayed_work(&pdata->carrier_check, + CARRIER_CHECK_DELAY); + return ret; } -- 2.7.4
[PATCH v2] usbnet: smsc95xx: disable carrier check while suspending
We need to make sure, that the carrier check polling is disabled while suspending. Otherwise we can end up with usbnet_read_cmd() being issued when only usbnet_read_cmd_nopm() is allowed. If this happens, read operations lock up. Fixes: d69d169493 ("usbnet: smsc95xx: fix link detection for disabled autonegotiation") Cc: Signed-off-by: Frieder Schrempf --- Changes in v2: * move cancel_delayed_work_sync() to correct error path drivers/net/usb/smsc95xx.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 262e7a3..2d17f3b 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -1598,6 +1598,8 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) return ret; } + cancel_delayed_work_sync(&pdata->carrier_check); + if (pdata->suspend_flags) { netdev_warn(dev->net, "error during last resume\n"); pdata->suspend_flags = 0; @@ -1840,6 +1842,11 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) */ if (ret && PMSG_IS_AUTO(message)) usbnet_resume(intf); + + if (ret) + schedule_delayed_work(&pdata->carrier_check, + CARRIER_CHECK_DELAY); + return ret; } -- 2.7.4
Re: [PATCH 5/6] usb: musb: gadget: implement send_response
Hi Bin, On Thu, Oct 11, 2018 at 11:07:46AM -0500, Bin Liu wrote: > Hi, > > On Tue, Oct 09, 2018 at 10:49:02PM -0400, Paul Elder wrote: > > This patch implements a mechanism to signal the MUSB driver to reply to > > a control OUT request with STALL or ACK. > > > > Signed-off-by: Paul Elder > > Reviewed-by: Laurent Pinchart > > The patch looks good to me, here is my Acked-by: > > Acked-by: Bin Liu > > but I am unable to test this patch set - the current Greg's usb-next > tree gives deadlock error between composite_disconnect() and > usb_function_deactivate() when loading g_webcam.ko on BeagleboneBlack. > The error happens before applying this patch set. We don't use g_webcam anymore, because it doesn't offer the flexibility that configfs does (for example, only one function can be configured with g_webcam). There are no features that g_webcam offers that configfs doesn't. I was unable to reproduce the deadlock that you mention on Greg's usb-next tree. Which commit were you on? I did, however, get the deadlock that you mention upon *killing* the userspace application providing the stream, not when loading g_webcam.ko. Here is a sample script for setting up a UVC gadget through configfs (I haven't tested this exact script; I extracted the functional components): CONFIGFS="/sys/kernel/config" GADGET="$CONFIGFS/usb_gadget" VID="0x0525" PID="0xa4a2" SERIAL="0123456789" MANUF=$(hostname) PRODUCT="UVC Gadget" UDC=`ls /sys/class/udc` cd $GADGET/g1 echo $VID > idVendor echo $PID > idProduct mkdir -p strings/0x409 echo $SERIAL > strings/0x409/serialnumber echo $MANUF > strings/0x409/manufacturer echo $PRODUCT > strings/0x409/product mkdir configs/c.1 mkdir configs/c.1/strings/0x409 # create uvc CONFIG="configs/c.1" FUNCTION="uvc.0" mkdir functions/$FUNCTION # create frame 640x360 uncompressed WIDTH=640 HEIGHT=360 wdir=functions/$FUNCTION/streaming/uncompressed/u/${HEIGHT}p mkdir $wdir echo $WIDTH > $wdir/wWidth echo $HEIGHT > $wdir/wHeight echo $(( $WIDTH * $HEIGHT * 2 )) > $wdir/dwMaxVideoFrameBufferSize cat < $wdir/dwFrameInterval 66 10 500 EOF # end create frame mkdir functions/$FUNCTION/streaming/header/h cd functions/$FUNCTION/streaming/header/h ln -s ../../uncompressed/u cd ../../class/fs ln -s ../../header/h cd ../../class/hs ln -s ../../header/h cd ../../../control mkdir header/h ln -s header/h class/fs ln -s header/h class/ss cd ../../../ # Set the packet size: uvc gadget max size is 3k... echo 3072 > functions/$FUNCTION/streaming_maxpacket echo 2048 > functions/$FUNCTION/streaming_maxpacket echo 1024 > functions/$FUNCTION/streaming_maxpacket ln -s functions/$FUNCTION configs/c.1 # end create uvc echo $UDC > UDC Thanks, Paul