* [PATCH RTF 1/3] usb: renesas_usbhs: Call clk_put()
2025-02-19 16:12 [PATCH RFT 0/3] usb: renesas_usbhs: Fixes for renesas_usbhs Claudiu
@ 2025-02-19 16:12 ` Claudiu
2025-02-19 16:12 ` [PATCH RTF 2/3] usb: renesas_usbhs: Use devm_usb_get_phy() Claudiu
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Claudiu @ 2025-02-19 16:12 UTC (permalink / raw)
To: gregkh, biju.das.jz, geert+renesas, yoshihiro.shimoda.uh,
laurent.pinchart, phil.edworthy, balbi, kuninori.morimoto.gx
Cc: claudiu.beznea, linux-usb, linux-kernel, linux-renesas-soc,
Claudiu Beznea, stable
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Clocks acquired with of_clk_get() need to be freed with clk_put(). Call
clk_put() on priv->clks[0] on error path.
Fixes: 3df0e240caba ("usb: renesas_usbhs: Add multiple clocks management")
Cc: stable@vger.kernel.org
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/usb/renesas_usbhs/common.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 935fc496fe94..6c7857b66a21 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -312,8 +312,10 @@ static int usbhsc_clk_get(struct device *dev, struct usbhs_priv *priv)
priv->clks[1] = of_clk_get(dev_of_node(dev), 1);
if (PTR_ERR(priv->clks[1]) == -ENOENT)
priv->clks[1] = NULL;
- else if (IS_ERR(priv->clks[1]))
+ else if (IS_ERR(priv->clks[1])) {
+ clk_put(priv->clks[0]);
return PTR_ERR(priv->clks[1]);
+ }
return 0;
}
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH RTF 2/3] usb: renesas_usbhs: Use devm_usb_get_phy()
2025-02-19 16:12 [PATCH RFT 0/3] usb: renesas_usbhs: Fixes for renesas_usbhs Claudiu
2025-02-19 16:12 ` [PATCH RTF 1/3] usb: renesas_usbhs: Call clk_put() Claudiu
@ 2025-02-19 16:12 ` Claudiu
2025-02-19 16:12 ` [PATCH RTF 3/3] usb: renesas_usbhs: Flush the notify_hotplug_work Claudiu
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Claudiu @ 2025-02-19 16:12 UTC (permalink / raw)
To: gregkh, biju.das.jz, geert+renesas, yoshihiro.shimoda.uh,
laurent.pinchart, phil.edworthy, balbi, kuninori.morimoto.gx
Cc: claudiu.beznea, linux-usb, linux-kernel, linux-renesas-soc,
Claudiu Beznea, stable
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
The gpriv->transceiver is retrieved in probe() through usb_get_phy() but
never released. Use devm_usb_get_phy() to handle this scenario.
This issue was identified through code investigation. No issue was found
without this change.
Fixes: b5a2875605ca ("usb: renesas_usbhs: Allow an OTG PHY driver to provide VBUS")
Cc: stable@vger.kernel.org
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/usb/renesas_usbhs/mod_gadget.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
index 105132ae87ac..e8e5723f5412 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -1094,7 +1094,7 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
goto usbhs_mod_gadget_probe_err_gpriv;
}
- gpriv->transceiver = usb_get_phy(USB_PHY_TYPE_UNDEFINED);
+ gpriv->transceiver = devm_usb_get_phy(dev, USB_PHY_TYPE_UNDEFINED);
dev_info(dev, "%stransceiver found\n",
!IS_ERR(gpriv->transceiver) ? "" : "no ");
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH RTF 3/3] usb: renesas_usbhs: Flush the notify_hotplug_work
2025-02-19 16:12 [PATCH RFT 0/3] usb: renesas_usbhs: Fixes for renesas_usbhs Claudiu
2025-02-19 16:12 ` [PATCH RTF 1/3] usb: renesas_usbhs: Call clk_put() Claudiu
2025-02-19 16:12 ` [PATCH RTF 2/3] usb: renesas_usbhs: Use devm_usb_get_phy() Claudiu
@ 2025-02-19 16:12 ` Claudiu
2025-02-19 16:17 ` [PATCH RFT 0/3] usb: renesas_usbhs: Fixes for renesas_usbhs Claudiu Beznea
2025-02-21 2:08 ` Yoshihiro Shimoda
4 siblings, 0 replies; 6+ messages in thread
From: Claudiu @ 2025-02-19 16:12 UTC (permalink / raw)
To: gregkh, biju.das.jz, geert+renesas, yoshihiro.shimoda.uh,
laurent.pinchart, phil.edworthy, balbi, kuninori.morimoto.gx
Cc: claudiu.beznea, linux-usb, linux-kernel, linux-renesas-soc,
Claudiu Beznea, stable
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
When performing continuous unbind/bind operations on the USB drivers
available on the Renesas RZ/G2L SoC, a kernel crash with the message
"Unable to handle kernel NULL pointer dereference at virtual address"
may occur. This issue points to the usbhsc_notify_hotplug() function.
Flush the delayed work to avoid its execution when driver resources are
unavailable.
Fixes: bc57381e6347 ("usb: renesas_usbhs: use delayed_work instead of work_struct")
Cc: stable@vger.kernel.org
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/usb/renesas_usbhs/common.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 6c7857b66a21..4b35ef216125 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -781,6 +781,8 @@ static void usbhs_remove(struct platform_device *pdev)
dev_dbg(&pdev->dev, "usb remove\n");
+ flush_delayed_work(&priv->notify_hotplug_work);
+
/* power off */
if (!usbhs_get_dparam(priv, runtime_pwctrl))
usbhsc_power_ctrl(priv, 0);
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH RFT 0/3] usb: renesas_usbhs: Fixes for renesas_usbhs
2025-02-19 16:12 [PATCH RFT 0/3] usb: renesas_usbhs: Fixes for renesas_usbhs Claudiu
` (2 preceding siblings ...)
2025-02-19 16:12 ` [PATCH RTF 3/3] usb: renesas_usbhs: Flush the notify_hotplug_work Claudiu
@ 2025-02-19 16:17 ` Claudiu Beznea
2025-02-21 2:08 ` Yoshihiro Shimoda
4 siblings, 0 replies; 6+ messages in thread
From: Claudiu Beznea @ 2025-02-19 16:17 UTC (permalink / raw)
To: gregkh, biju.das.jz, geert+renesas, yoshihiro.shimoda.uh,
laurent.pinchart, phil.edworthy, balbi, kuninori.morimoto.gx
Cc: linux-usb, linux-kernel, linux-renesas-soc, Claudiu Beznea
Adding reference to the missing series (see below).
On 19.02.2025 18:12, Claudiu wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>
> Hi,
>
> Series add fixes for the Renesas USBHS driver identified while
> working on the Renesas USB PHY driver (series at [1]).
>
> Series (with [1] on top) was tested on Renesas RZ/G3S with consecutive
> unbind/bind and data transfer tests before/after the unbind/bind.
>
> The unbind/bind was also tested on the devices with the following
> device trees but w/o checking the data transfer (as I only had
> remote access w/o USB devices connected):
> - r8a7742-iwg21d-q7.dts
> - r8a7743-iwg20d-q7.dts
> - r8a7744-iwg20d-q7.dts
> - r8a7745-iwg22d-sodimm.dts
> - r8a77470-iwg23s-sbc.dts
> - r8a774a1-hihope-rzg2m-ex.dts
> - r8a774b1-hihope-rzg2n-ex.dts
> - r8a774e1-hihope-rzg2h-ex.dts
> - r9a07g043u11-smarc.dts
> - r9a07g044c2-smarc.dts
> - r9a07g044l2-smarc.dts
> - r9a07g054l2-smarc.dts
> - r9a07g043f01-smarc.dts
>
> Please give it a try also on your devices with [1] on top as well.
[1]
https://lore.kernel.org/all/20250219160749.1750797-1-claudiu.beznea.uj@bp.renesas.com
>
> Thank you,
> Claudiu Beznea
>
> Claudiu Beznea (3):
> usb: renesas_usbhs: Call clk_put()
> usb: renesas_usbhs: Use devm_usb_get_phy()
> usb: renesas_usbhs: Flush the notify_hotplug_work
>
> drivers/usb/renesas_usbhs/common.c | 6 +++++-
> drivers/usb/renesas_usbhs/mod_gadget.c | 2 +-
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
^ permalink raw reply [flat|nested] 6+ messages in thread* RE: [PATCH RFT 0/3] usb: renesas_usbhs: Fixes for renesas_usbhs
2025-02-19 16:12 [PATCH RFT 0/3] usb: renesas_usbhs: Fixes for renesas_usbhs Claudiu
` (3 preceding siblings ...)
2025-02-19 16:17 ` [PATCH RFT 0/3] usb: renesas_usbhs: Fixes for renesas_usbhs Claudiu Beznea
@ 2025-02-21 2:08 ` Yoshihiro Shimoda
4 siblings, 0 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2025-02-21 2:08 UTC (permalink / raw)
To: Claudiu.Beznea, gregkh, Biju Das, geert+renesas,
laurent.pinchart, phil.edworthy, balbi, Kuninori Morimoto
Cc: Claudiu.Beznea, linux-usb, linux-kernel, linux-renesas-soc,
Claudiu Beznea
Hello Claudiu-san,
> From: Claudiu, Sent: Thursday, February 20, 2025 1:13 AM
>
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>
> Hi,
>
> Series add fixes for the Renesas USBHS driver identified while
> working on the Renesas USB PHY driver (series at [1]).
>
> Series (with [1] on top) was tested on Renesas RZ/G3S with consecutive
> unbind/bind and data transfer tests before/after the unbind/bind.
>
> The unbind/bind was also tested on the devices with the following
> device trees but w/o checking the data transfer (as I only had
> remote access w/o USB devices connected):
> - r8a7742-iwg21d-q7.dts
> - r8a7743-iwg20d-q7.dts
> - r8a7744-iwg20d-q7.dts
> - r8a7745-iwg22d-sodimm.dts
> - r8a77470-iwg23s-sbc.dts
> - r8a774a1-hihope-rzg2m-ex.dts
> - r8a774b1-hihope-rzg2n-ex.dts
> - r8a774e1-hihope-rzg2h-ex.dts
> - r9a07g043u11-smarc.dts
> - r9a07g044c2-smarc.dts
> - r9a07g044l2-smarc.dts
> - r9a07g054l2-smarc.dts
> - r9a07g043f01-smarc.dts
>
> Please give it a try also on your devices with [1] on top as well.
Thank you for the patches!
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
I tested on my environment (r8a77951-salvator-xs.dts) and it worked correctly.
So,
Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Best regards,
Yoshihiro Shimoda
> Thank you,
> Claudiu Beznea
>
> Claudiu Beznea (3):
> usb: renesas_usbhs: Call clk_put()
> usb: renesas_usbhs: Use devm_usb_get_phy()
> usb: renesas_usbhs: Flush the notify_hotplug_work
>
> drivers/usb/renesas_usbhs/common.c | 6 +++++-
> drivers/usb/renesas_usbhs/mod_gadget.c | 2 +-
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> --
> 2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread