[PATCH] USB/Gadget: Fix race between gether_disconnect and rx_submit

2019-06-18 Thread kvaradarajan
On spin lock release in rx_submit, gether_disconnect get a chance to run, it makes port_usb NULL, rx_submit access NULL port USB, hence null pointer crash. Fixed by releasing the lock in rx_submit after port_usb is used. Signed-off-by: KVaradarajan --- drivers/usb/gadget/function/u_et

Re: Pass transfer_buffer to gadget drivers

2019-06-18 Thread Felipe Balbi
Hi, Alan Stern writes: >> Also, does the gadget subsystem guarantee, that we get the complete() >> callback for the DATA stage of the OUT control request before we get a >> setup() callback for the next control request if there's any? > > As I recall, this isn't mentioned in the documentation.

Re: [PATCH] usb: xhci: dbc: get rid of global pointer

2019-06-18 Thread Felipe Balbi
Hi, Johan Hovold writes: >> Johan Hovold writes: >> > On Tue, Jun 11, 2019 at 08:24:16PM +0300, Felipe Balbi wrote: >> >> If we happen to have two XHCI controllers with DbC capability, then >> >> there's no hope this will ever work as the global pointer will be >> >> overwritten by the controll

Re: [RFC] Sorting out dwc3 ISOC endpoints once and for all

2019-06-18 Thread Felipe Balbi
Hi, Thinh Nguyen writes: > Would there be any obvious draw-back to going down this route? The thing > is that, as it is, it seems like we will *always* have some corner case > where we can't guarantee that we can even start a transfer since there's > no upper-bound between XferNo

Re: [PATCH] usb: gadget: avoid using gadget after freed

2019-06-18 Thread Felipe Balbi
Hi, Lianwei Wang writes: >> Lianwei Wang writes: >> > On Mon, Jun 17, 2019 at 5:40 AM Felipe Balbi wrote: >> >> >> >> Lianwei Wang writes: >> >> >> >> > The udc and gadget device will be deleted when udc device is >> >> > disconnected and the related function will be unbind with it. >> >> > >

Re: [PATCH] usb: gadget: avoid using gadget after freed

2019-06-18 Thread Lianwei Wang
On Tue, Jun 18, 2019 at 12:21 AM Felipe Balbi wrote: > > > Hi, > > Lianwei Wang writes: > > On Mon, Jun 17, 2019 at 5:40 AM Felipe Balbi wrote: > >> > >> Lianwei Wang writes: > >> > >> > The udc and gadget device will be deleted when udc device is > >> > disconnected and the related function wi

[PATCH] USB: serial: option: add support for GosunCn ME3630 RNDIS mode

2019-06-18 Thread Jörgen Storvist
Added USB IDs for GosunCn ME3630 cellular module in RNDIS mode. T: Bus=03 Lev=01 Prnt=01 Port=01 Cnt=03 Dev#= 18 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=19d2 ProdID=0601 Rev=03.18 S: Manufacturer=Android S: Product=Android S: SerialNumber=b950269

Re: [RFC] Sorting out dwc3 ISOC endpoints once and for all

2019-06-18 Thread Thinh Nguyen
Thinh Nguyen wrote: > Felipe Balbi wrote: >> Hi, >> >> Thinh Nguyen writes: > static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct > dwc3_request *req) > > > Would there be any obvious draw-back to going down this route? The thing > is that, as it is, it seems lik

Re: [RFC] Sorting out dwc3 ISOC endpoints once and for all

2019-06-18 Thread Thinh Nguyen
Felipe Balbi wrote: > Hi, > > Thinh Nguyen writes: static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) Would there be any obvious draw-back to going down this route? The thing is that, as it is, it seems like we will *always* have some co

Re: [PATCH] usb: Replace a < b ? a : b construct with min_t(type, a, b) in adutux driver

2019-06-18 Thread Greg KH
On Tue, Jun 18, 2019 at 10:22:52AM -0700, dmg wrote: > > Greg KH writes: > > >> diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c > >> index 9465fb95d70a..4a9fa3152f2a 100644 > >> --- a/drivers/usb/misc/adutux.c > >> +++ b/drivers/usb/misc/adutux.c > >> @@ -379,7 +379,7 @@ stati

Re: [PATCH] usb: Replace a < b ? a : b construct with min_t(type, a, b) in adutux driver

2019-06-18 Thread dmg
Greg KH writes: >> diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c >> index 9465fb95d70a..4a9fa3152f2a 100644 >> --- a/drivers/usb/misc/adutux.c >> +++ b/drivers/usb/misc/adutux.c >> @@ -379,7 +379,7 @@ static ssize_t adu_read(struct file *file, __user char >> *buffer, size_

Re: [PATCH] usb: Replace a < b ? a : b construct with min_t(type, a, b) in adutux driver

2019-06-18 Thread dmg
Greg KH writes: >> >> diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c >> index 9465fb95d70a..4a9fa3152f2a 100644 >> --- a/drivers/usb/misc/adutux.c >> +++ b/drivers/usb/misc/adutux.c >> @@ -379,7 +379,7 @@ static ssize_t adu_read(struct file *file, __user char >> *buffer, si

Re: [PATCH] usb: Replace a < b ? a : b construct with min_t(type, a, b) in adutux driver

2019-06-18 Thread Greg KH
On Tue, Jun 18, 2019 at 08:35:29AM -0700, d...@turingmachine.org wrote: > From: Daniel M German > > Use min_t to find the minimum of two values instead of using the ?: operator. > > We use min_t instead of min to avoid the compilation warning 'comparison of > distinct pointer types lacks a cast'

Re: [PATCH] usb: core: devio: add ioctls for suspend and resume

2019-06-18 Thread Alan Stern
On Tue, 18 Jun 2019, Mayuresh Kulkarni wrote: > > You're right that the program needs to know when the device is about > > to  > > be suspended.  But waiting for an ioctl to return isn't a good way  > > to do it; this needs to be a callback of some sort.  That is, the  > > kernel also needs to kno

Re: [RFC] deadlock with flush_work() in UAS

2019-06-18 Thread Oliver Neukum
Am Dienstag, den 18.06.2019, 11:29 -0400 schrieb Alan Stern: > On Tue, 18 Jun 2019, Oliver Neukum wrote: > > > Hi, > > > > looking at those deadlocks it looks to me like UAS can > > deadlock on itself. What do you think? > > > > Regards > > Oliver > > > > From 2d497f662e6c03

[PATCH] usb: Replace a < b ? a : b construct with min_t(type, a, b) in adutux driver

2019-06-18 Thread dmg
From: Daniel M German Use min_t to find the minimum of two values instead of using the ?: operator. We use min_t instead of min to avoid the compilation warning 'comparison of distinct pointer types lacks a cast'. This change does not alter functionality. It is merely cosmetic intended to impro

Re: [RFC] deadlock with flush_work() in UAS

2019-06-18 Thread Alan Stern
On Tue, 18 Jun 2019, Oliver Neukum wrote: > Hi, > > looking at those deadlocks it looks to me like UAS can > deadlock on itself. What do you think? > > Regards > Oliver > > From 2d497f662e6c03fe9e0a75e05b64d52514e890b3 Mon Sep 17 00:00:00 2001 > From: Oliver Neukum > Date:

Re: [PATCH] usb: Replace a < b ? a : b construct with min_t(type, a, b) in drivers/usb

2019-06-18 Thread Greg KH
On Tue, Jun 18, 2019 at 08:00:28AM -0700, dmg wrote: > > Greg KH writes: > > > On Mon, Jun 17, 2019 at 04:30:50PM -0700, d...@turingmachine.org wrote: > >> From: Daniel M German > >> > >> Use min_t to find the minimum of two values instead of using the ?: > >> operator. > > > > Why is min_t()

[RFC] deadlock with flush_work() in UAS

2019-06-18 Thread Oliver Neukum
Hi, looking at those deadlocks it looks to me like UAS can deadlock on itself. What do you think? Regards Oliver >From 2d497f662e6c03fe9e0a75e05b64d52514e890b3 Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Tue, 18 Jun 2019 15:03:56 +0200 Subject: [PATCH] UAS: fix de

Re: [PATCH] usb: Replace a < b ? a : b construct with min_t(type, a, b) in drivers/usb

2019-06-18 Thread dmg
Greg KH writes: > On Mon, Jun 17, 2019 at 04:30:50PM -0700, d...@turingmachine.org wrote: >> From: Daniel M German >> >> Use min_t to find the minimum of two values instead of using the ?: operator. > > Why is min_t() needed for all of these and not just min()? The use of min triggers a compi

Re: [PATCH] usb: xhci: dbc: get rid of global pointer

2019-06-18 Thread Johan Hovold
On Mon, Jun 17, 2019 at 09:43:19AM +0300, Felipe Balbi wrote: > > Hi, > > Johan Hovold writes: > > On Tue, Jun 11, 2019 at 08:24:16PM +0300, Felipe Balbi wrote: > >> If we happen to have two XHCI controllers with DbC capability, then > >> there's no hope this will ever work as the global pointer

possible deadlock in 3b6054da68f9b0d5ed6a7ed0f42a79e61904352c ("usb hub: send clear_tt_buffer_complete events when canceling TT clear work")

2019-06-18 Thread Oliver Neukum
Hi, looking at this code, which fixed a deadlock,it looks to me like it has introduced another deadlock. [assume a storage device on a hub being suspended] hub_suspend() -> hub_quiesce() -> flush_work(&hub->tt.clear_work) -> /* note that tt.clear_work is not on its own queue, it uses simple sc

[PATCH 1/2] usb: xhci: Don't try to recover an endpoint if port is in error state.

2019-06-18 Thread Mathias Nyman
A USB3 device needs to be reset and re-enumarated if the port it connects to goes to a error state, with link state inactive. There is no use in trying to recover failed transactions by resetting endpoints at this stage. Tests show that in rare cases, after multiple endpoint resets of a roothub po

[PATCH 2/2] xhci: detect USB 3.2 capable host controllers correctly

2019-06-18 Thread Mathias Nyman
USB 3.2 capability in a host can be detected from the xHCI Supported Protocol Capability major and minor revision fields. If major is 0x3 and minor 0x20 then the host is USB 3.2 capable. For USB 3.2 capable hosts set the root hub lane count to 2. The Major Revision and Minor Revision fields cont

[PATCH 0/2] xhci fixes for usb-linus

2019-06-18 Thread Mathias Nyman
Hi Greg A couple of fixes for usb-linus, one to detect usb 3.2 xhci hosts, another to resolve a rare host hang at resume issue. -Mathias Mathias Nyman (2): usb: xhci: Don't try to recover an endpoint if port is in error state. xhci: detect USB 3.2 capable host controllers correctly drivers

Re: [PATCH] usb: core: devio: add ioctls for suspend and resume

2019-06-18 Thread Mayuresh Kulkarni
On Mon, 2019-06-17 at 11:55 -0400, Alan Stern wrote: > On Mon, 17 Jun 2019, Mayuresh Kulkarni wrote: > > > > > > > > > (Note: I imagine you might run into trouble because devices > > > generally  > > > do not get put into runtime suspend immediately.  So if you call > > > the  > > > USBDEVFS_SUS

Re: Pass transfer_buffer to gadget drivers

2019-06-18 Thread Alan Stern
On Tue, 18 Jun 2019, Andrey Konovalov wrote: > On Tue, Jun 18, 2019 at 3:31 PM Andrey Konovalov > wrote: > > > > On Fri, Jun 7, 2019 at 5:05 PM Andrey Konovalov > > wrote: > > > > > > On Fri, Jun 7, 2019 at 5:02 PM Alan Stern > > > wrote: > > > > > > > > On Fri, 7 Jun 2019, Andrey Konovalov

Re: Pass transfer_buffer to gadget drivers

2019-06-18 Thread Andrey Konovalov
On Tue, Jun 18, 2019 at 3:31 PM Andrey Konovalov wrote: > > On Fri, Jun 7, 2019 at 5:05 PM Andrey Konovalov wrote: > > > > On Fri, Jun 7, 2019 at 5:02 PM Alan Stern wrote: > > > > > > On Fri, 7 Jun 2019, Andrey Konovalov wrote: > > > > > > > > > The problem is that I want to receive that data (f

Re: Pass transfer_buffer to gadget drivers

2019-06-18 Thread Andrey Konovalov
On Fri, Jun 7, 2019 at 5:05 PM Andrey Konovalov wrote: > > On Fri, Jun 7, 2019 at 5:02 PM Alan Stern wrote: > > > > On Fri, 7 Jun 2019, Andrey Konovalov wrote: > > > > > > > The problem is that I want to receive that data (from the data stage) > > > > > from within my gadget driver module. But it

RE: [PATCH] usb: Replace a < b ? a : b construct with min_t(type, a, b) in drivers/usb

2019-06-18 Thread David Laight
From: d...@turingmachine.org > Sent: 18 June 2019 00:31 > Use min_t to find the minimum of two values instead of using the ?: operator. > > This change does not alter functionality. It is merely cosmetic intended to > improve the readability of the code. > > Signed-off-by: Daniel M German > ---

[PATCH] usb: gadget: ether: Fix race between gether_disconnect and rx_submit

2019-06-18 Thread Felipe Balbi
From: Kiruthika Varadarajan On spin lock release in rx_submit, gether_disconnect get a chance to run, it makes port_usb NULL, rx_submit access NULL port USB, hence null pointer crash. Fixed by releasing the lock in rx_submit after port_usb is used. Fixes: 2b3d942c4878 ("usb ethernet gadget: spl

Re: [PATCH 8/8] xhci: tegra: enable ELPG for runtime/system PM

2019-06-18 Thread JC Kuo
Hi Greg, Code cleanup was done but I forgot the "NEED CLEANUP" in the commit comment. Sorry for that. I will wait for review comments to come and fix the commit message together with code improvements. Thanks, JC On 6/18/19 2:33 PM, Greg KH wrote: > On Fri, Jun 14, 2019 at 03:48:24PM +0800, JC

Re: [PATCH v2] usb: dwc2: Use generic PHY width in params setup

2019-06-18 Thread Felipe Balbi
Hi, Marek Szyprowski writes: > Hi All, > > On 2019-05-31 14:44, Minas Harutyunyan wrote: >> On 5/9/2019 1:16 PM, Jules Maselbas wrote: >>> Setting params.phy_utmi_width in dwc2_lowlevel_hw_init() is pointless >>> since >>> it's value will be overwritten by dwc2_init_params(). >>> >>> This chang

Re: [PATCH] usb: gadget: avoid using gadget after freed

2019-06-18 Thread Felipe Balbi
Hi, Lianwei Wang writes: > On Mon, Jun 17, 2019 at 5:40 AM Felipe Balbi wrote: >> >> Lianwei Wang writes: >> >> > The udc and gadget device will be deleted when udc device is >> > disconnected and the related function will be unbind with it. >> > >> > But if the configfs is not deleted, then t

Re: [RFC] Sorting out dwc3 ISOC endpoints once and for all

2019-06-18 Thread Felipe Balbi
Hi, Thinh Nguyen writes: >>> >>> static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct >>> dwc3_request *req) >>> >>> >>> Would there be any obvious draw-back to going down this route? The thing >>> is that, as it is, it seems like we will *always* have some corner case >>> where we can

Re: [PATCH] usb: Replace a < b ? a : b construct with min_t(type, a, b) in drivers/usb

2019-06-18 Thread Felipe Balbi
Hi, d...@turingmachine.org writes: > From: Daniel M German > > Use min_t to find the minimum of two values instead of using the ?: operator. > > This change does not alter functionality. It is merely cosmetic intended to > improve the readability of the code. > > Signed-off-by: Daniel M German