Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6162866rwd; Mon, 19 Jun 2023 03:22:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5uyoiUmMbUwn/FFE5Him11/scmI6xyHO4qcAo/9giUnJwFK6myXrRhpUxQ7dsZczDAicHi X-Received: by 2002:a17:90a:8a0b:b0:256:2cb7:406e with SMTP id w11-20020a17090a8a0b00b002562cb7406emr9952842pjn.45.1687170150641; Mon, 19 Jun 2023 03:22:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687170150; cv=none; d=google.com; s=arc-20160816; b=IkYyq/yV+Go/9JoJ22sbRNp/CHjWegSLBnDsR/AIjLkwlcaDOvB7waepgFTkC//BsO eSikJYb7S+ZOxJytYZ4yWggdlehc1P7oaYNqyUnus6HLq2e7MKBpHZN3f92H/lKL9iXB BwSbJMREOdQ9NGrKgxMejtBA7UGFMdqFG/ymB26QBnS+jNQj85dAxDeUZ5vuRSPbyzPa PDIgsIh6NXsWfihD6918hCI3EfcxTjQ5hN21Kmr7OrFLo0U6hULXpZO/o7cjV4AlOxxP tkKwAYuzgiLhl12aCFPS/LtiGWXldKocQurNB3ZoRV6tC8/XLBq/9Imx6mZoEd1xKOot XPtw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oc12-20020a17090b1c0c00b00235dc16de3asi7796606pjb.16.2023.06.19.03.22.17; Mon, 19 Jun 2023 03:22:30 -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 S231768AbjFSKJd (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 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 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 --- 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); -- 2.39.2