RE: [PATCH 09/11] phy: renesas: phy-rcar-gen3-usb2: Fix devm action registration for disabled VBUS regulator

From: Biju Das

Date: Mon Jun 15 2026 - 08:34:33 EST


Hi Claudiu,

> -----Original Message-----
> From: Biju Das
> Sent: 15 June 2026 12:51
> Subject: RE: [PATCH 09/11] phy: renesas: phy-rcar-gen3-usb2: Fix devm action registration for disabled
> VBUS regulator
>
> Hi Claudiu,
>
> > -----Original Message-----
> > From: Claudiu Beznea <claudiu.beznea@xxxxxxxxx>
> > Sent: 15 June 2026 12:44
> > Subject: Re: [PATCH 09/11] phy: renesas: phy-rcar-gen3-usb2: Fix devm
> > action registration for disabled VBUS regulator
> >
> >
> >
> > On 6/15/26 13:22, Biju Das wrote:
> > > Hi Claudiu,
> > >
> > >> -----Original Message-----
> > >> From: Claudiu Beznea <claudiu.beznea@xxxxxxxxx>
> > >> Sent: 15 June 2026 10:37
> > >> Subject: Re: [PATCH 09/11] phy: renesas: phy-rcar-gen3-usb2: Fix
> > >> devm action registration for disabled VBUS regulator
> > >>
> > >> Hi, Biju,
> > >>
> > >> On 6/12/26 17:30, Biju wrote:
> > >>> From: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
> > >>>
> > >>> devm_regulator_get_exclusive() initialises the regulator with
> > >>> enable_count = 1, requiring the consumer to disable it before release.
> > >>>
> > >>> Previously, the devm disable action was only registered when the
> > >>> regulator was explicitly enabled, causing the cleanup path to skip
> > >>> decrementing enable_count on device removal when the regulator was
> > >>> left disabled.
> > >>>
> > >>> Fix this by always registering the devm disable action when the
> > >>> regulator is enabled (checked via regulator_is_enabled()),
> > >>> covering both the explicitly-enabled case and the initial state
> > >>> set by devm_regulator_get_exclusive().
> > >>>
> > >>> This fixes WARN_ON enable count during regulator release.
> > >>>
> > >>> Fixes: 24843404efe4 ("phy: renesas: phy-rcar-gen3-usb2: Control
> > >>> VBUS for RZ/G2L SoCs")
> > >>> Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
> > >>
> > >> The approach in this patch don't solve the problem, at least on RZ/G3S. See [1] for logs.
> > >>
> > >> I applied this patch on next-20260610:
> > >>
> > >> git log --oneline -2
> > >> afe09f11d549 (HEAD) phy: renesas: phy-rcar-gen3-usb2: Fix devm
> > >> action registration for disabled VBUS regulator
> > >> abe651837cb3 (tag: next-20260610, linux-next/master) Add linux-next
> > >> specific files for 20260610
> > >>
> > >> [1]
> > >> https://github.com/claudiubeznea/logs/blob/2f1bab20407dfe6031385819
> > >> ff
> > >> eabfc4eac772bd/logs
> > >
> > > I have tested only with RZ/G3L host and I don't see the issue.
> > > How can the issue be reproduced? It could be related to RZ/G3S.
> >
> > It's reproducible with this patch on G2L as well, please see
> > https://github.com/claudiubeznea/logs/blob/0601044903b5ae714592db9770bc4ed31fd8bf84/logs.
> >
> > > I have executed the following tests and don't see any issue.
> > > Can you please try the same tests on RZ/G3S?
> >
> > Try stressing it a bit, e.g. the following command trigger it on both G3S and G2L:
>
> It is nothing related to stress, it is just enable_count issue.
> Usb function increments the enable count of regulator, which it never decrement Leading to
> WARN_ON(enable_count) during unbind.
>
> >
> > cnt=300; while [ $cnt -ge 0 ]; do echo 11c40000.usbphy-ctrl > unbind ;
> > echo 11c40000.usbphy-ctrl > bind ; cnt=$((cnt-1)); done
> >
> > Same command could be executed for other USB drivers.
> >
> > > Is unbind/bind ever worked on RZ?G3S previously?
> >
> > In the same way it works on G2L: functionality is OK, these stack
> > traces are displayed as on any other RZ/G2L based SoCs.
>
> I have identified the issue, it is USB function related.
>
> I am investigating the fix, which will fix for all platforms.

The issue you saw on RZ/G3S is

usbhs_platform_call(priv, hardware_exit, pdev) is called before
usbhsc_power_ctrl(priv, 0);

The former Nullify the PHY pointer and later does not call
phy_power_off(priv->phy) to decrement the regulator.

Cheers,
Biju