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 5D87DC27C77 for ; Tue, 11 Jun 2024 15:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id: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=2LbxbZ09cphyvBSZaTwA1+IeSS/LYMgbMrw3EO6xDLM=; b=W7jrbzNIT9xDyW Si46oH7I0blUQJuM7bXdBzBmMcF+dyA3hOHB3j1QTqFMRbKNywlCECGH/aXMxdUFps6bl7ngqSR38 hZXFPDI9ZU5F6UNajR9VSsyqtSfbfgvKBL7bT/jfNI6lVK+7Ykdl90Do0wHEd3nTu5257xxLi9HLd 6Jfs3e21PdAq59TZtdAF2bE8S6lYe3yaFPAu1GUXvKjnljMnoXOwRlyJSneGB0KG8tLfHaRKlAAas 1EqSuTUNHSrClSMvWHEY7Y83yP1XsNNpSMD75mNRUjT2kPEKw8C/gDT68+MC7hWw8aIKdV3bjVL+L HiUwirpTIZqMbcPlkmAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sH3CY-00000009IHI-0xD6; Tue, 11 Jun 2024 15:14:22 +0000 Received: from out-185.mta0.migadu.com ([2001:41d0:1004:224b::b9]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sH3CU-00000009IGo-454S for linux-arm-kernel@lists.infradead.org; Tue, 11 Jun 2024 15:14:20 +0000 X-Envelope-To: andrew@lunn.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1718118855; 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=qW3j5h6q3Oo1ihZw1Fz9Fs14ioQF7XsCBm6iwiYKMLk=; b=DohB/qiXj0/fOaAnpKROMiga+NnvRUZ6W9kui+YM6YSQ12WaTbG/q1vPfEQTCBoQ4E0poA nvuHpBLiwbgU/rbtT9AU/TiBnd0wHvWO45zEO0FwcjEjy4Lm15CQu2f4JREaqMRjlyh9Cg NcWDsIMPipfT7K4nYMBxrdw1/AuYHp8= X-Envelope-To: radhey.shyam.pandey@amd.com X-Envelope-To: netdev@vger.kernel.org X-Envelope-To: linux-arm-kernel@lists.infradead.org X-Envelope-To: michal.simek@amd.com X-Envelope-To: kuba@kernel.org X-Envelope-To: linux@armlinux.org.uk X-Envelope-To: pabeni@redhat.com X-Envelope-To: edumazet@google.com X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: davem@davemloft.net Message-ID: Date: Tue, 11 Jun 2024 11:14:11 -0400 MIME-Version: 1.0 Subject: Re: [PATCH net-next 3/3] net: xilinx: axienet: Add statistics support To: Andrew Lunn Cc: Radhey Shyam Pandey , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Michal Simek , Jakub Kicinski , Russell King , Paolo Abeni , Eric Dumazet , linux-kernel@vger.kernel.org, "David S . Miller" References: <20240610231022.2460953-1-sean.anderson@linux.dev> <20240610231022.2460953-4-sean.anderson@linux.dev> <7c06c9d7-ad11-4acd-8c80-fbeb902da40d@lunn.ch> 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: <7c06c9d7-ad11-4acd-8c80-fbeb902da40d@lunn.ch> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240611_081419_398671_F9C48C90 X-CRM114-Status: GOOD ( 18.62 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 6/10/24 20:13, Andrew Lunn wrote: > On Mon, Jun 10, 2024 at 07:10:22PM -0400, Sean Anderson wrote: >> Add support for reading the statistics counters, if they are enabled. >> The counters may be 64-bit, but we can't detect this as there's no >> ability bit for it and the counters are read-only. Therefore, we assume >> the counters are 32-bits. > >> +static void axienet_stats_update(struct axienet_local *lp) >> +{ >> + enum temac_stat stat; >> + >> + lockdep_assert_held(&lp->stats_lock); >> + >> + u64_stats_update_begin(&lp->hw_stat_sync); >> + for (stat = 0; stat < STAT_COUNT; stat++) { >> + u32 counter = axienet_ior(lp, XAE_STATS_OFFSET + stat * 8); > > The * 8 here suggests the counters are spaced so that they could be 64 > bit wide, even when only 32 bits are used. Correct. > Does the documentation say anything about the upper 32 bits when the > counters are only 32 bits? Are they guaranteed to read as zero? I'm > just wondering if the code should be forward looking and read all 64 > bits? The registers are documented as being 32-bit, with the upper 32-bits being registered upon reading the lower 32 bits. The documentation doesn't say what the upper registers are when the counters are 32 bits. >> static int __axienet_device_reset(struct axienet_local *lp) >> { >> u32 value; >> int ret; >> >> + /* Save statistics counters in case they will be reset */ >> + if (lp->features & XAE_FEATURE_STATS) { >> + mutex_lock(&lp->stats_lock); >> + axienet_stats_update(lp); >> + } > > It is a pretty unusual pattern to split a mutex lock/unlock like this > on an if statement. Maybe just unconditionally hold the mutex? This > does not appear to be anyway hot path, so the overhead should not > matter. OK --Sean _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel