drm/amdkfd: Add module option for testing large-BAR functionality
authorFelix Kuehling <Felix.Kuehling@amd.com>
Thu, 15 Mar 2018 21:27:53 +0000 (17:27 -0400)
committerOded Gabbay <oded.gabbay@gmail.com>
Thu, 15 Mar 2018 21:27:53 +0000 (17:27 -0400)
Simulate large-BAR system by exporting only visible memory. This
limits the amount of available VRAM to the size of the BAR, but
enables CPU access to VRAM.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Acked-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
drivers/gpu/drm/amd/amdkfd/kfd_crat.c
drivers/gpu/drm/amd/amdkfd/kfd_module.c
drivers/gpu/drm/amd/amdkfd/kfd_priv.h

index ec0b2c0284ecb2e24d0de337fef4af9b1155afdb..cd679cf1fd308fa5e436c6691399351e0f2f0c71 100644 (file)
@@ -1151,6 +1151,11 @@ bool kfd_dev_is_large_bar(struct kfd_dev *dev)
 {
        struct kfd_local_mem_info mem_info;
 
+       if (debug_largebar) {
+               pr_debug("Simulate large-bar allocation on non large-bar machine\n");
+               return true;
+       }
+
        if (dev->device_info->needs_iommu_device)
                return false;
 
index d85112224f1d3b75173f1fc08db33d4d6b4b155b..4f126ef6139b7636a3edb67059ab727dd976a6ea 100644 (file)
@@ -1117,6 +1117,9 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,
        sub_type_hdr = (typeof(sub_type_hdr))((char *)sub_type_hdr +
                        sub_type_hdr->length);
 
+       if (debug_largebar)
+               local_mem_info.local_mem_size_private = 0;
+
        if (local_mem_info.local_mem_size_private == 0)
                ret = kfd_fill_gpu_memory_affinity(&avail_size,
                                kdev, HSA_MEM_HEAP_TYPE_FB_PUBLIC,
index 65574c6a10b3db709994188f9ba40a868dfd1d6a..b0acb06038836188653a60b86dce11dd403994f1 100644 (file)
@@ -71,6 +71,11 @@ module_param(send_sigterm, int, 0444);
 MODULE_PARM_DESC(send_sigterm,
        "Send sigterm to HSA process on unhandled exception (0 = disable, 1 = enable)");
 
+int debug_largebar;
+module_param(debug_largebar, int, 0444);
+MODULE_PARM_DESC(debug_largebar,
+       "Debug large-bar flag used to simulate large-bar capability on non-large bar machine (0 = disable, 1 = enable)");
+
 int ignore_crat;
 module_param(ignore_crat, int, 0444);
 MODULE_PARM_DESC(ignore_crat,
index aa938635658731841356b44ccbc5c7a52009dc54..db27f9f13696f5e9bea3d06cceb3dd576d6bfd49 100644 (file)
@@ -104,6 +104,12 @@ extern int cwsr_enable;
  */
 extern int send_sigterm;
 
+/*
+ * This kernel module is used to simulate large bar machine on non-large bar
+ * enabled machines.
+ */
+extern int debug_largebar;
+
 /*
  * Ignore CRAT table during KFD initialization, can be used to work around
  * broken CRAT tables on some AMD systems