Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3526832imm; Mon, 2 Jul 2018 00:14:13 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeQxyZNBLCJ7qCD/VP2eDQ4PcBE8jgDuq53/cRdhtP6Srp8L2Cacssf6TzNeCSPxSX/NNJM X-Received: by 2002:a62:e413:: with SMTP id r19-v6mr6122569pfh.25.1530515653505; Mon, 02 Jul 2018 00:14:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530515653; cv=none; d=google.com; s=arc-20160816; b=aFn1CzNMN31GlwC3YpTLb/x0LjUh3yHDKYGwzIHkl2xCLLsB9FJLqz/jMQ+I+J5o1A el7w4zwIbsBR4RvqLwnnrNQyzfgbJYcsSEMN39bhWMaEeBndbVhZjG2kGJSt+xwkYYrm zfdcy8MC94s/6CuVKFjG8IzUhgjWOa/ompcsBe4viw1HFig8IUJncCwzDPQmBOnblOkQ jpnkNiJTIHgYUFvu2Tx2xfPBZqfSLZ+WJly0HHCnqejQiKO6ClW3KJcgOhBGsLRiY8sj PJg2Vl4Hvzf+VTGp4sqUN2MrrYjTy3FjTh4OWcZCBWrr/JP+DTQwJt6gnqJTN31+pZrK +YOw== 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:cc:to:subject:dkim-signature :arc-authentication-results; bh=BIAAFO3iQKAKWzJtISxWpnXzMpOBAIcz2CHp8KgDP0Q=; b=ig+M0B1HF10KC+6VwuXrcGqlc67hDnaepFu5SIJ242KFWEI9RIK1R+wS/ea6xvVBbE uOJbCkvkYLhKDMO/STuuSy3m2fTRWkEaVXtJ/mJs9mFYOktxPhg2oceSlUczmbZ0mVQU fh96Pk5LzGE1x3BbPhyJoJOeHQRQYQrIO9A553JDOR8DqvffE5b//woMp2kyCA7jWNt6 0tlP2vsV25tYBvuVbceqvsItbvbxgpBhGfum9Z+KvKlL/91AX23DOmFUS2gcR7uadwwG fgbynR3xF4wEEyPa8s5kttRbp5pvB1OT+L3lus7WeLjJoS+ewA1nHNY1l1+Iqparpdl8 Bx6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YMFgCrOf; 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 33-v6si15718611ply.344.2018.07.02.00.13.58; Mon, 02 Jul 2018 00:14:13 -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=YMFgCrOf; 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 S1753407AbeGBHLA (ORCPT + 99 others); Mon, 2 Jul 2018 03:11:00 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:34432 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751420AbeGBHK4 (ORCPT ); Mon, 2 Jul 2018 03:10:56 -0400 Received: by mail-lf0-f68.google.com with SMTP id n96-v6so11165871lfi.1; Mon, 02 Jul 2018 00:10:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=BIAAFO3iQKAKWzJtISxWpnXzMpOBAIcz2CHp8KgDP0Q=; b=YMFgCrOf+IQ+5Nk43LY0rbKKYTjHH4pBdrY8v1/Zb6GmKpKs+5cRQQof9MgE413SsY hEce/f1wCPTPPd1B1W5yMctgud3R6Fl3g4febEEEUJ34OHMm/RTyIasKIzYNMqd7ir+8 TRGHpUUpCxSTjKujkO5rUtUfZ8IcUhnqKYJs3tId480hLC7p+gYuNNTyTJYdoP0wseuI 1qO+JtAnVqqJjrH5ubA2SG8Gg2l1h+Xp7y77zATz4DoVr71v8Xh7/ynyw1vci7KWDudK i5lxzMNdzRBPoRg7/Z8VUG0k7QBez6Zc0PnedXeB+67CNmoqHtgqFplTkLm0PHCaR8jf 7rMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=BIAAFO3iQKAKWzJtISxWpnXzMpOBAIcz2CHp8KgDP0Q=; b=KGnqHkTR824K24JUOFn4ac38FscE+E50qlMhpYjAKhS8WJes6qjDKgZFXhubW94jch n/0HgY8YZtz8j7BBrl018tZRp53HG5NmAC78FXbx3bKhNrgzb7Dy9yx3LY1FX+SFLh/e QAw364B1M2uB7c4RF6hoBn0KbTKAHg3cCUOH1YqN45tNFsGiXWy4mSam/7gTQxROmUgS gwIfEd1Op4dgLlqVUgrgQfO+ctipSdKvpq45sar5U2ZEyRKyABawKj1JljRbOMGQG3CE nlxnUHhTXGdrKni1jf0cCkxsKRUw4fPBibA2Jojqd8K2h2tQoRWzE8IrinrDJoHNexF1 F5ZA== X-Gm-Message-State: APt69E2xNb7vzPMTjYDNRHTKSiFSmqrfAT+JdSRvDZ6BJtXHBbVVegzU VWQsyGnsxIIGBetuzYtyt24= X-Received: by 2002:a19:ca09:: with SMTP id a9-v6mr6079293lfg.142.1530515454211; Mon, 02 Jul 2018 00:10:54 -0700 (PDT) Received: from [10.17.182.9] (ll-53.209.223.85.sovam.net.ua. [85.223.209.53]) by smtp.gmail.com with ESMTPSA id n79-v6sm2850159lfi.51.2018.07.02.00.10.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 00:10:53 -0700 (PDT) Subject: Re: [PATCH v4 0/9] xen: dma-buf support for grant device To: jgross@suse.com, boris.ostrovsky@oracle.com Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, konrad.wilk@oracle.com, daniel.vetter@intel.com, dongwon.kim@intel.com, matthew.d.roper@intel.com, Oleksandr Andrushchenko References: <20180615062753.9229-1-andr2000@gmail.com> From: Oleksandr Andrushchenko Message-ID: <0d314f2f-e0c1-1017-5ba9-83489038b544@gmail.com> Date: Mon, 2 Jul 2018 10:10:52 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180615062753.9229-1-andr2000@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Boris, Juergen! Do you think I can re-base the series (which already has all required R-b's from Xen community) onto the latest kernel with API changes to patches 5 (of_dma_configure) and 8 (dma-buf atomic ops) and we can merge it to the Xen's kernel tree? It seems like no other reviews or objections are there so this seems reasonable to me now. Thank you, Oleksandr On 06/15/2018 09:27 AM, Oleksandr Andrushchenko wrote: > From: Oleksandr Andrushchenko > > This work is in response to my previous attempt to introduce Xen/DRM > zero-copy driver [1] to enable Linux dma-buf API [2] for Xen based > frontends/backends. There is also an existing hyper_dmabuf approach > available [3] which, if reworked to utilize the proposed solution, > can greatly benefit as well. > > RFC for this series was published and discussed [9], comments addressed. > > The original rationale behind this work was to enable zero-copying > use-cases while working with Xen para-virtual display driver [4]: > 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 > second it may result in unneeded huge data bus occupation and > performance loss. > > The helper driver [4] 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 (implemented on top of Linux dma-buf) > 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 > > Finally, it was discussed and decided ([1], [5]) that it is worth > implementing such use-cases via extension of the existing Xen gntdev > driver instead of introducing new DRM specific driver. > Please note, that the support of dma-buf is Linux only, > as dma-buf is a Linux only thing. > > Now to the proposed solution. The changes to the existing Xen drivers > in the Linux kernel fall into 2 categories: > 1. DMA-able memory buffer allocation and increasing/decreasing memory > reservation of the pages of such a buffer. > This is required if we are about to share dma-buf with the hardware > that does require those to be allocated with dma_alloc_xxx API. > (It is still possible to allocate a dma-buf from any system memory, > e.g. system pages). > 2. Extension of the gntdev driver to enable it to import/export dma-buf’s. > > The first six patches are in preparation for Xen dma-buf support, > but I consider those usable regardless of the dma-buf use-case, > e.g. other frontend/backend kernel modules may also benefit from these > for better code reuse: > 0001-xen-grant-table-Export-gnttab_-alloc-free-_pages-as-.patch > 0002-xen-grant-table-Make-set-clear-page-private-code-sha.patch > 0003-xen-balloon-Share-common-memory-reservation-routines.patch > 0004-xen-grant-table-Allow-allocating-buffers-suitable-fo.patch > 0005-xen-gntdev-Allow-mappings-for-DMA-buffers.patch > 0006-xen-gntdev-Make-private-routines-structures-accessib.patch > > The next three patches are Xen implementation of dma-buf as part of > the grant device: > 0007-xen-gntdev-Add-initial-support-for-dma-buf-UAPI.patch > 0008-xen-gntdev-Implement-dma-buf-export-functionality.patch > 0009-xen-gntdev-Implement-dma-buf-import-functionality.patch > > The corresponding libxengnttab changes are available at [6]. > > All the above was tested with display backend [7] and its accompanying > helper library [8] on Renesas ARM64 based board. > Basic balloon tests on x86. > > *To all the communities*: I would like to ask you to review the proposed > solution and give feedback on it, so I can improve and send final > patches for review (this is still work in progress, but enough to start > discussing the implementation). > > Thank you in advance, > Oleksandr Andrushchenko > > [1] https://lists.freedesktop.org/archives/dri-devel/2018-April/173163.html > [2] https://elixir.bootlin.com/linux/v4.17-rc5/source/Documentation/driver-api/dma-buf.rst > [3] https://lists.xenproject.org/archives/html/xen-devel/2018-02/msg01202.html > [4] https://cgit.freedesktop.org/drm/drm-misc/tree/drivers/gpu/drm/xen > [5] https://patchwork.kernel.org/patch/10279681/ > [6] https://github.com/andr2000/xen/tree/xen_dma_buf_v1 > [7] https://github.com/andr2000/displ_be/tree/xen_dma_buf_v1 > [8] https://github.com/andr2000/libxenbe/tree/xen_dma_buf_v1 > [9] https://lkml.org/lkml/2018/5/17/215 > > Changes since v3: > ***************** > - added r-b tags > - minor fixes > - removed gntdev_remove_map as it can be coded directly now > - moved IOCTL code to gntdev-dmabuf.c > - removed usless wait list walks and changed some walks to use > normal version of list iterators instead of safe ones as > we run under a lock anyways > - cleaned up comments, descriptions, pr_debug messages > > Changes since v2: > ***************** > - fixed missed break in dmabuf_exp_wait_obj_signal > - re-worked debug and error messages, be less verbose > - removed patch for making gntdev functions available to other drivers > - removed WARN_ON's in dma-buf code > - moved all dma-buf related code into gntdev-dmabuf > - introduced gntdev-common.h with common structures and function prototypes > - added additional checks for number of grants in IOCTLs > - gnttab patch cleanup > - made xenmem_reservation_scrub_page defined in the header as inline > - fixed __pfn_to_mfn use to pfn_to_bfn > - no changes to patches 1-2 > > Changes since v1: > ***************** > - Define GNTDEV_DMA_FLAG_XXX starting from bit 0 > - Rename mem_reservation.h to mem-reservation.h > - Remove usless comments > - Change licenses from GPLv2 OR MIT to GPLv2 only > - Make xenmem_reservation_va_mapping_{update|clear} inline > - Change EXPORT_SYMBOL to EXPORT_SYMBOL_GPL for new functions > - Make gnttab_dma_{alloc|free}_pages to request frames array > be allocated outside > - Fixe gnttab_dma_alloc_pages fail path (added xenmem_reservation_increase) > - Move most of dma-buf from gntdev.c to gntdev-dmabuf.c > - Add required dependencies to Kconfig > - Rework "#ifdef CONFIG_XEN_XXX" for if/else > - Export gnttab_{alloc|free}_pages as GPL symbols (patch 1) > > Oleksandr Andrushchenko (9): > xen/grant-table: Export gnttab_{alloc|free}_pages as GPL > xen/grant-table: Make set/clear page private code shared > xen/balloon: Share common memory reservation routines > xen/grant-table: Allow allocating buffers suitable for DMA > xen/gntdev: Allow mappings for DMA buffers > xen/gntdev: Make private routines/structures accessible > xen/gntdev: Add initial support for dma-buf UAPI > xen/gntdev: Implement dma-buf export functionality > xen/gntdev: Implement dma-buf import functionality > > drivers/xen/Kconfig | 24 + > drivers/xen/Makefile | 2 + > drivers/xen/balloon.c | 75 +-- > drivers/xen/gntdev-common.h | 94 ++++ > drivers/xen/gntdev-dmabuf.c | 870 ++++++++++++++++++++++++++++++++++ > drivers/xen/gntdev-dmabuf.h | 33 ++ > drivers/xen/gntdev.c | 220 ++++++--- > drivers/xen/grant-table.c | 153 +++++- > drivers/xen/mem-reservation.c | 118 +++++ > include/uapi/xen/gntdev.h | 106 +++++ > include/xen/grant_table.h | 21 + > include/xen/mem-reservation.h | 59 +++ > 12 files changed, 1615 insertions(+), 160 deletions(-) > create mode 100644 drivers/xen/gntdev-common.h > create mode 100644 drivers/xen/gntdev-dmabuf.c > create mode 100644 drivers/xen/gntdev-dmabuf.h > create mode 100644 drivers/xen/mem-reservation.c > create mode 100644 include/xen/mem-reservation.h >