From patchwork Tue Sep 27 12:07:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 9351783 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 379036077A for ; Tue, 27 Sep 2016 12:07:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28D04291CB for ; Tue, 27 Sep 2016 12:07:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D807291D0; Tue, 27 Sep 2016 12:07:47 +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 DD000291CD for ; Tue, 27 Sep 2016 12:07:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C703D6E679; Tue, 27 Sep 2016 12:07:41 +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 B48276E679 for ; Tue, 27 Sep 2016 12:07:40 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id l132so834473wmf.1 for ; Tue, 27 Sep 2016 05:07:40 -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; bh=3m5za2kvHtx46Xodj8dV3pC0UJvn6ythHQQZRvyjZGk=; b=Sk3Bf+yWHjpnqF8DRN6igWLzCB8BEPQKo9jXxLJKKR3GSFvNVtn/WBiowHqkKqoAPy IZmzRbW4Hw0GdGDDF3OVoO3lW85niQ0bh7hbmSAq5RNOZ9bgjhT2B/A8Z1jDndIQ4Uoy i76DQm7o1IBEDPCS/SkF5Rl/d0oSBWiAJyJQp6fq7if3wPkossBf4HVxxzmEajZFodKB nQ7Vj8bBOr6ifzhHcwFekJn/iq62a39aBHl/lE6m3UNjHLyqI36+L9XESHwNh7IovZm1 PhLAaxxtVRIUZ0YIc8R9PhiCMZINR4Bwaeq4znComDBH0AZJ+GtrMYfqX1HWeT/9r9e+ YNNw== 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; bh=3m5za2kvHtx46Xodj8dV3pC0UJvn6ythHQQZRvyjZGk=; b=Z3NivF2J0+VzUvQmIMnLtLuCl0W9OWdb7ozYwb2k3kKb5O1lY6nokRO3VsIfcYiOCi AHmpTi6Xv0bmiRBetBtk8JhEnz/pdpMgZRdwdln8K7smcj6V2pSOH/0w6wQFXIwLP4m3 2IvmG8hpiV4Y2NXQNsSzKz5Yy9Ua1EniuJJ6/Rl3kbk3Gdh5yFUB95Ku1xxbsw8ET64m vssdF1NmU4Pw0Vmi7tN7rTnBWYdhbqvHQKkw2C4qIe76l2RSWu0+Evbf8llYlWXHCqfd DoggeVT5KV38w2hjSiGpTL8+cgjWTYP2TLYYbZTSSzUvBAi/uPCfNxRhlEtoA4I9Ybty ofGg== X-Gm-Message-State: AA6/9RnlV9EcnnyoQ8zJ55Plyc5pq/W+C6sCNqFCXXHcyjDAmilJ3cyIdLeQ8UdggdLZZg== X-Received: by 10.28.189.197 with SMTP id n188mr2623886wmf.116.1474978059138; Tue, 27 Sep 2016 05:07:39 -0700 (PDT) Received: from e31.Home ([2a02:c7d:9b6d:e300:916a:6cab:ac67:71c2]) by smtp.gmail.com with ESMTPSA id f10sm2422345wje.14.2016.09.27.05.07.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Sep 2016 05:07:38 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Tue, 27 Sep 2016 13:07:13 +0100 Message-Id: <1474978033-4619-1-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.7.4 Subject: [Intel-gfx] [PATCH] 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. Signed-off-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 7 ++----- drivers/gpu/drm/i915/i915_gem_request.c | 16 +++------------- drivers/gpu/drm/i915/i915_gem_request.h | 4 ++-- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 33c85227643d..67f9fbeb29d0 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -1824,9 +1824,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; + i915_gem_request_add_to_client(params->request, file); /* * Save assorted stuff away to pass through to *_submission(). @@ -1841,8 +1839,7 @@ 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); + __i915_add_request(params->request, true); 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..b03f09567da2 100644 --- a/drivers/gpu/drm/i915/i915_gem_request.c +++ b/drivers/gpu/drm/i915/i915_gem_request.c @@ -115,29 +115,19 @@ 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) +void 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); + GEM_BUG_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 diff --git a/drivers/gpu/drm/i915/i915_gem_request.h b/drivers/gpu/drm/i915/i915_gem_request.h index 974bd7bcc801..7fa20f342acf 100644 --- a/drivers/gpu/drm/i915/i915_gem_request.h +++ b/drivers/gpu/drm/i915/i915_gem_request.h @@ -155,8 +155,8 @@ 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_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