All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] iommu/tegra: gart: Remove unnecessary cleanup with devm_*()
@ 2012-05-14 18:12 ` Hiroshi DOYU
  0 siblings, 0 replies; 26+ messages in thread
From: Hiroshi DOYU @ 2012-05-14 18:12 UTC (permalink / raw)
  To: hdoyu-DDmLM1+adcrQT0dZR+AlfA
  Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA, Joerg Roedel, Stephen Warren,
	Bharat Nihalani, Vandana Salve,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Remove unnecessary cleanup procedures with devm_*().

Signed-off-by: Hiroshi DOYU <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 drivers/iommu/tegra-gart.c |   22 +++-------------------
 1 files changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
index 0c0a377..33a23b6 100644
--- a/drivers/iommu/tegra-gart.c
+++ b/drivers/iommu/tegra-gart.c
@@ -345,7 +345,6 @@ static int tegra_gart_probe(struct platform_device *pdev)
 	struct gart_device *gart;
 	struct resource *res, *res_remap;
 	void __iomem *gart_regs;
-	int err;
 	struct device *dev = &pdev->dev;
 
 	if (gart_handle)
@@ -370,8 +369,7 @@ static int tegra_gart_probe(struct platform_device *pdev)
 	gart_regs = devm_ioremap(dev, res->start, resource_size(res));
 	if (!gart_regs) {
 		dev_err(dev, "failed to remap GART registers\n");
-		err = -ENXIO;
-		goto fail;
+		return -ENXIO;
 	}
 
 	gart->dev = &pdev->dev;
@@ -385,8 +383,7 @@ static int tegra_gart_probe(struct platform_device *pdev)
 	gart->savedata = vmalloc(sizeof(u32) * gart->page_count);
 	if (!gart->savedata) {
 		dev_err(dev, "failed to allocate context save area\n");
-		err = -ENOMEM;
-		goto fail;
+		return -ENOMEM;
 	}
 
 	platform_set_drvdata(pdev, gart);
@@ -394,27 +391,14 @@ static int tegra_gart_probe(struct platform_device *pdev)
 
 	gart_handle = gart;
 	return 0;
-
-fail:
-	if (gart_regs)
-		devm_iounmap(dev, gart_regs);
-	if (gart && gart->savedata)
-		vfree(gart->savedata);
-	devm_kfree(dev, gart);
-	return err;
 }
 
 static int tegra_gart_remove(struct platform_device *pdev)
 {
 	struct gart_device *gart = platform_get_drvdata(pdev);
-	struct device *dev = gart->dev;
 
 	writel(0, gart->regs + GART_CONFIG);
-	if (gart->savedata)
-		vfree(gart->savedata);
-	if (gart->regs)
-		devm_iounmap(dev, gart->regs);
-	devm_kfree(dev, gart);
+	vfree(gart->savedata);
 	gart_handle = NULL;
 	return 0;
 }
-- 
1.7.5.4

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

* [PATCH 1/2] iommu/tegra: gart: Remove unnecessary cleanup with devm_*()
@ 2012-05-14 18:12 ` Hiroshi DOYU
  0 siblings, 0 replies; 26+ messages in thread
From: Hiroshi DOYU @ 2012-05-14 18:12 UTC (permalink / raw)
  To: hdoyu
  Cc: linux-tegra, Joerg Roedel, Stephen Warren, Bharat Nihalani,
	Vandana Salve, linux-kernel

Remove unnecessary cleanup procedures with devm_*().

Signed-off-by: Hiroshi DOYU <hdoyu@nvidia.com>
---
 drivers/iommu/tegra-gart.c |   22 +++-------------------
 1 files changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
index 0c0a377..33a23b6 100644
--- a/drivers/iommu/tegra-gart.c
+++ b/drivers/iommu/tegra-gart.c
@@ -345,7 +345,6 @@ static int tegra_gart_probe(struct platform_device *pdev)
 	struct gart_device *gart;
 	struct resource *res, *res_remap;
 	void __iomem *gart_regs;
-	int err;
 	struct device *dev = &pdev->dev;
 
 	if (gart_handle)
@@ -370,8 +369,7 @@ static int tegra_gart_probe(struct platform_device *pdev)
 	gart_regs = devm_ioremap(dev, res->start, resource_size(res));
 	if (!gart_regs) {
 		dev_err(dev, "failed to remap GART registers\n");
-		err = -ENXIO;
-		goto fail;
+		return -ENXIO;
 	}
 
 	gart->dev = &pdev->dev;
@@ -385,8 +383,7 @@ static int tegra_gart_probe(struct platform_device *pdev)
 	gart->savedata = vmalloc(sizeof(u32) * gart->page_count);
 	if (!gart->savedata) {
 		dev_err(dev, "failed to allocate context save area\n");
-		err = -ENOMEM;
-		goto fail;
+		return -ENOMEM;
 	}
 
 	platform_set_drvdata(pdev, gart);
@@ -394,27 +391,14 @@ static int tegra_gart_probe(struct platform_device *pdev)
 
 	gart_handle = gart;
 	return 0;
-
-fail:
-	if (gart_regs)
-		devm_iounmap(dev, gart_regs);
-	if (gart && gart->savedata)
-		vfree(gart->savedata);
-	devm_kfree(dev, gart);
-	return err;
 }
 
 static int tegra_gart_remove(struct platform_device *pdev)
 {
 	struct gart_device *gart = platform_get_drvdata(pdev);
-	struct device *dev = gart->dev;
 
 	writel(0, gart->regs + GART_CONFIG);
-	if (gart->savedata)
-		vfree(gart->savedata);
-	if (gart->regs)
-		devm_iounmap(dev, gart->regs);
-	devm_kfree(dev, gart);
+	vfree(gart->savedata);
 	gart_handle = NULL;
 	return 0;
 }
-- 
1.7.5.4


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

