Subject: macppc softint handling
To: None <port-macppc@netbsd.org>
From: Bill Sommerfeld <sommerfeld@orchard.arlington.ma.us>
List: port-macppc
Date: 01/01/2001 12:07:35
[i don't subscribe to this port list..]

Someone asked me to look at the macppc softint code.

der Mouse's evaluation is correct; the
	ipending &= pcpl;

at the end of do_pending_int() is bogus.

there  since any set ipending bits
are cleared before the handler runs; if code called from the
softserial() handler sets SIR_NET, you can lose softnet interrupts.
If your only network interface is ppp, nothing else is likely to
generate them.

some suggestions: 

1) clear bits out of ipending before the handlers are invoked:

	hwpend = ipending & ~pcpl;	/* Do now unmasked pendings */
	if (!have_openpic) {
		imen &= ~hwpend;
		enable_irq(~imen);
	}
	hwpend &= HWIRQ_MASK;
	while (hwpend) {
		irq = 31 - cntlzw(hwpend);
		ipending &= ~(1L << irq);
		...
		hwpend = ipending & ~pcpl;
		hwpend &= HWIRQ_MASK;
	}

2) there should be a similar loop around the softint handlers; you
could reorder the invocation of the handlers (softserial first, then
softnet) as an "optimization" but for correctness purposes you're
better off assuming that any softint routine could post any other
softint.

3) since both software and hardware interrupts use "ipending", don't
bother with hwpend and HWIRQ_MASK; put the softint handler into the
intrhand[] tables, and clear bits out of ipending just before invoking
the handlers...

					- Bill