AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Sunil Khatri <sunil.khatri@amd.com>,
	Felix Kuehling <felix.kuehling@amd.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	amd-gfx@lists.freedesktop.org
Subject: Re: [Patch v2 2/2] drm/amdgpu: move variable declaration to top of amdgpu_cs_parser_bos
Date: Wed, 24 Sep 2025 14:09:59 +0200	[thread overview]
Message-ID: <9c78383a-d32c-43f7-8a91-dc01690d0a51@amd.com> (raw)
In-Reply-To: <20250924100156.3746229-2-sunil.khatri@amd.com>



On 24.09.25 12:01, Sunil Khatri wrote:
> In function amdgpu_cs_parser_bos, declare the variables in the beginning
> of the function and not during the initialization.
> 
> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index 31eea1c7dac3..a9bdc368c981 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> @@ -854,6 +854,9 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
>  	struct amdgpu_vm *vm = &fpriv->vm;
>  	struct amdgpu_bo_list_entry *e;
>  	struct drm_gem_object *obj;
> +	struct amdgpu_bo *bo;
> +	struct mm_struct *usermm;
> +	bool userpage_invalidated;
>  	unsigned long index;
>  	unsigned int i;
>  	int r;
> @@ -882,14 +885,12 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
>  	 * amdgpu_ttm_backend_bind() to flush and invalidate new pages
>  	 */
>  	amdgpu_bo_list_for_each_userptr_entry(e, p->bo_list) {
> -		bool userpage_invalidated = false;
> -		struct amdgpu_bo *bo = e->bo;
> +		userpage_invalidated = false;
> +		bo = e->bo;

Those can stay as they are. (Ok there should be an empty line between the declaration of variables and code).

>  		e->range = kzalloc(sizeof(*e->range), GFP_KERNEL);
>  		if (unlikely(!e->range))
>  			return -ENOMEM;
>  
> -		int i;
> -

But that here looks really fishy. It basically means that we have an "int it" declared in this block which overrides the "unsigned int i" declared.

Please make a patch just removing this "int it" here and feel free to just add my rb and push to amd-staging-drm-next.

I'm really wondering how the heck that happened?

Thanks,
Christian.


>  		r = amdgpu_ttm_tt_get_user_pages(bo, e->range);
>  		if (r)
>  			goto out_free_user_pages;
> @@ -930,8 +931,6 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
>  	}
>  
>  	amdgpu_bo_list_for_each_userptr_entry(e, p->bo_list) {
> -		struct mm_struct *usermm;
> -
>  		usermm = amdgpu_ttm_tt_get_usermm(e->bo->tbo.ttm);
>  		if (usermm && usermm != current->mm) {
>  			r = -EPERM;


  reply	other threads:[~2025-09-24 12:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-24 10:01 [Patch v2 1/2] drm/amdgpu: use user provided hmm_range buffer in amdgpu_ttm_tt_get_user_pages Sunil Khatri
2025-09-24 10:01 ` [Patch v2 2/2] drm/amdgpu: move variable declaration to top of amdgpu_cs_parser_bos Sunil Khatri
2025-09-24 12:09   ` Christian König [this message]
2025-09-24 16:57 ` [Patch v2 1/2] drm/amdgpu: use user provided hmm_range buffer in amdgpu_ttm_tt_get_user_pages Kuehling, Felix
2025-09-26 10:53   ` Khatri, Sunil
2025-10-01  5:41     ` Kuehling, Felix
2025-10-01  7:32       ` Christian König
2025-10-03 20:23     ` Chen, Xiaogang
2025-10-06 10:35       ` Khatri, Sunil

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=9c78383a-d32c-43f7-8a91-dc01690d0a51@amd.com \
    --to=christian.koenig@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=felix.kuehling@amd.com \
    --cc=sunil.khatri@amd.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