Received: by 10.192.165.156 with SMTP id m28csp1571235imm; Tue, 17 Apr 2018 01:23:12 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+5km42q4cUzB4a1kLhPJGW6PumeqDpdqA2oA7xxxtjX0Udt1b0qeOvVXTdcVPP3nHO6JK4 X-Received: by 10.99.111.65 with SMTP id k62mr84256pgc.73.1523953392732; Tue, 17 Apr 2018 01:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523953392; cv=none; d=google.com; s=arc-20160816; b=aShiEsENZpyGrY9XnoGUmLNoBT08R8tyHJkBEHc/w0z+/4mPNStzvpEkzSWSOMDDbl vDMp2QciysTZyKA/35WOe042ap5tuVGmT2hpRafdIoB4BEfQQAWLYyxPm/GtP6QphenX dhIf8VhNb9ygVWcGA4WQDpkE4heTQnwwcVauK2ocVbDxPyHnLfhx/Szr7oz4UhqNzgXm pGN4fA+tH79TB8MIVGRqyZSo3anj/SztEiPRiLh9QP3FJ1IfDTPEOb6UcNjlXrcPgz8j x4BzdGI1iA2YEEkOH+DBvG5T2MwGFpA8Jz+GlRmzqtFLQgofbhtJaF+csxIyk61+tW+z 4+mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature :arc-authentication-results; bh=ichV6hO0VX+NPEx5HHOersWk6k1ViLpjI4E1VNm5ZK4=; b=RH4QpiXsHsLiRcctNEIQKB4v1Epc1YtCbwaE6T1JK+1K7aaz6v8OJdIgdmcvVxZV4A CglmtYsKSQgmD7zchELlQYxybnYtzmYkifdjAtQleUpnS1JgTODV3kt+cqcu2LnYsROZ AS4TLmiFF2hWfFwU6pnAOiMV8AA2sNlg0mzbLV1TFqYUNt60QdznZa9VkhT16YEZkkYe Yuen3fpGzbW0ysLWHsS9bPSsUyz0OMovUOw81Sievyh3ibeG9vdM0c9Vuvia+ITMbiVR sRlYXUCn6EquTP3kGHEZbntYASlgr9By4ZUHZdnkqN7GjlRNGUgj9AvcQIC7NhBxGbh1 dB1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ucB/iRZV; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 90-v6si14057028plf.340.2018.04.17.01.22.58; Tue, 17 Apr 2018 01:23:12 -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=@gmail.com header.s=20161025 header.b=ucB/iRZV; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752592AbeDQIVC (ORCPT + 99 others); Tue, 17 Apr 2018 04:21:02 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34241 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751096AbeDQITZ (ORCPT ); Tue, 17 Apr 2018 04:19:25 -0400 Received: by mail-lf0-f66.google.com with SMTP id r7-v6so18906598lfr.1 for ; Tue, 17 Apr 2018 01:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=ichV6hO0VX+NPEx5HHOersWk6k1ViLpjI4E1VNm5ZK4=; b=ucB/iRZVelHWm9WLKUx04/JViZQc/h0F3wxlrqz+31ghCavGZ/oQEzuxtm1Q6hcDc4 eSGBUaIb1kJujq093Pq01xXzjJeWjbpPqeb+L1VxxNoArPDlPJFnuH9crEJU7RUlBokG Htv7L6wKZdPk9PXaKE9/ROJDGY+6iopd8vGO29UsA5ALbLiPqUYT0MzYKNguWiQZ9Kmq +JNDEbgR0H6bZjDWDXlUs5V+5QPjX3K7QdYrZ3xFgeBugrO5i4AdgY6PuORzSTx/zmAF KbY0HzttsYP9YrEyRYilikesXXOjnQOAaqrx9KUO3flaTjuz8xmy62eS7KbMcwTfGcQU 7iVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=ichV6hO0VX+NPEx5HHOersWk6k1ViLpjI4E1VNm5ZK4=; b=Xee06eojPs2nWWdODxBilcbg2Bjnofdn0syb+Zb0lYPSwhzXcFWhCfMJgTpwtOvBch elNUZ/2VANxe/CeXITsNMZzH2MsT4Zg2j2iXLevo9PfJ4aeUyPaHtEuFMqS+Uaiji4Nu pjaA76sSEwlrnms+NAbZTte597zVxgFj/JYv1bm6xD9c9EClppmlwhy4c4ViGMlJ0lJi bHlBp664R3DedFhHly8P1euJVb8L/Bm86NOrven5aHZNnCI36Cc0PhXuwaJu1dCqOmLR hBwYWFxhLMMXz3LHNprzw5r6fX/ci1bpA0VW6A3LHps75kxNyEAf/c4tLxq8T7iIGfg5 Ygow== X-Gm-Message-State: ALQs6tCd4zIcUSf2tBmyrBgODHthJ0+e3U76O/pVUHKf01yMkdDyKLoB qNjknKP4nMx9VHK2fw4HIyo= X-Received: by 10.46.154.205 with SMTP id p13mr791445ljj.60.1523953163906; Tue, 17 Apr 2018 01:19:23 -0700 (PDT) Received: from [10.17.182.9] (ll-74.141.223.85.sovam.net.ua. [85.223.141.74]) by smtp.gmail.com with ESMTPSA id e6-v6sm3248830lfg.59.2018.04.17.01.19.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Apr 2018 01:19:23 -0700 (PDT) Subject: Re: [PATCH 0/1] drm/xen-zcopy: Add Xen zero-copy helper DRM driver To: Dongwon Kim , jgross@suse.com, Artem Mygaiev , konrad.wilk@oracle.com, airlied@linux.ie, Oleksandr Andrushchenko , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, "Potrola, MateuszX" , daniel.vetter@intel.com, xen-devel@lists.xenproject.org, boris.ostrovsky@oracle.com References: <20180329131931.29957-1-andr2000@gmail.com> <5d8fec7f-956c-378f-be90-f45029385740@gmail.com> <20180416192905.GA18096@downor-Z87X-UD5H> <20180417075928.GT31310@phenom.ffwll.local> From: Oleksandr Andrushchenko Message-ID: Date: Tue, 17 Apr 2018 11:19:22 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180417075928.GT31310@phenom.ffwll.local> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/17/2018 10:59 AM, Daniel Vetter wrote: > On Mon, Apr 16, 2018 at 12:29:05PM -0700, Dongwon Kim wrote: >> Yeah, I definitely agree on the idea of expanding the use case to the >> general domain where dmabuf sharing is used. However, what you are >> targetting with proposed changes is identical to the core design of >> hyper_dmabuf. >> >> On top of this basic functionalities, hyper_dmabuf has driver level >> inter-domain communication, that is needed for dma-buf remote tracking >> (no fence forwarding though), event triggering and event handling, extra >> meta data exchange and hyper_dmabuf_id that represents grefs >> (grefs are shared implicitly on driver level) > This really isn't a positive design aspect of hyperdmabuf imo. The core > code in xen-zcopy (ignoring the ioctl side, which will be cleaned up) is > very simple & clean. > > If there's a clear need later on we can extend that. But for now xen-zcopy > seems to cover the basic use-case needs, so gets the job done. After we decided to remove DRM PRIME code from the zcopy driver I think we can extend the existing Xen drivers instead of introducing a new one: gntdev [1], [2] - to handle export/import of the dma-bufs to/from grefs balloon [3] - to allow allocating CMA buffers >> Also it is designed with frontend (common core framework) + backend >> (hyper visor specific comm and memory sharing) structure for portability. >> We just can't limit this feature to Xen because we want to use the same >> uapis not only for Xen but also other applicable hypervisor, like ACORN. > See the discussion around udmabuf and the needs for kvm. I think trying to > make an ioctl/uapi that works for multiple hypervisors is misguided - it > likely won't work. > > On top of that the 2nd hypervisor you're aiming to support is ACRN. That's > not even upstream yet, nor have I seen any patches proposing to land linux > support for ACRN. Since it's not upstream, it doesn't really matter for > upstream consideration. I'm doubting that ACRN will use the same grant > references as xen, so the same uapi won't work on ACRN as on Xen anyway. > >> So I am wondering we can start with this hyper_dmabuf then modify it for >> your use-case if needed and polish and fix any glitches if we want to >> to use this for all general dma-buf usecases. > Imo xen-zcopy is a much more reasonable starting point for upstream, which > can then be extended (if really proven to be necessary). > >> Also, I still have one unresolved question regarding the export/import flow >> in both of hyper_dmabuf and xen-zcopy. >> >> @danvet: Would this flow (guest1->import existing dmabuf->share underlying >> pages->guest2->map shared pages->create/export dmabuf) be acceptable now? > I think if you just look at the pages, and make sure you handle the > sg_page == NULL case it's ok-ish. It's not great, but mostly it should > work. The real trouble with hyperdmabuf was the forwarding of all these > calls, instead of just passing around a list of grant references. > -Daniel > >> Regards, >> DW >> >> On Mon, Apr 16, 2018 at 05:33:46PM +0300, Oleksandr Andrushchenko wrote: >>> Hello, all! >>> >>> After discussing xen-zcopy and hyper-dmabuf [1] approaches Even more context for the discussion [4], so Xen community can catch up >>> it seems that xen-zcopy can be made not depend on DRM core any more >>> >>> and be dma-buf centric (which it in fact is). >>> >>> The DRM code was mostly there for dma-buf's FD import/export >>> >>> with DRM PRIME UAPI and with DRM use-cases in mind, but it comes out that if >>> >>> the proposed 2 IOCTLs (DRM_XEN_ZCOPY_DUMB_FROM_REFS and >>> DRM_XEN_ZCOPY_DUMB_TO_REFS) >>> >>> are extended to also provide a file descriptor of the corresponding dma-buf, >>> then >>> >>> PRIME stuff in the driver is not needed anymore. >>> >>> That being said, xen-zcopy can safely be detached from DRM and moved from >>> >>> drivers/gpu/drm/xen into drivers/xen/dma-buf-backend(?). >>> >>> This driver then becomes a universal way to turn any shared buffer between >>> Dom0/DomD >>> >>> and DomU(s) into a dma-buf, e.g. one can create a dma-buf from any grant >>> references >>> >>> or represent a dma-buf as grant-references for export. >>> >>> This way the driver can be used not only for DRM use-cases, but also for >>> other >>> >>> use-cases which may require zero copying between domains. >>> >>> For example, the use-cases we are about to work in the nearest future will >>> use >>> >>> V4L, e.g. we plan to support cameras, codecs etc. and all these will benefit >>> >>> from zero copying much. Potentially, even block/net devices may benefit, >>> >>> but this needs some evaluation. >>> >>> >>> I would love to hear comments for authors of the hyper-dmabuf >>> >>> and Xen community, as well as DRI-Devel and other interested parties. >>> >>> >>> Thank you, >>> >>> Oleksandr >>> >>> >>> On 03/29/2018 04:19 PM, Oleksandr Andrushchenko wrote: >>>> From: Oleksandr Andrushchenko >>>> >>>> Hello! >>>> >>>> When using Xen PV DRM frontend driver then on backend side one will need >>>> to do copying of display buffers' contents (filled by the >>>> frontend's user-space) into buffers allocated at the backend side. >>>> Taking into account the size of display buffers and frames per seconds >>>> it may result in unneeded huge data bus occupation and performance loss. >>>> >>>> This helper driver allows implementing zero-copying use-cases >>>> when using Xen para-virtualized frontend display driver by >>>> implementing a DRM/KMS helper driver running on backend's side. >>>> It utilizes PRIME buffers API to share frontend's buffers with >>>> physical device drivers on backend's side: >>>> >>>> - a dumb buffer created on backend's side can be shared >>>> with the Xen PV frontend driver, so it directly writes >>>> into backend's domain memory (into the buffer exported from >>>> DRM/KMS driver of a physical display device) >>>> - a dumb buffer allocated by the frontend can be imported >>>> into physical device DRM/KMS driver, thus allowing to >>>> achieve no copying as well >>>> >>>> For that reason number of IOCTLs are introduced: >>>> - DRM_XEN_ZCOPY_DUMB_FROM_REFS >>>> This will create a DRM dumb buffer from grant references provided >>>> by the frontend >>>> - DRM_XEN_ZCOPY_DUMB_TO_REFS >>>> This will grant references to a dumb/display buffer's memory provided >>>> by the backend >>>> - DRM_XEN_ZCOPY_DUMB_WAIT_FREE >>>> This will block until the dumb buffer with the wait handle provided >>>> be freed >>>> >>>> With this helper driver I was able to drop CPU usage from 17% to 3% >>>> on Renesas R-Car M3 board. >>>> >>>> This was tested with Renesas' Wayland-KMS and backend running as DRM master. >>>> >>>> Thank you, >>>> Oleksandr >>>> >>>> Oleksandr Andrushchenko (1): >>>> drm/xen-zcopy: Add Xen zero-copy helper DRM driver >>>> >>>> Documentation/gpu/drivers.rst | 1 + >>>> Documentation/gpu/xen-zcopy.rst | 32 + >>>> drivers/gpu/drm/xen/Kconfig | 25 + >>>> drivers/gpu/drm/xen/Makefile | 5 + >>>> drivers/gpu/drm/xen/xen_drm_zcopy.c | 880 ++++++++++++++++++++++++++++ >>>> drivers/gpu/drm/xen/xen_drm_zcopy_balloon.c | 154 +++++ >>>> drivers/gpu/drm/xen/xen_drm_zcopy_balloon.h | 38 ++ >>>> include/uapi/drm/xen_zcopy_drm.h | 129 ++++ >>>> 8 files changed, 1264 insertions(+) >>>> create mode 100644 Documentation/gpu/xen-zcopy.rst >>>> create mode 100644 drivers/gpu/drm/xen/xen_drm_zcopy.c >>>> create mode 100644 drivers/gpu/drm/xen/xen_drm_zcopy_balloon.c >>>> create mode 100644 drivers/gpu/drm/xen/xen_drm_zcopy_balloon.h >>>> create mode 100644 include/uapi/drm/xen_zcopy_drm.h >>>> >>> [1] >>> https://lists.xenproject.org/archives/html/xen-devel/2018-02/msg01202.html >> _______________________________________________ >> dri-devel mailing list >> dri-devel@lists.freedesktop.org >> https://lists.freedesktop.org/mailman/listinfo/dri-devel [1] https://elixir.bootlin.com/linux/v4.17-rc1/source/include/uapi/xen/gntdev.h [2] https://elixir.bootlin.com/linux/v4.17-rc1/source/drivers/xen/gntdev.c [3] https://elixir.bootlin.com/linux/v4.17-rc1/source/drivers/xen/balloon.c [4] https://lkml.org/lkml/2018/4/16/355