From 8cb89b692649621fdc18fb54c5f68212e7661a42 Mon Sep 17 00:00:00 2001 From: Felix Kuehling Date: Tue, 15 Nov 2016 14:37:31 -0500 Subject: [PATCH] Use KFD_IOC_ALLOC_MEM_FLAGS_COHERENT for fine-grained memory Use KFD_IOC_ALLOC_MEM_FLAGS_COHERENT when allocating fine-grained memory and doorbell BOs so that they will be mapped with MTYPE_UC on GFX9 hardware. Change-Id: I51adf45b13105f479e6bcdaf54955b467920ee9a Signed-off-by: Felix Kuehling Reviewed-by: Shaoyun Liu --- src/fmm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/fmm.c b/src/fmm.c index 3dc51ab6e8..067b9c28c1 100644 --- a/src/fmm.c +++ b/src/fmm.c @@ -1023,7 +1023,8 @@ void *fmm_allocate_doorbell(uint32_t gpu_id, uint64_t MemorySizeInBytes, /* Use fine-grained aperture */ aperture = &svm.dgpu_alt_aperture; - ioc_flags = KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL; + ioc_flags = KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL | + KFD_IOC_ALLOC_MEM_FLAGS_COHERENT; mem = __fmm_allocate_device(gpu_id, MemorySizeInBytes, aperture, 0, NULL, @@ -1109,10 +1110,12 @@ static void* fmm_allocate_host_gpu(uint32_t node_id, uint64_t MemorySizeInBytes, size = MemorySizeInBytes; ioc_flags = 0; - if (flags.ui32.CoarseGrain) + if (flags.ui32.CoarseGrain) { aperture = &svm.dgpu_aperture; - else + } else { aperture = &svm.dgpu_alt_aperture; /* coherent */ + ioc_flags |= KFD_IOC_ALLOC_MEM_FLAGS_COHERENT; + } if (flags.ui32.AQLQueueMemory) { size = MemorySizeInBytes * 2; ioc_flags |= KFD_IOC_ALLOC_MEM_FLAGS_DGPU_AQL_QUEUE_MEM;