Skip to contentSkip to conversation

Implement ioremap_prot support (v2)

PATCH In review Jianwen Jiang 3 participants 3 messages Dec 2, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Implement ioremap_prot support (v2)

Feature ioremap_prot only needs an implementation of pte_pgprot on riscv.
That macro is similar to the same one on platform loongarch, mips and sh.
We just need:
1. replace _PFN_MASK with _PAGE_PFN_MASK in pte_gpprot;
2. add "select HAVE_IOREMAP_PROT" into arch/riscv/Kconfig;
3. add "depends on MMU" into drivers/fpga/Kconfig to fix the building error "undefined reference to generic_access_phys".

---
 arch/riscv/Kconfig            | 1 +
 arch/riscv/include/asm/page.h | 2 ++
 drivers/fpga/Kconfig          | 1 +
 3 files changed, 4 insertions(+)
arch/riscv/Kconfig +1 -0
index fa78595a6089..5ed2c7361040 100644
@@ -95,6 +95,7 @@ config RISCV
 	select HAVE_FUNCTION_ERROR_INJECTION
 	select HAVE_GCC_PLUGINS
 	select HAVE_GENERIC_VDSO if MMU && 64BIT
+	select HAVE_IOREMAP_PROT
 	select HAVE_IRQ_TIME_ACCOUNTING
 	select HAVE_KPROBES if !XIP_KERNEL
 	select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL
arch/riscv/include/asm/page.h +2 -0
index ac70b0fd9a9a..cb08a4911d60 100644
@@ -84,6 +84,8 @@ typedef struct page *pgtable_t;
 #define __pgd(x)	((pgd_t) { (x) })
 #define __pgprot(x)	((pgprot_t) { (x) })
 
+#define pte_pgprot(x)  __pgprot(pte_val(x) & ~_PAGE_PFN_MASK)
+
 #ifdef CONFIG_64BIT
 #define PTE_FMT "%016lx"
 #else
drivers/fpga/Kconfig +1 -0
index bbe0a7cabb75..0493272b8bff 100644
@@ -5,6 +5,7 @@
 
 menuconfig FPGA
 	tristate "FPGA Configuration Framework"
+	depends on MMU
 	help
 	  Say Y here if you want support for configuring FPGAs from the
 	  kernel.  The FPGA framework adds an FPGA manager class and FPGA
Signature · 7 lines
2.37.3.446.gd42b38dfb5


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#1 lore raw

Hello!

On Fri, Dec 02, 2022 at 04:33:56PM +0800, Jianwen Jiang wrote:a

Quoted 1 line

[PATCH] Implement ioremap_prot support (v2)

Some process bits.. Please put the v2 inside the leading [], git format-patch will do this for you with the -v N arg. Also, please add a subsytem prefix to the $subject & drop the leading spaces.

Quoted 1 line

Feature ioremap_prot only needs an implementation of pte_pgprot on riscv.

There's also no need to tab this stuff in

Quoted 7 lines

That macro is similar to the same one on platform loongarch, mips and sh.
We just need:
1. replace _PFN_MASK with _PAGE_PFN_MASK in pte_gpprot;
2. add "select HAVE_IOREMAP_PROT" into arch/riscv/Kconfig;
3. add "depends on MMU" into drivers/fpga/Kconfig to fix the building error "undefined reference to generic_access_phys".

And this line should not be tabbed in.

Quoted 4 lines
---
 arch/riscv/Kconfig            | 1 +
 arch/riscv/include/asm/page.h | 2 ++
 drivers/fpga/Kconfig          | 1 +

This needs to go as a separate patch to the FPGA subsystem, with the FPGA maintainers in to/cc.

Quoted 32 lines
 3 files changed, 4 insertions(+)
arch/riscv/Kconfig +1 -0
index fa78595a6089..5ed2c7361040 100644
@@ -95,6 +95,7 @@ config RISCV
 	select HAVE_FUNCTION_ERROR_INJECTION
 	select HAVE_GCC_PLUGINS
 	select HAVE_GENERIC_VDSO if MMU && 64BIT
