All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] xen: Stop abusing DT of_dma_configure API
@ 2019-10-08 19:41 ` Rob Herring
  0 siblings, 0 replies; 12+ messages in thread
From: Rob Herring @ 2019-10-08 19:41 UTC (permalink / raw)
  To: xen-devel
  Cc: linux-kernel, Robin Murphy, Julien Grall, Nicolas Saenz Julienne,
	Oleksandr Andrushchenko, Boris Ostrovsky, Juergen Gross,
	Stefano Stabellini, Christoph Hellwig

As the removed comments say, these aren't DT based devices.
of_dma_configure() is going to stop allowing a NULL DT node and calling
it will no longer work.

The comment is also now out of date as of commit 9ab91e7c5c51 ("arm64:
default to the direct mapping in get_arch_dma_ops"). Direct mapping
is now the default rather than dma_dummy_ops.

According to Stefano and Oleksandr, the only other part needed is
setting the DMA masks and there's no reason to restrict the masks to
32-bits. So set the masks to 64 bits.

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: Christoph Hellwig <hch@lst.de>
Cc: xen-devel@lists.xenproject.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
v2:
 - Setup dma masks
 - Also fix xen_drm_front.c
 
This can now be applied to the Xen tree independent of the coming
of_dma_configure() changes.

Rob

 drivers/gpu/drm/xen/xen_drm_front.c | 12 ++----------
 drivers/xen/gntdev.c                | 13 ++-----------
 2 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/xen/xen_drm_front.c b/drivers/gpu/drm/xen/xen_drm_front.c
index ba1828acd8c9..4be49c1aef51 100644
--- a/drivers/gpu/drm/xen/xen_drm_front.c
+++ b/drivers/gpu/drm/xen/xen_drm_front.c
@@ -718,17 +718,9 @@ 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);
+	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
 	if (ret < 0) {
-		DRM_ERROR("Cannot setup DMA ops, ret %d", ret);
+		DRM_ERROR("Cannot setup DMA mask, ret %d", ret);
 		return ret;
 	}
 
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index a446a7221e13..81401f386c9c 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -22,6 +22,7 @@
 
 #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt
 
+#include <linux/dma-mapping.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -34,9 +35,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 +623,7 @@ 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);
+	dma_coerce_mask_and_coherent(priv->dma_dev, DMA_BIT_MASK(64));
 #endif
 	pr_debug("priv %p\n", priv);
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Xen-devel] [PATCH v2] xen: Stop abusing DT of_dma_configure API
@ 2019-10-08 19:41 ` Rob Herring
  0 siblings, 0 replies; 12+ messages in thread
From: Rob Herring @ 2019-10-08 19:41 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Stefano Stabellini, Oleksandr Andrushchenko,
	linux-kernel, Julien Grall, Boris Ostrovsky, Robin Murphy,
	Christoph Hellwig, Nicolas Saenz Julienne

As the removed comments say, these aren't DT based devices.
of_dma_configure() is going to stop allowing a NULL DT node and calling
it will no longer work.

The comment is also now out of date as of commit 9ab91e7c5c51 ("arm64:
default to the direct mapping in get_arch_dma_ops"). Direct mapping
is now the default rather than dma_dummy_ops.

According to Stefano and Oleksandr, the only other part needed is
setting the DMA masks and there's no reason to restrict the masks to
32-bits. So set the masks to 64 bits.

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: Christoph Hellwig <hch@lst.de>
Cc: xen-devel@lists.xenproject.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
v2:
 - Setup dma masks
 - Also fix xen_drm_front.c
 
This can now be applied to the Xen tree independent of the coming
of_dma_configure() changes.

Rob

 drivers/gpu/drm/xen/xen_drm_front.c | 12 ++----------
 drivers/xen/gntdev.c                | 13 ++-----------
 2 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/xen/xen_drm_front.c b/drivers/gpu/drm/xen/xen_drm_front.c
index ba1828acd8c9..4be49c1aef51 100644
--- a/drivers/gpu/drm/xen/xen_drm_front.c
+++ b/drivers/gpu/drm/xen/xen_drm_front.c
@@ -718,17 +718,9 @@ 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);
+	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
 	if (ret < 0) {
-		DRM_ERROR("Cannot setup DMA ops, ret %d", ret);
+		DRM_ERROR("Cannot setup DMA mask, ret %d", ret);
 		return ret;
 	}
 
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index a446a7221e13..81401f386c9c 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -22,6 +22,7 @@
 
 #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt
 
