All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Robin Murphy <robin.murphy@arm.com>,
	Steven Price <steven.price@arm.com>,
	iommu@lists.linux.dev, linux-samsung-soc@vger.kernel.org,
	Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	lim Akhtar <alim.akhtar@samsung.com>,
	Lu Baolu <baolu.lu@linux.intel.com>
Subject: Re: [PATCH] iommu/exynos: add missing set_platform_dma_ops callback
Date: Wed, 12 Apr 2023 19:40:49 -0300	[thread overview]
Message-ID: <ZDczca117FRQn26A@nvidia.com> (raw)
In-Reply-To: <4fc0adda-2468-1db6-4ff3-1a48d8637615@samsung.com>

On Thu, Apr 13, 2023 at 12:03:55AM +0200, Marek Szyprowski wrote:
> On 07.04.2023 01:37, Jason Gunthorpe wrote:
> > On Mon, Feb 20, 2023 at 01:58:40PM +0000, Robin Murphy wrote:
> >> On 2023-02-17 12:35, Jason Gunthorpe wrote:
> >>> On Fri, Feb 17, 2023 at 12:08:42PM +0100, Marek Szyprowski wrote:
> >>>> I'm sorry for a delay in replying, but I was busy with other stuff.
> >>>>
> >>>> On 23.01.2023 22:00, Jason Gunthorpe wrote:
> >>>>> On Mon, Jan 23, 2023 at 10:31:01AM +0100, Marek Szyprowski wrote:
> >>>>>> Add set_platform_dma_ops() required for proper driver operation on ARM
> >>>>>> 32bit arch after recent changes in the IOMMU framework (detach ops
> >>>>>> removal).
> >>>>> Thanks for looking into this!
> >>>>>
> >>>>> Can you explain more about how this actually solves the problem in the
> >>>>> commit message? I don't get it.
> >>>> Exynos DRM driver calls arm_iommu_detach_device(), then
> >>>> arm_iommu_attach_device() with a difrent 'mapping', see
> >>>> drivers/gpu/drm/exynos/exynos_drm_dma.c Lack of set_platform_dma_ops
> >>>> leads to a warning in iommu_group_do_set_platform_dma(). The other case
> >>>> of calling arm_iommu_detach_device() is after unsuccessful probe of the
> >>>> platform device.
> >>> Why can't this just use the normal iommu path in all cases?
> >>>
> >>> It looks like it is trying to copy the DMA API domain from a parent
> >>> device to a sub device.
> >>>
> >>> Even when using arm_iommu an iommu_domain is still present, so the
> >>> copy code should work?
> >> The ARM DMA domain is a regular unmanaged domain owned by the ARM DMA code -
> >> in order to use any *other* domain, a user has to detach from that first
> >> (wrapped up in arm_iommu_detach_device() which also swizzles the DMA ops at
> >> the same time). Without set_platform_dma, that detach is now impossible
> >> (because no IOMMU API default domain exists either).
> > I was looking at this again, and for completeness, the reason it
> > doesn't have a default_domain is a bit subtle.
> >
> > The driver does support IOMMU_DOMAIN_DMA, and it will go through all
> > the iommu_group_alloc_default_domain() stuff with that..
> >
> > But... __iommu_domain_alloc() calls iommu_get_dma_cookie() which will
> > be wired to fail on ARM32, so the core code nixes the IOMMU_DOMAIN_DMA
> > after the driver successfully created it.
> >
> > I wonder if that is actually what we want? As it seems like it would
> > be OK for ARM32 to have, effectively, a permanently empty unmanaged
> > domain as the default_domain?
> >
> > If instead of failing due to iommu_get_dma_cookie() we set the type to
> > UNMANAGED and make that the default domain it could fix all of this,
> > even for all the other ARM32 drivers that haven't reported this yet?
> >
> > Alternatively since we taught these drivers to support IDENTITY, we
> > should be able to remove the set_platform_dma_ops and instead
> > implement for ARM32 def_domain_type fixed to return IDENTITY?
> 
> Maybe it would be easier to simply switch ARM32 to generic IOMMU-DMA layer?

It is the long term goal, yes

In the short term it would be nice if we could at least keep the hacks
out of the drivers

Jason

  reply	other threads:[~2023-04-12 22:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230123093116eucas1p19b8fe8afc4b631debbdc5321c53009e9@eucas1p1.samsung.com>
2023-01-23  9:31 ` [PATCH] iommu/exynos: add missing set_platform_dma_ops callback Marek Szyprowski
2023-01-23 21:00   ` Jason Gunthorpe
2023-02-17 11:08     ` Marek Szyprowski
2023-02-17 11:18       ` Baolu Lu
2023-02-17 12:35       ` Jason Gunthorpe
2023-02-20 13:58         ` Robin Murphy
2023-04-06 23:37           ` Jason Gunthorpe
2023-04-12 22:03             ` Marek Szyprowski
2023-04-12 22:40               ` Jason Gunthorpe [this message]
2023-02-03  9:41   ` Joerg Roedel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZDczca117FRQn26A@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=alim.akhtar@samsung.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=robin.murphy@arm.com \
    --cc=steven.price@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.