From patchwork Mon Nov 4 05:43:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13860920 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011070.outbound.protection.outlook.com [52.101.70.70]) (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 EA57117D341 for ; Mon, 4 Nov 2024 05:59:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730699948; cv=fail; b=IrodUgZtbRluijhayBX/ehPLJ1XePpGGHOcp3qG2jj+upIcMbtS9CIy374tMIzkCimpCoI/8UNEi+3APCvP6WYKNiMBrWKyZoFCrsLpPijYNEVBrfTpGwzE0wZQ8klOc5gQEmGwI5qxK0oEnuDcUr5s/wg7oRdRu54p4+clUyiY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730699948; c=relaxed/simple; bh=TpOmJjxesC92ijikdMY1N6LB2jlvspErGwqu2W3aSMs=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=hXT0VL+zZF2lVLbj5PQe98PD52K/zfcw8e37zDcx/SkhqAL+F0tUZpkKG7/qe/gnJSSGdLWecKDVpHoCSZmzSeH9fMHSl/Qg17UoKS8Q3eP5MDXhmSvn4TihtkUo9+kz/qLYnRh7gr7xecpMHb8wol8T8c1R3EvPPTAO/xI0sZE= 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=NRgWnagO; arc=fail smtp.client-ip=52.101.70.70 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="NRgWnagO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V3br2J/s8jyvS0chfoG4aygRKL9oXcrip8y22LiXGbbK4LOn3sFrglrf0R+F7CuSJrr9gQUh5WI6s9J8iDqASHHw3z0B2hV2KIb481aKne8IKLckn2xPVENxv6j8vdOUUiPN+MRR4LCW7OkXimCYJET43oQhVcaSoS/pPrWDlTZg0fGzn9xvXzStAo20DRQIavOiPcuNpqwaQUXEx/7Vz732poHdl74kVrWcIsFly5lVr5xwg5WSAuRkz3Ze4/bgwt01OFtDw959xJToy1dLCgswImB4mqklhtG+cYqxJhnYBsGe/sXgZCOHyK7ON6m8vqFKXj1VMttFKLjmnWqtDA== 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=ktxnUWkN+nkx3qM8i218Ry7l4pjTa4bXYkS410vJiuw=; b=TAb+wRHuJ3OFn5iOrMf8c+BBXMcroyLRt6B3plMDSJjxKKBd7jtTH801n7bJopW98ppdD6bNZKOLHuRJjxJqSI9JTN4ugG8cMxqeYQezuJTiJgzduyI16kSBhscGIudgiXfGRAjRuxj/Ej1X+UEjTLHlLdyTf/8LhCHf60a5L87NLuopxntA1cpLQDb151hfqCz4ZrUJonyepdnxxvkcyM3G8vWj78p2TChXRzmdtg50Ud2YmyNvaMguo5tTJk/WUZo8V8OWr9WdHCgsD1/4PrZU5lTIF73adI/g5Haq7cJLTOMXfmePRiBj8Eb48HqaESFoLXwo3IgXA0HlYCNReA== 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=ktxnUWkN+nkx3qM8i218Ry7l4pjTa4bXYkS410vJiuw=; b=NRgWnagOxl9inCuGPMX2ZB0LSIwyP4Ub4kZXvkuLIxPne4MK+Mo5TFrAnbLfDmZfms5yjWcFxxPGYnxxkFNWq3bS0H08zah8u5JKiapw+MFEqjDlgXYVO1wUslm5uO/cwhm5dEEehUdH8C2gp7L0HO6jKfAxdVqAGbi53fEB4JUPQGd9eiD/8/7M5nmAJUDDTnq73yY9UmPH2TYOESN8gwUA0ULDoOSBBw/rSYJIhXRqGayStesvCfqs0flTDIsZhU7ujTjbENLGzVQtOzBT2K56t/srG9PBiCoI5cXoG9L9TID6QVO6rScbBBa5hmCFomArL9/2hnIFNK6x5eCUvw== 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 PAXPR04MB8173.eurprd04.prod.outlook.com (2603:10a6:102:1ca::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Mon, 4 Nov 2024 05:59:02 +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.8114.028; Mon, 4 Nov 2024 05:59:02 +0000 From: Wei Fang To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch, claudiu.manoil@nxp.com, vladimir.oltean@nxp.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v2 net] net: enetc: Do not configure preemptible TCs if SIs do not support Date: Mon, 4 Nov 2024 13:43:09 +0800 Message-Id: <20241104054309.1388433-1-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SI1PR02CA0002.apcprd02.prod.outlook.com (2603:1096:4:1f7::16) 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_|PAXPR04MB8173:EE_ X-MS-Office365-Filtering-Correlation-Id: 1eec2edd-8288-45ac-6a8b-08dcfc95c84c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: iXS22+Nv3kzlQYCMxK96ZUFoFp1qQigk8OHEofyFbaRZYMZUo42Cn5pro3EM7hxIy0JYbO3ju6+8x4vkrxm2bphsCea4vOcki09v/H3ms7unyDuayDciBhLtWniKqKUgHyjtTx42NaK9yCPUGkmuuko+BkpZIHnsqkzHwiGp2sJu2E8Jx86QrmGnZlwGLH6WLJnB0G0ztNjrVfUI33OVb/XsHySE/BgijE7e7j3Q/ICWenVc2U1RezfmVtazKe/FWtoWs+DSSDN9/dipN/E+/Cs7myXda2J5lFIZYTT2rljMwK+Mk3UhRnec/OmK0Q2G0SHeTeGxlvgsNRMvTlbDeimmXaOmrTTET6i34kqFEe4HbYTKn5toqifDl92266OAkiUDtzRObFP1sMfoeTDqTrrIQwb7CDYE2ipwcjcJkSBq2sF4aj58J1l9fj1D0cgczB4bkay03DlPEa4NusiKHuLpMDE4DB5gVQm4DlIPz2Ry/p01bOMzoewfW7OyXICL6BiIzXN5pHoVA7Yfh0TxbRIkjy19RJjnE+u80S6IZjzP6x5XQT4X3cR5/rIpOh4J7K2vm0/zM+N2CjnF/UITajW/iE1Nw2+TfngPiFkkcthl9RL6+aDTtXZbT8obcoIzNxhDfqiyTTwIbeUv93PyAajl5Dp58ITERFtF+oDXtbXrrKEYbII2L/1j9xjDKUZ0uFS0WzshlqFJFaNgiq3n1sn8CxNqQywBsVslX8X3GOKCYQGFmRprDImpUrh+5GSkQT7oRzto5Y9ukDO/DmUF6tb3YA//0+jNPuqFiqf9eMRcQkDThv/uq2EmBdoietIUZAxRZnC7h58rUr2reiRUbo1wp4T+E/4bnqm/1IFcznbMcn80GH8Ddc1fGkdUe3sDewrDbhG3ySUxi8kmWRfSmsyDlEAvEMDwl0/T0YzlNa1+HR1StlaFSlrzwBxELUVlKQYGJIHLAtFIPlYOK2M14gMSPWxJzLSrS6CLQieh4m/AUhnaWibPHFNCRZPPhDsSYHVC3m7Dje2L1MvBnvxYZ8XkcWv9MH+Pc2ClsSRFj2TNV7ei1fNPipu78GY7eikq0kA4qxnfbPL7AWFNo75KUlhBbX8l0ZpVPMn0aDm15oiEYD27lZvKp9Apg+YwgudT157ONriCLG0ZoKNDlK3dXHaJ6vnG1DuOLXVKzLx7m9fTQPb40VupuMrwL7OrKsi1goCVQbhG396Utu8zsC59K89R2wdeqh/i0/g4KormaE8kWACTyFrCXFfm9UHi9HGZR9b3eyO8JtC83leROSQlqrD4vHrM1Sq8EecrpTvEjk2GlrNBJ/VCoGKNKp0ZMxiKLRsaGDSocHbGaqpJEX31f+IkehboeVHQtYpqzz2sbunCvLgevBXsX9Uk+W06Orth 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)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 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Z93PNIE3NnFwRLncBFj54OkA3Lrq4k3/ZM5SBTlFslfA4EBEEhvct51EbiLBA0RC6fJr+NO3TvEaDRwm2ZLhxLnhq2hf5RcekDJ1tiIP/v9yFF1sdSq4J0GnlFwlSa3K0ol0UmMkb7CeDY5SJiWmwwHvUHby0fhPPkrSZ80BAc3G0NgDVH5w8CzXe51BrGzP8hAjU6AtfSWEThtx36oyPJVyjODaLeFgZWo6bNVoScvWu2sFbd55a9XAgZnSoRfGgALJFgecx0UZQ8BL512EL6IYDYRyPQXUZzxREGKD5OBwfpaUQcw8qsNA7l4NkT4HidO/mXfwOXyY4LnyTi0sw37izAtz5SrIAMZslilZpP1i8g0LA2n1QDbARdTa876u7hFM3tD+AU3QtDdb76x7Npo9z81wb6tURmnn7TmA57UL/PvpqesPykdMeWw45aJ26oqx5CSDNnaOZYGXc88GreEKXWDh07k2BuFsJfa6GXd4kyXQGlIBB6te+zx1AvN9VVPCBU3ZmPcBp8/R9Ct8u0KMjaq6FsFHuWm15GO6hXGh9k6 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1eec2edd-8288-45ac-6a8b-08dcfc95c84c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2024 05:59:02.2934 (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: S/OpUtcnhdbxh26PWyoJz3jNwxbEJY6TlN9ordezIAywHWIDmRUY2JUUyEjgAInmtYPFKD47zTE0rLGrv+2xJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8173 Both ENETC PF and VF drivers share enetc_setup_tc_mqprio() to configure MQPRIO. And enetc_setup_tc_mqprio() calls enetc_change_preemptible_tcs() to configure preemptible TCs. However, only PF is able to configure preemptible TCs. Because only PF has related registers, while VF does not have these registers. So for VF, its hw->port pointer is NULL. Therefore, VF will access an invalid pointer when accessing a non-existent register, which will cause a call trace issue. The simplified log is as follows. root@ls1028ardb:~# tc qdisc add dev eno0vf0 parent root handle 100: \ mqprio num_tc 4 map 0 0 1 1 2 2 3 3 queues 1@0 1@1 1@2 1@3 hw 1 [ 187.290775] Unable to handle kernel paging request at virtual address 0000000000001f00 [ 187.424831] pc : enetc_mm_commit_preemptible_tcs+0x1c4/0x400 [ 187.430518] lr : enetc_mm_commit_preemptible_tcs+0x30c/0x400 [ 187.511140] Call trace: [ 187.513588] enetc_mm_commit_preemptible_tcs+0x1c4/0x400 [ 187.518918] enetc_setup_tc_mqprio+0x180/0x214 [ 187.523374] enetc_vf_setup_tc+0x1c/0x30 [ 187.527306] mqprio_enable_offload+0x144/0x178 [ 187.531766] mqprio_init+0x3ec/0x668 [ 187.535351] qdisc_create+0x15c/0x488 [ 187.539023] tc_modify_qdisc+0x398/0x73c [ 187.542958] rtnetlink_rcv_msg+0x128/0x378 [ 187.547064] netlink_rcv_skb+0x60/0x130 [ 187.550910] rtnetlink_rcv+0x18/0x24 [ 187.554492] netlink_unicast+0x300/0x36c [ 187.558425] netlink_sendmsg+0x1a8/0x420 [ 187.606759] ---[ end trace 0000000000000000 ]--- In addition, some PFs also do not support configuring preemptible TCs, such as eno1 and eno3 on LS1028A. It won't crash like it does for VFs, but we should prevent these PFs from accessing these unimplemented registers. Fixes: 827145392a4a ("net: enetc: only commit preemptible TCs to hardware when MM TX is active") Signed-off-by: Wei Fang Suggested-by: Vladimir Oltean --- v1 Link: https://lore.kernel.org/imx/20241030082117.1172634-1-wei.fang@nxp.com/ v2 changes: 1. Change the title and refine the commit message 2. Only set ENETC_SI_F_QBU bit for PFs which support Qbu 3. Prevent all SIs which not support Qbu from configuring preemptible TCs --- drivers/net/ethernet/freescale/enetc/enetc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index c09370eab319..59d4ca52dc21 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -28,6 +28,9 @@ EXPORT_SYMBOL_GPL(enetc_port_mac_wr); static void enetc_change_preemptible_tcs(struct enetc_ndev_priv *priv, u8 preemptible_tcs) { + if (!(priv->si->hw_features & ENETC_SI_F_QBU)) + return; + priv->preemptible_tcs = preemptible_tcs; enetc_mm_commit_preemptible_tcs(priv); } @@ -1752,7 +1755,12 @@ void enetc_get_si_caps(struct enetc_si *si) if (val & ENETC_SIPCAPR0_QBV) si->hw_features |= ENETC_SI_F_QBV; - if (val & ENETC_SIPCAPR0_QBU) + /* Although the SIPCAPR0 of VF indicates that VF supports Qbu, + * only PF can access the related registers to configure Qbu. + * Therefore, ENETC_SI_F_QBU is set only for PFs which support + * this feature. + */ + if (val & ENETC_SIPCAPR0_QBU && enetc_si_is_pf(si)) si->hw_features |= ENETC_SI_F_QBU; if (val & ENETC_SIPCAPR0_PSFP)