When a device error occurs, the mediated device need to be notified in order to notify the guest of device error. Add support to notify the specific mdev when an error is wq specific and broadcast errors to all mdev when it's a generic device error. Signed-off-by: Dave Jiang <dave.jiang@xxxxxxxxx> --- drivers/dma/idxd/idxd.h | 2 ++ drivers/dma/idxd/irq.c | 4 ++++ drivers/dma/idxd/vdev.c | 33 +++++++++++++++++++++++++++++++++ drivers/dma/idxd/vdev.h | 1 + 4 files changed, 40 insertions(+) diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h index 92a9718daa15..651196514ad5 100644 --- a/drivers/dma/idxd/idxd.h +++ b/drivers/dma/idxd/idxd.h @@ -362,5 +362,7 @@ void idxd_wq_del_cdev(struct idxd_wq *wq); /* mdev */ int idxd_mdev_host_init(struct idxd_device *idxd); void idxd_mdev_host_release(struct idxd_device *idxd); +void idxd_wq_vidxd_send_errors(struct idxd_wq *wq); +void idxd_vidxd_send_errors(struct idxd_device *idxd); #endif diff --git a/drivers/dma/idxd/irq.c b/drivers/dma/idxd/irq.c index bc634dc4e485..256ef7d8a5c9 100644 --- a/drivers/dma/idxd/irq.c +++ b/drivers/dma/idxd/irq.c @@ -167,6 +167,8 @@ irqreturn_t idxd_misc_thread(int vec, void *data) if (wq->type == IDXD_WQT_USER) wake_up_interruptible(&wq->idxd_cdev.err_queue); + else if (wq->type == IDXD_WQT_MDEV) + idxd_wq_vidxd_send_errors(wq); } else { int i; @@ -175,6 +177,8 @@ irqreturn_t idxd_misc_thread(int vec, void *data) if (wq->type == IDXD_WQT_USER) wake_up_interruptible(&wq->idxd_cdev.err_queue); + else if (wq->type == IDXD_WQT_MDEV) + idxd_vidxd_send_errors(idxd); } } diff --git a/drivers/dma/idxd/vdev.c b/drivers/dma/idxd/vdev.c index d2a15f1dae6a..83985f0a336e 100644 --- a/drivers/dma/idxd/vdev.c +++ b/drivers/dma/idxd/vdev.c @@ -568,3 +568,36 @@ int vidxd_free_ims_entry(struct vdcm_idxd *vidxd, int msix_idx) { return 0; } + +static void vidxd_send_errors(struct vdcm_idxd *vidxd) +{ + struct idxd_device *idxd = vidxd->idxd; + struct vdcm_idxd_pci_bar0 *bar0 = &vidxd->bar0; + u64 *swerr = (u64 *)&bar0->cap_ctrl_regs[IDXD_SWERR_OFFSET]; + int i; + + for (i = 0; i < 4; i++) { + *swerr = idxd->sw_err.bits[i]; + swerr++; + } + vidxd_send_interrupt(vidxd, 0); +} + +void idxd_wq_vidxd_send_errors(struct idxd_wq *wq) +{ + struct vdcm_idxd *vidxd; + + list_for_each_entry(vidxd, &wq->vdcm_list, list) + vidxd_send_errors(vidxd); +} + +void idxd_vidxd_send_errors(struct idxd_device *idxd) +{ + int i; + + for (i = 0; i < idxd->max_wqs; i++) { + struct idxd_wq *wq = &idxd->wqs[i]; + + idxd_wq_vidxd_send_errors(wq); + } +} diff --git a/drivers/dma/idxd/vdev.h b/drivers/dma/idxd/vdev.h index 3dfff6d0f641..14c6631e670c 100644 --- a/drivers/dma/idxd/vdev.h +++ b/drivers/dma/idxd/vdev.h @@ -38,5 +38,6 @@ int vidxd_setup_ims_entry(struct vdcm_idxd *vidxd, int ims_idx, u32 val); int vidxd_send_interrupt(struct vdcm_idxd *vidxd, int msix_idx); void vidxd_do_command(struct vdcm_idxd *vidxd, u32 val); void vidxd_reset(struct vdcm_idxd *vidxd); +void idxd_wq_vidxd_send_errors(struct idxd_wq *wq); #endif