2003-05-13 13:45:31

by Alex Riesen

[permalink] [raw]
Subject: 2.5.69+bk: "sleeping function called from illegal context" on card release while shutting down

Hi!

Just tried to eject the card while the system was shutting down.

-alex

$ lsmod
Module Size Used by
pcnet_cs 16100 1
8390 8384 1 pcnet_cs
crc32 3744 1 8390
ds 11616 3 pcnet_cs
yenta_socket 14240 2
pcmcia_core 53888 3 pcnet_cs,ds,yenta_socket
soundcore 6560 0

$ lspci |grep CardBus
00:11.0 CardBus bridge: Texas Instruments PCI1131 (rev 01)
00:11.1 CardBus bridge: Texas Instruments PCI1131 (rev 01)

$ grep PCMCIA .config
# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
# PCMCIA/CardBus support
CONFIG_PCMCIA=m
CONFIG_PCMCIA_PROBE=y
# CONFIG_PARPORT_PC_PCMCIA is not set
# PCMCIA SCSI adapter support
# CONFIG_PCMCIA_AHA152X is not set
# CONFIG_PCMCIA_FDOMAIN is not set
# CONFIG_PCMCIA_NINJA_SCSI is not set
# CONFIG_PCMCIA_QLOGIC is not set
# PCMCIA network device support
CONFIG_NET_PCMCIA=y
CONFIG_PCMCIA_3C589=m
CONFIG_PCMCIA_3C574=m
CONFIG_PCMCIA_FMVJ18X=m
CONFIG_PCMCIA_PCNET=m
CONFIG_PCMCIA_NMCLAN=m
CONFIG_PCMCIA_SMC91C92=m
CONFIG_PCMCIA_XIRC2PS=m
# CONFIG_PCMCIA_AXNET is not set
# PCMCIA character devices


Hw. address read/write mismap 0
Hw. address read/write mismap 1
Hw. address read/write mismap 2
Hw. address read/write mismap 3
Hw. address read/write mismap 4
Hw. address read/write mismap 5
Debug: sleeping function called from illegal context at include/asm/semaphore.h:119
Call Trace:
[<c0118bc8>] __might_sleep+0x58/0x70
[<c6a31eb6>] +0x82/0x58c [pcmcia_core]
[<c6a2d193>] undo_irq+0x23/0x90 [pcmcia_core]
[<c6a31eb6>] +0x82/0x58c [pcmcia_core]
[<c6a302f8>] pcmcia_release_irq+0xb8/0xe0 [pcmcia_core]
[<c6a25e00>] pcnet_release+0x0/0x80 [pcnet_cs]
[<c6a312d5>] CardServices+0x155/0x260 [pcmcia_core]
[<c6a312c9>] CardServices+0x149/0x260 [pcmcia_core]
[<c6a25e56>] pcnet_release+0x56/0x80 [pcnet_cs]
[<c01224a4>] run_timer_softirq+0xc4/0x1a0
[<c010a8b3>] handle_IRQ_event+0x33/0xf0
[<c011e889>] do_softirq+0xa9/0xb0
[<c010abb5>] do_IRQ+0x125/0x150
[<c01093a8>] common_interrupt+0x18/0x20
[<c01a3dba>] strnlen_user+0x1a/0x40
[<c016fd42>] create_elf_tables+0x2d2/0x360
[<c01706cd>] load_elf_binary+0x4cd/0xba0
[<c0134379>] buffered_rmqueue+0xc9/0x160
[<c0170200>] load_elf_binary+0x0/0xba0
[<c015639b>] search_binary_handler+0xcb/0x2d0
[<c01566f9>] do_execve+0x159/0x1a0
[<c0157d28>] getname+0x78/0xc0
[<c0107a46>] sys_execve+0x36/0x70
[<c0109187>] syscall_call+0x7/0xb


2003-05-13 14:46:57

by Felipe Alfaro Solana

[permalink] [raw]
Subject: Re: 2.5.69+bk: "sleeping function called from illegal context" on card release while shutting down

