public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Saravana Kannan <saravanak-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Cc: Android Kernel Team
	<kernel-team-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>,
	Patrick Daly <pdaly-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	Will Deacon <will-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	Thierry Reding
	<thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>,
	linux-arm-kernel
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	Pratik Patel <pratikp-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
Subject: Re: [RFC 0/2] iommu: arm-smmu: Add support for early direct mappings
Date: Mon, 13 Jan 2020 16:11:55 -0800	[thread overview]
Message-ID: <20200114001155.GJ1214176@minitux> (raw)
In-Reply-To: <CAGETcx8YAXOdr1__gTCT2xCPq47Cg9vGj+5HJ_ZLzy4mHxU2xA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Mon 13 Jan 14:01 PST 2020, Saravana Kannan wrote:

> I added everyone from the other thread, but somehow managed to miss
> the Bjorn who sent the emails! Fixing that now.
> 

Thanks for looping me in Saravana.

> On Mon, Jan 13, 2020 at 6:07 AM Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> >
> > On Fri, Jan 10, 2020 at 08:56:39PM -0800, Saravana Kannan wrote:
[..]
> > In the case where you're trying to inherit the bootloader configuration
> > of the SMMU, how do you solve the problem of passing the page tables to
> > the kernel? You must have some way of reserving that memory in order to
> > prevent the kernel from reusing it.
> 
> Maybe "inherit" makes it sound a lot more complicated than it is?
> Bjorn will know the details of what the bootloader sets up. But
> AFAICT, it looks like a simple "bypass"/identity mapping too. I don't
> think it actually sets up page tables.
> 

In the Qualcomm case we have a number of stream mappings installed when
the bootloader jumps to the OS, each one with SMR/S2CR referring to a CB
with SMMU_CBn_SCTLR.M not set.

As such the relevant hardware is able to access (without translation)
DDR even with SMMU_CR0.USFCFG being set.

The one case where this causes issues is that upon attaching a device to
a context we'll set SMMU_CBn_SCTLR.M, so until we actually have a
translation installed we do get faults - the difference is that these
are not picked up as fatal faults by the secure firmware, so they are
simply reported in Linux.

[..]
> > > > One option that I can think of would be to create an early identity
> > > > domain for each master and inherit it when that master is attached to
> > > > the domain later on, but that seems rather complicated from an book-
> > > > keeping point of view and tricky because we need to be careful not to
> > > > map regions twice, etc.
> > > >
> > > > Any good ideas on how to solve this? It'd also be interesting to see if
> > > > there's a more generic way of doing this. I know that something like
> > > > this isn't necessary on earlier Tegra SoCs with the custom Tegra SMMU
> > > > because translations are only enabled when the devices are attached to a
> > > > domain.
> > >
> > > Good foresight. As [1] shows, identity mapping doesn't solve it in a
> > > generic way.
> >
> > I think your [1] is a special case of identity mappings where the
> > mappings are already active. If you pass the information about the
> > mappings via memory-region properties, then you should be able to
> > reconstruct the identity mapping in the kernel before switching the
> > SMMU over to the new mapping for a seamless transition.
> 
> Ok, makes sense. But I don't have the full details here. So I'll let
> Bjorn comment here.
> 

It might be possible that we can install page tables and setup 1:1
mappings for the necessary resources, but it's not all devices with a
memory-region and a iommu context defined that should have this.

I will have to discuss this in more detail with the Qualcomm engineers.

PS. One detail that I did notice while distilling the downstream patches
is that unused mappings must have SMMU_S2CRx.CBNDX = 255 or I get odd
crashes when the display (CBNDX = 0) is active. I've yet to conclude
why this is.

Regards,
Bjorn

  parent reply	other threads:[~2020-01-14  0:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-09 15:07 [RFC 0/2] iommu: arm-smmu: Add support for early direct mappings Thierry Reding
     [not found] ` <20191209150748.2471814-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-12-09 15:07   ` [RFC 1/2] iommu: arm-smmu: Extract arm_smmu_of_parse() Thierry Reding
2019-12-09 15:07   ` [RFC 2/2] iommu: arm-smmu: Add support for early direct mappings Thierry Reding
2020-01-11  4:56   ` [RFC 0/2] " Saravana Kannan
     [not found]     ` <20200111045639.210486-1-saravanak-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2020-01-13 14:07       ` Thierry Reding
2020-01-13 22:01         ` Saravana Kannan
     [not found]           ` <CAGETcx8YAXOdr1__gTCT2xCPq47Cg9vGj+5HJ_ZLzy4mHxU2xA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-01-14  0:11             ` Bjorn Andersson [this message]
2020-02-28  2:57   ` Bjorn Andersson
2020-03-04 13:48     ` Laurentiu Tudor
2020-05-14 19:32     ` bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A
     [not found]       ` <20200514193249.GE279327-Y7zrm0MriT3hXIiyNabO3w@public.gmane.org>
2020-05-26 20:34         ` John Stultz
     [not found]           ` <CALAqxLVmomdKJCwh=e-PX+8-seDX0RXA81FzmG4sEyJmbXBh9A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-05-27  9:06             ` Laurentiu Tudor
2020-05-27 11:03             ` Will Deacon
2020-06-02  6:32               ` Bjorn Andersson
2020-06-03 11:00                 ` Robin Murphy
     [not found]                   ` <a1f9ee83-66cd-1f04-3e78-3281b3cafd07-5wv7dgnIgG8@public.gmane.org>
2020-07-01  7:40                     ` Bjorn Andersson
     [not found]                       ` <20200701074050.GO388985-Y7zrm0MriT3hXIiyNabO3w@public.gmane.org>
2020-07-01 10:54                         ` Will Deacon
2020-06-03 11:11                 ` Will Deacon
2020-06-03 17:23                   ` Bjorn Andersson
2020-06-02 11:02               ` Thierry Reding
2020-06-02 19:32                 ` Bjorn Andersson
     [not found]                   ` <20200602193249.GC1799770-Y7zrm0MriT3hXIiyNabO3w@public.gmane.org>
2020-06-03 10:24                     ` Thierry Reding
2020-06-03 17:17                       ` Bjorn Andersson

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=20200114001155.GJ1214176@minitux \
    --to=bjorn.andersson-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=kernel-team-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=pdaly-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=pratikp-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=robin.murphy-5wv7dgnIgG8@public.gmane.org \
    --cc=saravanak-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=will-DgEjT+Ai2ygdnm+yROfE0A@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