linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Prarit Bhargava <prarit@sgi.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: Latest bk kernel does not properly free PCI IO & MEM allocations
Date: Thu, 10 Mar 2005 15:07:12 +0000	[thread overview]
Message-ID: <423062A0.4070509@sgi.com> (raw)
In-Reply-To: <422F42A9.7050009@sgi.com>

[-- Attachment #1: Type: text/plain, Size: 2698 bytes --]

The following patch reproduces the oops 100% of the time by doing the 
following.

Boot machine.
Load Hotplug driver (if not already loaded)
Disable Slot that has MEM and IO allocations
cat /proc/iomem <--- leads to oops.

P.

Prarit Bhargava wrote:

>
>
> Hello all,
>
> I noticed this in testing of a hotplug driver I've written for SGI 
> Altix hardware.
>
> If you cat /proc/iomem and check lspci after removing a device via 
> hotplug:
>
> [root@cranberry3 linux-2.6.9-hotplug]# lspci
> 01:01.0 Co-processor: Silicon Graphics, Inc. IOC4 I/O controller (rev 4f)
> 01:03.0 SCSI storage controller: QLogic Corp. ISP12160 Dual Channel 
> Ultra3 SCSI Processor (rev 06)
> 01:04.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5701 
> Gigabit Ethernet (rev 15)
> 03:02.0 ATM network controller: FORE Systems Inc ForeRunnerHE ATM Adapter
> 04:01.0 SCSI storage controller: QLogic Corp. QLA2200 64-bit Fibre 
> Channel Adapter (rev 05)
> [root@cranberry3 linux-2.6.9-hotplug]# cat /proc/iomem 
> c00004080c200000-c00004080c2fffff : 0000:01:01.0
> c00004080f400000-c00004080f4fffff : 0000:03:02.0
> c00004080fe00000-c00004080fe00fff : 0000:04:01.0
> c00004080fe01000-c00004080fe01fff : 0000:04:02.0
>  00220000-0023ffff : 0000:04:01.0
>
> There are still allocations listed for device 04:02.0 even though it 
> has been
> removed from the system.
>
> I tracked down the issue to the following:
>
> When pci_remove_bus_device is called on the device in the slot (should 
> be a safe thing to do) both the pci_driver remove function for a 
> device and the function pci_free_resources are called.
>
> In the case of the QLA2x00 driver, the driver's remove function calls
> pci_release_regions.  This function releases the IO & MEM allocs for 
> the pci
> device and kfree's them.
>
> As previously mentioned, pci_free_resources is called.  This function 
> attempts to use and free IO & MEM allocs for the pci device.
>
> This may (about 5% of the time) causes an oops, ie) this is a critical 
> issue for anyone
> using hotplug.
>
> This raises the following question -- should a driver be cleaning up 
> resources or should
> PCI?
>
> P.
>
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
> Linux-hotplug-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
>

[-- Attachment #2: repro.patch --]
[-- Type: text/x-patch, Size: 628 bytes --]

--- kernel/resource.c.orig	2005-03-10 14:57:58.317008676 -0500
+++ kernel/resource.c	2005-03-10 14:58:02.310172689 -0500
@@ -495,20 +495,21 @@
 			break;
 		if (res->start <= start && res->end >= end) {
 			if (!(res->flags & IORESOURCE_BUSY)) {
 				p = &res->child;
 				continue;
 			}
 			if (res->start != start || res->end != end)
 				break;
 			*p = res->sibling;
 			write_unlock(&resource_lock);
+			memset(res, 0, sizeof(*res));
 			kfree(res);
 			return;
 		}
 		p = &res->sibling;
 	}
 
 	write_unlock(&resource_lock);
 
 	printk(KERN_WARNING "Trying to free nonexistent resource <%08lx-%08lx>\n", start, end);
 }

  reply	other threads:[~2005-03-10 15:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-09 18:38 Latest bk kernel does not properly free PCI IO & MEM allocations Prarit Bhargava
2005-03-10 15:07 ` Prarit Bhargava [this message]
2005-03-10 17:17 ` Greg KH
2005-03-10 18:16 ` Prarit Bhargava
2005-03-10 18:50 ` Prarit Bhargava
2005-03-10 23:23 ` Greg KH
2005-03-11 21:30 ` Prarit Bhargava
2005-03-12  7:38 ` Greg KH
2005-03-12 17:04 ` prarit
2005-03-13  0:49 ` Re: Latest bk kernel does not properly free PCI IO & MEM prarit
2005-03-15  6:11 ` Re: Latest bk kernel does not properly free PCI IO & MEM allocations Rajesh Shah
2005-03-15 12:55 ` Prarit Bhargava

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=423062A0.4070509@sgi.com \
    --to=prarit@sgi.com \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).