Re: Tegra-DRM: Tegra30: DMA mapping API

markz
2012-07-12T06:49:05Z

On Thu, 2012-07-12 at 11:33 +0800, Hiroshi Doyu wrote:
> On Thu, 12 Jul 2012 05:04:33 +0200
> markz <markz-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> wrote:
>
> > On Wed, 2012-07-11 at 19:42 +0800, Hiroshi Doyu wrote:
> > > Hi Joerg,
> > >
> > > On Wed, 11 Jul 2012 12:58:27 +0200
> > > Joerg Roedel <joerg.roedel-5C7GfCeVMHo@public.gmane.org> wrote:
> > >
> > > > Hi,
> > > >
> > > > On Tue, Jul 10, 2012 at 01:26:39PM +0300, Hiroshi Doyu wrote:
> > > > > > http://lists.linuxfoundation.org/pipermail/iommu/2012-January/003531.html
> > > > >
> > > > > Do you have any plan to merge the above "IOMMU: Make IOMMU-API ready
> > > > > for GART-like hardware"?
> > > > >
> > > > > Tegra DRM seems to need that feature eventually.
> > > >
> > > > I just rebased and updated the patch-set. A new version is sent out. If
> > > > no major objections come up I queue it for the next merge window.
> > >
> > > Thank you for your prompt action. This would help us a lot.
> >
> > That's great. So Hiroshi-san, about your patch:
> > http://lists.linuxfoundation.org/pipermail/iommu/2012-January/003531.html
> > , what is your plan to merge this?
>
> That's also under review along with the framework as below:
>
> [PATCH 6/7] iommu/tegra: Implement DOMAIN_ATTR_GEOMETRY attribute
> http://lists.linuxfoundation.org/pipermail/iommu/2012-July/004432.html
>
> > After Joerg's patch and yours are merged into linux-next, I can submit
> > my drm patch into review process.
>
> You can also send them now for early review with some note mentioning
> that your patches depend on the above "[PATCH 6/7] iommu/tegra:
> Implement DOMAIN_ATTR_GEOMETRY attribute" in the commit log.

Thank you. I merged this patch set locally but seems it has problems:
The requirement of the drm driver is: It needs a parameter named "base"
while calling function "arm_iommu_create_mapping" to reserve a block of
iova from GART/SMMU.
This patch set defines function "iommu_domain_get_attr" &
"iommu_domain_set_attr", but drm driver can't use them:
1. These 2 functions need a iommu_domain param which means the
iommu_domain should be created before calling them. But the iommu_domain
is created in function "arm_iommu_create_mapping".
2. It's not a good practice to make drm driver calls iommu apis
directly.

Actually, I'm curious that why function "arm_iommu_create_mapping" needs
this "base" param. AIUI, drm driver just needs to tell IOMMU the size of
the iova address to reserve, then the base address can be checked out in
a lot of ways. For example:
1. Via "dma_map_sg" interface -- dma_map_sg defines we can check out the
mapped iova address from "dma_address" member in scatterlist structure.
2. Use this iommu get/set attr interface. Of course, we need some dma
mapping api wrappers on them.

Mark