[PATCH 5/9] drm/amdgpu: Delay map sriov csa addr to ctx init

Christian König ckoenig.leichtzumerken at gmail.com
Thu Dec 6 12:38:33 UTC 2018


Am 06.12.18 um 13:14 schrieb Rex Zhu:
> 1. meet kfd request
> 2. align with baremetal, in baremetal, driver map csa
>     per ctx.
>
> Signed-off-by: Rex Zhu <Rex.Zhu at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 19 ++++++++++++++++++-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c |  8 --------
>   2 files changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> index 8802ff2..3ab7262 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> @@ -68,11 +68,13 @@ static int amdgpu_ctx_priority_permit(struct drm_file *filp,
>   }
>   
>   static int amdgpu_ctx_init(struct amdgpu_device *adev,
> +			   struct amdgpu_fpriv *fpriv,
>   			   enum drm_sched_priority priority,
>   			   struct drm_file *filp,
>   			   struct amdgpu_ctx *ctx)
>   {
>   	unsigned num_entities = amdgput_ctx_total_num_entities();
> +	uint64_t csa_addr;
>   	unsigned i, j;
>   	int r;
>   
> @@ -86,6 +88,21 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev,
>   	memset(ctx, 0, sizeof(*ctx));
>   	ctx->adev = adev;
>   
> +	if (amdgpu_sriov_vf(adev)) {
> +		if (!fpriv->csa_va) {
> +			csa_addr = amdgpu_csa_vaddr(adev, 1) & AMDGPU_GMC_HOLE_MASK;
> +			r = amdgpu_map_static_csa(adev, &fpriv->vm,
> +						adev->virt.csa_obj,
> +						&fpriv->csa_va,
> +						csa_addr,
> +						AMDGPU_CSA_SIZE);
> +			if (r) {
> +				amdgpu_free_static_csa(&adev->virt.csa_obj);
> +				return -EINVAL;
> +			}

Please double check that this is protected by some lock.

Christian.

> +		}
> +	}
> +
>   	ctx->fences = kcalloc(amdgpu_sched_jobs * num_entities,
>   			      sizeof(struct dma_fence*), GFP_KERNEL);
>   	if (!ctx->fences)
> @@ -255,7 +272,7 @@ static int amdgpu_ctx_alloc(struct amdgpu_device *adev,
>   	}
>   
>   	*id = (uint32_t)r;
> -	r = amdgpu_ctx_init(adev, priority, filp, ctx);
> +	r = amdgpu_ctx_init(adev, fpriv, priority, filp, ctx);
>   	if (r) {
>   		idr_remove(&mgr->ctx_handles, *id);
>   		*id = 0;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 338a091..34d000a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -977,14 +977,6 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
>   		goto error_vm;
>   	}
>   
> -	if (amdgpu_sriov_vf(adev)) {
> -		uint64_t csa_addr = amdgpu_csa_vaddr(adev, 1) & AMDGPU_GMC_HOLE_MASK;
> -		r = amdgpu_map_static_csa(adev, &fpriv->vm, adev->virt.csa_obj,
> -						&fpriv->csa_va, csa_addr, AMDGPU_CSA_SIZE);
> -		if (r)
> -			goto error_vm;
> -	}
> -
>   	mutex_init(&fpriv->bo_list_lock);
>   	idr_init(&fpriv->bo_list_handles);
>   



More information about the amd-gfx mailing list