AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Jesse Zhang <Jesse.Zhang@amd.com>, amd-gfx@lists.freedesktop.org
Cc: Alexander.Deucher@amd.com, prike.liang@amd.com, sukhatri@amd.com
Subject: Re: [PATCH V2 1/2] drm/amdgpu/userq: only accept doorbell BOs as queue doorbell
Date: Wed, 30 Sep 2026 12:24:30 +0200	[thread overview]
Message-ID: <56aebc88-13d2-4571-b59f-ea286622b2b7@amd.com> (raw)
In-Reply-To: <20260930093912.177219-1-Jesse.Zhang@amd.com>

On 9/30/26 11:38, Jesse Zhang wrote:
> amdgpu_userq_get_doorbell_index() pins any BO passed as doorbell_handle
> into the doorbell domain. For a regular BO, TTM moves it with
> ttm_bo_move_null() and its contents are lost. Since an importer on the
> same device gets the exporter's GEM object, a client can do this to a
> buffer another client shared with it.
> 
> Reject BOs that were not created in the doorbell domain.
> 
> v2: drop the error message, use a local abo variable (Christian)
> 
> Fixes: f09c1e6077ab ("drm/amdgpu: generate doorbell index for userqueue")
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> index 89e03d3a930c..5a922f283743 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> @@ -469,6 +469,7 @@ amdgpu_userq_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr,
>  	u64 doorbell_index;
>  	struct drm_gem_object *gobj;
>  	struct amdgpu_userq_obj *db_obj = db_info->db_obj;
> +	struct amdgpu_bo *abo;
>  	int r, db_size;
>  
>  	gobj = drm_gem_object_lookup(filp, db_info->doorbell_handle);
> @@ -477,7 +478,17 @@ amdgpu_userq_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr,
>  		return -EINVAL;
>  	}
>  
> -	db_obj->obj = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj));
> +	/*
> +	 * Pinning a regular BO into the doorbell domain would discard its
> +	 * contents, possibly those of a buffer shared by another client.
> +	 */
> +	abo = gem_to_amdgpu_bo(gobj);
> +	if (!(abo->preferred_domains & AMDGPU_GEM_DOMAIN_DOORBELL)) {
> +		drm_gem_object_put(gobj);
> +		return -EINVAL;
> +	}
> +
> +	db_obj->obj = amdgpu_bo_ref(abo);
>  	drm_gem_object_put(gobj);
>  
>  	r = amdgpu_bo_reserve(db_obj->obj, true);


      parent reply	other threads:[~2026-09-30 10:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30  9:38 [PATCH V2 1/2] drm/amdgpu/userq: only accept doorbell BOs as queue doorbell Jesse Zhang
2026-09-30  9:38 ` [PATCH V2 2/2] drm/amdgpu/userq: return the memdup_user() error for the user MQD Jesse Zhang
2026-09-30 10:25   ` Christian König
2026-09-30 10:24 ` Christian König [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=56aebc88-13d2-4571-b59f-ea286622b2b7@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Jesse.Zhang@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=prike.liang@amd.com \
    --cc=sukhatri@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