+	select HAVE_IOREMAP_PROT
 	select HAVE_IRQ_TIME_ACCOUNTING
 	select HAVE_KPROBES if !XIP_KERNEL
 	select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL
arch/riscv/include/asm/page.h +2 -0
index ac70b0fd9a9a..cb08a4911d60 100644
@@ -84,6 +84,8 @@ typedef struct page *pgtable_t;
 #define __pgd(x)	((pgd_t) { (x) })
 #define __pgprot(x)	((pgprot_t) { (x) })
 
+#define pte_pgprot(x)  __pgprot(pte_val(x) & ~_PAGE_PFN_MASK)
+
 #ifdef CONFIG_64BIT
 #define PTE_FMT "%016lx"
 #else
drivers/fpga/Kconfig +0 -0
index bbe0a7cabb75..0493272b8bff 100644

drivers/fpga/Kconfig line 8

Quoted 4 lines
drivers/fpga/Kconfig +1 -0
@@ -5,6 +5,7 @@
 
 menuconfig FPGA
 	tristate "FPGA Configuration Framework"
+	depends on MMU

How come no other arch needs this dependancy?

Thanks,
Conor.

Quoted 11 lines
drivers/fpga/Kconfig +0 -0
 	help
 	  Say Y here if you want support for configuring FPGAs from the
 	  kernel.  The FPGA framework adds an FPGA manager class and FPGA
Signature · 7 lines
2.37.3.446.gd42b38dfb5


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

maintainer
#2 lore raw
In reply to Jianwen Jiang
Quoted 6 lines · On Fri, 02 Dec 2022 00:33:56 PST (-0800), [email protected] wrote:

Feature ioremap_prot only needs an implementation of pte_pgprot on riscv.
That macro is similar to the same one on platform loongarch, mips and sh.
We just need:
1. replace _PFN_MASK with _PAGE_PFN_MASK in pte_gpprot;
2. add "select HAVE_IOREMAP_PROT" into arch/riscv/Kconfig;
3. add "depends on MMU" into drivers/fpga/Kconfig to fix the building error "undefined reference to generic_access_phys".

That third one should be its own patch, it's not really related to the RISC-V bits.

Quoted 45 lines
---
 arch/riscv/Kconfig            | 1 +
 arch/riscv/include/asm/page.h | 2 ++
 drivers/fpga/Kconfig          | 1 +
 3 files changed, 4 insertions(+)
arch/riscv/Kconfig +1 -0
index fa78595a6089..5ed2c7361040 100644
@@ -95,6 +95,7 @@ config RISCV
 	select HAVE_FUNCTION_ERROR_INJECTION
 	select HAVE_GCC_PLUGINS
 	select HAVE_GENERIC_VDSO if MMU && 64BIT
+	select HAVE_IOREMAP_PROT
 	select HAVE_IRQ_TIME_ACCOUNTING
 	select HAVE_KPROBES if !XIP_KERNEL
 	select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL
arch/riscv/include/asm/page.h +2 -0
index ac70b0fd9a9a..cb08a4911d60 100644
@@ -84,6 +84,8 @@ typedef struct page *pgtable_t;
 #define __pgd(x)	((pgd_t) { (x) })
 #define __pgprot(x)	((pgprot_t) { (x) })
 
+#define pte_pgprot(x)  __pgprot(pte_val(x) & ~_PAGE_PFN_MASK)
+
 #ifdef CONFIG_64BIT
 #define PTE_FMT "%016lx"
 #else
drivers/fpga/Kconfig +1 -0
index bbe0a7cabb75..0493272b8bff 100644
@@ -5,6 +5,7 @@
 
 menuconfig FPGA
 	tristate "FPGA Configuration Framework"
+	depends on MMU
 	help
 	  Say Y here if you want support for configuring FPGAs from the
 	  kernel.  The FPGA framework adds an FPGA manager class and FPGA