From: Oded Gabbay <oded.gabbay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: David Airlie <airlied-cv59FeDIM0c@public.gmane.org>,
Alex Deucher <alexander.deucher-5C7GfCeVMHo@public.gmane.org>,
Jerome Glisse <j.glisse-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
John Bridgman <John.Bridgman-5C7GfCeVMHo@public.gmane.org>,
Andrew Lewycky <Andrew.Lewycky-5C7GfCeVMHo@public.gmane.org>,
Joerg Roedel <joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>,
Evgeny Pinchuk <evgeny.pinchuk-5C7GfCeVMHo@public.gmane.org>,
Oded Gabbay <oded.gabbay-5C7GfCeVMHo@public.gmane.org>,
Ben Goz <ben.goz-5C7GfCeVMHo@public.gmane.org>,
Alexey Skidanov <Alexey.Skidanov-5C7GfCeVMHo@public.gmane.org>,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 32/83] hsa/radeon: implementing IOCTL for clock counters
Date: Fri, 11 Jul 2014 00:53:48 +0300 [thread overview]
Message-ID: <1405029279-6894-4-git-send-email-oded.gabbay@amd.com> (raw)
In-Reply-To: <1405029279-6894-1-git-send-email-oded.gabbay-5C7GfCeVMHo@public.gmane.org>
From: Evgeny Pinchuk <evgeny.pinchuk-5C7GfCeVMHo@public.gmane.org>
Implemented new IOCTL to query the CPU and GPU clock counters.
Signed-off-by: Evgeny Pinchuk <evgeny.pinchuk-5C7GfCeVMHo@public.gmane.org>
Signed-off-by: Oded Gabbay <oded.gabbay-5C7GfCeVMHo@public.gmane.org>
---
drivers/gpu/hsa/radeon/kfd_chardev.c | 37 ++++++++++++++++++++++++++++++++++++
include/uapi/linux/kfd_ioctl.h | 9 +++++++++
2 files changed, 46 insertions(+)
diff --git a/drivers/gpu/hsa/radeon/kfd_chardev.c b/drivers/gpu/hsa/radeon/kfd_chardev.c
index ddaf357..d6fa980 100644
--- a/drivers/gpu/hsa/radeon/kfd_chardev.c
+++ b/drivers/gpu/hsa/radeon/kfd_chardev.c
@@ -28,6 +28,7 @@
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <uapi/linux/kfd_ioctl.h>
+#include <linux/time.h>
#include "kfd_priv.h"
#include "kfd_scheduler.h"
@@ -284,6 +285,38 @@ out:
return err;
}
+static long
+kfd_ioctl_get_clock_counters(struct file *filep, struct kfd_process *p, void __user *arg)
+{
+ struct kfd_ioctl_get_clock_counters_args args;
+ struct kfd_dev *dev;
+ struct timespec time;
+
+ if (copy_from_user(&args, arg, sizeof(args)))
+ return -EFAULT;
+
+ dev = radeon_kfd_device_by_id(args.gpu_id);
+ if (dev == NULL)
+ return -EINVAL;
+
+ /* Reading GPU clock counter from KGD */
+ args.gpu_clock_counter = kfd2kgd->get_gpu_clock_counter(dev->kgd);
+
+ /* No access to rdtsc. Using raw monotonic time */
+ getrawmonotonic(&time);
+ args.cpu_clock_counter = time.tv_nsec;
+
+ get_monotonic_boottime(&time);
+ args.system_clock_counter = time.tv_nsec;
+
+ /* Since the counter is in nano-seconds we use 1GHz frequency */
+ args.system_clock_freq = 1000000000;
+
+ if (copy_to_user(arg, &args, sizeof(args)))
+ return -EFAULT;
+
+ return 0;
+}
static long
kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
@@ -312,6 +345,10 @@ kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
err = kfd_ioctl_set_memory_policy(filep, process, (void __user *)arg);
break;
+ case KFD_IOC_GET_CLOCK_COUNTERS:
+ err = kfd_ioctl_get_clock_counters(filep, process, (void __user *)arg);
+ break;
+
default:
dev_err(kfd_device,
"unknown ioctl cmd 0x%x, arg 0x%lx)\n",
diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h
index 928e628..5b9517e 100644
--- a/include/uapi/linux/kfd_ioctl.h
+++ b/include/uapi/linux/kfd_ioctl.h
@@ -70,12 +70,21 @@ struct kfd_ioctl_set_memory_policy_args {
uint64_t alternate_aperture_size; /* to KFD */
};
+struct kfd_ioctl_get_clock_counters_args {
+ uint32_t gpu_id; /* to KFD */
+ uint64_t gpu_clock_counter; /* from KFD */
+ uint64_t cpu_clock_counter; /* from KFD */
+ uint64_t system_clock_counter; /* from KFD */
+ uint64_t system_clock_freq; /* from KFD */
+};
+
#define KFD_IOC_MAGIC 'K'
#define KFD_IOC_GET_VERSION _IOR(KFD_IOC_MAGIC, 1, struct kfd_ioctl_get_version_args)
#define KFD_IOC_CREATE_QUEUE _IOWR(KFD_IOC_MAGIC, 2, struct kfd_ioctl_create_queue_args)
#define KFD_IOC_DESTROY_QUEUE _IOWR(KFD_IOC_MAGIC, 3, struct kfd_ioctl_destroy_queue_args)
#define KFD_IOC_SET_MEMORY_POLICY _IOW(KFD_IOC_MAGIC, 4, struct kfd_ioctl_set_memory_policy_args)
+#define KFD_IOC_GET_CLOCK_COUNTERS _IOWR(KFD_IOC_MAGIC, 5, struct kfd_ioctl_get_clock_counters_args)
#pragma pack(pop)
--
1.9.1
next parent reply other threads:[~2014-07-10 21:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1405029279-6894-1-git-send-email-oded.gabbay@amd.com>
[not found] ` <1405029279-6894-1-git-send-email-oded.gabbay-5C7GfCeVMHo@public.gmane.org>
2014-07-10 21:53 ` Oded Gabbay [this message]
2014-07-11 20:34 ` [PATCH 32/83] hsa/radeon: implementing IOCTL for clock counters Jerome Glisse
2014-07-10 21:53 ` [PATCH 42/83] hsa/radeon: 32-bit processes support Oded Gabbay
2014-07-10 21:54 ` [PATCH 44/83] hsa/radeon: HSA64/HSA32 modes support Oded Gabbay
[not found] ` <1405029279-6894-16-git-send-email-oded.gabbay-5C7GfCeVMHo@public.gmane.org>
2014-07-11 20:41 ` Jerome Glisse
2014-07-10 21:54 ` [PATCH 54/83] hsa/radeon: Switch to new queue scheduler Oded Gabbay
2014-07-10 21:54 ` [PATCH 55/83] hsa/radeon: Add IOCTL for update queue Oded Gabbay
2014-07-10 21:54 ` [PATCH 59/83] hsa/radeon: Exclusive access for perf. counters Oded Gabbay
2014-07-10 21:54 ` [PATCH 60/83] hsa/radeon: Rearrange structures in kfd_ioctl.h Oded Gabbay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1405029279-6894-4-git-send-email-oded.gabbay@amd.com \
--to=oded.gabbay-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=Alexey.Skidanov-5C7GfCeVMHo@public.gmane.org \
--cc=Andrew.Lewycky-5C7GfCeVMHo@public.gmane.org \
--cc=John.Bridgman-5C7GfCeVMHo@public.gmane.org \
--cc=airlied-cv59FeDIM0c@public.gmane.org \
--cc=alexander.deucher-5C7GfCeVMHo@public.gmane.org \
--cc=ben.goz-5C7GfCeVMHo@public.gmane.org \
--cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=evgeny.pinchuk-5C7GfCeVMHo@public.gmane.org \
--cc=j.glisse-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=oded.gabbay-5C7GfCeVMHo@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).