From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Hans de Goede <hansg@kernel.org>
Cc: linux-usb@vger.kernel.org, linux-media@vger.kernel.org,
gregkh@linuxfoundation.org, laurent.pinchart@ideasonboard.com,
hdegoede@redhat.com, Thinh.Nguyen@synopsys.com,
Amardeep Rai <amardeep.rai@intel.com>,
Kannappan R <r.kannappan@intel.com>,
Mathias Nyman <mathias.nyman@linux.intel.com>
Subject: Re: [PATCH v2 3/4] USB: Add a function to obtain USB version independent maximum bpi value
Date: Tue, 15 Jul 2025 08:13:25 +0000 [thread overview]
Message-ID: <aHYNpTKsnzBwhl3w@kekkonen.localdomain> (raw)
In-Reply-To: <4ae4a0cf-8b63-4999-941d-011f00cdb5fb@kernel.org>
Hi Hans,
Thank you for the review.
On Fri, Jul 11, 2025 at 03:44:21PM +0200, Hans de Goede wrote:
> Hi Sarari,
>
> On 11-Jul-25 10:34 AM, Sakari Ailus wrote:
> > From: "Rai, Amardeep" <amardeep.rai@intel.com>
> >
> > Add usb_endpoint_max_isoc_bpi() to obtain maximum bytes per interval for
> > isochronous endpoints in a USB version independent way.
>
> Nice, thank you for adding a generic helper for this.
>
> > Signed-off-by: Rai, Amardeep <amardeep.rai@intel.com>
> > Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
> > Co-developed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > ---
> > include/linux/usb.h | 22 ++++++++++++++++++++++
> > 1 file changed, 22 insertions(+)
> >
> > diff --git a/include/linux/usb.h b/include/linux/usb.h
> > index 68166718ab30..bd70bd5ca82d 100644
> > --- a/include/linux/usb.h
> > +++ b/include/linux/usb.h
> > @@ -2038,6 +2038,28 @@ static inline int usb_translate_errors(int error_code)
> > }
> > }
> >
> > +static inline u32 usb_endpoint_max_isoc_bpi(struct usb_device *dev,
> > + const struct usb_host_endpoint *ep)
> > +{
> > + if (usb_endpoint_type(&ep->desc) != USB_ENDPOINT_XFER_ISOC)
> > + return 0;
> > +
> > + switch (dev->speed) {
> > + case USB_SPEED_SUPER_PLUS:
> > + if (USB_SS_SSP_ISOC_COMP(ep->ss_ep_comp.bmAttributes))
> > + return le32_to_cpu(ep->ssp_isoc_ep_comp.dwBytesPerInterval);
> > + fallthrough;
> > + case USB_SPEED_SUPER:
> > + return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval);
> > + case USB_SPEED_HIGH:
> > + if (!usb_endpoint_maxp(&ep->desc) && le16_to_cpu(dev->descriptor.bcdUSB) == 0x220)
> > + return le32_to_cpu(ep->eusb2_isoc_ep_comp.dwBytesPerInterval);
>
> Shouldn't there be a check here that ep->eusb2_isoc_ep_comp is filled?
>
> Like how the USB_SPEED_SUPER_PLU code above checks
> USB_SS_SSP_ISOC_COMP(ep->ss_ep_comp.bmAttributes)?
>
> I know you check the bcdUSB, but in my experience that field sometimes
> contains made up numbers, so I was wondering if there is an extra check
> we can do here ?
In the case of eUSB2, there's no such flag as for the SuperSpeedPlus
Isochronous Endpoint Companion. The eUSB2 Isochronous Endpoint Companion
Descriptor is simply expected to be present on eUSB2 (bcdUSB check)
isochronous IN endpoints that support more than 3KB per microframe.
Also what the USB_SS_SSP_ISOC_COMP() macro returns actually dependens on
the device telling there's such a descriptor but it's still different from
the device actually providing one. But what would you do if the device
indicates it provides no SSP_ISOC_COMP descriptor but still does provide
one?
How about adding a flag (or maybe a bit field?) to tell which endpoint
descriptors have been actually filled in struct usb_host_endpoint? I might
do that as a separate patch on top...
I wonder what Mathias thinks, too.
--
Kind regards,
Sakari Ailus
next prev parent reply other threads:[~2025-07-15 8:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-11 8:34 [PATCH v2 0/4] eUSB2 support Sakari Ailus
2025-07-11 8:34 ` [PATCH v2 1/4] xhci: Add host support for eUSB2 double isochronous bandwidth devices Sakari Ailus
2025-07-11 8:34 ` [PATCH v2 2/4] USB: core: support eUSB2 double bandwidth large isoc URB frames Sakari Ailus
2025-07-11 8:34 ` [PATCH v2 3/4] USB: Add a function to obtain USB version independent maximum bpi value Sakari Ailus
2025-07-11 13:44 ` Hans de Goede
2025-07-15 8:13 ` Sakari Ailus [this message]
2025-07-16 16:35 ` Hans de Goede
2025-07-28 22:21 ` Sakari Ailus
2025-07-11 14:18 ` Alan Stern
2025-07-11 8:34 ` [PATCH v2 4/4] media: uvcvideo: eUSB2 double isochronous bandwidth support Sakari Ailus
2025-07-15 9:10 ` Laurent Pinchart
2025-08-21 9:08 ` Sakari Ailus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aHYNpTKsnzBwhl3w@kekkonen.localdomain \
--to=sakari.ailus@linux.intel.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=amardeep.rai@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=hdegoede@redhat.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@linux.intel.com \
--cc=r.kannappan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox