From: James Bottomley <James.Bottomley@SteelEye.com>

This is a necessary precursor patch for getting the Intel Alder motherboard
working (it has a PCI device corresponding to the IO-APIC which has to be
forcibly inserted into the machine's reserved memory region).

Eric Biederman was going to come up with a more comprehensive fix, but in
the meantime, this is the minimum necessary to get insert_resource to work
when the covering region is larger than the resource being inserted.



---

 25-akpm/kernel/resource.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff -puN kernel/resource.c~alder-insert_resource-fix kernel/resource.c
--- 25/kernel/resource.c~alder-insert_resource-fix	Fri Feb 20 16:13:51 2004
+++ 25-akpm/kernel/resource.c	Fri Feb 20 16:13:51 2004
@@ -306,11 +306,12 @@ EXPORT_SYMBOL(allocate_resource);
  *
  * Returns 0 on success, -EBUSY if the resource can't be inserted.
  *
- * This function is equivalent of request_resource when no
- * conflict happens. If a conflict happens, and the conflicting
- * resources entirely fit within the range of the new resource,
- * then the new resource is inserted and the conflicting resources
- * become childs of the new resource. 
+ * This function is equivalent of request_resource when no conflict
+ * happens. If a conflict happens, and the conflicting resources
+ * entirely fit within the range of the new resource, then the new
+ * resource is inserted and the conflicting resources become childs of
+ * the new resource.  Otherwise the new resource becomes the child of
+ * the conflicting resource
  */
 int insert_resource(struct resource *parent, struct resource *new)
 {
@@ -318,6 +319,7 @@ int insert_resource(struct resource *par
 	struct resource *first, *next;
 
 	write_lock(&resource_lock);
+ begin:
 	first = __request_resource(parent, new);
 	if (!first)
 		goto out;
@@ -331,8 +333,10 @@ int insert_resource(struct resource *par
 			break;
 
 	/* existing resource overlaps end of new resource */
-	if (next->end > new->end)
-		goto out;
+	if (next->end > new->end) {
+		parent = next;
+		goto begin;
+	}
 
 	result = 0;
 

_