]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
drm/amdgpu: Use asic specific doorbell index instead of macro definition
authorOak Zeng <ozeng@amd.com>
Mon, 19 Nov 2018 21:20:07 +0000 (15:20 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 28 Nov 2018 20:55:33 +0000 (15:55 -0500)
ASIC specific doorbell layout is used instead of enum definition

Signed-off-by: Oak Zeng <ozeng@amd.com>
Suggested-by: Felix Kuehling <Felix.Kuehling@amd.com>
Suggested-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
12 files changed:
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
drivers/gpu/drm/amd/amdgpu/tonga_ih.c
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
drivers/gpu/drm/amd/amdgpu/vega10_ih.c

index a9c7597963e6c39741b76d6bb384cfe65df3caef..b12dd4fa37a1f314705bef9d620378bf4f29667b 100644 (file)
@@ -181,25 +181,14 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
                         * process in case of 64-bit doorbells so we
                         * can use each doorbell assignment twice.
                         */
-                       if (adev->asic_type == CHIP_VEGA10) {
-                               gpu_resources.sdma_doorbell[0][i] =
-                                       AMDGPU_VEGA10_DOORBELL64_sDMA_ENGINE0 + (i >> 1);
-                               gpu_resources.sdma_doorbell[0][i+1] =
-                                       AMDGPU_VEGA10_DOORBELL64_sDMA_ENGINE0 + 0x200 + (i >> 1);
-                               gpu_resources.sdma_doorbell[1][i] =
-                                       AMDGPU_VEGA10_DOORBELL64_sDMA_ENGINE1 + (i >> 1);
-                               gpu_resources.sdma_doorbell[1][i+1] =
-                                       AMDGPU_VEGA10_DOORBELL64_sDMA_ENGINE1 + 0x200 + (i >> 1);
-                       } else {
-                               gpu_resources.sdma_doorbell[0][i] =
-                                       AMDGPU_DOORBELL64_sDMA_ENGINE0 + (i >> 1);
-                               gpu_resources.sdma_doorbell[0][i+1] =
-                                       AMDGPU_DOORBELL64_sDMA_ENGINE0 + 0x200 + (i >> 1);
-                               gpu_resources.sdma_doorbell[1][i] =
-                                       AMDGPU_DOORBELL64_sDMA_ENGINE1 + (i >> 1);
-                               gpu_resources.sdma_doorbell[1][i+1] =
-                                       AMDGPU_DOORBELL64_sDMA_ENGINE1 + 0x200 + (i >> 1);
-                       }
+                       gpu_resources.sdma_doorbell[0][i] =
+                               adev->doorbell_index.sdma_engine0 + (i >> 1);
+                       gpu_resources.sdma_doorbell[0][i+1] =
+                               adev->doorbell_index.sdma_engine0 + 0x200 + (i >> 1);
+                       gpu_resources.sdma_doorbell[1][i] =
+                               adev->doorbell_index.sdma_engine1 + (i >> 1);
+                       gpu_resources.sdma_doorbell[1][i+1] =
+                               adev->doorbell_index.sdma_engine1 + 0x200 + (i >> 1);
                }
                /* Doorbells 0x0e0-0ff and 0x2e0-2ff are reserved for
                 * SDMA, IH and VCN. So don't use them for the CP.
index a8b1c9c0432623b7c7a7678003c7a9c4ed0102a5..fdbc2c229bc608e024c3fe2406d17142a5c5f10f 100644 (file)
@@ -532,7 +532,7 @@ static int amdgpu_device_doorbell_init(struct amdgpu_device *adev)
        adev->doorbell.size = pci_resource_len(adev->pdev, 2);
 
        adev->doorbell.num_doorbells = min_t(u32, adev->doorbell.size / sizeof(u32),
-                                            AMDGPU_DOORBELL_MAX_ASSIGNMENT+1);
+                                            adev->doorbell_index.max_assignment+1);
        if (adev->doorbell.num_doorbells == 0)
                return -EINVAL;
 
index 6a70c0b7105fb4372cf3ddb5fda4c04e7082e9ee..97a60da62004a39cc8b78e1229a96f7bf8731ff9 100644 (file)
@@ -250,7 +250,7 @@ int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev,
        ring->adev = NULL;
        ring->ring_obj = NULL;
        ring->use_doorbell = true;
-       ring->doorbell_index = AMDGPU_DOORBELL_KIQ;
+       ring->doorbell_index = adev->doorbell_index.kiq;
 
        r = amdgpu_gfx_kiq_acquire(adev, ring);
        if (r)
index f467b9bd090d49b6cba62864f83317d7310f44bd..3a9fb6018c1611e99bf5e07eb35a21c44dda27f7 100644 (file)
@@ -4363,7 +4363,7 @@ static int gfx_v7_0_compute_ring_init(struct amdgpu_device *adev, int ring_id,
 
        ring->ring_obj = NULL;
        ring->use_doorbell = true;
-       ring->doorbell_index = AMDGPU_DOORBELL_MEC_RING0 + ring_id;
+       ring->doorbell_index = adev->doorbell_index.mec_ring0 + ring_id;
        sprintf(ring->name, "comp_%d.%d.%d", ring->me, ring->pipe, ring->queue);
 
        irq_type = AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP
index 77cac0e2562366312d736e75c9440ce9e9cd946c..1454fc30678332ac59748054148f2120e23abf2b 100644 (file)
@@ -1890,7 +1890,7 @@ static int gfx_v8_0_compute_ring_init(struct amdgpu_device *adev, int ring_id,
 
        ring->ring_obj = NULL;
        ring->use_doorbell = true;
-       ring->doorbell_index = AMDGPU_DOORBELL_MEC_RING0 + ring_id;
+       ring->doorbell_index = adev->doorbell_index.mec_ring0 + ring_id;
        ring->eop_gpu_addr = adev->gfx.mec.hpd_eop_gpu_addr
                                + (ring_id * GFX8_MEC_HPD_SIZE);
        sprintf(ring->name, "comp_%d.%d.%d", ring->me, ring->pipe, ring->queue);
@@ -2001,7 +2001,7 @@ static int gfx_v8_0_sw_init(void *handle)
                /* no gfx doorbells on iceland */
                if (adev->asic_type != CHIP_TOPAZ) {
                        ring->use_doorbell = true;
-                       ring->doorbell_index = AMDGPU_DOORBELL_GFX_RING0;
+                       ring->doorbell_index = adev->doorbell_index.gfx_ring0;
                }
 
                r = amdgpu_ring_init(adev, ring, 1024, &adev->gfx.eop_irq,
@@ -4215,7 +4215,7 @@ static void gfx_v8_0_set_cpg_door_bell(struct amdgpu_device *adev, struct amdgpu
 
        tmp = REG_SET_FIELD(0, CP_RB_DOORBELL_RANGE_LOWER,
                                        DOORBELL_RANGE_LOWER,
-                                       AMDGPU_DOORBELL_GFX_RING0);
+                                       adev->doorbell_index.gfx_ring0);
        WREG32(mmCP_RB_DOORBELL_RANGE_LOWER, tmp);
 
        WREG32(mmCP_RB_DOORBELL_RANGE_UPPER,
@@ -4644,8 +4644,8 @@ static int gfx_v8_0_kcq_init_queue(struct amdgpu_ring *ring)
 static void gfx_v8_0_set_mec_doorbell_range(struct amdgpu_device *adev)
 {
        if (adev->asic_type > CHIP_TONGA) {
-               WREG32(mmCP_MEC_DOORBELL_RANGE_LOWER, AMDGPU_DOORBELL_KIQ << 2);
-               WREG32(mmCP_MEC_DOORBELL_RANGE_UPPER, AMDGPU_DOORBELL_MEC_RING7 << 2);
+               WREG32(mmCP_MEC_DOORBELL_RANGE_LOWER, adev->doorbell_index.kiq << 2);
+               WREG32(mmCP_MEC_DOORBELL_RANGE_UPPER, adev->doorbell_index.mec_ring7 << 2);
        }
        /* enable doorbells */
        WREG32_FIELD(CP_PQ_STATUS, DOORBELL_ENABLE, 1);
index e409fbf67fe75e74359eacd11b35cf6f8645189c..af8ccb014be33a76d53cb69099764fd451c02623 100644 (file)
@@ -1566,7 +1566,7 @@ static int gfx_v9_0_compute_ring_init(struct amdgpu_device *adev, int ring_id,
 
        ring->ring_obj = NULL;
        ring->use_doorbell = true;
-       ring->doorbell_index = (AMDGPU_DOORBELL64_MEC_RING0 + ring_id) << 1;
+       ring->doorbell_index = (adev->doorbell_index.mec_ring0 + ring_id) << 1;
        ring->eop_gpu_addr = adev->gfx.mec.hpd_eop_gpu_addr
                                + (ring_id * GFX9_MEC_HPD_SIZE);
        sprintf(ring->name, "comp_%d.%d.%d", ring->me, ring->pipe, ring->queue);
@@ -1655,7 +1655,7 @@ static int gfx_v9_0_sw_init(void *handle)
                else
                        sprintf(ring->name, "gfx_%d", i);
                ring->use_doorbell = true;
-               ring->doorbell_index = AMDGPU_DOORBELL64_GFX_RING0 << 1;
+               ring->doorbell_index = adev->doorbell_index.gfx_ring0 << 1;
                r = amdgpu_ring_init(adev, ring, 1024,
                                     &adev->gfx.eop_irq, AMDGPU_CP_IRQ_GFX_EOP);
                if (r)
@@ -2981,9 +2981,9 @@ static int gfx_v9_0_kiq_init_register(struct amdgpu_ring *ring)
        /* enable the doorbell if requested */
        if (ring->use_doorbell) {
                WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER,
-                                       (AMDGPU_DOORBELL64_KIQ *2) << 2);
+                                       (adev->doorbell_index.kiq * 2) << 2);
                WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER,
-                                       (AMDGPU_DOORBELL64_USERQUEUE_END * 2) << 2);
+                                       (adev->doorbell_index.userqueue_end * 2) << 2);
        }
 
        WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL,
