From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796364847; b=kYLIEatm1G5xvNC5llaQxyrgWxZZgYE98qErXIo/6rJ4qGra5Ir/gdq8qA0xo9IEdURa kJaEsNUx9QCzu4uNWW/u5yWYSGvGpnNJAf7+4VANdtf+SkB8I/iKKCcdiliWW8HiSvZPG t88XWg4jnecVMoQ2IHbh8g4uKJtrJV/0HeLnLuxgAffRYHF6FQwDRQbY+CsT92xoIqcDx EOMUr3r0DjC+TwPwXwGePwn/33m7EFwnyOycQekYLaa79yVYbc4RYRbTd9LZPjg1U+u1p j7KoqL1/iHZPv2/a/QiobgxzoCppNWgXZoevAQ2SPJhJIdk9ppnw5b77Sr+j/g4SeBg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796364847; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=XlTheWwd65Z2JjU0WoJcEiZ5uMqKoubPXmJhT7N68u4=; b=Jd7a3JRqqMAD5+3d4O11KU8U9qc3/1caDIinSlZww60Q4k65u5mrNJxB9KOvrN3AC9i+ lEHh1Y7eEMfY4o4bee+mM11GhE9BKw+AsJftQFb/2rzN9FaGlMtmSJAiNje61PuAIvHsH A7hIaL1sTas4NYMyjuryvlAwtQ/x9veUbArZmaWYRP3FSLRgR6lil1w2UvoWiF+uI36fC DstIypPEzpgwAGka0/BqAbB6guedqNqL6Xh0n0zzTyJmY6mAeNaagKZsbfGf+BxeAqP7j lNugcWDMcN6FKoa3X9ydtvRjNSLdtWJNrCA5Uw4DQfidLRq/nhl0YxY1es1M1X+48MQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=O+ty2k5R; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2622D606A322 for ; Fri, 4 Dec 2026 06:14:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=O+ty2k5R Received: by smtp.kernel.org (Postfix) with ESMTPSA id A03FC1F0092C; Fri, 4 Dec 2026 06:14:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796364846; bh=XlTheWwd65Z2JjU0WoJcEiZ5uMqKoubPXmJhT7N68u4=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=O+ty2k5RCZjeU2kiJyF2j36GbM72JU1KFrXg64ELEUqmgTSgdKsunuf2EPqBUT2bz PR7CYicv5jg/1KWL9N6GgjGJo07dc1dYc4ItGwsJWq96HjvUo8iQXtamdMjmDqAo55 uZWwkDhAB6i+YVmBzPagcSXlrkY74sbogAUccdpDDyGirHkgYC92bwbbPJouRBWCcg QI8Snj3PqrXOafpQrPUSZTpPBuwjgD7Q9JMPHAkqUos1zKcetLWQ24BUh/7TeMzgOx 4ThEo6DvodNT53U2VQCwk1QQ6cU3ifMw8qrzu08QT67E4ANWulgCAvGi8cSg6f7uxC 01DshGp7fqMpg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH iwl-next v2 3/4] e1000: attach a CE4100 PHY through phylink Reply-To: sashiko-reviews@lists.linux.dev To: "Joseph Telaak" Cc: intel-wired-lan@lists.osuosl.org, devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261203-e1000-phylink-v2-3-0a8f80515363@telaak.dev> References: <20261203-e1000-phylink-v2-0-0a8f80515363@telaak.dev> <20261203-e1000-phylink-v2-3-0a8f80515363@telaak.dev> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 06:14:06 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] e1000: unchecked reg shift in e1000_ce4100_mdio_read()/write() - [Medium] e1000: e1000_mdio_register() rejects valid DT mdio nodes without phylink - [Medium] e1000: PHY state machine left polling BAR 1 MDIO in D3hot with WoL enabled -- commit 37b0dd6aa7b1616c73701607700385f94c7c3b35 Author: Joseph Telaak e1000: attach a CE4100 PHY through phylink This commit extends CE4100 phylink support to attach a PHY described by phy-handle on open, and registers the MAC's MDIO bus when an mdio child node is present in the device tree. > diff --git a/drivers/net/ethernet/intel/e1000/e1000_hw.c b/drivers/net/et= hernet/intel/e1000/e1000_hw.c > index f367b87938f14..3a2a9713e3b20 100644 > --- a/drivers/net/ethernet/intel/e1000/e1000_hw.c > +++ b/drivers/net/ethernet/intel/e1000/e1000_hw.c [ ... ] > +int e1000_ce4100_mdio_read(struct e1000_hw *hw, int addr, int reg) > +{ > + int ret; > + u32 sts; > + > + ret =3D e1000_ce4100_mdio_cmd(hw, (reg << E1000_MDIC_REG_SHIFT) | > + (addr << E1000_MDIC_PHY_SHIFT) | > + INTEL_CE_GBE_MDIC_OP_READ); > + if (ret) > + return ret; > + > + sts =3D readl(E1000_MDIO_STS); > + if (sts & INTEL_CE_GBE_MDIC_READ_ERROR) > + return -EIO; > + > + return sts & 0xffff; > +} > + > +/** > + * e1000_ce4100_mdio_write - write a register of a PHY on the CE4100 MDI= O bus > + * @hw: Struct containing variables accessed by shared code > + * @addr: PHY address > + * @reg: register number > + * @val: value to write > + * > + * Return: 0, or a negative error code. > + */ > +int e1000_ce4100_mdio_write(struct e1000_hw *hw, int addr, int reg, u16 = val) > +{ > + return e1000_ce4100_mdio_cmd(hw, val | (reg << E1000_MDIC_REG_SHIFT) | > + (addr << E1000_MDIC_PHY_SHIFT) | > + INTEL_CE_GBE_MDIC_OP_WRITE); > +} [Severity: Medium] Can an out-of-range reg value in e1000_ce4100_mdio_read() or e1000_ce4100_mdio_write() corrupt adjacent fields in E1000_MDIO_CMD? e1000_mii_ioctl() delegates SIOCGMIIREG and SIOCSMIIREG to phylink_mii_ioctl(), which passes the 16-bit mii->reg_num through __mdiobus_read() and __mdiobus_write() without range-checking regnum. Shifting reg left by E1000_MDIC_REG_SHIFT (16) unmasked lets bits 9:5 overwrite the PHY address field and bit 10 set INTEL_CE_GBE_MDIC_OP_WRITE, turning a read-only SIOCGMIIREG into a write of 0x0000. Values with reg >=3D 0x8000 also shift into the sign bit of signed int reg. Validating reg <=3D MAX_PHY_REG_ADDRESS (returning -EINVAL, as in e1000_read_phy_reg_ex()) or using FIELD_PREP() after bounds-checking would avoid this. > diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/= ethernet/intel/e1000/e1000_main.c > index f07afc451d098..1ac21f2c18b8f 100644 > --- a/drivers/net/ethernet/intel/e1000/e1000_main.c > +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c [ ... ] > +static int e1000_mdio_register(struct e1000_adapter *adapter) > +{ > + struct device *dev =3D &adapter->pdev->dev; > + struct device_node *np; > + struct mii_bus *bus; > + int err; > + > + np =3D of_get_available_child_by_name(dev->of_node, "mdio"); > + if (!np) > + return 0; > + > + /* Without phylink, e1000's own PHY code would drive the bus too */ > + if (!adapter->phylink) { > + e_dev_err("an mdio node needs a phy-handle or a fixed-link\n"); > + err =3D -EINVAL; > + goto out; > + } [Severity: Medium] As reported by Maxime Chevallier on v1 [1], should e1000_mdio_register() register the MDIO bus whenever an mdio child node is present instead of returning -EINVAL without phylink? Documentation/devicetree/bindings/net/intel,ce4100-gbe.yaml allows an mdio child node without phy-handle or fixed-link (for example, when another MAC or a switch uses devices on this bus), so returning -EINVAL here aborts e1000_probe() on valid DT configurations. Serializing CE4100 MDIO register access with e1000_phy_lock would allow registering the bus independently of phylink. [ ... ] > @@ -1549,6 +1631,13 @@ int e1000_open(struct net_device *netdev) > =20 > netif_carrier_off(netdev); > =20 > + if (adapter->phylink) { > + err =3D phylink_of_phy_connect(adapter->phylink, > + adapter->pdev->dev.of_node, 0); > + if (err) > + return err; > + } [Severity: Medium] With Wake-on-LAN enabled, can the PHY state machine keep polling BAR 1 MDIO registers after the PCI device enters PCI_D3hot? e1000_phylink_init() sets mac_managed_pm =3D true, so mdio_bus_phy_suspend() skips phy_stop_machine(). When WoL is enabled, __e1000_shutdown() passes mac_wol =3D true to phylink_suspend(), which takes the MAC-WoL branch and also skips phylink_stop() and phy_stop(). Because phydev->state_queue runs on the non-freezable system_power_efficient_wq, it can fire after pci_prepare_to_sleep() or e1000_shutdown() puts the device into PCI_D3hot. e1000_ce4100_mdio_cmd() then reads 0xffffffff and returns -ETIMEDOUT, causing _phy_state_machine() to trigger WARN(1) via phy_error_precise() and leave the PHY stuck in PHY_ERROR after phylink_resume(). [1] https://lore.kernel.org/r/80f76cd1-5fac-4809-8ab9-c6ccbce647fd@bootlin.= com --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-e1000-phyl= ink-v2-0-0a8f80515363@telaak.dev?part=3D3