public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: bartosz.golaszewski@oss.qualcomm.com
Cc: Simon Horman <horms@kernel.org>,
	magnus.damm@gmail.com, jernej.skrabec@gmail.com, s32@nxp.com,
	krzysztof.kozlowski@oss.qualcomm.com,
	linux-arm-msm@vger.kernel.org, imx@lists.linux.dev,
	festevam@gmail.com, linux-arm-kernel@lists.infradead.org,
	wens@kernel.org, netdev@vger.kernel.org, geert+renesas@glider.be,
	linux-stm32@st-md-mailman.stormreply.com,
	dfustini@tenstorrent.com, andersson@kernel.org,
	khilman@baylibre.com, linux-mips@vger.kernel.org,
	mripard@kernel.org, romain.gantois@bootlin.com, vkoul@kernel.org,
	linux-renesas-soc@vger.kernel.org, jbrunet@baylibre.com,
	kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com,
	sophgo@lists.linux.dev, brgl@kernel.org,
	devicetree@vger.kernel.org, konradybcio@kernel.org,
	prabhakar.mahadev-lad.rj@bp.renesas.com,
	linux-sunxi@lists.linux.dev, conor+dt@kernel.org,
	davem@davemloft.net, jan.petrous@oss.nxp.com,
	shawnguo@kernel.org, linux-amlogic@lists.infradead.org,
	linux-riscv@lists.infradead.org, bartosz.golaszewski@linaro.org,
	peppe.cavallaro@st.com, krzk+dt@kernel.org,
	mohd.anwar@oss.qualcomm.com, konrad.dybcio@oss.qualcomm.com,
	martin.blumenstingl@googlemail.com, andrew+netdev@lunn.ch,
	rrendec@redhat.com, linux-rockchip@lists.infradead.org,
	christophe.roullier@foss.st.com, linux-kernel@vger.kernel.org,
	neil.armstrong@linaro.org, alexandre.torgue@foss.st.com,
	edumazet@google.com, robh@kernel.org
Subject: Re: [PATCH net-next v10 6/6] net: stmmac: qcom-ethqos: add support for sa8255p
Date: Wed, 25 Mar 2026 16:53:35 +0000	[thread overview]
Message-ID: <20260325165335.326630-1-horms@kernel.org> (raw)
In-Reply-To: <20260323-qcom-sa8255p-emac-v10-6-79302b238a16@oss.qualcomm.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: stmmac: qcom-ethqos: add support for sa8255p

Extend the driver to support a new model - sa8255p. Unlike the
previously supported variants, this one's power management is done in
the firmware using SCMI. This is modeled in linux using power domains so
add support for them.

> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
> index f32ff0d9ce51..09ce80b446cb 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c

[ ... ]

> @@ -710,6 +785,45 @@ static int ethqos_mac_finish_serdes(struct net_device *ndev, void *priv,
>  	return ret;
>  }
>
> +static int ethqos_mac_finish_serdes_pd(struct net_device *ndev, void *priv,
> +				       unsigned int mode,
> +				       phy_interface_t interface)
> +{
> +	struct qcom_ethqos *ethqos = priv;
> +	struct device *dev = ethqos->pd.pd_list->pd_devs[ETHQOS_PD_SERDES];
> +	int ret = 0;
> +
> +	qcom_ethqos_set_sgmii_loopback(ethqos, false);
> +
> +	if (interface == PHY_INTERFACE_MODE_SGMII ||
> +	    interface == PHY_INTERFACE_MODE_2500BASEX)
> +		ret = dev_pm_opp_set_level(dev, ethqos->pd.serdes_level);
> +
> +	return ret;
> +}
> +
> +static int qcom_ethqos_pd_serdes_powerup(struct net_device *ndev, void *priv)
> +{
> +	struct qcom_ethqos *ethqos = priv;
> +	struct device *dev = ethqos->pd.pd_list->pd_devs[ETHQOS_PD_SERDES];
> +	int ret;
> +
> +	ret = qcom_ethqos_domain_on(ethqos, ETHQOS_PD_SERDES);
> +	if (ret < 0)
> +		return ret;
> +
> +	return dev_pm_opp_set_level(dev, ethqos->pd.serdes_level);
> +}

