Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2654624imj; Mon, 11 Feb 2019 06:32:20 -0800 (PST) X-Google-Smtp-Source: AHgI3IYmQ/NVa2HrslwX2QohAlM5jCyr5MaPaZbxevahRx21JPqSb0I1mY58gkW0rGhbypswG0Pt X-Received: by 2002:a17:902:ba85:: with SMTP id k5mr11003792pls.130.1549895540036; Mon, 11 Feb 2019 06:32:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895540; cv=none; d=google.com; s=arc-20160816; b=qT325r2hmBkinxTLbgwKRGKTSdNkX+yPMh0Ky75IxuwdzhOOSF3DtBd9efFSmElxlZ yV4i25pDnT6fPwLk3Rb7X+igNQ+SLhVyzMjaPpIL/fFKJq4jfhaFnFHsA0vRhU5TH8kF Mp6z8poJszXMd412rC/RtqvJAhXhx7qnGKKAD4KR68QiKyiqEgjbTXJ/WMe+YK/YiqP2 vjeFk8a9tNDiF1xfngv592+lX3vwx250JoLn+cvsHyQyd5opyVe5tPhAOEd0utnFdL79 4AxYajKp2lSkNgkj/fbXi6gmJzE8O9qI53iquXsOG2UpyrcudWdbhWecGe2oJnIFAxrP hJ0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1THpnQzIjJU62zU2ptbnz7L+J8ebtqew6Cqz2pC4jpo=; b=ER2sEycYUMcO2hu6QFhBe0jdZFzj1TN5oiMeVKapGaWWFHX7rOYNM+cum/xtk4UIlz yU0t11PBoQz7FGd/CxRe3XfgTbOSD3F4I0Y58TW1cDJEluBq6yhtueyqgknYDLvl32Ex JyRLj9DxDQG1QIolsJKsvOt5eVhbNkSXkET1uHDblFZYWV4FCFOBty7249UTG62jIYH8 Z2ih+daFpzeZJ/k/PX6QNINkNvBK+vx7wQwT5CKpCEPm81UXRLwIBehySm/9UujprI8o 07Ca7qmVZzRDBaSkQ1Rs2AXsgiUihz2ZBA8LoLYglnGcNXcruw6+eENn5EctP/mBrFXp bMtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=H3oYFeGn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 12si10642037pfx.102.2019.02.11.06.32.02; Mon, 11 Feb 2019 06:32:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=H3oYFeGn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730335AbfBKObh (ORCPT + 99 others); Mon, 11 Feb 2019 09:31:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:38548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730325AbfBKObe (ORCPT ); Mon, 11 Feb 2019 09:31:34 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A125820844; Mon, 11 Feb 2019 14:31:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895494; bh=9hVn75N3LPSjsv3h8GF57VsxqxoZ7Po5V16rZH7lrVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H3oYFeGntiXGEvrq1bMe9pHKxhbAA7VZkNkO8CepK0qx/JycOMyzoYUVt6kLpKDq1 cRDtjzsDyRBZo/tbfeemKgEfzPe2ECCWTzxbvcjEfakRCw1Cg6dT2UnJoqp/HUjgPz I8nLWjSw45HSi8QISARy2UWQN67GMYBs+2z1jIFw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Richard Cochran , Ariel Levkovich , Saeed Mahameed , Miroslav Lichvar , Sasha Levin Subject: [PATCH 4.20 224/352] mlx5: update timecounter at least twice per counter overflow Date: Mon, 11 Feb 2019 15:17:31 +0100 Message-Id: <20190211141901.475896932@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 5d8678365c90b9ce1fd2243ff5ea562609f6cec1 ] The timecounter needs to be updated at least once in half of the cyclecounter interval to prevent timecounter_cyc2time() interpreting a new timestamp as an old value and causing a backward jump. This would be an issue if the timecounter multiplier was so small that the update interval would not be limited by the 64-bit overflow in multiplication. Shorten the calculated interval to make sure the timecounter is updated in time even when the system clock is slowed down by up to 10%, the multiplier is increased by up to 10%, and the scheduled overflow check is late by 15%. Cc: Richard Cochran Cc: Ariel Levkovich Cc: Saeed Mahameed Signed-off-by: Miroslav Lichvar Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c index 0d90b1b4a3d3..2d6168ee99e8 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c @@ -511,14 +511,14 @@ void mlx5_init_clock(struct mlx5_core_dev *mdev) ktime_to_ns(ktime_get_real())); /* Calculate period in seconds to call the overflow watchdog - to make - * sure counter is checked at least once every wrap around. + * sure counter is checked at least twice every wrap around. * The period is calculated as the minimum between max HW cycles count * (The clock source mask) and max amount of cycles that can be * multiplied by clock multiplier where the result doesn't exceed * 64bits. */ overflow_cycles = div64_u64(~0ULL >> 1, clock->cycles.mult); - overflow_cycles = min(overflow_cycles, clock->cycles.mask >> 1); + overflow_cycles = min(overflow_cycles, div_u64(clock->cycles.mask, 3)); ns = cyclecounter_cyc2ns(&clock->cycles, overflow_cycles, frac, &frac); -- 2.19.1