From patchwork Wed Apr 20 17:13:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Harrison X-Patchwork-Id: 8893601 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 DB59D9F46D for ; Wed, 20 Apr 2016 17:17:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 071A620145 for ; Wed, 20 Apr 2016 17:17:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 1353920149 for ; Wed, 20 Apr 2016 17:17:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 01F566EAA7; Wed, 20 Apr 2016 17:17:37 +0000 (UTC) X-Original-To: Intel-GFX@lists.freedesktop.org Delivered-To: Intel-GFX@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 4FE2B6EA88 for ; Wed, 20 Apr 2016 17:14:40 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 20 Apr 2016 10:14:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,510,1455004800"; d="scan'208";a="689424633" Received: from johnharr-linux.isw.intel.com ([10.102.226.93]) by FMSMGA003.fm.intel.com with ESMTP; 20 Apr 2016 10:14:37 -0700 From: John.C.Harrison@Intel.com To: Intel-GFX@Lists.FreeDesktop.Org Date: Wed, 20 Apr 2016 18:13:53 +0100 Message-Id: <1461172435-4256-36-git-send-email-John.C.Harrison@Intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461172435-4256-1-git-send-email-John.C.Harrison@Intel.com> References: <1461172435-4256-1-git-send-email-John.C.Harrison@Intel.com> Subject: [Intel-gfx] [PATCH 1/1] drm/i915: Add wrapper for context priority interface 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.2 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 From: John Harrison There is an EGL extension to set execution priority per context. This can be implemented via the i915 per context priority parameter. This patch adds a wrapper to connect the two together in a way that can be updated as necessary without breaking one side or the other. Signed-off-by: John Harrison --- include/drm/i915_drm.h | 1 + intel/intel_bufmgr.h | 5 ++++ intel/intel_bufmgr_gem.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h index c4ce6b2..8d9f063 100644 --- a/include/drm/i915_drm.h +++ b/include/drm/i915_drm.h @@ -1167,6 +1167,7 @@ struct drm_i915_gem_context_param { #define I915_CONTEXT_PARAM_BAN_PERIOD 0x1 #define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2 #define I915_CONTEXT_PARAM_GTT_SIZE 0x3 +#define I915_CONTEXT_PARAM_PRIORITY 0x4 __u64 value; }; diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h index a1abbcd..49d4125 100644 --- a/intel/intel_bufmgr.h +++ b/intel/intel_bufmgr.h @@ -209,6 +209,11 @@ 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_priority(drm_intel_context *ctx, int *priority); +#define DRM_INTEL_CTX_SET_PRIORITY_EGL_LOW (0x10001) +#define DRM_INTEL_CTX_SET_PRIORITY_EGL_MEDIUM (0x10002) +#define DRM_INTEL_CTX_SET_PRIORITY_EGL_HIGH (0x10003) +int drm_intel_gem_context_set_priority(drm_intel_context *ctx, int priority); 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 0a4012b..591ccd5 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -3154,6 +3154,76 @@ drm_intel_gem_context_destroy(drm_intel_context *ctx) } int +drm_intel_gem_context_get_priority(drm_intel_context *ctx, int *priority) +{ + drm_intel_bufmgr_gem *bufmgr_gem; + struct drm_i915_gem_context_param ctxparam; + int ret; + + if ((ctx == NULL) || (priority == NULL)) + return -EINVAL; + + memclear(ctxparam); + + bufmgr_gem = (drm_intel_bufmgr_gem *)ctx->bufmgr; + ctxparam.ctx_id = ctx->ctx_id; + ctxparam.param = I915_CONTEXT_PARAM_PRIORITY; + ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, + &ctxparam); + if (ret != 0) { + int err = errno; + *priority = 0; + fprintf(stderr, "DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM failed: %s\n", + strerror(err)); + return -err; + } + + *priority = (int) ctxparam.value; + + return 0; +} + +int +drm_intel_gem_context_set_priority(drm_intel_context *ctx, int priority) +{ + drm_intel_bufmgr_gem *bufmgr_gem; + struct drm_i915_gem_context_param ctxparam; + int ret; + + if (ctx == NULL) + return -EINVAL; + + memclear(ctxparam); + + switch (priority) { + case DRM_INTEL_CTX_SET_PRIORITY_EGL_LOW: + priority = -500; + break; + case DRM_INTEL_CTX_SET_PRIORITY_EGL_MEDIUM: + priority = -0; + break; + case DRM_INTEL_CTX_SET_PRIORITY_EGL_HIGH: + priority = 500; + break; + } + + bufmgr_gem = (drm_intel_bufmgr_gem *)ctx->bufmgr; + ctxparam.ctx_id = ctx->ctx_id; + ctxparam.param = I915_CONTEXT_PARAM_PRIORITY; + ctxparam.value = priority; + ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, + &ctxparam); + if (ret != 0) { + int err = errno; + fprintf(stderr, "DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM failed: %s\n", + strerror(err)); + return -err; + } + + return 0; +} + +int drm_intel_get_reset_stats(drm_intel_context *ctx, uint32_t *reset_count, uint32_t *active,