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 C6157CD1284 for ; Tue, 2 Apr 2024 15:03:52 +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:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qgRRzqQ3X/2dhy2gY2P/gKADEuJZOlIn/qp0si+KCDc=; b=PL4mCl4KQjFZhO 0zU3dnsiH41sJOEDAKIDXCkoiPhcC6wvqEMdfoiE55hUEKiedPfK33hPYmp6kvF8ehf/GqCXqJ03w t3Xw6wwwTjzJ1J/uKEthMj924oTUa/3swe+piMuIGE2UUq9YaDZTfGdrBTqDVn34ghs4Q/c8Id7LV LPUqefPfeWMFhZZ1eiJuBIgy2v8nkBG8YkokIV0iJCtNTehP33Qezsgqfa/PIRz5fo3QxWTJqZTkw LDxP4tmLC55E3hHGbS06ld2sUdRaA+8yUH687vKUwua8LrR/YGXIDlF0/jlmPByYx3Q2PWQ2RFoWK q/mMFnMIWHp4qquMdSDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rrffq-0000000BjMT-1sVB; Tue, 02 Apr 2024 15:03:42 +0000 Received: from pandora.armlinux.org.uk ([78.32.30.218]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rreWk-0000000BRQ1-45ui for linux-arm-kernel@lists.infradead.org; Tue, 02 Apr 2024 13:50:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=GbhkBxn+Q4MglL3Lf04y1O0cOhqs2SZS9H0XUJs9VK0=; b=WiBOleVCJwBRPqHpBXE8Ef/U+G OXNriYeqoB6MRc7eicL0W9EYhGR5ajRr5dPJ3uNYPlNNIbBC0HxhOjk7DX+2wrYxTMNRua2n+Ouyd DcF7rtkkHvFur+rvqAyiGx3S/0gqFEQDFnWt/53GQX4zgJY1vfLs/j7thO2twHL23gXVKutcSLr+t NeyTrxfYKNeV1LKFgJ6lvMdTakw5Id9g+QsR+G9BFveVUS00EP3jajyAUvlglUWEbHpm7lDgYooWA 4eTco3FzRs32jC95CiPlQWcfUG6OgLsQ8riL7aDKCl/kqEz3RxVb1iYaSkQowHA0A5pYpDU9hP4uD ELWzNoKg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:37898) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rreWN-0006no-2a; Tue, 02 Apr 2024 14:49:51 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rreWK-00070E-DE; Tue, 02 Apr 2024 14:49:48 +0100 Date: Tue, 2 Apr 2024 14:49:48 +0100 From: "Russell King (Oracle)" To: Romain Gantois Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Alexandre Torgue , Jose Abreu , Maxime Coquelin , =?iso-8859-1?Q?Cl=E9ment_L=E9ger?= , Thomas Petazzoni , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH net-next 2/3] net: stmmac: add support for RZ/N1 GMAC Message-ID: References: <20240402-rzn1-gmac1-v1-0-5be2b2894d8c@bootlin.com> <20240402-rzn1-gmac1-v1-2-5be2b2894d8c@bootlin.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240402-rzn1-gmac1-v1-2-5be2b2894d8c@bootlin.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240402_065015_264871_3611C122 X-CRM114-Status: GOOD ( 16.21 ) 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 Tue, Apr 02, 2024 at 02:37:01PM +0200, Romain Gantois wrote: > + ret = stmmac_dvr_probe(dev, plat_dat, &stmmac_res); > + if (ret) > + return ret; > + > + ndev = platform_get_drvdata(pdev); > + priv = netdev_priv(ndev); > + > + pcs_node = of_parse_phandle(np, "pcs-handle", 0); > + if (pcs_node) { > + pcs = miic_create(dev, pcs_node); > + of_node_put(pcs_node); > + if (IS_ERR(pcs)) > + return PTR_ERR(pcs); > + > + priv->hw->phylink_pcs = pcs; > + } I'm afraid that this fails at one of the most basic principles of kernel multi-threaded programming. stmmac_dvr_probe() as part of its work calls register_netdev() which publishes to userspace the network device. Everything that is required must be setup _prior_ to publication to userspace to avoid races, because as soon as the network device is published, userspace can decide to bring that interface up. If one hasn't finished the initialisation, the interface can be brought up before that initialisation is complete. I don't see anything obvious in the stmmac data structures that would allow you to hook in at an appropriate point before the register_netdev() but after the netdev has been created. The priv->hw data structure is created by stmmac_hwif_init() I see that drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c is also guilty of this as well, and should be fixed. It's even worse because it does a truck load of stuff after stmmac_dvr_probe() which it most definitely should not be doing. I definitely get the feeling that the structure of the stmmac driver is really getting out of hand, and is making stuff harder for people, and it's not improving over time - in fact, it's getting worse. It needs a *lot* of work to bring it back to a sane model. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel