mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Rouven Czerwinski <r.czerwinski@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Subject: [PATCH 2/8] mtd: cfi_flash: allow 0x0 mapping
Date: Mon,  9 Nov 2020 14:44:24 +0100	[thread overview]
Message-ID: <20201109134430.21156-3-r.czerwinski@pengutronix.de> (raw)
In-Reply-To: <20201109134430.21156-1-r.czerwinski@pengutronix.de>

Annotate the different read and write functions with
zero_page_{access/faulting}. This allows the cfi_flash driver to be used
on the QEMU virt machine with an enabled MMU.

Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
---
 drivers/mtd/nor/cfi_flash.c |  6 ++++++
 drivers/mtd/nor/cfi_flash.h | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/drivers/mtd/nor/cfi_flash.c b/drivers/mtd/nor/cfi_flash.c
index 225b03ec3d..2fcbd13e46 100644
--- a/drivers/mtd/nor/cfi_flash.c
+++ b/drivers/mtd/nor/cfi_flash.c
@@ -896,8 +896,10 @@ static int cfi_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
 {
 	struct flash_info *info = container_of(mtd, struct flash_info, mtd);
 
+	zero_page_access();
 	memcpy(buf, info->base + from, len);
 	*retlen = len;
+	zero_page_faulting();
 
 	return 0;
 }
@@ -908,7 +910,9 @@ static int cfi_mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
 	struct flash_info *info = container_of(mtd, struct flash_info, mtd);
 	int ret;
 
+	zero_page_access();
 	ret = write_buff(info, buf, (unsigned long)info->base + to, len);
+	zero_page_faulting();
 	*retlen = len;
 
         return ret;
@@ -919,7 +923,9 @@ static int cfi_mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
 	struct flash_info *info = container_of(mtd, struct flash_info, mtd);
 	int ret;
 
+	zero_page_access();
 	ret = cfi_erase(info, instr->len, instr->addr);
+	zero_page_faulting();
 	if (ret)
 		return -EIO;
 
diff --git a/drivers/mtd/nor/cfi_flash.h b/drivers/mtd/nor/cfi_flash.h
index cea6a8712c..99359a325e 100644
--- a/drivers/mtd/nor/cfi_flash.h
+++ b/drivers/mtd/nor/cfi_flash.h
@@ -22,6 +22,8 @@
 #include <io.h>
 #include <linux/mtd/mtd.h>
 
+#include <zero_page.h>
+
 typedef unsigned long flash_sect_t;
 
 #if   defined(CONFIG_DRIVER_CFI_BANK_WIDTH_8)
@@ -255,43 +257,59 @@ void flash_make_cmd(struct flash_info *info, u32 cmd, cfiword_t *cmdbuf);
 
 static inline void flash_write8(u8 value, void *addr)
 {
+	zero_page_access();
 	__raw_writeb(value, addr);
+	zero_page_faulting();
 }
 
 static inline void flash_write16(u16 value, void *addr)
 {
+	zero_page_access();
 	__raw_writew(value, addr);
+	zero_page_faulting();
 }
 
 static inline void flash_write32(u32 value, void *addr)
 {
+	zero_page_access();
 	__raw_writel(value, addr);
+	zero_page_faulting();
 }
 
 static inline void flash_write64(u64 value, void *addr)
 {
+	zero_page_access();
 	memcpy((void *)addr, &value, 8);
+	zero_page_faulting();
 }
 
 static inline u8 flash_read8(void *addr)
 {
+	zero_page_access();
 	return __raw_readb(addr);
+	zero_page_faulting();
 }
 
 static inline u16 flash_read16(void *addr)
 {
+	zero_page_access();
 	return __raw_readw(addr);
+	zero_page_faulting();
 }
 
 static inline u32 flash_read32(void *addr)
 {
+	zero_page_access();
 	return __raw_readl(addr);
+	zero_page_faulting();
 }
 
 static inline u64 flash_read64(void *addr)
 {
+	zero_page_access();
 	/* No architectures currently implement readq() */
 	return *(volatile u64 *)addr;
+	zero_page_faulting();
 }
 
 /*
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-11-09 13:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09 13:44 [PATCH 0/8] QEMU virt machine support via mach-vexpress Rouven Czerwinski
2020-11-09 13:44 ` [PATCH 1/8] ARM: MMU: add zero_page_{access,faulting} Rouven Czerwinski
2020-11-09 13:44 ` Rouven Czerwinski [this message]
2020-11-09 13:52   ` [PATCH 2/8] mtd: cfi_flash: allow 0x0 mapping Lucas Stach
2020-11-10  6:33     ` Rouven Czerwinski
2020-11-10  7:48       ` Sascha Hauer
2020-11-10  9:15         ` Sascha Hauer
2020-11-10  9:36           ` Ahmad Fatoum
2020-11-10  9:43             ` Ahmad Fatoum
2020-11-12 10:06               ` Sascha Hauer
2020-11-12 10:09                 ` Rouven Czerwinski
2020-11-09 13:44 ` [PATCH 3/8] amba: add *_amba_driver helper macros Rouven Czerwinski
2020-11-09 13:44 ` [PATCH 4/8] ARM: vexpress: remove unused KConfig file Rouven Czerwinski
2020-11-09 13:44 ` [PATCH 5/8] ARM: vexpress: convert to board driver Rouven Czerwinski
2020-11-09 13:44 ` [PATCH 6/8] ARM: vexpress: move Options to ARCH_VEXPRESS Rouven Czerwinski
2020-11-09 13:44 ` [PATCH 7/8] ARM: qemu: add support for qemu virt platform Rouven Czerwinski
2020-11-09 13:44 ` [PATCH 8/8] ARM: vexpress: enable VIRT board, MMU and cmds Rouven Czerwinski
2020-11-12 10:30 ` [PATCH 0/8] QEMU virt machine support via mach-vexpress Sascha Hauer

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=20201109134430.21156-3-r.czerwinski@pengutronix.de \
    --to=r.czerwinski@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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