Skip to content

Commit 3dddebe

Browse files
committed
Merge tag 'vfio-for-v3.7-rc1' of git://github.com/awilliam/linux-vfio
Pull vfio fixes from Alex Williamson: "This includes a fix for PCI BAR mmaps after recent mm changes, fixing an interrupt race, and fixing a consistency bug in interrupt state when switching interrupt modes." * tag 'vfio-for-v3.7-rc1' of git://github.com/awilliam/linux-vfio: vfio: Fix PCI INTx disable consistency vfio: Move PCI INTx eventfd setting earlier vfio: Fix PCI mmap after b3b9c29
2 parents e626d17 + 899649b commit 3dddebe

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

drivers/vfio/pci/vfio_pci.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma)
408408
struct vfio_pci_device *vdev = device_data;
409409
struct pci_dev *pdev = vdev->pdev;
410410
unsigned int index;
411-
u64 phys_len, req_len, pgoff, req_start, phys;
411+
u64 phys_len, req_len, pgoff, req_start;
412412
int ret;
413413

414414
index = vma->vm_pgoff >> (VFIO_PCI_OFFSET_SHIFT - PAGE_SHIFT);
@@ -463,10 +463,9 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma)
463463
vma->vm_private_data = vdev;
464464
vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
465465
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
466+
vma->vm_pgoff = (pci_resource_start(pdev, index) >> PAGE_SHIFT) + pgoff;
466467

467-
phys = (pci_resource_start(pdev, index) >> PAGE_SHIFT) + pgoff;
468-
469-
return remap_pfn_range(vma, vma->vm_start, phys,
468+
return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
470469
req_len, vma->vm_page_prot);
471470
}
472471

drivers/vfio/pci/vfio_pci_intrs.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,17 @@ static int vfio_intx_enable(struct vfio_pci_device *vdev)
366366
return -ENOMEM;
367367

368368
vdev->num_ctx = 1;
369+
370+
/*
371+
* If the virtual interrupt is masked, restore it. Devices
372+
* supporting DisINTx can be masked at the hardware level
373+
* here, non-PCI-2.3 devices will have to wait until the
374+
* interrupt is enabled.
375+
*/
376+
vdev->ctx[0].masked = vdev->virq_disabled;
377+
if (vdev->pci_2_3)
378+
pci_intx(vdev->pdev, !vdev->ctx[0].masked);
379+
369380
vdev->irq_type = VFIO_PCI_INTX_IRQ_INDEX;
370381

371382
return 0;
@@ -400,25 +411,26 @@ static int vfio_intx_set_signal(struct vfio_pci_device *vdev, int fd)
400411
return PTR_ERR(trigger);
401412
}
402413

414+
vdev->ctx[0].trigger = trigger;
415+
403416
if (!vdev->pci_2_3)
404417
irqflags = 0;
405418

406419
ret = request_irq(pdev->irq, vfio_intx_handler,
407420
irqflags, vdev->ctx[0].name, vdev);
408421
if (ret) {
422+
vdev->ctx[0].trigger = NULL;
409423
kfree(vdev->ctx[0].name);
410424
eventfd_ctx_put(trigger);
411425
return ret;
412426
}
413427

414-
vdev->ctx[0].trigger = trigger;
415-
416428
/*
417429
* INTx disable will stick across the new irq setup,
418430
* disable_irq won't.
419431
*/
420432
spin_lock_irqsave(&vdev->irqlock, flags);
421-
if (!vdev->pci_2_3 && (vdev->ctx[0].masked || vdev->virq_disabled))
433+
if (!vdev->pci_2_3 && vdev->ctx[0].masked)
422434
disable_irq_nosync(pdev->irq);
423435
spin_unlock_irqrestore(&vdev->irqlock, flags);
424436

0 commit comments

Comments
 (0)