From patchwork Fri Apr 14 08:26:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Horatiu Vultur X-Patchwork-Id: 13211106 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 116A9C77B70 for ; Fri, 14 Apr 2023 08:28:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230230AbjDNI15 (ORCPT ); Fri, 14 Apr 2023 04:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230213AbjDNI1c (ORCPT ); Fri, 14 Apr 2023 04:27:32 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB262900C; Fri, 14 Apr 2023 01:27:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1681460829; x=1712996829; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=w2+6B68URgmKUVKHyS0K12IEVdDx3OVx3qeOmOW7/u8=; b=QOHxlzrQUM2Nz4j8qTFJmw/aWGEObVGFfH7W2bAbUx9RQG91N8z1o1gN 1pe1Y2kEq///IFZrqElbxrdUwzbfmxuRNCjeNPxFIdE2zJ8HJj3X6DIiD E4/MdFbK81zaJW+jpuXm5jaisRqTaMPa3LdpZOt4l9fZhX/T2u7N7Fo8S 8joCUc1nJt8SPOHDCe0hwzroKjZmjtx9U4xw6v/n6KTSzpFLz3jvuWWTQ vXBv3bsssVqfXSJzH6ifjS0aGk968D3HH1q4LivqJLT/+O3ZvgVfEzQ00 H/AXDLNyeAd4FL93/RoY+EmGTofxoLOoJar0LwogjVXkBrvWGL7/Sq1cg Q==; X-IronPort-AV: E=Sophos;i="5.99,195,1677567600"; d="scan'208";a="220867924" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Apr 2023 01:27:04 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Fri, 14 Apr 2023 01:27:03 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Fri, 14 Apr 2023 01:27:02 -0700 From: Horatiu Vultur To: , CC: , , , , , , , Horatiu Vultur Subject: [PATCH net-next] net: phy: micrel: Fix PTP_PF_PEROUT for lan8841 Date: Fri, 14 Apr 2023 10:26:59 +0200 Message-ID: <20230414082659.1321686-1-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.38.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org If the 1PPS output was enabled and then lan8841 was configured to be a follower, then target clock which is used to generate the 1PPS was not configure correctly. The problem was that for each adjustments of the time, also the nanosecond part of the target clock was changed. Therefore the initial nanosecond part of the target clock was changed. The issue can be observed if both the leader and the follower are generating 1PPS and see that their PPS are not aligned even if the time is allined. The fix consists of not modifying the nanosecond part of the target clock when adjusting the time. In this way the 1PPS get also aligned. Fixes: e4ed8ba08e3f ("net: phy: micrel: Add support for PTP_PF_PEROUT for lan8841") Signed-off-by: Horatiu Vultur --- drivers/net/phy/micrel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 3fee682603ef5..382144a6306f0 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -4025,7 +4025,7 @@ static int lan8841_ptp_update_target(struct kszphy_ptp_priv *ptp_priv, const struct timespec64 *ts) { return lan8841_ptp_set_target(ptp_priv, LAN8841_EVENT_A, - ts->tv_sec + LAN8841_BUFFER_TIME, ts->tv_nsec); + ts->tv_sec + LAN8841_BUFFER_TIME, 0); } #define LAN8841_PTP_LTC_TARGET_RELOAD_SEC_HI(event) ((event) == LAN8841_EVENT_A ? 282 : 292)