From patchwork Tue Oct 31 15:48:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 741011 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 E090CC4167B for ; Tue, 31 Oct 2023 15:48:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232452AbjJaPsc (ORCPT ); Tue, 31 Oct 2023 11:48:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231131AbjJaPsb (ORCPT ); Tue, 31 Oct 2023 11:48:31 -0400 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 E1566C9 for ; Tue, 31 Oct 2023 08:48:28 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed40:8e37:9cb1:cb68:af34]) by baptiste.telenet-ops.be with bizsmtp id 4foR2B00X54etMF01foRUF; Tue, 31 Oct 2023 16:48:26 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1qxqyc-00881g-UP; Tue, 31 Oct 2023 16:48:25 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1qxqyf-00GAds-IY; Tue, 31 Oct 2023 16:48:25 +0100 From: Geert Uytterhoeven To: Wolfram Sang , Ulf Hansson , Lad Prabhakar Cc: linux-mmc@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH/RFC] mmc: tmio: Cancel delayed work before freeing host Date: Tue, 31 Oct 2023 16:48:24 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org On RZ/Five SMARC EVK, where probing of SDHI fails due to missing pin control: ------------[ cut here ]------------ WARNING: CPU: 0 PID: 0 at kernel/time/timer.c:1739 __run_timers.part.0+0x1e8/0x22a Modules linked in: CPU: 0 PID: 0 Comm: swapper Not tainted 6.6.0-10953-ga37a67d260e6-dirty #86 Hardware name: Renesas SMARC EVK based on r9a07g043f01 (DT) epc : __run_timers.part.0+0x1e8/0x22a ra : __run_timers.part.0+0x130/0x22a epc : ffffffff8007540c ra : ffffffff80075354 sp : ffffffc800003e60 gp : ffffffff814f5f08 tp : ffffffff8140d5c0 t0 : 0000000000046600 t1 : 0000000000000001 t2 : ffffffff81200c10 s0 : ffffffc800003f20 s1 : ffffffd8023bc4a0 a0 : 00000000fffee790 a1 : 0000000000000200 a2 : 0000000000000200 a3 : ffffffff81489640 a4 : ffffffc800003e60 a5 : 0000000000000000 a6 : 0000000000000000 a7 : ffffffc800003e68 s2 : 0000000000200000 s3 : 0000000000000122 s4 : 0000000000000000 s5 : ffffffffffffffff s6 : ffffffff814896c0 s7 : ffffffff814f58a0 s8 : ffffffff80f8bec8 s9 : 0000000000000000 s10: ffffffc800003e60 s11: ffffffff81489640 t3 : ffffffff81489678 t4 : 0000000000000240 t5 : ffffffd8024ac018 t6 : ffffffd8024ac038 status: 0000000200000100 badaddr: 0000000000000000 cause: 0000000000000003 [] __run_timers.part.0+0x1e8/0x22a [] run_timer_softirq+0x24/0x4a [] __do_softirq+0xc6/0x212 [] irq_exit_rcu+0x7c/0x9a [] handle_riscv_irq+0x40/0x4e [] do_irq+0x40/0x68 ---[ end trace 0000000000000000 ]--- What happens? renesas_sdhi_probe() { tmio_mmc_host_alloc() mmc_alloc_host() INIT_DELAYED_WORK(&host->detect, mmc_rescan); devm_request_irq(tmio_mmc_irq); /* * After this, the interrupt handler may be invoked at any time * * tmio_mmc_irq() * { * __tmio_mmc_card_detect_irq() * mmc_detect_change() * _mmc_detect_change() * mmc_schedule_delayed_work(&host->detect, delay); * } */ tmio_mmc_host_probe() tmio_mmc_init_ocr() -EPROBE_DEFER tmio_mmc_host_free() mmc_free_host() } When expire_timers() runs later, it warns because the scheduled work was freed, and now contains a NULL handler function pointer. Signed-off-by: Geert Uytterhoeven --- Calling __mmc_stop_host() instead works too, but __mmc_stop_host() is an internal core function, and is not exported to modules yet. Perhaps this should be handled by mmc_free_host() instead? --- drivers/mmc/host/tmio_mmc_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index be7f18fd4836ab29..1e56e78a020d94b9 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1132,6 +1132,7 @@ EXPORT_SYMBOL_GPL(tmio_mmc_host_alloc); void tmio_mmc_host_free(struct tmio_mmc_host *host) { + cancel_delayed_work_sync(&host->mmc->detect); mmc_free_host(host->mmc); } EXPORT_SYMBOL_GPL(tmio_mmc_host_free);