Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46f9c2b9 authored by Heinz Graalfs's avatar Heinz Graalfs Committed by Rusty Russell
Browse files

virtio_ring: change host notification API



Currently a host kick error is silently ignored and not reflected in
the virtqueue of a particular virtio device.

Changing the notify API for guest->host notification seems to be one
prerequisite in order to be able to handle such errors in the context
where the kick is triggered.

This patch changes the notify API. The notify function must return a
bool return value. It returns false if the host notification failed.

Signed-off-by: default avatarHeinz Graalfs <graalfs@linux.vnet.ibm.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 630b54d3
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -229,7 +229,7 @@ struct lguest_vq_info {
 * make a hypercall.  We hand the physical address of the virtqueue so the Host
 * knows which virtqueue we're talking about.
 */
static void lg_notify(struct virtqueue *vq)
static bool lg_notify(struct virtqueue *vq)
{
	/*
	 * We store our virtqueue information in the "priv" pointer of the
@@ -238,6 +238,7 @@ static void lg_notify(struct virtqueue *vq)
	struct lguest_vq_info *lvq = vq->priv;

	hcall(LHCALL_NOTIFY, lvq->config.pfn << PAGE_SHIFT, 0, 0, 0);
	return true;
}

/* An extern declaration inside a C file is bad form.  Don't do it. */
+2 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@
#include "remoteproc_internal.h"

/* kick the remote processor, and let it know which virtqueue to poke at */
static void rproc_virtio_notify(struct virtqueue *vq)
static bool rproc_virtio_notify(struct virtqueue *vq)
{
	struct rproc_vring *rvring = vq->priv;
	struct rproc *rproc = rvring->rvdev->rproc;
@@ -39,6 +39,7 @@ static void rproc_virtio_notify(struct virtqueue *vq)
	dev_dbg(&rproc->dev, "kicking vq index: %d\n", notifyid);

	rproc->ops->kick(rproc, notifyid);
	return true;
}

/**
+6 −2
Original line number Diff line number Diff line
@@ -166,11 +166,15 @@ static void kvm_reset(struct virtio_device *vdev)
 * make a hypercall.  We hand the address  of the virtqueue so the Host
 * knows which virtqueue we're talking about.
 */
static void kvm_notify(struct virtqueue *vq)
static bool kvm_notify(struct virtqueue *vq)
{
	long rc;
	struct kvm_vqconfig *config = vq->priv;

	kvm_hypercall1(KVM_S390_VIRTIO_NOTIFY, config->address);
	rc = kvm_hypercall1(KVM_S390_VIRTIO_NOTIFY, config->address);
	if (rc < 0)
		return false;
	return true;
}

/*
+4 −1
Original line number Diff line number Diff line
@@ -162,7 +162,7 @@ static inline long do_kvm_notify(struct subchannel_id schid,
	return __rc;
}

static void virtio_ccw_kvm_notify(struct virtqueue *vq)
static bool virtio_ccw_kvm_notify(struct virtqueue *vq)
{
	struct virtio_ccw_vq_info *info = vq->priv;
	struct virtio_ccw_device *vcdev;
@@ -171,6 +171,9 @@ static void virtio_ccw_kvm_notify(struct virtqueue *vq)
	vcdev = to_vc_device(info->vq->vdev);
	ccw_device_get_schid(vcdev->cdev, &schid);
	info->cookie = do_kvm_notify(schid, vq->index, info->cookie);
	if (info->cookie < 0)
		return false;
	return true;
}

static int virtio_ccw_read_vq_conf(struct virtio_ccw_device *vcdev,
+2 −1
Original line number Diff line number Diff line
@@ -219,13 +219,14 @@ static void vm_reset(struct virtio_device *vdev)
/* Transport interface */

/* the notify function used when creating a virt queue */
static void vm_notify(struct virtqueue *vq)
static bool vm_notify(struct virtqueue *vq)
{
	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vq->vdev);

	/* We write the queue's selector into the notification register to
	 * signal the other end */
	writel(vq->index, vm_dev->base + VIRTIO_MMIO_QUEUE_NOTIFY);
	return true;
}

/* Notify all virtqueues on an interrupt. */
Loading