Source-Changes-HG archive

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

[src/netbsd-10]: src/sys/arch/next68k Pull up following revision(s) (requeste...



details:   https://anonhg.NetBSD.org/src/rev/62f70e285bc1
branches:  netbsd-10
changeset: 373313:62f70e285bc1
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Feb 01 18:55:11 2023 +0000

description:
Pull up following revision(s) (requested by tsutsui in ticket #63):

        sys/arch/next68k/next68k/machdep.c: revision 1.117
        sys/arch/next68k/dev/esp.c: revision 1.65
        sys/arch/next68k/include/cpu.h: revision 1.51
        sys/arch/next68k/include/bus_space.h: revision 1.20
        sys/arch/next68k/next68k/clock.c: revision 1.13

next68k: Fix delay_divisor value for proper delay(9) on 68040.

next68k: Specify proper constraints for bus_space_read region and multi ops.

These functions write the read data into memory at a specified pointer,
but without the "memory" constraint gcc could optimize out these ops
if the memory is allocated on local stack.

With this fix nextkbd(4) works again.
Should be pulled up to netbsd-10 and netbsd-9.

next68k: Fix silent stall of next68k esp(4) SCSI.

next68k esp(4) driver requires nextdma(4) interrupts at ipl 6
during ncr53c9x_intr() for esp(4) at ipl 3.  It worked on netbsd-5
and prior, but on netbsd-5 splbio() was changed from ipl 3 to 6
for SMP support and on netbsd-6 ncr53c9x driver was changed to
use mutex(9) instead of simple_lock(9), so nextdma interrupts
were no longer raised during ncr53c9x interrupt handler.

For now, just call mutex_exit(9) and mutex_enter(9) during
waiting nextdma(4) interrupts in MD esp_dma_intr() handler.

This could be wrong and the interrupt handler for nextdma should
be reorganized, but it just works.

Should be pulled up to netbsd-10 and netbsd-9.

diffstat:

 sys/arch/next68k/dev/esp.c           |   7 ++++---
 sys/arch/next68k/include/bus_space.h |  14 +++++++-------
 sys/arch/next68k/include/cpu.h       |   5 +----
 sys/arch/next68k/next68k/clock.c     |  36 ++----------------------------------
 sys/arch/next68k/next68k/machdep.c   |  25 ++++++++++++++++++-------
 5 files changed, 32 insertions(+), 55 deletions(-)

diffs (251 lines):

diff -r 0ad843cc00fe -r 62f70e285bc1 sys/arch/next68k/dev/esp.c
--- a/sys/arch/next68k/dev/esp.c        Mon Jan 30 11:56:02 2023 +0000
+++ b/sys/arch/next68k/dev/esp.c        Wed Feb 01 18:55:11 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: esp.c,v 1.64 2017/03/31 08:38:13 msaitoh Exp $ */
+/*     $NetBSD: esp.c,v 1.64.44.1 2023/02/01 18:55:11 martin Exp $     */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: esp.c,v 1.64 2017/03/31 08:38:13 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: esp.c,v 1.64.44.1 2023/02/01 18:55:11 martin Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -509,6 +509,7 @@
                        }
 #endif
 
+                       mutex_exit(&sc->sc_lock);       /* for nextdma intr */
                        while (!nextdma_finished(nsc)) {
                        /* esp_dma_isactive(sc)) { */
                                NDTRACEIF (ndtrace_addc('w'));
@@ -602,7 +603,7 @@
 
                        }
                out:
-                       ;
+                       mutex_enter(&sc->sc_lock);      /* for nextdma intr */
 
 #ifdef ESP_DEBUG
 /*                     esp_dma_nest--; */
diff -r 0ad843cc00fe -r 62f70e285bc1 sys/arch/next68k/include/bus_space.h
--- a/sys/arch/next68k/include/bus_space.h      Mon Jan 30 11:56:02 2023 +0000
+++ b/sys/arch/next68k/include/bus_space.h      Wed Feb 01 18:55:11 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_space.h,v 1.19 2021/01/23 19:38:08 christos Exp $  */
+/*     $NetBSD: bus_space.h,v 1.19.18.1 2023/02/01 18:55:11 martin Exp $       */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -167,7 +167,7 @@
                jne     1b"                                     :       \
                                                                :       \
                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
-                   "a0","a1","d0");                                    \
+                   "a0","a1","d0","memory");                           \
 } while (0);
 
 #define        bus_space_read_multi_2(t, h, o, a, c) do {                      \
@@ -181,7 +181,7 @@
                jne     1b"                                     :       \
                                                                :       \
                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
-                   "a0","a1","d0");                                    \
+                   "a0","a1","d0","memory");                           \
 } while (0);
 
 #define        bus_space_read_multi_4(t, h, o, a, c) do {                      \
@@ -195,7 +195,7 @@
                jne     1b"                                     :       \
                                                                :       \
                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
