Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[PATCH 2/2] iommu/tegra: gart: Reserve iomem resource

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


hdoyu at nvidia

May 14, 2012, 11:12 AM

Post #1 of 10 (194 views)
Permalink
[PATCH 2/2] iommu/tegra: gart: Reserve iomem resource

GART Register/Aperture range should be reserved.

Signed-off-by: Hiroshi DOYU <hdoyu [at] nvidia>
---
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


thierry.reding at avionic-design

May 21, 2012, 7:11 AM

Post #2 of 10 (179 views)
Permalink
Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource [In reply to]

* Hiroshi DOYU wrote:
> GART Register/Aperture range should be reserved.
>
> Signed-off-by: Hiroshi DOYU <hdoyu [at] nvidia>
> ---
> 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


swarren at wwwdotorg

May 21, 2012, 9:41 AM

Post #3 of 10 (184 views)
Permalink
Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource [In reply to]

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?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


dev at lynxeye

May 21, 2012, 10:05 AM

Post #4 of 10 (182 views)
Permalink
Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource [In reply to]

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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


swarren at wwwdotorg

May 21, 2012, 10:14 AM

Post #5 of 10 (181 views)
Permalink
Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource [In reply to]

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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


thierry.reding at avionic-design

May 21, 2012, 10:31 AM

Post #6 of 10 (179 views)
Permalink
Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource [In reply to]

* 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


dev at lynxeye

May 21, 2012, 10:38 AM

Post #7 of 10 (180 views)
Permalink
Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource [In reply to]

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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


thierry.reding at avionic-design

May 21, 2012, 10:38 AM

Post #8 of 10 (182 views)
Permalink
Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource [In reply to]

* 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


hdoyu at nvidia

Jun 18, 2012, 3:37 AM

Post #9 of 10 (158 views)
Permalink
Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource [In reply to]

Hi Lucas,

On Mon, 21 May 2012 19:38:28 +0200
Lucas Stach <dev [at] lynxeye> 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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


dev at lynxeye

Jun 18, 2012, 2:14 PM

Post #10 of 10 (159 views)
Permalink
Re: [PATCH 2/2] iommu/tegra: gart: Reserve iomem resource [In reply to]

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 [at] lynxeye> 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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.