Source-Changes-HG archive

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

[src/trunk]: src/sys/arch mips: Carefully use device_set_private for cpuN.



details:   https://anonhg.NetBSD.org/src/rev/f36bc1fd590f
branches:  trunk
changeset: 362586:f36bc1fd590f
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Mar 03 06:27:40 2022 +0000

description:
mips: Carefully use device_set_private for cpuN.

But don't do it in cpu_attach_common because the callers aren't set
up right -- instead leave a comment about what's wrong, to be dealt
with later.

diffstat:

 sys/arch/evbmips/evbmips/cpu.c        |  6 +++---
 sys/arch/evbmips/ingenic/cpu.c        |  6 +++---
 sys/arch/mips/cavium/octeon_cpunode.c |  6 +++---
 sys/arch/mips/mips/cpu_subr.c         |  9 +++++++--
 4 files changed, 16 insertions(+), 11 deletions(-)

diffs (111 lines):

diff -r 21378681db50 -r f36bc1fd590f sys/arch/evbmips/evbmips/cpu.c
--- a/sys/arch/evbmips/evbmips/cpu.c    Thu Mar 03 06:27:20 2022 +0000
+++ b/sys/arch/evbmips/evbmips/cpu.c    Thu Mar 03 06:27:40 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.5 2015/06/26 21:57:25 matt Exp $     */
+/*     $NetBSD: cpu.c,v 1.6 2022/03/03 06:27:40 riastradh Exp $        */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.5 2015/06/26 21:57:25 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.6 2022/03/03 06:27:40 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -64,7 +64,7 @@
        struct cpu_info * const ci = curcpu();
 
        ci->ci_dev = self;
-       self->dv_private = ci;
+       device_set_private(self, ci);
 
        aprint_normal(": %lu.%02luMHz (hz cycles = %lu, delay divisor = %lu)\n",
            ci->ci_cpu_freq / 1000000,
diff -r 21378681db50 -r f36bc1fd590f sys/arch/evbmips/ingenic/cpu.c
--- a/sys/arch/evbmips/ingenic/cpu.c    Thu Mar 03 06:27:20 2022 +0000
+++ b/sys/arch/evbmips/ingenic/cpu.c    Thu Mar 03 06:27:40 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.4 2017/05/21 06:49:12 skrll Exp $    */
+/*     $NetBSD: cpu.c,v 1.5 2022/03/03 06:27:40 riastradh Exp $        */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.4 2017/05/21 06:49:12 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.5 2022/03/03 06:27:40 riastradh Exp $");
 
 #include "opt_ingenic.h"
 #include "opt_multiprocessor.h"
@@ -113,7 +113,7 @@
 
        }
        ci->ci_dev = self;
-       self->dv_private = ci;
+       device_set_private(self, ci);
 
        aprint_normal(": %lu.%02luMHz (hz cycles = %lu, delay divisor = %lu)\n",
            ci->ci_cpu_freq / 1000000,
diff -r 21378681db50 -r f36bc1fd590f sys/arch/mips/cavium/octeon_cpunode.c
--- a/sys/arch/mips/cavium/octeon_cpunode.c     Thu Mar 03 06:27:20 2022 +0000
+++ b/sys/arch/mips/cavium/octeon_cpunode.c     Thu Mar 03 06:27:40 2022 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: octeon_cpunode.c,v 1.21 2021/08/07 16:18:59 thorpej Exp $   */
+/*      $NetBSD: octeon_cpunode.c,v 1.22 2022/03/03 06:27:41 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 #define __INTR_PRIVATE
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: octeon_cpunode.c,v 1.21 2021/08/07 16:18:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_cpunode.c,v 1.22 2022/03/03 06:27:41 riastradh Exp $");
 
 #include "locators.h"
 #include "cpunode.h"
@@ -252,7 +252,7 @@
        struct cpu_softc * const cpu __diagused = ci->ci_softc;
 
        ci->ci_dev = self;
-       self->dv_private = ci;
+       device_set_private(self, ci);
 
        KASSERTMSG(cpu != NULL, "ci %p index %d", ci, cpu_index(ci));
 
diff -r 21378681db50 -r f36bc1fd590f sys/arch/mips/mips/cpu_subr.c
--- a/sys/arch/mips/mips/cpu_subr.c     Thu Mar 03 06:27:20 2022 +0000
+++ b/sys/arch/mips/mips/cpu_subr.c     Thu Mar 03 06:27:40 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu_subr.c,v 1.59 2021/11/16 06:11:52 simonb Exp $     */
+/*     $NetBSD: cpu_subr.c,v 1.60 2022/03/03 06:27:41 riastradh Exp $  */
 
 /*-
  * Copyright (c) 2010, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.59 2021/11/16 06:11:52 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.60 2022/03/03 06:27:41 riastradh Exp $");
 
 #include "opt_cputype.h"
 #include "opt_ddb.h"
@@ -236,6 +236,11 @@
 
        /*
         * Cross link cpu_info and its device together
+        *
+        * XXX autoconf abuse: Can't use device_set_private here
+        * because some callers already do so -- and some callers
+        * (sbmips cpu_attach) already have a softc allocated by
+        * autoconf.
         */
        ci->ci_dev = self;
        self->dv_private = ci;



Home | Main Index | Thread Index | Old Index