From patchwork Wed Jan 31 08:41:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13538931 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7962E60898 for ; Wed, 31 Jan 2024 08:41:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690511; cv=none; b=pCHJgKZUb/NpTDzlxkh1A/85N8M+LAn+WIYqxTszGoWtFxWQeYxhVOLiLxDHlfGD17jqcf+mNjE8wNvA3OSBXaYntY73ehETTTI3LDCYySCHzo0LhxYtf20W66EAPjkNQMA9r2GBjWuMIJwsExz3ceFIhqjBNwjv3trLK3yJM48= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690511; c=relaxed/simple; bh=aaKf7z2xB1MNtfZ9vMqWh+Wx2jdR1MK9CRLol2unMF0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jX+CkPrM9rWzTv6ejjMPjopOp4hREWt7ZWP/Q0IkBZPIfK9hhmi2w7UykZdZlyJoBNl6FGOnvnYVsTVIwq/6GT0k8MrJrvfu6sD5BmY+1Yxfab7Y4EK59i04U4vXyXfiHISiZwTu0in1g29E7IWffuJ+HgJvpLcsWbMf+4dmo0o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=a08gYhQR; arc=none smtp.client-ip=209.85.208.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="a08gYhQR" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2d0600551ebso14518311fa.2 for ; Wed, 31 Jan 2024 00:41:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706690507; x=1707295307; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3nopmGlOYDibDD0J+/Hxx33H1qRqX0KJvglV4HoOWvw=; b=a08gYhQRlIgi/qUl044Zw3FcKBfxoHa6kVj6bphuS2MGkJ4DFPrA5WtlJW0b815jEj yNNwGWK+aydDHlUSOEA8m+rdv6R4Oz6nsAN3qLyrmcuSC5iyXvsO5Bjnslq2X/seI2WU GwiXz6rhsdd/VBbthhLOmqaREsCqZ3HmEg6YXiGJJfMglgpFD9VLfr2nHWuXgnCCbvSS kFncaSuNC9qQkBv6Clwqe7Vu3zjY3ID2FaJwvTikntRep5lxVzyQwFswkupI23g8Oju8 o/K1p0ggZ3lgm/V29aZAfL0x0BhSKpgod51d/4lh32ECWTTCpX5kO/KIcRuodHs+NDXC 3SvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706690507; x=1707295307; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3nopmGlOYDibDD0J+/Hxx33H1qRqX0KJvglV4HoOWvw=; b=Qi+f5a5jNcZgkArpj19+exOSoRvWZV7GpD1LI7EOfUpriw0ex0UoSC3RI/G23q6vAl KnnLgpZwFJ31a1RIXuB1HdkaOh0Ng9i4rexmbxuU/ohSrHSoIau5uNuIptljYf8hliDF 0Ip5qKGvGkKRAtduWSD9B4rSZ6y/bZbIXrn80YjbeLLyIkbiUrD0IQrPEZXisjrpGqiN kHfcyFyh6zOxKwWgHV7l70eQb7EjicOrSEY8lGgZsp2i1PN/jQEFhFH4mkmaoU8j+7Q1 sxgugM1cXXm1InDI4lRDFkH3RKpTqSIrGWuIbEpaLv2h5lsDqKJKexManDqTzswc8A7+ dF7w== X-Gm-Message-State: AOJu0YxV+KPU1jON6GwtAJDSm7Mazym5fD4MMZOBTpyZEZbJCpEoEAVV Rd7Z4YHlfEwkXQbAQqPNhI3LDAACQoy1eY40VueHZZyRWbFo+BBKiuP2LeMq/co= X-Google-Smtp-Source: AGHT+IEEAYF9I0Wd8hE2FKGQaz5+GpmWeBgNzUkbk825w4QlQTz0p1tW17uQk+d/geaJtlQ+4a4B5w== X-Received: by 2002:a05:651c:1a0f:b0:2cf:1ae2:dca with SMTP id by15-20020a05651c1a0f00b002cf1ae20dcamr799228ljb.16.1706690507376; Wed, 31 Jan 2024 00:41:47 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVINZIQxSHU9/Pkq2gP08HOZi6sVlBy3aTiloaO6v4iewhrYb8NolbjvUFEnGcamkz60RVZQPaEpoCm25S2D3KtobY34/cC3J+5c2db68rdUesbukQ2PDk/yl+19cu49aAWhdPT214NeskIYewypZ4LhXQJHSxXq/0vNHL1pT7M9w85CYUbtVv36onuBy3h8fkBead3dgATf9weN0/9QrT37J4bi0WVVHFhY181GC00R0hhJDmS1u8wnX4mayOpbUrqzg3YginFPuCoOMzv0NMbTvYngQhtbm7KZv9ugPwHOQiC0L9OGfBkPk4agQmKusxS84Sr3ZowH7+8mR5yFucpvC3n4nnMtTKIUrPlsL3WH/Y3yIO381AzrqQ8JInMxQEBqVBW4De67HXsmJ4ghB7SRsN8LTvZ1DZiv1fJyEpxO6/t3zY= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id cq16-20020a056402221000b0055f02661ae2sm2863630edb.78.2024.01.31.00.41.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:41:47 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v5 01/15] net: ravb: Let IP-specific receive function to interrogate descriptors Date: Wed, 31 Jan 2024 10:41:19 +0200 Message-Id: <20240131084133.1671440-2-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> References: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea ravb_poll() initial code used to interrogate the first descriptor of the RX queue in case gPTP is false to determine if ravb_rx() should be called. This is done for non-gPTP IPs. For gPTP IPs the driver PTP-specific information was used to determine if receive function should be called. As every IP has its own receive function that interrogates the RX descriptors list in the same way the ravb_poll() was doing there is no need to double check this in ravb_poll(). Removing the code from ravb_poll() leads to a cleaner code. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v5: - none Changes in v4: - none Changes in v3: - collected Sergey's tag Changes in v2: - addressed review comments and keep stale code out of this patch drivers/net/ethernet/renesas/ravb_main.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 0e3731f50fc2..d371c4bed634 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1288,25 +1288,16 @@ static int ravb_poll(struct napi_struct *napi, int budget) struct net_device *ndev = napi->dev; struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; - bool gptp = info->gptp || info->ccc_gac; - struct ravb_rx_desc *desc; unsigned long flags; int q = napi - priv->napi; int mask = BIT(q); int quota = budget; - unsigned int entry; - if (!gptp) { - entry = priv->cur_rx[q] % priv->num_rx_ring[q]; - desc = &priv->gbeth_rx_ring[entry]; - } /* Processing RX Descriptor Ring */ /* Clear RX interrupt */ ravb_write(ndev, ~(mask | RIS0_RESERVED), RIS0); - if (gptp || desc->die_dt != DT_FEMPTY) { - if (ravb_rx(ndev, "a, q)) - goto out; - } + if (ravb_rx(ndev, "a, q)) + goto out; /* Processing TX Descriptor Ring */ spin_lock_irqsave(&priv->lock, flags); From patchwork Wed Jan 31 08:41:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13538933 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3C0A60ECB for ; Wed, 31 Jan 2024 08:41:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690512; cv=none; b=VEdV/wwZsPltH/MogAB7i2FtJItBB+2aR1LkHUtXjGzxSG+xRaBSK5MHDtAUG9cF2SULa4IDHqfBehWyU8P3E2qUctrKrWHNyNNNNNYm9LI7vWETcx4onE4E8+dHHnZvbZ1TE5Y9DVfJ57oi3TeIjF6dZ/S58Lu2CWPiJUyMBus= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690512; c=relaxed/simple; bh=wv9pwCG0Owxu9SDT/z9arM+oZlxF2tOjU78JH/h+iBY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=McQhqYL5vh6dvSiVmvtZ+oDjd6h1RVO2SpudOuiGkXNLto5V9eq35GcxqvRw7nUcxLt8aptlma4Xp0Pi9pOpLvC53kY/djapKpFnJ7Ve+oBWitUVV2m7QnLiRcwJhhizXmhOY12Tof8ipHGtiGNP/m6inqJYXPnkWYh6O3Il45k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=brNrM1Tq; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="brNrM1Tq" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2d061f1e2feso11101131fa.1 for ; Wed, 31 Jan 2024 00:41:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706690509; x=1707295309; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TtbdQ2QcmkuWepYwSxBRl7Waeuw6uF2b5jWIwkLXEcg=; b=brNrM1TqmhZd+X92HtVahUWkw6XkVsdYAI1vesF5iseVga9UT/jECzuxqM5dmcQ8K2 jUOn+Tm3527cp3XDgLgDCtse1bACdErB6CM30fnuiUJW0KyToOkgRFE5bQ0Ku6bBUNob HlPYpkWA7g8f1uzV8mmgOJDMvVQAnBrsB3T4+CIKbuXo2yU6bXX6YfKswgUVmvp20gCb vXXQ89hOx4Wmjzl39df1Y5nOIEkjETS6hNrsfRSltqjHIuNWDSLkPRUOwwB+UrRCVBhb SCOv2DTTOz4tPJSMifSM4CqGEjyhJQyXvhX3wZzWEc8MRo1ON+2/lKzko/oa48BtdEed GuSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706690509; x=1707295309; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TtbdQ2QcmkuWepYwSxBRl7Waeuw6uF2b5jWIwkLXEcg=; b=a4GApYSq5Hu5eVhfR5P+5n3tflEPv5TZk34lFFoa3VV+NMz4LHue62Cu++pngblMk9 9FQevFzXkQTOVet1UGJf5OSEQxnphBd2PVv+6NXEaxWuvKEk+Ivs/MAaGzo0fClda0pm gxasAYsGsI+qCsuB8mUNq2CY6Rnw/Vcjmgh860TUK6tM1rXLi5Cz+0mpIoCGMX27gQxe TuuLfy+YKPSp+3XkfojvgENtKsoVveApl5KyGfF0usSp8tdeoh5aUK/prbX6cdzRy6Kr NytC1mqDsmsg+p70UEh//aHp5OUW/9fD9qrtwtNR+3dynOoRwkLBJtTqoWHsGzZ6vqcA Ij1g== X-Gm-Message-State: AOJu0YwwOn6lD5ypKNGTKemoSdMWgEHlwJ9aotT/U4K2BFQbBaRZIbU+ Hkd+OHoJupuxXADJ9FLp5iar9TEidzZAiLjrhfUy1GQK0Q9yx0ppCWUW4wtH9q0= X-Google-Smtp-Source: AGHT+IF631H2evJImQvgomOYIAMNfTZ0qBP18fEMZ47JUk4ieaXoq+jOyqoV+GhKTJREzPbu4yFULg== X-Received: by 2002:a2e:2a85:0:b0:2ce:e49:5b38 with SMTP id q127-20020a2e2a85000000b002ce0e495b38mr636065ljq.29.1706690508728; Wed, 31 Jan 2024 00:41:48 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWpIxpMV+B0SVPGEP4wtDINumQMK/LLVB2GFLs5sHROUSelIkRUpOwm8+jxO9yqMDu1rhdUKFZOIWEHHxTrWLhjZIIkux5q92ZWuuby5tfAk44UcB98B3+mZ41q+E/NWih0qsB6r1MLRfqlEDglg1HlImJsB/XZ3v4rupSLl1M0Fwf5y8ZN7lilFRxYQTFF4pZC3XtRGOKlFYyy7dhawBhMtLI3vPmq/C53VFSKZA+xFnq7SfAPsxVgphz93s3jw+N626IaTWgqIjBB1iL9TWICrNFPRJxi5hxIBC9HG0bFdF4+grLD6Xsc3vp1VQ8nJgLZW4e//A3C+OgqHCVHaJqGYeXGUJrDHFvIF6JHFPNE5E7HdZbKJZP1bCnWQSaXlybhtyY+WFMBlug0oJS5jJ6zOGwP7hSJgTueTDOUJcaUlECaV74= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id cq16-20020a056402221000b0055f02661ae2sm2863630edb.78.2024.01.31.00.41.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:41:48 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v5 02/15] net: ravb: Rely on PM domain to enable gptp_clk Date: Wed, 31 Jan 2024 10:41:20 +0200 Message-Id: <20240131084133.1671440-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> References: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea ravb_rzv2m_hw_info::gptp_ref_clk is enabled only for RZ/V2M. RZ/V2M is an ARM64-based device which selects power domains by default and CONFIG_PM. The RZ/V2M Ethernet DT node has proper power-domain binding available in device tree from the commit that added the Ethernet node. (4872ca1f92b0 ("arm64: dts: renesas: r9a09g011: Add ethernet nodes")). Power domain support was available in the rzg2l-cpg.c driver when the Ethernet DT node has been enabled in RZ/V2M device tree. (ef3c613ccd68 ("clk: renesas: Add CPG core wrapper for RZ/G2L SoC")). Thus, remove the explicit clock enable for gptp_clk (and treat it as the other clocks are treated) as it is not needed and removing it doesn't break the ABI according to the above explanations. By removing the enable/disable operation from the driver we can add runtime PM support (which operates on clocks) w/o the need to handle the gptp_clk in the Ethernet driver functions like ravb_runtime_nop(). PM domain does all that is needed. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v5: - none Changes in v4: - none Changes in v3: - none Changes in v2: - collected tags drivers/net/ethernet/renesas/ravb_main.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index d371c4bed634..3181fa73aa32 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2780,7 +2780,6 @@ static int ravb_probe(struct platform_device *pdev) error = PTR_ERR(priv->gptp_clk); goto out_disable_refclk; } - clk_prepare_enable(priv->gptp_clk); } ndev->max_mtu = info->rx_max_buf_size - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN); @@ -2800,13 +2799,13 @@ static int ravb_probe(struct platform_device *pdev) /* Set AVB config mode */ error = ravb_set_config_mode(ndev); if (error) - goto out_disable_gptp_clk; + goto out_disable_refclk; if (info->gptp || info->ccc_gac) { /* Set GTI value */ error = ravb_set_gti(ndev); if (error) - goto out_disable_gptp_clk; + goto out_disable_refclk; /* Request GTI loading */ ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); @@ -2826,7 +2825,7 @@ static int ravb_probe(struct platform_device *pdev) "Cannot allocate desc base address table (size %d bytes)\n", priv->desc_bat_size); error = -ENOMEM; - goto out_disable_gptp_clk; + goto out_disable_refclk; } for (q = RAVB_BE; q < DBAT_ENTRY_NUM; q++) priv->desc_bat[q].die_dt = DT_EOS; @@ -2889,8 +2888,6 @@ static int ravb_probe(struct platform_device *pdev) /* Stop PTP Clock driver */ if (info->ccc_gac) ravb_ptp_stop(ndev); -out_disable_gptp_clk: - clk_disable_unprepare(priv->gptp_clk); out_disable_refclk: clk_disable_unprepare(priv->refclk); out_release: @@ -2925,7 +2922,6 @@ static void ravb_remove(struct platform_device *pdev) ravb_set_opmode(ndev, CCC_OPC_RESET); - clk_disable_unprepare(priv->gptp_clk); clk_disable_unprepare(priv->refclk); pm_runtime_put_sync(&pdev->dev); From patchwork Wed Jan 31 08:41:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13538934 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB78D64CC8 for ; Wed, 31 Jan 2024 08:41:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690513; cv=none; b=LIp3RwipH1NNzcVJZBer0jSrnY+7zPe6eohpvL/U5Zt64gaj9QV4nBTQPj0mCtX7iBN3EKRx8yibRtDxxMCbc5QHS6cARQZ1hQgIFq8hZgYJbBZts2sdmgwjb/vNxRX8VDJ9gF9p5XhQX383GxpXj7ZTAK95D4/RRstvqeWw8CY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690513; c=relaxed/simple; bh=DYWljhVkT6KFyv0smmpo8+LSYn9vUohjIj0Lmz3vjh0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JpuwDnVDkddOa+obF78mmTru9v9qCp4g+rsiDp0kJbXjnZf3BxZ2xqSobSx99+TU/J68g7K3TYh/dlCYUDtK2iUKtrA8ZceLjCzQiOnzPZDKDJZs4tdCKQcEXIxYPB1kVEPndPKV/5bUJAktnS64wn+HiHvwMc63Op2z0BFaXBU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=T13fc2CK; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="T13fc2CK" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-55ef011e934so4243054a12.3 for ; Wed, 31 Jan 2024 00:41:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706690510; x=1707295310; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CaQ1tM25xxhSkLymulSrQ/sxhsU4Dz/iC9pZh2/7m5Y=; b=T13fc2CKmbKiLV8ntMXOuzMWiM9L3y+2eMYv1/FLeNzzWbbeFI3nFFeAypeFWngDzw /xHLmfPdbjANmPnXOp3YdwO0I63JgFxIq8O2MqVAe6fiyrdeB+YQ0FXv6+DY/e1NJ2lw 8kLhQ1v/Huhvu8faQm6YojoB1hzq1s8rPSP60dF6IF0BRVUjfNdtF3mf+x+m0IjFt6gn rk87Bj1GCNrtGns4Cdxr0Q+oRocuRpBrahh/FB2yCa7UFXUdvEKcs96527LY1DgBk6U+ YBw5iA0qQbebfA5B6uAIWiFo1vSONRrnsz/gQ9BFYojdAKMT3bvkoNO3iXAu0P+SzxJZ h9wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706690510; x=1707295310; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CaQ1tM25xxhSkLymulSrQ/sxhsU4Dz/iC9pZh2/7m5Y=; b=QgjntLQyIwt+USa5GArJdSh6VHH1YlXtakCFIMzDIktTqekV2SeYprW4QUrgfyDVLg N6Bx3zPEBn2PasUX6YL2l6rRK7mMCYoP0qZkZQdSn1pHnG2wZwgbMoaM6/RORMk8IQL6 aW/RbbNfZe7e+p2SlmCHcSbBbOkbRmU4UO1F4ymVnRNNN/jvXsNeeeYxatUowp14BKF7 uWa9+aE7+RVOf5XMxKtpea6dQWIUTeFkMOO5j8jpuscyP9dORHtdGyIVGVcdR3u0+fAZ JTt+WY609kOiNDnfGUyb51cDayCuqONvMCImK/e1/vMXX1Paje/OBnF2iUqaX7EzwerH xwIA== X-Gm-Message-State: AOJu0Yw4JKsYA3kcN8NpzeNY3wn7vUi7pEYC4xFvfLP/M6/A2luTm7Vi NTCa+rne6iB7ymKYaIiKzPyl+v1QT9J0HPOKyoyxJoeR7iLhukHsR45o9sgiWK+wdp5weQfkhib x X-Google-Smtp-Source: AGHT+IF5BkGFz/B9L2bagBNqDLFe2bl641/IcLpz4A4txk1UEazfadsTjRphU/mfT3oGj/T96KNrlA== X-Received: by 2002:a50:9f89:0:b0:55e:fdf3:d440 with SMTP id c9-20020a509f89000000b0055efdf3d440mr558641edf.39.1706690510118; Wed, 31 Jan 2024 00:41:50 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVILS4ofhnJK2GcMawFhlhzzqgG8pnSa60pPFIYUZoW3krIL0pxFlmGRFwyR8iEW5S079Dwnn/bWZdRqsDKI+8GvRuMC5EqTkagEnozBI9FsMSbGifRxz+Iqv553HiNp1XRnWZPSm5uiaWphDAjJDOVFQSP6awKxlX274xeUJKl+pwXuebiC18yjRxtWvdyYe2VWTs0Bf/zTFTWXdSzbCmDvmh2nUyko/y5knR1VeSTV4y183DNEc3+3gkIfwcoDBCtqGQe7emxO9/RH1vw3PXZ2D58TReRsiFAGCcp5NtObp9/Q8je6HKXD2CgOMOh5mqo7IR4RQ3YqA0U550qH0qdoYfD4wKuttguCN90vmuaXnbG4fUIxbINhP/bxx2m/T/gbTwgM82F/4ENbLvQhWXCOZORtSivIi9aJh1OLsNDlTB8jeg= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id cq16-20020a056402221000b0055f02661ae2sm2863630edb.78.2024.01.31.00.41.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:41:49 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v5 03/15] net: ravb: Make reset controller support mandatory Date: Wed, 31 Jan 2024 10:41:21 +0200 Message-Id: <20240131084133.1671440-4-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> References: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea On the RZ/G3S SoC the reset controller is mandatory for the IP to work. The device tree binding documentation for the ravb driver specifies that the resets are mandatory. Based on this, make the resets mandatory also in driver for all ravb devices. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Change in v5: - none Changes in v4: - select RESET_CONTROLLER - dropped Geert Rb as I changed the patch again according to his indication Changes in v3: - none Changes in v2: - collected tags drivers/net/ethernet/renesas/Kconfig | 1 + drivers/net/ethernet/renesas/ravb_main.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/Kconfig b/drivers/net/ethernet/renesas/Kconfig index d6136fe5c206..b03fae7a0f72 100644 --- a/drivers/net/ethernet/renesas/Kconfig +++ b/drivers/net/ethernet/renesas/Kconfig @@ -34,6 +34,7 @@ config RAVB select MII select MDIO_BITBANG select PHYLIB + select RESET_CONTROLLER help Renesas Ethernet AVB device driver. diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 3181fa73aa32..fd431f1a0b98 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2645,7 +2645,7 @@ static int ravb_probe(struct platform_device *pdev) return -EINVAL; } - rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); + rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); if (IS_ERR(rstc)) return dev_err_probe(&pdev->dev, PTR_ERR(rstc), "failed to get cpg reset\n"); From patchwork Wed Jan 31 08:41:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13538935 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 349B75FDBF for ; Wed, 31 Jan 2024 08:41:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690515; cv=none; b=PJxX6koJ8bTSBbZg1mv68pMyO7MMn1dXql2pGSpJLVqbBY2HclZQJtifk6Q/egeNqGGsbtfKwgGcu0FlX1z4vrXMTJMe38bCQDMqoW3zIm4B8BdqhIWBKZaXSaXSmiPi2U2zlFqelqwnprArOEJ1yEzGmN7CiRS8tSSO8YRI3Qs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690515; c=relaxed/simple; bh=dklOpKsyY20gACcIKy4CcTI5WliooZ2yY0L9WV+xUdM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qqD4DeZmE0u6iECo8Kn0Q3cnLsjMABqXUd6PpfwoGjujZTqSKB+fQJZ6UMTYolZiH07vy50nWi0qltZXE3a35VQDjPu9oPa/TnEI+TzbEwcpSQ7DGnpFuljr2awg8T/vo1YSGaK2SpRPHAZoWdHTQU8yeInV7TpviBOE3YIOyQY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=m0W6mpSA; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="m0W6mpSA" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-55f496d60e4so1928973a12.2 for ; Wed, 31 Jan 2024 00:41:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706690511; x=1707295311; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NJFy8U7M4bryV96Zq0jRThjn9Ebbq49lbecxpcNk9ss=; b=m0W6mpSAbEY1ButKbtsIumfUuDxjn0xYXCZNY6+zbpuDLKLoEM/OSCCpYJSey0e4+t SYSRYlKK15UcKLOM6/YBEsrj2rTSEiIOmHJcXJdAphJMNK0NFsD4YzTmZf5JJ9U/hU97 KiK0Ts6GHBnvQDDGdyExxVJ043zMcuT954tn6e7LT02Ik+b34wYKmix/rTV1E/0IQBsJ i0lf8jX2JTfwHrBDFiWZ3VhST6j3nGGD4fonaUybymQKS/q7XDjCPLqL2LpXhyXo3f0A PmOSy/v9ceQZ8JyfjSTZG5dqxKpuL2I4oyjxKXPFN/Ns0PzAh2PGFTzq+koyHUB/LTPj eUCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706690511; x=1707295311; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NJFy8U7M4bryV96Zq0jRThjn9Ebbq49lbecxpcNk9ss=; b=eXRQXybFP8rjfU/3PIPVjzIPZ13pet4SDCkYKsBeiv11ovTEnyKwdsdTBMvfjpDMMx Jhv6HWO78cDrIZtmn0fsR09xjbyaRaw4iLR/4BU6lv0Gtpvxj8kzjc1gI7oO659/VOCz /QbRwS4CFSSH0wygzkybg6r8ls4ev1P1bAm8CNL9TJjxLccFfD6bPQz3kuJc+rvGi+oC o6YDc0JY3XBkMi2Thm+G0447gxmVG/xfPGxwBTxRGCqcpGNW5GyYWxE6qnQn7ftKLulh UbFH97eYUho2P5VO5+GQINOBiKvBA1FCDhSDYTAunx9E0PrVHxbb+muHpt5r9G0FXVpp H0FA== X-Gm-Message-State: AOJu0Yxdl2RpZx2KPcOg2N5hJOxIXmtICSD0sf7lR49nLoIZEzGnR7ka eLKe39funik6fZdI0efnRE30ptJTJXPqv7NLupxHvqRUgPBW8bKYkff/d7jxXXE= X-Google-Smtp-Source: AGHT+IHul4OILIaDxbopgzMq6EJx+ujTxObFmE8uaf6iDVoivEW5FCjWHMGKN9JeHQe0LoLwdJOkRg== X-Received: by 2002:aa7:d897:0:b0:55f:28cd:bb42 with SMTP id u23-20020aa7d897000000b0055f28cdbb42mr592294edq.10.1706690511422; Wed, 31 Jan 2024 00:41:51 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCV8slgI9Hwzsyh94xWW4P4Yqr9iv4C0VIpCYRduKf57Dtl4RRbiTtpnkv2ZwxvT68F6trj1TctScQGC1SDmZO6no2g/DwBJ2h16HKx9o5OceLICxeOWdL98irFE+qSvM9yn49kozVT0Vcu/aYBtFjGuF1RE6TH1OUrsgh+RJ+6HRBlCzeQTvx0AOv8U62lFdyz6cxiFddW3NIZonD2nPUddsaTMbfvHIJgH4fEnLkv0v+UxJSc72bK7SfdvaR9ciMdq5K+ZNu4fiXZLQV1J1ikakBeTy3sC9c8M7UD4qskc0n3ixJRdXWLNbtwgVRH6lvUJESHfyulsO1X3KnAgOKsY2rYIk1GitSOLyyI2hInYPK4T4oMggNp/6uaMn/OaAcFbTvtS1eFQp62WRD979AjzRPzPudN3VhT1ndqz+dHuNuW3mD0= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id cq16-20020a056402221000b0055f02661ae2sm2863630edb.78.2024.01.31.00.41.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:41:51 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v5 04/15] net: ravb: Switch to SYSTEM_SLEEP_PM_OPS()/RUNTIME_PM_OPS() and pm_ptr() Date: Wed, 31 Jan 2024 10:41:22 +0200 Message-Id: <20240131084133.1671440-5-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> References: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea SET_SYSTEM_SLEEP_PM_OPS() and SET_RUNTIME_PM_OPS() are deprecated now and require __maybe_unused protection against unused function warnings. The usage of pm_ptr() and SYSTEM_SLEEP_PM_OPS()/RUNTIME_PM_OPS() allows the compiler to see the functions, thus suppressing the warning. Thus drop the __maybe_unused markings. Reviewed-by: Sergey Shtylyov Reviewed-by: Geert Uytterhoeven Signed-off-by: Claudiu Beznea --- Changes in v5: - none Changes in v4: - none Changes in v3: - none Changes in v2: - collected tags drivers/net/ethernet/renesas/ravb_main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index fd431f1a0b98..7ced5db04f75 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2971,7 +2971,7 @@ static int ravb_wol_restore(struct net_device *ndev) return disable_irq_wake(priv->emac_irq); } -static int __maybe_unused ravb_suspend(struct device *dev) +static int ravb_suspend(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct ravb_private *priv = netdev_priv(ndev); @@ -2993,7 +2993,7 @@ static int __maybe_unused ravb_suspend(struct device *dev) return ret; } -static int __maybe_unused ravb_resume(struct device *dev) +static int ravb_resume(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct ravb_private *priv = netdev_priv(ndev); @@ -3052,7 +3052,7 @@ static int __maybe_unused ravb_resume(struct device *dev) return ret; } -static int __maybe_unused ravb_runtime_nop(struct device *dev) +static int ravb_runtime_nop(struct device *dev) { /* Runtime PM callback shared between ->runtime_suspend() * and ->runtime_resume(). Simply returns success. @@ -3065,8 +3065,8 @@ static int __maybe_unused ravb_runtime_nop(struct device *dev) } static const struct dev_pm_ops ravb_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(ravb_suspend, ravb_resume) - SET_RUNTIME_PM_OPS(ravb_runtime_nop, ravb_runtime_nop, NULL) + SYSTEM_SLEEP_PM_OPS(ravb_suspend, ravb_resume) + RUNTIME_PM_OPS(ravb_runtime_nop, ravb_runtime_nop, NULL) }; static struct platform_driver ravb_driver = { @@ -3074,7 +3074,7 @@ static struct platform_driver ravb_driver = { .remove_new = ravb_remove, .driver = { .name = "ravb", - .pm = &ravb_dev_pm_ops, + .pm = pm_ptr(&ravb_dev_pm_ops), .of_match_table = ravb_match_table, }, }; From patchwork Wed Jan 31 08:41:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13538936 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 524D16994A for ; Wed, 31 Jan 2024 08:41:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690516; cv=none; b=Zwd6l3Z8gCVfNgwUramSybOyDsi918E5ygASJSoCBmfp/kCU+McXesLlMwUI73+Q8VtBSpfQpfkhkAABKaca93xHuG2ijdNA14mMzZIXIZbra9190U0Clnd4GOxZOnFl/vwjwPEDyuyd2RjNBjgvPfUhVqY5glSaGLKPDTeo4rU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690516; c=relaxed/simple; bh=F/pQ43TZd0yxTybIVFp9YQ1lJIzC8KcINVjpd5TwZSY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=S5avkXc1GkguhdEbQrF6NPeRyab5aEKuq2/KeFl6l2Fa5onfETuTOlAnRzgbNzdWFPaRh1Pd+0w+fmBJ8k24xGdmgErv1BSDgmsKeJslJhkZiX8MxDvbq33pLKdaWUh3DcrhIy7iI2AlJsGUqMXme7rwSSalzcDM2/CT6Fh6e7E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=qK9X4mmE; arc=none smtp.client-ip=209.85.208.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="qK9X4mmE" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-55ef011e934so4243105a12.3 for ; Wed, 31 Jan 2024 00:41:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706690512; x=1707295312; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1vYE6VGGaC6dDiCeRDs1uRAAsGK/Jz27M4TajzPwZTU=; b=qK9X4mmE5DLWMZWhaS9MWU+C2slURJijqI8YhKW/Q+vL34nR15YleS8d9UkD5vYNwO Dl0SXDQ3mQyHSj4ZEgq1M60xE9HTv1a2WKluPF9ykz+f0cbYWiFjST2lAnRVsSWLWN1U IFICrTWAI24bKUFDqHamoqngpLgPeEWK3T1b9pVqh9kuh5xg+jR5qmTjdiChL0CxOurm Crzqdf8HxOZaSe8ZcnBlSBupcU8Jjff0grup1QZPPq0yGZy8+4KBpMfEni3alSa4IdQk 73UDiT2pJmspsAkoC8hoCb22zfT84OFsVegPNR3wY4zaRBWHCvVWWVuLjjDaKlHaLBjL au8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706690512; x=1707295312; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1vYE6VGGaC6dDiCeRDs1uRAAsGK/Jz27M4TajzPwZTU=; b=tmAl/fXiZEAvtF0YPhuyeTIsCaqrOR9PTWFnnRlg6BGjX1cWIeqjbyREISWeIHDvvt 7DWXDuCJg5s011sgmYJ/stSmobAsy5XWQ1DDszSIX37LMKdUogn5mxFZkbGdLPiIxN81 nokN34Wv82FzkmaH7tk4lln4vxn7hsyPbIIJEIJE20pSeImEpY2o8VlNHdnzilKOkUso z+MknNW4JmPOAPZLsGmNDYZn7MVBzCCI1V3AxbZ7oP7IVtXm0ZJdesPA0+sEGCLUxRF3 rbBu3EVyJOBwqW0Xk4BawGkzZ+oGidAvKNLYIl9OazjNrWvr87hTRRBL0bvJraBxMzVK 2M8w== X-Gm-Message-State: AOJu0Ywcj/vrNGuiEOPfaN9MSP6PsF1Z6bUlHpaInwyob2ixGAFlhY+o EpzKa9Qc8U2WMNp4QB34ycyOhzvf377LzF9Ha7hTTWmrroVXYhOo/VgzW7d+xLM= X-Google-Smtp-Source: AGHT+IHLjjLm2buuFTHLorPXWtx/2gEZscx3uUOOI2BYIpDUfFOz4Fkpbg1fZxfpiKpoVOqiOswEgA== X-Received: by 2002:a05:6402:64f:b0:55f:3cb:9cfa with SMTP id u15-20020a056402064f00b0055f03cb9cfamr628504edx.30.1706690512682; Wed, 31 Jan 2024 00:41:52 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCV5j7LOeqH5BmenUWvzCmo2qCBc9iYVyjhYr3FrubKe3iWE6KVctdP7hRDi8vvMV1Q+Z/GBABR1kHRE/19Feaj8Tv5TKj2vG+Y1h7Qg9GWhLxmuK4SOiiCd/fg6jwaqha6DLNmRN3B7cvztCS5qZY7GmEejRWlMPHS1cLsERSl0poDKOuR/jUa+JK041ZemacvNbKxy0yi9aq+MpyN3f2QfeUjTJHHkcP+gTeTEFQEQGCxLgm3sPl03aXZtF/pcb0mVL6FH0Kus3Jouon0yMqSlipCYQlqwZCRx138lUr2e9CO+mP3SSzBkvOGbfyyvrKeKqP7866Ux+DnkG6x5ZCiEOwZ4sp0hg8Trf3Hkn576aEDaxhOZcH4+GtV4+LXf7qVxNfvm7/hiD8YvVxjOImQOYVomJYQu+BmCtsi7zStfwy3cMxo= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id cq16-20020a056402221000b0055f02661ae2sm2863630edb.78.2024.01.31.00.41.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:41:52 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v5 05/15] net: ravb: Use tabs instead of spaces Date: Wed, 31 Jan 2024 10:41:23 +0200 Message-Id: <20240131084133.1671440-6-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> References: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea Use tabs instead of spaces in the ravb_set_rate_gbeth() function. This aligns with the coding style requirements. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v5: - none Changes in v4: - none Changes in v3: - none Changes in v2: - collected tags drivers/net/ethernet/renesas/ravb_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 7ced5db04f75..c05d4a2664eb 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -96,13 +96,13 @@ static void ravb_set_rate_gbeth(struct net_device *ndev) struct ravb_private *priv = netdev_priv(ndev); switch (priv->speed) { - case 10: /* 10BASE */ + case 10: /* 10BASE */ ravb_write(ndev, GBETH_GECMR_SPEED_10, GECMR); break; - case 100: /* 100BASE */ + case 100: /* 100BASE */ ravb_write(ndev, GBETH_GECMR_SPEED_100, GECMR); break; - case 1000: /* 1000BASE */ + case 1000: /* 1000BASE */ ravb_write(ndev, GBETH_GECMR_SPEED_1000, GECMR); break; } From patchwork Wed Jan 31 08:41:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13538937 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0E9469973 for ; Wed, 31 Jan 2024 08:41:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690517; cv=none; b=NzkZ6Zl9L6ySstZSdEVDOy695oqAM+GeUhj8NSUnoW4rdsgMOpmxcd9muI7ac9jeG1CneiunbaBhFKVQKm/6nr0mjb4TYcYhiDcZMEG07M1SLuFZdLS6lSO5CZXfE4EpMxcljdT/XrmaD0pd3mEYvH70DeEjGnFD/Aj0E47KTCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690517; c=relaxed/simple; bh=/PWJylbKKwrgWlPJgrOJpkH0IScCVBZN792i+Gp+2SI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G56ngFjUxmkVceiKZuccoaxV6S0Rzu+F4mpWiUlsSJpHfWfQy6ddQhpuBnZdSpE9izn10DDqcIYh8Z5ayQcNM7jH9VkYBb3TVa/JYPaDr+C5ySr3ZyaMIm74+ltsigoz/zcrIAOD7+cf4VZ2wo4QjSR8we0nuEiCZ6B6Ik1PPn4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=qXe4WuFF; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="qXe4WuFF" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-55cca88b6a5so4946321a12.1 for ; Wed, 31 Jan 2024 00:41:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706690514; x=1707295314; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=itOIGVA3R7eyMhVQYhNOchTm4KKMCVx7yc0jtC14CEA=; b=qXe4WuFF/jIibmNYjRzxdXnwE2P7yHJJUwh0IX/kXluVSkktU4EJ5YB9Yz1se12gyb qqFc3DLkPehoPlU47mcs99zFFlrafTGISMkBIdy5VnM/Yt2Tw7l+e4paoGzNC+1XJqOK Qpxomv8J8fUBNuoyfJkS6ZHYciSWPqrq2768P+qPTsD0gtGk6/NRveNghVVAw4lFL6j0 IznFAQTgtaWJI7emXI5XuG3xXTIJUi6LSjglhS3dqCg9XGQNSFmXS4Oa1rfIjw1E4tuQ mpcYWMVzDgMBzb8WnW13EDqVcDRmPxjgo2HOPpxKMZnWU5YQAxqGu0+pd7cT3P5KoHJX AktQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706690514; x=1707295314; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=itOIGVA3R7eyMhVQYhNOchTm4KKMCVx7yc0jtC14CEA=; b=m5y8AjWuNGW816xOKG7SzdDMZhk/vNMiZ1p9tAgpO/ws0nM9AlI0fY5/uARb7u8pp+ 8ZUAVCqzzqMvdyyOgaCUIEDsXIwxiruDeCGWdrQMbEgP6wrIwBLxR89EB3qf82k22kPp sBaFw0c02GTHoWYSXl5xr0jL6jAeONBN36dN8KrmQwI4n3+r8S1hJJnNjNrTQMjtTumL vvti9EpePMqAjGKX6LkcbkTZxYISb7Ar2ZRSHMsA+EOdT78my7yZOGUeQpSgs7FrzGeS MYv5BRAtouUbNUKhO5zYVZmwQJ+Tlgh0su7frRqBkVqe1z+dRB/ixnt7bc5nl5JGrtsN 5QsA== X-Gm-Message-State: AOJu0YzW9UQvSkWTaRawa9EGd+D+fCFApSJkYFtX+nACmUwxH6q8RVLg LS7foQ63YC4CTDzPbNOe2g+n6j6hHXDla9lprKzXkLuNzCUHz7Rzk7QvTj+DHCU= X-Google-Smtp-Source: AGHT+IG9rGImo292r2RZzxIGuzmZgarHtrrUyPsuHv+Si+ydCummwyBkISc94Tv4f6xKXAs77SJF1Q== X-Received: by 2002:aa7:d295:0:b0:55f:80e1:29 with SMTP id w21-20020aa7d295000000b0055f80e10029mr581032edq.1.1706690514031; Wed, 31 Jan 2024 00:41:54 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVOa7jtGLIUOzbqQlRyo7VdLl2vPSo50eXt1GVm+ze22BKVkK2vAwQy30mcxXXWsk49Buip2FgifGbUKUW2PKpUWqAxmUMuJPFTiP/vj858c1fKxX+GaV2MdSPu6afhocNYu6xXgCCFFiw4M1DsMKuRNOddHzMKyC5qi+5CIpPxIOMyp3owAsm1+BPXn9vsRO8g5KgLFhpp24J+2Y2u3sBBrS3KykLjVXlT6eql1dTjJvd94SsjGKMbSWYKQH4srHfakkrivvKiYVNO+P1dz6X1EblE1bzDg6z/0+eepILVQtQXUOrwHhJDQcx2SZHomtAyz6KtrGSXZt1JJA4I4KpO0mCro0agXucYU6V2IwqSddMpQN3Gl6gZU5hRusy7WnqkYW2K7ZecZ3spdSYslbfAjaGIWM3SVu1ccNtTTXlVgqR0U0A= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id cq16-20020a056402221000b0055f02661ae2sm2863630edb.78.2024.01.31.00.41.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:41:53 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v5 06/15] net: ravb: Assert/de-assert reset on suspend/resume Date: Wed, 31 Jan 2024 10:41:24 +0200 Message-Id: <20240131084133.1671440-7-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> References: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea RZ/G3S can go to deep sleep states where power to most of the SoC parts is off. When resuming from such a state, the Ethernet controller needs to be reinitialized. De-asserting the reset signal for it should also be done. Thus, add reset assert/de-assert on suspend/resume functions. On the resume function, the de-assert was not reverted in case of failures to give the user a chance to restore the interface (e.g., bringing down/up the interface) in case suspend/resume failed. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v5: - none Changes in v4: - none Changes in v3: - collected tags Changes in v2: - fixed typos in patch description and subject - on ravb_suspend() assert the reset signal in case interface is down; due to this the Sergey's Rb tag was left aside in this version drivers/net/ethernet/renesas/ravb_main.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index c05d4a2664eb..c2b65bdad13c 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2978,7 +2978,7 @@ static int ravb_suspend(struct device *dev) int ret; if (!netif_running(ndev)) - return 0; + goto reset_assert; netif_device_detach(ndev); @@ -2990,7 +2990,11 @@ static int ravb_suspend(struct device *dev) if (priv->info->ccc_gac) ravb_ptp_stop(ndev); - return ret; + if (priv->wol_enabled) + return ret; + +reset_assert: + return reset_control_assert(priv->rstc); } static int ravb_resume(struct device *dev) @@ -2998,7 +3002,11 @@ static int ravb_resume(struct device *dev) struct net_device *ndev = dev_get_drvdata(dev); struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; - int ret = 0; + int ret; + + ret = reset_control_deassert(priv->rstc); + if (ret) + return ret; /* If WoL is enabled set reset mode to rearm the WoL logic */ if (priv->wol_enabled) { From patchwork Wed Jan 31 08:41:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13538938 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5063469D39 for ; Wed, 31 Jan 2024 08:41:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690519; cv=none; b=YgafkJMQFzVGIIxMHnYZ2PW7rbv3wLxJpH7OuBssG8nd42kStePZAP6C0O3RMk0ZwY/D6wklA1qAPb4DDeO4NX4yQrBhsAFFJyf3Iqv3e3RskxewhVfmOb1xSFQYeskmvzEvf9cedMme/xvpXmbf5BWpQRGBFQjiwYwfX4QP4s8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690519; c=relaxed/simple; bh=Is0c9bbZxCn+5Ie2CiggMb3E43fx7P0CqT2K/j3UZX8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NSIGFsuzdNPFi7//PccThiQ2NzfXpI4e9OHLhJhSPl+ZN10Y5KKGuWXmEZwY30x06G/CXClNNYG5oNQiBw4ZYQyidsupbLbPk1cHC4PLhPhVaRA8TEYfbGn/n7UUug5UK04oxM38H0Z5MS6WFlKKdLOXg6/3/xxDFpnphY/zrro= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=fZ1HZKrF; arc=none smtp.client-ip=209.85.208.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="fZ1HZKrF" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2d057003864so23610131fa.3 for ; Wed, 31 Jan 2024 00:41:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706690515; x=1707295315; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=21CiIC3Re4xYSF3pmN76UhVGc5ntYa8GN7cTx6QHvzc=; b=fZ1HZKrF6wjrxPmHlDwh8Yu8NQ6C2EOmqwg6TLeBI5gCW7vJSGs7m8jAZ5/mumcxct CoXERaBM8qFYaAe7b7yZv3cOnIS1gPewhgA+b/xaqkflqtu3sQ3uhHskQFv+ovsE1ioC rzNpYk5S9LGiszOzYjPCR2uCnVOIxBalQBNTj8mzOVfWHQjK8jm790RURKYlklXgIwmJ o83ecksGHfPfEneQzp5RHckoOG1xlMsUBkgSUPzqLfTNbNpJ5AmhX7qxi83MfOVUl6Sa R5GASdgPfznSaV80yDw4mRMvLm0cRQlzydDuSLp461olZgKlvI8s+jhw0L1rFv1E9g8d qnUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706690515; x=1707295315; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=21CiIC3Re4xYSF3pmN76UhVGc5ntYa8GN7cTx6QHvzc=; b=Xs7OhU5XDUi4Xr8ZEjqM4pFNAqLKFfM+NqnRyp+xUEMhToFe2hjBDQqZMOQuHCBIWW RGfhoCm4jpguJjM7qsw1xd0Xs7CUeWKRtUsJrZtnyiCDH1n2+LhpWcLO036jgQSfA0jR nKq4eubP8oGzNOmioUAkL0WsbqQNiAiqhmkY7YKe4CQzAoCwTuiLGdXDPfnsLnObopr/ Aq8NfYiPRik/qivxLp3dQjCt/jJxkU5AfcRL3RzuvhiUqmOF4gqThMMlXUwWwucL/0js Xj4rcutTGXTleacVcRqVSkiCK4U+igOLXvDZroGshdfS9x3ofXyCel/q4+kjmDdIJ2rP dCxg== X-Gm-Message-State: AOJu0YzDDRZZcX4lWfwj6qBbOo9IwiKIxrVxHKczZ9crT2MdM5/7whaT 9wFCjHRm0+WlAAnsm+mCtNg2fOydoUF0USu7Q08NeHaukNORCbH5tjLOCyCQbFY= X-Google-Smtp-Source: AGHT+IFtQU8M/3t+PU68pmwF9qXrG+6DN+Ca+1ziZ/MUajC/pTFxMvAg1cQRYLPHX8Fg47+RY7XCog== X-Received: by 2002:a2e:b6cc:0:b0:2d0:55ce:63d5 with SMTP id m12-20020a2eb6cc000000b002d055ce63d5mr610639ljo.26.1706690515351; Wed, 31 Jan 2024 00:41:55 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXwbCelHuuEVd3jkGZb91vi+k/bn3K+Yms81FHit1cGJUnzwVUyxYoq66cNIuG/rUtYFlNfAMKT7n9kknSc4xE6jYnTRyVd75kU6uBLq4Z2Z95QyP31acE5kUc+8JfNHo1GfDHiglw3WbJtxXUjmUTJCemcGldFrzfRUdls+JkT6Gv8lLhIi5S+llfUFuhM9jbbq927RoMqY2ad3dQyAUtw74xrLFS3tNqIA6ApsBi28snEtGohHg7q9d5qwvwiSemZ8ppqEOIsMZbhqviFSk1g/XlO7JvngE7UV29FHolXlF9uOIWKTDpzaaUZPU2Hnnn/s0lj8W8lPSfH9InHfnRJo/BYys8T+4nqrWZ/rpj7wS68n6rJn0KhqzZA7qEBF4dKEgiupZxLtIaFptXTE4VRuRlbQClNLkUYCQBKJymDuaURtxQ= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id cq16-20020a056402221000b0055f02661ae2sm2863630edb.78.2024.01.31.00.41.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:41:55 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v5 07/15] net: ravb: Move reference clock enable/disable on runtime PM APIs Date: Wed, 31 Jan 2024 10:41:25 +0200 Message-Id: <20240131084133.1671440-8-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> References: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea Reference clock could be or not be part of the power domain. If it is part of the power domain, the power domain takes care of properly setting it. In case it is not part of the power domain and full runtime PM support is available in driver the clock will not be propertly disabled/enabled at runtime. For this, keep the prepare/unprepare operations in the driver's probe()/remove() functions and move the enable/disable in runtime PM functions. By doing this, the previous ravb_runtime_nop() function was renamed ravb_runtime_suspend() and the comment was removed. A proper runtime PM resume function was added (ravb_runtime_resume()). The current driver still don't need to make any register settings on runtime suspend/resume (as expressed in the removed comment) because, currently, pm_runtime_put_sync() is called on the driver remove function. This will be changed in the next commits (that extends the runtime PM support) such that proper register settings (along with runtime resume/suspend) will be done on ravb_open()/ravb_close(). Along with it, the other clock request operations were moved close to reference clock request and prepare to have all the clock requests specific code grouped together. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v5: - fixed typos in patch description - improved patch description Changes in v4: - dropped tag Changes in v3: - squashed with patch 17/21 ("net: ravb: Keep clock request operations grouped together") from v2 - collected tags Changes in v2: - this patch is new and follows the recommendations proposed in the discussion of patch 08/13 ("net: ravb: Rely on PM domain to enable refclk") from v2 drivers/net/ethernet/renesas/ravb_main.c | 110 ++++++++++++----------- 1 file changed, 57 insertions(+), 53 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index c2b65bdad13c..e70c930840ce 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2664,11 +2664,6 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_free_netdev; - pm_runtime_enable(&pdev->dev); - error = pm_runtime_resume_and_get(&pdev->dev); - if (error < 0) - goto out_rpm_disable; - if (info->multi_irqs) { if (info->err_mgmt_irqs) irq = platform_get_irq_byname(pdev, "dia"); @@ -2679,7 +2674,7 @@ static int ravb_probe(struct platform_device *pdev) } if (irq < 0) { error = irq; - goto out_release; + goto out_reset_assert; } ndev->irq = irq; @@ -2697,10 +2692,37 @@ static int ravb_probe(struct platform_device *pdev) priv->num_rx_ring[RAVB_NC] = NC_RX_RING_SIZE; } + priv->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(priv->clk)) { + error = PTR_ERR(priv->clk); + goto out_reset_assert; + } + + if (info->gptp_ref_clk) { + priv->gptp_clk = devm_clk_get(&pdev->dev, "gptp"); + if (IS_ERR(priv->gptp_clk)) { + error = PTR_ERR(priv->gptp_clk); + goto out_reset_assert; + } + } + + priv->refclk = devm_clk_get_optional(&pdev->dev, "refclk"); + if (IS_ERR(priv->refclk)) { + error = PTR_ERR(priv->refclk); + goto out_reset_assert; + } + clk_prepare(priv->refclk); + + platform_set_drvdata(pdev, ndev); + pm_runtime_enable(&pdev->dev); + error = pm_runtime_resume_and_get(&pdev->dev); + if (error < 0) + goto out_rpm_disable; + priv->addr = devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(priv->addr)) { error = PTR_ERR(priv->addr); - goto out_release; + goto out_rpm_put; } /* The Ether-specific entries in the device structure. */ @@ -2711,7 +2733,7 @@ static int ravb_probe(struct platform_device *pdev) error = of_get_phy_mode(np, &priv->phy_interface); if (error && error != -ENODEV) - goto out_release; + goto out_rpm_put; priv->no_avb_link = of_property_read_bool(np, "renesas,no-ether-link"); priv->avb_link_active_low = @@ -2724,14 +2746,14 @@ static int ravb_probe(struct platform_device *pdev) irq = platform_get_irq_byname(pdev, "ch24"); if (irq < 0) { error = irq; - goto out_release; + goto out_rpm_put; } priv->emac_irq = irq; for (i = 0; i < NUM_RX_QUEUE; i++) { irq = platform_get_irq_byname(pdev, ravb_rx_irqs[i]); if (irq < 0) { error = irq; - goto out_release; + goto out_rpm_put; } priv->rx_irqs[i] = irq; } @@ -2739,7 +2761,7 @@ static int ravb_probe(struct platform_device *pdev) irq = platform_get_irq_byname(pdev, ravb_tx_irqs[i]); if (irq < 0) { error = irq; - goto out_release; + goto out_rpm_put; } priv->tx_irqs[i] = irq; } @@ -2748,40 +2770,19 @@ static int ravb_probe(struct platform_device *pdev) irq = platform_get_irq_byname(pdev, "err_a"); if (irq < 0) { error = irq; - goto out_release; + goto out_rpm_put; } priv->erra_irq = irq; irq = platform_get_irq_byname(pdev, "mgmt_a"); if (irq < 0) { error = irq; - goto out_release; + goto out_rpm_put; } priv->mgmta_irq = irq; } } - priv->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(priv->clk)) { - error = PTR_ERR(priv->clk); - goto out_release; - } - - priv->refclk = devm_clk_get_optional(&pdev->dev, "refclk"); - if (IS_ERR(priv->refclk)) { - error = PTR_ERR(priv->refclk); - goto out_release; - } - clk_prepare_enable(priv->refclk); - - if (info->gptp_ref_clk) { - priv->gptp_clk = devm_clk_get(&pdev->dev, "gptp"); - if (IS_ERR(priv->gptp_clk)) { - error = PTR_ERR(priv->gptp_clk); - goto out_disable_refclk; - } - } - ndev->max_mtu = info->rx_max_buf_size - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN); ndev->min_mtu = ETH_MIN_MTU; @@ -2799,13 +2800,13 @@ static int ravb_probe(struct platform_device *pdev) /* Set AVB config mode */ error = ravb_set_config_mode(ndev); if (error) - goto out_disable_refclk; + goto out_rpm_put; if (info->gptp || info->ccc_gac) { /* Set GTI value */ error = ravb_set_gti(ndev); if (error) - goto out_disable_refclk; + goto out_rpm_put; /* Request GTI loading */ ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); @@ -2825,7 +2826,7 @@ static int ravb_probe(struct platform_device *pdev) "Cannot allocate desc base address table (size %d bytes)\n", priv->desc_bat_size); error = -ENOMEM; - goto out_disable_refclk; + goto out_rpm_put; } for (q = RAVB_BE; q < DBAT_ENTRY_NUM; q++) priv->desc_bat[q].die_dt = DT_EOS; @@ -2871,8 +2872,6 @@ static int ravb_probe(struct platform_device *pdev) netdev_info(ndev, "Base address at %#x, %pM, IRQ %d.\n", (u32)ndev->base_addr, ndev->dev_addr, ndev->irq); - platform_set_drvdata(pdev, ndev); - return 0; out_napi_del: @@ -2888,12 +2887,12 @@ static int ravb_probe(struct platform_device *pdev) /* Stop PTP Clock driver */ if (info->ccc_gac) ravb_ptp_stop(ndev); -out_disable_refclk: - clk_disable_unprepare(priv->refclk); -out_release: +out_rpm_put: pm_runtime_put(&pdev->dev); out_rpm_disable: pm_runtime_disable(&pdev->dev); + clk_unprepare(priv->refclk); +out_reset_assert: reset_control_assert(rstc); out_free_netdev: free_netdev(ndev); @@ -2922,10 +2921,9 @@ static void ravb_remove(struct platform_device *pdev) ravb_set_opmode(ndev, CCC_OPC_RESET); - clk_disable_unprepare(priv->refclk); - pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); + clk_unprepare(priv->refclk); reset_control_assert(priv->rstc); free_netdev(ndev); platform_set_drvdata(pdev, NULL); @@ -3060,21 +3058,27 @@ static int ravb_resume(struct device *dev) return ret; } -static int ravb_runtime_nop(struct device *dev) +static int ravb_runtime_suspend(struct device *dev) { - /* Runtime PM callback shared between ->runtime_suspend() - * and ->runtime_resume(). Simply returns success. - * - * This driver re-initializes all registers after - * pm_runtime_get_sync() anyway so there is no need - * to save and restore registers here. - */ + struct net_device *ndev = dev_get_drvdata(dev); + struct ravb_private *priv = netdev_priv(ndev); + + clk_disable(priv->refclk); + return 0; } +static int ravb_runtime_resume(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct ravb_private *priv = netdev_priv(ndev); + + return clk_enable(priv->refclk); +} + static const struct dev_pm_ops ravb_dev_pm_ops = { SYSTEM_SLEEP_PM_OPS(ravb_suspend, ravb_resume) - RUNTIME_PM_OPS(ravb_runtime_nop, ravb_runtime_nop, NULL) + RUNTIME_PM_OPS(ravb_runtime_suspend, ravb_runtime_resume, NULL) }; static struct platform_driver ravb_driver = { From patchwork Wed Jan 31 08:41:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13538940 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2C26605A9 for ; Wed, 31 Jan 2024 08:41:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690522; cv=none; b=QJbVWYFaFoV8Cbi17vP9e0QGj1aVa5U5izWwlROalUjv9H/U5NXH1tgE1AzYIw2n61rwHoaZ5niVnh1M5CZvi6+nuYzYu4BjgLQGMICf8lGcctHX9rJBpARe91iXJyR2e8DU6vf4/f4xx6zksz1LbSPuKD/sQDB5cMFB5Rs3/ig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690522; c=relaxed/simple; bh=QKsaxl/aFv8oOhCIua/6fEkDbbYuv+jcvdH2AyGnVVw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EAuQLyieTt9d1xb49v9On+LYONJG574zv3Z4Wj1Z3o9FJpTQfTCSHR7c5+fNPlFbbBo2yPua2WWhNnz/ihelmNhYOWWJaBTdqPeorRiO23eJjqAos2RKkFXLq98u2KxgyupgDCie7C0MTqMns8XtL+1LbKkdtR0NgOSXfLBDkXg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=arSeRwQA; arc=none smtp.client-ip=209.85.208.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="arSeRwQA" Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-55eee4a042eso4196546a12.0 for ; Wed, 31 Jan 2024 00:41:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706690517; x=1707295317; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HT91HA0cf438KLXCFqahgOuGomP/5XEuDd167bXOWFI=; b=arSeRwQAWDfFBao6dO3MQMv+W5rq13NSIQmlBemDnXlPzudSlNZs7V+fRVDjdJ6+v1 DSCXVDTyQogmTzmOxQyAYgANWbP5UZrRbI90BUqBJVmpnaycrv3l+hcP3i1cUxTuW21W 9LOAeIm4bdCNtakdPESr0w3OPNBGngsCrEHbwjO8qrD35qR6ZpsnWWLLNJjP6m+rUnTh faIrygzc8UdCxsWzJE8bbzo8HzysLaLw+LO+BS5smgtEBl1GseQxFMGa9WAH+ZlF7Btb /ejIe9AGG1ymzyJchx+To8/KMI56qoYcoFIABLtoZbqqx8DuXWGkz+H+6kLjxBAjEmTi zwNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706690517; x=1707295317; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HT91HA0cf438KLXCFqahgOuGomP/5XEuDd167bXOWFI=; b=ILqIG4UOgbgXZRy0W35Q14XLoMz3QKT8Cy+3U6n+t87wOz1x29fS1JRw3XzqYJ/yze 2uVzP0A+RQRvoJSuHtO84NLcC3qH0RiRJbRv6vqddqeRf6asnO6pggBU+kzIo+gjoH4O mcm6IazdR2zSOS8vcOLvOiaifiGJZLnmFT67RH810rxiy4MEseFAzfZ3EQrixl8qN+1x nlLYopD249HZmjWLr81c12UKJ6Pd4HwKdxc9ENQPTiF5fs6Y7dWWos9MoofETigZYAvo 9GG5DaYHquCK1Geg3hcOSZipfT9VHH9JdeF/dZe3KKozFziH+hYAuq93fvMzK11drVq3 sD6w== X-Gm-Message-State: AOJu0YyRmldC8NUhznwFn9wEWGV8CF7pFLx0Y5oErxiqQv6gZdsk5iPU TqlVP0UbZkNX8AVeNrG0xLOr0keGcVXG6JFQNO94tvZPl+si5JbLTPFcmvlO+Do= X-Google-Smtp-Source: AGHT+IHz4jM9YV0tyExIajncKLJJwTdV5FdYPy0I/q8ACdh5o71eFuZDrmPXnfakfk+/XYwqtCi50A== X-Received: by 2002:a05:6402:3121:b0:55c:8ab7:9446 with SMTP id dd1-20020a056402312100b0055c8ab79446mr590513edb.7.1706690516842; Wed, 31 Jan 2024 00:41:56 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXkU2P0IBC/c0C7IoW0UHDa8fy4NBnUCcmfSDfxp53q4gjMbOhNjOPm5LREng0pRRpFhgilPWF/A465L7k33gucPgATMG3I3TFqXrtTR0JYLCCvOA3zPcLjZv5vseqGTDlrg2RzO4Au0pmZE45w1xEkPuod0MHIIysjTeDjNVku05232cr9Mao6cnkXCUZaTpmCKC2h8JdhO9tiC+k5NF+iYycORtK3CBJ4vHAe0wVGMX4CVcv5c59O1UajY/2Dj+2W44uf2Fryar3+jUdbeVQbrBUCE2n2LGplyqx/wIC6hdoi9PCy8U6mYOBFw238d9Cs43v01jSqj+eKs8NZ+2w1PRunQclGlhnyvNHhj8BeKP9gfvZzULDsNi6KutAF3D+WXwvmvaAOXnmvb05lGDz+rIwyUmrYThGTPT51jX32dzgXYME= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id cq16-20020a056402221000b0055f02661ae2sm2863630edb.78.2024.01.31.00.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:41:56 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v5 08/15] net: ravb: Move the IRQs getting/requesting in the probe() method Date: Wed, 31 Jan 2024 10:41:26 +0200 Message-Id: <20240131084133.1671440-9-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> References: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea The runtime PM implementation will disable clocks at the end of ravb_probe(). As some IP variants switch to reset mode as a result of setting module standby through clock disable APIs, to implement runtime PM the resource parsing and requesting are moved in the probe function and IP settings are moved in the open function. This is done because at the end of the probe some IP variants will switch anyway to reset mode and the registers content is lost. Also keeping only register settings operations in the ravb_open()/ravb_close() functions will make them faster. Commit moves IRQ requests to ravb_probe() to have all the IRQs ready when the interface is open. As now IRQs getting/requesting are in a single place there is no need to keep intermediary data (like ravb_rx_irqs[] and ravb_tx_irqs[] arrays or IRQs in struct ravb_private). In order to avoid accessing the IP registers while the IP is runtime suspended (e.g. in the timeframe b/w the probe requests shared IRQs and IP clocks are enabled) in the interrupt handlers were introduced pm_runtime_active() checks. The device runtime PM usage counter has been incremented to avoid disabling the device's clocks while the check is in progress (if any). This is a preparatory change to add runtime PM support for all IP variants. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v5: - fixed typos in patch description - collected tags Changes in v4: - use pm_runtime_active() in interrupt handlers - addressed review comments Changes in v3: - fixed typos in patch description - detailed patch description - reworked the code to have a single function doing IRQ get and request Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb.h | 4 - drivers/net/ethernet/renesas/ravb_main.c | 299 ++++++++++------------- 2 files changed, 130 insertions(+), 173 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index e0f8276cffed..e3506888cca6 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1089,10 +1089,6 @@ struct ravb_private { int msg_enable; int speed; int emac_irq; - int erra_irq; - int mgmta_irq; - int rx_irqs[NUM_RX_QUEUE]; - int tx_irqs[NUM_TX_QUEUE]; unsigned no_avb_link:1; unsigned avb_link_active_low:1; diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index e70c930840ce..f9297224e527 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -38,16 +38,6 @@ NETIF_MSG_RX_ERR | \ NETIF_MSG_TX_ERR) -static const char *ravb_rx_irqs[NUM_RX_QUEUE] = { - "ch0", /* RAVB_BE */ - "ch1", /* RAVB_NC */ -}; - -static const char *ravb_tx_irqs[NUM_TX_QUEUE] = { - "ch18", /* RAVB_BE */ - "ch19", /* RAVB_NC */ -}; - void ravb_modify(struct net_device *ndev, enum ravb_reg reg, u32 clear, u32 set) { @@ -1092,11 +1082,23 @@ static irqreturn_t ravb_emac_interrupt(int irq, void *dev_id) { struct net_device *ndev = dev_id; struct ravb_private *priv = netdev_priv(ndev); + struct device *dev = &priv->pdev->dev; + irqreturn_t result = IRQ_HANDLED; + + pm_runtime_get_noresume(dev); + + if (unlikely(!pm_runtime_active(dev))) { + result = IRQ_NONE; + goto out_rpm_put; + } spin_lock(&priv->lock); ravb_emac_interrupt_unlocked(ndev); spin_unlock(&priv->lock); - return IRQ_HANDLED; + +out_rpm_put: + pm_runtime_put_noidle(dev); + return result; } /* Error interrupt handler */ @@ -1176,9 +1178,15 @@ static irqreturn_t ravb_interrupt(int irq, void *dev_id) struct net_device *ndev = dev_id; struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; + struct device *dev = &priv->pdev->dev; irqreturn_t result = IRQ_NONE; u32 iss; + pm_runtime_get_noresume(dev); + + if (unlikely(!pm_runtime_active(dev))) + goto out_rpm_put; + spin_lock(&priv->lock); /* Get interrupt status */ iss = ravb_read(ndev, ISS); @@ -1222,6 +1230,9 @@ static irqreturn_t ravb_interrupt(int irq, void *dev_id) } spin_unlock(&priv->lock); + +out_rpm_put: + pm_runtime_put_noidle(dev); return result; } @@ -1230,9 +1241,15 @@ static irqreturn_t ravb_multi_interrupt(int irq, void *dev_id) { struct net_device *ndev = dev_id; struct ravb_private *priv = netdev_priv(ndev); + struct device *dev = &priv->pdev->dev; irqreturn_t result = IRQ_NONE; u32 iss; + pm_runtime_get_noresume(dev); + + if (unlikely(!pm_runtime_active(dev))) + goto out_rpm_put; + spin_lock(&priv->lock); /* Get interrupt status */ iss = ravb_read(ndev, ISS); @@ -1254,6 +1271,9 @@ static irqreturn_t ravb_multi_interrupt(int irq, void *dev_id) } spin_unlock(&priv->lock); + +out_rpm_put: + pm_runtime_put_noidle(dev); return result; } @@ -1261,8 +1281,14 @@ static irqreturn_t ravb_dma_interrupt(int irq, void *dev_id, int q) { struct net_device *ndev = dev_id; struct ravb_private *priv = netdev_priv(ndev); + struct device *dev = &priv->pdev->dev; irqreturn_t result = IRQ_NONE; + pm_runtime_get_noresume(dev); + + if (unlikely(!pm_runtime_active(dev))) + goto out_rpm_put; + spin_lock(&priv->lock); /* Network control/Best effort queue RX/TX */ @@ -1270,6 +1296,9 @@ static irqreturn_t ravb_dma_interrupt(int irq, void *dev_id, int q) result = IRQ_HANDLED; spin_unlock(&priv->lock); + +out_rpm_put: + pm_runtime_put_noidle(dev); return result; } @@ -1727,85 +1756,21 @@ static const struct ethtool_ops ravb_ethtool_ops = { .set_wol = ravb_set_wol, }; -static inline int ravb_hook_irq(unsigned int irq, irq_handler_t handler, - struct net_device *ndev, struct device *dev, - const char *ch) -{ - char *name; - int error; - - name = devm_kasprintf(dev, GFP_KERNEL, "%s:%s", ndev->name, ch); - if (!name) - return -ENOMEM; - error = request_irq(irq, handler, 0, name, ndev); - if (error) - netdev_err(ndev, "cannot request IRQ %s\n", name); - - return error; -} - /* Network device open function for Ethernet AVB */ static int ravb_open(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; - struct platform_device *pdev = priv->pdev; - struct device *dev = &pdev->dev; int error; napi_enable(&priv->napi[RAVB_BE]); if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); - if (!info->multi_irqs) { - error = request_irq(ndev->irq, ravb_interrupt, IRQF_SHARED, - ndev->name, ndev); - if (error) { - netdev_err(ndev, "cannot request IRQ\n"); - goto out_napi_off; - } - } else { - error = ravb_hook_irq(ndev->irq, ravb_multi_interrupt, ndev, - dev, "ch22:multi"); - if (error) - goto out_napi_off; - error = ravb_hook_irq(priv->emac_irq, ravb_emac_interrupt, ndev, - dev, "ch24:emac"); - if (error) - goto out_free_irq; - error = ravb_hook_irq(priv->rx_irqs[RAVB_BE], ravb_be_interrupt, - ndev, dev, "ch0:rx_be"); - if (error) - goto out_free_irq_emac; - error = ravb_hook_irq(priv->tx_irqs[RAVB_BE], ravb_be_interrupt, - ndev, dev, "ch18:tx_be"); - if (error) - goto out_free_irq_be_rx; - error = ravb_hook_irq(priv->rx_irqs[RAVB_NC], ravb_nc_interrupt, - ndev, dev, "ch1:rx_nc"); - if (error) - goto out_free_irq_be_tx; - error = ravb_hook_irq(priv->tx_irqs[RAVB_NC], ravb_nc_interrupt, - ndev, dev, "ch19:tx_nc"); - if (error) - goto out_free_irq_nc_rx; - - if (info->err_mgmt_irqs) { - error = ravb_hook_irq(priv->erra_irq, ravb_multi_interrupt, - ndev, dev, "err_a"); - if (error) - goto out_free_irq_nc_tx; - error = ravb_hook_irq(priv->mgmta_irq, ravb_multi_interrupt, - ndev, dev, "mgmt_a"); - if (error) - goto out_free_irq_erra; - } - } - /* Device init */ error = ravb_dmac_init(ndev); if (error) - goto out_free_irq_mgmta; + goto out_napi_off; ravb_emac_init(ndev); /* Initialise PTP Clock driver */ @@ -1826,26 +1791,6 @@ static int ravb_open(struct net_device *ndev) if (info->gptp) ravb_ptp_stop(ndev); ravb_stop_dma(ndev); -out_free_irq_mgmta: - if (!info->multi_irqs) - goto out_free_irq; - if (info->err_mgmt_irqs) - free_irq(priv->mgmta_irq, ndev); -out_free_irq_erra: - if (info->err_mgmt_irqs) - free_irq(priv->erra_irq, ndev); -out_free_irq_nc_tx: - free_irq(priv->tx_irqs[RAVB_NC], ndev); -out_free_irq_nc_rx: - free_irq(priv->rx_irqs[RAVB_NC], ndev); -out_free_irq_be_tx: - free_irq(priv->tx_irqs[RAVB_BE], ndev); -out_free_irq_be_rx: - free_irq(priv->rx_irqs[RAVB_BE], ndev); -out_free_irq_emac: - free_irq(priv->emac_irq, ndev); -out_free_irq: - free_irq(ndev->irq, ndev); out_napi_off: if (info->nc_queues) napi_disable(&priv->napi[RAVB_NC]); @@ -2180,19 +2125,6 @@ static int ravb_close(struct net_device *ndev) cancel_work_sync(&priv->work); - if (info->multi_irqs) { - free_irq(priv->tx_irqs[RAVB_NC], ndev); - free_irq(priv->rx_irqs[RAVB_NC], ndev); - free_irq(priv->tx_irqs[RAVB_BE], ndev); - free_irq(priv->rx_irqs[RAVB_BE], ndev); - free_irq(priv->emac_irq, ndev); - if (info->err_mgmt_irqs) { - free_irq(priv->erra_irq, ndev); - free_irq(priv->mgmta_irq, ndev); - } - } - free_irq(ndev->irq, ndev); - if (info->nc_queues) napi_disable(&priv->napi[RAVB_NC]); napi_disable(&priv->napi[RAVB_BE]); @@ -2616,6 +2548,90 @@ static void ravb_parse_delay_mode(struct device_node *np, struct net_device *nde } } +static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name, + const char *ch, int *irq, irq_handler_t handler) +{ + struct platform_device *pdev = priv->pdev; + struct net_device *ndev = priv->ndev; + struct device *dev = &pdev->dev; + const char *dev_name; + unsigned long flags; + int error; + + if (irq_name) { + dev_name = devm_kasprintf(dev, GFP_KERNEL, "%s:%s", ndev->name, ch); + if (!dev_name) + return -ENOMEM; + + *irq = platform_get_irq_byname(pdev, irq_name); + flags = 0; + } else { + dev_name = ndev->name; + *irq = platform_get_irq(pdev, 0); + flags = IRQF_SHARED; + } + if (*irq < 0) + return *irq; + + error = devm_request_irq(dev, *irq, handler, flags, dev_name, ndev); + if (error) + netdev_err(ndev, "cannot request IRQ %s\n", dev_name); + + return error; +} + +static int ravb_setup_irqs(struct ravb_private *priv) +{ + const struct ravb_hw_info *info = priv->info; + struct net_device *ndev = priv->ndev; + const char *irq_name, *emac_irq_name; + int error, irq; + + if (!info->multi_irqs) + return ravb_setup_irq(priv, NULL, NULL, &ndev->irq, ravb_interrupt); + + if (info->err_mgmt_irqs) { + irq_name = "dia"; + emac_irq_name = "line3"; + } else { + irq_name = "ch22"; + emac_irq_name = "ch24"; + } + + error = ravb_setup_irq(priv, irq_name, "ch22:multi", &ndev->irq, ravb_multi_interrupt); + if (error) + return error; + + error = ravb_setup_irq(priv, emac_irq_name, "ch24:emac", &priv->emac_irq, + ravb_emac_interrupt); + if (error) + return error; + + if (info->err_mgmt_irqs) { + error = ravb_setup_irq(priv, "err_a", "err_a", &irq, ravb_multi_interrupt); + if (error) + return error; + + error = ravb_setup_irq(priv, "mgmt_a", "mgmt_a", &irq, ravb_multi_interrupt); + if (error) + return error; + } + + error = ravb_setup_irq(priv, "ch0", "ch0:rx_be", &irq, ravb_be_interrupt); + if (error) + return error; + + error = ravb_setup_irq(priv, "ch1", "ch1:rx_nc", &irq, ravb_nc_interrupt); + if (error) + return error; + + error = ravb_setup_irq(priv, "ch18", "ch18:tx_be", &irq, ravb_be_interrupt); + if (error) + return error; + + return ravb_setup_irq(priv, "ch19", "ch19:tx_nc", &irq, ravb_nc_interrupt); +} + static void ravb_set_delay_mode(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); @@ -2635,9 +2651,8 @@ static int ravb_probe(struct platform_device *pdev) struct reset_control *rstc; struct ravb_private *priv; struct net_device *ndev; - int error, irq, q; struct resource *res; - int i; + int error, q; if (!np) { dev_err(&pdev->dev, @@ -2664,20 +2679,6 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_free_netdev; - if (info->multi_irqs) { - if (info->err_mgmt_irqs) - irq = platform_get_irq_byname(pdev, "dia"); - else - irq = platform_get_irq_byname(pdev, "ch22"); - } else { - irq = platform_get_irq(pdev, 0); - } - if (irq < 0) { - error = irq; - goto out_reset_assert; - } - ndev->irq = irq; - SET_NETDEV_DEV(ndev, &pdev->dev); priv = netdev_priv(ndev); @@ -2692,6 +2693,10 @@ static int ravb_probe(struct platform_device *pdev) priv->num_rx_ring[RAVB_NC] = NC_RX_RING_SIZE; } + error = ravb_setup_irqs(priv); + if (error) + goto out_reset_assert; + priv->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(priv->clk)) { error = PTR_ERR(priv->clk); @@ -2739,50 +2744,6 @@ static int ravb_probe(struct platform_device *pdev) priv->avb_link_active_low = of_property_read_bool(np, "renesas,ether-link-active-low"); - if (info->multi_irqs) { - if (info->err_mgmt_irqs) - irq = platform_get_irq_byname(pdev, "line3"); - else - irq = platform_get_irq_byname(pdev, "ch24"); - if (irq < 0) { - error = irq; - goto out_rpm_put; - } - priv->emac_irq = irq; - for (i = 0; i < NUM_RX_QUEUE; i++) { - irq = platform_get_irq_byname(pdev, ravb_rx_irqs[i]); - if (irq < 0) { - error = irq; - goto out_rpm_put; - } - priv->rx_irqs[i] = irq; - } - for (i = 0; i < NUM_TX_QUEUE; i++) { - irq = platform_get_irq_byname(pdev, ravb_tx_irqs[i]); - if (irq < 0) { - error = irq; - goto out_rpm_put; - } - priv->tx_irqs[i] = irq; - } - - if (info->err_mgmt_irqs) { - irq = platform_get_irq_byname(pdev, "err_a"); - if (irq < 0) { - error = irq; - goto out_rpm_put; - } - priv->erra_irq = irq; - - irq = platform_get_irq_byname(pdev, "mgmt_a"); - if (irq < 0) { - error = irq; - goto out_rpm_put; - } - priv->mgmta_irq = irq; - } - } - ndev->max_mtu = info->rx_max_buf_size - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN); ndev->min_mtu = ETH_MIN_MTU; From patchwork Wed Jan 31 08:41:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13538939 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00C0F6EB62 for ; Wed, 31 Jan 2024 08:41:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690522; cv=none; b=JckkoYgntEOL4yi5ddyUUdd7ZokKTMH+mpUohBjP+xy/vk3e7LB+kVhSgmG6cqOH3SWjbGpTMIZ26liJGmtfDR6faK98fLgT5m9B45azsOrlGZadlMxuPVGw+99inO6HaGci6uTlgGbicmjtNFFGHzGsbTlaYeF/tmyjWRTHHEc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690522; c=relaxed/simple; bh=aLlMQy8HZ3Uodd7EYAzkrNQyWPQI2JPqu4nG0FzkUGE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ORpisKDQyzoiJR3bxSADOpq9iO9lBSrP+m5/DhOPE2k9pNIELCBM5OmoBmOudXSKTW4a7YcRRyuMrCGlOqk8KIjHGnaxIPZO6FSsP7A2pOL752jRW+UuNjBab0ndQFt0ea10//yGx0YJWOm1ZmseJc8CmmXL4CEgpShgiq1xoKc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=aWxkgMYt; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="aWxkgMYt" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-55eed368b0bso1309972a12.0 for ; Wed, 31 Jan 2024 00:41:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706690518; x=1707295318; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nQCfrFSxrrf9tRO6HJcq+akjVQCNk3tk3vQzaskg9t8=; b=aWxkgMYtVswfmajGy8LMr8yIBEy2/fiC/NfYkxiDIFG7/PCuJXF8b60My06Y8kzefE D5Zz8cr0/A4tzST4FRWnB32gBFY3El9OK0hycQXmgFxuBrHfpCoz6eZhJ7Pgvj5JHhmO IymlO2KXMEHSKPGvhN1T/8m1zepAgMYjMBFyW90EZvQv0AFNfPySrg2fX2Iys9ketwde mTUM7O0D/E5jy3IgoXEx/ici9sUZff7Vyqh++OToD4JBtem1sBSggARD9ctK7hkZ0eQV cA4eZct+eUK56UdIUrKfRKYp1BicfopTMAp2p6SpnnqNECyEeIq94fYXyGgvFyLFTM3p Hy9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706690518; x=1707295318; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nQCfrFSxrrf9tRO6HJcq+akjVQCNk3tk3vQzaskg9t8=; b=Jv2Jv9cPASF5s4w2j+/mD/cKGtKHt+KDhuNSyagrMxbEYq2he+mmBWLnYMbjiIcqI9 IChh7SXYErGsT0Xd34FzKq4/D8vJj5OidAAeEHb9xYkVnOUL2Z3oXM/WWsrIFnB9PCk7 ORk4QSCclOmTGA7LTRMXkGq0yIz3RTAW6z9+Vh/FcxS9FrZvz5mUSjJfRo0xBFSwC4rR Wguiolevtfg+F5o5Jv7YPsnGvFWb+1r2BVzezrrkKx6a1yVuVctFLv6z30vDL6IflBAs jK3nsbVDp5q0XuQf6R6t2ZMhr7jhCPaVODZWcSxiRRp4GX1LQafghYr7JkQJKKjuQlE8 GKrQ== X-Gm-Message-State: AOJu0YxwUqZkyE1DqHHhQ+hAvMJs9gcCz2qNJZZD1oIF/spEaIqAVHIG q37PN/wGkLKP1TISqU2wNVt37wb8QJQCOUz264I+7Uxtkf5C/gtGk8F3n7+q8Qw= X-Google-Smtp-Source: AGHT+IHKr0M8p2erIxEMLCxQzd8C2G5HCFys+AO9+35Tn6g57xz7Pk+Ug/GD74zCWV734TpilIa+eA== X-Received: by 2002:a50:8d54:0:b0:55d:71d7:31c5 with SMTP id t20-20020a508d54000000b0055d71d731c5mr947757edt.6.1706690518298; Wed, 31 Jan 2024 00:41:58 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCW+fQSw5vPHy6jQbwiRMhmeUpgOaDIs3EZEsRstr6oQ56ilGrJP5dHob+V3YWhuc6t70LJ4sRzNaIRgR4cTmvR0CVyV2aO3qDPvfw8DZBWV0Yt7xZk/aPtjzPgstdLd71FwOGn644TvJh08hVHzpIot+gY5PMyhPdX3iWftXafslOSLbYY/zGATXTlVTjXPTpEPUxBZ3Q4qsneBd7EzqTvSCu0K0hsSVByS2lkY+uofDGreeAM5VR1x60DmJBx3x8fWPDtKeCA7nmlWLvUIuHO7rwlQso3pwWrZ5Jh7kpfFUZcF2MZW1GXC0dBjVXo6PwczjTWpl4u5iQV38vXx81HDWhBw62D1h9n3pIn9wSQNJGGQA3KbegUxSLBBUHa+EG9H0el5zDDizdo74JijFfDldGhpb3bNvV+WisJozn4ccc4ggTg= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id cq16-20020a056402221000b0055f02661ae2sm2863630edb.78.2024.01.31.00.41.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:41:57 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v5 09/15] net: ravb: Split GTI computation and set operations Date: Wed, 31 Jan 2024 10:41:27 +0200 Message-Id: <20240131084133.1671440-10-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> References: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea ravb_set_gti() was computing the value of GTI based on the reference clock rate and then applied it to register. This was done on the driver's probe function. In order to implement runtime PM for all IP variants (as some IP variants switches to reset mode (and thus the registers content is lost) when module standby is configured through clock APIs) the GTI setup was split in 2 parts: one computing the value of the GTI register (done in the driver's probe function) and one applying the computed value to register (done in the driver's ndo_open API). Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v5: - none Changes in v4: - collected tags Changes in v3: - fixed typos in patch description - use u64 instead of uint64_t - remove ravb_wait() for setting GCCR.LTI Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb.h | 2 + drivers/net/ethernet/renesas/ravb_main.c | 96 ++++++++++++------------ 2 files changed, 52 insertions(+), 46 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index e3506888cca6..268ccfafe7aa 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1102,6 +1102,8 @@ struct ravb_private { const struct ravb_hw_info *info; struct reset_control *rstc; + + u32 gti_tiv; }; static inline u32 ravb_read(struct net_device *ndev, enum ravb_reg reg) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index f9297224e527..0f7b1d503618 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1756,6 +1756,50 @@ static const struct ethtool_ops ravb_ethtool_ops = { .set_wol = ravb_set_wol, }; +static void ravb_set_gti(struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + const struct ravb_hw_info *info = 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 = netdev_priv(ndev); + const struct ravb_hw_info *info = priv->info; + struct device *dev = ndev->dev.parent; + unsigned long rate; + u64 inc; + + if (!(info->gptp || info->ccc_gac)) + return 0; + + if (info->gptp_ref_clk) + rate = clk_get_rate(priv->gptp_clk); + else + rate = clk_get_rate(priv->clk); + if (!rate) + return -EINVAL; + + inc = div64_ul(1000000000ULL << 20, rate); + + if (inc < GTI_TIV_MIN || inc > GTI_TIV_MAX) { + dev_err(dev, "gti.tiv increment 0x%llx is outside the range 0x%x - 0x%x\n", + inc, GTI_TIV_MIN, GTI_TIV_MAX); + return -EINVAL; + } + priv->gti_tiv = inc; + + return 0; +} + /* Network device open function for Ethernet AVB */ static int ravb_open(struct net_device *ndev) { @@ -1773,6 +1817,8 @@ static int ravb_open(struct net_device *ndev) goto out_napi_off; ravb_emac_init(ndev); + ravb_set_gti(ndev); + /* Initialise PTP Clock driver */ if (info->gptp) ravb_ptp_init(ndev, priv->pdev); @@ -2464,34 +2510,6 @@ static const struct of_device_id ravb_match_table[] = { }; MODULE_DEVICE_TABLE(of, ravb_match_table); -static int ravb_set_gti(struct net_device *ndev) -{ - struct ravb_private *priv = netdev_priv(ndev); - const struct ravb_hw_info *info = priv->info; - struct device *dev = ndev->dev.parent; - unsigned long rate; - uint64_t inc; - - if (info->gptp_ref_clk) - rate = clk_get_rate(priv->gptp_clk); - else - rate = clk_get_rate(priv->clk); - if (!rate) - return -EINVAL; - - inc = div64_ul(1000000000ULL << 20, rate); - - if (inc < GTI_TIV_MIN || inc > GTI_TIV_MAX) { - dev_err(dev, "gti.tiv increment 0x%llx is outside the range 0x%x - 0x%x\n", - inc, GTI_TIV_MIN, GTI_TIV_MAX); - return -EINVAL; - } - - ravb_write(ndev, inc, GTI); - - return 0; -} - static int ravb_set_config_mode(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); @@ -2763,15 +2781,9 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_rpm_put; - if (info->gptp || info->ccc_gac) { - /* Set GTI value */ - error = ravb_set_gti(ndev); - if (error) - goto out_rpm_put; - - /* Request GTI loading */ - ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); - } + error = ravb_compute_gti(ndev); + if (error) + goto out_rpm_put; if (info->internal_delay) { ravb_parse_delay_mode(np, ndev); @@ -2984,15 +2996,7 @@ static int ravb_resume(struct device *dev) if (ret) return ret; - if (info->gptp || info->ccc_gac) { - /* Set GTI value */ - ret = ravb_set_gti(ndev); - if (ret) - return ret; - - /* Request GTI loading */ - ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); - } + ravb_set_gti(ndev); if (info->internal_delay) ravb_set_delay_mode(ndev); From patchwork Wed Jan 31 08:41:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13538941 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A00FB74E39 for ; Wed, 31 Jan 2024 08:42:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690523; cv=none; b=qASHakS4l8ZG0QOAYAmeXnS3YE6Mg5KdQBlZ2MEuPNf3PhlACsTdgkq2a1lXl1veIYkLeQhywIWycmqKNunXPArgCgoqQr4nNxyKQRL0iHGIHR+yMB+YMVoY+X66eqcvMsJJYglhGphSa6WaHVqKnBIlHzf5Zb/vfaB9aNEZW1Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690523; c=relaxed/simple; bh=Tl9EE4rSqsLaclcX/s9TRCT5vjw2U2y2/W8A3V/zf38=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=REof9bQ0ZfIY+LHk+d/aQQUHIF8o8jBQcX+R6mlxO2YW9PEkcPu9WiOx5N9nFmkDCNuegR3ccf8LLPcAjvO4VODHkopwyP0MWVRp8nA/IVx9ta+y0ASDL4m9hXw/AjuCgQjGMX+iRrZkDvY1It0lANJKKrW8QaTOJeMfl1ZNMiM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=WB5gRiGg; arc=none smtp.client-ip=209.85.208.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="WB5gRiGg" Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2d05da19a9eso15847741fa.2 for ; Wed, 31 Jan 2024 00:42:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706690520; x=1707295320; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GOBNXx2ouuErkvp20qBEr9vbTwPM99kJ0Yx6JPusU6c=; b=WB5gRiGgOfX3jqysJlbDF7pEMokYyqw7/f/swlQSaBM2boFD4xdJmaV7+xsSIYfWtz Ga2rDrPAj9t9JX2IX/QinsNv14b9yLfsNP/SS4c0/IoePJKnQ54JfkJkuohipk2WZzbM P9QSn7KnKyTcks+H9XNCihEz8krvXoefmk3t3xxzJk10Lf0baqxfEK8Ck/rws0gwgEiu EddRL/j/CMRex436gGklNA8Emy4DqWwcBjjRE6HyQWJYS4BTnltlg7AjwfDE5q2NQg5l e0hUHgt49GjC9pBpfp13xyNbfv4tVudYqzP3/QFzv+jzBHvk7wOJndEw5TLLLpepaFOi yyLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706690520; x=1707295320; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GOBNXx2ouuErkvp20qBEr9vbTwPM99kJ0Yx6JPusU6c=; b=r7m+5efiBRufb+jBd2F2zrW8K/AJudNvdpUShy/oXHMZ32f3fwq3DbLlKx9tDTzA3U QV1Q6aHgZ4kwbSEgFisJ4St2bg9Z2I4OTz8LPG57V+cw9koALlC5lrwyD4FQxQk32ED2 I8U30SKDKwhUvzQ44CrdEjWaDr/BE2cTYs6G3dKzWDOzosC+lVO67AfySob51aZAaWKw S0LRfyhikq1vwTZQqnWSzHW8/TT3xWSY0FoVbMZdqJffLzWyx7wlvOxUlLQPzudEDZjz 0IhJZray7JH04QaRtENqyM3a7LTIeeCeLkB//i2ozn/lw8HHnRxAc3VqSSSEUV1jdDz0 xtXw== X-Gm-Message-State: AOJu0Ywv+5c31J78Q0m7EqQMzxL9Vkk5Gv4URrSkPnoGpgRlxW/aVN32 cvJKmARvFYB5jdE2q5gkiv5yBcWKOTJS/D+qyP7FetRwU1Vgr3EhXpcucgLQJZ4= X-Google-Smtp-Source: AGHT+IEy54eqGheW/EcWLkVM1buIOI5MscBwZx+E5+NeZmv6WTH76R9G6m2m4IJBp0Kg9+eYzgAL8w== X-Received: by 2002:a2e:a687:0:b0:2ce:19d:2118 with SMTP id q7-20020a2ea687000000b002ce019d2118mr516799lje.6.1706690519652; Wed, 31 Jan 2024 00:41:59 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCX5OZwG3k4GNd39QHlTcc5E9v6eJdTIABspjil8bPAO7sdAtLA+9npvhHYSz2JSgV0riKTS6KTUQagdYE53HoRbW7qcXIUhi/uGIePJDGKlwdJ38B6etmmx6f5q/B0o3FTZ2CNOSqwWgoVmx30vGw/b/QlpTc10Rw4O12+KMefjkk/pYqKdGfnpIeI9DNHj7xo3aCZdSLpBmCPQdLPidfLQoLpVghAId5Aifu51bmfH2lCLUnsh8+PtVA/kwEL1p2fi87aSjr5hCw1SnTaGfPV51fh4i7MIpHJ92c3cJpln1ABEktaNg4KO+uhOMIBWYQ4GA1bj54yUnb7MkivTn/ujMSp3e4+eqz213PpguBBkS4EdgL6QLPT5A3gMihr+qvCAyE/CdouoZXC4xRDfnBPCdyxxi9mq3vnca8gQyksVVvITnHA= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id cq16-20020a056402221000b0055f02661ae2sm2863630edb.78.2024.01.31.00.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:41:59 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v5 10/15] net: ravb: Move delay mode set in the driver's ndo_open API Date: Wed, 31 Jan 2024 10:41:28 +0200 Message-Id: <20240131084133.1671440-11-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> References: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea Delay parsing and setting were done in the driver's probe API. As some IP variants switch to reset mode (and thus the register contents is lost) when setting clocks (due to module standby functionality) to be able to implement runtime PM keep the delay parsing in the driver's probe function and move the delay applying function to the driver's ndo_open API. Along with it, ravb_parse_delay_mode() function was moved close to ravb_set_delay_mode() function to have the delay specific code in the same place. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v5: - fixed typos in patch description - improved patch description Changes in v4: - collected tags Changes in v3: - fixed typos in patch description Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 107 ++++++++++++----------- 1 file changed, 56 insertions(+), 51 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 0f7b1d503618..e5805e0d8e13 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1800,6 +1800,59 @@ static int ravb_compute_gti(struct net_device *ndev) return 0; } +/* Set tx and rx clock internal delay modes */ +static void ravb_parse_delay_mode(struct device_node *np, struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + bool explicit_delay = false; + u32 delay; + + if (!priv->info->internal_delay) + return; + + if (!of_property_read_u32(np, "rx-internal-delay-ps", &delay)) { + /* Valid values are 0 and 1800, according to DT bindings */ + priv->rxcidm = !!delay; + explicit_delay = true; + } + if (!of_property_read_u32(np, "tx-internal-delay-ps", &delay)) { + /* Valid values are 0 and 2000, according to DT bindings */ + priv->txcidm = !!delay; + explicit_delay = true; + } + + if (explicit_delay) + return; + + /* Fall back to legacy rgmii-*id behavior */ + if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || + priv->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) { + priv->rxcidm = 1; + priv->rgmii_override = 1; + } + + if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || + priv->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) { + priv->txcidm = 1; + priv->rgmii_override = 1; + } +} + +static void ravb_set_delay_mode(struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + u32 set = 0; + + if (!priv->info->internal_delay) + return; + + if (priv->rxcidm) + set |= APSR_RDM; + if (priv->txcidm) + set |= APSR_TDM; + ravb_modify(ndev, APSR, APSR_RDM | APSR_TDM, set); +} + /* Network device open function for Ethernet AVB */ static int ravb_open(struct net_device *ndev) { @@ -1811,6 +1864,8 @@ static int ravb_open(struct net_device *ndev) if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); + ravb_set_delay_mode(ndev); + /* Device init */ error = ravb_dmac_init(ndev); if (error) @@ -2531,41 +2586,6 @@ static int ravb_set_config_mode(struct net_device *ndev) return error; } -/* Set tx and rx clock internal delay modes */ -static void ravb_parse_delay_mode(struct device_node *np, struct net_device *ndev) -{ - struct ravb_private *priv = netdev_priv(ndev); - bool explicit_delay = false; - u32 delay; - - if (!of_property_read_u32(np, "rx-internal-delay-ps", &delay)) { - /* Valid values are 0 and 1800, according to DT bindings */ - priv->rxcidm = !!delay; - explicit_delay = true; - } - if (!of_property_read_u32(np, "tx-internal-delay-ps", &delay)) { - /* Valid values are 0 and 2000, according to DT bindings */ - priv->txcidm = !!delay; - explicit_delay = true; - } - - if (explicit_delay) - return; - - /* Fall back to legacy rgmii-*id behavior */ - if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || - priv->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) { - priv->rxcidm = 1; - priv->rgmii_override = 1; - } - - if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || - priv->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) { - priv->txcidm = 1; - priv->rgmii_override = 1; - } -} - static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name, const char *ch, int *irq, irq_handler_t handler) { @@ -2650,18 +2670,6 @@ static int ravb_setup_irqs(struct ravb_private *priv) return ravb_setup_irq(priv, "ch19", "ch19:tx_nc", &irq, ravb_nc_interrupt); } -static void ravb_set_delay_mode(struct net_device *ndev) -{ - struct ravb_private *priv = netdev_priv(ndev); - u32 set = 0; - - if (priv->rxcidm) - set |= APSR_RDM; - if (priv->txcidm) - set |= APSR_TDM; - ravb_modify(ndev, APSR, APSR_RDM | APSR_TDM, set); -} - static int ravb_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -2785,10 +2793,7 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_rpm_put; - if (info->internal_delay) { - ravb_parse_delay_mode(np, ndev); - ravb_set_delay_mode(ndev); - } + ravb_parse_delay_mode(np, ndev); /* Allocate descriptor base address table */ priv->desc_bat_size = sizeof(struct ravb_desc) * DBAT_ENTRY_NUM; From patchwork Wed Jan 31 08:41:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13538942 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8512768F8 for ; Wed, 31 Jan 2024 08:42:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690525; cv=none; b=Hl9M52boUdAMbz8md2wBqf1U1JwYk8PdcpS7jLozkEhs2Ib/w+aCQHgIIqd+iGZ/5nKchCoInrzSi+q5X5QnOCUOjmB+3Jb76owRjMi+Ixfi8gxUEuX2SVoN2SJQ6IGTt2ZUnOMh4d5jD1TmjwfOkcAQwZH/SfC+sR2b+ID2bas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690525; c=relaxed/simple; bh=/BMX0x/G9bxJjbupfpU/dtjHS5xnYYvUXfe51rH81nI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rfTcq+BUKpkj9yxoa5F0PnYfo5wvlQBWsDwvpGZsu7SwhsEweJS7ksmXFaCskLRPH6yJ/iWeyq/wFXLlfbNCxbWwRiH4CFXY5c97vItK+5nqj1hjy5naMoq00gjTjlJebfBGvCSRZYQSccxnsAfeU4rh5w8GPg+n+SxXUXjWQ4s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=eSqED3ta; arc=none smtp.client-ip=209.85.208.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="eSqED3ta" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-55f2b0c5ae9so2788506a12.2 for ; Wed, 31 Jan 2024 00:42:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706690521; x=1707295321; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yHLjzks9Tom/l8TYALcWPAs3A8Rh44UPVwxAZBkCSa4=; b=eSqED3ta/qRiamOCL/TLnLipHg9Z10wFkl8ama7sgAkrRQMan5Pz8pm8wRxUuEdYFF puxriH13WkHiMoUtfkzZZe2KkIgL/JW9l1sLN4ftXdHhdham9lRhsoFoQl/wOeD2LiBN 8KKRXhXrxqoO2ncHOYjxqb4FSKOVXni5prUktAn97sEjkekrRpSavEoySwKsgZdvxbYu niDDImlAgBfTTZGgAHS+IyMutAgDPvUaE61vU/tMmpBghYlyc4AQNqmTQztY/z9fCdQv q6p0curhvtj+AWAKWKOA91R5XStjgbBgqzB70CyJyU9DuUn++0XvvxmkLUbRKDoQhCm3 vkHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706690521; x=1707295321; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yHLjzks9Tom/l8TYALcWPAs3A8Rh44UPVwxAZBkCSa4=; b=Gh6YDOb6+/OH6wKYhh6h295nUZyIkoO91r0uoccwR4V3wjJptLQmeXbygT+31Af5Wb kwYp8dvov3Rae4x/tcyLrCi9tA8tpk+3BS2UA+OByzrLmwkmeWXMUvIZHncW/0613TwF sOMLzZofe4mOThmbxGODKmdh7/g6FZAp1fz56al6zvML9qgMCiKM3ebWQnbvqCTy5p2H xlRO8Un9dEM4l3bgqEOB72FkWb+59skpK3cI6jFsszSoO3XNhFfbVU6SktV+i5q9hwM6 SckJTfa24/X5W9o/C3gT4ami+HUwvQuDxVYJyDlzOIgfUFR/1NULxwSpgoa2l0NcTP2I d4kg== X-Gm-Message-State: AOJu0YxVIP8BbJW03MZfuCYSmtGfmvJ+KsE7OF73FI684tonFysnkNe4 49hSdevPkcGMiwT1WUKsoBBFV/qmM4mm6zbh7plod7L4N71qGShgk51MLB6xCHg= X-Google-Smtp-Source: AGHT+IH7MVKtCh910v/vagl15wE63ppiKdvQ13gV3Gx6m2Z9oNLNc/iGIHulI8TVJy/3HvqwCdFLAw== X-Received: by 2002:aa7:ca47:0:b0:55e:e9f3:4f7f with SMTP id j7-20020aa7ca47000000b0055ee9f34f7fmr633451edt.9.1706690521065; Wed, 31 Jan 2024 00:42:01 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWEqOO0JVT3DNYj7IKD4YRbtpXvrwJCG2b4edkq52HydSFFRxV7Ng6U6xMATXJ6aNp2dAu4bAMZ+6klPV014fzrh4XOGsjeEDXUVhBewECEZHWT4XEENKxgIek4iEVBD0TMe8WIk+2PZVsjJX/ZKL1yQiDekgRT6Dc2wQqjwiwMywZcz8OMNgu+5tt6ooSSRblgT3JFkiRnZs5h/FOpDKj2sIwv+WQ+6MjCLspkBhUrdDMZCN1ZTcPTt3YO/+M4hpi0AoW/JxOWKc3cHmTi17E0l9JiFKQqLEGtCnvCqpO9eskZ31wZQFEH1BaZ8vcWqGMhRfnI5JA/46wacFJTpf0g1TKQnBfzX4qG/ivcedEizuaAu42QfH/52Ww9lEoMDd/bW+FUGsIISiPX16gMDSy77cmocKlzKdOUKWdFG7aapqvqDvU= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id cq16-20020a056402221000b0055f02661ae2sm2863630edb.78.2024.01.31.00.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:42:00 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v5 11/15] net: ravb: Move DBAT configuration to the driver's ndo_open API Date: Wed, 31 Jan 2024 10:41:29 +0200 Message-Id: <20240131084133.1671440-12-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> References: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea DBAT setup was done in the driver's probe API. As some IP variants switch to reset mode (and thus registers content is lost) when setting clocks (due to module standby functionality) to be able to implement runtime PM move the DBAT configuration in the driver's ndo_open API. This commit prepares the code for the addition of runtime PM. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v5: - none Changes in v4: - none Changes in v3: - collected tags Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index e5805e0d8e13..318ab27635bb 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1865,6 +1865,7 @@ static int ravb_open(struct net_device *ndev) napi_enable(&priv->napi[RAVB_NC]); ravb_set_delay_mode(ndev); + ravb_write(ndev, priv->desc_bat_dma, DBAT); /* Device init */ error = ravb_dmac_init(ndev); @@ -2808,7 +2809,6 @@ static int ravb_probe(struct platform_device *pdev) } for (q = RAVB_BE; q < DBAT_ENTRY_NUM; q++) priv->desc_bat[q].die_dt = DT_EOS; - ravb_write(ndev, priv->desc_bat_dma, DBAT); /* Initialise HW timestamp list */ INIT_LIST_HEAD(&priv->ts_skb_list); From patchwork Wed Jan 31 08:41:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13538943 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9D4D78676 for ; Wed, 31 Jan 2024 08:42:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690526; cv=none; b=ZIQro58oIIaIDZVrr0V94443lSlnOLf/qOofrngQ6ZF46aleBs3qAN6Q7G7aPl/FjDeXevyOGcmnDJpt+qvcnDGuwm9BhIqTVXFarN2rIHRj8rXLkq4D0tTVfpRou3N6VeTiZ9nIkYgVuE0sz9nQtgsK+kz93EwEsCFtLjYSQ6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690526; c=relaxed/simple; bh=0ud/earGHL5ceFLGnOZtm9LhMl1uT4ztwKY+qDHwNlk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OKwyIKpx0Lof9KU/CnrrEkXKcCaGGTe85ub00zOKt4R+g9XOvAX5VimSC6eZ+2SMKqW7ZrqHSpfYl0gyNSJm3t/NTM7qbiqvN53Xe3fnQcNW/jFXcxG6F6UtqdVlTIwZPP2EJOKDGPdzW3i4BQ7tetRxkcS5NzAIXl2oIK5isbI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=Ah6g2KWE; arc=none smtp.client-ip=209.85.208.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="Ah6g2KWE" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-55ad2a47b7aso5349732a12.3 for ; Wed, 31 Jan 2024 00:42:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706690522; x=1707295322; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BONSj5EqZQfFZpRQIDw4PpK7x+FJrmVdcN0Lou7oXa8=; b=Ah6g2KWEBJRXaqd3OycZ5wKzvSrdWf3Rz40f+EnfW/YcQ/nc7Fau03x8raS6ddfWb6 Vgl+3MrCV4TrT8Hnwt5cV9bVMI16oin0EQ8Jjzh0vwdZ00gUAL00d1dFoy8soasgcPNu xaQAx9uPTMGhnJ5WmvZ59kf4bxihHYaX4+1qYK0WUtaccN3ZslGHfvzLT9U4zcJQUolj eYr9VH9mkEbd3LGRxCauleROEsfHtvu/fd+amlQpZVdYVeGo0Wji4KPjuB8O6Y18ohtA L02ZPFRi2wFj+T3u2pTw/0H6tXFoT7ThmHkWpmt5vJ7eagSXOfd5AB6xGdJo7EDR36GJ ITbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706690522; x=1707295322; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BONSj5EqZQfFZpRQIDw4PpK7x+FJrmVdcN0Lou7oXa8=; b=Gq4LZzmQlULNxTPxq+TkKjyOnrrixs28qSn6nfSdAnywzqaRex2N1gpZFp+DS8NzbX wkafxaxBnLwJxdBzUM5cGMxavA2wsocLpctKEsmc6ILJQvaBkBzwzY99o9sxB/5JgEQ5 wEo62cxYmFcUYoFQL9A4SyS2XvVoxDuV3vv3t+eVDrNZITqC4L364vE/u9FAV0E5A8E/ PUOPq6rP7EsQdQL0zWJLwrXLBpY/vPgEdC0iLZvSt6+cMHDGH3yfwqtpiLPmkFeYfvEe Hm2Sw1rEc18tyeWs6mPj2cX8g8KuOrY3rliMv38l9lKoR0zyt0tFpvqXXVMvk3XDthAF JixA== X-Gm-Message-State: AOJu0YzBbFmcFdzmTXW8EsjIJUbGuT7MlYvN3RkQaDkqY1J/SAL3u102 mpvqqpjl4S8ArllCSgvoOqmEEdPtBG6PHh4xH0NckxAF5RuEmD9unISlOdORzBw= X-Google-Smtp-Source: AGHT+IFzePjkrpbDwYkajriYVblY0QL9xwF/SLkY0HcbYLtg3g8hGD8Nbc3LdTsBKGTDNQuWZFC/ng== X-Received: by 2002:aa7:d891:0:b0:55f:19c4:600c with SMTP id u17-20020aa7d891000000b0055f19c4600cmr601408edq.37.1706690522296; Wed, 31 Jan 2024 00:42:02 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWypG4NjsIWtmFnxHAIB2Xg4ZXhliltyN5KNvLXbGuACdT1px3qJ0c8BBI24SB7qIODYblTkwjFDInRgDNZxlEXJNxY/RD5dsbkqakVl751NSpmf2mZatCmYZTvkdUPHe2km8sRAxGwbT5t6YuH70Xq5cOmWrYJB8Hh0oZKdlY/g/KhFsjaKtXy+A4cO0UrgIjCDbUGuj8afhxGyGyNPTni+UO6qdJoQCpI2Y3120xMCLz3H1h/+FWu1dwoKKbMMXPLMalLJvvti5RibK5s/0K4gbBu1S1QUGCgVuEHJm5sTDlBAYJpohO5e8qpvwdmXmOxJWXcT0eQtvqlOIjg/SNxELpI0eF01c1WhZC1iVom3f5eMYRZaKJlKy/OxOcoc0uAPEtCC3sAMjRg6X86+1n2GaGiiX2RCLJhFK7+zMDHLFv8Tho= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id cq16-20020a056402221000b0055f02661ae2sm2863630edb.78.2024.01.31.00.42.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:42:02 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v5 12/15] net: ravb: Move PTP initialization in the driver's ndo_open API for ccc_gac platorms Date: Wed, 31 Jan 2024 10:41:30 +0200 Message-Id: <20240131084133.1671440-13-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> References: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea The initialization sequence for PTP is the same for platforms with ccc_gac and gptp (according to "Figure 50.71 Flow of gPTP Initialization (Normal, Common to All Modes)" of the R-Car Series, 3rd generation hardware manual and "Figure 37A.53 Flow of gPTP Initialization (Normal, Common to All Modes)" of the RZ/G Series hardware manual). As some IP variants switch to reset mode (and thus the registers content is lost) when setting clocks (due to module standby functionality) to be able to implement runtime PM, move the PTP initialization to the driver's ndo_open API. This commit prepares the code for the addition of runtime PM. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v5: - none Changes in v4: - none Changes in v3: - fixed typos in patch description - collected tags Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 318ab27635bb..54099fef946e 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1876,7 +1876,7 @@ static int ravb_open(struct net_device *ndev) ravb_set_gti(ndev); /* Initialise PTP Clock driver */ - if (info->gptp) + if (info->gptp || info->ccc_gac) ravb_ptp_init(ndev, priv->pdev); /* PHY control start */ @@ -1890,7 +1890,7 @@ static int ravb_open(struct net_device *ndev) out_ptp_stop: /* Stop PTP Clock driver */ - if (info->gptp) + if (info->gptp || info->ccc_gac) ravb_ptp_stop(ndev); ravb_stop_dma(ndev); out_napi_off: @@ -2200,7 +2200,7 @@ static int ravb_close(struct net_device *ndev) ravb_write(ndev, 0, TIC); /* Stop PTP Clock driver */ - if (info->gptp) + if (info->gptp || info->ccc_gac) ravb_ptp_stop(ndev); /* Set the config mode to stop the AVB-DMAC's processes */ @@ -2813,10 +2813,6 @@ static int ravb_probe(struct platform_device *pdev) /* Initialise HW timestamp list */ INIT_LIST_HEAD(&priv->ts_skb_list); - /* Initialise PTP Clock driver */ - if (info->ccc_gac) - ravb_ptp_init(ndev, pdev); - /* Debug message level */ priv->msg_enable = RAVB_DEF_MSG_ENABLE; @@ -2861,10 +2857,6 @@ static int ravb_probe(struct platform_device *pdev) out_dma_free: dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, priv->desc_bat_dma); - - /* Stop PTP Clock driver */ - if (info->ccc_gac) - ravb_ptp_stop(ndev); out_rpm_put: pm_runtime_put(&pdev->dev); out_rpm_disable: @@ -2890,10 +2882,6 @@ static void ravb_remove(struct platform_device *pdev) ravb_mdio_release(priv); - /* Stop PTP Clock driver */ - if (info->ccc_gac) - ravb_ptp_stop(ndev); - dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, priv->desc_bat_dma); From patchwork Wed Jan 31 08:41:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13538944 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43EE179DB6 for ; Wed, 31 Jan 2024 08:42:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690528; cv=none; b=HFDi5oWywcDHhpL4VHPjmfn3ALBCe1Fu742WEgLKBbmeJ7D1vCQpBiHOsad/+eXrUs3cXiqCH0yK8sHYwJ8LdiuSFcKdMD60mXU55z+1waUXhz79ELIyXKi/vJelZezR4BF/Fy5bbde2fJA+nPURSNS8nxn7UUEq1qYA+PiLKH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690528; c=relaxed/simple; bh=SMFD2wooseUV4EjGWpE317D8OQSKSM0pSKR/g7N9T7Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=baSXfH8GVbvzQ9shYQVnx/2gpcqJ5EdiMMyr7pzoeF5wy8hCixvT9psd+zUyewxokz0CQ1Icqq3pxFy6+QCxVQb/lKkhPUVsb03/Jp3pldSvVfTS361VwLZOW+zt7BceSECr58YY6H9ttiZMiE9xToXg8ACYaOpNAt5cpYearV4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=bm4NH0oE; arc=none smtp.client-ip=209.85.208.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="bm4NH0oE" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2cf4a22e10dso57909481fa.3 for ; Wed, 31 Jan 2024 00:42:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706690524; x=1707295324; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j4P3NNUndOj/U3jAxOrkBuhZxASPQ1uf/KZV1iCgPUY=; b=bm4NH0oE3y+H9/a12wqU+uye9zHea82rWi2hXLGjmXTE90aKKQGz5iBzMb7Bml1pl7 8TCnUoR0OZFKI7kOH1sVXf2016yzi9OZQVYG2ZduWATZDLKuGvYgobtzttSDxnGEeUhX DWqL1IQLgqyjbZLY4HDr/kZw82rDBJ0GxPCWPCtBaKAGHqwhRRTzCx1j6eZuNFEDyUmG 6n3XwhNjWUaNHF12LwQucO+ne/gcpTtbOXBpFLehSvbTNNEVYn5nu8QQVZXhENYVjUEL ACmNMVKQrVOGcyMX00ZXCTHkNgKqEwvasQK8+BZ6ZNTq9kkBxMQXiV0FiDyoRNeHxs21 6gIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706690524; x=1707295324; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j4P3NNUndOj/U3jAxOrkBuhZxASPQ1uf/KZV1iCgPUY=; b=Koqff0XhUOheDUwbaFePIOmW7CjBU5N7/gO3ycEv5CynyrSxoRyDIYJqgIh4fLrEB2 RZrm0mG1Zdg48CH/S1ng2utRQjRUCAArzWGO8hDtqucivK03QzinR1HULCpIXfl1TYal KN51fXgLjiDKxwZgm1sKooXadAZD+U3CMafeGwaa9VhZVcNUZaGgYz5J/MyYQ0sELVoH lec7e/btnNCsHe5OFhc35JUxH9TJ0VKBhgnVo9cl4nCMtBhoqWe9VjJMGI77q/cp89Z7 g9ZW475XnZwdIdA1Rs0APwh7eLupaibbXqKElkCARCLDq4VTk1XyGLR/oQU6cCPGmFKV dDWg== X-Gm-Message-State: AOJu0YxgF+rS915BMun4bFtYjhr/zOxwEfupMOtftAfuUCwsgHkCxpOm fU/o2QSGJ2CtqY2HZ+ga8npfS5UJH5WSScCOwNZbJzf8Eoy+3FtL3lVek/0QgVA= X-Google-Smtp-Source: AGHT+IEiL482XuRa8KwAmlwH28GEu/fJYWXxZ+wtgFd+vKtDuH84PyPSa2bjesp31jrgpOFmZFaEcQ== X-Received: by 2002:a05:651c:221c:b0:2d0:604d:fda6 with SMTP id y28-20020a05651c221c00b002d0604dfda6mr814787ljq.44.1706690523545; Wed, 31 Jan 2024 00:42:03 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXrqLJw9JLWNup24eFLJBtSBvdaq8f/dNVorTAyKDfd5NoIXrdnwnkl6AVlqcBGvNUakV7rbez6nz+Prdy4WZr+QWhdnok1VXiZcPDWFsT1c0QE06g++9XfhA7XqGDqPiGw7SfgxTS6NIP5tjnraa8j3W8I0xeeU2w9K/uYk687RzKWp2OYlhHjBJqCzQ7fE92V4BJJDbTgUYv3YfsvtyXCn3TTElv00VCSgEsDNJDn1fVg2aYLxSDaNWaaeKH8j5Dht2RXCZxYCApPb9LJPU6Utqg9QNwozTFSEJB1kQBdztPmccL4l4x602pGASxZYku8GMg8K6Xuw07THbDX0GK4wb6yqY3/RcxaqxlbsUH+Py4PNDWL5eA18CXk4xZPmylN5quXnNu6tHbrIckKvI7c4tFkvbgGDVVJkEe0XVA80yW4DIw= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id cq16-20020a056402221000b0055f02661ae2sm2863630edb.78.2024.01.31.00.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:42:03 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v5 13/15] net: ravb: Set config mode in ndo_open and reset mode in ndo_close Date: Wed, 31 Jan 2024 10:41:31 +0200 Message-Id: <20240131084133.1671440-14-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> References: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea As some IP variants switch to reset mode (and thus the register contents is lost) when setting clocks (due to module standby functionality) to be able to implement runtime PM and save more power, set the IP's operating mode to reset at the end of the probe. Along with it, in the ndo_open API the IP will be switched to configuration, then operation mode. In the ndo_close API, the IP will be switched back to reset mode. This allows implementing runtime PM and, along with it, save more power when the IP is not used. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v5: - fixed typos in patch description - collected tags Changes in v4: - set config mode before reading mac address Changes in v3: - fixed typos in patch description - in ravb_probe() switch the hardware to reset mode just after phy initialization Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 78 ++++++++++++++---------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 54099fef946e..0dab98ea615a 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1756,6 +1756,27 @@ static const struct ethtool_ops ravb_ethtool_ops = { .set_wol = ravb_set_wol, }; +static int ravb_set_config_mode(struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + const struct ravb_hw_info *info = priv->info; + int error; + + if (info->gptp) { + error = 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 = ravb_set_opmode(ndev, CCC_OPC_CONFIG | CCC_GAC | CCC_CSEL_HPB); + } else { + error = ravb_set_opmode(ndev, CCC_OPC_CONFIG); + } + + return error; +} + static void ravb_set_gti(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); @@ -1864,13 +1885,19 @@ static int ravb_open(struct net_device *ndev) if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); + /* Set AVB config mode */ + error = ravb_set_config_mode(ndev); + if (error) + goto out_napi_off; + ravb_set_delay_mode(ndev); ravb_write(ndev, priv->desc_bat_dma, DBAT); /* Device init */ error = ravb_dmac_init(ndev); if (error) - goto out_napi_off; + goto out_set_reset; + ravb_emac_init(ndev); ravb_set_gti(ndev); @@ -1893,6 +1920,8 @@ static int ravb_open(struct net_device *ndev) if (info->gptp || info->ccc_gac) ravb_ptp_stop(ndev); ravb_stop_dma(ndev); +out_set_reset: + ravb_set_opmode(ndev, CCC_OPC_RESET); out_napi_off: if (info->nc_queues) napi_disable(&priv->napi[RAVB_NC]); @@ -2236,7 +2265,8 @@ static int ravb_close(struct net_device *ndev) if (info->nc_queues) ravb_ring_free(ndev, RAVB_NC); - return 0; + /* Set reset mode. */ + return ravb_set_opmode(ndev, CCC_OPC_RESET); } static int ravb_hwtstamp_get(struct net_device *ndev, struct ifreq *req) @@ -2566,27 +2596,6 @@ static const struct of_device_id ravb_match_table[] = { }; MODULE_DEVICE_TABLE(of, ravb_match_table); -static int ravb_set_config_mode(struct net_device *ndev) -{ - struct ravb_private *priv = netdev_priv(ndev); - const struct ravb_hw_info *info = priv->info; - int error; - - if (info->gptp) { - error = 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 = ravb_set_opmode(ndev, CCC_OPC_CONFIG | CCC_GAC | CCC_CSEL_HPB); - } else { - error = ravb_set_opmode(ndev, CCC_OPC_CONFIG); - } - - return error; -} - static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name, const char *ch, int *irq, irq_handler_t handler) { @@ -2785,11 +2794,6 @@ static int ravb_probe(struct platform_device *pdev) ndev->netdev_ops = &ravb_netdev_ops; ndev->ethtool_ops = &ravb_ethtool_ops; - /* Set AVB config mode */ - error = ravb_set_config_mode(ndev); - if (error) - goto out_rpm_put; - error = ravb_compute_gti(ndev); if (error) goto out_rpm_put; @@ -2816,6 +2820,11 @@ static int ravb_probe(struct platform_device *pdev) /* Debug message level */ priv->msg_enable = RAVB_DEF_MSG_ENABLE; + /* Set config mode as this is needed for PHY initialization. */ + error = ravb_set_opmode(ndev, CCC_OPC_CONFIG); + if (error) + goto out_rpm_put; + /* Read and set MAC address */ ravb_read_mac_address(np, ndev); if (!is_valid_ether_addr(ndev->dev_addr)) { @@ -2828,9 +2837,14 @@ static int ravb_probe(struct platform_device *pdev) error = ravb_mdio_init(priv); if (error) { dev_err(&pdev->dev, "failed to initialize MDIO\n"); - goto out_dma_free; + goto out_reset_mode; } + /* Undo previous switch to config opmode. */ + error = ravb_set_opmode(ndev, CCC_OPC_RESET); + if (error) + goto out_mdio_release; + netif_napi_add(ndev, &priv->napi[RAVB_BE], ravb_poll); if (info->nc_queues) netif_napi_add(ndev, &priv->napi[RAVB_NC], ravb_poll); @@ -2853,8 +2867,10 @@ static int ravb_probe(struct platform_device *pdev) netif_napi_del(&priv->napi[RAVB_NC]); netif_napi_del(&priv->napi[RAVB_BE]); +out_mdio_release: ravb_mdio_release(priv); -out_dma_free: +out_reset_mode: + ravb_set_opmode(ndev, CCC_OPC_RESET); dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, priv->desc_bat_dma); out_rpm_put: @@ -2885,8 +2901,6 @@ static void ravb_remove(struct platform_device *pdev) dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, priv->desc_bat_dma); - ravb_set_opmode(ndev, CCC_OPC_RESET); - pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); clk_unprepare(priv->refclk); From patchwork Wed Jan 31 08:41:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13538945 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E30597B3E3 for ; Wed, 31 Jan 2024 08:42:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690530; cv=none; b=HHycTnreTkkFI+myss0WFtxq1HkG9mqXoG2+t/VNhD7Np4MFGaM57JUduoWId2hX8sfuQ0A7jtt9J4igLCNpWsE/yvL8Y5t5r+3AwuROiBKtm8NSTdgsWljlZfmKPgTlYRob4SN2ZIwtBajZkHvqwMCfB1pe7AclnTo1qif/Opg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690530; c=relaxed/simple; bh=M4XElsAbkAPToo3ZEnKBpvLmehS5jEZzhlJpMuxS2lc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MxJa2kEjmc9SZhkvsoluAxuAeIpZ9gv1GchK4SqSh2aSK/SOU1P0/9o+CbAsJmYcIMv0fbCHPHCOUUPKfxcMMGMEA4Or7yp+HW/kswoj4FM+afTso+MjPZ4Qi+FWRWK6gOPaHRDLQuSew52ToKtjpwACCcvD0fSKfIm+ByKwC/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=IpHUfG7v; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="IpHUfG7v" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-55c2cf644f3so5036705a12.1 for ; Wed, 31 Jan 2024 00:42:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706690526; x=1707295326; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E1XrNomjmra/GM8RS/lknacwokF475kMeMhwWZ3EcPk=; b=IpHUfG7vGrYoMGri/XmbloOWvDcKQ9AFzDYOQ92wu4KCpW1cbM2Px27HrdVYIJd+Eq zHLXboJ+ZgY/cRoPLGoKEHiymO2GtyH9RJkdHWzVo050pyjLp434PA7uQp3kf6RNLLbX uaL14BScifZSILXbfD2M0fKUvvodRjAB5Qsv+S3Vab4tKL7tgqMJWwOO/AJsQ5kxvIrA gYE8nOo/BCrlmVU15EKn/iEBtGpRJidIa+h3spZQNZFZ4CJQ6lv8LSkzSZqkep8FgXwf lgJJZuuYBONWGxdrPHdtVy6U4xY53qFUJTDnk0fYHTWY078LMZFVoTBUoOOUA5mdSs+o rs9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706690526; x=1707295326; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E1XrNomjmra/GM8RS/lknacwokF475kMeMhwWZ3EcPk=; b=H9OV1d30r2F42L30NGELq7SaBl1Ouq3E0AZ9+OaMD5dCZxzVBsdThCi9wE7UALooMs 9tnXknOMgqIuYcwiVGoNBs1FUbBrrQHGtlR8yR8DNNo/k1TBP/pFk0W+46tXc4receiU WF58eRx6hC78/gNKXYiIarLocNY60Yd4zgn4u5moXuXmY50x/E20kgup2yKOJDh21j5m j+GXN6lGtNU1NiGqRr0OT6Q0qqekQwhgdpMV17O2XinrIwa+uhBfWjrkM9wckHWddF6J 5m29/h21SXYmMp7wSqf+J4yfloOb7zwlryg3DpcAvvql1sBw4zp+ZhsAQYwdsepQowTN hLEw== X-Gm-Message-State: AOJu0YyHXtCJQhon7V9IVOVE8wITRidUybbTeNScdQsYhdTx5C1tgiBn Iv8/b6rvmYs9x4nkdhzCPJdSyLETaoR/Q6cmbOZxlDpV9LZEa+JzkkK2mKM4hhI= X-Google-Smtp-Source: AGHT+IEYcNtSIIzLCU/TMm9w1bEGYlnXRZN3KzRwiFoYa83jrAWMHaIWWxOlkyinI5M2+MzKlTNT+g== X-Received: by 2002:a05:6402:1cad:b0:55f:82b:2da3 with SMTP id cz13-20020a0564021cad00b0055f082b2da3mr561401edb.22.1706690525968; Wed, 31 Jan 2024 00:42:05 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXIkeN+/q/7fkLe7PzMiRTrGGYp00Bgy3bQ1jPEuKPEBJVX0h37D/hMWLvhlSkSi/f13QSgf+r+BRMOgXxH2a6200kHM1DYhsUJAYuPrh+rbrACpP24O0qT5nlfxcDfkhTSEYigBHk9WPIqNVGzy9itC6VRSD6ZM1TfbPIlUSq3J48kjLfI4HMJy0NaWMPPtGVnHq8NwXx8klz1JZY0Q3wBlpSgklAgzL1FuUmw9Dk+JQnTPWmfWMRX4x6r5HlVt1p4uNCk2AwybR+1C1+9FID1AXV+1CbZiZQhaYKIfgfSUJXhmrQHcocU6CSpuKjHJENER11RspvZ3awkm5ws8gSx+02Joy+fx4+IfcaVqF2QmJ8kX2UsBRZQXPGQYRlqCKdibrNBG1lMKzAyZkHH6xN444BHhbTPURQnrRaOj4AcTId80Hw= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id cq16-20020a056402221000b0055f02661ae2sm2863630edb.78.2024.01.31.00.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:42:05 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v5 14/15] net: ravb: Simplify ravb_suspend() Date: Wed, 31 Jan 2024 10:41:32 +0200 Message-Id: <20240131084133.1671440-15-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> References: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea As ravb_close() contains now the call to ravb_ptp_stop() for both ccc_gac and gPTP aware platforms, there is no need to keep the separate call in ravb_suspend(). Instead, move it to ravb_wol_setup(). In this way the resulting code is cleaner. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v5: - none Changes in v4: - none Changes in v3: - fixed typos in patch description - collected tags Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 0dab98ea615a..661236affa5b 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2929,6 +2929,9 @@ static int ravb_wol_setup(struct net_device *ndev) /* Enable MagicPacket */ ravb_modify(ndev, ECMR, ECMR_MPDE, ECMR_MPDE); + if (priv->info->ccc_gac) + ravb_ptp_stop(ndev); + return enable_irq_wake(priv->emac_irq); } @@ -2961,14 +2964,10 @@ static int ravb_suspend(struct device *dev) netif_device_detach(ndev); if (priv->wol_enabled) - ret = ravb_wol_setup(ndev); - else - ret = ravb_close(ndev); + return ravb_wol_setup(ndev); - if (priv->info->ccc_gac) - ravb_ptp_stop(ndev); - - if (priv->wol_enabled) + ret = ravb_close(ndev); + if (ret) return ret; reset_assert: From patchwork Wed Jan 31 08:41:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13538946 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B05D7BB10 for ; Wed, 31 Jan 2024 08:42:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690531; cv=none; b=qcXdILWtXArXwhfE0Vdck4E+Niya3OgvyGbwfiNwrh7Sg6oxhkcwnL45H1Rn1p0Ul0TO7DmwfWvExl8OnPVbpSONXdyrEDIlFXNvIWtzbWJLx5oOJOPe2W5ywl4nGRYFe86YeYnwJNDx0RKjb/R58LKHOQbm43B7j6oOQkKgr5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706690531; c=relaxed/simple; bh=WfssnXglDOxvPIQ881a3cyhpT+Q6juxzbfkgOXoITAs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=vFxsGiD3wWu4/rzhIx7U/VQtRrFCCe0frg2kAGTn+bNcwYMjbSwAXX6nMdbre5AP1FhReP5ryn3yYyxMJ1yAjv/GcPiFZ+qEE60TycJZ9ZIpq97oJb97kl0DJ6ze72Ka+7JaLcparHI5RGQeY5ihyRKWxsFrcNqeyObXzj5k14w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=djfqqTDn; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="djfqqTDn" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-55f15762840so2951995a12.0 for ; Wed, 31 Jan 2024 00:42:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1706690527; x=1707295327; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jBX8tkoIGR61lIZo86EimVQm/t/fqsSustUrCgWT/u8=; b=djfqqTDn7y3VRP2bpuhyzGm/rVDZ97/sQXKzf1cCxpgzrpkQ563YnBkC/ILWiCq5TU K66AdcGkUUeOCafM7dzgze6uP1xmB3DQ0z0QrfVCHNel1lAl+FMAm1yDSPLEHLYk+YtR JOQN2cyi+M6rWSlizvbWYrL/bu6bBq6YCOXOFLmv37mvewZ5IXsbqqmx9wfDw9xlrz6a cHk7h2mOLSBOOrWfmxTFkl/fVF6DExmkeICh5gKVudlniEEYEBAhKwG4ok6Bkq/4k8SD 9F5ZynX1KdkwdUFd6FBxbTrXRdB4YcCDi4jns3PBvQxdUOYQJnVVTBS8e1fd8dK6OLQb xSuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706690527; x=1707295327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jBX8tkoIGR61lIZo86EimVQm/t/fqsSustUrCgWT/u8=; b=X+yntIEjcNqhrKfKa57e0RTH6Y4UFV3Ev0TK5kn9N1a1GlybCJNS4Ip4zpCtt6Gl53 D/HaH1i3vkAeRCJVVg09awF/O+WFSV2Pn7i4wcwqEd83s1fPisczcOtysyLRVgpR1FxQ xcCni8BQaVotIDnppqZS8B2b2D1TNOPET9JteS2ti/YV6Py/6lFGFAMbaH5sKNANpPqU E20ynnRjmFBaHEIoEzL5ucW3hXkkrdaBfyLGxpKzOMXTzJDDESVqN7oGZq4/9YVFcpPd asVmglAn3GFhqvmv9sPjBc35B2l78SLC+ygePSUu7Lp3TR/OpT6AEuNOC67c2qD5Sr5b 2ExA== X-Gm-Message-State: AOJu0YxbjpirPomFdJkQTBSROqi2qHSvEygJAqQQP5zZrFOQa1Q4HU0c dHn/qTCGUgplV+0qPeqIYGcNCG9NrJxrjZgIzNUNX8GP+JAfbq2Aj83lvP7tq8NYxg70yik1Au1 E X-Google-Smtp-Source: AGHT+IETb+W9LxMAOv3c52JCdeIUNnyL/r7fCODulLaukxAbqKVWWDu8z8ad43Vur2B0BD+jnUXWjg== X-Received: by 2002:a05:6402:ca3:b0:55f:6b5a:6310 with SMTP id cn3-20020a0564020ca300b0055f6b5a6310mr526532edb.33.1706690527359; Wed, 31 Jan 2024 00:42:07 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUj9A6JryuTEC/GJvCzjlvGXsHqucq7yAlwoC3FuaYE4ZR6bPhrBiy7YkBu2VgTH9sX5DKKTdyA82C5fc8TDoNnKNNNsbaFV9eG2gf2fLyWjC+UIa+MY8jck33SpF4f3f1w6OkzUUYR3/rcXZ9lKRq5St844j8pX468KStrj+j3O3Q7m4mnUA3Cgyx6jkx5xYy4afFm5at6VZ+i0ve0gTCFO2XphAkUqm1r70SxrsM+2eXeT1kITr9IyiqeKWALqEGF3MGpqRSIhVWbk3tYrcZhAudIj2T8NKjXt1/ots8H40cP7PJxCYxzPbykt+B4evpDX9ywLwKKDjVKOLAASc5uODthJmEIDeWdn3QDBEHZ9pDErNauNgjfVmM8sZmUGV6u7s7SPDkGqovHkqkII7G01nuzG5Eg4ca9i7D85kyVK96/osU= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.87]) by smtp.gmail.com with ESMTPSA id cq16-20020a056402221000b0055f02661ae2sm2863630edb.78.2024.01.31.00.42.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:42:07 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, geert+renesas@glider.be Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v5 15/15] net: ravb: Simplify ravb_resume() Date: Wed, 31 Jan 2024 10:41:33 +0200 Message-Id: <20240131084133.1671440-16-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> References: <20240131084133.1671440-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea Remove explicit calls to functions that are called by ravb_open(). There is no need to have them doubled now that the ravb_open() already contains what is needed for the interface configuration. Along with it, configurations needed by PTP were moved to ravb_wol_restore(). With this, code in ravb_resume() becomes simpler. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v5: - none Changes in v4: - none Changes in v3: - fixed typos in patch description - collected tags Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 58 ++++++++++-------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 661236affa5b..9521cd054274 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2939,6 +2939,20 @@ static int ravb_wol_restore(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; + int error; + + /* Set reset mode to rearm the WoL logic. */ + error = ravb_set_opmode(ndev, CCC_OPC_RESET); + if (error) + return error; + + /* Set AVB config mode. */ + error = ravb_set_config_mode(ndev); + if (error) + return error; + + if (priv->info->ccc_gac) + ravb_ptp_init(ndev, priv->pdev); if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); @@ -2978,53 +2992,29 @@ static int ravb_resume(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct ravb_private *priv = netdev_priv(ndev); - const struct ravb_hw_info *info = priv->info; int ret; ret = reset_control_deassert(priv->rstc); if (ret) return ret; - /* If WoL is enabled set reset mode to rearm the WoL logic */ + if (!netif_running(ndev)) + return 0; + + /* If WoL is enabled restore the interface. */ if (priv->wol_enabled) { - ret = ravb_set_opmode(ndev, CCC_OPC_RESET); + ret = ravb_wol_restore(ndev); if (ret) return ret; } - /* All register have been reset to default values. - * Restore all registers which where setup at probe time and - * reopen device if it was running before system suspended. - */ - - /* Set AVB config mode */ - ret = ravb_set_config_mode(ndev); - if (ret) + /* Reopening the interface will restore the device to the working state. */ + ret = ravb_open(ndev); + if (ret < 0) return ret; - ravb_set_gti(ndev); - - if (info->internal_delay) - ravb_set_delay_mode(ndev); - - /* Restore descriptor base address table */ - ravb_write(ndev, priv->desc_bat_dma, DBAT); - - if (priv->info->ccc_gac) - ravb_ptp_init(ndev, priv->pdev); - - if (netif_running(ndev)) { - if (priv->wol_enabled) { - ret = ravb_wol_restore(ndev); - if (ret) - return ret; - } - ret = ravb_open(ndev); - if (ret < 0) - return ret; - ravb_set_rx_mode(ndev); - netif_device_attach(ndev); - } + ravb_set_rx_mode(ndev); + netif_device_attach(ndev); return ret; }