[PATCH 2/5] platform/x86/amd/pmf: Inline simple helper functions of Core Layer
From: Rong Zhang
Date: Tue Sep 01 2026 - 11:21:54 EST
The Core Layer has simple and dumb helper functions defined as global
symbols, which are heavily used by other layers and become symbols
against linkage. This bloats the size of the module.
Convert them into static inline functions to get rid of the overhead of
function outlining and linkage, and shrink the module
(!CONFIG_AMD_PMF_DEBUG && CONFIG_AMD_PMF_UTIL_SUPPORT) size by 432 Bytes
(GCC 16 -O2):
text data bss total filename (before)
26781 31636 2768 61185 amd-pmf.ko
text data bss total filename (after)
26533 31452 2768 60753 amd-pmf.ko
Signed-off-by: Rong Zhang <i@xxxxxxxx>
---
drivers/platform/x86/amd/pmf/acpi.c | 11 -----------
drivers/platform/x86/amd/pmf/core.c | 22 ---------------------
drivers/platform/x86/amd/pmf/pmf.h | 39 +++++++++++++++++++++++++++++++++----
3 files changed, 35 insertions(+), 37 deletions(-)
diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index 3d94b03cf794..6a2c11e75eea 100644
--- a/drivers/platform/x86/amd/pmf/acpi.c
+++ b/drivers/platform/x86/amd/pmf/acpi.c
@@ -158,17 +158,6 @@ static int apts_if_call_store_buffer(struct amd_pmf_dev *pdev,
return err;
}
-int is_apmf_func_supported(struct amd_pmf_dev *pdev, unsigned long index)
-{
- /* If bit-n is set, that indicates function n+1 is supported */
- return !!(pdev->supported_func & BIT(index - 1));
-}
-
-int is_apmf_bios_input_notifications_supported(struct amd_pmf_dev *pdev)
-{
- return !!(pdev->notifications & CUSTOM_BIOS_INPUT_BITS);
-}
-
int apts_get_static_slider_granular_v2(struct amd_pmf_dev *pdev,
struct amd_pmf_apts_granular_output *data, u32 apts_idx)
{
diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c
index b4eae65e675b..ec2ce7fa3dee 100644
--- a/drivers/platform/x86/amd/pmf/core.c
+++ b/drivers/platform/x86/amd/pmf/core.c
@@ -138,14 +138,6 @@ static void amd_pmf_dbgfs_register(struct amd_pmf_dev *dev)
¤t_power_limits_fops);
}
-int amd_pmf_get_power_source(void)
-{
- if (power_supply_is_system_supplied() > 0)
- return POWER_SOURCE_AC;
- else
- return POWER_SOURCE_DC;
-}
-
static inline u32 amd_pmf_reg_read(struct amd_pmf_dev *dev, int reg_offset)
{
return ioread32(dev->regbase + reg_offset);
@@ -176,20 +168,6 @@ static void __maybe_unused amd_pmf_dump_registers(struct amd_pmf_dev *dev)
dev_dbg(dev->dev, "AMD_PMF_REGISTER_MESSAGE:%x\n", value);
}
-/**
- * fixp_q88_fromint: Convert integer to Q8.8
- * @val: input value
- *
- * Converts an integer into binary fixed point format where 8 bits
- * are used for integer and 8 bits are used for the decimal.
- *
- * Return: unsigned integer converted to Q8.8 format
- */
-u32 fixp_q88_fromint(u32 val)
-{
- return val << 8;
-}
-
int amd_pmf_send_cmd(struct amd_pmf_dev *dev, u8 message, bool get, u32 arg, u32 *data)
{
int rc;
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 4da2ef1abb50..024f20306e11 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -13,11 +13,13 @@
#include <linux/acpi.h>
#include <linux/amd-pmf-io.h>
+#include <linux/bits.h>
#include <linux/circ_buf.h>
#include <linux/compiler_attributes.h>
#include <linux/compiler_types.h>
#include <linux/input.h>
#include <linux/mutex_types.h>
+#include <linux/power_supply.h>
#include <linux/platform_device.h>
#include <linux/platform_profile.h>
#include <linux/types.h>
@@ -1073,18 +1075,47 @@ struct ta_pmf_shared_memory {
/* Core Layer */
int apmf_acpi_init(struct amd_pmf_dev *pmf_dev);
void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev);
-int is_apmf_func_supported(struct amd_pmf_dev *pdev, unsigned long index);
int amd_pmf_send_cmd(struct amd_pmf_dev *dev, u8 message, bool get, u32 arg, u32 *data);
int amd_pmf_init_metrics_table(struct amd_pmf_dev *dev);
-int amd_pmf_get_power_source(void);
int apmf_install_handler(struct amd_pmf_dev *pmf_dev);
int apmf_os_power_slider_update(struct amd_pmf_dev *dev, u8 flag);
int amd_pmf_set_dram_addr(struct amd_pmf_dev *dev, bool alloc_buffer);
int amd_pmf_notify_sbios_heartbeat_event_v2(struct amd_pmf_dev *dev, u8 flag);
-u32 fixp_q88_fromint(u32 val);
-int is_apmf_bios_input_notifications_supported(struct amd_pmf_dev *pdev);
void amd_pmf_set_device(struct device *p_device);
+static inline int is_apmf_func_supported(struct amd_pmf_dev *pdev, unsigned long index)
+{
+ /* If bit-n is set, that indicates function n+1 is supported */
+ return !!(pdev->supported_func & BIT(index - 1));
+}
+
+static inline int is_apmf_bios_input_notifications_supported(struct amd_pmf_dev *pdev)
+{
+ return !!(pdev->notifications & CUSTOM_BIOS_INPUT_BITS);
+}
+
+static inline int amd_pmf_get_power_source(void)
+{
+ if (power_supply_is_system_supplied() > 0)
+ return POWER_SOURCE_AC;
+ else
+ return POWER_SOURCE_DC;
+}
+
+/**
+ * fixp_q88_fromint: Convert integer to Q8.8
+ * @val: input value
+ *
+ * Converts an integer into binary fixed point format where 8 bits
+ * are used for integer and 8 bits are used for the decimal.
+ *
+ * Return: unsigned integer converted to Q8.8 format
+ */
+static inline u32 fixp_q88_fromint(u32 val)
+{
+ return val << 8;
+}
+
/* Metrics layer */
int amd_pmf_get_tbl_dram_addr(struct amd_pmf_dev *dev);
--
2.55.0