From f109473707a7a78c3b48dd32bb1d8aa77b1f8057 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 14 Mar 2026 16:57:00 -1000 Subject: [PATCH] [ethernet] Document lock-free polling rationale in RP2040 loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Explain why linkStatus() and connected() are called without LwIPLock — linkStatus() only reads the W5500 PHY via SPI, and connected() does a single atomic 32-bit read of netif->ip_addr. --- esphome/components/ethernet/ethernet_component_rp2040.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/esphome/components/ethernet/ethernet_component_rp2040.cpp b/esphome/components/ethernet/ethernet_component_rp2040.cpp index 354901b5823..fd2ff4a6473 100644 --- a/esphome/components/ethernet/ethernet_component_rp2040.cpp +++ b/esphome/components/ethernet/ethernet_component_rp2040.cpp @@ -80,7 +80,11 @@ void EthernetComponent::setup() { } void EthernetComponent::loop() { - // On RP2040, we need to poll connection state since there are no events + // On RP2040, we need to poll connection state since there are no events. + // linkStatus() reads the W5500 PHY register via SPI — no lwip state involved. + // connected() reads netif->ip_addr without LwIPLock, but this is a single + // 32-bit aligned read (atomic on ARM) — worst case is a one-iteration-stale + // value, which is benign for polling. if (this->eth_ != nullptr) { bool link_up = this->eth_->linkStatus() == LinkON; bool has_ip = this->eth_->connected();