mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Joerg Roedel <joro@8bytes.org>, iommu@lists.linux-foundation.org
Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Joerg Roedel <jroedel@suse.de>
Subject: Re: [PATCH 3/4] iommu/of: Don't call iommu_ops->add_device directly
Date: Wed, 5 Dec 2018 18:49:26 +0000	[thread overview]
Message-ID: <41d06767-fe6e-a746-d76a-557259af3034@arm.com> (raw)
In-Reply-To: <20181205143646.4876-4-joro@8bytes.org>

On 05/12/2018 14:36, Joerg Roedel wrote:
> From: Joerg Roedel <jroedel@suse.de>
> 
> Make sure to invoke this call-back through the proper
> function of the IOMMU-API.
> 
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> ---
>   drivers/iommu/of_iommu.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c
> index c5dd63072529..4d4847de727e 100644
> --- a/drivers/iommu/of_iommu.c
> +++ b/drivers/iommu/of_iommu.c
> @@ -218,10 +218,10 @@ const struct iommu_ops *of_iommu_configure(struct device *dev,
>   		ops = dev->iommu_fwspec->ops;
>   	/*
>   	 * If we have reason to believe the IOMMU driver missed the initial
> -	 * add_device callback for dev, replay it to get things in order.
> +	 * probe for dev, replay it to get things in order.
>   	 */
> -	if (ops && ops->add_device && dev->bus && !dev->iommu_group)

Ugh, code I wrote...

I think that first ops test is serving double-duty - it's not just an 
"is ops->add_device safe to call?" check, but also the specific "do we 
need to try doing this at all?" check, since ops is only (potentially) 
set in the !err case at the top of this context.

> -		err = ops->add_device(dev);
> +	if (dev->bus && !dev->iommu_group)

Thus to avoid calling add_device erroneously in either of the "no valid 
IOMMU" cases (since dev->bus->iommu_ops may well be non-NULL), this 
still needs to be at least:

	if (ops && dev->bus && !dev->iommu_group)

What I can't quite remember just now is whether it's actually valid to 
get here with err == 0 but dev->iommu_fwspec->ops == NULL, so it *might* 
be OK to use "!err" instead of "ops" to make things slightly more 
obvious - I'll work through the flow tomorrow to double-check.

Robin.

> +		err = iommu_probe_device(dev);
>   
>   	/* Ignore all other errors apart from EPROBE_DEFER */
>   	if (err == -EPROBE_DEFER) {
> 

  reply	other threads:[~2018-12-05 18:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-05 14:36 [PATCH 0/4] Consolitate iommu_ops->add/remove_device() calls Joerg Roedel
2018-12-05 14:36 ` [PATCH 1/4] iommu/sysfs: Rename iommu_release_device() Joerg Roedel
2018-12-05 14:36 ` [PATCH 2/4] iommu: Consolitate ->add/remove_device() calls Joerg Roedel
2018-12-05 14:54   ` Christoph Hellwig
2018-12-05 15:14     ` Joerg Roedel
2018-12-05 18:20   ` Robin Murphy
2018-12-06 15:47     ` Joerg Roedel
2018-12-05 14:36 ` [PATCH 3/4] iommu/of: Don't call iommu_ops->add_device directly Joerg Roedel
2018-12-05 18:49   ` Robin Murphy [this message]
2018-12-06 16:19     ` Joerg Roedel
2018-12-05 14:36 ` [PATCH 4/4] ACPI/IORT: " Joerg Roedel
2018-12-11 15:05 [PATCH 0/4 v2] Consolidate iommu_ops->add/remove_device() calls Joerg Roedel
2018-12-11 15:05 ` [PATCH 3/4] iommu/of: Don't call iommu_ops->add_device directly Joerg Roedel
2018-12-19  9:54   ` Marek Szyprowski
2018-12-19 14:34     ` Joerg Roedel
2018-12-19 14:53       ` Marek Szyprowski
2018-12-20  9:13         ` Joerg Roedel
2018-12-20 15:42       ` Geert Uytterhoeven
2019-01-11 10:23         ` 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=41d06767-fe6e-a746-d76a-557259af3034@arm.com \
    --to=robin.murphy@arm.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=jroedel@suse.de \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®