diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2008-06-27 18:56:57 -0400 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2008-07-16 17:27:05 -0400 |
commit | aee3ad815dd291a7193ab01da0f1a30c84d00061 (patch) | |
tree | b0549b2a98ddfe6734e1e5f7cedd3958eec18503 /drivers/pnp/isapnp | |
parent | 20bfdbba7212d19613b93dcea93f26cb65af91fe (diff) |
PNP: replace pnp_resource_table with dynamically allocated resources
PNP used to have a fixed-size pnp_resource_table for tracking the
resources used by a device. This table often overflowed, so we've
had to increase the table size, which wastes memory because most
devices have very few resources.
This patch replaces the table with a linked list of resources where
the entries are allocated on demand.
This removes messages like these:
pnpacpi: exceeded the max number of IO resources
00:01: too many I/O port resources
References:
http://bugzilla.kernel.org/show_bug.cgi?id=9535
http://bugzilla.kernel.org/show_bug.cgi?id=9740
http://lkml.org/lkml/2007/11/30/110
This patch also changes the way PNP uses the IORESOURCE_UNSET,
IORESOURCE_AUTO, and IORESOURCE_DISABLED flags.
Prior to this patch, the pnp_resource_table entries used the flags
like this:
IORESOURCE_UNSET
This table entry is unused and available for use. When this flag
is set, we shouldn't look at anything else in the resource structure.
This flag is set when a resource table entry is initialized.
IORESOURCE_AUTO
This resource was assigned automatically by pnp_assign_{io,mem,etc}().
This flag is set when a resource table entry is initialized and
cleared whenever we discover a resource setting by reading an ISAPNP
config register, parsing a PNPBIOS resource data stream, parsing an
ACPI _CRS list, or interpreting a sysfs "set" command.
Resources marked IORESOURCE_AUTO are reinitialized and marked as
IORESOURCE_UNSET by pnp_clean_resource_table() in these cases:
- before we attempt to assign resources automatically,
- if we fail to assign resources automatically,
- after disabling a device
IORESOURCE_DISABLED
Set by pnp_assign_{io,mem,etc}() when automatic assignment fails.
Also set by PNPBIOS and PNPACPI for:
- invalid IRQs or GSI registration failures
- invalid DMA channels
- I/O ports above 0x10000
- mem ranges with negative length
After this patch, there is no pnp_resource_table, and the resource list
entries use the flags like this:
IORESOURCE_UNSET
This flag is no longer used in PNP. Instead of keeping
IORESOURCE_UNSET entries in the resource list, we remove
entries from the list and free them.
IORESOURCE_AUTO
No change in meaning: it still means the resource was assigned
automatically by pnp_assign_{port,mem,etc}(), but these functions
now set the bit explicitly.
We still "clean" a device's resource list in the same places,
but rather than reinitializing IORESOURCE_AUTO entries, we
just remove them from the list.
Note that IORESOURCE_AUTO entries are always at the end of the
list, so removing them doesn't reorder other list entries.
This is because non-IORESOURCE_AUTO entries are added by the
ISAPNP, PNPBIOS, or PNPACPI "get resources" methods and by the
sysfs "set" command. In each of these cases, we completely free
the resource list first.
IORESOURCE_DISABLED
In addition to the cases where we used to set this flag, ISAPNP now
adds an IORESOURCE_DISABLED resource when it reads a configuration
register with a "disabled" value.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Diffstat (limited to 'drivers/pnp/isapnp')
-rw-r--r-- | drivers/pnp/isapnp/core.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 752b51fbaa6c..ca4457ec403b 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c | |||
@@ -973,8 +973,7 @@ static int isapnp_set_resources(struct pnp_dev *dev) | |||
973 | dev->active = 1; | 973 | dev->active = 1; |
974 | for (tmp = 0; tmp < ISAPNP_MAX_PORT; tmp++) { | 974 | for (tmp = 0; tmp < ISAPNP_MAX_PORT; tmp++) { |
975 | res = pnp_get_resource(dev, IORESOURCE_IO, tmp); | 975 | res = pnp_get_resource(dev, IORESOURCE_IO, tmp); |
976 | if (res && pnp_resource_valid(res) && | 976 | if (pnp_resource_enabled(res)) { |
977 | !(res->flags & IORESOURCE_DISABLED)) { | ||
978 | dev_dbg(&dev->dev, " set io %d to %#llx\n", | 977 | dev_dbg(&dev->dev, " set io %d to %#llx\n", |
979 | tmp, (unsigned long long) res->start); | 978 | tmp, (unsigned long long) res->start); |
980 | isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1), | 979 | isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1), |
@@ -983,8 +982,7 @@ static int isapnp_set_resources(struct pnp_dev *dev) | |||
983 | } | 982 | } |
984 | for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) { | 983 | for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) { |
985 | res = pnp_get_resource(dev, IORESOURCE_IRQ, tmp); | 984 | res = pnp_get_resource(dev, IORESOURCE_IRQ, tmp); |
986 | if (res && pnp_resource_valid(res) && | 985 | if (pnp_resource_enabled(res)) { |
987 | !(res->flags & IORESOURCE_DISABLED)) { | ||
988 | int irq = res->start; | 986 | int irq = res->start; |
989 | if (irq == 2) | 987 | if (irq == 2) |
990 | irq = 9; | 988 | irq = 9; |
@@ -994,8 +992,7 @@ static int isapnp_set_resources(struct pnp_dev *dev) | |||
994 | } | 992 | } |
995 | for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) { | 993 | for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) { |
996 | res = pnp_get_resource(dev, IORESOURCE_DMA, tmp); | 994 | res = pnp_get_resource(dev, IORESOURCE_DMA, tmp); |
997 | if (res && pnp_resource_valid(res) && | 995 | if (pnp_resource_enabled(res)) { |
998 | !(res->flags & IORESOURCE_DISABLED)) { | ||
999 | dev_dbg(&dev->dev, " set dma %d to %lld\n", | 996 | dev_dbg(&dev->dev, " set dma %d to %lld\n", |
1000 | tmp, (unsigned long long) res->start); | 997 | tmp, (unsigned long long) res->start); |
1001 | isapnp_write_byte(ISAPNP_CFG_DMA + tmp, res->start); | 998 | isapnp_write_byte(ISAPNP_CFG_DMA + tmp, res->start); |
@@ -1003,8 +1000,7 @@ static int isapnp_set_resources(struct pnp_dev *dev) | |||
1003 | } | 1000 | } |
1004 | for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) { | 1001 | for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) { |
1005 | res = pnp_get_resource(dev, IORESOURCE_MEM, tmp); | 1002 | res = pnp_get_resource(dev, IORESOURCE_MEM, tmp); |
1006 | if (res && pnp_resource_valid(res) && | 1003 | if (pnp_resource_enabled(res)) { |
1007 | !(res->flags & IORESOURCE_DISABLED)) { | ||
1008 | dev_dbg(&dev->dev, " set mem %d to %#llx\n", | 1004 | dev_dbg(&dev->dev, " set mem %d to %#llx\n", |
1009 | tmp, (unsigned long long) res->start); | 1005 | tmp, (unsigned long long) res->start); |
1010 | isapnp_write_word(ISAPNP_CFG_MEM + (tmp << 3), | 1006 | isapnp_write_word(ISAPNP_CFG_MEM + (tmp << 3), |