Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/xen Make hypervisor_set_ipending() and its consumer...



details:   https://anonhg.NetBSD.org/src/rev/d7fa1a88bddd
branches:  trunk
changeset: 782886:d7fa1a88bddd
user:      cherry <cherry%NetBSD.org@localhost>
date:      Sun Nov 25 08:39:35 2012 +0000

description:
Make hypervisor_set_ipending() and its consumers cpu unaware. This syncs syntax with semantics

diffstat:

 sys/arch/xen/include/hypervisor.h     |   5 +--
 sys/arch/xen/x86/hypervisor_machdep.c |  46 ++++++++++++++++++----------------
 sys/arch/xen/xen/evtchn.c             |   9 +++---
 3 files changed, 30 insertions(+), 30 deletions(-)

diffs (202 lines):

diff -r 60b40feb9efa -r d7fa1a88bddd sys/arch/xen/include/hypervisor.h
--- a/sys/arch/xen/include/hypervisor.h Sun Nov 25 07:48:46 2012 +0000
+++ b/sys/arch/xen/include/hypervisor.h Sun Nov 25 08:39:35 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hypervisor.h,v 1.38 2012/02/17 18:42:19 bouyer Exp $   */
+/*     $NetBSD: hypervisor.h,v 1.39 2012/11/25 08:39:35 cherry Exp $   */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -142,8 +142,7 @@
 void hypervisor_mask_event(unsigned int);
 void hypervisor_clear_event(unsigned int);
 void hypervisor_enable_ipl(unsigned int);
-void hypervisor_set_ipending(struct cpu_info *, 
-                            uint32_t, int, int);
+void hypervisor_set_ipending(uint32_t, int, int);
 void hypervisor_machdep_attach(void);
 void hypervisor_machdep_resume(void);
 
diff -r 60b40feb9efa -r d7fa1a88bddd sys/arch/xen/x86/hypervisor_machdep.c
--- a/sys/arch/xen/x86/hypervisor_machdep.c     Sun Nov 25 07:48:46 2012 +0000
+++ b/sys/arch/xen/x86/hypervisor_machdep.c     Sun Nov 25 08:39:35 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hypervisor_machdep.c,v 1.22 2012/11/10 16:28:06 cherry Exp $   */
+/*     $NetBSD: hypervisor_machdep.c,v 1.23 2012/11/25 08:39:36 cherry Exp $   */
 
 /*
  *
@@ -54,7 +54,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.22 2012/11/10 16:28:06 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.23 2012/11/25 08:39:36 cherry Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -87,11 +87,11 @@
 // #define EARLY_DEBUG_EVENT
 
 /* callback function type */
-typedef void (*iterate_func_t)(struct cpu_info *, unsigned int,
-                              unsigned int, unsigned int, void *);
+typedef void (*iterate_func_t)(unsigned int, unsigned int,
+                              unsigned int, void *);
 
 static inline void
-evt_iterate_bits(struct cpu_info *ci, volatile unsigned long *pendingl1,
+evt_iterate_bits(volatile unsigned long *pendingl1,
                 volatile unsigned long *pendingl2, 
                 volatile unsigned long *mask,
                 iterate_func_t iterate_pending, void *iterate_args)
@@ -109,7 +109,7 @@
                l1 &= ~(1UL << l1i);
 
                l2 = pendingl2[l1i] & (mask != NULL ? ~mask[l1i] : -1UL);
-               l2 &= ci->ci_evtmask[l1i];
+               l2 &= curcpu()->ci_evtmask[l1i];
 
                if (mask != NULL) xen_atomic_setbits_l(&mask[l1i], l2);
                xen_atomic_clearbits_l(&pendingl2[l1i], l2);
@@ -120,7 +120,7 @@
 
                        port = (l1i << LONG_SHIFT) + l2i;
 
-                       iterate_pending(ci, port, l1i, l2i, iterate_args);
+                       iterate_pending(port, l1i, l2i, iterate_args);
                }
        }
 }
@@ -131,20 +131,18 @@
  */
    
 static inline void
