aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Skidanov <Alexey.Skidanov@amd.com>2014-11-18 06:56:23 -0500
committerOded Gabbay <oded.gabbay@amd.com>2014-11-18 06:56:23 -0500
commitdd59239a9862a42e4b8d47e4aaa8d595d08c29ab (patch)
tree094241804abad7eee48ac6d68c03da4903add690
parentf1386fbc2bc9e316c3f58ef9463f03002eb41346 (diff)
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>
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_chardev.c4
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c6
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_process.c9
3 files changed, 11 insertions, 8 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 4f7b275f2f7b..7d4974b83af7 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -121,13 +121,9 @@ static int kfd_open(struct inode *inode, struct file *filep)
121 if (IS_ERR(process)) 121 if (IS_ERR(process))
122 return PTR_ERR(process); 122 return PTR_ERR(process);
123 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", 124 dev_dbg(kfd_device, "process %d opened, compat mode (32 bit) - %d\n",
127 process->pasid, process->is_32bit_user_mode); 125 process->pasid, process->is_32bit_user_mode);
128 126
129 kfd_init_apertures(process);
130
131 return 0; 127 return 0;
132} 128}
133 129
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
index 66df4da01c29..e64aa99e5e41 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
@@ -299,13 +299,13 @@ int kfd_init_apertures(struct kfd_process *process)
299 struct kfd_dev *dev; 299 struct kfd_dev *dev;
300 struct kfd_process_device *pdd; 300 struct kfd_process_device *pdd;
301 301
302 mutex_lock(&process->mutex);
303
304 /*Iterating over all devices*/ 302 /*Iterating over all devices*/
305 while ((dev = kfd_topology_enum_kfd_devices(id)) != NULL && 303 while ((dev = kfd_topology_enum_kfd_devices(id)) != NULL &&
306 id < NUM_OF_SUPPORTED_GPUS) { 304 id < NUM_OF_SUPPORTED_GPUS) {
307 305
308 pdd = kfd_get_process_device_data(dev, process, 1); 306 pdd = kfd_get_process_device_data(dev, process, 1);
307 if (!pdd)
308 return -1;
309 309
310 /* 310 /*
311 * For 64 bit process aperture will be statically reserved in 311 * For 64 bit process aperture will be statically reserved in
@@ -348,8 +348,6 @@ int kfd_init_apertures(struct kfd_process *process)
348 id++; 348 id++;
349 } 349 }
350 350
351 mutex_unlock(&process->mutex);
352
353 return 0; 351 return 0;
354} 352}
355 353
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index b85eb0b830b4..3c76ef05cbcf 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -26,6 +26,8 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/amd-iommu.h> 27#include <linux/amd-iommu.h>
28#include <linux/notifier.h> 28#include <linux/notifier.h>
29#include <linux/compat.h>
30
29struct mm_struct; 31struct mm_struct;
30 32
31#include "kfd_priv.h" 33#include "kfd_priv.h"
@@ -285,8 +287,15 @@ static struct kfd_process *create_process(const struct task_struct *thread)
285 if (err != 0) 287 if (err != 0)
286 goto err_process_pqm_init; 288 goto err_process_pqm_init;
287 289
290 /* init process apertures*/
291 process->is_32bit_user_mode = is_compat_task();
292 if (kfd_init_apertures(process) != 0)
293 goto err_init_apretures;
294
288 return process; 295 return process;
289 296
297err_init_apretures:
298 pqm_uninit(&process->pqm);
290err_process_pqm_init: 299err_process_pqm_init:
291 hash_del_rcu(&process->kfd_processes); 300 hash_del_rcu(&process->kfd_processes);
292 synchronize_rcu(); 301 synchronize_rcu();