mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-27 15:56:54 +00:00
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:
parent
b29fc619af
commit
cb31381561
@ -179,20 +179,6 @@ vhost_eventfd_test_and_clear(int fd)
|
|||||||
return rc > 0 ? 1 : 0;
|
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
|
static int
|
||||||
vhost_vq_register_eventfd(struct vhost_dev *vdev,
|
vhost_vq_register_eventfd(struct vhost_dev *vdev,
|
||||||
int idx, bool is_register)
|
int idx, bool is_register)
|
||||||
@ -203,6 +189,8 @@ vhost_vq_register_eventfd(struct vhost_dev *vdev,
|
|||||||
struct vhost_vq *vq;
|
struct vhost_vq *vq;
|
||||||
struct virtio_vq_info *vqi;
|
struct virtio_vq_info *vqi;
|
||||||
struct pcibar *bar;
|
struct pcibar *bar;
|
||||||
|
struct msix_table_entry *mte;
|
||||||
|
struct acrn_msi_entry msi;
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
|
|
||||||
/* this interface is called only by vhost_vq_start,
|
/* this interface is called only by vhost_vq_start,
|
||||||
@ -263,37 +251,15 @@ vhost_vq_register_eventfd(struct vhost_dev *vdev,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pci_msix_enabled(base->dev)) {
|
/* register irqfd for notify */
|
||||||
/* register irqfd for notify */
|
mte = &vdev->base->dev->msix.table[vqi->msix_idx];
|
||||||
struct msix_table_entry *mte;
|
msi.msi_addr = mte->addr;
|
||||||
struct acrn_msi_entry msi;
|
msi.msi_data = mte->msg_data;
|
||||||
|
irqfd.fd = vq->call_fd;
|
||||||
mte = &vdev->base->dev->msix.table[vqi->msix_idx];
|
/* no additional flag bit should be set */
|
||||||
msi.msi_addr = mte->addr;
|
irqfd.msi = msi;
|
||||||
msi.msi_data = mte->msg_data;
|
DPRINTF("[irqfd: %d][MSIX: %d]\n", irqfd.fd, vqi->msix_idx);
|
||||||
irqfd.fd = vq->call_fd;
|
rc = vm_irqfd(vdev->base->dev->vmctx, &irqfd);
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
WPRINTF("vm_irqfd failed rc = %d, errno = %d\n", rc, errno);
|
WPRINTF("vm_irqfd failed rc = %d, errno = %d\n", rc, errno);
|
||||||
/* unregister ioeventfd */
|
/* unregister ioeventfd */
|
||||||
@ -716,6 +682,12 @@ vhost_dev_start(struct vhost_dev *vdev)
|
|||||||
goto fail;
|
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);
|
rc = vhost_kernel_set_owner(vdev);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
WPRINTF("vhost_set_owner failed\n");
|
WPRINTF("vhost_set_owner failed\n");
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#define __VHOST_H__
|
#define __VHOST_H__
|
||||||
|
|
||||||
#include "virtio.h"
|
#include "virtio.h"
|
||||||
#include "mevent.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief vhost APIs
|
* @brief vhost APIs
|
||||||
@ -28,7 +27,6 @@ struct vhost_vq {
|
|||||||
int kick_fd; /**< fd of kick eventfd */
|
int kick_fd; /**< fd of kick eventfd */
|
||||||
int call_fd; /**< fd of call eventfd */
|
int call_fd; /**< fd of call eventfd */
|
||||||
int idx; /**< index of this vq in vhost dev */
|
int idx; /**< index of this vq in vhost dev */
|
||||||
struct mevent *mevp; /**< mevent for call eventfd */
|
|
||||||
struct vhost_dev *dev; /**< pointer to vhost_dev */
|
struct vhost_dev *dev; /**< pointer to vhost_dev */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user