Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1306719lqp; Mon, 15 Apr 2024 02:18:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWe2nLGf26ufO/TwKuwppPDhcPbgdTrmWYqnW03jlvbg596DBCLsViWcBzXws2qrDMEHwnSEOmLOirCuY0NTKTJu3mhFogkn/MF23qkEQ== X-Google-Smtp-Source: AGHT+IGpcO+MoxCz/UCcrStuyEpcxG8aEOmMv+FMZt5HlsZxFg1lN91zKaKGK0RPSZRbSZnVjReB X-Received: by 2002:a17:907:3d8f:b0:a51:d1f6:3938 with SMTP id he15-20020a1709073d8f00b00a51d1f63938mr7552054ejc.42.1713172717787; Mon, 15 Apr 2024 02:18:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713172717; cv=pass; d=google.com; s=arc-20160816; b=LKgP/VQf3S+dYiZG/kw7zJ3lzmRIARX0RdU3gOQGzOXGsW8VSCo32WejdTeo1rsUCO ddcAXSq/sUI48WOx7IE0WbqC/suvAp3/KGvB/19i1xPRVuxF2kVNh2sjEAODsIC9lFmk nRXgO1qtbVdsJY5NwZYhf3Pk6T9UTLSNx1/48XcgZkkurlyw40CbPSC4NqAdJZHTCkkq STzzi3BuJVVUObSiefMmMHHo6ffb5d7lTEnouGAaK51MqTHY5PKr1rmWJYaNTnhCYfEb /4mSR6rtIy1+tkaGLo5DBI/W2jm+Ii2nJspUbzMtiheFE1nXxuKShlf2/xrJSlEdZeBk 4Wfw== 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=o8ZBWrAJk/PVs901mX6fQjUvWR8gep9bkYKPbBH1tJI=; fh=zv4dUbjyDRUMvZQKv32vARXx9tsay/V0VtwBaT9TpJI=; b=h1g0WDJW+b93Px9KRzU1RpppQQc5RJNAjYSOc04JY9Soo612SnMIZ4SWz4yVOPmPCN s3mhOnOTDy8MQ6135nqlDDvQDewOU6NEdotYec1FXkl3WYc5CgxSS42YlzSQm0EeO/Lu EFJlcfoKN5tM35tdcT860TCO7IFWgbdSBiHFSWhVLqSvqUNmSICTeobSaIoKrGcz93ea Nc2tA4940D/jFAcaYuEQ5C4ELxl6I7c5dEmYySYS+3/J2TAgvGUCVBMY07MC0ISbJ7zx f8tJvi/cgbsVsK/dmw5QYvsiVnfv4S6oyIn75wVJ21vVxiQ7Xspc1peSELF2oOABu6wV NrNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=odifpq6h; 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-144823-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144823-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gb42-20020a170907962a00b00a4721dd8064si4629624ejc.1045.2024.04.15.02.18.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 02:18:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144823-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=odifpq6h; 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-144823-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144823-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 6460C1F22869 for ; Mon, 15 Apr 2024 09:18:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 46C6F3FE5D; Mon, 15 Apr 2024 09:18:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="odifpq6h" Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 B1D683BBF4; Mon, 15 Apr 2024 09:18:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713172694; cv=none; b=tZWZL5O1Rh674SyQx4Vxi/MDebIPao4DLg/1FrSJosWQ7o5TsaKnJAQniyedvrfX2Jg3hu6w2EDLD9GlXTkVXCuXvodPW6THWmJSwWcFue42V+DHLIfySeKfLIEJajWP3/EJ6Hc+iV34Bsq+7/2H+X7rzqvm1voxPTbOOxSYHJo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713172694; c=relaxed/simple; bh=UOOE9MGV2YJnmenuh04F9PE3eQaxMv7/gD6ePNH5HZ8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X7li2/E0slZON8aJ0ou/8XJyBOIVriMONxCo2CDt0Rl/S041v+UfbxEEw/xYNyL1kcxsflozMShCoosJ9CV0NnH+Gcv6g/3GElHYW8vq5vLJFGUrKvGgDFrM9dnHosni7iRqvK+nrlPJncy1RI5rdJcOmzdfsPYsYyF2u7HXR00= 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=odifpq6h; arc=none smtp.client-ip=217.70.183.198 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 2E743C0002; Mon, 15 Apr 2024 09:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713172689; 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=o8ZBWrAJk/PVs901mX6fQjUvWR8gep9bkYKPbBH1tJI=; b=odifpq6hF3p+KkE5pYY+2tx/uusTs5cvtRskO6SAGhMX6RgaVNLDD3b3FQIoFo4XSWM7LZ VqxPI72+RLIOIJM77dkz/wfXaQPCbvGmWJbiXWcBGkRrVIZYWwZ4rklDFFGzw2KukH2LgT mQ+IzYhQ/HEM+zCrkpu52kWOVfAJwTFXnlzGi+3z6+L7o1oH0o/oiVGlKbOvh6KHbwRtJ9 608/UFYExDnMsrbiYOm6v2/P1zM/rIEP/kE3Wc8h20xgrFDiOWocuoCw/X9LUSjwwcC7i5 ajrlihq5asVEdac3ZS98Hgs+Ent0ZxoCu4NIMR9JhiTB+JxK56xtcynzOdqaYg== From: Romain Gantois Date: Mon, 15 Apr 2024 11:18:42 +0200 Subject: [PATCH net-next v3 2/5] net: stmmac: introduce pcs_init/pcs_exit stmmac operations 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: <20240415-rzn1-gmac1-v3-2-ab12f2c4401d@bootlin.com> References: <20240415-rzn1-gmac1-v3-0-ab12f2c4401d@bootlin.com> In-Reply-To: <20240415-rzn1-gmac1-v3-0-ab12f2c4401d@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?= 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, "Russell King (Oracle)" , Maxime Chevallier , Romain Gantois X-Mailer: b4 0.13.0 X-GND-Sasl: romain.gantois@bootlin.com From: "Russell King (Oracle)" Introduce a mechanism whereby platforms can create their PCS instances prior to the network device being published to userspace, but after some of the core stmmac initialisation has been completed. This means that the data structures that platforms need will be available. Signed-off-by: Russell King (Oracle) Reviewed-by: Maxime Chevallier Signed-off-by: Romain Gantois --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 14 ++++++++++++++ include/linux/stmmac.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index fe3498e86de9d..25fa33ae7017b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7208,6 +7208,12 @@ static int stmmac_hw_init(struct stmmac_priv *priv) if (ret) return ret; + if (priv->plat->pcs_init) { + ret = priv->plat->pcs_init(priv, priv->hw); + if (ret) + return ret; + } + /* Get the HW capability (new GMAC newer than 3.50a) */ priv->hw_cap_support = stmmac_get_hw_features(priv); if (priv->hw_cap_support) { @@ -7290,6 +7296,12 @@ static int stmmac_hw_init(struct stmmac_priv *priv) return 0; } +static void stmmac_hw_exit(struct stmmac_priv *priv) +{ + if (priv->plat->pcs_exit) + priv->plat->pcs_exit(priv, priv->hw); +} + static void stmmac_napi_add(struct net_device *dev) { struct stmmac_priv *priv = netdev_priv(dev); @@ -7804,6 +7816,7 @@ int stmmac_dvr_probe(struct device *device, priv->hw->pcs != STMMAC_PCS_RTBI) stmmac_mdio_unregister(ndev); error_mdio_register: + stmmac_hw_exit(priv); stmmac_napi_del(ndev); error_hw_init: destroy_workqueue(priv->wq); @@ -7844,6 +7857,7 @@ void stmmac_dvr_remove(struct device *dev) if (priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI) stmmac_mdio_unregister(ndev); + stmmac_hw_exit(priv); destroy_workqueue(priv->wq); mutex_destroy(&priv->lock); bitmap_free(priv->af_xdp_zc_qps); diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index dfa1828cd756a..941fde506e514 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -285,6 +285,8 @@ struct plat_stmmacenet_data { int (*crosststamp)(ktime_t *device, struct system_counterval_t *system, void *ctx); void (*dump_debug_regs)(void *priv); + int (*pcs_init)(struct stmmac_priv *priv, struct mac_device_info *hw); + void (*pcs_exit)(struct stmmac_priv *priv, struct mac_device_info *hw); void *bsp_priv; struct clk *stmmac_clk; struct clk *pclk; -- 2.44.0