lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8cd2b49d-4edd-0fe9-a5dc-af2905a90951@microchip.com>
Date:   Fri, 19 Aug 2022 08:19:05 +0000
From:   <Claudiu.Beznea@...rochip.com>
To:     <harini.katakam@....com>, <Nicolas.Ferre@...rochip.com>,
        <davem@...emloft.net>, <richardcochran@...il.com>,
        <andrei.pistirica@...rochip.com>, <kuba@...nel.org>,
        <edumazet@...gle.com>, <pabeni@...hat.com>
CC:     <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <michal.simek@...inx.com>, <harinikatakamlinux@...il.com>,
        <harini.katakam@...inx.com>, <michal.simek@....com>,
        <radhey.shyam.pandey@....com>
Subject: Re: [RESEND PATCH 2/2] net: macb: Optimize reading HW timestamp

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@...inx.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@...inx.com>
> Signed-off-by: Michal Simek <michal.simek@...inx.com>
> Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@...inx.com>
> Acked-by: Richard Cochran <richardcochran@...il.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
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