All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] drm/i915: Add sysfs entry for reading GPU Timestamp
@ 2014-09-24 13:41 Michał Winiarski
  2014-09-24 14:59 ` Chris Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: Michał Winiarski @ 2014-09-24 13:41 UTC (permalink / raw)
  To: intel-gfx

Reading timestamp register using I915_READ64 returns incorrect value.
Unfortunately, that's how I915_REG_READ ioctl is handling it on x86_64,
resulting in different counter size (we can only get 32 usable bits on
x86_64 vs 36 bits on x86).
Propose new sysfs interface for accessing full 36 bits of timestamp in
architecture independent way (using two consecutive reads).

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/i915/i915_sysfs.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c
index 503847f..30e8e16 100644
--- a/drivers/gpu/drm/i915/i915_sysfs.c
+++ b/drivers/gpu/drm/i915/i915_sysfs.c
@@ -590,6 +590,23 @@ static struct bin_attribute error_state_attr = {
 	.write = error_state_write,
 };
 
+static ssize_t timestamp_show(struct device *dev, struct device_attribute *attr,
+				char *buf)
+{
+	struct drm_minor *dminor = dev_to_drm_minor(dev);
+	struct drm_device *drm_dev = dminor->dev;
+	struct drm_i915_private *dev_priv = drm_dev->dev_private;
+	u64 val;
+	val = I915_READ64_2x32(RING_TIMESTAMP(RENDER_RING_BASE), RING_TIMESTAMP(RENDER_RING_BASE) + 4);
+	return snprintf(buf, PAGE_SIZE, "%llu\n", val);
+}
+
+static struct device_attribute timestamp_attr = {
+	.attr.name = "timestamp",
+	.attr.mode = S_IRUGO,
+	.show = timestamp_show,
+};
+
 void i915_setup_sysfs(struct drm_device *dev)
 {
 	int ret;
@@ -627,6 +644,10 @@ void i915_setup_sysfs(struct drm_device *dev)
 				    &error_state_attr);
 	if (ret)
 		DRM_ERROR("error_state sysfs setup failed\n");
+
+	ret = device_create_file(dev->primary->kdev, &timestamp_attr);
+	if (ret)
+		DRM_ERROR("timestamp sysfs setup failed\n");
 }
 
 void i915_teardown_sysfs(struct drm_device *dev)
-- 
1.9.3

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC] drm/i915: Add sysfs entry for reading GPU Timestamp
  2014-09-24 13:41 [RFC] drm/i915: Add sysfs entry for reading GPU Timestamp Michał Winiarski
@ 2014-09-24 14:59 ` Chris Wilson
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Wilson @ 2014-09-24 14:59 UTC (permalink / raw)
  To: Michał Winiarski; +Cc: intel-gfx

On Wed, Sep 24, 2014 at 03:41:08PM +0200, Michał Winiarski wrote:
> Reading timestamp register using I915_READ64 returns incorrect value.
> Unfortunately, that's how I915_REG_READ ioctl is handling it on x86_64,
> resulting in different counter size (we can only get 32 usable bits on
> x86_64 vs 36 bits on x86).
> Propose new sysfs interface for accessing full 36 bits of timestamp in
> architecture independent way (using two consecutive reads).

I've seen lots of patches to avoid fixing the register read. Why?
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-24 14:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-24 13:41 [RFC] drm/i915: Add sysfs entry for reading GPU Timestamp Michał Winiarski
2014-09-24 14:59 ` Chris Wilson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.