From: <Claudiu.Beznea@microchip.com>
To: <harini.katakam@amd.com>, <Nicolas.Ferre@microchip.com>,
<davem@davemloft.net>, <richardcochran@gmail.com>,
<andrei.pistirica@microchip.com>, <kuba@kernel.org>,
<edumazet@google.com>, <pabeni@redhat.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<michal.simek@xilinx.com>, <harinikatakamlinux@gmail.com>,
<harini.katakam@xilinx.com>, <michal.simek@amd.com>,
<radhey.shyam.pandey@amd.com>
Subject: Re: [RESEND PATCH 2/2] net: macb: Optimize reading HW timestamp
Date: Fri, 19 Aug 2022 08:19:05 +0000 [thread overview]
Message-ID: <8cd2b49d-4edd-0fe9-a5dc-af2905a90951@microchip.com> (raw)
In-Reply-To: <20220816115500.353-3-harini.katakam@amd.com>
On 16.08.2022 14:55, Harini Katakam wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> From: Harini Katakam <harini.katakam@xilinx.com>
>
> The seconds input from BD (6 bits) just needs to be ORed with the
> upper bits from timer in this function. Avoid +/- operations every
> single time. Check for seconds rollover at BIT 5 and subtract the
> overhead only in that case.
>
> Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
> Acked-by: Richard Cochran <richardcochran@gmail.com>
> ---
> drivers/net/ethernet/cadence/macb_ptp.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb_ptp.c b/drivers/net/ethernet/cadence/macb_ptp.c
> index e6cb20aaa76a..674002661366 100644
> --- a/drivers/net/ethernet/cadence/macb_ptp.c
> +++ b/drivers/net/ethernet/cadence/macb_ptp.c
> @@ -247,6 +247,7 @@ static int gem_hw_timestamp(struct macb *bp, u32 dma_desc_ts_1,
> u32 dma_desc_ts_2, struct timespec64 *ts)
> {
> struct timespec64 tsu;
> + bool sec_rollover = false;
>
> ts->tv_sec = (GEM_BFEXT(DMA_SECH, dma_desc_ts_2) << GEM_DMA_SECL_SIZE) |
> GEM_BFEXT(DMA_SECL, dma_desc_ts_1);
> @@ -264,9 +265,12 @@ static int gem_hw_timestamp(struct macb *bp, u32 dma_desc_ts_1,
> */
> if ((ts->tv_sec & (GEM_DMA_SEC_TOP >> 1)) &&
> !(tsu.tv_sec & (GEM_DMA_SEC_TOP >> 1)))
> - ts->tv_sec -= GEM_DMA_SEC_TOP;
> + sec_rollover = true;
> +
> + ts->tv_sec |= ((~GEM_DMA_SEC_MASK) & tsu.tv_sec);
It looks to me that this instruction could be moved before
> if ((ts->tv_sec & (GEM_DMA_SEC_TOP >> 1)) &&
> !(tsu.tv_sec & (GEM_DMA_SEC_TOP >> 1)))
and get rid of sec_rolover extra variable thus, in the end, the diff could
look like this:
diff --git a/drivers/net/ethernet/cadence/macb_ptp.c
b/drivers/net/ethernet/cadence/macb_ptp.c
index e6cb20aaa76a..f9db4501b995 100644
--- a/drivers/net/ethernet/cadence/macb_ptp.c
+++ b/drivers/net/ethernet/cadence/macb_ptp.c
@@ -258,6 +258,8 @@ static int gem_hw_timestamp(struct macb *bp, u32
dma_desc_ts_1,
*/
gem_tsu_get_time(&bp->ptp_clock_info, &tsu, NULL);
+ ts->tv_sec |= ((~GEM_DMA_SEC_MASK) & tsu.tv_sec);
+
/* If the top bit is set in the timestamp,
* but not in 1588 timer, it has rolled over,
* so subtract max size
@@ -266,8 +268,6 @@ static int gem_hw_timestamp(struct macb *bp, u32
dma_desc_ts_1,
!(tsu.tv_sec & (GEM_DMA_SEC_TOP >> 1)))
ts->tv_sec -= GEM_DMA_SEC_TOP;
- ts->tv_sec += ((~GEM_DMA_SEC_MASK) & tsu.tv_sec);
-
return 0;
}
>
> - ts->tv_sec += ((~GEM_DMA_SEC_MASK) & tsu.tv_sec);
> + if (sec_rollover)
> + ts->tv_sec -= GEM_DMA_SEC_TOP;
>
> return 0;
> }
> --
> 2.17.1
>
prev parent reply other threads:[~2022-08-19 8:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-16 11:54 [RESEND PATCH 0/2] Macb PTP enhancements Harini Katakam
2022-08-16 11:54 ` [RESEND PATCH 1/2] net: macb: Enable PTP unicast Harini Katakam
2022-08-19 8:19 ` Claudiu.Beznea
2022-08-16 11:55 ` [RESEND PATCH 2/2] net: macb: Optimize reading HW timestamp Harini Katakam
2022-08-19 8:19 ` Claudiu.Beznea [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8cd2b49d-4edd-0fe9-a5dc-af2905a90951@microchip.com \
--to=claudiu.beznea@microchip.com \
--cc=Nicolas.Ferre@microchip.com \
--cc=andrei.pistirica@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=harini.katakam@amd.com \
--cc=harini.katakam@xilinx.com \
--cc=harinikatakamlinux@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=michal.simek@xilinx.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=radhey.shyam.pandey@amd.com \
--cc=richardcochran@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox