Sat Jan 3 06:36:59 2009 UTC ()
Raise IPL to splsoftnet() before calling callback funcions registered
via (atari specific) add_sicallback(), as a workaround hack.

Many drivers which use the MD sicallback depend on BASEPRI() macro
defined in <machine/cpu.h> to check nested interrupts,
but functions invoked from MI softint(9) won't run at IPL_SOFT
any longer and the BASEPRI() macro doesn't return expected value
as the past.

Fixes lost interrupt problem on Falcon wdc(4) reported by
Tuomo Makinen on port-atari, and also confirmed by him.

Should be pulled up to netbsd-5.


(tsutsui)
diff -r1.154 -r1.155 src/sys/arch/atari/atari/machdep.c

cvs diff -r1.154 -r1.155 src/sys/arch/atari/atari/machdep.c (expand / switch to unified diff)

--- src/sys/arch/atari/atari/machdep.c 2008/11/30 18:21:32 1.154
+++ src/sys/arch/atari/atari/machdep.c 2009/01/03 06:36:58 1.155
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: machdep.c,v 1.154 2008/11/30 18:21:32 martin Exp $ */ 1/* $NetBSD: machdep.c,v 1.155 2009/01/03 06:36:58 tsutsui Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. 4 * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer 8 * the Systems Programming Group of the University of Utah Computer
9 * Science Department. 9 * Science Department.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -67,27 +67,27 @@ @@ -67,27 +67,27 @@
67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 * SUCH DAMAGE. 72 * SUCH DAMAGE.
73 * 73 *
74 * from: Utah $Hdr: machdep.c 1.63 91/04/24$ 74 * from: Utah $Hdr: machdep.c 1.63 91/04/24$
75 * 75 *
76 * @(#)machdep.c 7.16 (Berkeley) 6/3/91 76 * @(#)machdep.c 7.16 (Berkeley) 6/3/91
77 */ 77 */
78 78
79#include <sys/cdefs.h> 79#include <sys/cdefs.h>
80__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.154 2008/11/30 18:21:32 martin Exp $"); 80__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.155 2009/01/03 06:36:58 tsutsui Exp $");
81 81
82#include "opt_ddb.h" 82#include "opt_ddb.h"
83#include "opt_compat_netbsd.h" 83#include "opt_compat_netbsd.h"
84#include "opt_mbtype.h" 84#include "opt_mbtype.h"
85#include "opt_panicbutton.h" 85#include "opt_panicbutton.h"
86 86
87#include <sys/param.h> 87#include <sys/param.h>
88#include <sys/systm.h> 88#include <sys/systm.h>
89#include <sys/signalvar.h> 89#include <sys/signalvar.h>
90#include <sys/kernel.h> 90#include <sys/kernel.h>
91#include <sys/proc.h> 91#include <sys/proc.h>
92#include <sys/buf.h> 92#include <sys/buf.h>
93#include <sys/reboot.h> 93#include <sys/reboot.h>
@@ -800,27 +800,40 @@ call_sicallbacks(void) @@ -800,27 +800,40 @@ call_sicallbacks(void)
800 si_callbacks = si->next; 800 si_callbacks = si->next;
801 splx(s); 801 splx(s);
802 802
803 if (si) { 803 if (si) {
804 function = si->function; 804 function = si->function;
805 rock1 = si->rock1; 805 rock1 = si->rock1;
806 rock2 = si->rock2; 806 rock2 = si->rock2;
807 s = splhigh (); 807 s = splhigh ();
808 if(si_callbacks) 808 if(si_callbacks)
809 softint_schedule(si_callback_cookie); 809 softint_schedule(si_callback_cookie);
810 si->next = si_free; 810 si->next = si_free;
811 si_free = si; 811 si_free = si;
812 splx(s); 812 splx(s);
 813
 814 /*
 815 * Raise spl for BASEPRI() checks to see
 816 * nested interrupts in some drivers using callbacks
 817 * since modern MI softint(9) doesn't seem to do it
 818 * in !__HAVE_FAST_SOFTINTS case.
 819 *
 820 * XXX: This is just a workaround hack.
 821 * Each driver should raise spl in its handler
 822 * to avoid nested interrupts if necessary.
 823 */
 824 s = splsoftnet(); /* XXX */
813 function(rock1, rock2); 825 function(rock1, rock2);
 826 splx(s);
814 } 827 }
815 } while (si); 828 } while (si);
816#ifdef DIAGNOSTIC 829#ifdef DIAGNOSTIC
817 if (ncbd) { 830 if (ncbd) {
818#ifdef DEBUG 831#ifdef DEBUG
819 printf("call_sicallback: %d more dynamic structures\n", ncbd); 832 printf("call_sicallback: %d more dynamic structures\n", ncbd);
820#endif 833#endif
821 ncbd = 0; 834 ncbd = 0;
822 } 835 }
823#endif 836#endif
824} 837}
825 838
826#if defined(DEBUG) && !defined(PANICBUTTON) 839#if defined(DEBUG) && !defined(PANICBUTTON)