All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zhang, Jerry (Junwei)" <Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>
To: "Christian König"
	<ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 08/11] drm/amdgpu: add amdgpu_gmc_pd_addr helper
Date: Thu, 23 Aug 2018 11:07:51 +0800	[thread overview]
Message-ID: <5B7E2507.5050205@amd.com> (raw)
In-Reply-To: <20180822150517.2330-8-christian.koenig-5C7GfCeVMHo@public.gmane.org>

On 08/22/2018 11:05 PM, Christian König wrote:
> Add a helper to get the root PD address and remove the workarounds from
> the GMC9 code for that.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/Makefile           |  3 +-
>   .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c  |  5 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c        |  2 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c       | 47 +++++++++++++++++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h       |  2 +
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c       |  2 +-
>   drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c      |  7 +--
>   drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c         |  4 --
>   drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c       |  7 +--
>   9 files changed, 56 insertions(+), 23 deletions(-)
>   create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile
> index 860cb8731c7c..d2bafabe585d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/Makefile
> +++ b/drivers/gpu/drm/amd/amdgpu/Makefile
> @@ -51,7 +51,8 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \
>   	amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \
>   	amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \
>   	amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o amdgpu_atomfirmware.o \
> -	amdgpu_vf_error.o amdgpu_sched.o amdgpu_debugfs.o amdgpu_ids.o
> +	amdgpu_vf_error.o amdgpu_sched.o amdgpu_debugfs.o amdgpu_ids.o \
> +	amdgpu_gmc.o
>
>   # add asic specific block
>   amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> index 7eadc58231f2..2e2393fe09b2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> @@ -364,7 +364,6 @@ static int vm_validate_pt_pd_bos(struct amdgpu_vm *vm)
>   	struct amdgpu_bo *pd = vm->root.base.bo;
>   	struct amdgpu_device *adev = amdgpu_ttm_adev(pd->tbo.bdev);
>   	struct amdgpu_vm_parser param;
> -	uint64_t addr, flags = AMDGPU_PTE_VALID;
>   	int ret;
>
>   	param.domain = AMDGPU_GEM_DOMAIN_VRAM;
> @@ -383,9 +382,7 @@ static int vm_validate_pt_pd_bos(struct amdgpu_vm *vm)
>   		return ret;
>   	}
>
> -	addr = amdgpu_bo_gpu_offset(vm->root.base.bo);
> -	amdgpu_gmc_get_vm_pde(adev, -1, &addr, &flags);
> -	vm->pd_phys_addr = addr;
> +	vm->pd_phys_addr = amdgpu_gmc_pd_addr(vm->root.base.bo);
>
>   	if (vm->use_cpu_for_update) {
>   		ret = amdgpu_bo_kmap(pd, NULL);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index 17bf63f93c93..d268035cf2f3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> @@ -946,7 +946,7 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)
>   	if (r)
>   		return r;
>
> -	p->job->vm_pd_addr = amdgpu_bo_gpu_offset(vm->root.base.bo);
> +	p->job->vm_pd_addr = amdgpu_gmc_pd_addr(vm->root.base.bo);
>
>   	if (amdgpu_vm_debug) {
>   		/* Invalidate all BOs to test for userspace bugs */
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> new file mode 100644
> index 000000000000..36058feac64f
> --- /dev/null
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> @@ -0,0 +1,47 @@
> +/*
> + * Copyright 2018 Advanced Micro Devices, Inc.
> + * All Rights Reserved.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the
> + * "Software"), to deal in the Software without restriction, including
> + * without limitation the rights to use, copy, modify, merge, publish,
> + * distribute, sub license, and/or sell copies of the Software, and to
> + * permit persons to whom the Software is furnished to do so, subject to
> + * the following conditions:
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
> + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
> + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
> + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
> + * USE OR OTHER DEALINGS IN THE SOFTWARE.
> + *
> + * The above copyright notice and this permission notice (including the
> + * next paragraph) shall be included in all copies or substantial portions
> + * of the Software.
> + *
> + */
> +
> +#include "amdgpu.h"
> +
> +/**
> + * amdgpu_gmc_pd_addr - return the address of the root directory
> + *
> + */
> +uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo)

