Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1340326 > unrolled thread

[PATCH 1/2] drm/tegra: Set DMA ops

Started byAlexandre Courbot <acourbot@nvidia.com>
First post2016-02-23 07:30 +0100
Last post2016-02-24 09:40 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/2] drm/tegra: Set DMA ops Alexandre Courbot <acourbot@nvidia.com> - 2016-02-23 07:30 +0100
    Re: [PATCH 1/2] drm/tegra: Set DMA ops Thierry Reding <thierry.reding@gmail.com> - 2016-02-23 16:30 +0100
      Re: [PATCH 1/2] drm/tegra: Set DMA ops Alexandre Courbot <acourbot@nvidia.com> - 2016-02-24 09:40 +0100

#1340326 — [PATCH 1/2] drm/tegra: Set DMA ops

FromAlexandre Courbot <acourbot@nvidia.com>
Date2016-02-23 07:30 +0100
Subject[PATCH 1/2] drm/tegra: Set DMA ops
Message-ID<r5eDU-1jC-5@gated-at.bofh.it>
The current settings leaves the DRM device's dma_ops field NULL, which
makes it use the dummy DMA ops on arm64 and return an error whenever we
try to import a buffer. Call of_dma_configure() with a NULL node (since
the device is not spawn from the device tree) so that
arch_setup_dma_ops() is called and sets the default ioswtlb DMA ops.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/gpu/drm/tegra/drm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index d347188bf8f4..bc0555adecaf 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -9,6 +9,7 @@
 
 #include <linux/host1x.h>
 #include <linux/iommu.h>
+#include <linux/of_device.h>
 
 #include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
@@ -990,6 +991,7 @@ static int host1x_drm_probe(struct host1x_device *dev)
 		return -ENOMEM;
 
 	dev_set_drvdata(&dev->dev, drm);
+	of_dma_configure(drm->dev, NULL);
 
 	err = drm_dev_register(drm, 0);
 	if (err < 0)
-- 
2.7.1

[toc] | [next] | [standalone]


#1340783

FromThierry Reding <thierry.reding@gmail.com>
Date2016-02-23 16:30 +0100
Message-ID<r5n4u-7ic-17@gated-at.bofh.it>
In reply to#1340326

[Multipart message — attachments visible in raw view] — view raw

On Tue, Feb 23, 2016 at 03:25:53PM +0900, Alexandre Courbot wrote:
> The current settings leaves the DRM device's dma_ops field NULL, which
> makes it use the dummy DMA ops on arm64 and return an error whenever we
> try to import a buffer. Call of_dma_configure() with a NULL node (since
> the device is not spawn from the device tree) so that
> arch_setup_dma_ops() is called and sets the default ioswtlb DMA ops.
> 
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
>  drivers/gpu/drm/tegra/drm.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
> index d347188bf8f4..bc0555adecaf 100644
> --- a/drivers/gpu/drm/tegra/drm.c
> +++ b/drivers/gpu/drm/tegra/drm.c
> @@ -9,6 +9,7 @@
>  
>  #include <linux/host1x.h>
>  #include <linux/iommu.h>
> +#include <linux/of_device.h>
>  
>  #include <drm/drm_atomic.h>
>  #include <drm/drm_atomic_helper.h>
> @@ -990,6 +991,7 @@ static int host1x_drm_probe(struct host1x_device *dev)
>  		return -ENOMEM;
>  
>  	dev_set_drvdata(&dev->dev, drm);
> +	of_dma_configure(drm->dev, NULL);

Looking at the various pieces, I think this really belongs in
host1x_device_add() (see drivers/gpu/host1x/bus.c) where it can replace
the open-coded setting of DMA and coherent DMA masks. Also why can't we
pass the correct device tree node here? The DRM device is a virtual
device that hangs off the host1x device, so I think it could use the
same device tree node as the host1x device.

Something like the below (untested).

Thierry

--- >8 ---
diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
index c2e7fba370bb..d46d26a574da 100644
--- a/drivers/gpu/host1x/bus.c
+++ b/drivers/gpu/host1x/bus.c
@@ -17,6 +17,7 @@
 
 #include <linux/host1x.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/slab.h>
 
 #include "bus.h"
@@ -393,9 +394,8 @@ static int host1x_device_add(struct host1x *host1x,
 	INIT_LIST_HEAD(&device->list);
 	device->driver = driver;
 
-	device->dev.coherent_dma_mask = host1x->dev->coherent_dma_mask;
-	device->dev.dma_mask = &device->dev.coherent_dma_mask;
 	dev_set_name(&device->dev, "%s", driver->driver.name);
+	of_dma_configure(&device->dev, host1x->dev->of_node);
 	device->dev.release = host1x_device_release;
 	device->dev.bus = &host1x_bus_type;
 	device->dev.parent = host1x->dev;

[toc] | [prev] | [next] | [standalone]


#1341648

FromAlexandre Courbot <acourbot@nvidia.com>
Date2016-02-24 09:40 +0100
Message-ID<r5D9g-1Oq-19@gated-at.bofh.it>
In reply to#1340783
On 02/24/2016 12:28 AM, Thierry Reding wrote:
> * PGP Signed by an unknown key
>
> On Tue, Feb 23, 2016 at 03:25:53PM +0900, Alexandre Courbot wrote:
>> The current settings leaves the DRM device's dma_ops field NULL, which
>> makes it use the dummy DMA ops on arm64 and return an error whenever we
>> try to import a buffer. Call of_dma_configure() with a NULL node (since
>> the device is not spawn from the device tree) so that
>> arch_setup_dma_ops() is called and sets the default ioswtlb DMA ops.
>>
>> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
>> ---
>>   drivers/gpu/drm/tegra/drm.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
>> index d347188bf8f4..bc0555adecaf 100644
>> --- a/drivers/gpu/drm/tegra/drm.c
>> +++ b/drivers/gpu/drm/tegra/drm.c
>> @@ -9,6 +9,7 @@
>>
>>   #include <linux/host1x.h>
>>   #include <linux/iommu.h>
>> +#include <linux/of_device.h>
>>
>>   #include <drm/drm_atomic.h>
>>   #include <drm/drm_atomic_helper.h>
>> @@ -990,6 +991,7 @@ static int host1x_drm_probe(struct host1x_device *dev)
>>   		return -ENOMEM;
>>
>>   	dev_set_drvdata(&dev->dev, drm);
>> +	of_dma_configure(drm->dev, NULL);
>
> Looking at the various pieces, I think this really belongs in
> host1x_device_add() (see drivers/gpu/host1x/bus.c) where it can replace
> the open-coded setting of DMA and coherent DMA masks. Also why can't we
> pass the correct device tree node here? The DRM device is a virtual
> device that hangs off the host1x device, so I think it could use the
> same device tree node as the host1x device.
>
> Something like the below (untested).

You're right, that looks like a much better place to do this. 
of_dma_configure() is called at the bus level (platform and PCI), so it 
makes sense to do it from host1x too.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web