From patchwork Wed May 3 08:19:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Albert Esteve X-Patchwork-Id: 13229810 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 57C23C77B78 for ; Wed, 3 May 2023 08:22:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pu7jZ-0001N2-8P; Wed, 03 May 2023 04:21:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pu7jV-0001Jp-Qv for qemu-devel@nongnu.org; Wed, 03 May 2023 04:21:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pu7jR-0002uG-BM for qemu-devel@nongnu.org; Wed, 03 May 2023 04:21:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683102060; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Q0Gg0nBy2P64ml8SECtcncY5urZtCRp+JKcCAzbkyyg=; b=ItRfkA4y5P3vg80Q/1VgIkSnk6J9xUw+z0XCEEo4YYcHcUmuzUNOjdEoUK0BgQVrY88jB/ gTvbLTKzz+X1N+oqBSd7SfqBMs0R/h68itB7aAN42QQeWolHwuEW7lYzIBVztuze3Eq0Fw xNmOPSbbOFqW7cbjF/liDUKH54ySSDg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-517-XsXtiLItOwaOyzmn1eyYQg-1; Wed, 03 May 2023 04:19:20 -0400 X-MC-Unique: XsXtiLItOwaOyzmn1eyYQg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 19362885622 for ; Wed, 3 May 2023 08:19:19 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.225.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B501C15BAD; Wed, 3 May 2023 08:19:17 +0000 (UTC) From: Albert Esteve To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Albert Esteve Subject: [PATCH 0/4] Virtio shared dma-buf Date: Wed, 3 May 2023 10:19:07 +0200 Message-Id: <20230503081911.119168-1-aesteve@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Received-SPF: pass client-ip=170.10.133.124; envelope-from=aesteve@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.171, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This patch covers the required steps to add support for virtio cross-device resource sharing[1], which support is already available in the kernel. The main usecase will be sharing dma buffers from virtio-gpu devices (as the exporter -see VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID in [2]), to virtio-video (under discussion) devices (as the buffer-user or importer). Therefore, even though virtio specs talk about resources or objects[3], this patch adds the infrastructure with dma-bufs in mind. Note that virtio specs let the devices themselves define what a vitio object is. These are the main parts that are covered in the patch: Shared resources table, to hold all resources that can be shared in the host and their assigned UUID Internal shared table API for virtio devices to add, lookup and remove resources Unit test to verify the API. New message to the vhost-user protocol to allow backend to interact with the shared table API through the control socket Applies cleanly to 4ebc33f [1] - https://lwn.net/Articles/828988/ [2] - https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html#x1-3730006 [3] - https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html#x1-10500011 Albert Esteve (4): virtio-dmabuf: introduce virtio-dmabuf vhost-user: add shared_object msg vhost-user: refactor send_resp code libvhost-user: add write_msg cb to dev struct docs/interop/vhost-user.rst | 15 +++ hw/display/meson.build | 1 + hw/display/virtio-dmabuf.c | 88 +++++++++++++++++ hw/virtio/vhost-user.c | 90 ++++++++++++++--- include/hw/virtio/virtio-dmabuf.h | 58 +++++++++++ subprojects/libvhost-user/libvhost-user.c | 40 ++++++++ subprojects/libvhost-user/libvhost-user.h | 46 +++++++++ tests/unit/meson.build | 1 + tests/unit/test-virtio-dmabuf.c | 112 ++++++++++++++++++++++ 9 files changed, 438 insertions(+), 13 deletions(-) create mode 100644 hw/display/virtio-dmabuf.c create mode 100644 include/hw/virtio/virtio-dmabuf.h create mode 100644 tests/unit/test-virtio-dmabuf.c