From patchwork Mon Jan 24 13:03:25 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: 12722169 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1808BC433FE for ; Mon, 24 Jan 2022 13:32:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 13AB010EC4D; Mon, 24 Jan 2022 13:32:39 +0000 (UTC) Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB41810EAF3; Mon, 24 Jan 2022 13:03:40 +0000 (UTC) Received: by mail-wr1-x429.google.com with SMTP id r22so5828896wra.8; Mon, 24 Jan 2022 05:03:40 -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=agpo0aI20Xjlb5LL2//pD0GbV+U1CeY3sh3BKQ8aATtQn2oAMdUv28BOM2KR++ik34 TgwfDY6ZmFaM7ug9NxfdaGD7jU05vaRSd5Z/clAXiwvoc43bEvnDnMqLh5QkBWo5ddn8 N5sF4M32CcNMNCeEN/sr1aoAVSvleVnG1gzo3NOz6GdXrFUkt0Q2a7uxB+eZZl9Fkn8t GN1XaZlV22cL3YD9ieVsNIeKvCQ2yH6rWdhga+zPkxippFHbfW2r2raezl259Voy0IbW exs4HwTTtZjFZeq/6z1ZG/a+bqLGq1gaLFH1nYIR/DmkkdPy7Uzm5UpLsOe4k9jPxVpH Ihfg== 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=1ycu+I6ZyTc4yCQooYNzryQNNE/aDEDgvecHqb8ylSoBNdgikn9U/u7/IyRxQCDI2n jsNuoM+xM4PFwELLelOFnijQVGCvKvPjKAiuTtnRRQTv1h61SGUX55t8Oi4ueBoIwNOt 4TSSa1nucn8b7GjIKSLJWyXpAazwK/ZIXFpjOYjWcAsOQKMahuOzjeQzi9h5OAVps5ds C1NRJz26bdnkVwvgxRqnUu2zhDb7ew5xemuE+sGbf35B3ALp9ppV3TdUViYoSSWcWJtK oAkkIBOF4oQTtJzMLfzaMxTo8eFzDCD2XZQ/KzRY3geeO3y/CpMzg9T15CdUUpM3Cb2m 9/Rw== X-Gm-Message-State: AOAM530Tcc5z71mV5Nslu0ka7kxjyiWHJ3Hhj7bbyG+xA+1SXA56attt Z/BhLGF9mNoBPg72M+iD00M= X-Google-Smtp-Source: ABdhPJyEtp/3osuhYgoMdqi3Ic7Zn2Xo+CaPn3nXwO9KCGcGih6tMBaEVYQDD3MIUtQRdLE2TfsAlg== X-Received: by 2002:adf:bb52:: with SMTP id x18mr14451422wrg.319.1643029419531; Mon, 24 Jan 2022 05:03:39 -0800 (PST) Received: from abel.fritz.box (p57b0bff8.dip0.t-ipconnect.de. [87.176.191.248]) by smtp.gmail.com with ESMTPSA id g4sm16543554wrd.12.2022.01.24.05.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 05:03:39 -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, zackr@vmware.com, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Date: Mon, 24 Jan 2022 14:03:25 +0100 Message-Id: <20220124130328.2376-9-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220124130328.2376-1-christian.koenig@amd.com> References: <20220124130328.2376-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 24 Jan 2022 13:32:09 +0000 Subject: [Intel-gfx] [PATCH 08/11] dma-buf: add dma_fence_chain_contained helper X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 Reviewed-by: Thomas Hellström --- 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 *