From: "naamax.meir" <naamax.meir@linux.intel.com>
To: Tony Nguyen <anthony.l.nguyen@intel.com>,
davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@google.com, netdev@vger.kernel.org
Cc: Vinicius Costa Gomes <vinicius.gomes@intel.com>,
sasha.neftin@intel.com, richardcochran@gmail.com,
Andre Guedes <andre.guedes@intel.com>,
Kurt Kanzenbach <kurt@linutronix.de>
Subject: Re: [PATCH net 1/4] igc: Fix race condition in PTP tx code
Date: Mon, 19 Jun 2023 10:27:08 +0300 [thread overview]
Message-ID: <b567fd9a-7a22-85bf-cb52-6ea2a383949c@linux.intel.com> (raw)
In-Reply-To: <20230530174928.2516291-2-anthony.l.nguyen@intel.com>
On 5/30/2023 20:49, Tony Nguyen wrote:
> From: Vinicius Costa Gomes <vinicius.gomes@intel.com>
>
> Currently, the igc driver supports timestamping only one tx packet at a
> time. During the transmission flow, the skb that requires hardware
> timestamping is saved in adapter->ptp_tx_skb. Once hardware has the
> timestamp, an interrupt is delivered, and adapter->ptp_tx_work is
> scheduled. In igc_ptp_tx_work(), we read the timestamp register, update
> adapter->ptp_tx_skb, and notify the network stack.
>
> While the thread executing the transmission flow (the user process
> running in kernel mode) and the thread executing ptp_tx_work don't
> access adapter->ptp_tx_skb concurrently, there are two other places
> where adapter->ptp_tx_skb is accessed: igc_ptp_tx_hang() and
> igc_ptp_suspend().
>
> igc_ptp_tx_hang() is executed by the adapter->watchdog_task worker
> thread which runs periodically so it is possible we have two threads
> accessing ptp_tx_skb at the same time. Consider the following scenario:
> right after __IGC_PTP_TX_IN_PROGRESS is set in igc_xmit_frame_ring(),
> igc_ptp_tx_hang() is executed. Since adapter->ptp_tx_start hasn't been
> written yet, this is considered a timeout and adapter->ptp_tx_skb is
> cleaned up.
>
> This patch fixes the issue described above by adding the ptp_tx_lock to
> protect access to ptp_tx_skb and ptp_tx_start fields from igc_adapter.
> Since igc_xmit_frame_ring() called in atomic context by the networking
> stack, ptp_tx_lock is defined as a spinlock, and the irq safe variants
> of lock/unlock are used.
>
> With the introduction of the ptp_tx_lock, the __IGC_PTP_TX_IN_PROGRESS
> flag doesn't provide much of a use anymore so this patch gets rid of it.
>
> Fixes: 2c344ae24501 ("igc: Add support for TX timestamping")
> Signed-off-by: Andre Guedes <andre.guedes@intel.com>
> Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
> Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>
> Tested-by: Naama Meir <naamax.meir@linux.intel.com>
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
> ---
> drivers/net/ethernet/intel/igc/igc.h | 5 +-
> drivers/net/ethernet/intel/igc/igc_main.c | 9 ++--
> drivers/net/ethernet/intel/igc/igc_ptp.c | 57 ++++++++++++-----------
> 3 files changed, 41 insertions(+), 30 deletions(-)
Tested-by: Naama Meir <naamax.meir@linux.intel.com>
next prev parent reply other threads:[~2023-06-19 7:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 17:49 [PATCH net 0/4][pull request] igc: TX timestamping fixes Tony Nguyen
2023-05-30 17:49 ` [PATCH net 1/4] igc: Fix race condition in PTP tx code Tony Nguyen
2023-06-19 7:27 ` naamax.meir [this message]
2023-05-30 17:49 ` [PATCH net 2/4] igc: Check if hardware TX timestamping is enabled earlier Tony Nguyen
2023-06-01 6:10 ` Jakub Kicinski
2023-06-01 21:21 ` Vinicius Costa Gomes
2023-06-02 3:55 ` Jakub Kicinski
2023-06-02 17:56 ` Vinicius Costa Gomes
2023-05-30 17:49 ` [PATCH net 3/4] igc: Retrieve TX timestamp during interrupt handling Tony Nguyen
2023-06-05 11:16 ` Marc Kleine-Budde
2023-06-05 18:11 ` Vinicius Costa Gomes
2023-05-30 17:49 ` [PATCH net 4/4] igc: Add workaround for missing timestamps Tony Nguyen
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=b567fd9a-7a22-85bf-cb52-6ea2a383949c@linux.intel.com \
--to=naamax.meir@linux.intel.com \
--cc=andre.guedes@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kurt@linutronix.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=sasha.neftin@intel.com \
--cc=vinicius.gomes@intel.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;
as well as URLs for NNTP newsgroup(s).