From: Huang Rui <ray.huang-5C7GfCeVMHo@public.gmane.org>
To: "Koenig, Christian" <Christian.Koenig-5C7GfCeVMHo@public.gmane.org>
Cc: "Zhou,
David(ChunMing)" <David1.Zhou-5C7GfCeVMHo@public.gmane.org>,
"Kuehling, Felix" <Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>,
"amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: [PATCH 2/2] drm/amdgpu: use amdgpu_bo_parm for amdgpu_bo_create
Date: Tue, 17 Apr 2018 09:39:09 +0800 [thread overview]
Message-ID: <20180417013908.GA31085@hr-amur2> (raw)
In-Reply-To: <d98bf0ab-8897-aebb-6487-18f082cefddc-5C7GfCeVMHo@public.gmane.org>
On Mon, Apr 16, 2018 at 08:20:59PM +0800, Koenig, Christian wrote:
> Am 16.04.2018 um 13:43 schrieb Huang Rui:
> > On Mon, Apr 16, 2018 at 07:13:05PM +0800, Chunming Zhou wrote:
> >> after that, we can easily add new parameter when need.
> >>
> >> Change-Id: I6e80039c3801f163129ecc605d931483fdbc91db
> >> Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
> >> Cc: christian.koenig@amd.com
> >> Cc: Felix.Kuehling@amd.com
> >> ---
> >> drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 12 ++++++--
> >> drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 10 +++++--
> >> drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 15 +++++++---
> >> drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 16 ++++++----
> >> drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 11 +++++--
> >> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 38 +++++++++++-------------
> >> drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 6 ++--
> >> drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 12 ++++++--
> >> drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 16 ++++++----
> >> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 15 ++++++----
> >> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 24 ++++++++++-----
> >> 11 files changed, 114 insertions(+), 61 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> >> index 4d36203ffb11..f90405e572f9 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> >> @@ -217,13 +217,19 @@ int alloc_gtt_mem(struct kgd_dev *kgd, size_t size,
> >> {
> >> struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
> >> struct amdgpu_bo *bo = NULL;
> >> + struct amdgpu_bo_param bp = {
> >> + .size = size,
> >> + .byte_align = PAGE_SIZE,
> >> + .domain = AMDGPU_GEM_DOMAIN_GTT,
> >> + .flags = AMDGPU_GEM_CREATE_CPU_GTT_USWC,
> >> + .type = ttm_bo_type_kernel,
> >> + .resv = NULL
> >> + };
> >> int r;
> >> uint64_t gpu_addr_tmp = 0;
> >> void *cpu_ptr_tmp = NULL;
> >>
> >> - r = amdgpu_bo_create(adev, size, PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,
> >> - AMDGPU_GEM_CREATE_CPU_GTT_USWC, ttm_bo_type_kernel,
> >> - NULL, &bo);
> >> + r = amdgpu_bo_create(adev, &bp, &bo);
> >> if (r) {
> >> dev_err(adev->dev,
> >> "failed to allocate BO for amdkfd (%d)\n", r);
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> >> index 1d6e1479da38..b7bd24c35b25 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> >> @@ -1004,6 +1004,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
> >> struct amdgpu_device *adev = get_amdgpu_device(kgd);
> >> struct amdgpu_vm *avm = (struct amdgpu_vm *)vm;
> >> struct amdgpu_bo *bo;
> >> + struct amdgpu_bo_param bp;
> >> int byte_align;
> >> u32 alloc_domain;
> >> u64 alloc_flags;
> >> @@ -1069,8 +1070,13 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
> >> pr_debug("\tcreate BO VA 0x%llx size 0x%llx domain %s\n",
> >> va, size, domain_string(alloc_domain));
> >>
> >> - ret = amdgpu_bo_create(adev, size, byte_align,
> >> - alloc_domain, alloc_flags, ttm_bo_type_device, NULL, &bo);
> >> + bp.size = size;
> >> + bp.byte_align = byte_align;
> >> + bp.domain = alloc_domain;
> >> + bp.flags = alloc_flags;
> >> + bp.type = ttm_bo_type_device;
> >> + bp.resv = NULL;
> >> + ret = amdgpu_bo_create(adev, &bp, &bo);
> >> if (ret) {
> >> pr_debug("Failed to create BO on domain %s. ret %d\n",
> >> domain_string(alloc_domain), ret);
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> >> index 02b849be083b..96bdb454bdf6 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c
> >> @@ -75,13 +75,20 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,
> >> {
> >> struct amdgpu_bo *dobj = NULL;
> >> struct amdgpu_bo *sobj = NULL;
> >> + struct amdgpu_bo_param bp = {
> >> + .size = size,
> >> + .byte_align = PAGE_SIZE,
> >> + .domain = sdomain,
> >> + .flags = 0,
> >> + .type = ttm_bo_type_kernel,
> >> + .resv = NULL
> >> + };
> >> uint64_t saddr, daddr;
> >> int r, n;
> >> int time;
> >>
> >> n = AMDGPU_BENCHMARK_ITERATIONS;
> >> - r = amdgpu_bo_create(adev, size, PAGE_SIZE,sdomain, 0,
> >> - ttm_bo_type_kernel, NULL, &sobj);
> >> + r = amdgpu_bo_create(adev, &bp, &sobj);
> >> if (r) {
> >> goto out_cleanup;
> >> }
> >> @@ -93,8 +100,8 @@ static void amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,
> >> if (r) {
> >> goto out_cleanup;
> >> }
> >> - r = amdgpu_bo_create(adev, size, PAGE_SIZE, ddomain, 0,
> >> - ttm_bo_type_kernel, NULL, &dobj);
> >> + bp.domain = ddomain;
> >> + r = amdgpu_bo_create(adev, &bp, &dobj);
> >> if (r) {
> >> goto out_cleanup;
> >> }
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> >> index cf0f186c6092..1f9b8ae7ad2b 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> >> @@ -110,15 +110,19 @@ static void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev)
> >> */
> >> int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev)
> >> {
> >> + struct amdgpu_bo_param bp = {
> >> + .size = adev->gart.table_size,
> >> + .byte_align = PAGE_SIZE,
> >> + .domain = AMDGPU_GEM_DOMAIN_VRAM,
> >> + .flags = AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
> >> + AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS,
> >> + .type = ttm_bo_type_kernel,
> >> + .resv = NULL
> >> + };
> >> int r;
> >>
> >> if (adev->gart.robj == NULL) {
> >> - r = amdgpu_bo_create(adev, adev->gart.table_size, PAGE_SIZE,
> >> - AMDGPU_GEM_DOMAIN_VRAM,
> >> - AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
> >> - AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS,
> >> - ttm_bo_type_kernel, NULL,
> >> - &adev->gart.robj);
> >> + r = amdgpu_bo_create(adev, &bp, &adev->gart.robj);
> >> 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 28c2706e48d7..e8f947d3da53 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> >> @@ -48,6 +48,14 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,
> >> struct drm_gem_object **obj)
> >> {
> >> struct amdgpu_bo *bo;
> >> + struct amdgpu_bo_param bp = {
> >> + .size = size,
> >> + .byte_align = alignment,
> >> + .domain = initial_domain,
> >> + .flags = flags,
> >> + .type = type,
> >> + .resv = resv
> >> + };
> >> int r;
> >>
> >> *obj = NULL;
> >> @@ -56,8 +64,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,
> >> alignment = PAGE_SIZE;
> >> }
> >>
> >> - r = amdgpu_bo_create(adev, size, alignment, initial_domain,
> >> - flags, type, resv, &bo);
> >> + r = amdgpu_bo_create(adev, &bp, &bo);
> >> if (r) {
> >> DRM_DEBUG("Failed to allocate GEM object (%ld, %d, %u, %d)\n",
> >> size, initial_domain, alignment, r);
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> >> index b557b63bb648..a7a73ea18704 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> >> @@ -191,14 +191,20 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
> >> u32 domain, struct amdgpu_bo **bo_ptr,
> >> u64 *gpu_addr, void **cpu_addr)
> >> {
> >> + struct amdgpu_bo_param bp = {
> >> + .size = size,
> >> + .byte_align = align,
> >> + .domain = domain,
> >> + .flags = AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
> >> + AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS,
> >> + .type = ttm_bo_type_kernel,
> >> + .resv = NULL
> >> + };
> > Others looks good.
> > How about also use amdgpu_bo_param for amdgpu_bo_create_kernel function?
>
> I really wanted to keep the _kernel and _reserved variant simple enough
> to not need that.
>
That's fine. I have no problem.
Reviewed-by: Huang Rui <ray.huang@amd.com>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2018-04-17 1:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-16 11:13 [PATCH 1/2] drm/amdgpu: add amdgpu_bo_param Chunming Zhou
[not found] ` <20180416111305.640-1-david1.zhou-5C7GfCeVMHo@public.gmane.org>
2018-04-16 11:13 ` [PATCH 2/2] drm/amdgpu: use amdgpu_bo_parm for amdgpu_bo_create Chunming Zhou
[not found] ` <20180416111305.640-2-david1.zhou-5C7GfCeVMHo@public.gmane.org>
2018-04-16 11:43 ` Huang Rui
2018-04-16 12:20 ` Christian König
[not found] ` <d98bf0ab-8897-aebb-6487-18f082cefddc-5C7GfCeVMHo@public.gmane.org>
2018-04-17 1:39 ` Huang Rui [this message]
2018-04-16 11:41 ` [PATCH 1/2] drm/amdgpu: add amdgpu_bo_param Huang Rui
2018-04-16 12:23 ` Christian König
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=20180417013908.GA31085@hr-amur2 \
--to=ray.huang-5c7gfcevmho@public.gmane.org \
--cc=Christian.Koenig-5C7GfCeVMHo@public.gmane.org \
--cc=David1.Zhou-5C7GfCeVMHo@public.gmane.org \
--cc=Felix.Kuehling-5C7GfCeVMHo@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
/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