diff options
author | Christian König <christian.koenig@amd.com> | 2018-09-18 08:24:49 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2019-01-14 15:04:47 -0500 |
commit | d81f78b440f314e2a551d938e4c509fca16a8fe7 (patch) | |
tree | f8ffd8455c23b8410ea33ca47e8321be79e96b9b /drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | |
parent | 8bb9eb480d032418bd08d0a6a39e4eaa1dec2fb8 (diff) |
drm/amdgpu: simplify IH programming
Calculate all the addresses and pointers in amdgpu_ih.c
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c index fb8dd6179926..d0a5db777b6d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | |||
@@ -52,6 +52,8 @@ int amdgpu_ih_ring_init(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih, | |||
52 | ih->use_bus_addr = use_bus_addr; | 52 | ih->use_bus_addr = use_bus_addr; |
53 | 53 | ||
54 | if (use_bus_addr) { | 54 | if (use_bus_addr) { |
55 | dma_addr_t dma_addr; | ||
56 | |||
55 | if (ih->ring) | 57 | if (ih->ring) |
56 | return 0; | 58 | return 0; |
57 | 59 | ||
@@ -59,21 +61,26 @@ int amdgpu_ih_ring_init(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih, | |||
59 | * add them to the end of the ring allocation. | 61 | * add them to the end of the ring allocation. |
60 | */ | 62 | */ |
61 | ih->ring = dma_alloc_coherent(adev->dev, ih->ring_size + 8, | 63 | ih->ring = dma_alloc_coherent(adev->dev, ih->ring_size + 8, |
62 | &ih->rb_dma_addr, GFP_KERNEL); | 64 | &dma_addr, GFP_KERNEL); |
63 | if (ih->ring == NULL) | 65 | if (ih->ring == NULL) |
64 | return -ENOMEM; | 66 | return -ENOMEM; |
65 | 67 | ||
66 | memset((void *)ih->ring, 0, ih->ring_size + 8); | 68 | memset((void *)ih->ring, 0, ih->ring_size + 8); |
67 | ih->wptr_offs = (ih->ring_size / 4) + 0; | 69 | ih->gpu_addr = dma_addr; |
68 | ih->rptr_offs = (ih->ring_size / 4) + 1; | 70 | ih->wptr_addr = dma_addr + ih->ring_size; |
71 | ih->wptr_cpu = &ih->ring[ih->ring_size / 4]; | ||
72 | ih->rptr_addr = dma_addr + ih->ring_size + 4; | ||
73 | ih->rptr_cpu = &ih->ring[(ih->ring_size / 4) + 1]; | ||
69 | } else { | 74 | } else { |
70 | r = amdgpu_device_wb_get(adev, &ih->wptr_offs); | 75 | unsigned wptr_offs, rptr_offs; |
76 | |||
77 | r = amdgpu_device_wb_get(adev, &wptr_offs); | ||
71 | if (r) | 78 | if (r) |
72 | return r; | 79 | return r; |
73 | 80 | ||
74 | r = amdgpu_device_wb_get(adev, &ih->rptr_offs); | 81 | r = amdgpu_device_wb_get(adev, &rptr_offs); |
75 | if (r) { | 82 | if (r) { |
76 | amdgpu_device_wb_free(adev, ih->wptr_offs); | 83 | amdgpu_device_wb_free(adev, wptr_offs); |
77 | return r; | 84 | return r; |
78 | } | 85 | } |
79 | 86 | ||
@@ -82,10 +89,15 @@ int amdgpu_ih_ring_init(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih, | |||
82 | &ih->ring_obj, &ih->gpu_addr, | 89 | &ih->ring_obj, &ih->gpu_addr, |
83 | (void **)&ih->ring); | 90 | (void **)&ih->ring); |
84 | if (r) { | 91 | if (r) { |
85 | amdgpu_device_wb_free(adev, ih->rptr_offs); | 92 | amdgpu_device_wb_free(adev, rptr_offs); |
86 | amdgpu_device_wb_free(adev, ih->wptr_offs); | 93 | amdgpu_device_wb_free(adev, wptr_offs); |
87 | return r; | 94 | return r; |
88 | } | 95 | } |
96 | |||
97 | ih->wptr_addr = adev->wb.gpu_addr + wptr_offs * 4; | ||
98 | ih->wptr_cpu = &adev->wb.wb[wptr_offs]; | ||
99 | ih->rptr_addr = adev->wb.gpu_addr + rptr_offs * 4; | ||
100 | ih->rptr_cpu = &adev->wb.wb[rptr_offs]; | ||
89 | } | 101 | } |
90 | return 0; | 102 | return 0; |
91 | } | 103 | } |
@@ -109,13 +121,13 @@ void amdgpu_ih_ring_fini(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih) | |||
109 | * add them to the end of the ring allocation. | 121 | * add them to the end of the ring allocation. |
110 | */ | 122 | */ |
111 | dma_free_coherent(adev->dev, ih->ring_size + 8, | 123 | dma_free_coherent(adev->dev, ih->ring_size + 8, |
112 | (void *)ih->ring, ih->rb_dma_addr); | 124 | (void *)ih->ring, ih->gpu_addr); |
113 | ih->ring = NULL; | 125 | ih->ring = NULL; |
114 | } else { | 126 | } else { |
115 | amdgpu_bo_free_kernel(&ih->ring_obj, &ih->gpu_addr, | 127 | amdgpu_bo_free_kernel(&ih->ring_obj, &ih->gpu_addr, |
116 | (void **)&ih->ring); | 128 | (void **)&ih->ring); |
117 | amdgpu_device_wb_free(adev, ih->wptr_offs); | 129 | amdgpu_device_wb_free(adev, (ih->wptr_addr - ih->gpu_addr) / 4); |
118 | amdgpu_device_wb_free(adev, ih->rptr_offs); | 130 | amdgpu_device_wb_free(adev, (ih->rptr_addr - ih->gpu_addr) / 4); |
119 | } | 131 | } |
120 | } | 132 | } |
121 | 133 | ||