mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matt Coster <Matt.Coster@imgtec.com>
To: Brajesh Gupta <Brajesh.Gupta@imgtec.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Frank Binns <Frank.Binns@imgtec.com>,
	Alessio Belle <Alessio.Belle@imgtec.com>,
	Alexandru Dadu <Alexandru.Dadu@imgtec.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/4] drm/imagination: Populate FW common context ID before passing to the FW
Date: Mon, 18 May 2026 15:01:46 +0000	[thread overview]
Message-ID: <d24d4065-e121-4c78-9b7c-78a6561e0a1a@imgtec.com> (raw)
In-Reply-To: <20260512-b4-context_reset-v1-1-439bee96ed83@imgtec.com>


[-- Attachment #1.1: Type: text/plain, Size: 3656 bytes --]

Hi Brajesh,

On 12/05/2026 07:47, Brajesh Gupta wrote:
> Fix context ID value for the FW common context by moving the context
> allocation earlier.

"Fix" is pretty vague here – can you describe the current behaviour, and
why that's wrong?

I also assume this fixes a previous change, so can you please add a
Fixes: tag referencing the commit which introduced the faulty behaviour
(and possibly a Cc: stable tag, if needed)?

> Also an old incorrect comment was removed.

This detail probably doesn't need to be mentioned.

Cheers,
Matt

> 
> Signed-off-by: Brajesh Gupta <brajesh.gupta@imgtec.com>
> ---
>  drivers/gpu/drm/imagination/pvr_context.c | 30 ++++++++++++++++--------------
>  1 file changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/imagination/pvr_context.c b/drivers/gpu/drm/imagination/pvr_context.c
> index 8de70c30b9de..eba4694400b5 100644
> --- a/drivers/gpu/drm/imagination/pvr_context.c
> +++ b/drivers/gpu/drm/imagination/pvr_context.c
> @@ -318,10 +318,14 @@ int pvr_context_create(struct pvr_file *pvr_file, struct drm_pvr_ioctl_create_co
>                 goto err_put_vm;
>         }
> 
> -       err = pvr_context_create_queues(ctx, args, ctx->data);
> +       err = xa_alloc(&pvr_dev->ctx_ids, &ctx->ctx_id, ctx, xa_limit_32b, GFP_KERNEL);
>         if (err)
>                 goto err_free_ctx_data;
> 
> +       err = pvr_context_create_queues(ctx, args, ctx->data);
> +       if (err)
> +               goto err_free_ctx_id;
> +
>         err = init_fw_objs(ctx, args, ctx->data);
>         if (err)
>                 goto err_destroy_queues;
> @@ -329,23 +333,12 @@ int pvr_context_create(struct pvr_file *pvr_file, struct drm_pvr_ioctl_create_co
>         err = pvr_fw_object_create(pvr_dev, ctx_size, PVR_BO_FW_FLAGS_DEVICE_UNCACHED,
>                                    ctx_fw_data_init, ctx, &ctx->fw_obj);
>         if (err)
> -               goto err_free_ctx_data;
> +               goto err_destroy_queues;
> 
> -       err = xa_alloc(&pvr_dev->ctx_ids, &ctx->ctx_id, ctx, xa_limit_32b, GFP_KERNEL);
> +       err = xa_alloc(&pvr_file->ctx_handles, &args->handle, ctx, xa_limit_32b, GFP_KERNEL);
>         if (err)
>                 goto err_destroy_fw_obj;
> 
> -       err = xa_alloc(&pvr_file->ctx_handles, &args->handle, ctx, xa_limit_32b, GFP_KERNEL);
> -       if (err) {
> -               /*
> -                * It's possible that another thread could have taken a reference on the context at
> -                * this point as it is in the ctx_ids xarray. Therefore instead of directly
> -                * destroying the context, drop a reference instead.
> -                */
> -               pvr_context_put(ctx);
> -               return err;
> -       }
> -
>         spin_lock(&pvr_dev->ctx_list_lock);
>         list_add_tail(&ctx->file_link, &pvr_file->contexts);
>         spin_unlock(&pvr_dev->ctx_list_lock);
> @@ -358,6 +351,15 @@ int pvr_context_create(struct pvr_file *pvr_file, struct drm_pvr_ioctl_create_co
>  err_destroy_queues:
>         pvr_context_destroy_queues(ctx);
> 
> +err_free_ctx_id:
> +       /*
> +        * Ctx_id is not exposed to userspace and not visible yet within
> +        * the kernel/FW, plus a matching context handle (exposed to userspace)
> +        * hasn't been allocated yet, so it is safe to remove ctx_id
> +        * from the ctx_ids xarray.
> +        */
> +       xa_erase(&pvr_dev->ctx_ids, ctx->ctx_id);
> +
>  err_free_ctx_data:
>         kfree(ctx->data);
> 
> 
> --
> 2.43.0
> 


-- 
Matt Coster
E: matt.coster@imgtec.com

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

  reply	other threads:[~2026-05-18 15:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12  6:47 [PATCH 0/4] drm/imagination: Multiple enhancement Brajesh Gupta
2026-05-12  6:47 ` [PATCH 1/4] drm/imagination: Populate FW common context ID before passing to the FW Brajesh Gupta
2026-05-18 15:01   ` Matt Coster [this message]
2026-05-19  8:27     ` Brajesh Gupta
2026-05-12  6:47 ` [PATCH 2/4] drm/imagination: Don't timeout job if its fence has been signaled Brajesh Gupta
2026-05-18 15:01   ` Matt Coster
2026-05-19  8:30     ` Brajesh Gupta
2026-05-12  6:47 ` [PATCH 3/4] drm/imagination: Rename FW booted to FW initialised Brajesh Gupta
2026-05-18 15:01   ` Matt Coster
2026-05-19  8:31     ` Brajesh Gupta
2026-05-12  6:47 ` [PATCH 4/4] drm/imagination: Access FW initialised state with READ/WRITE_ONCE Brajesh Gupta
2026-05-18 15:02   ` Matt Coster
2026-05-19  8:35     ` Brajesh Gupta

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=d24d4065-e121-4c78-9b7c-78a6561e0a1a@imgtec.com \
    --to=matt.coster@imgtec.com \
    --cc=Alessio.Belle@imgtec.com \
    --cc=Alexandru.Dadu@imgtec.com \
    --cc=Brajesh.Gupta@imgtec.com \
    --cc=Frank.Binns@imgtec.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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

all inboxes | Powered by JetHome®