Message ID | 205dc4c91b47e31b64392fe2498c7a449e717b4b.1701689330.git.geert+renesas@glider.be |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2696075vqy; Mon, 4 Dec 2023 03:30:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6IYUJ5kpN89IY5SF2AaE79eqOuxgp30jDblvZ5mFB3b1c/Lag4wJjdKlV4mUnynZml4Yp X-Received: by 2002:a17:90a:6d62:b0:286:6cc1:3f0d with SMTP id z89-20020a17090a6d6200b002866cc13f0dmr2632113pjj.68.1701689457635; Mon, 04 Dec 2023 03:30:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701689457; cv=none; d=google.com; s=arc-20160816; b=EW0wC6Fz9DTJqxMIUKV7RWYyV3pp/EiVeLZ3tIbbBFBylzzdydej2nIgDT7I13ezW6 3BDy6u58BrFE7US3Umvgdx7sxth7dTTt8jWzcynCxvCXRgF6Cm6AkqihAR2SI/YNwE/E I1YjhEbAmGR16ea1qK2Gs01Ao2XNlVFFF8f0tKVgKFfY4D4p8KOa6Zmi76VrxDPM2xJf +pZSa1wh+8xt3ygZJKaxLAnpqfGV3laihVTGK7WKBIvc4e3VN6ySSZe5E3QWL1Gxmo7R hepJTKgV4UN3Ps7OgC8W9G5kmpHSFUuJmW+WK8byrXr7fIzENa4KtUn/tqAFsWzVTCOh lNDw== 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 Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id r2-20020a17090aad0200b00286c13656dcsi684071pjq.187.2023.12.04.03.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 03:30:57 -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 043518079B1C; Mon, 4 Dec 2023 03:30:11 -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 <rfc822;chrisfriedt@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <geert@linux-m68k.org>) 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 <geert@linux-m68k.org>) id 1rA79D-002BS4-EQ; Mon, 04 Dec 2023 12:29:59 +0100 From: Geert Uytterhoeven <geert+renesas@glider.be> To: Ulf Hansson <ulf.hansson@linaro.org>, Wolfram Sang <wsa+renesas@sang-engineering.com>, Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Cc: linux-mmc@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven <geert+renesas@glider.be> 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: <linux-kernel.vger.kernel.org> 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:12 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784350724513823095 X-GMAIL-MSGID: 1784350724513823095 |
Series |
[v2] mmc: core: Cancel delayed work before releasing host
|
|
Commit Message
Geert Uytterhoeven
Dec. 4, 2023, 11:29 a.m. UTC
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
[<ffffffff800771a4>] __run_timers.part.0+0x1d0/0x1e8
[<ffffffff800771e0>] run_timer_softirq+0x24/0x4a
[<ffffffff80809092>] __do_softirq+0xc6/0x1fa
[<ffffffff80028e4c>] irq_exit_rcu+0x66/0x84
[<ffffffff80800f7a>] handle_riscv_irq+0x40/0x4e
[<ffffffff80808f48>] 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 <geert+renesas@glider.be>
---
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(+)
Comments
On Mon, Dec 4, 2023 at 11:30 AM Geert Uytterhoeven <geert+renesas@glider.be> wrote: > > 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 > [<ffffffff800771a4>] __run_timers.part.0+0x1d0/0x1e8 > [<ffffffff800771e0>] run_timer_softirq+0x24/0x4a > [<ffffffff80809092>] __do_softirq+0xc6/0x1fa > [<ffffffff80028e4c>] irq_exit_rcu+0x66/0x84 > [<ffffffff80800f7a>] handle_riscv_irq+0x40/0x4e > [<ffffffff80808f48>] 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 <geert+renesas@glider.be> > --- > 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(+) > Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Cheers, Prabhakar > 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 > >
On Mon, 4 Dec 2023 at 12:30, Geert Uytterhoeven <geert+renesas@glider.be> wrote: > > 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 > [<ffffffff800771a4>] __run_timers.part.0+0x1d0/0x1e8 > [<ffffffff800771e0>] run_timer_softirq+0x24/0x4a > [<ffffffff80809092>] __do_softirq+0xc6/0x1fa > [<ffffffff80028e4c>] irq_exit_rcu+0x66/0x84 > [<ffffffff80800f7a>] handle_riscv_irq+0x40/0x4e > [<ffffffff80808f48>] 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 <geert+renesas@glider.be> Applied for next and by adding a stable tag, thanks! Kind regards Uffe > --- > 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 >
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); }