From patchwork Fri Sep 17 12:34: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: 12501829 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C67CDC433F5 for ; Fri, 17 Sep 2021 12:35:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF39D611C8 for ; Fri, 17 Sep 2021 12:35:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244183AbhIQMgn (ORCPT ); Fri, 17 Sep 2021 08:36:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244172AbhIQMgl (ORCPT ); Fri, 17 Sep 2021 08:36:41 -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 660E1C061574 for ; Fri, 17 Sep 2021 05:35:18 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id i23so14966368wrb.2 for ; Fri, 17 Sep 2021 05:35: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=5+u8qc2R4BG24i/iDhv9Dl7RY3z3hrt5qBrjleD7a4M=; b=DO+agg2OEDNAzmgjtfIQLf3/3wD5w1pe/WD3Cpyqz0W68aOLG05Std+bRdufeVNLOh YV5BHaNcq44k9EwUCXm3hoONsWD9mIM0HbLXYf5WLcvxDP/cj1Or0BKiSbr5PO7at+pf CybzRBhAwoYAKlQ/VTXD2BHEo3R0Vu4gu/mVIMCkGr+fQzGUgQY+i8RqyqGwKoEGRVl5 Z52AK1fZGnHYlJENlBQyx+hQU+Ku6oz6ZtUpHoPcQNglhbzJm3+tfoZZARF9FftS12Km g0GlN6xu34ZCQWPdAR/t6Sn77CRRbcCD+yX+PW9ZYTK1ZYoYHvzcjAmGIAHHpGgw0rEz BmXA== 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=5+u8qc2R4BG24i/iDhv9Dl7RY3z3hrt5qBrjleD7a4M=; b=ca1rjSQpGhIKxYngT52RO787t2k++/XoQSg+GoCd1pL6wvo00Q04gSNm+44k0wG26R 4NAJ90qDIWrlo5SE/UOebzLbg199kh+80lLmHWqXYrUZzk34hK1ULCY9MEMDM46IHZj3 H2Lz8s/2Y2uA3DsXIjSEcI+PJIK9ErNl/00GFhn5mscIcS/0biy5njatjTFEKKVIGhzp IIVItgIIL1y4zXQPW/foYXw3fAxkarqnL6cFyCUOMNM3MZRhgp1A8XuXDnf1LXxlcNVt 6TLproiM0jTP8RiSc/j9CC097asJWfLiWi3mYOmN+BuTP2JCV9zzxjmElAo2NnRpBVbA B4Lg== X-Gm-Message-State: AOAM531R/6Xj/gDOtHOf3hG9aveHocfjcogb5bPISoJyVyEy/rCoWXyF m3m89HSgBzFe3lVhPadQNWM= X-Google-Smtp-Source: ABdhPJx2rLT7WcIhsex2Jd1FsoSV3RqyWPtA/hnLC3xhDpUuvFYmlmwp19mPoQfF5dhm0JkNo1Yhzg== X-Received: by 2002:adf:f543:: with SMTP id j3mr11911860wrp.287.1631882116985; Fri, 17 Sep 2021 05:35:16 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35:16 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch Subject: [PATCH 01/26] dma-buf: add dma_resv_for_each_fence_unlocked v2 Date: Fri, 17 Sep 2021 14:34:48 +0200 Message-Id: <20210917123513.1106-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Abstract the complexity of iterating over all the fences in a dma_resv object. The new loop handles the whole RCU and retry dance and returns only fences where we can be sure we grabbed the right one. v2: fix accessing the shared fences while they might be freed, improve kerneldoc, rename _cursor to _iter, add dma_resv_iter_is_exclusive, add dma_resv_iter_begin/end Signed-off-by: Christian König --- drivers/dma-buf/dma-resv.c | 61 +++++++++++++++++++++++++++ include/linux/dma-resv.h | 84 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 84fbe60629e3..3e77cad2c9d4 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -323,6 +323,67 @@ void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence) } EXPORT_SYMBOL(dma_resv_add_excl_fence); +/** + * dma_resv_iter_walk_unlocked - walk over fences in a dma_resv obj + * @cursor: cursor to record the current position + * @first: if we should start over + * + * 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 iterration is started over again. + */ +struct dma_fence *dma_resv_iter_walk_unlocked(struct dma_resv_iter *cursor, + bool first) +{ + struct dma_resv *obj = cursor->obj; + + first |= read_seqcount_retry(&obj->seq, cursor->seq); + do { + /* Drop the reference from the previous round */ + dma_fence_put(cursor->fence); + + cursor->is_first = first; + if (first) { + cursor->seq = read_seqcount_begin(&obj->seq); + cursor->index = -1; + cursor->fences = dma_resv_shared_list(obj); + + cursor->fence = dma_resv_excl_fence(obj); + if (cursor->fence && + test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, + &cursor->fence->flags)) + cursor->fence = NULL; + } else { + cursor->fence = NULL; + } + + if (cursor->fence) { + cursor->fence = dma_fence_get_rcu(cursor->fence); + } else if (cursor->all_fences && cursor->fences) { + struct dma_resv_list *fences = cursor->fences; + + while (++cursor->index < fences->shared_count) { + cursor->fence = rcu_dereference( + fences->shared[cursor->index]); + if (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, + &cursor->fence->flags)) + break; + } + if (cursor->index < fences->shared_count) + cursor->fence = + dma_fence_get_rcu(cursor->fence); + else + cursor->fence = NULL; + } + + /* For the eventually next round */ + first = true; + } while (read_seqcount_retry(&obj->seq, cursor->seq)); + + return cursor->fence; +} +EXPORT_SYMBOL_GPL(dma_resv_iter_walk_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..693d16117153 100644 --- a/include/linux/dma-resv.h +++ b/include/linux/dma-resv.h @@ -149,6 +149,90 @@ 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_first: true if this is the first returned fence */ + bool is_first; +}; + +struct dma_fence *dma_resv_iter_walk_unlocked(struct dma_resv_iter *cursor, + bool first); + +/** + * 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 iterator 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_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. The RCU read side lock must be hold when using this, but can + * be dropped and re-taken as necessary inside the loop. The cursor needs to be + * initialized with dma_resv_iter_begin_unlocked() and cleaned up with + * dma_resv_iter_end_unlocked(). + */ +#define dma_resv_for_each_fence_unlocked(cursor, fence) \ + for (fence = dma_resv_iter_walk_unlocked(cursor, true); \ + fence; fence = dma_resv_iter_walk_unlocked(cursor, false)) + #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 17 12:34: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: 12501831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AA1FC433EF for ; Fri, 17 Sep 2021 12:35:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 238C5611C8 for ; Fri, 17 Sep 2021 12:35:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244187AbhIQMgo (ORCPT ); Fri, 17 Sep 2021 08:36:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244176AbhIQMgl (ORCPT ); Fri, 17 Sep 2021 08:36:41 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D150C061764 for ; Fri, 17 Sep 2021 05:35:19 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id i23so14966408wrb.2 for ; Fri, 17 Sep 2021 05:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hq6P+apu5QddcJBxT2CG/al9Lr42cPbE+iNSMYU+UVY=; b=amvRmOwHV67bbo1i+CVbkv10A+JbdSkOSB1vD0Q1i6Fx+68k/VvP9QGuBbtA06pg9B 9h/qsezNPrrjHikRUslbltcjZ1ODeSAOCjnY8h7trNOvVO14eqAT5nTy4uW/qJnB9NSq NDHp14nzFIwrG1ib5yXZLdkrV12J3+E3WisTbv2avlR7RPEdh0nmi9gE76xBfekVkGIV djOHOKL/coO1fqbtMScS5VlQhPuH/x1Aa0twErApdU5OQvwNm6NNkNsi2RAEBrz5kOvh iXNIjU4SsLTkwoyr/zV0zv1191nCM78wB4rYUiyg7QwI6XT3LSVohzWBYjdZLpJOK3yn oIKw== 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=Hq6P+apu5QddcJBxT2CG/al9Lr42cPbE+iNSMYU+UVY=; b=cr/zp18cJlyv69qbI1lV1Nhazgki2zktb13hTI5baDjy4WqUJY8ID++1YFNsCriOfV XDO1k42r1ikczL3x7yG5XNpM0fPSGT0qO1rhYkDObgssbBNyPSuRHXa3zFO6K0TBIhHK TbMRa40/y1nwPRgA5cLxif0kUnhmfE6g76qfy1isHB5M8CZZG37HOxCX03fCd13mPXow 6lxzWoUYe53vTxptQRkedtmMY2I0lK/CpIN8wrtsA9/3YLUOH5yj1ZmGtdahlRimhz2V NQE+7hSTb3cXTvyjOUrIuNuwQgght40tgHKJCVrvdfHRRsUVJhltqJ4BiJkMSg1rXNX6 K/KA== X-Gm-Message-State: AOAM533uVMaVPdOeGveXcW3BB7Hy3f48BxHIabZrjf3eFHS1RUzIfU/M okKd7d5VRRHsMo//Sng/Xjg= X-Google-Smtp-Source: ABdhPJznMU/ayLHx4F7nt7nhyCxToln+2iLehyrTsiU79E0Izma7IDO7C0N5XoW+cItVQWTWHK5pVQ== X-Received: by 2002:a5d:4d92:: with SMTP id b18mr11979933wru.245.1631882117877; Fri, 17 Sep 2021 05:35:17 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 02/26] dma-buf: add dma_resv_for_each_fence Date: Fri, 17 Sep 2021 14:34:49 +0200 Message-Id: <20210917123513.1106-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 | 33 +++++++++++++++++++++++++++++++++ include/linux/dma-resv.h | 17 +++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 3e77cad2c9d4..a3c79a99fb44 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -384,6 +384,39 @@ struct dma_fence *dma_resv_iter_walk_unlocked(struct dma_resv_iter *cursor, } EXPORT_SYMBOL_GPL(dma_resv_iter_walk_unlocked); +/** + * dma_resv_iter_walk - walk over fences in a dma_resv obj + * @cursor: cursor to record the current position + * @first: if we should start over + * + * Return all the fences in the dma_resv object while holding the + * dma_resv::lock. + */ +struct dma_fence *dma_resv_iter_walk(struct dma_resv_iter *cursor, bool first) +{ + dma_resv_assert_held(cursor->obj); + + cursor->is_first = first; + if (first) { + struct dma_fence *fence; + + cursor->index = -1; + cursor->fences = dma_resv_shared_list(cursor->obj); + + fence = dma_resv_excl_fence(cursor->obj); + if (fence) + return fence; + } + + 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_walk); + /** * 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 693d16117153..8c968f8c9d33 100644 --- a/include/linux/dma-resv.h +++ b/include/linux/dma-resv.h @@ -179,6 +179,7 @@ struct dma_resv_iter { struct dma_fence *dma_resv_iter_walk_unlocked(struct dma_resv_iter *cursor, bool first); +struct dma_fence *dma_resv_iter_walk(struct dma_resv_iter *cursor, bool first); /** * dma_resv_iter_begin - initialize a dma_resv_iter object @@ -233,6 +234,22 @@ static inline bool dma_resv_iter_is_exclusive(struct dma_resv_iter *cursor) for (fence = dma_resv_iter_walk_unlocked(cursor, true); \ fence; fence = dma_resv_iter_walk_unlocked(cursor, false)) +/** + * 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. + */ +#define dma_resv_for_each_fence(cursor, obj, all_fences, fence) \ + for (dma_resv_iter_begin(cursor, obj, all_fences), \ + fence = dma_resv_iter_walk(cursor, true); fence; \ + fence = dma_resv_iter_walk(cursor, false)) + #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 17 12:34: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: 12501833 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4999C4332F for ; Fri, 17 Sep 2021 12:35:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D126610E9 for ; Fri, 17 Sep 2021 12:35:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244190AbhIQMgo (ORCPT ); Fri, 17 Sep 2021 08:36:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244178AbhIQMgm (ORCPT ); Fri, 17 Sep 2021 08:36:42 -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 0DB05C061766 for ; Fri, 17 Sep 2021 05:35:20 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id w17so6770956wrv.10 for ; Fri, 17 Sep 2021 05:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ipbb4pGWM/3XFhYqg0eQ7bjJFj3sOFyI7ZKdJRE6D0M=; b=mAa7/f9+tf2+hjbJCj8af3ffhew+9MkGBVjBYwijaUa2GndzOvfjywhRYuyHrgzEjh xtSBzSuvfsqpSQLs0bsZM8EdRSUWIRHyvPFPxN7aLX/LZQRTaHFK0Ew65YKvcdg70ZOV 3fJiCCn6yUSLU7Tb/hsIfz9QRduJOhVYYuLE6xr5frmSIiC6o4mTkEyHIJDMjWTn0iM9 jO4PhJsSje9OO+piF5aFjCSD0spX1xS48Fou+M/B7Qq97HbgkT9g2ZykhXqvJJcFamhL 5goZox9ThDmWU4vzCiPi0JuhhvNh/NxH7mVzZdXmlCAV6zmcKl9kENOOQrowKq8iouU3 L1Rw== 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=Ipbb4pGWM/3XFhYqg0eQ7bjJFj3sOFyI7ZKdJRE6D0M=; b=gd2AQ0jZeqO5yZckcktttyUUyaAbQ1s7DnhTVdh6F/a69y/rE04C3LVcvK5ANPFdL5 249xv3wsjnRpG1THM9IXgjA/bGYEHzje6deOtR4quy6h1S9PPdnbWPFPqXSiuha1bAOV TRrwr14vFrZr/s6FlknkPKBTSDFmw/VcwAK8ogEsfb6Kkq7ARoc65oaU1pusL+9JK+pP PRcE5V/BncxSrbx9hRrH2gsxpEsZ3W3h2Y52XkVUogtx5wEwBt9x6QjFb/EJmtV6xvIc Vt7dkivIapun2OMKmEK4svUEEDuSGGuTvw0zHz8CklRStDFyFux/JhBDAkfEuKTKPahP 95Tw== X-Gm-Message-State: AOAM532mUahhtqyjKVT9HtWy1teY/Cc7dx1Jstk3r0Lkvhs51iFwWx3o LoSnUF1jHuNX8gOe8x1DK1rDDZeTPUc= X-Google-Smtp-Source: ABdhPJwTOXrXCvAxWacGW1AiWElE/T+9t49LBa469jBNob+iaJiqRYFm2UdS0ez+WxQeY7AjNFFc7w== X-Received: by 2002:adf:f904:: with SMTP id b4mr11824300wrr.403.1631882118730; Fri, 17 Sep 2021 05:35:18 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 03/26] dma-buf: use new iterator in dma_resv_copy_fences Date: Fri, 17 Sep 2021 14:34:50 +0200 Message-Id: <20210917123513.1106-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 | 86 ++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 51 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index a3c79a99fb44..406150dea5e4 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -426,74 +426,58 @@ EXPORT_SYMBOL_GPL(dma_resv_iter_walk); */ 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); - -retry: - if (src_list) { - unsigned int shared_count = src_list->shared_count; - - rcu_read_unlock(); + list = NULL; + excl = NULL; - dst_list = dma_resv_list_alloc(shared_count); - if (!dst_list) - return -ENOMEM; + rcu_read_lock(); + dma_resv_iter_begin(&cursor, src, true); + dma_resv_for_each_fence_unlocked(&cursor, f) { - rcu_read_lock(); - src_list = dma_resv_shared_list(src); - if (!src_list || src_list->shared_count > shared_count) { - kfree(dst_list); - goto retry; - } + if (cursor.is_first) { + dma_resv_list_free(list); + dma_fence_put(excl); - dst_list->shared_count = 0; - for (i = 0; i < src_list->shared_count; ++i) { - struct dma_fence __rcu **dst; - struct dma_fence *fence; + if (cursor.fences) { + unsigned int cnt = cursor.fences->shared_count; - fence = rcu_dereference(src_list->shared[i]); - if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, - &fence->flags)) - continue; + rcu_read_unlock(); + list = dma_resv_list_alloc(cnt); + if (!list) { + dma_resv_iter_end(&cursor); + return -ENOMEM; + } - if (!dma_fence_get_rcu(fence)) { - dma_resv_list_free(dst_list); - src_list = dma_resv_shared_list(src); - goto retry; - } + list->shared_count = 0; + rcu_read_lock(); - if (dma_fence_is_signaled(fence)) { - dma_fence_put(fence); - continue; + } else { + list = NULL; } - - 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); + 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); rcu_read_unlock(); - src_list = dma_resv_shared_list(dst); - old = dma_resv_excl_fence(dst); - 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 17 12:34: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: 12501835 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6192BC43217 for ; Fri, 17 Sep 2021 12:35:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B083611F2 for ; Fri, 17 Sep 2021 12:35:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244169AbhIQMgp (ORCPT ); Fri, 17 Sep 2021 08:36:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244166AbhIQMgn (ORCPT ); Fri, 17 Sep 2021 08:36:43 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2CC3C061767 for ; Fri, 17 Sep 2021 05:35:20 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id t8so7936940wri.1 for ; Fri, 17 Sep 2021 05:35: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=a/rwiQ+ATFs+sDMWUu+w6Rs7NoUiJd4ETVjWIVuhdiI=; b=m5MN00i4b006eFm3fu30uWdf+tyKgl+dyeP/mt021jNoHcFFZBwd7lLGzdmZ3slJUE fvBhHXbSoBdhVXBre0nDAb1aYrEazpdHFbf5aN+d0nYJ9WAsf5NIVAsAYdXYJkrHcVQE q8GzAjxdoQzmViGD5bNdd/u6a5tfhPM/AxCHS+kJDVDckphIbIEOBw9OA3ZGfdNpyFpq Vg2uXeHuH7oveqGzYIhK59a2yDbIyrNWwNkfUDULRauR3ThZqyVdIE5QV1BFHLpy/wq9 jKuFLEGtWE5pVosH6Yih0WBwFeTBzPhBGk6otWzgrAwrd4JN90TkbGqkRMRZod4GXwtG rraQ== 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=a/rwiQ+ATFs+sDMWUu+w6Rs7NoUiJd4ETVjWIVuhdiI=; b=5IttMY/0ql7e1FRPxjkWsh6EuxdjIOanPfmAK0O/xPZdM3AVlPEuFsvCLN2gboZsMq 3lWJLyZqoJUG7fQ29S3a5UZL/CAtRv71m9c82x9tgxhlGiSPotIBJ9cLNfXYmnjB7S83 eMSgXUJqjCnbQQBe0fCf8o6SrwTdu/9e65ZzQ9gFDYq7t9PFH3CM/xKYatZ7QDtSUpn0 C3ZIgb7os6mouexSzdTFhbVphHM/NSa7VZaHw0e2If7K5+zfKJ7dDo7mmwyVzfvVrVFk UzAyj8UjrWm4yYGNLtIyRlpykYt1jMUvzzMwe2itbqe8EqdPWo51irktXvqh+mqfsS+4 SITA== X-Gm-Message-State: AOAM532fzlHGvhejBOOCPr85OytVZu9pqTBav8oWFP0C0Dik4WJuVYjD yZiJSbJ93+cPNmsjOQ7F9qqjQEUvkJA= X-Google-Smtp-Source: ABdhPJw2Xk+DGoJdfDUIjxpO8TN5jWGOTM3tr7l7PGRy9eESCcjoRc/3WnWS7CZs6hfj9f3STavDNw== X-Received: by 2002:a5d:5981:: with SMTP id n1mr11975526wri.82.1631882119510; Fri, 17 Sep 2021 05:35:19 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 04/26] dma-buf: use new iterator in dma_resv_get_fences v2 Date: Fri, 17 Sep 2021 14:34:51 +0200 Message-Id: <20210917123513.1106-5-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 Signed-off-by: Christian König Reviewed-by: Daniel Vetter --- drivers/dma-buf/dma-resv.c | 112 +++++++++++++------------------------ 1 file changed, 40 insertions(+), 72 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 406150dea5e4..9b90bd9ac018 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -487,99 +487,67 @@ 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); + rcu_read_lock(); + dma_resv_iter_begin(&cursor, obj, true); + dma_resv_for_each_fence_unlocked(&cursor, fence) { - if (sz) { - struct dma_fence **nshared; + if (cursor.is_first) { + 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; + rcu_read_unlock(); - ret = -ENOMEM; - break; - } - 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; + /* Eventually re-allocate the array */ + *shared = krealloc_array(*shared, count, + sizeof(void *), + GFP_KERNEL); + if (count && !*shared) { + dma_resv_iter_end(&cursor); + return -ENOMEM; } + rcu_read_lock(); } - 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 (dma_resv_iter_is_exclusive(&cursor) && fence_excl) + *fence_excl = fence; + else + (*shared)[(*shared_count)++] = fence; - if (!shared_count) { - kfree(shared); - shared = NULL; + /* Don't drop the reference */ + fence = NULL; } + dma_resv_iter_end(&cursor); + rcu_read_unlock(); - *pshared_count = shared_count; - *pshared = shared; - return ret; + return 0; } EXPORT_SYMBOL_GPL(dma_resv_get_fences); From patchwork Fri Sep 17 12:34: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: 12501837 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1851C433EF for ; Fri, 17 Sep 2021 12:35:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C8D0B6121F for ; Fri, 17 Sep 2021 12:35:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244176AbhIQMgp (ORCPT ); Fri, 17 Sep 2021 08:36:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244172AbhIQMgo (ORCPT ); Fri, 17 Sep 2021 08:36:44 -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 BED87C061764 for ; Fri, 17 Sep 2021 05:35:21 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id t18so15000360wrb.0 for ; Fri, 17 Sep 2021 05:35: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=8mVOVFn7bmhLuGrJEX+tbk0DRLKzhF9YYGPZtBVZ3ao=; b=YTrxJf7awtIaUN3OnOFQEAl2GGNFeguMpbirVAdGdLJu6EUqVOoKBMgt12jNkIJQD9 S5Zwo1vUZwqgFMs+SX1NEHcSW3WzHNPhBufMmXMNGNV1B0LaNWafQXIkAO7zjMB9rTD8 bOMi8foA42njV5ZGTcx2NVGk3bPKVfjKwfkLBbzDDkIbKUoJMLZnWEC08sMzvYMgvYqr 1q6aZgWYLwecii6sK6+GRlFHUdL77y+l3gDJ0D9H3De2T9xSOtgIhIDUSnqhRCGJ1nD1 F0CUK9aXnFaw6nGV6oeYyfJg+DCxR/gSX7ziuiZeibLKQDDHn18L4BZKz1f7FaACyOR/ AAYg== 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=8mVOVFn7bmhLuGrJEX+tbk0DRLKzhF9YYGPZtBVZ3ao=; b=hOkwPLSv8xTCOEYTmYQ4ceBs6eahxUEnlAq8PIrnrEX/y2JFHn1qbJlKHdAzwRiYmV ey8sZDQQfht8Mvoq1Ua51wjF9YQhpvUNAJwTmzudOqJ5WwTN5g4bSnT5QnOcLmjGD3qJ h4A7ik0VgRx7dBlxFJYbkL0YO+VzIXsopcpw/z/He9sZJmNYiGMG7++0BMAZ4jAVpC9e iqqeZYslTRecInVXvtzRRSGEAMb5f5udFEGe7uUpEu0kkWXP6zbuqdmJY2cI1/0wRA+N 5qDOu4dCfOZ+/srR1mTXGPphQBiLZ3CDg+XqQcp2y1yoDBoNwHDD1Pz0z9rt1nxhb6px jxoQ== X-Gm-Message-State: AOAM531JDybREgNfGPgfcEhr/hlbxIp91hR+iu3VgL6ply9RGTsmVW3a 8zkokLvWg3xkzN4/sYCoGQrPbvdQPHQ= X-Google-Smtp-Source: ABdhPJzp1OVanxiZTCCd7q1OJ3U2i8eSj4o2Z3hjO5r02JdQZtaKMhfkZHZMaQ58TWu9KG8LIATbYA== X-Received: by 2002:adf:e546:: with SMTP id z6mr11951871wrm.346.1631882120404; Fri, 17 Sep 2021 05:35:20 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 05/26] dma-buf: use new iterator in dma_resv_wait_timeout Date: Fri, 17 Sep 2021 14:34:52 +0200 Message-Id: <20210917123513.1106-6-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 | 68 ++++++-------------------------------- 1 file changed, 10 insertions(+), 58 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 9b90bd9ac018..c7db553ab115 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -569,74 +569,26 @@ 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; + dma_resv_iter_begin(&cursor, obj, wait_all); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + rcu_read_unlock(); - if (dma_fence_is_signaled(fence)) { - dma_fence_put(fence); - fence = NULL; + ret = dma_fence_wait_timeout(fence, intr, ret); + if (ret <= 0) { + dma_resv_iter_end(&cursor); + return ret; } - } 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; - } - - fence = lfence; - break; - } + rcu_read_lock(); } - + 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 17 12:34: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: 12501839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83792C433F5 for ; Fri, 17 Sep 2021 12:35:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A0D1611F2 for ; Fri, 17 Sep 2021 12:35:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244194AbhIQMgq (ORCPT ); Fri, 17 Sep 2021 08:36:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244189AbhIQMgo (ORCPT ); Fri, 17 Sep 2021 08:36:44 -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 963FFC061766 for ; Fri, 17 Sep 2021 05:35:22 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id q26so14925433wrc.7 for ; Fri, 17 Sep 2021 05:35: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=RfHqvcyiEJW+8Dv+evs+CpAicHAPfkZinp9Xu/Tw2t0=; b=G+urs6mPARXC3SO9XXPNshssXO2BZh8WmFOl5MT5iJsXIosexKxo9uUcPiDxc7Kv5F BGAQkNlQam50WpDy+MshUUpJXDnL1hz8tbvPjAmFzFTi1rFDuLh36jCcMM6I2fiukfbD 7MLfH4IZSg4W8HX0l0Sv6wKVm9bxkQcSVkIo0pthgQgdIzxvqeKdhm3qwyGSGT++Xuz6 leDyZ0/k0v7czH4H3Av2UNU2LMO45W0dExZQRovMrm5InsyI740pVD2CE8bqDdeUaH4/ E+zZKqDY1hkYiRgnqorvXl4fnJfnqpEIQWCCeaNACIVDp81PEFGSJM204n4VXsUCK0Gm xNyg== 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=RfHqvcyiEJW+8Dv+evs+CpAicHAPfkZinp9Xu/Tw2t0=; b=W6/Q9VgeW5p6o9mL5bcgFyhYEBkkDB/RQBKHXJ/lFh8ooGsj5MB0Vv7DVh6qRTc208 wEAuGsZs/OnBWpqH0jW1erXlPxl59FAPTsP+fltWSHUbrrtaRiybio1FkD7cnSqbpPTp C3Jg+SX/bkn/k0ZAUzVtaKJMkQE/FQlpW1NdcvhxYdyB2i6jORzoSYfXnritgusYqWjI qGFMZr3QywDrHflT6q+vZ3bw5aKvmzmLdoML0K0MXMJa1a0Ruvrg5sTN3cttkWZWnF9Q hZ4tRImXcY8Pbj2YzYADgjJt1PGU54B/qOnObSW6ZkD8WNBlme545WDIuOA5x9pn1/uE 6KuA== X-Gm-Message-State: AOAM5331mRavxCw+ORHAJh+ykKnZIqZz8YeGLv+REUDxhQb5nLnLGySN h7FCAVLTyKCQ/lyWJf/wMyY= X-Google-Smtp-Source: ABdhPJwP6PF7du9OAVJXVkoGkr0OBbNqSGCyO09T5wU1+fJSM9j6cy3vh+oonWYU/jK7vx2nVaGXDA== X-Received: by 2002:adf:a3c3:: with SMTP id m3mr12126933wrb.237.1631882121293; Fri, 17 Sep 2021 05:35:21 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 06/26] dma-buf: use new iterator in dma_resv_test_signaled Date: Fri, 17 Sep 2021 14:34:53 +0200 Message-Id: <20210917123513.1106-7-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 | 56 ++++++-------------------------------- 1 file changed, 9 insertions(+), 47 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index c7db553ab115..d8f428ddaedd 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -593,22 +593,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. @@ -625,43 +609,21 @@ 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; + dma_resv_iter_begin(&cursor, obj, test_all); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + if (!dma_fence_is_signaled(fence)) { + dma_resv_iter_end(&cursor); + rcu_read_unlock(); + return false; } } - - fence = dma_resv_excl_fence(obj); - if (ret && fence) { - ret = dma_resv_test_signaled_single(fence); - if (ret < 0) - goto retry; - - } - - if (read_seqcount_retry(&obj->seq, seq)) - goto retry; - + dma_resv_iter_end(&cursor); rcu_read_unlock(); - return ret; + return true; } EXPORT_SYMBOL_GPL(dma_resv_test_signaled); From patchwork Fri Sep 17 12:34: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: 12501841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7ABEC4332F for ; Fri, 17 Sep 2021 12:35:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD4E3611F2 for ; Fri, 17 Sep 2021 12:35:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244191AbhIQMgr (ORCPT ); Fri, 17 Sep 2021 08:36:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244166AbhIQMgp (ORCPT ); Fri, 17 Sep 2021 08:36:45 -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 809E0C061574 for ; Fri, 17 Sep 2021 05:35:23 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id d6so14867430wrc.11 for ; Fri, 17 Sep 2021 05:35: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=ia/BXArBzSo5qPiEzEa5zvEcCQIRTZj8N0lxekHwmwI=; b=l28NLQta/6LZmjFira6x6hBmN6dKFHo7l6S1OF757Ag7zBeYzOXOsbRDVoH9q3pmet GQTZnUoFNuuvtSD0iw9zqZP37/cwS3phSK+KTnF6sorAGcHMW+GndrCOAKz4cYq9X7Jf OeMnQqOV1SRqHKiLk0Btb1BXLMaZBUfmd4pwbtcuwnyype7KzVElH9kas883I0JAwcaP rVPBkUoA8qv+rfFeUjAAbfsngIphcbZjIQLcAp2+Cli24cVheLpMjfWrD5Op2CxuUTNs nzQKXUWRfytQFFccG1fwHnWQD3zL0fGcdMvVrxiO8iWvADAW87EQZel//vYrwzU0fLcx KqRg== 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=ia/BXArBzSo5qPiEzEa5zvEcCQIRTZj8N0lxekHwmwI=; b=qRQXzKyOqpnqYq8FeCmGuwdjAy3oUqG1iVk/yZ+sVEuuzS/HVGAiG1QKrsbIXuIFEN skn7KpvYkNBVHVeDkezUlCOPT3lnGoyDF8hre12de8M4ceGH8yoJEkqdqoLvngUt6FrC dNuuxn0eEVj/1LqOe81HIWJJ2nWMIywfBk8PkzUT1Hio6ZYWUwaHGwFwt1na5QG+oRkZ UYJPj0QcvMSe2vWQTKP2QzaX9aQ/sdvEHLE64Dj/wy7+rsPegLb9I73F1ldV1stjjYzX VlFeUt0P6xW/gMNbpUUzAsm86qRoHXJi8kjiHbKhwRktkJndSj42zG4FOhAXsqP1N7lZ fXlw== X-Gm-Message-State: AOAM5330h3aAaG4iyDRKVFTtWPcsOPu5d6Aqsw9MeCzXjvNpLXO+/Nqp Gc/shzpTyeEBEqniB4vhxzj+fNtFKXc= X-Google-Smtp-Source: ABdhPJwHB/pYnsex5U2dINaNbU/mxD0mYLE7uWX0oUu8MqBCU7Lxq9wRahgOXOsody97PreA7tSz0w== X-Received: by 2002:adf:f884:: with SMTP id u4mr11415641wrp.411.1631882122116; Fri, 17 Sep 2021 05:35:22 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 07/26] drm/ttm: use the new iterator in ttm_bo_flush_all_fences Date: Fri, 17 Sep 2021 14:34:54 +0200 Message-Id: <20210917123513.1106-8-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 3b22c0013dbf..7d804c0c69b0 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -269,22 +269,16 @@ 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); } + dma_resv_iter_end(&cursor); rcu_read_unlock(); } From patchwork Fri Sep 17 12:34: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: 12501843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A977C433FE for ; Fri, 17 Sep 2021 12:35:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 53F9D611C8 for ; Fri, 17 Sep 2021 12:35:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244206AbhIQMgr (ORCPT ); Fri, 17 Sep 2021 08:36:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244172AbhIQMgq (ORCPT ); Fri, 17 Sep 2021 08:36:46 -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 53FA5C061574 for ; Fri, 17 Sep 2021 05:35:24 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id q11so14924814wrr.9 for ; Fri, 17 Sep 2021 05:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RSipxlf8Rt1aqHkUOElk7qKJcjfTHCxexIhn6lnwGw0=; b=H+xduvAwk0tvPlIz4R7BPPhKlSH4Dd6FCZuuyCcoDfZ1PJKqAqjQU5QrSxkNzlqOSQ 8Pj9zBBcyObfKfKzOIRE++aGIbZCUL1GjuL/YbGZT6cZEnWRq7Cq2i/NfrGPSTYqPtDz QRnRqiH8WMWIk0EdkmuKL9Fp21P8PYXNxNalhnT8PNJfio7fWWBM6icmCcHBSYlaL070 UidpS/l7dlQI1ZLhsqsSRex9za9ebt04HaI6Eq8g6QkpBvW+6sryAhmKcHuGHdSd65hj hTpY3DXhThLxd1eemaZsgN64+kO+ePO3SKxKl8c3Ipiw+vm2RqoCucf+FJR9nfdp1uiG Cemw== 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=Wkn0rKWFhUjvl8hHL8/Aqv8C9FAxYmjqY5A0+GsyAndxh1lN4+GUGznSNZmIG6AKVT pferdcrHlaEbj/75KZhtwafEJexqIKtumrNbKkuA3V3vLb+3LFm3uHOKgtDv0PGMgh5j RQR7s+yrCouI3Jw1Rdlb84twXY61SFSQV1P6Scl7QpK5WURIXj97Fkc+wORhng8LJb+X YGNf7G4C+peWc0Go0ETuxtaevQUM3InDsQiETmCc2cgJ9Et8oNtOmOV8eR0u2GNq73Fa sfZS+lb/Yf5BGn+5hBPNX7zzS+Db8O+a4BEPSkx7+MGA0vUaStVRE2KG+tSOP74+4TMk G9eA== X-Gm-Message-State: AOAM533rr6x/ixl2SHPI7ec5UiCJz9vRY6J4SFM+kvZ9teXiaj0rYWxR DobR1fkvHkttY80YapWkwo82vh8mQxE= X-Google-Smtp-Source: ABdhPJxuQxhRcJcS8mN1wjn/sh65dvXJvqvjiWb+kwA4oOJfMAluglm+7xiaJRdFYnbZ1ZUHOHC/Vg== X-Received: by 2002:a5d:6cc2:: with SMTP id c2mr11396765wrc.53.1631882122963; Fri, 17 Sep 2021 05:35:22 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 08/26] drm/amdgpu: use the new iterator in amdgpu_sync_resv Date: Fri, 17 Sep 2021 14:34:55 +0200 Message-Id: <20210917123513.1106-9-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 17 12:34: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: 12501845 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B44DFC43217 for ; Fri, 17 Sep 2021 12:35:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A839A61248 for ; Fri, 17 Sep 2021 12:35:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244207AbhIQMgr (ORCPT ); Fri, 17 Sep 2021 08:36:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244166AbhIQMgr (ORCPT ); Fri, 17 Sep 2021 08:36:47 -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 42371C061574 for ; Fri, 17 Sep 2021 05:35:25 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id w17so6771317wrv.10 for ; Fri, 17 Sep 2021 05:35: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=w7BNkgXvEij5lrUuBoEgmNvE08Hfx+8QGysrl5h5aK0=; b=SO70r9SPYDkl1XMyj0huOLAPFmdIU/7ZO4zWgU5Dpzy/bzQ61KlGNo+7xBceV6FSYt WD85kj6Xps1VCNe86OkoRhxHupXCOMn7cHcN0DhQxvTonVh6UDNa57vqXq3qX3DSz1C0 f/6dyrUP2wNRzXywrxwrPvLNBcm06YANoVsLplyOwFjI9j9k0eac4xfrq2dRwb96RPGS h/MiUpKGX/oXEGmw0a14vepokZKAGGPUrljQaRA6i6K7CQxp4A5wMWuXSd+pITu9LMh0 Klcskx3eZ2JCYh9HjIfjMjRWAzsScG1CgngpNL6EKl8AnKuvQS+JZhixWztoI7IUb4Ce yNoA== 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=FVFXvmubTHEmSF+3PQ7WbZmsOUspxlf2jVjVVfTxSUsoTfrtUG/yEzhthFOUTvz172 B5bhcGMWdnU9BWpXacJagVZIQuXG/kpqu4MRTG6Z3uIBBWuBk3r5w/spL2+nWHnuA63+ 4fwGmGinQFmNrVWLAYGtDNKDrnuXmJliLiF7fLY3Qbu1xyfcLUASonPPOLmg5fBklM49 2tFEXDsLjS+VX6N5EIvS65trlXmeeb+mWwdRHgPsGebIbfJbr/JXC7V3Orgus2q02AmJ nbm5TMG2ew7XTs20locpCe+MxWpJ+C3D+xyOPXR6zdYVzHqNtg9YcIKO7Wu0NGyrwM09 2o1A== X-Gm-Message-State: AOAM530I8mUuyRo8MJLr/YmRhrCmbn2reZ5/IRUeiOfRAsCIUxe8Jw0U XGlF8wpO82vHbP1JvkZOZXPH0v0Kke0= X-Google-Smtp-Source: ABdhPJwOJvxsaerqCyTR6Vw7gWrPLu9hZ8OXjaUvsKD7Ysuf/lHgKybjHvCLAxaiBnBfnGjpX897ug== X-Received: by 2002:adf:9bdb:: with SMTP id e27mr11699354wrc.162.1631882123948; Fri, 17 Sep 2021 05:35:23 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 09/26] drm/amdgpu: use new iterator in amdgpu_ttm_bo_eviction_valuable Date: Fri, 17 Sep 2021 14:34:56 +0200 Message-Id: <20210917123513.1106-10-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 17 12:34: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: 12501847 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FC18C433F5 for ; Fri, 17 Sep 2021 12:35:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6BE8A6121F for ; Fri, 17 Sep 2021 12:35:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244208AbhIQMgs (ORCPT ); Fri, 17 Sep 2021 08:36:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244209AbhIQMgs (ORCPT ); Fri, 17 Sep 2021 08:36:48 -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 26FC4C061574 for ; Fri, 17 Sep 2021 05:35:26 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id x6so14881815wrv.13 for ; Fri, 17 Sep 2021 05:35: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=Xs3urb+CfK37NrDBLos1427ZQKhaGuo6xOveDYDdwk4=; b=gTKSq5IlpVVhJ7LmSQq4w/BPvlNKwZs3Zr8KCpeH88ZhemymL7oNRSKee7T8vn0gFu GiTupzuek4TK+fn7YWHeg6o7t12JrFsJeWuIZrACWgsgQfVyszfi2uIczoCrdUmREj4m 4of8y11J8eHNS0wN9MDCpuTyyIYr01zR0mEYxB0T0+TL8OPlxm9h/9ILVEmJtONaJ82t cb0Oe/GMnNxcBWK2ONQ3GlfYp5HbPR457PX7LKwv1phdg4FtZFYnDHJH/nNz04AqA+f7 B3FJ0kNxvmT/Ez/6+5D2891kRV7ItEnH1lZhEZey2wO+Y/nzU1tPnDqnP+6y0sSKY37g CFPQ== 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=mM3702S4omopiLj77M0riBu/p2M9nM4apeqcYwzA77X1TVbYlAPCAUvwKR1jygTei/ U9GyuGkyulnPAB8hTQS0tvj7JvKZRGSUrshwdM87LNpofRwt+MmPIGtzmsv/t56DzSM8 4Btu3rKVTjQMJBkh7qpgbSSAy1RyB4Bw6wQgJZeE9fsif2OkuVtzWBKJu3NM/nGwg5+P DZ8oNDzSbfPMGJWUY6CNnQZNiay5qPZtinjm6QJ8ZRRP0ug6QBItWa6zbOebPOEXDexn ekYxdtBgQfJPtF4Dzwh/AD50mRyzk+2aDZZefENlJiVX+1C3UyMFX8tU0Fu9JVPvXwn2 kfnA== X-Gm-Message-State: AOAM533ae21X572+3iC9g3byG8eVSQEfpYp3Hf0fFWswMW5uJdGvX1mH IoHBppzSYrVT1HrKUSJqTcE= X-Google-Smtp-Source: ABdhPJw0aEKpP6kGBge9nyKMlcuAMHE77hovCenDMfAimtSL6cGoyUszAQL8AU1AKI3ysXIT9I9FVA== X-Received: by 2002:a5d:5981:: with SMTP id n1mr11975957wri.82.1631882124773; Fri, 17 Sep 2021 05:35:24 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 10/26] drm/msm: use new iterator in msm_gem_describe Date: Fri, 17 Sep 2021 14:34:57 +0200 Message-Id: <20210917123513.1106-11-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 17 12:34: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: 12501849 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70025C433FE for ; Fri, 17 Sep 2021 12:35:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B88E6121F for ; Fri, 17 Sep 2021 12:35:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244214AbhIQMgt (ORCPT ); Fri, 17 Sep 2021 08:36:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244209AbhIQMgt (ORCPT ); Fri, 17 Sep 2021 08:36:49 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0822AC061574 for ; Fri, 17 Sep 2021 05:35:27 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id g19-20020a1c9d13000000b003075062d4daso6800106wme.0 for ; Fri, 17 Sep 2021 05:35: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=IkVWp2cRgm41mlWFdiuPcdEqOEMHJpLCxm3yFN2dD0Q=; b=MnWtggex5Ail8JVsmN18gU4UHQ3jSuSrLinUisjzQ2SEGe7ScDEXLvZt37dLvaCXEj du2do7tClOucHFUpb9UKhlIdhfOspxZgKMOQUbhf6nCD1OcyOLYsvrnV5wsJoEj+sox9 VgCRw4SbsOyj4zo3LUhEu60i6BndNeR40dViKCQjblRx6HHbZGt9k3TQs0AlvdTw4Nd7 ZBcif4iXQsEHzhbiNT9r+Z6InOC8GT1NcXUAGfKCBjbniX6l7/A+w3+Ugy1d85rFE1Ol vwG03IAHCY9BaSz5+bpmvRHoPWQ3WfM0RfrofDrI/JrW81ulln7xZ+xxXtBpe50sdixs ql3g== 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=JTp/voZa4oZWdcxLRLx5MRBXV3b4hlzkf5wug2lCgP357Iq3ho35Faxz+Tbjk+vMOs rqw8MvquLVX5rA54rQd84NBYFtOlnSL31LeiH6u9PrE3R7H6cxXYsyP5cZKzaffOMszS BhqukW6FjPoZz9h7AhUgxBnBHfas1EWE1HiaXzq1U+J8BZBQfN1fTm6EwA2q/zd44abs SWpBtMevur/CxBdILi8KYZjgU1hhtdfACkqbdN92Xd8o+rHlsHLKHmURPBTfySeLSO6p 7SssRMRqQuiOsVqlbwrnPNPUcbLiGhdeHp/1lgMY63/ZcZYKhQ1itd80C4sgtqkmc9lx siFA== X-Gm-Message-State: AOAM531lwg8WUB2M/k8KiY8Z8uMT4CipwX4gMKiZ1RTKy0+a7dQvJqxV C3BDaIZN1zlH3vcpN18pKfpzir76ENA= X-Google-Smtp-Source: ABdhPJzdFJRubHKlc6TxRV8emqLHCMF/tBXOi790xDh1XujN5nwcSLxOLOSNyq5qMuPOn9xUhM5OtQ== X-Received: by 2002:a05:600c:40c4:: with SMTP id m4mr14792529wmh.100.1631882125635; Fri, 17 Sep 2021 05:35:25 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 11/26] drm/radeon: use new iterator in radeon_sync_resv Date: Fri, 17 Sep 2021 14:34:58 +0200 Message-Id: <20210917123513.1106-12-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 17 12:34: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: 12501851 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 737DBC4332F for ; Fri, 17 Sep 2021 12:35:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 60C54611C8 for ; Fri, 17 Sep 2021 12:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244218AbhIQMgu (ORCPT ); Fri, 17 Sep 2021 08:36:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244209AbhIQMgt (ORCPT ); Fri, 17 Sep 2021 08:36:49 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6792C061574 for ; Fri, 17 Sep 2021 05:35:27 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 70so4280228wme.5 for ; Fri, 17 Sep 2021 05:35:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a24rUD+lvDbozllBrOmPRNBHQxSSbhyfXU0oYcihzyg=; b=nIdwXfLabzXcW1XiceUdnmzctWEURDQizwpJU2OUqH6G1ZuU2YX9NskikFXUwzC392 C5rT93WnEzI1d4Ke7nxW2BlJsrJbVJK2iydZlt5YaIzbEqGtKMBUGj2I3IPDHW18JhRw uYr3RCuz1bJLcMzHogMCrhy7GS4HCNI79lUSSd7Q2iKhSNYeQZ896b2jE6LSGgUP50LX IJfUfcPPVKBVQekWxSWFIVSQkiGPlHcbN/HB9LuOH9NvXIYHPkxN/KocH83NGwHhXRzR RJZoBw7DJdr7lDQlEeZA3IZMHAnq9h4cj5h2pcyZzDIgyQdWDJXJTMlLjCtgn4KohfgW enZg== 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=a24rUD+lvDbozllBrOmPRNBHQxSSbhyfXU0oYcihzyg=; b=UccWY9Sc8wdYYxLT15ubxyhMlihhvRU1Bc8V+JSVk4dQ5p4yIjtvvPsiM3+bnjkca4 3NGRy1xigonMyQ+n5WES9Y6wbu00JI7kyPh623v8pqsf7OPwP8GX8Dz9ks3zTmhTCbpl PoJ476ZQ057nD0T9ScCmXlsxRZUA+Ht4TyVUIsOy3n4AIW3j51I942qVoRf2xCuhVKjx LMwsslkghgu4rWgjMiylq6c4wHP96fUoyXvjIrzGvAI8w24IeoEsUeoqKUon8ye2oJtE VA8GC57dAUmYpMQv9U4YfcLuJDuufQizD+NTqfl7oT0UrqxkXOiH8xD0gvchixge9lbU R6AA== X-Gm-Message-State: AOAM532vleyvUwPKtYnH2MimLJvhrSD6QizKHsfXeMmwPU6eyOu62CGT u5lOBvx/kADGjAvI8h3iyvefbVFNtnw= X-Google-Smtp-Source: ABdhPJxh2B8tbcdyMHyLlJwdm9twJffSI2woQBoj+J90WpQgS6tgdN39QXiHuGZvFewkLx3TxfV2Kw== X-Received: by 2002:a7b:c4c2:: with SMTP id g2mr10105760wmk.134.1631882126494; Fri, 17 Sep 2021 05:35:26 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35:26 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch Subject: [PATCH 12/26] drm/scheduler: use new iterator in drm_sched_job_add_implicit_dependencies v2 Date: Fri, 17 Sep 2021 14:34:59 +0200 Message-Id: <20210917123513.1106-13-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 17 12:35: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: 12501853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12902C433FE for ; Fri, 17 Sep 2021 12:35:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0FCF611F2 for ; Fri, 17 Sep 2021 12:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244229AbhIQMgv (ORCPT ); Fri, 17 Sep 2021 08:36:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244220AbhIQMgu (ORCPT ); Fri, 17 Sep 2021 08:36:50 -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 A2C29C061574 for ; Fri, 17 Sep 2021 05:35:28 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id w17so6771608wrv.10 for ; Fri, 17 Sep 2021 05:35:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BrbXMO1uME+f7mLVpMCcy22kq2yF+JjSyltoWjwipSg=; b=bviXeXeCrAWZNOqQCBhHL015HD9zANiiD1Ju1cCP+d9sUE83p67saA0OHqEGKzTam7 HdV54+gh2VmKuE40uOPj4Mf/xEl0M6s5KMpSN3xlzeRcYhJ4ckTPYjpgrzuSRTt4+0Hl RXD2oc23kLoXKDqDohUeLEIEWIWrhtqY627SP2iBr4l4lhB0k90vuQ549nrdMQrtdAD/ cR4vAFJX1Nx1vEZY+Luy7W7qMZ3NHm6LXN3TIz1tcdlz+4mBCwAh0YlfdOvyes6GpVnh 0IDr45hLwzmFtrnRsRWpKxoUXGATG5bN4+ndE8B/CKSububs2FOS2ENs951hQNB/3Uw/ B81w== 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=BrbXMO1uME+f7mLVpMCcy22kq2yF+JjSyltoWjwipSg=; b=NUqgXnme5jbdl8c6Bf3+scasG+lhn29bsX1xPb3ULTVhiyWGCjJVG7bSyNcTnSSCpb QmxIVhVO6pb6l+JKXWNhnX4lcdk+GOlCkOzZC9oI+BwrNIZYeJP2yj7i7NlrYNiDIJGA yK5t1pd/IVC7WUyvmzsgGn7Mrpw7xq20vy8oASVWuOzebf5//jOZXIBFqGb1ZKIG5j9I yhsmE/OiWtZ6GXkkSre0//l8gVt6Nb+X2f+vFTSylUFLgcoOtVH/RgOP1ikepoVAxFjy uwAgFJDMuBr3qfUh7G0r0oD8ZvngbYCYIx2/HEQiAFtFGipqDsvxr1ysYoce4Gx3VEBK n3Vw== X-Gm-Message-State: AOAM531DUp/Zu+DE/h2p2dN0IqqU1VI3Oh3vmPq/4Jdbv1Q805R30kX0 ZXTmcJ6YV+8GGMXXO7OTsw8= X-Google-Smtp-Source: ABdhPJx8Hxqa3VDTaoBwL3jmEPhMic46DgkUgKS4VuJlO4HQI4pbqyIWl+bnYxJEX+ODY9LowQLqTw== X-Received: by 2002:adf:f101:: with SMTP id r1mr11239973wro.355.1631882127339; Fri, 17 Sep 2021 05:35:27 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35:27 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch Subject: [PATCH 13/26] drm/i915: use the new iterator in i915_gem_busy_ioctl Date: Fri, 17 Sep 2021 14:35:00 +0200 Message-Id: <20210917123513.1106-14-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 --- drivers/gpu/drm/i915/gem/i915_gem_busy.c | 32 ++++++++---------------- 1 file changed, 11 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..b1cb7ba688da 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,17 @@ 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 = false; + dma_resv_iter_begin(&cursor, obj->base.resv, true); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + 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 17 12:35: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: 12501855 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7A61C433F5 for ; Fri, 17 Sep 2021 12:35:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B0A246124E for ; Fri, 17 Sep 2021 12:35:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244235AbhIQMgw (ORCPT ); Fri, 17 Sep 2021 08:36:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244220AbhIQMgv (ORCPT ); Fri, 17 Sep 2021 08:36:51 -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 7BAEFC061574 for ; Fri, 17 Sep 2021 05:35:29 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id t8so7937653wri.1 for ; Fri, 17 Sep 2021 05:35: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=fnU59rAAZAZupB1agRScvsRy8FcaokBV3fXPNRfJmuM=; b=NZ//04R2oA7Ofi5J5H9RYrX45fRztLC6ng7eE/q30lidghN+eTwjRXi3eo0pqp9kzU jiToExYNvC0YZ4dCb5/1H8M9v+PSKKiEQM35cmsEXHcqFzJNFoqyZccU1bUeDY3VJNVt VRWu0rHHMU8kPTfZhz15x+SOfsbnVmmwejweeDiyJJms/DoBS8hUzsO3i0f/T01kXVS4 zEBYwfw532UGxfMqh6JMYGhbP+/tlJ04RS0YWUv8zSj00wVYsIDKaoMhfkUhFOtJGaiX SEyhKBQECkFaIhI5ZyXYV/HCXFLPncsAJt53y0tzdLvcC9UAyKAxfrPF2orWgob9r8Uw +ewA== 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=fnU59rAAZAZupB1agRScvsRy8FcaokBV3fXPNRfJmuM=; b=zknVh9nX2yD5HdPb3EaArs6iGUcmML+Z8Ei14qvOdSENC+/BsKQ62uSU1TssIWgUWc 4Xtn3Gco/gdRWT2eSzPvMyPp0v/BPxUVdj4jPHKLJD439/Z+5OUm8ycc97sgb6NQp4/N 57TovA5sQvgxWyxgIQVkiYCYM+h3LdtWIdMG+pNqNP6IckMqYsBv9nhE9ev5xeWJtaw2 uH0Dhvc8X3lOWYXbb1ydWEDoeO+u8pri+XFvZD6SEeZSXXqbNHLHsPV990GFwTusYn1O 09qopTQQUgDNHyFeSwy0jaJxMRMhOogRqB0agfQ11Pqyrmpw+W3wqvxgQCQshKuMbM5c 32FA== X-Gm-Message-State: AOAM53129YFxsJ3cPmdXhksuA15Vp0Dm7htAb5H2rhHKo+Qtw3yz4cvW UlDXY16ZjJm2k/r8SUVmQlA= X-Google-Smtp-Source: ABdhPJzfu4I1UPKXKEbsuR5FDbWn0p6UMTBQKmzpVOnvlDOvS1QnIwGdIoATAJR2bte/LnKCgf+aJA== X-Received: by 2002:a5d:54cf:: with SMTP id x15mr12200396wrv.27.1631882128177; Fri, 17 Sep 2021 05:35:28 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35:27 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch Subject: [PATCH 14/26] drm/i915: use the new iterator in i915_sw_fence_await_reservation v3 Date: Fri, 17 Sep 2021 14:35:01 +0200 Message-Id: <20210917123513.1106-15-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 | 57 ++++++++-------------------- 1 file changed, 15 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..7635b0478ea5 100644 --- a/drivers/gpu/drm/i915/i915_sw_fence.c +++ b/drivers/gpu/drm/i915/i915_sw_fence.c @@ -572,56 +572,29 @@ 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, + rcu_read_lock(); + dma_resv_iter_begin(&cursor, resv, write); + dma_resv_for_each_fence_unlocked(&cursor, f) { + rcu_read_unlock(); + pending = i915_sw_fence_await_dma_fence(fence, f, timeout, gfp); - if (pending < 0) + rcu_read_lock(); + if (pending < 0) { ret = pending; - else - ret |= pending; - } - - dma_fence_put(excl); + break; + } + ret |= pending; + } + dma_resv_iter_end(&cursor); + rcu_read_unlock(); return ret; } From patchwork Fri Sep 17 12:35: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: 12501857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC960C433FE for ; Fri, 17 Sep 2021 12:35:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A90E3611C8 for ; Fri, 17 Sep 2021 12:35:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244238AbhIQMgw (ORCPT ); Fri, 17 Sep 2021 08:36:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244220AbhIQMgw (ORCPT ); Fri, 17 Sep 2021 08:36:52 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59373C061574 for ; Fri, 17 Sep 2021 05:35:30 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id f62-20020a1c1f41000000b0030b42643f72so1776849wmf.3 for ; Fri, 17 Sep 2021 05:35: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=lPdZK7BIOkQEWY2TG92V49o75qXMdIlfGURkWq4Gvi0=; b=PxG28CRq7SfLj/CUTWydHmk4006k5rR2IcS9TrqiJsXEYfqf0xRqgYbOeW61NOovrv TT+d2LzxSF+ISst7yiR14Ik1DX+RUFzk4hPUgnow2ooP8xHIGy9oZi+r0N3wCnfi9Z0u eiddWPTKbHGqQJ29/9ocVpZI/qq/0Xg+ZaYRJjLfjUwfY2IeRb9gbQQat6SKPVfph3m7 jXqA/NmXccNQ98ql6Aqjpi8JrfqtJle+nhYoo7/m/eIX1t4jfTr+/Xo0pOt4wW82SSvp xbpVhyDrY5kZzBIgOJfaSLP/EJncnSc0KGjo/CQnWtDK32674h6MrGnN0Fi/vaa6FvDT fk3Q== 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=lPdZK7BIOkQEWY2TG92V49o75qXMdIlfGURkWq4Gvi0=; b=rdi6cUDYpaGuRKbgemfMO8HhGp/R5GyPR99jtncAInptWAD9AT+tkWzW1c/I5vXSLu sZVPzAnExDNXSnETYmf/MhUpTzIbzlDoE+ONjZ66QPQJq+7hq6E+Y+egYhVqKpfO4JNn QsfH2oN09iGtL9HM9wKsezRXfo30/1Hglf6gFMJBpnyxsIAqWu26oPudnVKWwO/0qcX1 GFblH0MmDJxJh7TzWciKaHF4cfMwLYvV6DIKAvZw2H07yLIOF033OtXaVDVbtVRUkJjB g/xROAzJ5fmYlf/NOQHKlETGFa5d9wU1BO/67UL8ag6Ep/B+OcTuKbXaxDrEqo/lQUK4 olxg== X-Gm-Message-State: AOAM532W30z6+twUtFo5oH15MmdtnwWJT7w0Rjzv6SwA9wc+ueqcObM+ vWMIdkuOBdq7WJ+VcsuUAwHspFe7lsI= X-Google-Smtp-Source: ABdhPJysDKC6VyP5ngCiTm1WvJqQsy1dzDim5DxuE39e6K262Xtj1qJmz5tuTO2Pa0VzjGCm33oxGg== X-Received: by 2002:a1c:2289:: with SMTP id i131mr14845111wmi.113.1631882128987; Fri, 17 Sep 2021 05:35:28 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 15/26] drm/i915: use the new iterator in i915_request_await_object v2 Date: Fri, 17 Sep 2021 14:35:02 +0200 Message-Id: <20210917123513.1106-16-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 --- 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 17 12:35: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: 12501859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7453C433F5 for ; Fri, 17 Sep 2021 12:35:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 91A48611F2 for ; Fri, 17 Sep 2021 12:35:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244242AbhIQMgx (ORCPT ); Fri, 17 Sep 2021 08:36:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244220AbhIQMgx (ORCPT ); Fri, 17 Sep 2021 08:36:53 -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 41A3BC061574 for ; Fri, 17 Sep 2021 05:35:31 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id u18so13196207wrg.5 for ; Fri, 17 Sep 2021 05:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fTYRDJJE+t2GlGO6++SOuXKZtEL0uOy1Wu4kUiFazeA=; b=do5a6C/CKoJ/t9gO3qZFk6Zo473jj7JAmKlkWbMHGOgVCNCadQiX4dj5blZ+Q02w24 lpaJ6VbHtguxph/wY2ANf+GuHZNZs6P+bo2k86RSDsg+0kB4bqSsGMb7ldNJA2eF+M06 HSCJDPYVsoZ9ZN8R/bdAqCDXRbpSlx79Roc8pkfNYUAYYsSZeIwaPbd2eaxG3CcDJ/g8 xgNy6vuUEaUYZyBDd49Ka3J9+1HZd51MNUGzODtbZy5LUFAByodUCMp5sXjV3yrUXN3h bbz08LCoqXRkkchlZI7SStEiAPz8viCz8AyKvWDvo481lE7U5kimmC3ny5iV7246gSCR 7AFg== 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=fTYRDJJE+t2GlGO6++SOuXKZtEL0uOy1Wu4kUiFazeA=; b=MhnxBMbED6qzvdCLPGyhSzm4wo2EJQjgkPFge/WolqpceEj5BWEFjVA0leHjy+pO3N u9Stbt9MbO0jtW7s3lwJC5whHZ87hHgLdeFeSPr9dtLvE83bDpNwpcyt4XBDVheOUsjc YfBZC2a3B+/B0MjvB4ZGFC6KlWhMua6CpG/nuFaBuVLa2k47+/nOX1ZFTB2vXiN6cVL7 0rFMKO/krsaCLqt48O4Uk3Sa8N1CjQezxmyG3ScIadW3gKkfHkgE6+39ZwWPVs04lVOa CHI2jDDYUMkJJVnkYv79IAB+r0ldc5GxcgDaumrb0C2Zk3PFQnWRj3tWtb2wdYfruWlh 9KdA== X-Gm-Message-State: AOAM531T8XW+pFYiGPyqRzI30NxIwMxkjB3p9whp8tEd2iB8y3wOUapw K2KCYC0HwtmmvMFKvuPelVk= X-Google-Smtp-Source: ABdhPJzm97Y1W1aEKpHQPWRcu76jJNrW79Rmy/gN+d5YlVYLRUfEHYXtRHvfLqrk3RsPZ9XPev0k3Q== X-Received: by 2002:adf:ed4c:: with SMTP id u12mr3858944wro.164.1631882129858; Fri, 17 Sep 2021 05:35:29 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 16/26] drm/i915: use new iterator in i915_gem_object_wait_reservation v2 Date: Fri, 17 Sep 2021 14:35:03 +0200 Message-Id: <20210917123513.1106-17-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 unlock. Signed-off-by: Christian König --- drivers/gpu/drm/i915/gem/i915_gem_wait.c | 57 ++++++------------------ 1 file changed, 14 insertions(+), 43 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..e416cf528635 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_wait.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_wait.c @@ -37,55 +37,26 @@ 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; - - 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); + struct dma_resv_iter cursor; + struct dma_fence *fence; + + rcu_read_lock(); + dma_resv_iter_begin(&cursor, resv, flags & I915_WAIT_ALL); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + rcu_read_unlock(); + timeout = i915_gem_object_wait_fence(fence, flags, timeout); + rcu_read_lock(); + 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); + rcu_read_unlock(); /* * 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 17 12:35: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: 12501861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B11F1C4332F for ; Fri, 17 Sep 2021 12:35:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9918B611F2 for ; Fri, 17 Sep 2021 12:35:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244267AbhIQMgy (ORCPT ); Fri, 17 Sep 2021 08:36:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244220AbhIQMgy (ORCPT ); Fri, 17 Sep 2021 08:36:54 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07331C061574 for ; Fri, 17 Sep 2021 05:35:32 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id a194-20020a1c98cb000000b0030b41ac389fso2048275wme.2 for ; Fri, 17 Sep 2021 05:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Sw+MS6XteEXCpv8sKsyjs9ShzNFMcMc6sPLH9JOk0jI=; b=U31LlhZncd5tO2cW45QRi3rq9TCmIkt4nY6X7fcCPa7vfRLh04v/W/R34ftcc+RnLW zwnuGViVtar56E22SHre1HV2qH3m/hpv2Jux083/+ucvWQD/YiLNdQpuSluW7HbiFu2M IaONrwS3ZC3icPOBEbEUrEqdUmQB+burkje3wuRSYVTLCfmbK7oKfR0Rb6+w6YrvPKL/ UKzEb466lwVCRLNz1H0R6auREPQ82I8rJPdzSUdqtpTFsEqGphdkGyDwmczQbp7mnFUe 1Z2PUx1LLkja3DzAnO0dsFpSe2UlvNQkHhCaYgw+9eEX8wDT9odd5sL2d28mWVXaiUrn hi7g== 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=Sw+MS6XteEXCpv8sKsyjs9ShzNFMcMc6sPLH9JOk0jI=; b=CzDJRXw26nrSNLgZhfXJEuy54gFl8u/w3j33CXMtKxaSpgmDm08TEW0mfZhSjx16AV VDuBip/1s+tN/QPgvsKw1Cjo8CS/lU/RTW/qH0p9eATtNvdPG8/8SG3fGxkOFyZzNuCN wBuRz6gO491R6VyTbaWfY7MiqeMA4Bfbp4YeZBSQ943O87L2otRUaCNOTbMj88+RCn5P w1kIJ6wjaFSQ3q0QjOIgGuXeWez6HNTwnwPtP7fxL1tkCPqUvwyTbLogliUhDTxIRD6p NYbnJiSgz1U6cV2slZoH0wRrIyv9mphYGJlpxEne1dfRPn0IlmahWnY+ZG4yHix/y/GZ uGCw== X-Gm-Message-State: AOAM531UK27WmbuPXLI1BybjJ7keDdcvkykZFHA4jkQGAXYYfpIDh40Q 65QldihOD1EmMNhn17PrBFfQWE4tSjw= X-Google-Smtp-Source: ABdhPJxhkEFsuKkLknoNrRxVOQijCepLFFhcg793t2v1pp6SYTYBtLT6kE3SwOvHHAB5lvDB9caSEg== X-Received: by 2002:a05:600c:4f0b:: with SMTP id l11mr14772678wmq.0.1631882130695; Fri, 17 Sep 2021 05:35:30 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 17/26] drm/i915: use new iterator in i915_gem_object_wait_priority v2 Date: Fri, 17 Sep 2021 14:35:04 +0200 Message-Id: <20210917123513.1106-18-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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() Signed-off-by: Christian König --- drivers/gpu/drm/i915/gem/i915_gem_wait.c | 34 +++++++----------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_wait.c b/drivers/gpu/drm/i915/gem/i915_gem_wait.c index e416cf528635..de8084b6af42 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_wait.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_wait.c @@ -122,32 +122,18 @@ 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); + rcu_read_lock(); + dma_resv_iter_begin(&cursor, obj->base.resv, flags & I915_WAIT_ALL); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + rcu_read_unlock(); + i915_gem_fence_wait_priority(fence, attr); + rcu_read_lock(); } + dma_resv_iter_end(&cursor); + rcu_read_unlock(); return 0; } From patchwork Fri Sep 17 12:35: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: 12501863 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63FFFC433F5 for ; Fri, 17 Sep 2021 12:35:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52D3F611C8 for ; Fri, 17 Sep 2021 12:35:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244268AbhIQMgz (ORCPT ); Fri, 17 Sep 2021 08:36:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244253AbhIQMgy (ORCPT ); Fri, 17 Sep 2021 08:36:54 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C86D3C061764 for ; Fri, 17 Sep 2021 05:35:32 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id c8-20020a7bc008000000b002e6e462e95fso9862178wmb.2 for ; Fri, 17 Sep 2021 05:35: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=BPSU1DXFCGE7WDMspzajAb5+e08n2RYsOOJEReWtL6U=; b=G7GZR/a3uftoZUOQE1c5/xOo1bxgEpGvghaVs/z0MIKYtjDRjokQ7n9avxKHenfJmP QJpAsdMHxHBym8ybMepqG99FkHP3tRqLVtRAzRFUZBypbd+VXJUStpFWHbDo5iiVCgn3 Pbvps5yJ8rmr9efaFRBWkvaz8BarNd/aexogI9NPT7fHt/P6Dyl16sGMXHbZKkPWhT1L qFMnnDBkaCb+iz+HInXNKlKtuO9s1Apg9hXVe07nLBnntrGUmKflElYKOw7/qyMdOOOa r16gh0Q625ASoLJMdrsIWYI8ud+9xFbYuUCCUqSU9RwfLAo9dQiRgQb5UNk7i6huNurb cjqA== 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=BPSU1DXFCGE7WDMspzajAb5+e08n2RYsOOJEReWtL6U=; b=S1cEHcY+ynhD+kj273iwhkxFY73bNxBVxFafQxD32VmCCpGYAg+eFkt2jcZzzLLz/6 ylA3rGd9YzmuoNs20KTu/WbxPuMN93pULhIIFhvZEbVdUXzxqqNntuCpMuTS/vWVyt5h kB0DLFgGq17FiK4pt8UDs+aYt/q4WHYGkf32SqThOe5jonCXE5MVGE91cGoEHVpcX4Uy zGd3Fq/SOd4qfJ3CV5EJImHfew5a7eMn4vSlilUpeYtVdDakVjLyICLtHbZnhktWx9dA 5gB49dkq26IHp1NPJjd7/x+Z7pr8It0dOUsRVtAHOynCQevyDHM01kKeJiqPky4f2u8h g7Mg== X-Gm-Message-State: AOAM533Nrw+VHti0LHWs/89fA6w87sP4IR8GMQOs/oAmkcZ/0o2dC4An DbMGMYr4kDF5Pk/Q+YwKPpw= X-Google-Smtp-Source: ABdhPJyYZOZM3qHZmzmJADXhbU1qBTWv4kCQvYb25PVLMl4AWhnK4e6h1RUh9Oi/FX1k49dfTAyXWQ== X-Received: by 2002:a7b:cbc4:: with SMTP id n4mr15128737wmi.93.1631882131496; Fri, 17 Sep 2021 05:35:31 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 18/26] drm/i915: use new iterator in i915_gem_object_last_write_engine v2 Date: Fri, 17 Sep 2021 14:35:05 +0200 Message-Id: <20210917123513.1106-19-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This is maybe even a fix since the RCU usage here looks incorrect. v2: add missing rcu_read_lock()/unlock() Signed-off-by: Christian König --- drivers/gpu/drm/i915/gem/i915_gem_object.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h index 48112b9d76df..487329a96e92 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_object.h +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h @@ -507,16 +507,18 @@ static inline struct intel_engine_cs * i915_gem_object_last_write_engine(struct drm_i915_gem_object *obj) { struct intel_engine_cs *engine = NULL; + struct dma_resv_iter cursor; struct dma_fence *fence; rcu_read_lock(); - fence = dma_resv_get_excl_unlocked(obj->base.resv); + dma_resv_iter_begin(&cursor, obj->base.resv, false); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + if (fence && dma_fence_is_i915(fence) && + !dma_fence_is_signaled(fence)) + engine = to_request(fence)->engine; + } + dma_resv_iter_end(&cursor); rcu_read_unlock(); - - if (fence && dma_fence_is_i915(fence) && !dma_fence_is_signaled(fence)) - engine = to_request(fence)->engine; - dma_fence_put(fence); - return engine; } From patchwork Fri Sep 17 12:35: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: 12501865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20A5CC433FE for ; Fri, 17 Sep 2021 12:35:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DAC3611F2 for ; Fri, 17 Sep 2021 12:35:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244272AbhIQMg4 (ORCPT ); Fri, 17 Sep 2021 08:36:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244253AbhIQMgz (ORCPT ); Fri, 17 Sep 2021 08:36:55 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9151C061574 for ; Fri, 17 Sep 2021 05:35:33 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 196-20020a1c04cd000000b002fa489ffe1fso9829417wme.4 for ; Fri, 17 Sep 2021 05:35: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=kXKjeGBADw7OkfdzhZSt4MyIYI/kiJUFDi8gqE27MEk=; b=XGeEkOBDKSxjLIr9h/2LXxg9b9Qp9nQ1jeAbxOHQ+Y2aKqPLBmAEgc5hv8ZllcOneH SXLXD4Mlufs09lr7ateqOtcrvkmEeRMotR+E4NhWQCyLAYRPsfbdDJ8QfQihjOVRtBb/ xCd1cQ8thLx5ZidjLtsClZ4an9qRTn3z+LA+qfuFiJJKwZSMcLebr9doAJ8QSVJK5CHz ygSW/dgDvOCbV2ZTz9v5mgMlKmTm9mWcPKxCldkP9CEENogrstu9w/h1Qn7IC1T6zdFi OQhQVLbMuZCAhuj0EXJXdrqUBXxpexyAaR3qsYU9TGdqdQHnqbdisIfWYbgmHxzCrgBG 0UBQ== 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=kXKjeGBADw7OkfdzhZSt4MyIYI/kiJUFDi8gqE27MEk=; b=c/KXdPkWZGpIZQ4pJrt3wb5CsPRc0F4ToTTmxCNre3SdbVjFYrrwUrOroluESjjP8A ZL4lsXM6XpL3ujv7YiY4MksfIVmv6WdTLWdF20HFYPxGM59nDoVwmm/LLz4AkUwE4C58 zgwdd98fIE6fu2okwT4Ci9h/AvXA9W2zuwgLn3ofa7PX/vJGnsPDgWYdr7oVsClvq2km h3TkMR6xnWmzKH/d0syJpDd3nI0uthtssECGBA69MibPFT8/mD3UR7VeeZc6X9VTCPhh Rrv5/E5fwXhmRhXhu2lZlpwiKJwUCPdCadkDsQjBlQbXVWwFPjikUcrRh5oqiu9TlX/g MeNw== X-Gm-Message-State: AOAM533nobld8ce8UiPdyZzu8aQdi7SjtBb+xVeLzx2RAv73RVExjq4p hhHjcCn56dccESS3RmRRxbU52GTEB5g= X-Google-Smtp-Source: ABdhPJxnRPxEMk2FxBtoUnZidz/iVaBR9QM19ZzVdBgpzDZjd+/cY+u8xzzlOzFvnY7JyZ0eNQMvpQ== X-Received: by 2002:a7b:cc96:: with SMTP id p22mr10074382wma.83.1631882132299; Fri, 17 Sep 2021 05:35:32 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 19/26] drm/i915: use new cursor in intel_prepare_plane_fb v2 Date: Fri, 17 Sep 2021 14:35:06 +0200 Message-Id: <20210917123513.1106-20-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 rcu_read_lock()/unlock() Signed-off-by: Christian König --- drivers/gpu/drm/i915/display/intel_display.c | 11 ++++++++--- 1 file changed, 8 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..51e3df0de1ce 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,16 @@ 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) { + rcu_read_lock(); + dma_resv_iter_begin(&cursor, obj->base.resv, false); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + rcu_read_unlock(); add_rps_boost_after_vblank(new_plane_state->hw.crtc, fence); - dma_fence_put(fence); + rcu_read_lock(); } + dma_resv_iter_end(&cursor); + rcu_read_unlock(); } else { add_rps_boost_after_vblank(new_plane_state->hw.crtc, new_plane_state->uapi.fence); From patchwork Fri Sep 17 12:35: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: 12501867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8977C433EF for ; Fri, 17 Sep 2021 12:35:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B44F561241 for ; Fri, 17 Sep 2021 12:35:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244279AbhIQMg5 (ORCPT ); Fri, 17 Sep 2021 08:36:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244253AbhIQMg4 (ORCPT ); Fri, 17 Sep 2021 08:36:56 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 705A2C061574 for ; Fri, 17 Sep 2021 05:35:34 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id s24so7202522wmh.4 for ; Fri, 17 Sep 2021 05:35: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=j7dWmZ5SavrHHTbVPyl3pWrCBr/RL2bOHTMMTnJ649k=; b=DvS8f4lkWP+ukbTxyx8NLbmQo0JecP0yTi8V9mwXk8o/IbJTNYe2YlDalIWzkkzPUw 04+S2IxOxKqG1cfDvcj3sEGgbOCb291u4pgMCfHuRqCVqUG8OoCwrsAbfoR/BR8IJN7z g9E9N681nC+EN7/SGXphQws8tHfev5dO8iyAgUq5vQol3HZodnKlyXikemRwLbfkjmd4 AjQQaIGoSUiEbLxMScL5evZgyevkbC1uRjJXdRgPQ0Al8ohm0ldx5WcB0ebTbS3HiKkJ aLqd6Fj6y7lK2tBtIBe/ZN6pznqMKkycu1wWp3NfPEeiok7Ge0yHY+cvWnC8jTEVCoTq ktpg== 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=j7dWmZ5SavrHHTbVPyl3pWrCBr/RL2bOHTMMTnJ649k=; b=4/geoVz5jPkdmqLa57e5DxLKYN3AtcEEWVMQNWWf3KjWr50t0VEbKj+y0w5ifoKyjF LmYcgG5quunCROb04cEpasDKHkJ43WlO0w1L+QTOll1xNRS9JwwWeHnkZTby23OHnkA1 fD24qagxNoD2KJ82DR695X2oZXR966NJtRxIhB0nnoWYJuX7otgG0u5gOZrlW1BLo7YT BIJaNG0aCdH91rHS+k2FJS4Lne6O+ou1/K3I0J1oTWdz0hVRu+BAmNUZ/cNhbiZO7cvg QgHytPs1KrAwu9P83CsOp7CsA2tPfFDbA1AfgEOykzW00bpTLPUxxpjsvjyXU0H3HM2k JXJA== X-Gm-Message-State: AOAM531e3eTvr/QhRBYRqBc5SZYR7EI/TWW3NiyMpljsASGC1yOpVvKs CfvqQqf1Cgq8CpdAgiK7FsAfh/LkT44= X-Google-Smtp-Source: ABdhPJyUPm27pFXNdl4Rlzw33QBSbUFZ4QLV1vHG8Ty6t+fL7l1sHDIbj5v4mOUBXGv6CbVZZrTv8g== X-Received: by 2002:a05:600c:4154:: with SMTP id h20mr14745069wmm.172.1631882133129; Fri, 17 Sep 2021 05:35:33 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 20/26] drm: use new iterator in drm_gem_fence_array_add_implicit v2 Date: Fri, 17 Sep 2021 14:35:07 +0200 Message-Id: <20210917123513.1106-21-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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() Signed-off-by: Christian König --- drivers/gpu/drm/drm_gem.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 09c820045859..c2c41b668f40 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -1340,31 +1340,21 @@ 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); - } - - 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]); + struct dma_resv_iter cursor; + struct dma_fence *fence; + int ret = 0; + + rcu_read_lock(); + dma_resv_iter_begin(&cursor, obj->resv, write); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + rcu_read_unlock(); + ret = drm_gem_fence_array_add(fence_array, fence); + rcu_read_lock(); if (ret) break; } - - for (; i < fence_count; i++) - dma_fence_put(fences[i]); - kfree(fences); + dma_resv_iter_end(&cursor); + rcu_read_unlock(); return ret; } EXPORT_SYMBOL(drm_gem_fence_array_add_implicit); From patchwork Fri Sep 17 12:35: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: 12501869 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36943C433EF for ; Fri, 17 Sep 2021 12:35:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1EEE56121F for ; Fri, 17 Sep 2021 12:35:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244157AbhIQMg5 (ORCPT ); Fri, 17 Sep 2021 08:36:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244052AbhIQMg5 (ORCPT ); Fri, 17 Sep 2021 08:36:57 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54BB4C061574 for ; Fri, 17 Sep 2021 05:35:35 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id u19-20020a7bc053000000b002f8d045b2caso6789170wmc.1 for ; Fri, 17 Sep 2021 05:35: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=ibIrVYeDdndjRxY0zDZkaJhUSUXFhvWWL8GzRn7VBN0=; b=nTpCSrxBWqRflD7TltRYtMBxjZX8oKi2IfhO13ZCBM2qt4GQXfVswJjDOlUmCP/mgA plaBw1Bdhb01gWkBwiCI/ZkLJmNMg0cOADZis0pl3cKZ89M+LDa5Wgsq74d5U5lLTes4 R7N4C+UMo88xEXk5VplBMOtug+/L6kvPIjDa7PPLfETO0K7xaKVSeQB9MfqZtQd+kpfd Wv0YzDPkI5pIkjFriR66hqR8W5uJ3w2GB+I011kxPnT5/59ek4+gHHpGx7MDpA7yrbFI BAzZ533uV6YXtkP+88k6UJ6g6iBn8SXC5Hnus14t+2M+1QoKlqhIFYLxQXJXruX2vaCd WF1A== 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=ibIrVYeDdndjRxY0zDZkaJhUSUXFhvWWL8GzRn7VBN0=; b=Kufh+sX1/b0g32x6SewmfwEL0fEdFVjs5tj4+AEP/Tqzhd+U106y4vdnXB8AnLHy5M 28ti/oZaWLGdXd8yTJ6Z/jwTkAg8IVszSdWugUG2N+cQnWSJpb6/fqPho8mW96kUnbRw DqcSbQwYHPWl3BPKy7fo9zQnvPl8uCi/vkOKY5JGTd5cfsiQnYgDfk/cFnztVe6imyo7 9kXlW/ReJ6tY8TTyC0xfuAyrowBZxSFq1o+VndRCBFdM5alHd8WPDOhv9ASZ8wfdHnET vZPsrF+QD53pTJRIX3P+dak3ZbdSV5PcP+etrm8D+Jeh+QejvVMKGzI1CZvBQdo5KhH0 qMDg== X-Gm-Message-State: AOAM5310Gx6ru1tofNA6ZOAouWTvAdGIN/0O0017cdHngc9D99s2/66U eHa3YnYJ6yMIupgeSWf2cFY= X-Google-Smtp-Source: ABdhPJxaaMctBBBSc/yluqiL4tEsEQ0z0EM7vwHWdMAeiTkXSi1P8pCp+SZzIrt68qrV1FTEXvFuPg== X-Received: by 2002:a05:600c:414d:: with SMTP id h13mr14900043wmm.121.1631882133974; Fri, 17 Sep 2021 05:35:33 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 21/26] drm: use new iterator in drm_gem_plane_helper_prepare_fb v2 Date: Fri, 17 Sep 2021 14:35:08 +0200 Message-Id: <20210917123513.1106-22-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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(). v2: add missing rcu_read_lock()/unlock() Signed-off-by: Christian König --- drivers/gpu/drm/drm_gem_atomic_helper.c | 14 ++++++++++++-- 1 file changed, 12 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..d8f9c6432544 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,18 @@ 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); + rcu_read_lock(); + dma_resv_iter_begin(&cursor, obj->resv, false); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + rcu_read_unlock(); + /* TODO: We only use the first write fence here */ + drm_atomic_set_fence_for_plane(state, fence); + return 0; + } + dma_resv_iter_end(&cursor); + rcu_read_unlock(); + drm_atomic_set_fence_for_plane(state, NULL); return 0; } EXPORT_SYMBOL_GPL(drm_gem_plane_helper_prepare_fb); From patchwork Fri Sep 17 12:35: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: 12501871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0A60C433FE for ; Fri, 17 Sep 2021 12:35:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE040611F2 for ; Fri, 17 Sep 2021 12:35:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244282AbhIQMg6 (ORCPT ); Fri, 17 Sep 2021 08:36:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244280AbhIQMg6 (ORCPT ); Fri, 17 Sep 2021 08:36:58 -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 3945FC061574 for ; Fri, 17 Sep 2021 05:35:36 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id x6so14882605wrv.13 for ; Fri, 17 Sep 2021 05:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/+r4v7UIazK0HaIgNf9t5Xden24q10DFKnoad4rknzc=; b=qcdDHMrY9dAkH1CfZYbl1paITikRgjzIfXYfcWhnMMotQgyVybJVfg2I6jsbnrUtto i9d1iz2w9lUQ3Tp8eoYJkCgSPF538vXT52MeHh7t3IAMa+I5GdC8Z15ZEdU4E2R3y0Mq KTiVQB7w8RP9jLv3SpXH6ZC/MbL5lRAyEXTpTzhlRaYhDu4wUC0Ni1XL3/Lh1TQFbDJ5 wFj7/2W5b3e9HYXeb0gEx/AVdp7HAg2s+yhCjpKf/AfwiKhgQDH5R4df+kLyTxBxO8Dl pXUj1RvL9fDfnLXP+wD2tBv+WWBeQN9WG4+vRGP107Tz3CROmbXvVOfPI3g25qQFOzex vv7w== 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=dr5NJp/+vY3DeiYDVb0Y2VxZZJYmaNID7rESb8a8kIi6ig5B2TWLsGfXbWZnhTJaDU p/byKqSkun83PpyxknLMZh0Jhg/47uM/Hvfx5/lxwFR0TQYvfBmejNohn2AuekA9nwPb gWmcclm7oo3wKibXpEpCQi6OtwYO9lBZB97OqNKqP/oZIHxypDo+zDfRniBPyde5n52C IrSR/ZqAULhNxS3DXlkfr+LAJu265Hv5+oO8RwD6eNXl3H7ZlW7rASLPAUOfDuGgpKjQ Zk+jX9KLd13fzOB3OxDMJdLJlGFTcRVbCfH+tcww/kO4SK8RHGEJ9vosR8VgOag8z+UN MEPg== X-Gm-Message-State: AOAM532+ehh0AKYIcZsh/bHa5UOYTfQNtTU34aJlQXsYfW6Xsy9lEH6U Df2MCvX04YehJqqVEaFimyE= X-Google-Smtp-Source: ABdhPJw/ijoW4HVKLdVG3icsgL3cLccAIbN1qtLlkqGp8bmKWjWNYHwK4hhXW43D4RigPblzMDVsKg== X-Received: by 2002:adf:9bdb:: with SMTP id e27mr11700230wrc.162.1631882134915; Fri, 17 Sep 2021 05:35:34 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 22/26] drm/nouveau: use the new iterator in nouveau_fence_sync Date: Fri, 17 Sep 2021 14:35:09 +0200 Message-Id: <20210917123513.1106-23-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 17 12:35: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: 12501873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0693FC433FE for ; Fri, 17 Sep 2021 12:35:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E7DDE610E9 for ; Fri, 17 Sep 2021 12:35:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244291AbhIQMhC (ORCPT ); Fri, 17 Sep 2021 08:37:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244052AbhIQMhA (ORCPT ); Fri, 17 Sep 2021 08:37:00 -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 0F19CC061574 for ; Fri, 17 Sep 2021 05:35:37 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id q11so14925802wrr.9 for ; Fri, 17 Sep 2021 05:35: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=fK8E2pCKjRcBSyfXu2xH9VECGzfOaqRD3Tk7GXUBKRw=; b=BTyXf9UtKDzLAi4jeEUDgvEODrUW5OGr0NQtvBSadofvysxt2m40uJVudR8svWEYbf aSoxQesCOlzc2KKmx5mzPd5v8zLlHvm5XOwqfZni26Wjf6k7icqlxviwG+cbHC2YLrhn n0LG+uvbBz94U77jNUdyIy0Lc/ENRXibz1nXMz/QGsFHLKyZdhV4FQpjK28sYB3TDgLP 7854Ci4cs44519k4S6JP4TC5lzJhUiP3dvRW5cTf0/CyXH5oeWUo9geH5YgnsnnafbPG QGKlcI605ltdy+hnr+JUPP09JNFVSMHgHgob7e+LdOh/xemqCDh1Nb2wPJX/zWWrOatE 59qQ== 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=fK8E2pCKjRcBSyfXu2xH9VECGzfOaqRD3Tk7GXUBKRw=; b=d+gMTX2GjxLdIGJyzvGfWWnqyo43kXtXVL8HnAx6Io35xHG9mecmRHNj66sL0McDB5 x4s2L9h6XcrxlMGK6Z6Zm86U00wB8WuePZfdZLRtFlGfA5Td3Y31qR6DdtkliSM7Hfvg 4dM5sdoik7Sj8YWGDiPdHJWNphQedkPVCeajH/6VBrD6HPRx6QNXkiuQgxi5ZtX2o8Up EKvsZyKMB6iYH4hBBBFsVDVs70ssVlbaQ2r4SgQhgYiCI5PKzgbFN7s1KZdk01F5jLLk 6x0Jof1Ipjgs9ERDlF5InZRVOWlMQWrpfQuMX5Dpe5QuKVXTaTrscv7wvgPppENeIHDk Sikg== X-Gm-Message-State: AOAM530YCSooyK+GqpTyyLgtFN3TvpuUNDe1l7SLKEPgu8CA7GGDIJRi EvRJ1qV/dMBA4dwkJgSc8u0= X-Google-Smtp-Source: ABdhPJwPpOc101oPI9x/Zh1EJ6JRH0QuWwO8FmQqIwXXJwqsL70lbNjH1SjLmsPw8jrnjwj+whe1lQ== X-Received: by 2002:adf:f904:: with SMTP id b4mr11825741wrr.403.1631882135743; Fri, 17 Sep 2021 05:35:35 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 23/26] drm/nouveau: use the new interator in nv50_wndw_prepare_fb v2 Date: Fri, 17 Sep 2021 14:35:10 +0200 Message-Id: <20210917123513.1106-24-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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(). v2: add missing rcu_read_lock()/unlock() Signed-off-by: Christian König --- drivers/gpu/drm/nouveau/dispnv50/wndw.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c b/drivers/gpu/drm/nouveau/dispnv50/wndw.c index 8d048bacd6f0..566f50f53f24 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,15 @@ 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); + rcu_read_lock(); + 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); + rcu_read_unlock(); asyw->image.offset[0] = nvbo->offset; if (wndw->func->prepare) { From patchwork Fri Sep 17 12:35: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: 12501875 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DEA6C433F5 for ; Fri, 17 Sep 2021 12:35:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6FFB861241 for ; Fri, 17 Sep 2021 12:35:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244292AbhIQMhC (ORCPT ); Fri, 17 Sep 2021 08:37:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244288AbhIQMhB (ORCPT ); Fri, 17 Sep 2021 08:37:01 -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 D11C2C061764 for ; Fri, 17 Sep 2021 05:35:37 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id t8so14941407wrq.4 for ; Fri, 17 Sep 2021 05:35: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=AUpHD5Mst15U8lHt1Hgxp+Cu6jJmPPk21DhsAGpzZ+s=; b=j+uAS7ZkiO0ApRZo17ZwTDrdSBOiMynTykHMOTGXqTXiQQ1p6ejG6KfnZ9XeJgbh22 AKsV4AWL7PbDytdH2vV7R8VYd/xPzEGjOYX+C07N4l/AKlApEraVUvbKCn7l7pN9izXm NxrY/tY3a/3IZCKtUznLpISCgzSlofZLz+OcphEPaLbHEekzrjXMlyjH3LO7TQkzGTLh YuucCnOf8VUv/Mi23x5SN0BxOFfHlMYMzKOKCc73XvciU5o9GGBbASXplusvUeueuPX2 n/XGrIvLtesDBJeaIEZmsxnOxgcE/sz97Cc9Jt3q6YDJX1ObCUDaMdMHPU9Ud2WrPS0+ IoMQ== 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=AUpHD5Mst15U8lHt1Hgxp+Cu6jJmPPk21DhsAGpzZ+s=; b=q9VGdEddX02hvuqn//d4/TkJudcVjEfYBjKgzPo3gr7kWLIRcBoRTF2jUIgAaPR58Q kuYC3/xriBj5I4xwIGOC6ftVeOXrQdcD1m3ugKPE7n1f4tf3L7mn8LvYEURbIaZdToNA J0Cd6duW2cuz4f2jpQQJVTN421AARRZkRpr5NsBNUTFMu7qmy4zf3agLQvHfn53/Njxm 9RVGL3uVzfg2lQ29RBFTUC+UwTsFJNX5koiXXBqEtNGpVoBFBKxRILdo94Y32vpwz9bF Wth+momlo0auZSY7leGaPNK+SEzqSrFZFM1W0Al6FiZ+PnRbTbCq9JGzbFu4D1oCDoPV OZAg== X-Gm-Message-State: AOAM5327Rkwl1ktKcFvJZWa+g90913ytRNyiDrxzlGBieQKF2u3ATrYN D9Rb0YOUYdk22AgCr8PtKog= X-Google-Smtp-Source: ABdhPJz+TxgvDq1tNUR5ZcT7whVGLx4K5oVeHiddhXow//SYV0XseFxVr5yspabtLCqA2Wclcvx5bQ== X-Received: by 2002:a5d:404b:: with SMTP id w11mr11830630wrp.437.1631882136529; Fri, 17 Sep 2021 05:35:36 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 24/26] drm/etnaviv: use new iterator in etnaviv_gem_describe Date: Fri, 17 Sep 2021 14:35:11 +0200 Message-Id: <20210917123513.1106-25-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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 | 29 ++++++++++----------------- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c index 8f1b5af47dd6..16f5991446c8 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); @@ -450,19 +448,14 @@ static void etnaviv_gem_describe(struct drm_gem_object *obj, struct seq_file *m) 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); + dma_resv_iter_end(&cursor); rcu_read_unlock(); } From patchwork Fri Sep 17 12:35: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: 12501877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12800C433EF for ; Fri, 17 Sep 2021 12:35:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F370161248 for ; Fri, 17 Sep 2021 12:35:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244297AbhIQMhD (ORCPT ); Fri, 17 Sep 2021 08:37:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244286AbhIQMhB (ORCPT ); Fri, 17 Sep 2021 08:37:01 -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 B9F0DC061766 for ; Fri, 17 Sep 2021 05:35:38 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id t18so15001853wrb.0 for ; Fri, 17 Sep 2021 05:35: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=vDNZbZcYoW7IFr6lQi88QIbXjkbY+ZD5EoDTFjlvddA=; b=ClzefoT8ZJqdUhLiTrPyn/tYDsZAUMp22rU6KvROHSGBst/72K19MsNlgZgPwNO7TW AzzYRDpFMvki1AWIpcB3SZIsVtHNlefi2C0rzgvLNY2ea7LGm7pyCHeorIzpd6z/PhVs Yg3bacdCLixtAitXPrJanpP7YNVwgDDRW+BjgRpPr2dluoppn1Anx7C2CpiYPQdRWBOx YhpsSFuvu0fHEtr9Io9x3aaRelwNL0ds1HpVg6Jwo/i2bglZSrqyknWPgpVo+NJ8siwr IheZXKe8bubdnLwaZiIbyC9G055EWnN2K3oamY6NP8jStkHOeNyf+cBn8KYiJgOBvGV6 OAuA== 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=ELKPq85USVs2Nvk5YqeV7yMhZ9qK6um2Gk5bndDmiy5ahrtl/ghT6Lxl9EsFS6AaB2 FuF4cy7xQfU1SFEe3uIoJFbRBfUQ88A0g3iDyP5HbXb5kCgY5vNzpYBGr0z9Lk6SH2c6 Ka21ebbeuiagaIiZSX4ui66au7G/miwUrviyXtnazzWnpVu/H+UNGGrIQxRYMfpZF1ux pnsw6xTwsnGot0o0mSa6D3Qiq/er9Mr6CLlDwpfVGmQneOII7nEo8rueWxlK2yGk1rQP qfwN3c8gepba4iN1waygsN7n9effP8XjABOGgxHGHiv/K4Xc5ndQ3WyzSs7eFvRKdwt1 qKUA== X-Gm-Message-State: AOAM531fb98Ex3Jb0PCnu3Xh7suomFnajkffwm9uV02/4IHl5ldZXzQe 6lUYLKGzPTFHZEb8fcKEj1I= X-Google-Smtp-Source: ABdhPJzNtLWcjUTMHGl/9GN0PRbPfq18kIpBmMBWkzWXF+U+Lc7iVK6lvLbnj7xd/dMsUoLsX6t9Qg== X-Received: by 2002:a5d:5981:: with SMTP id n1mr11976979wri.82.1631882137364; Fri, 17 Sep 2021 05:35:37 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 25/26] drm/etnaviv: replace dma_resv_get_excl_unlocked Date: Fri, 17 Sep 2021 14:35:12 +0200 Message-Id: <20210917123513.1106-26-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-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)); } } From patchwork Fri Sep 17 12:35: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: 12501879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75A6EC4332F for ; Fri, 17 Sep 2021 12:35:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E43461248 for ; Fri, 17 Sep 2021 12:35:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244311AbhIQMhD (ORCPT ); Fri, 17 Sep 2021 08:37:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244280AbhIQMhB (ORCPT ); Fri, 17 Sep 2021 08:37:01 -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 7E57FC061574 for ; Fri, 17 Sep 2021 05:35:39 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id g16so14931025wrb.3 for ; Fri, 17 Sep 2021 05:35: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=15+uJTFQ+0nCVkT4/mZ7IrPmRTAjcaW6IMKjQRnhGys=; b=GnEDY2QZZLVo3N6y/3h/jMG/Fl//rb8DWsmVdxMaNQCfKakz2pqp4y4QJfHGQZrlev DHCXwHbKJvJqven9s8MIZUTJh/hAYNA18hmlD9sDYep0iAfAWtY4onOhOVlfDOEiW26W eldwTPDvHkWwz74bKWWdLE+Oo1C+nwZgWH3J1W2485DT89bccoqn1Gp1N33chZm1WTAf rYlMbRmmWTlNlCBAl912AD+HuCKiyKb5bLfgTYMVxgLXr1vOTwL62BQwIz/kT8jtQk71 bCNuiBb8aZqR6hDQIy5NHDVBiMUh+++jut+tYNZhALAE+ulGCo+sC1O/d1l6zjlMRCgl 70Lw== 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=15+uJTFQ+0nCVkT4/mZ7IrPmRTAjcaW6IMKjQRnhGys=; b=2+GUEb9LlmkHsvnIqo1Laot73hHgfGzOBk8285Y/6Ef2XTy7WBY5IhOdmSUlKaPr94 z33M85WylbfxFzQdtROBikF02D2enV8FmXCP91NypiYTrQqp4jpKmYTyE7wvgNrnO3/B QrEkp5dueE7QLG59latWVTFXB2ec+39KwQvVuX+OPLTywr7iztQEcQUKCva7owW8C45z 2Hc9BAf/nrIvQGq7+ktsoT96WFoI5fqnYLdH8isEbX3nTinW7iq/JIIl5IJD8QG3ZJE3 c21SmVXujaDe6TnNeMVyJSOHobyyJ3gggqqj2eAt0440nwkffb7TsbJHNsmaJtUx16p0 55mQ== X-Gm-Message-State: AOAM531VZNJb/YeCtqrZ7f4+iWJnOeG6wxipJA2pIRq8XPaLGAVm5XnV 8wnsTOfRE7H5Y7irjmpWhp0= X-Google-Smtp-Source: ABdhPJzdTXHakNF50MDsYEldBoA37kWhAHaVU9uOM525IrV+75dybxQfkaNHiR6FU0vQleGYfhuaXA== X-Received: by 2002:adf:f48e:: with SMTP id l14mr12138630wro.109.1631882138177; Fri, 17 Sep 2021 05:35:38 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l21sm6122049wmh.31.2021.09.17.05.35.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 05:35: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 Subject: [PATCH 26/26] dma-buf: nuke dma_resv_get_excl_unlocked Date: Fri, 17 Sep 2021 14:35:13 +0200 Message-Id: <20210917123513.1106-27-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210917123513.1106-1-christian.koenig@amd.com> References: <20210917123513.1106-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Heureka, that's finally not used any more. Signed-off-by: Christian König Reviewed-by: Daniel Vetter --- include/linux/dma-resv.h | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h index 8c968f8c9d33..f42ca254acb5 100644 --- a/include/linux/dma-resv.h +++ b/include/linux/dma-resv.h @@ -423,32 +423,6 @@ dma_resv_excl_fence(struct dma_resv *obj) return rcu_dereference_check(obj->fence_excl, dma_resv_held(obj)); } -/** - * dma_resv_get_excl_unlocked - get the reservation object's - * exclusive fence, without lock held. - * @obj: the reservation object - * - * If there is an exclusive fence, this atomically increments it's - * reference count and returns it. - * - * RETURNS - * The exclusive fence or NULL if none - */ -static inline struct dma_fence * -dma_resv_get_excl_unlocked(struct dma_resv *obj) -{ - struct dma_fence *fence; - - if (!rcu_access_pointer(obj->fence_excl)) - return NULL; - - rcu_read_lock(); - fence = dma_fence_get_rcu_safe(&obj->fence_excl); - rcu_read_unlock(); - - return fence; -} - /** * dma_resv_shared_list - get the reservation object's shared fence list * @obj: the reservation object