Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1873818lqo; Mon, 13 May 2024 00:25:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVeNYCXLGBsj+ErXepoAhTg585dOnJOJBC9PDp8f90KNh3utNgpkhS/YOnEH7sMKPpprs0bamyUbPLaP/cHhcz3zdE89FzlWxqD3EJcSw== X-Google-Smtp-Source: AGHT+IHvSEAQU9aVtiif+CuPJeX2Wf2WAiJhE0VusHc+xrbCSLV2faRCVj0WQB5dUuoC1y7Jp0VA X-Received: by 2002:a05:6a21:3d85:b0:1af:d017:c13e with SMTP id adf61e73a8af0-1afde1c5528mr8234185637.41.1715585122669; Mon, 13 May 2024 00:25:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715585122; cv=pass; d=google.com; s=arc-20160816; b=TG0a5kVYMFSNovlHVGwSUeI3g1o2UeQA0ofLfNOi8s/CGo1EGatrTr7iJtb5M4U9md 0DhhiaR0Pxdqa7DxMyikDKeKnvQsGEKbkS7RwqyQOTUJ2ka5Z5l7kN0M0OElvqdv3Cw6 ldfqekEWHcjynaeT4LDBTJ6QNcgULdHXL0XzuK++DxrIyKex/I+gSm9gHFIdKDgdMGTY bByRpjmVx93Zbz9KxW1OtqoxxpT81KXHIBebyGSOpRlE2azMPH+u/HPnYOQxliRmrIlM fRPgypR1LFxKTT8Y2fTjn5m4XyFI42itPkdxyN77aCfyG/XrTSc0vojxRMt/vVSEN5uV LGXg== 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=ufbIpBwYhCBLt0HwFL9PphnclS/treiNgHpb10AIWSk=; fh=2sYwKR36Uy22n6+ea57VDFN0PBg+1b1b+KttwOFSFVk=; b=GsHvq+ENXI9sYgowOl7nfdvI1+ulTbP1mZWcwE2XaEeB05b4lyC0VPBdkk+K7bf16C 68YfOoqoy+suYCZZuNWn5Mg2/oCyOtZLfBhfM8CrOEr9opKAoq1SL6LDV8njVqIW/m9d Ak1Bi+QMz2MSGzxsyZlKSGQMSpCAFrQR6IEaQOKa4X+gWAVKoR7joVkgo7j7XtTtO3Er bflNyfW9S+4LB6MQI1N6+0v9CZ9GQCuKhuGtdIL7vafQoicny746cWsUeHnM1PVWiOSB h0m9YWLdYzCbmqRFp46GOO+LkNdxlq0MUf63TF8EfKD+SQ/u3wHsaV1MI5BPt42TBY0P 4X1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=fHiaML0U; 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-177248-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177248-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c15d583si87021385ad.475.2024.05.13.00.25.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 00:25:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177248-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=fHiaML0U; 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-177248-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177248-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 221A728164A for ; Mon, 13 May 2024 07:25:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D09761474BA; Mon, 13 May 2024 07:24:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="fHiaML0U" Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 94711146A78; Mon, 13 May 2024 07:24:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715585084; cv=none; b=SnVnIJ7nrui6bFp2N5Wp2cLwlTMXOJXfVyBr3d21tVWEoc0o87kGSii5+WIo8tnIhdXW+R6hUKBKFd/SbXr/Ut4KyJ0H31S3U+dBerTW9w5qwaFx9sdtUiek/HEKW9QNd5Oa0IhrwnrENBTQodF9uSPklyM6/1TLNFj8RjV9PU8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715585084; c=relaxed/simple; bh=i2nT1vC9UiHNTpAL0/8VtMxDNwiYwrfdrcJ1yq5t0RM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sRowG+q3H2l0I9I8k93XrzKreT5kxPlh9XB8yv+txKVgoKcIIFipGRK+rin/pNOJIsbphI3mLBiBj2vEV4OGUOKxhxTmdshCtOq+MZrFSTH8MPNZdOOesKV6qUxHNYR+ICLv/dsfsXwRF5PKLT6PGNsWHYqswvpbOzKMgiJNIAs= 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=fHiaML0U; arc=none smtp.client-ip=217.70.183.200 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 D06062000A; Mon, 13 May 2024 07:24:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1715585081; 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=ufbIpBwYhCBLt0HwFL9PphnclS/treiNgHpb10AIWSk=; b=fHiaML0UpztueGdjpw77aS1UcuSr/NLec1MSt2rL3WkK6zKJ15qgY4SMDW2mpnxeWmLgDG H4gKhbdu2qMV5wf7e89/tIHRhjg1K82oqEizp9jU43uin3/MUijF6pdLNyD4Hiz+rdpWCq FaqqJoNN6+VlSBtVsKxGY0qR2lPwQUBIiO9gr0vKZWjbO+6X9oi4Enockm5qlFXtWuNBeN CYGFkd5vLSoDrazfHbAChqKQejbBLIU8EtWQim3git6mCvP9fNoUnKw9pU8CmsjnfuTtUG 1cBJgIfaRnXpTwFT6NW+x+OpmRE3JU6ukSotgFW9F3g+62eHZ5nei8Syf6HwOA== From: Romain Gantois Date: Mon, 13 May 2024 09:25:13 +0200 Subject: [PATCH net-next v7 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: <20240513-rzn1-gmac1-v7-2-6acf58b5440d@bootlin.com> References: <20240513-rzn1-gmac1-v7-0-6acf58b5440d@bootlin.com> In-Reply-To: <20240513-rzn1-gmac1-v7-0-6acf58b5440d@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 , "Russell King (Oracle)" 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 Reviewed-by: Russell King (Oracle) --- 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