Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp982984pxb; Fri, 15 Apr 2022 17:22:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxNVY/F++qNxGvmdb72G4V8ujOQOZuGutC03XqBHYbqeMOSF6fQbyNzG9zfVpfVNNQIAHm X-Received: by 2002:a17:90a:c003:b0:1cb:65a2:81ab with SMTP id p3-20020a17090ac00300b001cb65a281abmr6864537pjt.161.1650068536805; Fri, 15 Apr 2022 17:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650068536; cv=none; d=google.com; s=arc-20160816; b=hQkr6iphBig//rExXQS9fxOCHr9wHCz8iTLjMVv/71DRNf1xJevXdCYdVLWqaUgX41 UfwYP/rWy2W83ZEHV0bbzUzpUuq1y/DE1TiR5cn2TDHUgm92F34VaFfbnrezHN9rjAB5 T5h6C9u+roCmL0ut8xv/XDqdKaPba/r9P2K2kcatuxAjO7EIMyG3BPlF7a69/QlZGj38 ltjywh1wRE3bRLb1f36O81+iZAG2mGQkz6VmmeBm1Z2PwzwLTOzNFSkB9YMwyNLSoQiZ YEYLEL+GUo/B08xgzMMbA9+1+l8GbKKLC/Zxe4WwzjtDWUDRJCSCSVUtdjUKwqhNkjRJ wlrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=r5e/ituSe4Bvmn7/ipiIp9xLyWhKGgopzYJiAYxoSB0=; b=giAA1uSIqDocghOloh+4SHrYKUjgderG7+18oU9JU++QNB0ySz0Zgh5O/6opyKwJzL 6JpDSN3OWoyc3z1lPvT2FmxEuY+pAypfbXntpaDNUMEEaUj4FXXdZA0Cttn20W1ygEWS K/pPciRKGyJjhImafXMNOn4EOnCCPTsaxwSh0eNHbIUmCnn8Bfot0BXRvJVqB04Q3wHJ fwYNyMiFBqlzmduAjeeu0IbRHkortn3P1BI9l6xHCfKR3kfXGGZlCL/TPl30OVG8TlAy uY8Gc/0+09ukAOzf1eCO68nl6P6YVTiL+TWVHzCqWEzQW4JC837bl7BsSExzKT1/PesK aSFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="dP1/xN0G"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x127-20020a626385000000b00505f73f2a30si2597240pfb.344.2022.04.15.17.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 17:22:16 -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=@bootlin.com header.s=gm1 header.b="dP1/xN0G"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DB086DFDEB; Fri, 15 Apr 2022 17:21:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354135AbiDONsX (ORCPT + 99 others); Fri, 15 Apr 2022 09:48:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235290AbiDONsV (ORCPT ); Fri, 15 Apr 2022 09:48:21 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B05F18385; Fri, 15 Apr 2022 06:45:51 -0700 (PDT) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id A45F9C0011; Fri, 15 Apr 2022 13:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1650030349; 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=r5e/ituSe4Bvmn7/ipiIp9xLyWhKGgopzYJiAYxoSB0=; b=dP1/xN0GlD+5NO3uXdngygB6HWCd34pEyuj2uJZuOjEhCjNV8KDx/W6DPiiCDOqogfDQqV DmuZrWkzeibO1RY6xPNIXlHafkYusP16Mw5fhuJEM2RKlPCTUd7Ysw24zp4lbQvZiqKj5Y APIDQs52Lr/5dCbwI2iwQ7wcVPBv3cKPgbz51JA368MmF/XLK6pDNMq1Xj++bDH82Vy/ys 16bqIrZe+CurQqZG/ji7Gx9s7sS4DFvQXUqMpLLXSJt1yxAJZNgzuUtKIw/tCVzzFfaZBw UNjrh1QHY1OwWY6iCBmpi5uds62SenhMsbzgdOv784fwRMQ3P5qd48Iyl75K7Q== Date: Fri, 15 Apr 2022 15:44:20 +0200 From: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= To: Andrew Lunn 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 , =?UTF-8?B?TWlxdcOobA==?= 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: <20220415154420.128a0fca@fixe.home> In-Reply-To: References: <20220414122250.158113-1-clement.leger@bootlin.com> <20220414122250.158113-8-clement.leger@bootlin.com> <20220415140402.76822543@fixe.home> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 Le Fri, 15 Apr 2022 15:37:38 +0200, Andrew Lunn a =C3=A9crit : > > > > +static void a5psw_get_ethtool_stats(struct dsa_switch *ds, int por= t, > > > > + uint64_t *data) > > > > +{ > > > > + struct a5psw *a5psw =3D ds->priv; > > > > + u32 reg_lo, reg_hi; > > > > + unsigned int u; > > > > + > > > > + for (u =3D 0; u < ARRAY_SIZE(a5psw_stats); u++) { > > > > + /* A5PSW_STATS_HIWORD is global and thus, access must be > > > > + * exclusive > > > > + */ =20 > > >=20 > > > Could you explain that a bit more. The RTNL lock will prevent two > > > parallel calls to this function. =20 > >=20 > > Ok, I wasn't sure of the locking applicable here. =20 >=20 > 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(). Ok, I'll look at the call stack in details to see what locking is applied. >=20 > 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. >=20 > Look in the mailing list for past discussion for details. Ok, thanks, >=20 > Andrew --=20 Cl=C3=A9ment L=C3=A9ger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com