KFD: Mapping-specific MTYPEs on Arcturus
Subsystems (4)
cover KFD: Mapping-specific MTYPEs on Arcturus
This is a simplified version of Oak's patch series, addressing some of the concerns raised during code review. Patches 1-3 are taken directly from Oak's series. Patch 4 is a simplified version of Oak's patches 3 and 5 that keeps all the KFD memory type abstractions out of the GMC IP-version-specific code.
Compile tested only.
Felix Kuehling (1):
drm/amdgpu: Determing PTE flags separately for each mapping
Oak Zeng (3):
drm/amdgpu: Extends amdgpu vm definitions
drm/amdgpu: Support new arcturus mtype
drm/amdgpu: Support snooped PTE flag
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 2 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 60 ++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 9 ++- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 6 ++ drivers/gpu/drm/amd/include/vega10_enum.h | 1 + include/uapi/drm/amdgpu_drm.h | 4 ++ 6 files changed, 63 insertions(+), 19 deletions(-)
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20190823213249.10749-1-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org
PATCH 1/4 drm/amdgpu: Extends amdgpu vm definitions
From: Oak Zeng <[email protected]>
Add definition of all supported mtypes. The RW mtype is recently introduced for arcturus. Also add definition of a flag to probe and possibly invalidate remote GPU cache, which will be used later in this series.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 9 +++++++-- include/uapi/drm/amdgpu_drm.h | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +7 -2
@@ -80,8 +80,13 @@ struct amdgpu_bo_list_entry;#define AMDGPU_PTE_MTYPE_VG10 (a) ((uint64_t)(a) << 57)#define AMDGPU_PTE_MTYPE_VG10_MASK AMDGPU_PTE_MTYPE_VG10(3ULL) -#define AMDGPU_MTYPE_NC 0 -#define AMDGPU_MTYPE_CC 2 +enum amdgpu_mtype { +AMDGPU_MTYPE_NC =0 , +AMDGPU_MTYPE_WC =1 , +AMDGPU_MTYPE_CC =2 , +AMDGPU_MTYPE_UC =3 , +AMDGPU_MTYPE_RW =4 , +};#define AMDGPU_PTE_DEFAULT_ATC (AMDGPU_PTE_SYSTEM \ | AMDGPU_PTE_SNOOPED \
include/uapi/drm/amdgpu_drm.h +4 -0
@@ -503,6 +503,10 @@ struct drm_amdgpu_gem_op {#define AMDGPU_VM_MTYPE_CC (3 << 5)/* Use UC MTYPE instead of default MTYPE */ #define AMDGPU_VM_MTYPE_UC (4 << 5) +/* Use RW MTYPE instead of default MTYPE */ +#define AMDGPU_VM_MTYPE_RW (5 << 5) +/* Cacheable/snoopable */ +#define AMDGPU_VM_PAGE_INVALIDATE_PROBE (1 << 9)struct drm_amdgpu_gem_va {/** GEM object handle */
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20190823213249.10749-2-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 1/4] drm/amdgpu: Extends amdgpu vm definitions
Am 23.08.19 um 23:33 schrieb Kuehling, Felix:
Quoted 6 lines
From: Oak Zeng <[email protected]>
Add definition of all supported mtypes. The RW mtype is recently introduced for arcturus. Also add definition of a flag to probe and possibly invalidate remote GPU cache, which will be used later in this series.
Maybe separate that into two patches?
Christian.
Quoted 33 lines
Change-Id I96fc9bb4b6b1e62bdc10b600d8aaa6a802128d6dSigned-off-by Oak Zeng <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 9 +++++++-- include/uapi/drm/amdgpu_drm.h | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +7
-2@@ -80,8 +80,13 @@ struct amdgpu_bo_list_entry;#define AMDGPU_PTE_MTYPE_VG10 (a) ((uint64_t)(a) << 57)#define AMDGPU_PTE_MTYPE_VG10_MASK AMDGPU_PTE_MTYPE_VG10(3ULL) -#define AMDGPU_MTYPE_NC 0 -#define AMDGPU_MTYPE_CC 2 +enum amdgpu_mtype { +AMDGPU_MTYPE_NC =0 , +AMDGPU_MTYPE_WC =1 , +AMDGPU_MTYPE_CC =2 , +AMDGPU_MTYPE_UC =3 , +AMDGPU_MTYPE_RW =4 , +};#define AMDGPU_PTE_DEFAULT_ATC (AMDGPU_PTE_SYSTEM \ | AMDGPU_PTE_SNOOPED \include/uapi/drm/amdgpu_drm.h +0
-0
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_gem_op { · line 512
Quoted 10 lines
include/uapi/drm/amdgpu_drm.h +4
-0@@ -503,6 +503,10 @@ struct drm_amdgpu_gem_op {#define AMDGPU_VM_MTYPE_CC (3 << 5)/* Use UC MTYPE instead of default MTYPE */ #define AMDGPU_VM_MTYPE_UC (4 << 5) +/* Use RW MTYPE instead of default MTYPE */ +#define AMDGPU_VM_MTYPE_RW (5 << 5) +/* Cacheable/snoopable */ +#define AMDGPU_VM_PAGE_INVALIDATE_PROBE (1 << 9)struct drm_amdgpu_gem_va {/** GEM object handle */
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/4 drm/amdgpu: Support new arcturus mtype
In reply to a message not in the archiveFrom: Oak Zeng <[email protected]>
Arcturus repurposed mtype WC to RW. Modify gmc functions to support the new mtype
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ drivers/gpu/drm/amd/include/vega10_enum.h | 1 + 2 files changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3 -0
@@ -587,6 +587,9 @@ static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev,case AMDGPU_VM_MTYPE_WC : pte_flag |=AMDGPU_PTE_MTYPE_VG10 (MTYPE_WC );break ; +case AMDGPU_VM_MTYPE_RW : + pte_flag |=AMDGPU_PTE_MTYPE_VG10 (MTYPE_RW ); +break ;case AMDGPU_VM_MTYPE_CC : pte_flag |=AMDGPU_PTE_MTYPE_VG10 (MTYPE_CC );break ;
drivers/gpu/drm/amd/include/vega10_enum.h +1 -0
@@ -1037,6 +1037,7 @@ TCC_CACHE_POLICY_STREAM = 0x00000001,typedef enum MTYPE {MTYPE_NC =0x00000000 ,MTYPE_WC =0x00000001 , +MTYPE_RW =0x00000001 ,MTYPE_CC =0x00000002 ,MTYPE_UC =0x00000003 , }MTYPE ;
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/4 drm/amdgpu: Support snooped PTE flag
In reply to a message not in the archiveFrom: Oak Zeng <[email protected]>
Set snooped PTE flag according to mapping flag. Write request to a page with snooped bit set, will send out invalidate probe request to TCC of the remote GPU where the vram page resides.
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3 -0
@@ -604,6 +604,9 @@ static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev,if (flags &AMDGPU_VM_PAGE_PRT ) pte_flag |=AMDGPU_PTE_PRT ; +if (flags &AMDGPU_VM_PAGE_INVALIDATE_PROBE ) + pte_flag |=AMDGPU_PTE_SNOOPED ; +return pte_flag; }
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20190823213249.10749-4-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 3/4] drm/amdgpu: Support snooped PTE flag
Am 23.08.19 um 23:33 schrieb Kuehling, Felix:
Quoted 17 lines
From: Oak Zeng <[email protected]>
Set snooped PTE flag according to mapping flag. Write request to a page with snooped bit set, will send out invalidate probe request to TCC of the remote GPU where the vram page resides.
Change-Id I799f68ec7a5a1abf32075f5ef31051641a0b3736Signed-off-by Oak Zeng <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev, · line 609
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3
-0@@ -604,6 +604,9 @@ static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev,if (flags &AMDGPU_VM_PAGE_PRT ) pte_flag |=AMDGPU_PTE_PRT ; +if (flags &AMDGPU_VM_PAGE_INVALIDATE_PROBE ) + pte_flag |=AMDGPU_PTE_SNOOPED ; +
That is still a NAK without further checks. We need to make absolutely sure that we don't set this when PCIe routing is in use.
Christian.
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev, · line 612
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-0return pte_flag; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): f09e6893-347b-4ade-76e5-ad37d8e4e782-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH 3/4] drm/amdgpu: Support snooped PTE flag
Quoted 13 lines · Christian König
Am 23.08.19 um 23:33 schrieb Kuehling, Felix:
Quoted 12 lines
From: Oak Zeng <[email protected]>
Set snooped PTE flag according to mapping flag. Write request to a page with snooped bit set, will send out invalidate probe request to TCC of the remote GPU where the vram page resides.
Change-Id I799f68ec7a5a1abf32075f5ef31051641a0b3736Signed-off-by Oak Zeng <[email protected]>---
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c| 3 +++1 file changed, 3 insertions(+)
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static uint64_t gmc_v9_0_get_vm_pte_flags(struct · line 609
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2
-0@@ -604,6 +604,9 @@ static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev, if (flags & AMDGPU_VM_PAGE_PRT) pte_flag |= AMDGPU_PTE_PRT; + if (flags & AMDGPU_VM_PAGE_INVALIDATE_PROBE) + pte_flag |= AMDGPU_PTE_SNOOPED; +That is still a NAK without further checks. We need to make absolutely sure that we don't set this when PCIe routing is in use.
The only place where AMDGPU_VM_... flags are accepted from user mode seems to be amdgpu_gem_va_ioctl. It has an explicit set of valid_flags it accepts. The new INVALIDATE_PROBE flag is not part of it. That means user mode will not be able to set it directly. If we added it to the set of valid_flags in amdgpu_gem_va_ioctl, we'd need to add appropriate checks at the same time.
KFD does not expose AMDGPU_VM_... flags directly to user mode. It only sets the INVALIDATE_PROBE flag in kernel mode for mappings in the same XGMI hive on Arturus (in patch 4).
If there is something I'm missing, please point it out. But AFAICT the checking that is currently done should satisfy your requirements.
Regards,
Felix
Quoted 6 lines
Christian.
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-0return pte_flag; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): a7f9ad48-2e46-5415-e2a8-1738a101d716-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 3/4] drm/amdgpu: Support snooped PTE flag
Am 24.08.19 um 18:24 schrieb Kuehling, Felix:
Quoted 35 lines · Christian König
Quoted 13 lines
Am 23.08.19 um 23:33 schrieb Kuehling, Felix:
Quoted 12 lines
From: Oak Zeng <[email protected]>
Set snooped PTE flag according to mapping flag. Write request to a page with snooped bit set, will send out invalidate probe request to TCC of the remote GPU where the vram page resides.
Change-Id I799f68ec7a5a1abf32075f5ef31051641a0b3736Signed-off-by Oak Zeng <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 1 file changed, 3 insertions(+)Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static uint64_t gmc_v9_0_get_vm_pte_flags(struct · line 609
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2
-0@@ -604,6 +604,9 @@ static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev, if (flags & AMDGPU_VM_PAGE_PRT) pte_flag |= AMDGPU_PTE_PRT; + if (flags & AMDGPU_VM_PAGE_INVALIDATE_PROBE) + pte_flag |= AMDGPU_PTE_SNOOPED; +That is still a NAK without further checks. We need to make absolutely sure that we don't set this when PCIe routing is in use.
The only place where
AMDGPU_VM_... flags are accepted from user mode seems to beamdgpu_gem_va_ioctl. It has an explicit set ofvalid_flagsit accepts. The newINVALIDATE_PROBEflag is not part of it. That means user mode will not be able to set it directly. If we added it to the set ofvalid_flagsinamdgpu_gem_va_ioctl, we'd need to add appropriate checks at the same time.
Quoted 6 lines
KFD does not expose
AMDGPU_VM_... flags directly to user mode. It only sets theINVALIDATE_PROBEflag in kernel mode for mappings in the same XGMI hive on Arturus (in patch 4).If there is something I'm missing, please point it out. But AFAICT the checking that is currently done should satisfy your requirements.
The hardware behavior depends on the placement of the buffer, so at bare minimum we need to check if it's pointing to PCIe or local (check the system bit).
But even if it's local what is the behavior for local memory? E.g. not accessed through XGMI?
As far as I can see what we need to check here is that this is a remote access over XGMI and then (and only then!) we are allowed to set the snoop bit on the PTE.
Regards,
Christian.
Quoted 4 lines
Regards,
Felix
Quoted 8 lines
Quoted 4 lines
Christian.
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-0return pte_flag; }_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 96b6ac1d-de87-3fdb-a531-af4b0a42f1d5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH 3/4] drm/amdgpu: Support snooped PTE flag
Quoted 47 lines · Christian König
Am 24.08.19 um 18:24 schrieb Kuehling, Felix:
Quoted 35 lines · Christian König
Quoted 13 lines
Am 23.08.19 um 23:33 schrieb Kuehling, Felix:
Quoted 12 lines
From: Oak Zeng <[email protected]>
Set snooped PTE flag according to mapping flag. Write request to a page with snooped bit set, will send out invalidate probe request to TCC of the remote GPU where the vram page resides.
Change-Id I799f68ec7a5a1abf32075f5ef31051641a0b3736Signed-off-by Oak Zeng <[email protected]>---
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c| 3 +++1 file changed, 3 insertions(+)Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static uint64_t gmc_v9_0_get_vm_pte_flags(struct · line 609
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2
-0@@ -604,6 +604,9 @@ static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev, if (flags & AMDGPU_VM_PAGE_PRT) pte_flag |= AMDGPU_PTE_PRT; + if (flags & AMDGPU_VM_PAGE_INVALIDATE_PROBE) + pte_flag |= AMDGPU_PTE_SNOOPED; +That is still a NAK without further checks. We need to make absolutely sure that we don't set this when PCIe routing is in use.
The only place where
AMDGPU_VM_... flags are accepted from user mode seems to beamdgpu_gem_va_ioctl. It has an explicit set ofvalid_flagsit accepts. The newINVALIDATE_PROBEflag is not part of it. That means user mode will not be able to set it directly. If we added it to the set ofvalid_flagsinamdgpu_gem_va_ioctl, we'd need to add appropriate checks at the same time.Quoted 6 lines
KFD does not expose
AMDGPU_VM_... flags directly to user mode. It only sets theINVALIDATE_PROBEflag in kernel mode for mappings in the same XGMI hive on Arturus (in patch 4).If there is something I'm missing, please point it out. But AFAICT the checking that is currently done should satisfy your requirements.
The hardware behavior depends on the placement of the buffer, so at bare minimum we need to check if it's pointing to PCIe or local (check the system bit).
Quoted 6 lines
But even if it's local what is the behavior for local memory? E.g. not accessed through XGMI?
As far as I can see what we need to check here is that this is a remote access over XGMI and then (and only then!) we are allowed to set the snoop bit on the PTE.
My point is, the only place where this bit can get set right now is in kernel mode in amdgpu_amdkfd_gpuvm.c. See patch 4 of my series. That code already has all the right conditions to make sure the INVALIDATE_PROBE bit is only set in the correct circumstances (remote XGMI mappings in the same hive):
Review
Quoted 12 lines
(quoted diff) +12
-0+ switch (adev->asic_type) { + case CHIP_ARCTURUS: + if (mem->alloc_flags & ALLOC_MEM_FLAGS_VRAM) { + if (bo_adev == adev) { + ... + } else { + ... + if (amdgpu_xgmi_same_hive(adev, bo_adev)) + mapping_flags |= + AMDGPU_VM_PAGE_INVALIDATE_PROBE; + } + } else {
I think you're asking me to add an extra check for the same conditions in the GMC code? Like GMC doesn't trust amdgpu_amdkfd. It seems completely redundant and a bit paranoid to me. gmc_v9_0_get_vm_pte_flags doesn't even have all the information it needs to make that determination.
Regards,
Felix
Quoted 17 lines
Regards,
Christian.Quoted 12 lines
Regards,
FelixQuoted 4 lines
Christian.
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-0return pte_flag; }_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 4b48fc1a-6ee2-bb60-0518-ea9c6346b8d6-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 3/4] drm/amdgpu: Support snooped PTE flag
Am 26.08.19 um 17:45 schrieb Kuehling, Felix:
Quoted 59 lines · Christian König
Quoted 46 lines
Am 24.08.19 um 18:24 schrieb Kuehling, Felix:
Quoted 35 lines · Christian König
Quoted 13 lines
Am 23.08.19 um 23:33 schrieb Kuehling, Felix:
Quoted 12 lines
From: Oak Zeng <[email protected]>
Set snooped PTE flag according to mapping flag. Write request to a page with snooped bit set, will send out invalidate probe request to TCC of the remote GPU where the vram page resides.
Change-Id I799f68ec7a5a1abf32075f5ef31051641a0b3736Signed-off-by Oak Zeng <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 1 file changed, 3 insertions(+)Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static uint64_t gmc_v9_0_get_vm_pte_flags(struct · line 609
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2
-0@@ -604,6 +604,9 @@ static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev, if (flags & AMDGPU_VM_PAGE_PRT) pte_flag |= AMDGPU_PTE_PRT; + if (flags & AMDGPU_VM_PAGE_INVALIDATE_PROBE) + pte_flag |= AMDGPU_PTE_SNOOPED; +That is still a NAK without further checks. We need to make absolutely sure that we don't set this when PCIe routing is in use.
The only place where
AMDGPU_VM_... flags are accepted from user mode seems to beamdgpu_gem_va_ioctl. It has an explicit set ofvalid_flagsit accepts. The newINVALIDATE_PROBEflag is not part of it. That means user mode will not be able to set it directly. If we added it to the set ofvalid_flagsinamdgpu_gem_va_ioctl, we'd need to add appropriate checks at the same time.Quoted 6 lines
KFD does not expose
AMDGPU_VM_... flags directly to user mode. It only sets theINVALIDATE_PROBEflag in kernel mode for mappings in the same XGMI hive on Arturus (in patch 4).If there is something I'm missing, please point it out. But AFAICT the checking that is currently done should satisfy your requirements.
The hardware behavior depends on the placement of the buffer, so at bare minimum we need to check if it's pointing to PCIe or local (check the system bit).
Quoted 6 lines
But even if it's local what is the behavior for local memory? E.g. not accessed through XGMI?
As far as I can see what we need to check here is that this is a remote access over XGMI and then (and only then!) we are allowed to set the snoop bit on the PTE.
My point is, the only place where this bit can get set right now is in kernel mode in
amdgpu_amdkfd_gpuvm.c. See patch 4 of my series. That code already has all the right conditions to make sure theINVALIDATE_PROBEbit is only set in the correct circumstances (remote XGMI mappings in the same hive):
Quoted 15 lines
Review
Quoted 12 lines
(quoted diff) +12
-0+ switch (adev->asic_type) { + case CHIP_ARCTURUS: + if (mem->alloc_flags & ALLOC_MEM_FLAGS_VRAM) { + if (bo_adev == adev) { + ... + } else { + ... + if (amdgpu_xgmi_same_hive(adev, bo_adev)) + mapping_flags |= + AMDGPU_VM_PAGE_INVALIDATE_PROBE; + } + } else {I think you're asking me to add an extra check for the same conditions in the GMC code? Like GMC doesn't trust
amdgpu_amdkfd. It seems completely redundant and a bit paranoid to me.
Well the job of the VM code is to figure out the flags and location for the PTE based on the current placement BO and the flags given for the mapping.
And yes that implies that we don't trust upper layers to do this instead.
Quoted 1 line
gmc_v9_0_get_vm_pte_flagsdoesn't even have all the information it needs to make that determination.
Well then we probably need to change that.
Regards,
Christian.
Quoted 4 lines
Regards,
Felix
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 89bf5baa-4b63-e40a-7995-fa35bad988b7-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 3/4] drm/amdgpu: Support snooped PTE flag
Quoted 75 lines · On 2019-08-26 1:16 p.m., wrote:
Am 26.08.19 um 17:45 schrieb Kuehling, Felix:
Quoted 59 lines · Christian König
Quoted 46 lines
Am 24.08.19 um 18:24 schrieb Kuehling, Felix:
Quoted 35 lines · Christian König
Quoted 13 lines
Am 23.08.19 um 23:33 schrieb Kuehling, Felix:
Quoted 12 lines
From: Oak Zeng <[email protected]>
Set snooped PTE flag according to mapping flag. Write request to a page with snooped bit set, will send out invalidate probe request to TCC of the remote GPU where the vram page resides.
Change-Id I799f68ec7a5a1abf32075f5ef31051641a0b3736Signed-off-by Oak Zeng <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 1 file changed, 3 insertions(+)Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static uint64_t gmc_v9_0_get_vm_pte_flags(struct · line 609
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2
-0@@ -604,6 +604,9 @@ static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev, if (flags & AMDGPU_VM_PAGE_PRT) pte_flag |= AMDGPU_PTE_PRT; + if (flags & AMDGPU_VM_PAGE_INVALIDATE_PROBE) + pte_flag |= AMDGPU_PTE_SNOOPED; +That is still a NAK without further checks. We need to make absolutely sure that we don't set this when PCIe routing is in use.
The only place where
AMDGPU_VM_... flags are accepted from user mode seems to beamdgpu_gem_va_ioctl. It has an explicit set ofvalid_flagsit accepts. The newINVALIDATE_PROBEflag is not part of it. That means user mode will not be able to set it directly. If we added it to the set ofvalid_flagsinamdgpu_gem_va_ioctl, we'd need to add appropriate checks at the same time.Quoted 6 lines
KFD does not expose
AMDGPU_VM_... flags directly to user mode. It only sets theINVALIDATE_PROBEflag in kernel mode for mappings in the same XGMI hive on Arturus (in patch 4).If there is something I'm missing, please point it out. But AFAICT the checking that is currently done should satisfy your requirements.
The hardware behavior depends on the placement of the buffer, so at bare minimum we need to check if it's pointing to PCIe or local (check the system bit).
Quoted 6 lines
But even if it's local what is the behavior for local memory? E.g. not accessed through XGMI?
As far as I can see what we need to check here is that this is a remote access over XGMI and then (and only then!) we are allowed to set the snoop bit on the PTE.
My point is, the only place where this bit can get set right now is in kernel mode in
amdgpu_amdkfd_gpuvm.c. See patch 4 of my series. That code already has all the right conditions to make sure theINVALIDATE_PROBEbit is only set in the correct circumstances (remote XGMI mappings in the same hive):Quoted 15 lines
Review
Quoted 12 lines
(quoted diff) +12
-0+ switch (adev->asic_type) { + case CHIP_ARCTURUS: + if (mem->alloc_flags & ALLOC_MEM_FLAGS_VRAM) { + if (bo_adev == adev) { + ... + } else { + ... + if (amdgpu_xgmi_same_hive(adev, bo_adev)) + mapping_flags |= + AMDGPU_VM_PAGE_INVALIDATE_PROBE; + } + } else {I think you're asking me to add an extra check for the same conditions in the GMC code? Like GMC doesn't trust
amdgpu_amdkfd. It seems completely redundant and a bit paranoid to me.
Quoted 5 lines
Well the job of the VM code is to figure out the flags and location for the PTE based on the current placement BO and the flags given for the mapping.
And yes that implies that we don't trust upper layers to do this instead.
I consider amdgpu_amdkfd_gpuvm as part of the lower layer. It has control over the placement of the buffers.
That said, if the GMC code has to figure out the PTE mapping flags based on the location of the buffer and the intended usage, it'll be hard to avoid some of the abstractions you criticized in Oak's patch series. You can't have it both ways. Either you give user mode the responsibility to know all the HW details and let user mode determine the mtype and flags (which is what you currently do in the GEM interface), or you let the VM code determine the flags based on more abstract information from user mode.
I see this discussion moving towards a more abstract interface. I'll see if I can add that into the GMC IP without breaking the existing AMDGPU GEM APIs.
Regards,
Felix
Quoted 10 lines
Quoted 2 lines
gmc_v9_0_get_vm_pte_flagsdoesn't even have all the information it needs to make that determination.Well then we probably need to change that.
Regards,
Christian.Quoted 3 lines
Regards,
Felix
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 216f63db-78c5-1098-bea5-2f379b0bf051-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 3/4] drm/amdgpu: Support snooped PTE flag
Am 26.08.19 um 20:03 schrieb Kuehling, Felix:
Quoted 84 lines · On 2019-08-26 1:16 p.m., wrote:
Quoted 75 lines
Am 26.08.19 um 17:45 schrieb Kuehling, Felix:
Quoted 59 lines · Christian König
Quoted 46 lines
Am 24.08.19 um 18:24 schrieb Kuehling, Felix:
Quoted 35 lines · Christian König
Quoted 13 lines
Am 23.08.19 um 23:33 schrieb Kuehling, Felix:
Quoted 12 lines
From: Oak Zeng <[email protected]>
Set snooped PTE flag according to mapping flag. Write request to a page with snooped bit set, will send out invalidate probe request to TCC of the remote GPU where the vram page resides.
Change-Id I799f68ec7a5a1abf32075f5ef31051641a0b3736Signed-off-by Oak Zeng <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 1 file changed, 3 insertions(+)Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static uint64_t gmc_v9_0_get_vm_pte_flags(struct · line 609
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2
-0@@ -604,6 +604,9 @@ static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev, if (flags & AMDGPU_VM_PAGE_PRT) pte_flag |= AMDGPU_PTE_PRT; + if (flags & AMDGPU_VM_PAGE_INVALIDATE_PROBE) + pte_flag |= AMDGPU_PTE_SNOOPED; +That is still a NAK without further checks. We need to make absolutely sure that we don't set this when PCIe routing is in use.
The only place where
AMDGPU_VM_... flags are accepted from user mode seems to beamdgpu_gem_va_ioctl. It has an explicit set ofvalid_flagsit accepts. The newINVALIDATE_PROBEflag is not part of it. That means user mode will not be able to set it directly. If we added it to the set ofvalid_flagsinamdgpu_gem_va_ioctl, we'd need to add appropriate checks at the same time.Quoted 6 lines
KFD does not expose
AMDGPU_VM_... flags directly to user mode. It only sets theINVALIDATE_PROBEflag in kernel mode for mappings in the same XGMI hive on Arturus (in patch 4).If there is something I'm missing, please point it out. But AFAICT the checking that is currently done should satisfy your requirements.
The hardware behavior depends on the placement of the buffer, so at bare minimum we need to check if it's pointing to PCIe or local (check the system bit).
Quoted 6 lines
But even if it's local what is the behavior for local memory? E.g. not accessed through XGMI?
As far as I can see what we need to check here is that this is a remote access over XGMI and then (and only then!) we are allowed to set the snoop bit on the PTE.
My point is, the only place where this bit can get set right now is in kernel mode in
amdgpu_amdkfd_gpuvm.c. See patch 4 of my series. That code already has all the right conditions to make sure theINVALIDATE_PROBEbit is only set in the correct circumstances (remote XGMI mappings in the same hive):Quoted 15 lines
Review
Quoted 12 lines
(quoted diff) +12
-0+ switch (adev->asic_type) { + case CHIP_ARCTURUS: + if (mem->alloc_flags & ALLOC_MEM_FLAGS_VRAM) { + if (bo_adev == adev) { + ... + } else { + ... + if (amdgpu_xgmi_same_hive(adev, bo_adev)) + mapping_flags |= + AMDGPU_VM_PAGE_INVALIDATE_PROBE; + } + } else {I think you're asking me to add an extra check for the same conditions in the GMC code? Like GMC doesn't trust
amdgpu_amdkfd. It seems completely redundant and a bit paranoid to me.Quoted 5 lines
Well the job of the VM code is to figure out the flags and location for the PTE based on the current placement BO and the flags given for the mapping.
And yes that implies that we don't trust upper layers to do this instead.
I consider
amdgpu_amdkfd_gpuvmas part of the lower layer. It has control over the placement of the buffers.
Quoted 7 lines
That said, if the GMC code has to figure out the PTE mapping flags based on the location of the buffer and the intended usage, it'll be hard to avoid some of the abstractions you criticized in Oak's patch series. You can't have it both ways. Either you give user mode the responsibility to know all the HW details and let user mode determine the mtype and flags (which is what you currently do in the GEM interface), or you let the VM code determine the flags based on more abstract information from user mode.
Good point, and yes I actually think as well that we shouldn't have had the gmc_v9_0_get_vm_pte_flags callback in the first place.
Quoted 3 lines
I see this discussion moving towards a more abstract interface. I'll see if I can add that into the GMC IP without breaking the existing AMDGPU GEM APIs.
We should probably just revert back the to doing most of the mapping in amdgpu_vm_bo_split_mapping().
Here we already have a whole bunch of ASIC specific handling anyway:
Quoted 20 lines
if (!(mapping->flags &
AMDGPU_PTE_READABLE)) flags &= ~AMDGPU_PTE_READABLE; if (!(mapping->flags &AMDGPU_PTE_WRITEABLE)) flags &= ~AMDGPU_PTE_WRITEABLE;flags &= ~AMDGPU_PTE_EXECUTABLE;
flags |=mapping->flags&AMDGPU_PTE_EXECUTABLE;if (
adev->asic_type==CHIP_NAVI10) {
flags &= ~AMDGPU_PTE_MTYPE_NV10_MASK;
flags |= (mapping->flags&AMDGPU_PTE_MTYPE_NV10_MASK); } else {
flags &= ~AMDGPU_PTE_MTYPE_VG10_MASK;
flags |= (mapping->flags&AMDGPU_PTE_MTYPE_VG10_MASK); }if ((
mapping->flags&AMDGPU_PTE_PRT) && (adev->asic_type>=CHIP_VEGA10)) { flags |=AMDGPU_PTE_PRT;
if (adev->asic_type>=CHIP_NAVI10) {
Quoted 6 lines
flags |= AMDGPU_PTE_SNOOPED; flags |= AMDGPU_PTE_LOG; flags |= AMDGPU_PTE_SYSTEM;}
flags &= ~AMDGPU_PTE_VALID;
}
And now that you mentioned it, the code you proposed wouldn't have worked anyway because the AMDGPU_PTE_SNOOPED would have been filtered out here :)
Regards,
Christian.
Quoted 14 lines
Regards,
FelixQuoted 9 lines
Quoted 1 line
gmc_v9_0_get_vm_pte_flagsdoesn't even have all the information it needs to make that determination.Well then we probably need to change that.
Regards,
Christian.Quoted 3 lines
Regards,
Felix
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 49ba47da-a225-5a21-9014-ccc316c55b60-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 3/4] drm/amdgpu: Support snooped PTE flag
Quoted 32 lines · Christian
We should probably just revert back the to doing most of the mapping in
amdgpu_vm_bo_split_mapping().Here we already have a whole bunch of ASIC specific handling anyway:
Quoted 20 lines
if (!(mapping->flags &
AMDGPU_PTE_READABLE)) flags &= ~AMDGPU_PTE_READABLE; if (!(mapping->flags &AMDGPU_PTE_WRITEABLE)) flags &= ~AMDGPU_PTE_WRITEABLE;flags &= ~AMDGPU_PTE_EXECUTABLE;
flags |=mapping->flags&AMDGPU_PTE_EXECUTABLE;if (
adev->asic_type==CHIP_NAVI10) {
flags &= ~AMDGPU_PTE_MTYPE_NV10_MASK;
flags |= (mapping->flags&AMDGPU_PTE_MTYPE_NV10_MASK); } else {
flags &= ~AMDGPU_PTE_MTYPE_VG10_MASK;
flags |= (mapping->flags&AMDGPU_PTE_MTYPE_VG10_MASK); }if ((
mapping->flags&AMDGPU_PTE_PRT) && (adev->asic_type>=CHIP_VEGA10)) { flags |=AMDGPU_PTE_PRT;
if (adev->asic_type>=CHIP_NAVI10) {Quoted 6 lines
flags |= AMDGPU_PTE_SNOOPED; flags |= AMDGPU_PTE_LOG; flags |= AMDGPU_PTE_SYSTEM;}
flags &= ~AMDGPU_PTE_VALID;
}
Quoted 3 lines
And now that you mentioned it, the code you proposed wouldn't have worked anyway because the
AMDGPU_PTE_SNOOPEDwould have been filtered out here :)
OK, and that does look like the right place to set the PTE_SNOOPED bit for XGMI mappings on Arcturus. I'll send out an updated patch series that no longer needs the AMDGPU_VM_PAGE_INVALIDATE_PROBE bit in the UAPI.
Thanks for the pointer,
Felix
Quoted 4 lines
Regards,
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/4 drm/amdgpu: Determing PTE flags separately for each mapping
In reply to a message not in the archiveThe same BO can be mapped with different PTE flags by different GPUs. Therefore determine the PTE flags separately for each mapping instead of storing them in the buffer object.
Add a helper function to determine the PTE flags with special logic for Arcturus that takes advantages of the new MTYPE_RW and the ability to probe-invalidate remote caches over XGMI.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 2 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 60 ++++++++++++++----- 2 files changed, 45 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +1 -1
@@ -57,7 +57,7 @@ struct kgd_mem {unsigned int mapped_to_gpu_memory;uint64_t va; -uint32_t mapping_flags; +uint32_t alloc_flags;atomic_t invalid;struct amdkfd_process_info *process_info;
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +44 -16
96 lines not on this page · raw message
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx