Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/radeon: Add PASID manager for KFD

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Felix Kuehling and committed by
Alex Deucher
f4d6229b 02208441

+31
+31
drivers/gpu/drm/radeon/radeon_kfd.c
··· 58 58 static uint64_t get_gpu_clock_counter(struct kgd_dev *kgd); 59 59 60 60 static uint32_t get_max_engine_clock_in_mhz(struct kgd_dev *kgd); 61 + 62 + static int alloc_pasid(unsigned int bits); 63 + static void free_pasid(unsigned int pasid); 64 + 61 65 static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type); 62 66 63 67 /* ··· 116 112 .get_vmem_size = get_vmem_size, 117 113 .get_gpu_clock_counter = get_gpu_clock_counter, 118 114 .get_max_engine_clock_in_mhz = get_max_engine_clock_in_mhz, 115 + .alloc_pasid = alloc_pasid, 116 + .free_pasid = free_pasid, 119 117 .program_sh_mem_settings = kgd_program_sh_mem_settings, 120 118 .set_pasid_vmid_mapping = kgd_set_pasid_vmid_mapping, 121 119 .init_pipeline = kgd_init_pipeline, ··· 345 339 346 340 /* The sclk is in quantas of 10kHz */ 347 341 return rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac.sclk / 100; 342 + } 343 + 344 + /* 345 + * PASID manager 346 + */ 347 + static DEFINE_IDA(pasid_ida); 348 + 349 + int alloc_pasid(unsigned int bits) 350 + { 351 + int pasid = -EINVAL; 352 + 353 + for (bits = min(bits, 31U); bits > 0; bits--) { 354 + pasid = ida_simple_get(&pasid_ida, 355 + 1U << (bits - 1), 1U << bits, 356 + GFP_KERNEL); 357 + if (pasid != -ENOSPC) 358 + break; 359 + } 360 + 361 + return pasid; 362 + } 363 + 364 + void free_pasid(unsigned int pasid) 365 + { 366 + ida_simple_remove(&pasid_ida, pasid); 348 367 } 349 368 350 369 static inline struct radeon_device *get_radeon_device(struct kgd_dev *kgd)