From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Randy.Dunlap" Subject: [PATCH] g_NCR5380 - 2.6.0 - problem with reloading module Date: Sun, 11 Jan 2004 15:30:51 -0800 Sender: linux-scsi-owner@vger.kernel.org Message-ID: <20040111153051.03d56e7e.rddunlap@osdl.org> References: <20040105224220.GA1168@nihil.tappe.netz> <20040109112656.25313810.rddunlap@osdl.org> <20040110193814.GA371@nihil.tappe.netz> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart_Sun__11_Jan_2004_15:30:51_-0800_085c0528" Return-path: Received: from fw.osdl.org ([65.172.181.6]:6868 "EHLO mail.osdl.org") by vger.kernel.org with ESMTP id S266023AbUAKXcn (ORCPT ); Sun, 11 Jan 2004 18:32:43 -0500 In-Reply-To: <20040110193814.GA371@nihil.tappe.netz> List-Id: linux-scsi@vger.kernel.org To: Kevin Tappe Cc: linux-scsi@vger.kernel.org, jejb This is a multi-part message in MIME format. --Multipart_Sun__11_Jan_2004_15:30:51_-0800_085c0528 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 10 Jan 2004 20:38:15 +0100 Kevin Tappe 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 --Multipart_Sun__11_Jan_2004_15:30:51_-0800_085c0528 Content-Type: application/octet-stream; name="gNCR_regions.patch" Content-Disposition: attachment; filename="gNCR_regions.patch" Content-Transfer-Encoding: base64 ZGVzY3JpcHRpb246ICAgICAgcmVsZWFzZSByZWdpb24gb2YgYWxsb2NhdGVkIChyZXF1ZXN0ZWQp IHNpemUKcHJvZHVjdF92ZXJzaW9uczogTGludXggMi42LjEKCmRpZmZzdGF0Oj0KIGRyaXZlcnMv c2NzaS9nX05DUjUzODAuYyB8ICAgIDkgKysrKysrKy0tCiAgMSBmaWxlcyBjaGFuZ2VkLCA3IGlu c2VydGlvbnMoKyksIDIg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