Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp328984lqo; Fri, 10 May 2024 00:38:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXNVqIyxsyE/UfT6kRTOSjDKQz5Yy0aZglzsFT1xDvJWRYgvyrebvYrb7LbX1pT1d6oJMEaJIn/U5FF/LJMLxZeb7Vh2QnG5j4y/XJ2Kg== X-Google-Smtp-Source: AGHT+IH7S3jtCqEA4eNLNrPpU7Mv5hQPXxKeBc2csO0LP+K1M86DgAekmIyO9vDT3BVyu9k8jISD X-Received: by 2002:a05:6a00:4613:b0:6ed:41f4:1886 with SMTP id d2e1a72fcca58-6f4df3db383mr3311009b3a.8.1715326730217; Fri, 10 May 2024 00:38:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715326730; cv=pass; d=google.com; s=arc-20160816; b=OMLFyrl0LrKAnJrIlfzKFHqiGGM+rSZQr4Xy9nRwsreBn/knD8g1pssLFvUtPgC27i MXl8PDujymCcdt+XAN7up4jXII7rNHbQm4IukHcFssedbELsFyGPMfyuAKoYZ/N7uvpr M0B5fTajOabeHA/W25O5+hQwrBfu2HfjrIUyQR9UAhrcO0IFafrOL0p0kZP5IdhObjUP mFX5L2mh4pwA1cXJux7lq6lyMS+4iw4O4uEKQjFmnCE5xD1Q4J9pMkIwW3wgwnMilktW yQO/LBnoFHG7SqryNHP0tmTMk/4Post82ZezIq2TtSAX2MVDkUBld15KhLCXCM42GIrM WCuw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=7rIpZAk8Wec4E2PAYnFztgJW8F7HaR4BB0LLl7tUusw=; fh=iKbzTsM6Akj2X0N29umtxBSsa4Nmw1Zki5pbjnRyyYA=; b=DYvK24nSsLoVix3u6boII6L3FbV4Df2QuwqJfMEEA0yrcIwe6jDxXrxy5+cNAJdPHW 4Dl/cK+ETJLaKw2pqe5TluaOJoBCP5QfUHbLyqqRBrEa1wm6N2as22gCG/7NezPxVNHq v7gr+b4PSTEnQeR/4/4AxWpEJ6OaHtUJArxiRw6tdadjYuxvPEWGFYSkTVocrx8OTesj Uy95YmvLm50f8LRB4ARcOEaGRMGASkXSeuhf1NmbguIK8AEnqVt0EifseybpVmBpKqRw jpF5jP92OYUE7WO1ieKCaIyTLZbpGRICT3uWrvaddegRPiUa6ubJNtn2+j7ulTT0A0Xq P4VQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=UPl9+D8c; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-175407-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175407-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6340b395624si3324492a12.221.2024.05.10.00.38.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 00:38:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175407-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=UPl9+D8c; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-175407-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175407-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 20945B209BC for ; Fri, 10 May 2024 07:38:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2A39165FAD; Fri, 10 May 2024 07:37:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="UPl9+D8c" Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 8447915ECF1; Fri, 10 May 2024 07:37:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715326663; cv=none; b=KnN2U2rpP6gIkJ9NH/rA0EnbAnnbGj+8O8JvrGbpnLGsfsbxKBiAsvZiTeBoRn++CvjiNSd4voVWSNEusLF2CCRVMTx7O1IqMRNSZPJ09Jyl27Bp/nnQbRusTFbH1HvRsWYvjyzB90NcST3/cw5odjXklB25L+I6zt8D7jXbI1o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715326663; c=relaxed/simple; bh=jKoOYbwP+MiZkFwajW202qtdxaWWXKJ3pajvhaWPdXc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NU/GiFQq2o4GUXJcj16DYzmVXyblQnVpAFiSBSFGsh+D5Pwk0Rw84Kf5dGGOHw131zFHnJ/+7DN5Y3nmbJRM797tqPkpbSNv3pB1U8EIj58zxfuUNWVeL48TKLd86s4pc2EoZQYYkf7LT3vJsKf5EZyxfqNcepDd7Mib6vFrutI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=UPl9+D8c; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id C7706240006; Fri, 10 May 2024 07:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1715326653; 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=7rIpZAk8Wec4E2PAYnFztgJW8F7HaR4BB0LLl7tUusw=; b=UPl9+D8cgsOH1S+lx1D0pngAsI3a7o768jWCFoQSMDcbS0wWKKGBXQ9QbgrcWDDzhH9O1k 9orAUeI3HhSJCyW5zxO5osRhozCg94i/0p2mt/jXWRlkPyp/uYwKCpfdIJDKxM5V4m0YPv z1kwaukUDu/nRCbcNxAJ33QW0vdjMQi/Oy7oGanz3DwH7uckCjKTaH7Kt8cuqDgyg9HR2B NS3nxkh+A2yXhxa4u5/E+/uDaCqspaFHyle81z50twC/r+gHtSaoEswslA4LeyaRviGVCw D+XebuO8eKB9osbWdZZBUtKIBPJ4ZTFX+0pGpaJqpqLmJtfWkYmI5oI5/9uYaA== From: Romain Gantois Date: Fri, 10 May 2024 09:38:09 +0200 Subject: [PATCH net-next v6 2/7] net: stmmac: Add dedicated XPCS cleanup method Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240510-rzn1-gmac1-v6-2-b63942be334c@bootlin.com> References: <20240510-rzn1-gmac1-v6-0-b63942be334c@bootlin.com> In-Reply-To: <20240510-rzn1-gmac1-v6-0-b63942be334c@bootlin.com> To: "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 , Russell King , =?utf-8?q?Cl=C3=A9ment_L=C3=A9ger?= , Serge Semin Cc: 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, Romain Gantois X-Mailer: b4 0.13.0 X-GND-Sasl: romain.gantois@bootlin.com From: Serge Semin Currently the XPCS handler destruction is performed in the stmmac_mdio_unregister() method. It doesn't look good because the handler isn't originally created in the corresponding protagonist stmmac_mdio_unregister(), but in the stmmac_xpcs_setup() function. In order to have more coherent MDIO and XPCS setup/cleanup procedures, let's move the DW XPCS destruction to the dedicated stmmac_pcs_clean() method. This method will also be used to cleanup PCS hardware using the pcs_exit() callback that will be introduced to stmmac in a subsequent patch. Signed-off-by: Serge Semin Co-developed-by: Romain Gantois Signed-off-by: Romain Gantois --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++++- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 14 +++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index dddcaa9220cc3..badfe686a5702 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -361,6 +361,7 @@ int stmmac_mdio_unregister(struct net_device *ndev); int stmmac_mdio_register(struct net_device *ndev); int stmmac_mdio_reset(struct mii_bus *mii); int stmmac_xpcs_setup(struct mii_bus *mii); +void stmmac_pcs_clean(struct net_device *ndev); void stmmac_set_ethtool_ops(struct net_device *netdev); int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 3d828904db0d3..0ac99c132733d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7789,8 +7789,9 @@ int stmmac_dvr_probe(struct device *device, error_netdev_register: phylink_destroy(priv->phylink); -error_xpcs_setup: error_phy_setup: + stmmac_pcs_clean(ndev); +error_xpcs_setup: if (priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI) stmmac_mdio_unregister(ndev); @@ -7832,6 +7833,9 @@ void stmmac_dvr_remove(struct device *dev) if (priv->plat->stmmac_rst) reset_control_assert(priv->plat->stmmac_rst); reset_control_assert(priv->plat->stmmac_ahb_rst); + + stmmac_pcs_clean(ndev); + if (priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI) stmmac_mdio_unregister(ndev); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index 0542cfd1817e6..73ba9901a4439 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -523,6 +523,17 @@ int stmmac_xpcs_setup(struct mii_bus *bus) return 0; } +void stmmac_pcs_clean(struct net_device *ndev) +{ + struct stmmac_priv *priv = netdev_priv(ndev); + + if (!priv->hw->xpcs) + return; + + xpcs_destroy(priv->hw->xpcs); + priv->hw->xpcs = NULL; +} + /** * stmmac_mdio_register * @ndev: net device structure @@ -679,9 +690,6 @@ int stmmac_mdio_unregister(struct net_device *ndev) if (!priv->mii) return 0; - if (priv->hw->xpcs) - xpcs_destroy(priv->hw->xpcs); - mdiobus_unregister(priv->mii); priv->mii->priv = NULL; mdiobus_free(priv->mii); -- 2.44.0