From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eigenstate.org ([206.124.132.107]) by ewsd; Sat Nov 16 23:50:09 EST 2019 Received: from eigenstate.org (localhost [127.0.0.1]) by eigenstate.org (OpenSMTPD) with ESMTP id 2c7d4e4b for <9front@9front.org>; Sat, 16 Nov 2019 20:50:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=eigenstate.org; h= message-id:to:subject:date:from:mime-version:content-type :content-transfer-encoding; s=mail; bh=amA7oo1HayqZMyfFPSXpU18Ot x4=; b=MHnl1mguYpoYS5SuHRCm9MnPy4hm7CY8kj1iEcXhNq+X60wwMCsk22Hie v8ZmaLGlRcwx7zDiMHclssezYH2v2rfn9LmMs7Xg/3Aij4kqw7/EozhO/lDVUnwI z7tX/ufvDfU3spq77EUJRadu6PKy+rU/LB5cWqAD2dC+KMyvhQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=eigenstate.org; h=message-id :to:subject:date:from:mime-version:content-type :content-transfer-encoding; q=dns; s=mail; b=bKmeeC7pT9cf+WPEqlz n3Farc8G9hZKKnXmqEfRuoqevO8Ww15m+8P9jwqYIEo8mw9T9ui/qro73pzlnjo7 Orp4/zkQhLlJEB6kJdf+KJbpwNLsqaa2NCq0FqxlCXL51DQIphwtOvEAoSdUyMWV IcEOUcjUrok7A18r6B3i1/cY= Received: from abbatoir.hsd1.ca.comcast.net (c-76-21-119-139.hsd1.ca.comcast.net [76.21.119.139]) by eigenstate.org (OpenSMTPD) with ESMTPSA id 91eaf8c6 (TLSv1.2:ECDHE-RSA-AES256-SHA:256:NO) for <9front@9front.org>; Sat, 16 Nov 2019 20:50:08 -0800 (PST) Message-ID: To: 9front@9front.org Subject: ahci led: reset spins. Date: Sat, 16 Nov 2019 20:50:07 -0800 From: ori@eigenstate.org MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: firewall blockchain software On one of my machines, there was aa fairly constant load from the ialed kproc, because it was stuck in a loop resetting the ahci controller. The controller never came back. I'm guessing the controller was confused because there are no drives attached. I added a timeout as a workaround. The AHCI spec says: If the HBA has not cleared GHC.HR to ‘0’ within 1 second of software setting GHC.HR to ‘1’, the HBA is in a hung or locked state. And I've tested on a couple of machines, both with and without drives attached, and it seems to work -- but given that people seem to think accessing disks is important, more testing should probably be done before committing: diff -r c4896008f196 sys/src/9/pc/sdiahci.c --- a/sys/src/9/pc/sdiahci.c Fri Nov 15 13:26:25 2019 -0800 +++ b/sys/src/9/pc/sdiahci.c Sat Nov 16 20:23:26 2019 -0800 @@ -1215,13 +1215,20 @@ ahciencreset(Ctlr *c) { Ahba *h; + int ndelay; if(c->enctype == Eesb) return 0; h = c->hba; h->emctl |= Emrst; - while(h->emctl & Emrst) + ndelay = 0; + while(h->emctl & Emrst){ + if(ndelay++ > 1000){ + print("hung ctlr: %s\n", Tname(c)); + return -1; + } delay(1); + } return 0; } @@ -1403,7 +1410,8 @@ memset(map, 0, sizeof map); for(i = 0; i < niactlr; i++) if(iactlr[i].enctype != 0){ - ahciencreset(iactlr + i); + if(ahciencreset(iactlr + i) == -1) + continue; map[i] = 1; j++; }