From patchwork Tue Nov 28 08:04:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13470596 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="NSH+yIqa" Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCE0ACB for ; Tue, 28 Nov 2023 00:04:44 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4079ed65582so36352775e9.1 for ; Tue, 28 Nov 2023 00:04:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1701158683; x=1701763483; 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=TER/zjgFsQ4zH/M/nBtL41p2wpZGtg22rimu0p57AMs=; b=NSH+yIqa5s/ZejJN07Qauf8d3WJ0IEOgE4+CpI5Ssa7gTjJgaJ8SKPO995OfuT9yiT ayBU6HqLc35b+YC1Pe9OicLyCOXwsySYl+EVIcsaYZ6H8AHJROjjcYxgh3eIBuAxQR5i WI+9CDTAi8vOPIX9u3K5rbkKyovh0twyjTiQdGLGRyP+trLsVOMDekoT7VazH0cra6Nk UgFzWAdzI7bN9m7wUyFNUQSbKFLze6KCd8/jzdTqd21+1eAzztQYyWaIQ0q+qqYKgLI6 UtjVproy8mrqO703i2QqpZmnOhBCmXFbFgMdf06JTPZSmO7asZqVGnAiunDC3+D7OvQD KHzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701158683; x=1701763483; 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=TER/zjgFsQ4zH/M/nBtL41p2wpZGtg22rimu0p57AMs=; b=kHD8Ugdc+ReLRuye17e8gzUF4l0u/zIoG8+mLRNN+wHhbuQI8BwfeiuFPqM7l3AGA9 ptDHRL3BN/ytTh4sYDhJNMl3ggbkjmsSGyUBP0BgfJr39OR4dtih7q3+Pr2iSCCWRMFl ndWkMrIbx5v9xkEGP1Kfm5BcS6Po2eIUy5hgUktNB8vO3nStJuYrHmYPDhIvm5NkfnaJ SWcrbnRA4/tVG85iTtympZx/f8IlkDIvQeC8ZzzpIRVuVA8Bb+xRCYrG1Xn2x1sMX7Wv CA/FNJVau+hFTkexvx+lfPpTJrRoaLTXrlatrN8oOF/ZmitFb2lMTrsjCNKtiN2P4VD3 FkdQ== X-Gm-Message-State: AOJu0YyTEZtie9jucCbEfSxYeKCTiDWiihpOMb737Qi3ftl8E7lJGfcA QjC6rtK9sCUfTkPu7WCLHoqiNg== X-Google-Smtp-Source: AGHT+IF9kC7vFv0UFd4k0YZm4RaGwXdesZdpw8BOTVxF/2FVztXa95IPMgGc0hCY8Loptjy7Z4wZhQ== X-Received: by 2002:a05:600c:4f8a:b0:40b:4520:45a6 with SMTP id n10-20020a05600c4f8a00b0040b452045a6mr4460089wmq.8.1701158683147; Tue, 28 Nov 2023 00:04:43 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.125]) by smtp.gmail.com with ESMTPSA id g18-20020a05600c4ed200b0040b4ccdcffbsm1127534wmq.2.2023.11.28.00.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 00:04:42 -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, yoshihiro.shimoda.uh@renesas.com, renesas@sang-engineering.com, robh@kernel.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com, mitsuhiro.kimura.kc@renesas.com, masaru.nagai.vx@renesas.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/6] net: ravb: Check return value of reset_control_deassert() Date: Tue, 28 Nov 2023 10:04:34 +0200 Message-Id: <20231128080439.852467-2-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231128080439.852467-1-claudiu.beznea.uj@bp.renesas.com> References: <20231128080439.852467-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea reset_control_deassert() could return an error. Some devices cannot work if reset signal de-assert operation fails. To avoid this check the return code of reset_control_deassert() in ravb_probe() and take proper action. Along with it, the free_netdev() call from the error path was moved after reset_control_assert() on its own label (out_free_netdev) to free netdev in case reset_control_deassert() fails. Fixes: 0d13a1a464a0 ("ravb: Add reset support") Reviewed-by: Sergey Shtylyov Reviewed-by: Philipp Zabel Signed-off-by: Claudiu Beznea --- Changes in v2: - documented the addition of out_free_netdev goto label - collected Rb tags Changes since [1]: - added goto label for free_netdev() [1] https://lore.kernel.org/all/20231120084606.4083194-1-claudiu.beznea.uj@bp.renesas.com/ drivers/net/ethernet/renesas/ravb_main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index c70cff80cc99..50c4c79be035 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2645,7 +2645,10 @@ static int ravb_probe(struct platform_device *pdev) ndev->features = info->net_features; ndev->hw_features = info->net_hw_features; - reset_control_deassert(rstc); + error = reset_control_deassert(rstc); + if (error) + goto out_free_netdev; + pm_runtime_enable(&pdev->dev); pm_runtime_get_sync(&pdev->dev); @@ -2872,11 +2875,11 @@ static int ravb_probe(struct platform_device *pdev) out_disable_refclk: clk_disable_unprepare(priv->refclk); out_release: - free_netdev(ndev); - pm_runtime_put(&pdev->dev); pm_runtime_disable(&pdev->dev); reset_control_assert(rstc); +out_free_netdev: + free_netdev(ndev); return error; } From patchwork Tue Nov 28 08:04:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13470595 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="BhSlTlws" Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 584FE98 for ; Tue, 28 Nov 2023 00:04:46 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40b30308c67so38204255e9.0 for ; Tue, 28 Nov 2023 00:04:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1701158685; x=1701763485; 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=tex/f+v5XiThmeQ/1yf1Rnsid+DeltBdSjavRwGvUE0=; b=BhSlTlwsDX7EXSCG+VX6B79BvgoXHd3U8a/cpeGFbEjaV2osMCqUhL1pl4XF9LE0bQ iPwiKRrjO2grjbrzsg8VG4nqHOJRJGP8BDCO0SuLC0xuWcG/MGsCJrry6FTYGfFBFkQe rhCsCs8vcXl7YB+XR+OVZp8Nkz4hPDab+7zPn6DtAlpGmXmseDlEjry+8DyTE3Q0SRDF S01ZUwc8WvTwJsfEi6HLvdLa7IxdUoKiMm+gnW1DcEkdwk94w/vERWZyR/S8VCyshEvl UuKsydZip5vsibo/rNvTIu6QW2BxwpZd5MSQ4vy2tMxbcx4TDYCDdrLVv/+t7poAAXr/ bhdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701158685; x=1701763485; 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=tex/f+v5XiThmeQ/1yf1Rnsid+DeltBdSjavRwGvUE0=; b=PiRczplVG5RUMKBHrXjgp/4NbvtWMJ0KdAkiuZJK8qBuQqTSZBIITx3+6+0pgQNekL qRzu24RLs4hnLb/LVyiir3zDeRR8j3f/u2mvhfaQGnfiMv4A10wi3rPfXqFtNrkobzwr +D18+TBiH8Aa0XwGRskSI8BP5alSkFiCZ6AovWwvX/OcPuG55ysJ0LapEtsJ7k6rADW0 p0gluszT2/ZnXoUrlPS6qpD+gxxI0QJlzXHhPtSCSvqo4ggzbv8lZQV/ftLdUZuB1Ad6 kp+Vk1ZmL5qvDcyQKxP1KQ5t6MyYfyd1dNj+kFFW10fskA0wpjZITXePFnfQn1196Juf Mm7Q== X-Gm-Message-State: AOJu0YygXnAt7DreaZ+MT0JYDWKyJoCeZQ5J3GgZrpp24c9vR8Yycd1e 1eg5f5SQdfpN6KwuTgMeoowmbw== X-Google-Smtp-Source: AGHT+IFiDsJyWYZmV3dZR43yD6C7sj8hAw5H2KlFm+QwzJszuvuTxrXcIrJdx2qTTyted2pjAXexOQ== X-Received: by 2002:a05:600c:1381:b0:405:3455:e1a3 with SMTP id u1-20020a05600c138100b004053455e1a3mr9383229wmf.17.1701158684750; Tue, 28 Nov 2023 00:04:44 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.125]) by smtp.gmail.com with ESMTPSA id g18-20020a05600c4ed200b0040b4ccdcffbsm1127534wmq.2.2023.11.28.00.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 00:04:44 -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, yoshihiro.shimoda.uh@renesas.com, renesas@sang-engineering.com, robh@kernel.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com, mitsuhiro.kimura.kc@renesas.com, masaru.nagai.vx@renesas.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] net: ravb: Use pm_runtime_resume_and_get() Date: Tue, 28 Nov 2023 10:04:35 +0200 Message-Id: <20231128080439.852467-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231128080439.852467-1-claudiu.beznea.uj@bp.renesas.com> References: <20231128080439.852467-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea pm_runtime_get_sync() may return an error. In case it returns with an error dev->power.usage_count needs to be decremented. pm_runtime_resume_and_get() takes care of this. Thus use it. Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper") Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v2: - s/out_runtime_disable/out_rpm_disable - collected Rb tag Changes since [1]: - added goto label for pm_runtime_disable(); with this innecessary changes were removed [1] https://lore.kernel.org/all/20231120084606.4083194-1-claudiu.beznea.uj@bp.renesas.com/ drivers/net/ethernet/renesas/ravb_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 50c4c79be035..0af2ace286be 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2650,7 +2650,9 @@ static int ravb_probe(struct platform_device *pdev) goto out_free_netdev; pm_runtime_enable(&pdev->dev); - pm_runtime_get_sync(&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) @@ -2876,6 +2878,7 @@ static int ravb_probe(struct platform_device *pdev) clk_disable_unprepare(priv->refclk); out_release: pm_runtime_put(&pdev->dev); +out_rpm_disable: pm_runtime_disable(&pdev->dev); reset_control_assert(rstc); out_free_netdev: From patchwork Tue Nov 28 08:04:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13470597 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="QnXBzJ+g" Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4AF8100 for ; Tue, 28 Nov 2023 00:04:47 -0800 (PST) Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2c72e275d96so68839911fa.2 for ; Tue, 28 Nov 2023 00:04:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1701158686; x=1701763486; 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=IoaNebWj6WdqROHUgOaXFN9XZbA5N7Tmp23rLr1Pw/A=; b=QnXBzJ+g115eGwqrZGkYam4RQe2aCxxcfRRj2P+wZuoHuDS+QUdWc3XIIS6xY6ygkX 9oLkZHXsXjJV+8eUvT/l1bQ3faYTQ0fdIBu7T94qOMwB0Nzp2T5utMqZCR6t5IyI9IHG g967U2liIckFIWnLJa7IFW7Z5vdDRLmSnex2U+y9fWrqKilyFH/2AYuVKZ8y6nXEu2YV iMlL5VRDuIB3pB65bSVEhfat1nNB7J+CNd0ZQuGtjvvjDSIdmJnCkGUQGIrAK7S6cieo XBUaMvD8HmKWHTWT2arr1E3aBf+lrQOqNFuDBwH5jrsemVtb/rn/EVI+I0Nwc5QiYnib R54w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701158686; x=1701763486; 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=IoaNebWj6WdqROHUgOaXFN9XZbA5N7Tmp23rLr1Pw/A=; b=N303HwjCnCKUWxvufucHsZhGA6Wfinleyvwbv9IodN+F6p/CF4npKo3bIxrxpwFNgd 2SharzciGoXqfj3IW1hfApeorrDVVKdvwdmQojr/Z2axf8cvFmIVEIMR/p/Ywam+AyMk zllvd3aW/9aELDN8abChnO4/U44BW4ngilutfK4u8VLhgHlePa9TqgbKbx/lLwTvrN+O T8hThLB0u7yS9LLccxaz/FQZMjSYeyKLRaMv7x72OpFefaUe8uTBSXGzV3HWbvTZMtUk anwutGdFFu8ekuBl0XPomhXnYHjg8ASDgtCLqsAcnaJ3aQFgu+bNbNWPTvGaPOoSLmak +E3Q== X-Gm-Message-State: AOJu0YxXw9xYeGrsDLKHVXFOCG+F5inIz+Emge4cmwriU5v60o716XE5 F55pgbjkAKyrfTQfHXpQwyriUA== X-Google-Smtp-Source: AGHT+IErqR2Cn2h+EP/BDSG5BWoEdhxj1fOVQMKlNR2IEscd0xHw7EMwldO6e4QfLqwg+Dyq/nh+Gw== X-Received: by 2002:a19:8c5c:0:b0:50a:b9dd:43f with SMTP id i28-20020a198c5c000000b0050ab9dd043fmr8382999lfj.21.1701158686229; Tue, 28 Nov 2023 00:04:46 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.125]) by smtp.gmail.com with ESMTPSA id g18-20020a05600c4ed200b0040b4ccdcffbsm1127534wmq.2.2023.11.28.00.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 00:04:45 -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, yoshihiro.shimoda.uh@renesas.com, renesas@sang-engineering.com, robh@kernel.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com, mitsuhiro.kimura.kc@renesas.com, masaru.nagai.vx@renesas.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/6] net: ravb: Make write access to CXR35 first before accessing other EMAC registers Date: Tue, 28 Nov 2023 10:04:36 +0200 Message-Id: <20231128080439.852467-4-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231128080439.852467-1-claudiu.beznea.uj@bp.renesas.com> References: <20231128080439.852467-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea Hardware manual of RZ/G3S (and RZ/G2L) specifies the following on the description of CXR35 register (chapter "PHY interface select register (CXR35)"): "After release reset, make write-access to this register before making write-access to other registers (except MDIOMOD). Even if not need to change the value of this register, make write-access to this register at least one time. Because RGMII/MII MODE is recognized by accessing this register". The setup procedure for EMAC module (chapter "Setup procedure" of RZ/G3S, RZ/G2L manuals) specifies the E-MAC.CXR35 register is the first EMAC register that is to be configured. Note [A] from chapter "PHY interface select register (CXR35)" specifies the following: [A] The case which CXR35 SEL_XMII is used for the selection of RGMII/MII in APB Clock 100 MHz. (1) To use RGMII interface, Set ‘H’03E8_0000’ to this register. (2) To use MII interface, Set ‘H’03E8_0002’ to this register. Take into account these indication. Fixes: 1089877ada8d ("ravb: Add RZ/G2L MII interface support") Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v2: - none Changes since [1]: - collected Rb tag [1] https://lore.kernel.org/all/20231120084606.4083194-1-claudiu.beznea.uj@bp.renesas.com/ drivers/net/ethernet/renesas/ravb_main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 0af2ace286be..62a986b5de41 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -515,6 +515,15 @@ static void ravb_emac_init_gbeth(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); + if (priv->phy_interface == PHY_INTERFACE_MODE_MII) { + ravb_write(ndev, (1000 << 16) | CXR35_SEL_XMII_MII, CXR35); + ravb_modify(ndev, CXR31, CXR31_SEL_LINK0 | CXR31_SEL_LINK1, 0); + } else { + ravb_write(ndev, (1000 << 16) | CXR35_SEL_XMII_RGMII, CXR35); + ravb_modify(ndev, CXR31, CXR31_SEL_LINK0 | CXR31_SEL_LINK1, + CXR31_SEL_LINK0); + } + /* Receive frame limit set register */ ravb_write(ndev, GBETH_RX_BUFF_MAX + ETH_FCS_LEN, RFLR); @@ -537,14 +546,6 @@ static void ravb_emac_init_gbeth(struct net_device *ndev) /* E-MAC interrupt enable register */ ravb_write(ndev, ECSIPR_ICDIP, ECSIPR); - - if (priv->phy_interface == PHY_INTERFACE_MODE_MII) { - ravb_modify(ndev, CXR31, CXR31_SEL_LINK0 | CXR31_SEL_LINK1, 0); - ravb_write(ndev, (1000 << 16) | CXR35_SEL_XMII_MII, CXR35); - } else { - ravb_modify(ndev, CXR31, CXR31_SEL_LINK0 | CXR31_SEL_LINK1, - CXR31_SEL_LINK0); - } } static void ravb_emac_init_rcar(struct net_device *ndev) From patchwork Tue Nov 28 08:04:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13470598 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="btPiitC9" Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F61F194 for ; Tue, 28 Nov 2023 00:04:49 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40b4c2ef584so3642625e9.3 for ; Tue, 28 Nov 2023 00:04:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1701158688; x=1701763488; 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=fTVx8N2lyLVeP/GZzmvvrZO4776iEUf9UriNFWs6nw4=; b=btPiitC99qPsBgEM94E46UgZB7+GJfKZdtn6J7Gckw3he8kTGnxcUnc6GwqkSf8Dd+ Rw7WQ9nf7agG9IlppmHfSombhRYKlZw4FWXo+xXPvwKriiJ9xY+qLC6iHF+sG0NuQF01 Mhyz/R6OvjIsBK1qO0xe3rdQ5I6XK75Ifrp7G2nFrPZKHKuecDtuiod9KMAX0KrWN29/ 3z9JD3TcdzyEoMcrY79WmYjGjqiaBSoJi80veH8iHGcTQcX+6UCWzvkpwLjBapaj0YRb zOw18C8BKGHWlrDVTyy+h9V/oKQ5yCKINE6o3i0q3q1YBIPO7GW6uuX7oAg9Ck6WoFuO O3kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701158688; x=1701763488; 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=fTVx8N2lyLVeP/GZzmvvrZO4776iEUf9UriNFWs6nw4=; b=JA76aCOZsgYNVOAmCUx4xJG6iZ3fDd8L0sT6XhVs65kIrouQ27gIxNz1o1qB13lOgA WltQ9txMcyAB9MpbBsyDamNoxB4yLM/2FYoyL96OdPQpo8mL9GuaK84FxlOeNCG5GmEx w6/NTyQwbDHqsQr7GwWtP6Dqh/Mirj7kmvd+5F1RQf6K3cq9c/hQDv8pftrvDOXG25CM DO2Pq7rc/Sz6UTfBlerv7Jos1o9q7HHE+e7sdVWac3jrpAcfKApzoS26s/yKkN0Fk21d vg/rcm/TO5bba0gwNQBSgzFZb3XgTWeVqVbyYE9tJgONSOr20PP8VWX3XYgTbvUfmyCK 0jvg== X-Gm-Message-State: AOJu0YxaXjviULzQsKpWt2lORNkDE8Xqf9EKJRH4GXUN5W0+hWcZV9s1 uT1711SLr+4NM6aCqcN1mEo1GA== X-Google-Smtp-Source: AGHT+IFyVl5DgTjPU+gokz2yqs2Qa0rEamBDcYdphY/WmgNzjG2BIF2ih2kCDELTlkbG0p0uVZjPbg== X-Received: by 2002:a05:600c:4e94:b0:40b:4c36:f80 with SMTP id f20-20020a05600c4e9400b0040b4c360f80mr810627wmq.32.1701158687784; Tue, 28 Nov 2023 00:04:47 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.125]) by smtp.gmail.com with ESMTPSA id g18-20020a05600c4ed200b0040b4ccdcffbsm1127534wmq.2.2023.11.28.00.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 00:04: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, yoshihiro.shimoda.uh@renesas.com, renesas@sang-engineering.com, robh@kernel.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com, mitsuhiro.kimura.kc@renesas.com, masaru.nagai.vx@renesas.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] net: ravb: Start TX queues after HW initialization succeeded Date: Tue, 28 Nov 2023 10:04:37 +0200 Message-Id: <20231128080439.852467-5-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231128080439.852467-1-claudiu.beznea.uj@bp.renesas.com> References: <20231128080439.852467-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea ravb_phy_start() may fail. If that happens, the TX queues will remain started. Thus, move the netif_tx_start_all_queues() after PHY is successfully initialized. Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper") Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea Reviewed-by: Kalesh AP --- Changes in v2: - none Changes since [1]: - collected Rb tag [1] https://lore.kernel.org/all/20231120084606.4083194-1-claudiu.beznea.uj@bp.renesas.com/ drivers/net/ethernet/renesas/ravb_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 62a986b5de41..2ef46c71f2bb 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1812,13 +1812,13 @@ static int ravb_open(struct net_device *ndev) if (info->gptp) ravb_ptp_init(ndev, priv->pdev); - netif_tx_start_all_queues(ndev); - /* PHY control start */ error = ravb_phy_start(ndev); if (error) goto out_ptp_stop; + netif_tx_start_all_queues(ndev); + return 0; out_ptp_stop: From patchwork Tue Nov 28 08:04:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13470599 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="NTru99EY" Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BED65B0 for ; Tue, 28 Nov 2023 00:04:50 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40b2ad4953cso34317935e9.0 for ; Tue, 28 Nov 2023 00:04:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1701158689; x=1701763489; 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=7UUIFtQDzSDtAn0+xL/a4rToHREO/z6KIZ1fp0e9QBw=; b=NTru99EYPWeI2IZS/ZDXNx/2q9s804lRjP4j4Kgs3Bj9vAiCsUpHBQhvORI30Xg+F/ nlpuAp8hrQb3tncaeBk8Xf6FIBlipXk0hoFAywPHFlEVZvh600BeBxoO0/Pp2XWIvAHK r2hw0yBpBcf3dubMAOqG1p2h2wcR8RV5fnSvcBP/vGp2Hfuq55Yq8+I1D+a5rusT9qCJ XdF/ti3gINrjlH+OJoEw7sNR7NgFL2d5oPIMm2jxZMaR/zB98G0u2w3Vm2IAtZrzB//S IdvtiSnp1J9qJV2B6NOf0IhajygZT/dq4GdIV4k6+B1gJ/BxNg+k8JWQNPV1QTK2WzeT AHtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701158689; x=1701763489; 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=7UUIFtQDzSDtAn0+xL/a4rToHREO/z6KIZ1fp0e9QBw=; b=aKm0Ek8UVMLlaQQsAcwqxB32WycN6MXYPkWj5RxxXn4xBVa+9/Iv2HGBM8BcjStTgl Wg5KkE++FuNAf4qEfji89uO5uIWrgrPsFYINiqFvJUgmza4dqnkLQTu2PX0FTgdHKGev LNdQBOEjYM8MXgdFGqD5cKT5uYLjnwSYp3ejSczXvh4Xv8M/8j3T9PqQ0XXs4SR/Or7M CuaBnJkZWFuMJDunmpXuKDKVyMLw/lGOZkf7g6TeThAfpriQkUNpqMFpSqZEQxgnKVAk jhE/3jOqteuVCoDUcip/4B8xh1Mic+AjxsLaNPgGT/R6XU13QvQ0vkm+cQcIe90JJoDa IXJA== X-Gm-Message-State: AOJu0YzinKbSyYeoG0Jx1HqmzFmSef4bR1DBNoJuq5udi0zyfC2Gm10+ Rm+XsTW6t1x2XmlvnIF+zQeqqg== X-Google-Smtp-Source: AGHT+IEObelGQNl9tI+LG1sQsyG2i2yFcxb2Q6riQzEbIjU+MG5AYRIubmmNG6CsXxUcxblwvRfk8w== X-Received: by 2002:a05:600c:35c7:b0:40b:3322:2af6 with SMTP id r7-20020a05600c35c700b0040b33222af6mr12528814wmq.5.1701158689281; Tue, 28 Nov 2023 00:04:49 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.125]) by smtp.gmail.com with ESMTPSA id g18-20020a05600c4ed200b0040b4ccdcffbsm1127534wmq.2.2023.11.28.00.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 00:04: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, yoshihiro.shimoda.uh@renesas.com, renesas@sang-engineering.com, robh@kernel.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com, mitsuhiro.kimura.kc@renesas.com, masaru.nagai.vx@renesas.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/6] net: ravb: Stop DMA in case of failures on ravb_open() Date: Tue, 28 Nov 2023 10:04:38 +0200 Message-Id: <20231128080439.852467-6-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231128080439.852467-1-claudiu.beznea.uj@bp.renesas.com> References: <20231128080439.852467-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea In case ravb_phy_start() returns with error the settings applied in ravb_dmac_init() are not reverted (e.g. config mode). For this call ravb_stop_dma() on failure path of ravb_open(). Fixes: a0d2f20650e8 ("Renesas Ethernet AVB PTP clock driver") Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v2: - none Changes since [1]: - s/ravb_dma_init/ravb_dmac_init in commit description - collected Rb tag [1] https://lore.kernel.org/all/20231120084606.4083194-1-claudiu.beznea.uj@bp.renesas.com/ drivers/net/ethernet/renesas/ravb_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 2ef46c71f2bb..2396fab3f608 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1825,6 +1825,7 @@ static int ravb_open(struct net_device *ndev) /* Stop PTP Clock driver */ if (info->gptp) ravb_ptp_stop(ndev); + ravb_stop_dma(ndev); out_free_irq_mgmta: if (!info->multi_irqs) goto out_free_irq; From patchwork Tue Nov 28 08:04:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13470600 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="PrE3MAkP" Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9E46D4C for ; Tue, 28 Nov 2023 00:04:52 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40b4f6006d5so456655e9.1 for ; Tue, 28 Nov 2023 00:04:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1701158691; x=1701763491; 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=llunhkM8sKXrafDQaQtl/MAyFYLs2dUG+zsrZHGyqOA=; b=PrE3MAkPkGQcth7uVaMUssbZEHhpQknLEbWRZVyPUW/LT+seWNHo8Ox1JohwEXY1qP R4EF+8QaGmNSOEzhfiP7ywLFi8++Mr/S1eL6p2Y4BinebiRPwRdvDKfUg5ABPUdrTJuf 85ZVmWxqVQ4zRVwVPrFJw8wuQ/LJuGDVNsBkryLqb3PkOPgu7e6NjBXhIu0hi/c4ul4m APwfDK/yLoS0wElgR1SgQLjB/Jwct5XYTH5Gb//1nXeKYp3NZJR3ElYaBnQxbVvQY3Bl ABfJSq5FUTxP7SGiQYl58FAu3Y7Hyeyrmt7wgPIBLHwhUibLsXHmAKBABUZY8pn2r5/l 5Mjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701158691; x=1701763491; 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=llunhkM8sKXrafDQaQtl/MAyFYLs2dUG+zsrZHGyqOA=; b=HZBJNgVY6uRmzAqFHYqlF6Yv0B3dGK9Qg+pKmfRlkSSwsZkwrKMnhPgiqRHypwTk/G kGya+soJTqGE7Ra6tLpqmWwJLWd+m02R912WCN5H7jYHUo9KWLkU14TqX+9O7+J6zf4R KkmAbNG43W2Rg0fWBe0U3i/y5HQxBEg9Ct9bbP2WZcEfFxb4vSYaSX82qvieXasV+KDU vmOxoksM6+N8NqId+NhyiKqMVRMHLlQvQ85O9Oo1UIe+S2Ph1q9QfBJBHQwzN9ERbu7Y EspsasYiHLcGBx6QNklfD7ZvUM1a/E6v2nCgdZYxsbjXBRe30zZDxjPHRyPq1GQ8gzHu +1Tw== X-Gm-Message-State: AOJu0YxQ0komWvBR9JZVeRGlTfYySOucuGEo5a7+goAlVyZjS3Kf2A7v +Rs+xliGESNq+FCGamcuIHI1rw== X-Google-Smtp-Source: AGHT+IGnCMgf0SdfdRgyacJnLuJ5KyPuGcHpPOquhV3N6OvasOIFBd4jOd1MCEmiwzmtXLhZkt/QWg== X-Received: by 2002:a05:600c:1f82:b0:408:364e:34a2 with SMTP id je2-20020a05600c1f8200b00408364e34a2mr6194992wmb.10.1701158691121; Tue, 28 Nov 2023 00:04:51 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.125]) by smtp.gmail.com with ESMTPSA id g18-20020a05600c4ed200b0040b4ccdcffbsm1127534wmq.2.2023.11.28.00.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 00:04:50 -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, yoshihiro.shimoda.uh@renesas.com, renesas@sang-engineering.com, robh@kernel.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com, mitsuhiro.kimura.kc@renesas.com, masaru.nagai.vx@renesas.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/6] net: ravb: Keep reverse order of operations in ravb_remove() Date: Tue, 28 Nov 2023 10:04:39 +0200 Message-Id: <20231128080439.852467-7-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231128080439.852467-1-claudiu.beznea.uj@bp.renesas.com> References: <20231128080439.852467-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea On RZ/G3S SMARC Carrier II board having RGMII connections b/w Ethernet MACs and PHYs it has been discovered that doing unbind/bind for ravb driver in a loop leads to wrong speed and duplex for Ethernet links and broken connectivity (the connectivity cannot be restored even with bringing interface down/up). Before doing unbind/bind the Ethernet interfaces were configured though systemd. The sh instructions used to do unbind/bind were: $ cd /sys/bus/platform/drivers/ravb/ $ while :; do echo 11c30000.ethernet > unbind ; \ echo 11c30000.ethernet > bind; done It has been discovered that there is a race b/w IOCTLs initialized by systemd at the response of success binding and the "ravb_write(ndev, CCC_OPC_RESET, CCC)" call in ravb_remove() as follows: 1/ as a result of bind success the user space open/configures the interfaces tough an IOCTL; the following stack trace has been identified on RZ/G3S: Call trace: dump_backtrace+0x9c/0x100 show_stack+0x20/0x38 dump_stack_lvl+0x48/0x60 dump_stack+0x18/0x28 ravb_open+0x70/0xa58 __dev_open+0xf4/0x1e8 __dev_change_flags+0x198/0x218 dev_change_flags+0x2c/0x80 devinet_ioctl+0x640/0x708 inet_ioctl+0x1e4/0x200 sock_do_ioctl+0x50/0x108 sock_ioctl+0x240/0x358 __arm64_sys_ioctl+0xb0/0x100 invoke_syscall+0x50/0x128 el0_svc_common.constprop.0+0xc8/0xf0 do_el0_svc+0x24/0x38 el0_svc+0x34/0xb8 el0t_64_sync_handler+0xc0/0xc8 el0t_64_sync+0x190/0x198 2/ this call may execute concurrently with ravb_remove() as the unbind/bind operation was executed in a loop 3/ if the operation mode is changed to RESET (through ravb_write(ndev, CCC_OPC_RESET, CCC) call in ravb_remove()) while the above ravb_open() is in progress it may lead to MAC (or PHY, or MAC-PHY connection, the right point hasn't been identified at the moment) to be broken, thus the Ethernet connectivity fails to restore. The simple fix for this is to move ravb_write(ndev, CCC_OPC_RESET, CCC)) after unregister_netdev() to avoid resetting the controller while the netdev interface is still registered. To avoid future issues in ravb_remove(), the patch follows the proper order of operations in ravb_remove(): reverse order compared with ravb_probe(). This avoids described races as the IOCTLs as well as unregister_netdev() (called now at the beginning of ravb_remove()) calls rtnl_lock() before continuing and IOCTLs check (though devinet_ioctl()) if device is still registered just after taking the lock: int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr) { // ... rtnl_lock(); ret = -ENODEV; dev = __dev_get_by_name(net, ifr->ifr_name); if (!dev) goto done; // ... done: rtnl_unlock(); out: return ret; } Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper") Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v2: - fixed typos in commit description - collected Rb tag Changes since [1]: - s/ravb_dma_init/ravb_dmac_init in commit description - collected Rb tag [1] https://lore.kernel.org/all/20231120084606.4083194-1-claudiu.beznea.uj@bp.renesas.com/ drivers/net/ethernet/renesas/ravb_main.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 2396fab3f608..9178f6d60e74 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2894,22 +2894,26 @@ static void ravb_remove(struct platform_device *pdev) struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; - /* Stop PTP Clock driver */ - if (info->ccc_gac) - ravb_ptp_stop(ndev); - - clk_disable_unprepare(priv->gptp_clk); - clk_disable_unprepare(priv->refclk); - - /* Set reset mode */ - ravb_write(ndev, CCC_OPC_RESET, CCC); unregister_netdev(ndev); if (info->nc_queues) netif_napi_del(&priv->napi[RAVB_NC]); netif_napi_del(&priv->napi[RAVB_BE]); + 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); + + /* Set reset mode */ + ravb_write(ndev, CCC_OPC_RESET, CCC); + + clk_disable_unprepare(priv->gptp_clk); + clk_disable_unprepare(priv->refclk); + pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); reset_control_assert(priv->rstc);