mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
To: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>,
	Ziyang Huang <hzyitc@outlook.com>,
	"amelie.delaunay@foss.st.com" <amelie.delaunay@foss.st.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] usb: dwc2: drd: fix inconsistent mode if role-switch-default-mode="host"
Date: Wed, 1 Mar 2023 12:26:04 +0100	[thread overview]
Message-ID: <0ffed85a-6bc9-b51e-c431-a23b9bf3919c@foss.st.com> (raw)
In-Reply-To: <BYAPR12MB33996D70422B24DE982F3B4AA7AA9@BYAPR12MB3399.namprd12.prod.outlook.com>

On 2/22/23 08:00, Minas Harutyunyan wrote:
> Hi Amelie,
> 
> Could you please review and test this patch on your setup.
> Doesn't broke anything.
> 

Hi Minas,

I tested at my end on behalf of Amelie.
Of course I let her possibly comment.

This doesn't break anything on existing boards. I also tested the
example described by Ziyang in the commit message.

You can add my:
Tested-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>

Thanks & BR,
Fabrice

> Thanks,
> Minas
> 
> On 2/21/2023 2:30 PM, Ziyang Huang <hzyitc@outlook.com> wrote:
>> From: Ziyang Huang <hzyitc@outlook.com>
>> Sent: Tuesday, February 21, 2023 2:30 PM
>> To: Minas Harutyunyan <hminas@synopsys.com>
>> Cc: gregkh@linuxfoundation.org; fabrice.gasnier@foss.st.com;
>> amelie.delaunay@foss.st.com; linux-usb@vger.kernel.org; linux-
>> kernel@vger.kernel.org; Ziyang Huang <hzyitc@outlook.com>
>> Subject: [PATCH v2] usb: dwc2: drd: fix inconsistent mode if role-switch-
>> default-mode="host"
>>
>> Some boards might use USB-A female connector for USB ports, however, the
>> port could be connected to a dual-mode USB controller, making it also
>> behaves as a peripheral device if male-to-male cable is connected.
>>
>> In this case, the dts looks like this:
>>
>> 	&usb0 {
>> 		status = "okay";
>> 		dr_mode = "otg";
>> 		usb-role-switch;
>> 		role-switch-default-mode = "host";
>> 	};
>>
>> After boot, dwc2_ovr_init() sets GOTGCTL to GOTGCTL_AVALOVAL and call
>> dwc2_force_mode() with parameter host=false, which causes inconsistent mode
>> - The hardware is in peripheral mode while the kernel status is in host
>> mode.
>>
>> What we can do now is to call dwc2_drd_role_sw_set() to switch to device
>> mode, and everything should work just fine now, even switching back to
>> none(default) mode afterwards.
>>
>> Fixes: e14acb876985 ("usb: dwc2: drd: add role-switch-default-node support")
>> Signed-off-by: Ziyang Huang <hzyitc@outlook.com>
>> ---
>> Changes since v1
>> - Use corrent name in Signed-off-by
>>
>> drivers/usb/dwc2/drd.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/dwc2/drd.c b/drivers/usb/dwc2/drd.c index
>> d8d6493bc457..a8605b02115b 100644
>> --- a/drivers/usb/dwc2/drd.c
>> +++ b/drivers/usb/dwc2/drd.c
>> @@ -35,7 +35,8 @@ static void dwc2_ovr_init(struct dwc2_hsotg *hsotg)
>>
>> 	spin_unlock_irqrestore(&hsotg->lock, flags);
>>
>> -	dwc2_force_mode(hsotg, (hsotg->dr_mode == USB_DR_MODE_HOST));
>> +	dwc2_force_mode(hsotg, (hsotg->dr_mode == USB_DR_MODE_HOST) ||
>> +				(hsotg->role_sw_default_mode == USB_DR_MODE_HOST));
>> }
>>
>> static int dwc2_ovr_avalid(struct dwc2_hsotg *hsotg, bool valid)
>> --
>> 2.34.1
> 

  reply	other threads:[~2023-03-01 11:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-21 10:30 Ziyang Huang
2023-02-21 10:41 ` Greg KH
2023-02-21 12:33   ` Ziyang Huang
2023-02-21 13:48     ` Greg KH
2023-02-22  7:00 ` Minas Harutyunyan
2023-03-01 11:26   ` Fabrice Gasnier [this message]
2023-03-01 11:30     ` Minas Harutyunyan
2023-03-01 11:31     ` Amelie Delaunay
2023-03-01 11:34 ` Minas Harutyunyan

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=0ffed85a-6bc9-b51e-c431-a23b9bf3919c@foss.st.com \
    --to=fabrice.gasnier@foss.st.com \
    --cc=Minas.Harutyunyan@synopsys.com \
    --cc=amelie.delaunay@foss.st.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hzyitc@outlook.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@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

all inboxes | Powered by JetHome®