aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2016-06-17 13:31:33 -0400
committerAlex Deucher <alexander.deucher@amd.com>2016-07-07 14:54:44 -0400
commit6f8941a2308811626edc083c70584837d54e0382 (patch)
tree4c3ff65c0a0d5f9cfcbdc13d138e23c0e3f8a746
parent8b2ac103208b6933e265b3dc81776c2974cb5c7a (diff)
drm/amdgpu: add disable_cu parameter
This parameter will allow disabling individual CUs on module load, e.g. amdgpu.disable_cu=2.0.3,2.0.4 to disable CUs 3 and 4 of SE2. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c44
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h2
4 files changed, 51 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index be2e2f450bf5..c1abe0900f48 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -90,6 +90,7 @@ extern unsigned amdgpu_pcie_gen_cap;
90extern unsigned amdgpu_pcie_lane_cap; 90extern unsigned amdgpu_pcie_lane_cap;
91extern unsigned amdgpu_cg_mask; 91extern unsigned amdgpu_cg_mask;
92extern unsigned amdgpu_pg_mask; 92extern unsigned amdgpu_pg_mask;
93extern char *amdgpu_disable_cu;
93 94
94#define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000 95#define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000
95#define AMDGPU_MAX_USEC_TIMEOUT 100000 /* 100 ms */ 96#define AMDGPU_MAX_USEC_TIMEOUT 100000 /* 100 ms */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 17bf19b063b0..3cea56942f52 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -87,6 +87,7 @@ unsigned amdgpu_pcie_gen_cap = 0;
87unsigned amdgpu_pcie_lane_cap = 0; 87unsigned amdgpu_pcie_lane_cap = 0;
88unsigned amdgpu_cg_mask = 0xffffffff; 88unsigned amdgpu_cg_mask = 0xffffffff;
89unsigned amdgpu_pg_mask = 0xffffffff; 89unsigned amdgpu_pg_mask = 0xffffffff;
90char *amdgpu_disable_cu = NULL;
90 91
91MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes"); 92MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes");
92module_param_named(vramlimit, amdgpu_vram_limit, int, 0600); 93module_param_named(vramlimit, amdgpu_vram_limit, int, 0600);
@@ -180,6 +181,9 @@ module_param_named(cg_mask, amdgpu_cg_mask, uint, 0444);
180MODULE_PARM_DESC(pg_mask, "Powergating flags mask (0 = disable power gating)"); 181MODULE_PARM_DESC(pg_mask, "Powergating flags mask (0 = disable power gating)");
181module_param_named(pg_mask, amdgpu_pg_mask, uint, 0444); 182module_param_named(pg_mask, amdgpu_pg_mask, uint, 0444);
182 183
184MODULE_PARM_DESC(disable_cu, "Disable CUs (se.sh.cu,...)");
185module_param_named(disable_cu, amdgpu_disable_cu, charp, 0444);
186
183static const struct pci_device_id pciidlist[] = { 187static const struct pci_device_id pciidlist[] = {
184#ifdef CONFIG_DRM_AMDGPU_CIK 188#ifdef CONFIG_DRM_AMDGPU_CIK
185 /* Kaveri */ 189 /* Kaveri */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 9f95da4f0536..a074edd95c70 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -70,3 +70,47 @@ void amdgpu_gfx_scratch_free(struct amdgpu_device *adev, uint32_t reg)
70 } 70 }
71 } 71 }
72} 72}
73
74/**
75 * amdgpu_gfx_parse_disable_cu - Parse the disable_cu module parameter
76 *
77 * @mask: array in which the per-shader array disable masks will be stored
78 * @max_se: number of SEs
79 * @max_sh: number of SHs
80 *
81 * The bitmask of CUs to be disabled in the shader array determined by se and
82 * sh is stored in mask[se * max_sh + sh].
83 */
84void amdgpu_gfx_parse_disable_cu(unsigned *mask, unsigned max_se, unsigned max_sh)
85{
86 unsigned se, sh, cu;
87 const char *p;
88
89 memset(mask, 0, sizeof(*mask) * max_se * max_sh);
90
91 if (!amdgpu_disable_cu || !*amdgpu_disable_cu)
92 return;
93
94 p = amdgpu_disable_cu;
95 for (;;) {
96 char *next;
97 int ret = sscanf(p, "%u.%u.%u", &se, &sh, &cu);
98 if (ret < 3) {
99 DRM_ERROR("amdgpu: could not parse disable_cu\n");
100 return;
101 }
102
103 if (se < max_se && sh < max_sh && cu < 16) {
104 DRM_INFO("amdgpu: disabling CU %u.%u.%u\n", se, sh, cu);
105 mask[se * max_sh + sh] |= 1u << cu;
106 } else {
107 DRM_ERROR("amdgpu: disable_cu %u.%u.%u is out of range\n",
108 se, sh, cu);
109 }
110
111 next = strchr(p, ',');
112 if (!next)
113 break;
114 p = next + 1;
115 }
116}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
index dc06cbda7be6..51321e154c09 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
@@ -27,4 +27,6 @@
27int amdgpu_gfx_scratch_get(struct amdgpu_device *adev, uint32_t *reg); 27int amdgpu_gfx_scratch_get(struct amdgpu_device *adev, uint32_t *reg);
28void amdgpu_gfx_scratch_free(struct amdgpu_device *adev, uint32_t reg); 28void amdgpu_gfx_scratch_free(struct amdgpu_device *adev, uint32_t reg);
29 29
30unsigned amdgpu_gfx_parse_disable_cu(unsigned *mask, unsigned max_se, unsigned max_sh);
31
30#endif 32#endif