netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Anderson <sean.anderson@linux.dev>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>,
	netdev@vger.kernel.org, Simon Horman <horms@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Russell King <linux@armlinux.org.uk>,
	"David S . Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Paolo Abeni <pabeni@redhat.com>,
	Michal Simek <michal.simek@amd.com>,
	Eric Dumazet <edumazet@google.com>
Subject: Re: [PATCH net-next v2 2/2] net: xilinx: axienet: Add statistics support
Date: Mon, 12 Aug 2024 16:25:16 -0400	[thread overview]
Message-ID: <f1837494-7411-463f-b9f6-fbdd09217423@linux.dev> (raw)
In-Reply-To: <e78256f2-9ad6-49e1-9cd5-02a28c92d2fc@lunn.ch>

On 8/12/24 16:22, Andrew Lunn wrote:
>>  static int __axienet_device_reset(struct axienet_local *lp)
>>  {
>>  	u32 value;
>>  	int ret;
>>  
>> +	/* Save statistics counters in case they will be reset */
>> +	guard(mutex)(&lp->stats_lock);
>> +	if (lp->features & XAE_FEATURE_STATS)
>> +		axienet_stats_update(lp, true);
> 
> My understanding of guard() is that the mutex is held until the
> function completes. That is much longer than you need. A
> scoped_guard() would be better here, and it makes it clear when the
> mutex will be released.

We have to hold it until...

>> +
>>  	/* Reset Axi DMA. This would reset Axi Ethernet core as well. The reset
>>  	 * process of Axi DMA takes a while to complete as all pending
>>  	 * commands/transfers will be flushed or completed during this
>> @@ -551,6 +595,23 @@ static int __axienet_device_reset(struct axienet_local *lp)
>>  		return ret;
>>  	}
>>  
>> +	/* Update statistics counters with new values */
>> +	if (lp->features & XAE_FEATURE_STATS) {
>> +		enum temac_stat stat;
>> +
>> +		write_seqcount_begin(&lp->hw_stats_seqcount);
>> +		lp->reset_in_progress = false;
>> +		for (stat = 0; stat < STAT_COUNT; stat++) {
>> +			u32 counter =
>> +				axienet_ior(lp, XAE_STATS_OFFSET + stat * 8);
>> +
>> +			lp->hw_stat_base[stat] +=
>> +				lp->hw_last_counter[stat] - counter;
>> +			lp->hw_last_counter[stat] = counter;
>> +		}
>> +		write_seqcount_end(&lp->hw_stats_seqcount);

...here

Which is effectively the whole function. The main reason why I used guard() was to
simplify the error return cases.

--Sean

>> +	}
>> +
>>  	return 0;
>>  }
>>  
> 
> 	Andrew


  reply	other threads:[~2024-08-12 20:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-12 17:41 [PATCH net-next v2 0/2] net: xilinx: axienet: Add statistics support Sean Anderson
2024-08-12 17:41 ` [PATCH net-next v2 1/2] net: xilinx: axienet: Report RxRject as rx_dropped Sean Anderson
2024-08-12 20:11   ` Andrew Lunn
2024-08-12 17:41 ` [PATCH net-next v2 2/2] net: xilinx: axienet: Add statistics support Sean Anderson
2024-08-12 20:22   ` Andrew Lunn
2024-08-12 20:25     ` Sean Anderson [this message]
2024-08-12 21:18       ` Andrew Lunn
2024-08-12 21:19         ` Sean Anderson

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=f1837494-7411-463f-b9f6-fbdd09217423@linux.dev \
    --to=sean.anderson@linux.dev \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=michal.simek@amd.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=radhey.shyam.pandey@amd.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).