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]

 



* Felipe Balbi | 2011-12-15 13:07:31 [+0200]:

>diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>index 0d08aa7..9741026 100644
>--- a/drivers/usb/dwc3/gadget.c
>+++ b/drivers/usb/dwc3/gadget.c
>@@ -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);
>+
>+				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;

Waaa. So you want me to respect sg_table size in uasp. It is not done
yet.
Could we change sg_tablesize to sg_supported? So I don't have to support
it? From DWC3 point of view you just need to stop in the middle of
request and continue later. I don't think anyone has a restriction here
(I don't really know where this limit is comming from). If you don't
then I need to split the sg list into two or more requests which will
probably end up with the same thing. And, as recently learned a sg_list
of 4 entries could be mapped into one. If I have to split it manually we
may lose that.
If you really want an upper limit (which you copied from usb core where
it is treated as 0/1) then you could rename it so sg_entries or
something like that.

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