+#include <linux/dma-mapping.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -34,9 +35,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 +623,7 @@ 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);
+	dma_coerce_mask_and_coherent(priv->dma_dev, DMA_BIT_MASK(64));
 #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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] xen: Stop abusing DT of_dma_configure API
  2019-10-08 19:41 ` [Xen-devel] " Rob Herring
@ 2019-10-09 11:42   ` Oleksandr Andrushchenko
  -1 siblings, 0 replies; 12+ messages in thread
From: Oleksandr Andrushchenko @ 2019-10-09 11:42 UTC (permalink / raw)
  To: Rob Herring, xen-devel
  Cc: linux-kernel, Robin Murphy, Julien Grall, Nicolas Saenz Julienne,
	Boris Ostrovsky, Juergen Gross, Stefano Stabellini,
	Christoph Hellwig

On 10/8/19 10:41 PM, Rob Herring wrote:
> As the removed comments say, these aren't DT based devices.
> of_dma_configure() is going to stop allowing a NULL DT node and calling
> it will no longer work.
>
> The comment is also now out of date as of commit 9ab91e7c5c51 ("arm64:
> default to the direct mapping in get_arch_dma_ops"). Direct mapping
> is now the default rather than dma_dummy_ops.
>
> According to Stefano and Oleksandr, the only other part needed is
> setting the DMA masks and there's no reason to restrict the masks to
> 32-bits. So set the masks to 64 bits.
>
> 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: Christoph Hellwig <hch@lst.de>
> Cc: xen-devel@lists.xenproject.org
> Signed-off-by: Rob Herring <robh@kernel.org>
Acked-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

Unfortunately I cannot test this patch with real HW running Xen:
I am still on 4.14 kernel which is dictated by the board's BSP and
it is not possible to have more recent one at the moment.
So, I hope the patch will work as intended.

Thank you,
Oleksandr
> ---
> v2:
>   - Setup dma masks
>   - Also fix xen_drm_front.c
>   
> This can now be applied to the Xen tree independent of the coming
> of_dma_configure() changes.
>
> Rob
>
>   drivers/gpu/drm/xen/xen_drm_front.c | 12 ++----------
>   drivers/xen/gntdev.c                | 13 ++-----------
>   2 files changed, 4 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/xen/xen_drm_front.c b/drivers/gpu/drm/xen/xen_drm_front.c
> index ba1828acd8c9..4be49c1aef51 100644
> --- a/drivers/gpu/drm/xen/xen_drm_front.c
> +++ b/drivers/gpu/drm/xen/xen_drm_front.c
> @@ -718,17 +718,9 @@ 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);
> +	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
>   	if (ret < 0) {
> -		DRM_ERROR("Cannot setup DMA ops, ret %d", ret);
> +		DRM_ERROR("Cannot setup DMA mask, ret %d", ret);
>   		return ret;
>   	}
>   
> diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
> index a446a7221e13..81401f386c9c 100644
> --- a/drivers/xen/gntdev.c
> +++ b/drivers/xen/gntdev.c
> @@ -22,6 +22,7 @@
>   
>   #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt
>   
> +#include <linux/dma-mapping.h>
>   #include <linux/module.h>
>   #include <linux/kernel.h>
>   #include <linux/init.h>
> @@ -34,9 +35,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 +623,7 @@ 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);
> +	dma_coerce_mask_and_coherent(priv->dma_dev, DMA_BIT_MASK(64));
>   #endif
>   	pr_debug("priv %p\n", priv);
>   

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Xen-devel] [PATCH v2] xen: Stop abusing DT of_dma_configure API
@ 2019-10-09 11:42   ` Oleksandr Andrushchenko
  0 siblings, 0 replies; 12+ messages in thread
From: Oleksandr Andrushchenko @ 2019-10-09 11:42 UTC (permalink / raw)
  To: Rob Herring, xen-devel
  Cc: Juergen Gross, Stefano Stabellini, linux-kernel, Julien Grall,
	Boris Ostrovsky, Robin Murphy, Christoph Hellwig,
	Nicolas Saenz Julienne

On 10/8/19 10:41 PM, Rob Herring wrote:
> As the removed comments say, these aren't DT based devices.
> of_dma_configure() is going to stop allowing a NULL DT node and calling
> it will no longer work.
>
> The comment is also now out of date as of commit 9ab91e7c5c51 ("arm64:
> default to the direct mapping in get_arch_dma_ops"). Direct mapping
> is now the default rather than dma_dummy_ops.
>
> According to Stefano and Oleksandr, the only other part needed is
> setting the DMA masks and there's no reason to restrict the masks to
> 32-bits. So set the masks to 64 bits.
>
> 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: Christoph Hellwig <hch@lst.de>
> Cc: xen-devel@lists.xenproject.org
> Signed-off-by: Rob Herring <robh@kernel.org>
Acked-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

Unfortunately I cannot test this patch with real HW running Xen:
I am still on 4.14 kernel which is dictated by the board's BSP and
it is not possible to have more recent one at the moment.
So, I hope the patch will work as intended.

Thank you,
Oleksandr
> ---
> v2:
>   - Setup dma masks
>   - Also fix xen_drm_front.c
>   
> This can now be applied to the Xen tree independent of the coming
> of_dma_configure() changes.
>
> Rob
>
>   drivers/gpu/drm/xen/xen_drm_front.c | 12 ++----------
>   drivers/xen/gntdev.c                | 13 ++-----------
>   2 files changed, 4 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/xen/xen_drm_front.c b/drivers/gpu/drm/xen/xen_drm_front.c
> index ba1828acd8c9..4be49c1aef51 100644
> --- a/drivers/gpu/drm/xen/xen_drm_front.c
> +++ b/drivers/gpu/drm/xen/xen_drm_front.c
> @@ -718,17 +718,9 @@ 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);
> +	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
>   	if (ret < 0) {
> -		DRM_ERROR("Cannot setup DMA ops, ret %d", ret);
> +		DRM_ERROR("Cannot setup DMA mask, ret %d", ret);
>   		return ret;
>   	}
>   
> diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
> index a446a7221e13..81401f386c9c 100644
> --- a/drivers/xen/gntdev.c
> +++ b/drivers/xen/gntdev.c
> @@ -22,6 +22,7 @@
>   
>   #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt
>   
> +#include <linux/dma-mapping.h>
>   #include <linux/module.h>
>   #include <linux/kernel.h>
>   #include <linux/init.h>
> @@ -34,9 +35,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 +623,7 @@ 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);
> +	dma_coerce_mask_and_coherent(priv->dma_dev, DMA_BIT_MASK(64));
>   #endif
>   	pr_debug("priv %p\n", priv);
>   
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] xen: Stop abusing DT of_dma_configure API
  2019-10-09 11:42   ` [Xen-devel] " Oleksandr Andrushchenko
@ 2019-10-10 13:59     ` Boris Ostrovsky
  -1 siblings, 0 replies; 12+ messages in thread
From: Boris Ostrovsky @ 2019-10-10 13:59 UTC (permalink / raw)
  To: Oleksandr Andrushchenko, Rob Herring, xen-devel
  Cc: linux-kernel, Robin Murphy, Julien Grall, Nicolas Saenz Julienne,
	Juergen Gross, Stefano Stabellini, Christoph Hellwig

On 10/9/19 7:42 AM, Oleksandr Andrushchenko wrote:
> On 10/8/19 10:41 PM, Rob Herring wrote:
>> As the removed comments say, these aren't DT based devices.
>> of_dma_configure() is going to stop allowing a NULL DT node and calling
>> it will no longer work.
>>
>> The comment is also now out of date as of commit 9ab91e7c5c51 ("arm64:
>> default to the direct mapping in get_arch_dma_ops"). Direct mapping
>> is now the default rather than dma_dummy_ops.
>>
>> According to Stefano and Oleksandr, the only other part needed is
>> setting the DMA masks and there's no reason to restrict the masks to
>> 32-bits. So set the masks to 64 bits.
>>
>> 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: Christoph Hellwig <hch@lst.de>
>> Cc: xen-devel@lists.xenproject.org
>> Signed-off-by: Rob Herring <robh@kernel.org>
> Acked-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>


Is this going to go via drm tree or should I pick it up for Xen tree?

-boris



>
> Unfortunately I cannot test this patch with real HW running Xen:
> I am still on 4.14 kernel which is dictated by the board's BSP and
> it is not possible to have more recent one at the moment.
> So, I hope the patch will work as intended.
>
> Thank you,
> Oleksandr
>> ---
>> v2:
>>   - Setup dma masks
>>   - Also fix xen_drm_front.c
>>   
>> This can now be applied to the Xen tree independent of the coming
>> of_dma_configure() changes.
>>
>> Rob
>>
>>   drivers/gpu/drm/xen/xen_drm_front.c | 12 ++----------
>>   drivers/xen/gntdev.c                | 13 ++-----------
>>   2 files changed, 4 insertions(+), 21 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xen/xen_drm_front.c b/drivers/gpu/drm/xen/xen_drm_front.c
>> index ba1828acd8c9..4be49c1aef51 100644
>> --- a/drivers/gpu/drm/xen/xen_drm_front.c
>> +++ b/drivers/gpu/drm/xen/xen_drm_front.c
>> @@ -718,17 +718,9 @@ 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);
>> +	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
>>   	if (ret < 0) {
>> -		DRM_ERROR("Cannot setup DMA ops, ret %d", ret);
>> +		DRM_ERROR("Cannot setup DMA mask, ret %d", ret);
>>   		return ret;
>>   	}
>>   
>> diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
>> index a446a7221e13..81401f386c9c 100644
>> --- a/drivers/xen/gntdev.c
>> +++ b/drivers/xen/gntdev.c
>> @@ -22,6 +22,7 @@
>>   
>>   #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt
>>   
>> +#include <linux/dma-mapping.h>
>>   #include <linux/module.h>
>>   #include <linux/kernel.h>
>>   #include <linux/init.h>
>> @@ -34,9 +35,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 +623,7 @@ 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);
>> +	dma_coerce_mask_and_coherent(priv->dma_dev, DMA_BIT_MASK(64));
>>   #endif
>>   	pr_debug("priv %p\n", priv);
>>   


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Xen-devel] [PATCH v2] xen: Stop abusing DT of_dma_configure API
@ 2019-10-10 13:59     ` Boris Ostrovsky
  0 siblings, 0 replies; 12+ messages in thread
