Re: [PATCH v11 2/4] uacce: add uacce driver

2020-01-15 Thread zhangfei

Hi, Dave

On 2020/1/16 上午12:43, Dave Jiang wrote:



On 1/15/20 4:18 AM, zhangfei wrote:

Hi, Greg

On 2020/1/14 下午10:59, Greg Kroah-Hartman wrote:

On Mon, Jan 13, 2020 at 11:34:55AM +0800, zhangfei wrote:

Hi, Greg

Thanks for the review.

On 2020/1/12 上午3:40, Greg Kroah-Hartman wrote:

On Sat, Jan 11, 2020 at 10:48:37AM +0800, Zhangfei Gao wrote:

+static int uacce_fops_open(struct inode *inode, struct file *filep)
+{
+    struct uacce_mm *uacce_mm = NULL;
+    struct uacce_device *uacce;
+    struct uacce_queue *q;
+    int ret = 0;
+
+    uacce = xa_load(_xa, iminor(inode));
+    if (!uacce)
+    return -ENODEV;
+
+    if (!try_module_get(uacce->parent->driver->owner))
+    return -ENODEV;

Why are you trying to grab the module reference of the parent device?
Why is that needed and what is that going to help with here?

This shouldn't be needed as the module reference of the owner of the
fileops for this module is incremented, and the "parent" module 
depends

on this module, so how could it be unloaded without this code being
unloaded?

Yes, if you build this code into the kernel and the "parent" 
driver is a

module, then you will not have a reference, but when you remove that
parent driver the device will be removed as it has to be unregistered
before that parent driver can be removed from the system, right?

Or what am I missing here?
The refcount here is preventing rmmod "parent" module after fd is 
opened,
since user driver has mmap kernel memory to user space, like mmio, 
which may

still in-use.

With the refcount protection, rmmod "parent" module will fail until
application free the fd.
log like: rmmod: ERROR: Module hisi_zip is in use

But if the "parent" module is to be unloaded, it has to unregister the
"child" device and that will call the destructor in here and then you
will tear everything down and all should be good.

There's no need to "forbid" a module from being unloaded, even if it is
being used.  Look at all networking drivers, they work that way, right?

Thanks Greg for the kind suggestion.

I still have one uncertainty.
Does uacce has to block process continue accessing the mmapped area 
when remove "parent" module?
Uacce can block device access the physical memory when parent module 
call uacce_remove.
But application is still running, and suppose it is not the kernel 
driver's responsibility to call unmap.


I am looking for some examples in kernel,
looks vfio does not block process continue accessing when 
vfio_unregister_iommu_driver either.


In my test, application will keep waiting after rmmod parent, until 
ctrl+c, when unmap is called.

During the process, kernel does not report any error.

Do you have any advice?


Would it work to call unmap_mapping_range() on the char dev 
inode->i_mappings? I think you need to set the vma->fault function ptr 
for the vm_operations_struct in the original mmap(). After the 
mappings are unmapped, you can set a state variable to trigger the 
return of VM_FAULT_SIGBUS in the ->fault function when the user app 
accesses the mmap region again and triggers a page fault. The user app 
needs to be programmed to catch exceptions to deal with that.


Thanks Dave for the advice.
Will look into it, may need some time to investigate.
I would like to make an additional patch for this issue, since it does 
not impact the main function.


Thanks

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v11 2/4] uacce: add uacce driver

2020-01-15 Thread Dave Jiang



On 1/15/20 4:18 AM, zhangfei wrote:

Hi, Greg

On 2020/1/14 下午10:59, Greg Kroah-Hartman wrote:

On Mon, Jan 13, 2020 at 11:34:55AM +0800, zhangfei wrote:

Hi, Greg

Thanks for the review.

On 2020/1/12 上午3:40, Greg Kroah-Hartman wrote:

On Sat, Jan 11, 2020 at 10:48:37AM +0800, Zhangfei Gao wrote:

