svn commit: r186535 - in projects/releng_7_xen/sys: dev/xen/blkfront dev/xen/console dev/xen/evtchn dev/xen/netfront i386/conf i386/i386 i386/include/xen i386/isa i386/xen xen xen/evtchn xen/xenbus

Kip Macy kmacy at FreeBSD.org
Sat Dec 27 22:01:43 PST 2008


Author: kmacy
Date: Sun Dec 28 06:01:42 2008
New Revision: 186535
URL: http://svn.freebsd.org/changeset/base/186535

Log:
  - merge in latest xenbus from dfr's xenhvm
  - fix race condition in xs_read_reply by converting tsleep to mtx_sleep

Added:
  projects/releng_7_xen/sys/xen/evtchn.h   (contents, props changed)
     - copied, changed from r186315, projects/releng_7_xen/sys/i386/include/xen/evtchn.h
  projects/releng_7_xen/sys/xen/hypervisor.h   (props changed)
     - copied unchanged from r186315, projects/releng_7_xen/sys/i386/include/xen/hypervisor.h
  projects/releng_7_xen/sys/xen/xen_intr.h   (contents, props changed)
     - copied, changed from r186315, projects/releng_7_xen/sys/i386/include/xen/xen_intr.h
Deleted:
  projects/releng_7_xen/sys/i386/include/xen/evtchn.h
  projects/releng_7_xen/sys/i386/include/xen/hypervisor.h
  projects/releng_7_xen/sys/i386/include/xen/xen_intr.h
Modified:
  projects/releng_7_xen/sys/dev/xen/blkfront/blkfront.c
  projects/releng_7_xen/sys/dev/xen/console/console.c
  projects/releng_7_xen/sys/dev/xen/console/xencons_ring.c
  projects/releng_7_xen/sys/dev/xen/evtchn/evtchn_dev.c
  projects/releng_7_xen/sys/dev/xen/netfront/netfront.c
  projects/releng_7_xen/sys/i386/conf/XEN
  projects/releng_7_xen/sys/i386/i386/genassym.c
  projects/releng_7_xen/sys/i386/i386/machdep.c
  projects/releng_7_xen/sys/i386/i386/vm_machdep.c
  projects/releng_7_xen/sys/i386/include/xen/xenfunc.h
  projects/releng_7_xen/sys/i386/isa/npx.c
  projects/releng_7_xen/sys/i386/xen/clock.c
  projects/releng_7_xen/sys/i386/xen/mp_machdep.c
  projects/releng_7_xen/sys/i386/xen/mptable.c
  projects/releng_7_xen/sys/i386/xen/pmap.c
  projects/releng_7_xen/sys/i386/xen/xen_machdep.c
  projects/releng_7_xen/sys/xen/evtchn/evtchn.c
  projects/releng_7_xen/sys/xen/evtchn/evtchn_dev.c
  projects/releng_7_xen/sys/xen/features.c
  projects/releng_7_xen/sys/xen/gnttab.c
  projects/releng_7_xen/sys/xen/gnttab.h
  projects/releng_7_xen/sys/xen/xenbus/xenbus_client.c
  projects/releng_7_xen/sys/xen/xenbus/xenbus_comms.c
  projects/releng_7_xen/sys/xen/xenbus/xenbus_comms.h
  projects/releng_7_xen/sys/xen/xenbus/xenbus_dev.c
  projects/releng_7_xen/sys/xen/xenbus/xenbus_probe.c
  projects/releng_7_xen/sys/xen/xenbus/xenbus_probe_backend.c
  projects/releng_7_xen/sys/xen/xenbus/xenbus_xs.c
  projects/releng_7_xen/sys/xen/xenbus/xenbusvar.h

Modified: projects/releng_7_xen/sys/dev/xen/blkfront/blkfront.c
==============================================================================
--- projects/releng_7_xen/sys/dev/xen/blkfront/blkfront.c	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/dev/xen/blkfront/blkfront.c	Sun Dec 28 06:01:42 2008	(r186535)
@@ -40,10 +40,10 @@ __FBSDID("$FreeBSD$");
 #include <machine/intr_machdep.h>
 #include <machine/vmparam.h>
 
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #include <machine/xen/xen-os.h>
-#include <machine/xen/xen_intr.h>
-#include <machine/xen/evtchn.h>
+#include <xen/xen_intr.h>
+#include <xen/evtchn.h>
 #include <xen/interface/grant_table.h>
 #include <xen/interface/io/protocols.h>
 #include <xen/xenbus/xenbusvar.h>
@@ -214,7 +214,7 @@ xlvbd_add(device_t dev, blkif_sector_t c
 	struct xb_softc	*sc;
 	int	unit, error = 0;
 	const char *name;
-	
+
 	blkfront_vdevice_to_unit(vdevice, &unit, &name);
 
 	sc = (struct xb_softc *)malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO);
@@ -227,12 +227,12 @@ xlvbd_add(device_t dev, blkif_sector_t c
 
 	memset(&sc->xb_disk, 0, sizeof(sc->xb_disk)); 
 	sc->xb_disk = disk_alloc();
-	sc->xb_disk->d_unit = unit;
+	sc->xb_disk->d_unit = sc->xb_unit;
 	sc->xb_disk->d_open = blkif_open;
 	sc->xb_disk->d_close = blkif_close;
 	sc->xb_disk->d_ioctl = blkif_ioctl;
 	sc->xb_disk->d_strategy = xb_strategy;
-	sc->xb_disk->d_name = "xbd";
+	sc->xb_disk->d_name = name;
 	sc->xb_disk->d_drv1 = sc;
 	sc->xb_disk->d_sectorsize = sector_size;
 
@@ -329,8 +329,8 @@ blkfront_attach(device_t dev)
 
 	/* FIXME: Use dynamic device id if this is not set. */
 	err = xenbus_scanf(XBT_NIL, xenbus_get_node(dev),
-			   "virtual-device", "%i", &vdevice);
-	if (err != 1) {
+	    "virtual-device", NULL, "%i", &vdevice);
+	if (err) {
 		xenbus_dev_fatal(dev, err, "reading virtual-device");
 		printf("couldn't find virtual device");
 		return (err);
@@ -363,9 +363,8 @@ blkfront_attach(device_t dev)
 	info->handle = strtoul(strrchr(xenbus_get_node(dev),'/')+1, NULL, 0);
 
 	err = talk_to_backend(dev, info);
-	if (err) {
-		return err;
-	}
+	if (err)
+		return (err);
 
 	return (0);
 }
@@ -381,7 +380,8 @@ blkfront_resume(device_t dev)
 	blkif_free(info, 1);
 
 	err = talk_to_backend(dev, info);
-	if (!err)
+
+	if (info->connected == BLKIF_STATE_SUSPENDED && !err)
 		blkif_recover(info);
 
 	return err;
@@ -427,7 +427,7 @@ talk_to_backend(device_t dev, struct blk
 	}
 	err = xenbus_transaction_end(xbt, 0);
 	if (err) {
-		if (err == -EAGAIN)
+		if (err == EAGAIN)
 			goto again;
 		xenbus_dev_fatal(dev, err, "completing transaction");
 		goto destroy_blkring;
@@ -450,7 +450,7 @@ static int 
 setup_blkring(device_t dev, struct blkfront_info *info)
 {
 	blkif_sring_t *sring;
-	int err;
+	int error;
 
 	info->ring_ref = GRANT_INVALID_REF;
 
@@ -462,28 +462,27 @@ setup_blkring(device_t dev, struct blkfr
 	SHARED_RING_INIT(sring);
 	FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE);
 
-	err = xenbus_grant_ring(dev, (vtomach(info->ring.sring) >> PAGE_SHIFT));
-	if (err < 0) {
+	error = xenbus_grant_ring(dev, (vtomach(info->ring.sring) >> PAGE_SHIFT),
+		&info->ring_ref);
+	if (error) {
 		free(sring, M_DEVBUF);
 		info->ring.sring = NULL;
 		goto fail;
 	}
-	info->ring_ref = err;
 	
-	err = bind_listening_port_to_irqhandler(xenbus_get_otherend_id(dev),
+	error = bind_listening_port_to_irqhandler(xenbus_get_otherend_id(dev),
 		"xbd", (driver_intr_t *)blkif_int, info,
-					INTR_TYPE_BIO | INTR_MPSAFE, NULL);
-	if (err <= 0) {
-		xenbus_dev_fatal(dev, err,
+					INTR_TYPE_BIO | INTR_MPSAFE, &info->irq);
+	if (error) {
+		xenbus_dev_fatal(dev, error,
 				 "bind_evtchn_to_irqhandler failed");
 		goto fail;
 	}
-	info->irq = err;
 
-	return 0;
+	return (0);
  fail:
 	blkif_free(info, 0);
-	return err;
+	return (error);
 }
 
 
@@ -999,7 +998,7 @@ blkif_free(struct blkfront_info *info, i
 		info->ring.sring = NULL;
 	}
 	if (info->irq)
-		unbind_from_irqhandler(info->irq, info); 
+		unbind_from_irqhandler(info->irq);
 	info->irq = 0;
 
 }

Modified: projects/releng_7_xen/sys/dev/xen/console/console.c
==============================================================================
--- projects/releng_7_xen/sys/dev/xen/console/console.c	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/dev/xen/console/console.c	Sun Dec 28 06:01:42 2008	(r186535)
@@ -15,8 +15,8 @@
 #include <sys/bus.h>
 #include <machine/stdarg.h>
 #include <machine/xen/xen-os.h>
-#include <machine/xen/hypervisor.h>
-#include <machine/xen/xen_intr.h>
+#include <xen/hypervisor.h>
+#include <xen/xen_intr.h>
 #include <sys/cons.h>
 #include <sys/proc.h>
 #include <sys/priv.h>
@@ -77,17 +77,17 @@ static unsigned int wc, wp; /* write_con
 #define	XCUNIT(x)	(minor(x))
 #define ISTTYOPEN(tp)	((tp) && ((tp)->t_state & TS_ISOPEN))
 #define CN_LOCK_INIT(x, _name) \
-        mtx_init(&x, _name, NULL, MTX_SPIN|MTX_RECURSE)
+        mtx_init(&x, _name, NULL, MTX_DEF|MTX_RECURSE)
 
 #define CN_LOCK(l)        								\
 		do {											\
 				if (panicstr == NULL)					\
-                        mtx_lock_spin(&(l));			\
+                        mtx_lock(&(l));			\
 		} while (0)
 #define CN_UNLOCK(l)        							\
 		do {											\
 				if (panicstr == NULL)					\
-                        mtx_unlock_spin(&(l));			\
+                        mtx_unlock(&(l));			\
 		} while (0)
 #define CN_LOCK_ASSERT(x)    mtx_assert(&x, MA_OWNED)
 #define CN_LOCK_DESTROY(x)   mtx_destroy(&x)
@@ -234,6 +234,7 @@ xc_probe(device_t dev)
 static int
 xc_attach(device_t dev) 
 {
+	int error;
 	struct xc_softc *sc = (struct xc_softc *)device_get_softc(dev);
 
 
@@ -260,13 +261,14 @@ xc_attach(device_t dev) 
 	callout_reset(&xc_callout, XC_POLLTIME, xc_timeout, xccons);
     
 	if (xen_start_info->flags & SIF_INITDOMAIN) {
-		PANIC_IF(bind_virq_to_irqhandler(
+			error = bind_virq_to_irqhandler(
 				 VIRQ_CONSOLE,
 				 0,
 				 "console",
 				 xencons_priv_interrupt,
-					 NULL, INTR_TYPE_TTY) < 0);
+					 NULL, INTR_TYPE_TTY, NULL);
 		
+				KASSERT(error >= 0, ("can't register console interrupt"));
 	}
 
 

Modified: projects/releng_7_xen/sys/dev/xen/console/xencons_ring.c
==============================================================================
--- projects/releng_7_xen/sys/dev/xen/console/xencons_ring.c	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/dev/xen/console/xencons_ring.c	Sun Dec 28 06:01:42 2008	(r186535)
@@ -15,19 +15,20 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <machine/stdarg.h>
 #include <machine/xen/xen-os.h>
-#include <machine/xen/hypervisor.h>
-#include <machine/xen/xen_intr.h>
+#include <xen/hypervisor.h>
+#include <xen/xen_intr.h>
 #include <sys/cons.h>
 
 
 #include <dev/xen/console/xencons_ring.h>
-#include <machine/xen/evtchn.h>
+#include <xen/evtchn.h>
 #include <xen/interface/io/console.h>
 
 
 #define console_evtchn	console.domU.evtchn
 extern char *console_page;
- 
+extern struct mtx              cn_mtx;
+
 static inline struct xencons_interface *
 xencons_interface(void)
 {
@@ -82,6 +83,7 @@ xencons_handle_input(void *unused)
 	struct xencons_interface *intf;
 	XENCONS_RING_IDX cons, prod;
 
+	mtx_lock(&cn_mtx);
 	intf = xencons_interface();
 
 	cons = intf->in_cons;
@@ -99,6 +101,7 @@ xencons_handle_input(void *unused)
 	notify_remote_via_evtchn(xen_start_info->console_evtchn);
 
 	xencons_tx();
+	mtx_unlock(&cn_mtx);
 }
 
 void 

Modified: projects/releng_7_xen/sys/dev/xen/evtchn/evtchn_dev.c
==============================================================================
--- projects/releng_7_xen/sys/dev/xen/evtchn/evtchn_dev.c	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/dev/xen/evtchn/evtchn_dev.c	Sun Dec 28 06:01:42 2008	(r186535)
@@ -26,13 +26,13 @@ __FBSDID("$FreeBSD$");
 #include <machine/cpufunc.h>
 #include <machine/intr_machdep.h>
 #include <machine/xen-os.h>
-#include <machine/xen_intr.h>
+#include <xen/xen_intr.h>
 #include <machine/bus.h>
 #include <sys/rman.h>
 #include <machine/resource.h>
 #include <machine/synch_bitops.h>
 
-#include <machine/hypervisor.h>
+#include <xen/hypervisor.h>
 
 
 typedef struct evtchn_sotfc {

Modified: projects/releng_7_xen/sys/dev/xen/netfront/netfront.c
==============================================================================
--- projects/releng_7_xen/sys/dev/xen/netfront/netfront.c	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/dev/xen/netfront/netfront.c	Sun Dec 28 06:01:42 2008	(r186535)
@@ -63,9 +63,9 @@ __FBSDID("$FreeBSD$");
 #include <machine/intr_machdep.h>
 
 #include <machine/xen/xen-os.h>
-#include <machine/xen/hypervisor.h>
-#include <machine/xen/xen_intr.h>
-#include <machine/xen/evtchn.h>
+#include <xen/hypervisor.h>
+#include <xen/xen_intr.h>
+#include <xen/evtchn.h>
 #include <xen/gnttab.h>
 #include <xen/interface/memory.h>
 #include <dev/xen/netfront/mbufq.h>
@@ -364,24 +364,25 @@ makembuf (struct mbuf *buf)
 static int 
 xen_net_read_mac(device_t dev, uint8_t mac[])
 {
-	char *s;
-	int i;
-	char *e;
-	char *macstr = xenbus_read(XBT_NIL, xenbus_get_node(dev), "mac", NULL);
-	if (IS_ERR(macstr)) {
-		return PTR_ERR(macstr);
-	}
+	int error, i;
+	char *s, *e, *macstr;
+
+	error = xenbus_read(XBT_NIL, xenbus_get_node(dev), "mac", NULL,
+	    (void **) &macstr);
+	if (error)
+		return (error);
+
 	s = macstr;
 	for (i = 0; i < ETHER_ADDR_LEN; i++) {
 		mac[i] = strtoul(s, &e, 16);
 		if (s == e || (e[0] != ':' && e[0] != 0)) {
 			free(macstr, M_DEVBUF);
-			return ENOENT;
+			return (ENOENT);
 		}
 		s = &e[1];
 	}
 	free(macstr, M_DEVBUF);
-	return 0;
+	return (0);
 }
 
 /**
@@ -423,13 +424,11 @@ netfront_attach(device_t dev)
  * leave the device-layer structures intact so that this is transparent to the
  * rest of the kernel.
  */
-static int 
+static int
 netfront_resume(device_t dev)
 {
 	struct netfront_info *info = device_get_softc(dev);
-	
-	DPRINTK("%s\n", xenbus_get_node(dev));
-	
+
 	netif_disconnect_backend(info);
 	return (0);
 }
@@ -533,7 +532,7 @@ setup_device(device_t dev, struct netfro
 {
 	netif_tx_sring_t *txs;
 	netif_rx_sring_t *rxs;
-	int err;
+	int error;
 	struct ifnet *ifp;
 	
 	ifp = info->xn_ifp;
@@ -546,51 +545,45 @@ setup_device(device_t dev, struct netfro
 
 	txs = (netif_tx_sring_t *)malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT|M_ZERO);
 	if (!txs) {
-		err = ENOMEM;
-		xenbus_dev_fatal(dev, err, "allocating tx ring page");
+		error = ENOMEM;
+		xenbus_dev_fatal(dev, error, "allocating tx ring page");
 		goto fail;
 	}
 	SHARED_RING_INIT(txs);
 	FRONT_RING_INIT(&info->tx, txs, PAGE_SIZE);
-	err = xenbus_grant_ring(dev, virt_to_mfn(txs));
-	if (err < 0)
+	error = xenbus_grant_ring(dev, virt_to_mfn(txs), &info->tx_ring_ref);
+	if (error)
 		goto fail;
-	info->tx_ring_ref = err;
 
 	rxs = (netif_rx_sring_t *)malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT|M_ZERO);
 	if (!rxs) {
-		err = ENOMEM;
-		xenbus_dev_fatal(dev, err, "allocating rx ring page");
+		error = ENOMEM;
+		xenbus_dev_fatal(dev, error, "allocating rx ring page");
 		goto fail;
 	}
 	SHARED_RING_INIT(rxs);
 	FRONT_RING_INIT(&info->rx, rxs, PAGE_SIZE);
 
-	err = xenbus_grant_ring(dev, virt_to_mfn(rxs));
-	if (err < 0)
+	error = xenbus_grant_ring(dev, virt_to_mfn(rxs), &info->rx_ring_ref);
+	if (error)
 		goto fail;
-	info->rx_ring_ref = err;
 
-#if 0	
-	network_connect(info);
-#endif
-	err = bind_listening_port_to_irqhandler(xenbus_get_otherend_id(dev),
-		"xn", xn_intr, info, INTR_TYPE_NET | INTR_MPSAFE, NULL);
+	error = bind_listening_port_to_irqhandler(xenbus_get_otherend_id(dev),
+	         "xn", xn_intr, info, INTR_TYPE_NET | INTR_MPSAFE, &info->irq);
 
-	if (err <= 0) {
-		xenbus_dev_fatal(dev, err,
+	if (error) {
+		xenbus_dev_fatal(dev, error,
 				 "bind_evtchn_to_irqhandler failed");
 		goto fail;
 	}
-	info->irq = err;
-	
+
 	show_device(info);
 	
-	return 0;
+	return (0);
 	
  fail:
 	netif_free(info);
-	return err;
+	return (error);
 }
 
 /**
@@ -1226,7 +1219,7 @@ xennet_get_responses(struct netfront_inf
 				MULTI_update_va_mapping(mcl, (u_long)vaddr,
 				    (((vm_paddr_t)mfn) << PAGE_SHIFT) | PG_RW |
 				    PG_V | PG_M | PG_A, 0);
-				pfn = (uint32_t)m->m_ext.ext_args;
+				pfn = (uintptr_t)m->m_ext.ext_args;
 				mmu->ptr = ((vm_paddr_t)mfn << PAGE_SHIFT) |
 				    MMU_MACHPHYS_UPDATE;
 				mmu->val = pfn;
@@ -1558,18 +1551,18 @@ xn_stop(struct netfront_info *sc)
 int
 network_connect(struct netfront_info *np)
 {
-	int i, requeue_idx, err;
+	int i, requeue_idx, error;
 	grant_ref_t ref;
 	netif_rx_request_t *req;
 	u_int feature_rx_copy, feature_rx_flip;
 
-	err = xenbus_scanf(XBT_NIL, xenbus_get_otherend_path(np->xbdev),
-			   "feature-rx-copy", "%u", &feature_rx_copy);
-	if (err != 1)
+	error = xenbus_scanf(XBT_NIL, xenbus_get_otherend_path(np->xbdev),
+	    "feature-rx-copy", NULL, "%u", &feature_rx_copy);
+	if (error)
 		feature_rx_copy = 0;
-	err = xenbus_scanf(XBT_NIL, xenbus_get_otherend_path(np->xbdev),
-			   "feature-rx-flip", "%u", &feature_rx_flip);
-	if (err != 1)
+	error = xenbus_scanf(XBT_NIL, xenbus_get_otherend_path(np->xbdev),
+	    "feature-rx-flip", NULL, "%u", &feature_rx_flip);
+	if (error)
 		feature_rx_flip = 1;
 
 	/*
@@ -1582,9 +1575,9 @@ network_connect(struct netfront_info *np
 
 	XN_LOCK(np);
 	/* Recovery procedure: */
-	err = talk_to_backend(np->xbdev, np);
-	if (err) 
-		return (err);
+	error = talk_to_backend(np->xbdev, np);
+	if (error) 
+		return (error);
 	
 	/* Step 1: Reinitialise variables. */
 	netif_release_tx_bufs(np);
@@ -1592,6 +1585,7 @@ network_connect(struct netfront_info *np
 	/* Step 2: Rebuild the RX buffer freelist and the RX ring itself. */
 	for (requeue_idx = 0, i = 0; i < NET_RX_RING_SIZE; i++) {
 		struct mbuf *m;
+		u_long pfn;
 
 		if (np->rx_mbufs[i] == NULL)
 			continue;
@@ -1599,15 +1593,16 @@ network_connect(struct netfront_info *np
 		m = np->rx_mbufs[requeue_idx] = xennet_get_rx_mbuf(np, i);
 		ref = np->grant_rx_ref[requeue_idx] = xennet_get_rx_ref(np, i);
 		req = RING_GET_REQUEST(&np->rx, requeue_idx);
+		pfn = vtophys(mtod(m, vm_offset_t)) >> PAGE_SHIFT;
 
 		if (!np->copying_receiver) {
 			gnttab_grant_foreign_transfer_ref(ref,
 			    xenbus_get_otherend_id(np->xbdev),
-			    vtophys(mtod(m, vm_offset_t)));
+			    pfn);
 		} else {
 			gnttab_grant_foreign_access_ref(ref,
 			    xenbus_get_otherend_id(np->xbdev),
-			    vtophys(mtod(m, vm_offset_t)), 0);
+			    PFNTOMFN(pfn), 0);
 		}
 		req->gref = ref;
 		req->id   = requeue_idx;
@@ -1708,7 +1703,7 @@ create_netdev(device_t dev)
 	ifp = np->xn_ifp = if_alloc(IFT_ETHER);
     	ifp->if_softc = np;
     	if_initname(ifp, "xn",  device_get_unit(dev));
-    	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
+    	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
     	ifp->if_ioctl = xn_ioctl;
     	ifp->if_output = ether_output;
     	ifp->if_start = xn_start;
@@ -1778,11 +1773,14 @@ static void netif_free(struct netfront_i
 #endif
 }
 
-
-
 static void netif_disconnect_backend(struct netfront_info *info)
 {
-	xn_stop(info);
+	XN_RX_LOCK(info);
+	XN_TX_LOCK(info);
+	netfront_carrier_off(info);
+	XN_TX_UNLOCK(info);
+	XN_RX_UNLOCK(info);
+
 	end_access(info->tx_ring_ref, info->tx.sring);
 	end_access(info->rx_ring_ref, info->rx.sring);
 	info->tx_ring_ref = GRANT_INVALID_REF;
@@ -1790,12 +1788,9 @@ static void netif_disconnect_backend(str
 	info->tx.sring = NULL;
 	info->rx.sring = NULL;
 
-#if 0
 	if (info->irq)
-		unbind_from_irqhandler(info->irq, info->netdev);
-#else 
-	panic("FIX ME");
-#endif
+		unbind_from_irqhandler(info->irq);
+
 	info->irq = 0;
 }
 

Modified: projects/releng_7_xen/sys/i386/conf/XEN
==============================================================================
--- projects/releng_7_xen/sys/i386/conf/XEN	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/i386/conf/XEN	Sun Dec 28 06:01:42 2008	(r186535)
@@ -27,9 +27,9 @@ ident		GENERIC
 makeoptions	DEBUG=-g		# Build kernel with gdb(1) debug symbols
 #makeoptions	MODULES_OVERRIDE=""
 
-#options 	SCHED_ULE		# ULE scheduler
-#options 	PREEMPTION		# Enable kernel thread preemption
-options		SCHED_4BSD		 
+options 	SCHED_ULE		# ULE scheduler
+options 	PREEMPTION		# Enable kernel thread preemption
+#options		SCHED_4BSD		 
 
 options 	INET			# InterNETworking
 options 	INET6			# IPv6 communications protocols

Modified: projects/releng_7_xen/sys/i386/i386/genassym.c
==============================================================================
--- projects/releng_7_xen/sys/i386/i386/genassym.c	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/i386/i386/genassym.c	Sun Dec 28 06:01:42 2008	(r186535)
@@ -230,7 +230,7 @@ ASSYM(BUS_SPACE_HANDLE_IAT, offsetof(str
 #endif
 
 #ifdef XEN
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 ASSYM(PC_CR3, offsetof(struct pcpu, pc_cr3));
 ASSYM(HYPERVISOR_VIRT_START, __HYPERVISOR_VIRT_START);
 #endif

Modified: projects/releng_7_xen/sys/i386/i386/machdep.c
==============================================================================
--- projects/releng_7_xen/sys/i386/i386/machdep.c	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/i386/i386/machdep.c	Sun Dec 28 06:01:42 2008	(r186535)
@@ -145,11 +145,11 @@ uint32_t arch_i386_xbox_memsize = 0;
 #ifdef XEN
 /* XEN includes */
 #include <machine/xen/xen-os.h>
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #include <machine/xen/xen-os.h>
 #include <machine/xen/xenvar.h>
 #include <machine/xen/xenfunc.h>
-#include <machine/xen/xen_intr.h>
+#include <xen/xen_intr.h>
 
 void Xhypervisor_callback(void);
 void failsafe_callback(void);

Modified: projects/releng_7_xen/sys/i386/i386/vm_machdep.c
==============================================================================
--- projects/releng_7_xen/sys/i386/i386/vm_machdep.c	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/i386/i386/vm_machdep.c	Sun Dec 28 06:01:42 2008	(r186535)
@@ -90,7 +90,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm_param.h>
 
 #ifdef XEN
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #endif
 #ifdef PC98
 #include <pc98/cbus/cbus.h>

Modified: projects/releng_7_xen/sys/i386/include/xen/xenfunc.h
==============================================================================
--- projects/releng_7_xen/sys/i386/include/xen/xenfunc.h	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/i386/include/xen/xenfunc.h	Sun Dec 28 06:01:42 2008	(r186535)
@@ -33,7 +33,7 @@
 #define _XEN_XENFUNC_H_
 
 #include <machine/xen/xen-os.h>
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #include <machine/xen/xenpmap.h>
 #include <machine/segments.h>
 #include <sys/pcpu.h>

Modified: projects/releng_7_xen/sys/i386/isa/npx.c
==============================================================================
--- projects/releng_7_xen/sys/i386/isa/npx.c	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/i386/isa/npx.c	Sun Dec 28 06:01:42 2008	(r186535)
@@ -70,7 +70,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/intr_machdep.h>
 #ifdef XEN
 #include <machine/xen/xen-os.h>
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #endif
 
 #ifdef DEV_ISA

Modified: projects/releng_7_xen/sys/i386/xen/clock.c
==============================================================================
--- projects/releng_7_xen/sys/i386/xen/clock.c	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/i386/xen/clock.c	Sun Dec 28 06:01:42 2008	(r186535)
@@ -78,11 +78,11 @@ __FBSDID("$FreeBSD$");
 #include <i386/isa/isa.h>
 #include <isa/rtc.h>
 
-#include <machine/xen/xen_intr.h>
+#include <xen/xen_intr.h>
 #include <vm/vm.h>
 #include <vm/pmap.h>
 #include <machine/pmap.h>
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #include <machine/xen/xen-os.h>
 #include <machine/xen/xenfunc.h>
 #include <xen/interface/vcpu.h>
@@ -791,18 +791,20 @@ static struct vcpu_set_periodic_timer xe
 void
 cpu_initclocks(void)
 {
-	int time_irq;
-
+	unsigned int time_irq;
+	int error;
+	
 	xen_set_periodic_tick.period_ns = NS_PER_TICK;
 
 	HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, 0,
 			   &xen_set_periodic_tick);
-
-        if ((time_irq = bind_virq_to_irqhandler(VIRQ_TIMER, 0, "clk", 
+	
+        error = bind_virq_to_irqhandler(VIRQ_TIMER, 0, "clk", 
 		                                clkintr, NULL,
-						INTR_TYPE_CLK | INTR_FAST)) < 0) {
+	    INTR_TYPE_CLK | INTR_FAST, &time_irq);
+	if (error)
 		panic("failed to register clock interrupt\n");
-	}
+
 
 	/* should fast clock be enabled ? */
 	
@@ -811,18 +813,19 @@ cpu_initclocks(void)
 int
 ap_cpu_initclocks(int cpu)
 {
-	int time_irq;
+	unsigned int time_irq;
+	int error;
 
 	xen_set_periodic_tick.period_ns = NS_PER_TICK;
 
 	HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, cpu,
 			   &xen_set_periodic_tick);
-
-        if ((time_irq = bind_virq_to_irqhandler(VIRQ_TIMER, cpu, "clk", 
-						clkintr2, NULL,
-						INTR_TYPE_CLK | INTR_FAST)) < 0) {
+        error = bind_virq_to_irqhandler(VIRQ_TIMER, 0, "clk", 
+		                                clkintr, NULL,
+	    INTR_TYPE_CLK | INTR_FAST, &time_irq);
+	if (error)
 		panic("failed to register clock interrupt\n");
-	}
+
 
 	return (0);
 }

Modified: projects/releng_7_xen/sys/i386/xen/mp_machdep.c
==============================================================================
--- projects/releng_7_xen/sys/i386/xen/mp_machdep.c	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/i386/xen/mp_machdep.c	Sun Dec 28 06:01:42 2008	(r186535)
@@ -85,9 +85,9 @@ __FBSDID("$FreeBSD$");
 
 
 #include <machine/xen/xen-os.h>
-#include <machine/xen/evtchn.h>
-#include <machine/xen/xen_intr.h>
-#include <machine/xen/hypervisor.h>
+#include <xen/evtchn.h>
+#include <xen/xen_intr.h>
+#include <xen/hypervisor.h>
 #include <xen/interface/vcpu.h>
 
 #define stop_cpus_with_nmi	0
@@ -435,7 +435,8 @@ static int
 xen_smp_intr_init(unsigned int cpu)
 {
 	int rc;
-
+	unsigned int irq;
+	
 	per_cpu(resched_irq, cpu) = per_cpu(callfunc_irq, cpu) = -1;
 
 	sprintf(resched_name[cpu], "resched%u", cpu);
@@ -443,22 +444,22 @@ xen_smp_intr_init(unsigned int cpu)
 				    cpu,
 				    resched_name[cpu],
 				    smp_reschedule_interrupt,
-				    INTR_FAST|INTR_TYPE_TTY|INTR_MPSAFE);
+	    INTR_FAST|INTR_TYPE_TTY|INTR_MPSAFE, &irq);
 
 	printf("cpu=%d irq=%d vector=%d\n",
 	    cpu, rc, RESCHEDULE_VECTOR);
 	
-	per_cpu(resched_irq, cpu) = rc;
+	per_cpu(resched_irq, cpu) = irq;
 
 	sprintf(callfunc_name[cpu], "callfunc%u", cpu);
 	rc = bind_ipi_to_irqhandler(CALL_FUNCTION_VECTOR,
 				    cpu,
 				    callfunc_name[cpu],
 				    smp_call_function_interrupt,
-				    INTR_FAST|INTR_TYPE_TTY|INTR_MPSAFE);
+	    INTR_FAST|INTR_TYPE_TTY|INTR_MPSAFE, &irq);
 	if (rc < 0)
 		goto fail;
-	per_cpu(callfunc_irq, cpu) = rc;
+	per_cpu(callfunc_irq, cpu) = irq;
 
 	printf("cpu=%d irq=%d vector=%d\n",
 	    cpu, rc, CALL_FUNCTION_VECTOR);
@@ -471,9 +472,9 @@ xen_smp_intr_init(unsigned int cpu)
 
  fail:
 	if (per_cpu(resched_irq, cpu) >= 0)
-		unbind_from_irqhandler(per_cpu(resched_irq, cpu), NULL);
+		unbind_from_irqhandler(per_cpu(resched_irq, cpu));
 	if (per_cpu(callfunc_irq, cpu) >= 0)
-		unbind_from_irqhandler(per_cpu(callfunc_irq, cpu), NULL);
+		unbind_from_irqhandler(per_cpu(callfunc_irq, cpu));
 	return rc;
 }
 

Modified: projects/releng_7_xen/sys/i386/xen/mptable.c
==============================================================================
--- projects/releng_7_xen/sys/i386/xen/mptable.c	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/i386/xen/mptable.c	Sun Dec 28 06:01:42 2008	(r186535)
@@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/mptable.h>
 #include <machine/specialreg.h>
 
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #include <machine/xen/xen-os.h>
 #include <machine/smp.h>
 #include <xen/interface/vcpu.h>

Modified: projects/releng_7_xen/sys/i386/xen/pmap.c
==============================================================================
--- projects/releng_7_xen/sys/i386/xen/pmap.c	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/i386/xen/pmap.c	Sun Dec 28 06:01:42 2008	(r186535)
@@ -154,7 +154,7 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #include <xen/interface/xen.h>
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #include <machine/xen/hypercall.h>
 #include <machine/xen/xenvar.h>
 #include <machine/xen/xenfunc.h>

Modified: projects/releng_7_xen/sys/i386/xen/xen_machdep.c
==============================================================================
--- projects/releng_7_xen/sys/i386/xen/xen_machdep.c	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/i386/xen/xen_machdep.c	Sun Dec 28 06:01:42 2008	(r186535)
@@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$");
 
 
 
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #include <machine/xen/xenvar.h>
 #include <machine/xen/xenfunc.h>
 #include <machine/xen/xenpmap.h>

Copied and modified: projects/releng_7_xen/sys/xen/evtchn.h (from r186315, projects/releng_7_xen/sys/i386/include/xen/evtchn.h)
==============================================================================
--- projects/releng_7_xen/sys/i386/include/xen/evtchn.h	Fri Dec 19 06:50:15 2008	(r186315, copy source)
+++ projects/releng_7_xen/sys/xen/evtchn.h	Sun Dec 28 06:01:42 2008	(r186535)
@@ -12,7 +12,7 @@
 #ifndef __ASM_EVTCHN_H__
 #define __ASM_EVTCHN_H__
 #include <machine/pcpu.h>
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #include <machine/xen/synch_bitops.h>
 #include <machine/frame.h>
 

Modified: projects/releng_7_xen/sys/xen/evtchn/evtchn.c
==============================================================================
--- projects/releng_7_xen/sys/xen/evtchn/evtchn.c	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/xen/evtchn/evtchn.c	Sun Dec 28 06:01:42 2008	(r186535)
@@ -23,10 +23,10 @@ __FBSDID("$FreeBSD$");
 #include <machine/cpufunc.h>
 #include <machine/intr_machdep.h>
 #include <machine/xen/xen-os.h>
-#include <machine/xen/xen_intr.h>
+#include <xen/xen_intr.h>
 #include <machine/xen/synch_bitops.h>
-#include <machine/xen/evtchn.h>
-#include <machine/xen/hypervisor.h>
+#include <xen/evtchn.h>
+#include <xen/hypervisor.h>
 #include <sys/smp.h>
 
 
@@ -76,6 +76,7 @@ static struct mtx irq_mapping_update_loc
 static struct xenpic *xp;
 struct xenpic_intsrc {
 	struct intsrc     xp_intsrc;
+	void		  *xp_cookie;
 	uint8_t           xp_vector;
 	boolean_t	  xp_masked;
 };
@@ -295,6 +296,7 @@ bind_caller_port_to_irq(unsigned int cal
         }
 
         irq_bindcount[irq]++;
+	unmask_evtchn(caller_port);
 
  out:
         mtx_unlock_spin(&irq_mapping_update_lock);
@@ -320,6 +322,7 @@ bind_local_port_to_irq(unsigned int loca
         evtchn_to_irq[local_port] = irq;
         irq_info[irq] = mk_irq_info(IRQT_LOCAL_PORT, 0, local_port);
         irq_bindcount[irq]++;
+	unmask_evtchn(local_port);
 
  out:
         mtx_unlock_spin(&irq_mapping_update_lock);
@@ -465,20 +468,25 @@ bind_caller_port_to_irqhandler(unsigned 
 			  driver_intr_t handler,
 			  void *arg,
 			  unsigned long irqflags,
-                          void **cookiep)
+                          unsigned int *irqp)
 {
 	unsigned int irq;
-	int retval;
+	int error;
 
 	irq = bind_caller_port_to_irq(caller_port);
 	intr_register_source(&xp->xp_pins[irq].xp_intsrc);
-	retval = intr_add_handler(devname, irq, NULL, handler, arg, irqflags, cookiep);
-	if (retval != 0) {
+	error = intr_add_handler(devname, irq, NULL, handler, arg, irqflags,
+	    &xp->xp_pins[irq].xp_cookie);
+
+	if (error) {
 		unbind_from_irq(irq);
-		return -retval;
+		return (error);
 	}
 
-	return irq;
+	if (irqp)
+		*irqp = irq;
+
+	return (0);
 }
 
 int 
@@ -488,43 +496,50 @@ bind_listening_port_to_irqhandler(
 			  driver_intr_t handler,
 			  void *arg,
 			  unsigned long irqflags,
-                          void **cookiep)
+                          unsigned int *irqp)
 {
 	unsigned int irq;
-	int retval;
+	int error;
 
 	irq = bind_listening_port_to_irq(remote_domain);
 	intr_register_source(&xp->xp_pins[irq].xp_intsrc);
-	retval = intr_add_handler(devname, irq, NULL, handler, arg, irqflags, cookiep);
-	if (retval != 0) {
+	error = intr_add_handler(devname, irq, NULL, handler, arg, irqflags,
+	    &xp->xp_pins[irq].xp_cookie);
+	if (error) {
 		unbind_from_irq(irq);
-		return -retval;
+		return (error);
 	}
-
-	return irq;
+	if (irqp)
+		*irqp = irq;
+	
+	return (0);
 }
 
 int 
 bind_interdomain_evtchn_to_irqhandler(
-	                unsigned int remote_domain,
-	                unsigned int remote_port,
-			const char *devname,
-			driver_filter_t filter,
-			driver_intr_t handler,
-			unsigned long irqflags)
+	                    unsigned int remote_domain,
+			    unsigned int remote_port,
+			    const char *devname,
+			    driver_filter_t filter,
+			    driver_intr_t handler,
+			    unsigned long irqflags,
+			    unsigned int *irqp)
 {
 	unsigned int irq;
-	int retval;
+	int error;
 
 	irq = bind_interdomain_evtchn_to_irq(remote_domain, remote_port);
 	intr_register_source(&xp->xp_pins[irq].xp_intsrc);
-	retval = intr_add_handler(devname, irq, filter, handler, NULL, irqflags, NULL);
-	if (retval != 0) {
+	error = intr_add_handler(devname, irq, filter, handler, NULL,
+	    irqflags, &xp->xp_pins[irq].xp_cookie);
+	if (error) {
 		unbind_from_irq(irq);
-		return -retval;
+		return (error);
 	}
 
-	return irq;
+	if (irqp)
+		*irqp = irq;
+	return (0);
 }
 
 int 
@@ -533,20 +548,24 @@ bind_virq_to_irqhandler(unsigned int vir
 			const char *devname,
 			driver_filter_t filter,
 			driver_intr_t handler,
-			unsigned long irqflags)
+                        unsigned long irqflags,
+                        unsigned int *irqp)
 {
 	unsigned int irq;
-	int retval;
+	int error;
 
 	irq = bind_virq_to_irq(virq, cpu);
 	intr_register_source(&xp->xp_pins[irq].xp_intsrc);
-	retval = intr_add_handler(devname, irq, filter, handler, NULL, irqflags, NULL);
-	if (retval != 0) {
+	error = intr_add_handler(devname, irq, filter, handler,
+	    NULL, irqflags, &xp->xp_pins[irq].xp_cookie);
+	if (error) {
 		unbind_from_irq(irq);
-		return -retval;
+		return (error);
 	}
 
-	return irq;
+	if (irqp)
+		*irqp = irq;
+	return (0);
 }
 
 int 
@@ -554,27 +573,30 @@ bind_ipi_to_irqhandler(unsigned int ipi,
 		       unsigned int cpu,
 		       const char *devname,
 		       driver_filter_t filter,
-		       unsigned long irqflags)
+                       unsigned long irqflags,
+                       unsigned int *irqp)
 {
-	int irq, retval;
+	unsigned int irq;
+	int error;
 	
 	irq = bind_ipi_to_irq(ipi, cpu);
 	intr_register_source(&xp->xp_pins[irq].xp_intsrc);
-	retval = intr_add_handler(devname, irq, filter, NULL,
-	    NULL, irqflags, NULL);
-	if (retval != 0) {
+	error = intr_add_handler(devname, irq, filter, NULL,
+	    NULL, irqflags, &xp->xp_pins[irq].xp_cookie);
+	if (error) {
 		unbind_from_irq(irq);
-		return -retval;
+		return (error);
 	}
 
-	return irq;
+	if (irqp)
+		*irqp = irq;
+	return (0);
 }
 
 void
-unbind_from_irqhandler(unsigned int irq, void *dev_id)
+unbind_from_irqhandler(unsigned int irq)
 {
-	if (dev_id)
-		intr_remove_handler(dev_id); /* XXX */
+	intr_remove_handler(xp->xp_pins[irq].xp_cookie);
 	unbind_from_irq(irq);
 }
 

Modified: projects/releng_7_xen/sys/xen/evtchn/evtchn_dev.c
==============================================================================
--- projects/releng_7_xen/sys/xen/evtchn/evtchn_dev.c	Sun Dec 28 05:38:49 2008	(r186534)
+++ projects/releng_7_xen/sys/xen/evtchn/evtchn_dev.c	Sun Dec 28 06:01:42 2008	(r186535)
@@ -26,13 +26,13 @@ __FBSDID("$FreeBSD$");
 #include <machine/cpufunc.h>
 #include <machine/intr_machdep.h>
 #include <machine/xen/xen-os.h>
-#include <machine/xen/xen_intr.h>
+#include <xen/xen_intr.h>
 #include <machine/bus.h>
 #include <sys/rman.h>
 #include <machine/resource.h>
 #include <machine/xen/synch_bitops.h>
-#include <machine/xen/hypervisor.h>
-#include <machine/xen/evtchn.h>
+#include <xen/hypervisor.h>
+#include <xen/evtchn.h>
 
 

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-projects mailing list