public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: joro@8bytes•org (Joerg Roedel)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v5 2/3] arm64: Add IOMMU dma_ops
Date: Fri, 7 Aug 2015 10:52:34 +0200	[thread overview]
Message-ID: <20150807085233.GV14980@8bytes.org> (raw)
In-Reply-To: <8a5abd0a9929aae160ccb74d7a8d9c3698f61910.1438362603.git.robin.murphy@arm.com>

On Fri, Jul 31, 2015 at 06:18:28PM +0100, Robin Murphy wrote:
> +/*
> + * TODO: Right now __iommu_setup_dma_ops() gets called too early to do
> + * everything it needs to - the device isn't yet fully created, and the
> + * IOMMU driver hasn't seen it yet, so we need this delayed attachment
> + * dance. Once IOMMU probe ordering is sorted to move the
> + * arch_setup_dma_ops() call later, all the notifier bits below become
> + * unnecessary, and will go away.
> + */
> +struct iommu_dma_notifier_data {
> +	struct list_head list;
> +	struct device *dev;
> +	struct iommu_domain *dma_domain;
> +};
> +static LIST_HEAD(iommu_dma_masters);
> +static DEFINE_MUTEX(iommu_dma_notifier_lock);

Ugh, thats incredibly ugly. Why can't you do the setup work then the
iommu driver sees the device? Just call the dma-api setup functions
there (like the x86 iommu drivers do it too) and be done without any
notifiers.

> +static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
> +				  const struct iommu_ops *ops)
> +{
> +	struct iommu_domain *domain;
> +	int err;
> +
> +	if (!ops)
> +		return;
> +	/*
> +	 * In a perfect world, everything happened in the right order up to
> +	 * here, and the IOMMU core has already attached the device to an
> +	 * appropriate default domain for us to set up...
> +	 */
> +	domain = iommu_get_domain_for_dev(dev);
> +	if (!domain) {
> +		/*
> +		 * Urgh. Reliable default domains for platform devices can't
> +		 * happen anyway without some sensible way of handling
> +		 * non-trivial groups. So until then, HORRIBLE HACKS!
> +		 */

I don't get this, what is preventing to rely on default domains here?

> +		domain = ops->domain_alloc(IOMMU_DOMAIN_DMA);

The IOMMU core should already tried to allocate an IOMMU_DOMAIN_DMA type
domain. No need to try this again here.



	Joerg

  parent reply	other threads:[~2015-08-07  8:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-31 17:18 [PATCH v5 0/3] arm64: IOMMU-backed DMA mapping Robin Murphy
2015-07-31 17:18 ` [PATCH v5 1/3] iommu: Implement common IOMMU ops for " Robin Murphy
2015-08-03 17:40   ` Catalin Marinas
2015-08-06 15:23   ` Will Deacon
2015-08-06 17:54     ` joro at 8bytes.org
2015-08-07  8:42   ` Joerg Roedel
2015-08-07 13:38     ` Robin Murphy
2015-08-11  9:37       ` Joerg Roedel
2015-08-11 13:31         ` Robin Murphy
2015-07-31 17:18 ` [PATCH v5 2/3] arm64: Add IOMMU dma_ops Robin Murphy
2015-08-03 17:33   ` Catalin Marinas
2015-08-07  8:52   ` Joerg Roedel [this message]
2015-08-07 15:27     ` Robin Murphy
2015-08-11  9:49       ` Joerg Roedel
2015-08-11 20:15         ` Robin Murphy
2015-09-22 17:12   ` Daniel Kurtz
2015-09-22 18:11     ` Robin Murphy
2015-07-31 17:18 ` [PATCH v5 3/3] arm64: Hook up " Robin Murphy
2015-08-07  8:55   ` Joerg Roedel
2015-08-26  6:19 ` [PATCH v5 0/3] arm64: IOMMU-backed DMA mapping Yong Wu

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=20150807085233.GV14980@8bytes.org \
    --to=joro@8bytes$(echo .)org \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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