Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1854849lqe; Tue, 9 Apr 2024 02:22:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXIIRfs5ygRjYGBF0MYZuvkjiJtsyKy+Nhrrc7fHQRb9/aa7h50cerpRhvQjwF7p3OZ29SRAkYJ7bkrzxa5p4GCy51F37TVpJUpYjkbbA== X-Google-Smtp-Source: AGHT+IHEUbp5tipXZlMXSsEpR04TN0ZTy1M0rQfFqLsRb8gTNmsYrhnz9oImzdrsZHQEHrxnMsBJ X-Received: by 2002:a17:906:a850:b0:a51:8672:66e4 with SMTP id dx16-20020a170906a85000b00a51867266e4mr2096907ejb.22.1712654521848; Tue, 09 Apr 2024 02:22:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712654521; cv=pass; d=google.com; s=arc-20160816; b=baqjUyy0mplXM9qTjJ1krB8vQmuoKmQJMpIEra6Bok3TxmcMDcxqYDb0/yZiHUCBO7 8jFagzA23sJM/VDLG3M+Uz4SFNRqTCYVm2V2rX1zFyhXgoTWB/UDC7J9VOYAIGHUYFNF CDEANN3LvbC5GPFgmVoQ4sdHHhl3V/XNHXyX84O4+0UdRcfx26GiVzKKRi3FY4RX+eL7 W+yeVRCHpk25eftdmE/QNltIcAlzyANegwodune87cjV5YQ0QF9ZuQBZn4sOuTy/4JA3 hxUCuSs2TbsaAqNPhvPF2PSXAQwHl4jhb+hTW7QZtQusvveL/yNo/LwznlWm3/u95EHp 7Spg== 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=NPfM5DXi3AOxcOxSFXD66Q2xnC+7MkQaEdZih6HEgsY=; fh=zv4dUbjyDRUMvZQKv32vARXx9tsay/V0VtwBaT9TpJI=; b=MbRhGkuUhJMiFQNy5TgtgdYOcsflzdnD3rdTK+v3Ot/AtBmhixh8CBRcmx39oA5JO4 nX6OgdBGD1LlDRiRQAtFBgATFsNsDE+QJbv48PsDk2VY88IlmjarYF2sQ9ZWQ+LMKNYs iEMRTdy7ifrzHjLRgcn5Zio66n5ToFM7fepKmbsh7ZmOxbYzCXcRAe5SssAgYv9DxYv9 39cqKcemEsZomkBMzmCBI1F27kvM3gOrjPqkIj4njBX4A9pJSzqEKiLhF9TQq7qQzVK0 WtREI7CWm2g5Mo5j5MkVViWyEvsqgB1ZRGRTkm59qREjZnL9EIa0PsdUrgS9mSGKkoXc imOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=XFtmtanh; 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-136540-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136540-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g11-20020a1709063b0b00b00a4e280e4e0asi4560986ejf.714.2024.04.09.02.22.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 02:22:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136540-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=XFtmtanh; 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-136540-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136540-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 8CAEA1F22215 for ; Tue, 9 Apr 2024 09:22:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C5ACD8121A; Tue, 9 Apr 2024 09:21:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="XFtmtanh" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 4F6207F482; Tue, 9 Apr 2024 09:21:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712654482; cv=none; b=W2/iILp/CiEsaab5Kr/fQ25KTM7K/7TXm1bzzE7nsupVTVYDdwKv8nC6mW6gHNtrQUCiN/kjF0eg1ja+UBBm9taBgzQwG2mQXCnxnWCGEmrFLeMugYW3s1RfnuKcQEZCbtdmdu0bsgUpryVxFsZ+yF+gYX7atAnHizWBy7EfrQU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712654482; c=relaxed/simple; bh=0fIq0EiaoSUE8hihT4+KSPVneM0zHJ4IeA1fFweZO4g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rFEkaxwf9rdRRsP+cmYEQKeuXG4IeQDzhlXFZwjAVDdrPQQWnkwimE25qeltR2+S+0+nMVT/TQxGAmktiJ914S6sHWNYQHeFCG+YyF0D1OZewH/nnXU2YD2ZpcbDL2PVIReajWk0o31OwwcwFoODPhFy06SzN4/pWYwrO80tPmA= 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=XFtmtanh; arc=none smtp.client-ip=217.70.183.201 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 2B6751BF213; Tue, 9 Apr 2024 09:21:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712654473; 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=NPfM5DXi3AOxcOxSFXD66Q2xnC+7MkQaEdZih6HEgsY=; b=XFtmtanhLu0vOCNKC0pqBEwASpKSq2H5FzNkHYa1WJ/dLzHQpZBR9vmbNZWJjFGpV4JrVQ cGdhBPLD+G9ZGYnpy8/zoD76IosZz93NqXeTfBj3P19NjuwiKUZWsO7BWCflu8ejhq7/FP tZXMJLKbWzcI4GKIEAUx3fN0loNTjrHF1ou0kbLWxGJJSx5iCP5pOkFQI35pYaxMwrYZfq R+JHjGPnzomRfAyyFd2ENXhlgOTjmIhoP2I/mYMos9+ZQX4gKcq/O+NCA5TTI+OxFh7jUA GqJczs5HTXA2shzL3bsp5bpMmJkdZUsDe3Bdts7xKPeEKZV5nor0+YjtgoCqIA== From: Romain Gantois Date: Tue, 09 Apr 2024 11:21:45 +0200 Subject: [PATCH net-next v2 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: <20240409-rzn1-gmac1-v2-2-79ca45f2fc79@bootlin.com> References: <20240409-rzn1-gmac1-v2-0-79ca45f2fc79@bootlin.com> In-Reply-To: <20240409-rzn1-gmac1-v2-0-79ca45f2fc79@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 fe3498e86de9..25fa33ae7017 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 dfa1828cd756..941fde506e51 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