diff options
author | Ken Wang <Qingqing.Wang@amd.com> | 2016-03-18 03:08:49 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-03-29 23:53:35 -0400 |
commit | 7014285ade54bae2fe03aa397aa45846a0cd3e31 (patch) | |
tree | c006fa04728f5049b1675b9113ff910468582296 | |
parent | 536fbf946cf84ff60cdef471c23ab96058e62f39 (diff) |
drm/amdgpu: add 64bit wb functions
Newer asics need 64 bit writeback slots.
Reviewed-by: Christian König <christian.koenig@amd.com>
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>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 39 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 50 |
3 files changed, 78 insertions, 13 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 93ecf692b9f6..9c1ce40b33b2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -1021,6 +1021,8 @@ struct amdgpu_wb { | |||
1021 | 1021 | ||
1022 | int amdgpu_wb_get(struct amdgpu_device *adev, u32 *wb); | 1022 | int amdgpu_wb_get(struct amdgpu_device *adev, u32 *wb); |
1023 | void amdgpu_wb_free(struct amdgpu_device *adev, u32 wb); | 1023 | void amdgpu_wb_free(struct amdgpu_device *adev, u32 wb); |
1024 | int amdgpu_wb_get_64bit(struct amdgpu_device *adev, u32 *wb); | ||
1025 | void amdgpu_wb_free_64bit(struct amdgpu_device *adev, u32 wb); | ||
1024 | 1026 | ||
1025 | void amdgpu_get_pcie_info(struct amdgpu_device *adev); | 1027 | void amdgpu_get_pcie_info(struct amdgpu_device *adev); |
1026 | 1028 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index ffaa703e89f5..fcf83178b113 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -516,6 +516,29 @@ int amdgpu_wb_get(struct amdgpu_device *adev, u32 *wb) | |||
516 | } | 516 | } |
517 | 517 | ||
518 | /** | 518 | /** |
519 | * amdgpu_wb_get_64bit - Allocate a wb entry | ||
520 | * | ||
521 | * @adev: amdgpu_device pointer | ||
522 | * @wb: wb index | ||
523 | * | ||
524 | * Allocate a wb slot for use by the driver (all asics). | ||
525 | * Returns 0 on success or -EINVAL on failure. | ||
526 | */ | ||
527 | int amdgpu_wb_get_64bit(struct amdgpu_device *adev, u32 *wb) | ||
528 | { | ||
529 | unsigned long offset = bitmap_find_next_zero_area_off(adev->wb.used, | ||
530 | adev->wb.num_wb, 0, 2, 7, 0); | ||
531 | if ((offset + 1) < adev->wb.num_wb) { | ||
532 | __set_bit(offset, adev->wb.used); | ||
533 | __set_bit(offset + 1, adev->wb.used); | ||
534 | *wb = offset; | ||
535 | return 0; | ||
536 | } else { | ||
537 | return -EINVAL; | ||
538 | } | ||
539 | } | ||
540 | |||
541 | /** | ||
519 | * amdgpu_wb_free - Free a wb entry | 542 | * amdgpu_wb_free - Free a wb entry |
520 | * | 543 | * |
521 | * @adev: amdgpu_device pointer | 544 | * @adev: amdgpu_device pointer |
@@ -530,6 +553,22 @@ void amdgpu_wb_free(struct amdgpu_device *adev, u32 wb) | |||
530 | } | 553 | } |
531 | 554 | ||
532 | /** | 555 | /** |
556 | * amdgpu_wb_free_64bit - Free a wb entry | ||
557 | * | ||
558 | * @adev: amdgpu_device pointer | ||
559 | * @wb: wb index | ||
560 | * | ||
561 | * Free a wb slot allocated for use by the driver (all asics) | ||
562 | */ | ||
563 | void amdgpu_wb_free_64bit(struct amdgpu_device *adev, u32 wb) | ||
564 | { | ||
565 | if ((wb + 1) < adev->wb.num_wb) { | ||
566 | __clear_bit(wb, adev->wb.used); | ||
567 | __clear_bit(wb + 1, adev->wb.used); | ||
568 | } | ||
569 | } | ||
570 | |||
571 | /** | ||
533 | * amdgpu_vram_location - try to find VRAM location | 572 | * amdgpu_vram_location - try to find VRAM location |
534 | * @adev: amdgpu device structure holding all necessary informations | 573 | * @adev: amdgpu device structure holding all necessary informations |
535 | * @mc: memory controller structure holding memory informations | 574 | * @mc: memory controller structure holding memory informations |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c index c9b536f4b019..bfd4022210ed 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | |||
@@ -182,16 +182,32 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, | |||
182 | return r; | 182 | return r; |
183 | } | 183 | } |
184 | 184 | ||
185 | r = amdgpu_wb_get(adev, &ring->rptr_offs); | 185 | if (ring->funcs->support_64bit_ptrs) { |
186 | if (r) { | 186 | r = amdgpu_wb_get_64bit(adev, &ring->rptr_offs); |
187 | dev_err(adev->dev, "(%d) ring rptr_offs wb alloc failed\n", r); | 187 | if (r) { |
188 | return r; | 188 | dev_err(adev->dev, "(%d) ring rptr_offs wb alloc failed\n", r); |
189 | } | 189 | return r; |
190 | } | ||
191 | |||
192 | r = amdgpu_wb_get_64bit(adev, &ring->wptr_offs); | ||
193 | if (r) { | ||
194 | dev_err(adev->dev, "(%d) ring wptr_offs wb alloc failed\n", r); | ||
195 | return r; | ||
196 | } | ||
197 | |||
198 | } else { | ||
199 | r = amdgpu_wb_get(adev, &ring->rptr_offs); | ||
200 | if (r) { | ||
201 | dev_err(adev->dev, "(%d) ring rptr_offs wb alloc failed\n", r); | ||
202 | return r; | ||
203 | } | ||
204 | |||
205 | r = amdgpu_wb_get(adev, &ring->wptr_offs); | ||
206 | if (r) { | ||
207 | dev_err(adev->dev, "(%d) ring wptr_offs wb alloc failed\n", r); | ||
208 | return r; | ||
209 | } | ||
190 | 210 | ||
191 | r = amdgpu_wb_get(adev, &ring->wptr_offs); | ||
192 | if (r) { | ||
193 | dev_err(adev->dev, "(%d) ring wptr_offs wb alloc failed\n", r); | ||
194 | return r; | ||
195 | } | 211 | } |
196 | 212 | ||
197 | r = amdgpu_wb_get(adev, &ring->fence_offs); | 213 | r = amdgpu_wb_get(adev, &ring->fence_offs); |
@@ -256,10 +272,18 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring) | |||
256 | { | 272 | { |
257 | ring->ready = false; | 273 | ring->ready = false; |
258 | 274 | ||
259 | amdgpu_wb_free(ring->adev, ring->cond_exe_offs); | 275 | if (ring->funcs->support_64bit_ptrs) { |
260 | amdgpu_wb_free(ring->adev, ring->fence_offs); | 276 | amdgpu_wb_free_64bit(ring->adev, ring->cond_exe_offs); |
261 | amdgpu_wb_free(ring->adev, ring->rptr_offs); | 277 | amdgpu_wb_free_64bit(ring->adev, ring->fence_offs); |
262 | amdgpu_wb_free(ring->adev, ring->wptr_offs); | 278 | amdgpu_wb_free_64bit(ring->adev, ring->rptr_offs); |
279 | amdgpu_wb_free_64bit(ring->adev, ring->wptr_offs); | ||
280 | } else { | ||
281 | amdgpu_wb_free(ring->adev, ring->cond_exe_offs); | ||
282 | amdgpu_wb_free(ring->adev, ring->fence_offs); | ||
283 | amdgpu_wb_free(ring->adev, ring->rptr_offs); | ||
284 | amdgpu_wb_free(ring->adev, ring->wptr_offs); | ||
285 | } | ||
286 | |||
263 | 287 | ||
264 | amdgpu_bo_free_kernel(&ring->ring_obj, | 288 | amdgpu_bo_free_kernel(&ring->ring_obj, |
265 | &ring->gpu_addr, | 289 | &ring->gpu_addr, |