* Re: [PATCH v4] usb: dwc3: Don't switch OTG -> peripheral if extcon is present
2022-09-23 18:23 ` Andrey Smirnov
@ 2022-09-23 18:35 ` Sven Peter
2022-09-23 18:58 ` Andy Shevchenko
2022-09-23 18:54 ` Andy Shevchenko
` (2 subsequent siblings)
3 siblings, 1 reply; 26+ messages in thread
From: Sven Peter @ 2022-09-23 18:35 UTC (permalink / raw)
To: Andrey Smirnov, Andy Shevchenko
Cc: Ferry Toth, Greg Kroah-Hartman, Felipe Balbi, Thinh Nguyen,
linux-usb, linux-kernel, Thinh Nguyen
On Fri, Sep 23, 2022, at 20:23, Andrey Smirnov wrote:
> On Fri, Sep 23, 2022 at 9:42 AM Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
>>
>> On Thu, Sep 22, 2022 at 04:32:55PM -0700, Andrey Smirnov wrote:
>> > On Thu, Sep 22, 2022 at 3:23 AM Ferry Toth <fntoth@gmail.com> wrote:
>> > > On 22-09-2022 12:08, Andy Shevchenko wrote:
>> > > On Sun, Apr 03, 2022 at 09:49:07AM -0700, Andrey Smirnov wrote:
>>
>> FYI: For now I sent a revert, but if we got a solution quicker we always
>> can choose the course of actions.
>>
>
> I think we have another problem. This patch happened in parallel to mine
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc6&id=ab7aa2866d295438dc60522f85c5421c6b4f1507
>
> so my changes didn't have that fix in mind and I think your revert
> will not preserve that fix. Can you update your revert to take care of
> that too, please?
>
> I'm really confused how the above commit could be followed up by:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/usb/dwc3/drd.c?h=v6.0-rc6&id=0f01017191384e3962fa31520a9fd9846c3d352f
>
> the diffs in dwc3_drd_init seem contradictory
I noticed this a while ago when I finally rebased the M1 USB3 PHY WIP branch
and have been meaning to send a fix. Then life unfortunately got in the way and
I completely forgot about it again.
Both patches were sent at approximately the same time and I think got merged into
two separate branches. The conflict resolution [1] then went bad but I didn't notice
until weeks later :(
Best,
Sven
[1] https://lore.kernel.org/lkml/20220426150842.473be40e@canb.auug.org.au/
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4] usb: dwc3: Don't switch OTG -> peripheral if extcon is present
2022-09-23 18:35 ` Sven Peter
@ 2022-09-23 18:58 ` Andy Shevchenko
2022-09-24 1:07 ` Andrey Smirnov
0 siblings, 1 reply; 26+ messages in thread
From: Andy Shevchenko @ 2022-09-23 18:58 UTC (permalink / raw)
To: Sven Peter, Stephen Rothwell
Cc: Andrey Smirnov, Ferry Toth, Greg Kroah-Hartman, Felipe Balbi,
Thinh Nguyen, linux-usb, linux-kernel, Thinh Nguyen
+Stephen to help to realize what the mess we have now...
On Fri, Sep 23, 2022 at 08:35:13PM +0200, Sven Peter wrote:
> On Fri, Sep 23, 2022, at 20:23, Andrey Smirnov wrote:
> > On Fri, Sep 23, 2022 at 9:42 AM Andy Shevchenko
> > <andriy.shevchenko@intel.com> wrote:
> >>
> >> On Thu, Sep 22, 2022 at 04:32:55PM -0700, Andrey Smirnov wrote:
> >> > On Thu, Sep 22, 2022 at 3:23 AM Ferry Toth <fntoth@gmail.com> wrote:
> >> > > On 22-09-2022 12:08, Andy Shevchenko wrote:
> >> > > On Sun, Apr 03, 2022 at 09:49:07AM -0700, Andrey Smirnov wrote:
> >>
> >> FYI: For now I sent a revert, but if we got a solution quicker we always
> >> can choose the course of actions.
> >>
> >
> > I think we have another problem. This patch happened in parallel to mine
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc6&id=ab7aa2866d295438dc60522f85c5421c6b4f1507
> >
> > so my changes didn't have that fix in mind and I think your revert
> > will not preserve that fix. Can you update your revert to take care of
> > that too, please?
> >
> > I'm really confused how the above commit could be followed up by:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/usb/dwc3/drd.c?h=v6.0-rc6&id=0f01017191384e3962fa31520a9fd9846c3d352f
> >
> > the diffs in dwc3_drd_init seem contradictory
>
> I noticed this a while ago when I finally rebased the M1 USB3 PHY WIP branch
> and have been meaning to send a fix. Then life unfortunately got in the way and
> I completely forgot about it again.
>
> Both patches were sent at approximately the same time and I think got merged into
> two separate branches. The conflict resolution [1] then went bad but I didn't notice
> until weeks later :(
Folks, I have no idea what you are talking about. Can you check that revert
series [2] gets your change still in? Because I have no clue how it's involved at
all into discussion.
> [1] https://lore.kernel.org/lkml/20220426150842.473be40e@canb.auug.org.au/
[2]: https://lore.kernel.org/linux-usb/20220923163051.36288-1-andriy.shevchenko@linux.intel.com/
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4] usb: dwc3: Don't switch OTG -> peripheral if extcon is present
2022-09-23 18:58 ` Andy Shevchenko
@ 2022-09-24 1:07 ` Andrey Smirnov
0 siblings, 0 replies; 26+ messages in thread
From: Andrey Smirnov @ 2022-09-24 1:07 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Sven Peter, Stephen Rothwell, Ferry Toth, Greg Kroah-Hartman,
Felipe Balbi, Thinh Nguyen, linux-usb, linux-kernel,
Thinh Nguyen
On Fri, Sep 23, 2022 at 11:58 AM Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
>
> +Stephen to help to realize what the mess we have now...
>
> On Fri, Sep 23, 2022 at 08:35:13PM +0200, Sven Peter wrote:
> > On Fri, Sep 23, 2022, at 20:23, Andrey Smirnov wrote:
> > > On Fri, Sep 23, 2022 at 9:42 AM Andy Shevchenko
> > > <andriy.shevchenko@intel.com> wrote:
> > >>
> > >> On Thu, Sep 22, 2022 at 04:32:55PM -0700, Andrey Smirnov wrote:
> > >> > On Thu, Sep 22, 2022 at 3:23 AM Ferry Toth <fntoth@gmail.com> wrote:
> > >> > > On 22-09-2022 12:08, Andy Shevchenko wrote:
> > >> > > On Sun, Apr 03, 2022 at 09:49:07AM -0700, Andrey Smirnov wrote:
> > >>
> > >> FYI: For now I sent a revert, but if we got a solution quicker we always
> > >> can choose the course of actions.
> > >>
> > >
> > > I think we have another problem. This patch happened in parallel to mine
> > >
> > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc6&id=ab7aa2866d295438dc60522f85c5421c6b4f1507
> > >
> > > so my changes didn't have that fix in mind and I think your revert
> > > will not preserve that fix. Can you update your revert to take care of
> > > that too, please?
> > >
> > > I'm really confused how the above commit could be followed up by:
> > >
> > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/usb/dwc3/drd.c?h=v6.0-rc6&id=0f01017191384e3962fa31520a9fd9846c3d352f
> > >
> > > the diffs in dwc3_drd_init seem contradictory
> >
> > I noticed this a while ago when I finally rebased the M1 USB3 PHY WIP branch
> > and have been meaning to send a fix. Then life unfortunately got in the way and
> > I completely forgot about it again.
> >
> > Both patches were sent at approximately the same time and I think got merged into
> > two separate branches. The conflict resolution [1] then went bad but I didn't notice
> > until weeks later :(
>
> Folks, I have no idea what you are talking about. Can you check that revert
> series [2] gets your change still in? Because I have no clue how it's involved at
> all into discussion.
>
> > [1] https://lore.kernel.org/lkml/20220426150842.473be40e@canb.auug.org.au/
>
> [2]: https://lore.kernel.org/linux-usb/20220923163051.36288-1-andriy.shevchenko@linux.intel.com/
>
Here's Sven's diff:
diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
index b60b5f7b6dff4..8cad9e7d33687 100644
--- a/drivers/usb/dwc3/drd.c
+++ b/drivers/usb/dwc3/drd.c
@@ -584,16 +584,15 @@ int dwc3_drd_init(struct dwc3 *dwc)
{
int ret, irq;
+ if (ROLE_SWITCH &&
+ device_property_read_bool(dwc->dev, "usb-role-switch"))
+ return dwc3_setup_role_switch(dwc);
+
dwc->edev = dwc3_get_extcon(dwc);
if (IS_ERR(dwc->edev))
return PTR_ERR(dwc->edev);
- if (ROLE_SWITCH &&
- device_property_read_bool(dwc->dev, "usb-role-switch")) {
- ret = dwc3_setup_role_switch(dwc);
- if (ret < 0)
- return ret;
- } else if (dwc->edev) {
+ if (dwc->edev) {
Here's your revert of my patch:
@@ -538,6 +584,10 @@ int dwc3_drd_init(struct dwc3 *dwc)
{
int ret, irq;
+ dwc->edev = dwc3_get_extcon(dwc);
+ if (IS_ERR(dwc->edev))
+ return PTR_ERR(dwc->edev);
+
if (ROLE_SWITCH &&
device_property_read_bool(dwc->dev, "usb-role-switch"))
return dwc3_setup_role_switch(dwc);
There's an order of operations difference. Dwc3_get_extcon() Needs to
be happening after if (ROLE_SWITCH
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH v4] usb: dwc3: Don't switch OTG -> peripheral if extcon is present
2022-09-23 18:23 ` Andrey Smirnov
2022-09-23 18:35 ` Sven Peter
@ 2022-09-23 18:54 ` Andy Shevchenko
2022-09-24 1:27 ` Andrey Smirnov
2022-09-23 20:10 ` Ferry Toth
2022-09-24 21:29 ` Ferry Toth
3 siblings, 1 reply; 26+ messages in thread
From: Andy Shevchenko @ 2022-09-23 18:54 UTC (permalink / raw)
To: Andrey Smirnov
Cc: Ferry Toth, Greg Kroah-Hartman, Felipe Balbi, Thinh Nguyen,
linux-usb, linux-kernel, Thinh Nguyen, Sven Peter
On Fri, Sep 23, 2022 at 11:23:23AM -0700, Andrey Smirnov wrote:
> On Fri, Sep 23, 2022 at 9:42 AM Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
> > On Thu, Sep 22, 2022 at 04:32:55PM -0700, Andrey Smirnov wrote:
> > > On Thu, Sep 22, 2022 at 3:23 AM Ferry Toth <fntoth@gmail.com> wrote:
> > > > On 22-09-2022 12:08, Andy Shevchenko wrote:
> > > > On Sun, Apr 03, 2022 at 09:49:07AM -0700, Andrey Smirnov wrote:
> >
> > FYI: For now I sent a revert, but if we got a solution quicker we always
> > can choose the course of actions.
>
> I think we have another problem. This patch happened in parallel to mine
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc6&id=ab7aa2866d295438dc60522f85c5421c6b4f1507
>
> so my changes didn't have that fix in mind and I think your revert
> will not preserve that fix. Can you update your revert to take care of
> that too, please?
>
> I'm really confused how the above commit could be followed up by:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/usb/dwc3/drd.c?h=v6.0-rc6&id=0f01017191384e3962fa31520a9fd9846c3d352f
>
> the diffs in dwc3_drd_init seem contradictory
I'm not sure I follow. Your patch has been merged and after that some kind of
merge conflict was resolved by an additional change. To revert your stuff
cleanly we need to revert the merge update patch first. That's why revert is a
series of patches and not a single one. I have no idea how above mentioned
commit at all related to all this.
Can you elaborate more, please?
> > > > If the extcon device exists, get the mode from the extcon device. If
> > > > the controller is DRD and the driver is unable to determine the mode,
> > > > only then default the dr_mode to USB_DR_MODE_PERIPHERAL.
> > > >
> > > > According to Ferry (Cc'ed) this broke Intel Merrifield platform. Ferry, can you
> > > > share bisect log?
> > > >
> > > > I can but not right now. But what I did was bisect between 5.18.0 (good) and 5.19.0 (bad) then when I got near the culprit (~20 remaining) based on the commit message I tried 0f01017191384e3962fa31520a9fd9846c3d352f "usb: dwc3: Don't switch OTG -> peripheral if extcon is present" (bad) and commit before that (good).
> > > >
> > > > The effect of the patch is that on Merrifield (I tested with Intel Edison Arduino board which has a HW switch to select between host and device mode) device mode works but in host mode USB is completely not working.
> > > >
> > > > Currently on host mode - when working - superfluous error messages from tusb1210 appear. When host mode is not working there are no tusb1210 messages in the logs / on the console at all. Seemingly tusb1210 is not probed, which points in the direction of a relation to extcon.
> > > >
> > > > Taking into account the late cycle, I would like to revert the change. And
> > > > Ferry and I would help to test any other (non-regressive) approach).
> > > >
> > > > I have not yet tested if a simple revert fixes the problem but will tonight.
> > > >
> > > > I would be happy to test other approaches too.
> > >
> > > It's a bit hard for me to suggest an alternative approach without
> > > knowing how things are breaking in this case. I'd love to order one of
> > > those boards to repro and fix this on my end, but it looks like this
> > > HW is EOLed and out of stock in most places. If you guys know how to
> > > get my hands on those boards I'm all ears.
> >
> > There are still some second hand Intel Edison boards flying around
> > (but maybe cost a bit more than expected) and there are also
> > Dell Venue 7 3740 tablets based on the same platform/SoC. The latter
> > option though requires more actions in order something to be boot
> > there.
>
> OK, I'll check e-bay just in case.
>
> > In any case, it's probably quicker to ask Ferry or me for testing.
> > (Although currently I have no access to the board to test OTG, it's
> > remote device which I can only power on and off and it has always
> > be in host mode.)
> >
> > > Barring that, Ferry can you dig more into this failure? E.g. is it this hunk
> > >
> > > @@ -85,7 +86,7 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
> > > * mode. If the controller supports DRD but the dr_mode is not
> > > * specified or set to OTG, then set the mode to peripheral.
> > > */
> > > - if (mode == USB_DR_MODE_OTG &&
> > > + if (mode == USB_DR_MODE_OTG && !dwc->edev &&
> > > (!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) ||
> > > !device_property_read_bool(dwc->dev, "usb-role-switch")) &&
> > > !DWC3_VER_IS_PRIOR(DWC3, 330A))
> > > @@ -1632,6 +1633,51 @@ static void dwc3_check_params(struct dwc3 *dwc)
> > > }
> > > }
> > >
> > > that's problematic or moving
> >
> > I think you wanted to revert only this line and test?
>
> Yes.
Ferry, can you try that (but I believe it won't help anyway, because I don't
see how we handle deferred probe).
> > > static int dwc3_probe(struct platform_device *pdev)
> > > {
> > > struct device *dev = &pdev->dev;
> > > @@ -1744,6 +1790,13 @@ static int dwc3_probe(struct platform_device *pdev)
> > > goto err2;
> > > }
> > >
> > > + dwc->edev = dwc3_get_extcon(dwc);
> > > + if (IS_ERR(dwc->edev)) {
> > > + ret = PTR_ERR(dwc->edev);
> > > + dev_err_probe(dwc->dev, ret, "failed to get extcon\n");
> > > + goto err3;
> > > + }
> > > +
> > > ret = dwc3_get_dr_mode(dwc);
> > > if (ret)
> > > goto err3;
> > >
> > > to happen earlier?
> >
> > It is not always possible to have an extcon driver available, that's why in
> > some cases the probe of it defers. I dunno how your patch supposed to work
> > in that case.
>
> I'm not sure I understand what you mean. AFAIU the logic is that if
> the platform specifies the presence of extcon either via DT or, like
> Merrifield, via and explicit "linux,extcon-name" device property in
> the code then extcon is a mandatory component of the DRD stack and the
> driver is expected to be present for the whole thing to work.
> I don't
> think I really changed that logic with my patch, even after the revert
> dwc3_get_extcon() will be called as a part of a probing codepath,
But it's not true as proved by the experiment. So with your patch it doesn't
work anymore, so the logic _is_ changed.
> so
> if the a missing driver is causing a probe deferral it should still be
> happening, unless I missed something.
The merge fix removes deferred probe by some reason.
> > > Does tracing the "mrfld_bcove_pwrsrc" driver (the
> > > excton provider in this case AFIACT) show anything interesting?
> >
> > I believe there is nothing interesting.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4] usb: dwc3: Don't switch OTG -> peripheral if extcon is present
2022-09-23 18:54 ` Andy Shevchenko
@ 2022-09-24 1:27 ` Andrey Smirnov
2022-09-24 11:55 ` Ferry Toth
0 siblings, 1 reply; 26+ messages in thread
From: Andrey Smirnov @ 2022-09-24 1:27 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Ferry Toth, Greg Kroah-Hartman, Felipe Balbi, Thinh Nguyen,
linux-usb, linux-kernel, Thinh Nguyen, Sven Peter
On Fri, Sep 23, 2022 at 11:54 AM Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
>
> On Fri, Sep 23, 2022 at 11:23:23AM -0700, Andrey Smirnov wrote:
> > On Fri, Sep 23, 2022 at 9:42 AM Andy Shevchenko
> > <andriy.shevchenko@intel.com> wrote:
> > > On Thu, Sep 22, 2022 at 04:32:55PM -0700, Andrey Smirnov wrote:
> > > > On Thu, Sep 22, 2022 at 3:23 AM Ferry Toth <fntoth@gmail.com> wrote:
> > > > > On 22-09-2022 12:08, Andy Shevchenko wrote:
> > > > > On Sun, Apr 03, 2022 at 09:49:07AM -0700, Andrey Smirnov wrote:
> > >
> > > FYI: For now I sent a revert, but if we got a solution quicker we always
> > > can choose the course of actions.
> >
> > I think we have another problem. This patch happened in parallel to mine
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc6&id=ab7aa2866d295438dc60522f85c5421c6b4f1507
> >
> > so my changes didn't have that fix in mind and I think your revert
> > will not preserve that fix. Can you update your revert to take care of
> > that too, please?
> >
> > I'm really confused how the above commit could be followed up by:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/usb/dwc3/drd.c?h=v6.0-rc6&id=0f01017191384e3962fa31520a9fd9846c3d352f
> >
> > the diffs in dwc3_drd_init seem contradictory
>
> I'm not sure I follow. Your patch has been merged and after that some kind of
> merge conflict was resolved by an additional change. To revert your stuff
> cleanly we need to revert the merge update patch first. That's why revert is a
> series of patches and not a single one. I have no idea how above mentioned
> commit at all related to all this.
>
> Can you elaborate more, please?
>
It's not important to clarify, just me voicing my confusion, we have
way too many threads of discussion already.
> > > > > If the extcon device exists, get the mode from the extcon device. If
> > > > > the controller is DRD and the driver is unable to determine the mode,
> > > > > only then default the dr_mode to USB_DR_MODE_PERIPHERAL.
> > > > >
> > > > > According to Ferry (Cc'ed) this broke Intel Merrifield platform. Ferry, can you
> > > > > share bisect log?
> > > > >
> > > > > I can but not right now. But what I did was bisect between 5.18.0 (good) and 5.19.0 (bad) then when I got near the culprit (~20 remaining) based on the commit message I tried 0f01017191384e3962fa31520a9fd9846c3d352f "usb: dwc3: Don't switch OTG -> peripheral if extcon is present" (bad) and commit before that (good).
> > > > >
> > > > > The effect of the patch is that on Merrifield (I tested with Intel Edison Arduino board which has a HW switch to select between host and device mode) device mode works but in host mode USB is completely not working.
> > > > >
> > > > > Currently on host mode - when working - superfluous error messages from tusb1210 appear. When host mode is not working there are no tusb1210 messages in the logs / on the console at all. Seemingly tusb1210 is not probed, which points in the direction of a relation to extcon.
> > > > >
> > > > > Taking into account the late cycle, I would like to revert the change. And
> > > > > Ferry and I would help to test any other (non-regressive) approach).
> > > > >
> > > > > I have not yet tested if a simple revert fixes the problem but will tonight.
> > > > >
> > > > > I would be happy to test other approaches too.
> > > >
> > > > It's a bit hard for me to suggest an alternative approach without
> > > > knowing how things are breaking in this case. I'd love to order one of
> > > > those boards to repro and fix this on my end, but it looks like this
> > > > HW is EOLed and out of stock in most places. If you guys know how to
> > > > get my hands on those boards I'm all ears.
> > >
> > > There are still some second hand Intel Edison boards flying around
> > > (but maybe cost a bit more than expected) and there are also
> > > Dell Venue 7 3740 tablets based on the same platform/SoC. The latter
> > > option though requires more actions in order something to be boot
> > > there.
> >
> > OK, I'll check e-bay just in case.
> >
> > > In any case, it's probably quicker to ask Ferry or me for testing.
> > > (Although currently I have no access to the board to test OTG, it's
> > > remote device which I can only power on and off and it has always
> > > be in host mode.)
> > >
> > > > Barring that, Ferry can you dig more into this failure? E.g. is it this hunk
> > > >
> > > > @@ -85,7 +86,7 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
> > > > * mode. If the controller supports DRD but the dr_mode is not
> > > > * specified or set to OTG, then set the mode to peripheral.
> > > > */
> > > > - if (mode == USB_DR_MODE_OTG &&
> > > > + if (mode == USB_DR_MODE_OTG && !dwc->edev &&
> > > > (!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) ||
> > > > !device_property_read_bool(dwc->dev, "usb-role-switch")) &&
> > > > !DWC3_VER_IS_PRIOR(DWC3, 330A))
> > > > @@ -1632,6 +1633,51 @@ static void dwc3_check_params(struct dwc3 *dwc)
> > > > }
> > > > }
> > > >
> > > > that's problematic or moving
> > >
> > > I think you wanted to revert only this line and test?
> >
> > Yes.
>
> Ferry, can you try that (but I believe it won't help anyway, because I don't
> see how we handle deferred probe).
>
> > > > static int dwc3_probe(struct platform_device *pdev)
> > > > {
> > > > struct device *dev = &pdev->dev;
> > > > @@ -1744,6 +1790,13 @@ static int dwc3_probe(struct platform_device *pdev)
> > > > goto err2;
> > > > }
> > > >
> > > > + dwc->edev = dwc3_get_extcon(dwc);
> > > > + if (IS_ERR(dwc->edev)) {
> > > > + ret = PTR_ERR(dwc->edev);
> > > > + dev_err_probe(dwc->dev, ret, "failed to get extcon\n");
> > > > + goto err3;
> > > > + }
> > > > +
> > > > ret = dwc3_get_dr_mode(dwc);
> > > > if (ret)
> > > > goto err3;
> > > >
> > > > to happen earlier?
> > >
> > > It is not always possible to have an extcon driver available, that's why in
> > > some cases the probe of it defers. I dunno how your patch supposed to work
> > > in that case.
> >
> > I'm not sure I understand what you mean. AFAIU the logic is that if
> > the platform specifies the presence of extcon either via DT or, like
> > Merrifield, via and explicit "linux,extcon-name" device property in
> > the code then extcon is a mandatory component of the DRD stack and the
> > driver is expected to be present for the whole thing to work.
>
> > I don't
> > think I really changed that logic with my patch, even after the revert
> > dwc3_get_extcon() will be called as a part of a probing codepath,
>
> But it's not true as proved by the experiment. So with your patch it doesn't
> work anymore, so the logic _is_ changed.
>
I think you are jumping the gun here. We know that the patch breaks
USB host functionality on Merrifield. We know that "Seemingly tusb1210
is not probed". Do we know that dwc3.ko (I think that'd be the
driver's name) is not probed? Did Ferry share that info with you in
some other thread? I don't deny it is possible, but I don't think this
is really clear at this moment to say definitively.
> > so
> > if the a missing driver is causing a probe deferral it should still be
> > happening, unless I missed something.
>
> The merge fix removes deferred probe by some reason.
>
> > > > Does tracing the "mrfld_bcove_pwrsrc" driver (the
> > > > excton provider in this case AFIACT) show anything interesting?
> > >
> > > I believe there is nothing interesting.
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4] usb: dwc3: Don't switch OTG -> peripheral if extcon is present
2022-09-24 1:27 ` Andrey Smirnov
@ 2022-09-24 11:55 ` Ferry Toth
0 siblings, 0 replies; 26+ messages in thread
From: Ferry Toth @ 2022-09-24 11:55 UTC (permalink / raw)
To: Andrey Smirnov, Andy Shevchenko
Cc: Greg Kroah-Hartman, Felipe Balbi, Thinh Nguyen, linux-usb,
linux-kernel, Thinh Nguyen, Sven Peter
Hi,
Op 24-09-2022 om 03:27 schreef Andrey Smirnov:
> On Fri, Sep 23, 2022 at 11:54 AM Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
>> On Fri, Sep 23, 2022 at 11:23:23AM -0700, Andrey Smirnov wrote:
>>> On Fri, Sep 23, 2022 at 9:42 AM Andy Shevchenko
>>> <andriy.shevchenko@intel.com> wrote:
>>>> On Thu, Sep 22, 2022 at 04:32:55PM -0700, Andrey Smirnov wrote:
>>>>> On Thu, Sep 22, 2022 at 3:23 AM Ferry Toth <fntoth@gmail.com> wrote:
>>>>>> On 22-09-2022 12:08, Andy Shevchenko wrote:
>>>>>> On Sun, Apr 03, 2022 at 09:49:07AM -0700, Andrey Smirnov wrote:
>>>> FYI: For now I sent a revert, but if we got a solution quicker we always
>>>> can choose the course of actions.
>>> I think we have another problem. This patch happened in parallel to mine
>>>
>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc6&id=ab7aa2866d295438dc60522f85c5421c6b4f1507
>>>
>>> so my changes didn't have that fix in mind and I think your revert
>>> will not preserve that fix. Can you update your revert to take care of
>>> that too, please?
>>>
>>> I'm really confused how the above commit could be followed up by:
>>>
>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/usb/dwc3/drd.c?h=v6.0-rc6&id=0f01017191384e3962fa31520a9fd9846c3d352f
>>>
>>> the diffs in dwc3_drd_init seem contradictory
>> I'm not sure I follow. Your patch has been merged and after that some kind of
>> merge conflict was resolved by an additional change. To revert your stuff
>> cleanly we need to revert the merge update patch first. That's why revert is a
>> series of patches and not a single one. I have no idea how above mentioned
>> commit at all related to all this.
>>
>> Can you elaborate more, please?
>>
> It's not important to clarify, just me voicing my confusion, we have
> way too many threads of discussion already.
>
>>>>>> If the extcon device exists, get the mode from the extcon device. If
>>>>>> the controller is DRD and the driver is unable to determine the mode,
>>>>>> only then default the dr_mode to USB_DR_MODE_PERIPHERAL.
>>>>>>
>>>>>> According to Ferry (Cc'ed) this broke Intel Merrifield platform. Ferry, can you
>>>>>> share bisect log?
>>>>>>
>>>>>> I can but not right now. But what I did was bisect between 5.18.0 (good) and 5.19.0 (bad) then when I got near the culprit (~20 remaining) based on the commit message I tried 0f01017191384e3962fa31520a9fd9846c3d352f "usb: dwc3: Don't switch OTG -> peripheral if extcon is present" (bad) and commit before that (good).
>>>>>>
>>>>>> The effect of the patch is that on Merrifield (I tested with Intel Edison Arduino board which has a HW switch to select between host and device mode) device mode works but in host mode USB is completely not working.
>>>>>>
>>>>>> Currently on host mode - when working - superfluous error messages from tusb1210 appear. When host mode is not working there are no tusb1210 messages in the logs / on the console at all. Seemingly tusb1210 is not probed, which points in the direction of a relation to extcon.
>>>>>>
>>>>>> Taking into account the late cycle, I would like to revert the change. And
>>>>>> Ferry and I would help to test any other (non-regressive) approach).
>>>>>>
>>>>>> I have not yet tested if a simple revert fixes the problem but will tonight.
>>>>>>
>>>>>> I would be happy to test other approaches too.
>>>>> It's a bit hard for me to suggest an alternative approach without
>>>>> knowing how things are breaking in this case. I'd love to order one of
>>>>> those boards to repro and fix this on my end, but it looks like this
>>>>> HW is EOLed and out of stock in most places. If you guys know how to
>>>>> get my hands on those boards I'm all ears.
>>>> There are still some second hand Intel Edison boards flying around
>>>> (but maybe cost a bit more than expected) and there are also
>>>> Dell Venue 7 3740 tablets based on the same platform/SoC. The latter
>>>> option though requires more actions in order something to be boot
>>>> there.
>>> OK, I'll check e-bay just in case.
>>>
>>>> In any case, it's probably quicker to ask Ferry or me for testing.
>>>> (Although currently I have no access to the board to test OTG, it's
>>>> remote device which I can only power on and off and it has always
>>>> be in host mode.)
>>>>
>>>>> Barring that, Ferry can you dig more into this failure? E.g. is it this hunk
>>>>>
>>>>> @@ -85,7 +86,7 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
>>>>> * mode. If the controller supports DRD but the dr_mode is not
>>>>> * specified or set to OTG, then set the mode to peripheral.
>>>>> */
>>>>> - if (mode == USB_DR_MODE_OTG &&
>>>>> + if (mode == USB_DR_MODE_OTG && !dwc->edev &&
>>>>> (!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) ||
>>>>> !device_property_read_bool(dwc->dev, "usb-role-switch")) &&
>>>>> !DWC3_VER_IS_PRIOR(DWC3, 330A))
>>>>> @@ -1632,6 +1633,51 @@ static void dwc3_check_params(struct dwc3 *dwc)
>>>>> }
>>>>> }
>>>>>
>>>>> that's problematic or moving
>>>> I think you wanted to revert only this line and test?
>>> Yes.
>> Ferry, can you try that (but I believe it won't help anyway, because I don't
>> see how we handle deferred probe).
>>
>>>>> static int dwc3_probe(struct platform_device *pdev)
>>>>> {
>>>>> struct device *dev = &pdev->dev;
>>>>> @@ -1744,6 +1790,13 @@ static int dwc3_probe(struct platform_device *pdev)
>>>>> goto err2;
>>>>> }
>>>>>
>>>>> + dwc->edev = dwc3_get_extcon(dwc);
>>>>> + if (IS_ERR(dwc->edev)) {
>>>>> + ret = PTR_ERR(dwc->edev);
>>>>> + dev_err_probe(dwc->dev, ret, "failed to get extcon\n");
>>>>> + goto err3;
>>>>> + }
>>>>> +
>>>>> ret = dwc3_get_dr_mode(dwc);
>>>>> if (ret)
>>>>> goto err3;
>>>>>
>>>>> to happen earlier?
>>>> It is not always possible to have an extcon driver available, that's why in
>>>> some cases the probe of it defers. I dunno how your patch supposed to work
>>>> in that case.
>>> I'm not sure I understand what you mean. AFAIU the logic is that if
>>> the platform specifies the presence of extcon either via DT or, like
>>> Merrifield, via and explicit "linux,extcon-name" device property in
>>> the code then extcon is a mandatory component of the DRD stack and the
>>> driver is expected to be present for the whole thing to work.
>>> I don't
>>> think I really changed that logic with my patch, even after the revert
>>> dwc3_get_extcon() will be called as a part of a probing codepath,
>> But it's not true as proved by the experiment. So with your patch it doesn't
>> work anymore, so the logic _is_ changed.
>>
> I think you are jumping the gun here. We know that the patch breaks
> USB host functionality on Merrifield. We know that "Seemingly tusb1210
> is not probed". Do we know that dwc3.ko (I think that'd be the
> driver's name) is not probed? Did Ferry share that info with you in
> some other thread? I don't deny it is possible, but I don't think this
> is really clear at this moment to say definitively.
I am not sure. I have dwc3 builtin. And intel_soc_pmic_mrfld and
extcon-intel-mrfld as a module.
But with the USB host broken this returns nothing:
root@yuna:~# journalctl -k -b -0 | grep -i dwc
While with the 2 reverts (and host working):
root@yuna:~# journalctl -k -b -1 | grep -i dwc
Sep 22 22:57:38 yuna kernel: tusb1210 dwc3.0.auto.ulpi: GPIO lookup for
consumer reset
...
Sep 22 22:57:38 yuna kernel: debugfs: Directory 'dwc3.0.auto' with
parent 'ulpi' already present!
...
Sep 22 22:57:39 yuna kernel: tusb1210 dwc3.0.auto.ulpi: error -110
writing val 0x41 to reg 0x80
Like I mentioned before, when host works I get warnings and errors on
the console as well as in the logs.
I also get this one, but believe that is related to another problem,
something in hub.c. Which happens when the host works as a hub is plugin
there.
Sep 22 22:57:39 yuna kernel: DMA-API: dwc3 dwc3.0.auto: cacheline
tracking EEXIST, overlapping mappings aren't supported
>>> so
>>> if the a missing driver is causing a probe deferral it should still be
>>> happening, unless I missed something.
>> The merge fix removes deferred probe by some reason.
>>
>>>>> Does tracing the "mrfld_bcove_pwrsrc" driver (the
>>>>> excton provider in this case AFIACT) show anything interesting?
>>>> I believe there is nothing interesting.
>> --
>> With Best Regards,
>> Andy Shevchenko
>>
>>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4] usb: dwc3: Don't switch OTG -> peripheral if extcon is present
2022-09-23 18:23 ` Andrey Smirnov
2022-09-23 18:35 ` Sven Peter
2022-09-23 18:54 ` Andy Shevchenko
@ 2022-09-23 20:10 ` Ferry Toth
2022-09-24 21:29 ` Ferry Toth
3 siblings, 0 replies; 26+ messages in thread
From: Ferry Toth @ 2022-09-23 20:10 UTC (permalink / raw)
To: Andrey Smirnov, Andy Shevchenko
Cc: Greg Kroah-Hartman, Felipe Balbi, Thinh Nguyen, linux-usb,
linux-kernel, Thinh Nguyen, Sven Peter
Hi
Op 23-09-2022 om 20:23 schreef Andrey Smirnov:
> On Fri, Sep 23, 2022 at 9:42 AM Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
>>
>> On Thu, Sep 22, 2022 at 04:32:55PM -0700, Andrey Smirnov wrote:
>>> On Thu, Sep 22, 2022 at 3:23 AM Ferry Toth <fntoth@gmail.com> wrote:
>>>> On 22-09-2022 12:08, Andy Shevchenko wrote:
>>>> On Sun, Apr 03, 2022 at 09:49:07AM -0700, Andrey Smirnov wrote:
>>
>> FYI: For now I sent a revert, but if we got a solution quicker we always
>> can choose the course of actions.
>>
>
> I think we have another problem. This patch happened in parallel to mine
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc6&id=ab7aa2866d295438dc60522f85c5421c6b4f1507
>
> so my changes didn't have that fix in mind and I think your revert
> will not preserve that fix. Can you update your revert to take care of
> that too, please?
>
> I'm really confused how the above commit could be followed up by:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/usb/dwc3/drd.c?h=v6.0-rc6&id=0f01017191384e3962fa31520a9fd9846c3d352f
>
> the diffs in dwc3_drd_init seem contradictory
>
>>>> If the extcon device exists, get the mode from the extcon device. If
>>>> the controller is DRD and the driver is unable to determine the mode,
>>>> only then default the dr_mode to USB_DR_MODE_PERIPHERAL.
>>>>
>>>> According to Ferry (Cc'ed) this broke Intel Merrifield platform. Ferry, can you
>>>> share bisect log?
>>>>
>>>> I can but not right now. But what I did was bisect between 5.18.0 (good) and 5.19.0 (bad) then when I got near the culprit (~20 remaining) based on the commit message I tried 0f01017191384e3962fa31520a9fd9846c3d352f "usb: dwc3: Don't switch OTG -> peripheral if extcon is present" (bad) and commit before that (good).
>>>>
>>>> The effect of the patch is that on Merrifield (I tested with Intel Edison Arduino board which has a HW switch to select between host and device mode) device mode works but in host mode USB is completely not working.
>>>>
>>>> Currently on host mode - when working - superfluous error messages from tusb1210 appear. When host mode is not working there are no tusb1210 messages in the logs / on the console at all. Seemingly tusb1210 is not probed, which points in the direction of a relation to extcon.
>>>>
>>>> Taking into account the late cycle, I would like to revert the change. And
>>>> Ferry and I would help to test any other (non-regressive) approach).
>>>>
>>>> I have not yet tested if a simple revert fixes the problem but will tonight.
>>>>
>>>>
>>>> I would be happy to test other approaches too.
>>>
>>>
>>> It's a bit hard for me to suggest an alternative approach without
>>> knowing how things are breaking in this case. I'd love to order one of
>>> those boards to repro and fix this on my end, but it looks like this
>>> HW is EOLed and out of stock in most places. If you guys know how to
>>> get my hands on those boards I'm all ears.
>>
>> There are still some second hand Intel Edison boards flying around
>> (but maybe cost a bit more than expected) and there are also
>> Dell Venue 7 3740 tablets based on the same platform/SoC. The latter
>> option though requires more actions in order something to be boot
>> there.
>>
>
> OK, I'll check e-bay just in case.
I see one Edison + Arduino board on eBay $99.99
>> In any case, it's probably quicker to ask Ferry or me for testing.
>> (Although currently I have no access to the board to test OTG, it's
>> remote device which I can only power on and off and it has always
>> be in host mode.)
>>
>>> Barring that, Ferry can you dig more into this failure? E.g. is it this hunk
>>>
>>> @@ -85,7 +86,7 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
>>> * mode. If the controller supports DRD but the dr_mode is not
>>> * specified or set to OTG, then set the mode to peripheral.
>>> */
>>> - if (mode == USB_DR_MODE_OTG &&
>>> + if (mode == USB_DR_MODE_OTG && !dwc->edev &&
>>> (!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) ||
>>> !device_property_read_bool(dwc->dev, "usb-role-switch")) &&
>>> !DWC3_VER_IS_PRIOR(DWC3, 330A))
>>> @@ -1632,6 +1633,51 @@ static void dwc3_check_params(struct dwc3 *dwc)
>>> }
>>> }
>>>
>>> that's problematic or moving
>>
>> I think you wanted to revert only this line and test?
>
> Yes.
>
>>
>>> static int dwc3_probe(struct platform_device *pdev)
>>> {
>>> struct device *dev = &pdev->dev;
>>> @@ -1744,6 +1790,13 @@ static int dwc3_probe(struct platform_device *pdev)
>>> goto err2;
>>> }
>>>
>>> + dwc->edev = dwc3_get_extcon(dwc);
>>> + if (IS_ERR(dwc->edev)) {
>>> + ret = PTR_ERR(dwc->edev);
>>> + dev_err_probe(dwc->dev, ret, "failed to get extcon\n");
>>> + goto err3;
>>> + }
>>> +
>>> ret = dwc3_get_dr_mode(dwc);
>>> if (ret)
>>> goto err3;
>>>
>>> to happen earlier?
>>
>> It is not always possible to have an extcon driver available, that's why in
>> some cases the probe of it defers. I dunno how your patch supposed to work
>> in that case.
>
> I'm not sure I understand what you mean. AFAIU the logic is that if
> the platform specifies the presence of extcon either via DT or, like
> Merrifield, via and explicit "linux,extcon-name" device property in
> the code then extcon is a mandatory component of the DRD stack and the
> driver is expected to be present for the whole thing to work. I don't
> think I really changed that logic with my patch, even after the revert
> dwc3_get_extcon() will be called as a part of a probing codepath, so
> if the a missing driver is causing a probe deferral it should still be
> happening, unless I missed something.
>
>>
>>> Does tracing the "mrfld_bcove_pwrsrc" driver (the
>>> excton provider in this case AFIACT) show anything interesting?
>>
>> I believe there is nothing interesting.
>>
>> --
>> With Best Regards,
>> Andy Shevchenko
>>
>>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4] usb: dwc3: Don't switch OTG -> peripheral if extcon is present
2022-09-23 18:23 ` Andrey Smirnov
` (2 preceding siblings ...)
2022-09-23 20:10 ` Ferry Toth
@ 2022-09-24 21:29 ` Ferry Toth
2022-09-25 19:21 ` Ferry Toth
3 siblings, 1 reply; 26+ messages in thread
From: Ferry Toth @ 2022-09-24 21:29 UTC (permalink / raw)
To: Andrey Smirnov, Andy Shevchenko
Cc: Greg Kroah-Hartman, Felipe Balbi, Thinh Nguyen, linux-usb,
linux-kernel, Thinh Nguyen, Sven Peter
Hi,
One more test
Op 23-09-2022 om 20:23 schreef Andrey Smirnov:
> On Fri, Sep 23, 2022 at 9:42 AM Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
>> On Thu, Sep 22, 2022 at 04:32:55PM -0700, Andrey Smirnov wrote:
>>> On Thu, Sep 22, 2022 at 3:23 AM Ferry Toth <fntoth@gmail.com> wrote:
>>>> On 22-09-2022 12:08, Andy Shevchenko wrote:
>>>> On Sun, Apr 03, 2022 at 09:49:07AM -0700, Andrey Smirnov wrote:
>> FYI: For now I sent a revert, but if we got a solution quicker we always
>> can choose the course of actions.
>>
> I think we have another problem. This patch happened in parallel to mine
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc6&id=ab7aa2866d295438dc60522f85c5421c6b4f1507
>
> so my changes didn't have that fix in mind and I think your revert
> will not preserve that fix. Can you update your revert to take care of
> that too, please?
>
> I'm really confused how the above commit could be followed up by:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/usb/dwc3/drd.c?h=v6.0-rc6&id=0f01017191384e3962fa31520a9fd9846c3d352f
>
> the diffs in dwc3_drd_init seem contradictory
>
>>>> If the extcon device exists, get the mode from the extcon device. If
>>>> the controller is DRD and the driver is unable to determine the mode,
>>>> only then default the dr_mode to USB_DR_MODE_PERIPHERAL.
>>>>
>>>> According to Ferry (Cc'ed) this broke Intel Merrifield platform. Ferry, can you
>>>> share bisect log?
>>>>
>>>> I can but not right now. But what I did was bisect between 5.18.0 (good) and 5.19.0 (bad) then when I got near the culprit (~20 remaining) based on the commit message I tried 0f01017191384e3962fa31520a9fd9846c3d352f "usb: dwc3: Don't switch OTG -> peripheral if extcon is present" (bad) and commit before that (good).
>>>>
>>>> The effect of the patch is that on Merrifield (I tested with Intel Edison Arduino board which has a HW switch to select between host and device mode) device mode works but in host mode USB is completely not working.
>>>>
>>>> Currently on host mode - when working - superfluous error messages from tusb1210 appear. When host mode is not working there are no tusb1210 messages in the logs / on the console at all. Seemingly tusb1210 is not probed, which points in the direction of a relation to extcon.
>>>>
>>>> Taking into account the late cycle, I would like to revert the change. And
>>>> Ferry and I would help to test any other (non-regressive) approach).
>>>>
>>>> I have not yet tested if a simple revert fixes the problem but will tonight.
>>>>
>>>>
>>>> I would be happy to test other approaches too.
>>>
>>> It's a bit hard for me to suggest an alternative approach without
>>> knowing how things are breaking in this case. I'd love to order one of
>>> those boards to repro and fix this on my end, but it looks like this
>>> HW is EOLed and out of stock in most places. If you guys know how to
>>> get my hands on those boards I'm all ears.
>> There are still some second hand Intel Edison boards flying around
>> (but maybe cost a bit more than expected) and there are also
>> Dell Venue 7 3740 tablets based on the same platform/SoC. The latter
>> option though requires more actions in order something to be boot
>> there.
>>
> OK, I'll check e-bay just in case.
>
>> In any case, it's probably quicker to ask Ferry or me for testing.
>> (Although currently I have no access to the board to test OTG, it's
>> remote device which I can only power on and off and it has always
>> be in host mode.)
>>
>>> Barring that, Ferry can you dig more into this failure? E.g. is it this hunk
>>>
>>> @@ -85,7 +86,7 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
>>> * mode. If the controller supports DRD but the dr_mode is not
>>> * specified or set to OTG, then set the mode to peripheral.
>>> */
>>> - if (mode == USB_DR_MODE_OTG &&
>>> + if (mode == USB_DR_MODE_OTG && !dwc->edev &&
>>> (!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) ||
>>> !device_property_read_bool(dwc->dev, "usb-role-switch")) &&
>>> !DWC3_VER_IS_PRIOR(DWC3, 330A))
>>> @@ -1632,6 +1633,51 @@ static void dwc3_check_params(struct dwc3 *dwc)
>>> }
>>> }
>>>
>>> that's problematic or moving
>> I think you wanted to revert only this line and test?
> Yes.
>
>>> static int dwc3_probe(struct platform_device *pdev)
>>> {
>>> struct device *dev = &pdev->dev;
>>> @@ -1744,6 +1790,13 @@ static int dwc3_probe(struct platform_device *pdev)
>>> goto err2;
>>> }
>>>
>>> + dwc->edev = dwc3_get_extcon(dwc);
>>> + if (IS_ERR(dwc->edev)) {
>>> + ret = PTR_ERR(dwc->edev);
>>> + dev_err_probe(dwc->dev, ret, "failed to get extcon\n");
>>> + goto err3;
>>> + }
>>> +
>>> ret = dwc3_get_dr_mode(dwc);
>>> if (ret)
>>> goto err3;
>>>
>>> to happen earlier?
I tried moving dwc3_get_extcon after dwc3_get_dr_mode like so::
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 8c8e32651473..3bf370def546 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1843,6 +1843,10 @@ static int dwc3_probe(struct platform_device *pdev)
goto err2;
}
+ ret = dwc3_get_dr_mode(dwc);
+ if (ret)
+ goto err3;
+
dwc->edev = dwc3_get_extcon(dwc);
if (IS_ERR(dwc->edev)) {
ret = PTR_ERR(dwc->edev);
@@ -1850,10 +1854,6 @@ static int dwc3_probe(struct platform_device *pdev)
goto err3;
}
- ret = dwc3_get_dr_mode(dwc);
- if (ret)
- goto err3;
-
ret = dwc3_alloc_scratch_buffers(dwc);
if (ret)
goto err3;
--
host mode still does not work (no change visible).
>> It is not always possible to have an extcon driver available, that's why in
>> some cases the probe of it defers. I dunno how your patch supposed to work
>> in that case.
> I'm not sure I understand what you mean. AFAIU the logic is that if
> the platform specifies the presence of extcon either via DT or, like
> Merrifield, via and explicit "linux,extcon-name" device property in
> the code then extcon is a mandatory component of the DRD stack and the
> driver is expected to be present for the whole thing to work. I don't
> think I really changed that logic with my patch, even after the revert
> dwc3_get_extcon() will be called as a part of a probing codepath, so
> if the a missing driver is causing a probe deferral it should still be
> happening, unless I missed something.
>
>>> Does tracing the "mrfld_bcove_pwrsrc" driver (the
>>> excton provider in this case AFIACT) show anything interesting?
>> I believe there is nothing interesting.
>>
>> --
>> With Best Regards,
>> Andy Shevchenko
>>
>>
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH v4] usb: dwc3: Don't switch OTG -> peripheral if extcon is present
2022-09-24 21:29 ` Ferry Toth
@ 2022-09-25 19:21 ` Ferry Toth
2022-09-26 5:43 ` Andrey Smirnov
2022-09-26 10:45 ` Sven Peter
0 siblings, 2 replies; 26+ messages in thread
From: Ferry Toth @ 2022-09-25 19:21 UTC (permalink / raw)
To: Andrey Smirnov, Andy Shevchenko
Cc: Greg Kroah-Hartman, Felipe Balbi, Thinh Nguyen, linux-usb,
linux-kernel, Thinh Nguyen, Sven Peter
Hi,
Promising results below.
Op 24-09-2022 om 23:29 schreef Ferry Toth:
> Hi,
>
> One more test
>
> Op 23-09-2022 om 20:23 schreef Andrey Smirnov:
>> On Fri, Sep 23, 2022 at 9:42 AM Andy Shevchenko
>> <andriy.shevchenko@intel.com> wrote:
>>> On Thu, Sep 22, 2022 at 04:32:55PM -0700, Andrey Smirnov wrote:
>>>> On Thu, Sep 22, 2022 at 3:23 AM Ferry Toth <fntoth@gmail.com> wrote:
>>>>> On 22-09-2022 12:08, Andy Shevchenko wrote:
>>>>> On Sun, Apr 03, 2022 at 09:49:07AM -0700, Andrey Smirnov wrote:
>>> FYI: For now I sent a revert, but if we got a solution quicker we
>>> always
>>> can choose the course of actions.
>>>
>> I think we have another problem. This patch happened in parallel to mine
>>
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc6&id=ab7aa2866d295438dc60522f85c5421c6b4f1507
>>
>>
>> so my changes didn't have that fix in mind and I think your revert
>> will not preserve that fix. Can you update your revert to take care of
>> that too, please?
>>
>> I'm really confused how the above commit could be followed up by:
>>
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/usb/dwc3/drd.c?h=v6.0-rc6&id=0f01017191384e3962fa31520a9fd9846c3d352f
>>
>>
>> the diffs in dwc3_drd_init seem contradictory
>>
>>>>> If the extcon device exists, get the mode from the extcon device. If
>>>>> the controller is DRD and the driver is unable to determine the mode,
>>>>> only then default the dr_mode to USB_DR_MODE_PERIPHERAL.
>>>>>
>>>>> According to Ferry (Cc'ed) this broke Intel Merrifield platform.
>>>>> Ferry, can you
>>>>> share bisect log?
>>>>>
>>>>> I can but not right now. But what I did was bisect between 5.18.0
>>>>> (good) and 5.19.0 (bad) then when I got near the culprit (~20
>>>>> remaining) based on the commit message I tried
>>>>> 0f01017191384e3962fa31520a9fd9846c3d352f "usb: dwc3: Don't switch
>>>>> OTG -> peripheral if extcon is present" (bad) and commit before
>>>>> that (good).
>>>>>
>>>>> The effect of the patch is that on Merrifield (I tested with Intel
>>>>> Edison Arduino board which has a HW switch to select between host
>>>>> and device mode) device mode works but in host mode USB is
>>>>> completely not working.
>>>>>
>>>>> Currently on host mode - when working - superfluous error messages
>>>>> from tusb1210 appear. When host mode is not working there are no
>>>>> tusb1210 messages in the logs / on the console at all. Seemingly
>>>>> tusb1210 is not probed, which points in the direction of a
>>>>> relation to extcon.
>>>>>
>>>>> Taking into account the late cycle, I would like to revert the
>>>>> change. And
>>>>> Ferry and I would help to test any other (non-regressive) approach).
>>>>>
>>>>> I have not yet tested if a simple revert fixes the problem but
>>>>> will tonight.
>>>>>
>>>>>
>>>>> I would be happy to test other approaches too.
>>>>
>>>> It's a bit hard for me to suggest an alternative approach without
>>>> knowing how things are breaking in this case. I'd love to order one of
>>>> those boards to repro and fix this on my end, but it looks like this
>>>> HW is EOLed and out of stock in most places. If you guys know how to
>>>> get my hands on those boards I'm all ears.
>>> There are still some second hand Intel Edison boards flying around
>>> (but maybe cost a bit more than expected) and there are also
>>> Dell Venue 7 3740 tablets based on the same platform/SoC. The latter
>>> option though requires more actions in order something to be boot
>>> there.
>>>
>> OK, I'll check e-bay just in case.
>>
>>> In any case, it's probably quicker to ask Ferry or me for testing.
>>> (Although currently I have no access to the board to test OTG, it's
>>> remote device which I can only power on and off and it has always
>>> be in host mode.)
>>>
>>>> Barring that, Ferry can you dig more into this failure? E.g. is it
>>>> this hunk
>>>>
>>>> @@ -85,7 +86,7 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
>>>> * mode. If the controller supports DRD but the
>>>> dr_mode is not
>>>> * specified or set to OTG, then set the mode to
>>>> peripheral.
>>>> */
>>>> - if (mode == USB_DR_MODE_OTG &&
>>>> + if (mode == USB_DR_MODE_OTG && !dwc->edev &&
>>>> (!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) ||
>>>> !device_property_read_bool(dwc->dev, "usb-role-switch")) &&
>>>> !DWC3_VER_IS_PRIOR(DWC3, 330A))
>>>> @@ -1632,6 +1633,51 @@ static void dwc3_check_params(struct dwc3 *dwc)
>>>> }
>>>> }
>>>>
>>>> that's problematic or moving
>>> I think you wanted to revert only this line and test?
>> Yes.
>>
>>>> static int dwc3_probe(struct platform_device *pdev)
>>>> {
>>>> struct device *dev = &pdev->dev;
>>>> @@ -1744,6 +1790,13 @@ static int dwc3_probe(struct platform_device
>>>> *pdev)
>>>> goto err2;
>>>> }
>>>>
>>>> + dwc->edev = dwc3_get_extcon(dwc);
>>>> + if (IS_ERR(dwc->edev)) {
>>>> + ret = PTR_ERR(dwc->edev);
>>>> + dev_err_probe(dwc->dev, ret, "failed to get
>>>> extcon\n");
>>>> + goto err3;
>>>> + }
>>>> +
>>>> ret = dwc3_get_dr_mode(dwc);
>>>> if (ret)
>>>> goto err3;
>>>>
>>>> to happen earlier?
>
> I tried moving dwc3_get_extcon after dwc3_get_dr_mode like so::
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 8c8e32651473..3bf370def546 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1843,6 +1843,10 @@ static int dwc3_probe(struct platform_device
> *pdev)
> goto err2;
> }
>
> + ret = dwc3_get_dr_mode(dwc);
> + if (ret)
> + goto err3;
> +
> dwc->edev = dwc3_get_extcon(dwc);
> if (IS_ERR(dwc->edev)) {
> ret = PTR_ERR(dwc->edev);
> @@ -1850,10 +1854,6 @@ static int dwc3_probe(struct platform_device
> *pdev)
> goto err3;
> }
>
> - ret = dwc3_get_dr_mode(dwc);
> - if (ret)
> - goto err3;
> -
> ret = dwc3_alloc_scratch_buffers(dwc);
> if (ret)
> goto err3;
After trying to understand the code a bit, I successfully tested the
following move:
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 8c8e32651473..4a38cff8cb16 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1843,13 +1843,6 @@ static int dwc3_probe(struct platform_device *pdev)
goto err2;
}
- dwc->edev = dwc3_get_extcon(dwc);
- if (IS_ERR(dwc->edev)) {
- ret = PTR_ERR(dwc->edev);
- dev_err_probe(dwc->dev, ret, "failed to get extcon\n");
- goto err3;
- }
-
ret = dwc3_get_dr_mode(dwc);
if (ret)
goto err3;
@@ -1867,6 +1860,13 @@ static int dwc3_probe(struct platform_device *pdev)
dwc3_check_params(dwc);
dwc3_debugfs_init(dwc);
+ dwc->edev = dwc3_get_extcon(dwc);
+ if (IS_ERR(dwc->edev)) {
+ ret = PTR_ERR(dwc->edev);
+ dev_err_probe(dwc->dev, ret, "failed to get extcon\n");
+ goto err5;
+ }
+
ret = dwc3_core_init_mode(dwc);
if (ret)
goto err5;
This moves dwc3_get_extcon() until after dwc3_core_init() but just
before dwc3_core_init_mode(). AFAIU initially dwc3_get_extcon() was
called from within dwc3_core_init_mode() but only for case
USB_DR_MODE_OTG. So with this change order of events is more or less
unchanged.
Due to move I modified goto to err5, not sure if that is correct.
Thoughts? Can we get something like this in quick or should we revert first?
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH v4] usb: dwc3: Don't switch OTG -> peripheral if extcon is present
2022-09-25 19:21 ` Ferry Toth
@ 2022-09-26 5:43 ` Andrey Smirnov
2022-09-26 10:19 ` Andy Shevchenko
2022-09-26 10:45 ` Sven Peter
1 sibling, 1 reply; 26+ messages in thread
From: Andrey Smirnov @ 2022-09-26 5:43 UTC (permalink / raw)
To: Ferry Toth
Cc: Andy Shevchenko, Greg Kroah-Hartman, Felipe Balbi, Thinh Nguyen,
linux-usb, linux-kernel, Thinh Nguyen, Sven Peter
On Sun, Sep 25, 2022 at 12:21 PM Ferry Toth <fntoth@gmail.com> wrote:
>
> Hi,
>
> Promising results below.
>
> Op 24-09-2022 om 23:29 schreef Ferry Toth:
> > Hi,
> >
> > One more test
> >
> > Op 23-09-2022 om 20:23 schreef Andrey Smirnov:
> >> On Fri, Sep 23, 2022 at 9:42 AM Andy Shevchenko
> >> <andriy.shevchenko@intel.com> wrote:
> >>> On Thu, Sep 22, 2022 at 04:32:55PM -0700, Andrey Smirnov wrote:
> >>>> On Thu, Sep 22, 2022 at 3:23 AM Ferry Toth <fntoth@gmail.com> wrote:
> >>>>> On 22-09-2022 12:08, Andy Shevchenko wrote:
> >>>>> On Sun, Apr 03, 2022 at 09:49:07AM -0700, Andrey Smirnov wrote:
> >>> FYI: For now I sent a revert, but if we got a solution quicker we
> >>> always
> >>> can choose the course of actions.
> >>>
> >> I think we have another problem. This patch happened in parallel to mine
> >>
> >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc6&id=ab7aa2866d295438dc60522f85c5421c6b4f1507
> >>
> >>
> >> so my changes didn't have that fix in mind and I think your revert
> >> will not preserve that fix. Can you update your revert to take care of
> >> that too, please?
> >>
> >> I'm really confused how the above commit could be followed up by:
> >>
> >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/usb/dwc3/drd.c?h=v6.0-rc6&id=0f01017191384e3962fa31520a9fd9846c3d352f
> >>
> >>
> >> the diffs in dwc3_drd_init seem contradictory
> >>
> >>>>> If the extcon device exists, get the mode from the extcon device. If
> >>>>> the controller is DRD and the driver is unable to determine the mode,
> >>>>> only then default the dr_mode to USB_DR_MODE_PERIPHERAL.
> >>>>>
> >>>>> According to Ferry (Cc'ed) this broke Intel Merrifield platform.
> >>>>> Ferry, can you
> >>>>> share bisect log?
> >>>>>
> >>>>> I can but not right now. But what I did was bisect between 5.18.0
> >>>>> (good) and 5.19.0 (bad) then when I got near the culprit (~20
> >>>>> remaining) based on the commit message I tried
> >>>>> 0f01017191384e3962fa31520a9fd9846c3d352f "usb: dwc3: Don't switch
> >>>>> OTG -> peripheral if extcon is present" (bad) and commit before
> >>>>> that (good).
> >>>>>
> >>>>> The effect of the patch is that on Merrifield (I tested with Intel
> >>>>> Edison Arduino board which has a HW switch to select between host
> >>>>> and device mode) device mode works but in host mode USB is
> >>>>> completely not working.
> >>>>>
> >>>>> Currently on host mode - when working - superfluous error messages
> >>>>> from tusb1210 appear. When host mode is not working there are no
> >>>>> tusb1210 messages in the logs / on the console at all. Seemingly
> >>>>> tusb1210 is not probed, which points in the direction of a
> >>>>> relation to extcon.
> >>>>>
> >>>>> Taking into account the late cycle, I would like to revert the
> >>>>> change. And
> >>>>> Ferry and I would help to test any other (non-regressive) approach).
> >>>>>
> >>>>> I have not yet tested if a simple revert fixes the problem but
> >>>>> will tonight.
> >>>>>
> >>>>>
> >>>>> I would be happy to test other approaches too.
> >>>>
> >>>> It's a bit hard for me to suggest an alternative approach without
> >>>> knowing how things are breaking in this case. I'd love to order one of
> >>>> those boards to repro and fix this on my end, but it looks like this
> >>>> HW is EOLed and out of stock in most places. If you guys know how to
> >>>> get my hands on those boards I'm all ears.
> >>> There are still some second hand Intel Edison boards flying around
> >>> (but maybe cost a bit more than expected) and there are also
> >>> Dell Venue 7 3740 tablets based on the same platform/SoC. The latter
> >>> option though requires more actions in order something to be boot
> >>> there.
> >>>
> >> OK, I'll check e-bay just in case.
> >>
> >>> In any case, it's probably quicker to ask Ferry or me for testing.
> >>> (Although currently I have no access to the board to test OTG, it's
> >>> remote device which I can only power on and off and it has always
> >>> be in host mode.)
> >>>
> >>>> Barring that, Ferry can you dig more into this failure? E.g. is it
> >>>> this hunk
> >>>>
> >>>> @@ -85,7 +86,7 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
> >>>> * mode. If the controller supports DRD but the
> >>>> dr_mode is not
> >>>> * specified or set to OTG, then set the mode to
> >>>> peripheral.
> >>>> */
> >>>> - if (mode == USB_DR_MODE_OTG &&
> >>>> + if (mode == USB_DR_MODE_OTG && !dwc->edev &&
> >>>> (!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) ||
> >>>> !device_property_read_bool(dwc->dev, "usb-role-switch")) &&
> >>>> !DWC3_VER_IS_PRIOR(DWC3, 330A))
> >>>> @@ -1632,6 +1633,51 @@ static void dwc3_check_params(struct dwc3 *dwc)
> >>>> }
> >>>> }
> >>>>
> >>>> that's problematic or moving
> >>> I think you wanted to revert only this line and test?
> >> Yes.
> >>
> >>>> static int dwc3_probe(struct platform_device *pdev)
> >>>> {
> >>>> struct device *dev = &pdev->dev;
> >>>> @@ -1744,6 +1790,13 @@ static int dwc3_probe(struct platform_device
> >>>> *pdev)
> >>>> goto err2;
> >>>> }
> >>>>
> >>>> + dwc->edev = dwc3_get_extcon(dwc);
> >>>> + if (IS_ERR(dwc->edev)) {
> >>>> + ret = PTR_ERR(dwc->edev);
> >>>> + dev_err_probe(dwc->dev, ret, "failed to get
> >>>> extcon\n");
> >>>> + goto err3;
> >>>> + }
> >>>> +
> >>>> ret = dwc3_get_dr_mode(dwc);
> >>>> if (ret)
> >>>> goto err3;
> >>>>
> >>>> to happen earlier?
> >
> > I tried moving dwc3_get_extcon after dwc3_get_dr_mode like so::
> >
> > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> > index 8c8e32651473..3bf370def546 100644
> > --- a/drivers/usb/dwc3/core.c
> > +++ b/drivers/usb/dwc3/core.c
> > @@ -1843,6 +1843,10 @@ static int dwc3_probe(struct platform_device
> > *pdev)
> > goto err2;
> > }
> >
> > + ret = dwc3_get_dr_mode(dwc);
> > + if (ret)
> > + goto err3;
> > +
> > dwc->edev = dwc3_get_extcon(dwc);
> > if (IS_ERR(dwc->edev)) {
> > ret = PTR_ERR(dwc->edev);
> > @@ -1850,10 +1854,6 @@ static int dwc3_probe(struct platform_device
> > *pdev)
> > goto err3;
> > }
> >
> > - ret = dwc3_get_dr_mode(dwc);
> > - if (ret)
> > - goto err3;
> > -
> > ret = dwc3_alloc_scratch_buffers(dwc);
> > if (ret)
> > goto err3;
>
> After trying to understand the code a bit, I successfully tested the
> following move:
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 8c8e32651473..4a38cff8cb16 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1843,13 +1843,6 @@ static int dwc3_probe(struct platform_device *pdev)
> goto err2;
> }
>
> - dwc->edev = dwc3_get_extcon(dwc);
> - if (IS_ERR(dwc->edev)) {
> - ret = PTR_ERR(dwc->edev);
> - dev_err_probe(dwc->dev, ret, "failed to get extcon\n");
> - goto err3;
> - }
> -
> ret = dwc3_get_dr_mode(dwc);
> if (ret)
> goto err3;
> @@ -1867,6 +1860,13 @@ static int dwc3_probe(struct platform_device *pdev)
> dwc3_check_params(dwc);
> dwc3_debugfs_init(dwc);
>
> + dwc->edev = dwc3_get_extcon(dwc);
> + if (IS_ERR(dwc->edev)) {
> + ret = PTR_ERR(dwc->edev);
> + dev_err_probe(dwc->dev, ret, "failed to get extcon\n");
> + goto err5;
> + }
> +
> ret = dwc3_core_init_mode(dwc);
> if (ret)
> goto err5;
>
> This moves dwc3_get_extcon() until after dwc3_core_init() but just
> before dwc3_core_init_mode(). AFAIU initially dwc3_get_extcon() was
> called from within dwc3_core_init_mode() but only for case
> USB_DR_MODE_OTG. So with this change order of events is more or less
> unchanged.
I think we'd want to figure out why the ordering is important if we
want to justify the above fix.
>
> Due to move I modified goto to err5, not sure if that is correct.
>
> Thoughts? Can we get something like this in quick or should we revert first?
>
This will need some extra code to fix the case Sven's patch was fixing
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc6&id=ab7aa2866d295438dc60522f85c5421c6b4f1507
IMHO instead of trying to rush something in it be prudent to revert my
patch _and_ address the fact that above patch was lost during the
merge (Andy's revert needs to be updated)
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4] usb: dwc3: Don't switch OTG -> peripheral if extcon is present
2022-09-26 5:43 ` Andrey Smirnov
@ 2022-09-26 10:19 ` Andy Shevchenko
2022-09-26 18:31 ` Andrey Smirnov
0 siblings, 1 reply; 26+ messages in thread
From: Andy Shevchenko @ 2022-09-26 10:19 UTC (permalink / raw)
To: Andrey Smirnov
Cc: Ferry Toth, Greg Kroah-Hartman, Felipe Balbi, Thinh Nguyen,
linux-usb, linux-kernel, Thinh Nguyen, Sven Peter
On Sun, Sep 25, 2022 at 10:43:07PM -0700, Andrey Smirnov wrote:
> On Sun, Sep 25, 2022 at 12:21 PM Ferry Toth <fntoth@gmail.com> wrote:
...
> I think we'd want to figure out why the ordering is important if we
> want to justify the above fix.
At least we all on the same page (I hope) on justification for reverts.
...
> IMHO instead of trying to rush something in it be prudent to revert my
> patch _and_ address the fact that above patch was lost during the
> merge (Andy's revert needs to be updated)
I'm not an expert in your fixes for DWC3, so please come up with
the solution sooner than later, otherwise I will try to get my
reverts into the final release, because they obviously fix the
regression.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4] usb: dwc3: Don't switch OTG -> peripheral if extcon is present
2022-09-26 10:19 ` Andy Shevchenko
@ 2022-09-26 18:31 ` Andrey Smirnov
2022-09-27 12:21 ` Andy Shevchenko
0 siblings, 1 reply; 26+ messages in thread
From: Andrey Smirnov @ 2022-09-26 18:31 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Ferry Toth, Greg Kroah-Hartman, Felipe Balbi, Thinh Nguyen,
linux-usb, linux-kernel, Thinh Nguyen, Sven Peter
On Mon, Sep 26, 2022 at 3:19 AM Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
>
> On Sun, Sep 25, 2022 at 10:43:07PM -0700, Andrey Smirnov wrote:
> > On Sun, Sep 25, 2022 at 12:21 PM Ferry Toth <fntoth@gmail.com> wrote:
>
> ...
>
> > I think we'd want to figure out why the ordering is important if we
> > want to justify the above fix.
>
> At least we all on the same page (I hope) on justification for reverts.
Yes, there's clearly a regression here (multiple ones, really).
>
> ...
>
> > IMHO instead of trying to rush something in it be prudent to revert my
> > patch _and_ address the fact that above patch was lost during the
> > merge (Andy's revert needs to be updated)
>
> I'm not an expert in your fixes for DWC3, so please come up with
> the solution sooner than later, otherwise I will try to get my
> reverts into the final release, because they obviously fix the
> regression.
You don't need to be an expert here. All that's required is that your
revert get the code to look like it looks in
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc6&id=ab7aa2866d295438dc60522f85c5421c6b4f1507
so the last hunk in your patch instead of looking like:
@@ -538,6 +584,10 @@ int dwc3_drd_init(struct dwc3 *dwc)
{
int ret, irq;
+ dwc->edev = dwc3_get_extcon(dwc);
+ if (IS_ERR(dwc->edev))
+ return PTR_ERR(dwc->edev);
+
if (ROLE_SWITCH &&
device_property_read_bool(dwc->dev, "usb-role-switch"))
return dwc3_setup_role_switch(dwc);
should look like
@@ -538,6 +584,10 @@ int dwc3_drd_init(struct dwc3 *dwc)
{
int ret, irq;
if (ROLE_SWITCH &&
device_property_read_bool(dwc->dev, "usb-role-switch"))
return dwc3_setup_role_switch(dwc);
+ dwc->edev = dwc3_get_extcon(dwc);
+ if (IS_ERR(dwc->edev))
+ return PTR_ERR(dwc->edev);
+
Can you update your series accordingly or do you need me to do that? I
won't have the cycles until the end of the week (Sat).
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4] usb: dwc3: Don't switch OTG -> peripheral if extcon is present
2022-09-26 18:31 ` Andrey Smirnov
@ 2022-09-27 12:21 ` Andy Shevchenko
0 siblings, 0 replies; 26+ messages in thread
From: Andy Shevchenko @ 2022-09-27 12:21 UTC (permalink / raw)
To: Andrey Smirnov
Cc: Ferry Toth, Greg Kroah-Hartman, Felipe Balbi, Thinh Nguyen,
linux-usb, linux-kernel, Thinh Nguyen, Sven Peter
On Mon, Sep 26, 2022 at 11:31:58AM -0700, Andrey Smirnov wrote:
> On Mon, Sep 26, 2022 at 3:19 AM Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
> > On Sun, Sep 25, 2022 at 10:43:07PM -0700, Andrey Smirnov wrote:
> > > On Sun, Sep 25, 2022 at 12:21 PM Ferry Toth <fntoth@gmail.com> wrote:
...
> > > IMHO instead of trying to rush something in it be prudent to revert my
> > > patch _and_ address the fact that above patch was lost during the
> > > merge (Andy's revert needs to be updated)
> >
> > I'm not an expert in your fixes for DWC3, so please come up with
> > the solution sooner than later, otherwise I will try to get my
> > reverts into the final release, because they obviously fix the
> > regression.
>
> You don't need to be an expert here. All that's required is that your
> revert get the code to look like it looks in
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc6&id=ab7aa2866d295438dc60522f85c5421c6b4f1507
>
> so the last hunk in your patch instead of looking like:
>
> @@ -538,6 +584,10 @@ int dwc3_drd_init(struct dwc3 *dwc)
> {
> int ret, irq;
>
> + dwc->edev = dwc3_get_extcon(dwc);
> + if (IS_ERR(dwc->edev))
> + return PTR_ERR(dwc->edev);
> +
> if (ROLE_SWITCH &&
> device_property_read_bool(dwc->dev, "usb-role-switch"))
> return dwc3_setup_role_switch(dwc);
>
> should look like
>
> @@ -538,6 +584,10 @@ int dwc3_drd_init(struct dwc3 *dwc)
> {
> int ret, irq;
>
> if (ROLE_SWITCH &&
> device_property_read_bool(dwc->dev, "usb-role-switch"))
> return dwc3_setup_role_switch(dwc);
>
> + dwc->edev = dwc3_get_extcon(dwc);
> + if (IS_ERR(dwc->edev))
> + return PTR_ERR(dwc->edev);
> +
>
> Can you update your series accordingly or do you need me to do that? I
> won't have the cycles until the end of the week (Sat).
Thanks for elaboration. I will do it (hopefully today).
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4] usb: dwc3: Don't switch OTG -> peripheral if extcon is present
2022-09-25 19:21 ` Ferry Toth
2022-09-26 5:43 ` Andrey Smirnov
@ 2022-09-26 10:45 ` Sven Peter
1 sibling, 0 replies; 26+ messages in thread
From: Sven Peter @ 2022-09-26 10:45 UTC (permalink / raw)
To: Ferry Toth, Andrey Smirnov, Andy Shevchenko
Cc: Greg Kroah-Hartman, Felipe Balbi, Thinh Nguyen, linux-usb,
linux-kernel, Thinh Nguyen
On Sun, Sep 25, 2022, at 21:21, Ferry Toth wrote:
> Hi,
>
> Promising results below.
>
> Op 24-09-2022 om 23:29 schreef Ferry Toth:
>> Hi,
>>
>> One more test
>>
>> Op 23-09-2022 om 20:23 schreef Andrey Smirnov:
>>> On Fri, Sep 23, 2022 at 9:42 AM Andy Shevchenko
>>> <andriy.shevchenko@intel.com> wrote:
>>>> On Thu, Sep 22, 2022 at 04:32:55PM -0700, Andrey Smirnov wrote:
>>>>> On Thu, Sep 22, 2022 at 3:23 AM Ferry Toth <fntoth@gmail.com> wrote:
>>>>>> On 22-09-2022 12:08, Andy Shevchenko wrote:
>>>>>> On Sun, Apr 03, 2022 at 09:49:07AM -0700, Andrey Smirnov wrote:
>>>> FYI: For now I sent a revert, but if we got a solution quicker we
>>>> always
>>>> can choose the course of actions.
>>>>
>>> I think we have another problem. This patch happened in parallel to mine
>>>
>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc6&id=ab7aa2866d295438dc60522f85c5421c6b4f1507
>>>
>>>
>>> so my changes didn't have that fix in mind and I think your revert
>>> will not preserve that fix. Can you update your revert to take care of
>>> that too, please?
>>>
>>> I'm really confused how the above commit could be followed up by:
>>>
>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/usb/dwc3/drd.c?h=v6.0-rc6&id=0f01017191384e3962fa31520a9fd9846c3d352f
>>>
>>>
>>> the diffs in dwc3_drd_init seem contradictory
>>>
>>>>>> If the extcon device exists, get the mode from the extcon device. If
>>>>>> the controller is DRD and the driver is unable to determine the mode,
>>>>>> only then default the dr_mode to USB_DR_MODE_PERIPHERAL.
>>>>>>
>>>>>> According to Ferry (Cc'ed) this broke Intel Merrifield platform.
>>>>>> Ferry, can you
>>>>>> share bisect log?
>>>>>>
>>>>>> I can but not right now. But what I did was bisect between 5.18.0
>>>>>> (good) and 5.19.0 (bad) then when I got near the culprit (~20
>>>>>> remaining) based on the commit message I tried
>>>>>> 0f01017191384e3962fa31520a9fd9846c3d352f "usb: dwc3: Don't switch
>>>>>> OTG -> peripheral if extcon is present" (bad) and commit before
>>>>>> that (good).
>>>>>>
>>>>>> The effect of the patch is that on Merrifield (I tested with Intel
>>>>>> Edison Arduino board which has a HW switch to select between host
>>>>>> and device mode) device mode works but in host mode USB is
>>>>>> completely not working.
>>>>>>
>>>>>> Currently on host mode - when working - superfluous error messages
>>>>>> from tusb1210 appear. When host mode is not working there are no
>>>>>> tusb1210 messages in the logs / on the console at all. Seemingly
>>>>>> tusb1210 is not probed, which points in the direction of a
>>>>>> relation to extcon.
>>>>>>
>>>>>> Taking into account the late cycle, I would like to revert the
>>>>>> change. And
>>>>>> Ferry and I would help to test any other (non-regressive) approach).
>>>>>>
>>>>>> I have not yet tested if a simple revert fixes the problem but
>>>>>> will tonight.
>>>>>>
>>>>>>
>>>>>> I would be happy to test other approaches too.
>>>>>
>>>>> It's a bit hard for me to suggest an alternative approach without
>>>>> knowing how things are breaking in this case. I'd love to order one of
>>>>> those boards to repro and fix this on my end, but it looks like this
>>>>> HW is EOLed and out of stock in most places. If you guys know how to
>>>>> get my hands on those boards I'm all ears.
>>>> There are still some second hand Intel Edison boards flying around
>>>> (but maybe cost a bit more than expected) and there are also
>>>> Dell Venue 7 3740 tablets based on the same platform/SoC. The latter
>>>> option though requires more actions in order something to be boot
>>>> there.
>>>>
>>> OK, I'll check e-bay just in case.
>>>
>>>> In any case, it's probably quicker to ask Ferry or me for testing.
>>>> (Although currently I have no access to the board to test OTG, it's
>>>> remote device which I can only power on and off and it has always
>>>> be in host mode.)
>>>>
>>>>> Barring that, Ferry can you dig more into this failure? E.g. is it
>>>>> this hunk
>>>>>
>>>>> @@ -85,7 +86,7 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
>>>>> * mode. If the controller supports DRD but the
>>>>> dr_mode is not
>>>>> * specified or set to OTG, then set the mode to
>>>>> peripheral.
>>>>> */
>>>>> - if (mode == USB_DR_MODE_OTG &&
>>>>> + if (mode == USB_DR_MODE_OTG && !dwc->edev &&
>>>>> (!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) ||
>>>>> !device_property_read_bool(dwc->dev, "usb-role-switch")) &&
>>>>> !DWC3_VER_IS_PRIOR(DWC3, 330A))
>>>>> @@ -1632,6 +1633,51 @@ static void dwc3_check_params(struct dwc3 *dwc)
>>>>> }
>>>>> }
>>>>>
>>>>> that's problematic or moving
>>>> I think you wanted to revert only this line and test?
>>> Yes.
>>>
>>>>> static int dwc3_probe(struct platform_device *pdev)
>>>>> {
>>>>> struct device *dev = &pdev->dev;
>>>>> @@ -1744,6 +1790,13 @@ static int dwc3_probe(struct platform_device
>>>>> *pdev)
>>>>> goto err2;
>>>>> }
>>>>>
>>>>> + dwc->edev = dwc3_get_extcon(dwc);
>>>>> + if (IS_ERR(dwc->edev)) {
>>>>> + ret = PTR_ERR(dwc->edev);
>>>>> + dev_err_probe(dwc->dev, ret, "failed to get
>>>>> extcon\n");
>>>>> + goto err3;
>>>>> + }
>>>>> +
>>>>> ret = dwc3_get_dr_mode(dwc);
>>>>> if (ret)
>>>>> goto err3;
>>>>>
>>>>> to happen earlier?
>>
>> I tried moving dwc3_get_extcon after dwc3_get_dr_mode like so::
>>
>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>> index 8c8e32651473..3bf370def546 100644
>> --- a/drivers/usb/dwc3/core.c
>> +++ b/drivers/usb/dwc3/core.c
>> @@ -1843,6 +1843,10 @@ static int dwc3_probe(struct platform_device
>> *pdev)
>> goto err2;
>> }
>>
>> + ret = dwc3_get_dr_mode(dwc);
>> + if (ret)
>> + goto err3;
>> +
>> dwc->edev = dwc3_get_extcon(dwc);
>> if (IS_ERR(dwc->edev)) {
>> ret = PTR_ERR(dwc->edev);
>> @@ -1850,10 +1854,6 @@ static int dwc3_probe(struct platform_device
>> *pdev)
>> goto err3;
>> }
>>
>> - ret = dwc3_get_dr_mode(dwc);
>> - if (ret)
>> - goto err3;
>> -
>> ret = dwc3_alloc_scratch_buffers(dwc);
>> if (ret)
>> goto err3;
>
> After trying to understand the code a bit, I successfully tested the
> following move:
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 8c8e32651473..4a38cff8cb16 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1843,13 +1843,6 @@ static int dwc3_probe(struct platform_device *pdev)
> goto err2;
> }
>
> - dwc->edev = dwc3_get_extcon(dwc);
> - if (IS_ERR(dwc->edev)) {
> - ret = PTR_ERR(dwc->edev);
> - dev_err_probe(dwc->dev, ret, "failed to get extcon\n");
> - goto err3;
> - }
> -
> ret = dwc3_get_dr_mode(dwc);
> if (ret)
> goto err3;
> @@ -1867,6 +1860,13 @@ static int dwc3_probe(struct platform_device *pdev)
> dwc3_check_params(dwc);
> dwc3_debugfs_init(dwc);
>
> + dwc->edev = dwc3_get_extcon(dwc);
> + if (IS_ERR(dwc->edev)) {
> + ret = PTR_ERR(dwc->edev);
> + dev_err_probe(dwc->dev, ret, "failed to get extcon\n");
> + goto err5;
> + }
> +
> ret = dwc3_core_init_mode(dwc);
> if (ret)
> goto err5;
>
> This moves dwc3_get_extcon() until after dwc3_core_init() but just
> before dwc3_core_init_mode(). AFAIU initially dwc3_get_extcon() was
> called from within dwc3_core_init_mode() but only for case
> USB_DR_MODE_OTG. So with this change order of events is more or less
> unchanged.
>
> Due to move I modified goto to err5, not sure if that is correct.
err5 is correct there, that failure path starts to clean up what dwc3_core_init did.
>
> Thoughts? Can we get something like this in quick or should we revert first?
I don't know anything about that platform and following this thread is a bit hard
for me since I lack context so this is a total guess: dwc3_core_init brings up the
PHYs and also soft resets the core. Could any of these two things interact with your
extcon and somehow break it?
Sven
^ permalink raw reply [flat|nested] 26+ messages in thread