All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liviu Dudau <liviu.dudau@arm.com>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: "Steven Price" <steven.price@arm.com>,
	"Adrián Larumbe" <adrian.larumbe@collabora.com>,
	dri-devel@lists.freedesktop.org,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Akash Goel" <akash.goel@arm.com>,
	"Rob Clark" <robin.clark@oss.qualcomm.com>,
	"Sean Paul" <sean@poorly.run>,
	"Konrad Dybcio" <konradybcio@kernel.org>,
	"Akhil P Oommen" <akhilpo@oss.qualcomm.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Dmitry Osipenko" <dmitry.osipenko@collabora.com>,
	"Chris Diamand" <chris.diamand@arm.com>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Alice Ryhl" <aliceryhl@google.com>,
	kernel@collabora.com
Subject: Re: [PATCH v1 4/9] drm/panthor: Group panthor_kernel_bo_xxx() helpers
Date: Thu, 15 Jan 2026 13:41:24 +0000	[thread overview]
Message-ID: <aWjuhPwho0VMUqxN@e142607> (raw)
In-Reply-To: <20260109130801.1239558-5-boris.brezillon@collabora.com>

On Fri, Jan 09, 2026 at 02:07:56PM +0100, Boris Brezillon wrote:
> Move all panthor_kernel_bo_xxx() helpers at the end of the file, just
> before the debugfs init logic. This will make further panthor_gem.c
> refactoring more readable.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>

Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>