* [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
  2012-05-14 18:12 ` Hiroshi DOYU
@ 2012-05-14 18:12   ` Hiroshi DOYU
  -1 siblings, 0 replies; 26+ messages in thread
From: Hiroshi DOYU @ 2012-05-14 18:12 UTC (permalink / raw)
  To: hdoyu
  Cc: linux-tegra, Joerg Roedel, Stephen Warren, Bharat Nihalani,
	Vandana Salve, linux-kernel

GART Register/Aperture range should be reserved.

Signed-off-by: Hiroshi DOYU <hdoyu@nvidia.com>
---
 drivers/iommu/tegra-gart.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
index 33a23b6..a431006 100644
--- a/drivers/iommu/tegra-gart.c
+++ b/drivers/iommu/tegra-gart.c
@@ -366,12 +366,18 @@ static int tegra_gart_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	gart_regs = devm_ioremap(dev, res->start, resource_size(res));
+	gart_regs = devm_request_and_ioremap(dev, res);
 	if (!gart_regs) {
 		dev_err(dev, "failed to remap GART registers\n");
 		return -ENXIO;
 	}
 
+	if (!devm_request_mem_region(dev, res_remap->start,
+				     resource_size(res_remap), dev_name(dev))) {
+		dev_err(dev, "failed to reserve GART aperture\n");
+		return -EBUSY;
+	}
+
 	gart->dev = &pdev->dev;
 	spin_lock_init(&gart->pte_lock);
 	spin_lock_init(&gart->client_lock);
-- 
1.7.5.4

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

* [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
@ 2012-05-14 18:12   ` Hiroshi DOYU
  0 siblings, 0 replies; 26+ messages in thread
From: Hiroshi DOYU @ 2012-05-14 18:12 UTC (permalink / raw)
  To: hdoyu
  Cc: linux-tegra, Joerg Roedel, Stephen Warren, Bharat Nihalani,
	Vandana Salve, linux-kernel

GART Register/Aperture range should be reserved.

Signed-off-by: Hiroshi DOYU <hdoyu@nvidia.com>
---
 drivers/iommu/tegra-gart.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
index 33a23b6..a431006 100644
--- a/drivers/iommu/tegra-gart.c
+++ b/drivers/iommu/tegra-gart.c
@@ -366,12 +366,18 @@ static int tegra_gart_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	gart_regs = devm_ioremap(dev, res->start, resource_size(res));
+	gart_regs = devm_request_and_ioremap(dev, res);
 	if (!gart_regs) {
 		dev_err(dev, "failed to remap GART registers\n");
 		return -ENXIO;
 	}
 
+	if (!devm_request_mem_region(dev, res_remap->start,
+				     resource_size(res_remap), dev_name(dev))) {
+		dev_err(dev, "failed to reserve GART aperture\n");
+		return -EBUSY;
+	}
+
 	gart->dev = &pdev->dev;
 	spin_lock_init(&gart->pte_lock);
 	spin_lock_init(&gart->client_lock);
-- 
1.7.5.4


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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
  2012-05-14 18:12   ` Hiroshi DOYU
@ 2012-05-21 14:11       ` Thierry Reding
  -1 siblings, 0 replies; 26+ messages in thread
From: Thierry Reding @ 2012-05-21 14:11 UTC (permalink / raw)
  To: Hiroshi DOYU
  Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA, Joerg Roedel, Stephen Warren,
	Bharat Nihalani, Vandana Salve,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 1193 bytes --]

* Hiroshi DOYU wrote:
> GART Register/Aperture range should be reserved.
> 
> Signed-off-by: Hiroshi DOYU <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---
>  drivers/iommu/tegra-gart.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
> index 33a23b6..a431006 100644
> --- a/drivers/iommu/tegra-gart.c
> +++ b/drivers/iommu/tegra-gart.c
> @@ -366,12 +366,18 @@ static int tegra_gart_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  	}
>  
> -	gart_regs = devm_ioremap(dev, res->start, resource_size(res));
> +	gart_regs = devm_request_and_ioremap(dev, res);
>  	if (!gart_regs) {
>  		dev_err(dev, "failed to remap GART registers\n");
>  		return -ENXIO;
>  	}
>  
> +	if (!devm_request_mem_region(dev, res_remap->start,
> +				     resource_size(res_remap), dev_name(dev))) {
> +		dev_err(dev, "failed to reserve GART aperture\n");
> +		return -EBUSY;
> +	}
> +

I'm not so sure that this is a good idea. If the GART driver requests the
GART aperture, then users of the GART aperture (e.g. the DRM driver) will no
longer be able to use it.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
@ 2012-05-21 14:11       ` Thierry Reding
  0 siblings, 0 replies; 26+ messages in thread
From: Thierry Reding @ 2012-05-21 14:11 UTC (permalink / raw)
  To: Hiroshi DOYU
  Cc: linux-tegra, Joerg Roedel, Stephen Warren, Bharat Nihalani,
	Vandana Salve, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1164 bytes --]

* Hiroshi DOYU wrote:
> GART Register/Aperture range should be reserved.
> 
> Signed-off-by: Hiroshi DOYU <hdoyu@nvidia.com>
> ---
>  drivers/iommu/tegra-gart.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
> index 33a23b6..a431006 100644
> --- a/drivers/iommu/tegra-gart.c
> +++ b/drivers/iommu/tegra-gart.c
> @@ -366,12 +366,18 @@ static int tegra_gart_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  	}
>  
> -	gart_regs = devm_ioremap(dev, res->start, resource_size(res));
> +	gart_regs = devm_request_and_ioremap(dev, res);
>  	if (!gart_regs) {
>  		dev_err(dev, "failed to remap GART registers\n");
>  		return -ENXIO;
>  	}
>  
> +	if (!devm_request_mem_region(dev, res_remap->start,
> +				     resource_size(res_remap), dev_name(dev))) {
> +		dev_err(dev, "failed to reserve GART aperture\n");
> +		return -EBUSY;
> +	}
> +

I'm not so sure that this is a good idea. If the GART driver requests the
GART aperture, then users of the GART aperture (e.g. the DRM driver) will no
longer be able to use it.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 1/2] iommu/tegra: gart: Remove unnecessary cleanup with devm_*()
  2012-05-14 18:12 ` Hiroshi DOYU
@ 2012-05-21 14:16     ` Thierry Reding
  -1 siblings, 0 replies; 26+ messages in thread
From: Thierry Reding @ 2012-05-21 14:16 UTC (permalink / raw)
  To: Hiroshi DOYU
  Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA, Joerg Roedel, Stephen Warren,
	Bharat Nihalani, Vandana Salve,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 386 bytes --]

* Hiroshi DOYU wrote:
> Remove unnecessary cleanup procedures with devm_*().
> 
> Signed-off-by: Hiroshi DOYU <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---
>  drivers/iommu/tegra-gart.c |   22 +++-------------------
>  1 files changed, 3 insertions(+), 19 deletions(-)
> 

Reviewed-by: Thierry Reding <thierry.reding-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org>

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 1/2] iommu/tegra: gart: Remove unnecessary cleanup with devm_*()
@ 2012-05-21 14:16     ` Thierry Reding
  0 siblings, 0 replies; 26+ messages in thread
From: Thierry Reding @ 2012-05-21 14:16 UTC (permalink / raw)
  To: Hiroshi DOYU
  Cc: linux-tegra, Joerg Roedel, Stephen Warren, Bharat Nihalani,
	Vandana Salve, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 325 bytes --]

* Hiroshi DOYU wrote:
> Remove unnecessary cleanup procedures with devm_*().
> 
> Signed-off-by: Hiroshi DOYU <hdoyu@nvidia.com>
> ---
>  drivers/iommu/tegra-gart.c |   22 +++-------------------
>  1 files changed, 3 insertions(+), 19 deletions(-)
> 

Reviewed-by: Thierry Reding <thierry.reding@avionic-design.de>

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
  2012-05-21 14:11       ` Thierry Reding
  (?)
@ 2012-05-21 16:41       ` Stephen Warren
       [not found]         ` <4FBA702A.1010203-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
  -1 siblings, 1 reply; 26+ messages in thread
From: Stephen Warren @ 2012-05-21 16:41 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Hiroshi DOYU, linux-tegra, Joerg Roedel, Bharat Nihalani,
	Vandana Salve, linux-kernel

On 05/21/2012 08:11 AM, Thierry Reding wrote:
> * Hiroshi DOYU wrote:
>> GART Register/Aperture range should be reserved.
...
>> diff --git a/drivers/iommu/tegra-gart.c
>> b/drivers/iommu/tegra-gart.c
...
>> +	if (!devm_request_mem_region(dev, res_remap->start, +
>> resource_size(res_remap), dev_name(dev))) { +		dev_err(dev,
>> "failed to reserve GART aperture\n"); +		return -EBUSY; +	} +
> 
> I'm not so sure that this is a good idea. If the GART driver
> requests the GART aperture, then users of the GART aperture (e.g.
> the DRM driver) will no longer be able to use it.

Presumably the DRM driver would be obtaining access to parts of the
GART aperture through the GART driver, rather than just grabbing the
IO region and using it for itself?

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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
  2012-05-21 16:41       ` Stephen Warren
@ 2012-05-21 17:05             ` Lucas Stach
  0 siblings, 0 replies; 26+ messages in thread
From: Lucas Stach @ 2012-05-21 17:05 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Thierry Reding, Hiroshi DOYU, linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	Joerg Roedel, Bharat Nihalani, Vandana Salve,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Am Montag, den 21.05.2012, 10:41 -0600 schrieb Stephen Warren:
> On 05/21/2012 08:11 AM, Thierry Reding wrote:
> > * Hiroshi DOYU wrote:
> >> GART Register/Aperture range should be reserved.
> ...
> >> diff --git a/drivers/iommu/tegra-gart.c
> >> b/drivers/iommu/tegra-gart.c
> ...
> >> +	if (!devm_request_mem_region(dev, res_remap->start, +
> >> resource_size(res_remap), dev_name(dev))) { +		dev_err(dev,
> >> "failed to reserve GART aperture\n"); +		return -EBUSY; +	} +
> > 
> > I'm not so sure that this is a good idea. If the GART driver
> > requests the GART aperture, then users of the GART aperture (e.g.
> > the DRM driver) will no longer be able to use it.
> 
> Presumably the DRM driver would be obtaining access to parts of the
> GART aperture through the GART driver, rather than just grabbing the
> IO region and using it for itself?

With a TTM-like memory manager the DRM driver will take over the address
space management of the GART aperture. The GART driver is only used to
set up the mappings in the IOMMU. The DRM driver is the one that sets
up/tears down the CPU mappings on demand, so the aperture should be
claimed in the DRM driver.

-- Lucas

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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
@ 2012-05-21 17:05             ` Lucas Stach
  0 siblings, 0 replies; 26+ messages in thread
From: Lucas Stach @ 2012-05-21 17:05 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Thierry Reding, Hiroshi DOYU, linux-tegra, Joerg Roedel,
	Bharat Nihalani, Vandana Salve, linux-kernel

Am Montag, den 21.05.2012, 10:41 -0600 schrieb Stephen Warren:
> On 05/21/2012 08:11 AM, Thierry Reding wrote:
> > * Hiroshi DOYU wrote:
> >> GART Register/Aperture range should be reserved.
> ...
> >> diff --git a/drivers/iommu/tegra-gart.c
> >> b/drivers/iommu/tegra-gart.c
> ...
> >> +	if (!devm_request_mem_region(dev, res_remap->start, +
> >> resource_size(res_remap), dev_name(dev))) { +		dev_err(dev,
> >> "failed to reserve GART aperture\n"); +		return -EBUSY; +	} +
> > 
> > I'm not so sure that this is a good idea. If the GART driver
> > requests the GART aperture, then users of the GART aperture (e.g.
> > the DRM driver) will no longer be able to use it.
> 
> Presumably the DRM driver would be obtaining access to parts of the
> GART aperture through the GART driver, rather than just grabbing the
> IO region and using it for itself?

With a TTM-like memory manager the DRM driver will take over the address
space management of the GART aperture. The GART driver is only used to
set up the mappings in the IOMMU. The DRM driver is the one that sets
up/tears down the CPU mappings on demand, so the aperture should be
claimed in the DRM driver.

-- Lucas



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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
  2012-05-21 17:05             ` Lucas Stach
@ 2012-05-21 17:14               ` Stephen Warren
  -1 siblings, 0 replies; 26+ messages in thread
From: Stephen Warren @ 2012-05-21 17:14 UTC (permalink / raw)
  To: Lucas Stach
  Cc: Thierry Reding, Hiroshi DOYU, linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	Joerg Roedel, Bharat Nihalani, Vandana Salve,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On 05/21/2012 11:05 AM, Lucas Stach wrote:
> Am Montag, den 21.05.2012, 10:41 -0600 schrieb Stephen Warren:
>> On 05/21/2012 08:11 AM, Thierry Reding wrote:
>>> * Hiroshi DOYU wrote:
>>>> GART Register/Aperture range should be reserved.
>> ...
>>>> diff --git a/drivers/iommu/tegra-gart.c
>>>> b/drivers/iommu/tegra-gart.c
>> ...
>>>> +	if (!devm_request_mem_region(dev, res_remap->start, +
>>>> resource_size(res_remap), dev_name(dev))) { +		dev_err(dev,
>>>> "failed to reserve GART aperture\n"); +		return -EBUSY; +	} +
>>>
>>> I'm not so sure that this is a good idea. If the GART driver
>>> requests the GART aperture, then users of the GART aperture (e.g.
>>> the DRM driver) will no longer be able to use it.
>>
>> Presumably the DRM driver would be obtaining access to parts of the
>> GART aperture through the GART driver, rather than just grabbing the
>> IO region and using it for itself?
> 
> With a TTM-like memory manager the DRM driver will take over the address
> space management of the GART aperture. The GART driver is only used to
> set up the mappings in the IOMMU. The DRM driver is the one that sets
> up/tears down the CPU mappings on demand, so the aperture should be
> claimed in the DRM driver.

Even if the DRM driver is managing the aperture, I still think the GART
driver should claim it. The physical address of the aperture is a
property of the GART, so only the GART's resources (and DT node) should
contain a representation of where that aperture is. The DRM driver
should call into the GART driver to find out where the aperture is, and
hence GART is able to claim it without conflict.

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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
@ 2012-05-21 17:14               ` Stephen Warren
  0 siblings, 0 replies; 26+ messages in thread
From: Stephen Warren @ 2012-05-21 17:14 UTC (permalink / raw)
  To: Lucas Stach
  Cc: Thierry Reding, Hiroshi DOYU, linux-tegra, Joerg Roedel,
	Bharat Nihalani, Vandana Salve, linux-kernel

On 05/21/2012 11:05 AM, Lucas Stach wrote:
> Am Montag, den 21.05.2012, 10:41 -0600 schrieb Stephen Warren:
>> On 05/21/2012 08:11 AM, Thierry Reding wrote:
>>> * Hiroshi DOYU wrote:
>>>> GART Register/Aperture range should be reserved.
>> ...
>>>> diff --git a/drivers/iommu/tegra-gart.c
>>>> b/drivers/iommu/tegra-gart.c
>> ...
>>>> +	if (!devm_request_mem_region(dev, res_remap->start, +
>>>> resource_size(res_remap), dev_name(dev))) { +		dev_err(dev,
>>>> "failed to reserve GART aperture\n"); +		return -EBUSY; +	} +
>>>
>>> I'm not so sure that this is a good idea. If the GART driver
>>> requests the GART aperture, then users of the GART aperture (e.g.
>>> the DRM driver) will no longer be able to use it.
>>
>> Presumably the DRM driver would be obtaining access to parts of the
>> GART aperture through the GART driver, rather than just grabbing the
>> IO region and using it for itself?
> 
> With a TTM-like memory manager the DRM driver will take over the address
> space management of the GART aperture. The GART driver is only used to
> set up the mappings in the IOMMU. The DRM driver is the one that sets
> up/tears down the CPU mappings on demand, so the aperture should be
> claimed in the DRM driver.

Even if the DRM driver is managing the aperture, I still think the GART
driver should claim it. The physical address of the aperture is a
property of the GART, so only the GART's resources (and DT node) should
contain a representation of where that aperture is. The DRM driver
should call into the GART driver to find out where the aperture is, and
hence GART is able to claim it without conflict.

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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
  2012-05-21 17:14               ` Stephen Warren
@ 2012-05-21 17:31                   ` Thierry Reding
  -1 siblings, 0 replies; 26+ messages in thread
From: Thierry Reding @ 2012-05-21 17:31 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Lucas Stach, Hiroshi DOYU, linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	Joerg Roedel, Bharat Nihalani, Vandana Salve,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 1914 bytes --]

* Stephen Warren wrote:
> On 05/21/2012 11:05 AM, Lucas Stach wrote:
> > Am Montag, den 21.05.2012, 10:41 -0600 schrieb Stephen Warren:
> >> On 05/21/2012 08:11 AM, Thierry Reding wrote:
> >>> * Hiroshi DOYU wrote:
> >>>> GART Register/Aperture range should be reserved.
> >> ...
> >>>> diff --git a/drivers/iommu/tegra-gart.c
> >>>> b/drivers/iommu/tegra-gart.c
> >> ...
> >>>> +	if (!devm_request_mem_region(dev, res_remap->start, +
> >>>> resource_size(res_remap), dev_name(dev))) { +		dev_err(dev,
> >>>> "failed to reserve GART aperture\n"); +		return -EBUSY; +	} +
> >>>
> >>> I'm not so sure that this is a good idea. If the GART driver
> >>> requests the GART aperture, then users of the GART aperture (e.g.
> >>> the DRM driver) will no longer be able to use it.
> >>
> >> Presumably the DRM driver would be obtaining access to parts of the
> >> GART aperture through the GART driver, rather than just grabbing the
> >> IO region and using it for itself?
> > 
> > With a TTM-like memory manager the DRM driver will take over the address
> > space management of the GART aperture. The GART driver is only used to
> > set up the mappings in the IOMMU. The DRM driver is the one that sets
> > up/tears down the CPU mappings on demand, so the aperture should be
> > claimed in the DRM driver.
> 
> Even if the DRM driver is managing the aperture, I still think the GART
> driver should claim it. The physical address of the aperture is a
> property of the GART, so only the GART's resources (and DT node) should
> contain a representation of where that aperture is. The DRM driver
> should call into the GART driver to find out where the aperture is, and
> hence GART is able to claim it without conflict.

That could be difficult to do. There isn't any API to allow this. I guess if
something like that is added it should probably go into the IOMMU framework.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
@ 2012-05-21 17:31                   ` Thierry Reding
  0 siblings, 0 replies; 26+ messages in thread
From: Thierry Reding @ 2012-05-21 17:31 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Lucas Stach, Hiroshi DOYU, linux-tegra, Joerg Roedel,
	Bharat Nihalani, Vandana Salve, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1914 bytes --]

* Stephen Warren wrote:
> On 05/21/2012 11:05 AM, Lucas Stach wrote:
> > Am Montag, den 21.05.2012, 10:41 -0600 schrieb Stephen Warren:
> >> On 05/21/2012 08:11 AM, Thierry Reding wrote:
> >>> * Hiroshi DOYU wrote:
> >>>> GART Register/Aperture range should be reserved.
> >> ...
> >>>> diff --git a/drivers/iommu/tegra-gart.c
> >>>> b/drivers/iommu/tegra-gart.c
> >> ...
> >>>> +	if (!devm_request_mem_region(dev, res_remap->start, +
> >>>> resource_size(res_remap), dev_name(dev))) { +		dev_err(dev,
> >>>> "failed to reserve GART aperture\n"); +		return -EBUSY; +	} +
> >>>
> >>> I'm not so sure that this is a good idea. If the GART driver
> >>> requests the GART aperture, then users of the GART aperture (e.g.
> >>> the DRM driver) will no longer be able to use it.
> >>
> >> Presumably the DRM driver would be obtaining access to parts of the
> >> GART aperture through the GART driver, rather than just grabbing the
> >> IO region and using it for itself?
> > 
> > With a TTM-like memory manager the DRM driver will take over the address
> > space management of the GART aperture. The GART driver is only used to
> > set up the mappings in the IOMMU. The DRM driver is the one that sets
> > up/tears down the CPU mappings on demand, so the aperture should be
> > claimed in the DRM driver.
> 
> Even if the DRM driver is managing the aperture, I still think the GART
> driver should claim it. The physical address of the aperture is a
> property of the GART, so only the GART's resources (and DT node) should
> contain a representation of where that aperture is. The DRM driver
> should call into the GART driver to find out where the aperture is, and
> hence GART is able to claim it without conflict.

That could be difficult to do. There isn't any API to allow this. I guess if
something like that is added it should probably go into the IOMMU framework.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
  2012-05-21 17:31                   ` Thierry Reding
  (?)
@ 2012-05-21 17:38                   ` Lucas Stach
  2012-06-18 10:37                       ` Hiroshi Doyu
  -1 siblings, 1 reply; 26+ messages in thread
From: Lucas Stach @ 2012-05-21 17:38 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Stephen Warren, Hiroshi DOYU, linux-tegra, Joerg Roedel,
	Bharat Nihalani, Vandana Salve, linux-kernel

Am Montag, den 21.05.2012, 19:31 +0200 schrieb Thierry Reding:
> * Stephen Warren wrote:
> > On 05/21/2012 11:05 AM, Lucas Stach wrote:
> > > Am Montag, den 21.05.2012, 10:41 -0600 schrieb Stephen Warren:
> > >> On 05/21/2012 08:11 AM, Thierry Reding wrote:
> > >>> * Hiroshi DOYU wrote:
> > >>>> GART Register/Aperture range should be reserved.
> > >> ...
> > >>>> diff --git a/drivers/iommu/tegra-gart.c
> > >>>> b/drivers/iommu/tegra-gart.c
> > >> ...
> > >>>> +	if (!devm_request_mem_region(dev, res_remap->start, +
> > >>>> resource_size(res_remap), dev_name(dev))) { +		dev_err(dev,
> > >>>> "failed to reserve GART aperture\n"); +		return -EBUSY; +	} +
> > >>>
> > >>> I'm not so sure that this is a good idea. If the GART driver
> > >>> requests the GART aperture, then users of the GART aperture (e.g.
> > >>> the DRM driver) will no longer be able to use it.
> > >>
> > >> Presumably the DRM driver would be obtaining access to parts of the
> > >> GART aperture through the GART driver, rather than just grabbing the
> > >> IO region and using it for itself?
> > > 
> > > With a TTM-like memory manager the DRM driver will take over the address
> > > space management of the GART aperture. The GART driver is only used to
> > > set up the mappings in the IOMMU. The DRM driver is the one that sets
> > > up/tears down the CPU mappings on demand, so the aperture should be
> > > claimed in the DRM driver.
> > 
> > Even if the DRM driver is managing the aperture, I still think the GART
> > driver should claim it. The physical address of the aperture is a
> > property of the GART, so only the GART's resources (and DT node) should
> > contain a representation of where that aperture is. The DRM driver
> > should call into the GART driver to find out where the aperture is, and
> > hence GART is able to claim it without conflict.
> 
> That could be difficult to do. There isn't any API to allow this. I guess if
> something like that is added it should probably go into the IOMMU framework.

Ah, yes. There already was a plan to add properties for this to the
IOMMU API. So I'm ok with the GART driver claiming the resources. I will
try to push the needed API changes forward in the next few days.

-- Lucas

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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
  2012-05-21 17:31                   ` Thierry Reding
@ 2012-05-21 17:38                       ` Thierry Reding
  -1 siblings, 0 replies; 26+ messages in thread
From: Thierry Reding @ 2012-05-21 17:38 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Lucas Stach, Hiroshi DOYU, linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	Joerg Roedel, Bharat Nihalani, Vandana Salve,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 2428 bytes --]

* Thierry Reding wrote:
> * Stephen Warren wrote:
> > On 05/21/2012 11:05 AM, Lucas Stach wrote:
> > > Am Montag, den 21.05.2012, 10:41 -0600 schrieb Stephen Warren:
> > >> On 05/21/2012 08:11 AM, Thierry Reding wrote:
> > >>> * Hiroshi DOYU wrote:
> > >>>> GART Register/Aperture range should be reserved.
> > >> ...
> > >>>> diff --git a/drivers/iommu/tegra-gart.c
> > >>>> b/drivers/iommu/tegra-gart.c
> > >> ...
> > >>>> +	if (!devm_request_mem_region(dev, res_remap->start, +
> > >>>> resource_size(res_remap), dev_name(dev))) { +		dev_err(dev,
> > >>>> "failed to reserve GART aperture\n"); +		return -EBUSY; +	} +
> > >>>
> > >>> I'm not so sure that this is a good idea. If the GART driver
> > >>> requests the GART aperture, then users of the GART aperture (e.g.
> > >>> the DRM driver) will no longer be able to use it.
> > >>
> > >> Presumably the DRM driver would be obtaining access to parts of the
> > >> GART aperture through the GART driver, rather than just grabbing the
> > >> IO region and using it for itself?
> > > 
> > > With a TTM-like memory manager the DRM driver will take over the address
> > > space management of the GART aperture. The GART driver is only used to
> > > set up the mappings in the IOMMU. The DRM driver is the one that sets
> > > up/tears down the CPU mappings on demand, so the aperture should be
> > > claimed in the DRM driver.
> > 
> > Even if the DRM driver is managing the aperture, I still think the GART
> > driver should claim it. The physical address of the aperture is a
> > property of the GART, so only the GART's resources (and DT node) should
> > contain a representation of where that aperture is. The DRM driver
> > should call into the GART driver to find out where the aperture is, and
> > hence GART is able to claim it without conflict.
> 
> That could be difficult to do. There isn't any API to allow this. I guess if
> something like that is added it should probably go into the IOMMU framework.

Thinking some more about this, even then care needs to be taken to allow only
one user access to the GART aperture. Having the DRM driver request the
region would automatically prevent any other driver from requesting the same
memory. This is no longer true if an extra API is used to request the GART
aperture from the IOMMU. Unless of course some of these restrictions are
reimplemented in the IOMMU API.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
@ 2012-05-21 17:38                       ` Thierry Reding
  0 siblings, 0 replies; 26+ messages in thread
From: Thierry Reding @ 2012-05-21 17:38 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Lucas Stach, Hiroshi DOYU, linux-tegra, Joerg Roedel,
	Bharat Nihalani, Vandana Salve, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2428 bytes --]

* Thierry Reding wrote:
> * Stephen Warren wrote:
> > On 05/21/2012 11:05 AM, Lucas Stach wrote:
> > > Am Montag, den 21.05.2012, 10:41 -0600 schrieb Stephen Warren:
> > >> On 05/21/2012 08:11 AM, Thierry Reding wrote:
> > >>> * Hiroshi DOYU wrote:
> > >>>> GART Register/Aperture range should be reserved.
> > >> ...
> > >>>> diff --git a/drivers/iommu/tegra-gart.c
> > >>>> b/drivers/iommu/tegra-gart.c
> > >> ...
> > >>>> +	if (!devm_request_mem_region(dev, res_remap->start, +
> > >>>> resource_size(res_remap), dev_name(dev))) { +		dev_err(dev,
> > >>>> "failed to reserve GART aperture\n"); +		return -EBUSY; +	} +
> > >>>
> > >>> I'm not so sure that this is a good idea. If the GART driver
> > >>> requests the GART aperture, then users of the GART aperture (e.g.
> > >>> the DRM driver) will no longer be able to use it.
> > >>
> > >> Presumably the DRM driver would be obtaining access to parts of the
> > >> GART aperture through the GART driver, rather than just grabbing the
> > >> IO region and using it for itself?
> > > 
> > > With a TTM-like memory manager the DRM driver will take over the address
> > > space management of the GART aperture. The GART driver is only used to
> > > set up the mappings in the IOMMU. The DRM driver is the one that sets
> > > up/tears down the CPU mappings on demand, so the aperture should be
> > > claimed in the DRM driver.
> > 
> > Even if the DRM driver is managing the aperture, I still think the GART
> > driver should claim it. The physical address of the aperture is a
> > property of the GART, so only the GART's resources (and DT node) should
> > contain a representation of where that aperture is. The DRM driver
> > should call into the GART driver to find out where the aperture is, and
> > hence GART is able to claim it without conflict.
> 
> That could be difficult to do. There isn't any API to allow this. I guess if
> something like that is added it should probably go into the IOMMU framework.

Thinking some more about this, even then care needs to be taken to allow only
one user access to the GART aperture. Having the DRM driver request the
region would automatically prevent any other driver from requesting the same
memory. This is no longer true if an extra API is used to request the GART
aperture from the IOMMU. Unless of course some of these restrictions are
reimplemented in the IOMMU API.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
  2012-05-21 17:38                   ` Lucas Stach
@ 2012-06-18 10:37                       ` Hiroshi Doyu
  0 siblings, 0 replies; 26+ messages in thread
From: Hiroshi Doyu @ 2012-06-18 10:37 UTC (permalink / raw)
  To: Lucas Stach, joerg.roedel-5C7GfCeVMHo
  Cc: Stephen Warren, Bharat Nihalani, Thierry Reding,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA, Vandana Salve

Hi Lucas,

On Mon, 21 May 2012 19:38:28 +0200
Lucas Stach <dev-8ppwABl0HbeELgA04lAiVw@public.gmane.org> wrote:

> Am Montag, den 21.05.2012, 19:31 +0200 schrieb Thierry Reding:
> > * Stephen Warren wrote:
> > > On 05/21/2012 11:05 AM, Lucas Stach wrote:
> > > > Am Montag, den 21.05.2012, 10:41 -0600 schrieb Stephen Warren:
> > > >> On 05/21/2012 08:11 AM, Thierry Reding wrote:
> > > >>> * Hiroshi DOYU wrote:
> > > >>>> GART Register/Aperture range should be reserved.
> > > >> ...
> > > >>>> diff --git a/drivers/iommu/tegra-gart.c
> > > >>>> b/drivers/iommu/tegra-gart.c
> > > >> ...
> > > >>>> +	if (!devm_request_mem_region(dev, res_remap->start, +
> > > >>>> resource_size(res_remap), dev_name(dev))) { +		dev_err(dev,
> > > >>>> "failed to reserve GART aperture\n"); +		return -EBUSY; +	} +
> > > >>>
> > > >>> I'm not so sure that this is a good idea. If the GART driver
> > > >>> requests the GART aperture, then users of the GART aperture (e.g.
> > > >>> the DRM driver) will no longer be able to use it.
> > > >>
> > > >> Presumably the DRM driver would be obtaining access to parts of the
> > > >> GART aperture through the GART driver, rather than just grabbing the
> > > >> IO region and using it for itself?
> > > > 
> > > > With a TTM-like memory manager the DRM driver will take over the address
> > > > space management of the GART aperture. The GART driver is only used to
> > > > set up the mappings in the IOMMU. The DRM driver is the one that sets
> > > > up/tears down the CPU mappings on demand, so the aperture should be
> > > > claimed in the DRM driver.
> > > 
> > > Even if the DRM driver is managing the aperture, I still think the GART
> > > driver should claim it. The physical address of the aperture is a
> > > property of the GART, so only the GART's resources (and DT node) should
> > > contain a representation of where that aperture is. The DRM driver
> > > should call into the GART driver to find out where the aperture is, and
> > > hence GART is able to claim it without conflict.
> > 
> > That could be difficult to do. There isn't any API to allow this. I guess if
> > something like that is added it should probably go into the IOMMU framework.
> 
> Ah, yes. There already was a plan to add properties for this to the
> IOMMU API. So I'm ok with the GART driver claiming the resources.

I think that DRM driver should be independent of GART, one specific
implementation of IOMMU H/W, but it should be a normal client of DMA
BUF(or DMABUF API?), which asks info via IOMMU API if necessary.

For new IOMMU API, I guess that the following would be the one we need here.

[PATCH 0/5] IOMMU: Make IOMMU-API ready for GART-like hardware
  https://lkml.org/lkml/2012/1/19/170

> I will try to push the needed API changes forward in the next few
> days.

Have you had any chance to post the above succeeding patch? I couldn't
find.

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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
@ 2012-06-18 10:37                       ` Hiroshi Doyu
  0 siblings, 0 replies; 26+ messages in thread
