drm/amdkfd: Add more comments on GFX9 user CP queue MQD workaround
authorYong Zhao <Yong.Zhao@amd.com>
Wed, 4 Mar 2020 20:29:35 +0000 (15:29 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 6 Mar 2020 19:34:30 +0000 (14:34 -0500)
Because too many things are involved in this workaround, we need more
comments to avoid pitfalls.

Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Philip Yang <philip.yang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c

index 436b7f518979185392b264c374b9f0c950f973e1..48cda3073b70448dd96851d2a55fa459c65e447d 100644 (file)
@@ -87,9 +87,21 @@ static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd,
        int retval;
        struct kfd_mem_obj *mqd_mem_obj = NULL;
 
-       /* From V9,  for CWSR, the control stack is located on the next page
-        * boundary after the mqd, we will use the gtt allocation function
-        * instead of sub-allocation function.
+       /* For V9 only, due to a HW bug, the control stack of a user mode
+        * compute queue needs to be allocated just behind the page boundary
+        * of its regular MQD buffer. So we allocate an enlarged MQD buffer:
+        * the first page of the buffer serves as the regular MQD buffer
+        * purpose and the remaining is for control stack. Although the two
+        * parts are in the same buffer object, they need different memory
+        * types: MQD part needs UC (uncached) as usual, while control stack
+        * needs NC (non coherent), which is different from the UC type which
+        * is used when control stack is allocated in user space.
+        *
+        * Because of all those, we use the gtt allocation function instead
+        * of sub-allocation function for this enlarged MQD buffer. Moreover,
+        * in order to achieve two memory types in a single buffer object, we
+        * pass a special bo flag AMDGPU_GEM_CREATE_CP_MQD_GFX9 to instruct
+        * amdgpu memory functions to do so.
         */
        if (kfd->cwsr_enabled && (q->type == KFD_QUEUE_TYPE_COMPUTE)) {
                mqd_mem_obj = kzalloc(sizeof(struct kfd_mem_obj), GFP_KERNEL);