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=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,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 C865CC5B57D for ; Wed, 3 Jul 2019 02:19:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 993A52187F for ; Wed, 3 Jul 2019 02:19:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562120394; bh=EXU4tNDrkaXGLhQDSTLyzWSbk5vH+e18n79TcZUDWHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=H7hwbi86Qiq24CqWhfoA9Q4MPVdQ7Ly+q9icqr5ViDSAc2ID+ZjcgQ4vYIh+DO7sY T1KfGpZMP1Wb4jGkS2wfu+ALHo1qFK60rMV5O4YYEGCteYiM3zSDeiuuTJh4U4/tTz THuPCrWSF8ZlXOXWXZi1Z89FYhdPa37gwfMlarS0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728347AbfGCCS5 (ORCPT ); Tue, 2 Jul 2019 22:18:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:56766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728323AbfGCCS4 (ORCPT ); Tue, 2 Jul 2019 22:18:56 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2A49B2187F; Wed, 3 Jul 2019 02:18:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562120335; bh=EXU4tNDrkaXGLhQDSTLyzWSbk5vH+e18n79TcZUDWHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K72SugIKAiAmJ0h8Zi1i6gjRXgTWTKNbdbGhM1aE/chyqVR2yXDuxxuRFu3puV+Ff DdQeABDPJW51IzKzk2LmlNKTVi664HaBcWmUgYoLJQSVv+ZR2E1YDGxRHcHiQZE1Vy BgQy6q4XYkZloi7qIVb394iQc+bSPhBAvgzR2NHI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Roland Hii , Ong Boon Leong , Voon Weifeng , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 5/8] net: stmmac: fixed new system time seconds value calculation Date: Tue, 2 Jul 2019 22:18:44 -0400 Message-Id: <20190703021847.18542-5-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703021847.18542-1-sashal@kernel.org> References: <20190703021847.18542-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Roland Hii [ Upstream commit a1e5388b4d5fc78688e5e9ee6641f779721d6291 ] When ADDSUB bit is set, the system time seconds field is calculated as the complement of the seconds part of the update value. For example, if 3.000000001 seconds need to be subtracted from the system time, this field is calculated as 2^32 - 3 = 4294967296 - 3 = 0x100000000 - 3 = 0xFFFFFFFD Previously, the 0x100000000 is mistakenly written as 100000000. This is further simplified from sec = (0x100000000ULL - sec); to sec = -sec; Fixes: ba1ffd74df74 ("stmmac: fix PTP support for GMAC4") Signed-off-by: Roland Hii Signed-off-by: Ong Boon Leong Signed-off-by: Voon Weifeng Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c index f4074e25fb71..25136941a964 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c @@ -125,7 +125,7 @@ static int stmmac_adjust_systime(void __iomem *ioaddr, u32 sec, u32 nsec, * programmed with (2^32 – ) */ if (gmac4) - sec = (100000000ULL - sec); + sec = -sec; value = readl(ioaddr + PTP_TCR); if (value & PTP_TCR_TSCTRLSSR) -- 2.20.1