From: sashiko-bot@kernel.org
To: "Joseph Telaak" <joseph@telaak.dev>
Cc: intel-wired-lan@lists.osuosl.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH iwl-next v2 2/4] e1000: use phylink for a CE4100 fixed link
Date: Fri, 04 Dec 2026 06:14:05 +0000 [thread overview]
Message-ID: <sashiko-outbox-249195@kernel.org> (raw)
In-Reply-To: <20261203-e1000-phylink-v2-2-0a8f80515363@telaak.dev>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] e1000: unlocked netif_running() races phylink
start/resume/suspend with close
- [Low] e1000: unlocked data race on adapter->phylink_up
- [Low] e1000: e1000_probe() pulses PHY_RST when e1000_phylink_init()
fails
--
commit ba7508c7349c5b00062c75577f7323e893d36d78
Author: Joseph Telaak <joseph@telaak.dev>
e1000: use phylink for a CE4100 fixed link
This commit adds phylink support for CE4100 devices with a fixed-link OF
node so the MAC forces speed, duplex, and flow control from phylink instead
of scanning for an MDIO PHY. Link state, ethtool link and pause settings,
and MII ioctls are delegated to phylink while guarding MAC register updates
against resets and transmit setup with a mutex.
> diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
> index a52fff0259a17..f07afc451d098 100644
> --- a/drivers/net/ethernet/intel/e1000/e1000_main.c
> +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
[ ... ]
> @@ -1182,8 +1348,14 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> adapter->wol = adapter->eeprom_wol;
> device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
>
> - /* Auto detect PHY address */
> if (hw->mac_type == e1000_ce4100) {
> + err = e1000_phylink_init(adapter);
> + if (err)
> + goto err_eeprom;
> + }
[ ... ]
> @@ -1227,6 +1403,7 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> err_register:
> err_eeprom:
> e1000_phy_hw_reset(hw);
> + e1000_phylink_destroy(adapter);
[Severity: Low]
Does jumping to err_eeprom pulse E1000_CTRL_PHY_RST when e1000_phylink_init()
fails?
If phylink_create() returns -EPROBE_DEFER (for example via
phylink_parse_fixedlink() waiting on link-gpios), adapter->phylink is still
NULL. At err_eeprom, e1000_phy_hw_reset() checks e1000_uses_phylink(hw),
sees NULL, and asserts E1000_CTRL_PHY_RST for 10 ms plus the 10 ms wait in
e1000_get_phy_cfg_done(), which can disrupt an externally managed peer on
every deferred probe retry.
Jumping past e1000_phy_hw_reset() (for instance to err_mdio_ioremap) when
e1000_phylink_init() fails would avoid pulsing PHY_RST.
[ ... ]
> @@ -2397,6 +2586,9 @@ bool e1000_has_link(struct e1000_adapter *adapter)
> struct e1000_hw *hw = &adapter->hw;
> bool link_active = false;
>
> + if (adapter->phylink)
> + return adapter->phylink_up;
> +
[Severity: Low]
Is there a data race on adapter->phylink_up here and in e1000_link_test()?
e1000_mac_link_up() and e1000_mac_link_down() write adapter->phylink_up
under adapter->phylink_lock from phylink_resolve() without rtnl_lock, while
e1000_has_link() (from e1000_watchdog() and e1000_get_link()) and
e1000_link_test() read it without adapter->phylink_lock or READ_ONCE().
During e1000_open(), firing E1000_ICS_LSC before phylink_start() runs
e1000_watchdog() concurrently with phylink_resolve(), producing a KCSAN data
race. Reading adapter->phylink_up under adapter->phylink_lock (as e1000_up()
does) or using READ_ONCE()/WRITE_ONCE() would resolve it.
[ ... ]
> @@ -5091,6 +5292,8 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)
>
> WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags));
> rtnl_lock();
> + if (adapter->phylink)
> + phylink_suspend(adapter->phylink, !!adapter->wol);
> e1000_down(adapter);
> rtnl_unlock();
> }
[ ... ]
> @@ -5204,8 +5407,14 @@ static int e1000_resume(struct device *dev)
>
> e1000_init_manageability(adapter);
>
> - if (netif_running(netdev))
> + if (netif_running(netdev)) {
> e1000_up(adapter);
> + if (adapter->phylink) {
> + rtnl_lock();
> + phylink_resume(adapter->phylink);
> + rtnl_unlock();
> + }
> + }
[ ... ]
> @@ -5329,6 +5541,11 @@ static void e1000_io_resume(struct pci_dev *pdev)
> pr_info("can't bring device back up after reset\n");
> return;
> }
> + if (adapter->phylink) {
> + rtnl_lock();
> + phylink_start(adapter->phylink);
> + rtnl_unlock();
> + }
> }
[Severity: Medium]
Can e1000_io_resume(), e1000_resume(), and __e1000_shutdown() race with
e1000_close() because netif_running(netdev) is checked outside rtnl_lock()?
__dev_close_many() allows e1000_close() to run under rtnl_lock() even while
the netdev is detached:
CPU0 CPU1
e1000_io_resume()
if (netif_running(netdev))
e1000_up(adapter)
dev_close() /* holds rtnl_lock */
__dev_close_many()
e1000_close()
phylink_stop(adapter->phylink)
e1000_down(adapter)
rtnl_lock()
phylink_start(adapter->phylink) <-- started on closed netdev
rtnl_unlock()
This leaves phylink running on a closed interface. A later e1000_remove()
skips e1000_close() because the interface is down, so phylink_destroy()
frees pl and puts pl->link_gpio without stopping pl->link_poll or freeing
pl->link_irq, causing a use-after-free and an IRQ leak.
The same unlocked netif_running(netdev) check happens in e1000_resume()
before phylink_resume(), and in __e1000_shutdown() before sleeping and
calling phylink_suspend(). In __e1000_shutdown(), calling phylink_suspend()
on a closed interface with WoL enabled leaves PHYLINK_DISABLE_MAC_WOL set
because e1000_resume() will skip phylink_resume().
Holding rtnl_lock() across the netif_running(netdev) check,
e1000_up()/e1000_down(), and the phylink call (matching
e1000_io_error_detected()) would avoid these races.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-e1000-phylink-v2-0-0a8f80515363@telaak.dev?part=2
next prev parent reply other threads:[~2026-12-04 6:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 6:13 [PATCH iwl-next v2 0/4] e1000: phylink for the Intel CE4100 GbE Joseph Telaak
2026-12-03 6:13 ` [PATCH iwl-next v2 1/4] dt-bindings: net: add " Joseph Telaak
2026-12-03 14:52 ` Krzysztof Kozlowski
2026-12-03 23:02 ` Joseph Telaak
2026-12-03 6:13 ` [PATCH iwl-next v2 2/4] e1000: use phylink for a CE4100 fixed link Joseph Telaak
2026-12-04 6:14 ` sashiko-bot [this message]
2026-12-03 6:13 ` [PATCH iwl-next v2 3/4] e1000: attach a CE4100 PHY through phylink Joseph Telaak
2026-12-04 6:14 ` sashiko-bot
2026-12-03 6:13 ` [PATCH iwl-next v2 4/4] e1000: disable EEE on a CE4100 PHY under phylink Joseph Telaak
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=sashiko-outbox-249195@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=joseph@telaak.dev \
--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