From patchwork Fri Apr 28 09:11:06 2017 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: 9705049 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CB150602BE for ; Fri, 28 Apr 2017 16:11:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCF1428688 for ; Fri, 28 Apr 2017 16:11:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B10A928691; Fri, 28 Apr 2017 16:11:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 53DE628688 for ; Fri, 28 Apr 2017 16:11:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D328989949; Fri, 28 Apr 2017 16:11:27 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 81DC589949 for ; Fri, 28 Apr 2017 16:11:26 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Apr 2017 09:11:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,388,1488873600"; d="scan'208";a="81864568" Received: from omateolo-linux.fm.intel.com ([10.1.27.118]) by orsmga004.jf.intel.com with ESMTP; 28 Apr 2017 09:11:08 -0700 From: Oscar Mateo To: intel-gfx@lists.freedesktop.org Date: Fri, 28 Apr 2017 09:11:06 +0000 Message-Id: <1493370666-14461-1-git-send-email-oscar.mateo@intel.com> X-Mailer: git-send-email 1.9.1 Cc: Ben Widawsky , Mika Kuoppala Subject: [Intel-gfx] [PATCH] drm/i915: Allow null render state batchbuffers bigger than one page 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-Virus-Scanned: ClamAV using ClamSMTP The new batchbuffer for CNL surpasses the 4096 byte mark. Cc: Mika Kuoppala Cc: Ben Widawsky Signed-off-by: Oscar Mateo --- drivers/gpu/drm/i915/i915_gem_render_state.c | 40 +++++++++++++++------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_render_state.c b/drivers/gpu/drm/i915/i915_gem_render_state.c index 12d7036..07f9bd6 100644 --- a/drivers/gpu/drm/i915/i915_gem_render_state.c +++ b/drivers/gpu/drm/i915/i915_gem_render_state.c @@ -62,12 +62,12 @@ struct intel_render_state { * this is sufficient as the null state generator makes the final batch * with two passes to build command and state separately. At this point * the size of both are known and it compacts them by relocating the state - * right after the commands taking care of alignment so we should sufficient - * space below them for adding new commands. + * right after the commands taking care of alignment so we should have + * sufficient space below them for adding new commands. */ -#define OUT_BATCH(batch, i, val) \ +#define OUT_BATCH(batch, size, i, val) \ do { \ - if ((i) >= PAGE_SIZE / sizeof(u32)) \ + if ((i) >= size / sizeof(u32)) \ goto err; \ (batch)[(i)++] = (val); \ } while(0) @@ -86,7 +86,11 @@ static int render_state_setup(struct intel_render_state *so, if (ret) return ret; - d = kmap_atomic(i915_gem_object_get_dirty_page(obj, 0)); + d = i915_gem_object_pin_map(obj, I915_MAP_WB); + if (IS_ERR(d)) { + ret = PTR_ERR(d); + goto out; + } while (i < rodata->batch_items) { u32 s = rodata->batch[i]; @@ -118,7 +122,7 @@ static int render_state_setup(struct intel_render_state *so, so->batch_size = rodata->batch_items * sizeof(u32); while (i % CACHELINE_DWORDS) - OUT_BATCH(d, i, MI_NOOP); + OUT_BATCH(d, obj->base.size, i, MI_NOOP); so->aux_offset = i * sizeof(u32); @@ -141,15 +145,15 @@ static int render_state_setup(struct intel_render_state *so, */ u32 eu_pool_config = 0x00777000; - OUT_BATCH(d, i, GEN9_MEDIA_POOL_STATE); - OUT_BATCH(d, i, GEN9_MEDIA_POOL_ENABLE); - OUT_BATCH(d, i, eu_pool_config); - OUT_BATCH(d, i, 0); - OUT_BATCH(d, i, 0); - OUT_BATCH(d, i, 0); + OUT_BATCH(d, obj->base.size, i, GEN9_MEDIA_POOL_STATE); + OUT_BATCH(d, obj->base.size, i, GEN9_MEDIA_POOL_ENABLE); + OUT_BATCH(d, obj->base.size, i, eu_pool_config); + OUT_BATCH(d, obj->base.size, i, 0); + OUT_BATCH(d, obj->base.size, i, 0); + OUT_BATCH(d, obj->base.size, i, 0); } - OUT_BATCH(d, i, MI_BATCH_BUFFER_END); + OUT_BATCH(d, obj->base.size, i, MI_BATCH_BUFFER_END); so->aux_size = i * sizeof(u32) - so->aux_offset; so->aux_offset += so->batch_offset; /* @@ -160,7 +164,7 @@ static int render_state_setup(struct intel_render_state *so, if (needs_clflush) drm_clflush_virt_range(d, i * sizeof(u32)); - kunmap_atomic(d); + i915_gem_object_unpin_map(obj); ret = i915_gem_object_set_to_gtt_domain(obj, false); out: @@ -168,7 +172,7 @@ static int render_state_setup(struct intel_render_state *so, return ret; err: - kunmap_atomic(d); + i915_gem_object_unpin_map(obj); ret = -EINVAL; goto out; } @@ -189,14 +193,12 @@ int i915_gem_render_state_init(struct intel_engine_cs *engine) if (!rodata) return 0; - if (rodata->batch_items * 4 > PAGE_SIZE) - return -EINVAL; - so = kmalloc(sizeof(*so), GFP_KERNEL); if (!so) return -ENOMEM; - obj = i915_gem_object_create_internal(engine->i915, PAGE_SIZE); + obj = i915_gem_object_create_internal(engine->i915, + PAGE_ALIGN(rodata->batch_items * 4)); if (IS_ERR(obj)) { ret = PTR_ERR(obj); goto err_free;