index b6a25f92d566bc292805e4e019e7928b76bbd2f1..1bccc5fe2d9d97865677a25e7c967ec0b3cbe46b 100644 (file)
@@ -1146,7 +1146,7 @@ static int sdma_v3_0_sw_init(void *handle)
                if (!amdgpu_sriov_vf(adev)) {
                        ring->use_doorbell = true;
                        ring->doorbell_index = (i == 0) ?
-                               AMDGPU_DOORBELL_sDMA_ENGINE0 : AMDGPU_DOORBELL_sDMA_ENGINE1;
+                               adev->doorbell_index.sdma_engine0 : adev->doorbell_index.sdma_engine1;
                } else {
                        ring->use_pollmem = true;
                }
index a973dea7b242fa12bb7dc7361af4845c0a076666..4b6d3e5c821fba1f12974a9b778c1b17eaa71906 100644 (file)
@@ -1518,15 +1518,13 @@ static int sdma_v4_0_sw_init(void *handle)
                ring->ring_obj = NULL;
                ring->use_doorbell = true;
 
+               DRM_INFO("use_doorbell being set to: [%s]\n",
+                               ring->use_doorbell?"true":"false");
+
                /* doorbell size is 2 dwords, get DWORD offset */
-               if (adev->asic_type == CHIP_VEGA10)
-                       ring->doorbell_index = (i == 0) ?
-                               (AMDGPU_VEGA10_DOORBELL64_sDMA_ENGINE0 << 1)
-                               : (AMDGPU_VEGA10_DOORBELL64_sDMA_ENGINE1 << 1);
-               else
-                       ring->doorbell_index = (i == 0) ?
-                               (AMDGPU_DOORBELL64_sDMA_ENGINE0 << 1)
-                               : (AMDGPU_DOORBELL64_sDMA_ENGINE1 << 1);
+               ring->doorbell_index = (i == 0) ?
+                       (adev->doorbell_index.sdma_engine0 << 1)
+                       : (adev->doorbell_index.sdma_engine1 << 1);
 
                sprintf(ring->name, "sdma%d", i);
                r = amdgpu_ring_init(adev, ring, 1024,
@@ -1545,14 +1543,9 @@ static int sdma_v4_0_sw_init(void *handle)
                        /* paging queue use same doorbell index/routing as gfx queue
                         * with 0x400 (4096 dwords) offset on second doorbell page
                         */
-                       if (adev->asic_type == CHIP_VEGA10)
-                               ring->doorbell_index = (i == 0) ?
-                                       (AMDGPU_VEGA10_DOORBELL64_sDMA_ENGINE0 << 1)
-                                       : (AMDGPU_VEGA10_DOORBELL64_sDMA_ENGINE1 << 1);
-                       else
-                               ring->doorbell_index = (i == 0) ?
-                                       (AMDGPU_DOORBELL64_sDMA_ENGINE0 << 1)
-                                       : (AMDGPU_DOORBELL64_sDMA_ENGINE1 << 1);
+                       ring->doorbell_index = (i == 0) ?
+                               (adev->doorbell_index.sdma_engine0 << 1)
+                               : (adev->doorbell_index.sdma_engine1 << 1);
                        ring->doorbell_index += 0x400;
 
                        sprintf(ring->name, "page%d", i);
index 3abffd06b5c785488795a952ece19680e4d559d1..dcdbb4d72472e8dc8732364928a6dac02a162236 100644 (file)
@@ -322,7 +322,7 @@ static int tonga_ih_sw_init(void *handle)
                return r;
 
        adev->irq.ih.use_doorbell = true;
-       adev->irq.ih.doorbell_index = AMDGPU_DOORBELL_IH;
+       adev->irq.ih.doorbell_index = adev->doorbell_index.ih;
 
        r = amdgpu_irq_init(adev);
 
index 8a4595968d98f4b506bcfbddee121cd640c4c956..3680a013743b33cce22627b1582d689dcac7a098 100644 (file)
@@ -455,9 +455,9 @@ static int uvd_v7_0_sw_init(void *handle)
                                 * sriov, so set unused location for other unused rings.
                                 */
                                if (i == 0)
-                                       ring->doorbell_index = AMDGPU_DOORBELL64_UVD_RING0_1 * 2;
+                                       ring->doorbell_index = adev->doorbell_index.uvd_vce.uvd_ring0_1 * 2;
                                else
-                                       ring->doorbell_index = AMDGPU_DOORBELL64_UVD_RING2_3 * 2 + 1;
+                                       ring->doorbell_index = adev->doorbell_index.uvd_vce.uvd_ring2_3 * 2 + 1;
                        }
                        r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.inst[j].irq, 0);
                        if (r)
