From patchwork Mon Jan 24 07:40:38 2022 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: 80238 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1nBty7-005iT6-R0; Mon, 24 Jan 2022 07:40:52 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241831AbiAXHku (ORCPT + 1 other); Mon, 24 Jan 2022 02:40:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241806AbiAXHkt (ORCPT ); Mon, 24 Jan 2022 02:40:49 -0500 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 60CD9C06173B for ; Sun, 23 Jan 2022 23:40:49 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id v13so11812728wrv.10 for ; Sun, 23 Jan 2022 23:40:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=nkHC8QZFOIHT45+bm5mbkRLb4msTxzU2f5F+QSxdoAg=; b=Qj2yBp4MqQ7KNASeGTANOuELaoriQPEus+Y5WG9R1BeNlKfWpoIpNdldl25Dp739sv Az06vMnMIfiC9jcFemaGJdxt4ksPV3D8IgfABi+dTcLwDcZqSLP7Vwff05NY1nIIgwB7 FsEk327TEn7KK6LOlZL9hEkNA5+JAXfVE2iVj5qvBHsgqjzsdkq1s8DqvXnR3vmUCKbR sKpTRuGMUEw5CVwsUHzceA0paF3lWmzHi84RljO6OMZlo15XXlrylqjBucdtB8Vnvt92 6nI85ykpmGtgGonR1HfNg8as0g/v75cbSo+t5WzkOHO4sdrYNuW8HTIb651QRaqtDXTq LYGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=nkHC8QZFOIHT45+bm5mbkRLb4msTxzU2f5F+QSxdoAg=; b=zEx0XxV5tGEoqOapuTtZ8wvPhViONm7agnDqLd+cWweHLfElGguN/n2KXyhtwGfaLu NktHkAFA5KkxoZ+mYMarfRBZkgVseEqcR5FxoDjVdw73Qqs99Edwcz5O1PjpabF1y8Zo mjuCFCzimnEC8oOfO3kXEQAY6zg5RJ4jWxgvDHMTex12TTpf/hl5kqCs9b6Igz1fgr3+ JqT7YfJlYUDM0g/zj1LHeMmQfhTlldqKJFkbPT6csJlg0n8Haia8yvYtwDeI1LPdr2iz 1N9LuJ161R1mmuz1yPo5UEk698LFuII5cy9a/RqwKipz1vAdi2OZ5Hs+fB6HYFUdTnJj gU6g== X-Gm-Message-State: AOAM531djZIofnLRyqeA1nO4Q9AXx54AzbmKtuLMxL0k1OgacT4xCYJ1 BaOQNFMKJgJAr28qq7sqn8E= X-Google-Smtp-Source: ABdhPJzhRxuEYmrw3Ii07RY11RBs/o/Fq2cYVaEP6QMU32uHoHeBFsvH7w6OILGVbItZxRNvx2es8Q== X-Received: by 2002:adf:d1c2:: with SMTP id b2mr6047282wrd.411.1643010047896; Sun, 23 Jan 2022 23:40:47 -0800 (PST) Received: from abel.fritz.box (p57b0bff8.dip0.t-ipconnect.de. [87.176.191.248]) by smtp.gmail.com with ESMTPSA id u15sm516370wrs.17.2022.01.23.23.40.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 23:40:47 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, sumit.semwal@linaro.org, gustavo@padovan.org, daniel.vetter@ffwll.ch, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH 1/9] dma-buf: consolidate dma_fence subclass checking Date: Mon, 24 Jan 2022 08:40:38 +0100 Message-Id: <20220124074046.4865-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 X-LSpam-Score: -7.5 (-------) X-LSpam-Report: No, score=-7.5 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,FREEMAIL_FORGED_FROMDOMAIN=0.001,FREEMAIL_FROM=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_HI=-5 autolearn=ham autolearn_force=no Consolidate the wrapper functions to check for dma_fence subclasses in the dma_fence header. This makes it easier to document and also check the different requirements for fence containers in the subclasses. Signed-off-by: Christian König --- include/linux/dma-fence-array.h | 15 +------------ include/linux/dma-fence-chain.h | 3 +-- include/linux/dma-fence.h | 38 +++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/include/linux/dma-fence-array.h b/include/linux/dma-fence-array.h index 303dd712220f..fec374f69e12 100644 --- a/include/linux/dma-fence-array.h +++ b/include/linux/dma-fence-array.h @@ -45,19 +45,6 @@ struct dma_fence_array { struct irq_work work; }; -extern const struct dma_fence_ops dma_fence_array_ops; - -/** - * dma_fence_is_array - check if a fence is from the array subsclass - * @fence: fence to test - * - * Return true if it is a dma_fence_array and false otherwise. - */ -static inline bool dma_fence_is_array(struct dma_fence *fence) -{ - return fence->ops == &dma_fence_array_ops; -} - /** * to_dma_fence_array - cast a fence to a dma_fence_array * @fence: fence to cast to a dma_fence_array @@ -68,7 +55,7 @@ static inline bool dma_fence_is_array(struct dma_fence *fence) static inline struct dma_fence_array * to_dma_fence_array(struct dma_fence *fence) { - if (fence->ops != &dma_fence_array_ops) + if (!fence || !dma_fence_is_array(fence)) return NULL; return container_of(fence, struct dma_fence_array, base); diff --git a/include/linux/dma-fence-chain.h b/include/linux/dma-fence-chain.h index 54fe3443fd2c..ee906b659694 100644 --- a/include/linux/dma-fence-chain.h +++ b/include/linux/dma-fence-chain.h @@ -49,7 +49,6 @@ struct dma_fence_chain { spinlock_t lock; }; -extern const struct dma_fence_ops dma_fence_chain_ops; /** * to_dma_fence_chain - cast a fence to a dma_fence_chain @@ -61,7 +60,7 @@ extern const struct dma_fence_ops dma_fence_chain_ops; static inline struct dma_fence_chain * to_dma_fence_chain(struct dma_fence *fence) { - if (!fence || fence->ops != &dma_fence_chain_ops) + if (!fence || !dma_fence_is_chain(fence)) return NULL; return container_of(fence, struct dma_fence_chain, base); diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h index 1ea691753bd3..775cdc0b4f24 100644 --- a/include/linux/dma-fence.h +++ b/include/linux/dma-fence.h @@ -587,4 +587,42 @@ struct dma_fence *dma_fence_get_stub(void); struct dma_fence *dma_fence_allocate_private_stub(void); u64 dma_fence_context_alloc(unsigned num); +extern const struct dma_fence_ops dma_fence_array_ops; +extern const struct dma_fence_ops dma_fence_chain_ops; + +/** + * dma_fence_is_array - check if a fence is from the array subclass + * @fence: the fence to test + * + * Return true if it is a dma_fence_array and false otherwise. + */ +static inline bool dma_fence_is_array(struct dma_fence *fence) +{ + return fence->ops == &dma_fence_array_ops; +} + +/** + * dma_fence_is_chain - check if a fence is from the chain subclass + * @fence: the fence to test + * + * Return true if it is a dma_fence_chain and false otherwise. + */ +static inline bool dma_fence_is_chain(struct dma_fence *fence) +{ + return fence->ops == &dma_fence_chain_ops; +} + +/** + * dma_fence_is_container - check if a fence is a container for other fences + * @fence: the fence to test + * + * Return true if this fence is a container for other fences, false otherwise. + * This is important since we can't build up large fence structure or otherwise + * we run into recursion during operation on those fences. + */ +static inline bool dma_fence_is_container(struct dma_fence *fence) +{ + return dma_fence_is_array(fence) || dma_fence_is_chain(fence); +} + #endif /* __LINUX_DMA_FENCE_H */ From patchwork Mon Jan 24 07:40:39 2022 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: 80239 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1nBty8-005iT6-UK; Mon, 24 Jan 2022 07:40:53 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241853AbiAXHkv (ORCPT + 1 other); Mon, 24 Jan 2022 02:40:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241806AbiAXHku (ORCPT ); Mon, 24 Jan 2022 02:40:50 -0500 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 1A209C06173B for ; Sun, 23 Jan 2022 23:40:50 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id n12-20020a05600c3b8c00b0034eb13edb8eso2001531wms.0 for ; Sun, 23 Jan 2022 23:40:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=CoA+r1KF28F1CAMI7pwE9OjWnR4XEafI/kYvKFT/pwo=; b=JHN6/biYR6rsgSz3WyO//6PDm/q/8LQIvmA3YasHnIKZrFL3TjAcTmyMNuKT5Bi3/G 7954P/l9i9zNlzCuS2wFA9Dh2+v9wc8Lf6uHKRMuF+9tJEpWb26Bdo14y8e9A4PehBn7 WDJDCE5RvXOG+3OV4tlFEnGS7uFDdB68WtNYP4K6rDa/lS8RGlQ2OKmo9u5qMfY4kshp O3XPkzBTi5NXPmYW5gMRLVqAtc5sNbWAjJFq11XQURfuCZ3WvxoZ+OVlhtw086htTd+I MDyjnCvI+m7FyB0H0kudzDdLh+JMxhAypoklvualZoGpO1pJgIJXyB0S7jioNJhUZZtr eZbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CoA+r1KF28F1CAMI7pwE9OjWnR4XEafI/kYvKFT/pwo=; b=4hpQUWsl6EdsbXUYv0NB4mwTMwjS4wjkdFjmJFINKRBRRXs3xvAH7Jmw28hb+Cb++k JcAhcI7D/q5EBzW57IZ1FDHqcFJ2VlU8dkR1Cphf3Wz64l/LjzWy2y1Ax61GRZEiFf50 +9N13C6FNMg18FqGvDqll0XVgpYtceX3Yljclj4nBfYEjx+jAZk5XD8AgYbTNheLtOL7 mWuqQYZXJ3f4sRiIDXNRdvWGIvvIR+BkReKpupF3wPf1loPcKglBsiXaSZnR6dHxFRel YVS7B/J64fxNseSAdFVNspxpkjeW+vtDL86tAF9NrUq93gt/RjIHijl/V7kxO1Zkavsj mbhQ== X-Gm-Message-State: AOAM5337FFzd8OFm2ZOkO+ClzkJWmuQoMVDLE9D5ng41yT4+M2+Fz8I4 VIxDFpGc8hTYKvUwXPzBvfM= X-Google-Smtp-Source: ABdhPJzcv7lRZbMGhd+k7E1Cx+likm9kmGU8+1pG9V8vLBdZv+Wbt7kpy3IymkIZyESK+zh4ET2BFQ== X-Received: by 2002:a05:600c:1da2:: with SMTP id p34mr611776wms.97.1643010048736; Sun, 23 Jan 2022 23:40:48 -0800 (PST) Received: from abel.fritz.box (p57b0bff8.dip0.t-ipconnect.de. [87.176.191.248]) by smtp.gmail.com with ESMTPSA id u15sm516370wrs.17.2022.01.23.23.40.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 23:40:48 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, sumit.semwal@linaro.org, gustavo@padovan.org, daniel.vetter@ffwll.ch, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH 2/9] dma-buf: warn about dma_fence_array container rules v2 Date: Mon, 24 Jan 2022 08:40:39 +0100 Message-Id: <20220124074046.4865-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220124074046.4865-1-christian.koenig@amd.com> References: <20220124074046.4865-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -7.5 (-------) X-LSpam-Report: No, score=-7.5 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,FREEMAIL_FORGED_FROMDOMAIN=0.001,FREEMAIL_FROM=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_HI=-5 autolearn=ham autolearn_force=no It's not allowed to nest another dma_fence container into a dma_fence_array or otherwise we can run into recursion. Warn about that when we create a dma_fence_array. v2: fix comment style and typo in the warning pointed out by Thomas Signed-off-by: Christian König Reviewed-by: Daniel Vetter --- drivers/dma-buf/dma-fence-array.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c index 3e07f961e2f3..cb1bacb5a42b 100644 --- a/drivers/dma-buf/dma-fence-array.c +++ b/drivers/dma-buf/dma-fence-array.c @@ -176,6 +176,20 @@ struct dma_fence_array *dma_fence_array_create(int num_fences, array->base.error = PENDING_ERROR; + /* + * dma_fence_array objects should never contain any other fence + * containers or otherwise we run into recursion and potential kernel + * stack overflow on operations on the dma_fence_array. + * + * The correct way of handling this is to flatten out the array by the + * caller instead. + * + * Enforce this here by checking that we don't create a dma_fence_array + * with any container inside. + */ + while (num_fences--) + WARN_ON(dma_fence_is_container(fences[num_fences])); + return array; } EXPORT_SYMBOL(dma_fence_array_create); From patchwork Mon Jan 24 07:40:40 2022 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: 80240 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1nBty9-005iT6-U2; Mon, 24 Jan 2022 07:40:54 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241893AbiAXHkw (ORCPT + 1 other); Mon, 24 Jan 2022 02:40:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241886AbiAXHkv (ORCPT ); Mon, 24 Jan 2022 02:40:51 -0500 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 DBACFC06173D for ; Sun, 23 Jan 2022 23:40:50 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id i2so11829468wrb.12 for ; Sun, 23 Jan 2022 23:40:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=OIMpCxdpOEYcnoEMYTLid8nSDucpIJk7Qs0av1g9rGU=; b=Wv6vmwAFRm/BaVWQYECalHzGjxL6WBq8wgOBag2tP/iMbsAsL/4gZEIGOyVn1Rcjgr 6x4TmZKGuDV0H8OvJ0fVM+Upr/0BEJyhwPtsbccFwHUGSF01C68xUOWB0Ghjfnms0sR7 X4ubrYWqCJ0jbmuyo1UOrZVgkFqJYcWvo5BeFUuOn18kG8G6fxscUi9/bxgHz5+j/Uzl OHfeRSQXsIV+UyE1Y93OK6QqrqjhDlSgQ9oxap1nmW6kC6IVHu5K6uz7v5hytI6irg5c DJJeXty1NDcMubyBbcIjaoToervqB4E8hDqne+bJYNzatkMhaCowOCghSPkSQc9YTIlw mdMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OIMpCxdpOEYcnoEMYTLid8nSDucpIJk7Qs0av1g9rGU=; b=kNQatw0d50BRUSQ/DdIzVW6RRqHk/gd1esp6fsqsqpgsm1HUYmoGd/R921zd4aTZoO j0zoXoxZ3fL3QO3UuuaFLqIdOe5Vtb8W6W9U736yOT2jZB0TMebmG2hf2zSUNXAIQTdb ymeLz6WrLO34U2DAP4XnCnvKxTO76h3R3PALvEb+p76GdINCG4ZUOsZ2frntCM5GkYIw 9SQckfRxuwtYSsj0AJ2ugG4sbr2S3Q6uALu/a4KgyknRPBi2y5aUW4eRYbNmJ8HPc3xs p5RRN/9GSkKN1NF0oLCMf4mV7s8rxVwm5EE5CRsQvJMe3flda9UQmV5bNygGyChT1yWs gdJw== X-Gm-Message-State: AOAM532B10wolXSrcf1KcJw6+5lW9LDMu9zXopelx6Ag9E2ZXLFywV06 aKCzTXoxz1kPRFxNmtRShqU= X-Google-Smtp-Source: ABdhPJwicjL4DAH0Upf8PByvfLmXIDl5/1wL7YjXzl4vvkruVIvcrPQL5OoBv3lIQqy8sAq6rRBHwg== X-Received: by 2002:a5d:6e8b:: with SMTP id k11mr13035578wrz.102.1643010049568; Sun, 23 Jan 2022 23:40:49 -0800 (PST) Received: from abel.fritz.box (p57b0bff8.dip0.t-ipconnect.de. [87.176.191.248]) by smtp.gmail.com with ESMTPSA id u15sm516370wrs.17.2022.01.23.23.40.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 23:40:49 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, sumit.semwal@linaro.org, gustavo@padovan.org, daniel.vetter@ffwll.ch, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH 3/9] dma-buf: Warn about dma_fence_chain container rules v2 Date: Mon, 24 Jan 2022 08:40:40 +0100 Message-Id: <20220124074046.4865-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220124074046.4865-1-christian.koenig@amd.com> References: <20220124074046.4865-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -7.5 (-------) X-LSpam-Report: No, score=-7.5 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,FREEMAIL_FORGED_FROMDOMAIN=0.001,FREEMAIL_FROM=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_HI=-5 autolearn=ham autolearn_force=no Chaining of dma_fence_chain objects is only allowed through the prev fence and not through the contained fence. Warn about that when we create a dma_fence_chain. v2: fix comment style Signed-off-by: Christian König Reviewed-by: Daniel Vetter Reviewed-by: Thomas Hellström --- drivers/dma-buf/dma-fence-chain.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/dma-buf/dma-fence-chain.c b/drivers/dma-buf/dma-fence-chain.c index 1b4cb3e5cec9..084c6927b735 100644 --- a/drivers/dma-buf/dma-fence-chain.c +++ b/drivers/dma-buf/dma-fence-chain.c @@ -254,5 +254,14 @@ void dma_fence_chain_init(struct dma_fence_chain *chain, dma_fence_init(&chain->base, &dma_fence_chain_ops, &chain->lock, context, seqno); + + /* + * Chaining dma_fence_chain container together is only allowed through + * the prev fence and not through the contained fence. + * + * The correct way of handling this is to flatten out the fence + * structure into a dma_fence_array by the caller instead. + */ + WARN_ON(dma_fence_is_chain(fence)); } EXPORT_SYMBOL(dma_fence_chain_init); From patchwork Mon Jan 24 07:40:41 2022 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: 80241 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1nBtyA-005iT6-U7; Mon, 24 Jan 2022 07:40:55 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241878AbiAXHkw (ORCPT + 1 other); Mon, 24 Jan 2022 02:40:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241902AbiAXHkw (ORCPT ); Mon, 24 Jan 2022 02:40:52 -0500 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 B5DD1C06173B for ; Sun, 23 Jan 2022 23:40:51 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id ba4so11802666wrb.4 for ; Sun, 23 Jan 2022 23:40:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=NMvNPKP34hAKYGcpxJqq3LnQ/oLcKhJxLzf1TGkhp7o=; b=bAyiVbeL0O/tXrVEJoufHk2hMCElT7PNsdTJZ4q1rRynh+wz81LxDxU2r01Iym6VVt sVaIcM92UfKeJDnXO1Rf5z9TcBW/Vk/SwAaEpaYkTSaEuuaHCorczWFU5dpVe3QpJvHm 8zXVgegBY1i23LrTU+T4IeYqBE9fHWevOENAlblziqtjiZuR1bpy76Pc17hS0zZtwRLX AWzZKJgOMcDr5lf946FqoFkO8RrLddgwIys8pL6IrbBIZoxCcQ3fSJgYZZIONsCYPamM 2H9wdS06v75M6zo3keQG/CY/o3fMpE9zYPSubQjmQ9a0Mft+ASlJAz5l0KsEYKE/D5pS G/bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NMvNPKP34hAKYGcpxJqq3LnQ/oLcKhJxLzf1TGkhp7o=; b=GdlcrRtzHKaUqDTxdPAcDNIskVCPHSad5yIeVBig3W90xIAtWl+79okdCIXO8Fl0eR CCmKhTf7BVMa4N9Pw4HIZN6EBfMujl7OD7xEILNXv1JtEaJ5wHs/BYf8v6hTkEPIz9AF PCJsWWrl3m3awsyyU2eTbQ7/lZ04BLAR88Ugu2KeeSwgWx6NFZv0zgVfdCVfTumNwZ31 o8D4AT9hJLpM4Zu6MHRmB/dMHm5ibeJCKo4YGwPv7hCnbuh6Oi7OZOqZMtp9qEXwYAgN ymveg4SwCvzuX/v5JAOd83cbcir7HsrWQRXhWonFZVhsvxEg0nS4jkUu/J7koIAJtNpZ TcjQ== X-Gm-Message-State: AOAM5329LUVACBR0T+tIP4lrv9FcGtZdJ4ViOdKLJNSVhFAjodwqk0Dv BV2Kpt8bOsmzqBHa1aSsQsg= X-Google-Smtp-Source: ABdhPJy6f2RHhcqqgDM9WwFjE7EjUM8xU24oiTj68CEJVDxm+pU6cyKrOR36zVZu7Z9+3QZY9dF4Dg== X-Received: by 2002:a05:6000:18a1:: with SMTP id b1mr5366493wri.608.1643010050406; Sun, 23 Jan 2022 23:40:50 -0800 (PST) Received: from abel.fritz.box (p57b0bff8.dip0.t-ipconnect.de. [87.176.191.248]) by smtp.gmail.com with ESMTPSA id u15sm516370wrs.17.2022.01.23.23.40.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 23:40:50 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, sumit.semwal@linaro.org, gustavo@padovan.org, daniel.vetter@ffwll.ch, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH 4/9] dma-buf: warn about containers in dma_resv object Date: Mon, 24 Jan 2022 08:40:41 +0100 Message-Id: <20220124074046.4865-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220124074046.4865-1-christian.koenig@amd.com> References: <20220124074046.4865-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -7.5 (-------) X-LSpam-Report: No, score=-7.5 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,FREEMAIL_FORGED_FROMDOMAIN=0.001,FREEMAIL_FROM=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_HI=-5 autolearn=ham autolearn_force=no Drivers should not add containers as shared fences to the dma_resv object, instead each fence should be added individually. Signed-off-by: Christian König Reviewed-by: Daniel Vetter --- drivers/dma-buf/dma-resv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 6dd9a40b55d4..e8a0c1d51da2 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -256,6 +256,11 @@ void dma_resv_add_shared_fence(struct dma_resv *obj, struct dma_fence *fence) dma_resv_assert_held(obj); + /* Drivers should not add containers here, instead add each fence + * individually. + */ + WARN_ON(dma_fence_is_container(fence)); + fobj = dma_resv_shared_list(obj); count = fobj->shared_count; From patchwork Mon Jan 24 07:40:42 2022 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: 80242 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1nBtyB-005iT6-Su; Mon, 24 Jan 2022 07:40:56 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241886AbiAXHkx (ORCPT + 1 other); Mon, 24 Jan 2022 02:40:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235988AbiAXHkw (ORCPT ); Mon, 24 Jan 2022 02:40:52 -0500 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 88009C06173B for ; Sun, 23 Jan 2022 23:40:52 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id c2so22290822wml.1 for ; Sun, 23 Jan 2022 23:40:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=dl1dUYcNTDp2GOm0X9C0j70YZVM11w1ghZ3iu9NNtok=; b=H++pXdsUq2N0QRGJum8gg0Y1t9HjPcUAL8BjYobm6XCmowSylvoYqIxWSzNkep2I+X 572mKZoDd305g8tzdxrgrSTFlgkzoa+UB0AJaDI/K8WLOBKR4BBLkp2GtPF+GRJh16DW rRsyC5TCPibtzuM3he477LqBlMGRX4x92gtuYHtV6SpbHebvHI3zeA+oL2unBZu0wJZq /FB0BlH58IqSHO3V6435DEVHCSw7428W8Thm1VAoVRUY4E18jnrp9iEY9wlUlhugZvDY E/9HfKlSd2GXzQyZ4s8yyczU2nribKFSSvlfxccEgyWqrcr2pkUjoqEkgNiix23DPWsc a8Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dl1dUYcNTDp2GOm0X9C0j70YZVM11w1ghZ3iu9NNtok=; b=bsgi5wR4tNMSPVVjTuN1vM475bnY96Cl7lUqSf49C5qMBCqqI3z2SMJrFEPBeMbxr+ UFodLT9oBxde7OoNoQ4rT1pj8qq1ll2UHi0qP4tKvsQxLkLPhK9cp11sw9QCsCHoysVt muLp0009vqrWwNIELnrgOyblGp8hcz4ITB1Hr8JexCJmvzKc7wThy+CMCzoLbUjbTSiV GW5p+/3R5aMigTtLCHy149D5As8s50SQE2/ycX6R6ieobnBb8OZJFvRpjXgn3FnpHm/k XXKky0Hs13sUmxXYr5rIMasdATNwkjfbRHs/CcpeOHS3F4Quz3Tv4zDr1jR/QZv5spl0 Wl1g== X-Gm-Message-State: AOAM533PV3nwWKPmbVPDzJBGGDslKSReOluKTcTqN+oafrOR4ZJb3GlY TEqs3WL3LVn9G5LQs6PA89E= X-Google-Smtp-Source: ABdhPJy/Wnk6fYE1mYGlQVbnJ0NItvaQnYWhtE9i8fY/XOTtQFLywCS0XkfQzd06LyyQybG+YfTVNA== X-Received: by 2002:a05:600c:2042:: with SMTP id p2mr592461wmg.167.1643010051206; Sun, 23 Jan 2022 23:40:51 -0800 (PST) Received: from abel.fritz.box (p57b0bff8.dip0.t-ipconnect.de. [87.176.191.248]) by smtp.gmail.com with ESMTPSA id u15sm516370wrs.17.2022.01.23.23.40.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 23:40:50 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, sumit.semwal@linaro.org, gustavo@padovan.org, daniel.vetter@ffwll.ch, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH 5/9] dma-buf: Add dma_fence_array_for_each (v2) Date: Mon, 24 Jan 2022 08:40:42 +0100 Message-Id: <20220124074046.4865-5-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220124074046.4865-1-christian.koenig@amd.com> References: <20220124074046.4865-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -7.5 (-------) X-LSpam-Report: No, score=-7.5 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,FREEMAIL_FORGED_FROMDOMAIN=0.001,FREEMAIL_FROM=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_HI=-5 autolearn=ham autolearn_force=no From: Christian König Add a helper to iterate over all fences in a dma_fence_array object. v2 (Jason Ekstrand) - Return NULL from dma_fence_array_first if head == NULL. This matches the iterator behavior of dma_fence_chain_for_each in that it iterates zero times if head == NULL. - Return NULL from dma_fence_array_next if index > array->num_fences. Signed-off-by: Jason Ekstrand Reviewed-by: Jason Ekstrand Reviewed-by: Christian König Cc: Daniel Vetter Cc: Maarten Lankhorst --- drivers/dma-buf/dma-fence-array.c | 27 +++++++++++++++++++++++++++ include/linux/dma-fence-array.h | 17 +++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c index cb1bacb5a42b..52b85d292383 100644 --- a/drivers/dma-buf/dma-fence-array.c +++ b/drivers/dma-buf/dma-fence-array.c @@ -219,3 +219,30 @@ bool dma_fence_match_context(struct dma_fence *fence, u64 context) return true; } EXPORT_SYMBOL(dma_fence_match_context); + +struct dma_fence *dma_fence_array_first(struct dma_fence *head) +{ + struct dma_fence_array *array; + + if (!head) + return NULL; + + array = to_dma_fence_array(head); + if (!array) + return head; + + return array->fences[0]; +} +EXPORT_SYMBOL(dma_fence_array_first); + +struct dma_fence *dma_fence_array_next(struct dma_fence *head, + unsigned int index) +{ + struct dma_fence_array *array = to_dma_fence_array(head); + + if (!array || index >= array->num_fences) + return NULL; + + return array->fences[index]; +} +EXPORT_SYMBOL(dma_fence_array_next); diff --git a/include/linux/dma-fence-array.h b/include/linux/dma-fence-array.h index fec374f69e12..e34dcb0bb462 100644 --- a/include/linux/dma-fence-array.h +++ b/include/linux/dma-fence-array.h @@ -61,6 +61,19 @@ to_dma_fence_array(struct dma_fence *fence) return container_of(fence, struct dma_fence_array, base); } +/** + * dma_fence_array_for_each - iterate over all fences in array + * @fence: current fence + * @index: index into the array + * @head: potential dma_fence_array object + * + * Test if @array is a dma_fence_array object and if yes iterate over all fences + * in the array. If not just iterate over the fence in @array itself. + */ +#define dma_fence_array_for_each(fence, index, head) \ + for (index = 0, fence = dma_fence_array_first(head); fence; \ + ++(index), fence = dma_fence_array_next(head, index)) + struct dma_fence_array *dma_fence_array_create(int num_fences, struct dma_fence **fences, u64 context, unsigned seqno, @@ -68,4 +81,8 @@ struct dma_fence_array *dma_fence_array_create(int num_fences, bool dma_fence_match_context(struct dma_fence *fence, u64 context); +struct dma_fence *dma_fence_array_first(struct dma_fence *head); +struct dma_fence *dma_fence_array_next(struct dma_fence *head, + unsigned int index); + #endif /* __LINUX_DMA_FENCE_ARRAY_H */ From patchwork Mon Jan 24 07:40:43 2022 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: 80243 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1nBtyD-005iT6-69; Mon, 24 Jan 2022 07:40:57 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241902AbiAXHky (ORCPT + 1 other); Mon, 24 Jan 2022 02:40:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235988AbiAXHkx (ORCPT ); Mon, 24 Jan 2022 02:40:53 -0500 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 5DD73C06173B for ; Sun, 23 Jan 2022 23:40:53 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id r22so4193736wra.8 for ; Sun, 23 Jan 2022 23:40:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Rx5rKIs1h4pkPPx07vOixo6aKMAm9lXxnCcc7E9V7dU=; b=dH5sM5ldW3QMoO003IFYaAB598warM4tFOgMpkiy7HjUkEiLWT661aYTZvtyjFvlIC p2tArPmx5Ku4JKfUH15rUgXfqFJJdviqXadBtxmEZXL5WABRHkGmZpWA/sPYG8USXPDK ahuVcKfjH122XozbZodfY9LBAEVak5BlTNvw7aWIG4WRH5WPx0AI6PqeC41KuBChN1Cy tMOs/9Vx1vVBR/xXanhtVaSWvHaBH8s/qbFFC8FhnzfjuG36j0Vw0GFYLt2KqsT1Xf9u emO9f+DHsWSaCK7cvOc77OVcweaX+2VUaAymv5LDat8bf9t/6v6jEIHneYIs01tpGDn+ nbzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rx5rKIs1h4pkPPx07vOixo6aKMAm9lXxnCcc7E9V7dU=; b=nfQO/yhWBXkEQNEisSY0doxfxgK168/QBmvc0awpxm9VTRoJjDUnbRPUEkd5SECGvm cqtIQzCAegPO6UoDvLD2xw0ywYqWGEmCw8pbrdyV3cHKsgE4Ya7PgpAuSbYoIaxq49+i sH5qLajAjLzxmV+pGgW/96jVVy7dcqfnfc0vqwiCfgwltsWo0uf6yoNPyijlO1RK8Fql sZxk3r/Use3QZFe5WuiG5pq2ABIFW4IMfDc59l/b5aeV8M/sgXc2+xVZ558fchcxkKgY 0rciNdw882vBW/wgIlgsY/RRPu6j6CdD6SnT3K3PzgwY9oARopz5LUnHA2ioId1e7HkX 6aow== X-Gm-Message-State: AOAM531M5LrusrpW3WdbufgTmk7ENS/OBsTjxPdBL7bQw/PaWb5LQcUg 0uINfVdX7sBZiZKFlVeq4/0= X-Google-Smtp-Source: ABdhPJzUXuu+U7lDxd6QtCBjJhL/Nn1issoTdOPgnREM6UtyKIt6NhHGaoe1OvEjjHrM5pUcUipgkA== X-Received: by 2002:adf:f5c2:: with SMTP id k2mr13012175wrp.669.1643010051987; Sun, 23 Jan 2022 23:40:51 -0800 (PST) Received: from abel.fritz.box (p57b0bff8.dip0.t-ipconnect.de. [87.176.191.248]) by smtp.gmail.com with ESMTPSA id u15sm516370wrs.17.2022.01.23.23.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 23:40:51 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, sumit.semwal@linaro.org, gustavo@padovan.org, daniel.vetter@ffwll.ch, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH 6/9] dma-buf: add dma_fence_chain_contained helper Date: Mon, 24 Jan 2022 08:40:43 +0100 Message-Id: <20220124074046.4865-6-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220124074046.4865-1-christian.koenig@amd.com> References: <20220124074046.4865-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -7.5 (-------) X-LSpam-Report: No, score=-7.5 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,FREEMAIL_FORGED_FROMDOMAIN=0.001,FREEMAIL_FROM=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_HI=-5 autolearn=ham autolearn_force=no It's a reoccurring pattern that we need to extract the fence from a dma_fence_chain object. Add a helper for this. Signed-off-by: Christian König --- drivers/dma-buf/dma-fence-chain.c | 6 ++---- include/linux/dma-fence-chain.h | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/dma-buf/dma-fence-chain.c b/drivers/dma-buf/dma-fence-chain.c index 084c6927b735..06f8ef97c6e8 100644 --- a/drivers/dma-buf/dma-fence-chain.c +++ b/drivers/dma-buf/dma-fence-chain.c @@ -148,8 +148,7 @@ static bool dma_fence_chain_enable_signaling(struct dma_fence *fence) dma_fence_get(&head->base); dma_fence_chain_for_each(fence, &head->base) { - struct dma_fence_chain *chain = to_dma_fence_chain(fence); - struct dma_fence *f = chain ? chain->fence : fence; + struct dma_fence *f = dma_fence_chain_contained(fence); dma_fence_get(f); if (!dma_fence_add_callback(f, &head->cb, dma_fence_chain_cb)) { @@ -165,8 +164,7 @@ static bool dma_fence_chain_enable_signaling(struct dma_fence *fence) static bool dma_fence_chain_signaled(struct dma_fence *fence) { dma_fence_chain_for_each(fence, fence) { - struct dma_fence_chain *chain = to_dma_fence_chain(fence); - struct dma_fence *f = chain ? chain->fence : fence; + struct dma_fence *f = dma_fence_chain_contained(fence); if (!dma_fence_is_signaled(f)) { dma_fence_put(fence); diff --git a/include/linux/dma-fence-chain.h b/include/linux/dma-fence-chain.h index ee906b659694..10d51bcdf7b7 100644 --- a/include/linux/dma-fence-chain.h +++ b/include/linux/dma-fence-chain.h @@ -66,6 +66,21 @@ to_dma_fence_chain(struct dma_fence *fence) return container_of(fence, struct dma_fence_chain, base); } +/** + * dma_fence_chain_contained - return the contained fence + * @fence: the fence to test + * + * If the fence is a dma_fence_chain the function returns the fence contained + * inside the chain object, otherwise it returns the fence itself. + */ +static inline struct dma_fence * +dma_fence_chain_contained(struct dma_fence *fence) +{ + struct dma_fence_chain *chain = to_dma_fence_chain(fence); + + return chain ? chain->fence : fence; +} + /** * dma_fence_chain_alloc * From patchwork Mon Jan 24 07:40:44 2022 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: 80244 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1nBtyE-005iT6-62; Mon, 24 Jan 2022 07:40:58 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241912AbiAXHk5 (ORCPT + 1 other); Mon, 24 Jan 2022 02:40:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235988AbiAXHky (ORCPT ); Mon, 24 Jan 2022 02:40:54 -0500 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 60F73C06173B for ; Sun, 23 Jan 2022 23:40:54 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id s18so11831334wrv.7 for ; Sun, 23 Jan 2022 23:40:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=32x746+aqRVJfpOzq5mPUyMArnAKR0oshZjP3RNr6L8=; b=mG9CH90QC3I0Kyzw5y97iSNP9PKE/WVtuooRunf7nd6IStTMUWHcpXD6CBgFSAzYcc 4nj0LnYyS4DS6WNAo7pgQp0P5OrOeTPnFgfGBFyIUgGqW/n9Nml/4rP6hhxrvPVIOWzT 9kCfjaCTyxQPQrTBwvJzzfSvZvbS4cLWCtyfIqFA8jYs/coBp6zCUlsv5gEuhNMgZM85 yctcg1vjOhrNtMASAKrp/iVmKCwmE4RYU8CYLR6OmR9JLXG7+qd4pMVIyf82yn0OjWPg gcdEJntMlPDJLPBBIQ648UZr5CVOorNM/aGKcXOHOdRTKHhAHt+CBeGRGmFA3w/T88C7 aJsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=32x746+aqRVJfpOzq5mPUyMArnAKR0oshZjP3RNr6L8=; b=NscfuOgXV1Y4QUufPT3IThUZCos489XZkq+gN6+b43tkVq2qLAEyCbMVISZc07yUBR VtMSFCnFQkEACg6kghGlj6Ixk/rkQJ5aecUmqsoGTsI0X+36idEdEhB+Dj72LtwNfb8V /m7Kv4wyfBYRDQTOhlyAU47hlTiylYVsEoLLTffuMLGEkOsAOjHjuML8VAUAo9/mW+Vh +MRJCpMiOHqrrXQhpSycsd7+cMVuDmaAp05BXLkCxeoAKJMhwHSkJBiUQ5gkFN+ZwkeF 8HnKsFzJXVzz/HTd9enjZJNzqYiL7MmWy4vkLaj2kyAWJG9hEtbybKVuHPCnO6AXu9Hq 0k1w== X-Gm-Message-State: AOAM5305/0I2MIydzKaKcQbqS5XlR8Cptsq/vnF313uufu9tzj4Hvr9G 3bo8o367ku5KBbKji/Fn5rI= X-Google-Smtp-Source: ABdhPJwMln34ByUlknX94Kfn4e2Z9+KJmZUiiAPAAQbyVgCnwUNiQ9kwRWOqrhxswOPyncTsQLoDAw== X-Received: by 2002:a5d:6947:: with SMTP id r7mr13378665wrw.510.1643010052928; Sun, 23 Jan 2022 23:40:52 -0800 (PST) Received: from abel.fritz.box (p57b0bff8.dip0.t-ipconnect.de. [87.176.191.248]) by smtp.gmail.com with ESMTPSA id u15sm516370wrs.17.2022.01.23.23.40.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 23:40:52 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, sumit.semwal@linaro.org, gustavo@padovan.org, daniel.vetter@ffwll.ch, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH 7/9] drm/amdgpu: use dma_fence_chain_contained Date: Mon, 24 Jan 2022 08:40:44 +0100 Message-Id: <20220124074046.4865-7-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220124074046.4865-1-christian.koenig@amd.com> References: <20220124074046.4865-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -7.5 (-------) X-LSpam-Report: No, score=-7.5 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,FREEMAIL_FORGED_FROMDOMAIN=0.001,FREEMAIL_FROM=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_HI=-5 autolearn=ham autolearn_force=no Instead of manually extracting the fence. Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c index f7d8487799b2..40e06745fae9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c @@ -261,10 +261,9 @@ int amdgpu_sync_resv(struct amdgpu_device *adev, struct amdgpu_sync *sync, 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); + struct dma_fence *tmp = dma_fence_chain_contained(f); - if (amdgpu_sync_test_fence(adev, mode, owner, chain ? - chain->fence : f)) { + if (amdgpu_sync_test_fence(adev, mode, owner, tmp)) { r = amdgpu_sync_fence(sync, f); dma_fence_put(f); if (r) From patchwork Mon Jan 24 07:40:45 2022 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: 80245 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1nBtyF-005iT6-8O; Mon, 24 Jan 2022 07:40:59 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241929AbiAXHk5 (ORCPT + 1 other); Mon, 24 Jan 2022 02:40:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241919AbiAXHk4 (ORCPT ); Mon, 24 Jan 2022 02:40:56 -0500 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 3102EC06173D for ; Sun, 23 Jan 2022 23:40:55 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id u15so11817103wrt.3 for ; Sun, 23 Jan 2022 23:40:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=MJIzfIJj7sWuWjvaqjpDxEclvLa+rSTBKh+L03ndIwY=; b=eid9bSkdSE1qqzBPTOdeU1UdZDPaPcucxR4THSbHCD+g3xfLv/639REo5ghYJODMPr c/MYEqc5ny8dt0D3VaZ+RGT6aN8HQMrvl29cmFcXjCGQhDuMNe73/UF6EX4jPHK1eixQ d+HkTqe0AeWgxFkcM4fegKg/FwYMg9FqZDn18ZTQCuIzYhGbxCUedbtBREzDVckgX9Bv QtRfOfyYmCQ1AJW7zj+bdx6y/cwFDn1uFnxsZfL/gCdrsPAyBL5oNVkIWlUdhLuru8V0 c2yHKKJJxPn4gzP5MKZZtGSHpkdp1ijiZ1HRuVGOdhrpmLZqLisvZSF6XGMxUb2Kpywa 3BJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MJIzfIJj7sWuWjvaqjpDxEclvLa+rSTBKh+L03ndIwY=; b=Q6dg4IbOfccjMRJJw2EuebNimBuVSfnwNNTc4jZAy9iQblItaTgB1joaRSJ8HSHmUI +j3KMrXGwT4CQgymdM2L4QZz0fqgT+4vWOErMu4xXx/6vnBZn8USgwDHGnANy710C7wV 9tbeRxaf41H9ArKGo9+1tn5o3VMxcU8hfcSTDBwKOUXfUQA9n888aBmNUk2xTIlB4wtA 8zvzNScbAgzL2TsDlu9ZXZCOz2yN/qxa5H/VTwrW8Nqm1yWeCXjPiXkWrI/F940HT8VM /cl3GG2xNRXdZgGJPqkQGuzsWDTYwRaioEu3lhDb106B2xzdnZo5R0QTeDKijHGsG9yo AAsQ== X-Gm-Message-State: AOAM532i8ye6se3S91qm2RU5uz7xC6yoNw6r0MH/T+0T9u6N++U6xINi gMlrP31xn7yMHZfCf7ca7oc= X-Google-Smtp-Source: ABdhPJxk2ee9UaF0qaj+FHOxXtvlSUM0bjtSIG1Eu4Cqy6hogLlbR6wvWNtzpEvwwO1JvG0fxVEP1A== X-Received: by 2002:a05:6000:1d86:: with SMTP id bk6mr13362585wrb.367.1643010053841; Sun, 23 Jan 2022 23:40:53 -0800 (PST) Received: from abel.fritz.box (p57b0bff8.dip0.t-ipconnect.de. [87.176.191.248]) by smtp.gmail.com with ESMTPSA id u15sm516370wrs.17.2022.01.23.23.40.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 23:40:53 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, sumit.semwal@linaro.org, gustavo@padovan.org, daniel.vetter@ffwll.ch, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH 8/9] drm/i915: use dma_fence extractor functions Date: Mon, 24 Jan 2022 08:40:45 +0100 Message-Id: <20220124074046.4865-8-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220124074046.4865-1-christian.koenig@amd.com> References: <20220124074046.4865-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -7.5 (-------) X-LSpam-Report: No, score=-7.5 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,FREEMAIL_FORGED_FROMDOMAIN=0.001,FREEMAIL_FROM=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_HI=-5 autolearn=ham autolearn_force=no Instead of manually messing with the data structures use the iterators and extraction helpers provided by the framework. This whole handling should essentially go away when boost handling is implemented in the core dma-buf framework. Signed-off-by: Christian König --- drivers/gpu/drm/i915/gem/i915_gem_busy.c | 40 ++++++-------------- drivers/gpu/drm/i915/gem/i915_gem_wait.c | 31 ++++------------ drivers/gpu/drm/i915/i915_request.c | 47 +++++++----------------- 3 files changed, 33 insertions(+), 85 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_busy.c b/drivers/gpu/drm/i915/gem/i915_gem_busy.c index 470fdfd61a0f..4ea7a5b26405 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_busy.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_busy.c @@ -41,6 +41,8 @@ static __always_inline unsigned int __busy_set_if_active(struct dma_fence *fence, u32 (*flag)(u16 id)) { const struct i915_request *rq; + struct dma_fence *current_fence; + unsigned int i; /* * We have to check the current hw status of the fence as the uABI @@ -58,40 +60,22 @@ __busy_set_if_active(struct dma_fence *fence, u32 (*flag)(u16 id)) * * 2. A single i915 request. */ - if (dma_fence_is_array(fence)) { - struct dma_fence_array *array = to_dma_fence_array(fence); - struct dma_fence **child = array->fences; - unsigned int nchild = array->num_fences; - - do { - struct dma_fence *current_fence = *child++; - - /* Not an i915 fence, can't be busy per above */ - if (!dma_fence_is_i915(current_fence) || - !test_bit(I915_FENCE_FLAG_COMPOSITE, - ¤t_fence->flags)) { - return 0; - } - - rq = to_request(current_fence); - if (!i915_request_completed(rq)) - return flag(rq->engine->uabi_class); - } while (--nchild); - - /* All requests in array complete, not busy */ - return 0; - } else { - if (!dma_fence_is_i915(fence)) - return 0; + dma_fence_array_for_each(current_fence, i, fence) { - rq = to_request(fence); - if (i915_request_completed(rq)) + /* Not an i915 fence, can't be busy per above */ + if (!dma_fence_is_i915(current_fence) || + !test_bit(I915_FENCE_FLAG_COMPOSITE, ¤t_fence->flags)) return 0; + rq = to_request(current_fence); /* Beware type-expansion follies! */ BUILD_BUG_ON(!typecheck(u16, rq->engine->uabi_class)); - return flag(rq->engine->uabi_class); + if (!i915_request_completed(rq)) + return flag(rq->engine->uabi_class); } + + /* All requests in array complete, not busy */ + return 0; } static __always_inline unsigned int diff --git a/drivers/gpu/drm/i915/gem/i915_gem_wait.c b/drivers/gpu/drm/i915/gem/i915_gem_wait.c index dab3d30c09a0..13f37b6aedf7 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_wait.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_wait.c @@ -72,11 +72,6 @@ static void fence_set_priority(struct dma_fence *fence, rcu_read_unlock(); } -static inline bool __dma_fence_is_chain(const struct dma_fence *fence) -{ - return fence->ops == &dma_fence_chain_ops; -} - void i915_gem_fence_wait_priority(struct dma_fence *fence, const struct i915_sched_attr *attr) { @@ -85,25 +80,15 @@ void i915_gem_fence_wait_priority(struct dma_fence *fence, local_bh_disable(); - /* Recurse once into a fence-array */ - if (dma_fence_is_array(fence)) { - struct dma_fence_array *array = to_dma_fence_array(fence); - int i; + /* The chain is ordered; if we boost the last, we boost all */ + dma_fence_chain_for_each(fence, fence) { + struct dma_fence *array, *element; + unsigned int i; - for (i = 0; i < array->num_fences; i++) - fence_set_priority(array->fences[i], attr); - } else if (__dma_fence_is_chain(fence)) { - struct dma_fence *iter; - - /* The chain is ordered; if we boost the last, we boost all */ - dma_fence_chain_for_each(iter, fence) { - fence_set_priority(to_dma_fence_chain(iter)->fence, - attr); - break; - } - dma_fence_put(iter); - } else { - fence_set_priority(fence, attr); + /* Recurse once into a fence-array */ + array = dma_fence_chain_contained(fence); + dma_fence_array_for_each(element, i, array) + fence_set_priority(element, attr); } local_bh_enable(); /* kick the tasklets if queues were reprioritised */ diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c index ad175d662b4e..2d8add5b5da9 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -1345,18 +1345,15 @@ i915_request_await_external(struct i915_request *rq, struct dma_fence *fence) struct dma_fence *iter; int err = 0; - if (!to_dma_fence_chain(fence)) - return __i915_request_await_external(rq, fence); - dma_fence_chain_for_each(iter, fence) { - struct dma_fence_chain *chain = to_dma_fence_chain(iter); + struct dma_fence *tmp = dma_fence_chain_contained(iter); - if (!dma_fence_is_i915(chain->fence)) { + if (!dma_fence_is_i915(tmp)) { err = __i915_request_await_external(rq, iter); break; } - err = i915_request_await_dma_fence(rq, chain->fence); + err = i915_request_await_dma_fence(rq, tmp); if (err < 0) break; } @@ -1386,24 +1383,14 @@ static bool is_same_parallel_context(struct i915_request *to, int i915_request_await_execution(struct i915_request *rq, - struct dma_fence *fence) + struct dma_fence *array) { - struct dma_fence **child = &fence; - unsigned int nchild = 1; + struct dma_fence *fence; + unsigned int i; int ret; - if (dma_fence_is_array(fence)) { - struct dma_fence_array *array = to_dma_fence_array(fence); - - /* XXX Error for signal-on-any fence arrays */ + dma_fence_array_for_each(fence, i, array) { - child = array->fences; - nchild = array->num_fences; - GEM_BUG_ON(!nchild); - } - - do { - fence = *child++; if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) continue; @@ -1425,7 +1412,7 @@ i915_request_await_execution(struct i915_request *rq, } if (ret < 0) return ret; - } while (--nchild); + } return 0; } @@ -1482,10 +1469,10 @@ i915_request_await_request(struct i915_request *to, struct i915_request *from) } int -i915_request_await_dma_fence(struct i915_request *rq, struct dma_fence *fence) +i915_request_await_dma_fence(struct i915_request *rq, struct dma_fence *array) { - struct dma_fence **child = &fence; - unsigned int nchild = 1; + struct dma_fence *fence; + unsigned int i; int ret; /* @@ -1496,16 +1483,8 @@ i915_request_await_dma_fence(struct i915_request *rq, struct dma_fence *fence) * amdgpu and we should not see any incoming fence-array from * sync-file being in signal-on-any mode. */ - if (dma_fence_is_array(fence)) { - struct dma_fence_array *array = to_dma_fence_array(fence); - - child = array->fences; - nchild = array->num_fences; - GEM_BUG_ON(!nchild); - } + dma_fence_array_for_each(fence, i, array) { - do { - fence = *child++; if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) continue; @@ -1537,7 +1516,7 @@ i915_request_await_dma_fence(struct i915_request *rq, struct dma_fence *fence) if (fence->context) intel_timeline_sync_set(i915_request_timeline(rq), fence); - } while (--nchild); + } return 0; } From patchwork Mon Jan 24 07:40:46 2022 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: 80246 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1nBtyG-005iT6-Ea; Mon, 24 Jan 2022 07:41:00 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241923AbiAXHk6 (ORCPT + 1 other); Mon, 24 Jan 2022 02:40:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241892AbiAXHk4 (ORCPT ); Mon, 24 Jan 2022 02:40:56 -0500 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 F2529C061401 for ; Sun, 23 Jan 2022 23:40:55 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id v123so22289062wme.2 for ; Sun, 23 Jan 2022 23:40:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZOOWkC73PSVhRT0FPLika7h1bqOJ9nqV8+v2bYOzvlk=; b=TnBh+fIYWftha2w3/naklVERd4+PeVS6nK+c/kdOAJnA4MgoECHm/VhS7+dPvxxPJ/ xa4o/3zukPV2ZuRciIjCrLeRjpFq1oWSPIfIoNSuC8q0x8S89LFrva0n24JLVNC94c63 i5tl/FGmYut9jTBwlUY8IeIlrBhTBc94TNdFrWXcOpVhCYMuxggdQqdmEzHBMMVMotIN u6SOjTEzTrrrt6xLtfShEIK4nW2nlCCiCVY3AiqioxwBK8kiKfmlv59XjIpmgAP439pU YMoQDe8OzFWHXQhUsGzt9qZcb4LMO5J32SCWQ+dLMxURUr9/YZfU3/0rSMmnk2RYGyjB OajQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZOOWkC73PSVhRT0FPLika7h1bqOJ9nqV8+v2bYOzvlk=; b=RUMwcKZXlHZ657bnM2Ux19+yg9w9GvuTunYGTNjTCRGKP8THMZNi1FF6qCdg95hPiW KpzzdtecyVSUMQmQz8psv/HMUIer/G3jv0d7qIp+6D7slEyoOfICS+2Le9P4sxN32Csl UWbXHG71rrzTXR3rs/6mCT309Nmot2d87QLQZ6LcNrlXIM+5ueBh0NE6Wdb/saVrtu6c AAF3IWm+/uMCzczCq/k0f7LO6aPIiVURxGLY1/vgT63Eg8kC6RUnE3tY3FLxPdCHZc+B EnTLzLY60eHsdZwmti7st9rEo05ciGs5Sr8u4tb5ravqXxCLHjyN2LdMmXQ8SjhYudAB YmRw== X-Gm-Message-State: AOAM533RqibyQtarT2As4oY0csCzRtyPOTv6BH17+km6VxVWSMu/OGrd OJoQnG6QHH/JDCfw1x6jr+Y= X-Google-Smtp-Source: ABdhPJxLKgXz1O9g3pJlePgtBPG5KpWlMynNepWzLwMTxgMkVdNR45ard+HWfBWT5Sxvx7h09sy7Nw== X-Received: by 2002:a05:600c:1d21:: with SMTP id l33mr637157wms.134.1643010054627; Sun, 23 Jan 2022 23:40:54 -0800 (PST) Received: from abel.fritz.box (p57b0bff8.dip0.t-ipconnect.de. [87.176.191.248]) by smtp.gmail.com with ESMTPSA id u15sm516370wrs.17.2022.01.23.23.40.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 23:40:54 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, sumit.semwal@linaro.org, gustavo@padovan.org, daniel.vetter@ffwll.ch, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH 9/9] drm/vmwgfx: remove vmw_wait_dma_fence Date: Mon, 24 Jan 2022 08:40:46 +0100 Message-Id: <20220124074046.4865-9-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220124074046.4865-1-christian.koenig@amd.com> References: <20220124074046.4865-1-christian.koenig@amd.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -7.5 (-------) X-LSpam-Report: No, score=-7.5 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,FREEMAIL_FORGED_FROMDOMAIN=0.001,FREEMAIL_FROM=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_HI=-5 autolearn=ham autolearn_force=no Decomposing fence containers don't seem to make any sense here. So just remove the function entirely and call dma_fence_wait() directly. Signed-off-by: Christian König Cc: VMware Graphics Cc: Zack Rusin --- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 46 ------------------------- drivers/gpu/drm/vmwgfx/vmwgfx_fence.h | 3 -- 3 files changed, 1 insertion(+), 50 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c index 44ca23b0ea4e..0ff28f0e3eb4 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c @@ -4500,7 +4500,7 @@ int vmw_execbuf_ioctl(struct drm_device *dev, void *data, goto mksstats_out; } - ret = vmw_wait_dma_fence(dev_priv->fman, in_fence); + ret = dma_fence_wait(in_fence, true); if (ret) goto out; } diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c index c60d395f9e2e..430f83a1847c 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c @@ -621,52 +621,6 @@ int vmw_user_fence_create(struct drm_file *file_priv, return ret; } - -/** - * vmw_wait_dma_fence - Wait for a dma fence - * - * @fman: pointer to a fence manager - * @fence: DMA fence to wait on - * - * This function handles the case when the fence is actually a fence - * array. If that's the case, it'll wait on each of the child fence - */ -int vmw_wait_dma_fence(struct vmw_fence_manager *fman, - struct dma_fence *fence) -{ - struct dma_fence_array *fence_array; - int ret = 0; - int i; - - - if (dma_fence_is_signaled(fence)) - return 0; - - if (!dma_fence_is_array(fence)) - return dma_fence_wait(fence, true); - - /* From i915: Note that if the fence-array was created in - * signal-on-any mode, we should *not* decompose it into its individual - * fences. However, we don't currently store which mode the fence-array - * is operating in. Fortunately, the only user of signal-on-any is - * private to amdgpu and we should not see any incoming fence-array - * from sync-file being in signal-on-any mode. - */ - - fence_array = to_dma_fence_array(fence); - for (i = 0; i < fence_array->num_fences; i++) { - struct dma_fence *child = fence_array->fences[i]; - - ret = dma_fence_wait(child, true); - - if (ret < 0) - return ret; - } - - return 0; -} - - /* * vmw_fence_fifo_down - signal all unsignaled fence objects. */ diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.h b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.h index 079ab4f3ba51..a7eee579c76a 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.h @@ -104,9 +104,6 @@ extern int vmw_user_fence_create(struct drm_file *file_priv, struct vmw_fence_obj **p_fence, uint32_t *p_handle); -extern int vmw_wait_dma_fence(struct vmw_fence_manager *fman, - struct dma_fence *fence); - extern void vmw_fence_fifo_up(struct vmw_fence_manager *fman); extern void vmw_fence_fifo_down(struct vmw_fence_manager *fman);