Module Name:    src
Committed By:   riastradh
Date:           Sat Mar 26 19:38:00 UTC 2022

Modified Files:
        src/sys/arch/mips/cavium: octeon_intr.c

Log Message:
mips/cavium: Simplify membars around interrupt establishment.

Previously I used xc_barrier to ensure the initialization of the
struct octeon_intrhand was witnessed on all CPUs before publishing
it, in order to avoid needing any barrier on the usage side to be
issued by the interrupt handler.

But there's no need to avoid atomic_load_consume at time of
interrupt: on MIPS it's the same as atomic_load_relaxed anyway, so
there's no additional memory barrier cost here.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/mips/cavium/octeon_intr.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/mips/cavium/octeon_intr.c
diff -u src/sys/arch/mips/cavium/octeon_intr.c:1.25 src/sys/arch/mips/cavium/octeon_intr.c:1.26
--- src/sys/arch/mips/cavium/octeon_intr.c:1.25	Wed Mar 23 23:24:21 2022
+++ src/sys/arch/mips/cavium/octeon_intr.c	Sat Mar 26 19:38:00 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: octeon_intr.c,v 1.25 2022/03/23 23:24:21 riastradh Exp $	*/
+/*	$NetBSD: octeon_intr.c,v 1.26 2022/03/26 19:38:00 riastradh Exp $	*/
 /*
  * Copyright 2001, 2002 Wasabi Systems, Inc.
  * All rights reserved.
@@ -44,7 +44,7 @@
 #define __INTR_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: octeon_intr.c,v 1.25 2022/03/23 23:24:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_intr.c,v 1.26 2022/03/26 19:38:00 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -354,14 +354,6 @@ octeon_intr_establish(int irq, int ipl, 
 	ih->ih_irq = irq;
 	ih->ih_ipl = ipl;
 
-	/*
-	 * Make sure the initialization is visible on all CPUs before
-	 * we expose it in octciu_intrs.  This way we don't need to
-	 * issue any membar for a load-acquire when handling the
-	 * interrupt.
-	 */
-	xc_barrier(0);
-
 	mutex_enter(&octeon_intr_lock);
 
 	/*
@@ -370,7 +362,7 @@ octeon_intr_establish(int irq, int ipl, 
 	KASSERTMSG(octciu_intrs[irq] == NULL, "irq %d in use! (%p)",
 	    irq, octciu_intrs[irq]);
 
-	atomic_store_relaxed(&octciu_intrs[irq], ih);
+	atomic_store_release(&octciu_intrs[irq], ih);
 
 	/*
 	 * Now enable it.
@@ -518,7 +510,7 @@ octeon_iointr(int ipl, vaddr_t pc, uint3
 			hwpend[bank] &= ~__BIT(bit);
 
 			struct octeon_intrhand * const ih =
-			    atomic_load_relaxed(&octciu_intrs[irq]);
+			    atomic_load_consume(&octciu_intrs[irq]);
 			cpu->cpu_intr_evs[irq].ev_count++;
 			if (__predict_true(ih != NULL)) {
 #ifdef MULTIPROCESSOR

Reply via email to