All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: "Boris Brezillon" <boris.brezillon@collabora.com>,
	"Steven Price" <steven.price@arm.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: Tue, 1 Oct 2024 18:44:12 +0200	[thread overview]
Message-ID: <20241001184412.7403c784@collabora.com> (raw)
In-Reply-To: <20240913112722.492144-1-boris.brezillon@collabora.com>

On Fri, 13 Sep 2024 13:27:22 +0200
Boris Brezillon <boris.brezillon@collabora.com> 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>

Queued to drm-misc-fixes.

> ---
>  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.


      parent reply	other threads:[~2024-10-01 16:44 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
2024-10-01 16:44 ` Boris Brezillon [this message]

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=20241001184412.7403c784@collabora.com \
    --to=boris.brezillon@collabora.com \
    --cc=adrian.larumbe@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@collabora.com \
    --cc=liviu.dudau@arm.com \
    --cc=steven.price@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.