Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2977788rwl; Sun, 9 Apr 2023 05:42:27 -0700 (PDT) X-Google-Smtp-Source: AKy350amkYquVg5tjYuPS/4CoVwt0j4nf9GOdWbGs0x/K0AVSabQSUddYLByY3iRnyOYYJpSQ7vT X-Received: by 2002:a17:906:7399:b0:94a:6e09:3cad with SMTP id f25-20020a170906739900b0094a6e093cadmr1805666ejl.9.1681044147478; Sun, 09 Apr 2023 05:42:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681044147; cv=none; d=google.com; s=arc-20160816; b=bbwRIIlpf519FFywP9AwK5TRkiPx+mDIbKmsM7RGkdlvSEVFJyEgW5od9QeHBsAyhL fz4OPK/isOX2OqkB/evVyeBhqdBQXeYd8o6HfCUDAaO/RYWVf5v4flbXKOgJOj7ZeNri zRKbVn8lISK5rPBJHzbxFvInk9N/sD9lvrmRkvBo2mKUvjPE2FlqEyfdbyfCier+AZoL YgT0fqxr99PkGbVy5Z7sH2KyhZhpRE347J/VV1SEIp/cx8NmWT7HD9u2iAREcWZEfMka 55V7TIGg2D3+I7nwAK6S4IEfTtd14hoj2U1gn8z9Kr2h9M/Q7ch7o3c678NLY96UcgNk maNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+GWCRiZh6jfdToDYPKhE/V5YJSSt/ZMevffhH9qmOXM=; b=JjPPmGp/AP3DQezekHEpt0YpwTvvyXqsUr18Std5a8NoCbJm+aj/R9rO7pKX5x3OEg /Mm/PV0N0/on1l3a5nx0sGbKG6AT+sYuDiBmA9+cqXCWpYDQyBBrgNvOjcMkXyQiNDzq N2kuDyX4IPy/kEwUANiRlXYO7q8V4NgxG3/tKEOzxjT9vFgTz/MIIRjn4cirE5A3Z+Da +sUgrdUiBHsDiewF5KdHA7Xeyx9VNOnAM4Y50dKhEguaww2duYZBU/SH0nibZaHbTBm8 pHEku2Be4gm6dCSbaOsAKjibDzxWDW6bUtw6WP5RCI38w6D102C/v52QW4shhUk5tDPr Il9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=jLhPIeeT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn16-20020a1709070d1000b00939ad825dd8si8170836ejc.837.2023.04.09.05.42.02; Sun, 09 Apr 2023 05:42:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=jLhPIeeT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229545AbjDIMks (ORCPT + 99 others); Sun, 9 Apr 2023 08:40:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbjDIMko (ORCPT ); Sun, 9 Apr 2023 08:40:44 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFD283C3D for ; Sun, 9 Apr 2023 05:40:43 -0700 (PDT) Received: from workpc.. (109-252-119-170.nat.spd-mgts.ru [109.252.119.170]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by madras.collabora.co.uk (Postfix) with ESMTPSA id 87BBD66031E9; Sun, 9 Apr 2023 13:40:41 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1681044042; bh=LXZqn9JZkk7iPwWsuND2XuT7vg+8om2rZKLRJkZQfxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jLhPIeeTxCNtjwOlYXNAW+NlrRbdIW2XKGHybgjvUcA1SMM00q6WqNQd3DjAxBmHI Z7f1QcNcN2c6oAEbPK2uUElaXi0EexP70szW2eB/G9gIuQB2JPvOVNe8VnlcRN+Lrd aCFoUcndSp0ulUnPsPFR/8ABEbRLsUpIJNEhI0kBpf1KhF0ejRNwlLGS7BWOpXWXDx dsQamKSXuhy2RwWGB3P//OqgZmKYCQwm+imYSadkzdGqJYpzLMkIVQBlUIvx8p2Q72 wVh/vRtgzCisKbWJAeaOSmRWWXiUoSI4/Dpc6x5CBOoREL7VWRTNMDp87qa8mFLYBA Vp+jeejqm+3Jw== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Rob Clark , =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= , Pierre-Eric Pelloux-Prayer , Emil Velikov Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com, virtualization@lists.linux-foundation.org Subject: [PATCH v5 2/3] drm/virtio: Wait for each dma-fence of in-fence array individually Date: Sun, 9 Apr 2023 15:39:56 +0300 Message-Id: <20230409123957.29553-3-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230409123957.29553-1-dmitry.osipenko@collabora.com> References: <20230409123957.29553-1-dmitry.osipenko@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use dma-fence-unwrap API for waiting each dma-fence of the in-fence array individually. Sync file's in-fence array always has a non-matching fence context ID, which doesn't allow to skip waiting of fences with a matching context ID in a case of a merged sync file fence. Suggested-by: Rob Clark Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio/virtgpu_submit.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_submit.c b/drivers/gpu/drm/virtio/virtgpu_submit.c index 902734778d1b..b60dea077240 100644 --- a/drivers/gpu/drm/virtio/virtgpu_submit.c +++ b/drivers/gpu/drm/virtio/virtgpu_submit.c @@ -32,8 +32,8 @@ struct virtio_gpu_submit { void *buf; }; -static int virtio_gpu_dma_fence_wait(struct virtio_gpu_submit *submit, - struct dma_fence *in_fence) +static int virtio_gpu_do_fence_wait(struct virtio_gpu_submit *submit, + struct dma_fence *in_fence) { uint32_t context = submit->fence_ctx + submit->ring_idx; @@ -43,6 +43,22 @@ static int virtio_gpu_dma_fence_wait(struct virtio_gpu_submit *submit, return dma_fence_wait(in_fence, true); } +static int virtio_gpu_dma_fence_wait(struct virtio_gpu_submit *submit, + struct dma_fence *fence) +{ + struct dma_fence_unwrap itr; + struct dma_fence *f; + int err; + + dma_fence_unwrap_for_each(f, &itr, fence) { + err = virtio_gpu_do_fence_wait(submit, f); + if (err) + return err; + } + + return 0; +} + static int virtio_gpu_fence_event_create(struct drm_device *dev, struct drm_file *file, struct virtio_gpu_fence *fence, -- 2.39.2