dri-devel Archive mirror
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: Steven Price <steven.price@arm.com>
Cc: "Liviu Dudau" <liviu.dudau@arm.com>,
	"Adrián Larumbe" <adrian.larumbe@collabora.com>,
	dri-devel@lists.freedesktop.org, kernel@collabora.com,
	"Eric Smith" <eric.smith@collabora.com>
Subject: Re: [PATCH v3 4/5] drm/panthor: Fix an off-by-one in the heap context retrieval logic
Date: Thu, 2 May 2024 18:52:23 +0200	[thread overview]
Message-ID: <20240502185223.79caf041@collabora.com> (raw)
In-Reply-To: <d2b2f36f-a2d4-4515-bc2c-24f4c1b548d3@arm.com>

On Thu, 2 May 2024 16:52:24 +0100
Steven Price <steven.price@arm.com> wrote:

> On 02/05/2024 16:40, 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.
> > 
> > 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>  
> 
> Don't we also need to change the xa_init_flags() in
> panthor_heap_pool_create()?

Uh, we should, indeed.

> 
> Steve
> 
> > ---
> >  drivers/gpu/drm/panthor/panthor_heap.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/panthor/panthor_heap.c b/drivers/gpu/drm/panthor/panthor_heap.c
> > index 683bb94761bc..252332f5390f 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);
> >    
> 


  reply	other threads:[~2024-05-02 16:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-02 15:40 [PATCH v3 0/5] drm/panthor: Collection of tiler heap related fixes Boris Brezillon
2024-05-02 15:40 ` [PATCH v3 1/5] drm/panthor: Fix tiler OOM handling to allow incremental rendering Boris Brezillon
2024-05-02 15:40 ` [PATCH v3 2/5] drm/panthor: Make sure the tiler initial/max chunks are consistent Boris Brezillon
2024-05-02 15:40 ` [PATCH v3 3/5] drm/panthor: Relax the constraints on the tiler chunk size Boris Brezillon
2024-05-02 15:47   ` Steven Price
2024-05-02 16:53     ` Boris Brezillon
2024-05-02 15:40 ` [PATCH v3 4/5] drm/panthor: Fix an off-by-one in the heap context retrieval logic Boris Brezillon
2024-05-02 15:52   ` Steven Price
2024-05-02 16:52     ` Boris Brezillon [this message]
2024-05-02 15:40 ` [PATCH v3 5/5] drm/panthor: Document drm_panthor_tiler_heap_destroy::handle validity constraints Boris Brezillon
2024-05-02 15:52   ` Steven Price

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=20240502185223.79caf041@collabora.com \
    --to=boris.brezillon@collabora.com \
    --cc=adrian.larumbe@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eric.smith@collabora.com \
    --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 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).