From 57018372b4ee285f7a86484923f0ffb3a214ff6e Mon Sep 17 00:00:00 2001 From: Ashish Mhetre Date: Fri, 12 May 2023 10:49:26 +0000 Subject: [PATCH] NVIDIA: SAUCE: memory: tegra: Skip SID override on HV BugLink: https://bugs.launchpad.net/bugs/2072591 HV has blocked access to MC registers. SID override programming is required on L4T. Add a function to check if HV is present and skip SID override programming in that case. http://nvbugs/4062998 Signed-off-by: Ashish Mhetre Reviewed-by: Prathamesh Shete Tested-by: Prathamesh Shete Signed-off-by: Laxman Dewangan Acked-by: Jacob Martin Acked-by: Noah Wager Signed-off-by: Noah Wager --- drivers/memory/tegra/tegra186.c | 6 ++++++ drivers/soc/tegra/Kconfig | 7 +++++++ include/soc/tegra/tegra-platform-helper.h | 19 +++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 include/soc/tegra/tegra-platform-helper.h diff --git a/drivers/memory/tegra/tegra186.c b/drivers/memory/tegra/tegra186.c index 1b3183951bfe..67950d68c5ca 100644 --- a/drivers/memory/tegra/tegra186.c +++ b/drivers/memory/tegra/tegra186.c @@ -12,6 +12,7 @@ #include #include +#include #if defined(CONFIG_ARCH_TEGRA_186_SOC) #include @@ -121,6 +122,11 @@ static int tegra186_mc_probe_device(struct tegra_mc *mc, struct device *dev) if (!tegra_dev_iommu_get_stream_id(dev, &sid)) return 0; + if (tegra_is_hypervisor_mode() == true) { + pr_debug("MC register access not allowed in Guest Linux\n"); + return 0; + } + while (!of_parse_phandle_with_args(dev->of_node, "interconnects", "#interconnect-cells", index, &args)) { if (args.np == mc->dev->of_node && args.args_count != 0) { diff --git a/drivers/soc/tegra/Kconfig b/drivers/soc/tegra/Kconfig index f16beeabaa92..78a382a96795 100644 --- a/drivers/soc/tegra/Kconfig +++ b/drivers/soc/tegra/Kconfig @@ -170,3 +170,10 @@ config SOC_TEGRA_CBB Support for handling error from Tegra Control Backbone(CBB). This driver handles the errors from CBB and prints debug information about the failed transactions. + +config SOC_TEGRA_PLATFORM_HELPER + def_bool y + help + This config enables support of the platform helpers APIs which can + be used by the out-tree. If this config is y then the helper APIs + are available else not. diff --git a/include/soc/tegra/tegra-platform-helper.h b/include/soc/tegra/tegra-platform-helper.h new file mode 100644 index 000000000000..40911433a26c --- /dev/null +++ b/include/soc/tegra/tegra-platform-helper.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. + */ + +#ifndef TEGRA_PLATFORM_HELPER_H +#define TEGRA_PLATFORM_HELPER_H + +static inline bool tegra_is_hypervisor_mode(void) +{ +#ifdef CONFIG_OF + return of_property_read_bool(of_chosen, + "nvidia,tegra-hypervisor-mode"); +#else + return false; +#endif +} + +#endif /* TEGRA_PLATFORM_HELPER_H */