From: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
To: Mohd Ayaan Anwar <mohd.anwar@oss.qualcomm.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Andrew Davis <afd@ti.com>,
Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Richard Cochran <richardcochran@gmail.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Giuseppe Cavallaro <peppe.cavallaro@st.com>,
Jose Abreu <joabreu@synopsys.com>,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH net-next v2 8/9] net: stmmac: qcom-ethqos: add per-platform NOC clock voting
Date: Wed, 9 Sep 2026 20:47:48 +0200 [thread overview]
Message-ID: <aqGp1D6ySJpTK1fB@lore-desk> (raw)
In-Reply-To: <20260908-shikra_ethernet-v2-8-bbe3389d0652@oss.qualcomm.com>
[-- Attachment #1: Type: text/plain, Size: 5659 bytes --]
> Some SoCs gate the EMAC's path to the System NOC behind dedicated clocks
> that must be enabled before the DMA can reach memory. Add
> ethqos_noc_clk_cfg and the corresponding fields in the driver-data and
> runtime structs so each compatible can declare its own set with per-clock
> rates. The clocks are acquired during probe and enabled/disabled
> alongside the existing link clock in ethqos_clks_config().
>
> No functional change for existing compatibles. This will help us when
> we add support for Shikra.
>
> Signed-off-by: Mohd Ayaan Anwar <mohd.anwar@oss.qualcomm.com>
> ---
> .../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 106 +++++++++++++++++++++
> 1 file changed, 106 insertions(+)
>
[...]
> static u32 rgmii_readl(struct qcom_ethqos *ethqos, unsigned int offset)
> @@ -689,15 +703,51 @@ static int ethqos_mac_finish_serdes(struct net_device *ndev, void *priv,
> static int ethqos_clks_config(void *priv, bool enabled)
> {
> struct qcom_ethqos *ethqos = priv;
> + unsigned int i;
> int ret = 0;
>
> if (enabled) {
> + if (ethqos->num_noc_clks) {
> + ret = dev_pm_opp_set_rate(ðqos->pdev->dev,
> + ethqos->noc_clk_rates[0]);
assuming the first clock is always an OPP device seems a bit fragile to me.
Can we find a way to enforce it? (e.g. have a dedicated clk_bulk_data struct
for it).
> + if (ret) {
> + dev_err(ðqos->pdev->dev,
> + "NOC OPP rate set failed: %d\n", ret);
> + return ret;
> + }
> +
> + for (i = 1; i < ethqos->num_noc_clks; i++) {
> + ret = clk_set_rate(ethqos->noc_clks[i].clk,
> + ethqos->noc_clk_rates[i]);
> + if (ret) {
> + dev_err(ðqos->pdev->dev,
> + "NOC clock rate set failed: %d\n", ret);
> + dev_pm_opp_set_rate(ðqos->pdev->dev, 0);
> + return ret;
> + }
> + }
> + }
> +
> ret = clk_prepare_enable(ethqos->link_clk);
> if (ret) {
> dev_err(ðqos->pdev->dev, "link_clk enable failed\n");
> + if (ethqos->num_noc_clks)
> + dev_pm_opp_set_rate(ðqos->pdev->dev, 0);
> return ret;
> }
>
> + if (ethqos->num_noc_clks) {
> + ret = clk_bulk_prepare_enable(ethqos->num_noc_clks,
> + ethqos->noc_clks);
> + if (ret) {
> + dev_err(ðqos->pdev->dev,
> + "NOC clocks enable failed: %d\n", ret);
> + clk_disable_unprepare(ethqos->link_clk);
> + dev_pm_opp_set_rate(ðqos->pdev->dev, 0);
> + return ret;
> + }
> + }
> +
> /* Enable functional clock to prevent DMA reset to timeout due
> * to lacking PHY clock after the hardware block has been power
> * cycled. The actual configuration will be adjusted once
> @@ -706,7 +756,12 @@ static int ethqos_clks_config(void *priv, bool enabled)
> qcom_ethqos_set_sgmii_loopback(ethqos, true);
> ethqos_set_func_clk_en(ethqos);
> } else {
> + if (ethqos->num_noc_clks)
> + clk_bulk_disable_unprepare(ethqos->num_noc_clks,
> + ethqos->noc_clks);
> clk_disable_unprepare(ethqos->link_clk);
> + if (ethqos->num_noc_clks)
> + dev_pm_opp_set_rate(ðqos->pdev->dev, 0);
> }
>
> return ret;
> @@ -734,6 +789,51 @@ static void ethqos_ptp_clk_freq_config(struct stmmac_priv *priv)
> netdev_dbg(priv->dev, "PTP rate %lu\n", plat_dat->clk_ptp_rate);
> }
>
> +static void qcom_ethqos_noc_opp_cleanup(void *dev)
> +{
> + dev_pm_opp_set_rate(dev, 0);
> +}
> +
> +/* Some SoCs gate NOC access behind dedicated clocks. Acquire them here
> + * so ethqos_clks_config() can enable/disable them at runtime. The OPP
> + * table is used to propagate the required VDD_CX performance state via
> + * dev_pm_opp_set_rate().
> + */
> +static int qcom_ethqos_init_noc_clks(struct qcom_ethqos *ethqos,
> + const struct ethqos_emac_driver_data *data)
> +{
> + struct device *dev = ðqos->pdev->dev;
> + unsigned int i;
> + int ret;
> +
> + if (!data->num_noc_clks)
> + return 0;
> +
> + for (i = 0; i < data->num_noc_clks; i++) {
> + ethqos->noc_clks[i].id = data->noc_clk_cfg[i].id;
> + ethqos->noc_clk_rates[i] = data->noc_clk_cfg[i].rate;
> + }
> + ethqos->num_noc_clks = data->num_noc_clks;
> +
> + ret = devm_clk_bulk_get(dev, ethqos->num_noc_clks, ethqos->noc_clks);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to get NOC clocks\n");
> +
> + ret = devm_pm_opp_set_clkname(dev, data->noc_clk_cfg[0].id);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to set OPP clock name\n");
> +
> + ret = devm_pm_opp_of_add_table(dev);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to add OPP table\n");
> +
> + ret = dev_pm_opp_set_rate(dev, data->noc_clk_cfg[0].rate);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to set initial NOC OPP rate\n");
> +
> + return devm_add_action_or_reset(dev, qcom_ethqos_noc_opp_cleanup, dev);
> +}
> +
> static int qcom_ethqos_probe(struct platform_device *pdev)
> {
> struct device_node *np = pdev->dev.of_node;
> @@ -795,6 +895,12 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
> ethqos->has_emac_ge_3 = data->has_emac_ge_3;
> ethqos->needs_sgmii_loopback = data->needs_sgmii_loopback;
>
> + if (data->num_noc_clks) {
I guess you can drop this check since it is already done in
qcom_ethqos_init_noc_clks(), right?
Regards,
Lorenzo
> + ret = qcom_ethqos_init_noc_clks(ethqos, data);
> + if (ret)
> + return ret;
> + }
> +
> ethqos->link_clk = devm_clk_get(dev, data->link_clk_name ?: "rgmii");
> if (IS_ERR(ethqos->link_clk))
> return dev_err_probe(dev, PTR_ERR(ethqos->link_clk),
>
> --
> 2.34.1
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-09-09 18:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 20:23 [PATCH net-next v2 0/9] net: stmmac: qcom-ethqos: add Shikra EMAC support Mohd Ayaan Anwar
2026-09-07 20:23 ` [PATCH net-next v2 1/9] dt-bindings: net: ti,dp83867: add supply properties Mohd Ayaan Anwar
2026-09-11 11:25 ` netdev-bot+sashiko
2026-09-07 20:23 ` [PATCH net-next v2 2/9] net: phy: dp83867: add regulator supply management Mohd Ayaan Anwar
2026-09-08 15:01 ` Andrew Davis
2026-09-09 17:08 ` Lorenzo Bianconi
2026-09-11 11:25 ` netdev-bot+sashiko
2026-09-07 20:23 ` [PATCH net-next v2 3/9] dt-bindings: net: qcom,ethqos: add qcom,shikra-ethqos compatible Mohd Ayaan Anwar
2026-09-11 11:25 ` netdev-bot+sashiko
2026-09-07 20:23 ` [PATCH net-next v2 4/9] net: stmmac: qcom-ethqos: convert ethqos_rgmii_macro_init() to void Mohd Ayaan Anwar
2026-09-09 17:16 ` Lorenzo Bianconi
2026-09-11 11:25 ` netdev-bot+sashiko
2026-09-07 20:23 ` [PATCH net-next v2 5/9] net: stmmac: qcom-ethqos: fix RGMII_ID mode to use DLL bypass Mohd Ayaan Anwar
2026-09-11 11:25 ` netdev-bot+sashiko
2026-09-07 20:23 ` [PATCH net-next v2 6/9] net: stmmac: qcom-ethqos: warn about legacy RGMII PHY modes Mohd Ayaan Anwar
2026-09-11 11:25 ` netdev-bot+sashiko
2026-09-07 20:23 ` [PATCH net-next v2 7/9] net: stmmac: qcom-ethqos: set initial RGMII link clock to lowest speed Mohd Ayaan Anwar
2026-09-11 11:25 ` netdev-bot+sashiko
2026-09-07 20:23 ` [PATCH net-next v2 8/9] net: stmmac: qcom-ethqos: add per-platform NOC clock voting Mohd Ayaan Anwar
2026-09-09 18:47 ` Lorenzo Bianconi [this message]
2026-09-11 11:25 ` netdev-bot+sashiko
2026-09-07 20:23 ` [PATCH net-next v2 9/9] net: stmmac: qcom-ethqos: add Shikra EMAC support Mohd Ayaan Anwar
2026-09-09 18:55 ` Lorenzo Bianconi
2026-09-11 11:25 ` netdev-bot+sashiko
2026-09-11 14:26 ` Konrad Dybcio
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=aqGp1D6ySJpTK1fB@lore-desk \
--to=lorenzo.bianconi@oss.qualcomm.com \
--cc=afd@ti.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andersson@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=joabreu@synopsys.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=mohd.anwar@oss.qualcomm.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=peppe.cavallaro@st.com \
--cc=richardcochran@gmail.com \
--cc=robh@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
all inboxes | Powered by JetHome®