From: Hiroshi Doyu @ 2012-06-18 10:37 UTC (permalink / raw)
  To: Lucas Stach, joerg.roedel
  Cc: Thierry Reding, Stephen Warren, linux-tegra, Joerg Roedel,
	Bharat Nihalani, Vandana Salve, linux-kernel, iommu

Hi Lucas,

On Mon, 21 May 2012 19:38:28 +0200
Lucas Stach <dev@lynxeye.de> wrote:

> Am Montag, den 21.05.2012, 19:31 +0200 schrieb Thierry Reding:
> > * Stephen Warren wrote:
> > > On 05/21/2012 11:05 AM, Lucas Stach wrote:
> > > > Am Montag, den 21.05.2012, 10:41 -0600 schrieb Stephen Warren:
> > > >> On 05/21/2012 08:11 AM, Thierry Reding wrote:
> > > >>> * Hiroshi DOYU wrote:
> > > >>>> GART Register/Aperture range should be reserved.
> > > >> ...
> > > >>>> diff --git a/drivers/iommu/tegra-gart.c
> > > >>>> b/drivers/iommu/tegra-gart.c
> > > >> ...
> > > >>>> +	if (!devm_request_mem_region(dev, res_remap->start, +
> > > >>>> resource_size(res_remap), dev_name(dev))) { +		dev_err(dev,
> > > >>>> "failed to reserve GART aperture\n"); +		return -EBUSY; +	} +
> > > >>>
> > > >>> I'm not so sure that this is a good idea. If the GART driver
> > > >>> requests the GART aperture, then users of the GART aperture (e.g.
> > > >>> the DRM driver) will no longer be able to use it.
> > > >>
> > > >> Presumably the DRM driver would be obtaining access to parts of the
> > > >> GART aperture through the GART driver, rather than just grabbing the
> > > >> IO region and using it for itself?
> > > > 
> > > > With a TTM-like memory manager the DRM driver will take over the address
> > > > space management of the GART aperture. The GART driver is only used to
> > > > set up the mappings in the IOMMU. The DRM driver is the one that sets
> > > > up/tears down the CPU mappings on demand, so the aperture should be
> > > > claimed in the DRM driver.
> > > 
> > > Even if the DRM driver is managing the aperture, I still think the GART
> > > driver should claim it. The physical address of the aperture is a
> > > property of the GART, so only the GART's resources (and DT node) should
> > > contain a representation of where that aperture is. The DRM driver
> > > should call into the GART driver to find out where the aperture is, and
> > > hence GART is able to claim it without conflict.
> > 
> > That could be difficult to do. There isn't any API to allow this. I guess if
> > something like that is added it should probably go into the IOMMU framework.
> 
> Ah, yes. There already was a plan to add properties for this to the
> IOMMU API. So I'm ok with the GART driver claiming the resources.

I think that DRM driver should be independent of GART, one specific
implementation of IOMMU H/W, but it should be a normal client of DMA
BUF(or DMABUF API?), which asks info via IOMMU API if necessary.

For new IOMMU API, I guess that the following would be the one we need here.

[PATCH 0/5] IOMMU: Make IOMMU-API ready for GART-like hardware
  https://lkml.org/lkml/2012/1/19/170

> I will try to push the needed API changes forward in the next few
> days.

Have you had any chance to post the above succeeding patch? I couldn't
find.

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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
  2012-06-18 10:37                       ` Hiroshi Doyu
@ 2012-06-18 21:14                           ` Lucas Stach
  -1 siblings, 0 replies; 26+ messages in thread
From: Lucas Stach @ 2012-06-18 21:14 UTC (permalink / raw)
  To: Hiroshi Doyu
  Cc: joerg.roedel-5C7GfCeVMHo, Thierry Reding, Stephen Warren,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA, Bharat Nihalani,
	Vandana Salve, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

Hello Hiroshi,

Am Montag, den 18.06.2012, 13:37 +0300 schrieb Hiroshi Doyu:
> Hi Lucas,
> 
> On Mon, 21 May 2012 19:38:28 +0200
> Lucas Stach <dev-8ppwABl0HbeELgA04lAiVw@public.gmane.org> wrote:
> 
> > Am Montag, den 21.05.2012, 19:31 +0200 schrieb Thierry Reding:
> > > * Stephen Warren wrote:
> > > > On 05/21/2012 11:05 AM, Lucas Stach wrote:
> > > > > Am Montag, den 21.05.2012, 10:41 -0600 schrieb Stephen Warren:
> > > > >> On 05/21/2012 08:11 AM, Thierry Reding wrote:
> > > > >>> * Hiroshi DOYU wrote:
> > > > >>>> GART Register/Aperture range should be reserved.
> > > > >> ...
> > > > >>>> diff --git a/drivers/iommu/tegra-gart.c
> > > > >>>> b/drivers/iommu/tegra-gart.c
> > > > >> ...
> > > > >>>> +	if (!devm_request_mem_region(dev, res_remap->start, +
> > > > >>>> resource_size(res_remap), dev_name(dev))) { +		dev_err(dev,
> > > > >>>> "failed to reserve GART aperture\n"); +		return -EBUSY; +	} +
> > > > >>>
> > > > >>> I'm not so sure that this is a good idea. If the GART driver
> > > > >>> requests the GART aperture, then users of the GART aperture (e.g.
> > > > >>> the DRM driver) will no longer be able to use it.
> > > > >>
> > > > >> Presumably the DRM driver would be obtaining access to parts of the
> > > > >> GART aperture through the GART driver, rather than just grabbing the
> > > > >> IO region and using it for itself?
> > > > > 
> > > > > With a TTM-like memory manager the DRM driver will take over the address
> > > > > space management of the GART aperture. The GART driver is only used to
> > > > > set up the mappings in the IOMMU. The DRM driver is the one that sets
> > > > > up/tears down the CPU mappings on demand, so the aperture should be
> > > > > claimed in the DRM driver.
> > > > 
> > > > Even if the DRM driver is managing the aperture, I still think the GART
> > > > driver should claim it. The physical address of the aperture is a
> > > > property of the GART, so only the GART's resources (and DT node) should
> > > > contain a representation of where that aperture is. The DRM driver
> > > > should call into the GART driver to find out where the aperture is, and
> > > > hence GART is able to claim it without conflict.
> > > 
> > > That could be difficult to do. There isn't any API to allow this. I guess if
> > > something like that is added it should probably go into the IOMMU framework.
> > 
> > Ah, yes. There already was a plan to add properties for this to the
> > IOMMU API. So I'm ok with the GART driver claiming the resources.
> 
> I think that DRM driver should be independent of GART, one specific
> implementation of IOMMU H/W, but it should be a normal client of DMA
> BUF(or DMABUF API?), which asks info via IOMMU API if necessary.

You are right that the DRM driver should not care about the specific
IOMMU implementation. It shouldn't matter to the graphics driver if it
sits on top of a Tegra 2 GART with a fixed aperture of 32MB or on top of
a Tegra 3 SMMU with an virtual address space of several Gigabytes. 

However graphics cores are one of the most complicated devices when it
comes to DMA resource management. Because of it's natural operation mode
as a completely parallel coprocessor to the CPU and the big amounts of
data that has to be mapped at every given time, the GPU doesn't fit
terribly well within the normal Linux Kernel DMA API.

We already have a solution for GPU address space management in the
kernel, called TTM, which in turn integrates with other things like
DMABUF. But to guarantee the best performance TTM will have to manage
the whole virtual address space of the GPU. So I think the IOMMU API is
the perfect abstraction level for interaction between the DRM and the
GART/SMMU driver. This way the DRM is able to manage the DMA resources
on it's own while staying completely agnostic about the underlying IOMMU
hardware.

> 
> For new IOMMU API, I guess that the following would be the one we need here.
> 
> [PATCH 0/5] IOMMU: Make IOMMU-API ready for GART-like hardware
>   https://lkml.org/lkml/2012/1/19/170
> 
Yes, this is exactly the patchset I had in mind.

> > I will try to push the needed API changes forward in the next few
> > days.
> 
> Have you had any chance to post the above succeeding patch? I couldn't
> find.
> 
No, sorry. I was occupied with other things for the last weeks and
couldn't find the time to revisit this topic.

-- Lucas

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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
@ 2012-06-18 21:14                           ` Lucas Stach
  0 siblings, 0 replies; 26+ messages in thread
From: Lucas Stach @ 2012-06-18 21:14 UTC (permalink / raw)
  To: Hiroshi Doyu
  Cc: joerg.roedel, Thierry Reding, Stephen Warren, linux-tegra,
	Bharat Nihalani, Vandana Salve, linux-kernel, iommu

Hello Hiroshi,

Am Montag, den 18.06.2012, 13:37 +0300 schrieb Hiroshi Doyu:
> Hi Lucas,
> 
> On Mon, 21 May 2012 19:38:28 +0200
> Lucas Stach <dev@lynxeye.de> wrote:
> 
> > Am Montag, den 21.05.2012, 19:31 +0200 schrieb Thierry Reding:
> > > * Stephen Warren wrote:
> > > > On 05/21/2012 11:05 AM, Lucas Stach wrote:
> > > > > Am Montag, den 21.05.2012, 10:41 -0600 schrieb Stephen Warren:
> > > > >> On 05/21/2012 08:11 AM, Thierry Reding wrote:
> > > > >>> * Hiroshi DOYU wrote:
> > > > >>>> GART Register/Aperture range should be reserved.
> > > > >> ...
> > > > >>>> diff --git a/drivers/iommu/tegra-gart.c
> > > > >>>> b/drivers/iommu/tegra-gart.c
> > > > >> ...
> > > > >>>> +	if (!devm_request_mem_region(dev, res_remap->start, +
> > > > >>>> resource_size(res_remap), dev_name(dev))) { +		dev_err(dev,
> > > > >>>> "failed to reserve GART aperture\n"); +		return -EBUSY; +	} +
> > > > >>>
> > > > >>> I'm not so sure that this is a good idea. If the GART driver
> > > > >>> requests the GART aperture, then users of the GART aperture (e.g.
> > > > >>> the DRM driver) will no longer be able to use it.
> > > > >>
> > > > >> Presumably the DRM driver would be obtaining access to parts of the
> > > > >> GART aperture through the GART driver, rather than just grabbing the
> > > > >> IO region and using it for itself?
> > > > > 
> > > > > With a TTM-like memory manager the DRM driver will take over the address
> > > > > space management of the GART aperture. The GART driver is only used to
> > > > > set up the mappings in the IOMMU. The DRM driver is the one that sets
> > > > > up/tears down the CPU mappings on demand, so the aperture should be
> > > > > claimed in the DRM driver.
> > > > 
> > > > Even if the DRM driver is managing the aperture, I still think the GART
> > > > driver should claim it. The physical address of the aperture is a
> > > > property of the GART, so only the GART's resources (and DT node) should
> > > > contain a representation of where that aperture is. The DRM driver
> > > > should call into the GART driver to find out where the aperture is, and
> > > > hence GART is able to claim it without conflict.
> > > 
> > > That could be difficult to do. There isn't any API to allow this. I guess if
> > > something like that is added it should probably go into the IOMMU framework.
> > 
> > Ah, yes. There already was a plan to add properties for this to the
> > IOMMU API. So I'm ok with the GART driver claiming the resources.
> 
> I think that DRM driver should be independent of GART, one specific
> implementation of IOMMU H/W, but it should be a normal client of DMA
> BUF(or DMABUF API?), which asks info via IOMMU API if necessary.

You are right that the DRM driver should not care about the specific
IOMMU implementation. It shouldn't matter to the graphics driver if it
sits on top of a Tegra 2 GART with a fixed aperture of 32MB or on top of
a Tegra 3 SMMU with an virtual address space of several Gigabytes. 

However graphics cores are one of the most complicated devices when it
comes to DMA resource management. Because of it's natural operation mode
as a completely parallel coprocessor to the CPU and the big amounts of
data that has to be mapped at every given time, the GPU doesn't fit
terribly well within the normal Linux Kernel DMA API.

We already have a solution for GPU address space management in the
kernel, called TTM, which in turn integrates with other things like
DMABUF. But to guarantee the best performance TTM will have to manage
the whole virtual address space of the GPU. So I think the IOMMU API is
the perfect abstraction level for interaction between the DRM and the
GART/SMMU driver. This way the DRM is able to manage the DMA resources
on it's own while staying completely agnostic about the underlying IOMMU
hardware.

> 
> For new IOMMU API, I guess that the following would be the one we need here.
> 
> [PATCH 0/5] IOMMU: Make IOMMU-API ready for GART-like hardware
>   https://lkml.org/lkml/2012/1/19/170
> 
Yes, this is exactly the patchset I had in mind.

> > I will try to push the needed API changes forward in the next few
> > days.
> 
> Have you had any chance to post the above succeeding patch? I couldn't
> find.
> 
No, sorry. I was occupied with other things for the last weeks and
couldn't find the time to revisit this topic.

-- Lucas



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

* [PATCH 1/2] iommu/tegra: gart: Remove unnecessary cleanup with devm_*()
  2012-06-18 21:14                           ` Lucas Stach
  (?)
@ 2012-06-20  7:04                           ` Hiroshi DOYU
       [not found]                             ` <1340175873-12531-1-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  -1 siblings, 1 reply; 26+ messages in thread
From: Hiroshi DOYU @ 2012-06-20  7:04 UTC (permalink / raw)
  To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
  Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA, Hiroshi DOYU, Lucas Stach

From: Hiroshi DOYU <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

Remove unnecessary cleanup procedures with devm_*().

Signed-off-by: Hiroshi DOYU <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Reviewed-by: Thierry Reding <thierry.reding-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org>
Cc: Lucas Stach <dev-8ppwABl0HbeELgA04lAiVw@public.gmane.org>
---
 drivers/iommu/tegra-gart.c |   22 +++-------------------
 1 files changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
index 0c0a377..33a23b6 100644
--- a/drivers/iommu/tegra-gart.c
+++ b/drivers/iommu/tegra-gart.c
@@ -345,7 +345,6 @@ static int tegra_gart_probe(struct platform_device *pdev)
 	struct gart_device *gart;
 	struct resource *res, *res_remap;
 	void __iomem *gart_regs;
-	int err;
 	struct device *dev = &pdev->dev;
 
 	if (gart_handle)
