drm/amdkfd: fixes for HMM mem allocation
authorjsg <jsg@openbsd.org>
Mon, 29 Jan 2024 01:56:26 +0000 (01:56 +0000)
committerjsg <jsg@openbsd.org>
Mon, 29 Jan 2024 01:56:26 +0000 (01:56 +0000)
From Dafna Hirschfeld
1515db19c4a374f75e6bf5430f9cb9b7e3c2fd0d in linux-6.6.y/6.6.14
02eed83abc1395a1207591aafad9bcfc5cb1abcb in mainline linux

sys/dev/pci/drm/amd/amdkfd/kfd_migrate.c

index 7d82c7d..6593136 100644 (file)
@@ -1021,7 +1021,7 @@ int kgd2kfd_init_zone_device(struct amdgpu_device *adev)
        } else {
                res = devm_request_free_mem_region(adev->dev, &iomem_resource, size);
                if (IS_ERR(res))
-                       return -ENOMEM;
+                       return PTR_ERR(res);
                pgmap->range.start = res->start;
                pgmap->range.end = res->end;
                pgmap->type = MEMORY_DEVICE_PRIVATE;
@@ -1037,10 +1037,10 @@ int kgd2kfd_init_zone_device(struct amdgpu_device *adev)
        r = devm_memremap_pages(adev->dev, pgmap);
        if (IS_ERR(r)) {
                pr_err("failed to register HMM device memory\n");
-               /* Disable SVM support capability */
-               pgmap->type = 0;
                if (pgmap->type == MEMORY_DEVICE_PRIVATE)
                        devm_release_mem_region(adev->dev, res->start, resource_size(res));
+               /* Disable SVM support capability */
+               pgmap->type = 0;
                return PTR_ERR(r);
        }