Skip to content

net: stmmac: don't put an absent MDIO reset GPIO - #524

Open
sormy wants to merge 1 commit into
armbian:rk-6.1-rkr5.1from
sormy:net/stmmac-absent-mdio-reset-gpio
Open

net: stmmac: don't put an absent MDIO reset GPIO#524
sormy wants to merge 1 commit into
armbian:rk-6.1-rkr5.1from
sormy:net/stmmac-absent-mdio-reset-gpio

Conversation

@sormy

@sormy sormy commented Aug 15, 2026

Copy link
Copy Markdown

devm_gpiod_get_optional() returns NULL when the property is absent, but both call
sites only test IS_ERR() before devm_gpiod_put(). Putting NULL means
devres_release() finds nothing, returns -ENOENT, and the WARN_ON inside
devm_gpiod_put() fires on every probe:

WARNING: CPU: 1 PID: 1 at drivers/gpio/gpiolib-devres.c:327 devm_gpiod_put+0x34/0x44
 devm_gpiod_put → stmmac_mdio_reset → __mdiobus_register

Only three device trees in this repo set snps,reset, so most Rockchip boards with
an integrated PHY take the NULL path. gpiod_set_value_cansleep() already tolerates
NULL, so only the two puts need guarding.

Verified on an RK3528 board: MDIO registers (stmmac-0:02), end0 comes up, warning
gone.

devm_gpiod_get_optional() returns NULL when the property is absent, and both
call sites only test IS_ERR() before calling devm_gpiod_put(). With no
"snps,reset" in the device tree that puts NULL, devres_release() finds nothing
to release, and WARN_ON fires on every probe:

  WARNING: CPU: 1 PID: 1 at drivers/gpio/gpiolib-devres.c:327 devm_gpiod_put+0x34/0x44
  Call trace:
   devm_gpiod_put+0x34/0x44
   stmmac_mdio_reset+0x110/0x150
   __mdiobus_register+0x228/0x298

Boards whose PHY needs no reset line hit this every boot — the RK3528 TV boxes
use an integrated FEPHY and never set the property.

Signed-off-by: Artem Butusov <art.sormy@gmail.com>
@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b0675efd-759b-4494-accf-ca387b9c0a97

📥 Commits

Reviewing files that changed from the base of the PR and between 5280f9b and a44fa53.

📒 Files selected for processing (1)
  • drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c

Walkthrough

The STMMAC MDIO driver now checks whether the optional reset GPIO descriptor exists before releasing it in stmmac_mdio_idle and stmmac_mdio_reset. This removes cleanup calls for null descriptors.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to a44fa

This localized change safely avoids releasing an absent MDIO reset GPIO descriptor; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the fix for absent MDIO reset GPIO handling.
Description check ✅ Passed The description explains the NULL GPIO issue, the warning, the code fix, and verification results.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant