From: Marc Zyngier <maz@kernel.org>
To: "Sven Peter" <sven@svenpeter.dev>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pci@vger.kernel.org, "Bjorn Helgaas" <bhelgaas@google.com>,
"Rob Herring" <robh+dt@kernel.org>,
"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Alyssa Rosenzweig" <alyssa@rosenzweig.io>,
"Stan Skowronek" <stan@corellium.com>,
"Mark Kettenis" <kettenis@openbsd.org>,
"Hector Martin" <marcan@marcan.st>,
"Robin Murphy" <Robin.Murphy@arm.com>,
kernel-team@android.com
Subject: Re: [PATCH v3 09/10] iommu/dart: Exclude MSI doorbell from PCIe device IOVA range
Date: Fri, 17 Sep 2021 11:01:43 +0100 [thread overview]
Message-ID: <87ilyzbjw8.wl-maz@kernel.org> (raw)
In-Reply-To: <479322ce-b0e4-40e4-831e-387415b4e310@www.fastmail.com>
On Tue, 14 Sep 2021 14:54:07 +0100,
"Sven Peter" <sven@svenpeter.dev> wrote:
>
>
>
> On Mon, Sep 13, 2021, at 20:25, Marc Zyngier wrote:
> > The MSI doorbell on Apple HW can be any address in the low 4GB
> > range. However, the MSI write is matched by the PCIe block before
> > hitting the iommu. It must thus be excluded from the IOVA range
> > that is assigned to any PCIe device.
> >
> > Signed-off-by: Marc Zyngier <maz@kernel.org>
>
> It's not pretty but I'm not aware of any better solution and this should
> work as long as these two are always paired. With the small nit below
> addressed:
>
> Reviewed-by: Sven Peter <sven@svenpeter.dev>
>
> > ---
> > drivers/iommu/apple-dart.c | 25 +++++++++++++++++++++++++
> > drivers/pci/controller/Kconfig | 5 +++++
> > drivers/pci/controller/pcie-apple.c | 4 +++-
> > 3 files changed, 33 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
> > index 559db9259e65..d1456663688e 100644
> > --- a/drivers/iommu/apple-dart.c
> > +++ b/drivers/iommu/apple-dart.c
> > @@ -721,6 +721,29 @@ static int apple_dart_def_domain_type(struct device *dev)
> > return 0;
> > }
> >
> > +#define DOORBELL_ADDR (CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR & PAGE_MASK)
> > +
> > +static void apple_dart_get_resv_regions(struct device *dev,
> > + struct list_head *head)
> > +{
> > +#ifdef CONFIG_PCIE_APPLE
>
> I think using IS_ENABLED would be better here in case the pcie
> driver is built as a module which would then only define
> CONFIG_PCIE_APPLE_MODULE AIUI.
You're right, this isn't great. However, IS_ENABLED() still results in
the evaluation of the following code by the compiler, even if it would
be dropped by the optimiser.
I resorted to the following construct:
<quote>
#ifndef CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR
/* Keep things compiling when CONFIG_PCI_APPLE isn't selected */
#define CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR 0
#endif
#define DOORBELL_ADDR (CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR & PAGE_MASK)
static void apple_dart_get_resv_regions(struct device *dev,
struct list_head *head)
{
if (IS_ENABLED(CONFIG_PCIE_APPLE) && dev_is_pci(dev)) {
</quote>
which is ugly, but works. The alternative is, of course, to add a new
include file for one single value, which I find even worse.
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2021-09-17 10:01 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-13 18:25 [PATCH v3 00/10] PCI: Add support for Apple M1 Marc Zyngier
2021-09-13 18:25 ` [PATCH v3 01/10] irqdomain: Make of_phandle_args_to_fwspec generally available Marc Zyngier
2021-09-13 18:25 ` [PATCH v3 02/10] of/irq: Allow matching of an interrupt-map local to an interrupt controller Marc Zyngier
2021-09-13 21:13 ` Rob Herring
2021-09-13 18:25 ` [PATCH v3 03/10] PCI: of: Allow matching of an interrupt-map local to a pci device Marc Zyngier
2021-09-13 21:30 ` Rob Herring
2021-09-14 19:09 ` Bjorn Helgaas
2021-09-13 18:25 ` [PATCH v3 04/10] PCI: apple: Add initial hardware bring-up Marc Zyngier
2021-09-13 20:48 ` Sven Peter
2021-09-17 9:20 ` Marc Zyngier
2021-09-17 10:42 ` Hector Martin
2021-09-13 18:25 ` [PATCH v3 05/10] PCI: apple: Set up reference clocks when probing Marc Zyngier
2021-09-13 18:25 ` [PATCH v3 06/10] PCI: apple: Add INTx and per-port interrupt support Marc Zyngier
2021-09-13 18:25 ` [PATCH v3 07/10] arm64: apple: t8103: Add root port interrupt routing Marc Zyngier
2021-09-13 18:25 ` [PATCH v3 08/10] PCI: apple: Implement MSI support Marc Zyngier
2021-09-13 20:43 ` Alyssa Rosenzweig
2021-09-17 9:08 ` Marc Zyngier
2021-09-13 18:25 ` [PATCH v3 09/10] iommu/dart: Exclude MSI doorbell from PCIe device IOVA range Marc Zyngier
2021-09-13 18:55 ` Alyssa Rosenzweig
2021-09-17 10:05 ` Marc Zyngier
2021-09-14 13:54 ` Sven Peter
2021-09-17 10:01 ` Marc Zyngier [this message]
2021-09-13 18:25 ` [PATCH v3 10/10] PCI: apple: Configure RID to SID mapper on device addition Marc Zyngier
2021-09-13 20:45 ` Sven Peter
2021-09-14 9:35 ` Marc Zyngier
2021-09-14 9:56 ` Mark Kettenis
2021-09-17 9:19 ` Marc Zyngier
2021-09-17 9:31 ` Mark Kettenis
2021-09-14 13:56 ` Sven Peter
2021-09-19 11:39 ` [PATCH v3 00/10] PCI: Add support for Apple M1 Alyssa Rosenzweig
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=87ilyzbjw8.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=Robin.Murphy@arm.com \
--cc=alyssa@rosenzweig.io \
--cc=bhelgaas@google.com \
--cc=devicetree@vger.kernel.org \
--cc=kernel-team@android.com \
--cc=kettenis@openbsd.org \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=marcan@marcan.st \
--cc=robh+dt@kernel.org \
--cc=stan@corellium.com \
--cc=sven@svenpeter.dev \
/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.