drm/amdgpu: rework amdgpu open() path to function in sleep state
Subsystems (2)
v2 cover drm/amdgpu: rework amdgpu open() path to function in sleep state
This patch series reworks the amdgpu open/close, vm, cs, and validation functionality to allow for access of the GPU's CPU sided bookkeeping data without waking up the GPU from idle.
The overhaul will allow a few tools to function without waking up the GPU, which can improve power efficiency within relevant domains, and can hopefully be expanded on later to adapt for useful utilities.
v2:
- Force a vm->generation mismatch by adding 1 to the result of amdgpu_vm_generation.
- Seperate validation logic from patch "drm/amdgpu: defer GPU resume from open/close to first use" into a new patch.
- Change validation logic to not depend on flags to operate. Instead relying on a vm->generation mismatch.
- Clear vm pts in the kernel.evicted loop instead.
- Remove the root_cleared flag.
- Let the vm domain be initialized to VRAM in amdgpu_vm_pt_create if the vm->root.bo is not null.
- Clear the root page table on vm_init if pm_ref was true.
Shahyan Soltani (3):
drm/amdgpu: add 1 to to result of vram_lost_counter drm/amdgpu: clear vm pts upon a vm->generation mismatch drm/amdgpu: defer GPU resume from open/close to first use
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 18 ++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 24 +++++++++++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 7 ++++++- 5 files changed, 37 insertions(+), 19 deletions(-)
Signature · 1 line
2.56.0
PATCH v2 1/3 drm/amdgpu: add 1 to to result of vram_lost_counter
[Why]
The current implementation of page table validation does not process a vm->generation != amdgpu_vm_generation() mismatch if vm->generation is never assigned a value. This discrepancy is due to vm->generation having a default value of 0 on kzalloc.
[What]
By simply adding 1 to the result of the vram_lost_counter, 0 is never a valid result of amdgpu_vm_generation(). This forces a mismatch between vm->generation and amdgpu_vm_generation() if vm->generation was never assigned a value.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
@@ -555,7 +555,7 @@ static void amdgpu_vm_fini_entities(struct amdgpu_vm *vm)*/ uint64_t amdgpu_vm_generation (struct amdgpu_device *adev,struct amdgpu_vm *vm) { -uint64_t result = (u64 )atomic_read (&adev->vram_lost_counter) <<32 ; +uint64_t result = ((u64 )atomic_read (&adev->vram_lost_counter) +1 ) <<32 ;if (!vm)return result;
Signature · 1 line
2.56.0
Christian König
maintainerRe: [PATCH v2 1/3] drm/amdgpu: add 1 to to result of vram_lost_counter
Quoted 11 lines · Shahyan Soltani
[Why]
The current implementation of page table validation does not process avm->generation!=amdgpu_vm_generation()mismatch ifvm->generationis never assigned a value. This discrepancy is due tovm->generationhaving a default value of 0 on kzalloc.[What]
By simply adding 1 to the result of thevram_lost_counter, 0 is never a valid result ofamdgpu_vm_generation(). This forces a mismatch betweenvm->generationandamdgpu_vm_generation()ifvm->generationwas never assigned a value.
Interesting approach but I would rather initialize vm->generation to ~0UL.
Regards,
Christian.
Quoted 19 lines
Signed-off-by Shahyan Soltani <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-1@@ -555,7 +555,7 @@ static void amdgpu_vm_fini_entities(struct amdgpu_vm *vm)*/ uint64_t amdgpu_vm_generation (struct amdgpu_device *adev,struct amdgpu_vm *vm) { -uint64_t result = (u64 )atomic_read (&adev->vram_lost_counter) <<32 ; +uint64_t result = ((u64 )atomic_read (&adev->vram_lost_counter) +1 ) <<32 ;if (!vm)return result;
PATCH v2 2/3 drm/amdgpu: clear vm pts upon a vm->generation mismatch
In reply to Shahyan Soltani[Why]
Upon a vm->generation mismatch, the evicted pagetables are iterated through, resetting their state, and moved to their preferred domain. However validation doesn't process the necessary step of clearing the pagetables' garbage data.
[What]
Clear the vm page tables through the kernel.evicted loop upon a vm->generation mismatch. This ensures any garbage data is wiped. The new vm->generation value is assigned after the loop.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +9 -1
@@ -630,7 +630,6 @@ int amdgpu_vm_validate(struct amdgpu_device *adev, struct amdgpu_vm *vm,dma_resv_assert_held (vm->root.bo->tbo.base.resv);if (vm->generation != new_vm_generation) { - vm->generation = new_vm_generation;amdgpu_vm_bo_reset_state_machine (vm);amdgpu_vm_fini_entities (vm); r =amdgpu_vm_init_entities (adev, vm);
@@ -645,9 +644,18 @@ int amdgpu_vm_validate(struct amdgpu_device *adev, struct amdgpu_vm *vm, vm->update_funcs->map_table (to_amdgpu_bo_vm (bo_base->bo)); bo_base->moved = true; + +if (vm->generation != new_vm_generation) { + r =amdgpu_vm_pt_clear (adev, vm,to_amdgpu_bo_vm (bo_base->bo), false); +if (r) +return r; + } +amdgpu_vm_bo_needs_update (bo_base); } + vm->generation = new_vm_generation; +/* * As soon as all page tables are in place we can start updating them * again.
Signature · 1 line
2.56.0
Re: [PATCH v2 2/3] drm/amdgpu: clear vm pts upon a vm->generation mismatch
Quoted 7 lines · Shahyan Soltani
[Why]
Upon avm->generationmismatch, the evicted pagetables are iterated through, resetting their state, and moved to their preferred domain. However validation doesn't process the necessary step of clearing the pagetables' garbage data.[What]
I strongly suggest to drop the Why/What tags in the commit message, they don't add any additional value.
Quoted 6 lines
Clear the vm page tables through the kernel.evicted loop upon a
vm->generationmismatch. This ensures any garbage data is wiped. The newvm->generationvalue is assigned after the loop.Suggested-by Christian König <[email protected]>Signed-off-by Shahyan Soltani <[email protected]>
Quoted 35 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +9
-1@@ -630,7 +630,6 @@ int amdgpu_vm_validate(struct amdgpu_device *adev, struct amdgpu_vm *vm,dma_resv_assert_held (vm->root.bo->tbo.base.resv);if (vm->generation != new_vm_generation) { - vm->generation = new_vm_generation;amdgpu_vm_bo_reset_state_machine (vm);amdgpu_vm_fini_entities (vm); r =amdgpu_vm_init_entities (adev, vm);@@ -645,9 +644,18 @@ int amdgpu_vm_validate(struct amdgpu_device *adev, struct amdgpu_vm *vm, vm->update_funcs->map_table (to_amdgpu_bo_vm (bo_base->bo)); bo_base->moved = true; + +if (vm->generation != new_vm_generation) { + r =amdgpu_vm_pt_clear (adev, vm,to_amdgpu_bo_vm (bo_base->bo), false); +if (r) +return r; + } +amdgpu_vm_bo_needs_update (bo_base); } + vm->generation = new_vm_generation; +/* * As soon as all page tables are in place we can start updating them * again.
PATCH v2 3/3 drm/amdgpu: defer GPU resume from open/close to first use
In reply to Shahyan Soltani[Why]
Every open system call for an amdgpu device holds a runtime reference and resumes the device from a BACO/BOCO sleep state even if direct hardware access is not required.
[What]
Drop pm_runtime_get_sync() from open/close KMS to prevent unnecessary resumes. Instead, the PM reference will only be held if the GPU is currently awake.
Introduce delayed virtual memory hardware initialization through a powered_init flag. The powered_init flag handles initializing the VM domain in a GTT or VRAM domain depending on the init state of the GPU.
Remove the vm->generation assignment on amdgpu_vm_init() to force a mismatch and proccess the amdgpu_vm_validate() logic. This path will migrate GTT based page tables into VRAM upon a cs_ioctl, as well as clear any garbage data within those page tables.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 18 +++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 +++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 7 ++++++- 5 files changed, 27 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +9 -9
@@ -1502,6 +1502,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)struct amdgpu_fpriv *fpriv;struct drm_exec exec;int r, pasid =0 ; +int pm_ref;/* Ensure IB tests are run on ring */ flush_delayed_work (&adev->delayed_init_work);
@@ -1514,9 +1515,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) file_priv->driver_priv =NULL ; - r =pm_runtime_get_sync (dev->dev); -if (r <0 ) - goto pm_put; + pm_ref =pm_runtime_get_if_active (dev->dev); fpriv =kzalloc (sizeof (*fpriv),GFP_KERNEL );if (unlikely (!fpriv)) {
@@ -1530,7 +1529,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)amdgpu_debugfs_vm_init (file_priv); - r =amdgpu_vm_init (adev, &fpriv->vm, fpriv->xcp_id); + r =amdgpu_vm_init (adev, &fpriv->vm, fpriv->xcp_id, !!pm_ref);if (r) goto error_pasid;
@@ -1597,9 +1596,8 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)kfree (fpriv); out_suspend: -pm_put: -pm_runtime_put_autosuspend (dev->dev); - +if (pm_ref >0 ) +pm_runtime_put_autosuspend (dev->dev);return r; }
@@ -1619,12 +1617,13 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,struct amdgpu_bo_list *list;struct amdgpu_bo *pd;unsigned long handle; +int pm_ref;u32 pasid;if (!fpriv)return ; -pm_runtime_get_sync (dev->dev); + pm_ref =pm_runtime_get_if_active (dev->dev);if (amdgpu_device_ip_get_ip_block (adev,AMD_IP_BLOCK_TYPE_UVD ) !=NULL )amdgpu_uvd_free_handles (adev, file_priv);
@@ -1663,7 +1662,8 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,kfree (fpriv); file_priv->driver_priv =NULL ; -pm_runtime_put_autosuspend (dev->dev); +if (pm_ref >0 ) +pm_runtime_put_autosuspend (dev->dev); }
drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +1 -1
@@ -4169,7 +4169,7 @@ int amdgpu_ualink_manager_start(struct amdgpu_device *adev) {int i, r; - r =amdgpu_vm_init (adev, &adev->ualink.npa_vm,0 ); + r =amdgpu_vm_init (adev, &adev->ualink.npa_vm,0 , true);if (r) goto out;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7 -5
@@ -2634,7 +2634,7 @@ void amdgpu_vm_set_task_info(struct amdgpu_vm *vm)* 0 for success, error for failure. */ int amdgpu_vm_init (struct amdgpu_device *adev,struct amdgpu_vm *vm, -int32_t xcp_id) +int32_t xcp_id,bool device_active) {struct amdgpu_bo *root_bo;struct amdgpu_bo_vm *root;
@@ -2658,6 +2658,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,ttm_lru_bulk_move_init (&vm->lru_bulk_move); + vm->powered_init = device_active; vm->is_compute_context = false; vm->need_tlb_fence =amdgpu_userq_enabled (&adev->ddev);
@@ -2678,7 +2679,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, vm->last_update =dma_fence_get_stub (); vm->last_unlocked =dma_fence_get_stub (); vm->last_tlb_flush =dma_fence_get_stub (); - vm->generation =amdgpu_vm_generation (adev,NULL );mutex_init (&vm->eviction_lock); vm->evicting = false;
@@ -2701,9 +2701,11 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,if (r) goto error_free_root; - r =amdgpu_vm_pt_clear (adev, vm, root, false); -if (r) - goto error_free_root; +if (device_active) { + r =amdgpu_vm_pt_clear (adev, vm, root, false); +if (r) + goto error_free_root; + } r =amdgpu_vm_create_task_info (vm);if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +4 -1
@@ -372,6 +372,8 @@ struct amdgpu_vm {bool is_npa;/* Flag to indicate if VM needs a TLB fence (KFD or KGD) */ bool need_tlb_fence; +/* Flag to indicate if VM during initialization holds a runtime reference */ +bool powered_init;/* Memory partition number, -1 means any partition */ int8_t mem_id;
@@ -433,7 +435,8 @@ void amdgpu_vm_manager_init(struct amdgpu_device *adev);void amdgpu_vm_manager_fini (struct amdgpu_device *adev);long amdgpu_vm_wait_idle (struct amdgpu_vm *vm,long timeout); -int amdgpu_vm_init (struct amdgpu_device *adev,struct amdgpu_vm *vm,int32_t xcp_id); +int amdgpu_vm_init (struct amdgpu_device *adev,struct amdgpu_vm *vm,int32_t xcp_id, +bool device_active);int amdgpu_vm_make_compute (struct amdgpu_device *adev,struct amdgpu_vm *vm);int amdgpu_vm_make_npa (struct amdgpu_device *adev,struct amdgpu_vm *vm);void amdgpu_vm_fini (struct amdgpu_device *adev,struct amdgpu_vm *vm);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +6 -1
@@ -456,7 +456,7 @@ int amdgpu_vm_pt_create(struct amdgpu_device *adev, struct amdgpu_vm *vm, bp.size =amdgpu_vm_pt_size (adev, level); bp.byte_align =AMDGPU_GPU_PAGE_SIZE ; -if (!adev->gmc.is_app_apu) +if (!adev->gmc.is_app_apu && (vm->powered_init || vm->root.bo)) bp.domain =AMDGPU_GEM_DOMAIN_VRAM ;else bp.domain =AMDGPU_GEM_DOMAIN_GTT ;
@@ -486,6 +486,11 @@ int amdgpu_vm_pt_create(struct amdgpu_device *adev, struct amdgpu_vm *vm,if (r)return r; +if (bp.domain ==AMDGPU_GEM_DOMAIN_GTT && !adev->gmc.is_app_apu) { + (*vmbo)->bo.preferred_domains =AMDGPU_GEM_DOMAIN_VRAM ; + (*vmbo)->bo.allowed_domains =AMDGPU_GEM_DOMAIN_GTT |AMDGPU_GEM_DOMAIN_VRAM ; + } +/* Assumes that reservation is shared with the VM root and that the * reservation is locked */
Signature · 1 line
2.56.0
Christian König
maintainerRe: [PATCH v2 3/3] drm/amdgpu: defer GPU resume from open/close to first use
Quoted 9 lines · Shahyan Soltani
[Why]
Every open system call for an amdgpu device holds a runtime reference and resumes the device from a BACO/BOCO sleep state even if direct hardware access is not required.[What]
Droppm_runtime_get_sync()from open/close KMS to prevent unnecessary resumes. Instead, the PM reference will only be held if the GPU is currently awake.
Just drop grabbing the PM reference, the parameter to vm_init and the powered_init flag entirely.
Instead do something like this in amdgpu_vm_pt_create() for the root PD:
1. Calculate the disired domain in a local variable instead of bp.domain.
2. Initialize bp.domain to zero (or AMDGPU_GEM_DOMAIN_SYSTEM if zero doesn't work for some reason, it should but that path is probably not well tested).
3. After the amdgpu_bo_create_vm() worked update bo->allowed_domain and bo->preferred_domain to the real values figured out before.
This way clearing the root PD only on first use is always exercised and not just in rare cases.
Apart from that the whole approach looks pretty solid to me now.
Regards,
Christian.
Quoted 193 lines
Introduce delayed virtual memory hardware initialization through a
powered_initflag. Thepowered_initflag handles initializing the VM domain in a GTT or VRAM domain depending on the init state of the GPU.Remove the
vm->generationassignment onamdgpu_vm_init()to force a mismatch and proccess theamdgpu_vm_validate()logic. This path will migrate GTT based page tables into VRAM upon acs_ioctl, as well as clear any garbage data within those page tables.Signed-off-by Shahyan Soltani <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 18 +++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 +++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 7 ++++++- 5 files changed, 27 insertions(+), 17 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +9
-9@@ -1502,6 +1502,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)struct amdgpu_fpriv *fpriv;struct drm_exec exec;int r, pasid =0 ; +int pm_ref;/* Ensure IB tests are run on ring */ flush_delayed_work (&adev->delayed_init_work);@@ -1514,9 +1515,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) file_priv->driver_priv =NULL ; - r =pm_runtime_get_sync (dev->dev); -if (r <0 ) - goto pm_put; + pm_ref =pm_runtime_get_if_active (dev->dev); fpriv =kzalloc (sizeof (*fpriv),GFP_KERNEL );if (unlikely (!fpriv)) {@@ -1530,7 +1529,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)amdgpu_debugfs_vm_init (file_priv); - r =amdgpu_vm_init (adev, &fpriv->vm, fpriv->xcp_id); + r =amdgpu_vm_init (adev, &fpriv->vm, fpriv->xcp_id, !!pm_ref);if (r) goto error_pasid;@@ -1597,9 +1596,8 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)kfree (fpriv); out_suspend: -pm_put: -pm_runtime_put_autosuspend (dev->dev); - +if (pm_ref >0 ) +pm_runtime_put_autosuspend (dev->dev);return r; }@@ -1619,12 +1617,13 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,struct amdgpu_bo_list *list;struct amdgpu_bo *pd;unsigned long handle; +int pm_ref;u32 pasid;if (!fpriv)return ; -pm_runtime_get_sync (dev->dev); + pm_ref =pm_runtime_get_if_active (dev->dev);if (amdgpu_device_ip_get_ip_block (adev,AMD_IP_BLOCK_TYPE_UVD ) !=NULL )amdgpu_uvd_free_handles (adev, file_priv);@@ -1663,7 +1662,8 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,kfree (fpriv); file_priv->driver_priv =NULL ; -pm_runtime_put_autosuspend (dev->dev); +if (pm_ref >0 ) +pm_runtime_put_autosuspend (dev->dev); }drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +1
-1@@ -4169,7 +4169,7 @@ int amdgpu_ualink_manager_start(struct amdgpu_device *adev) {int i, r; - r =amdgpu_vm_init (adev, &adev->ualink.npa_vm,0 ); + r =amdgpu_vm_init (adev, &adev->ualink.npa_vm,0 , true);if (r) goto out;drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7
-5@@ -2634,7 +2634,7 @@ void amdgpu_vm_set_task_info(struct amdgpu_vm *vm)* 0 for success, error for failure. */ int amdgpu_vm_init (struct amdgpu_device *adev,struct amdgpu_vm *vm, -int32_t xcp_id) +int32_t xcp_id,bool device_active) {struct amdgpu_bo *root_bo;struct amdgpu_bo_vm *root;@@ -2658,6 +2658,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,ttm_lru_bulk_move_init (&vm->lru_bulk_move); + vm->powered_init = device_active; vm->is_compute_context = false; vm->need_tlb_fence =amdgpu_userq_enabled (&adev->ddev);@@ -2678,7 +2679,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, vm->last_update =dma_fence_get_stub (); vm->last_unlocked =dma_fence_get_stub (); vm->last_tlb_flush =dma_fence_get_stub (); - vm->generation =amdgpu_vm_generation (adev,NULL );mutex_init (&vm->eviction_lock); vm->evicting = false;@@ -2701,9 +2701,11 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,if (r) goto error_free_root; - r =amdgpu_vm_pt_clear (adev, vm, root, false); -if (r) - goto error_free_root; +if (device_active) { + r =amdgpu_vm_pt_clear (adev, vm, root, false); +if (r) + goto error_free_root; + } r =amdgpu_vm_create_task_info (vm);if (r)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +4
-1@@ -372,6 +372,8 @@ struct amdgpu_vm {bool is_npa;/* Flag to indicate if VM needs a TLB fence (KFD or KGD) */ bool need_tlb_fence; +/* Flag to indicate if VM during initialization holds a runtime reference */ +bool powered_init;/* Memory partition number, -1 means any partition */ int8_t mem_id;@@ -433,7 +435,8 @@ void amdgpu_vm_manager_init(struct amdgpu_device *adev);void amdgpu_vm_manager_fini (struct amdgpu_device *adev);long amdgpu_vm_wait_idle (struct amdgpu_vm *vm,long timeout); -int amdgpu_vm_init (struct amdgpu_device *adev,struct amdgpu_vm *vm,int32_t xcp_id); +int amdgpu_vm_init (struct amdgpu_device *adev,struct amdgpu_vm *vm,int32_t xcp_id, +bool device_active);int amdgpu_vm_make_compute (struct amdgpu_device *adev,struct amdgpu_vm *vm);int amdgpu_vm_make_npa (struct amdgpu_device *adev,struct amdgpu_vm *vm);void amdgpu_vm_fini (struct amdgpu_device *adev,struct amdgpu_vm *vm);drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +6
-1@@ -456,7 +456,7 @@ int amdgpu_vm_pt_create(struct amdgpu_device *adev, struct amdgpu_vm *vm, bp.size =amdgpu_vm_pt_size (adev, level); bp.byte_align =AMDGPU_GPU_PAGE_SIZE ; -if (!adev->gmc.is_app_apu) +if (!adev->gmc.is_app_apu && (vm->powered_init || vm->root.bo)) bp.domain =AMDGPU_GEM_DOMAIN_VRAM ;else bp.domain =AMDGPU_GEM_DOMAIN_GTT ;@@ -486,6 +486,11 @@ int amdgpu_vm_pt_create(struct amdgpu_device *adev, struct amdgpu_vm *vm,if (r)return r; +if (bp.domain ==AMDGPU_GEM_DOMAIN_GTT && !adev->gmc.is_app_apu) { + (*vmbo)->bo.preferred_domains =AMDGPU_GEM_DOMAIN_VRAM ; + (*vmbo)->bo.allowed_domains =AMDGPU_GEM_DOMAIN_GTT |AMDGPU_GEM_DOMAIN_VRAM ; + } +/* Assumes that reservation is shared with the VM root and that the * reservation is locked */