tegra: hwpm: add wrapper for timeout functions

Move timeout related code using Linux APIs to os/linux path. Add OS
agnostic wrappers for timeout functions.

Jira THWPM-59

Change-Id: I8e6aa8dabd3a54ecc8a946090d11d036c97a104b
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2735074
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Vedashree Vidwans
2022-06-24 09:00:46 -07:00
committed by mobile promotions
parent 486ec4a24c
commit 74dee85a03
6 changed files with 159 additions and 22 deletions

View File

@@ -27,6 +27,7 @@
#include <tegra_hwpm.h>
#include <tegra_hwpm_kmem.h>
#include <tegra_hwpm_common.h>
#include <tegra_hwpm_timers.h>
#include <tegra_hwpm_mem_mgmt.h>
#include <tegra_hwpm_static_analysis.h>
@@ -243,10 +244,10 @@ int tegra_hwpm_clear_mem_pipeline(struct tegra_soc_hwpm *hwpm)
/* Stream MEM_BYTES to clear pipeline */
if (hwpm->mem_mgmt->mem_bytes_kernel) {
s32 timeout_msecs = 1000;
u32 sleep_msecs = 100;
u32 *mem_bytes_kernel_u32 =
(u32 *)(hwpm->mem_mgmt->mem_bytes_kernel);
u32 sleep_msecs = 100;
struct tegra_hwpm_timeout timeout;
do {
ret = hwpm->active_chip->stream_mem_bytes(hwpm);
@@ -255,13 +256,12 @@ int tegra_hwpm_clear_mem_pipeline(struct tegra_soc_hwpm *hwpm)
"Trigger mem_bytes streaming failed");
goto fail;
}
msleep(sleep_msecs);
timeout_msecs -= sleep_msecs;
tegra_hwpm_msleep(sleep_msecs);
} while ((*mem_bytes_kernel_u32 ==
TEGRA_SOC_HWPM_MEM_BYTES_INVALID) &&
(timeout_msecs > 0));
(tegra_hwpm_timeout_expired(hwpm, &timeout) == 0));
if (timeout_msecs <= 0) {
if (*mem_bytes_kernel_u32 == TEGRA_SOC_HWPM_MEM_BYTES_INVALID) {
tegra_hwpm_err(hwpm,
"Timeout expired for MEM_BYTES streaming");
return -ETIMEDOUT;