From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
To: Amelie DELAUNAY <amelie.delaunay@st.com>
Cc: Alexandre TORGUE <alexandre.torgue@st.com>,
"balbi@kernel.org" <balbi@kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
Fabrice GASNIER <fabrice.gasnier@st.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"hminas@synopsys.com" <hminas@synopsys.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-stm32@st-md-mailman.stormreply.com"
<linux-stm32@st-md-mailman.stormreply.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"mcoquelin.stm32@gmail.com" <mcoquelin.stm32@gmail.com>,
"robh+dt@kernel.org" <robh+dt@kernel.org>
Subject: Re: [PATCH 1/3] usb: dwc2: override PHY input signals with usb role switch support
Date: Sun, 19 Jul 2020 21:56:27 +0200 [thread overview]
Message-ID: <CAFBinCDUxvovAyDywz3xVcu_1v4nai+ebR2D38U2B8oBGss=yg@mail.gmail.com> (raw)
In-Reply-To: <ee4ee889-835e-2244-504c-2b1b605d78aa@st.com>
Hello Amelie,
sorry for the late reply
On Wed, Jul 8, 2020 at 6:00 PM Amelie DELAUNAY <amelie.delaunay@st.com> wrote:
[...]
> Could you please test with:
>
> static int dwc2_drd_role_sw_set(struct device *dev, enum usb_role role)
> {
> struct dwc2_hsotg *hsotg = dev_get_drvdata(dev);
> unsigned long flags;
> int already = 0;
>
> /* Skip session not in line with dr_mode */
> if ((role == USB_ROLE_DEVICE && hsotg->dr_mode == USB_DR_MODE_HOST) ||
> (role == USB_ROLE_HOST && hsotg->dr_mode == USB_DR_MODE_PERIPHERAL))
> return -EINVAL;
>
> /* Skip session if core is in test mode */
> if (role == USB_ROLE_NONE && hsotg->test_mode) {
> dev_dbg(hsotg->dev, "Core is in test mode\n");
> return -EBUSY;
> }
>
> spin_lock_irqsave(&hsotg->lock, flags);
>
> if (role == USB_ROLE_HOST) {
> already = dwc2_ovr_avalid(hsotg, true);
> } else if (role == USB_ROLE_DEVICE) {
> already = dwc2_ovr_bvalid(hsotg, true);
> /* This clear DCTL.SFTDISCON bit */
> dwc2_hsotg_core_connect(hsotg);
> } else {
> if (dwc2_is_device_mode(hsotg)) {
> if (!dwc2_ovr_bvalid(hsotg, false))
> /* This set DCTL.SFTDISCON bit */
> dwc2_hsotg_core_disconnect(hsotg);
> } else {
> dwc2_ovr_avalid(hsotg, false);
> }
> }
>
> spin_unlock_irqrestore(&hsotg->lock, flags);
>
> if (!already &&
> role != USB_ROLE_NONE && hsotg->dr_mode == USB_DR_MODE_OTG)
> /* This will raise a Connector ID Status Change Interrupt */
> dwc2_force_mode(hsotg, role == USB_ROLE_HOST);
>
> dev_dbg(hsotg->dev, "%s-session valid\n",
> role == USB_ROLE_NONE ? "No" :
> role == USB_ROLE_HOST ? "A" : "B");
>
> return 0;
> }
>
>
> dwc2_force_mode is called outside the spin_lock_irqsave so the kernel
> should not complain. I've tested on my setup and the behavior seems the
> same.
this one is looking good - the previous kernel warnings are now gone!
thank you very much
Best regards,
Martin
next prev parent reply other threads:[~2020-07-19 19:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-16 14:07 [PATCH 0/3] Add USB role switch support to DWC2 Amelie Delaunay
2020-06-16 14:07 ` [PATCH 1/3] usb: dwc2: override PHY input signals with usb role switch support Amelie Delaunay
2020-07-04 17:42 ` Martin Blumenstingl
2020-07-07 16:13 ` Amelie DELAUNAY
2020-07-07 18:55 ` Martin Blumenstingl
2020-07-08 16:00 ` Amelie DELAUNAY
2020-07-19 19:56 ` Martin Blumenstingl [this message]
2020-07-23 7:15 ` Amelie DELAUNAY
2020-06-16 14:07 ` [PATCH 2/3] usb: dwc2: don't use ID/Vbus detection if usb-role-switch on STM32MP15 SoCs Amelie Delaunay
2020-06-16 14:07 ` [PATCH 3/3] ARM: dts: stm32: enable usb-role-switch on USB OTG on stm32mp15xx-dkx Amelie Delaunay
2020-06-25 11:34 ` [PATCH 0/3] Add USB role switch support to DWC2 Minas Harutyunyan
2020-07-21 8:54 ` Alexandre Torgue
2020-07-24 12:57 ` Amelie DELAUNAY
2020-07-24 13:45 ` Felipe Balbi
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='CAFBinCDUxvovAyDywz3xVcu_1v4nai+ebR2D38U2B8oBGss=yg@mail.gmail.com' \
--to=martin.blumenstingl@googlemail.com \
--cc=alexandre.torgue@st.com \
--cc=amelie.delaunay@st.com \
--cc=balbi@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=fabrice.gasnier@st.com \
--cc=gregkh@linuxfoundation.org \
--cc=hminas@synopsys.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux-usb@vger.kernel.org \
--cc=mcoquelin.stm32@gmail.com \
--cc=robh+dt@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).