diff mbox series

mmc: vub300: fix warning - do not call blocking ops when !TASK_RUNNING

Message ID 87dc45b122d26d63c80532976813c9365d7160b3.1670140888.git.deren.wu@mediatek.com
State New
Headers show
Series mmc: vub300: fix warning - do not call blocking ops when !TASK_RUNNING | expand

Commit Message

Deren Wu Dec. 4, 2022, 8:24 a.m. UTC
vub300_enable_sdio_irq() works with mutex and need TASK_RUNNING here.
Ensure that we mark current as TASK_RUNNING for sleepable context.

[   77.554641] do not call blocking ops when !TASK_RUNNING; state=1 set at [<ffffffff92a72c1d>] sdio_irq_thread+0x17d/0x5b0
[   77.554652] WARNING: CPU: 2 PID: 1983 at kernel/sched/core.c:9813 __might_sleep+0x116/0x160
[   77.554905] CPU: 2 PID: 1983 Comm: ksdioirqd/mmc1 Tainted: G           OE      6.1.0-rc5 #1
[   77.554910] Hardware name: Intel(R) Client Systems NUC8i7BEH/NUC8BEB, BIOS BECFL357.86A.0081.2020.0504.1834 05/04/2020
[   77.554912] RIP: 0010:__might_sleep+0x116/0x160
[   77.554920] RSP: 0018:ffff888107b7fdb8 EFLAGS: 00010282
[   77.554923] RAX: 0000000000000000 RBX: ffff888118c1b740 RCX: 0000000000000000
[   77.554926] RDX: 0000000000000001 RSI: 0000000000000004 RDI: ffffed1020f6ffa9
[   77.554928] RBP: ffff888107b7fde0 R08: 0000000000000001 R09: ffffed1043ea60ba
[   77.554930] R10: ffff88821f5305cb R11: ffffed1043ea60b9 R12: ffffffff93aa3a60
[   77.554932] R13: 000000000000011b R14: 7fffffffffffffff R15: ffffffffc0558660
[   77.554934] FS:  0000000000000000(0000) GS:ffff88821f500000(0000) knlGS:0000000000000000
[   77.554937] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   77.554939] CR2: 00007f8a44010d68 CR3: 000000024421a003 CR4: 00000000003706e0
[   77.554942] Call Trace:
[   77.554944]  <TASK>
[   77.554952]  mutex_lock+0x78/0xf0
[   77.554973]  vub300_enable_sdio_irq+0x103/0x3c0 [vub300]
[   77.554981]  sdio_irq_thread+0x25c/0x5b0
[   77.555006]  kthread+0x2b8/0x370
[   77.555017]  ret_from_fork+0x1f/0x30
[   77.555023]  </TASK>
[   77.555025] ---[ end trace 0000000000000000 ]---

Fixes: 88095e7b473a ("mmc: Add new VUB300 USB-to-SD/SDIO/MMC driver")
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
---
 drivers/mmc/host/vub300.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Ulf Hansson Dec. 7, 2022, 12:37 p.m. UTC | #1
