2003-06-20 08:04:48

by Eivind Tagseth

[permalink] [raw]
Subject: Problems with PCMCIA Compact Flash adapter in 2.5.72

I've got a Kingston Compact Flash adapter that I use to mount the flash
card of my digital camera. I've had several problems with the kernel
with this, both 2.4.20, 2.5.69 and 2.5.72.

Both 2.4.20 and 2.5.69 works though, but oopses if I remove the card.
2.5.72 doesn't work at all:

(using yenta.ko)
Jun 18 21:09:19 [cardmgr] initializing socket 1
Jun 18 21:09:19 [cardmgr] socket 1: ATA/IDE Fixed Disk
Jun 18 21:09:19 [cardmgr] product info: "SanDisk", "SDP", "5/3 0.6"
Jun 18 21:09:19 [cardmgr] manfid: 0x0045, 0x0401 function: 4 (fixed disk)
Jun 18 21:09:19 [cardmgr] executing: 'modprobe ide-cs'
Jun 18 21:09:19 [cardmgr] bind 'ide-cs' to socket 1 failed: Invalid argument

I'm not sure what cardmgr tries to do with ide-cs, but it works with
2.5.69 but seems to have stopped working in 2.5.70 or 2.5.71 (didn't try
2.5.70) and is still not working in 2.5.72. stracing cardmgr didn't help,
as the interesting parts are hidden inside a vfork which strace won't follow.

2.5.69 works (using yenta_socket.ko) and logs this:
Jun 15 20:43:19 [kernel] cs: memory probe 0xa0000000-0xa0ffffff: clean.
Jun 15 20:43:19 [cardmgr] socket 1: ATA/IDE Fixed Disk
Jun 15 20:43:20 [cardmgr] executing: 'modprobe ide-cs'
Jun 15 20:43:23 [kernel] hdc: Flash Card, CFA DISK drive
Jun 15 20:43:23 [kernel] hdc: max request size: 128KiB
Jun 15 20:43:23 [kernel] hdc: task_no_data_intr: status=0x51 { DriveReady SeekCo
mplete Error }
Jun 15 20:43:23 [kernel] hdc: 1006992 sectors (516 MB) w/0KiB Cache, CHS=999/16/
63
Jun 15 20:43:23 [kernel] /dev/ide/host1/bus0/target0/lun0: p1
Jun 15 20:43:23 [cardmgr] executing: './ide start hdc'


Cardmgr is 3.2.4, pcmcia-cs is 3.2.4, gcc is 3.2.2.


I always seem to forget some vital information when reporting bugs,
please don't hesitate to ask for more info. I'll be happy to try any
patches to the kernel and/or cardmgr if needed.



Eivind


2003-06-20 17:43:31

by Bill Davidsen

[permalink] [raw]
Subject: Re: Problems with PCMCIA Compact Flash adapter in 2.5.72

On Fri, 20 Jun 2003, Eivind Tagseth wrote:

> I've got a Kingston Compact Flash adapter that I use to mount the flash
> card of my digital camera. I've had several problems with the kernel
> with this, both 2.4.20, 2.5.69 and 2.5.72.

I finally gave up on PCMCIA and invested $20 in a USB2.0 reader. Dies what
I need and seems to work with 2.4 and 2.5.6? when I last tried.

--
bill davidsen <[email protected]>
CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.

2003-06-20 19:55:04

by Russell King

[permalink] [raw]
Subject: Re: Problems with PCMCIA Compact Flash adapter in 2.5.72

On Fri, Jun 20, 2003 at 01:50:56PM -0400, Bill Davidsen wrote:
> On Fri, 20 Jun 2003, Eivind Tagseth wrote:
>
> > I've got a Kingston Compact Flash adapter that I use to mount the flash
> > card of my digital camera. I've had several problems with the kernel
> > with this, both 2.4.20, 2.5.69 and 2.5.72.
>
> I finally gave up on PCMCIA and invested $20 in a USB2.0 reader. Dies what
> I need and seems to work with 2.4 and 2.5.6? when I last tried.

Unfortunately, I seem to be unable to locate any reports describing
your problem(s).

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

