Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sparc64 Improve cpu_idle() by allowing a platform s...



details:   https://anonhg.NetBSD.org/src/rev/711a043b1fbd
branches:  trunk
changeset: 982176:711a043b1fbd
user:      palle <palle%NetBSD.org@localhost>
date:      Sat Apr 03 17:01:24 2021 +0000

description:
Improve cpu_idle() by allowing a platform specific implementaion (same logic as the sparc implementation) - currently only used by sun4v

diffstat:

 sys/arch/sparc64/include/cpu.h       |   9 +++++++--
 sys/arch/sparc64/sparc64/cpu.c       |  19 ++++++++++++++++---
 sys/arch/sparc64/sparc64/genassym.cf |   3 ++-
 sys/arch/sparc64/sparc64/locore.s    |  14 +++++++++++---
 4 files changed, 36 insertions(+), 9 deletions(-)

diffs (125 lines):

diff -r 42ee6c2aa429 -r 711a043b1fbd sys/arch/sparc64/include/cpu.h
--- a/sys/arch/sparc64/include/cpu.h    Sat Apr 03 15:29:02 2021 +0000
+++ b/sys/arch/sparc64/include/cpu.h    Sat Apr 03 17:01:24 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.130 2020/03/10 03:49:56 christos Exp $ */
+/*     $NetBSD: cpu.h,v 1.131 2021/04/03 17:01:24 palle Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -212,12 +212,14 @@
        paddr_t                 ci_devmq;  /* device mondo queue address */
        paddr_t                 ci_cpuset; /* mondo recipient address */ 
        paddr_t                 ci_mondo;  /* mondo message address */
-       
+
        /* probe fault in PCI config space reads */
        bool                    ci_pci_probe;
        bool                    ci_pci_fault;
 
        volatile void           *ci_ddb_regs;   /* DDB regs */
+
+       void (*ci_idlespin)(void);
 };
 
 #endif /* _KERNEL || _KMEMUSER */
@@ -438,6 +440,9 @@
 void   next_tick(long);
 void   next_stick(long);
 void   next_stick_init(void);
+#ifdef SUN4V
+void    cpu_idle_sun4v(void);
+#endif
 /* trap.c */
 void   cpu_vmspace_exec(struct lwp *, vaddr_t, vaddr_t);
 int    rwindow_save(struct lwp *);
diff -r 42ee6c2aa429 -r 711a043b1fbd sys/arch/sparc64/sparc64/cpu.c
--- a/sys/arch/sparc64/sparc64/cpu.c    Sat Apr 03 15:29:02 2021 +0000
+++ b/sys/arch/sparc64/sparc64/cpu.c    Sat Apr 03 17:01:24 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.138 2020/08/07 14:20:08 fcambus Exp $ */
+/*     $NetBSD: cpu.c,v 1.139 2021/04/03 17:01:24 palle Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.138 2020/08/07 14:20:08 fcambus Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.139 2021/04/03 17:01:24 palle Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -695,9 +695,22 @@
                ci->ci_cpuset = pa;
                pa += 64;
        }
-       
+
+       /*
+        * cpu_idle setup (currently only necessary for sun4v)
+        */
+       if (CPU_ISSUN4V) {
+         ci->ci_idlespin = cpu_idle_sun4v;
+       }
 }
 
+#ifdef SUN4V
+void cpu_idle_sun4v(void)
+{
+  hv_cpu_yield();
+}
+#endif
+
 int
 cpu_myid(void)
 {
diff -r 42ee6c2aa429 -r 711a043b1fbd sys/arch/sparc64/sparc64/genassym.cf
--- a/sys/arch/sparc64/sparc64/genassym.cf      Sat Apr 03 15:29:02 2021 +0000
+++ b/sys/arch/sparc64/sparc64/genassym.cf      Sat Apr 03 17:01:24 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: genassym.cf,v 1.84 2020/02/17 09:09:49 skrll Exp $
+#      $NetBSD: genassym.cf,v 1.85 2021/04/03 17:01:24 palle Exp $
 
 #
 # Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -183,6 +183,7 @@
 ifdef MULTIPROCESSOR
 define CI_IPIEVC       offsetof(struct cpu_info, ci_ipi_evcnt[0].ev_count)
 endif
+define CI_IDLESPIN offsetof(struct cpu_info, ci_idlespin)
 
 # CPU boot arguments structure
 define CBA_NODE        offsetof(struct cpu_bootargs, cb_node)
diff -r 42ee6c2aa429 -r 711a043b1fbd sys/arch/sparc64/sparc64/locore.s
--- a/sys/arch/sparc64/sparc64/locore.s Sat Apr 03 15:29:02 2021 +0000
+++ b/sys/arch/sparc64/sparc64/locore.s Sat Apr 03 17:01:24 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.s,v 1.426 2021/03/30 20:03:14 palle Exp $       */
+/*     $NetBSD: locore.s,v 1.427 2021/04/03 17:01:24 palle Exp $       */
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -6619,11 +6619,19 @@
         mov %fp, %o0
 
 /*
- * nothing MD to do in the idle loop
+ * Call optional cpu_idle handler if provided
  */
 ENTRY(cpu_idle)
+       set     CPUINFO_VA, %o0
+       LDPTR   [%o0 + CI_IDLESPIN], %o1
+       tst     %o1
+       bz      1f
+        nop
+       jmp     %o1
+        nop
+1:
        retl
-        nop
+       nop
 
 /*
  * cpu_switchto() switches to an lwp to run and runs it, saving the



Home | Main Index | Thread Index | Old Index