Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp988429pxb; Fri, 15 Apr 2022 17:32:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdxYyTRjGTLP+YB2hfP1c4798h7OQ918yFCjGG6cHDuctJuuqx3ftpH6gJkeVqvG+Tao0g X-Received: by 2002:a05:6a00:2286:b0:505:d881:d71 with SMTP id f6-20020a056a00228600b00505d8810d71mr1409865pfe.16.1650069153585; Fri, 15 Apr 2022 17:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650069153; cv=none; d=google.com; s=arc-20160816; b=rXwwJNZRZFdydZQKCAVtypGWu5rT6FkGn/D7UdFBtuuDQLHltm0g3tMyA9dHJz/cOA TC+/RLtdF6i/a4uCgVNbH2gBGTOiDFbNXc7k0AYYNRbebffZ/47EDcPuzWPAE4vOzGNA 1rja/S3jpyzfIIlkEZZnM7gAEa5N6Tdl2vOTlU/YCQ4pZqg3np6sBqljfCgXmHpdwGXm Sxgxvxxd5gD5Ve97Yrw0SYHV0mOnhE2BHGjqPHkd/dQ4VDGZbRJ12l2iCUgcXyCoceC7 Vk+WLS0c+RrS+l63pZsZkuyXg+NhuJwl2/FkQafFO2VrqntnVwp15fOrVR6qg3PRWsTX QhLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BOAhwHUPSM+JCjTiYm2spjP9JaC7ZzVEZgiYumkURbk=; b=wKvUruIG9uQOjT13BRBEQqnch7ek5CRocA8kptltVXMgT7VeT84haCfzdcOHpqZ6gK ntqzmEP8nc6zI4F7Zx36CwHv+ioonbT3xeKaCj6IXFtJDzt1+jouNuhr4595EpsP1oJ3 +nibFjFCQ5w02hGHRhzsLLUJQTjMKgdo0s9+Bqcu37T3BursSxMTYxsKMcDXlwgfTux9 cu8oubNPWxH6OKMIZA2/WaD0AU1OG/QezHbb+TcLGn7mpkqwtWZTIVfWi0og0Hru6jyb 8CYqqHGsYbHW6CtDPXjJJts01Icvu09a389wPLpBSm+2T9eRS4B6Q+pvwHjcTwuZZspL doFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=TbkE71iH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i9-20020a63cd09000000b003a27204cc3csi2735398pgg.857.2022.04.15.17.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 17:32:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=TbkE71iH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C4D24189; Fri, 15 Apr 2022 17:29:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354075AbiDONk3 (ORCPT + 99 others); Fri, 15 Apr 2022 09:40:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354101AbiDONkY (ORCPT ); Fri, 15 Apr 2022 09:40:24 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2E518BE12; Fri, 15 Apr 2022 06:37:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=BOAhwHUPSM+JCjTiYm2spjP9JaC7ZzVEZgiYumkURbk=; b=TbkE71iHLRmKz6slCznm3IDV3g wn5AddDaxIz0BilXV5zBOCzeaF+d4DENi7hrRmgasOe3nqsdLRjx6d4mcMji+r9uDMvyBSULSC9np hGWYkSa406fW5bNA9dpgoj5n28mBef/XJieNIpwsmeZEtyH68Xq2kn3eYYRgnps4PUtA=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1nfM8o-00FyVp-3q; Fri, 15 Apr 2022 15:37:38 +0200 Date: Fri, 15 Apr 2022 15:37:38 +0200 From: Andrew Lunn To: =?iso-8859-1?Q?Cl=E9ment_L=E9ger?= Cc: Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Geert Uytterhoeven , Magnus Damm , Heiner Kallweit , Russell King , Thomas Petazzoni , Herve Codina , =?iso-8859-1?Q?Miqu=E8l?= Raynal , Milan Stevanovic , Jimmy Lalande , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH net-next 07/12] net: dsa: rzn1-a5psw: add statistics support Message-ID: References: <20220414122250.158113-1-clement.leger@bootlin.com> <20220414122250.158113-8-clement.leger@bootlin.com> <20220415140402.76822543@fixe.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220415140402.76822543@fixe.home> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > +static void a5psw_get_ethtool_stats(struct dsa_switch *ds, int port, > > > + uint64_t *data) > > > +{ > > > + struct a5psw *a5psw = ds->priv; > > > + u32 reg_lo, reg_hi; > > > + unsigned int u; > > > + > > > + for (u = 0; u < ARRAY_SIZE(a5psw_stats); u++) { > > > + /* A5PSW_STATS_HIWORD is global and thus, access must be > > > + * exclusive > > > + */ > > > > Could you explain that a bit more. The RTNL lock will prevent two > > parallel calls to this function. > > Ok, I wasn't sure of the locking applicable here. In general, RTNL protects you for any user space management like operation on the driver. In this case, if you look in net/ethtool, you will find the IOCTL handler code takes RTNL before calling into the main IOCTL dispatcher. If you want to be paranoid/document the assumption, you can add an ASSERT_RTNL(). The semantics for some of the other statistics Vladimir requested can be slightly different. One of them is in atomic context, because a spinlock is held. But i don't remember if RTNL is also held. This is less of an issue for your switch, since it uses MMIO, however many switches need to perform blocking IO over MDIO, SPI, IC2 etc to get stats, which you cannot do in atomic context. So they end up returning cached values. Look in the mailing list for past discussion for details. Andrew