Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'vfio-v6.7-rc4' of https://github.com/awilliam/linux-vfio

Pull vfio fixes from Alex Williamson:

- Fix the lifecycle of a mutex in the pds variant driver such that a
reset prior to opening the device won't find it uninitialized.
Implement the release path to symmetrically destroy the mutex. Also
switch a different lock from spinlock to mutex as the code path has
the potential to sleep and doesn't need the spinlock context
otherwise (Brett Creeley)

- Fix an issue detected via randconfig where KVM tries to symbol_get an
undeclared function. The symbol is temporarily declared
unconditionally here, which resolves the problem and avoids churn
relative to a series pending for the next merge window which resolves
some of this symbol ugliness, but also fixes Kconfig dependencies
(Sean Christopherson)

* tag 'vfio-v6.7-rc4' of https://github.com/awilliam/linux-vfio:
vfio: Drop vfio_file_iommu_group() stub to fudge around a KVM wart
vfio/pds: Fix possible sleep while in atomic context
vfio/pds: Fix mutex lock->magic != lock warning

+26 -18
+2 -2
drivers/vfio/pci/pds/pci_drv.c
··· 55 55 * VFIO_DEVICE_STATE_RUNNING. 56 56 */ 57 57 if (deferred_reset_needed) { 58 - spin_lock(&pds_vfio->reset_lock); 58 + mutex_lock(&pds_vfio->reset_mutex); 59 59 pds_vfio->deferred_reset = true; 60 60 pds_vfio->deferred_reset_state = VFIO_DEVICE_STATE_ERROR; 61 - spin_unlock(&pds_vfio->reset_lock); 61 + mutex_unlock(&pds_vfio->reset_mutex); 62 62 } 63 63 } 64 64
+21 -9
drivers/vfio/pci/pds/vfio_dev.c
··· 29 29 void pds_vfio_state_mutex_unlock(struct pds_vfio_pci_device *pds_vfio) 30 30 { 31 31 again: 32 - spin_lock(&pds_vfio->reset_lock); 32 + mutex_lock(&pds_vfio->reset_mutex); 33 33 if (pds_vfio->deferred_reset) { 34 34 pds_vfio->deferred_reset = false; 35 35 if (pds_vfio->state == VFIO_DEVICE_STATE_ERROR) { ··· 39 39 } 40 40 pds_vfio->state = pds_vfio->deferred_reset_state; 41 41 pds_vfio->deferred_reset_state = VFIO_DEVICE_STATE_RUNNING; 42 - spin_unlock(&pds_vfio->reset_lock); 42 + mutex_unlock(&pds_vfio->reset_mutex); 43 43 goto again; 44 44 } 45 45 mutex_unlock(&pds_vfio->state_mutex); 46 - spin_unlock(&pds_vfio->reset_lock); 46 + mutex_unlock(&pds_vfio->reset_mutex); 47 47 } 48 48 49 49 void pds_vfio_reset(struct pds_vfio_pci_device *pds_vfio) 50 50 { 51 - spin_lock(&pds_vfio->reset_lock); 51 + mutex_lock(&pds_vfio->reset_mutex); 52 52 pds_vfio->deferred_reset = true; 53 53 pds_vfio->deferred_reset_state = VFIO_DEVICE_STATE_RUNNING; 54 54 if (!mutex_trylock(&pds_vfio->state_mutex)) { 55 - spin_unlock(&pds_vfio->reset_lock); 55 + mutex_unlock(&pds_vfio->reset_mutex); 56 56 return; 57 57 } 58 - spin_unlock(&pds_vfio->reset_lock); 58 + mutex_unlock(&pds_vfio->reset_mutex); 59 59 pds_vfio_state_mutex_unlock(pds_vfio); 60 60 } 61 61 ··· 155 155 156 156 pds_vfio->vf_id = vf_id; 157 157 158 + mutex_init(&pds_vfio->state_mutex); 159 + mutex_init(&pds_vfio->reset_mutex); 160 + 158 161 vdev->migration_flags = VFIO_MIGRATION_STOP_COPY | VFIO_MIGRATION_P2P; 159 162 vdev->mig_ops = &pds_vfio_lm_ops; 160 163 vdev->log_ops = &pds_vfio_log_ops; ··· 171 168 return 0; 172 169 } 173 170 171 + static void pds_vfio_release_device(struct vfio_device *vdev) 172 + { 173 + struct pds_vfio_pci_device *pds_vfio = 174 + container_of(vdev, struct pds_vfio_pci_device, 175 + vfio_coredev.vdev); 176 + 177 + mutex_destroy(&pds_vfio->state_mutex); 178 + mutex_destroy(&pds_vfio->reset_mutex); 179 + vfio_pci_core_release_dev(vdev); 180 + } 181 + 174 182 static int pds_vfio_open_device(struct vfio_device *vdev) 175 183 { 176 184 struct pds_vfio_pci_device *pds_vfio = ··· 193 179 if (err) 194 180 return err; 195 181 196 - mutex_init(&pds_vfio->state_mutex); 197 182 pds_vfio->state = VFIO_DEVICE_STATE_RUNNING; 198 183 pds_vfio->deferred_reset_state = VFIO_DEVICE_STATE_RUNNING; 199 184 ··· 212 199 pds_vfio_put_save_file(pds_vfio); 213 200 pds_vfio_dirty_disable(pds_vfio, true); 214 201 mutex_unlock(&pds_vfio->state_mutex); 215 - mutex_destroy(&pds_vfio->state_mutex); 216 202 vfio_pci_core_close_device(vdev); 217 203 } 218 204 219 205 static const struct vfio_device_ops pds_vfio_ops = { 220 206 .name = "pds-vfio", 221 207 .init = pds_vfio_init_device, 222 - .release = vfio_pci_core_release_dev, 208 + .release = pds_vfio_release_device, 223 209 .open_device = pds_vfio_open_device, 224 210 .close_device = pds_vfio_close_device, 225 211 .ioctl = vfio_pci_core_ioctl,
+1 -1
drivers/vfio/pci/pds/vfio_dev.h
··· 18 18 struct pds_vfio_dirty dirty; 19 19 struct mutex state_mutex; /* protect migration state */ 20 20 enum vfio_device_mig_state state; 21 - spinlock_t reset_lock; /* protect reset_done flow */ 21 + struct mutex reset_mutex; /* protect reset_done flow */ 22 22 u8 deferred_reset; 23 23 enum vfio_device_mig_state deferred_reset_state; 24 24 struct notifier_block nb;
+2 -6
include/linux/vfio.h
··· 289 289 /* 290 290 * External user API 291 291 */ 292 - #if IS_ENABLED(CONFIG_VFIO_GROUP) 293 292 struct iommu_group *vfio_file_iommu_group(struct file *file); 293 + 294 + #if IS_ENABLED(CONFIG_VFIO_GROUP) 294 295 bool vfio_file_is_group(struct file *file); 295 296 bool vfio_file_has_dev(struct file *file, struct vfio_device *device); 296 297 #else 297 - static inline struct iommu_group *vfio_file_iommu_group(struct file *file) 298 - { 299 - return NULL; 300 - } 301 - 302 298 static inline bool vfio_file_is_group(struct file *file) 303 299 { 304 300 return false;