shithub: riscv

Download patch

ref: 0fd4ad8016cecf7210e64e9878d2cd6861a72fbf
parent: 4ac5cfed08bb156dc13fae3ce43c3edab06cf952
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Jul 9 11:35:40 EDT 2023

omap: Fix missing preempted() call after non-clock interrupt (Thanks Anthony Martin)

Same as the previous patch...

Untested tho :(

--- a/sys/src/9/omap/trap.c
+++ b/sys/src/9/omap/trap.c
@@ -446,7 +446,7 @@
 void
 trap(Ureg *ureg)
 {
-	int clockintr, user, x, rv, rem;
+	int user, x, rv, rem;
 	ulong inst, fsr;
 	uintptr va;
 	char buf[ERRMAX];
@@ -475,7 +475,6 @@
 	else
 		ureg->pc -= 4;
 
-	clockintr = 0;		/* if set, may call sched() before return */
 	switch(ureg->type){
 	default:
 		panic("unknown trap; type %#lux, psr mode %#lux", ureg->type,
@@ -483,7 +482,12 @@
 		break;
 	case PsrMirq:
 		ldrexvalid = 0;
-		clockintr = irq(ureg);
+		if(!irq(ureg))
+			preempted();
+		else if(up != nil && up->delaysched){
+			ldrexvalid = 0;
+			sched();
+		}
 		m->intr++;
 		break;
 	case PsrMabt:			/* prefetch fault */
@@ -614,14 +618,6 @@
 		break;
 	}
 	splhi();
-
-	/* delaysched set because we held a lock or because our quantum ended */
-	if(up && up->delaysched && clockintr){
-		ldrexvalid = 0;
-		sched();		/* can cause more traps */
-		splhi();
-	}
-
 	if(user){
 		if(up->procctl || up->nnote)
 			notify(ureg);