* [RFC/PATCH 02/45] usb: gadget: composite: correctly initialize ep->maxpacket
[not found] <20160928130554.29790-1-felipe.balbi@linux.intel.com>
@ 2016-09-28 13:05 ` Felipe Balbi
2016-09-28 13:05 ` [RFC/PATCH 03/45] usb: gadget: composite: always set ep->mult to a sensible value Felipe Balbi
2016-09-28 13:05 ` [RFC/PATCH 04/45] usb: dwc3: gadget: set PCM1 field of isochronous-first TRBs Felipe Balbi
2 siblings, 0 replies; 3+ messages in thread
From: Felipe Balbi @ 2016-09-28 13:05 UTC (permalink / raw)
To: Linux USB; +Cc: Felipe Balbi, stable
usb_endpoint_maxp() returns wMaxPacketSize in its
raw form. Without taking into consideration that it
also contains other bits reserved for isochronous
endpoints.
This patch fixes one occasion where this is a
problem by making sure that we initialize
ep->maxpacket only with lower 10 bits of the value
returned by usb_endpoint_maxp(). Note that seperate
patches will be necessary to audit all call sites of
usb_endpoint_maxp() and make sure that
usb_endpoint_maxp() only returns lower 10 bits of
wMaxPacketSize.
Cc: <stable@vger.kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---
drivers/usb/gadget/composite.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 32176f779861..f6a7583ab6d1 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -197,7 +197,7 @@ int config_ep_by_speed(struct usb_gadget *g,
ep_found:
/* commit results */
- _ep->maxpacket = usb_endpoint_maxp(chosen_desc);
+ _ep->maxpacket = usb_endpoint_maxp(chosen_desc) & 0x7ff;
_ep->desc = chosen_desc;
_ep->comp_desc = NULL;
_ep->maxburst = 0;
--
2.10.0.440.g21f862b
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [RFC/PATCH 03/45] usb: gadget: composite: always set ep->mult to a sensible value
[not found] <20160928130554.29790-1-felipe.balbi@linux.intel.com>
2016-09-28 13:05 ` [RFC/PATCH 02/45] usb: gadget: composite: correctly initialize ep->maxpacket Felipe Balbi
@ 2016-09-28 13:05 ` Felipe Balbi
2016-09-28 13:05 ` [RFC/PATCH 04/45] usb: dwc3: gadget: set PCM1 field of isochronous-first TRBs Felipe Balbi
2 siblings, 0 replies; 3+ messages in thread
From: Felipe Balbi @ 2016-09-28 13:05 UTC (permalink / raw)
To: Linux USB; +Cc: Felipe Balbi, stable
ep->mult is supposed to be set to Isochronous and
Interrupt Endapoint's multiplier value. This value
is computed from different places depending on the
link speed.
If we're dealing with HighSpeed, then it's part of
bits [12:11] of wMaxPacketSize. This case wasn't
taken into consideration before.
While at that, also make sure the ep->mult defaults
to one so drivers can use it unconditionally and
assume they'll never multiply ep->maxpacket to zero.
Cc: <stable@vger.kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---
drivers/usb/gadget/composite.c | 9 +++++++--
drivers/usb/gadget/function/uvc_video.c | 2 +-
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index f6a7583ab6d1..0426d3c1fff9 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -201,7 +201,12 @@ int config_ep_by_speed(struct usb_gadget *g,
_ep->desc = chosen_desc;
_ep->comp_desc = NULL;
_ep->maxburst = 0;
- _ep->mult = 0;
+ _ep->mult = 1;
+
+ if (g->speed == USB_SPEED_HIGH && (usb_endpoint_xfer_isoc(_ep->desc) ||
+ usb_endpoint_xfer_int(_ep->desc)))
+ _ep->mult = usb_endpoint_maxp_mult(_ep->desc);
+
if (!want_comp_desc)
return 0;
@@ -218,7 +223,7 @@ int config_ep_by_speed(struct usb_gadget *g,
switch (usb_endpoint_type(_ep->desc)) {
case USB_ENDPOINT_XFER_ISOC:
/* mult: bits 1:0 of bmAttributes */
- _ep->mult = comp_desc->bmAttributes & 0x3;
+ _ep->mult = (comp_desc->bmAttributes & 0x3) + 1;
case USB_ENDPOINT_XFER_BULK:
case USB_ENDPOINT_XFER_INT:
_ep->maxburst = comp_desc->bMaxBurst + 1;
diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index 3d0d5d94a62f..0f01c04d7cbd 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -243,7 +243,7 @@ uvc_video_alloc_requests(struct uvc_video *video)
req_size = video->ep->maxpacket
* max_t(unsigned int, video->ep->maxburst, 1)
- * (video->ep->mult + 1);
+ * (video->ep->mult);
for (i = 0; i < UVC_NUM_REQUESTS; ++i) {
video->req_buffer[i] = kmalloc(req_size, GFP_KERNEL);
--
2.10.0.440.g21f862b
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [RFC/PATCH 04/45] usb: dwc3: gadget: set PCM1 field of isochronous-first TRBs
[not found] <20160928130554.29790-1-felipe.balbi@linux.intel.com>
2016-09-28 13:05 ` [RFC/PATCH 02/45] usb: gadget: composite: correctly initialize ep->maxpacket Felipe Balbi
2016-09-28 13:05 ` [RFC/PATCH 03/45] usb: gadget: composite: always set ep->mult to a sensible value Felipe Balbi
@ 2016-09-28 13:05 ` Felipe Balbi
2 siblings, 0 replies; 3+ messages in thread
From: Felipe Balbi @ 2016-09-28 13:05 UTC (permalink / raw)
To: Linux USB; +Cc: Felipe Balbi, stable
In case of High-Speed, High-Bandwidth endpoints, we
need to tell DWC3 that we have more than one packet
per interval. We do that by setting PCM1 field of
Isochronous-First TRB.
Cc: <stable@vger.kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---
drivers/usb/dwc3/gadget.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 07cc8929f271..89145a8a92a8 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -771,6 +771,9 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
unsigned length, unsigned chain, unsigned node)
{
struct dwc3_trb *trb;
+ struct dwc3 *dwc = dep->dwc;
+ struct usb_gadget *gadget = &dwc->gadget;
+ enum usb_device_speed speed = gadget->speed;
dwc3_trace(trace_dwc3_gadget, "%s: req %p dma %08llx length %d%s",
dep->name, req, (unsigned long long) dma,
@@ -797,10 +800,16 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
break;
case USB_ENDPOINT_XFER_ISOC:
- if (!node)
+ if (!node) {
trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS_FIRST;
- else
+
+ if (speed == USB_SPEED_HIGH) {
+ struct usb_ep *ep = &dep->endpoint;
+ trb->size |= DWC3_TRB_SIZE_PCM1(ep->mult - 1);
+ }
+ } else {
trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS;
+ }
/* always enable Interrupt on Missed ISOC */
trb->ctrl |= DWC3_TRB_CTRL_ISP_IMI;
--
2.10.0.440.g21f862b
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-28 13:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20160928130554.29790-1-felipe.balbi@linux.intel.com>
2016-09-28 13:05 ` [RFC/PATCH 02/45] usb: gadget: composite: correctly initialize ep->maxpacket Felipe Balbi
2016-09-28 13:05 ` [RFC/PATCH 03/45] usb: gadget: composite: always set ep->mult to a sensible value Felipe Balbi
2016-09-28 13:05 ` [RFC/PATCH 04/45] usb: dwc3: gadget: set PCM1 field of isochronous-first TRBs Felipe Balbi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).