Skip to contentSkip to conversation

accel/ivpu: Remove unnecessary min_t()/max_t() usage

PATCH Applied Andrzej Kacprowski 2 participants 3 messages Jul 16 – Jul 17

Subsystems (2)
lore
Share & tools
lore

Andrzej Kacprowski

author maintainer
#0 lore raw

PATCH 1/1 accel/ivpu: Remove unnecessary min_t()/max_t() usage

Remove unnecessary min_t()/max_t() usage in ivpu_fw.c and ivpu_mmu_context.c. The min()/max() macros are sufficient as the types are compatible and there is no risk of overflow.

---
 drivers/accel/ivpu/ivpu_fw.c          | 2 +-
 drivers/accel/ivpu/ivpu_mmu_context.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/accel/ivpu/ivpu_fw.c +1 -1
index 5a8f7dfb54e6..b78b7c35cd9b 100644
@@ -318,7 +318,7 @@ static int ivpu_fw_parse(struct ivpu_device *vdev)
 	fw->shave_nn_size = PAGE_ALIGN(fw_hdr->shave_nn_fw_size);
 	fw->cold_boot_entry_point = fw_hdr->entry_point;
 
-	fw->trace_level = min_t(u32, ivpu_fw_log_level, IVPU_FW_LOG_FATAL);
+	fw->trace_level = min(ivpu_fw_log_level, IVPU_FW_LOG_FATAL);
 	fw->trace_destination_mask = VPU_TRACE_DESTINATION_VERBOSE_TRACING;
 	fw->trace_hw_component_mask = -1;
 
drivers/accel/ivpu/ivpu_mmu_context.c +2 -2
index c4014c83e727..bb3ca81838e3 100644
@@ -588,8 +588,8 @@ void ivpu_mmu_context_init(struct ivpu_device *vdev, struct ivpu_mmu_context *ct
 		start = vdev->hw->ranges.runtime.start;
 		end = vdev->hw->ranges.shave.end;
 	} else {
-		start = min_t(u64, vdev->hw->ranges.user.start, vdev->hw->ranges.shave.start);
-		end = max_t(u64, vdev->hw->ranges.user.end, vdev->hw->ranges.dma.end);
+		start = min(vdev->hw->ranges.user.start, vdev->hw->ranges.shave.start);
+		end = max(vdev->hw->ranges.user.end, vdev->hw->ranges.dma.end);
 	}
 
 	drm_mm_init(&ctx->mm, start, end - start);
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · Andrzej Kacprowski

Remove unnecessary min_t()/max_t() usage in ivpu_fw.c and ivpu_mmu_context.c. The min()/max() macros are sufficient as the types are compatible and there is no risk of overflow.

---
  drivers/accel/ivpu/ivpu_fw.c          | 2 +-
  drivers/accel/ivpu/ivpu_mmu_context.c | 4 ++--
  2 files changed, 3 insertions(+), 3 deletions(-)
drivers/accel/ivpu/ivpu_fw.c +1 -1
index 5a8f7dfb54e6..b78b7c35cd9b 100644
@@ -318,7 +318,7 @@ static int ivpu_fw_parse(struct ivpu_device *vdev)
  	fw->shave_nn_size = PAGE_ALIGN(fw_hdr->shave_nn_fw_size);
  	fw->cold_boot_entry_point = fw_hdr->entry_point;
 
-	fw->trace_level = min_t(u32, ivpu_fw_log_level, IVPU_FW_LOG_FATAL);
+	fw->trace_level = min(ivpu_fw_log_level, IVPU_FW_LOG_FATAL);
  	fw->trace_destination_mask = VPU_TRACE_DESTINATION_VERBOSE_TRACING;
  	fw->trace_hw_component_mask = -1;
 
drivers/accel/ivpu/ivpu_mmu_context.c +0 -0
index c4014c83e727..bb3ca81838e3 100644

drivers/accel/ivpu/ivpu_mmu_context.c void ivpu_mmu_context_init(struct ivpu_device *vdev, struct ivpu_mmu_context *ct · line 595

Quoted 10 lines
drivers/accel/ivpu/ivpu_mmu_context.c +2 -2
@@ -588,8 +588,8 @@ void ivpu_mmu_context_init(struct ivpu_device *vdev, struct ivpu_mmu_context *ct
  		start = vdev->hw->ranges.runtime.start;
  		end = vdev->hw->ranges.shave.end;
  	} else {
-		start = min_t(u64, vdev->hw->ranges.user.start, vdev->hw->ranges.shave.start);
-		end = max_t(u64, vdev->hw->ranges.user.end, vdev->hw->ranges.dma.end);
+		start = min(vdev->hw->ranges.user.start, vdev->hw->ranges.shave.start);
+		end = max(vdev->hw->ranges.user.end, vdev->hw->ranges.dma.end);
  	}
 
  	drm_mm_init(&ctx->mm, start, end - start);
maintainer Applied
#2 lore raw
Quoted 35 lines · Karol
Quoted 34 lines · Andrzej Kacprowski

Remove unnecessary min_t()/max_t() usage in ivpu_fw.c and ivpu_mmu_context.c. The min()/max() macros are sufficient as the types are compatible and there is no risk of overflow.

---
  drivers/accel/ivpu/ivpu_fw.c          | 2 +- drivers/accel/ivpu/ivpu_mmu_context.c | 4 ++--

  2 files changed, 3 insertions(+), 3 deletions(-)
drivers/accel/ivpu/ivpu_fw.c +1 -1
index 5a8f7dfb54e6..b78b7c35cd9b 100644
@@ -318,7 +318,7 @@ static int ivpu_fw_parse(struct ivpu_device *vdev)
       fw->shave_nn_size = PAGE_ALIGN(fw_hdr->shave_nn_fw_size);
       fw->cold_boot_entry_point = fw_hdr->entry_point;
-    fw->trace_level = min_t(u32, ivpu_fw_log_level, IVPU_FW_LOG_FATAL);
+    fw->trace_level = min(ivpu_fw_log_level, IVPU_FW_LOG_FATAL);
       fw->trace_destination_mask = VPU_TRACE_DESTINATION_VERBOSE_TRACING;
       fw->trace_hw_component_mask = -1;
drivers/accel/ivpu/ivpu_mmu_context.c +0 -2
index c4014c83e727..bb3ca81838e3 100644
@@ -588,8 +588,8 @@ void ivpu_mmu_context_init(struct ivpu_device 
 *vdev, struct ivpu_mmu_context *ct
           start = vdev->hw->ranges.runtime.start;
           end = vdev->hw->ranges.shave.end;
       } else {
-        start = min_t(u64, vdev->hw->ranges.user.start, vdev->hw- 
 >ranges.shave.start);
-        end = max_t(u64, vdev->hw->ranges.user.end, vdev->hw- 
Quoted 8 lines
Quoted 6 lines
drivers/accel/ivpu/ivpu_mmu_context.c +1 -0
 >ranges.dma.end);
+        start = min(vdev->hw->ranges.user.start, vdev->hw- 
Quoted 1 line

ranges.shave.start);

+        end = max(vdev->hw->ranges.user.end, vdev->hw->ranges.dma.end); }
      drm_mm_init(&ctx->mm, start, end - start);

Pushed to drm-misc-next.