Re: [PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-13 Thread Alan Stern
On Tue, 11 Apr 2017, Alan Stern wrote: > For now, I think it would be best to put smp_mb() in both places. > After I do a more thorough rewrite, the memory barriers will make more > sense. Felipe: I have prepared a series of two patches: one to change the way f_mass_storage handles asynchronou

Re: [PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-11 Thread Thinh Nguyen
On 4/11/2017 7:35 AM, Alan Stern wrote: On Mon, 10 Apr 2017, Thinh Nguyen wrote: To fix this problem, both the smp_rmb() in sleep_thread() and the smp_wmb() in wakeup_thread() should be changed to smp_mb(). Wouldn't it be sufficient to have smp_mb() just either in the sleep_thread() or the wa

Re: [PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-11 Thread Alan Stern
On Mon, 10 Apr 2017, Thinh Nguyen wrote: > To fix this problem, both the smp_rmb() in sleep_thread() and the > smp_wmb() in wakeup_thread() should be changed to smp_mb(). > > Wouldn't it be sufficient to have smp_mb() just either in the > sleep_thread() or the wakeup_thread() in this c

Re: [PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-11 Thread Felipe Balbi
Hi, Alan Stern writes: > Felipe, was this patch meant to solve the problem you encountered in > your "Memory barrier needed with wake_up_process()?" email thread last > fall? it certainly smells like it, but Thinh Nguyen didn't say for sure :-) -- balbi signature.asc Description: PGP signat

Re: [PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-10 Thread Thinh Nguyen
On 4/10/2017 12:31 PM, Paul E. McKenney wrote: On Mon, Apr 10, 2017 at 03:00:34PM -0400, Alan Stern wrote: On Mon, 10 Apr 2017, Paul E. McKenney wrote: The ordering with current->state is sadly not relevant because it is only touched if wake_up() actually wakes the process up. Well, it is _w

Re: [PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-10 Thread Paul E. McKenney
On Mon, Apr 10, 2017 at 03:00:34PM -0400, Alan Stern wrote: > On Mon, 10 Apr 2017, Paul E. McKenney wrote: > > > > > The ordering with current->state is sadly not relevant because it is > > > > only touched if wake_up() actually wakes the process up. > > > > > > Well, it is _written_ only if wake

Re: [PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-10 Thread Alan Stern
On Mon, 10 Apr 2017, Paul E. McKenney wrote: > > > The ordering with current->state is sadly not relevant because it is > > > only touched if wake_up() actually wakes the process up. > > > > Well, it is _written_ only if wake_up() actually wakes the process up. > > But it is _read_ in every cas

Re: [PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-10 Thread Paul E. McKenney
On Mon, Apr 10, 2017 at 01:48:13PM -0400, Alan Stern wrote: > On Mon, 10 Apr 2017, Paul E. McKenney wrote: > > > On Mon, Apr 10, 2017 at 12:20:53PM -0400, Alan Stern wrote: > > > On Mon, 10 Apr 2017, Paul E. McKenney wrote: > > > > > > > > But I would like to get this matter settled first. Is th

Re: [PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-10 Thread Alan Stern
On Mon, 10 Apr 2017, Paul E. McKenney wrote: > On Mon, Apr 10, 2017 at 12:20:53PM -0400, Alan Stern wrote: > > On Mon, 10 Apr 2017, Paul E. McKenney wrote: > > > > > > But I would like to get this matter settled first. Is the explicit > > > > barrier truly necessary? > > > > > > If you are usi

Re: [PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-10 Thread Paul E. McKenney
On Mon, Apr 10, 2017 at 12:20:53PM -0400, Alan Stern wrote: > On Mon, 10 Apr 2017, Paul E. McKenney wrote: > > > > But I would like to get this matter settled first. Is the explicit > > > barrier truly necessary? > > > > If you are using wait_event()/wake_up() or friends, the explicit > > barri

Re: [PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-10 Thread Alan Stern
On Mon, 10 Apr 2017, Paul E. McKenney wrote: > > But I would like to get this matter settled first. Is the explicit > > barrier truly necessary? > > If you are using wait_event()/wake_up() or friends, the explicit > barrier -is- necessary. To see this, look at v4.10's wait_event(): > >

Re: [PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-10 Thread Paul E. McKenney
On Mon, Apr 10, 2017 at 11:01:59AM -0400, Alan Stern wrote: > On Mon, 10 Apr 2017, Felipe Balbi wrote: > > > Hi, > > > > Thinh Nguyen writes: > > > f_mass_storage has a memorry barrier issue with the sleep and wake > > > functions that can cause a deadlock. This results in intermittent hangs > >

Re: [PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-10 Thread Alan Stern
On Mon, 10 Apr 2017, Felipe Balbi wrote: > Hi, > > Thinh Nguyen writes: > > f_mass_storage has a memorry barrier issue with the sleep and wake > > functions that can cause a deadlock. This results in intermittent hangs > > during MSC file transfer. The host will reset the device after receiving

Re: [PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-10 Thread Felipe Balbi
Hi, Thinh Nguyen writes: > f_mass_storage has a memorry barrier issue with the sleep and wake > functions that can cause a deadlock. This results in intermittent hangs > during MSC file transfer. The host will reset the device after receiving > no response to resume the transfer. This issue is s

Re: [PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-07 Thread Michal Nazarewicz
On Fri, Apr 07 2017, Thinh Nguyen wrote: > f_mass_storage has a memorry barrier issue with the sleep and wake > functions that can cause a deadlock. This results in intermittent hangs > during MSC file transfer. The host will reset the device after receiving > no response to resume the transfer. Th

[PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-07 Thread Thinh Nguyen
f_mass_storage has a memorry barrier issue with the sleep and wake functions that can cause a deadlock. This results in intermittent hangs during MSC file transfer. The host will reset the device after receiving no response to resume the transfer. This issue is seen when dwc3 is processing 2 transf