From: Joerg Roedel <joro@8bytes.org>
To: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
jroedel@suse.de, Sudeep Holla <sudeep.holla@arm.com>,
Robin Murphy <robin.murphy@arm.com>,
Krzysztof Kozlowski <krzk@kernel.org>
Subject: Re: [PATCH 3/4] iommu/of: Don't call iommu_ops->add_device directly
Date: Wed, 19 Dec 2018 15:34:51 +0100 [thread overview]
Message-ID: <20181219143451.GY16835@8bytes.org> (raw)
In-Reply-To: <30d86186-e0a2-2be1-2295-20510fbd74ba@samsung.com>
Hi Marek,
thanks for the report!
On Wed, Dec 19, 2018 at 10:54:18AM +0100, Marek Szyprowski wrote:
> On 2018-12-11 16:05, 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)
> > - err = ops->add_device(dev);
> > + if (dev->bus && !dev->iommu_group)
> > + err = iommu_probe_device(dev);
>
> This change removes a check for NULL ops, what causes NULL pointer
> exception on first device without IOMMU.
Bummer, this check was supposed to be in iommu_probe_device(), but
apparently it got lost. Does the attached patch fix it?
> I'm also not sure if this is a good idea to call iommu_probe_device(),
> which comes from dev->bus->iommu_ops, which might be different from ops
> from local variable.
The local variable comes from dev->iommu_fwspec->ops, which should be
exactly the same as dev->bus->iommu_ops. I'll leave that for now until
it turns out to be a problem (which I don't expect).
Regards,
Joerg
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index a2131751dcff..3ed4db334341 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -114,10 +114,14 @@ void iommu_device_unregister(struct iommu_device *iommu)
int iommu_probe_device(struct device *dev)
{
const struct iommu_ops *ops = dev->bus->iommu_ops;
+ int ret = -EINVAL;
WARN_ON(dev->iommu_group);
- return ops->add_device(dev);
+ if (ops)
+ ret = ops->add_device(dev);
+
+ return ret;
}
void iommu_release_device(struct device *dev)
next prev parent reply other threads:[~2018-12-19 14:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-11 15:05 [PATCH 0/4 v2] Consolidate iommu_ops->add/remove_device() calls Joerg Roedel
2018-12-11 15:05 ` Joerg Roedel
2018-12-11 15:05 ` [PATCH 1/4] iommu/sysfs: Rename iommu_release_device() Joerg Roedel
2018-12-11 15:05 ` [PATCH 2/4] iommu: Consolitate ->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 [this message]
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
[not found] ` <20181211150513.15161-1-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2018-12-11 15:05 ` [PATCH 4/4] ACPI/IORT: " Joerg Roedel
2018-12-11 15:05 ` Joerg Roedel
[not found] ` <20181211150513.15161-5-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2018-12-17 9:40 ` Hanjun Guo
2018-12-17 9:40 ` Hanjun Guo
-- strict thread matches above, loose matches on Subject: below --
2018-12-05 14:36 [PATCH 0/4] Consolitate iommu_ops->add/remove_device() calls 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
2018-12-06 16:19 ` 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=20181219143451.GY16835@8bytes.org \
--to=joro@8bytes.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jroedel@suse.de \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=robin.murphy@arm.com \
--cc=sudeep.holla@arm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.