From: Rustam Adilov <adilov@disroot.org>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: Vinod Koul <vkoul@kernel.org>,
Neil Armstrong <neil.armstrong@linaro.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Stanley Chang <stanley_chang@realtek.com>,
linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Michael Zavertkin <misha.zavertkin@mail.ru>
Subject: Re: [PATCH v2 4/6] phy: realtek: usb2: introduce reset controller struct
Date: Tue, 31 Mar 2026 16:35:36 +0000 [thread overview]
Message-ID: <fcf97f76c391ca2a4eb0ecd195f63017@disroot.org> (raw)
In-Reply-To: <20260330213955.udqpa77ek7n4arsq@skbuf>
On 2026-03-30 21:39, Vladimir Oltean wrote:
> On Fri, Mar 27, 2026 at 09:06:36PM +0500, Rustam Adilov wrote:
>> In RTL9607C, there is so called "IP Enable Controller" which resemble
>> reset controller with reset lines and is used for various things like
>> USB, PCIE, GMAC and such.
>>
>> Introduce the reset_control struct to this driver to handle deasserting
>> usb2 phy reset line.
>>
>> Make use of the function devm_reset_control_array_get_optional_exclusive()
>> function to get the reset controller and since existing RTD SoCs don't
>> specify the resets we can have a cleaner code.
>>
>> Co-developed-by: Michael Zavertkin <misha.zavertkin@mail.ru>
>> Signed-off-by: Michael Zavertkin <misha.zavertkin@mail.ru>
>> Signed-off-by: Rustam Adilov <adilov@disroot.org>
>> ---
>> drivers/phy/realtek/phy-rtk-usb2.c | 12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>>
>> diff --git a/drivers/phy/realtek/phy-rtk-usb2.c b/drivers/phy/realtek/phy-rtk-usb2.c
>> index e65b8525b88b..070cba1e0e0a 100644
>> --- a/drivers/phy/realtek/phy-rtk-usb2.c
>> +++ b/drivers/phy/realtek/phy-rtk-usb2.c
>> @@ -17,6 +17,7 @@
>> #include <linux/sys_soc.h>
>> #include <linux/mfd/syscon.h>
>> #include <linux/phy/phy.h>
>> +#include <linux/reset.h>
>> #include <linux/usb.h>
>>
>> /* GUSB2PHYACCn register */
>> @@ -130,6 +131,7 @@ struct rtk_phy {
>> struct phy_cfg *phy_cfg;
>> int num_phy;
>> struct phy_parameter *phy_parameter;
>> + struct reset_control *phy_rst;
>>
>> struct dentry *debug_dir;
>> };
>> @@ -602,6 +604,10 @@ static int do_rtk_phy_init(struct rtk_phy *rtk_phy, int index)
>> phy_parameter = &((struct phy_parameter *)rtk_phy->phy_parameter)[index];
>> phy_reg = &phy_parameter->phy_reg;
>>
>> + reset_control_deassert(rtk_phy->phy_rst);
>
> LLM review says:
>
> (less important)
> Can reset_control_deassert() fail here? If there is a hardware communication
> error with the reset controller, should this check the return value and
> propagate the error up instead of proceeding to configure the PHY?
> Additionally, since the exclusive reset line is deasserted here, does this
> code need a corresponding reset_control_assert() in the driver's teardown
> or exit path? Leaving the IP block permanently enabled after shutdown could
> lead to power leaks and prevent proper hardware re-initialization.
It realistically shouldn't fail. But I can add the return error for this.
And no, it doesn't need the reset_control_assert.
>> +
>> + mdelay(5);
>
> (more important)
> This code unnecessarily penalizes existing platforms. If rtk_phy->phy_rst
> is NULL (as on older platforms where the optional reset is not defined), the
> delay still executes.
>
> Also, since PHY initialization callbacks run in a sleepable context, would it
> be better to use a sleep-based delay like usleep_range(5000, 6000) to yield
> the CPU instead of busy-waiting with mdelay(5)?
I can change mdelay to msleep and wrap it around something like if (rtk_phy->phy_rst).
>> +
>> if (phy_cfg->use_default_parameter) {
>> dev_dbg(rtk_phy->dev, "%s phy#%d use default parameter\n",
>> __func__, index);
>> @@ -1069,6 +1075,12 @@ static int rtk_usb2phy_probe(struct platform_device *pdev)
>>
>> rtk_phy->num_phy = phy_cfg->num_phy;
>>
>> + rtk_phy->phy_rst = devm_reset_control_array_get_optional_exclusive(dev);
>> + if (IS_ERR(rtk_phy->phy_rst)) {
>> + dev_err(dev, "usb2 phy resets are not working\n");
>> + return PTR_ERR(rtk_phy->phy_rst);
>> + }
>> +
>
> (still LLM review)
> If the reset controller driver is not yet ready, this will return
> -EPROBE_DEFER and print an error message to the kernel log.
> Should this use dev_err_probe() to silently handle probe deferral while
> correctly logging actual errors?
I can change it to dev_err_probe, no problem with that.
>> ret = parse_phy_data(rtk_phy);
>> if (ret)
>> goto err;
>> --
>> 2.53.0
>>
>>
next prev parent reply other threads:[~2026-03-31 16:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-27 16:06 [PATCH v2 0/6] phy: realtek: usb2: support for RTL9607C USB2 PHY Rustam Adilov
2026-03-27 16:06 ` [PATCH v2 1/6] phy: realtek: usb2: introduce vstatus/new_reg_req variables to driver data Rustam Adilov
2026-03-27 16:06 ` [PATCH v2 2/6] phy: realtek: usb2: introduce read and write functions " Rustam Adilov
2026-03-30 21:19 ` Vladimir Oltean
2026-03-30 21:32 ` Vladimir Oltean
2026-03-31 16:26 ` Rustam Adilov
2026-03-31 16:34 ` Michael Zavertkin
2026-03-31 15:45 ` Rustam Adilov
2026-03-27 16:06 ` [PATCH v2 3/6] dt-bindings: phy: realtek,usb2phy.yaml: extend for resets and RTL9607C support Rustam Adilov
2026-03-27 16:06 ` [PATCH v2 4/6] phy: realtek: usb2: introduce reset controller struct Rustam Adilov
2026-03-30 21:39 ` Vladimir Oltean
2026-03-31 16:35 ` Rustam Adilov [this message]
2026-03-27 16:06 ` [PATCH v2 5/6] phy: realtek: usb2: add support for RTL9607C USB2 PHY Rustam Adilov
2026-03-30 21:50 ` Vladimir Oltean
2026-03-31 16:48 ` Rustam Adilov
2026-03-31 19:36 ` Vladimir Oltean
2026-04-01 14:16 ` Rustam Adilov
2026-03-27 16:06 ` [PATCH v2 6/6] phy: realtek: usb2: Make configs available for MACH_REALTEK_RTL Rustam Adilov
2026-03-30 21:52 ` Vladimir Oltean
2026-03-31 16:48 ` Rustam Adilov
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=fcf97f76c391ca2a4eb0ecd195f63017@disroot.org \
--to=adilov@disroot.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=misha.zavertkin@mail.ru \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=robh@kernel.org \
--cc=stanley_chang@realtek.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox