Re: [PATCH 2/2] USB: f_mass_storage: improve memory barriers and synchronization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 4/13/2017 1:37 PM, Alan Stern wrote:
> This patch reworks the way f_mass_storage.c handles memory barriers
> and synchronization:
> 
> 	The driver now uses a wait_queue instead of doing its own
> 	task-state manipulations (even though only one task will ever
> 	use the wait_queue).
> 
> 	The thread_wakeup_needed variable is removed.  It was only a
> 	source of trouble; although it was what the driver tested to
> 	see whether it should wake up, what we really wanted to see
> 	was whether a USB transfer had completed.
> 
> 	All the explicit memory barriers scattered throughout the
> 	driver are replaced by a few calls to smp_load_acquire() and
> 	smp_store_release().
> 
> 	The inreq_busy and outreq_busy fields are removed.  In their
> 	place, the driver keeps track of the current I/O direction by
> 	splitting BUF_STATE_BUSY into two states: BUF_STATE_SENDING
> 	and BUF_STATE_RECEIVING.
> 
> 	The buffer states are no longer protected by a lock.  Mutual
> 	exclusion isn't needed; the state is changed only by the
> 	driver's main thread when it owns the buffer, and only by the
> 	request completion routine when the gadget core owns the buffer.
> 
> 	The do_write() and throw_away_data() routines were reorganized
> 	to make efficient use of the new sleeping mechanism.  This
> 	resulted in the removal of one indentation level in those
> 	routines, making the patch appear to be more more complicated
> 	than it really is.
> 
> 	In a few places, the driver allowed itself to be frozen although
> 	it really shouldn't have (in the middle of executing a SCSI
> 	command).  Those places have been fixed.
> 
> 	The logic in the exception handler for aborting transfers and
> 	waiting for them to stop has been simplified.
> 
> Signed-off-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
> 
> ---
> 
> 
> [as1824]
> 
> 
>   drivers/usb/gadget/function/f_mass_storage.c |  355 +++++++++++----------------
>   drivers/usb/gadget/function/storage_common.h |    7
>   2 files changed, 156 insertions(+), 206 deletions(-)
> 

I ran some stress tests against this patch series and found no issue 
beside some trivial checkpatch complains.

Kernel: 4.11-rc5
Driver: dwc3
Platform: HAPS-DX
IP: USB 3.0 IP version 3.10a and USB 3.1 version 1.60a
System: x86_64

Tested-by: Thinh Nguyen <thinhn@xxxxxxxxxxxx>

BR,
Thinh Nguyen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux