diff options
author | Jammy Zhou <Jammy.Zhou@amd.com> | 2015-09-01 01:04:08 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-09-02 12:24:43 -0400 |
commit | edff0e2826412be38f0c7977cbf89262141aad87 (patch) | |
tree | 8f6272e27b1e7f13ed7d65355b50515fdeaea33f /drivers/gpu | |
parent | 4b2f7e2ca94d58ea16e411a1f717392b91f7730a (diff) |
drm/amdgpu: add insert_nop ring func and default implementation
The insert_nop function is added to amdgpu_ring_funcs structure as
well as the default implementation
Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 24 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/cik_sdma.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/vce_v2_0.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 1 |
12 files changed, 36 insertions, 3 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 057e7ef5c0d0..668939a14206 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -343,6 +343,8 @@ struct amdgpu_ring_funcs { | |||
343 | int (*test_ring)(struct amdgpu_ring *ring); | 343 | int (*test_ring)(struct amdgpu_ring *ring); |
344 | int (*test_ib)(struct amdgpu_ring *ring); | 344 | int (*test_ib)(struct amdgpu_ring *ring); |
345 | bool (*is_lockup)(struct amdgpu_ring *ring); | 345 | bool (*is_lockup)(struct amdgpu_ring *ring); |
346 | /* insert NOP packets */ | ||
347 | void (*insert_nop)(struct amdgpu_ring *ring, uint32_t count); | ||
346 | }; | 348 | }; |
347 | 349 | ||
348 | /* | 350 | /* |
@@ -1217,6 +1219,7 @@ int amdgpu_ib_ring_tests(struct amdgpu_device *adev); | |||
1217 | void amdgpu_ring_free_size(struct amdgpu_ring *ring); | 1219 | void amdgpu_ring_free_size(struct amdgpu_ring *ring); |
1218 | int amdgpu_ring_alloc(struct amdgpu_ring *ring, unsigned ndw); | 1220 | int amdgpu_ring_alloc(struct amdgpu_ring *ring, unsigned ndw); |
1219 | int amdgpu_ring_lock(struct amdgpu_ring *ring, unsigned ndw); | 1221 | int amdgpu_ring_lock(struct amdgpu_ring *ring, unsigned ndw); |
1222 | void amdgpu_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count); | ||
1220 | void amdgpu_ring_commit(struct amdgpu_ring *ring); | 1223 | void amdgpu_ring_commit(struct amdgpu_ring *ring); |
1221 | void amdgpu_ring_unlock_commit(struct amdgpu_ring *ring); | 1224 | void amdgpu_ring_unlock_commit(struct amdgpu_ring *ring); |
1222 | void amdgpu_ring_undo(struct amdgpu_ring *ring); | 1225 | void amdgpu_ring_undo(struct amdgpu_ring *ring); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c index 7d442c51063e..9bec91484c24 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | |||
@@ -131,6 +131,21 @@ int amdgpu_ring_lock(struct amdgpu_ring *ring, unsigned ndw) | |||
131 | return 0; | 131 | return 0; |
132 | } | 132 | } |
133 | 133 | ||
134 | /** amdgpu_ring_insert_nop - insert NOP packets | ||
135 | * | ||
136 | * @ring: amdgpu_ring structure holding ring information | ||
137 | * @count: the number of NOP packets to insert | ||
138 | * | ||
139 | * This is the generic insert_nop function for rings except SDMA | ||
140 | */ | ||
141 | void amdgpu_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count) | ||
142 | { | ||
143 | int i; | ||
144 | |||
145 | for (i = 0; i < count; i++) | ||
146 | amdgpu_ring_write(ring, ring->nop); | ||
147 | } | ||
148 | |||
134 | /** | 149 | /** |
135 | * amdgpu_ring_commit - tell the GPU to execute the new | 150 | * amdgpu_ring_commit - tell the GPU to execute the new |
136 | * commands on the ring buffer | 151 | * commands on the ring buffer |
@@ -143,10 +158,13 @@ int amdgpu_ring_lock(struct amdgpu_ring *ring, unsigned ndw) | |||
143 | */ | 158 | */ |
144 | void amdgpu_ring_commit(struct amdgpu_ring *ring) | 159 | void amdgpu_ring_commit(struct amdgpu_ring *ring) |
145 | { | 160 | { |
161 | uint32_t count; | ||
162 | |||
146 | /* We pad to match fetch size */ | 163 | /* We pad to match fetch size */ |
147 | while (ring->wptr & ring->align_mask) { | 164 | count = ring->align_mask + 1 - (ring->wptr & ring->align_mask); |
148 | amdgpu_ring_write(ring, ring->nop); | 165 | count %= ring->align_mask + 1; |
149 | } | 166 | ring->funcs->insert_nop(ring, count); |
167 | |||
150 | mb(); | 168 | mb(); |
151 | amdgpu_ring_set_wptr(ring); | 169 | amdgpu_ring_set_wptr(ring); |
152 | } | 170 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c index cc909c9cee63..f0661b269a63 100644 --- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c +++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c | |||
@@ -1305,6 +1305,7 @@ static const struct amdgpu_ring_funcs cik_sdma_ring_funcs = { | |||
1305 | .test_ring = cik_sdma_ring_test_ring, | 1305 | .test_ring = cik_sdma_ring_test_ring, |
1306 | .test_ib = cik_sdma_ring_test_ib, | 1306 | .test_ib = cik_sdma_ring_test_ib, |
1307 | .is_lockup = cik_sdma_ring_is_lockup, | 1307 | .is_lockup = cik_sdma_ring_is_lockup, |
1308 | .insert_nop = amdgpu_ring_insert_nop, | ||
1308 | }; | 1309 | }; |
1309 | 1310 | ||
1310 | static void cik_sdma_set_ring_funcs(struct amdgpu_device *adev) | 1311 | static void cik_sdma_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c index fab7b236f37f..517a68f82ec3 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | |||
@@ -5598,6 +5598,7 @@ static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_gfx = { | |||
5598 | .test_ring = gfx_v7_0_ring_test_ring, | 5598 | .test_ring = gfx_v7_0_ring_test_ring, |
5599 | .test_ib = gfx_v7_0_ring_test_ib, | 5599 | .test_ib = gfx_v7_0_ring_test_ib, |
5600 | .is_lockup = gfx_v7_0_ring_is_lockup, | 5600 | .is_lockup = gfx_v7_0_ring_is_lockup, |
5601 | .insert_nop = amdgpu_ring_insert_nop, | ||
5601 | }; | 5602 | }; |
5602 | 5603 | ||
5603 | static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_compute = { | 5604 | static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_compute = { |
@@ -5614,6 +5615,7 @@ static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_compute = { | |||
5614 | .test_ring = gfx_v7_0_ring_test_ring, | 5615 | .test_ring = gfx_v7_0_ring_test_ring, |
5615 | .test_ib = gfx_v7_0_ring_test_ib, | 5616 | .test_ib = gfx_v7_0_ring_test_ib, |
5616 | .is_lockup = gfx_v7_0_ring_is_lockup, | 5617 | .is_lockup = gfx_v7_0_ring_is_lockup, |
5618 | .insert_nop = amdgpu_ring_insert_nop, | ||
5617 | }; | 5619 | }; |
5618 | 5620 | ||
5619 | static void gfx_v7_0_set_ring_funcs(struct amdgpu_device *adev) | 5621 | static void gfx_v7_0_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c index 818edb37fa9c..956a35822f86 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | |||
@@ -4378,6 +4378,7 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_gfx = { | |||
4378 | .test_ring = gfx_v8_0_ring_test_ring, | 4378 | .test_ring = gfx_v8_0_ring_test_ring, |
4379 | .test_ib = gfx_v8_0_ring_test_ib, | 4379 | .test_ib = gfx_v8_0_ring_test_ib, |
4380 | .is_lockup = gfx_v8_0_ring_is_lockup, | 4380 | .is_lockup = gfx_v8_0_ring_is_lockup, |
4381 | .insert_nop = amdgpu_ring_insert_nop, | ||
4381 | }; | 4382 | }; |
4382 | 4383 | ||
4383 | static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute = { | 4384 | static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute = { |
@@ -4394,6 +4395,7 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute = { | |||
4394 | .test_ring = gfx_v8_0_ring_test_ring, | 4395 | .test_ring = gfx_v8_0_ring_test_ring, |
4395 | .test_ib = gfx_v8_0_ring_test_ib, | 4396 | .test_ib = gfx_v8_0_ring_test_ib, |
4396 | .is_lockup = gfx_v8_0_ring_is_lockup, | 4397 | .is_lockup = gfx_v8_0_ring_is_lockup, |
4398 | .insert_nop = amdgpu_ring_insert_nop, | ||
4397 | }; | 4399 | }; |
4398 | 4400 | ||
4399 | static void gfx_v8_0_set_ring_funcs(struct amdgpu_device *adev) | 4401 | static void gfx_v8_0_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c index 2457bf3e3a1e..1b913bce2599 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | |||
@@ -1316,6 +1316,7 @@ static const struct amdgpu_ring_funcs sdma_v2_4_ring_funcs = { | |||
1316 | .test_ring = sdma_v2_4_ring_test_ring, | 1316 | .test_ring = sdma_v2_4_ring_test_ring, |
1317 | .test_ib = sdma_v2_4_ring_test_ib, | 1317 | .test_ib = sdma_v2_4_ring_test_ib, |
1318 | .is_lockup = sdma_v2_4_ring_is_lockup, | 1318 | .is_lockup = sdma_v2_4_ring_is_lockup, |
1319 | .insert_nop = amdgpu_ring_insert_nop, | ||
1319 | }; | 1320 | }; |
1320 | 1321 | ||
1321 | static void sdma_v2_4_set_ring_funcs(struct amdgpu_device *adev) | 1322 | static void sdma_v2_4_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c index 70b2f03c5712..a7550a8f5d84 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | |||
@@ -1440,6 +1440,7 @@ static const struct amdgpu_ring_funcs sdma_v3_0_ring_funcs = { | |||
1440 | .test_ring = sdma_v3_0_ring_test_ring, | 1440 | .test_ring = sdma_v3_0_ring_test_ring, |
1441 | .test_ib = sdma_v3_0_ring_test_ib, | 1441 | .test_ib = sdma_v3_0_ring_test_ib, |
1442 | .is_lockup = sdma_v3_0_ring_is_lockup, | 1442 | .is_lockup = sdma_v3_0_ring_is_lockup, |
1443 | .insert_nop = amdgpu_ring_insert_nop, | ||
1443 | }; | 1444 | }; |
1444 | 1445 | ||
1445 | static void sdma_v3_0_set_ring_funcs(struct amdgpu_device *adev) | 1446 | static void sdma_v3_0_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c index 9ac383bc6c1f..5fac5da694f0 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c | |||
@@ -886,6 +886,7 @@ static const struct amdgpu_ring_funcs uvd_v4_2_ring_funcs = { | |||
886 | .test_ring = uvd_v4_2_ring_test_ring, | 886 | .test_ring = uvd_v4_2_ring_test_ring, |
887 | .test_ib = uvd_v4_2_ring_test_ib, | 887 | .test_ib = uvd_v4_2_ring_test_ib, |
888 | .is_lockup = amdgpu_ring_test_lockup, | 888 | .is_lockup = amdgpu_ring_test_lockup, |
889 | .insert_nop = amdgpu_ring_insert_nop, | ||
889 | }; | 890 | }; |
890 | 891 | ||
891 | static void uvd_v4_2_set_ring_funcs(struct amdgpu_device *adev) | 892 | static void uvd_v4_2_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c index de4b3f57902d..2d5c59c318af 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | |||
@@ -825,6 +825,7 @@ static const struct amdgpu_ring_funcs uvd_v5_0_ring_funcs = { | |||
825 | .test_ring = uvd_v5_0_ring_test_ring, | 825 | .test_ring = uvd_v5_0_ring_test_ring, |
826 | .test_ib = uvd_v5_0_ring_test_ib, | 826 | .test_ib = uvd_v5_0_ring_test_ib, |
827 | .is_lockup = amdgpu_ring_test_lockup, | 827 | .is_lockup = amdgpu_ring_test_lockup, |
828 | .insert_nop = amdgpu_ring_insert_nop, | ||
828 | }; | 829 | }; |
829 | 830 | ||
830 | static void uvd_v5_0_set_ring_funcs(struct amdgpu_device *adev) | 831 | static void uvd_v5_0_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c index 66c975870e97..d9f553fce531 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | |||
@@ -805,6 +805,7 @@ static const struct amdgpu_ring_funcs uvd_v6_0_ring_funcs = { | |||
805 | .test_ring = uvd_v6_0_ring_test_ring, | 805 | .test_ring = uvd_v6_0_ring_test_ring, |
806 | .test_ib = uvd_v6_0_ring_test_ib, | 806 | .test_ib = uvd_v6_0_ring_test_ib, |
807 | .is_lockup = amdgpu_ring_test_lockup, | 807 | .is_lockup = amdgpu_ring_test_lockup, |
808 | .insert_nop = amdgpu_ring_insert_nop, | ||
808 | }; | 809 | }; |
809 | 810 | ||
810 | static void uvd_v6_0_set_ring_funcs(struct amdgpu_device *adev) | 811 | static void uvd_v6_0_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c index 303d961d57bd..cd16df543f64 100644 --- a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c | |||
@@ -643,6 +643,7 @@ static const struct amdgpu_ring_funcs vce_v2_0_ring_funcs = { | |||
643 | .test_ring = amdgpu_vce_ring_test_ring, | 643 | .test_ring = amdgpu_vce_ring_test_ring, |
644 | .test_ib = amdgpu_vce_ring_test_ib, | 644 | .test_ib = amdgpu_vce_ring_test_ib, |
645 | .is_lockup = amdgpu_ring_test_lockup, | 645 | .is_lockup = amdgpu_ring_test_lockup, |
646 | .insert_nop = amdgpu_ring_insert_nop, | ||
646 | }; | 647 | }; |
647 | 648 | ||
648 | static void vce_v2_0_set_ring_funcs(struct amdgpu_device *adev) | 649 | static void vce_v2_0_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c index 4349658081ff..5642b8eb92ad 100644 --- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | |||
@@ -608,6 +608,7 @@ static const struct amdgpu_ring_funcs vce_v3_0_ring_funcs = { | |||
608 | .test_ring = amdgpu_vce_ring_test_ring, | 608 | .test_ring = amdgpu_vce_ring_test_ring, |
609 | .test_ib = amdgpu_vce_ring_test_ib, | 609 | .test_ib = amdgpu_vce_ring_test_ib, |
610 | .is_lockup = amdgpu_ring_test_lockup, | 610 | .is_lockup = amdgpu_ring_test_lockup, |
611 | .insert_nop = amdgpu_ring_insert_nop, | ||
611 | }; | 612 | }; |
612 | 613 | ||
613 | static void vce_v3_0_set_ring_funcs(struct amdgpu_device *adev) | 614 | static void vce_v3_0_set_ring_funcs(struct amdgpu_device *adev) |