2003-06-20 20:02:42

by Russell King

[permalink] [raw]
Subject: Re: Problems with PCMCIA Compact Flash adapter in 2.5.72

On Fri, Jun 20, 2003 at 10:18:46AM +0200, Eivind Tagseth wrote:
> I've got a Kingston Compact Flash adapter that I use to mount the flash
> card of my digital camera. I've had several problems with the kernel
> with this, both 2.4.20, 2.5.69 and 2.5.72.

Hmm, you mention pcmcia-cs 3.2.4 later in your mail. Are you trying to
get pcmcia-cs modules to work with the 2.5.72 pcmcia subsystem?

> I always seem to forget some vital information when reporting bugs,
> please don't hesitate to ask for more info. I'll be happy to try any
> patches to the kernel and/or cardmgr if needed.

There is this which fixes some people problems, and is already in Linus'
recent bk tree. Does this solve your problem?

--- orig/drivers/pcmcia/cs.c Tue Jun 17 12:56:30 2003
+++ linux/drivers/pcmcia/cs.c Wed Jun 18 09:47:39 2003
@@ -816,7 +816,8 @@
if ((skt->state & SOCKET_PRESENT) &&
!(status & SS_DETECT))
socket_shutdown(skt);
- if (status & SS_DETECT)
+ if (!(skt->state & SOCKET_PRESENT) &&
+ status & SS_DETECT)
socket_insert(skt);
}
if (events & SS_BATDEAD)

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

2003-06-22 11:32:40

by Eivind Tagseth

[permalink] [raw]
Subject: Re: Problems with PCMCIA Compact Flash adapter in 2.5.72

* Russell King <[email protected]> [030620 22:18]:
> Hmm, you mention pcmcia-cs 3.2.4 later in your mail. Are you trying to
> get pcmcia-cs modules to work with the 2.5.72 pcmcia subsystem?

Of course not. But I need pcmcia-cs for cardmgr and other tools. The
modules are from 2.5.72. I've also got a wireless card, which works
fine.

After learning about the -F flag to strace, I've been able to figure
out a little bit more about what cardmgr is doing:

3158 ioctl(4, 0xc050643c, 0x8054160) = -1 EINVAL (Invalid argument)

As far as I can see, this is cardmgr calling ioctl(xx, DS_BIND_REQUEST, xx),
which is defined as:
_IOWR('d', 60, bind_info_t)

> There is this which fixes some people problems, and is already in Linus'
> recent bk tree. Does this solve your problem?

Nope, no change I'm afraid.




Eivind

2003-06-22 13:01:39

by Russell King

[permalink] [raw]
Subject: Re: Problems with PCMCIA Compact Flash adapter in 2.5.72

On Sun, Jun 22, 2003 at 01:46:42PM +0200, Eivind Tagseth wrote:
> > There is this which fixes some people problems, and is already in Linus'
> > recent bk tree. Does this solve your problem?
>
> Nope, no change I'm afraid.

There appears to be something of an inconsistency in the naming (again)
for ide-cs. This should fix it.