-                   "a0","a1","d0");                                    \
+                   "a0","a1","d0","memory");                           \
 } while (0);
 
 /*
@@ -219,7 +219,7 @@
                jne     1b"                                     :       \
                                                                :       \
                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
-                   "a0","a1","d0");                                    \
+                   "a0","a1","d0","memory");                           \
 } while (0);
 
 #define        bus_space_read_region_2(t, h, o, a, c) do {                     \
@@ -233,7 +233,7 @@
                jne     1b"                                     :       \
                                                                :       \
                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
-                   "a0","a1","d0");                                    \
+                   "a0","a1","d0","memory");                                   \
 } while (0);
 
 #define        bus_space_read_region_4(t, h, o, a, c) do {                     \
@@ -247,7 +247,7 @@
                jne     1b"                                     :       \
                                                                :       \
                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
-                   "a0","a1","d0");                                    \
+                   "a0","a1","d0","memory");                                   \
 } while (0);
 
 /*
diff -r 0ad843cc00fe -r 62f70e285bc1 sys/arch/next68k/include/cpu.h
--- a/sys/arch/next68k/include/cpu.h    Mon Jan 30 11:56:02 2023 +0000
+++ b/sys/arch/next68k/include/cpu.h    Wed Feb 01 18:55:11 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.50 2019/11/23 19:40:36 ad Exp $      */
+/*     $NetBSD: cpu.h,v 1.50.26.1 2023/02/01 18:55:11 martin Exp $     */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -120,9 +120,6 @@
 void   doboot(void) __attribute__((__noreturn__));
 int    nmihand(void *);
 
-/* clock.c functions */
-void   next68k_calibrate_delay(void);
-
 #endif /* _KERNEL */
 
 #define NEXT_RAMBASE  (0x4000000) /* really depends on slot, but... */
diff -r 0ad843cc00fe -r 62f70e285bc1 sys/arch/next68k/next68k/clock.c
--- a/sys/arch/next68k/next68k/clock.c  Mon Jan 30 11:56:02 2023 +0000
+++ b/sys/arch/next68k/next68k/clock.c  Wed Feb 01 18:55:11 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clock.c,v 1.12 2010/04/24 19:58:13 dbj Exp $   */
+/*     $NetBSD: clock.c,v 1.12.90.1 2023/02/01 18:55:11 martin Exp $   */
 /*
  * Copyright (c) 1998 Darrin B. Jewell
  * All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.12 2010/04/24 19:58:13 dbj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.12.90.1 2023/02/01 18:55:11 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -48,38 +48,6 @@
  * -- jewell%mit.edu@localhost
  */
 
-/*
- * Note that the value of delay_divisor is roughly
- * 2048 / cpuspeed (where cpuspeed is in MHz) on 68020
- * and 68030 systems.  See clock.c for the delay
- * calibration algorithm.
- */
-int    cpuspeed;                 /* relative cpu speed; XXX skewed on 68040 */
-int    delay_divisor = 2048/25;  /* delay constant */
-
-/*
- * Calibrate the delay constant.
- */
-void
-next68k_calibrate_delay(void)
-{
-       extern int delay_divisor;
-
-       /* @@@ write this once we know how to read
-        * a real time clock
-        */
-
-       /*
-        * Sanity check the delay_divisor value.  If we totally lost,
-        * assume a 25MHz CPU;
-        */
-       if (delay_divisor == 0)
-               delay_divisor = 2048 / 25;
-
-       /* Calculate CPU speed. */
-       cpuspeed = 2048 / delay_divisor;
-}
-
 int clock_intr(void *);
 
 int
diff -r 0ad843cc00fe -r 62f70e285bc1 sys/arch/next68k/next68k/machdep.c
--- a/sys/arch/next68k/next68k/machdep.c        Mon Jan 30 11:56:02 2023 +0000
+++ b/sys/arch/next68k/next68k/machdep.c        Wed Feb 01 18:55:11 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.116 2021/10/09 20:00:42 tsutsui Exp $    */
+/*     $NetBSD: machdep.c,v 1.116.4.1 2023/02/01 18:55:11 martin Exp $ */
 
 /*
  * Copyright (c) 1998 Darrin B. Jewell
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.116 2021/10/09 20:00:42 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.116.4.1 2023/02/01 18:55:11 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -168,6 +168,17 @@
 phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
 int    mem_cluster_cnt;
 
+/*
+ * On the 68020/68030, the value of delay_divisor is roughly
+ * 2048 / cpuspeed (where cpuspeed is in MHz).
+ *
+ * On the 68040/68060(?), the value of delay_divisor is roughly
+ * 759 / cpuspeed (where cpuspeed is in MHz).
+ * XXX -- is the above formula correct?
+ */
+int    cpuspeed = 33;            /* relative cpu speed; XXX skewed on 68040 */
+int    delay_divisor = 759 / 33;  /* delay constant; assume fastest 33 MHz */
+
 /****************************************************************/
 
 /*
@@ -208,9 +219,6 @@
                }
        }
 
-       /* Calibrate the delay loop. */
-       next68k_calibrate_delay();
-
        /*
         * Initialize error message buffer (at end of core).
         */
@@ -256,8 +264,6 @@
                }
 
                init = 1;
-       } else {
-               next68k_calibrate_delay();
        }
 }
 
@@ -316,6 +322,7 @@
 identifycpu(void)
 {
        const char *mc, *mmu_str, *fpu_str, *cache_str;
+       extern int turbo;
 
        /*
         * ...and the CPU type.
@@ -323,9 +330,13 @@
        switch (cputype) {
        case CPU_68040:
                mc = "40";
+               cpuspeed = turbo ? 33 : 25;
+               delay_divisor = 759 / cpuspeed;
                break;
        case CPU_68030:
                mc = "30";
+               cpuspeed = 25;
+               delay_divisor = 2048 / cpuspeed;
                break;
        case CPU_68020:
                mc = "20";



Home | Main Index | Thread Index | Old Index