liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

phram-allow-cached-mappings.patch (1494B)


      1 From bb7e7aeb3d832059e33b1e76eb85d4680f77abf2 Mon Sep 17 00:00:00 2001
      2 From: Ben Hutchings <ben@decadent.org.uk>
      3 Date: Fri, 3 Jun 2016 01:08:36 +0100
      4 Subject: [PATCH] phram: Use memremap() to allow mapping of system RAM
      5 
      6 Using memremap() instead of ioremap() allows mapping a disk image in
      7 system RAM that has somehow been reserved.  It should fall back
      8 to ioremap() where necessary.
      9 
     10 Entirely untested, and I'm not convinced this is a good idea at all.
     11 ---
     12  drivers/mtd/devices/phram.c | 7 ++++---
     13  1 file changed, 4 insertions(+), 3 deletions(-)
     14 
     15 diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
     16 index 8b66e52ca3cc..0ea254e2ba51 100644
     17 --- a/drivers/mtd/devices/phram.c
     18 +++ b/drivers/mtd/devices/phram.c
     19 @@ -88,7 +88,7 @@ static void unregister_devices(void)
     20  
     21  	list_for_each_entry_safe(this, safe, &phram_list, list) {
     22  		mtd_device_unregister(&this->mtd);
     23 -		iounmap(this->mtd.priv);
     24 +		memunmap(this->mtd.priv);
     25  		kfree(this->mtd.name);
     26  		kfree(this);
     27  	}
     28 @@ -104,7 +104,8 @@ static int register_device(char *name, phys_addr_t start, size_t len)
     29  		goto out0;
     30  
     31  	ret = -EIO;
     32 -	new->mtd.priv = ioremap(start, len);
     33 +	new->mtd.priv = memremap(start, len,
     34 +				 MEMREMAP_WB | MEMREMAP_WT | MEMREMAP_WC);
     35  	if (!new->mtd.priv) {
     36  		pr_err("ioremap failed\n");
     37  		goto out1;
     38 @@ -134,7 +135,7 @@ static int register_device(char *name, phys_addr_t start, size_t len)
     39  	return 0;
     40  
     41  out2:
     42 -	iounmap(new->mtd.priv);
     43 +	memunmap(new->mtd.priv);
     44  out1:
     45  	kfree(new);
     46  out0:
     47