Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1295404imm; Thu, 6 Sep 2018 20:11:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaKARPY7/O+15ZD0dd3rUUy1dQI0Sv2fPAETfdbAzlYHD09bVcm3JR8PAS1xIwD5/9m4+xQ X-Received: by 2002:a17:902:5a87:: with SMTP id r7-v6mr5760777pli.247.1536289892130; Thu, 06 Sep 2018 20:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536289892; cv=none; d=google.com; s=arc-20160816; b=yIbQ3rQu9W9wfTueNHuGT6wkZ6EEInNf3E8IzsFZU6+er9/usd/oW4f1fpYk/gNFn+ 0Sbc/aWqRAKdY9u4iAh6RFJcDzf8UCPGXGn8k/VgiQigk9Vd6n5pxYQ8zDLI8a6epNcV Ylxen9nm9x+m3DrI4/bAIKYv0o4/GZM+XCAtC8APi5xzpnqPtuhqo9Kj6b5SgNANp1d/ bzPD8DVQnRiXmZo5EjHGB+kL7i8SMY3ZeZewYO/JCwjixpLnhdvmc9QWApyInrLZR2CU WBGtgI9RHxypGQ1Pwsm0OFzekvgjLtRpBbVjXO8+QdH01YDgKEJqHXxyXVvNvBSDI1kU 73rQ== 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:message-id:subject:cc:to:from:date; bh=ZEhmuNp1K85NjPa1hemZuE55euyd/5v8zxhnEp2L9zY=; b=cu99BrZYh7gR63iylrGEcF5MUAI1IlHzgBFQrOWWziYaOtuPr8+BbUDN8K8cVbUnpM gIBQ5LjTokSiJWnUWI2DGmL32SUz/WNI/ZqXLZln/7u7d50yxZfSN96sSHhhYjOxEAKR /udnTEReFhAgGIV8YFJ9FOVgDjwW0G8WHUTKgoCFZRZMq8qqfAbMQlTJmpJUhdhoRvMp zexasCTqfSnQM82D2tmmUNOHJo5FoZb42rolaf0NpmvYx3uKmlBl9Fulq2xWtuCNufgU JhGmQlSfPPA8C6LolO7Fd25Eoy1lIpd0THbgac3+ZAT4y5qMZgYA6nJycxUvZoFBjv5k Hkaw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v61-v6si6381414plb.448.2018.09.06.20.11.17; Thu, 06 Sep 2018 20:11:32 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729083AbeIGHBn (ORCPT + 99 others); Fri, 7 Sep 2018 03:01:43 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:41321 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726293AbeIGHBn (ORCPT ); Fri, 7 Sep 2018 03:01:43 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 799F2EC87F2AA; Fri, 7 Sep 2018 10:23:09 +0800 (CST) Received: from localhost (10.67.212.75) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server (TLS) id 14.3.399.0; Fri, 7 Sep 2018 10:23:03 +0800 Date: Fri, 7 Sep 2018 10:21:15 +0800 From: Kenneth Lee To: Randy Dunlap CC: Kenneth Lee , Jonathan Corbet , Herbert Xu , "David S . Miller" , Joerg Roedel , Alex Williamson , Hao Fang , Zhou Wang , Zaibo Xu , Philippe Ombredanne , Greg Kroah-Hartman , Thomas Gleixner , , , , , , , Lu Baolu , Sanjay Kumar , Subject: Re: [PATCH 1/7] vfio/sdmdev: Add documents for WarpDrive framework Message-ID: <20180907022115.GH230707@Turing-Arch-b> References: <20180903005204.26041-1-nek.in.cn@gmail.com> <20180903005204.26041-2-nek.in.cn@gmail.com> <56f5f66d-f6d9-f4fa-40ca-e4a8bad170c1@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <56f5f66d-f6d9-f4fa-40ca-e4a8bad170c1@infradead.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 06, 2018 at 11:36:36AM -0700, Randy Dunlap wrote: > Date: Thu, 6 Sep 2018 11:36:36 -0700 > From: Randy Dunlap > To: Kenneth Lee , Jonathan Corbet , > Herbert Xu , "David S . Miller" > , Joerg Roedel , Alex Williamson > , Kenneth Lee , Hao > Fang , Zhou Wang , Zaibo Xu > , Philippe Ombredanne , Greg > Kroah-Hartman , Thomas Gleixner > , linux-doc@vger.kernel.org, > linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, > iommu@lists.linux-foundation.org, kvm@vger.kernel.org, > linux-accelerators@lists.ozlabs.org, Lu Baolu , > Sanjay Kumar > CC: linuxarm@huawei.com > Subject: Re: [PATCH 1/7] vfio/sdmdev: Add documents for WarpDrive framework > User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 > Thunderbird/52.9.1 > Message-ID: <56f5f66d-f6d9-f4fa-40ca-e4a8bad170c1@infradead.org> > > Hi, > > On 09/02/2018 05:51 PM, Kenneth Lee wrote: > > From: Kenneth Lee > > > > WarpDrive is a common user space accelerator framework. Its main component > > in Kernel is called sdmdev, Share Domain Mediated Device. It exposes > > the hardware capabilities to the user space via vfio-mdev. So processes in > > user land can obtain a "queue" by open the device and direct access the > > hardware MMIO space or do DMA operation via VFIO interface. > > > > WarpDrive is intended to be used with Jean Philippe Brucker's SVA > > patchset to support multi-process. But This is not a must. Without the > > SVA patches, WarpDrive can still work for one process for every hardware > > device. > > > > This patch add detail documents for the framework. > > > > Signed-off-by: Kenneth Lee > > --- > > Documentation/00-INDEX | 2 + > > Documentation/warpdrive/warpdrive.rst | 100 ++++ > > Documentation/warpdrive/wd-arch.svg | 728 ++++++++++++++++++++++++++ > > 3 files changed, 830 insertions(+) > > create mode 100644 Documentation/warpdrive/warpdrive.rst > > create mode 100644 Documentation/warpdrive/wd-arch.svg > > > diff --git a/Documentation/warpdrive/warpdrive.rst b/Documentation/warpdrive/warpdrive.rst > > new file mode 100644 > > index 000000000000..6d2a5d1e08c4 > > --- /dev/null > > +++ b/Documentation/warpdrive/warpdrive.rst > > @@ -0,0 +1,100 @@ > > +Introduction of WarpDrive > > +========================= > > + > > +*WarpDrive* is a general accelerator framework for user space. It intends to > > +provide interface for the user process to send request to hardware > > +accelerator without heavy user-kernel interaction cost. > > + > > +The *WarpDrive* user library is supposed to provide a pipe-based API, such as: > > Do you say "is supposed to" because it doesn't do that (yet)? > Or you could just change that to say: > > The WarpDrive user library provides a pipe-based API, such as: > Actually, I tried to say it can be defined like this. But people can choose other implementation with the same kernel API. I will say it explicitly in the future version. Thank you. > > > + :: > > + int wd_request_queue(struct wd_queue *q); > > + void wd_release_queue(struct wd_queue *q); > > + > > + int wd_send(struct wd_queue *q, void *req); > > + int wd_recv(struct wd_queue *q, void **req); > > + int wd_recv_sync(struct wd_queue *q, void **req); > > + int wd_flush(struct wd_queue *q); > > + > > +*wd_request_queue* creates the pipe connection, *queue*, between the > > +application and the hardware. The application sends request and pulls the > > +answer back by asynchronized wd_send/wd_recv, which directly interact with the > > +hardware (by MMIO or share memory) without syscall. > > + > > +*WarpDrive* maintains a unified application address space among all involved > > +accelerators. With the following APIs: :: > > Seems like an extra '.' there. How about: > > accelerators with the following APIs: :: > Err, the "with..." clause belong to the following "The referred process space...". > > + > > + int wd_mem_share(struct wd_queue *q, const void *addr, > > + size_t size, int flags); > > + void wd_mem_unshare(struct wd_queue *q, const void *addr, size_t size); > > + > > +The referred process space shared by these APIs can be directly referred by the > > +hardware. The process can also dedicate its whole process space with flags, > > +*WD_SHARE_ALL* (not in this patch yet). > > + > > +The name *WarpDrive* is simply a cool and general name meaning the framework > > +makes the application faster. As it will be explained in this text later, the > > +facility in kernel is called *SDMDEV*, namely "Share Domain Mediated Device". > > + > > + > > +How does it work > > +================ > > + > > +*WarpDrive* is built upon *VFIO-MDEV*. The queue is wrapped as *mdev* in VFIO. > > +So memory sharing can be done via standard VFIO standard DMA interface. > > + > > +The architecture is illustrated as follow figure: > > + > > +.. image:: wd-arch.svg > > + :alt: WarpDrive Architecture > > + > > +Accelerator driver shares its capability via *SDMDEV* API: :: > > + > > + vfio_sdmdev_register(struct vfio_sdmdev *sdmdev); > > + vfio_sdmdev_unregister(struct vfio_sdmdev *sdmdev); > > + vfio_sdmdev_wake_up(struct spimdev_queue *q); > > + > > +*vfio_sdmdev_register* is a helper function to register the hardware to the > > +*VFIO_MDEV* framework. The queue creation is done by *mdev* creation interface. > > + > > +*WarpDrive* User library mmap the mdev to access its mmio space and shared > > s/mmio/MMIO/ > > > +memory. Request can be sent to, or receive from, hardware in this mmap-ed > > +space until the queue is full or empty. > > + > > +The user library can wait on the queue by ioctl(VFIO_SDMDEV_CMD_WAIT) the mdev > > +if the queue is full or empty. If the queue status is changed, the hardware > > +driver use *vfio_sdmdev_wake_up* to wake up the waiting process. > > + > > + > > +Multiple processes support > > +========================== > > + > > +In the latest mainline kernel (4.18) when this document is written, > > +multi-process is not supported in VFIO yet. > > + > > +Jean Philippe Brucker has a patchset to enable it[1]_. We have tested it > > +with our hardware (which is known as *D06*). It works well. *WarpDrive* rely > > +on them to support multiple processes. If it is not enabled, *WarpDrive* can > > +still work, but it support only one mdev for a process, which will share the > > +same io map table with kernel. (But it is not going to be a security problem, > > +since the user application cannot access the kernel address space) > > + > > +When multiprocess is support, mdev can be created based on how many > > +hardware resource (queue) is available. Because the VFIO framework accepts only > > +one open from one mdev iommu_group. Mdev become the smallest unit for process > > +to use queue. And the mdev will not be released if the user process exist. So > > +it will need a resource agent to manage the mdev allocation for the user > > +process. This is not in this document's range. > > + > > + > > +Legacy Mode Support > > +=================== > > +For the hardware on which IOMMU is not support, WarpDrive can run on *NOIOMMU* > > +mode. That require some update to the mdev driver, which is not included in > > +this version yet. > > + > > + > > +References > > +========== > > +.. [1] https://patchwork.kernel.org/patch/10394851/ > > + > > +.. vim: tw=78 > > thanks, > -- > ~Randy -- -Kenneth(Hisilicon) ================================================================================ 本邮件及其附件含有华为公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁 止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中 的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件! This e-mail and its attachments contain confidential information from HUAWEI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!