dri-devel Archive mirror
 help / color / mirror / Atom feed
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,
	Eric Smith <eric.smith@collabora.com>
Subject: Re: [PATCH v4 4/5] drm/panthor: Fix an off-by-one in the heap context retrieval logic
Date: Fri, 3 May 2024 09:26:00 +0100	[thread overview]
Message-ID: <fd7fb2ca-2468-4f1f-a65d-ea617fa32f90@arm.com> (raw)
In-Reply-To: <20240502165158.1458959-5-boris.brezillon@collabora.com>

On 02/05/2024 17:51, Boris Brezillon wrote:
> The heap ID is used to index the heap context pool, and allocating
> in the [1:MAX_HEAPS_PER_POOL] leads to an off-by-one. This was
> originally to avoid returning a zero heap handle, but given the handle
> is formed with (vm_id << 16) | heap_id, with vm_id > 0, we already can't
> end up with a valid heap handle that's zero.
> 
> v4:
> - s/XA_FLAGS_ALLOC1/XA_FLAGS_ALLOC/
> 
> v3:
> - Allocate in the [0:MAX_HEAPS_PER_POOL-1] range
> 
> v2:
> - New patch
> 
> Fixes: 9cca48fa4f89 ("drm/panthor: Add the heap logical block")
> Reported-by: Eric Smith <eric.smith@collabora.com>
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> Tested-by: Eric Smith <eric.smith@collabora.com>

Reviewed-by: Steven Price <steven.price@arm.com>

Thanks,
Steve

> ---
>  drivers/gpu/drm/panthor/panthor_heap.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panthor/panthor_heap.c b/drivers/gpu/drm/panthor/panthor_heap.c
> index b0fc5b9ee847..95a1c6c9f35e 100644
> --- a/drivers/gpu/drm/panthor/panthor_heap.c
> +++ b/drivers/gpu/drm/panthor/panthor_heap.c
> @@ -323,7 +323,8 @@ int panthor_heap_create(struct panthor_heap_pool *pool,
>  	if (!pool->vm) {
>  		ret = -EINVAL;
>  	} else {
> -		ret = xa_alloc(&pool->xa, &id, heap, XA_LIMIT(1, MAX_HEAPS_PER_POOL), GFP_KERNEL);
> +		ret = xa_alloc(&pool->xa, &id, heap,
> +			       XA_LIMIT(0, MAX_HEAPS_PER_POOL - 1), GFP_KERNEL);
>  		if (!ret) {
>  			void *gpu_ctx = panthor_get_heap_ctx(pool, id);
>  
> @@ -543,7 +544,7 @@ panthor_heap_pool_create(struct panthor_device *ptdev, struct panthor_vm *vm)
>  	pool->vm = vm;
>  	pool->ptdev = ptdev;
>  	init_rwsem(&pool->lock);
> -	xa_init_flags(&pool->xa, XA_FLAGS_ALLOC1);
> +	xa_init_flags(&pool->xa, XA_FLAGS_ALLOC);
>  	kref_init(&pool->refcount);
>  
>  	pool->gpu_contexts = panthor_kernel_bo_create(ptdev, vm, bosize,


  reply	other threads:[~2024-05-03  8:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-02 16:51 [PATCH v4 0/5] drm/panthor: Collection of tiler heap related fixes Boris Brezillon
2024-05-02 16:51 ` [PATCH v4 1/5] drm/panthor: Fix tiler OOM handling to allow incremental rendering Boris Brezillon
2024-05-02 16:51 ` [PATCH v4 2/5] drm/panthor: Make sure the tiler initial/max chunks are consistent Boris Brezillon
2024-05-02 16:51 ` [PATCH v4 3/5] drm/panthor: Relax the constraints on the tiler chunk size Boris Brezillon
2024-05-02 16:51 ` [PATCH v4 4/5] drm/panthor: Fix an off-by-one in the heap context retrieval logic Boris Brezillon
2024-05-03  8:26   ` Steven Price [this message]
2024-05-03 10:22   ` Liviu Dudau
2024-05-02 16:51 ` [PATCH v4 5/5] drm/panthor: Document drm_panthor_tiler_heap_destroy::handle validity constraints Boris Brezillon
2024-05-03 10:22   ` Liviu Dudau
2024-05-13 11:41 ` [PATCH v4 0/5] drm/panthor: Collection of tiler heap related fixes 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=fd7fb2ca-2468-4f1f-a65d-ea617fa32f90@arm.com \
    --to=steven.price@arm.com \
    --cc=adrian.larumbe@collabora.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eric.smith@collabora.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).