[PATCH 3/3] drm/amdgpu:invoke CSA functions

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

 



Am 11.01.2017 um 11:43 schrieb Monk Liu:
> Change-Id: I528c2f324830aaa21ab8d8250bc80a2a6bab33bd
> Signed-off-by: Monk Liu <Monk.Liu at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c     | 14 ++++++++++++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 ++++++++++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 14 ++++++++++++++
>   drivers/gpu/drm/amd/amdgpu/vi.c            |  3 +++
>   4 files changed, 43 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index 6159afc..328f1c7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> @@ -771,6 +771,20 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p,
>   	if (r)
>   		return r;
>   
> +	if (amdgpu_sriov_vf(adev)) {
> +		struct fence *f;

A new line between declaration and code.

> +		bo_va = vm->csa_bo_va;
> +		BUG_ON(!bo_va);
> +		r = amdgpu_vm_bo_update(adev, bo_va, false);
> +		if (r)
> +			return r;
> +
> +		f = bo_va->last_pt_update;
> +		r = amdgpu_sync_fence(adev, &p->job->sync, f);
> +		if (r)
> +			return r;
> +	}
> +
>   	if (p->bo_list) {
>   		for (i = 0; i < p->bo_list->num_entries; i++) {
>   			struct fence *f;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index f82919d..7c73dee 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -1384,6 +1384,15 @@ static int amdgpu_init(struct amdgpu_device *adev)
>   				return r;
>   			}
>   			adev->ip_blocks[i].status.hw = true;
> +
> +			/* right after GMC hw init, we create CSA */
> +			if (amdgpu_sriov_vf(adev)) {
> +				r = amdgpu_allocate_static_csa(adev);
> +				if (r) {
> +					DRM_ERROR("allocate CSA failed %d\n", r);
> +					return r;
> +				}
> +			}

We sooner or later need to fix those extras in the init order, but that 
is clearly not topic of this patch.

>   		}
>   	}
>   
> @@ -1517,6 +1526,9 @@ static int amdgpu_fini(struct amdgpu_device *adev)
>   		adev->ip_blocks[i].status.late_initialized = false;
>   	}
>   
> +	if (amdgpu_sriov_vf(adev))
> +		amdgpu_bo_free_kernel(&adev->virt.csa_obj, &adev->virt.csa_vmid0_addr, NULL);
> +
>   	return 0;
>   }
>   
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 47bc8e1..1421a9d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -650,6 +650,12 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
>   		goto out_suspend;
>   	}
>   
> +	if (amdgpu_sriov_vf(adev)) {
> +		r = amdgpu_map_static_csa(adev, &fpriv->vm);
> +		if (r)
> +			goto out_suspend;
> +	}
> +
>   	mutex_init(&fpriv->bo_list_lock);
>   	idr_init(&fpriv->bo_list_handles);
>   
> @@ -688,6 +694,14 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
>   	amdgpu_uvd_free_handles(adev, file_priv);
>   	amdgpu_vce_free_handles(adev, file_priv);
>   
> +	if (amdgpu_sriov_vf(adev)) {
> +		/* TODO: how to handle reserve failure */
> +		BUG_ON(amdgpu_bo_reserve(adev->virt.csa_obj, false));

Reservation should never fail as long as you don't set the interruptible 
paramter to true, so using BUG_ON() should be ok here.

But I'm not 100% sure if BUG_ON() doesn't works like assert(), e.g. on a 
not debug build the compiler could optimize the call to 
amdgpu_bo_reserve away.

So better do:
r = amdgpu_bo_reserve(adev->virt.csa_obj, false);
BUG_ON(!r);

With that fixed the patch is Reviewed-by: Christian König 
<christian.koenig at amd.com>.

Regards,
Christian.

> +		amdgpu_vm_bo_rmv(adev, fpriv->vm.csa_bo_va);
> +		fpriv->vm.csa_bo_va = NULL;
> +		amdgpu_bo_unreserve(adev->virt.csa_obj);
> +	}
> +
>   	amdgpu_vm_fini(adev, &fpriv->vm);
>   
>   	idr_for_each_entry(&fpriv->bo_list_handles, list, handle)
> diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c
> index 7350a8f..1f307c3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vi.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vi.c
> @@ -455,6 +455,9 @@ static void vi_detect_hw_virtualization(struct amdgpu_device *adev)
>   		if (is_virtual_machine()) /* passthrough mode exclus sr-iov mode */
>   			adev->virt.caps |= AMDGPU_PASSTHROUGH_MODE;
>   	}
> +
> +	if (amdgpu_sriov_vf(adev))
> +		adev->virt.csa_size = AMDGPU_CSA_SIZE; /* two page now for VI and AI */
>   }
>   
>   static const struct amdgpu_allowed_register_entry tonga_allowed_read_registers[] = {




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

  Powered by Linux