2023-03-21 12:43:03

by Pawel Laszczak

[permalink] [raw]
Subject: [PATCH v2] usb: cdnsp: Fixes issue with redundant Status Stage

In some cases, driver trees to send Status Stage twice.
The first one from upper layer of gadget usb subsystem and
second time from controller driver.
This patch fixes this issue and remove tricky handling of
SET_INTERFACE from controller driver which is no longer
needed.

cc: <[email protected]>
Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver")
Signed-off-by: Pawel Laszczak <[email protected]>

---
Changelog:
v2:
- removed Smatch static checker warning

drivers/usb/cdns3/cdnsp-ep0.c | 22 ++--------------------
1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/cdns3/cdnsp-ep0.c b/drivers/usb/cdns3/cdnsp-ep0.c
index 9b8325f82499..f317d3c84781 100644
--- a/drivers/usb/cdns3/cdnsp-ep0.c
+++ b/drivers/usb/cdns3/cdnsp-ep0.c
@@ -403,20 +403,6 @@ static int cdnsp_ep0_std_request(struct cdnsp_device *pdev,
case USB_REQ_SET_ISOCH_DELAY:
ret = cdnsp_ep0_set_isoch_delay(pdev, ctrl);
break;
- case USB_REQ_SET_INTERFACE:
- /*
- * Add request into pending list to block sending status stage
- * by libcomposite.
- */
- list_add_tail(&pdev->ep0_preq.list,
- &pdev->ep0_preq.pep->pending_list);
-
- ret = cdnsp_ep0_delegate_req(pdev, ctrl);
- if (ret == -EBUSY)
- ret = 0;
-
- list_del(&pdev->ep0_preq.list);
- break;
default:
ret = cdnsp_ep0_delegate_req(pdev, ctrl);
break;
@@ -428,7 +414,7 @@ static int cdnsp_ep0_std_request(struct cdnsp_device *pdev,
void cdnsp_setup_analyze(struct cdnsp_device *pdev)
{
struct usb_ctrlrequest *ctrl = &pdev->setup;
- int ret = 0;
+ int ret = -EINVAL;
u16 len;

trace_cdnsp_ctrl_req(ctrl);
@@ -438,7 +424,6 @@ void cdnsp_setup_analyze(struct cdnsp_device *pdev)

if (pdev->gadget.state == USB_STATE_NOTATTACHED) {
dev_err(pdev->dev, "ERR: Setup detected in unattached state\n");
- ret = -EINVAL;
goto out;
}

@@ -474,9 +459,6 @@ void cdnsp_setup_analyze(struct cdnsp_device *pdev)
else
ret = cdnsp_ep0_delegate_req(pdev, ctrl);

- if (!len)
- pdev->ep0_stage = CDNSP_STATUS_STAGE;
-
if (ret == USB_GADGET_DELAYED_STATUS) {
trace_cdnsp_ep0_status_stage("delayed");
return;
@@ -484,6 +466,6 @@ void cdnsp_setup_analyze(struct cdnsp_device *pdev)
out:
if (ret < 0)
cdnsp_ep0_stall(pdev);
- else if (pdev->ep0_stage == CDNSP_STATUS_STAGE)
+ else if (!len && pdev->ep0_stage != CDNSP_STATUS_STAGE)
cdnsp_status_stage(pdev);
}
--
2.34.1



2023-03-29 08:42:37

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v2] usb: cdnsp: Fixes issue with redundant Status Stage

On Tue, Mar 21, 2023 at 08:40:53AM -0400, Pawel Laszczak wrote:
> In some cases, driver trees to send Status Stage twice.
> The first one from upper layer of gadget usb subsystem and
> second time from controller driver.
> This patch fixes this issue and remove tricky handling of
> SET_INTERFACE from controller driver which is no longer
> needed.
>
> cc: <[email protected]>
> Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver")
> Signed-off-by: Pawel Laszczak <[email protected]>
>
> ---
> Changelog:
> v2:
> - removed Smatch static checker warning

This is already in 6.3-rc4, right?

thanks,

greg k-h

2023-03-29 08:57:35

by Pawel Laszczak

[permalink] [raw]
Subject: RE: [PATCH v2] usb: cdnsp: Fixes issue with redundant Status Stage

>
>On Tue, Mar 21, 2023 at 08:40:53AM -0400, Pawel Laszczak wrote:
>> In some cases, driver trees to send Status Stage twice.
>> The first one from upper layer of gadget usb subsystem and second time
>> from controller driver.
>> This patch fixes this issue and remove tricky handling of
>> SET_INTERFACE from controller driver which is no longer needed.
>>
>> cc: <[email protected]>
>> Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence
>> USBSSP DRD Driver")
>> Signed-off-by: Pawel Laszczak <[email protected]>
>>
>> ---
>> Changelog:
>> v2:
>> - removed Smatch static checker warning
>
>This is already in 6.3-rc4, right?
>

v1 is in 6.3-rc4.

v2 fix the following issue:
The patch 5bc38d33a5a1: "usb: cdnsp: Fixes issue with redundant Status Stage" from Mar 7, 2023, leads to the following Smatch static checker warning:

drivers/usb/cdns3/cdnsp-ep0.c:470 cdnsp_setup_analyze()
error: uninitialized symbol 'len'.

Regards,
Pawel

2023-03-29 09:00:34

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v2] usb: cdnsp: Fixes issue with redundant Status Stage

On Wed, Mar 29, 2023 at 08:52:43AM +0000, Pawel Laszczak wrote:
> >
> >On Tue, Mar 21, 2023 at 08:40:53AM -0400, Pawel Laszczak wrote:
> >> In some cases, driver trees to send Status Stage twice.
> >> The first one from upper layer of gadget usb subsystem and second time
> >> from controller driver.
> >> This patch fixes this issue and remove tricky handling of
> >> SET_INTERFACE from controller driver which is no longer needed.
> >>
> >> cc: <[email protected]>
> >> Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence
> >> USBSSP DRD Driver")
> >> Signed-off-by: Pawel Laszczak <[email protected]>
> >>
> >> ---
> >> Changelog:
> >> v2:
> >> - removed Smatch static checker warning
> >
> >This is already in 6.3-rc4, right?
> >
>
> v1 is in 6.3-rc4.
>
> v2 fix the following issue:
> The patch 5bc38d33a5a1: "usb: cdnsp: Fixes issue with redundant Status Stage" from Mar 7, 2023, leads to the following Smatch static checker warning:
>
> drivers/usb/cdns3/cdnsp-ep0.c:470 cdnsp_setup_analyze()
> error: uninitialized symbol 'len'.

I can't replace an existing commit in a tree, sorry, that's not how git
works. Please send a fix-up change instead.

greg k-h