amdkfd: init aperture once per process

Since the user space may call open() more that once from the same process,
the aperture initialization should be moved from kfd_open()

Signed-off-by: Alexey Skidanov <Alexey.Skidanov@amd.com>
Reviewed-by: Oded Gabbay <oded.gabbay@amd.com>
Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>

authored by Alexey Skidanov and committed by Oded Gabbay dd59239a f1386fbc

+11 -8
-4
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
··· 121 121 if (IS_ERR(process)) 122 122 return PTR_ERR(process); 123 123 124 - process->is_32bit_user_mode = is_32bit_user_mode; 125 - 126 124 dev_dbg(kfd_device, "process %d opened, compat mode (32 bit) - %d\n", 127 125 process->pasid, process->is_32bit_user_mode); 128 - 129 - kfd_init_apertures(process); 130 126 131 127 return 0; 132 128 }
+2 -4
drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
··· 299 299 struct kfd_dev *dev; 300 300 struct kfd_process_device *pdd; 301 301 302 - mutex_lock(&process->mutex); 303 - 304 302 /*Iterating over all devices*/ 305 303 while ((dev = kfd_topology_enum_kfd_devices(id)) != NULL && 306 304 id < NUM_OF_SUPPORTED_GPUS) { 307 305 308 306 pdd = kfd_get_process_device_data(dev, process, 1); 307 + if (!pdd) 308 + return -1; 309 309 310 310 /* 311 311 * For 64 bit process aperture will be statically reserved in ··· 347 347 348 348 id++; 349 349 } 350 - 351 - mutex_unlock(&process->mutex); 352 350 353 351 return 0; 354 352 }
+9
drivers/gpu/drm/amd/amdkfd/kfd_process.c
··· 26 26 #include <linux/slab.h> 27 27 #include <linux/amd-iommu.h> 28 28 #include <linux/notifier.h> 29 + #include <linux/compat.h> 30 + 29 31 struct mm_struct; 30 32 31 33 #include "kfd_priv.h" ··· 287 285 if (err != 0) 288 286 goto err_process_pqm_init; 289 287 288 + /* init process apertures*/ 289 + process->is_32bit_user_mode = is_compat_task(); 290 + if (kfd_init_apertures(process) != 0) 291 + goto err_init_apretures; 292 + 290 293 return process; 291 294 295 + err_init_apretures: 296 + pqm_uninit(&process->pqm); 292 297 err_process_pqm_init: 293 298 hash_del_rcu(&process->kfd_processes); 294 299 synchronize_rcu();