Skip to content

Commit 4138f02

Browse files
committed
Merge tag 'vfio-v6.9-rc1' of https://github.com/awilliam/linux-vfio
Pull VFIO updates from Alex Williamson: - Add warning in unlikely case that device is not captured with driver_override (Kunwu Chan) - Error handling improvements in mlx5-vfio-pci to detect firmware tracking object error states, logging of firmware error syndrom, and releasing of firmware resources in aborted migration sequence (Yishai Hadas) - Correct an un-alphabetized VFIO MAINTAINERS entry (Alex Williamson) - Make the mdev_bus_type const and also make the class struct const for a couple of the vfio-mdev sample drivers (Ricardo B. Marliere) - Addition of a new vfio-pci variant driver for the GPU of NVIDIA's Grace-Hopper superchip. During initialization of the chip-to-chip interconnect in this hardware module, the PCI BARs of the device become unused in favor of a faster, coherent mechanism for exposing device memory. This driver primarily changes the VFIO representation of the device to masquerade this coherent aperture to replace the physical PCI BARs for userspace drivers. This also incorporates use of a new vma flag allowing KVM to use write combining attributes for uncached device memory (Ankit Agrawal) - Reset fixes and cleanups for the pds-vfio-pci driver. Save and restore files were previously leaked if the device didn't pass through an error state, this is resolved and later re-fixed to prevent access to the now freed files. Reset handling is also refactored to remove the complicated deferred reset mechanism (Brett Creeley) - Remove some references to pl330 in the vfio-platform amba driver (Geert Uytterhoeven) - Remove twice redundant and ugly code to unpin incidental pins of the zero-page (Alex Williamson) - Deferred reset logic is also removed from the hisi-acc-vfio-pci driver as a simplification (Shameer Kolothum) - Enforce that mlx5-vfio-pci devices must support PRE_COPY and remove resulting unnecessary code. There is no device firmware that has been available publicly without this support (Yishai Hadas) - Switch over to using the .remove_new callback for vfio-platform in support of the broader transition for a void remove function (Uwe Kleine-König) - Resolve multiple issues in interrupt code for VFIO bus drivers that allow calling eventfd_signal() on a NULL context. This also remove a potential race in INTx setup on certain hardware for vfio-pci, races with various mechanisms to mask INTx, and leaked virqfds in vfio-platform (Alex Williamson) * tag 'vfio-v6.9-rc1' of https://github.com/awilliam/linux-vfio: (29 commits) vfio/fsl-mc: Block calling interrupt handler without trigger vfio/platform: Create persistent IRQ handlers vfio/platform: Disable virqfds on cleanup vfio/pci: Create persistent INTx handler vfio: Introduce interface to flush virqfd inject workqueue vfio/pci: Lock external INTx masking ops vfio/pci: Disable auto-enable of exclusive INTx IRQ vfio/pds: Refactor/simplify reset logic vfio/pds: Make sure migration file isn't accessed after reset vfio/platform: Convert to platform remove callback returning void vfio/mlx5: Enforce PRE_COPY support vfio/mbochs: make mbochs_class constant vfio/mdpy: make mdpy_class constant hisi_acc_vfio_pci: Remove the deferred_reset logic Revert "vfio/type1: Unpin zero pages" vfio/nvgrace-gpu: Convey kvm to map device memory region as noncached vfio: amba: Rename pl330_ids[] to vfio_amba_ids[] vfio/pds: Always clear the save/restore FDs on reset vfio/nvgrace-gpu: Add vfio pci variant module for grace hopper vfio/pci: rename and export range_intersect_range ...
2 parents 4f712ee + 7447d91 commit 4138f02

35 files changed

+1459
-452
lines changed

MAINTAINERS

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23164,12 +23164,11 @@ L: kvm@vger.kernel.org
2316423164
S: Maintained
2316523165
F: drivers/vfio/pci/mlx5/
2316623166

23167-
VFIO VIRTIO PCI DRIVER
23168-
M: Yishai Hadas <yishaih@nvidia.com>
23167+
VFIO NVIDIA GRACE GPU DRIVER
23168+
M: Ankit Agrawal <ankita@nvidia.com>
2316923169
L: kvm@vger.kernel.org
23170-
L: virtualization@lists.linux.dev
23171-
S: Maintained
23172-
F: drivers/vfio/pci/virtio
23170+
S: Supported
23171+
F: drivers/vfio/pci/nvgrace-gpu/
2317323172

