From nobody Sun Jun 14 12:42:18 2026 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2446D37B03B for ; Thu, 2 Apr 2026 19:42:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775158961; cv=none; b=O91rs2xOsttSaDlcBWhfeapjpHelJ6c+hxlXngtNsWeaINZemRBqTc37R2OHnYHQ9VxnjacjSVfbDCJ0bg3/9CMxl3Kjfn26ZgdFziLv9uAcMGXa+ZfTacXPW/D5wodlrRMCzjnXjIqri53r/usniU9ELIaCaorP0oV6m+fbcho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775158961; c=relaxed/simple; bh=bXZVRbhyQyXsHPD+AK7JXDHMmDS9HrnLFBdnlZiPr8c=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=B/lDu2tokrmbZ920HOwjtYNqtxzNTqKWNpILuLRChnhIrv/4aF0mhft6+0KcNADBP4WbzeO3y+zxatWI2UPNDWVVIspRLG3bwp62jBXSD1P1wz/buoUSOjvISB75ljudgy57bBuwzSkepPF/CiGPq9tTfhoKMdFCHW3v8/kdEzY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UlJxvlgN; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UlJxvlgN" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2ad9516a653so6140925ad.0 for ; Thu, 02 Apr 2026 12:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775158959; x=1775763759; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wB0nhkRSEuZ4VZIuA2RyZ5ktjm9nKZErCv/yIZXktnY=; b=UlJxvlgNbLcDWqX1fYIp28vwI7ofRss7kQlo/+rHzdaNe0k/v428Wy/ps7u8J5VYwi j7G4GGRZflRlKOVBKi6shwp/mA6LYQ7VvHnBJxSQZT0kSxRTiirATj1mAjyHVM1Ya3AW ANFKhbJwHU30QDC//1BbzGTgIrhr3EmNScrslj549t5wgGqpQmemxaCnvJa1CD16NdpJ qeBvDhHoxwvsE3a6s0khKTiDqi6JQNuVmhP34oQAPOXil2bwAXvZ5nBRQbGmpLnkoLXa HlA/N7hW8Itnkg//ih+1Q/NN86fjT7nVEdcCqonmKlw1CqEhIsY5TOaVMjlRo4XF2TTx t7sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775158959; x=1775763759; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=wB0nhkRSEuZ4VZIuA2RyZ5ktjm9nKZErCv/yIZXktnY=; b=RbZi6ILjeHBtuctWdD+K4urkVz4NQEDnCMrHUrnyn08F6Htn9GPc0+tjsTy1grXaX9 Re/Cp+YnDcJocvr8ifetTUznUi4p799XfIUOBon7HGMUB6Ip5h85fFGOKYWlvgU76chs 6YjKH4D1pTtmmSzGvwECoNdbtBTIgGjdj8j6mqAHHmPa2dnEP9KjPUbe3cgVbtSv6lUX 5BjgJXOuCV+uv5am0Jh7OjZZ1uER7oBj52cXVdWR+ZgVf6D+6h0PIoGNCB+8C159eYAu 1912to5chSm2yvcA5IYp4Errr85RzOhWAsLXQ5BuFFuptX9NynunH+iy2YF0tirvECYa QRMQ== X-Forwarded-Encrypted: i=1; AJvYcCXMcHD/52isdeIpP0HwOVz8GEdCLxFLAZMDaMzXJCFN8UFu3/+uGbRdLUq1pNO6Gm3VdKbDiR8ctygcK8U=@vger.kernel.org X-Gm-Message-State: AOJu0YxJxPomREB4Sy7A5lKhCQMEckxeskBcAdm2lUlpsLrMEfW41YEc HALXIkizEUKRazwncxNEZQ0o7H90QW1iD26Dzm9WAZ6yiw3HdSro7wqq X-Gm-Gg: AeBDietqAAlNT9OF0UeG0Eb3ZbCWHUFq1eTbsI4UTrofI36abmdpEVS+VAztZ9/juNe XkCBHDMUwP1sZxXpWCX77uWowAgfBqoYjEEm6WOfYHUh8pwF8ukBD+hN3dKhT/3pruvOEOOUnnI Cq63kdGbg9JQhWlKYxmZEl3NsGPBKYSrpVgLY6+GuFbEIo/5I5kydLn9E7Pwb1l/rws6HngbI6g fzLIVJB98FIM+5tl9zk/iMrG+8UJjN4IbGGZ8Jl1ZQATFZkLplLqxNJwtSw8faB9ShbQMXiv4xO kryYhBnQHMDxE8usxNd7A8FweDBLw6J91HJBCl2ytmHZfhCLPhVNaNMxlO+Wqu81iDiyvEvl62p QNF7zu7HaI9N7fVrzobh5mwyAotiBGif8zT36b6YyWTta9m7Mr5XwFEdOgYlMo3tLiDt/GhJX4y ShUrrLvfwBY7quB9u0d/YkbQsU+pFcwpu18IBTlxOAF2u43V2IXpaydYPeMmISWA== X-Received: by 2002:a17:903:238b:b0:2ad:d0ff:2ed4 with SMTP id d9443c01a7336-2b28164c3d7mr6124885ad.6.1775158959241; Thu, 02 Apr 2026 12:42:39 -0700 (PDT) Received: from ubunut-vm.. (c-73-240-82-137.hsd1.or.comcast.net. [73.240.82.137]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b27472d5e5sm48432755ad.15.2026.04.02.12.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2026 12:42:38 -0700 (PDT) From: Joel To: andrew+netdev@lunn.ch Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Joel Subject: [PATCH] sungem: fix PHY initialization hardware failure check and pointe style Date: Thu, 2 Apr 2026 19:42:35 +0000 Message-ID: <20260402194235.11986-1-joelcrouch@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, bcm5411_init does not validate the result of the PHY register reads. This can lead to silent failures if the hardware is unresponsive or the MDIO bus times out, as 0xffff would be treated as valid data. This patch: 1: Adds a check for -EIO and 0xffff during BCM5411 initialization. 2: Updates gem_init_phy to log an error message fi the PHY- specific init fails. 3: Cleans up pointer formatting(eg,. foo* bar to foo *bar) to align with Linux Kernel Coding Style in the modified files. Signed-off-by: Joel --- drivers/net/ethernet/sun/sungem.c | 8 +++-- drivers/net/sungem_phy.c | 60 +++++++++++++++++-------------- 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/sun/sungem.c b/drivers/net/ethernet/sun/s= ungem.c index 8e69d917d..525aba527 100644 --- a/drivers/net/ethernet/sun/sungem.c +++ b/drivers/net/ethernet/sun/sungem.c @@ -1707,8 +1707,12 @@ static void gem_init_phy(struct gem *gp) sungem_phy_probe(&gp->phy_mii, gp->mii_phy_addr); =20 /* Init PHY */ - if (gp->phy_mii.def && gp->phy_mii.def->ops->init) - gp->phy_mii.def->ops->init(&gp->phy_mii); + if (gp->phy_mii.def && gp->phy_mii.def->ops->init) { + int err =3D gp->phy_mii.def->ops->init(&gp->phy_mii); + + if (err) + netdev_err(gp->dev, "PHY init failed: %d\n", err); + } } else { gem_pcs_reset(gp); gem_pcs_reinit_adv(gp); diff --git a/drivers/net/sungem_phy.c b/drivers/net/sungem_phy.c index c10198d44..ec8800c93 100644 --- a/drivers/net/sungem_phy.c +++ b/drivers/net/sungem_phy.c @@ -44,27 +44,27 @@ static const int phy_BCM5400_link_table[8][3] =3D { { 1, 0, 1 }, /* 1000BT */ }; =20 -static inline int __sungem_phy_read(struct mii_phy* phy, int id, int reg) +static inline int __sungem_phy_read(struct mii_phy *phy, int id, int reg) { return phy->mdio_read(phy->dev, id, reg); } =20 -static inline void __sungem_phy_write(struct mii_phy* phy, int id, int reg= , int val) +static inline void __sungem_phy_write(struct mii_phy *phy, int id, int reg= , int val) { phy->mdio_write(phy->dev, id, reg, val); } =20 -static inline int sungem_phy_read(struct mii_phy* phy, int reg) +static inline int sungem_phy_read(struct mii_phy *phy, int reg) { return phy->mdio_read(phy->dev, phy->mii_id, reg); } =20 -static inline void sungem_phy_write(struct mii_phy* phy, int reg, int val) +static inline void sungem_phy_write(struct mii_phy *phy, int reg, int val) { phy->mdio_write(phy->dev, phy->mii_id, reg, val); } =20 -static int reset_one_mii_phy(struct mii_phy* phy, int phy_id) +static int reset_one_mii_phy(struct mii_phy *phy, int phy_id) { u16 val; int limit =3D 10000; @@ -88,7 +88,7 @@ static int reset_one_mii_phy(struct mii_phy* phy, int phy= _id) return limit <=3D 0; } =20 -static int bcm5201_init(struct mii_phy* phy) +static int bcm5201_init(struct mii_phy *phy) { u16 data; =20 @@ -101,7 +101,7 @@ static int bcm5201_init(struct mii_phy* phy) return 0; } =20 -static int bcm5201_suspend(struct mii_phy* phy) +static int bcm5201_suspend(struct mii_phy *phy) { sungem_phy_write(phy, MII_BCM5201_INTERRUPT, 0); sungem_phy_write(phy, MII_BCM5201_MULTIPHY, MII_BCM5201_MULTIPHY_SUPERISO= LATE); @@ -109,7 +109,7 @@ static int bcm5201_suspend(struct mii_phy* phy) return 0; } =20 -static int bcm5221_init(struct mii_phy* phy) +static int bcm5221_init(struct mii_phy *phy) { u16 data; =20 @@ -132,7 +132,7 @@ static int bcm5221_init(struct mii_phy* phy) return 0; } =20 -static int bcm5221_suspend(struct mii_phy* phy) +static int bcm5221_suspend(struct mii_phy *phy) { u16 data; =20 @@ -147,7 +147,7 @@ static int bcm5221_suspend(struct mii_phy* phy) return 0; } =20 -static int bcm5241_init(struct mii_phy* phy) +static int bcm5241_init(struct mii_phy *phy) { u16 data; =20 @@ -170,7 +170,7 @@ static int bcm5241_init(struct mii_phy* phy) return 0; } =20 -static int bcm5241_suspend(struct mii_phy* phy) +static int bcm5241_suspend(struct mii_phy *phy) { u16 data; =20 @@ -185,7 +185,7 @@ static int bcm5241_suspend(struct mii_phy* phy) return 0; } =20 -static int bcm5400_init(struct mii_phy* phy) +static int bcm5400_init(struct mii_phy *phy) { u16 data; =20 @@ -214,7 +214,7 @@ static int bcm5400_init(struct mii_phy* phy) return 0; } =20 -static int bcm5400_suspend(struct mii_phy* phy) +static int bcm5400_suspend(struct mii_phy *phy) { #if 0 /* Commented out in Darwin... someone has those dawn docs ? */ sungem_phy_write(phy, MII_BMCR, BMCR_PDOWN); @@ -222,7 +222,7 @@ static int bcm5400_suspend(struct mii_phy* phy) return 0; } =20 -static int bcm5401_init(struct mii_phy* phy) +static int bcm5401_init(struct mii_phy *phy) { u16 data; int rev; @@ -270,7 +270,7 @@ static int bcm5401_init(struct mii_phy* phy) return 0; } =20 -static int bcm5401_suspend(struct mii_phy* phy) +static int bcm5401_suspend(struct mii_phy *phy) { #if 0 /* Commented out in Darwin... someone has those dawn docs ? */ sungem_phy_write(phy, MII_BMCR, BMCR_PDOWN); @@ -278,8 +278,9 @@ static int bcm5401_suspend(struct mii_phy* phy) return 0; } =20 -static int bcm5411_init(struct mii_phy* phy) +static int bcm5411_init(struct mii_phy *phy) { + int val; u16 data; =20 /* Here's some more Apple black magic to setup @@ -295,7 +296,12 @@ static int bcm5411_init(struct mii_phy* phy) sungem_phy_write(phy, MII_BMCR, BMCR_RESET); sungem_phy_write(phy, MII_BMCR, 0x1340); =20 - data =3D sungem_phy_read(phy, MII_BCM5400_GB_CONTROL); + val =3D sungem_phy_read(phy, MII_BCM5400_GB_CONTROL); + + if (val < 0 || val =3D=3D 0xffff) + return -EIO; + + data =3D (u16)val; data |=3D MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP; sungem_phy_write(phy, MII_BCM5400_GB_CONTROL, data); =20 @@ -408,14 +414,14 @@ static int genmii_read_link(struct mii_phy *phy) return 0; } =20 -static int generic_suspend(struct mii_phy* phy) +static int generic_suspend(struct mii_phy *phy) { sungem_phy_write(phy, MII_BMCR, BMCR_PDOWN); =20 return 0; } =20 -static int bcm5421_init(struct mii_phy* phy) +static int bcm5421_init(struct mii_phy *phy) { u16 data; unsigned int id; @@ -548,7 +554,7 @@ static int bcm54xx_read_link(struct mii_phy *phy) u16 val; =20 if (phy->autoneg) { - val =3D sungem_phy_read(phy, MII_BCM5400_AUXSTATUS); + val =3D sungem_phy_read(phy, MII_BCM5400_AUXSTATUS); link_mode =3D ((val & MII_BCM5400_AUXSTATUS_LINKMODE_MASK) >> MII_BCM5400_AUXSTATUS_LINKMODE_SHIFT); phy->duplex =3D phy_BCM5400_link_table[link_mode][0] ? @@ -568,7 +574,7 @@ static int bcm54xx_read_link(struct mii_phy *phy) return 0; } =20 -static int marvell88e1111_init(struct mii_phy* phy) +static int marvell88e1111_init(struct mii_phy *phy) { u16 rev; =20 @@ -592,7 +598,7 @@ static int marvell88e1111_init(struct mii_phy* phy) =20 #define BCM5421_MODE_MASK (1 << 5) =20 -static int bcm5421_poll_link(struct mii_phy* phy) +static int bcm5421_poll_link(struct mii_phy *phy) { u32 phy_reg; int mode; @@ -616,7 +622,7 @@ static int bcm5421_poll_link(struct mii_phy* phy) return 1; } =20 -static int bcm5421_read_link(struct mii_phy* phy) +static int bcm5421_read_link(struct mii_phy *phy) { u32 phy_reg; int mode; @@ -644,7 +650,7 @@ static int bcm5421_read_link(struct mii_phy* phy) return 0; } =20 -static int bcm5421_enable_fiber(struct mii_phy* phy, int autoneg) +static int bcm5421_enable_fiber(struct mii_phy *phy, int autoneg) { /* enable fiber mode */ sungem_phy_write(phy, MII_NCONFIG, 0x9020); @@ -665,7 +671,7 @@ static int bcm5421_enable_fiber(struct mii_phy* phy, in= t autoneg) #define BCM5461_FIBER_LINK (1 << 2) #define BCM5461_MODE_MASK (3 << 1) =20 -static int bcm5461_poll_link(struct mii_phy* phy) +static int bcm5461_poll_link(struct mii_phy *phy) { u32 phy_reg; int mode; @@ -691,7 +697,7 @@ static int bcm5461_poll_link(struct mii_phy* phy) =20 #define BCM5461_FIBER_DUPLEX (1 << 3) =20 -static int bcm5461_read_link(struct mii_phy* phy) +static int bcm5461_read_link(struct mii_phy *phy) { u32 phy_reg; int mode; @@ -720,7 +726,7 @@ static int bcm5461_read_link(struct mii_phy* phy) return 0; } =20 -static int bcm5461_enable_fiber(struct mii_phy* phy, int autoneg) +static int bcm5461_enable_fiber(struct mii_phy *phy, int autoneg) { /* select fiber mode, enable 1000 base-X registers */ sungem_phy_write(phy, MII_NCONFIG, 0xfc0b); --=20 2.43.0