From nobody Mon Apr 6 20:13:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C98A5ECAAD3 for ; Mon, 5 Sep 2022 17:02:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237653AbiIERCM (ORCPT ); Mon, 5 Sep 2022 13:02:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237395AbiIERCD (ORCPT ); Mon, 5 Sep 2022 13:02:03 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80051.outbound.protection.outlook.com [40.107.8.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5870E5E32A; Mon, 5 Sep 2022 10:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SwhQs+gId/+usHHhAq6sXGJUmYTl3SbYsA0RQLdNVn3aN0S2Xd31iofyNidioEs2RVsQxEnTtd73V9KF7v9kQq0cXDdXEh7tR7+fwpYg4HN778tX06AZXTjQN4qA1vcq5b6Fb19gVO7Ng67TftGfkciRjDJwR/KZSKn9Su9DDTqzY8lxKHKACwB1jMXhaf3mq74E47z3PIKtNGRtPwcqbWUeLjAdQhiwRMF9eIMTEieE41aVfGNLaLpZ/eLExtpfg0w6SmDP5vZ3Z4aphv47Z5spl2FmoE7vZezLwH2SUtwdTPXeQ7H7lYCFSc9z6fPpAi/VJzWNkO1xd5qZIlN3Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=gwsbrN5FDWrq4WfWAhnkC/lVFCbjRT2gzxMDvfrXLlA=; b=asx9puZ5pNahUZ9mqC7E6CanKkYkwn66XdS41rFfswLDnB0usSV2DA/CsBE2zsqqunstegD4IMDcPu3dfEzjXTGjdW9jujIHLc7KKpIoYC8gWjTlnyneJsoGAOXZ1lbukVYyyFipoE0oBBooi0fbj8Voj1bPYgMbAdQaG95BGX0PGrCsbae8q/M3EDoQPQeRtSF8739RjWHQmipqt4k1PPgXuGCwFpIFMOqiXVwlPj0DXN23haDYU63aA/7wYX77lvNVfyy5I74Pm16dbS6lgVYQ9aEeiSwFE1LyT81jICx/eZkQ6KY2ET5z3wtWDzcIgB22JcLEVYuWhiau8ZVt5Q== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gwsbrN5FDWrq4WfWAhnkC/lVFCbjRT2gzxMDvfrXLlA=; b=rFKlRveH3Rpaeo94lm/G1zCujX1Jglt+mEd75wlI22BP8MEestQUWMabWJPITwdTgYbFhBmMfxvTL4eKIF2FL+FEQ+AbVcL4KkgrIkqBIuLuD9BNQ8/77aImCfcxQktTIHXY+5iS4II6Ll0XCFt6R60cu0TeXCU+rjafTnAYvqw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM0PR04MB4803.eurprd04.prod.outlook.com (2603:10a6:208:c7::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.18; Mon, 5 Sep 2022 17:01:58 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3412:9d57:ec73:fef3]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3412:9d57:ec73:fef3%5]) with mapi id 15.20.5588.017; Mon, 5 Sep 2022 17:01:58 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xiaoliang Yang , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Michael Walle , Vinicius Costa Gomes , Maxim Kochetkov , Colin Foster , Richie Pearn , linux-kernel@vger.kernel.org Subject: [PATCH v2 net 1/3] net: dsa: felix: tc-taprio intervals smaller than MTU should send at least one packet Date: Mon, 5 Sep 2022 20:01:23 +0300 Message-Id: <20220905170125.1269498-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220905170125.1269498-1-vladimir.oltean@nxp.com> References: <20220905170125.1269498-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: VI1PR06CA0140.eurprd06.prod.outlook.com (2603:10a6:803:a0::33) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 17cd0884-a469-46dd-3750-08da8f6057e6 X-MS-TrafficTypeDiagnostic: AM0PR04MB4803:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rUKHCtHWCeISNm8bOAg3GFHi9hJJqUGKT11mnt41wZLqvznaKF0Inf9NCxApUKN53cJXP7n2K7h1/kEp4FNw5uN65P/dZiWlMP4RFCbzlprS5qLCUtwsfK44/J0vcQzPOARXMoFEbbWiGlxr1qO9A5bd9UHEJjqaqZ1a9Fa6GpR8ZG/fjzjVPXLGLUb1ubNK6OO1Orgm/7iTBvWSMBRHvwXtLzqvKnkZnLNrXascODzI8cGERlMK6LG3Bktra2cdWOwpp010VMwLRzqMIHUXZPD4ByA3jvOH8H70VnOolzJmIc/f3gLsr6pBTwxCkPW4TUGkLtvPRN5qvpq8AaCNUJkH0R7IQnHdN1ZY1pEltQQyQlewdAgDkHu7S4bJWoV4p9MnbaPxXvDR5cfBPXIsI677iQctVTa+7Nv8y/nbpsuBnarqDJ2i/ZZ2HxUa3G1FnNSghtQwF0uKoq/F7C+vWO8d06ZdjSVRpIEagiLXqDhbCbHZpZB3jVAarrCjCAE5NC4CEe8fILE3rmBdprFK+AhbmUeg1geeTLC/PjJQKKpmVEAzYlOKiTE5nF7VK7iyWfQL8qNMrOnKDv+N5mUfbQSb0iyz5YxmLJgbb+l2zBEtXEVPVw8VnOEGsfSoI8hAR8IeIE9s2GtvHEuE/pV+RIAOvPwF++0HBA55PXLYVU/wRWd5KZtyleYfQz0nTEWO7qQxi96pFMTS6lSTC+DuEYE5hdAfflAXHVLiKVm2x8Om3RsuAIYmmgFMCmXfA0BAk8xUp7A2DIOd0/SHLGQ/ag== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(39860400002)(366004)(346002)(396003)(376002)(136003)(186003)(6916009)(54906003)(1076003)(2616005)(83380400001)(316002)(8936002)(26005)(6486002)(2906002)(36756003)(6512007)(41300700001)(5660300002)(6506007)(52116002)(4326008)(8676002)(44832011)(38350700002)(478600001)(66946007)(38100700002)(86362001)(66476007)(6666004)(66556008)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?L9y6anLML104VetAOPseE5MQVv80nZmgHBWuYbMd7DcKnX4zTLKCreh0BpC1?= =?us-ascii?Q?ftyfalYk9bzLkofolvhzLYvwEv17YuOVBUeO+ZMucyK/F3lwwMJ5PjGLTYq5?= =?us-ascii?Q?OJlljiXcmKAgOycg/FdZ01e8kcDbyvJeookxJyHLLGJ9W6QEgL/N5gu6S8N1?= =?us-ascii?Q?FvUe+HUkQI5DqpLyjwaT0Ei63ptsqbisgC/q+/vclOmyPMl/ZkaFv1SIpy8r?= =?us-ascii?Q?aNu2uHpVRVu+6jhMysuEvrzyFSnH+ISd1CGOphIMrdZi2PH7Ud2oux6obJQ5?= =?us-ascii?Q?LqTFX8zdid70srZ+t4p8XvlKHmXBNhxTOEBRKR9W/h9bv+cQHZ3YmX/Q1/dW?= =?us-ascii?Q?ulcxImI60XKVpNBESM96eydq+mQCjYsEZ70qPsUw5rfOd2DzB7Nj/oIq8/Nv?= =?us-ascii?Q?hHmU1xyQSB1NNhywliXL3B7ojcJUjzzd0/fGYjFkkVy4YZYxKUHrSOaMWhSn?= =?us-ascii?Q?TDC7zpKTEkxFF1QfmhnOxatVFuLEHc+Lc1VNaC6964F5mKFhIK6L0D4YvSRH?= =?us-ascii?Q?bGPbSQZsmItVtGzEFzwmvkjX1WRCqoU6ebN8VGjaWA2RqyE0e3xvJR+5DRZ/?= =?us-ascii?Q?nWNnl+arvPHDDb8EMJbxGoxHU23k3pgPFuzldP5xUqppXcP9rbM+dqw7C9vQ?= =?us-ascii?Q?fUkUWU6boNQpMOcekfKyJLXotyLSiFcqOtS2MbWQAhTLfe5pCQFC8FosQc38?= =?us-ascii?Q?fIbuWEHnYXvJt/QQ2KnFCto6qazKZgjFlc+sWkmBqQGQaU7U9Tm4mP1O1WEi?= =?us-ascii?Q?iXVWd5XYmn/585KH4Wz+dp1GXqZ+d6fX2x/WAt/WWUZzN6IuvTGijVXWwOvu?= =?us-ascii?Q?pdhKA7n3+tnatQ+VqFSFWrTBVg9NMBIC24ww8ZKqkRbxlv5JjF6umewv8CdX?= =?us-ascii?Q?bz1hiEKe3tXfnLqpg9qtxeIXIjwBYs3X8vPvbCJuLYWeGoFJoxCkCfZ6XsLX?= =?us-ascii?Q?+tzntVNHWVD+tyoM48r3ZAMCzMplyrpv9Afowfg/4uknU4rS9zxOJiY3DEC2?= =?us-ascii?Q?n6FQXq6SzMhQYnNgii7E03svGEeDD0nRnZm8AQzR0IEgjzbot9z/dLYQODsd?= =?us-ascii?Q?CzweoPjg01p/OZj/qq8YVWgsCQkaGTiEOM5ZavVjzfPElR61V3EzCBXner1U?= =?us-ascii?Q?kgx8HelcM45VBD/lsjMN4yNaz2ndwZZWqan1faTbfOXzVxu0+2ZrrVIn4YRP?= =?us-ascii?Q?tKaaDXGrwO4IrliIM8Gk5i8hP8jpQGNThplsqgbjEP42T3fei7+gJVLT46Z9?= =?us-ascii?Q?xvYxAf0jc/2Mix182nVuFOggx2Bn9NFmBEETZ/lvsmT7GfpcZLqKoEGO79vR?= =?us-ascii?Q?wN0fnNlL5VF4zAnYOANR4w8HB6khyy+eRB13grhlGoB4Fyq9s44WP4EGpMC1?= =?us-ascii?Q?fBKj5AS4xpeYrJ+lmqTptWvvSEjW5YMF1WfaU1U7nxFV2RbzPVH9goSXPhg1?= =?us-ascii?Q?D5JDaAw8fcs5a4h/ChJ4JKeABs4ev1TDwtNd4wHDooW2/LgPw+MwhV9kAy6n?= =?us-ascii?Q?bREeH/7rF9sg7zfSB+Q/XYFGI23azUChIP9SmnVxhLcOA/u7pjlaVrXVmHLg?= =?us-ascii?Q?MQHa+/5ex5EDmZ8VoGInbLF+/CGPp99DICJO7P6hh97ZdLzOhWcMjOLJXIuF?= =?us-ascii?Q?TQ=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 17cd0884-a469-46dd-3750-08da8f6057e6 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2022 17:01:58.3183 (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: zY+aTIYZhAuaazex8pxhheWXdmmYDRDHhP8yPamFZbDv4Bp8e28eVgBahSShm/XAWUH1HjVykYbSxfM2vJi4Tw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4803 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The blamed commit broke tc-taprio schedules such as this one: tc qdisc replace dev $swp1 root taprio \ num_tc 8 \ map 0 1 2 3 4 5 6 7 \ queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 \ base-time 0 \ sched-entry S 0x7f 990000 \ sched-entry S 0x80 10000 \ flags 0x2 because the gate entry for TC 7 (S 0x80 10000 ns) now has a static guard band added earlier than its 'gate close' event, such that packet overruns won't occur in the worst case of the largest packet possible. Since guard bands are statically determined based on the per-tc QSYS_QMAXSDU_CFG_* with a fallback on the port-based QSYS_PORT_MAX_SDU, we need to discuss what happens with TC 7 depending on kernel version, since the driver, prior to commit 55a515b1f5a9 ("net: dsa: felix: drop oversized frames with tc-taprio instead of hanging the port"), did not touch QSYS_QMAXSDU_CFG_*, and therefore relied on QSYS_PORT_MAX_SDU. 1 (before vsc9959_tas_guard_bands_update): QSYS_PORT_MAX_SDU defaults to 1518, and at gigabit this introduces a static guard band (independent of packet sizes) of 12144 ns, plus QSYS::HSCH_MISC_CFG.FRM_ADJ (bit time of 20 octets =3D> 160 ns). But this is larger than the time window itself, of 10000 ns. So, the queue system never considers a frame with TC 7 as eligible for transmission, since the gate practically never opens, and these frames are forever stuck in the TX queues and hang the port. 2 (after vsc9959_tas_guard_bands_update): Under the sole goal of enabling oversized frame dropping, we make an effort to set QSYS_QMAXSDU_CFG_7 to 1230 bytes. But QSYS_QMAXSDU_CFG_7 plays one more role, which we did not take into account: per-tc static guard band, expressed in L2 byte time (auto-adjusted for FCS and L1 overhead). There is a discrepancy between what the driver thinks (that there is no guard band, and 100% of min_gate_len[tc] is available for egress scheduling) and what the hardware actually does (crops the equivalent of QSYS_QMAXSDU_CFG_7 ns out of min_gate_len[tc]). In practice, this means that the hardware thinks it has exactly 0 ns for scheduling tc 7. In both cases, even minimum sized Ethernet frames are stuck on egress rather than being considered for scheduling on TC 7, even if they would fit given a proper configuration. Considering the current situation, with vsc9959_tas_guard_bands_update(), frames between 60 octets and 1230 octets in size are not eligible for oversized dropping (because they are smaller than QSYS_QMAXSDU_CFG_7), but won't be considered as eligible for scheduling either, because the min_gate_len[7] (10000 ns) minus the guard band determined by QSYS_QMAXSDU_CFG_7 (1230 octets * 8 ns per octet =3D=3D 9840 ns) minus the guard band auto-added for L1 overhead by QSYS::HSCH_MISC_CFG.FRM_ADJ (20 octets * 8 ns per octet =3D=3D 160 octets) leaves 0 ns for scheduling in the queue system proper. Investigating the hardware behavior, it becomes apparent that the queue system needs precisely 33 ns of 'gate open' time in order to consider a frame as eligible for scheduling to a tc. So the solution to this problem is to amend vsc9959_tas_guard_bands_update(), by giving the per-tc guard bands less space by exactly 33 ns, just enough for one frame to be scheduled in that interval. This allows the queue system to make forward progress for that port-tc, and prevents it from hanging. Fixes: 297c4de6f780 ("net: dsa: felix: re-enable TAS guard band mode") Reported-by: Xiaoliang Yang Signed-off-by: Vladimir Oltean --- v1->v2: - add Xiaoliang's Reported-by: tag, since he did report the correct issue after all (my bad) - reword commit message and explanations - reserve just 33 ns of min_gate_len[tc] as useful space for scheduling, rather than one whole max MTU frame worth of time. In the given example of 10 us tc-taprio interval, this raises our useful max SDU to 1225, compared to 601 octets in v1. drivers/net/dsa/ocelot/felix_vsc9959.c | 35 +++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelo= t/felix_vsc9959.c index 1cdce8a98d1d..262be2cf4e4b 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -22,6 +22,7 @@ #define VSC9959_NUM_PORTS 6 =20 #define VSC9959_TAS_GCL_ENTRY_MAX 63 +#define VSC9959_TAS_MIN_GATE_LEN_NS 33 #define VSC9959_VCAP_POLICER_BASE 63 #define VSC9959_VCAP_POLICER_MAX 383 #define VSC9959_SWITCH_PCI_BAR 4 @@ -1478,6 +1479,23 @@ static void vsc9959_mdio_bus_free(struct ocelot *oce= lot) mdiobus_free(felix->imdio); } =20 +/* The switch considers any frame (regardless of size) as eligible for + * transmission if the traffic class gate is open for at least 33 ns. + * Overruns are prevented by cropping an interval at the end of the gate t= ime + * slot for which egress scheduling is blocked, but we need to still keep = 33 ns + * available for one packet to be transmitted, otherwise the port tc will = hang. + * This function returns the size of a gate interval that remains availabl= e for + * setting the guard band, after reserving the space for one egress frame. + */ +static u64 vsc9959_tas_remaining_gate_len_ps(u64 gate_len_ns) +{ + /* Gate always open */ + if (gate_len_ns =3D=3D U64_MAX) + return U64_MAX; + + return (gate_len_ns - VSC9959_TAS_MIN_GATE_LEN_NS) * PSEC_PER_NSEC; +} + /* Extract shortest continuous gate open intervals in ns for each traffic = class * of a cyclic tc-taprio schedule. If a gate is always open, the duration = is * considered U64_MAX. If the gate is always closed, it is considered 0. @@ -1596,10 +1614,13 @@ static void vsc9959_tas_guard_bands_update(struct o= celot *ocelot, int port) vsc9959_tas_min_gate_lengths(ocelot_port->taprio, min_gate_len); =20 for (tc =3D 0; tc < OCELOT_NUM_TC; tc++) { + u64 remaining_gate_len_ps; u32 max_sdu; =20 - if (min_gate_len[tc] =3D=3D U64_MAX /* Gate always open */ || - min_gate_len[tc] * PSEC_PER_NSEC > needed_bit_time_ps) { + remaining_gate_len_ps =3D + vsc9959_tas_remaining_gate_len_ps(min_gate_len[tc]); + + if (remaining_gate_len_ps > needed_bit_time_ps) { /* Setting QMAXSDU_CFG to 0 disables oversized frame * dropping. */ @@ -1612,9 +1633,15 @@ static void vsc9959_tas_guard_bands_update(struct oc= elot *ocelot, int port) /* If traffic class doesn't support a full MTU sized * frame, make sure to enable oversize frame dropping * for frames larger than the smallest that would fit. + * + * However, the exact same register, QSYS_QMAXSDU_CFG_*, + * controls not only oversized frame dropping, but also + * per-tc static guard band lengths, so it reduces the + * useful gate interval length. Therefore, be careful + * to calculate a guard band (and therefore max_sdu) + * that still leaves 33 ns available in the time slot. */ - max_sdu =3D div_u64(min_gate_len[tc] * PSEC_PER_NSEC, - picos_per_byte); + max_sdu =3D div_u64(remaining_gate_len_ps, picos_per_byte); /* A TC gate may be completely closed, which is a * special case where all packets are oversized. * Any limit smaller than 64 octets accomplishes this --=20 2.34.1 From nobody Mon Apr 6 20:13:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5353ECAAD5 for ; Mon, 5 Sep 2022 17:02:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237822AbiIERCa (ORCPT ); Mon, 5 Sep 2022 13:02:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237618AbiIERCJ (ORCPT ); Mon, 5 Sep 2022 13:02:09 -0400 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50056.outbound.protection.outlook.com [40.107.5.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 946A661B08; Mon, 5 Sep 2022 10:02:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jO3zr214gFHTcbOVxLEli3U9CF68vE8cqgjLdEa29i3p3soAJ9+W+N5fNDjUaZp6QmVS8EzENrz76XhaAHNvQYbeuUWQo2BDhP3IEBxgFtepPUnShiq2zfzAjPb01qHzaj11V3xvyK/Bqa0tgdkcE/hQIC+fgtFhqpeikfLnKK3U1Km3dWZhVwHEoDXNrWWTIqdTKSJoQ2NGwRgqJmpmlOVTAf+AmNTn5U6c5tjfZ14XUjbm2qL9OXgIn1CoY25X/fFmr5iXGB6oIcITh/LKUlmoQxyUY8L7VRJGHgJLD26UN0uOqHR35UT+ZQ8PREIXkuNcD4odjuV57rtnE9mWjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=pLduDSul0k5tZYWtZZYwVBSNR01yuZO+d3URa1bor9I=; b=H8yFneZRldU9KRFc2C5jx6X47NO46izqJeu59Njt16B5zyLoRCcvNNwsAIMLQERhQSpZdjMIF85Xt4trzglIyJw06xVlyjZvZJGrHm6EmSUdzxGOuLUk/hm4qcI0i0FvjkBfjzzWQz8MnPTYD0kMarQ3OKE5B6vFQrO1vyETBSRgAjh/vWgWOJVQsYWnwN5sBhJHpe6Nd9HPJVhIa7cRQ7VJ1dcORKQvFUMMrDoxJT4JvzhgDYJDbYOwHKOF6LFiquInX8DaIDPCtkJS31O5r5JkU/cel276u3JOUVu7XVIF97boN1vOIwUXPTAITHqAQ48F89YTArzjk29EVY4XQg== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pLduDSul0k5tZYWtZZYwVBSNR01yuZO+d3URa1bor9I=; b=h5B9s1CCVrwwZxxT/dljbE/b9il72UfaJlG43F1gESdCZwcber6riyfLrDf0NaipXvqI4G/zt19kvGnfwFolKk8dU/GR/ryK3HwEIdKava8ZbM/DQ8iXGHfMSTdsjyuuKl2EZRKZ9SYK62eQLTMBO5l/ZLM0RzmaV65rNfmUzk8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DB3PR0402MB3897.eurprd04.prod.outlook.com (2603:10a6:8:12::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.14; Mon, 5 Sep 2022 17:01:59 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3412:9d57:ec73:fef3]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3412:9d57:ec73:fef3%5]) with mapi id 15.20.5588.017; Mon, 5 Sep 2022 17:01:59 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xiaoliang Yang , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Michael Walle , Vinicius Costa Gomes , Maxim Kochetkov , Colin Foster , Richie Pearn , linux-kernel@vger.kernel.org Subject: [PATCH v2 net 2/3] net: dsa: felix: disable cut-through forwarding for frames oversized for tc-taprio Date: Mon, 5 Sep 2022 20:01:24 +0300 Message-Id: <20220905170125.1269498-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220905170125.1269498-1-vladimir.oltean@nxp.com> References: <20220905170125.1269498-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: VI1PR06CA0140.eurprd06.prod.outlook.com (2603:10a6:803:a0::33) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 963ebb03-c450-4044-7b28-08da8f60588f X-MS-TrafficTypeDiagnostic: DB3PR0402MB3897:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8tW2Txd7n04iz/CCtyCl6MD0jhMyCJLhvrQFZiH8aevAMVrBTLO/BYhbiwW0RJkLryLNO7miH+NSCaCXZB9LV1VCLul4QGi1zXO6ElzT0tIPKOzWke4C5sYpKmo4Gnz+HRVQSrWeSexpR8HmvnAByuXnLmDEXCug+pbAZgU0HYYi2efvokF4VsjwVEZrvjVhId3gDN6jURPpWlG2cx5w7QOJzZ7oQzDjea6L/rPg9m212GnqQfUAsW9EsivgfT6CZHxjvZ6faUWXJF5yUqud1R30vXsFl6wDyTKOTNfZIxCIO0iSLn01bL1+hkmlGyLZDRkwryGHO7NJ0NoIO4Ff4uYOlnfF6Q9rr7EWGVWjEGDnKxYt7WY3YqZZlrOBmcvz/0H4nY3lvbpwjIUnGhNQOtG5X3PFJ164QzDZW+WQmgo0begTDcWnOJ15O3i7HchCmBNwfJgF+kqm477/0r9zGZ6KBH5qlF69Bma2pyJCPSIuMgHBtCbGgho9jX8/Feaw/4V3q75JDFC0xfAjmFO3dtTm3dqkZcWBdhcOJ6I70sWMz2LoTqbzpWArff/0GNBjfkmjeM5BLU0auJgD+Dws+vCsjhy7/I4HHIk9SOHTKjaKJm9lVW3/rN5IZw+4zBU/+sQhxGxIGn6JrpoTEmQRWs1MeY6UhwyvJDtO204Ld7Z6iUR3iA+cp0940x+YA7lkMYAsFVmT+F1vrh5mcRkcVGYLtjeHDVutiNsioPn/l9KiWBJYIMxP6W3LGJH0kJ0TzDiLWrtVgntud1RlvZYLjA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(376002)(39860400002)(346002)(396003)(366004)(136003)(6666004)(8676002)(36756003)(4326008)(2906002)(8936002)(66476007)(5660300002)(7416002)(66946007)(66556008)(83380400001)(86362001)(54906003)(316002)(6916009)(44832011)(2616005)(478600001)(41300700001)(6506007)(6486002)(38100700002)(26005)(6512007)(38350700002)(1076003)(186003)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?gQ76oRbjhRMzUHTEHGFiDC3nuO0weWpxDwa/EE7VEb2AnG14yCmj8vTvc5/1?= =?us-ascii?Q?ri3T0PF4TGzatknP+VruB+fSBoL6kh0E93NlX32vngFJTHS5n81KOqBNCfV5?= =?us-ascii?Q?3pJhSuIWonGK+qljRkxm8es2nTYBYEuWL0IqRL6/O58r44n61ki3upjyNSF1?= =?us-ascii?Q?kWlqGSbT5wcMX0IV77znBCF6keJVg6+hmFRQg4GFA/+qLkVVh8DzoDEUHhfj?= =?us-ascii?Q?EErFCnqWyJkfjaMXYpUvpxy6EqUy4h2elcYIRJV4EN5X1D6D0oy5j34SsIBC?= =?us-ascii?Q?KP9TYc4zXO7nxJW/kTvzMZkuwMgmTtbIfSoDsvIqcGpTcOh5aXS3pRISjHi+?= =?us-ascii?Q?6O0nnLWC9FdO/0k2vGr+18uyc+cWDPsR0eNDcM1nRX75cJVhrQWUSqORSQCe?= =?us-ascii?Q?+5t/f84/Ps8T5ZIa8OqNxZxDYnSv9cbLoMuRyS3u9WcoQ4pypT6F8ifM+U6u?= =?us-ascii?Q?ONAxy8HNi6cseW+qoCB4Em1s/oxIdneOjFvxUhPljk/ruPtPC9uMPnUEf+Du?= =?us-ascii?Q?TW4D3x4OllP9p9dCeJytWE3PYsItHiIpiTwNwNPsDHUH6fanv0Pxptw1Uiot?= =?us-ascii?Q?5rfUeUWy5YKwg550ng1BWB2uxI1Xyj4hpjYRJwENvAcvrSDK+kley3rr7Y7Q?= =?us-ascii?Q?HrR/SXLgON/xvQ7a89B5Jkz6XDbayrMzli7V2dp3LOq94pR8asmpL5IdPcf/?= =?us-ascii?Q?RWyg7uBN2uDL1n3fI46dMuvvZPyJAls6uTL8KVQqx+QCgv6BmvmeFbtjVg/6?= =?us-ascii?Q?Er3FZ+UiTgj/SWU6Jrd//cecHtw2tG78sq+QWwgl3sdEyu80cgUkD2cNT0Vq?= =?us-ascii?Q?jHGEwOwEOBMkwWupoTPNbTzeWgZAm1HhXhj10nTWxrVgvwELwEY4yBDI8Mz9?= =?us-ascii?Q?c7iuV2C1ChMQz9G7zXY9KPDCxh2N47Tk50CwEknob6fQaSDXd200oKL1fras?= =?us-ascii?Q?Z42BscZfFZ746AYcfXf4RXCxkIazoHO0Go+SqFBUhs0vpfWBvX/gH84Wshsj?= =?us-ascii?Q?eg5fRwMZ2MH7Xg23cwSWROtRcwfVeiniETOoV6L97VENYde4caMZDlhsejJN?= =?us-ascii?Q?hhaWvyk8b/ITV9jCfJDlqTqkjTa9T95GBfheMXz8mJ74b4sY3SRGyMWgiFVQ?= =?us-ascii?Q?QzEitD+Ff68hPiyipN45yPoCN/vI3hFpOUgwdkjQVT9fsb1PEL7Jmp7Ag1pa?= =?us-ascii?Q?1DPHec3qkra8afXRh6avq6teER9+8cL5P6ABzybzWs6ce/3N6GGN68yKlSEl?= =?us-ascii?Q?KteU3HAXsVF3KuOrDiSIsKu48rc8/esbtZmgFENpmwRqINvihIg4neLnvyZ+?= =?us-ascii?Q?pwn+RBt3iWDKvKSetUoum+VXgL/eAQ94j+y5hQ9sayGsPQ9aEA8Bv7I42nMD?= =?us-ascii?Q?Waoq6GszLLH8QYAsd+cBmMsfavbxkMkVunVbe3MG8Rww8NELnj9tqZWT9xc6?= =?us-ascii?Q?0bTSFGPRUOVKujI1UCkTCz8nVuMPvuA0dl+2COVx8Zno/QCatXarsCPAdyFV?= =?us-ascii?Q?SdRGrldWT1IjneRy0xzpfuu4C5OGdW4P5O6wJzeWVnyTlIwNPTmjSBupdf5R?= =?us-ascii?Q?a9hnW0dbiTWRHK/L64j79F0Ss6cwFHbG61SBqofKgD526DaUkCGQm8/r0Gvx?= =?us-ascii?Q?RQ=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 963ebb03-c450-4044-7b28-08da8f60588f X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2022 17:01:59.3495 (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: gGJ45+5VZcG8eFb6vUxj2aqN+r7m2Oauv9LMm5oSYBqtK0uE6JD9zhE1esNhcaydU7BBbv1DGb6EAqu06umgjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3897 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Experimentally, it looks like when QSYS_QMAXSDU_CFG_7 is set to 605, frames even way larger than 601 octets are transmitted even though these should be considered as oversized, according to the documentation, and dropped. Since oversized frame dropping depends on frame size, which is only known at the EOF stage, and therefore not at SOF when cut-through forwarding begins, it means that the switch cannot take QSYS_QMAXSDU_CFG_* into consideration for traffic classes that are cut-through. Since cut-through forwarding has no UAPI to control it, and the driver enables it based on the mantra "if we can, then why not", the strategy is to alter vsc9959_cut_through_fwd() to take into consideration which tc's have oversize frame dropping enabled, and disable cut-through for them. Then, from vsc9959_tas_guard_bands_update(), we re-trigger the cut-through determination process. There are 2 strategies for vsc9959_cut_through_fwd() to determine whether a tc has oversized dropping enabled or not. One is to keep a bit mask of traffic classes per port, and the other is to read back from the hardware registers (a non-zero value of QSYS_QMAXSDU_CFG_* means the feature is enabled). We choose reading back from registers, because struct ocelot_port is shared with drivers (ocelot, seville) that don't support either cut-through nor tc-taprio, and we don't have a felix specific extension of struct ocelot_port. Furthermore, reading registers from the Felix hardware is quite cheap, since they are memory-mapped. Fixes: 55a515b1f5a9 ("net: dsa: felix: drop oversized frames with tc-taprio= instead of hanging the port") Signed-off-by: Vladimir Oltean --- v1->v2: none drivers/net/dsa/ocelot/felix_vsc9959.c | 122 ++++++++++++++++--------- 1 file changed, 79 insertions(+), 43 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelo= t/felix_vsc9959.c index 262be2cf4e4b..ad7c795d6612 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1557,6 +1557,65 @@ static void vsc9959_tas_min_gate_lengths(struct tc_t= aprio_qopt_offload *taprio, min_gate_len[tc] =3D 0; } =20 +/* ocelot_write_rix is a macro that concatenates QSYS_MAXSDU_CFG_* with _R= SZ, + * so we need to spell out the register access to each traffic class in he= lper + * functions, to simplify callers + */ +static void vsc9959_port_qmaxsdu_set(struct ocelot *ocelot, int port, int = tc, + u32 max_sdu) +{ + switch (tc) { + case 0: + ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_0, + port); + break; + case 1: + ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_1, + port); + break; + case 2: + ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_2, + port); + break; + case 3: + ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_3, + port); + break; + case 4: + ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_4, + port); + break; + case 5: + ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_5, + port); + break; + case 6: + ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_6, + port); + break; + case 7: + ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_7, + port); + break; + } +} + +static u32 vsc9959_port_qmaxsdu_get(struct ocelot *ocelot, int port, int t= c) +{ + switch (tc) { + case 0: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_0, port); + case 1: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_1, port); + case 2: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_2, port); + case 3: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_3, port); + case 4: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_4, port); + case 5: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_5, port); + case 6: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_6, port); + case 7: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_7, port); + default: + return 0; + } +} + /* Update QSYS_PORT_MAX_SDU to make sure the static guard bands added by t= he * switch (see the ALWAYS_GUARD_BAND_SCH_Q comment) are correct at all MTU * values (the default value is 1518). Also, for traffic class windows sma= ller @@ -1613,6 +1672,8 @@ static void vsc9959_tas_guard_bands_update(struct oce= lot *ocelot, int port) =20 vsc9959_tas_min_gate_lengths(ocelot_port->taprio, min_gate_len); =20 + mutex_lock(&ocelot->fwd_domain_lock); + for (tc =3D 0; tc < OCELOT_NUM_TC; tc++) { u64 remaining_gate_len_ps; u32 max_sdu; @@ -1664,47 +1725,14 @@ static void vsc9959_tas_guard_bands_update(struct o= celot *ocelot, int port) max_sdu); } =20 - /* ocelot_write_rix is a macro that concatenates - * QSYS_MAXSDU_CFG_* with _RSZ, so we need to spell out - * the writes to each traffic class - */ - switch (tc) { - case 0: - ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_0, - port); - break; - case 1: - ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_1, - port); - break; - case 2: - ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_2, - port); - break; - case 3: - ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_3, - port); - break; - case 4: - ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_4, - port); - break; - case 5: - ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_5, - port); - break; - case 6: - ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_6, - port); - break; - case 7: - ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_7, - port); - break; - } + vsc9959_port_qmaxsdu_set(ocelot, port, tc, max_sdu); } =20 ocelot_write_rix(ocelot, maxlen, QSYS_PORT_MAX_SDU, port); + + ocelot->ops->cut_through_fwd(ocelot); + + mutex_unlock(&ocelot->fwd_domain_lock); } =20 static void vsc9959_sched_speed_set(struct ocelot *ocelot, int port, @@ -2797,7 +2825,7 @@ static void vsc9959_cut_through_fwd(struct ocelot *oc= elot) { struct felix *felix =3D ocelot_to_felix(ocelot); struct dsa_switch *ds =3D felix->ds; - int port, other_port; + int tc, port, other_port; =20 lockdep_assert_held(&ocelot->fwd_domain_lock); =20 @@ -2841,19 +2869,27 @@ static void vsc9959_cut_through_fwd(struct ocelot *= ocelot) min_speed =3D other_ocelot_port->speed; } =20 - /* Enable cut-through forwarding for all traffic classes. */ - if (ocelot_port->speed =3D=3D min_speed) + /* Enable cut-through forwarding for all traffic classes that + * don't have oversized dropping enabled, since this check is + * bypassed in cut-through mode. + */ + if (ocelot_port->speed =3D=3D min_speed) { val =3D GENMASK(7, 0); =20 + for (tc =3D 0; tc < OCELOT_NUM_TC; tc++) + if (vsc9959_port_qmaxsdu_get(ocelot, port, tc)) + val &=3D ~BIT(tc); + } + set: tmp =3D ocelot_read_rix(ocelot, ANA_CUT_THRU_CFG, port); if (tmp =3D=3D val) continue; =20 dev_dbg(ocelot->dev, - "port %d fwd mask 0x%lx speed %d min_speed %d, %s cut-through forwardin= g\n", + "port %d fwd mask 0x%lx speed %d min_speed %d, %s cut-through forwardin= g on TC mask 0x%x\n", port, mask, ocelot_port->speed, min_speed, - val ? "enabling" : "disabling"); + val ? "enabling" : "disabling", val); =20 ocelot_write_rix(ocelot, val, ANA_CUT_THRU_CFG, port); } --=20 2.34.1 From nobody Mon Apr 6 20:13:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E59B9ECAAD5 for ; Mon, 5 Sep 2022 17:02:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237897AbiIERCZ (ORCPT ); Mon, 5 Sep 2022 13:02:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237585AbiIERCF (ORCPT ); Mon, 5 Sep 2022 13:02:05 -0400 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50056.outbound.protection.outlook.com [40.107.5.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD87F5D110; Mon, 5 Sep 2022 10:02:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WEI+eLOT80EC0zv+36V3PSP0VfTDF4Wo0/rsXmO51lI6FIeDybySUx0vy7PIYylJ/Pij3Y+5cUstI8SHPH/+P4MAZicgK4o0zFAyWt+dyexEvsBwMG1JoTTeFZYzlR8u2iwcYC3YEbThZjNW80KKp+eqXBK3yNyAzdiKDHNDaCRQWHXjxV/HSo1XpVvcd0U/t3flDF1z/YOrVD5kzc9zqVz6J/hcUScmWyNdcCn3FQGwJgpjM6P6CNes4J6PJvKqoYSE+rb7ahruvicvCdHKZSekLlZRAkQHTVNFkKHHDgQ+FB8Mi3AIQ2AXthvntOmH8wzHLdT1LE86dEVzxxPmwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=b3eM3qTwcNQni5jVHUpxGSa7RsQkFVsitIb+pjjX+CI=; b=Va9VGY5cDM7rDYLMs172ExFYeVKIbJwR/F9SODy6nPgYDyEcpSVAcJRK9oxW8r0jXyiAjjxEw1SJDH+eH0K0G46sBjlYrbVjrZHh5Jgw3LoODT6Ak1X6U5NFEP6jtBu9hnLHNO4dNDfd37SGXToe4DxyYgjVubHcPY0QPW2lNYpUsRNydLzSjNn78g/orFFv5v2rJQWh5kDEIwe5sOM9Wr4KHu6msm3HcMhUSEEYgicYms2I/yhrdL+U13/P/7H9S/tyx83eXkHYhCZmqtCBBKu0TW84sIhm1NHFmm8WoXsifDL90+GyCeEu8kWMZC7owF57BZ0WIQYvPAYvTtpjjQ== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b3eM3qTwcNQni5jVHUpxGSa7RsQkFVsitIb+pjjX+CI=; b=i7MpOJgl7Y2H59/8TedBvyQwKUee+toYM43U41WwQkXxyjwrOwmR2buxLW6mpIyXiijJI1GiPIbHvnRz5BizCdi+ovShag+1xWHKjhmJHktU8bj6wj/Y5XWJxHzYAAGwc6/kgzqLDPMygcxztRK43GUBEw4JUi0v84ySOX85k38= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DB3PR0402MB3897.eurprd04.prod.outlook.com (2603:10a6:8:12::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.14; Mon, 5 Sep 2022 17:02:00 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3412:9d57:ec73:fef3]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3412:9d57:ec73:fef3%5]) with mapi id 15.20.5588.017; Mon, 5 Sep 2022 17:02:00 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xiaoliang Yang , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Michael Walle , Vinicius Costa Gomes , Maxim Kochetkov , Colin Foster , Richie Pearn , linux-kernel@vger.kernel.org Subject: [PATCH v2 net 3/3] net: dsa: felix: access QSYS_TAG_CONFIG under tas_lock in vsc9959_sched_speed_set Date: Mon, 5 Sep 2022 20:01:25 +0300 Message-Id: <20220905170125.1269498-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220905170125.1269498-1-vladimir.oltean@nxp.com> References: <20220905170125.1269498-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: VI1PR06CA0140.eurprd06.prod.outlook.com (2603:10a6:803:a0::33) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5bb456c0-d0e4-4a85-0ee6-08da8f605928 X-MS-TrafficTypeDiagnostic: DB3PR0402MB3897:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fu/N0bIIqEQteBjxrV2g4Ja5ALpBImAt92QhXRiwe3X2ATD7evwdVBixXg1LqdfDxJJGM7D6gfQDv1r6mvdeXo9QHnwgrTmqEIQEg95k4iP4AKnZd0z4j9HHQ9f+LaEK11f+8yoj7BgkxeztnOsoAuJGcER5YI6vIbFdgen+AB970AJ6YEIg8f9Nt3ugYbfk/GTIGguyv5srWyMUvE8lncQJmWkChVfmv2i7ScFbrsfXIx/HTglk7eRKm+Ea6/KHZGP0hx2uHiHyo9dMb7HW6vftV1BNv4XNawOPwfGS8aBASKTPHnEb2B6oh2Aqp2Lxflr7uPHF5UVtuiWULvMVnjtkGKZHK5g1l+QUM5hUMxO0DO3PtuQTOFBRPtn4M3kmre+/XcN6EYglHMCHGrW84cIPZkbWdviK6RJs0lDx6pj0AULo9xgelCsUzh56PtXbdvt54JODvZHDxJ5bUMHaYqoOChCBYbmXnwt1CX003SfARIbXXUvLLrbuMAzPm+DAi0EDztIGu4vKaHMtX4duLyLMI0DWSVBMkCR6SuJ9Ul3uy1nSiwg3iLkyUVTI3Mvp5p3fCUOqi011ENRl7aPh5bUaZcLPzch0klORgUKcmCI932Jic8cQvX9QDVJsVBZ3MVUspD4bUdpGsYw2aXsGX7/zcGjH5NrunuxKJXrT0MFdkHoxMYsdYmNXXavOUiLLYG9aZ1jTrDlKSM7DkjePcbm9dEJPwsRMjUiNVJVN5Cbl7pBZuvYsLvFeajBPnw+jHNyhIJW0tzQ1RwrLjhsp/Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(376002)(39860400002)(346002)(396003)(366004)(136003)(6666004)(8676002)(36756003)(4326008)(2906002)(8936002)(66476007)(5660300002)(7416002)(66946007)(66556008)(83380400001)(86362001)(54906003)(316002)(6916009)(44832011)(2616005)(478600001)(41300700001)(6506007)(6486002)(38100700002)(26005)(6512007)(38350700002)(1076003)(186003)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?rY2bWPmhfZYSr1jhgth851XgVS6c9+2FHcPDzYpzh+pYuIrjGapL+j+hK1Es?= =?us-ascii?Q?SfHGMERiRq+JsHjTsL33oMu52BrfUQ3qRQFVR9/tb81N05I2xOHkey10hNGJ?= =?us-ascii?Q?P5FxY6iXm1Xe8OB4TJiI0/DMYfpp88jmQu4B/d90DVKUscIHCerjyrbyvcEJ?= =?us-ascii?Q?q2XTj4kfm3uwm96R8bqXbVtszfP5B+fiU35h+k34wOWsHQMaw4feSL00fvTz?= =?us-ascii?Q?lz2Gs7Bj4mRbJ8ML09bExGzAuwrV3UxH2a7H5nA4U6mV70zoObWrDEgZdOmG?= =?us-ascii?Q?lLxIWy2XoJcCIEtA+4kVyJj+19RM9VS61jhTZOZo26cxP83L4G4K5K15gBzw?= =?us-ascii?Q?mVQaFJCH4e7h/lX4By8tCZgSM4k3qPLmBCbN6HEn/3AG9UOksPSOUvtKOCG2?= =?us-ascii?Q?ic+8Zjp2CdSBK97+ApyZ9ARB20Dp/a7STHLxH78mVTY5tjoPwv0tJxd5qFEw?= =?us-ascii?Q?tWnJjQP3RG/3fZ/VRfszG/YHcGIqh4Z77fgMeEqE0jTyB0CGXNkC252B3X+w?= =?us-ascii?Q?AbDdoyApT0hBd9n4zqNRUuq12W1CwYFWt7gIvJqYTQIWctcWTSINflE74zuG?= =?us-ascii?Q?5arvvvMChmWDjHD+IDd/kSlUbuyvhPUe6IAn84M5iHlrzGF1oR4vM4heBbI7?= =?us-ascii?Q?+s6kCymTHZy8UwO9Zt1+5kgzcvpBdeqsbCNLACowLnmtJdtEI7FnwzLM8Tf1?= =?us-ascii?Q?COurbrqyTElW6YTEcqWFM4S4DnbJh1wkTGovIhgxQdbsVNz7CQ25z0ihy7Xz?= =?us-ascii?Q?1bwphxaYiyCnIsl2fOIjW8Kc0flZEat2Om7JuNRr2QRo6feMZ4fLv+arbig7?= =?us-ascii?Q?D8pxZwV/aE/b5IxEVpmmE+Rix7yhDVERw8llvIG/PuLb540llSs8Tz6ZChUp?= =?us-ascii?Q?vZUG+fKgYUugu+mcGTPp5+XcBFl0EGgDK/nS5+4tnFLCfd062Pq0RV9+oQ/n?= =?us-ascii?Q?gALefQkMeoQKQxD4SsYdbaaHLysHdzq4r5w2nfamk5cfNizmSScjIfefKuu/?= =?us-ascii?Q?3UbUIJ2JhomgU1EmRKU2UYgs7CFXsFtKvijRSx56LhDldFOPrYOJVj4pVZEd?= =?us-ascii?Q?ziJY+C3ifxqd0fQs6PprggtR212AkSfOfotqI8a6v8Qa9PhoAE8EIcDzWNa+?= =?us-ascii?Q?JIWBvL3T6zf0wc41ICPS767GLmEzdS+xHWvdH1iuhPY5pC5jydrqd5oATcPr?= =?us-ascii?Q?Qb6EwhuFI5YN/T7lQx3s7O5inGAUjro0QHQqz13MA2xfmC+a5WO8NqegSexH?= =?us-ascii?Q?hnjuzaCWifNFcEWSZ7q4qN18qwrUA+PDGefiv8piQ22EJ3cPv3WhZ10RxQoZ?= =?us-ascii?Q?KEz3iNLm3URMRPjufHAQ7HwPSFNq0tPe1em4yU91V9Mk7xCrBqfVMBGMkysU?= =?us-ascii?Q?ETMLjQXRf0DKuNqM0Gysz5ldVwourBm/aJx3hzNDQTf214BIWlD2Vv9rTC9w?= =?us-ascii?Q?AZSC+wCDMmf7qB9aQwLRpTFmVE/WEGpJg8rH+ugSwNwcWEEDrpp42TeDABPz?= =?us-ascii?Q?7/IaAJJuYwxeTweTlQqXh4oJ7IocTE5fzTS/vndEMVpfb+Mi/5PjKXn+niwi?= =?us-ascii?Q?WydiylLGo/OIST6awH5lYln9lHCvZTi0k1RXlzXPSQKBTbIoaLC8zpkt4dxF?= =?us-ascii?Q?jQ=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5bb456c0-d0e4-4a85-0ee6-08da8f605928 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2022 17:02:00.3651 (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: wkSgdoYtLKbMnzQhMumWFPWeYRObRev4KCGKrE53JP9aNhVvBzXDuHLc5Th7TuSaZjMJpyFLgEJsPdsubTXBLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3897 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The read-modify-write of QSYS_TAG_CONFIG from vsc9959_sched_speed_set() runs unlocked with respect to the other functions that access it, which are vsc9959_tas_guard_bands_update(), vsc9959_qos_port_tas_set() and vsc9959_tas_clock_adjust(). All the others are under ocelot->tas_lock, so move the vsc9959_sched_speed_set() access under that lock as well, to resolve the concurrency. Fixes: 55a515b1f5a9 ("net: dsa: felix: drop oversized frames with tc-taprio= instead of hanging the port") Signed-off-by: Vladimir Oltean --- v1->v2: none drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelo= t/felix_vsc9959.c index ad7c795d6612..f8f19a85744c 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1759,13 +1759,13 @@ static void vsc9959_sched_speed_set(struct ocelot *= ocelot, int port, break; } =20 + mutex_lock(&ocelot->tas_lock); + ocelot_rmw_rix(ocelot, QSYS_TAG_CONFIG_LINK_SPEED(tas_speed), QSYS_TAG_CONFIG_LINK_SPEED_M, QSYS_TAG_CONFIG, port); =20 - mutex_lock(&ocelot->tas_lock); - if (ocelot_port->taprio) vsc9959_tas_guard_bands_update(ocelot, port); =20 --=20 2.34.1