diff mbox series

[v5,4/4] mips: bmips: enable RAC on BMIPS4350

Message ID 20240511130349.23409-5-ansuelsmth@gmail.com (mailing list archive)
State Superseded
Headers show
Series mips: bmips: improve handling of RAC and CBR addr | expand

Commit Message

Christian Marangi May 11, 2024, 1:03 p.m. UTC
From: Daniel González Cabanelas <dgcbueu@gmail.com>

The data RAC is left disabled by the bootloader in some SoCs, at least in
the core it boots from.
Enabling this feature increases the performance up to +30% depending on the
task.

Signed-off-by: Daniel González Cabanelas <dgcbueu@gmail.com>
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
[ rework code and reduce code duplication ]
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Acked-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 arch/mips/kernel/smp-bmips.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Thomas Bogendoerfer June 11, 2024, 8:47 a.m. UTC | #1
On Sat, May 11, 2024 at 03:03:48PM +0200, Christian Marangi wrote:
> From: Daniel González Cabanelas <dgcbueu@gmail.com>
> 
> The data RAC is left disabled by the bootloader in some SoCs, at least in
> the core it boots from.
> Enabling this feature increases the performance up to +30% depending on the
> task.
> 
> Signed-off-by: Daniel González Cabanelas <dgcbueu@gmail.com>
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> [ rework code and reduce code duplication ]
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> Acked-by: Florian Fainelli <florian.fainelli@broadcom.com>
> ---
>  arch/mips/kernel/smp-bmips.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c
> index 20e2fb10022d..52324738cbb3 100644
> --- a/arch/mips/kernel/smp-bmips.c
> +++ b/arch/mips/kernel/smp-bmips.c
> @@ -626,6 +626,23 @@ void bmips_cpu_setup(void)
>  		__raw_readl(cbr + BMIPS_RAC_ADDRESS_RANGE);
>  		break;
>  
> +	case CPU_BMIPS4350:
> +		u32 rac_addr = BMIPS_RAC_CONFIG_1;

my gcc 10.2.1 doesn't like the declaration here:

/local/tbogendoerfer/korg/linux/arch/mips/kernel/smp-bmips.c:630:3: error: a label can only be part of a statement and a declaration is not a statement
  630 |   u32 rac_addr = BMIPS_RAC_CONFIG_1;

Thomas.
Christian Marangi June 11, 2024, 11:37 a.m. UTC | #2
On Tue, Jun 11, 2024 at 10:47:16AM +0200, Thomas Bogendoerfer wrote:
> On Sat, May 11, 2024 at 03:03:48PM +0200, Christian Marangi wrote:
> > From: Daniel González Cabanelas <dgcbueu@gmail.com>
> > 
> > The data RAC is left disabled by the bootloader in some SoCs, at least in
> > the core it boots from.
> > Enabling this feature increases the performance up to +30% depending on the
> > task.
> > 
> > Signed-off-by: Daniel González Cabanelas <dgcbueu@gmail.com>
> > Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> > [ rework code and reduce code duplication ]
> > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> > Acked-by: Florian Fainelli <florian.fainelli@broadcom.com>
> > ---
> >  arch/mips/kernel/smp-bmips.c | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> > 
> > diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c
> > index 20e2fb10022d..52324738cbb3 100644
> > --- a/arch/mips/kernel/smp-bmips.c
> > +++ b/arch/mips/kernel/smp-bmips.c
> > @@ -626,6 +626,23 @@ void bmips_cpu_setup(void)
> >  		__raw_readl(cbr + BMIPS_RAC_ADDRESS_RANGE);
> >  		break;
> >  
> > +	case CPU_BMIPS4350:
> > +		u32 rac_addr = BMIPS_RAC_CONFIG_1;
> 
> my gcc 10.2.1 doesn't like the declaration here:
> 
> /local/tbogendoerfer/korg/linux/arch/mips/kernel/smp-bmips.c:630:3: error: a label can only be part of a statement and a declaration is not a statement
>   630 |   u32 rac_addr = BMIPS_RAC_CONFIG_1;
>

Thanks I moved the declaration up before the switch.
diff mbox series

Patch

diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c
index 20e2fb10022d..52324738cbb3 100644
--- a/arch/mips/kernel/smp-bmips.c
+++ b/arch/mips/kernel/smp-bmips.c
@@ -626,6 +626,23 @@  void bmips_cpu_setup(void)
 		__raw_readl(cbr + BMIPS_RAC_ADDRESS_RANGE);
 		break;
 
+	case CPU_BMIPS4350:
+		u32 rac_addr = BMIPS_RAC_CONFIG_1;
+
+		if (!(read_c0_brcm_cmt_local() & (1 << 31)))
+			rac_addr = BMIPS_RAC_CONFIG;
+
+		/* Enable data RAC */
+		cfg = __raw_readl(cbr + rac_addr);
+		__raw_writel(cfg | 0xf, cbr + rac_addr);
+		__raw_readl(cbr + rac_addr);
+
+		/* Flush stale data out of the readahead cache */
+		cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG);
+		__raw_writel(cfg | 0x100, cbr + BMIPS_RAC_CONFIG);
+		__raw_readl(cbr + BMIPS_RAC_CONFIG);
+		break;
+
 	case CPU_BMIPS4380:
 		/* CBG workaround for early BMIPS4380 CPUs */
 		switch (read_c0_prid()) {