From patchwork Thu Sep 23 07:55:44 2021 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: 12512457 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70CAFC433EF for ; Thu, 23 Sep 2021 11:57:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1352C60F41 for ; Thu, 23 Sep 2021 11:57:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1352C60F41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1E3FD6ED12; Thu, 23 Sep 2021 11:57:24 +0000 (UTC) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by gabe.freedesktop.org (Postfix) with ESMTPS id CC2BB6E0F2 for ; Thu, 23 Sep 2021 07:56:11 +0000 (UTC) Received: by mail-wr1-x42e.google.com with SMTP id w17so14442364wrv.10 for ; Thu, 23 Sep 2021 00:56:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=j72UGkuuDcgcNEbU7Ge4Dor/jiN8qEzXwuFx/qj5WO8=; b=PTvbMBwv5n9NMo2j+gYZ0lvAvkioFx9YLnB7stM/dTJtjmV0QQSgNJAsT1W8RzVkxU URGkncS59EgjYk6rlBb/lAYetwH8w0XBG03Y93LgLlt7bVY5GTsZNGG8xwWSEO688mLp 36Ip+x76BL4atYR8AQ4LY80AD11L7hiesbPE3vHYspgeRtlHBdPECd3PAvsUBZhmesmG Gc5KwFqsFIY+4BEP0twj4/3FirvmvRM+OCgOgT23SZefhH7AC1HetaIgYjyimHHnKwDM 8ABazyybiRtJEF3uuXVl1e7Ped1EpMvWfAao6r1VeqTMHMPzKiAdhg0n9vkudbJrOTRx EIHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=j72UGkuuDcgcNEbU7Ge4Dor/jiN8qEzXwuFx/qj5WO8=; b=TG1To7qw991WoKFOeD8xMpA3nGfzsl/Q6LM2/FxqEQJZE/z7mHoE/ZfPvENkI6uA/s +tTNtmAX+VjvEw7Ieqh5ok+5iukCgOSGNpeaBFlK85plfpAshMDTTQA42/A09eI8HN3g z4QpeoNbq9QGkacFSMleioGpEdBex0uhz7Djof1njA/wDZYs1xceshsvUpNLSJ4Q1FG1 Ez2GMLCrHYjsKoE40RGLLBp+oYZOyiAGBgMJUo0maxXh1pclvXzjwA1fpUh4noeYZk49 vtpJjjFardlAygd3X+72Ed0QSRjxw5TrINjq+inwjlqlp1LTxY0HMJ73MDKaLwgYmsNN 1xgQ== X-Gm-Message-State: AOAM531LNu2tC94kU8lz3C6TBMJvXSTuGFnupuNxge61SkgKdU2XzFyk aHwaHE0135Dd/8lPVLAguKT14nlI47w= X-Google-Smtp-Source: ABdhPJxzhqwkXo4c9kvGIwZbT+zgYqETZGM/K4lbj6Tae4lvVt6P/NGgAC+QBReG5ekZt95KSwnHpg== X-Received: by 2002:adf:fc0e:: with SMTP id i14mr3332422wrr.173.1632383770267; Thu, 23 Sep 2021 00:56:10 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:09 -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 Date: Thu, 23 Sep 2021 09:55:44 +0200 Message-Id: <20210923075608.2873-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 01/25] dma-buf: add dma_resv_for_each_fence_unlocked v5 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Abstract the complexity of iterating over all the fences in a dma_resv object. The new loop handles the whole RCU and retry dance and returns only fences where we can be sure we grabbed the right one. v2: fix accessing the shared fences while they might be freed, improve kerneldoc, rename _cursor to _iter, add dma_resv_iter_is_exclusive, add dma_resv_iter_begin/end v3: restructor the code, move rcu_read_lock()/unlock() into the iterator, add dma_resv_iter_is_restarted() v4: fix NULL deref when no explicit fence exists, drop superflous rcu_read_lock()/unlock() calls. v5: fix typos in the documentation Signed-off-by: Christian König --- drivers/dma-buf/dma-resv.c | 95 ++++++++++++++++++++++++++++++++++++++ include/linux/dma-resv.h | 95 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 190 insertions(+) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 84fbe60629e3..fbd00e4e1fb4 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -323,6 +323,101 @@ void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence) } EXPORT_SYMBOL(dma_resv_add_excl_fence); +/** + * dma_resv_iter_restart_unlocked - restart the unlocked iterator + * @cursor: The dma_resv_iter object to restart + * + * Restart the unlocked iteration by initializing the cursor object. + */ +static void dma_resv_iter_restart_unlocked(struct dma_resv_iter *cursor) +{ + cursor->seq = read_seqcount_begin(&cursor->obj->seq); + cursor->index = -1; + if (cursor->all_fences) + cursor->fences = dma_resv_shared_list(cursor->obj); + else + cursor->fences = NULL; + cursor->is_restarted = true; +} + +/** + * dma_resv_iter_walk_unlocked - walk over fences in a dma_resv obj + * @cursor: cursor to record the current position + * + * Return all the fences in the dma_resv object which are not yet signaled. + * The returned fence has an extra local reference so will stay alive. + * If a concurrent modify is detected the whole iteration is started over again. + */ +static void dma_resv_iter_walk_unlocked(struct dma_resv_iter *cursor) +{ + struct dma_resv *obj = cursor->obj; + + do { + /* Drop the reference from the previous round */ + dma_fence_put(cursor->fence); + + if (cursor->index++ == -1) { + cursor->fence = dma_resv_excl_fence(obj); + + } else if (!cursor->fences || + cursor->index >= cursor->fences->shared_count) { + cursor->fence = NULL; + + } else { + struct dma_resv_list *fences = cursor->fences; + unsigned int idx = cursor->index; + + cursor->fence = rcu_dereference(fences->shared[idx]); + } + if (cursor->fence) + cursor->fence = dma_fence_get_rcu(cursor->fence); + } while (cursor->fence && dma_fence_is_signaled(cursor->fence)); +} + +/** + * dma_resv_iter_first_unlocked - first fence in an unlocked dma_resv obj. + * @cursor: the cursor with the current position + * + * Returns the first fence from an unlocked dma_resv obj. + */ +struct dma_fence *dma_resv_iter_first_unlocked(struct dma_resv_iter *cursor) +{ + rcu_read_lock(); + do { + dma_resv_iter_restart_unlocked(cursor); + dma_resv_iter_walk_unlocked(cursor); + } while (read_seqcount_retry(&cursor->obj->seq, cursor->seq)); + rcu_read_unlock(); + + return cursor->fence; +} +EXPORT_SYMBOL(dma_resv_iter_first_unlocked); + +/** + * dma_resv_iter_next_unlocked - next fence in an unlocked dma_resv obj. + * @cursor: the cursor with the current position + * + * Returns the next fence from an unlocked dma_resv obj. + */ +struct dma_fence *dma_resv_iter_next_unlocked(struct dma_resv_iter *cursor) +{ + bool restart; + + rcu_read_lock(); + cursor->is_restarted = false; + restart = read_seqcount_retry(&cursor->obj->seq, cursor->seq); + do { + if (restart) + dma_resv_iter_restart_unlocked(cursor); + dma_resv_iter_walk_unlocked(cursor); + restart = true; + } while (read_seqcount_retry(&cursor->obj->seq, cursor->seq)); + rcu_read_unlock(); + + return cursor->fence; +} +EXPORT_SYMBOL(dma_resv_iter_next_unlocked); + /** * dma_resv_copy_fences - Copy all fences from src to dst. * @dst: the destination reservation object diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h index 9100dd3dc21f..5d7d28cb9008 100644 --- a/include/linux/dma-resv.h +++ b/include/linux/dma-resv.h @@ -149,6 +149,101 @@ struct dma_resv { struct dma_resv_list __rcu *fence; }; +/** + * struct dma_resv_iter - current position into the dma_resv fences + * + * Don't touch this directly in the driver, use the accessor function instead. + */ +struct dma_resv_iter { + /** @obj: The dma_resv object we iterate over */ + struct dma_resv *obj; + + /** @all_fences: If all fences should be returned */ + bool all_fences; + + /** @fence: the currently handled fence */ + struct dma_fence *fence; + + /** @seq: sequence number to check for modifications */ + unsigned int seq; + + /** @index: index into the shared fences */ + unsigned int index; + + /** @fences: the shared fences */ + struct dma_resv_list *fences; + + /** @is_restarted: true if this is the first returned fence */ + bool is_restarted; +}; + +struct dma_fence *dma_resv_iter_first_unlocked(struct dma_resv_iter *cursor); +struct dma_fence *dma_resv_iter_next_unlocked(struct dma_resv_iter *cursor); + +/** + * dma_resv_iter_begin - initialize a dma_resv_iter object + * @cursor: The dma_resv_iter object to initialize + * @obj: The dma_resv object which we want to iterate over + * @all_fences: If all fences should be returned or just the exclusive one + */ +static inline void dma_resv_iter_begin(struct dma_resv_iter *cursor, + struct dma_resv *obj, + bool all_fences) +{ + cursor->obj = obj; + cursor->all_fences = all_fences; + cursor->fence = NULL; +} + +/** + * dma_resv_iter_end - cleanup a dma_resv_iter object + * @cursor: the dma_resv_iter object which should be cleaned up + * + * Make sure that the reference to the fence in the cursor is properly + * dropped. + */ +static inline void dma_resv_iter_end(struct dma_resv_iter *cursor) +{ + dma_fence_put(cursor->fence); +} + +/** + * dma_resv_iter_is_exclusive - test if the current fence is the exclusive one + * @cursor: the cursor of the current position + * + * Returns true if the currently returned fence is the exclusive one. + */ +static inline bool dma_resv_iter_is_exclusive(struct dma_resv_iter *cursor) +{ + return cursor->index == -1; +} + +/** + * dma_resv_iter_is_restarted - test if this is the first fence after a restart + * @cursor: the cursor with the current position + * + * Return true if this is the first fence in an iteration after a restart. + */ +static inline bool dma_resv_iter_is_restarted(struct dma_resv_iter *cursor) +{ + return cursor->is_restarted; +} + +/** + * dma_resv_for_each_fence_unlocked - unlocked fence iterator + * @cursor: a struct dma_resv_iter pointer + * @fence: the current fence + * + * Iterate over the fences in a struct dma_resv object without holding the + * &dma_resv.lock and using RCU instead. The cursor needs to be initialized + * with dma_resv_iter_begin() and cleaned up with dma_resv_iter_end(). Inside + * the iterator a reference to the dma_fence is held and the RCU lock dropped. + * When the dma_resv is modified the iteration starts over again. + */ +#define dma_resv_for_each_fence_unlocked(cursor, fence) \ + for (fence = dma_resv_iter_first_unlocked(cursor); \ + fence; fence = dma_resv_iter_next_unlocked(cursor)) + #define dma_resv_held(obj) lockdep_is_held(&(obj)->lock.base) #define dma_resv_assert_held(obj) lockdep_assert_held(&(obj)->lock.base) From patchwork Thu Sep 23 07:55:45 2021 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: 12512451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1404EC433FE for ; Thu, 23 Sep 2021 11:57:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CDE7460F56 for ; Thu, 23 Sep 2021 11:57:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CDE7460F56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2B8446E0D4; Thu, 23 Sep 2021 11:57:23 +0000 (UTC) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by gabe.freedesktop.org (Postfix) with ESMTPS id AE5716E0F2 for ; Thu, 23 Sep 2021 07:56:12 +0000 (UTC) Received: by mail-wr1-x42e.google.com with SMTP id g16so14587925wrb.3 for ; Thu, 23 Sep 2021 00:56:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=kPCka9T3P34f62D+X6M7ZDJ9o/aXOY9QeOUh7RtpT/U=; b=XTBOX/tz/P+zSwCbiPFvdsPPRW4DxznluwH7OBJhBFd1ATvppOBpf1Jkcwy5S7XZJt t748cLefHZlEepEWdCcCysdh7dOqdFkwjpihyGF0buwdvPV/BrQB/wpePlp0OXs3DbOv PNKxBYgEbBJgZcso9P4AEt2ofWJrmKalHKo/3mat+1s/0EH4ClpwhmIJ6QBovZMNDoEY dXOgzbJB2YzKfl2sT3NpxowCt+iqYG2eDEZ4/YnpIzkzwekzUIdsZk+bA+lljyakfegr Wi+HNfzaYLf0wb1MpgMaM7tqZ3sUJHEHRpZZL/AhJjO2PrcCzilLNMQIjLrpKHKdD+Bz OLoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kPCka9T3P34f62D+X6M7ZDJ9o/aXOY9QeOUh7RtpT/U=; b=5i5gTVLkc2yGg6uFhLTx+7amWQSYNMbV6t66hMCsLp1yjzWOIR1qqp7DThseZj89r/ 5RgCj6BtjAYWh/iwaMskyJKU2xbLILDUeb7q+7t0Q2GAExqrlMfLyFR8uQzQZ2telKuB iXfIpERzzyVCiGjXT++3Z9UZ15kPA66nGuxVKNZ8g5OMnQJomG42HPCbpJVEtxj1wEuv iMAc6QKDNKXAchqnh7P2pElvF4cEvxFUxj1FXc8rEPNKSB3uCcXUnkgDVd7Ae1omu1nj tBsJ0PGuGYRCBJ0nzugKUxhN6PExpoVZtokf+s0KuDLjLR9SQRq986dW9q8VpEsDCm3C x5Cg== X-Gm-Message-State: AOAM530bNjliYFCtd2burFhl+S2b43H7zK2eRhhRc12Rm6rfy3QqVR7H SJNeTZIRTZDPxIc0ESGNe+GrJxjy8QA= X-Google-Smtp-Source: ABdhPJx3Gx2ROd1qV/9jerJfYTgeZ4YDFRnn1miZDaDj+RcCTKDHiipkP5cOEu/yLTDVBfqDtKXxFQ== X-Received: by 2002:adf:f24a:: with SMTP id b10mr3471971wrp.281.1632383771300; Thu, 23 Sep 2021 00:56:11 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:10 -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 Date: Thu, 23 Sep 2021 09:55:45 +0200 Message-Id: <20210923075608.2873-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 02/25] dma-buf: add dma_resv_for_each_fence X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" A simpler version of the iterator to be used when the dma_resv object is locked. Signed-off-by: Christian König --- drivers/dma-buf/dma-resv.c | 46 ++++++++++++++++++++++++++++++++++++++ include/linux/dma-resv.h | 19 ++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index fbd00e4e1fb4..3cfcfa72074b 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -418,6 +418,52 @@ struct dma_fence *dma_resv_iter_next_unlocked(struct dma_resv_iter *cursor) } EXPORT_SYMBOL(dma_resv_iter_next_unlocked); +/** + * dma_resv_iter_first - first fence from a locked dma_resv object + * @cursor: cursor to record the current position + * + * Return all the fences in the dma_resv object while holding the + * &dma_resv.lock. + */ +struct dma_fence *dma_resv_iter_first(struct dma_resv_iter *cursor) +{ + struct dma_fence *fence; + + dma_resv_assert_held(cursor->obj); + + cursor->index = -1; + cursor->fences = dma_resv_shared_list(cursor->obj); + + fence = dma_resv_excl_fence(cursor->obj); + if (!fence) + fence = dma_resv_iter_next(cursor); + + cursor->is_restarted = true; + return fence; +} +EXPORT_SYMBOL_GPL(dma_resv_iter_first); + +/** + * dma_resv_iter_next - next fence from a locked dma_resv object + * @cursor: cursor to record the current position + * + * Return all the fences in the dma_resv object while holding the + * &dma_resv.lock. + */ +struct dma_fence *dma_resv_iter_next(struct dma_resv_iter *cursor) +{ + dma_resv_assert_held(cursor->obj); + + cursor->is_restarted = false; + if (!cursor->all_fences || !cursor->fences || + ++cursor->index >= cursor->fences->shared_count) + return NULL; + + return rcu_dereference_protected(cursor->fences->shared[cursor->index], + dma_resv_held(cursor->obj)); +} +EXPORT_SYMBOL_GPL(dma_resv_iter_next); + /** * dma_resv_copy_fences - Copy all fences from src to dst. * @dst: the destination reservation object diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h index 5d7d28cb9008..d4b4cd43f0f1 100644 --- a/include/linux/dma-resv.h +++ b/include/linux/dma-resv.h @@ -179,6 +179,8 @@ struct dma_resv_iter { struct dma_fence *dma_resv_iter_first_unlocked(struct dma_resv_iter *cursor); struct dma_fence *dma_resv_iter_next_unlocked(struct dma_resv_iter *cursor); +struct dma_fence *dma_resv_iter_first(struct dma_resv_iter *cursor); +struct dma_fence *dma_resv_iter_next(struct dma_resv_iter *cursor); /** * dma_resv_iter_begin - initialize a dma_resv_iter object @@ -244,6 +246,23 @@ static inline bool dma_resv_iter_is_restarted(struct dma_resv_iter *cursor) for (fence = dma_resv_iter_first_unlocked(cursor); \ fence; fence = dma_resv_iter_next_unlocked(cursor)) +/** + * dma_resv_for_each_fence - fence iterator + * @cursor: a struct dma_resv_iter pointer + * @obj: a dma_resv object pointer + * @all_fences: true if all fences should be returned + * @fence: the current fence + * + * Iterate over the fences in a struct dma_resv object while holding the + * &dma_resv.lock. @all_fences controls if the shared fences are returned as + * well. The cursor initialisation is part of the iterator and the fence stays + * valid as long as the lock is held. + */ +#define dma_resv_for_each_fence(cursor, obj, all_fences, fence) \ + for (dma_resv_iter_begin(cursor, obj, all_fences), \ + fence = dma_resv_iter_first(cursor); fence; \ + fence = dma_resv_iter_next(cursor)) + #define dma_resv_held(obj) lockdep_is_held(&(obj)->lock.base) #define dma_resv_assert_held(obj) lockdep_assert_held(&(obj)->lock.base) From patchwork Thu Sep 23 07:55:46 2021 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: 12512473 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A72B7C433F5 for ; Thu, 23 Sep 2021 11:57:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7826960F41 for ; Thu, 23 Sep 2021 11:57:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7826960F41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E5F936ED0F; Thu, 23 Sep 2021 11:57:23 +0000 (UTC) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by gabe.freedesktop.org (Postfix) with ESMTPS id A864C6E0F2 for ; Thu, 23 Sep 2021 07:56:13 +0000 (UTC) Received: by mail-wr1-x436.google.com with SMTP id i23so14639965wrb.2 for ; Thu, 23 Sep 2021 00:56:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=JcouvlOHYgve196mSq2X/8dI59e7EBz8YOo8+Yvafec=; b=ckW8LmPPVhGyx1J6EqWgribZIyZ60VLjcgWmaEByvH8KnuJH8X5ob0+aaYvZWAcd/4 I+wLdzyHQ8jOMUTNr2c++YYhPN7dg/VbgbwkpL3CNb9Hf9ucAEcEjcKNaliNlkLgn9xa t9cPLqXGVFkMxC2DDZ8a86YPpqFdNTch9ZnxjRlfqwN8wQswVwQ6WU89iA+YFcGB/NX9 Cce/ibch1FNHgS9GWfkqWp5cg8ARJa04p/alnmIRKihveW8QCJ5QH5yL8z8rl0cICYkm AJ9/d4B9KyJ1a6bvmlOkFVTJPSQ1MZDCh6AZidHQpxsMKSYDh8oiMlLH/y9WDpKhei8Z VJlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JcouvlOHYgve196mSq2X/8dI59e7EBz8YOo8+Yvafec=; b=TTKdhYmUTF1iimvyw5qWon60ZsrJ2QhMTZvzTBrR6JoWPVtOuRX3YJdYr/PkpFRZGz YH0XzCMY5kPcZ5XzVYvhU2F7B2qUNh4WpfVuqG8L2onHb4WtXgaismgzocxDqq1K/ozc YPUrLV3+sUwdqNBhINswW+UhYhA6mH+CSR+X62ws9O+bMBqmU093umU3po/VfgE66UJR gHPH4fMQ58PRRRe3AZxAWr6d+Vbwbc3XCTcCxAfYqBuYd1dz5OBQt24XTvz16GDHKwIc hgOdKFwhHchtz/4ucgHvB8V3M6a1Qks4I6VoDa1qL4YzoCS2MHMzHrirDdM0mJZah830 jz7g== X-Gm-Message-State: AOAM532cGCimAjnI74WRgfCHToGAssF4WFZNOZINzBfNT4i8sGENzMfy EZRTGDoWbLJSiCUKYMMZw5JBuIWLDCw= X-Google-Smtp-Source: ABdhPJxto9Q1dk6Ih1tzx2ONQAxgg1IIz/vOQ6P4FBX4meFIDzdj3UvvUh8wr0Nz36XdJetENTAtcQ== X-Received: by 2002:a1c:9846:: with SMTP id a67mr2992233wme.148.1632383772159; Thu, 23 Sep 2021 00:56:12 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:11 -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 Date: Thu, 23 Sep 2021 09:55:46 +0200 Message-Id: <20210923075608.2873-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 03/25] dma-buf: use new iterator in dma_resv_copy_fences X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" This makes the function much simpler since the complex retry logic is now handled else where. Signed-off-by: Christian König Reviewed-by: Daniel Vetter --- drivers/dma-buf/dma-resv.c | 84 +++++++++++++++----------------------- 1 file changed, 32 insertions(+), 52 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 3cfcfa72074b..fdaae9bb5d3e 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -473,74 +473,54 @@ EXPORT_SYMBOL_GPL(dma_resv_iter_next); */ int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src) { - struct dma_resv_list *src_list, *dst_list; - struct dma_fence *old, *new; - unsigned int i; + struct dma_resv_iter cursor; + struct dma_resv_list *list; + struct dma_fence *f, *excl; dma_resv_assert_held(dst); - rcu_read_lock(); - src_list = dma_resv_shared_list(src); + list = NULL; + excl = NULL; -retry: - if (src_list) { - unsigned int shared_count = src_list->shared_count; + dma_resv_iter_begin(&cursor, src, true); + dma_resv_for_each_fence_unlocked(&cursor, f) { - rcu_read_unlock(); + if (dma_resv_iter_is_restarted(&cursor)) { + dma_resv_list_free(list); + dma_fence_put(excl); - dst_list = dma_resv_list_alloc(shared_count); - if (!dst_list) - return -ENOMEM; + if (cursor.fences) { + unsigned int cnt = cursor.fences->shared_count; - rcu_read_lock(); - src_list = dma_resv_shared_list(src); - if (!src_list || src_list->shared_count > shared_count) { - kfree(dst_list); - goto retry; - } - - dst_list->shared_count = 0; - for (i = 0; i < src_list->shared_count; ++i) { - struct dma_fence __rcu **dst; - struct dma_fence *fence; + list = dma_resv_list_alloc(cnt); + if (!list) { + dma_resv_iter_end(&cursor); + return -ENOMEM; + } - fence = rcu_dereference(src_list->shared[i]); - if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, - &fence->flags)) - continue; + list->shared_count = 0; - if (!dma_fence_get_rcu(fence)) { - dma_resv_list_free(dst_list); - src_list = dma_resv_shared_list(src); - goto retry; + } else { + list = NULL; } - - if (dma_fence_is_signaled(fence)) { - dma_fence_put(fence); - continue; - } - - dst = &dst_list->shared[dst_list->shared_count++]; - rcu_assign_pointer(*dst, fence); + excl = NULL; } - } else { - dst_list = NULL; - } - new = dma_fence_get_rcu_safe(&src->fence_excl); - rcu_read_unlock(); - - src_list = dma_resv_shared_list(dst); - old = dma_resv_excl_fence(dst); + dma_fence_get(f); + if (dma_resv_iter_is_exclusive(&cursor)) + excl = f; + else + RCU_INIT_POINTER(list->shared[list->shared_count++], f); + } + dma_resv_iter_end(&cursor); write_seqcount_begin(&dst->seq); - /* write_seqcount_begin provides the necessary memory barrier */ - RCU_INIT_POINTER(dst->fence_excl, new); - RCU_INIT_POINTER(dst->fence, dst_list); + excl = rcu_replace_pointer(dst->fence_excl, excl, dma_resv_held(dst)); + list = rcu_replace_pointer(dst->fence, list, dma_resv_held(dst)); write_seqcount_end(&dst->seq); - dma_resv_list_free(src_list); - dma_fence_put(old); + dma_resv_list_free(list); + dma_fence_put(excl); return 0; } From patchwork Thu Sep 23 07:55:47 2021 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: 12512475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE397C433EF for ; Thu, 23 Sep 2021 11:57:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 79BED60F56 for ; Thu, 23 Sep 2021 11:57:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 79BED60F56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E6D006ED1A; Thu, 23 Sep 2021 11:57:24 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 71B246ECF6 for ; Thu, 23 Sep 2021 07:56:14 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id w29so14483116wra.8 for ; Thu, 23 Sep 2021 00:56:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=6B5OIuGtvz8jdHWI8J86g4Kqk/a3jGDdYaqhZl1SdTU=; b=Be/Ps0XFuPwRhTnEjiq77ZMbltsG7CGWfqwGYiDg22svDt9PljDIvKlyg7/J18hkoZ PK2jyYqM63QjgFCzF7PwFpGSA1zFV5xxwAuKwNFLGO/kS7fK1aVkhCA1ywHZvNvmEQs1 210kYr3nqB3VgVwme2iwUHxHkBQUNpOia0i6io6S1IdqLE8JBcHNfBVkOnv0ZtmnoUN3 M4x0fpzHsbftcZckUOUBZaFueWh2tO9wLgUzZDMRHvFLmoe2Uc6Y56VihI4647Gj+8YM OTnw4jWcUgMTkqh3Ecw6k8iXQ13JZmUDZp3Wpa7INlMB4vyT3XY6cVU/PsfGR9qPp7za 8ZBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6B5OIuGtvz8jdHWI8J86g4Kqk/a3jGDdYaqhZl1SdTU=; b=je29Xj864yjDkQLD1UTOhi44VkHDyNKrVK2jyacqRg/MjcmE+5LGioBkfvT5C2qDsq NkogCsCgkcNwHvXZsNR9QEC+x8ozadpewKkfVIJXiqiLTi4Ds2scFHzYuFFa3f+O+d05 XLVuT9QAiOc9ylbk+Z5tin2Q2wTzm5p+rTcyyqhNG0iHpToICygj3ELB3fCm/fytIBem 0O91hBjb/XnCdAFw3e2qoQ+omgEhMhCdCcvuo54N8NtZMWNKfY9F2Vba11Mh+aSRAGp5 zJbnx+mA7jYzQprv2yyp9OwgSxmQvJnsvBf4JMgtB+JglctgMP+E14NYKMJ3vSFokKG3 legw== X-Gm-Message-State: AOAM530ETTriDgqKvrtziWyv9XTv2an3qPZ+6lkdRLxUq+4KvEAYjVxD dnJsE5U9aCywb0gpkVI2Lm+W5Q13Zsw= X-Google-Smtp-Source: ABdhPJxcmb42en46FCXNHXi3YHyPEhwg/3RzjgE+Dhqj0gjga9xHpab44oX8bEV35PUpAaDHFv4muQ== X-Received: by 2002:a5d:4488:: with SMTP id j8mr3518163wrq.260.1632383773025; Thu, 23 Sep 2021 00:56:13 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:12 -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 Date: Thu, 23 Sep 2021 09:55:47 +0200 Message-Id: <20210923075608.2873-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 04/25] dma-buf: use new iterator in dma_resv_get_fences v3 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" This makes the function much simpler since the complex retry logic is now handled elsewhere. v2: use sizeof(void*) instead v3: fix rebase bug Signed-off-by: Christian König Reviewed-by: Daniel Vetter --- drivers/dma-buf/dma-resv.c | 108 ++++++++++++------------------------- 1 file changed, 35 insertions(+), 73 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index fdaae9bb5d3e..b7e7ec270fe6 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -530,99 +530,61 @@ EXPORT_SYMBOL(dma_resv_copy_fences); * dma_resv_get_fences - Get an object's shared and exclusive * fences without update side lock held * @obj: the reservation object - * @pfence_excl: the returned exclusive fence (or NULL) - * @pshared_count: the number of shared fences returned - * @pshared: the array of shared fence ptrs returned (array is krealloc'd to + * @fence_excl: the returned exclusive fence (or NULL) + * @shared_count: the number of shared fences returned + * @shared: the array of shared fence ptrs returned (array is krealloc'd to * the required size, and must be freed by caller) * * Retrieve all fences from the reservation object. If the pointer for the * exclusive fence is not specified the fence is put into the array of the * shared fences as well. Returns either zero or -ENOMEM. */ -int dma_resv_get_fences(struct dma_resv *obj, struct dma_fence **pfence_excl, - unsigned int *pshared_count, - struct dma_fence ***pshared) +int dma_resv_get_fences(struct dma_resv *obj, struct dma_fence **fence_excl, + unsigned int *shared_count, struct dma_fence ***shared) { - struct dma_fence **shared = NULL; - struct dma_fence *fence_excl; - unsigned int shared_count; - int ret = 1; - - do { - struct dma_resv_list *fobj; - unsigned int i, seq; - size_t sz = 0; - - shared_count = i = 0; - - rcu_read_lock(); - seq = read_seqcount_begin(&obj->seq); + struct dma_resv_iter cursor; + struct dma_fence *fence; - fence_excl = dma_resv_excl_fence(obj); - if (fence_excl && !dma_fence_get_rcu(fence_excl)) - goto unlock; + *shared_count = 0; + *shared = NULL; - fobj = dma_resv_shared_list(obj); - if (fobj) - sz += sizeof(*shared) * fobj->shared_max; + if (fence_excl) + *fence_excl = NULL; - if (!pfence_excl && fence_excl) - sz += sizeof(*shared); + dma_resv_iter_begin(&cursor, obj, true); + dma_resv_for_each_fence_unlocked(&cursor, fence) { - if (sz) { - struct dma_fence **nshared; + if (dma_resv_iter_is_restarted(&cursor)) { + unsigned int count; - nshared = krealloc(shared, sz, - GFP_NOWAIT | __GFP_NOWARN); - if (!nshared) { - rcu_read_unlock(); + while (*shared_count) + dma_fence_put((*shared)[--(*shared_count)]); - dma_fence_put(fence_excl); - fence_excl = NULL; + if (fence_excl) + dma_fence_put(*fence_excl); - nshared = krealloc(shared, sz, GFP_KERNEL); - if (nshared) { - shared = nshared; - continue; - } + count = cursor.fences ? cursor.fences->shared_count : 0; + count += fence_excl ? 0 : 1; - ret = -ENOMEM; - break; + /* Eventually re-allocate the array */ + *shared = krealloc_array(*shared, count, + sizeof(void *), + GFP_KERNEL); + if (count && !*shared) { + dma_resv_iter_end(&cursor); + return -ENOMEM; } - shared = nshared; - shared_count = fobj ? fobj->shared_count : 0; - for (i = 0; i < shared_count; ++i) { - shared[i] = rcu_dereference(fobj->shared[i]); - if (!dma_fence_get_rcu(shared[i])) - break; - } - } - - if (i != shared_count || read_seqcount_retry(&obj->seq, seq)) { - while (i--) - dma_fence_put(shared[i]); - dma_fence_put(fence_excl); - goto unlock; } - ret = 0; -unlock: - rcu_read_unlock(); - } while (ret); - - if (pfence_excl) - *pfence_excl = fence_excl; - else if (fence_excl) - shared[shared_count++] = fence_excl; - - if (!shared_count) { - kfree(shared); - shared = NULL; + dma_fence_get(fence); + if (dma_resv_iter_is_exclusive(&cursor) && fence_excl) + *fence_excl = fence; + else + (*shared)[(*shared_count)++] = fence; } + dma_resv_iter_end(&cursor); - *pshared_count = shared_count; - *pshared = shared; - return ret; + return 0; } EXPORT_SYMBOL_GPL(dma_resv_get_fences); From patchwork Thu Sep 23 07:55:48 2021 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: 12512453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7D3CC433EF for ; Thu, 23 Sep 2021 11:57:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8252360F41 for ; Thu, 23 Sep 2021 11:57:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8252360F41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 52B486ED08; Thu, 23 Sep 2021 11:57:23 +0000 (UTC) Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 50D3F6E0F2 for ; Thu, 23 Sep 2021 07:56:15 +0000 (UTC) Received: by mail-wr1-x42d.google.com with SMTP id w17so14442797wrv.10 for ; Thu, 23 Sep 2021 00:56:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BP/8jZAGc2RAWZArfR5fOahh1L+EWPd9n33zf1IoJh0=; b=M2Yy+2g490k0n1XvOJqAKWls577lj67zlvF17ArhLsDBwzMa+Hy5U0RiUiZqZk0hbZ myQNBLMo+5wYcbm0AmBevNEOMhQo/UCPz5bnSwKt0lIOgzOJ4IDZ/zoSLvTYE9WTg1ni jszzhsq3iQYgx4hfrMQz8SBrTGvRWJA2gE0VGvqArmasuPlXJGjmmkQFBQn8R4AWB2Vz Hgl/3+mAZ28wj7tTy28CqyQ/qU9VgLojhHBcAgQq/JF0bCRqoHDete9YixPAOpyo1emG KP1vOImvq5vqdzKgjwbEPymHN9KRb5ItC7x7X2FjChXp4CAuqJrhQQhmCVJxNR37Qa6K lODw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BP/8jZAGc2RAWZArfR5fOahh1L+EWPd9n33zf1IoJh0=; b=xA2BP9KOKfwjSOdMnagtIkIbgy5otKxcw4RR0KAw/eAKjT2rx5mJ8sd1X2wgBUQxY4 mlpcl4wRtq1leoJrBhKNU3edkWjC4AQfx7+sH8Bd47W13HU6E6c0IXKzm6/bdNAw/Odi Fqyj+lc/uQAZogxjnpzpoz7Hxk7GSODZNpEtYeLrn1N7Hw23dtdqTq0gSsXA7A6Cak4H 5VjkrsF15PO5dUoinzmo+zuVfZ5TRGen274Lu2+yMMpD2vqm4aGogi+a6q8s26fjrICw YKk5msm7DaL1cksprn0ERoNY0iFln7dZbLiPTk7frp2zvXenfjimJKT5Yp4xLO9a9//w RHXw== X-Gm-Message-State: AOAM531wzvwQ/hRS7GeStt5LE776oeLGyMLb80/hQxfhdXZpZDIxlc5J DyXfqj1z3dfM3wzZj/WPX7e8xhSxfOI= X-Google-Smtp-Source: ABdhPJyyGk4kNOGcASv7iOePsQWrybqcs2wlt4kQGT0yLyKyImkB41PiVp/x98kHusVK3YvlL7cKVg== X-Received: by 2002:a05:6000:1284:: with SMTP id f4mr3512231wrx.88.1632383773881; Thu, 23 Sep 2021 00:56:13 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56: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 Date: Thu, 23 Sep 2021 09:55:48 +0200 Message-Id: <20210923075608.2873-5-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 05/25] dma-buf: use new iterator in dma_resv_wait_timeout X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" This makes the function much simpler since the complex retry logic is now handled elsewhere. Signed-off-by: Christian König Reviewed-by: Daniel Vetter --- drivers/dma-buf/dma-resv.c | 69 +++++--------------------------------- 1 file changed, 8 insertions(+), 61 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index b7e7ec270fe6..2b86444034d4 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -606,74 +606,21 @@ long dma_resv_wait_timeout(struct dma_resv *obj, bool wait_all, bool intr, unsigned long timeout) { long ret = timeout ? timeout : 1; - unsigned int seq, shared_count; + struct dma_resv_iter cursor; struct dma_fence *fence; - int i; - -retry: - shared_count = 0; - seq = read_seqcount_begin(&obj->seq); - rcu_read_lock(); - i = -1; - - fence = dma_resv_excl_fence(obj); - if (fence && !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) { - if (!dma_fence_get_rcu(fence)) - goto unlock_retry; - - if (dma_fence_is_signaled(fence)) { - dma_fence_put(fence); - fence = NULL; - } - - } else { - fence = NULL; - } - - if (wait_all) { - struct dma_resv_list *fobj = dma_resv_shared_list(obj); - - if (fobj) - shared_count = fobj->shared_count; - - for (i = 0; !fence && i < shared_count; ++i) { - struct dma_fence *lfence; - lfence = rcu_dereference(fobj->shared[i]); - if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, - &lfence->flags)) - continue; - - if (!dma_fence_get_rcu(lfence)) - goto unlock_retry; - - if (dma_fence_is_signaled(lfence)) { - dma_fence_put(lfence); - continue; - } + dma_resv_iter_begin(&cursor, obj, wait_all); + dma_resv_for_each_fence_unlocked(&cursor, fence) { - fence = lfence; - break; + ret = dma_fence_wait_timeout(fence, intr, ret); + if (ret <= 0) { + dma_resv_iter_end(&cursor); + return ret; } } + dma_resv_iter_end(&cursor); - rcu_read_unlock(); - if (fence) { - if (read_seqcount_retry(&obj->seq, seq)) { - dma_fence_put(fence); - goto retry; - } - - ret = dma_fence_wait_timeout(fence, intr, ret); - dma_fence_put(fence); - if (ret > 0 && wait_all && (i + 1 < shared_count)) - goto retry; - } return ret; - -unlock_retry: - rcu_read_unlock(); - goto retry; } EXPORT_SYMBOL_GPL(dma_resv_wait_timeout); From patchwork Thu Sep 23 07:55:49 2021 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: 12512469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FFF4C433F5 for ; Thu, 23 Sep 2021 11:57:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1A0E060F41 for ; Thu, 23 Sep 2021 11:57:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1A0E060F41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3F11C6ED1B; Thu, 23 Sep 2021 11:57:25 +0000 (UTC) Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by gabe.freedesktop.org (Postfix) with ESMTPS id 67E666E0F2 for ; Thu, 23 Sep 2021 07:56:16 +0000 (UTC) Received: by mail-wr1-x435.google.com with SMTP id d6so14430528wrc.11 for ; Thu, 23 Sep 2021 00:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=X8SZ7tNe8IP8r7Mir/lLzEK5PEM5eFrGSfF2xAfw+1U=; b=oK12GkunoO2OY5mmXamQmQ0ryHu4kqxXgruyPLqu8NdqabBqUT5uF4rvRMiQE4Xm5Q 3wqGJmvJd0fUuHq8aQZbDaY4c/16hkYDj2JO+YZNmI4B23MzMsoI6fEFvRdIbkjK3Tqk bMvBtzfUDd9YWZ03iJoAMaQX26BMgeiXwR5k86sKuez4w0U0BNj7Rikfc9vYcxOL4G/5 qo2ig5jbs1TuVQifxp0X0QZs9f2J96pHrvr21ajP8zl5MIs09VgpIDldCNtxR6LLDmTi K5Q3ffu56flQ3IYxhgeCT7gqnK8KfzFiwZvmeOjAkp1QhqvjCkDcDrdSEEs/f4ZgKyn6 AeUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X8SZ7tNe8IP8r7Mir/lLzEK5PEM5eFrGSfF2xAfw+1U=; b=FwOUT5AzgnZ1Jcjx+2AzTJ89QFjDltFmL2XBuiZq3U8ycocmlL4E3QlUdz6cR/M8Wg tRO7N+Azqv7RA6ILaEKzo45kgV2q+s+pqIR1TjQWjVz4wc6ow3HoX/Ozwah3ybaehZmg CsjY4Xr+b5bumaARv6jg7TbvSkmxUrL+REPK36FYuGMxh6z9RPAj2VlX2sqBisQ7aBcB u6d+8GbfBMlmbcaQUbaQu+23WfwUAOMHafX6taP4rmTQuQJ6+tK0Rno42bskYLkZh6QP TtLo49PYkkzH1IJzNt4ugvhLJNi/E6F0KaCh+eRp6pdi0dp112R9bu62NI+Tv4V1QDge +I5w== X-Gm-Message-State: AOAM531qIsuOAiIVp+vHvi8iCdZ9IOIa56+Opw927IzH7KSeA7xtSlRS CxAQ3c5OF7t7eFHoR14ovf79rmtPo+E= X-Google-Smtp-Source: ABdhPJzvdLcA26+ELSw0l/hOtn8JBBhkS7WHSBk9z2Oi1dK4yWuFr9REXeCeKx94A69fUhClcevBPA== X-Received: by 2002:adf:b348:: with SMTP id k8mr3422789wrd.123.1632383774987; Thu, 23 Sep 2021 00:56:14 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:14 -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 Date: Thu, 23 Sep 2021 09:55:49 +0200 Message-Id: <20210923075608.2873-6-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 06/25] dma-buf: use new iterator in dma_resv_test_signaled X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" This makes the function much simpler since the complex retry logic is now handled elsewhere. Signed-off-by: Christian König Reviewed-by: Daniel Vetter --- drivers/dma-buf/dma-resv.c | 57 +++++--------------------------------- 1 file changed, 7 insertions(+), 50 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 2b86444034d4..266ec9e3caef 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -625,22 +625,6 @@ long dma_resv_wait_timeout(struct dma_resv *obj, bool wait_all, bool intr, EXPORT_SYMBOL_GPL(dma_resv_wait_timeout); -static inline int dma_resv_test_signaled_single(struct dma_fence *passed_fence) -{ - struct dma_fence *fence, *lfence = passed_fence; - int ret = 1; - - if (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &lfence->flags)) { - fence = dma_fence_get_rcu(lfence); - if (!fence) - return -1; - - ret = !!dma_fence_is_signaled(fence); - dma_fence_put(fence); - } - return ret; -} - /** * dma_resv_test_signaled - Test if a reservation object's fences have been * signaled. @@ -657,43 +641,16 @@ static inline int dma_resv_test_signaled_single(struct dma_fence *passed_fence) */ bool dma_resv_test_signaled(struct dma_resv *obj, bool test_all) { + struct dma_resv_iter cursor; struct dma_fence *fence; - unsigned int seq; - int ret; - - rcu_read_lock(); -retry: - ret = true; - seq = read_seqcount_begin(&obj->seq); - - if (test_all) { - struct dma_resv_list *fobj = dma_resv_shared_list(obj); - unsigned int i, shared_count; - - shared_count = fobj ? fobj->shared_count : 0; - for (i = 0; i < shared_count; ++i) { - fence = rcu_dereference(fobj->shared[i]); - ret = dma_resv_test_signaled_single(fence); - if (ret < 0) - goto retry; - else if (!ret) - break; - } - } - - fence = dma_resv_excl_fence(obj); - if (ret && fence) { - ret = dma_resv_test_signaled_single(fence); - if (ret < 0) - goto retry; + dma_resv_iter_begin(&cursor, obj, test_all); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + dma_resv_iter_end(&cursor); + return false; } - - if (read_seqcount_retry(&obj->seq, seq)) - goto retry; - - rcu_read_unlock(); - return ret; + dma_resv_iter_end(&cursor); + return true; } EXPORT_SYMBOL_GPL(dma_resv_test_signaled); From patchwork Thu Sep 23 07:55:50 2021 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: 12512483 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28DABC433F5 for ; Thu, 23 Sep 2021 11:57:55 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EE60761107 for ; Thu, 23 Sep 2021 11:57:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EE60761107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 775F26ED42; Thu, 23 Sep 2021 11:57:29 +0000 (UTC) Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by gabe.freedesktop.org (Postfix) with ESMTPS id 322E66ECF8 for ; Thu, 23 Sep 2021 07:56:17 +0000 (UTC) Received: by mail-wr1-x435.google.com with SMTP id t18so14651031wrb.0 for ; Thu, 23 Sep 2021 00:56:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=12q+kmLcqrOLQ+PRaX5+iil+oP7YjLgyfMuSdQvd75Y=; b=HW6VwC943W2AU17gOqldF5xl6ofOKV8AGSeLyP9BNaxAXZjM+7rk6Z9sNPJZInXKHp Tv1NiANRq+r08zHwPo+BM7iGi0uT5LRn4ZvqE26VQgL4hMl7fqv653r4vHf4S/7DRYCV E72+2eiCje8VsALZXSpPsjy4866xmH61ro5ya6YF2CrPFQ+PMJy2iN7ILbJ9GLd/gVX1 kmwzrirPGypWTXcZ/oWnbMllUxK/N9Tn0nm+Rsg35TrOJPUVnH8j4Fbrs3EoTmRqR32Y mouXUKoHk/RKAE7JSVsMxzLeWayqN3bC04s2Ua8ZpMtuzKtWKkMAvojqdqcniMo3/mir nPWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=12q+kmLcqrOLQ+PRaX5+iil+oP7YjLgyfMuSdQvd75Y=; b=GVAo6L7M22UoezjFVbl4JOizGR1mUqcnKe8aBu7d6SP6fbRM0/zlIBsATwNbXqa+6w w9gAUHcDOXb72bOsV8CJ9BFqv+Ma00CquU1JhwjnUwJNDBz9YLqXASiYy2UMofG2pBh+ bnZhFcdTVLF4w/bgGwuhA7EvBh33TewQzvMWa/fH8CTWQPw7P9BwxpHmSpkzD88YWxq0 Qbw+mIsLYnGuizAXVbwHbrRB5D72iiQqduXUpdqStyNmQWOPovLkvXuq1ah+tPtPgZfs VTS5XB/blWXTBJO/vkUDzQvjdyBjCCBj+WsmE/+KoWUC0lGF4R6DoutUhRQz92PNJTcS fDlQ== X-Gm-Message-State: AOAM531SxL0rZb7JexJF2FRMAdv2HiKZpzCzDD+YPx8MZFE7Ql4+Hc2Z 0GmXL1ZPW+aM8XotQ3I6LkvYQ063c1o= X-Google-Smtp-Source: ABdhPJxxl4C0Dwty4B7o/jMMhwqiClAVufLuXA4QEi6Ga1wHJzLdloLVfoPnqtUGism2BdVqYhgz5A== X-Received: by 2002:adf:ef02:: with SMTP id e2mr3282088wro.401.1632383775807; Thu, 23 Sep 2021 00:56:15 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:15 -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 Date: Thu, 23 Sep 2021 09:55:50 +0200 Message-Id: <20210923075608.2873-7-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 07/25] drm/ttm: use the new iterator in ttm_bo_flush_all_fences X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" This is probably a fix since we didn't even grabed a reference to the fences. Signed-off-by: Christian König Reviewed-by: Daniel Vetter --- drivers/gpu/drm/ttm/ttm_bo.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 3b22c0013dbf..301b0b4b082e 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -269,23 +269,15 @@ static int ttm_bo_individualize_resv(struct ttm_buffer_object *bo) static void ttm_bo_flush_all_fences(struct ttm_buffer_object *bo) { struct dma_resv *resv = &bo->base._resv; - struct dma_resv_list *fobj; + struct dma_resv_iter cursor; struct dma_fence *fence; - int i; - - rcu_read_lock(); - fobj = dma_resv_shared_list(resv); - fence = dma_resv_excl_fence(resv); - if (fence && !fence->ops->signaled) - dma_fence_enable_sw_signaling(fence); - - for (i = 0; fobj && i < fobj->shared_count; ++i) { - fence = rcu_dereference(fobj->shared[i]); + dma_resv_iter_begin(&cursor, resv, true); + dma_resv_for_each_fence_unlocked(&cursor, fence) { if (!fence->ops->signaled) dma_fence_enable_sw_signaling(fence); } - rcu_read_unlock(); + dma_resv_iter_end(&cursor); } /** From patchwork Thu Sep 23 07:55:51 2021 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: 12512489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 033A2C433EF for ; Thu, 23 Sep 2021 11:58:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C16F361107 for ; Thu, 23 Sep 2021 11:58:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C16F361107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 02B1B6E0D4; Thu, 23 Sep 2021 11:58:28 +0000 (UTC) Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F3E36ECF6 for ; Thu, 23 Sep 2021 07:56:18 +0000 (UTC) Received: by mail-wr1-x42f.google.com with SMTP id u15so14534880wru.6 for ; Thu, 23 Sep 2021 00:56:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=RSipxlf8Rt1aqHkUOElk7qKJcjfTHCxexIhn6lnwGw0=; b=AaFuLZkw+OCDtTP+0vZWJq+jx2ct6CzKGdW2zI1OXuhmzekSpKEJn6pV6rS5U7ZMqD nLaZyYGDARNPqkLXaiQGccvCuoHcI5JeWRHoirc1OCueJWokXfun43PW7x96Ztwx5Ria +mi4lufzj9Rd6POb/QY7IzcgfOXfTrySM24mVkNp0YrDHSvPIehvmWAtLt8OwdFGHPcW YZUK87m/pbc0MherWaWQh9j7KMDJLC2kdXcdEqCEe/kTLNSRkrc94i1lThCKC9IIDObO K950vZeWcx4uRK59rl3Jil0+EDxMwktsPwPrtlBaCTl7wFVf70AkQ4dhpX8/V9Bzgk0p RW9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RSipxlf8Rt1aqHkUOElk7qKJcjfTHCxexIhn6lnwGw0=; b=xQdlwAjRV+TWaMAjY4ju7aWSvs3G6RxwcHIw59PuA5QfzWAvpkZ00MWsWzeYw9gEaj PWpNl+cOZcUDFbpPSC0FW0rcvLQUKOKCScsjNup8ghW8TWCtKlRPmKP9jF/ELXz066AA ZGwawv5oyZzByIZCO0xPpA07JFWzQ7cikD9LtIfUOQjtCFNRrHT1egK23nZWVl3VPyAf kn+0OKdVJE9/o5l37ooCBPKvpcliLnV46p2T9/L2KYnqo0JX7lu2/bjwyphLKMCgm3Sh daJN+V9FNGlUE+btYkO3U/pTLse6Mi1ugu0BqUSZkI7GuesVeL/NP9T4rjJ/EL8z0zBy 8r4A== X-Gm-Message-State: AOAM531LlFHv+vKcsrkjspAVegxFwk2teQevp2L2dePb9R1WUMM371EY n22URvtm+e9fHT7J+PECWGUObcvD5S4= X-Google-Smtp-Source: ABdhPJwOmsftrmLHpvUL5ek/bFPzij3YfDCLxbAuViNVdvZP6ADQgHjHxqjdqznUtB4NEufBxZGucg== X-Received: by 2002:adf:ee48:: with SMTP id w8mr3370198wro.263.1632383776654; Thu, 23 Sep 2021 00:56:16 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:16 -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 Date: Thu, 23 Sep 2021 09:55:51 +0200 Message-Id: <20210923075608.2873-8-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 08/25] drm/amdgpu: use the new iterator in amdgpu_sync_resv X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Simplifying the code a bit. Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | 44 ++++++++---------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c index 862eb3c1c4c5..f7d8487799b2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c @@ -252,41 +252,25 @@ int amdgpu_sync_resv(struct amdgpu_device *adev, struct amdgpu_sync *sync, struct dma_resv *resv, enum amdgpu_sync_mode mode, void *owner) { - struct dma_resv_list *flist; + struct dma_resv_iter cursor; struct dma_fence *f; - unsigned i; - int r = 0; + int r; if (resv == NULL) return -EINVAL; - /* always sync to the exclusive fence */ - f = dma_resv_excl_fence(resv); - dma_fence_chain_for_each(f, f) { - struct dma_fence_chain *chain = to_dma_fence_chain(f); - - if (amdgpu_sync_test_fence(adev, mode, owner, chain ? - chain->fence : f)) { - r = amdgpu_sync_fence(sync, f); - dma_fence_put(f); - if (r) - return r; - break; - } - } - - flist = dma_resv_shared_list(resv); - if (!flist) - return 0; - - for (i = 0; i < flist->shared_count; ++i) { - f = rcu_dereference_protected(flist->shared[i], - dma_resv_held(resv)); - - if (amdgpu_sync_test_fence(adev, mode, owner, f)) { - r = amdgpu_sync_fence(sync, f); - if (r) - return r; + dma_resv_for_each_fence(&cursor, resv, true, f) { + dma_fence_chain_for_each(f, f) { + struct dma_fence_chain *chain = to_dma_fence_chain(f); + + if (amdgpu_sync_test_fence(adev, mode, owner, chain ? + chain->fence : f)) { + r = amdgpu_sync_fence(sync, f); + dma_fence_put(f); + if (r) + return r; + break; + } } } return 0; From patchwork Thu Sep 23 07:55:52 2021 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: 12512479 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91BDEC433FE for ; Thu, 23 Sep 2021 11:57:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6142560F56 for ; Thu, 23 Sep 2021 11:57:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6142560F56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EB9246ED26; Thu, 23 Sep 2021 11:57:27 +0000 (UTC) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by gabe.freedesktop.org (Postfix) with ESMTPS id E037A6ECF6 for ; Thu, 23 Sep 2021 07:56:18 +0000 (UTC) Received: by mail-wr1-x430.google.com with SMTP id i23so14640617wrb.2 for ; Thu, 23 Sep 2021 00:56:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=w7BNkgXvEij5lrUuBoEgmNvE08Hfx+8QGysrl5h5aK0=; b=pIzmceqEN5QgcgGYcRC08ZEg2vmPgWuooVEIAHnaMrAdOaiD/cRnrtEjW++Ttk45HK Rze8sEPjRLu4i5+VRkt58QST4eMPDdumOrFhdNw74tCbOlR5J1R2W706mNntjGztnciX pvdt0GsWoYCpFLxqT60tJlL/kL08IMaDIh+zAyf2FlYkJMsyA9sgygR31sX+44uiQlCp EyohhyLFPkBfAzD3x3RrkyWfb/i4DcGsx5TpnazqkkAITO77aROwfHSfx0+Sp1y7Tqlr IFUtPk36xKJdXmLunQKowbaabHomHk650oQ+qliVNKAs1fWEZqAz19d4yp0dZ68XT9Lo e8gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w7BNkgXvEij5lrUuBoEgmNvE08Hfx+8QGysrl5h5aK0=; b=qDpSmo1RTxwKg8fuqoqSINw0il8zQ330OU5hMs8EsgAT/HdrDW3WQVkd8hjbS7wZ2C ytqW4IkBfj2usNogKOp6sZRxWgYbqlQ1ZQ+YKp9iD+fQ0gKqTK5A6BAlozyxZsYJguZj cGURrRd8nQvBpG9zKCfKfucNRi900m4H5oILNPg7zG0ahfRMxGHsdIp1l0OTai8oS+43 1AJpDSvBqrAF6ZWifY6LEgUDv6GVlM8Fi7xXtDR3TS8exHcKQSvk91MagHr9PNLvlOCE PMj8JyO15qSm7n11lDtmfv/NfFip5xYgeKhbuhSDzVzY1+fyjiA4JDrdoFGYKNKpN2ru LkjQ== X-Gm-Message-State: AOAM53009WL1vYsnsHnUpvFQUfkQXgKpOgArJn67rczgzOv4J7VgCQpX IcRG2sCmEmAJatopvSlV9Ja2tpO5Yc8= X-Google-Smtp-Source: ABdhPJwGC55gmpHr+2zcJSkpok58moZu856KOjGUvIdd4zK4G1UTAGffKC62T3OvaEr1powCQVvVTA== X-Received: by 2002:adf:e408:: with SMTP id g8mr3515058wrm.138.1632383777402; Thu, 23 Sep 2021 00:56:17 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:17 -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 Date: Thu, 23 Sep 2021 09:55:52 +0200 Message-Id: <20210923075608.2873-9-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 09/25] drm/amdgpu: use new iterator in amdgpu_ttm_bo_eviction_valuable X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Simplifying the code a bit. Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 1129e17e9f09..4511cd15c3a6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1332,10 +1332,9 @@ static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, const struct ttm_place *place) { unsigned long num_pages = bo->resource->num_pages; + struct dma_resv_iter resv_cursor; struct amdgpu_res_cursor cursor; - struct dma_resv_list *flist; struct dma_fence *f; - int i; /* Swapout? */ if (bo->resource->mem_type == TTM_PL_SYSTEM) @@ -1349,14 +1348,9 @@ static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, * If true, then return false as any KFD process needs all its BOs to * be resident to run successfully */ - flist = dma_resv_shared_list(bo->base.resv); - if (flist) { - for (i = 0; i < flist->shared_count; ++i) { - f = rcu_dereference_protected(flist->shared[i], - dma_resv_held(bo->base.resv)); - if (amdkfd_fence_check_mm(f, current->mm)) - return false; - } + dma_resv_for_each_fence(&resv_cursor, bo->base.resv, true, f) { + if (amdkfd_fence_check_mm(f, current->mm)) + return false; } switch (bo->resource->mem_type) { From patchwork Thu Sep 23 07:55:53 2021 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: 12512467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28F69C433FE for ; Thu, 23 Sep 2021 11:57:44 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E92FE60F56 for ; Thu, 23 Sep 2021 11:57:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E92FE60F56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F7E46ED20; Thu, 23 Sep 2021 11:57:25 +0000 (UTC) Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by gabe.freedesktop.org (Postfix) with ESMTPS id BB61C6E0F2 for ; Thu, 23 Sep 2021 07:56:19 +0000 (UTC) Received: by mail-wr1-x42f.google.com with SMTP id q11so14487590wrr.9 for ; Thu, 23 Sep 2021 00:56:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=SQ++zZ5/yZpkHj9Fw3rhcDISIEh5bldO1ALOtoZPTbI=; b=JXVoytsv9/SsGjstM6+NqsOmWF79/3PMOAT5X6oLPm2XzKEvCzNmm9RhCDCoXwk4Hj kA/Rs0MKBxOs1oL0w14Fa24RLoqj/CTvUCbl2EERTSfT8hiSJ2zkyum1uflgYhbbrAkb 7otG6vztVfw4i0HqmWd0v7a5/v7Yna8i9x0cfBoiMnjALnGEmDaYQLQKAlD+PYJuua8k +HltBgLxJtHp/pVOGL13jBkFVuF5+9zgdiSFEEaazRF3VAL1F9LNZobuK5IcaXox0j9h gV1eg9z0Sx2uowKzQ6vQcnSZ/ucdvHyT+Qdhcg0JmCZyfEbL7uY5+K6uS8K6e50ySyC6 gkHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SQ++zZ5/yZpkHj9Fw3rhcDISIEh5bldO1ALOtoZPTbI=; b=tgVer5+KEA8GTQkIWR9ZO3XgVOZ+ogcnQt+a8LcWth/cKAAzYljYRBTsedbgqME9st Bef7fRDYBE3jtQvNe5XxVMAdQ5RA+TvDjdwIxVA+QtqxkDYH9Rc3ujN4jHispIMCtGPZ ecMRhyBqioShvYkL/i75Cxb/PhZ8ljZGCVsVStz3aao2gt2rM6Ex3LEBgmD9YlolbeoS DMF3Y5ej7tjbNpWZfovN9BCGf7bdfDz9VozWPv4i0UXNu9laeNp5+HEZhGHr50W9LrxW 4Mf4sbirlAdClY56k1Tl44oawgaKrvCP6Bxf/BqXf4kCLER59fqeGv8L/uAseH7x+MIb Ge4g== X-Gm-Message-State: AOAM530wAONf8PFDIP7UdD2zPROQM5th4LzPcgvN+FyQIZSn8fB/uG1A uwY4hrGiKQYUkA6mNYGFYCkWRyFemz8= X-Google-Smtp-Source: ABdhPJwbG3HA460PIx5c5/LxNVYXBW0wtSO9jm0hd085/2JWNGw+T2bHDobwGGjtOciL6ZJHVRt4Tw== X-Received: by 2002:a05:600c:19ca:: with SMTP id u10mr2914991wmq.45.1632383778294; Thu, 23 Sep 2021 00:56:18 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:17 -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 Date: Thu, 23 Sep 2021 09:55:53 +0200 Message-Id: <20210923075608.2873-10-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 10/25] drm/amdgpu: use new iterator in amdgpu_vm_prt_fini X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" No need to actually allocate an array of fences here. Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 6b15cad78de9..e42dd79ed6f4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -2090,30 +2090,14 @@ static void amdgpu_vm_free_mapping(struct amdgpu_device *adev, static void amdgpu_vm_prt_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) { struct dma_resv *resv = vm->root.bo->tbo.base.resv; - struct dma_fence *excl, **shared; - unsigned i, shared_count; - int r; + struct dma_resv_iter cursor; + struct dma_fence *fence; - r = dma_resv_get_fences(resv, &excl, &shared_count, &shared); - if (r) { - /* Not enough memory to grab the fence list, as last resort - * block for all the fences to complete. - */ - dma_resv_wait_timeout(resv, true, false, - MAX_SCHEDULE_TIMEOUT); - return; - } - - /* Add a callback for each fence in the reservation object */ - amdgpu_vm_prt_get(adev); - amdgpu_vm_add_prt_cb(adev, excl); - - for (i = 0; i < shared_count; ++i) { + dma_resv_for_each_fence(&cursor, resv, true, fence) { + /* Add a callback for each fence in the reservation object */ amdgpu_vm_prt_get(adev); - amdgpu_vm_add_prt_cb(adev, shared[i]); + amdgpu_vm_add_prt_cb(adev, fence); } - - kfree(shared); } /** From patchwork Thu Sep 23 07:55:54 2021 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: 12512493 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79499C433EF for ; Thu, 23 Sep 2021 11:58:31 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3FA7760F56 for ; Thu, 23 Sep 2021 11:58:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3FA7760F56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4D2ED6ED0B; Thu, 23 Sep 2021 11:58:28 +0000 (UTC) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6FFEF6ECF8 for ; Thu, 23 Sep 2021 07:56:20 +0000 (UTC) Received: by mail-wr1-x436.google.com with SMTP id d21so14423217wra.12 for ; Thu, 23 Sep 2021 00:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Xs3urb+CfK37NrDBLos1427ZQKhaGuo6xOveDYDdwk4=; b=ZwDfpOhbmWhwLMk8IJuyvyPJQPys8ZM/DIvja7+YSw8UFRiMqx8auI8AtQCCP2IX7W Noiu0gSXP1pv6YQM3ijzXSAFP4F2l9WrXFokxpBMNLDWzPu4qQQw7Gb70Iz7pWPS+zMP sq9cFCx7KW3JiijFCQNEqL9yFFoC5aNqhL0rQnEHwZhKEdaHD9A3rZKjedBuw+RmbOoO rlkQnNk7CU7KGdBeKSBmhneo2lVpyoEyiuYKVu9eoVwTT7Cj1zPo8Q0bJ6uhBmrxZQYK JXVE1rE98HYPQ9pqJpMrQd1EMUgdrpgyvkiLxVCFotu0f//rY0865bQrt/fuPezu9xJj +akA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xs3urb+CfK37NrDBLos1427ZQKhaGuo6xOveDYDdwk4=; b=dTfTqM4CRNBLM4q8BK75d23meRureN/LKQ9lpXL5BBPNCfl+Bn567LElIdWjWxLYua LXQGa+utAt1C/p0Kf/Ewr46sHjKFtgi/HAPjKZ33FP2gonsce1dLHOj0fP5A1/vc8cOr Fu0jRfpzAN7Z5IZ+ZyWI6wyV9p/bpnxJTGjST2vTDtQb4iXyqqKklyb14w+oJ7mFIQZg 5GPEUei0Lw+ZuxH7Z4ZgTH6ENY5eEiPkEc2ndAKSfElrAEzzz8lVWWVmedC2FPsn8AXW uFq7frhCZM8ZFja4x0WkRLikBcge5v5JIRqvLaY8HbXSB57nlJJmIJZQBzq0G3HfWrE8 +uYA== X-Gm-Message-State: AOAM531wyFzb2oIVYPb+p4+gWistdIrXODEn8NWhabE4zUvbud84T4ki N0W1W3ZU0J56RFAlTbQVUfL7EDnlDyY= X-Google-Smtp-Source: ABdhPJwRagv4wSh+wbPrYAhKMMEMkBbbGAn2z0ndhVG8dWc3kpkcOselyLfnRt42XprQqGkh1LQs4Q== X-Received: by 2002:a1c:800e:: with SMTP id b14mr14917314wmd.54.1632383778992; Thu, 23 Sep 2021 00:56:18 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:18 -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 Date: Thu, 23 Sep 2021 09:55:54 +0200 Message-Id: <20210923075608.2873-11-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 11/25] drm/msm: use new iterator in msm_gem_describe X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Simplifying the code a bit. Also drop the RCU read side lock since the object is locked anyway. Untested since I can't get the driver to compile on !ARM. Signed-off-by: Christian König --- drivers/gpu/drm/msm/msm_gem.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index 22308a1b66fc..14907622769f 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -880,7 +880,7 @@ void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m, { struct msm_gem_object *msm_obj = to_msm_bo(obj); struct dma_resv *robj = obj->resv; - struct dma_resv_list *fobj; + struct dma_resv_iter cursor; struct dma_fence *fence; struct msm_gem_vma *vma; uint64_t off = drm_vma_node_start(&obj->vma_node); @@ -955,22 +955,13 @@ void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m, seq_puts(m, "\n"); } - rcu_read_lock(); - fobj = dma_resv_shared_list(robj); - if (fobj) { - unsigned int i, shared_count = fobj->shared_count; - - for (i = 0; i < shared_count; i++) { - fence = rcu_dereference(fobj->shared[i]); + dma_resv_for_each_fence(&cursor, robj, true, fence) { + if (dma_resv_iter_is_exclusive(&cursor)) + describe_fence(fence, "Exclusive", m); + else describe_fence(fence, "Shared", m); - } } - fence = dma_resv_excl_fence(robj); - if (fence) - describe_fence(fence, "Exclusive", m); - rcu_read_unlock(); - msm_gem_unlock(obj); } From patchwork Thu Sep 23 07:55:55 2021 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: 12512491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EE80C433FE for ; Thu, 23 Sep 2021 11:58:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3423E60F56 for ; Thu, 23 Sep 2021 11:58:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3423E60F56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 241536ED08; Thu, 23 Sep 2021 11:58:28 +0000 (UTC) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1DC7E6ECF8 for ; Thu, 23 Sep 2021 07:56:21 +0000 (UTC) Received: by mail-wr1-x42b.google.com with SMTP id d21so14423279wra.12 for ; Thu, 23 Sep 2021 00:56:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=IkVWp2cRgm41mlWFdiuPcdEqOEMHJpLCxm3yFN2dD0Q=; b=ZCqzI2iGAiYMZ92MWXWTeKpcqad2DOXICsCA97M6kyoXWTKBzSYBnw6Ybuq3qBz2/m aUFgr/eGu61FCuxACQd1So6I6QMyQPOmvRcW54LZXLnPTEqlDPSHNlOKCaHstJJJKhTc n+n3AKFapt/X2y1vrG4FZqe+XHdvpc2Y29rGWkeLTDNrotPAAUbfisWqFOOpHBO/1Egc oV3rnRd4aB487LRdQLe7LrUMJMpWHsKZdb6a0KSneTI36+wfXGupCPAla2dsLB2wmM+W ll7pmK0W4cRb870lHomW3DjhzKahK6GqOiBIrHjZWsZCar3WsWl7cTzeu5QlGQMaI4Ij r8YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IkVWp2cRgm41mlWFdiuPcdEqOEMHJpLCxm3yFN2dD0Q=; b=z/J4NZIl335EqvffeK02RRJCMpSPoIpCfeFUqOJDUZa8MWxUB/VC4aFPtSChKN1bJG dktW+6oPcK5abuVQyGM7cbXbFCGDgNosj3q7K6jv67hGSiFWChfWnb3kffetUrOsRAHP ByF8wOAkHXPjcq8TMRakCvJe+Sz/Bg4UZgcKJeCZztKW25au+UJYIoc4hBzGzQIGevYy 8w6X5iNGy/ElbUMt/kh3xDLo70vSGezxlhApjzxJMqLKedml2scLE7dgok9cPsB7X3IE M4V6uX5SbnyseoyCJaRZmbyRx4g1+qdrj4cJPKV28gTe2FlFAidf9wKe0gXbEPKX8deD A6Ng== X-Gm-Message-State: AOAM533IVaOf2wqlqYiO7PqDA4972rifeUvWaL3R2cNqLa2+k5dydcEm W3MKkW7nr6GvxQuC+NpAynKNb2bucLg= X-Google-Smtp-Source: ABdhPJwIpSlbune9RS9q/9SQUhAw0PHqkJmoxUyYa84GRfmIl/ZlQKeA8mjLd377n8ZTrSgXNPxe+A== X-Received: by 2002:adf:f24a:: with SMTP id b10mr3472662wrp.281.1632383779757; Thu, 23 Sep 2021 00:56:19 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:19 -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 Date: Thu, 23 Sep 2021 09:55:55 +0200 Message-Id: <20210923075608.2873-12-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 12/25] drm/radeon: use new iterator in radeon_sync_resv X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Simplifying the code a bit. Signed-off-by: Christian König --- drivers/gpu/drm/radeon/radeon_sync.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_sync.c b/drivers/gpu/drm/radeon/radeon_sync.c index 9257b60144c4..b991ba1bcd51 100644 --- a/drivers/gpu/drm/radeon/radeon_sync.c +++ b/drivers/gpu/drm/radeon/radeon_sync.c @@ -91,33 +91,17 @@ int radeon_sync_resv(struct radeon_device *rdev, struct dma_resv *resv, bool shared) { - struct dma_resv_list *flist; - struct dma_fence *f; + struct dma_resv_iter cursor; struct radeon_fence *fence; - unsigned i; + struct dma_fence *f; int r = 0; - /* always sync to the exclusive fence */ - f = dma_resv_excl_fence(resv); - fence = f ? to_radeon_fence(f) : NULL; - if (fence && fence->rdev == rdev) - radeon_sync_fence(sync, fence); - else if (f) - r = dma_fence_wait(f, true); - - flist = dma_resv_shared_list(resv); - if (shared || !flist || r) - return r; - - for (i = 0; i < flist->shared_count; ++i) { - f = rcu_dereference_protected(flist->shared[i], - dma_resv_held(resv)); + dma_resv_for_each_fence(&cursor, resv, shared, f) { fence = to_radeon_fence(f); if (fence && fence->rdev == rdev) radeon_sync_fence(sync, fence); else r = dma_fence_wait(f, true); - if (r) break; } From patchwork Thu Sep 23 07:55:56 2021 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: 12512459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E627DC433F5 for ; Thu, 23 Sep 2021 11:57:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9C73960F56 for ; Thu, 23 Sep 2021 11:57:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9C73960F56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 336816ED15; Thu, 23 Sep 2021 11:57:24 +0000 (UTC) Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by gabe.freedesktop.org (Postfix) with ESMTPS id 09ECB6ECFA for ; Thu, 23 Sep 2021 07:56:22 +0000 (UTC) Received: by mail-wr1-x433.google.com with SMTP id i23so14641055wrb.2 for ; Thu, 23 Sep 2021 00:56:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=d730QTcA12WB0FxkhM0n+vEOwpHIgTa3YH56dqVvnac=; b=E01i4/VhKHLSBzmXJY2cmn2Vap1DfLwnqZXq6NzJg7a1QlmZSFLiiINNFdomdJCbpF LqMNq9wvbPNT7Apnyj23sFjbiV26FJXpl3wEtZkHOtaECZErgYB91YeokGP6zyfNcZGI eeTM1WcQqG8ikWK70aUbFIqcZxzXjWyyJiih7RCeh2/6OW5ExXAI8UsHYXCHvF0aQCim l9rLzEL/3A92g7BROpM7frQEFte3FBgDwyMaWLKd2khDIYTlImr6tkbLlX3aL4LKpGJK HEoWpIGwJ4fKMo4rymjxAodfnyMx2e09MbgGozhbuXCfvBZFQNjSYeXDkuBLloL79iPd tUag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d730QTcA12WB0FxkhM0n+vEOwpHIgTa3YH56dqVvnac=; b=16FtH6llT0MP2lZGy+lH+ytsq/jEq91SPBogLBoEq1eT/EidVdx+aXg7tmNsDcKYxq gqm3wlY91Qj9OK0gOF6ZYv3rUz7YupfsjfcGa6it+1xJUNg8rkbMWLIFNrX+0ZMBADUC 4JcXjmwsUIUs8us6c4+RW7jFaimQDhd4oJLpeeuykUPXBJyaKygFHJtegy/e9fWBOCp9 T0Uff52DPuxjLg676cwhlUGvOb0rlG3lthcXT0k0kjHbOPBxuF6sFGRfEha9hwRy+V5C QuGrc55EjropBJb05rMSW/HwMGCEGamNHoI8gG2Htzqfnkq9mpU/nGErUvuhDt21Vijt Ua7Q== X-Gm-Message-State: AOAM5320t5zgTyvNZbzZtEbDYZbsnbZlHA+zTEslL4LGB/5p5X7h+IWF WunhamieiiFgu1MrsC2xyJ2OR8qZpV4= X-Google-Smtp-Source: ABdhPJxWmqPeteffQAhVwlppNQXEQ142csPYX4dB7Y8TJZ/TougfFwfzCA1y/fzn6UcO/uAs404esQ== X-Received: by 2002:a05:6000:1a52:: with SMTP id t18mr3345181wry.21.1632383780614; Thu, 23 Sep 2021 00:56:20 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:20 -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 Date: Thu, 23 Sep 2021 09:55:56 +0200 Message-Id: <20210923075608.2873-13-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 13/25] drm/scheduler: use new iterator in drm_sched_job_add_implicit_dependencies v2 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Simplifying the code a bit. v2: use dma_resv_for_each_fence Signed-off-by: Christian König Reviewed-by: Daniel Vetter --- drivers/gpu/drm/scheduler/sched_main.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index 042c16b5d54a..5bc5f775abe1 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -699,30 +699,16 @@ int drm_sched_job_add_implicit_dependencies(struct drm_sched_job *job, struct drm_gem_object *obj, bool write) { + struct dma_resv_iter cursor; + struct dma_fence *fence; int ret; - struct dma_fence **fences; - unsigned int i, fence_count; - - if (!write) { - struct dma_fence *fence = dma_resv_get_excl_unlocked(obj->resv); - - return drm_sched_job_add_dependency(job, fence); - } - - ret = dma_resv_get_fences(obj->resv, NULL, &fence_count, &fences); - if (ret || !fence_count) - return ret; - for (i = 0; i < fence_count; i++) { - ret = drm_sched_job_add_dependency(job, fences[i]); + dma_resv_for_each_fence(&cursor, obj->resv, write, fence) { + ret = drm_sched_job_add_dependency(job, fence); if (ret) - break; + return ret; } - - for (; i < fence_count; i++) - dma_fence_put(fences[i]); - kfree(fences); - return ret; + return 0; } EXPORT_SYMBOL(drm_sched_job_add_implicit_dependencies); From patchwork Thu Sep 23 07:55:57 2021 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: 12512455 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B32C4C433F5 for ; Thu, 23 Sep 2021 11:57:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7E29360F56 for ; Thu, 23 Sep 2021 11:57:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7E29360F56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CBB626ED0D; Thu, 23 Sep 2021 11:57:23 +0000 (UTC) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by gabe.freedesktop.org (Postfix) with ESMTPS id D3B676E0EE for ; Thu, 23 Sep 2021 07:56:22 +0000 (UTC) Received: by mail-wr1-x430.google.com with SMTP id t8so14678130wri.1 for ; Thu, 23 Sep 2021 00:56:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9ue7puBcgohS+7D/zNLeUPSF3Sf1Ar8z9127abKsq3w=; b=PL7lb9UvqeQe+UyrZ+u5efAWqbJfk8FAKuX5iRKLx+aph7/fLspjEfpC3ns+14U58w FHOM0g0W41qb4UpWNCcGQBZsAbhUnu5i79T7cIdGFQM9F3G/Ux28gb/WXHAx0xiVfQso zTpOCk8NHUiz82fRD0DUG0zn2sC7ME8pvCOMnRgCyMW8rKOSarzaNgRrqbL3GVXaY4k4 5dEzi5bmGVRcBYKPcg6RLLGGcb0AYDfV2NUNVVy7dHTgvaVZOgs8XROW/gC6Ah91VEXp bpUKHwFdhm0NM3cSk/qCvx+luJiCR0C25ELhrVKIpsHBl+kEOP8+oDqiydnhNgDOwc7n rGUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9ue7puBcgohS+7D/zNLeUPSF3Sf1Ar8z9127abKsq3w=; b=TNYW4tOpo/3DM2CXwqf6Y2GvsZbey8au9AIE/g36QPh8t6jOE7YRvdsk+op6vsu6lW uijpgqmgs7+utXJPNc+mBaLxLObU3waiX6CraTbizE1rZr1+Qfa/6FICdnqKP7PGDgpL y3wu49X1WaBjU0vW3hL7RxRqIzXRIuHx2nXgETWGI/sv1SvIbs/inqSdr6TP3ij/u8Qz MoVHOplME0+YqTzsLC6Vo6OSqHGI4upunN638fOV9Q6Per5bH97kxaKOBxX/tNBlrP4G QDUvAuuA3ez5RwM5Y0wPCFrAwvKW9dweFi98BJRt1khcma2akpvjKPwApiZSixt/w3bU HvjQ== X-Gm-Message-State: AOAM533AtUyX28mLpvPPkuRDMxrZ3XRWSQRubthOMtBoHXVIoKSQnlGU Np1umFY3US7kXdPHMddB31jPAMEqRrI= X-Google-Smtp-Source: ABdhPJwBIRNH0zSG6K1zB4QtaRGm4dgLd74woIU9GvCLLLoJA8ucbd6WjtgSlUiwwgtXU/h4E9S8kA== X-Received: by 2002:a7b:c409:: with SMTP id k9mr14302249wmi.153.1632383781400; Thu, 23 Sep 2021 00:56:21 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:20 -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 Date: Thu, 23 Sep 2021 09:55:57 +0200 Message-Id: <20210923075608.2873-14-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 14/25] drm/i915: use the new iterator in i915_gem_busy_ioctl v2 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" This makes the function much simpler since the complex retry logic is now handled else where. Signed-off-by: Christian König Reviewed-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/gem/i915_gem_busy.c | 35 ++++++++++-------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_busy.c b/drivers/gpu/drm/i915/gem/i915_gem_busy.c index 6234e17259c1..dc72b36dae54 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_busy.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_busy.c @@ -82,8 +82,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 dma_resv_list *list; - unsigned int seq; + struct dma_resv_iter cursor; + struct dma_fence *fence; int err; err = -ENOENT; @@ -109,27 +109,20 @@ 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); - - /* Translate the exclusive fence to the READ *and* WRITE engine */ - args->busy = busy_check_writer(dma_resv_excl_fence(obj->base.resv)); - - /* Translate shared fences to READ set of engines */ - list = dma_resv_shared_list(obj->base.resv); - 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]); - + args->busy = 0; + dma_resv_iter_begin(&cursor, obj->base.resv, true); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + if (dma_resv_iter_is_restarted(&cursor)) + args->busy = 0; + + if (dma_resv_iter_is_exclusive(&cursor)) + /* Translate the exclusive fence to the READ *and* WRITE engine */ + args->busy |= busy_check_writer(fence); + else + /* Translate shared fences to READ set of engines */ args->busy |= busy_check_reader(fence); - } } - - if (args->busy && read_seqcount_retry(&obj->base.resv->seq, seq)) - goto retry; + dma_resv_iter_end(&cursor); err = 0; out: From patchwork Thu Sep 23 07:55:58 2021 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: 12512497 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 263FFC433F5 for ; Thu, 23 Sep 2021 11:58:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E94CB61107 for ; Thu, 23 Sep 2021 11:58:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E94CB61107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 71EAF6ED0D; Thu, 23 Sep 2021 11:58:28 +0000 (UTC) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by gabe.freedesktop.org (Postfix) with ESMTPS id A4E7C6ECF8 for ; Thu, 23 Sep 2021 07:56:23 +0000 (UTC) Received: by mail-wr1-x42a.google.com with SMTP id w29so14484238wra.8 for ; Thu, 23 Sep 2021 00:56:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=s+B96AdxRkADIO5Sz7pGY2LZZPwHDe6rOqsFSHpv8M0=; b=ID7zk2ljNoV/wxX7aKuzEWSHvPd/v+Cr/kHkuLyO+yI4ahaoxvyMetsxjVKCtl5d8Z LEF/UjoR+QOcsaiQeH1GcAt9GgIsnLYgP3YTNBQFwP5gtGYvDT8DOEQxk8B2LJ9BOE1o MnYJEg8xYfwsErZnN6F6k5ZhP19ppsE3h3Ecb5iBbDvzi3ILhmaLdzvMKNUj+IF0UNRA b+g4/oMWikwLDtDc8lCs4qjndx4zhGjGawSbeULPb0pslzIb/1VYPwI9eEGqYkAXCXK+ JTe0wWcD8+Pq8VIUeyBrSRSdvX1w6SrsDPQZW8a3MH7ujzvA/IKG25hRTlpZtqWhM4qz VYow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s+B96AdxRkADIO5Sz7pGY2LZZPwHDe6rOqsFSHpv8M0=; b=bp94fyf0mkzi+s5sauvOdwtmLP5c+WUwAtTt+vVQT5z5NE6BylloPRHh28QBmtp1DP H6gqe1Fk2ZxWDALIogXu73r+bweq8SrvmJKi9/qtqKBbg4JwDLr271/Yr0jBcpxjtS7o sNRxnEQdpNUJq2/Niq3SkPCLXTY6JJTnd3kD1xT04WlF8wR/k7TT/vtG/5uDVnqV4N85 axQhlPUiSMn95t5JHOJKzQv6boQ/8hw/L09qhBB705wqC376Xa5LEwQMxweQ4tF5wAon ZCvWllOydhR9OYz2vH5xc0uZVGccB65nLtRV07jIC4Vv90tzYn7gTYE31Cik2f2CB+Wa /ypQ== X-Gm-Message-State: AOAM5314yr+uZiq7eoEaf9b50BUpcPbLuK606HfCXM5uYRwRgKul3ypj XzLVJuBdgvQ7zINiUE5fbJso53vw5EM= X-Google-Smtp-Source: ABdhPJz2vnJvre8C0kcDobZD+b4c5oOe+DwttGUrPW5XRL2N6HPY7JagTBRotPa4CNe/jTW2iKR9Qg== X-Received: by 2002:a1c:7515:: with SMTP id o21mr2950244wmc.150.1632383782210; Thu, 23 Sep 2021 00:56:22 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:21 -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 Date: Thu, 23 Sep 2021 09:55:58 +0200 Message-Id: <20210923075608.2873-15-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 15/25] drm/i915: use the new iterator in i915_sw_fence_await_reservation v3 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Simplifying the code a bit. v2: use dma_resv_for_each_fence instead, according to Tvrtko the lock is held here anyway. v3: back to using dma_resv_for_each_fence_unlocked. Signed-off-by: Christian König --- drivers/gpu/drm/i915/i915_sw_fence.c | 53 ++++++---------------------- 1 file changed, 11 insertions(+), 42 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_sw_fence.c b/drivers/gpu/drm/i915/i915_sw_fence.c index c589a681da77..7ea0dbf81530 100644 --- a/drivers/gpu/drm/i915/i915_sw_fence.c +++ b/drivers/gpu/drm/i915/i915_sw_fence.c @@ -572,56 +572,25 @@ int i915_sw_fence_await_reservation(struct i915_sw_fence *fence, unsigned long timeout, gfp_t gfp) { - struct dma_fence *excl; + struct dma_resv_iter cursor; + struct dma_fence *f; int ret = 0, pending; debug_fence_assert(fence); might_sleep_if(gfpflags_allow_blocking(gfp)); - if (write) { - struct dma_fence **shared; - unsigned int count, i; - - ret = dma_resv_get_fences(resv, &excl, &count, &shared); - if (ret) - return ret; - - for (i = 0; i < count; i++) { - if (shared[i]->ops == exclude) - continue; - - pending = i915_sw_fence_await_dma_fence(fence, - shared[i], - timeout, - gfp); - if (pending < 0) { - ret = pending; - break; - } - - ret |= pending; - } - - for (i = 0; i < count; i++) - dma_fence_put(shared[i]); - kfree(shared); - } else { - excl = dma_resv_get_excl_unlocked(resv); - } - - if (ret >= 0 && excl && excl->ops != exclude) { - pending = i915_sw_fence_await_dma_fence(fence, - excl, - timeout, + dma_resv_iter_begin(&cursor, resv, write); + dma_resv_for_each_fence_unlocked(&cursor, f) { + pending = i915_sw_fence_await_dma_fence(fence, f, timeout, gfp); - if (pending < 0) + if (pending < 0) { ret = pending; - else - ret |= pending; - } - - dma_fence_put(excl); + break; + } + ret |= pending; + } + dma_resv_iter_end(&cursor); return ret; } From patchwork Thu Sep 23 07:55:59 2021 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: 12512465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFF05C433FE for ; Thu, 23 Sep 2021 11:57:41 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 78BD960F41 for ; Thu, 23 Sep 2021 11:57:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 78BD960F41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2D7DC6ED13; Thu, 23 Sep 2021 11:57:24 +0000 (UTC) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6D74C6ECF6 for ; Thu, 23 Sep 2021 07:56:24 +0000 (UTC) Received: by mail-wr1-x42e.google.com with SMTP id t8so14591405wrq.4 for ; Thu, 23 Sep 2021 00:56:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=y78+lw9uajwG2nya7zXv9lL0eVUeHEAbTx0GIeLnzI0=; b=W0OzX7EiFb1ngl/k3/EYf3XYd5icD2grdh7nSOEWlf4FJkieovgZkcl8rb6esgxfIV TZAgmwe2qMrP4Srmv25K7L5HU5Y+tEzEGvcqaCMWknORIv6g85KLjSH4kuWEfl7OFWTc FRGlqBiykj6WxF3pRsDUwp2TUJ74o9czCZ1NpjJolIh6+p1aDWyhpS4aANFtv/cC5k9z S7l1lXHhJF+KpCYejqVIIMnGtxAnIfd4fCbYcHi7hyoUlgCbqfVDVi7utn0ngPGc9H3S kTaK/6fT1m9N2UjP+wmoVTUDjRYql28acp6yTsaRIg/4WKKua7PL79xT1cJjVd+BXpPs v2jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y78+lw9uajwG2nya7zXv9lL0eVUeHEAbTx0GIeLnzI0=; b=UCXDzg7cp9NRrSgei+c5qZpXFTEsdBD/EAH9P9BC2D655eCCoCFHvvuez24deBTQ9y qAPnxFDydvMu8VcXGy/UezRQOQN8wGZJREsr+DCjRTUU0dvDQohCEGQ5phhSeNu07WZl AWMOhpIvbQ3Md29xElcWueDF9JRBv94i9VqLmkkKj1rFuufG2NFZtUFmprl3OPPtpmLb pg1NYT62H6olHm0yGZ+8f9/Q5+5ojKrO/+UdTkitTtr95i5U7p9Te11vlCzrs1GPChvk fzUkmMP5KpENK2hwJ31IsK2xdDikEBZY8jCtKhbAX+LayKA8zF0Ovm3Ga8JEB9yDgOp3 1H1g== X-Gm-Message-State: AOAM532nH/NLpecjKCQ19dDxf67e7RjA6l3n1hERBrb7I2XsdfMjetQ+ KfmM//lA5oSNzLh4ojU5Y+XPLxX/vIw= X-Google-Smtp-Source: ABdhPJwGn4HNf6NXCbI3r5zn38+YH/qnd22g4A4AT+35hoG+oXw5+1XUtxIo5oK1Qz4LaIh/wxE/8w== X-Received: by 2002:a1c:21c3:: with SMTP id h186mr14543982wmh.18.1632383782962; Thu, 23 Sep 2021 00:56:22 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:22 -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 Date: Thu, 23 Sep 2021 09:55:59 +0200 Message-Id: <20210923075608.2873-16-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 16/25] drm/i915: use the new iterator in i915_request_await_object v2 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Simplifying the code a bit. v2: add missing rcu_read_lock()/rcu_read_unlock() v3: use dma_resv_for_each_fence instead Signed-off-by: Christian König Reviewed-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_request.c | 34 +++++------------------------ 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c index ce446716d092..3839712ebd23 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -1509,38 +1509,14 @@ i915_request_await_object(struct i915_request *to, struct drm_i915_gem_object *obj, bool write) { - struct dma_fence *excl; + struct dma_resv_iter cursor; + struct dma_fence *fence; int ret = 0; - if (write) { - struct dma_fence **shared; - unsigned int count, i; - - ret = dma_resv_get_fences(obj->base.resv, &excl, &count, - &shared); + dma_resv_for_each_fence(&cursor, obj->base.resv, write, fence) { + ret = i915_request_await_dma_fence(to, fence); if (ret) - return ret; - - for (i = 0; i < count; i++) { - ret = i915_request_await_dma_fence(to, shared[i]); - if (ret) - break; - - dma_fence_put(shared[i]); - } - - for (; i < count; i++) - dma_fence_put(shared[i]); - kfree(shared); - } else { - excl = dma_resv_get_excl_unlocked(obj->base.resv); - } - - if (excl) { - if (ret == 0) - ret = i915_request_await_dma_fence(to, excl); - - dma_fence_put(excl); + break; } return ret; From patchwork Thu Sep 23 07:56:00 2021 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: 12512461 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F513C433FE for ; Thu, 23 Sep 2021 11:57:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F1B6B60F41 for ; Thu, 23 Sep 2021 11:57:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F1B6B60F41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 089FC6ED10; Thu, 23 Sep 2021 11:57:24 +0000 (UTC) Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4E0B76ECF9 for ; Thu, 23 Sep 2021 07:56:25 +0000 (UTC) Received: by mail-wr1-x429.google.com with SMTP id w17so14443959wrv.10 for ; Thu, 23 Sep 2021 00:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QNte/ZxHyZbzH1TCe5eQqnVIdZH6R4S8//YNPJMBVTc=; b=WiA2F+x533mH/9Apm7AMgNe283Dy46y23VgWh4349ho1NdrUk4uy3ZAjO8erqCBono gG+rqut/lz+OPQfM89n8PQCfAFtXBE9kQfDtO6MPeSMiXm82d+GcboWM4YOm4sJfQQh4 3SPX6qfcwNtQCSioQePHCTMa0koZzx1Z4ZblgTDVR4jSIobseGUt96LaR/jH3lijbnpR TAQwONf+si2Naxb+GIA6xvxqvFxW9Dzmy2ZRyEFVxHjt3DsLKhwM8YAKyDHDy2cSeCkR 4Lf6XR2uueJk7IeG7KRanpMT+th9ClefTpczQgTg5aPb9eVHXIDy1VGEBErzTrE2YC/a rW+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QNte/ZxHyZbzH1TCe5eQqnVIdZH6R4S8//YNPJMBVTc=; b=HD3+NcH9WxMlvdSD0b3FKm9CvRuthYlU4rHZlbrg06QoBqelWPlUnwrs52fqEZCB3c dLkuwUXVs5vUJM17+NJcFfFoKjmQM4EOVqfahxdB9v76GbaKEmUHl4IfryhIfxYX6n/x PoIYO9EEA3yED8aeAl5N+xLGMb860B2ZVa2lSMeautLdngaeyHgmotmaVuNFUJbV1k06 ggFkG1CA+Wghyi7QOqW51scqb8ZTyeU0hSlyz/ABmbbEgoh4SaM5vpeTdwn1KkNxe/WQ Fr1ZlJ1eMvJE1Uv8moY6V4Y4vib7HBBmLlEt4ut7k4jnrZd6MU9+e2PLZHXGGceeQzJ7 IyXA== X-Gm-Message-State: AOAM530vaOB1JplZrhe8bmm/HqbYNTwlEdTIAHcnRHczRJ2Em1BOBSwr ifIJB3wsv72k1cP26tNqwrijiLJDmhA= X-Google-Smtp-Source: ABdhPJy9oWMP++xQezjLOHQ01kvtJ4mQZ5jK/utFN6tpEJ8KiOJSymJVzqqa7DJTEGfeNoX3iWH9Xw== X-Received: by 2002:a1c:3b09:: with SMTP id i9mr2866099wma.175.1632383783853; Thu, 23 Sep 2021 00:56:23 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:23 -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 Date: Thu, 23 Sep 2021 09:56:00 +0200 Message-Id: <20210923075608.2873-17-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 17/25] drm/i915: use new iterator in i915_gem_object_wait_reservation X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Simplifying the code a bit. Signed-off-by: Christian König --- drivers/gpu/drm/i915/gem/i915_gem_wait.c | 51 +++++------------------- 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_wait.c b/drivers/gpu/drm/i915/gem/i915_gem_wait.c index f909aaa09d9c..a13193db1dba 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_wait.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_wait.c @@ -37,55 +37,22 @@ i915_gem_object_wait_reservation(struct dma_resv *resv, unsigned int flags, long timeout) { - struct dma_fence *excl; - bool prune_fences = false; - - if (flags & I915_WAIT_ALL) { - struct dma_fence **shared; - unsigned int count, i; - int ret; + struct dma_resv_iter cursor; + struct dma_fence *fence; - ret = dma_resv_get_fences(resv, &excl, &count, &shared); - if (ret) - return ret; - - for (i = 0; i < count; i++) { - timeout = i915_gem_object_wait_fence(shared[i], - flags, timeout); - if (timeout < 0) - break; - - dma_fence_put(shared[i]); - } - - for (; i < count; i++) - dma_fence_put(shared[i]); - kfree(shared); - - /* - * If both shared fences and an exclusive fence exist, - * then by construction the shared fences must be later - * than the exclusive fence. If we successfully wait for - * all the shared fences, we know that the exclusive fence - * must all be signaled. If all the shared fences are - * signaled, we can prune the array and recover the - * floating references on the fences/requests. - */ - prune_fences = count && timeout >= 0; - } else { - excl = dma_resv_get_excl_unlocked(resv); + dma_resv_iter_begin(&cursor, resv, flags & I915_WAIT_ALL); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + timeout = i915_gem_object_wait_fence(fence, flags, timeout); + if (timeout < 0) + break; } - - if (excl && timeout >= 0) - timeout = i915_gem_object_wait_fence(excl, flags, timeout); - - dma_fence_put(excl); + dma_resv_iter_end(&cursor); /* * Opportunistically prune the fences iff we know they have *all* been * signaled. */ - if (prune_fences) + if (timeout > 0) dma_resv_prune(resv); return timeout; From patchwork Thu Sep 23 07:56:01 2021 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: 12512463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D95EC433F5 for ; Thu, 23 Sep 2021 11:57:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 381F760F41 for ; Thu, 23 Sep 2021 11:57:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 381F760F41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EC80E6ED1E; Thu, 23 Sep 2021 11:57:25 +0000 (UTC) Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1F4C46ECF6 for ; Thu, 23 Sep 2021 07:56:26 +0000 (UTC) Received: by mail-wr1-x434.google.com with SMTP id w29so14484537wra.8 for ; Thu, 23 Sep 2021 00:56:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=sR69q70gSeg6sG3/QgjbBFqvIqYfytfoA0SgvZr7HAU=; b=GEdsxBT2Mmt21mskNGv6r+x583M/bomSYgUaJkmfxIlaTI1zt46dDvhmxAPmqhArRU YXckLJ0P1gV8c5+BhMOJy+0/UfQQsFULpQfxHOExs9ILCgiF1ZwSBIG4vJd29kB7l1Jp FzyaviCKZL2HfizVF+xtaqtF5S6snHdfSGUArP17Xs7iE/JXlNWztWGRjFw918N+1luI AS+w9pqI7LwQeeOPFabLUaDO+1c8eKGUIhP0OoHQFWuHUg2F1UmiO2tJaxai//2B/EtW 9JrHq6GLO+xT0YILNCw6KirLAlMl3ICinCZnK8l7bmvmRGiqrk4tt1lh3PmmTuXxU5jE 0t9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sR69q70gSeg6sG3/QgjbBFqvIqYfytfoA0SgvZr7HAU=; b=Mcwvan3y/Pmi2qNUVHdZi53XwBnlqWtaii+/StIzslBIcf3QmkS9rq9cCSkyn6ez6N xRvKd6UyO2YWSw4cLZX/bjSbaFCqN4EV1hqapEN4R2f5G0FCF2aETm1oUxamdVdRLf5P PI50NDNoPUHX0AA3QN6rrmSyHV+xNaU/HPGVZC/BLewt8DhqsqRHCjoPYLC4fS/vg4wm K2wX/KZ/UdjY89J8r4AqN+2Hzvjh3TJoEEMVrV/UACvkGYaxcbdAYX1x/vsQrfTNckS+ VJLmoev0LjNhAjbzVFTyLFlYf7mY3uB7WGG+vdjsQmNiCcf6yF7yJaIgBr8uvTaAAmYl yZBQ== X-Gm-Message-State: AOAM532WOdYB67M2v+JjEytbxvyKJggKGrKTnKDZrzz7rSJrSHUAODrU KNe1zRAvOWVP1JKWgvhiMacDyCzluyg= X-Google-Smtp-Source: ABdhPJw+8+g1VPI3LtJr8L/0oofQIajVEq4vbsQHO5KHCeH9C+wkb8oLBw1rdWuqwLIDpXXMm5OP0A== X-Received: by 2002:a1c:ac03:: with SMTP id v3mr14652141wme.13.1632383784714; Thu, 23 Sep 2021 00:56:24 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:24 -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 Date: Thu, 23 Sep 2021 09:56:01 +0200 Message-Id: <20210923075608.2873-18-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 18/25] drm/i915: use new iterator in i915_gem_object_wait_priority X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Simplifying the code a bit. Signed-off-by: Christian König --- drivers/gpu/drm/i915/gem/i915_gem_wait.c | 31 +++++------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_wait.c b/drivers/gpu/drm/i915/gem/i915_gem_wait.c index a13193db1dba..569658c7859c 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_wait.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_wait.c @@ -118,32 +118,13 @@ i915_gem_object_wait_priority(struct drm_i915_gem_object *obj, unsigned int flags, const struct i915_sched_attr *attr) { - struct dma_fence *excl; - - if (flags & I915_WAIT_ALL) { - struct dma_fence **shared; - unsigned int count, i; - int ret; - - ret = dma_resv_get_fences(obj->base.resv, &excl, &count, - &shared); - if (ret) - return ret; - - for (i = 0; i < count; i++) { - i915_gem_fence_wait_priority(shared[i], attr); - dma_fence_put(shared[i]); - } - - kfree(shared); - } else { - excl = dma_resv_get_excl_unlocked(obj->base.resv); - } + struct dma_resv_iter cursor; + struct dma_fence *fence; - if (excl) { - i915_gem_fence_wait_priority(excl, attr); - dma_fence_put(excl); - } + dma_resv_iter_begin(&cursor, obj->base.resv, flags & I915_WAIT_ALL); + dma_resv_for_each_fence_unlocked(&cursor, fence) + i915_gem_fence_wait_priority(fence, attr); + dma_resv_iter_end(&cursor); return 0; } From patchwork Thu Sep 23 07:56:02 2021 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: 12512495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C207FC4332F for ; Thu, 23 Sep 2021 11:58:31 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 957A261107 for ; Thu, 23 Sep 2021 11:58:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 957A261107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 857D46ED12; Thu, 23 Sep 2021 11:58:28 +0000 (UTC) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 10E956ECF8 for ; Thu, 23 Sep 2021 07:56:27 +0000 (UTC) Received: by mail-wr1-x42b.google.com with SMTP id q11so14488527wrr.9 for ; Thu, 23 Sep 2021 00:56:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ETFFVmDbRxb5cxrXOen58gkxhSGsPJL2Y8O/7sOAJto=; b=CWmaT6p+IP5wmKpo0j6GfDewzCHSGfP7rKr6Na4PmWmJeHeZVhnkSxiGMkjzGf08P7 cqjlArXG96JGEZmsPCLLMM4rBblNXCg0pEstUfRuwh980hU+INLdSqISEmO6t4P8VELJ TGPBr6C2uSmHM+1SJKwcXLHiQqbbynxq7rDxkxM19a7uUTlVapiqwXahI3Q0/K83cFkW oVzumxUItaXeFPIvQkC/9IzSpIKW7eGbKRp6bgyz08xD4aWsVFw5ZnOPiIF/nKJg6pF8 sPQMn8pNMp8NZNEWP2r5QTzlAyMxgrGs9z/0Cw77GapcfIjA8NMNd6Vs9QDcmmz952J8 RAcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ETFFVmDbRxb5cxrXOen58gkxhSGsPJL2Y8O/7sOAJto=; b=ei1wPZqaTdY2X6ja7eWZCndJgMchHvP/FHVBMrNDtoTpL5fJTWfaU6BqsFioFdaUK2 R3rREmxzxnme4rVhqul16GWTUjFhboFFCdcIM5X+Q5ebwECzyxMW4h4KN4Gr/8HhIBj0 ibpAheCqUNb6uBbVMU+80TlTWGrZXqLyGXQfZUJYZeRADoBEOOrVj29jOdzBwM1XHb8N K/J7j0uwfn/g3cBDIC5kwrroHCvYoLGmzAb53en2woI6sRWMJ2P1z78CqM9VCF9fI4cp C7qbMABccpkylWu5689T9pv5L89+VI9DwLhEkzSP7mKxE6cq8vAbhEciCtEXspNVNmvV OMLA== X-Gm-Message-State: AOAM530Z8mBAcWr1Egf08629UmeJTDBL7ErG+o0qU2nP/ztx7GhkasJO Vo6MM851Kz3cmfO2xstJax+Xk5lq+rM= X-Google-Smtp-Source: ABdhPJyMplS32YX6/Lk8UVzT0hEEJhan8X6KIgu4LXwrqOXerdrsAGL4sJjwldYkvKQEO0zLeocoKg== X-Received: by 2002:a1c:9dd2:: with SMTP id g201mr14287569wme.46.1632383785566; Thu, 23 Sep 2021 00:56:25 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:25 -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 Date: Thu, 23 Sep 2021 09:56:02 +0200 Message-Id: <20210923075608.2873-19-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 19/25] drm/i915: use new cursor in intel_prepare_plane_fb X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Simplifying the code a bit. Signed-off-by: Christian König --- drivers/gpu/drm/i915/display/intel_display.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index 134a6acbd8fb..d32137a84694 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -11290,6 +11290,7 @@ intel_prepare_plane_fb(struct drm_plane *_plane, i915_gem_object_flush_frontbuffer(obj, ORIGIN_DIRTYFB); if (!new_plane_state->uapi.fence) { /* implicit fencing */ + struct dma_resv_iter cursor; struct dma_fence *fence; ret = i915_sw_fence_await_reservation(&state->commit_ready, @@ -11300,12 +11301,12 @@ intel_prepare_plane_fb(struct drm_plane *_plane, if (ret < 0) goto unpin_fb; - fence = dma_resv_get_excl_unlocked(obj->base.resv); - if (fence) { + dma_resv_iter_begin(&cursor, obj->base.resv, false); + dma_resv_for_each_fence_unlocked(&cursor, fence) { add_rps_boost_after_vblank(new_plane_state->hw.crtc, fence); - dma_fence_put(fence); } + dma_resv_iter_end(&cursor); } else { add_rps_boost_after_vblank(new_plane_state->hw.crtc, new_plane_state->uapi.fence); From patchwork Thu Sep 23 07:56:03 2021 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: 12512485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14C93C433FE for ; Thu, 23 Sep 2021 11:57:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D297C60F41 for ; Thu, 23 Sep 2021 11:57:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D297C60F41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F20C26ED34; Thu, 23 Sep 2021 11:57:28 +0000 (UTC) Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by gabe.freedesktop.org (Postfix) with ESMTPS id DFE486ECF8 for ; Thu, 23 Sep 2021 07:56:27 +0000 (UTC) Received: by mail-wr1-x429.google.com with SMTP id t8so14678712wri.1 for ; Thu, 23 Sep 2021 00:56:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=by8trJVpX1Yx/8GVC1WzD9CSlRZcllVkqP6ongV+oMI=; b=S7PNCNo6vX4W4dcU926D+jmzfX7Nisbs6/D2cnTk5w4wwJdhI4ET5RN8Y5hhdHJ9Lp K+Z4Owl0rYlgG/9VtjQG+lfIv9ods3Eu/68XyRLHhtdBoAdnYvNFNETdwZPu4WXPbfKd a1bLVTBm14WZzZF54UYTWQIH2leJGekIHcVp3uJ6DE9Dn4awJXvyoBZNiNXzj1FMzp74 WLFnqxcgr0MI+e/pgLVGFZIEhqfhAVPX3clmzKfDdK1dgX2Nx6tROG+Yv6gcgTawvsuo 4vfVUqNO+ZNd2QqngRGKQ5dRc1NdzyVUEdDA/OppHQZzXqgFwUip+0fmdayM4lElnhoK tG2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=by8trJVpX1Yx/8GVC1WzD9CSlRZcllVkqP6ongV+oMI=; b=Itmjd7qtonTNmZ5cp3GSIrAB+VcaeM5+If9vn8urf1oBGSU0MEwtJvXexk5YQckgAS DXTah5HKmw4EVK4Q0cDE3rAoxkKZHn9+e6cqY9A/dyMH75xOxJkLpxG4PbY7h/jJ6mNC 1QRL0tAqBoXl8KiRRhsAlKJ+iGean0faCgJTKkZ4J9Avxj4N0FZSVMraZXvHBhM5Nijw P/RAU6Ctf8mE4xPAPYkLlyegLhlxPGSSWgkj8exA0CNMOOtPfWH9xZp3jUFgjTpFTm0O bP50GzmvEg9Hujfk8tXfDh9onQH0gz8jlOD5ROg/0sn8VLS67jDBvWEzQEYc4MSSGsUU kEZw== X-Gm-Message-State: AOAM533Rzum2+GxojtYkF9B6GusyY/O+eQDao6GQbXla5wx59S5w4f7x GjiVVpdDBMd8TR6l4lM1UI0r5+NkOHI= X-Google-Smtp-Source: ABdhPJzwRvn5VjgNay8BFZKKTgdFZ8+S34GryXVtYOJxl4Dm7v84XHE9TB7A/QMZyJtKZFi//K74Cw== X-Received: by 2002:a05:600c:190c:: with SMTP id j12mr14824726wmq.122.1632383786472; Thu, 23 Sep 2021 00:56:26 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:26 -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 Date: Thu, 23 Sep 2021 09:56:03 +0200 Message-Id: <20210923075608.2873-20-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 20/25] drm: use new iterator in drm_gem_fence_array_add_implicit v3 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Simplifying the code a bit. v2: add missing rcu_read_lock()/unlock() v3: switch to locked version Signed-off-by: Christian König --- drivers/gpu/drm/drm_gem.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 09c820045859..4dcdec6487bb 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -1340,31 +1340,15 @@ int drm_gem_fence_array_add_implicit(struct xarray *fence_array, struct drm_gem_object *obj, bool write) { - int ret; - struct dma_fence **fences; - unsigned int i, fence_count; - - if (!write) { - struct dma_fence *fence = - dma_resv_get_excl_unlocked(obj->resv); - - return drm_gem_fence_array_add(fence_array, fence); - } + struct dma_resv_iter cursor; + struct dma_fence *fence; + int ret = 0; - ret = dma_resv_get_fences(obj->resv, NULL, - &fence_count, &fences); - if (ret || !fence_count) - return ret; - - for (i = 0; i < fence_count; i++) { - ret = drm_gem_fence_array_add(fence_array, fences[i]); + dma_resv_for_each_fence(&cursor, obj->resv, write, fence) { + ret = drm_gem_fence_array_add(fence_array, fence); if (ret) break; } - - for (; i < fence_count; i++) - dma_fence_put(fences[i]); - kfree(fences); return ret; } EXPORT_SYMBOL(drm_gem_fence_array_add_implicit); From patchwork Thu Sep 23 07:56:04 2021 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: 12512499 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8AFAC433EF for ; Thu, 23 Sep 2021 11:58:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 999A16115A for ; Thu, 23 Sep 2021 11:58:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 999A16115A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2B4D06ED6B; Thu, 23 Sep 2021 11:58:45 +0000 (UTC) Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by gabe.freedesktop.org (Postfix) with ESMTPS id B7AF96ECF6 for ; Thu, 23 Sep 2021 07:56:28 +0000 (UTC) Received: by mail-wr1-x42d.google.com with SMTP id i23so14641873wrb.2 for ; Thu, 23 Sep 2021 00:56:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=embkrJo3e9xiJFTU9PfC3+rsuixYC3ybu+PUBE5n6do=; b=ME1Yk6vcB4pBagrYM9vgm7be/sbQ3V17g7odwTb8d5NIfOXo/6yqdM0Snz8jbVWlGy lHoZN/GtIwY3uNXLeQM3MZL6BV0m5ED4b6/Ty/98ShF0cS5kOqwCdZ0ekb6nROzVG09F jZI0epowvxrx6Moi4WcF7YXBKYr/cvZujyCklQGb6PICbX6VNBGdsyyUPxfP8CafOOlg rnaWPk7cwBz2XXmJXzZE5VGW5KFoktbvl3Y6BzWNIkeOVoAbbaMVyI9/wFNB8l/pOjre zlie/ezhiCOFB2zZOnv2AP/Gi1ziDFIQOl1Jg+lqFa1rOl2sgizi2tEJGULk/S21ktcM 5CfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=embkrJo3e9xiJFTU9PfC3+rsuixYC3ybu+PUBE5n6do=; b=wRCUn4bDKyxkR+jqjDwBowbhVCyvhJ5HqJg+Z39KVjKlFxtEq1K2ejZklTLgfYFuJa uwiIoHwDtzbVGJ4TydpcrFIgdNC34kKcVG68X2mWQm7ti4c1LNrzeRdwOlkTOgkEdziE pTyNOUL0g6ebsbZQZkpNS4vZuTYu0mAXSrxN0wVlwQHAVGk9ch0OvaGVPm0ItS4or6lT +hQICOERuPSzWOmCZGNd+kLN41GFdDq82WKP4MUjNj2KrKnjKDEDNfw7/v0y7NlXUw8I Lo1sycALzsQ9eZo7eAgrTnU33v/4VZTg3+clUDJsuUwrzLlbbs+XwN00AerDqamaUXwt 9kZg== X-Gm-Message-State: AOAM531THl2Pj/EiYcWo+8XwAcBUUn3sLTZxwwJitcN5ZU+nBFhYyH4b PzVPYlYM4KIWMc/xTe075ncDS98rS7w= X-Google-Smtp-Source: ABdhPJw1t14vDdzv2NH5/hy3UFRfV6A6zWi2pHD/V5OBN2ZcSvCseoTzzbMsD42+hZE9LSSXtVXZjA== X-Received: by 2002:a1c:9846:: with SMTP id a67mr2993215wme.148.1632383787265; Thu, 23 Sep 2021 00:56:27 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:26 -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 Date: Thu, 23 Sep 2021 09:56:04 +0200 Message-Id: <20210923075608.2873-21-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 21/25] drm: use new iterator in drm_gem_plane_helper_prepare_fb X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Makes the handling a bit more complex, but avoids the use of dma_resv_get_excl_unlocked(). Signed-off-by: Christian König --- drivers/gpu/drm/drm_gem_atomic_helper.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_atomic_helper.c b/drivers/gpu/drm/drm_gem_atomic_helper.c index e570398abd78..21ed930042b8 100644 --- a/drivers/gpu/drm/drm_gem_atomic_helper.c +++ b/drivers/gpu/drm/drm_gem_atomic_helper.c @@ -143,6 +143,7 @@ */ int drm_gem_plane_helper_prepare_fb(struct drm_plane *plane, struct drm_plane_state *state) { + struct dma_resv_iter cursor; struct drm_gem_object *obj; struct dma_fence *fence; @@ -150,9 +151,17 @@ int drm_gem_plane_helper_prepare_fb(struct drm_plane *plane, struct drm_plane_st return 0; obj = drm_gem_fb_get_obj(state->fb, 0); - fence = dma_resv_get_excl_unlocked(obj->resv); - drm_atomic_set_fence_for_plane(state, fence); + dma_resv_iter_begin(&cursor, obj->resv, false); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + dma_fence_get(fence); + dma_resv_iter_end(&cursor); + /* TODO: We only use the first write fence here */ + drm_atomic_set_fence_for_plane(state, fence); + return 0; + } + dma_resv_iter_end(&cursor); + drm_atomic_set_fence_for_plane(state, NULL); return 0; } EXPORT_SYMBOL_GPL(drm_gem_plane_helper_prepare_fb); From patchwork Thu Sep 23 07:56:05 2021 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: 12512477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A299AC433F5 for ; Thu, 23 Sep 2021 11:57:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6D8E760F41 for ; Thu, 23 Sep 2021 11:57:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6D8E760F41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 253AA6ED27; Thu, 23 Sep 2021 11:57:28 +0000 (UTC) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by gabe.freedesktop.org (Postfix) with ESMTPS id 903176ECF6 for ; Thu, 23 Sep 2021 07:56:29 +0000 (UTC) Received: by mail-wr1-x431.google.com with SMTP id u18so14558968wrg.5 for ; Thu, 23 Sep 2021 00:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=/+r4v7UIazK0HaIgNf9t5Xden24q10DFKnoad4rknzc=; b=Bvalqa3QOvL7MScXy3GCyyZ5DkrbXNu6BIGjHQ5Nq0jFvQWbxMjZuOKsci4Wm6CZee rj8aoyG02/Tijqmd8Ox0S4E8mKVfdRHcdFRY/IxfyrdbZkNZleBajvmiY57TMLCHxGr6 sXQCjXQR9dXfBviatHBewI0U7KMXWdhdNYNTGG0FHwWCbSZ9zQbfChvO8wrMSoRUn2xA x+bx3XChRaWKyrFIByhIws04f4TslvBkTRUmu4QH+YcbehnTs55Y3t9k42tN9B74hOnV pZSqX1xnbWOllZpp2s/uevL3kkcrUivlf8GnNm8TS21qYtR8YQWw8pUMkSZozzWOxZxa DrIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/+r4v7UIazK0HaIgNf9t5Xden24q10DFKnoad4rknzc=; b=Hd7jbEkfMUEuyx21v/wZTsJT2zOETMFNYIE8sB2COh5wX8pc5RppnsqA7eLzpOkEqX TZmC56pofbjVrlVj9xXO8CDZxsISqFPrLIB8q2SIqCD6ZSdiX1CgaPF3zZnx4SCxnuvR hUw6GuQcfFuOIa9bBgTq/q6/HBcjYcCEgxdeqQmv8V+vuwDTb3AQUiBKc3c97nw0O4CZ 3dM9ndP3WQo/vEEDdU0GYokAt0jf8PjkuHiHUaFiKNKkpWy9rxJuLc5kyGsOBMBZKwXl nFWytiQOIh0GZqVc2xjoYmNKBkTBmo01+iQR6fKKpqauS8T4csBxeEgzqT+UC4DqS2RU hI2A== X-Gm-Message-State: AOAM530aVI5Y7fnQeduFtPzUcGH5C6VmMsqJ16wFWKZh8vUuaipkAPk2 mpMSj3tGLL/YGjegOrtMlEGDRNevBIM= X-Google-Smtp-Source: ABdhPJzG7AFaYDwQJpn233Mj4QJuEh8U+Zh7+eaiUDerwROIIC2YEoHHxZ/uuESjovXChOtO2jnJzg== X-Received: by 2002:adf:edc7:: with SMTP id v7mr3460092wro.63.1632383788200; Thu, 23 Sep 2021 00:56:28 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:27 -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 Date: Thu, 23 Sep 2021 09:56:05 +0200 Message-Id: <20210923075608.2873-22-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 22/25] drm/nouveau: use the new iterator in nouveau_fence_sync X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Simplifying the code a bit. Signed-off-by: Christian König --- drivers/gpu/drm/nouveau/nouveau_fence.c | 48 +++++++------------------ 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c index 05d0b3eb3690..26f9299df881 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fence.c +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c @@ -339,14 +339,15 @@ nouveau_fence_wait(struct nouveau_fence *fence, bool lazy, bool intr) } int -nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool exclusive, bool intr) +nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, + bool exclusive, bool intr) { struct nouveau_fence_chan *fctx = chan->fence; - struct dma_fence *fence; struct dma_resv *resv = nvbo->bo.base.resv; - struct dma_resv_list *fobj; + struct dma_resv_iter cursor; + struct dma_fence *fence; struct nouveau_fence *f; - int ret = 0, i; + int ret; if (!exclusive) { ret = dma_resv_reserve_shared(resv, 1); @@ -355,10 +356,7 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool e return ret; } - fobj = dma_resv_shared_list(resv); - fence = dma_resv_excl_fence(resv); - - if (fence) { + dma_resv_for_each_fence(&cursor, resv, exclusive, fence) { struct nouveau_channel *prev = NULL; bool must_wait = true; @@ -366,41 +364,19 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool e if (f) { rcu_read_lock(); prev = rcu_dereference(f->channel); - if (prev && (prev == chan || fctx->sync(f, prev, chan) == 0)) + if (prev && (prev == chan || + fctx->sync(f, prev, chan) == 0)) must_wait = false; rcu_read_unlock(); } - if (must_wait) + if (must_wait) { ret = dma_fence_wait(fence, intr); - - return ret; - } - - if (!exclusive || !fobj) - return ret; - - for (i = 0; i < fobj->shared_count && !ret; ++i) { - struct nouveau_channel *prev = NULL; - bool must_wait = true; - - fence = rcu_dereference_protected(fobj->shared[i], - dma_resv_held(resv)); - - f = nouveau_local_fence(fence, chan->drm); - if (f) { - rcu_read_lock(); - prev = rcu_dereference(f->channel); - if (prev && (prev == chan || fctx->sync(f, prev, chan) == 0)) - must_wait = false; - rcu_read_unlock(); + if (ret) + return ret; } - - if (must_wait) - ret = dma_fence_wait(fence, intr); } - - return ret; + return 0; } void From patchwork Thu Sep 23 07:56:06 2021 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: 12512471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AA92C433FE for ; Thu, 23 Sep 2021 11:57:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5B48360F41 for ; Thu, 23 Sep 2021 11:57:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5B48360F41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 785C86ED16; Thu, 23 Sep 2021 11:57:24 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 837BE895E1 for ; Thu, 23 Sep 2021 07:56:30 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id q11so14488866wrr.9 for ; Thu, 23 Sep 2021 00:56:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=KGewx1QiQQVkw015IvGnnogZeqnpnoxIhP9ykI50FyQ=; b=nMhjVztgacZ7Rgh4Zl2/jUdj8mUPiIM5Utw8bUq0NXFTRWOhKgbtqkKB/D5yj6/g4c C/M2FwzIJjXkPyjisj7p/BK1RQf9USA6P5EVz2XXwjcffnsJR7KMgV6tkLjDyGEOIhrO q6DX/gE8jOs5Y+v5IMnGugpljGUFWAmeQsN2BbtvksqUcZhW9uFWf/VHgjOaLz4kKtLJ kWwslfzg3o1ykxoYJmi/Vqj8b4iZX/stncNOH4sNOlMSqA9dOpANZHvf4+RCYdolJhC9 Muu+eLXudWipNoUz4CtNh8FiVQyn0v00Tvf/ZsXGEbTFRD7KMc6rWOwN1JDwhkH6vmgu aKbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KGewx1QiQQVkw015IvGnnogZeqnpnoxIhP9ykI50FyQ=; b=LIbkwZy+6Ywo8YzXLo2shvy8L0vsZgyEI5RmYSJ+JuYwXhjUS/iBNPoDHC7E9IqJbS 3lnpzkdO6ukgE/bVV2SCVxBpBcFaI31FVWX53MZL6XCHCmOvo13CnstrkIcmU9c1WPgL lc9WdXK+yQ8xMTC+vKjztuS1q9zuFnjpCBK6EwJT1eV/PlgBk9fR+mo4H9+ePBUl8D1U fzwRVqQmv4dAV9HqtF0nBbCFxvWYPsKEr/2A+2k+I88t/9l4jJfKPEFDcAXqWG/yH/I5 4bfv9ESxWSis3wZXHBhrQ9QP84alRYE2ACea0Kg+2Rpp9f63ZOt1K3IGiGD8zmIMGfPQ srNA== X-Gm-Message-State: AOAM530fxu3ZgMq1zj96yLHl3dL3buz3c7NA8le6BA79+sf2ql5lro7O 6EwXwCK+cd2QH0K63V11gogyxAsaH8k= X-Google-Smtp-Source: ABdhPJxRQzMuq23JuS/dui5gE4n9C+GpslHug7+WGksLckMepyMz5pc3PBKzDjcAWLQ8+F3vZfmA8g== X-Received: by 2002:a5d:5386:: with SMTP id d6mr3499864wrv.112.1632383789073; Thu, 23 Sep 2021 00:56:29 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:28 -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 Date: Thu, 23 Sep 2021 09:56:06 +0200 Message-Id: <20210923075608.2873-23-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 23/25] drm/nouveau: use the new interator in nv50_wndw_prepare_fb X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Makes the handling a bit more complex, but avoids the use of dma_resv_get_excl_unlocked(). Signed-off-by: Christian König --- drivers/gpu/drm/nouveau/dispnv50/wndw.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c b/drivers/gpu/drm/nouveau/dispnv50/wndw.c index 8d048bacd6f0..30712a681e2a 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c +++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c @@ -539,6 +539,8 @@ nv50_wndw_prepare_fb(struct drm_plane *plane, struct drm_plane_state *state) struct nouveau_bo *nvbo; struct nv50_head_atom *asyh; struct nv50_wndw_ctxdma *ctxdma; + struct dma_resv_iter cursor; + struct dma_fence *fence; int ret; NV_ATOMIC(drm, "%s prepare: %p\n", plane->name, fb); @@ -561,7 +563,13 @@ nv50_wndw_prepare_fb(struct drm_plane *plane, struct drm_plane_state *state) asyw->image.handle[0] = ctxdma->object.handle; } - asyw->state.fence = dma_resv_get_excl_unlocked(nvbo->bo.base.resv); + dma_resv_iter_begin(&cursor, nvbo->bo.base.resv, false); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + /* TODO: We only use the first writer here */ + asyw->state.fence = dma_fence_get(fence); + break; + } + dma_resv_iter_end(&cursor); asyw->image.offset[0] = nvbo->offset; if (wndw->func->prepare) { From patchwork Thu Sep 23 07:56:07 2021 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: 12512481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64F24C433F5 for ; Thu, 23 Sep 2021 11:57:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 392D960F56 for ; Thu, 23 Sep 2021 11:57:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 392D960F56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B8A626ED25; Thu, 23 Sep 2021 11:57:27 +0000 (UTC) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by gabe.freedesktop.org (Postfix) with ESMTPS id 05F1C6ECF6 for ; Thu, 23 Sep 2021 07:56:32 +0000 (UTC) Received: by mail-wr1-x436.google.com with SMTP id t28so1163283wra.7 for ; Thu, 23 Sep 2021 00:56:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=jIUir/k9ok0mhA9lZLcDk0nsv9skwzmV2ts7X5dBo9o=; b=O3SmItKwUV6yyjU1KfQZ9CyqmNgPIxJFFQ806wPnttMzTcetckgEIu5qlHGYxPiZ3G Lua3jJ7DtL3fETuzKmXsS5p7CDQGfrl2vbuGu90Xsn5khs2h5P9ussv90PYiCOjcI0LP kRu0OjQq0XFr3pZEkLgs8ub4Z/7bSG92/jY9oPcyrXrugF/jpJVdltFuItstIx6KPr/q IE8Ro1Rj3TesWg1SDkYXiuCOtzte0ygKVJwXHqnr3umalBoRU0qoTtFR3yZgo89P8Xqy 3j+MR7i/ZJrRydnYn4mEJ6LOBYuOxJa6IqDRhjAQUHoG5BmuzUvGsH6bSGH8QPKKp8H/ 3k/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jIUir/k9ok0mhA9lZLcDk0nsv9skwzmV2ts7X5dBo9o=; b=pp6m7cVd6Azxpoo657tfxMfpE0FQtN+BCVlqD+RyuwZ5aP7liTrXnK8kD8BKnZUrzf MRwk5ylU9jF1+0O5y2raccEbyjPpUmHcRxpOCd+RXJTkKYJeqoJEprLnFkeJxN4xIP9I cPXOYKovPmXF2WJRfvg+vAdeaxip9OBPFmYRW6prH4AneMzr158hw1uQTF1EuV3qcBJ3 uxhiLf7SrgdyFMR1XYcoIjVa+M5vFKvVON3oW9J9PNhVs55tqFCbRK1Cd2aJMYmd+ztm 8/jfVjVp3ZhLKtB8exnxfA8cDfyzXzP/GQTQMywuw9cCH6pgUvVQG3n7vzpiS9Va2rAi PWtQ== X-Gm-Message-State: AOAM530CbApzEhsNAaNVqITlByXjVk3mH2rwDM3GAu6vWP//Q3RstfKu ProYgVHfX0GLXSwLCA0LxTQ2oq1hPlI= X-Google-Smtp-Source: ABdhPJyvs3LrHnZEmHzsGZR77dBavh+yb1fpQW8HdX0AjrQi6f4PdGEG2TgUa3rAkPk//ih8qo80QQ== X-Received: by 2002:a5d:510b:: with SMTP id s11mr3362657wrt.79.1632383790656; Thu, 23 Sep 2021 00:56:30 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:29 -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 Date: Thu, 23 Sep 2021 09:56:07 +0200 Message-Id: <20210923075608.2873-24-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 24/25] drm/etnaviv: use new iterator in etnaviv_gem_describe X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Instead of hand rolling the logic. Signed-off-by: Christian König --- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 31 ++++++++++----------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c index 8f1b5af47dd6..0eeb33de2ff4 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c @@ -428,19 +428,17 @@ int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj, static void etnaviv_gem_describe_fence(struct dma_fence *fence, const char *type, struct seq_file *m) { - if (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) - seq_printf(m, "\t%9s: %s %s seq %llu\n", - type, - fence->ops->get_driver_name(fence), - fence->ops->get_timeline_name(fence), - fence->seqno); + seq_printf(m, "\t%9s: %s %s seq %llu\n", type, + fence->ops->get_driver_name(fence), + fence->ops->get_timeline_name(fence), + fence->seqno); } static void etnaviv_gem_describe(struct drm_gem_object *obj, struct seq_file *m) { struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj); struct dma_resv *robj = obj->resv; - struct dma_resv_list *fobj; + struct dma_resv_iter cursor; struct dma_fence *fence; unsigned long off = drm_vma_node_start(&obj->vma_node); @@ -449,21 +447,14 @@ static void etnaviv_gem_describe(struct drm_gem_object *obj, struct seq_file *m) obj->name, kref_read(&obj->refcount), off, etnaviv_obj->vaddr, obj->size); - rcu_read_lock(); - fobj = dma_resv_shared_list(robj); - if (fobj) { - unsigned int i, shared_count = fobj->shared_count; - - for (i = 0; i < shared_count; i++) { - fence = rcu_dereference(fobj->shared[i]); + dma_resv_iter_begin(&cursor, robj, true); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + if (dma_resv_iter_is_exclusive(&cursor)) + etnaviv_gem_describe_fence(fence, "Exclusive", m); + else etnaviv_gem_describe_fence(fence, "Shared", m); - } } - - fence = dma_resv_excl_fence(robj); - if (fence) - etnaviv_gem_describe_fence(fence, "Exclusive", m); - rcu_read_unlock(); + dma_resv_iter_end(&cursor); } void etnaviv_gem_describe_objects(struct etnaviv_drm_private *priv, From patchwork Thu Sep 23 07:56:08 2021 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: 12512487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 054ADC433F5 for ; Thu, 23 Sep 2021 11:57:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CA25860F41 for ; Thu, 23 Sep 2021 11:57:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CA25860F41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 17CC16ED64; Thu, 23 Sep 2021 11:57:30 +0000 (UTC) Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by gabe.freedesktop.org (Postfix) with ESMTPS id 127CE6ECF6 for ; Thu, 23 Sep 2021 07:56:33 +0000 (UTC) Received: by mail-wr1-x432.google.com with SMTP id d21so14424742wra.12 for ; Thu, 23 Sep 2021 00:56:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=vDNZbZcYoW7IFr6lQi88QIbXjkbY+ZD5EoDTFjlvddA=; b=BuZrVO2AK8pOXHBnqQb9ANq1oJMSvD8QLzif1+QS9pdLsQMJVv0+vRw+zRaO8nzzal 0frR/1OsKDG/G50rZY1nMaiEc9w9QfkOrD47IgioQir735ukviJrbg7lTFrJoCRIMQ86 GqJRiqn7Qmr/NzxFkMC+o4YrfZOq/08Uf0qOW553+dk+LTlWtp1fwS6YvfnebOe8ois2 +4TnKtee+6wgVGxEi2V85BF0+eCi5LWD/SPuI/Z5mt4uF4qcoz9jc8vwktMf4fB1vUXx Y7NOJDqZj4kvzDbd/jaM5tECd5Pbf/fQLqQQE8g2DJJFQC6xHjZUYIqoaxORD23Txudz JQ2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vDNZbZcYoW7IFr6lQi88QIbXjkbY+ZD5EoDTFjlvddA=; b=jp+qtsAl3XZlJCWfBFtg8jJidguIuwb7OkXyeq5WfhrvyoImr999ka/BKCqnowWVb5 Qr2tC4gPbcjIh4ply32eqs0EzWfRsGUxnMaoLJiJXV8m/RCrqC2vIzDvyjFYSWQg74Up yqjkfZzl1SP5scZ9d6NmGEqn2ElHOZeB6JowoGOkJSG+GUCu1GFAbk8BBMf3xVG/xk65 CUWn4GYM47fnTxJuUB9XdJS74GKzsTkAAJzSt689p5POzKMgg7Y3mxisjR1YILwpaX4O 3ffa5emRBVrBUbNg8d4YreaS8l35+wavcjS/civMX9dkkB9ZrTjK0dw9yaICydfK41oD Weig== X-Gm-Message-State: AOAM532O1t9uKg6elbozOTmfPNZ/srEXGbisXCgeIZHydbdx87zbTypC 1PNTKRZEuxpc8YZxp/1jJVM0SPMANzE= X-Google-Smtp-Source: ABdhPJwuhS+KVPJmS5vaJHKH0VrYF7uz87ZbZCxvAirkjzDAgtSBCCGHWWJJ2HB33V4WF3bK4QQOww== X-Received: by 2002:a1c:f405:: with SMTP id z5mr3004727wma.72.1632383791652; Thu, 23 Sep 2021 00:56:31 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id k19sm4280704wmr.21.2021.09.23.00.56.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 00:56:31 -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 Date: Thu, 23 Sep 2021 09:56:08 +0200 Message-Id: <20210923075608.2873-25-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923075608.2873-1-christian.koenig@amd.com> References: <20210923075608.2873-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: [Intel-gfx] [PATCH 25/25] drm/etnaviv: replace dma_resv_get_excl_unlocked X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" We certainly hold the reservation lock here, no need for the RCU dance. Signed-off-by: Christian König --- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c index 4dd7d9d541c0..7e17bc2b5df1 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c @@ -195,7 +195,7 @@ static int submit_fence_sync(struct etnaviv_gem_submit *submit) if (ret) return ret; } else { - bo->excl = dma_resv_get_excl_unlocked(robj); + bo->excl = dma_fence_get(dma_resv_excl_fence(robj)); } }