Re: Question about multiple scatter-gathers

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

 



On Fri, 4 Sep 2009, aditya uttam wrote:

> 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);
> }

This looks okay to me.  Have you tried using usbmon to find out what's 
really going on?

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