From patchwork Mon Nov 25 09:07:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13884612 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2080.outbound.protection.outlook.com [40.107.104.80]) (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 94D3F19005F; Mon, 25 Nov 2024 09:23:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732526609; cv=fail; b=X7DcuymdD4FwXz+a+aiiT7UogoHB12sX5smkcpj3xyU6fmX4lRfh82C7SaSpCrj0x9ugT46sXAc1Auyr7Y/5IeWTIE3lBg0KLBSNrxvWuHLkYoWGD2H+p945jMMdg/wge09k0SyaD7l51i/rtAa0YgYY27TklgEi5LzGjqvXbks= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732526609; c=relaxed/simple; bh=yTJh7ddvPD6/cc6FdX1PrQpJgzcTiV+NAkmm8MVPOmw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=NRNqm0iPgvSF4hh/smGEzVR5CBA1Rv+IteUW3I5SMkN01NeZvRlJgnEr2ZqhlmJxh7QmeaQItCPY3ZJmvJX0uZLkIO8A3lvjY6+eZEiE8q4ljMhMZgFxwoza6MOVOel7IwVHG7ltTI/qkGaAJOOsedmYU50jxFl6M2kvSALmmF8= 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=QDY5l7rM; arc=fail smtp.client-ip=40.107.104.80 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="QDY5l7rM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KpUGYC+ykKiumaO0dsnukI/aUVvcFl8N9BAf34ZB6i7gTmFXSQzkPu/RzyM6AICJdI0Lv3QMzUMeByjzc0lvKDZxO+G9tmYbrejNXhjhuqS/4h5MTgfYK3DW9/XWTDHxZTh1Q3G8EuOMdgByu9gs7tlqfLTiZVE0y3F+DsKH9BWmYiaMZTrmI3xl0NiQRHwAG35mxjDS5Ec3iWAnspCWAaS84aZ8iRniiqNnxQcfPflUWebe0cBQWmtTUbVOoemS9E36tzXCtQmvrSoBv06sfCjd2/kXiOzZ06hidPnLSaeU4FZ1hjFmy44WkyfwI8WOo3WgdZRHfDD5OWGZNaf/kQ== 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=BMFcLnf3+nh21wurkg8u622bfIPqfM6yXHnyuz6Of+o=; b=yTZ3FscwVHipvsi998ixpK7Y+KkLhpUY0eVAZFlVihrhkWi+ANBBjYz4g/b4/xmHY/x9dYeE6qX5sDIJN+akIBRJV1o+RkuUEK/omyqnp991rGDT2Pd750BIwGCJG+f7j5Xn7Hr6vNlc2LEEht+bXwwY74YVN3KMs8EK89eA8LPZrDmGMWdesch5/5mC1DzMmG7TLQVOkEaRXpSvq2AAy2VlVsoxIzgroD9fK1lxYTHujWK0n81Abm6qLnq1aPul3qlDavvG6k7YsC50SRsQbS1BTAuih0pVDHj87q+mmFShlQ5IF+vr5i4GltxAGp3M9vvf7sr0VNdI48fbaQdszw== 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=BMFcLnf3+nh21wurkg8u622bfIPqfM6yXHnyuz6Of+o=; b=QDY5l7rML72/h1LuVv07RtJbVpusMlfWVAVsINwqrReryfSiVqTNi9o+9OCvbF9p6Hck+dENmROqoVopa6iFiYLC8gVEM8JlinZdYKBM041YFvKfJwz/75vSCG+wWkTGU0HlMXprdK2CB5AuyONBr2ElEleuJwO9rsP+xcvF1u3sXXWP8c2V6Pot16Jc2wpRQOhbYTX1WIgIQ7xLakkvuu5NXR2zAJ5H7A/Z/JgQW5DbUwRYGLY4Pzpr9ypDBF1LR0CQST5VtqaQNTBMiMIqTyzY76KN/PtlrReFn2AHdw75dbSc3Gh2WyK+3Bd+7m11DVVAV2sx6opSth95rehPYw== 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 AM7PR04MB6773.eurprd04.prod.outlook.com (2603:10a6:20b:dc::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.18; Mon, 25 Nov 2024 09:23:24 +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.8182.019; Mon, 25 Nov 2024 09:23:24 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v3 net 1/2] net: enetc: read TSN capabilities from port register, not SI Date: Mon, 25 Nov 2024 17:07:18 +0800 Message-Id: <20241125090719.2159124-2-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241125090719.2159124-1-wei.fang@nxp.com> References: <20241125090719.2159124-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2P153CA0041.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c6::10) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) 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: PAXPR04MB8510:EE_|AM7PR04MB6773:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a6c8734-5c6c-41db-2273-08dd0d32cfeb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016|52116014|38350700014; X-Microsoft-Antispam-Message-Info: 9bOby1a3ngap3gNA+jwkPaDKF4hTmUFtnfhMYLvhvUXRxczES2vHhaOFdRIES9A3COcHlxK7AXpZDMtWkkEJxtvZQXBPgUVfY9nIZPZHD7CQ6N7F8rzU5BKdi34AiNbO61o2tc3QmoDE37JUsWQ1zB2yOXfHKtx9AEgNJZTFErxPTTHh3+b49uGaTMkr4uzYH3QtOKP2YcfXkrcIcdkZImwiOuFBMEOCzwUuYztqWfkwFv1CWSWyNlwuBqvH4e1EpGRBKFv+qJP3l6VvksBxr3r6Gu5KUt0aBh7qDCSBDb8ylkakEjB5UdeNdt9IN7GRueAeGk+EqNunEqnKAAaUaZx1r2PoQOGdoVa7f3DbjomA1J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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)(1800799024)(376014)(366016)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: m6Vbpxf86IvfKx67hMqir3KaiCSOCcN0YLGEJhsSZWElPV/tEKvzkGfgo0MnH52dORxTeL3FTAw9YbchkjWL8brFt6yW2Hd5t8B1OLzIUTMonOfVbM1DHUPX1WPcMdKT5fJdeAQfrwy/QWjMFXljGXBM6zdeD0mTfdGT+tAMhiSVW1oRCI2koBkYMcrPbZyPOI4EkyPlzUHaGB03+sIIXgbWYwnqZIcSmn6a3eC70dOg4iRCWnRCwQiDJ6Qynp2DY1q6LAB96WkcuJTG4gdDSlJ6SRQnE5fg5ytem33IWv+sBhtlT7D7uXOigqqvEoYBlfJDu9u3Jyj/HpI1DZ34ULDDoJfCFYly8/ZmA/IAbvpDriYIeFmIPv6ewzEhjfa9otWkUxUx5gOYTr1kvsrKbIV71pnAJsq7LzDM1a7eHWoMJyH+a9u1fkEM721BIkcwaqozo5Faaw0eSAyIWsu+oXrJ4qraa2EhdDj5ddZucZSXaowH4+fJffRUH7i3HWJHVamwPFLzSgAL5yagReErTq2SkwQkx1o2SSB2wQnfmIPunexTJu0cqO91TW/aaB2M/IpGNN5POAe1vsNjaqkAkA5o7GaC+TjAe2xcKXi/Z/q1eaFHEkrmwTAX4nmUzWVmbz0s5gnyVywbTcVuzIsRfJAzlN+Ndsh1a4aoWLvEnHapEnMk0a+H3AFvzpFCLfYT+y7Ipu63y5zVUxQ7c9eCv89KP52worvA8nYM/ZQUhAAZFGP8/0Dmqp78QzFGUPsPMnGD1McKO2Qc/7mnqYgEcXCd01f31mFijCc3sMiJWL9u195AKNnU7OTgXHk5Q8QWXJsarkV+BYTnILFhIljJgUHWzrW8SgqMawhU6GIGV6EVS+P5tQbIsSDpbDS+BgURhfsTgT/NyQhU7rlWAxGJOXB0NgaED3Cd9FippVZ47pViMIft+S4movxdnco4myEU5G3r8rgvIxl1my5k1OSw8yVkU+LaxTEtDJ2IgPc/0y9nJQbUI5gF7LBxzLVdUpJj49ExE4FRxy2X3ibS4rOyjF08ph47y13guzqk3fZjeXnTQCyxY8OTXJn+0qBrt9mDoeGCtf4fzwbipEkXq31nrOAZsMNc4bw6zp2hGsfbU7rrPrQwOGDy4weBaW5lldVR+RDN7++bN7IWVbBH3J/93ze/NeoFNRl/HLn8gfBq+ko3rrwZi0qJLHlFEjO2nCmVVb+z3II9vmiCsHYiCgXlh4cYsXRxfmqDvxSIPuyWPK/kyJUb79kcBZ0/dZWW3rNgu6Dq2JUOp9UU5JYOoFVqBk09s0jvnBlfnRfoft1ImnQ9IxzKiKisgF7UYjT+/dEYYrhjYmcYT/rQ9zO1EouN1BNriUq8M9zkaUvmtsSZt0JnQmQGXMboBz0mIqSGw/rSXYVp+si/dPVjM4L5mc8HQuYAkzeEqnuROGLh58j7i9jjWm5HmWXHi5IHINT07MIdA59Q2b4vZVYdo7veImhHPInGTX/pISEQXYMIsrK7tCYi1kjDjXyDBPMuPMtqfLYEtwQYZn/LLbgA9V+wuMIei9uy1zA+yWhtF5hX4gq7PWR31CnT0pMfdbS6NHtxBwWW X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2a6c8734-5c6c-41db-2273-08dd0d32cfeb X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Nov 2024 09:23:24.6366 (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: 18zGTgn3OpMuddrGZ0QkQz0j8Hk2Mx70Ar2R5RDi/qCBKD+xqmNMFmojgWA/b/mYyNLDhBfRmeLYEI1GQZwhFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6773 X-Patchwork-Delegate: kuba@kernel.org From: Vladimir Oltean Configuring TSN (Qbv, Qbu, PSFP) capabilities requires access to port registers, which are available to the PSI but not the VSI. Yet, the SI port capability register 0 (PSICAPR0), exposed to both PSIs and VSIs, presents the same capabilities to the VF as to the PF, thus leading the VF driver into thinking it can configure these features. In the case of ENETC_SI_F_QBU, having it set in the VF leads to a crash: 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 ]--- while the other TSN features in the VF are harmless, because the net_device_ops used for the VF driver do not expose entry points for these other features. These capability bits are in the process of being defeatured from the SI registers. We should read them from the port capability register, where they are also present, and which is naturally only exposed to the PF. The change to blame (relevant for stable backports) is the one where this started being a problem, aka when the kernel started to crash due to the wrong capability seen by the VF driver. Fixes: 827145392a4a ("net: enetc: only commit preemptible TCs to hardware when MM TX is active") Reported-by: Wei Fang Signed-off-by: Vladimir Oltean --- v3: new patch. --- drivers/net/ethernet/freescale/enetc/enetc.c | 9 --------- .../net/ethernet/freescale/enetc/enetc_hw.h | 6 +++--- .../net/ethernet/freescale/enetc/enetc_pf.c | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 35634c516e26..bece220535a1 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1756,15 +1756,6 @@ void enetc_get_si_caps(struct enetc_si *si) rss = enetc_rd(hw, ENETC_SIRSSCAPR); si->num_rss = ENETC_SIRSSCAPR_GET_NUM_RSS(rss); } - - if (val & ENETC_SIPCAPR0_QBV) - si->hw_features |= ENETC_SI_F_QBV; - - if (val & ENETC_SIPCAPR0_QBU) - si->hw_features |= ENETC_SI_F_QBU; - - if (val & ENETC_SIPCAPR0_PSFP) - si->hw_features |= ENETC_SI_F_PSFP; } EXPORT_SYMBOL_GPL(enetc_get_si_caps); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index 7c3285584f8a..55ba949230ff 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -23,10 +23,7 @@ #define ENETC_SICTR0 0x18 #define ENETC_SICTR1 0x1c #define ENETC_SIPCAPR0 0x20 -#define ENETC_SIPCAPR0_PSFP BIT(9) #define ENETC_SIPCAPR0_RSS BIT(8) -#define ENETC_SIPCAPR0_QBV BIT(4) -#define ENETC_SIPCAPR0_QBU BIT(3) #define ENETC_SIPCAPR0_RFS BIT(2) #define ENETC_SIPCAPR1 0x24 #define ENETC_SITGTGR 0x30 @@ -194,6 +191,9 @@ enum enetc_bdr_type {TX, RX}; #define ENETC_PCAPR0 0x0900 #define ENETC_PCAPR0_RXBDR(val) ((val) >> 24) #define ENETC_PCAPR0_TXBDR(val) (((val) >> 16) & 0xff) +#define ENETC_PCAPR0_PSFP BIT(9) +#define ENETC_PCAPR0_QBV BIT(4) +#define ENETC_PCAPR0_QBU BIT(3) #define ENETC_PCAPR1 0x0904 #define ENETC_PSICFGR0(n) (0x0940 + (n) * 0xc) /* n = SI index */ #define ENETC_PSICFGR0_SET_TXBDR(val) ((val) & 0xff) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index c47b4a743d93..203862ec1114 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -409,6 +409,23 @@ static void enetc_port_assign_rfs_entries(struct enetc_si *si) enetc_port_wr(hw, ENETC_PRFSMR, ENETC_PRFSMR_RFSE); } +static void enetc_port_get_caps(struct enetc_si *si) +{ + struct enetc_hw *hw = &si->hw; + u32 val; + + val = enetc_port_rd(hw, ENETC_PCAPR0); + + if (val & ENETC_PCAPR0_QBV) + si->hw_features |= ENETC_SI_F_QBV; + + if (val & ENETC_PCAPR0_QBU) + si->hw_features |= ENETC_SI_F_QBU; + + if (val & ENETC_PCAPR0_PSFP) + si->hw_features |= ENETC_SI_F_PSFP; +} + static void enetc_port_si_configure(struct enetc_si *si) { struct enetc_pf *pf = enetc_si_priv(si); @@ -416,6 +433,8 @@ static void enetc_port_si_configure(struct enetc_si *si) int num_rings, i; u32 val; + enetc_port_get_caps(si); + val = enetc_port_rd(hw, ENETC_PCAPR0); num_rings = min(ENETC_PCAPR0_RXBDR(val), ENETC_PCAPR0_TXBDR(val)); From patchwork Mon Nov 25 09:07:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13884613 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2053.outbound.protection.outlook.com [40.107.105.53]) (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 50F78191F9C; Mon, 25 Nov 2024 09:23:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732526615; cv=fail; b=RiV1spNonD5L1R8BIo1MsAfp8adELH/tJRvJw97h7VREZuUTmgaXldHW1WF6+HnfD0LiCjK68lvhP/lL5LBexpDYd4wcpBLb7x0hvemkuOHkgTvKWkl0A2kgFnQDP9RFydjsDUklkfmhJeV377D2b1Mf1h8rm84rbdz6VV6ZCXY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732526615; c=relaxed/simple; bh=Xido9d/rfQqCPZ4ilYIa0q7WL8tg6FLXpdrmPTgu75w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=UqkmBYeRXDVrGl3VWavF6MiGDmWxD42HM8SuUIElytCDJ4p0Mwhtgcv3o72KGRz4stDiUOWOGT+f2wzQkYF26fuyded2HY23rloWoT0BZ1xVvKM6iSmhEoHxvqxEAL2TiAfEs+SZNNf3bQLouIK7bel46SXmYiBMWo/y2XTJ8zE= 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=XQwWdwg1; arc=fail smtp.client-ip=40.107.105.53 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="XQwWdwg1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sBOgCqEkOQ1NGmhObxMY9ECS9IVAY1pzHelTq83WXQFLZ8SCM4KVHltbyCo4oMY3DNckkYULc7/BfzCDI6G0g73Lujh5sJbycH43mTNgtLIiPhLFDqBWiUREYhV7QzijtH/QzLjxAVfv7trDihf6xSrVucfo5aXiedqoU3npG6GA4vebKizJmBWt0oHwWhNagkiPL7RaG4k5kJ1SEPDTStvbHjz7OlBbuvu4dkr52nKNKUcmXBrmHd073GaoITaRzjhpQKMHG/VfNT+6tPkK20DqGXz6ELdTbcVEwbfJoN7jMbFsRSSXXcWgUf8T+hwznq+ZOecXbAOjNbY8onKHgg== 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=7MPxxxCutL++lnq4/rKOPtsMN9A0H7NzOV7jT3Ylboo=; b=V0kDjO8mhnY+nwZ/yi/oYlxY6cRCwy1PfUT1p2XQREX/sax/NqvhcSLDPu8VBWmpqJ2mcVC3t4exmpHcrpyIPzMPaHlI6Q1zKGNx8K/IeiJi9ziHM5Q+Pf8Ap/ITawiEDRPshOsuS6kBQAiIMHucl2v7nAh8PiAINkCTuE1sRBlSkt6LKD35LmmLgkp20VRztY1My3xTBrhbnQf+Go7Dc1n5rSsUTpZL9zUxSfmOZ5kTUavPwYG2pmOtHjlZF3Rjb7Z7s+PvdPOqZWlaW9EOrSX87fSdxcpBA48EpYl43zEniUw48A1oH5aQeNWKLaPTkX5Ra1szuA0GAoBDkq9I9w== 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=7MPxxxCutL++lnq4/rKOPtsMN9A0H7NzOV7jT3Ylboo=; b=XQwWdwg1En7+vnAEWjRnfphTEM6RC7YMtfXVHEI7OB+TfHfnEZJ0FWxjvtM8FXuvEPrGKKHHxpyBeQgEODU0IVJYeRbvWFNIdcmmTL1/7OUgFfPxIlWmYjsZXGrXYinpE2K9ttyMQJWM+NbdMG2zglSvNDUnD5KUtcW6ULPPIaMTwoS0aRre2pglYYmkny4USssPnFs6LdKbmnY+mSg/UIsRkV4phQ3Qzx4iCYILizeENl7PKNXpj/WagPvPe4cZwXqX+Z2pdCQFwDzxhugtvx+vcS6a55YKTCOzSMNpEZ/BXCkdhqinyh9ITohjUNE/aG0mQi1/mcYL4BcgqmxVTw== 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 AM7PR04MB6773.eurprd04.prod.outlook.com (2603:10a6:20b:dc::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.18; Mon, 25 Nov 2024 09:23:30 +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.8182.019; Mon, 25 Nov 2024 09:23:28 +0000 From: Wei Fang To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com, xiaoning.wang@nxp.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v3 net 2/2] net: enetc: Do not configure preemptible TCs if SIs do not support Date: Mon, 25 Nov 2024 17:07:19 +0800 Message-Id: <20241125090719.2159124-3-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241125090719.2159124-1-wei.fang@nxp.com> References: <20241125090719.2159124-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2P153CA0041.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c6::10) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) 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: PAXPR04MB8510:EE_|AM7PR04MB6773:EE_ X-MS-Office365-Filtering-Correlation-Id: e668336b-8a1b-42d3-a648-08dd0d32d215 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016|52116014|38350700014; X-Microsoft-Antispam-Message-Info: ESvMhiRIBBc1UckuXB441MwjLlNazXzfKcV0kPj3bRQ62wUJ9TQ4WtTTrVQ9dh42rivJom2zedmNHQtpk8sUm4uRFNewqQN16HuHgcrrb6EnrXCx0rm1byCLsNJl9PehftNC7e/lIHSDKjazQSF9U+d1dpg48hILt4cp8D62oaWCZXEOmVSeN0YogeR3mpZwxsJ/Pmfd9/YwvNM3YZWCq73vGG18ZQTuC2uecSgNiJherBfk39m0m3tqNEoVNO8dnF0kCW5phFt4FHu9DSDy/69MasHSRQeVTYgQ27ckYGU9PG5hEscU+VFKtnDi2cX16+yVWAF8X1rPoyGzYns0M3zrwoMqiBImpdKOFlGZta5nF0I91AinJE99R/DSNAtgBz68mIZQjgASQ1saL99HSjwLrgBsN7shryA35U5bOLZo6OyOZLoYIPF3OWfkX4LH7qC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04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BtbQhZ1GptU59VLpq9MtYH4tNxFbu5ZsAvB0DkunxIxr7qmdAP9rXCim8Qj4t0/Jrbqd+8bNSg0O7Xvrh/zHAO80m3Ozt2TxeGbkxoMOqa+AJIYbO9HSF9btu8hxWABhbMy+xXrRzIWEm4wVjmff9SGzHBt3X1mgVywaeAi9AQQFZFs9sHIKMYnD77ArG6yaJk/RFPCR/kGqmnZ3UieySPN++Mhyup+exbk/rmjHh0d+ZswVCUxQz8ZQqPjHuiCfYmxm6GcjscMNyqEW09pp5tQWGa+57P4bLuFwNbH526b/VOd1fk4UQkZQGXZbCj2PmCP4CO2K3UlzFjSe3rFF8ezDkN+BUV95nCUyskL+jRskoW3/btFgxqOQmrgs27I/hn9cC9u73MGSj8XFI4ZHnMqArCVhJC0ifm1s56amMAggil5QKI1yyFlNZ9pJSAuH/3PD9xoBay2s6ql9/O4q/Lrg/GHfgM/cJKqEki70FANJTlyQDPXv4P6aA2cr5eYvbke6q/cRMAumeN0tDqzrMqXAPJkjFqMa/NLIXYdyxD1HJuvhb8uTTOjpivcNerHtLxJzKeTEeadCTy1A5oG76FeRmmrH1GR0hOz4oTDdYzPd+iRbbh0BqUU3tZF+4KPaZVIVCYZO9mHw8/ECb5+gEzfwp4B+gHUcX5yk1sBSR22Y+SlM+oHEIXelsjTlZMosYfATV9swNplLCgvKWobDWU5p7ivViCpmCXKvXo93oqysmLZoNmm8AYiLzeHQRyT25DcUjaSJ5XCwa9oGM2sXMrfQyGdyVBh47kAUYjf7/u8HN6BxgRTkOhCI+ofGp6wC24w3eGPj/iBjS3fPDZUFQs9dZw92qJMP1lgrb4Sxm//1ew4GFD2MXn4ZPvlm/RiFf4na8fq9aCEoquzoNPUCg+F7rAtx1BG7UwVgONZDWK4h8cFKZwlWpViSnocUt/hckjhRyHYPkqkKMkTw2ByyDdsZFO68EHEkAN8h5NsBrns/FFWa8A47sw42AMV2UtAIyeBVf8kSonCHO+p0KVF+ZxZYXVx4M3AWTSI7XSKzMUl6B7489qU72yC+e5Fz4sTVcIGZNcnULbXTZAmzwaeH5+i0ECHKeC5siZYO8ESV4gcAsu9pmE+XYRsSrg/+q8Z622C0G/K+pXKGDxt6mBkdCeB0T/Z7mShrgFTGVDPBRKrPB/spSEBNarMZnDre2seEOJ7RLhiIStvey0ofwozPBSDx/KyiWQF6nXvca2q0sPiHkK8j59MHW9Zy4o52DSdLhHsNukjR+ljcyY13yMSa+z955XT/2oAoYO5nBM/GMMZY20+BWV+htCUzlR9of0vLY4vqeKqHQpgr27CkL48HTFunlldWQZNp53eDuP4eVSh9d3fTPkAV+y19N3EaUmxF2dKupw/NxlXY3wh+Gph57D146AGlz6VsrP6psnNl74adrREeSlshr9X2HJizINacrZRshYEBdVgy+oVGPw9+pyIazLRBh43VdH/VzGkjfKWK1Zeav2keReHiEW1Qi8WX7K7+T4oVA+B75l9STtiEALKkeuW94bOwKl3F+6PE5Zvt2Lr8oWaxE107tndYy9/1 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e668336b-8a1b-42d3-a648-08dd0d32d215 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Nov 2024 09:23:28.2917 (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: YIkalf4wqDEFDPdZZZR/Uz20mxm198czKqvVhBHwoGPNLXivGu91T9KicLSCsUkXKTGI7B1f8OcHWhfk0hz34A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6773 X-Patchwork-Delegate: kuba@kernel.org 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 crash 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 --- 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 v3 changes: 1. remove the changes in enetc_get_si_caps(). --- drivers/net/ethernet/freescale/enetc/enetc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index bece220535a1..535969fa0fdb 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -29,6 +29,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); }