Linux ACPI
 help / color / mirror / Atom feed
* [patch 07/26] ACPI: request correct fixed hardware resource type (MMIO vs I/O port)
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, bjorn.helgaas


From: Bjorn Helgaas <bjorn.helgaas@hp.com>

ACPI supports fixed hardware (PM_TMR, GPE blocks, etc) in either I/O port
or MMIO space, but used to always request the regions from I/O space
because it didn't check the address_space_id.

Sample ACPI fixed hardware in MMIO space (HP rx2600), was incorrectly
reported in /proc/ioports, now reported in /proc/iomem:

    ff5c1004-ff5c1007 : PM_TMR
    ff5c1008-ff5c100b : PM1a_EVT_BLK
    ff5c100c-ff5c100d : PM1a_CNT_BLK
    ff5c1010-ff5c1013 : GPE0_BLK
    ff5c1014-ff5c1017 : GPE1_BLK

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/motherboard.c |   41 +++++++++++++++++++----------------
 1 files changed, 23 insertions(+), 18 deletions(-)

diff -puN drivers/acpi/motherboard.c~acpi-request-correct-fixed-hardware-resource-type-mmio-vs-i-o-port drivers/acpi/motherboard.c
--- devel/drivers/acpi/motherboard.c~acpi-request-correct-fixed-hardware-resource-type-mmio-vs-i-o-port	2006-03-28 14:03:03.000000000 -0800
+++ devel-akpm/drivers/acpi/motherboard.c	2006-03-28 14:03:03.000000000 -0800
@@ -123,41 +123,46 @@ static struct acpi_driver acpi_motherboa
 		},
 };
 
