On Wed, 26 Jun 2002, Ladislav Michl wrote:
> +int be_ip22_handler(struct pt_regs *regs, int is_fixup)
> +{
> + save_and_clear_buserr();
> + if (nofault) {
> + nofault = 0;
> + compute_return_epc(regs);
> + return MIPS_BE_DISCARD;
> + }
> + return MIPS_BE_FIXUP;
> +}
I wouldn't use nofault -- it leads to reentrancy problems and I don't
think you really need it. You probably need to code it like this:
{
save_and_clear_buserr();
return is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL;
}
unless:
1. There is a condition when for is_fixup true you should ignore the fixup
anyway (e.g. what the bus error logic reports is irrelevant to fixups).
You should choose between MIPS_BE_FATAL and MIPS_BE_DISCARD then.
2. There is a condition when for is_fixup false, an error is not fatal and
execution should get restarted. You should return MIPS_BE_DISCARD then.
> +int ip22_baddr(unsigned int *val, unsigned long addr)
> +{
> + nofault = 1;
> + *val = *(volatile unsigned int *) addr;
> + __asm__ __volatile__("nop;nop;nop;nop");
> + if (nofault) {
> + nofault = 0;
> + return 0;
> + }
> + return -EFAULT;
> +}
Why not simply:
{
int err;
err = get_dbe(*val, (volatile unsigned int *) addr);
return err ? -EFAULT : 0;
}
It was designed exactly for this purpose. You may consider using "u32"
instead of "unsigned int" for hardware accesses to assure the type will
always be 32-bit.
Maciej
--
+ Maciej W. Rozycki, Technical University of Gdansk, Poland +
+--------------------------------------------------------------+
+ e-mail: macro@ds2.pg.gda.pl, PGP key available +
|