mirror of
git://nv-tegra.nvidia.com/linux-hwpm.git
synced 2025-12-23 01:35:10 +03:00
tegra: hwpm: update aperture mmio details
HWPM components (PMA, RTR, perfmon) have MMIO address space and a corresponding virtual address region. It is possible that both MMIO and virtual addresses are same for an aperture. MMIO address of an aperture is used in device node to enable the aperture and further to map HWPM component in the driver. Virtual addresses are used by the applications to execute regops on HWPM apertures. Virtual addresses are also used to fake aperture address space in simulation. This patch updates - HWPM aperture structures to include MMIO address. - aperture ioremap function to use MMIO address values. - fake register allocation to use virtual address values. Jira THWPM-41 Change-Id: I05acb68dcb278722cd333e1187b2355d1d739e93 Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com> (cherry picked from commit 1c0e8107b4cddad7532c10dddc22bb30cef2540b) Reviewed-on: https://git-master.nvidia.com/r/c/linux-hwpm/+/2853213 Reviewed-by: Seema Khowala <seemaj@nvidia.com> GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
1bbda26d7d
commit
e115e1da2f
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -37,6 +37,7 @@ int tegra_hwpm_perfmon_reserve_impl(struct tegra_soc_hwpm *hwpm,
|
||||
}
|
||||
|
||||
/* Reserve */
|
||||
/* Make sure that resource exists in device node */
|
||||
res = platform_get_resource(hwpm_linux->pdev,
|
||||
IORESOURCE_MEM, perfmon->device_index);
|
||||
if ((!res) || (res->start == 0) || (res->end == 0)) {
|
||||
@@ -44,26 +45,17 @@ int tegra_hwpm_perfmon_reserve_impl(struct tegra_soc_hwpm *hwpm,
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (res->start != perfmon->start_abs_pa) {
|
||||
/* Confirm that correct resource is retrived */
|
||||
if (res->start != perfmon->start_pa) {
|
||||
tegra_hwpm_err(hwpm, "Failed to get correct"
|
||||
"perfmon address for %s,"
|
||||
"Expected - 0x%llx, Returned - 0x%llx",
|
||||
perfmon->name, perfmon->start_abs_pa,
|
||||
res->start);
|
||||
perfmon->name, perfmon->start_pa, res->start);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
perfmon->dt_mmio = devm_ioremap(
|
||||
hwpm_linux->dev, res->start, resource_size(res));
|
||||
if (IS_ERR(perfmon->dt_mmio)) {
|
||||
tegra_hwpm_err(hwpm, "Couldn't map perfmon %s", perfmon->name);
|
||||
return PTR_ERR(perfmon->dt_mmio);
|
||||
}
|
||||
|
||||
perfmon->start_pa = res->start;
|
||||
perfmon->end_pa = res->end;
|
||||
|
||||
if (hwpm->fake_registers_enabled) {
|
||||
/* Allocate resource memory as MMIO */
|
||||
u64 address_range = tegra_hwpm_safe_add_u64(
|
||||
tegra_hwpm_safe_sub_u64(res->end, res->start), 1ULL);
|
||||
u64 num_regs = address_range / sizeof(u32);
|
||||
@@ -76,7 +68,17 @@ int tegra_hwpm_perfmon_reserve_impl(struct tegra_soc_hwpm *hwpm,
|
||||
perfmon->start_abs_pa, perfmon->end_abs_pa);
|
||||
return -ENOMEM;
|
||||
}
|
||||
} else {
|
||||
/* Map resource memory in kernel space */
|
||||
perfmon->dt_mmio = devm_ioremap(
|
||||
hwpm_linux->dev, res->start, resource_size(res));
|
||||
if (IS_ERR(perfmon->dt_mmio)) {
|
||||
tegra_hwpm_err(hwpm,
|
||||
"Couldn't map perfmon %s", perfmon->name);
|
||||
return PTR_ERR(perfmon->dt_mmio);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -88,14 +90,11 @@ int tegra_hwpm_perfmux_reserve_impl(struct tegra_soc_hwpm *hwpm,
|
||||
|
||||
tegra_hwpm_fn(hwpm, " ");
|
||||
|
||||
perfmux->start_pa = perfmux->start_abs_pa;
|
||||
perfmux->end_pa = perfmux->end_abs_pa;
|
||||
|
||||
/* Allocate fake registers */
|
||||
if (hwpm->fake_registers_enabled) {
|
||||
u64 address_range = tegra_hwpm_safe_add_u64(
|
||||
tegra_hwpm_safe_sub_u64(
|
||||
perfmux->end_pa, perfmux->start_pa), 1ULL);
|
||||
tegra_hwpm_safe_sub_u64(perfmux->end_abs_pa,
|
||||
perfmux->start_abs_pa), 1ULL);
|
||||
u64 num_regs = address_range / sizeof(u32);
|
||||
|
||||
perfmux->fake_registers =
|
||||
@@ -103,7 +102,7 @@ int tegra_hwpm_perfmux_reserve_impl(struct tegra_soc_hwpm *hwpm,
|
||||
if (perfmux->fake_registers == NULL) {
|
||||
tegra_hwpm_err(hwpm, "Aperture(0x%llx - 0x%llx):"
|
||||
" Couldn't allocate memory for fake registers",
|
||||
perfmux->start_pa, perfmux->end_pa);
|
||||
perfmux->start_abs_pa, perfmux->end_abs_pa);
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
@@ -149,8 +148,6 @@ int tegra_hwpm_perfmon_release_impl(struct tegra_soc_hwpm *hwpm,
|
||||
}
|
||||
devm_iounmap(hwpm_linux->dev, perfmon->dt_mmio);
|
||||
perfmon->dt_mmio = NULL;
|
||||
perfmon->start_pa = 0ULL;
|
||||
perfmon->end_pa = 0ULL;
|
||||
|
||||
if (perfmon->fake_registers) {
|
||||
tegra_hwpm_kfree(hwpm, perfmon->fake_registers);
|
||||
|
||||
Reference in New Issue
Block a user