Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3078555rwb; Mon, 15 Aug 2022 17:35:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR6hrhJjkwyfXEsFVHTqBxu64Ti3JiaRjLFcQLRVMhSKp0NEWPuxIZ8EQKzrmwAF/lW3y325 X-Received: by 2002:a17:907:2e01:b0:730:9ecc:cd28 with SMTP id ig1-20020a1709072e0100b007309ecccd28mr11634336ejc.360.1660610146702; Mon, 15 Aug 2022 17:35:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610146; cv=none; d=google.com; s=arc-20160816; b=fJz9aKONs0anP9VkZhdkGR734jMLm5au5SDwjjmQE0KmorXu+R6ZjzUPeibJIdyz0e xn3Lrr4zlM3TgFE7n1cWOEG/Lm2E9qB5WUZscsmSzxc+U70lDuq38UTSbr/8phdbtJwv u1+NUGb+j90hmLiC+gdfFD74CYEWPVb05+VhdLTbbgYTzFWANjp1wl9VaBARt+d8R/WA WyZ+QFBWEYPSHQbnMb3IpMMxwTX7bENDkNfaiGzq7iWa1VcNUUWXGnVG1vsX31R8D/Ul S5a5QSpBckiTwkfYqoWJGmmC7ZmbLdGexst+7fL3VQO2ZhmR1ftTxFiCdpOimI7aV9n7 fkOA== 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=qNc5dp+bUD9frFGXbwHWRxhngCRd7LqS9ssrL18n9uM=; b=rFqlGqw33l0zRtMhf1BmaLdZEayFg1cjSxwFA3/QVklzew0BaL0Rgo8vtDc3hRew9R 6elrQF8jGC7EurxaSjirRx4QcSFLOl5F9KLp6ZKzciBCQ/ALeEuVH+NmtxchOpjqL1m8 +lqaatouVW9M2+l/njilcylVgysrpBN9XDPk8XFx19oy8MdAsDB18EiVNkrzAOBUy8io bI8OwcSr1KmgU+KP49x3wdWVszdnWLAtlO+3BZ8I89xU1SgawIdaj22d89o/hJo+Nx0D Smw9KDhjfBl4MX9x89a/rmyAK0agtSlwtKekwFb5Q6ruthspBlgCQ5lNim8AeOuVYZVn KfmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TTv6G4If; 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 l22-20020a170906795600b0072b4addd854si8726523ejo.292.2022.08.15.17.35.21; Mon, 15 Aug 2022 17:35:46 -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=TTv6G4If; 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 S1354999AbiHOXq4 (ORCPT + 99 others); Mon, 15 Aug 2022 19:46:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354326AbiHOXlx (ORCPT ); Mon, 15 Aug 2022 19:41:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B73572C665; Mon, 15 Aug 2022 13:12:37 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 53C116077B; Mon, 15 Aug 2022 20:12:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 541F9C433C1; Mon, 15 Aug 2022 20:12:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594356; bh=Y7dWTjLqANNjbJKqLAbtLdNNLRyhsxmBAvgy0geNrzM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TTv6G4IfScpWIDNA/Vnmb1rtgz2GFc9biFIAP7ZR2rjEBl9PAIjq169ih7PhWV4yd ItbccRauNFSoJHo9ZVq+bvwlFB2s/6e/IPcIh44SZAY5sNwq2RBlH7IfW00TVf9SVY SDldB4yVGLtVrKFU6Ocy5cbb84HF/tqmwoEwCfgo= 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.18 1084/1095] net: dsa: felix: fix min gate len calculation for tc when its first gate is closed Date: Mon, 15 Aug 2022 20:08:03 +0200 Message-Id: <20220815180513.883761274@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 @@ -1133,6 +1133,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 */ @@ -1160,16 +1161,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