From: Boris Ostrovsky @ 2019-10-10 13:59 UTC (permalink / raw)
  To: Oleksandr Andrushchenko, Rob Herring, xen-devel
  Cc: Juergen Gross, Stefano Stabellini, linux-kernel, Julien Grall,
	Robin Murphy, Christoph Hellwig, Nicolas Saenz Julienne

On 10/9/19 7:42 AM, Oleksandr Andrushchenko wrote:
> On 10/8/19 10:41 PM, Rob Herring wrote:
>> As the removed comments say, these aren't DT based devices.
>> of_dma_configure() is going to stop allowing a NULL DT node and calling
>> it will no longer work.
>>
>> The comment is also now out of date as of commit 9ab91e7c5c51 ("arm64:
>> default to the direct mapping in get_arch_dma_ops"). Direct mapping
>> is now the default rather than dma_dummy_ops.
>>
>> According to Stefano and Oleksandr, the only other part needed is
>> setting the DMA masks and there's no reason to restrict the masks to
>> 32-bits. So set the masks to 64 bits.
>>
>> 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: Christoph Hellwig <hch@lst.de>
>> Cc: xen-devel@lists.xenproject.org
>> Signed-off-by: Rob Herring <robh@kernel.org>
> Acked-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>


Is this going to go via drm tree or should I pick it up for Xen tree?

-boris



>
> Unfortunately I cannot test this patch with real HW running Xen:
> I am still on 4.14 kernel which is dictated by the board's BSP and
> it is not possible to have more recent one at the moment.
> So, I hope the patch will work as intended.
>
> Thank you,
> Oleksandr
>> ---
>> v2:
>>   - Setup dma masks
>>   - Also fix xen_drm_front.c
>>   
>> This can now be applied to the Xen tree independent of the coming
>> of_dma_configure() changes.
>>
>> Rob
>>
>>   drivers/gpu/drm/xen/xen_drm_front.c | 12 ++----------
>>   drivers/xen/gntdev.c                | 13 ++-----------
>>   2 files changed, 4 insertions(+), 21 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xen/xen_drm_front.c b/drivers/gpu/drm/xen/xen_drm_front.c
>> index ba1828acd8c9..4be49c1aef51 100644
>> --- a/drivers/gpu/drm/xen/xen_drm_front.c
>> +++ b/drivers/gpu/drm/xen/xen_drm_front.c
>> @@ -718,17 +718,9 @@ 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);
>> +	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
>>   	if (ret < 0) {
>> -		DRM_ERROR("Cannot setup DMA ops, ret %d", ret);
>> +		DRM_ERROR("Cannot setup DMA mask, ret %d", ret);
>>   		return ret;
>>   	}
>>   
>> diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
>> index a446a7221e13..81401f386c9c 100644
>> --- a/drivers/xen/gntdev.c
>> +++ b/drivers/xen/gntdev.c
>> @@ -22,6 +22,7 @@
>>   
>>   #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt
>>   
>> +#include <linux/dma-mapping.h>
>>   #include <linux/module.h>
>>   #include <linux/kernel.h>
>>   #include <linux/init.h>
>> @@ -34,9 +35,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 +623,7 @@ 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);
>> +	dma_coerce_mask_and_coherent(priv->dma_dev, DMA_BIT_MASK(64));
>>   #endif
>>   	pr_debug("priv %p\n", priv);
>>   


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] xen: Stop abusing DT of_dma_configure API
  2019-10-10 13:59     ` [Xen-devel] " Boris Ostrovsky
@ 2019-10-10 15:32       ` Rob Herring
  -1 siblings, 0 replies; 12+ messages in thread
From: Rob Herring @ 2019-10-10 15:32 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Oleksandr Andrushchenko, xen-devel, linux-kernel, Robin Murphy,
	Julien Grall, Nicolas Saenz Julienne, Juergen Gross,
	Stefano Stabellini, Christoph Hellwig

On Thu, Oct 10, 2019 at 9:00 AM Boris Ostrovsky
<boris.ostrovsky@oracle.com> wrote:
>
> On 10/9/19 7:42 AM, Oleksandr Andrushchenko wrote:
> > On 10/8/19 10:41 PM, Rob Herring wrote:
> >> As the removed comments say, these aren't DT based devices.
> >> of_dma_configure() is going to stop allowing a NULL DT node and calling
> >> it will no longer work.
> >>
> >> The comment is also now out of date as of commit 9ab91e7c5c51 ("arm64:
> >> default to the direct mapping in get_arch_dma_ops"). Direct mapping
> >> is now the default rather than dma_dummy_ops.
> >>
> >> According to Stefano and Oleksandr, the only other part needed is
> >> setting the DMA masks and there's no reason to restrict the masks to
> >> 32-bits. So set the masks to 64 bits.
> >>
> >> 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: Christoph Hellwig <hch@lst.de>
> >> Cc: xen-devel@lists.xenproject.org
> >> Signed-off-by: Rob Herring <robh@kernel.org>
> > Acked-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>
>
> Is this going to go via drm tree or should I pick it up for Xen tree?

Please apply to the Xen tree.

Rob

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Xen-devel] [PATCH v2] xen: Stop abusing DT of_dma_configure API
@ 2019-10-10 15:32       ` Rob Herring
  0 siblings, 0 replies; 12+ messages in thread
From: Rob Herring @ 2019-10-10 15:32 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Juergen Gross, Stefano Stabellini, Oleksandr Andrushchenko,
	linux-kernel, Julien Grall, xen-devel, Robin Murphy,
	Christoph Hellwig, Nicolas Saenz Julienne

On Thu, Oct 10, 2019 at 9:00 AM Boris Ostrovsky
<boris.ostrovsky@oracle.com> wrote:
>
> On 10/9/19 7:42 AM, Oleksandr Andrushchenko wrote:
> > On 10/8/19 10:41 PM, Rob Herring wrote:
> >> As the removed comments say, these aren't DT based devices.
> >> of_dma_configure() is going to stop allowing a NULL DT node and calling
> >> it will no longer work.
> >>
> >> The comment is also now out of date as of commit 9ab91e7c5c51 ("arm64:
> >> default to the direct mapping in get_arch_dma_ops"). Direct mapping
> >> is now the default rather than dma_dummy_ops.
> >>
> >> According to Stefano and Oleksandr, the only other part needed is
> >> setting the DMA masks and there's no reason to restrict the masks to
> >> 32-bits. So set the masks to 64 bits.
> >>
> >> 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: Christoph Hellwig <hch@lst.de>
> >> Cc: xen-devel@lists.xenproject.org
> >> Signed-off-by: Rob Herring <robh@kernel.org>
> > Acked-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>
>
> Is this going to go via drm tree or should I pick it up for Xen tree?

Please apply to the Xen tree.

Rob

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] xen: Stop abusing DT of_dma_configure API
  2019-10-10 15:32       ` [Xen-devel] " Rob Herring
@ 2019-10-10 15:44         ` Boris Ostrovsky
  -1 siblings, 0 replies; 12+ messages in thread
From: Boris Ostrovsky @ 2019-10-10 15:44 UTC (permalink / raw)
  To: Rob Herring
  Cc: Oleksandr Andrushchenko, xen-devel, linux-kernel, Robin Murphy,
	Julien Grall, Nicolas Saenz Julienne, Juergen Gross,
	Stefano Stabellini, Christoph Hellwig

On 10/10/19 11:32 AM, Rob Herring wrote:
> On Thu, Oct 10, 2019 at 9:00 AM Boris Ostrovsky
> <boris.ostrovsky@oracle.com> wrote:
>> On 10/9/19 7:42 AM, Oleksandr Andrushchenko wrote:
>>> On 10/8/19 10:41 PM, Rob Herring wrote:
>>>> As the removed comments say, these aren't DT based devices.
>>>> of_dma_configure() is going to stop allowing a NULL DT node and calling
>>>> it will no longer work.
>>>>
>>>> The comment is also now out of date as of commit 9ab91e7c5c51 ("arm64:
>>>> default to the direct mapping in get_arch_dma_ops"). Direct mapping
>>>> is now the default rather than dma_dummy_ops.
>>>>
>>>> According to Stefano and Oleksandr, the only other part needed is
>>>> setting the DMA masks and there's no reason to restrict the masks to
>>>> 32-bits. So set the masks to 64 bits.
>>>>
>>>> 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: Christoph Hellwig <hch@lst.de>
>>>> Cc: xen-devel@lists.xenproject.org
>>>> Signed-off-by: Rob Herring <robh@kernel.org>
>>> Acked-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>>
>> Is this going to go via drm tree or should I pick it up for Xen tree?
> Please apply to the Xen tree.

Ok. FTR,

Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Xen-devel] [PATCH v2] xen: Stop abusing DT of_dma_configure API
@ 2019-10-10 15:44         ` Boris Ostrovsky
  0 siblings, 0 replies; 12+ messages in thread
From: Boris Ostrovsky @ 2019-10-10 15:44 UTC (permalink / raw)
  To: Rob Herring
  Cc: Juergen Gross, Stefano Stabellini, Oleksandr Andrushchenko,
	linux-kernel, Julien Grall, xen-devel, Robin Murphy,
	Christoph Hellwig, Nicolas Saenz Julienne

On 10/10/19 11:32 AM, Rob Herring wrote:
> On Thu, Oct 10, 2019 at 9:00 AM Boris Ostrovsky
> <boris.ostrovsky@oracle.com> wrote:
>> On 10/9/19 7:42 AM, Oleksandr Andrushchenko wrote:
>>> On 10/8/19 10:41 PM, Rob Herring wrote:
>>>> As the removed comments say, these aren't DT based devices.
>>>> of_dma_configure() is going to stop allowing a NULL DT node and calling
>>>> it will no longer work.
>>>>
>>>> The comment is also now out of date as of commit 9ab91e7c5c51 ("arm64:
>>>> default to the direct mapping in get_arch_dma_ops"). Direct mapping
>>>> is now the default rather than dma_dummy_ops.
>>>>
>>>> According to Stefano and Oleksandr, the only other part needed is
>>>> setting the DMA masks and there's no reason to restrict the masks to
>>>> 32-bits. So set the masks to 64 bits.
>>>>
>>>> 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: Christoph Hellwig <hch@lst.de>
>>>> Cc: xen-devel@lists.xenproject.org
>>>> Signed-off-by: Rob Herring <robh@kernel.org>
>>> Acked-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>>
>> Is this going to go via drm tree or should I pick it up for Xen tree?
> Please apply to the Xen tree.

Ok. FTR,

Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>




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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] xen: Stop abusing DT of_dma_configure API
  2019-10-08 19:41 ` [Xen-devel] " Rob Herring
@ 2019-10-11  1:42   ` Stefano Stabellini
  -1 siblings, 0 replies; 12+ messages in thread
From: Stefano Stabellini @ 2019-10-11  1:42 UTC (permalink / raw)
  To: Rob Herring
  Cc: xen-devel, linux-kernel, Robin Murphy, Julien Grall,
	Nicolas Saenz Julienne, Oleksandr Andrushchenko, Boris Ostrovsky,
	Juergen Gross, Stefano Stabellini, Christoph Hellwig

