Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Markus Stockhausen" <markus.stockhausen@gmx.de>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next 3/3] net: mdio: realtek-rtl9300: Support non-default clock frequency
Date: Fri, 04 Sep 2026 12:22:02 +0000	[thread overview]
Message-ID: <20260904122202.9A3CF1F00A3F@smtp.kernel.org> (raw)
In-Reply-To: <20260903122119.2638354-4-markus.stockhausen@gmx.de>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Using an uninitialized `bus->dev` pointer for logging before the MDIO bus is registered, resulting in a '(null)' prefix.
- [Low] The `global_freq` variable is overloaded as both an initialization flag and frequency storage, failing if `clock-frequency` is explicitly set to 0.
--

commit 9b57074cdf8cafdf9765568d20f29655308463cf
Author: Markus Stockhausen <markus.stockhausen@gmx.de>

net: mdio: realtek-rtl9300: Support non-default clock frequency

This commit enhances the realtek-rtl9300 MDIO driver to allow setting the
MDC clock frequency via device tree. For the RTL839x series, which only
supports global frequency selection, the driver configures the global
speed based on the first probed bus and issues warnings for conflicts.

> diff --git a/drivers/net/mdio/mdio-realtek-rtl9300.c b/drivers/net/mdio/mdio-realtek-rtl9300.c
> --- a/drivers/net/mdio/mdio-realtek-rtl9300.c
> +++ b/drivers/net/mdio/mdio-realtek-rtl9300.c
[ ... ]
> @@ -749,6 +766,34 @@ static int otto_emdio_8380_setup_controller(struct otto_emdio_priv *priv)
>  	return regmap_set_bits(priv->regmap, RTL8380_SMI_GLB_CTRL, RTL8380_SMI_PHY_PATCH_DONE);
>  }
>  
> +static int otto_emdio_8390_set_bus_frequency(struct mii_bus *bus, u32 freq)
> +{
> +	u32 val = FIELD_PREP(RTL8390_SMI_FREQ_SEL, min_t(u32, freq / 2500000, 2U));
> +	struct otto_emdio_priv *priv = otto_emdio_bus_to_priv(bus);
> +
> +	if (priv->global_freq) {

[Severity: Low]
Does this logic correctly handle a scenario where the device tree explicitly
sets the clock-frequency to 0?

Since priv->global_freq is used as both an initialization flag and for
storing the frequency, a frequency of 0 would evaluate to false here.
This could bypass the conflict detection for subsequent buses and silently
overwrite the global hardware frequency.

Would a dedicated initialization flag or sentinel value (like -1) be more
robust to handle all integer inputs?

> +		/* With only one global frequency available skip setup for second bus. */
> +		if (freq != priv->global_freq)
> +			dev_warn(&bus->dev, "Only one frequency for all buses supported");

[Severity: Medium]
Will this dev_warn() print a (null) device name prefix?

Looking at otto_emdio_probe_one(), set_bus_frequency() is called before the
bus is registered via devm_of_mdiobus_register():

	err = priv->info->set_bus_frequency(bus, freq);
	if (err)
		return dev_err_probe(...);

	err = devm_of_mdiobus_register(dev, bus, node);

Because dev_set_name() hasn't been called on bus->dev yet, the logger won't
have a valid name to display. Could this be resolved by logging with
bus->parent instead?

> +		return 0;
> +	}
> +	priv->global_freq = freq;
> +
> +	return regmap_update_bits(priv->regmap, RTL8390_SMI_GLB_CTRL, RTL8390_SMI_FREQ_SEL, val);
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260903122119.2638354-1-markus.stockhausen@gmx.de?part=3

      parent reply	other threads:[~2026-09-04 12:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 12:21 [PATCH net-next 0/3] net: mdio: realtek-rtl9300: add bus frequency handling Markus Stockhausen
2026-09-03 12:21 ` [PATCH net-next 1/3] dt-bindings: net: realtek,rtl9301-mdio: Add clock-frequency Markus Stockhausen
2026-09-03 12:30   ` Andrew Lunn
2026-09-04 12:22   ` sashiko-bot
2026-09-03 12:21 ` [PATCH net-next 2/3] net: mdio: realtek-rtl9300: Convert "fwnode" left-overs to "of" Markus Stockhausen
2026-09-03 12:26   ` Andrew Lunn
2026-09-04 12:22   ` sashiko-bot
2026-09-03 12:21 ` [PATCH net-next 3/3] net: mdio: realtek-rtl9300: Support non-default clock frequency Markus Stockhausen
2026-09-03 12:32   ` Andrew Lunn
2026-09-04 12:22   ` sashiko-bot [this message]

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=20260904122202.9A3CF1F00A3F@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=markus.stockhausen@gmx.de \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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