in belated regression testing, i found that i introduced a
bug in ahci when fixing hbas with a sparse pi register.
(it's possible to have a non-contiguous set of available ports.
this is often the case on last-generation laptops.)

the symptom is that drives on the highest-numbered port
never see interrupts.  the simplist change is to replace
/n/sources/plan9/sys/src/9/pc/sdiahci.c:1925
                c->mport = c->hba->cap & ((1<<5)-1);
with
                c->mport = (c->hba->cap & 0x1f) + 1;
however it's not entirely clear from the ahci 0.99—1.3 standards
that with sparse ports, that the highest bit set in the pi
register is < (c->hba->cap & 0x1f) + 1, though that's implied.

dodging this problem results in a more robust and efficient interrupt
routine (the only place where mport is used), so i think a
better but slightly bigger change is to get rid of c->mport
entirely and change (>)/add (+) these two lines:

static void
iainterrupt(Ureg*, void *a)
{
        int i;
        ulong cause, m;
        Ctlr *c;
        Drive *d;

        c = a;
        ilock(c);
        cause = c->hba->isr;
>       for(i = 0; cause; i++){
                m = 1 << i;
                if((cause & m) == 0)
                        continue;
+               cause &= ~m;

this was the change i made in the contrib packages
quanstro/sd and quanstro/9load-e820.

- erik

Reply via email to