All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saravana Kannan <saravanak-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
To: thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	robin.murphy-5wv7dgnIgG8@public.gmane.org,
	will-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	Saravana Kannan
	<saravanak-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	Patrick Daly <pdaly-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	Pratik Patel <pratikp-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	Rob Clark <robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	kernel-team-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org
Subject: Re: [RFC 0/2] iommu: arm-smmu: Add support for early direct mappings
Date: Fri, 10 Jan 2020 20:56:39 -0800	[thread overview]
Message-ID: <20200111045639.210486-1-saravanak@google.com> (raw)
In-Reply-To: <20191209150748.2471814-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Hi Thierry,

I happened upon this thread while looking into another thread [1].

> From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> 
> On some platforms, the firmware will setup hardware to read from a given
> region of memory. One such example is a display controller that is
> scanning out a splash screen from physical memory.
> 
> During Linux' boot process, the ARM SMMU will configure all contexts to
> fault by default. This means that memory accesses that happen by an SMMU
> master before its driver has had a chance to properly set up the IOMMU
> will cause a fault. This is especially annoying for something like the
> display controller scanning out a splash screen because the faults will
> result in the display controller getting bogus data (all-ones on Tegra)
> and since it repeatedly scans that framebuffer, it will keep triggering
> such faults and spam the boot log with them.

While I'm not an expert on IOMMUs, I have a decent high level
understanding of the problem you are trying to solve.

> In order to work around such problems, scan the device tree for IOMMU
> masters and set up a special identity domain that will map 1:1 all of
> the reserved regions associated with them. This happens before the SMMU
> is enabled, so that the mappings are already set up before translations
> begin.

I'm not sure if this RFC will solve the splash screen issue across SoCs
([1] seems to have a different issue and might not have memory-regions).

> One thing that was pointed out earlier, and which I don't have a good
> idea on how to solve it, is that the early identity domain is not
> discarded. The assumption is that the standard direct mappings code of
> the IOMMU framework will replace the early identity domain once devices
> are properly attached to domains, but we don't have a good point in time
> when it would be safe to remove the early identity domain.

You are in luck! I added sync_state() driver callbacks [2] exactly for
cases like this. Heck, I even listed IOMMUs as an example use case. :)
sync_state() works even with modules if one enables of_devlink [3] kernel
parameter (which already supports iommus DT bindings). I'd be happy to
answer any question you have on sync_state() and of_devlink.

> 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.

How about actually reading the current settings/mappings and just
inheriting that instead of always doing a 1:1 identity mapping? And then
those "inherited" mappings can be dropped when you get a sync_state().
What's wrong with that option?

Cheers,
Saravana

[1] https://lore.kernel.org/linux-arm-msm/20200108091641.GA15147@willie-the-truck/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/driver-api/driver-model/driver.rst#n172
[3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/kernel-parameters.txt#n3239

WARNING: multiple messages have this Message-ID (diff)
From: Saravana Kannan via iommu <iommu@lists.linux-foundation.org>
To: thierry.reding@gmail.com
Cc: kernel-team@android.com, Saravana Kannan <saravanak@google.com>,
	Patrick Daly <pdaly@codeaurora.org>,
	robin.murphy@arm.com, iommu@lists.linux-foundation.org,
	linux-tegra@vger.kernel.org, will@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Pratik Patel <pratikp@codeaurora.org>
Subject: Re: [RFC 0/2] iommu: arm-smmu: Add support for early direct mappings
Date: Fri, 10 Jan 2020 20:56:39 -0800	[thread overview]
Message-ID: <20200111045639.210486-1-saravanak@google.com> (raw)
In-Reply-To: <20191209150748.2471814-1-thierry.reding@gmail.com>

Hi Thierry,

I happened upon this thread while looking into another thread [1].

> From: Thierry Reding <treding@nvidia.com>
> 
> On some platforms, the firmware will setup hardware to read from a given
> region of memory. One such example is a display controller that is
> scanning out a splash screen from physical memory.
> 
> During Linux' boot process, the ARM SMMU will configure all contexts to
> fault by default. This means that memory accesses that happen by an SMMU
> master before its driver has had a chance to properly set up the IOMMU
> will cause a fault. This is especially annoying for something like the
> display controller scanning out a splash screen because the faults will
> result in the display controller getting bogus data (all-ones on Tegra)
> and since it repeatedly scans that framebuffer, it will keep triggering
> such faults and spam the boot log with them.

While I'm not an expert on IOMMUs, I have a decent high level
understanding of the problem you are trying to solve.

> In order to work around such problems, scan the device tree for IOMMU
> masters and set up a special identity domain that will map 1:1 all of
> the reserved regions associated with them. This happens before the SMMU
> is enabled, so that the mappings are already set up before translations
> begin.

I'm not sure if this RFC will solve the splash screen issue across SoCs
([1] seems to have a different issue and might not have memory-regions).

> One thing that was pointed out earlier, and which I don't have a good
> idea on how to solve it, is that the early identity domain is not
> discarded. The assumption is that the standard direct mappings code of
> the IOMMU framework will replace the early identity domain once devices
> are properly attached to domains, but we don't have a good point in time
> when it would be safe to remove the early identity domain.

You are in luck! I added sync_state() driver callbacks [2] exactly for
cases like this. Heck, I even listed IOMMUs as an example use case. :)
sync_state() works even with modules if one enables of_devlink [3] kernel
parameter (which already supports iommus DT bindings). I'd be happy to
answer any question you have on sync_state() and of_devlink.

