[V2] memory: tegra: Remove clients SID override programming

Message ID 20221122053103.17895-1-amhetre@nvidia.com
State New
Headers
Series [V2] memory: tegra: Remove clients SID override programming |

Commit Message

Ashish Mhetre Nov. 22, 2022, 5:31 a.m. UTC
  On newer Tegra releases, early boot SID override programming and SID
override programming during resume is handled by bootloader.
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 more 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.
Hence, removing the SID override programming of all clients.

Fixes: 393d66fd2cac ("memory: tegra: Implement SID override programming")
Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
---
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(-)
  

Comments

Krzysztof Kozlowski Nov. 22, 2022, 11:14 a.m. UTC | #1
On 22/11/2022 06:31, Ashish Mhetre wrote:
> On newer Tegra releases, early boot SID override programming and SID
> override programming during resume is handled by bootloader.
> 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 more 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.
> Hence, removing the SID override programming of all clients.
> 
> Fixes: 393d66fd2cac ("memory: tegra: Implement SID override programming")

I could not get from commit msg what is the bug being fixed. You just
said "more correctly", but usually things are either correct or not.
What are visible effects of the bug?

Otherwise it sounds more like optimization or a bit better approach, but
not a bugfix.

Best regards,
Krzysztof
  
Ashish Mhetre Nov. 24, 2022, 10:20 a.m. UTC | #2
On 11/22/2022 4:44 PM, Krzysztof Kozlowski wrote:
> External email: Use caution opening links or attachments
>
>
> On 22/11/2022 06:31, Ashish Mhetre wrote:
>> On newer Tegra releases, early boot SID override programming and SID
>> override programming during resume is handled by bootloader.
>> 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 more 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.
>> Hence, removing the SID override programming of all clients.
>>
>> Fixes: 393d66fd2cac ("memory: tegra: Implement SID override programming")
> I could not get from commit msg what is the bug being fixed. You just
> said "more correctly", but usually things are either correct or not.
> What are visible effects of the bug?
>
> Otherwise it sounds more like optimization or a bit better approach, but
> not a bugfix.
>
> Best regards,
> Krzysztof

Thanks for the review. 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. So, that's a possible bug.
Also, it's an optimization over current approach because it saves time by
removing re-writing of these SID override registers as in new Tegra releases
SID override of all clients is programmed by bootloader. So, MC driver don't
need to program them again.

Thanks,
Ashish Mhetre
  
Krzysztof Kozlowski Nov. 24, 2022, 11:34 a.m. UTC | #3
On 24/11/2022 11:20, Ashish Mhetre wrote:
> 
> On 11/22/2022 4:44 PM, Krzysztof Kozlowski wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> On 22/11/2022 06:31, Ashish Mhetre wrote:
>>> On newer Tegra releases, early boot SID override programming and SID
>>> override programming during resume is handled by bootloader.
>>> 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 more 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.
>>> Hence, removing the SID override programming of all clients.
>>>
>>> Fixes: 393d66fd2cac ("memory: tegra: Implement SID override programming")
>> I could not get from commit msg what is the bug being fixed. You just
>> said "more correctly", but usually things are either correct or not.
>> What are visible effects of the bug?
>>
>> Otherwise it sounds more like optimization or a bit better approach, but
>> not a bugfix.
>>
>> Best regards,
>> Krzysztof
> 
> Thanks for the review. 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. So, that's a possible bug.

Please add it to commit msg, because it justifies Fixes tag and probably
backport.

> Also, it's an optimization over current approach because it saves time by
> removing re-writing of these SID override registers as in new Tegra releases
> SID override of all clients is programmed by bootloader. So, MC driver don't
> need to program them again.

Best regards,
Krzysztof
  
Ashish Mhetre Nov. 25, 2022, 3:49 a.m. UTC | #4
On 11/24/2022 5:04 PM, Krzysztof Kozlowski wrote:
> External email: Use caution opening links or attachments
>
>
> On 24/11/2022 11:20, Ashish Mhetre wrote:
>> On 11/22/2022 4:44 PM, Krzysztof Kozlowski wrote:
>>> External email: Use caution opening links or attachments
>>>
>>>
>>> On 22/11/2022 06:31, Ashish Mhetre wrote:
>>>> On newer Tegra releases, early boot SID override programming and SID
>>>> override programming during resume is handled by bootloader.
>>>> 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 more 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.
>>>> Hence, removing the SID override programming of all clients.
>>>>
>>>> Fixes: 393d66fd2cac ("memory: tegra: Implement SID override programming")
>>> I could not get from commit msg what is the bug being fixed. You just
>>> said "more correctly", but usually things are either correct or not.
>>> What are visible effects of the bug?
>>>
>>> Otherwise it sounds more like optimization or a bit better approach, but
>>> not a bugfix.
>>>
>>> Best regards,
>>> Krzysztof
>> Thanks for the review. 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. So, that's a possible bug.
> Please add it to commit msg, because it justifies Fixes tag and probably
> backport.

Sure, I will send V3 with updated commit message. Thank you.

>> Also, it's an optimization over current approach because it saves time by
>> removing re-writing of these SID override registers as in new Tegra releases
>> SID override of all clients is programmed by bootloader. So, MC driver don't
>> need to program them again.
> Best regards,
> Krzysztof
>
  

Patch

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,
 };