aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlex Deucher <alexander.deucher@amd.com>2017-06-07 12:59:29 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-06-07 18:02:06 -0400
commit2db0cdbe2879f424e28f69755a16344348247d44 (patch)
tree71773c2285989ccfbf9824ee7573bb8abf13fcbe /drivers
parentee04fac3b7cc5093653ba87bfdc241d321f4a3da (diff)
drm/amdgpu: move mec queue helpers to amdgpu_gfx.h
They are gfx related, not general helpers. Reviewed-by: Alex Xie <AlexBin.Xie@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h30
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c9
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h30
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c4
6 files changed, 40 insertions, 39 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index ef34ff214083..3308e6200690 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1831,36 +1831,6 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
1831 return NULL; 1831 return NULL;
1832} 1832}
1833 1833
1834static inline int amdgpu_queue_to_bit(struct amdgpu_device *adev,
1835 int mec, int pipe, int queue)
1836{
1837 int bit = 0;
1838
1839 bit += mec * adev->gfx.mec.num_pipe_per_mec
1840 * adev->gfx.mec.num_queue_per_pipe;
1841 bit += pipe * adev->gfx.mec.num_queue_per_pipe;
1842 bit += queue;
1843
1844 return bit;
1845}
1846
1847static inline void amdgpu_bit_to_queue(struct amdgpu_device *adev, int bit,
1848 int *mec, int *pipe, int *queue)
1849{
1850 *queue = bit % adev->gfx.mec.num_queue_per_pipe;
1851 *pipe = (bit / adev->gfx.mec.num_queue_per_pipe)
1852 % adev->gfx.mec.num_pipe_per_mec;
1853 *mec = (bit / adev->gfx.mec.num_queue_per_pipe)
1854 / adev->gfx.mec.num_pipe_per_mec;
1855
1856}
1857static inline bool amdgpu_is_mec_queue_enabled(struct amdgpu_device *adev,
1858 int mec, int pipe, int queue)
1859{
1860 return test_bit(amdgpu_queue_to_bit(adev, mec, pipe, queue),
1861 adev->gfx.mec.queue_bitmap);
1862}
1863
1864/* 1834/*
1865 * ASICs macro. 1835 * ASICs macro.
1866 */ 1836 */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
index 339e8cd9c289..5f8ada1d872b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
@@ -24,6 +24,7 @@
24#include "amd_shared.h" 24#include "amd_shared.h"
25#include <drm/drmP.h> 25#include <drm/drmP.h>
26#include "amdgpu.h" 26#include "amdgpu.h"
27#include "amdgpu_gfx.h"
27#include <linux/module.h> 28#include <linux/module.h>
28 29
29const struct kfd2kgd_calls *kfd2kgd; 30const struct kfd2kgd_calls *kfd2kgd;
@@ -113,10 +114,10 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
113 114
114 /* remove the KIQ bit as well */ 115 /* remove the KIQ bit as well */
115 if (adev->gfx.kiq.ring.ready) 116 if (adev->gfx.kiq.ring.ready)
116 clear_bit(amdgpu_queue_to_bit(adev, 117 clear_bit(amdgpu_gfx_queue_to_bit(adev,
117 adev->gfx.kiq.ring.me - 1, 118 adev->gfx.kiq.ring.me - 1,
118 adev->gfx.kiq.ring.pipe, 119 adev->gfx.kiq.ring.pipe,
119 adev->gfx.kiq.ring.queue), 120 adev->gfx.kiq.ring.queue),
120 gpu_resources.queue_bitmap); 121 gpu_resources.queue_bitmap);
121 122
122 /* According to linux/bitmap.h we shouldn't use bitmap_clear if 123 /* According to linux/bitmap.h we shouldn't use bitmap_clear if
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
index 9b9ea6eb49c5..fa20438a7b4f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
@@ -45,4 +45,34 @@ static inline u32 amdgpu_gfx_create_bitmask(u32 bit_width)
45 return (u32)((1ULL << bit_width) - 1); 45 return (u32)((1ULL << bit_width) - 1);
46} 46}
47 47
48static inline int amdgpu_gfx_queue_to_bit(struct amdgpu_device *adev,
49 int mec, int pipe, int queue)
50{
51 int bit = 0;
52
53 bit += mec * adev->gfx.mec.num_pipe_per_mec
54 * adev->gfx.mec.num_queue_per_pipe;
55 bit += pipe * adev->gfx.mec.num_queue_per_pipe;
56 bit += queue;
57
58 return bit;
59}
60
61static inline void amdgpu_gfx_bit_to_queue(struct amdgpu_device *adev, int bit,
62 int *mec, int *pipe, int *queue)
63{
64 *queue = bit % adev->gfx.mec.num_queue_per_pipe;
65 *pipe = (bit / adev->gfx.mec.num_queue_per_pipe)
66 % adev->gfx.mec.num_pipe_per_mec;
67 *mec = (bit / adev->gfx.mec.num_queue_per_pipe)
68 / adev->gfx.mec.num_pipe_per_mec;
69
70}
71static inline bool amdgpu_gfx_is_mec_queue_enabled(struct amdgpu_device *adev,
72 int mec, int pipe, int queue)
73{
74 return test_bit(amdgpu_gfx_queue_to_bit(adev, mec, pipe, queue),
75 adev->gfx.mec.queue_bitmap);
76}
77
48#endif 78#endif
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
index 6ffb2da7b3df..d80cf72f6922 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
@@ -4776,7 +4776,7 @@ static int gfx_v7_0_sw_init(void *handle)
4776 for (i = 0; i < adev->gfx.mec.num_mec; ++i) { 4776 for (i = 0; i < adev->gfx.mec.num_mec; ++i) {
4777 for (j = 0; j < adev->gfx.mec.num_queue_per_pipe; j++) { 4777 for (j = 0; j < adev->gfx.mec.num_queue_per_pipe; j++) {
4778 for (k = 0; k < adev->gfx.mec.num_pipe_per_mec; k++) { 4778 for (k = 0; k < adev->gfx.mec.num_pipe_per_mec; k++) {
4779 if (!amdgpu_is_mec_queue_enabled(adev, i, k, j)) 4779 if (!amdgpu_gfx_is_mec_queue_enabled(adev, i, k, j))
4780 continue; 4780 continue;
4781 4781
4782 r = gfx_v7_0_compute_ring_init(adev, 4782 r = gfx_v7_0_compute_ring_init(adev,
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index 8d39e7d3dcce..fc8e03bf7f41 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -1393,7 +1393,7 @@ static int gfx_v8_0_kiq_acquire(struct amdgpu_device *adev,
1393 if (test_bit(queue_bit, adev->gfx.mec.queue_bitmap)) 1393 if (test_bit(queue_bit, adev->gfx.mec.queue_bitmap))
1394 continue; 1394 continue;
1395 1395
1396 amdgpu_bit_to_queue(adev, queue_bit, &mec, &pipe, &queue); 1396 amdgpu_gfx_bit_to_queue(adev, queue_bit, &mec, &pipe, &queue);
1397 1397
1398 /* Using pipes 2/3 from MEC 2 seems cause problems */ 1398 /* Using pipes 2/3 from MEC 2 seems cause problems */
1399 if (mec == 1 && pipe > 1) 1399 if (mec == 1 && pipe > 1)
@@ -2178,7 +2178,7 @@ static int gfx_v8_0_sw_init(void *handle)
2178 for (i = 0; i < adev->gfx.mec.num_mec; ++i) { 2178 for (i = 0; i < adev->gfx.mec.num_mec; ++i) {
2179 for (j = 0; j < adev->gfx.mec.num_queue_per_pipe; j++) { 2179 for (j = 0; j < adev->gfx.mec.num_queue_per_pipe; j++) {
2180 for (k = 0; k < adev->gfx.mec.num_pipe_per_mec; k++) { 2180 for (k = 0; k < adev->gfx.mec.num_pipe_per_mec; k++) {
2181 if (!amdgpu_is_mec_queue_enabled(adev, i, k, j)) 2181 if (!amdgpu_gfx_is_mec_queue_enabled(adev, i, k, j))
2182 continue; 2182 continue;
2183 2183
2184 r = gfx_v8_0_compute_ring_init(adev, 2184 r = gfx_v8_0_compute_ring_init(adev,
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 4c47754f68d8..6d30476f8a43 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -1015,7 +1015,7 @@ static int gfx_v9_0_kiq_acquire(struct amdgpu_device *adev,
1015 if (test_bit(queue_bit, adev->gfx.mec.queue_bitmap)) 1015 if (test_bit(queue_bit, adev->gfx.mec.queue_bitmap))
1016 continue; 1016 continue;
1017 1017
1018 amdgpu_bit_to_queue(adev, queue_bit, &mec, &pipe, &queue); 1018 amdgpu_gfx_bit_to_queue(adev, queue_bit, &mec, &pipe, &queue);
1019 1019
1020 /* Using pipes 2/3 from MEC 2 seems cause problems */ 1020 /* Using pipes 2/3 from MEC 2 seems cause problems */
1021 if (mec == 1 && pipe > 1) 1021 if (mec == 1 && pipe > 1)
@@ -1556,7 +1556,7 @@ static int gfx_v9_0_sw_init(void *handle)
1556 for (i = 0; i < adev->gfx.mec.num_mec; ++i) { 1556 for (i = 0; i < adev->gfx.mec.num_mec; ++i) {
1557 for (j = 0; j < adev->gfx.mec.num_queue_per_pipe; j++) { 1557 for (j = 0; j < adev->gfx.mec.num_queue_per_pipe; j++) {
1558 for (k = 0; k < adev->gfx.mec.num_pipe_per_mec; k++) { 1558 for (k = 0; k < adev->gfx.mec.num_pipe_per_mec; k++) {
1559 if (!amdgpu_is_mec_queue_enabled(adev, i, k, j)) 1559 if (!amdgpu_gfx_is_mec_queue_enabled(adev, i, k, j))
1560 continue; 1560 continue;
1561 1561
1562 r = gfx_v9_0_compute_ring_init(adev, 1562 r = gfx_v9_0_compute_ring_init(adev,