From patchwork Thu Mar 27 18:00:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: oscar.mateo@intel.com X-Patchwork-Id: 3898921 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 6468ABF540 for ; Thu, 27 Mar 2014 17:12:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8D9FD20237 for ; Thu, 27 Mar 2014 17:12:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 94B1A20240 for ; Thu, 27 Mar 2014 17:12:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 309206E9F0; Thu, 27 Mar 2014 10:12:46 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 9F8A76E9F0 for ; Thu, 27 Mar 2014 10:12:45 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 27 Mar 2014 10:07:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,743,1389772800"; d="scan'208";a="501086977" Received: from omateolo-linux2.iwi.intel.com ([172.28.253.148]) by fmsmga001.fm.intel.com with ESMTP; 27 Mar 2014 10:06:26 -0700 From: oscar.mateo@intel.com To: intel-gfx@lists.freedesktop.org Date: Thu, 27 Mar 2014 18:00:05 +0000 Message-Id: <1395943218-7708-37-git-send-email-oscar.mateo@intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1395943218-7708-1-git-send-email-oscar.mateo@intel.com> References: <1395943218-7708-1-git-send-email-oscar.mateo@intel.com> Subject: [Intel-gfx] [PATCH 36/49] drm/i915/bdw: Prepare for a 20-bits globally unique submission ID 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.6 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: Oscar Mateo Consisting on 12 bits with the filepriv ID, 5 bits with the context ID and 3 bits with the ring ID. Note: this changes the ABI (only 4096 file descriptors are now allowed, with 8 contexts per-fd) and will break some IGT tests (those that open a big number of fds). If required, I can try to rewrite this so that only legacy ring contexts are affected (as it stands now, legacy hw contexts limits are also modified). Signed-off-by: Oscar Mateo --- drivers/gpu/drm/i915/i915_drv.h | 5 ++++- drivers/gpu/drm/i915/i915_gem.c | 3 ++- drivers/gpu/drm/i915/i915_gem_context.c | 4 ++-- drivers/gpu/drm/i915/i915_lrc.c | 18 ++++++++++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 2f6e55d..ba3d262 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -588,7 +588,8 @@ struct i915_ctx_hang_stats { }; /* This must match up with the value previously used for execbuf2.rsvd1. */ -#define DEFAULT_CONTEXT_ID 0 +#define DEFAULT_CONTEXT_ID 0 +#define CONTEXT_ID_BITS 5 struct i915_hw_context { struct kref ref; int id; @@ -1262,6 +1263,8 @@ struct intel_pipe_crc { wait_queue_head_t wq; }; +#define MIN_FILEPRIV_ID 1 +#define FILEPRIV_ID_BITS 12 typedef struct drm_i915_private { struct drm_device *dev; struct kmem_cache *slab; diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 07d88847..10bb50f 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -4893,7 +4893,8 @@ int i915_gem_open(struct drm_device *dev, struct drm_file *file) file_priv->dev_priv = dev->dev_private; file_priv->file = file; - ret = idr_alloc(&dev_priv->filepriv_idr, file_priv, 0, 0, GFP_KERNEL); + ret = idr_alloc(&dev_priv->filepriv_idr, file_priv, MIN_FILEPRIV_ID, + (1 << FILEPRIV_ID_BITS) - 1, GFP_KERNEL); if (ret < 0) { kfree(file_priv); return ret; diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index a4e878e..1322e00 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -259,8 +259,8 @@ __create_hw_context(struct drm_device *dev, if (file_priv == NULL) return ctx; - ret = idr_alloc(&file_priv->context_idr, ctx, DEFAULT_CONTEXT_ID, 0, - GFP_KERNEL); + ret = idr_alloc(&file_priv->context_idr, ctx, DEFAULT_CONTEXT_ID, + (1 << CONTEXT_ID_BITS) - 1, GFP_KERNEL); if (ret < 0) goto err_out; diff --git a/drivers/gpu/drm/i915/i915_lrc.c b/drivers/gpu/drm/i915/i915_lrc.c index 9d1e7f3..91e7ea6 100644 --- a/drivers/gpu/drm/i915/i915_lrc.c +++ b/drivers/gpu/drm/i915/i915_lrc.c @@ -77,6 +77,24 @@ #define CTX_R_PWR_CLK_STATE 0x42 #define CTX_GPGPU_CSR_BASE_ADDRESS 0x44 +static inline u32 get_submission_id(struct i915_hw_context *ctx) +{ + struct drm_i915_file_private *file_priv = ctx->file_priv; + u32 submission_id; + + if (file_priv) { + WARN(ctx->ring_id & ~0x7, "Ring ID > 3 bits!\n"); + submission_id = ctx->ring_id; + submission_id |= (ctx->id << 3); + submission_id |= (file_priv->id << (CONTEXT_ID_BITS + 3)); + } else { + submission_id = ctx->ring_id; + submission_id |= (ctx->id << 3); + } + + return submission_id; +} + void gen8_gem_context_free(struct i915_hw_context *ctx) { /* Global default contexts ringbuffers are take care of