]> Git Repo - J-linux.git/blobdiff - drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
Merge tag 'cxl-for-6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl
[J-linux.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_mes.c
index 1569bef030eac166ea6194427ca9c8489cc62796..5ca5c47ab54ed8ea6afca4c8d43561978c3f8199 100644 (file)
 #define AMDGPU_MES_MAX_NUM_OF_QUEUES_PER_PROCESS 1024
 #define AMDGPU_ONE_DOORBELL_SIZE 8
 
+signed long amdgpu_mes_fence_wait_polling(u64 *fence,
+                                         u64 wait_seq,
+                                         signed long timeout)
+{
+
+       while ((s64)(wait_seq - *fence) > 0 && timeout > 0) {
+               udelay(2);
+               timeout -= 2;
+       }
+       return timeout > 0 ? timeout : 0;
+}
+
 int amdgpu_mes_doorbell_process_slice(struct amdgpu_device *adev)
 {
        return roundup(AMDGPU_ONE_DOORBELL_SIZE *
@@ -40,7 +52,6 @@ int amdgpu_mes_doorbell_process_slice(struct amdgpu_device *adev)
 }
 
 static int amdgpu_mes_kernel_doorbell_get(struct amdgpu_device *adev,
-                                        struct amdgpu_mes_process *process,
                                         int ip_type, uint64_t *doorbell_index)
 {
        unsigned int offset, found;
@@ -65,7 +76,6 @@ static int amdgpu_mes_kernel_doorbell_get(struct amdgpu_device *adev,
 }
 
 static void amdgpu_mes_kernel_doorbell_free(struct amdgpu_device *adev,
-                                          struct amdgpu_mes_process *process,
                                           uint32_t doorbell_index)
 {
        unsigned int old, rel_index;
@@ -656,7 +666,7 @@ int amdgpu_mes_add_hw_queue(struct amdgpu_device *adev, int gang_id,
        *queue_id = queue->queue_id = r;
 
        /* allocate a doorbell index for the queue */
-       r = amdgpu_mes_kernel_doorbell_get(adev, gang->process,
+       r = amdgpu_mes_kernel_doorbell_get(adev,
                                          qprops->queue_type,
                                          &qprops->doorbell_off);
        if (r)
@@ -714,8 +724,7 @@ int amdgpu_mes_add_hw_queue(struct amdgpu_device *adev, int gang_id,
        return 0;
 
 clean_up_doorbell:
-       amdgpu_mes_kernel_doorbell_free(adev, gang->process,
-                                      qprops->doorbell_off);
+       amdgpu_mes_kernel_doorbell_free(adev, qprops->doorbell_off);
 clean_up_queue_id:
        spin_lock_irqsave(&adev->mes.queue_id_lock, flags);
        idr_remove(&adev->mes.queue_id_idr, queue->queue_id);
@@ -769,8 +778,7 @@ int amdgpu_mes_remove_hw_queue(struct amdgpu_device *adev, int queue_id)
                          queue_id);
 
        list_del(&queue->list);
-       amdgpu_mes_kernel_doorbell_free(adev, gang->process,
-                                      queue->doorbell_off);
+       amdgpu_mes_kernel_doorbell_free(adev, queue->doorbell_off);
        amdgpu_mes_unlock(&adev->mes);
 
        amdgpu_mes_queue_free_mqd(queue);
@@ -778,6 +786,28 @@ int amdgpu_mes_remove_hw_queue(struct amdgpu_device *adev, int queue_id)
        return 0;
 }
 
+int amdgpu_mes_map_legacy_queue(struct amdgpu_device *adev,
+                               struct amdgpu_ring *ring)
+{
+       struct mes_map_legacy_queue_input queue_input;
+       int r;
+
+       memset(&queue_input, 0, sizeof(queue_input));
+
+       queue_input.queue_type = ring->funcs->type;
+       queue_input.doorbell_offset = ring->doorbell_index;
+       queue_input.pipe_id = ring->pipe;
+       queue_input.queue_id = ring->queue;
+       queue_input.mqd_addr = amdgpu_bo_gpu_offset(ring->mqd_obj);
+       queue_input.wptr_addr = ring->wptr_gpu_addr;
+
+       r = adev->mes.funcs->map_legacy_queue(&adev->mes, &queue_input);
+       if (r)
+               DRM_ERROR("failed to map legacy queue\n");
+
+       return r;
+}
+
 int amdgpu_mes_unmap_legacy_queue(struct amdgpu_device *adev,
                                  struct amdgpu_ring *ring,
                                  enum amdgpu_unmap_queues_action action,
@@ -1475,7 +1505,7 @@ int amdgpu_mes_init_microcode(struct amdgpu_device *adev, int pipe)
        const struct mes_firmware_header_v1_0 *mes_hdr;
        struct amdgpu_firmware_info *info;
        char ucode_prefix[30];
-       char fw_name[40];
+       char fw_name[50];
        bool need_retry = false;
        int r;
 
This page took 0.029792 seconds and 4 git commands to generate.