<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Patches 1-3:</p>
<p style="margin-top:0;margin-bottom:0">Reviewed-by: Alex Deucher <alexander.deucher@amd.com></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Patch 4:</p>
<p style="margin-top:0;margin-bottom:0">Acked-by: Alex Deucher <alexander.deucher@amd.com><br>
</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Christian König <ckoenig.leichtzumerken@gmail.com><br>
<b>Sent:</b> Tuesday, January 23, 2018 5:15:54 AM<br>
<b>To:</b> Liu, Monk; amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> [PATCH 4/4] drm/amdgpu: move static CSA address to top of address space v2</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Move the CSA area to the top of the VA space to avoid clashing with<br>
HMM/ATC in the lower range on GFX9.<br>
<br>
v2: wrong sign noticed by Roger, rebase on CSA_VADDR cleanup, handle VA<br>
hole on GFX9 as well.<br>
<br>
Signed-off-by: Christian König <christian.koenig@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 24 ++++++++++++++++++------<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 5 +++--<br>
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 6 +++---<br>
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 4 ++--<br>
4 files changed, 26 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c<br>
index e7dfb7b44b4b..b832651d2137 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c<br>
@@ -24,6 +24,18 @@<br>
#include "amdgpu.h"<br>
#define MAX_KIQ_REG_WAIT 100000000 /* in usecs */<br>
<br>
+uint64_t amdgpu_csa_vaddr(struct amdgpu_device *adev)<br>
+{<br>
+ uint64_t addr = adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT;<br>
+<br>
+ addr -= AMDGPU_VA_RESERVED_SIZE;<br>
+<br>
+ if (addr >= AMDGPU_VA_HOLE_START)<br>
+ addr |= AMDGPU_VA_HOLE_END;<br>
+<br>
+ return addr;<br>
+}<br>
+<br>
bool amdgpu_virt_mmio_blocked(struct amdgpu_device *adev)<br>
{<br>
/* By now all MMIO pages except mailbox are blocked */<br>
@@ -55,14 +67,14 @@ void amdgpu_free_static_csa(struct amdgpu_device *adev) {<br>
<br>
/*<br>
* amdgpu_map_static_csa should be called during amdgpu_vm_init<br>
- * it maps virtual address "AMDGPU_VA_RESERVED_SIZE - AMDGPU_CSA_SIZE"<br>
- * to this VM, and each command submission of GFX should use this virtual<br>
- * address within META_DATA init package to support SRIOV gfx preemption.<br>
+ * it maps virtual address amdgpu_csa_vaddr() to this VM, and each command<br>
+ * submission of GFX should use this virtual address within META_DATA init<br>
+ * package to support SRIOV gfx preemption.<br>
*/<br>
-<br>
int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm,<br>
struct amdgpu_bo_va **bo_va)<br>
{<br>
+ uint64_t csa_addr = amdgpu_csa_vaddr(adev) & AMDGPU_VA_HOLE_MASK;<br>
struct ww_acquire_ctx ticket;<br>
struct list_head list;<br>
struct amdgpu_bo_list_entry pd;<br>
@@ -90,7 +102,7 @@ int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm,<br>
return -ENOMEM;<br>
}<br>
<br>
- r = amdgpu_vm_alloc_pts(adev, (*bo_va)->base.vm, AMDGPU_CSA_VADDR,<br>
+ r = amdgpu_vm_alloc_pts(adev, (*bo_va)->base.vm, csa_addr,<br>
AMDGPU_CSA_SIZE);<br>
if (r) {<br>
DRM_ERROR("failed to allocate pts for static CSA, err=%d\n", r);<br>
@@ -99,7 +111,7 @@ int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm,<br>
return r;<br>
}<br>
<br>
- r = amdgpu_vm_bo_map(adev, *bo_va, AMDGPU_CSA_VADDR, 0, AMDGPU_CSA_SIZE,<br>
+ r = amdgpu_vm_bo_map(adev, *bo_va, csa_addr, 0, AMDGPU_CSA_SIZE,<br>
AMDGPU_PTE_READABLE | AMDGPU_PTE_WRITEABLE |<br>
AMDGPU_PTE_EXECUTABLE);<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h<br>
index 6a83425aa9ed..880ac113a3a9 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h<br>
@@ -251,8 +251,7 @@ struct amdgpu_virt {<br>
uint32_t gim_feature;<br>
};<br>
<br>
-#define AMDGPU_CSA_SIZE (8 * 1024)<br>
-#define AMDGPU_CSA_VADDR (AMDGPU_VA_RESERVED_SIZE - AMDGPU_CSA_SIZE)<br>
+#define AMDGPU_CSA_SIZE (8 * 1024)<br>
<br>
#define amdgpu_sriov_enabled(adev) \<br>
((adev)->virt.caps & AMDGPU_SRIOV_CAPS_ENABLE_IOV)<br>
@@ -279,6 +278,8 @@ static inline bool is_virtual_machine(void)<br>
}<br>
<br>
struct amdgpu_vm;<br>
+<br>
+uint64_t amdgpu_csa_vaddr(struct amdgpu_device *adev);<br>
bool amdgpu_virt_mmio_blocked(struct amdgpu_device *adev);<br>
int amdgpu_allocate_static_csa(struct amdgpu_device *adev);<br>
int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm,<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<br>
index 530d2ea1b73c..6482efec47a1 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<br>
@@ -7147,11 +7147,11 @@ static void gfx_v8_0_ring_emit_ce_meta(struct amdgpu_ring *ring)<br>
} ce_payload = {};<br>
<br>
if (ring->adev->virt.chained_ib_support) {<br>
- ce_payload_addr = AMDGPU_CSA_VADDR +<br>
+ ce_payload_addr = amdgpu_csa_vaddr(ring->adev) +<br>
offsetof(struct vi_gfx_meta_data_chained_ib, ce_payload);<br>
cnt_ce = (sizeof(ce_payload.chained) >> 2) + 4 - 2;<br>
} else {<br>
- ce_payload_addr = AMDGPU_CSA_VADDR +<br>
+ ce_payload_addr = amdgpu_csa_vaddr(ring->adev) +<br>
offsetof(struct vi_gfx_meta_data, ce_payload);<br>
cnt_ce = (sizeof(ce_payload.regular) >> 2) + 4 - 2;<br>
}<br>
@@ -7175,7 +7175,7 @@ static void gfx_v8_0_ring_emit_de_meta(struct amdgpu_ring *ring)<br>
struct vi_de_ib_state_chained_ib chained;<br>
} de_payload = {};<br>
<br>
- csa_addr = AMDGPU_CSA_VADDR;<br>
+ csa_addr = amdgpu_csa_vaddr(ring->adev);<br>
gds_addr = csa_addr + 4096;<br>
if (ring->adev->virt.chained_ib_support) {<br>
de_payload.chained.gds_backup_addrlo = lower_32_bits(gds_addr);<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
index 720d15f1324e..1363e7ddd04a 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c<br>
@@ -3873,7 +3873,7 @@ static void gfx_v9_0_ring_emit_ce_meta(struct amdgpu_ring *ring)<br>
int cnt;<br>
<br>
cnt = (sizeof(ce_payload) >> 2) + 4 - 2;<br>
- csa_addr = AMDGPU_CSA_VADDR;<br>
+ csa_addr = amdgpu_csa_vaddr(ring->adev);<br>
<br>
amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt));<br>
amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(2) |<br>
@@ -3891,7 +3891,7 @@ static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring)<br>
uint64_t csa_addr, gds_addr;<br>
int cnt;<br>
<br>
- csa_addr = AMDGPU_CSA_VADDR;<br>
+ csa_addr = amdgpu_csa_vaddr(ring->adev);<br>
gds_addr = csa_addr + 4096;<br>
de_payload.gds_backup_addrlo = lower_32_bits(gds_addr);<br>
de_payload.gds_backup_addrhi = upper_32_bits(gds_addr);<br>
-- <br>
2.14.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
</div>
</span></font></div>
</body>
</html>