From nobody Tue Dec 16 23:59:22 2025 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 894CDC71153 for ; Thu, 24 Aug 2023 18:34:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243078AbjHXSeP (ORCPT ); Thu, 24 Aug 2023 14:34:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243069AbjHXSdq (ORCPT ); Thu, 24 Aug 2023 14:33:46 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A218D1BE5 for ; Thu, 24 Aug 2023 11:33:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692901980; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6MSPeUOmvEq1eUUgwQ2syHQsuZQFtArlwfrE4/FiNFk=; b=MlFwLBFWJG6gjowEuFQCKNzg9JVCfTrGVQgaLU9iWtUcx6YAE/byFaQzduOJ8eq40QIEYL U/y0CXWakzmuxFykx5wNhtp3oMCy2S8oRXjdu3RVAivM0dool/YSaTvV8BBqzgr5cK+w9N 7K5vl69YJnVD4EVnYD3wg5otyWehKKg= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-613-fIwoh08cPwe46NH9gP9zAg-1; Thu, 24 Aug 2023 14:32:59 -0400 X-MC-Unique: fIwoh08cPwe46NH9gP9zAg-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-649fac91500so11618456d6.1 for ; Thu, 24 Aug 2023 11:32:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692901979; x=1693506779; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6MSPeUOmvEq1eUUgwQ2syHQsuZQFtArlwfrE4/FiNFk=; b=gO+kZ/XapO2vwuN2Fsv0ujRD8EpWHkxxNsWHVYvLCvXHkelwrTP2XnwWjcO98w4esa 8WN8KjE6AgaadsZEaZCR/FaPGfnK1d4MQCwl7/qSZctxXNro9nPpx65qE+oLKWYXZUNP ubYci8ZmUISxsueZQUo6a13olBJjXi97xeRL3pTJHikOCdFKi6vehjgW+RiS/u34saXK 5eqOxnX6jiEl8nOyvhmgnpzpH5Td6U8uS8N7afNca4u6jQOYSS9CIfAxnjL9wyYbyXFo /h/CisMgYYfBtJKF2gPjyJn1MaUQ9y5pb1Y8kaFQNG96r6yN8k6yHjjfJwI+9jVcj2aJ sWwA== X-Gm-Message-State: AOJu0YxlLZt82fjGdHByHM0c/Ygkz396VBIbl3DW924Ju+DfNI3KQlX8 w54WD4KOCViWxQDo70vQSqc/FbsipgZeLaK0lC5lLJw6QBDrhC0erMaUEHy+bYgQYf1wqwZ7JPK Au2/Oo/sOAV1kqmhuHu9e1ZuG X-Received: by 2002:a0c:e246:0:b0:647:2653:bcc with SMTP id x6-20020a0ce246000000b0064726530bccmr18915153qvl.13.1692901978980; Thu, 24 Aug 2023 11:32:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOnxZtOm4Zbo/1b64keu9y2z8jyW5dWXMkNKbfmN/AXxPf8v016bCHVXCzjBnQUDUxKTav6w== X-Received: by 2002:a0c:e246:0:b0:647:2653:bcc with SMTP id x6-20020a0ce246000000b0064726530bccmr18915120qvl.13.1692901978737; Thu, 24 Aug 2023 11:32:58 -0700 (PDT) Received: from [192.168.1.165] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id j17-20020a0ceb11000000b0064f77d37798sm4209qvp.5.2023.08.24.11.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 11:32:58 -0700 (PDT) From: Andrew Halaney Date: Thu, 24 Aug 2023 13:32:52 -0500 Subject: [PATCH net-next 1/7] net: stmmac: Use consistent variable name for subsecond increment MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230824-stmmac-subsecond-inc-cleanup-v1-1-e0b9f7c18b37@redhat.com> References: <20230824-stmmac-subsecond-inc-cleanup-v1-0-e0b9f7c18b37@redhat.com> In-Reply-To: <20230824-stmmac-subsecond-inc-cleanup-v1-0-e0b9f7c18b37@redhat.com> To: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Subsecond increment is the name of the field being programmed. Let's stop using a bunch of variations of that name and just use sub_second_inc throughout. Signed-off-by: Andrew Halaney --- drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 6 +++--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ether= net/stmicro/stmmac/hwif.h index 238f17c50a1e..bd607da65037 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -524,7 +524,7 @@ struct stmmac_ops { struct stmmac_hwtimestamp { void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data); void (*config_sub_second_increment)(void __iomem *ioaddr, u32 ptp_clock, - int gmac4, u32 *ssinc); + int gmac4, u32 *sub_second_inc); int (*init_systime) (void __iomem *ioaddr, u32 sec, u32 nsec); int (*config_addend) (void __iomem *ioaddr, u32 addend); int (*adjust_systime) (void __iomem *ioaddr, u32 sec, u32 nsec, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/driver= s/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c index 540f6a4ec0b8..6dcf8582a70e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c @@ -24,7 +24,7 @@ static void config_hw_tstamping(void __iomem *ioaddr, u32= data) } =20 static void config_sub_second_increment(void __iomem *ioaddr, - u32 ptp_clock, int gmac4, u32 *ssinc) + u32 ptp_clock, int gmac4, u32 *sub_second_inc) { u32 value =3D readl(ioaddr + PTP_TCR); unsigned long data; @@ -56,8 +56,8 @@ static void config_sub_second_increment(void __iomem *ioa= ddr, =20 writel(reg_value, ioaddr + PTP_SSIR); =20 - if (ssinc) - *ssinc =3D data; + if (sub_second_inc) + *sub_second_inc =3D data; } =20 static void hwtstamp_correct_latency(struct stmmac_priv *priv) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index 7a9bbcf03ea5..67e4f65f0f68 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -836,7 +836,7 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *priv= , u32 systime_flags) { bool xmac =3D priv->plat->has_gmac4 || priv->plat->has_xgmac; struct timespec64 now; - u32 sec_inc =3D 0; + u32 sub_second_inc =3D 0; u64 temp =3D 0; =20 if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp)) @@ -848,16 +848,16 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *pr= iv, u32 systime_flags) /* program Sub Second Increment reg */ stmmac_config_sub_second_increment(priv, priv->ptpaddr, priv->plat->clk_ptp_rate, - xmac, &sec_inc); - temp =3D div_u64(1000000000ULL, sec_inc); + xmac, &sub_second_inc); + temp =3D div_u64(1000000000ULL, sub_second_inc); =20 /* Store sub second increment for later use */ - priv->sub_second_inc =3D sec_inc; + priv->sub_second_inc =3D sub_second_inc; =20 /* calculate default added value: * formula is : * addend =3D (2^32)/freq_div_ratio; - * where, freq_div_ratio =3D 1e9ns/sec_inc + * where, freq_div_ratio =3D 1e9ns/sub_second_inc */ temp =3D (u64)(temp << 32); priv->default_addend =3D div_u64(temp, priv->plat->clk_ptp_rate); --=20 2.41.0 From nobody Tue Dec 16 23:59:22 2025 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 C1671C7EE43 for ; Thu, 24 Aug 2023 18:34:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243097AbjHXSeR (ORCPT ); Thu, 24 Aug 2023 14:34:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243082AbjHXSdv (ORCPT ); Thu, 24 Aug 2023 14:33:51 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D8B519B0 for ; Thu, 24 Aug 2023 11:33:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692901982; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=thxHPyqpXjBOV26mQw4932uoaf4t0NSsG4y7+rk0Hj4=; b=gYa4tBS4f5oK40bQR6hGQM5vJLmEyh8YfSRCxWo7/SisVwV7IL6LzmSJq1wpMePpaiMyMI K28ti6ALn5+5ZkQdm2zixodxGQbSWe8upww+yk2k9u9jC3631LZJ8Z1DmAQipP/yvO86sU GBgMKvO94M7BslCERBd7ycU6m0d7WkY= Received: from mail-oa1-f70.google.com (mail-oa1-f70.google.com [209.85.160.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-483-7o7M4F2mM4aKVtHl2tR8Dw-1; Thu, 24 Aug 2023 14:33:00 -0400 X-MC-Unique: 7o7M4F2mM4aKVtHl2tR8Dw-1 Received: by mail-oa1-f70.google.com with SMTP id 586e51a60fabf-1ccbcb5034aso101658fac.3 for ; Thu, 24 Aug 2023 11:33:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692901980; x=1693506780; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=thxHPyqpXjBOV26mQw4932uoaf4t0NSsG4y7+rk0Hj4=; b=jUUcpkeSLDCTQQDZpm9wPEAgnsfwKx4e16JVSiFaQSELXXiCVmNAgbwwxAmxIyKUQQ joVQV6+ULC/b/GS2RN2S9+an5y6mGndqFs322kLzVLVqelr+7ixti2MPGthJ3DEYP0Ec Nvr9kbxpeg0O/k6rbdtkeVYUql0rue+xkNMjkRpmiia+G+2NdoPwvbdwodXWINV2T+O4 7nXp9cHxsX08IsE8XaJg5oijee8s/k0vK7NkgKCSmhRVfxdRPBXFkQ4MPdEAvc0EN/2b GRqH5gDJi289wkoMFzg3Jc2nzO32FATUC9CLhu4V5eGdTHHIO6hnTPcmXt8i4Jfnlc3q uISw== X-Gm-Message-State: AOJu0YyONr7o5II40k8r4N+HZNLtPWjF9j/ocYb0sp89E/SMOR+55bHv G9olBBvILRMofXInRH3RkBxIWujsheT2gnWsQdwCuSdQKNUoJi6xAH07K2CsExRbRzkQnsbjO6T r3WE57mqcL02Y8AiTykQhgUTo X-Received: by 2002:a05:6870:b30e:b0:1c8:b870:4e62 with SMTP id a14-20020a056870b30e00b001c8b8704e62mr553972oao.52.1692901980218; Thu, 24 Aug 2023 11:33:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNSmaNfEZS7WL931iN10lI15Wz+1s4J2mbWyoGTTDkdpLqrEtuCwFnkDMpqeyKk0MWFoSBXQ== X-Received: by 2002:a05:6870:b30e:b0:1c8:b870:4e62 with SMTP id a14-20020a056870b30e00b001c8b8704e62mr553945oao.52.1692901979913; Thu, 24 Aug 2023 11:32:59 -0700 (PDT) Received: from [192.168.1.165] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id j17-20020a0ceb11000000b0064f77d37798sm4209qvp.5.2023.08.24.11.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 11:32:59 -0700 (PDT) From: Andrew Halaney Date: Thu, 24 Aug 2023 13:32:53 -0500 Subject: [PATCH net-next 2/7] net: stmmac: Use NSEC_PER_SEC for hwtstamp calculations MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230824-stmmac-subsecond-inc-cleanup-v1-2-e0b9f7c18b37@redhat.com> References: <20230824-stmmac-subsecond-inc-cleanup-v1-0-e0b9f7c18b37@redhat.com> In-Reply-To: <20230824-stmmac-subsecond-inc-cleanup-v1-0-e0b9f7c18b37@redhat.com> To: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This makes it more clear what unit conversions are happening. Signed-off-by: Andrew Halaney --- drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 6 +++--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/driver= s/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c index 6dcf8582a70e..29fd51bb853d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c @@ -36,12 +36,12 @@ static void config_sub_second_increment(void __iomem *i= oaddr, * to mid-range =3D 2^31 when the remainder of this division is zero, * which will make the accumulator overflow once every 2 ptp_clock * cycles, adding twice the number of nanoseconds of a clock cycle : - * 2000000000ULL / ptp_clock. + * 2 * NSEC_PER_SEC / ptp_clock. */ if (value & PTP_TCR_TSCFUPDT) - data =3D (2000000000ULL / ptp_clock); + data =3D (2 * NSEC_PER_SEC / ptp_clock); else - data =3D (1000000000ULL / ptp_clock); + data =3D (NSEC_PER_SEC / ptp_clock); =20 /* 0.465ns accuracy */ if (!(value & PTP_TCR_TSCTRLSSR)) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index 67e4f65f0f68..ba38ca284e26 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -849,7 +849,7 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *priv= , u32 systime_flags) stmmac_config_sub_second_increment(priv, priv->ptpaddr, priv->plat->clk_ptp_rate, xmac, &sub_second_inc); - temp =3D div_u64(1000000000ULL, sub_second_inc); + temp =3D div_u64(NSEC_PER_SEC, sub_second_inc); =20 /* Store sub second increment for later use */ priv->sub_second_inc =3D sub_second_inc; --=20 2.41.0 From nobody Tue Dec 16 23:59:22 2025 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 E1169C88CB2 for ; Thu, 24 Aug 2023 18:34:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243108AbjHXSeT (ORCPT ); Thu, 24 Aug 2023 14:34:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243088AbjHXSdx (ORCPT ); Thu, 24 Aug 2023 14:33:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C7EA19A3 for ; Thu, 24 Aug 2023 11:33:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692901983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6l23XMepM0Sh/iOcowpX76UCT+vWOCxLFJ6fQYXhTVo=; b=X0y107lxiVSyYEmIPUufzreSZ7fAZXPY6VHZIVHtZyobUFY1zBYE41vOxI/IghliVsVQXO jjepjQmwzAhZp5kDJste6kkkTLQjMyhvh55CxNyQoulYBTVEcDIi4EsA+BznCaHUZxiFJ1 LVOWyBxc1BGxKg2uzlUpDWJB/lxDqyo= Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-668-XOuaS_s8MJW5f72hwjyl3A-1; Thu, 24 Aug 2023 14:33:02 -0400 X-MC-Unique: XOuaS_s8MJW5f72hwjyl3A-1 Received: by mail-oo1-f69.google.com with SMTP id 006d021491bc7-5711abe79ffso185720eaf.1 for ; Thu, 24 Aug 2023 11:33:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692901981; x=1693506781; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6l23XMepM0Sh/iOcowpX76UCT+vWOCxLFJ6fQYXhTVo=; b=g1jJ0EVU9hJH2yNEbb0XA3vC2Sem4SjKUppBbZTO9isWIkRJRsmgFoniZUmPBDZtud X4waRVzIy+4i6HXnMnYbdMMJp8v38rqsfuvVDLn0VaUV9Pep8Gp5Z1tqC1Qg0NJb4CgX KsdQ0wwysC8XxDye/vpI535nV/N12crhk4lQNjXLsTNBV1gEKC6Qp3TkMi6TQb1mXZ/V Q5+qTlnQHqmoxdg9FE01rvQTCLDYu03FwpeO1C3K6T2RL+43MQvVLPUH+mKNWvpRSYMt gH3NfiiDnYgJEIGksMraBA7uhSIe4c87Y811lDeBCO5/aGy3PQkLlsymoaKW0Y+yfw1U lP7Q== X-Gm-Message-State: AOJu0Yxnc0/a0Cnk4yQ40+FxoiWDS8IONNT0ECo7ev/yhrevNaNlgJPb HNyCt/KoDUaWDFr/37k1MuKqXkDn1XOSu8ynzQJGJDJQx5bIYSfcNlfzAL37qpzr9zr0K4FtpOI 0RU+ORa43oyhY7++ii0sfQoP9 X-Received: by 2002:a05:6870:e253:b0:1be:f8d9:7bdd with SMTP id d19-20020a056870e25300b001bef8d97bddmr627381oac.6.1692901981471; Thu, 24 Aug 2023 11:33:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHS3fEn/UFcZp7p1JhHHa0Wzb/ax2PIiQ32dL4ujO6wuTfaKPgzGkO+lp3kAWh66sAyZwY+xw== X-Received: by 2002:a05:6870:e253:b0:1be:f8d9:7bdd with SMTP id d19-20020a056870e25300b001bef8d97bddmr627359oac.6.1692901981225; Thu, 24 Aug 2023 11:33:01 -0700 (PDT) Received: from [192.168.1.165] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id j17-20020a0ceb11000000b0064f77d37798sm4209qvp.5.2023.08.24.11.33.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 11:33:00 -0700 (PDT) From: Andrew Halaney Date: Thu, 24 Aug 2023 13:32:54 -0500 Subject: [PATCH net-next 3/7] net: stmmac: Precede entire addend calculation with its comment MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230824-stmmac-subsecond-inc-cleanup-v1-3-e0b9f7c18b37@redhat.com> References: <20230824-stmmac-subsecond-inc-cleanup-v1-0-e0b9f7c18b37@redhat.com> In-Reply-To: <20230824-stmmac-subsecond-inc-cleanup-v1-0-e0b9f7c18b37@redhat.com> To: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The addend calculation is currently split. The variable to be programmed is first altered, then a comment explaining the full calculation is seen, then the variable is altered further before the calculation is finished. Make the comment the first thing read. This makes the conversion of sub_second_increment from nanoseconds to hertz much easier to understand and reads logically. Signed-off-by: Andrew Halaney --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index ba38ca284e26..f0e585e6ef76 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -849,7 +849,6 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *priv= , u32 systime_flags) stmmac_config_sub_second_increment(priv, priv->ptpaddr, priv->plat->clk_ptp_rate, xmac, &sub_second_inc); - temp =3D div_u64(NSEC_PER_SEC, sub_second_inc); =20 /* Store sub second increment for later use */ priv->sub_second_inc =3D sub_second_inc; @@ -859,6 +858,7 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *priv= , u32 systime_flags) * addend =3D (2^32)/freq_div_ratio; * where, freq_div_ratio =3D 1e9ns/sub_second_inc */ + temp =3D div_u64(NSEC_PER_SEC, sub_second_inc); temp =3D (u64)(temp << 32); priv->default_addend =3D div_u64(temp, priv->plat->clk_ptp_rate); stmmac_config_addend(priv, priv->ptpaddr, priv->default_addend); --=20 2.41.0 From nobody Tue Dec 16 23:59:22 2025 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 AF6E9C7EE2C for ; Thu, 24 Aug 2023 18:34:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243103AbjHXSeS (ORCPT ); Thu, 24 Aug 2023 14:34:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243089AbjHXSdx (ORCPT ); Thu, 24 Aug 2023 14:33:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F0971BEB for ; Thu, 24 Aug 2023 11:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692901984; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XQSvh9slhSAVrK9RWa2tfsuNvxEUSp0MXiAFYeXPuAw=; b=XJfc4y6N2faFmurv6tTIlm1ifXhNdcbkV5RcYj9ST7tFrp7hrZakhqKF9te/G2q/psf3ds KOcTdHPhDXmfSuaSws3mxTP7cmsxArBiwjd2x4iKwZNPr7+Rg/zWnZTKP28hEMCKXogyaI EY+Or76eHK0L7xAWRvgUtnMFBSwZe8w= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-670-ctDG47sWNoqiMu8LaOB5yw-1; Thu, 24 Aug 2023 14:33:03 -0400 X-MC-Unique: ctDG47sWNoqiMu8LaOB5yw-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-63faa1e03a8so1450286d6.2 for ; Thu, 24 Aug 2023 11:33:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692901982; x=1693506782; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XQSvh9slhSAVrK9RWa2tfsuNvxEUSp0MXiAFYeXPuAw=; b=iUJEBp4+11rGhkLEUMtnp5aRwkbUI8FOHlHzpaz40iXp5PuJAv0IFhx+tsht9TFfQK HxfQYK/dNytp3f8URyjGFG+CtZMpZ+CYlrhZJ7JXJqTGm6KvtLJMOVGPgcMnUZuEYZqs mSkTfhMuUZE51VywYkfRE2ivzDC/c+nJ4f0nru1SqUhdO/ldRbSXMi+EilwMDWcd4d7t fEd8/nUYvN0YL2q+cwjaPebaEO21SNdOzooVmPcrBn8ESSUoGk8G5XX84ce7KY6Dg4iK sT8dg2rJDT7Ivzk+bpXbboV7KmX1+ixKMyTfG6R7rbUFcO0LktOr0jopq2PrlfKpdivl tkMw== X-Gm-Message-State: AOJu0Yyh7YE13/MetITYu1u/mQ0RuKoOJvGPFJA62NBbST41u+lNl+Fi s4H4BKDK2fb/uIxDVmWzXGNNHG5kAkrUULw85kofqysDviWSUGy0JKmzJB10fGQp/xkLvwcx1zr 6iYhWmucCT7c49Ceh4i8K9Z0m X-Received: by 2002:a0c:a99b:0:b0:63a:5ebc:6e7a with SMTP id a27-20020a0ca99b000000b0063a5ebc6e7amr15574218qvb.31.1692901982709; Thu, 24 Aug 2023 11:33:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFj5ZJm6hpe0krNTRRf2s5iyapXzQ1FpiG0EpY/VpNEjLrDgHOUR63fuY3Iw6CLeMnPKpjAVQ== X-Received: by 2002:a0c:a99b:0:b0:63a:5ebc:6e7a with SMTP id a27-20020a0ca99b000000b0063a5ebc6e7amr15574200qvb.31.1692901982497; Thu, 24 Aug 2023 11:33:02 -0700 (PDT) Received: from [192.168.1.165] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id j17-20020a0ceb11000000b0064f77d37798sm4209qvp.5.2023.08.24.11.33.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 11:33:02 -0700 (PDT) From: Andrew Halaney Date: Thu, 24 Aug 2023 13:32:55 -0500 Subject: [PATCH net-next 4/7] net: stmmac: Remove a pointless cast MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230824-stmmac-subsecond-inc-cleanup-v1-4-e0b9f7c18b37@redhat.com> References: <20230824-stmmac-subsecond-inc-cleanup-v1-0-e0b9f7c18b37@redhat.com> In-Reply-To: <20230824-stmmac-subsecond-inc-cleanup-v1-0-e0b9f7c18b37@redhat.com> To: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The type is already u64, there's no reason to cast it again. Signed-off-by: Andrew Halaney --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index f0e585e6ef76..20ef068b3e6b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -859,7 +859,7 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *priv= , u32 systime_flags) * where, freq_div_ratio =3D 1e9ns/sub_second_inc */ temp =3D div_u64(NSEC_PER_SEC, sub_second_inc); - temp =3D (u64)(temp << 32); + temp =3D temp << 32; priv->default_addend =3D div_u64(temp, priv->plat->clk_ptp_rate); stmmac_config_addend(priv, priv->ptpaddr, priv->default_addend); =20 --=20 2.41.0 From nobody Tue Dec 16 23:59:22 2025 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 10853EE4993 for ; Thu, 24 Aug 2023 18:34:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243112AbjHXSeW (ORCPT ); Thu, 24 Aug 2023 14:34:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243091AbjHXSdx (ORCPT ); Thu, 24 Aug 2023 14:33:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3E291BE9 for ; Thu, 24 Aug 2023 11:33:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692901985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kLlThC3R9OImoZ+MRsaHGOa2SVCnd5iJ51KhprNayB4=; b=WI7GAb87tP7mnRpBeTH91Znyjn1cl6S5pWbLfXl89I62rPWiJ1mi3ExG69AI3NceGiB2+B J+r/tGPsVW2Q3QaaR8Ud/ot4DDrI5hX42/1NXmIoPqsiOyTyGfF5DNCdFwayx+jvefuhME 2HG/A67KcfqLKLhgQHXLJRAH4KLlS3U= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-146-mVWxVleXNsma081_XsL5Nw-1; Thu, 24 Aug 2023 14:33:04 -0400 X-MC-Unique: mVWxVleXNsma081_XsL5Nw-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-649fac91500so11618886d6.1 for ; Thu, 24 Aug 2023 11:33:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692901984; x=1693506784; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kLlThC3R9OImoZ+MRsaHGOa2SVCnd5iJ51KhprNayB4=; b=I0bsBaITLTs+4yGzzwZKY/nwGrexL+jKS4FNzCqX+fVcWnJMftALfiDmAWongkpxcN eatsrtyXGge7R4ieTcNrdXN6iX51F/qZ3N8LD8vkp/qFKe6HfU1fcDvzcV2Pf2RBbZaZ t7jGtXmoHeuwb8zYKLIKNQXmtE/FK9x+TZRTX4g/tFl0Fe2HLr5wxDBwxvPWtxw5PRPL rRSUkh29Eq1l/LGJdp5pJRWP7ts+PmFsBtuGqWr8BRGfTVngzGK70IvvA6/l/yqvV2uw e0I0qWjX4uNX4uIqFNPXsJ3n+fs4EWd3chQc9fQ1/c9qVmhdCQj5GE+47nR7N1L84rS6 qN0g== X-Gm-Message-State: AOJu0YxfIvkQn3b4RpmCaW6aABC/mS3jn5Gute9/mzpNzvA6MHsC1XgU Q6oarbnET91xtxUjA1LeUqkk5MUhaqubICRFISAuKNgVvls8icHe4tuHe0btrLcyQgFvhz6saML JspJ+R7yddoEFazMN14WKb2DN X-Received: by 2002:a05:6214:ac9:b0:64b:926a:e7fc with SMTP id g9-20020a0562140ac900b0064b926ae7fcmr19233930qvi.21.1692901984162; Thu, 24 Aug 2023 11:33:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/pC6Ozwx0rjBhGbBoQuQPKXeDRWWo7/yf47bHb2XuaionNEwEaUXyApPQsLo9pKSgtTNXGg== X-Received: by 2002:a05:6214:ac9:b0:64b:926a:e7fc with SMTP id g9-20020a0562140ac900b0064b926ae7fcmr19233915qvi.21.1692901983920; Thu, 24 Aug 2023 11:33:03 -0700 (PDT) Received: from [192.168.1.165] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id j17-20020a0ceb11000000b0064f77d37798sm4209qvp.5.2023.08.24.11.33.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 11:33:03 -0700 (PDT) From: Andrew Halaney Date: Thu, 24 Aug 2023 13:32:56 -0500 Subject: [PATCH net-next 5/7] net: stmmac: Correct addend typo MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230824-stmmac-subsecond-inc-cleanup-v1-5-e0b9f7c18b37@redhat.com> References: <20230824-stmmac-subsecond-inc-cleanup-v1-0-e0b9f7c18b37@redhat.com> In-Reply-To: <20230824-stmmac-subsecond-inc-cleanup-v1-0-e0b9f7c18b37@redhat.com> To: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org added should be addend in this context. Signed-off-by: Andrew Halaney --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index 20ef068b3e6b..dfead0df6163 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -853,7 +853,7 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *priv= , u32 systime_flags) /* Store sub second increment for later use */ priv->sub_second_inc =3D sub_second_inc; =20 - /* calculate default added value: + /* calculate default addend value: * formula is : * addend =3D (2^32)/freq_div_ratio; * where, freq_div_ratio =3D 1e9ns/sub_second_inc --=20 2.41.0 From nobody Tue Dec 16 23:59:22 2025 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 9ED02C3DA6F for ; Thu, 24 Aug 2023 18:34:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243092AbjHXSeQ (ORCPT ); Thu, 24 Aug 2023 14:34:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243083AbjHXSdv (ORCPT ); Thu, 24 Aug 2023 14:33:51 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 477CB19BE for ; Thu, 24 Aug 2023 11:33:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692901987; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZLXDxLfpL9zLoWLRxApVYve11hS/OEKZe5Jy4SYblss=; b=D89olKtSfR2cYQvbsASFJfWvuU398byhR+5AemSdKcCMdSyJyEyPckXXqpGFsnLtdDXjIQ of6Ih/NSxHJ157Km0p5n0McNZltGJ6Sj3PbMCqdxyIPlst7xrQitts+KGfglK8P6Equ/pJ HzvVUbFCC9XUzhJFzMdqmY0vCo3l02I= Received: from mail-oa1-f72.google.com (mail-oa1-f72.google.com [209.85.160.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-611-_pkhuncZOEezRLgo4woftQ-1; Thu, 24 Aug 2023 14:33:06 -0400 X-MC-Unique: _pkhuncZOEezRLgo4woftQ-1 Received: by mail-oa1-f72.google.com with SMTP id 586e51a60fabf-1c0ed186cf5so110053fac.1 for ; Thu, 24 Aug 2023 11:33:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692901985; x=1693506785; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZLXDxLfpL9zLoWLRxApVYve11hS/OEKZe5Jy4SYblss=; b=GmHuy+3R/3/MOI3pXOq7HVyQ+pj3pBK8vxtI/1WzoFvhz+1+BRQWNUjML7yw/7GJck h3QmXB2BwSbmaTY8z6GFTMKlwssKpPVy+awbTvhHvHa80mH1LlQovzSzD/YE9x9t5cir T07YL92qVqTDK7xg1brzVOesQJzqeJE1uGjfqJg8P0JcPM29CeQ7ncjJf4gBTd8OlcFF yjaFZv6pWU6kncUew7q2ngCvoC/Sa8Ek5HeqaLL2Ztz5vleWwQ7gconHEaXthXs1nalU 34AVPEWuzheZraPKlWuRhWb9hZBjpOuwcBNsW49XhvuoFbRoim8+nyxl8YUVDmkvYyYK IAFg== X-Gm-Message-State: AOJu0YxIY23uFGJfCIHBaWaLceZY3jv+P5dmPyRkp3pmEK0qHO9SJ/Ls Lo5AcGosZF5fKDv1s8o2MF6U5wGOQbGfwIP3Rg6UwDQgED89YmfD2Og2Cg9WCBe3qPfaX7I3aTy CSeWwm4kY07+crIqHhD41Aklm X-Received: by 2002:a05:6871:299:b0:1b4:60b3:98bc with SMTP id i25-20020a056871029900b001b460b398bcmr646681oae.2.1692901985290; Thu, 24 Aug 2023 11:33:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbJca0VCeTskNWvGHD1H3TewlM9C3a0yafFFNkx3PrLHoWuGVt7iXKwhjuSJvnGG6tkI3pdg== X-Received: by 2002:a05:6871:299:b0:1b4:60b3:98bc with SMTP id i25-20020a056871029900b001b460b398bcmr646661oae.2.1692901985092; Thu, 24 Aug 2023 11:33:05 -0700 (PDT) Received: from [192.168.1.165] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id j17-20020a0ceb11000000b0064f77d37798sm4209qvp.5.2023.08.24.11.33.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 11:33:04 -0700 (PDT) From: Andrew Halaney Date: Thu, 24 Aug 2023 13:32:57 -0500 Subject: [PATCH net-next 6/7] net: stmmac: Fix comment about default addend calculation MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230824-stmmac-subsecond-inc-cleanup-v1-6-e0b9f7c18b37@redhat.com> References: <20230824-stmmac-subsecond-inc-cleanup-v1-0-e0b9f7c18b37@redhat.com> In-Reply-To: <20230824-stmmac-subsecond-inc-cleanup-v1-0-e0b9f7c18b37@redhat.com> To: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The comment neglects that freq_div_ratio is the ratio between the subsecond increment frequency and the clk_ptp_rate frequency. Signed-off-by: Andrew Halaney --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index dfead0df6163..64185753865f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -853,10 +853,12 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *pr= iv, u32 systime_flags) /* Store sub second increment for later use */ priv->sub_second_inc =3D sub_second_inc; =20 - /* calculate default addend value: - * formula is : - * addend =3D (2^32)/freq_div_ratio; - * where, freq_div_ratio =3D 1e9ns/sub_second_inc + /* Calculate default addend so the accumulator overflows (2^32) in + * sub_second_inc (ns). The addend is added to the accumulator + * every clk_ptp cycle. + * + * addend =3D (2^32) / freq_div_ratio + * where, freq_div_ratio =3D (1e9ns / sub_second_inc) / clk_ptp_rate */ temp =3D div_u64(NSEC_PER_SEC, sub_second_inc); temp =3D temp << 32; --=20 2.41.0 From nobody Tue Dec 16 23:59:22 2025 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 F3528C83003 for ; Thu, 24 Aug 2023 18:34:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243117AbjHXSeX (ORCPT ); Thu, 24 Aug 2023 14:34:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243101AbjHXSd5 (ORCPT ); Thu, 24 Aug 2023 14:33:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B72931BF6 for ; Thu, 24 Aug 2023 11:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692901988; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qzwAY3qfQtSXBG/JoTJUgqmvExN/Fjeet/g8tdk5k1I=; b=TL9fvLw+yqz3s/7odtWIpAK6orDDc5L4WsTsgNyPMRhkB8P+WF01UC5wKRMeyqXG55V0r8 p1y8Em/jvelAmvKMOMD1fxDswIj8jfFcqeRUbsOZeqsG/skBuaLFUZoEaqB8zFn+zurMVZ vr0AsIYmcKuwi0lc58z4llPjbAB0YqM= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-464-x7ETsS2zMmiHg6alqRKLvg-1; Thu, 24 Aug 2023 14:33:07 -0400 X-MC-Unique: x7ETsS2zMmiHg6alqRKLvg-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-64aaa3c2bc2so1487276d6.0 for ; Thu, 24 Aug 2023 11:33:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692901987; x=1693506787; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qzwAY3qfQtSXBG/JoTJUgqmvExN/Fjeet/g8tdk5k1I=; b=RjbZrgetXaoXL2M/cZ6nqPUeTSAraVr5OTGzFgNPyTs++f4b/6jxT3sYWR2xQX2GS4 vAtnxV87oSaag50Xrk1KEpZXn3LttLhinxRObI5p9NoRQJ9Fw2/RbLhE6eLZJW2LVYMi P7ttvodM3vkRQmyPsbejgpRp3vKmWmQDJPGf8sYEAUSNZVcUhFS1njaApIs58E2m32qy AbEtFF1EsahTjOdpPZbR5Nlh8q8/sBWTnCPVIOQfrT4q0t4S0WAflLFeK/f05VDSdMi3 rCq/Hk+o5WuAPtmgB7TzwLg0OK8OONrxl6l8c0Zdwc1ftpyfrk0XnWFgIyGhpdDjAML2 SSLw== X-Gm-Message-State: AOJu0YxcIq4RIie6FqdgCq0zpKVIs2uxtS8pkrXuf5Bz27It0Z4PWBox KnMdgk/HDaluAqIAFg9y9rx3GiA72ItOTQRoulnMsvAOpoC3epWPYPs0icmCpqU5ZIVmfzDQqSq 2aJbzc/9oi6xsFrGSLaU/cmAq X-Received: by 2002:a0c:cb8a:0:b0:64b:997f:5a73 with SMTP id p10-20020a0ccb8a000000b0064b997f5a73mr17312069qvk.0.1692901986875; Thu, 24 Aug 2023 11:33:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0V6Mej9o119R+pmyxj+YFe+lm4pgu3DlavB9TMY9jyVspWXod0xr56aTpa4++K5uMfm7xpg== X-Received: by 2002:a0c:cb8a:0:b0:64b:997f:5a73 with SMTP id p10-20020a0ccb8a000000b0064b997f5a73mr17312048qvk.0.1692901986627; Thu, 24 Aug 2023 11:33:06 -0700 (PDT) Received: from [192.168.1.165] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id j17-20020a0ceb11000000b0064f77d37798sm4209qvp.5.2023.08.24.11.33.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 11:33:06 -0700 (PDT) From: Andrew Halaney Date: Thu, 24 Aug 2023 13:32:58 -0500 Subject: [PATCH net-next 7/7] net: stmmac: Make PTP reference clock references more clear MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230824-stmmac-subsecond-inc-cleanup-v1-7-e0b9f7c18b37@redhat.com> References: <20230824-stmmac-subsecond-inc-cleanup-v1-0-e0b9f7c18b37@redhat.com> In-Reply-To: <20230824-stmmac-subsecond-inc-cleanup-v1-0-e0b9f7c18b37@redhat.com> To: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ptp_clock is an overloaded term, and in some instances it is used to represent the clk_ptp_rate variable. Just use that name as it is clear that it represents the rate of the PTP reference clock. Signed-off-by: Andrew Halaney --- drivers/net/ethernet/stmicro/stmmac/hwif.h | 5 +++-- drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ether= net/stmicro/stmmac/hwif.h index bd607da65037..ba92b10cff0e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -523,8 +523,9 @@ struct stmmac_ops { /* PTP and HW Timer helpers */ struct stmmac_hwtimestamp { void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data); - void (*config_sub_second_increment)(void __iomem *ioaddr, u32 ptp_clock, - int gmac4, u32 *sub_second_inc); + void (*config_sub_second_increment)(void __iomem *ioaddr, + u32 clk_ptp_rate, + int gmac4, u32 *sub_second_inc); int (*init_systime) (void __iomem *ioaddr, u32 sec, u32 nsec); int (*config_addend) (void __iomem *ioaddr, u32 addend); int (*adjust_systime) (void __iomem *ioaddr, u32 sec, u32 nsec, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/driver= s/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c index 29fd51bb853d..cc0386ee6dee 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c @@ -24,7 +24,7 @@ static void config_hw_tstamping(void __iomem *ioaddr, u32= data) } =20 static void config_sub_second_increment(void __iomem *ioaddr, - u32 ptp_clock, int gmac4, u32 *sub_second_inc) + u32 clk_ptp_rate, int gmac4, u32 *sub_second_inc) { u32 value =3D readl(ioaddr + PTP_TCR); unsigned long data; @@ -34,14 +34,14 @@ static void config_sub_second_increment(void __iomem *i= oaddr, * increment to twice the number of nanoseconds of a clock cycle. * The calculation of the default_addend value by the caller will set it * to mid-range =3D 2^31 when the remainder of this division is zero, - * which will make the accumulator overflow once every 2 ptp_clock + * which will make the accumulator overflow once every 2 clk_ptp_rate * cycles, adding twice the number of nanoseconds of a clock cycle : - * 2 * NSEC_PER_SEC / ptp_clock. + * 2 * NSEC_PER_SEC / clk_ptp_rate. */ if (value & PTP_TCR_TSCFUPDT) - data =3D (2 * NSEC_PER_SEC / ptp_clock); + data =3D (2 * NSEC_PER_SEC / clk_ptp_rate); else - data =3D (NSEC_PER_SEC / ptp_clock); + data =3D (NSEC_PER_SEC / clk_ptp_rate); =20 /* 0.465ns accuracy */ if (!(value & PTP_TCR_TSCTRLSSR)) --=20 2.41.0