drm/ttm: add pgprot handling for RISC-V
Subsystems (4)
PATCH v2 1/1 drm/ttm: add pgprot handling for RISC-V
The RISC-V Svpbmt privileged extension provides support for overriding page memory coherency attributes, and, along with vendor extensions like Xtheadmae, supports pgprot_{writecombine,noncached} on RISC-V.
Adapt the codepath that maps ttm_write_combined to pgprot_writecombine and ttm_noncached to pgprot_noncached to RISC-V, to allow proper page access attributes.
---
Changes in v2:
- Added Han Gao's test tag.
drivers/gpu/drm/ttm/ttm_module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_module.c +2 -1
@@ -74,7 +74,8 @@ pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp)#endif /* CONFIG_UML */ #endif /* __i386__ || __x86_64__ */ #if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || \ - defined(__powerpc__) || defined(__mips__) || defined(__loongarch__) + defined(__powerpc__) || defined(__mips__) || defined(__loongarch__) || \ + defined(__riscv)if (caching == ttm_write_combined) tmp =pgprot_writecombine (tmp);else
Signature · 1 line
2.51.0
Quoted 22 lines · Icenowy Zheng
The RISC-V Svpbmt privileged extension provides support for overriding page memory coherency attributes, and, along with vendor extensions like Xtheadmae, supports pgprot_{writecombine,noncached} on RISC-V.
Adapt the codepath that maps
ttm_write_combinedtopgprot_writecombineandttm_noncachedtopgprot_noncachedto RISC-V, to allow proper page access attributes.Signed-off-by Icenowy Zheng <[email protected]>Tested-by Han Gao <[email protected]>---
Changes in v2:
- Added Han Gao's test tag.drivers/gpu/drm/ttm/ttm_module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/ttm/ttm_module.c +0
-0
drivers/gpu/drm/ttm/ttm_module.c pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp) · line 78
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_module.c +2
-1@@ -74,7 +74,8 @@ pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp)#endif /* CONFIG_UML */ #endif /* __i386__ || __x86_64__ */ #if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || \ - defined(__powerpc__) || defined(__mips__) || defined(__loongarch__) + defined(__powerpc__) || defined(__mips__) || defined(__loongarch__) || \ + defined(__riscv)
Looks reasonable, but does that work on all RISC-V variants?
And while at it maybe please fix the indentation, using a tab here is probably not very adequate. In other words make the defined() match the one on the first line.
Regards,
Christian.
Quoted 3 lines
drivers/gpu/drm/ttm/ttm_module.c +0
-0if (caching == ttm_write_combined) tmp =pgprot_writecombine (tmp);else
Tested on sophgo sg2042/sophgo sg2044/ultrarisc dp1000.
Quoted 49 lines · On Mon, Oct 27, 2025 at 15:57 Christian König <[email protected]> wrote:
Quoted 10 lines · Icenowy Zheng
The RISC-V Svpbmt privileged extension provides support for overriding page memory coherency attributes, and, along with vendor extensions like Xtheadmae, supports pgprot_{writecombine,noncached} on RISC-V.
Adapt the codepath that maps
ttm_write_combinedtopgprot_writecombineandttm_noncachedtopgprot_noncachedto RISC-V, to allow proper page access attributes.Signed-off-by Icenowy Zheng <[email protected]>Tested-by Han Gao <[email protected]>Review
Quoted 8 lines
---
Changes in v2:
- Added Han Gao's test tag.drivers/gpu/drm/ttm/ttm_module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/gpu/drm/ttm/ttm_module.cdrivers/gpu/drm/ttm/ttm_module.c pgprot_t ttm_prot_from_caching(enum ttm_caching
Quoted 4 lines
index
b3fffe7b5062a..aa137ead5cc59100644drivers/gpu/drm/ttm/ttm_module.c +0
-0@@ -74,7 +74,8 @@ pgprot_t ttm_prot_from_caching(enum ttm_cachingcaching,
pgprot_ttmp)drivers/gpu/drm/ttm/ttm_module.c pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp)
Quoted 5 lines
drivers/gpu/drm/ttm/ttm_module.c +1
-1#endif /* CONFIG_UML */ #endif /* __i386__ || __x86_64__ */ #if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || \ - defined(__powerpc__) || defined(__mips__) || defined(__loongarch__) + defined(__powerpc__) || defined(__mips__) ||
defined(__loongarch__)|| \drivers/gpu/drm/ttm/ttm_module.c pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp) · line 78
Quoted 1 line
drivers/gpu/drm/ttm/ttm_module.c +1
-0+defined (__riscv)Looks reasonable, but does that work on all RISC-V variants?
And while at it maybe please fix the indentation, using a tab here is probably not very adequate. In other words make the
defined()match the one on the first line.Regards,
Christian.Quoted 3 lines
drivers/gpu/drm/ttm/ttm_module.c +0
-0if (caching == ttm_write_combined) tmp =pgprot_writecombine (tmp);else
Paul Walmsley
maintainerQuoted 8 lines · Christian König
Quoted 7 lines · Icenowy Zheng
The RISC-V Svpbmt privileged extension provides support for overriding page memory coherency attributes, and, along with vendor extensions like Xtheadmae, supports pgprot_{writecombine,noncached} on RISC-V.
Adapt the codepath that maps
ttm_write_combinedtopgprot_writecombineandttm_noncachedtopgprot_noncachedto RISC-V, to allow proper page access attributes.
[ ... ]
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/ttm/ttm_module.c +0
-0@@ -74,7 +74,8 @@ pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp)
Quoted 8 lines
drivers/gpu/drm/ttm/ttm_module.c pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp) · line 78
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_module.c +2
-1#endif /* CONFIG_UML */ #endif /* __i386__ || __x86_64__ */ #if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || \ - defined(__powerpc__) || defined(__mips__) || defined(__loongarch__) + defined(__powerpc__) || defined(__mips__) || defined(__loongarch__) || \ + defined(__riscv)Looks reasonable, but does that work on all RISC-V variants?
From an RISC-V architectural perspective, yes.
Of course there might be a hardware bug in some given manufacturer's implementation, but then again, that could happen on the other architectures as well.
- Paul
Quoted 27 lines · Paul Walmsley
Quoted 8 lines · Christian König
Quoted 7 lines · Icenowy Zheng
The RISC-V Svpbmt privileged extension provides support for overriding page memory coherency attributes, and, along with vendor extensions like Xtheadmae, supports pgprot_{writecombine,noncached} on RISC-V.
Adapt the codepath that maps
ttm_write_combinedtopgprot_writecombineandttm_noncachedtopgprot_noncachedto RISC-V, to allow proper page access attributes.[ ... ]
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/ttm/ttm_module.c +0
-0@@ -74,7 +74,8 @@ pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp)Quoted 8 lines
drivers/gpu/drm/ttm/ttm_module.c pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp) · line 78
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_module.c +2
-1#endif /* CONFIG_UML */ #endif /* __i386__ || __x86_64__ */ #if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || \ - defined(__powerpc__) || defined(__mips__) || defined(__loongarch__) + defined(__powerpc__) || defined(__mips__) || defined(__loongarch__) || \ + defined(__riscv)Looks reasonable, but does that work on all RISC-V variants?
Quoted 5 lines
From an RISC-V architectural perspective, yes.
Of course there might be a hardware bug in some given manufacturer's implementation, but then again, that could happen on the other architectures as well.
I've added my acked-by and pushed it to drm-misc-next.
Regards,
Christian.
Quoted 3 lines
- Paul
Tested on sophgo sg2042/sophgo sg2044/ultrarisc dp1000.
Quoted 44 lines · Christian König
Quoted 22 lines · Icenowy Zheng
The RISC-V Svpbmt privileged extension provides support for overriding page memory coherency attributes, and, along with vendor extensions like Xtheadmae, supports pgprot_{writecombine,noncached} on RISC-V.
Adapt the codepath that maps
ttm_write_combinedtopgprot_writecombineandttm_noncachedtopgprot_noncachedto RISC-V, to allow proper page access attributes.Signed-off-by Icenowy Zheng <[email protected]>Tested-by Han Gao <[email protected]>---
Changes in v2:
- Added Han Gao's test tag.drivers/gpu/drm/ttm/ttm_module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/ttm/ttm_module.c +0
-0drivers/gpu/drm/ttm/ttm_module.c pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp) · line 78
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_module.c +2
-1@@ -74,7 +74,8 @@ pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp)#endif /* CONFIG_UML */ #endif /* __i386__ || __x86_64__ */ #if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || \ - defined(__powerpc__) || defined(__mips__) || defined(__loongarch__) + defined(__powerpc__) || defined(__mips__) || defined(__loongarch__) || \ + defined(__riscv)Looks reasonable, but does that work on all RISC-V variants?
And while at it maybe please fix the indentation, using a tab here is probably not very adequate. In other words make the
defined()match the one on the first line.Regards,
Christian.Quoted 3 lines
drivers/gpu/drm/ttm/ttm_module.c +0
-0if (caching == ttm_write_combined) tmp =pgprot_writecombine (tmp);else