public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [RFC PATCH 1/3] riscv: errata: cmo: add CMO macro variant with both VA and PA
       [not found] ` <20230104074146.578485-2-uwu@icenowy.me>
@ 2023-01-04  8:48   ` Guo Ren
  0 siblings, 0 replies; 7+ messages in thread
From: Guo Ren @ 2023-01-04  8:48 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Heiko Stuebner,
	Samuel Holland, Conor Dooley, linux-riscv, linux-kernel

Thx for the patch! It's nice.

Reviewed-by: Guo Ren <guoren@kernel.org>

On Wed, Jan 4, 2023 at 3:42 PM Icenowy Zheng <uwu@icenowy.me> wrote:
>
> The standardized Zicbom extension supports only VA, however there's some
> vendor extensions (e.g. XtheadCmo) that can handle cache management
> operations on PA directly, bypassing the TLB lookup.
>
> Add a CMO alternatives macro variant that come with both VA and PA
> supplied, and the code can be patched to use either the VA or the PA at
> runtime. In this case the codepath is now patched to use VA for Zicbom
> and PA for XtheadCmo.
>
> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> ---
>  arch/riscv/include/asm/errata_list.h | 30 ++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
>
> diff --git a/arch/riscv/include/asm/errata_list.h b/arch/riscv/include/asm/errata_list.h
> index 46adc1c9428f..bf80dd58145e 100644
> --- a/arch/riscv/include/asm/errata_list.h
> +++ b/arch/riscv/include/asm/errata_list.h
> @@ -118,6 +118,9 @@ asm volatile(ALTERNATIVE(                                           \
>  #define THEAD_clean_A0 ".long 0x0255000b"
>  #define THEAD_flush_A0 ".long 0x0275000b"
>  #define THEAD_SYNC_S   ".long 0x0190000b"
> +#define THEAD_inval_PA_A0      ".long 0x02a5000b"
> +#define THEAD_clean_PA_A0      ".long 0x0295000b"
> +#define THEAD_flush_PA_A0      ".long 0x02b5000b"
>
>  #define ALT_CMO_OP(_op, _start, _size, _cachesize)                     \
>  asm volatile(ALTERNATIVE_2(                                            \
> @@ -144,6 +147,33 @@ asm volatile(ALTERNATIVE_2(                                                \
>             "r"((unsigned long)(_start) + (_size))                      \
>         : "a0")
>
> +#define ALT_CMO_OP_VPA(_op, _vaddr, _paddr, _size, _cachesize)         \
> +asm volatile(ALTERNATIVE_2(                                            \
> +       __nops(6),                                                      \
> +       "mv a0, %1\n\t"                                                 \
> +       "j 2f\n\t"                                                      \
> +       "3:\n\t"                                                        \
> +       "cbo." __stringify(_op) " (a0)\n\t"                             \
> +       "add a0, a0, %0\n\t"                                            \
> +       "2:\n\t"                                                        \
> +       "bltu a0, %2, 3b\n\t"                                           \
> +       "nop", 0, CPUFEATURE_ZICBOM, CONFIG_RISCV_ISA_ZICBOM,           \
> +       "mv a0, %3\n\t"                                                 \
> +       "j 2f\n\t"                                                      \
> +       "3:\n\t"                                                        \
> +       THEAD_##_op##_PA_A0 "\n\t"                                      \
> +       "add a0, a0, %0\n\t"                                            \
> +       "2:\n\t"                                                        \
> +       "bltu a0, %4, 3b\n\t"                                           \
> +       THEAD_SYNC_S, THEAD_VENDOR_ID,                                  \
> +                       ERRATA_THEAD_CMO, CONFIG_ERRATA_THEAD_CMO)      \
> +       : : "r"(_cachesize),                                            \
> +           "r"((unsigned long)(_vaddr) & ~((_cachesize) - 1UL)),       \
> +           "r"((unsigned long)(_vaddr) + (_size)),                     \
> +           "r"((unsigned long)(_paddr) & ~((_cachesize) - 1UL)),       \
> +           "r"((unsigned long)(_paddr) + (_size))                      \
> +       : "a0")
> +
>  #define THEAD_C9XX_RV_IRQ_PMU                  17
>  #define THEAD_C9XX_CSR_SCOUNTEROF              0x5c5
>
> --
> 2.38.1
>


-- 
Best Regards
 Guo Ren

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 2/3] riscv: use VA+PA variant of CMO macros for DMA synchorization
       [not found] ` <20230104074146.578485-3-uwu@icenowy.me>
@ 2023-01-04  8:50   ` Guo Ren
  2023-01-04  8:59     ` Icenowy Zheng
  0 siblings, 1 reply; 7+ messages in thread
From: Guo Ren @ 2023-01-04  8:50 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Heiko Stuebner,
	Samuel Holland, Conor Dooley, linux-riscv, linux-kernel

On Wed, Jan 4, 2023 at 3:43 PM Icenowy Zheng <uwu@icenowy.me> wrote:
>
> DMA synchorization is done on PA and the VA is calculated from the PA.
>
> Use the alternative macro variant that takes both VA and PA as
> parameters, thus in case the ISA extension used support PA directly, the
> overhead for re-converting VA to PA can be omitted.
>
> Suggested-by: Guo Ren <guoren@kernel.org>
> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> ---
>  arch/riscv/mm/dma-noncoherent.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/riscv/mm/dma-noncoherent.c b/arch/riscv/mm/dma-noncoherent.c
> index d919efab6eba..a751f4aece62 100644
> --- a/arch/riscv/mm/dma-noncoherent.c
> +++ b/arch/riscv/mm/dma-noncoherent.c
> @@ -19,13 +19,13 @@ void arch_sync_dma_for_device(phys_addr_t paddr, size_t size,
>
>         switch (dir) {
>         case DMA_TO_DEVICE:
> -               ALT_CMO_OP(clean, vaddr, size, riscv_cbom_block_size);
> +               ALT_CMO_OP_VPA(clean, vaddr, paddr, size, riscv_cbom_block_size);
ALT_CMO_OP -> ALT_CMO_OP_VPA, is the renaming necessary?

Others:
Reviewed-by: Guo Ren <guoren@kernel.org>

>                 break;
>         case DMA_FROM_DEVICE:
> -               ALT_CMO_OP(clean, vaddr, size, riscv_cbom_block_size);
> +               ALT_CMO_OP_VPA(clean, vaddr, paddr, size, riscv_cbom_block_size);
>                 break;
>         case DMA_BIDIRECTIONAL:
> -               ALT_CMO_OP(flush, vaddr, size, riscv_cbom_block_size);
> +               ALT_CMO_OP_VPA(flush, vaddr, paddr, size, riscv_cbom_block_size);
>                 break;
>         default:
>                 break;
> @@ -42,7 +42,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
>                 break;
>         case DMA_FROM_DEVICE:
>         case DMA_BIDIRECTIONAL:
> -               ALT_CMO_OP(flush, vaddr, size, riscv_cbom_block_size);
> +               ALT_CMO_OP_VPA(flush, vaddr, paddr, size, riscv_cbom_block_size);
>                 break;
>         default:
>                 break;
> --
> 2.38.1
>


-- 
Best Regards
 Guo Ren

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 2/3] riscv: use VA+PA variant of CMO macros for DMA synchorization
  2023-01-04  8:50   ` [RFC PATCH 2/3] riscv: use VA+PA variant of CMO macros for DMA synchorization Guo Ren
@ 2023-01-04  8:59     ` Icenowy Zheng
  2023-01-04  9:24       ` Guo Ren
  0 siblings, 1 reply; 7+ messages in thread
From: Icenowy Zheng @ 2023-01-04  8:59 UTC (permalink / raw)
  To: Guo Ren
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Heiko Stuebner,
	Samuel Holland, Conor Dooley, linux-riscv, linux-kernel

在 2023-01-04星期三的 16:50 +0800,Guo Ren写道:
> On Wed, Jan 4, 2023 at 3:43 PM Icenowy Zheng <uwu@icenowy.me> wrote:
> > 
> > DMA synchorization is done on PA and the VA is calculated from the
> > PA.
> > 
> > Use the alternative macro variant that takes both VA and PA as
> > parameters, thus in case the ISA extension used support PA
> > directly, the
> > overhead for re-converting VA to PA can be omitted.
> > 
> > Suggested-by: Guo Ren <guoren@kernel.org>
> > Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> > ---
> >  arch/riscv/mm/dma-noncoherent.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/arch/riscv/mm/dma-noncoherent.c b/arch/riscv/mm/dma-
> > noncoherent.c
> > index d919efab6eba..a751f4aece62 100644
> > --- a/arch/riscv/mm/dma-noncoherent.c
> > +++ b/arch/riscv/mm/dma-noncoherent.c
> > @@ -19,13 +19,13 @@ void arch_sync_dma_for_device(phys_addr_t
> > paddr, size_t size,
> > 
> >         switch (dir) {
> >         case DMA_TO_DEVICE:
> > -               ALT_CMO_OP(clean, vaddr, size,
> > riscv_cbom_block_size);
> > +               ALT_CMO_OP_VPA(clean, vaddr, paddr, size,
> > riscv_cbom_block_size);
> ALT_CMO_OP -> ALT_CMO_OP_VPA, is the renaming necessary?

I didn't rename the original ALT_CMO_OP, ALT_CMO_OP_VPA is something
new.

> 
> Others:
> Reviewed-by: Guo Ren <guoren@kernel.org>
> 
> >                 break;
> >         case DMA_FROM_DEVICE:
> > -               ALT_CMO_OP(clean, vaddr, size,
> > riscv_cbom_block_size);
> > +               ALT_CMO_OP_VPA(clean, vaddr, paddr, size,
> > riscv_cbom_block_size);
> >                 break;
> >         case DMA_BIDIRECTIONAL:
> > -               ALT_CMO_OP(flush, vaddr, size,
> > riscv_cbom_block_size);
> > +               ALT_CMO_OP_VPA(flush, vaddr, paddr, size,
> > riscv_cbom_block_size);
> >                 break;
> >         default:
> >                 break;
> > @@ -42,7 +42,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr,
> > size_t size,
> >                 break;
> >         case DMA_FROM_DEVICE:
> >         case DMA_BIDIRECTIONAL:
> > -               ALT_CMO_OP(flush, vaddr, size,
> > riscv_cbom_block_size);
> > +               ALT_CMO_OP_VPA(flush, vaddr, paddr, size,
> > riscv_cbom_block_size);
> >                 break;
> >         default:
> >                 break;
> > --
> > 2.38.1
> > 
> 
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 2/3] riscv: use VA+PA variant of CMO macros for DMA synchorization
  2023-01-04  8:59     ` Icenowy Zheng
@ 2023-01-04  9:24       ` Guo Ren
  2023-01-04  9:27         ` Icenowy Zheng
  0 siblings, 1 reply; 7+ messages in thread
From: Guo Ren @ 2023-01-04  9:24 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Heiko Stuebner,
	Samuel Holland, Conor Dooley, linux-riscv, linux-kernel

On Wed, Jan 4, 2023 at 4:59 PM Icenowy Zheng <uwu@icenowy.me> wrote:
>
> 在 2023-01-04星期三的 16:50 +0800,Guo Ren写道:
> > On Wed, Jan 4, 2023 at 3:43 PM Icenowy Zheng <uwu@icenowy.me> wrote:
> > >
> > > DMA synchorization is done on PA and the VA is calculated from the
> > > PA.
> > >
> > > Use the alternative macro variant that takes both VA and PA as
> > > parameters, thus in case the ISA extension used support PA
> > > directly, the
> > > overhead for re-converting VA to PA can be omitted.
> > >
> > > Suggested-by: Guo Ren <guoren@kernel.org>
> > > Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> > > ---
> > >  arch/riscv/mm/dma-noncoherent.c | 8 ++++----
> > >  1 file changed, 4 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/arch/riscv/mm/dma-noncoherent.c b/arch/riscv/mm/dma-
> > > noncoherent.c
> > > index d919efab6eba..a751f4aece62 100644
> > > --- a/arch/riscv/mm/dma-noncoherent.c
> > > +++ b/arch/riscv/mm/dma-noncoherent.c
> > > @@ -19,13 +19,13 @@ void arch_sync_dma_for_device(phys_addr_t
> > > paddr, size_t size,
> > >
> > >         switch (dir) {
> > >         case DMA_TO_DEVICE:
> > > -               ALT_CMO_OP(clean, vaddr, size,
> > > riscv_cbom_block_size);
> > > +               ALT_CMO_OP_VPA(clean, vaddr, paddr, size,
> > > riscv_cbom_block_size);
> > ALT_CMO_OP -> ALT_CMO_OP_VPA, is the renaming necessary?
>
> I didn't rename the original ALT_CMO_OP, ALT_CMO_OP_VPA is something
> new.
The ##_VPA is really strange.

How about:
ALT_CMO_OP          -> ALT_CMO_OP_VA
ALT_CMO_OP_VPA -> ALT_CMO_OP

>
> >
> > Others:
> > Reviewed-by: Guo Ren <guoren@kernel.org>
> >
> > >                 break;
> > >         case DMA_FROM_DEVICE:
> > > -               ALT_CMO_OP(clean, vaddr, size,
> > > riscv_cbom_block_size);
> > > +               ALT_CMO_OP_VPA(clean, vaddr, paddr, size,
> > > riscv_cbom_block_size);
> > >                 break;
> > >         case DMA_BIDIRECTIONAL:
> > > -               ALT_CMO_OP(flush, vaddr, size,
> > > riscv_cbom_block_size);
> > > +               ALT_CMO_OP_VPA(flush, vaddr, paddr, size,
> > > riscv_cbom_block_size);
> > >                 break;
> > >         default:
> > >                 break;
> > > @@ -42,7 +42,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr,
> > > size_t size,
> > >                 break;
> > >         case DMA_FROM_DEVICE:
> > >         case DMA_BIDIRECTIONAL:
> > > -               ALT_CMO_OP(flush, vaddr, size,
> > > riscv_cbom_block_size);
> > > +               ALT_CMO_OP_VPA(flush, vaddr, paddr, size,
> > > riscv_cbom_block_size);
> > >                 break;
> > >         default:
> > >                 break;
> > > --
> > > 2.38.1
> > >
> >
> >
>


-- 
Best Regards
 Guo Ren

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 2/3] riscv: use VA+PA variant of CMO macros for DMA synchorization
  2023-01-04  9:24       ` Guo Ren
@ 2023-01-04  9:27         ` Icenowy Zheng
  2023-01-04 12:16           ` Heiko Stübner
  0 siblings, 1 reply; 7+ messages in thread
From: Icenowy Zheng @ 2023-01-04  9:27 UTC (permalink / raw)
  To: Guo Ren
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Heiko Stuebner,
	Samuel Holland, Conor Dooley, linux-riscv, linux-kernel

在 2023-01-04星期三的 17:24 +0800,Guo Ren写道:
> On Wed, Jan 4, 2023 at 4:59 PM Icenowy Zheng <uwu@icenowy.me> wrote:
> > 
> > 在 2023-01-04星期三的 16:50 +0800,Guo Ren写道:
> > > On Wed, Jan 4, 2023 at 3:43 PM Icenowy Zheng <uwu@icenowy.me>
> > > wrote:
> > > > 
> > > > DMA synchorization is done on PA and the VA is calculated from
> > > > the
> > > > PA.
> > > > 
> > > > Use the alternative macro variant that takes both VA and PA as
> > > > parameters, thus in case the ISA extension used support PA
> > > > directly, the
> > > > overhead for re-converting VA to PA can be omitted.
> > > > 
> > > > Suggested-by: Guo Ren <guoren@kernel.org>
> > > > Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> > > > ---
> > > >  arch/riscv/mm/dma-noncoherent.c | 8 ++++----
> > > >  1 file changed, 4 insertions(+), 4 deletions(-)
> > > > 
> > > > diff --git a/arch/riscv/mm/dma-noncoherent.c
> > > > b/arch/riscv/mm/dma-
> > > > noncoherent.c
> > > > index d919efab6eba..a751f4aece62 100644
> > > > --- a/arch/riscv/mm/dma-noncoherent.c
> > > > +++ b/arch/riscv/mm/dma-noncoherent.c
> > > > @@ -19,13 +19,13 @@ void arch_sync_dma_for_device(phys_addr_t
> > > > paddr, size_t size,
> > > > 
> > > >         switch (dir) {
> > > >         case DMA_TO_DEVICE:
> > > > -               ALT_CMO_OP(clean, vaddr, size,
> > > > riscv_cbom_block_size);
> > > > +               ALT_CMO_OP_VPA(clean, vaddr, paddr, size,
> > > > riscv_cbom_block_size);
> > > ALT_CMO_OP -> ALT_CMO_OP_VPA, is the renaming necessary?
> > 
> > I didn't rename the original ALT_CMO_OP, ALT_CMO_OP_VPA is
> > something
> > new.
> The ##_VPA is really strange.
> 
> How about:
> ALT_CMO_OP          -> ALT_CMO_OP_VA
> ALT_CMO_OP_VPA -> ALT_CMO_OP

It's thus a much bigger change.

If you are not fond of _VPA, I can rename it to _VA_PA.

> 
> > 
> > > 
> > > Others:
> > > Reviewed-by: Guo Ren <guoren@kernel.org>
> > > 
> > > >                 break;
> > > >         case DMA_FROM_DEVICE:
> > > > -               ALT_CMO_OP(clean, vaddr, size,
> > > > riscv_cbom_block_size);
> > > > +               ALT_CMO_OP_VPA(clean, vaddr, paddr, size,
> > > > riscv_cbom_block_size);
> > > >                 break;
> > > >         case DMA_BIDIRECTIONAL:
> > > > -               ALT_CMO_OP(flush, vaddr, size,
> > > > riscv_cbom_block_size);
> > > > +               ALT_CMO_OP_VPA(flush, vaddr, paddr, size,
> > > > riscv_cbom_block_size);
> > > >                 break;
> > > >         default:
> > > >                 break;
> > > > @@ -42,7 +42,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr,
> > > > size_t size,
> > > >                 break;
> > > >         case DMA_FROM_DEVICE:
> > > >         case DMA_BIDIRECTIONAL:
> > > > -               ALT_CMO_OP(flush, vaddr, size,
> > > > riscv_cbom_block_size);
> > > > +               ALT_CMO_OP_VPA(flush, vaddr, paddr, size,
> > > > riscv_cbom_block_size);
> > > >                 break;
> > > >         default:
> > > >                 break;
> > > > --
> > > > 2.38.1
> > > > 
> > > 
> > > 
> > 
> 
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 2/3] riscv: use VA+PA variant of CMO macros for DMA synchorization
  2023-01-04  9:27         ` Icenowy Zheng
@ 2023-01-04 12:16           ` Heiko Stübner
  2023-01-06  7:38             ` Icenowy Zheng
  0 siblings, 1 reply; 7+ messages in thread
From: Heiko Stübner @ 2023-01-04 12:16 UTC (permalink / raw)
  To: Guo Ren, Icenowy Zheng
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Samuel Holland,
	Conor Dooley, linux-riscv, linux-kernel

Hi,

Am Mittwoch, 4. Januar 2023, 10:27:53 CET schrieb Icenowy Zheng:
> 在 2023-01-04星期三的 17:24 +0800,Guo Ren写道:
> > On Wed, Jan 4, 2023 at 4:59 PM Icenowy Zheng <uwu@icenowy.me> wrote:
> > > 
> > > 在 2023-01-04星期三的 16:50 +0800,Guo Ren写道:
> > > > On Wed, Jan 4, 2023 at 3:43 PM Icenowy Zheng <uwu@icenowy.me>
> > > > wrote:
> > > > > 
> > > > > DMA synchorization is done on PA and the VA is calculated from
> > > > > the
> > > > > PA.
> > > > > 
> > > > > Use the alternative macro variant that takes both VA and PA as
> > > > > parameters, thus in case the ISA extension used support PA
> > > > > directly, the
> > > > > overhead for re-converting VA to PA can be omitted.
> > > > > 
> > > > > Suggested-by: Guo Ren <guoren@kernel.org>
> > > > > Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> > > > > ---
> > > > >  arch/riscv/mm/dma-noncoherent.c | 8 ++++----
> > > > >  1 file changed, 4 insertions(+), 4 deletions(-)
> > > > > 
> > > > > diff --git a/arch/riscv/mm/dma-noncoherent.c
> > > > > b/arch/riscv/mm/dma-
> > > > > noncoherent.c
> > > > > index d919efab6eba..a751f4aece62 100644
> > > > > --- a/arch/riscv/mm/dma-noncoherent.c
> > > > > +++ b/arch/riscv/mm/dma-noncoherent.c
> > > > > @@ -19,13 +19,13 @@ void arch_sync_dma_for_device(phys_addr_t
> > > > > paddr, size_t size,
> > > > > 
> > > > >         switch (dir) {
> > > > >         case DMA_TO_DEVICE:
> > > > > -               ALT_CMO_OP(clean, vaddr, size,
> > > > > riscv_cbom_block_size);
> > > > > +               ALT_CMO_OP_VPA(clean, vaddr, paddr, size,
> > > > > riscv_cbom_block_size);
> > > > ALT_CMO_OP -> ALT_CMO_OP_VPA, is the renaming necessary?
> > > 
> > > I didn't rename the original ALT_CMO_OP, ALT_CMO_OP_VPA is
> > > something
> > > new.
> > The ##_VPA is really strange.
> > 
> > How about:
> > ALT_CMO_OP          -> ALT_CMO_OP_VA
> > ALT_CMO_OP_VPA -> ALT_CMO_OP
> 
> It's thus a much bigger change.
> 
> If you are not fond of _VPA, I can rename it to _VA_PA.

before you spend too much time on this, there is currently a parallel
discussion running about including all the other different vendor-
specific cache management.

See [0] and the thread before that for reference.

The consensus seems to be that cache-handling itself is not fast anyway,
and therefore to reduce complexity for the cache handling and move
non-zicbom cache-handling into a indirect function call that the can be
overridden at runtime.


Heiko

[0] https://lore.kernel.org/all/43aee000-5b89-4d94-98d2-b37b1a18a83e@app.fastmail.com/



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 2/3] riscv: use VA+PA variant of CMO macros for DMA synchorization
  2023-01-04 12:16           ` Heiko Stübner
@ 2023-01-06  7:38             ` Icenowy Zheng
  0 siblings, 0 replies; 7+ messages in thread
From: Icenowy Zheng @ 2023-01-06  7:38 UTC (permalink / raw)
  To: Heiko Stübner, Guo Ren
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Samuel Holland,
	Conor Dooley, linux-riscv, linux-kernel

在 2023-01-04星期三的 13:16 +0100,Heiko Stübner写道:
> Hi,
> 
> Am Mittwoch, 4. Januar 2023, 10:27:53 CET schrieb Icenowy Zheng:
> > 在 2023-01-04星期三的 17:24 +0800,Guo Ren写道:
> > > On Wed, Jan 4, 2023 at 4:59 PM Icenowy Zheng <uwu@icenowy.me>
> > > wrote:
> > > > 
> > > > 在 2023-01-04星期三的 16:50 +0800,Guo Ren写道:
> > > > > On Wed, Jan 4, 2023 at 3:43 PM Icenowy Zheng <uwu@icenowy.me>
> > > > > wrote:
> > > > > > 
> > > > > > DMA synchorization is done on PA and the VA is calculated
> > > > > > from
> > > > > > the
> > > > > > PA.
> > > > > > 
> > > > > > Use the alternative macro variant that takes both VA and PA
> > > > > > as
> > > > > > parameters, thus in case the ISA extension used support PA
> > > > > > directly, the
> > > > > > overhead for re-converting VA to PA can be omitted.
> > > > > > 
> > > > > > Suggested-by: Guo Ren <guoren@kernel.org>
> > > > > > Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> > > > > > ---
> > > > > >  arch/riscv/mm/dma-noncoherent.c | 8 ++++----
> > > > > >  1 file changed, 4 insertions(+), 4 deletions(-)
> > > > > > 
> > > > > > diff --git a/arch/riscv/mm/dma-noncoherent.c
> > > > > > b/arch/riscv/mm/dma-
> > > > > > noncoherent.c
> > > > > > index d919efab6eba..a751f4aece62 100644
> > > > > > --- a/arch/riscv/mm/dma-noncoherent.c
> > > > > > +++ b/arch/riscv/mm/dma-noncoherent.c
> > > > > > @@ -19,13 +19,13 @@ void
> > > > > > arch_sync_dma_for_device(phys_addr_t
> > > > > > paddr, size_t size,
> > > > > > 
> > > > > >         switch (dir) {
> > > > > >         case DMA_TO_DEVICE:
> > > > > > -               ALT_CMO_OP(clean, vaddr, size,
> > > > > > riscv_cbom_block_size);
> > > > > > +               ALT_CMO_OP_VPA(clean, vaddr, paddr, size,
> > > > > > riscv_cbom_block_size);
> > > > > ALT_CMO_OP -> ALT_CMO_OP_VPA, is the renaming necessary?
> > > > 
> > > > I didn't rename the original ALT_CMO_OP, ALT_CMO_OP_VPA is
> > > > something
> > > > new.
> > > The ##_VPA is really strange.
> > > 
> > > How about:
> > > ALT_CMO_OP          -> ALT_CMO_OP_VA
> > > ALT_CMO_OP_VPA -> ALT_CMO_OP
> > 
> > It's thus a much bigger change.
> > 
> > If you are not fond of _VPA, I can rename it to _VA_PA.
> 
> before you spend too much time on this, there is currently a parallel
> discussion running about including all the other different vendor-
> specific cache management.
> 
> See [0] and the thread before that for reference.

The code shown here seems to be only a draft, and not even testable.

> 
> The consensus seems to be that cache-handling itself is not fast
> anyway,
> and therefore to reduce complexity for the cache handling and move
> non-zicbom cache-handling into a indirect function call that the can
> be
> overridden at runtime.

Well yes I tested this patchset on my LiteX with OpenC906, and it does
not help at all on LiteETH throughtput. So maybe this is only some
theortical gain.

> 
> 
> Heiko
> 
> [0]
> https://lore.kernel.org/all/43aee000-5b89-4d94-98d2-b37b1a18a83e@app.fastmail.com/
> 
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-01-06  7:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20230104074146.578485-1-uwu@icenowy.me>
     [not found] ` <20230104074146.578485-2-uwu@icenowy.me>
2023-01-04  8:48   ` [RFC PATCH 1/3] riscv: errata: cmo: add CMO macro variant with both VA and PA Guo Ren
     [not found] ` <20230104074146.578485-3-uwu@icenowy.me>
2023-01-04  8:50   ` [RFC PATCH 2/3] riscv: use VA+PA variant of CMO macros for DMA synchorization Guo Ren
2023-01-04  8:59     ` Icenowy Zheng
2023-01-04  9:24       ` Guo Ren
2023-01-04  9:27         ` Icenowy Zheng
2023-01-04 12:16           ` Heiko Stübner
2023-01-06  7:38             ` Icenowy Zheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox