From patchwork Tue Apr 30 07:29:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13648421 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 B911DC4345F for ; Tue, 30 Apr 2024 07:30:27 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VB0Q8Z5P02F3a5P/w4M8VDDy08f2R6cH5by7xYhxFYY=; b=j8hsJ0DWogbLjG QR+0dfuSQso0DgWdOSBWe9mSfCsvT77xisCoHQvg6HKy9MpV6vPdrO2wMNbTMNcHaWAQZbX4lGDEp MiYghXVBo/uv1bhNsjuaUNFcoBsgbrASSKsCn79p40ABwqng13ncQXWULyDwMahRu8iqQHKkWK9gZ 0jaX8us3m6SJzwvcpBpWLoWXkcu3VSiCkWZZmcv+W/LtXEBH0tAvwHQ+5s9xEOTXfRWxezyMcaFQL 2sxiYQa5JhiHv4T99RgExjAFXBX0Y6rjLjOHZEUc0Ju7LNjsGbMffWXRAZ5Ghs3jpsetpPVEm28V3 65937MO+8azC3MZsMrKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1hwG-00000005R8F-3gzv; Tue, 30 Apr 2024 07:30:08 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1hw5-00000005R29-0vc1 for linux-arm-kernel@bombadil.infradead.org; Tue, 30 Apr 2024 07:29:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=Quwz6Y6DCJb6oI8QivjHVeJ8W6gP2+As4r5PbpcMIik=; b=PqsMptgoKJVwHPEoKhcTnkLcdf 7kPEhGp1A9WrxA2Sq20Pkl5gAxey1Ugwbf1ldXz2bTo6UWdSZBg8/JPkXupC4QuzcxkOalj0yx7RZ 1C6A6NJEFFNt6wRSrEFKDLCxeewlbaZ6BpfqerVvgQxYDUGbbg8WN5ndA7PKZoVOjmuuKrq+EpY4L arrO9ddglV5Me68rWK61NiOoHt8pXK5MTThr1Ra5Rwbrot5tmKf+yDP919qyYKTsLHEWIiWExe/st OYKXMcUEDMy6vA8u9LP1D83fu9J5qBajKlmrodN5pey+7wAy9HOnHmAQvQzvi+NelA4fyZKmj74Xv WEeBV6yg==; Received: from relay1-d.mail.gandi.net ([217.70.183.193]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1hvy-0000000GqFy-34UZ for linux-arm-kernel@lists.infradead.org; Tue, 30 Apr 2024 07:29:53 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 319CF24000B; Tue, 30 Apr 2024 07:29:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1714462147; 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=Quwz6Y6DCJb6oI8QivjHVeJ8W6gP2+As4r5PbpcMIik=; b=ZxwuCRRbn1FQlBI4z2c9GSAvPY/TW1CMBCxRD+iRIiteCUzjtF+IQ4XvRXzA/TeRQbyojZ Rrp3s1TWVVeyGCBCwMd4y9jTQG14n56nB6m+ILT0XBATUXn9G88e2bheoEKc1ByN5lP9Ql WnQyfPmWAOdArHELhHYAVH71FPH+pI3pqEpNas/kF0+XvsgIQEJfT07qbTSd6nTKfrzKRe rIPIDNup+s4Ez3ptqXYR4Gs45cAkb0L9RucYO03U1W2aBlTatCwTa9shguXaA0E6FCsedZ jsqZNnusVtA8SdVHVeLSFFNCKqMo7ZppyHuEaKF1jIJHxOkKmQVQTd3Kn/uflQ== From: Romain Gantois Date: Tue, 30 Apr 2024 09:29:42 +0200 Subject: [PATCH net-next v5 2/7] net: stmmac: Add dedicated XPCS cleanup method MIME-Version: 1.0 Message-Id: <20240430-rzn1-gmac1-v5-2-62f65a84f418@bootlin.com> References: <20240430-rzn1-gmac1-v5-0-62f65a84f418@bootlin.com> In-Reply-To: <20240430-rzn1-gmac1-v5-0-62f65a84f418@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?b?Q2zDqW1lbnQgTMOpZ2Vy?= , 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240430_082951_249320_2DD19084 X-CRM114-Status: GOOD ( 12.93 ) 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 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 | 12 +++++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index dddcaa9220cc3..7e0d727ed795b 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 stmmac_priv *priv); 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 59bf83904b62d..2a55c5d07f6b8 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(priv); +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(priv); + 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..508bd39cbe2b3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -523,6 +523,15 @@ int stmmac_xpcs_setup(struct mii_bus *bus) return 0; } +void stmmac_pcs_clean(struct stmmac_priv *priv) +{ + if (!priv->hw->xpcs) + return; + + xpcs_destroy(priv->hw->xpcs); + priv->hw->xpcs = NULL; +} + /** * stmmac_mdio_register * @ndev: net device structure @@ -679,9 +688,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);