Skip to content

Commit df3cae8

Browse files
nvmochsnirmoy
authored andcommitted
NVIDIA: SAUCE: vfio/nvgrace-gpu: Avoid resmem pfn unregistration
On platforms without the mig HW bug (e.g. Grace-Blackwell) there is not a requirement to create the resmem region. Accordingly, this region is not configured on these platforms, which leads to the following print when the device is closed: resource: Trying to free nonexistent resource <0x0000000000000000-0x000000000000ffff> Avoid calling unregister_pfn_address_space for resmem when the region is not being used. Fixes: 2d21b7b ("vfio/nvgrace-gpu: register device memory for poison handling") Signed-off-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Acked-by: Nirmoy Das <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit bd0187d https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]>
1 parent ad84f5d commit df3cae8

File tree

1 file changed

+5
-3
lines changed
  • drivers/vfio/pci/nvgrace-gpu

1 file changed

+5
-3
lines changed

drivers/vfio/pci/nvgrace-gpu/main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ static void nvgrace_gpu_close_device(struct vfio_device *core_vdev)
239239
mutex_destroy(&nvdev->remap_lock);
240240

241241
#ifdef CONFIG_MEMORY_FAILURE
242-
unregister_pfn_address_space(&nvdev->resmem.pfn_address_space);
242+
if (nvdev->resmem.memlength)
243+
unregister_pfn_address_space(&nvdev->resmem.pfn_address_space);
243244
unregister_pfn_address_space(&nvdev->usemem.pfn_address_space);
244245
#endif
245246
vfio_pci_core_close_device(core_vdev);
@@ -320,9 +321,10 @@ static int nvgrace_gpu_mmap(struct vfio_device *core_vdev,
320321
#ifdef CONFIG_MEMORY_FAILURE
321322
vma->vm_ops = &nvgrace_gpu_vfio_pci_mmap_ops;
322323

323-
if (index == VFIO_PCI_BAR2_REGION_INDEX)
324+
if (index == VFIO_PCI_BAR2_REGION_INDEX) {
325+
WARN_ON_ONCE(!nvdev->has_mig_hw_bug);
324326
ret = nvgrace_gpu_vfio_pci_register_pfn_range(&nvdev->resmem, vma);
325-
else
327+
} else
326328
ret = nvgrace_gpu_vfio_pci_register_pfn_range(&nvdev->usemem, vma);
327329
#endif
328330

0 commit comments

Comments
 (0)