From patchwork Mon Jan 24 13:03:18 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: 12722167 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 9E387C433EF for ; Mon, 24 Jan 2022 13:32:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0E45910EB74; Mon, 24 Jan 2022 13:32:38 +0000 (UTC) Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by gabe.freedesktop.org (Postfix) with ESMTPS id 14C9810E5CC; Mon, 24 Jan 2022 13:03:34 +0000 (UTC) Received: by mail-wr1-x435.google.com with SMTP id l25so13440579wrb.13; Mon, 24 Jan 2022 05:03:34 -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=iln5gjTz62zqfYGlcLHz+tSndCkcbqCw4qI5vFOyxu0=; b=FtHZGsNcCMqHb5xGQRdkRgDH7RY0N6RZ6ivUXEw1s/MNexBi1c+CI3gtAY9Bv8brI1 H3O/N1KMMFQVs1/envxvkYCilUUZlxpsTpL0TvzG/BLSlZPAlhy/cPZmWDgMM3MmJgfx OmPlwkliusrYX8Qf7OBR50y+pbNSSQMD33G0N1MhfeW+FcSJ3eBWo1+2LiJLjYQ2QaUQ JRyKrN8GVPmuqoSdHyAgT0toI9zbc0Zkdsb8rjia36TU00FmIWxdJHylIZpA4GaD1oQy H4mYax9UFCpO9Q1zNA7fLevRivELP4sOTpGi0fpSqol/Mu6h4VoiFRdgpw7qFAFD3c1y gRhw== 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=iln5gjTz62zqfYGlcLHz+tSndCkcbqCw4qI5vFOyxu0=; b=eaSezEVWaCGRBQXCeV7V2Y+Sbea+QdQTyON2JkM53vJa6JtaU2h7aKhGi7h+mSSn75 Zxn0vH2Lvvsv5s97eDSWFfCXlHHF6kBBQ83mdMWRnL+Ctu+hJECMJKZgs/1iuJqdGxUj Wem2rgFWmJmgBjVAmKJ7jatS/SFMZXcTbZj6kc/CuxgZNFhwENmeBhlLrM5qmOSN57Li AmxFKFVqmVLdQfPOU0hyPdqBSSZJNHVf2ujrxcUYM/pT+WHllB85SLbbn6kredTpXnuI jE4oGkmHk4gBIM0Kvw0kjsWEkxPDS0SjSquOpC4K8ytwDfoa95ZQrOMOUyteCYi+0GDl SX+Q== X-Gm-Message-State: AOAM532q1Z+/qOZzheMAwH/nqdeH9lyhWtw6ftpYQqSxbtC2IVGMLXEl D09tvTaq6rTqs4+fx6YuUz4= X-Google-Smtp-Source: ABdhPJx73TPcrcp4J6XlhIWaLhB6ba/1n7iR3MXQPOOTPOBZn9KdwnCJrygAK0v9RCLneem3MgsKXQ== X-Received: by 2002:a5d:470b:: with SMTP id y11mr2845559wrq.122.1643029412475; Mon, 24 Jan 2022 05:03:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 05:03:32 -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:18 +0100 Message-Id: <20220124130328.2376-2-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 01/11] drm/radeon: use ttm_resource_manager_debug 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" Instead of calling the debug operation directly. Signed-off-by: Christian König Reviewed-by: Huang Rui --- drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 11b21d605584..0d1283cdc8fb 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -802,7 +802,7 @@ static int radeon_mm_vram_dump_table_show(struct seq_file *m, void *unused) TTM_PL_VRAM); struct drm_printer p = drm_seq_file_printer(m); - man->func->debug(man, &p); + ttm_resource_manager_debug(man, &p); return 0; } @@ -820,7 +820,7 @@ static int radeon_mm_gtt_dump_table_show(struct seq_file *m, void *unused) TTM_PL_TT); struct drm_printer p = drm_seq_file_printer(m); - man->func->debug(man, &p); + ttm_resource_manager_debug(man, &p); return 0; } From patchwork Mon Jan 24 13:03:19 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: 12722171 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 5E42CC433F5 for ; Mon, 24 Jan 2022 13:32:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7364610ECD4; Mon, 24 Jan 2022 13:32:47 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by gabe.freedesktop.org (Postfix) with ESMTPS id D6C1410E7DE; Mon, 24 Jan 2022 13:03:34 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id v13so13444323wrv.10; Mon, 24 Jan 2022 05:03:34 -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=r0nXcZqVGQ6Ta4bR5kQnQWxyJcyVFZB12g3PuPb0C9w=; b=nftL/d7gjyMEVVqsmMsHQvvAHZjqRoZ87F4j8U53Z9SJqdadiTw6wNOpuacpXloMF7 mM2hanVVVbDCcS/uSnaRZJC019c85wYViQ5ztmnWHsRnb2Lrm6MfWE3TyXhQJMrs9yQA ZKTahxOYqEsb0xrlWhkYMrAkBgsIxGXaoLjDjl799P/xlWA+ajY8cPeTdXXGEIOw5AaR X27W5xQhEWV9lGeJBNMQEcn8sa8MF/c5UhuSC1xUxvBHFj6loLfGu6TxVEM4M3NuhYHe 0koUaI1OB+aYjgH0cNn12jKctMsw42vABGE9K+KKvQzXfVpNjzvQvt6tAkoiyc3IOkOV kRRg== 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=r0nXcZqVGQ6Ta4bR5kQnQWxyJcyVFZB12g3PuPb0C9w=; b=C3pTJLnjZJVy/dFbO3t0MXHBshgn6ga9AH+YEueD3zzV5y0epnDcbc1tijgZVom52/ 0jvgUMUCFIzv2+uERmPU5BRwjSjwEdiv6Wke1cKbcPF/THq8Za6VmpLbEXn4uekFjDPT 9FvtWDNYnhmLdK6NFcdAJkaPiOd6Fin49OHS1HovxoTqet5rMd1WFOHYSr1JKDI68DmX 4o6kEAIjphKYUBj+CkotAG5WqoZbXArV21iFQjkPK0+Me6Q003iVOIEbAnQGCQACJqkB OJ33pllwUdYcSgYBJ6mMEDoTnJPNS5jK+b8Sz+7QeBqREyie1RNejxaBhLlhvqAbTak2 xkcA== X-Gm-Message-State: AOAM530J9QijaEZ7lPfYQjgioMa1MaI5n7SjWnP8zTKgpuarkkzomn7R cosCa+1/Ma9tfNgyfB6nncA= X-Google-Smtp-Source: ABdhPJz2zt//EU8ROABvVL+unJmuxPgWOCUhgF7nNeJ9i10SZvbdXAJUV6qDThFd6rwZC53Myvv24Q== X-Received: by 2002:adf:e806:: with SMTP id o6mr14903326wrm.331.1643029413522; Mon, 24 Jan 2022 05:03:33 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 05:03:33 -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:19 +0100 Message-Id: <20220124130328.2376-3-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 02/11] drm/amdgpu: use ttm_resource_manager_debug 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" Instead of calling the debug operation directly. Signed-off-by: Christian König Reviewed-by: Huang Rui --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index fb0d8bffdce2..eac2ff4647e3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -2076,7 +2076,7 @@ static int amdgpu_mm_vram_table_show(struct seq_file *m, void *unused) TTM_PL_VRAM); struct drm_printer p = drm_seq_file_printer(m); - man->func->debug(man, &p); + ttm_resource_manager_debug(man, &p); return 0; } @@ -2094,7 +2094,7 @@ static int amdgpu_mm_tt_table_show(struct seq_file *m, void *unused) TTM_PL_TT); struct drm_printer p = drm_seq_file_printer(m); - man->func->debug(man, &p); + ttm_resource_manager_debug(man, &p); return 0; } @@ -2105,7 +2105,7 @@ static int amdgpu_mm_gds_table_show(struct seq_file *m, void *unused) AMDGPU_PL_GDS); struct drm_printer p = drm_seq_file_printer(m); - man->func->debug(man, &p); + ttm_resource_manager_debug(man, &p); return 0; } @@ -2116,7 +2116,7 @@ static int amdgpu_mm_gws_table_show(struct seq_file *m, void *unused) AMDGPU_PL_GWS); struct drm_printer p = drm_seq_file_printer(m); - man->func->debug(man, &p); + ttm_resource_manager_debug(man, &p); return 0; } @@ -2127,7 +2127,7 @@ static int amdgpu_mm_oa_table_show(struct seq_file *m, void *unused) AMDGPU_PL_OA); struct drm_printer p = drm_seq_file_printer(m); - man->func->debug(man, &p); + ttm_resource_manager_debug(man, &p); return 0; } From patchwork Mon Jan 24 13:03:20 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: 12722173 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 25298C433FE for ; Mon, 24 Jan 2022 13:32:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C320A10EC49; Mon, 24 Jan 2022 13:32:47 +0000 (UTC) Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0EC2710EA98; Mon, 24 Jan 2022 13:03:36 +0000 (UTC) Received: by mail-wr1-x433.google.com with SMTP id s18so13466167wrv.7; Mon, 24 Jan 2022 05:03:35 -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=nkHC8QZFOIHT45+bm5mbkRLb4msTxzU2f5F+QSxdoAg=; b=T7+N3iUT/tvx0/HroBHPMeE8P01beuEHO5jLeP/wMjXxLkAUimfP4cVdk7IW3px50p cARlb7W/5m4Cjr+ptCbaxnuDHgSMk6Nqg6PXHkPvd1CGWLe9ks1SjkXxwP0u/EEfVu/h xzIinNMNARHC5HJvsROQaBsiiT41chqJoAsQhQw0P5t0PTyIq4qLyetolwOG8DATZjfc 54+qV4wvlqhEtueI1eseV1Wc2GCJMle4GwcFNZF3kbLVrH8rT514mwYLs+W2IG7eKKqw DXbALz12EBFUNDvRrFQAGiE7ayS5A1ZRrzEL6wrbTgFOvn2e2Ayghj2ydqYyRQVbktQq Kuvg== 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=nkHC8QZFOIHT45+bm5mbkRLb4msTxzU2f5F+QSxdoAg=; b=uYsQsXDvhEnmcs0uedDKQXsw1Yp4JkOzQpGtvfBd9xjh/kZuUwkRfPr1Xl0QnD+Owe 7GHuKUW3W1Tzd33jWHRIK2hjPGtTzQCCFzrqESfLWHy2u2IQuOF+MwBPpw2B00t6h6od GIHwlKxricSD0ZbTXOfA9RPI8dONZ6pPvy2zLNq5XMEISCEbIvZgH2Br2Z0rULUW9/RN BLURDf9f96u3PYuNHo1KsSJfDyATXXvjfVhAzLVB88834VLUACFDsE75N2q3QZ2G69Rv eYZnDNeeIzobaCsg3/STno4EmGq+Y4lktB7apXwHKWAefjuuw/PslWE1xFYiWTWt13rK PNzg== X-Gm-Message-State: AOAM531BbJMwIr1yZcwa5E0uS3w/aAcQRBf/OfOzNlIlGvqoAjq7YTAh 09tKc1B30ZhOn3rax2AXImw= X-Google-Smtp-Source: ABdhPJwszP5PKy5lRXuewCh5csQKxLvCvH5uGeQwuqcGu00xvYDhD0SHw9IA7jKagtr48W1cDQ1sQQ== X-Received: by 2002:a05:6000:2cc:: with SMTP id o12mr7195807wry.41.1643029414650; Mon, 24 Jan 2022 05:03:34 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 05:03:34 -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:20 +0100 Message-Id: <20220124130328.2376-4-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 03/11] dma-buf: consolidate dma_fence subclass checking 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" 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 13:03:21 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: 12722164 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 A98F0C433FE for ; Mon, 24 Jan 2022 13:32:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 456F710E96C; Mon, 24 Jan 2022 13:32:11 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 091EE10E7DE; Mon, 24 Jan 2022 13:03:37 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id i2so13460694wrb.12; Mon, 24 Jan 2022 05:03:36 -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=cIOzXEE5EC1Tz/fcrcFHUYHyr8c5+b40bPRHwMMP2zwfimRbd06SzhWeuAvbXXWQiV qaOSfP7s6l0uvcT288WJAtX3RszY8F8V8NjwczrE4i3Wv2dsts6PxATUp0WNOBaFxHzu ysnIIP5kbx0Hx+5o7Z8ZSIFYbauc3yub3Fo/07RhHiEBMKOokPgibzZGgOibEybM3wyz 6dftEXuh2bT+xTwSn0QSp2HJU1kUby32Uja1rHbE2MpF2CU3Z9neXAlDgeEGR6hYiFIl uPXoBoGtSL6xE99G+KaXbQ557khAFyezO+3OFF6tfkQ3tkBSD2yrvxpgMRdfAZXQihF8 bnhQ== 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=rCMmiymjWa9VDFiirbZEkw81vjwG6ViS72jrH8ESBaZkRW/nM720uz+4d2TOSTQ+s1 7vC3znwxhlGQK+VzyHP0kdOn0naECnsAbmHEU5DyfeBUBXpWLWtj9ejoHbckurpPB0bv fmaM0j8FaUWmMvRah49za7Fd8WALvQKOW1bRHZ+/Z/gPX7/fzfxb2rVtcIEgYWxO7RgR eeR/4gZ1hdDHs7soJiInZyvon8HQ/R7vjzoFhQZe6CxkngF5am/QTm1lMa/Mf3NQ4khB UhhWXx12KGfTJ1eEskAhQe8qL1EEWLOhKqj6Lk6lAXAOoxtuZ2Ru++wWtVgqVhST6vNw EGpw== X-Gm-Message-State: AOAM533+bdUHMrhH0Q/zF65RKkqwXpNxwsukSWlbe5NKE3U7oXTyc6IH qeY996PdklWiP9q/AsPV+dl28ipYUWM= X-Google-Smtp-Source: ABdhPJz8YMGjZC/90UmA7yXibWlmpeoAiaU+31DFIQQPY6Fglc75a7vxcse0ZoigED2XGmkMLF5cQg== X-Received: by 2002:a5d:5044:: with SMTP id h4mr11949849wrt.681.1643029415677; Mon, 24 Jan 2022 05:03:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 05:03:35 -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:21 +0100 Message-Id: <20220124130328.2376-5-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 04/11] dma-buf: warn about dma_fence_array container rules v2 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 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 Reviewed-by: Thomas Hellström --- 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 13:03:22 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: 12722158 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 8328DC433EF for ; Mon, 24 Jan 2022 13:32:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C57F710E8AE; Mon, 24 Jan 2022 13:32:10 +0000 (UTC) Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 13CD210E7DE; Mon, 24 Jan 2022 13:03:38 +0000 (UTC) Received: by mail-wr1-x42d.google.com with SMTP id s18so13466341wrv.7; Mon, 24 Jan 2022 05:03:37 -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=Za0l1xsonKjouvDIMROzfQL6VhlP8mzkESil1aeWuJGWeszrr05TDVJRnNQPHMjAmL ciUKjhRVlVdfIoWOstpjaFKypK3pZm8V3ujTya8XDZfJjQi5YVtpMaPGRFLaPYd6AzFX fAtr6XVhop5ak70LhAo3KDlnf7lqgftnijiM4MhYk3o6XKMxyXLbeAIpRygNIyHsfjPC ULnsMaFPKcBIJg7wQ05fw7igggYGtQTZS9cUIHtdH9r2hva7pZW+dJpwrEyi/0J0gjlU aTxrjnGzBGw8J3B65Hj0RK4nSgn+engUyV+MR5IoBAUUvROjofmJTZzKJ0a3KpOVSV4O nwpA== 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=NWeETnhQImnHfjWAvsfU/aPfEpS6CotaVpnCadepDsjP+a6pn/DfVPn0RhWa737fa9 sVpStKp3fac/6VjWooqzd0bsg8at8epSU2aPh+6qc9QQimWAq5kbDlVPVUC+e9t5E9qU psFS61sJFks6Zq7AitEav6++vN/AwFbR8WYLcYSahIQzG95xafSrJgP7EF2zEon+d/R8 HWzdrfEMgUiKt60VIfLcrkwem/SzmPW5Hti1OJ1yQgpiqapdL73aJ3fKlu03EpRX3OS+ VekXYYPH+3E2bgzIpatnBKF0XvxTgpuowhi/oK7863IUHAwT8Dq3V8N10TysGRQdpZch 3xPw== X-Gm-Message-State: AOAM530UQg2OtgJfV1eA7FZsUsVpxk+J+mHxx1GEw5r3xN6arXDOji12 Tasq6aVBy26kwwux/wA9AJU= X-Google-Smtp-Source: ABdhPJybmvbb5mAUUvu0Ijhnddxeo7Xw1mcpCy2qmY9reEMoeiW/+OvaQYIKxw/RSfns4ryIV8XoZA== X-Received: by 2002:adf:f804:: with SMTP id s4mr7647788wrp.425.1643029416642; Mon, 24 Jan 2022 05:03:36 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 05:03:36 -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:22 +0100 Message-Id: <20220124130328.2376-6-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 05/11] dma-buf: Warn about dma_fence_chain container rules v2 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" 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 13:03:23 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: 12722170 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 8BC39C4332F 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 6796210EC6A; Mon, 24 Jan 2022 13:32:39 +0000 (UTC) Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB14010EA82; Mon, 24 Jan 2022 13:03:38 +0000 (UTC) Received: by mail-wr1-x42d.google.com with SMTP id h29so10817364wrb.5; Mon, 24 Jan 2022 05:03:38 -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=k4LocfeKqgCiOSb/bFkVIe+Ku658A7zBja842FU5zGdTH4NyJvvfBvfC1rpFFs/N9/ Dz+5WYB/YSi4WC1+4LkgurAiJyl+Ru/4fkgqNb3xGwpZdaDJwD7gjOKTUwopixnAKqn4 iSCVjbdzTeGr4092nLs7seeDslt4C2M6A7kFCdCvePJtVUcIhx+hFdOmVcEVrykssxmJ Beh7uRJ+R6fz4YBEwJlnyF7nk2PsAr2V2oc1+3P8wI58BHuzqHoBknI6IldOXNgAzr41 hzBUWmho+twZ4l0H7oJUgIFpgP0rpopfmrHJkhaGpiMJFm9NaXimRQVpNtQ82+mf2OtL kUVg== 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=0v8uwIRygD/Dgp3I5AiIuC1XpFdFKua6IXwSlstHEqZuIAHY069funSkqGh9cW5Qbm lk66paZfXE2MRQiAMLHbsLa7K6GII/iPcJp3j5jrgsJs3QOY4SYgb06xuFa282vqzoZM xKi2+ST0G+Rv6RJWQCTCuspiGvj01e6lQXPPs8NgXslG5uf6DdIxL8GYkXPV22IxaoKb sk1pf60QrReI/5Owq1k6CdhJAfOTWM14CPrz9VKgRaw3jikr2EaCdoA/BriwZbLNBVde Qczb5YBCJTVy2d+8ZQOauV1gO01Dv8YuxlvZX5s5Q+w5LkfFrB1xyLpa9hFMyHJpvnW9 PdRQ== X-Gm-Message-State: AOAM530s7Djq6fXUGgBTHjq9JTOSm87KjAO+14Jw1SpBe0WUjXPKVuQC NhuvV47w9uDeFPSuZw4I4Us= X-Google-Smtp-Source: ABdhPJxQFRSIdOY815uMIjIuICHy/VNW3E4LthwsrDEXVnYnOzu387vE+YAzcwllAcmtblw8wKBGmA== X-Received: by 2002:a5d:6510:: with SMTP id x16mr5230197wru.613.1643029417626; Mon, 24 Jan 2022 05:03:37 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 05:03:37 -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:23 +0100 Message-Id: <20220124130328.2376-7-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 06/11] dma-buf: warn about containers in dma_resv object 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" 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 Reviewed-by: Thomas Hellström --- 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 13:03:24 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: 12722162 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 D4979C433FE for ; Mon, 24 Jan 2022 13:32:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D363F10EA5A; Mon, 24 Jan 2022 13:32:11 +0000 (UTC) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by gabe.freedesktop.org (Postfix) with ESMTPS id EFB8610E7DE; Mon, 24 Jan 2022 13:03:39 +0000 (UTC) Received: by mail-wr1-x430.google.com with SMTP id w11so1308391wra.4; Mon, 24 Jan 2022 05:03:39 -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=eU0Way/p0gtmxtdXNwIJ0cJ1YMvpXPNq1X9Q84RaqxsLycEgkYVHdXY4vFIX/Ao5tf 7bdBaz9m2saCHhtUpfULRrmNtvxumofa4Dt9HUTIE20xH3J2cTnrPgakeYBQAyvlK39x Ms4E/NygDlHxoieyBlSf8ypfUr9wBulYBzlwb720y2E4+hQ6MhtPENhfZBYjPEJLWwGn CXDckfmUJijLv2Ill6jtZd6lpzr8f4OuCCQLrcDXpXhHXUGxcIibtkmZVIiYt2Om26gc yQbiijahJ2z1PqVwSDUla0jKeOvdCIP9zO1AHqdYc2EEwi01knXl9kFyw4giBxZkYVul puBQ== 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=cu1YNM9n2eu9UthNGDi/cv/iuFXUqT7y4XFZJPgAXhrPxtdkKOhE3mmLThdm5axHa2 kgsIDhksWI/0IuWJK0Gq6aybYJ7UcVXSNxvqVBYFsr663q5CsshqGozyRXNKLswlTfBW GO4GXpwXHg+mI8qfW55j0ZgiqUpgCbryTmG36HDv/lWv6qnyBIZ9oPYCyXzt/hQ8XXjK GhR7Jhj4jUasQ5OmA9VTCG+LBRkFW0q3KCPkHkWD4HWWj6OFQuPM2dq4O0o9GYcT+yZv 6vItHLYenrnwvcn5Zm9Ht79m4bp+WmLSm3iUCArXUFcxScVoWnYKcw0uLaDG5it0GMxa u/QA== X-Gm-Message-State: AOAM531Sfp7HbVbrIGwvPtaGcHlgb+U0s0Pkej3nhv8uy0/63/NufRlK OMXTXpf3cCsTSjQlF8je5fo= X-Google-Smtp-Source: ABdhPJwAu7+U0MqbGH2TAyInUKLCd01EqoEzOU37D1z1qWDfHgZ+sfo/tjzM3H0sQlkYGj3OC6tkOg== X-Received: by 2002:a05:6000:1861:: with SMTP id d1mr12886342wri.497.1643029418557; Mon, 24 Jan 2022 05:03:38 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 05:03:38 -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:24 +0100 Message-Id: <20220124130328.2376-8-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 07/11] dma-buf: Add dma_fence_array_for_each (v2) 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" 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 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 * From patchwork Mon Jan 24 13:03:26 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: 12722172 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 C03C1C433EF for ; Mon, 24 Jan 2022 13:32:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 69DEE10EC6B; Mon, 24 Jan 2022 13:32:47 +0000 (UTC) Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by gabe.freedesktop.org (Postfix) with ESMTPS id 03B2510EC02; Mon, 24 Jan 2022 13:03:42 +0000 (UTC) Received: by mail-wr1-x435.google.com with SMTP id l25so13441364wrb.13; Mon, 24 Jan 2022 05:03:41 -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=d7GdV3zrFFYVKk31SMgh4ZYGFlJFqcDxuu45uUfdQqmIpu6BoD/+/68mq9J+1fTVme PL30RKTL/FL+RA+y/j4gc4axOLMkl1kPB7Nnhd7jqCA2Es2Kuqb5MbOL51/dhebD9dBE 2iqeY0IPGfcMahD3j8CdmBvITrq4EdnC83Ljj75bpiN6f9zam9x2HtK8fKahWPyrpw5j GCWRZcCTJqVHbqy/QyKUvAlY8cNPQVjx3AuB/B2mnQsbjLqhPQQosBCQduhjQQ99sRmx 7ZI+Npxk11LDL39q775wx1nKvklgsow9cilzlWln0mMBJBC5L43bn6rwFmqibzN981kX 3eJQ== 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=tdadE2wHb/11kLG1Gi3a26jv9XQMzkkiUXs1RmYSeQK52JXtwM6RPegl3Rk+sHRep9 oi2T54Jp/oFBwH5nhJ976smn8evOV1/zf1im33sjvEdwe8CvoTOpl0sYHCxuiG4leeyW SWqP/dhoEQR4+bAP2Hl5MTLsOFlodojtQpKuGv3qjLtftYN2X+TzwdSkYn/HteqjJ0xN IFP4CJlesNWfnojjWcirbzvg18qHkLQME/iZPv5VlCXZz62TeDWRewoS7FUDCHrEK8fE fIrtQD7bQ3ZjWA9FWzDQThSjySxEHuZqaLE8wpFkQWxV6Ux2VwTV6hpA5cb900gt5si9 yA/w== X-Gm-Message-State: AOAM532v9aBxHEUpSMWGCg3NLDaMKMzj5sgsQ/BroUwI1QYBBcNti+3D Vh9bItQltjsOyfFAlvf2N/M= X-Google-Smtp-Source: ABdhPJxvdjWU3RM8A6b76whKwGja3Vlgl4pegYkdp0qNNsZaMEJtD/HoOG09RzcoyFzY95O1xToLfA== X-Received: by 2002:adf:e112:: with SMTP id t18mr8103522wrz.293.1643029420441; Mon, 24 Jan 2022 05:03:40 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 05:03:40 -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:26 +0100 Message-Id: <20220124130328.2376-10-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 09/11] drm/amdgpu: use dma_fence_chain_contained 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" 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 13:03:27 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: 12722160 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 EB4DCC433FE for ; Mon, 24 Jan 2022 13:32:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B26A310EA38; Mon, 24 Jan 2022 13:32:11 +0000 (UTC) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4945710ECAC; Mon, 24 Jan 2022 13:03:43 +0000 (UTC) Received: by mail-wr1-x436.google.com with SMTP id v13so13445019wrv.10; Mon, 24 Jan 2022 05:03:43 -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=mayDO4SqOT6sf2NhBRvsP0DLMeVKsM7h9unw0ZHqmAWO5qafsGittBMwjgB4z6OJuQ jBzh/KUjDickCvFJoxImLwpQ+sWe+hi0m3cmoC8RVrEeGIbc44mSybgkJeLH095QjZfJ Iscy4NwK29NCxKpviz2Blk8d1UPvdiTwsE0Q+dNdpC7yeYOhs1683+YyjjZvAyyEnQQs wL7RdeiZpJaNpeQd4GrkUha0BCFhyDc9nau7zAFAdXS6j3kEoeWd6FpVnDtahI8vRzPq l+uXy/zp3B+bBcPruwUH842qiv29poaQp54esQjWkbHGlby30p3cPlz0mGDr/ELlnM6p XvSQ== 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=6C39EklZi/Y1WzL1NFqDpxhXoF3oSjFw2yOZtj4qEG1IAcfcdFYUbi5/I7FsgVjnaW PMpZShZCLHQqWn9wclh/ibXBmuax9Dnf/ZyMOdQFw/S3VcRLwNQYJCV1Kmfo2eaGNTvY 2WOkLhM5Q0okMkMrD5bpBlrtA40tf2i9Eyhige8jIW84PR6JineDY/tSylFttDrcFYbe xevnIdKvlnNk9RaTlgd7N8e7/QCoQBu9K0IOjtq4A1PGaQjBV0NVILmaxSD31okacntL 2UjGhfo8jUZ0znsDDm7WbGaQgBj3NCh7bCDkscO0+48Ndz/fAPBiDtmMjAnzUdGVbDRk KhXg== X-Gm-Message-State: AOAM530L/YqamU2KPN7KLahb3W++CvH2JTvxi1WSfPXxitFM+YoCArWX v063yQdTcJFDurcYQwvyIUc= X-Google-Smtp-Source: ABdhPJxs2g8ipzz/+fii/LaxWHZmuklRaYRFm9GrwFmRzJY1FJzjG8l+Js3pYAYVarlheQ8AYF0SAw== X-Received: by 2002:adf:fe85:: with SMTP id l5mr13914919wrr.661.1643029421485; Mon, 24 Jan 2022 05:03:41 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 05:03:41 -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:27 +0100 Message-Id: <20220124130328.2376-11-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 10/11] drm/i915: use dma_fence extractor functions 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" 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 Reported-by: kernel test robot --- 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 13:03:28 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: 12722157 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 9B7EEC433F5 for ; Mon, 24 Jan 2022 13:32:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C70CE10E8F8; Mon, 24 Jan 2022 13:32:10 +0000 (UTC) Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0CB2410ED36; Mon, 24 Jan 2022 13:03:44 +0000 (UTC) Received: by mail-wm1-x335.google.com with SMTP id c2so22886767wml.1; Mon, 24 Jan 2022 05:03:43 -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=BN4G1G1uZmHVPUdddjzKNuL0BBo7JYTZkQQyIvk63C2H72ryniGJxuuRifcQLLoCcm hQwVCCkXY/wNaT8Z1LaA+v4ExIHN3M2+LZG+Ug8dM2uWX854BnKbbn68p/3FS2OroLOb xU7JiItwucYfKwsJ9Hn1ShkWz9e21axei8cwYaT+zsIxR1gHW1Un4Wf+iQTjGKG/E+Wi afnlSkLzpvjkp8rMGslR8XUxIXdZoNpKmak7xl9EwIMJy6OE+3pLF9L2trntd29LJy93 UzUH+l1iyBU3yjh+Fy/gUyccrfa8UFM1UapXbIlsUQnUvBNQpK37fm9gCMyYjn58wLqU 6RMQ== 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=Bkk2ZpyPgsNkuFCg5oaTBPgJV+g/xs2tAf0zEex0F8Wie8nxG5Uj2UAtpHsRYaQM9k U8afa/ypdMYCM4zK6brCuCW+pPqtuW/jgxuTTMiwdsXVIf8fY+sELp5fcuO5Bq6tDXHE HiaiAuJ3bb3Uc6+fVLNnF2lPkJ3r1XdtDSOoaibZcXoMEmcJtBLAwc1m24QQF+n4z74p JkG4LercgdKE6XuVU6giyyJMC3gHZ2SzRK50njno/dRwx54L9VfaP+8iZx6brSbuV3Zk T4ORSzfKzPsZoKY4iZjDOxEhHwSxuqZTvNCx+AQZPA7L13ilT2FIM8VtHi+5FdY/JYtc oXOQ== X-Gm-Message-State: AOAM532RZZ2yjhcYtDL9Gy4XON5cnBEAsqj4RGslBnv2QnXJTrFj14Rm U015a/lxCSg7pLjBXP+frEY= X-Google-Smtp-Source: ABdhPJyM1SO5I7sGhctwpaezFuuegLgqLtmxJh+6i7GsHrfxCcvi0BoPrElxd8RWOVOT+IekzQ33ow== X-Received: by 2002:a1c:e913:: with SMTP id q19mr1753907wmc.87.1643029422366; Mon, 24 Jan 2022 05:03:42 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 05:03:42 -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:28 +0100 Message-Id: <20220124130328.2376-12-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 11/11] drm/vmwgfx: remove vmw_wait_dma_fence 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" 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 Reviewed-by: 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);