[tip:x86/acpi] ACPI: Implement physical address table override

2012-09-30 Thread tip-bot for Thomas Renninger
Commit-ID:  b2a35003dfbcc7b7a5e5c6e524e7d49ba66e0bb5
Gitweb: http://git.kernel.org/tip/b2a35003dfbcc7b7a5e5c6e524e7d49ba66e0bb5
Author: Thomas Renninger 
AuthorDate: Mon, 1 Oct 2012 00:23:55 +0200
Committer:  H. Peter Anvin 
CommitDate: Sun, 30 Sep 2012 18:03:29 -0700

ACPI: Implement physical address table override

Previous patches stored ACPI tables provided via initrd in a memblock reserved
area.
If a table is loaded and the table type of an initrd provided one matches,
the one from initrd is prefered.
In case of a SSDT table, the OEM table id also has to match.

ACPI tables can be loaded at boot time (static table pointers in XSDT),
but also dynamically any time later via ASL commands load() or loadTable().
The override mechanism always works.

Signed-off-by: Thomas Renninger 
Link: http://lkml.kernel.org/r/1349043837-22659-5-git-send-email-tr...@suse.de
Cc: Len Brown 
Cc: Robert Moore 
Cc: Yinghai Lu 
Cc: Eric Piel 
Signed-off-by: H. Peter Anvin 
---
 drivers/acpi/osl.c |   60 ---
 1 files changed, 56 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index b20b079..007224b 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -681,12 +681,64 @@ acpi_os_table_override(struct acpi_table_header * 
existing_table,
 
 acpi_status
 acpi_os_physical_table_override(struct acpi_table_header *existing_table,
-   acpi_physical_address * new_address,
-   u32 *new_table_length)
+   acpi_physical_address *address,
+   u32 *table_length)
 {
-   return AE_SUPPORT;
-}
+#ifndef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
+   *table_length = 0;
+   *address = 0;
+   return AE_OK;
+#else
+   int table_offset = 0;
+   struct acpi_table_header *table;
+
+   *table_length = 0;
+   *address = 0;
+
+   if (!acpi_tables_addr)
+   return AE_OK;
+
+   do {
+   if (table_offset + ACPI_HEADER_SIZE > all_tables_size) {
+   WARN_ON(1);
+   return AE_OK;
+   }
+
+   table = acpi_os_map_memory(acpi_tables_addr + table_offset,
+  ACPI_HEADER_SIZE);
+
+   if (table_offset + table->length > all_tables_size) {
+   acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
+   WARN_ON(1);
+   return AE_OK;
+   }
 
+   table_offset += table->length;
+
+   if (memcmp(existing_table->signature, table->signature, 4)) {
+   acpi_os_unmap_memory(table,
+ACPI_HEADER_SIZE);
+   continue;
+   }
+
+   /* Only override tables with matching oem id */
+   if (memcmp(table->oem_table_id, existing_table->oem_table_id,
+  ACPI_OEM_TABLE_ID_SIZE)) {
+   acpi_os_unmap_memory(table,
+ACPI_HEADER_SIZE);
+   continue;
+   }
+
+   table_offset -= table->length;
+   *table_length = table->length;
+   acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
+   *address = acpi_tables_addr + table_offset;
+   break;
+   } while (table_offset + ACPI_HEADER_SIZE < all_tables_size);
+
+   return AE_OK;
+#endif
+}
 
 static irqreturn_t acpi_irq(int irq, void *dev_id)
 {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/acpi] ACPI: Implement physical address table override

2012-09-30 Thread tip-bot for Thomas Renninger
Commit-ID:  b2a35003dfbcc7b7a5e5c6e524e7d49ba66e0bb5
Gitweb: http://git.kernel.org/tip/b2a35003dfbcc7b7a5e5c6e524e7d49ba66e0bb5
Author: Thomas Renninger tr...@suse.de
AuthorDate: Mon, 1 Oct 2012 00:23:55 +0200
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Sun, 30 Sep 2012 18:03:29 -0700

ACPI: Implement physical address table override

Previous patches stored ACPI tables provided via initrd in a memblock reserved
area.
If a table is loaded and the table type of an initrd provided one matches,
the one from initrd is prefered.
In case of a SSDT table, the OEM table id also has to match.

ACPI tables can be loaded at boot time (static table pointers in XSDT),
but also dynamically any time later via ASL commands load() or loadTable().
The override mechanism always works.

Signed-off-by: Thomas Renninger tr...@suse.de
Link: http://lkml.kernel.org/r/1349043837-22659-5-git-send-email-tr...@suse.de
Cc: Len Brown l...@kernel.org
Cc: Robert Moore robert.mo...@intel.com
Cc: Yinghai Lu ying...@kernel.org
Cc: Eric Piel eric.p...@tremplin-utc.net
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 drivers/acpi/osl.c |   60 ---
 1 files changed, 56 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index b20b079..007224b 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -681,12 +681,64 @@ acpi_os_table_override(struct acpi_table_header * 
existing_table,
 
 acpi_status
 acpi_os_physical_table_override(struct acpi_table_header *existing_table,
-   acpi_physical_address * new_address,
-   u32 *new_table_length)
+   acpi_physical_address *address,
+   u32 *table_length)
 {
-   return AE_SUPPORT;
-}
+#ifndef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
+   *table_length = 0;
+   *address = 0;
+   return AE_OK;
+#else
+   int table_offset = 0;
+   struct acpi_table_header *table;
+
+   *table_length = 0;
+   *address = 0;
+
+   if (!acpi_tables_addr)
+   return AE_OK;
+
+   do {
+   if (table_offset + ACPI_HEADER_SIZE  all_tables_size) {
+   WARN_ON(1);
+   return AE_OK;
+   }
+
+   table = acpi_os_map_memory(acpi_tables_addr + table_offset,
+  ACPI_HEADER_SIZE);
+
+   if (table_offset + table-length  all_tables_size) {
+   acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
+   WARN_ON(1);
+   return AE_OK;
+   }
 
+   table_offset += table-length;
+
+   if (memcmp(existing_table-signature, table-signature, 4)) {
+   acpi_os_unmap_memory(table,
+ACPI_HEADER_SIZE);
+   continue;
+   }
+
+   /* Only override tables with matching oem id */
+   if (memcmp(table-oem_table_id, existing_table-oem_table_id,
+  ACPI_OEM_TABLE_ID_SIZE)) {
+   acpi_os_unmap_memory(table,
+ACPI_HEADER_SIZE);
+   continue;
+   }
+
+   table_offset -= table-length;
+   *table_length = table-length;
+   acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
+   *address = acpi_tables_addr + table_offset;
+   break;
+   } while (table_offset + ACPI_HEADER_SIZE  all_tables_size);
+
+   return AE_OK;
+#endif
+}
 
 static irqreturn_t acpi_irq(int irq, void *dev_id)
 {
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/acpi] ACPI: Implement physical address table override

2012-09-27 Thread tip-bot for Thomas Renninger
Commit-ID:  6fd61f98ef5afcf1841bcd1aaf792f9ad42d16bc
Gitweb: http://git.kernel.org/tip/6fd61f98ef5afcf1841bcd1aaf792f9ad42d16bc
Author: Thomas Renninger 
AuthorDate: Wed, 26 Sep 2012 14:18:59 +0200
Committer:  H. Peter Anvin 
CommitDate: Thu, 27 Sep 2012 15:01:30 -0700

ACPI: Implement physical address table override

Previous patches stored ACPI tables provided via initrd in a memblock reserved
area.
If a table is loaded and the table type of an initrd provided one matches,
the one from initrd is prefered.
In case of a SSDT table, the OEM table id also has to match.

ACPI tables can be loaded at boot time (static table pointers in XSDT),
but also dynamically any time later via ASL commands load() or loadTable().
The override mechanism always works.

Signed-off-by: Thomas Renninger 
Link: http://lkml.kernel.org/r/1348661941-71287-5-git-send-email-tr...@suse.de
Cc: Len Brown 
Cc: Robert Moore 
Cc: Yinghai Lu 
Cc: Eric Piel 
Signed-off-by: H. Peter Anvin 
---
 drivers/acpi/osl.c |   60 ---
 1 files changed, 56 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index b20b079..007224b 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -681,12 +681,64 @@ acpi_os_table_override(struct acpi_table_header * 
existing_table,
 
 acpi_status
 acpi_os_physical_table_override(struct acpi_table_header *existing_table,
-   acpi_physical_address * new_address,
-   u32 *new_table_length)
+   acpi_physical_address *address,
+   u32 *table_length)
 {
-   return AE_SUPPORT;
-}
+#ifndef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
+   *table_length = 0;
+   *address = 0;
+   return AE_OK;
+#else
+   int table_offset = 0;
+   struct acpi_table_header *table;
+
+   *table_length = 0;
+   *address = 0;
+
+   if (!acpi_tables_addr)
+   return AE_OK;
+
+   do {
+   if (table_offset + ACPI_HEADER_SIZE > all_tables_size) {
+   WARN_ON(1);
+   return AE_OK;
+   }
+
+   table = acpi_os_map_memory(acpi_tables_addr + table_offset,
+  ACPI_HEADER_SIZE);
+
+   if (table_offset + table->length > all_tables_size) {
+   acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
+   WARN_ON(1);
+   return AE_OK;
+   }
 
+   table_offset += table->length;
+
+   if (memcmp(existing_table->signature, table->signature, 4)) {
+   acpi_os_unmap_memory(table,
+ACPI_HEADER_SIZE);
+   continue;
+   }
+
+   /* Only override tables with matching oem id */
+   if (memcmp(table->oem_table_id, existing_table->oem_table_id,
+  ACPI_OEM_TABLE_ID_SIZE)) {
+   acpi_os_unmap_memory(table,
+ACPI_HEADER_SIZE);
+   continue;
+   }
+
+   table_offset -= table->length;
+   *table_length = table->length;
+   acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
+   *address = acpi_tables_addr + table_offset;
+   break;
+   } while (table_offset + ACPI_HEADER_SIZE < all_tables_size);
+
+   return AE_OK;
+#endif
+}
 
 static irqreturn_t acpi_irq(int irq, void *dev_id)
 {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:x86/acpi] ACPI: Implement physical address table override

2012-09-27 Thread tip-bot for Thomas Renninger
Commit-ID:  6fd61f98ef5afcf1841bcd1aaf792f9ad42d16bc
Gitweb: http://git.kernel.org/tip/6fd61f98ef5afcf1841bcd1aaf792f9ad42d16bc
Author: Thomas Renninger tr...@suse.de
AuthorDate: Wed, 26 Sep 2012 14:18:59 +0200
Committer:  H. Peter Anvin h...@linux.intel.com
CommitDate: Thu, 27 Sep 2012 15:01:30 -0700

ACPI: Implement physical address table override

Previous patches stored ACPI tables provided via initrd in a memblock reserved
area.
If a table is loaded and the table type of an initrd provided one matches,
the one from initrd is prefered.
In case of a SSDT table, the OEM table id also has to match.

ACPI tables can be loaded at boot time (static table pointers in XSDT),
but also dynamically any time later via ASL commands load() or loadTable().
The override mechanism always works.

Signed-off-by: Thomas Renninger tr...@suse.de
Link: http://lkml.kernel.org/r/1348661941-71287-5-git-send-email-tr...@suse.de
Cc: Len Brown l...@kernel.org
Cc: Robert Moore robert.mo...@intel.com
Cc: Yinghai Lu ying...@kernel.org
Cc: Eric Piel eric.p...@tremplin-utc.net
Signed-off-by: H. Peter Anvin h...@linux.intel.com
---
 drivers/acpi/osl.c |   60 ---
 1 files changed, 56 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index b20b079..007224b 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -681,12 +681,64 @@ acpi_os_table_override(struct acpi_table_header * 
existing_table,
 
 acpi_status
 acpi_os_physical_table_override(struct acpi_table_header *existing_table,
-   acpi_physical_address * new_address,
-   u32 *new_table_length)
+   acpi_physical_address *address,
+   u32 *table_length)
 {
-   return AE_SUPPORT;
-}
+#ifndef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
+   *table_length = 0;
+   *address = 0;
+   return AE_OK;
+#else
+   int table_offset = 0;
+   struct acpi_table_header *table;
+
+   *table_length = 0;
+   *address = 0;
+
+   if (!acpi_tables_addr)
+   return AE_OK;
+
+   do {
+   if (table_offset + ACPI_HEADER_SIZE  all_tables_size) {
+   WARN_ON(1);
+   return AE_OK;
+   }
+
+   table = acpi_os_map_memory(acpi_tables_addr + table_offset,
+  ACPI_HEADER_SIZE);
+
+   if (table_offset + table-length  all_tables_size) {
+   acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
+   WARN_ON(1);
+   return AE_OK;
+   }
 
+   table_offset += table-length;
+
+   if (memcmp(existing_table-signature, table-signature, 4)) {
+   acpi_os_unmap_memory(table,
+ACPI_HEADER_SIZE);
+   continue;
+   }
+
+   /* Only override tables with matching oem id */
+   if (memcmp(table-oem_table_id, existing_table-oem_table_id,
+  ACPI_OEM_TABLE_ID_SIZE)) {
+   acpi_os_unmap_memory(table,
+ACPI_HEADER_SIZE);
+   continue;
+   }
+
+   table_offset -= table-length;
+   *table_length = table-length;
+   acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
+   *address = acpi_tables_addr + table_offset;
+   break;
+   } while (table_offset + ACPI_HEADER_SIZE  all_tables_size);
+
+   return AE_OK;
+#endif
+}
 
 static irqreturn_t acpi_irq(int irq, void *dev_id)
 {
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/