From nobody Fri Sep 25 21:02:57 2026 Received: from fout-b3-smtp.messagingengine.com (fout-b3-smtp.messagingengine.com [202.12.124.146]) (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 2C00E4ED19A; Mon, 21 Sep 2026 17:51:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013068; cv=none; b=bHifiZ9Ffn/HjhuiSE5zB0JURd79avtf/tWy7/TgDRNyZj4fpvkWVIimuyDonJLajxgMIa1tu7NsU41Jm1FA3V95UTubggxg12tztZ5f6OM170aEPKCLX7zlgBWmzBkfkbRAw62t9fijZVJA0d2tAqDcxdVR1yG6MAckvm0513Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013068; c=relaxed/simple; bh=RfD39CrFszYWmLvlkyR80p6gowbn6xTMaq0aOLyOiUc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZMbM86x2qKUZKFAGrnSmCf6CGD1AVg4jRmNj9UmQqJ6pZSam+AnPoelbalta4cWFwyVPcBuuisywzD3btHSduQ3yK5Pv3sBeBiYhmvV5gCUQK2QsOGpphlBsInPOwbUzYl02c9ojtWtPL8j/2VmWMpWUigrApSedpwCrDNFICdU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=AZLeDDM5; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=VAqs+sMK; arc=none smtp.client-ip=202.12.124.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="AZLeDDM5"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="VAqs+sMK" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id 5F7A01D000D6; Mon, 21 Sep 2026 13:51:03 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Mon, 21 Sep 2026 13:51:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1790013063; x=1790099463; bh=IrhSvj+nx3bsDyqmh0CZIarm7FuOw+qs7by83REZ9gs=; b= AZLeDDM5DAM+FNoE+JIZ0CwiBDZsYLlF4jmfICEcxN5vveA5tTfyAJwhfGsNcMiT n8XVx1tiu2WU1xERMRiT4cLhxCoxa8YnfyyeA7ZDrwukf6mcE6rh2H4eNYQiHl8V UrMlOm+PUEEd/6Buz1kyRxC4rp2BzlxVYMPE9CMpzG7ZA3B0XGMPG7OcSZP7aioi V8stLykVAPP0GkIX/M8n4K2id1UWMR2HvTvfzHS2RpFG+f6vt7d7Ys/phhE+pVtp NMWDsRnIVcM8+37bcZ48KbMMMEPj/gZV74kqyjc0ck0tgpUOCCb9UxBxus4U1wLT QC27qhXaWya58uRsnXIKGw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1790013063; x= 1790099463; bh=IrhSvj+nx3bsDyqmh0CZIarm7FuOw+qs7by83REZ9gs=; b=V Aqs+sMKucPG+Ab1b0MLib0r0g5Ioqb/IgBT4tZGhEsA/Tb3tXDiplkpPI0UENXB/ WAmqdkE/Qxsm95WpY7GNlPVur60Pwn9bzTgyez1yC7gON2l5z4/O/Q5/RYRQ9Hu9 IMVLd9Gk4YqzArIwz0bxWq/eh7SamhiSRxBuown8iLqB3Uq2QiS05PgIoedCpyds oFkjCEUKNhvJL7iv9oD/AOyNNPUANsfp/zacfM9ucmCv/dZvCLTxhOL5GlHydlYt jatTW4ZpdWVxD26HajdeVltlcE334EQ6k/YO7xUzP2yNoSDnDnNpmDhhT0tAUQlH WTnn6flvqy3mnUU+ms3mw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFKyuwNHokJCgIndgtoOusqu1/6uPi/0uzv51oOMJoBVzbBuuQBERlY9Rv3NvmA6T d/CD1lxyU3UgPnEeJyPNbZpf+4OQPJ3AbFbyzvtJqzJyhSU0WyRw2N3jkO5MC6tTob5H+B TCxu9EekrWCaHBw+6MstQGy681MV+L5ictmDPIp7n4+FYelCRH1YJ2M1xfPZF1CqF0smxw c4JIURjRlH1wsfm+CyMKRUhHTOncPDoh9a2aZMLd+DzObP2w66sKePqFvy/aIxy5vDMgrD fRXTZksUaWctOWTnUr66Aqn0xuMYZyKstCQR4Y6Vusob1m7Y0ettnqm2yu1mZb4HnTRWTB CXw0yx8G20+twMHKTFIQz+upxN1DFiPdPgB+2b+NdjVGTESWkmuQRWw/j0vxxNGU6M23oG r3qsoYm68DGErRGndv0r/EVz4V79AoNgOail4hU7ni35A3s6vHsZ12iTM0jJYiRZkenqzc ZfshMB8gl+zwNQGvpfcCjmwGMlBjt1mdneMXhig9ogKMCV1sxzOpUsE5GGROtgXX9s4Q7j MONHtC8IeavJGscuZUn4QD7WF/BvK+hbs4tQ+nc7EP3Ws9ufso1hBhgWrq/pvoLyovhW8b ECOGLIMfcgHovn9ekxI2jEKSpnrszkmBTa/ioXObhb5mrrmFFlcLL5NgUeEw X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 21 Sep 2026 13:51:02 -0400 (EDT) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: paul@pbarker.dev, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Richard Cochran , Andrew Lunn , "DavidS. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vadim Fedorenko , Sergey Shtylyov , linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH net-next v5 01/10] net: ethernet: ravb: Remove gPTP control from WoL setup and restore Date: Mon, 21 Sep 2026 19:50:28 +0200 Message-ID: <20260921175037.4084310-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> References: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> 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: quoted-printable Since commit a6a85ba36fd0 ("net: ravb: Move PTP initialization in the driver's ndo_open API for ccc_gac platorms") the gPTP clock (if supported) is stopped and started by opening and closing the ndev. This makes the special case to stop and start it when resuming from WoL redundant. As the ndev will always be closed and re-opened when resuming the system. Signed-off-by: Niklas S=C3=B6derlund Reviewed-by: Sergey Shtylyov --- * Changes from v4 - Updated commit message to try and address LLM hallucination. --- drivers/net/ethernet/renesas/ravb_main.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index ea1c7e536791..36173a09e2fd 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -3182,9 +3182,6 @@ static int ravb_wol_setup(struct net_device *ndev) /* Enable MagicPacket */ ravb_modify(ndev, ECMR, ECMR_MPDE, ECMR_MPDE); =20 - if (priv->info->ccc_gac) - ravb_ptp_stop(ndev); - return enable_irq_wake(priv->emac_irq); } =20 @@ -3204,9 +3201,6 @@ static int ravb_wol_restore(struct net_device *ndev) if (error) return error; =20 - if (priv->info->ccc_gac) - ravb_ptp_init(ndev, priv->pdev); - if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); napi_enable(&priv->napi[RAVB_BE]); --=20 2.55.0 From nobody Fri Sep 25 21:02:57 2026 Received: from fout-b3-smtp.messagingengine.com (fout-b3-smtp.messagingengine.com [202.12.124.146]) (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 CB9594AF9F4; Mon, 21 Sep 2026 17:51:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013069; cv=none; b=duKmvxKtpci7+3aj1AsKLoPnk1AasmNaK+e9Qi6/YcKQKQYzdL8kpH2WiJtA/+44dthbvNSPk1e46hyHnzkL+Ylq62BbBgRBOQaZSS4q6YkOsIPt7L4yEmKcUFNB5SRSlvgT/o6lxgRuDSvfNRsA2/eMQ6LmFDl1D3wle1zj2Xo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013069; c=relaxed/simple; bh=OK8h4W8Qb3WdBP0L5gFqTZOwrg1Mh9yNZb1fGNPTOzU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PdI5TCY5ptI+BoGh5nZQt/LMy573a1nvC1zsF546c0fotwEqqB1JiSrUMKsW/2DEAEMnBwng0Ca084vxRHU1fQEDZSOqAKUawLak52J5fveuS8IM2kbvbiJfdTlcugTYN0WcN7CzCXetYagZTJMnF+sSG6Qp4Xm5leLgMxn1lnQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=OkxZCfPL; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=R7P2SBrF; arc=none smtp.client-ip=202.12.124.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="OkxZCfPL"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="R7P2SBrF" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 8E8451D00117; Mon, 21 Sep 2026 13:51:06 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Mon, 21 Sep 2026 13:51:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1790013066; x=1790099466; bh=xLsQam9KYOnUXlZpyMTlagCg0xIJIMA0dYVJY+iePdU=; b= OkxZCfPLqVPrna/yYKGCQcTcP+T0fs8ufk2y6qCG7JZmoLPSMsqgWNb1fc7nqye5 j083C3LUHgBjwo0kQTEC9fC+3TC1jKFQ8ei76MBjNkiskQAQSCMiByoZ94OqBS1Y 3b7X4iiOvmfc0jXG6908/66P9V/FQ/LJueJhc3NEA/fX0uSKTRrq8lbnhiONjt3i YuSVB4ey5isgQgzFam84bKzqaZY034QCuDvBX/XrkIUU3Y4o0fYTnW7lg/HczAOx 4NWiqlqMXdEAweQb3jKcyZXdlifx6vJNPFobIm3yToqpGyMghnGDXkyCtAM3rqNR j/Qz5qfMkO1At+avRH/o6w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1790013066; x= 1790099466; bh=xLsQam9KYOnUXlZpyMTlagCg0xIJIMA0dYVJY+iePdU=; b=R 7P2SBrFI8UpVY9583Pc6v9qA0h69HjouuF6dPyrco9pGLeBhIWc2CC9FbMX3QIuV Meuv64nWkh2q/2qfeiBxG5+tDZwBY4uhBDqFjQaT820OxEGHwKPQaplMa8d8MsFx EkY6Zt60XjOdeskRnyvRLPRlldnTOt/vX7C7vNMEoDcoOvAqs4ZDHAhgMuRCAvWd Cn+h/mmJ9xh0Td9XfeoIpWEVthBce9WkD/eVZgVt5EdSUbQvMPrhOTQR+cwIvq3b 6nIrO+qUZfcv8hHqB0vMACspFGCsNMxjXY0MnqWAKLqUreXp2MxKqYQLOHHfECpv aov8CCNSNJAd+jSKRA+kw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFKyuwNHokJCgIndgtoOusqu1/6uPi/0uzv51oOMJoBVzbBuuQBERlY9Rv3NvmA6T d/CD1lxyU3UgPnEeJyPNbZpf+4OQPJ3AbFbyzvtJqzJyhSU0WyRw2N3jkO5MC6tTob5H+B TCxu9EekrWCaHBw+6MstQGy681MV+L5ictmDPIp7n4+FYelCRH1YJ2M1xfPZF1CqF0smxw c4JIURjRlH1wsfm+CyMKRUhHTOncPDoh9a2aZMLd+DzObP2w66sKePqFvy/aIxy5vDMgrD fRXTZksUaWctOWTnUr66Aqn0xuMYZyKstCQR4Y6Vusob1m7Y0ettnqm2yu1mZb4HnTRWZc 4pnvDWpnD1pj18sTy78Sk44z0Oj10BsEdC2DhTgIeFCoq4Z61df/0k0eQ0qxYOZAagjPe1 MOWqOR62HXnFbhlk6S1Fs+KZT+/ic0N5f/yUjYgtDj0kH/mI540pWjRukXRVwA0ClrIIcZ 5BipCBkPtf+hxnqrfYv+pJjpBZOB0Hxr+fgPEZQruH0Yxc0F9ZDFLOZUQSXknflbZqdvOD Yp+LeBlxcUH9bFndAZ8kenRg4wwtC90QDZvqkvH3msLXkBon5iMURb4C1abqNFL8YcpSfX kBSVbGiFvFCH9ibzNwBJ9f8cVavK9WV6K/1i/DLQPNpH+jGzhfdwcXGZLxSg X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 21 Sep 2026 13:51:05 -0400 (EDT) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: paul@pbarker.dev, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Richard Cochran , Andrew Lunn , "DavidS. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vadim Fedorenko , Sergey Shtylyov , linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH net-next v5 02/10] net: ethernet: ravb: Move programming of gPTP timer interval Date: Mon, 21 Sep 2026 19:50:29 +0200 Message-ID: <20260921175037.4084310-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> References: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> 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: quoted-printable Commit f384ab481cab ("net: ravb: Split GTI computation and set operations") broke apart the operations of computing the timer interval and programming of it. However it kept the programming of the interval in the RAVB main logic. Having split the two apart this can be improved further by moving the programming to the gPTP initialization function, as the first action of the gPTP init function is to wait for the timer interval programming to be acknowledge by the hardware. As an added bonus the interaction with the gPTP registers for the programming can then also be done while holding the gPTP registers lock. Signed-off-by: Niklas S=C3=B6derlund Reviewed-by: Sergey Shtylyov --- * Changes since v4 - Update comment in code to try and address LLM hallucination. --- drivers/net/ethernet/renesas/ravb_main.c | 16 ---------------- drivers/net/ethernet/renesas/ravb_ptp.c | 11 ++++++++++- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index 36173a09e2fd..a89f6fe7866f 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1846,20 +1846,6 @@ static int ravb_set_config_mode(struct net_device *n= dev) return error; } =20 -static void ravb_set_gti(struct net_device *ndev) -{ - struct ravb_private *priv =3D netdev_priv(ndev); - const struct ravb_hw_info *info =3D priv->info; - - if (!(info->gptp || info->ccc_gac)) - return; - - ravb_write(ndev, priv->gti_tiv, GTI); - - /* Request GTI loading */ - ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); -} - static int ravb_compute_gti(struct net_device *ndev) { struct ravb_private *priv =3D netdev_priv(ndev); @@ -1974,8 +1960,6 @@ static int ravb_open(struct net_device *ndev) =20 ravb_emac_init(ndev); =20 - ravb_set_gti(ndev); - /* Initialise PTP Clock driver */ if (info->gptp || info->ccc_gac) ravb_ptp_init(ndev, priv->pdev); diff --git a/drivers/net/ethernet/renesas/ravb_ptp.c b/drivers/net/ethernet= /renesas/ravb_ptp.c index 43218bc15b15..ac91a6813368 100644 --- a/drivers/net/ethernet/renesas/ravb_ptp.c +++ b/drivers/net/ethernet/renesas/ravb_ptp.c @@ -321,11 +321,20 @@ void ravb_ptp_init(struct net_device *ndev, struct pl= atform_device *pdev) =20 priv->ptp.info =3D ravb_ptp_info; =20 - priv->ptp.default_addend =3D ravb_read(ndev, GTI); + priv->ptp.default_addend =3D priv->gti_tiv; priv->ptp.current_addend =3D priv->ptp.default_addend; =20 spin_lock_irqsave(&priv->lock, flags); + + /* Set gPTP Timer Increment Value. */ + ravb_write(ndev, priv->ptp.default_addend, GTI); + + /* Request GTI loading. */ + ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); + + /* Wait for GIT loading to complete by checking there are no requests. */ ravb_wait(ndev, GCCR, GCCR_TCR, GCCR_TCR_NOREQ); + ravb_modify(ndev, GCCR, GCCR_TCSS, GCCR_TCSS_ADJGPTP); spin_unlock_irqrestore(&priv->lock, flags); =20 --=20 2.55.0 From nobody Fri Sep 25 21:02:57 2026 Received: from fhigh-b5-smtp.messagingengine.com (fhigh-b5-smtp.messagingengine.com [202.12.124.156]) (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 2542F4E5336; Mon, 21 Sep 2026 17:51:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013073; cv=none; b=Lr07LI1ztqjXDxyPlyB44+UKC5TRz7zIlODUnjpOYUDmMyrnOJOHadWhJT+zpazfJnriwlQvuH6PD+6rOx3SOeZh9eXvltKd3ioMRq/GZHJmsOcl8XZGLOP3Hvn3IJbbLzl7IeYrFtzjuSBiEVHb8n1bflU53JwGR9JtLCG716k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013073; c=relaxed/simple; bh=srAWmKXguWc0q1fxvPQkRLk3OtDf6cRshaZ343sxc4k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Fc5iCjkHyVX8zt3UwRv/chpK5sFfIFEv6a44p63/DGx4dLSwWLNsw8s1xCU81tyVOnk6SPGEZZI344jkHYqKY2hv9+p6cjO+gWhai7maac9KjbOK5atp5QeLZzEv06/asooitr28FRs4+xuz2DFsFh6Z5zKmhf/sHyE9dZZAYJc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=jIaoTuw7; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=QqQB38Z4; arc=none smtp.client-ip=202.12.124.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="jIaoTuw7"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="QqQB38Z4" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id 70F0F7A0104; Mon, 21 Sep 2026 13:51:09 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Mon, 21 Sep 2026 13:51:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1790013069; x=1790099469; bh=Hx9Zvyr370J8/nt0naogfD+gRG6r1y/8v2dOZV7ReHo=; b= jIaoTuw7ZTnrGdjEs3y1Xp5SxoKOzMnQfoq2gNWDOGEcxedt1VWVj+RfWgM5WyUJ hKXw7OacWn2KGyrMEEDxiOhfSpSAJU428fKf/WinvkkGq/vid5vhFqjhRHY3ECSr 5YwpaS7DId08l+A/bPBhwakuDEkAwVTkSffFkLgFmZqLaWnLYCd/DF5wU+qAAwji ySVc6hwQFRnwZ5YdiU/Ge678LOaLX1VuMw5LAbYqTNeqxZRDsyFbOM9hUKVDvMFe 3Ddr2zZ8Lc9Ipb3g5+GkIWrseG9ViWdGxTXGok+j2ECfPO3LEVVHdfL0KzmAbpZ6 O48QRtFGXDqluttMUq8nVw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1790013069; x= 1790099469; bh=Hx9Zvyr370J8/nt0naogfD+gRG6r1y/8v2dOZV7ReHo=; b=Q qQB38Z4AMMmL0nxXshF3Yz4YYq0B7uDROAqK+cYr4ebb0xNfxp8KTvlFQgSftvJH yMub4vvx6KNGg20KfJbDrmMIorA547nUUhrkdUL5V4bWbgzOWsPlh1wYWeXPVMZX 3JkKRJ3lamBkofDbHxGXfi+FtV423OsBAHw1dNpBedTrc/+3zcj4a+gmoWwiE2BO TK4nSFAEP2ABb5m/N7Haz7rnlm1eFhpFOf7qQ8T8RUWbL823hEe7i8ZBMZbi1/59 TRb01phcgWfWmDySHHAsYVuiDd4WUD5VbTXLotoOMogQZbmeDuVaDPeH7cjMX2Vv WbjtniJnjqbSumdObKBSw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTERb8iWuOaCoZl7Bdy7ms8LtfxU+xjK78I80yyQZdvSwOOOfv5Eh589Pe9RlM06WU dDnU8HOY0XEZCSLotd4wkziCSyOMbfYp7QQMcpxqxHGnE0sN+h/hwRsMQX/TPzjkM+eutR EyTNwAM1tWMwrq7QvnP58hqr16hBRsM/xWQjxvzbUj3rLPulCyCubKGS8/OfnPdml28WZP 11HBM2ETQKxQIL8VV/A/GNA6vlfx97xrmJ0/jihnD6jQBVLDZo9wvlSWgasgNowAQLofbi uJp5/Pi8DlT51OEeXr8hn2lIL64WOU6L6jZxXkbUv9MeKffjxF51gA/7UnWz5uX+sq6JTi enyrpEnj+/zN34WERnmon9+hcAmHRPho/VpdEQOXolNmPWpxSUHoqG+RQfBBWClN/WkFOH uVTgyrYzqn+kLoRCbFl0CVE111Nnfoxq3KchnJzi8VRas0Y2dbLOhvIsPW/fhMOyNXq9T7 x6ttQ3uaNRjOrOopTGoyza5q87lgml0DzBK/jI0s6PaGWxq8Z91Omc2mgDjpjMR7T6o7/G 9QZNNHQXjoH3FvAb9KrI0VkE1JLHBVnpkR/X3x4fJ3W1ng9JCw1xHsd3UFJx1sNd4nls// i8fFw31QFi7k95ndiobkDJ20MEKGAzytsQYOTo3oIM1Uk4F4f3Kr1nN+LkWg X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 21 Sep 2026 13:51:08 -0400 (EDT) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: paul@pbarker.dev, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Richard Cochran , Andrew Lunn , "DavidS. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vadim Fedorenko , Sergey Shtylyov , linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH net-next v5 03/10] net: ethernet: ravb: Simplify gPTP start and stop Date: Mon, 21 Sep 2026 19:50:30 +0200 Message-ID: <20260921175037.4084310-4-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> References: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> 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: quoted-printable For devices that do not support the gPTP clock in config mode the somewhat oddly named flag gptp is set, compared to devices that do support the gPTP clock in config and operation mode where the flag ccc_gac is set instead. The two flags are mutually exclusive. For the gptp-flag devices (Gen2) the clock is tied to the AVB-DMAC, when it is stopped so is the gPTP clock. For ccc_gac-flag devices (Gen3) the gPTP clock is available whenever the ndev is open. Prepare to add Gen4 support which will add a third way by cleaning the Gen2 and Gen3 cases up a bit. Fold the gptp-flag start and stop calls into ravb_dmac_init() and ravb_stop_dma(), which start and stop the AVB-DMAC. There are no functional change as all call sites to the construct: if (info->gptp) ravb_ptp_init(ndev, priv->pdev); are always just after a call to into ravb_dmac_init() and all call sites to the construct: if (info->gptp) ravb_ptp_stop(ndev); are always directly followed by a call to ravb_stop_dma(). There are two special cases where the calling construct covers both the gptp-flag and info->ccc_gac devices, one for start and one for stop. The condition that it is preceded by a call to ravb_dmac_init(), or followed by a call to ravb_stop_dma() are however true for them too. Reworked the two special cases to drop the check of info->gptp. The end result is that the gPTP clock will be started or stopped for the gptp-flag devices in tandem with the AVB-DMAC, while the info->ccc_gac devices will be controlled, as before, when the ndev is opened or closed. Signed-off-by: Niklas S=C3=B6derlund Reviewed-by: Sergey Shtylyov --- * Changes since v4 - Fix gPTP stop in error path of ravb_open(), thanks LLM a real issue! * Changes since v1 - Improve spelling in commit message. --- drivers/net/ethernet/renesas/ravb_main.c | 36 +++++++++++------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index a89f6fe7866f..42d208e6b8ec 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -707,7 +707,15 @@ static int ravb_dmac_init(struct net_device *ndev) return error; =20 /* Setting the control will start the AVB-DMAC process. */ - return ravb_set_opmode(ndev, CCC_OPC_OPERATION); + error =3D ravb_set_opmode(ndev, CCC_OPC_OPERATION); + if (error) + return error; + + /* Initialise PTP Clock driver */ + if (info->gptp) + ravb_ptp_init(ndev, priv->pdev); + + return 0; } =20 static void ravb_get_tx_tstamp(struct net_device *ndev) @@ -1115,6 +1123,10 @@ static int ravb_stop_dma(struct net_device *ndev) netdev_err(ndev, "failed to stop AXI BUS\n"); } =20 + /* Stop PTP Clock driver */ + if (info->gptp) + ravb_ptp_stop(ndev); + /* Stop AVB-DMAC process */ return ravb_set_opmode(ndev, CCC_OPC_CONFIG); } @@ -1719,9 +1731,7 @@ static int ravb_set_ringparam(struct net_device *ndev, =20 if (netif_running(ndev)) { netif_device_detach(ndev); - /* Stop PTP Clock driver */ - if (info->gptp) - ravb_ptp_stop(ndev); + /* Wait for DMA stopping */ error =3D ravb_stop_dma(ndev); if (error) { @@ -1752,10 +1762,6 @@ static int ravb_set_ringparam(struct net_device *nde= v, =20 ravb_emac_init(ndev); =20 - /* Initialise PTP Clock driver */ - if (info->gptp) - ravb_ptp_init(ndev, priv->pdev); - netif_device_attach(ndev); } =20 @@ -1961,7 +1967,7 @@ static int ravb_open(struct net_device *ndev) ravb_emac_init(ndev); =20 /* Initialise PTP Clock driver */ - if (info->gptp || info->ccc_gac) + if (info->ccc_gac) ravb_ptp_init(ndev, priv->pdev); =20 /* PHY control start */ @@ -1975,7 +1981,7 @@ static int ravb_open(struct net_device *ndev) =20 out_ptp_stop: /* Stop PTP Clock driver */ - if (info->gptp || info->ccc_gac) + if (info->ccc_gac) ravb_ptp_stop(ndev); ravb_stop_dma(ndev); out_set_reset: @@ -2020,10 +2026,6 @@ static void ravb_tx_timeout_work(struct work_struct = *work) =20 netif_tx_stop_all_queues(ndev); =20 - /* Stop PTP Clock driver */ - if (info->gptp) - ravb_ptp_stop(ndev); - /* Wait for DMA stopping */ if (ravb_stop_dma(ndev)) { /* If ravb_stop_dma() fails, the hardware is still operating @@ -2056,10 +2058,6 @@ static void ravb_tx_timeout_work(struct work_struct = *work) ravb_emac_init(ndev); =20 out: - /* Initialise PTP Clock driver */ - if (info->gptp) - ravb_ptp_init(ndev, priv->pdev); - netif_tx_start_all_queues(ndev); =20 out_unlock: @@ -2374,7 +2372,7 @@ static int ravb_close(struct net_device *ndev) } =20 /* Stop PTP Clock driver */ - if (info->gptp || info->ccc_gac) + if (info->ccc_gac) ravb_ptp_stop(ndev); =20 /* Set the config mode to stop the AVB-DMAC's processes */ --=20 2.55.0 From nobody Fri Sep 25 21:02:57 2026 Received: from fhigh-b5-smtp.messagingengine.com (fhigh-b5-smtp.messagingengine.com [202.12.124.156]) (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 D2D774F3EBE; Mon, 21 Sep 2026 17:51:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013075; cv=none; b=fomNdyrHaKCC5u6iDYaLz0bfJiCbzFTK89jQTLBY+cKDTgiUuGDaizwNMa7B7JmDeq6vXJkdNrPxDX4xSKfqF9K8Le0wdDC0Fd6mJi95+kEKbxNF7qtagnPtu22/jhi0lU1eji9udJ9/UsM4CQ8Vd3TvLs0ZdNz8BFy/FeQrXNg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013075; c=relaxed/simple; bh=n8uMvO6lkLqeZI1gW7SImMJOFb8/LIYVX94RbwXVc8w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LBY+zzowNOHcPlg744a3Y0xHiRX2z070PA+/2qLMKxZhSG4cReChbqVxYmoHouQ4ssZVlHPRizeCRw6W+BOzvSmJYc/582Gb97dGhkS0QeCyahFaaM30nEFXp5a93kab6OzxSvsDDbxtrhCoVQf2Dg+tDmW/IVrIIsGHdiG/ZIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=GF2Tf8Ld; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=DmO2APUG; arc=none smtp.client-ip=202.12.124.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="GF2Tf8Ld"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="DmO2APUG" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.stl.internal (Postfix) with ESMTP id 862EC7A00C2; Mon, 21 Sep 2026 13:51:12 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Mon, 21 Sep 2026 13:51:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1790013072; x=1790099472; bh=zhK2da/WvXsINzlSRetnNOBunpzwaf0zMWO1x1DU4zQ=; b= GF2Tf8LdvYOe6XnClhdZBkkdYYvGpz+5pMGDJdmCagKXI04rdIUHrqp/OJDpa+IZ 6pRu4T0b++TiBrx6wYoSfQLKnSU2kd86bTfSzRE569RN+hjNDOU+alLFCjVq2h9u DadlQT9XB7bvUXbnpQDUdo3wBzDsSc2/TEM3QHxhepkH/DVOfFihm7ZI7OJHUi+Q 0IQZDji6HUD/y0ktjSBlX/vA+R2b1J7F/pMWizyH1OBFAwZcpdZ/GXN9CPTnpJzO 7H560ta1WoERUWUfH4u38JUiVN44x2iIKSIo52h8mDGEOuv3VOENNRWvQk8cN2sn ZSQbp/Fw9f2rcu4c0enkxQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1790013072; x= 1790099472; bh=zhK2da/WvXsINzlSRetnNOBunpzwaf0zMWO1x1DU4zQ=; b=D mO2APUGJfTdgl9Lo1kfFI5Xme0MaAsHLiPWzCeVuLNDl3syuGwVg0leM4W8mQV1O vK0HEpAso8bhYWhxc1pAkVxbTkZ9r+vd/AcK+Aqv3do++LWlQBURnxXUi0p98SVM /nQqcyRTQmk0/LBJFGiBBv4K7tg49xiZQBOrNdEmE2rSG3rEpIW9s7oyFh0XzBiM 1f3c2Op4M2kU3nTP95evv3l5+N/wRA1QixUsUnIQmPlZA7JzhHZ1rARpALtCGFCG s/q8S+kt28XVZlSv6mRcQRzB2o4GH9PNzuMHHd549xZus9QsIV1Z8+pr9wjN4Ux+ rwY/uq6UFbE0ADk8pf50g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTERb8iWuOaCoZl7Bdy7ms8LtfxU+xjK78I80yyQZdvSwOOOfv5Eh589Pe9RlM06WU dDnU8HOY0XEZCSLotd4wkziCSyOMbfYp7QQMcpxqxHGnE0sN+h/hwRsMQX/TPzjkM+eutR EyTNwAM1tWMwrq7QvnP58hqr16hBRsM/xWQjxvzbUj3rLPulCyCubKGS8/OfnPdml28WZP 11HBM2ETQKxQIL8VV/A/GNA6vlfx97xrmJ0/jihnD6jQBVLDZo9wvlSWgasgNowAQLofbi uJp5/Pi8DlT51OEeXr8hn2lIL64WOU6L6jZxXkbUv9MeKffjxF51gA/7UnWz5uX+sq6JG2 ITdsLqQkFa3h7S3XVJV0s/l0O9h6eSu9xjJlIxNRDIXO5nUD0b2RKhnw2SFFqzoWbu29g2 Bdwu/9dmua7YTDTI4b0lqvqDOmhRS9v9UVt4aR+IzhoNfumI/VOEnicDL0L4FAn0tMzZu7 74ztFZnX7wM9f3NmbRoMzaJQkeiIEjaEI8WrVXxBrn1to1E+HpzLFWpDpSAlVSLdLKwVLC 7/h+zRTW6H65cMhNU+gP6HZ7KX17mbRzR6Yndqai0wsS2OTTYoXI9EBksT0tNKH+e6aZqm pccKl+oQA+Y3ewOZeIAlECk6dPWK1IqQIBt8yVfWWnDU/ICzcYSjgPLa0ogA X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 21 Sep 2026 13:51:11 -0400 (EDT) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: paul@pbarker.dev, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Richard Cochran , Andrew Lunn , "DavidS. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vadim Fedorenko , Sergey Shtylyov , linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH net-next v5 04/10] net: ethernet: ravb: Remove redundant argument to ravb_ptp_init() Date: Mon, 21 Sep 2026 19:50:31 +0200 Message-ID: <20260921175037.4084310-5-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> References: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> 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: quoted-printable There is no need to explicitly pass the struct platform_device pointer to ravb_ptp_init(), it can retrieve it directly from the private data structure. Signed-off-by: Niklas S=C3=B6derlund Reviewed-by: Sergey Shtylyov --- drivers/net/ethernet/renesas/ravb.h | 2 +- drivers/net/ethernet/renesas/ravb_main.c | 4 ++-- drivers/net/ethernet/renesas/ravb_ptp.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/ren= esas/ravb.h index 3ee4c6108189..aa45f5466001 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1163,7 +1163,7 @@ void ravb_modify(struct net_device *ndev, enum ravb_r= eg reg, u32 clear, int ravb_wait(struct net_device *ndev, enum ravb_reg reg, u32 mask, u32 va= lue); =20 void ravb_ptp_interrupt(struct net_device *ndev); -void ravb_ptp_init(struct net_device *ndev, struct platform_device *pdev); +void ravb_ptp_init(struct net_device *ndev); void ravb_ptp_stop(struct net_device *ndev); =20 #endif /* #ifndef __RAVB_H__ */ diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index 42d208e6b8ec..1dfe905832a0 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -713,7 +713,7 @@ static int ravb_dmac_init(struct net_device *ndev) =20 /* Initialise PTP Clock driver */ if (info->gptp) - ravb_ptp_init(ndev, priv->pdev); + ravb_ptp_init(ndev); =20 return 0; } @@ -1968,7 +1968,7 @@ static int ravb_open(struct net_device *ndev) =20 /* Initialise PTP Clock driver */ if (info->ccc_gac) - ravb_ptp_init(ndev, priv->pdev); + ravb_ptp_init(ndev); =20 /* PHY control start */ error =3D ravb_phy_start(ndev); diff --git a/drivers/net/ethernet/renesas/ravb_ptp.c b/drivers/net/ethernet= /renesas/ravb_ptp.c index ac91a6813368..6817e94721b5 100644 --- a/drivers/net/ethernet/renesas/ravb_ptp.c +++ b/drivers/net/ethernet/renesas/ravb_ptp.c @@ -313,7 +313,7 @@ void ravb_ptp_interrupt(struct net_device *ndev) ravb_write(ndev, ~(gis | GIS_RESERVED), GIS); } =20 -void ravb_ptp_init(struct net_device *ndev, struct platform_device *pdev) +void ravb_ptp_init(struct net_device *ndev) { struct ravb_private *priv =3D netdev_priv(ndev); struct ptp_clock *clock; @@ -338,7 +338,7 @@ void ravb_ptp_init(struct net_device *ndev, struct plat= form_device *pdev) ravb_modify(ndev, GCCR, GCCR_TCSS, GCCR_TCSS_ADJGPTP); spin_unlock_irqrestore(&priv->lock, flags); =20 - clock =3D ptp_clock_register(&priv->ptp.info, &pdev->dev); + clock =3D ptp_clock_register(&priv->ptp.info, &priv->pdev->dev); if (IS_ERR(clock)) { netdev_err(ndev, "failed to register PTP clock: %pe\n", clock); clock =3D NULL; --=20 2.55.0 From nobody Fri Sep 25 21:02:57 2026 Received: from fout-b3-smtp.messagingengine.com (fout-b3-smtp.messagingengine.com [202.12.124.146]) (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 8E8104EFFD8; Mon, 21 Sep 2026 17:51:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013078; cv=none; b=P43uaVqXq1mnjpSY/SsegC61pSgrHP6tCrjb9wb3FojvnZMGk4VrGvXEkWqxtiiwIc5YGxPAqzp/kRBSjWUMmKyNPJ3qoSM5qkUd2zlUd+eo7+9v4hdEnFS2vyxN+u9QoQkG8W4A1gOXGzXz3shQ05TWrt/eXw3e7JLtz9d2aOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013078; c=relaxed/simple; bh=afRHI9FtEbxCLNKeHKo467KfMaY6RFbHTRoY1FFrJ5A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=r44irH5jWcXc6VGwtZyclU/4i7k7qis6xPQ613eaw8hhQ2EUGTrpGF98R5bDwwRObnDlTpk3UA0K77TcmBPdFxw7WIq3mQN5eJvZtXuyh4fxlFziQZHnCI3Vc8SvMyhI7x3WeV+8mekOkuXnv2JFasXCzzwpzzeaUipmxy8zpb0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=WB9+vVPx; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=MV104EVo; arc=none smtp.client-ip=202.12.124.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="WB9+vVPx"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="MV104EVo" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.stl.internal (Postfix) with ESMTP id 684401D000D6; Mon, 21 Sep 2026 13:51:15 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Mon, 21 Sep 2026 13:51:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1790013075; x=1790099475; bh=ibc1CId1Nm0nkVBYGtch82/IlWWe7XN6GaGSe3rG3FQ=; b= WB9+vVPxMAKRFyiQ5llOMkNzuCVNNhuCC3pHoMG0RAM9PN2BVLxjOy+mvZThT2zs Yxoen3f21Q60IDTKHfGPHSnrp1TQ7K9NneAP1XOX8CfzfEu7+VCzUfM5q9jO/FO6 6YwHj/NRzmXAYxF532THt7pVq0gOJ/O9Ss10+rloHSZ+tO3DQKyaCdSqorY1vS0K Bx0thVJV8Yejl8FH8ydrx+9oh3DDsO5p0bI5kCY8+Dutnqd6Y6aGaIKRdlidv3YD zll384EkeNzFurbFUxVWDW6GAaAhl7R2N53a7JrO4RwUXY/26jlujFjRcuBnIR+9 1oTKdj9L1t9fvAeccIb3nQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1790013075; x= 1790099475; bh=ibc1CId1Nm0nkVBYGtch82/IlWWe7XN6GaGSe3rG3FQ=; b=M V104EVo9EqhPbajuovpm6HGmOEteZgS3pPYaBGblE4qz06gX9+WlIlVaW70SJ+iJ X/oC+fdlFZT/HuoNFFMy5KET1AvcIqJodvGnwZc20k7mNGLoT/NxIgQDzmVkpquw A8nRdt/akGrVYWg+jhoeg8dm5mMSvDyc6PGsLc8J8WSEdL9KDejltFYtNIu80bin eqiVHxVzmhGYTLmdAStHolcxmkjLpgqv64+XFbOqKnJOc0LoRuqSWucmy5VS5t7R Iz2kGQWqCa6YPbwx2ypaXOA7MPEmjKVe2PouTV+NlEoqZ/4fyXBpjmkWx/6MWaie HHjvqsnRSAoRKDp8x70yQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGxueDU6ybJrp3DH63sos1//zx+SFUDv+Z0HmZd1kiJ7nzuFU0LghLhMGbNt8CtYt wt5HRnq8CzXv75RJbh41RmrgUsjkhBuSa7HsiS+BvOsgN2w1ECbKLiyF06hhLO/qiieiwC wkZKkiHKAYNIzrgCTqxZ7xQexBG+kgbIhc6BI6nKd8ZJJotjeCwEepYGWxT35kQ689BIZa NOiqgBNzAoMxfOrq/9EkB1onjknI4lCkOrel9/ympJ7mWhVbylSWekfBi0VyqfMViZEcZk gme1mTHDxRopPgczIQ18lr31i4s7n6F5NBqxwBc9Ufu8NPc84/QeYVPBiw/u91oS2vtklv beAf+X8nWUg0+r2jTwRUSUk2ild7xmQSw0ga2dyPXHbz6AnFSpa+XkCGumAcffURgoJOir HorPI2JO7gHoDrd9fdgsQRXpaLIezOAuMa+liDjW/4KnCSsIGH6xFl8yXJy/IR16mtImeL cggR5G0f/i355LetlOnO66j1JNMlvQfpsopIVP0jQG5ubaXIeWibWPmT1Rk/E/F6FrPg84 hPTFQLMvsO1P9MUa3w2WNn1g3eIwpfIf1Fz+TfDEfVFtCeQBpjUJjSLqd7vheEoczhbWqR jNuD4wbJYO3hSjQF4R6QHbvKynK38Ny6Ln2GMONiUdDH7zWN9fL9Uq6WYQew X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 21 Sep 2026 13:51:14 -0400 (EDT) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: paul@pbarker.dev, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Richard Cochran , Andrew Lunn , "DavidS. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vadim Fedorenko , Sergey Shtylyov , linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH net-next v5 05/10] net: ethernet: ravb: Propagate error from ptp_clock_register() Date: Mon, 21 Sep 2026 19:50:32 +0200 Message-ID: <20260921175037.4084310-6-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> References: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> 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: quoted-printable If the PTP clock registration failed the error is silently ignored. Before reworking all callers of ravb_ptp_init() handle and propagate the error so it can be used. Link: https://sashiko.dev/#/patchset/20260610102432.3538432-2-niklas.soderl= und+renesas@ragnatech.se?part=3D1 Signed-off-by: Niklas S=C3=B6derlund Reviewed-by: Sergey Shtylyov --- * Changes since v3 - Add check to keep sashiko happy, the remark is fixed already later in the series but to keep the bot happy. * Changes since v2 - Rework to remove the caching of phc_index added by LLM without access to hardware. * Changes since v1 - New in v2. --- drivers/net/ethernet/renesas/ravb.h | 3 +-- drivers/net/ethernet/renesas/ravb_main.c | 5 ++--- drivers/net/ethernet/renesas/ravb_ptp.c | 27 +++++++++++------------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/ren= esas/ravb.h index aa45f5466001..0c122a815840 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1028,7 +1028,6 @@ struct ravb_ptp_perout { struct ravb_ptp { struct ptp_clock *clock; struct ptp_clock_info info; - int phc_index; u32 default_addend; u32 current_addend; int extts[N_EXT_TS]; @@ -1163,7 +1162,7 @@ void ravb_modify(struct net_device *ndev, enum ravb_r= eg reg, u32 clear, int ravb_wait(struct net_device *ndev, enum ravb_reg reg, u32 mask, u32 va= lue); =20 void ravb_ptp_interrupt(struct net_device *ndev); -void ravb_ptp_init(struct net_device *ndev); +int ravb_ptp_init(struct net_device *ndev); void ravb_ptp_stop(struct net_device *ndev); =20 #endif /* #ifndef __RAVB_H__ */ diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index 1dfe905832a0..db3ef87f0991 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1774,7 +1774,7 @@ static int ravb_get_ts_info(struct net_device *ndev, struct ravb_private *priv =3D netdev_priv(ndev); const struct ravb_hw_info *hw_info =3D priv->info; =20 - if (hw_info->gptp || hw_info->ccc_gac) { + if (priv->ptp.clock && (hw_info->gptp || hw_info->ccc_gac)) { info->so_timestamping =3D SOF_TIMESTAMPING_TX_SOFTWARE | SOF_TIMESTAMPING_TX_HARDWARE | @@ -1785,7 +1785,7 @@ static int ravb_get_ts_info(struct net_device *ndev, (1 << HWTSTAMP_FILTER_NONE) | (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) | (1 << HWTSTAMP_FILTER_ALL); - info->phc_index =3D READ_ONCE(priv->ptp.phc_index); + info->phc_index =3D ptp_clock_index(priv->ptp.clock); } =20 return 0; @@ -2937,7 +2937,6 @@ static int ravb_probe(struct platform_device *pdev) priv->rstc =3D rstc; priv->ndev =3D ndev; priv->pdev =3D pdev; - priv->ptp.phc_index =3D -1; priv->num_tx_ring[RAVB_BE] =3D BE_TX_RING_SIZE; priv->num_rx_ring[RAVB_BE] =3D BE_RX_RING_SIZE; if (info->nc_queues) { diff --git a/drivers/net/ethernet/renesas/ravb_ptp.c b/drivers/net/ethernet= /renesas/ravb_ptp.c index 6817e94721b5..407ae97b76bb 100644 --- a/drivers/net/ethernet/renesas/ravb_ptp.c +++ b/drivers/net/ethernet/renesas/ravb_ptp.c @@ -313,11 +313,11 @@ void ravb_ptp_interrupt(struct net_device *ndev) ravb_write(ndev, ~(gis | GIS_RESERVED), GIS); } =20 -void ravb_ptp_init(struct net_device *ndev) +int ravb_ptp_init(struct net_device *ndev) { struct ravb_private *priv =3D netdev_priv(ndev); - struct ptp_clock *clock; unsigned long flags; + int ret =3D 0; =20 priv->ptp.info =3D ravb_ptp_info; =20 @@ -338,15 +338,14 @@ void ravb_ptp_init(struct net_device *ndev) ravb_modify(ndev, GCCR, GCCR_TCSS, GCCR_TCSS_ADJGPTP); spin_unlock_irqrestore(&priv->lock, flags); =20 - clock =3D ptp_clock_register(&priv->ptp.info, &priv->pdev->dev); - if (IS_ERR(clock)) { - netdev_err(ndev, "failed to register PTP clock: %pe\n", clock); - clock =3D NULL; + priv->ptp.clock =3D ptp_clock_register(&priv->ptp.info, &priv->pdev->dev); + if (IS_ERR(priv->ptp.clock)) { + ret =3D PTR_ERR(priv->ptp.clock); + priv->ptp.clock =3D NULL; + ravb_ptp_stop(ndev); } =20 - WRITE_ONCE(priv->ptp.clock, clock); - if (clock) - WRITE_ONCE(priv->ptp.phc_index, ptp_clock_index(clock)); + return ret; } =20 static void ravb_ptp_disable(struct net_device *ndev) @@ -369,14 +368,12 @@ static void ravb_ptp_sync_irqs(struct net_device *nde= v) void ravb_ptp_stop(struct net_device *ndev) { struct ravb_private *priv =3D netdev_priv(ndev); - struct ptp_clock *clock; - - WRITE_ONCE(priv->ptp.phc_index, -1); - clock =3D xchg(&priv->ptp.clock, NULL); =20 ravb_ptp_disable(ndev); ravb_ptp_sync_irqs(ndev); =20 - if (clock) - ptp_clock_unregister(clock); + if (priv->ptp.clock) { + ptp_clock_unregister(priv->ptp.clock); + priv->ptp.clock =3D NULL; + } } --=20 2.55.0 From nobody Fri Sep 25 21:02:57 2026 Received: from fhigh-b5-smtp.messagingengine.com (fhigh-b5-smtp.messagingengine.com [202.12.124.156]) (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 C01204F30D9; Mon, 21 Sep 2026 17:51:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013081; cv=none; b=EtE2DZIUKks2JFTVbUVjgisA8IrYpGSP6FED3CjtGXHF69KtPb5H0tGRC/oyTF6uGQ7F4xvNBhVo5xV13ngGuRbMQFIfe+LK/A4otrKGIN1NN4sjGl64nder4gK7OTbKWfDJ6c82WBcgIUOmpCqJ66wkhdUtVNbEPKmny98yNoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013081; c=relaxed/simple; bh=6EeNiIB/cWlzlYzv3WRadrrHMUqyPhqeFZm7gxBhrFc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uu0LVsxsq9EgEXVjmHljxtzozWt7VhdZTxA9qSuq4DFsD8ZgiE3UUkB+HbpvqVw/t3zkZgkiwRrpB+mrPBvo5k7i2JK97nMUUHobQ/0LhPUqnpCaIFxZ5By325f4IveCd82yuTQFSaZFDWfbISB//f+V0M6njRvsnTh6E0M9dfQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=KHqhkqcI; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=BmTfoa0i; arc=none smtp.client-ip=202.12.124.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="KHqhkqcI"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="BmTfoa0i" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfhigh.stl.internal (Postfix) with ESMTP id 862EB7A00C2; Mon, 21 Sep 2026 13:51:18 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Mon, 21 Sep 2026 13:51:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1790013078; x=1790099478; bh=jBtMlQMWcvBYE/2p3rhF3jRLyp1sF7Jm5ovtkkdH9wE=; b= KHqhkqcI3q4rTLJbjS5arvUy913sQfD3WZE6nvOAvUfYDl0MKvFON+2i7c/Yjb98 0ukVTzkSgwPlr3N90rmp73lMGkvAKIYMSHidH++S7zTl1W7zuu12ikNDwgyjwAjf sSk+SAtUP7mCCShEsyrh4bLSX0tgBJOW10PDOjPxsp96GnrrOPPQFodzSHSYMBQ4 zK0T/DdX9AWiyF24PcDmqZXjjnOuwR5hMGCM0ErWpluv8+oSgHaIyUbrQ1GG4g2j +phWdDfnrmI9ym67ccjAGnqw4gBMe6/bnzFwwgCR0pohcz+syZ32EZfKSmZt0w3Z Hza4tNtH6g+FHSpU63imdQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1790013078; x= 1790099478; bh=jBtMlQMWcvBYE/2p3rhF3jRLyp1sF7Jm5ovtkkdH9wE=; b=B mTfoa0it0+kIcTHequ99G/sV3pMf2B2ZERSuyFKQjxmOsMi/zObrqkoKbTsaNLiz 0Gov2ruKdi4TcQE1f4s3SrfWEnRn+e//wG5u6N9ReADdFeI7w0IoXNEdrNXAx58L RILYcsvSXexyG5Zdkx9ITCj8dAf2s69hyWX3MxvbeuIlowmU/wzJ5T+zfUR01P16 D3Wzus4nVtmlBHf8ZcXNdPFPqaB2sQZdYALBb1duFYakzUgq/IgExJgINI3MOlBx DdqEl3hGLk1jy5Sa2qlWUOIJ3wjuDMSaMEDVgWTEdyEOXV7YC5j9msmdq0RnGBVc CVsjuwKog77VMzE2TEkPw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFKyuwNHokJCgIndgtoOusqu1/6uPi/0uzv51oOMJoBVzbBuuQBERlY9Rv3NvmA6T d/CD1lxyU3UgPnEeJyPNbZpf+4OQPJ3AbFbyzvtJqzJyhSU0WyRw2N3jkO5MC6tTob5H+B TCxu9EekrWCaHBw+6MstQGy681MV+L5ictmDPIp7n4+FYelCRH1YJ2M1xfPZF1CqF0smxw c4JIURjRlH1wsfm+CyMKRUhHTOncPDoh9a2aZMLd+DzObP2w66sKePqFvy/aIxy5vDMgrD fRXTZksUaWctOWTnUr66Aqn0xuMYZyKstCQR4Y6Vusob1m7Y0ettnqm2yu1mZb4HnTRWRn XSPBDV8rmEP2oG74r/s6E+nduI4BqSlXJAURNGtP0WI5vsMx+ewJD5MyGgCif7zkC/8G64 jwy9JTpJH4v1Whbk5MP0SFOnDxT2hVwJdZyUcea2x2bTMFPZuwX8/hhjzrlWNfZk+s4Z8v JaCMpEWvJuuwmAT8jhWSxEBLogPZby4LYePk3XRToaORzv0Gz/NSH7ow/9rmq9b9tZx/t4 UUS+aar+RDMRux5ZvjjVcc5C+usSkXclfTg8E2xj/40ajvBCYSUCb4EcxD+wN8vbcrG5+R kx4Z+CmFSG6/vfDDxQ44y8eFCEDeOrzjbMQw9Av95eqd721e7ephMhBVG63Q X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 21 Sep 2026 13:51:17 -0400 (EDT) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: paul@pbarker.dev, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Richard Cochran , Andrew Lunn , "DavidS. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vadim Fedorenko , Sergey Shtylyov , linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH net-next v5 06/10] net: ethernet: ravb: Replace gPTP flags with callbacks Date: Mon, 21 Sep 2026 19:50:33 +0200 Message-ID: <20260921175037.4084310-7-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> References: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> 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: quoted-printable Prepare for adding Gen4 support which will add a third and new way to interact with the gPTP clock by replacing the flags for Gen2 behavior (info->gptp) and Gen3 behavior (info->ccc_gac) with callbacks. This will make adding Gen4 support cleaner as the code will not have "if else if else" sprinkled all over to handle each generations special cases. Signed-off-by: Niklas S=C3=B6derlund Reviewed-by: Sergey Shtylyov --- * Changes since v1 - Handle error from starting the PTP clock. --- drivers/net/ethernet/renesas/ravb.h | 24 ++++++- drivers/net/ethernet/renesas/ravb_main.c | 87 +++++++++++++++--------- 2 files changed, 78 insertions(+), 33 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/ren= esas/ravb.h index 0c122a815840..6603f90b19e1 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1034,6 +1034,27 @@ struct ravb_ptp { struct ravb_ptp_perout perout[N_PER_OUT]; }; =20 +/** + * struct ravb_gptp_info - Platform specific gPTP behavior + * + * Each generation of RAVB have slightly different behaviors when interact= ing + * with the gPTP clock. This struct provides the callbacks to be called at + * critical points in the RAVB driver. + * + * @set_config_mode: Enter config mode + * @dmac_start: Called when the DMAC starts + * @dmac_stop: Called when the DMAC stops + * @ndev_open: Called when the ndev is opened + * @ndev_close: Called when the ndev is closed + */ +struct ravb_gptp_info { + int (*set_config_mode)(struct net_device *ndev); + int (*dmac_start)(struct net_device *ndev); + void (*dmac_stop)(struct net_device *ndev); + int (*ndev_open)(struct net_device *ndev); + void (*ndev_close)(struct net_device *ndev); +}; + struct ravb_hw_info { int (*receive)(struct net_device *ndev, int budget, int q); void (*set_rate)(struct net_device *ndev); @@ -1052,6 +1073,7 @@ struct ravb_hw_info { u32 rx_buffer_size; u32 rx_desc_size; u32 dbat_entry_num; + const struct ravb_gptp_info *ptp; /* Callbacks to handle gPTP interaction= s. */ unsigned aligned_tx: 1; unsigned coalesce_irqs:1; /* Needs software IRQ coalescing */ =20 @@ -1062,8 +1084,6 @@ struct ravb_hw_info { unsigned multi_irqs:1; /* AVB-DMAC and E-MAC has multiple irqs */ unsigned irq_en_dis:1; /* Has separate irq enable and disable regs */ unsigned err_mgmt_irqs:1; /* Line1 (Err) and Line2 (Mgmt) irqs are separa= te */ - unsigned gptp:1; /* AVB-DMAC has gPTP support */ - unsigned ccc_gac:1; /* AVB-DMAC has gPTP support active in config mode */ unsigned gptp_ref_clk:1; /* gPTP has separate reference clock */ unsigned nc_queues:1; /* AVB-DMAC has RX and TX NC queues */ unsigned magic_pkt:1; /* E-MAC supports magic packet detection */ diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index db3ef87f0991..b558e9f5611e 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -712,8 +712,8 @@ static int ravb_dmac_init(struct net_device *ndev) return error; =20 /* Initialise PTP Clock driver */ - if (info->gptp) - ravb_ptp_init(ndev); + if (info->ptp && info->ptp->dmac_start) + return info->ptp->dmac_start(ndev); =20 return 0; } @@ -1124,8 +1124,8 @@ static int ravb_stop_dma(struct net_device *ndev) } =20 /* Stop PTP Clock driver */ - if (info->gptp) - ravb_ptp_stop(ndev); + if (info->ptp && info->ptp->dmac_stop) + info->ptp->dmac_stop(ndev); =20 /* Stop AVB-DMAC process */ return ravb_set_opmode(ndev, CCC_OPC_CONFIG); @@ -1774,7 +1774,7 @@ static int ravb_get_ts_info(struct net_device *ndev, struct ravb_private *priv =3D netdev_priv(ndev); const struct ravb_hw_info *hw_info =3D priv->info; =20 - if (priv->ptp.clock && (hw_info->gptp || hw_info->ccc_gac)) { + if (priv->ptp.clock && hw_info->ptp) { info->so_timestamping =3D SOF_TIMESTAMPING_TX_SOFTWARE | SOF_TIMESTAMPING_TX_HARDWARE | @@ -1835,21 +1835,11 @@ static int ravb_set_config_mode(struct net_device *= ndev) { struct ravb_private *priv =3D netdev_priv(ndev); const struct ravb_hw_info *info =3D priv->info; - int error; =20 - if (info->gptp) { - error =3D ravb_set_opmode(ndev, CCC_OPC_CONFIG); - if (error) - return error; - /* Set CSEL value */ - ravb_modify(ndev, CCC, CCC_CSEL, CCC_CSEL_HPB); - } else if (info->ccc_gac) { - error =3D ravb_set_opmode(ndev, CCC_OPC_CONFIG | CCC_GAC | CCC_CSEL_HPB); - } else { - error =3D ravb_set_opmode(ndev, CCC_OPC_CONFIG); - } + if (info->ptp && info->ptp->set_config_mode) + return info->ptp->set_config_mode(ndev); =20 - return error; + return ravb_set_opmode(ndev, CCC_OPC_CONFIG); } =20 static int ravb_compute_gti(struct net_device *ndev) @@ -1860,7 +1850,7 @@ static int ravb_compute_gti(struct net_device *ndev) unsigned long rate; u64 inc; =20 - if (!(info->gptp || info->ccc_gac)) + if (!info->ptp) return 0; =20 if (info->gptp_ref_clk) @@ -1967,8 +1957,11 @@ static int ravb_open(struct net_device *ndev) ravb_emac_init(ndev); =20 /* Initialise PTP Clock driver */ - if (info->ccc_gac) - ravb_ptp_init(ndev); + if (info->ptp && info->ptp->ndev_open) { + error =3D info->ptp->ndev_open(ndev); + if (error) + goto out_ptp_stop; + } =20 /* PHY control start */ error =3D ravb_phy_start(ndev); @@ -1981,8 +1974,8 @@ static int ravb_open(struct net_device *ndev) =20 out_ptp_stop: /* Stop PTP Clock driver */ - if (info->ccc_gac) - ravb_ptp_stop(ndev); + if (info->ptp && info->ptp->ndev_close) + info->ptp->ndev_close(ndev); ravb_stop_dma(ndev); out_set_reset: ravb_set_opmode(ndev, CCC_OPC_RESET); @@ -2190,7 +2183,7 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *sk= b, struct net_device *ndev) desc->dptr =3D cpu_to_le32(dma_addr); =20 /* TX timestamp required */ - if (info->gptp || info->ccc_gac) { + if (info->ptp) { if (q =3D=3D RAVB_NC) { ts_skb =3D kmalloc_obj(*ts_skb, GFP_ATOMIC); if (!ts_skb) { @@ -2372,8 +2365,8 @@ static int ravb_close(struct net_device *ndev) } =20 /* Stop PTP Clock driver */ - if (info->ccc_gac) - ravb_ptp_stop(ndev); + if (info->ptp && info->ptp->ndev_close) + info->ptp->ndev_close(ndev); =20 /* Set the config mode to stop the AVB-DMAC's processes */ if (ravb_stop_dma(ndev) < 0) @@ -2381,7 +2374,7 @@ static int ravb_close(struct net_device *ndev) "device will be stopped after h/w processes are done.\n"); =20 /* Clear the timestamp list */ - if (info->gptp || info->ccc_gac) { + if (info->ptp) { list_for_each_entry_safe(ts_skb, ts_skb2, &priv->ts_skb_list, list) { list_del(&ts_skb->list); kfree_skb(ts_skb->skb); @@ -2663,6 +2656,26 @@ static int ravb_mdio_release(struct ravb_private *pr= iv) return 0; } =20 +static int ravb_gen2_ptp_set_config_mode(struct net_device *ndev) +{ + int ret; + + ret =3D ravb_set_opmode(ndev, CCC_OPC_CONFIG); + if (ret) + return ret; + + /* gPTP Clock Select High-speed peripheral bus clock. */ + ravb_modify(ndev, CCC, CCC_CSEL, CCC_CSEL_HPB); + + return 0; +} + +static const struct ravb_gptp_info ravb_gen2_ptp_info =3D { + .set_config_mode =3D ravb_gen2_ptp_set_config_mode, + .dmac_start =3D ravb_ptp_init, + .dmac_stop =3D ravb_ptp_stop, +}; + static const struct ravb_hw_info ravb_gen2_hw_info =3D { .receive =3D ravb_rx_rcar, .set_rate =3D ravb_set_rate_rcar, @@ -2681,12 +2694,24 @@ static const struct ravb_hw_info ravb_gen2_hw_info = =3D { SKB_DATA_ALIGN(sizeof(struct skb_shared_info)), .rx_desc_size =3D sizeof(struct ravb_ex_rx_desc), .dbat_entry_num =3D 22, + .ptp =3D &ravb_gen2_ptp_info, .aligned_tx =3D 1, - .gptp =3D 1, .nc_queues =3D 1, .magic_pkt =3D 1, }; =20 +static int ravb_gen3_ptp_set_config_mode(struct net_device *ndev) +{ + /* Enable gPTP Clock and Select High-speed peripheral bus clock. */ + return ravb_set_opmode(ndev, CCC_OPC_CONFIG | CCC_GAC | CCC_CSEL_HPB); +} + +static const struct ravb_gptp_info ravb_gen3_ptp_info =3D { + .set_config_mode =3D ravb_gen3_ptp_set_config_mode, + .ndev_open =3D ravb_ptp_init, + .ndev_close =3D ravb_ptp_stop, +}; + static const struct ravb_hw_info ravb_gen3_hw_info =3D { .receive =3D ravb_rx_rcar, .set_rate =3D ravb_set_rate_rcar, @@ -2705,11 +2730,11 @@ static const struct ravb_hw_info ravb_gen3_hw_info = =3D { SKB_DATA_ALIGN(sizeof(struct skb_shared_info)), .rx_desc_size =3D sizeof(struct ravb_ex_rx_desc), .dbat_entry_num =3D 22, + .ptp =3D &ravb_gen3_ptp_info, .internal_delay =3D 1, .tx_counters =3D 1, .multi_irqs =3D 1, .irq_en_dis =3D 1, - .ccc_gac =3D 1, .nc_queues =3D 1, .magic_pkt =3D 1, }; @@ -2736,7 +2761,7 @@ static const struct ravb_hw_info ravb_gen4_hw_info = =3D { .tx_counters =3D 1, .multi_irqs =3D 1, .irq_en_dis =3D 1, - .ccc_gac =3D 1, + .ptp =3D &ravb_gen3_ptp_info, .nc_queues =3D 1, .magic_pkt =3D 1, }; @@ -2761,7 +2786,7 @@ static const struct ravb_hw_info ravb_rzv2m_hw_info = =3D { .dbat_entry_num =3D 22, .multi_irqs =3D 1, .err_mgmt_irqs =3D 1, - .gptp =3D 1, + .ptp =3D &ravb_gen2_ptp_info, .gptp_ref_clk =3D 1, .nc_queues =3D 1, .magic_pkt =3D 1, --=20 2.55.0 From nobody Fri Sep 25 21:02:57 2026 Received: from fhigh-b5-smtp.messagingengine.com (fhigh-b5-smtp.messagingengine.com [202.12.124.156]) (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 2E35042CB08; Mon, 21 Sep 2026 17:51:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013085; cv=none; b=IUGZP6oMirF6/Wsv0OwURCTf2VrRKbK9zxYq5+jSNpbh14FXTNcESnN4AbB3ZDxcuFZIK34qJRkDjhupO5qgeBBhTmZEKv3PQ5IT6Yk0LRgD0pXtE0x7E3UE4VHVJSFtKaldMi2sFlrgkuaxwRxQEsEeYfOTT6EKUkbRK/WFKDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013085; c=relaxed/simple; bh=AmOxELWrLpRNOOEvuK76rWVP0rdipn8VwhP888W6Ndc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aN1WuOhRzeUfjdAKPZ8PYjZmGF3AJ8UN2lf9sWZAM10SW+YEL8vDNaQ3uJJxUsyPjHtTmHFooh/cqfi5xfoLIZ1rdh0HJfsMGZ0uUwldhXhM8kAwiQ8ZFV+XGeTUcbwzMXLRj+jHY/VdFiChOccZLMCnMTXoRu7/SjpzUfFYn7Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=DKz9ELD5; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=MuR0zDE6; arc=none smtp.client-ip=202.12.124.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="DKz9ELD5"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="MuR0zDE6" Received: from phl-compute-07.internal (phl-compute-07.internal [10.202.2.47]) by mailfhigh.stl.internal (Postfix) with ESMTP id B52BF7A010D; Mon, 21 Sep 2026 13:51:21 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-07.internal (MEProxy); Mon, 21 Sep 2026 13:51:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1790013081; x=1790099481; bh=zlZFTCaCBi4pH01alg4KYleEqNE5ncM5Y8ZIm694iK8=; b= DKz9ELD5kfEXegnLqnQrBk7ZQpF/+n2Q1ahs8f7mjW91fJfZHf3GGi+Ymaj5vK4x KO8rSPZf59fMhjY5MBey+SBpT94WTWuaWLIdZOhub0oM8v9f/zWzCVNv3twOWnsQ PrpXFd4v6UEyQhGCbCb2CromLF2N5A6F3Dr3QooFbVF/G405ISl1MoYWGQZwzMzU EVdEBbOR7uHOSNi7xo5DGLRPVYyi6uqS/0OWZXSdaFRWJ+SFA8ZCoGJQJdGLdMhW Fzgcf4DjEBLncOxeT6romdYJdCtu6l8fnjZlWH1JNs/cNMI0HYl2zlCqGUQ6iO4+ yCvkT232+bZ74x8oLkdrmA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1790013081; x= 1790099481; bh=zlZFTCaCBi4pH01alg4KYleEqNE5ncM5Y8ZIm694iK8=; b=M uR0zDE6A2nkPdJ6LzSr/9l8eLaLzrLtvpsHhTrOKOuWKoL2gHeXgeuz13ZIhL/mq RMt/US4vKhjHCucEmCcfPezaFPHluh9brj2qo4fSpaPODK2jG9JgJgO0DZt9+N8h 3603ItUteKvT0Rsfitt4yJN8/h8lfu7c+pbNOflYl8Ai4Wu4FKbDWDzdMMyM0OV4 VkSaZG3aC3ffkNt1V5wkjIiw5YSWrgnpKdJII2RiSwbjbWzEr3f7rZjRg1zLCiT7 t0Adqv8VNY93Q5SdpMDcZwlpvERZd0PbiUpirAAiHWCcjDoxru80YljB8faW8b3U rlwnEhfa3JDcHmjAL9Kpg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTERb8iWuOaCoZl7Bdy7ms8LtfxU+xjK78I80yyQZdvSwOOOfv5Eh589Pe9RlM06WU dDnU8HOY0XEZCSLotd4wkziCSyOMbfYp7QQMcpxqxHGnE0sN+h/hwRsMQX/TPzjkM+eutR EyTNwAM1tWMwrq7QvnP58hqr16hBRsM/xWQjxvzbUj3rLPulCyCubKGS8/OfnPdml28WZP 11HBM2ETQKxQIL8VV/A/GNA6vlfx97xrmJ0/jihnD6jQBVLDZo9wvlSWgasgNowAQLofbi uJp5/Pi8DlT51OEeXr8hn2lIL64WOU6L6jZxXkbUv9MeKffjxF51gA/7UnWz5uX+sq6JQ2 3KgReaCK0ECM7CI/ZwVV0nm/nHR05ce5xFEtvEdXyKkMbgW2zNZ7ywqbG7LqCU3/3Qb5JM 1ba3ZNdMFI/FIU+VrVTQIAnkN8viqaARtDSjHyIUgKPwqbBknCimaRbUbApl/XxYrcjkih 97nEfmOQClGDu6DZ2+w9RmmuRgedKMYxIziBYBzp4eSXo4RsneTeSvhev8TRT+7I+JU1CD lNKlFa9S29HC5G/XIRYhHfRnhIKw57YwLNfE3N1Pi5w7raHt0/y7LqrTx7G1HzRNk2sNTw p2zS7Q+ruVAZc+uySkRSSNUIQlmgPb5slXMfADTtc8lRsu08Vm7Hr0E7PfxA X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 21 Sep 2026 13:51:20 -0400 (EDT) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: paul@pbarker.dev, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Richard Cochran , Andrew Lunn , "DavidS. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vadim Fedorenko , Sergey Shtylyov , linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH net-next v5 07/10] net: ethernet: ravb: Add callback for gPTP probe Date: Mon, 21 Sep 2026 19:50:34 +0200 Message-ID: <20260921175037.4084310-8-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> References: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> 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: quoted-printable Different generations of the RAVB IP have different needs when it probes the gPTP timer clock. Add a callback in the PTP information to allow each generation to probe its own way. With this the last gPTP specific flag (gptp_ref_clk) can be removed. However the primary motivation for the change is to prepare for Gen4 support, which compared to other generations with gPTP support does not have the clock as part of the IP itself. Gen4 will not need to compute GTI value as it have nowhere to write it, as the gPTP clock is external. For this reason move the computation of it into the newly gPTP probe specific callbacks for the RAVB IP's that support it. Signed-off-by: Niklas S=C3=B6derlund Reviewed-by: Sergey Shtylyov --- * Changes since v1 - Improve spelling in commit message. --- drivers/net/ethernet/renesas/ravb.h | 3 +- drivers/net/ethernet/renesas/ravb_main.c | 53 +++++++++++++++--------- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/ren= esas/ravb.h index 6603f90b19e1..b788e8f5260d 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1041,6 +1041,7 @@ struct ravb_ptp { * with the gPTP clock. This struct provides the callbacks to be called at * critical points in the RAVB driver. * + * @probe: Probe the gPTP clock * @set_config_mode: Enter config mode * @dmac_start: Called when the DMAC starts * @dmac_stop: Called when the DMAC stops @@ -1048,6 +1049,7 @@ struct ravb_ptp { * @ndev_close: Called when the ndev is closed */ struct ravb_gptp_info { + int (*probe)(struct net_device *ndev); int (*set_config_mode)(struct net_device *ndev); int (*dmac_start)(struct net_device *ndev); void (*dmac_stop)(struct net_device *ndev); @@ -1084,7 +1086,6 @@ struct ravb_hw_info { unsigned multi_irqs:1; /* AVB-DMAC and E-MAC has multiple irqs */ unsigned irq_en_dis:1; /* Has separate irq enable and disable regs */ unsigned err_mgmt_irqs:1; /* Line1 (Err) and Line2 (Mgmt) irqs are separa= te */ - unsigned gptp_ref_clk:1; /* gPTP has separate reference clock */ unsigned nc_queues:1; /* AVB-DMAC has RX and TX NC queues */ unsigned magic_pkt:1; /* E-MAC supports magic packet detection */ unsigned half_duplex:1; /* E-MAC supports half duplex mode */ diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index b558e9f5611e..77e66a9870ab 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1842,21 +1842,14 @@ static int ravb_set_config_mode(struct net_device *= ndev) return ravb_set_opmode(ndev, CCC_OPC_CONFIG); } =20 -static int ravb_compute_gti(struct net_device *ndev) +static int ravb_compute_gti(struct net_device *ndev, struct clk *clk) { struct ravb_private *priv =3D netdev_priv(ndev); - const struct ravb_hw_info *info =3D priv->info; struct device *dev =3D ndev->dev.parent; unsigned long rate; u64 inc; =20 - if (!info->ptp) - return 0; - - if (info->gptp_ref_clk) - rate =3D clk_get_rate(priv->gptp_clk); - else - rate =3D clk_get_rate(priv->clk); + rate =3D clk_get_rate(clk); if (!rate) return -EINVAL; =20 @@ -2656,6 +2649,13 @@ static int ravb_mdio_release(struct ravb_private *pr= iv) return 0; } =20 +static int ravb_gen2_ptp_probe(struct net_device *ndev) +{ + struct ravb_private *priv =3D netdev_priv(ndev); + + return ravb_compute_gti(ndev, priv->clk); +} + static int ravb_gen2_ptp_set_config_mode(struct net_device *ndev) { int ret; @@ -2671,6 +2671,7 @@ static int ravb_gen2_ptp_set_config_mode(struct net_d= evice *ndev) } =20 static const struct ravb_gptp_info ravb_gen2_ptp_info =3D { + .probe =3D ravb_gen2_ptp_probe, .set_config_mode =3D ravb_gen2_ptp_set_config_mode, .dmac_start =3D ravb_ptp_init, .dmac_stop =3D ravb_ptp_stop, @@ -2707,6 +2708,7 @@ static int ravb_gen3_ptp_set_config_mode(struct net_d= evice *ndev) } =20 static const struct ravb_gptp_info ravb_gen3_ptp_info =3D { + .probe =3D ravb_gen2_ptp_probe, .set_config_mode =3D ravb_gen3_ptp_set_config_mode, .ndev_open =3D ravb_ptp_init, .ndev_close =3D ravb_ptp_stop, @@ -2766,6 +2768,24 @@ static const struct ravb_hw_info ravb_gen4_hw_info = =3D { .magic_pkt =3D 1, }; =20 +static int ravb_rzv2m_ptp_probe(struct net_device *ndev) +{ + struct ravb_private *priv =3D netdev_priv(ndev); + + priv->gptp_clk =3D devm_clk_get(&priv->pdev->dev, "gptp"); + if (IS_ERR(priv->gptp_clk)) + return PTR_ERR(priv->gptp_clk); + + return ravb_compute_gti(ndev, priv->gptp_clk); +} + +static const struct ravb_gptp_info ravb_rzv2m_ptp_info =3D { + .probe =3D ravb_rzv2m_ptp_probe, + .set_config_mode =3D ravb_gen2_ptp_set_config_mode, + .dmac_start =3D ravb_ptp_init, + .dmac_stop =3D ravb_ptp_stop, +}; + static const struct ravb_hw_info ravb_rzv2m_hw_info =3D { .receive =3D ravb_rx_rcar, .set_rate =3D ravb_set_rate_rcar, @@ -2786,8 +2806,7 @@ static const struct ravb_hw_info ravb_rzv2m_hw_info = =3D { .dbat_entry_num =3D 22, .multi_irqs =3D 1, .err_mgmt_irqs =3D 1, - .ptp =3D &ravb_gen2_ptp_info, - .gptp_ref_clk =3D 1, + .ptp =3D &ravb_rzv2m_ptp_info, .nc_queues =3D 1, .magic_pkt =3D 1, }; @@ -2979,12 +2998,10 @@ static int ravb_probe(struct platform_device *pdev) goto out_reset_assert; } =20 - if (info->gptp_ref_clk) { - priv->gptp_clk =3D devm_clk_get(&pdev->dev, "gptp"); - if (IS_ERR(priv->gptp_clk)) { - error =3D PTR_ERR(priv->gptp_clk); + if (info->ptp && info->ptp->probe) { + error =3D info->ptp->probe(ndev); + if (error) goto out_reset_assert; - } } =20 priv->refclk =3D devm_clk_get_optional(&pdev->dev, "refclk"); @@ -3037,10 +3054,6 @@ static int ravb_probe(struct platform_device *pdev) ndev->netdev_ops =3D &ravb_netdev_ops; ndev->ethtool_ops =3D &ravb_ethtool_ops; =20 - error =3D ravb_compute_gti(ndev); - if (error) - goto out_rpm_put; - ravb_parse_delay_mode(np, ndev); =20 /* Allocate descriptor base address table */ --=20 2.55.0 From nobody Fri Sep 25 21:02:57 2026 Received: from fhigh-b5-smtp.messagingengine.com (fhigh-b5-smtp.messagingengine.com [202.12.124.156]) (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 EE7AC4F7CAB; Mon, 21 Sep 2026 17:51:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013088; cv=none; b=KJlM0IjPtDHLF8wkYs7uKdlwu/mvoK0StEzF6/zyh+joMtaJ9wJrhi2bBDw1EaK3ZkRWLeGSxkWWuEC/7ihEOJLN4JNqGlaulPmDgRDzLc/tBQLSZ5mNYmi4e4EiQI6KCvnm88q/sze05gr7xw2A/3schrGLJk2onpY7T4PMoBU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013088; c=relaxed/simple; bh=oAQT8va7y41DUuDdgvbf6NvxjRN2XamC1NCFHyjCBtw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=s0cQnQjRQbZom6pmHVRf0DP//sCOllaCsuJQQfmN4jbWSsqDUE5vpn/UKMt0Hzwwxz47jps6dwnAx/l5CBFQ9IQ62k46z5HWjWCz9w4aAGoFiwBHV3B+VC7scCQCpfBEn6KT3XP6YeQ1BcGIgbV4MyaqJVgjNc4A5No2pDFJuuE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=SpK7a1wQ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=R3vDzsNm; arc=none smtp.client-ip=202.12.124.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="SpK7a1wQ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="R3vDzsNm" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id C2FF67A00BA; Mon, 21 Sep 2026 13:51:24 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Mon, 21 Sep 2026 13:51:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1790013084; x=1790099484; bh=DzbstqLUQPRmED+g/cWawWvIDYgeFfAxDbES9Q2/vwA=; b= SpK7a1wQehCLZSlUcTZpJydsvmGhfxY23hBbQBvqsVJjPX6OH5JR/h+LrVzijyQh lxi0xzoKn3NXxf8RsnkDcu5PhZUHR1yOrw2nUtFWUVBlrmXZirXeQk1sA9XxC2dI DFH7mn4BTgpc2JXJGmNfNsGPIglSK4c5QZf58Iu+n9R+km9xgCenwIf/HaN+fwUa lYdvPEXWSLREQTKTCrFH04YwETt/5EbVCukwxq5BSsETwzZWt+u3ViWByZ3Jj5Dt fGDXLCAhWfdncOwPwgVvtqhiyBT+mO45J7/mXNazMU3gabxso0nspSpwy1AfALPc EzTmwrcBl6NEPKG73uRb+g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1790013084; x= 1790099484; bh=DzbstqLUQPRmED+g/cWawWvIDYgeFfAxDbES9Q2/vwA=; b=R 3vDzsNmk1LveMsSukKOJ65Kp4253jPbaPGAK4PA7+sQQbtiHzqM7gSL4y97U/4Y1 ygd7kT/gM3QeUc6Ey0TzlildfGYP6tKJL/H6sCEU8n73QzGBx3eVAvo+TaLQUGlY dnEtyhmUN/nlySmgoCuleco2LXH2L3A0MI1nt07G2WlKEJ5fMlL4XVW7ugchJJa5 biPiBsKBb4iawStT9UWLin4m7oTyoPxf/FflToyb/hR7iB7v74P65Fr3gK3t5cQc sw+bggSS/plLm9Pt9r4YhkrpOjs7lc2XDTmjmpnGIyDP+EIKHJElwFiSNTqXxI25 NjnDyMb65aiuOA74F55zA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTERb8iWuOaCoZl7Bdy7ms8LtfxU+xjK78I80yyQZdvSwOOOfv5Eh589Pe9RlM06WU dDnU8HOY0XEZCSLotd4wkziCSyOMbfYp7QQMcpxqxHGnE0sN+h/hwRsMQX/TPzjkM+eutR EyTNwAM1tWMwrq7QvnP58hqr16hBRsM/xWQjxvzbUj3rLPulCyCubKGS8/OfnPdml28WZP 11HBM2ETQKxQIL8VV/A/GNA6vlfx97xrmJ0/jihnD6jQBVLDZo9wvlSWgasgNowAQLofbi uJp5/Pi8DlT51OEeXr8hn2lIL64WOU6L6jZxXkbUv9MeKffjxF51gA/7UnWz5uX+sq6JVv wbIRVVyqxihrRHw8l4GwzpytQ2JTjeIc1bVT3Mo1CWrPQotlQEYeGLrkaf44MlmBXcpn2b CX9PtPS1YV2maSE+mAjQW64jN7PZEYL6YX5/uZ7xjJMhuCqHoY9MlE7OlD8mT10NB7ZJ2q web9q4IoUXCSysmYKoZ/0Llw2cvdB7vNNdZAE+4iE6koPmhX2M5b0TOw3BAdXjICG2l0zw w7DzZgIZmuAF+HrFVevIHGcvPzGQExDRkoibDMGzkU81+Y/WnXTvKuq7/KUimf/BvOR292 EN3OEFK23lIWiNVxDPnxv5PaMpzbjFPqeCrDWSrG2xF6H6Eunpxk0mqqr51w X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 21 Sep 2026 13:51:23 -0400 (EDT) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: paul@pbarker.dev, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Richard Cochran , Andrew Lunn , "DavidS. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vadim Fedorenko , Sergey Shtylyov , linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH net-next v5 08/10] net: ethernet: ravb: Add callback for gPTP clock index Date: Mon, 21 Sep 2026 19:50:35 +0200 Message-ID: <20260921175037.4084310-9-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> References: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> 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: quoted-printable Prepare for adding Gen4 support which have an optional external gPTP clock. Add a callback to get the clock index and use it to determine if the device shall report gPTP support. Signed-off-by: Niklas S=C3=B6derlund Reviewed-by: Sergey Shtylyov --- * Changes since v3 - Add check to feed sashiko. --- drivers/net/ethernet/renesas/ravb.h | 2 ++ drivers/net/ethernet/renesas/ravb_main.c | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/ren= esas/ravb.h index b788e8f5260d..27e2b31955ba 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1042,6 +1042,7 @@ struct ravb_ptp { * critical points in the RAVB driver. * * @probe: Probe the gPTP clock + * @clock_index: Get the PTP clock index, if any * @set_config_mode: Enter config mode * @dmac_start: Called when the DMAC starts * @dmac_stop: Called when the DMAC stops @@ -1050,6 +1051,7 @@ struct ravb_ptp { */ struct ravb_gptp_info { int (*probe)(struct net_device *ndev); + int (*clock_index)(struct net_device *ndev); int (*set_config_mode)(struct net_device *ndev); int (*dmac_start)(struct net_device *ndev); void (*dmac_stop)(struct net_device *ndev); diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index 77e66a9870ab..2dff47c2a125 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1773,8 +1773,13 @@ static int ravb_get_ts_info(struct net_device *ndev, { struct ravb_private *priv =3D netdev_priv(ndev); const struct ravb_hw_info *hw_info =3D priv->info; + int index =3D -1; =20 - if (priv->ptp.clock && hw_info->ptp) { + if (hw_info->ptp && hw_info->ptp->clock_index) + index =3D hw_info->ptp->clock_index(ndev); + + /* Only advertise ptp clock if present. */ + if (index >=3D 0) { info->so_timestamping =3D SOF_TIMESTAMPING_TX_SOFTWARE | SOF_TIMESTAMPING_TX_HARDWARE | @@ -1785,7 +1790,7 @@ static int ravb_get_ts_info(struct net_device *ndev, (1 << HWTSTAMP_FILTER_NONE) | (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) | (1 << HWTSTAMP_FILTER_ALL); - info->phc_index =3D ptp_clock_index(priv->ptp.clock); + info->phc_index =3D index; } =20 return 0; @@ -2656,6 +2661,16 @@ static int ravb_gen2_ptp_probe(struct net_device *nd= ev) return ravb_compute_gti(ndev, priv->clk); } =20 +static int ravb_gen2_ptp_clock_index(struct net_device *ndev) +{ + struct ravb_private *priv =3D netdev_priv(ndev); + + if (!priv->ptp.clock) + return -ENODEV; + + return ptp_clock_index(priv->ptp.clock); +} + static int ravb_gen2_ptp_set_config_mode(struct net_device *ndev) { int ret; @@ -2672,6 +2687,7 @@ static int ravb_gen2_ptp_set_config_mode(struct net_d= evice *ndev) =20 static const struct ravb_gptp_info ravb_gen2_ptp_info =3D { .probe =3D ravb_gen2_ptp_probe, + .clock_index =3D ravb_gen2_ptp_clock_index, .set_config_mode =3D ravb_gen2_ptp_set_config_mode, .dmac_start =3D ravb_ptp_init, .dmac_stop =3D ravb_ptp_stop, @@ -2709,6 +2725,7 @@ static int ravb_gen3_ptp_set_config_mode(struct net_d= evice *ndev) =20 static const struct ravb_gptp_info ravb_gen3_ptp_info =3D { .probe =3D ravb_gen2_ptp_probe, + .clock_index =3D ravb_gen2_ptp_clock_index, .set_config_mode =3D ravb_gen3_ptp_set_config_mode, .ndev_open =3D ravb_ptp_init, .ndev_close =3D ravb_ptp_stop, @@ -2781,6 +2798,7 @@ static int ravb_rzv2m_ptp_probe(struct net_device *nd= ev) =20 static const struct ravb_gptp_info ravb_rzv2m_ptp_info =3D { .probe =3D ravb_rzv2m_ptp_probe, + .clock_index =3D ravb_gen2_ptp_clock_index, .set_config_mode =3D ravb_gen2_ptp_set_config_mode, .dmac_start =3D ravb_ptp_init, .dmac_stop =3D ravb_ptp_stop, --=20 2.55.0 From nobody Fri Sep 25 21:02:57 2026 Received: from fout-b3-smtp.messagingengine.com (fout-b3-smtp.messagingengine.com [202.12.124.146]) (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 CED364F85C8; Mon, 21 Sep 2026 17:51:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013090; cv=none; b=fTRH1wexfJjta5Iqfk2haEosPvYWVo3XHM2zQdrd3EGKimJ/h8Dbr8jbF8uy534bQhrG8T7oLC9DX2Jp8xVaP6uZpPv9EfhasLHgXJZOx25T1QUC2E5yXSgw54Fk3qUrkLFqXNZqyQ/P6Yk8P0b1GaqFnoEx0MQpxWMrNctVaaA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013090; c=relaxed/simple; bh=T2U0BhcSuHwr3Q04Oax+Q9cAEyg+8M3IrVjIN1pHo2w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=G2SAi/CUdwR7EbcrFvAsAbyg9NjtaG16RKCLW5+nHORcYWn05h2blp1m1ix4KCAGjAEa26QMMAe6QFByYJy/XDC3e3bOewq1Tp4Ylrt6Kbh4syWItWYO/ne2qsHAga+4+K2JeEftpbVffTz1kXQLcT2gp2UAYdPGE9ZAia77gt8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=AxzdnXSS; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=FjEsukt0; arc=none smtp.client-ip=202.12.124.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="AxzdnXSS"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="FjEsukt0" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.stl.internal (Postfix) with ESMTP id AF70B1D000C9; Mon, 21 Sep 2026 13:51:27 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Mon, 21 Sep 2026 13:51:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1790013087; x=1790099487; bh=J+UiB0JQF3J734EIk7xL8AfWMjHXBByPW0qfltoR+18=; b= AxzdnXSSNxjN2NmoY43ImzMu7bQyhgIcuJU6XH9CMqVcX7Ugx6NZsCTo79B13xIk q318bVu+3YmuUu//busjQ3I65rYR4PbkUyDW/ToteMUCOdgqHwELzO04t1jCICWK vmB5mKzT2h8ZgWKZUd9pSgMc0BvfL1PiPpCUSSQ7rmYBWBrkXra7L2hkRXBw0BbV +ZVuq5iVJUu6UwFxnhb3Jsm9cR3Pi7Z0NknhJ7Dp+P5NiLi5M8UW91P9puyehBtB lao+q49c4szhG+tB5bIx+a5ghQ+Fvlj2ik0SSc3zTZxhYDdLF5zdqeyHqP1jQgXu VkKAjZ1MKOoZyjsv2GEQ0g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1790013087; x= 1790099487; bh=J+UiB0JQF3J734EIk7xL8AfWMjHXBByPW0qfltoR+18=; b=F jEsukt0QjfIMRSinM+HyaYXubqTmMpCIupir0wQhav/C9zrzwdz/HOFTQ5b9ivac fh8BFiP/KWJKkF+fdeU+vqWXdrbG6EFYWILn1kiUboECMzazuQu73pXJC4nA1D+p j1tABmqFv1NrYAzA5Lcvw9v5IHGxjJOdKcuEqDTrE/3cMvNz14kZVXgGivNoaXsj 6X23/xdbn9WNkYEyfEKgn2HAvLyxps+qDzu0CgkJ9gkY1tZZoKMOG0pDpId0BrXs 8WW8Jmqdd8VMd/vGyGUeD+dN3NnpcHyV5i4+ILeLMQJnK7Ls4ht1lVBLTR1EZgcy iHvhQGqJLQ3IE6/MHxEIw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGx2PI0DCnFrKcjMpN3OXygpnBESiscvY5kHlzEb0x0+o4FTTZEJElp0ZbKiSJAfr 9qumY/qqho/hgXggk3d2wfNQkjmBj+lpobCkXWUqdRsAj8XXkUiqQjcsx1q5D9Wr9zaWI8 X64FUraMSuaqcvyCi5Zhye9Uarla6wOm8gh9JnIMF7PxnXg/ryhWze3tQalyHbFA0/PBOJ jWU1l09x6SyhF42n1BsmxFmPXUpPQUV4hYfNI72sJwVWpwxhsveDqh2IlreCDI9lzkEkLz JR8n209yuLfW1Bux0fdKAeNpBPQErw7/J0JR/KE7EW2jk3BZnTl0MVG1vEfIko8Lm/JpGS HcyvqLICVcow4hLwxbxVn+KxJjy48Kqn/mvxkBPm2CS72PEt054suqZgInHcL160za235/ T7MQ8T7LkSWxqB8kEDIt1eZAQeXaPejcLmpqWUHbQ4wFPSDCsJpPk9tybTS0uTo32JIjOh wWzt5vnLAz6VAje9LEM+xiqJpO8BJzZUeFJud/tBWBvKg0wz9I9wBaUiQwIr/GUMghOeyY L1JMgDHc76L22MZZKuZ9vhNCZsByAT12FVI8zXTGArMiDCmFxKqFieIBpSvxwHZ57DtYVe /OST2Njt24zVfqN82mNN793UXTWYuwAmyd0uNuIo2p1SViUVnAO+2z1YiacA X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 21 Sep 2026 13:51:26 -0400 (EDT) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: paul@pbarker.dev, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Richard Cochran , Andrew Lunn , "DavidS. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vadim Fedorenko , Sergey Shtylyov , linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Krzysztof Kozlowski Subject: [PATCH net-next v5 09/10] dt-bindings: net: renesas,etheravb: Add optional gPTP phandle for Gen4 Date: Mon, 21 Sep 2026 19:50:36 +0200 Message-ID: <20260921175037.4084310-10-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> References: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> 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: quoted-printable The RAVB module on Gen4 have no gPTP clock as part of the RAVB module itself, instead it relies on an external system wide gPTP clock. The gPTP clock is shared with RTSN on V4H and RSWITCH on S4. Add an optional phandle so that the RAVB driver can find and use the gPTP clock. Ideally this should have been a mandatory property but for backward compatible it is optional. The RAVB module is capable of functioning without it, but can in such cases not provided PTP functionality. Signed-off-by: Niklas S=C3=B6derlund Reviewed-by: Sergey Shtylyov Reviewed-by: Krzysztof Kozlowski --- * Changes since v1 - Use generic ptp-timer property instead of vendor specific one. - Improve spelling in commit message. --- .../devicetree/bindings/net/renesas,etheravb.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/devicetree/bindings/net/renesas,etheravb.yaml b/= Documentation/devicetree/bindings/net/renesas,etheravb.yaml index 1e00ef5b3acd..fad002492421 100644 --- a/Documentation/devicetree/bindings/net/renesas,etheravb.yaml +++ b/Documentation/devicetree/bindings/net/renesas,etheravb.yaml @@ -97,6 +97,8 @@ properties: =20 phy-handle: true =20 + ptp-timer: true + '#address-cells': description: Number of address cells for the MDIO bus. const: 1 @@ -305,6 +307,15 @@ allOf: items: - const: fck - const: refclk + - if: + not: + properties: + compatible: + contains: + const: renesas,etheravb-rcar-gen4 + then: + properties: + ptp-timer: false =20 additionalProperties: false =20 --=20 2.55.0 From nobody Fri Sep 25 21:02:57 2026 Received: from fhigh-b5-smtp.messagingengine.com (fhigh-b5-smtp.messagingengine.com [202.12.124.156]) (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 B7ACD4F4036; Mon, 21 Sep 2026 17:51:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013093; cv=none; b=RMXFA7bcu1hWcFDnnWUR87lw0dZkcO0X2rtKdPMMFXnzWHeJit9eE/Qm2Rtw6i+Be3sHPa/urxbZH+TEgTA84r6Fm8xOhzMKZuwutSC6v5okqiYIB6Mr7G6gnKEIW2o3xtyZhU3XrFWrYg2VqlyoAwV2ETGAqcM5zuDa7T4hev4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790013093; c=relaxed/simple; bh=0bwI0a+uIW27qUsZVp8iQa/5REZHgX+PZuhBY/cEFgw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AaiIZmQgzuF1nIUqh7PTorKXRbM2H2cyHtSTiYkTUdpYoYZSlLcwx3T1ZWAC14y9MiDdYOhQqxhndJ2g7cDoTJ1/sN/vI3WPYHBKUzcCOCPfKDOYTRl3EhL0muHUDfRrILjP99VvKVGYF0M+0p1j5+FG9ozruU2Sxv9C9aftuD0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=a5Tgt80f; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=p78n+Xvm; arc=none smtp.client-ip=202.12.124.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="a5Tgt80f"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="p78n+Xvm" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.stl.internal (Postfix) with ESMTP id 87DE37A00C2; Mon, 21 Sep 2026 13:51:30 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Mon, 21 Sep 2026 13:51:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1790013090; x=1790099490; bh=kW1EsC6GNtfwVJkQYsrWS24yxwxN7itDa+qfiyvuU80=; b= a5Tgt80f12rpHElTp49KU3VDQsRhziCYdQncna/YxdQnhtrHxtjS3EPoLDJOIl+E Llwqm+I4vQdUXwtV0APKXePKHJWuTXiNbhUgjo15ZvWg5/gAuaPDeBc5nZMFMF7o tWR0S3r9xqG0Bovf1yfdo+ZKJmGYmks3ExougFUfTxFpjEFrWUFY9VPJig5Xuxj8 vpGOGtO85ywhbf19iP+aX9HhRZhpHXMvsCLwBBM89d9B4LWFYHzIdk0NX+5iVXWL 28Tf3pUTcY0tqvpwQrc5JukYPVyCanoRfkL47xokzwxkXrsepPsHU7NImSso/dX1 BYCopPGn9cOTT7I+g4uWjw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1790013090; x= 1790099490; bh=kW1EsC6GNtfwVJkQYsrWS24yxwxN7itDa+qfiyvuU80=; b=p 78n+XvmEG6NtPEvNWZfnx0OaGvLgbDBXxNxMysRjzWAgjc9qJL8f3oiSRq/7fDqe aABwL5uZ/mlnZGNqTeLl1KKvD3B4sP1Zul8LDyY4cmYLvg86zw3uQrDLU7hPoqLq EsO1bhCxhQFv2kyQ/CSPcB4odmt6Uz2ZpwDYloACe76HHSpw31CUb+Kjt0SDvsJP xh9MZomB0t50z31pKKxyFbsBehWlLkTkWj0zcaweDtM3YhIGPbvSJKxiHBSowm25 P1Yo1M8iUljRMMfd2JXfZEsMKkylB6pzoUYcSEL3eTcfaNbZoN5rpZEWTOQojPvC KyLmdVcUmbn+UXZ/onxyg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGx2PI0DCnFrKcjMpN3OXygpnBESiscvY5kHlzEb0x0+o4FTTZEJElp0ZbKiSJAfr 9qumY/qqho/hgXggk3d2wfNQkjmBj+lpobCkXWUqdRsAj8XXkUiqQjcsx1q5D9Wr9zaWI8 X64FUraMSuaqcvyCi5Zhye9Uarla6wOm8gh9JnIMF7PxnXg/ryhWze3tQalyHbFA0/PBOJ jWU1l09x6SyhF42n1BsmxFmPXUpPQUV4hYfNI72sJwVWpwxhsveDqh2IlreCDI9lzkEkLz JR8n209yuLfW1Bux0fdKAeNpBPQErw7/J0JR/KE7EW2jk3BZnTl0MVG1vEfIko8Lm/Jpmq Ht4rPkeDpEJHHhl7lY3i9wNMhvyporoE/t3IPXgNoNmeCYWbZhBtv6SEWseSJLiLAHV7F9 3zNuDItAfPZ7JlDUnJcit6WxQrA/yjf/EIkHuVRs2wNwiIJ34bFbfit+bAgs/T7pkhEPsT WXm8GXCG+Lb9KGV/8InpO+EgulTsl6uyyzfFa2O3ys+0anmz/N6PdYuvkfKeuvohimCK1l 5FMjJbLQY58jA67JWVsH/154FEPtLxi9LuhXEBmvfLzowCf8efptklm7r50vY14NZ0rLiB j0PMiOtXon1riAaVJOeiNdoiy2uHgiOoGNAOV5uY+RDdvlZGG22aZZZBGocw X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 21 Sep 2026 13:51:29 -0400 (EDT) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: paul@pbarker.dev, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Richard Cochran , Andrew Lunn , "DavidS. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vadim Fedorenko , Sergey Shtylyov , linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH net-next v5 10/10] net: ethernet: ravb: Add gPTP support for Gen4 Date: Mon, 21 Sep 2026 19:50:37 +0200 Message-ID: <20260921175037.4084310-11-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> References: <20260921175037.4084310-1-niklas.soderlund+renesas@ragnatech.se> 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: quoted-printable While driver advertises gPTP support on Gen4 platforms it is in fact completely broken. On R-Car Gen4 devices the RAVB module have no internal gPTP clock as generations before it. Instead it utilizes a system-wide gPTP clock. This change utilizes the refactoring of the RAVB gPTP code to add support for a system-wide clock and stops the Gen4 devices trying to use the non-existing internal gPTP clock. To remain backward compatible the ptp-timer property is optional.If not present, or not enabled, the RAVB driver will no longer advertise gPTP support to user-space. Signed-off-by: Niklas S=C3=B6derlund Reviewed-by: Sergey Shtylyov --- * Changes since v2 - Use full 100 character width instead of breaking at 80. - Remove superfluous return statement. * Changes since v1 - Use the standard generic ptp-timer property from ethernet-controller.yaml instead of a vendor specific one. - Improve spelling in commit message. --- drivers/net/ethernet/renesas/ravb.h | 3 ++ drivers/net/ethernet/renesas/ravb_main.c | 54 +++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/ren= esas/ravb.h index 27e2b31955ba..5d35b40d7c58 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -249,6 +249,8 @@ enum APSR_BIT { APSR_RDM =3D 0x00002000, APSR_TDM =3D 0x00004000, APSR_MIISELECT =3D 0x01000000, /* R-Car V4M only */ + APSR_GPTPTIMER_SOURCE =3D BIT(25), /* Gen4 */ + APSR_GPTPCLOCK =3D BIT(29), /* Gen4 */ }; =20 /* RCR */ @@ -1132,6 +1134,7 @@ struct ravb_private { struct list_head ts_skb_list; u32 ts_skb_tag; struct ravb_ptp ptp; + struct device_node *of_gptp; /* Reference to external gPTP clock, if any.= */ spinlock_t lock; /* Register access lock */ u32 cur_rx[NUM_RX_QUEUE]; /* Consumer ring indices */ u32 dirty_rx[NUM_RX_QUEUE]; /* Producer ring indices */ diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index 2dff47c2a125..5a07cc0180d8 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2758,6 +2758,57 @@ static const struct ravb_hw_info ravb_gen3_hw_info = =3D { .magic_pkt =3D 1, }; =20 +static int ravb_gen4_ptp_probe(struct net_device *ndev) +{ + struct ravb_private *priv =3D netdev_priv(ndev); + + priv->of_gptp =3D of_parse_phandle(priv->pdev->dev.of_node, "ptp-timer", = 0); + if (!priv->of_gptp) + return 0; + + if (!of_device_is_available(priv->of_gptp)) { + of_node_put(priv->of_gptp); + priv->of_gptp =3D NULL; + } + + return 0; +} + +static int ravb_gen4_ptp_clock_index(struct net_device *ndev) +{ + struct ravb_private *priv =3D netdev_priv(ndev); + + /* If no clock, mimic ptp_clock_index_by_of_node() fail and return -1 */ + if (!priv->of_gptp) + return -1; + + return ptp_clock_index_by_of_node(priv->of_gptp); +} + +static int ravb_gen4_ptp_set_config_mode(struct net_device *ndev) +{ + struct ravb_private *priv =3D netdev_priv(ndev); + int ret; + + /* Enable gPTP Clock and Select High-speed peripheral bus clock. */ + ret =3D ravb_set_opmode(ndev, CCC_OPC_CONFIG | CCC_GAC | CCC_CSEL_HPB); + if (ret) + return ret; + + /* Set PTP source to GPTP module, only option on Gen4. */ + if (priv->of_gptp) + ravb_modify(ndev, APSR, APSR_GPTPTIMER_SOURCE | APSR_GPTPCLOCK, + APSR_GPTPTIMER_SOURCE | APSR_GPTPCLOCK); + + return 0; +} + +static const struct ravb_gptp_info ravb_gen4_ptp_info =3D { + .probe =3D ravb_gen4_ptp_probe, + .clock_index =3D ravb_gen4_ptp_clock_index, + .set_config_mode =3D ravb_gen4_ptp_set_config_mode, +}; + static const struct ravb_hw_info ravb_gen4_hw_info =3D { .receive =3D ravb_rx_rcar, .set_rate =3D ravb_set_rate_rcar, @@ -2780,7 +2831,7 @@ static const struct ravb_hw_info ravb_gen4_hw_info = =3D { .tx_counters =3D 1, .multi_irqs =3D 1, .irq_en_dis =3D 1, - .ptp =3D &ravb_gen3_ptp_info, + .ptp =3D &ravb_gen4_ptp_info, .nc_queues =3D 1, .magic_pkt =3D 1, }; @@ -3194,6 +3245,7 @@ static void ravb_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); pm_runtime_dont_use_autosuspend(dev); clk_unprepare(priv->refclk); + of_node_put(priv->of_gptp); reset_control_assert(priv->rstc); free_netdev(ndev); platform_set_drvdata(pdev, NULL); --=20 2.55.0