From 1f3a6a15771ed70d3b2581663dcc6b9bc134baa5 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Thu, 28 Jul 2005 14:42:00 -0400 Subject: [ACPI] acpi_register_gsi() can return error Current acpi_register_gsi() function has no way to indicate errors to its callers even though acpi_register_gsi() can fail to register gsi because of some reasons (out of memory, lack of interrupt vectors, incorrect BIOS, and so on). As a result, caller of acpi_register_gsi() cannot handle the case that acpi_register_gsi() fails. I think failure of acpi_register_gsi() should be handled properly. This series of patches changes acpi_register_gsi() to return negative value on error, and also changes callers of acpi_register_gsi() to handle failure of acpi_register_gsi(). This patch changes the type of return value of acpi_register_gsi() from "unsigned int" to "int" to indicate an error. If acpi_register_gsi() fails to register gsi, it returns negative value. Signed-off-by: Kenji Kaneshige Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- arch/i386/kernel/acpi/boot.c | 6 +++++- arch/ia64/kernel/acpi.c | 6 +++++- include/linux/acpi.h | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c index 848bb97af7c..364f4b7c4e3 100644 --- a/arch/i386/kernel/acpi/boot.c +++ b/arch/i386/kernel/acpi/boot.c @@ -457,7 +457,11 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) return 0; } -unsigned int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low) +/* + * success: return IRQ number (>=0) + * failure: return < 0 + */ +int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low) { unsigned int irq; unsigned int plat_gsi = gsi; diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c index 1c118b72df3..7513ff9361a 100644 --- a/arch/ia64/kernel/acpi.c +++ b/arch/ia64/kernel/acpi.c @@ -565,7 +565,11 @@ acpi_numa_arch_fixup (void) } #endif /* CONFIG_ACPI_NUMA */ -unsigned int +/* + * success: return IRQ number (>=0) + * failure: return < 0 + */ +int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low) { if (has_8259 && gsi < 16) diff --git a/include/linux/acpi.h b/include/linux/acpi.h index ca0cd240cee..9378bcde73a 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -432,7 +432,7 @@ static inline int acpi_boot_table_init(void) #endif /*!CONFIG_ACPI_BOOT*/ -unsigned int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low); +int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low); int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); /* -- cgit v1.2.3 From 349f0d5640c18db09a646f9da51a97f1da908660 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Thu, 28 Jul 2005 14:42:00 -0400 Subject: [ACPI] acpi_pci_enable_irq() now checks for acpi_register_gsi() errors Signed-off-by: Kenji Kaneshige Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/acpi/pci_irq.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index c536ccfc541..7ed4b2ef265 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c @@ -424,6 +424,7 @@ acpi_pci_irq_enable ( int edge_level = ACPI_LEVEL_SENSITIVE; int active_high_low = ACPI_ACTIVE_LOW; char *link = NULL; + int rc; ACPI_FUNCTION_TRACE("acpi_pci_irq_enable"); @@ -475,7 +476,13 @@ acpi_pci_irq_enable ( } } - dev->irq = acpi_register_gsi(irq, edge_level, active_high_low); + rc = acpi_register_gsi(irq, edge_level, active_high_low); + if (rc < 0) { + printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed " + "to register GSI\n", pci_name(dev), ('A' + pin)); + return_VALUE(rc); + } + dev->irq = rc; printk(KERN_INFO PREFIX "PCI Interrupt %s[%c] -> ", pci_name(dev), 'A' + pin); -- cgit v1.2.3 From a9bd53bc49ee8984633e57c1d9d45111c58e9457 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Thu, 28 Jul 2005 14:42:00 -0400 Subject: [ACPI] HPET driver now checks for acpi_register_gsi() errors Signed-off-by: Kenji Kaneshige Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/char/hpet.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index 5ec732e6ca9..a8d4c47f7ad 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c @@ -906,11 +906,15 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data) if (irqp->number_of_interrupts > 0) { hdp->hd_nirqs = irqp->number_of_interrupts; - for (i = 0; i < hdp->hd_nirqs; i++) - hdp->hd_irq[i] = + for (i = 0; i < hdp->hd_nirqs; i++) { + int rc = acpi_register_gsi(irqp->interrupts[i], irqp->edge_level, irqp->active_high_low); + if (rc < 0) + return AE_ERROR; + hdp->hd_irq[i] = rc; + } } } -- cgit v1.2.3 From 71df30f8e3e97fde573c41df063c2d66c1ad01b0 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Thu, 28 Jul 2005 14:42:00 -0400 Subject: [ACPI] PNPACPI driver now checks for acpi_register_gsi() errors Signed-off-by: Kenji Kaneshige Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/pnp/pnpacpi/rsparser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 75575f6c349..1e296cbef00 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -81,7 +81,7 @@ pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, int irq) i++; if (i < PNP_MAX_IRQ) { res->irq_resource[i].flags = IORESOURCE_IRQ; //Also clears _UNSET flag - if (irq == -1) { + if (irq < 0) { res->irq_resource[i].flags |= IORESOURCE_DISABLED; return; } -- cgit v1.2.3 From 58e0276245f6c60119f0384e7eca576b08aa89e2 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Thu, 28 Jul 2005 14:42:00 -0400 Subject: [ACPI] 8250 driver now checks for acpi_register_gsi() errors Signed-off-by: Kenji Kaneshige Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/serial/8250_acpi.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/serial/8250_acpi.c b/drivers/serial/8250_acpi.c index 6b9ead28851..a802bdce6e5 100644 --- a/drivers/serial/8250_acpi.c +++ b/drivers/serial/8250_acpi.c @@ -47,18 +47,30 @@ static acpi_status acpi_serial_port(struct uart_port *port, static acpi_status acpi_serial_ext_irq(struct uart_port *port, struct acpi_resource_ext_irq *ext_irq) { - if (ext_irq->number_of_interrupts > 0) - port->irq = acpi_register_gsi(ext_irq->interrupts[0], + int rc; + + if (ext_irq->number_of_interrupts > 0) { + rc = acpi_register_gsi(ext_irq->interrupts[0], ext_irq->edge_level, ext_irq->active_high_low); + if (rc < 0) + return AE_ERROR; + port->irq = rc; + } return AE_OK; } static acpi_status acpi_serial_irq(struct uart_port *port, struct acpi_resource_irq *irq) { - if (irq->number_of_interrupts > 0) - port->irq = acpi_register_gsi(irq->interrupts[0], + int rc; + + if (irq->number_of_interrupts > 0) { + rc = acpi_register_gsi(irq->interrupts[0], irq->edge_level, irq->active_high_low); + if (rc < 0) + return AE_ERROR; + port->irq = rc; + } return AE_OK; } -- cgit v1.2.3 From 14454a1b3ff8d1d15fbe7cc77f27373777184ddf Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Thu, 28 Jul 2005 14:42:00 -0400 Subject: [ACPI] iosapic_register_intr() now returns error instead of panic error condition is passed along by acpi_register_gsi(). Signed-off-by: Kenji Kaneshige Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- arch/ia64/kernel/iosapic.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c index 88b014381df..40afbfa47ec 100644 --- a/arch/ia64/kernel/iosapic.c +++ b/arch/ia64/kernel/iosapic.c @@ -562,7 +562,7 @@ static inline int vector_is_shared (int vector) return (iosapic_intr_info[vector].count > 1); } -static void +static int register_intr (unsigned int gsi, int vector, unsigned char delivery, unsigned long polarity, unsigned long trigger) { @@ -577,7 +577,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery, index = find_iosapic(gsi); if (index < 0) { printk(KERN_WARNING "%s: No IOSAPIC for GSI %u\n", __FUNCTION__, gsi); - return; + return -ENODEV; } iosapic_address = iosapic_lists[index].addr; @@ -588,7 +588,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery, rte = iosapic_alloc_rte(); if (!rte) { printk(KERN_WARNING "%s: cannot allocate memory\n", __FUNCTION__); - return; + return -ENOMEM; } rte_index = gsi - gsi_base; @@ -603,7 +603,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery, struct iosapic_intr_info *info = &iosapic_intr_info[vector]; if (info->trigger != trigger || info->polarity != polarity) { printk (KERN_WARNING "%s: cannot override the interrupt\n", __FUNCTION__); - return; + return -EINVAL; } } @@ -623,6 +623,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery, __FUNCTION__, vector, idesc->handler->typename, irq_type->typename); idesc->handler = irq_type; } + return 0; } static unsigned int @@ -710,7 +711,7 @@ int iosapic_register_intr (unsigned int gsi, unsigned long polarity, unsigned long trigger) { - int vector, mask = 1; + int vector, mask = 1, err; unsigned int dest; unsigned long flags; struct iosapic_rte_info *rte; @@ -735,8 +736,11 @@ again: /* If vector is running out, we try to find a sharable vector */ vector = assign_irq_vector_nopanic(AUTO_ASSIGN); - if (vector < 0) + if (vector < 0) { vector = iosapic_find_sharable_vector(trigger, polarity); + if (vector < 0) + Return -ENOSPC; + } spin_lock_irqsave(&irq_descp(vector)->lock, flags); spin_lock(&iosapic_lock); @@ -750,8 +754,13 @@ again: } dest = get_target_cpu(gsi, vector); - register_intr(gsi, vector, IOSAPIC_LOWEST_PRIORITY, + err = register_intr(gsi, vector, IOSAPIC_LOWEST_PRIORITY, polarity, trigger); + if (err < 0) { + spin_unlock(&iosapic_lock); + spin_unlock_irqrestore(&irq_descp(vector)->lock, flags); + return err; + } /* * If the vector is shared and already unmasked for -- cgit v1.2.3 From 53de49f52e305e96143375d1741f15acff7bf34b Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sat, 30 Jul 2005 04:18:00 -0400 Subject: [ACPI] CONFIG_ACPI=n build fix Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- include/linux/acpi.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 9378bcde73a..bf96ae9d93a 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -420,16 +420,6 @@ extern int sbf_port ; #define acpi_mp_config 0 -static inline int acpi_boot_init(void) -{ - return 0; -} - -static inline int acpi_boot_table_init(void) -{ - return 0; -} - #endif /*!CONFIG_ACPI_BOOT*/ int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low); @@ -536,5 +526,17 @@ static inline int acpi_get_pxm(acpi_handle handle) extern int pnpacpi_disabled; +#else /* CONFIG_ACPI */ + +static inline int acpi_boot_init(void) +{ + return 0; +} + +static inline int acpi_boot_table_init(void) +{ + return 0; +} + #endif /* CONFIG_ACPI */ #endif /*_LINUX_ACPI_H*/ -- cgit v1.2.3 From e92310a930462c6e1611f35453f57357c42bde14 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sat, 30 Jul 2005 04:18:00 -0400 Subject: [ACPI] fix IA64 build warning Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- include/asm-ia64/acpi-ext.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/asm-ia64/acpi-ext.h b/include/asm-ia64/acpi-ext.h index 9271d74c64c..56d2ddc97b3 100644 --- a/include/asm-ia64/acpi-ext.h +++ b/include/asm-ia64/acpi-ext.h @@ -11,6 +11,7 @@ #define _ASM_IA64_ACPI_EXT_H #include +#include extern acpi_status hp_acpi_csr_space (acpi_handle, u64 *base, u64 *length); -- cgit v1.2.3 From 031ec77bf67e4bda994ef8ceba267be3295ffdb7 Mon Sep 17 00:00:00 2001 From: Karol Kozimor Date: Sat, 30 Jul 2005 04:18:00 -0400 Subject: [ACPI] acpi_remove_notify_handler() on video driver unload The video driver doesn't properly remove all the notify handlers on module unload. This has a side effect of subdevices failing to register on module reload, but sudden death looms if the handlers trigger after the module is unloaded. Signed-off-by: Karol Kozimor Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/acpi/video.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 2cf264fd52e..7b10a7b070c 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -1665,6 +1665,7 @@ static int acpi_video_bus_put_one_device( struct acpi_video_device *device) { + acpi_status status; struct acpi_video_bus *video; ACPI_FUNCTION_TRACE("acpi_video_bus_put_one_device"); @@ -1679,6 +1680,12 @@ acpi_video_bus_put_one_device( up(&video->sem); acpi_video_device_remove_fs(device->dev); + status = acpi_remove_notify_handler(device->handle, + ACPI_DEVICE_NOTIFY, acpi_video_device_notify); + if (ACPI_FAILURE(status)) + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error removing notify handler\n")); + return_VALUE(0); } -- cgit v1.2.3 From 4fdcf0804598f44b0f48da9e5281af48a4db393f Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sat, 30 Jul 2005 04:18:00 -0400 Subject: [ACPI] lint: irqrouter_suspend() takes a pm_message_t, not a u32 Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/acpi/pci_link.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 0091dbdf7ef..a0df2f3606d 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -786,10 +786,7 @@ end: return_VALUE(result); } -static int -irqrouter_suspend( - struct sys_device *dev, - u32 state) +static int irqrouter_suspend(struct sys_device *dev, pm_message_t state) { struct list_head *node = NULL; struct acpi_pci_link *link = NULL; -- cgit v1.2.3 From cbfc1bae55bbd053308ef0fa6b6448cd1ddf3e67 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sat, 30 Jul 2005 04:18:00 -0400 Subject: [ACPI] ACPI_HOTPLUG_CPU Kconfig dependency update prevent: HOTPLUG_CPU=y ACPI_PROCESSOR=y ACPI_HOTPLUG_CPU=n Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/acpi/Kconfig | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 281a64040f3..eded2e81cc1 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -154,12 +154,10 @@ config ACPI_PROCESSOR support it. config ACPI_HOTPLUG_CPU - bool "Processor Hotplug (EXPERIMENTAL)" - depends on ACPI_PROCESSOR && HOTPLUG_CPU && EXPERIMENTAL + bool + depends on ACPI_PROCESSOR && HOTPLUG_CPU select ACPI_CONTAINER - default n - ---help--- - Select this option if your platform support physical CPU hotplug. + default y config ACPI_THERMAL tristate "Thermal Zone" -- cgit v1.2.3