From patchwork Fri Sep 10 08:26:42 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: 509330 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, 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 A7261C433F5 for ; Fri, 10 Sep 2021 08:27:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 88689610C7 for ; Fri, 10 Sep 2021 08:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231731AbhIJI2K (ORCPT ); Fri, 10 Sep 2021 04:28:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231502AbhIJI2J (ORCPT ); Fri, 10 Sep 2021 04:28:09 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5C00C061574 for ; Fri, 10 Sep 2021 01:26:58 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id z9-20020a7bc149000000b002e8861aff59so855654wmi.0 for ; Fri, 10 Sep 2021 01:26:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Qg7l/EFf9rR8AshzqDpvjOG0up4Bpj2cOJ4DPctGlsg=; b=hYO0/QJu51bK9PIC7tiV1/qT5E7pqxEhAMyFhTjajOMeAp5BV6wFpmpNanNfoAaT1i ryloc9aWQdHyMvzcBh2C/v5qQSV4OPVUQQBkhxNiXROJRTgT7YjJMFopK1+/73HgYCm/ 4BirXEKTsHk/iST/yzgyCagZPytlnvADiEELvSqKk4lxJk1GkExVa7NRcNo9JUvY8zKL gXi9cBGqGU6XRIW02kDuaxAeUBHrDd44Az/AwFmPs99Qiznj/K9eXesRP8/FYh4j71FX 1wTIDFEtHgZa0OHrGKN4S+kMzO3Re+APPHn3MqQVpFrVz/hdsxhKAXijO6UUy5x1jOSE uQwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Qg7l/EFf9rR8AshzqDpvjOG0up4Bpj2cOJ4DPctGlsg=; b=PRCXYMvrJd7jaRegMAhB+miL5tZ6mVnB66dpbiP1cTzsC2LWBNNHrWWLAoniRLjC4t dc1L+aPFc4uIv8cMc0csAZeqDDQexdKiNLOT5MLJsa1mYQKqctwOTasCA+H0uyUhW1xa 0KfQQMNZEJNHIos+IicJns/eT39jN2Mkgk54GhRTrUP9bZuCriHhvtPFGEVFk0Us5hEE jtNVL68WtBsGAbd8usdEsEcT+L+yGykGDMdNn0+73vW0c8AVwvQVRlwNFaA2g8sK5rLP bj4oU03Nn/38LT8064tiX5O0Wc5eBPwxXREl6nsHMuSYg/QppLxLq1DXtwM4CUKOLzeG qy2A== X-Gm-Message-State: AOAM531Ad4m9Lb2hZZR5axo1a2+aTmCd3p41zu/2tU+8FwqTYxednQNP B3N4veC0sbRVj4VxcL+OIt0= X-Google-Smtp-Source: ABdhPJxY8uiFmE1WR/yWgIv+FQO7at7p+ltamy2XMb+pMdNS7j34icDOhYn2bnvmsAmeZ9nekC359A== X-Received: by 2002:a1c:f314:: with SMTP id q20mr6966890wmq.154.1631262417454; Fri, 10 Sep 2021 01:26:57 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l10sm4429756wrg.50.2021.09.10.01.26.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 01:26:57 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=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 Cc: daniel@ffwll.ch Subject: [PATCH 01/14] dma-buf: add dma_resv_for_each_fence_unlocked Date: Fri, 10 Sep 2021 10:26:42 +0200 Message-Id: <20210910082655.82168-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Abstract the complexity of iterating over all the fences in a dma_resv object. The new loop handles the whole RCU and retry dance and returns only fences where we can be sure we grabbed the right one. Signed-off-by: Christian König --- drivers/dma-buf/dma-resv.c | 63 ++++++++++++++++++++++++++++++++++++++ include/linux/dma-resv.h | 36 ++++++++++++++++++++++ 2 files changed, 99 insertions(+) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 84fbe60629e3..213a9b7251ca 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -323,6 +323,69 @@ void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence) } EXPORT_SYMBOL(dma_resv_add_excl_fence); +/** + * dma_resv_walk_unlocked - walk over fences in a dma_resv obj + * @obj: the dma_resv object + * @cursor: cursor to record the current position + * @all_fences: true returns also the shared fences + * @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 iterator is started over again. + */ +struct dma_fence *dma_resv_walk_unlocked(struct dma_resv *obj, + struct dma_resv_cursor *cursor, + bool all_fences, bool first) +{ + struct dma_fence *fence = NULL; + + do { + /* Drop the reference from the previous round */ + dma_fence_put(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->is_exclusive = true; + + fence = dma_resv_excl_fence(obj); + if (fence && test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, + &fence->flags)) + fence = NULL; + } else { + fence = NULL; + } + + if (fence) { + fence = dma_fence_get_rcu(fence); + } else if (all_fences && cursor->fences) { + struct dma_resv_list *fences = cursor->fences; + + cursor->is_exclusive = false; + while (++cursor->index < fences->shared_count) { + fence = rcu_dereference(fences->shared[ + cursor->index]); + if (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, + &fence->flags)) + break; + } + if (cursor->index < fences->shared_count) + fence = dma_fence_get_rcu(fence); + else + fence = NULL; + } + + /* For the eventually next round */ + first = true; + } while (read_seqcount_retry(&obj->seq, cursor->seq)); + + return fence; +} +EXPORT_SYMBOL_GPL(dma_resv_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..f5b91c292ee0 100644 --- a/include/linux/dma-resv.h +++ b/include/linux/dma-resv.h @@ -149,6 +149,39 @@ struct dma_resv { struct dma_resv_list __rcu *fence; }; +/** + * struct dma_resv_cursor - current position into the dma_resv fences + * @seq: sequence number to check + * @index: index into the shared fences + * @shared: the shared fences + * @is_first: true if this is the first returned fence + * @is_exclusive: if the current fence is the exclusive one + */ +struct dma_resv_cursor { + unsigned int seq; + unsigned int index; + struct dma_resv_list *fences; + bool is_first; + bool is_exclusive; +}; + +/** + * dma_resv_for_each_fence_unlocked - fence iterator + * @obj: a dma_resv object pointer + * @cursor: a struct dma_resv_cursor pointer + * @all_fences: true if all fences should be returned + * @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. @all_fences controls + * if the shared fences are returned as well. + */ +#define dma_resv_for_each_fence_unlocked(obj, cursor, all_fences, fence) \ + for (fence = dma_resv_walk_unlocked(obj, cursor, all_fences, true); \ + fence; dma_fence_put(fence), \ + fence = dma_resv_walk_unlocked(obj, cursor, all_fences, false)) + #define dma_resv_held(obj) lockdep_is_held(&(obj)->lock.base) #define dma_resv_assert_held(obj) lockdep_assert_held(&(obj)->lock.base) @@ -366,6 +399,9 @@ void dma_resv_fini(struct dma_resv *obj); int dma_resv_reserve_shared(struct dma_resv *obj, unsigned int num_fences); void dma_resv_add_shared_fence(struct dma_resv *obj, struct dma_fence *fence); void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence); +struct dma_fence *dma_resv_walk_unlocked(struct dma_resv *obj, + struct dma_resv_cursor *cursor, + bool first, bool all_fences); int dma_resv_get_fences(struct dma_resv *obj, struct dma_fence **pfence_excl, unsigned *pshared_count, struct dma_fence ***pshared); int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src); From patchwork Fri Sep 10 08:26:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 508958 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, 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 793A6C433EF for ; Fri, 10 Sep 2021 08:27:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5DBE1611BF for ; Fri, 10 Sep 2021 08:27:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231755AbhIJI2L (ORCPT ); Fri, 10 Sep 2021 04:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231502AbhIJI2K (ORCPT ); Fri, 10 Sep 2021 04:28:10 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5D94C061574 for ; Fri, 10 Sep 2021 01:26:59 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id u15-20020a05600c19cf00b002f6445b8f55so797187wmq.0 for ; Fri, 10 Sep 2021 01:26:59 -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=YErPkwK3P1MRDtjuzNu0YD+XcPHeEcSK9BW/6kjgcgQ=; b=qA/lui572R0JwDCPqnhU7qt9TvJbbM5H91fOEu8BCQu0Q7yQOy1wwMumBD0JiGRoUg O/zGB8kL3WqFpJa3249cNJ5/W63M3kkvF7lV7Nvcnemx3Q+2fH1fZdBrMjijr0c3+oyR jQ4sKocFtEmwuWdPseoEuhMZXfhyyaXwgYB593uZflsMqclnRfBJSw36Hup5VznB0ayz 63gpI7+twv2v7fQC1ZXYeioDxoWVGXXxjypmbjqtT7BNWH17MwOXxtQDO1IYmNhXpV6C iwY4EUMPtBWXPgc08en4w8K7nx+z7fn8e3SxJL6F+Kz48JcEi2uu6bX0Fh21na0s3PV2 BB4g== 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=YErPkwK3P1MRDtjuzNu0YD+XcPHeEcSK9BW/6kjgcgQ=; b=E2FNI7Ykq8sgZWw/xNy3Uclcnrqmf/HdZ1z6UJ7HeTa5iUeY21l2Ii3tpToLRcmz+x qmgE8nbDN9DHSWn4Qn8/PneN/RoxBP9n0reKtG+XVZG9cPVKe0jkjjJqNuj8WUEwbpSJ CYGLfZ+5t+eCrBgm0aRvHp1JsSC7eeCJk1jB9s0S76SxeCdDarB9krPfjPUANDw3cDRj ke+OLnjrxnSeZ5C+0Vm00bwwcmvSMgFZzCOh4fng2Laxr2dkfErkPY+dPC/fe0H6LNdi oMihuG1cGSfW+dhB9NmrogflnbZt6ralAddwcax7mMXPH6jnXGN+LB4m6u7JAcwqQswI GvJQ== X-Gm-Message-State: AOAM5334l6J6ScSPnQ9/2dAQVWmiwT3jO65V1GACJjtW4tzpeIW/X/LX k1/D+kX/AC9owwQtpCQjMCRKGrdNTpwLUPz2 X-Google-Smtp-Source: ABdhPJyFWwMk0FJo1jkyoNh9TWkolVVZj0em99m4EzBxrCK7B1f0XNxpgbLiEvGjXPviAm64aqOIHQ== X-Received: by 2002:a7b:cf21:: with SMTP id m1mr766929wmg.95.1631262418476; Fri, 10 Sep 2021 01:26:58 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l10sm4429756wrg.50.2021.09.10.01.26.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 01:26:58 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=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 Cc: daniel@ffwll.ch Subject: [PATCH 02/14] dma-buf: add dma_resv_for_each_fence Date: Fri, 10 Sep 2021 10:26:43 +0200 Message-Id: <20210910082655.82168-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910082655.82168-1-christian.koenig@amd.com> References: <20210910082655.82168-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 | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/dma-resv.h | 18 ++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 213a9b7251ca..8cbccaae169d 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -323,6 +323,44 @@ void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence) } EXPORT_SYMBOL(dma_resv_add_excl_fence); +/** + * dma_resv_walk - walk over fences in a dma_resv obj + * @obj: the dma_resv object + * @cursor: cursor to record the current position + * @all_fences: true returns also the shared fences + * @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_walk(struct dma_resv *obj, + struct dma_resv_cursor *cursor, + bool all_fences, bool first) +{ + dma_resv_assert_held(obj); + + cursor->is_first = first; + if (first) { + struct dma_fence *fence; + + cursor->index = -1; + cursor->fences = dma_resv_shared_list(obj); + cursor->is_exclusive = true; + + fence = dma_resv_excl_fence(obj); + if (fence) + return fence; + } + + if (!all_fences || !cursor->fences || + ++cursor->index >= cursor->fences->shared_count) + return NULL; + + return rcu_dereference_protected(cursor->fences->shared[cursor->index], + dma_resv_held(obj)); +} +EXPORT_SYMBOL_GPL(dma_resv_walk); + /** * dma_resv_walk_unlocked - walk over fences in a dma_resv obj * @obj: the dma_resv object diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h index f5b91c292ee0..6f9bb7e4c538 100644 --- a/include/linux/dma-resv.h +++ b/include/linux/dma-resv.h @@ -165,6 +165,21 @@ struct dma_resv_cursor { bool is_exclusive; }; +/** + * dma_resv_for_each_fence - fence iterator + * @obj: a dma_resv object pointer + * @cursor: a struct dma_resv_cursor 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. + */ +#define dma_resv_for_each_fence(obj, cursor, all_fences, fence) \ + for (fence = dma_resv_walk(obj, cursor, all_fences, true); fence; \ + fence = dma_resv_walk(obj, cursor, all_fences, false)) + /** * dma_resv_for_each_fence_unlocked - fence iterator * @obj: a dma_resv object pointer @@ -399,6 +414,9 @@ void dma_resv_fini(struct dma_resv *obj); int dma_resv_reserve_shared(struct dma_resv *obj, unsigned int num_fences); void dma_resv_add_shared_fence(struct dma_resv *obj, struct dma_fence *fence); void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence); +struct dma_fence *dma_resv_walk(struct dma_resv *obj, + struct dma_resv_cursor *cursor, + bool first, bool all_fences); struct dma_fence *dma_resv_walk_unlocked(struct dma_resv *obj, struct dma_resv_cursor *cursor, bool first, bool all_fences); From patchwork Fri Sep 10 08:26:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 509329 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, 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 68788C433FE for ; Fri, 10 Sep 2021 08:27:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48A36611C5 for ; Fri, 10 Sep 2021 08:27:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231773AbhIJI2L (ORCPT ); Fri, 10 Sep 2021 04:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231502AbhIJI2L (ORCPT ); Fri, 10 Sep 2021 04:28:11 -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 AFFE6C061574 for ; Fri, 10 Sep 2021 01:27:00 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id d6so1431550wrc.11 for ; Fri, 10 Sep 2021 01:27:00 -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=L5dIDlEb7TduptKFQf5pK4qlvzDeGzLljRLEJA4EwpM=; b=QW6FYNP8uWQsUwkM+c2KEOZQm7ch4KK8iurjtNDTAvKtWmZE4r20QbTXnvVoInNXFh I7CN9X+8zzZoK1KL0eUraoxtzTDITqDsUpmOc1u4Nei2q5Yp45m9N+z9uk/1OCJrbtAG fYlKCa08xPnWgmcjF7LeMk1AQCSrKGsamk+vv0CopILztqQbLxweSJQCkoj7LsjnajTZ ToMceDb48xf7m3n+i5u+/TsFA9+61JOiwuuKOtN2DGvBkzpMSAyEhN+MwrLrGDQa1fFq YHqdamSaec5BWtoB9n3W483ecyZFV1rDM981m33J7vZXNmq2oX28oqUggo/RllieZul3 tfcg== 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=L5dIDlEb7TduptKFQf5pK4qlvzDeGzLljRLEJA4EwpM=; b=B5/4pw5Wq4rngDQb7rhtATmfnGIO2ZKGpRGS8918l6Oja6R0D8PDdxV81zWthfsSrW yBSWF1QVMmjZ3qcpzXyESKyOw7/hRv9M8ZvnY8MKX2suMfxIKAjXAfufH1gxY2X5QOwU L431KFvUrBksqgVL7OBUmtOFn+EErlZ1pFaBehrSKw4nMjpP4ic01Ksv//5PWHoNCqQu OQQsMb3H8kl2yK6HqOyLwvV5+XE4W6iB/R9x85ApsYzlvPgRcRD6Xdhe3U4/h3X5nIN/ dfOPxtSBU+qCXRlJilB0qnRyICFgRNO584K2Ouvp8unr4qXLtHFL+W2zh+rsEZTJzPRE TNMA== X-Gm-Message-State: AOAM531p8/4rk0uhcBj9xd7AHwc3xdS+DMC/bvA4sjJY4zYZM0x2p5gM iqDhYWFp2+/LNFilwmfBxNo= X-Google-Smtp-Source: ABdhPJw0H96EVho6e+D7qCMJS8mWk4G39tWkKOX4/EPVrxRLEx5atvunrpg6COw8vyus+jXx7vZbKw== X-Received: by 2002:adf:e645:: with SMTP id b5mr8469261wrn.34.1631262419343; Fri, 10 Sep 2021 01:26:59 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l10sm4429756wrg.50.2021.09.10.01.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 01:26:58 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=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 Cc: daniel@ffwll.ch Subject: [PATCH 03/14] dma-buf: use new iterator in dma_resv_copy_fences Date: Fri, 10 Sep 2021 10:26:44 +0200 Message-Id: <20210910082655.82168-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910082655.82168-1-christian.koenig@amd.com> References: <20210910082655.82168-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/dma-buf/dma-resv.c | 81 +++++++++++++++----------------------- 1 file changed, 32 insertions(+), 49 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 8cbccaae169d..9a9c0bba772b 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -433,74 +433,57 @@ EXPORT_SYMBOL_GPL(dma_resv_walk_unlocked); */ 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_cursor cursor; + struct dma_resv_list *list; + struct dma_fence *f, *excl; dma_resv_assert_held(dst); - rcu_read_lock(); - src_list = dma_resv_shared_list(src); + list = NULL; + excl = NULL; -retry: - if (src_list) { - unsigned int shared_count = src_list->shared_count; + rcu_read_lock(); + dma_resv_for_each_fence_unlocked(dst, &cursor, true, f) { - rcu_read_unlock(); + if (cursor.is_first) { + dma_resv_list_free(list); + dma_fence_put(excl); - dst_list = dma_resv_list_alloc(shared_count); - if (!dst_list) - return -ENOMEM; + if (cursor.fences) { + unsigned int cnt = cursor.fences->shared_count; - rcu_read_lock(); - src_list = dma_resv_shared_list(src); - if (!src_list || src_list->shared_count > shared_count) { - kfree(dst_list); - goto retry; - } + rcu_read_unlock(); + list = dma_resv_list_alloc(cnt); + if (!list) + return -ENOMEM; - dst_list->shared_count = 0; - for (i = 0; i < src_list->shared_count; ++i) { - struct dma_fence __rcu **dst; - struct dma_fence *fence; + list->shared_count = 0; + rcu_read_lock(); - fence = rcu_dereference(src_list->shared[i]); - if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, - &fence->flags)) - continue; - - if (!dma_fence_get_rcu(fence)) { - dma_resv_list_free(dst_list); - src_list = dma_resv_shared_list(src); - goto retry; + } else { + list = NULL; } + excl = NULL; + } - if (dma_fence_is_signaled(fence)) { - dma_fence_put(fence); - continue; - } + if (cursor.is_exclusive) + excl = f; + else + RCU_INIT_POINTER(list->shared[list->shared_count++], f); - dst = &dst_list->shared[dst_list->shared_count++]; - rcu_assign_pointer(*dst, fence); - } - } else { - dst_list = NULL; + /* Don't drop the reference */ + f = NULL; } - new = dma_fence_get_rcu_safe(&src->fence_excl); rcu_read_unlock(); - src_list = dma_resv_shared_list(dst); - old = dma_resv_excl_fence(dst); - 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 10 08:26:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 508957 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, 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 7E84EC433F5 for ; Fri, 10 Sep 2021 08:27:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 67915610C7 for ; Fri, 10 Sep 2021 08:27:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231771AbhIJI2N (ORCPT ); Fri, 10 Sep 2021 04:28:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231774AbhIJI2M (ORCPT ); Fri, 10 Sep 2021 04:28:12 -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 DA9D3C061574 for ; Fri, 10 Sep 2021 01:27:01 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id u16so1449521wrn.5 for ; Fri, 10 Sep 2021 01:27:01 -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=nRgKzPY716uBcqzlD486ZNP7MTz75iQyYL0S/ztJuik=; b=FS4E88FNOuhDufIsC6QEy21VBZNvlW9xy/w3nbJHqGYzUPLTeReXi5mBTchosSHG5f ZWwidH0HyDKLtyouZqwPcSvZ53D7SkOhh0wpZHDDaoy7HASls0oUCmGSq8Ms4Ohx0HqP 1+3fBCQbYzUs+lj5oV2NC1uf6QuIRBSLRB4tcFrkAZnLVhdvAOH/qT7q4cKHjh6HAEZO ywS+PgEMK9uSdXh7JLSkJk8dZWqGgs5sPvbVFhfBRwj825HG0B4f3Z9JGaucv5OcXKzB ZNlKRjf5HkTn5jKothqucLGgwIuIjIUbpNmd7YLhr0CZcPuEL4L9NEQVU7Dk2BBSdJUO h58w== 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=nRgKzPY716uBcqzlD486ZNP7MTz75iQyYL0S/ztJuik=; b=lDRcYWNFpvPa+u4acMJmigvDNjZs7iu8TDTM734u6gKckP+Xrc0Y47JmX7FSH8Lc5t vUCeJC/5Onq6+hZdEQk6owdHBHZRzDwsPFegVIf5+Y+18SFMSJruxwoodafr8ZxKsWj2 EVJuu+/Wt+sHkPEoJtO5IaCq9Iq7EOgiQdF6c98Hx/gIuR68hkLLWdN7Q0rLu5yjozGO pWqFluf/hPJHV6CrcxefQqYDHe+t0Pu8/0SQOsRq83cUEy5Mh2dNEVAr0cIFEQooE1j5 Ay2rRmwUuq3Df8RpIHzzuM/t69ZdshVi+LtDx8zsNzne3GJFpzVeuY4dOhFgEaLbZnAZ ZFyA== X-Gm-Message-State: AOAM531SbqDOVVyU5vLsJ0/0vCcRI5LfsTKXPg25wTWX+Yvfl31OA6sm BUVUzPoda/gUrigaeOA6zB4= X-Google-Smtp-Source: ABdhPJz61M3U+vGt3QVPLv7BGmosqiUuJUUtGZ7ovO7uFD3uT3WFpi4JJCO2cPrmuymJNsMmoSamPg== X-Received: by 2002:adf:d185:: with SMTP id v5mr8294151wrc.378.1631262420440; Fri, 10 Sep 2021 01:27:00 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l10sm4429756wrg.50.2021.09.10.01.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 01:26:59 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=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 Cc: daniel@ffwll.ch Subject: [PATCH 04/14] dma-buf: use new iterator in dma_resv_get_fences Date: Fri, 10 Sep 2021 10:26:45 +0200 Message-Id: <20210910082655.82168-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910082655.82168-1-christian.koenig@amd.com> References: <20210910082655.82168-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 Reported-by: kernel test robot --- drivers/dma-buf/dma-resv.c | 110 +++++++++++++------------------------ 1 file changed, 37 insertions(+), 73 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 9a9c0bba772b..2dfb04e6a62f 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -493,99 +493,63 @@ 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); - - fence_excl = dma_resv_excl_fence(obj); - if (fence_excl && !dma_fence_get_rcu(fence_excl)) - goto unlock; + struct dma_resv_cursor cursor; + struct dma_fence *fence; - fobj = dma_resv_shared_list(obj); - if (fobj) - sz += sizeof(*shared) * fobj->shared_max; + *shared_count = 0; + *shared = NULL; - if (!pfence_excl && fence_excl) - sz += sizeof(*shared); + if (fence_excl) + *fence_excl = NULL; - if (sz) { - struct dma_fence **nshared; + rcu_read_lock(); + dma_resv_for_each_fence_unlocked(obj, &cursor, true, fence) { - nshared = krealloc(shared, sz, - GFP_NOWAIT | __GFP_NOWARN); - if (!nshared) { - rcu_read_unlock(); + if (cursor.is_first) { + unsigned int count; - dma_fence_put(fence_excl); - fence_excl = NULL; + while (*shared_count) + dma_fence_put((*shared)[--(*shared_count)]); - nshared = krealloc(shared, sz, GFP_KERNEL); - if (nshared) { - shared = nshared; - continue; - } + if (fence_excl) + dma_fence_put(*fence_excl); - 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; - } - } + count = cursor.fences ? cursor.fences->shared_count : 0; + count += fence_excl ? 0 : 1; + rcu_read_unlock(); - if (i != shared_count || read_seqcount_retry(&obj->seq, seq)) { - while (i--) - dma_fence_put(shared[i]); - dma_fence_put(fence_excl); - goto unlock; + /* Eventually re-allocate the array */ + *shared = krealloc_array(*shared, count, + sizeof(*shared), + GFP_KERNEL); + if (count && !*shared) + return -ENOMEM; + rcu_read_lock(); } - 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 (cursor.is_exclusive && fence_excl) + *fence_excl = fence; + else + (*shared)[(*shared_count)++] = fence; - if (!shared_count) { - kfree(shared); - shared = NULL; + /* Don't drop the reference */ + fence = NULL; } + rcu_read_unlock(); - *pshared_count = shared_count; - *pshared = shared; - return ret; + return 0; } EXPORT_SYMBOL_GPL(dma_resv_get_fences); From patchwork Fri Sep 10 08:26:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 509328 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, 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 42C9FC433EF for ; Fri, 10 Sep 2021 08:27:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C7B5611AD for ; Fri, 10 Sep 2021 08:27:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231776AbhIJI2O (ORCPT ); Fri, 10 Sep 2021 04:28:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231774AbhIJI2N (ORCPT ); Fri, 10 Sep 2021 04:28:13 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D32F6C061574 for ; Fri, 10 Sep 2021 01:27:02 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id u16so1449631wrn.5 for ; Fri, 10 Sep 2021 01:27:02 -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=iv3iL4Al5MFxDujFTlhS5KAG1aDR1CSRZPf6sBHgzmk=; b=Yqzo7HG07zVVhXVU1Pt7gjvFnqhuaXnhZaPz5IBwfMJmjnqY3jL/EGOBvHw6xsNSHV Xh7Kt1ZYxdDl//EZRgG3MhNtDrNkvxrSGH+1khUDORwVypfH8EMYZlax9gQ3rkVbnSTm uWDBcg35eInF+K9AKkdcAI3SX3zjZe/+gNUMNu57O/JVqK58elyRqJVKE3zbSF1/d/GC bXlfwhNoQwRMoA1fWfuLve2JbbIDMW5yQo0u9EcKJ17UACE9AmWHom2Hi7Vg1im/d7eI NxrLLZf7Hwd3r4T24C2T7gGk15p2n+dMSBzcwVpJKos67lfXB2R76kAlEaV5rYJFr9eG 8+Iw== 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=iv3iL4Al5MFxDujFTlhS5KAG1aDR1CSRZPf6sBHgzmk=; b=LY5LXvuvUrRJ31lM8cKA3LrfIfCHmv5AABL+Uh/COMiB9d+aNxZx+kA41MQ7eOdzlG DktG+aOShunBZM/7QUway2j/TRu9SlmQEQkT8jc6ruWIDbGNYP5OXF+9a8dEIXjrWJr9 aWuHWzLGF8k0Rpl4cmzWgFW1o1ZLyeq797lqeZ/Y6WT43ElqGYov+kecmQOtX7RLqzdj y+BgeGWAjKxEEeUmDBG45c396Cehn1/2qkE457r5RH/N9DGfZmFmz0qBvVFqfV2fd4kR Uo357QRzZS1o+SBPrXYo0hZ6gpwaPzSmJBn5Nb+G0UE/oQAX5f1QBC6fAEcpqztDd9hJ TDpw== X-Gm-Message-State: AOAM5333gyrPhU8OmIsD9v8RBGt+dUrnq6QL6nhk0oKxUdasld70pQaf ICjdlfOo9sGVbdlSvsloxlQ= X-Google-Smtp-Source: ABdhPJwvkdWSjL3l6YyCllswNbQ1FNCp5nB/7SmqNLTNtMIAhMCUuwSEjPqPSPVvHJV0GqPjrH6zbQ== X-Received: by 2002:adf:dc8a:: with SMTP id r10mr8348379wrj.371.1631262421539; Fri, 10 Sep 2021 01:27:01 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l10sm4429756wrg.50.2021.09.10.01.27.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 01:27:01 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=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 Cc: daniel@ffwll.ch Subject: [PATCH 05/14] dma-buf: use new iterator in dma_resv_wait_timeout Date: Fri, 10 Sep 2021 10:26:46 +0200 Message-Id: <20210910082655.82168-5-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910082655.82168-1-christian.koenig@amd.com> References: <20210910082655.82168-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 --- drivers/dma-buf/dma-resv.c | 64 +++++--------------------------------- 1 file changed, 7 insertions(+), 57 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 2dfb04e6a62f..645cf52a6a6c 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -571,74 +571,24 @@ 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_cursor 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_for_each_fence_unlocked(obj, &cursor, wait_all, fence) { + rcu_read_unlock(); - if (dma_fence_is_signaled(fence)) { + ret = dma_fence_wait_timeout(fence, intr, ret); + if (ret <= 0) { dma_fence_put(fence); - fence = NULL; + 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(); } - 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 10 08:26:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 508956 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, 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 2A52EC43217 for ; Fri, 10 Sep 2021 08:27:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0F32D611AD for ; Fri, 10 Sep 2021 08:27:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231783AbhIJI2O (ORCPT ); Fri, 10 Sep 2021 04:28:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231774AbhIJI2O (ORCPT ); Fri, 10 Sep 2021 04:28:14 -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 C51C4C061574 for ; Fri, 10 Sep 2021 01:27:03 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id q26so1446896wrc.7 for ; Fri, 10 Sep 2021 01:27:03 -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=qW+9yeXWdgQdV+++wShEfX/2r8PdvtzgR8RKF6D1Slo=; b=VzzUsjk0AEIRSeBRpV5cyDCOrSGL9w5QUkSlFheWQB/c9xHxQsZAqclnL/JGB+y3f3 zNlWhIVVhqLTN9AavwmJJX6ADnNHQSgb7fRU7qce20FAYUwXFWg0UAU9jTWQY+Cl4CYO 2YLJ1N16KKzW9x3EX/jZdoz7MuR6qttw2RAIuhNpqu6AbZYJUxJaE95SsgrG33RETAGY 50fLxqhx462/l/nQ1eTKo9DdOkrYojZQ6Omp67DNoMlrD5WYtdLwypEiewKYWCoHRkp9 BL5mr0+r4s1KMlm9PN5WAeBPWk8+Pg4lURDG/3QSNbTXDmHeiqct6Y5bU4BGVhYEQCNF XOcw== 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=qW+9yeXWdgQdV+++wShEfX/2r8PdvtzgR8RKF6D1Slo=; b=J/DfRm6UPX1gqavEjTjru7joql8CwIC29M+41lZP4tFVs0Sm5rDCUFwb5xfthOkrm6 LtzIkbHLlCNTFdni5R/mEY8H2wO8sCYrr+OY0ncOA7Msw5cH9POlA+GP2qO53g6v15ay GqgjQrac/TfQ6jKrDdCO4wy5PfWt+fQMycSUIsysPomH0fgOYmT32ZN0xI2Dq0olrgPB 9bk0Zg++LmUXsO1dv5U6k3hYrf6zVBCZCyS4cz6oRJ8h2B5Y/YVgqkVMBpvfTC/fLrOh WlExllBrx/6w3liBQcV/uzx7cRFtjBzwjsz+mx/ZSP9Kp9nSNLQ0KBrNLghD/kylzzfT 6SuA== X-Gm-Message-State: AOAM531UePBNJ5K+qiDXnWr6JAXUx0YgQ7xQUv+dhjCFgGMz6iEjlOc8 z4gFKws8pul9GfeV0FodFC8= X-Google-Smtp-Source: ABdhPJzEW++4UtO+2/WEXjNR4ZrvyQisPxmWGmjCsRmLMya0Yo65UWWhGodkfXL8zjWWriaK+QFhFw== X-Received: by 2002:adf:fb09:: with SMTP id c9mr8111801wrr.93.1631262422437; Fri, 10 Sep 2021 01:27:02 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l10sm4429756wrg.50.2021.09.10.01.27.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 01:27:02 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=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 Cc: daniel@ffwll.ch Subject: [PATCH 06/14] dma-buf: use new iterator in dma_resv_test_signaled Date: Fri, 10 Sep 2021 10:26:47 +0200 Message-Id: <20210910082655.82168-6-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910082655.82168-1-christian.koenig@amd.com> References: <20210910082655.82168-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 --- drivers/dma-buf/dma-resv.c | 54 +++++--------------------------------- 1 file changed, 7 insertions(+), 47 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 645cf52a6a6c..cde5d448d029 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,19 @@ 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_cursor 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_for_each_fence_unlocked(obj, &cursor, test_all, fence) { + if (!dma_fence_is_signaled(fence)) { + rcu_read_unlock(); + dma_fence_put(fence); + 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; - rcu_read_unlock(); - return ret; + return true; } EXPORT_SYMBOL_GPL(dma_resv_test_signaled); From patchwork Fri Sep 10 08:26: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: 509327 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, 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 95963C433F5 for ; Fri, 10 Sep 2021 08:27:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FAB9611C4 for ; Fri, 10 Sep 2021 08:27:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231787AbhIJI2Q (ORCPT ); Fri, 10 Sep 2021 04:28:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231774AbhIJI2P (ORCPT ); Fri, 10 Sep 2021 04:28:15 -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 A9F01C061574 for ; Fri, 10 Sep 2021 01:27:04 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id u16so1449747wrn.5 for ; Fri, 10 Sep 2021 01:27:04 -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=byLSDqjdKi3+cE2IMMDe/R3eVJ9OpfF5t0/Jijtn6q0=; b=M1RjKlSJECx4MS0DsZ1oArWcYKVcShptg1wsRAotmw1sniqngIJqtiAE3qMaCmkPLX lEG/vaQf3P4qw3rCZbxGt2y8/sIT539y5GkEQhbx/ui7Ao/GlSSvixm2fN7a9mJMoG/+ 01Gqs805XQAF/rJFxdViLwn3FBTNqb8d1BEP32pqLh187NRgc91uKspSGsjRasIbusy7 xH9UK/jcaGUslitEmn3CuvD/FNeYb5ZP6uIpXNbGSaA/fBj+waWwo4rGG2r5Gg3cQwxY vMxnCGBhwrWq9f2+Lkf2R6xBkcpzqSpk25ce5oQ4ssN+anqUm1qMLZWDAqxrBKF6Iq46 fxsA== 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=byLSDqjdKi3+cE2IMMDe/R3eVJ9OpfF5t0/Jijtn6q0=; b=4g5zYOZ2h0LAcSK15JcM3rd7GtOFuYNMJvoLVrrSxdKePCNP7qnM7gDH5TcDFTTCKq tcZOVhDnljpWGFRF5dL9qPvIruBmS9uS+3ur1nd89cgV1LG2Zhc0HgV863hZmPx570PK cyyiE5U55AO931yjaGXFIKlo9ow4MBReFvu53Z/75a7Yje+AzE1cr+jDLC/4EW8cN28l U6wFat1crBF5ZRogH2vFMEWTHrgw/mw3V6KIDk7EWSODxSFg/Jzh8/4/qvCYVGJI1PBg PbEKQNnI6O/CictBjzYjBq3n+rhP3vdGYVlE2suNdQA5KpfpXG8kW1sKjrjG7SOjtNG/ WL7w== X-Gm-Message-State: AOAM531V7r0FzVu5LOzgNmO+iXTFkxPQM6FYZ/S7M0Hxb0Ven5TebgiG 018oeLNz3YtmwkUJSXDay16A0f0cTpwGbF9n X-Google-Smtp-Source: ABdhPJwti/PivNUxcntiq+mV5bRnvy3fWoun3RXdVSzz/jtT7J7GtASJ96xhTkxgTdJNYJ6YimSHEQ== X-Received: by 2002:a5d:4e51:: with SMTP id r17mr8260877wrt.308.1631262423353; Fri, 10 Sep 2021 01:27:03 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l10sm4429756wrg.50.2021.09.10.01.27.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 01:27:03 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=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 Cc: daniel@ffwll.ch Subject: [PATCH 07/14] drm/i915: use the new iterator in i915_gem_busy_ioctl Date: Fri, 10 Sep 2021 10:26:48 +0200 Message-Id: <20210910082655.82168-7-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910082655.82168-1-christian.koenig@amd.com> References: <20210910082655.82168-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 | 30 +++++++----------------- 1 file changed, 9 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..c6c6d747b33e 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_cursor cursor; + struct dma_fence *fence; int err; err = -ENOENT; @@ -109,28 +109,16 @@ 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_for_each_fence_unlocked(obj->base.resv, &cursor, true, fence) { + if (cursor.is_exclusive) + /* 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; - err = 0; out: rcu_read_unlock(); From patchwork Fri Sep 10 08:26: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: 508954 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, 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 96D6BC4332F for ; Fri, 10 Sep 2021 08:27:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 814446113A for ; Fri, 10 Sep 2021 08:27:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231793AbhIJI2U (ORCPT ); Fri, 10 Sep 2021 04:28:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231774AbhIJI2Q (ORCPT ); Fri, 10 Sep 2021 04:28:16 -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 879C3C061574 for ; Fri, 10 Sep 2021 01:27:05 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id x6so1426912wrv.13 for ; Fri, 10 Sep 2021 01:27:05 -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=AQf+EG1LqOYQqT40zZYv5ISTQOpig8QPja/gK5mvSkk=; b=KWztHsb21w2it84cyHjC8FeFPLylec8BzPNdnnOAyMTcQFQvrL3Iphclm4QJJZDNY3 USh7eCwk5QhBrruugl+vnG0zMSXsO13CTBLDKslniTxOaJVtfYs7rKOKsYErSqvPcjD4 TB/wXN0YbSOQ+jJolf3+e/xGFvb9UzZ4renfdtmpogVZD1t2tDKSbOw7Eic3v95/zTYT ksVo+L5+rZQLvXxkicZlQmoPI3Cjb4segzer8T6r6MsO1LAJMapEIRAAqBov5nmivbbn r7RfobGfU50paoaXQ3qhW9fD4cxFkPOOkM1wprcyGTEMWGK404bnGwZ7L+wvx76UF0AX 6tAA== 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=AQf+EG1LqOYQqT40zZYv5ISTQOpig8QPja/gK5mvSkk=; b=QVmf+dsnJsBvRjqH+AvdrVLrgDQagipegaMwzvRDgWXaWAGin2R7e37WOXw2OtB7ZN H9k9JD8n1s9/j+73nwjOSpkORl1UKk8YqtSmXcJQXknODmUbnaxpeeTSYfa+tbJZ1+7R G3WfPnvtFcgZ0CwDhNkMG1OCYef2Vs4eMO10GWKgpwTgjcnUJ51IpcZR/AWcUTRbPmKo DXXoVeQOz3vbDEg/HsQUA5CgqFzp5xBEl59Rw0SIAKVMYKgCQWXjUf5DbjTFYMLCx2a3 hk9TMxXl/KcuG1rhgRMFh8URxWcpVrCXHSXs/J5LQ1efjs4MQjWE5Ujb5m3aAAYRm7+g n/Rg== X-Gm-Message-State: AOAM531nPFRx7pIr+eZGJuYiYlQDlvCoCNboZhoaGNYKYuNicyPzqcQl A4VWD8BZUWm0+xtsMAhLv5CUW0IkunjuIx5f X-Google-Smtp-Source: ABdhPJy68Z8lYN7Y274ina8jZFGUbeYevbUiZ29MIqcoqNjsNlZswRucR0lzTahDGThht/diqI0B7w== X-Received: by 2002:adf:eb4c:: with SMTP id u12mr8424261wrn.111.1631262424189; Fri, 10 Sep 2021 01:27:04 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l10sm4429756wrg.50.2021.09.10.01.27.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 01:27:03 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=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 Cc: daniel@ffwll.ch Subject: [PATCH 08/14] drm/ttm: use the new iterator in ttm_bo_flush_all_fences Date: Fri, 10 Sep 2021 10:26:49 +0200 Message-Id: <20210910082655.82168-8-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910082655.82168-1-christian.koenig@amd.com> References: <20210910082655.82168-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 --- drivers/gpu/drm/ttm/ttm_bo.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 0a3127436f61..5dd0c3dfec3c 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -269,19 +269,11 @@ 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_cursor 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_for_each_fence_unlocked(resv, &cursor, true, fence) { if (!fence->ops->signaled) dma_fence_enable_sw_signaling(fence); } From patchwork Fri Sep 10 08:26: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: 509326 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, 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 22501C43219 for ; Fri, 10 Sep 2021 08:27:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 09381611C0 for ; Fri, 10 Sep 2021 08:27:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231792AbhIJI2U (ORCPT ); Fri, 10 Sep 2021 04:28:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231788AbhIJI2R (ORCPT ); Fri, 10 Sep 2021 04:28:17 -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 85BCDC061756 for ; Fri, 10 Sep 2021 01:27:06 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id g74so612277wmg.5 for ; Fri, 10 Sep 2021 01:27:06 -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=Y/imVMS+E7ZynWw7iSiIjDs1SxBWXyWjuW715+Mfo5c=; b=WtZaZ8lTrzJYkzKuB+d6ATVa2C6k5r+VXR9fkvKSv7zY3+Wpt9lWHA1pwqPZlayoft TEa8zcAd84lNsM7gKRlyqKdfBV74rX2zlmk9xfsqP03pWCwl3GJC56Qkn1idmJdF1Lg7 s8WJvVtgv+lT7Orxk1R/z7jCJD5m/s4KJ1UbtU7Fe/er9HCRKjBAV/uicmyDXGLLUKws 78FVl2AsmhWdmtCwnn03bFgTiNBOeOxsKjKi2ZC2OZI/rM8wVNxgsr5wxM3mjFqUOZiQ CUhI+LEJufmj4NPth0Oi6nUMzKDO/3IGhc7ZbdTxoVRpsJkHRpYbU6mBGxdQeMFRIqAS 08eA== 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=Y/imVMS+E7ZynWw7iSiIjDs1SxBWXyWjuW715+Mfo5c=; b=D6CejkYL1KWbkRu66wAk9tFe9oseWOL8Sg4ajfqmmsXc2rqX6n1ad1/gHTiZh/Ttnz MNMgzxC8IWNm1Y7PKkcKZpdWDUCVBRWD8PozOzIsejLEKzE0tcw0rQWlDhixjDHRLTso p2LarbVClMgjBAEBuzgisIN/5vLRnxamudS8it3SRrwZUoZR3nH+mJeSNZe6ViZHBhGk ooPVEFopCX/Fj5QL02AFMpNft4yzoSZJswD1sz2fn/Ez7zelOhh3NFDo+rHe8umFUGJD Be6Y1fkPbnmCDafrUhCedFhPblt0l6F5micu94u0JYLBticSFavLoIUtXBD3fGUlvxgY SFtg== X-Gm-Message-State: AOAM532WOHpL7sv1N2MfwOMcMSe616ZwtBvjWeVLA0uFhQGO6ic4B4Jj IaBwshTyqCSmWIq1h5rvb5o= X-Google-Smtp-Source: ABdhPJyz6KtB+9SFHXD6Ag3BbTzhdxjn4oJj/Wy4PIb7F55aitZHvqm3vDWMLYmLb9u7fpDLGo1GpA== X-Received: by 2002:a7b:cd92:: with SMTP id y18mr7165760wmj.78.1631262425147; Fri, 10 Sep 2021 01:27:05 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l10sm4429756wrg.50.2021.09.10.01.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 01:27:04 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=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 Cc: daniel@ffwll.ch Subject: [PATCH 09/14] drm/etnaviv: use new iterator in etnaviv_gem_describe Date: Fri, 10 Sep 2021 10:26:50 +0200 Message-Id: <20210910082655.82168-9-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910082655.82168-1-christian.koenig@amd.com> References: <20210910082655.82168-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 | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c index b8fa6ed3dd73..6808dbef5c79 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c @@ -437,19 +437,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_cursor cursor; struct dma_fence *fence; unsigned long off = drm_vma_node_start(&obj->vma_node); @@ -459,19 +457,12 @@ 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_for_each_fence_unlocked(robj, &cursor, true, fence) { + if (cursor.is_exclusive) + etnaviv_gem_describe_fence(fence, "Exclusive", m); + else etnaviv_gem_describe_fence(fence, "Shared", m); - } } - - fence = dma_resv_excl_fence(robj); - if (fence) - etnaviv_gem_describe_fence(fence, "Exclusive", m); rcu_read_unlock(); } From patchwork Fri Sep 10 08:26: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: 508955 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, 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 F1CAFC433FE for ; Fri, 10 Sep 2021 08:27:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA6F7610C7 for ; Fri, 10 Sep 2021 08:27:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231791AbhIJI2T (ORCPT ); Fri, 10 Sep 2021 04:28:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231724AbhIJI2S (ORCPT ); Fri, 10 Sep 2021 04:28:18 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94FD3C061757 for ; Fri, 10 Sep 2021 01:27:07 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 196-20020a1c04cd000000b002fa489ffe1fso819209wme.4 for ; Fri, 10 Sep 2021 01:27:07 -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=hvNXqtq5mdZJpJK7jpCUZ+hsh9G2TDoGYYpRx9Mul74=; b=A0kUPdgAC5+TWncOXFWh9Qfoaz4FqK6InBydLkzZ2x7lLAs7i9QFOntRXj7yX9qarp cUBcMzhKvr9jHJpHtBm+wJjchNGcL6IoCyzu9L483z8pzFqYV3B0KTH+6m9hAHIGKKtu 0sgckvdf0Yj9lszW2BU2mwHEI+scDEg6bsDzdWehB+mB3EzrE6VcbsHrBHxYq4VFwR7v mYGnlldEKj2n5a/+SMQYOW/vloLUldESANOPycvU0UV/EFyvTlRYWZQqkEfmEORntF/m yXgusF9ccePSbKyYDC8ZP02wrj3GXK5P4bKvgooD7j9adhlK2j3q9aRhJUsWMqnKJ3Ph RHaA== 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=hvNXqtq5mdZJpJK7jpCUZ+hsh9G2TDoGYYpRx9Mul74=; b=CMw76YMPRvOdoMk50VN4yszYuCmqU7DxgWxX0zHTex6vA0kquU1inLx7hav6WAeK3K zyDl1JIrPw5IdVz4YfC1XjhRXZgwwosoWWJ9I/yDs1TD5cMJSjsay85z/8Dbme0Vv7+o L3zxt+hFAf4DRQYUYJKe+7qHvLdGu8K1tpW2524vEmhLLHTlq68NsYgzr0fvO3bXCaEG UVAjxsK3gkagZsWkpuT33CIisNl4//SRORUJ9a1XHzM1lyKD2K1+ecQ1/Bl06nYdOGDe rfiyEf1Y+/K4We4yeihOsc5odkK6uvxgjntD5wuTsGiw6q8VyNad8sHezCME6iKY5u/b RGSw== X-Gm-Message-State: AOAM531UJOMFgToRl6OIO70YyWDXgS4vzaQCMzrPzqeBVjEOp94cQSx5 8rxcWCVPlWIihqaip2xwiFg= X-Google-Smtp-Source: ABdhPJzCx/DlccM/dfWL6V5U0asbK2EJmgwOciOgRAKzlNGULrLLN3jCgvQVAzCAfYglVTL5xpoYmw== X-Received: by 2002:a1c:cc16:: with SMTP id h22mr7144408wmb.117.1631262426227; Fri, 10 Sep 2021 01:27:06 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l10sm4429756wrg.50.2021.09.10.01.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 01:27:05 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=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 Cc: daniel@ffwll.ch Subject: [PATCH 10/14] drm/amdgpu: use the new iterator in amdgpu_sync_resv Date: Fri, 10 Sep 2021 10:26:51 +0200 Message-Id: <20210910082655.82168-10-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910082655.82168-1-christian.koenig@amd.com> References: <20210910082655.82168-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..031ba20debb9 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_cursor 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(resv, &cursor, 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 10 08:26: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: 509325 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, 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 914AAC433FE for ; Fri, 10 Sep 2021 08:27:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77C29611C0 for ; Fri, 10 Sep 2021 08:27:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231797AbhIJI2V (ORCPT ); Fri, 10 Sep 2021 04:28:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231789AbhIJI2T (ORCPT ); Fri, 10 Sep 2021 04:28:19 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EC2CC061574 for ; Fri, 10 Sep 2021 01:27:08 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id g16so1461383wrb.3 for ; Fri, 10 Sep 2021 01:27:08 -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=E+vlHAHze2GbFEMjJ18FaF4XzFbDHKUq0E4VCOiUNuo=; b=HybftAd+7uKdOV5zg2ea0y+qhWvQofD19fVH44gZl20wjwRGG1zpzzasvlB1cJjN7u 5OLeGUdVvhXnrz93ObRQjFXGpoTmn+f5IfUQp9X0ClvsDVJuq2POC9dWspHGv9C7qf5Y SUM4Mqk1mXxACItxPdU7gFcsg7TOuFo1V122TOkOE1AZXMNKvE/zDlAn2RnUrm3PnAoJ jZaaCERt4hzU7yqGy1IjJtQ76pMLGTiJSQxOCVxQo3jh3dADc3PldDEe1lVymKyfSco9 uU/jPvx5MQ4XME91lEapNwjnxXvCqTm+34SAC4ZoYb2SshqdbWAsG0vEiPBPVDra8Iu/ 1GUg== 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=E+vlHAHze2GbFEMjJ18FaF4XzFbDHKUq0E4VCOiUNuo=; b=jc6JOX39O92lj6pgrMBNzX9bvnJuagx8w3aQY8+tCxcVaYaTZjyWDQb4WRwBOiObWd JjVBLP4tRgIFznq8xO9aOFxuwS4/nqbQx2EVZ7K6pQ7z99t+sYrswDvJKDn9SCaT9L+g 1qfzxCzTtu11hzFglQfr4jUou48oBj5pU6InC4gro0L4m4Dm1x9oz4czTW9Ppn7w3xJu /hnzRJbTRclHhb04JChXtl0qzgqmgdq45U0KTqNcxlxR1ddq5Rf84/5eZlmCc9akj8iD YMbW1w1Q9fg6nasBpu3E+7yyFotWix4LBuTsTpTVB6f57fkhb6zAx65aqCAelPd5KQZR F7og== X-Gm-Message-State: AOAM533E+CVDsQxNWkJOGKdOeDA/dYG6yEZge32Myga6IfrmgNP4J1hc 551DQ1zX+oo8Q/Z3TnE9LXM= X-Google-Smtp-Source: ABdhPJzfd/Udc2aUZ+b/NYD27ztPjCkExkaZPwjk+zgrhKyeNASlXYGYiyLGf6eAhsuRtI8c+BhUKQ== X-Received: by 2002:adf:f3ce:: with SMTP id g14mr320170wrp.95.1631262427136; Fri, 10 Sep 2021 01:27:07 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l10sm4429756wrg.50.2021.09.10.01.27.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 01:27:06 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=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 Cc: daniel@ffwll.ch Subject: [PATCH 11/14] drm/amdgpu: use new iterator in amdgpu_ttm_bo_eviction_valuable Date: Fri, 10 Sep 2021 10:26:52 +0200 Message-Id: <20210910082655.82168-11-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910082655.82168-1-christian.koenig@amd.com> References: <20210910082655.82168-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 489e22190e29..0a927006ba9c 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_cursor 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(bo->base.resv, &resv_cursor, true, f) { + if (amdkfd_fence_check_mm(f, current->mm)) + return false; } switch (bo->resource->mem_type) { From patchwork Fri Sep 10 08:26: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: 508953 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, 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 59A4FC433EF for ; Fri, 10 Sep 2021 08:27:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44BD0610C7 for ; Fri, 10 Sep 2021 08:27:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231799AbhIJI2V (ORCPT ); Fri, 10 Sep 2021 04:28:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231794AbhIJI2U (ORCPT ); Fri, 10 Sep 2021 04:28:20 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D793C061574 for ; Fri, 10 Sep 2021 01:27:09 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id n14-20020a05600c3b8e00b002f8bd2f8ab6so819960wms.5 for ; Fri, 10 Sep 2021 01:27:09 -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=SoAGyzr0AFHKUUA0vh6k3hC1t95HnGfzvSeL9OXTB3o=; b=Z3iC+Swm/AAIJ5S/nzJFDgKB/1deDYDWIvJHSIZZkReTUl7PpCdA2jxrlDFfpdmiOu t2YqkLV2EsTZ24/oR/1LWA3s34bUo7ah3JCqtEYlKQYP2qZX3AUrz6c3mIfNmhUoW/ur +mWRK2K0hsLLLEGoycitOQMzkxR4XHi/SdaDjfz18w+KlI6c9THsDdBR2izyAPt4ZKuz Bb7zoYOn32kZb3XSBl51sQklFUjKJiVnnnarZgV73OpFnuPz/ifQHmyUOE2fzD2GCgdQ YQDVJOGJLvzv04xFF0NO+xbiwvkuQ22hVCYBc4Vr7jeNeHmM/QzrQz6fZ9LTbHXVs6As d9iw== 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=SoAGyzr0AFHKUUA0vh6k3hC1t95HnGfzvSeL9OXTB3o=; b=drIXg9PDkUfAit5iIiFt0SOvSecXFjE6d6BhiFiSGYP4CzZM5Ftq7Tqmv4IBDJi1vB unNcH3Ehoo2X7bOVBzYrYTf6rj2w/xPBqfXF5lvV21P0Gx99tgnpFo2mrLvs1FBbLdZb Td7YvHL6bS0BR2xslFhxIQPfGTU3g00zmH+Kf5RV3fDB2BU+PMZoD2tLPMO5HIAiKYHt 8uF/2m09hEaKHjGMRuuCvxWmkWkf0QJVsHOQoyOOtGp2Gbi8cvthLuCNysVN7pKr7YsV AagnqQLbmhe4/v7AOO1kmL0ZOy1AZpEESHCWZ1SwAbIja24cnWufj2ovf0PO0731rIue IjSw== X-Gm-Message-State: AOAM5315maRGse7EiEQoD+UA0JndxTTzoeO7egmQ9JLwFnWj3dZg0B+6 xY0W2NKahMPsDG46GUAimKw= X-Google-Smtp-Source: ABdhPJyp1TSwidEpj8PAEswJmvQlCFP+0w3GyUfxZc/HjYy4dAcrjUXWhYXK4rt7EyLcq3pk+9dAGw== X-Received: by 2002:a1c:2b04:: with SMTP id r4mr7169119wmr.89.1631262428260; Fri, 10 Sep 2021 01:27:08 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l10sm4429756wrg.50.2021.09.10.01.27.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 01:27:07 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=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 Cc: daniel@ffwll.ch Subject: [PATCH 12/14] drm/msm: use new iterator in msm_gem_describe Date: Fri, 10 Sep 2021 10:26:53 +0200 Message-Id: <20210910082655.82168-12-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910082655.82168-1-christian.koenig@amd.com> References: <20210910082655.82168-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 5db07fc287ad..8ee4e8881b03 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -906,7 +906,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_cursor cursor; struct dma_fence *fence; struct msm_gem_vma *vma; uint64_t off = drm_vma_node_start(&obj->vma_node); @@ -981,22 +981,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(robj, &cursor, true, fence) { + if (cursor.is_exclusive) + 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 10 08:26: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: 509324 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, 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 B7790C433F5 for ; Fri, 10 Sep 2021 08:27:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A48C4610C7 for ; Fri, 10 Sep 2021 08:27:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231800AbhIJI2W (ORCPT ); Fri, 10 Sep 2021 04:28:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231789AbhIJI2V (ORCPT ); Fri, 10 Sep 2021 04:28:21 -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 B4431C061574 for ; Fri, 10 Sep 2021 01:27:10 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id v20-20020a1cf714000000b002e71f4d2026so591165wmh.1 for ; Fri, 10 Sep 2021 01:27:10 -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=aaz1/XKVq6nri9Uw2UQQseQfjyJkmrID5vYRDnEleeE=; b=a5N8gtB7x7wOQgsGTg5fo6+i3lIEKECnuhibaXMwLjgukcuTNZnoX/3B4gLOY6qTQW i3liQ75PyfcOy0oqfGQACaIn4EGODYUmw+q+IsAAy61R1AV4yWfcHCC4TbwvMFNrxPl1 MnDak6yqI7rxnrWXq/TFK35N/EcQ5xqfgaiI8JpZJErEWXa3MFX/T5fIHNviAH77Rmnq Bt7P6vIRsHeHvDy/+Q0tlyKZh/0bRqahIBIgUgVi1b//SkXKgLFzjdMFp9eYNpQnGa3U sPWtLqZSUSWtqyuJ2iUhXZok33rbWfgQ3+08gdlVjLKdw65v59E+akJuUgTUPRM46EtZ i85g== 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=aaz1/XKVq6nri9Uw2UQQseQfjyJkmrID5vYRDnEleeE=; b=0+QZh+SWgxES3QVYX0pY9ia+wDy8LIFf0mIbL3g9xvtfFpl+MkxakbUE2M6vFY21x5 fLo+QTRCAjyIO3ZWuZ/e5rAau+rw9X8QNubpFMsPBZrZkgrme93QcM9ZjaVlR7WsICWL o+YgZroJ3Wj/0sILH0e56yuzshbiRWhkz9lpDsV07ZG28b4kr+IzAuIPttuzBXSJ9+mP vhnJeEr8pzCUqkGoPCH5os7WQT+miCwln1AGCy5udMvHd87eolnCAR2fS6K5zcYy8Jdf Bu3cT4pA8mCN7yz4mIufms256lZ6OSuNNVeHODeH6798wizTVAyMTZRoovMGs7WVFvhK gZdg== X-Gm-Message-State: AOAM532u1utQeyQWdtJCxTCVCtzCU7O55OibCjKi1YB6YxX2YEwKGxpP oGOiV7bhNoekqjBm2zZc2t858IVWPiTMRDVi X-Google-Smtp-Source: ABdhPJwNg4sxGjY/to3Qc4OVsIG5ULofcu9pKXMqJiXuSTeSZcYd/FZeSHgrkCBst++XlHhVhSWXsg== X-Received: by 2002:a1c:238a:: with SMTP id j132mr7157728wmj.185.1631262429324; Fri, 10 Sep 2021 01:27:09 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l10sm4429756wrg.50.2021.09.10.01.27.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 01:27:08 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=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 Cc: daniel@ffwll.ch Subject: [PATCH 13/14] drm/nouveau: use the new iterator in nouveau_fence_sync Date: Fri, 10 Sep 2021 10:26:54 +0200 Message-Id: <20210910082655.82168-13-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910082655.82168-1-christian.koenig@amd.com> References: <20210910082655.82168-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..dc8d7ca1e239 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_cursor 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(resv, &cursor, 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 10 08:26: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: 508952 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, 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 12E00C4332F for ; Fri, 10 Sep 2021 08:27:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED4D0611C0 for ; Fri, 10 Sep 2021 08:27:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231815AbhIJI20 (ORCPT ); Fri, 10 Sep 2021 04:28:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231805AbhIJI2W (ORCPT ); Fri, 10 Sep 2021 04:28:22 -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 BBF8CC061574 for ; Fri, 10 Sep 2021 01:27:11 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id u16so1450126wrn.5 for ; Fri, 10 Sep 2021 01:27:11 -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=R6hl7Kj0yqQ18nUKlg1tjNnt1DaG6v6UQcKSpcEHFSE=; b=AF9j13vF2C40YiZF8YnlmkRI+2y0Zgx5gxsyI8poos90I9FQMyjQftYcu/PQQbKRid qbgd2bSNKqUg3uORGqVR3m7f44omguz6cGmpda84jTegLUf6kT9iGnfiiMCKVxGpozGt 4DkOkj8JqIxYhcy+Rr+gGXH4WA060kafbhcNNdhGWWVehKlZ9gj/F8BgSvTTUyTPsQe5 V2k5ZBmi2Rg2/UiszoM7SXqfPfEp1yQVwjHSCgWMRZjh8ZMnmEuNrI3xnBZxt3f7DFRD yv8Chc8CTkXgJgzEe9h+eMgYid1dfBUqacTAw9N4IkxYm0gzfAl1auYyqd4X66ZoZHkn o4Hg== 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=R6hl7Kj0yqQ18nUKlg1tjNnt1DaG6v6UQcKSpcEHFSE=; b=rCayaOyXAN8DJE3UhEUkreQuJChY3RVVR/HjV67hwLj9cQ/sgnBoG3tSwz5DWObGNg 2nEHJOoF281mMBIc1uxKxGvyCksYnEUuv2TiiKDysPF/hWUsq9itWqFXBrBgAylyejCH eFMJo0XhFXEF/bWb/l+TqT0eDNOegOWjDt6tL2YkJeSHCVdeYrZ/6WT30c9lhpUHrmN/ Dtr9FYMXaDvKy2Rwu0lAUTd6aSdS+HO0wlDXijB4eD2O9Hv3fgrBnct2rfS26vH28yhX Xr32YeZAUzD5C10kreeoifzOkZuncD84SVv2KqW1jAhaVJVudXRd7ZxCQ77coSeEnY9M 8pQQ== X-Gm-Message-State: AOAM5306xCnm3rbnXCBZhICrNl7SMHGcJE5sR0zD0I19MESUA8JS+uud t4jPyGlYyVjiJ8CWTYu+QwI= X-Google-Smtp-Source: ABdhPJwY9+avZrDVp15kV3L6A7ao2zBHMwJf/F8q7CwTgO/k1/czo3Esq+RiUn9i7G+1GaBzEM4rZA== X-Received: by 2002:adf:f08d:: with SMTP id n13mr8365190wro.339.1631262430440; Fri, 10 Sep 2021 01:27:10 -0700 (PDT) Received: from abel.fritz.box (p5b0ea1b5.dip0.t-ipconnect.de. [91.14.161.181]) by smtp.gmail.com with ESMTPSA id l10sm4429756wrg.50.2021.09.10.01.27.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 01:27:09 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=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 Cc: daniel@ffwll.ch Subject: [PATCH 14/14] drm/radeon: use new iterator in radeon_sync_resv Date: Fri, 10 Sep 2021 10:26:55 +0200 Message-Id: <20210910082655.82168-14-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910082655.82168-1-christian.koenig@amd.com> References: <20210910082655.82168-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..14a4d8135bad 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_cursor 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(resv, &cursor, 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; }