On Tue, 2003-05-13 at 15:57, Alex Riesen wrote:
> Just tried to eject the card while the system was shutting down.
>
> Debug: sleeping function called from illegal context at include/asm/semaphore.h:119
> Call Trace:
> [<c0118bc8>] __might_sleep+0x58/0x70
> [<c6a31eb6>] +0x82/0x58c [pcmcia_core]
> [<c6a2d193>] undo_irq+0x23/0x90 [pcmcia_core]
> [<c6a31eb6>] +0x82/0x58c [pcmcia_core]
> [<c6a302f8>] pcmcia_release_irq+0xb8/0xe0 [pcmcia_core]
> [<c6a25e00>] pcnet_release+0x0/0x80 [pcnet_cs]
> [<c6a312d5>] CardServices+0x155/0x260 [pcmcia_core]
> [<c6a312c9>] CardServices+0x149/0x260 [pcmcia_core]
> [<c6a25e56>] pcnet_release+0x56/0x80 [pcnet_cs]
> [<c01224a4>] run_timer_softirq+0xc4/0x1a0
> [<c010a8b3>] handle_IRQ_event+0x33/0xf0
> [<c011e889>] do_softirq+0xa9/0xb0
> [<c010abb5>] do_IRQ+0x125/0x150
> [<c01093a8>] common_interrupt+0x18/0x20
> [<c01a3dba>] strnlen_user+0x1a/0x40
> [<c016fd42>] create_elf_tables+0x2d2/0x360
> [<c01706cd>] load_elf_binary+0x4cd/0xba0
> [<c0134379>] buffered_rmqueue+0xc9/0x160
> [<c0170200>] load_elf_binary+0x0/0xba0
> [<c015639b>] search_binary_handler+0xcb/0x2d0
> [<c01566f9>] do_execve+0x159/0x1a0
> [<c0157d28>] getname+0x78/0xc0
> [<c0107a46>] sys_execve+0x36/0x70
> [<c0109187>] syscall_call+0x7/0xb

Don't know if this is fixed by latest Russell patches, but vanilla and
-bk snapshots do *not* contain the latest PCMCIA/CardBus code. Is it
possible for you to try 2.5.69-mm4?

Thanks!


2003-05-13 15:19:34

by Paul Fulghum

[permalink] [raw]
Subject: Re: 2.5.69+bk: "sleeping function called from illegal context" on card release while shutting down

On Tue, 2003-05-13 at 09:58, Felipe Alfaro Solana wrote:
> On Tue, 2003-05-13 at 15:57, Alex Riesen wrote:
> > Just tried to eject the card while the system was shutting down.

> Don't know if this is fixed by latest Russell patches, but vanilla and
> -bk snapshots do *not* contain the latest PCMCIA/CardBus code. Is it
> possible for you to try 2.5.69-mm4?

Russell's patches do not address this.

Individual PCMCIA drivers need to be updated to call
thier release function directly when processing a
CARD_RELEASE message instead of from a timer procedure.

Similar to this patch for synclink_cs.c:

diff -u -4 -r4.9 synclink_cs.c
--- synclink_cs.c 2003/05/08 19:26:53 4.9
+++ synclink_cs.c 2003/05/13 15:29:15
@@ -814,9 +814,9 @@
case CS_EVENT_CARD_REMOVAL:
link->state &= ~DEV_PRESENT;
if (link->state & DEV_CONFIG) {
((MGSLPC_INFO *)link->priv)->stop = 1;
- mod_timer(&link->release, jiffies + HZ/20);
+ mgslpc_release((u_long)link);
}
break;
case CS_EVENT_CARD_INSERTION:
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;

The timer link->release is initialized with the release
function (in this case mgslpc_release, but called something
else in your driver). Now it is called directly.

--
Paul Fulghum, [email protected]
Microgate Corporation, http://www.microgate.com


2003-05-13 16:00:07

by Russell King

[permalink] [raw]
Subject: Re: 2.5.69+bk: "sleeping function called from illegal context" on card release while shutting down

On Tue, May 13, 2003 at 10:31:01AM -0500, Paul Fulghum wrote:
> Russell's patches do not address this.

In part they do - the patch gives us a guaranteed process context for
the pcmcia event stuff. The process context is provided in the right
place (core pcmcia code).

Things left in this area are:

- Remove workqueues from socket drivers.
- I'd like to see struct pcmcia_driver expand to include more
functions (card removal, insertion, etc) rather than having
an event handler.
- Remove the card removal event timers from pcmcia drivers.

--
Russell King ([email protected]) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html

2003-05-13 17:08:47

by Alex Riesen

[permalink] [raw]
Subject: Re: 2.5.69+bk: "sleeping function called from illegal context" on card release while shutting down

