提交 adfed2b0 编写于 作者: A Alex Deucher

drm/radeon: use gart memory for DMA ring tests

Avoids HDP cache flush issues when using vram which can
cause ring test failures on certain boards.
Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
Cc: Alexander Fyodorov <halcy@yandex.ru>
Cc: stable@vger.kernel.org
上级 49104038
...@@ -618,16 +618,19 @@ int cik_sdma_ring_test(struct radeon_device *rdev, ...@@ -618,16 +618,19 @@ int cik_sdma_ring_test(struct radeon_device *rdev,
{ {
unsigned i; unsigned i;
int r; int r;
void __iomem *ptr = (void *)rdev->vram_scratch.ptr; unsigned index;
u32 tmp; u32 tmp;
u64 gpu_addr;
if (!ptr) { if (ring->idx == R600_RING_TYPE_DMA_INDEX)
DRM_ERROR("invalid vram scratch pointer\n"); index = R600_WB_DMA_RING_TEST_OFFSET;
return -EINVAL; else
} index = CAYMAN_WB_DMA1_RING_TEST_OFFSET;
gpu_addr = rdev->wb.gpu_addr + index;
tmp = 0xCAFEDEAD; tmp = 0xCAFEDEAD;
writel(tmp, ptr); rdev->wb.wb[index/4] = cpu_to_le32(tmp);
r = radeon_ring_lock(rdev, ring, 5); r = radeon_ring_lock(rdev, ring, 5);
if (r) { if (r) {
...@@ -635,14 +638,14 @@ int cik_sdma_ring_test(struct radeon_device *rdev, ...@@ -635,14 +638,14 @@ int cik_sdma_ring_test(struct radeon_device *rdev,
return r; return r;
} }
radeon_ring_write(ring, SDMA_PACKET(SDMA_OPCODE_WRITE, SDMA_WRITE_SUB_OPCODE_LINEAR, 0)); radeon_ring_write(ring, SDMA_PACKET(SDMA_OPCODE_WRITE, SDMA_WRITE_SUB_OPCODE_LINEAR, 0));
radeon_ring_write(ring, rdev->vram_scratch.gpu_addr & 0xfffffffc); radeon_ring_write(ring, lower_32_bits(gpu_addr));
radeon_ring_write(ring, upper_32_bits(rdev->vram_scratch.gpu_addr)); radeon_ring_write(ring, upper_32_bits(gpu_addr));
radeon_ring_write(ring, 1); /* number of DWs to follow */ radeon_ring_write(ring, 1); /* number of DWs to follow */
radeon_ring_write(ring, 0xDEADBEEF); radeon_ring_write(ring, 0xDEADBEEF);
radeon_ring_unlock_commit(rdev, ring, false); radeon_ring_unlock_commit(rdev, ring, false);
for (i = 0; i < rdev->usec_timeout; i++) { for (i = 0; i < rdev->usec_timeout; i++) {
tmp = readl(ptr); tmp = le32_to_cpu(rdev->wb.wb[index/4]);
if (tmp == 0xDEADBEEF) if (tmp == 0xDEADBEEF)
break; break;
DRM_UDELAY(1); DRM_UDELAY(1);
......
...@@ -241,16 +241,19 @@ int r600_dma_ring_test(struct radeon_device *rdev, ...@@ -241,16 +241,19 @@ int r600_dma_ring_test(struct radeon_device *rdev,
{ {
unsigned i; unsigned i;
int r; int r;
void __iomem *ptr = (void *)rdev->vram_scratch.ptr; unsigned index;
u32 tmp; u32 tmp;
u64 gpu_addr;
if (!ptr) { if (ring->idx == R600_RING_TYPE_DMA_INDEX)
DRM_ERROR("invalid vram scratch pointer\n"); index = R600_WB_DMA_RING_TEST_OFFSET;
return -EINVAL; else
} index = CAYMAN_WB_DMA1_RING_TEST_OFFSET;
gpu_addr = rdev->wb.gpu_addr + index;
tmp = 0xCAFEDEAD; tmp = 0xCAFEDEAD;
writel(tmp, ptr); rdev->wb.wb[index/4] = cpu_to_le32(tmp);
r = radeon_ring_lock(rdev, ring, 4); r = radeon_ring_lock(rdev, ring, 4);
if (r) { if (r) {
...@@ -258,13 +261,13 @@ int r600_dma_ring_test(struct radeon_device *rdev, ...@@ -258,13 +261,13 @@ int r600_dma_ring_test(struct radeon_device *rdev,
return r; return r;
} }
radeon_ring_write(ring, DMA_PACKET(DMA_PACKET_WRITE, 0, 0, 1)); radeon_ring_write(ring, DMA_PACKET(DMA_PACKET_WRITE, 0, 0, 1));
radeon_ring_write(ring, rdev->vram_scratch.gpu_addr & 0xfffffffc); radeon_ring_write(ring, lower_32_bits(gpu_addr));
radeon_ring_write(ring, upper_32_bits(rdev->vram_scratch.gpu_addr) & 0xff); radeon_ring_write(ring, upper_32_bits(gpu_addr) & 0xff);
radeon_ring_write(ring, 0xDEADBEEF); radeon_ring_write(ring, 0xDEADBEEF);
radeon_ring_unlock_commit(rdev, ring, false); radeon_ring_unlock_commit(rdev, ring, false);
for (i = 0; i < rdev->usec_timeout; i++) { for (i = 0; i < rdev->usec_timeout; i++) {
tmp = readl(ptr); tmp = le32_to_cpu(rdev->wb.wb[index/4]);
if (tmp == 0xDEADBEEF) if (tmp == 0xDEADBEEF)
break; break;
DRM_UDELAY(1); DRM_UDELAY(1);
......
...@@ -1132,6 +1132,8 @@ struct radeon_wb { ...@@ -1132,6 +1132,8 @@ struct radeon_wb {
#define R600_WB_EVENT_OFFSET 3072 #define R600_WB_EVENT_OFFSET 3072
#define CIK_WB_CP1_WPTR_OFFSET 3328 #define CIK_WB_CP1_WPTR_OFFSET 3328
#define CIK_WB_CP2_WPTR_OFFSET 3584 #define CIK_WB_CP2_WPTR_OFFSET 3584
#define R600_WB_DMA_RING_TEST_OFFSET 3588
#define CAYMAN_WB_DMA1_RING_TEST_OFFSET 3592
/** /**
* struct radeon_pm - power management datas * struct radeon_pm - power management datas
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册