On Thu, Nov 03, 2016 at 12:50:43PM +0200, Felipe Balbi wrote:
> 
> Hi,
> 
> Peter Chen <hzpeterc...@gmail.com> writes:
> > On Thu, Nov 03, 2016 at 11:27:40AM +0200, Felipe Balbi wrote:
> >> 
> >> Hi,
> >> 
> >> Peter Chen <hzpeterc...@gmail.com> writes:
> >> >> Peter Chen <peter.c...@nxp.com> writes:
> >> >> > For isoc endpoint descriptor, the wMaxPacketSize is not real max 
> >> >> > packet
> >> >> > size (see Table 9-13. Standard Endpoint Descriptor, USB 2.0 
> >> >> > specifcation),
> >> >> > it may contain the number of packet, so the real max packet should be
> >> >> > ep->desc->wMaxPacketSize && 0x7ff.
> >> >> >
> >> >> > Cc: Felipe F. Tonello <e...@felipetonello.com>
> >> >> > Cc: Felipe Balbi <felipe.ba...@linux.intel.com>
> >> >> > Fixes: 16b114a6d797 ("usb: gadget: fix usb_ep_align_maybe
> >> >> >   endianness and new usb_ep_aligna")
> >> >> >
> >> >> > Signed-off-by: Peter Chen <peter.c...@nxp.com>
> >> >> > ---
> >> >> >  include/linux/usb/gadget.h | 5 ++++-
> >> >> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >> >> >
> >> >> > diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> >> >> > index 8e81f9e..cce2db6 100644
> >> >> > --- a/include/linux/usb/gadget.h
> >> >> > +++ b/include/linux/usb/gadget.h
> >> >> > @@ -429,7 +429,10 @@ static inline struct usb_gadget 
> >> >> > *dev_to_usb_gadget(struct device *dev)
> >> >> >   */
> >> >> >  static inline size_t usb_ep_align(struct usb_ep *ep, size_t len)
> >> >> >  {
> >> >> > -     return round_up(len, 
> >> >> > (size_t)le16_to_cpu(ep->desc->wMaxPacketSize));
> >> >> > +     int max_packet_size = 
> >> >> > (size_t)le16_to_cpu(ep->desc->wMaxPacketSize)
> >> >> > +                     && 0x7ff;
> >>                         ^^
> >> hehe, I just noticed this bug. Did you really test this patch? :-)
> >> 
> >
> > Any problems you find? Without this patch, the usbtest can't be ran
> > for high bandwidth isoc transfer.
> 
> wMaxPacketSize && 0x7ff is always 1 unless wMaxPacketSize is zero, which
> is invalid anyway.
> 
> >> >> > +
> >> >> > +     return round_up(len, max_packet_size);
> >> >> >  }
> >> >> 
> >> >> care to update this to use new usb_endpoint_maxp()?
> >> >> 
> >> >
> >> > But it is a bug existed at v4.9, the usb_ep_align returns wrong request
> >> > length for isoc. I found this bug by running usbtest.
> >> 
> >> keep your & (after fixing it), but use usb_endpoint_maxp(). Later we can
> >> just remove the unnecessary & operation.
> >> 
> >> -- 
> >> balbi
> >
> > I will use usb_endpoint_maxp, but I still not find the problem for this
> > patch.
> 
> Logical vs Bitwise operator
> 

Oh, my careless, I should read my patch again after getting your
comments. Test is ok not stands for code logic is ok.

round_up(3072,1) = 3072, so patch does not trigger error.

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to