From: Steven Price <steven.price@arm.com>
To: "Boris Brezillon" <boris.brezillon@collabora.com>,
"Liviu Dudau" <liviu.dudau@arm.com>,
"Adrián Larumbe" <adrian.larumbe@collabora.com>
Cc: dri-devel@lists.freedesktop.org, kernel@collabora.com
Subject: Re: [PATCH] drm/panthor: Lock the VM resv before calling drm_gpuvm_bo_obtain_prealloc()
Date: Fri, 13 Sep 2024 15:18:51 +0100 [thread overview]
Message-ID: <e7d3ebf4-b9cf-47df-91ee-da5cb3fb979f@arm.com> (raw)
In-Reply-To: <20240913112722.492144-1-boris.brezillon@collabora.com>
On 13/09/2024 12:27, Boris Brezillon wrote:
> drm_gpuvm_bo_obtain_prealloc() will call drm_gpuvm_bo_put() on our
> pre-allocated BO if the <BO,VM> association exists. Given we
> only have one ref on preallocated_vm_bo, drm_gpuvm_bo_destroy() will
> be called immediately, and we have to hold the VM resv lock when
> calling this function.
>
> Fixes: 647810ec2476 ("drm/panthor: Add the MMU/VM logical block")
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Steven Price <steven.price@arm.com>
> ---
> drivers/gpu/drm/panthor/panthor_mmu.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
> index 37f1885c54c7..aa12ed2acfcf 100644
> --- a/drivers/gpu/drm/panthor/panthor_mmu.c
> +++ b/drivers/gpu/drm/panthor/panthor_mmu.c
> @@ -1251,9 +1251,17 @@ static int panthor_vm_prepare_map_op_ctx(struct panthor_vm_op_ctx *op_ctx,
> goto err_cleanup;
> }
>
> + /* drm_gpuvm_bo_obtain_prealloc() will call drm_gpuvm_bo_put() on our
> + * pre-allocated BO if the <BO,VM> association exists. Given we
> + * only have one ref on preallocated_vm_bo, drm_gpuvm_bo_destroy() will
> + * be called immediately, and we have to hold the VM resv lock when
> + * calling this function.
> + */
> + dma_resv_lock(panthor_vm_resv(vm), NULL);
> mutex_lock(&bo->gpuva_list_lock);
> op_ctx->map.vm_bo = drm_gpuvm_bo_obtain_prealloc(preallocated_vm_bo);
> mutex_unlock(&bo->gpuva_list_lock);
> + dma_resv_unlock(panthor_vm_resv(vm));
>
> /* If the a vm_bo for this <VM,BO> combination exists, it already
> * retains a pin ref, and we can release the one we took earlier.
next prev parent reply other threads:[~2024-09-13 14:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-13 11:27 [PATCH] drm/panthor: Lock the VM resv before calling drm_gpuvm_bo_obtain_prealloc() Boris Brezillon
2024-09-13 14:01 ` Liviu Dudau
2024-09-13 14:18 ` Steven Price [this message]
2024-10-01 16:44 ` 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=e7d3ebf4-b9cf-47df-91ee-da5cb3fb979f@arm.com \
--to=steven.price@arm.com \
--cc=adrian.larumbe@collabora.com \
--cc=boris.brezillon@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@collabora.com \
--cc=liviu.dudau@arm.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 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.