Re: [PATCH v2 06/20] x86, ACPI: Store override acpi tables phys addr in cpio files info array

Yinghai Lu
2013-04-04T20:03:19Z

[-- Attachment #1: Type: text/plain, Size: 925 bytes --]

On Thu, Apr 4, 2013 at 11:27 AM, Tejun Heo <tj@kernel.org> wrote:
>> for (no = 0; no < ACPI_OVERRIDE_TABLES; no++) {
>> + /*
>> + * have to use unsigned long, otherwise 32bit spit warning
>> + * and it is ok to unsigned long, as bootloader would not
>> + * load initrd above 4G for 32bit kernel.
>> + */
>> + unsigned long addr = (unsigned long)acpi_initrd_files[no].data;
>
> I can't say I like this. It's stuffing phys_addr_t into void *. It
> might work okay but the code is a bit misleading / confusing. "void
> *" shouldn't contain a physical address. Maybe the alternatives are
> uglier, I don't know. If you can think of a reasonable way to not do
> this, it would be great.

Please check if you are happy with attached.

-v2: introduce file_pos to save phys address instead of abusing cpio_data
that tj is not happy with.

[-- Attachment #2: fix_acpi_override_2.patch --]
[-- Type: application/octet-stream, Size: 2390 bytes --]

Subject: [PATCH] x86, ACPI: Store override acpi tables phys addr in cpio files info array

In 32bit we will find table with phys address during 32bit flat mode
in head_32.S, because at that time we don't need set page table to
access initrd.

For copying we could use early_ioremap() with phys directly before mem mapping
is set.

To keep 32bit and 64bit consistent, use phys_addr for all.

-v2: introduce file_pos to save phys address instead of abusing cpio_data
that tj is not happy with.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: linux-acpi@vger.kernel.org

---
drivers/acpi/osl.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

Index: linux-2.6/drivers/acpi/osl.c
===================================================================
--- linux-2.6.orig/drivers/acpi/osl.c
+++ linux-2.6/drivers/acpi/osl.c
@@ -570,7 +570,11 @@ static const char * const table_sigs[] =
#define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)

#define ACPI_OVERRIDE_TABLES 64
-static struct cpio_data __initdata acpi_initrd_files[ACPI_OVERRIDE_TABLES];
+struct file_pos {
+ phys_addr_t data;
+ phys_addr_t size;
+};
+static struct file_pos __initdata acpi_initrd_files[ACPI_OVERRIDE_TABLES];

void __init acpi_initrd_override_find(void *data, size_t size)
{
@@ -615,7 +619,7 @@ void __init acpi_initrd_override_find(vo
table->signature, cpio_path, file.name, table->length);

all_tables_size += table->length;
- acpi_initrd_files[table_nr].data = file.data;
+ acpi_initrd_files[table_nr].data = __pa_nodebug(file.data);
acpi_initrd_files[table_nr].size = file.size;
table_nr++;
}
@@ -624,7 +628,7 @@ void __init acpi_initrd_override_find(vo
void __init acpi_initrd_override_copy(void)
{
int no, total_offset = 0;
- char *p;
+ char *p, *q;

if (!all_tables_size)
return;
@@ -659,12 +663,15 @@ void __init acpi_initrd_override_copy(vo
* one by one during copying.
*/
for (no = 0; no < ACPI_OVERRIDE_TABLES; no++) {
+ phys_addr_t addr = acpi_initrd_files[no].data;
phys_addr_t size = acpi_initrd_files[no].size;

if (!size)
break;
+ q = early_ioremap(addr, size);
p = early_ioremap(acpi_tables_addr + total_offset, size);
- memcpy(p, acpi_initrd_files[no].data, size);
+ memcpy(p, q, size);
+ early_iounmap(q, size);
early_iounmap(p, size);
total_offset += size;
}