On Tue, 8 Oct 2019, Rob Herring wrote:
> As the removed comments say, these aren't DT based devices.
> of_dma_configure() is going to stop allowing a NULL DT node and calling
> it will no longer work.
> 
> The comment is also now out of date as of commit 9ab91e7c5c51 ("arm64:
> default to the direct mapping in get_arch_dma_ops"). Direct mapping
> is now the default rather than dma_dummy_ops.
> 
> According to Stefano and Oleksandr, the only other part needed is
> setting the DMA masks and there's no reason to restrict the masks to
> 32-bits. So set the masks to 64 bits.
> 
> 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: Christoph Hellwig <hch@lst.de>
> Cc: xen-devel@lists.xenproject.org
> Signed-off-by: Rob Herring <robh@kernel.org>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
> v2:
>  - Setup dma masks
>  - Also fix xen_drm_front.c
>  
> This can now be applied to the Xen tree independent of the coming
> of_dma_configure() changes.
> 
> Rob
> 
>  drivers/gpu/drm/xen/xen_drm_front.c | 12 ++----------
>  drivers/xen/gntdev.c                | 13 ++-----------
>  2 files changed, 4 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xen/xen_drm_front.c b/drivers/gpu/drm/xen/xen_drm_front.c
> index ba1828acd8c9..4be49c1aef51 100644
> --- a/drivers/gpu/drm/xen/xen_drm_front.c
> +++ b/drivers/gpu/drm/xen/xen_drm_front.c
> @@ -718,17 +718,9 @@ 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);
> +	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
>  	if (ret < 0) {
> -		DRM_ERROR("Cannot setup DMA ops, ret %d", ret);
> +		DRM_ERROR("Cannot setup DMA mask, ret %d", ret);
>  		return ret;
>  	}
>  
> diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
> index a446a7221e13..81401f386c9c 100644
> --- a/drivers/xen/gntdev.c
> +++ b/drivers/xen/gntdev.c
> @@ -22,6 +22,7 @@
>  
>  #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt
>  
> +#include <linux/dma-mapping.h>
>  #include <linux/module.h>
>  #include <linux/kernel.h>
>  #include <linux/init.h>
> @@ -34,9 +35,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 +623,7 @@ 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);
> +	dma_coerce_mask_and_coherent(priv->dma_dev, DMA_BIT_MASK(64));
>  #endif
>  	pr_debug("priv %p\n", priv);
>  
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Xen-devel] [PATCH v2] xen: Stop abusing DT of_dma_configure API
@ 2019-10-11  1:42   ` Stefano Stabellini
  0 siblings, 0 replies; 12+ messages in thread
From: Stefano Stabellini @ 2019-10-11  1:42 UTC (permalink / raw)
  To: Rob Herring
  Cc: Juergen Gross, Stefano Stabellini, Oleksandr Andrushchenko,
	linux-kernel, Julien Grall, xen-devel, Boris Ostrovsky,
	Robin Murphy, Christoph Hellwig, Nicolas Saenz Julienne

On Tue, 8 Oct 2019, Rob Herring wrote:
> As the removed comments say, these aren't DT based devices.
> of_dma_configure() is going to stop allowing a NULL DT node and calling
> it will no longer work.
> 
> The comment is also now out of date as of commit 9ab91e7c5c51 ("arm64:
> default to the direct mapping in get_arch_dma_ops"). Direct mapping
> is now the default rather than dma_dummy_ops.
> 
> According to Stefano and Oleksandr, the only other part needed is
> setting the DMA masks and there's no reason to restrict the masks to
> 32-bits. So set the masks to 64 bits.
> 
> 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: Christoph Hellwig <hch@lst.de>
> Cc: xen-devel@lists.xenproject.org
> Signed-off-by: Rob Herring <robh@kernel.org>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
> v2:
>  - Setup dma masks
>  - Also fix xen_drm_front.c
>  
> This can now be applied to the Xen tree independent of the coming
> of_dma_configure() changes.
> 
> Rob
> 
>  drivers/gpu/drm/xen/xen_drm_front.c | 12 ++----------
>  drivers/xen/gntdev.c                | 13 ++-----------
>  2 files changed, 4 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xen/xen_drm_front.c b/drivers/gpu/drm/xen/xen_drm_front.c
> index ba1828acd8c9..4be49c1aef51 100644
> --- a/drivers/gpu/drm/xen/xen_drm_front.c
> +++ b/drivers/gpu/drm/xen/xen_drm_front.c
> @@ -718,17 +718,9 @@ 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);
> +	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
>  	if (ret < 0) {
> -		DRM_ERROR("Cannot setup DMA ops, ret %d", ret);
> +		DRM_ERROR("Cannot setup DMA mask, ret %d", ret);
>  		return ret;
>  	}
>  
> diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
> index a446a7221e13..81401f386c9c 100644
> --- a/drivers/xen/gntdev.c
> +++ b/drivers/xen/gntdev.c
> @@ -22,6 +22,7 @@
>  
>  #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt
>  
> +#include <linux/dma-mapping.h>
>  #include <linux/module.h>
>  #include <linux/kernel.h>
>  #include <linux/init.h>
> @@ -34,9 +35,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 +623,7 @@ 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);
> +	dma_coerce_mask_and_coherent(priv->dma_dev, DMA_BIT_MASK(64));
>  #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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-10-11  1:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-08 19:41 [PATCH v2] xen: Stop abusing DT of_dma_configure API Rob Herring
2019-10-08 19:41 ` [Xen-devel] " Rob Herring
2019-10-09 11:42 ` Oleksandr Andrushchenko
2019-10-09 11:42   ` [Xen-devel] " Oleksandr Andrushchenko
2019-10-10 13:59   ` Boris Ostrovsky
2019-10-10 13:59     ` [Xen-devel] " Boris Ostrovsky
2019-10-10 15:32     ` Rob Herring
2019-10-10 15:32       ` [Xen-devel] " Rob Herring
2019-10-10 15:44       ` Boris Ostrovsky
2019-10-10 15:44         ` [Xen-devel] " Boris Ostrovsky
2019-10-11  1:42 ` Stefano Stabellini
2019-10-11  1:42   ` [Xen-devel] " Stefano Stabellini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.