From patchwork Fri Sep 24 15:30: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: 12515721 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 84C78C433F5 for ; Fri, 24 Sep 2021 15:31:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6972F61100 for ; Fri, 24 Sep 2021 15:31:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347105AbhIXPcv (ORCPT ); Fri, 24 Sep 2021 11:32:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233132AbhIXPcv (ORCPT ); Fri, 24 Sep 2021 11:32:51 -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 E70A3C061571 for ; Fri, 24 Sep 2021 08:31:17 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id r23so3333168wra.6 for ; Fri, 24 Sep 2021 08:31: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:mime-version :content-transfer-encoding; bh=RovzGMzaSWHakypBGZN+u1EWd1sJLcm0NSLX1BEno7c=; b=p7DMYUsrQJJ4SN/3hwH0DzYdCYyYV69CbmZdqTnBdBAa06bA+vsPE46VFuU24lujhY iICFQJ23Tmj2r4HTkdhXgFUPZzHuPG7cJGW86pQe1O9kyxO6GcCgEd0dQlx2LaYqUv4l oCrWlKPRiXtTRlSUEpFCs7IUzaw9fCDvb2moxgq1RSqx2O7RNm6Ao18fHR+fzsyJEq84 YNmORb2A7j9fQGG4pKVmNisNLFe1Oj9pj34j1ourxzliwxPl/jztzsVA+Ft+6E3m337E qOA/A98NXpZNede9vjuwJ6VEpQHV355ElMAUHXNzVSssAYY2EertkG6J6VCEQCfnoU0E w7Ig== 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:mime-version :content-transfer-encoding; bh=RovzGMzaSWHakypBGZN+u1EWd1sJLcm0NSLX1BEno7c=; b=j05Ipt1vS30NOGChN4R61EwElmWVvBF0vmWujXTyuFIHjuz30LM2WBauwfyurm0QUy oocp5za0xaHqSvJsjpXqIBg3FBOsJW5PdyneNwFj9pdBqoi/0IKy2o0JeVMms8FARKIP BoOuu/GK3G3WihkGb6XUm+/pImrqjlq/xkoApwci9HgxUW/wLL0597USwtYQFnVoM7Tp TktSCNhe7U19pccsICVUZgC4Y1zJekOzqY+w/Zix6Pq/73/Hi8AP2lXSgVgpNwQQaVzc YjQdYW9liysYLamBADXtiU63AFNJry+bIjMIkKIWrv76BoMLmk8D/Yvv82Qc790dV6ur KwyA== X-Gm-Message-State: AOAM530lqYOHqz+WlDfVcUOl6ESWan5aiZb77N9m2TQsoCiqMkd2WLpu t5M3htVJuvGgf9qJsyGTeCttab/H7jQ= X-Google-Smtp-Source: ABdhPJwppQmf+3VAG5tgB7vYH8MaPbrtS4Nh0Pu9ikOK5z3zat2U0nfTe3efiAOhymy9xQXPlPZrmg== X-Received: by 2002:a7b:c0c5:: with SMTP id s5mr2865131wmh.126.1632497476421; Fri, 24 Sep 2021 08:31:16 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 01/27] dma-buf: add dma_resv_for_each_fence_unlocked v6 Date: Fri, 24 Sep 2021 17:30:47 +0200 Message-Id: <20210924153113.2159-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 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 Signed-off-by: Christian König --- drivers/dma-buf/dma-resv.c | 98 ++++++++++++++++++++++++++++++++++++++ include/linux/dma-resv.h | 95 ++++++++++++++++++++++++++++++++++++ 2 files changed, 193 insertions(+) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 84fbe60629e3..97af397304f3 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -323,6 +323,104 @@ 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); + } while (cursor->fence && dma_fence_is_signaled(cursor->fence)); +} + +/** + * dma_resv_iter_first_unlocked - first fence in an unlocked dma_resv obj. + * @cursor: the cursor with the current position + * + * Returns the first fence from an unlocked dma_resv obj. + */ +struct dma_fence *dma_resv_iter_first_unlocked(struct dma_resv_iter *cursor) +{ + rcu_read_lock(); + do { + dma_resv_iter_restart_unlocked(cursor); + dma_resv_iter_walk_unlocked(cursor); + } while (read_seqcount_retry(&cursor->obj->seq, cursor->seq)); + rcu_read_unlock(); + + return cursor->fence; +} +EXPORT_SYMBOL(dma_resv_iter_first_unlocked); + +/** + * dma_resv_iter_next_unlocked - next fence in an unlocked dma_resv obj. + * @cursor: the cursor with the current position + * + * Returns the next fence from an unlocked dma_resv obj. + */ +struct dma_fence *dma_resv_iter_next_unlocked(struct dma_resv_iter *cursor) +{ + bool restart; + + rcu_read_lock(); + cursor->is_restarted = false; + restart = read_seqcount_retry(&cursor->obj->seq, cursor->seq); + do { + if (restart) + dma_resv_iter_restart_unlocked(cursor); + dma_resv_iter_walk_unlocked(cursor); + restart = true; + } while (read_seqcount_retry(&cursor->obj->seq, cursor->seq)); + rcu_read_unlock(); + + return cursor->fence; +} +EXPORT_SYMBOL(dma_resv_iter_next_unlocked); + /** * dma_resv_copy_fences - Copy all fences from src to dst. * @dst: the destination reservation object diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h index 9100dd3dc21f..5d7d28cb9008 100644 --- a/include/linux/dma-resv.h +++ b/include/linux/dma-resv.h @@ -149,6 +149,101 @@ struct dma_resv { struct dma_resv_list __rcu *fence; }; +/** + * struct dma_resv_iter - current position into the dma_resv fences + * + * Don't touch this directly in the driver, use the accessor function instead. + */ +struct dma_resv_iter { + /** @obj: The dma_resv object we iterate over */ + struct dma_resv *obj; + + /** @all_fences: If all fences should be returned */ + bool all_fences; + + /** @fence: the currently handled fence */ + struct dma_fence *fence; + + /** @seq: sequence number to check for modifications */ + unsigned int seq; + + /** @index: index into the shared fences */ + unsigned int index; + + /** @fences: the shared fences */ + struct dma_resv_list *fences; + + /** @is_restarted: true if this is the first returned fence */ + bool is_restarted; +}; + +struct dma_fence *dma_resv_iter_first_unlocked(struct dma_resv_iter *cursor); +struct dma_fence *dma_resv_iter_next_unlocked(struct dma_resv_iter *cursor); + +/** + * dma_resv_iter_begin - initialize a dma_resv_iter object + * @cursor: The dma_resv_iter object to initialize + * @obj: The dma_resv object which we want to iterate over + * @all_fences: If all fences should be returned or just the exclusive one + */ +static inline void dma_resv_iter_begin(struct dma_resv_iter *cursor, + struct dma_resv *obj, + bool all_fences) +{ + cursor->obj = obj; + cursor->all_fences = all_fences; + cursor->fence = NULL; +} + +/** + * dma_resv_iter_end - cleanup a dma_resv_iter object + * @cursor: the dma_resv_iter object which should be cleaned up + * + * Make sure that the reference to the fence in the cursor is properly + * dropped. + */ +static inline void dma_resv_iter_end(struct dma_resv_iter *cursor) +{ + dma_fence_put(cursor->fence); +} + +/** + * dma_resv_iter_is_exclusive - test if the current fence is the exclusive one + * @cursor: the cursor of the current position + * + * Returns true if the currently returned fence is the exclusive one. + */ +static inline bool dma_resv_iter_is_exclusive(struct dma_resv_iter *cursor) +{ + return cursor->index == -1; +} + +/** + * dma_resv_iter_is_restarted - test if this is the first fence after a restart + * @cursor: the cursor with the current position + * + * Return true if this is the first fence in an iteration after a restart. + */ +static inline bool dma_resv_iter_is_restarted(struct dma_resv_iter *cursor) +{ + return cursor->is_restarted; +} + +/** + * dma_resv_for_each_fence_unlocked - unlocked fence iterator + * @cursor: a struct dma_resv_iter pointer + * @fence: the current fence + * + * Iterate over the fences in a struct dma_resv object without holding the + * &dma_resv.lock and using RCU instead. The cursor needs to be initialized + * with dma_resv_iter_begin() and cleaned up with dma_resv_iter_end(). Inside + * the iterator a reference to the dma_fence is held and the RCU lock dropped. + * When the dma_resv is modified the iteration starts over again. + */ +#define dma_resv_for_each_fence_unlocked(cursor, fence) \ + for (fence = dma_resv_iter_first_unlocked(cursor); \ + fence; fence = dma_resv_iter_next_unlocked(cursor)) + #define dma_resv_held(obj) lockdep_is_held(&(obj)->lock.base) #define dma_resv_assert_held(obj) lockdep_assert_held(&(obj)->lock.base) From patchwork Fri Sep 24 15:30: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: 12515723 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 981F0C433FE for ; Fri, 24 Sep 2021 15:31:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E14161107 for ; Fri, 24 Sep 2021 15:31:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347120AbhIXPcx (ORCPT ); Fri, 24 Sep 2021 11:32:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233132AbhIXPcw (ORCPT ); Fri, 24 Sep 2021 11:32:52 -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 C9D54C061571 for ; Fri, 24 Sep 2021 08:31:18 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id t28so15272773wra.7 for ; Fri, 24 Sep 2021 08:31: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=8GcZUte1eKAW3KEA8b90CyEUqRj3RuvP1QuX3wuqstY=; b=C63CTnmyjqVSqMcN0rJ4kkZvs5ecdEU/Yj1kMn4gBkfFJRyHz25EhxsslTa14fnHN/ Q+PBZAk6po5Tmtqv0gLEVwWW6UyZErLCM4Q7Xz+zis+vJi8upvO69e7R65BlytEIcPhH Pgu7CHhjW/XWlX2y6DZWlrF6tA/4Lc3fwPFzcr8kBEfFmqyfN0lEmHzAkHlay4/HzO30 mOlqZSdd4A7eOJuR+tNJ8pITyaLP53VaLBkD570xULpylMyjoTnTha0oFgqb3hkoR07x PVP9MBtZgrfvQaPCWxNnzhj8d/wYjNiNynFAyjZHEAxsA/WRxuZe+DWsfyGBIrQrNyXV QGuw== 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=8GcZUte1eKAW3KEA8b90CyEUqRj3RuvP1QuX3wuqstY=; b=EPs98kJprTrhYj2tEu9G5YDPO9rb3afT71BSceRvOz032Hg3WhI5gKxaazMyih2Jro FhJ2lpLhvVa6jySxReVlrf5Nk3kaDhgmbXaSoj0KALprpcKWuEzDfVwjeqcBTRvDsVsJ MzRtf4F5HB/+1yDb5LGOMIfsB/TwNY9UpqsF7rAiggLwplUYfEEVs5jTOnOQq0yXWjpI Heh4yh7MV15enghFWMk8UG8QhCDhAPZIxj37kRkbtQUNUZcryp37FA4fpv9d3jCkCdEA MwPbgwv45/+zkC2yWFjNIyAxBpljgKMHIDMyU4Uf9Bt5SDxT0/3G7Z6mzbT/3nMwRsgO K2Xw== X-Gm-Message-State: AOAM5303w91fSjeyfvC+V81riJKX3WwSJjG8DbWcTm7W8vVSWFIn/GKw vIIClBDDFGiB96RMbjFLTavNTAMSa1Q= X-Google-Smtp-Source: ABdhPJz1VjL0gM2i5SpTpbnaY6wOWsW4rXQoKeFakTmbWY5/IYFUxV5lMreHayByU4QS8Oae/L38OA== X-Received: by 2002:a05:600c:4e86:: with SMTP id f6mr2898221wmq.52.1632497477404; Fri, 24 Sep 2021 08:31:17 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 02/27] dma-buf: add dma_resv_for_each_fence Date: Fri, 24 Sep 2021 17:30:48 +0200 Message-Id: <20210924153113.2159-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 97af397304f3..98cb0050c615 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -421,6 +421,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 Sep 24 15:30: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: 12515725 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 C2306C433F5 for ; Fri, 24 Sep 2021 15:31:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A0CBC610D1 for ; Fri, 24 Sep 2021 15:31:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347148AbhIXPcx (ORCPT ); Fri, 24 Sep 2021 11:32:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233132AbhIXPcx (ORCPT ); Fri, 24 Sep 2021 11:32:53 -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 231F9C061571 for ; Fri, 24 Sep 2021 08:31:20 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id w29so28586426wra.8 for ; Fri, 24 Sep 2021 08:31: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=lj2Yv/wWR6TC7dOizEI5QN7SBISIYTE1BHrEKqHlUyU=; b=EHI/GN6zLHjnVSCx4/mw7LwnyTXJEk8y0ZtD2faHsuyN0r684yxdvxrku53+zpSUSx 2+5b4B6x4pPwWMPWVJyGbvXded/IdhyhjugMKOiNGzDW8PHpl4TJ1srq+vvpvHJyGB75 DBhUlvV98AhJGO+ffjx0DPptZRpQvTy3uCRPs47qneJvrZ8wY9HQ3+iomi3Ljj7oxFQB o3ykjQGAGxCQsezSTzH9dS9BzBm7jpot6zTRqjcgKXoVLEg6EzcIUJY+7UZFNnbWCaEq 2Um+MLM+saqx+K5O1mnkpLVb0U3C7ibfaAW+s4ZEBy786xJmFY+rqSX7jYxMHrUKfGor Kwpw== 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=EwVtZo6j5mZeAgLpaYwK5NBKZEukKtpr57ls0sQEZHABmYAsHLTGzqZA7//cZPvXV3 6MJ20D/yQP5zAv4e/elqM60zx4aj2D9XxnFsND6TRtayMkdTt3bMKpxmY/6YANFVMQNm +qNz+l8WPY4vrN/KpdwnqSrnkfsCoLk2kp7HfAQlj8iIBSkJkUWfLtUnoCgv/uQFRhpO EMJHmvvKWBt7B+KOJ8RgUMZ/K7/3g20Iu/DZSrLKOiCr9qmYFOaeLJtWjTRVqt5KdOu+ pVcR95QDbhl9yitkfKC0aXdkIgtmOJos/LBidF+MNXNiZMKeI/1EvKfSI9/a623Q78lw JCdA== X-Gm-Message-State: AOAM5307v0jk2Xbb17ndIYtrTSKFVdxBxR+tc+pxS7RsRGRcz7XpMT6n rjN7TBH656fANRLjP5UqeqA= X-Google-Smtp-Source: ABdhPJxugfWY0jf88JQ7B+wdQvMpJkmUKl2qk9Ih/jM6ZmeQU97dioXheSAakYLMsfZG/j5flckT3A== X-Received: by 2002:a7b:ce94:: with SMTP id q20mr2854368wmj.83.1632497478333; Fri, 24 Sep 2021 08:31:18 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 03/27] dma-buf: add dma_resv selftest Date: Fri, 24 Sep 2021 17:30:49 +0200 Message-Id: <20210924153113.2159-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 Sep 24 15:30: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: 12515727 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 420C0C4332F for ; Fri, 24 Sep 2021 15:31:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3160961100 for ; Fri, 24 Sep 2021 15:31:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347149AbhIXPcy (ORCPT ); Fri, 24 Sep 2021 11:32:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347141AbhIXPcx (ORCPT ); Fri, 24 Sep 2021 11:32:53 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B224C061613 for ; Fri, 24 Sep 2021 08:31:20 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id i24so12737997wrc.9 for ; Fri, 24 Sep 2021 08:31: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=PWcrX/+AX77jPmOcO42ygzOFau6SefsmvnsKtVw/iNk=; b=RyXaAlvF4YkEyyjnBaQtd9nr2dDZOYaEhHNj4d/Unuu4kAoU+LOQHq7qnjTLEm75LP yA6YLFCDevuNggbY8Y6Wk5s1HbSt8NzQ3WZgHOBdWql7KRg0KBgLGgN27HhtsH935V1j d3Xl5D6bYN+9a068zT4nvdm6MKNx/4CvqPgwErC+LiGD9050bObTSpWsUWbsiwBoBgOs cIiHwgatxWHXEndRGLHImCPHvAkC4PrxuKt6buWEe62283bTSMQBT9ThbaNyJNG4Bgwi jI8jxjC04n039XqngoUNm8iGxczJC4UyHH8B8kHWQ8RFO2US2eFRpB633/Mvkpkitl9M CR2A== 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=PWcrX/+AX77jPmOcO42ygzOFau6SefsmvnsKtVw/iNk=; b=JNatqJv3Fjpv2pN9I46bbZdP83BTX0htRsFyYS18P8xCnz9afIlZzxDIIBRbuNkmhs Ap0QEslz7+3Yly1d2XhLW2KTqJLSX4zvpaCAUKV4BrGMDBkPmciGQjCKhyylQd8nhts1 xfWG4E6jztq+k37K8h3LR/UXQPonKRumsf3upPn/YLplGyKdnXWZMseOzNIPbWzObnwV 3rCr+QROhzmuz6oE8iUAkHNculbTjIVY7CDEhmW8CkChZpcWtrBifJHGJl1xznujGXIL EabidYMGCJgQEDztPi+XIOb+BlJrAbunjFHUiU08YmtdL7DqC8A014hOz3wv1tle+n2S kQ+A== X-Gm-Message-State: AOAM532f9WWtwqunLtCeMD2Vw25WJ/J2yooitGj9cmcnU5piXe5rfLnH x+vL9EJ3din0b0Sk9LKK2ZA= X-Google-Smtp-Source: ABdhPJxVz6e8g8VEXKuq7e7sEa6mOjNpVpagxm/btfJ1IZdusReUAaINnzyw4wkMg1yz3sgjejm4mg== X-Received: by 2002:a05:600c:4ba5:: with SMTP id e37mr2743028wmp.65.1632497479308; Fri, 24 Sep 2021 08:31:19 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 04/27] dma-buf: use new iterator in dma_resv_copy_fences Date: Fri, 24 Sep 2021 17:30:50 +0200 Message-Id: <20210924153113.2159-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 98cb0050c615..17ef7472830b 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -476,74 +476,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 Sep 24 15:30: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: 12515729 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 344AAC43217 for ; Fri, 24 Sep 2021 15:31:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2171A6124F for ; Fri, 24 Sep 2021 15:31:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347154AbhIXPcz (ORCPT ); Fri, 24 Sep 2021 11:32:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347141AbhIXPcy (ORCPT ); Fri, 24 Sep 2021 11:32:54 -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 934E9C061571 for ; Fri, 24 Sep 2021 08:31:21 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id w17so28581536wrv.10 for ; Fri, 24 Sep 2021 08:31: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=HQVosJQpuUUknAdjCdCypn6pqpIcqGG/U168PyisnxY=; b=iHj1LIcnPqp89fiF3K0y08ByL59xHLV5JQ4BIDNqpLYbZW1CH2+Pg7DOYZLTUEi/8C JzOmtR/fMNXNIhERDCr2hx/P7jI/gdZfb2TLjUoRbmn7v2M5pu3Xp6gidJhgBgVUwQwq 0RmCBJjefHKmcOZm9NXBx1OPM2GlzuukF2vWNElXj+pJKK+zguB3fyKWAQwtJmESMMBC wHAUW+UJ7wxwWQn3g4SZOGHHtCkRy6Kc4hgWHjSt6ji/h7EAB26+/4sh3PoSO5XYBs2G wIvhETO33D+za12Cv+nE7V0Pe9z+Pr4y/Fg4PuxZnVe6qrcLWyMk54TgwMVYPPBuPcQL DfSA== 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=HQVosJQpuUUknAdjCdCypn6pqpIcqGG/U168PyisnxY=; b=KAR2Ka/1KVMlXMnxzydnw+DmY/Sch5Pw4PoTl5cI5DujI8MQyhqDWTRuVx3h/bbGli wCEy/7xGQluWm0dG7+drOddma8fFDTKwh80a3u8ycpEBD7z0Inx2dnlAw+gQWtNrjBoT KhH82Rfdpg7TEKnO/otu5yxRPqRmPLgLEejEq9YMz1HTPPFkzRQaM9yTy1KzCRCN3I6Z PUR9BW22IH+q+X5zYNeAIibl020XnRJPPG4APL3cgQB2zglIgeTlGHJGeaWulOBWMieg 65IN/AC+2kosrFVwICqIhg+LZnlv3FSSenR5uwTFQf2JSjSK25I1DZ7vMyCxSJI1tYpt 4piw== X-Gm-Message-State: AOAM532GCrT89pSFee1IUsX6x5hYHvbVt3rRSNyLzIsxjuNkwW+Q0hlp SPnZkrOCYfK9KSSLWu5hpOI= X-Google-Smtp-Source: ABdhPJz2mdoAObvJWaUI7IqsdqFb8qbFEUrhqL8G56kY83AJLxAyCmPmA06V4+CfHVFtRSiD18RdHg== X-Received: by 2002:a05:600c:3ba4:: with SMTP id n36mr2792647wms.35.1632497480194; Fri, 24 Sep 2021 08:31:20 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 05/27] dma-buf: use new iterator in dma_resv_get_fences v3 Date: Fri, 24 Sep 2021 17:30:51 +0200 Message-Id: <20210924153113.2159-5-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 17ef7472830b..39a3eac28834 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -533,99 +533,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 Sep 24 15:30: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: 12515731 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 E2B7EC433F5 for ; Fri, 24 Sep 2021 15:31:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBDD961241 for ; Fri, 24 Sep 2021 15:31:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347155AbhIXPc4 (ORCPT ); Fri, 24 Sep 2021 11:32:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347141AbhIXPcz (ORCPT ); Fri, 24 Sep 2021 11:32:55 -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 80E41C061571 for ; Fri, 24 Sep 2021 08:31:22 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id t8so28737394wrq.4 for ; Fri, 24 Sep 2021 08:31: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=bdxDl1m+8XOXTzKq7WnyxAATGKOR0ud+UbtwoDgVbbc=; b=ODU69SvYQBoe73ZOhuuTO6W6+86702JL7nwv1wqbUR1w7nhw4trtrpe4xaxe7Hnt4A HcLneQPCTnIJfN0FR0Jg1clTtbm37v+F9b7x12WzhGbvsbie++Qz4gB156cwcr3RjrIb ZjrMr9Nuu+z84nIImNVRg7WjDASFyFS2syrInI67L0kZf2Go+wp97NCJ332XpnXTWkV0 QPv7d+ZIkM/qny9xCwMiy3BypuJsaE9AXX8b4l9tFdSY7JESSO3rh9YyGJS9yqmMw8Js h7caAt9bRbN11FDnDe+CA/9QzS3OErtFKSN+PEWEdpaAu7ETImdUzfA5EDt2XzCYSxPH vqaQ== 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=bdxDl1m+8XOXTzKq7WnyxAATGKOR0ud+UbtwoDgVbbc=; b=1RD90Et0OR0F6UCkVwqBAwDC0yjVyjzYoGq3uK9bsFFgloHO8FpX8MnsGfaLnZuxC2 F9LJM0OXMr4IIBG0VjRaz0FFBM+dJFmX3RBurqYLd8OdJKDOHnTd5B8KEqZnML+lfD45 cdLafMy9TkqsFIO4WvxFMsRal0/gAZNvsCSRQrQk8FzA5MqxqnYskU0iR91Z5LE2OuGp 79FsjJD3edG+gzN8fqGUDiyze3KR3MG19WJ68RKbozoEdbcKiqmRmYQNy1xjNAzidwe1 xcytxN3ocsqe3ZQafTE2lah9EthfrpmF+POaMxj7RnSSO5ub/Rq1NwLAeSMHO/nASl+N KFeA== X-Gm-Message-State: AOAM531cX4hsdTzmEcogNZlF3jym16IaAH7GzYUBnZtbDnCVxALj5vcp AMmpo5SmblMRJ4epwjNiiLk= X-Google-Smtp-Source: ABdhPJzBcYtkQo3Wyfd0nFGOnH0pHsA6d0aPb408PLKgYO3fGWVqda/NXtNrnrTfn+xSdzFZXxhBMw== X-Received: by 2002:a1c:2246:: with SMTP id i67mr2712664wmi.157.1632497481199; Fri, 24 Sep 2021 08:31:21 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 06/27] dma-buf: use new iterator in dma_resv_wait_timeout Date: Fri, 24 Sep 2021 17:30:52 +0200 Message-Id: <20210924153113.2159-6-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 39a3eac28834..ce6d0ac43911 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -609,74 +609,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 Sep 24 15:30: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: 12515733 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 C19E6C433FE for ; Fri, 24 Sep 2021 15:31:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9B5C5610D1 for ; Fri, 24 Sep 2021 15:31:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347159AbhIXPc5 (ORCPT ); Fri, 24 Sep 2021 11:32:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347141AbhIXPc4 (ORCPT ); Fri, 24 Sep 2021 11:32:56 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B363C061571 for ; Fri, 24 Sep 2021 08:31:23 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id t7so28540133wrw.13 for ; Fri, 24 Sep 2021 08:31: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=cS5iGWKRJZl9e2of130B6u1H96gfOwZtKEhbMlq6Irk=; b=I32ZkThQcwKx3to2uBUfDeM5WLqc9uTo/9yKtWlyaVTvtwfxVLqaZkC4oA6eProDkH FNaURTTrDBl21EAO+tZRAmjlApg+LCOQ4ijfwScl5XyESPI7OUsnkA5aE781VgCQfqzO ng8k2LWOISV9vRzV22rk4rnrPAro1vrJdl4O/Ygv3ozRRCs/bESZ0r07u1meES3+rSyH 2aXc+DLkA7TWxduJ9LVMopq5WKqF5SKmfPB//BmfNWxR0WjA+J12bQ59HaiKgMzslLJ1 jrTdIRgBDiCwbpazj2rFmIlrjpnfvduc7LzMxLDr9JlSXJzJ0O4nKS5HfKv39fxFt73n XKiA== 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=cS5iGWKRJZl9e2of130B6u1H96gfOwZtKEhbMlq6Irk=; b=ubTPYeVHgr8Z3AUbyBcYZpmjp+jr8K0fkiP6Qg9rWSgGxNwnAiuNQOevQUohDxDKh0 AauPReQdPRspxoHTcdD6bN/bYAn9CrX/mfflAcP+JfwJ9FrJpCpt6wOI1AWIMC7m3IKA d2iFsldKR+19jJq2BaeOmXPFERdt/Fyn3b0vY35E8izT9WVOduRoTZBMGmKW+NdWxPZg sFn7UpPAbwjGkLqdVyrZMdCBBhSkuKU8ztNGluV0v6I6N/BNzmTFIUuZXZ/MVOXpLqSg 74ElMUR0PTFOdw4Eoexhd5SmSNCRuy5h2PUG7PNjTOVvwnvHNUFSPeL4J56fjygFbycM 8l6w== X-Gm-Message-State: AOAM531yQtRZDYDA2yQl7Es7WvYCUxsUJ8bAKMD/7iM/p2vX9WITP33W HTAX+qFYFPkffagv591h0rU= X-Google-Smtp-Source: ABdhPJz5UL0/fv33FZR1HQor/mYzMpKSGiWoxeRCAkd4oZHML1sJxXeamhANPXgWuOMxqrZVbjzmKg== X-Received: by 2002:a7b:c92f:: with SMTP id h15mr2845866wml.60.1632497482031; Fri, 24 Sep 2021 08:31:22 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 07/27] dma-buf: use new iterator in dma_resv_test_signaled Date: Fri, 24 Sep 2021 17:30:53 +0200 Message-Id: <20210924153113.2159-7-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 ce6d0ac43911..42ed72db9801 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -628,22 +628,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. @@ -660,43 +644,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 Sep 24 15:30: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: 12515735 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 00A81C433F5 for ; Fri, 24 Sep 2021 15:31:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9DC8610CB for ; Fri, 24 Sep 2021 15:31:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347162AbhIXPc6 (ORCPT ); Fri, 24 Sep 2021 11:32:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347141AbhIXPc5 (ORCPT ); Fri, 24 Sep 2021 11:32:57 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5471BC061571 for ; Fri, 24 Sep 2021 08:31:24 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id t28so15273677wra.7 for ; Fri, 24 Sep 2021 08:31: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=94c9/cvO4ig+518zY5xyP/tzsv4f6nlGZ8qTXZ85g0M=; b=YlNroZ5biwT4gRqCxs308agE8oTbg2jZFIcIx5gpx/s397fd+zzRJQ5Hplq1GevfSW b2ZSzIzAVlaZ3Z/2ECfLxMkY8q59zM4ZtLbGQZ/rwtTRi1Gkwht9FStOAeQo9yULR7Nr AZyi4hr9cQuyI7NIXADwKXP0vpCKJKQ3TGei6/q/TXtedJwOISdZ/uXXmRsbYCbLmQO7 yafiDUqIfvWVm8f3Jmne0f6ilncN1MH7/NLGe6YL48xcUOJBnMvLlt9TVzrNXhMViZtg Oa7kq23yTRLK0lNIL3BGDl5sMKWtBKGaovIgSJTAz04am2GFkIZwwT3UUcRGMTJgH5hM ZVhQ== 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=94c9/cvO4ig+518zY5xyP/tzsv4f6nlGZ8qTXZ85g0M=; b=44/+dzPqhVkItse3eX+4Dpgn53+CRQEZjCCMf7XCswFLeHJOqrC424Alk9bULA3mGw abcPvBuD1bs0w4RZFxXXCtF6thzc6gNwoVPVKEbo4GQiqeg6M4JeTHOBk9VZgtO3FnDH ssRPLArQEV7PcmfCGtbvshJM/mqvUz2gx9Vfh/GNm+K3Bhwol77FtBZRNylTiQPfVZvl FKOKigQw9SUsZfWSi47nXRWhV/QmMEqKLs2ODTkQ1HWlvpuhWSYkzgqkFK04Mo1S/Jmw mNvBR2g7niNDoEg1Nmq8upNRsMzFPxvanN+qqHRaQGHPoIFy/wIhHCTJB0rCYOYcQuV+ HWMA== X-Gm-Message-State: AOAM530SgINofcay80unn7N/IYHQdViKd2K1Br4jWVzV32c5NFzDeoxs s3iQFojSCglhPU9QiVMAP/8= X-Google-Smtp-Source: ABdhPJy+yiRepmZL6xJsYzD6MfHT8qUFF2ibMp+Qb4FMclBELxNiicxgkVgOBbeClOYdUw6jjBg0fw== X-Received: by 2002:a5d:5229:: with SMTP id i9mr12230244wra.373.1632497483032; Fri, 24 Sep 2021 08:31:23 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 08/27] dma-buf: use the new iterator in dma_buf_debug_show Date: Fri, 24 Sep 2021 17:30:54 +0200 Message-Id: <20210924153113.2159-8-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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/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 474de2d988ca..d35c71743ccb 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -1368,10 +1368,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; @@ -1398,21 +1397,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 Sep 24 15:30: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: 12515737 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 B044FC433FE for ; Fri, 24 Sep 2021 15:31:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93530610CB for ; Fri, 24 Sep 2021 15:31:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347165AbhIXPc7 (ORCPT ); Fri, 24 Sep 2021 11:32:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347141AbhIXPc6 (ORCPT ); Fri, 24 Sep 2021 11:32:58 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5822BC061571 for ; Fri, 24 Sep 2021 08:31:25 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id t7so28540469wrw.13 for ; Fri, 24 Sep 2021 08:31: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=12q+kmLcqrOLQ+PRaX5+iil+oP7YjLgyfMuSdQvd75Y=; b=XVCAHX80yj7fOOVhGmDrldDzQ+tZU1P01Ey6y5LZO1bhqLritw4vRboSKw9v1ZiVkJ +Qq+Im9zUJGVqrUWGXSAA9IcemqPtfIo/wr7WwzzeRFMun+hksrMaP7yBhACzRkr0q1L egGSvjFbf21ceOxwJWa+XiU6iUda0TyWJZsf3rLkzV0VznYvWfe8uDzuQO+dMPQe7fQ4 ttTwD8bIXQTG9D5hbaNC92Nmi1nT54rn/RbHFH4CvhxiR546Lxo1jSzsooQoQzggRUXC hYKln3uM44d2NgLl0u8LlqS79zw1VeOXTkn+7LUEddNRZVB8Wze6nUkK+ZnFZlEl03c+ xinA== 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=12q+kmLcqrOLQ+PRaX5+iil+oP7YjLgyfMuSdQvd75Y=; b=OR+r8fmOfhamwG/65ge4K4jjGqE0inidCfLzMcL4J3qC+XhhlBA8QaUm1DAXjXXyaF n2VqmCY5mU2L8a3zpEyuTyAVW2ESKsFsnSpUGndo+iLXq3U8vEqAuamH+nazlgMCmDUU g8DM5epCdpH09zzGsv5vAjmihHex6swKFdQV3pZZRZ+ElKFh4QXi8jhD+EjbfcJMzqC1 ZWH6Lj/SMnm9DJb8fjj/oR3hMSvDXqB/lYngFAeWfK3Rs2SMPJKhow9xTJMWWlAC3LA2 WH8EbZCluVZqKPxRE7Pl+TzHzwf4caLLEo1ZAq3NZnv/vXMpsVvJGi+dbaBzeyrfkddF OOcw== X-Gm-Message-State: AOAM532eY00PczvWA39Acryv7EkV97kOLGc9ub+Vt/JrzH85ZRipY/Ca yEC5SDElAYr7Qb1b5F7Un+s= X-Google-Smtp-Source: ABdhPJxfVU2ZRGajuHbNqSwwhLNc1V+itYxHz7cNctZZYqzXr+vVdmnmCGw1zqkJ6hJhq4Oo9BoeSg== X-Received: by 2002:a1c:8096:: with SMTP id b144mr2680834wmd.189.1632497483876; Fri, 24 Sep 2021 08:31:23 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 09/27] drm/ttm: use the new iterator in ttm_bo_flush_all_fences Date: Fri, 24 Sep 2021 17:30:55 +0200 Message-Id: <20210924153113.2159-9-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 3b22c0013dbf..301b0b4b082e 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -269,23 +269,15 @@ static int ttm_bo_individualize_resv(struct ttm_buffer_object *bo) static void ttm_bo_flush_all_fences(struct ttm_buffer_object *bo) { struct dma_resv *resv = &bo->base._resv; - struct dma_resv_list *fobj; + struct dma_resv_iter cursor; struct dma_fence *fence; - int i; - - rcu_read_lock(); - fobj = dma_resv_shared_list(resv); - fence = dma_resv_excl_fence(resv); - if (fence && !fence->ops->signaled) - dma_fence_enable_sw_signaling(fence); - - for (i = 0; fobj && i < fobj->shared_count; ++i) { - fence = rcu_dereference(fobj->shared[i]); + dma_resv_iter_begin(&cursor, resv, true); + dma_resv_for_each_fence_unlocked(&cursor, fence) { if (!fence->ops->signaled) dma_fence_enable_sw_signaling(fence); } - rcu_read_unlock(); + dma_resv_iter_end(&cursor); } /** From patchwork Fri Sep 24 15:30: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: 12515739 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 99807C4332F for ; Fri, 24 Sep 2021 15:31:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8359561100 for ; Fri, 24 Sep 2021 15:31:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347167AbhIXPdA (ORCPT ); Fri, 24 Sep 2021 11:33:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347141AbhIXPc7 (ORCPT ); Fri, 24 Sep 2021 11:32:59 -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 53F2DC061571 for ; Fri, 24 Sep 2021 08:31:26 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id d21so28559688wra.12 for ; Fri, 24 Sep 2021 08:31: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=RSipxlf8Rt1aqHkUOElk7qKJcjfTHCxexIhn6lnwGw0=; b=p+wRc1sNylAta5gGLWOUxoq4SRD+JVK/ZYiTsuz4StmBHX2gqnBSyF0cIZt0XSm5rx DBA/zVuCE4eV/hEfaMIng0NhgwNc4Ipch7MUp1rAgBi9kDMbxrl1d4Ovl1qGgolW5N7J kZTzQlAbBeQYTBgR9BinnpIF0H8Vh3b2w9LMsD2UVVT6IeUMsTMbx4B3z3SuWHl3v5R6 xE9bU93IMBzFpUZQhMb8rYI8QyFH0rf/njQcRp63LD5uS5EvS9vV6HeDKg8ClnGGvSuw pod3BMBnO2iZeurdTVQuoUDWyk7lhEFMzUXBnoQAPaRFhzINiCJtW6eeBKE+YnAjr9i0 BIXg== 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=rZfRshy/IR1HielmVwgAU2IGbSq/DYcnSMyxrhN60kc2P6gmSD0Up/JAE1dzi91hRM JFChMVvrpmG60EwCBzqdP0oEJGRPaEPQJOuVfm6NLbtOlmRrNWwb/5i1S2omTRUIZz/r yd/Cz4MPs18tustS5Art7cQU5KS2y7cdP3B59mNULphF4qQzDzlLIzK6anKr2dZeYOEv vrPL9ItKhgxd6JTH1TQddk/vgARSY9GYpJhC5ZuSfMKKiyq/yQ2gkrsaciLNnx6/ELIh fsgBbU6iXTBNGQOOB/rpI/1WUBCvtfPQwS75hiGvhtw9SNxwthX3PY6pXvUj1zdAFE0h 9cEA== X-Gm-Message-State: AOAM5324I/5x6LEDxPe7xEMmd5pgVoRuT39O8JwJf2CSSUCkVxmtATnR WFbpR8tHsQ0Vi3CSk4Lc8QY= X-Google-Smtp-Source: ABdhPJyIPRl3nUImaPEHX0dkGNVZKX1295/miUAmR2Ra/obAIqq4uDr+3k9Cv1zNDrgVO/uuS5OSVA== X-Received: by 2002:a1c:22c3:: with SMTP id i186mr2743462wmi.145.1632497484999; Fri, 24 Sep 2021 08:31:24 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 10/27] drm/amdgpu: use the new iterator in amdgpu_sync_resv Date: Fri, 24 Sep 2021 17:30:56 +0200 Message-Id: <20210924153113.2159-10-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 Sep 24 15:30: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: 12515741 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 2F3F2C433EF for ; Fri, 24 Sep 2021 15:31:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1870C61241 for ; Fri, 24 Sep 2021 15:31:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347168AbhIXPdD (ORCPT ); Fri, 24 Sep 2021 11:33:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347141AbhIXPdD (ORCPT ); Fri, 24 Sep 2021 11:33:03 -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 B4BEBC061571 for ; Fri, 24 Sep 2021 08:31:29 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id d21so28560197wra.12 for ; Fri, 24 Sep 2021 08:31: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=w7BNkgXvEij5lrUuBoEgmNvE08Hfx+8QGysrl5h5aK0=; b=a4akh4ID5KuyrpALon1xoq8zr/R246FjYrieniK5ios7B0UV0Ai5dD8IlAkFIgcotS CQxisOr7JpNwDrc7+ebqHN1zLQNaNWVCAPOMYv1/KVTUsL+LWfZcNUiP4vOTqdcJ13F0 51PObG/lazWsxIUOc2VafqxP2JYM5of6F1MW5smH30LNbCYYeN0jErS9IJSw81LxkRKU m27Vd/XtNf8ajn0sQj+YdbpPLMR2xMKH9/kshK06g/zmP6XCjfZn9DCJ1xw60903fqPb ehWMFECagkjPjoMx8hesovqK4Orywl/g/By7IFg/UTQ1bNGN+rpHPnyUURw5Ng69Qeeg EUvg== 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=w7BNkgXvEij5lrUuBoEgmNvE08Hfx+8QGysrl5h5aK0=; b=LflI2eLHQjXiQmsG1QtgfUAksvOnFbfLFJrFjAR4VXKley3uEruBk7/5fK/7GqbweH YTCoerHHTNOLqY970tYGAfsrxvQrei6shNBm1VH0NRHJfjnKwnYHAvPhoFPLfXRitkW2 dO+iYHx/OUm/ctaDRjqtpfQk9CFVHwew8O00yOZjK0vK4Q2ZIIvRU/ojc8vB2Ja+S84S qzG4FzwXxbMsT2dgCXJrMTu0WtA+vIQVe8/iJUwfEykPGmJzha/xj+R19+GL8+qG8nAI CtE6bzF173+aYSQhZ6n3+2tMRMEa3jLgpNQnU+M4Cms0u9h7lpuQMOFPRJNjfByU2ZIO vQsw== X-Gm-Message-State: AOAM533KSA7GkY3ySBELq1rdnnZKda5nk7aGq1lJKopR0sbV1l2SHvLT Hp6K8+ULYJCM3U3x7n5+m3o= X-Google-Smtp-Source: ABdhPJx7+QBhgNXmmAEUe0jGUM1umwFutgTQGiyXVPu52SHAcwWcciqMjSgrBc9YWfE+rcEQvn8NsA== X-Received: by 2002:a1c:2289:: with SMTP id i131mr2718379wmi.179.1632497485903; Fri, 24 Sep 2021 08:31:25 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 11/27] drm/amdgpu: use new iterator in amdgpu_ttm_bo_eviction_valuable Date: Fri, 24 Sep 2021 17:30:57 +0200 Message-Id: <20210924153113.2159-11-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 1129e17e9f09..4511cd15c3a6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1332,10 +1332,9 @@ static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, const struct ttm_place *place) { unsigned long num_pages = bo->resource->num_pages; + struct dma_resv_iter resv_cursor; struct amdgpu_res_cursor cursor; - struct dma_resv_list *flist; struct dma_fence *f; - int i; /* Swapout? */ if (bo->resource->mem_type == TTM_PL_SYSTEM) @@ -1349,14 +1348,9 @@ static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, * If true, then return false as any KFD process needs all its BOs to * be resident to run successfully */ - flist = dma_resv_shared_list(bo->base.resv); - if (flist) { - for (i = 0; i < flist->shared_count; ++i) { - f = rcu_dereference_protected(flist->shared[i], - dma_resv_held(bo->base.resv)); - if (amdkfd_fence_check_mm(f, current->mm)) - return false; - } + dma_resv_for_each_fence(&resv_cursor, bo->base.resv, true, f) { + if (amdkfd_fence_check_mm(f, current->mm)) + return false; } switch (bo->resource->mem_type) { From patchwork Fri Sep 24 15:30: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: 12515743 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 68C71C4332F for ; Fri, 24 Sep 2021 15:31:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57EE7610D1 for ; Fri, 24 Sep 2021 15:31:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347172AbhIXPdE (ORCPT ); Fri, 24 Sep 2021 11:33:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347170AbhIXPdD (ORCPT ); Fri, 24 Sep 2021 11:33:03 -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 3A726C061571 for ; Fri, 24 Sep 2021 08:31:30 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id t7so28541191wrw.13 for ; Fri, 24 Sep 2021 08:31: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=SQ++zZ5/yZpkHj9Fw3rhcDISIEh5bldO1ALOtoZPTbI=; b=GU9YhU5Pryn0hB8x07xuYZF8M7s+qXgLshbnexafRjeTizxn7h9FRONZ6n23xvPfTf UJ2eGR7lgmUiPjoir92KNbFbT5uEYvWIO+IJOxVkyn6iiRLbK5B/INWdcFZAChlFP3TQ qa0Mhu4+bkT/yb9oZIjUQJP3L6Qck7I/EtefMbt7uQ/2RCDjAS2GGZV/EaIQz7RNSFms vKXHR8Ui3fo8EU7WYsgti/u780Y0A1J2aoWareMMd6+ydH0C8PHT3l9HlqDhVyXjtew9 nz8JC4ADUXW8vq/Ywl37I3PYeKNtPQRfX80jQ5F+bVAMs/z6aL5eZ+QKBJ1aekzFCe07 6uNQ== 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=kMKmTYF7KxrMARSPiBLuwKaEorEn7lrMWPTY0vcY32ZCQJoVBTh4XUt1FicEzLBiFd kr8NGx4z0mYuNtEEZQy/+YCntUeP9g7CtA33PwfBtnevvn/zkOdQwdrZDI1LBz+uQI85 jg55Zheftj9YgZy4sWWEYyU9KK1si9FB7ulS01hAyIXUPpxPFkTDeJietB/vBfz4Y6Ju PFDwEpWcYI2BWQCigigr/OLW+XcEXqdNhW6Hh3/7nAk2MTBSN82fqgy9VqFpDKxJKpJI GCXFJydTuTZGi1jHOylmVeqMeBQ2RhxxpX8QG3zEkReUvtcod2b7tLLrRp8JeQ/CLRxm 3OHw== X-Gm-Message-State: AOAM533UgO/fqDntX8v/MZ2J9yBHv/RwTAjZGOfjXZ4QQOU11uMgI1bj utEet4Z3Hs00UUcuSm3fIXmialt18M8= X-Google-Smtp-Source: ABdhPJwpe/xR1soLgzkh2xZshodGJdGysorueiWodthKrz5USEQ/vTDRlUoA0X5iRPY+P7LFZUt8ow== X-Received: by 2002:a5d:67cc:: with SMTP id n12mr12092772wrw.381.1632497488865; Fri, 24 Sep 2021 08:31:28 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 12/27] drm/amdgpu: use new iterator in amdgpu_vm_prt_fini Date: Fri, 24 Sep 2021 17:30:58 +0200 Message-Id: <20210924153113.2159-12-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 Sep 24 15:30: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: 12515745 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 DF01BC433FE for ; Fri, 24 Sep 2021 15:31:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6434610D1 for ; Fri, 24 Sep 2021 15:31:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347173AbhIXPdF (ORCPT ); Fri, 24 Sep 2021 11:33:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347171AbhIXPdE (ORCPT ); Fri, 24 Sep 2021 11:33:04 -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 01036C061571 for ; Fri, 24 Sep 2021 08:31:31 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id i24so12739746wrc.9 for ; Fri, 24 Sep 2021 08:31: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=Xs3urb+CfK37NrDBLos1427ZQKhaGuo6xOveDYDdwk4=; b=RzWuZAIMOpiub0i7yP5lKCR61AHclgo7MbaIOB/YpUBnGhJeWQb8Q5AqotPExpFYQQ dy6t/eBKl6/M2Gz6wG86VOYRcceKsTWJLtjW2eGl01Pml8yspK/aeE/nrYwwXWngv1Yk 3nz0SdDKu8c3EI+2GsAl9PQBLtP85YPiOXp4jmBPoi1UM14B9eXN6wnLRJF/DOY1N8du efRUA4Ijkq9U2mF8o02NZZ7XQBSHJ3QWSnauZ4R3il+/l3bkxuxLYh6+WacVk2XVwwT+ /5PXoEMf7oiQXnDwz0ne1WQlDb2jKN2JsMfy5PyhjwamiIQOnq1B4UeeFBF6J6NJeECz vf6Q== 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=Xs3urb+CfK37NrDBLos1427ZQKhaGuo6xOveDYDdwk4=; b=iLbAv0StX+5p6KxwCHGu6du2ldsRsIo4wAmJv1jVmqI8L4VRmE2ONyvi/8wO0mqn7p VYZ0Ym8g44P/T1RtWdtyBBrR+Z1nLRcaPdJujr4hOlcjGqHoI9IgWECBKcW5jXpnTery hA+GoXaL8wh4UjXQphP5DzQbQlLnTtb6BXClz1D9ONipXlRPA6YJ5NxVyqZ1IU24ZLdH NWIwYprJ7pm4o9CEJGhM+bMcXyoogP+pbN9oBWuMMjqk/F/GV+UBONxe2lAF5rlW4IgI cC8OAxiEzc0lboDb9zEEVW8vG9a4WLGnTTjS2RNQomv9KrK3VXmzyjTLG2DJDT8XGn7Y /LZg== X-Gm-Message-State: AOAM531E2C/b2pAGFMUJCtmrXx/kJft9+lwCXmefBKP2fYulTDYneXoI c/apaJUo9hpkQNccqVzYTYM= X-Google-Smtp-Source: ABdhPJw9rc8OiQvJzlLG/fsJFsT7Qo05foEBmvzgcuYqLtl+aLiMxcLcARExzXnhKjvfu2LBv5YmCA== X-Received: by 2002:adf:ce84:: with SMTP id r4mr12371922wrn.107.1632497489685; Fri, 24 Sep 2021 08:31:29 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 13/27] drm/msm: use new iterator in msm_gem_describe Date: Fri, 24 Sep 2021 17:30:59 +0200 Message-Id: <20210924153113.2159-13-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 22308a1b66fc..14907622769f 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -880,7 +880,7 @@ void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m, { struct msm_gem_object *msm_obj = to_msm_bo(obj); struct dma_resv *robj = obj->resv; - struct dma_resv_list *fobj; + struct dma_resv_iter cursor; struct dma_fence *fence; struct msm_gem_vma *vma; uint64_t off = drm_vma_node_start(&obj->vma_node); @@ -955,22 +955,13 @@ void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m, seq_puts(m, "\n"); } - rcu_read_lock(); - fobj = dma_resv_shared_list(robj); - if (fobj) { - unsigned int i, shared_count = fobj->shared_count; - - for (i = 0; i < shared_count; i++) { - fence = rcu_dereference(fobj->shared[i]); + dma_resv_for_each_fence(&cursor, robj, true, fence) { + if (dma_resv_iter_is_exclusive(&cursor)) + describe_fence(fence, "Exclusive", m); + else describe_fence(fence, "Shared", m); - } } - fence = dma_resv_excl_fence(robj); - if (fence) - describe_fence(fence, "Exclusive", m); - rcu_read_unlock(); - msm_gem_unlock(obj); } From patchwork Fri Sep 24 15:31: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: 12515747 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 4251DC433EF for ; Fri, 24 Sep 2021 15:31:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2988C60EE0 for ; Fri, 24 Sep 2021 15:31:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347176AbhIXPdG (ORCPT ); Fri, 24 Sep 2021 11:33:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347171AbhIXPdF (ORCPT ); Fri, 24 Sep 2021 11:33:05 -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 8D21EC061613 for ; Fri, 24 Sep 2021 08:31:32 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id d6so28549176wrc.11 for ; Fri, 24 Sep 2021 08:31: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=IkVWp2cRgm41mlWFdiuPcdEqOEMHJpLCxm3yFN2dD0Q=; b=h75DPlfzvi0Y5L6JHOzXyzPJNHfjtxZfuvuYNARNXh37ufDGKFdCsSz920sBteo4Ff 2+ZyPBESlT065wf3LBrNWNS/9G7wsxcBfJy3Eqk32hn43Shwy+pM6U+kJ9R0ZejuR+Vz yLXzbd9Fqh58hReqDGcLpg5cRhUJS1FqN9OB8KTqMrHIiZ4JuNtRBeI1pPj2jOt8Skri u0LDjp7UCnj2gZ2CFnDl8PaexMJygajFPVi7CRCis59A6Ez7Ikfjf32Yi5LUm+uc0SSG mLfBDsQ5wQIYfQHwtMpWP5Yhja4lWiRV/2XgAq5g2TWJONo8xDiz0PWZ4axw3N3EayBb DzWQ== 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=FWuyX1EK3kqqhZoAaS1Jfk8LCwkwEgQkJnf67aUUklyjBTpfvj4+D2sdh0k9fCrXDX iqh7B+zUhXQrvK41AqBWkNxGx/eK+UD8ZTsUFiKrJcUGbm42z6bCO+f1DariOMGnQzfT GE+mnFPC4lkdlDxW260mk7t9N2b3tvehJWBpavwKdCpv+bP39lf144ta+PR8BbFXDL29 o/V9s2pSBYm2enuysItyAPWMCUeEEIQoADcBFioZWlcH7CbSV2+FAxoBDh8iQYf0wYD5 fGzA4mmhz4/Ju7ZhxQWV9ROx7Wq0pbgkHmEouNjJ6MHVPyVAm3qQPy7lAttDMIfsKQdX Trgw== X-Gm-Message-State: AOAM533ppuoeianmYpDArCC4CQ2AGUAeBx6Qaih/RRs5oYnnxulAsz1a DXLYEq/B/WnaKoSKOkWbFrI= X-Google-Smtp-Source: ABdhPJwyWAVMcyXwelTSK6xbOku8WjdhPsn8N1Gqe2DhnPKS7Z/zmZ1yQ1Z6lfpvcNwol/KLubCcmw== X-Received: by 2002:adf:fb04:: with SMTP id c4mr12282673wrr.244.1632497491274; Fri, 24 Sep 2021 08:31:31 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 14/27] drm/radeon: use new iterator in radeon_sync_resv Date: Fri, 24 Sep 2021 17:31:00 +0200 Message-Id: <20210924153113.2159-14-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 Sep 24 15:31: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: 12515749 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 D4FCAC433EF for ; Fri, 24 Sep 2021 15:31:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF18660EE0 for ; Fri, 24 Sep 2021 15:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347178AbhIXPdI (ORCPT ); Fri, 24 Sep 2021 11:33:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347171AbhIXPdH (ORCPT ); Fri, 24 Sep 2021 11:33:07 -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 96A2DC061571 for ; Fri, 24 Sep 2021 08:31:33 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id w29so28588457wra.8 for ; Fri, 24 Sep 2021 08:31: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=d730QTcA12WB0FxkhM0n+vEOwpHIgTa3YH56dqVvnac=; b=mmuXhFJ0qEV7A7UrLuynDivz0cZ/r085e6pCA784a2FVamGKuvtee2dOg0nHjMroS6 UvOnoxzVqqVkOICBgHNknXEw/IrvfRGckdzbkBHVl/OUt87YsWH3vdebSEqmyRjailVa xisluGWdaUHNgleuVangMayhSmZsvQRQ0Y0AugyZR7fZVlGYF/hYJYwnv7WksLtZRPeW M9hnKztRktOObOPxp3fuur/JzOrEL8xoaHUYmyJMxKmwMTq2BZbRuI91zmIHt8nC7M/Q ncaMrUuYf7OxZifqVeoegdRXg2ILxqiwdC9Ar9zMogPUxvecDK1FuBUWunchdryuz3La JtqQ== 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=hX0THJAbaNkH7byD3E9QNNapw7S7SVWkOWJ+hjUI0QF49WooX8x86As7TVqcijXJS8 C/a5wgXqkd3CKs92jgT3Y1JnzCjYdQV6uN9Yoeywe3DGhILMFNCDjPNJs5QzmJ8v8aNb AhSrHWqOo+SHYj27XDtgJJqm5+li7n6QQIzaLnE9g5F43pGw5TAoZhs7nZx5HmrGX1AS P3LmpkZNHPkshrImdPacrc2vxMmclXK1qfk7oZWJkGMRzfY+6KS964VeAn8HCU4ZMeKn k9yY2qUXDSQ2cmF5aSJbvRewuo4m02wRYo+dQYElYXJiqVJgOWV9MUqHdWcDjpLeSBRY 8y6w== X-Gm-Message-State: AOAM530wOnuJaGTpiBO4A0K5fKKaBwbsuEhjbuAvzL2rX2qruhARfP5K 9PS+ZJiNJ+q9wckGpwG9sf4txacVhHA= X-Google-Smtp-Source: ABdhPJwijaRgtkvA1rTTTYnmmkrv5+ub1+0ElId0x1Nfo9cuEK8BbS8nqDasRqB7IOjx9Y4kXNMbaA== X-Received: by 2002:a5d:6846:: with SMTP id o6mr12539577wrw.327.1632497492228; Fri, 24 Sep 2021 08:31:32 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 15/27] drm/scheduler: use new iterator in drm_sched_job_add_implicit_dependencies v2 Date: Fri, 24 Sep 2021 17:31:01 +0200 Message-Id: <20210924153113.2159-15-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 Sep 24 15:31: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: 12515751 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 A830CC433F5 for ; Fri, 24 Sep 2021 15:31:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95CC060EE0 for ; Fri, 24 Sep 2021 15:31:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347180AbhIXPdI (ORCPT ); Fri, 24 Sep 2021 11:33:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347179AbhIXPdI (ORCPT ); Fri, 24 Sep 2021 11:33:08 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5671C061571 for ; Fri, 24 Sep 2021 08:31:34 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id d6so28549536wrc.11 for ; Fri, 24 Sep 2021 08:31: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=9ue7puBcgohS+7D/zNLeUPSF3Sf1Ar8z9127abKsq3w=; b=e8ktm8j908F+o346SDIu24SHhmwHHVacBvNBnmLYGX4bjCZ0T/w2KBISyzalGTK8Yp T17P07dLJfGwqG4bcMEg0/iy9raP7DcDQd0tLCXKQsIc7xI60ZjREFyX9DMJqWnGuojj jDGvLnRhkadbz9GldUlXFBEAx14AjGWHwHXSO1JJ7kF0yTFByHTJF7tKgam2sil4xO6o 6zOh6Am9zSD+6nGgzYmbR4VPM0y9Aqz1RfYmq7F0Gi/SNo0veUh2yfoYoz8TGhKiMxkV AJ0TOagSCKIjrEyz9ocSMalLC4UMTYGriCTWIlHJmqq5yBP0PAcuO+dzR5TZSftTbgiF wKpA== 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=ZyNjPqoLPv0cJMOzwD6aTe83tzoO2h1mwTxYJNDql0vA4xgiaQcYhySQIJKnIZvH+f 5o/5mSlldMV28Djhu9QFBFnzRrIVcm06cvyzLqkv1M/bykAkxoA+KHheVdAD2U5M6cLg wpONW2zD5EI2U+0nzfiUbQGO5rlgOuzxTFJ8R/uAIuUx2kS3M39Q+DOuZ3P44C9S2540 1EnLgmXtm/8pmycNrUk/RDlsNHJ2tTG2TTFqGbVo8nGuSMS2eMC6fAo67eU1kWjFRKqY jntAQgfValnxpxRvAXxuMO1pWDZzDAeFjKRlIgO1cK4CGFyQxWpXLsVCxaE5k8oM1zbg Vymg== X-Gm-Message-State: AOAM533EKxl0fPyLIQs34ebUo+ai5XxQ2dseRlkJXUB+UuYltn8Ttp2M ri0zL2WO3K9ItAW/v9kXZBQ= X-Google-Smtp-Source: ABdhPJw8um7sB9PGM9PM6XT+29vgXwyT8JT1FRlkJlu9BgxfIgtfxD2SFGvg3W5V/i3CaMY/sscWFg== X-Received: by 2002:a5d:6b82:: with SMTP id n2mr5767805wrx.85.1632497493377; Fri, 24 Sep 2021 08:31:33 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 16/27] drm/i915: use the new iterator in i915_gem_busy_ioctl v2 Date: Fri, 24 Sep 2021 17:31:02 +0200 Message-Id: <20210924153113.2159-16-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 Sep 24 15:31: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: 12515753 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 E2814C433EF for ; Fri, 24 Sep 2021 15:31:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C8FB660EE0 for ; Fri, 24 Sep 2021 15:31:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347183AbhIXPdJ (ORCPT ); Fri, 24 Sep 2021 11:33:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347181AbhIXPdJ (ORCPT ); Fri, 24 Sep 2021 11:33:09 -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 A9A70C061571 for ; Fri, 24 Sep 2021 08:31:35 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id t18so28761144wrb.0 for ; Fri, 24 Sep 2021 08:31: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=s+B96AdxRkADIO5Sz7pGY2LZZPwHDe6rOqsFSHpv8M0=; b=pFwZpIzK/LMtY4OsZhjTXzHSD72F01e+k2NV8lY6cZ7PGoSTxw3n6jgeiq4UhDo5JI jgdJEwvyr31jJT4CPMMF0TEhEAZRN9620dWtJs5o9bmhiKD2beVKeh/BfMGbT+teNKrL js2gt4P2AkNYQ3x2eBQh/pCSaHp0YGNWgInxbKgRmYQoW58ykaCeKnDnOOKvbTELJsMD 8Gh3+rrb4kSPIDdT3p/Rn9BSbu0/B4zmGm1h5D9UtQGfi1pzWsnT4u5jm3DCu4uwmLKa OcCpLKlDOnP1LZdTvlM1SjhnIk3ijiZK6s++8F4BmimDUoRPDPHT6BFElXfoGfXgZw3C kj/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=s+B96AdxRkADIO5Sz7pGY2LZZPwHDe6rOqsFSHpv8M0=; b=ckc/rTLYX3n5U8aBIovG5IrjW9rFo+lKAWYIDZtATzmSj6M4cl4lHtwC9xOA47j6HN 0Lyx9Tkc9V+bvf2xR7HTV9uDYLNSm5SAP0fwmnbnz91cc0+pRPivFr+Q8c8vdn6wYrvU edKp6XZmmJlaKahmDuvx7TWrUmJqpctUr2oa1QCt8CkKBxgAKmLvODEr7Mb31N0vrfIe HfXazrfXbuHEPLYJy1AqiEPyaIbNVkRgz0+8sG4GszzCzxY3aCeN23d9O3463NzcgPZa p4RokUr6jK+hKv6ksZiEQt8/BMGQpRtobS0ICZD3NqpRUj0kIxgT4uxubBG1wCl7IyVt YvTw== X-Gm-Message-State: AOAM531jaToqDmzXKrUytdxnmcgLZ8k1vsLBUy2NsRWe0VJe41BO6SGR WOihRgn6WtNC7FmoEGmxTkk= X-Google-Smtp-Source: ABdhPJwWULq+EjLBYu8IpzfvBCbg1EetZ0enHJ6BjWFO8X3kOoGEU7xjuFzefEKYfgPy1rAVdzphSQ== X-Received: by 2002:a05:6000:144d:: with SMTP id v13mr11902637wrx.303.1632497494380; Fri, 24 Sep 2021 08:31:34 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 17/27] drm/i915: use the new iterator in i915_sw_fence_await_reservation v3 Date: Fri, 24 Sep 2021 17:31:03 +0200 Message-Id: <20210924153113.2159-17-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 Sep 24 15:31: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: 12515755 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 0CB43C433EF for ; Fri, 24 Sep 2021 15:31:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E9D9160E97 for ; Fri, 24 Sep 2021 15:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347186AbhIXPdL (ORCPT ); Fri, 24 Sep 2021 11:33:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347182AbhIXPdJ (ORCPT ); Fri, 24 Sep 2021 11:33:09 -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 82F08C061571 for ; Fri, 24 Sep 2021 08:31:36 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id t28so15275533wra.7 for ; Fri, 24 Sep 2021 08:31: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=y78+lw9uajwG2nya7zXv9lL0eVUeHEAbTx0GIeLnzI0=; b=iO4CmtdNAnL4uuv8xgnCB16BsxNVtl9ibKpLd6ayJybZbrebzBGngjD239pa1XN9vn RESwql8n+MLOmofxMqnr5ZJtbNSAjAp+LM1rba73yQYAR1d5zQk62rr2v+ZChdv+v2FW kXM2uIQd8P2iXiVKkNl5y2xUHltmfphvSXBvVHTeJT5fXvF5sIpXasUG3dj9Vmy65iyf U8FM+VLTayiyUbzxVG95NIo/rcX9u6mCgbf+aTdIM6NaghwdvhA2Qe7bm3HpjQ/3aKqY XtZZiHLMMT2B/EsfYvK+8RPtydU7Hu9eflzOgSMklpRKcaX7bf6c4qX5jQ3lwBpwOPtR Fi3w== 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=k12KFHai45eC09mCw3Ve81I6NGVIpYSfxlLnMs1faMrq/fTeQQKAc7FUvJUkeOhG5u ejhkqG9YQ4lAg2Nh7mrl39Q4YWEGrG8ecK1gpwHJ9ckgo8KUCghfmT7+sEcyg4lBwS1g 8xZqJZiqaLXa4550zCwhnzWHTVmCMIiDb/5ctP8OSv5MYjX/OYlaLNGT1m2YbmWx6N1T NYKaY+Gc0L4FcacFlcuI2EfqV6FJxKREIYGb5lSoASb6SlWKPa/GMwwdSDkIOrDOFu/L HvFNfwHphzpoubdHhzcSl6Wvoxjj9YgeqHAp1ixKQNzUovVS+aNv0Zi+jv+tPGqiIY83 LPrw== X-Gm-Message-State: AOAM530exq89D9SAkjbsCD/fSNmc5Rs44FOl8byMuawORy2HFQ4fRVNn ss8b8DphTn1y/E+QdbX1KrbzXc9yuJU= X-Google-Smtp-Source: ABdhPJyxcD57OlJxWG3U4RdnHWzhMBXfGvx5jpnBs0+/4OjO0WJtsxhWnDdkItuAS//GCUb3gqE/Gg== X-Received: by 2002:a5d:460a:: with SMTP id t10mr12532920wrq.145.1632497495158; Fri, 24 Sep 2021 08:31:35 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 18/27] drm/i915: use the new iterator in i915_request_await_object v2 Date: Fri, 24 Sep 2021 17:31:04 +0200 Message-Id: <20210924153113.2159-18-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 Sep 24 15:31: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: 12515757 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 B43EAC433EF for ; Fri, 24 Sep 2021 15:31:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9FBEE60E97 for ; Fri, 24 Sep 2021 15:31:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347193AbhIXPdN (ORCPT ); Fri, 24 Sep 2021 11:33:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347185AbhIXPdL (ORCPT ); Fri, 24 Sep 2021 11:33:11 -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 64A0EC061613 for ; Fri, 24 Sep 2021 08:31:37 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id i23so28764698wrb.2 for ; Fri, 24 Sep 2021 08:31: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=QNte/ZxHyZbzH1TCe5eQqnVIdZH6R4S8//YNPJMBVTc=; b=YcayZl7Kc7T3Pj3XVmGGOuIjTxpVoAoI2od6lbwc9TSJwmi1zd2t7gVnV0cfgzyTig +v4iCwgn+C/amFzCz6IV5oMD3rhliK1MCiVloKsAwGJiE8yKBag0B88v64dyrnQlbJ3p N5qSv7jL72pGt6itiSaEbCXydbAN7OJSxmtqAoaRdgi4AJlduo3WFUSMDZ6R1mjKutmS vtGx9Uy43a9KEsMUOxZCwgD+iL1JYZZ1bIiBPnZzkvkXpdgp/+Jbg2WlXPL4Q85rlpmg xcl33SGH6IJWsFCEzL2oYC2aVlzRD4zUmvtv6U5jz91dAsMdPmExJuBtBf5lNZJKSxZZ Fa+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QNte/ZxHyZbzH1TCe5eQqnVIdZH6R4S8//YNPJMBVTc=; b=MZVcO2z4CIP1TlYYLxpOxjEHTR1koD4lbIFvI/VhFEEc3b2jnOlIKcy7NDogveZJmH 0mORwKkDtx0yR21c5e+7zHtqaDoBB/dHmGPYXYkbRC2+X/1sxVgZ3s2KTsNteeNhxI+6 8sP+hGFv3IrGqp+GlYINs+3qA928X0unCjWd+OsKGtoPJZXrIAINzBA5zCmHlyf94zR+ ZE8H91W226BOSxeLI9IJgkY5J3PIzBaG7jbGcrpola2t45aCyG462mjb31bMGgJf/vFK MuqvemX3L5buTVShhJtl5JGqqRX4DR+Ylrq0seqM1o/BCEaF4ISDLfK71/93rFnS2Ms6 wrqQ== X-Gm-Message-State: AOAM531Rqj1pltnIeg99fm6W3rvzgZQUZuPS5bLOMqjHjBxoxfSXWPZX sGvDQpZadyiOxvVxPz88fL8= X-Google-Smtp-Source: ABdhPJyQdLXkMxahC1Tzbt4CRsN/npvnT2ZtzZDDhzFaKodNBkXw9jGP/wgMZdIO8YjjpySbz9jZuA== X-Received: by 2002:a5d:6292:: with SMTP id k18mr12305654wru.110.1632497496045; Fri, 24 Sep 2021 08:31:36 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 19/27] drm/i915: use new iterator in i915_gem_object_wait_reservation Date: Fri, 24 Sep 2021 17:31:05 +0200 Message-Id: <20210924153113.2159-19-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 Sep 24 15:31: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: 12515759 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 19567C43219 for ; Fri, 24 Sep 2021 15:31:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3BF560EB6 for ; Fri, 24 Sep 2021 15:31:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347184AbhIXPdO (ORCPT ); Fri, 24 Sep 2021 11:33:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347187AbhIXPdL (ORCPT ); Fri, 24 Sep 2021 11:33:11 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 660E7C061571 for ; Fri, 24 Sep 2021 08:31:38 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id t7so28542536wrw.13 for ; Fri, 24 Sep 2021 08:31: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=sR69q70gSeg6sG3/QgjbBFqvIqYfytfoA0SgvZr7HAU=; b=DPqiK0QGMir4AEcKBE/0nJK0LmfPdYfiAUEmkA8qHxsVVv4LHPBhMaUJcZ/9gZjTdQ t6x7gI9t20wuBPVwNG3Fxep4a0efbXOXwcjjcqvS0ozmwcvmRw1JAcScYGuMBElbKzTv 970VEWqKQtlqmQ3gljOAP+h2G1t/MnAZABZoExQGXuV/BrWljEYsfNWRsalMTEEmlxM0 nLme9UJU5PEsk0IPB481MpiNIGjKP6sKSVQqRJ2GjrVyMSGNIL3rvpWAyDSqtHKIGsRT 2fcVAYIRoOkcbn+lW7wN/Asidz25tHjtcpoxS6QnUr+8eofclLZhmGD7AyWsgp5Atwys dLSw== 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=OLq/hcmJH9yHM9U+6Bpc/pjnZYkU9GjIhC8ZreylbzlDgAXiz+HmPtxsu8NJG7b6Np SRnWTybk+QCRrWt3bprqKHt8ZWVgd35Idvul0CHR8tR7tT138JTm/4xbx3MxTLDUOQxe DpykCp0l6xMnlft+hyuH0pR7XU5WXDOp/8LdOLgZGqdAmbfAcWb21u/Y1JeDLahi6Zu1 U68GniAih5eDjIJSGpwSIH/SHbmcOUamBsksh9bbBVGY5Q7b6nQl20oO/aOpDVdHk4yW yisJs8W5O8+bn0daFyFAXEubZaiF+tNWtO4aTC4R5VHlkMCpFKHeO+3yU4eyPfpnjK/D bx2g== X-Gm-Message-State: AOAM5307cdW2V+tVLAORslLf5BFgGik6cj90Ry46D/TwzfZoF4J5k4Pp jR0cCqftC1BYMWHJA7oZUNY= X-Google-Smtp-Source: ABdhPJxlt6d85SaAGgSvsRODSO3oHYmCGLPQqiQ540iLtKWHx5U8VK/yjhJbPFlndLeFvwsgGPUDFw== X-Received: by 2002:a5d:56c4:: with SMTP id m4mr12256993wrw.225.1632497497105; Fri, 24 Sep 2021 08:31:37 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 20/27] drm/i915: use new iterator in i915_gem_object_wait_priority Date: Fri, 24 Sep 2021 17:31:06 +0200 Message-Id: <20210924153113.2159-20-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 Sep 24 15:31: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: 12515761 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 D9A3EC4321E for ; Fri, 24 Sep 2021 15:31:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4F6060E97 for ; Fri, 24 Sep 2021 15:31:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347204AbhIXPdO (ORCPT ); Fri, 24 Sep 2021 11:33:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347182AbhIXPdM (ORCPT ); Fri, 24 Sep 2021 11:33:12 -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 76673C061613 for ; Fri, 24 Sep 2021 08:31:39 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id t18so28761765wrb.0 for ; Fri, 24 Sep 2021 08:31: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=ETFFVmDbRxb5cxrXOen58gkxhSGsPJL2Y8O/7sOAJto=; b=Eqf0TsStDMRTsdGFJuWVnJf2v0hiU5Gee3VDgqFxAzZ4shiQx3J5v0f2tbpNl4fudu QxRSbr4FinII9L6a7uTnPsMcOD4Q7sr0QVgTVMlE0IQQ7UhgKNEdKBSbKw8dAaBHx0QO HhzVzmR5sssTD29ad7XRYJJM5oojlUuZEXL6Zpek3SMvs/GxmhfaMUB44UdSBa94IRpz X8iDf4MhkoUZgslH5G25e2hc7lC6G4WAVAP6Vc47lfyFwNdQUa3v0sSFf1LoN3K7lRC8 e2j7Ij8aQLyPV+xNhlUM039IQ0xM8NMqbs7yLdau8szJe3EfJ9EDmylj0pzwlLX7VXz9 4o6w== 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=i0JJG78vTJTx2nu/UxssvXXZnE8+d71T7WVwE7u+zh7S5CboxUalbvWtLeTEjnxD2q MeIx5SVpOHyeG7POsAJxri7S57YXqZaPqG4EeeEmhy3R5Bj+uC79shIQXEaTBfwjy1Tp lt4wSlnw/iSu8v1/zSNrFQ05hbHmeU41VI19A2TZl+mq+VrEy0RCUlUbquNgR8QB18bk xrXkM+g6T4u7xVtLhXF6H4oXLtPHvjHd7qZPmHfIeGWDzUIB1BCGXTL7rQHjYp6OwYDP LVtYMCILzyoGAam2CcRaHPXCgR28xf+ASU70MdQSQAqMF/mwgFBoM1NNxN4PguAjHpEN /MrQ== X-Gm-Message-State: AOAM5334OObrvF8Yp4+mWXvsgHjbzMH24WXW3Z0A39J0GmBUNFgBJ+ev BuzuX0mnAFfFtImw6bmBCiM= X-Google-Smtp-Source: ABdhPJyEIbwNagKQjRCKtbLDbhGeGif8L2hXwXVmEhLFr3BzHmPyroyuxSsJRkQX4iKyLiCBG6iiCA== X-Received: by 2002:a5d:6846:: with SMTP id o6mr12540258wrw.327.1632497498031; Fri, 24 Sep 2021 08:31:38 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31: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 21/27] drm/i915: use new cursor in intel_prepare_plane_fb Date: Fri, 24 Sep 2021 17:31:07 +0200 Message-Id: <20210924153113.2159-21-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 Sep 24 15:31: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: 12515763 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 92195C433F5 for ; Fri, 24 Sep 2021 15:31:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E5F560EE7 for ; Fri, 24 Sep 2021 15:31:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347205AbhIXPdP (ORCPT ); Fri, 24 Sep 2021 11:33:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347196AbhIXPdN (ORCPT ); Fri, 24 Sep 2021 11:33:13 -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 659EAC061571 for ; Fri, 24 Sep 2021 08:31:40 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id t28so15276123wra.7 for ; Fri, 24 Sep 2021 08:31:40 -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=LqIJKlQBXsG7Yc8cj0wu8e+zpM+ggMNapNCxgSE3sA3BXCeRQfZXfYBiUMyShPkWwF oL0yYy6+FuFweL8evwpfXLe7KsUQT1cRcGwNKDJTayuWJMZxrmBssXfy6tNFistzneu5 YIgCRNeoWDeSKToAGWUSON7PPEH9jzCqDSKnHBKgbbBYlKQCMubaJNoBBq67UsfHLVF/ 3A/cxE3KByKJtVe2TVdwchsrA3y+QM8ltA0GRo8u2gcNrsyppg05rDQxX/8TwDDWX+a9 XWgey+cnt52gL738JuvwoyEVoRUu/YczhvzHO49m+ytujObmT4tU39KP9UwQQUr1o0UR o+ng== 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=lFRCNgLr9mKUdtTZ4SntuF9y12/4jNwDMHNN4Kkd/i0zgcmQRmX8iBxbmUkdVkXUAZ f1UkfvqIuu812eYQrNYqvZX3MvXrV3YI8a18kHFbJL6Y2YqsO1Mr0U2VBTPTo4WgMiIY 2wy5AoqjYc8fQQTcv0sg4+0wzaPLE+doU1sfsOReKgzuNYSVP3KwdS1G/Vla7xJ5NY+L h7qb/ei8LGeFY48lHS44tPt0PqtbGFG1L3HxmWiQEMKo0g7xE/D+HXrqiOvRTP6miIPN rlPoWbRo/YBHTibgyAe6ddgkbQhvYC/lfSOfI36QRGKgl+hFB4H1IXX0AnemNYJDfMOX 0g6Q== X-Gm-Message-State: AOAM531/PfbqsPpO64fh1TOq5NR2VnWw7Q/xjcdYIvXgVZfhAjgRM2Rg WaJZJXDMNq/SKyM1JKJk8wQ= X-Google-Smtp-Source: ABdhPJyy/4U2GaT2BMEka+ag/8o17YZY2/EO0i+JqubriX7iz9usIJ4MLyYl+KmBqFvgybBZUwg4AA== X-Received: by 2002:a5d:58ef:: with SMTP id f15mr12367035wrd.160.1632497499033; Fri, 24 Sep 2021 08:31:39 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31:38 -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/27] drm: use new iterator in drm_gem_fence_array_add_implicit v3 Date: Fri, 24 Sep 2021 17:31:08 +0200 Message-Id: <20210924153113.2159-22-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 --- 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 Sep 24 15:31: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: 12515765 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 3D037C433EF for ; Fri, 24 Sep 2021 15:31:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A22360EE7 for ; Fri, 24 Sep 2021 15:31:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347207AbhIXPdQ (ORCPT ); Fri, 24 Sep 2021 11:33:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347202AbhIXPdP (ORCPT ); Fri, 24 Sep 2021 11:33:15 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 517D1C061571 for ; Fri, 24 Sep 2021 08:31:41 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id g16so28700366wrb.3 for ; Fri, 24 Sep 2021 08:31:41 -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=gbdY/KA3GiigP6gfzDXQt0kMvxgGUf2PrYOU3yOPF9Kh8nJa9t1fKH9GDL9tktcv7i gKBby0cEHW216F0Q3ocIcvrj5fJPs1++oQEOdfDdKv4Bvlt+6tHlqahiQYtyXHBs82iu QA6YBMC60kODJvJLwsB2c+cOGwoEtRWfDkUHL0ZExuHvZ0YNmUEksOwXHtJqwFacYSNa zvL+YtxiqCgZRCNxqIC87FKyfkvmI+vCAoz5xsV445eo1QUFL0LypbJLbGIhUX/7u82Y QEeT+8HjaoFMoWgPJb3TA/UaTMp4SHLyCr43SnnnjC35G6QXBOV5dzhtpel9nPd36qCw R4qQ== 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=hb2cjxwC/2pRjXnidhGjwnV6JDJv0C+rSDBqD8p6D1ZXLZru/GzTclrg851AqAztbc vXM68AAspdZMdN6xhxb3S987zkb1XdnzD9NO78oV9bWAS55RXFfP1wRP6VUvNBHYXd55 vQexYxLDutCmPksniSb8TlTsZmw30Vgd6obpAZjOF5kXokQAj83Db1mVqJNp/KBAKN8p fpRfv42Wo1uUem0gp1m6mfvcHVZvQ5gXxU3Z5KKxRAezGfn17JQLiAiuMu+rs+x5crRp rx10+voF7K22xw03gdyxZIF/bwRIm+tt6IkwBCk3TyDZyVo8CzNiEuIk/izmN22jvibQ pHzw== X-Gm-Message-State: AOAM532YPpsQfAIN29O86Yvyh0JE8XlCMKjiuLFHftKqYv/DSynueMql WwYeNtiylSn2IKs5ra1WRjDditpVGO8= X-Google-Smtp-Source: ABdhPJythMo56KnpHAm9/NvsZq86P+VwYHnzlv11F1l50InYobwErKrgQWC9UACBlTFYmZT6gOlsYQ== X-Received: by 2002:a5d:67cc:: with SMTP id n12mr12094112wrw.381.1632497499953; Fri, 24 Sep 2021 08:31:39 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31:39 -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/27] drm: use new iterator in drm_gem_plane_helper_prepare_fb Date: Fri, 24 Sep 2021 17:31:09 +0200 Message-Id: <20210924153113.2159-23-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 Sep 24 15:31: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: 12515767 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 281C2C4332F for ; Fri, 24 Sep 2021 15:31:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15D9A60EE9 for ; Fri, 24 Sep 2021 15:31:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347199AbhIXPdR (ORCPT ); Fri, 24 Sep 2021 11:33:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347198AbhIXPdP (ORCPT ); Fri, 24 Sep 2021 11:33:15 -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 4864DC061613 for ; Fri, 24 Sep 2021 08:31:42 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id g16so28700495wrb.3 for ; Fri, 24 Sep 2021 08:31:42 -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=Z9YgoSWQMi0swZmjtdlmJm9oQRufLdcZM/Fk+QKFTcWara2nRxH6ZMFLLIE1ojh9JW qd+ITxakFpjTfC1yoC92bAHElJOaI8R0p+b79QFmgAhPYkJ9Y1757HhpBSBRiNQGsHeY 1h3zAGM2YraR5hAj0XGyZxRjdSfk7+Xe7tG2d71RsgdUi3AgaqZ6X0vmALeIzqVK8Hjl PAZlW7gjLCgVifRauC7krU+ad1grJuZXnV02Xi7aDLfTfioqsSefV06PoJVgBFVZqt4D YxLzJzTgjV5SDZc1+Sj6PS+nel+/d+VXvWcTx4J87buVta4c2F3F1wiXJ+23MfR90BWe 5QgA== 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=RIhmvKPq2ZKYggj/EXhFv/Z90o2oaiH+HvQd9Ra39jIfP9T9FNVTuf7ApR5I65/ZOo y0a7ddV3vPdD4MFg4J27lPEPol4ExyX7YDBfO0K2+WPouqdZYLhG2Cy7kbL/7dkZKrfh N3g9z6GMjFyE5M4hSw87WPblsBNQpaiolhPGez0p/uCD22gKY+UXI4hSnsFWV807XTiw IeIk0Sg9Qb4lbc1CzoZXJX9VDrBV1dhJpPC0PWHdC7PvNKtTPkcXuZjcEogTonbUKt0g +FH/izm6zUmqfCbNTBTMSTTRHZE1MQKWitiArho21Tve+e4TeLjJa9Gau9T2v6l3ZvWo mJqA== X-Gm-Message-State: AOAM530lknL5J6fzzwqx+p8rydSFHg12fAo8oIvyjg+9aSWXsastUE+3 fA30Q8tHmWU6RsE/ghq2Qko= X-Google-Smtp-Source: ABdhPJyExBTORM3Xmjlq/oYuKANVHGlgS1MmSJcPgu3g82awnnlo3Aai1c/s1G1zWoB7O3vsEv2p1A== X-Received: by 2002:adf:9147:: with SMTP id j65mr12063286wrj.163.1632497500882; Fri, 24 Sep 2021 08:31:40 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31:40 -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/27] drm/nouveau: use the new iterator in nouveau_fence_sync Date: Fri, 24 Sep 2021 17:31:10 +0200 Message-Id: <20210924153113.2159-24-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 Sep 24 15:31:11 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: 12515769 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 D483CC433F5 for ; Fri, 24 Sep 2021 15:31:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE65660EE0 for ; Fri, 24 Sep 2021 15:31:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347213AbhIXPdR (ORCPT ); Fri, 24 Sep 2021 11:33:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347209AbhIXPdQ (ORCPT ); Fri, 24 Sep 2021 11:33: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 26142C061571 for ; Fri, 24 Sep 2021 08:31:43 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id t8so28740604wrq.4 for ; Fri, 24 Sep 2021 08:31:43 -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=hef6b05hQy+5lGerGWpcfLcr9CeyiiWOn1lDY3P3sgSPdAg6Nb+txTI3e7Ym276Coc BUmcrvtRlg63/BmdOK5uhpfgtLSoyr/L6RUKzu/Ct7NAbo17Qhb8aR/3KwXoMnJFNDFp RDbXA2+0Bnwyi7I47FHZUjyj1KN7amdrhZiCQJ406fGjD6o/vP5JydsEWwgtZpdTYvyB wOFv/6F/YNr1LHOsUb8SbVNSQTRM/VUovKgc751PksR3+qI27eTUQmsaglPU7+crkhXG gvXcPxVHpse/eyifuhbJrWCL22RzvujeHGxTcbVN3e/O6yi/0vd2LtfLGY01dJC2Yrks Dxww== 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=fOos5BZRwVeL2Ti3UKqkArIAGNhkV8kSnKbRVdncLJ9mnUSdLToHlcJretpkIL4tfa iBTMbTvO7SLQu4S0Qcnfr8vUxrS7nQp4ABLVT8QCthXwLJ90ZSyNv2b5ceBLtUyzsB5O kVSKT7KPb5fPqvmr5bP18pC7lr+D9MfkjCGvbMDjqK5ePOTkML1NxUdbmv9p6GLelNqx yRGSiT1/9DO3voa9cTDipYlyQSIHnrl0VbOFePtI8ryPhIzPeyxe+C2Krquq5Stfzn9o AC+kQ16AmrpU9VN+QddVQDHGX2DJjnjFFpRpQjQjgzTmDwwlRpFvdXYpWdhE3M1nSbos IaaQ== X-Gm-Message-State: AOAM530MlTn1cj5D4SL6GPsdBezPPFmJzPsOT81TV38GRIUUOlKAJgbG 0VWz/4swflKsBYsXcUncd6g= X-Google-Smtp-Source: ABdhPJwCQ50FiYFb6laK69EQMOH+0x7uDi595rBzL2mWBKY4VTN0iDpCqcFixhE+dNDw9UjaQDD1KQ== X-Received: by 2002:a05:6000:184e:: with SMTP id c14mr12162487wri.242.1632497501846; Fri, 24 Sep 2021 08:31:41 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31:41 -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/27] drm/nouveau: use the new interator in nv50_wndw_prepare_fb Date: Fri, 24 Sep 2021 17:31:11 +0200 Message-Id: <20210924153113.2159-25-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 Sep 24 15:31:12 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: 12515771 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 6229DC433EF for ; Fri, 24 Sep 2021 15:31:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C5E060EE9 for ; Fri, 24 Sep 2021 15:31:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347212AbhIXPdS (ORCPT ); Fri, 24 Sep 2021 11:33:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347211AbhIXPdR (ORCPT ); Fri, 24 Sep 2021 11:33:17 -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 07CD0C061571 for ; Fri, 24 Sep 2021 08:31:44 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id d21so28562482wra.12 for ; Fri, 24 Sep 2021 08:31:43 -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=OaedxYvHghmjqk4DBag2kWlEQZeISxgQBnPcRCG5N4NPM1OqwH9utjCi/E7qmvqPAO 63nXRQ0FZgU2WClkMphgqMFB+2765rp9KhDXZfEl/d1ExnvmGUgDOmYF+9gkzBd3iYM4 AAiVOYVCMVN+xyKIbuD0SWsBYl9M8p2LS3xGf3Be3gYopRJCnrHJwSmDwqKqFWuFPaNB ap48mrEfys/ZGfWz8LFuYpqjqmQFzUw7A47qH09zgf+aEmF73HIMtdSU4To54BEsUtes gkJFAKyWEXk+t979Q4WhmL0nrDhcekrMPLMaLmZfGegZUsE1QWy/922WmOkcG/p6HQ8C 6w0g== 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=ws9QKZAp08/CzOd8gO2ECuGIwF6nVLLBTUUS6ANgFtfvMUTYdaVmrXzcYM7MJ4OzMx aS7oWrFVP7sOBaTG4CZC5Tqk1AYkEk6mVfJzsaS2rOZlxCqkMjbqH7ZtTSPsi45mcySU kkwXoWGCUzzfVx9X+oNbhct95B3DmEeddAtGD2NeUuYxdI2cQP+fEcWL/QWvLrd3/nqM ScsrkCKQ/rBzpMAQlLoEAiQyKXNU6uf+0Pz+9O4YO3VftSUIIQV5n57d7ewGu7vU8IvZ QQavhowfAUVhjeZKWqcd1hw10ppvOMlVn9r41/QLS2uqCyXnWwVdqQOfsTIFoSZOn/HJ VefA== X-Gm-Message-State: AOAM530oiRdeMJuyFVJYqZzSn/Ta+EUzCriPx3P4lUVJoqubOJGov5ye Km5nnVpm/mRZBJq5PrpugLs= X-Google-Smtp-Source: ABdhPJz8idSpsAtOJoVoMECo8YlmNubvC2BJykpIFF14bKjqW+Dmv7uDeIq1SLFp6iGiqENrmWyFnQ== X-Received: by 2002:a5d:6292:: with SMTP id k18mr12306437wru.110.1632497502693; Fri, 24 Sep 2021 08:31:42 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31:42 -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/27] drm/etnaviv: use new iterator in etnaviv_gem_describe Date: Fri, 24 Sep 2021 17:31:12 +0200 Message-Id: <20210924153113.2159-26-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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 Sep 24 15:31:13 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: 12515773 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 D63ABC43217 for ; Fri, 24 Sep 2021 15:31:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1C3360EE9 for ; Fri, 24 Sep 2021 15:31:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347214AbhIXPdT (ORCPT ); Fri, 24 Sep 2021 11:33:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347209AbhIXPdS (ORCPT ); Fri, 24 Sep 2021 11:33:18 -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 CEE7AC06173F for ; Fri, 24 Sep 2021 08:31:44 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id g16so28700828wrb.3 for ; Fri, 24 Sep 2021 08:31:44 -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=qcTCwplmusmyAvJ40fwoarKDm4FklaUId8KuFdmldXBzzf7vYkFVTyGyrhxR1exe+a Ti7FFhKsfqQldIbzHeSQHl/TSs9QBtevczGTSyno+qKVRsDPyPX660zU8DjZofoZojaW FNBfpXcAWhbxnD1RL0eiFC5NIsuYG9iBDJwWGfziefGeY7RRSGCSKm29W/jS4EI+WeOC x2TjnDEX7xTqdcQVq/6V1GNr8UvayIb2+zzF730lCN0tXYiLqK7eUMVsXcW0Dw6sWMCg O6fFa1PsdYFIB+Ok6yr8Da4ddQbOIw3OET21Mtlp0kAmgPA7Jzw4pdmsBA8BV/ZPCGtt Cf9w== 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=F/SnUQPdtNF/+UWviCo3N710N2i+A05Xrc+eAdoZ8oWxUCM6LLE3IuWcFr1juo5hTf /PpsHeQMQTAG75JMZzrk646BdA06+M7uRzAafYdzUR6kSiDwuVi6z+UMNFsLGU9AW+5P iDGpfqvmkzkMYwvXQulooYwQKolRpokSAHw5x1h3MiFO1nMyd8cUFXWbhgM5VEnMoT7u BwCbwggluMw2MDKc6X20oWPG7uf0zDuDOnPKtj84OkuguSEhoZ6LbC/o+ER4mEs/6Vai SLour+c0D+h0NtIj9CbZQ7s+y3SGW3tjWS1L1XLOYZ0dFxWBYeePzpZ+3zRIrPo35F2Q wY2w== X-Gm-Message-State: AOAM531UsHSAaViKA1KyYhHPEqCMOhaieJ2fa6J+uJERuxKift+a1++e L4I61FprJRTLmHujQK/Jn8Q= X-Google-Smtp-Source: ABdhPJxH7t42u6+VO/+NY11r/YcaQHT6Oijj6TbR+5kXQxpt0qv0iqBvhkcje1t5rM51uMyYkthXsg== X-Received: by 2002:a5d:618c:: with SMTP id j12mr11983777wru.189.1632497503516; Fri, 24 Sep 2021 08:31:43 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id u25sm9902248wmm.5.2021.09.24.08.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 08:31:43 -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/27] drm/etnaviv: replace dma_resv_get_excl_unlocked Date: Fri, 24 Sep 2021 17:31:13 +0200 Message-Id: <20210924153113.2159-27-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924153113.2159-1-christian.koenig@amd.com> References: <20210924153113.2159-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)); } }