Received: by 10.213.65.68 with SMTP id h4csp2314390imn; Mon, 9 Apr 2018 01:04:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Cjiv++kpHpSksGuwzNIm7aqjEBN1EHzkJ49L5qpbWPAVGdRDIUqwUH5UMgyeKzJX04mJ6 X-Received: by 2002:a17:902:9308:: with SMTP id bc8-v6mr37604531plb.189.1523261083230; Mon, 09 Apr 2018 01:04:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523261083; cv=none; d=google.com; s=arc-20160816; b=x0d8ckJANVRIioOOeiFD3rGPGamMplbeOt+D1OGL7y1RxOYZZ01CYG0nNa9O7oNJsY +ZtNtsXRBUF8Ak0Xit48sz6ZPFO/vN8/YCWK9ZO8zhtoXIfyyiELE9I+Ugta8Rrp2IbZ WU6bad/qUG7QGSr8MB+BnQJyK44QKR91uV1znA3xHmGL0CQ1YDEDVUxLG2L531ToIbae HomaX7yfRoGVBGMx7rJpTMhKUyl5RRzkgnOE94SUlzQ25I0ittZhyVtiwKS+F+dLAMCE sR72RvkGbfzopMM6GUQ30nVif6IP5ggCewNoaElGU1IxfTg3jVgvyA0a13utNZFJU1S1 kWmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=ajc6TU5h9RrZFSrPuZE+oyKN92S/iNxLzJAkRgaleVM=; b=T9IfLynpGgZ7FYfjdbbz4NE0gbiH4y3Dc9DVYG4bNiBpI27GIa4/bxQijkvNrBzzwW Yf589HrqlGqu8tD+N4IUcoo1UjqbLL+DKCnbPwxp47YCGfGqXEj4AJs+gLFSHPtCaJrz R8ONZxMLldFTuac/tQMaWy7lXvuIKeR9H1oUhY6PvrEJY0j+Xx07IGepUc2fIzETHUvI EtDHdqQ37EY8AQtUaMTN2gQflttW1rtBEi+RGuElAOGB9NcWoU8T6yEq+fJyvzwIPfje +08KGOTPpxQvGnc9jyBfJgdbiEIC/tGcxAAFCGjn0jHOCLVlyfgJIoTkLYna03eMZOSJ clVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=dr4HRXB2; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o30si11091500pgc.282.2018.04.09.01.04.05; Mon, 09 Apr 2018 01:04:43 -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=fail header.i=@ffwll.ch header.s=google header.b=dr4HRXB2; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751914AbeDIIA5 (ORCPT + 99 others); Mon, 9 Apr 2018 04:00:57 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:38710 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751416AbeDIIAz (ORCPT ); Mon, 9 Apr 2018 04:00:55 -0400 Received: by mail-wm0-f53.google.com with SMTP id i3so14581111wmf.3 for ; Mon, 09 Apr 2018 01:00:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=ajc6TU5h9RrZFSrPuZE+oyKN92S/iNxLzJAkRgaleVM=; b=dr4HRXB2cPr9Q2R597SwxFHXBVi9+39SepvJL/Tgys+26EPSN17z9C6d7iMpIzj4Oj kAC3dqRL/6Rv3/OsOq25EddCvOVzRFsY1WiGmpuIlIvwdp2bPbO2j5xGIfl/o93AFeMp 6wzQgpoXqRQ8W3/axTUX/kLtOVMAJBr9IYvXM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=ajc6TU5h9RrZFSrPuZE+oyKN92S/iNxLzJAkRgaleVM=; b=ApPFzFkT/Rsl3ELn+iIyYL5pyXx+spdN4ZkJ4p/DmdZYJrh/pchOtRHuyiJXJYco4Y GwLo1w0MUu3H3CtVsA02NoXxoUcnJSVA7kukOkLEYm8YcypQ8GGEnJ/s1Wn8xHj5CBH/ cmppwv1O4dXCKmP0lChKVAQGgujURvm1z1jwPapJPqTGvBgh8gQI8xtQy5i8FC+uSDTs gdKodq/KWnwUCn3akjTZOhmreq9bKPz5GAVsvcmarGJVSuKbOtsG41Y5Wm1lGb7UMu0F TszmysyllwxsGSldmrZOKbOW/kcI+y5JwbMc4oB+RziK546sBrwuua45i52YBr064M6P HrKg== X-Gm-Message-State: ALQs6tDs3KliGS2M4/3eKxjRIld3x5qzick1wyBR+3gaqNWGxf/assPC hUy9V4molv2Ue5tsfIMY7ewLwA== X-Received: by 10.80.142.21 with SMTP id 21mr21338728edw.127.1523260854032; Mon, 09 Apr 2018 01:00:54 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:5635:0:39d2:f87e:2033:9f6]) by smtp.gmail.com with ESMTPSA id e11sm37877edn.18.2018.04.09.01.00.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Apr 2018 01:00:53 -0700 (PDT) Date: Mon, 9 Apr 2018 10:00:51 +0200 From: Daniel Vetter To: Gerd Hoffmann Cc: Daniel Stone , Tomeu Vizoso , David Airlie , qemu-devel@nongnu.org, dri-devel , open list , "moderated list:DMA BUFFER SHARING FRAMEWORK" , "open list:DMA BUFFER SHARING FRAMEWORK" Subject: Re: [RfC PATCH] Add udmabuf misc device Message-ID: <20180409080051.GD31310@phenom.ffwll.local> Mail-Followup-To: Gerd Hoffmann , Daniel Stone , Tomeu Vizoso , David Airlie , qemu-devel@nongnu.org, dri-devel , open list , "moderated list:DMA BUFFER SHARING FRAMEWORK" , "open list:DMA BUFFER SHARING FRAMEWORK" References: <20180313154826.20436-1-kraxel@redhat.com> <20180313161035.GL4788@phenom.ffwll.local> <20180314080301.366zycak3whqvvqx@sirius.home.kraxel.org> <20180406105422.6tewkkciwerud3tm@sirius.home.kraxel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180406105422.6tewkkciwerud3tm@sirius.home.kraxel.org> X-Operating-System: Linux phenom 4.15.0-1-amd64 User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 06, 2018 at 12:54:22PM +0200, Gerd Hoffmann wrote: > On Fri, Apr 06, 2018 at 10:52:21AM +0100, Daniel Stone wrote: > > Hi Gerd, > > > > On 14 March 2018 at 08:03, Gerd Hoffmann wrote: > > >> Either mlock account (because it's mlocked defacto), and get_user_pages > > >> won't do that for you. > > >> > > >> Or you write the full-blown userptr implementation, including mmu_notifier > > >> support (see i915 or amdgpu), but that also requires Christian K?nigs > > >> latest ->invalidate_mapping RFC for dma-buf (since atm exporting userptr > > >> buffers is a no-go). > > > > > > I guess I'll look at mlock accounting for starters then. Easier for > > > now, and leaves the door open to switch to userptr later as this should > > > be transparent to userspace. > > > > Out of interest, do you have usecases for full userptr support? Maybe > > another way would be to allow creation of dmabufs from memfds. > > I have two things in mind. > > One is vga emulation. I have virtual pci memory bar for the virtual > vga. qemu backs vga memory with anonymous pages right now, switching > that to shmem should be easy though if that makes things easier. Guest > places the framebuffer somewhere in the pci bar, and I want export the > chunk which represents the framebuffer as dma-buf to display it on the > host without copying around data. Framebuffer is linear in guest > physical memory, so a single block only. That is the simpler case. > > The more difficuilt one is virtio-gpu ressources. virtio-gpu resources > live in host memory (guest has no direct access). The guest can > optionally specify guest memory pages as backing storage for the > resource. Guest backing storage is allowed to be scattered. Commands > exist to copy both ways between host storage and guest backing. > > With virgl (opengl acceleration) enabled the guest will send rendering > commands to fill the framebuffer ressource, so there is no need to copy > content to the framebuffer ressource. The guest may fill other > resources such as textures used for rendering with copy commands. > > Without acceleration the guest does software-rendering to the backing > storage, then sends a command to copy the framebuffer content from guest > backing storage to host ressource. > > Now it would be useful to allow a shared mapping, so no copying between > guest backing storage and host resource is needed, especially for the > software rendering case (i.e. dumb gem buffers). Being able to export > guest dumb buffers to other host processes would be useful too, for > example to display guest windows seamlessly on the host wayland server. > > So getting a dma-buf for the guest backing storage via udmabuf looked > like a useful approach. We can export the guest gem buffers to other > host processes that way. qemu itself could map it too, to get a linear > representation of the scattered guest backing storage. > > The other obvious approach would be to do it the other way around and > allow the guest map the host resource somehow. On the host side qemu > could use vgem to allocate resource memory, so it'll be a gem object > already. Mapping that into the guest isn't that straight-forward > though. The guest manages its physical address space, so the guest > would need to find a free spot and ask the host to place the resource > there. Then the guest needs page structs covering the mapped resource, > so it can work with it. Didn't investigate how difficuilt that is. Use > memory hotplug maybe? Can we easily unmap the resource then? Also I > think updating the guests physical memory layout (which we would need to > do on every resource map/unmap) isn't an exactly cheap operation ... Generally we try to cache mappings as much as possible. And wrt finding a slot: Create a sufficiently sized BAR on the virgl device, just for that? -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch