From b27a32e7f010433cbf848996567b610861b96aa7 Mon Sep 17 00:00:00 2001 From: vasukis Date: Wed, 15 Feb 2023 05:04:15 +0000 Subject: [PATCH] tegra: hwpm: Modify OS common code for QNX Modify the OS common code to be used by HWPM QNX resource manager. JIRA THWPM-44 Change-Id: Ibade56d3d94ce4d7e014e199963e2ddf568e7d3a Signed-off-by: vasukis Reviewed-on: https://git-master.nvidia.com/r/c/linux-hwpm/+/2858465 Reviewed-by: Seema Khowala Reviewed-by: Vivek Bangera GVS: Gerrit_Virtual_Submit --- drivers/tegra/hwpm/include/tegra_hwpm.h | 5 ++++- drivers/tegra/hwpm/include/tegra_hwpm_kmem.h | 15 +------------- drivers/tegra/hwpm/include/tegra_hwpm_log.h | 20 +++++++++---------- .../hwpm/include/tegra_hwpm_static_analysis.h | 20 +++++++++---------- .../tegra/hwpm/include/tegra_hwpm_timers.h | 17 +--------------- drivers/tegra/hwpm/include/tegra_hwpm_types.h | 2 ++ 6 files changed, 28 insertions(+), 51 deletions(-) diff --git a/drivers/tegra/hwpm/include/tegra_hwpm.h b/drivers/tegra/hwpm/include/tegra_hwpm.h index 1d5fc28..af6e4e6 100644 --- a/drivers/tegra/hwpm/include/tegra_hwpm.h +++ b/drivers/tegra/hwpm/include/tegra_hwpm.h @@ -224,8 +224,11 @@ struct hwpm_ip_aperture { u32 device_index; /* MMIO device tree aperture - only populated for perfmon */ +#ifdef __KERNEL__ void __iomem *dt_mmio; - +#else + void *dt_mmio; +#endif /* DT tree name */ char name[64]; diff --git a/drivers/tegra/hwpm/include/tegra_hwpm_kmem.h b/drivers/tegra/hwpm/include/tegra_hwpm_kmem.h index be31734..03d3609 100644 --- a/drivers/tegra/hwpm/include/tegra_hwpm_kmem.h +++ b/drivers/tegra/hwpm/include/tegra_hwpm_kmem.h @@ -27,20 +27,7 @@ #ifdef __KERNEL__ #include #else -void *tegra_hwpm_kzalloc_impl(struct tegra_soc_hwpm *hwpm, size_t size) -{ - return NULL; -} - -void *tegra_hwpm_kcalloc_impl(struct tegra_soc_hwpm *hwpm, u32 num, size_t size) -{ - return NULL; -} - -void tegra_hwpm_kfree_impl(struct tegra_soc_hwpm *hwpm, void *addr) -{ - return; -} +#include #endif #define tegra_hwpm_kzalloc(hwpm, size) \ diff --git a/drivers/tegra/hwpm/include/tegra_hwpm_log.h b/drivers/tegra/hwpm/include/tegra_hwpm_log.h index 7b79164..4f7006c 100644 --- a/drivers/tegra/hwpm/include/tegra_hwpm_log.h +++ b/drivers/tegra/hwpm/include/tegra_hwpm_log.h @@ -28,16 +28,7 @@ #include #include #else -void tegra_hwpm_err_impl(struct tegra_soc_hwpm *hwpm, - const char *func, int line, const char *fmt, ...) -{ - return; -} -void tegra_hwpm_dbg_impl(struct tegra_soc_hwpm *hwpm, - u32 dbg_mask, const char *func, int line, const char *fmt, ...) -{ - return; -} +#include #endif #define TEGRA_SOC_HWPM_MODULE_NAME "tegra-soc-hwpm" @@ -85,6 +76,7 @@ enum tegra_soc_hwpm_log_type { /* Kmem debug prints */ #define hwpm_dbg_kmem BIT(17) +#ifdef __KERNEL__ #define tegra_hwpm_err(hwpm, fmt, arg...) \ tegra_hwpm_err_impl(hwpm, __func__, __LINE__, fmt, ##arg) @@ -92,5 +84,13 @@ enum tegra_soc_hwpm_log_type { tegra_hwpm_dbg_impl(hwpm, dbg_mask, __func__, __LINE__, fmt, ##arg) #define tegra_hwpm_fn(hwpm, fmt, arg...) \ tegra_hwpm_dbg_impl(hwpm, hwpm_fn, __func__, __LINE__, fmt, ##arg) +#else +#define tegra_hwpm_err(hwpm, fmt, arg...) \ + tegra_hwpm_err_impl(hwpm, fmt, ##arg) +#define tegra_hwpm_dbg(hwpm, dbg_mask, fmt, arg...) \ + tegra_hwpm_dbg_impl(hwpm, dbg_mask, fmt, ##arg) +#define tegra_hwpm_fn(hwpm, fmt, arg...) \ + tegra_hwpm_dbg_impl(hwpm, hwpm_fn, fmt, ##arg) +#endif #endif /* TEGRA_HWPM_LOG_H */ diff --git a/drivers/tegra/hwpm/include/tegra_hwpm_static_analysis.h b/drivers/tegra/hwpm/include/tegra_hwpm_static_analysis.h index 1e8e446..ec42c73 100644 --- a/drivers/tegra/hwpm/include/tegra_hwpm_static_analysis.h +++ b/drivers/tegra/hwpm/include/tegra_hwpm_static_analysis.h @@ -42,7 +42,7 @@ static inline u32 tegra_hwpm_safe_add_u32(u32 ui_a, u32 ui_b) { if ((UINT_MAX - ui_a) < ui_b) { - WARN_ON(true); + BUG(); return 0U; } else { return ui_a + ui_b; @@ -65,7 +65,7 @@ static inline u32 tegra_hwpm_safe_add_u32(u32 ui_a, u32 ui_b) static inline u64 tegra_hwpm_safe_add_u64(u64 ul_a, u64 ul_b) { if ((ULONG_MAX - ul_a) < ul_b) { - WARN_ON(true); + BUG(); return 0U; } else { return ul_a + ul_b; @@ -87,7 +87,7 @@ static inline u64 tegra_hwpm_safe_add_u64(u64 ul_a, u64 ul_b) static inline u32 tegra_hwpm_safe_sub_u32(u32 ui_a, u32 ui_b) { if (ui_a < ui_b) { - WARN_ON(true); + BUG(); return 0U; } else { return ui_a - ui_b; @@ -109,7 +109,7 @@ static inline u32 tegra_hwpm_safe_sub_u32(u32 ui_a, u32 ui_b) static inline u64 tegra_hwpm_safe_sub_u64(u64 ul_a, u64 ul_b) { if (ul_a < ul_b) { - WARN_ON(true); + BUG(); return 0U; } else { return ul_a - ul_b; @@ -137,7 +137,7 @@ static inline u32 tegra_hwpm_safe_mult_u32(u32 ui_a, u32 ui_b) if ((ui_a == 0U) || (ui_b == 0U)) { return 0U; } else if (ui_a > (UINT_MAX / ui_b)) { - WARN_ON(true); + BUG(); return 0U; } else { return ui_a * ui_b; @@ -165,7 +165,7 @@ static inline u64 tegra_hwpm_safe_mult_u64(u64 ul_a, u64 ul_b) if ((ul_a == 0UL) || (ul_b == 0UL)) { return 0UL; } else if (ul_a > (ULONG_MAX / ul_b)) { - WARN_ON(true); + BUG(); return 0U; } else { return ul_a * ul_b; @@ -185,7 +185,7 @@ static inline u64 tegra_hwpm_safe_mult_u64(u64 ul_a, u64 ul_b) static inline u32 tegra_hwpm_safe_cast_u64_to_u32(u64 ul_a) { if (ul_a > UINT_MAX) { - WARN_ON(true); + BUG(); return 0U; } else { return (u32)ul_a; @@ -205,7 +205,7 @@ static inline u32 tegra_hwpm_safe_cast_u64_to_u32(u64 ul_a) static inline u64 tegra_hwpm_safe_cast_s32_to_u64(s32 si_a) { if (si_a < 0) { - WARN_ON(true); + BUG(); return 0U; } else { return (u64)si_a; @@ -226,7 +226,7 @@ static inline u64 tegra_hwpm_safe_cast_s32_to_u64(s32 si_a) static inline s32 tegra_hwpm_safe_cast_u64_to_s32(u64 ul_a) { if (ul_a > tegra_hwpm_safe_cast_s32_to_u64(INT_MAX)) { - WARN_ON(true); + BUG(); return 0; } else { return (s32)ul_a; @@ -247,7 +247,7 @@ static inline s32 tegra_hwpm_safe_cast_u64_to_s32(u64 ul_a) static inline u8 tegra_hwpm_safe_cast_u32_to_u8(u32 ui_a) { if (ui_a > U8_MAX) { - WARN_ON(true); + BUG(); return 0U; } else { return (u8)ui_a; diff --git a/drivers/tegra/hwpm/include/tegra_hwpm_timers.h b/drivers/tegra/hwpm/include/tegra_hwpm_timers.h index f5ebf64..93f99ab 100644 --- a/drivers/tegra/hwpm/include/tegra_hwpm_timers.h +++ b/drivers/tegra/hwpm/include/tegra_hwpm_timers.h @@ -29,22 +29,7 @@ #ifdef __KERNEL__ #include #else -int tegra_hwpm_timeout_init_impl(struct tegra_hwpm *hwpm, - struct tegra_hwpm_timeout *timeout, u32 retries) -{ - return -EINVAL; -} - -int tegra_hwpm_timeout_expired_impl(struct tegra_hwpm *hwpm, - struct tegra_hwpm_timeout *timeout) -{ - return -EINVAL; -} - -void tegra_hwpm_msleep_impl(unsigned int msecs) -{ - return -EINVAL; -} +#include #endif #define tegra_hwpm_timeout_init(hwpm, timeout, retries) \ diff --git a/drivers/tegra/hwpm/include/tegra_hwpm_types.h b/drivers/tegra/hwpm/include/tegra_hwpm_types.h index c1f017e..c798ca9 100644 --- a/drivers/tegra/hwpm/include/tegra_hwpm_types.h +++ b/drivers/tegra/hwpm/include/tegra_hwpm_types.h @@ -34,6 +34,8 @@ #include #include #endif +#else +#include #endif #endif /* TEGRA_HWPM_TYPES_H */