diff options
author | Andrew Lewycky <Andrew.Lewycky@amd.com> | 2014-07-16 18:46:17 -0400 |
---|---|---|
committer | Oded Gabbay <oded.gabbay@amd.com> | 2014-07-16 18:46:17 -0400 |
commit | 41a286fa54e850add4482146c511b088354f6f2d (patch) | |
tree | 93a5580926d0540022908f77e4f9ea2b09b8368d | |
parent | 39b027d957d4a9666a815ccf5bdce82e7796b2c6 (diff) |
amdkfd: Implement the Set Memory Policy IOCTL
Signed-off-by: Andrew Lewycky <Andrew.Lewycky@amd.com>
Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index d342035a8634..1020faf3d703 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <uapi/asm-generic/mman-common.h> | 35 | #include <uapi/asm-generic/mman-common.h> |
36 | #include <asm/processor.h> | 36 | #include <asm/processor.h> |
37 | #include "kfd_priv.h" | 37 | #include "kfd_priv.h" |
38 | #include "kfd_device_queue_manager.h" | ||
38 | 39 | ||
39 | static long kfd_ioctl(struct file *, unsigned int, unsigned long); | 40 | static long kfd_ioctl(struct file *, unsigned int, unsigned long); |
40 | static int kfd_open(struct inode *, struct file *); | 41 | static int kfd_open(struct inode *, struct file *); |
@@ -345,7 +346,56 @@ static int kfd_ioctl_update_queue(struct file *filp, struct kfd_process *p, | |||
345 | static long kfd_ioctl_set_memory_policy(struct file *filep, | 346 | static long kfd_ioctl_set_memory_policy(struct file *filep, |
346 | struct kfd_process *p, void __user *arg) | 347 | struct kfd_process *p, void __user *arg) |
347 | { | 348 | { |
348 | return -ENODEV; | 349 | struct kfd_ioctl_set_memory_policy_args args; |
350 | struct kfd_dev *dev; | ||
351 | int err = 0; | ||
352 | struct kfd_process_device *pdd; | ||
353 | enum cache_policy default_policy, alternate_policy; | ||
354 | |||
355 | if (copy_from_user(&args, arg, sizeof(args))) | ||
356 | return -EFAULT; | ||
357 | |||
358 | if (args.default_policy != KFD_IOC_CACHE_POLICY_COHERENT | ||
359 | && args.default_policy != KFD_IOC_CACHE_POLICY_NONCOHERENT) { | ||
360 | return -EINVAL; | ||
361 | } | ||
362 | |||
363 | if (args.alternate_policy != KFD_IOC_CACHE_POLICY_COHERENT | ||
364 | && args.alternate_policy != KFD_IOC_CACHE_POLICY_NONCOHERENT) { | ||
365 | return -EINVAL; | ||
366 | } | ||
367 | |||
368 | dev = kfd_device_by_id(args.gpu_id); | ||
369 | if (dev == NULL) | ||
370 | return -EINVAL; | ||
371 | |||
372 | mutex_lock(&p->mutex); | ||
373 | |||
374 | pdd = kfd_bind_process_to_device(dev, p); | ||
375 | if (IS_ERR(pdd) < 0) { | ||
376 | err = PTR_ERR(pdd); | ||
377 | goto out; | ||
378 | } | ||
379 | |||
380 | default_policy = (args.default_policy == KFD_IOC_CACHE_POLICY_COHERENT) | ||
381 | ? cache_policy_coherent : cache_policy_noncoherent; | ||
382 | |||
383 | alternate_policy = | ||
384 | (args.alternate_policy == KFD_IOC_CACHE_POLICY_COHERENT) | ||
385 | ? cache_policy_coherent : cache_policy_noncoherent; | ||
386 | |||
387 | if (!dev->dqm->set_cache_memory_policy(dev->dqm, | ||
388 | &pdd->qpd, | ||
389 | default_policy, | ||
390 | alternate_policy, | ||
391 | (void __user *)args.alternate_aperture_base, | ||
392 | args.alternate_aperture_size)) | ||
393 | err = -EINVAL; | ||
394 | |||
395 | out: | ||
396 | mutex_unlock(&p->mutex); | ||
397 | |||
398 | return err; | ||
349 | } | 399 | } |
350 | 400 | ||
351 | static long kfd_ioctl_get_clock_counters(struct file *filep, | 401 | static long kfd_ioctl_get_clock_counters(struct file *filep, |