Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2818083rwd; Wed, 14 Jun 2023 07:43:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5KUCtGVgAZ6tP78xWu1qjPzhC6vK3BqBQonh0ukgnBHby03CPIyeF8Etqgd1ZMnj7dQViG X-Received: by 2002:a17:907:2683:b0:977:e99c:c958 with SMTP id bn3-20020a170907268300b00977e99cc958mr14858276ejc.10.1686753811940; Wed, 14 Jun 2023 07:43:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686753811; cv=none; d=google.com; s=arc-20160816; b=kvBDEeIfnkvCXGgYtKDGqwhOf70GhkyD0WBNtkUK+LLQtA6LIWTMq+LlYwP70/NQ2L OeO+um3vF9pCq42WjA+GGjy0kk82w0tazWyRJgtkW6ujpm3EZDhl1bjLO60ZNlPjY1yt gDgXwasy9ChIVHFKLUKYz44If6FfRQwvBJgDQg5Ya7Imy5OMmrAzC7q8Pnl+8FSZYHeM 5gquwX6AHRZH1Sm6On0z9FI6KuxgTyxk8KiyxfmDJJh6G1d6bpVztJJ/X1FyfRVrKHEB 2Gzd+2OhM4FHqLo+X5EjenEbJ9ZTiUtQYbcgwqJFitJ2jkSDSJe88FqHQefeL8ttPEM8 g6YQ== 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=7hUQE7jx0fknKMAL9e6sfNn3hoeeuEK7E2AxmOK/Kq4=; b=TC7Wp5NlKZNJnsc4iMHhksCcpiK06fmD323se6b+ImQ6nznqa7frNDAVGjMle8eyx4 n+k96oxGUHKzV0nCP2t7NajmhAhmCCrUNoI5fLnsWAj+URvIyJcfLI0QVYzyHbp3P7AT A13Xox72zYZ6eIJaWLiq1fnojV3oh9hn0v5oN5ASxMphbbNkTw1peXrepRnhkXO+OXxt CBB4lgghQWa60SMTl9uB5jBiL8cClUn8Rvs+9SSen4IqKA2r9WZmajRdDtI/VT2Uo+TO maGRJrStg0XqsBKYT+meAm07BOAoQNW2KNMLXFdvVFRhtJc38T9o13AQbr4VZ/Uvkl7m AF7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=e1jQpj4m; dkim=neutral (no key) header.i=@linutronix.de header.b=Zp2JPID6; 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 pv4-20020a170907208400b0096f573835bcsi8003648ejb.753.2023.06.14.07.43.07; Wed, 14 Jun 2023 07:43:31 -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=e1jQpj4m; dkim=neutral (no key) header.i=@linutronix.de header.b=Zp2JPID6; 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 S245166AbjFNOHw (ORCPT + 99 others); Wed, 14 Jun 2023 10:07:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245382AbjFNOHh (ORCPT ); Wed, 14 Jun 2023 10:07:37 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C22AF1BFD; Wed, 14 Jun 2023 07:07:35 -0700 (PDT) From: Florian Kauer DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686751654; 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=7hUQE7jx0fknKMAL9e6sfNn3hoeeuEK7E2AxmOK/Kq4=; b=e1jQpj4mpNOmUjLaTWrTqzJCKoe2XCIeX84UQxj8V+Ot1GjzyK4wF2ASVXOEk692Bue4FH RF58gFTXbaZbf5YM0srXUHwnnTSdsbvEtKVutDE4fZjqwpSfxclXybP9ChEfyK+k6hlcmD iE9nPwlA/d2G61e7QBFIQIFgKiIYkr/si5Tp4oje8P3Cxw/T2mde51yLfFKrI578U6LcVy LTvwFSJobm9cE/XYKDlOVi7YAsob56NxctFPKJ/TN8ru/S4o2OWm9tMnCdzRjkQ360zZzM aUlCS/ExREN7aG7u+9vnEW67tZoepFWuWuj1veN9j7I6KviTOd7oWFFEjHzbLw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686751654; 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=7hUQE7jx0fknKMAL9e6sfNn3hoeeuEK7E2AxmOK/Kq4=; b=Zp2JPID67ZKSHdcUNmB9agCGcbNECGLtbWi+KbGEHVsxXJ21kzyORuLrlHdx8fSHFz8ZBM XPAv3YOD4EkoFkBg== 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-next 5/6] igc: Fix launchtime before start of cycle Date: Wed, 14 Jun 2023 16:07:13 +0200 Message-Id: <20230614140714.14443-6-florian.kauer@linutronix.de> In-Reply-To: <20230614140714.14443-1-florian.kauer@linutronix.de> References: <20230614140714.14443-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,URIBL_BLOCKED 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 35ace8d338a5..ec8649751d19 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -1010,7 +1010,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