PERFORCE change 132157 for review
Kip Macy
kmacy at FreeBSD.org
Sun Dec 30 23:18:51 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=132157
Change 132157 by kmacy at pandemonium:kmacy:xen31 on 2007/12/31 07:18:47
update to newer evtchn interface
sync up somewhat with linux implementation
Affected files ...
.. //depot/projects/xen31/sys/dev/xen/blkfront/blkfront.c#5 edit
.. //depot/projects/xen31/sys/dev/xen/blkfront/block.h#2 edit
Differences ...
==== //depot/projects/xen31/sys/dev/xen/blkfront/blkfront.c#5 (text+ko) ====
@@ -89,7 +89,7 @@
static char *blkif_state_name[] = {
[BLKIF_STATE_DISCONNECTED] = "disconnected",
[BLKIF_STATE_CONNECTED] = "connected",
- [BLKIF_STATE_SUSPENDED] = "closed",
+ [BLKIF_STATE_SUSPENDED] = "closed",
};
static char * blkif_status_name[] = {
@@ -238,14 +238,14 @@
struct blkfront_info *info;
/* FIXME: Use dynamic device id if this is not set. */
- err = xenbus_scanf(NULL, dev->nodename,
+ err = xenbus_scanf(XBT_NIL, dev->nodename,
"virtual-device", "%i", &vdevice);
if (err != 1) {
xenbus_dev_fatal(dev, err, "reading virtual-device");
return err;
}
- info = malloc(sizeof(*info), M_DEVBUF, M_NOWAIT);
+ info = malloc(sizeof(*info), M_DEVBUF, M_NOWAIT|M_ZERO);
if (info == NULL) {
xenbus_dev_fatal(dev, ENOMEM, "allocating info structure");
return ENOMEM;
@@ -253,26 +253,20 @@
info->xbdev = dev;
info->vdevice = vdevice;
info->connected = BLKIF_STATE_DISCONNECTED;
- info->mi = NULL;
- info->gd = NULL;
/* work queue needed ? */
- info->shadow_free = 0;
- memset(info->shadow, 0, sizeof(info->shadow));
for (i = 0; i < BLK_RING_SIZE; i++)
info->shadow[i].req.id = i+1;
info->shadow[BLK_RING_SIZE-1].req.id = 0x0fffffff;
- info->users = 0;
-
/* Front end dir is a number, which is used as the id. */
info->handle = strtoul(strrchr(dev->nodename,'/')+1, NULL, 0);
- dev->data = info;
+ dev->dev_driver_data = info;
err = talk_to_backend(dev, info);
if (err) {
free(info, M_DEVBUF);
- dev->data = NULL;
+ dev->dev_driver_data = NULL;
return err;
}
@@ -282,7 +276,7 @@
static int blkfront_resume(struct xenbus_device *dev)
{
- struct blkfront_info *info = dev->data;
+ struct blkfront_info *info = dev->dev_driver_data;
int err;
DPRINTK("blkfront_resume: %s\n", dev->nodename);
@@ -301,7 +295,7 @@
struct blkfront_info *info)
{
const char *message = NULL;
- struct xenbus_transaction *xbt;
+ struct xenbus_transaction xbt;
int err;
/* Create shared ring, alloc event channel. */
@@ -310,8 +304,8 @@
goto out;
again:
- xbt = xenbus_transaction_start();
- if (IS_ERR(xbt)) {
+ err = xenbus_transaction_start(&xbt);
+ if (err) {
xenbus_dev_fatal(dev, err, "starting transaction");
goto destroy_blkring;
}
@@ -323,17 +317,12 @@
goto abort_transaction;
}
err = xenbus_printf(xbt, dev->nodename,
- "event-channel", "%u", info->evtchn);
+ "event-channel", "%u", irq_to_evtchn_port(info->irq));
if (err) {
message = "writing event-channel";
goto abort_transaction;
}
- err = xenbus_switch_state(dev, xbt, XenbusStateInitialised);
- if (err) {
- goto abort_transaction;
- }
-
err = xenbus_transaction_end(xbt, 0);
if (err) {
if (err == -EAGAIN)
@@ -341,7 +330,8 @@
xenbus_dev_fatal(dev, err, "completing transaction");
goto destroy_blkring;
}
-
+ xenbus_switch_state(dev, XenbusStateInitialised);
+
return 0;
abort_transaction:
@@ -377,7 +367,7 @@
goto fail;
}
info->ring_ref = err;
-
+
err = bind_listening_port_to_irqhandler(dev->otherend_id,
"xbd", (driver_intr_t *)blkif_int,
info, INTR_TYPE_BIO | INTR_MPSAFE, NULL);
@@ -401,7 +391,7 @@
static void backend_changed(struct xenbus_device *dev,
XenbusState backend_state)
{
- struct blkfront_info *info = dev->data;
+ struct blkfront_info *info = dev->dev_driver_data;
DPRINTK("blkfront:backend_changed.\n");
@@ -457,7 +447,7 @@
DPRINTK("blkfront.c:connect:%s.\n", info->xbdev->otherend);
- err = xenbus_gather(NULL, info->xbdev->otherend,
+ err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
"sectors", "%lu", §ors,
"info", "%u", &binfo,
"sector-size", "%lu", §or_size,
@@ -468,10 +458,15 @@
info->xbdev->otherend);
return;
}
+ err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
+ "feature-barrier", "%lu", &info->feature_barrier,
+ NULL);
+ if (err)
+ info->feature_barrier = 0;
- xlvbd_add(sectors, info->vdevice, binfo, sector_size, info);
+ xlvbd_add(sectors, info->vdevice, binfo, sector_size, info);
- (void)xenbus_switch_state(info->xbdev, NULL, XenbusStateConnected);
+ (void)xenbus_switch_state(info->xbdev, XenbusStateConnected);
/* Kick pending requests. */
mtx_lock(&blkif_io_lock);
@@ -492,7 +487,7 @@
*/
static void blkfront_closing(struct xenbus_device *dev)
{
- struct blkfront_info *info = dev->data;
+ struct blkfront_info *info = dev->dev_driver_data;
DPRINTK("blkfront_closing: %s removed\n", dev->nodename);
@@ -502,13 +497,13 @@
info->mi = NULL;
}
- xenbus_switch_state(dev, NULL, XenbusStateClosed);
+ xenbus_switch_state(dev, XenbusStateClosed);
}
static int blkfront_remove(struct xenbus_device *dev)
{
- struct blkfront_info *info = dev->data;
+ struct blkfront_info *info = dev->dev_driver_data;
DPRINTK("blkfront_remove: %s removed\n", dev->nodename);
@@ -893,7 +888,7 @@
}
if (info->irq)
unbind_from_irqhandler(info->irq, info);
- info->evtchn = info->irq = 0;
+ info->irq = 0;
}
@@ -955,7 +950,7 @@
free(copy, M_DEVBUF);
- (void)xenbus_switch_state(info->xbdev, NULL, XenbusStateConnected);
+ xenbus_switch_state(info->xbdev, XenbusStateConnected);
/* Now safe for us to use the shared ring */
mtx_lock(&blkif_io_lock);
@@ -971,6 +966,14 @@
mtx_unlock(&blkif_io_lock);
}
+static int
+blkfront_is_ready(struct xenbus_device *dev)
+{
+ struct blkfront_info *info = dev->dev_driver_data;
+
+ return info->is_ready;
+}
+
static struct xenbus_device_id blkfront_ids[] = {
{ "vbd" },
{ "" }
@@ -984,6 +987,7 @@
.remove = blkfront_remove,
.resume = blkfront_resume,
.otherend_changed = backend_changed,
+ .is_ready = blkfront_is_ready,
};
==== //depot/projects/xen31/sys/dev/xen/blkfront/block.h#2 (text+ko) ====
@@ -53,7 +53,7 @@
int connected;
int ring_ref;
blkif_front_ring_t ring;
- unsigned int evtchn, irq;
+ unsigned int irq;
struct xlbd_major_info *mi;
#if 0
request_queue_t *rq;
@@ -63,6 +63,8 @@
struct blk_shadow shadow[BLK_RING_SIZE];
unsigned long shadow_free;
struct xb_softc *sc;
+ int feature_barrier;
+ int is_ready;
/**
* The number of people holding this device open. We won't allow a
* hot-unplug unless this is 0.
More information about the p4-projects
mailing list