aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorAlex Deucher <alexander.deucher@amd.com>2017-04-17 16:21:52 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-05-24 17:40:16 -0400
commit2fdde9fa9705cb4df29445c2a4dd241b1e9c03f2 (patch)
treea70ebb26e2303042401ed88280db76eaa8ffa2e7 /drivers/gpu
parentf1f7b443788c5e81a7a2ee8079e3d5b9f24ef003 (diff)
drm/amdgpu/gfx9: wait for completion in KIQ init
We need to make sure the various init sequences submitted to KIQ complete before testing the rings. Reviewed-by: monk liu <monk.liu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c89
1 files changed, 79 insertions, 10 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index c95886d2f163..711aaaca6f4b 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -1833,9 +1833,26 @@ static void gfx_v9_0_kiq_setting(struct amdgpu_ring *ring)
1833 WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS, tmp); 1833 WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS, tmp);
1834} 1834}
1835 1835
1836static void gfx_v9_0_kiq_enable(struct amdgpu_ring *ring) 1836static int gfx_v9_0_kiq_enable(struct amdgpu_ring *ring)
1837{ 1837{
1838 amdgpu_ring_alloc(ring, 8); 1838 struct amdgpu_device *adev = ring->adev;
1839 uint32_t scratch, tmp = 0;
1840 int r, i;
1841
1842 r = amdgpu_gfx_scratch_get(adev, &scratch);
1843 if (r) {
1844 DRM_ERROR("Failed to get scratch reg (%d).\n", r);
1845 return r;
1846 }
1847 WREG32(scratch, 0xCAFEDEAD);
1848
1849 r = amdgpu_ring_alloc(ring, 8);
1850 if (r) {
1851 DRM_ERROR("Failed to lock KIQ (%d).\n", r);
1852 amdgpu_gfx_scratch_free(adev, scratch);
1853 return r;
1854 }
1855 amdgpu_ring_alloc(ring, 11);
1839 /* set resources */ 1856 /* set resources */
1840 amdgpu_ring_write(ring, PACKET3(PACKET3_SET_RESOURCES, 6)); 1857 amdgpu_ring_write(ring, PACKET3(PACKET3_SET_RESOURCES, 6));
1841 amdgpu_ring_write(ring, PACKET3_SET_RESOURCES_VMID_MASK(0) | 1858 amdgpu_ring_write(ring, PACKET3_SET_RESOURCES_VMID_MASK(0) |
@@ -1846,19 +1863,52 @@ static void gfx_v9_0_kiq_enable(struct amdgpu_ring *ring)
1846 amdgpu_ring_write(ring, 0); /* gws mask hi */ 1863 amdgpu_ring_write(ring, 0); /* gws mask hi */
1847 amdgpu_ring_write(ring, 0); /* oac mask */ 1864 amdgpu_ring_write(ring, 0); /* oac mask */
1848 amdgpu_ring_write(ring, 0); /* gds heap base:0, gds heap size:0 */ 1865 amdgpu_ring_write(ring, 0); /* gds heap base:0, gds heap size:0 */
1866 /* write to scratch for completion */
1867 amdgpu_ring_write(ring, PACKET3(PACKET3_SET_UCONFIG_REG, 1));
1868 amdgpu_ring_write(ring, (scratch - PACKET3_SET_UCONFIG_REG_START));
1869 amdgpu_ring_write(ring, 0xDEADBEEF);
1849 amdgpu_ring_commit(ring); 1870 amdgpu_ring_commit(ring);
1850 udelay(50); 1871
1872 for (i = 0; i < adev->usec_timeout; i++) {
1873 tmp = RREG32(scratch);
1874 if (tmp == 0xDEADBEEF)
1875 break;
1876 DRM_UDELAY(1);
1877 }
1878 if (i >= adev->usec_timeout) {
1879 DRM_ERROR("KIQ enable failed (scratch(0x%04X)=0x%08X)\n",
1880 scratch, tmp);
1881 r = -EINVAL;
1882 }
1883 amdgpu_gfx_scratch_free(adev, scratch);
1884
1885 return r;
1851} 1886}
1852 1887
1853static void gfx_v9_0_map_queue_enable(struct amdgpu_ring *kiq_ring, 1888static int gfx_v9_0_map_queue_enable(struct amdgpu_ring *kiq_ring,
1854 struct amdgpu_ring *ring) 1889 struct amdgpu_ring *ring)
1855{ 1890{
1856 struct amdgpu_device *adev = kiq_ring->adev; 1891 struct amdgpu_device *adev = kiq_ring->adev;
1857 uint64_t mqd_addr, wptr_addr; 1892 uint64_t mqd_addr, wptr_addr;
1893 uint32_t scratch, tmp = 0;
1894 int r, i;
1895
1896 r = amdgpu_gfx_scratch_get(adev, &scratch);
1897 if (r) {
1898 DRM_ERROR("Failed to get scratch reg (%d).\n", r);
1899 return r;
1900 }
1901 WREG32(scratch, 0xCAFEDEAD);
1902
1903 r = amdgpu_ring_alloc(kiq_ring, 10);
1904 if (r) {
1905 DRM_ERROR("Failed to lock KIQ (%d).\n", r);
1906 amdgpu_gfx_scratch_free(adev, scratch);
1907 return r;
1908 }
1858 1909
1859 mqd_addr = amdgpu_bo_gpu_offset(ring->mqd_obj); 1910 mqd_addr = amdgpu_bo_gpu_offset(ring->mqd_obj);
1860 wptr_addr = adev->wb.gpu_addr + (ring->wptr_offs * 4); 1911 wptr_addr = adev->wb.gpu_addr + (ring->wptr_offs * 4);
1861 amdgpu_ring_alloc(kiq_ring, 8);
1862 1912
1863 amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_MAP_QUEUES, 5)); 1913 amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_MAP_QUEUES, 5));
1864 /* Q_sel:0, vmid:0, vidmem: 1, engine:0, num_Q:1*/ 1914 /* Q_sel:0, vmid:0, vidmem: 1, engine:0, num_Q:1*/
@@ -1877,8 +1927,26 @@ static void gfx_v9_0_map_queue_enable(struct amdgpu_ring *kiq_ring,
1877 amdgpu_ring_write(kiq_ring, upper_32_bits(mqd_addr)); 1927 amdgpu_ring_write(kiq_ring, upper_32_bits(mqd_addr));
1878 amdgpu_ring_write(kiq_ring, lower_32_bits(wptr_addr)); 1928 amdgpu_ring_write(kiq_ring, lower_32_bits(wptr_addr));
1879 amdgpu_ring_write(kiq_ring, upper_32_bits(wptr_addr)); 1929 amdgpu_ring_write(kiq_ring, upper_32_bits(wptr_addr));
1930 /* write to scratch for completion */
1931 amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_SET_UCONFIG_REG, 1));
1932 amdgpu_ring_write(kiq_ring, (scratch - PACKET3_SET_UCONFIG_REG_START));
1933 amdgpu_ring_write(kiq_ring, 0xDEADBEEF);
1880 amdgpu_ring_commit(kiq_ring); 1934 amdgpu_ring_commit(kiq_ring);
1881 udelay(50); 1935
1936 for (i = 0; i < adev->usec_timeout; i++) {
1937 tmp = RREG32(scratch);
1938 if (tmp == 0xDEADBEEF)
1939 break;
1940 DRM_UDELAY(1);
1941 }
1942 if (i >= adev->usec_timeout) {
1943 DRM_ERROR("KCQ enable failed (scratch(0x%04X)=0x%08X)\n",
1944 scratch, tmp);
1945 r = -EINVAL;
1946 }
1947 amdgpu_gfx_scratch_free(adev, scratch);
1948
1949 return r;
1882} 1950}
1883 1951
1884static int gfx_v9_0_mqd_init(struct amdgpu_ring *ring) 1952static int gfx_v9_0_mqd_init(struct amdgpu_ring *ring)
@@ -2124,6 +2192,7 @@ static int gfx_v9_0_kiq_init_queue(struct amdgpu_ring *ring)
2124 struct v9_mqd *mqd = ring->mqd_ptr; 2192 struct v9_mqd *mqd = ring->mqd_ptr;
2125 bool is_kiq = (ring->funcs->type == AMDGPU_RING_TYPE_KIQ); 2193 bool is_kiq = (ring->funcs->type == AMDGPU_RING_TYPE_KIQ);
2126 int mqd_idx = AMDGPU_MAX_COMPUTE_RINGS; 2194 int mqd_idx = AMDGPU_MAX_COMPUTE_RINGS;
2195 int r;
2127 2196
2128 if (is_kiq) { 2197 if (is_kiq) {
2129 gfx_v9_0_kiq_setting(&kiq->ring); 2198 gfx_v9_0_kiq_setting(&kiq->ring);
@@ -2162,11 +2231,11 @@ static int gfx_v9_0_kiq_init_queue(struct amdgpu_ring *ring)
2162 } 2231 }
2163 2232
2164 if (is_kiq) 2233 if (is_kiq)
2165 gfx_v9_0_kiq_enable(ring); 2234 r = gfx_v9_0_kiq_enable(ring);
2166 else 2235 else
2167 gfx_v9_0_map_queue_enable(&kiq->ring, ring); 2236 r = gfx_v9_0_map_queue_enable(&kiq->ring, ring);
2168 2237
2169 return 0; 2238 return r;
2170} 2239}
2171 2240
2172static int gfx_v9_0_kiq_resume(struct amdgpu_device *adev) 2241static int gfx_v9_0_kiq_resume(struct amdgpu_device *adev)