Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6367360yba; Thu, 11 Apr 2019 18:37:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiBV8hsvDYML6fm5u6T5cUl7NIiRUZX/H21CGU8pGBXV7nJAyR/YeH4TU/DUuQV1GiG4CY X-Received: by 2002:a63:6503:: with SMTP id z3mr44986726pgb.113.1555033053652; Thu, 11 Apr 2019 18:37:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555033053; cv=none; d=google.com; s=arc-20160816; b=HjbnEoqGgfRm4mSmXzp3KEKGPhZSNlqVyhmR0/0HVksaKMoq1EfMlJlFPG5ySxLy2b mA/K3kKcxsa+4vohylVyTKn3NjGaVliTJ5K2Owr6hbuND6ZLKNSwcOZR4lRJ7n20vwMH r+pdQrDNtI2gCkqJy9/DollsNVWd7F+TQiPKcVzGf/ZT7hX8UyX2SOKTo38k7ehh9K5m Qn8lAv6R3oV+8WmnS7ZORXKU0IYmYi6TRFjH5wJWFgCBpRi51wo2VypJd5q81yXiyCCY wDncgnUKNRmpxKM1m5jm7sVoOQXJTODDgmyuts+lArLXt9kZ5YwrEtFU+hUwEQrIlXfh MHbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=XPCwRPH4gaObJMDjbw17FcWfdaCNXB4H2vbtWZc0D2I=; b=TAuHmnz0MirjLF+xFX0qZvuVz+qpyXyYgEKxLnCk7GePBwaW2b2CMkyJqbI0tawOKt hJvmjYecfXvMR+orb64y+rGi70RpIVTjQt76OIyjEI7Vz7cGS0VgzcC99uhSrLBGrkvH IZ06QeszRrpHbPTgIxs6IjHSF6zBjEMi5xD0kIorFHbUptnp0xLBvZWhRGwwJM5zOkU+ ulucsX+RbQ9bCz//Z5LlK4iAb+q+fP+xtRiRxHctl1rC/dlmx7g6EhYjyXKA0IZLiGqX 9BT8FZ6lwbdW8xInGbwSNJsOgV71DLWyjgqubH1p71nlkQpUEaDlHq7jlh/eAiAq56qA BCVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VBSEr4JT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m10si35449812pll.355.2019.04.11.18.37.12; Thu, 11 Apr 2019 18:37:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VBSEr4JT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726690AbfDLBgc (ORCPT + 99 others); Thu, 11 Apr 2019 21:36:32 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:33606 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726636AbfDLBgc (ORCPT ); Thu, 11 Apr 2019 21:36:32 -0400 Received: by mail-lj1-f193.google.com with SMTP id f23so7341464ljc.0 for ; Thu, 11 Apr 2019 18:36:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XPCwRPH4gaObJMDjbw17FcWfdaCNXB4H2vbtWZc0D2I=; b=VBSEr4JT3nM3wVIXDvBCU18Oezm7wfxk+0x8PNJ3ODCdI49JbhV7iLjPF6SYzl4JZK ouZ/smJ2TjSoc1CPH/hkAc7oG/oLVZmexDleKyg7Df0sSXfD7NPE5IFLhPKx35EJJfXZ PGA8iO0IEm0D0Wx+xLsvXC5dcNH1uhypITHlY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XPCwRPH4gaObJMDjbw17FcWfdaCNXB4H2vbtWZc0D2I=; b=Wd2NpLrc1ZIsWiNEZANhPnUMHUA0h1uUcKYLsHMjkPkyX2BN1wqzcWt/J5Pr+0sOvH FioogCnoKw8gYc+YLtBG4f2TOOaVu+Ee+KCo218f+2pzVgTwTQwamI8I+AiZ8maswKKK PY1NRNwYU7+usflKpy25CRFrs1GsHhOgeqwBbcIcY/hzwMHfAW705zVlfk68+HfWC/hU 5fxzD/ecaU0wvgZZSgxY/PbZYm8WInYTV0jsTcrF5a+s5WY/kxqtoLshFDLy8kJjM35Z 4ZGpcx2LKTt4tdEVLzmbik2XE7F5Zm5BmrXFGg8nFHG74ui1pYVFNkKTMrEyyf9N4AIF o+Lg== X-Gm-Message-State: APjAAAVot5xeoJORPrXk00Lg+vER8FlqDaUij8P5argLxUy0u6Qo03Di MV0huUo9XdwzcGEeuzb/FweTdpl5I70= X-Received: by 2002:a2e:84ce:: with SMTP id q14mr27956208ljh.80.1555032988887; Thu, 11 Apr 2019 18:36:28 -0700 (PDT) Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com. [209.85.208.177]) by smtp.gmail.com with ESMTPSA id j10sm2968183lfc.56.2019.04.11.18.36.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Apr 2019 18:36:28 -0700 (PDT) Received: by mail-lj1-f177.google.com with SMTP id p14so7301389ljg.5 for ; Thu, 11 Apr 2019 18:36:27 -0700 (PDT) X-Received: by 2002:a2e:808e:: with SMTP id i14mr29794761ljg.103.1555032987370; Thu, 11 Apr 2019 18:36:27 -0700 (PDT) MIME-Version: 1.0 References: <20190410114227.25846-1-kraxel@redhat.com> <20190410114227.25846-4-kraxel@redhat.com> <20190411050322.mfxo5mrwwzajlz3h@sirius.home.kraxel.org> In-Reply-To: <20190411050322.mfxo5mrwwzajlz3h@sirius.home.kraxel.org> From: Gurchetan Singh Date: Thu, 11 Apr 2019 18:36:15 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/3] virtio-gpu api: VIRTIO_GPU_F_RESSOURCE_V2 To: Gerd Hoffmann Cc: ML dri-devel , virtio@lists.oasis-open.org, David Airlie , "Michael S. Tsirkin" , =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= , Tomeu Vizoso , Jason Wang , David Airlie , "open list:VIRTIO CORE, NET AND BLOCK DRIVERS" , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 10, 2019 at 10:03 PM Gerd Hoffmann wrote: > > > > +/* VIRTIO_GPU_CMD_RESOURCE_CREATE_V2 */ > > > +struct virtio_gpu_cmd_resource_create_v2 { > > > + struct virtio_gpu_ctrl_hdr hdr; > > > + __le32 resource_id; > > > + __le32 format; > > > + __le32 width; > > > + __le32 height; > > > + /* 3d only */ > > > + __le32 target; > > > + __le32 bind; > > > + __le32 depth; > > > + __le32 array_size; > > > + __le32 last_level; > > > + __le32 nr_samples; > > > + __le32 flags; > > > +}; > > > > > > I assume this is always backed by some host side allocation, without any > > guest side pages associated with it? > > No. It is not backed at all yet. Workflow would be like this: > > (1) VIRTIO_GPU_CMD_RESOURCE_CREATE_V2 > (2) VIRTIO_GPU_CMD_MEMORY_CREATE (see patch 2) > (3) VIRTIO_GPU_CMD_RESOURCE_MEMORY_ATTACH (see patch 2) Thanks for the clarification. > > You could also create a larger pool with VIRTIO_GPU_CMD_MEMORY_CREATE, > then go attach multiple resources to it. > > > If so, do we want the option for the guest allocate? > > Allocation options are handled by VIRTIO_GPU_CMD_MEMORY_CREATE > (initially guest allocated only, i.e. what virtio-gpu supports today, > the plan is to add other allocation types later on). You want to cover Vulkan, host-allocated dma-bufs, and guest-allocated dma-bufs with this, correct? Let me know if it's a non-goal :-) If so, we might want to distinguish between memory types (kind of like memoryTypeIndex in Vulkan). [Assuming memory_id is like resource_id] Here's some host-side APIs Chromium might want to use this with workflow: 1) Vulkan seems the most straightforward virtio_gpu_cmd_memory_create --> create kernel data structure, vkAllocateMemory on the host or import guest memory into Vulkan, depending on the memory type virtio_gpu_cmd_resource_create_v2 --> vkCreateImage + vkGetImageMemoryRequirements on host virtio_gpu_cmd_resource_attach_memory --> vkBindImageMemory on host 2) With a guest allocated dma-buf using some new allocation library, virtio_gpu_cmd_resource_create_v2 --> host returns metadata describing optimal allocation virtio_gpu_cmd_memory_create --> allocate guest memory pages since it's guest memory type virtio_gpu_cmd_resource_attach_memory --> associate guest pages with resource in kernel, send iovecs to host for bookkeeping 3) With gbm it's a little trickier, virtio_gpu_cmd_resource_create_v2 --> gbm_bo_create_with_modifiers, get metadata in return virtio_gpu_cmd_memory_create --> create kernel data structure, but don't allocate pages, nothing on the host virtio_gpu_cmd_resource_attach_memory --> associate memory structure with resource in kernel, nothing on the host Is this what you have in mind? > > > > +/* VIRTIO_GPU_RESP_OK_RESOURCE_INFO */ > > > +struct virtio_gpu_resp_resource_info { > > > + struct virtio_gpu_ctrl_hdr hdr; > > > + __le32 stride[4]; > > > + __le32 size[4]; > > > +}; > > > > offsets[4] needed too > > That is in VIRTIO_GPU_CMD_RESOURCE_MEMORY_ATTACH ... I assume the offsets aren't returned by VIRTIO_GPU_CMD_RESOURCE_MEMORY_ATTACH. How does the guest know at which offsets in memory will be compatible to share with display, camera, etc? Also, do you want to cover the case where the resource is backed by three separate memory regions (VK_IMAGE_CREATE_DISJOINT_BIT)? If so, we might want to make resource_create_v2 more opaque like VkImageMemoryRequirementsInfo2. > > cheers, > Gerd >