> 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.

How about actually reading the current settings/mappings and just
inheriting that instead of always doing a 1:1 identity mapping? And then
those "inherited" mappings can be dropped when you get a sync_state().
What's wrong with that option?

Cheers,
Saravana

[1] https://lore.kernel.org/linux-arm-msm/20200108091641.GA15147@willie-the-truck/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/driver-api/driver-model/driver.rst#n172
[3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/kernel-parameters.txt#n3239
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

WARNING: multiple messages have this Message-ID (diff)
From: Saravana Kannan <saravanak@google.com>
To: thierry.reding@gmail.com
Cc: kernel-team@android.com, Saravana Kannan <saravanak@google.com>,
	Patrick Daly <pdaly@codeaurora.org>,
	robin.murphy@arm.com, joro@8bytes.org,
	Rob Clark <robdclark@gmail.com>,
	iommu@lists.linux-foundation.org, linux-tegra@vger.kernel.org,
	will@kernel.org, linux-arm-kernel@lists.infradead.org,
	Pratik Patel <pratikp@codeaurora.org>
Subject: Re: [RFC 0/2] iommu: arm-smmu: Add support for early direct mappings
Date: Fri, 10 Jan 2020 20:56:39 -0800	[thread overview]
Message-ID: <20200111045639.210486-1-saravanak@google.com> (raw)
In-Reply-To: <20191209150748.2471814-1-thierry.reding@gmail.com>

Hi Thierry,

I happened upon this thread while looking into another thread [1].

> From: Thierry Reding <treding@nvidia.com>
> 
> On some platforms, the firmware will setup hardware to read from a given
> region of memory. One such example is a display controller that is
> scanning out a splash screen from physical memory.
> 
> During Linux' boot process, the ARM SMMU will configure all contexts to
> fault by default. This means that memory accesses that happen by an SMMU
> master before its driver has had a chance to properly set up the IOMMU
> will cause a fault. This is especially annoying for something like the
> display controller scanning out a splash screen because the faults will
> result in the display controller getting bogus data (all-ones on Tegra)
> and since it repeatedly scans that framebuffer, it will keep triggering
> such faults and spam the boot log with them.

While I'm not an expert on IOMMUs, I have a decent high level
understanding of the problem you are trying to solve.

> In order to work around such problems, scan the device tree for IOMMU
> masters and set up a special identity domain that will map 1:1 all of
> the reserved regions associated with them. This happens before the SMMU
> is enabled, so that the mappings are already set up before translations
> begin.

I'm not sure if this RFC will solve the splash screen issue across SoCs
([1] seems to have a different issue and might not have memory-regions).

> One thing that was pointed out earlier, and which I don't have a good
> idea on how to solve it, is that the early identity domain is not
> discarded. The assumption is that the standard direct mappings code of
> the IOMMU framework will replace the early identity domain once devices
> are properly attached to domains, but we don't have a good point in time
> when it would be safe to remove the early identity domain.

You are in luck! I added sync_state() driver callbacks [2] exactly for
cases like this. Heck, I even listed IOMMUs as an example use case. :)
sync_state() works even with modules if one enables of_devlink [3] kernel
parameter (which already supports iommus DT bindings). I'd be happy to
answer any question you have on sync_state() and of_devlink.

> 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.

How about actually reading the current settings/mappings and just
inheriting that instead of always doing a 1:1 identity mapping? And then
those "inherited" mappings can be dropped when you get a sync_state().
What's wrong with that option?

Cheers,
Saravana

[1] https://lore.kernel.org/linux-arm-msm/20200108091641.GA15147@willie-the-truck/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/driver-api/driver-model/driver.rst#n172
[3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/kernel-parameters.txt#n3239

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-01-11  4:56 UTC|newest]

