From patchwork Tue Jun 30 12:24:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Weinehall X-Patchwork-Id: 6695501 Return-Path: X-Original-To: patchwork-dri-devel@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 2DFA19F380 for ; Tue, 30 Jun 2015 12:25:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8830820612 for ; Tue, 30 Jun 2015 12:25:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8B82B20616 for ; Tue, 30 Jun 2015 12:25:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 582C06E485; Tue, 30 Jun 2015 05:25:34 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 97CEA6E46A for ; Tue, 30 Jun 2015 05:25:32 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 30 Jun 2015 05:25:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,377,1432623600"; d="scan'208";a="720273139" Received: from dweineha-mobl3.fi.intel.com ([10.237.72.77]) by orsmga001.jf.intel.com with ESMTP; 30 Jun 2015 05:25:32 -0700 From: David Weinehall To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] intel: Add get/set context parameter helpers Date: Tue, 30 Jun 2015 15:24:52 +0300 Message-Id: <1435667093-14563-2-git-send-email-david.weinehall@linux.intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435667093-14563-1-git-send-email-david.weinehall@linux.intel.com> References: <1435667093-14563-1-git-send-email-david.weinehall@linux.intel.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.8 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 Add helper functions to set/get GEM context parameters. Signed-off-by: David Weinehall --- intel/intel_bufmgr.h | 4 ++++ intel/intel_bufmgr_gem.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) 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..2ac00cb3be3e 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, + ¶m); + 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, + ¶m); + if (ret != 0) + fprintf(stderr, "DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM failed: %s\n", + strerror(errno)); + + return ret; +} + +int drm_intel_get_reset_stats(drm_intel_context *ctx, uint32_t *reset_count, uint32_t *active,