From: Lorenzo Pieralisi <lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
To: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: "Robin Murphy" <robin.murphy-5wv7dgnIgG8@public.gmane.org>,
"Bjorn Helgaas" <helgaas-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"Vidya Sagar" <vidyas-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
bhelgaas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kthota-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org,
swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org,
mmaddireddy-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org,
"Michal Simek"
<michal.simek-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>,
"Sören Brinkmann"
<soren.brinkmann-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>,
"Simon Horman" <horms-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>,
ryder.lee-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org
Subject: Re: [PATCH] PCI: tegra: limit MSI target address to 32-bit
Date: Mon, 20 Nov 2017 17:07:08 +0000 [thread overview]
Message-ID: <20171120170708.GA1941@red-moon> (raw)
In-Reply-To: <20171110130704.GA31316@ulmo>
[+ryder]
On Fri, Nov 10, 2017 at 02:07:05PM +0100, Thierry Reding wrote:
[...]
> > The really neat version is to take a known non-memory physical address like
> > the host controller's own MMIO region, which has no legitimate reason to
> > ever be used as a DMA address. pcie-mediatek almost gets this right, but by
> > using virt_to_phys() on an ioremapped address they end up with nonsense
> > rather than the correct address (although realistically you would have to be
> > extremely unlucky for said nonsense to collide with a real DMA address given
> > to a PCI endpoint later). Following on from above, dma_map_resource() would
> > be the foolproof way to get that right.
>
> Yes, that was our intention as well. Our initial plan was to use an
> address from the PCI aperture within Tegra that wasn't being used for
> any other purpose.
Hi Thierry,
to wrap up this thread, why an address from the PCI aperture and
not a host bridge register ?
I CC'ed Ryder so that he can explain to me please what:
PCIE_MSI_VECTOR and PCIE_IMSI_ADDR offsets in:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/host/pcie-mediatek.c?h=v4.14
register space represent (IIUC the driver uses:
virt_to_phys(port->base + PCIE_MSI_VECTOR);
as MSI doorbell address, which is wrong anyway as Robin explained, just
want to understand how that register was chosen - it is never written or
read in the driver so it is hard to figure that out) to understand
whether the approach can be replicated instead of relying on GFP_DMA
for pages allocation.
Thanks,
Lorenzo
> However, we ran into some odd corner cases where this wasn't working
> as expected. As a temporary solution we wanted to move to GFP_DMA32
> (or GFP_DMA) in order to support 32-bit only MSI endpoints.
>
> Eventually we'll want to get rid of the allocation altogether, we just
> need to find a set of values that work reliably. In the meantime, it
> looks as though GFP_DMA would be the right solution as long as we have
> to stick with __get_free_pages().
>
> Alternatively, since we've already verified that the MSI writes are
> never committed to memory, we could choose some random address pointing
> to system memory as well, but I'm reluctant to do that because it could
> end up being confusing for users (and developers) to see some random
> address showing up somewhere. A physical address such as the beginning
> of system memory should always work and might be unique enough to
> indicate that it is special.
>
> Thierry
next prev parent reply other threads:[~2017-11-20 17:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-06 18:03 [PATCH] PCI: tegra: limit MSI target address to 32-bit Vidya Sagar
[not found] ` <1509991387-15951-1-git-send-email-vidyas-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2017-11-08 21:25 ` Bjorn Helgaas
[not found] ` <20171108212558.GC21597-1RhO1Y9PlrlHTL0Zs8A6p5iNqAH0jzoTYJqu5kTmcBRl57MIdRCFDg@public.gmane.org>
2017-11-09 7:18 ` Vidya Sagar
[not found] ` <e993e1f8-b6b3-de07-759c-a56012e06a2a-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2017-11-09 18:14 ` Bjorn Helgaas
2017-11-09 18:41 ` Vidya Sagar
[not found] ` <7727b9bc-a44b-4cbe-1839-7e4dd7c2c186-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2017-11-10 9:37 ` Thierry Reding
2017-11-10 11:57 ` Arnd Bergmann
2017-11-10 9:47 ` David Laight
[not found] ` <20171109181435.GB7629-1RhO1Y9PlrlHTL0Zs8A6p5iNqAH0jzoTYJqu5kTmcBRl57MIdRCFDg@public.gmane.org>
2017-11-10 0:47 ` subrahmanya_lingappa
[not found] ` <1686e861-79ac-75eb-b905-769253c6f79e-DTHOJn6Rh8lhmhkoCovsdw@public.gmane.org>
2017-11-10 9:44 ` Thierry Reding
2017-11-10 11:22 ` Lorenzo Pieralisi
2017-11-10 12:04 ` Robin Murphy
[not found] ` <3887d62c-98bb-04d5-5b40-96d5b7b43e63-5wv7dgnIgG8@public.gmane.org>
2017-11-10 13:07 ` Thierry Reding
2017-11-20 17:07 ` Lorenzo Pieralisi [this message]
2017-11-13 11:06 ` Lorenzo Pieralisi
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=20171120170708.GA1941@red-moon \
--to=lorenzo.pieralisi-5wv7dgnigg8@public.gmane.org \
--cc=bhelgaas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=helgaas-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=horms-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org \
--cc=kthota-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=michal.simek-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org \
--cc=mmaddireddy-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=robin.murphy-5wv7dgnIgG8@public.gmane.org \
--cc=ryder.lee-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
--cc=soren.brinkmann-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org \
--cc=swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=vidyas-DDmLM1+adcrQT0dZR+AlfA@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