Thread overview: 85+ 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
2019-12-09 15:07 ` Thierry Reding
2019-12-09 15:07 ` 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     ` Thierry Reding
2019-12-09 15:07     ` Thierry Reding
2019-12-09 15:07   ` [RFC 2/2] iommu: arm-smmu: Add support for early direct mappings Thierry Reding
2019-12-09 15:07     ` Thierry Reding
2019-12-09 15:07     ` Thierry Reding
2020-01-11  4:56   ` Saravana Kannan [this message]
2020-01-11  4:56     ` [RFC 0/2] " Saravana Kannan
2020-01-11  4:56     ` Saravana Kannan via iommu
     [not found]     ` <20200111045639.210486-1-saravanak-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2020-01-13 14:07       ` Thierry Reding
2020-01-13 14:07         ` Thierry Reding
2020-01-13 14:07         ` Thierry Reding
2020-01-13 22:01         ` Saravana Kannan
2020-01-13 22:01           ` Saravana Kannan
2020-01-13 22:01           ` Saravana Kannan via iommu
     [not found]           ` <CAGETcx8YAXOdr1__gTCT2xCPq47Cg9vGj+5HJ_ZLzy4mHxU2xA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-01-14  0:11             ` Bjorn Andersson
2020-01-14  0:11               ` Bjorn Andersson
2020-01-14  0:11               ` Bjorn Andersson
2020-02-28  2:57   ` Bjorn Andersson
2020-02-28  2:57     ` Bjorn Andersson
2020-02-28  2:57     ` Bjorn Andersson
2020-02-28  2:57     ` Bjorn Andersson
2020-03-04 13:48     ` Laurentiu Tudor
2020-03-04 13:48       ` Laurentiu Tudor
2020-03-04 13:48       ` Laurentiu Tudor
2020-03-04 13:48       ` Laurentiu Tudor
2020-05-14 19:32     ` bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A
2020-05-14 19:32       ` bjorn.andersson
2020-05-14 19:32       ` bjorn.andersson
2020-05-14 19:32       ` bjorn.andersson
     [not found]       ` <20200514193249.GE279327-Y7zrm0MriT3hXIiyNabO3w@public.gmane.org>
2020-05-26 20:34         ` John Stultz
2020-05-26 20:34           ` John Stultz
2020-05-26 20:34           ` John Stultz
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  9:06               ` Laurentiu Tudor
2020-05-27  9:06               ` Laurentiu Tudor
2020-05-27  9:06               ` Laurentiu Tudor
2020-05-27 11:03             ` Will Deacon
2020-05-27 11:03               ` Will Deacon
2020-05-27 11:03               ` Will Deacon
2020-05-27 11:03               ` Will Deacon
2020-06-02  6:32               ` Bjorn Andersson
2020-06-02  6:32                 ` Bjorn Andersson
2020-06-02  6:32                 ` Bjorn Andersson
2020-06-02  6:32                 ` Bjorn Andersson
2020-06-03 11:00                 ` Robin Murphy
2020-06-03 11:00                   ` Robin Murphy
2020-06-03 11:00                   ` Robin Murphy
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
2020-07-01  7:40                       ` Bjorn Andersson
2020-07-01  7:40                       ` Bjorn Andersson
2020-07-01  7:40                       ` Bjorn Andersson
     [not found]                       ` <20200701074050.GO388985-Y7zrm0MriT3hXIiyNabO3w@public.gmane.org>
2020-07-01 10:54                         ` Will Deacon
2020-07-01 10:54                           ` Will Deacon
2020-07-01 10:54                           ` Will Deacon
2020-07-01 10:54                           ` Will Deacon
2020-06-03 11:11                 ` Will Deacon
2020-06-03 11:11                   ` Will Deacon
2020-06-03 11:11                   ` Will Deacon
2020-06-03 11:11                   ` Will Deacon
2020-06-03 17:23                   ` Bjorn Andersson
2020-06-03 17:23                     ` Bjorn Andersson
2020-06-03 17:23                     ` Bjorn Andersson
2020-06-03 17:23                     ` Bjorn Andersson
2020-06-02 11:02               ` Thierry Reding
2020-06-02 11:02                 ` Thierry Reding
2020-06-02 11:02                 ` Thierry Reding
2020-06-02 11:02                 ` Thierry Reding
2020-06-02 19:32                 ` Bjorn Andersson
2020-06-02 19:32                   ` Bjorn Andersson
2020-06-02 19:32                   ` Bjorn Andersson
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 10:24                       ` Thierry Reding
2020-06-03 10:24                       ` Thierry Reding
2020-06-03 10:24                       ` Thierry Reding
2020-06-03 17:17                       ` Bjorn Andersson
2020-06-03 17:17                         ` Bjorn Andersson
2020-06-03 17:17                         ` Bjorn Andersson
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=20200111045639.210486-1-saravanak@google.com \
    --to=saravanak-hpiqsd4aklfqt0dzr+alfa@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=joro-zLv9SwRftAIdnm+yROfE0A@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=robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=robin.murphy-5wv7dgnIgG8@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 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.