Module Name:    src
Committed By:   jmcneill
Date:           Mon Feb 15 13:03:52 UTC 2021

Modified Files:
        src/sys/arch/arm/pic: pic.c

Log Message:
pic: reduce the number of daif accesses in pic_do_pending_ints

The caller has already provided daif state. No need to keep updating
daif via pic_set_priority if it's already in the state we need (interrupts
disabled).


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/arm/pic/pic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.62 src/sys/arch/arm/pic/pic.c:1.63
--- src/sys/arch/arm/pic/pic.c:1.62	Sun Feb  7 21:18:37 2021
+++ src/sys/arch/arm/pic/pic.c	Mon Feb 15 13:03:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.62 2021/02/07 21:18:37 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.63 2021/02/15 13:03:52 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.62 2021/02/07 21:18:37 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.63 2021/02/15 13:03:52 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -129,6 +129,21 @@ pic_set_priority(struct cpu_info *ci, in
 	if ((psw & I32_bit) == 0)
 		cpsie(I32_bit);
 }
+
+static void
+pic_set_priority_psw(struct cpu_info *ci, register_t psw, int newipl)
+{
+	if ((psw & I32_bit) == 0) {
+		DISABLE_INTERRUPT();
+	}
+	if (pic_list[0] != NULL) {
+		(pic_list[0]->pic_ops->pic_set_priority)(pic_list[0], newipl);
+	}
+	ci->ci_cpl = newipl;
+	if ((psw & I32_bit) == 0) {
+		ENABLE_INTERRUPT();
+	}
+}
 #endif
 
 #ifdef MULTIPROCESSOR
@@ -573,7 +588,7 @@ pic_do_pending_ints(register_t psw, int 
 			if (ipl <= newipl)
 				break;
 
-			pic_set_priority(ci, ipl);
+			pic_set_priority_psw(ci, psw, ipl);
 			pic_list_deliver_irqs(pend, psw, ipl, frame);
 			pic_list_unblock_irqs(pend);
 		}
@@ -582,12 +597,12 @@ pic_do_pending_ints(register_t psw, int 
 #endif /* __HAVE_PIC_PENDING_INTRS */
 #ifdef __HAVE_PREEMPTION
 	if (newipl == IPL_NONE && (ci->ci_astpending & __BIT(1))) {
-		pic_set_priority(ci, IPL_SCHED);
+		pic_set_priority_psw(ci, psw, IPL_SCHED);
 		kpreempt(0);
 	}
 #endif
 	if (ci->ci_cpl != newipl)
-		pic_set_priority(ci, newipl);
+		pic_set_priority_psw(ci, psw, newipl);
 }
 
 static void

Reply via email to