drm/amdgpu: change wptr to 64 bits (v2)
authorKen Wang <Qingqing.Wang@amd.com>
Sat, 12 Mar 2016 01:32:30 +0000 (09:32 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 30 Mar 2017 03:53:35 +0000 (23:53 -0400)
Newer asics need 64 bit wptrs.  If the wptr is now
smaller than the rptr that doesn't indicate a wrap-around
anymore.

v2: integrate Christian's comments.

Signed-off-by: Ken Wang <Qingqing.Wang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
15 files changed:
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
drivers/gpu/drm/amd/amdgpu/cik_sdma.c
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
drivers/gpu/drm/amd/amdgpu/si_dma.c
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c

index d5eed6b8631448b42b7e837c56c2df77e941ee4f..93ecf692b9f63ee7ffe5934d3c9660b3c94e3507 100644 (file)
@@ -1601,7 +1601,7 @@ static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v)
 {
        if (ring->count_dw <= 0)
                DRM_ERROR("amdgpu: writing more dwords to the ring than expected!\n");
-       ring->ring[ring->wptr++] = v;
+       ring->ring[ring->wptr++ & ring->buf_mask] = v;
        ring->wptr &= ring->ptr_mask;
        ring->count_dw--;
 }
index cead88ac3788c1fd49c21e18703c6c2a52e6b668..c9b536f4b0196017eaadc62f8c41810666b4848b 100644 (file)
@@ -232,7 +232,10 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,
                }
                amdgpu_ring_clear_ring(ring);
        }
-       ring->ptr_mask = (ring->ring_size / 4) - 1;
+       ring->buf_mask = (ring->ring_size / 4) - 1;
+       ring->ptr_mask = ring->funcs->support_64bit_ptrs ?
+               0xffffffffffffffff : ring->buf_mask;
+
        ring->max_dw = max_dw;
 
        if (amdgpu_debugfs_ring_init(adev, ring)) {
index da702dc6e2e58c862aabc7c3a05f71edcee34677..dada0a022bedec55963296d135b0a6e0548ee006 100644 (file)
@@ -96,10 +96,11 @@ struct amdgpu_ring_funcs {
        enum amdgpu_ring_type   type;
        uint32_t                align_mask;
        u32                     nop;
+       bool                    support_64bit_ptrs;
 
        /* ring read/write ptr handling */
-       u32 (*get_rptr)(struct amdgpu_ring *ring);
-       u32 (*get_wptr)(struct amdgpu_ring *ring);
+       u64 (*get_rptr)(struct amdgpu_ring *ring);
+       u64 (*get_wptr)(struct amdgpu_ring *ring);
        void (*set_wptr)(struct amdgpu_ring *ring);
        /* validating and patching of IBs */
        int (*parse_cs)(struct amdgpu_cs_parser *p, uint32_t ib_idx);
@@ -148,13 +149,14 @@ struct amdgpu_ring {
        struct amdgpu_bo        *ring_obj;
        volatile uint32_t       *ring;
        unsigned                rptr_offs;
-       unsigned                wptr;
-       unsigned                wptr_old;
+       u64                     wptr;
+       u64                     wptr_old;
        unsigned                ring_size;
        unsigned                max_dw;
        int                     count_dw;
        uint64_t                gpu_addr;
-       uint32_t                ptr_mask;
+       uint64_t                ptr_mask;
+       uint32_t                buf_mask;
        bool                    ready;
        u32                     idx;
        u32                     me;
index c33bc1bb46552dd94b1a9d0c6d3361c9131677b5..131f69b3f70e4b7080addb6ff8de52b4a68cfaf1 100644 (file)
@@ -158,7 +158,7 @@ out:
  *
  * Get the current rptr from the hardware (CIK+).
  */
-static uint32_t cik_sdma_ring_get_rptr(struct amdgpu_ring *ring)
+static uint64_t cik_sdma_ring_get_rptr(struct amdgpu_ring *ring)
 {
        u32 rptr;
 
@@ -174,7 +174,7 @@ static uint32_t cik_sdma_ring_get_rptr(struct amdgpu_ring *ring)
  *
  * Get the current wptr from the hardware (CIK+).
  */
-static uint32_t cik_sdma_ring_get_wptr(struct amdgpu_ring *ring)
+static uint64_t cik_sdma_ring_get_wptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
        u32 me = (ring == &adev->sdma.instance[0].ring) ? 0 : 1;
@@ -194,7 +194,8 @@ static void cik_sdma_ring_set_wptr(struct amdgpu_ring *ring)
        struct amdgpu_device *adev = ring->adev;
        u32 me = (ring == &adev->sdma.instance[0].ring) ? 0 : 1;
 
-       WREG32(mmSDMA0_GFX_RB_WPTR + sdma_offsets[me], (ring->wptr << 2) & 0x3fffc);
+       WREG32(mmSDMA0_GFX_RB_WPTR + sdma_offsets[me],
+                       (lower_32_bits(ring->wptr) << 2) & 0x3fffc);
 }
 
 static void cik_sdma_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count)
@@ -225,7 +226,7 @@ static void cik_sdma_ring_emit_ib(struct amdgpu_ring *ring,
        u32 extra_bits = vm_id & 0xf;
 
        /* IB packet must end on a 8 DW boundary */
-       cik_sdma_ring_insert_nop(ring, (12 - (ring->wptr & 7)) % 8);
+       cik_sdma_ring_insert_nop(ring, (12 - (lower_32_bits(ring->wptr) & 7)) % 8);
 
        amdgpu_ring_write(ring, SDMA_PACKET(SDMA_OPCODE_INDIRECT_BUFFER, 0, extra_bits));
        amdgpu_ring_write(ring, ib->gpu_addr & 0xffffffe0); /* base must be 32 byte aligned */
@@ -432,7 +433,7 @@ static int cik_sdma_gfx_resume(struct amdgpu_device *adev)
                WREG32(mmSDMA0_GFX_RB_BASE_HI + sdma_offsets[i], ring->gpu_addr >> 40);
 
                ring->wptr = 0;
-               WREG32(mmSDMA0_GFX_RB_WPTR + sdma_offsets[i], ring->wptr << 2);
+               WREG32(mmSDMA0_GFX_RB_WPTR + sdma_offsets[i], lower_32_bits(ring->wptr) << 2);
 
                /* enable DMA RB */
                WREG32(mmSDMA0_GFX_RB_CNTL + sdma_offsets[i],
@@ -1209,6 +1210,7 @@ static const struct amdgpu_ring_funcs cik_sdma_ring_funcs = {
        .type = AMDGPU_RING_TYPE_SDMA,
        .align_mask = 0xf,
        .nop = SDMA_PACKET(SDMA_OPCODE_NOP, 0, 0),
+       .support_64bit_ptrs = false,
        .get_rptr = cik_sdma_ring_get_rptr,
        .get_wptr = cik_sdma_ring_get_wptr,
        .set_wptr = cik_sdma_ring_set_wptr,
index 02ca2322c30bce37230e029fe7aef7cc90c05d09..1a1de6499517ce4411acc548ce970e3eba89b0df 100644 (file)
@@ -2192,12 +2192,12 @@ static int gfx_v6_0_cp_gfx_resume(struct amdgpu_device *adev)
        return 0;
 }
 
-static u32 gfx_v6_0_ring_get_rptr(struct amdgpu_ring *ring)
+static u64 gfx_v6_0_ring_get_rptr(struct amdgpu_ring *ring)
 {
        return ring->adev->wb.wb[ring->rptr_offs];
 }
 
-static u32 gfx_v6_0_ring_get_wptr(struct amdgpu_ring *ring)
+static u64 gfx_v6_0_ring_get_wptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
@@ -2215,7 +2215,7 @@ static void gfx_v6_0_ring_set_wptr_gfx(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
-       WREG32(mmCP_RB0_WPTR, ring->wptr);
+       WREG32(mmCP_RB0_WPTR, lower_32_bits(ring->wptr));
        (void)RREG32(mmCP_RB0_WPTR);
 }
 
@@ -2224,10 +2224,10 @@ static void gfx_v6_0_ring_set_wptr_compute(struct amdgpu_ring *ring)
        struct amdgpu_device *adev = ring->adev;
 
        if (ring == &adev->gfx.compute_ring[0]) {
-               WREG32(mmCP_RB1_WPTR, ring->wptr);
+               WREG32(mmCP_RB1_WPTR, lower_32_bits(ring->wptr));
                (void)RREG32(mmCP_RB1_WPTR);
        } else if (ring == &adev->gfx.compute_ring[1]) {
-               WREG32(mmCP_RB2_WPTR, ring->wptr);
+               WREG32(mmCP_RB2_WPTR, lower_32_bits(ring->wptr));
                (void)RREG32(mmCP_RB2_WPTR);
        } else {
                BUG();
@@ -3631,6 +3631,7 @@ static const struct amdgpu_ring_funcs gfx_v6_0_ring_funcs_gfx = {
        .type = AMDGPU_RING_TYPE_GFX,
        .align_mask = 0xff,
        .nop = 0x80000000,
+       .support_64bit_ptrs = false,
        .get_rptr = gfx_v6_0_ring_get_rptr,
        .get_wptr = gfx_v6_0_ring_get_wptr,
        .set_wptr = gfx_v6_0_ring_set_wptr_gfx,
index 1b8b4941dcf330d9a9dbcee4529bf9030b110be5..1de2e5318b673c434ca3fbf04e964c6fa4e98beb 100644 (file)
@@ -2629,7 +2629,7 @@ static int gfx_v7_0_cp_gfx_resume(struct amdgpu_device *adev)
        /* Initialize the ring buffer's read and write pointers */
        WREG32(mmCP_RB0_CNTL, tmp | CP_RB0_CNTL__RB_RPTR_WR_ENA_MASK);
        ring->wptr = 0;
-       WREG32(mmCP_RB0_WPTR, ring->wptr);
+       WREG32(mmCP_RB0_WPTR, lower_32_bits(ring->wptr));
 
        /* set the wb address wether it's enabled or not */
        rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4);
@@ -2658,12 +2658,12 @@ static int gfx_v7_0_cp_gfx_resume(struct amdgpu_device *adev)
        return 0;
 }
 
-static u32 gfx_v7_0_ring_get_rptr(struct amdgpu_ring *ring)
+static u64 gfx_v7_0_ring_get_rptr(struct amdgpu_ring *ring)
 {
        return ring->adev->wb.wb[ring->rptr_offs];
 }
 
-static u32 gfx_v7_0_ring_get_wptr_gfx(struct amdgpu_ring *ring)
+static u64 gfx_v7_0_ring_get_wptr_gfx(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
@@ -2674,11 +2674,11 @@ static void gfx_v7_0_ring_set_wptr_gfx(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
-       WREG32(mmCP_RB0_WPTR, ring->wptr);
+       WREG32(mmCP_RB0_WPTR, lower_32_bits(ring->wptr));
        (void)RREG32(mmCP_RB0_WPTR);
 }
 
-static u32 gfx_v7_0_ring_get_wptr_compute(struct amdgpu_ring *ring)
+static u64 gfx_v7_0_ring_get_wptr_compute(struct amdgpu_ring *ring)
 {
        /* XXX check if swapping is necessary on BE */
        return ring->adev->wb.wb[ring->wptr_offs];
@@ -2689,8 +2689,8 @@ static void gfx_v7_0_ring_set_wptr_compute(struct amdgpu_ring *ring)
        struct amdgpu_device *adev = ring->adev;
 
        /* XXX check if swapping is necessary on BE */
-       adev->wb.wb[ring->wptr_offs] = ring->wptr;
-       WDOORBELL32(ring->doorbell_index, ring->wptr);
+       adev->wb.wb[ring->wptr_offs] = lower_32_bits(ring->wptr);
+       WDOORBELL32(ring->doorbell_index, lower_32_bits(ring->wptr));
 }
 
 /**
@@ -3160,7 +3160,7 @@ static int gfx_v7_0_cp_compute_resume(struct amdgpu_device *adev)
 
                /* read and write pointers, similar to CP_RB0_WPTR/_RPTR */
                ring->wptr = 0;
-               mqd->queue_state.cp_hqd_pq_wptr = ring->wptr;
+               mqd->queue_state.cp_hqd_pq_wptr = lower_32_bits(ring->wptr);
                WREG32(mmCP_HQD_PQ_WPTR, mqd->queue_state.cp_hqd_pq_wptr);
                mqd->queue_state.cp_hqd_pq_rptr = RREG32(mmCP_HQD_PQ_RPTR);
 
@@ -5206,6 +5206,7 @@ static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_gfx = {
        .type = AMDGPU_RING_TYPE_GFX,
        .align_mask = 0xff,
        .nop = PACKET3(PACKET3_NOP, 0x3FFF),
+       .support_64bit_ptrs = false,
        .get_rptr = gfx_v7_0_ring_get_rptr,
        .get_wptr = gfx_v7_0_ring_get_wptr_gfx,
        .set_wptr = gfx_v7_0_ring_set_wptr_gfx,
@@ -5236,6 +5237,7 @@ static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_compute = {
        .type = AMDGPU_RING_TYPE_COMPUTE,
        .align_mask = 0xff,
        .nop = PACKET3(PACKET3_NOP, 0x3FFF),
+       .support_64bit_ptrs = false,
        .get_rptr = gfx_v7_0_ring_get_rptr,
        .get_wptr = gfx_v7_0_ring_get_wptr_compute,
        .set_wptr = gfx_v7_0_ring_set_wptr_compute,
index fefec6e6379b26dfa479c7d714ad4b9c9908ea52..03ff1399fbfaa3c4e8e399cce26c9d7509fdbb6b 100644 (file)
@@ -4490,7 +4490,7 @@ static int gfx_v8_0_cp_gfx_resume(struct amdgpu_device *adev)
        /* Initialize the ring buffer's read and write pointers */
        WREG32(mmCP_RB0_CNTL, tmp | CP_RB0_CNTL__RB_RPTR_WR_ENA_MASK);
        ring->wptr = 0;
-       WREG32(mmCP_RB0_WPTR, ring->wptr);
+       WREG32(mmCP_RB0_WPTR, lower_32_bits(ring->wptr));
 
        /* set the wb address wether it's enabled or not */
        rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4);
@@ -5204,7 +5204,7 @@ static int gfx_v8_0_cp_compute_resume(struct amdgpu_device *adev)
 
                /* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */
                ring->wptr = 0;
-               mqd->cp_hqd_pq_wptr = ring->wptr;
+               mqd->cp_hqd_pq_wptr = lower_32_bits(ring->wptr);
                WREG32(mmCP_HQD_PQ_WPTR, mqd->cp_hqd_pq_wptr);
                mqd->cp_hqd_pq_rptr = RREG32(mmCP_HQD_PQ_RPTR);
 
@@ -6458,12 +6458,12 @@ static int gfx_v8_0_set_clockgating_state(void *handle,
        return 0;
 }
 
-static u32 gfx_v8_0_ring_get_rptr(struct amdgpu_ring *ring)
+static u64 gfx_v8_0_ring_get_rptr(struct amdgpu_ring *ring)
 {
        return ring->adev->wb.wb[ring->rptr_offs];
 }
 
-static u32 gfx_v8_0_ring_get_wptr_gfx(struct amdgpu_ring *ring)
+static u64 gfx_v8_0_ring_get_wptr_gfx(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
@@ -6480,10 +6480,10 @@ static void gfx_v8_0_ring_set_wptr_gfx(struct amdgpu_ring *ring)
 
        if (ring->use_doorbell) {
                /* XXX check if swapping is necessary on BE */
-               adev->wb.wb[ring->wptr_offs] = ring->wptr;
-               WDOORBELL32(ring->doorbell_index, ring->wptr);
+               adev->wb.wb[ring->wptr_offs] = lower_32_bits(ring->wptr);
+               WDOORBELL32(ring->doorbell_index, lower_32_bits(ring->wptr));
        } else {
-               WREG32(mmCP_RB0_WPTR, ring->wptr);
+               WREG32(mmCP_RB0_WPTR, lower_32_bits(ring->wptr));
                (void)RREG32(mmCP_RB0_WPTR);
        }
 }
@@ -6671,7 +6671,7 @@ static void gfx_v8_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
        }
 }
 
-static u32 gfx_v8_0_ring_get_wptr_compute(struct amdgpu_ring *ring)
+static u64 gfx_v8_0_ring_get_wptr_compute(struct amdgpu_ring *ring)
 {
        return ring->adev->wb.wb[ring->wptr_offs];
 }
@@ -6681,8 +6681,8 @@ static void gfx_v8_0_ring_set_wptr_compute(struct amdgpu_ring *ring)
        struct amdgpu_device *adev = ring->adev;
 
        /* XXX check if swapping is necessary on BE */
-       adev->wb.wb[ring->wptr_offs] = ring->wptr;
-       WDOORBELL32(ring->doorbell_index, ring->wptr);
+       adev->wb.wb[ring->wptr_offs] = lower_32_bits(ring->wptr);
+       WDOORBELL32(ring->doorbell_index, lower_32_bits(ring->wptr));
 }
 
 static void gfx_v8_0_ring_emit_fence_compute(struct amdgpu_ring *ring,
@@ -7037,6 +7037,7 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_gfx = {
        .type = AMDGPU_RING_TYPE_GFX,
        .align_mask = 0xff,
        .nop = PACKET3(PACKET3_NOP, 0x3FFF),
+       .support_64bit_ptrs = false,
        .get_rptr = gfx_v8_0_ring_get_rptr,
        .get_wptr = gfx_v8_0_ring_get_wptr_gfx,
        .set_wptr = gfx_v8_0_ring_set_wptr_gfx,
@@ -7069,6 +7070,7 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute = {
        .type = AMDGPU_RING_TYPE_COMPUTE,
        .align_mask = 0xff,
        .nop = PACKET3(PACKET3_NOP, 0x3FFF),
+       .support_64bit_ptrs = false,
        .get_rptr = gfx_v8_0_ring_get_rptr,
        .get_wptr = gfx_v8_0_ring_get_wptr_compute,
        .set_wptr = gfx_v8_0_ring_set_wptr_compute,
@@ -7097,6 +7099,7 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_kiq = {
        .type = AMDGPU_RING_TYPE_KIQ,
        .align_mask = 0xff,
        .nop = PACKET3(PACKET3_NOP, 0x3FFF),
+       .support_64bit_ptrs = false,
        .get_rptr = gfx_v8_0_ring_get_rptr,
        .get_wptr = gfx_v8_0_ring_get_wptr_compute,
        .set_wptr = gfx_v8_0_ring_set_wptr_compute,
index a881cf475a19eaad1a33c7cebd8ee64649305e66..a733c0f63bbaa06102d6d86364e8143594de5857 100644 (file)
@@ -186,7 +186,7 @@ out:
  *
  * Get the current rptr from the hardware (VI+).
  */
-static uint32_t sdma_v2_4_ring_get_rptr(struct amdgpu_ring *ring)
+static uint64_t sdma_v2_4_ring_get_rptr(struct amdgpu_ring *ring)
 {
        /* XXX check if swapping is necessary on BE */
        return ring->adev->wb.wb[ring->rptr_offs] >> 2;
@@ -199,7 +199,7 @@ static uint32_t sdma_v2_4_ring_get_rptr(struct amdgpu_ring *ring)
  *
  * Get the current wptr from the hardware (VI+).
  */
-static uint32_t sdma_v2_4_ring_get_wptr(struct amdgpu_ring *ring)
+static uint64_t sdma_v2_4_ring_get_wptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
        int me = (ring == &ring->adev->sdma.instance[0].ring) ? 0 : 1;
@@ -220,7 +220,7 @@ static void sdma_v2_4_ring_set_wptr(struct amdgpu_ring *ring)
        struct amdgpu_device *adev = ring->adev;
        int me = (ring == &ring->adev->sdma.instance[0].ring) ? 0 : 1;
 
-       WREG32(mmSDMA0_GFX_RB_WPTR + sdma_offsets[me], ring->wptr << 2);
+       WREG32(mmSDMA0_GFX_RB_WPTR + sdma_offsets[me], lower_32_bits(ring->wptr) << 2);
 }
 
 static void sdma_v2_4_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count)
@@ -251,7 +251,7 @@ static void sdma_v2_4_ring_emit_ib(struct amdgpu_ring *ring,
        u32 vmid = vm_id & 0xf;
 
        /* IB packet must end on a 8 DW boundary */
-       sdma_v2_4_ring_insert_nop(ring, (10 - (ring->wptr & 7)) % 8);
+       sdma_v2_4_ring_insert_nop(ring, (10 - (lower_32_bits(ring->wptr) & 7)) % 8);
 
        amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_INDIRECT) |
                          SDMA_PKT_INDIRECT_HEADER_VMID(vmid));
@@ -466,7 +466,7 @@ static int sdma_v2_4_gfx_resume(struct amdgpu_device *adev)
                WREG32(mmSDMA0_GFX_RB_BASE_HI + sdma_offsets[i], ring->gpu_addr >> 40);
 
                ring->wptr = 0;
-               WREG32(mmSDMA0_GFX_RB_WPTR + sdma_offsets[i], ring->wptr << 2);
+               WREG32(mmSDMA0_GFX_RB_WPTR + sdma_offsets[i], lower_32_bits(ring->wptr) << 2);
 
                /* enable DMA RB */
                rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 1);
@@ -1206,6 +1206,7 @@ static const struct amdgpu_ring_funcs sdma_v2_4_ring_funcs = {
        .type = AMDGPU_RING_TYPE_SDMA,
        .align_mask = 0xf,
        .nop = SDMA_PKT_NOP_HEADER_OP(SDMA_OP_NOP),
+       .support_64bit_ptrs = false,
        .get_rptr = sdma_v2_4_ring_get_rptr,
        .get_wptr = sdma_v2_4_ring_get_wptr,
        .set_wptr = sdma_v2_4_ring_set_wptr,
index c4d7dd7f73a8828b3d7ec37f99b0d3cd5a933132..cafa3852143d951a0bc098b420c27b36dbd78b44 100644 (file)
@@ -337,7 +337,7 @@ out:
  *
  * Get the current rptr from the hardware (VI+).
  */
-static uint32_t sdma_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
+static uint64_t sdma_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
 {
        /* XXX check if swapping is necessary on BE */
        return ring->adev->wb.wb[ring->rptr_offs] >> 2;
@@ -350,7 +350,7 @@ static uint32_t sdma_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
  *
  * Get the current wptr from the hardware (VI+).
  */
-static uint32_t sdma_v3_0_ring_get_wptr(struct amdgpu_ring *ring)
+static uint64_t sdma_v3_0_ring_get_wptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
        u32 wptr;
@@ -380,12 +380,12 @@ static void sdma_v3_0_ring_set_wptr(struct amdgpu_ring *ring)
 
        if (ring->use_doorbell) {
                /* XXX check if swapping is necessary on BE */
-               adev->wb.wb[ring->wptr_offs] = ring->wptr << 2;
-               WDOORBELL32(ring->doorbell_index, ring->wptr << 2);
+               adev->wb.wb[ring->wptr_offs] = lower_32_bits(ring->wptr) << 2;
+               WDOORBELL32(ring->doorbell_index, lower_32_bits(ring->wptr) << 2);
        } else {
                int me = (ring == &ring->adev->sdma.instance[0].ring) ? 0 : 1;
 
-               WREG32(mmSDMA0_GFX_RB_WPTR + sdma_offsets[me], ring->wptr << 2);
+               WREG32(mmSDMA0_GFX_RB_WPTR + sdma_offsets[me], lower_32_bits(ring->wptr) << 2);
        }
 }
 
@@ -417,7 +417,7 @@ static void sdma_v3_0_ring_emit_ib(struct amdgpu_ring *ring,
        u32 vmid = vm_id & 0xf;
 
        /* IB packet must end on a 8 DW boundary */
-       sdma_v3_0_ring_insert_nop(ring, (10 - (ring->wptr & 7)) % 8);
+       sdma_v3_0_ring_insert_nop(ring, (10 - (lower_32_bits(ring->wptr) & 7)) % 8);
 
        amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_INDIRECT) |
                          SDMA_PKT_INDIRECT_HEADER_VMID(vmid));
@@ -660,7 +660,7 @@ static int sdma_v3_0_gfx_resume(struct amdgpu_device *adev)
                WREG32(mmSDMA0_GFX_RB_BASE_HI + sdma_offsets[i], ring->gpu_addr >> 40);
 
                ring->wptr = 0;
-               WREG32(mmSDMA0_GFX_RB_WPTR + sdma_offsets[i], ring->wptr << 2);
+               WREG32(mmSDMA0_GFX_RB_WPTR + sdma_offsets[i], lower_32_bits(ring->wptr) << 2);
 
                doorbell = RREG32(mmSDMA0_GFX_DOORBELL + sdma_offsets[i]);
 
@@ -1579,6 +1579,7 @@ static const struct amdgpu_ring_funcs sdma_v3_0_ring_funcs = {
        .type = AMDGPU_RING_TYPE_SDMA,
        .align_mask = 0xf,
        .nop = SDMA_PKT_NOP_HEADER_OP(SDMA_OP_NOP),
+       .support_64bit_ptrs = false,
        .get_rptr = sdma_v3_0_ring_get_rptr,
        .get_wptr = sdma_v3_0_ring_get_wptr,
        .set_wptr = sdma_v3_0_ring_set_wptr,
index 3372a071bb859c09c4a37588ddcb6871a1cf9ba0..c4fb3f94c26f45a88603b3b5f5072066bec4ef12 100644 (file)
@@ -37,12 +37,12 @@ static void si_dma_set_buffer_funcs(struct amdgpu_device *adev);
 static void si_dma_set_vm_pte_funcs(struct amdgpu_device *adev);
 static void si_dma_set_irq_funcs(struct amdgpu_device *adev);
 
-static uint32_t si_dma_ring_get_rptr(struct amdgpu_ring *ring)
+static uint64_t si_dma_ring_get_rptr(struct amdgpu_ring *ring)
 {
        return ring->adev->wb.wb[ring->rptr_offs>>2];
 }
 
-static uint32_t si_dma_ring_get_wptr(struct amdgpu_ring *ring)
+static uint64_t si_dma_ring_get_wptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
        u32 me = (ring == &adev->sdma.instance[0].ring) ? 0 : 1;
@@ -55,7 +55,8 @@ static void si_dma_ring_set_wptr(struct amdgpu_ring *ring)
        struct amdgpu_device *adev = ring->adev;
        u32 me = (ring == &adev->sdma.instance[0].ring) ? 0 : 1;
 
-       WREG32(DMA_RB_WPTR + sdma_offsets[me], (ring->wptr << 2) & 0x3fffc);
+       WREG32(DMA_RB_WPTR + sdma_offsets[me],
+              (lower_32_bits(ring->wptr) << 2) & 0x3fffc);
 }
 
 static void si_dma_ring_emit_ib(struct amdgpu_ring *ring,
@@ -65,7 +66,7 @@ static void si_dma_ring_emit_ib(struct amdgpu_ring *ring,
        /* The indirect buffer packet must end on an 8 DW boundary in the DMA ring.
         * Pad as necessary with NOPs.
         */
-       while ((ring->wptr & 7) != 5)
+       while ((lower_32_bits(ring->wptr) & 7) != 5)
                amdgpu_ring_write(ring, DMA_PACKET(DMA_PACKET_NOP, 0, 0, 0, 0));
        amdgpu_ring_write(ring, DMA_IB_PACKET(DMA_PACKET_INDIRECT_BUFFER, vm_id, 0));
        amdgpu_ring_write(ring, (ib->gpu_addr & 0xFFFFFFE0));
@@ -184,7 +185,7 @@ static int si_dma_start(struct amdgpu_device *adev)
                WREG32(DMA_CNTL + sdma_offsets[i], dma_cntl);
 
                ring->wptr = 0;
-               WREG32(DMA_RB_WPTR + sdma_offsets[i], ring->wptr << 2);
+               WREG32(DMA_RB_WPTR + sdma_offsets[i], lower_32_bits(ring->wptr) << 2);
                WREG32(DMA_RB_CNTL + sdma_offsets[i], rb_cntl | DMA_RB_ENABLE);
 
                ring->ready = true;
@@ -766,6 +767,7 @@ static const struct amdgpu_ring_funcs si_dma_ring_funcs = {
        .type = AMDGPU_RING_TYPE_SDMA,
        .align_mask = 0xf,
        .nop = DMA_PACKET(DMA_PACKET_NOP, 0, 0, 0, 0),
+       .support_64bit_ptrs = false,
        .get_rptr = si_dma_ring_get_rptr,
        .get_wptr = si_dma_ring_get_wptr,
        .set_wptr = si_dma_ring_set_wptr,
index b34cefc7ebd5b0d67033bf9f89604994d39ff527..4bcb2f37cb7f2c1e4cf1949114a2f50047af77db 100644 (file)
@@ -55,7 +55,7 @@ static void uvd_v4_2_set_dcm(struct amdgpu_device *adev,
  *
  * Returns the current hardware read pointer
  */
-static uint32_t uvd_v4_2_ring_get_rptr(struct amdgpu_ring *ring)
+static uint64_t uvd_v4_2_ring_get_rptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
@@ -69,7 +69,7 @@ static uint32_t uvd_v4_2_ring_get_rptr(struct amdgpu_ring *ring)
  *
  * Returns the current hardware write pointer
  */
-static uint32_t uvd_v4_2_ring_get_wptr(struct amdgpu_ring *ring)
+static uint64_t uvd_v4_2_ring_get_wptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
@@ -87,7 +87,7 @@ static void uvd_v4_2_ring_set_wptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
-       WREG32(mmUVD_RBC_RB_WPTR, ring->wptr);
+       WREG32(mmUVD_RBC_RB_WPTR, lower_32_bits(ring->wptr));
 }
 
 static int uvd_v4_2_early_init(void *handle)
@@ -367,7 +367,7 @@ static int uvd_v4_2_start(struct amdgpu_device *adev)
        WREG32(mmUVD_RBC_RB_RPTR, 0x0);
 
        ring->wptr = RREG32(mmUVD_RBC_RB_RPTR);
-       WREG32(mmUVD_RBC_RB_WPTR, ring->wptr);
+       WREG32(mmUVD_RBC_RB_WPTR, lower_32_bits(ring->wptr));
 
        /* set the ring address */
        WREG32(mmUVD_RBC_RB_BASE, ring->gpu_addr);
@@ -770,6 +770,7 @@ static const struct amdgpu_ring_funcs uvd_v4_2_ring_funcs = {
        .type = AMDGPU_RING_TYPE_UVD,
        .align_mask = 0xf,
        .nop = PACKET0(mmUVD_NO_OP, 0),
+       .support_64bit_ptrs = false,
        .get_rptr = uvd_v4_2_ring_get_rptr,
        .get_wptr = uvd_v4_2_ring_get_wptr,
        .set_wptr = uvd_v4_2_ring_set_wptr,
index ad8c02e423d4f2c5d2161a1ec2b173185d8b516a..35008c181363c890fdecb03556cf2b3896c2d9d8 100644 (file)
@@ -51,7 +51,7 @@ static void uvd_v5_0_enable_mgcg(struct amdgpu_device *adev,
  *
  * Returns the current hardware read pointer
  */
-static uint32_t uvd_v5_0_ring_get_rptr(struct amdgpu_ring *ring)
+static uint64_t uvd_v5_0_ring_get_rptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
@@ -65,7 +65,7 @@ static uint32_t uvd_v5_0_ring_get_rptr(struct amdgpu_ring *ring)
  *
  * Returns the current hardware write pointer
  */
-static uint32_t uvd_v5_0_ring_get_wptr(struct amdgpu_ring *ring)
+static uint64_t uvd_v5_0_ring_get_wptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
@@ -83,7 +83,7 @@ static void uvd_v5_0_ring_set_wptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
-       WREG32(mmUVD_RBC_RB_WPTR, ring->wptr);
+       WREG32(mmUVD_RBC_RB_WPTR, lower_32_bits(ring->wptr));
 }
 
 static int uvd_v5_0_early_init(void *handle)
@@ -424,7 +424,7 @@ static int uvd_v5_0_start(struct amdgpu_device *adev)
        WREG32(mmUVD_RBC_RB_RPTR, 0);
 
        ring->wptr = RREG32(mmUVD_RBC_RB_RPTR);
-       WREG32(mmUVD_RBC_RB_WPTR, ring->wptr);
+       WREG32(mmUVD_RBC_RB_WPTR, lower_32_bits(ring->wptr));
 
        WREG32_P(mmUVD_RBC_RB_CNTL, 0, ~UVD_RBC_RB_CNTL__RB_NO_FETCH_MASK);
 
@@ -879,6 +879,7 @@ static const struct amdgpu_ring_funcs uvd_v5_0_ring_funcs = {
        .type = AMDGPU_RING_TYPE_UVD,
        .align_mask = 0xf,
        .nop = PACKET0(mmUVD_NO_OP, 0),
+       .support_64bit_ptrs = false,
        .get_rptr = uvd_v5_0_ring_get_rptr,
        .get_wptr = uvd_v5_0_ring_get_wptr,
        .set_wptr = uvd_v5_0_ring_set_wptr,
index 18a6de4e1512b189efc153244454763b5b7e5263..46fe4980accc269f03ea7974598eeb0f3905440a 100644 (file)
@@ -54,7 +54,7 @@ static void uvd_v6_0_enable_mgcg(struct amdgpu_device *adev,
  *
  * Returns the current hardware read pointer
  */
-static uint32_t uvd_v6_0_ring_get_rptr(struct amdgpu_ring *ring)
+static uint64_t uvd_v6_0_ring_get_rptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
@@ -68,7 +68,7 @@ static uint32_t uvd_v6_0_ring_get_rptr(struct amdgpu_ring *ring)
  *
  * Returns the current hardware write pointer
  */
-static uint32_t uvd_v6_0_ring_get_wptr(struct amdgpu_ring *ring)
+static uint64_t uvd_v6_0_ring_get_wptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
@@ -86,7 +86,7 @@ static void uvd_v6_0_ring_set_wptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
-       WREG32(mmUVD_RBC_RB_WPTR, ring->wptr);
+       WREG32(mmUVD_RBC_RB_WPTR, lower_32_bits(ring->wptr));
 }
 
 static int uvd_v6_0_early_init(void *handle)
@@ -521,7 +521,7 @@ static int uvd_v6_0_start(struct amdgpu_device *adev)
        WREG32(mmUVD_RBC_RB_RPTR, 0);
 
        ring->wptr = RREG32(mmUVD_RBC_RB_RPTR);
-       WREG32(mmUVD_RBC_RB_WPTR, ring->wptr);
+       WREG32(mmUVD_RBC_RB_WPTR, lower_32_bits(ring->wptr));
 
        WREG32_FIELD(UVD_RBC_RB_CNTL, RB_NO_FETCH, 0);
 
@@ -1108,6 +1108,7 @@ static const struct amdgpu_ring_funcs uvd_v6_0_ring_phys_funcs = {
        .type = AMDGPU_RING_TYPE_UVD,
        .align_mask = 0xf,
        .nop = PACKET0(mmUVD_NO_OP, 0),
+       .support_64bit_ptrs = false,
        .get_rptr = uvd_v6_0_ring_get_rptr,
        .get_wptr = uvd_v6_0_ring_get_wptr,
        .set_wptr = uvd_v6_0_ring_set_wptr,
@@ -1134,6 +1135,7 @@ static const struct amdgpu_ring_funcs uvd_v6_0_ring_vm_funcs = {
        .type = AMDGPU_RING_TYPE_UVD,
        .align_mask = 0xf,
        .nop = PACKET0(mmUVD_NO_OP, 0),
+       .support_64bit_ptrs = false,
        .get_rptr = uvd_v6_0_ring_get_rptr,
        .get_wptr = uvd_v6_0_ring_get_wptr,
        .set_wptr = uvd_v6_0_ring_set_wptr,
index cb0b730ff77a408aea10321a1f3c034b5b4d60d3..3433a73ae04bc9a8d35852b9471e7b0bfd5b5969 100644 (file)
@@ -52,7 +52,7 @@ static void vce_v2_0_set_irq_funcs(struct amdgpu_device *adev);
  *
  * Returns the current hardware read pointer
  */
-static uint32_t vce_v2_0_ring_get_rptr(struct amdgpu_ring *ring)
+static uint64_t vce_v2_0_ring_get_rptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
@@ -69,7 +69,7 @@ static uint32_t vce_v2_0_ring_get_rptr(struct amdgpu_ring *ring)
  *
  * Returns the current hardware write pointer
  */
-static uint32_t vce_v2_0_ring_get_wptr(struct amdgpu_ring *ring)
+static uint64_t vce_v2_0_ring_get_wptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
@@ -91,9 +91,9 @@ static void vce_v2_0_ring_set_wptr(struct amdgpu_ring *ring)
        struct amdgpu_device *adev = ring->adev;
 
        if (ring == &adev->vce.ring[0])
-               WREG32(mmVCE_RB_WPTR, ring->wptr);
+               WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
        else
-               WREG32(mmVCE_RB_WPTR2, ring->wptr);
+               WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
 }
 
 static int vce_v2_0_lmi_clean(struct amdgpu_device *adev)
@@ -241,15 +241,15 @@ static int vce_v2_0_start(struct amdgpu_device *adev)
        vce_v2_0_mc_resume(adev);
 
        ring = &adev->vce.ring[0];
-       WREG32(mmVCE_RB_RPTR, ring->wptr);
-       WREG32(mmVCE_RB_WPTR, ring->wptr);
+       WREG32(mmVCE_RB_RPTR, lower_32_bits(ring->wptr));
+       WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
        WREG32(mmVCE_RB_BASE_LO, ring->gpu_addr);
        WREG32(mmVCE_RB_BASE_HI, upper_32_bits(ring->gpu_addr));
        WREG32(mmVCE_RB_SIZE, ring->ring_size / 4);
 
        ring = &adev->vce.ring[1];
-       WREG32(mmVCE_RB_RPTR2, ring->wptr);
-       WREG32(mmVCE_RB_WPTR2, ring->wptr);
+       WREG32(mmVCE_RB_RPTR2, lower_32_bits(ring->wptr));
+       WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
        WREG32(mmVCE_RB_BASE_LO2, ring->gpu_addr);
        WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr));
        WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4);
@@ -631,6 +631,7 @@ static const struct amdgpu_ring_funcs vce_v2_0_ring_funcs = {
        .type = AMDGPU_RING_TYPE_VCE,
        .align_mask = 0xf,
        .nop = VCE_CMD_NO_OP,
+       .support_64bit_ptrs = false,
        .get_rptr = vce_v2_0_ring_get_rptr,
        .get_wptr = vce_v2_0_ring_get_wptr,
        .set_wptr = vce_v2_0_ring_set_wptr,
index 93ec8815bb1395bf6d8a3db4519f3ab50ac2e65f..2c5f88cad8ac42355a976bc494714c8a9788ad08 100644 (file)
@@ -73,7 +73,7 @@ static int vce_v3_0_wait_for_idle(void *handle);
  *
  * Returns the current hardware read pointer
  */
-static uint32_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
+static uint64_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
@@ -92,7 +92,7 @@ static uint32_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
  *
  * Returns the current hardware write pointer
  */
-static uint32_t vce_v3_0_ring_get_wptr(struct amdgpu_ring *ring)
+static uint64_t vce_v3_0_ring_get_wptr(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
 
@@ -116,11 +116,11 @@ static void vce_v3_0_ring_set_wptr(struct amdgpu_ring *ring)
        struct amdgpu_device *adev = ring->adev;
 
        if (ring == &adev->vce.ring[0])
-               WREG32(mmVCE_RB_WPTR, ring->wptr);
+               WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
        else if (ring == &adev->vce.ring[1])
-               WREG32(mmVCE_RB_WPTR2, ring->wptr);
+               WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
        else
-               WREG32(mmVCE_RB_WPTR3, ring->wptr);
+               WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr));
 }
 
 static void vce_v3_0_override_vce_clock_gating(struct amdgpu_device *adev, bool override)
@@ -231,22 +231,22 @@ static int vce_v3_0_start(struct amdgpu_device *adev)
        int idx, r;
 
        ring = &adev->vce.ring[0];
-       WREG32(mmVCE_RB_RPTR, ring->wptr);
-       WREG32(mmVCE_RB_WPTR, ring->wptr);
+       WREG32(mmVCE_RB_RPTR, lower_32_bits(ring->wptr));
+       WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
        WREG32(mmVCE_RB_BASE_LO, ring->gpu_addr);
        WREG32(mmVCE_RB_BASE_HI, upper_32_bits(ring->gpu_addr));
        WREG32(mmVCE_RB_SIZE, ring->ring_size / 4);
 
        ring = &adev->vce.ring[1];
-       WREG32(mmVCE_RB_RPTR2, ring->wptr);
-       WREG32(mmVCE_RB_WPTR2, ring->wptr);
+       WREG32(mmVCE_RB_RPTR2, lower_32_bits(ring->wptr));
+       WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
        WREG32(mmVCE_RB_BASE_LO2, ring->gpu_addr);
        WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr));
        WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4);
 
        ring = &adev->vce.ring[2];
-       WREG32(mmVCE_RB_RPTR3, ring->wptr);
-       WREG32(mmVCE_RB_WPTR3, ring->wptr);
+       WREG32(mmVCE_RB_RPTR3, lower_32_bits(ring->wptr));
+       WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr));
        WREG32(mmVCE_RB_BASE_LO3, ring->gpu_addr);
        WREG32(mmVCE_RB_BASE_HI3, upper_32_bits(ring->gpu_addr));
        WREG32(mmVCE_RB_SIZE3, ring->ring_size / 4);
@@ -860,6 +860,7 @@ static const struct amdgpu_ring_funcs vce_v3_0_ring_phys_funcs = {
        .type = AMDGPU_RING_TYPE_VCE,
        .align_mask = 0xf,
        .nop = VCE_CMD_NO_OP,
+       .support_64bit_ptrs = false,
        .get_rptr = vce_v3_0_ring_get_rptr,
        .get_wptr = vce_v3_0_ring_get_wptr,
        .set_wptr = vce_v3_0_ring_set_wptr,
@@ -882,6 +883,7 @@ static const struct amdgpu_ring_funcs vce_v3_0_ring_vm_funcs = {
        .type = AMDGPU_RING_TYPE_VCE,
        .align_mask = 0xf,
        .nop = VCE_CMD_NO_OP,
+       .support_64bit_ptrs = false,
        .get_rptr = vce_v3_0_ring_get_rptr,
        .get_wptr = vce_v3_0_ring_get_wptr,
        .set_wptr = vce_v3_0_ring_set_wptr,