* [PATCH v2 1/2] usb: gadget: call usb_gadget_check_config() to verify UDC capability
@ 2023-07-07 23:00 Frank Li
2023-07-07 23:00 ` [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config Frank Li
2023-07-25 14:37 ` [PATCH v2 1/2] usb: gadget: call usb_gadget_check_config() to verify UDC capability Frank Li
0 siblings, 2 replies; 7+ messages in thread
From: Frank Li @ 2023-07-07 23:00 UTC (permalink / raw)
To: frank.li
Cc: Thinh.Nguyen, andriy.shevchenko, gregkh, imx, jgilab, jun.li,
linux-kernel, linux-usb, peter.chen, quic_eserrao, quic_prashk,
r-gunasekaran, rogerq
The legacy gadget driver omitted calling usb_gadget_check_config()
to ensure that the USB device controller (UDC) has adequate resources,
including sufficient endpoint numbers and types, to support the given
configuration.
Previously, usb_add_config() was solely invoked by the legacy gadget
driver. Adds the necessary usb_gadget_check_config() after the bind()
operation to fix the issue.
Fixes: dce49449e04f ("usb: cdns3: allocate TX FIFO size according to composite EP number")
Reported-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
change from v1 to v2
- not change for this patch, just add new patch to fix multi-config case
drivers/usb/gadget/composite.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 403563c06477..cb0a4e2cdbb7 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1029,6 +1029,10 @@ int usb_add_config(struct usb_composite_dev *cdev,
goto done;
status = bind(config);
+
+ if (status == 0)
+ status = usb_gadget_check_config(cdev->gadget);
+
if (status < 0) {
while (!list_empty(&config->functions)) {
struct usb_function *f;
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config
2023-07-07 23:00 [PATCH v2 1/2] usb: gadget: call usb_gadget_check_config() to verify UDC capability Frank Li
@ 2023-07-07 23:00 ` Frank Li
[not found] ` <f803653c-8967-b187-8339-fbec0cdeef25@web.de>
` (2 more replies)
2023-07-25 14:37 ` [PATCH v2 1/2] usb: gadget: call usb_gadget_check_config() to verify UDC capability Frank Li
1 sibling, 3 replies; 7+ messages in thread
From: Frank Li @ 2023-07-07 23:00 UTC (permalink / raw)
To: frank.li
Cc: Thinh.Nguyen, andriy.shevchenko, gregkh, imx, jgilab, jun.li,
linux-kernel, linux-usb, peter.chen, quic_eserrao, quic_prashk,
r-gunasekaran, rogerq
Previously, the cdns3_gadget_check_config() function in the cdns3 driver
mistakenly calculated the ep_buf_size by considering only one
configuration's endpoint information because "claimed" will be clear after
call usb_gadget_check_config().
The fix involves checking the private flags EP_CLAIMED instead of relying
on the "claimed" flag.
Fixes: dce49449e04f ("usb: cdns3: allocate TX FIFO size according to composite EP number")
Reported-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
drivers/usb/cdns3/cdns3-gadget.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
index ccfaebca6faa..3326955f6991 100644
--- a/drivers/usb/cdns3/cdns3-gadget.c
+++ b/drivers/usb/cdns3/cdns3-gadget.c
@@ -2999,12 +2999,14 @@ static int cdns3_gadget_udc_stop(struct usb_gadget *gadget)
static int cdns3_gadget_check_config(struct usb_gadget *gadget)
{
struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget);
+ struct cdns3_endpoint *priv_ep;
struct usb_ep *ep;
int n_in = 0;
int total;
list_for_each_entry(ep, &gadget->ep_list, ep_list) {
- if (ep->claimed && (ep->address & USB_DIR_IN))
+ priv_ep = ep_to_cdns3_ep(ep);
+ if ((priv_ep->flags & EP_CLAIMED) && (ep->address & USB_DIR_IN))
n_in++;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config
[not found] ` <f803653c-8967-b187-8339-fbec0cdeef25@web.de>
@ 2023-07-09 8:06 ` Greg Kroah-Hartman
0 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2023-07-09 8:06 UTC (permalink / raw)
To: Markus Elfring
Cc: Frank Li, linux-usb, kernel-janitors, imx, Andy Shevchenko,
Elson Roy Serrao, Jó Ágila Bitsch, Jun Li, Peter Chen,
Prashanth K, Ravi Gunasekaran, Roger Quadros, LKML
On Sat, Jul 08, 2023 at 05:18:38PM +0200, Markus Elfring wrote:
> …
> > The fix involves checking the private flags EP_CLAIMED instead of relying
> > on the "claimed" flag.
> …
>
> Please choose an imperative change suggestion.
Please do not review USB kernel patches, the comments you make are not
helpful for developers and will be ignored.
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config
2023-07-07 23:00 ` [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config Frank Li
[not found] ` <f803653c-8967-b187-8339-fbec0cdeef25@web.de>
@ 2023-07-10 3:38 ` Peter Chen
2023-07-10 11:14 ` Ravi Gunasekaran
2 siblings, 0 replies; 7+ messages in thread
From: Peter Chen @ 2023-07-10 3:38 UTC (permalink / raw)
To: Frank Li
Cc: Thinh.Nguyen, andriy.shevchenko, gregkh, imx, jgilab, jun.li,
linux-kernel, linux-usb, quic_eserrao, quic_prashk, r-gunasekaran,
rogerq
On 23-07-07 19:00:15, Frank Li wrote:
> Previously, the cdns3_gadget_check_config() function in the cdns3 driver
> mistakenly calculated the ep_buf_size by considering only one
> configuration's endpoint information because "claimed" will be clear after
> call usb_gadget_check_config().
>
> The fix involves checking the private flags EP_CLAIMED instead of relying
> on the "claimed" flag.
>
> Fixes: dce49449e04f ("usb: cdns3: allocate TX FIFO size according to composite EP number")
> Reported-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/usb/cdns3/cdns3-gadget.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
> index ccfaebca6faa..3326955f6991 100644
> --- a/drivers/usb/cdns3/cdns3-gadget.c
> +++ b/drivers/usb/cdns3/cdns3-gadget.c
> @@ -2999,12 +2999,14 @@ static int cdns3_gadget_udc_stop(struct usb_gadget *gadget)
> static int cdns3_gadget_check_config(struct usb_gadget *gadget)
> {
> struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget);
> + struct cdns3_endpoint *priv_ep;
> struct usb_ep *ep;
> int n_in = 0;
> int total;
>
> list_for_each_entry(ep, &gadget->ep_list, ep_list) {
> - if (ep->claimed && (ep->address & USB_DIR_IN))
> + priv_ep = ep_to_cdns3_ep(ep);
> + if ((priv_ep->flags & EP_CLAIMED) && (ep->address & USB_DIR_IN))
> n_in++;
> }
Acked-by: Peter Chen <peter.chen@kernel.org>
--
Thanks,
Peter Chen
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config
2023-07-07 23:00 ` [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config Frank Li
[not found] ` <f803653c-8967-b187-8339-fbec0cdeef25@web.de>
2023-07-10 3:38 ` Peter Chen
@ 2023-07-10 11:14 ` Ravi Gunasekaran
2 siblings, 0 replies; 7+ messages in thread
From: Ravi Gunasekaran @ 2023-07-10 11:14 UTC (permalink / raw)
To: Frank Li
Cc: Thinh.Nguyen, andriy.shevchenko, gregkh, imx, jgilab, jun.li,
linux-kernel, linux-usb, peter.chen, quic_eserrao, quic_prashk,
rogerq
On 7/8/23 4:30 AM, Frank Li wrote:
> Previously, the cdns3_gadget_check_config() function in the cdns3 driver
> mistakenly calculated the ep_buf_size by considering only one
> configuration's endpoint information because "claimed" will be clear after
> call usb_gadget_check_config().
>
> The fix involves checking the private flags EP_CLAIMED instead of relying
> on the "claimed" flag.
>
> Fixes: dce49449e04f ("usb: cdns3: allocate TX FIFO size according to composite EP number")
> Reported-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/usb/cdns3/cdns3-gadget.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
> index ccfaebca6faa..3326955f6991 100644
> --- a/drivers/usb/cdns3/cdns3-gadget.c
> +++ b/drivers/usb/cdns3/cdns3-gadget.c
> @@ -2999,12 +2999,14 @@ static int cdns3_gadget_udc_stop(struct usb_gadget *gadget)
> static int cdns3_gadget_check_config(struct usb_gadget *gadget)
> {
> struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget);
> + struct cdns3_endpoint *priv_ep;
> struct usb_ep *ep;
> int n_in = 0;
> int total;
>
> list_for_each_entry(ep, &gadget->ep_list, ep_list) {
> - if (ep->claimed && (ep->address & USB_DIR_IN))
> + priv_ep = ep_to_cdns3_ep(ep);
> + if ((priv_ep->flags & EP_CLAIMED) && (ep->address & USB_DIR_IN))
> n_in++;
> }
>
Tested-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
--
Regards,
Ravi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] usb: gadget: call usb_gadget_check_config() to verify UDC capability
2023-07-07 23:00 [PATCH v2 1/2] usb: gadget: call usb_gadget_check_config() to verify UDC capability Frank Li
2023-07-07 23:00 ` [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config Frank Li
@ 2023-07-25 14:37 ` Frank Li
2023-07-25 15:09 ` Greg KH
1 sibling, 1 reply; 7+ messages in thread
From: Frank Li @ 2023-07-25 14:37 UTC (permalink / raw)
To: Thinh.Nguyen, andriy.shevchenko, gregkh, imx, jgilab, jun.li,
linux-kernel, linux-usb, peter.chen, quic_eserrao, quic_prashk,
r-gunasekaran, rogerq
On Fri, Jul 07, 2023 at 07:00:14PM -0400, Frank Li wrote:
> The legacy gadget driver omitted calling usb_gadget_check_config()
> to ensure that the USB device controller (UDC) has adequate resources,
> including sufficient endpoint numbers and types, to support the given
> configuration.
>
> Previously, usb_add_config() was solely invoked by the legacy gadget
> driver. Adds the necessary usb_gadget_check_config() after the bind()
> operation to fix the issue.
>
> Fixes: dce49449e04f ("usb: cdns3: allocate TX FIFO size according to composite EP number")
> Reported-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
@greg
ping
> change from v1 to v2
> - not change for this patch, just add new patch to fix multi-config case
>
> drivers/usb/gadget/composite.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index 403563c06477..cb0a4e2cdbb7 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -1029,6 +1029,10 @@ int usb_add_config(struct usb_composite_dev *cdev,
> goto done;
>
> status = bind(config);
> +
> + if (status == 0)
> + status = usb_gadget_check_config(cdev->gadget);
> +
> if (status < 0) {
> while (!list_empty(&config->functions)) {
> struct usb_function *f;
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] usb: gadget: call usb_gadget_check_config() to verify UDC capability
2023-07-25 14:37 ` [PATCH v2 1/2] usb: gadget: call usb_gadget_check_config() to verify UDC capability Frank Li
@ 2023-07-25 15:09 ` Greg KH
0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2023-07-25 15:09 UTC (permalink / raw)
To: Frank Li
Cc: Thinh.Nguyen, andriy.shevchenko, imx, jgilab, jun.li,
linux-kernel, linux-usb, peter.chen, quic_eserrao, quic_prashk,
r-gunasekaran, rogerq
On Tue, Jul 25, 2023 at 10:37:11AM -0400, Frank Li wrote:
> On Fri, Jul 07, 2023 at 07:00:14PM -0400, Frank Li wrote:
> > The legacy gadget driver omitted calling usb_gadget_check_config()
> > to ensure that the USB device controller (UDC) has adequate resources,
> > including sufficient endpoint numbers and types, to support the given
> > configuration.
> >
> > Previously, usb_add_config() was solely invoked by the legacy gadget
> > driver. Adds the necessary usb_gadget_check_config() after the bind()
> > operation to fix the issue.
> >
> > Fixes: dce49449e04f ("usb: cdns3: allocate TX FIFO size according to composite EP number")
> > Reported-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > ---
>
> @greg
> ping
It's in my review queue, please give me a chance to catch up.
While you wait, doing review of other USB patches would be most
appreciated.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-07-25 15:09 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-07 23:00 [PATCH v2 1/2] usb: gadget: call usb_gadget_check_config() to verify UDC capability Frank Li
2023-07-07 23:00 ` [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config Frank Li
[not found] ` <f803653c-8967-b187-8339-fbec0cdeef25@web.de>
2023-07-09 8:06 ` Greg Kroah-Hartman
2023-07-10 3:38 ` Peter Chen
2023-07-10 11:14 ` Ravi Gunasekaran
2023-07-25 14:37 ` [PATCH v2 1/2] usb: gadget: call usb_gadget_check_config() to verify UDC capability Frank Li
2023-07-25 15:09 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox