From patchwork Wed May 20 14:01:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Weinehall X-Patchwork-Id: 6446601 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 540FB9F318 for ; Wed, 20 May 2015 14:03:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 635EE2026F for ; Wed, 20 May 2015 14:03:15 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 721702026D for ; Wed, 20 May 2015 14:03:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0873B6E0AE; Wed, 20 May 2015 07:03:14 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id BFBFD6E0AE for ; Wed, 20 May 2015 07:03:12 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 20 May 2015 07:03:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,464,1427785200"; d="scan'208";a="697783933" Received: from dweineha-mobl3.fi.intel.com (HELO boom) ([10.237.72.77]) by orsmga001.jf.intel.com with ESMTP; 20 May 2015 07:03:11 -0700 Date: Wed, 20 May 2015 17:01:41 +0300 From: David Weinehall To: intel-gfx Message-ID: <20150520140141.GC13974@boom> Mail-Followup-To: intel-gfx MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150520135419.GA13974@boom> X-Editor: Vi Improved X-Accept-Language: Swedish, English X-GPG-Fingerprint: ED69 8CF5 6102 21B9 AFD1 9DB7 0B27 96FD 15DA A404 X-GPG-Key: http://www.acc.umu.se/~tao/files/pub_15daa404.gpg.asc X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.5.23 (2014-03-12) Subject: [Intel-gfx] [PATCH 02/03] libdrm: export context_{get, set}param and I915_CONTEXT_PARAM_NO_ZEROMAP X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 Provide helper functions for the context_{get,set}param ioctls, as well as the I915_CONTEXT_PARAM_NO_ZEROMAP parameter. Signed-off-by: David Weinehall --- configure.ac | 2 - include/drm/i915_drm.h | 1 intel/intel_bufmgr.h | 4 +++ intel/intel_bufmgr_gem.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 78a0010d851f..e48fb7e87c52 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ AC_PREREQ([2.63]) AC_INIT([libdrm], - [2.4.61], + [2.4.62], [https://bugs.freedesktop.org/enter_bug.cgi?product=DRI], [libdrm]) diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h index ded43b1cb117..a658d1cc367a 100644 --- a/include/drm/i915_drm.h +++ b/include/drm/i915_drm.h @@ -1101,6 +1101,7 @@ struct drm_i915_gem_context_param { __u32 size; __u64 param; #define I915_CONTEXT_PARAM_BAN_PERIOD 0x1 +#define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2 __u64 value; }; diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h index 285919e4c40d..b9af2361735d 100644 --- a/intel/intel_bufmgr.h +++ b/intel/intel_bufmgr.h @@ -203,6 +203,10 @@ int drm_intel_gem_bo_wait(drm_intel_bo *bo, int64_t timeout_ns); drm_intel_context *drm_intel_gem_context_create(drm_intel_bufmgr *bufmgr); void drm_intel_gem_context_destroy(drm_intel_context *ctx); +int drm_intel_gem_context_get_param(drm_intel_context *ctx, + uint64_t param, uint64_t *value); +int drm_intel_gem_context_set_param(drm_intel_context *ctx, + uint64_t param, uint64_t value); int drm_intel_gem_bo_context_exec(drm_intel_bo *bo, drm_intel_context *ctx, int used, unsigned int flags); diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index 60c06fccfb20..53378df2ecdf 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -3326,6 +3326,63 @@ drm_intel_gem_context_destroy(drm_intel_context *ctx) } int +drm_intel_gem_context_get_param(drm_intel_context *ctx, + uint64_t param, uint64_t *value) +{ + drm_intel_bufmgr_gem *bufmgr_gem; + struct drm_i915_gem_context_param ctx_param; + int ret; + + if (ctx == NULL) + return -EINVAL; + + memclear(ctx_param); + + bufmgr_gem = (drm_intel_bufmgr_gem *)ctx->bufmgr; + + ctx_param.ctx_id = ctx->ctx_id; + ctx_param.param = param; + + ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, + &ctx_param); + if (ret != 0) + fprintf(stderr, "DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM failed: %s\n", + strerror(errno)); + else + *value = ctx_param.value; + + return ret; +} + +int +drm_intel_gem_context_set_param(drm_intel_context *ctx, + uint64_t param, uint64_t value) +{ + drm_intel_bufmgr_gem *bufmgr_gem; + struct drm_i915_gem_context_param ctx_param; + int ret; + + if (ctx == NULL) + return -EINVAL; + + memclear(ctx_param); + + bufmgr_gem = (drm_intel_bufmgr_gem *)ctx->bufmgr; + + ctx_param.ctx_id = ctx->ctx_id; + ctx_param.param = param; + ctx_param.value = value; + + ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, + &ctx_param); + if (ret != 0) + fprintf(stderr, "DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM failed: %s (%d); %d\n", + strerror(errno), errno, ret); + + return ret; +} + +int drm_intel_get_reset_stats(drm_intel_context *ctx, uint32_t *reset_count, uint32_t *active,