--- orig/drivers/ide/legacy/ide-cs.c Sat Jun 14 22:33:52 2003
+++ linux/drivers/ide/legacy/ide-cs.c Sun Jun 22 14:14:35 2003
@@ -473,7 +473,7 @@
static struct pcmcia_driver ide_cs_driver = {
.owner = THIS_MODULE,
.drv = {
- .name = "ide_cs",
+ .name = "ide-cs",
},
.attach = ide_attach,
.detach = ide_detach,

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

2003-06-22 18:14:38

by Eivind Tagseth

[permalink] [raw]
Subject: Re: Problems with PCMCIA Compact Flash adapter in 2.5.72

* Russell King <[email protected]> [030622 15:18]:
> There appears to be something of an inconsistency in the naming (again)
> for ide-cs. This should fix it.

Much better. At least I think so:

Jun 22 20:22:16 [cardmgr] initializing socket 1
Jun 22 20:22:16 [cardmgr] socket 1: ATA/IDE Fixed Disk
Jun 22 20:22:16 [cardmgr] product info: "SanDisk", "SDP", "5/3 0.6"
Jun 22 20:22:16 [cardmgr] manfid: 0x0045, 0x0401 function: 4 (fixed disk)
Jun 22 20:22:16 [cardmgr] executing: 'modprobe ide-cs'
Jun 22 20:22:19 [kernel] hdc: SanDisk SDCFB-32, CFA DISK drive
Jun 22 20:22:19 [kernel] hdc: max request size: 128KiB
Jun 22 20:22:19 [kernel] /dev/ide/host1/bus0/target0/lun0: p1
Jun 22 20:22:19 [kernel] devfs_mk_bdev: could not append to parent for ide/host1/bus0/target0/lun0/part1
Jun 22 20:22:19 [kernel] kobject_register failed for hdc1 (-17)
Jun 22 20:22:19 [kernel] Call Trace:
Jun 22 20:22:19 [kernel] [<c0212640>] kobject_register+0x50/0x60
Jun 22 20:22:19 [kernel] [<c0186377>] register_disk+0x147/0x180
Jun 22 20:22:19 [kernel] [<c0245d40>] add_disk+0x50/0x60
Jun 22 20:22:19 [kernel] [<c0245cc0>] exact_match+0x0/0x10
Jun 22 20:22:19 [kernel] [<c0245cd0>] exact_lock+0x0/0x20
Jun 22 20:22:19 [kernel] [<c02643f9>] idedisk_attach+0x129/0x1b0
Jun 22 20:22:19 [kernel] [<c026032f>] ata_attach+0x9f/0x1c0
Jun 22 20:22:19 [kernel] [<c02597c3>] ideprobe_init+0xe3/0xff
Jun 22 20:22:19 [kernel] [<c025e833>] ide_probe_module+0x13/0x20
Jun 22 20:22:19 [kernel] [<c025f47f>] ide_register_hw+0x15f/0x190
Jun 22 20:22:19 [kernel] [<d0a98276>] idecs_register+0x66/0x80 [ide_cs]
Jun 22 20:22:19 [kernel] [<d32c8225>] CardServices+0x215/0x362 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d0a987c8>] ide_config+0x538/0x8a0 [ide_cs]
Jun 22 20:22:19 [kernel] [<d32c00c4>] set_cis_map+0x44/0x120 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d32c02cc>] read_cis_mem+0x12c/0x1a0 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d32c0596>] read_cis_cache+0xe6/0x170 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d32c0f1b>] pcmcia_get_tuple_data+0x9b/0xa0 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d32c225f>] pcmcia_parse_tuple+0x10f/0x180 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d32c2373>] read_tuple+0xa3/0xb0 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d0a887c3>] yenta_set_mem_map+0x1c3/0x220 [yenta]
Jun 22 20:22:19 [kernel] [<d32c0e30>] pcmcia_get_next_tuple+0x240/0x290 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d32c0955>] pcmcia_get_first_tuple+0xb5/0x160 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d0a887c3>] yenta_set_mem_map+0x1c3/0x220 [yenta]
Jun 22 20:22:19 [kernel] [<d0a887c3>] yenta_set_mem_map+0x1c3/0x220 [yenta]
Jun 22 20:22:19 [kernel] [<d32c00c4>] set_cis_map+0x44/0x120 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d32c02cc>] read_cis_mem+0x12c/0x1a0 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d32c0596>] read_cis_cache+0xe6/0x170 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d32c0f1b>] pcmcia_get_tuple_data+0x9b/0xa0 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d32c225f>] pcmcia_parse_tuple+0x10f/0x180 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d32c2373>] read_tuple+0xa3/0xb0 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d0a887c3>] yenta_set_mem_map+0x1c3/0x220 [yenta]
Jun 22 20:22:19 [kernel] [<d32c0e30>] pcmcia_get_next_tuple+0x240/0x290 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d32c0955>] pcmcia_get_first_tuple+0xb5/0x160 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d32c0596>] read_cis_cache+0xe6/0x170 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d32c0e30>] pcmcia_get_next_tuple+0x240/0x290 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<c020271a>] set_bit_in_list_bitmap+0x5a/0x70
Jun 22 20:22:19 [kernel] [<c01f0fd1>] check_left+0x141/0x170
Jun 22 20:22:19 [kernel] [<c01fcff3>] pathrelse_and_restore+0x43/0x50
Jun 22 20:22:19 [kernel] [<d0a98cc7>] ide_event+0x67/0x100 [ide_cs]
Jun 22 20:22:19 [kernel] [<d32c6c83>] pcmcia_register_client+0x213/0x280 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d0a887c3>] yenta_set_mem_map+0x1c3/0x220 [yenta]
Jun 22 20:22:19 [kernel] [<d32c81be>] CardServices+0x1ae/0x362 [pcmcia_core]
Jun 22 20:22:19 [kernel] [<d0a9810e>] +0x10e/0x150 [ide_cs]
Jun 22 20:22:19 [kernel] [<d0a99ac0>] dev_info+0x0/0x20 [ide_cs]
Jun 22 20:22:19 [kernel] [<d0a98c60>] ide_event+0x0/0x100 [ide_cs]
Jun 22 20:22:19 [kernel] [<d0a98db5>] +0x1c/0x27 [ide_cs]
Jun 22 20:22:19 [kernel] [<d0a9447f>] get_pcmcia_driver+0x3f/0x50 [ds]
Jun 22 20:22:19 [kernel] [<d0a99b00>] ide_cs_driver+0x0/0x80 [ide_cs]
Jun 22 20:22:19 [kernel] [<d0a93536>] bind_request+0x186/0x220 [ds]
Jun 22 20:22:19 [kernel] [<d0a98db5>] +0x1c/0x27 [ide_cs]
Jun 22 20:22:19 [kernel] [<d0a9410a>] ds_ioctl+0x5ca/0x6c0 [ds]
Jun 22 20:22:19 [kernel] [<c028a260>] sock_def_readable+0x80/0x90
Jun 22 20:22:19 [kernel] [<c02ddbb7>] unix_dgram_sendmsg+0x377/0x570
Jun 22 20:22:19 [kernel] [<c0286a9e>] sock_sendmsg+0x9e/0xd0
Jun 22 20:22:19 [kernel] [<c016e84f>] wake_up_inode+0xf/0x30
Jun 22 20:22:19 [kernel] [<c017fc41>] proc_get_inode+0x161/0x190
Jun 22 20:22:19 [kernel] [<c013bb2e>] buffered_rmqueue+0xce/0x1a0
Jun 22 20:22:19 [kernel] [<c014419b>] zap_pmd_range+0x4b/0x70
Jun 22 20:22:19 [kernel] [<c014420b>] unmap_page_range+0x4b/0x90
Jun 22 20:22:19 [kernel] [<c014431f>] unmap_vmas+0xcf/0x240
Jun 22 20:22:19 [kernel] [<c0148145>] unmap_region+0x95/0xe0
Jun 22 20:22:19 [kernel] [<c0148042>] unmap_vma+0x42/0x80
Jun 22 20:22:19 [kernel] [<c014809f>] unmap_vma_list+0x1f/0x30
Jun 22 20:22:19 [kernel] [<c014848d>] do_munmap+0x15d/0x1c0
Jun 22 20:22:19 [kernel] [<c0166620>] sys_ioctl+0x100/0x290
Jun 22 20:22:19 [kernel] [<c01092db>] syscall_call+0x7/0xb
Jun 22 20:22:19 [kernel]
Jun 22 20:22:19 [cardmgr] executing: './ide start hdc'
Jun 22 20:22:19 [kernel] Module ide_cs cannot be unloaded due to unsafe usage in include/linux/module.h:479
Jun 22 20:22:19 [kernel] Unable to handle kernel NULL pointer dereference at virtual address 0000004f
Jun 22 20:22:19 [cardmgr] start cmd exited with status 139


