Skip to contentSkip to conversation

accel/ivpu: Apply minor code style cleanups to align with kernel style

PATCH In review Karol Wachowski 2 participants 3 messages Mar 10 – Mar 11

Subsystems (2)
lore
Share & tools
lore

Karol Wachowski

author maintainer
#0 lore raw

PATCH 1/1 accel/ivpu: Apply minor code style cleanups to align with kernel style

Replace direct import_attach test with drm_gem_is_imported() in ivpu_bo_bind().

Replace kzalloc(sizeof(*bo), GFP_KERNEL) with kzalloc_obj() in ivpu_gem_create_object().

Remove unnecessary cast to bool in ivpu_dbg_bo().

No functional changes.

---
 drivers/accel/ivpu/ivpu_gem.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/accel/ivpu/ivpu_gem.c +4 -4
index 8009965286e0..4f2005a8d496 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (C) 2020-2023 Intel Corporation
+ * Copyright (C) 2020-2026 Intel Corporation
  */
 
 #include <linux/dma-buf.h>
@@ -31,7 +31,7 @@ static inline void ivpu_dbg_bo(struct ivpu_device *vdev, struct ivpu_bo *bo, con
 		 "%6s: bo %8p size %9zu ctx %d vpu_addr %9llx pages %d sgt %d mmu_mapped %d wc %d imported %d\n",
 		 action, bo, ivpu_bo_size(bo), bo->ctx_id, bo->vpu_addr,
 		 (bool)bo->base.pages, (bool)bo->base.sgt, bo->mmu_mapped, bo->base.map_wc,
-		 (bool)drm_gem_is_imported(&bo->base.base));
+		 drm_gem_is_imported(&bo->base.base));
 }
 
 static inline int ivpu_bo_lock(struct ivpu_bo *bo)
@@ -81,7 +81,7 @@ int __must_check ivpu_bo_bind(struct ivpu_bo *bo)
 
 	ivpu_dbg_bo(vdev, bo, "bind");
 
-	if (bo->base.base.import_attach)
+	if (drm_gem_is_imported(&bo->base.base))
 		sgt = ivpu_bo_map_attachment(vdev, bo);
 	else
 		sgt = drm_gem_shmem_get_pages_sgt(&bo->base);
@@ -195,7 +195,7 @@ struct drm_gem_object *ivpu_gem_create_object(struct drm_device *dev, size_t siz
 	if (size == 0 || !PAGE_ALIGNED(size))
 		return ERR_PTR(-EINVAL);
 
-	bo = kzalloc(sizeof(*bo), GFP_KERNEL);
+	bo = kzalloc_obj(*bo);
 	if (!bo)
 		return ERR_PTR(-ENOMEM);
 
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 54 lines · Karol Wachowski

Replace direct import_attach test with drm_gem_is_imported() in ivpu_bo_bind().

Replace kzalloc(sizeof(*bo), GFP_KERNEL) with kzalloc_obj() in ivpu_gem_create_object().

Remove unnecessary cast to bool in ivpu_dbg_bo().

No functional changes.

---
  drivers/accel/ivpu/ivpu_gem.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
drivers/accel/ivpu/ivpu_gem.c +4 -4
index 8009965286e0..4f2005a8d496 100644
@@ -1,6 +1,6 @@
  // SPDX-License-Identifier: GPL-2.0-only
  /*
- * Copyright (C) 2020-2023 Intel Corporation
+ * Copyright (C) 2020-2026 Intel Corporation
   */
 
  #include <linux/dma-buf.h>
@@ -31,7 +31,7 @@ static inline void ivpu_dbg_bo(struct ivpu_device *vdev, struct ivpu_bo *bo, con
  		 "%6s: bo %8p size %9zu ctx %d vpu_addr %9llx pages %d sgt %d mmu_mapped %d wc %d imported %d\n",
  		 action, bo, ivpu_bo_size(bo), bo->ctx_id, bo->vpu_addr,
  		 (bool)bo->base.pages, (bool)bo->base.sgt, bo->mmu_mapped, bo->base.map_wc,
-		 (bool)drm_gem_is_imported(&bo->base.base));
+		 drm_gem_is_imported(&bo->base.base));
  }
 
  static inline int ivpu_bo_lock(struct ivpu_bo *bo)
