Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2639380rdb; Mon, 4 Dec 2023 03:30:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFb0QGFV/TisORfmAW0nvj4YXP45Zosj/ar18RyJY7RPsnolC1Hi1prLmlj4aPChJ88vwaK X-Received: by 2002:a05:6a20:3254:b0:18c:1570:49fb with SMTP id hm20-20020a056a20325400b0018c157049fbmr4171485pzc.50.1701689458488; Mon, 04 Dec 2023 03:30:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701689458; cv=none; d=google.com; s=arc-20160816; b=gak2zQZF4hWgRlitEmXrZJeliVXP18QJ129+v7iDdj6p4QOUOdbMVNTVVp04ci+3MM V+pDuxZeiItPumlOLnviaTnuXImsRPAdcmI5Y8O0e1DjGHlBQpNYEhNMt0kL1Lpi4VkG FbI7aLZgqmQFCTirBw1RTkwc4Rhj6UR7PdNvZOWjtK23l7MZRhrk0AL+8/qM0eO3OQwD sbqeUqPMrPC5w0aYZ+9VLtkM2t+RZDGoDXJ0tzkuD6H1Lbj+G5x02eezEMhedQm3YaQl 93GNUs6MoSVpmNQg8xd5txhnXaY+cQWve0WvBD84yJB+RlmXRrxssFnWOmdz9gOwWIe5 /5cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=0eAJx5nJDauq8i4G9yVY3hYWhFWejNtEyoV0lfe/e8E=; fh=4e1InOgaRDyOamKL9+M8RW+YUOyE1klphVA9tE+mgdw=; b=ldUPowkT4572YPlmy5bLVEjIFYGKRayRCdS8CZebfCtMjUbBdSe09zjb8i6zDhKwdW pahrpnheBfSuMaexXwrUkKmvcNUEbLzAcSZAwzobUc8gwceQAhUfdAK73YEmK5oTVSCX e0cZookDtWFaa6UHChn0ESV7fgTMVZHlIkPE32zRkCU13jPF46qy0xwSxkDMfVcIcYeX JzMha9yh1e145hm15FumAK28NQRN+MshzkFyTO+S3lDjLL64uycY7pSw+Uf+oWG7AmoL OqHdWyCz55gIf13jHZxS33xSyqBGx00g3guLFMtCcvRO48XXlKQHvEwv4ZaLg9CB2TLL OlIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id u16-20020a63ef10000000b005c65ac797acsi4086458pgh.360.2023.12.04.03.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 03:30:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 748D98082CC1; Mon, 4 Dec 2023 03:30:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231286AbjLDLaD (ORCPT + 99 others); Mon, 4 Dec 2023 06:30:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231334AbjLDL37 (ORCPT ); Mon, 4 Dec 2023 06:29:59 -0500 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 E7BACBB for ; Mon, 4 Dec 2023 03:30:03 -0800 (PST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed40:f143:dd2b:2cfe:eb7c]) by baptiste.telenet-ops.be with bizsmtp id JBVz2B00R5Tnyl201BVzsb; Mon, 04 Dec 2023 12:30:00 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1rA78t-00Aw16-H5; Mon, 04 Dec 2023 12:29:59 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1rA79D-002BS4-EQ; Mon, 04 Dec 2023 12:29:59 +0100 From: Geert Uytterhoeven To: Ulf Hansson , Wolfram Sang , Lad Prabhakar Cc: linux-mmc@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2] mmc: core: Cancel delayed work before releasing host Date: Mon, 4 Dec 2023 12:29:53 +0100 Message-Id: <205dc4c91b47e31b64392fe2498c7a449e717b4b.1701689330.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 04 Dec 2023 03:30:19 -0800 (PST) On RZ/Five SMARC EVK, where probing of SDHI is deferred due to probe deferral of the vqmmc-supply regulator: ------------[ cut here ]------------ WARNING: CPU: 0 PID: 0 at kernel/time/timer.c:1738 __run_timers.part.0+0x1d0/0x1e8 Modules linked in: CPU: 0 PID: 0 Comm: swapper Not tainted 6.7.0-rc4 #101 Hardware name: Renesas SMARC EVK based on r9a07g043f01 (DT) epc : __run_timers.part.0+0x1d0/0x1e8 ra : __run_timers.part.0+0x134/0x1e8 epc : ffffffff800771a4 ra : ffffffff80077108 sp : ffffffc800003e60 gp : ffffffff814f5028 tp : ffffffff8140c5c0 t0 : ffffffc800000000 t1 : 0000000000000001 t2 : ffffffff81201300 s0 : ffffffc800003f20 s1 : ffffffd8023bc4a0 a0 : 00000000fffee6b0 a1 : 0004010000400000 a2 : ffffffffc0000016 a3 : ffffffff81488640 a4 : ffffffc800003e60 a5 : 0000000000000000 a6 : 0000000004000000 a7 : ffffffc800003e68 s2 : 0000000000000122 s3 : 0000000000200000 s4 : 0000000000000000 s5 : ffffffffffffffff s6 : ffffffff81488678 s7 : ffffffff814886c0 s8 : ffffffff814f49c0 s9 : ffffffff81488640 s10: 0000000000000000 s11: ffffffc800003e60 t3 : 0000000000000240 t4 : 0000000000000a52 t5 : ffffffd8024ae018 t6 : ffffffd8024ae038 status: 0000000200000100 badaddr: 0000000000000000 cause: 0000000000000003 [] __run_timers.part.0+0x1d0/0x1e8 [] run_timer_softirq+0x24/0x4a [] __do_softirq+0xc6/0x1fa [] irq_exit_rcu+0x66/0x84 [] handle_riscv_irq+0x40/0x4e [] call_on_irq_stack+0x1c/0x28 ---[ 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 MMC host structure containing the delayed work was freed, and now contains an invalid work function pointer. Fix this by cancelling any pending delayed work before releasing the MMC host structure. Signed-off-by: Geert Uytterhoeven --- This is v2 of "[RFC] mmc: tmio: Cancel delayed work before freeing host". v2: - Move cancel_delayed_work_sync() call from tmio_mmc_host_free() to mmc_free_host(), - Correct explanation from missing pin control to vqmmc-supply probe deferral, - Update backtrace. --- drivers/mmc/core/host.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 096093f7be006353..2f51db4df1a8571b 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -692,6 +692,7 @@ EXPORT_SYMBOL(mmc_remove_host); */ void mmc_free_host(struct mmc_host *host) { + cancel_delayed_work_sync(&host->detect); mmc_pwrseq_free(host); put_device(&host->class_dev); } -- 2.34.1