* [PATCH] g_NCR5380 - 2.6.0 - problem with reloading module
[not found] ` <20040110193814.GA371@nihil.tappe.netz>
@ 2004-01-11 23:30 ` Randy.Dunlap
0 siblings, 0 replies; 3+ messages in thread
From: Randy.Dunlap @ 2004-01-11 23:30 UTC (permalink / raw)
To: Kevin Tappe; +Cc: linux-scsi, jejb
[-- Attachment #1: Type: text/plain, Size: 2732 bytes --]
On Sat, 10 Jan 2004 20:38:15 +0100 Kevin Tappe <kevin@zerodivide.de> 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
[-- Attachment #2: gNCR_regions.patch --]
[-- Type: application/octet-stream, Size: 2183 bytes --]
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(-)
diff -Naurp ./drivers/scsi/g_NCR5380.c~fakehw ./drivers/scsi/g_NCR5380.c
--- ./drivers/scsi/g_NCR5380.c~fakehw 2004-01-08 22:59:10.000000000 -0800
+++ ./drivers/scsi/g_NCR5380.c 2004-01-11 15:21:00.000000000 -0800
@@ -290,6 +290,7 @@ int __init generic_NCR5380_detect(Scsi_H
static 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(st
NCR5380_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
^ permalink raw reply [flat|nested] 3+ messages in thread