[PATCH RFC 2/2] drm/amdgpu: Set/clear CPU_ACCESS flag on page fault and move to VRAM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 30.06.2017 um 17:18 schrieb John Brooks:
> When a BO is moved to VRAM, clear AMDGPU_BO_FLAG_CPU_ACCESS. This allows it
> to potentially later move to invisible VRAM if the CPU does not access it
> again.
>
> Setting the CPU_ACCESS flag in amdgpu_fault_reserve_notify() also means
> that we can remove the loop to restrict lpfn to the end of visible VRAM,
> because amdgpu_ttm_placement_init() will do it for us.
>
> Signed-off-by: John Brooks <john at fastquake.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 +++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 8 ++++++++
>   2 files changed, 11 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index fa8aeca..19bd2fd 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -953,6 +953,9 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
>   		return 0;
>   
>   	abo = container_of(bo, struct amdgpu_bo, tbo);
> +
> +	abo->flags |= AMDGPU_BO_FLAG_CPU_ACCESS;
> +
>   	if (bo->mem.mem_type != TTM_PL_VRAM)
>   		return 0;
>   
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index c9b131b..cc65cdd 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -417,6 +417,7 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo,
>   				struct ttm_mem_reg *new_mem)
>   {
>   	struct amdgpu_device *adev;
> +	struct amdgpu_bo *abo;
>   	struct ttm_mem_reg *old_mem = &bo->mem;
>   	struct ttm_mem_reg tmp_mem;
>   	struct ttm_placement placement;
> @@ -424,6 +425,7 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo,
>   	int r;
>   
>   	adev = amdgpu_ttm_adev(bo->bdev);
> +	abo = container_of(bo, struct amdgpu_bo, tbo);
>   	tmp_mem = *new_mem;
>   	tmp_mem.mm_node = NULL;
>   	placement.num_placement = 1;
> @@ -446,6 +448,12 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo,
>   	if (unlikely(r)) {
>   		goto out_cleanup;
>   	}
> +
> +	/* The page fault handler will re-set this if the CPU accesses the BO
> +	 * after it's moved.
> +	 */
> +	abo->flags &= ~AMDGPU_BO_FLAG_CPU_ACCESS;
> +

This is the wrong place for clearing the flag. This code path is only 
called when we move things back in after suspend/resume (or run out of 
GTT space).

Regards,
Christian.

>   out_cleanup:
>   	ttm_bo_mem_put(bo, &tmp_mem);
>   	return r;




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux