Re: File Storage Gadget Driver - a small doubt

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

 



On Thu, 23 Jul 2009, Madhavi Manchala wrote:

> Dear Alan,
> 
> Thanks for the information.
> 
> I overlooked the **preq in the alloc_request() function. I understand
> it now a little bit more.
> 
> I have been modifying the file storage gadget driver code to handle
> the multiple commands from a few days. As a part of this, first I have
> implemented the three threads as shown below.
> 
>          main thread
>        		|
>       		|
> 	---------------------
> 	|		    |
>    Thread-1		Thread-2
> 
> The idea behind it is, the main thread queues the commands and wakeups
> the thread-1 (currently I have created only main thread and thread-1).
> Then the thread-1 do the remaining functionality.
> 
> main thread functionality
> -----------------------------------
> 
> 1)	Invokes the get_next_command and waits for the command.
> 2)	This will be signaled from completion callback function.
> 3)	Then, queues the command.
> 4)	Wakeups the thread-1 to process command.
> 5)	Again, sleeps to get the next command.

You don't need a separate thread to do this.  Just let the completion 
callback function queue the command and wake up thread-1.

> thread-1 functionality
> ------------------------------
> 1)	This thread will be started from the fsg_bind function and waits to
> receive a signal from the main thread.
> 2)	After wakeup from the main thread, it performs the do_scsi_command,
> finish_reply and send_status functionality.
> 3)	Again, sleeps to wake from the main thread.
> 
> After doing the above modifications, the file_storage gadget driver
> works fine without any issues.
> 
> However, I need some clarifications for the following.
> 
> 1)	Is it possible to handle the multiple commands in the gadget driver
> code if we do the modifications as said above without doing any
> modifications to the dummy_hcd driver at all. Ofcourse, if the mass
> storage driver sends the multiple commands.

No changes should be needed in dummy-hcd.

> 2)	I would like to wake up thread-2 from main thread when ever there
> is a next command to process (at this time thread-1 is busy processing
> first command). I guess, to handle like this, I need to create
> different buffer heads for each thread. Am I correct?

Well, you will certainly want to have more than two buffer heads.  Two 
per thread ought to be enough.

> Is there any
> different approach to handle multiple commands?

You could handle them one at a time, in a single thread.  Or you could 
figure out how to do all the I/O in interrupt context, by calling the 
block layer directly.

Alan Stern

--
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