Skip to contentSkip to conversation

drm/amdgpu: move amdgpu_num_kcq handling to a helper

PATCH In review Alex Deucher 3 participants 3 messages Oct 16, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: move amdgpu_num_kcq handling to a helper

Add a helper so we can set per asic default values. Also, the module parameter is currently clamped to 8, but clamp it per asic just in case some asics have different limits in the future. Enable the option on gfx6,7 as well for consistency.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  7 -------
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 11 +++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h    |  1 +
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c     |  3 ++-
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c      |  3 ++-
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c      |  3 ++-
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c      |  3 ++-
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c      |  3 ++-
 8 files changed, 22 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -7
index abddcd9dab3d..fb9e61f861e9 100644
@@ -1374,13 +1374,6 @@ static int amdgpu_device_check_arguments(struct amdgpu_device *adev)
 
 	amdgpu_gmc_tmz_set(adev);
 
-	if (amdgpu_num_kcq == -1) {
-		amdgpu_num_kcq = 8;
-	} else if (amdgpu_num_kcq > 8 || amdgpu_num_kcq < 0) {
-		amdgpu_num_kcq = 8;
-		dev_warn(adev->dev, "set kernel compute queue number to 8 due to invalid parameter provided by user\n");
-	}
-
 	amdgpu_gmc_noretry_set(adev);
 
 	return 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +11 -0
index 8c9bacfdbc30..e584f48f3b54 100644
@@ -804,3 +804,14 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v)
 failed_kiq_write:
 	dev_err(adev->dev, "failed to write reg:%x\n", reg);
 }
+
+int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev)
+{
+	if (amdgpu_num_kcq == -1) {
+		return 8;
+	} else if (amdgpu_num_kcq > 8 || amdgpu_num_kcq < 0) {
+		dev_warn(adev->dev, "set kernel compute queue number to 8 due to invalid parameter provided by user\n");
+		return 8;
+	}
+	return amdgpu_num_kcq;
+}
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1 -0
index 190753930b11..786eb4aa7314 100644
@@ -393,4 +393,5 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev,
 				  struct amdgpu_iv_entry *entry);
 uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg);
 void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v);
+int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev);
 #endif
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2 -1
index 669c352c27af..b4df472194af 100644
@@ -7406,7 +7406,8 @@ static int gfx_v10_0_early_init(void *handle)
 		break;
 	}
 
-	adev->gfx.num_compute_rings = amdgpu_num_kcq;
+	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
+					  AMDGPU_MAX_COMPUTE_RINGS);
 
 	gfx_v10_0_set_kiq_pm4_funcs(adev);
 	gfx_v10_0_set_ring_funcs(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +2 -1
index 79c52c7a02e3..671c46ebeced 100644
@@ -3064,7 +3064,8 @@ static int gfx_v6_0_early_init(void *handle)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
 	adev->gfx.num_gfx_rings = GFX6_NUM_GFX_RINGS;
-	adev->gfx.num_compute_rings = GFX6_NUM_COMPUTE_RINGS;
+	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
+					  GFX6_NUM_COMPUTE_RINGS);
 	adev->gfx.funcs = &gfx_v6_0_gfx_funcs;
 	adev->gfx.rlc.funcs = &gfx_v6_0_rlc_funcs;
 	gfx_v6_0_set_ring_funcs(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +2 -1
index 04eaf3a8fddb..cb07bc21dcbe 100644
@@ -4238,7 +4238,8 @@ static int gfx_v7_0_early_init(void *handle)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
 	adev->gfx.num_gfx_rings = GFX7_NUM_GFX_RINGS;
-	adev->gfx.num_compute_rings = AMDGPU_MAX_COMPUTE_RINGS;
+	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
+					  AMDGPU_MAX_COMPUTE_RINGS);
 	adev->gfx.funcs = &gfx_v7_0_gfx_funcs;
 	adev->gfx.rlc.funcs = &gfx_v7_0_rlc_funcs;
 	gfx_v7_0_set_ring_funcs(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +2 -1
index 94b7e0531d09..6487ea3cfdd2 100644
@@ -5295,7 +5295,8 @@ static int gfx_v8_0_early_init(void *handle)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
 	adev->gfx.num_gfx_rings = GFX8_NUM_GFX_RINGS;
-	adev->gfx.num_compute_rings = amdgpu_num_kcq;
+	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
+					  AMDGPU_MAX_COMPUTE_RINGS);
 	adev->gfx.funcs = &gfx_v8_0_gfx_funcs;
 	gfx_v8_0_set_ring_funcs(adev);
 	gfx_v8_0_set_irq_funcs(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -1
index 2c3224948ea5..d3df4c0441a2 100644
@@ -4635,7 +4635,8 @@ static int gfx_v9_0_early_init(void *handle)
 		adev->gfx.num_gfx_rings = 0;
 	else
 		adev->gfx.num_gfx_rings = GFX9_NUM_GFX_RINGS;
-	adev->gfx.num_compute_rings = amdgpu_num_kcq;
+	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
+					  AMDGPU_MAX_COMPUTE_RINGS);
 	gfx_v9_0_set_kiq_pm4_funcs(adev);
 	gfx_v9_0_set_ring_funcs(adev);
 	gfx_v9_0_set_irq_funcs(adev);
Signature · 6 lines
2.25.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Acked-by Nirmoy Das on v1 1/1
#1 lore raw
Quoted 125 lines · Alex Deucher

Add a helper so we can set per asic default values. Also, the module parameter is currently clamped to 8, but clamp it per asic just in case some asics have different limits in the future. Enable the option on gfx6,7 as well for consistency.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  7 -------
  drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 11 +++++++++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h    |  1 +
  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c     |  3 ++-
  drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c      |  3 ++-
  drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c      |  3 ++-
  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c      |  3 ++-
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c      |  3 ++-
  8 files changed, 22 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -7
index abddcd9dab3d..fb9e61f861e9 100644
@@ -1374,13 +1374,6 @@ static int amdgpu_device_check_arguments(struct amdgpu_device *adev)
 
  	amdgpu_gmc_tmz_set(adev);
 
-	if (amdgpu_num_kcq == -1) {
-		amdgpu_num_kcq = 8;
-	} else if (amdgpu_num_kcq > 8 || amdgpu_num_kcq < 0) {
-		amdgpu_num_kcq = 8;
-		dev_warn(adev->dev, "set kernel compute queue number to 8 due to invalid parameter provided by user\n");
-	}
-
  	amdgpu_gmc_noretry_set(adev);
 
  	return 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +11 -0
index 8c9bacfdbc30..e584f48f3b54 100644
@@ -804,3 +804,14 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v)
  failed_kiq_write:
  	dev_err(adev->dev, "failed to write reg:%x\n", reg);
  }
+
+int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev)
+{
+	if (amdgpu_num_kcq == -1) {
+		return 8;
+	} else if (amdgpu_num_kcq > 8 || amdgpu_num_kcq < 0) {
+		dev_warn(adev->dev, "set kernel compute queue number to 8 due to invalid parameter provided by user\n");
+		return 8;
+	}
+	return amdgpu_num_kcq;
+}
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1 -0
index 190753930b11..786eb4aa7314 100644
@@ -393,4 +393,5 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev,
  				  struct amdgpu_iv_entry *entry);
  uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg);
  void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v);
+int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev);
  #endif
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2 -1
index 669c352c27af..b4df472194af 100644
@@ -7406,7 +7406,8 @@ static int gfx_v10_0_early_init(void *handle)
  		break;
  	}
 
-	adev->gfx.num_compute_rings = amdgpu_num_kcq;
+	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
+					  AMDGPU_MAX_COMPUTE_RINGS);
 
  	gfx_v10_0_set_kiq_pm4_funcs(adev);
  	gfx_v10_0_set_ring_funcs(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +2 -1
index 79c52c7a02e3..671c46ebeced 100644
@@ -3064,7 +3064,8 @@ static int gfx_v6_0_early_init(void *handle)
  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
  	adev->gfx.num_gfx_rings = GFX6_NUM_GFX_RINGS;
-	adev->gfx.num_compute_rings = GFX6_NUM_COMPUTE_RINGS;
+	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
+					  GFX6_NUM_COMPUTE_RINGS);
  	adev->gfx.funcs = &gfx_v6_0_gfx_funcs;
  	adev->gfx.rlc.funcs = &gfx_v6_0_rlc_funcs;
  	gfx_v6_0_set_ring_funcs(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +2 -1
index 04eaf3a8fddb..cb07bc21dcbe 100644
@@ -4238,7 +4238,8 @@ static int gfx_v7_0_early_init(void *handle)
  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
  	adev->gfx.num_gfx_rings = GFX7_NUM_GFX_RINGS;
-	adev->gfx.num_compute_rings = AMDGPU_MAX_COMPUTE_RINGS;
+	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
+					  AMDGPU_MAX_COMPUTE_RINGS);
  	adev->gfx.funcs = &gfx_v7_0_gfx_funcs;
  	adev->gfx.rlc.funcs = &gfx_v7_0_rlc_funcs;
  	gfx_v7_0_set_ring_funcs(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +2 -1
index 94b7e0531d09..6487ea3cfdd2 100644
@@ -5295,7 +5295,8 @@ static int gfx_v8_0_early_init(void *handle)
  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
  	adev->gfx.num_gfx_rings = GFX8_NUM_GFX_RINGS;
-	adev->gfx.num_compute_rings = amdgpu_num_kcq;
+	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
+					  AMDGPU_MAX_COMPUTE_RINGS);
  	adev->gfx.funcs = &gfx_v8_0_gfx_funcs;
  	gfx_v8_0_set_ring_funcs(adev);
  	gfx_v8_0_set_irq_funcs(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -0
index 2c3224948ea5..d3df4c0441a2 100644

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_early_init(void *handle) · line 4642

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -1
@@ -4635,7 +4635,8 @@ static int gfx_v9_0_early_init(void *handle)
  		adev->gfx.num_gfx_rings = 0;
  	else
  		adev->gfx.num_gfx_rings = GFX9_NUM_GFX_RINGS;
-	adev->gfx.num_compute_rings = amdgpu_num_kcq;
+	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
+					  AMDGPU_MAX_COMPUTE_RINGS);
  	gfx_v9_0_set_kiq_pm4_funcs(adev);
  	gfx_v9_0_set_ring_funcs(adev);
  	gfx_v9_0_set_irq_funcs(adev);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by on v1 1/1
#2 lore raw
In reply to Alex Deucher

Am 2020-10-16 um 10:20 a.m. schrieb Alex Deucher:

Quoted 6 lines

Add a helper so we can set per asic default values. Also, the module parameter is currently clamped to 8, but clamp it per asic just in case some asics have different limits in the future. Enable the option on gfx6,7 as well for consistency.

Quoted 119 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  7 -------
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 11 +++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h    |  1 +
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c     |  3 ++-
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c      |  3 ++-
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c      |  3 ++-
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c      |  3 ++-
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c      |  3 ++-
 8 files changed, 22 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -7
index abddcd9dab3d..fb9e61f861e9 100644
@@ -1374,13 +1374,6 @@ static int amdgpu_device_check_arguments(struct amdgpu_device *adev)
 
 	amdgpu_gmc_tmz_set(adev);
 
-	if (amdgpu_num_kcq == -1) {
-		amdgpu_num_kcq = 8;
-	} else if (amdgpu_num_kcq > 8 || amdgpu_num_kcq < 0) {
-		amdgpu_num_kcq = 8;
-		dev_warn(adev->dev, "set kernel compute queue number to 8 due to invalid parameter provided by user\n");
-	}
-
 	amdgpu_gmc_noretry_set(adev);
 
 	return 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +11 -0
index 8c9bacfdbc30..e584f48f3b54 100644
@@ -804,3 +804,14 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v)
 failed_kiq_write:
 	dev_err(adev->dev, "failed to write reg:%x\n", reg);
 }
+
+int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev)
+{
+	if (amdgpu_num_kcq == -1) {
+		return 8;
+	} else if (amdgpu_num_kcq > 8 || amdgpu_num_kcq < 0) {
+		dev_warn(adev->dev, "set kernel compute queue number to 8 due to invalid parameter provided by user\n");
+		return 8;
+	}
+	return amdgpu_num_kcq;
+}
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1 -0
index 190753930b11..786eb4aa7314 100644
@@ -393,4 +393,5 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev,
 				  struct amdgpu_iv_entry *entry);
 uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg);
 void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v);
+int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev);
 #endif
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2 -1
index 669c352c27af..b4df472194af 100644
@@ -7406,7 +7406,8 @@ static int gfx_v10_0_early_init(void *handle)
 		break;
 	}
 
-	adev->gfx.num_compute_rings = amdgpu_num_kcq;
+	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
+					  AMDGPU_MAX_COMPUTE_RINGS);
 
 	gfx_v10_0_set_kiq_pm4_funcs(adev);
 	gfx_v10_0_set_ring_funcs(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +2 -1
index 79c52c7a02e3..671c46ebeced 100644
@@ -3064,7 +3064,8 @@ static int gfx_v6_0_early_init(void *handle)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
 	adev->gfx.num_gfx_rings = GFX6_NUM_GFX_RINGS;
-	adev->gfx.num_compute_rings = GFX6_NUM_COMPUTE_RINGS;
+	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
+					  GFX6_NUM_COMPUTE_RINGS);
 	adev->gfx.funcs = &gfx_v6_0_gfx_funcs;
 	adev->gfx.rlc.funcs = &gfx_v6_0_rlc_funcs;
 	gfx_v6_0_set_ring_funcs(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +2 -1
index 04eaf3a8fddb..cb07bc21dcbe 100644
@@ -4238,7 +4238,8 @@ static int gfx_v7_0_early_init(void *handle)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
 	adev->gfx.num_gfx_rings = GFX7_NUM_GFX_RINGS;
-	adev->gfx.num_compute_rings = AMDGPU_MAX_COMPUTE_RINGS;
+	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
+					  AMDGPU_MAX_COMPUTE_RINGS);
 	adev->gfx.funcs = &gfx_v7_0_gfx_funcs;
 	adev->gfx.rlc.funcs = &gfx_v7_0_rlc_funcs;
 	gfx_v7_0_set_ring_funcs(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +2 -1
index 94b7e0531d09..6487ea3cfdd2 100644
@@ -5295,7 +5295,8 @@ static int gfx_v8_0_early_init(void *handle)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
 	adev->gfx.num_gfx_rings = GFX8_NUM_GFX_RINGS;
-	adev->gfx.num_compute_rings = amdgpu_num_kcq;
+	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
+					  AMDGPU_MAX_COMPUTE_RINGS);
 	adev->gfx.funcs = &gfx_v8_0_gfx_funcs;
 	gfx_v8_0_set_ring_funcs(adev);
 	gfx_v8_0_set_irq_funcs(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -0
index 2c3224948ea5..d3df4c0441a2 100644

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_early_init(void *handle) · line 4642

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -1
@@ -4635,7 +4635,8 @@ static int gfx_v9_0_early_init(void *handle)
 		adev->gfx.num_gfx_rings = 0;
 	else
 		adev->gfx.num_gfx_rings = GFX9_NUM_GFX_RINGS;
-	adev->gfx.num_compute_rings = amdgpu_num_kcq;
+	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
+					  AMDGPU_MAX_COMPUTE_RINGS);
 	gfx_v9_0_set_kiq_pm4_funcs(adev);
 	gfx_v9_0_set_ring_funcs(adev);
 	gfx_v9_0_set_irq_funcs(adev);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx