From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Nirmoy Das <nirmoy.das@amd.com>, Christian.Koenig@amd.com
Cc: felix.kuehling@amd.com, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 1/5] drm/amdgpu: allow variable BO struct creation
Date: Tue, 9 Mar 2021 13:36:15 +0100 [thread overview]
Message-ID: <78dda73e-ef55-b33e-2dac-bcb0dda0dc04@gmail.com> (raw)
In-Reply-To: <20210309084659.37649-1-nirmoy.das@amd.com>
Am 09.03.21 um 09:46 schrieb Nirmoy Das:
> Allow allocating BO structures with different structure size
> than struct amdgpu_bo.
>
> v2: Check bo_ptr_size in all amdgpu_bo_create() caller.
>
> CC: felix.kuehling@amd.com
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 2 ++
> drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 2 ++
> drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 2 ++
> drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 ++
> drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 2 ++
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 8 ++++++--
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 +
> drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 1 +
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 1 +
> 9 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> index f44185f512de..2151fcb1e19d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> @@ -245,6 +245,7 @@ int amdgpu_amdkfd_alloc_gtt_mem(struct kgd_dev *kgd, size_t size,
> bp.flags = AMDGPU_GEM_CREATE_CPU_GTT_USWC;
> bp.type = ttm_bo_type_kernel;
> bp.resv = NULL;
> + bp.bo_ptr_size = sizeof(struct amdgpu_bo);
>
> if (cp_mqd_gfx9)
> bp.flags |= AMDGPU_GEM_CREATE_CP_MQD_GFX9;
> @@ -326,6 +327,7 @@ int amdgpu_amdkfd_alloc_gws(struct kgd_dev *kgd, size_t size,
> bp.flags = AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
> bp.type = ttm_bo_type_device;
> bp.resv = NULL;
> + bp.bo_ptr_size = sizeof(struct amdgpu_bo);
>
> r = amdgpu_bo_create(adev, &bp, &bo);
> if (r) {
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> index d9b35df33806..313517f7cf10 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> @@ -85,6 +85,8 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,
> bp.flags = 0;
> bp.type = ttm_bo_type_kernel;
> bp.resv = NULL;
> + bp.bo_ptr_size = sizeof(struct amdgpu_bo);
> +
> n = AMDGPU_BENCHMARK_ITERATIONS;
> r = amdgpu_bo_create(adev, &bp, &sobj);
> if (r) {
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> index 5807cad833d3..c5a9a4fb10d2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> @@ -126,6 +126,8 @@ int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev)
> AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
> bp.type = ttm_bo_type_kernel;
> bp.resv = NULL;
> + bp.bo_ptr_size = sizeof(struct amdgpu_bo);
> +
> r = amdgpu_bo_create(adev, &bp, &adev->gart.bo);
> if (r) {
> return r;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> index fb7171e5507c..bca260d56f76 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> @@ -71,6 +71,8 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,
> bp.preferred_domain = initial_domain;
> bp.flags = flags;
> bp.domain = initial_domain;
> + bp.bo_ptr_size = sizeof(struct amdgpu_bo);
> +
> r = amdgpu_bo_create(adev, &bp, &bo);
> if (r)
> return r;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> index 6f7995293a1e..1e07c66676c2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> @@ -55,6 +55,8 @@ int amdgpu_gmc_pdb0_alloc(struct amdgpu_device *adev)
> AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
> bp.type = ttm_bo_type_kernel;
> bp.resv = NULL;
> + bp.bo_ptr_size = sizeof(struct amdgpu_bo);
> +
> r = amdgpu_bo_create(adev, &bp, &adev->gmc.pdb0_bo);
> if (r)
> return r;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index ac1bb5089260..c30f10f931fc 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -248,6 +248,7 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
> bp.flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
> bp.type = ttm_bo_type_kernel;
> bp.resv = NULL;
> + bp.bo_ptr_size = sizeof(struct amdgpu_bo);
>
> if (!*bo_ptr) {
> r = amdgpu_bo_create(adev, &bp, bo_ptr);
> @@ -543,9 +544,10 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
> if (!amdgpu_bo_validate_size(adev, size, bp->domain))
> return -ENOMEM;
>
> - *bo_ptr = NULL;
> + BUG_ON(bp->bo_ptr_size < sizeof(struct amdgpu_bo));
>
> - bo = kzalloc(sizeof(struct amdgpu_bo), GFP_KERNEL);
> + *bo_ptr = NULL;
> + bo = kzalloc(bp->bo_ptr_size, GFP_KERNEL);
> if (bo == NULL)
> return -ENOMEM;
> drm_gem_private_object_init(adev_to_drm(adev), &bo->tbo.base, size);
> @@ -635,6 +637,7 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev,
> AMDGPU_GEM_CREATE_SHADOW;
> bp.type = ttm_bo_type_kernel;
> bp.resv = bo->tbo.base.resv;
> + bp.bo_ptr_size = sizeof(struct amdgpu_bo);
>
> r = amdgpu_bo_do_create(adev, &bp, &bo->shadow);
> if (!r) {
> @@ -669,6 +672,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
> int r;
>
> bp->flags = bp->flags & ~AMDGPU_GEM_CREATE_SHADOW;
> +
> r = amdgpu_bo_do_create(adev, bp, bo_ptr);
> if (r)
> return r;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> index 54ceb065e546..8e2b556f0b7b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> @@ -40,6 +40,7 @@
> struct amdgpu_bo_param {
> unsigned long size;
> int byte_align;
> + u32 bo_ptr_size;
> u32 domain;
> u32 preferred_domain;
> u64 flags;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
> index 7b230bcbf2c6..909d830b513e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
> @@ -62,6 +62,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
> bp.flags = 0;
> bp.type = ttm_bo_type_kernel;
> bp.resv = NULL;
> + bp.bo_ptr_size = sizeof(struct amdgpu_bo);
>
> r = amdgpu_bo_create(adev, &bp, &vram_obj);
> if (r) {
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 9d19078246c8..a8f8b9a06899 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -869,6 +869,7 @@ static void amdgpu_vm_bo_param(struct amdgpu_device *adev, struct amdgpu_vm *vm,
> bp->domain = amdgpu_bo_get_preferred_pin_domain(adev, bp->domain);
> bp->flags = AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |
> AMDGPU_GEM_CREATE_CPU_GTT_USWC;
> + bp->bo_ptr_size = sizeof(struct amdgpu_bo);
> if (vm->use_cpu_for_update)
> bp->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
> else if (!vm->root.base.bo || vm->root.base.bo->shadow)
> --
> 2.30.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2021-03-09 12:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-09 8:46 [PATCH v2 1/5] drm/amdgpu: allow variable BO struct creation Nirmoy Das
2021-03-09 8:46 ` [PATCH v2 2/5] drm/amdgpu: introduce struct amdgpu_bo_user Nirmoy Das
2021-03-09 12:37 ` Christian König
2021-03-09 8:46 ` [PATCH 3/5] drm/amdgpu: fb BO should be ttm_bo_type_device Nirmoy Das
2021-03-09 12:39 ` Christian König
2021-03-09 14:33 ` Nirmoy
2021-03-09 15:08 ` Christian König
2021-03-09 8:46 ` [PATCH 4/5] drm/amdgpu: use amdgpu_bo_create_user() for when possible Nirmoy Das
2021-03-09 12:40 ` Christian König
2021-03-09 8:46 ` [PATCH v3 5/5] drm/amdgpu: use amdgpu_bo_user bo for metadata and tiling flag Nirmoy Das
2021-03-09 12:42 ` Christian König
2021-03-09 12:36 ` Christian König [this message]
2021-03-10 22:17 ` [PATCH v2 1/5] drm/amdgpu: allow variable BO struct creation Felix Kuehling
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=78dda73e-ef55-b33e-2dac-bcb0dda0dc04@gmail.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=Christian.Koenig@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=felix.kuehling@amd.com \
--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.