Patchwork The resource allocator does not like zero-sized fixed resources

login
register
about
Submitter Myles Watson
Date 2009-08-19 17:59:20
Message ID <2831fecf0908191059j54c62badpb05f5f342bd615e4@mail.gmail.com>
Download mbox | patch
Permalink /patch/145/
State Accepted
Headers show

Comments

Myles Watson - 2009-08-19 17:59:20
On Wed, Aug 19, 2009 at 11:32 AM, Patrick Georgi<patrick@georgi-clan.de> wrote:
> Am 19.08.2009 19:08, schrieb Myles Watson:
>>
>> The example you gave in src/devices/pci_device.c was for the old way of
>> specifying PCI ROM locations.  Now that CBFS is going mainstream, that
>> should disappear.  If it doesn't, I think it should have a size.  Even 1
>> would work, since no Option ROM can be smaller than that.
>>
>
> I'd love to get rid of the rom_address thing once we drop the pre-cbfs way
> of doing things (which will take quite some time, still), but I'm not sure
> if there isn't some need for it left.
OK.

>> What other fixed resources have 0 size, especially on Kontron?  I'd like
>> to
>> fix the root cause.
>>
>
> That's the only one on Kontron. I just wanted to have proper behaviour even
> with such weird entries.
Let's add something like this patch.  I'm happy to have the wording
changed, but I think it's important that we don't silently fail to
avoid fixed resources.

Signed-off-by: Myles Watson <mylesgw@gmail.com>
Thanks,
Myles
Patrick Georgi - 2009-08-19 19:05:36
Am 19.08.2009 19:59, schrieb Myles Watson:
> Let's add something like this patch.  I'm happy to have the wording
> changed, but I think it's important that we don't silently fail to
> avoid fixed resources.
>    
I'm fine with the wording
> Signed-off-by: Myles Watson<mylesgw@gmail.com>
>    
Acked-by: Patrick Georgi <patrick.georgi@coresystems.de>
Myles Watson - 2009-08-19 19:13:15
On Wed, Aug 19, 2009 at 1:05 PM, Patrick Georgi<patrick@georgi-clan.de> wrote:
> Am 19.08.2009 19:59, schrieb Myles Watson:
>>
>> Let's add something like this patch.  I'm happy to have the wording
>> changed, but I think it's important that we don't silently fail to
>> avoid fixed resources.
>>
>
> I'm fine with the wording
>>
>> Signed-off-by: Myles Watson<mylesgw@gmail.com>
>>
>
> Acked-by: Patrick Georgi <patrick.georgi@coresystems.de>
Rev 4557.

Thanks,
Myles

Patch

Index: svn/src/devices/device.c
===================================================================
--- svn.orig/src/devices/device.c
+++ svn/src/devices/device.c
@@ -556,8 +556,12 @@  static void constrain_resources(struct d
 	/* Constrain limits based on the fixed resources of this device. */
 	for (i = 0; i < dev->resources; i++) {
 		res = &dev->resource[i];
-		if (!res->size)
+		if (!res->size) {
+			/* It makes no sense to have 0-sized, fixed resources.*/
+			printk_err("skipping %s@%lx fixed resource, size=0!\n",
+				   dev_path(dev), res->index);
 			continue;
+		}
 		if (!(res->flags & IORESOURCE_FIXED))
 			continue;
 
Index: svn/src/devices/pci_device.c
===================================================================
--- svn.orig/src/devices/pci_device.c
+++ svn/src/devices/pci_device.c
@@ -332,6 +332,8 @@  static void pci_get_rom_resource(struct 
 	 * inited by driver_pci_onboard_ops::enable_dev() */
 	if ((dev->on_mainboard) && (dev->rom_address != 0)) {
 		resource->base = dev->rom_address;
+		/* The resource allocator needs the size to be non-zero. */
+		resource->size = 0x100;
 		resource->flags |= IORESOURCE_MEM | IORESOURCE_READONLY |
 		    IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
 	}