dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Lucas Stach <l.stach-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Cc: Mikko Perttunen
	<mperttunen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH v2 1/7] drm/tegra: Add Tegra DRM allocation API
Date: Wed, 14 Dec 2016 15:39:12 +0100	[thread overview]
Message-ID: <20161214143912.GA30280@ulmo.ba.sec> (raw)
In-Reply-To: <1481724116.2313.39.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

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

On Wed, Dec 14, 2016 at 03:01:56PM +0100, Lucas Stach wrote:
> Am Mittwoch, den 14.12.2016, 14:48 +0100 schrieb Thierry Reding:
> > On Wed, Dec 14, 2016 at 12:35:31PM +0100, Lucas Stach wrote:
> > > Am Mittwoch, den 14.12.2016, 13:16 +0200 schrieb Mikko Perttunen:
> > > > Add a new IO virtual memory allocation API to allow clients to
> > > > allocate non-GEM memory in the Tegra DRM IOMMU domain. This is
> > > > required e.g. for loading client firmware when clients are attached
> > > > to the IOMMU domain.
> > > > 
> > > > The allocator allocates contiguous physical pages that are then
> > > > mapped contiguously to the IOMMU domain using the iova_domain
> > > > library provided by the kernel. Contiguous physical pages are
> > > > used so that the same allocator works also when IOMMU support
> > > > is disabled and therefore devices access physical memory directly.
> > > > 
> > > Why is this needed? If you use the DMA API for those buffers you should
> > > end up with CMA memory in the !IOMMU case and normal paged memory with
> > > IOMMU enabled. From my understanding this should match the requirements.
> > 
> > We can't currently use the DMA API for these allocations because it
> > doesn't allow (or at least didn't back when this was first implemented)
> > us to share a mapping between two devices.
> 
> Hm, maybe I'm overlooking something, but isn't this just a matter of
> allocating on one device, then constructing a SG list (dma_get_sgtable)
> from the buffer you got and use that to dma_map_sg() the buffer on the
> other device?

Yes, that would work. What I was referring to is sharing framebuffers
between multiple CRTCs. Back at the time when IOMMU support was first
added, I tried to use the DMA API. However, the problem with that was
that we would've had to effectively dma_map_sg() on every page-flip
since the buffer is imported into the DRM device, but there's no call
that would import it for each CRTC only once. So when the framebuffer
is added to a plane, you have to map it to the corresponding display
controller. And the dma_map_sg() was, if I recall correctly, on the
order of 5-10 ms, which is prohibitively expensive to do per frame.

It's also completely unnecessary because all CRTCs in a DRM device can
simply share the same IOMMU domain. I can't think of a reason why you
would want or need to use separate domains.

Back at the time this was something that the DMA API couldn't do, it
would simply assign a separate IOMMU domain per device. It's possible
that this has changed now given that many others must've run into the
same problem meanwhile.

> Maybe doing the firmware buffer allocation on host1x (with a 4GB upper
> bound) and then sharing the SG list to the devices?

That's pretty much what this API is doing. Only it's the other way
around: we don't share the SG list with other devices for mapping, we
simply reuse the same mapping across multiple devices, since they're
all in the same IOMMU domain.

> > The reason why we need these patches is that when IOMMU is enabled, then
> > the units' falcons will read memory through the IOMMU, so we must have
> > allocations for GEM buffers and the firmware go through the same
> > mechanism.
> 
> Sorry for maybe dumb questions.
> 
> Do you have any engines other than the GPU that can handle SG
> themselves?

No, I don't think so.

> Wouldn't you want the GEM objects to be backed by CMA in the !MMU
> case?

That's exactly what's happening already. If no IOMMU is available we
allocate buffer objects backing store with dma_alloc_wc().

> How are ordinary GEM objects different from the falcon firmware?

They're not. I think we could probably reuse more of the BO allocation
functions for the firmware as well. I think Mikko already agreed to look
into that. We might have to add some special cases, or split up the
helpers a little differently to avoid creating GEM objects from the
firmware buffers. We wouldn't want userspace to start mmap()'ing those.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2016-12-14 14:39 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-14 11:16 [PATCH v2 0/7] Host1x IOMMU support + VIC support Mikko Perttunen
     [not found] ` <20161214111617.24548-1-mperttunen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-12-14 11:16   ` [PATCH v2 1/7] drm/tegra: Add Tegra DRM allocation API Mikko Perttunen
2016-12-14 11:35     ` Lucas Stach
     [not found]       ` <1481715331.2313.28.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-12-14 12:36         ` Mikko Perttunen
2016-12-14 12:56           ` Lucas Stach
     [not found]             ` <1481720206.2313.32.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-12-14 13:17               ` Mikko Perttunen
2016-12-14 13:48         ` Thierry Reding
     [not found]           ` <20161214134833.GA29981-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2016-12-14 14:01             ` Lucas Stach
     [not found]               ` <1481724116.2313.39.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-12-14 14:39                 ` Thierry Reding [this message]
     [not found]                   ` <20161214143912.GA30280-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2017-01-27 22:45                     ` Mikko Perttunen
2016-12-14 11:16   ` [PATCH v2 2/7] drm/tegra: Add falcon helper library Mikko Perttunen
2016-12-14 11:16   ` [PATCH v2 3/7] drm/tegra: Add VIC support Mikko Perttunen
2016-12-14 11:16   ` [PATCH v2 4/7] gpu: host1x: Add IOMMU support Mikko Perttunen
2016-12-14 11:16   ` [PATCH v2 5/7] dt-bindings: Add bindings for the Tegra VIC Mikko Perttunen
2016-12-14 11:16   ` [PATCH v2 7/7] arm64: tegra: Enable IOMMU for Host1x on Tegra210 Mikko Perttunen
2016-12-14 12:30   ` [PATCH v2 0/7] Host1x IOMMU support + VIC support Daniel Vetter
     [not found]     ` <20161214123004.urnvlqarcnp5rp4a-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2016-12-14 12:41       ` Mikko Perttunen
2016-12-14 13:05         ` Daniel Vetter
     [not found]           ` <20161214130545.gfpkosyixr5lfkkf-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2016-12-14 13:32             ` Mikko Perttunen
2016-12-14 14:11               ` Daniel Vetter
     [not found]                 ` <20161214141142.jmrofknylonhprbk-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2016-12-14 14:29                   ` Mikko Perttunen
2016-12-14 14:48                   ` Daniel Vetter
     [not found]                     ` <CAKMK7uGw3XwbPU798YJ-9eLbwhMWs7z_F-ro238RfFN8LFURtw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-15  2:52                       ` Sean V Kelley
2017-01-17 16:22                   ` Mikko Perttunen
2017-01-23  7:42                     ` Daniel Vetter
2016-12-14 14:18       ` Thierry Reding
2016-12-14 18:26     ` Emil Velikov
2016-12-14 11:16 ` [PATCH v2 6/7] arm64: tegra: Enable VIC on T210 Mikko Perttunen

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=20161214143912.GA30280@ulmo.ba.sec \
    --to=thierry.reding-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=l.stach-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mperttunen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox