Skip to contentSkip to conversation

drm/amdgpu: use kernel is_power_of_2 rather than local version

PATCH In review Alex Deucher 2 participants 2 messages Jun 21, 2017 1 message not in the archive

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

PATCH 1/1 drm/amdgpu: use kernel is_power_of_2 rather than local version

Use the kernel provided version.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -16
index 6c64551..b6efda1 100644
@@ -1032,19 +1032,6 @@ static unsigned int amdgpu_vga_set_decode(void *cookie, bool state)
 		return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
 }
 
-/**
- * amdgpu_check_pot_argument - check that argument is a power of two
- *
- * @arg: value to check
- *
- * Validates that a certain argument is a power of two (all asics).
- * Returns true if argument is valid.
- */
-static bool amdgpu_check_pot_argument(int arg)
-{
-	return (arg & (arg - 1)) == 0;
-}
-
 static void amdgpu_check_block_size(struct amdgpu_device *adev)
 {
 	/* defines number of bits in page table versus page directory,
@@ -1078,7 +1065,7 @@ static void amdgpu_check_vm_size(struct amdgpu_device *adev)
 	if (amdgpu_vm_size == -1)
 		return;
 
-	if (!amdgpu_check_pot_argument(amdgpu_vm_size)) {
+	if (!is_power_of_2(amdgpu_vm_size)) {
 		dev_warn(adev->dev, "VM size (%d) must be a power of 2\n",
 			 amdgpu_vm_size);
 		goto def_value;
@@ -1119,7 +1106,7 @@ static void amdgpu_check_arguments(struct amdgpu_device *adev)
 		dev_warn(adev->dev, "sched jobs (%d) must be at least 4\n",
 			 amdgpu_sched_jobs);
 		amdgpu_sched_jobs = 4;
-	} else if (!amdgpu_check_pot_argument(amdgpu_sched_jobs)){
+	} else if (!is_power_of_2(amdgpu_sched_jobs)){
 		dev_warn(adev->dev, "sched jobs (%d) must be a power of 2\n",
 			 amdgpu_sched_jobs);
 		amdgpu_sched_jobs = roundup_pow_of_two(amdgpu_sched_jobs);
@@ -1139,7 +1126,7 @@ static void amdgpu_check_arguments(struct amdgpu_device *adev)
 	amdgpu_check_block_size(adev);
 
 	if (amdgpu_vram_page_split != -1 && (amdgpu_vram_page_split < 16 ||
-	    !amdgpu_check_pot_argument(amdgpu_vram_page_split))) {
+	    !is_power_of_2(amdgpu_vram_page_split))) {
 		dev_warn(adev->dev, "invalid VRAM page split (%d)\n",
 			 amdgpu_vram_page_split);
 		amdgpu_vram_page_split = 1024;
Signature · 6 lines
2.5.5

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

A message that is not in the archive (sent off-list or not yet received): 1498063478-12052-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#2 lore raw

Am 21.06.2017 um 18:44 schrieb Alex Deucher:

Quoted 3 lines

Use the kernel provided version.

Quoted 47 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 19 +++----------------
  1 file changed, 3 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -15
index 6c64551..b6efda1 100644
@@ -1032,19 +1032,6 @@ static unsigned int amdgpu_vga_set_decode(void *cookie, bool state)
  		return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
  }
 
-/**
- * amdgpu_check_pot_argument - check that argument is a power of two
- *
- * @arg: value to check
- *
- * Validates that a certain argument is a power of two (all asics).
- * Returns true if argument is valid.
- */
-static bool amdgpu_check_pot_argument(int arg)
-{
-	return (arg & (arg - 1)) == 0;
-}
-
  static void amdgpu_check_block_size(struct amdgpu_device *adev)
  {
  	/* defines number of bits in page table versus page directory,
@@ -1078,7 +1065,7 @@ static void amdgpu_check_vm_size(struct amdgpu_device *adev)
  	if (amdgpu_vm_size == -1)
  		return;
 
-	if (!amdgpu_check_pot_argument(amdgpu_vm_size)) {
+	if (!is_power_of_2(amdgpu_vm_size)) {
  		dev_warn(adev->dev, "VM size (%d) must be a power of 2\n",
  			 amdgpu_vm_size);
  		goto def_value;
@@ -1119,7 +1106,7 @@ static void amdgpu_check_arguments(struct amdgpu_device *adev)
  		dev_warn(adev->dev, "sched jobs (%d) must be at least 4\n",
  			 amdgpu_sched_jobs);
  		amdgpu_sched_jobs = 4;
-	} else if (!amdgpu_check_pot_argument(amdgpu_sched_jobs)){
+	} else if (!is_power_of_2(amdgpu_sched_jobs)){
  		dev_warn(adev->dev, "sched jobs (%d) must be a power of 2\n",
  			 amdgpu_sched_jobs);
  		amdgpu_sched_jobs = roundup_pow_of_two(amdgpu_sched_jobs);

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static void amdgpu_check_arguments(struct amdgpu_device *adev) · line 1132

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -1139,7 +1126,7 @@ static void amdgpu_check_arguments(struct amdgpu_device *adev)
  	amdgpu_check_block_size(adev);
 
  	if (amdgpu_vram_page_split != -1 && (amdgpu_vram_page_split < 16 ||
-	    !amdgpu_check_pot_argument(amdgpu_vram_page_split))) {
+	    !is_power_of_2(amdgpu_vram_page_split))) {
  		dev_warn(adev->dev, "invalid VRAM page split (%d)\n",
  			 amdgpu_vram_page_split);
  		amdgpu_vram_page_split = 1024;

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