@@ -370,8 +369,7 @@ static int tegra_gart_probe(struct platform_device *pdev)
 	gart_regs = devm_ioremap(dev, res->start, resource_size(res));
 	if (!gart_regs) {
 		dev_err(dev, "failed to remap GART registers\n");
-		err = -ENXIO;
-		goto fail;
+		return -ENXIO;
 	}
 
 	gart->dev = &pdev->dev;
@@ -385,8 +383,7 @@ static int tegra_gart_probe(struct platform_device *pdev)
 	gart->savedata = vmalloc(sizeof(u32) * gart->page_count);
 	if (!gart->savedata) {
 		dev_err(dev, "failed to allocate context save area\n");
-		err = -ENOMEM;
-		goto fail;
+		return -ENOMEM;
 	}
 
 	platform_set_drvdata(pdev, gart);
@@ -394,27 +391,14 @@ static int tegra_gart_probe(struct platform_device *pdev)
 
 	gart_handle = gart;
 	return 0;
-
-fail:
-	if (gart_regs)
-		devm_iounmap(dev, gart_regs);
-	if (gart && gart->savedata)
-		vfree(gart->savedata);
-	devm_kfree(dev, gart);
-	return err;
 }
 
 static int tegra_gart_remove(struct platform_device *pdev)
 {
 	struct gart_device *gart = platform_get_drvdata(pdev);
-	struct device *dev = gart->dev;
 
 	writel(0, gart->regs + GART_CONFIG);
-	if (gart->savedata)
-		vfree(gart->savedata);
-	if (gart->regs)
-		devm_iounmap(dev, gart->regs);
-	devm_kfree(dev, gart);
+	vfree(gart->savedata);
 	gart_handle = NULL;
 	return 0;
 }
-- 
1.7.5.4

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

* [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
       [not found]                             ` <1340175873-12531-1-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2012-06-20  7:04                               ` Hiroshi DOYU
       [not found]                                 ` <1340175873-12531-2-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  2012-06-20 16:00                               ` [PATCH 1/2] iommu/tegra: gart: Remove unnecessary cleanup with devm_*() Stephen Warren
  1 sibling, 1 reply; 26+ messages in thread
From: Hiroshi DOYU @ 2012-06-20  7:04 UTC (permalink / raw)
  To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
  Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA, Hiroshi DOYU, Thierry Reding,
	Lucas Stach

From: Hiroshi DOYU <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

GART Register/Aperture range should be reserved.

Signed-off-by: Hiroshi DOYU <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: Thierry Reding <thierry.reding-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org>
Cc: Lucas Stach <dev-8ppwABl0HbeELgA04lAiVw@public.gmane.org>
---
 drivers/iommu/tegra-gart.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
index 33a23b6..a431006 100644
--- a/drivers/iommu/tegra-gart.c
+++ b/drivers/iommu/tegra-gart.c
@@ -366,12 +366,18 @@ static int tegra_gart_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	gart_regs = devm_ioremap(dev, res->start, resource_size(res));
+	gart_regs = devm_request_and_ioremap(dev, res);
 	if (!gart_regs) {
 		dev_err(dev, "failed to remap GART registers\n");
 		return -ENXIO;
 	}
 
+	if (!devm_request_mem_region(dev, res_remap->start,
+				     resource_size(res_remap), dev_name(dev))) {
+		dev_err(dev, "failed to reserve GART aperture\n");
+		return -EBUSY;
+	}
+
 	gart->dev = &pdev->dev;
 	spin_lock_init(&gart->pte_lock);
 	spin_lock_init(&gart->client_lock);
-- 
1.7.5.4

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

* Re: [PATCH 1/2] iommu/tegra: gart: Remove unnecessary cleanup with devm_*()
       [not found]                             ` <1340175873-12531-1-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  2012-06-20  7:04                               ` [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource Hiroshi DOYU
@ 2012-06-20 16:00                               ` Stephen Warren
  1 sibling, 0 replies; 26+ messages in thread
From: Stephen Warren @ 2012-06-20 16:00 UTC (permalink / raw)
  To: Hiroshi DOYU
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA, Lucas Stach

On 06/20/2012 01:04 AM, Hiroshi DOYU wrote:
> From: Hiroshi DOYU <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> 
> Remove unnecessary cleanup procedures with devm_*().
> 
> Signed-off-by: Hiroshi DOYU <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> Reviewed-by: Thierry Reding <thierry.reding-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org>
> Cc: Lucas Stach <dev-8ppwABl0HbeELgA04lAiVw@public.gmane.org>

Acked-by: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>

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

* Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource
       [not found]                                 ` <1340175873-12531-2-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2012-06-20 16:01                                   ` Stephen Warren
  0 siblings, 0 replies; 26+ messages in thread
From: Stephen Warren @ 2012-06-20 16:01 UTC (permalink / raw)
  To: Hiroshi DOYU
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA, Thierry Reding, Lucas Stach

On 06/20/2012 01:04 AM, Hiroshi DOYU wrote:
> From: Hiroshi DOYU <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> 
> GART Register/Aperture range should be reserved.
> 
> Signed-off-by: Hiroshi DOYU <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> Cc: Thierry Reding <thierry.reding-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org>
> Cc: Lucas Stach <dev-8ppwABl0HbeELgA04lAiVw@public.gmane.org>

Acked-by: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>

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

end of thread, other threads:[~2012-06-20 16:01 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-14 18:12 [PATCH 1/2] iommu/tegra: gart: Remove unnecessary cleanup with devm_*() Hiroshi DOYU
2012-05-14 18:12 ` Hiroshi DOYU
2012-05-14 18:12 ` [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource Hiroshi DOYU
2012-05-14 18:12   ` Hiroshi DOYU
     [not found]   ` <1337019127-6863-2-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-05-21 14:11     ` Thierry Reding
2012-05-21 14:11       ` Thierry Reding
2012-05-21 16:41       ` Stephen Warren
     [not found]         ` <4FBA702A.1010203-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-05-21 17:05           ` Lucas Stach
2012-05-21 17:05             ` Lucas Stach
2012-05-21 17:14             ` Stephen Warren
2012-05-21 17:14               ` Stephen Warren
     [not found]               ` <4FBA77E2.4000409-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-05-21 17:31                 ` Thierry Reding
2012-05-21 17:31                   ` Thierry Reding
2012-05-21 17:38                   ` Lucas Stach
2012-06-18 10:37                     ` Hiroshi Doyu
2012-06-18 10:37                       ` Hiroshi Doyu
     [not found]                       ` <20120618133736.8d23c4e70b34b1de8cb71f6f-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-06-18 21:14                         ` Lucas Stach
2012-06-18 21:14                           ` Lucas Stach
2012-06-20  7:04                           ` [PATCH 1/2] iommu/tegra: gart: Remove unnecessary cleanup with devm_*() Hiroshi DOYU
     [not found]                             ` <1340175873-12531-1-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-06-20  7:04                               ` [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource Hiroshi DOYU
     [not found]                                 ` <1340175873-12531-2-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-06-20 16:01                                   ` Stephen Warren
2012-06-20 16:00                               ` [PATCH 1/2] iommu/tegra: gart: Remove unnecessary cleanup with devm_*() Stephen Warren
     [not found]                   ` <20120521173124.GB11824-RM9K5IK7kjIQXX3q8xo1gnVAuStQJXxyR5q1nwbD4aMs9pC9oP6+/A@public.gmane.org>
2012-05-21 17:38                     ` [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource Thierry Reding
2012-05-21 17:38                       ` Thierry Reding
     [not found] ` <1337019127-6863-1-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-05-21 14:16   ` [PATCH 1/2] iommu/tegra: gart: Remove unnecessary cleanup with devm_*() Thierry Reding
2012-05-21 14:16     ` Thierry Reding

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.