drm/amdgpu/sdma: Fix incorrect calculations of the wptr of the doorbells
authorjsg <jsg@openbsd.org>
Fri, 10 Jun 2022 00:59:19 +0000 (00:59 +0000)
committerjsg <jsg@openbsd.org>
Fri, 10 Jun 2022 00:59:19 +0000 (00:59 +0000)
From Haohui Mai
7719a8044bf66b9f59818e50b0c7877e1397e7f4 in linux 5.15.y/5.15.46
7dba6e838e741caadcf27ef717b6dcb561e77f89 in mainline linux

sys/dev/pci/drm/amd/amdgpu/sdma_v4_0.c
sys/dev/pci/drm/amd/amdgpu/sdma_v5_0.c
sys/dev/pci/drm/amd/amdgpu/sdma_v5_2.c

index 7085d8a..5913b7f 100644 (file)
@@ -770,8 +770,8 @@ static void sdma_v4_0_ring_set_wptr(struct amdgpu_ring *ring)
 
                DRM_DEBUG("Using doorbell -- "
                                "wptr_offs == 0x%08x "
-                               "lower_32_bits(ring->wptr) << 2 == 0x%08x "
-                               "upper_32_bits(ring->wptr) << 2 == 0x%08x\n",
+                               "lower_32_bits(ring->wptr << 2) == 0x%08x "
+                               "upper_32_bits(ring->wptr << 2) == 0x%08x\n",
                                ring->wptr_offs,
                                lower_32_bits(ring->wptr << 2),
                                upper_32_bits(ring->wptr << 2));
index 21d1664..ca65d17 100644 (file)
@@ -400,8 +400,8 @@ static void sdma_v5_0_ring_set_wptr(struct amdgpu_ring *ring)
        if (ring->use_doorbell) {
                DRM_DEBUG("Using doorbell -- "
                                "wptr_offs == 0x%08x "
-                               "lower_32_bits(ring->wptr) << 2 == 0x%08x "
-                               "upper_32_bits(ring->wptr) << 2 == 0x%08x\n",
+                               "lower_32_bits(ring->wptr << 2) == 0x%08x "
+                               "upper_32_bits(ring->wptr << 2) == 0x%08x\n",
                                ring->wptr_offs,
                                lower_32_bits(ring->wptr << 2),
                                upper_32_bits(ring->wptr << 2));
@@ -782,9 +782,9 @@ static int sdma_v5_0_gfx_resume(struct amdgpu_device *adev)
 
                if (!amdgpu_sriov_vf(adev)) { /* only bare-metal use register write for wptr */
                        WREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_WPTR),
-                              lower_32_bits(ring->wptr) << 2);
+                              lower_32_bits(ring->wptr << 2));
                        WREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_WPTR_HI),
-                              upper_32_bits(ring->wptr) << 2);
+                              upper_32_bits(ring->wptr << 2));
                }
 
                doorbell = RREG32_SOC15_IP(GC, sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_DOORBELL));
index 81560ad..943d54d 100644 (file)
@@ -287,8 +287,8 @@ static void sdma_v5_2_ring_set_wptr(struct amdgpu_ring *ring)
        if (ring->use_doorbell) {
                DRM_DEBUG("Using doorbell -- "
                                "wptr_offs == 0x%08x "
-                               "lower_32_bits(ring->wptr) << 2 == 0x%08x "
-                               "upper_32_bits(ring->wptr) << 2 == 0x%08x\n",
+                               "lower_32_bits(ring->wptr << 2) == 0x%08x "
+                               "upper_32_bits(ring->wptr << 2) == 0x%08x\n",
                                ring->wptr_offs,
                                lower_32_bits(ring->wptr << 2),
                                upper_32_bits(ring->wptr << 2));
@@ -660,8 +660,8 @@ static int sdma_v5_2_gfx_resume(struct amdgpu_device *adev)
                WREG32_SOC15_IP(GC, sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_MINOR_PTR_UPDATE), 1);
 
                if (!amdgpu_sriov_vf(adev)) { /* only bare-metal use register write for wptr */
-                       WREG32(sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_RB_WPTR), lower_32_bits(ring->wptr) << 2);
-                       WREG32(sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_RB_WPTR_HI), upper_32_bits(ring->wptr) << 2);
+                       WREG32(sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_RB_WPTR), lower_32_bits(ring->wptr << 2));
+                       WREG32(sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_RB_WPTR_HI), upper_32_bits(ring->wptr << 2));
                }
 
                doorbell = RREG32_SOC15_IP(GC, sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_DOORBELL));