Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6174087rwd; Mon, 19 Jun 2023 03:34:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6gRzQDV0rq9p8F8ujl5lXg30SIDiIzs1t3WPaVVKDqcr2bLEEPkvM9mnf8yJkt6gLz+O5G X-Received: by 2002:a17:90a:6f44:b0:25b:e747:103 with SMTP id d62-20020a17090a6f4400b0025be7470103mr6972540pjk.26.1687170876927; Mon, 19 Jun 2023 03:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687170876; cv=none; d=google.com; s=arc-20160816; b=F5FMKsq5gyecJVo7OshitvXPYmIYX6dx0TGDUwjP2ATXnThuGtehENbXfPRRHAwD4H A8cGzYEwf4pmogF209urbU1Fxe3Vhn8m8q5uEPVLnJQtw6spjR15ZJzLHS5HWCJWLKD9 5T/4D001Sg5VmV9F/0NQ9w/W/T1zevnjSTzCdMzgMJUeJDP1igRRqm8JHg1agjQAPPfR jeiMKx2+zjznO7WTati8tAglMye6xZ8d3i4pem654fLjGaK+NgCldi9uu84SjavfSTiA +Ck7e7mAS26A26MVXun/DFJIxtMFzNKIws9B6NFQeiY/1NeW0uOjIurbVJDQZPJBi/RO WglA== 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 :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=Is0YIMn/H6ydBj7dX1G099v3DjIIzn8LEApqQ8ulQHk=; b=Wi64BCOGlOZwk5qKXnIMk/VF1w8BwoMGizAWxTUqkmfOtK7PKaTTLT/tbCGUOZ9A/a bo9qcmkoO+ud2J+KQUKXz7/qEy7CtIW1ZSyfxVeorc9mSBsMC+KWSM5Yavly7Nkxrc+N vAkiC+cTvyPpq/vS+KJ1+0549E4+aDXo68cMF3fLqG2RO8fFaFrQdjskylyW3TpJ8L// 5gNG4X1X/iqvcPRipj+tTgal67Xwxpwt9M2uWiOzk2tihqtArnl5mZ1h/J0KgDWRHo7k nMk1DXaQTq4kaMuUl+U6OqXr7cIYi42rz1RH2M+6GevtwdLt+oLVEz3oQLYhu2IyTbKl uINw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=w9dNBja6; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u15-20020a17090a3fcf00b00256023fabd3si7340443pjm.151.2023.06.19.03.34.25; Mon, 19 Jun 2023 03:34:36 -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=@linutronix.de header.s=2020 header.b=w9dNBja6; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231137AbjFSKJ0 (ORCPT + 99 others); Mon, 19 Jun 2023 06:09:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231363AbjFSKJS (ORCPT ); Mon, 19 Jun 2023 06:09:18 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CBF113D; Mon, 19 Jun 2023 03:09:08 -0700 (PDT) From: Florian Kauer DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1687169347; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Is0YIMn/H6ydBj7dX1G099v3DjIIzn8LEApqQ8ulQHk=; b=w9dNBja6aYYCS8vG/OHDsCve1SLJSDHnb5qkcuLiqUHZLSov3++OGw0oLnD4kH8FDeLN+j I4KXKm8OrAD1ynwGbcjaaOWu3u7qund2UIUQu4dGQiyFYy69GLDQnRjRPdWG220jj5gddl 3HE6gN7h4ECtzFSSaYXk7x4iFN4MBGZ1Pa+VCldUOfpJ71QMONh8ndl+lYHUCVcnlEWFy8 7f82pBoDxr1iJf8AzWiMssMumsvOBR9PNYqC+maeE7HCz1dUkv5VA2IcdweDt4l5k6+qsC oL47jcpR14cI94jLTRIxCvI/uhv0GPvWsqm4ZfofESWlYHxODMg8vB/BWu4p8A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1687169347; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Is0YIMn/H6ydBj7dX1G099v3DjIIzn8LEApqQ8ulQHk=; b=2akTjKyxka3hdp7ghvy56WOEZfiM2GdO5A6gmZP3hv6FNFfYxLYKdENNFe+vo/+VRSIqsy n2D6Vze7qMyjvrDw== To: Jesse Brandeburg , Tony Nguyen , Vinicius Costa Gomes , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Tan Tee Min , Muhammad Husaini Zulkifli , Aravindhan Gunasekaran , Malli C Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kurt@linutronix.de, florian.kauer@linutronix.de Subject: [PATCH net v2 2/6] igc: Do not enable taprio offload for invalid arguments Date: Mon, 19 Jun 2023 12:08:54 +0200 Message-Id: <20230619100858.116286-3-florian.kauer@linutronix.de> In-Reply-To: <20230619100858.116286-1-florian.kauer@linutronix.de> References: <20230619100858.116286-1-florian.kauer@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Only set adapter->taprio_offload_enable after validating the arguments. Otherwise, it stays set even if the offload was not enabled. Since the subsequent code does not get executed in case of invalid arguments, it will not be read at first. However, by activating and then deactivating another offload (e.g. ETF/TX launchtime offload), taprio_offload_enable is read and erroneously keeps the offload feature of the NIC enabled. This can be reproduced as follows: # TAPRIO offload (flags == 0x2) and negative base-time leading to expected -ERANGE sudo tc qdisc replace dev enp1s0 parent root handle 100 stab overhead 24 taprio \ num_tc 1 \ map 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \ queues 1@0 \ base-time -1000 \ sched-entry S 01 300000 \ flags 0x2 # IGC_TQAVCTRL is 0x0 as expected (iomem=relaxed for reading register) sudo pcimem /sys/bus/pci/devices/0000:01:00.0/resource0 0x3570 w*1 # Activate ETF offload sudo tc qdisc replace dev enp1s0 parent root handle 6666 mqprio \ num_tc 3 \ map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 \ queues 1@0 1@1 2@2 \ hw 0 sudo tc qdisc add dev enp1s0 parent 6666:1 etf \ clockid CLOCK_TAI \ delta 500000 \ offload # IGC_TQAVCTRL is 0x9 as expected sudo pcimem /sys/bus/pci/devices/0000:01:00.0/resource0 0x3570 w*1 # Deactivate ETF offload again sudo tc qdisc delete dev enp1s0 parent 6666:1 # IGC_TQAVCTRL should now be 0x0 again, but is observed as 0x9 sudo pcimem /sys/bus/pci/devices/0000:01:00.0/resource0 0x3570 w*1 Fixes: e17090eb2494 ("igc: allow BaseTime 0 enrollment for Qbv") Signed-off-by: Florian Kauer Reviewed-by: Kurt Kanzenbach --- drivers/net/ethernet/intel/igc/igc_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index dda057a3b5e3..290daa5827f0 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -6053,6 +6053,7 @@ static int igc_tsn_clear_schedule(struct igc_adapter *adapter) adapter->base_time = 0; adapter->cycle_time = NSEC_PER_SEC; + adapter->taprio_offload_enable = false; adapter->qbv_config_change_errors = 0; for (i = 0; i < adapter->num_tx_queues; i++) { @@ -6075,8 +6076,6 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter, size_t n; int i; - adapter->taprio_offload_enable = qopt->enable; - if (!qopt->enable) return igc_tsn_clear_schedule(adapter); @@ -6091,6 +6090,7 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter, adapter->cycle_time = qopt->cycle_time; adapter->base_time = qopt->base_time; + adapter->taprio_offload_enable = true; for (n = 0; n < qopt->num_entries; n++) { struct tc_taprio_sched_entry *e = &qopt->entries[n]; -- 2.39.2