tegra: hwpm: add wrapper linux os structure

Currently, HWPM parent structure contains linux specific device
variables. In an effort to make HWPM driver OS agnostic, create Linux
specific wrapper HWPM structure tegra_hwpm_os_linux. Move linux specific
variables from tegra_soc_hwpm structure to tegra_hwpm_os_linux
structure.

Jira THWPM-60

Change-Id: I189cde92c5b83b327ccb467c72dee5756f16481d
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2729700
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Vedashree Vidwans
2022-06-15 23:41:07 -07:00
committed by mobile promotions
parent 2dd64aec0b
commit 738361e0e2
14 changed files with 292 additions and 212 deletions

View File

@@ -31,11 +31,21 @@
#include <tegra_hwpm_mem_mgmt.h>
#include <tegra_hwpm_static_analysis.h>
#include <os/linux/driver.h>
static int tegra_hwpm_dma_map_stream_buffer(struct tegra_soc_hwpm *hwpm,
struct tegra_soc_hwpm_alloc_pma_stream *alloc_pma_stream)
{
struct tegra_hwpm_os_linux *hwpm_linux = NULL;
tegra_hwpm_fn(hwpm, " ");
hwpm_linux = tegra_hwpm_os_linux_from_hwpm(hwpm);
if (!hwpm_linux) {
tegra_hwpm_err(NULL, "Invalid hwpm_linux struct");
return -ENODEV;
}
hwpm->mem_mgmt->stream_buf_size = alloc_pma_stream->stream_buf_size;
hwpm->mem_mgmt->stream_dma_buf =
dma_buf_get(tegra_hwpm_safe_cast_u64_to_s32(
@@ -45,7 +55,7 @@ static int tegra_hwpm_dma_map_stream_buffer(struct tegra_soc_hwpm *hwpm,
return PTR_ERR(hwpm->mem_mgmt->stream_dma_buf);
}
hwpm->mem_mgmt->stream_attach =
dma_buf_attach(hwpm->mem_mgmt->stream_dma_buf, hwpm->dev);
dma_buf_attach(hwpm->mem_mgmt->stream_dma_buf, hwpm_linux->dev);
if (IS_ERR(hwpm->mem_mgmt->stream_attach)) {
tegra_hwpm_err(hwpm, "Unable to attach stream dma_buf");
return PTR_ERR(hwpm->mem_mgmt->stream_attach);
@@ -74,8 +84,16 @@ static int tegra_hwpm_dma_map_stream_buffer(struct tegra_soc_hwpm *hwpm,
static int tegra_hwpm_dma_map_mem_bytes_buffer(struct tegra_soc_hwpm *hwpm,
struct tegra_soc_hwpm_alloc_pma_stream *alloc_pma_stream)
{
struct tegra_hwpm_os_linux *hwpm_linux = NULL;
tegra_hwpm_fn(hwpm, " ");
hwpm_linux = tegra_hwpm_os_linux_from_hwpm(hwpm);
if (!hwpm_linux) {
tegra_hwpm_err(NULL, "Invalid hwpm_linux struct");
return -ENODEV;
}
hwpm->mem_mgmt->mem_bytes_dma_buf =
dma_buf_get(tegra_hwpm_safe_cast_u64_to_s32(
alloc_pma_stream->mem_bytes_buf_fd));
@@ -85,7 +103,7 @@ static int tegra_hwpm_dma_map_mem_bytes_buffer(struct tegra_soc_hwpm *hwpm,
}
hwpm->mem_mgmt->mem_bytes_attach = dma_buf_attach(
hwpm->mem_mgmt->mem_bytes_dma_buf, hwpm->dev);
hwpm->mem_mgmt->mem_bytes_dma_buf, hwpm_linux->dev);
if (IS_ERR(hwpm->mem_mgmt->mem_bytes_attach)) {
tegra_hwpm_err(hwpm, "Unable to attach mem bytes dma_buf");
return PTR_ERR(hwpm->mem_mgmt->mem_bytes_attach);