From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,URI_HEX, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B410DC83004 for ; Wed, 29 Apr 2020 17:21:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 94AEC208FE for ; Wed, 29 Apr 2020 17:21:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726621AbgD2RVC (ORCPT ); Wed, 29 Apr 2020 13:21:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726511AbgD2RVB (ORCPT ); Wed, 29 Apr 2020 13:21:01 -0400 X-Greylist: delayed 301 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 29 Apr 2020 10:21:01 PDT Received: from baptiste.telenet-ops.be (baptiste.telenet-ops.be [IPv6:2a02:1800:120:4::f00:13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 498CFC035493 for ; Wed, 29 Apr 2020 10:21:01 -0700 (PDT) Received: from ramsan ([IPv6:2a02:1810:ac12:ed60:182a:142e:a95f:66c2]) by baptiste.telenet-ops.be with bizsmtp id YhFx2200E0w8ZL601hFxGf; Wed, 29 Apr 2020 19:15:57 +0200 Received: from geert (helo=localhost) by ramsan with local-esmtp (Exim 4.90_1) (envelope-from ) id 1jTqJR-0005gr-93; Wed, 29 Apr 2020 19:15:57 +0200 Date: Wed, 29 Apr 2020 19:15:57 +0200 (CEST) From: Geert Uytterhoeven To: =?ISO-8859-15?Q?Niklas_S=F6derlund?= cc: Wolfram Sang , Masahiro Yamada , Ulf Hansson , linux-mmc@vger.kernel.org, linux-pm@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: Re: [PATCH 1/2] mmc: tmio: undo PM autosuspend when removing the host In-Reply-To: <20190109223452.11184-2-niklas.soderlund+renesas@ragnatech.se> Message-ID: References: <20190109223452.11184-1-niklas.soderlund+renesas@ragnatech.se> <20190109223452.11184-2-niklas.soderlund+renesas@ragnatech.se> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1654730921-1588180557=:4052" Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1654730921-1588180557=:4052 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT Hi Niklas, On Wed, 9 Jan 2019, Niklas Söderlund wrote: > When removing the driver make sure to undo the PM autosuspend configured > when probing the host. > > Signed-off-by: Niklas Söderlund > Reviewed-by: Wolfram Sang This is commit bb60023c6387842b ("mmc: tmio: undo PM autosuspend when removing the host"), and I've bisected a regression to it. Sorry for taking that long to discover this issue (by loading a DT overlay to enable SCIFA5 on Koelsch, which requires unbinding SHDI0 first). > --- a/drivers/mmc/host/tmio_mmc_core.c > +++ b/drivers/mmc/host/tmio_mmc_core.c > @@ -1287,6 +1287,7 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host) > cancel_delayed_work_sync(&host->delayed_reset_work); > tmio_mmc_release_dma(host); > > + pm_runtime_dont_use_autosuspend(&pdev->dev); > pm_runtime_put_sync(&pdev->dev); > pm_runtime_disable(&pdev->dev); > } When unbinding the sdhi driver on e.g. Koelsch or Salvator-XS: echo ee100000.sd > /sys/bus/platform/drivers/sh_mobile_sdhi/unbind echo ee100000.sd > /sys/bus/platform/drivers/renesas_sdhi_internal_dmac/unbind Two warnings are triggered: WARNING: CPU: 0 PID: 586 at drivers/clk/clk.c:954 clk_core_disable+0x40/0x214 sdhi0 already disabled CPU: 0 PID: 586 Comm: bash Not tainted 5.7.0-rc3-shmobile-00508-g3c2c87c467f1c34e-dirty #547 Hardware name: Generic R-Car Gen2 (Flattened Device Tree) [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0x88/0xa8) [] (dump_stack) from [] (__warn+0xd0/0xec) [] (__warn) from [] (warn_slowpath_fmt+0x70/0x9c) [] (warn_slowpath_fmt) from [] (clk_core_disable+0x40/0x214) [] (clk_core_disable) from [] (clk_core_disable_lock+0x18/0x24) [] (clk_core_disable_lock) from [] (renesas_sdhi_clk_disable+0x14/0x34) [] (renesas_sdhi_clk_disable) from [] (renesas_sdhi_remove+0x18/0x20) [] (renesas_sdhi_remove) from [] (platform_drv_remove+0x24/0x3c) [] (platform_drv_remove) from [] (device_release_driver_internal+0xf0/0x198) [] (device_release_driver_internal) from [] (unbind_store+0x44/0x68) [] (unbind_store) from [] (kernfs_fop_write+0x128/0x1e4) [] (kernfs_fop_write) from [] (__vfs_write+0x28/0xe0) [] (__vfs_write) from [] (vfs_write+0x98/0xbc) [] (vfs_write) from [] (ksys_write+0x68/0xb4) [] (ksys_write) from [] (ret_fast_syscall+0x0/0x54) ... WARNING: CPU: 0 PID: 586 at drivers/clk/clk.c:813 clk_core_unprepare+0x40/0x108 sdhi0 already unprepared CPU: 0 PID: 586 Comm: bash Tainted: G W 5.7.0-rc3-shmobile-00508-g3c2c87c467f1c34e-dirty #547 Hardware name: Generic R-Car Gen2 (Flattened Device Tree) [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0x88/0xa8) [] (dump_stack) from [] (__warn+0xd0/0xec) [] (__warn) from [] (warn_slowpath_fmt+0x70/0x9c) [] (warn_slowpath_fmt) from [] (clk_core_unprepare+0x40/0x108) [] (clk_core_unprepare) from [] (clk_unprepare+0x24/0x2c) [] (clk_unprepare) from [] (__pm_clk_remove+0x38/0x54) [] (__pm_clk_remove) from [] (pm_clk_destroy+0xc4/0xdc) [] (pm_clk_destroy) from [] (genpd_remove_device+0x10c/0x128) [] (genpd_remove_device) from [] (genpd_dev_pm_detach+0x44/0xe4) [] (genpd_dev_pm_detach) from [] (platform_drv_remove+0x34/0x3c) [] (platform_drv_remove) from [] (device_release_driver_internal+0xf0/0x198) [] (device_release_driver_internal) from [] (unbind_store+0x44/0x68) [] (unbind_store) from [] (kernfs_fop_write+0x128/0x1e4) [] (kernfs_fop_write) from [] (__vfs_write+0x28/0xe0) [] (__vfs_write) from [] (vfs_write+0x98/0xbc) [] (vfs_write) from [] (ksys_write+0x68/0xb4) [] (ksys_write) from [] (ret_fast_syscall+0x0/0x54) Removing the call to pm_runtime_dont_use_autosuspend() fixes that symptom. But that is definitely not the right fix, as doing so causes genpd_stop_dev() to no longer being called on unbind. What seems to happen is: - During driver probe, the clocks are enabled twice, by 1. renesas_sdhi_clk_enable(), called from renesas_sdhi_probe(), 2. pm_clk_resume(), called from tmio_mmc_host_probe(). - During driver unbind, the clocks are disabled thrice, by: 1. renesas_sdhi_clk_disable(), called from tmio_mmc_host_runtime_suspend(), 2. pm_clk_suspend(), called from tmio_mmc_host_remove() through pm_runtime_put_sync(), 3. renesas_sdhi_clk_disable(), called from renesas_sdhi_remove(). In addition, an extra clock unprepare happens in __pm_clk_remove(), called from genpd_remove_device() through pm_clk_destroy(). Note that tmio_mmc_host_runtime_suspend() is never called, so there is definitely an imbalance in the Runtime PM handling.. Without the call to pm_runtime_dont_use_autosuspend(), the clocks are disabled twice during driver unbind, by: 1. renesas_sdhi_clk_disable(), called from renesas_sdhi_remove(), 2. __pm_clk_remove(), called from genpd_remove_device() through pm_clk_destroy(). Hence the warning is gone, by accident, as e.g. the pm_clk_resume() call is never balanced by its counterpart pm_clk_suspend(). Thanks for your comments! Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds --8323329-1654730921-1588180557=:4052--