From 5b8bb57dcb4f507cd240926c9c2667fff599b00f Mon Sep 17 00:00:00 2001 From: Vedashree Vidwans Date: Wed, 26 Apr 2023 22:17:14 -0700 Subject: [PATCH] hwpm: Makefile: Add support to make as module Add support to make the HWPM driver as module. Set appropriate path and environment variable which needs to be passed when building the driver as module. Use basic fuse.h file instead of using fuse-helper.h which is not available in OOT builds. Introduce HWPM mock file to add definitions for register and unregister used if HWPM is not compiled in a build. Bug 4088571 Change-Id: Id6cfb78356d752b963ad7eb16e39b85df92a9a4b Signed-off-by: Laxman Dewangan Signed-off-by: Vedashree Vidwans Reviewed-on: https://git-master.nvidia.com/r/c/linux-hwpm/+/2894547 GVS: Gerrit_Virtual_Submit --- drivers/Kconfig | 7 ++++ drivers/Makefile | 5 +++ drivers/tegra/hwpm/Kconfig | 7 ++++ drivers/tegra/hwpm/Makefile | 48 +++++++++++---------- drivers/tegra/hwpm/Makefile.sources | 18 ++++++++ drivers/tegra/hwpm/os/linux/soc_utils.c | 2 +- drivers/tegra/hwpm/tegra_hwpm_mock.c | 55 +++++++++++++++++++++++++ 7 files changed, 120 insertions(+), 22 deletions(-) create mode 100644 drivers/Kconfig create mode 100644 drivers/Makefile create mode 100644 drivers/tegra/hwpm/Makefile.sources create mode 100644 drivers/tegra/hwpm/tegra_hwpm_mock.c diff --git a/drivers/Kconfig b/drivers/Kconfig new file mode 100644 index 0000000..f27158f --- /dev/null +++ b/drivers/Kconfig @@ -0,0 +1,7 @@ +append_menu "Device Drivers" + +if ARCH_TEGRA +source "drivers/tegra/hwpm/Kconfig" +endif + +endmenu diff --git a/drivers/Makefile b/drivers/Makefile new file mode 100644 index 0000000..c81d978 --- /dev/null +++ b/drivers/Makefile @@ -0,0 +1,5 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +subdir-ccflags-y += -Werror + +obj-y += tegra/hwpm/ diff --git a/drivers/tegra/hwpm/Kconfig b/drivers/tegra/hwpm/Kconfig index 2e5e6da..96f6a42 100644 --- a/drivers/tegra/hwpm/Kconfig +++ b/drivers/tegra/hwpm/Kconfig @@ -1,3 +1,10 @@ +config TEGRA_SOC_HWPM + tristate "Tegra SOC HWPM driver" + default m + help + The SOC HWPM driver enables performance monitoring for various Tegra + IPs. + config TEGRA_T234_HWPM bool "Tegra T23x HWPM driver" depends on TEGRA_SOC_HWPM && ARCH_TEGRA_23x_SOC diff --git a/drivers/tegra/hwpm/Makefile b/drivers/tegra/hwpm/Makefile index 2fea4b5..07c0b68 100644 --- a/drivers/tegra/hwpm/Makefile +++ b/drivers/tegra/hwpm/Makefile @@ -1,13 +1,21 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. # # Tegra SOC HWPM # -# SPDX-License-Identifier: GPL-2.0 GCOV_PROFILE := y -ccflags-y += -I$(srctree.nvidia)/include -ccflags-y += -I$(srctree.nvidia)/drivers/platform/tegra/hwpm/include -ccflags-y += -I$(srctree.nvidia)/drivers/platform/tegra/hwpm +ifeq ($(origin srctree.hwpm), undefined) +srctree.hwpm := $(abspath $(shell dirname $(lastword $(MAKEFILE_LIST))))/../../.. +endif + +CONFIG_TEGRA_SOC_HWPM := y +ccflags-y += -DCONFIG_TEGRA_SOC_HWPM + +CONFIG_TEGRA_T234_HWPM := y +ccflags-y += -DCONFIG_TEGRA_T234_HWPM + +NVHWPM_OBJ = m # For OOT builds, set required config flags ifeq ($(CONFIG_TEGRA_OOT_MODULE),m) @@ -17,26 +25,24 @@ ccflags-y += -DCONFIG_TEGRA_HWPM_OOT CONFIG_TEGRA_FUSE_UPSTREAM := y ccflags-y += -DCONFIG_TEGRA_FUSE_UPSTREAM -CONFIG_TEGRA_T234_HWPM := y -ccflags-y += -DCONFIG_TEGRA_T234_HWPM -NVHWPM_OBJ = m +LINUXINCLUDE += -I$(srctree.hwpm)/include +LINUXINCLUDE += -I$(srctree.hwpm)/drivers/tegra/hwpm/include +LINUXINCLUDE += -I$(srctree.hwpm)/drivers/tegra/hwpm + else -NVHWPM_OBJ = y +ccflags-y += -I$(srctree.nvidia)/include +ccflags-y += -I$(srctree.hwpm)/include +ccflags-y += -I$(srctree.hwpm)/drivers/tegra/hwpm/include +ccflags-y += -I$(srctree.hwpm)/drivers/tegra/hwpm + endif +ifeq ($(NV_BUILD_CONFIGURATION_IS_SAFETY),1) +obj-${NVHWPM_OBJ} += tegra_hwpm_mock.o +else # Add required objects to nvhwpm object variable -# Include common files -include $(srctree.nvidia)/drivers/platform/tegra/hwpm/Makefile.common.sources -nvhwpm-objs += ${nvhwpm-common-objs} - -# Include linux files -include $(srctree.nvidia)/drivers/platform/tegra/hwpm/Makefile.linux.sources -nvhwpm-objs += ${nvhwpm-linux-objs} - -ifeq ($(CONFIG_TEGRA_T234_HWPM),y) -# Include T234 files -include $(srctree.nvidia)/drivers/platform/tegra/hwpm/Makefile.t234.sources -nvhwpm-objs += ${nvhwpm-t234-objs} -endif +include $(srctree.hwpm)/drivers/tegra/hwpm/Makefile.sources obj-${NVHWPM_OBJ} += nvhwpm.o + +endif diff --git a/drivers/tegra/hwpm/Makefile.sources b/drivers/tegra/hwpm/Makefile.sources new file mode 100644 index 0000000..1521f55 --- /dev/null +++ b/drivers/tegra/hwpm/Makefile.sources @@ -0,0 +1,18 @@ +# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. +# +# Tegra SOC HWPM Sources +# + +# Include common files +include $(srctree.hwpm)/drivers/tegra/hwpm/Makefile.common.sources +nvhwpm-objs += ${nvhwpm-common-objs} + +# Include linux files +include $(srctree.hwpm)/drivers/tegra/hwpm/Makefile.linux.sources +nvhwpm-objs += ${nvhwpm-linux-objs} + +ifeq ($(CONFIG_TEGRA_T234_HWPM),y) +# Include T234 files +include $(srctree.hwpm)/drivers/tegra/hwpm/Makefile.t234.sources +nvhwpm-objs += ${nvhwpm-t234-objs} +endif diff --git a/drivers/tegra/hwpm/os/linux/soc_utils.c b/drivers/tegra/hwpm/os/linux/soc_utils.c index abd95d4..e88e3f0 100644 --- a/drivers/tegra/hwpm/os/linux/soc_utils.c +++ b/drivers/tegra/hwpm/os/linux/soc_utils.c @@ -18,7 +18,7 @@ #if CONFIG_ACPI #include #endif -#include +#include #include #include diff --git a/drivers/tegra/hwpm/tegra_hwpm_mock.c b/drivers/tegra/hwpm/tegra_hwpm_mock.c new file mode 100644 index 0000000..0d7009e --- /dev/null +++ b/drivers/tegra/hwpm/tegra_hwpm_mock.c @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2023, NVIDIA CORPORATION. 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, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include + +void tegra_soc_hwpm_ip_register(struct tegra_soc_hwpm_ip_ops *hwpm_ip_ops) +{ + /* Dummy function */ +} +EXPORT_SYMBOL(tegra_soc_hwpm_ip_register); + +void tegra_soc_hwpm_ip_unregister(struct tegra_soc_hwpm_ip_ops *hwpm_ip_ops) +{ + /* Dummy function */ +} +EXPORT_SYMBOL(tegra_soc_hwpm_ip_unregister); + + +/* Dummy implementation for module */ +static int __init tegra_hwpm_init(void) +{ + return 0; +} + +static void __exit tegra_hwpm_exit(void) +{ +} + +#if defined(CONFIG_TEGRA_HWPM_OOT) +module_init(tegra_hwpm_init); +#else +postcore_initcall(tegra_hwpm_init); +#endif +module_exit(tegra_hwpm_exit); + +MODULE_ALIAS(TEGRA_SOC_HWPM_MODULE_NAME); +MODULE_DESCRIPTION("Tegra SOC HWPM MOCK Driver"); +MODULE_LICENSE("GPL v2"); +