+static int uacce_fops_open(struct inode *inode, struct file *filep)
+{
+    struct uacce_mm *uacce_mm = NULL;
+    struct uacce_device *uacce;
+    struct uacce_queue *q;
+    int ret = 0;
+
+    uacce = xa_load(_xa, iminor(inode));
+    if (!uacce)
+    return -ENODEV;
+
+    if (!try_module_get(uacce->parent->driver->owner))
+    return -ENODEV;

Why are you trying to grab the module reference of the parent device?
Why is that needed and what is that going to help with here?

This shouldn't be needed as the module reference of the owner of the
fileops for this module is incremented, and the "parent" module depends
on this module, so how could it be unloaded without this code being
unloaded?

Yes, if you build this code into the kernel and the "parent" driver 
is a

module, then you will not have a reference, but when you remove that
parent driver the device will be removed as it has to be unregistered
before that parent driver can be removed from the system, right?

Or what am I missing here?
The refcount here is preventing rmmod "parent" module after fd is 
opened,
since user driver has mmap kernel memory to user space, like mmio, 
which may

still in-use.

With the refcount protection, rmmod "parent" module will fail until
application free the fd.
log like: rmmod: ERROR: Module hisi_zip is in use

But if the "parent" module is to be unloaded, it has to unregister the
"child" device and that will call the destructor in here and then you
will tear everything down and all should be good.

There's no need to "forbid" a module from being unloaded, even if it is
being used.  Look at all networking drivers, they work that way, right?

Thanks Greg for the kind suggestion.

I still have one uncertainty.
Does uacce has to block process continue accessing the mmapped area when 
remove "parent" module?
Uacce can block device access the physical memory when parent module 
call uacce_remove.
But application is still running, and suppose it is not the kernel 
driver's responsibility to call unmap.


I am looking for some examples in kernel,
looks vfio does not block process continue accessing when 
vfio_unregister_iommu_driver either.


In my test, application will keep waiting after rmmod parent, until 
ctrl+c, when unmap is called.

During the process, kernel does not report any error.

Do you have any advice?


Would it work to call unmap_mapping_range() on the char dev 
inode->i_mappings? I think you need to set the vma->fault function ptr 
for the vm_operations_struct in the original mmap(). After the mappings 
are unmapped, you can set a state variable to trigger the return of 
VM_FAULT_SIGBUS in the ->fault function when the user app accesses the 
mmap region again and triggers a page fault. The user app needs to be 
programmed to catch exceptions to deal with that.





+static void uacce_release(struct device *dev)
+{
+    struct uacce_device *uacce = to_uacce_device(dev);
+
+    kfree(uacce);
+    uacce = NULL;

That line didn't do anything :)

Yes, this is a mistake.
It is up to caller to set to NULL to prevent release multi times.

Release function is called by the driver core which will not touch the
value again.

Yes, I understand, it's my mistake. Will remove it.

Thanks

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v11 2/4] uacce: add uacce driver

2020-01-15 Thread zhangfei



On 2020/1/15 下午8:02, Greg Kroah-Hartman wrote:

On Wed, Jan 15, 2020 at 07:18:34PM +0800, zhangfei wrote:

Hi, Greg

On 2020/1/14 下午10:59, Greg Kroah-Hartman wrote:

On Mon, Jan 13, 2020 at 11:34:55AM +0800, zhangfei wrote:

Hi, Greg

Thanks for the review.

On 2020/1/12 上午3:40, Greg Kroah-Hartman wrote:

On Sat, Jan 11, 2020 at 10:48:37AM +0800, Zhangfei Gao wrote:

+static int uacce_fops_open(struct inode *inode, struct file *filep)
+{
+   struct uacce_mm *uacce_mm = NULL;
+   struct uacce_device *uacce;
+   struct uacce_queue *q;
+   int ret = 0;
+
+   uacce = xa_load(_xa, iminor(inode));
+   if (!uacce)
+   return -ENODEV;
+
+   if (!try_module_get(uacce->parent->driver->owner))
+   return -ENODEV;

Why are you trying to grab the module reference of the parent device?
Why is that needed and what is that going to help with here?

This shouldn't be needed as the module reference of the owner of the
fileops for this module is incremented, and the "parent" module depends
on this module, so how could it be unloaded without this code being
unloaded?

Yes, if you build this code into the kernel and the "parent" driver is a
module, then you will not have a reference, but when you remove that
parent driver the device will be removed as it has to be unregistered
before that parent driver can be removed from the system, right?

Or what am I missing here?

The refcount here is preventing rmmod "parent" module after fd is opened,
since user driver has mmap kernel memory to user space, like mmio, which may
still in-use.

With the refcount protection, rmmod "parent" module will fail until
application free the fd.
log like: rmmod: ERROR: Module hisi_zip is in use

But if the "parent" module is to be unloaded, it has to unregister the
"child" device and that will call the destructor in here and then you
will tear everything down and all should be good.

There's no need to "forbid" a module from being unloaded, even if it is
being used.  Look at all networking drivers, they work that way, right?

Thanks Greg for the kind suggestion.

I still have one uncertainty.
Does uacce has to block process continue accessing the mmapped area when
remove "parent" module?
Uacce can block device access the physical memory when parent module call
uacce_remove.
But application is still running, and suppose it is not the kernel driver's
responsibility to call unmap.

I am looking for some examples in kernel,
looks vfio does not block process continue accessing when
vfio_unregister_iommu_driver either.

In my test, application will keep waiting after rmmod parent, until ctrl+c,
when unmap is called.
During the process, kernel does not report any error.

Do you have any advice?

Is there no way for the kernel to invalidate the memory and tell the
process to stop?  tty drivers do this for when they are removed from the
system.

Anyway, this is all very rare, no kernel module is ever unloaded on a
real system, that is only for when developers are working on them, so
it's probably not that big of an issue, right?


Thanks Greg, will update a new version while ignoring this first.

Thanks

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v11 2/4] uacce: add uacce driver

2020-01-15 Thread Greg Kroah-Hartman
On Wed, Jan 15, 2020 at 07:18:34PM +0800, zhangfei wrote:
> Hi, Greg
> 
> On 2020/1/14 下午10:59, Greg Kroah-Hartman wrote:
> > On Mon, Jan 13, 2020 at 11:34:55AM +0800, zhangfei wrote:
> > > Hi, Greg
> > > 
> > > Thanks for the review.
> > > 
> > > On 2020/1/12 上午3:40, Greg Kroah-Hartman wrote:
> > > > On Sat, Jan 11, 2020 at 10:48:37AM +0800, Zhangfei Gao wrote:
> > > > > +static int uacce_fops_open(struct inode *inode, struct file *filep)
> > > > > +{
> > > > > + struct uacce_mm *uacce_mm = NULL;
> > > > > + struct uacce_device *uacce;
> > > > > + struct uacce_queue *q;
> > > > > + int ret = 0;
> > > > > +
> > > > > + uacce = xa_load(_xa, iminor(inode));
> > > > > + if (!uacce)
> > > > > + return -ENODEV;
> > > > > +
> > > > > + if (!try_module_get(uacce->parent->driver->owner))
> > > > > + return -ENODEV;
> > > > Why are you trying to grab the module reference of the parent device?
> > > > Why is that needed and what is that going to help with here?
> > > > 
> > > > This shouldn't be needed as the module reference of the owner of the
> > > > fileops for this module is incremented, and the "parent" module depends
> > > > on this module, so how could it be unloaded without this code being
> > > > unloaded?
> > > > 
> > > > Yes, if you build this code into the kernel and the "parent" driver is a
> > > > module, then you will not have a reference, but when you remove that
> > > > parent driver the device will be removed as it has to be unregistered
> > > > before that parent driver can be removed from the system, right?
> > > > 
> > > > Or what am I missing here?
> > > The refcount here is preventing rmmod "parent" module after fd is opened,
> > > since user driver has mmap kernel memory to user space, like mmio, which 
> > > may
> > > still in-use.
> > > 
> > > With the refcount protection, rmmod "parent" module will fail until
> > > application free the fd.
> > > log like: rmmod: ERROR: Module hisi_zip is in use
> > But if the "parent" module is to be unloaded, it has to unregister the
> > "child" device and that will call the destructor in here and then you
> > will tear everything down and all should be good.
> > 
> > There's no need to "forbid" a module from being unloaded, even if it is
> > being used.  Look at all networking drivers, they work that way, right?
> Thanks Greg for the kind suggestion.
> 
> I still have one uncertainty.
> Does uacce has to block process continue accessing the mmapped area when
> remove "parent" module?
> Uacce can block device access the physical memory when parent module call
> uacce_remove.
> But application is still running, and suppose it is not the kernel driver's
> responsibility to call unmap.
> 
> I am looking for some examples in kernel,
> looks vfio does not block process continue accessing when
> vfio_unregister_iommu_driver either.
> 
> In my test, application will keep waiting after rmmod parent, until ctrl+c,
> when unmap is called.
> During the process, kernel does not report any error.
> 
> Do you have any advice?

Is there no way for the kernel to invalidate the memory and tell the
process to stop?  tty drivers do this for when they are removed from the
system.

Anyway, this is all very rare, no kernel module is ever unloaded on a
real system, that is only for when developers are working on them, so
it's probably not that big of an issue, right?

thanks,

greg k-h
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v11 2/4] uacce: add uacce driver

2020-01-15 Thread zhangfei

Hi, Greg

On 2020/1/14 下午10:59, Greg Kroah-Hartman wrote:

On Mon, Jan 13, 2020 at 11:34:55AM +0800, zhangfei wrote:

Hi, Greg

Thanks for the review.

On 2020/1/12 上午3:40, Greg Kroah-Hartman wrote:

On Sat, Jan 11, 2020 at 10:48:37AM +0800, Zhangfei Gao wrote:

+static int uacce_fops_open(struct inode *inode, struct file *filep)
+{
+   struct uacce_mm *uacce_mm = NULL;
+   struct uacce_device *uacce;
+   struct uacce_queue *q;
+   int ret = 0;
+
+   uacce = xa_load(_xa, iminor(inode));
+   if (!uacce)
+   return -ENODEV;
+
+   if (!try_module_get(uacce->parent->driver->owner))
+   return -ENODEV;

Why are you trying to grab the module reference of the parent device?
Why is that needed and what is that going to help with here?

This shouldn't be needed as the module reference of the owner of the
fileops for this module is incremented, and the "parent" module depends
on this module, so how could it be unloaded without this code being
unloaded?

Yes, if you build this code into the kernel and the "parent" driver is a
module, then you will not have a reference, but when you remove that
parent driver the device will be removed as it has to be unregistered
before that parent driver can be removed from the system, right?

Or what am I missing here?

The refcount here is preventing rmmod "parent" module after fd is opened,
since user driver has mmap kernel memory to user space, like mmio, which may
still in-use.

With the refcount protection, rmmod "parent" module will fail until
application free the fd.
log like: rmmod: ERROR: Module hisi_zip is in use

But if the "parent" module is to be unloaded, it has to unregister the
"child" device and that will call the destructor in here and then you
will tear everything down and all should be good.

There's no need to "forbid" a module from being unloaded, even if it is
being used.  Look at all networking drivers, they work that way, right?

Thanks Greg for the kind suggestion.

I still have one uncertainty.
Does uacce has to block process continue accessing the mmapped area when 
remove "parent" module?
Uacce can block device access the physical memory when parent module 
call uacce_remove.
But application is still running, and suppose it is not the kernel 
driver's responsibility to call unmap.


I am looking for some examples in kernel,
looks vfio does not block process continue accessing when 
vfio_unregister_iommu_driver either.


In my test, application will keep waiting after rmmod parent, until 
ctrl+c, when unmap is called.

During the process, kernel does not report any error.

Do you have any advice?


+static void uacce_release(struct device *dev)
+{
+   struct uacce_device *uacce = to_uacce_device(dev);
+
+   kfree(uacce);
+   uacce = NULL;

That line didn't do anything :)

Yes, this is a mistake.
It is up to caller to set to NULL to prevent release multi times.

Release function is called by the driver core which will not touch the
value again.

Yes, I understand, it's my mistake. Will remove it.

Thanks
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v11 2/4] uacce: add uacce driver

2020-01-14 Thread Greg Kroah-Hartman
On Mon, Jan 13, 2020 at 11:34:55AM +0800, zhangfei wrote:
> Hi, Greg
> 
> Thanks for the review.
> 
> On 2020/1/12 上午3:40, Greg Kroah-Hartman wrote:
> > On Sat, Jan 11, 2020 at 10:48:37AM +0800, Zhangfei Gao wrote:
> > > +static int uacce_fops_open(struct inode *inode, struct file *filep)
> > > +{
> > > + struct uacce_mm *uacce_mm = NULL;
> > > + struct uacce_device *uacce;
> > > + struct uacce_queue *q;
> > > + int ret = 0;
> > > +
> > > + uacce = xa_load(_xa, iminor(inode));
> > > + if (!uacce)
> > > + return -ENODEV;
> > > +
> > > + if (!try_module_get(uacce->parent->driver->owner))
> > > + return -ENODEV;
> > Why are you trying to grab the module reference of the parent device?
> > Why is that needed and what is that going to help with here?
> > 
> > This shouldn't be needed as the module reference of the owner of the
> > fileops for this module is incremented, and the "parent" module depends
> > on this module, so how could it be unloaded without this code being
> > unloaded?
> > 
> > Yes, if you build this code into the kernel and the "parent" driver is a
> > module, then you will not have a reference, but when you remove that
> > parent driver the device will be removed as it has to be unregistered
> > before that parent driver can be removed from the system, right?
> > 
> > Or what am I missing here?
> The refcount here is preventing rmmod "parent" module after fd is opened,
> since user driver has mmap kernel memory to user space, like mmio, which may
> still in-use.
> 
> With the refcount protection, rmmod "parent" module will fail until
> application free the fd.
> log like: rmmod: ERROR: Module hisi_zip is in use

But if the "parent" module is to be unloaded, it has to unregister the
"child" device and that will call the destructor in here and then you
will tear everything down and all should be good.

There's no need to "forbid" a module from being unloaded, even if it is
being used.  Look at all networking drivers, they work that way, right?

> > > +static void uacce_release(struct device *dev)
> > > +{
> > > + struct uacce_device *uacce = to_uacce_device(dev);
> > > +
> > > + kfree(uacce);
> > > + uacce = NULL;
> > That line didn't do anything :)
> Yes, this is a mistake.
> It is up to caller to set to NULL to prevent release multi times.

Release function is called by the driver core which will not touch the
value again.

thanks,

greg k-h
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v11 2/4] uacce: add uacce driver

2020-01-12 Thread zhangfei

Hi, Greg

Thanks for the review.

On 2020/1/12 上午3:40, Greg Kroah-Hartman wrote:

On Sat, Jan 11, 2020 at 10:48:37AM +0800, Zhangfei Gao wrote:

+static int uacce_fops_open(struct inode *inode, struct file *filep)
+{
+   struct uacce_mm *uacce_mm = NULL;
+   struct uacce_device *uacce;
+   struct uacce_queue *q;
+   int ret = 0;
+
+   uacce = xa_load(_xa, iminor(inode));
+   if (!uacce)
+   return -ENODEV;
+
+   if (!try_module_get(uacce->parent->driver->owner))
+   return -ENODEV;

Why are you trying to grab the module reference of the parent device?
Why is that needed and what is that going to help with here?

This shouldn't be needed as the module reference of the owner of the
fileops for this module is incremented, and the "parent" module depends
on this module, so how could it be unloaded without this code being
unloaded?

Yes, if you build this code into the kernel and the "parent" driver is a
module, then you will not have a reference, but when you remove that
parent driver the device will be removed as it has to be unregistered
before that parent driver can be removed from the system, right?

Or what am I missing here?

The refcount here is preventing rmmod "parent" module after fd is opened,
since user driver has mmap kernel memory to user space, like mmio, which 
may still in-use.


With the refcount protection, rmmod "parent" module will fail until 
application free the fd.

log like: rmmod: ERROR: Module hisi_zip is in use



+static void uacce_release(struct device *dev)
+{
+   struct uacce_device *uacce = to_uacce_device(dev);
+
+   kfree(uacce);
+   uacce = NULL;

That line didn't do anything :)

Yes, this is a mistake.
It is up to caller to set to NULL to prevent release multi times.

Thanks
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v11 2/4] uacce: add uacce driver

2020-01-11 Thread Greg Kroah-Hartman
On Sat, Jan 11, 2020 at 10:48:37AM +0800, Zhangfei Gao wrote:
> +static int uacce_fops_open(struct inode *inode, struct file *filep)
> +{
> + struct uacce_mm *uacce_mm = NULL;
> + struct uacce_device *uacce;
> + struct uacce_queue *q;
> + int ret = 0;
> +
> + uacce = xa_load(_xa, iminor(inode));
> + if (!uacce)
> + return -ENODEV;
> +
> + if (!try_module_get(uacce->parent->driver->owner))
> + return -ENODEV;

Why are you trying to grab the module reference of the parent device?
Why is that needed and what is that going to help with here?

This shouldn't be needed as the module reference of the owner of the
fileops for this module is incremented, and the "parent" module depends
on this module, so how could it be unloaded without this code being
unloaded?

Yes, if you build this code into the kernel and the "parent" driver is a
module, then you will not have a reference, but when you remove that
parent driver the device will be removed as it has to be unregistered
before that parent driver can be removed from the system, right?

Or what am I missing here?

> +static void uacce_release(struct device *dev)
> +{
> + struct uacce_device *uacce = to_uacce_device(dev);
> +
> + kfree(uacce);
> + uacce = NULL;

That line didn't do anything :)

thanks,

greg k-h
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH v11 2/4] uacce: add uacce driver

2020-01-10 Thread Zhangfei Gao
From: Kenneth Lee 

Uacce (Unified/User-space-access-intended Accelerator Framework) targets to
provide Shared Virtual Addressing (SVA) between accelerators and processes.
So accelerator can access any data structure of the main cpu.
This differs from the data sharing between cpu and io device, which share
only data content rather than address.
Since unified address, hardware and user space of process can share the
same virtual address in the communication.

Uacce create a chrdev for every registration, the queue is allocated to
the process when the chrdev is opened. Then the process can access the
hardware resource by interact with the queue file. By mmap the queue
file space to user space, the process can directly put requests to the
hardware without syscall to the kernel space.

The IOMMU core only tracks mm<->device bonds at the moment, because it
only needs to handle IOTLB invalidation and PASID table entries. However
uacce needs a finer granularity since multiple queues from the same
device can be bound to an mm. When the mm exits, all bound queues must
be stopped so that the IOMMU can safely clear the PASID table entry and
reallocate the PASID.

An intermediate struct uacce_mm links uacce devices and queues.
Note that an mm may be bound to multiple devices but an uacce_mm
structure only ever belongs to a single device, because we don't need
anything more complex (if multiple devices are bound to one mm, then
we'll create one uacce_mm for each bond).

uacce_device --+-- uacce_mm --+-- uacce_queue
   |  '-- uacce_queue
   |
   '-- uacce_mm --+-- uacce_queue
  +-- uacce_queue
  '-- uacce_queue

Reviewed-by: Jonathan Cameron 
Signed-off-by: Kenneth Lee 
Signed-off-by: Zaibo Xu 
Signed-off-by: Zhou Wang 
Signed-off-by: Jean-Philippe Brucker 
Signed-off-by: Zhangfei Gao 
---
 Documentation/ABI/testing/sysfs-driver-uacce |  39 ++
 drivers/misc/Kconfig |   1 +
 drivers/misc/Makefile|   1 +
 drivers/misc/uacce/Kconfig   |  13 +
 drivers/misc/uacce/Makefile  |   2 +
 drivers/misc/uacce/uacce.c   | 626 +++
 include/linux/uacce.h| 161 +++
 include/uapi/misc/uacce/uacce.h  |  38 ++
 8 files changed, 881 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-uacce
 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/uacce.h

diff --git a/Documentation/ABI/testing/sysfs-driver-uacce 
b/Documentation/ABI/testing/sysfs-driver-uacce
new file mode 100644
index 000..ef4003a
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-uacce
@@ -0,0 +1,39 @@
+What:   /sys/class/uacce//api
+Date:   Jan 2020
+KernelVersion:  5.6
+Contact:linux-accelerat...@lists.ozlabs.org
+Description:Api of the device
+Can be any string and up to userspace to parse.
+Application use the api to match the correct driver
+
+What:   /sys/class/uacce//flags
+Date:   Jan 2020
+KernelVersion:  5.6
+Contact:linux-accelerat...@lists.ozlabs.org
+Description:Attributes of the device, see UACCE_DEV_xxx flag defined in 
uacce.h
+
+What:   /sys/class/uacce//available_instances
+Date:   Jan 2020
+KernelVersion:  5.6
+Contact:linux-accelerat...@lists.ozlabs.org
+Description:Available instances left of the device
+Return -ENODEV if uacce_ops get_available_instances is not 
provided
+
+What:   /sys/class/uacce//algorithms
+Date:   Jan 2020
+KernelVersion:  5.6
+Contact:linux-accelerat...@lists.ozlabs.org
+Description:Algorithms supported by this accelerator, separated by new 
line.
+Can be any string and up to userspace to parse.
+
+What:   /sys/class/uacce//region_mmio_size
+Date:   Jan 2020
+KernelVersion:  5.6
+Contact:linux-accelerat...@lists.ozlabs.org
+Description:Size (bytes) of mmio region queue file
+
+What:   /sys/class/uacce//region_dus_size
+Date:   Jan 2020
+KernelVersion:  5.6
+Contact:linux-accelerat...@lists.ozlabs.org
+Description:Size (bytes) of dus region queue file
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 7f0d48f..99e1514 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -480,4 +480,5 @@ source "drivers/misc/cxl/Kconfig"
 source "drivers/misc/ocxl/Kconfig"
 source "drivers/misc/cardreader/Kconfig"
 source "drivers/misc/habanalabs/Kconfig"
+source "drivers/misc/uacce/Kconfig"
 endmenu
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index c1860d3..9abf292 100644
---