Skip to contentSkip to conversation

drm/radeon: use kernel is_power_of_2 rather than local version

PATCH Applied Jonathan Gray 3 participants 3 messages Dec 30, 2021 – Jan 7, 2022

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

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

Follow the amdgpu change made in 7611750784664db46d0db95631e322aeb263dde7
and replace local radeon function with is_power_of_2().

---
 drivers/gpu/drm/radeon/radeon_device.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)
drivers/gpu/drm/radeon/radeon_device.c +3 -16
index 4f0fbf667431..15692cb241fc 100644
@@ -1085,19 +1085,6 @@ static unsigned int radeon_vga_set_decode(struct pci_dev *pdev, bool state)
 		return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
 }
 
-/**
- * radeon_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 radeon_check_pot_argument(int arg)
-{
-	return (arg & (arg - 1)) == 0;
-}
-
 /**
  * radeon_gart_size_auto - Determine a sensible default GART size
  *                         according to ASIC family.
@@ -1126,7 +1113,7 @@ static int radeon_gart_size_auto(enum radeon_family family)
 static void radeon_check_arguments(struct radeon_device *rdev)
 {
 	/* vramlimit must be a power of two */
-	if (!radeon_check_pot_argument(radeon_vram_limit)) {
+	if (!is_power_of_2(radeon_vram_limit)) {
 		dev_warn(rdev->dev, "vram limit (%d) must be a power of 2\n",
 				radeon_vram_limit);
 		radeon_vram_limit = 0;
@@ -1140,7 +1127,7 @@ static void radeon_check_arguments(struct radeon_device *rdev)
 		dev_warn(rdev->dev, "gart size (%d) too small\n",
 				radeon_gart_size);
 		radeon_gart_size = radeon_gart_size_auto(rdev->family);
-	} else if (!radeon_check_pot_argument(radeon_gart_size)) {
+	} else if (!is_power_of_2(radeon_gart_size)) {
 		dev_warn(rdev->dev, "gart size (%d) must be a power of 2\n",
 				radeon_gart_size);
 		radeon_gart_size = radeon_gart_size_auto(rdev->family);
@@ -1163,7 +1150,7 @@ static void radeon_check_arguments(struct radeon_device *rdev)
 		break;
 	}
 
-	if (!radeon_check_pot_argument(radeon_vm_size)) {
+	if (!is_power_of_2(radeon_vm_size)) {
 		dev_warn(rdev->dev, "VM size (%d) must be a power of 2\n",
 			 radeon_vm_size);
 		radeon_vm_size = 4;
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 30.12.21 um 06:00 schrieb Jonathan Gray:

Quoted 5 lines

Follow the amdgpu change made in 7611750784664db46d0db95631e322aeb263dde7
and replace local radeon function with is_power_of_2().

Quoted 55 lines
---
  drivers/gpu/drm/radeon/radeon_device.c | 19 +++----------------
  1 file changed, 3 insertions(+), 16 deletions(-)
drivers/gpu/drm/radeon/radeon_device.c +3 -16
index 4f0fbf667431..15692cb241fc 100644
@@ -1085,19 +1085,6 @@ static unsigned int radeon_vga_set_decode(struct pci_dev *pdev, bool state)
  		return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
  }
 
-/**
- * radeon_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 radeon_check_pot_argument(int arg)
-{
-	return (arg & (arg - 1)) == 0;
-}
-
  /**
   * radeon_gart_size_auto - Determine a sensible default GART size
   *                         according to ASIC family.
@@ -1126,7 +1113,7 @@ static int radeon_gart_size_auto(enum radeon_family family)
  static void radeon_check_arguments(struct radeon_device *rdev)
  {
  	/* vramlimit must be a power of two */
-	if (!radeon_check_pot_argument(radeon_vram_limit)) {
+	if (!is_power_of_2(radeon_vram_limit)) {
  		dev_warn(rdev->dev, "vram limit (%d) must be a power of 2\n",
  				radeon_vram_limit);
  		radeon_vram_limit = 0;
@@ -1140,7 +1127,7 @@ static void radeon_check_arguments(struct radeon_device *rdev)
  		dev_warn(rdev->dev, "gart size (%d) too small\n",
  				radeon_gart_size);
  		radeon_gart_size = radeon_gart_size_auto(rdev->family);
-	} else if (!radeon_check_pot_argument(radeon_gart_size)) {
+	} else if (!is_power_of_2(radeon_gart_size)) {
  		dev_warn(rdev->dev, "gart size (%d) must be a power of 2\n",
  				radeon_gart_size);
  		radeon_gart_size = radeon_gart_size_auto(rdev->family);
@@ -1163,7 +1150,7 @@ static void radeon_check_arguments(struct radeon_device *rdev)
  		break;
  	}
 
-	if (!radeon_check_pot_argument(radeon_vm_size)) {
+	if (!is_power_of_2(radeon_vm_size)) {
  		dev_warn(rdev->dev, "VM size (%d) must be a power of 2\n",
  			 radeon_vm_size);
  		radeon_vm_size = 4;
Applied
#2 lore raw

Applied. Thanks!

Alex

Quoted 66 lines · Christian König

Am 30.12.21 um 06:00 schrieb Jonathan Gray:

Quoted 5 lines

Follow the amdgpu change made in 7611750784664db46d0db95631e322aeb263dde7
and replace local radeon function with is_power_of_2().

Quoted 55 lines
---
  drivers/gpu/drm/radeon/radeon_device.c | 19 +++----------------
  1 file changed, 3 insertions(+), 16 deletions(-)
drivers/gpu/drm/radeon/radeon_device.c +3 -16
index 4f0fbf667431..15692cb241fc 100644
@@ -1085,19 +1085,6 @@ static unsigned int radeon_vga_set_decode(struct pci_dev *pdev, bool state)
              return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
  }
 
-/**
- * radeon_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 radeon_check_pot_argument(int arg)
-{
-     return (arg & (arg - 1)) == 0;
-}
-
  /**
   * radeon_gart_size_auto - Determine a sensible default GART size
   *                         according to ASIC family.
@@ -1126,7 +1113,7 @@ static int radeon_gart_size_auto(enum radeon_family family)
  static void radeon_check_arguments(struct radeon_device *rdev)
  {
      /* vramlimit must be a power of two */
-     if (!radeon_check_pot_argument(radeon_vram_limit)) {
+     if (!is_power_of_2(radeon_vram_limit)) {
              dev_warn(rdev->dev, "vram limit (%d) must be a power of 2\n",
                              radeon_vram_limit);
              radeon_vram_limit = 0;
@@ -1140,7 +1127,7 @@ static void radeon_check_arguments(struct radeon_device *rdev)
              dev_warn(rdev->dev, "gart size (%d) too small\n",
                              radeon_gart_size);
              radeon_gart_size = radeon_gart_size_auto(rdev->family);
-     } else if (!radeon_check_pot_argument(radeon_gart_size)) {
+     } else if (!is_power_of_2(radeon_gart_size)) {
              dev_warn(rdev->dev, "gart size (%d) must be a power of 2\n",
                              radeon_gart_size);
              radeon_gart_size = radeon_gart_size_auto(rdev->family);
@@ -1163,7 +1150,7 @@ static void radeon_check_arguments(struct radeon_device *rdev)
              break;
      }
 
-     if (!radeon_check_pot_argument(radeon_vm_size)) {
+     if (!is_power_of_2(radeon_vm_size)) {
              dev_warn(rdev->dev, "VM size (%d) must be a power of 2\n",
                       radeon_vm_size);
              radeon_vm_size = 4;