g_NCR5380 - 2.6.0 - problem with reloading module
Subsystems (2)
Hi,
i hope this is the right emailadress for my problem...
The first time I load the module g_NCR5380 everything works fine:
scsi0 : interrupts not enabled. for better interactive performance, scsi0 : please jumper the board for a free IRQ.
scsi0 : at port 0x280 interrupts disabled options CAN_QUEUE=16
CMD_PER_LUN=2 release=1 generic options AUTOPROBE_IRQ AUTOSENSE USLEEP, USLEEP_POLL=1 USLEEP_SLEEP=20 generic release=7
scsi0 : Generic NCR5380/53C400 Driver
Vendor: UMAX Model: Astra 1200S
Rev: V2.9 Type: Scanner ANSI SCSI revision: 02
Attached scsi generic sg0 at scsi0, channel 0, id 5, lun 0, type 6
I can't reload the module g_NCR5380 after an rmmod:
nihil:~# modprobe -v g_NCR5380 insmod /lib/modules/2.6.0/kernel/drivers/scsi/g_NCR5380.ko ncr_irq=255 ncr_addr=0x280 dtc_3181e=1 FATAL: Error inserting g_NCR5380 (/lib/modules/2.6.0/kernel/drivers/scsi/g_NCR53 80.ko): No such device
After a reboot everything is just fine again.
I use a vanilla 2.6.0 kernel. Please let me know if you need any further information.
-Kevin
Signature · 3 lines
Think how much fear is going to be required to stop people from passing along copies of things on their computers. I hope you don't want to live in a world with that much fear. - Richard M. Stallman
On Mon, 5 Jan 2004 23:42:20 +0100 Kevin Tappe <[email protected]> wrote:
| Hi, | | i hope this is the right emailadress for my problem... | | The first time I load the module g_NCR5380 everything works fine: | scsi0 : interrupts not enabled. for better interactive performance, | scsi0 : please jumper the board for a free IRQ. | scsi0 : at port 0x280 interrupts disabled options CAN_QUEUE=16 | CMD_PER_LUN=2 release=1 generic options | AUTOPROBE_IRQ AUTOSENSE USLEEP, USLEEP_POLL=1 USLEEP_SLEEP=20 | generic release=7 | scsi0 : Generic NCR5380/53C400 Driver | Vendor: UMAX Model: Astra 1200S | Rev: V2.9 Type: Scanner ANSI SCSI revision: 02 | Attached scsi generic sg0 at scsi0, channel 0, id 5, lun 0, type 6 | | I can't reload the module g_NCR5380 after an rmmod: | | nihil:~# modprobe -v g_NCR5380 | insmod /lib/modules/2.6.0/kernel/drivers/scsi/g_NCR5380.ko ncr_irq=255 | ncr_addr=0x280 dtc_3181e=1 | FATAL: Error inserting g_NCR5380 | (/lib/modules/2.6.0/kernel/drivers/scsi/g_NCR53 | 80.ko): No such device | | After a reboot everything is just fine again. | I use a vanilla 2.6.0 kernel. Please let me know if you need any further | information.
Hi,
Can you show that 'modprobe -v g_NCR5380' output for the first time that the driver is loaded also?
What's in /proc/scsi/g_NCR5380 while the driver is loaded the first time? and in /proc/ioports and /proc/iomem?
Also, the latter 2 files after the driver is removed.
and in /proc/scsi after the driver is removed.
--
~Randy
MOTD: Always include version info.
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 g_NCR5380 - 2.6.0 - problem with reloading module
On Sat, 10 Jan 2004 20:38:15 +0100 Kevin Tappe <[email protected]> wrote:
| Hi, | | On Fri, Jan 09, 2004 at 11:26:56AM -0800, Randy.Dunlap wrote: | > Can you show that 'modprobe -v g_NCR5380' output for the first time | > that the driver is loaded also? | | nihil:~# modprobe -v g_NCR5380 | insmod /lib/modules/2.6.0/kernel/drivers/scsi/g_NCR5380.ko ncr_irq=255 | ncr_addr=0x280 dtc_3181e=1
no output from the driver??
That's OK though, I found the problem.
| > What's in /proc/scsi/g_NCR5380 while the driver is loaded the first time? | > and in /proc/ioports and /proc/iomem? | | nihil:~# cat /proc/scsi/g_NCR5380/0 | SCSI host number 0 : Generic NCR5380/NCR53C400 Scsi Driver | Generic NCR5380 driver version 1 | NCR5380 core version 7 | NO NCR53C400 driver extensions | Using port mapping at port 0x280, no interrupt | REQ not asserted, phase unknown. | No currently connected command | issue_queue | disconnected_queue | | nihil:~# cat /proc/ioports ... | 0213-0213 : ISAPnP | 0220-022f : SoundBlaster | 0260-0261 : pnp 00:11 | 0280-028f : ncr53c80 | 02f8-02ff : serial ... | 0a79-0a79 : isapnp write ... | f800-f81f : pnp 00:12 | f820-f83f : pnp 00:12 | fc00-fc0f : pnp 00:12 | | nihil:~# cat /proc/iomem ... | | > Also, the latter 2 files after the driver is removed. | > and in /proc/scsi after the driver is removed. | | nihil:~# cat /proc/ioports | Segmentation fault
Yes, I see that one also.
The problem is that the detect function requests an IO region of 16 bytes (at least when a command line override parameter is used) but the release function only tries to release 8 bytes, and this request isn't done because it doesn't match any allocated IO region. [NCR53C400 extensions are not enabled, so NCR5380_region_size is 8, not 16, but the request uses NCR5380_region_size regardless.]
If enough kernel messages are enabled (like 'echo 9 > /proc/sysrq-trigger'), you should have seen this message when the driver module was unloaded:
Trying to free nonexistent resource <280-287>
because 280-28f was allocated.
Options to fix this:
1/ if the release_region() in the release function fails, have it try
a second time with a different region size; (easy, sorta sloppy);
2/ save the allocated region size in instance->n_io_ports and release
that size only; <<<<< PATCH ATTACHED <<<<<
3/ if an override was used, release a region size of 16 in the
release function; (this only looks clean for one adapter, not multiple)
Kevin, please test and report the results. I think that the module will be reloadable now.
Patch comments? If no problems, James, please apply.
| nihil:~# cat /proc/iomem
...
| | The files in /proc/scsi are attached. Hope that helps... | -Kevin | --
--
~Randy
description: release region of allocated (requested) size product_versions: Linux 2.6.1
diffstat:=
drivers/scsi/g_NCR5380.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
drivers/scsi/g_NCR5380.c renamed from drivers/scsi/g_NCR5380.c~fakehw +7 -2
@@ -290,6 +290,7 @@ int __init generic_NCR5380_detect(Scsi_Hstatic int current_override =0 ;int count, i;unsigned int *ports; +unsigned long region_size =16 ;static unsigned int __initdata ncr_53c400a_ports[] = {0x280 ,0x290 ,0x300 ,0x310 ,0x330 ,0x340 ,0x348 ,0x350 ,0 };
@@ -420,6 +421,7 @@ int __init generic_NCR5380_detect(Scsi_H/* Not a 53C400A style setup - just grab */ if (!(request_region (overrides[current_override].NCR5380_map_name, NCR5380_region_size,"ncr5380" )))continue ; + region_size = NCR5380_region_size; }#else if (!request_mem_region (overrides[current_override].NCR5380_map_name, NCR5380_region_size,"ncr5380" ))
@@ -428,7 +430,7 @@ int __init generic_NCR5380_detect(Scsi_H instance =scsi_register (tpnt,sizeof (struct NCR5380_hostdata ));if (instance ==NULL ) {#ifndef CONFIG_SCSI_G_NCR5380_MEM -release_region (overrides[current_override].NCR5380_map_name, NCR5380_region_size); +release_region (overrides[current_override].NCR5380_map_name, region_size);#else release_mem_region (overrides[current_override].NCR5380_map_name, NCR5380_region_size);#endif
@@ -436,6 +438,9 @@ int __init generic_NCR5380_detect(Scsi_H } instance->NCR5380_instance_name = overrides[current_override].NCR5380_map_name; +#ifndef CONFIG_SCSI_G_NCR5380_MEM + instance->n_io_port = region_size; +#endif NCR5380_init (instance, flags);
@@ -498,7 +503,7 @@ int generic_NCR5380_release_resources(stNCR5380_setup (instance);#ifndef CONFIG_SCSI_G_NCR5380_MEM -release_region (instance->NCR5380_instance_name, NCR5380_region_size); +release_region (instance->NCR5380_instance_name, instance->n_io_port);#else release_mem_region (instance->NCR5380_instance_name, NCR5380_region_size);#endif