From patchwork Fri Oct 1 10:05:43 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: 12530125 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 381E5C433EF for ; Fri, 1 Oct 2021 10:06:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1CC2C61A50 for ; Fri, 1 Oct 2021 10:06:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231225AbhJAKIB (ORCPT ); Fri, 1 Oct 2021 06:08:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230350AbhJAKIA (ORCPT ); Fri, 1 Oct 2021 06:08:00 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BBE6C06177B for ; Fri, 1 Oct 2021 03:06:16 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id i6-20020a1c3b06000000b0030d05169e9bso8594894wma.4 for ; Fri, 01 Oct 2021 03:06:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Aeu6CMgi3DA9s2EzOD6NRsLY5k+Po1EA6cDruO86FOI=; b=jHOtm50Ocqqs32d0A+92zeoUysexcREiiCNcR8DTSln9GM5UQrQTWXIOZ5EHQeELkB KM3o5QNgm3EQ6fPIVywsiCQv+lpf/w1D//vDIrPCh/EqtmEqAaLWvzSi2f+BXiEOLmrq 22stm6GgrkqezKpGs9I3btZooqYqUe0LaFX7HwAZGpva/j0m1dbkDVnnyoDVzG2u6dB8 8aRXK7pYx7apMTW1zzWz0qj6FC0QJw2jcGUT9BVJil7Bpz+pN8UyRFQbr5joDOS5lT/I THoaP85gsMgkWP2OSI/p4oAQToJ7KPK2paGsP6GEeDpoTpfVpJIaDWGF+bztqrVdgmqc +lPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Aeu6CMgi3DA9s2EzOD6NRsLY5k+Po1EA6cDruO86FOI=; b=jdbRBVB4j/osOixvCc0iNAqwwlIdDdlaV1/LbAQbqGvEMJ3ZuunXUDkKJXA9c8+Mtk qgmf4ar0vhSHdlMHwB8fbER2Biw8i2BmXFWHcLr5l7bKJBAZ4pwQdkiqguIbQbr+BBuy ND/bkTYAPjsfFCo3rAMvo0aSJmfbLYhLzHrxzSEskgw7xD7aJCJUelT5swxh0iO5naA5 Z2bwCBfp2PvpDV1IQXUH9UM4vpGsjWW7Dw4DAC9Iuzd94go9zXX+vQqX8ugkq68ecgm/ PmYQetnA6yGdjiNDUc/HeZK15pTybP6bMEzhFeMtDH2LpSuF8BZfWAeP63Qs2KQ6C6S2 SeHQ== X-Gm-Message-State: AOAM530gQF/xK1BkNqe1K2h5Um6VctqAsZFyEx4ccXmfJN/M/bFemQT/ AW6mEUSI46f+82Dd6ZnHdgA= X-Google-Smtp-Source: ABdhPJxWUxtDIq8zRxGgtbKe4U388TIcUHgzrsopGHq09EJ0fJEPl1kpM3Qym0y7OGT3+BdFATVDmQ== X-Received: by 2002:a05:600c:3b83:: with SMTP id n3mr3575407wms.50.1633082774599; Fri, 01 Oct 2021 03:06:14 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:14 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 01/28] dma-buf: add dma_resv_for_each_fence_unlocked v7 Date: Fri, 1 Oct 2021 12:05:43 +0200 Message-Id: <20211001100610.2899-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 v6: fix coding error when excl fence is NULL v7: one more logic fix Signed-off-by: Christian König Reviewed-by: Tvrtko Ursulin --- drivers/dma-buf/dma-resv.c | 100 +++++++++++++++++++++++++++++++++++++ include/linux/dma-resv.h | 95 +++++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 84fbe60629e3..3cbcf66a137e 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -323,6 +323,106 @@ 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); + cursor->index++; + if (!cursor->fence) + continue; + + } else if (!cursor->fences || + cursor->index >= cursor->fences->shared_count) { + cursor->fence = NULL; + break; + + } else { + struct dma_resv_list *fences = cursor->fences; + unsigned int idx = cursor->index++; + + cursor->fence = rcu_dereference(fences->shared[idx]); + } + cursor->fence = dma_fence_get_rcu(cursor->fence); + if (!cursor->fence || !dma_fence_is_signaled(cursor->fence)) + break; + } while (true); +} + +/** + * 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 Fri Oct 1 10:05: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: 12530127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6CB7C433FE for ; Fri, 1 Oct 2021 10:06:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D32F61A63 for ; Fri, 1 Oct 2021 10:06:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353344AbhJAKIC (ORCPT ); Fri, 1 Oct 2021 06:08:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231320AbhJAKIC (ORCPT ); Fri, 1 Oct 2021 06:08:02 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD00EC061775 for ; Fri, 1 Oct 2021 03:06:17 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id t16-20020a1c7710000000b003049690d882so10759047wmi.5 for ; Fri, 01 Oct 2021 03:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v4LbHzasULQayC+y/hjohCjdtn1xDHygzW8kntq697M=; b=AJluI3DqUgVPqr2pdUTmoNMEUOTbYCvC8CrWSUQPgcw2ADm8tZ7DUd9U/V3nPpVd7I 1j8ecLCjZ9xw2DnehZPJeDMFvjfDvcceEk7847Y/MDe/72+qJ9mBQVw0JKb/EIsizNaP q+Aej35RF8NTB6HuxnggjeJUp5zFsBYxHuO5UqUe/8INWnkpDZ9+18+WPFg7S4apY6JR eOVwDsB83C+AxTpoAyqaya/1zgdURnMjBg1IIvp86MaFFzubR74Qqx7xLG6N73ZvO4r/ KflvDuzTRdgbDJCqaFBcQ6cSnYXFhJM/AtysbDa6a36uqs8VED/D6/YfW0ys9nwNdLLu ueGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v4LbHzasULQayC+y/hjohCjdtn1xDHygzW8kntq697M=; b=BKpgs6slVJatL23gHGhJ565JJusNii+/9BtpO2uSA872bomEvTxcAoB5Q+g6VdQ4Sg aEp3ikrD7YP/MDtXOOmeEVzImf0yK/huHnqOzykOnySKCwrPWIW2f6Lj/Da0URejTkH/ R5neG9RKgTuO7EzPs7WWBb5RMEOuRpZ7kYQX91zfSg4bFA8z4J70dNteCnN8J2v4MKB9 9nD7fpY2OM8Lgx0QkYtDK3V/ypbeWlCsbzsW3aoRh2tlVYWWj5vl8vfo59zNqistGThL X4LeSOtHh+lpeIaZCbzes55o0sZcBUMUUy7YLfV1NHtBPIvRT1/g2oXmKMX/X7bT4mpi XIrw== X-Gm-Message-State: AOAM531+bY5f/0R5MIER3UetEYBf+dNzbIKPyx3WC15QU5wMpX1udHso RDzyNzwtyUL7V2JSttwPseA= X-Google-Smtp-Source: ABdhPJxvq+HAvChoc1/EnB92mPvCRlpuvwfmJ9QzOfN9qS0JkdMuVk0zMD6p034f/W2/8PDdj7lN+g== X-Received: by 2002:a1c:e906:: with SMTP id q6mr3792282wmc.126.1633082775419; Fri, 01 Oct 2021 03:06:15 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:15 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 02/28] dma-buf: add dma_resv_for_each_fence Date: Fri, 1 Oct 2021 12:05:44 +0200 Message-Id: <20211001100610.2899-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 3cbcf66a137e..a104197d12b5 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -423,6 +423,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 Fri Oct 1 10:05: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: 12530129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84A3DC433EF for ; Fri, 1 Oct 2021 10:06:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6477561A63 for ; Fri, 1 Oct 2021 10:06:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353348AbhJAKID (ORCPT ); Fri, 1 Oct 2021 06:08:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230400AbhJAKIC (ORCPT ); Fri, 1 Oct 2021 06:08:02 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1E9EC06177B for ; Fri, 1 Oct 2021 03:06:17 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id x20so14589231wrg.10 for ; Fri, 01 Oct 2021 03:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lj2Yv/wWR6TC7dOizEI5QN7SBISIYTE1BHrEKqHlUyU=; b=F1cew7aZEUucNVVNFZlNfSBSfXsZ8gbknKuLsr23knf9WXCaxF7SSM845G0YLqkIxP TFPr0rb/+iezQtLlEYcm/bci1worOBdkAy7AmYGc0xhQJzZWgF9vQeIj1+sb3Qe/uFYp pUhQYXiWK3CJneoQbRLveMWgZ5BlgudG604+Rl9I7IFeAbufJpa98KtU19i9dMNDoQfd AAphbF++RL5oETTWkFDFTlpuO7+tmKU21/jcTpKyF9uEMu7nr7z/MIlsjhHHTGnyAqqS VDzTF28/wAFWxRm58SHZSH+O5oYk2JFTnP6C2/JQzB9KEJ88IVwDLYlT4yc4PTpFORg9 CciA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lj2Yv/wWR6TC7dOizEI5QN7SBISIYTE1BHrEKqHlUyU=; b=RpjPd32QGwT3uca4dwhXxvLC7wcXdCh1uvASooMaKE0vCbK6eYZ2N1VKDmSzR92oes gi5jyimRbnlLLOuwTR0DDESk/u5EHIso+3PZXExRLXlEwfx9pP5AlmFmCMqadB7F/lr5 dc6hufY3du+iwXiphYNuUQh3yBgGl7vKzYHq7M7I2yXsu9FQZ7R6PZzjaG435lUbkTp+ yI5+gHELnhOpw6/DWq6BbnD3FF9+p+tpptG+EZFuTT8KBp1rEBWa3xMsf5926pJB2Ycq k5Tz5QLRiWlaCCQygCEJHNFWtQbsXOz2xlLoOLiRtQORkQbGEMU9AGnNiaNowpEg9a66 g1og== X-Gm-Message-State: AOAM531Jf2qkVO/ZucFzX4qWLKFZhATyqW08Lqt/B6Q4VeON4Pnq8Msy 3xhBxXyzsnAdu8ONgOdlYJI= X-Google-Smtp-Source: ABdhPJwF4w8sP02fwa4GAQ5OjEFRtUPoYdMOh1BHF+3PWJhYQbxaJOfIm2jrfhL09Kz2OJkbgOazRA== X-Received: by 2002:adf:fec6:: with SMTP id q6mr11075927wrs.122.1633082776331; Fri, 01 Oct 2021 03:06:16 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:15 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 03/28] dma-buf: add dma_resv selftest Date: Fri, 1 Oct 2021 12:05:45 +0200 Message-Id: <20211001100610.2899-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Just exercising a very minor subset of the functionality, but already proven useful. Signed-off-by: Christian König --- drivers/dma-buf/Makefile | 3 +- drivers/dma-buf/selftests.h | 1 + drivers/dma-buf/st-dma-resv.c | 164 ++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 drivers/dma-buf/st-dma-resv.c diff --git a/drivers/dma-buf/Makefile b/drivers/dma-buf/Makefile index 1ef021273a06..511805dbeb75 100644 --- a/drivers/dma-buf/Makefile +++ b/drivers/dma-buf/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_DMABUF_SYSFS_STATS) += dma-buf-sysfs-stats.o dmabuf_selftests-y := \ selftest.o \ st-dma-fence.o \ - st-dma-fence-chain.o + st-dma-fence-chain.o \ + st-dma-resv.o obj-$(CONFIG_DMABUF_SELFTESTS) += dmabuf_selftests.o diff --git a/drivers/dma-buf/selftests.h b/drivers/dma-buf/selftests.h index bc8cea67bf1e..97d73aaa31da 100644 --- a/drivers/dma-buf/selftests.h +++ b/drivers/dma-buf/selftests.h @@ -12,3 +12,4 @@ selftest(sanitycheck, __sanitycheck__) /* keep first (igt selfcheck) */ selftest(dma_fence, dma_fence) selftest(dma_fence_chain, dma_fence_chain) +selftest(dma_resv, dma_resv) diff --git a/drivers/dma-buf/st-dma-resv.c b/drivers/dma-buf/st-dma-resv.c new file mode 100644 index 000000000000..ea44769d058d --- /dev/null +++ b/drivers/dma-buf/st-dma-resv.c @@ -0,0 +1,164 @@ +/* SPDX-License-Identifier: MIT */ + +/* +* Copyright © 2019 Intel Corporation +*/ + +//#include +//#include +//#include +//#include +//#include + +#include +#include +#include + +#include "selftest.h" + +static struct spinlock fence_lock; + +static const char *fence_name(struct dma_fence *f) +{ + return "selftest"; +} + +static const struct dma_fence_ops fence_ops = { + .get_driver_name = fence_name, + .get_timeline_name = fence_name, +}; + +static struct dma_fence *alloc_fence(void) +{ + struct dma_fence *f; + + f = kmalloc(sizeof(*f), GFP_KERNEL); + if (!f) + return NULL; + + dma_fence_init(f, &fence_ops, &fence_lock, 0, 0); + return f; +} + +static int sanitycheck(void *arg) +{ + struct dma_fence *f; + + f = alloc_fence(); + if (!f) + return -ENOMEM; + + dma_fence_signal(f); + dma_fence_put(f); + return 0; +} + +static int test_excl_signaling(void *arg) +{ + struct dma_resv resv; + struct dma_fence *f; + int err = -EINVAL; + + f = alloc_fence(); + if (!f) + return -ENOMEM; + + dma_resv_init(&resv); + dma_resv_add_excl_fence(&resv, f); + if (dma_resv_test_signaled(&resv, false)) { + pr_err("Resv unexpectedly signaled\n"); + goto err_free; + } + dma_fence_signal(f); + if (!dma_resv_test_signaled(&resv, false)) { + pr_err("Resv not reporting signaled\n"); + goto err_free; + } + err = 0; +err_free: + dma_resv_fini(&resv); + dma_fence_put(f); + return err; +} + +static int test_shared_signaling(void *arg) +{ + struct dma_resv resv; + struct dma_fence *f; + int err; + + f = alloc_fence(); + if (!f) + return -ENOMEM; + + dma_resv_init(&resv); + err = dma_resv_reserve_shared(&resv, 1); + if (err) { + pr_err("Resv shared slot allocation failed\n"); + goto err_free; + } + + err = -EINVAL; + dma_resv_add_shared_fence(&resv, f); + if (dma_resv_test_signaled(&resv, true)) { + pr_err("Resv unexpectedly signaled\n"); + goto err_free; + } + dma_fence_signal(f); + if (!dma_resv_test_signaled(&resv, true)) { + pr_err("Resv not reporting signaled\n"); + goto err_free; + } + err = 0; +err_free: + dma_resv_fini(&resv); + dma_fence_put(f); + return err; +} + +static int test_excl_for_each(void *arg) +{ + struct dma_resv_iter cursor; + struct dma_fence *f, *fence; + struct dma_resv resv; + int err; + + f = alloc_fence(); + if (!f) + return -ENOMEM; + + dma_resv_init(&resv); + dma_resv_add_excl_fence(&resv, f); + + err = -EINVAL; + dma_resv_for_each_fence(&cursor, &resv, false, fence) { + if (f != fence) { + pr_err("Unexpected fence\n"); + goto err_free; + } + err = 0; + } + if (err) { + pr_err("No fence found\n"); + goto err_free; + } + dma_fence_signal(f); + err = 0; +err_free: + dma_resv_fini(&resv); + dma_fence_put(f); + return err; +} + +int dma_resv(void) +{ + static const struct subtest tests[] = { + SUBTEST(sanitycheck), + SUBTEST(test_excl_signaling), + SUBTEST(test_shared_signaling), + SUBTEST(test_excl_for_each), + }; + + spin_lock_init(&fence_lock); + return subtests(tests, NULL); +} From patchwork Fri Oct 1 10:05: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: 12530131 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2B8CC433F5 for ; Fri, 1 Oct 2021 10:06:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A86E961A6F for ; Fri, 1 Oct 2021 10:06:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353355AbhJAKIE (ORCPT ); Fri, 1 Oct 2021 06:08:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353290AbhJAKIC (ORCPT ); Fri, 1 Oct 2021 06:08:02 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98F2EC061775 for ; Fri, 1 Oct 2021 03:06:18 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id m22so9153657wrb.0 for ; Fri, 01 Oct 2021 03:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q1qIY7djP00ihPSVoWQA0SIOjmkVpQHX9FfVKyvwxz4=; b=mQVBB3YSod034fbpYGnsfEPIgxQOgKLtRNGVt2lW2ZbgOkrcO5ZsjWPYCJ4y/02GEa kdO0dBWYjw0w5QXU4T5Iz+zjQmU2d0g9FzrOE7Hf87YzwMFNKAMO4YNY0lcJWQ++VRWE cgC8kQHmSpiUoH1pud96q/mLQuyedWQE0iyqD+UCo7MGHW3YwDd+1urkKV6b6QpMKYti 9t0JR7T+dljAICh8K8OVyL27gWSIj1WFx3hhXCFyVrkO7V0bpzd77Lo8fA6XiJlG7sO8 qssq9WT/lH03bESs33J3TcX0ckTFkYovUisgXJV9wC+lLJbNBfqOyt4ACVQBxo2/YsgE gTMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q1qIY7djP00ihPSVoWQA0SIOjmkVpQHX9FfVKyvwxz4=; b=P+1ckddO25rxLNyTDgBtzdkNHZbsWsPFZoDCB780ex+j8+6cKcxN6I7B6GnUwCtE01 RE53ZBxMnXBasJgdQ8QSxj9tjR492vIYFLxjyz/vN1sWtE/A5C9S4YftEi53EH4wZNOB YdeY7lUmtRExUANzLLrOeLB7AzYMWxkV9BHu0A2mKFJNWCkw8P2xSWPN130pBtgRpPl7 wx+sar1F7yz7TutDj8K1LtI7Nleh2A0eB7s9tOMmd7og9jigomRIJhjrHlllzzGtgF1r uT5iSSnS8fLJnUa40khVuaOeylwbVmMcjKTPNnSOyH5Gwz6rPFaIpLCsEFipPex5JQhv jCBg== X-Gm-Message-State: AOAM530qRl1piOJR6eznnerxNJVptkKRjgViiYNILeWVeNTkEo/uZzVS Rgcwp8x+a6xY3CU2SgWr8lw= X-Google-Smtp-Source: ABdhPJyqwaAqdUMdBcZACqFhSkKIuhcuAtbkCG8k2pKDV2/8jVkYYA7VIpWyeslTXeS4Hm5EYTzJ5Q== X-Received: by 2002:adf:aade:: with SMTP id i30mr7433371wrc.384.1633082777188; Fri, 01 Oct 2021 03:06:17 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:16 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 04/28] dma-buf: use new iterator in dma_resv_copy_fences Date: Fri, 1 Oct 2021 12:05:46 +0200 Message-Id: <20211001100610.2899-5-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 a104197d12b5..064972c6bde2 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -478,74 +478,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 Fri Oct 1 10:05: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: 12530135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD62BC433FE for ; Fri, 1 Oct 2021 10:06:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A376E61A50 for ; Fri, 1 Oct 2021 10:06:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353388AbhJAKIF (ORCPT ); Fri, 1 Oct 2021 06:08:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230400AbhJAKID (ORCPT ); Fri, 1 Oct 2021 06:08:03 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79031C061775 for ; Fri, 1 Oct 2021 03:06:19 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id d26so14610689wrb.6 for ; Fri, 01 Oct 2021 03:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/k/dWpbbOkoaVHuG86xApdnQjc/bREftK1P14dEbxBw=; b=hYd82/WoRJdGADzGX9G77Kp6d1bzNAYwhM3cAJxsrd1QXx3fSP9R6EBaz1uGHQVUIp jHdA7PvS/TxeS3Uk9dykNsFZMDRgh0tcaqb475KBnvv91XARZrPhsFoKzZgS9DWfKv95 KTbZRpJ62axAD3EMjf7VZ2CVyLS6+2bM8GKqbGn1/9ZHsjAXSMh7VsI1G4/6MTvuZn3q 7XCoEs8SrKzgmFfZvCGjM8QPMUQHm6uARLHh+f/pG4yr6d2zSRVtUxi3AxGpcQ+nnpR6 bIpE8eRqp3m+dwh5cVjcgqWXFdznj/7y4aFqVlwbfZyEx1C9oYzSZJNLfW9Wy4N5iy36 fWNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/k/dWpbbOkoaVHuG86xApdnQjc/bREftK1P14dEbxBw=; b=hREbaQXFqzZQD5tnWVGih2c0zbnYfER6MGJWy7cctJJGThYeq+BD/QVReAYi6Bsvsu TOOXAPaJ/IOomOIZpCu2vIX5uZ/dSQYc7mZ6MgB1FW4veqUPbrAv4+iImFVq2oaT/+vz WS7l/6rY8KS5aIWOJl9qAAg6m9pWNHcIj8Shi8ZfJOJMFj25Qw/4lX/GZgQ/aL8HM74C KtjFjFvM8nJnjk4JZgEXUaadxixsKNlAWBy9kWBr/MYjB8mzcbpTK57GJ3MvUOK0cJ7y 6AsLqJBtTvjRn8vH5T72ZuvAUKKeuH0Iiz9LrMyT9V23dam2yD5XAPirTkJVtginDY0V NHhw== X-Gm-Message-State: AOAM531nH8PTga4mRvkckL8n3/SwTVcTMo5cAzrjKHJINgxHhX4n17xx prb3gcFW4OQBoqg15wPPwB8= X-Google-Smtp-Source: ABdhPJx0scSwaKaao1K0xkBL/nbytkmSdOehr0QPy835XvQGVeMNvVj9LCYEzmCqLVPuLtnN5fupRw== X-Received: by 2002:adf:ffc9:: with SMTP id x9mr11114448wrs.123.1633082778100; Fri, 01 Oct 2021 03:06:18 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:17 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 05/28] dma-buf: use new iterator in dma_resv_get_fences v3 Date: Fri, 1 Oct 2021 12:05:47 +0200 Message-Id: <20211001100610.2899-6-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 064972c6bde2..9b494828e7ca 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -535,99 +535,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 Fri Oct 1 10:05: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: 12530133 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB132C4332F for ; Fri, 1 Oct 2021 10:06:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C0F4B61A50 for ; Fri, 1 Oct 2021 10:06:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353396AbhJAKIG (ORCPT ); Fri, 1 Oct 2021 06:08:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353386AbhJAKIE (ORCPT ); Fri, 1 Oct 2021 06:08:04 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92540C061775 for ; Fri, 1 Oct 2021 03:06:20 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id w29so14617303wra.8 for ; Fri, 01 Oct 2021 03:06:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DLn0ZmdbAH2RzPW/tcdHG/ty+pcMQGDFLOQ2PJC46s4=; b=NnfkMsQhVQWp+VnHgA4QOViEoonm7dolqt+Q+FjQOGMRuaaz0cXgLDrRVRcRedMDup kRDPMlSFOdbZU7jwq0tjQhlPU3duqxg99UpWsUBnodzqWKWWpetIeH1ePZuGy+RHfHAG LQQ6i5PFFXlGnyVOVZx6CTAYV7LG16mvi7qbOB7gXt0gEblm226RcpYZ0wWFVuYMHRFU sMMCMdTEbZcdKZw0YI5mogh8BsIB9V6opYA9yM0XSz9JzYor0/Lud/GTsePfepSguJZu xxRNdcNKJ5DSg56p7fqG9tUs9oc0OvYzCyL4lmPTrCjyIGlwCJMn+MtrnUzlMaFCobb8 YU0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DLn0ZmdbAH2RzPW/tcdHG/ty+pcMQGDFLOQ2PJC46s4=; b=VzTE6vQwhAVK9nvCN6eEcUW66+z+w0dHlqszWnl3fV830bgjv9KHwlDxtoH1Cq1agH RjN3Q5duM27+wNtx77+BUXGFtIKgJ00vqWYf45cRx7V4jM/57OIkw/mw8TNOOR3hlgY4 R9O+KrV8Av2WGJnmA2qNFeM6fCatVXydLqC5L2vwriV+Jjhlpqjuoc8TQVUxhJhDaCGc g1BzK0dCvyI8png/qStZd9eWR+04laD8zWVFtvU7TsCUEr1/0CK3+20vF1RJOsDvl3Iv CF6Ajfg89BNKR8/VIq12zKDhZIjGjLaHAZ1jmyT1QRD97uMG5Bd8iQZ3k5dTE+olOvtR 0yoQ== X-Gm-Message-State: AOAM533iG0q+xH49bV95fXYGhouzbZvqCmCoA+XLmzd4Z+bLOKnQIzi1 IVx273dFNHLNvxHKRQtj2EiYPHuTPeI= X-Google-Smtp-Source: ABdhPJz/aW5sUJgBDhsPc6PbxZWz95pBOKKVeJgdt0cjwyv9AG40FNPNmoDglQ/xHFW1pSioYbjPQg== X-Received: by 2002:adf:a2c8:: with SMTP id t8mr8546800wra.215.1633082778942; Fri, 01 Oct 2021 03:06:18 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:18 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 06/28] dma-buf: use new iterator in dma_resv_wait_timeout Date: Fri, 1 Oct 2021 12:05:48 +0200 Message-Id: <20211001100610.2899-7-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 9b494828e7ca..510e15f805bb 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -611,74 +611,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 Fri Oct 1 10:05: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: 12530141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2A53C433EF for ; Fri, 1 Oct 2021 10:06:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9ACAC61A50 for ; Fri, 1 Oct 2021 10:06:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353487AbhJAKIO (ORCPT ); Fri, 1 Oct 2021 06:08:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353391AbhJAKIF (ORCPT ); Fri, 1 Oct 2021 06:08:05 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BBECC06177B for ; Fri, 1 Oct 2021 03:06:21 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 205-20020a1c01d6000000b0030cd17ffcf8so10782632wmb.3 for ; Fri, 01 Oct 2021 03:06:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xZyEDI8vSHJnpr1jQdm0wne+UPSjEKtih6sz0wcxBNk=; b=OYTh8vKmtrav14mFz8uIdkFtVVJHQhZYyQPeaXN5qFQHZ7/ULXl/4PxGUUzvj03DNI 40e3/JxSh6SCcK6I11YGTftVpWLZv4yKuyXFKalqYAKqUiPVSEkQMB4v7KM4Gre77pO/ 7b3t5a86MLfWfoQq900zPJ/ePr4Qng5Akw3PC6W0S4TRqbpaCpA2Kx3WQArBQVDoRyCN 7BklFre1m78aJ9sEqbiU2Y6bdBFJ7TW8Z1jZqYyXJ2fqOJrkSXNuMAE9JjBkHAWf2E87 uLcvyiSml6I2qDS5EsDXkuKvowIXNfs6Aa+ppTvJRF3G52tUvSJuCVsf7GyjDqqjt8AL vpDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xZyEDI8vSHJnpr1jQdm0wne+UPSjEKtih6sz0wcxBNk=; b=Gl+LL9ROzzHZtQCpNDGd3HiOytlAo9OwwOUDHfpddLuL3AisbuYEwMuLRa+HTlATcP QujYwF4Sh2+359SV+lCOgpwpphZEUNHcinHJh7u5mwgRTLTIKHICF2/NVw3lNrJLkzzZ YMJL9obH2R1bIjdXO1g6lrMbRMZBpN9UmOYbqnG3SzaFrCGX84XFlFGWkwokcSdRCLzY 3dhi+LYuCSQGNOLEZjzZnPL/kXU28X3nGQnKGA8FgJ2cVIW2m7AWW1T8whGhCbluCysg R5QqYx5Y5HiXQkX0yPR1GnI0AjVD42K5zAwFphUzYIPH1o+zD2UMh4o/92ByOfZ40bwv 3qmQ== X-Gm-Message-State: AOAM5337dYlScaEm/6I2do6flnYNJuYzudIF2ZXwceMXHRd3ZsKpfmwp 4iEIMLMH2RC89TXLj9W47/U= X-Google-Smtp-Source: ABdhPJzp/6YpInBjtTPgP5OEoDFJyzZkQNVa1ROWKLVSqv2qBL0iNks8TNepIeCpIrbwqPJhRvxQpw== X-Received: by 2002:a05:600c:1d16:: with SMTP id l22mr3637600wms.44.1633082779853; Fri, 01 Oct 2021 03:06:19 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:19 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 07/28] dma-buf: use new iterator in dma_resv_test_signaled Date: Fri, 1 Oct 2021 12:05:49 +0200 Message-Id: <20211001100610.2899-8-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 510e15f805bb..324f243cb56b 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -630,22 +630,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. @@ -662,43 +646,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 Fri Oct 1 10:05: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: 12530139 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32971C433F5 for ; Fri, 1 Oct 2021 10:06:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13ABD61A6F for ; Fri, 1 Oct 2021 10:06:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353488AbhJAKIP (ORCPT ); Fri, 1 Oct 2021 06:08:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353405AbhJAKIJ (ORCPT ); Fri, 1 Oct 2021 06:08:09 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13F0AC061775 for ; Fri, 1 Oct 2021 03:06:22 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 205-20020a1c01d6000000b0030cd17ffcf8so10782670wmb.3 for ; Fri, 01 Oct 2021 03:06:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eXOyf2Axg9vbweqRF85gRFPRys7FD2K3wIzrdoghDjE=; b=f3SJa+yl39fdzfr+eQ3qogubPh4JXxTayU7uod7iR/pYu8GMn/ZDCtQh9mfnfghJLT x7A7wAf9WUq4lnrJqXfADeXcPC4YFI++CJH0O5Syf8nalDmKqztxZdeATm5d8V+FrgNp RMedTVN5vO47M1WzPxnccfphC7k7kG9EZ1ut90fsv0Lee9Vs1kkJLqUqoV//wA7CUQjz WW/jMrXIL7Si7LKXiYVgfgwFNvd7lMGZr9mQYHKcwvxsGdWBBSeT6BPZ/hc/j2bgb6Gd w1pX1v4UEiV04Ooy966Dq5pZNFVEEU9/SzYowqnmQH4mRE4F6J0Nl3Q22pQzhm2jAehL F/5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eXOyf2Axg9vbweqRF85gRFPRys7FD2K3wIzrdoghDjE=; b=qVjPnsLUKryLJGh41JaegNn+ZMf7eHyy9lrMRTYcjpkSgp5B5jOCfw6njSrLv9T9LL +vyBxGtIYZhHKFnwm21aqYw+MgREhCN3MRXzcHZjrf4N1qDorG4GMHYIfo5jHiU04Xdm klBxDMC/muzUHbx3p+g6H4ft5ElKsOhRnubMsVmimaIQ2/FJClqcj0YG821Yl5hi5rlz 4nMPjNUDHPwieNtR0sk5cYJwrAsKeDpglA4ehB4HhPDlmSdP80On7Lcc+UYdC3UFwE7e /oP1z+H0BFXyWeGWqDaRLNcfYFNLIKp8NF0kPR9ZJCsACxldKW8EHKS+lkDjPvlQUIt4 9n9w== X-Gm-Message-State: AOAM531CLLQULcaV5dKB+bh7uktkdEhyu1cfhKmSOaymvBQegmrOLWU0 7uxWERQY1sHrvhykp28yLT3G84aMBd4= X-Google-Smtp-Source: ABdhPJyyQVfysNmOcePFx27bxTFG1UOPzy4hO6DgLiIYp5NUkPq9miqXDk1ukzvUPvbwPA0/Rp3xvg== X-Received: by 2002:a1c:48c:: with SMTP id 134mr3536403wme.137.1633082780703; Fri, 01 Oct 2021 03:06:20 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:20 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 08/28] dma-buf: use the new iterator in dma_buf_debug_show Date: Fri, 1 Oct 2021 12:05:50 +0200 Message-Id: <20211001100610.2899-9-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Simplifying the code a bit. Signed-off-by: Christian König Reviewed-by: Tvrtko Ursulin --- drivers/dma-buf/dma-buf.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 61e20ae7b08b..8242b5d9baeb 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -1356,10 +1356,9 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused) { struct dma_buf *buf_obj; struct dma_buf_attachment *attach_obj; - struct dma_resv *robj; - struct dma_resv_list *fobj; + struct dma_resv_iter cursor; struct dma_fence *fence; - int count = 0, attach_count, shared_count, i; + int count = 0, attach_count; size_t size = 0; int ret; @@ -1386,21 +1385,10 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused) file_inode(buf_obj->file)->i_ino, buf_obj->name ?: ""); - robj = buf_obj->resv; - fence = dma_resv_excl_fence(robj); - if (fence) - seq_printf(s, "\tExclusive fence: %s %s %ssignalled\n", - fence->ops->get_driver_name(fence), - fence->ops->get_timeline_name(fence), - dma_fence_is_signaled(fence) ? "" : "un"); - - fobj = rcu_dereference_protected(robj->fence, - dma_resv_held(robj)); - shared_count = fobj ? fobj->shared_count : 0; - for (i = 0; i < shared_count; i++) { - fence = rcu_dereference_protected(fobj->shared[i], - dma_resv_held(robj)); - seq_printf(s, "\tShared fence: %s %s %ssignalled\n", + dma_resv_for_each_fence(&cursor, buf_obj->resv, true, fence) { + seq_printf(s, "\t%s fence: %s %s %ssignalled\n", + dma_resv_iter_is_exclusive(&cursor) ? + "Exclusive" : "Shared", fence->ops->get_driver_name(fence), fence->ops->get_timeline_name(fence), dma_fence_is_signaled(fence) ? "" : "un"); From patchwork Fri Oct 1 10:05: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: 12530151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDDB0C4332F for ; Fri, 1 Oct 2021 10:06:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB0356023B for ; Fri, 1 Oct 2021 10:06:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353463AbhJAKIR (ORCPT ); Fri, 1 Oct 2021 06:08:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353407AbhJAKIJ (ORCPT ); Fri, 1 Oct 2021 06:08:09 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D89BEC06177B for ; Fri, 1 Oct 2021 03:06:22 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id b192so6812183wmb.2 for ; Fri, 01 Oct 2021 03:06:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4oUqNlwRJHuQB2mIRsKmTeRaOwkcWmdtZ6villVsEcY=; b=Czbm+9usHUFKPdcRQ2WYOrvJ0RF3b5jz4tkhBVrUnY2ybN33X6b1Z4nJz/DRThDH73 zHa1Nl9QIRSpHLCYzmRlX+4bO5htIukCw9FoCdKjJhsfNHSQNNscizt7USHQqJHzGS+9 HCx/+vA8WPC+IwhVRd0tNfZ3Ah7mWuZwjFn7V3UMrVPOJxQ8ZTuGIBw1jZNUxOvDjlqC CCLOnn88N5PZSNwYlWYoHfHiJwJJoSOSGHBlCViLCGwdQHSBll26BgvmwyZLMDI03nQl gOqnG3BlTFz2rN1HyBGMan85SRQhjRX2BRi3NN83iwEEr7kej+4o56DCBhas/5W2RTJf zRnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4oUqNlwRJHuQB2mIRsKmTeRaOwkcWmdtZ6villVsEcY=; b=wghHFIDdOqE6Kh8BEJhw+KfRlvUZco/nq1acu0lZ+IY1yC5JfblFY6YEBS15EcTcqE buohQl0r9qsw1FocUwJk5w6IBO4G/SXhsdGXrU+7297Oei6VnHr34Yl4/qiclp94jMtg WBRnlrMsgTNkilOMMvxFPDlekK2305SpP1x0IJSfrh3XrAtadSuqqu9nUuKABae0vQLU CIq5IJ8ubdYADzoqLAp1eavMJoowuzh/pe1+YGp6T854Q/6dA67hwiYplU33FOeFFdp8 sjzyrfIRfN8zA23RjCcm9u01tr/S0/ZBCLsVeblgiSue40ozpdFogqIOfhAW5oF8yeK8 xzBQ== X-Gm-Message-State: AOAM530ooQBdBeAPpu9JjHyALnwjujTunBxQ/NwCtK8wje8aKKCKh2Wd 7Rg6r6YnG+4qkZs78tw78xo= X-Google-Smtp-Source: ABdhPJyJ9+sUT94cagH8ST7a3wE9TSF5SLVIKCTHVtTtHAGvOEn+x/WN9d8Ez2+gly8HzfXpfBGnTw== X-Received: by 2002:a05:600c:4e93:: with SMTP id f19mr3535149wmq.185.1633082781519; Fri, 01 Oct 2021 03:06:21 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:21 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 09/28] dma-buf: use the new iterator in dma_resv_poll Date: Fri, 1 Oct 2021 12:05:51 +0200 Message-Id: <20211001100610.2899-10-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Simplify the code a bit. Signed-off-by: Christian König Reviewed-by: Tvrtko Ursulin --- drivers/dma-buf/dma-buf.c | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 8242b5d9baeb..beb504a92d60 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -209,19 +209,14 @@ static void dma_buf_poll_cb(struct dma_fence *fence, struct dma_fence_cb *cb) dma_fence_put(fence); } -static bool dma_buf_poll_shared(struct dma_resv *resv, +static bool dma_buf_poll_add_cb(struct dma_resv *resv, bool write, struct dma_buf_poll_cb_t *dcb) { - struct dma_resv_list *fobj = dma_resv_shared_list(resv); + struct dma_resv_iter cursor; struct dma_fence *fence; - int i, r; - - if (!fobj) - return false; + int r; - for (i = 0; i < fobj->shared_count; ++i) { - fence = rcu_dereference_protected(fobj->shared[i], - dma_resv_held(resv)); + dma_resv_for_each_fence(&cursor, resv, write, fence) { dma_fence_get(fence); r = dma_fence_add_callback(fence, &dcb->cb, dma_buf_poll_cb); if (!r) @@ -232,24 +227,6 @@ static bool dma_buf_poll_shared(struct dma_resv *resv, return false; } -static bool dma_buf_poll_excl(struct dma_resv *resv, - struct dma_buf_poll_cb_t *dcb) -{ - struct dma_fence *fence = dma_resv_excl_fence(resv); - int r; - - if (!fence) - return false; - - dma_fence_get(fence); - r = dma_fence_add_callback(fence, &dcb->cb, dma_buf_poll_cb); - if (!r) - return true; - dma_fence_put(fence); - - return false; -} - static __poll_t dma_buf_poll(struct file *file, poll_table *poll) { struct dma_buf *dmabuf; @@ -282,8 +259,7 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll) spin_unlock_irq(&dmabuf->poll.lock); if (events & EPOLLOUT) { - if (!dma_buf_poll_shared(resv, dcb) && - !dma_buf_poll_excl(resv, dcb)) + if (!dma_buf_poll_add_cb(resv, true, dcb)) /* No callback queued, wake up any other waiters */ dma_buf_poll_cb(NULL, &dcb->cb); else @@ -303,7 +279,7 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll) spin_unlock_irq(&dmabuf->poll.lock); if (events & EPOLLIN) { - if (!dma_buf_poll_excl(resv, dcb)) + if (!dma_buf_poll_add_cb(resv, false, dcb)) /* No callback queued, wake up any other waiters */ dma_buf_poll_cb(NULL, &dcb->cb); else From patchwork Fri Oct 1 10:05: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: 12530149 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F550C43217 for ; Fri, 1 Oct 2021 10:06:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A3CE610C9 for ; Fri, 1 Oct 2021 10:06:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353406AbhJAKIS (ORCPT ); Fri, 1 Oct 2021 06:08:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353411AbhJAKIK (ORCPT ); Fri, 1 Oct 2021 06:08:10 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B87DAC06177C for ; Fri, 1 Oct 2021 03:06:23 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id m14-20020a05600c3b0e00b0030d4dffd04fso1049132wms.3 for ; Fri, 01 Oct 2021 03:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3Ayg2vtlIruNC6YCBqNsxWyZiGKufnG6wJQHZ9LfwL8=; b=K00QXrgQxZygBJhqldjpdmwq0Z5FQMgADFlRfTssTKaJE3iovqCn0W1uWy/liFb27G sRmAAVDGt10vOqAJN0XqaYtC7FbPeUEetGV5wXz82aJ1DtKUYn9lbgVZn6BaKXJuKOML x8ozY++DPIsV7PPpHPTt9h9iinHbivfk3NL2ifluDQ8edJitoGOmN5bJPKiU1riKJqvU 7rmcZWL3h1FqkMXqqcvTUv5ANiq3XXBvjTtN7DeD4CD1j1FcN6mW2FYMXurRwYJMibFk A3PYLakR7Nt52UVSXLXGwoSgLGCmH5XuwoUIEgI0I//exVwLlvDSMoIUatN/5zgo3MbS uPKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3Ayg2vtlIruNC6YCBqNsxWyZiGKufnG6wJQHZ9LfwL8=; b=FFmjH9pdLp/Y2N6lbSQkLFEtV4kFdHYAxzJmbcqzBXv1BLLwAejO8yC+5BJSXS5XkH T2g2T+fZJF3Vuu6EiG6TBhN0qcHJqW0ZU/LeWY3UDvy0Siyzr8+dxoxHZv7kPGQ7MhcL QqNf+mC1ZEmT3hSJhHGRNojjOKJJySeHo+9N5aDecQ8ARG4D2b3bkPIL+k6bsBh+rkrC N/72nlswZPsJ4OxbZ35uCB1pJewZ7Aq9651Kiblvp2uz/KR6KYmJ6oBQQcI84nJkeVWP q4tRSHgVHnvoUtZOmD0/d8vn5KFiXAJ86aXDvR3xM2z2mfPY5UZM1Mu3ex0OA7XFfY7+ GjsQ== X-Gm-Message-State: AOAM533DFyszGUEm3Q4vBPVrbh04uwk5Kkm4XsfQ7a+pZnyjuWeR9UQS duVSribajXZS5quHxzUm6nIxz7pS4tE= X-Google-Smtp-Source: ABdhPJzKkdtSodQ60XlSPJX3CpAQhUJ5wkBsX+8uyL9AlLN6Kemxmfa1pWO/5mr4TwWesK30VX9KFg== X-Received: by 2002:a1c:7302:: with SMTP id d2mr3614174wmb.92.1633082782335; Fri, 01 Oct 2021 03:06:22 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:22 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 10/28] drm/ttm: use the new iterator in ttm_bo_flush_all_fences Date: Fri, 1 Oct 2021 12:05:52 +0200 Message-Id: <20211001100610.2899-11-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 d62b2013c367..3934ee225c78 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 Fri Oct 1 10:05: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: 12530145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A828C433FE for ; Fri, 1 Oct 2021 10:06:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 88B0C61A63 for ; Fri, 1 Oct 2021 10:06:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353441AbhJAKIQ (ORCPT ); Fri, 1 Oct 2021 06:08:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353413AbhJAKIK (ORCPT ); Fri, 1 Oct 2021 06:08:10 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AE0AC06177D for ; Fri, 1 Oct 2021 03:06:24 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id a18so2536889wru.4 for ; Fri, 01 Oct 2021 03:06:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RSipxlf8Rt1aqHkUOElk7qKJcjfTHCxexIhn6lnwGw0=; b=X3REhpDlVS9wIOne/RNjbJmWqf4pS8COhuSJuljJkQs36loC2xUyvxhwrAkwFnXfQ4 WhItcIOHXFQ+J/XU0dNuURjauprDX/PchS89rW9dl9Ph5q0AYkizqqR+Ckkej4fNU5ze 2UeyStYcoP1QsJUzuVa8cKuUZHK1siDvXW3xdTHwoz33ZHZrVx3HeE2PVSf09uSfNGZZ MN1mRHOGXjlW0E/0pHkO/Xf++MISf45UPyhYro7bkuAdoeQD1kVuc/FrIeGs6Ggm25SY FGgt5GB5ffo9/rdXivPFP5HvW4O1sZ9wedRGj4Kq4awx/lDT7C+aFKSZfSUR6wqo0rIn bw1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RSipxlf8Rt1aqHkUOElk7qKJcjfTHCxexIhn6lnwGw0=; b=pJuO0SbN1ZvPO+6svPCx3WIy9SR/eiMBCz/MeeToJg9PqfNPlx75VEWrMh3+i7ODKs PXz9/A6S2GM9dcAb8gESYFf2CnKvWvfQ8FRaa8COMISfwFT0u7xEL6IKGzizyKybx3s4 8PzCb4oQIgtkGCur6L74nzdfS9rTIjAiJ0NqC7qNcbOltXQ/8rZGc9eRAqkIkspFth1u m6Uxce58EgOBjkOcAa8eczno7Yox8b1R/0r1wi97Z7YT5K6X96aksI7l7+JO4n6iBK6x rzo4tEmo1Ihy8ysZ+srfYxUKixIgsdG85DEbRlQvF9S/eGPvAd0KMMhbmyEhgEi832+w OWxQ== X-Gm-Message-State: AOAM532ubdjnmAGMxYwoozI8V9w9nftmmsFNKoANBR7rJ41DKGIykw1F wlWOAPoZpBoSfYj6wA4RxAw= X-Google-Smtp-Source: ABdhPJxkclJUwXiD8adtQWL2MmswZa03hGkkN/MaPO7pzJbsoLrk9yT4EdDewfRqp5qIEMwOCW0Xkw== X-Received: by 2002:adf:eac8:: with SMTP id o8mr10547558wrn.273.1633082783149; Fri, 01 Oct 2021 03:06:23 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:22 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 11/28] drm/amdgpu: use the new iterator in amdgpu_sync_resv Date: Fri, 1 Oct 2021 12:05:53 +0200 Message-Id: <20211001100610.2899-12-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 Fri Oct 1 10:05: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: 12530147 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B865C433F5 for ; Fri, 1 Oct 2021 10:06:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 14B3860187 for ; Fri, 1 Oct 2021 10:06:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353418AbhJAKIR (ORCPT ); Fri, 1 Oct 2021 06:08:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353412AbhJAKIK (ORCPT ); Fri, 1 Oct 2021 06:08:10 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AEEAC06177E for ; Fri, 1 Oct 2021 03:06:25 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id q17-20020a7bce91000000b0030d4e298215so810294wmj.0 for ; Fri, 01 Oct 2021 03:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yabWm1MzZV7BE4HotZc9CHXB10OboyyVoWyddM9btKw=; b=Qjc1wIHm7C7+FZ0zf0J37xwTtZPLvOO6ASxDvrf3+VcrFSzE2KmeNFyiQaE/Vl+Rlq Jx8kk1cYPA9lPwImZ1HbLMioQPlM2SjpvNPVxIxJBpkB8GUbwvvObtiKWmwMYipkoOub uT6mAfqw8T6viENClrMypA9d0xMDMZ+/yfHRCaWYevYJyI1Is/7lIqgbFJye0EzBZk+L 8ySgBLZ2PuMN1K4kXFltYLbBP9Y4Fhi1bIWjh6eoU2jvmPteWnEA7hb2fVoO2a0Lp1eX RDZu6OZZm8gVpIB8h+eQqnKJI4oKdq6bepcKhAJ4cXMWNn3gAJVsXB/hmshmn+ZWnSh0 lPPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yabWm1MzZV7BE4HotZc9CHXB10OboyyVoWyddM9btKw=; b=J2/paFn1+0oaxD+YfmdoaFgnYCT7A4j8HZhq5o7tG2NRbCTjmufm7N9BOxB68AxeRF xB9gQNmLUksJWjUSYqoEeQY2nSdMvwWFpJCN7LbdlZXnjUG1dEXCq2uP7iMRJ53/xlL3 PbtURxNi6rBRjYch9Td8ZxXendQkB7waGKvt7mHLTjeAV18tOyQiqm2cySkdfOIzD3IJ /mxnuFzOGq+sXOM/JJ2MkE6VRU3nbQH1w2U+SGWt8T4/ok4DSaC6JQ57PRVt6L6oGxjq quky9c79uvr+ZUwRAg8mjUvRv+8isYh7VPTT+wYuYZwJ6QV7URpMk4Gfdb41K4oCTLZB eZaA== X-Gm-Message-State: AOAM531oOEk2tDE6Q0o4whlFBG5GOs4UaTECXq8RQS8yMnr7WntaBXeo QiM2BCAUgaILSg4IBGdSMbc= X-Google-Smtp-Source: ABdhPJxdwp7ya/4uzZlQK5Pj4CHR/r3oHjNKAdXCi+hVDyDFWhNfKd+r+tsruJgQprqOmZaeu4PP9Q== X-Received: by 2002:a05:600c:190c:: with SMTP id j12mr3706058wmq.122.1633082784009; Fri, 01 Oct 2021 03:06:24 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:23 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 12/28] drm/amdgpu: use new iterator in amdgpu_ttm_bo_eviction_valuable Date: Fri, 1 Oct 2021 12:05:54 +0200 Message-Id: <20211001100610.2899-13-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 e8d70b6e6737..722e3c9e8882 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1345,10 +1345,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) @@ -1362,14 +1361,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 Fri Oct 1 10:05: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: 12530143 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 371E9C4332F for ; Fri, 1 Oct 2021 10:06:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 16DE46134F for ; Fri, 1 Oct 2021 10:06:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353401AbhJAKIQ (ORCPT ); Fri, 1 Oct 2021 06:08:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353441AbhJAKIK (ORCPT ); Fri, 1 Oct 2021 06:08:10 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E1E3C06177F for ; Fri, 1 Oct 2021 03:06:26 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id v25so3996487wra.2 for ; Fri, 01 Oct 2021 03:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SQ++zZ5/yZpkHj9Fw3rhcDISIEh5bldO1ALOtoZPTbI=; b=UM9ChvMCzLT/g8BK9R+hJGTlCze07DoZNWDU6c6Ol7XK9CN8E7G/NDBOy68ZmnBWbL FdmoJfKtb08w1sd2JBTYvWIS/47VdayqpbgelyFBI8VQhyhsGjl/a6yquVUjPljiYqP4 ixAz0EfAwK9ew0WXQzaGkhQ56HlqlR0NNEZr0drGUMyx622NRL5Wsmrh8OTAof2cY0tl fkvF4y2skFIQuVa4k7K6VSWsHJ+e7cRQ4FsFnBqPZsBrRBTuJrxEFskLK/q8yeyIs1Oe U+m+rJTYSf1ZI3mJIVd9Wn2lclW6D8aV9q8vdCy3YLgTzIRuqP1OuiR5+9lX36OceQid 3bRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SQ++zZ5/yZpkHj9Fw3rhcDISIEh5bldO1ALOtoZPTbI=; b=xMyIQzxNaLtrzUTf6IYGVXMmZ74lHm6AIPC1Fvm5JON5y157HnvXn5Dq8VY8sQWdUU EVCnS7yKZn6oZ/11S6EwX/is/z+FtVxlFCKrA+I9N0NlrvdLOZX2edfbvoaNwd84j96/ EMcKm03cxTFmRxHDGPNuR4IMIpkBGDBEXKZK867O2MtWo1c5r0GNU25UVoqTnidhYLrd Ql/4XUWVtJAUQNoo6sCWka3unaal5hlXlqpRN+LS0I02/SkbczsyLk+7o/SyMTfLLsPA +yvAtAQbmiYId6bbcjcTLFPfJX+I56lt4vQ/EqFXZeRguWe5yztZLslqDrjmZjit3zEd 6+EQ== X-Gm-Message-State: AOAM531PXikBYBJocE0efikzj4ttjhLRdMC8IHYbqHDR7KdQNdvuL/jw XawBWtNtmwQ+qtGwnIz0Q+A= X-Google-Smtp-Source: ABdhPJyJUBOE+MiUZvzQD3ius4Snchh+gNRDbkZW1bywtXNIOwA7EWH6bn+BYDWERd9AhoOYOXe1TQ== X-Received: by 2002:a05:6000:184c:: with SMTP id c12mr11577197wri.150.1633082784866; Fri, 01 Oct 2021 03:06:24 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:24 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 13/28] drm/amdgpu: use new iterator in amdgpu_vm_prt_fini Date: Fri, 1 Oct 2021 12:05:55 +0200 Message-Id: <20211001100610.2899-14-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 Fri Oct 1 10:05: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: 12530137 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7BFBC43217 for ; Fri, 1 Oct 2021 10:06:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8DBD561A63 for ; Fri, 1 Oct 2021 10:06:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353489AbhJAKIP (ORCPT ); Fri, 1 Oct 2021 06:08:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353460AbhJAKIL (ORCPT ); Fri, 1 Oct 2021 06:08:11 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14C01C061775 for ; Fri, 1 Oct 2021 03:06:27 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id j27so6842180wms.0 for ; Fri, 01 Oct 2021 03:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=svmFiiyBNTOLlFWjgaUjcSSYX7QcL0TbCV34MdRHULg=; b=SeWOp56Q+stkLUfrHU+2IN8GGPWI9v1emdLlba9y3G4/qG92EwRdVpi2uAIWU+0DN6 EVoVMrpMAxdjoglRFSNcpEEM/fv+jlA3dibG7wUY8366mWI6CtSw7bF3AVicHInB4SLC hi47/Gi3XKBpCOQgoU6ELW1dEEFfAxpmvYaU7cvHPKq9suz0BKa7m7RgcY/ky/vpljRi k3wYL9r9sVEZY8wKHtV7Kzz6qu2ZwBYzalr4o/MGG+VB2XrDJa0zYBPdnovfLxA8FzRt n2Evxx85irE8Z9DNmafJ/7sKk6PBj1woVZvlrBj+Srb0Ge9s8hSk/F5BvqA3X7vvc+Cv tlUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=svmFiiyBNTOLlFWjgaUjcSSYX7QcL0TbCV34MdRHULg=; b=Y5M7nMkZDb4ehF9yOMS7SPURESPbw1aNwOuI5MN04vLwqOJcdz+CarTHjiMJvo765j tW4QmGMC/5XJb6Esz/Gm28rnvw9rZxmwyYVEOA1AMum8wx89VPWaMtTsaIRHoxJMTLeY xWBUtxxAvmyRi4LRCN3UR95DCQe7kCplYmERjK1kUG5gZuMordPbuauB2qttU3fgIT5j bl0VM8YBaAmFZo/kfifDpaw4P/hpYjXVjTykxZYfzZuoNJeo0qb0qj/VrK9jXDzRO7xh V+z4UefG0v7iTV0ZYQXY14b/LZGC4Rn6JvCImsEWd0VV7Jo0nlFohDag2wXWwCGa8xBk AOBA== X-Gm-Message-State: AOAM531UOr+QkhGIvhKbquuMf5YQbrRY6ogyJ/xI9y+QWleDyDhn9xJS x8m8W6RJMqOsHt+yGG7S25TMXyijLEI= X-Google-Smtp-Source: ABdhPJz5GdBwInX0HcHiq4cY5DrVsDDxvKbmevZjVBxvxPTmRIsT0zcitxa6m+x6ZMvly0w9A57eQQ== X-Received: by 2002:a1c:a387:: with SMTP id m129mr3546114wme.181.1633082785686; Fri, 01 Oct 2021 03:06:25 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:25 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 14/28] drm/msm: use new iterator in msm_gem_describe Date: Fri, 1 Oct 2021 12:05:56 +0200 Message-Id: <20211001100610.2899-15-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 40a9863f5951..5bd511f07c07 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 Fri Oct 1 10:05: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: 12530153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9B3EC43219 for ; Fri, 1 Oct 2021 10:06:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D60836023B for ; Fri, 1 Oct 2021 10:06:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353458AbhJAKIS (ORCPT ); Fri, 1 Oct 2021 06:08:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353469AbhJAKIM (ORCPT ); Fri, 1 Oct 2021 06:08:12 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED400C061775 for ; Fri, 1 Oct 2021 03:06:27 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id b192so6812331wmb.2 for ; Fri, 01 Oct 2021 03:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IkVWp2cRgm41mlWFdiuPcdEqOEMHJpLCxm3yFN2dD0Q=; b=ggVb8tFWsym5tY2UFXYnp5/+wnnhdTTKklDhpXqU4dN2UZhBEMrcl7xcSW2VYnX7is umf7OVYBxPyMxyUR/5R2qTniROZiQo6IJrBeun7y5YjQZ/wYsR8EHazV7oevOeyxLRaA ilEl7koiJasAEhERC/Sd9DHlEAcbOxoeyRcAU2PH+ksfq9swgrHqYgV4/Rn7RhfWVkJu veQgyB7FNey0VjLsgPOiIn/ZIslZUF0fF+GPAK45UoERalsc1A1MPm7cpaudMkJjn+2A eWrNMlXvm6RvQDbesUW/VQdlMi+aEzSk+RVQdBcHw84Gg3IIc04fhqrwSe3KTRfICUID 2b+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IkVWp2cRgm41mlWFdiuPcdEqOEMHJpLCxm3yFN2dD0Q=; b=uP0NmDGF1eNmXGk9kAgWEOKACf0mTOe3foUcvXShYOLdzkpc7ra5YVrQOxZmtN0pJQ xoq/PVUbqWvFpp+YPx9YOvE9nLwXtGBXFtkjrpePQ4wIYhpr0+y1uQg03GdrQF3UXD6S ayt58xBopgRIXFDNbcvghht1/dpl9uutlXV21LoFKxJKxqUzadkB9ypgbZrOP8WCjhU6 vbEfTy4bTa5CHQzbH0vj2GGZ0xddrstlLEHAoVESWAfnZLRO1v6hb1urZZ3d8RVyH75F fayif3/RPco19SY1xna3wWhVI8/4TN/JtOR/U9RF4LmDU0csIw6QJawLazBtS3N/v2Oh 5GBQ== X-Gm-Message-State: AOAM533V3XqKoQIvB3xP/YqS4eYTN25mYHQFymwW0h/+7GJE9trm7FeJ qSdSfcv7p2NHiL0frGTZ+GA= X-Google-Smtp-Source: ABdhPJzFcEw39LPJdVp2bONu8d449hKR3YKtBopmWidnNRqiFqYpNm90jU1PdtiKjjOLulAqsyODpw== X-Received: by 2002:a05:600c:a45:: with SMTP id c5mr3574645wmq.79.1633082786509; Fri, 01 Oct 2021 03:06:26 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:26 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 15/28] drm/radeon: use new iterator in radeon_sync_resv Date: Fri, 1 Oct 2021 12:05:57 +0200 Message-Id: <20211001100610.2899-16-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 Fri Oct 1 10:05: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: 12530155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59AD3C433F5 for ; Fri, 1 Oct 2021 10:06:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3561D6134F for ; Fri, 1 Oct 2021 10:06:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353469AbhJAKIT (ORCPT ); Fri, 1 Oct 2021 06:08:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353476AbhJAKIM (ORCPT ); Fri, 1 Oct 2021 06:08:12 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFF4FC061775 for ; Fri, 1 Oct 2021 03:06:28 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id d26so14611406wrb.6 for ; Fri, 01 Oct 2021 03:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=d730QTcA12WB0FxkhM0n+vEOwpHIgTa3YH56dqVvnac=; b=aLz6htSFtsiJnmZk6iPAAcargupnOFJsx0x5S20/nkp2OEcsstBr3b46ddds+UNSB+ kPQgf7O5UHAQyWsoRD4CbVGZyrHxHCY+V5qBwggSJkqt7dQjdnjQ2v287HDIUs/smbiQ zWsSDNB8ooRKxv60yqwYZHnzZYbeocAIJnmG6ELZtaJHUnCV7jlPCtjjHcrYzhS9b+Ed FNilwvj+wOLBK/f5gTC1VDaltB0FO9qldFrYqbU4MWQRycQaH/qWFCutT7+tH7BOw4AT OH/y7bZyJSY8mKvGlf3p2zcgvJiDMV4G9LDbbYWf4WXP2N79Gh9uBgaXT3uhY4WnKWSK HI8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d730QTcA12WB0FxkhM0n+vEOwpHIgTa3YH56dqVvnac=; b=BA1OgKJGSHor1eQw9Auh+hZbgAfiVX+31hsY6a9aM1nhSeFu7mfEdHmZzZYrK8uOso WlKdOkRw8QsKqyzjlyqHXrleYFB5YwGOxHMXv98eTReFiBV+WzH8Bt7faIoaN8DUsulP pZ2xRkEeGnGu5R/Kx1hskbUGuRJrf4FKweNOr/zfnI/vUQWOKM97Umv3A8gR2jX8njca YH8dbP/n584eg3/yt1j3oh5IQ7n3cechUG6e1UDN0QiVvLiIoCAlupTbwHH3wZrw20W3 w9P+r38KO2OZneidJaicOjjkftaKWQiLhTnfLjkr/GBc9+irFU8QmYaoM9KS3GI7Oy1n z0aw== X-Gm-Message-State: AOAM530yxm4Ewij/ywD47/VDxxDXB9a30aVtgtUyfAiS1799nv6v/jJr ftOEyq6wMZQz1uve1Ordwic= X-Google-Smtp-Source: ABdhPJwgWXQpla7lMGDPPe0fAEP9N6dAexMHV3C4YjWZP22yd+DnwSODgfTN4bxkkGbD2Y6yAclTxg== X-Received: by 2002:a05:6000:144e:: with SMTP id v14mr9975574wrx.228.1633082787356; Fri, 01 Oct 2021 03:06:27 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:27 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 16/28] drm/scheduler: use new iterator in drm_sched_job_add_implicit_dependencies v2 Date: Fri, 1 Oct 2021 12:05:58 +0200 Message-Id: <20211001100610.2899-17-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 Fri Oct 1 10:05: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: 12530157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCD8DC433FE for ; Fri, 1 Oct 2021 10:06:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C7D8860240 for ; Fri, 1 Oct 2021 10:06:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353490AbhJAKIT (ORCPT ); Fri, 1 Oct 2021 06:08:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353483AbhJAKIN (ORCPT ); Fri, 1 Oct 2021 06:08:13 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0D73C061775 for ; Fri, 1 Oct 2021 03:06:29 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id d6so14550041wrc.11 for ; Fri, 01 Oct 2021 03:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9ue7puBcgohS+7D/zNLeUPSF3Sf1Ar8z9127abKsq3w=; b=ZsjIr/vefBbHHiUwrD7XJy6MswdJEEhiBaLuWXQmIOhOiycUXnK4K0Mr6yl3X/ZLXN 01ZHFiF7Bcchgp+oaYJ6GzVkisSKo6t3pZKQuA1E4988bGs6bEeuPLIDTWv6oWbmD5AC YokBuiOn3ytUFAvyaZH6zfeVIRuI7sE0ZjbAEiT9tUi/VWmFAyYZIrIuUSCPNFwoSOk7 knnoQIZICNp7V1xeCANmtyScQ3pL9y0AdIHstGD1+yFaUjG/KmQ6mbWLKDNR95opqfMI rVFjPTkPYXfVxv4pwgc96ORquSUQO2yvHhwsqn8AQQbBhT6+5PC6Nw9+Yki15qkSQDai P+eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9ue7puBcgohS+7D/zNLeUPSF3Sf1Ar8z9127abKsq3w=; b=VprkX0l/oTWxMUdQ8AcnfYoruGimD1TXc2xmqy7CHiDgPAujn/84ERvkyiJAgUVkqq p5/acGGgDyV8O1CpyV5DY09xy+sphDOt/QP22QPkY2yVI3Pjr1pI5lQUCMgKShvyr63t fDJuaYaM8ZS46ELUyTFfbYoyqEdCgudr06zlplXC5JDAD2NtqvRbOYRDhvhyb371Fwgb I0zNcOfgoCFYzK2ujua+cT4Q7I3JKcnxgT1d1z9a9tYGEZtPRsG/Ef8U2yKSST+MN3PT KlWs30PvaG9qfXUQMnQ1ohAIih9qx/Fziyk8wKYY130oNydFvNFLC4rH4JznHKBTblcr CbSg== X-Gm-Message-State: AOAM532N2d54d82zsPsqXodccSBXkFgOzhQoqjxYwCfk8FNXLeGPCOdw rhT2y80aqvHmE1D1f1klQik= X-Google-Smtp-Source: ABdhPJzm+9VExwWXqnVNs6G8xbrEIBMs86W03GOK95wzmAH6ZIKsuQCZRsC1otcFgzk6whqQoGRC0Q== X-Received: by 2002:adf:97d4:: with SMTP id t20mr4627990wrb.34.1633082788233; Fri, 01 Oct 2021 03:06:28 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:27 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 17/28] drm/i915: use the new iterator in i915_gem_busy_ioctl v2 Date: Fri, 1 Oct 2021 12:05:59 +0200 Message-Id: <20211001100610.2899-18-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 Fri Oct 1 10:06: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: 12530159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78FBAC433EF for ; Fri, 1 Oct 2021 10:06:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 62511610C7 for ; Fri, 1 Oct 2021 10:06:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353483AbhJAKIU (ORCPT ); Fri, 1 Oct 2021 06:08:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353386AbhJAKIO (ORCPT ); Fri, 1 Oct 2021 06:08:14 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76071C061775 for ; Fri, 1 Oct 2021 03:06:30 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id t8so14655903wri.1 for ; Fri, 01 Oct 2021 03:06:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s+B96AdxRkADIO5Sz7pGY2LZZPwHDe6rOqsFSHpv8M0=; b=AzKiJlwT3VxO44dRR9XUeDPKxjRN3IWI2nv20mvSeTTXH4RstYBlN4dN50+WShjt13 fLz4+VVBKSv/KrO6M3pX63u+/9u+Ctu4DKJRMkTBMEfq1E5ZMinrOVvpnl6fxWtMC2LG ZeRqoQQ5bN5nXzkVrJTcWHSnhGtGOYrl9UDbN18jxzJxew/l1ZaWTi+hnVl+GxOsMWHZ QcUJecwJSuCF6815sP/fNKt9yL9mEthSWDrkCUEyTscCd2PSwvq8KalGHjz3Hko8ypli 706GmZTT14mR3KyVQCAB4xnYQ86Fz32DPqEVlk/eSNNKXoQJnR+N823QVg17+8xgzxmF hBSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s+B96AdxRkADIO5Sz7pGY2LZZPwHDe6rOqsFSHpv8M0=; b=ENjHasRFgYZ7Vxs8o7xL7hGf4Kta2NjsGAvtimaRSpXjYXBuZBQ4H2sixoOxfmFy/v aWlh7cnB3g8rVHmp8giGJF8L66RfZ9yL7NmhSiFsgPVO9Keg25mrM90/sNk5ZiDTk0rG i9uF8+g5CaSyy4aJebSmCcCIlRt2KnISHFHrUMpZdPMQi7txO8RUnDkC1Hxq9GKUqEHo k/wtD+j12HJ/32A4NbQgmZDiNiOFou4dQbKHl9xXQrrLpEPokpJc3G1nF4qdH3E2ejoX nntcLLYWLlixdusuWwpt+3UiNPXS/5U/B0E+6UH82CCpqHgnn75lLo8x/SIntGBdsE7c nE0g== X-Gm-Message-State: AOAM531O2QETaOmAK8CXhAXwkAdktCZrTs4NsRoFt6o60nAbxk3YDDll l4SsBapiMjCKe8MTZxdZ7b4= X-Google-Smtp-Source: ABdhPJyStwefq0t9iGN9OcfJ/7fDO+KwhT1qseTmxxqq08hFNrxxVRmAQiqqNgPam0/3z7wBw1f1lA== X-Received: by 2002:a05:6000:1569:: with SMTP id 9mr11473987wrz.337.1633082789101; Fri, 01 Oct 2021 03:06:29 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:28 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 18/28] drm/i915: use the new iterator in i915_sw_fence_await_reservation v3 Date: Fri, 1 Oct 2021 12:06:00 +0200 Message-Id: <20211001100610.2899-19-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 Fri Oct 1 10:06: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: 12530161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24181C433F5 for ; Fri, 1 Oct 2021 10:06:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C2E8610C9 for ; Fri, 1 Oct 2021 10:06:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353472AbhJAKIV (ORCPT ); Fri, 1 Oct 2021 06:08:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353394AbhJAKIP (ORCPT ); Fri, 1 Oct 2021 06:08:15 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5542EC061775 for ; Fri, 1 Oct 2021 03:06:31 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id m22so9154568wrb.0 for ; Fri, 01 Oct 2021 03:06:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y78+lw9uajwG2nya7zXv9lL0eVUeHEAbTx0GIeLnzI0=; b=BP6jRFQE6j4XrQH1SqYs4MKpf087zibEfrPSq4Yl8tJ6hUX1Ct8GXdHKSdGUctrhzh MCea6G8WbuliBoevLNWxXBhVNzlhG2fB8TysQ0cz+JfdOUNjAHSFtknVTzVLnzXbNIrM RJDLwKb7N7t0O42P4/jYaZhwS7L6jGYoqgNLG4KXhMjl1BMQ5dNJ53PFlPZ8UH1D7x/V b5wgjp0a/CSZvGmOUZ7r4lnSgUdFysONd3bqENiql/yc76UMLPs6yWx1kCY6xZYKWsoc S+X/uiLbvXDSgVKviXTmawH8Q6LDskU/tJu/MnrL459scjRVUXqQuN4zsoiS29dOKwYT zb8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y78+lw9uajwG2nya7zXv9lL0eVUeHEAbTx0GIeLnzI0=; b=UEttBMwAxCHzeNxenWRBNWQ2etOrHiX8w8vZEYMMJb3kHzF/YvW2IG2ZB9EU39SqZZ YB10HpbU4e1ZXCSplK4AbAkT8heIdAOF5FeoHk/HU4hv5qc0AIhuNCDQWMLRviwzTpB3 0nUxkVriINCnEOZn6/y7br2ubgvhhEGHIvs5LBylfjXbQYkSx9V+ZFoOAgAoindirHPU RWFq2BITDi7AFB6NVKZI2KQDbefAx6GV0XdMvIrD4+40lnvvXBJRz3WRFGTF9KRDjN+I 4/rdV5/1JwjcjWLm7opr8RSHNkZKZEig+om6qk/rW+Dm5Nxnd2uQoXEBfD6uGXiRez5F 4LBA== X-Gm-Message-State: AOAM533imza70DM4847vEeCSK6ukxG1y5UjH9NMGXoj8L5RalyCAf01d 18IKrRMiIjJdalL+n5VQC8E= X-Google-Smtp-Source: ABdhPJxfUTaPbuI7VagQKKHsUlhxfQWHViZmyo/qnbH0HU/kn19HyeiJwQKHXYxtIJ5amoCPz2Lb6Q== X-Received: by 2002:a5d:6ace:: with SMTP id u14mr11639570wrw.206.1633082789927; Fri, 01 Oct 2021 03:06:29 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:29 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 19/28] drm/i915: use the new iterator in i915_request_await_object v2 Date: Fri, 1 Oct 2021 12:06:01 +0200 Message-Id: <20211001100610.2899-20-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 Fri Oct 1 10:06: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: 12530163 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D5E7C4332F for ; Fri, 1 Oct 2021 10:06:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8AF2361250 for ; Fri, 1 Oct 2021 10:06:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353471AbhJAKIV (ORCPT ); Fri, 1 Oct 2021 06:08:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353460AbhJAKIQ (ORCPT ); Fri, 1 Oct 2021 06:08:16 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A27FC061775 for ; Fri, 1 Oct 2021 03:06:32 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id m22so9154622wrb.0 for ; Fri, 01 Oct 2021 03:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QNte/ZxHyZbzH1TCe5eQqnVIdZH6R4S8//YNPJMBVTc=; b=iUXLLrRCq5VuGu2ExmMH4st6B9HD43VM9DJT6/ZnZvDe5dY8UJcmZw/7bHADMGew98 X5qjl5pixMJWAizCZC+xcI96OQvE1T6Y0Ga2Ev/igknIV+22UlBkXgHS3UVaC699y1BX 2NqO/Y6typ4mrDx8pVzvybXnwv8hy2ijaKmnsAm1KK+raafFRqYBhPDM6Vl2IUSIvvF4 KgT++elvcWdIHjzP/8Tno5yFjM/9+ouQC42NYIPVG+w6++shImH0A0arnN3Mf21HcpW4 xj7STaXMpQBGLXeONOoz/xPIPzLZp8llBiYhbQXvK6Vw88K68eb/EiCTqV8RSpepBYuT FbVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QNte/ZxHyZbzH1TCe5eQqnVIdZH6R4S8//YNPJMBVTc=; b=2WxOaGhP0qxZwIBEfWwFEL6hFO7hUAmzPhG7yZ26dekAZ05WMReGIhy+PEntjYE9EE L6tkp9w25kF6YChSLeCtyDX9vOBUFjAASx0KMatmHGFz+4Er0JGRA57RJrhvyrRIP1M+ cznhOoymUlR9NX2ZdvHHktMv2Zvk99Pk18YNBnG6Qf0Ga5u5Bmk930GCMTRFIkBSLJ3g 3uUQrE0k58cs5QLX1gIJouTOZnMLDauXCxrdLZN2xB/CAWiJETCwDKpKC8CZhjtZofXl Vn70ajZhdBce8/91zeKAUcTIJb9UaLnBisq5VzEhErIZDhRShPkT0ylQU/sdCfCCFwuf 8z3g== X-Gm-Message-State: AOAM530Un6STAvK5Sik9MpMARXTDnGx1vZl6LtXGf1PQ8zvvzO+2w0H5 qzAx+jOLbPMXSe5XTx6yvWM= X-Google-Smtp-Source: ABdhPJy/Lma0dKGkX6dySp/8hr8i6mnCAwx2pE0jNyRvnW7knDgZ2dEgdpqFi27v5N9LBGbWo6v8Xg== X-Received: by 2002:adf:e906:: with SMTP id f6mr11377619wrm.207.1633082790787; Fri, 01 Oct 2021 03:06:30 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:30 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 20/28] drm/i915: use new iterator in i915_gem_object_wait_reservation Date: Fri, 1 Oct 2021 12:06:02 +0200 Message-Id: <20211001100610.2899-21-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 Fri Oct 1 10:06: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: 12530165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F92CC433EF for ; Fri, 1 Oct 2021 10:06:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5C8426124F for ; Fri, 1 Oct 2021 10:06:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353470AbhJAKIW (ORCPT ); Fri, 1 Oct 2021 06:08:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353456AbhJAKIR (ORCPT ); Fri, 1 Oct 2021 06:08:17 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D14AC061775 for ; Fri, 1 Oct 2021 03:06:33 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id k7so14492633wrd.13 for ; Fri, 01 Oct 2021 03:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sR69q70gSeg6sG3/QgjbBFqvIqYfytfoA0SgvZr7HAU=; b=Ea4WSe15oLwwlNdQvSBetjw7fNJ7A/u0TCKXwUS2Vcmu5XZOlo48VdQej41rFjqpqq eYUy0mXBw/fut1muWHXT9+1hqksgRHF+THgYMqbL9k5FUlMmOi1T+aRUA1Y1EWNB8nIg 14CRVkMV35yMz083mG8awueAhh/p0mRuRB4+OW1j7FsMBVOz/VzCd2taDBnx1lfH3izG 5TK658+MW+NsmHWlVc8ztktPuQFIk70ARmz3/5rbvmNDPfiI3J3VHWVzUx8kG/9pz4Og ukqvNwGCE7yyRFAz7fTKND4foPrqoPRCRq5PcO4qzShXhX+PCfN3hn7VHPM1PjmU7din RG8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sR69q70gSeg6sG3/QgjbBFqvIqYfytfoA0SgvZr7HAU=; b=m1s463UkcwddKqjsZqrUSng87Ddp0dF7i/sdngYW+mJyhBYEogq7BHuZs1/Rk8SDST sdprf/irxGbVheRTypEqZmjNJVnQZcyjNQV+NZ/7Ge0lhrUtPuNf+1xnc2ZkIxpJARBx rj6IG4Ve39gCc0Efb7quuK7Mf6nyVaWwj2VYzS8uPVJPhi7ao8dF2AxzOAcht94zAXQb knQGsV9V4OzY4EFKew/b0V4LNyq3iHHInDFX85qEN4nWJR0A3Q1Df8ZrhuJ5jfXPgFH4 Ks3q5LbsN8E+l6tjBKiWZt8J/sPZU2GBEX741K7oGtQtBVmgYmQOtEoN56rVyO/nUyfz LBHQ== X-Gm-Message-State: AOAM533nRtXLPtdlTnBlrdjz0Ug1izUohUDNiqqyH2x1UrVmtZ8Y2sMb rxUirD6r7PrPD2wipVqB23hnnqg5LHQ= X-Google-Smtp-Source: ABdhPJyhTV6eK+nXojv3NtgnfpImqFkB7246DJKrxQRsA2i58ql61cG9cmL2nAfe56n6teyJszJRNw== X-Received: by 2002:adf:a4cf:: with SMTP id h15mr11320275wrb.56.1633082791648; Fri, 01 Oct 2021 03:06:31 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:31 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 21/28] drm/i915: use new iterator in i915_gem_object_wait_priority Date: Fri, 1 Oct 2021 12:06:03 +0200 Message-Id: <20211001100610.2899-22-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 Fri Oct 1 10:06: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: 12530167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 082FAC433F5 for ; Fri, 1 Oct 2021 10:06:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E3E9161250 for ; Fri, 1 Oct 2021 10:06:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353475AbhJAKIX (ORCPT ); Fri, 1 Oct 2021 06:08:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353462AbhJAKIS (ORCPT ); Fri, 1 Oct 2021 06:08:18 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0155AC061775 for ; Fri, 1 Oct 2021 03:06:34 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id g19-20020a1c9d13000000b003075062d4daso6382214wme.0 for ; Fri, 01 Oct 2021 03:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ETFFVmDbRxb5cxrXOen58gkxhSGsPJL2Y8O/7sOAJto=; b=QZ7jIyUtRkqWi3/s0K0fbEd02lkzUinpljPHbXZlqpmhMVHLiSbCFHJYGGybWrA8Jm HmlcLkCjz/B3Fueg7T2MO5A8CIU/W5rd4QtclWoBYabjupoj8UeoRe+umMh0ARSQw0/u LfYvx0aumLyVdqSznnKPD5m3G2+hL4QJPRT3HnfhrMe6+oTZBmZ1CCYjBgEaNjOExPEA sLEBaYfijWq74Ou5RZjifErnWjzojo2EBTlbg1IhoybYLlE2at/N66Jh/qcjIUH8RRmk LIs88T6grbCdFtMQCcdovIRrzZPeQToDAmDTSo6MlGwmippZzNCB4Ffi/D6qJipiYHLB +p9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ETFFVmDbRxb5cxrXOen58gkxhSGsPJL2Y8O/7sOAJto=; b=rLDOU1FxrD24FL5NjdPjsWdv+BrCfPPDMcAeaopticii9PdvaVlQDGEgXs+anod5Z8 bcLpzPcKv1pYQC64+37V4X/VPaK7AgdlO5LVcvFo3KYOFKNbMMvXLjT7lAURwr/PQoLS SLFaSHkrfFRQ0HOLZC1zQ4IvFBTh8Rfyvg2tqfq7qw9iIwCwfaDTaUlC09h0eEAGUbEt qYE8Wmt8AuuhQ+FfrPGnKXvYkyKPHYIxkj1sysa1NuryTqzzHp2evU4ZMEpZUmrDqbOO bkhfN47Q/FQkc13ldH69J/UbdR8j3iKhWT668M5oEJakgr0ZChgwgs+2m6FvPDywW5OK vo4w== X-Gm-Message-State: AOAM5316lq3XI7Es/ReM9ZBIY1BpdA88dvRmXXZXLEml3ohGE3L0eUrp BSxWmYvIelctO3BXfYCdyrk= X-Google-Smtp-Source: ABdhPJwnczMK6QJ2ymumuKHZRC/JtWjIcbjAHbL+u7jejn8qlHzl8dTw34Cn0jdZd2kK2n/HjgmQuw== X-Received: by 2002:a1c:f609:: with SMTP id w9mr3585301wmc.24.1633082792628; Fri, 01 Oct 2021 03:06:32 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:32 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 22/28] drm/i915: use new cursor in intel_prepare_plane_fb Date: Fri, 1 Oct 2021 12:06:04 +0200 Message-Id: <20211001100610.2899-23-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 Fri Oct 1 10:06: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: 12530169 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C481C4332F for ; Fri, 1 Oct 2021 10:06:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 702A5610C9 for ; Fri, 1 Oct 2021 10:06:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353480AbhJAKIX (ORCPT ); Fri, 1 Oct 2021 06:08:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353461AbhJAKIS (ORCPT ); Fri, 1 Oct 2021 06:08:18 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCBE7C061775 for ; Fri, 1 Oct 2021 03:06:34 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id a131-20020a1c7f89000000b0030d4c90fa87so1136269wmd.2 for ; Fri, 01 Oct 2021 03:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=by8trJVpX1Yx/8GVC1WzD9CSlRZcllVkqP6ongV+oMI=; b=KXbwWoEASyQRsPuv46mUDMotK0Bcif+uiHZAp4YIIqwwTbHos+IZJPI4rZHU1TbmZJ 1nJO6fk2NViAzlCQRF5SYfwt2q9eB7Fsb+Pe8b5ffcEcrJO1CcVK8Um2p733gPBiyz9c 0gxWwQfNwHPheQEQsPoaxwI9d16TG35+ISWIdcvyFXtMFR9YpH5DECmihkGTLnLxmw7O +ogdMbOiQ5cX+QDXaJ0THmIjriLY2XxCJ6TXfdMhQLhkDyUwZMC9n5Q8XjjD0wHihjB8 qY5xF+BJcdc4OcMXKvZOc2upqpirE/igGCZCNQcN9SEo5N4RFflm5Q7+B1NZiuzTYc9c xMRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=by8trJVpX1Yx/8GVC1WzD9CSlRZcllVkqP6ongV+oMI=; b=3/GKcekZDtSO1PmCgcrY1l/Q377jf0DTumkWNyZqjoP/bRoANOadtIO+b2rLtKq4wa m8DMhSpnzsPHzcpBzN0/2g9y2KZjIVgEPQt2Oyexv4Hd01iilhx652rwovYma9eW+7pa ZEWwdqIDv1C1VwQA9CLIqNW2k8InLs2AHtslHB/4OSbwN8v/DNJU4p9/7lKjL08pEgp/ AKgPdt45E4PkhgxXHDHQtOr3P56ARoOu6PSEWLmA6eJnmJGgrPmE0P4WnSeh5LtFpgTE kMYYkw2BZEJhAURzIEPOGtuzheqnpJBKc0jN3M4yn3c+Klv4N3LNKH8+yeXNPy6Cr9cm bH8w== X-Gm-Message-State: AOAM533vQGc3w18WauxcfjqsTM1t2r6cdwMuaUeZlBo9bjjWWZltfemX gLbS8cd3bxBBvCiiY3DgX90w7bpP5Uo= X-Google-Smtp-Source: ABdhPJzm+JKATE43IbiivZ6as6JSo9Ps7DVTMr7G6kRy9LrsCmdMBrHvTDiQ4kirIRVSCjM/zx/b2w== X-Received: by 2002:a1c:94:: with SMTP id 142mr3640878wma.87.1633082793441; Fri, 01 Oct 2021 03:06:33 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:33 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 23/28] drm: use new iterator in drm_gem_fence_array_add_implicit v3 Date: Fri, 1 Oct 2021 12:06:05 +0200 Message-Id: <20211001100610.2899-24-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Simplifying the code a bit. v2: add missing rcu_read_lock()/unlock() v3: switch to locked version Signed-off-by: Christian König Reviewed-by: Tvrtko Ursulin --- 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 Fri Oct 1 10:06: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: 12530171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57EABC433FE for ; Fri, 1 Oct 2021 10:06:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45400610C7 for ; Fri, 1 Oct 2021 10:06:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353461AbhJAKIY (ORCPT ); Fri, 1 Oct 2021 06:08:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353465AbhJAKIT (ORCPT ); Fri, 1 Oct 2021 06:08:19 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6057C061775 for ; Fri, 1 Oct 2021 03:06:35 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id t8so14656244wri.1 for ; Fri, 01 Oct 2021 03:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=embkrJo3e9xiJFTU9PfC3+rsuixYC3ybu+PUBE5n6do=; b=Q5fsXjqZacYAaNCcYSLJtyR71stnzbiX9gtPzj7ceKIeRysoqMaOtUNllAvvgd2ZoQ Sc5D057EX2p+NDRuTem2faYmnkbO43kWuIuS+RbsMlLREQ+P22kmAFgGUaFzNec5ugqD OLcj30xorhSLnNJLon3PdbY0boGcwnhVrvYCH2+GauY5bybmqLL9cylzhgca4EhRe7hh f+Ko3Dix7MvOGdih49HSBRBf8jlQIzNadjJ63NOeUnw/DcptLjx6EvXSlvHWyyGq4jac ze1k0PdHgLhw1ssuJI6N5O89xBmMlrlY1L4Tcr8UXVl2/OLehgJE25IVdX+WbI9UVv2A pOZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=embkrJo3e9xiJFTU9PfC3+rsuixYC3ybu+PUBE5n6do=; b=1xYHI8iN4CQh3s82CH9bhTUTcUgtBgGLjXeycG28IwzNPpc0jzVw82SF8MgHiS1Rng UR0R5QIQxLf7MmxMJoO9i3td6LDNe9IlLwWOkyDY+1f3gzCGhFbOSF9eOy/3vVHBOU2o Kv+NgFeRIfDh4WRZWvq4gGHdTCLrIVGzw8VvvEk+oEzxbvFgWdZFamV2j6iwu8E7bGbL RyryC0Rzc9Tt+/bH4wxxixWmBO3Lju7j51L8f26kXCvbfLsz1l4LZa7WCbioLrUHk3xe MEKljwrEi6u27c7y4mje93uIy4CDminXgg7IEo/2hz7fadyhiDrnrPn6SyDbI60L/RSY mMjg== X-Gm-Message-State: AOAM532MXXcNH72zu+GWIVL3xKh48gPGv7CEVp4F58svMNBo/ZcXFbRR 2QkiXQPe1gFF/IDHw/Nu24U= X-Google-Smtp-Source: ABdhPJyyVqiekh0Qo/9t/1Ebo4yekIFwSNoQ4xwKqMx7ARLoWIBrbcftHj6Gp3duatEx2cQ8mnEMNQ== X-Received: by 2002:a05:6000:2cd:: with SMTP id o13mr11033052wry.193.1633082794324; Fri, 01 Oct 2021 03:06:34 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:34 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 24/28] drm: use new iterator in drm_gem_plane_helper_prepare_fb Date: Fri, 1 Oct 2021 12:06:06 +0200 Message-Id: <20211001100610.2899-25-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 Fri Oct 1 10:06: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: 12530173 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5857C433F5 for ; Fri, 1 Oct 2021 10:06:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2F79610C7 for ; Fri, 1 Oct 2021 10:06:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353478AbhJAKIY (ORCPT ); Fri, 1 Oct 2021 06:08:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353386AbhJAKIU (ORCPT ); Fri, 1 Oct 2021 06:08:20 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CD7EC061775 for ; Fri, 1 Oct 2021 03:06:36 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id o19so6826524wms.1 for ; Fri, 01 Oct 2021 03:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/+r4v7UIazK0HaIgNf9t5Xden24q10DFKnoad4rknzc=; b=GEIzzdUFcSKpvoIwIy/MzrJapJAKZntSukZ5p6roG1d5bVF3FTwA+A/81iLTZfDJm7 B14RDR0mktQK41PBvkpcUZEYZaPZ6hyZsZHjxZde46wLYQqRqlTECjtWvnAMkk9RlrL4 PlQRRB85sJS8tCJhNJhAljJg8zPFWdayIFN+7h/y+N1mXlaA5i8uxoUphxVnv25weZp2 z7EeR6gOksmOb2HpP8Nd21+iaqaQycJfOPfM7dJ7g2MRLIQxGhaSBQa1PhmHR4VMqIip Fszd2ATa+I3mGa0kyJb6vrgPEoG/1mKQxtiPPz3rosU18N7AchmnH74E9obNFjBS3I3k 6OdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/+r4v7UIazK0HaIgNf9t5Xden24q10DFKnoad4rknzc=; b=ahji4mVvuYeQhE5zjUJ3abDorSPV0f7DjT+wZWcdJw7UFKpAoUtzn9SycpRcAxrEey ALPg0CWXsLb6Gy3pc4Ho4N2GxPv999z2YQz69Ztugr4Q5nHAH38KqNmxlG6ovzjv9GzJ dnxvYrT8qTlexadFtDlwGjw1L8N4aOanI8VNNGZEWKIg6ZYdiuAyTg9OLWyqumjSJPNn i5mf2nuCsRt7JWyU+CznTHSpOt8ez/pIR1FJ0Pk8aKN+18CSjAJVtchAaKoUoIP5Bd7e CEYe32N5WLWdVxqtEacsLQBX/8ja+Jzhqduc1KKHfu4IqQcb9KZK62ufbTEMUPsVx0hc eN9Q== X-Gm-Message-State: AOAM531a3EqZAZBIR+JvQNc7erVA7LWlaXvIdKgoQ9A5MBUEFEOVZN0S rdVTm3hIQEwBIjaE3kc7+ms= X-Google-Smtp-Source: ABdhPJweZo3sMdXN2Yo33ydRmQ3ZjHih+i0AoWONKI3PwdRb0YyzMGRwcws91yM/HxU4EVObzQH2FA== X-Received: by 2002:a1c:48c:: with SMTP id 134mr3537527wme.137.1633082795149; Fri, 01 Oct 2021 03:06:35 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:34 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 25/28] drm/nouveau: use the new iterator in nouveau_fence_sync Date: Fri, 1 Oct 2021 12:06:07 +0200 Message-Id: <20211001100610.2899-26-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 Fri Oct 1 10:06: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: 12530175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 770EFC43217 for ; Fri, 1 Oct 2021 10:06:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 63885610C7 for ; Fri, 1 Oct 2021 10:06:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353479AbhJAKIZ (ORCPT ); Fri, 1 Oct 2021 06:08:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353492AbhJAKIV (ORCPT ); Fri, 1 Oct 2021 06:08:21 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C67DC061775 for ; Fri, 1 Oct 2021 03:06:37 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id m22so9155018wrb.0 for ; Fri, 01 Oct 2021 03:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KGewx1QiQQVkw015IvGnnogZeqnpnoxIhP9ykI50FyQ=; b=Cyh1S+VO3uhIzwT/x7r/+ke6Tw/sa5XVJuThgyu+evB5Z5y/CWutZVCiwpCfFHZegQ 26g2VRhhPd9KX0OahtFF1IqXac+YyHgvNSG+BpcuOZhLk6rSPqls/sVfH9Wsl6pjbXUB XsRKnopUjSmdmOFWLn/0SAswKVinKLLZIOOJ68Rji+ehsq9pT/XNSYhgJl3p4zqWjxdG qRMNY3UTJrNN4+H9YzyNpl5HDZW6MDXbSwuFyS6RhLSt5i+dUEBzxA8h8vacLvnZfnK4 XkBWBukDRFSr/FdkYI1aumJo88N0+S3UmvOt/8HN1d6x0qt8I6r1t141kR5TM+/8VbRq N11g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KGewx1QiQQVkw015IvGnnogZeqnpnoxIhP9ykI50FyQ=; b=LZubEOX461KWS+1GUrsIj7pSMx4whq0bGkv/xcV7olgtiVpKyTIkw1AC2uItU+8WyJ lPAPSAXFkKi3Lz307/UQc3oN50O5sUOLUvV9ppn4oT/Y5NCNqAki02N3+hszWAWT8+Hz 9aVRndMIgTZssTBPWDePGaX787TxV6aCYCGN8+dSrHgkrqdpT3GN21Oz3D+aixq+socB XGkcBCAAF+rJkiPCN3etJIx3Qp8QjDMsTz/najAxgtYDhOVEolafB5EZuY4LiKTJcEZ4 h/H3ubCop8u9WU9T07Vk5HmXtx7wInGwACzFD+xsFxT9H+HdM3bZK8sAmXDZLRCFXqr6 SEKA== X-Gm-Message-State: AOAM533XjwfZ+LKLtVklktA23mNyPrs42mYVFbTRqep0mhySGcYTV0X9 Oj0cmpyBNm3KYjUneuLRiPk= X-Google-Smtp-Source: ABdhPJwhtgvOI7xyayup3oIPTfuGI4IkHPBzz6DTtAC78R48IvmCzllr7F2U4ngGqkW0ygDIrfd4qA== X-Received: by 2002:adf:dc0d:: with SMTP id t13mr11183115wri.158.1633082795955; Fri, 01 Oct 2021 03:06:35 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:35 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 26/28] drm/nouveau: use the new interator in nv50_wndw_prepare_fb Date: Fri, 1 Oct 2021 12:06:08 +0200 Message-Id: <20211001100610.2899-27-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 Fri Oct 1 10:06:09 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: 12530177 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 287C3C433FE for ; Fri, 1 Oct 2021 10:06:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 152DD6124F for ; Fri, 1 Oct 2021 10:06:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353482AbhJAKI0 (ORCPT ); Fri, 1 Oct 2021 06:08:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353493AbhJAKIW (ORCPT ); Fri, 1 Oct 2021 06:08:22 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37F85C061775 for ; Fri, 1 Oct 2021 03:06:38 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id q17-20020a7bce91000000b0030d4e298215so810676wmj.0 for ; Fri, 01 Oct 2021 03:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jIUir/k9ok0mhA9lZLcDk0nsv9skwzmV2ts7X5dBo9o=; b=WN6qInpAsn24+ftDpOyCYIkBgofW7UaWxMslwRXjLU3tyhh3Ca31+rUNhj+m9LztjU sWlGZD0XwTpt2tvUoPdlCD0YI/kuc5NjlzJM3AL8v//Od+x+O5S9Bx1fg2QpUDF5QPk1 v2zv0mPo3/0J6rlyBUFGwQq3jLBGRNgXXFRDhJPUW+rSLH4e0pbxLaEWoRTavpYUXAu+ w5Y1FWlBaSQL+7OURv5Er1N3tlBspNHHn8g2E23BT+BrottgnGEiJ8e6Km0kCfPFI4Az LjBlXpnYh0LjQHfhVPTCWNRFHPAoBtx2ZxOYXYlMEyBzq1Sf4TBz1KqRD1vafSvHIXhQ 2KdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jIUir/k9ok0mhA9lZLcDk0nsv9skwzmV2ts7X5dBo9o=; b=ekAuMx+sb/tLKyPUssWAA3AnoRJ/1mtDGeIg8kkNGACMxTVDZYbo/ldb2E9ULLBU8C 9rr4MClsfNcgAGGZXNjXcszIlsXfKpOp9V/DRET2J87E0JOEsr87CsOknd2NfNkPi9lf WzS3Dj8QkSBrGx+wjpg2hoouC40Bwshx8hR3eXHD7KfOyhSRrWZIu3brEQse/l1pqKEC DfoHOIXap19juyql60KcDtpX8vQAyuHmZnKahHOYrCoNE8c3WIBixG7tTm6zjEHHEwkg 6HccEfBocs3r2xVD+EUparbvEvAZ2q4Fo2ezPtPE4viVoqBZnl3Fi+L7PaWs+SKCR99N u8Sg== X-Gm-Message-State: AOAM533QGDuLlgdY0runQdlK7G4r0O4SbFmKA+YbdRr0DJLlNUEZKjF8 fJZx4K22XWJ4oCUJL5vX5jo= X-Google-Smtp-Source: ABdhPJymDfL7NFE48Y02DYUiKpeGEfG6vmQwsVgnGjDCH8Rsk9Komv7T3/TkF1ZwvPureSAXTL/EgQ== X-Received: by 2002:a1c:44d7:: with SMTP id r206mr3584007wma.150.1633082796860; Fri, 01 Oct 2021 03:06:36 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:36 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 27/28] drm/etnaviv: use new iterator in etnaviv_gem_describe Date: Fri, 1 Oct 2021 12:06:09 +0200 Message-Id: <20211001100610.2899-28-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 Fri Oct 1 10:06:10 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: 12530179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A144CC433EF for ; Fri, 1 Oct 2021 10:06:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BDE36124F for ; Fri, 1 Oct 2021 10:06:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353485AbhJAKI0 (ORCPT ); Fri, 1 Oct 2021 06:08:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353477AbhJAKIX (ORCPT ); Fri, 1 Oct 2021 06:08:23 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19DE6C061775 for ; Fri, 1 Oct 2021 03:06:39 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id l18-20020a05600c4f1200b002f8cf606262so10788628wmq.1 for ; Fri, 01 Oct 2021 03:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vDNZbZcYoW7IFr6lQi88QIbXjkbY+ZD5EoDTFjlvddA=; b=PXH8tk9DNBtLaZwDDHnKup32VEbpBQdrjnSXIPz0PW/dyKbkTSjIKHVTAC+gmlyDuj wOAsN80WpUYrWHZo1ChOZ5tQC/9V7NFyqsQvdfIhpUyYSYzeOGDWq2Ab9U2HzyPAQOmb lT2BL5MBr+q3BTqhoCKyW1GTdauzxNRnK9dr3J8fFlHFxp1kh1vJLBaeaB6cc2ba1Et9 32HQ5EfNMdB/gf9+hKRYIQxYReupUwsW70EDr32L6Np0ef8uBgpmnH18fmZva2PhJ9f5 1iddLO3Wz1BxBZ+fc9dpTP2RwYIcZb2YV9BnvM8ASO30hzVRAqXskgB6BkfF7bx/+XHt v7+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:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vDNZbZcYoW7IFr6lQi88QIbXjkbY+ZD5EoDTFjlvddA=; b=2Vj+flUcXPxuLc79wcwov0q4pQ60QEmi2LU6cMRipQI7A8ZnsfaRgzasPrk5dVNxZq 4G4hDAR3yY4r/09/tC5E2djDM2kG1OLndg+pHefhwqmqE9DyDv93pXkB4CruBEzQlrjm Mgfx56qX/q+BW/X0/R7GaiMx7QBKBZK9iNXaXzMJ5sTBoKE6+66iyd779yJu1l8rcIbW /ezjl49jNAav3a3wZpwkWRFfc3bmTDNq8EgVgRfWsR/EczVfuBmCS6JDylPB2jRr4yy2 oCNMoyiIndSvbuWLgAYhavqOPn3FaUyZcarTHUTf7dZbWEMxWSggnqe/CXhegIOBVHpp gdaQ== X-Gm-Message-State: AOAM530e4m0TtsaZ4EBbRyhCKfIA1T9qlBT51pooAJ5wYNqzTDSW7AEV /Oj3Bv5UXUVcHvQJiyMOaJw= X-Google-Smtp-Source: ABdhPJx7qiKtQqciPHO0by0iLKqUhwG5jjzzHPN8NAGU+x7I7V5LqtDnXG25PcpZlk3SIHVxGLVmAQ== X-Received: by 2002:a05:600c:35c6:: with SMTP id r6mr3635692wmq.24.1633082797663; Fri, 01 Oct 2021 03:06:37 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id v17sm5746069wro.34.2021.10.01.03.06.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 03:06:37 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch, tvrtko.ursulin@linux.intel.com Subject: [PATCH 28/28] drm/etnaviv: replace dma_resv_get_excl_unlocked Date: Fri, 1 Oct 2021 12:06:10 +0200 Message-Id: <20211001100610.2899-29-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001100610.2899-1-christian.koenig@amd.com> References: <20211001100610.2899-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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)); } }