[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <33e1fcd2-af99-4c8c-bab5-20fe98922452@redhat.com>
Date: Thu, 17 Oct 2024 11:20:10 +0200
From: Paolo Abeni <pabeni@...hat.com>
To: Mahesh Bandewar <maheshb@...gle.com>, Netdev <netdev@...r.kernel.org>,
Tariq Toukan <tariqt@...dia.com>, Yishai Hadas <yishaih@...dia.com>
Cc: Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
David Miller <davem@...emloft.net>,
Richard Cochran <richardcochran@...il.com>,
Mahesh Bandewar <mahesh@...dewar.net>
Subject: Re: [PATCHv2 net-next 1/3] mlx4: introduce the time_cache into the
mlx4 PTP implementation
On 10/12/24 13:47, Mahesh Bandewar wrote:
> The mlx4_clock_read() function, when invoked by cycle_counter->read(),
> previously returned only the raw cycle count. However, for PTP helpers
> like gettimex64(), which require both pre- and post-timestamps,
> returning just the raw cycles is insufficient; the necessary
> timestamps must also be provided.
>
> This patch introduces the time_cache into the implementation. As a
> result, mlx4_en_read_clock() is now responsible for reading and
> updating the clock_cache. This allows the function
> mlx4_en_read_clock_cache() to serve as the cycle reader for
> cycle_counter->read(), maintaining the same interface
>
> Signed-off-by: Mahesh Bandewar <maheshb@...gle.com>
> ---
> drivers/net/ethernet/mellanox/mlx4/en_clock.c | 28 +++++++++++++++----
> drivers/net/ethernet/mellanox/mlx4/main.c | 1 -
> drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 1 +
> 3 files changed, 24 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_clock.c b/drivers/net/ethernet/mellanox/mlx4/en_clock.c
> index cd754cd76bde..cab9221a0b26 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_clock.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_clock.c
> @@ -36,15 +36,22 @@
>
> #include "mlx4_en.h"
>
> -/* mlx4_en_read_clock - read raw cycle counter (to be used by time counter)
> +/* mlx4_en_read_clock_cache - read cached raw cycle counter (to be
> + * used by time counter)
> */
> -static u64 mlx4_en_read_clock(const struct cyclecounter *tc)
> +static u64 mlx4_en_read_clock_cache(const struct cyclecounter *tc)
> {
> struct mlx4_en_dev *mdev =
> container_of(tc, struct mlx4_en_dev, cycles);
> - struct mlx4_dev *dev = mdev->dev;
>
> - return mlx4_read_clock(dev) & tc->mask;
> + return READ_ONCE(mdev->clock_cache) & tc->mask;
> +}
> +
> +static void mlx4_en_read_clock(struct mlx4_en_dev *mdev)
> +{
> + u64 cycles = mlx4_read_clock(mdev->dev);
> +
> + WRITE_ONCE(mdev->clock_cache, cycles);
> }
>
> u64 mlx4_en_get_cqe_ts(struct mlx4_cqe *cqe)
> @@ -109,6 +116,9 @@ void mlx4_en_ptp_overflow_check(struct mlx4_en_dev *mdev)
>
> if (timeout) {
> write_seqlock_irqsave(&mdev->clock_lock, flags);
> + /* refresh the clock_cache */
> + mlx4_en_read_clock(mdev);
It looks like you could make patch 2/3 much smaller introducing an
explit cache_refresh() helper, that will not take the 2nd argument and
using it where needed.
Possibly even more importantly, why do you need a cache at all? I guess
you could use directly mlx4_read_clock() in mlx4_en_phc_gettimex(), and
implement mlx4_en_read_clock as:
static void mlx4_en_read_clock(struct mlx4_en_dev *mdev)
{
return mlx4_read_clock(mdev->dev, NULL);
}
Does the cache give some extra gain I can't see? If so, it should be
explained somewhere in the commit message.
> diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
> index febeadfdd5a5..9408313b0f4d 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/main.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/main.c
> @@ -1946,7 +1946,6 @@ u64 mlx4_read_clock(struct mlx4_dev *dev)
> }
> EXPORT_SYMBOL_GPL(mlx4_read_clock);
>
> -
Please don't introduce unrelated whitespace changes
Thanks,
Paolo
Powered by blists - more mailing lists