-evt_set_pending(struct cpu_info *ci, unsigned int port, unsigned int l1i,
+evt_set_pending(unsigned int port, unsigned int l1i,
                unsigned int l2i, void *args)
 {
 
        KASSERT(args != NULL);
-       KASSERT(ci != NULL);
 
        int *ret = args;
 
        if (evtsource[port]) {
-               hypervisor_set_ipending(evtsource[port]->ev_cpu,
-                   evtsource[port]->ev_imask, l1i, l2i);
+               hypervisor_set_ipending(evtsource[port]->ev_imask, l1i, l2i);
                evtsource[port]->ev_evcnt.ev_count++;
-               if (*ret == 0 && ci->ci_ilevel <
+               if (*ret == 0 && curcpu()->ci_ilevel <
                    evtsource[port]->ev_maxlevel)
                        *ret = 1;
        }
@@ -193,7 +191,7 @@
 
                vci->evtchn_upcall_pending = 0;
 
-               evt_iterate_bits(ci, &vci->evtchn_pending_sel,
+               evt_iterate_bits(&vci->evtchn_pending_sel,
                    s->evtchn_pending, s->evtchn_mask,
                    evt_set_pending, &ret);
 
@@ -214,12 +212,12 @@
 /* Iterate through pending events and call the event handler */
 
 static inline void
-evt_do_hypervisor_callback(struct cpu_info *ci, unsigned int port,
-                          unsigned int l1i, unsigned int l2i, void *args)
+evt_do_hypervisor_callback(unsigned int port, unsigned int l1i,
+                          unsigned int l2i, void *args)
 {
        KASSERT(args != NULL);
-       KASSERT(ci == curcpu());
 
+       struct cpu_info *ci = curcpu();
        struct intrframe *regs = args;
 
 #ifdef PORT_DEBUG
@@ -273,7 +271,7 @@
        while (vci->evtchn_upcall_pending) {
                vci->evtchn_upcall_pending = 0;
 
-               evt_iterate_bits(ci, &vci->evtchn_pending_sel,
+               evt_iterate_bits(&vci->evtchn_pending_sel,
                    s->evtchn_pending, s->evtchn_mask,
                    evt_do_hypervisor_callback, regs);
        }
@@ -390,10 +388,9 @@
 }
 
 static inline void
-evt_enable_event(struct cpu_info *ci, unsigned int port,  
-                unsigned int l1i, unsigned int l2i, void *args)
+evt_enable_event(unsigned int port, unsigned int l1i,
+                unsigned int l2i, void *args)
 {
-       KASSERT(ci != NULL);
        KASSERT(args == NULL);
        hypervisor_enable_event(port);
 }
@@ -409,16 +406,21 @@
         * we know that all callback for this event have been processed.
         */
 
-       evt_iterate_bits(ci, &ci->ci_isources[ipl]->ipl_evt_mask1,
+       evt_iterate_bits(&ci->ci_isources[ipl]->ipl_evt_mask1,
            ci->ci_isources[ipl]->ipl_evt_mask2, NULL, 
            evt_enable_event, NULL);
 
 }
 
 void
-hypervisor_set_ipending(struct cpu_info *ci, uint32_t iplmask, int l1, int l2)
+hypervisor_set_ipending(uint32_t iplmask, int l1, int l2)
 {
+
+       /* This function is not re-entrant */
+       KASSERT(x86_read_psl() != 0);
+
        int ipl;
+       struct cpu_info *ci = curcpu();
 
        /* set pending bit for the appropriate IPLs */  
        ci->ci_ipending |= iplmask;
diff -r 60b40feb9efa -r d7fa1a88bddd sys/arch/xen/xen/evtchn.c
--- a/sys/arch/xen/xen/evtchn.c Sun Nov 25 07:48:46 2012 +0000
+++ b/sys/arch/xen/xen/evtchn.c Sun Nov 25 08:39:35 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: evtchn.c,v 1.63 2012/11/25 07:48:46 cherry Exp $       */
+/*     $NetBSD: evtchn.c,v 1.64 2012/11/25 08:39:36 cherry Exp $       */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -54,7 +54,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.63 2012/11/25 07:48:46 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.64 2012/11/25 08:39:36 cherry Exp $");
 
 #include "opt_xen.h"
 #include "isa.h"
@@ -282,8 +282,7 @@
                    printf("evtsource[%d]->ev_maxlevel %d <= ilevel %d\n",
                    evtch, evtsource[evtch]->ev_maxlevel, ilevel);
 #endif
-               hypervisor_set_ipending(evtsource[evtch]->ev_cpu,
-                                       evtsource[evtch]->ev_imask,
+               hypervisor_set_ipending(evtsource[evtch]->ev_imask,
                                        evtch >> LONG_SHIFT,
                                        evtch & LONG_MASK);
 
@@ -309,7 +308,7 @@
                    printf("ih->ih_level %d <= ilevel %d\n", ih->ih_level, ilevel);
 #endif
                        cli();
-                       hypervisor_set_ipending(ih->ih_cpu, iplmask,
+                       hypervisor_set_ipending(iplmask,
                            evtch >> LONG_SHIFT, evtch & LONG_MASK);
                        /* leave masked */
                        mutex_spin_exit(&evtlock[evtch]);



Home | Main Index | Thread Index | Old Index