2023-07-07 23:06:44

by Frank Li

[permalink] [raw]
Subject: [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config

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 <[email protected]>
Signed-off-by: Frank Li <[email protected]>
---
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



2023-07-09 08:13:50

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config

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

2023-07-10 04:07:27

by Peter Chen

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config

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 <[email protected]>
> Signed-off-by: Frank Li <[email protected]>
> ---
> 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 <[email protected]>

--

Thanks,
Peter Chen

2023-07-10 11:40:12

by Ravi Gunasekaran

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config



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 <[email protected]>
> Signed-off-by: Frank Li <[email protected]>
> ---
> 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 <[email protected]>

--
Regards,
Ravi