From patchwork Wed Aug 7 13:53:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 11085953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 114EA14D5 for ; Fri, 9 Aug 2019 09:19:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0149B28BBC for ; Fri, 9 Aug 2019 09:19:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9DF728C54; Fri, 9 Aug 2019 09:19:27 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable 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 63DC728C3E for ; Fri, 9 Aug 2019 09:19:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7EA136EDDE; Fri, 9 Aug 2019 09:19:22 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by gabe.freedesktop.org (Postfix) with ESMTPS id DB23B6E6EC; Wed, 7 Aug 2019 13:53:15 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id l2so148219wmg.0; Wed, 07 Aug 2019 06:53:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dMaE7C1AgtvhXFU8IBpUtrbV9gh4P12ShfV3iNE/Fvg=; b=kAyNyNN/U1hHC/jWoqQYu4FvqRgGM9BnT/q5KR+vfNv3XTB8CfpG1SV8lL70olZDDq QY82UZH9EqCQ0qZ24pXq+27wZlK0GTguXKsJekExGsQEP4YbqLJBZCSoPz4ybRH44cHi t/IyvcOoBII+uz7Kl269J1rM6WV15H0aFJmzLv7jvDbclLSHAMMCx/BiZKxktLt1xLNl oephyQS/3Um4G/j6TT5oqVnwAIyGCcF+2mSA1XKSdCR0Un5CcjALvaspRNbYM+4NGNUo LymNIjtorfmJvqlsHy3GnI5zLBKMcmISl84N0yJRX3mv3Z0eQCb/my+ydS7sKjKNQ7bI Jjrg== X-Gm-Message-State: APjAAAV3daMyHvAk3v/MdghmEIyT8PFA+++Y8brJVzKeiYbcq+78c0YQ iAcTz9q86tdwe1rnvCtBz/hoEhtW X-Google-Smtp-Source: APXvYqyWTuSwIs/JrISy3bNFKnM2NIF4zxE+zfA8AyptILCB4ydVHCen6CLhk0l93x8tr9P1bXX2fw== X-Received: by 2002:a1c:a1c5:: with SMTP id k188mr115466wme.102.1565185994291; Wed, 07 Aug 2019 06:53:14 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:645a:5b76:280d:27be]) by smtp.gmail.com with ESMTPSA id o11sm33095wmh.37.2019.08.07.06.53.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Aug 2019 06:53:13 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: intel-gfx@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, chris@chris-wilson.co.uk Date: Wed, 7 Aug 2019 15:53:10 +0200 Message-Id: <20190807135312.1730-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190807135312.1730-1-christian.koenig@amd.com> References: <20190807135312.1730-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 09 Aug 2019 09:15:44 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=dMaE7C1AgtvhXFU8IBpUtrbV9gh4P12ShfV3iNE/Fvg=; b=PnPN39mblGcnSxscpAlfBpnT7Dji4Zi3QG6zKrqDLw+jV/OY5wsynbcLmW6CI2oLtm CBRo2Ihr+TQ7y2voiwBS4lzTZPY747ftfQY5RfAUOqrCdMvb2KDCNJFvAPsinbzFWglv xMIeLN4R4evZ5rvEEADfSnwyK07WERQm0iiBzrB6GOuDcq7MDBQvBkR6dxVWU3QhNgT6 t2iuMk13KRW9AsYeRBruPRc+fPVOr+3oCzOo+IbdThlSTz0Iej8rJe246no0ijnTd7sB TJy9TYwbIIH6ib2kAy9YLC5Ebam+pUDiCedZIgU9Dzb7RqOnyrciTRvCX9Yfg+JqT6NG 2ASw== Subject: [Intel-gfx] [PATCH 2/4] drm/i915: use new reservation_object_fences helper X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Instead of open coding the sequence loop use the new helper. Signed-off-by: Christian König --- drivers/gpu/drm/i915/gem/i915_gem_busy.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_busy.c b/drivers/gpu/drm/i915/gem/i915_gem_busy.c index 6ad93a09968c..8473292096cb 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_busy.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_busy.c @@ -83,7 +83,8 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data, struct drm_i915_gem_busy *args = data; struct drm_i915_gem_object *obj; struct reservation_object_list *list; - unsigned int seq; + unsigned int i, shared_count; + struct dma_fence *excl; int err; err = -ENOENT; @@ -109,29 +110,18 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data, * to report the overall busyness. This is what the wait-ioctl does. * */ -retry: - seq = raw_read_seqcount(&obj->base.resv->seq); + reservation_object_fences(obj->base.resv, &excl, &list, &shared_count); /* Translate the exclusive fence to the READ *and* WRITE engine */ - args->busy = - busy_check_writer(rcu_dereference(obj->base.resv->fence_excl)); + args->busy = busy_check_writer(excl); /* Translate shared fences to READ set of engines */ - list = rcu_dereference(obj->base.resv->fence); - if (list) { - unsigned int shared_count = list->shared_count, i; + for (i = 0; i < shared_count; ++i) { + struct dma_fence *fence = rcu_dereference(list->shared[i]); - for (i = 0; i < shared_count; ++i) { - struct dma_fence *fence = - rcu_dereference(list->shared[i]); - - args->busy |= busy_check_reader(fence); - } + args->busy |= busy_check_reader(fence); } - if (args->busy && read_seqcount_retry(&obj->base.resv->seq, seq)) - goto retry; - err = 0; out: rcu_read_unlock();