Re: R5000SC issues and fix

Nick Hudson <[email protected]> Fri, 5 Dec 2025 09:11:59 +0000
Newsgroups gmane.os.netbsd.ports.mips.devel
Message-ID <[email protected]>
On 05/12/2025 07:53, Adrian Chadd wrote:
> hi!
> 
> I dropped an R5000SC into the Indy and it just .. hung and then
> powered off after the kernel was handed the IP.
> 
> After a whole lot of fun digging, I narrowed it down to the dcache
> wbinv in the cache setup path and that led me to a 2020 change which
> broke things on this system:
> 
> ===
> commit f86ae8229690c251a562e5bd34efd02d230c471d
> Author: tsutsui <[email protected]>
> Date:   Sun Jun 14 15:12:56 2020 +0000
> 
>      Use proper "page" alignments for R5k Page Invalidate(S) op.  PR/55139
> ===
> 
> Simply reverting the math change done fixes it, ie:
> 
> ===
> diff --git a/sys/arch/mips/include/cache_r5k.h
> b/sys/arch/mips/include/cache_r5k.h
> index a59fa18fdc02..6bdf9bd688c2 100644
> --- a/sys/arch/mips/include/cache_r5k.h
> +++ b/sys/arch/mips/include/cache_r5k.h
> @@ -68,6 +68,11 @@ void r5k_sdcache_wb_range(register_t, vsize_t);
>   #define        R5K_SC_PAGESIZE         (R5K_SC_LINESIZE * 128)
>   #define        R5K_SC_PAGEMASK         (R5K_SC_PAGESIZE - 1)
> 
> +#if 0
>   #define        mips_r5k_round_page(x)  (((x) + (register_t)R5K_SC_PAGEMASK) \
>                                      & (register_t)R5K_SC_PAGEMASK)

#define mips_r5k_round_page(x)  (((x) + (register_t)R5K_SC_PAGEMASK) \
                                      & ~(register_t)R5K_SC_PAGEMASK)

might just do the trick