linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch V2 1/2] memory: tegra: Add SID override programming for MC clients
@ 2023-11-07 11:27 Ashish Mhetre
  2023-11-07 11:27 ` [Patch V2 2/2] memory: tegra: Skip SID programming if SID registers aren't set Ashish Mhetre
  2023-11-21  9:10 ` [Patch V2 1/2] memory: tegra: Add SID override programming for MC clients Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: Ashish Mhetre @ 2023-11-07 11:27 UTC (permalink / raw)
  To: krzysztof.kozlowski, thierry.reding, jonathanh, dmitry.osipenko
  Cc: linux-tegra, linux-kernel, Ashish Mhetre

For some devices the bootloader/firmware may set up the device in
bypass. Memory clients like display needs kernel to program SID after
resume because bootloader/firmware programs the SID of display device to
bypass. In order to make sure that kernel IOMMU mappings for these
devices work after resume, add SID override programming support for all
memory clients on memory controller resume.

This partially reverts 'commit ef86b2c2807f ("memory: tegra: Remove
clients SID override programming")'

Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
---
Changes in v2:
- Fixed build issues reported by Kernel test robot from v1

 drivers/memory/tegra/tegra186.c | 14 ++++++++++++++
 include/soc/tegra/mc.h          |  1 +
 2 files changed, 15 insertions(+)

diff --git a/drivers/memory/tegra/tegra186.c b/drivers/memory/tegra/tegra186.c
index 533f85a4b2bd..8203f0db1350 100644
--- a/drivers/memory/tegra/tegra186.c
+++ b/drivers/memory/tegra/tegra186.c
@@ -136,9 +136,23 @@ static int tegra186_mc_probe_device(struct tegra_mc *mc, struct device *dev)
 	return 0;
 }
 
+static int tegra186_mc_resume(struct tegra_mc *mc)
+{
+	unsigned int i;
+
+	for (i = 0; i < mc->soc->num_clients; i++) {
+		const struct tegra_mc_client *client = &mc->soc->clients[i];
+
+		tegra186_mc_client_sid_override(mc, client, client->sid);
+	}
+
+	return 0;
+}
+
 const struct tegra_mc_ops tegra186_mc_ops = {
 	.probe = tegra186_mc_probe,
 	.remove = tegra186_mc_remove,
+	.resume = tegra186_mc_resume,
 	.probe_device = tegra186_mc_probe_device,
 	.handle_irq = tegra30_mc_handle_irq,
 };
diff --git a/include/soc/tegra/mc.h b/include/soc/tegra/mc.h
index 71ae37d3bedd..af1d73a7f0cd 100644
--- a/include/soc/tegra/mc.h
+++ b/include/soc/tegra/mc.h
@@ -162,6 +162,7 @@ struct tegra_mc_ops {
 	 */
 	int (*probe)(struct tegra_mc *mc);
 	void (*remove)(struct tegra_mc *mc);
+	int (*resume)(struct tegra_mc *mc);
 	irqreturn_t (*handle_irq)(int irq, void *data);
 	int (*probe_device)(struct tegra_mc *mc, struct device *dev);
 };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Patch V2 2/2] memory: tegra: Skip SID programming if SID registers aren't set
  2023-11-07 11:27 [Patch V2 1/2] memory: tegra: Add SID override programming for MC clients Ashish Mhetre
@ 2023-11-07 11:27 ` Ashish Mhetre
  2023-11-21  9:10 ` [Patch V2 1/2] memory: tegra: Add SID override programming for MC clients Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Ashish Mhetre @ 2023-11-07 11:27 UTC (permalink / raw)
  To: krzysztof.kozlowski, thierry.reding, jonathanh, dmitry.osipenko
  Cc: linux-tegra, linux-kernel, Ashish Mhetre

There are few MC clients where SID security and override register
offsets are not specified like "sw_cluster0" in tegra234. Don't program
SID override for such clients because it leads to access to invalid
addresses.

Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
---
 drivers/memory/tegra/tegra186.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/memory/tegra/tegra186.c b/drivers/memory/tegra/tegra186.c
index 8203f0db1350..d1f1dfb42716 100644
--- a/drivers/memory/tegra/tegra186.c
+++ b/drivers/memory/tegra/tegra186.c
@@ -75,6 +75,9 @@ static void tegra186_mc_client_sid_override(struct tegra_mc *mc,
 {
 	u32 value, old;
 
+	if (client->regs.sid.security == 0 && client->regs.sid.override == 0)
+		return;
+
 	value = readl(mc->regs + client->regs.sid.security);
 	if ((value & MC_SID_STREAMID_SECURITY_OVERRIDE) == 0) {
 		/*
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Patch V2 1/2] memory: tegra: Add SID override programming for MC clients
  2023-11-07 11:27 [Patch V2 1/2] memory: tegra: Add SID override programming for MC clients Ashish Mhetre
  2023-11-07 11:27 ` [Patch V2 2/2] memory: tegra: Skip SID programming if SID registers aren't set Ashish Mhetre
@ 2023-11-21  9:10 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2023-11-21  9:10 UTC (permalink / raw)
  To: thierry.reding, jonathanh, dmitry.osipenko, Ashish Mhetre
  Cc: Krzysztof Kozlowski, linux-tegra, linux-kernel


On Tue, 07 Nov 2023 16:57:12 +0530, Ashish Mhetre wrote:
> For some devices the bootloader/firmware may set up the device in
> bypass. Memory clients like display needs kernel to program SID after
> resume because bootloader/firmware programs the SID of display device to
> bypass. In order to make sure that kernel IOMMU mappings for these
> devices work after resume, add SID override programming support for all
> memory clients on memory controller resume.
> 
> [...]

Applied, thanks!

[1/2] memory: tegra: Add SID override programming for MC clients
      https://git.kernel.org/krzk/linux-mem-ctrl/c/fe3b082a6eb8b1526ed7397c849d6b2a6baeb6a1
[2/2] memory: tegra: Skip SID programming if SID registers aren't set
      https://git.kernel.org/krzk/linux-mem-ctrl/c/0d6c918011ce4764ed277de4726a468b7ffe5fed

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-21  9:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-07 11:27 [Patch V2 1/2] memory: tegra: Add SID override programming for MC clients Ashish Mhetre
2023-11-07 11:27 ` [Patch V2 2/2] memory: tegra: Skip SID programming if SID registers aren't set Ashish Mhetre
2023-11-21  9:10 ` [Patch V2 1/2] memory: tegra: Add SID override programming for MC clients Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).