All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Cc: davem@davemloft.net, Andre Guedes <andre.guedes@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	Aaron Brown <aaron.f.brown@intel.com>
Subject: Re: [net-next 05/13] igc: Check __IGC_PTP_TX_IN_PROGRESS instead of ptp_tx_skb
Date: Fri, 26 Jun 2020 21:30:35 -0700	[thread overview]
Message-ID: <20200626213035.45653c24@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <20200627015431.3579234-6-jeffrey.t.kirsher@intel.com>

On Fri, 26 Jun 2020 18:54:23 -0700 Jeff Kirsher wrote:
> From: Andre Guedes <andre.guedes@intel.com>
> 
> The __IGC_PTP_TX_IN_PROGRESS flag indicates we have a pending Tx
> timestamp. In some places, instead of checking that flag, we check
> adapter->ptp_tx_skb. This patch fixes those places to use the flag.
> 
> Quick note about igc_ptp_tx_hwtstamp() change: when that function is
> called, adapter->ptp_tx_skb is expected to be valid always so we
> WARN_ON_ONCE() in case it is not.
> 
> Quick note about igc_ptp_suspend() change: when suspending, we don't
> really need to check if there is a pending timestamp. We can simply
> clear it unconditionally.
> 
> Signed-off-by: Andre Guedes <andre.guedes@intel.com>
> Tested-by: Aaron Brown <aaron.f.brown@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> ---
>  drivers/net/ethernet/intel/igc/igc_ptp.c | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/igc/igc_ptp.c b/drivers/net/ethernet/intel/igc/igc_ptp.c
> index b1b23c6bf689..e65fdcf966b2 100644
> --- a/drivers/net/ethernet/intel/igc/igc_ptp.c
> +++ b/drivers/net/ethernet/intel/igc/igc_ptp.c
> @@ -404,9 +404,6 @@ void igc_ptp_tx_hang(struct igc_adapter *adapter)
>  	bool timeout = time_is_before_jiffies(adapter->ptp_tx_start +
>  					      IGC_PTP_TX_TIMEOUT);
>  
> -	if (!adapter->ptp_tx_skb)
> -		return;
> -
>  	if (!test_bit(__IGC_PTP_TX_IN_PROGRESS, &adapter->state))
>  		return;
>  
> @@ -435,6 +432,9 @@ static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter)
>  	struct igc_hw *hw = &adapter->hw;
>  	u64 regval;
>  
> +	if (WARN_ON_ONCE(!skb))
> +		return;
> +
>  	regval = rd32(IGC_TXSTMPL);
>  	regval |= (u64)rd32(IGC_TXSTMPH) << 32;
>  	igc_ptp_systim_to_hwtstamp(adapter, &shhwtstamps, regval);
> @@ -466,7 +466,7 @@ static void igc_ptp_tx_work(struct work_struct *work)
>  	struct igc_hw *hw = &adapter->hw;
>  	u32 tsynctxctl;
>  
> -	if (!adapter->ptp_tx_skb)
> +	if (!test_bit(__IGC_PTP_TX_IN_PROGRESS, &adapter->state))
>  		return;

Not that reading ptp_tx_skb is particularly correct here, but I think
it's better. See how they get set:

		if (adapter->tstamp_config.tx_type == HWTSTAMP_TX_ON &&
		    !test_and_set_bit_lock(__IGC_PTP_TX_IN_PROGRESS,
					   &adapter->state)) {
			skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
			tx_flags |= IGC_TX_FLAGS_TSTAMP;

			adapter->ptp_tx_skb = skb_get(skb);
			adapter->ptp_tx_start = jiffies;

bit is set first and other fields after. Since there is no locking here
we may just see the bit but none of the fields set.

>  	if (time_is_before_jiffies(adapter->ptp_tx_start +
> @@ -588,11 +588,9 @@ void igc_ptp_suspend(struct igc_adapter *adapter)
>  		return;
>  
>  	cancel_work_sync(&adapter->ptp_tx_work);
> -	if (adapter->ptp_tx_skb) {
> -		dev_kfree_skb_any(adapter->ptp_tx_skb);
> -		adapter->ptp_tx_skb = NULL;
> -		clear_bit_unlock(__IGC_PTP_TX_IN_PROGRESS, &adapter->state);
> -	}
> +	dev_kfree_skb_any(adapter->ptp_tx_skb);
> +	adapter->ptp_tx_skb = NULL;
> +	clear_bit_unlock(__IGC_PTP_TX_IN_PROGRESS, &adapter->state);
>  }
>  
>  /**


  reply	other threads:[~2020-06-27  4:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-27  1:54 [net-next 00/13][pull request] 1GbE Intel Wired LAN Driver Updates 2020-06-26 Jeff Kirsher
2020-06-27  1:54 ` [net-next 01/13] igc: Add initial EEE support Jeff Kirsher
2020-06-28  0:28   ` David Miller
2020-06-27  1:54 ` [net-next 02/13] igc: Add initial LTR support Jeff Kirsher
2020-06-27  1:54 ` [net-next 03/13] igc: Clean up Rx timestamping logic Jeff Kirsher
2020-06-27  1:54 ` [net-next 04/13] igc: Remove duplicate code in Tx timestamp handling Jeff Kirsher
2020-06-27  1:54 ` [net-next 05/13] igc: Check __IGC_PTP_TX_IN_PROGRESS instead of ptp_tx_skb Jeff Kirsher
2020-06-27  4:30   ` Jakub Kicinski [this message]
2020-06-29 20:51     ` Andre Guedes
2020-06-29 22:11       ` Jakub Kicinski
2020-06-30  0:07         ` Andre Guedes
2020-06-30  0:19           ` Jakub Kicinski
2020-06-30  0:23             ` Kirsher, Jeffrey T
2020-06-27  1:54 ` [net-next 06/13] igc: Remove UDP filter setup in PTP code Jeff Kirsher
2020-06-27  1:54 ` [net-next 07/13] igc: Refactor igc_ptp_set_timestamp_mode() Jeff Kirsher
2020-06-27  1:54 ` [net-next 08/13] igc: Fix Rx timestamp disabling Jeff Kirsher
2020-06-27  1:54 ` [net-next 09/13] igc: Add LPI counters Jeff Kirsher
2020-06-27  1:54 ` [net-next 10/13] igc: Remove TCP segmentation TX fail counter Jeff Kirsher
2020-06-27  1:54 ` [net-next 11/13] igc: Refactor the igc_power_down_link() Jeff Kirsher
2020-06-27  1:54 ` [net-next 12/13] igc: Remove unneeded check for copper media type Jeff Kirsher
2020-06-27  1:54 ` [net-next 13/13] igc: Remove checking media type during MAC initialization Jeff Kirsher

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=20200626213035.45653c24@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
    --to=kuba@kernel.org \
    --cc=aaron.f.brown@intel.com \
    --cc=andre.guedes@intel.com \
    --cc=davem@davemloft.net \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.