mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stanimir Varbanov <svarbanov@suse.de>
To: linux-tegra@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev,
	linux-kernel@vger.kernel.org
Cc: Thierry Reding <thierry.reding@gmail.com>,
	Krishna Reddy <vdumpa@nvidia.com>, Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Joerg Roedel <joro@8bytes.org>,
	Stanimir Varbanov <svarbanov@suse.de>
Subject: [RFC PATCH] iommu: arm-smmu-nvidia: Add default domain type implementation op
Date: Mon, 10 Jul 2023 11:22:52 +0300	[thread overview]
Message-ID: <20230710082252.9702-1-svarbanov@suse.de> (raw)

Add def_domain_type implementation op and override default IOMMU
domain Kconfig option (CONFIG_IOMMU_DEFAULT_PASSTHROUGH=y), which
could be enabled on some distros. The current quirk has been done
for Tegra234 machine, because I found the issue on it. The issue
itself appears on USB host controller which cannot be initialized
without IOMMU translation. Something more, we proved that IOMMU
translation is needed for display and GPU drivers as well.

I evaluated few possible options to solve that:

 a) select default IOMMU domain from .def_domain_type op
 b) Unset CONFIG_IOMMU_DEFAULT_PASSTHROUGH=n
 c) add iommu.passthrough=0 on the kernel cmdline
 d) firmware - ACPI / DT

a) This option is implemented in the proposed patch.

b) Since that the community has agreed that pass-through is preferred
as a default IOMMU domain option because this will avoid performance
impacts on some of the platforms [1]. On the other side we have examples
where you cannot even install Linux distribution on a machine where the
storage media cannot be detected and the system just hangs.

c) - This option involves installer's knowledge of platforms/devices
which needs IOMMU translations.

d) - IORT ACPI table / DT - I'm not sure is that option even possible
but firmware looks like a good place for such.

Please, treat this as an RFC and a call for proper solution.

[1] https://marc.info/?l=linux-arm-kernel&m=148864682514762

Signed-off-by: Stanimir Varbanov <svarbanov@suse.de>
---
 drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c b/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c
index 87bf522b9d2e..691b57d1e699 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c
@@ -286,6 +286,22 @@ static int nvidia_smmu_init_context(struct arm_smmu_domain *smmu_domain,
 	return 0;
 }
 
+static int nvidia_smmu_def_domain_type(struct device *dev)
+{
+	if (of_machine_is_compatible("nvidia,tegra234"))
+		return IOMMU_DOMAIN_DMA;
+
+	return 0;
+}
+
+static int nvidia_smmu_single_def_domain_type(struct device *dev)
+{
+	if (of_machine_is_compatible("nvidia,tegra234"))
+		return IOMMU_DOMAIN_DMA;
+
+	return 0;
+}
+
 static const struct arm_smmu_impl nvidia_smmu_impl = {
 	.read_reg = nvidia_smmu_read_reg,
 	.write_reg = nvidia_smmu_write_reg,
@@ -297,11 +313,13 @@ static const struct arm_smmu_impl nvidia_smmu_impl = {
 	.context_fault = nvidia_smmu_context_fault,
 	.probe_finalize = nvidia_smmu_probe_finalize,
 	.init_context = nvidia_smmu_init_context,
+	.def_domain_type = nvidia_smmu_def_domain_type,
 };
 
 static const struct arm_smmu_impl nvidia_smmu_single_impl = {
 	.probe_finalize = nvidia_smmu_probe_finalize,
 	.init_context = nvidia_smmu_init_context,
+	.def_domain_type = nvidia_smmu_single_def_domain_type,
 };
 
 struct arm_smmu_device *nvidia_smmu_impl_init(struct arm_smmu_device *smmu)
-- 
2.41.0


             reply	other threads:[~2023-07-10  8:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-10  8:22 Stanimir Varbanov [this message]
2023-07-10 10:40 ` Thierry Reding
2023-07-11 10:58   ` Stanimir Varbanov
2023-07-11 15:55     ` Thierry Reding
2023-07-13 13:31       ` Thierry Reding
2023-07-14  3:14         ` Baolu Lu
2023-07-14  6:56           ` Thierry Reding
2023-08-18 16:06             ` Robin Murphy
2023-07-31 15:32       ` Stanimir Varbanov
2023-07-10 18:40 ` Jason Gunthorpe
2023-07-13 13:37   ` Thierry Reding

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=20230710082252.9702-1-svarbanov@suse.de \
    --to=svarbanov@suse.de \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=thierry.reding@gmail.com \
    --cc=vdumpa@nvidia.com \
    --cc=will@kernel.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

all inboxes | Powered by JetHome®