Paul Fulghum, Tue, May 13, 2003 17:31:01 +0200:
> > > Just tried to eject the card while the system was shutting down.
> > Don't know if this is fixed by latest Russell patches, but vanilla and
> > -bk snapshots do *not* contain the latest PCMCIA/CardBus code. Is it
> > possible for you to try 2.5.69-mm4?
>
> Russell's patches do not address this.

still i'm going to give them a spin a bit later.

> Individual PCMCIA drivers need to be updated to call
> thier release function directly when processing a
> CARD_RELEASE message instead of from a timer procedure.
>
> Similar to this patch for synclink_cs.c:
...
> - mod_timer(&link->release, jiffies + HZ/20);
> + mgslpc_release((u_long)link);

Tried that. This time the trace looks different:

Debug: sleeping function called from illegal context at include/asm/semaphore.h:119
Call Trace:
[<c0118bc8>] __might_sleep+0x58/0x70
[<c6a31eb6>] +0x82/0x58c [pcmcia_core]
[<c6a2d193>] undo_irq+0x23/0x90 [pcmcia_core]
[<c6a31eb6>] +0x82/0x58c [pcmcia_core]
[<c6a302f8>] pcmcia_release_irq+0xb8/0xe0 [pcmcia_core]
[<c6a25e00>] pcnet_release+0x0/0x80 [pcnet_cs]
[<c6a312d5>] CardServices+0x155/0x260 [pcmcia_core]
[<c6a312c9>] CardServices+0x149/0x260 [pcmcia_core]
[<c6a25e56>] pcnet_release+0x56/0x80 [pcnet_cs]
[<c01224a4>] run_timer_softirq+0xc4/0x1a0
[<c010a8b3>] handle_IRQ_event+0x33/0xf0
[<c011e889>] do_softirq+0xa9/0xb0
[<c010abb5>] do_IRQ+0x125/0x150
[<c01093a8>] common_interrupt+0x18/0x20
[<c013cfb6>] zap_pte_range+0xd6/0x1d0
[<c013d0f3>] zap_pmd_range+0x43/0x70
[<c013d153>] unmap_page_range+0x33/0x60
[<c013d271>] unmap_vmas+0xf1/0x260
[<c01412d5>] exit_mmap+0x65/0x180
[<c0119196>] mmput+0x56/0xb0
[<c01556ce>] exec_mmap+0xce/0x150
[<c01557e8>] flush_old_exec+0x18/0x830
[<c01555ea>] kernel_read+0x3a/0x50
[<c0170483>] load_elf_binary+0x283/0xba0
[<c01316fd>] generic_file_aio_read+0x3d/0x50
[<c0134379>] buffered_rmqueue+0xc9/0x160
[<c0170200>] load_elf_binary+0x0/0xba0
[<c015639b>] search_binary_handler+0xcb/0x2d0
[<c01566f9>] do_execve+0x159/0x1a0
[<c0157d28>] getname+0x78/0xc0
[<c0107a46>] sys_execve+0x36/0x70
[<c0109187>] syscall_call+0x7/0xb

2003-05-13 17:16:47

by Paul Fulghum

[permalink] [raw]
Subject: Re: 2.5.69+bk: "sleeping function called from illegal context" on card release while shutting down

On Tue, 2003-05-13 at 12:21, Alex Riesen wrote:
> Paul Fulghum, Tue, May 13, 2003 17:31:01 +0200:
> > Similar to this patch for synclink_cs.c:
> ...
> > - mod_timer(&link->release, jiffies + HZ/20);
> > + mgslpc_release((u_long)link);
>
> Tried that. This time the trace looks different:
>
> Debug: sleeping function called from illegal context at include/asm/semaphore.h:119
> Call Trace:
> [<c0118bc8>] __might_sleep+0x58/0x70
> [<c6a31eb6>] +0x82/0x58c [pcmcia_core]
> [<c6a2d193>] undo_irq+0x23/0x90 [pcmcia_core]
> [<c6a31eb6>] +0x82/0x58c [pcmcia_core]
> [<c6a302f8>] pcmcia_release_irq+0xb8/0xe0 [pcmcia_core]
> [<c6a25e00>] pcnet_release+0x0/0x80 [pcnet_cs]
> [<c6a312d5>] CardServices+0x155/0x260 [pcmcia_core]
> [<c6a312c9>] CardServices+0x149/0x260 [pcmcia_core]
> [<c6a25e56>] pcnet_release+0x56/0x80 [pcnet_cs]
> [<c01224a4>] run_timer_softirq+0xc4/0x1a0
> [<c010a8b3>] handle_IRQ_event+0x33/0xf0
> [<c011e889>] do_softirq+0xa9/0xb0
> [<c010abb5>] do_IRQ+0x125/0x150
> [<c01093a8>] common_interrupt+0x18/0x20

