usb: gadget: call usb_gadget_check_config() to verify UDC capability
Subsystems (4)
Frank Li
maintainerPATCH v2 1/2 usb: gadget: call usb_gadget_check_config() to verify UDC capability
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.
---
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(+)
drivers/usb/gadget/composite.c +4 -0
@@ -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;
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH 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.
--- drivers/usb/cdns3/cdns3-gadget.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/cdns3/cdns3-gadget.c +3 -1
@@ -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++; }
Signature · 1 line
2.34.1
Re: [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config
…
Quoted 2 lines
The fix involves checking the private flags
EP_CLAIMEDinstead of relying on the "claimed" flag.
…
Please choose an imperative change suggestion.
Will a cover letter become helpful also for the presented small patch series?
Regards,
Markus
Greg Kroah-Hartman
maintainerRe: [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config
Quoted 6 lines · Markus Elfring
…
Quoted 2 lines
The fix involves checking the private flags
EP_CLAIMEDinstead 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
Re: [v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config
Quoted 9 lines
Quoted 6 lines
…
Quoted 2 lines
The fix involves checking the private flags
EP_CLAIMEDinstead 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.
Does such a response really indicate that you a reject a known advice from the Linux development documentation?
Do you like the same patch reviews more by other contributors?
By the way:
Further change suggestions (including patches) from my selection are still waiting on more positive and constructive feedback.
Regards,
Markus
Re: [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config
In reply to Frank LiQuoted 24 lines · Frank Li
Previously, the
cdns3_gadget_check_config()function in the cdns3 driver mistakenly calculated theep_buf_sizeby considering only one configuration's endpoint information because "claimed" will be clear after callusb_gadget_check_config().The fix involves checking the private flags
EP_CLAIMEDinstead 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(-)drivers/usb/cdns3/cdns3-gadget.c +1
-0@@ -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;
drivers/usb/cdns3/cdns3-gadget.c static int cdns3_gadget_udc_stop(struct usb_gadget *gadget) · line 3011
Quoted 10 lines
drivers/usb/cdns3/cdns3-gadget.c +2
-1struct 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++; }
Signature · 2 lines
Thanks, Peter Chen
Re: [PATCH v2 2/2] usb: cdns3: fix incorrect calculation of ep_buf_size when more than one config
In reply to Frank LiQuoted 25 lines · Frank Li
Previously, the
cdns3_gadget_check_config()function in the cdns3 driver mistakenly calculated theep_buf_sizeby considering only one configuration's endpoint information because "claimed" will be clear after callusb_gadget_check_config().The fix involves checking the private flags
EP_CLAIMEDinstead 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(-)drivers/usb/cdns3/cdns3-gadget.c +1
-0@@ -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;
drivers/usb/cdns3/cdns3-gadget.c static int cdns3_gadget_udc_stop(struct usb_gadget *gadget) · line 3012
Quoted 10 lines
drivers/usb/cdns3/cdns3-gadget.c +2
-1int 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++; }
Signature · 2 lines
Regards, Ravi
Frank Li
maintainerQuoted 5 lines · Frank Li
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.
Quoted 8 lines
Previously,
usb_add_config()was solely invoked by the legacy gadget driver. Adds the necessaryusb_gadget_check_config()after thebind()operation to fix the issue.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]>---
@greg
ping
Quoted 24 lines
change from v1 to v2
- not change for this patch, just add new patch to fix multi-config casedrivers/usb/gadget/composite.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/usb/gadget/composite.c +4
-0@@ -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;Signature · 1 line
2.34.1
Greg KH
maintainerQuoted 10 lines · Frank Li
Quoted 9 lines · Frank Li
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 necessaryusb_gadget_check_config()after thebind()operation to fix the issue.
Quoted 7 lines
Quoted 4 lines
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]>---
@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