+static void __init acpi_request_region (struct acpi_generic_address *addr,
+	unsigned int length, char *desc)
+{
+	if (!addr->address || !length)
+		return;
+
+	if (addr->address_space_id == ACPI_ADR_SPACE_SYSTEM_IO)
+		request_region(addr->address, length, desc);
+	else if (addr->address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
+		request_mem_region(addr->address, length, desc);
+}
+
 static void __init acpi_reserve_resources(void)
 {
-	if (acpi_gbl_FADT->xpm1a_evt_blk.address && acpi_gbl_FADT->pm1_evt_len)
-		request_region(acpi_gbl_FADT->xpm1a_evt_blk.address,
+	acpi_request_region(&acpi_gbl_FADT->xpm1a_evt_blk,
 			       acpi_gbl_FADT->pm1_evt_len, "PM1a_EVT_BLK");
 
-	if (acpi_gbl_FADT->xpm1b_evt_blk.address && acpi_gbl_FADT->pm1_evt_len)
-		request_region(acpi_gbl_FADT->xpm1b_evt_blk.address,
+	acpi_request_region(&acpi_gbl_FADT->xpm1b_evt_blk,
 			       acpi_gbl_FADT->pm1_evt_len, "PM1b_EVT_BLK");
 
-	if (acpi_gbl_FADT->xpm1a_cnt_blk.address && acpi_gbl_FADT->pm1_cnt_len)
-		request_region(acpi_gbl_FADT->xpm1a_cnt_blk.address,
+	acpi_request_region(&acpi_gbl_FADT->xpm1a_cnt_blk,
 			       acpi_gbl_FADT->pm1_cnt_len, "PM1a_CNT_BLK");
 
-	if (acpi_gbl_FADT->xpm1b_cnt_blk.address && acpi_gbl_FADT->pm1_cnt_len)
-		request_region(acpi_gbl_FADT->xpm1b_cnt_blk.address,
+	acpi_request_region(&acpi_gbl_FADT->xpm1b_cnt_blk,
 			       acpi_gbl_FADT->pm1_cnt_len, "PM1b_CNT_BLK");
 
-	if (acpi_gbl_FADT->xpm_tmr_blk.address && acpi_gbl_FADT->pm_tm_len == 4)
-		request_region(acpi_gbl_FADT->xpm_tmr_blk.address, 4, "PM_TMR");
+	if (acpi_gbl_FADT->pm_tm_len == 4)
+		acpi_request_region(&acpi_gbl_FADT->xpm_tmr_blk, 4, "PM_TMR");
 
-	if (acpi_gbl_FADT->xpm2_cnt_blk.address && acpi_gbl_FADT->pm2_cnt_len)
-		request_region(acpi_gbl_FADT->xpm2_cnt_blk.address,
+	acpi_request_region(&acpi_gbl_FADT->xpm2_cnt_blk,
 			       acpi_gbl_FADT->pm2_cnt_len, "PM2_CNT_BLK");
 
 	/* Length of GPE blocks must be a non-negative multiple of 2 */
 
-	if (acpi_gbl_FADT->xgpe0_blk.address && acpi_gbl_FADT->gpe0_blk_len &&
-	    !(acpi_gbl_FADT->gpe0_blk_len & 0x1))
-		request_region(acpi_gbl_FADT->xgpe0_blk.address,
+	if (!(acpi_gbl_FADT->gpe0_blk_len & 0x1))
+		acpi_request_region(&acpi_gbl_FADT->xgpe0_blk,
 			       acpi_gbl_FADT->gpe0_blk_len, "GPE0_BLK");
 
-	if (acpi_gbl_FADT->xgpe1_blk.address && acpi_gbl_FADT->gpe1_blk_len &&
-	    !(acpi_gbl_FADT->gpe1_blk_len & 0x1))
-		request_region(acpi_gbl_FADT->xgpe1_blk.address,
+	if (!(acpi_gbl_FADT->gpe1_blk_len & 0x1))
+		acpi_request_region(&acpi_gbl_FADT->xgpe1_blk,
 			       acpi_gbl_FADT->gpe1_blk_len, "GPE1_BLK");
 }
 
_

^ permalink raw reply

* [patch 10/26] ACPI: fix sonypi ACPI driver registration
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, bjorn.helgaas


From: Bjorn Helgaas <bjorn.helgaas@hp.com>

Remove the assumption that acpi_bus_register_driver() returns the number of
devices claimed.  Returning the count is unreliable because devices may be
hot-plugged in the future (admittedly not applicable for this driver).

This also fixes a bug: if sonypi_acpi_driver was registered but found no
devices, sonypi_exit() did not unregister it.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/char/sonypi.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff -puN drivers/char/sonypi.c~acpi-fix-sonypi-acpi-driver-registration drivers/char/sonypi.c
--- devel/drivers/char/sonypi.c~acpi-fix-sonypi-acpi-driver-registration	2006-03-28 14:03:04.000000000 -0800
+++ devel-akpm/drivers/char/sonypi.c	2006-03-28 14:03:04.000000000 -0800
@@ -512,7 +512,7 @@ static struct sonypi_device {
 
 #ifdef CONFIG_ACPI
 static struct acpi_device *sonypi_acpi_device;
-static int acpi_enabled;
+static int acpi_driver_registered;
 #endif
 
 static int sonypi_ec_write(u8 addr, u8 value)
@@ -869,7 +869,7 @@ found:
 		sonypi_report_input_event(event);
 
 #ifdef CONFIG_ACPI
-	if (acpi_enabled)
+	if (sonypi_acpi_device)
 		acpi_bus_generate_event(sonypi_acpi_device, 1, event);
 #endif
 
@@ -1548,8 +1548,8 @@ static int __init sonypi_init(void)
 		goto err_free_device;
 
 #ifdef CONFIG_ACPI
-	if (acpi_bus_register_driver(&sonypi_acpi_driver) > 0)
-		acpi_enabled = 1;
+	if (acpi_bus_register_driver(&sonypi_acpi_driver) >= 0)
+		acpi_driver_registered = 1;
 #endif
 
 	return 0;
@@ -1564,7 +1564,7 @@ static int __init sonypi_init(void)
 static void __exit sonypi_exit(void)
 {
 #ifdef CONFIG_ACPI
-	if (acpi_enabled)
+	if (acpi_driver_registered)
 		acpi_bus_unregister_driver(&sonypi_acpi_driver);
 #endif
 	platform_device_unregister(sonypi_platform_device);
_

^ permalink raw reply

* [patch 09/26] ACPI: update asus_acpi driver registration
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, bjorn.helgaas


From: Bjorn Helgaas <bjorn.helgaas@hp.com>

Remove the assumption that acpi_bus_register_driver() returns the number of
devices claimed.  Returning the count is unreliable because devices may be
hot-plugged in the future (admittedly not applicable for this driver).

Since the hardware for this driver is not hot-pluggable, determine whether the
hardware is present by noticing calls to the .add() method.  It would be
better to probe the ACPI namespace for the ASUS HIDs, and load the driver only
when we find one, but ACPI doesn't support that yet.

I don't have an ASUS laptop to test on, but on my HP dl360, it does report the
appropriate error when attempting to load the module:

    $ sudo insmod drivers/acpi/asus_acpi.ko
    insmod: error inserting 'drivers/acpi/asus_acpi.ko': -1 No such device

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/asus_acpi.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletion(-)

diff -puN drivers/acpi/asus_acpi.c~acpi-update-asus_acpi-driver-registration drivers/acpi/asus_acpi.c
--- devel/drivers/acpi/asus_acpi.c~acpi-update-asus_acpi-driver-registration	2006-03-28 14:03:03.000000000 -0800
+++ devel-akpm/drivers/acpi/asus_acpi.c	2006-03-28 14:03:03.000000000 -0800
@@ -1119,6 +1119,8 @@ static int __init asus_hotk_check(void)
 	return result;
 }
 
+static int asus_hotk_found;
+
 static int __init asus_hotk_add(struct acpi_device *device)
 {
 	acpi_status status = AE_OK;
@@ -1180,6 +1182,8 @@ static int __init asus_hotk_add(struct a
 		}
 	}
 
+	asus_hotk_found = 1;
+
       end:
 	if (result) {
 		kfree(hotk);
@@ -1226,7 +1230,19 @@ static int __init asus_acpi_init(void)
 	asus_proc_dir->owner = THIS_MODULE;
 
 	result = acpi_bus_register_driver(&asus_hotk_driver);
-	if (result < 1) {
+	if (result < 0) {
+		remove_proc_entry(PROC_ASUS, acpi_root_dir);
+		return -ENODEV;
+	}
+
+	/*
+	 * This is a bit of a kludge.  We only want this module loaded
+	 * for ASUS systems, but there's currently no way to probe the
+	 * ACPI namespace for ASUS HIDs.  So we just return failure if
+	 * we didn't find one, which will cause the module to be
+	 * unloaded.
+	 */
+	if (!asus_hotk_found) {
 		acpi_bus_unregister_driver(&asus_hotk_driver);
 		remove_proc_entry(PROC_ASUS, acpi_root_dir);
 		return -ENODEV;
_

^ permalink raw reply

* [patch 06/26] PNPACPI: whitespace cleanup
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, bjorn.helgaas


From: Bjorn Helgaas <bjorn.helgaas@hp.com>

Tidy up whitespace.  No functional change.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/pnp/pnpacpi/rsparser.c |   97 +++++++++++++++----------------
 1 files changed, 47 insertions(+), 50 deletions(-)

diff -puN drivers/pnp/pnpacpi/rsparser.c~pnpacpi-whitespace-cleanup drivers/pnp/pnpacpi/rsparser.c
--- devel/drivers/pnp/pnpacpi/rsparser.c~pnpacpi-whitespace-cleanup	2006-03-28 14:03:02.000000000 -0800
+++ devel-akpm/drivers/pnp/pnpacpi/rsparser.c	2006-03-28 14:03:02.000000000 -0800
@@ -36,13 +36,13 @@ static int irq_flags(int triggering, int
 {
 	int flag;
 	if (triggering == ACPI_LEVEL_SENSITIVE) {
-		if(polarity == ACPI_ACTIVE_LOW)
+		if (polarity == ACPI_ACTIVE_LOW)
 			flag = IORESOURCE_IRQ_LOWLEVEL;
 		else
 			flag = IORESOURCE_IRQ_HIGHLEVEL;
 	}
 	else {
-		if(polarity == ACPI_ACTIVE_LOW)
+		if (polarity == ACPI_ACTIVE_LOW)
 			flag = IORESOURCE_IRQ_LOWEDGE;
 		else
 			flag = IORESOURCE_IRQ_HIGHEDGE;
@@ -57,7 +57,7 @@ static void decode_irq_flags(int flag, i
 		*triggering = ACPI_LEVEL_SENSITIVE;
 		*polarity = ACPI_ACTIVE_LOW;
 		break;
-	case IORESOURCE_IRQ_HIGHLEVEL:	
+	case IORESOURCE_IRQ_HIGHLEVEL:
 		*triggering = ACPI_LEVEL_SENSITIVE;
 		*polarity = ACPI_ACTIVE_HIGH;
 		break;
@@ -73,7 +73,7 @@ static void decode_irq_flags(int flag, i
 }
 
 static void
-pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi,
+pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, u32 gsi,
 	int triggering, int polarity)
 {
 	int i = 0;
@@ -101,7 +101,7 @@ pnpacpi_parse_allocated_irqresource(stru
 }
 
 static void
-pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, u32 dma)
+pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, u32 dma)
 {
 	int i = 0;
 	while (i < PNP_MAX_DMA &&
@@ -119,7 +119,7 @@ pnpacpi_parse_allocated_dmaresource(stru
 }
 
 static void
-pnpacpi_parse_allocated_ioresource(struct pnp_resource_table * res,
+pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res,
 	u64 io, u64 len)
 {
 	int i = 0;
@@ -138,7 +138,7 @@ pnpacpi_parse_allocated_ioresource(struc
 }
 
 static void
-pnpacpi_parse_allocated_memresource(struct pnp_resource_table * res,
+pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res,
 	u64 mem, u64 len)
 {
 	int i = 0;
@@ -181,7 +181,7 @@ pnpacpi_parse_allocated_address_space(st
 static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
 	void *data)
 {
-	struct pnp_resource_table * res_table = (struct pnp_resource_table *)data;
+	struct pnp_resource_table *res_table = (struct pnp_resource_table *)data;
 	int i;
 
 	switch (res->type) {
@@ -266,11 +266,11 @@ static acpi_status pnpacpi_allocated_res
 		pnp_warn("PnPACPI: unknown resource type %d", res->type);
 		return AE_ERROR;
 	}
-			
+
 	return AE_OK;
 }
 
-acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, struct pnp_resource_table * res)
+acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, struct pnp_resource_table *res)
 {
 	/* Blank the resource table values */
 	pnp_init_resource_table(res);
@@ -328,17 +328,17 @@ static void pnpacpi_parse_dma_option(str
 		pnp_err("Invalid DMA transfer type");
 	}
 
-	pnp_register_dma_resource(option,dma);
+	pnp_register_dma_resource(option, dma);
 	return;
 }
 
-	
+
 static void pnpacpi_parse_irq_option(struct pnp_option *option,
 	struct acpi_resource_irq *p)
 {
 	int i;
-	struct pnp_irq * irq;
-	
+	struct pnp_irq *irq;
+
 	if (p->interrupt_count == 0)
 		return;
 	irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
@@ -358,7 +358,7 @@ static void pnpacpi_parse_ext_irq_option
 	struct acpi_resource_extended_irq *p)
 {
 	int i;
-	struct pnp_irq * irq;
+	struct pnp_irq *irq;
 
 	if (p->interrupt_count == 0)
 		return;
@@ -379,7 +379,7 @@ static void
 pnpacpi_parse_port_option(struct pnp_option *option,
 	struct acpi_resource_io *io)
 {
-	struct pnp_port * port;
+	struct pnp_port *port;
 
 	if (io->address_length == 0)
 		return;
@@ -392,7 +392,7 @@ pnpacpi_parse_port_option(struct pnp_opt
 	port->size = io->address_length;
 	port->flags = ACPI_DECODE_16 == io->io_decode ?
 		PNP_PORT_FLAG_16BITADDR : 0;
-	pnp_register_port_resource(option,port);
+	pnp_register_port_resource(option, port);
 	return;
 }
 
@@ -400,7 +400,7 @@ static void
 pnpacpi_parse_fixed_port_option(struct pnp_option *option,
 	struct acpi_resource_fixed_io *io)
 {
-	struct pnp_port * port;
+	struct pnp_port *port;
 
 	if (io->address_length == 0)
 		return;
@@ -411,7 +411,7 @@ pnpacpi_parse_fixed_port_option(struct p
 	port->size = io->address_length;
 	port->align = 0;
 	port->flags = PNP_PORT_FLAG_FIXED;
-	pnp_register_port_resource(option,port);
+	pnp_register_port_resource(option, port);
 	return;
 }
 
@@ -419,7 +419,7 @@ static void
 pnpacpi_parse_mem24_option(struct pnp_option *option,
 	struct acpi_resource_memory24 *p)
 {
-	struct pnp_mem * mem;
+	struct pnp_mem *mem;
 
 	if (p->address_length == 0)
 		return;
@@ -434,7 +434,7 @@ pnpacpi_parse_mem24_option(struct pnp_op
 	mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
 			IORESOURCE_MEM_WRITEABLE : 0;
 
-	pnp_register_mem_resource(option,mem);
+	pnp_register_mem_resource(option, mem);
 	return;
 }
 
@@ -442,7 +442,7 @@ static void
 pnpacpi_parse_mem32_option(struct pnp_option *option,
 	struct acpi_resource_memory32 *p)
 {
-	struct pnp_mem * mem;
+	struct pnp_mem *mem;
 
 	if (p->address_length == 0)
 		return;
@@ -457,7 +457,7 @@ pnpacpi_parse_mem32_option(struct pnp_op
 	mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
 			IORESOURCE_MEM_WRITEABLE : 0;
 
-	pnp_register_mem_resource(option,mem);
+	pnp_register_mem_resource(option, mem);
 	return;
 }
 
@@ -465,7 +465,7 @@ static void
 pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
 	struct acpi_resource_fixed_memory32 *p)
 {
-	struct pnp_mem * mem;
+	struct pnp_mem *mem;
 
 	if (p->address_length == 0)
 		return;
@@ -479,7 +479,7 @@ pnpacpi_parse_fixed_mem32_option(struct 
 	mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
 			IORESOURCE_MEM_WRITEABLE : 0;
 
-	pnp_register_mem_resource(option,mem);
+	pnp_register_mem_resource(option, mem);
 	return;
 }
 
@@ -488,8 +488,8 @@ pnpacpi_parse_address_option(struct pnp_
 {
 	struct acpi_resource_address64 addr, *p = &addr;
 	acpi_status status;
-	struct pnp_mem * mem;
-	struct pnp_port * port;
+	struct pnp_mem *mem;
+	struct pnp_port *port;
 
 	status = acpi_resource_to_address64(r, p);
 	if (!ACPI_SUCCESS(status)) {
@@ -509,7 +509,7 @@ pnpacpi_parse_address_option(struct pnp_
 		mem->align = 0;
 		mem->flags = (p->info.mem.write_protect ==
 		    ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0;
-		pnp_register_mem_resource(option,mem);
+		pnp_register_mem_resource(option, mem);
 	} else if (p->resource_type == ACPI_IO_RANGE) {
 		port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
 		if (!port)
@@ -518,7 +518,7 @@ pnpacpi_parse_address_option(struct pnp_
 		port->size = p->address_length;
 		port->align = 0;
 		port->flags = PNP_PORT_FLAG_FIXED;
-		pnp_register_port_resource(option,port);
+		pnp_register_port_resource(option, port);
 	}
 }
 
@@ -542,7 +542,7 @@ static acpi_status pnpacpi_option_resour
 			break;
 
 		case ACPI_RESOURCE_TYPE_DMA:
-			pnpacpi_parse_dma_option(option, &res->data.dma);	
+			pnpacpi_parse_dma_option(option, &res->data.dma);
 			break;
 
 		case ACPI_RESOURCE_TYPE_START_DEPENDENT:
@@ -550,7 +550,7 @@ static acpi_status pnpacpi_option_resour
 				case ACPI_GOOD_CONFIGURATION:
 					priority = PNP_RES_PRIORITY_PREFERRED;
 					break;
-					
+
 				case ACPI_ACCEPTABLE_CONFIGURATION:
 					priority = PNP_RES_PRIORITY_ACCEPTABLE;
 					break;
@@ -566,7 +566,7 @@ static acpi_status pnpacpi_option_resour
 			option = pnp_register_dependent_option(dev, priority);
 			if (!option)
 				return AE_ERROR;
-			parse_data->option = option;	
+			parse_data->option = option;
 			break;
 
 		case ACPI_RESOURCE_TYPE_END_DEPENDENT:
@@ -626,7 +626,7 @@ static acpi_status pnpacpi_option_resour
 			pnp_warn("PnPACPI: unknown resource type %d", res->type);
 			return AE_ERROR;
 	}
-			
+
 	return AE_OK;
 }
 
@@ -679,10 +679,9 @@ static acpi_status pnpacpi_count_resourc
 	return AE_OK;
 }
 
-static acpi_status pnpacpi_type_resources(struct acpi_resource *res,
-	void *data)
+static acpi_status pnpacpi_type_resources(struct acpi_resource *res, void *data)
 {
-	struct acpi_resource **resource = (struct acpi_resource **)data;	
+	struct acpi_resource **resource = (struct acpi_resource **)data;
 
 	if (pnpacpi_supported_resource(res)) {
 		(*resource)->type = res->type;
@@ -731,9 +730,8 @@ static void pnpacpi_encode_irq(struct ac
 	struct resource *p)
 {
 	int triggering, polarity;
-	
-	decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering,
-		&polarity);
+
+	decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, &polarity);
 	resource->data.irq.triggering = triggering;
 	resource->data.irq.polarity = polarity;
 	if (triggering == ACPI_EDGE_SENSITIVE)
@@ -748,9 +746,8 @@ static void pnpacpi_encode_ext_irq(struc
 	struct resource *p)
 {
 	int triggering, polarity;
-	
-	decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering,
-		&polarity);
+
+	decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, &polarity);
 	resource->data.extended_irq.producer_consumer = ACPI_CONSUMER;
 	resource->data.extended_irq.triggering = triggering;
 	resource->data.extended_irq.polarity = polarity;
@@ -862,37 +859,37 @@ int pnpacpi_encode_resources(struct pnp_
 			pnp_dbg("Encode dma");
 			pnpacpi_encode_dma(resource,
 				&res_table->dma_resource[dma]);
-			dma ++;
+			dma++;
 			break;
 		case ACPI_RESOURCE_TYPE_IO:
 			pnp_dbg("Encode io");
 			pnpacpi_encode_io(resource,
 				&res_table->port_resource[port]);
-			port ++;
+			port++;
 			break;
 		case ACPI_RESOURCE_TYPE_FIXED_IO:
 			pnp_dbg("Encode fixed io");
 			pnpacpi_encode_fixed_io(resource,
 				&res_table->port_resource[port]);
-			port ++;
+			port++;
 			break;
 		case ACPI_RESOURCE_TYPE_MEMORY24:
 			pnp_dbg("Encode mem24");
 			pnpacpi_encode_mem24(resource,
 				&res_table->mem_resource[mem]);
-			mem ++;
+			mem++;
 			break;
 		case ACPI_RESOURCE_TYPE_MEMORY32:
 			pnp_dbg("Encode mem32");
 			pnpacpi_encode_mem32(resource,
 				&res_table->mem_resource[mem]);
-			mem ++;
+			mem++;
 			break;
 		case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
 			pnp_dbg("Encode fixed mem32");
 			pnpacpi_encode_fixed_mem32(resource,
 				&res_table->mem_resource[mem]);
-			mem ++;
+			mem++;
 			break;
 		case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
 			pnp_dbg("Encode ext irq");
@@ -913,8 +910,8 @@ int pnpacpi_encode_resources(struct pnp_
 			pnp_warn("unknown resource type %d", resource->type);
 			return -EINVAL;
 		}
-		resource ++;
-		i ++;
+		resource++;
+		i++;
 	}
 	return 0;
 }
_

^ permalink raw reply

* [patch 02/26] sem2mutex: drivers/acpi/
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, arjan, mingo


From: Arjan van de Ven <arjan@infradead.org>

Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.

Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/processor_perflib.c |   27 ++++++++++++++-------------
 drivers/acpi/scan.c              |    3 ++-
 2 files changed, 16 insertions(+), 14 deletions(-)

diff -puN drivers/acpi/processor_perflib.c~sem2mutex-drivers-acpi drivers/acpi/processor_perflib.c
--- devel/drivers/acpi/processor_perflib.c~sem2mutex-drivers-acpi	2006-03-28 14:03:00.000000000 -0800
+++ devel-akpm/drivers/acpi/processor_perflib.c	2006-03-28 14:03:00.000000000 -0800
@@ -34,6 +34,7 @@
 #ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/mutex.h>
 
 #include <asm/uaccess.h>
 #endif
@@ -48,7 +49,7 @@
 #define _COMPONENT		ACPI_PROCESSOR_COMPONENT
 ACPI_MODULE_NAME("acpi_processor")
 
-static DECLARE_MUTEX(performance_sem);
+static DEFINE_MUTEX(performance_mutex);
 
 /*
  * _PPC support is implemented as a CPUfreq policy notifier:
@@ -72,7 +73,7 @@ static int acpi_processor_ppc_notifier(s
 	struct acpi_processor *pr;
 	unsigned int ppc = 0;
 
-	down(&performance_sem);
+	mutex_lock(&performance_mutex);
 
 	if (event != CPUFREQ_INCOMPATIBLE)
 		goto out;
@@ -93,7 +94,7 @@ static int acpi_processor_ppc_notifier(s
 				     core_frequency * 1000);
 
       out:
-	up(&performance_sem);
+	mutex_unlock(&performance_mutex);
 
 	return 0;
 }
@@ -620,7 +621,7 @@ int acpi_processor_preregister_performan
 
 	ACPI_FUNCTION_TRACE("acpi_processor_preregister_performance");
 
-	down(&performance_sem);
+	mutex_lock(&performance_mutex);
 
 	retval = 0;
 
@@ -768,7 +769,7 @@ err_ret:
 		pr->performance = NULL; /* Will be set for real in register */
 	}
 
-	up(&performance_sem);
+	mutex_unlock(&performance_mutex);
 	return_VALUE(retval);
 }
 EXPORT_SYMBOL(acpi_processor_preregister_performance);
@@ -785,16 +786,16 @@ acpi_processor_register_performance(stru
 	if (!(acpi_processor_ppc_status & PPC_REGISTERED))
 		return_VALUE(-EINVAL);
 
-	down(&performance_sem);
+	mutex_lock(&performance_mutex);
 
 	pr = processors[cpu];
 	if (!pr) {
-		up(&performance_sem);
+		mutex_unlock(&performance_mutex);
 		return_VALUE(-ENODEV);
 	}
 
 	if (pr->performance) {
-		up(&performance_sem);
+		mutex_unlock(&performance_mutex);
 		return_VALUE(-EBUSY);
 	}
 
@@ -802,13 +803,13 @@ acpi_processor_register_performance(stru
 
 	if (acpi_processor_get_performance_info(pr)) {
 		pr->performance = NULL;
-		up(&performance_sem);
+		mutex_unlock(&performance_mutex);
 		return_VALUE(-EIO);
 	}
 
 	acpi_cpufreq_add_file(pr);
 
-	up(&performance_sem);
+	mutex_unlock(&performance_mutex);
 	return_VALUE(0);
 }
 
@@ -822,11 +823,11 @@ acpi_processor_unregister_performance(st
 
 	ACPI_FUNCTION_TRACE("acpi_processor_unregister_performance");
 
-	down(&performance_sem);
+	mutex_lock(&performance_mutex);
 
 	pr = processors[cpu];
 	if (!pr) {
-		up(&performance_sem);
+		mutex_unlock(&performance_mutex);
 		return_VOID;
 	}
 
@@ -835,7 +836,7 @@ acpi_processor_unregister_performance(st
 
 	acpi_cpufreq_remove_file(pr);
 
-	up(&performance_sem);
+	mutex_unlock(&performance_mutex);
 
 	return_VOID;
 }
diff -puN drivers/acpi/scan.c~sem2mutex-drivers-acpi drivers/acpi/scan.c
--- devel/drivers/acpi/scan.c~sem2mutex-drivers-acpi	2006-03-28 14:03:00.000000000 -0800
+++ devel-akpm/drivers/acpi/scan.c	2006-03-28 14:03:00.000000000 -0800
@@ -5,6 +5,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/acpi.h>
+#include <linux/mutex.h>
 
 #include <acpi/acpi_drivers.h>
 #include <acpi/acinterp.h>	/* for acpi_ex_eisa_id_to_string() */
@@ -470,7 +471,7 @@ static int acpi_bus_get_perf_flags(struc
    -------------------------------------------------------------------------- */
 
 static LIST_HEAD(acpi_bus_drivers);
-static DECLARE_MUTEX(acpi_bus_drivers_lock);
+static DEFINE_MUTEX(acpi_bus_drivers_lock);
 
 /**
  * acpi_bus_match - match device IDs to driver's supported IDs
_

^ permalink raw reply

* [patch 11/26] ACPI: make acpi_bus_register_driver() return success/failure, not device count
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, bjorn.helgaas


From: Bjorn Helgaas <bjorn.helgaas@hp.com>

acpi_bus_register_driver() should not return the number of devices claimed. 
We're not asking to find devices, we're making a driver available to devices,
including hot-pluggable devices that may appear in the future.

I audited all callers of acpi_bus_register_driver(), and except asus_acpi.c
and sonypi.c (fixed in previous patches), all either ignore the return value
or test only for failure (<0).

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/scan.c |   16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)

diff -puN drivers/acpi/scan.c~acpi-make-acpi_bus_register_driver-return-success-failure-not-device-count drivers/acpi/scan.c
--- devel/drivers/acpi/scan.c~acpi-make-acpi_bus_register_driver-return-success-failure-not-device-count	2006-03-28 14:03:04.000000000 -0800
+++ devel-akpm/drivers/acpi/scan.c	2006-03-28 14:03:04.000000000 -0800
@@ -548,10 +548,9 @@ static int acpi_start_single_object(stru
 	return_VALUE(result);
 }
 
-static int acpi_driver_attach(struct acpi_driver *drv)
+static void acpi_driver_attach(struct acpi_driver *drv)
 {
 	struct list_head *node, *next;
-	int count = 0;
 
 	ACPI_FUNCTION_TRACE("acpi_driver_attach");
 
@@ -568,7 +567,6 @@ static int acpi_driver_attach(struct acp
 			if (!acpi_bus_driver_init(dev, drv)) {
 				acpi_start_single_object(dev);
 				atomic_inc(&drv->references);
-				count++;
 				ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 						  "Found driver [%s] for device [%s]\n",
 						  drv->name, dev->pnp.bus_id));
@@ -577,7 +575,6 @@ static int acpi_driver_attach(struct acp
 		spin_lock(&acpi_device_lock);
 	}
 	spin_unlock(&acpi_device_lock);
-	return_VALUE(count);
 }
 
 static int acpi_driver_detach(struct acpi_driver *drv)
@@ -610,14 +607,11 @@ static int acpi_driver_detach(struct acp
  * @driver: driver being registered
  *
  * Registers a driver with the ACPI bus.  Searches the namespace for all
- * devices that match the driver's criteria and binds.  Returns the
- * number of devices that were claimed by the driver, or a negative
- * error status for failure.
+ * devices that match the driver's criteria and binds.  Returns zero for
+ * success or a negative error status for failure.
  */
 int acpi_bus_register_driver(struct acpi_driver *driver)
 {
-	int count;
-
 	ACPI_FUNCTION_TRACE("acpi_bus_register_driver");
 
 	if (acpi_disabled)
@@ -629,9 +623,9 @@ int acpi_bus_register_driver(struct acpi
 	spin_lock(&acpi_device_lock);
 	list_add_tail(&driver->node, &acpi_bus_drivers);
 	spin_unlock(&acpi_device_lock);
-	count = acpi_driver_attach(driver);
+	acpi_driver_attach(driver);
 
-	return_VALUE(count);
+	return_VALUE(0);
 }
 
 EXPORT_SYMBOL(acpi_bus_register_driver);
_

^ permalink raw reply

* [patch 12/26] ACPI: simplify scan.c coding
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, bjorn.helgaas


From: Bjorn Helgaas <bjorn.helgaas@hp.com>

No functional changes; just remove leftover, unused "buffer" and simplify
control flow (no need to remember error values and goto the end, when we can
simply return the value directly).

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/scan.c |   36 +++++++++++++-----------------------
 1 files changed, 13 insertions(+), 23 deletions(-)

diff -puN drivers/acpi/scan.c~acpi-simplify-scanc-coding drivers/acpi/scan.c
--- devel/drivers/acpi/scan.c~acpi-simplify-scanc-coding	2006-03-28 14:03:04.000000000 -0800
+++ devel-akpm/drivers/acpi/scan.c	2006-03-28 14:03:04.000000000 -0800
@@ -235,12 +235,9 @@ static int acpi_bus_get_power_flags(stru
 
 int acpi_match_ids(struct acpi_device *device, char *ids)
 {
-	int error = 0;
-	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
-
 	if (device->flags.hardware_id)
 		if (strstr(ids, device->pnp.hardware_id))
-			goto Done;
+			return 0;
 
 	if (device->flags.compatible_ids) {
 		struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
@@ -249,15 +246,10 @@ int acpi_match_ids(struct acpi_device *d
 		/* compare multiple _CID entries against driver ids */
 		for (i = 0; i < cid_list->count; i++) {
 			if (strstr(ids, cid_list->id[i].value))
-				goto Done;
+				return 0;
 		}
 	}
-	error = -ENOENT;
-
-      Done:
-	if (buffer.pointer)
-		acpi_os_free(buffer.pointer);
-	return error;
+	return -ENOENT;
 }
 
 static acpi_status
@@ -639,21 +631,19 @@ EXPORT_SYMBOL(acpi_bus_register_driver);
  */
 int acpi_bus_unregister_driver(struct acpi_driver *driver)
 {
-	int error = 0;
-
 	ACPI_FUNCTION_TRACE("acpi_bus_unregister_driver");
 
-	if (driver) {
-		acpi_driver_detach(driver);
+	if (!driver)
+		return_VALUE(-EINVAL);
 
-		if (!atomic_read(&driver->references)) {
-			spin_lock(&acpi_device_lock);
-			list_del_init(&driver->node);
-			spin_unlock(&acpi_device_lock);
-		}
-	} else
-		error = -EINVAL;
-	return_VALUE(error);
+	acpi_driver_detach(driver);
+
+	if (!atomic_read(&driver->references)) {
+		spin_lock(&acpi_device_lock);
+		list_del_init(&driver->node);
+		spin_unlock(&acpi_device_lock);
+	}
+	return_VALUE(0);
 }
 
 EXPORT_SYMBOL(acpi_bus_unregister_driver);
_

^ permalink raw reply

* [patch 13/26] ACPI: print wakeup device list on same line as label
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, bjorn.helgaas


From: Bjorn Helgaas <bjorn.helgaas@hp.com>

Print the ACPI wakeup device list on the same line as the label to make
"dmesg | grep ACPI" output more useful.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/sleep/wakeup.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

diff -puN drivers/acpi/sleep/wakeup.c~acpi-print-wakeup-device-list-on-same-line-as-label drivers/acpi/sleep/wakeup.c
--- devel/drivers/acpi/sleep/wakeup.c~acpi-print-wakeup-device-list-on-same-line-as-label	2006-03-28 14:03:04.000000000 -0800
+++ devel-akpm/drivers/acpi/sleep/wakeup.c	2006-03-28 14:03:04.000000000 -0800
@@ -155,7 +155,7 @@ static int __init acpi_wakeup_device_ini
 
 	if (acpi_disabled)
 		return 0;
-	printk("ACPI wakeup devices: \n");
+	printk(KERN_INFO PREFIX "wakeup devices: ");
 
 	spin_lock(&acpi_device_lock);
 	list_for_each_safe(node, next, &acpi_wakeup_device_list) {
_

^ permalink raw reply

* [patch 14/26] ACPI: fix memory hotplug range length handling
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, bjorn.helgaas


From: Bjorn Helgaas <bjorn.helgaas@hp.com>

Address space descriptors contain _MIN, _MAX, and _LEN.  _MIN and _MAX are
the bounds within which the region can be moved (this is clarified in Table
6-38 of the ACPI 3.0 spec).  We should use _LEN to determine the size of
the region, not _MAX - _MIN + 1.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/acpi_memhotplug.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff -puN drivers/acpi/acpi_memhotplug.c~acpi-fix-memory-hotplug-range-length-handling drivers/acpi/acpi_memhotplug.c
--- devel/drivers/acpi/acpi_memhotplug.c~acpi-fix-memory-hotplug-range-length-handling	2006-03-28 14:03:05.000000000 -0800
+++ devel-akpm/drivers/acpi/acpi_memhotplug.c	2006-03-28 14:03:05.000000000 -0800
@@ -74,7 +74,7 @@ struct acpi_memory_device {
 	unsigned short caching;	/* memory cache attribute */
 	unsigned short write_protect;	/* memory read/write attribute */
 	u64 start_addr;		/* Memory Range start physical addr */
-	u64 end_addr;		/* Memory Range end physical addr */
+	u64 length;		/* Memory Range length */
 };
 
 static int
@@ -97,12 +97,11 @@ acpi_memory_get_device_resources(struct 
 	if (ACPI_SUCCESS(status)) {
 		if (address64.resource_type == ACPI_MEMORY_RANGE) {
 			/* Populate the structure */
-			mem_device->caching =
-			    address64.info.mem.caching;
+			mem_device->caching = address64.info.mem.caching;
 			mem_device->write_protect =
 			    address64.info.mem.write_protect;
 			mem_device->start_addr = address64.minimum;
-			mem_device->end_addr = address64.maximum;
+			mem_device->length = address64.address_length;
 		}
 	}
 
@@ -197,8 +196,7 @@ static int acpi_memory_enable_device(str
 	 * Tell the VM there is more memory here...
 	 * Note: Assume that this function returns zero on success
 	 */
-	result = add_memory(mem_device->start_addr,
-			    (mem_device->end_addr - mem_device->start_addr) + 1);
+	result = add_memory(mem_device->start_addr, mem_device->length);
 	if (result) {
 		ACPI_ERROR((AE_INFO, "add_memory failed"));
 		mem_device->state = MEMORY_INVALID_STATE;
@@ -247,7 +245,7 @@ static int acpi_memory_disable_device(st
 {
 	int result;
 	u64 start = mem_device->start_addr;
-	u64 len = mem_device->end_addr - start + 1;
+	u64 len = mem_device->length;
 
 	ACPI_FUNCTION_TRACE("acpi_memory_disable_device");
 
_

^ permalink raw reply

* [patch 15/26] HPET: fix ACPI memory range length handling
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, bjorn.helgaas


From: Bjorn Helgaas <bjorn.helgaas@hp.com>

ACPI address space descriptors contain _MIN, _MAX, and _LEN.  _MIN and _MAX
are the bounds within which the region can be moved (this is clarified in
Table 6-38 of the ACPI 3.0 spec).  We should use _LEN to determine the size
of the region, not _MAX - _MIN + 1.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/char/hpet.c |    5 +----
 1 files changed, 1 insertion(+), 4 deletions(-)

diff -puN drivers/char/hpet.c~hpet-fix-acpi-memory-range-length-handling drivers/char/hpet.c
--- devel/drivers/char/hpet.c~hpet-fix-acpi-memory-range-length-handling	2006-03-28 14:03:05.000000000 -0800
+++ devel-akpm/drivers/char/hpet.c	2006-03-28 14:03:05.000000000 -0800
@@ -925,11 +925,8 @@ static acpi_status hpet_resources(struct
 	status = acpi_resource_to_address64(res, &addr);
 
 	if (ACPI_SUCCESS(status)) {
-		unsigned long size;
-
-		size = addr.maximum - addr.minimum + 1;
 		hdp->hd_phys_address = addr.minimum;
-		hdp->hd_address = ioremap(addr.minimum, size);
+		hdp->hd_address = ioremap(addr.minimum, addr.address_length);
 
 		if (hpet_is_known(hdp)) {
 			printk(KERN_DEBUG "%s: 0x%lx is busy\n",
_

^ permalink raw reply

* [patch 18/26] ACPI: remove __init/__exit from Asus .add()/.remove() methods
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, bjorn.helgaas


From: Bjorn Helgaas <bjorn.helgaas@hp.com>

Even though the devices claimed by asus_acpi.c can not be hot-plugged, the
driver registration infrastructure allows the .add() and .remove() methods to
be called at any time while the driver is registered.  So remove __init and
__exit from them.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/asus_acpi.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff -puN drivers/acpi/asus_acpi.c~acpi-remove-__init-__exit-from-asus-add-remove-methods drivers/acpi/asus_acpi.c
--- devel/drivers/acpi/asus_acpi.c~acpi-remove-__init-__exit-from-asus-add-remove-methods	2006-03-28 14:03:06.000000000 -0800
+++ devel-akpm/drivers/acpi/asus_acpi.c	2006-03-28 14:03:06.000000000 -0800
@@ -817,7 +817,7 @@ typedef int (proc_writefunc) (struct fil
 			      unsigned long count, void *data);
 
 static int
-__init asus_proc_add(char *name, proc_writefunc * writefunc,
+asus_proc_add(char *name, proc_writefunc * writefunc,
 		     proc_readfunc * readfunc, mode_t mode,
 		     struct acpi_device *device)
 {
@@ -836,7 +836,7 @@ __init asus_proc_add(char *name, proc_wr
 	return 0;
 }
 
-static int __init asus_hotk_add_fs(struct acpi_device *device)
+static int asus_hotk_add_fs(struct acpi_device *device)
 {
 	struct proc_dir_entry *proc;
 	mode_t mode;
@@ -954,7 +954,7 @@ static void asus_hotk_notify(acpi_handle
  * This function is used to initialize the hotk with right values. In this
  * method, we can make all the detection we want, and modify the hotk struct
  */
-static int __init asus_hotk_get_info(void)
+static int asus_hotk_get_info(void)
 {
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 	struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -1101,7 +1101,7 @@ static int __init asus_hotk_get_info(voi
 	return AE_OK;
 }
 
-static int __init asus_hotk_check(void)
+static int asus_hotk_check(void)
 {
 	int result = 0;
 
@@ -1121,7 +1121,7 @@ static int __init asus_hotk_check(void)
 
 static int asus_hotk_found;
 
-static int __init asus_hotk_add(struct acpi_device *device)
+static int asus_hotk_add(struct acpi_device *device)
 {
 	acpi_status status = AE_OK;
 	int result;
_

^ permalink raw reply

* [patch 16/26] acpi_os_acquire_object (GFP_KERNEL) called with IRQs disabled through suspend-resume
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, davi.arnaut, pavel


From: Davi Arnaut <davi.arnaut@gmail.com>

acpi_os_acquire_object() gets called, with IRQs disabled, from:

Debug: sleeping function called from invalid context at mm/slab.c:2499
in_atomic():0, irqs_disabled():1
 [<c01462f3>] kmem_cache_alloc+0x40/0x4f     [<c0202c85>] acpi_os_acquire_object+0xb/0x3c
 [<c02171b1>] acpi_ut_allocate_object_desc_dbg+0x13/0x49     [<c021704b>] acpi_ut_create_internal_object_dbg+0xf/0x5e
 [<c02136d4>] acpi_rs_set_srs_method_data+0x3d/0xb9     [<c021aa3d>] acpi_pci_link_set+0x102/0x17b
 [<c021aecb>] irqrouter_resume+0x1e/0x3c     [<c024d921>] __sysdev_resume+0x11/0x6b
 [<c024dbde>] sysdev_resume+0x34/0x52     [<c0251cb7>] device_power_up+0x5/0xa
 [<c0138787>] suspend_enter+0x44/0x46     [<c01386e5>] suspend_prepare+0x63/0xc1
 [<c0138813>] enter_state+0x5e/0x7c     [<c013894c>] state_store+0x81/0x8f
 [<c01388cb>] state_store+0x0/0x8f     [<c0196a0a>] subsys_attr_store+0x1e/0x22
 [<c0196c12>] flush_write_buffer+0x22/0x28     [<c0196c64>] sysfs_write_file+0x4c/0x71
 [<c0196c18>] sysfs_write_file+0x0/0x71     [<c015b2c9>] vfs_write+0xa2/0x15a
 [<c015b42c>] sys_write+0x41/0x6a     [<c0102e75>] syscall_call+0x7/0xb

The patch also fixes a missing check for NULL return from
acpi_os_acquire_object().

Signed-off-by: Davi Arnaut <davi.arnaut@gmail.com>
Cc: "Brown, Len" <len.brown@intel.com>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/osl.c            |    7 ++++++-
 drivers/acpi/parser/psutils.c |    8 ++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff -puN drivers/acpi/osl.c~acpi_os_acquire_object-gfp_kernel-called-with-irqs drivers/acpi/osl.c
--- devel/drivers/acpi/osl.c~acpi_os_acquire_object-gfp_kernel-called-with-irqs	2006-03-28 14:03:05.000000000 -0800
+++ devel-akpm/drivers/acpi/osl.c	2006-03-28 14:03:05.000000000 -0800
@@ -1141,7 +1141,12 @@ acpi_status acpi_os_release_object(acpi_
 
 void *acpi_os_acquire_object(acpi_cache_t * cache)
 {
-	void *object = kmem_cache_alloc(cache, GFP_KERNEL);
+	void *object;
+
+	if (acpi_in_resume)
+		object = kmem_cache_alloc(cache, GFP_ATOMIC);
+	else
+		object = kmem_cache_alloc(cache, GFP_KERNEL);
 	WARN_ON(!object);
 	return object;
 }
diff -puN drivers/acpi/parser/psutils.c~acpi_os_acquire_object-gfp_kernel-called-with-irqs drivers/acpi/parser/psutils.c
--- devel/drivers/acpi/parser/psutils.c~acpi_os_acquire_object-gfp_kernel-called-with-irqs	2006-03-28 14:03:05.000000000 -0800
+++ devel-akpm/drivers/acpi/parser/psutils.c	2006-03-28 14:03:05.000000000 -0800
@@ -139,12 +139,16 @@ union acpi_parse_object *acpi_ps_alloc_o
 		/* The generic op (default) is by far the most common (16 to 1) */
 
 		op = acpi_os_acquire_object(acpi_gbl_ps_node_cache);
-		memset(op, 0, sizeof(struct acpi_parse_obj_common));
+
+		if (op)
+			memset(op, 0, sizeof(struct acpi_parse_obj_common));
 	} else {
 		/* Extended parseop */
 
 		op = acpi_os_acquire_object(acpi_gbl_ps_node_ext_cache);
-		memset(op, 0, sizeof(struct acpi_parse_obj_named));
+
+		if (op)
+			memset(op, 0, sizeof(struct acpi_parse_obj_named));
 	}
 
 	/* Initialize the Op */
_

^ permalink raw reply

* [patch 17/26] acpi: ia64: wake on LAN fix
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, takeuchi_satoru, tony.luck


From: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>

Currently wakeup capability is available if and only if
CONFIG_ACPI_SLEEP=y.  But S5 is not a sleep state.  This patch makes ACPI
subsystem to be able to wakeup from S5 state even if sleep mode is not
supported.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Cc: "Brown, Len" <len.brown@intel.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/sleep/Makefile   |    3 +--
 drivers/acpi/sleep/poweroff.c |    1 +
 drivers/acpi/sleep/proc.c     |   16 ++++++++++++++++
 drivers/acpi/sleep/wakeup.c   |    2 ++
 4 files changed, 20 insertions(+), 2 deletions(-)

diff -puN drivers/acpi/sleep/Makefile~acpi-ia64-wake-on-lan-fix drivers/acpi/sleep/Makefile
--- devel/drivers/acpi/sleep/Makefile~acpi-ia64-wake-on-lan-fix	2006-03-28 14:03:06.000000000 -0800
+++ devel-akpm/drivers/acpi/sleep/Makefile	2006-03-28 14:03:06.000000000 -0800
@@ -1,5 +1,4 @@
-obj-y					:= poweroff.o wakeup.o
+obj-y					:= poweroff.o wakeup.o proc.o
 obj-$(CONFIG_ACPI_SLEEP)		+= main.o
-obj-$(CONFIG_ACPI_SLEEP_PROC_FS)	+= proc.o
 
 EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff -puN drivers/acpi/sleep/poweroff.c~acpi-ia64-wake-on-lan-fix drivers/acpi/sleep/poweroff.c
--- devel/drivers/acpi/sleep/poweroff.c~acpi-ia64-wake-on-lan-fix	2006-03-28 14:03:06.000000000 -0800
+++ devel-akpm/drivers/acpi/sleep/poweroff.c	2006-03-28 14:03:06.000000000 -0800
@@ -45,6 +45,7 @@ void acpi_power_off(void)
 	/* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
 	printk("%s called\n", __FUNCTION__);
 	local_irq_disable();
+	acpi_enable_wakeup_device(ACPI_STATE_S5);
 	/* Some SMP machines only can poweroff in boot CPU */
 	acpi_enter_sleep_state(ACPI_STATE_S5);
 }
diff -puN drivers/acpi/sleep/proc.c~acpi-ia64-wake-on-lan-fix drivers/acpi/sleep/proc.c
--- devel/drivers/acpi/sleep/proc.c~acpi-ia64-wake-on-lan-fix	2006-03-28 14:03:06.000000000 -0800
+++ devel-akpm/drivers/acpi/sleep/proc.c	2006-03-28 14:03:06.000000000 -0800
@@ -70,6 +70,7 @@ acpi_system_write_sleep(struct file *fil
 }
 #endif				/* CONFIG_ACPI_SLEEP_PROC_SLEEP */
 
+#ifdef	CONFIG_ACPI_SLEEP
 static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
 {
 	u32 sec, min, hr;
@@ -339,6 +340,7 @@ acpi_system_write_alarm(struct file *fil
       end:
 	return_VALUE(result ? result : count);
 }
+#endif				/* CONFIG_ACPI_SLEEP */
 
 extern struct list_head acpi_wakeup_device_list;
 extern spinlock_t acpi_device_lock;
@@ -357,6 +359,10 @@ acpi_system_wakeup_device_seq_show(struc
 
 		if (!dev->wakeup.flags.valid)
 			continue;
+#ifndef CONFIG_ACPI_SLEEP
+		if (dev->wakeup.sleep_state != ACPI_STATE_S5)
+			continue;
+#endif
 		spin_unlock(&acpi_device_lock);
 		seq_printf(seq, "%4s	%4d		%s%8s\n",
 			   dev->pnp.bus_id,
@@ -394,6 +400,10 @@ acpi_system_write_wakeup_device(struct f
 		    container_of(node, struct acpi_device, wakeup_list);
 		if (!dev->wakeup.flags.valid)
 			continue;
+#ifndef CONFIG_ACPI_SLEEP
+		if (dev->wakeup.sleep_state != ACPI_STATE_S5)
+			continue;
+#endif
 
 		if (!strncmp(dev->pnp.bus_id, str, 4)) {
 			dev->wakeup.state.enabled =
@@ -452,6 +462,7 @@ static struct file_operations acpi_syste
 };
 #endif				/* CONFIG_ACPI_SLEEP_PROC_SLEEP */
 
+#ifdef	CONFIG_ACPI_SLEEP
 static struct file_operations acpi_system_alarm_fops = {
 	.open = acpi_system_alarm_open_fs,
 	.read = seq_read,
@@ -467,6 +478,7 @@ static u32 rtc_handler(void *context)
 
 	return ACPI_INTERRUPT_HANDLED;
 }
+#endif				/* CONFIG_ACPI_SLEEP */
 
 static int acpi_sleep_proc_init(void)
 {
@@ -484,12 +496,14 @@ static int acpi_sleep_proc_init(void)
 		entry->proc_fops = &acpi_system_sleep_fops;
 #endif
 
+#ifdef	CONFIG_ACPI_SLEEP
 	/* 'alarm' [R/W] */
 	entry =
 	    create_proc_entry("alarm", S_IFREG | S_IRUGO | S_IWUSR,
 			      acpi_root_dir);
 	if (entry)
 		entry->proc_fops = &acpi_system_alarm_fops;
+#endif
 
 	/* 'wakeup device' [R/W] */
 	entry =
@@ -498,7 +512,9 @@ static int acpi_sleep_proc_init(void)
 	if (entry)
 		entry->proc_fops = &acpi_system_wakeup_device_fops;
 
+#ifdef	CONFIG_ACPI_SLEEP
 	acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL);
+#endif
 	return 0;
 }
 
diff -puN drivers/acpi/sleep/wakeup.c~acpi-ia64-wake-on-lan-fix drivers/acpi/sleep/wakeup.c
--- devel/drivers/acpi/sleep/wakeup.c~acpi-ia64-wake-on-lan-fix	2006-03-28 14:03:06.000000000 -0800
+++ devel-akpm/drivers/acpi/sleep/wakeup.c	2006-03-28 14:03:06.000000000 -0800
@@ -48,6 +48,7 @@ void acpi_enable_wakeup_device_prep(u8 s
 	}
 	spin_unlock(&acpi_device_lock);
 }
+#endif
 
 /**
  * acpi_enable_wakeup_device - enable wakeup devices
@@ -100,6 +101,7 @@ void acpi_enable_wakeup_device(u8 sleep_
 	spin_unlock(&acpi_device_lock);
 }
 
+#ifdef CONFIG_ACPI_SLEEP
 /**
  * acpi_disable_wakeup_device - disable devices' wakeup capability
  *	@sleep_state:	ACPI state
_

^ permalink raw reply

* [patch 21/26] acpi EC: acpi-ecdt-uid-hack
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, jirislaby, luming.yu


From: Jiri Slaby <jirislaby@gmail.com>

On some boxes ecdt uid may be equal to 0, so do not test for uids equality,
so that fake handler will be unconditionally removed to allow loading the
real one.

See http://bugzilla.kernel.org/show_bug.cgi?id=6111

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Luming Yu <luming.yu@intel.com>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/ec.c |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)

diff -puN drivers/acpi/ec.c~acpi-ec-acpi-ecdt-uid-hack drivers/acpi/ec.c
--- devel/drivers/acpi/ec.c~acpi-ec-acpi-ecdt-uid-hack	2006-03-28 14:03:07.000000000 -0800
+++ devel-akpm/drivers/acpi/ec.c	2006-03-28 14:03:07.000000000 -0800
@@ -989,7 +989,6 @@ static int acpi_ec_poll_add(struct acpi_
 	int result = 0;
 	acpi_status status = AE_OK;
 	union acpi_ec *ec = NULL;
-	unsigned long uid;
 
 	ACPI_FUNCTION_TRACE("acpi_ec_add");
 
@@ -1012,10 +1011,9 @@ static int acpi_ec_poll_add(struct acpi_
 	acpi_evaluate_integer(ec->common.handle, "_GLK", NULL,
 			      &ec->common.global_lock);
 
-	/* If our UID matches the UID for the ECDT-enumerated EC,
-	   we now have the *real* EC info, so kill the makeshift one. */
-	acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid);
-	if (ec_ecdt && ec_ecdt->common.uid == uid) {
+	/* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
+	   http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
+	if (ec_ecdt) {
 		acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
 						  ACPI_ADR_SPACE_EC,
 						  &acpi_ec_space_handler);
@@ -1059,7 +1057,6 @@ static int acpi_ec_intr_add(struct acpi_
 	int result = 0;
 	acpi_status status = AE_OK;
 	union acpi_ec *ec = NULL;
-	unsigned long uid;
 
 	ACPI_FUNCTION_TRACE("acpi_ec_add");
 
@@ -1085,10 +1082,9 @@ static int acpi_ec_intr_add(struct acpi_
 	acpi_evaluate_integer(ec->common.handle, "_GLK", NULL,
 			      &ec->common.global_lock);
 
-	/* If our UID matches the UID for the ECDT-enumerated EC,
-	   we now have the *real* EC info, so kill the makeshift one. */
-	acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid);
-	if (ec_ecdt && ec_ecdt->common.uid == uid) {
+	/* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
+	   http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
+	if (ec_ecdt) {
 		acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
 						  ACPI_ADR_SPACE_EC,
 						  &acpi_ec_space_handler);
_

^ permalink raw reply

* [patch 22/26] acpi memory hotplug cannot manage _CRS with plural resoureces
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, kamezawa.hiroyu, kaneshige.kenji


From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

Current acpi memory hotplug just looks into the first entry of resources in
_CRS.  But, _CRS can contain plural resources.  So, if _CRS contains plural
resoureces, acpi memory hot add cannot add all memory.

With this patch, acpi memory hotplug can deal with Memory Device, whose
_CRS contains plural resources.

Tested on ia64 memory hotplug test envrionment (not emulation, uses alpha
version firmware which supports dynamic reconfiguration of NUMA.)

Note: Microsoft's Windows Server 2003 requires big (>4G)resoureces to be
      divided into small (<4G) resources. looks crazy, but not invalid.
      (See http://www.microsoft.com/whdc/system/pnppwr/hotadd/hotaddmem.mspx)
      For this reason, a firmware vendor who supports Windows writes plural
      resources in a _CRS even if they are contiguous.

[akpm@osdl.org: export acpi_os_allocate]
Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/acpi_memhotplug.c |  109 ++++++++++++++++++++++---------
 drivers/acpi/osl.c             |    1 
 2 files changed, 79 insertions(+), 31 deletions(-)

diff -puN drivers/acpi/acpi_memhotplug.c~acpi-memory-hotplug-cannot-manage-_crs-with-plural-resoureces drivers/acpi/acpi_memhotplug.c
--- devel/drivers/acpi/acpi_memhotplug.c~acpi-memory-hotplug-cannot-manage-_crs-with-plural-resoureces	2006-03-28 14:03:07.000000000 -0800
+++ devel-akpm/drivers/acpi/acpi_memhotplug.c	2006-03-28 14:03:07.000000000 -0800
@@ -68,44 +68,76 @@ static struct acpi_driver acpi_memory_de
 		},
 };
 
+struct acpi_memory_info {
+	struct list_head list;
+	u64 start_addr;		/* Memory Range start physical addr */
+	u64 length;		/* Memory Range length */
+	unsigned short caching;	/* memory cache attribute */
+	unsigned short write_protect;	/* memory read/write attribute */
+	unsigned int enabled:1;
+};
+
 struct acpi_memory_device {
 	acpi_handle handle;
 	unsigned int state;	/* State of the memory device */
-	unsigned short caching;	/* memory cache attribute */
-	unsigned short write_protect;	/* memory read/write attribute */
-	u64 start_addr;		/* Memory Range start physical addr */
-	u64 length;		/* Memory Range length */
+	struct list_head res_list;
 };
 
+static acpi_status
+acpi_memory_get_resource(struct acpi_resource *resource, void *context)
+{
+	struct acpi_memory_device *mem_device = context;
+	struct acpi_resource_address64 address64;
+	struct acpi_memory_info *info, *new;
+	acpi_status status;
+
+	status = acpi_resource_to_address64(resource, &address64);
+	if (ACPI_FAILURE(status) ||
+	    (address64.resource_type != ACPI_MEMORY_RANGE))
+		return AE_OK;
+
+	list_for_each_entry(info, &mem_device->res_list, list) {
+		/* Can we combine the resource range information? */
+		if ((info->caching == address64.info.mem.caching) &&
+		    (info->write_protect == address64.info.mem.write_protect) &&
+		    (info->start_addr + info->length == address64.minimum)) {
+			info->length += address64.address_length;
+			return AE_OK;
+		}
+	}
+
+	new = acpi_os_allocate(sizeof(struct acpi_memory_info));
+	if (!new)
+		return AE_ERROR;
+
+	memset(new, 0, sizeof(*new));
+	INIT_LIST_HEAD(&new->list);
+	new->caching = address64.info.mem.caching;
+	new->write_protect = address64.info.mem.write_protect;
+	new->start_addr = address64.minimum;
+	new->length = address64.address_length;
+	list_add_tail(&new->list, &mem_device->res_list);
+
+	return AE_OK;
+}
+
 static int
 acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
 {
 	acpi_status status;
-	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
-	struct acpi_resource *resource = NULL;
-	struct acpi_resource_address64 address64;
+	struct acpi_memory_info *info, *n;
 
 	ACPI_FUNCTION_TRACE("acpi_memory_get_device_resources");
 
 	/* Get the range from the _CRS */
-	status = acpi_get_current_resources(mem_device->handle, &buffer);
-	if (ACPI_FAILURE(status))
+	status = acpi_walk_resources(mem_device->handle, METHOD_NAME__CRS,
+				     acpi_memory_get_resource, mem_device);
+	if (ACPI_FAILURE(status)) {
+		list_for_each_entry_safe(info, n, &mem_device->res_list, list)
+			acpi_os_free(info);
 		return_VALUE(-EINVAL);
-
-	resource = (struct acpi_resource *)buffer.pointer;
-	status = acpi_resource_to_address64(resource, &address64);
-	if (ACPI_SUCCESS(status)) {
-		if (address64.resource_type == ACPI_MEMORY_RANGE) {
-			/* Populate the structure */
-			mem_device->caching = address64.info.mem.caching;
-			mem_device->write_protect =
-			    address64.info.mem.write_protect;
-			mem_device->start_addr = address64.minimum;
-			mem_device->length = address64.address_length;
-		}
 	}
 
-	acpi_os_free(buffer.pointer);
 	return_VALUE(0);
 }
 
@@ -180,7 +212,8 @@ static int acpi_memory_check_device(stru
 
 static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
 {
-	int result;
+	int result, num_enabled = 0;
+	struct acpi_memory_info *info;
 
 	ACPI_FUNCTION_TRACE("acpi_memory_enable_device");
 
@@ -195,12 +228,21 @@ static int acpi_memory_enable_device(str
 	/*
 	 * Tell the VM there is more memory here...
 	 * Note: Assume that this function returns zero on success
+    	 * We don't have memory-hot-add rollback function,now.
+         * (i.e. memory-hot-remove function)
 	 */
-	result = add_memory(mem_device->start_addr, mem_device->length);
-	if (result) {
+	list_for_each_entry(info, &mem_device->res_list, list) {
+		result = add_memory(info->start_addr, info->length);
+		if (result)
+			continue;
+		info->enabled = 1;
+		num_enabled++;
+	}
+
+	if (!num_enabled) {
 		ACPI_ERROR((AE_INFO, "add_memory failed"));
 		mem_device->state = MEMORY_INVALID_STATE;
-		return result;
+		return -EINVAL;
 	}
 
 	return result;
@@ -244,8 +286,7 @@ static int acpi_memory_powerdown_device(
 static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
 {
 	int result;
-	u64 start = mem_device->start_addr;
-	u64 len = mem_device->length;
+	struct acpi_memory_info *info, *n;
 
 	ACPI_FUNCTION_TRACE("acpi_memory_disable_device");
 
@@ -253,9 +294,14 @@ static int acpi_memory_disable_device(st
 	 * Ask the VM to offline this memory range.
 	 * Note: Assume that this function returns zero on success
 	 */
-	result = remove_memory(start, len);
-	if (result)
-		return_VALUE(result);
+	list_for_each_entry_safe(info, n, &mem_device->res_list, list) {
+		if (info->enabled) {
+			result = remove_memory(info->start_addr, info->length);
+			if (result)
+				return_VALUE(result);
+		}
+		acpi_os_free(info);
+	}
 
 	/* Power-off and eject the device */
 	result = acpi_memory_powerdown_device(mem_device);
@@ -347,6 +393,7 @@ static int acpi_memory_device_add(struct
 		return_VALUE(-ENOMEM);
 	memset(mem_device, 0, sizeof(struct acpi_memory_device));
 
+	INIT_LIST_HEAD(&mem_device->res_list);
 	mem_device->handle = device->handle;
 	sprintf(acpi_device_name(device), "%s", ACPI_MEMORY_DEVICE_NAME);
 	sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS);
diff -puN drivers/acpi/osl.c~acpi-memory-hotplug-cannot-manage-_crs-with-plural-resoureces drivers/acpi/osl.c
--- devel/drivers/acpi/osl.c~acpi-memory-hotplug-cannot-manage-_crs-with-plural-resoureces	2006-03-28 14:03:07.000000000 -0800
+++ devel-akpm/drivers/acpi/osl.c	2006-03-28 14:03:07.000000000 -0800
@@ -145,6 +145,7 @@ void *acpi_os_allocate(acpi_size size)
 	else
 		return kmalloc(size, GFP_KERNEL);
 }
+EXPORT_SYMBOL(acpi_os_allocate);
 
 void acpi_os_free(void *ptr)
 {
_

^ permalink raw reply

* [patch 23/26] x86_64: Remove entries in /sys/firmware/acpi for processor also
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, ashok.raj, ak


From: Ashok Raj <ashok.raj@intel.com>

Processor entries under /sys/firmware/acpi/namespace/ACPI/_SB/CPU* were not
being removed due to acpi_bus_trim not asking for it just for processors. 
Without which a new hot-add after a remove doesnt call appropriate init
functions resulting in subsequent hot-add for same cpu failing.

Not clear why we restricted that to non-processor devices.

Signed-off-by: Ashok Raj <ashok.raj@intel.com>
Cc: Andi Kleen <ak@muc.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/scan.c |    5 +----
 1 files changed, 1 insertion(+), 4 deletions(-)

diff -puN drivers/acpi/scan.c~remove-entries-in-sys-firmware-acpi-for-processor-also drivers/acpi/scan.c
--- devel/drivers/acpi/scan.c~remove-entries-in-sys-firmware-acpi-for-processor-also	2006-03-28 14:03:07.000000000 -0800
+++ devel-akpm/drivers/acpi/scan.c	2006-03-28 14:03:07.000000000 -0800
@@ -433,10 +433,7 @@ acpi_eject_store(struct acpi_device *dev
 	islockable = device->flags.lockable;
 	handle = device->handle;
 
-	if (type == ACPI_TYPE_PROCESSOR)
-		result = acpi_bus_trim(device, 0);
-	else
-		result = acpi_bus_trim(device, 1);
+	result = acpi_bus_trim(device, 1);
 
 	if (!result)
 		result = acpi_eject_operation(handle, islockable);
_

^ permalink raw reply

* [patch 19/26] acpi signedness fix
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, ashok.raj, davej, kaneshige.kenji


From: Ashok Raj <ashok.raj@intel.com>

Local apic entries are only 8 bits, but it seemed to not be caught with u8
return value result in the check

cpu_index >= NR_CPUS becomming always false.

drivers/acpi/processor_core.c: In function `acpi_processor_get_info':
drivers/acpi/processor_core.c:483: warning: comparison is always false due to limited range of data type

Signed-off-by: Ashok Raj <ashok.raj@intel.com>
Cc: "Brown, Len" <len.brown@intel.com>
Cc: Dave Jones <davej@codemonkey.org.uk>
Cc: Kenji Kaneshige <kaneshige.kenji@soft.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/processor_core.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff -puN drivers/acpi/processor_core.c~acpi-signedness-fix-2 drivers/acpi/processor_core.c
--- devel/drivers/acpi/processor_core.c~acpi-signedness-fix-2	2006-03-28 14:03:06.000000000 -0800
+++ devel-akpm/drivers/acpi/processor_core.c	2006-03-28 14:03:06.000000000 -0800
@@ -382,7 +382,7 @@ static int acpi_processor_remove_fs(stru
 
 /* Use the acpiid in MADT to map cpus in case of SMP */
 #ifndef CONFIG_SMP
-#define convert_acpiid_to_cpu(acpi_id) (0xff)
+#define convert_acpiid_to_cpu(acpi_id) (-1)
 #else
 
 #ifdef CONFIG_IA64
@@ -395,7 +395,7 @@ static int acpi_processor_remove_fs(stru
 #define ARCH_BAD_APICID		(0xff)
 #endif
 
-static u8 convert_acpiid_to_cpu(u8 acpi_id)
+static int convert_acpiid_to_cpu(u8 acpi_id)
 {
 	u16 apic_id;
 	int i;
@@ -421,7 +421,7 @@ static int acpi_processor_get_info(struc
 	acpi_status status = 0;
 	union acpi_object object = { 0 };
 	struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
-	u8 cpu_index;
+	int cpu_index;
 	static int cpu0_initialized;
 
 	ACPI_FUNCTION_TRACE("acpi_processor_get_info");
@@ -466,7 +466,7 @@ static int acpi_processor_get_info(struc
 	cpu_index = convert_acpiid_to_cpu(pr->acpi_id);
 
 	/* Handle UP system running SMP kernel, with no LAPIC in MADT */
-	if (!cpu0_initialized && (cpu_index == 0xff) &&
+	if (!cpu0_initialized && (cpu_index == -1) &&
 	    (num_online_cpus() == 1)) {
 		cpu_index = 0;
 	}
@@ -480,7 +480,7 @@ static int acpi_processor_get_info(struc
 	 *  less than the max # of CPUs. They should be ignored _iff
 	 *  they are physically not present.
 	 */
-	if (cpu_index >= NR_CPUS) {
+	if (cpu_index == -1) {
 		if (ACPI_FAILURE
 		    (acpi_processor_hotadd_init(pr->handle, &pr->id))) {
 			ACPI_ERROR((AE_INFO,
_

^ permalink raw reply

* [patch 24/26] x86_64: Remove unnecessary lapic definition from acpidef.h
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, ashok.raj, ak


From: Ashok Raj <ashok.raj@intel.com>

Dont know why this exists...  just happened to trip me when i used a variable
name with lapic, and until i looked at the pre-processed output couldnt figure
out we had a lame definition like this.

Hope I am not breaking anything here..

Signed-off-by: Ashok Raj <ashok.raj@intel.com>
Cc: Andi Kleen <ak@muc.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 include/asm-i386/apicdef.h   |    1 -
 include/asm-x86_64/apicdef.h |    2 --
 2 files changed, 3 deletions(-)

diff -puN include/asm-i386/apicdef.h~remove-unnecessary-lapic-definition-from-acpidefh include/asm-i386/apicdef.h
--- devel/include/asm-i386/apicdef.h~remove-unnecessary-lapic-definition-from-acpidefh	2006-03-28 14:03:07.000000000 -0800
+++ devel-akpm/include/asm-i386/apicdef.h	2006-03-28 14:03:07.000000000 -0800
@@ -120,7 +120,6 @@
  */
 #define u32 unsigned int
 
-#define lapic ((volatile struct local_apic *)APIC_BASE)
 
 struct local_apic {
 
diff -puN include/asm-x86_64/apicdef.h~remove-unnecessary-lapic-definition-from-acpidefh include/asm-x86_64/apicdef.h
--- devel/include/asm-x86_64/apicdef.h~remove-unnecessary-lapic-definition-from-acpidefh	2006-03-28 14:03:07.000000000 -0800
+++ devel-akpm/include/asm-x86_64/apicdef.h	2006-03-28 14:03:07.000000000 -0800
@@ -137,8 +137,6 @@
  */
 #define u32 unsigned int
 
-#define lapic ((volatile struct local_apic *)APIC_BASE)
-
 struct local_apic {
 
 /*000*/	struct { u32 __reserved[4]; } __reserved_01;
_

^ permalink raw reply

* [patch 26/26] Catch notification of memory add event of ACPI via container driver. (avoid redundant call add_memory)
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, y-goto, haveblue


From: Yasunori Goto <y-goto@jp.fujitsu.com>

When acpi_memory_device_init() is called at boottime to register struct
memory acpi_memory_device, acpi_bus_add() are called via
acpi_driver_attach().

But it also calls ops->start() function.  It is called even if the memory
blocks are initialized at early boottime.  In this case add_memory() return
-EEXIST, and the memory blocks becomes INVALID state even if it is normal.

This is patch to avoid calling add_memory() for already available memory.

[akpm@osdl.org: coding cleanups]
Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: "Brown, Len" <len.brown@intel.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/acpi_memhotplug.c |   11 +++++++++++
 1 files changed, 11 insertions(+)

diff -puN drivers/acpi/acpi_memhotplug.c~catch-notification-of-memory-add-event-of-acpi-via-container-driveravoid-redundant-call-add_memory drivers/acpi/acpi_memhotplug.c
--- devel/drivers/acpi/acpi_memhotplug.c~catch-notification-of-memory-add-event-of-acpi-via-container-driveravoid-redundant-call-add_memory	2006-03-28 14:03:08.000000000 -0800
+++ devel-akpm/drivers/acpi/acpi_memhotplug.c	2006-03-28 14:03:08.000000000 -0800
@@ -234,6 +234,17 @@ static int acpi_memory_enable_device(str
          * (i.e. memory-hot-remove function)
 	 */
 	list_for_each_entry(info, &mem_device->res_list, list) {
+		u64 start_pfn, end_pfn;
+
+		start_pfn = info->start_addr >> PAGE_SHIFT;
+		end_pfn = (info->start_addr + info->length - 1) >> PAGE_SHIFT;
+
+		if (pfn_valid(start_pfn) || pfn_valid(end_pfn)) {
+			/* already enabled. try next area */
+			num_enabled++;
+			continue;
+		}
+
 		result = add_memory(info->start_addr, info->length);
 		if (result)
 			continue;
_

^ permalink raw reply

* [patch 25/26] Catch notification of memory add event of ACPI via container driver. (register start func for memory device)
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, y-goto, haveblue


From: Yasunori Goto <y-goto@jp.fujitsu.com>

This is a patch to call add_memroy() when notify reaches for new node's add
event.

When new node is added, notify of ACPI reaches container device which means
the node.

Container device driver calls acpi_bus_scan() to find and add belonging
devices (which means cpu, memory and so on).  Its function calls add and
start function of belonging devices's driver.

Howevever, current memory hotplug driver just register add function to
create sysfs file for its memory.  But, acpi_memory_enable_device() is not
called because it is considered just the case that notify reaches memory
device directly.  So, if notify reaches container device nothing can call
add_memory().

This is a patch to create start function which calls add_memory(). 
add_memory() can be called by this when notify reaches container device.

[akpm@osdl.org: coding cleanups]
Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: "Brown, Len" <len.brown@intel.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/acpi/acpi_memhotplug.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+)

diff -puN drivers/acpi/acpi_memhotplug.c~catch-notification-of-memory-add-event-of-acpi-via-container-driver-register-start-func-for-memory-device drivers/acpi/acpi_memhotplug.c
--- devel/drivers/acpi/acpi_memhotplug.c~catch-notification-of-memory-add-event-of-acpi-via-container-driver-register-start-func-for-memory-device	2006-03-28 14:03:08.000000000 -0800
+++ devel-akpm/drivers/acpi/acpi_memhotplug.c	2006-03-28 14:03:08.000000000 -0800
@@ -57,6 +57,7 @@ MODULE_LICENSE("GPL");
 
 static int acpi_memory_device_add(struct acpi_device *device);
 static int acpi_memory_device_remove(struct acpi_device *device, int type);
+static int acpi_memory_device_start(struct acpi_device *device);
 
 static struct acpi_driver acpi_memory_device_driver = {
 	.name = ACPI_MEMORY_DEVICE_DRIVER_NAME,
@@ -65,6 +66,7 @@ static struct acpi_driver acpi_memory_de
 	.ops = {
 		.add = acpi_memory_device_add,
 		.remove = acpi_memory_device_remove,
+		.start = acpi_memory_device_start,
 		},
 };
 
@@ -429,6 +431,25 @@ static int acpi_memory_device_remove(str
 	return_VALUE(0);
 }
 
+static int acpi_memory_device_start (struct acpi_device *device)
+{
+	struct acpi_memory_device *mem_device;
+	int result = 0;
+
+	ACPI_FUNCTION_TRACE("acpi_memory_device_start");
+
+	mem_device = acpi_driver_data(device);
+
+	if (!acpi_memory_check_device(mem_device)) {
+		/* call add_memory func */
+		result = acpi_memory_enable_device(mem_device);
+		if (result)
+			ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+				"Error in acpi_memory_enable_device\n"));
+	}
+	return_VALUE(result);
+}
+
 /*
  * Helper function to check for memory device
  */
_

^ permalink raw reply

* [patch 20/26] ACPI should depend on, not select PCI
From: akpm @ 2006-03-28 22:03 UTC (permalink / raw)
  To: len.brown; +Cc: linux-acpi, akpm, bunk


From: Adrian Bunk <bunk@stusta.de>

ACPI should depend on, not select PCI.

Otherwise, illegal configurations like X86_VOYAGER=y, PCI=y are
possible.

This patch also fixes the options select'ing ACPI to also select PCI.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 arch/ia64/Kconfig    |    1 +
 arch/x86_64/Kconfig  |    1 +
 drivers/acpi/Kconfig |    3 +--
 3 files changed, 3 insertions(+), 2 deletions(-)

diff -puN arch/ia64/Kconfig~acpi-should-depend-on-not-select-pci arch/ia64/Kconfig
--- devel/arch/ia64/Kconfig~acpi-should-depend-on-not-select-pci	2006-03-28 14:03:06.000000000 -0800
+++ devel-akpm/arch/ia64/Kconfig	2006-03-28 14:03:06.000000000 -0800
@@ -77,6 +77,7 @@ choice
 config IA64_GENERIC
 	bool "generic"
 	select ACPI
+	select PCI
 	select NUMA
 	select ACPI_NUMA
 	help
diff -puN arch/x86_64/Kconfig~acpi-should-depend-on-not-select-pci arch/x86_64/Kconfig
--- devel/arch/x86_64/Kconfig~acpi-should-depend-on-not-select-pci	2006-03-28 14:03:06.000000000 -0800
+++ devel-akpm/arch/x86_64/Kconfig	2006-03-28 14:03:06.000000000 -0800
@@ -289,6 +289,7 @@ config X86_64_ACPI_NUMA
        bool "ACPI NUMA detection"
        depends on NUMA
        select ACPI 
+	select PCI
        select ACPI_NUMA
        default y
        help
diff -puN drivers/acpi/Kconfig~acpi-should-depend-on-not-select-pci drivers/acpi/Kconfig
--- devel/drivers/acpi/Kconfig~acpi-should-depend-on-not-select-pci	2006-03-28 14:03:06.000000000 -0800
+++ devel-akpm/drivers/acpi/Kconfig	2006-03-28 14:03:06.000000000 -0800
@@ -10,9 +10,8 @@ menu "ACPI (Advanced Configuration and P
 config ACPI
 	bool "ACPI Support"
 	depends on IA64 || X86
+	depends on PCI
 	select PM
-	select PCI
-
 	default y
 	---help---
 	  Advanced Configuration and Power Interface (ACPI) support for 
_

^ permalink raw reply

* Re: [Patch:001/004]Unify pxm_to_node id ver.3.(generic code)
From: Yasunori Goto @ 2006-03-29  1:28 UTC (permalink / raw)
  To: Andrew Morton
  Cc: tony.luck, ak, len.brown, linux-kernel, linux-acpi, linux-ia64,
	discuss
In-Reply-To: <20060328130736.5a4273d9.akpm@osdl.org>

> Yasunori Goto <y-goto@jp.fujitsu.com> wrote:
> >
> > +/* Proximity bitmap length */
> >  +#ifdef CONFIG_NR_NODES_CHANGABLE
> >  +#define MAX_PXM_DOMAINS CONFIG_NR_NODES
> >  +#else
> >  +#define MAX_PXM_DOMAINS (256)
> >  +#endif
> 
> I don't think we need CONFIG_NR_NODES_CHANGABLE (it is spelled
> "changeable", btw).
> 
> If the architecture wants to support changing of CONFIG_NR_NODES then it
> can permit CONFIG_NR_NODES to be changed in its Kconfig implementation.
> 
> If the architecture doesn't want to permit changing of CONFIG_NR_NODES
> then it should simply hardwire CONFIG_NR_NODES to the chosen value in
> its Kconfig.
> 
> So all architectures which use acpi_numa must implement CONFIG_NR_NODES.
> 
> In fact, it would probably make sense to require that all NUMA-supporting
> archtectures implement CONFIG_NR_NODES.
> 
> Also, we already have NODES_SHIFT defined in include/asm-*/numnodes.h. 
> What's the relationship between that and CONFIG_NR_NODES?  It seems that we
> want to derive NODES_SHIFT from CONFIG_NR_NODES.
> 
> Was ia64's CONFIG_IA64_NR_NODES the best choice?  Should ia64 instead have
> made NODES_SHIFT Kconfigurable, and derived its max-nr_nodes from that?
> 
> It's all a bit of a pickle.
> 
> 
> I guess for now a suitable approach would be to make all numa-using
> architectures define CONFIG_NR_NODES, and to leave that rather
> unpleasant-looking code in include/asm-ia64/numnodes.h as it is.
> 

Ahhh.
I understand what you wish at last.

I thought relationship between pxm and nid is just acpi-using
architecture's issue.
But, it becomes for all numa-using architecture's issue.

Ok. I'll change it.

Thanks.

-- 
Yasunori Goto 



^ permalink raw reply

* DSDT view.php doesnt work
From: Ahmad Salim Doost @ 2006-03-29 10:25 UTC (permalink / raw)
  To: linux-acpi

Hello dear Web-Master,
all the links of DSDT doesnt work. For example the following link:
http://acpi.sourceforge.net/dsdt/view.php

Please repair it soon and write me, because I need it.

Thank you

Salim


^ permalink raw reply

* RE: DSDT view.php doesnt work
From: Yu, Ling L @ 2006-03-29 14:39 UTC (permalink / raw)
  To: Ahmad Salim Doost; +Cc: linux-acpi

Hi, Salim
These links has been repaired, please try again, sorry for causing any
inconvenience.

Thanks
- Ling


>-----Original Message-----
>From: linux-acpi-owner@vger.kernel.org
[mailto:linux-acpi-owner@vger.kernel.org] On
>Behalf Of Ahmad Salim Doost
>Sent: Wednesday, March 29, 2006 6:26 PM
>To: linux-acpi@vger.kernel.org
>Subject: DSDT view.php doesnt work
>
>Hello dear Web-Master,
>all the links of DSDT doesnt work. For example the following link:
>http://acpi.sourceforge.net/dsdt/view.php
>
>Please repair it soon and write me, because I need it.
>
>Thank you
>
>Salim
>
>-
>To unsubscribe from this list: send the line "unsubscribe linux-acpi"
in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* no /proc/acpi, trying to dump dsdt to a file
From: glen martin @ 2006-03-29 17:50 UTC (permalink / raw)
  To: linux-acpi

Greetings,

I've done some searches, poked around in the kernel source and doc, 
can't seem to find anything relevant.

kernel is 2.6.15, with gentoo patches and the patch to load a dsdt from 
initrd.

I'm trying to dump my dsdt, but there is no /proc/acpi, let alone 
/proc/acpi/dsdt.

Is there something special needed to make /proc/acpi show up? Or other 
way to get at the existing dsdt in this situation?

The dsdt table in my BIOS is broken, in case that's relevant and 
nonobvious. :)  I'm hoping the broken existing table isn't what is 
blocking the /proc/acpi ...

The other interesting (to me, anyway) snippet is that CONFIG_ACPI_SYSTEM 
doesn't show up when 'make menuconfig', but is set to 'Y' in the .config 
file.  /drivers/acpi/system.o is built.

I've tried booting with various kernel parameters, disabling variously 
acpi, apic and lapic. no difference in behavior. right now they're all 
turned on (no special parms on kernel line).

Here's a snippet from my .config

#
# ACPI (Advanced Configuration and Power Interface) Support
#
CONFIG_ACPI=y
# CONFIG_ACPI_AC is not set
# CONFIG_ACPI_BATTERY is not set
CONFIG_ACPI_BUTTON=y
CONFIG_ACPI_VIDEO=y
# CONFIG_ACPI_HOTKEY is not set
CONFIG_ACPI_FAN=y
CONFIG_ACPI_PROCESSOR=y
CONFIG_ACPI_THERMAL=y
# CONFIG_ACPI_ASUS is not set
# CONFIG_ACPI_IBM is not set
# CONFIG_ACPI_TOSHIBA is not set
CONFIG_ACPI_CUSTOM_DSDT_INITRD=y
CONFIG_ACPI_BLACKLIST_YEAR=0
CONFIG_ACPI_DEBUG=y
CONFIG_ACPI_EC=y
CONFIG_ACPI_POWER=y
CONFIG_ACPI_SYSTEM=y
CONFIG_X86_PM_TIMER=y
# CONFIG_ACPI_CONTAINER is not set

Here's the dmesg output when loading the existing BIOS DSDT, in case 
that is relevant.

ACPI: Looking for DSDT in initramfs... error, file /DSDT.aml not found.
 tbxface-0109 [02] load_tables           : ACPI Tables successfully acquired
nssearch-0311: *** Error: ns_search_and_enter: Bad character in ACPI 
Name: 43035350
 dswload-0292: *** Error: Looking up [0x43035350] (NON-ASCII)
 in namespace, AE_BAD_CHARACTER
  psloop-0287 [09] ps_parse_loop         : During name lookup/catalog, 
AE_BAD_CHARACTER
 tbxface-0115: *** Error: acpi_load_tables: Could not load namespace: 
AE_BAD_CHARACTER
 tbxface-0123: *** Error: acpi_load_tables: Could not load tables: 
AE_BAD_CHARACTER
ACPI: Unable to load the System Description Tables


Any suggestions?

Thanks in advance,

glen


^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox