From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DC5620E7 for ; Fri, 20 Oct 2023 05:09:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D72A1D50 for ; Thu, 19 Oct 2023 22:09:29 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qthko-0001Lr-Dt; Fri, 20 Oct 2023 07:08:58 +0200 Received: from [2a0a:edc0:2:b01:1d::c0] (helo=ptx.whiteo.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qthkm-002xCC-Tz; Fri, 20 Oct 2023 07:08:56 +0200 Received: from ore by ptx.whiteo.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1qthkm-00FNf4-Pe; Fri, 20 Oct 2023 07:08:56 +0200 Date: Fri, 20 Oct 2023 07:08:56 +0200 From: Oleksij Rempel To: Vladimir Oltean Cc: "David S. Miller" , Andrew Lunn , Eric Dumazet , Florian Fainelli , Jakub Kicinski , Paolo Abeni , Woojung Huh , Arun Ramadoss , Conor Dooley , Krzysztof Kozlowski , Rob Herring , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, "Russell King (Oracle)" , devicetree@vger.kernel.org Subject: Re: [PATCH net-next v6 5/9] net: dsa: microchip: ksz9477: Add Wake on Magic Packet support Message-ID: <20231020050856.GB3637381@pengutronix.de> References: <20231019122850.1199821-1-o.rempel@pengutronix.de> <20231019122850.1199821-1-o.rempel@pengutronix.de> <20231019122850.1199821-6-o.rempel@pengutronix.de> <20231019122850.1199821-6-o.rempel@pengutronix.de> <20231019172953.ajqtmnnthohnlek7@skbuf> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231019172953.ajqtmnnthohnlek7@skbuf> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: devicetree@vger.kernel.org On Thu, Oct 19, 2023 at 08:29:53PM +0300, Vladimir Oltean wrote: > On Thu, Oct 19, 2023 at 02:28:46PM +0200, Oleksij Rempel wrote: .... > > @@ -109,10 +110,22 @@ void ksz9477_get_wol(struct ksz_device *dev, int port, > > > > wol->supported = WAKE_PHY; > > > > + /* Check if at this moment we would be able to get the MAC address > > + * and use it for WAKE_MAGIC support. This result may change dynamically > > + * depending on configuration of other ports. > > + */ > > + ret = ksz_switch_macaddr_get(dev->ds, port, NULL); > > + if (!ret) { > > + wol->supported |= WAKE_MAGIC; > > + ksz_switch_macaddr_put(dev->ds); > > I don't get it, why do you release the reference on the MAC address as > soon as you successfully get it? Without a reference held, the > programmed address still lingers on, but the HSR offload code, on a > different port with a different MAC address, can change it and break WoL. It is ksz9477_get_wol() function. We do not actually need to program here the MAC address, we only need to test if we would be able to get it. To show the use more or less correct information on WoL capabilities. For example, instead showing the user that Wake on Magic is supported, where we already know that is not the case, we can already show correct information. May be it will be better to have extra option for ksz_switch_macaddr_get() to not allocate and do the refcounting or have a separate function. Regards, Oleksij -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |