shithub: riscv

Download patch

ref: 921d96ea15e2f544ac24ee2c715161ac406f828c
parent: 390c71f0c79b2b8b94997cd9ae03037272075f8b
author: cinap_lenrek <[email protected]>
date: Wed May 24 14:03:41 EDT 2023

sdnvme: use delay() instead of tsleep() in nvmedisable()

SDifc.disable() can be called from:

reboot() -> chandevshutdown() -> sdshutdown()

... which has interrupts disabled (and we should
not re-enable them).

Also dont waste 100ms in sleeping as a usual drive can
complete its controller disable and shutdown notification
in just a few ms (< 4ms).

--- a/sys/src/9/port/sdnvme.c
+++ b/sys/src/9/port/sdnvme.c
@@ -521,18 +521,18 @@
 
 	/* notify normal power off */
 	ctlr->reg[CCfg] = (ctlr->reg[CCfg] & ~(3<<14)) | 1<<14;
-	for(i = 0; i < 30; i++){
+	for(i = 0; i < 3000; i++){
 		if((ctlr->reg[CSts] & 0xc) == 0x8)
 			break;
-		tsleep(&up->sleep, return0, nil, 100);
+		delay(1);
 	}
 
 	/* disable controller */
 	ctlr->reg[CCfg] = 0;
-	for(i = 0; i < 10; i++){
+	for(i = 0; i < 1000; i++){
 		if((ctlr->reg[CSts] & 1) == 0)
 			break;
-		tsleep(&up->sleep, return0, nil, 100);
+		delay(1);
 	}
 
 	snprint(name, sizeof(name), "%s (%s)", sd->name, sd->ifc->name);