From patchwork Thu Apr 17 17:13:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 14055953 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 6D672C369D0 for ; Thu, 17 Apr 2025 17:38:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jIkX0gP+PNuwun86Ur3bCb3SB1wHpFzUd5pZCiudByo=; b=Gbz+speTh9ikoNMam+M+2poPHx vCtHas4dL9K0X/BexBXDRsDiq3Mc/8eEO+F88skzOLiF7NoxYqvLA/wQX2N3hkcRiFEiYOH4aFa9A UlFI6JTJxHB0X8a4FHhNkvvBdcDZxxJWxVbgrbUVC+2MNcDZeTpOp/PVXdYSc+gSdVTBzZMlBrQbx cQkLIY08TiHAwfNHXlEB7/a1oSG+VurMwBkukAjnJl07yvmiKDuCx3q597aFOKQbxQgDdvz9lpOZR QfKGUSiDSKc441X+UvSU2u12s/ZBYZCJiXMz9tek8EkmWMSG4QZ30pifAGeGEOAcmfXfhSbrJzPgA 3t53zlbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1u5TBt-0000000DstV-191A; Thu, 17 Apr 2025 17:38:21 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1u5SqT-0000000Do1h-2LR1 for linux-arm-kernel@bombadil.infradead.org; Thu, 17 Apr 2025 17:16:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description; bh=jIkX0gP+PNuwun86Ur3bCb3SB1wHpFzUd5pZCiudByo=; b=Cv1sii2X41zrJr8jmRgcZyZFf5 His+I3yr4/LVWx28aIlEA9tdovXZMe1l73i6PFldFZAhf0Pb9XbqHH2ccyK3c/iR39NH1RkhyI4zw Y1/q2Jto+ozzgCYZ9XvsGydAvgO738qq3lpcNRDsnTLDD/OHsDOJCsSIQJvDM6HJ7/De3GqwWvrJJ NOf4ebXGH0AbM7E5xnRmehT1dcC0r8wZCJtihcwDH+Ir+7TS3QSBvNaXfRvLUbgYY/0dv/4ydnhz4 EUmG9Izs3/knFUJYtR9mw+giozNckk7Ypf3rcmvclDqxJNy4ZsNPt4Nu2sACr7J3OOJF4xrTJVdck dUVka7/Q==; Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by desiato.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1u5SqQ-0000000AL6q-3d0F for linux-arm-kernel@lists.infradead.org; Thu, 17 Apr 2025 17:16:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To: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=jIkX0gP+PNuwun86Ur3bCb3SB1wHpFzUd5pZCiudByo=; b=qG/DQSPO81AjWQcYIU2O70+Eqh HQb4SRUlE90z00GdZVteYr3gUbHImvmDYPdm2BDeD+ipr/BuAIOGEiWhtgk96526ASD8herclHR5C Yvfx8D43Exg29ioWZGO2vFGkT+b+N0DiDyUPd7vF/JMHC8n9SXAFfP+jstwofJSgCVYUEN7iaabLl qDET+qpzM+R3MZJ7v87nTgMhT8LdGFlRIcQkOI0hfkjpvk8DY9vppmr3VD/MigyhRY0xlSzQtPdyb ngIHldeZsuO7exDVwP9//IbBrM38HQ0DD4DOfmmvoOeIZHUFgcxN4U5KWOqa19tu2TuQTR4mOyWyY gCTBqKyA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:53520 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u5SoP-0007hB-0x; Thu, 17 Apr 2025 18:14:05 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1u5Snn-001IJq-L0; Thu, 17 Apr 2025 18:13:27 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Chevallier , Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni Subject: [PATCH net-next v3 4/5] net: stmmac: socfpga: call set_phy_mode() before registration MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 17 Apr 2025 18:13:27 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250417_181610_977608_ED04C675 X-CRM114-Status: GOOD ( 15.60 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Initialisation/setup after registration is a bug. This is the second of two patches fixing this in socfpga. The set_phy_mode() functions do various hardware setup that would interfere with a netdev that has been published, and thus available to be opened by the kernel/userspace. However, set_phy_mode() relies upon the netdev having been initialised to get at the plat_stmmacenet_data structure, which is probably why it was placed after stmmac_drv_probe(). We can remove that need by storing a pointer to struct plat_stmmacenet_data in struct socfpga_dwmac. Move the call to set_phy_mode() before calling stmmac_dvr_probe(). This also simplifies the probe function as there is no need to unregister the netdev if set_phy_mode() fails. Signed-off-by: Russell King (Oracle) --- .../ethernet/stmicro/stmmac/dwmac-socfpga.c | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c index 69ffc52c0275..c7c120e30297 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c @@ -50,6 +50,7 @@ struct socfpga_dwmac { u32 reg_offset; u32 reg_shift; struct device *dev; + struct plat_stmmacenet_data *plat_dat; struct regmap *sys_mgr_base_addr; struct reset_control *stmmac_rst; struct reset_control *stmmac_ocp_rst; @@ -233,10 +234,7 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device * static int socfpga_get_plat_phymode(struct socfpga_dwmac *dwmac) { - struct net_device *ndev = dev_get_drvdata(dwmac->dev); - struct stmmac_priv *priv = netdev_priv(ndev); - - return priv->plat->mac_interface; + return dwmac->plat_dat->mac_interface; } static void socfpga_sgmii_config(struct socfpga_dwmac *dwmac, bool enable) @@ -490,6 +488,7 @@ static int socfpga_dwmac_probe(struct platform_device *pdev) */ dwmac->stmmac_rst = plat_dat->stmmac_rst; dwmac->ops = ops; + dwmac->plat_dat = plat_dat; plat_dat->bsp_priv = dwmac; plat_dat->fix_mac_speed = socfpga_dwmac_fix_mac_speed; @@ -501,20 +500,11 @@ static int socfpga_dwmac_probe(struct platform_device *pdev) plat_dat->riwt_off = 1; - ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); - if (ret) - return ret; - ret = socfpga_dwmac_init(pdev, dwmac); if (ret) - goto err_dvr_remove; - - return 0; - -err_dvr_remove: - stmmac_dvr_remove(&pdev->dev); + return ret; - return ret; + return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); } static const struct socfpga_dwmac_ops socfpga_gen5_ops = {