Does this leak the PM runtime reference if dev_pm_opp_set_level() fails?

qcom_ethqos_pd_serdes_powerup() calls qcom_ethqos_domain_on() which
acquires a PM runtime reference via pm_runtime_resume_and_get():

qcom_ethqos_pd_serdes_powerup()
  qcom_ethqos_domain_on()
    pm_runtime_resume_and_get(dev)

If the subsequent dev_pm_opp_set_level() fails, the function returns the
error without calling qcom_ethqos_domain_off() to release the reference.

The caller stmmac_legacy_serdes_power_up() in stmmac_main.c does not set
legacy_serdes_is_powered=true on error, so stmmac_legacy_serdes_power_down()
in the cleanup path skips the powerdown call.

In the existing non-PD code path, qcom_ethqos_serdes_powerup() correctly
handles this case by calling phy_exit() when phy_power_on() fails:

drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c:qcom_ethqos_serdes_powerup() {
	ret = phy_init(ethqos->pm.serdes_phy);
	if (ret)
		return ret;

	ret = phy_power_on(ethqos->pm.serdes_phy);
	if (ret) {
		phy_exit(ethqos->pm.serdes_phy);
		return ret;
	}
	...
}

Should qcom_ethqos_pd_serdes_powerup() call qcom_ethqos_domain_off()
before returning the error from dev_pm_opp_set_level()?

> +
> +static void qcom_ethqos_pd_serdes_powerdown(struct net_device *ndev, void *priv)
> +{
> +	struct qcom_ethqos *ethqos = priv;
> +	struct device *dev = ethqos->pd.pd_list->pd_devs[ETHQOS_PD_SERDES];
> +
> +	dev_pm_opp_set_level(dev, 0);
> +	qcom_ethqos_domain_off(ethqos, ETHQOS_PD_SERDES);
> +}

[ ... ]

      reply	other threads:[~2026-03-25 16:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-23 13:20 [PATCH net-next v10 0/6] net: stmmac: qcom-ethqos: add support for SCMI power domains Bartosz Golaszewski
2026-03-23 13:20 ` [PATCH net-next v10 1/6] dt-bindings: net: qcom: document the ethqos device for SCMI-based systems Bartosz Golaszewski
2026-03-23 13:20 ` [PATCH net-next v10 2/6] net: stmmac: qcom-ethqos: use generic device properties Bartosz Golaszewski
2026-03-25 21:14   ` Russell King (Oracle)
2026-03-23 13:20 ` [PATCH net-next v10 3/6] net: stmmac: qcom-ethqos: wrap emac driver data in additional structure Bartosz Golaszewski
2026-03-23 13:20 ` [PATCH net-next v10 4/6] net: stmmac: qcom-ethqos: split power management fields into a separate structure Bartosz Golaszewski
2026-03-23 13:20 ` [PATCH net-next v10 5/6] net: stmmac: qcom-ethqos: split power management context into a separate struct Bartosz Golaszewski
2026-03-23 13:20 ` [PATCH net-next v10 6/6] net: stmmac: qcom-ethqos: add support for sa8255p Bartosz Golaszewski
2026-03-25 16:53   ` Simon Horman [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=20260325165335.326630-1-horms@kernel.org \
    --to=horms@kernel.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andersson@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=brgl@kernel.org \
    --cc=christophe.roullier@foss.st.com \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=dfustini@tenstorrent.com \
    --cc=edumazet@google.com \
    --cc=festevam@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=imx@lists.linux.dev \
    --cc=jan.petrous@oss.nxp.com \
    --cc=jbrunet@baylibre.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=khilman@baylibre.com \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=krzysztof.kozlowski@oss.qualcomm.com \
    --cc=kuba@kernel.org \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=magnus.damm@gmail.com \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=mohd.anwar@oss.qualcomm.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=peppe.cavallaro@st.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=robh@kernel.org \
    --cc=romain.gantois@bootlin.com \
    --cc=rrendec@redhat.com \
    --cc=s32@nxp.com \
    --cc=shawnguo@kernel.org \
    --cc=sophgo@lists.linux.dev \
    --cc=vkoul@kernel.org \
    --cc=wens@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