Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3261110rwb; Mon, 15 Aug 2022 22:35:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR5AinB5ReWWYqvbqMvOD4FOlcvkiJeuFI3zQSVSalIz/6KA30X7p6rQYaDK6RW7kAG7PYvL X-Received: by 2002:a17:907:d15:b0:731:179f:9245 with SMTP id gn21-20020a1709070d1500b00731179f9245mr12368246ejc.626.1660628154432; Mon, 15 Aug 2022 22:35:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660628154; cv=none; d=google.com; s=arc-20160816; b=qFbHt+iInuYOOOaYhejRBBHvbhcd4YREBOUG0gYi71uNxRM5GJHlb9kSTqos+jERd9 CIWRRAFQ+1g9OuX3+gS+d+BcWYFmT2RyylnLMWD4fuUn3aT4MMszb/GiM+HX+0vgVfcx Qsb1I66SyBkM9H9TxhWo0meL928+8fJpIEOgXCCYbofoQNv3um0HL/Mf41XySkwUqJde KxSRGN9y6a0QzUsYqiXjFql0B7intlNpOc7gmX9dJ3GJzciPdCO34iMniPSUX17CGzXr KN61id1GhmrW052XR184uPoXQ/ED3bnjr9/CumuPekfAmBiSz8iR8p5Zgcf8MfLD/MeS syug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Z0nF6GVxMbHkOuKktwKImzvsRK7gDnbfAmt4Cg2Fv5I=; b=ZBCt8f7IY8AdkThvntj4juHa/XS9Sz+qOD9WTKmE0qgXgAcamPw/XQMD0vFluWLuR8 yRRxlOuIiDOQyHiHVg3sN5fTCDNr8WqZk4l+Js91gxHAG+8MfJUIFdGqXs2FkoMMnhDS ie7iNC4f6SA7rxcvt0d66LVSkZsPfjMS1msu4aRSuVeXc6QJzxj4+5Ml/Kx0CJLEVO0t TN5k6GpEpdlaDW5W4ro8ubsl6tWhtbgNrsgttubIcwstkN1f1ExE8JUDQ76D7P4cr8P9 v0kzeTOPaSLUbt0wZQutyuE9qnycnUuIVCn/6b1G5K0jouBkgYCwKlcbJefGy7YfjV8E xTlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=G7N3PWsg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n14-20020a05640205ce00b0043d9effde35si11329475edx.632.2022.08.15.22.35.29; Mon, 15 Aug 2022 22:35:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=G7N3PWsg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234159AbiHPE6m (ORCPT + 99 others); Tue, 16 Aug 2022 00:58:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231869AbiHPE5o (ORCPT ); Tue, 16 Aug 2022 00:57:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B5ECBC129; Mon, 15 Aug 2022 13:51:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 92B16B8113E; Mon, 15 Aug 2022 20:51:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0151C433C1; Mon, 15 Aug 2022 20:51:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596691; bh=CcEXs1wOl50usw5N4AKXfF+Uu0otjqaJAqH0q47J1p8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G7N3PWsg/zFaMgGxd8wVin35jXF6Cw7cwzKqIJvmRLSWbQ9IAPb3cZTSV+o/DkKi8 Xr9n4ITX2xIBUvY6TKPdD5I+GpFTmxY2MTDX1rOfJy5uHtDwAJnXnjZXqk9btcNicI pudnqj+F9BVBLaIjR/qPBo62apEemqbLIEhC5SSA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Jakub Kicinski Subject: [PATCH 5.19 1153/1157] net: dsa: felix: fix min gate len calculation for tc when its first gate is closed Date: Mon, 15 Aug 2022 20:08:29 +0200 Message-Id: <20220815180526.658433843@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean commit 7e4babffa6f340a74c820d44d44d16511e666424 upstream. min_gate_len[tc] is supposed to track the shortest interval of continuously open gates for a traffic class. For example, in the following case: TC 76543210 t0 00000001b 200000 ns t1 00000010b 200000 ns min_gate_len[0] and min_gate_len[1] should be 200000, while min_gate_len[2-7] should be 0. However what happens is that min_gate_len[0] is 200000, but min_gate_len[1] ends up being 0 (despite gate_len[1] being 200000 at the point where the logic detects the gate close event for TC 1). The problem is that the code considers a "gate close" event whenever it sees that there is a 0 for that TC (essentially it's level rather than edge triggered). By doing that, any time a gate is seen as closed without having been open prior, gate_len, which is 0, will be written into min_gate_len. Once min_gate_len becomes 0, it's impossible for it to track anything higher than that (the length of actually open intervals). To fix this, we make the writing to min_gate_len[tc] be edge-triggered, which avoids writes for gates that are closed in consecutive intervals. However what this does is it makes us need to special-case the permanently closed gates at the end. Fixes: 55a515b1f5a9 ("net: dsa: felix: drop oversized frames with tc-taprio instead of hanging the port") Signed-off-by: Vladimir Oltean Link: https://lore.kernel.org/r/20220804202817.1677572-1-vladimir.oltean@nxp.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/dsa/ocelot/felix_vsc9959.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1136,6 +1136,7 @@ static void vsc9959_tas_min_gate_lengths { struct tc_taprio_sched_entry *entry; u64 gate_len[OCELOT_NUM_TC]; + u8 gates_ever_opened = 0; int tc, i, n; /* Initialize arrays */ @@ -1163,16 +1164,28 @@ static void vsc9959_tas_min_gate_lengths for (tc = 0; tc < OCELOT_NUM_TC; tc++) { if (entry->gate_mask & BIT(tc)) { gate_len[tc] += entry->interval; + gates_ever_opened |= BIT(tc); } else { /* Gate closes now, record a potential new * minimum and reinitialize length */ - if (min_gate_len[tc] > gate_len[tc]) + if (min_gate_len[tc] > gate_len[tc] && + gate_len[tc]) min_gate_len[tc] = gate_len[tc]; gate_len[tc] = 0; } } } + + /* min_gate_len[tc] actually tracks minimum *open* gate time, so for + * permanently closed gates, min_gate_len[tc] will still be U64_MAX. + * Therefore they are currently indistinguishable from permanently + * open gates. Overwrite the gate len with 0 when we know they're + * actually permanently closed, i.e. after the loop above. + */ + for (tc = 0; tc < OCELOT_NUM_TC; tc++) + if (!(gates_ever_opened & BIT(tc))) + min_gate_len[tc] = 0; } /* Update QSYS_PORT_MAX_SDU to make sure the static guard bands added by the