All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch V3] memory: tegra: Remove clients SID override programming
@ 2022-11-25  4:07 Ashish Mhetre
  2022-11-25 15:57 ` Thierry Reding
  2022-12-27  8:59 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: Ashish Mhetre @ 2022-11-25  4:07 UTC (permalink / raw)
  To: krzysztof.kozlowski, thierry.reding, jonathanh, dmitry.osipenko,
	linux-kernel, linux-tegra
  Cc: Ashish Mhetre

On newer Tegra releases, early boot SID override programming and SID
override programming during resume is handled by bootloader.
In the function tegra186_mc_program_sid() which is getting removed, SID
override register of all clients is written without checking if secure
firmware has allowed write on it or not. If write is disabled by secure
firmware then it can lead to errors coming from secure firmware and hang
in kernel boot.
Also, SID override is programmed on-demand during probe_finalize() call
of IOMMU which is done in tegra186_mc_client_sid_override() in this same
file. This function does it correctly by checking if write is permitted
on SID override register. It also checks if SID override register is
already written with correct value and skips re-writing it in that case.

Fixes: 393d66fd2cac ("memory: tegra: Implement SID override programming")
Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
---
Changes in v3:
- Updated the commit message to point out the bug fix.

Changes in v2:
- After offline discussions with Thierry and Jonathan, removed SID
  override programming during resume as well.


 drivers/memory/tegra/tegra186.c | 36 ---------------------------------
 1 file changed, 36 deletions(-)

diff --git a/drivers/memory/tegra/tegra186.c b/drivers/memory/tegra/tegra186.c
index 62477e592bf5..7bb73f06fad3 100644
--- a/drivers/memory/tegra/tegra186.c
+++ b/drivers/memory/tegra/tegra186.c
@@ -22,32 +22,6 @@
 #define MC_SID_STREAMID_SECURITY_WRITE_ACCESS_DISABLED BIT(16)
 #define MC_SID_STREAMID_SECURITY_OVERRIDE BIT(8)
 
-static void tegra186_mc_program_sid(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];
-		u32 override, security;
-
-		override = readl(mc->regs + client->regs.sid.override);
-		security = readl(mc->regs + client->regs.sid.security);
-
-		dev_dbg(mc->dev, "client %s: override: %x security: %x\n",
-			client->name, override, security);
-
-		dev_dbg(mc->dev, "setting SID %u for %s\n", client->sid,
-			client->name);
-		writel(client->sid, mc->regs + client->regs.sid.override);
-
-		override = readl(mc->regs + client->regs.sid.override);
-		security = readl(mc->regs + client->regs.sid.security);
-
-		dev_dbg(mc->dev, "client %s: override: %x security: %x\n",
-			client->name, override, security);
-	}
-}
-
 static int tegra186_mc_probe(struct tegra_mc *mc)
 {
 	struct platform_device *pdev = to_platform_device(mc->dev);
@@ -85,8 +59,6 @@ static int tegra186_mc_probe(struct tegra_mc *mc)
 	if (err < 0)
 		return err;
 
-	tegra186_mc_program_sid(mc);
-
 	return 0;
 }
 
@@ -95,13 +67,6 @@ static void tegra186_mc_remove(struct tegra_mc *mc)
 	of_platform_depopulate(mc->dev);
 }
 
-static int tegra186_mc_resume(struct tegra_mc *mc)
-{
-	tegra186_mc_program_sid(mc);
-
-	return 0;
-}
-
 #if IS_ENABLED(CONFIG_IOMMU_API)
 static void tegra186_mc_client_sid_override(struct tegra_mc *mc,
 					    const struct tegra_mc_client *client,
@@ -173,7 +138,6 @@ static int tegra186_mc_probe_device(struct tegra_mc *mc, struct device *dev)
 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,
 };
-- 
2.17.1


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

* Re: [Patch V3] memory: tegra: Remove clients SID override programming
  2022-11-25  4:07 [Patch V3] memory: tegra: Remove clients SID override programming Ashish Mhetre
@ 2022-11-25 15:57 ` Thierry Reding
  2022-12-27  8:59 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Thierry Reding @ 2022-11-25 15:57 UTC (permalink / raw)
  To: Ashish Mhetre
  Cc: krzysztof.kozlowski, jonathanh, dmitry.osipenko, linux-kernel,
	linux-tegra

[-- Attachment #1: Type: text/plain, Size: 1419 bytes --]

On Fri, Nov 25, 2022 at 09:37:52AM +0530, Ashish Mhetre wrote:
> On newer Tegra releases, early boot SID override programming and SID
> override programming during resume is handled by bootloader.
> In the function tegra186_mc_program_sid() which is getting removed, SID
> override register of all clients is written without checking if secure
> firmware has allowed write on it or not. If write is disabled by secure
> firmware then it can lead to errors coming from secure firmware and hang
> in kernel boot.
> Also, SID override is programmed on-demand during probe_finalize() call
> of IOMMU which is done in tegra186_mc_client_sid_override() in this same
> file. This function does it correctly by checking if write is permitted
> on SID override register. It also checks if SID override register is
> already written with correct value and skips re-writing it in that case.
> 
> Fixes: 393d66fd2cac ("memory: tegra: Implement SID override programming")
> Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
> ---
> Changes in v3:
> - Updated the commit message to point out the bug fix.
> 
> Changes in v2:
> - After offline discussions with Thierry and Jonathan, removed SID
>   override programming during resume as well.
> 
> 
>  drivers/memory/tegra/tegra186.c | 36 ---------------------------------
>  1 file changed, 36 deletions(-)

Acked-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [Patch V3] memory: tegra: Remove clients SID override programming
  2022-11-25  4:07 [Patch V3] memory: tegra: Remove clients SID override programming Ashish Mhetre
  2022-11-25 15:57 ` Thierry Reding
@ 2022-12-27  8:59 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2022-12-27  8:59 UTC (permalink / raw)
  To: dmitry.osipenko, linux-kernel, linux-tegra, jonathanh,
	Ashish Mhetre, thierry.reding
  Cc: Krzysztof Kozlowski

On Fri, 25 Nov 2022 09:37:52 +0530, Ashish Mhetre wrote:
> On newer Tegra releases, early boot SID override programming and SID
> override programming during resume is handled by bootloader.
> In the function tegra186_mc_program_sid() which is getting removed, SID
> override register of all clients is written without checking if secure
> firmware has allowed write on it or not. If write is disabled by secure
> firmware then it can lead to errors coming from secure firmware and hang
> in kernel boot.
> Also, SID override is programmed on-demand during probe_finalize() call
> of IOMMU which is done in tegra186_mc_client_sid_override() in this same
> file. This function does it correctly by checking if write is permitted
> on SID override register. It also checks if SID override register is
> already written with correct value and skips re-writing it in that case.
> 
> [...]

Applied, thanks!

[1/1] memory: tegra: Remove clients SID override programming
      https://git.kernel.org/krzk/linux-mem-ctrl/c/ef86b2c2807f41c045e5534d8513a8b83f63bc39

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

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

end of thread, other threads:[~2022-12-27  8:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25  4:07 [Patch V3] memory: tegra: Remove clients SID override programming Ashish Mhetre
2022-11-25 15:57 ` Thierry Reding
2022-12-27  8:59 ` Krzysztof Kozlowski

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.