From patchwork Thu Dec 12 14:08:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13905250 X-Patchwork-Delegate: kuba@kernel.org Received: from OSPPR02CU001.outbound.protection.outlook.com (mail-norwayeastazon11013044.outbound.protection.outlook.com [40.107.159.44]) (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 ED79C2144A2 for ; Thu, 12 Dec 2024 14:08:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.159.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734012529; cv=fail; b=RaGkj87A1l0szyed1nfjPdJoRZVEH8+wWgHpWHKxDRkpIlr3NovNCbexYCfcJQr1F3JmSB2f+IjNkQapZJu8XLlFK3JmfFmVa2b7NXv1fPdbBdCCXMnD+UgJmYjOaPu0itfhcCx7sVQggUGXfqtPNsseB2EaBQTHWnSYW4SpRNM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734012529; c=relaxed/simple; bh=gLidDEWrzwqnOGkhb25NmD+f/+CLhZy90e3Olq1XapM=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=bGNcJnrcKhjZc5pI9D9BoJLAaDxwMdg4+VwYB64LZBdPygG/SOZxLiU+A2EztpRMYWH8/IHNmpHfYttXoJwhaMIvBFGbEA6JZR7RQdCrJkACKKld1WTgVA8o+8LEvXzJKdVrUgVedvzfeLaw7YwQM4oe0JKaVUvbhTI5bdozjvk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=m1ZKK3gH; arc=fail smtp.client-ip=40.107.159.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="m1ZKK3gH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Lz8FklMOLmXJ6TsGJ0M4FwdsGt0X9v+/GM2bLalM4Bivw3nFQJP9TcrETw4s89P2A+FCAmzfXqJvfCDZ0HHUDNh910mC0ObQGJ2KHId/gUVktifQIIMwxJiBRlEWN3XX+jO0NeylhOz1zmUizRfaRQ/7focA2eLLhx3TJS7j4B+Rk1bXuwZAqCI+4EoBWrSf5Ckt8qdAN3KJAb9XUt2aKPsEkWqTEugsbBDshNPml5EpfLf6+M4cGpzcxNXzlixJq+2+WN7IpmmhZn/K7F3j3AP53telCeEGooWfKJ2yAL6/kAVSJV/a6NoT98CehTQKWjFSIPraj9zf2kyTTyYEcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jyDAAskNd+4MLJafa+eSg0txv8UkZ5iWuf5N7IQLXBg=; b=khM5POZZwAY5Z1oI/xnoD3uttF2VHXxlnI9c+GeDavVQY+VBdrgUxqd/bL4dhbQBhla7RvADK0fWhKswmKcZB1RErLVCpancbGT/8b597P1zM0otglnWSdL94huUZcvXtanGGFD8B+N1E2FsGEuGkvTcqyRTvQGezulB6oE9mMJL4IKFWQX/dPl/3sw/nqunab48ZWTYtZ0/s5hfIVnxAeMaVQcGgZ/I3G0XFTmW8Wu7ZP0hxAoF0QCuYASjQPjj6Bw86wKPeNhPFyk+/5TNTVX8i8lZT+htChhckyvAfP1uaxva4EikzP0we7/E6rMmaY3N/Z/h1znsibNf4i7mRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jyDAAskNd+4MLJafa+eSg0txv8UkZ5iWuf5N7IQLXBg=; b=m1ZKK3gHnxcuGVVDjklVlmLyqFMEuzQzRNUgU5o/nsFDEFsMg5O5cljHbGJgvC8GTebw2lRPUIdkLrxRUWEEGSB+ko3Fstb1EjB69J0rPDfhffS9B9QuuDef2jbbA5rB82if8y7qt2adRo9J7kAAPI9kx1dymglpSmJJww2cq76YmyX+NnTPP93tTQTeI4KJMIVjD6y28AgZz14AIC5rV+vrlhQj5IZ6k66SM+GC9RfBNGhpgfME8IbX29DSVWpYQpjVgRXh/xuJ6ZxL0B2mZWT35S3GsXH4rf6k0FexRNaLuqIrEd0hoBWGFedSlk/9uUdG7YPGn6hpAxyI7Uj8/Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) by AS8PR04MB7655.eurprd04.prod.outlook.com (2603:10a6:20b:292::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Thu, 12 Dec 2024 14:08:43 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%6]) with mapi id 15.20.8251.015; Thu, 12 Dec 2024 14:08:43 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Russell King , Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v3 net-next] net: phylink: improve phylink_sfp_config_phy() error message with missing PHY driver Date: Thu, 12 Dec 2024 16:08:34 +0200 Message-ID: <20241212140834.278894-1-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.43.0 X-ClientProxiedBy: BE1P281CA0041.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::19) To AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM8PR04MB7779:EE_|AS8PR04MB7655:EE_ X-MS-Office365-Filtering-Correlation-Id: 1ea4abb1-afe4-4665-e46d-08dd1ab67c87 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|1800799024|376014|38350700014; X-Microsoft-Antispam-Message-Info: 5qQtlba3JrkYUBhafbITU6B2YwaK8gGaIt3pM/PGTfsUpr2fzBlinf/H/3RbW9ViglS06bXozoTFJJlhgCPiJ3PsjnhkiOVwVuJuCleV2Jwy7X2xPwoMrnQwENBa7bYwSTzj/xusAkXAmaYUonnPAF1GuFeerX3NXc/WtmW6mmcmlzlWtq6iQNCEGfoUJheLoVSlOb9w88Fw/gCsb/FW40crh0e9Z1KF7s5X5RijQ7pyBWPR1Nrtdw+s8sjnNa1vg96hmrTiTZtn4dCNIzEcDwQBrdJQJdiZJai5KVJd5AgC+Wq2xmECjWvBSTV5bQ94e2To5zG2MpjBdicvHgzKDhZXhhRH5v91n2w4LnS/n32MYT3jiu3/nLvKPRMYB6CCf0jijbTIFtZ5sQ9EFaArX+yODcJLs6JbAbep9glxqxQb/9sQOzox6wuRVQDZVfQP1NqUqm7V5L27gOCmVFqej7ebXrErmdY7rgybxsV0H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ypioasm4UXlhZLuFyNgjDVp5m44y6wGBtzMV0LkqVrih7CgDJGK1I4nhJjXEED/dfPLl0jwgDemeFIvOSSQ2nU4gabzbDFp3HLg4dplqslj07f2eLhwD2Tpk2ZGl11Pg/yzZpxuFha2rUNzaHVKeyB48wrW3EtbvZDdmWf3KEJdfhT863oDzcsoLfyC0d9pab2zShuq5mM2JXCd0n/zH5H7CPhYWj7775bZc5bmTQ8LZDNqkbnok0Lt3gsfYOTmQSgylO2AgQNBOMqmT25YjtZlxGWl5HOtKtqTzjoXzIsWWz9JzY43tkpUCPlrJ0I4WOL6ea9XTHngUM3f6YTGIoFcjYqcKHdJQFmMjKGtLrTE0M/rC3GQ0FssL279y/9B6kiTAFb4E9wResHLL3YR7D0vzs+1lE5yT5x3f0YPnJniRUGQwfVKdzETvp6Zs8eMHwN/0Ffa0xKBF0eERPgVqvrVVrudemLt13zx0RxlEXFENjDORmcXi+N3dyWSfhHVDZTpMF1Ue0MhYT12DKE8755U8h2URJAbIpqlgakzqP/bxY1vQxoJCZqtORaluVt2JGbRlxWbVKCb/yRFstnpUy7i0kaaqrE1nji14nbhwLwU4D/rDpvKBAHkldCMBqk0t1EcsVg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ea4abb1-afe4-4665-e46d-08dd1ab67c87 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2024 14:08:43.3833 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1yT7k2Sq54oUgCqkyITKrpSYaInBsHbY2ymTEq1rodUyvbdYlD6ZKQDng3uAPKUCFyvDBmhnTTLAngWafLAN4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7655 X-Patchwork-Delegate: kuba@kernel.org It seems that phylink does not support driving PHYs in SFP modules using the Generic PHY or Generic Clause 45 PHY driver. I've come to this conclusion after analyzing these facts: - sfp_sm_probe_phy(), who is our caller here, first calls phy_device_register() and then sfp_add_phy() -> ... -> phylink_sfp_connect_phy(). - phydev->supported is populated by phy_probe() - phy_probe() is usually called synchronously from phy_device_register() via phy_bus_match(), if a precise device driver is found for the PHY. In that case, phydev->supported has a good chance of being set to a non-zero mask. - There is an exceptional case for the PHYs for which phy_bus_match() didn't find a driver. Those devices sit for a while without a driver, then phy_attach_direct() force-binds the genphy_c45_driver or genphy_driver to them. Again, this triggers phy_probe() and renders a good chance of phydev->supported being populated, assuming compatibility with genphy_read_abilities() or genphy_c45_pma_read_abilities(). - phylink_sfp_config_phy() does not support the exceptional case of retrieving phydev->supported from the Generic PHY driver, due to its code flow. It expects the phydev->supported mask to already be non-empty, because it first calls phylink_validate() on it, and only calls phylink_attach_phy() if that succeeds. Thus, phylink_attach_phy() -> phy_attach_direct() has no chance of running. It is not my wish to change the state of affairs by altering the code flow, but merely to document the limitation rather than have the current unspecific error: [ 61.800079] mv88e6085 d0032004.mdio-mii:12 sfp: validation with support 00,00000000,00000000,00000000 failed: -EINVAL [ 61.820743] sfp sfp: sfp_add_phy failed: -EINVAL On the premise that an empty phydev->supported is going to make phylink_validate() fail anyway, and that this is caused by a missing PHY driver, it would be more informative to single out that case, undercut the entire phylink_sfp_config_phy() call, including phylink_validate(), and print a more specific message for this common gotcha: [ 37.076403] mv88e6085 d0032004.mdio-mii:12 sfp: PHY i2c:sfp:16 (id 0x01410cc2) has no driver loaded [ 37.089157] mv88e6085 d0032004.mdio-mii:12 sfp: Drivers which handle known common cases: CONFIG_BCM84881_PHY, CONFIG_MARVELL_PHY [ 37.108047] sfp sfp: sfp_add_phy failed: -EINVAL Link: https://lore.kernel.org/netdev/20241113144229.3ff4bgsalvj7spb7@skbuf/ Signed-off-by: Vladimir Oltean Reviewed-by: Russell King (Oracle) --- v2->v3: test specifically for the NULL quality of phy->drv, to avoid the "maybe" in the error message. v1->v2: add one more informational line containing common Kconfig options, as per review feedback. Link to v2: https://lore.kernel.org/netdev/20241211172537.1245216-1-vladimir.oltean@nxp.com/ Link to v1: https://lore.kernel.org/netdev/20241114165348.2445021-1-vladimir.oltean@nxp.com/ drivers/net/phy/phylink.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 95fbc363f9a6..6d50c2fdb190 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -3623,6 +3623,13 @@ static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy) { struct phylink *pl = upstream; + if (!phy->drv) { + phylink_err(pl, "PHY %s (id 0x%.8lx) has no driver loaded\n", + phydev_name(phy), (unsigned long)phy->phy_id); + phylink_err(pl, "Drivers which handle known common cases: CONFIG_BCM84881_PHY, CONFIG_MARVELL_PHY\n"); + return -EINVAL; + } + /* * This is the new way of dealing with flow control for PHYs, * as described by Timur Tabi in commit 529ed1275263 ("net: phy: