From patchwork Sun Mar 19 16:08:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 6858 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp786829wrt; Sun, 19 Mar 2023 09:31:39 -0700 (PDT) X-Google-Smtp-Source: AK7set9nRLBUs27mXudKWkaEt9199oRagPcCXiV0FERYCWfUeZiefFD7eZ/qLO7QTDaHYmIPRKo2 X-Received: by 2002:aa7:9ed1:0:b0:627:ad8a:6470 with SMTP id r17-20020aa79ed1000000b00627ad8a6470mr5664022pfq.26.1679243499267; Sun, 19 Mar 2023 09:31:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679243499; cv=none; d=google.com; s=arc-20160816; b=b9RIWPvK26tpsaSj4W2xjk4y/YxCf1uGsC22wCoWFymwCMxzip/o5T3u8yi2JgtQZq KFXAQrybMMdhYoB1c2cMjxfRxuG0gJ/KZmufw2HRUKmKNCdM30rQfqAe2JtLARE39vwB e69udonTHFTxcE0BjUS1s7fGPOYz/LBPeLgcN51pfir+XOa1yFYMDhYTKKRwqZfKkC2O gKIHfwJVuK/hxegD2wcabyju4czKyVr7+2CVh3ONjzkyL3alRKAkeoVDC/BOBsWjXDB9 AmQuW/UP6ag0jO1f0tyLjjb0318nD+d6jMHf5UB9WukpwWx8mk6bzYOmRi1px5yUxS1y 8HxA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=DK/je3vE7xVTe06kPF+BhyPA4yjEfe2gak8xewgmofs=; b=v12gICB7+H73Fe4I61GzJMCq8Jv3dnP6Uo/wqucbTBJSTtIw/yiOikPlIgMRFdsD2Z qWVQ/l/mIkRi4PY8ImTP/bF4MQ0NSRtIvCBqndccOK5Pj3ArRIFnSGieB6I50mNol4ER S00dCwEtJQNH7dL92mAndVlWd2Yiiu2Wd9XjYMmv1H83cA26sLyEjNL3tRdYc8EU7yJn GZzgCmuu9aloUsqfUjXRfRf+/QTYQ+cKys5FdRALVZ3UutuTbpAkMeoO0UazvYwGc/g0 apc+5ufmRE5gGMgetWc2GvFOBncpr4XI+XI3+LeEBjO1keVeVwz1q4+6a9s/Zgs9IaM6 5v7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=RvUzdhZR; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q31-20020a631f5f000000b004fcc0120074si7767128pgm.161.2023.03.19.09.31.19; Sun, 19 Mar 2023 09:31:39 -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=RvUzdhZR; 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 S230387AbjCSQLF (ORCPT + 99 others); Sun, 19 Mar 2023 12:11:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229699AbjCSQLD (ORCPT ); Sun, 19 Mar 2023 12:11:03 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49ADC144AF for ; Sun, 19 Mar 2023 09:11:01 -0700 (PDT) Received: from workpc.. (109-252-120-116.nat.spd-mgts.ru [109.252.120.116]) (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 7095F6602E85; Sun, 19 Mar 2023 16:10:59 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1679242260; bh=jPLHTnWTUSdZXY8GKvIeoYeqXSgn03eKYxl5Rh0PcFI=; h=From:To:Cc:Subject:Date:From; b=RvUzdhZRkKcywnWUfN8Yz8qW5EqvinT8rLe0gnwLi1VMAu68LaE1n29v3QhnFVBBm EYCVGadvdXyTK1N8HBWPC7JHEyWmj0VcAVUTVgnzi367HR8MpOVjgIZpkU6pNroYkG jsQ+YesTMBs12l0pqOz+dNHxjDjMNwe4isFRagt38Be4Nek5mnydk1k+ooYdzQm+lY wWJwWoj9cK1upMCB1vxogu2AAuk0EtZAPNoO9BbBgXOmYo74j2CmrbBwe76J9MaTqv VLlTSaJaVHXCGD9JecuijnYKgArlbbl5cxjgef8STwIICq5oipLt2BfoD+j3FGPSoo Y9i5bJMzW9hYQ== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Rob Clark , =?utf-8?b?TWFyZWsgT2zFocOhaw==?= , Pierre-Eric Pelloux-Prayer Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com, virtualization@lists.linux-foundation.org Subject: [PATCH v2 0/2] Add sync object UAPI support to VirtIO-GPU driver Date: Sun, 19 Mar 2023 19:08:00 +0300 Message-Id: <20230319160802.3297643-1-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760814431672084789?= X-GMAIL-MSGID: =?utf-8?q?1760814431672084789?= We have multiple Vulkan context types that are awaiting for the addition of the sync object DRM UAPI support to the VirtIO-GPU kernel driver: 1. Venus context 2. Native contexts (virtio-freedreno, virtio-intel, virtio-amdgpu) Mesa core supports DRM sync object UAPI, providing Vulkan drivers with a generic fencing implementation that we want to utilize. This patch adds initial sync objects support. It creates fundament for a further fencing improvements. Later on we will want to extend the VirtIO-GPU fencing API with passing fence IDs to host for waiting, it will be a new additional VirtIO-GPU IOCTL and more. Today we have several VirtIO-GPU context drivers in works that require VirtIO-GPU to support sync objects UAPI. The patch is heavily inspired by the sync object UAPI implementation of the MSM driver. Changelog: v2: - Fixed chain-fence context matching by making use of dma_fence_chain_contained(). - Fixed potential uninitialized var usage in error code patch of parse_post_deps(). MSM driver had a similar issue that is fixed already in upstream. - Added new patch that refactors job submission code path. I found that it was very difficult to add a new/upcoming host-waits feature because of how variables are passed around the code, the virtgpu_ioctl.c also was growing to unmanageable size. Dmitry Osipenko (2): drm/virtio: Refactor job submission code path drm/virtio: Support sync objects drivers/gpu/drm/virtio/Makefile | 2 +- drivers/gpu/drm/virtio/virtgpu_drv.c | 3 +- drivers/gpu/drm/virtio/virtgpu_drv.h | 4 + drivers/gpu/drm/virtio/virtgpu_ioctl.c | 182 --------- drivers/gpu/drm/virtio/virtgpu_submit.c | 510 ++++++++++++++++++++++++ include/uapi/drm/virtgpu_drm.h | 16 +- 6 files changed, 532 insertions(+), 185 deletions(-) create mode 100644 drivers/gpu/drm/virtio/virtgpu_submit.c