lsmod:

Module Size Used by
ide_cs 7552 2 [unsafe]
ds 15200 5 ide_cs
yenta 13216 2
pcmcia_core 72224 3 ide_cs,ds,yenta
r128 95224 2
agpgart 31752 0
usbcore 110612 1
psmouse 8324 0
mousedev 9044 1

ls on /dev/discs/disc1 hangs and is unkillable, and attempting to mount it
hangs forever as well.




Eivind

2003-06-22 19:02:39

by Eivind Tagseth

[permalink] [raw]
Subject: Re: Problems with PCMCIA Compact Flash adapter in 2.5.72

* Eivind Tagseth <[email protected]> [030622 20:31]:
> * Russell King <[email protected]> [030622 15:18]:
> > There appears to be something of an inconsistency in the naming (again)
> > for ide-cs. This should fix it.
>
> Much better. At least I think so:
>
> Jun 22 20:22:19 [kernel] kobject_register failed for hdc1 (-17)
> Jun 22 20:22:19 [kernel] Call Trace:

Actually, rebooting and retrying, it works:


Jun 22 20:52:37 [cardmgr] initializing socket 1
Jun 22 20:52:37 [kernel] cs: memory probe 0xa0000000-0xa0ffffff: clean.
Jun 22 20:52:37 [cardmgr] socket 1: ATA/IDE Fixed Disk
Jun 22 20:52:37 [cardmgr] product info: "SanDisk", "SDP", "5/3 0.6"
Jun 22 20:52:37 [cardmgr] manfid: 0x0045, 0x0401 function: 4 (fixed disk)
Jun 22 20:52:37 [cardmgr] executing: 'modprobe ide-cs'
Jun 22 20:52:40 [kernel] hdc: SanDisk SDCFB-32, CFA DISK drive
Jun 22 20:52:40 [kernel] hdc: max request size: 128KiB
Jun 22 20:52:40 [kernel] /dev/ide/host1/bus0/target0/lun0: p1
Jun 22 20:52:40 [kernel] Module ide_cs cannot be unloaded due to unsafe usage in
include/linux/module.h:479
Jun 22 20:52:40 [cardmgr] executing: './ide start hdc'
Jun 22 20:52:40 [cardmgr] + mknod /dev/hdc b 22 0
Jun 22 20:52:40 [cardmgr] + mknod: `/dev/hdc': File exists
Jun 22 20:52:40 [cardmgr] + mknod /dev/hdc1 b 22 1
Jun 22 20:52:40 [cardmgr] + mknod: `/dev/hdc1': File exists
Jun 22 20:52:40 [cardmgr] + mknod /dev/hdc2 b 22 2
Jun 22 20:52:40 [cardmgr] + mknod /dev/hdc3 b 22 3
.
.
.
Jun 22 20:52:40 [cardmgr] + mknod /dev/hdc16 b 22 16


However, removing the card causes a kernel panic, and everything completely
freezes. This also happened with 2.5.69, so it's not caused by a recent
change.

If I'm not _supposed_ to be able to remove the card, or if I'm doing it
the wrong way, please let me know...

I'm unable to see the top of the panic, and I'm too lazy to type
it all down, but here's what I did see:

try_to_wake_up
default_wake_function
ide_release
update_process_times
ide_release
run_timer
do_timer
do_softirq
do_IRQ
common_interrupt
sys_ipc
apm_bios_call_simple
apm_do_idle
apm_cpu_idle
apm_cpu_idle
default_idle
cpu_idle
_stext
start_kernel
unknown_bootoption

Code: 0f 0b 4b 02 3f fd 31 c0 e9 a6 f7 ff ff 8d 74 26 00 55 31 d2
<0>Kernel panic: Fatal exception in interrupt


(beware of typos).

If providing all the info helps you, I'll do it. I have no idea what I can
do to read the whole message though.



Eivind

2003-06-23 09:15:41

by Russell King

[permalink] [raw]
Subject: Re: Problems with PCMCIA Compact Flash adapter in 2.5.72

On Sun, Jun 22, 2003 at 09:16:27PM +0200, Eivind Tagseth wrote:
> However, removing the card causes a kernel panic, and everything completely
> freezes. This also happened with 2.5.69, so it's not caused by a recent
> change.

ide-cs currently calls ide_unregister from interrupt context, which is
a big nono. Can you try the following patch please (which is completely
untested)?

--- orig/drivers/ide/legacy/ide-cs.c Sat Jun 14 22:33:52 2003
+++ linux/drivers/ide/legacy/ide-cs.c Mon Jun 23 10:27:20 2003
@@ -92,7 +92,7 @@
int hd;
} ide_info_t;

-static void ide_release(u_long arg);
+static void ide_release(dev_link_t *link);
static int ide_event(event_t event, int priority,
event_callback_args_t *args);

@@ -126,9 +126,6 @@
memset(info, 0, sizeof(*info));
link = &info->link; link->priv = info;

- init_timer(&link->release);
- link->release.function = &ide_release;
- link->release.data = (u_long)link;
link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
link->io.IOAddrLines = 3;
@@ -187,9 +184,8 @@
if (*linkp == NULL)
return;

- del_timer(&link->release);
if (link->state & DEV_CONFIG)
- ide_release((u_long)link);
+ ide_release(link);

if (link->handle) {
ret = CardServices(DeregisterClient, link->handle);
@@ -383,7 +379,7 @@
cs_failed:
cs_error(link->handle, last_fn, last_ret);
failed:
- ide_release((u_long)link);
+ ide_release(link);
link->state &= ~DEV_CONFIG_PENDING;

} /* ide_config */
@@ -396,9 +392,8 @@

======================================================================*/

-void ide_release(u_long arg)
+void ide_release(dev_link_t *link)
{
- dev_link_t *link = (dev_link_t *)arg;
ide_info_t *info = link->priv;

DEBUG(0, "ide_release(0x%p)\n", link);
@@ -446,7 +441,7 @@
case CS_EVENT_CARD_REMOVAL:
link->state &= ~DEV_PRESENT;
if (link->state & DEV_CONFIG)
- mod_timer(&link->release, jiffies + HZ/20);
+ ide_release(link);
break;
case CS_EVENT_CARD_INSERTION:
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;


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

2003-06-23 11:21:42

by Alan

[permalink] [raw]
Subject: Re: Problems with PCMCIA Compact Flash adapter in 2.5.72

On Llu, 2003-06-23 at 10:29, Russell King wrote:
> On Sun, Jun 22, 2003 at 09:16:27PM +0200, Eivind Tagseth wrote:
> > However, removing the card causes a kernel panic, and everything completely
> > freezes. This also happened with 2.5.69, so it's not caused by a recent
> > change.
>
> ide-cs currently calls ide_unregister from interrupt context, which is
> a big nono. Can you try the following patch please (which is completely
> untested)?
>

This is better but still wrong in a way - ide_unregister can fail and
ide-cs in both 2.4 and 2.5 doesnt recover from that, or know about the
new "unplugged" ops it should force

2003-06-24 08:36:14

by Eivind Tagseth

[permalink] [raw]
Subject: Re: Problems with PCMCIA Compact Flash adapter in 2.5.72

* Russell King <[email protected]> [030623 11:32]:
> On Sun, Jun 22, 2003 at 09:16:27PM +0200, Eivind Tagseth wrote:
> > However, removing the card causes a kernel panic, and everything completely
> > freezes. This also happened with 2.5.69, so it's not caused by a recent
> > change.
>
> ide-cs currently calls ide_unregister from interrupt context, which is
> a big nono. Can you try the following patch please (which is completely
> untested)?

Ok, I tried it (with 2.5.73), with slightly better success. I still
get oopses, but the system doesn't hang completely anymore. But the pcmcia
system (and probably more) is unstable afterwards. There are oopses
when shutting down as well...

Console output when inserting the card:

hdc: SanDisk SDCFB-32, CFA DISK drive
ide1 at 0x140-0x147,0x14e on irq 9
hdc: max request size: 128KiB
hdc: task_no_data_intr: status=0x51 { DriveReady SeekComplete Error }
hdc: task_no_data_intr: error=0x04 { DriveStatusError }
hdc: 62720 sectors (32 MB) w/1KiB Cache, CHS=490/4/32
/dev/ide/host1/bus0/target0/lun0: p1
/dev/ide/host1/bus0/target0/lun0: p1
devfs_mk_bdev: could not append to parent for ide/host1/bus0/target0/lun0/part1
kobject_register failed for hdc1 (-17)
Call Trace:
[<c0213560>] kobject_register+0x50/0x60
[<c0186ff7>] register_disk+0x147/0x180
[<c0245e20>] add_disk+0x50/0x60
[<c0245da0>] exact_match+0x0/0x10
[<c0245db0>] exact_lock+0x0/0x20
[<c0264789>] idedisk_attach+0x129/0x1b0
[<c02606af>] ata_attach+0x9f/0x1c0
[<c0259a23>] ideprobe_init+0xe3/0xff
[<c025ebb3>] ide_probe_module+0x13/0x20
[<c025f7ff>] ide_register_hw+0x15f/0x190
[<d0aa3246>] idecs_register+0x66/0x80 [ide_cs]
[<d0a912a5>] CardServices+0x215/0x362 [pcmcia_core]
[<d0aa3798>] ide_config+0x538/0x8a0 [ide_cs]
[<d0a890bc>] set_cis_map+0x3c/0x120 [pcmcia_core]
[<d0a892cc>] read_cis_mem+0x12c/0x1a0 [pcmcia_core]
[<d0a89596>] read_cis_cache+0xe6/0x170 [pcmcia_core]
[<d0a89f1b>] pcmcia_get_tuple_data+0x9b/0xa0 [pcmcia_core]
[<d0a8b25f>] pcmcia_parse_tuple+0x10f/0x180 [pcmcia_core]
[<d0a8b373>] read_tuple+0xa3/0xb0 [pcmcia_core]
[<d0a577c3>] yenta_set_mem_map+0x1c3/0x220 [yenta_socket]
[<c0119105>] __ioremap+0xe5/0x120
[<d0a89e30>] pcmcia_get_next_tuple+0x240/0x290 [pcmcia_core]
[<d0a89955>] pcmcia_get_first_tuple+0xb5/0x160 [pcmcia_core]
[<d0a577c3>] yenta_set_mem_map+0x1c3/0x220 [yenta_socket]
[<d0a577c3>] yenta_set_mem_map+0x1c3/0x220 [yenta_socket]
[<d0a890bc>] set_cis_map+0x3c/0x120 [pcmcia_core]
[<d0a892cc>] read_cis_mem+0x12c/0x1a0 [pcmcia_core]
[<d0a89596>] read_cis_cache+0xe6/0x170 [pcmcia_core]
[<d0a89f1b>] pcmcia_get_tuple_data+0x9b/0xa0 [pcmcia_core]
[<d0a8b25f>] pcmcia_parse_tuple+0x10f/0x180 [pcmcia_core]
[<d0a8b373>] read_tuple+0xa3/0xb0 [pcmcia_core]
[<d0a577c3>] yenta_set_mem_map+0x1c3/0x220 [yenta_socket]
[<c0119105>] __ioremap+0xe5/0x120
[<d0a89e30>] pcmcia_get_next_tuple+0x240/0x290 [pcmcia_core]
[<d0a89955>] pcmcia_get_first_tuple+0xb5/0x160 [pcmcia_core]
[<d0a89596>] read_cis_cache+0xe6/0x170 [pcmcia_core]
[<d0a89e30>] pcmcia_get_next_tuple+0x240/0x290 [pcmcia_core]
[<d0a8b4b3>] pcmcia_validate_cis+0x133/0x210 [pcmcia_core]
[<c0157662>] __find_get_block+0x92/0xf0
[<c01f1ca1>] create_virtual_node+0x361/0x540
[<c01fdfd3>] pathrelse_and_restore+0x43/0x50
[<d0aa3c88>] ide_event+0x58/0xe0 [ide_cs]
[<d0a8fd03>] pcmcia_register_client+0x213/0x280 [pcmcia_core]
[<d0a577c3>] yenta_set_mem_map+0x1c3/0x220 [yenta_socket]
[<d0a9123e>] CardServices+0x1ae/0x362 [pcmcia_core]
[<d0aa30f3>] +0xf3/0x130 [ide_cs]
[<d0aa4960>] dev_info+0x0/0x20 [ide_cs]
[<d0aa3c30>] ide_event+0x0/0xe0 [ide_cs]
[<d0aa3d65>] +0x1c/0x37 [ide_cs]
[<d0a634bf>] get_pcmcia_driver+0x3f/0x50 [ds]
[<d0aa49a0>] ide_cs_driver+0x0/0x80 [ide_cs]
[<d0a62536>] bind_request+0x186/0x220 [ds]
[<d0aa3d65>] +0x1c/0x37 [ide_cs]
[<d0a63141>] ds_ioctl+0x601/0x700 [ds]
[<c011ae76>] preempt_schedule+0x36/0x50
[<c02de8a7>] unix_dgram_sendmsg+0x377/0x580
[<c013c2e0>] __alloc_pages+0xa0/0x330
[<c028705e>] sock_sendmsg+0x9e/0xd0
[<c0118b6c>] do_page_fault+0x23c/0x456
[<c016f32f>] wake_up_inode+0xf/0x30
[<c0180871>] proc_get_inode+0x161/0x190
[<c013c16e>] buffered_rmqueue+0xce/0x1a0
[<c014486b>] zap_pmd_range+0x4b/0x70
[<c01448db>] unmap_page_range+0x4b/0x90
[<c01449ef>] unmap_vmas+0xcf/0x240
[<c0148815>] unmap_region+0x95/0xe0
[<c0148712>] unmap_vma+0x42/0x80
[<c014876f>] unmap_vma_list+0x1f/0x30
[<c0148b5d>] do_munmap+0x15d/0x1c0
[<c0167050>] sys_ioctl+0x100/0x290
[<c010931b>] syscall_call+0x7/0xb

Module ide_cs cannot be unloaded due to unsafe usage in include/linux/module.h:479
ide-cs: hdc: Vcc = 3.3, Vpp = 0.0


(this also happens without your patch. I reported it earlier for 2.5.72, but
I said that it didn't happen after I rebooted. With 2.5.73 (without your
patch) it happens every time.

The device still works though, even with this not very encouraging message.


Console messages when physically removing the card (I haven't mounted
it or done anything with it since inserting the card):

devfs_remove: ide/host1/bus0/target0/lun0/disc not found, cannot remove
Call Trace:
[<c01b014d>] devfs_remove+0xad/0xb0
[<c0245d91>] blk_unregister_region+0x21/0x30
[<c01876ce>] devfs_remove_disk+0x4e/0x95
[<c0187327>] del_gendisk+0x87/0xe0
[<c02643e8>] idedisk_cleanup+0x48/0x60
[<c025f613>] ide_unregister+0x863/0x890
[<c011ac2b>] schedule+0x1bb/0x3d0
[<c0126629>] schedule_timeout+0x69/0xc0
[<d0aa3b94>] ide_release+0x94/0x130 [ide_cs]
[<d0aa3c7a>] ide_event+0x4a/0xe0 [ide_cs]
[<d0a8e361>] send_event+0x61/0x70 [pcmcia_core]
[<d0a8e3e0>] socket_remove_drivers+0x20/0x50 [pcmcia_core]
[<d0a8e423>] socket_shutdown+0x13/0x60 [pcmcia_core]
[<d0a8e9a3>] pccardd+0x143/0x210 [pcmcia_core]
[<c011ae90>] default_wake_function+0x0/0x30
[<c01091f2>] ret_from_fork+0x6/0x14
[<c011ae90>] default_wake_function+0x0/0x30
[<d0a8e860>] pccardd+0x0/0x210 [pcmcia_core]
[<c01071e5>] kernel_thread_helper+0x5/0x10


There are some weird messages about devices.

This is what it looks like when the card is in:

brw------- 1 eivindt root 22, 1 Jan 1 1970 /dev/ide/host1/bus0/target0/lun0/part1

This is what it looks like when it's been removed:

drwxr-xr-x 1 root root 0 Jan 1 1970 /dev/ide/host1/bus0/target0/

There is not /dev/ide/host1 when the card has not been inserted at all.


Hope this helps, Eivind