Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp579991ybe; Fri, 13 Sep 2019 02:46:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZERbKzTTvmfkKG3iA+wE7p2qsNrfm/aI2GrycaVnvKiAna4utqyaXyNQd1rLiCv0t+4Du X-Received: by 2002:a50:cc46:: with SMTP id n6mr21505247edi.7.1568368011688; Fri, 13 Sep 2019 02:46:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568368011; cv=none; d=google.com; s=arc-20160816; b=UYZ8K8POSbjTXfiGFhGkyeuOVbHL9nELdyCfboBsi/sO77tHqiuVW1mRI785KtVQdI l4VLay9qFcqp0ZlrwKXkCjT07MMAsA4Vm6qMn5uxVdUplTVCXrtRujH7OFCmzq7nuAyx gBIyxOpD99nML3uAVOLD9BzyfHKvVon3b4T9GDNYxHlG9rb0D3eKpcjHd5vFAYiA6Mxx CBUEu+Sk+qLvrXlFn/F4NvQBQTYg0qhh4NuxhuNHmljhFo3Co4gac0BRtjFKdeRXTgUS S7R6b19FmZIyrvNcBC2pGSwpMxmonmkjrXhP8JxeQIAaD6lI69leDnFm/v7Ypovm8Bx3 KzhQ== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=zMNOpSkIwslhII23SeMIcJh3nG19salcko4WcvTeTMo=; b=KInLy1tfwe4deD1N2Q/AnHVM+LUEvw2cMMvZtFBCiyXEcH8VuiSm/z5Uaf0Sg667V7 6W94q5nkVUSb5QKz3p03RYl+J84RracziLarCDjbQdtkOE4KfPCFDb2t0KsgpTeO0FMq I5Pq3yJw4Dd88np7mRPVpU1QGqe23hlBP7IkKO07iZbcWdNTc5DE5NL8JjRfzzeADAqu BJclNpiIEdRIURsR2W2kmRiqzKo3pogigdrJuiMIp/q0/APL+9Xw0/36v6d5rbLxWTTe QtZ5BkXsK3xORgp/aKsPDZyJrDqbyD29/Lw7DAZ59jI+c7Mvx6gnPLZ+jODfSTrd+3WM 2LMg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v24si15848168edq.156.2019.09.13.02.46.28; Fri, 13 Sep 2019 02:46:51 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729164AbfIMIHK (ORCPT + 99 others); Fri, 13 Sep 2019 04:07:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45978 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728237AbfIMIHJ (ORCPT ); Fri, 13 Sep 2019 04:07:09 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C7EFF30655F9; Fri, 13 Sep 2019 08:07:08 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E23360C63; Fri, 13 Sep 2019 08:07:08 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 6171A9D75; Fri, 13 Sep 2019 10:07:07 +0200 (CEST) Date: Fri, 13 Sep 2019 10:07:07 +0200 From: Gerd Hoffmann To: Tomasz Figa Cc: David Airlie , Daniel Vetter , dri-devel , virtualization@lists.linux-foundation.org, Linux Kernel Mailing List , stevensd@chromium.org, =?utf-8?B?U3TDqXBoYW5l?= Marchesin , Zach Reizner , Keiichi Watanabe , Pawel Osciak Subject: Re: [RFC PATCH] drm/virtio: Export resource handles via DMA-buf API Message-ID: <20190913080707.unhyoezesvfhx5np@sirius.home.kraxel.org> References: <20190912094121.228435-1-tfiga@chromium.org> <20190912123821.rraib5entkcxt5p5@sirius.home.kraxel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 13 Sep 2019 08:07:09 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, > > > To seamlessly enable buffer sharing with drivers using such frameworks, > > > make the virtio-gpu driver expose the resource handle as the DMA address > > > of the buffer returned from the DMA-buf mapping operation. Arguably, the > > > resource handle is a kind of DMA address already, as it is the buffer > > > identifier that the device needs to access the backing memory, which is > > > exactly the same role a DMA address provides for native devices. > > First of all, thanks for taking a look at this. > > > No. A scatter list has guest dma addresses, period. Stuffing something > > else into a scatterlist is asking for trouble, things will go seriously > > wrong when someone tries to use such a fake scatterlist as real scatterlist. > > What is a "guest dma address"? The definition of a DMA address in the > Linux DMA API is an address internal to the DMA master address space. > For virtio, the resource handle namespace may be such an address > space. No. DMA master address space in virtual machines is pretty much the same it is on physical machines. So, on x86 without iommu, identical to (guest) physical address space. You can't re-define it like that. > However, we could as well introduce a separate DMA address > space if resource handles are not the right way to refer to the memory > from other virtio devices. s/other virtio devices/other devices/ dma-bufs are for buffer sharing between devices, not limited to virtio. You can't re-define that in some virtio-specific way. > > Also note that "the DMA address of the buffer" is bonkers in virtio-gpu > > context. virtio-gpu resources are not required to be physically > > contigous in memory, so typically you actually need a scatter list to > > describe them. > > There is no such requirement even on a bare metal system, see any > system that has an IOMMU, which is typical on ARM/ARM64. The DMA > address space must be contiguous only from the DMA master point of > view. Yes, the iommu (if present) could remap your scatterlist that way. You can't depend on that though. What is the plan here? Host-side buffer sharing I guess? So you are looking for some way to pass buffer handles from the guest to the host, even in case those buffers are not created by your driver but imported from somewhere else? cheers, Gerd