Re: [PATCH v3 5/5] usb: dwc3: gadget: add support for SG lists

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

 



Hi

On 12/15/2011 4:37 PM, Felipe Balbi wrote:
> add support for SG lists on dwc3 driver. With
> this we can e.g. use VFS layer's SG lists on
> storage gadgets so that we can start bigger
> transfers and improve throughput.
> 
> Signed-off-by: Felipe Balbi <balbi@xxxxxx>
> ---
> 

<snip>

>  
>  /*
> @@ -663,19 +704,58 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting)
>  		return;
>  
>  	list_for_each_entry_safe(req, n, &dep->request_list, list) {
> -		trbs_left--;
> +		unsigned	length;
> +		dma_addr_t	dma;
>  
> -		if (!trbs_left)
> -			last_one = 1;
> +		if (req->request.num_mapped_sgs > 0) {
> +			struct usb_request *request = &req->request;
> +			struct scatterlist *sg = request->sg;
> +			struct scatterlist *s;
> +			int		i;
>  
> -		/* Is this the last request? */
> -		if (list_empty(&dep->request_list))
> -			last_one = 1;
> +			for_each_sg(sg, s, request->num_mapped_sgs, i) {
> +				unsigned chain = true;
>  
> -		dwc3_prepare_one_trb(dep, req, last_one);
> +				length = sg_dma_len(s);
> +				dma = sg_dma_address(s);
>  
> -		if (last_one)
> -			break;
> +				if (i == (request->num_mapped_sgs - 1)
> +						|| sg_is_last(s)) {
> +					last_one = true;
> +					chain = false;
> +				}
> +
> +				trbs_left--;
> +				if (!trbs_left)
> +					last_one = true;
> +
> +				if (last_one)
> +					chain = false;
> +
> +				dwc3_prepare_one_trb(dep, req, dma, length,
> +						last_one, chain);
> +

We are setting LST bit to true for the last trb in the current SG list.

Ideally we should set LST bit true for the last trb in the current
transfer. That means we should set last_one to true only if this req is
the last one in the request_list. Sorry If my understanding is wrong.


> +				if (last_one)
> +					break;
> +			}
> +		} else {
> +			dma = req->request.dma;
> +			length = req->request.length;
> +			trbs_left--;
> +
> +			if (!trbs_left)
> +				last_one = 1;
> +
> +			/* Is this the last request? */
> +			if (list_is_last(&req->list, &dep->request_list))
> +				last_one = 1;
> +
> +			dwc3_prepare_one_trb(dep, req, dma, length,
> +					last_one, false);
> +
> +			if (last_one)
> +				break;
> +		}
>  	}
>  }
>  
> @@ -1989,6 +2069,7 @@ int __devinit dwc3_gadget_init(struct dwc3 *dwc)
>  	dwc->gadget.max_speed		= USB_SPEED_SUPER;
>  	dwc->gadget.speed		= USB_SPEED_UNKNOWN;
>  	dwc->gadget.dev.parent		= dwc->dev;
> +	dwc->gadget.sg_tablesize	= DWC3_TRB_NUM;
>  
>  	dma_set_coherent_mask(&dwc->gadget.dev, dwc->dev->coherent_dma_mask);
>  

Thanks,
Pavan
-- 
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
--
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