From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 10699 invoked from network); 24 Jan 2021 15:07:41 -0000 Received: from 1ess.inri.net (216.126.196.35) by inbox.vuxu.org with ESMTPUTF8; 24 Jan 2021 15:07:41 -0000 Received: from duke.felloff.net ([216.126.196.34]) by 1ess; Sun Jan 24 10:01:18 -0500 2021 Message-ID: <5B3B970A411ADBCC5D32FFDFAB1E4D3E@felloff.net> Date: Sun, 24 Jan 2021 16:01:07 +0100 From: cinap_lenrek@felloff.net To: 9front@9front.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: mobile plugin high-performance-scale manager Subject: Re: [9front] 9front on Raspberry Pi 400 Reply-To: 9front@9front.org Precedence: bulk Ok, i also added a bunch of debug prints into the xhci driver (in addition to the GIC debug prints) and updated the pi9 kernels in these url locations: http://felloff.net/usr/cinap_lenrek/9pi4 (kernel for sdcard) http://felloff.net/usr/cinap_lenrek/s9pi4 (a.out for debug symbols) http://felloff.net/usr/cinap_lenrek/usbxhci.c (changed file) sha1 checksums: 0ddfe8a7c00164dc8a07c71219b3ab5eba48da6e 9pi4 2f7bc6b6f6ae514b977c6411f27d548eb183d5b1 s9pi4 and the diff: diff -r 5c327eddc496 sys/src/9/port/usbxhci.c --- a/sys/src/9/port/usbxhci.c Sat Jan 23 20:36:09 2021 -0800 +++ b/sys/src/9/port/usbxhci.c Sun Jan 24 15:53:30 2021 +0100 @@ -397,18 +397,32 @@ return nil; } +static int +pollwait(u32int *reg, u32int mask, u32int val, int timeout) +{ + while((*reg & mask) != val) { + if(timeout <= 0) + return -1; + timeout -= 10; + if(up != nil && islo()) + tsleep(&up->sleep, return0, nil, 10); + else + delay(10); + } + return 0; +} + static void handoff(Ctlr *ctlr) { u32int *r; - int i; if((r = xecp(ctlr, 1, nil)) == nil) return; if(getconf("*noxhcihandoff") == nil){ r[0] |= 1<<24; /* request ownership */ - for(i = 0; (r[0] & (1<<16)) != 0 && i<100; i++) - tsleep(&up->sleep, return0, nil, 10); + if(pollwait(&r[0], 1<<16, 0, 1000) < 0) + print("xhci %llux: handoff timeout\n", ctlr->base); } /* disable SMI interrupts */ r[1] &= 7<<1 | 255<<5 | 7<<17 | 7<<29; @@ -421,11 +435,9 @@ shutdown(Hci *hp) { Ctlr *ctlr = hp->aux; - int i; ctlr->opr[USBCMD] = 0; - for(i=0; (ctlr->opr[USBSTS] & HCH) == 0 && i < 10; i++) - delay(10); + pollwait(&ctlr->opr[USBSTS], HCH, HCH, 100); intrdisable(ctlr->pcidev->intl, hp->interrupt, hp, ctlr->pcidev->tbdf, hp->type); pcidisable(ctlr->pcidev); } @@ -477,13 +489,16 @@ ctlr->hccparams = ctlr->mmio[HCCPARAMS]; handoff(ctlr); - for(i=0; (ctlr->opr[USBSTS] & CNR) != 0 && i<100; i++) - tsleep(&up->sleep, return0, nil, 10); + if(pollwait(&ctlr->opr[USBSTS], CNR, 0, 1000) < 0) + print("xhci %llux: controller not ready before reset: %.8ux\n", + ctlr->base, ctlr->opr[USBSTS]); ctlr->opr[USBCMD] = HCRST; delay(1); - for(i=0; (ctlr->opr[USBSTS] & (CNR|HCH)) != HCH && i<100; i++) - tsleep(&up->sleep, return0, nil, 10); + + if(pollwait(&ctlr->opr[USBSTS], CNR|HCH, HCH, 1000) < 0) + print("xhci %llux: controller not halted after reset: %.8ux\n", + ctlr->base, ctlr->opr[USBSTS]); pcisetbme(ctlr->pcidev); intrenable(ctlr->pcidev->intl, hp->interrupt, hp, ctlr->pcidev->tbdf, hp->type); @@ -593,8 +608,10 @@ coherence(); ctlr->opr[USBCMD] = RUNSTOP|INTE|HSEE|EWE; - for(i=0; (ctlr->opr[USBSTS] & (CNR|HCH)) != 0 && i<100; i++) - tsleep(&up->sleep, return0, nil, 10); + + if(pollwait(&ctlr->opr[USBSTS], CNR|HCH, 0, 1000) < 0) + print("xhci %llux: controller not ready after run: %.8ux\n", + ctlr->base, ctlr->opr[USBSTS]); kproc("xhcirecover", recover, hp); } -- cinap