From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C36C8C04AAD for ; Mon, 6 May 2019 15:09:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 94DDE2053B for ; Mon, 6 May 2019 15:09:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557155386; bh=SGIO49HU9nzxxhyzNornMmXmuF4ftIIlr/spORJIoHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=uLQ4fD5MhXbscl408DwjnsgOE+62so+pN0og5rU5fWJfKk3M7k48cXeeO9IxhDg5w KjuT+OOhPX2/CuqTpFEze0CVC4InXlbhJrGgnzxzL5UJYusOfW42+0WdQFEyyOjxg7 kumbSKxval0iCFqo0LYHsszZTIIggQW2HtLjnwTg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726843AbfEFOfH (ORCPT ); Mon, 6 May 2019 10:35:07 -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: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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