From patchwork Sat Feb 3 20:52:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13544369 X-Patchwork-Delegate: kuba@kernel.org Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACD5A10A11 for ; Sat, 3 Feb 2024 20:53:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706993613; cv=none; b=rye0fDToPR8ILJMArV66M6d65CrFXn9HpZmaOFnJro/72WFxVH+IzX4Q0dMsbDbYTF1AYSRc98Y09IjyHpByClRZvYUVUjPL7WAnE7dozsRn/F7Og86sk5YsoCA5Z6VnXoYB8TUblZ60FU3BJ/uoO4VBHCpWgls9CfVELkIAvYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706993613; c=relaxed/simple; bh=7nsBao2j4yH1nAS0a3c2dFEXqBSj444mxPDfHt60bOg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pp+oYQl/DEyeyD91lAPty3G9CQ3KxhzSI02Uo/8DvFCp9dd8m9vyhPYeAr/2JTetlOZ2Vey03VTgL7h/j61AZ/i+Z66yUUtksA4rpot/1Ng5jOEycrVRHCY3ch1qCf3U84/ps3Y0z04OovIKEaoCVByN9kQoLISGzAuQ1s7+Q3k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=5Zedetam; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="5Zedetam" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:From: Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Content-Disposition: In-Reply-To:References; bh=srLZxFsDGhm2yJ40n65dVal0f1ULH3nj6wwqVFrGgGE=; b=5Z edetam+TQpsp5Oot8jieTE/7wgumufiobgEzkRnCC3k7Ae1S5MZthnzmzbM/te02xNJ4rT5R3JWAr jWYQedxmuiDdHGVLFIWsdR8/U8JSNqYaeppeExlQjCBkAxiBJcezeOcr6c3+qaS8OV0oJXUwRaIVa cQUTRxojTCcWleI=; Received: from c-76-156-36-110.hsd1.mn.comcast.net ([76.156.36.110] helo=thinkpad.home.lunn.ch) by vps0.lunn.ch with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rWN0v-006vPr-RM; Sat, 03 Feb 2024 21:53:26 +0100 From: Andrew Lunn Date: Sat, 03 Feb 2024 14:52:48 -0600 Subject: [PATCH net-next 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240203-unify-c22-c45-scan-error-handling-v1-1-8aa9fa3c4fca@lunn.ch> References: <20240203-unify-c22-c45-scan-error-handling-v1-0-8aa9fa3c4fca@lunn.ch> In-Reply-To: <20240203-unify-c22-c45-scan-error-handling-v1-0-8aa9fa3c4fca@lunn.ch> To: Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Vladimir Oltean Cc: netdev@vger.kernel.org, Tim Menninger , Andrew Lunn X-Mailer: b4 0.12.4 X-Patchwork-Delegate: kuba@kernel.org When scanning the MDIO bus for C22 devices, the driver returning -ENODEV is not considered fatal, it just indicates the MDIO bus master knows there is no device at that address, maybe because of hardware limitation. Make the C45 scan code act on -ENODEV the same way, to make C22 and C45 more uniform. It is expected all reads for a given address will return -ENODEV, so within get_phy_c45_ids() only the first place a read occurs has been changed. Signed-off-by: Andrew Lunn Reviewed-by: Florian Fainelli --- drivers/net/phy/phy_device.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 52828d1c64f7..962ab53c23ff 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -780,7 +780,7 @@ static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr, * and identifiers in @c45_ids. * * Returns zero on success, %-EIO on bus access error, or %-ENODEV if - * the "devices in package" is invalid. + * the "devices in package" is invalid or no device responds. */ static int get_phy_c45_ids(struct mii_bus *bus, int addr, struct phy_c45_device_ids *c45_ids) @@ -803,7 +803,11 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, */ ret = phy_c45_probe_present(bus, addr, i); if (ret < 0) - return -EIO; + /* returning -ENODEV doesn't stop bus + * scanning + */ + return (phy_reg == -EIO || + phy_reg == -ENODEV) ? -ENODEV : -EIO; if (!ret) continue; From patchwork Sat Feb 3 20:52:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13544368 X-Patchwork-Delegate: kuba@kernel.org Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 831DE111AE for ; Sat, 3 Feb 2024 20:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706993613; cv=none; b=OSv1PHsxfE7LewOmy8pWo83NhltqHkL9djiBuwup62F2u8PFvxU7wZauv8prVQ1ZDJVMTNLGYkIyGwLdjpXO3wB3c+66e8cgp39i8qlZF99hW3mstDzCWpbJwbEH9y1EVfZNkoHwN9GE7qBJQRtZZrS4HQqjBMx3wAB5WjeSnFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706993613; c=relaxed/simple; bh=qu169GEumHvNvv9UgSCcOQ8/DCAEs+xjyo7cUJd1D0U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OKhINtiTqVAoovip97/wKP6M+bB4PHmfZX7aSlmUnh9OCCymBLKgbfBWm+NTNawo+o11TTKB5/XD13kSsmJV4bTwT0Y9XVaIWSP24ckQL7OtbvOuXvrEqJqfu/zZIHcH1Y7lxXAX1WRy19lv09xO202xPahJ4YYTogX54jiMHFM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=fOaXywUF; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="fOaXywUF" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:From: Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Content-Disposition: In-Reply-To:References; bh=ejO5e+PFYubo5A40MRKGh6GVUJx2o46x/9WbysR9nc8=; b=fO aXywUFLAwUEDnsYTDapU/hMnkP4L0INyisfATo1EUQFBNFDGIiwl1m98A+YMP0v6I/a1tAde/xm4d wVb4pcRpK2zTf+Yy1xW3MV+o+scpHchE21ghnpfgqDCa6ViLhRqJ5u5A54qI6dDGEuebEWn7WGKEs BAerPGXMPmMBVIc=; Received: from c-76-156-36-110.hsd1.mn.comcast.net ([76.156.36.110] helo=thinkpad.home.lunn.ch) by vps0.lunn.ch with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rWN0y-006vPr-N2; Sat, 03 Feb 2024 21:53:28 +0100 From: Andrew Lunn Date: Sat, 03 Feb 2024 14:52:49 -0600 Subject: [PATCH net-next 2/2] net: dsa: mv88e6xxx: Return -ENODEV when C22/C45 not supported Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240203-unify-c22-c45-scan-error-handling-v1-2-8aa9fa3c4fca@lunn.ch> References: <20240203-unify-c22-c45-scan-error-handling-v1-0-8aa9fa3c4fca@lunn.ch> In-Reply-To: <20240203-unify-c22-c45-scan-error-handling-v1-0-8aa9fa3c4fca@lunn.ch> To: Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Vladimir Oltean Cc: netdev@vger.kernel.org, Tim Menninger , Andrew Lunn X-Mailer: b4 0.12.4 X-Patchwork-Delegate: kuba@kernel.org MDIO bus drivers can return -ENODEV when they know the bus does not have a device at the given address, e.g. because of hardware limitation. One such limitation is that the bus does not support C22 or C45 at all. This is more efficient than returning 0xffff, since it immediately stops the probing on the given address, where as further reads can be made when 0xffff is returned. Signed-off-by: Andrew Lunn --- drivers/net/dsa/mv88e6xxx/chip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 6eec2e4aa031..ce4e4bdf475d 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -3633,7 +3633,7 @@ static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg) int err; if (!chip->info->ops->phy_read) - return -EOPNOTSUPP; + return -ENODEV; mv88e6xxx_reg_lock(chip); err = chip->info->ops->phy_read(chip, bus, phy, reg, &val); @@ -3659,7 +3659,7 @@ static int mv88e6xxx_mdio_read_c45(struct mii_bus *bus, int phy, int devad, int err; if (!chip->info->ops->phy_read_c45) - return 0xffff; + return -ENODEV; mv88e6xxx_reg_lock(chip); err = chip->info->ops->phy_read_c45(chip, bus, phy, devad, reg, &val);