From: Karol Wachowski <karol.wachowski@linux.intel.com>
To: Maciej Falkowski <maciej.falkowski@linux.intel.com>,
dri-devel@lists.freedesktop.org
Cc: oded.gabbay@gmail.com, jeff.hugo@oss.qualcomm.com,
lizhi.hou@amd.com,
Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Subject: Re: [PATCH] accel/ivpu: Improve BO alloc/free warnings
Date: Wed, 1 Oct 2025 09:51:02 +0200 [thread overview]
Message-ID: <3fa5c368-726e-42f7-9900-cdbe3189a57c@linux.intel.com> (raw)
In-Reply-To: <20250925145154.1446427-1-maciej.falkowski@linux.intel.com>
Reviewed-by: Karol Wachowski <karol.wachowski@linux.intel.com>
On 9/25/2025 4:51 PM, Maciej Falkowski wrote:
> From: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
>
> Add additional warnings related to allocation and
> deallocation of buffer objects to better track possible
> memory leaks and generally the BO's lifecycle.
>
> Introduce checks for handle_count to ensure it is zero
> before creating a new handle, and exactly one
> after successfully creating a handle.
>
> Introduce also a check to warn if the VMA node is not
> empty when freeing the buffer object.
>
> Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
> Signed-off-by: Maciej Falkowski <maciej.falkowski@linux.intel.com>
> ---
> drivers/accel/ivpu/ivpu_gem.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/accel/ivpu/ivpu_gem.c b/drivers/accel/ivpu/ivpu_gem.c
> index 38ecf933d144..e9830ad48d4b 100644
> --- a/drivers/accel/ivpu/ivpu_gem.c
> +++ b/drivers/accel/ivpu/ivpu_gem.c
> @@ -332,6 +332,7 @@ static void ivpu_gem_bo_free(struct drm_gem_object *obj)
> drm_WARN_ON(&vdev->drm, bo->ctx);
>
> drm_WARN_ON(obj->dev, refcount_read(&bo->base.pages_use_count) > 1);
> + drm_WARN_ON(obj->dev, bo->base.base.vma_node.vm_files.rb_node);
> drm_gem_shmem_free(&bo->base);
> }
>
> @@ -370,12 +371,16 @@ int ivpu_bo_create_ioctl(struct drm_device *dev, void *data, struct drm_file *fi
> return PTR_ERR(bo);
> }
>
> + drm_WARN_ON(&vdev->drm, bo->base.base.handle_count != 0);
> +
> ret = drm_gem_handle_create(file, &bo->base.base, &args->handle);
> - if (ret)
> + if (ret) {
> ivpu_err(vdev, "Failed to create handle for BO: %pe (ctx %u size %llu flags 0x%x)",
> bo, file_priv->ctx.id, args->size, args->flags);
> - else
> + } else {
> args->vpu_addr = bo->vpu_addr;
> + drm_WARN_ON(&vdev->drm, bo->base.base.handle_count != 1);
> + }
>
> drm_gem_object_put(&bo->base.base);
>
next prev parent reply other threads:[~2025-10-01 7:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-25 14:51 [PATCH] accel/ivpu: Improve BO alloc/free warnings Maciej Falkowski
2025-10-01 7:51 ` Karol Wachowski [this message]
2025-10-01 8:05 ` Karol Wachowski
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=3fa5c368-726e-42f7-9900-cdbe3189a57c@linux.intel.com \
--to=karol.wachowski@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jacek.lawrynowicz@linux.intel.com \
--cc=jeff.hugo@oss.qualcomm.com \
--cc=lizhi.hou@amd.com \
--cc=maciej.falkowski@linux.intel.com \
--cc=oded.gabbay@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox