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