Hmmm... the pcnet_release() function is still being called
from a timer context.

Looking at pcnet_cs.c I see that in function pcnet_close()
that the release function is being being run from
a timer. Try changing that instance to calling pcnet_release()
directly as you did in the CS_EVENT handler.

--
Paul Fulghum, [email protected]
Microgate Corporation, http://www.microgate.com


2003-05-13 17:20:28

by Alex Riesen

[permalink] [raw]
Subject: Re: 2.5.69+bk: "sleeping function called from illegal context" on card release while shutting down

Alex Riesen, Tue, May 13, 2003 19:21:14 +0200:
> Paul Fulghum, Tue, May 13, 2003 17:31:01 +0200:
> > Individual PCMCIA drivers need to be updated to call
> > thier release function directly when processing a
> > CARD_RELEASE message instead of from a timer procedure.
> >
> > Similar to this patch for synclink_cs.c:
> ...
> > - mod_timer(&link->release, jiffies + HZ/20);
> > + mgslpc_release((u_long)link);
>
> Tried that. This time the trace looks different:
>

I was probably too fast with the conclusions. It seemed I didn't update
modules (though I and bash history distinctly remember doing that).

I cannot reproduce the trace anymore. The patch was:

--- pcnet_cs.c 2003-04-30 06:17:05.000000000 +0200
+++ pcnet_cs.c 2003-05-13 19:31:12.000000000 +0200
@@ -848,7 +848,7 @@ static int pcnet_event(event_t event, in
link->state &= ~DEV_PRESENT;
if (link->state & DEV_CONFIG) {
netif_device_detach(&info->dev);
- mod_timer(&link->release, jiffies + HZ/20);
+ pcnet_release((u_long)link);
}
break;
case CS_EVENT_CARD_INSERTION:

2003-05-13 18:34:22

by Alex Riesen

[permalink] [raw]
Subject: Re: 2.5.69+bk: "sleeping function called from illegal context" on card release while shutting down

Thanks Paul,

your last suggestion (pcnet_close) helped. The previous patch was not
enough, of course.
I tried hard to reproduce it, and almost broke the card.
No "wrong sleepers" seen anymore.

Someone still has to remove the timer. It is not used anymore, in this
file, at least.

-alex

--- a/drivers/net/pcmcia/pcnet_cs.c 2003-05-13 20:34:12.000000000 +0200
+++ b/drivers/net/pcmcia/pcnet_cs.c 2003-05-13 20:34:08.000000000 +0200
@@ -848,7 +848,7 @@ static int pcnet_event(event_t event, in
link->state &= ~DEV_PRESENT;
if (link->state & DEV_CONFIG) {
netif_device_detach(&info->dev);
- mod_timer(&link->release, jiffies + HZ/20);
+ pcnet_release(link);
}
break;
case CS_EVENT_CARD_INSERTION:
@@ -1054,7 +1054,7 @@ static int pcnet_close(struct net_device
netif_stop_queue(dev);
del_timer(&info->watchdog);
if (link->state & DEV_STALE_CONFIG)
- mod_timer(&link->release, jiffies + HZ/20);
+ pcnet_release((u_long)link);

return 0;
} /* pcnet_close */

2003-05-13 21:39:27

by Felipe Alfaro Solana

[permalink] [raw]
Subject: Re: 2.5.69+bk: "sleeping function called from illegal context" on card release while shutting down

On Tue, 2003-05-13 at 17:31, Paul Fulghum wrote:
> > Don't know if this is fixed by latest Russell patches, but vanilla and
> > -bk snapshots do *not* contain the latest PCMCIA/CardBus code. Is it
> > possible for you to try 2.5.69-mm4?
>
> Russell's patches do not address this.

I knew I were no expert on this... ;-)

> Individual PCMCIA drivers need to be updated to call
> thier release function directly when processing a
> CARD_RELEASE message instead of from a timer procedure.

Aha! I got you! Thanks.