Linux-m68k Archive mirror
 help / color / mirror / Atom feed
From: Finn Thain <fthain@linux-m68k.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Joshua Thompson <funaho@jurai.org>,
	linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org
Subject: [PATCH] macintosh/via-macii: Fix "BUG: sleeping function called from invalid context"
Date: Wed, 13 Mar 2024 13:53:41 +1100	[thread overview]
Message-ID: <419fcc09d0e563b425c419053d02236b044d86b0.1710298421.git.fthain@linux-m68k.org> (raw)

The via-macii ADB driver calls request_irq() after disabling hard
interrupts. But disabling interrupts isn't necessary here because the
VIA shift register interrupt was masked during VIA1 initialization.

Cc: Joshua Thompson <funaho@jurai.org>
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Finn Thain <fthain@linux-m68k.org>

---

This old bug was found while testing Geert's CONFIG_PREEMPT=y patch.

BUG: sleeping function called from invalid context at include/linux/sched/mm.h:306
in_atomic(): 0, irqs_disabled(): 1, non_block: 0, pid: 1, name: swapper
preempt_count: 0, expected: 0
RCU nest depth: 0, expected: 0
CPU: 0 PID: 1 Comm: swapper Not tainted 6.8.0-rc7-mac-00232-g88f8d9d514ed #5
Stack from 0084be34:
        0084be34 0054af2c 0054af2c 00000001 00000dc0 0084be54 004980b6 0054af2c
        0084be68 0003f920 00000000 008012d0 00598ff0 0084be7c 0003f95e 00543a0d
        00000132 00000000 0084beb0 000f44ee 00543a0d 00000132 00000000 0000000a
        002ef380 002ef380 00038166 004897c0 005a95a0 00598ff0 00000000 0084bee0
        000567d8 008012d0 00000dc0 00000034 00002000 00000000 0063d1e8 00002092
        005a95a0 004c9706 00649b30 0084bf08 002ef962 0000000a 002ef380 00000000
Call Trace: [<004980b6>] dump_stack+0x10/0x16
 [<0003f920>] __might_resched+0x138/0x150
 [<0003f95e>] __might_sleep+0x26/0x72
 [<000f44ee>] kmalloc_trace+0x94/0x1ea
 [<002ef380>] macii_interrupt+0x0/0x576
 [<002ef380>] macii_interrupt+0x0/0x576
 [<00038166>] parse_args+0x0/0x3a6
 [<004897c0>] strcpy+0x0/0x1e
 [<000567d8>] request_threaded_irq+0xa4/0x19e
 [<00002000>] _start+0x0/0x8
 [<00002092>] do_one_initcall+0x0/0x22a
 [<002ef962>] macii_init+0x5a/0x94
 [<002ef380>] macii_interrupt+0x0/0x576
 [<002ef380>] macii_interrupt+0x0/0x576
 [<00635bee>] adb_init+0x52/0x114
 [<00635b9c>] adb_init+0x0/0x114
 [<000020c6>] do_one_initcall+0x34/0x22a
 [<00002092>] do_one_initcall+0x0/0x22a
 [<00038166>] parse_args+0x0/0x3a6
 [<004897c0>] strcpy+0x0/0x1e
 [<00060006>] rcu_exp_wait_wake+0x618/0x92e
 [<00621ace>] kernel_init_freeable+0x156/0x1ae
 [<00621ade>] kernel_init_freeable+0x166/0x1ae
 [<00635b9c>] adb_init+0x0/0x114
 [<00498e4a>] kernel_init+0x0/0xfa
 [<00498e62>] kernel_init+0x18/0xfa
 [<00498e4a>] kernel_init+0x0/0xfa
 [<00002700>] ret_from_kernel_thread+0xc/0x14
---
 drivers/macintosh/via-macii.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/macintosh/via-macii.c b/drivers/macintosh/via-macii.c
index db9270da5b8e..b6ddf1d47cb4 100644
--- a/drivers/macintosh/via-macii.c
+++ b/drivers/macintosh/via-macii.c
@@ -140,24 +140,19 @@ static int macii_probe(void)
 /* Initialize the driver */
 static int macii_init(void)
 {
-	unsigned long flags;
 	int err;
 
-	local_irq_save(flags);
-
 	err = macii_init_via();
 	if (err)
-		goto out;
+		return err;
 
 	err = request_irq(IRQ_MAC_ADB, macii_interrupt, 0, "ADB",
 			  macii_interrupt);
 	if (err)
-		goto out;
+		return err;
 
 	macii_state = idle;
-out:
-	local_irq_restore(flags);
-	return err;
+	return 0;
 }
 
 /* initialize the hardware */
-- 
2.39.3


             reply	other threads:[~2024-03-13  2:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13  2:53 Finn Thain [this message]
2024-04-29 14:37 ` [PATCH] macintosh/via-macii: Fix "BUG: sleeping function called from invalid context" Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=419fcc09d0e563b425c419053d02236b044d86b0.1710298421.git.fthain@linux-m68k.org \
    --to=fthain@linux-m68k.org \
    --cc=funaho@jurai.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).