From: Lorenzo Pieralisi <lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
To: Marc Zyngier <marc.zyngier-5wv7dgnIgG8@public.gmane.org>
Cc: Shameer Kolothum
<shameerali.kolothum.thodi-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
sudeep.holla-5wv7dgnIgG8@public.gmane.org,
will.deacon-5wv7dgnIgG8@public.gmane.org,
robin.murphy-5wv7dgnIgG8@public.gmane.org,
joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org,
mark.rutland-5wv7dgnIgG8@public.gmane.org,
robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
gabriele.paoloni-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
john.garry-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devel-E0kO6a4B6psdnm+yROfE0A@public.gmane.org,
linuxarm-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
wangzhou1-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org,
guohanjun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org
Subject: Re: [PATCH v8 3/5] iommu/of: Add msi address regions reservation helper
Date: Wed, 4 Oct 2017 14:50:07 +0100 [thread overview]
Message-ID: <20171004135007.GA12327@red-moon> (raw)
In-Reply-To: <f3146f49-6004-7a15-866b-653e3ea54856-5wv7dgnIgG8@public.gmane.org>
On Wed, Oct 04, 2017 at 12:22:04PM +0100, Marc Zyngier wrote:
> On 27/09/17 14:32, Shameer Kolothum wrote:
> > From: John Garry <john.garry-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> >
> > On some platforms msi-controller address regions have to be excluded
> > from normal IOVA allocation in that they are detected and decoded in
> > a HW specific way by system components and so they cannot be considered
> > normal IOVA address space.
> >
> > Add a helper function that retrieves msi address regions through device
> > tree msi mapping, so that these regions will not be translated by IOMMU
> > and will be excluded from IOVA allocations.
> >
> > Signed-off-by: John Garry <john.garry-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> > [Shameer: Modified msi-parent retrieval logic]
> > Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> > ---
> > drivers/iommu/of_iommu.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++
> > include/linux/of_iommu.h | 10 +++++
> > 2 files changed, 105 insertions(+)
> >
> > diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c
> > index e60e3db..ffd7fb7 100644
> > --- a/drivers/iommu/of_iommu.c
> > +++ b/drivers/iommu/of_iommu.c
> > @@ -21,6 +21,7 @@
> > #include <linux/iommu.h>
> > #include <linux/limits.h>
> > #include <linux/of.h>
> > +#include <linux/of_address.h>
> > #include <linux/of_iommu.h>
> > #include <linux/of_pci.h>
> > #include <linux/slab.h>
> > @@ -138,6 +139,14 @@ static int of_iommu_xlate(struct device *dev,
> > return ops->of_xlate(dev, iommu_spec);
> > }
> >
> > +static int __get_pci_rid(struct pci_dev *pdev, u16 alias, void *data)
> > +{
> > + u32 *rid = data;
> > +
> > + *rid = alias;
> > + return 0;
> > +}
> > +
> > struct of_pci_iommu_alias_info {
> > struct device *dev;
> > struct device_node *np;
> > @@ -163,6 +172,73 @@ static int of_pci_iommu_init(struct pci_dev *pdev, u16 alias, void *data)
> > return info->np == pdev->bus->dev.of_node;
> > }
> >
> > +static int of_iommu_alloc_resv_region(struct device_node *np,
> > + struct list_head *head)
> > +{
> > + int prot = IOMMU_WRITE | IOMMU_NOEXEC | IOMMU_MMIO;
> > + struct iommu_resv_region *region;
> > + struct resource res;
> > + int err;
> > +
> > + err = of_address_to_resource(np, 0, &res);
>
> What is the rational for registering the first region only? Surely you
> can have more than one region in an MSI controller (yes, your particular
> case is the ITS which has only one, but we're trying to do something
> generic here).
>
> Another issue I have with this code is that it inserts all of the ITS
> MMIO in the RESV_MSI range. As long as we don't generate any page tables
> for this, we're fine. But if we ever change this, we'll end-up with the
> ITS programming interface being exposed to a device, which wouldn't be
> acceptable.
>
> Why can't we have some generic property instead, that would describe the
> actual ranges that cannot be translated? That way, no random insertion
> of a random range, and relatively future proof.
IORT code has the same issue (ie it reserves all ITS regions) and I do
not know where a property can be added to describe those ranges (IORT
specs ? I'd rather not) in ACPI other than the IORT tables entries
themselves.
> I'm not sure where to declare it (PCIe node? IOMMU node?), but it'd feel
> like a much nicer and simpler solution to this problem.
It could be but if we throw ACPI into the picture we have to knock
together Hisilicon specific namespace bindings to handle this and
quickly.
Lorenzo
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-10-04 13:50 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-27 13:32 [PATCH v8 0/5] iommu/smmu-v3: Workaround for hisilicon 161010801 erratum(reserve HW MSI) Shameer Kolothum
2017-09-27 13:32 ` [PATCH v8 1/5] Doc: iommu/arm-smmu-v3: Add workaround for HiSilicon erratum 161010801 Shameer Kolothum
2017-10-05 22:24 ` Rob Herring
2017-09-27 13:32 ` [PATCH v8 3/5] iommu/of: Add msi address regions reservation helper Shameer Kolothum
[not found] ` <20170927133241.21036-4-shameerali.kolothum.thodi-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-10-04 11:22 ` Marc Zyngier
[not found] ` <f3146f49-6004-7a15-866b-653e3ea54856-5wv7dgnIgG8@public.gmane.org>
2017-10-04 13:50 ` Lorenzo Pieralisi [this message]
2017-10-05 11:07 ` Robin Murphy
[not found] ` <5c80f292-dc5d-a1c6-d7a0-df2a84cc77d1-5wv7dgnIgG8@public.gmane.org>
2017-10-05 11:57 ` Will Deacon
[not found] ` <20171005115719.GC11088-5wv7dgnIgG8@public.gmane.org>
2017-10-05 12:55 ` Robin Murphy
2017-10-05 12:37 ` John Garry
[not found] ` <d525f112-fb20-d14b-bea0-6547c8b933dd-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-10-05 12:44 ` Robin Murphy
2017-10-05 13:08 ` John Garry
[not found] ` <82272c18-717d-bbaf-b8c3-61785af496bd-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-10-05 14:05 ` Robin Murphy
2017-10-04 17:07 ` Shameerali Kolothum Thodi
2017-09-27 13:32 ` [PATCH v8 4/5] iommu/dma: Add a helper function to reserve HW MSI address regions for IOMMU drivers Shameer Kolothum
2017-09-27 13:32 ` [PATCH v8 5/5] iommu/arm-smmu-v3:Enable ACPI based HiSilicon erratum 161010801 Shameer Kolothum
[not found] ` <20170927133241.21036-1-shameerali.kolothum.thodi-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-09-27 13:32 ` [PATCH v8 2/5] ACPI/IORT: Add msi address regions reservation helper Shameer Kolothum
[not found] ` <20170927133241.21036-3-shameerali.kolothum.thodi-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-10-04 14:17 ` Marc Zyngier
[not found] ` <001729e8-7b34-0bb4-8af6-8af100661906-5wv7dgnIgG8@public.gmane.org>
2017-10-06 10:17 ` Shameerali Kolothum Thodi
2017-10-04 10:03 ` [PATCH v8 0/5] iommu/smmu-v3: Workaround for hisilicon 161010801 erratum(reserve HW MSI) Shameerali Kolothum Thodi
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=20171004135007.GA12327@red-moon \
--to=lorenzo.pieralisi-5wv7dgnigg8@public.gmane.org \
--cc=devel-E0kO6a4B6psdnm+yROfE0A@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=gabriele.paoloni-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=guohanjun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=john.garry-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org \
--cc=linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linuxarm-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=marc.zyngier-5wv7dgnIgG8@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=robin.murphy-5wv7dgnIgG8@public.gmane.org \
--cc=shameerali.kolothum.thodi-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=sudeep.holla-5wv7dgnIgG8@public.gmane.org \
--cc=wangzhou1-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org \
--cc=will.deacon-5wv7dgnIgG8@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;
as well as URLs for NNTP newsgroup(s).