]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
drm/amdgpu/sdma: allocate CSA per sdma ring
authorJack Xiao <Jack.Xiao@amd.com>
Mon, 7 Jan 2019 07:28:01 +0000 (15:28 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 21 Jun 2019 23:57:40 +0000 (18:57 -0500)
Allocate CSA for the given sdma ring.

Acked-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Jack Xiao <Jack.Xiao@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h

index 115bb0c99b0ff603ac0124280bf48e1a89f10d8e..8ad21865c9f02deda659e490e05df333f7e33ad3 100644 (file)
 #include "amdgpu.h"
 #include "amdgpu_sdma.h"
 
+#define AMDGPU_CSA_SDMA_SIZE 64
+/* SDMA CSA reside in the 3rd page of CSA */
+#define AMDGPU_CSA_SDMA_OFFSET (4096 * 2)
+
 /*
  * GPU SDMA IP block helpers function.
  */
@@ -56,3 +60,26 @@ int amdgpu_sdma_get_index_from_ring(struct amdgpu_ring *ring, uint32_t *index)
 
        return -EINVAL;
 }
+
+uint64_t amdgpu_sdma_get_csa_mc_addr(struct amdgpu_ring *ring,
+                                    unsigned vmid)
+{
+       struct amdgpu_device *adev = ring->adev;
+       uint64_t csa_mc_addr;
+       uint32_t index = 0;
+       int r;
+
+       if (vmid == 0 || !amdgpu_mcbp)
+               return 0;
+
+       r = amdgpu_sdma_get_index_from_ring(ring, &index);
+
+       if (r || index > 31)
+               csa_mc_addr = 0;
+       else
+               csa_mc_addr = amdgpu_csa_vaddr(adev) +
+                       AMDGPU_CSA_SDMA_OFFSET +
+                       index * AMDGPU_CSA_SDMA_SIZE;
+
+       return csa_mc_addr;
+}
index 1ba9ba3b54f7f7d2fe08e5c75fda44d3ac9ff454..35dd152f9d5c15c42942874156f98d35cba63f58 100644 (file)
@@ -97,5 +97,5 @@ struct amdgpu_buffer_funcs {
 struct amdgpu_sdma_instance *
 amdgpu_sdma_get_instance_from_ring(struct amdgpu_ring *ring);
 int amdgpu_sdma_get_index_from_ring(struct amdgpu_ring *ring, uint32_t *index);
-
+uint64_t amdgpu_sdma_get_csa_mc_addr(struct amdgpu_ring *ring, unsigned vmid);
 #endif