tegra: hwpm: add membytes high address check

Adding mem bytes high address validation to make sure
it is the same as stream buffer high address.

Change-Id: I189f44037279dc8e9569d1affcee4e19c3194558
Signed-off-by: Besar Wicaksono <bwicaksono@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-hwpm/+/3319873
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Yifei Wan <ywan@nvidia.com>
This commit is contained in:
Besar Wicaksono
2025-03-14 17:54:46 +00:00
committed by mobile promotions
parent a02386ec6e
commit f1de425d35

View File

@@ -125,6 +125,21 @@ static int tegra_hwpm_dma_map_mem_bytes_buffer(struct tegra_soc_hwpm *hwpm,
hwpm->mem_mgmt->mem_bytes_buf_va = hwpm->mem_mgmt->mem_bytes_buf_va =
sg_dma_address(hwpm->mem_mgmt->mem_bytes_sgt->sgl); sg_dma_address(hwpm->mem_mgmt->mem_bytes_sgt->sgl);
/**
* The PMA doesnt define register to specify the high 32-bit address of
* the mem bytes buffer. It will take from the stream buffer's high
* 32-bit address.
* Since mem bytes is allocated in different buffer, we need to check
* the high address of mem bytes buffer is equal to the high address
* of stream buffer.
*/
if ((hwpm->mem_mgmt->mem_bytes_buf_va >> 32) !=
(hwpm->mem_mgmt->stream_buf_va >> 32)) {
tegra_hwpm_err(hwpm,
"Mem bytes and stream buffer high address mismatch");
return -EINVAL;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
/* /*
* Kernel version 5.11 and above introduces dma_buf_map structure * Kernel version 5.11 and above introduces dma_buf_map structure
@@ -342,13 +357,14 @@ int tegra_hwpm_clear_mem_pipeline(struct tegra_soc_hwpm *hwpm)
goto fail; goto fail;
} }
fail:
/* Reset stream buffer */ /* Reset stream buffer */
ret = tegra_hwpm_reset_stream_buf(hwpm); ret = tegra_hwpm_reset_stream_buf(hwpm);
if (ret != 0) { if (ret != 0) {
tegra_hwpm_err(hwpm, "Failed to reset stream buffer"); tegra_hwpm_err(hwpm, "Failed to reset stream buffer");
goto fail; goto fail;
} }
fail:
return ret; return ret;
} }