* Few TMZ BO move patches
@ 2020-03-02 12:17 Christian König
2020-03-02 12:17 ` [PATCH 1/3] drm/amdgpu: also add the TMZ flag to GART Christian König
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Christian König @ 2020-03-02 12:17 UTC (permalink / raw)
To: amd-gfx
Because of a shift in priorities I won't work on TMZ this week.
So attached are a few smaller patches I already prepared, but the bounce copy for system eviction is still missing.
Patches are totally untested, but I anybody find them useful feel free to test and review them.
Regards,
Christian.
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] drm/amdgpu: also add the TMZ flag to GART
2020-03-02 12:17 Few TMZ BO move patches Christian König
@ 2020-03-02 12:17 ` Christian König
2020-03-02 12:17 ` [PATCH 2/3] drm/amdgpu: add TMZ handling to amdgpu_move_blit Christian König
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Christian König @ 2020-03-02 12:17 UTC (permalink / raw)
To: amd-gfx
This is necessary for TMZ handling during buffer moves and scanout.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 660867cf2597..18f6caa7b6a2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1033,6 +1033,9 @@ int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
struct amdgpu_ttm_tt *gtt = (void *)ttm;
int r;
+ if (amdgpu_bo_encrypted(abo))
+ flags |= AMDGPU_PTE_TMZ;
+
if (abo->flags & AMDGPU_GEM_CREATE_MQD_GFX9) {
uint64_t page_idx = 1;
--
2.17.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] drm/amdgpu: add TMZ handling to amdgpu_move_blit
2020-03-02 12:17 Few TMZ BO move patches Christian König
2020-03-02 12:17 ` [PATCH 1/3] drm/amdgpu: also add the TMZ flag to GART Christian König
@ 2020-03-02 12:17 ` Christian König
2020-03-02 12:17 ` [PATCH 3/3] drm/amdgpu: stop evicting encrypted BOs to swap Christian König
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Christian König @ 2020-03-02 12:17 UTC (permalink / raw)
To: amd-gfx
This way we should be at least able to move buffers from VRAM to GTT.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 28 +++++++++++++++++--------
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 2 +-
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 18f6caa7b6a2..25d3b93f446e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -65,7 +65,7 @@
static int amdgpu_map_buffer(struct ttm_buffer_object *bo,
struct ttm_mem_reg *mem, unsigned num_pages,
uint64_t offset, unsigned window,
- struct amdgpu_ring *ring,
+ struct amdgpu_ring *ring, bool tmz,
uint64_t *addr);
static int amdgpu_invalidate_caches(struct ttm_bo_device *bdev, uint32_t flags)
@@ -295,17 +295,23 @@ static struct drm_mm_node *amdgpu_find_mm_node(struct ttm_mem_reg *mem,
/**
* amdgpu_copy_ttm_mem_to_mem - Helper function for copy
+ * @adev: amdgpu device
+ * @src: buffer/address where to read from
+ * @dst: buffer/address where to write to
+ * @size: number of bytes to copy
+ * @tmz: if a secure copy should be used
+ * @resv: resv object to sync to
+ * @f: Returns the last fence if multiple jobs are submitted.
*
* The function copies @size bytes from {src->mem + src->offset} to
* {dst->mem + dst->offset}. src->bo and dst->bo could be same BO for a
* move and different for a BO to BO copy.
*
- * @f: Returns the last fence if multiple jobs are submitted.
*/
int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
struct amdgpu_copy_mem *src,
struct amdgpu_copy_mem *dst,
- uint64_t size,
+ uint64_t size, bool tmz,
struct dma_resv *resv,
struct dma_fence **f)
{
@@ -357,7 +363,7 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
if (src->mem->start == AMDGPU_BO_INVALID_OFFSET) {
r = amdgpu_map_buffer(src->bo, src->mem,
PFN_UP(cur_size + src_page_offset),
- src_node_start, 0, ring,
+ src_node_start, 0, ring, tmz,
&from);
if (r)
goto error;
@@ -370,7 +376,7 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
if (dst->mem->start == AMDGPU_BO_INVALID_OFFSET) {
r = amdgpu_map_buffer(dst->bo, dst->mem,
PFN_UP(cur_size + dst_page_offset),
- dst_node_start, 1, ring,
+ dst_node_start, 1, ring, tmz,
&to);
if (r)
goto error;
@@ -378,7 +384,7 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
}
r = amdgpu_copy_buffer(ring, from, to, cur_size,
- resv, &next, false, true, false);
+ resv, &next, false, true, tmz);
if (r)
goto error;
@@ -430,6 +436,7 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
struct ttm_mem_reg *old_mem)
{
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
+ struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
struct amdgpu_copy_mem src, dst;
struct dma_fence *fence = NULL;
int r;
@@ -443,14 +450,14 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
r = amdgpu_ttm_copy_mem_to_mem(adev, &src, &dst,
new_mem->num_pages << PAGE_SHIFT,
+ amdgpu_bo_encrypted(abo),
bo->base.resv, &fence);
if (r)
goto error;
/* clear the space being freed */
if (old_mem->mem_type == TTM_PL_VRAM &&
- (ttm_to_amdgpu_bo(bo)->flags &
- AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE)) {
+ (abo->flags & AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE)) {
struct dma_fence *wipe_fence = NULL;
r = amdgpu_fill_buffer(ttm_to_amdgpu_bo(bo), AMDGPU_POISON,
@@ -2023,7 +2030,7 @@ int amdgpu_mmap(struct file *filp, struct vm_area_struct *vma)
static int amdgpu_map_buffer(struct ttm_buffer_object *bo,
struct ttm_mem_reg *mem, unsigned num_pages,
uint64_t offset, unsigned window,
- struct amdgpu_ring *ring,
+ struct amdgpu_ring *ring, bool tmz,
uint64_t *addr)
{
struct amdgpu_ttm_tt *gtt = (void *)bo->ttm;
@@ -2064,6 +2071,9 @@ static int amdgpu_map_buffer(struct ttm_buffer_object *bo,
dma_address = >t->ttm.dma_address[offset >> PAGE_SHIFT];
flags = amdgpu_ttm_tt_pte_flags(adev, ttm, mem);
+ if (tmz)
+ flags |= AMDGPU_PTE_TMZ;
+
r = amdgpu_gart_map(adev, 0, num_pages, dma_address, flags,
&job->ibs[0].ptr[num_dw]);
if (r)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index 2c4ad5b589d0..6001ab9bd932 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
@@ -91,7 +91,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset,
int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
struct amdgpu_copy_mem *src,
struct amdgpu_copy_mem *dst,
- uint64_t size,
+ uint64_t size, bool tmz,
struct dma_resv *resv,
struct dma_fence **f);
int amdgpu_fill_buffer(struct amdgpu_bo *bo,
--
2.17.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] drm/amdgpu: stop evicting encrypted BOs to swap
2020-03-02 12:17 Few TMZ BO move patches Christian König
2020-03-02 12:17 ` [PATCH 1/3] drm/amdgpu: also add the TMZ flag to GART Christian König
2020-03-02 12:17 ` [PATCH 2/3] drm/amdgpu: add TMZ handling to amdgpu_move_blit Christian König
@ 2020-03-02 12:17 ` Christian König
2020-03-02 21:37 ` Alex Deucher
2020-03-02 13:10 ` Few TMZ BO move patches Pierre-Eric Pelloux-Prayer
2020-03-02 21:47 ` Luben Tuikov
4 siblings, 1 reply; 8+ messages in thread
From: Christian König @ 2020-03-02 12:17 UTC (permalink / raw)
To: amd-gfx
Swapping out encrypted BOs doesn't work because they can't change
their physical location without going through a bounce copy.
As a workaround disable evicting encrypted BOs to the system
domain for now.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 25d3b93f446e..96d97523da65 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1552,6 +1552,9 @@ static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
switch (bo->mem.mem_type) {
case TTM_PL_TT:
+ if (amdgpu_bo_is_amdgpu_bo(bo) &&
+ amdgpu_bo_encrypted(ttm_to_amdgpu_bo(bo)))
+ return false;
return true;
case TTM_PL_VRAM:
--
2.17.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: Few TMZ BO move patches
2020-03-02 12:17 Few TMZ BO move patches Christian König
` (2 preceding siblings ...)
2020-03-02 12:17 ` [PATCH 3/3] drm/amdgpu: stop evicting encrypted BOs to swap Christian König
@ 2020-03-02 13:10 ` Pierre-Eric Pelloux-Prayer
2020-03-02 21:47 ` Luben Tuikov
4 siblings, 0 replies; 8+ messages in thread
From: Pierre-Eric Pelloux-Prayer @ 2020-03-02 13:10 UTC (permalink / raw)
To: Christian König, amd-gfx
Hi Christian,
The 3 patches are:
Tested-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Regards,
Pierre-Eric
On 02/03/2020 13:17, Christian König wrote:
> Because of a shift in priorities I won't work on TMZ this week.
>
> So attached are a few smaller patches I already prepared, but the bounce copy for system eviction is still missing.
>
> Patches are totally untested, but I anybody find them useful feel free to test and review them.
>
> Regards,
> Christian.
>
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] drm/amdgpu: stop evicting encrypted BOs to swap
2020-03-02 12:17 ` [PATCH 3/3] drm/amdgpu: stop evicting encrypted BOs to swap Christian König
@ 2020-03-02 21:37 ` Alex Deucher
0 siblings, 0 replies; 8+ messages in thread
From: Alex Deucher @ 2020-03-02 21:37 UTC (permalink / raw)
To: Christian König; +Cc: amd-gfx list
On Mon, Mar 2, 2020 at 7:18 AM Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
>
> Swapping out encrypted BOs doesn't work because they can't change
> their physical location without going through a bounce copy.
>
> As a workaround disable evicting encrypted BOs to the system
> domain for now.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
Series is:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 25d3b93f446e..96d97523da65 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -1552,6 +1552,9 @@ static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
>
> switch (bo->mem.mem_type) {
> case TTM_PL_TT:
> + if (amdgpu_bo_is_amdgpu_bo(bo) &&
> + amdgpu_bo_encrypted(ttm_to_amdgpu_bo(bo)))
> + return false;
> return true;
>
> case TTM_PL_VRAM:
> --
> 2.17.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Few TMZ BO move patches
2020-03-02 12:17 Few TMZ BO move patches Christian König
` (3 preceding siblings ...)
2020-03-02 13:10 ` Few TMZ BO move patches Pierre-Eric Pelloux-Prayer
@ 2020-03-02 21:47 ` Luben Tuikov
2020-03-04 12:41 ` Christian König
4 siblings, 1 reply; 8+ messages in thread
From: Luben Tuikov @ 2020-03-02 21:47 UTC (permalink / raw)
To: Christian König, amd-gfx
Thanks Christian. I'll take a look and play with it.
Regards,
Luben
On 2020-03-02 7:17 a.m., Christian König wrote:
> Because of a shift in priorities I won't work on TMZ this week.
>
> So attached are a few smaller patches I already prepared, but the bounce copy for system eviction is still missing.
>
> Patches are totally untested, but I anybody find them useful feel free to test and review them.
>
> Regards,
> Christian.
>
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Cluben.tuikov%40amd.com%7Cbb0a04fde1ea4b7960d408d7bea3c2d0%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637187482887561950&sdata=F1KJ%2BX%2F04Kkj7Wzw4bsc1TXLReLNVkrcw9R5ohbgvOQ%3D&reserved=0
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Few TMZ BO move patches
2020-03-02 21:47 ` Luben Tuikov
@ 2020-03-04 12:41 ` Christian König
0 siblings, 0 replies; 8+ messages in thread
From: Christian König @ 2020-03-04 12:41 UTC (permalink / raw)
To: Luben Tuikov, amd-gfx
Had to commit that today since I need to work on a different project.
If you find anything let me know and we can fix it in a follow up patch.
Christian.
Am 02.03.20 um 22:47 schrieb Luben Tuikov:
> Thanks Christian. I'll take a look and play with it.
>
> Regards,
> Luben
>
> On 2020-03-02 7:17 a.m., Christian König wrote:
>> Because of a shift in priorities I won't work on TMZ this week.
>>
>> So attached are a few smaller patches I already prepared, but the bounce copy for system eviction is still missing.
>>
>> Patches are totally untested, but I anybody find them useful feel free to test and review them.
>>
>> Regards,
>> Christian.
>>
>>
>> _______________________________________________
>> amd-gfx mailing list
>> amd-gfx@lists.freedesktop.org
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Cluben.tuikov%40amd.com%7Cbb0a04fde1ea4b7960d408d7bea3c2d0%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637187482887561950&sdata=F1KJ%2BX%2F04Kkj7Wzw4bsc1TXLReLNVkrcw9R5ohbgvOQ%3D&reserved=0
>>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-03-04 12:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-02 12:17 Few TMZ BO move patches Christian König
2020-03-02 12:17 ` [PATCH 1/3] drm/amdgpu: also add the TMZ flag to GART Christian König
2020-03-02 12:17 ` [PATCH 2/3] drm/amdgpu: add TMZ handling to amdgpu_move_blit Christian König
2020-03-02 12:17 ` [PATCH 3/3] drm/amdgpu: stop evicting encrypted BOs to swap Christian König
2020-03-02 21:37 ` Alex Deucher
2020-03-02 13:10 ` Few TMZ BO move patches Pierre-Eric Pelloux-Prayer
2020-03-02 21:47 ` Luben Tuikov
2020-03-04 12:41 ` Christian König
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.