2317423173
VFIO PCI DEVICE SPECIFIC DRIVERS
2317523174
R: Jason Gunthorpe <jgg@nvidia.com>
@@ -23194,6 +23193,13 @@ L: kvm@vger.kernel.org
2319423193
S: Maintained
2319523194
F: drivers/vfio/platform/
2319623195

23196+
VFIO VIRTIO PCI DRIVER
23197+
M: Yishai Hadas <yishaih@nvidia.com>
23198+
L: kvm@vger.kernel.org
23199+
L: virtualization@lists.linux.dev
23200+
S: Maintained
23201+
F: drivers/vfio/pci/virtio
23202+
2319723203
VGA_SWITCHEROO
2319823204
R: Lukas Wunner <lukas@wunner.de>
2319923205
S: Maintained

drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,14 @@ static int vfio_fsl_mc_set_irq_trigger(struct vfio_fsl_mc_device *vdev,
141141
irq = &vdev->mc_irqs[index];
142142

143143
if (flags & VFIO_IRQ_SET_DATA_NONE) {
144-
vfio_fsl_mc_irq_handler(hwirq, irq);
144+
if (irq->trigger)
145+
eventfd_signal(irq->trigger);
145146

146147
} else if (flags & VFIO_IRQ_SET_DATA_BOOL) {
147148
u8 trigger = *(u8 *)data;
148149

149-
if (trigger)
150-
vfio_fsl_mc_irq_handler(hwirq, irq);
150+
if (trigger && irq->trigger)
151+
eventfd_signal(irq->trigger);
151152
}
152153

153154
return 0;

drivers/vfio/mdev/mdev_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static int mdev_match(struct device *dev, struct device_driver *drv)
4040
return 0;
4141
}
4242

43-
struct bus_type mdev_bus_type = {
43+
const struct bus_type mdev_bus_type = {
4444
.name = "mdev",
4545
.probe = mdev_probe,
4646
.remove = mdev_remove,

drivers/vfio/mdev/mdev_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
int mdev_bus_register(void);
1414
void mdev_bus_unregister(void);
1515

16-
extern struct bus_type mdev_bus_type;
16+
extern const struct bus_type mdev_bus_type;
1717
extern const struct attribute_group *mdev_device_groups[];
1818

1919
#define to_mdev_type_attr(_attr) \

drivers/vfio/pci/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,6 @@ source "drivers/vfio/pci/pds/Kconfig"
6767

6868
source "drivers/vfio/pci/virtio/Kconfig"
6969

70+
source "drivers/vfio/pci/nvgrace-gpu/Kconfig"
71+
7072
endmenu

drivers/vfio/pci/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ obj-$(CONFIG_HISI_ACC_VFIO_PCI) += hisilicon/
1515
obj-$(CONFIG_PDS_VFIO_PCI) += pds/
1616

1717
obj-$(CONFIG_VIRTIO_VFIO_PCI) += virtio/
18+
19+
obj-$(CONFIG_NVGRACE_GPU_VFIO_PCI) += nvgrace-gpu/

drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -630,25 +630,11 @@ static void hisi_acc_vf_disable_fds(struct hisi_acc_vf_core_device *hisi_acc_vde
630630
}
631631
}
632632

633-
/*
634-
* This function is called in all state_mutex unlock cases to
635-
* handle a 'deferred_reset' if exists.
636-
*/
637-
static void
638-
hisi_acc_vf_state_mutex_unlock(struct hisi_acc_vf_core_device *hisi_acc_vdev)
633+
static void hisi_acc_vf_reset(struct hisi_acc_vf_core_device *hisi_acc_vdev)
639634
{
640-
again:
641-
spin_lock(&hisi_acc_vdev->reset_lock);
642-
if (hisi_acc_vdev->deferred_reset) {
643-
hisi_acc_vdev->deferred_reset = false;
644-
spin_unlock(&hisi_acc_vdev->reset_lock);
645-
hisi_acc_vdev->vf_qm_state = QM_NOT_READY;
646-
hisi_acc_vdev->mig_state = VFIO_DEVICE_STATE_RUNNING;
647-
hisi_acc_vf_disable_fds(hisi_acc_vdev);
648-
goto again;
649-
}
650-
mutex_unlock(&hisi_acc_vdev->state_mutex);
651-
spin_unlock(&hisi_acc_vdev->reset_lock);
635+
hisi_acc_vdev->vf_qm_state = QM_NOT_READY;
636+
hisi_acc_vdev->mig_state = VFIO_DEVICE_STATE_RUNNING;
637+
hisi_acc_vf_disable_fds(hisi_acc_vdev);
652638
}
653639

654640
static void hisi_acc_vf_start_device(struct hisi_acc_vf_core_device *hisi_acc_vdev)
@@ -804,8 +790,10 @@ static long hisi_acc_vf_precopy_ioctl(struct file *filp,
804790

805791
info.dirty_bytes = 0;
806792
info.initial_bytes = migf->total_length - *pos;
793+
mutex_unlock(&migf->lock);
794+
mutex_unlock(&hisi_acc_vdev->state_mutex);
807795

808-
ret = copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0;
796+
return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0;
809797
out:
810798
mutex_unlock(&migf->lock);
811799
mutex_unlock(&hisi_acc_vdev->state_mutex);
@@ -1071,7 +1059,7 @@ hisi_acc_vfio_pci_set_device_state(struct vfio_device *vdev,
10711059
break;
10721060
}
10731061
}
1074-
hisi_acc_vf_state_mutex_unlock(hisi_acc_vdev);
1062+
mutex_unlock(&hisi_acc_vdev->state_mutex);
10751063
return res;
10761064
}
10771065

