From: "Zhang, Jerry (Junwei)" <Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>
To: "Christian König"
<deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 1/7] drm/amdgpu: cleanup adjust_mc_addr handling v2
Date: Thu, 25 May 2017 10:10:59 +0800 [thread overview]
Message-ID: <59263D33.3070706@amd.com> (raw)
In-Reply-To: <b9c0c5b3-a42c-b2e8-0b84-718807d5e7cf-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
On 05/24/2017 05:18 PM, Christian König wrote:
> Am 18.05.2017 um 07:33 schrieb Zhang, Jerry (Junwei):
>> On 05/17/2017 05:22 PM, Christian König wrote:
>>> [SNIP]
>>> +static uint64_t gmc_v6_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr)
>>> +{
>>> + BUG_ON(addr & 0xFFFFF0000000FFFULL);
>>> + return addr;
>>> +}
>>
>> Just wonder why we didn't return the address as below?
>> adev->vm_manager.vram_base_offset + addr
>
> That is a really good question and I couldn't figure out all the details either.
>
> I've tested it on an Kaveri and it still seems to work fine, so the logic is
> indeed correct.
Thanks for your verification.
Then it's a makeshift change for now, although it looks a little suspicious.
Let's dig it more in the future with HW team.
Please feel free to add my RB for the v3 one.
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
Jerry
>
>> Does that cause gmc6~gmc8 has no APU support officially?
>
> No, only the pro driver doesn't support APUs. The open source driver works
> perfectly fine on them.
>
>> Or I miss any info about them?
>
> The documentation for gfx6-8 is very unclear on this.
>
> It says that the registers and PDE should use physical addresses, but from my
> testing that isn't the case.
>
> Going to ping the hardware dev on this once more when I have time.
>
> Regards,
> Christian.
>
>>
>> Jerry
>>
>>> +
>>> static void gmc_v6_0_set_fault_enable_default(struct amdgpu_device *adev,
>>> bool value)
>>> {
>>> @@ -1127,6 +1133,7 @@ static const struct amdgpu_gart_funcs
>>> gmc_v6_0_gart_funcs = {
>>> .flush_gpu_tlb = gmc_v6_0_gart_flush_gpu_tlb,
>>> .set_pte_pde = gmc_v6_0_gart_set_pte_pde,
>>> .set_prt = gmc_v6_0_set_prt,
>>> + .get_vm_pde = gmc_v6_0_get_vm_pde,
>>> .get_vm_pte_flags = gmc_v6_0_get_vm_pte_flags
>>> };
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
>>> b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
>>> index 967505b..4f140e8 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
>>> @@ -472,6 +472,12 @@ static uint64_t gmc_v7_0_get_vm_pte_flags(struct
>>> amdgpu_device *adev,
>>> return pte_flag;
>>> }
>>>
>>> +static uint64_t gmc_v7_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr)
>>> +{
>>> + BUG_ON(addr & 0xFFFFF0000000FFFULL);
>>> + return addr;
>>> +}
>>> +
>>> /**
>>> * gmc_v8_0_set_fault_enable_default - update VM fault handling
>>> *
>>> @@ -1293,7 +1299,8 @@ static const struct amdgpu_gart_funcs
>>> gmc_v7_0_gart_funcs = {
>>> .flush_gpu_tlb = gmc_v7_0_gart_flush_gpu_tlb,
>>> .set_pte_pde = gmc_v7_0_gart_set_pte_pde,
>>> .set_prt = gmc_v7_0_set_prt,
>>> - .get_vm_pte_flags = gmc_v7_0_get_vm_pte_flags
>>> + .get_vm_pte_flags = gmc_v7_0_get_vm_pte_flags,
>>> + .get_vm_pde = gmc_v7_0_get_vm_pde
>>> };
>>>
>>> static const struct amdgpu_irq_src_funcs gmc_v7_0_irq_funcs = {
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
>>> b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
>>> index 3b5ea0f..f05c034 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
>>> @@ -656,6 +656,12 @@ static uint64_t gmc_v8_0_get_vm_pte_flags(struct
>>> amdgpu_device *adev,
>>> return pte_flag;
>>> }
>>>
>>> +static uint64_t gmc_v8_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr)
>>> +{
>>> + BUG_ON(addr & 0xFFF0000000000FFFULL);
>>> + return addr;
>>> +}
>>> +
>>> /**
>>> * gmc_v8_0_set_fault_enable_default - update VM fault handling
>>> *
>>> @@ -1612,7 +1618,8 @@ static const struct amdgpu_gart_funcs
>>> gmc_v8_0_gart_funcs = {
>>> .flush_gpu_tlb = gmc_v8_0_gart_flush_gpu_tlb,
>>> .set_pte_pde = gmc_v8_0_gart_set_pte_pde,
>>> .set_prt = gmc_v8_0_set_prt,
>>> - .get_vm_pte_flags = gmc_v8_0_get_vm_pte_flags
>>> + .get_vm_pte_flags = gmc_v8_0_get_vm_pte_flags,
>>> + .get_vm_pde = gmc_v8_0_get_vm_pde
>>> };
>>>
>>> static const struct amdgpu_irq_src_funcs gmc_v8_0_irq_funcs = {
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
>>> b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
>>> index 19e1027..047b1a7 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
>>> @@ -358,17 +358,19 @@ static uint64_t gmc_v9_0_get_vm_pte_flags(struct
>>> amdgpu_device *adev,
>>> return pte_flag;
>>> }
>>>
>>> -static u64 gmc_v9_0_adjust_mc_addr(struct amdgpu_device *adev, u64 mc_addr)
>>> +static u64 gmc_v9_0_get_vm_pde(struct amdgpu_device *adev, u64 addr)
>>> {
>>> - return adev->vm_manager.vram_base_offset + mc_addr - adev->mc.vram_start;
>>> + addr = adev->vm_manager.vram_base_offset + addr - adev->mc.vram_start;
>>> + BUG_ON(addr & 0xFFFF00000000003FULL);
>>> + return addr;
>>> }
>>>
>>> static const struct amdgpu_gart_funcs gmc_v9_0_gart_funcs = {
>>> .flush_gpu_tlb = gmc_v9_0_gart_flush_gpu_tlb,
>>> .set_pte_pde = gmc_v9_0_gart_set_pte_pde,
>>> - .get_vm_pte_flags = gmc_v9_0_get_vm_pte_flags,
>>> - .adjust_mc_addr = gmc_v9_0_adjust_mc_addr,
>>> .get_invalidate_req = gmc_v9_0_get_invalidate_req,
>>> + .get_vm_pte_flags = gmc_v9_0_get_vm_pte_flags,
>>> + .get_vm_pde = gmc_v9_0_get_vm_pde
>>> };
>>>
>>> static void gmc_v9_0_set_gart_funcs(struct amdgpu_device *adev)
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
>>> b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
>>> index 91cf7e6..fb6f4b3 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
>>> @@ -1143,10 +1143,8 @@ static void sdma_v4_0_ring_emit_vm_flush(struct
>>> amdgpu_ring *ring,
>>> uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
>>> unsigned eng = ring->vm_inv_eng;
>>>
>>> - pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev,
>>> pd_addr);
>>> - pd_addr = pd_addr | 0x1; /* valid bit */
>>> - /* now only use physical base address of PDE and valid */
>>> - BUG_ON(pd_addr & 0xFFFF00000000003EULL);
>>> + pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
>>> + pd_addr |= AMDGPU_PTE_VALID;
>>>
>>> amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_SRBM_WRITE) |
>>> SDMA_PKT_SRBM_WRITE_HEADER_BYTE_EN(0xf));
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
>>> b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
>>> index 22f42f3..1997ec8 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
>>> @@ -1316,10 +1316,8 @@ static void uvd_v7_0_ring_emit_vm_flush(struct
>>> amdgpu_ring *ring,
>>> uint32_t data0, data1, mask;
>>> unsigned eng = ring->vm_inv_eng;
>>>
>>> - pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev,
>>> pd_addr);
>>> - pd_addr = pd_addr | 0x1; /* valid bit */
>>> - /* now only use physical base address of PDE and valid */
>>> - BUG_ON(pd_addr & 0xFFFF00000000003EULL);
>>> + pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
>>> + pd_addr |= AMDGPU_PTE_VALID;
>>>
>>> data0 = (hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2;
>>> data1 = upper_32_bits(pd_addr);
>>> @@ -1358,10 +1356,8 @@ static void uvd_v7_0_enc_ring_emit_vm_flush(struct
>>> amdgpu_ring *ring,
>>> uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
>>> unsigned eng = ring->vm_inv_eng;
>>>
>>> - pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev,
>>> pd_addr);
>>> - pd_addr = pd_addr | 0x1; /* valid bit */
>>> - /* now only use physical base address of PDE and valid */
>>> - BUG_ON(pd_addr & 0xFFFF00000000003EULL);
>>> + pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
>>> + pd_addr |= AMDGPU_PTE_VALID;
>>>
>>> amdgpu_ring_write(ring, HEVC_ENC_CMD_REG_WRITE);
>>> amdgpu_ring_write(ring, (hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2);
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
>>> b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
>>> index 07b2ac7..8dbd0b7 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
>>> @@ -926,10 +926,8 @@ static void vce_v4_0_emit_vm_flush(struct amdgpu_ring
>>> *ring,
>>> uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
>>> unsigned eng = ring->vm_inv_eng;
>>>
>>> - pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev,
>>> pd_addr);
>>> - pd_addr = pd_addr | 0x1; /* valid bit */
>>> - /* now only use physical base address of PDE and valid */
>>> - BUG_ON(pd_addr & 0xFFFF00000000003EULL);
>>> + pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
>>> + pd_addr |= AMDGPU_PTE_VALID;
>>>
>>> amdgpu_ring_write(ring, VCE_CMD_REG_WRITE);
>>> amdgpu_ring_write(ring, (hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2);
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
>>> b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
>>> index ad1862f..b2d995b 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
>>> @@ -882,9 +882,8 @@ static void vcn_v1_0_dec_ring_emit_vm_flush(struct
>>> amdgpu_ring *ring,
>>> uint32_t data0, data1, mask;
>>> unsigned eng = ring->vm_inv_eng;
>>>
>>> - pd_addr = pd_addr | 0x1; /* valid bit */
>>> - /* now only use physical base address of PDE and valid */
>>> - BUG_ON(pd_addr & 0xFFFF00000000003EULL);
>>> + pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
>>> + pd_addr |= AMDGPU_PTE_VALID;
>>>
>>> data0 = (hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2;
>>> data1 = upper_32_bits(pd_addr);
>>>
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
prev parent reply other threads:[~2017-05-25 2:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-17 9:22 [PATCH 1/7] drm/amdgpu: cleanup adjust_mc_addr handling v2 Christian König
[not found] ` <1495012972-20698-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-05-17 9:22 ` [PATCH 2/7] drm/amdgpu: add some extra VM error handling Christian König
2017-05-17 9:22 ` [PATCH 3/7] drm/amdgpu: fix another fundamental VM bug Christian König
2017-05-17 9:22 ` [PATCH 4/7] drm/amdgpu: Return EINVAL if no PT BO Christian König
2017-05-17 9:22 ` [PATCH 5/7] drm/amdgpu: cache the complete pde Christian König
2017-05-17 9:22 ` [PATCH 6/7] drm/amdgpu: stop joining VM PTE updates Christian König
[not found] ` <1495012972-20698-6-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-05-17 10:08 ` Zhou, David(ChunMing)
[not found] ` <MWHPR1201MB02064FC493616E242D75A2C6B4E70-3iK1xFAIwjrUF/YbdlDdgWrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-05-18 5:35 ` Zhang, Jerry (Junwei)
2017-05-17 9:22 ` [PATCH 7/7] drm/amdgpu: enable huge page handling in the VM Christian König
[not found] ` <1495012972-20698-7-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-05-18 5:30 ` zhoucm1
[not found] ` <591D3164.7070105-5C7GfCeVMHo@public.gmane.org>
2017-05-24 9:15 ` Christian König
[not found] ` <5efe2316-b0bb-799b-345e-120c040237ae-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-05-24 9:28 ` zhoucm1
2017-05-18 5:33 ` [PATCH 1/7] drm/amdgpu: cleanup adjust_mc_addr handling v2 Zhang, Jerry (Junwei)
[not found] ` <591D323A.5000304-5C7GfCeVMHo@public.gmane.org>
2017-05-24 9:18 ` Christian König
[not found] ` <b9c0c5b3-a42c-b2e8-0b84-718807d5e7cf-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-05-25 2:10 ` Zhang, Jerry (Junwei) [this message]
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=59263D33.3070706@amd.com \
--to=jerry.zhang-5c7gfcevmho@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=deathsimple-ANTagKRnAhcb1SvskN2V4Q@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