* [PATCH] RISC-V: Define pgprot_dmacoherent() for non-coherent devices
@ 2025-08-20 15:23 Anup Patel
2025-10-12 6:07 ` Guo Ren
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Anup Patel @ 2025-08-20 15:23 UTC (permalink / raw)
To: Sunil V L, Rafael J . Wysocki, Palmer Dabbelt, Paul Walmsley
Cc: Alexandre Ghiti, Atish Patra, Andrew Jones, Anup Patel,
linux-riscv, linux-kernel, Anup Patel
The pgprot_dmacoherent() is used when allocating memory for
non-coherent devices and by default pgprot_dmacoherent() is
same as pgprot_noncached() unless architecture overrides it.
Currently, there is no pgprot_dmacoherent() definition for
RISC-V hence non-coherent device memory is being mapped as
IO thereby making CPU access to such memory slow.
Define pgprot_dmacoherent() to be same as pgprot_writecombine()
for RISC-V so that CPU access non-coherent device memory as
NOCACHE which is better than accessing it as IO.
Fixes: ff689fd21cb1 ("riscv: add RISC-V Svpbmt extension support")
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
arch/riscv/include/asm/pgtable.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index 91697fbf1f90..00d8bdaf1e8d 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -653,6 +653,8 @@ static inline pgprot_t pgprot_writecombine(pgprot_t _prot)
return __pgprot(prot);
}
+#define pgprot_dmacoherent pgprot_writecombine
+
/*
* Both Svade and Svadu control the hardware behavior when the PTE A/D bits need to be set. By
* default the M-mode firmware enables the hardware updating scheme when only Svadu is present in
--
2.43.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] RISC-V: Define pgprot_dmacoherent() for non-coherent devices
2025-08-20 15:23 [PATCH] RISC-V: Define pgprot_dmacoherent() for non-coherent devices Anup Patel
@ 2025-10-12 6:07 ` Guo Ren
2025-10-12 6:59 ` Guo Ren
2025-10-12 10:00 ` Han Gao (Revy)
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Guo Ren @ 2025-10-12 6:07 UTC (permalink / raw)
To: Anup Patel
Cc: Alexandre Ghiti, Atish Patra, Anup Patel, Rafael J . Wysocki,
linux-kernel, Palmer Dabbelt, Paul Walmsley, linux-riscv,
Andrew Jones
On Wed, Aug 20, 2025 at 08:53:16PM +0530, Anup Patel wrote:
> The pgprot_dmacoherent() is used when allocating memory for
> non-coherent devices and by default pgprot_dmacoherent() is
> same as pgprot_noncached() unless architecture overrides it.
>
> Currently, there is no pgprot_dmacoherent() definition for
> RISC-V hence non-coherent device memory is being mapped as
> IO thereby making CPU access to such memory slow.
>
> Define pgprot_dmacoherent() to be same as pgprot_writecombine()
> for RISC-V so that CPU access non-coherent device memory as
> NOCACHE which is better than accessing it as IO.
>
> Fixes: ff689fd21cb1 ("riscv: add RISC-V Svpbmt extension support")
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> ---
> arch/riscv/include/asm/pgtable.h | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> index 91697fbf1f90..00d8bdaf1e8d 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -653,6 +653,8 @@ static inline pgprot_t pgprot_writecombine(pgprot_t _prot)
> return __pgprot(prot);
> }
>
> +#define pgprot_dmacoherent pgprot_writecombine
I missed this patch and sent out a duplicate one [1]. Maybe the comments
from [1] could be appended to this one.
Tested-by: Guo Ren (Alibaba DAMO Academy) <guoren@kernel.org>
> +
> /*
> * Both Svade and Svadu control the hardware behavior when the PTE A/D bits need to be set. By
> * default the M-mode firmware enables the hardware updating scheme when only Svadu is present in
> --
> 2.43.0
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] RISC-V: Define pgprot_dmacoherent() for non-coherent devices
2025-10-12 6:07 ` Guo Ren
@ 2025-10-12 6:59 ` Guo Ren
0 siblings, 0 replies; 6+ messages in thread
From: Guo Ren @ 2025-10-12 6:59 UTC (permalink / raw)
To: Anup Patel
Cc: Alexandre Ghiti, Atish Patra, Anup Patel, Rafael J . Wysocki,
linux-kernel, Palmer Dabbelt, Paul Walmsley, linux-riscv,
Andrew Jones
On Sun, Oct 12, 2025 at 02:07:34AM -0400, Guo Ren wrote:
> On Wed, Aug 20, 2025 at 08:53:16PM +0530, Anup Patel wrote:
> > The pgprot_dmacoherent() is used when allocating memory for
> > non-coherent devices and by default pgprot_dmacoherent() is
> > same as pgprot_noncached() unless architecture overrides it.
> >
> > Currently, there is no pgprot_dmacoherent() definition for
> > RISC-V hence non-coherent device memory is being mapped as
> > IO thereby making CPU access to such memory slow.
> >
> > Define pgprot_dmacoherent() to be same as pgprot_writecombine()
> > for RISC-V so that CPU access non-coherent device memory as
> > NOCACHE which is better than accessing it as IO.
> >
> > Fixes: ff689fd21cb1 ("riscv: add RISC-V Svpbmt extension support")
> > Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> > ---
> > arch/riscv/include/asm/pgtable.h | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> > index 91697fbf1f90..00d8bdaf1e8d 100644
> > --- a/arch/riscv/include/asm/pgtable.h
> > +++ b/arch/riscv/include/asm/pgtable.h
> > @@ -653,6 +653,8 @@ static inline pgprot_t pgprot_writecombine(pgprot_t _prot)
> > return __pgprot(prot);
> > }
> >
> > +#define pgprot_dmacoherent pgprot_writecombine
> I missed this patch and sent out a duplicate one [1]. Maybe the comments
> from [1] could be appended to this one.
[1]: https://lore.kernel.org/linux-riscv/20251011155746.1558731-1-guoren@kernel.org/
>
> Tested-by: Guo Ren (Alibaba DAMO Academy) <guoren@kernel.org>
>
> > +
> > /*
> > * Both Svade and Svadu control the hardware behavior when the PTE A/D bits need to be set. By
> > * default the M-mode firmware enables the hardware updating scheme when only Svadu is present in
> > --
> > 2.43.0
> >
> >
> > _______________________________________________
> > linux-riscv mailing list
> > linux-riscv@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-riscv
> >
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] RISC-V: Define pgprot_dmacoherent() for non-coherent devices
2025-08-20 15:23 [PATCH] RISC-V: Define pgprot_dmacoherent() for non-coherent devices Anup Patel
2025-10-12 6:07 ` Guo Ren
@ 2025-10-12 10:00 ` Han Gao (Revy)
2025-10-18 16:01 ` patchwork-bot+linux-riscv
2026-05-09 11:56 ` Vadim Akimov
3 siblings, 0 replies; 6+ messages in thread
From: Han Gao (Revy) @ 2025-10-12 10:00 UTC (permalink / raw)
To: Anup Patel
Cc: Atish Patra, Alexandre Ghiti, Rafael J . Wysocki, Anup Patel,
Han Gao (Revy), linux-kernel, Palmer Dabbelt, Paul Walmsley,
linux-riscv, Andrew Jones
> On Aug 20, 2025, at 23:23, Anup Patel <apatel@ventanamicro.com> wrote:
>
> The pgprot_dmacoherent() is used when allocating memory for
> non-coherent devices and by default pgprot_dmacoherent() is
> same as pgprot_noncached() unless architecture overrides it.
>
> Currently, there is no pgprot_dmacoherent() definition for
> RISC-V hence non-coherent device memory is being mapped as
> IO thereby making CPU access to such memory slow.
>
> Define pgprot_dmacoherent() to be same as pgprot_writecombine()
> for RISC-V so that CPU access non-coherent device memory as
> NOCACHE which is better than accessing it as IO.
>
> Fixes: ff689fd21cb1 ("riscv: add RISC-V Svpbmt extension support")
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Tested-by: Han Gao <rabenda.cn@gmail.com>
> ---
> arch/riscv/include/asm/pgtable.h | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> index 91697fbf1f90..00d8bdaf1e8d 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -653,6 +653,8 @@ static inline pgprot_t pgprot_writecombine(pgprot_t _prot)
> return __pgprot(prot);
> }
>
> +#define pgprot_dmacoherent pgprot_writecombine
> +
> /*
> * Both Svade and Svadu control the hardware behavior when the PTE A/D bits need to be set. By
> * default the M-mode firmware enables the hardware updating scheme when only Svadu is present in
> --
> 2.43.0
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] RISC-V: Define pgprot_dmacoherent() for non-coherent devices
2025-08-20 15:23 [PATCH] RISC-V: Define pgprot_dmacoherent() for non-coherent devices Anup Patel
2025-10-12 6:07 ` Guo Ren
2025-10-12 10:00 ` Han Gao (Revy)
@ 2025-10-18 16:01 ` patchwork-bot+linux-riscv
2026-05-09 11:56 ` Vadim Akimov
3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+linux-riscv @ 2025-10-18 16:01 UTC (permalink / raw)
To: Anup Patel
Cc: alex, rafael, anup, atish.patra, linux-kernel, palmer,
paul.walmsley, linux-riscv, ajones
Hello:
This patch was applied to riscv/linux.git (fixes)
by Paul Walmsley <pjw@kernel.org>:
On Wed, 20 Aug 2025 20:53:16 +0530 you wrote:
> The pgprot_dmacoherent() is used when allocating memory for
> non-coherent devices and by default pgprot_dmacoherent() is
> same as pgprot_noncached() unless architecture overrides it.
>
> Currently, there is no pgprot_dmacoherent() definition for
> RISC-V hence non-coherent device memory is being mapped as
> IO thereby making CPU access to such memory slow.
>
> [...]
Here is the summary with links:
- RISC-V: Define pgprot_dmacoherent() for non-coherent devices
https://git.kernel.org/riscv/c/ca525d53f994
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] RISC-V: Define pgprot_dmacoherent() for non-coherent devices
2025-08-20 15:23 [PATCH] RISC-V: Define pgprot_dmacoherent() for non-coherent devices Anup Patel
` (2 preceding siblings ...)
2025-10-18 16:01 ` patchwork-bot+linux-riscv
@ 2026-05-09 11:56 ` Vadim Akimov
3 siblings, 0 replies; 6+ messages in thread
From: Vadim Akimov @ 2026-05-09 11:56 UTC (permalink / raw)
To: Anup Patel
Cc: Alexandre Ghiti, Atish Patra, Anup Patel, Rafael J . Wysocki,
linux-kernel, Palmer Dabbelt, Paul Walmsley, linux-riscv,
linux-sunxi, Andrew Jones
Hi,
On Wed, Aug 20, 2025 at 08:53:16PM +0530, Anup Patel wrote:
> The pgprot_dmacoherent() is used when allocating memory for
> non-coherent devices and by default pgprot_dmacoherent() is
> same as pgprot_noncached() unless architecture overrides it.
> diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> index 91697fbf1f90..00d8bdaf1e8d 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> +#define pgprot_dmacoherent pgprot_writecombine
This single-line patch, as implemented in commit 00b58d2c25d10fecffbebaa0c369fc9d0a6de397 for 6.6.y,
breaks allwinner D1 SDcard handling:
[ 0.000000] Linux version 6.6.115 (surfin@nedoserver) (riscv64-unknown-linux-gnu-gcc () 11.3.0, GNU ld (GNU Binutils) 2.38) #1 Tue May 5 10:25:47 MSK 2026
[ 4.886823] sunxi-mmc 4020000.mmc: Got CD GPIO
[ 4.893625] sunxi-mmc 4021000.mmc: allocated mmc-pwrseq
[ 4.941711] sunxi-mmc 4021000.mmc: initialized, max. request size: 2048 KB, uses new timings mode
[ 4.958033] sunxi-mmc 4020000.mmc: initialized, max. request size: 2048 KB, uses new timings mode
[ 4.990692] sunxi-mmc 4021000.mmc: card claims to support voltages below defined range
[ 5.009712] mmc1: new high speed SDIO card at address 0001
then following never happens with that patch, i.e. no SD card is found.
#[ 5.109896] mmc0: new high speed SDHC card at address 0001
#[ 5.116546] mmcblk0: mmc0:0001 EB1QT 29.8 GiB
#[ 5.128887] mmcblk0: p1 p2
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-05-09 11:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20 15:23 [PATCH] RISC-V: Define pgprot_dmacoherent() for non-coherent devices Anup Patel
2025-10-12 6:07 ` Guo Ren
2025-10-12 6:59 ` Guo Ren
2025-10-12 10:00 ` Han Gao (Revy)
2025-10-18 16:01 ` patchwork-bot+linux-riscv
2026-05-09 11:56 ` Vadim Akimov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox