public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: tbaicar@codeaurora•org (Baicar, Tyler)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v2 1/2] efi: esrt: use memremap not ioremap to access ESRT table in memory
Date: Tue, 16 Feb 2016 12:19:47 -0700	[thread overview]
Message-ID: <56C37653.9060807@codeaurora.org> (raw)
In-Reply-To: <1455535953-5056-2-git-send-email-ard.biesheuvel@linaro.org>

On 2/15/2016 4:32 AM, Ard Biesheuvel wrote:
> On ARM and arm64, ioremap() and memremap() are not interchangeable like
> on x86, and the use of ioremap() on ordinary RAM is typically flagged
> as an error if the memory region being mapped is also covered by the
> linear mapping, since that would lead to aliases with conflicting
> cacheability attributes.
>
> Since what we are dealing with is not an I/O region with side effects,
> using ioremap() here is arguably incorrect anyway, so let's replace
> it with memremap instead. Also add a missing unmap on the success path,
> and drop a memblock_remove() call which does not belong here, this far
> into the boot sequence.
>
> Cc: Peter Jones <pjones@redhat•com>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro•org>

Tested-by: Tyler Baicar<tbaicar@codeaurora•org>

> ---
>   drivers/firmware/efi/esrt.c | 16 ++++++++--------
>   1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c
> index 22c5285f7705..f096a0a26dbd 100644
> --- a/drivers/firmware/efi/esrt.c
> +++ b/drivers/firmware/efi/esrt.c
> @@ -16,6 +16,7 @@
>   #include <linux/device.h>
>   #include <linux/efi.h>
>   #include <linux/init.h>
> +#include <linux/io.h>
>   #include <linux/kernel.h>
>   #include <linux/kobject.h>
>   #include <linux/list.h>
> @@ -385,15 +386,15 @@ static void cleanup_entry_list(void)
>   static int __init esrt_sysfs_init(void)
>   {
>   	int error;
> -	struct efi_system_resource_table __iomem *ioesrt;
> +	struct efi_system_resource_table *memesrt;
>   
>   	pr_debug("esrt-sysfs: loading.\n");
>   	if (!esrt_data || !esrt_data_size)
>   		return -ENOSYS;
>   
> -	ioesrt = ioremap(esrt_data, esrt_data_size);
> -	if (!ioesrt) {
> -		pr_err("ioremap(%pa, %zu) failed.\n", &esrt_data,
> +	memesrt = memremap(esrt_data, esrt_data_size, MEMREMAP_WB);
> +	if (!memesrt) {
> +		pr_err("memremap(%pa, %zu, MEMREMAP_WB) failed.\n", &esrt_data,
>   		       esrt_data_size);
>   		return -ENOMEM;
>   	}
> @@ -401,11 +402,12 @@ static int __init esrt_sysfs_init(void)
>   	esrt = kmalloc(esrt_data_size, GFP_KERNEL);
>   	if (!esrt) {
>   		pr_err("kmalloc failed. (wanted %zu bytes)\n", esrt_data_size);
> -		iounmap(ioesrt);
> +		memunmap(memesrt);
>   		return -ENOMEM;
>   	}
>   
> -	memcpy_fromio(esrt, ioesrt, esrt_data_size);
> +	memcpy(esrt, memesrt, esrt_data_size);
> +	memunmap(memesrt);
>   
>   	esrt_kobj = kobject_create_and_add("esrt", efi_kobj);
>   	if (!esrt_kobj) {
> @@ -432,8 +434,6 @@ static int __init esrt_sysfs_init(void)
>   	if (error)
>   		goto err_cleanup_list;
>   
> -	memblock_remove(esrt_data, esrt_data_size);
> -
>   	pr_debug("esrt-sysfs: loaded.\n");
>   
>   	return 0;
Thanks,
Tyler

-- 
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  parent reply	other threads:[~2016-02-16 19:19 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-15 11:32 [PATCH v2 0/2] efi: ARM/arm64: wire up ESRT table Ard Biesheuvel
2016-02-15 11:32 ` [PATCH v2 1/2] efi: esrt: use memremap not ioremap to access ESRT table in memory Ard Biesheuvel
2016-02-15 15:45   ` Peter Jones
2016-02-16 19:19   ` Baicar, Tyler [this message]
2016-02-18 10:44   ` Matt Fleming
2016-02-18 12:16     ` Ard Biesheuvel
2016-02-18 13:28       ` Matt Fleming
2016-02-18 13:29         ` Ard Biesheuvel
2016-02-18 13:43           ` Matt Fleming
2016-02-18 13:44             ` Ard Biesheuvel
2016-02-18 14:15               ` Matt Fleming
2016-02-18 14:21                 ` Ard Biesheuvel
2016-02-18 14:38                   ` Matt Fleming
2016-02-19  9:27                   ` Dave Young
2016-02-18 19:16                 ` Peter Jones
2016-02-26 14:41                   ` Matt Fleming
2016-03-01 23:30                     ` Matt Fleming
2016-03-01 23:31                       ` Matt Fleming
2016-03-02  1:16                       ` Dave Young
2016-03-02 10:23                         ` Matt Fleming
2016-03-04  6:25                       ` Dave Young
2016-05-18  8:36                         ` Ard Biesheuvel
2016-05-18  8:53                           ` Matt Fleming
2016-06-16 13:47                             ` Ard Biesheuvel
2016-06-20 11:49                               ` Matt Fleming
2016-02-15 11:32 ` [PATCH v2 2/2] arm64/efi: esrt: add missing call to efi_esrt_init() Ard Biesheuvel
2016-02-15 15:46   ` Peter Jones
2016-02-16 20:25   ` Baicar, Tyler
2016-02-17  8:32     ` Ard Biesheuvel
2016-05-17 20:36     ` Christopher Covington
  -- strict thread matches above, loose matches on Subject: below --
2016-07-11 19:00 [PATCH v2 0/2] efi/arm*: wire up ESRT table Ard Biesheuvel
2016-07-11 19:00 ` [PATCH v2 1/2] efi: esrt: use memremap not ioremap to access ESRT table in memory Ard Biesheuvel
2016-07-15 15:05   ` Matt Fleming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56C37653.9060807@codeaurora.org \
    --to=tbaicar@codeaurora$(echo .)org \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox