[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y5Gs27MjJ1RrkVld@unreal>
Date: Thu, 8 Dec 2022 11:22:35 +0200
From: Leon Romanovsky <leon@...nel.org>
To: Tony Nguyen <anthony.l.nguyen@...el.com>
Cc: davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com,
edumazet@...gle.com, Jacob Keller <jacob.e.keller@...el.com>,
netdev@...r.kernel.org, richardcochran@...il.com,
Gurucharan G <gurucharanx.g@...el.com>
Subject: Re: [PATCH net-next v2 09/15] ice: protect init and calibrating
check in ice_ptp_request_ts
On Wed, Dec 07, 2022 at 01:09:31PM -0800, Tony Nguyen wrote:
> From: Jacob Keller <jacob.e.keller@...el.com>
>
> When requesting a new timestamp, the ice_ptp_request_ts function does not
> hold the Tx tracker lock while checking init and calibrating. This means
> that we might issue a new timestamp request just after the Tx timestamp
> tracker starts being deinitialized. This could lead to incorrect access of
> the timestamp structures. Correct this by moving the init and calibrating
> checks under the lock, and updating the flows which modify these fields to
> use the lock.
>
> Note that we do not need to hold the lock while checking for tx->init in
> ice_ptp_tstamp_tx. This is because the teardown function will use
> synchronize_irq after clearing the flag to ensure that the threaded
> interrupt completes. Either a) the tx->init flag will be cleared before the
> ice_ptp_tx_tstamp function starts, thus it will exit immediately, or b) the
> threaded interrupt will be executing and the synchronize_irq will wait
> until the threaded interrupt has completed at which point we know the init
> field has definitely been set and new interrupts will not execute the Tx
> timestamp thread function.
>
> Signed-off-by: Jacob Keller <jacob.e.keller@...el.com>
> Tested-by: Gurucharan G <gurucharanx.g@...el.com> (A Contingent worker at Intel)
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@...el.com>
> ---
> drivers/net/ethernet/intel/ice/ice_ptp.c | 36 ++++++++++++++++++++----
> drivers/net/ethernet/intel/ice/ice_ptp.h | 2 +-
> 2 files changed, 32 insertions(+), 6 deletions(-)
Much better, thanks
Powered by blists - more mailing lists