Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3001133imm; Thu, 17 May 2018 01:26:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoHQyG2zlgx0wcmMWXezbGBu0Ot27wt6kjeAgIt9IReGS4Ad5Tfzp2EoIxTwS6+yTkhcye/ X-Received: by 2002:a63:5e44:: with SMTP id s65-v6mr3480483pgb.104.1526545615487; Thu, 17 May 2018 01:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526545615; cv=none; d=google.com; s=arc-20160816; b=BkoqbdBaBDDFudCb9hpav/bmPKCUnGiu7VXH+hdlJzFlGLkT0A+UcNj2TAOQVLj3zQ j2pwdsIGYywSaoxj8w08mYWwi6dX9AHwISTGhnMO+s+QeEha8ZGzjW2jE/lFIYnSTxxv 7osC+ZVlfTJ8OhfRKN3Sps4cfR3Rljp00Hi7UdTlxW2mPXfK4kvs8i2jo1yRTo2Z3k+e Wnfs1i8UdENqZTLBq04kTy29a+oRd6e9Q63GJkQdBraI//UOyvZMqH0rDsvHWYvyLlO8 b+3FGSfCkwq7YUkrE/FJfYVIT1Wbt8ivZeuLujEfxEzAYkYs8ho7yFF+qh6tTvPBnpUe eW8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=NKYkAjLr5t8nj2R5Fov298bb8GRY1jS5VbVk6EsYLL8=; b=fS+lRxiI9+zmmWXxQemzudEpAqI8PnlNQ0ETMsPqWLoBS4I8HVbJ+y1yFOzrUq4R/w u3KW+RJb9K07u3wPN0wHiFGvbYN7vquFGDAIOySRz98DCQ60mQXDpJaIRaEdy131/FgC EGLOJ2i/p5qylz2v8+Sh02Hpgflk4/WllebyYFCMVFjey1LIhiTaswGazp1DnoeTB4kd DLr7FpApv9Uob8B+3jM5EtIHTxPfN7aTtJLsuhQdb/pAMf/R1p+i3DTqYBPcvzIRhZn4 qo3juvCgbzrfkTCRl+GLAIBa7DBeMZ3+21fjJdFUuahCTK3Px34au+AaHlOOnJ85zGqJ n7lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qfuxlhzS; 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 z73-v6si4952977pfj.197.2018.05.17.01.26.41; Thu, 17 May 2018 01:26:55 -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=qfuxlhzS; 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 S1752455AbeEQI0W (ORCPT + 99 others); Thu, 17 May 2018 04:26:22 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36381 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752173AbeEQI0O (ORCPT ); Thu, 17 May 2018 04:26:14 -0400 Received: by mail-lf0-f68.google.com with SMTP id t129-v6so7460806lff.3; Thu, 17 May 2018 01:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NKYkAjLr5t8nj2R5Fov298bb8GRY1jS5VbVk6EsYLL8=; b=qfuxlhzSCwb7MV1if3/wFPLiGqDa69vIM10hY05tiGwP4XukKpWKx81GV+sV7uJggV 7kY16kZHPIEJ4wB/B2v1YMEZa3s+uMFvdH2DOWPAUik8vdVCYJEfCZDcAC/uYyubODo6 RibU5LVPVqlO+fGYQ3P9LCKtsOkzTN8C472e9ol05hls47HdMLqp8P6iSmfC7q860nb6 2cSMLzp92xblQweRiumqMwML/yTLqYU+n78QsLASO5f/UzHLfokG2KNRDfB+tNEcWaW/ +7vLXb1zLFBywAIL1F4sNuhJe/HWHxCW0PQmWMlH6erjKPsGAEhv7AONRNbZ9Urdq/QS AfMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NKYkAjLr5t8nj2R5Fov298bb8GRY1jS5VbVk6EsYLL8=; b=tXqhM3HuD1qDrXdiv+3ChAn9qEHrNgnmDYgk0IXmHue/Y2wdFOr5D2exXkne2P/P52 d3IIgS4TwiFrMpCnK4EsRtiF9h6r2dlGJb1CUeMgupAPqp4Jmcr37BsP+1Y1aEfT1ORZ 7ZdP56bzS9JG13IqtDn2VgyxivTCr4/Rtgvf4hbuV7/KoCgdt4lfIkjft0fu+PsQMiut P4rxlhhyQM9HKu7LjJAZ0gSvmfzM73GGlUD6zWksvMka+xPaZJsa+ZkauP1+1oH59Vn4 RgcRHz3nX9XiQdaSGf0jAXk7BQElRURXMdq5evJmlu15qr1VnoaLMU+V71/d7PmHaSi1 1WSQ== X-Gm-Message-State: ALKqPweq0JOJjr0X/3+S/k+PibQbNJqZRNTyG5lcJcvWw4cFYHQHYNoj qE+rr4X08TlGUuAI2bqbokI= X-Received: by 2002:a2e:81d0:: with SMTP id s16-v6mr2545708ljg.115.1526545572283; Thu, 17 May 2018 01:26:12 -0700 (PDT) Received: from a2k-HP-ProDesk-600-G2-SFF.kyiv.epam.com (ll-52.209.223.85.sovam.net.ua. [85.223.209.52]) by smtp.gmail.com with ESMTPSA id y1-v6sm1102381lfg.10.2018.05.17.01.26.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 May 2018 01:26:11 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, jgross@suse.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com Cc: daniel.vetter@intel.com, andr2000@gmail.com, dongwon.kim@intel.com, matthew.d.roper@intel.com, Oleksandr Andrushchenko Subject: [Xen-devel][RFC 0/3] dma-buf support for gntdev Date: Thu, 17 May 2018 11:26:01 +0300 Message-Id: <20180517082604.14828-1-andr2000@gmail.com> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 ballooning in/out 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 other memory, e.g. system pages). 2. Extension of the gntdev driver to enable it to import/export dma-buf’s. The first two patches in this series solve #1 and the last one is for #2. 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. *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 Oleksandr Andrushchenko (3): xen/balloon: Allow allocating DMA buffers xen/grant-table: Extend API to work with DMA buffers xen/gntdev: Add support for Linux dma buffers drivers/xen/balloon.c | 214 +++++++-- drivers/xen/gntdev.c | 954 +++++++++++++++++++++++++++++++++++++- drivers/xen/grant-table.c | 49 ++ drivers/xen/xen-balloon.c | 2 + include/uapi/xen/gntdev.h | 101 ++++ include/xen/balloon.h | 11 +- include/xen/gntdev_exp.h | 23 + include/xen/grant_table.h | 7 + 8 files changed, 1310 insertions(+), 51 deletions(-) create mode 100644 include/xen/gntdev_exp.h -- 2.17.0