@@ -81,7 +81,7 @@ int __must_check ivpu_bo_bind(struct ivpu_bo *bo)
 
  	ivpu_dbg_bo(vdev, bo, "bind");
 
-	if (bo->base.base.import_attach)
+	if (drm_gem_is_imported(&bo->base.base))
  		sgt = ivpu_bo_map_attachment(vdev, bo);
  	else
  		sgt = drm_gem_shmem_get_pages_sgt(&bo->base);
@@ -195,7 +195,7 @@ struct drm_gem_object *ivpu_gem_create_object(struct drm_device *dev, size_t siz
  	if (size == 0 || !PAGE_ALIGNED(size))
  		return ERR_PTR(-EINVAL);
 
-	bo = kzalloc(sizeof(*bo), GFP_KERNEL);
+	bo = kzalloc_obj(*bo);
  	if (!bo)
  		return ERR_PTR(-ENOMEM);
 
author maintainer Applied
#2 lore raw
Quoted 1 line · Maciej

Thank you! Applied to drm-misc-next.

Quoted 56 lines · Karol Wachowski
Quoted 54 lines

Replace direct import_attach test with drm_gem_is_imported() in ivpu_bo_bind().

Replace kzalloc(sizeof(*bo), GFP_KERNEL) with kzalloc_obj() in ivpu_gem_create_object().

Remove unnecessary cast to bool in ivpu_dbg_bo().

No functional changes.

---
  drivers/accel/ivpu/ivpu_gem.c | 8 ++++----

  1 file changed, 4 insertions(+), 4 deletions(-)
drivers/accel/ivpu/ renamed from drivers/accel/ivpu/ivpu_gem.c +0 -0

ivpu_gem.c
index 8009965286e0..4f2005a8d496 100644

drivers/accel/ivpu/ivpu_gem.c +1 -1
@@ -1,6 +1,6 @@
   // SPDX-License-Identifier: GPL-2.0-only
   /*
- * Copyright (C) 2020-2023 Intel Corporation
+ * Copyright (C) 2020-2026 Intel Corporation
    */
     #include <linux/dma-buf.h>
@@ -31,7 +31,7 @@ static inline void ivpu_dbg_bo(struct ivpu_device
 *vdev, struct ivpu_bo *bo, con

           "%6s: bo %8p size %9zu ctx %d vpu_addr %9llx pages %d sgt %d mmu_mapped %d wc %d imported %d\n",
           action, bo, ivpu_bo_size(bo), bo->ctx_id, bo->vpu_addr, (bool)bo->base.pages, (bool)bo->base.sgt, bo->mmu_mapped, bo->base.map_wc,
-         (bool)drm_gem_is_imported(&bo->base.base));
+         drm_gem_is_imported(&bo->base.base));
  }
    static inline int ivpu_bo_lock(struct ivpu_bo *bo)

drivers/accel/ivpu/ivpu_gem.c +1 -0
@@ -81,7 +81,7 @@ int __must_check ivpu_bo_bind(struct ivpu_bo *bo)
         ivpu_dbg_bo(vdev, bo, "bind");
   -    if (bo->base.base.import_attach)
+    if (drm_gem_is_imported(&bo->base.base))
           sgt = ivpu_bo_map_attachment(vdev, bo);

      else
          sgt = drm_gem_shmem_get_pages_sgt(&bo->base);

drivers/accel/ivpu/ivpu_gem.c +1 -0
@@ -195,7 +195,7 @@ struct drm_gem_object
 *ivpu_gem_create_object(struct drm_device *dev, size_t siz
       if (size == 0 || !PAGE_ALIGNED(size))
           return ERR_PTR(-EINVAL);
   -    bo = kzalloc(sizeof(*bo), GFP_KERNEL);
+    bo = kzalloc_obj(*bo);
       if (!bo)
           return ERR_PTR(-ENOMEM);