diff mbox series

[4/6] usb: gadget: tegra-xudc: fix the wrong mult value for HS isoc or intr

Message ID 1628739182-30089-4-git-send-email-chunfeng.yun@mediatek.com (mailing list archive)
State Superseded
Headers show
Series [1/6] usb: mtu3: restore HS function when set SS/SSP | expand

Commit Message

Chunfeng Yun Aug. 12, 2021, 3:33 a.m. UTC
usb_endpoint_maxp() only returns the bit[10:0] of wMaxPacketSize
of endpoint descriptor, not includes bit[12:11] anymore, so use
usb_endpoint_maxp_mult() instead.
Meanwhile no need AND 0x7ff when get maxp, remove it.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/usb/gadget/udc/tegra-xudc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Felipe Balbi Aug. 12, 2021, 6:51 a.m. UTC | #1
Chunfeng Yun <chunfeng.yun@mediatek.com> writes:

> usb_endpoint_maxp() only returns the bit[10:0] of wMaxPacketSize
> of endpoint descriptor, not includes bit[12:11] anymore, so use
> usb_endpoint_maxp_mult() instead.
> Meanwhile no need AND 0x7ff when get maxp, remove it.
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
>  drivers/usb/gadget/udc/tegra-xudc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c
> index a54d1cef17db..40a7417e7ae4 100644
> --- a/drivers/usb/gadget/udc/tegra-xudc.c
> +++ b/drivers/usb/gadget/udc/tegra-xudc.c
> @@ -1610,7 +1610,7 @@ static void tegra_xudc_ep_context_setup(struct tegra_xudc_ep *ep)
>  	u16 maxpacket, maxburst = 0, esit = 0;
>  	u32 val;
>  
> -	maxpacket = usb_endpoint_maxp(desc) & 0x7ff;
> +	maxpacket = usb_endpoint_maxp(desc);
>  	if (xudc->gadget.speed == USB_SPEED_SUPER) {
>  		if (!usb_endpoint_xfer_control(desc))
>  			maxburst = comp_desc->bMaxBurst;
> @@ -1621,7 +1621,7 @@ static void tegra_xudc_ep_context_setup(struct tegra_xudc_ep *ep)
>  		   (usb_endpoint_xfer_int(desc) ||
>  		    usb_endpoint_xfer_isoc(desc))) {
>  		if (xudc->gadget.speed == USB_SPEED_HIGH) {
> -			maxburst = (usb_endpoint_maxp(desc) >> 11) & 0x3;
> +			maxburst = usb_endpoint_maxp_mult(desc) - 1;

this looks like a bug fix. Before this change, maxburst was always 0,
right?

In any case:

Acked-by: Felipe Balbi <balbi@kernel.org>
Chunfeng Yun Aug. 12, 2021, 11:54 a.m. UTC | #2
On Thu, 2021-08-12 at 09:51 +0300, Felipe Balbi wrote:
> Chunfeng Yun <chunfeng.yun@mediatek.com> writes:
> 
> > usb_endpoint_maxp() only returns the bit[10:0] of wMaxPacketSize
> > of endpoint descriptor, not includes bit[12:11] anymore, so use
> > usb_endpoint_maxp_mult() instead.
> > Meanwhile no need AND 0x7ff when get maxp, remove it.
> > 
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > ---
> >  drivers/usb/gadget/udc/tegra-xudc.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/usb/gadget/udc/tegra-xudc.c
> > b/drivers/usb/gadget/udc/tegra-xudc.c
> > index a54d1cef17db..40a7417e7ae4 100644
> > --- a/drivers/usb/gadget/udc/tegra-xudc.c
> > +++ b/drivers/usb/gadget/udc/tegra-xudc.c
> > @@ -1610,7 +1610,7 @@ static void
> > tegra_xudc_ep_context_setup(struct tegra_xudc_ep *ep)
> >  	u16 maxpacket, maxburst = 0, esit = 0;
> >  	u32 val;
> >  
> > -	maxpacket = usb_endpoint_maxp(desc) & 0x7ff;
> > +	maxpacket = usb_endpoint_maxp(desc);
> >  	if (xudc->gadget.speed == USB_SPEED_SUPER) {
> >  		if (!usb_endpoint_xfer_control(desc))
> >  			maxburst = comp_desc->bMaxBurst;
> > @@ -1621,7 +1621,7 @@ static void
> > tegra_xudc_ep_context_setup(struct tegra_xudc_ep *ep)
> >  		   (usb_endpoint_xfer_int(desc) ||
> >  		    usb_endpoint_xfer_isoc(desc))) {
> >  		if (xudc->gadget.speed == USB_SPEED_HIGH) {
> > -			maxburst = (usb_endpoint_maxp(desc) >> 11) &
> > 0x3;
> > +			maxburst = usb_endpoint_maxp_mult(desc) - 1;
> 
> this looks like a bug fix. Before this change, maxburst was always 0,
> right?
Yes
> 
> In any case:
> 
> Acked-by: Felipe Balbi <balbi@kernel.org>
>
diff mbox series

Patch

diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c
index a54d1cef17db..40a7417e7ae4 100644
--- a/drivers/usb/gadget/udc/tegra-xudc.c
+++ b/drivers/usb/gadget/udc/tegra-xudc.c
@@ -1610,7 +1610,7 @@  static void tegra_xudc_ep_context_setup(struct tegra_xudc_ep *ep)
 	u16 maxpacket, maxburst = 0, esit = 0;
 	u32 val;
 
-	maxpacket = usb_endpoint_maxp(desc) & 0x7ff;
+	maxpacket = usb_endpoint_maxp(desc);
 	if (xudc->gadget.speed == USB_SPEED_SUPER) {
 		if (!usb_endpoint_xfer_control(desc))
 			maxburst = comp_desc->bMaxBurst;
@@ -1621,7 +1621,7 @@  static void tegra_xudc_ep_context_setup(struct tegra_xudc_ep *ep)
 		   (usb_endpoint_xfer_int(desc) ||
 		    usb_endpoint_xfer_isoc(desc))) {
 		if (xudc->gadget.speed == USB_SPEED_HIGH) {
-			maxburst = (usb_endpoint_maxp(desc) >> 11) & 0x3;
+			maxburst = usb_endpoint_maxp_mult(desc) - 1;
 			if (maxburst == 0x3) {
 				dev_warn(xudc->dev,
 					 "invalid endpoint maxburst\n");