Re: [PATCH V3 03/10] MIPS: Loongson-3: Enable Store Fill Buffer at runtime

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Huacai,

On Sat, Apr 28, 2018 at 11:21:27AM +0800, Huacai Chen wrote:
> New Loongson-3 (Loongson-3A R2, Loongson-3A R3, and newer) has SFB
> (Store Fill Buffer) which can improve the performance of memory access.
> Now, SFB enablement is controlled by CONFIG_LOONGSON3_ENHANCEMENT, and
> the generic kernel has no benefit from SFB (even it is running on a new
> Loongson-3 machine). With this patch, we can enable SFB at runtime by
> detecting the CPU type (the expense is war_io_reorder_wmb() will always
> be a 'sync', which will hurt the performance of old Loongson-3).

Neat - I like the move towards the kernel detecting this at runtime,
rather than requiring the user to select it at configuration/build time.

> diff --git a/arch/mips/include/asm/mach-loongson64/kernel-entry-init.h b/arch/mips/include/asm/mach-loongson64/kernel-entry-init.h
> index 3127391..cbac603 100644
> --- a/arch/mips/include/asm/mach-loongson64/kernel-entry-init.h
> +++ b/arch/mips/include/asm/mach-loongson64/kernel-entry-init.h
> @@ -11,6 +11,8 @@
>  #ifndef __ASM_MACH_LOONGSON64_KERNEL_ENTRY_H
>  #define __ASM_MACH_LOONGSON64_KERNEL_ENTRY_H
>  
> +#include <asm/cpu.h>
> +
>  /*
>   * Override macros used in arch/mips/kernel/head.S.
>   */
> @@ -26,12 +28,15 @@
>  	mfc0	t0, CP0_PAGEGRAIN
>  	or	t0, (0x1 << 29)
>  	mtc0	t0, CP0_PAGEGRAIN
> -#ifdef CONFIG_LOONGSON3_ENHANCEMENT
>  	/* Enable STFill Buffer */
> +	mfc0	t0, CP0_PRID
> +	andi	t0, (PRID_IMP_MASK | PRID_REV_MASK)
> +	slti	t0, (PRID_IMP_LOONGSON_64 | PRID_REV_LOONGSON3A_R2)
> +	bnez	t0, 1f
>  	mfc0	t0, CP0_CONFIG6
>  	or	t0, 0x100
>  	mtc0	t0, CP0_CONFIG6
> -#endif
> +1:
>  	_ehb
>  	.set	pop
>  #endif

I think it'd be neater if we did this from C in cpu_probe_loongson()
though. If we add __BUILD_SET_C0(config6) to asm/mipsregs.h and define a
macro naming the SFB enable bit then both boot CPU & secondary cases
could be handled by a single line in cpu_probe_loongson(). Something
like this:

    set_c0_config6(LOONGSON_CONFIG6_SFB_ENABLE);

Unless there's a technical reason this doesn't work I'd prefer it to the
assembly version (and maybe we could move the LPA & ELPA configuration
into cpu-probe.c too then remove asm/mach-loongson64/kernel-entry-init.h
entirely).

Thanks,
    Paul




[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux