mbox series

[0/2] A General Accelerator Framework, WarpDrive

Message ID 1565775265-21212-1-git-send-email-zhangfei.gao@linaro.org
Headers show
Series A General Accelerator Framework, WarpDrive | expand

Message

Zhangfei Gao Aug. 14, 2019, 9:34 a.m. UTC
*WarpDrive* is a general accelerator framework for the user application to
access the hardware without going through the kernel in data path.

WarpDrive is the name for the whole framework. The component in kernel
is called uacce, meaning "Unified/User-space-access-intended Accelerator
Framework". It makes use of the capability of IOMMU to maintain a
unified virtual address space between the hardware and the process.

WarpDrive is intended to be used with Jean Philippe Brucker's SVA
patchset[1], which enables IO side page fault and PASID support. 
We have keep verifying with Jean's sva/current [2]
We also keep verifying with Eric's SMMUv3 Nested Stage patch [3]

This series and related zip & qm driver as well as dummy driver for qemu test:
https://github.com/Linaro/linux-kernel-warpdrive/tree/5.3-rc1-warpdrive-v1
zip driver already been upstreamed.
zip supporting uacce will be the next step.

The library and user application:
https://github.com/Linaro/warpdrive/tree/wdprd-v1-current

Change History:
v4 changed from V3
1. Rebase to 5.3-rc1
2. Build on iommu interface
3. Verifying with Jean's sva and Eric's nested mode iommu.
4. User library has developed a lot: support zlib, openssl etc.
5. Move to misc first

V3 changed from V2:
https://lkml.org/lkml/2018/11/12/1951
1. Build uacce from original IOMMU interface. V2 is built on VFIO.
   But the VFIO way locking the user memory in place will not
   work properly if the process fork a child. Because the
   copy-on-write strategy will make the parent process lost its
   page. This is not acceptable to accelerator user.
2. The kernel component is renamed to uacce from sdmdev accordingly
3. Document is updated for the new design. The Static Shared
   Virtual Memory concept is introduced to replace the User
	Memory Sharing concept.
4. Rebase to the lastest kernel (4.20.0-rc1)
5. As an RFC, this version is tested only with "test-to-pass"
   test case and not tested with Jean's SVA patch.

V2 changed from V1:
https://lwn.net/Articles/763990/
1. Change kernel framework name from SPIMDEV (Share Parent IOMMU
   Mdev) to SDMDEV (Share Domain Mdev).
2. Allocate Hardware Resource when a new mdev is created (While
   it is allocated when the mdev is openned)
3. Unmap pages from the shared domain when the sdmdev iommu group is
   detached. (This procedure is necessary, but missed in V1)
4. Update document accordingly.
5. Rebase to the latest kernel (4.19.0-rc1)

References:
[1] http://jpbrucker.net/sva/
[2] http://www.linux-arm.org/git?p=linux-jpb.git;a=shortlog;h=refs/heads/sva/current
[3] https://github.com/eauger/linux/tree/v5.3.0-rc0-2stage-v9

Kenneth Lee (2):
  uacce: Add documents for WarpDrive/uacce
  uacce: add uacce module

 Documentation/misc-devices/warpdrive.rst |  351 +++++++++
 drivers/misc/Kconfig                     |    1 +
 drivers/misc/Makefile                    |    1 +
 drivers/misc/uacce/Kconfig               |   13 +
 drivers/misc/uacce/Makefile              |    2 +
 drivers/misc/uacce/uacce.c               | 1186 ++++++++++++++++++++++++++++++
 include/linux/uacce.h                    |  109 +++
 include/uapi/misc/uacce.h                |   44 ++
 8 files changed, 1707 insertions(+)
 create mode 100644 Documentation/misc-devices/warpdrive.rst
 create mode 100644 drivers/misc/uacce/Kconfig
 create mode 100644 drivers/misc/uacce/Makefile
 create mode 100644 drivers/misc/uacce/uacce.c
 create mode 100644 include/linux/uacce.h
 create mode 100644 include/uapi/misc/uacce.h

-- 
2.7.4

Comments

Jerome Glisse Aug. 15, 2019, 5:04 p.m. UTC | #1
On Wed, Aug 14, 2019 at 05:34:23PM +0800, Zhangfei Gao wrote:
> *WarpDrive* is a general accelerator framework for the user application to

> access the hardware without going through the kernel in data path.

> 

> WarpDrive is the name for the whole framework. The component in kernel

> is called uacce, meaning "Unified/User-space-access-intended Accelerator

> Framework". It makes use of the capability of IOMMU to maintain a

> unified virtual address space between the hardware and the process.

> 

> WarpDrive is intended to be used with Jean Philippe Brucker's SVA

> patchset[1], which enables IO side page fault and PASID support. 

> We have keep verifying with Jean's sva/current [2]

> We also keep verifying with Eric's SMMUv3 Nested Stage patch [3]

> 

> This series and related zip & qm driver as well as dummy driver for qemu test:

> https://github.com/Linaro/linux-kernel-warpdrive/tree/5.3-rc1-warpdrive-v1

> zip driver already been upstreamed.

> zip supporting uacce will be the next step.

> 

> The library and user application:

> https://github.com/Linaro/warpdrive/tree/wdprd-v1-current


Do we want a new framework ? I think that is the first question that
should be answer here. Accelerator are in many forms and so far they
never have been enough commonality to create a framework, even GPUs
with the drm is an example of that, drm only offer share framework
for the modesetting part of the GPU (as thankfully monitor connector
are not specific to GPU brands :))

FPGA is another example the only common code expose to userspace is
about bitstream management AFAIK.

I would argue that a framework should only be created once there is
enough devices with same userspace API. Meanwhile you can provide
in kernel helper that allow driver to expose same API. If after a
while we have enough device driver which all use that same in kernel
helpers API then it will a good time to introduce a new framework.
Meanwhile this will allow individual device driver to tinker with
their API and maybe get to something useful to more devices in the
end.

Note that what i propose also allow userspace code sharing for all
driver that use the same in kernel helper.

Cheers,
Jérôme
Zhangfei Gao Aug. 20, 2019, 2:26 p.m. UTC | #2
Hi, Jerome

Thanks for your suggestion

On 2019/8/16 上午1:04, Jerome Glisse wrote:
> On Wed, Aug 14, 2019 at 05:34:23PM +0800, Zhangfei Gao wrote:

>> *WarpDrive* is a general accelerator framework for the user application to

>> access the hardware without going through the kernel in data path.

>>

>> WarpDrive is the name for the whole framework. The component in kernel

>> is called uacce, meaning "Unified/User-space-access-intended Accelerator

>> Framework". It makes use of the capability of IOMMU to maintain a

>> unified virtual address space between the hardware and the process.

>>

>> WarpDrive is intended to be used with Jean Philippe Brucker's SVA

>> patchset[1], which enables IO side page fault and PASID support.

>> We have keep verifying with Jean's sva/current [2]

>> We also keep verifying with Eric's SMMUv3 Nested Stage patch [3]

>>

>> This series and related zip & qm driver as well as dummy driver for qemu test:

>> https://github.com/Linaro/linux-kernel-warpdrive/tree/5.3-rc1-warpdrive-v1

>> zip driver already been upstreamed.

>> zip supporting uacce will be the next step.

>>

>> The library and user application:

>> https://github.com/Linaro/warpdrive/tree/wdprd-v1-current

> Do we want a new framework ? I think that is the first question that

> should be answer here. Accelerator are in many forms and so far they

> never have been enough commonality to create a framework, even GPUs

> with the drm is an example of that, drm only offer share framework

> for the modesetting part of the GPU (as thankfully monitor connector

> are not specific to GPU brands :))

>

> FPGA is another example the only common code expose to userspace is

> about bitstream management AFAIK.

>

> I would argue that a framework should only be created once there is

> enough devices with same userspace API. Meanwhile you can provide

> in kernel helper that allow driver to expose same API. If after a

> while we have enough device driver which all use that same in kernel

> helpers API then it will a good time to introduce a new framework.

