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.

vfio/pci: Share the core device pointer while invoking feature functions

There is no need to share the main device pointer (struct vfio_device *)
with all the feature functions as they only need the core device
pointer. Therefore, extract the core device pointer once in the
caller (vfio_pci_core_ioctl_feature) and share it instead.

Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Tested-by: Alex Mastro <amastro@fb.com>
Tested-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Acked-by: Ankit Agrawal <ankita@nvidia.com>
Link: https://lore.kernel.org/r/20251120-dmabuf-vfio-v9-8-d7f71607f371@nvidia.com
Signed-off-by: Alex Williamson <alex@shazbot.org>

authored by

Vivek Kasireddy and committed by
Alex Williamson
47d13c93 64a5dedc

+13 -17
+13 -17
drivers/vfio/pci/vfio_pci_core.c
··· 299 299 return 0; 300 300 } 301 301 302 - static int vfio_pci_core_pm_entry(struct vfio_device *device, u32 flags, 302 + static int vfio_pci_core_pm_entry(struct vfio_pci_core_device *vdev, u32 flags, 303 303 void __user *arg, size_t argsz) 304 304 { 305 - struct vfio_pci_core_device *vdev = 306 - container_of(device, struct vfio_pci_core_device, vdev); 307 305 int ret; 308 306 309 307 ret = vfio_check_feature(flags, argsz, VFIO_DEVICE_FEATURE_SET, 0); ··· 318 320 } 319 321 320 322 static int vfio_pci_core_pm_entry_with_wakeup( 321 - struct vfio_device *device, u32 flags, 323 + struct vfio_pci_core_device *vdev, u32 flags, 322 324 struct vfio_device_low_power_entry_with_wakeup __user *arg, 323 325 size_t argsz) 324 326 { 325 - struct vfio_pci_core_device *vdev = 326 - container_of(device, struct vfio_pci_core_device, vdev); 327 327 struct vfio_device_low_power_entry_with_wakeup entry; 328 328 struct eventfd_ctx *efdctx; 329 329 int ret; ··· 372 376 up_write(&vdev->memory_lock); 373 377 } 374 378 375 - static int vfio_pci_core_pm_exit(struct vfio_device *device, u32 flags, 379 + static int vfio_pci_core_pm_exit(struct vfio_pci_core_device *vdev, u32 flags, 376 380 void __user *arg, size_t argsz) 377 381 { 378 - struct vfio_pci_core_device *vdev = 379 - container_of(device, struct vfio_pci_core_device, vdev); 380 382 int ret; 381 383 382 384 ret = vfio_check_feature(flags, argsz, VFIO_DEVICE_FEATURE_SET, 0); ··· 1467 1473 } 1468 1474 EXPORT_SYMBOL_GPL(vfio_pci_core_ioctl); 1469 1475 1470 - static int vfio_pci_core_feature_token(struct vfio_device *device, u32 flags, 1471 - uuid_t __user *arg, size_t argsz) 1476 + static int vfio_pci_core_feature_token(struct vfio_pci_core_device *vdev, 1477 + u32 flags, uuid_t __user *arg, 1478 + size_t argsz) 1472 1479 { 1473 - struct vfio_pci_core_device *vdev = 1474 - container_of(device, struct vfio_pci_core_device, vdev); 1475 1480 uuid_t uuid; 1476 1481 int ret; 1477 1482 ··· 1497 1504 int vfio_pci_core_ioctl_feature(struct vfio_device *device, u32 flags, 1498 1505 void __user *arg, size_t argsz) 1499 1506 { 1507 + struct vfio_pci_core_device *vdev = 1508 + container_of(device, struct vfio_pci_core_device, vdev); 1509 + 1500 1510 switch (flags & VFIO_DEVICE_FEATURE_MASK) { 1501 1511 case VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY: 1502 - return vfio_pci_core_pm_entry(device, flags, arg, argsz); 1512 + return vfio_pci_core_pm_entry(vdev, flags, arg, argsz); 1503 1513 case VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP: 1504 - return vfio_pci_core_pm_entry_with_wakeup(device, flags, 1514 + return vfio_pci_core_pm_entry_with_wakeup(vdev, flags, 1505 1515 arg, argsz); 1506 1516 case VFIO_DEVICE_FEATURE_LOW_POWER_EXIT: 1507 - return vfio_pci_core_pm_exit(device, flags, arg, argsz); 1517 + return vfio_pci_core_pm_exit(vdev, flags, arg, argsz); 1508 1518 case VFIO_DEVICE_FEATURE_PCI_VF_TOKEN: 1509 - return vfio_pci_core_feature_token(device, flags, arg, argsz); 1519 + return vfio_pci_core_feature_token(vdev, flags, arg, argsz); 1510 1520 default: 1511 1521 return -ENOTTY; 1512 1522 }