diff options
author | Erin Allison | 2021-12-19 15:44:24 -0600 |
---|---|---|
committer | Erin Allison | 2021-12-19 15:44:24 -0600 |
commit | ff62cb9c7f0ab470e787081ca708fc960ca66f32 (patch) | |
tree | 0a13d51aeb89c65da10632bf10c60fbafe69eef0 /twelve.patch | |
download | aur-ff62cb9c7f0ab470e787081ca708fc960ca66f32.tar.gz |
Initial upload: nvidia-merged 460.73.01-9
Signed-off-by: Erin Allison <erin@eallison.us>
Diffstat (limited to 'twelve.patch')
-rw-r--r-- | twelve.patch | 260 |
1 files changed, 260 insertions, 0 deletions
diff --git a/twelve.patch b/twelve.patch new file mode 100644 index 000000000000..3a268f2f7170 --- /dev/null +++ b/twelve.patch @@ -0,0 +1,260 @@ +--- ./nvidia-vgpu-vfio/nvidia-vgpu-vfio.c ++++ ./nvidia-vgpu-vfio/nvidia-vgpu-vfio.c +@@ -24,6 +24,7 @@ + #include <linux/kernel.h> + #include <linux/init.h> + #include <linux/err.h> ++#include <linux/eventfd.h> + #include "nvstatus.h" + #include "nv-misc.h" + #include "nv-linux.h" +@@ -2666,19 +2667,18 @@ + + static int vgpu_save_fd(vgpu_dev_t *vgpu_dev, int fd, NvU32 index) + { +- struct fd irqfd; ++ struct eventfd_ctx *evt; + +- irqfd = fdget(fd); +- if (!irqfd.file) +- return -EBADF; ++ evt = eventfd_ctx_fdget(fd); ++ if (IS_ERR(evt)) ++ return PTR_ERR(evt); + + if (index == VFIO_PCI_INTX_IRQ_INDEX) +- vgpu_dev->intr_info.intx_file = irqfd.file; +- else if (index == VFIO_PCI_MSI_IRQ_INDEX) +- vgpu_dev->intr_info.msi_file = irqfd.file; ++ vgpu_dev->intr_info.intx_evtfd = evt; ++ else if (index == VFIO_PCI_MSI_IRQ_INDEX) ++ vgpu_dev->intr_info.msi_evtfd = evt; + + vgpu_dev->intr_info.index = index; +- fdput(irqfd); + + return 0; + } +@@ -2687,11 +2687,8 @@ + static irqreturn_t vgpu_msix_handler(int irq, void *arg) + { + vgpu_dev_t *vgpu_dev = (vgpu_dev_t *)arg; +- struct file *pfile = NULL; +- mm_segment_t old_fs; +- NvU64 val = 1; ++ struct eventfd_ctx *evt = NULL; + int ret = 0; +- loff_t offset = 0; + int i; + unsigned long eflags; + +@@ -2699,21 +2696,16 @@ + { + if (vgpu_dev->intr_info.allocated_irq[i] == irq) + { +- pfile = vgpu_dev->intr_info.msix_fd[i].file; ++ evt = vgpu_dev->intr_info.msix_evtfd[i]; + break; + } + } + +- if (pfile && pfile->f_op && pfile->f_op->write) ++ if (evt) + { +- old_fs = get_fs(); +- set_fs(KERNEL_DS); +- + NV_SAVE_FLAGS(eflags); +- ret = pfile->f_op->write(pfile, (char *)&val, sizeof(val), &offset); ++ ret = eventfd_signal(evt, 1); + NV_RESTORE_FLAGS(eflags); +- +- set_fs(old_fs); + } + + return IRQ_HANDLED; +@@ -2724,23 +2716,24 @@ + { + struct pci_dev *pdev; + int irq = INVALID_IRQ, ret; +- struct fd irqfd; ++ struct eventfd_ctx *evt; + + pdev = to_pci_dev(NV_GET_MDEV_PARENT(vgpu_dev->mdev)); + +- if (vgpu_dev->intr_info.msix_fd[vector].file) ++ if (vgpu_dev->intr_info.msix_evtfd[vector]) + { + free_irq(vgpu_dev->intr_info.allocated_irq[vector], vgpu_dev); +- vgpu_dev->intr_info.msix_fd[vector].file = NULL; ++ eventfd_ctx_put(vgpu_dev->intr_info.msix_evtfd[vector]); ++ vgpu_dev->intr_info.msix_evtfd[vector] = NULL; + vgpu_dev->intr_info.allocated_irq[vector] = INVALID_IRQ; + } + + if (fd < 0) + return 0; + +- irqfd = fdget(fd); +- if (!irqfd.file) +- return -EBADF; ++ evt = eventfd_ctx_fdget(fd); ++ if (IS_ERR(evt)) ++ return PTR_ERR(evt); + + if (vector < 0 || vector >= vgpu_dev->intr_info.num_ctx) + return -EINVAL; +@@ -2756,7 +2749,7 @@ + + vgpu_dev->intr_info.allocated_irq[vector] = irq; + +- vgpu_dev->intr_info.msix_fd[vector]= irqfd; ++ vgpu_dev->intr_info.msix_evtfd[vector]= evt; + + return 0; + } +@@ -2773,7 +2766,12 @@ + if (vgpu_dev->intr_info.allocated_irq[i] != INVALID_IRQ) + { + free_irq(vgpu_dev->intr_info.allocated_irq[i], vgpu_dev); +- vgpu_dev->intr_info.msix_fd[i].file = NULL; ++ ++ if (vgpu_dev->intr_info.msix_evtfd[i]) { ++ eventfd_ctx_put(vgpu_dev->intr_info.msix_evtfd[i]); ++ vgpu_dev->intr_info.msix_evtfd[i] = NULL; ++ } ++ + vgpu_dev->intr_info.allocated_irq[i] = INVALID_IRQ; + } + } +@@ -2862,7 +2860,10 @@ + { + if (flags & VFIO_IRQ_SET_DATA_NONE) + { +- vgpu_dev->intr_info.intx_file = NULL; ++ if (vgpu_dev->intr_info.intx_evtfd) { ++ eventfd_ctx_put(vgpu_dev->intr_info.intx_evtfd); ++ vgpu_dev->intr_info.intx_evtfd = NULL; ++ } + break; + } + +@@ -2887,7 +2888,10 @@ + { + if (flags & VFIO_IRQ_SET_DATA_NONE) + { +- vgpu_dev->intr_info.msi_file = NULL; ++ if (vgpu_dev->intr_info.msi_evtfd) { ++ eventfd_ctx_put(vgpu_dev->intr_info.msi_evtfd); ++ vgpu_dev->intr_info.msi_evtfd = NULL; ++ } + vgpu_dev->intr_info.index = VFIO_PCI_INTX_IRQ_INDEX; + break; + } +@@ -2895,10 +2899,9 @@ + if (flags & VFIO_IRQ_SET_DATA_EVENTFD) + { + int fd = *(int *)data; +- if (fd > 0) ++ if (fd > 0 && !vgpu_dev->intr_info.msi_evtfd) + { +- if (vgpu_dev->intr_info.msi_file == NULL) +- ret = vgpu_save_fd(vgpu_dev, fd, index); ++ ret = vgpu_save_fd(vgpu_dev, fd, index); + } + } + break; +@@ -2953,12 +2956,9 @@ + + NV_STATUS nv_vgpu_inject_interrupt(void *vgpuRef) + { +- mm_segment_t old_fs; +- NvU64 val = 1; + int ret = 0; +- loff_t offset = 0; + NV_STATUS status = NV_OK; +- struct file *pfile = NULL; ++ struct eventfd_ctx *evt = NULL; + vgpu_dev_t *vgpu_dev = vgpuRef; + unsigned long eflags; + +@@ -2967,12 +2967,12 @@ + + NV_SPIN_LOCK_IRQSAVE(&vgpu_dev->intr_info_lock, eflags); + +- if ((vgpu_dev->intr_info.index == VFIO_PCI_MSI_IRQ_INDEX) && (vgpu_dev->intr_info.msi_file == NULL)) ++ if ((vgpu_dev->intr_info.index == VFIO_PCI_MSI_IRQ_INDEX) && (!vgpu_dev->intr_info.msi_evtfd)) + { + NV_SPIN_UNLOCK_IRQRESTORE(&vgpu_dev->intr_info_lock, eflags); + return NV_ERR_INVALID_REQUEST; + } +- else if ((vgpu_dev->intr_info.index == VFIO_PCI_INTX_IRQ_INDEX) && (vgpu_dev->intr_info.intx_file == NULL)) ++ else if ((vgpu_dev->intr_info.index == VFIO_PCI_INTX_IRQ_INDEX) && (!vgpu_dev->intr_info.intx_evtfd)) + { + NV_SPIN_UNLOCK_IRQRESTORE(&vgpu_dev->intr_info_lock, eflags); + return NV_ERR_INVALID_REQUEST; +@@ -2984,9 +2984,9 @@ + } + + if (vgpu_dev->intr_info.index == VFIO_PCI_MSI_IRQ_INDEX) +- pfile = vgpu_dev->intr_info.msi_file; ++ evt = vgpu_dev->intr_info.msi_evtfd; + else +- pfile = vgpu_dev->intr_info.intx_file; ++ evt = vgpu_dev->intr_info.intx_evtfd; + + // QEMU has exited. So, safe to ignore interrupts. + if (vgpu_dev->intr_info.ignore_interrupts == NV_TRUE) +@@ -2996,19 +2996,14 @@ + } + NV_SPIN_UNLOCK_IRQRESTORE(&vgpu_dev->intr_info_lock, eflags); + +- old_fs = get_fs(); +- set_fs(KERNEL_DS); +- +- if (pfile->f_op && pfile->f_op->write) +- ret = pfile->f_op->write(pfile, (char *)&val, sizeof(val), &offset); +- else +- status = NV_ERR_INVALID_REQUEST; ++ if (evt) ++ ret = eventfd_signal(evt, 1); ++ else ++ status = NV_ERR_INVALID_REQUEST; + + if (ret < 0) + status = NV_ERR_INVALID_STATE; + +- set_fs(old_fs); +- + return status; + } + +--- ./nvidia-vgpu-vfio/nvidia-vgpu-vfio.h ++++ ./nvidia-vgpu-vfio/nvidia-vgpu-vfio.h +@@ -37,6 +37,7 @@ + #include <linux/list.h> + #include <linux/pci.h> + #include <linux/sched.h> ++#include <linux/eventfd.h> + + struct vgpu_dev_s; + struct mapping_node_s; +@@ -293,15 +294,15 @@ + + typedef struct + { +- struct file *intx_file; +- struct file *msi_file; ++ struct eventfd_ctx *intx_evtfd; ++ struct eventfd_ctx *msi_evtfd; + int index; + NvBool ignore_interrupts; + + NvU32 allocated_irq[MAX_NUM_VECTORS]; + NvU32 num_ctx; + #if defined(NV_VGPU_KVM_BUILD) +- struct fd msix_fd[MAX_NUM_VECTORS]; ++ struct eventfd_ctx *msix_evtfd[MAX_NUM_VECTORS]; + #endif + + } intr_info_t; |