Subject: Re: spontaneous reboot only once after power-up
To: None <port-dreamcast@netbsd.org, port-sh3@netbsd.org>
From: ITOH Yasufumi <itohy@netbsd.org>
List: port-dreamcast
Date: 11/03/2002 13:56:07
In article <200211021730.gA2HUZM06440@mirage.ceres.dti.ne.jp>
tsutsui@ceres.dti.ne.jp writes:

> In article <200211021530.gA2FUb914591@pl374.nas911.nara.nttpc.ne.jp>
> itohy@netbsd.org wrote:
> 
> > I happen to try following change and the problem disappear.
> > Here, we are clearing the TLB.  The original code clears TLB
> > via address array, and new code does it via data array 1.
> 
> I just take a look at SH4 programming manual, but
> I guess if you use UTLB data array 1 to invalidate TLB entries
> there are follow problems:
> (1) it does not clear VPN

I don't think it is a problem.
The V (valid) and D (dirty) bits are cleared by either way,
and the VPN shall not make sense if an entry is not valid
(if the MMU works as described).

> (2) it might break other bits (cacheable, writethrough etc.)

If a new entry is loaded by LDTLB instruction
all the fields will be overwritten, and I don't think
it is a problem (if the MMU works as described :-).

I tried some alternatives in sh4_tlb_invalidate_all():

(a) the code of my previous mail (works)
	for (e = 0; e < eend; e++) {
		a = SH4_UTLB_DA1 | (e << SH4_UTLB_E_SHIFT);
		_reg_write_4(a, 0);	/* SZ = 0 */
	}

(b) page size 1MB (causes reset)
	for (e = 0; e < eend; e++) {
		a = SH4_UTLB_DA1 | (e << SH4_UTLB_E_SHIFT);
		_reg_write_4(a, 0x90);	/* SZ = 3 */
	}

...and I think at least the SZ (page size) field should be initialized.

Possibly, an errata or something?
Have anyone heard something like this?

> BTW, there is an errata about TLB usage for SH3:
> http://www.hitachisemiconductor.com/sic/resource/japan/eng/pdf/mpumcu/ms/tnsh7291ae.pdf
> According to this doc, it's better to wrote 0xf0000000 to VPN on
> invalidating TLB entries to avoid an exception on TLB
> (which might cause another bug of SH3).

Mmm, I tried

(c) VA = 0xf0000000 (causes reset)
	for (e = 0; e < eend; e++) {
		a = SH4_UTLB_AA | (e << SH4_UTLB_E_SHIFT);
		_reg_write_4(a, 0xf0000000);
	}

and no improvement.

Thoughts?
-- 
ITOH Yasufumi