[PATCH 3/9] drm/radeon: Add PASID manager for KFD

Christian König deathsimple at vodafone.de
Sat Aug 26 13:27:46 UTC 2017


Am 26.08.2017 um 09:19 schrieb Felix Kuehling:
> Change-Id: I101a5ac8e0ebf0dbbe6dbd1f61cd8236d499c5b8
> Signed-off-by: Felix Kuehling <Felix.Kuehling at amd.com>

Reviewed-by: Christian König <christian.koenig at amd.com>

> ---
>   drivers/gpu/drm/radeon/radeon_kfd.c | 30 ++++++++++++++++++++++++++++++
>   1 file changed, 30 insertions(+)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_kfd.c b/drivers/gpu/drm/radeon/radeon_kfd.c
> index 81fb94b..acfe34e 100644
> --- a/drivers/gpu/drm/radeon/radeon_kfd.c
> +++ b/drivers/gpu/drm/radeon/radeon_kfd.c
> @@ -79,6 +79,9 @@ static uint64_t get_gpu_clock_counter(struct kgd_dev *kgd);
>   
>   static uint32_t get_max_engine_clock_in_mhz(struct kgd_dev *kgd);
>   
> +static int alloc_pasid(unsigned int bits);
> +static void free_pasid(unsigned int pasid);
> +
>   static int create_process_vm(struct kgd_dev *kgd, void **vm, void **info);
>   static void destroy_process_vm(struct kgd_dev *kgd, void *vm);
>   
> @@ -161,6 +164,8 @@ static const struct kfd2kgd_calls kfd2kgd = {
>   	.get_local_mem_info = get_local_mem_info,
>   	.get_gpu_clock_counter = get_gpu_clock_counter,
>   	.get_max_engine_clock_in_mhz = get_max_engine_clock_in_mhz,
> +	.alloc_pasid = alloc_pasid,
> +	.free_pasid = free_pasid,
>   	.create_process_vm = create_process_vm,
>   	.destroy_process_vm = destroy_process_vm,
>   	.get_process_page_dir = get_process_page_dir,
> @@ -415,6 +420,31 @@ static uint32_t get_max_engine_clock_in_mhz(struct kgd_dev *kgd)
>   }
>   
>   /*
> + * PASID manager
> + */
> +static DEFINE_IDA(pasid_ida);
> +
> +int alloc_pasid(unsigned int bits)
> +{
> +	int pasid = -EINVAL;
> +
> +	for (bits = min(bits, 31U); bits > 0; bits--) {
> +		pasid = ida_simple_get(&pasid_ida,
> +				       1U << (bits - 1), 1U << bits,
> +				       GFP_KERNEL);
> +		if (pasid != -ENOSPC)
> +			break;
> +	}
> +
> +	return pasid;
> +}
> +
> +void free_pasid(unsigned int pasid)
> +{
> +	ida_simple_remove(&pasid_ida, pasid);
> +}
> +
> +/*
>    * Creates a VM context for HSA process
>    */
>   static int create_process_vm(struct kgd_dev *kgd, void **vm, void **info)




More information about the amd-gfx mailing list