If the func is going to handle all pd address, it's better to be called in gmc6,7,8 as well.

> +{
> +	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
> +	uint64_t pd_addr;
> +
> +	pd_addr = amdgpu_bo_gpu_offset(bo);
> +	/* TODO: move that into ASIC specific code */

Sounds it could be a func(.gmc_pd_addr) in the group of amdgpu_gmc_funcs?

Regards,
Jerry

> +	if (adev->asic_type >= CHIP_VEGA10) {
> +		uint64_t flags = AMDGPU_PTE_VALID;
> +
> +		amdgpu_gmc_get_vm_pde(adev, -1, &pd_addr, &flags);
> +		pd_addr |= flags;
> +	}
> +	return pd_addr;
> +}
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> index f3ea0a6d4660..7c469cce0498 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> @@ -131,4 +131,6 @@ static inline bool amdgpu_gmc_vram_full_visible(struct amdgpu_gmc *gmc)
>   	return (gmc->real_vram_size == gmc->visible_vram_size);
>   }
>
> +uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo);
> +
>   #endif
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index e7f73deed975..eb08a03b82a0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -2049,7 +2049,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset,
>   		return r;
>
>   	if (vm_needs_flush) {
> -		job->vm_pd_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
> +		job->vm_pd_addr = amdgpu_gmc_pd_addr(adev->gart.bo);
>   		job->vm_needs_flush = true;
>   	}
>   	if (resv) {
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c
> index 2baab7e69ef5..3403ded39d13 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c
> @@ -37,12 +37,7 @@ u64 gfxhub_v1_0_get_mc_fb_offset(struct amdgpu_device *adev)
>
>   static void gfxhub_v1_0_init_gart_pt_regs(struct amdgpu_device *adev)
>   {
> -	uint64_t value = amdgpu_bo_gpu_offset(adev->gart.bo);
> -
> -	BUG_ON(value & (~0x0000FFFFFFFFF000ULL));
> -	value -= adev->gmc.vram_start + adev->vm_manager.vram_base_offset;
> -	value &= 0x0000FFFFFFFFF000ULL;
> -	value |= 0x1; /*valid bit*/
> +	uint64_t value = amdgpu_gmc_pd_addr(adev->gart.bo);
>
>   	WREG32_SOC15(GC, 0, mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32,
>   		     lower_32_bits(value));
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> index 3393a329fc9c..e12e007cf7d9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> @@ -436,12 +436,8 @@ static uint64_t gmc_v9_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring,
>   	struct amdgpu_device *adev = ring->adev;
>   	struct amdgpu_vmhub *hub = &adev->vmhub[ring->funcs->vmhub];
>   	uint32_t req = gmc_v9_0_get_invalidate_req(vmid);
> -	uint64_t flags = AMDGPU_PTE_VALID;
>   	unsigned eng = ring->vm_inv_eng;
>
> -	amdgpu_gmc_get_vm_pde(adev, -1, &pd_addr, &flags);
> -	pd_addr |= flags;
> -
>   	amdgpu_ring_emit_wreg(ring, hub->ctx0_ptb_addr_lo32 + (2 * vmid),
>   			      lower_32_bits(pd_addr));
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
> index 800ec4687f13..5f6a9c85488f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
> @@ -47,12 +47,7 @@ u64 mmhub_v1_0_get_fb_location(struct amdgpu_device *adev)
>
>   static void mmhub_v1_0_init_gart_pt_regs(struct amdgpu_device *adev)
>   {
> -	uint64_t value = amdgpu_bo_gpu_offset(adev->gart.bo);
> -
> -	BUG_ON(value & (~0x0000FFFFFFFFF000ULL));
> -	value -= adev->gmc.vram_start + adev->vm_manager.vram_base_offset;
> -	value &= 0x0000FFFFFFFFF000ULL;
> -	value |= 0x1; /* valid bit */
> +	uint64_t value = amdgpu_gmc_pd_addr(adev->gart.bo);
>
>   	WREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32,
>   		     lower_32_bits(value));
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-08-23  3:07 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-22 15:05 [PATCH 01/11] drm/amdgpu: remove extra root PD alignment Christian König
     [not found] ` <20180822150517.2330-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-22 15:05   ` [PATCH 02/11] drm/amdgpu: validate the VM root PD from the VM code Christian König
     [not found]     ` <20180822150517.2330-2-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-23  2:46       ` Zhang, Jerry (Junwei)
2018-08-23  7:28       ` Huang Rui
2018-08-23 12:01         ` Christian König
2018-08-22 15:05   ` [PATCH 03/11] drm/amdgpu: cleanup VM handling in the CS a bit Christian König
     [not found]     ` <20180822150517.2330-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-22 19:49       ` Alex Deucher
2018-08-23  7:54       ` Huang Rui
2018-08-22 15:05   ` [PATCH 04/11] drm/amdgpu: move setting the GART addr into TTM Christian König
     [not found]     ` <20180822150517.2330-4-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-22 19:50       ` Alex Deucher
2018-08-23 11:23       ` Huang Rui
2018-08-22 15:05   ` [PATCH 05/11] drm/amdgpu: rename gart.robj into gart.bo Christian König
     [not found]     ` <20180822150517.2330-5-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-22 19:50       ` Alex Deucher
2018-08-23 11:27       ` Huang Rui
2018-08-22 15:05   ` [PATCH 06/11] drm/amdgpu: remove gart.table_addr Christian König
2018-08-22 15:05   ` [PATCH 07/11] drm/amdgpu: add GMC9 support for PDs/PTs in system memory Christian König
     [not found]     ` <20180822150517.2330-7-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-23  2:50       ` Zhang, Jerry (Junwei)
     [not found]         ` <5B7E2109.3020406-5C7GfCeVMHo@public.gmane.org>
2018-08-23 11:39           ` Huang Rui
2018-08-23 11:40       ` Huang Rui
2018-08-22 15:05   ` [PATCH 08/11] drm/amdgpu: add amdgpu_gmc_pd_addr helper Christian König
     [not found]     ` <20180822150517.2330-8-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-22 22:09       ` Felix Kuehling
2018-08-23  3:07       ` Zhang, Jerry (Junwei) [this message]
     [not found]         ` <5B7E2507.5050205-5C7GfCeVMHo@public.gmane.org>
2018-08-23 12:18           ` Christian König
2018-08-23 11:42       ` Huang Rui
2018-08-22 15:05   ` [PATCH 09/11] drm/amdgpu: add amdgpu_gmc_get_pde_for_bo helper Christian König
     [not found]     ` <20180822150517.2330-9-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-23 12:45       ` Huang Rui
2018-08-22 15:05   ` [PATCH 10/11] drm/amdgpu: add helper for VM PD/PT allocation parameters Christian König
     [not found]     ` <20180822150517.2330-10-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-22 19:55       ` Alex Deucher
2018-08-23  3:19       ` Zhang, Jerry (Junwei)
2018-08-23 12:46       ` Huang Rui
2018-08-22 15:05   ` [PATCH 11/11] drm/amdgpu: enable GTT PD/PT for raven Christian König
     [not found]     ` <20180822150517.2330-11-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-22 15:44       ` Andrey Grodzovsky
     [not found]         ` <f5c10bb6-4d93-5102-2c3b-ae0e161b70e1-5C7GfCeVMHo@public.gmane.org>
2018-08-23 12:54           ` Huang Rui
2018-08-23 13:02             ` Christian König
2018-08-23  5:28       ` Zhang, Jerry (Junwei)
2018-08-22 19:46   ` [PATCH 01/11] drm/amdgpu: remove extra root PD alignment Alex Deucher
     [not found]     ` <CADnq5_OscxLwhzUnR9pcQ9cRVLPK1YyqEp6kCGOdVWahWPKEUg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-08-23  2:36       ` Zhang, Jerry (Junwei)
2018-08-23  6:52       ` Christian König
2018-08-23  7:21   ` Huang Rui

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=5B7E2507.5050205@amd.com \
    --to=jerry.zhang-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@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 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.