> ---
>  drivers/gpu/drm/panthor/panthor_gem.c | 212 +++++++++++++-------------
>  1 file changed, 106 insertions(+), 106 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panthor/panthor_gem.c b/drivers/gpu/drm/panthor/panthor_gem.c
> index 13e9dd3764fa..4b3d82f001d8 100644
> --- a/drivers/gpu/drm/panthor/panthor_gem.c
> +++ b/drivers/gpu/drm/panthor/panthor_gem.c
> @@ -132,112 +132,6 @@ static void panthor_gem_free_object(struct drm_gem_object *obj)
>  	drm_gem_object_put(vm_root_gem);
>  }
>  
> -/**
> - * panthor_kernel_bo_destroy() - Destroy a kernel buffer object
> - * @bo: Kernel buffer object to destroy. If NULL or an ERR_PTR(), the destruction
> - * is skipped.
> - */
> -void panthor_kernel_bo_destroy(struct panthor_kernel_bo *bo)
> -{
> -	struct panthor_vm *vm;
> -
> -	if (IS_ERR_OR_NULL(bo))
> -		return;
> -
> -	vm = bo->vm;
> -	panthor_kernel_bo_vunmap(bo);
> -
> -	drm_WARN_ON(bo->obj->dev,
> -		    to_panthor_bo(bo->obj)->exclusive_vm_root_gem != panthor_vm_root_gem(vm));
> -	panthor_vm_unmap_range(vm, bo->va_node.start, bo->va_node.size);
> -	panthor_vm_free_va(vm, &bo->va_node);
> -	drm_gem_object_put(bo->obj);
> -	panthor_vm_put(vm);
> -	kfree(bo);
> -}
> -
> -/**
> - * panthor_kernel_bo_create() - Create and map a GEM object to a VM
> - * @ptdev: Device.
> - * @vm: VM to map the GEM to. If NULL, the kernel object is not GPU mapped.
> - * @size: Size of the buffer object.
> - * @bo_flags: Combination of drm_panthor_bo_flags flags.
> - * @vm_map_flags: Combination of drm_panthor_vm_bind_op_flags (only those
> - * that are related to map operations).
> - * @gpu_va: GPU address assigned when mapping to the VM.
> - * If gpu_va == PANTHOR_VM_KERNEL_AUTO_VA, the virtual address will be
> - * automatically allocated.
> - * @name: Descriptive label of the BO's contents
> - *
> - * Return: A valid pointer in case of success, an ERR_PTR() otherwise.
> - */
> -struct panthor_kernel_bo *
> -panthor_kernel_bo_create(struct panthor_device *ptdev, struct panthor_vm *vm,
> -			 size_t size, u32 bo_flags, u32 vm_map_flags,
> -			 u64 gpu_va, const char *name)
> -{
> -	struct drm_gem_shmem_object *obj;
> -	struct panthor_kernel_bo *kbo;
> -	struct panthor_gem_object *bo;
> -	u32 debug_flags = PANTHOR_DEBUGFS_GEM_USAGE_FLAG_KERNEL;
> -	int ret;
> -
> -	if (drm_WARN_ON(&ptdev->base, !vm))
> -		return ERR_PTR(-EINVAL);
> -
> -	kbo = kzalloc(sizeof(*kbo), GFP_KERNEL);
> -	if (!kbo)
> -		return ERR_PTR(-ENOMEM);
> -
> -	obj = drm_gem_shmem_create(&ptdev->base, size);
> -	if (IS_ERR(obj)) {
> -		ret = PTR_ERR(obj);
> -		goto err_free_bo;
> -	}
> -
> -	bo = to_panthor_bo(&obj->base);
> -	kbo->obj = &obj->base;
> -	bo->flags = bo_flags;
> -	bo->base.map_wc = should_map_wc(bo, vm);
> -	bo->exclusive_vm_root_gem = panthor_vm_root_gem(vm);
> -	drm_gem_object_get(bo->exclusive_vm_root_gem);
> -	bo->base.base.resv = bo->exclusive_vm_root_gem->resv;
> -
> -	if (vm == panthor_fw_vm(ptdev))
> -		debug_flags |= PANTHOR_DEBUGFS_GEM_USAGE_FLAG_FW_MAPPED;
> -
> -	panthor_gem_kernel_bo_set_label(kbo, name);
> -	panthor_gem_debugfs_set_usage_flags(to_panthor_bo(kbo->obj), debug_flags);
> -
> -	/* The system and GPU MMU page size might differ, which becomes a
> -	 * problem for FW sections that need to be mapped at explicit address
> -	 * since our PAGE_SIZE alignment might cover a VA range that's
> -	 * expected to be used for another section.
> -	 * Make sure we never map more than we need.
> -	 */
> -	size = ALIGN(size, panthor_vm_page_size(vm));
> -	ret = panthor_vm_alloc_va(vm, gpu_va, size, &kbo->va_node);
> -	if (ret)
> -		goto err_put_obj;
> -
> -	ret = panthor_vm_map_bo_range(vm, bo, 0, size, kbo->va_node.start, vm_map_flags);
> -	if (ret)
> -		goto err_free_va;
> -
> -	kbo->vm = panthor_vm_get(vm);
> -	return kbo;
> -
> -err_free_va:
> -	panthor_vm_free_va(vm, &kbo->va_node);
> -
> -err_put_obj:
> -	drm_gem_object_put(&obj->base);
> -
> -err_free_bo:
> -	kfree(kbo);
> -	return ERR_PTR(ret);
> -}
> -
>  static struct sg_table *
>  panthor_gem_prime_map_dma_buf(struct dma_buf_attachment *attach,
>  			      enum dma_data_direction dir)
> @@ -603,6 +497,112 @@ panthor_gem_sync(struct drm_gem_object *obj, u32 type,
>  	return 0;
>  }
>  
> +/**
> + * panthor_kernel_bo_destroy() - Destroy a kernel buffer object
> + * @bo: Kernel buffer object to destroy. If NULL or an ERR_PTR(), the destruction
> + * is skipped.
> + */
> +void panthor_kernel_bo_destroy(struct panthor_kernel_bo *bo)
> +{
> +	struct panthor_vm *vm;
> +
> +	if (IS_ERR_OR_NULL(bo))
> +		return;
> +
> +	vm = bo->vm;
> +	panthor_kernel_bo_vunmap(bo);
> +
> +	drm_WARN_ON(bo->obj->dev,
> +		    to_panthor_bo(bo->obj)->exclusive_vm_root_gem != panthor_vm_root_gem(vm));
> +	panthor_vm_unmap_range(vm, bo->va_node.start, bo->va_node.size);
> +	panthor_vm_free_va(vm, &bo->va_node);
> +	drm_gem_object_put(bo->obj);
> +	panthor_vm_put(vm);
> +	kfree(bo);
> +}
> +
> +/**
> + * panthor_kernel_bo_create() - Create and map a GEM object to a VM
> + * @ptdev: Device.
> + * @vm: VM to map the GEM to. If NULL, the kernel object is not GPU mapped.
> + * @size: Size of the buffer object.
> + * @bo_flags: Combination of drm_panthor_bo_flags flags.
> + * @vm_map_flags: Combination of drm_panthor_vm_bind_op_flags (only those
> + * that are related to map operations).
> + * @gpu_va: GPU address assigned when mapping to the VM.
> + * If gpu_va == PANTHOR_VM_KERNEL_AUTO_VA, the virtual address will be
> + * automatically allocated.
> + * @name: Descriptive label of the BO's contents
> + *
> + * Return: A valid pointer in case of success, an ERR_PTR() otherwise.
> + */
> +struct panthor_kernel_bo *
> +panthor_kernel_bo_create(struct panthor_device *ptdev, struct panthor_vm *vm,
> +			 size_t size, u32 bo_flags, u32 vm_map_flags,
> +			 u64 gpu_va, const char *name)
> +{
> +	struct drm_gem_shmem_object *obj;
> +	struct panthor_kernel_bo *kbo;
> +	struct panthor_gem_object *bo;
> +	u32 debug_flags = PANTHOR_DEBUGFS_GEM_USAGE_FLAG_KERNEL;
> +	int ret;
> +
> +	if (drm_WARN_ON(&ptdev->base, !vm))
> +		return ERR_PTR(-EINVAL);
> +
> +	kbo = kzalloc(sizeof(*kbo), GFP_KERNEL);
> +	if (!kbo)
> +		return ERR_PTR(-ENOMEM);
> +
> +	obj = drm_gem_shmem_create(&ptdev->base, size);
> +	if (IS_ERR(obj)) {
> +		ret = PTR_ERR(obj);
> +		goto err_free_bo;
> +	}
> +
> +	bo = to_panthor_bo(&obj->base);
> +	kbo->obj = &obj->base;
> +	bo->flags = bo_flags;
> +	bo->base.map_wc = should_map_wc(bo, vm);
> +	bo->exclusive_vm_root_gem = panthor_vm_root_gem(vm);
> +	drm_gem_object_get(bo->exclusive_vm_root_gem);
> +	bo->base.base.resv = bo->exclusive_vm_root_gem->resv;
> +
> +	if (vm == panthor_fw_vm(ptdev))
> +		debug_flags |= PANTHOR_DEBUGFS_GEM_USAGE_FLAG_FW_MAPPED;
> +
> +	panthor_gem_kernel_bo_set_label(kbo, name);
> +	panthor_gem_debugfs_set_usage_flags(to_panthor_bo(kbo->obj), debug_flags);
> +
> +	/* The system and GPU MMU page size might differ, which becomes a
> +	 * problem for FW sections that need to be mapped at explicit address
> +	 * since our PAGE_SIZE alignment might cover a VA range that's
> +	 * expected to be used for another section.
> +	 * Make sure we never map more than we need.
> +	 */
> +	size = ALIGN(size, panthor_vm_page_size(vm));
> +	ret = panthor_vm_alloc_va(vm, gpu_va, size, &kbo->va_node);
> +	if (ret)
> +		goto err_put_obj;
> +
> +	ret = panthor_vm_map_bo_range(vm, bo, 0, size, kbo->va_node.start, vm_map_flags);
> +	if (ret)
> +		goto err_free_va;
> +
> +	kbo->vm = panthor_vm_get(vm);
> +	return kbo;
> +
> +err_free_va:
> +	panthor_vm_free_va(vm, &kbo->va_node);
> +
> +err_put_obj:
> +	drm_gem_object_put(&obj->base);
> +
> +err_free_bo:
> +	kfree(kbo);
> +	return ERR_PTR(ret);
> +}
> +
>  #ifdef CONFIG_DEBUG_FS
>  struct gem_size_totals {
>  	size_t size;
> -- 
> 2.52.0
> 

  parent reply	other threads:[~2026-01-15 13:42 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-09 13:07 [PATCH v1 0/9] drm/panthor: Add a GEM shrinker Boris Brezillon
2026-01-09 13:07 ` [PATCH v1 1/9] drm/gem: Consider GEM object reclaimable if shrinking fails Boris Brezillon
2026-01-12  9:25   ` Alice Ryhl
2026-01-12 10:02     ` Boris Brezillon
2026-01-15 13:28   ` Liviu Dudau
2026-01-09 13:07 ` [PATCH v1 2/9] drm/gpuvm: Validate BOs in the extobj list when VM is resv protected Boris Brezillon
2026-01-09 19:38   ` Danilo Krummrich
2026-01-12  7:30     ` Boris Brezillon
2026-01-09 13:07 ` [PATCH v1 3/9] drm/panthor: Move panthor_gems_debugfs_init() to panthor_gem.c Boris Brezillon
2026-01-12 11:27   ` Steven Price
2026-01-15 13:39   ` Liviu Dudau
2026-01-09 13:07 ` [PATCH v1 4/9] drm/panthor: Group panthor_kernel_bo_xxx() helpers Boris Brezillon
2026-01-12 11:29   ` Steven Price
2026-01-15 13:41   ` Liviu Dudau [this message]
2026-01-09 13:07 ` [PATCH v1 5/9] drm/panthor: Part ways with drm_gem_shmem_object Boris Brezillon
2026-01-12 12:06   ` Steven Price
2026-01-12 14:17     ` Boris Brezillon
2026-01-12 16:03       ` Steven Price
2026-01-12 16:45         ` Boris Brezillon
2026-01-21 11:11       ` Akash Goel
2026-01-21 15:17         ` Boris Brezillon
2026-01-15 16:51   ` Liviu Dudau
2026-01-15 17:27     ` Boris Brezillon
2026-01-15 17:45       ` Liviu Dudau
2026-01-16 12:09         ` Steven Price
2026-01-09 13:07 ` [PATCH v1 6/9] drm/panthor: Lazily allocate pages on mmap() Boris Brezillon
2026-01-12 12:15   ` Steven Price
2026-01-12 14:32     ` Boris Brezillon
2026-01-12 16:41       ` Steven Price
2026-01-12 16:50         ` Boris Brezillon
2026-01-15 17:34   ` Liviu Dudau
2026-01-15 19:27     ` Boris Brezillon
2026-01-16  8:19   ` kernel test robot
2026-01-09 13:07 ` [PATCH v1 7/9] drm/panthor: Split panthor_vm_prepare_map_op_ctx() to prepare for reclaim Boris Brezillon
2026-01-12 12:21   ` Steven Price
2026-01-15 17:40   ` Liviu Dudau
2026-01-09 13:08 ` [PATCH v1 8/9] drm/panthor: Track the number of mmap on a BO Boris Brezillon
2026-01-12 12:33   ` Steven Price
2026-01-12 14:39     ` Boris Brezillon
2026-01-12 15:19       ` Alice Ryhl
2026-01-12 15:49         ` Boris Brezillon
2026-01-12 15:51           ` Alice Ryhl
2026-01-12 16:06             ` Boris Brezillon
2026-01-12 16:49       ` Steven Price
2026-01-12 16:59         ` Boris Brezillon
2026-01-12 17:10           ` Steven Price
2026-01-12 17:18             ` Boris Brezillon
2026-01-13 12:26             ` Boris Brezillon
2026-01-09 13:08 ` [PATCH v1 9/9] drm/panthor: Add a GEM shrinker Boris Brezillon
2026-01-14 15:05   ` Steven Price
2026-01-15 10:50     ` Boris Brezillon
2026-01-15 11:24       ` Steven Price
2026-01-15 12:01         ` Boris Brezillon
2026-01-15 13:56   ` Akash Goel
2026-01-15 14:36     ` Boris Brezillon
2026-01-15 14:37     ` Boris Brezillon
2026-01-21 11:49   ` Akash Goel
2026-01-21 14:52     ` Boris Brezillon
2026-01-28 11:21       ` Akash Goel
2026-01-28 15:52         ` Boris Brezillon
2026-01-28 16:26           ` Akash Goel
2026-01-12  8:37 ` [PATCH v1 0/9] " Boris Brezillon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aWjuhPwho0VMUqxN@e142607 \
    --to=liviu.dudau@arm.com \
    --cc=adrian.larumbe@collabora.com \
    --cc=airlied@gmail.com \
    --cc=akash.goel@arm.com \
    --cc=akhilpo@oss.qualcomm.com \
    --cc=aliceryhl@google.com \
    --cc=boris.brezillon@collabora.com \
    --cc=chris.diamand@arm.com \
    --cc=dakr@kernel.org \
    --cc=dmitry.osipenko@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@collabora.com \
    --cc=konradybcio@kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matthew.brost@intel.com \
    --cc=mripard@kernel.org \
    --cc=robin.clark@oss.qualcomm.com \
    --cc=sean@poorly.run \
    --cc=simona@ffwll.ch \
    --cc=steven.price@arm.com \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.