Linux IOMMU Development
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
To: Magnus Damm <magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Cc: linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	horms+renesas-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org,
	laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org
Subject: Re: [PATCH/RFC 1/2] arm64: mm: Silently allow devices lacking IOMMU group
Date: Mon, 23 Jan 2017 12:34:05 +0000	[thread overview]
Message-ID: <66c082c6-da2e-9765-0db8-e0ba2c5bd501@arm.com> (raw)
In-Reply-To: <148517353630.18128.12799811817831597628.sendpatchset@little-apple>

Hi Magnus,

On 23/01/17 12:12, Magnus Damm wrote:
> From: Magnus Damm <damm+renesas-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org>
> 
> Consider failure of iommu_get_domain_for_dev() as non-critical and
> get rid of the warning printout. This allows IOMMU properties to be
> included in the DTB even though the kernel is configured with
> CONFIG_IOMMU_API=n or in case a particular IOMMU driver refuses to
> enable IOMMU support for a certain slave device and returns error
> from the ->add_device() callback.
> 
> This is only a cosmetic change that removes console warning printouts.

The warning is there for a reason - at this point, we *expected* the
device to be using an IOMMU for DMA, so a failure is significant. Rather
than masking genuine failures in other cases because your case
deliberately breaks that expectation, simply change the expectation -
i.e. rather than letting of_xlate() succeed then failing add_device()
later, reject the of_xlate() call up-front such that the DMA layer never
gets told about the IOMMU in the first place.

Robin.

> Signed-off-by: Magnus Damm <damm+renesas-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org>
> ---
> 
>  arch/arm64/mm/dma-mapping.c |   10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> --- 0001/arch/arm64/mm/dma-mapping.c
> +++ work/arch/arm64/mm/dma-mapping.c	2017-01-23 20:54:40.060607110 +0900
> @@ -827,11 +827,19 @@ static bool do_iommu_attach(struct devic
>  	struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
>  
>  	/*
> +	 * In case IOMMU support is excluded from the kernel or if the device
> +	 * is not hooked up to any IOMMU group then be silent and keep the
> +	 * old dma_ops.
> +	 */
> +	if (!domain)
> +		return false;
> +
> +	/*
>  	 * If the IOMMU driver has the DMA domain support that we require,
>  	 * then the IOMMU core will have already configured a group for this
>  	 * device, and allocated the default domain for that group.
>  	 */
> -	if (!domain || iommu_dma_init_domain(domain, dma_base, size, dev)) {
> +	if (iommu_dma_init_domain(domain, dma_base, size, dev)) {
>  		pr_warn("Failed to set up IOMMU for device %s; retaining platform DMA ops\n",
>  			dev_name(dev));
>  		return false;
> _______________________________________________
> iommu mailing list
> iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
> https://lists.linuxfoundation.org/mailman/listinfo/iommu
> 

  reply	other threads:[~2017-01-23 12:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-23 12:11 [PATCH/RFC 0/2] iommu/ipmmu-vmsa: IPMMU slave device whitelist Magnus Damm
2017-01-23 12:12 ` [PATCH/RFC 1/2] arm64: mm: Silently allow devices lacking IOMMU group Magnus Damm
2017-01-23 12:34   ` Robin Murphy [this message]
     [not found]     ` <66c082c6-da2e-9765-0db8-e0ba2c5bd501-5wv7dgnIgG8@public.gmane.org>
2017-01-24  8:19       ` Sricharan
2017-01-25 10:02     ` Magnus Damm
2017-01-23 12:12 ` [PATCH/RFC 2/2] iommu/ipmmu-vmsa: Opt-in slave devices based on ES version Magnus Damm
2017-01-23 12:50   ` Geert Uytterhoeven
     [not found]     ` <CAMuHMdWyV4DWN5pKsp+Z6C0MhZF5fKch4T1g1_Hbk3oxrR6_zw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-24  9:38       ` Magnus Damm
2017-01-24 10:32         ` Geert Uytterhoeven

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=66c082c6-da2e-9765-0db8-e0ba2c5bd501@arm.com \
    --to=robin.murphy-5wv7dgnigg8@public.gmane.org \
    --cc=geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org \
    --cc=horms+renesas-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@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