From: "Christian König" <christian.koenig@amd.com>
To: Nirmoy Das <nirmoy.das@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/5] drm/amdgpu: allow variable BO struct creation
Date: Mon, 8 Mar 2021 19:12:38 +0100 [thread overview]
Message-ID: <74fdd82f-1661-a2c6-6cd4-650f33d8c7fb@amd.com> (raw)
In-Reply-To: <20210308153705.37414-1-nirmoy.das@amd.com>
Am 08.03.21 um 16:37 schrieb Nirmoy Das:
> Allow allocating BO structures with different structure size
> than struct amdgpu_bo.
>
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 9 +++++++--
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 +
> 2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index ac1bb5089260..d32379cbad89 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -543,9 +543,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 +636,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 +671,9 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
> int r;
>
> bp->flags = bp->flags & ~AMDGPU_GEM_CREATE_SHADOW;
> + if (bp->bo_ptr_size < sizeof(struct amdgpu_bo))
> + bp->bo_ptr_size = sizeof(struct amdgpu_bo);
> +
It's not strictly necessary, but I would prefer if you change all
callers of amdgpu_bo_create() to correctly do this instead of the check
here.
Christian.
> 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;
_______________________________________________
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-08 18:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-08 15:37 [PATCH 1/5] drm/amdgpu: allow variable BO struct creation Nirmoy Das
2021-03-08 15:37 ` [PATCH 2/5] drm/amdgpu: introduce struct amdgpu_bo_user Nirmoy Das
2021-03-08 20:24 ` Christian König
2021-03-08 15:37 ` [PATCH 3/5] drm/amdgpu: fb BO should be ttm_bo_type_device Nirmoy Das
2021-03-08 20:20 ` Christian König
2021-03-08 20:34 ` Alex Deucher
2021-03-08 20:36 ` Christian König
2021-03-08 15:37 ` [PATCH 4/5] drm/amdgpu: use amdgpu_bo_create_user() for when possible Nirmoy Das
2021-03-08 15:37 ` [PATCH 5/5] drm/amdgpu: use amdgpu_bo_user bo for metadata and tiling flag Nirmoy Das
2021-03-08 20:23 ` Christian König
2021-03-08 18:12 ` Christian König [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-03-05 15:06 [PATCH 1/5] drm/amdgpu: allow variable BO struct creation Nirmoy Das
2021-03-05 15:15 ` Christian König
2021-03-05 14:35 Nirmoy Das
2021-03-05 14:37 ` Christian König
2021-03-05 14:48 ` Nirmoy
2021-03-05 15:18 ` Christian König
2021-03-05 15:19 ` Nirmoy
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=74fdd82f-1661-a2c6-6cd4-650f33d8c7fb@amd.com \
--to=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.