Re: Question about multiple scatter-gathers

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

 



Thanks for your reply.

The below is code snippet how I'm handling scatter gather for the device.

I'm invoking the function stor_bulk_transfer_sglist() from two
different threads with different srb parameters.
When the scatter-gather function is called for READ and WRITE at the
same time from two different threads I am getting time-out error.
Is there anything wrong in my implementation. Please let me know.

Function Call
-------------
result = stor_bulk_transfer_sglist(current_urb_context, pipe, scsi_sglist(srb),
				      scsi_sg_count(srb), scsi_bufflen(srb),
				      &partial);

Implementation
--------------
static int stor_bulk_transfer_sglist(struct urb_context
*current_urb_context, unsigned int pipe, struct scatterlist *sg, int
num_sg, unsigned int length, unsigned int *act_len)
{
	int result;
	
	/* don't submit s-g requests during abort processing */
	if (test_bit(US_FLIDX_ABORTING, &current_urb_context->dflags))
		return USB_STOR_XFER_ERROR;

	/* initialize the scatter-gather request block */
	
	result = usb_sg_init(current_urb_context->current_sg,
current_urb_context->pusb_dev, pipe, 0,
			sg, num_sg, length, GFP_NOIO);
	if (result) {		
		return USB_STOR_XFER_ERROR;
	}

	/* since the block has been initialized successfully, it's now
	 * okay to cancel it */
	set_bit(US_FLIDX_SG_ACTIVE, &current_urb_context->dflags);

	/* did an abort occur during the submission? */
	if (test_bit(US_FLIDX_ABORTING, &current_urb_context->dflags)) {

		/* cancel the request, if it hasn't been cancelled already */
		if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &current_urb_context->dflags)) {
			usb_sg_cancel(current_urb_context->current_sg);
		}
	}

	/* wait for the completion of the transfer */
	usb_sg_wait(current_urb_context->current_sg);
	clear_bit(US_FLIDX_SG_ACTIVE, &current_urb_context->dflags);

	result = current_urb_context->current_sg->status;
	if (act_len)
		*act_len = current_urb_context->current_sg->bytes;

	return interpret_urb_result(pipe, length, result,
			current_urb_context->current_sg->bytes);
}

Thanks
Aditya

On Thu, Sep 3, 2009 at 9:24 PM, Alan Stern<stern@xxxxxxxxxxxxxxxxxxx> wrote:
> On Thu, 3 Sep 2009, aditya uttam wrote:
>
>> Dear All,
>>
>> I am trying to develop a Bulk mass storage device for USB.
>> I am having two threads in my driver which can actually read and write
>> from the device simultaneously.
>> When I am doing so, my system is getting crash with time out message.
>>
>> My question is can I do scatter-gather read/write from different
>> threads over different pipes in the same driver?
>
> Yes, you can.
>
> 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