[Xen-devel] [RFC PATCH] xen/gntdev: Stop abusing DT of_dma_configure API

Rob Herring posted 1 patch 6 years, 1 month ago
Failed in applying to current master (apply log)
drivers/xen/gntdev.c | 11 -----------
1 file changed, 11 deletions(-)
[Xen-devel] [RFC PATCH] xen/gntdev: Stop abusing DT of_dma_configure API
Posted by Rob Herring 6 years, 1 month ago
As the comment says, this isn't a DT based device. of_dma_configure()
is going to stop allowing a NULL DT node, so this needs to be fixed.

Not sure exactly what setup besides arch_setup_dma_ops is needed...

Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Julien Grall <julien.grall@arm.com>
Cc: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: xen-devel@lists.xenproject.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/xen/gntdev.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index a446a7221e13..59906f9a40e4 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -34,9 +34,6 @@
 #include <linux/slab.h>
 #include <linux/highmem.h>
 #include <linux/refcount.h>
-#ifdef CONFIG_XEN_GRANT_DMA_ALLOC
-#include <linux/of_device.h>
-#endif
 
 #include <xen/xen.h>
 #include <xen/grant_table.h>
@@ -625,14 +622,6 @@ static int gntdev_open(struct inode *inode, struct file *flip)
 	flip->private_data = priv;
 #ifdef CONFIG_XEN_GRANT_DMA_ALLOC
 	priv->dma_dev = gntdev_miscdev.this_device;
-
-	/*
-	 * The device is not spawn from a device tree, so arch_setup_dma_ops
-	 * is not called, thus leaving the device with dummy DMA ops.
-	 * Fix this by calling of_dma_configure() with a NULL node to set
-	 * default DMA ops.
-	 */
-	of_dma_configure(priv->dma_dev, NULL, true);
 #endif
 	pr_debug("priv %p\n", priv);
 
-- 
2.20.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [RFC PATCH] xen/gntdev: Stop abusing DT of_dma_configure API
Posted by Nicolas Saenz Julienne 6 years, 1 month ago
On Wed, 2019-09-25 at 16:50 -0500, Rob Herring wrote:
> As the comment says, this isn't a DT based device. of_dma_configure()
> is going to stop allowing a NULL DT node, so this needs to be fixed.
> 
> Not sure exactly what setup besides arch_setup_dma_ops is needed...
> 
> Cc: Robin Murphy <robin.murphy@arm.com>
> Cc: Julien Grall <julien.grall@arm.com>
> Cc: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Cc: Juergen Gross <jgross@suse.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: xen-devel@lists.xenproject.org
> Signed-off-by: Rob Herring <robh@kernel.org>

Just so it isn't forgotten, the same applies here:

diff --git a/drivers/gpu/drm/xen/xen_drm_front.c
b/drivers/gpu/drm/xen/xen_drm_front.c
index ba1828acd8c9..de316a891f39 100644
--- a/drivers/gpu/drm/xen/xen_drm_front.c
+++ b/drivers/gpu/drm/xen/xen_drm_front.c
@@ -11,7 +11,6 @@
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
 
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_drv.h>
@@ -718,19 +717,7 @@ static int xen_drv_probe(struct xenbus_device *xb_dev,
        struct device *dev = &xb_dev->dev;
        int ret;
 
-       /*
-        * The device is not spawn from a device tree, so arch_setup_dma_ops
-        * is not called, thus leaving the device with dummy DMA ops.
-        * This makes the device return error on PRIME buffer import, which
-        * is not correct: to fix this call of_dma_configure() with a NULL
-        * node to set default DMA ops.
-        */
        dev->coherent_dma_mask = DMA_BIT_MASK(32);
-       ret = of_dma_configure(dev, NULL, true);
-       if (ret < 0) {
-               DRM_ERROR("Cannot setup DMA ops, ret %d", ret);
-               return ret;
-       }
 
        front_info = devm_kzalloc(&xb_dev->dev,
                                  sizeof(*front_info), GFP_KERNEL);

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [RFC PATCH] xen/gntdev: Stop abusing DT of_dma_configure API
Posted by Julien Grall 6 years, 1 month ago
Hi Rob,


On 9/25/19 10:50 PM, Rob Herring wrote:
> As the comment says, this isn't a DT based device. of_dma_configure()
> is going to stop allowing a NULL DT node, so this needs to be fixed.

And this can't work on arch not selecting CONFIG_OF and can select 
CONFIG_XEN_GRANT_DMA_ALLOC.

We are lucky enough on x86 because, AFAICT, arch_setup_dma_ops is just a 
nop.

> 
> Not sure exactly what setup besides arch_setup_dma_ops is needed...

We probably want to update dma_mask, coherent_dma_mask and dma_pfn_offset.

Also, while look at of_configure_dma, I noticed that we consider the DMA 
will not be coherent for the grant-table. Oleksandr, do you know why 
they can't be coherent?

Cheers,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel