From nobody Fri Sep 25 18:26:55 2026 Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) (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 4723F38BF97; Wed, 9 Sep 2026 17:31:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975062; cv=none; b=WlYvdmWZT+AiRqEuShsWyTLJtSNWCcbdf0PN7G3ZdJA5n/1L1TijWN1r3jeSVhGvx3O5y/G+r1Memc+DXMD98ZlSZyeM6irqlm+vaHQTYMGmGKp/Wt6pt5rK5BpZMcjK4hdr6bGJlQfhuEhmTQrN7Ceg8QMNgDWb1cBSBCqNmJw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975062; c=relaxed/simple; bh=hSAdOWtlVWhEw5isQol0W5FJllngNHJ4Hq5nmctpjro=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pMXvMAQXSJXPjplCpll4ZtwMiEHs1MEtRZVbvkVwPgrWCeyatioMnpGYGLxmBy4iCjUqujuP3UEKty953jf/yTWEOCUgBZVcy7Q8Rz97wBbbmyDWeBhsIB+qmH6zgqY2Sy7UZtPNXUu8aGH5d7GFqdKpS5AuTpWG/mmn2APUzc4= 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=PwteYLGJ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=x/gs61UN; arc=none smtp.client-ip=202.12.124.144 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="PwteYLGJ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="x/gs61UN" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.stl.internal (Postfix) with ESMTP id CFE6E1D0010B; Wed, 9 Sep 2026 13:30:58 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Wed, 09 Sep 2026 13:30:59 -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=1788975058; x=1789061458; bh=T8k+avs8lR3xZvvDuzR3e4makBnhsvUEK4t2dzJBoIE=; b= PwteYLGJ4JSPKyGeS1MqdFC8GkxmyqhwvOMJmycNqLeWR5RWu9BEvl6dYhcxBFTF gwd13HF0iHGkIXps3DgzGT9ZZxdYXbxGrQOBrVpeARYtehR59/swViN24dKATK+t QzyyLiSN/gTjOBc++EOe3V4eiawSErpVShnqR2Ll9tE0PWwFwGkXucP9HIpXM1dn ueu8z4q3lXn1qkgoC+cU26oMSlKxSqCgPHC7c5eNDQQb6lcV90JuSdjfZ/jreS/c MxFFx/O0TZ3WnVEPRhxi9fHY4GXCUy65Uk1oGoa20h6ww4GY61UyaiQMcBefNKm3 7u9GZKO8+2NM0f8wwLH+Mg== 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=1788975058; x= 1789061458; bh=T8k+avs8lR3xZvvDuzR3e4makBnhsvUEK4t2dzJBoIE=; b=x /gs61UNSMh9aineH5PMGz9mKC3P4usWCar1wmYaTJMpRxp2i/v2ngvg439qcL2+7 xsAtPTP6WtSQpHZQKXE03FV9cjNFyklTkhNYwE77s9uBm8EUeK7NJIZ/nGJVpDAe ZnC6b36Ped/FW4aH9n3kMswmRJTs/eUQQ+V0xRzOQEJZzefnW/H16z/9igHibolp w6hz7osRO45zuspZQPAnOnUbqu5i2CR6gI4BMkMbC0qzsWWrSHGvtzEd9iY56vlr /jW8lhnb5G3uG709Tyw+WNRwqJPJzovX/JJ495p5QTmEt6dbRdnBLDygAFNxulC2 h2tdS7jDzaFAjUt9vSYyQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFpKuOoHA8K6npXM0EyPQ3B6fuJj1V92yxTkRTwTvOrGLmaogCPSGJNdxe3w3n+ts 3Bnq9S0gANJKKK31pjNWK50OZ9a7PMq2fNO8DZXCQ+/ff2Kmc+UHBXNITlDnGREVxg/f50 czaZu7ewfHhQ8KEOahciUDlJaktTnHuAyQxRzBwFm86u+eYYubMr2Wb9/todjLgmh5z450 82zfjBukuoe9N1IpciNBSfLDvZO88JgjH/tASHI61YFG/pSFyNvmg0AvAJCBYM82e580+H IntiqdDAd7FDyLCJPHSk55kS+5m53Gxxbft8dJNI3qmcm7XJFRCQyhfwNMEehhg0cLBjJH z8L0KRuy0cqEh9d59UgN7I0n9KcImprG7ydF9xwUaeH5fiEu65OZZoZRH1V42CD2ZkPKie lWOqMXJ1sZuuXPiYzdZH2zo8BMoHOkz9/OnsEpYBoFT3NFQOoyTUH/hiG8GuUhNEN8BnNs 3BszYg7G0/ZvmdIhU1anH37SJhiIvK5wi2sqYgvd/Br7xFqzVcbTm9QOa7m+DWHqBxvi/Q 4lvSINnujOjidPlM98W3nz+1Pe2vTgfT7xQ8OcNkTq860An/OUrTA5KM2dMSn1m6Djvx+4 CMgjX80sZ4TeHmRpmmzoShYbAER2Gh60CTEbUuSjV4NI8KIDbcW/3PB8DKAA X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 9 Sep 2026 13:30:57 -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 v4 01/10] net: ethernet: ravb: Remove gPTP control from WoL setup and restore Date: Wed, 9 Sep 2026 19:30:18 +0200 Message-ID: <20260909173027.2201560-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909173027.2201560-1-niklas.soderlund+renesas@ragnatech.se> References: <20260909173027.2201560-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 suspending and resuming the system. Signed-off-by: Niklas S=C3=B6derlund Reviewed-by: Sergey Shtylyov --- 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 18:26:55 2026 Received: from fhigh-b8-smtp.messagingengine.com (fhigh-b8-smtp.messagingengine.com [202.12.124.159]) (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 6FE44389452; Wed, 9 Sep 2026 17:31:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.159 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975065; cv=none; b=LHgT4gpugYF+Lk3F6t3krKc1gGTcH3eMkWl5DKYsY3gePQ/Ql37EWwK/DhrPW7Jy1fGBNUbR4dROMLz5sfVATFWWRlIHEL7U5BKAzlmfhAHhn8+4no4NWCnQuYc4rwpUSoMo9mPoo4vy2IA8OCxLJECwO44mBc2NDv4J4/zSIAo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975065; c=relaxed/simple; bh=hmpis5gJE2ngNtWrXSfh/ef+Yj7WTtZXvIsOf15v1rU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bmehKOrC4qbfiFNu7Bk/Vh8xYbJcrfGhPRXXqMkKZE8R0kg1RVsPJ/FXoqUKExynQWX1SuGk7JYTNw9f+C/VMD1XKT0jcYWOOqOZ6MnjxxpfbEmruFvLGPK100HVEY/zlI8Hwhr7n+zqPcVns5AISqXYJXIN6p/bfHIwKkpygf8= 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=Q0disXzW; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=TkRThlIf; arc=none smtp.client-ip=202.12.124.159 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="Q0disXzW"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="TkRThlIf" Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id 359D87A00D2; Wed, 9 Sep 2026 13:31:02 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-12.internal (MEProxy); Wed, 09 Sep 2026 13:31:02 -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=1788975062; x=1789061462; bh=L+9oK0TXXxk/EiHiWORG0xWm1SXmTAQfkqGE6zxyfjg=; b= Q0disXzW/jt1mdlmdwzTH8b1dBGoNZRbg0Q026rJTCjAg0+omEszQvpED4yLO4H6 hDtJo5ImwfIUD/w9x2gmRSPV5qjLKTwnmDpO6XWpXZPmDcLsMdIbClER58Py89dM IgUMA4+90G1+T+PzmGV9XfJ8i3WqsAM/hbn3N/kRuLLO2VFkfiToPKx8WOUegwcV oNAYBxPsxPvsZlZINE1AsnMaE67995EUdeoC5XD/rbGhuqHvphZWQtrfAPqD0JWN rj5EESmbNyDFPALJg/7JT0U1WUSMCS7yfdYigsEd41gjW49k79H0KzEAcCukhs2A p59d+RxbA7jJ2Nfmfub34A== 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=1788975062; x= 1789061462; bh=L+9oK0TXXxk/EiHiWORG0xWm1SXmTAQfkqGE6zxyfjg=; b=T kRThlIfsWCHV+PavOxIo4B8NfM7IxUXoiOQDOR/xx3qP66n4l6pIXHbDbcGfBbCN lSAgfIr7v2itKCRDJ+gCn/vunubpOKWX3k1KOFc5fjuH9P/5amRRoLBNIaa4kVEF jM9ViLw0c80TFosyX8gxqhg5J03SMjhmKEWLR0bElYF1bsa76Dmk/E4F1G2cKULl NvR6quN+Cv0p+9lwetxv7K0eAhGTFR35/zgFEzkwdf1hUKof1vE+Z8OreIsIe7rz 07rgPHAtDcVuVDeZnsjAJZb41AhtpJN4BHmwV6xw03m1wzI6Hsgq20L8dF1ca4e4 IdMHTA2US3etoJHR3/rqA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFpKuOoHA8K6npXM0EyPQ3B6fuJj1V92yxTkRTwTvOrGLmaogCPSGJNdxe3w3n+ts 3Bnq9S0gANJKKK31pjNWK50OZ9a7PMq2fNO8DZXCQ+/ff2Kmc+UHBXNITlDnGREVxg/f50 czaZu7ewfHhQ8KEOahciUDlJaktTnHuAyQxRzBwFm86u+eYYubMr2Wb9/todjLgmh5z450 82zfjBukuoe9N1IpciNBSfLDvZO88JgjH/tASHI61YFG/pSFyNvmg0AvAJCBYM82e580+H IntiqdDAd7FDyLCJPHSk55kS+5m53Gxxbft8dJNI3qmcm7XJFRCQyhfwNMEehhg0cLBjAQ GQP0Aj9YMiTcjbYXAWjQrxALfSo2EwiTRSfOeMEnoCrdKuBsKlErL3n0aPeT8hZT3lJk0n Rvl1AKVaNMZ/zReDwUXlJzOnPQzaF3wt4VLWeeYHuB0eFMxmkgH81WWGreieo/W00u1Arr tu3+KkIsDC/+iIrL/HRWdOy/N0T/1x9a9TqZ5/l5yKT91hVTrTrq+6MBHMMyHfszgeie6e /Sr6rvY/6XDelquMGnAROqaSy9bJhbbR0dTf+IT9zjYq/P7idLJTL+4/ZGKzLmkDfzoVc7 ZenSvPvC3N6yaftlDlgZC2njMZx1h6fx3Gp+b/B1oIiFsGwSyQNtgwoVxGWg X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 9 Sep 2026 13:31:00 -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 v4 02/10] net: ethernet: ravb: Move programming of gPTP timer interval Date: Wed, 9 Sep 2026 19:30:19 +0200 Message-ID: <20260909173027.2201560-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909173027.2201560-1-niklas.soderlund+renesas@ragnatech.se> References: <20260909173027.2201560-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 --- 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..157fb78209c7 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. */ 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 18:26:55 2026 Received: from fhigh-b8-smtp.messagingengine.com (fhigh-b8-smtp.messagingengine.com [202.12.124.159]) (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 755723921E6; Wed, 9 Sep 2026 17:31:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.159 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975068; cv=none; b=XOOaamfHBTARtcpS0xnBA7bjIGry7AUdHA+bNUWxqxekzeL2aIpvT2l6+tt7ixQFw3AiNKD8hxdzD9TbmedqbkR96JLcBiQiuiMWeOIEuTRMIiVMnldz9aec53L4IeHf+9aBMyzCSX487VGdCmhdHJLzbqRu2qkmR4fWinqBUCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975068; c=relaxed/simple; bh=nSR3HSnVpPTuu5U9i4z2bz+hbzVGtMi+/826ESHNgTw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C5xd4BhU+/lDHDm1L6yDQLG3sHmQBt6GmKsomD7BSFXfDHOb7TRXeElHuZaDm/jHNcZYX/VgikggtPrY2JOj/YMCMHzuF3hIwO+egxr5hfA9uQHs3PnTY4LWwdP/jFr8l3r1cT7qN1DxX+aG9O2jB+TxKH9PVkN0U27ylngRf0s= 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=mDU2Xc5b; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=b9zmnIew; arc=none smtp.client-ip=202.12.124.159 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="mDU2Xc5b"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="b9zmnIew" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id 351B77A00D5; Wed, 9 Sep 2026 13:31:05 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Wed, 09 Sep 2026 13:31:05 -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=1788975065; x=1789061465; bh=90yR28BloUHX3qSrTf3FabQIL1bRJn8PhLYzuvKpi4Q=; b= mDU2Xc5bo2wDSWbPnDHUOunyUv0uGCgNfBSbpzpnymJIHHLUoo85GaOJ45fNEvZ4 aIXt1m1eP5jCSrGoKLeXN6gRNGGPOQ/uYPiAhmCs6uFBxVTTOWfCcmbX5z/rIWZa brinLi0uoL8Y3Zt6/w/km6+RaksFAtEwSNUHMDHfowAv0BOYMG1fSzVAU8X4P7UP bD8PDbIC8vXtPVmgzyeutAj+RNsS6/ZcwOvM0pSGxOMVbOzOdDy67iAew24uNRy7 ilWIOOauNA7ngMBurJkS/DQ4fmPcVHcnYnxF5/yhGS+boltXC9d9kWqFbPOkPiSg m4xi8/zT3oFT+rXPMrqEUQ== 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=1788975065; x= 1789061465; bh=90yR28BloUHX3qSrTf3FabQIL1bRJn8PhLYzuvKpi4Q=; b=b 9zmnIew2W7dd7QJaIsehj99OVEHu23KpKSlKUSAFybKNPHGqFHjd+gGgZQOH/RSG S8LUVhUixWcqrzrE1bzdcv/rBwZJ6vMT77I8IthB3tCtEu4r5s1k4Z9qRPjldkmT W9q4JfycUy5T14H/5vcSC94la1j/3rpEDzEZS8OmM042lj7z/m6g8Dll2m0Sll9k sxQEg2LUl7oQhZ4HMzE1RBRI+Yzhxd7raoDFzw3tvQiG8wAAC9dwFGwSobv2MxFB XljEQHs49ot13RHDx+5W1hmnJSJoILZB0fXmcVel1Q5M/GHEJap4WpMTJ0+sS/0o IBwztgXPuEipULE7DMF8w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEF01o62KOqUAHAoE+QVORj7r8TaCrIRf5OPWQ9Sp090ondym5bOSJDH9EhDA0N1J m6oWrIHZUlXi6Du7gssdeyy+/BlAkuIXaHCAN1uAugotP20y1lNMlpeZQus2Nlz/ti9KgY FhB6kaG9EPjkChJBP2fV57Rf5YCpIccezHDvjFb5cYW7BGEV2v4vM6aFtwlMNxZ7lMRyEj +cp5LwLEc2MEUsvUI+o18XYg0zrEaWvgxZJMSqPSeKERfPJg0jhZ39Wpp4IzKso4KrZ+Jd nafFym7s9udRKlmBiDB8FyT/3eFfMJ58g+x9eInhq64X5vYSgsZjNwy9qzGmVDF5g97He0 jwjGOdP2zxodBtHyxeswTt66zoEuOiT5K/ajgPJ/cfb5AS1l6Mc7vPrzwDpG91gY4Oci+u Xm+DmCGdZNyLlMzR34cOGDagDKnnAH4nDAZLP2tByo0uFC7tkBI9nONWEifxUXs+NY0tXT nmzfFePjHoBF4FKJiz1gZ2/q/xDC7PFseT3rnq3KgGxc7g/knTnfyLTx2Gqa61/YqvPCWh w8O/m5ibygF1Ahc6b0OkuZDmO1vJcj2qxB4jy/1Nf90i5c1uE0uP/DtfAOdDxu2K3p7IW2 TMudaa4PNRiThQ07cKeyKlJwtrjTw6Hl9zNnKJVj8aPMIIF+T/nlOq0Tg68A X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 9 Sep 2026 13:31:04 -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 v4 03/10] net: ethernet: ravb: Simplify gPTP start and stop Date: Wed, 9 Sep 2026 19:30:20 +0200 Message-ID: <20260909173027.2201560-4-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909173027.2201560-1-niklas.soderlund+renesas@ragnatech.se> References: <20260909173027.2201560-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 v1 - Improve spelling in commit message. --- drivers/net/ethernet/renesas/ravb_main.c | 37 ++++++++++-------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index a89f6fe7866f..2d0022a4f85c 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 */ @@ -1974,9 +1980,6 @@ static int ravb_open(struct net_device *ndev) return 0; =20 out_ptp_stop: - /* Stop PTP Clock driver */ - if (info->gptp || info->ccc_gac) - ravb_ptp_stop(ndev); ravb_stop_dma(ndev); out_set_reset: ravb_set_opmode(ndev, CCC_OPC_RESET); @@ -2020,10 +2023,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 +2055,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 +2369,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 18:26:55 2026 Received: from fhigh-b8-smtp.messagingengine.com (fhigh-b8-smtp.messagingengine.com [202.12.124.159]) (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 7B72639524D; Wed, 9 Sep 2026 17:31:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.159 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975071; cv=none; b=b/xQ8hrQGdwx4EWxpJ5m8gdE80VYFdRh+ZkMd0h1o2UVrfyVRJdBQs37uQiiLzjBaFgnjxAHBnySAtRGWuzXe0TtBXMZbMRjDKJ+7+d+6U00xHZQ/mkz+DeP+Nf6rE1yqlep/fQzN5D0hPIm5JpuXAhV7G2Y7VZAAIsa66VaJ2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975071; c=relaxed/simple; bh=FJztA2dI//Yj90jhc8DfU7N4OGjw/VMslofrOnrUU2Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gfnKzaHnLQxFpBgcUduKirB/rcPx58Wz2yHXD9S/HlGsTPGuNDwPm14spp+wsT4YkdUQbOeKAR7jf+eH9S1rSqNxET+WUB4W6tdyxQvh4mIpXF6OotvvP2YYgMDdlE9D8F77X+qwzb1Y0DA4vUa/6w2dAEbVur6MnNL6cYaJAPM= 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=J0oMWM8J; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=klEG+QG9; arc=none smtp.client-ip=202.12.124.159 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="J0oMWM8J"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="klEG+QG9" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id 4B5597A00AD; Wed, 9 Sep 2026 13:31:08 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Wed, 09 Sep 2026 13:31:08 -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=1788975068; x=1789061468; bh=eHUolKWoGc53KCB8pHoRUBfxoy8S27gEX2vWdwF1i7Q=; b= J0oMWM8JKbGRJQ0K8mzMbrZhOnrrVwQFxjXp4sJcltGo4FskGxDEe14t+yDM9kqn dfxQu17tgkVkwqdjaBmHJRsnZA8EU5yGKDsB3inWEHdhjPC92m87c5ADUgRYn46q ZVUqOw++0Vxl4fkQ84kXoL2JHG2wAGrGhqTa72l2EvpptozFepeyLBTUpK+xPn2h lToALxxoY5GJTRoVoesVnLzeTwIjScus00wq+oxezVsBeiEoLxP5v5dXQhN3/4TO ywtDNK3mW5h4u1bA0QhQ+VQ2ddu5Q9t1ARMM1PlTtHpEgXmw2HaWgnNjXdRkWOmK aNN8Zp7i8zRATg3VFAHecA== 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=1788975068; x= 1789061468; bh=eHUolKWoGc53KCB8pHoRUBfxoy8S27gEX2vWdwF1i7Q=; b=k lEG+QG9ZQm3R5ocA/rbANV6dBIz0Lb5lyTeqFZijjcoKroF9bObE9SRfz1F+DrDE 6ORBwTyi6OxCoG3tkINaHFJ1gSNY2U3loKSL4dNaK6KVs/rJKZDwMX5sSD7ZZifN TeTuBe6wfeRsjShkbmiHVdHPV4TKiSGE8C0puY9lE6qTzobZUAHIFzi79nKQLJEi S+K4I1NK2ay5GP3fdJuWLwCXGis7jbn6kOav1i7iOXM/aVqGMAtOHTeGCZ18N/G7 H7H1ljXCAqXcRPUeDf+J/0bC77wNOAbQ+jiqiOu+c5Qni29iuvvYRNB7vWkJuMBd sa/AcVeHhx8ttFh1jElqw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFpKuOoHA8K6npXM0EyPQ3B6fuJj1V92yxTkRTwTvOrGLmaogCPSGJNdxe3w3n+ts 3Bnq9S0gANJKKK31pjNWK50OZ9a7PMq2fNO8DZXCQ+/ff2Kmc+UHBXNITlDnGREVxg/f50 czaZu7ewfHhQ8KEOahciUDlJaktTnHuAyQxRzBwFm86u+eYYubMr2Wb9/todjLgmh5z450 82zfjBukuoe9N1IpciNBSfLDvZO88JgjH/tASHI61YFG/pSFyNvmg0AvAJCBYM82e580+H IntiqdDAd7FDyLCJPHSk55kS+5m53Gxxbft8dJNI3qmcm7XJFRCQyhfwNMEehhg0cLBja5 WgLaZ1Lqxmvw1wx+QQv41fmkLC2+Vv2Pv4bGKyBP37fq8cqHZO6ONYoP6b/MygCMb8nxYK Nc/9Nsa6cRDmBr/mjlq+/hq6C5knNdKQOe+NeElbJCKgxuYd1SUUln37CaqRo57WQOmRx2 bU6GhfwNg0zWc98wW4qA/5GiIg6CqUQLakHDfxOPOrKtbHVZpaNrj3FmxwAi/YWrBLR3kz 6CbTRTjRzgxJEPABtplw1BO6IqSHSlAufxWW0toBu6rr+ejC1RzA5LIxNkVNC7d550TpDs LvZNbVrCAEb0VcSJqm9ACHgTdztEElnAoTE/W3CQ9G5D1eWxg9TibnHfPXKw X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 9 Sep 2026 13:31:07 -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 v4 04/10] net: ethernet: ravb: Remove redundant argument to ravb_ptp_init() Date: Wed, 9 Sep 2026 19:30:21 +0200 Message-ID: <20260909173027.2201560-5-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909173027.2201560-1-niklas.soderlund+renesas@ragnatech.se> References: <20260909173027.2201560-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 2d0022a4f85c..e44d065f77cc 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 157fb78209c7..f70b616ac847 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 18:26:55 2026 Received: from fhigh-b8-smtp.messagingengine.com (fhigh-b8-smtp.messagingengine.com [202.12.124.159]) (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 A9C78397695; Wed, 9 Sep 2026 17:31:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.159 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975074; cv=none; b=rsACcMVMhi0wp7wTek8fiLMoU8e4wzvpaTn0n0lNidgjk7e7QeioxvIddSBMSDsT+HQX0+PPu1Pdn2SvAi98U76wnlw9CiSOJt7JVYVAXgP764AF4kroR6TUpyWpu1L5tyyeUA2Xk1lxTPk4sPHaBcKO3SIKjoWGo3+z7n3ejtE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975074; c=relaxed/simple; bh=U9tSzxcVWwLrJR9B4hdd9gitDj6fl2dhFCC0n8ujmSM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qdDH2EXkuOPuMDMztJrWln32VVXVd+u7xMrt7mPIGMYFhUBUt6zeoirDr4xM/W1AfMmJASAosuQA4RSVnflnGx+VoZjpRxBQcPXG+tQ6LeBfjHz4Bnysel9QUBsexlnrWzr0snfyr0sV9o01aHWTzum82w+/lq1/thW+FkY6gdI= 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=LLj89Wus; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=knLjLujX; arc=none smtp.client-ip=202.12.124.159 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="LLj89Wus"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="knLjLujX" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id 1FF907A00CD; Wed, 9 Sep 2026 13:31:11 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Wed, 09 Sep 2026 13:31:11 -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=1788975070; x=1789061470; bh=OmKc6ftdoWzNo+hls5mYDi7giLLHAyvIxMQEScl7AIc=; b= LLj89WusFohixK2o8hmec81K0ZI67t22qMnultmSnzFm9nsxeoZgYpcDJH8f70yl LkRRU6dRwIDXTGTehEKUorRkYLzqGWziqJ3mL19SXPAU4iah8mdS5ND9n/iPF/Lx WAJVpV5m5yckT7jHKeb4KzKHp+5lJrcc9mSWT8Mr+7u7N4Bg8SN6iiNbCLCT3ORp TgOAcJ+5RWW7njncfj5mlDfgcQ0yXjexY4SE5yPuSpJtmQx5kC5BkWCwm137GxSM TPffNBMLTCSAfpfs+6jUpvQCIymeiKdi/LwL8hrV6Bk9keSssioBUTjwgjE1DR81 +DgvPAJYJAJevqkrikO+Hw== 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=1788975070; x= 1789061470; bh=OmKc6ftdoWzNo+hls5mYDi7giLLHAyvIxMQEScl7AIc=; b=k nLjLujXce6oGs9Oli1asdKC2GXizKjCNiXBtnlQU/qPW0hTOtFvc8GeG8WGm7v65 BsUzdJGYN7Wtir5plhytamaHjs3TdLy1DqgL2u2+1ZEB6DM6vq424O9xrV/js6Bv fT0udZQh9ON0kvrm2F9Y8Kbtpk4AXpDb1zF74OynSgZOThVe4nNQrPracntv9NpW KvvQPBrHzZB2vDM6NkdA3s9QobT2xJmPhZk4Lqx0EkC7w2G2y5XbYbTidxo5FHLq xwfb5+DhrW0189iqIov+f08Xhtm5WT0B/YOkbRKdyvzYnOnnb0HFYCa4hD50mNRY ssktAWHKMSETjUQT6Im/w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEq3FTDpjBKCOp3f5adHaq2tctvBTIVYwu5YOD0r0APkXdl3WnbUjSR6/ELXOuGwM yVqK963GfWKzhYFHOuyj73vHCWpLZYeL4lXE+xSHQ/6u5zAyWUyUH1lL19FgVYefxLnxkw JDufjKfO7IeTL1+lxnZuLtiNItrdGTMd0TVELvwKG1ioGaoJ7wtq6fOo3MGEelnTx+w2/X Gw4u8BJYKT6tnahKuZrI1Ih2Wju0n/fYMnzGwrvOYfWhdd3SegXgegvYMb6dCDGLQwpzqa JEJ2U0Goa65eRPBK7NB//Om3OLwpDm4jJqOKowyW9j5bpAnW4hQjDKnoS/uEge8yrexmjs w+bgvPWwqLNWuMAR7YZ8VYlsSPpGDN40uecvwIXxilS3Zry4Bge2xnUusN0bQ/0iLXzeJ2 u4z8qR0UCRz9y7HuCsGtjA3HQZHwkg0u0IzGSxbotsmIIth3+cFb/5t87N+TiF3V5n8okA Gl+ErLF3XuACCv9bGXfhA1ej/tm/Iwt7p16vntlm4cLs5JHbj9M7cRuLo2PjEBt/osUgmY aWAkBzD1PpiF2v6drYsJ0EMkNQ2Ngil0MDhqsYSXl3ClGZxR/+TrH+rgS0dPSv4wb9ziEZ ZZ0xuz2uzZzStIq2RMJzVPtLiPlSDtbxnM7HohpGAR777X4XiKt8OelinvJQ X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 9 Sep 2026 13:31:10 -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 v4 05/10] net: ethernet: ravb: Propagate error from ptp_clock_register() Date: Wed, 9 Sep 2026 19:30:22 +0200 Message-ID: <20260909173027.2201560-6-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909173027.2201560-1-niklas.soderlund+renesas@ragnatech.se> References: <20260909173027.2201560-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 e44d065f77cc..5ba322593a01 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; @@ -2934,7 +2934,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 f70b616ac847..37161c0579ce 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 18:26:55 2026 Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) (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 6FB4C38D6BD; Wed, 9 Sep 2026 17:31:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975077; cv=none; b=SWVLD20iMfq2ilcws+r0yCEpmBrpieW36LJUsEYtCIq6+2JC5ag15fwUJja15gCmmSdMt7QlZ9wzPw3DpoFPaUb4XD+1uK4J/efJFhZP30SISMMSikBr3mgzz6gRsh2yk0I7COB2zA+izAHx9+GBeL87YjfZ0dEzZtgE7+UdYRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975077; c=relaxed/simple; bh=7vK78GlO2mGmPsbvEys/WT5uL2xQEz6UezB8GBaChec=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MtJ79AXI6Ob/AlDzX0NvuEaC0e7ixe2wUK5YK9h6bJpvYTn0gxaGxeqyY3B9ieaG6/pOqbUj1MWMR11KqIwjwQw1k12mDc1MJb+/4RwGP/OocGw61GiF/RuXZ/sB6APnIJXIB0M3X8MEZsR8yKVeifRUqx5AHvt7Fgcjtq/gJIw= 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=u4Dr1RIg; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=ZVVOqLy9; arc=none smtp.client-ip=202.12.124.144 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="u4Dr1RIg"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ZVVOqLy9" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.stl.internal (Postfix) with ESMTP id 1C87B1D0011D; Wed, 9 Sep 2026 13:31:14 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Wed, 09 Sep 2026 13:31:14 -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=1788975073; x=1789061473; bh=DZCW3AX4IQy7VtLxOkg1LexBaFGy8OVeG+7z1SNmxkc=; b= u4Dr1RIgWUx8wHbljsX1vVFhKlQeDV/rLwIHvqAd3LQ1K01NxhPLpAlOGZU5fTpj b1tDMAR5ufoInVzIXh0mvSs35FRAaXgG9ZEtYt5OCrZ6s/pp7stEaDEJBlvkfhPm Gx7tPNMH8/4NDSKyvl4Yeh7huz2SYn6XjeSVSxEF+zmBwKy7fbdVkgHgNFAaLeKo 5PVdX6VGcSRTQ98/gyNTLYbWkO6tchtBiJNEduBXtYIhVtW49+wbqCmvhOuoz4IE hbTqWFfsKaPx7fJfPPqKUE6u9yhtbpaSAuXLR+51bm9zqV6k02E2u4AfTvpGtepj JPcc2H+jKhdPE9bW8qv/mQ== 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=1788975073; x= 1789061473; bh=DZCW3AX4IQy7VtLxOkg1LexBaFGy8OVeG+7z1SNmxkc=; b=Z VVOqLy9E3XVHmTZoQazDO5a0pK6cHB89ujHvOBxPK3Jmw09IDZyhgEnvbejyzGy6 N0G9wN3JVzeErI1KsTnV5HDpfKvkhBInidlKdXdSgpVjKwO0//jAbEy/3ig70oSh fg4T6MdvS4F8ip6E5uTMK3Pm9OcQDL/YQMy504i7FOVinn8yktuAPYw0jA+XLZt7 7zr6ygjxKhumOHSuoDGdiVKtWOsu6IzNNmik8lFHUa7YnZgB3p9YnXHcu0PpcyRV VGkoUbKIyHr1Iw2mdP4mRaYEgmyeoVJB5Ld6742RheY89EIkwHZOrgawnDrlTnwS 9wT04RTyPIyr6+gY6STXg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFpKuOoHA8K6npXM0EyPQ3B6fuJj1V92yxTkRTwTvOrGLmaogCPSGJNdxe3w3n+ts 3Bnq9S0gANJKKK31pjNWK50OZ9a7PMq2fNO8DZXCQ+/ff2Kmc+UHBXNITlDnGREVxg/f50 czaZu7ewfHhQ8KEOahciUDlJaktTnHuAyQxRzBwFm86u+eYYubMr2Wb9/todjLgmh5z450 82zfjBukuoe9N1IpciNBSfLDvZO88JgjH/tASHI61YFG/pSFyNvmg0AvAJCBYM82e580+H IntiqdDAd7FDyLCJPHSk55kS+5m53Gxxbft8dJNI3qmcm7XJFRCQyhfwNMEehhg0cLBjSw dJUTnx9U+x22UZE0O5siuLEVi2dt562Jjl5+bVMISm/KqhrpB4EwHL6gVV+tkVNDi6oehA WYTAavGhu3rin3NReO/13BqeXQmv6f5EXrXFwG0ndjgLMHq4+WNnlvmUToKq8mOKrn6moA 4xpSr3//oFHCrMx00IDjm/vO+s+/E+tzh+2IwXPvcC0Re2sicl6Gyqm2NoNgH2/gA6qEbJ MWHY7rZVIywg5oUxzcPTYZpba4g9bRz6K2oPQQZ8LUJDFWBmrLbzHrFKc6p1ZTGJ+645S0 ZqvEBAhcYV0ydo674scPOfYB7nWhcmlCK75GNpL6ytI4HOzBHeCJl3e7l6cw X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 9 Sep 2026 13:31:13 -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 v4 06/10] net: ethernet: ravb: Replace gPTP flags with callbacks Date: Wed, 9 Sep 2026 19:30:23 +0200 Message-ID: <20260909173027.2201560-7-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909173027.2201560-1-niklas.soderlund+renesas@ragnatech.se> References: <20260909173027.2201560-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 | 83 +++++++++++++++--------- 2 files changed, 76 insertions(+), 31 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 5ba322593a01..9e9b1c4fbe95 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); @@ -2187,7 +2180,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) { @@ -2369,8 +2362,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) @@ -2378,7 +2371,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); @@ -2660,6 +2653,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, @@ -2678,12 +2691,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, @@ -2702,11 +2727,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, }; @@ -2733,7 +2758,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, }; @@ -2758,7 +2783,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 18:26:55 2026 Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) (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 0F22239B4BF; Wed, 9 Sep 2026 17:31:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975079; cv=none; b=Xl9Q4bG7iig+VhuTTDbXvEUq8LtWs7o7xOp97LmGtVRch5FCslNwlhh8iYIRgKnOWgG3ZaNSxYUulPfWTkX/LeGML/tWLspDI7F/1jS6uhnJCcPDqEfTETEfYu4IRGxzn3ers6Yg/jq+K866HpLmkYiRi1XCAmTOqmGKFX+LhXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975079; c=relaxed/simple; bh=PxMbZv0PCG64WZi3JTF9f/IhuydEEm5eAfOa7M+FiP4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FyVtqAf0Tf08RkwOm2x5rkjfTWp3Gazq+rGTCQT1FyzqaMIvDCvxoqK+IXQC1txsRb3ESPCzmH5z3ryFOKQQMqL5vOCz9N1eagA1vcJa+4uQH7ia5u8NGnN+/Umq7qv8VCVhAO9p3lN1GHVRkg9pM8ObiY0wyVPD4EgOx4RFqgY= 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=XyQXRKAW; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=n89dOpRf; arc=none smtp.client-ip=202.12.124.144 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="XyQXRKAW"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="n89dOpRf" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id CBB311D0010B; Wed, 9 Sep 2026 13:31:16 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Wed, 09 Sep 2026 13:31:17 -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=1788975076; x=1789061476; bh=5cv8y3BXMbHx5oTK4jiSUap3Dq6Hfl1AS26ZX2vIoQo=; b= XyQXRKAWtXsoKsHGNY6Zi7I4urMGcGaDzAymieN+YUs84YZFFQBNEVhmuFUKZ8Wo frNM8rKFAdSEF2tv4zl5Tnb4WLLg8nZsU6KrTqBSwrEyIO9gbYNCLBCAhXDxWBHo xf7sYe9jOgjMiSyyYv0LBgclJnc4t0mkGM3aclDx11RYK7os0UeiYRES6GtVOqeQ O9arHkgAsnCfE+ZShu5cT/nWHlGYBGDcKyXOvOYhxAtWXC3e6hHpxXCc22nH1NnX oHuAGLwkz4kEPNGtrC+QV++BUECqbuOHoHD4eVBkZ1g6GP9OJXp/aHxxy9gbdPpT 7O1l+AnteRPTOxvuUBw98A== 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=1788975076; x= 1789061476; bh=5cv8y3BXMbHx5oTK4jiSUap3Dq6Hfl1AS26ZX2vIoQo=; b=n 89dOpRfqB0PGNFRfh146YqdPjid3Fea2gYvGkGnzm5vGz72FEW8ZE1eF4urhGZvc OidExbY1ObCSZ5cRUx66zKmsfrkmCvEB/e6uIeHpj1qxhgKbQPB9Vpgo/SCWx5OF e1ZkqgOzze/mUprNW2I62jcQHT2pNc3Bzxjurf8QyHuAz9QiY8i/oToqY8QhnNFc p/YBFBFCVHkbEh8JypDtlmwMUZt/qdguZQ9lYpcPs+01fzasyAbTV//dfW7c040t Merm1stL0d2twua34ZJimWB83VX1Ut+7HNWHG4EaNcIixItUrLhpP8JgA+SI8eOX KKWqIBvLrQivIjRKLq3Fw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEF01o62KOqUAHAoE+QVORj7r8TaCrIRf5OPWQ9Sp090ondym5bOSJDH9EhDA0N1J m6oWrIHZUlXi6Du7gssdeyy+/BlAkuIXaHCAN1uAugotP20y1lNMlpeZQus2Nlz/ti9KgY FhB6kaG9EPjkChJBP2fV57Rf5YCpIccezHDvjFb5cYW7BGEV2v4vM6aFtwlMNxZ7lMRyEj +cp5LwLEc2MEUsvUI+o18XYg0zrEaWvgxZJMSqPSeKERfPJg0jhZ39Wpp4IzKso4KrZ+Jd nafFym7s9udRKlmBiDB8FyT/3eFfMJ58g+x9eInhq64X5vYSgsZjNwy9qzGmVDF5g97HXB GLrJwgkjE0yByJgzDn6GtLgw29Pt10aVDF4yWayZo5xdEdXBghTH899wY7ewTUBeFJ6xDh vfj7X3ucptvKxRw0BczOUZ0RhZf1WaWWVniimjDwNnoyNkbeT3Z/zG9KX36IElz/j542iA dSw6HYSnf38StY0N7wOTVMTsTyAYTx2Y1S7oZzPDV4tzY41qevBT9i98Q1rHMMlUrXSBTu vN3uVQq4z7ViWO9caWbpPkmFLbatP5Mmttlx85N1gKY57g9/y5Xe7mKtR7EDkedx6lJ07P VwR6frzKgvT5ap+ES7tonvhcic4/acvqE7LldOjEbihZnpXEqwVCHbQN6g9g X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 9 Sep 2026 13:31:16 -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 v4 07/10] net: ethernet: ravb: Add callback for gPTP probe Date: Wed, 9 Sep 2026 19:30:24 +0200 Message-ID: <20260909173027.2201560-8-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909173027.2201560-1-niklas.soderlund+renesas@ragnatech.se> References: <20260909173027.2201560-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 9e9b1c4fbe95..1092e8ada188 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 @@ -2653,6 +2646,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; @@ -2668,6 +2668,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, @@ -2704,6 +2705,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, @@ -2763,6 +2765,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, @@ -2783,8 +2803,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, }; @@ -2976,12 +2995,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"); @@ -3034,10 +3051,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 18:26:55 2026 Received: from fhigh-b8-smtp.messagingengine.com (fhigh-b8-smtp.messagingengine.com [202.12.124.159]) (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 A723B3A3E76; Wed, 9 Sep 2026 17:31:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.159 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975083; cv=none; b=eSBxkuDr5eVOG3g7iUu57dNJFVCHc/UZPbUFZWQO4XY7dHPqXILKYgiwyiAMca0R+lILFwAIQAnVf2AO9lsR2B61GKwPhuiFccrrw6N1lUMuWaKzPuS2hjQ10CiRI/eSxdT3H/7eNAXd74KlsW4XRFNSlwOsda5IAAmJxlzuLkM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975083; c=relaxed/simple; bh=93JsYLxWf43Z4lB44N6XlCD1AtrDkTa1YbfZxKouPFc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SzND3Jz+FjSNA5VWYW3FLdTtfDYEV2YuhwpeK36t1eInqJ3NkKtATUu7GRQ+hJ6bFnI4qg1Ib1/TW7giQLCiOdyGM2c45CcaKc8TtUPmdNXEJDEPxigAl/bz6TQmgrQKf9xT8s/PEaQmEbxIVxB0iHQBHSd0AIM2s5uqL2d/7F8= 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=o/Wpv8ln; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=sQuV9hnl; arc=none smtp.client-ip=202.12.124.159 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="o/Wpv8ln"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="sQuV9hnl" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfhigh.stl.internal (Postfix) with ESMTP id 797A27A00D5; Wed, 9 Sep 2026 13:31:20 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Wed, 09 Sep 2026 13:31:20 -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=1788975080; x=1789061480; bh=3As11Y4/j4vd5fRYoUyxOaAShGEnhOe+hveBHuRB/W0=; b= o/Wpv8lnLoNUrQX6mo/9sG3h19xFiJC2zR3johSrsRMhYqvsXhOT1NWPROmpkkk2 EDvAOias9t66ujJ6wN8ys0oPxtoTO09+AEXN6Xx5XxzXCGBdxmAciNlEBgebGCT/ 0h4wCTTP8BGBRYvXj0bBahgFaimE+5skMsMfQC3Wrs4kttXZmkl6T118vrmIn23T AF/KQut1nc4xoqB/JYDx0X4z5hKV6oP3eX3O0WJ8o437PswW7Nx9628uTARmnFYR ttkY9tYnbhUp0QhozznRPe0Kvea82qflVCytcC+vMlzi/2/rpn09ghoc+ywuvAhc STkT1h4cYD28SWERRHx4LA== 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=1788975080; x= 1789061480; bh=3As11Y4/j4vd5fRYoUyxOaAShGEnhOe+hveBHuRB/W0=; b=s QuV9hnl0HtusgbiKgJsME79BFJiP0DhC3DeHclUqwWau7Kzcq3fO9eqj9h+vzCid itbdRs3OcrVIN6wKmH0wWmybbYoQ7G/DEapp+lkAQwEq81h5DxyB3+TXhnIXr5TZ Va+67SVP5DeGZGCsgmxowP5JJfedNUIbe1MqF8/NuULRZ6i5QUPuj70uxQcJ0HeY twFZaGaMHLEfOb019Vfn/WKu3SG1SUxeF45NwBa9hQkkgHnwrY3UeXQ17UlgMnVL PragoiNADJBRk00ZzTB8poImFAeX2TuBtq9lV/LRVPgjpofmIQiOm6ylzv3PxMq1 o9fW7A7tWESKzU43hMC+w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFpKuOoHA8K6npXM0EyPQ3B6fuJj1V92yxTkRTwTvOrGLmaogCPSGJNdxe3w3n+ts 3Bnq9S0gANJKKK31pjNWK50OZ9a7PMq2fNO8DZXCQ+/ff2Kmc+UHBXNITlDnGREVxg/f50 czaZu7ewfHhQ8KEOahciUDlJaktTnHuAyQxRzBwFm86u+eYYubMr2Wb9/todjLgmh5z450 82zfjBukuoe9N1IpciNBSfLDvZO88JgjH/tASHI61YFG/pSFyNvmg0AvAJCBYM82e580+H IntiqdDAd7FDyLCJPHSk55kS+5m53Gxxbft8dJNI3qmcm7XJFRCQyhfwNMEehhg0cLBjn3 1FXMrH2iGxIIyuhcsC8vaqNVJNAN6u0+/yXgMpsQYahv35X9RyamMX3hF3mchImcRo9Jf3 rNvai9/DccOg8InC/rN/THdCLScIF5/V75dj4s4izcfq93rkMQqrwGHRAR46Nqy823qP6C fbMTCkorDbRtMv6EJnENY5kpX370cox0IBa+TY1Wjuhljeh5rKO9imwmLm7+mkP6tuRe6F 4pcuQxlHpQO0mOlqCMxx8uL4NFe7LdJ0xp/PWNMi1xjoksiz+OYd62XuLWd1DQO/ZQwFe/ +44U8Yud13y5qWeSvvuh/SHQzfWaQJWW3DfnDsOccppbIzunL8+y2eKZoXSw X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 9 Sep 2026 13:31:19 -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 v4 08/10] net: ethernet: ravb: Add callback for gPTP clock index Date: Wed, 9 Sep 2026 19:30:25 +0200 Message-ID: <20260909173027.2201560-9-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909173027.2201560-1-niklas.soderlund+renesas@ragnatech.se> References: <20260909173027.2201560-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 1092e8ada188..8617c30dbb14 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; @@ -2653,6 +2658,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; @@ -2669,6 +2684,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, @@ -2706,6 +2722,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, @@ -2778,6 +2795,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 18:26:55 2026 Received: from fhigh-b8-smtp.messagingengine.com (fhigh-b8-smtp.messagingengine.com [202.12.124.159]) (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 9260F5678C9; Wed, 9 Sep 2026 17:31:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.159 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975086; cv=none; b=Te9KJDUt+dHq2A7dTPRCVnPEhXSw1lkUoHAJk3MLN3ODglQVC1EMyrRWzlfyWGqODmZTrtz33FLf/A5YF9708f7I8hzCXQAD0bF7Ns6AGQz8KgJhLaLWY0EfS+VkdPhOx1KSYIjJgsNGuOtk3WeMBnOZv5AkGHRZRZS60s+xAE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975086; c=relaxed/simple; bh=T2U0BhcSuHwr3Q04Oax+Q9cAEyg+8M3IrVjIN1pHo2w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WAyHUajK2Pq4AL4yGf7gCl5pb5seJRpAScT8A/EQOy4/C73b4RItOMzay95zNPcKwFVAYfYpjd/iSv04hjHdO1rdNfQxn22a7yrrezLtHfqHxQDBTfgw5Z+lgIAiTIlxTBESEk2fag5H6lsJVTi+2XucWSkq1yp1yZh1eLVVpdw= 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=zwg2ydvE; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Ei6VKWxD; arc=none smtp.client-ip=202.12.124.159 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="zwg2ydvE"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Ei6VKWxD" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id 797967A00CD; Wed, 9 Sep 2026 13:31:23 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Wed, 09 Sep 2026 13:31:24 -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=1788975083; x=1789061483; bh=J+UiB0JQF3J734EIk7xL8AfWMjHXBByPW0qfltoR+18=; b= zwg2ydvECnUvMht9hW8076PWjx8woNgu29hvuYB0ZbS/J7xyAM4nrk1nO5Sycvu7 UVRa4PnEKHFDnZKI9ym9TFGmByvIjE5j7Z6qhg3vnW5zdToRtGsxJdNw1D2Y4a3r O0d6+pnUzIbdoJ013Sm8eyCDTqQzMSxEMdCpRZ+ErYjyGkA9wlnSXAKOrvxAuk67 VW9X7J/hqklxiBTq9V+wvwg0I1ah4KAKClAO1uL0tHDsc6OG+5f/wnkOj/x+CLqw PP2X6bwdtlBPzWUcWOTilbJ2Mjk5yJZoai+AkO7OiEb4qJZ4EqaaNESu0M8nFRNS GU2eQCD1MC08Yf8oKbD0Yg== 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=1788975083; x= 1789061483; bh=J+UiB0JQF3J734EIk7xL8AfWMjHXBByPW0qfltoR+18=; b=E i6VKWxDNbjUvSwSiuMaKJ/IquayiuRs9o4QTkmdNVDt6gRM9cJPg3VbavKHrGWPf n4o+zAdUorDRcA9Erx5vOZG+Bm8Cssbfkm3MBVpHV4E+4ZiM45NZTV4J5C1XUuei kSbLa9pbB2VRu9zWtAnPAtf99kweTC5gEmBl4yeF0tTYCxKDEQq5iVG5tqKkHQFI 9VQW9jUqDPJ/nyuB6JSOuO03hYqd81DOi844dl6BSl+jbD1kSfuKw/1cepihTJZF 6mpdC9OoONEWwSs4sr2UR0ZjhgIfyB8U1ftpmSCpmTCz8AMkHJV+PFrTbbPoJOpF DTVRoP5VObIHdy2WHttuQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFXqFEZUnNCVBq6maUL3v38xhhrAf8GAtK+/CXoS0IWijgVEgLNpLnHNVjDlGVlDs v2hY7tvTUbKhcu8SwS2K92TuSoyVhqa+KWn7TC6YbQfS58BAB1nv1N3sqsvMkLmGhALYbL GyU/ctPmiWnfMzWE8wrxRbe9sTQmGk8DZ+5fQDhWfC3F0u2qvNKhnxBTgXb3k+4T0J4Kb7 XcVCeXE4LdKjTMQja3Cq0gf9GSuSItpIgO/ZpzH/36Riyo8o4Ec2R4ehjDJI06WvqmepHz urjDsXPLML1i71n5LV4ZtIXVzc13eMh130tNZs2yEAFcsipzsVFrm5VzV+UdoUyrm2CASt s8IzLjb/0PL1pQuo0yz6LLG/esGXiuKPxw54fVjVjk4ROjQeeQV/amrSP7irD9jug3BWtg yjr4WLPdia/H5KW+8GPjV4BtKJKQRo+yCEIXUxyUJPTa6/am5BbgpoCpvovedAFxCnVFXp vKK83Txzslf9yUG2/NM7gjRjNJccpf8/Izi7pmG87DEMZuE+iceiHKbVdSU8IJ/I7pCjhN mzJm1cSTrNsy9/L0PvRRIZ+wUfatKoY2OB9g2vhLTzsh0SLP/inewHneZhUWei7g1rdNfz Bqp1TpijQrEBwyEh1EMqvnEIgGRqceBOUhuMiA7LHqO9Ly7fGw2QZ3RkJY1w X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 9 Sep 2026 13:31:22 -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 v4 09/10] dt-bindings: net: renesas,etheravb: Add optional gPTP phandle for Gen4 Date: Wed, 9 Sep 2026 19:30:26 +0200 Message-ID: <20260909173027.2201560-10-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909173027.2201560-1-niklas.soderlund+renesas@ragnatech.se> References: <20260909173027.2201560-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 18:26:55 2026 Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) (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 6FAA139061C; Wed, 9 Sep 2026 17:31:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975089; cv=none; b=ZZ5FjX1c+GBLY0k2ffSb3TDnuUepXfq4d+QxulgW2QYeTlSqLLREWwNdzwdzQ2R4d/8YMXlVjvpvleGzj10J+vVZ9QmsA3af/94k8kkt+7xunDK82WzP3tSNfm7nMAdmQWVp4+laQYERk/utgwNrBget/sTbZIsoTuN0MsiKgag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788975089; c=relaxed/simple; bh=4KMQp8rTJQvzBUKJn9sX2qIe5GfiR1pdIJMhnTRBSVU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SMVOQPchT9/h+rCKZYXP7sF/jToTiDNVlr2ynEI5XSBiWa/J6xB+PSQMqYvUYKmNO4DclMjGoqjPm/Mxi27tD9mEP352MXzHTrmqRok2YptelN8dwZlrx034wWOAruRuMgBYfGpp/RCp3ZkR/Vdx2BvvyglnDkeEBqL7csbKkQY= 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=luBn8IA0; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=T9amcVfz; arc=none smtp.client-ip=202.12.124.144 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="luBn8IA0"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="T9amcVfz" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 5F6A41D0010B; Wed, 9 Sep 2026 13:31:26 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Wed, 09 Sep 2026 13:31:26 -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=1788975086; x=1789061486; bh=ihZEPhfAAgVdPS6YmrQJJR0q1RkJhvdyb72UKC6qyy8=; b= luBn8IA0N/t8YRPNtc19aOmjf4LyRFgublyxnjbv0Bdc+zWMFuKB6UV/vQUkEpQe +CqlaHUOLB3fMBSW/9FLJaGQKUq9HOIUeihUxluqtzryU5ic6wt9nFDypHJMJht+ XG6RzqkFvnScPdozn30b7lmzck5ix3rCVOssYPIelM/BfjUwnFOEWI2Rz2a8g5dh b13Gnl7RFUu+uFAApTSbpZVXq/UmpvAyQkY2c/thCMTja/vMdWzbe/dEM/J7Gr/t +whFwQxlQLQRIMA5l8ED7gL78OXQ61AuJdVg6/HMEMto/71rRnCruGpntIj6NkWA 1/mwg6kPArsuTClHddR/yg== 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=1788975086; x= 1789061486; bh=ihZEPhfAAgVdPS6YmrQJJR0q1RkJhvdyb72UKC6qyy8=; b=T 9amcVfz2bvnEtAS6ufAd/+v1bqGpWlrUCsHApxldGY3GT/KVvysMhStNUO27XDOj DFqsKhRIwAf/phpfQRoREbWgkKWtwy13+zsKoJCTtkZGdY4K7PwBXSeSs6GcIJxT 8PMg7uhDJOM9m9h51jGcAt7mPRhdqQQ0Vvpv/3WSettp/H9QYjzjZzFvkTknzwVD kmPg7Ywn4vWFyE1w8oCRn9XbSKK1pAeHx7RazSIXQcwhS6p8kN8Kv/lO/+6Fqv5S C4k65HuBy88uXdJcWJYACDqHY4Eb4yLw/UimkWzzQU4Nsh9dCcN6nlsWluifeaAK vzOrDYe1aloQxtY2W8oMw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFUeD2bObQ9WETToF3IY/QOFektlLy47Td8nXeDSoyFzR75aH2WHfWROwb+gG2z5i qhQ5oFT0y4K2rSmBFwxmPvTFvhvpZ6feFNq1lZpwY2t9xN+OnxEIfNpov4ISs/yEYqSikD NwhVc6CmZQP5uH9JEc7TOqdE/ACZ93Kd5U8kCOjp+r8Twj7I3pUPq7WNMNT0pfSrTOHbdL KxnNZ/xrHtGSfH/K2UjWS2ACkETqC6qR0lP3OfQqZWi9CIel9kXW4BULtzgwBB/UoVUv1m QR/NrTw8T3Nudg3xAWbZGN8Iw5WqtsQjaIQHbItaSt72RyM1u2UvvxJzzhGH4yw6tpvcJy 9lkitttXcOZwuXQpk+be/wlnkR9bnskJ0bFDOOonRVpZM8+Gn50spYKV6QqtgMA+1i7+LY diT4LhXZrfQ631OwD6HyRfL7OHyeTWC5duiP7yPc/RbNLL0WeV3gdZVH1fIPevTCWp9Mdy jZCJLHWBADbMGcJvVhnUiWH2KZXjlr7sYPVqMzCMamR3H9rzdDg9USarn3gohSZGMM7wnq 6ZHeujAG3XNZVHVfCiHx9OoFmoqB7wX39Dcg4Nr66JcR+1MlFHNHI92sYzv6SJIf44eMJU 0HjqpiRQUmGaSr9RtPtkivG40jbaYkIyUwkH94ni/ioAsvKv4+myw22nYA/w X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 9 Sep 2026 13:31:25 -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 v4 10/10] net: ethernet: ravb: Add gPTP support for Gen4 Date: Wed, 9 Sep 2026 19:30:27 +0200 Message-ID: <20260909173027.2201560-11-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909173027.2201560-1-niklas.soderlund+renesas@ragnatech.se> References: <20260909173027.2201560-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 8617c30dbb14..c8aa40136c3d 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2755,6 +2755,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, @@ -2777,7 +2828,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, }; @@ -3191,6 +3242,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