9front - general discussion about 9front
 help / color / mirror / Atom feed
From: ori@eigenstate.org
To: 9front@9front.org
Subject: ahci led: reset spins.
Date: Sat, 16 Nov 2019 20:50:07 -0800	[thread overview]
Message-ID: <E196E7B9A63F3382559A4EBA852969BC@eigenstate.org> (raw)

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++;
 		}



                 reply	other threads:[~2019-11-17  4:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E196E7B9A63F3382559A4EBA852969BC@eigenstate.org \
    --to=ori@eigenstate.org \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).