Module Name: src
Committed By: jym
Date: Thu May 26 22:30:32 UTC 2011
Modified Files:
src/sys/arch/xen/xen [jym-xensuspend]: if_xennet_xenbus.c xbd_xenbus.c
Log Message:
Split allocation and initialization of ring I/O for xbd(4) and xennet(4):
- allocation belongs to _attach()
- init to _resume(), so that it can be used by suspend/resume code too.
To generate a diff of this commit:
cvs rdiff -u -r1.33.2.10 -r1.33.2.11 src/sys/arch/xen/xen/if_xennet_xenbus.c
cvs rdiff -u -r1.38.2.9 -r1.38.2.10 src/sys/arch/xen/xen/xbd_xenbus.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/xen/xen/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.33.2.10 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.33.2.11
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.33.2.10 Sat May 7 17:42:09 2011
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c Thu May 26 22:30:31 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: if_xennet_xenbus.c,v 1.33.2.10 2011/05/07 17:42:09 jym Exp $ */
+/* $NetBSD: if_xennet_xenbus.c,v 1.33.2.11 2011/05/26 22:30:31 jym Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -85,7 +85,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.33.2.10 2011/05/07 17:42:09 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.33.2.11 2011/05/26 22:30:31 jym Exp $");
#include "opt_xen.h"
#include "opt_nfs_boot.h"
@@ -375,9 +375,9 @@
/* alloc shared rings */
tx_ring = (void *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
- UVM_KMF_WIRED | UVM_KMF_ZERO);
+ UVM_KMF_WIRED);
rx_ring = (void *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
- UVM_KMF_WIRED | UVM_KMF_ZERO);
+ UVM_KMF_WIRED);
if (tx_ring == NULL || rx_ring == NULL)
panic("%s: can't alloc rings", device_xname(self));
@@ -481,8 +481,12 @@
tx_ring = sc->sc_tx_ring.sring;
rx_ring = sc->sc_rx_ring.sring;
+ /* Initialize rings */
+ memset(tx_ring, 0, PAGE_SIZE);
SHARED_RING_INIT(tx_ring);
FRONT_RING_INIT(&sc->sc_tx_ring, tx_ring, PAGE_SIZE);
+
+ memset(rx_ring, 0, PAGE_SIZE);
SHARED_RING_INIT(rx_ring);
FRONT_RING_INIT(&sc->sc_rx_ring, rx_ring, PAGE_SIZE);
Index: src/sys/arch/xen/xen/xbd_xenbus.c
diff -u src/sys/arch/xen/xen/xbd_xenbus.c:1.38.2.9 src/sys/arch/xen/xen/xbd_xenbus.c:1.38.2.10
--- src/sys/arch/xen/xen/xbd_xenbus.c:1.38.2.9 Mon May 2 22:49:59 2011
+++ src/sys/arch/xen/xen/xbd_xenbus.c Thu May 26 22:30:31 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: xbd_xenbus.c,v 1.38.2.9 2011/05/02 22:49:59 jym Exp $ */
+/* $NetBSD: xbd_xenbus.c,v 1.38.2.10 2011/05/26 22:30:31 jym Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.38.2.9 2011/05/02 22:49:59 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.38.2.10 2011/05/26 22:30:31 jym Exp $");
#include "opt_xen.h"
#include "rnd.h"
@@ -268,8 +268,7 @@
sc->sc_backend_status = BLKIF_STATE_DISCONNECTED;
sc->sc_shutdown = BLKIF_SHUTDOWN_REMOTE;
- ring = (void *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
- UVM_KMF_ZERO | UVM_KMF_WIRED);
+ ring = (void *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_WIRED);
if (ring == NULL)
panic("%s: can't alloc ring", device_xname(self));
sc->sc_ring.sring = ring;
@@ -372,8 +371,8 @@
s = splbio();
/* wait for requests to complete, then suspend device */
while (sc->sc_backend_status == BLKIF_STATE_CONNECTED &&
- sc->sc_dksc.sc_dkdev.dk_stats->io_busy > 0)
- tsleep(xbd_xenbus_suspend, PRIBIO, "xbdsuspend", hz/2);
+ sc->sc_dksc.sc_dkdev.dk_stats->io_busy > 0)
+ tsleep(xbd_xenbus_suspend, PRIBIO, "xbdsuspend", hz/2);
hypervisor_mask_event(sc->sc_evtchn);
sc->sc_backend_status = BLKIF_STATE_SUSPENDED;
@@ -407,8 +406,10 @@
xengnt_revoke_access(sc->sc_ring_gntref);
}
sc->sc_ring_gntref = GRANT_INVALID_REF;
- ring = sc->sc_ring.sring;
+ /* Initialize ring */
+ ring = sc->sc_ring.sring;
+ memset(ring, 0, PAGE_SIZE);
SHARED_RING_INIT(ring);
FRONT_RING_INIT(&sc->sc_ring, ring, PAGE_SIZE);
@@ -698,9 +699,11 @@
done:
xen_rmb();
sc->sc_ring.rsp_cons = i;
+
RING_FINAL_CHECK_FOR_RESPONSES(&sc->sc_ring, more_to_do);
if (more_to_do)
goto again;
+
dk_iodone(sc->sc_di, &sc->sc_dksc);
if (sc->sc_xbdreq_wait)
wakeup(&sc->sc_xbdreq_wait);