Skip to content

Commit 374200b

Browse files
fxkamdogabbay
authored andcommitted
drm/amdkfd: Add module option for testing large-BAR functionality
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>
1 parent 0fc8011 commit 374200b

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,11 @@ bool kfd_dev_is_large_bar(struct kfd_dev *dev)
11511151
{
11521152
struct kfd_local_mem_info mem_info;
11531153

1154+
if (debug_largebar) {
1155+
pr_debug("Simulate large-bar allocation on non large-bar machine\n");
1156+
return true;
1157+
}
1158+
11541159
if (dev->device_info->needs_iommu_device)
11551160
return false;
11561161

drivers/gpu/drm/amd/amdkfd/kfd_crat.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,9 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,
11171117
sub_type_hdr = (typeof(sub_type_hdr))((char *)sub_type_hdr +
11181118
sub_type_hdr->length);
11191119

1120+
if (debug_largebar)
1121+
local_mem_info.local_mem_size_private = 0;
1122+
11201123
if (local_mem_info.local_mem_size_private == 0)
11211124
ret = kfd_fill_gpu_memory_affinity(&avail_size,
11221125
kdev, HSA_MEM_HEAP_TYPE_FB_PUBLIC,

drivers/gpu/drm/amd/amdkfd/kfd_module.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ module_param(send_sigterm, int, 0444);
7171
MODULE_PARM_DESC(send_sigterm,
7272
"Send sigterm to HSA process on unhandled exception (0 = disable, 1 = enable)");
7373

74+
int debug_largebar;
75+
module_param(debug_largebar, int, 0444);
76+
MODULE_PARM_DESC(debug_largebar,
77+
"Debug large-bar flag used to simulate large-bar capability on non-large bar machine (0 = disable, 1 = enable)");
78+
7479
int ignore_crat;
7580
module_param(ignore_crat, int, 0444);
7681
MODULE_PARM_DESC(ignore_crat,

drivers/gpu/drm/amd/amdkfd/kfd_priv.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ extern int cwsr_enable;
104104
*/
105105
extern int send_sigterm;
106106

107+
/*
108+
* This kernel module is used to simulate large bar machine on non-large bar
109+
* enabled machines.
110+
*/
111+
extern int debug_largebar;
112+
107113
/*
108114
* Ignore CRAT table during KFD initialization, can be used to work around
109115
* broken CRAT tables on some AMD systems

0 commit comments

Comments
 (0)