Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2534673yba; Mon, 6 May 2019 07:38:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkYU0jzEZuYHeTffB0eLoxEHbzs8llkb1KRf7jPfBHYXLvpCJTtIB2x62MEmIwqFgzzeBE X-Received: by 2002:a62:125c:: with SMTP id a89mr33648618pfj.93.1557153483688; Mon, 06 May 2019 07:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557153483; cv=none; d=google.com; s=arc-20160816; b=vlTPnb4yl5W5D4GAlT6alOAJs/bIYN5+feQXN383xYsU4lO8996IhwYprjRYulK2pX qE6XlGBLEF1QZc0oXPfZCX5LNcRFBAqbtTg7JOiLKN0AXlIYx4HD55+hlDzvOTg/vM47 bJqEjMUOZT2U9CHuGt5CWtWO8gnopOxyD9r5L+k5AEm9/bINW3CuB++wTmXlUW2Qndod 6x7vGgGOAzwu1AJcLclfx9tBE/AXUneqsSE1qZw1KsFfP8q6glY9o3Ndtp31z/SWRc7G bAhSCKLdZ1DLqRnY0UJZ/kt7NAIkSpSN5ofksyxZuhAmmYA+1p4B5oPCIqdIcuv7aJih 0OAQ== 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=ouCTufFHMW4nYkZYt40cxqLHS7DaMrDaRC8w/P9aP4w=; b=z2NjSkSPfkj7GlUB5pj201pEV2isWW6/tq/xCIXxASYdyEN6wIFklUgqM4LO6gPU7e RNGlbizybANf9Q4wT8gcXr5/Cycu+fSJwhFHsWuSZnLFTt8peXJ6ioobxvh4FJ8X5HSA yJk8ejf9Aq3iiEptxRF2ILQ7pU6ODVjkSIvMIja8pGztoNYbgt6hLzIJzTlG1ZB0vvhU sQaphOr9D3mkEQ3LDCkoZlFnjCAU5QgqQn3ZQb/x5XzF/TQ1HDG8ZlfJ8jaAjl2bU4jQ cgyYLaSmJUG+w+9bD+WEg/V9nP1Ljm1fp8CHHqWShaEPSUUWGdHECrbmAg4QE49g7d93 lS/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QoNJ4QZZ; 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 b67si16470669plb.206.2019.05.06.07.37.47; Mon, 06 May 2019 07:38:03 -0700 (PDT) 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=QoNJ4QZZ; 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 S1726855AbfEFOfI (ORCPT + 99 others); Mon, 6 May 2019 10:35:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:55040 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726837AbfEFOfG (ORCPT ); Mon, 6 May 2019 10:35:06 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 D294420B7C; Mon, 6 May 2019 14:35:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557153306; bh=SGIO49HU9nzxxhyzNornMmXmuF4ftIIlr/spORJIoHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QoNJ4QZZHFNm3wIBk8ofECOpGlVOpvXhnx4q1qdTqS5dFpcjp/vv2cXvfxcoFdDcN T319DoXA+w+CzuOghugEymdK1tlxmBZpJl19SW1ov2sEZUndLheHhpZC8+1Jb8Rt4q BP2gjqz/3DpSC1xs0wYfRQ10OKK06DoWESSOonjw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jacob Keller , Arnd Bergmann , Andrew Bowers , Jeff Kirsher , "Sasha Levin (Microsoft)" Subject: [PATCH 5.0 039/122] i40e: fix i40e_ptp_adjtime when given a negative delta Date: Mon, 6 May 2019 16:31:37 +0200 Message-Id: <20190506143058.408004932@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190506143054.670334917@linuxfoundation.org> References: <20190506143054.670334917@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit b3ccbbce1e455b8454d3935eb9ae0a5f18939e24 ] Commit 0ac30ce43323 ("i40e: fix up 32 bit timespec references", 2017-07-26) claims to be cleaning up references to 32-bit timespecs. The actual contents of the commit make no sense, as it converts a call to timespec64_add into timespec64_add_ns. This would seem ok, if (a) the change was documented in the commit message, and (b) timespec64_add_ns supported negative numbers. timespec64_add_ns doesn't work with signed deltas, because the implementation is based around iter_div_u64_rem. This change resulted in a regression where i40e_ptp_adjtime would interpret small negative adjustments as large positive additions, resulting in incorrect behavior. This commit doesn't appear to fix anything, is not well explained, and introduces a bug, so lets just revert it. Reverts: 0ac30ce43323 ("i40e: fix up 32 bit timespec references", 2017-07-26) Signed-off-by: Jacob Keller Reviewed-by: Arnd Bergmann Tested-by: Andrew Bowers Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin (Microsoft) --- drivers/net/ethernet/intel/i40e/i40e_ptp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c index 5fb4353c742b..31575c0bb884 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c @@ -146,12 +146,13 @@ static int i40e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb) static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) { struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); - struct timespec64 now; + struct timespec64 now, then; + then = ns_to_timespec64(delta); mutex_lock(&pf->tmreg_lock); i40e_ptp_read(pf, &now, NULL); - timespec64_add_ns(&now, delta); + now = timespec64_add(now, then); i40e_ptp_write(pf, (const struct timespec64 *)&now); mutex_unlock(&pf->tmreg_lock); -- 2.20.1