From patchwork Thu Aug 24 18:32:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13364556 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B01C71549C for ; Thu, 24 Aug 2023 18:33:02 +0000 (UTC) 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 82E8A1BC2 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-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-660-hpf9l0MAMN6VxulcMpg0rg-1; Thu, 24 Aug 2023 14:32:59 -0400 X-MC-Unique: hpf9l0MAMN6VxulcMpg0rg-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-649fac91500so11618446d6.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=dEd6b1b+u9AqC+4/RAJHlGJ/B5Oeb3NpVZJIxhM/T9J58cIIWV71nrirS93faGpPRu MuYQmIpJqEXnOpkQBSs2AkE4NCL7SjU8/7SAggHSXP6rkUfG+PK4bLYWm2JDqNFRylw6 sRPVXWWW9huY14Tu9ASxPOLuvq0G4m5n/eulKrGI3mcgucJ/mj7FTJVwG+mW/scoWIiV kywixoebeBnFqDVBLFCJ5zi4NhmFuJyd49nSMZA5EMsmXghdojydeVYMU4BhMq3w4ihA ju8eN0yM2wWQ17NOymBR2+PdASmZ+AHYz6ag5bW0qPm2b+aiiqIufSXSUd7eLYaS+KCp XoPw== X-Gm-Message-State: AOJu0YzZrsYAYbW43jqRtPU+0attGyaznZLarx3/A6Ob+DNNUvWXYf7b G8NwbI0e1UEGO/ELDXp//c4brNIEmUkKqsD7DfOSBVUdX4MZRs64KPsMZCJVa7fFe952IX1RVA5 U2Lx3O7+/FfzV52eh X-Received: by 2002:a0c:e246:0:b0:647:2653:bcc with SMTP id x6-20020a0ce246000000b0064726530bccmr18915150qvl.13.1692901978978; 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@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/ethernet/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/drivers/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) } 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 = readl(ioaddr + PTP_TCR); unsigned long data; @@ -56,8 +56,8 @@ static void config_sub_second_increment(void __iomem *ioaddr, writel(reg_value, ioaddr + PTP_SSIR); - if (ssinc) - *ssinc = data; + if (sub_second_inc) + *sub_second_inc = data; } static void hwtstamp_correct_latency(struct stmmac_priv *priv) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/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 = priv->plat->has_gmac4 || priv->plat->has_xgmac; struct timespec64 now; - u32 sec_inc = 0; + u32 sub_second_inc = 0; u64 temp = 0; if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp)) @@ -848,16 +848,16 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *priv, 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 = div_u64(1000000000ULL, sec_inc); + xmac, &sub_second_inc); + temp = div_u64(1000000000ULL, sub_second_inc); /* Store sub second increment for later use */ - priv->sub_second_inc = sec_inc; + priv->sub_second_inc = sub_second_inc; /* calculate default added value: * formula is : * addend = (2^32)/freq_div_ratio; - * where, freq_div_ratio = 1e9ns/sec_inc + * where, freq_div_ratio = 1e9ns/sub_second_inc */ temp = (u64)(temp << 32); priv->default_addend = div_u64(temp, priv->plat->clk_ptp_rate); From patchwork Thu Aug 24 18:32:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13364558 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 221C515AF6 for ; Thu, 24 Aug 2023 18:33:06 +0000 (UTC) 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 33A871BE9 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=thxHPyqpXjBOV26mQw4932uoaf4t0NSsG4y7+rk0Hj4=; b=i1Mp3NMvhru5TQEvSKtHYa50rws/P9+SZuykiTODCUiUxO7xnNjJEyc3XCladaGbQ7ZHTC fmmU9wfZaF+W4H//iI3x+mS3nBD6y51xA9L4lX+tTV+QnN7U/1lkKDH2znW/JBAUkDrpnk YV1AhRwhL2TBJGzS+eyTkRL6zz5ocqo= 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-91-wDoeQsRHMhKXaNJmd02Z1g-1; Thu, 24 Aug 2023 14:33:01 -0400 X-MC-Unique: wDoeQsRHMhKXaNJmd02Z1g-1 Received: by mail-oa1-f72.google.com with SMTP id 586e51a60fabf-1cc61e461deso102166fac.2 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=CGn2FWW7pg/kfGAvLviBrnH1zKKbfg/8LtedsJFO6bIZwKblnzzjvwE6GGbFfQMvUK LXxlIPLmthuDIwDmDSAkRkAnJDr+ejH644GJxXSbXUX7AUoWe7zusAzVvspzs9HoQ2aM LK9aiUPmCpdIh58quejQDUaYmCfldBA1U1TRQP88XjFKHpLFIBbGmazzmGzXN7descej Oubgmvt+h7szaqyO1gzFUV30Qyp2ObCtBR7Fha8krFBG0b7B7UDfgDFP4XfBMFSCiG1i rf/WHrW6ksJff4JH8kQ/1+DRPKvnd9K/qbOTwlabaBt8VTx0pW+k3UM0v9NgMukXmZUj VuZA== X-Gm-Message-State: AOJu0Yzf9Wbw6Sf3oRsaa/OPaYvyL0MJo8Xs9PsVkDZrasHf6wnCuPWW 2Fic5mpL6E7i5Qm9cngXsAiSr9XkghH9XNN2jeFaP/IWpDkJUcpN+qvpkrGe8mJtlx+EwhrYdWe k21NihVR7D4XG9Whz X-Received: by 2002:a05:6870:b30e:b0:1c8:b870:4e62 with SMTP id a14-20020a056870b30e00b001c8b8704e62mr553975oao.52.1692901980221; 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@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/drivers/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 *ioaddr, * to mid-range = 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 = (2000000000ULL / ptp_clock); + data = (2 * NSEC_PER_SEC / ptp_clock); else - data = (1000000000ULL / ptp_clock); + data = (NSEC_PER_SEC / ptp_clock); /* 0.465ns accuracy */ if (!(value & PTP_TCR_TSCTRLSSR)) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/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 = div_u64(1000000000ULL, sub_second_inc); + temp = div_u64(NSEC_PER_SEC, sub_second_inc); /* Store sub second increment for later use */ priv->sub_second_inc = sub_second_inc; From patchwork Thu Aug 24 18:32:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13364557 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DD5A15AC7 for ; Thu, 24 Aug 2023 18:33:05 +0000 (UTC) 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 608AA19BE 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-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-615-8q1nb6KeOHqMJ5RN7OcHAg-1; Thu, 24 Aug 2023 14:33:02 -0400 X-MC-Unique: 8q1nb6KeOHqMJ5RN7OcHAg-1 Received: by mail-oa1-f70.google.com with SMTP id 586e51a60fabf-1befca4fdfaso117711fac.2 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=AxaXpgP1bzs0yidL2sjqhtvsznpyxJbq2qHGyvzCOxHumoVyEyyxKCkt4Huqlojf24 tY3bbiw40OnRJ0UkehX8S80H2fwoMbtSR3l27ZE3YbnwfVq/VOdzkNxGAHBAW14Zwttq GjsdDMcvcJqHUNbC95grR5z2D0O5iUIRtRJLEHl0elb3AS/6vzXQMNqwLglmVYP5ENWy s2EAMj1X9CnNBQ/HYuUQvAqMJ4VLiYw72uh/mvibB5P7omFW40BXKZKlWDj1IW64qxYr PiH+ukYDxhZecjQut3oa6pvuCHBVfl8NDo7Hqpc/nCvQPTUKl2D5Pif3SzFKz/reC8te CEIg== X-Gm-Message-State: AOJu0YzbGVSfNh1jYFN5X24i6x0QZn0rK7Q+9PkeY4m/jfnGaAsVmC+1 29Eggkf1ykpsRStR4odKIODJyoNn6DTLVgzdrOiSBveRb+GcGwj+plYf0S8bI2QvC0XMkCsUHSA 7qDSUSXyUlkg2J2iP X-Received: by 2002:a05:6870:e253:b0:1be:f8d9:7bdd with SMTP id d19-20020a056870e25300b001bef8d97bddmr627371oac.6.1692901981455; 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@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/net/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 = div_u64(NSEC_PER_SEC, sub_second_inc); /* Store sub second increment for later use */ priv->sub_second_inc = sub_second_inc; @@ -859,6 +858,7 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags) * addend = (2^32)/freq_div_ratio; * where, freq_div_ratio = 1e9ns/sub_second_inc */ + temp = div_u64(NSEC_PER_SEC, sub_second_inc); temp = (u64)(temp << 32); priv->default_addend = div_u64(temp, priv->plat->clk_ptp_rate); stmmac_config_addend(priv, priv->ptpaddr, priv->default_addend); From patchwork Thu Aug 24 18:32:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13364559 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 923BF174E3 for ; Thu, 24 Aug 2023 18:33:06 +0000 (UTC) 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 677CB1BEC 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-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-BZmBse4DOk228aOzJL7VeQ-1; Thu, 24 Aug 2023 14:33:03 -0400 X-MC-Unique: BZmBse4DOk228aOzJL7VeQ-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-63faa1e03a8so1450276d6.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=AQS4LGpSfxFbgQ6QNehOp2Fou9zd7/dXQs2Xx7dZKwFtmRNl01Qb0v9O1C3UCi8+h+ ucFxiZWk2FIPMeNfkK8Yg7q59rcGgAGzGd1o5CSHb/4YaAm4LYWU8rHdb77Iq5VTzmFI iKzkm8Y9X1TYWm1+9/uwS1kLEeDi0x8W/bLey3zHOfNsMddkNLyB38wgp1jSmOt6QGID drxWoSiKFCdOqnZZKYROt1u7pSNVLjU6otP/SHuR87NhYzGDGLklpltN6AVFW5XBL7HC ctKjZ3Sj20aIL5PkSL6hBtXgba53Bq9Zf0bN6tZG40grtVYvSxYW4aWhuTeGutdOQj3k 5QJQ== X-Gm-Message-State: AOJu0Yzkw9UG+GQftJugKo6rbYeImnct6So2o4QWLVB1XyE0ISuEuItq g2XduaY7Deng9UGXKnw30ADwmeDZhYRbxS6JHnqsq2sLjiNdQLmzUHWhbvD29MhiAr2zwFAGkOn LH3pqWpemFUik7PCT X-Received: by 2002:a0c:a99b:0:b0:63a:5ebc:6e7a with SMTP id a27-20020a0ca99b000000b0063a5ebc6e7amr15574212qvb.31.1692901982708; 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@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/net/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 = 1e9ns/sub_second_inc */ temp = div_u64(NSEC_PER_SEC, sub_second_inc); - temp = (u64)(temp << 32); + temp = temp << 32; priv->default_addend = div_u64(temp, priv->plat->clk_ptp_rate); stmmac_config_addend(priv, priv->ptpaddr, priv->default_addend); From patchwork Thu Aug 24 18:32:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13364560 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A34AB17FFA for ; Thu, 24 Aug 2023 18:33:07 +0000 (UTC) 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 A552419BE 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-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-688-_Oj6L3MhPoOlVcCcQPgjYQ-1; Thu, 24 Aug 2023 14:33:04 -0400 X-MC-Unique: _Oj6L3MhPoOlVcCcQPgjYQ-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-649fac91500so11618866d6.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=dMDzojsLZ6XQOV14LAR8qnTPdIFwskyc4atyCP7LbO6vrFaV4Bva2kVjd9YgOLEJtI jmR0i08p1E2N4+XRDg1qTitMWuv/5ZMgPq1BneSqGWb8v9le4kxtJefKVykAIsa9zMWs eyk8LJ4BD66ZtMyLEKvfTBG01ylLj6lLWcNoErAAEf2Bv7AeqMBCHqK7CqhOmcfX35CP jVUqqD7C34ORnpk1EgxPkZTTNGS2H07vHftSz18SB7gJIYuw6SXmbi8WQha9D5QieMBd 56saO3jzXdQSHt/fzkE4pjbxQb0OYtFeXQ8fHpdKlIVoj8N9XPEfru2e8ZDo8VqdgbSD X0Zg== X-Gm-Message-State: AOJu0YwqoLINxOTjwacvFNbYiJ/MDdexs4o3CgqOog/tp9zgMylrwsPF uGa55eGe0TP5tjDujgMBuMco7kBZJ5V7pZeHn3duBj1y2D1HOTLbUvbqZfZa/fh2B57BQONmObo +nFij+MRxaD1hph2Y X-Received: by 2002:a05:6214:ac9:b0:64b:926a:e7fc with SMTP id g9-20020a0562140ac900b0064b926ae7fcmr19233936qvi.21.1692901984166; 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@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/net/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 = sub_second_inc; - /* calculate default added value: + /* calculate default addend value: * formula is : * addend = (2^32)/freq_div_ratio; * where, freq_div_ratio = 1e9ns/sub_second_inc From patchwork Thu Aug 24 18:32:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13364561 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 288E518032 for ; Thu, 24 Aug 2023 18:33:10 +0000 (UTC) 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 CAA671BF1 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-f69.google.com (mail-oa1-f69.google.com [209.85.160.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-595-B-Fd6xj-Oi-HzxVwOGP6RA-1; Thu, 24 Aug 2023 14:33:06 -0400 X-MC-Unique: B-Fd6xj-Oi-HzxVwOGP6RA-1 Received: by mail-oa1-f69.google.com with SMTP id 586e51a60fabf-1ccbcb5034aso101694fac.3 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=V3au/6Nlp8gm4VzfeluKQhSjiNPpcr0Gu6ZkH9HOZyFsoYnuA/H1RdqnyYUL8Jsvpu KRetctnH4/h8yh0YFjfdZ/5N1WQeJy007227HAYqNRUeXgpJ8hUR944JXrEAPI0QkE6R fPjjlRYxlY3dEiLBWetSHcneo4L0MpGFinZmnd/7tRTkohXfMCGNxfTENUWxWq8823l+ PYCOXiz7Z7Hzbs6FGmBC+4U2iuee3p7M/Bq7O5sdvtXXchX+HJogehys+YdTVMuzSJoG HPVfjBKbDCO/87hOp2SP2Fv4D/VELs+eBSDB5gxMrQZbw9/iy8BP6bdM3y1G9G9ygg8g AQ1w== X-Gm-Message-State: AOJu0YzD+hqNnz7qZG9K94tNeROdM1G7P5WQQ4ssBgdoabSteA+YuHwx xakXGUXYP0sTIQIKeAunvKC4aNh62nfAjpfaoFgdmcglcGN4z+Sj82kEqdzea5MQ5wf/LZEF0ip MU2N2APh6CGoKfVTA X-Received: by 2002:a05:6871:299:b0:1b4:60b3:98bc with SMTP id i25-20020a056871029900b001b460b398bcmr646684oae.2.1692901985291; 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@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/net/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 *priv, u32 systime_flags) /* Store sub second increment for later use */ priv->sub_second_inc = sub_second_inc; - /* calculate default addend value: - * formula is : - * addend = (2^32)/freq_div_ratio; - * where, freq_div_ratio = 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 = (2^32) / freq_div_ratio + * where, freq_div_ratio = (1e9ns / sub_second_inc) / clk_ptp_rate */ temp = div_u64(NSEC_PER_SEC, sub_second_inc); temp = temp << 32; From patchwork Thu Aug 24 18:32:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13364562 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0EEA18032 for ; Thu, 24 Aug 2023 18:33:10 +0000 (UTC) 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 B348E1BF5 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-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-633-88no-JMuOY-Z9lmRyFZ33g-1; Thu, 24 Aug 2023 14:33:07 -0400 X-MC-Unique: 88no-JMuOY-Z9lmRyFZ33g-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-64b7c2a0d5dso1330006d6.3 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=MerHMC2zoce7B19sfsrMqp/Lf2HaaNlnpVHMvnzp+wnPzDwS9w9CUL/CSUcrpuRCKx VtKHEH//5OyTTE3Yr7MwKze0ZwwaeVpSeEdnkB8WKAkkYsSKx15SVpQKYyzW8Dv/pDYQ RKKNiyCw5mb5DB7GmcfQA6JZVtgOsGjOM0Fif5x6/pi2NHasO23F+AlmQ6DG/d8QzQox /YFxF6fzJ/+owroTjk6QrVG6aLYBwKrocUbk+vC4hkAk4vgkEu552xEuB0ODclAqhw7F r7aAEDb7L+tQF7gQVkH8dWy8mtbHkLBkD+tjHzTA5dSOcK2qytEqp0WwVREd5C2jppnV bosA== X-Gm-Message-State: AOJu0Yz+NU3FPA4vJ9Z/Es3YtkfEEjE++C9ad1KjewxSLV/sQRxnPmlE bYOnHzS3Vlt8fn+7aQxezGgNi+6Q6wkQgzMph3mQgt3inji6xRsx/IcTQSqaBhraYp5FuQnvs2f /IX+E00GRRxduhWFACiMvPqeq X-Received: by 2002:a0c:cb8a:0:b0:64b:997f:5a73 with SMTP id p10-20020a0ccb8a000000b0064b997f5a73mr17312062qvk.0.1692901986874; 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@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/ethernet/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/drivers/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) } 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 = readl(ioaddr + PTP_TCR); unsigned long data; @@ -34,14 +34,14 @@ static void config_sub_second_increment(void __iomem *ioaddr, * 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 = 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 = (2 * NSEC_PER_SEC / ptp_clock); + data = (2 * NSEC_PER_SEC / clk_ptp_rate); else - data = (NSEC_PER_SEC / ptp_clock); + data = (NSEC_PER_SEC / clk_ptp_rate); /* 0.465ns accuracy */ if (!(value & PTP_TCR_TSCTRLSSR))