From patchwork Fri Feb 3 10:33:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 9553845 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 2BEAB60424 for ; Fri, 3 Feb 2017 10:33:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DABE28501 for ; Fri, 3 Feb 2017 10:33:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1263028515; Fri, 3 Feb 2017 10:33:57 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 5F41B28501 for ; Fri, 3 Feb 2017 10:33:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CE0196EB58; Fri, 3 Feb 2017 10:33:55 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id A7CCA6EB58 for ; Fri, 3 Feb 2017 10:33:54 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id u63so3447969wmu.2 for ; Fri, 03 Feb 2017 02:33:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=pqzVmkwyW+IIcZz0d9y2Pe4ENvtmaLkNkuLlBczIQ7g=; b=q+hcS65Mir6XAIS2P4ZqCAwY2kaWfD5F+8uNYmz4DgTQWLrswM44CYVsgynw7DAlgS HFqtXolv6/ldaqyoZ8tt72k6o6+jTSLb+AJyCiUK2ARla0JNIgr+D2+520Oxt6VF1ZwR 6/XtQ3cjafjDy0QLmiNoif0QWswO8pnYyeP2srPLNFAPIM9mErZC4QC23S16/59hty2E a10gwkXH3hhzxHhScRe1MtzBJLrs2s5ncnSSFfLmszMLqWg57bFTUCCKEkJIHk99owRH VYkTntqU7R1ispr1pdijkIvtvngcEC/VrPxOj8FGjgHUjnxNup7NccA3vTdNuSyA2Bqo EroQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=pqzVmkwyW+IIcZz0d9y2Pe4ENvtmaLkNkuLlBczIQ7g=; b=EAPUXsV/tj5u+nMg/Gingr+1yaJZVX/wLe+tksd7Zmlsg+QPgVqX/JHkHBHV9vFzrb iyAqga6mV2TBVgtPlbM4LNEQ/JIH0pNcH2VtiE6QJj4HfH5U0Hn6s8xD1eoPgDmlM+gC +L/5DlvBDRVlq/v9PKySw7l+SjFMMz0Fmk0Uo/WH934JwBPLcW8Yqv77ylhziL+hGcGB FJMp9Ci/e+MroR8WBHY3AAz/NOg908xQnyxtY/5fMIZVSOn8l8Ip4iSIGJ7iqCaWtOHu +RCnrR059YldC54pRyjJ2VlTP2KLH/MlXijcfBfJc1U36JbydaCeyOsWc6EfjH0vq+sF ov4Q== X-Gm-Message-State: AMke39lGuDRIuLRc1qKBZXjPzruFaZpwX8J+5crNwla14Wk+SXhLDs9KMJ+1cX4WKhkQBQ== X-Received: by 10.28.51.205 with SMTP id z196mr751400wmz.22.1486118032910; Fri, 03 Feb 2017 02:33:52 -0800 (PST) Received: from t460p.intel ([2a02:c7d:9bd6:b000:f37e:1e07:a7d8:46cd]) by smtp.gmail.com with ESMTPSA id v128sm2313196wmv.2.2017.02.03.02.33.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Feb 2017 02:33:52 -0800 (PST) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Fri, 3 Feb 2017 10:33:44 +0000 Message-Id: <1486118024-4146-1-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.7.4 Subject: [Intel-gfx] [PATCH] drm/i915: Remove i915_execbuffer_params 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 From: Tvrtko Ursulin Tidy i915_gem_do_execbuffer by removing the structure which is under no plans to be used any longer. This improves the redability of the code, decreases lines of source and shrinks the binary. Signed-off-by: Tvrtko Ursulin Cc: Chris Wilson Cc: Joonas Lahtinen --- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 114 +++++++++++------------------ 1 file changed, 43 insertions(+), 71 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index a40ade6d1c16..b5f55bf858d3 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -49,17 +49,6 @@ #define BATCH_OFFSET_BIAS (256*1024) -struct i915_execbuffer_params { - struct drm_device *dev; - struct drm_file *file; - struct i915_vma *batch; - u32 dispatch_flags; - u32 args_batch_start_offset; - struct intel_engine_cs *engine; - struct i915_gem_context *ctx; - struct drm_i915_gem_request *request; -}; - struct eb_vmas { struct drm_i915_private *i915; struct list_head vmas; @@ -1408,21 +1397,22 @@ i915_gem_execbuffer_parse(struct intel_engine_cs *engine, } static int -execbuf_submit(struct i915_execbuffer_params *params, - struct drm_i915_gem_execbuffer2 *args, +execbuf_submit(struct drm_i915_gem_request *req, u32 batch_start, + u32 dispatch_flags, struct drm_i915_gem_execbuffer2 *args, struct list_head *vmas) { - struct drm_i915_private *dev_priv = params->request->i915; + struct drm_i915_private *dev_priv = req->i915; + struct intel_engine_cs *engine = req->engine; u64 exec_start, exec_len; int instp_mode; u32 instp_mask; int ret; - ret = i915_gem_execbuffer_move_to_gpu(params->request, vmas); + ret = i915_gem_execbuffer_move_to_gpu(req, vmas); if (ret) return ret; - ret = i915_switch_context(params->request); + ret = i915_switch_context(req); if (ret) return ret; @@ -1432,25 +1422,25 @@ execbuf_submit(struct i915_execbuffer_params *params, case I915_EXEC_CONSTANTS_REL_GENERAL: case I915_EXEC_CONSTANTS_ABSOLUTE: case I915_EXEC_CONSTANTS_REL_SURFACE: - if (instp_mode != 0 && params->engine->id != RCS) { + if (instp_mode != 0 && engine->id != RCS) { DRM_DEBUG("non-0 rel constants mode on non-RCS\n"); return -EINVAL; } if (instp_mode != dev_priv->relative_constants_mode) { - if (INTEL_INFO(dev_priv)->gen < 4) { + if (INTEL_GEN(dev_priv) < 4) { DRM_DEBUG("no rel constants on pre-gen4\n"); return -EINVAL; } - if (INTEL_INFO(dev_priv)->gen > 5 && + if (INTEL_GEN(dev_priv) > 5 && instp_mode == I915_EXEC_CONSTANTS_REL_SURFACE) { DRM_DEBUG("rel surface constants mode invalid on gen5+\n"); return -EINVAL; } /* The HW changed the meaning on this bit on gen6 */ - if (INTEL_INFO(dev_priv)->gen >= 6) + if (INTEL_GEN(dev_priv) >= 6) instp_mask &= ~I915_EXEC_CONSTANTS_REL_SURFACE; } break; @@ -1459,11 +1449,11 @@ execbuf_submit(struct i915_execbuffer_params *params, return -EINVAL; } - if (params->engine->id == RCS && + if (engine->id == RCS && instp_mode != dev_priv->relative_constants_mode) { - struct intel_ring *ring = params->request->ring; + struct intel_ring *ring = req->ring; - ret = intel_ring_begin(params->request, 4); + ret = intel_ring_begin(req, 4); if (ret) return ret; @@ -1477,27 +1467,24 @@ execbuf_submit(struct i915_execbuffer_params *params, } if (args->flags & I915_EXEC_GEN7_SOL_RESET) { - ret = i915_reset_gen7_sol_offsets(params->request); + ret = i915_reset_gen7_sol_offsets(req); if (ret) return ret; } exec_len = args->batch_len; - exec_start = params->batch->node.start + - params->args_batch_start_offset; + exec_start = req->batch->node.start + batch_start; if (exec_len == 0) - exec_len = params->batch->size - params->args_batch_start_offset; + exec_len = req->batch->size - batch_start; - ret = params->engine->emit_bb_start(params->request, - exec_start, exec_len, - params->dispatch_flags); + ret = engine->emit_bb_start(req, exec_start, exec_len, dispatch_flags); if (ret) return ret; - trace_i915_gem_ring_dispatch(params->request, params->dispatch_flags); + trace_i915_gem_ring_dispatch(req, dispatch_flags); - i915_gem_execbuffer_move_to_active(vmas, params->request); + i915_gem_execbuffer_move_to_active(vmas, req); return 0; } @@ -1591,10 +1578,10 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, struct intel_engine_cs *engine; struct i915_gem_context *ctx; struct i915_address_space *vm; - struct i915_execbuffer_params params_master; /* XXX: will be removed later */ - struct i915_execbuffer_params *params = ¶ms_master; + struct drm_i915_gem_request *req; + struct i915_vma *batch; const u32 ctx_id = i915_execbuffer2_get_context_id(*args); - u32 dispatch_flags; + u32 dispatch_flags, batch_start; struct dma_fence *in_fence = NULL; struct sync_file *out_fence = NULL; int out_fence_fd = -1; @@ -1684,8 +1671,6 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, else vm = &ggtt->base; - memset(¶ms_master, 0x00, sizeof(params_master)); - eb = eb_create(dev_priv, args); if (eb == NULL) { i915_gem_context_put(ctx); @@ -1700,7 +1685,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, goto err; /* take note of the batch buffer before we might reorder the lists */ - params->batch = eb_get_batch(eb); + batch = eb_get_batch(eb); /* Move the objects en-masse into the GTT, evicting if necessary. */ need_relocs = (args->flags & I915_EXEC_NO_RELOC) == 0; @@ -1724,24 +1709,24 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, } /* Set the pending read domains for the batch buffer to COMMAND */ - if (params->batch->obj->base.pending_write_domain) { + if (batch->obj->base.pending_write_domain) { DRM_DEBUG("Attempting to use self-modifying batch buffer\n"); ret = -EINVAL; goto err; } - if (args->batch_start_offset > params->batch->size || - args->batch_len > params->batch->size - args->batch_start_offset) { + if (args->batch_start_offset > batch->size || + args->batch_len > batch->size - args->batch_start_offset) { DRM_DEBUG("Attempting to use out-of-bounds batch\n"); ret = -EINVAL; goto err; } - params->args_batch_start_offset = args->batch_start_offset; + batch_start = args->batch_start_offset; if (engine->needs_cmd_parser && args->batch_len) { struct i915_vma *vma; vma = i915_gem_execbuffer_parse(engine, &shadow_exec_entry, - params->batch->obj, + batch->obj, eb, args->batch_start_offset, args->batch_len, @@ -1762,18 +1747,18 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, * command parser has accepted. */ dispatch_flags |= I915_DISPATCH_SECURE; - params->args_batch_start_offset = 0; - params->batch = vma; + batch_start = 0; + batch = vma; } } - params->batch->obj->base.pending_read_domains |= I915_GEM_DOMAIN_COMMAND; + batch->obj->base.pending_read_domains |= I915_GEM_DOMAIN_COMMAND; /* snb/ivb/vlv conflate the "batch in ppgtt" bit with the "non-secure * batch" bit. Hence we need to pin secure batches into the global gtt. * hsw should have this fixed, but bdw mucks it up again. */ if (dispatch_flags & I915_DISPATCH_SECURE) { - struct drm_i915_gem_object *obj = params->batch->obj; + struct drm_i915_gem_object *obj = batch->obj; struct i915_vma *vma; /* @@ -1792,25 +1777,24 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, goto err; } - params->batch = vma; + batch = vma; } /* Allocate a request for this batch buffer nice and early. */ - params->request = i915_gem_request_alloc(engine, ctx); - if (IS_ERR(params->request)) { - ret = PTR_ERR(params->request); + req = i915_gem_request_alloc(engine, ctx); + if (IS_ERR(req)) { + ret = PTR_ERR(req); goto err_batch_unpin; } if (in_fence) { - ret = i915_gem_request_await_dma_fence(params->request, - in_fence); + ret = i915_gem_request_await_dma_fence(req, in_fence); if (ret < 0) goto err_request; } if (out_fence_fd != -1) { - out_fence = sync_file_create(¶ms->request->fence); + out_fence = sync_file_create(&req->fence); if (!out_fence) { ret = -ENOMEM; goto err_request; @@ -1823,27 +1807,15 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, * inactive_list and lose its active reference. Hence we do not need * to explicitly hold another reference here. */ - params->request->batch = params->batch; + req->batch = batch; - ret = i915_gem_request_add_to_client(params->request, file); + ret = i915_gem_request_add_to_client(req, file); if (ret) goto err_request; - /* - * Save assorted stuff away to pass through to *_submission(). - * NB: This data should be 'persistent' and not local as it will - * kept around beyond the duration of the IOCTL once the GPU - * scheduler arrives. - */ - params->dev = dev; - params->file = file; - params->engine = engine; - params->dispatch_flags = dispatch_flags; - params->ctx = ctx; - - ret = execbuf_submit(params, args, &eb->vmas); + ret = execbuf_submit(req, batch_start, dispatch_flags, args, &eb->vmas); err_request: - __i915_add_request(params->request, ret == 0); + __i915_add_request(req, ret == 0); if (out_fence) { if (ret == 0) { fd_install(out_fence_fd, out_fence->file); @@ -1863,7 +1835,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, * active. */ if (dispatch_flags & I915_DISPATCH_SECURE) - i915_vma_unpin(params->batch); + i915_vma_unpin(batch); err: /* the request owns the ref now */ i915_gem_context_put(ctx);