From: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: tomm.merciai@gmail.com, linux-renesas-soc@vger.kernel.org,
biju.das.jz@bp.renesas.com, "Peter Rosin" <peda@axentia.se>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Vinod Koul" <vkoul@kernel.org>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
"Fabrizio Castro" <fabrizio.castro.jz@renesas.com>,
"Lad Prabhakar" <prabhakar.mahadev-lad.rj@bp.renesas.com>,
"Philipp Zabel" <p.zabel@pengutronix.de>,
"Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>,
"Magnus Damm" <magnus.damm@gmail.com>,
"Sebastian Reichel" <sebastian.reichel@collabora.com>,
"Andi Shyti" <andi.shyti@kernel.org>,
"Jonathan Cameron" <jonathan.cameron@huawei.com>,
"Uwe Kleine-König" <ukleinek@kernel.org>,
"Arnd Bergmann" <arnd@arndb.de>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-phy@lists.infradead.org
Subject: Re: [PATCH v4 11/22] phy: renesas: rcar-gen3-usb2: Use mux-state for phyrst management
Date: Tue, 25 Nov 2025 16:57:14 +0100 [thread overview]
Message-ID: <aSXR2iEAKjxM8VOR@tom-desktop> (raw)
In-Reply-To: <CAMuHMdXBbzTeiQJQWuUnJ_rRD1Zo=1TBOzrv4WbvC7whL1=E9w@mail.gmail.com>
Hi Geert,
Thanks for your review!
On Tue, Nov 25, 2025 at 03:10:22PM +0100, Geert Uytterhoeven wrote:
> Hi Tommaso,
>
> On Fri, 21 Nov 2025 at 16:14, Tommaso Merciai
> <tommaso.merciai.xr@bp.renesas.com> wrote:
> > Add support for selecting the phyrst mux-state using the Linux mux
> > subsystem in the R-Car Gen3 USB2 PHY driver. This ensures correct hardware
> > initialization and integration with systems utilizing the mux-state device
> > tree property.
> >
> > A temporary wrapper for optional muxes is introduced until native support
> > is available in the multiplexer subsystem.
> >
> > Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
>
> Thanks for your patch!
>
> > --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> > +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> > @@ -938,11 +939,27 @@ static int rcar_gen3_phy_usb2_vbus_regulator_register(struct rcar_gen3_chan *cha
> > return rcar_gen3_phy_usb2_vbus_regulator_get_exclusive_enable(channel, enable);
> > }
> >
> > +/* Temporary wrapper until the multiplexer subsystem supports optional muxes */
> > +static inline struct mux_state *
> > +devm_mux_state_get_optional(struct device *dev, const char *mux_name)
> > +{
> > + if (!of_property_present(dev->of_node, "mux-states"))
> > + return NULL;
> > +
> > + return devm_mux_state_get(dev, mux_name);
> > +}
> > +
> > +static void rcar_gen3_phy_mux_state_deselect(void *data)
> > +{
> > + mux_state_deselect(data);
> > +}
> > +
> > static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> > {
> > struct device *dev = &pdev->dev;
> > struct rcar_gen3_chan *channel;
> > struct phy_provider *provider;
> > + struct mux_state *mux_state;
> > int ret = 0, i, irq;
> >
> > if (!dev->of_node) {
> > @@ -1019,6 +1036,23 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> > phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]);
> > }
> >
> > + mux_state = devm_mux_state_get_optional(dev, NULL);
> > + if (IS_ERR(mux_state)) {
> > + if (PTR_ERR(mux_state) == -EPROBE_DEFER)
> > + return PTR_ERR(mux_state);
> > + mux_state = NULL;
>
> No need to set mux_state to NULL, as mux_state is not used below.
>
> However, shouldn't you propagate all errors up?
> If the mux is not present, mux_state should already be NULL,
> i.e. IS_ERR(mux_state) would be false.
>
> > + } else {
> > + ret = mux_state_select(mux_state);
>
> This causes a crash on R-Car Gen3 and RZ/Five, as mux_state_select()
> doesn't handle NULL pointers gracefully yet.
>
> Adding a check like
>
> - } else {
> + } else if (mux_state) {
>
> fixes the issue.
Thank you for checking this!
Ack :)
I will switch to:
mux_state = devm_mux_state_get_optional(dev, NULL);
if (IS_ERR(mux_state)) {
return PTR_ERR(mux_state);
} else if (mux_state) {
ret = mux_state_select(mux_state);
if (ret)
return dev_err_probe(dev, ret, "Failed to select USB mux\n");
ret = devm_add_action_or_reset(dev, rcar_gen3_phy_mux_state_deselect,
mux_state);
if (ret)
return dev_err_probe(dev, ret,
"Failed to register USB mux state deselect\n");
}
In v5.
Kind Regards,
Tommaso
>
> > + if (ret)
> > + return dev_err_probe(dev, ret, "Failed to select USB mux\n");
> > +
> > + ret = devm_add_action_or_reset(dev, rcar_gen3_phy_mux_state_deselect,
> > + mux_state);
> > + if (ret)
> > + return dev_err_probe(dev, ret,
> > + "Failed to register USB mux state deselect\n");
> > + }
> > +
> > if (channel->phy_data->no_adp_ctrl && channel->is_otg_channel) {
> > ret = rcar_gen3_phy_usb2_vbus_regulator_register(channel);
> > if (ret)
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
>
next prev parent reply other threads:[~2025-11-25 15:57 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 01/22] dt-bindings: mux: Remove nodename pattern constraints Tommaso Merciai
2025-11-21 18:24 ` Conor Dooley
2025-11-24 8:57 ` Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 02/22] phy: renesas: rcar-gen3-usb2: Use devm_pm_runtime_enable() Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 03/22] phy: renesas: rcar-gen3-usb2: Factor out VBUS control logic Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 04/22] reset: rzv2h-usb2phy: Keep PHY clock enabled for entire device lifetime Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 05/22] dt-bindings: reset: renesas,rzv2h-usb2phy: Add '#mux-state-cells' property Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 06/22] mux: Add driver for Renesas RZ/V2H USB VBUS_SEL mux Tommaso Merciai
2025-11-27 2:28 ` Jian Hui Lee
2025-11-27 9:07 ` Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 07/22] reset: rzv2h-usb2phy: Add support for VBUS mux controller registration Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 08/22] dt-bindings: phy: renesas,usb2-phy: Document USB VBUS regulator Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 09/22] dt-bindings: phy: renesas,usb2-phy: Document mux-states property Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 10/22] phy: renesas: rcar-gen3-usb2: Add regulator for OTG VBUS control Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 11/22] phy: renesas: rcar-gen3-usb2: Use mux-state for phyrst management Tommaso Merciai
2025-11-25 14:10 ` Geert Uytterhoeven
2025-11-25 15:57 ` Tommaso Merciai [this message]
2025-11-26 7:43 ` Geert Uytterhoeven
2025-11-21 15:12 ` [PATCH v4 12/22] dt-bindings: usb: renesas,usbhs: Add RZ/G3E SoC support Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 13/22] dt-bindings: phy: renesas,usb2-phy: Document RZ/G3E SoC Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 14/22] dt-bindings: reset: Document RZ/G3E USB2PHY reset Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 15/22] arm64: dts: renesas: r9a09g057: Add USB2.0 VBUS_SEL mux-controller support Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 16/22] arm64: dts: renesas: r9a09g056: " Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 17/22] arm64: dts: renesas: r9a09g056: Add USB2.0 PHY VBUS internal regulator node Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 18/22] arm64: dts: renesas: r9a09g056n48-rzv2n-evk: Enable USB2 PHY0 VBUS support Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 19/22] arm64: dts: renesas: r9a09g057: Add USB2.0 PHY VBUS internal regulator node Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 20/22] arm64: dts: renesas: r9a09g057h44-rzv2h-evk: Enable USB2 PHY0 VBUS support Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 21/22] arm64: dts: renesas: r9a09g047: Add USB2.0 support Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 22/22] arm64: dts: renesas: r9a09g047e57-smarc: Enable " Tommaso Merciai
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=aSXR2iEAKjxM8VOR@tom-desktop \
--to=tommaso.merciai.xr@bp.renesas.com \
--cc=andi.shyti@kernel.org \
--cc=arnd@arndb.de \
--cc=biju.das.jz@bp.renesas.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=fabrizio.castro.jz@renesas.com \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=jonathan.cameron@huawei.com \
--cc=kishon@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=p.zabel@pengutronix.de \
--cc=peda@axentia.se \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=robh@kernel.org \
--cc=sebastian.reichel@collabora.com \
--cc=tomm.merciai@gmail.com \
--cc=ukleinek@kernel.org \
--cc=vkoul@kernel.org \
--cc=yoshihiro.shimoda.uh@renesas.com \
/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).