From patchwork Mon Jan 9 16:28:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13093831 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 218C2C54EBD for ; Mon, 9 Jan 2023 16:29:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233951AbjAIQ3G (ORCPT ); Mon, 9 Jan 2023 11:29:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234274AbjAIQ2n (ORCPT ); Mon, 9 Jan 2023 11:28:43 -0500 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E26F45FFA; Mon, 9 Jan 2023 08:28:41 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.96,311,1665414000"; d="scan'208";a="148740074" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 10 Jan 2023 01:28:41 +0900 Received: from localhost.localdomain (unknown [10.226.92.188]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 4E634401F40A; Tue, 10 Jan 2023 01:28:36 +0900 (JST) From: Biju Das To: "David S. Miller" , gregkh@linuxfoundation.org, Jakub Kicinski , Philipp Zabel Cc: Biju Das , Sergey Shtylyov , Sasha Levin , Geert Uytterhoeven , Yoshihiro Shimoda , Yang Li , Mitsuhiro Kimura , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, stable@vger.kernel.org, Fabrizio Castro , Leon Romanovsky , Paolo Abeni Subject: [PATCH] ravb: Fix "failed to switch device to config mode" message during unbind Date: Mon, 9 Jan 2023 16:28:33 +0000 Message-Id: <20230109162833.666722-1-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org commit c72a7e42592b2e18d862cf120876070947000d7a upstream. This patch fixes the error "ravb 11c20000.ethernet eth0: failed to switch device to config mode" during unbind. We are doing register access after pm_runtime_put_sync(). We usually do cleanup in reverse order of init. Currently in remove(), the "pm_runtime_put_sync" is not in reverse order. Probe reset_control_deassert(rstc); pm_runtime_enable(&pdev->dev); pm_runtime_get_sync(&pdev->dev); remove pm_runtime_put_sync(&pdev->dev); unregister_netdev(ndev); .. ravb_mdio_release(priv); pm_runtime_disable(&pdev->dev); Consider the call to unregister_netdev() unregister_netdev->unregister_netdevice_queue->rollback_registered_many that calls the below functions which access the registers after pm_runtime_put_sync() 1) ravb_get_stats 2) ravb_close Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper") Cc: stable@vger.kernel.org # 5.4.y Signed-off-by: Biju Das Reviewed-by: Leon Romanovsky Link: https://lore.kernel.org/r/20221214105118.2495313-1-biju.das.jz@bp.renesas.com Signed-off-by: Paolo Abeni [biju: cherry-picked from 6.0 stable] Signed-off-by: Biju Das --- Resending to 5.4 with confilcts[1] fixed [1] https://lore.kernel.org/stable/1672841810167252@kroah.com/ --- 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 95fd1f2d5439..3fd5155bdd5f 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2216,11 +2216,11 @@ static int ravb_remove(struct platform_device *pdev) priv->desc_bat_dma); /* Set reset mode */ ravb_write(ndev, CCC_OPC_RESET, CCC); - pm_runtime_put_sync(&pdev->dev); unregister_netdev(ndev); netif_napi_del(&priv->napi[RAVB_NC]); netif_napi_del(&priv->napi[RAVB_BE]); ravb_mdio_release(priv); + pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); free_netdev(ndev); platform_set_drvdata(pdev, NULL);