Linux IOMMU Development
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
To: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>,
	x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: [RFC PATCH] x86: Allow IOMMU drivers to Hook arch_setup_dma_ops()
Date: Mon, 31 Oct 2016 08:34:51 -0600	[thread overview]
Message-ID: <1477924491.14501.16.camel@infradead.org> (raw)
In-Reply-To: <a95e5fb2-3f5d-5334-c62d-e4b99a52adcb-5wv7dgnIgG8@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 2581 bytes --]

On Mon, 2016-10-31 at 11:45 +0000, Robin Murphy wrote:
> Hi David,
> 
> On 30/10/16 19:14, David Woodhouse wrote:
> > 
> > The Intel IOMMU code registers a notifier and plays nasty tricks to fill
> > device pointers in with its DMAR scope tables when devices are detected,
> > then later compares the device pointers in those tables when it needs to
> > find the IOMMU unit for a given device.
> > 
> > If we let it use arch_setup_dma_ops() to match the device to an IOMMU
> > unit at device_register() time, this gets a whole lot saner.
>
> I like the sound of this, but do beware that there are plans afoot to
> move the arch_setup_dma_ops() call later, to driver probe time[1], 

That's OK. I only need the arch_setup_dma_ops() call to happen *after*
the initial parsing of the DMAR tables (which is really early), and
*before* anyone actually tries to set up DMA for a given device.

There's a special case for RMRRs where we have to set up the 1:1
mapping before we enable the IOMMU, but that needs work anyway — it
currently doesn't cope with non-existent devices (the HP horridness
where a device is doing DMA and we don't even know it *exists*).

So I want to fix the RMRR thing to be entirely decoupled from the
actual *devices* anyway.

> FWIW, arm64 is probably the nicer example. The arch side of the DMA ops
> is purely cache maintenance, and the rest is just funnelled through the
> generic dma-iommu.c glue layer.

Right, that's exactly what we're looking for.

So dma_ops can go back to being a platform-wide thing; it's only the
IOMMU ops which are different per device.

> > And IOMMU ops should be per-device of course, not per-bus. But this is
> > a start...
> As it happens, that was one of the additional motivations for
> introducing the new iommu_fwspec - see [3] for my take on the matter.

Right... in my case I don't actually need iommu_ops to change. We have
multiple IOMMUs of the same type, and we don't have a *separate* ops
structure for each of them.

What we *do* need to change is the iommu-private data pointer, which
indicates specifically which DMAR unit is being used.

That's currently kept in dev->archdata but with assumptions that the
device->IOMMU mapping is only done when the domain is first set up, so
it needs to be redone either with a new field in dev->archdata or some
additional complexity.

Rather than a new field in archdata.... should we make this a generic
iommu_priv pointer living next to iommu_ops in the device structure?

Could you use that?

-- 
dwmw2


[-- Attachment #1.2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5760 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



  parent reply	other threads:[~2016-10-31 14:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-30 19:14 [RFC PATCH] x86: Allow IOMMU drivers to Hook arch_setup_dma_ops() David Woodhouse
     [not found] ` <1477854889.14501.6.camel-1zP8QHzw3cfLoDKTGw+V6w@public.gmane.org>
2016-10-31 11:45   ` Robin Murphy
     [not found]     ` <a95e5fb2-3f5d-5334-c62d-e4b99a52adcb-5wv7dgnIgG8@public.gmane.org>
2016-10-31 14:34       ` David Woodhouse [this message]
     [not found]         ` <1477924491.14501.16.camel-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2016-10-31 17:04           ` Robin Murphy
     [not found]             ` <d2b36234-df39-da1c-08cb-d85a953d703b-5wv7dgnIgG8@public.gmane.org>
2016-10-31 18:06               ` David Woodhouse
     [not found]                 ` <e7649392eaae9867fbd0b5d80efb6e07.squirrel-fWAbwA/6YHlc2C7mugBRk2EX/6BAtgUQ@public.gmane.org>
2016-10-31 19:10                   ` Robin Murphy

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=1477924491.14501.16.camel@infradead.org \
    --to=dwmw2-wegcikhe2lqwvfeawa7xhq@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=robin.murphy-5wv7dgnIgG8@public.gmane.org \
    --cc=x86-DgEjT+Ai2ygdnm+yROfE0A@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