From patchwork Mon Jun 19 10:08:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Kauer X-Patchwork-Id: 109894 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2893008vqr; Mon, 19 Jun 2023 03:20:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5BLKK9aoQES5oShu1heMe+CEvdSw8gn8MZEHkdQi8FSRL9KYcrSR/pi14vxxkUKyEwyFoE X-Received: by 2002:a17:90b:a0d:b0:25b:de8c:6be8 with SMTP id gg13-20020a17090b0a0d00b0025bde8c6be8mr7022601pjb.13.1687170056307; Mon, 19 Jun 2023 03:20:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687170056; cv=none; d=google.com; s=arc-20160816; b=qCw0JPSZs6wChJfr4x5an/Gxm27chWjwOZGXqTXOj4oPMH0VIGYqW9yjC6JOFUS4jO keWRl0FfSz3mrEr0O2ehIlcFWQM6Bidh1sWiOs8XpVH2AFbwRNXdvFNgOVhlTGSHjHdm H2Ylcdoy8dFrbIO7Yyc5DAuJYdOcU1UENg3y7GnrPpqB6d31a2ZNbE2P6jAc42D36E5L AD3CsaBYw3On5apj3KoOPJck2F9Ur5wpN6XbI+Ow45xAe9sPL5Br4kUiGDHsVA67+O2C qZZVumuldedyo53MfbKO9aIF604BPTIJVE4jUGb4WpLNuiidjYT8jqnyp9V0IstS4xfc qZ+g== 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 header.b=2akTjKyx; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k21-20020a637b55000000b0054f993d039bsi8747318pgn.490.2023.06.19.03.20.41; Mon, 19 Jun 2023 03:20:56 -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 header.b=2akTjKyx; 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 S231346AbjFSKJ0 (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769126029036364319?= X-GMAIL-MSGID: =?utf-8?q?1769126029036364319?= 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 Tested-by: Naama Meir --- 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];