From patchwork Wed Sep 24 13:41:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Winiarski?= X-Patchwork-Id: 4965971 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A583EBEEA5 for ; Wed, 24 Sep 2014 13:52:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 70463201E4 for ; Wed, 24 Sep 2014 13:52:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B3F69201CD for ; Wed, 24 Sep 2014 13:52:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D9CA96E410; Wed, 24 Sep 2014 06:51:59 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org X-Greylist: delayed 561 seconds by postgrey-1.34 at gabe; Wed, 24 Sep 2014 06:51:58 PDT Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 980FF6E410 for ; Wed, 24 Sep 2014 06:51:58 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 24 Sep 2014 06:40:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,589,1406617200"; d="scan'208";a="578221939" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by orsmga001.jf.intel.com with ESMTP; 24 Sep 2014 06:42:36 -0700 Received: from mwiniars-desk.igk.intel.com (172.28.173.29) by IRSMSX103.ger.corp.intel.com (163.33.3.157) with Microsoft SMTP Server id 14.3.195.1; Wed, 24 Sep 2014 14:42:16 +0100 From: =?UTF-8?q?Micha=C5=82=20Winiarski?= To: Date: Wed, 24 Sep 2014 15:41:08 +0200 Message-ID: <1411566068-1018-1-git-send-email-michal.winiarski@intel.com> X-Mailer: git-send-email 1.9.3 MIME-Version: 1.0 X-Originating-IP: [172.28.173.29] Subject: [Intel-gfx] [RFC] drm/i915: Add sysfs entry for reading GPU Timestamp X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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, ×tamp_attr); + if (ret) + DRM_ERROR("timestamp sysfs setup failed\n"); } void i915_teardown_sysfs(struct drm_device *dev)