linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pawel Laszczak <pawell@cadence.com>
To: Peter Chen <peter.chen@kernel.org>
Cc: "rogerq@kernel.org" <rogerq@kernel.org>,
	"a-govindraju@ti.com" <a-govindraju@ti.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"felipe.balbi@linux.intel.com" <felipe.balbi@linux.intel.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kishon@ti.com" <kishon@ti.com>,
	Rahul Kumar <kurahul@cadence.com>,
	Sanket Parmar <sparmar@cadence.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH] usb: cdns3: Fixed incorrect gadget state
Date: Mon, 28 Jun 2021 03:46:38 +0000	[thread overview]
Message-ID: <BYAPR07MB53812E6619228B19C2C3A6DADD039@BYAPR07MB5381.namprd07.prod.outlook.com> (raw)
In-Reply-To: <20210626085655.GA13671@Peter>

>
>On 21-06-23 09:02:47, Pawel Laszczak wrote:
>> From: Pawel Laszczak <pawell@cadence.com>
>>
>> For delayed status phase, the usb_gadget->state was set
>> to USB_STATE_ADDRESS and it has never been updated to
>> USB_STATE_CONFIGURED.
>> Patch updates the gadget state to correct USB_STATE_CONFIGURED.
>> As a result of this bug the controller was not able to enter to
>> Test Mode while using MSC function.
>
>Pawel, would you please describe more about this issue? I remember the cdns3
>controller at i.mx series SoC could enter test mode by using current
>code.

The issue occurs only for MSC class. MSC class has delayed status stage, so
after returning from cdns3_req_ep0_set_configuration function called 
for Set Configuration driver remains in USB_STATE_ADDRESS.

In order to enter to test mode driver needs meet the condition included in 
cdns3_ep0_feature_handle_device function:
		if (state != USB_STATE_CONFIGURED || speed > USB_SPEED_HIGH)
			return -EINVAL;

But it is still in USB_STATE_ADDRESS, because there was delayed status stage.
To fix issue driver state must be updated to USB_STATE_CONFIGURED before 
or after  finishing status stage.

>
>>
>> Cc: <stable@vger.kernel.org>
>> Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
>> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
>> ---
>>  drivers/usb/cdns3/cdns3-ep0.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/usb/cdns3/cdns3-ep0.c b/drivers/usb/cdns3/cdns3-ep0.c
>> index 9a17802275d5..ec5bfd8944c3 100644
>> --- a/drivers/usb/cdns3/cdns3-ep0.c
>> +++ b/drivers/usb/cdns3/cdns3-ep0.c
>> @@ -731,6 +731,7 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
>>  		request->actual = 0;
>>  		priv_dev->status_completion_no_call = true;
>>  		priv_dev->pending_status_request = request;
>> +		usb_gadget_set_state(&priv_dev->gadget, USB_STATE_CONFIGURED);
>>  		spin_unlock_irqrestore(&priv_dev->lock, flags);
>>
>>  		/*
>> --
>> 2.25.1
>>
>
--

Thanks,
Pawel Laszczak


  reply	other threads:[~2021-06-28  3:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-23  7:02 [PATCH] usb: cdns3: Fixed incorrect gadget state Pawel Laszczak
2021-06-26  8:56 ` Peter Chen
2021-06-28  3:46   ` Pawel Laszczak [this message]
2021-06-29  1:14     ` Peter Chen
2021-06-29  4:14       ` Pawel Laszczak

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=BYAPR07MB53812E6619228B19C2C3A6DADD039@BYAPR07MB5381.namprd07.prod.outlook.com \
    --to=pawell@cadence.com \
    --cc=a-govindraju@ti.com \
    --cc=felipe.balbi@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kishon@ti.com \
    --cc=kurahul@cadence.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter.chen@kernel.org \
    --cc=rogerq@kernel.org \
    --cc=sparmar@cadence.com \
    --cc=stable@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).