mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Liang, Prike" <Prike.Liang@amd.com>
To: "Koenig, Christian" <Christian.Koenig@amd.com>,
	Dan Carpenter <dan.carpenter@linaro.org>
Cc: "Deucher, Alexander" <Alexander.Deucher@amd.com>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	"Sharma, Shashank" <Shashank.Sharma@amd.com>,
	Arvind Yadav <Arvind.Yadav@amd.com>,
	"Khatri, Sunil" <Sunil.Khatri@amd.com>,
	"Zhang, Jesse(Jie)" <Jesse.Zhang@amd.com>,
	"Paneer Selvam, Arunpravin" <Arunpravin.PaneerSelvam@amd.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>
Subject: RE: [PATCH next] drm/amdgpu/userq: Fix error codes in mes_userq_mqd_create()
Date: Mon, 29 Sep 2025 06:15:55 +0000	[thread overview]
Message-ID: <DS7PR12MB6005F149007C50C77ACBFC99FB1BA@DS7PR12MB6005.namprd12.prod.outlook.com> (raw)
In-Reply-To: <DS7PR12MB6005B4FD8CABEE1A06594C66FB11A@DS7PR12MB6005.namprd12.prod.outlook.com>

[Public]

Regards,
      Prike

> -----Original Message-----
> From: Liang, Prike
> Sent: Friday, September 19, 2025 10:51 AM
> To: Koenig, Christian <Christian.Koenig@amd.com>; Dan Carpenter
> <dan.carpenter@linaro.org>
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; David Airlie
> <airlied@gmail.com>; Simona Vetter <simona@ffwll.ch>; Sharma, Shashank
> <Shashank.Sharma@amd.com>; Arvind Yadav <Arvind.Yadav@amd.com>; Khatri,
> Sunil <Sunil.Khatri@amd.com>; Zhang, Jesse(Jie) <Jesse.Zhang@amd.com>;
> Paneer Selvam, Arunpravin <Arunpravin.PaneerSelvam@amd.com>; amd-
> gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org; linux-
> kernel@vger.kernel.org; kernel-janitors@vger.kernel.org
> Subject: RE: [PATCH next] drm/amdgpu/userq: Fix error codes in
> mes_userq_mqd_create()
>
>
>
> Regards,
>       Prike
>
> > -----Original Message-----
> > From: Koenig, Christian <Christian.Koenig@amd.com>
> > Sent: Thursday, September 18, 2025 5:57 PM
> > To: Dan Carpenter <dan.carpenter@linaro.org>; Liang, Prike
> > <Prike.Liang@amd.com>
> > Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; David Airlie
> > <airlied@gmail.com>; Simona Vetter <simona@ffwll.ch>; Sharma, Shashank
> > <Shashank.Sharma@amd.com>; Arvind Yadav <Arvind.Yadav@amd.com>;
> > Khatri, Sunil <Sunil.Khatri@amd.com>; Zhang, Jesse(Jie)
> > <Jesse.Zhang@amd.com>; Paneer Selvam, Arunpravin
> > <Arunpravin.PaneerSelvam@amd.com>; amd- gfx@lists.freedesktop.org;
> > dri-devel@lists.freedesktop.org; linux- kernel@vger.kernel.org;
> > kernel-janitors@vger.kernel.org
> > Subject: Re: [PATCH next] drm/amdgpu/userq: Fix error codes in
> > mes_userq_mqd_create()
> >
> >
> >
> > On 18.09.25 11:46, Dan Carpenter wrote:
> > > Return the error code if amdgpu_userq_input_va_validate() fails.
> > > Don't return success.
> > >
> > > Fixes: 9e46b8bb0539 ("drm/amdgpu: validate userq buffer virtual
> > > address and size")
> > > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > > ---
> > >  drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 15 +++++++++------
> > >  1 file changed, 9 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> > > b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> > > index 2db9b2c63693..775b0bd5d6c4 100644
> > > --- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> > > +++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> > > @@ -298,8 +298,9 @@ static int mes_userq_mqd_create(struct
> > amdgpu_userq_mgr *uq_mgr,
> > >                   goto free_mqd;
> > >           }
> > >
> > > -         if (amdgpu_userq_input_va_validate(queue->vm, compute_mqd-
> > >eop_va,
> > > -             max_t(u32, PAGE_SIZE, AMDGPU_GPU_PAGE_SIZE)))
> > > +         r = amdgpu_userq_input_va_validate(queue->vm, compute_mqd-
> > >eop_va,
> > > +             max_t(u32, PAGE_SIZE, AMDGPU_GPU_PAGE_SIZE));
> >
> > That code is nonsense to begin with, AMDGPU_GPU_PAGE_SIZE is always <=
> > PAGE_SIZE or otherwise the whole driver stack doesn't work.
> >
> > We should probably drop the max_t() as well.
>
> The userq EOP buffer size is determined by the Mesa driver using dev_info-
> >gart_page_size.
> Accordingly, we align the expected userq EOP size with dev_info->gart_page_size
> and use it to verify that the EOP buffer whether is resident within a valid mapping
> range.
We could assign the return code inline in the if() condition. I’ll incorporate this and make it explicit in the following VA track patch sets.

Regards,
  Prike
> Thanks,
> Prike
> > Regards,
> > Christian.
> >
> > > +         if (r)
> > >                   goto free_mqd;
> > >
> > >           userq_props->eop_gpu_addr = compute_mqd->eop_va; @@ -330,8
> > +331,9
> > > @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr,
> > >           userq_props->tmz_queue =
> > >                   mqd_user->flags &
> > AMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE;
> > >
> > > -         if (amdgpu_userq_input_va_validate(queue->vm, mqd_gfx_v11-
> > >shadow_va,
> > > -             shadow_info.shadow_size))
> > > +         r = amdgpu_userq_input_va_validate(queue->vm, mqd_gfx_v11-
> > >shadow_va,
> > > +             shadow_info.shadow_size);
> > > +         if (r)
> > >                   goto free_mqd;
> > >
> > >           kfree(mqd_gfx_v11);
> > > @@ -351,8 +353,9 @@ static int mes_userq_mqd_create(struct
> > amdgpu_userq_mgr *uq_mgr,
> > >                   goto free_mqd;
> > >           }
> > >
> > > -         if (amdgpu_userq_input_va_validate(queue->vm, mqd_sdma_v11-
> > >csa_va,
> > > -             shadow_info.csa_size))
> > > +         r = amdgpu_userq_input_va_validate(queue->vm, mqd_sdma_v11-
> > >csa_va,
> > > +             shadow_info.csa_size);
> > > +         if (r)
> > >                   goto free_mqd;
> > >
> > >           userq_props->csa_addr = mqd_sdma_v11->csa_va;


      reply	other threads:[~2025-09-29  6:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-18  9:46 Dan Carpenter
2025-09-18  9:57 ` Christian König
2025-09-19  2:50   ` Liang, Prike
2025-09-29  6:15     ` Liang, Prike [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=DS7PR12MB6005F149007C50C77ACBFC99FB1BA@DS7PR12MB6005.namprd12.prod.outlook.com \
    --to=prike.liang@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Arunpravin.PaneerSelvam@amd.com \
    --cc=Arvind.Yadav@amd.com \
    --cc=Christian.Koenig@amd.com \
    --cc=Jesse.Zhang@amd.com \
    --cc=Shashank.Sharma@amd.com \
    --cc=Sunil.Khatri@amd.com \
    --cc=airlied@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dan.carpenter@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=simona@ffwll.ch \
    /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®