From patchwork Tue Oct 8 06:11:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13825681 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012063.outbound.protection.outlook.com [52.101.66.63]) (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 2CEB91DED7B for ; Tue, 8 Oct 2024 06:27:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728368871; cv=fail; b=I8HlhZxboPkn7t808vArmiAfeiAYej9YSo9/PgWrDHWO/5K8vKe0zwCaz7vE/9QywPo3bxmTWkWR8V/WR2xhnA6hFoHW9yzOdYwByqAdIJjmv7wEinIre+7FMUeT/67a31Gpo7Z0HK7EU9HwSyqYeNxaDq9rr+LdafBQ02n2aAg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728368871; c=relaxed/simple; bh=ZvUYNmY44trHqLoTU6pv1v9i7xNzNZlGK5abIklPtFc=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=t+sTnL8LW2BWNOw2nBF8dZHhWgpfGZr7e7+SfC7WGqCYf7lgUonzjIsiMvoyrY2J08TYEOuis57JUIsItnU1Z+3iqrtw7O4R2U/k2NMOTJJ/xkfTEBihB0FdJBumgzBJu0bYVve8df2a6m5zJBk1be/1x5XTbFR/UJ7K+CLlWpM= 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=eR3tXh7I; arc=fail smtp.client-ip=52.101.66.63 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="eR3tXh7I" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lVQ/qCR9oeLOYV1Cb34zFdOs+GnJ4+KaKa1k/wZ2DVH60KncSk77hQvH9BBbe3Zr7HLtYRIv8SoqKTzhRAsvggDaiKWOmDTRFCEOolJ91PvCqnmfTGc5IvTWgK8ygpg6kdMb86rrVrnPyNmFNuFypxo+iqETH9hzO6RTtTRq6nf87zHlDGHz8IwUzpKBc/b72Wtd1lK5NQkMk5/MVOV2XoTnPKvoMVrjfvPPcd/o7fD6Jga7pf455zQ6qQFJ623xY1C1hn+xtaquLGQPG701/KkV9shif05UVe5AnIMxVSKpsbCyNjW+d2T047f8eLwBe5eeyRv8J1XtbTDF/9Et2Q== 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=ZptgwN0nlsw8Pa5N3Td77WwPhTzmO5puaaKFNptaSHo=; b=spUb9MhfjPSPkQxrcjukqV5zDzo/glXGY/gAoK16hOIclggw8rf05peX/gfOzv3C+CZ4h7bvT1Iz8HYG10e8cEmKzlp9GicFBd3ApDVm0qlxqXe7dy2t4udnfw3zpXV+zxSpj0n4MK3dHprtIX5vP/oRZQNC1CHSudkU/tTZsuVLoRAkZ33wNzfCRinvftvU8X6SusD7xLHSvdJYNwOgBmf1KTLqgNXZd4HED+CMNmZ57Gp7ORGg+cqcq2L7dFTkJ4Oh9RLfS03TT6dIMDijRie9x8+woyIOEvLfBxL/i9SX9hKfSoYvwcjKKUw3JYP8xK1QOysvV5TzZVLGEIt2fQ== 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=ZptgwN0nlsw8Pa5N3Td77WwPhTzmO5puaaKFNptaSHo=; b=eR3tXh7ImcI7YpcBlAM43O5yqH4oAf6ZLoPHWvcMmx5oWp2fXYWaODF44Iw1DippOfrVMNg7V+eHEZre4qd4Ysb9B8rrLD6QGOA1OSjwrVRanEDI+avEh9api1lLZpoAxqMAKuwh0QmVWLBqJIbcwaSN/K8tcoOU+T3JIbbadez9N+OyZZeNO0r5CiVvPSbgvPWemVrA322+xmyu8zKHCwWoP/fVBBugfW87r6M9bxhMBWu52cDn7LV+eZCGMKsWIxtT86NcMD6RgUqbiZv31cIbI1urkbaRnylDKGZTZgTr6peK8L8ofSmSCtziNz2zyCVAZhKrJPqQjeTXcEBMEg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by AM9PR04MB9004.eurprd04.prod.outlook.com (2603:10a6:20b:40b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Tue, 8 Oct 2024 06:27:47 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%7]) with mapi id 15.20.8026.019; Tue, 8 Oct 2024 06:27:47 +0000 From: Wei Fang To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, csokas.bence@prolan.hu, shenwei.wang@nxp.com, xiaoning.wang@nxp.com Cc: linux@roeck-us.net, imx@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net] net: fec: don't save PTP state if PTP is unsupported Date: Tue, 8 Oct 2024 14:11:53 +0800 Message-Id: <20241008061153.1977930-1-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SI2PR02CA0018.apcprd02.prod.outlook.com (2603:1096:4:194::18) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|AM9PR04MB9004:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b88b632-7f1c-453e-aeff-08dce7625315 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|52116014|366016|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: Uog5WqBBhUaWssEA1hw3PfT+X5ilqgyyA227YiKO/KNE26Hj8mABjb/INHLSYjySf2cII6cZvn1HxSJrD9yglEhh2IfAD5W5ob1JOc8yUw7AKpB/8yT7rlwfJ5ldbPfu1m5cniuzAIJwQUcGyuzIYbOpa1lgq9aJ4UpUDHbHZbm2qzecHwVsyMaVaKBpFrvh8bKOHII4e8UqQtwydvahYVCLF4EYQWDVi7GVm5Z557dSsHwyqIn716ANAIbNEz34B9xVYOrGt/CmHp+U9e4ciiAUG4bUO8fvUkADpRCzS8GElKCiLndZIop7D6SVgmL1PqI3ihrcp+es8puBAdvYcUoK24Gjo10mkgj3r6Cs/V9wL4gxQ6mXVz0HYojAYxEeI2x/5T8bQn37qfu3DcUqMq7sFf4rnOT7rQDPMRjVstqMuv9lSkt5W8xrZtaregRjV2ab50sK2UjW4KDfrHUBXiN4lr99S69FdZB6a5O7e5NKyuMAp/6ZaFgi4g/DelYEKX/bB/Px1JO1MOk86aptugUUUcrXWN5nL2DnyZx/wMzOAWxbsCj0XbWmhmwvKZpMsKpjOYSvxzEof0ocVrbIZUDOj/XOXUYc+0bHxRfftcUArJGYJ6iHvKcryPtwIDWnOg93RJ9kJRmbzQYXrHVYpf7UH9Z9gAZYKTdszdnbGANcu653iOLUTyAXhcR8DKajxYX/nqccW3WXb1f/xxA6cUk0WW9uotC0mf6JgCvrlKZoQDyvbcocZC2eK4Sx1YsLxtNTdxlsgLfmUZ2pTZa38fa/eEJ0OFu3Xez8LfGKv2EioB+Va5Bs6lSvpecczF7req7e+Fued4DN/vkrRkOeQt111fYA/ah2PB/RHMjgJG4DP8aFyD9vp82L7lcEEhGa73ruE/cDbI4IeP4d+B3qkOi0VK+1X0xOsBznpOAluBSflf6fHGU6s61SsB3RDvmGprg8jFl8EFo7Nx71VzfdSPbI7Fi8jVwN5sGrcm10b7TvAayhr8mFwivOd58M6392zDzG6BAD3ih8U9BQME8vStPevF39kqVHJbJWpBOZjKfNxBhkC0JyzbbXQmlYQzQXkDkGz9ABzjxm2Ou1jUOGBefRk66pi5tKF//KdeggZXdLOIvVjyDP/81nm9HwdphzNcPQ8HXgMwXYf7uG0ntulbZowoPfDTHi43jk2OsrpxpFW/dwjkUuCqg08bGsX2SHOrPpTR3RGzDoBMq1oWgBMa2+bVpuDPcCgce9ui0jVbIFRKjcT7mJHywlDU4/T6+4vGi1Cu64ikZDT56gCcf/O0OWnTr6MfAFX4SGDe+OfB6Zb3/aNe/2cdqJgTQiwcLUoV287kgU2sKTCJVUZJKJYw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(52116014)(366016)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-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qdkvrf6BlUKmwFrX14gv7PXP7cbUFwg28NrhB9Qp2xlSM7lFCJs7Z3rrpmbLCOM979ZYz7jQkRHeDjrEHCjINWfPN4Kfx4NISGOBgbxkUEXxQFK0Hnxx/ZrTdJ4ljM4kHW1B5v6NobIoeB7oQ6P9cQ+G95eswk1tqKCxgmcnRajS7j9MUbaufTMkqFFG5gGKJmwNVt2mghJGl8qCcJA+FkZ5jTmMph6giMJcYgqQTcX/21MjOp1bTXS5ra1K7SzMhQFfTh7XkQ9j/AYUMXw9jhCmPo5HvI3lSWZAbu/w220gEZMoE4E3sV0dUwG/4OUpPechvvO4h+bahgtZT2NKd7K/WBEVOCRHWTDBvYw+PInqOp0FMiFXpmUxC0ZRd/xkNGVMyV7XzR/pKryJMybLm2RvOwLWSWBwGqkd8fbJoQNJPwI/G+AZhsLiSgpqTWU+EZejJ1juRSZwSYVPkqdXwoQaxxkTtzfvYFo/cTWXLykplE9ed0LZ0YTQCj1UdWo2a8u/+3KJuSJqjWiPBDFahtZj3Dx3VR93MEFUGGeCUoV X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b88b632-7f1c-453e-aeff-08dce7625315 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2024 06:27:46.9701 (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: SBdw6+5M3or9VPHKtMrqSVshfWzoS2jqd/FcFY3JOCveo4mToPF9vaJY8EfH0kzWwmLvfHjncGxd3L0fFb4Uuw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB9004 Some platforms (such as i.MX25 and i.MX27) do not support PTP, so on these platforms fec_ptp_init() is not called and the related members in fep are not initialized. However, fec_ptp_save_state() is called unconditionally, which causes the kernel to panic. Therefore, add a condition so that fec_ptp_save_state() is not called if PTP is not supported. Fixes: a1477dc87dc4 ("net: fec: Restart PPS after link state change") Reported-by: Guenter Roeck Closes: https://lore.kernel.org/lkml/353e41fe-6bb4-4ee9-9980-2da2a9c1c508@roeck-us.net/ Signed-off-by: Wei Fang Reviewed-by: Csókás, Bence Reviewed-by: Simon Horman Tested-by: Guenter Roeck --- drivers/net/ethernet/freescale/fec_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 60fb54231ead..1b55047c0237 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -1077,7 +1077,8 @@ fec_restart(struct net_device *ndev) u32 rcntl = OPT_FRAME_SIZE | 0x04; u32 ecntl = FEC_ECR_ETHEREN; - fec_ptp_save_state(fep); + if (fep->bufdesc_ex) + fec_ptp_save_state(fep); /* Whack a reset. We should wait for this. * For i.MX6SX SOC, enet use AXI bus, we use disable MAC @@ -1340,7 +1341,8 @@ fec_stop(struct net_device *ndev) netdev_err(ndev, "Graceful transmit stop did not complete!\n"); } - fec_ptp_save_state(fep); + if (fep->bufdesc_ex) + fec_ptp_save_state(fep); /* Whack a reset. We should wait for this. * For i.MX6SX SOC, enet use AXI bus, we use disable MAC