linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mdt: slram: use memremap() instead of ioremap()
@ 2017-10-17 20:56 Roy Franz
  2017-10-17 21:14 ` Ard Biesheuvel
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Roy Franz @ 2017-10-17 20:56 UTC (permalink / raw)
  To: linux-arm-kernel

Convert slram to use memremap() to map the memory it uses to back an MTD
device, as this is the proper interface for mapping memory. This change
enables normal memory to be used to back an MTD device on arm64, as arm64
prevents ioremap() being used on normal memory.

Signed-off-by: Roy Franz <roy.franz@cavium.com>
---
Tested on arm64 simulation, using simulator to preload filesystem image into RAM,
and also tested on x86_64 using video card memory.  This is useful for speeding
up booting on (very slow) emulation environments by avoiding any processing of
an initramfs.

 drivers/mtd/devices/slram.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c
index 8087c36dc693..0ec85f316d24 100644
--- a/drivers/mtd/devices/slram.c
+++ b/drivers/mtd/devices/slram.c
@@ -163,8 +163,9 @@ static int register_device(char *name, unsigned long start, unsigned long length
 	}
 
 	if (!(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start =
-				ioremap(start, length))) {
-		E("slram: ioremap failed\n");
+		memremap(start, length,
+			 MEMREMAP_WB | MEMREMAP_WT | MEMREMAP_WC))) {
+		E("slram: memremap failed\n");
 		return -EIO;
 	}
 	((slram_priv_t *)(*curmtd)->mtdinfo->priv)->end =
@@ -186,7 +187,7 @@ static int register_device(char *name, unsigned long start, unsigned long length
 
 	if (mtd_device_register((*curmtd)->mtdinfo, NULL, 0))	{
 		E("slram: Failed to register new device\n");
-		iounmap(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start);
+		memunmap(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start);
 		kfree((*curmtd)->mtdinfo->priv);
 		kfree((*curmtd)->mtdinfo);
 		return(-EAGAIN);
@@ -206,7 +207,7 @@ static void unregister_devices(void)
 	while (slram_mtdlist) {
 		nextitem = slram_mtdlist->next;
 		mtd_device_unregister(slram_mtdlist->mtdinfo);
-		iounmap(((slram_priv_t *)slram_mtdlist->mtdinfo->priv)->start);
+		memunmap(((slram_priv_t *)slram_mtdlist->mtdinfo->priv)->start);
 		kfree(slram_mtdlist->mtdinfo->priv);
 		kfree(slram_mtdlist->mtdinfo);
 		kfree(slram_mtdlist);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] mdt: slram: use memremap() instead of ioremap()
  2017-10-17 20:56 [PATCH] mdt: slram: use memremap() instead of ioremap() Roy Franz
@ 2017-10-17 21:14 ` Ard Biesheuvel
  2017-10-17 22:02 ` David Daney
  2017-10-19 15:37 ` Christoph Hellwig
  2 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2017-10-17 21:14 UTC (permalink / raw)
  To: linux-arm-kernel

On 17 October 2017 at 21:56, Roy Franz <rfranz@cavium.com> wrote:
> Convert slram to use memremap() to map the memory it uses to back an MTD
> device, as this is the proper interface for mapping memory. This change
> enables normal memory to be used to back an MTD device on arm64, as arm64
> prevents ioremap() being used on normal memory.
>
> Signed-off-by: Roy Franz <roy.franz@cavium.com>

Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
> Tested on arm64 simulation, using simulator to preload filesystem image into RAM,
> and also tested on x86_64 using video card memory.  This is useful for speeding
> up booting on (very slow) emulation environments by avoiding any processing of
> an initramfs.
>
>  drivers/mtd/devices/slram.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c
> index 8087c36dc693..0ec85f316d24 100644
> --- a/drivers/mtd/devices/slram.c
> +++ b/drivers/mtd/devices/slram.c
> @@ -163,8 +163,9 @@ static int register_device(char *name, unsigned long start, unsigned long length
>         }
>
>         if (!(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start =
> -                               ioremap(start, length))) {
> -               E("slram: ioremap failed\n");
> +               memremap(start, length,
> +                        MEMREMAP_WB | MEMREMAP_WT | MEMREMAP_WC))) {
> +               E("slram: memremap failed\n");
>                 return -EIO;
>         }
>         ((slram_priv_t *)(*curmtd)->mtdinfo->priv)->end =
> @@ -186,7 +187,7 @@ static int register_device(char *name, unsigned long start, unsigned long length
>
>         if (mtd_device_register((*curmtd)->mtdinfo, NULL, 0))   {
>                 E("slram: Failed to register new device\n");
> -               iounmap(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start);
> +               memunmap(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start);
>                 kfree((*curmtd)->mtdinfo->priv);
>                 kfree((*curmtd)->mtdinfo);
>                 return(-EAGAIN);
> @@ -206,7 +207,7 @@ static void unregister_devices(void)
>         while (slram_mtdlist) {
>                 nextitem = slram_mtdlist->next;
>                 mtd_device_unregister(slram_mtdlist->mtdinfo);
> -               iounmap(((slram_priv_t *)slram_mtdlist->mtdinfo->priv)->start);
> +               memunmap(((slram_priv_t *)slram_mtdlist->mtdinfo->priv)->start);
>                 kfree(slram_mtdlist->mtdinfo->priv);
>                 kfree(slram_mtdlist->mtdinfo);
>                 kfree(slram_mtdlist);
> --
> 2.11.0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] mdt: slram: use memremap() instead of ioremap()
  2017-10-17 20:56 [PATCH] mdt: slram: use memremap() instead of ioremap() Roy Franz
  2017-10-17 21:14 ` Ard Biesheuvel
@ 2017-10-17 22:02 ` David Daney
  2017-10-19 15:37 ` Christoph Hellwig
  2 siblings, 0 replies; 5+ messages in thread
From: David Daney @ 2017-10-17 22:02 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/17/2017 01:56 PM, Roy Franz wrote:
> Convert slram to use memremap() to map the memory it uses to back an MTD
> device, as this is the proper interface for mapping memory. This change
> enables normal memory to be used to back an MTD device on arm64, as arm64
> prevents ioremap() being used on normal memory.
> 
> Signed-off-by: Roy Franz <roy.franz@cavium.com>

Thanks Roy.  I just tested on MIPS64 with no regressions, so:

Tested-by: David Daney <david.daney@cavium.com>


> ---
> Tested on arm64 simulation, using simulator to preload filesystem image into RAM,
> and also tested on x86_64 using video card memory.  This is useful for speeding
> up booting on (very slow) emulation environments by avoiding any processing of
> an initramfs.
> 
>   drivers/mtd/devices/slram.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c
> index 8087c36dc693..0ec85f316d24 100644
> --- a/drivers/mtd/devices/slram.c
> +++ b/drivers/mtd/devices/slram.c
> @@ -163,8 +163,9 @@ static int register_device(char *name, unsigned long start, unsigned long length
>   	}
>   
>   	if (!(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start =
> -				ioremap(start, length))) {
> -		E("slram: ioremap failed\n");
> +		memremap(start, length,
> +			 MEMREMAP_WB | MEMREMAP_WT | MEMREMAP_WC))) {
> +		E("slram: memremap failed\n");
>   		return -EIO;
>   	}
>   	((slram_priv_t *)(*curmtd)->mtdinfo->priv)->end =
> @@ -186,7 +187,7 @@ static int register_device(char *name, unsigned long start, unsigned long length
>   
>   	if (mtd_device_register((*curmtd)->mtdinfo, NULL, 0))	{
>   		E("slram: Failed to register new device\n");
> -		iounmap(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start);
> +		memunmap(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start);
>   		kfree((*curmtd)->mtdinfo->priv);
>   		kfree((*curmtd)->mtdinfo);
>   		return(-EAGAIN);
> @@ -206,7 +207,7 @@ static void unregister_devices(void)
>   	while (slram_mtdlist) {
>   		nextitem = slram_mtdlist->next;
>   		mtd_device_unregister(slram_mtdlist->mtdinfo);
> -		iounmap(((slram_priv_t *)slram_mtdlist->mtdinfo->priv)->start);
> +		memunmap(((slram_priv_t *)slram_mtdlist->mtdinfo->priv)->start);
>   		kfree(slram_mtdlist->mtdinfo->priv);
>   		kfree(slram_mtdlist->mtdinfo);
>   		kfree(slram_mtdlist);
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] mdt: slram: use memremap() instead of ioremap()
  2017-10-17 20:56 [PATCH] mdt: slram: use memremap() instead of ioremap() Roy Franz
  2017-10-17 21:14 ` Ard Biesheuvel
  2017-10-17 22:02 ` David Daney
@ 2017-10-19 15:37 ` Christoph Hellwig
  2017-10-19 20:08   ` Roy Franz
  2 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2017-10-19 15:37 UTC (permalink / raw)
  To: linux-arm-kernel

s/mdt/mtd/ in the subject?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] mdt: slram: use memremap() instead of ioremap()
  2017-10-19 15:37 ` Christoph Hellwig
@ 2017-10-19 20:08   ` Roy Franz
  0 siblings, 0 replies; 5+ messages in thread
From: Roy Franz @ 2017-10-19 20:08 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Oct 19, 2017 at 8:37 AM, Christoph Hellwig <hch@infradead.org> wrote:
> s/mdt/mtd/ in the subject?

Yup, I'll repost a fixed version.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-10-19 20:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-17 20:56 [PATCH] mdt: slram: use memremap() instead of ioremap() Roy Franz
2017-10-17 21:14 ` Ard Biesheuvel
2017-10-17 22:02 ` David Daney
2017-10-19 15:37 ` Christoph Hellwig
2017-10-19 20:08   ` Roy Franz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).