From patchwork Mon Jun 19 10:08:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Kauer X-Patchwork-Id: 109912 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2899788vqr; Mon, 19 Jun 2023 03:35:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6TCxHVpAGHt+C3pDAbVn57uWiIUjblFAyQGdwrBzZ6zwLLXZAdFUjVyZeufzoOa9Ui+jzP X-Received: by 2002:a17:90a:1906:b0:25e:a8ab:9157 with SMTP id 6-20020a17090a190600b0025ea8ab9157mr9120748pjg.22.1687170951713; Mon, 19 Jun 2023 03:35:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687170951; cv=none; d=google.com; s=arc-20160816; b=aLVG/J89yMe/39PQcWSSQbZ6t1IO/uvTq6u15cZZIMF4LxwrsfVvAHyWUxPutz4mDU zYr/uX+lYNDpp8BShsT5aqo/c7QUcY2Z8bWMBqBMTyJoPig4aJgxS2Prd+qNwxi/nGBm hQzqvdRHT7b/1lPwpWx8ZcBDQwxn9AQ+eotiZkcubs+axcLEe09RIfOBsrupxTxjmIyg m+wsp8sa0wvxGEnz8msiWQeqJuVMoYwYhg6ofegWd7AUvpfMAuVis4IAN3zHlvN2TDhb ZmF3Garo8ZD7q/MfraYvdTPIyLkeql20Xf5XX76isAfBXgHTTv+knN/6rE6GfRdpni8s l49Q== 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=ifTkOc+IePMxuKDemBz16w3UeJ8myDaZex1J+2pMJyw=; b=WyNTtEXGsIoNS7BxBqt8LeHpLwIJaBXAszLRlT2tgp2V45RCnK4Wj5s40ea6vaUVXp +rhsBAtvVVodCk7OIIY6dVMTDSumO+ihvH065vHnJ1xHc6x7R+GqrMPYOKJoxKPZBTOU dSGcHwvLfZ3GLOj2mlpcgAFAn0WjLIyWJC033YLnQ3SjgAN54aK6ej3c8zuEevI9SAC6 6PQ/U0519fqBumPm71YKCIi1QLmXum+Ru0TkYKwq3X7PFlGhTmwxgho23JTYZy6kCBAV +90x3ZdxeaOcnDPMWx7mHsP/sO1Sx+7yiBfS/ekaWJOaK6/1BvxVVxDnTxS4V76olwXW tvdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=O1sb0RIn; dkim=neutral (no key) header.i=@linutronix.de header.b="mvBdAF/i"; 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 v15-20020a17090a6b0f00b0024e2afd72a3si7191592pjj.182.2023.06.19.03.35.37; Mon, 19 Jun 2023 03:35:51 -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=O1sb0RIn; dkim=neutral (no key) header.i=@linutronix.de header.b="mvBdAF/i"; 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 S231887AbjFSKJd (ORCPT + 99 others); Mon, 19 Jun 2023 06:09:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231788AbjFSKJa (ORCPT ); Mon, 19 Jun 2023 06:09:30 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB0AAE4F; Mon, 19 Jun 2023 03:09:18 -0700 (PDT) From: Florian Kauer DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1687169348; 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=ifTkOc+IePMxuKDemBz16w3UeJ8myDaZex1J+2pMJyw=; b=O1sb0RIn6Hy6jCcn3trgyXlbi2F7M/tZc1oHs55EChHsMkOVxTWEvpmuHRQD3/pEccJKOK ESPzMyNi+0R4oVNLy1dZE9I+YAf72swbc0Hr4tWQkM6h6t7IJHZXMCn8EyprCNmUavhT+9 PyD1MF5FEOLJ42V9fgvPhdq67drLFP7CpJvi+QdHl8SMpz55xilEZDkY7ITwh3vIbGZflN etl7jQsCevFxi0nQItYAiuqUXVIKouU7RibrA4IZsWrJHu95WXIDVxnd/MR76PbP5246Yb qdIULppA+9QBImqLyo9oK96FGBjP9ZsO3fKw65pU1ATkxQbpFqSf0ozxpWH4MA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1687169348; 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=ifTkOc+IePMxuKDemBz16w3UeJ8myDaZex1J+2pMJyw=; b=mvBdAF/iCI7Y3/a7COxWzds9FSCtuMIHxL8z2+O5kNMffu0l3Cxtn9idwFTvT90lVFr1L6 TJHzDFGhJf1yPRBQ== 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 5/6] igc: Fix launchtime before start of cycle Date: Mon, 19 Jun 2023 12:08:57 +0200 Message-Id: <20230619100858.116286-6-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?1769126968352175280?= X-GMAIL-MSGID: =?utf-8?q?1769126968352175280?= It is possible (verified on a running system) that frames are processed by igc_tx_launchtime with a txtime before the start of the cycle (baset_est). However, the result of txtime - baset_est is written into a u32, leading to a wrap around to a positive number. The following launchtime > 0 check will only branch to executing launchtime = 0 if launchtime is already 0. Fix it by using a s32 before checking launchtime > 0. Fixes: db0b124f02ba ("igc: Enhance Qbv scheduling by using first flag bit") Signed-off-by: Florian Kauer Reviewed-by: Kurt Kanzenbach Tested-by: Naama Meir --- drivers/net/ethernet/intel/igc/igc_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 9c04df900b59..565c72bd737d 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -1017,7 +1017,7 @@ static __le32 igc_tx_launchtime(struct igc_ring *ring, ktime_t txtime, ktime_t base_time = adapter->base_time; ktime_t now = ktime_get_clocktai(); ktime_t baset_est, end_of_cycle; - u32 launchtime; + s32 launchtime; s64 n; n = div64_s64(ktime_sub_ns(now, base_time), cycle_time);