index 0054ba1b9a6855df99dfd1f3362bce11ed6af0ab..9fb34b7d8e03e88f411dcf369a79d4853aaef897 100644 (file)
@@ -466,9 +466,9 @@ static int vce_v4_0_sw_init(void *handle)
                         * so set unused location for other unused rings.
                         */
                        if (i == 0)
-                               ring->doorbell_index = AMDGPU_DOORBELL64_VCE_RING0_1 * 2;
+                               ring->doorbell_index = adev->doorbell_index.uvd_vce.vce_ring0_1 * 2;
                        else
-                               ring->doorbell_index = AMDGPU_DOORBELL64_VCE_RING2_3 * 2 + 1;
+                               ring->doorbell_index = adev->doorbell_index.uvd_vce.vce_ring2_3 * 2 + 1;
                }
                r = amdgpu_ring_init(adev, ring, 512, &adev->vce.irq, 0);
                if (r)
index a0fda6f9252a52979b5c90569d48b4212f4ea27a..d84b687240d11d41a28a2841fa5ee8c2a51a1855 100644 (file)
@@ -385,7 +385,7 @@ static int vega10_ih_sw_init(void *handle)
                return r;
 
        adev->irq.ih.use_doorbell = true;
-       adev->irq.ih.doorbell_index = AMDGPU_DOORBELL64_IH << 1;
+       adev->irq.ih.doorbell_index = adev->doorbell_index.ih << 1;
 
        r = amdgpu_irq_init(adev);