On Sun, 4 Dec 2022 at 09:27, Deren Wu <deren.wu@mediatek.com> wrote:
>
> vub300_enable_sdio_irq() works with mutex and need TASK_RUNNING here.
> Ensure that we mark current as TASK_RUNNING for sleepable context.
>
> [   77.554641] do not call blocking ops when !TASK_RUNNING; state=1 set at [<ffffffff92a72c1d>] sdio_irq_thread+0x17d/0x5b0
> [   77.554652] WARNING: CPU: 2 PID: 1983 at kernel/sched/core.c:9813 __might_sleep+0x116/0x160
> [   77.554905] CPU: 2 PID: 1983 Comm: ksdioirqd/mmc1 Tainted: G           OE      6.1.0-rc5 #1
> [   77.554910] Hardware name: Intel(R) Client Systems NUC8i7BEH/NUC8BEB, BIOS BECFL357.86A.0081.2020.0504.1834 05/04/2020
> [   77.554912] RIP: 0010:__might_sleep+0x116/0x160
> [   77.554920] RSP: 0018:ffff888107b7fdb8 EFLAGS: 00010282
> [   77.554923] RAX: 0000000000000000 RBX: ffff888118c1b740 RCX: 0000000000000000
> [   77.554926] RDX: 0000000000000001 RSI: 0000000000000004 RDI: ffffed1020f6ffa9
> [   77.554928] RBP: ffff888107b7fde0 R08: 0000000000000001 R09: ffffed1043ea60ba
> [   77.554930] R10: ffff88821f5305cb R11: ffffed1043ea60b9 R12: ffffffff93aa3a60
> [   77.554932] R13: 000000000000011b R14: 7fffffffffffffff R15: ffffffffc0558660
> [   77.554934] FS:  0000000000000000(0000) GS:ffff88821f500000(0000) knlGS:0000000000000000
> [   77.554937] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [   77.554939] CR2: 00007f8a44010d68 CR3: 000000024421a003 CR4: 00000000003706e0
> [   77.554942] Call Trace:
> [   77.554944]  <TASK>
> [   77.554952]  mutex_lock+0x78/0xf0
> [   77.554973]  vub300_enable_sdio_irq+0x103/0x3c0 [vub300]
> [   77.554981]  sdio_irq_thread+0x25c/0x5b0
> [   77.555006]  kthread+0x2b8/0x370
> [   77.555017]  ret_from_fork+0x1f/0x30
> [   77.555023]  </TASK>
> [   77.555025] ---[ end trace 0000000000000000 ]---
>
> Fixes: 88095e7b473a ("mmc: Add new VUB300 USB-to-SD/SDIO/MMC driver")
> Signed-off-by: Deren Wu <deren.wu@mediatek.com>

Ideally this driver should be converted to use the sdio_signal_irq()
interface and thus move away from the legacy mmc_signal_sdio_irq()
interface. However, as a fix for stable kernels, this looks good to
me!

So, applied for next and by adding a stable tag, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/vub300.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/mmc/host/vub300.c b/drivers/mmc/host/vub300.c
> index 97beece62fec..b58a1a869ed8 100644
> --- a/drivers/mmc/host/vub300.c
> +++ b/drivers/mmc/host/vub300.c
> @@ -2049,6 +2049,7 @@ static void vub300_enable_sdio_irq(struct mmc_host *mmc, int enable)
>                 return;
>         kref_get(&vub300->kref);
>         if (enable) {
> +               set_current_state(TASK_RUNNING);
>                 mutex_lock(&vub300->irq_mutex);
>                 if (vub300->irqs_queued) {
>                         vub300->irqs_queued -= 1;
> @@ -2064,6 +2065,7 @@ static void vub300_enable_sdio_irq(struct mmc_host *mmc, int enable)
>                         vub300_queue_poll_work(vub300, 0);
>                 }
>                 mutex_unlock(&vub300->irq_mutex);
> +               set_current_state(TASK_INTERRUPTIBLE);
>         } else {
>                 vub300->irq_enabled = 0;
>         }
> --
> 2.18.0
>
diff mbox series

Patch

diff --git a/drivers/mmc/host/vub300.c b/drivers/mmc/host/vub300.c
index 97beece62fec..b58a1a869ed8 100644
--- a/drivers/mmc/host/vub300.c
+++ b/drivers/mmc/host/vub300.c
@@ -2049,6 +2049,7 @@  static void vub300_enable_sdio_irq(struct mmc_host *mmc, int enable)
 		return;
 	kref_get(&vub300->kref);
 	if (enable) {
+		set_current_state(TASK_RUNNING);
 		mutex_lock(&vub300->irq_mutex);
 		if (vub300->irqs_queued) {
 			vub300->irqs_queued -= 1;
@@ -2064,6 +2065,7 @@  static void vub300_enable_sdio_irq(struct mmc_host *mmc, int enable)
 			vub300_queue_poll_work(vub300, 0);
 		}
 		mutex_unlock(&vub300->irq_mutex);
+		set_current_state(TASK_INTERRUPTIBLE);
 	} else {
 		vub300->irq_enabled = 0;
 	}