> Meanwhile this will allow individual device driver to tinker with

> their API and maybe get to something useful to more devices in the

> end.

>

> Note that what i propose also allow userspace code sharing for all

> driver that use the same in kernel helper.

>

Yes, we understand it is not easy for a new framework.
There are discussions in rfc2 (2018/9) and rfc3 (2018/11).
To make life easier, we plan to move the uacce to driver/misc to support 
our own product first until it is mature.
Using uacce, Currently we get quite a big performance improvement in our 
crypto product, like zip, hpre, sec.
Our final goal is "A General Accelerator Framework", which maybe ambitious.
So uacce is designed to be a common framework, can be easily supporting 
more accelerators.
And we are happy to get more requirements and make it mature.

Another good point is SVA support in ongoing, http://jpbrucker.net/sva/
After sva mature, the accelerators support will be much easier.

Thanks
Kenneth Lee Aug. 26, 2019, 4:14 a.m. UTC | #3
On Thu, Aug 15, 2019 at 01:04:24PM -0400, Jerome Glisse wrote:
> Date: Thu, 15 Aug 2019 13:04:24 -0400

> From: Jerome Glisse <jglisse@redhat.com>

> To: Zhangfei Gao <zhangfei.gao@linaro.org>

> CC: linux-accelerators@lists.ozlabs.org, Greg Kroah-Hartman

>  <gregkh@linuxfoundation.org>, linux-kernel@vger.kernel.org, Arnd Bergmann

>  <arnd@arndb.de>

> Subject: Re: [PATCH 0/2] A General Accelerator Framework, WarpDrive

> User-Agent: Mutt/1.11.3 (2019-02-01)

> Message-ID: <20190815170424.GA30916@redhat.com>

> 

> On Wed, Aug 14, 2019 at 05:34:23PM +0800, Zhangfei Gao wrote:

> > *WarpDrive* is a general accelerator framework for the user application to

> > access the hardware without going through the kernel in data path.

> > 

> > WarpDrive is the name for the whole framework. The component in kernel

> > is called uacce, meaning "Unified/User-space-access-intended Accelerator

> > Framework". It makes use of the capability of IOMMU to maintain a

> > unified virtual address space between the hardware and the process.

> > 

> > WarpDrive is intended to be used with Jean Philippe Brucker's SVA

> > patchset[1], which enables IO side page fault and PASID support. 

> > We have keep verifying with Jean's sva/current [2]

> > We also keep verifying with Eric's SMMUv3 Nested Stage patch [3]

> > 

> > This series and related zip & qm driver as well as dummy driver for qemu test:

> > https://github.com/Linaro/linux-kernel-warpdrive/tree/5.3-rc1-warpdrive-v1

> > zip driver already been upstreamed.

> > zip supporting uacce will be the next step.

> > 

> > The library and user application:

> > https://github.com/Linaro/warpdrive/tree/wdprd-v1-current

> 

> Do we want a new framework ? I think that is the first question that

> should be answer here. Accelerator are in many forms and so far they

> never have been enough commonality to create a framework, even GPUs

> with the drm is an example of that, drm only offer share framework

> for the modesetting part of the GPU (as thankfully monitor connector

> are not specific to GPU brands :))

> 

> FPGA is another example the only common code expose to userspace is

> about bitstream management AFAIK.

> 

> I would argue that a framework should only be created once there is

> enough devices with same userspace API. Meanwhile you can provide

> in kernel helper that allow driver to expose same API. If after a

> while we have enough device driver which all use that same in kernel

> helpers API then it will a good time to introduce a new framework.

> Meanwhile this will allow individual device driver to tinker with

> their API and maybe get to something useful to more devices in the

> end.

> 

> Note that what i propose also allow userspace code sharing for all

> driver that use the same in kernel helper.

> 

> Cheers,

> Jérôme


Hi, Jerome, I explain the idea here: https://zhuanlan.zhihu.com/p/79680889. We
think this is a comment requirement for eveybody. Hope this can help the
discussion. Thanks

-- 
			-Kenneth(Hisilicon)