From: Aleksei Sviridkin <f@lex.la>
To: andrew@lunn.ch, andrew+netdev@lunn.ch, hkallweit1@gmail.com,
linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org
Cc: ericwouds@gmail.com, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH net-next 5/7] net: phy: air: skip the download when the MD32 is already running
Date: Sun, 6 Sep 2026 17:45:41 +0000 [thread overview]
Message-ID: <20260906174548.4106801-5-f@lex.la> (raw)
In-Reply-To: <cover.1788711797.git.f@lex.la>
The download is unconditional, so a chip whose firmware was loaded by
something else - a bootloader, an earlier bind of the PHY driver, or
an MDIO device serving the chip - is reprogrammed at 144KB per probe.
Read the status register the loader already polls for readiness and
skip the download when it reports ready, only picking up the running
firmware's version. Adopting is reported back distinctly from loading,
because nothing on that path touches FW_CTRL_1: the PHY driver must
leave the MCU restart to .config_init() rather than assume probe
already did it.
The image in RAM now wins over the files on disk. Where the PHY node
carries no reset-gpios nothing clears that RAM on unbind, so writing
new firmware files and rebinding keeps the old image running and
reports its version as the current one. A power cycle, or a reset line
on the PHY node for phy_detach() to assert, brings the reload back.
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
---
drivers/net/phy/air_en8811h.c | 4 ++--
drivers/net/phy/air_phy_lib.c | 26 ++++++++++++++++++++++++++
drivers/net/phy/air_phy_lib.h | 3 +++
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/air_en8811h.c b/drivers/net/phy/air_en8811h.c
index 920cc0ea1f67..786c0b26ae65 100644
--- a/drivers/net/phy/air_en8811h.c
+++ b/drivers/net/phy/air_en8811h.c
@@ -1024,8 +1024,8 @@ static int en8811h_probe(struct phy_device *phydev)
if (ret < 0)
return ret;
- /* mcu has just restarted after firmware load */
- priv->mcu_needs_restart = false;
+ /* Adopted firmware was never restarted here. */
+ priv->mcu_needs_restart = (ret == 1);
/* MDIO_DEVS1/2 empty, so set mmds_present bits here */
phydev->c45_ids.mmds_present |= MDIO_DEVS_PMAPMD | MDIO_DEVS_AN;
diff --git a/drivers/net/phy/air_phy_lib.c b/drivers/net/phy/air_phy_lib.c
index 5b7427e0d977..a5b6b3606bec 100644
--- a/drivers/net/phy/air_phy_lib.c
+++ b/drivers/net/phy/air_phy_lib.c
@@ -410,6 +410,17 @@ static int air_mmd_status_read(struct mdio_device *mdiodev)
return ret;
}
+int air_en8811h_mcu_running(struct mdio_device *mdiodev)
+{
+ int ret = air_mmd_status_read(mdiodev);
+
+ if (ret < 0)
+ return ret;
+
+ return ret == EN8811H_PHY_READY;
+}
+EXPORT_SYMBOL_GPL(air_en8811h_mcu_running);
+
int air_en8811h_wait_mcu_ready(struct mdio_device *mdiodev)
{
int ret, reg_value;
@@ -443,6 +454,21 @@ int air_en8811h_fw_download(struct mdio_device *mdiodev, u32 *fw_version)
struct device *dev = &mdiodev->dev;
int ret;
+ ret = air_en8811h_mcu_running(mdiodev);
+ if (ret < 0)
+ return ret;
+
+ if (ret) {
+ ret = air_mdio_buckpbus_reg_read(mdiodev, EN8811H_FW_VERSION,
+ fw_version);
+ if (ret < 0)
+ return ret;
+
+ dev_info(dev, "MD32 already running, firmware %08x\n",
+ *fw_version);
+ return 1;
+ }
+
ret = request_firmware_direct(&fw1, EN8811H_MD32_DM, dev);
if (ret < 0)
return ret;
diff --git a/drivers/net/phy/air_phy_lib.h b/drivers/net/phy/air_phy_lib.h
index 70c8ba66bd73..226dc9f2eb07 100644
--- a/drivers/net/phy/air_phy_lib.h
+++ b/drivers/net/phy/air_phy_lib.h
@@ -64,7 +64,10 @@ struct firmware;
int air_fw_write_buf(struct mdio_device *mdiodev, u32 address,
const struct firmware *fw);
+/* Returns 1 running, 0 dormant, negative on a failed status read. */
+int air_en8811h_mcu_running(struct mdio_device *mdiodev);
int air_en8811h_wait_mcu_ready(struct mdio_device *mdiodev);
+/* Returns 1 when it adopted firmware that was already running. */
int air_en8811h_fw_download(struct mdio_device *mdiodev, u32 *fw_version);
#endif /* __AIR_PHY_LIB_H */
--
2.53.0
next prev parent reply other threads:[~2026-09-06 17:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 17:45 [RFC PATCH net-next 0/7] net: mdio: an MDIO device driver for the Airoha EN8811H Aleksei Sviridkin
2026-09-06 17:45 ` [RFC PATCH net-next 1/7] dt-bindings: net: add Airoha EN8811H PHY MCU Aleksei Sviridkin
2026-09-06 17:45 ` [RFC PATCH net-next 2/7] net: phy: add mdiodev_lock(), mdiodev_lock_nested() and mdiodev_unlock() Aleksei Sviridkin
2026-09-06 17:45 ` [RFC PATCH net-next 3/7] net: phy: air: type the buckpbus core on the mdio device Aleksei Sviridkin
2026-09-06 17:45 ` [RFC PATCH net-next 4/7] net: phy: air: move the EN8811H firmware download into the library Aleksei Sviridkin
2026-09-06 17:45 ` Aleksei Sviridkin [this message]
2026-09-06 17:45 ` [RFC PATCH net-next 6/7] net: mdio: add Airoha EN8811H MDIO device driver Aleksei Sviridkin
2026-09-06 17:45 ` [RFC PATCH net-next 7/7] net: mdio: en8811h: add the nested bus Aleksei Sviridkin
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=20260906174548.4106801-5-f@lex.la \
--to=f@lex.la \
--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=ericwouds@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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