From patchwork Thu Sep 29 07:53:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 9355823 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 47453600C8 for ; Thu, 29 Sep 2016 07:53:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 381362987A for ; Thu, 29 Sep 2016 07:53:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C9482987E; Thu, 29 Sep 2016 07:53:48 +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 3C1C12987A for ; Thu, 29 Sep 2016 07:53:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D495D6E1B3; Thu, 29 Sep 2016 07:53:46 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 133906E1C1 for ; Thu, 29 Sep 2016 07:53:45 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id w84so9362952wmg.0 for ; Thu, 29 Sep 2016 00:53:44 -0700 (PDT) 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:in-reply-to:references; bh=4WxJx8/AEuK3TmkO70Gdd3+MSK18rKxhmxC5xrbCDxw=; b=PctyTy5li62e3PjdP5pMn5KAIpTcAZHBBcHEK9qazp2+yya/1UnzZxOgJQZVP18snI MA39BgLjxyL2pmaPRkXoXIYzg5687RQ5iN0timTeZ20MdPUYH27Ec8UYhYFzlTKu1FV9 AF2HHPa/TPpQhAj9vsyXtMGQjTR9r8nQWpDVD5OnIXSO02MT3LiLIRNM0aKQd++QfoUg llvuqXJD/PZVCaqNVYnA8J4CDdz5slkb91/c+WCBKFdgupxcVPCUJdyHWelir25YSUjy Y1f48YUW2sMkgibmtSM7gVd7dwRjXMLcOrI8YkMdAvCEUp4EEqXGu1HkXwbEQswL/M3f NhaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4WxJx8/AEuK3TmkO70Gdd3+MSK18rKxhmxC5xrbCDxw=; b=AiiunzL/4sH2wipcNndw2zqkrZs5z9vcQsUkhD3RjJkLH0cDs7LQqZvExgqDjEki2r 6es4JsHX385MrI+nEaMerOAEoshSoVdhMd7kPkLLUuJVYrBcLTCJQd3Aezx4p93UW+mN rkizQsjDMeMAdteZ5znHC63XKuQ0S4qCH6peUrJxCXvPjlVlOk9SLkPV4XFsd57960SP dpyC5YdLsDh2fUrDPg/nVNSdXs4gRO7PUHGN9bklNKK5Bd2dvkyH1bBmAkPFh+n1XePp ODPPtjFTa83Iz+tO5f1zwvrXLwC1s2I8S5mPZNdd8TqkZdZ/N9rtFTQkGsfS+CA6/cWl ykHQ== X-Gm-Message-State: AA6/9RkOcVcqIk2CLjj+cNr3a3wBp1gKocWFzMBwy1rEKNlzHzYysrxyZdyBL9ql4atfiA== X-Received: by 10.28.93.14 with SMTP id r14mr1274625wmb.89.1475135623459; Thu, 29 Sep 2016 00:53:43 -0700 (PDT) Received: from localhost.localdomain ([2a02:c7d:9b6d:e300:916a:6cab:ac67:71c2]) by smtp.gmail.com with ESMTPSA id va3sm12634621wjb.18.2016.09.29.00.53.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Sep 2016 00:53:43 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Thu, 29 Sep 2016 08:53:31 +0100 Message-Id: <1475135611-18548-1-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20160928170930.GA28107@nuc-i3427.alporthouse.com> References: <20160928170930.GA28107@nuc-i3427.alporthouse.com> Subject: [Intel-gfx] [PATCH v3] drm/i915: Cleanup i915_gem_request_add_to_client 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 Several things we can clean up in this function: * Request and file passed in cannot be NULL. There is a single caller which makes it impossible so change that condition to a GEM_BUG_ON instead of a WARN with a return code. * Same is true for req->file_priv which is always zeroed before this function is called. * With the above we can remove the error return from the function making it void. * dev_private local variable was unused. * Call site in i915_gem_do_execbuffer can be simplified since there is no error handling any longer. v2: * Move next to the only caller. (Chris Wilson) * Remove useless asserts. (Joonas Lahtinen) v3: * Shorten name, remove last standing assert and fix flushing after failed submit. (Chris Wilson) Signed-off-by: Tvrtko Ursulin Reviewed-by: Joonas Lahtinen (v1) --- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 16 ++++++++++++---- drivers/gpu/drm/i915/i915_gem_request.c | 25 ------------------------- drivers/gpu/drm/i915/i915_gem_request.h | 2 -- 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 33c85227643d..f7b96391ff66 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -1612,6 +1612,17 @@ eb_select_engine(struct drm_i915_private *dev_priv, return engine; } +static void +add_to_client(struct drm_i915_gem_request *req, struct drm_file *file) +{ + struct drm_i915_file_private *file_priv = file->driver_priv; + + spin_lock(&file_priv->mm.lock); + req->file_priv = file_priv; + list_add_tail(&req->client_list, &file_priv->mm.request_list); + spin_unlock(&file_priv->mm.lock); +} + static int i915_gem_do_execbuffer(struct drm_device *dev, void *data, struct drm_file *file, @@ -1824,9 +1835,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, */ params->request->batch = params->batch; - ret = i915_gem_request_add_to_client(params->request, file); - if (ret) - goto err_request; + add_to_client(params->request, file); /* * Save assorted stuff away to pass through to *_submission(). @@ -1841,7 +1850,6 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, params->ctx = ctx; ret = execbuf_submit(params, args, &eb->vmas); -err_request: __i915_add_request(params->request, ret == 0); err_batch_unpin: diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c index 40978bc12ceb..490d3a40271a 100644 --- a/drivers/gpu/drm/i915/i915_gem_request.c +++ b/drivers/gpu/drm/i915/i915_gem_request.c @@ -115,31 +115,6 @@ const struct fence_ops i915_fence_ops = { .timeline_value_str = i915_fence_timeline_value_str, }; -int i915_gem_request_add_to_client(struct drm_i915_gem_request *req, - struct drm_file *file) -{ - struct drm_i915_private *dev_private; - struct drm_i915_file_private *file_priv; - - WARN_ON(!req || !file || req->file_priv); - - if (!req || !file) - return -EINVAL; - - if (req->file_priv) - return -EINVAL; - - dev_private = req->i915; - file_priv = file->driver_priv; - - spin_lock(&file_priv->mm.lock); - req->file_priv = file_priv; - list_add_tail(&req->client_list, &file_priv->mm.request_list); - spin_unlock(&file_priv->mm.lock); - - return 0; -} - static inline void i915_gem_request_remove_from_client(struct drm_i915_gem_request *request) { diff --git a/drivers/gpu/drm/i915/i915_gem_request.h b/drivers/gpu/drm/i915/i915_gem_request.h index 974bd7bcc801..df1a41bbf645 100644 --- a/drivers/gpu/drm/i915/i915_gem_request.h +++ b/drivers/gpu/drm/i915/i915_gem_request.h @@ -155,8 +155,6 @@ static inline bool fence_is_i915(struct fence *fence) struct drm_i915_gem_request * __must_check i915_gem_request_alloc(struct intel_engine_cs *engine, struct i915_gem_context *ctx); -int i915_gem_request_add_to_client(struct drm_i915_gem_request *req, - struct drm_file *file); void i915_gem_request_retire_upto(struct drm_i915_gem_request *req); static inline u32