@@ -1092,7 +1080,7 @@ hisi_acc_vfio_pci_get_device_state(struct vfio_device *vdev,
10921080

10931081
mutex_lock(&hisi_acc_vdev->state_mutex);
10941082
*curr_state = hisi_acc_vdev->mig_state;
1095-
hisi_acc_vf_state_mutex_unlock(hisi_acc_vdev);
1083+
mutex_unlock(&hisi_acc_vdev->state_mutex);
10961084
return 0;
10971085
}
10981086

@@ -1104,21 +1092,9 @@ static void hisi_acc_vf_pci_aer_reset_done(struct pci_dev *pdev)
11041092
VFIO_MIGRATION_STOP_COPY)
11051093
return;
11061094

1107-
/*
1108-
* As the higher VFIO layers are holding locks across reset and using
1109-
* those same locks with the mm_lock we need to prevent ABBA deadlock
1110-
* with the state_mutex and mm_lock.
1111-
* In case the state_mutex was taken already we defer the cleanup work
1112-
* to the unlock flow of the other running context.
1113-
*/
1114-
spin_lock(&hisi_acc_vdev->reset_lock);
1115-
hisi_acc_vdev->deferred_reset = true;
1116-
if (!mutex_trylock(&hisi_acc_vdev->state_mutex)) {
1117-
spin_unlock(&hisi_acc_vdev->reset_lock);
1118-
return;
1119-
}
1120-
spin_unlock(&hisi_acc_vdev->reset_lock);
1121-
hisi_acc_vf_state_mutex_unlock(hisi_acc_vdev);
1095+
mutex_lock(&hisi_acc_vdev->state_mutex);
1096+
hisi_acc_vf_reset(hisi_acc_vdev);
1097+
mutex_unlock(&hisi_acc_vdev->state_mutex);
11221098
}
11231099

11241100
static int hisi_acc_vf_qm_init(struct hisi_acc_vf_core_device *hisi_acc_vdev)

drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ struct hisi_acc_vf_migration_file {
9898

9999
struct hisi_acc_vf_core_device {
100100
struct vfio_pci_core_device core_device;
101-
u8 match_done:1;
102-
u8 deferred_reset:1;
101+
u8 match_done;
102+
103103
/* For migration state */
104104
struct mutex state_mutex;
105105
enum vfio_device_mig_state mig_state;
@@ -109,8 +109,6 @@ struct hisi_acc_vf_core_device {
109109
struct hisi_qm vf_qm;
110110
u32 vf_qm_state;
111111
int vf_id;
112-
/* For reset handler */
113-
spinlock_t reset_lock;
114112
struct hisi_acc_vf_migration_file *resuming_migf;
115113
struct hisi_acc_vf_migration_file *saving_migf;
116114
};

0 commit comments

Comments
 (0)