Subject: PNP: Increase the value of PNP constant
From: Zhao Yakui <[email protected]>
On some systems the number of resources(IO,MEM) returnedy by PNP
device is greater than the PNP constant, for example motherboard devices.
It brings that some resources can't be reserved and resource confilicts.
This will cause PCI resources are assigned wrongly in some systems, and
cause hang. This is a regression since we deleted ACPI motherboard
driver and use PNP system driver.
Andrew, I thought this is an urgent issue and should be fixed ASAP, and
this is a good candidate for -stable tree
Signed-off-by: Li Shaohua <[email protected]>
Signed-off-by: Zhao Yakui <[email protected]>
---
drivers/pnp/pnpacpi/rsparser.c | 18 ++++++++++++++++--
include/linux/pnp.h | 4 ++--
2 files changed, 18 insertions(+), 4 deletions(-)
Index: linux-2.6.24-rc2/include/linux/pnp.h
===================================================================
--- linux-2.6.24-rc2.orig/include/linux/pnp.h
+++ linux-2.6.24-rc2/include/linux/pnp.h
@@ -13,8 +13,8 @@
#include <linux/errno.h>
#include <linux/mod_devicetable.h>
-#define PNP_MAX_PORT 8
-#define PNP_MAX_MEM 4
+#define PNP_MAX_PORT 24
+#define PNP_MAX_MEM 12
#define PNP_MAX_IRQ 2
#define PNP_MAX_DMA 2
#define PNP_NAME_LEN 50
Index: linux-2.6.24-rc2/drivers/pnp/pnpacpi/rsparser.c
===================================================================
--- linux-2.6.24-rc2.orig/drivers/pnp/pnpacpi/rsparser.c
+++ linux-2.6.24-rc2/drivers/pnp/pnpacpi/rsparser.c
@@ -82,9 +82,11 @@ static void pnpacpi_parse_allocated_irqr
while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) &&
i < PNP_MAX_IRQ)
i++;
- if (i >= PNP_MAX_IRQ)
+ if (i >= PNP_MAX_IRQ) {
+ printk(KERN_ERR "Exceed the max number of IRQ resource: "
+ "%d \n",PNP_MAX_IRQ);
return;
-
+ }
#ifdef CONFIG_X86
if (gsi < 16 && (triggering != ACPI_EDGE_SENSITIVE ||
polarity != ACPI_ACTIVE_HIGH)) {
@@ -173,6 +175,10 @@ static void pnpacpi_parse_allocated_dmar
}
res->dma_resource[i].start = dma;
res->dma_resource[i].end = dma;
+ } else {
+ printk(KERN_ERR "Exceed the max number of DMA resource: "
+ "%d \n",PNP_MAX_DMA);
+ return;
}
}
@@ -194,6 +200,10 @@ static void pnpacpi_parse_allocated_iore
}
res->port_resource[i].start = io;
res->port_resource[i].end = io + len - 1;
+ } else {
+ printk(KERN_ERR "Exceed the max number of IO Resource: "
+ "%d \n",PNP_MAX_PORT);
+ return;
}
}
@@ -217,6 +227,10 @@ static void pnpacpi_parse_allocated_memr
res->mem_resource[i].start = mem;
res->mem_resource[i].end = mem + len - 1;
+ } else {
+ printk(KERN_ERR "Exceed the max number of Mem Resource: "
+ "%d \n",PNP_MAX_MEM);
+ return;
}
}
On 16-11-07 08:39, Zhao Yakui wrote:
> Subject: PNP: Increase the value of PNP constant
> From: Zhao Yakui <[email protected]>
>
> On some systems the number of resources(IO,MEM) returnedy by PNP
> device is greater than the PNP constant, for example motherboard devices.
> It brings that some resources can't be reserved and resource confilicts.
> This will cause PCI resources are assigned wrongly in some systems, and
> cause hang. This is a regression since we deleted ACPI motherboard
> driver and use PNP system driver.
>
> Andrew, I thought this is an urgent issue and should be fixed ASAP, and
> this is a good candidate for -stable tree
>
> Signed-off-by: Li Shaohua <[email protected]>
> Signed-off-by: Zhao Yakui <[email protected]>
>
> ---
> drivers/pnp/pnpacpi/rsparser.c | 18 ++++++++++++++++--
> include/linux/pnp.h | 4 ++--
> 2 files changed, 18 insertions(+), 4 deletions(-)
>
> Index: linux-2.6.24-rc2/include/linux/pnp.h
> ===================================================================
> --- linux-2.6.24-rc2.orig/include/linux/pnp.h
> +++ linux-2.6.24-rc2/include/linux/pnp.h
> @@ -13,8 +13,8 @@
> #include <linux/errno.h>
> #include <linux/mod_devicetable.h>
>
> -#define PNP_MAX_PORT 8
> -#define PNP_MAX_MEM 4
> +#define PNP_MAX_PORT 24
> +#define PNP_MAX_MEM 12
This fairly significantly grows (for example?) a struct pnp_resource_table.
Are 24 and 12 really sensible?
Rene.
On Friday 16 November 2007 09:52:48 am Rene Herman wrote:
> On 16-11-07 08:39, Zhao Yakui wrote:
>
> > Subject: PNP: Increase the value of PNP constant
> > From: Zhao Yakui <[email protected]>
> >
> > On some systems the number of resources(IO,MEM) returnedy by PNP
> > device is greater than the PNP constant, for example motherboard devices.
> > It brings that some resources can't be reserved and resource confilicts.
> > This will cause PCI resources are assigned wrongly in some systems, and
> > cause hang. This is a regression since we deleted ACPI motherboard
> > driver and use PNP system driver.
> >
> > Andrew, I thought this is an urgent issue and should be fixed ASAP, and
> > this is a good candidate for -stable tree
Thomas Renninger is working on PNP patches so we can accomodate any
number of resources. We had talked about an interim solution like
the one Shaohua is proposing, but thought the space overhead was
objectionable:
I (Bjorn) wrote:
> ... We're going from 16 resource structs
> per PNP device to 42. Each struct resource looks like about 7
> longs or pointers, so on a 32-bit system with 16 PNP devices, we
> are going from about 7K to almost 19K just for these tables, most
> of which are mostly empty. On a 64-bit system, it goes from about
> 14K to over 37K.
However, we did not realize that switching from the ACPI motherboard
driver to the PNP driver would cause a regression. Since that's the
case, I don't think we have much choice -- I think we have to either
increase the table sizes until we can handle things dynamically, or
switch back to the ACPI motherboard driver until we have Thomas's
work. For a -stable patch, I think enlarging the tables is safer.
The space analysis above was based on increasing PNP_MAX_PORT from
8 to 32 and PNP_MAX_IRQ from 2 to 4 (total increase of 26 resources
per device). Shaohua's patch adds 16 port and 8 mem resources for
an increase of 24, so will use slightly less space.
Acked-by: Bjorn Helgaas <[email protected]>
> > Signed-off-by: Li Shaohua <[email protected]>
> > Signed-off-by: Zhao Yakui <[email protected]>
> >
> > ---
> > drivers/pnp/pnpacpi/rsparser.c | 18 ++++++++++++++++--
> > include/linux/pnp.h | 4 ++--
> > 2 files changed, 18 insertions(+), 4 deletions(-)
> >
> > Index: linux-2.6.24-rc2/include/linux/pnp.h
> > ===================================================================
> > --- linux-2.6.24-rc2.orig/include/linux/pnp.h
> > +++ linux-2.6.24-rc2/include/linux/pnp.h
> > @@ -13,8 +13,8 @@
> > #include <linux/errno.h>
> > #include <linux/mod_devicetable.h>
> >
> > -#define PNP_MAX_PORT 8
> > -#define PNP_MAX_MEM 4
> > +#define PNP_MAX_PORT 24
> > +#define PNP_MAX_MEM 12
>
> This fairly significantly grows (for example?) a struct pnp_resource_table.
> Are 24 and 12 really sensible?
>
> Rene.