dm: vhost: remove support for non-msix devices

irqfd only supports msix devices. In the current code a mevent is
added to poll the callfd from userspace to support intx devices.
This patch removes the support for non-msix devices since they are
not used in the current device model.

Tracked-On: #1877
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Jian Jun Chen 2018-12-12 15:09:08 +08:00 committed by wenlingz
parent b29fc619af
commit cb31381561
2 changed files with 17 additions and 47 deletions

View File

@ -179,20 +179,6 @@ vhost_eventfd_test_and_clear(int fd)
return rc > 0 ? 1 : 0;
}
static void
vhost_vq_notify(int fd __attribute__((unused)),
enum ev_type t __attribute__((unused)),
void *arg)
{
struct vhost_vq *vq = arg;
struct virtio_vq_info *vqi;
struct vhost_dev *vdev;
vdev = vq->dev;
vqi = &vdev->base->queues[vdev->vq_idx + vq->idx];
vq_interrupt(vdev->base, vqi);
}
static int
vhost_vq_register_eventfd(struct vhost_dev *vdev,
int idx, bool is_register)
@ -203,6 +189,8 @@ vhost_vq_register_eventfd(struct vhost_dev *vdev,
struct vhost_vq *vq;
struct virtio_vq_info *vqi;
struct pcibar *bar;
struct msix_table_entry *mte;
struct acrn_msi_entry msi;
int rc = -1;
/* this interface is called only by vhost_vq_start,
@ -263,37 +251,15 @@ vhost_vq_register_eventfd(struct vhost_dev *vdev,
return -1;
}
if (pci_msix_enabled(base->dev)) {
/* register irqfd for notify */
struct msix_table_entry *mte;
struct acrn_msi_entry msi;
mte = &vdev->base->dev->msix.table[vqi->msix_idx];
msi.msi_addr = mte->addr;
msi.msi_data = mte->msg_data;
irqfd.fd = vq->call_fd;
/* no additional flag bit should be set */
irqfd.msi = msi;
DPRINTF("[irqfd: %d][MSIX: %d]\n", irqfd.fd, vqi->msix_idx);
rc = vm_irqfd(vdev->base->dev->vmctx, &irqfd);
} else {
/*
* irqfd only supports MSIx now. For non-MSIx, call_fd is polled
* by dm then inject interrupts to guest
*/
if (is_register) {
vq->mevp = mevent_add(vq->call_fd, EVF_READ,
vhost_vq_notify, vq, NULL, NULL);
if (!vq->mevp) {
WPRINTF("mevent_add failed\n");
rc = -1;
}
} else if (vq->mevp) {
mevent_delete(vq->mevp);
vq->mevp = NULL;
}
}
/* register irqfd for notify */
mte = &vdev->base->dev->msix.table[vqi->msix_idx];
msi.msi_addr = mte->addr;
msi.msi_data = mte->msg_data;
irqfd.fd = vq->call_fd;
/* no additional flag bit should be set */
irqfd.msi = msi;
DPRINTF("[irqfd: %d][MSIX: %d]\n", irqfd.fd, vqi->msix_idx);
rc = vm_irqfd(vdev->base->dev->vmctx, &irqfd);
if (rc < 0) {
WPRINTF("vm_irqfd failed rc = %d, errno = %d\n", rc, errno);
/* unregister ioeventfd */
@ -716,6 +682,12 @@ vhost_dev_start(struct vhost_dev *vdev)
goto fail;
}
/* only msix is supported now */
if (!pci_msix_enabled(vdev->base->dev)) {
WPRINTF("only msix is supported\n");
goto fail;
}
rc = vhost_kernel_set_owner(vdev);
if (rc < 0) {
WPRINTF("vhost_set_owner failed\n");

View File

@ -15,7 +15,6 @@
#define __VHOST_H__
#include "virtio.h"
#include "mevent.h"
/**
* @brief vhost APIs
@ -28,7 +27,6 @@ struct vhost_vq {
int kick_fd; /**< fd of kick eventfd */
int call_fd; /**< fd of call eventfd */
int idx; /**< index of this vq in vhost dev */
struct mevent *mevp; /**< mevent for call eventfd */
struct vhost_dev *dev; /**< pointer to vhost_dev */
};