From patchwork Wed Sep 28 16:48:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 9354331 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 3E77D60757 for ; Wed, 28 Sep 2016 16:48:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F67829743 for ; Wed, 28 Sep 2016 16:48:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22AF329745; Wed, 28 Sep 2016 16:48:37 +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 A2F3929743 for ; Wed, 28 Sep 2016 16:48:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A1086E7DF; Wed, 28 Sep 2016 16:48:35 +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 08C476E7E0 for ; Wed, 28 Sep 2016 16:48:34 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id l132so6792091wmf.1 for ; Wed, 28 Sep 2016 09:48:33 -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=+L8M8VYQojFaM6rLVnAbB9J8Gp0YfQ2+tCSNruLIlEM=; b=fmnw/Y8m5TXXEihBZX1lFKLtAWdGtNAi2Zq5hgdwjkoEVlHz/1ZcRytN0ZGFtN6F/B h/0BT1KCYJhBbbTNlot1uay7VQecFgVc/W04mGhBLAxd7cY8a4ZqHgaWTMgydV+O2+cQ mysuJWMYBQJr37oDWfC1vuas6+xYDMNxwGDJyeupd4+qHdF9JGxNtatYMv8KA1uveI5W lu1mkn3mio+tOfC5svSTAll47Z3SqeDSyHrRFUoLIl9ye7qYs7U4nl+eTSugxboGrqHq bRjUCOjUzYLIu/CadAiHOlUCAuidEcM2AxUMtMDTtW0UwjoybCg7GAcsBnoXTKkVSP05 fOZQ== 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=+L8M8VYQojFaM6rLVnAbB9J8Gp0YfQ2+tCSNruLIlEM=; b=eA6gQWIv8SYtXgQVkn1ilFAZjqFQ8K2EL1zSU3BlyJBaGSMfdhgBXjQ3mukC2M9DKt T8UkEn9wqUwt0L7UyooKd2qn8rXLbCtjQgFWO3zpHze5v3fNH8yiHUbfmztrBHZbjads wkxt6TS68H2gmmviDOTFoOfSek0Un985dTaDBMWtj4gwmVBNXk9+lFDQvCggQa6gVXXs 3NMGm1CUnvkHV5uautBZGaVgR1MGmUaV4UnXWD7oYcSp0KihQRYGoYP2MnsgmHWM29cu FYuo9x+/rcL9Dy/9eH6yDfZPUtE29z87K/fAW5iiNmrwdIhV+5p09ElXfHYQrEUBM+LN DxvQ== X-Gm-Message-State: AA6/9RntR4VQIsNi3gmBtrzLQS8C0TX1dqbmuHLbDWW6xk38eqL6vYQ7EK1/05GYQMcW0g== X-Received: by 10.194.80.104 with SMTP id q8mr22018283wjx.83.1475081311455; Wed, 28 Sep 2016 09:48:31 -0700 (PDT) Received: from e31.Home ([2a02:c7d:9b6d:e300:916a:6cab:ac67:71c2]) by smtp.gmail.com with ESMTPSA id r2sm23368949wmf.14.2016.09.28.09.48.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Sep 2016 09:48:31 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Wed, 28 Sep 2016 17:48:23 +0100 Message-Id: <1475081303-10821-1-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <0160927121915.GU28107@nuc-i3427.alporthouse.com> References: <0160927121915.GU28107@nuc-i3427.alporthouse.com> Subject: [Intel-gfx] [PATCH v2] 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) Signed-off-by: Tvrtko Ursulin Reviewed-by: Joonas Lahtinen (v1) --- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 20 +++++++++++++++----- drivers/gpu/drm/i915/i915_gem_request.c | 25 ------------------------- drivers/gpu/drm/i915/i915_gem_request.h | 2 -- 3 files changed, 15 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 33c85227643d..20dc7d90cecf 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -1612,6 +1612,19 @@ eb_select_engine(struct drm_i915_private *dev_priv, return engine; } +static void i915_gem_request_add_to_client(struct drm_i915_gem_request *req, + struct drm_file *file) +{ + struct drm_i915_file_private *file_priv = file->driver_priv; + + GEM_BUG_ON(req->file_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 +1837,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 +1852,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..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