[v5,3/8] acpi: Refactor acpi_os_map_memory to be architecturally independent
diff mbox

Message ID 1453536020-16196-4-git-send-email-zhaoshenglong@huawei.com
State New, archived
Headers show

Commit Message

Shannon Zhao Jan. 23, 2016, 8 a.m. UTC
From: Shannon Zhao <shannon.zhao@linaro.org>

The first Mb handling is not necessary and the attribute of __vmap() is
different for ARM. Factor the first Mb handling only for x86 and define
a mapping attribute for each architecture.

Cc: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
v5: only factor the first Mb handling and the attribute of __vmap()
---
 xen/drivers/acpi/osl.c     | 11 +++++++----
 xen/include/asm-x86/acpi.h |  2 ++
 2 files changed, 9 insertions(+), 4 deletions(-)

Comments

Jan Beulich Jan. 25, 2016, 2:43 p.m. UTC | #1
>>> On 23.01.16 at 09:00, <zhaoshenglong@huawei.com> wrote:
> v5: only factor the first Mb handling and the attribute of __vmap()

Much better.

> --- a/xen/drivers/acpi/osl.c
> +++ b/xen/drivers/acpi/osl.c
> @@ -92,11 +92,14 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
>  		mfn_t mfn = _mfn(PFN_DOWN(phys));
>  		unsigned int offs = phys & (PAGE_SIZE - 1);
>  
> -		/* The low first Mb is always mapped. */
> -		if ( !((phys + size - 1) >> 20) )
> -			return __va(phys);
> +		if (IS_ENABLED(CONFIG_X86)) {
> +			/* The low first Mb is always mapped. */
> +			if ( !((phys + size - 1) >> 20) )
> +				return __va(phys);
> +		}

But please combine the two if()-s into one.

Jan

Patch
diff mbox

diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
index a2fc8c4..63a4b1f 100644
--- a/xen/drivers/acpi/osl.c
+++ b/xen/drivers/acpi/osl.c
@@ -92,11 +92,14 @@  acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
 		mfn_t mfn = _mfn(PFN_DOWN(phys));
 		unsigned int offs = phys & (PAGE_SIZE - 1);
 
-		/* The low first Mb is always mapped. */
-		if ( !((phys + size - 1) >> 20) )
-			return __va(phys);
+		if (IS_ENABLED(CONFIG_X86)) {
+			/* The low first Mb is always mapped. */
+			if ( !((phys + size - 1) >> 20) )
+				return __va(phys);
+		}
+
 		return __vmap(&mfn, PFN_UP(offs + size), 1, 1,
-			      PAGE_HYPERVISOR_NOCACHE) + offs;
+			      ACPI_MAP_MEM_ATTR) + offs;
 	}
 	return __acpi_map_table(phys, size);
 }
diff --git a/xen/include/asm-x86/acpi.h b/xen/include/asm-x86/acpi.h
index d3bde78..d532e3d 100644
--- a/xen/include/asm-x86/acpi.h
+++ b/xen/include/asm-x86/acpi.h
@@ -163,4 +163,6 @@  void hvm_acpi_sleep_button(struct domain *d);
 void save_rest_processor_state(void);
 void restore_rest_processor_state(void);
 
+#define ACPI_MAP_MEM_ATTR	PAGE_HYPERVISOR_NOCACHE
+
 #endif /*__X86_ASM_ACPI_H*/