From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3215BC3DA7F for ; Mon, 12 Aug 2024 20:26:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/Bkmy6zP1fl2Mg1iKu43im3gTS8tdXysjwgG/iqJOJY=; b=mn/H0m8qYuTkoRqUE3hlQwCMEd WVe2ne1c/ruTK0p8kwE/0RGwuqy511IQPbkYPEpu1qIc9K52XLqvr0OyHPLS6vg1jKE7lrj5aLoNU 2RzjfHK3pmKXnAfoRwbqinqjAR3AywmlYsLFdfmKsRlnABsMj6SbLb83zYeuIkk8v01gioiDZAb1V urvnQ7MdsE0eLW+GK6GQ/lPiOCclOKkITtGL3R1ilcIH9de70/+9lPegTFhdVB9DmmX+2KY5MJHHR J6WFMT+MS2xYGvYNIkgQtxJbTdWM233fiM10hmarLLGZhz2X1H790qYKq/kvxHVRAVdRbNFZsmfDk AeqT3QXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdbcC-00000001SRN-3tDa; Mon, 12 Aug 2024 20:26:04 +0000 Received: from out-182.mta1.migadu.com ([95.215.58.182]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdbba-00000001SHg-09hu for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:25:28 +0000 Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1723494322; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/Bkmy6zP1fl2Mg1iKu43im3gTS8tdXysjwgG/iqJOJY=; b=dAudFyoOhQBVwAQv2dOLBEGD7qdICDdJs3JP3KM95yaQJAcCB2gI1bnoCAQ0nzuhq04FSJ OB68KXwo6eDkt2MCBBP89scLc3o/Deauhm3A8iSPZekyu9mRoqun9jdYROyXdL9pEKJvvP JpVfnW/TxRLm77kRy3+upLwwHchfZKI= Date: Mon, 12 Aug 2024 16:25:16 -0400 MIME-Version: 1.0 Subject: Re: [PATCH net-next v2 2/2] net: xilinx: axienet: Add statistics support To: Andrew Lunn Cc: Radhey Shyam Pandey , netdev@vger.kernel.org, Simon Horman , Jakub Kicinski , Russell King , "David S . Miller" , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Paolo Abeni , Michal Simek , Eric Dumazet References: <20240812174118.3560730-1-sean.anderson@linux.dev> <20240812174118.3560730-3-sean.anderson@linux.dev> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sean Anderson In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_132527_186073_BC31C495 X-CRM114-Status: GOOD ( 15.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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