All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Nirmoy Das <nirmoy.das@amd.com>, Christian.Koenig@amd.com
Cc: amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 4/5] drm/amdgpu: use tiling_flags of struct amdgpu_bo_user
Date: Fri, 5 Mar 2021 16:13:18 +0100	[thread overview]
Message-ID: <42997172-c13f-4f75-ca24-20bd7bb13243@gmail.com> (raw)
In-Reply-To: <20210305143532.5936-4-nirmoy.das@amd.com>



Am 05.03.21 um 15:35 schrieb Nirmoy Das:
> This flag is only needed for BOs created by amdgpu_gem_object_create(),
> so we can remove tiling_flags from the base class.
>
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 19 +++++++++++++++++--
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |  1 -
>   2 files changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 355d01ebce51..2e5cf46251af 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -1174,12 +1174,19 @@ int amdgpu_bo_fbdev_mmap(struct amdgpu_bo *bo,
>   int amdgpu_bo_set_tiling_flags(struct amdgpu_bo *bo, u64 tiling_flags)
>   {
>   	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
> +	struct amdgpu_bo_user *ubo;
> +
> +	if (bo->tbo.type != ttm_bo_type_device) {
> +		DRM_ERROR("can not set tiling_flags for a non-amdgpu_bo_user type BO\n");
> +		return -EINVAL;
> +	}

I would just replace this with a WARN_ON or even BUG_ON since we should 
never ever make kernel BOs accessible to users space.

But what could be is that this is used with an imported SG table BO, so 
you need to make this check bo->tbo.type == ttm_bo_type_kernel.

Christian.

>   
>   	if (adev->family <= AMDGPU_FAMILY_CZ &&
>   	    AMDGPU_TILING_GET(tiling_flags, TILE_SPLIT) > 6)
>   		return -EINVAL;
>   
> -	bo->tiling_flags = tiling_flags;
> +	ubo = container_of((bo), struct amdgpu_bo_user, bo);
> +	ubo->tiling_flags = tiling_flags;
>   	return 0;
>   }
>   
> @@ -1193,10 +1200,18 @@ int amdgpu_bo_set_tiling_flags(struct amdgpu_bo *bo, u64 tiling_flags)
>    */
>   void amdgpu_bo_get_tiling_flags(struct amdgpu_bo *bo, u64 *tiling_flags)
>   {
> +	struct amdgpu_bo_user *ubo;
> +
> +	if (bo->tbo.type != ttm_bo_type_device) {
> +		DRM_ERROR("can not get tiling_flags for a non-amdgpu_bo_user type BO\n");
> +		return;
> +	}
> +
>   	dma_resv_assert_held(bo->tbo.base.resv);
> +	ubo = container_of((bo), struct amdgpu_bo_user, bo);
>   
>   	if (tiling_flags)
> -		*tiling_flags = bo->tiling_flags;
> +		*tiling_flags = ubo->tiling_flags;
>   }
>   
>   /**
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> index cbb881afe6da..6cc38b71f7ca 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> @@ -91,7 +91,6 @@ struct amdgpu_bo {
>   	struct ttm_bo_kmap_obj		kmap;
>   	u64				flags;
>   	unsigned			pin_count;
> -	u64				tiling_flags;
>   	u64				metadata_flags;
>   	void				*metadata;
>   	u32				metadata_size;

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  reply	other threads:[~2021-03-05 15:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05 14:35 [PATCH 1/5] drm/amdgpu: allow variable BO struct creation Nirmoy Das
2021-03-05 14:35 ` [PATCH 2/5] drm/amdgpu: introduce struct amdgpu_bo_user Nirmoy Das
2021-03-05 15:16   ` Christian König
2021-03-05 14:35 ` [PATCH 3/5] drm/amdgpu: use amdgpu_bo_create_user() for gem object Nirmoy Das
2021-03-05 15:11   ` Christian König
2021-03-08 13:56     ` Nirmoy
2021-03-08 13:58       ` Christian König
2021-03-08 14:06         ` Nirmoy
2021-03-05 14:35 ` [PATCH 4/5] drm/amdgpu: use tiling_flags of struct amdgpu_bo_user Nirmoy Das
2021-03-05 15:13   ` Christian König [this message]
2021-03-05 14:35 ` [PATCH 5/5] drm/amdgpu: use metadata members " Nirmoy Das
2021-03-05 15:14   ` Christian König
2021-03-05 14:37 ` [PATCH 1/5] drm/amdgpu: allow variable BO struct creation Christian König
2021-03-05 14:48   ` Nirmoy
2021-03-05 15:18     ` Christian König
2021-03-05 15:19       ` Nirmoy
2021-03-05 15:06 Nirmoy Das
2021-03-05 15:06 ` [PATCH 4/5] drm/amdgpu: use tiling_flags of struct amdgpu_bo_user Nirmoy Das

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=42997172-c13f-4f75-ca24-20bd7bb13243@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=Christian.Koenig@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=nirmoy.das@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.