[PATCH 5/5] platform/x86/amd/pmf: Inline wrappers of ap{mf,ts}_if_call_store_buffer()
From: Rong Zhang
Date: Tue Sep 01 2026 - 11:23:02 EST
There are several simple and dumb wrappers of
ap{mf,ts}_if_call_store_buffer() defined as global symbols, which are
heavily used by multiple layers and become symbols against linkage. This
bloats the size of the module.
Since is_apmf_func_supported() has been converted, convert the mentioned
wrappers 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 515 Bytes
(GCC 16 -O2):
text data bss total filename (before)
26261 31264 2768 60293 amd-pmf.ko
text data bss total filename (after)
26046 30964 2768 59778 amd-pmf.ko
Signed-off-by: Rong Zhang <i@xxxxxxxx>
---
drivers/platform/x86/amd/pmf/acpi.c | 65 +----------------------------
drivers/platform/x86/amd/pmf/pmf.h | 83 +++++++++++++++++++++++++++++++------
2 files changed, 73 insertions(+), 75 deletions(-)
diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index 6a2c11e75eea..4392bf0bc0bf 100644
--- a/drivers/platform/x86/amd/pmf/acpi.c
+++ b/drivers/platform/x86/amd/pmf/acpi.c
@@ -50,7 +50,7 @@ static union acpi_object *apmf_if_call(struct amd_pmf_dev *pdev, int fn, struct
return buffer.pointer;
}
-static int apmf_if_call_store_buffer(struct amd_pmf_dev *pdev, int fn, void *dest, size_t out_sz)
+int apmf_if_call_store_buffer(struct amd_pmf_dev *pdev, int fn, void *dest, size_t out_sz)
{
union acpi_object *info;
size_t size;
@@ -121,8 +121,7 @@ static union acpi_object *apts_if_call(struct amd_pmf_dev *pdev, u32 state_index
return buffer.pointer;
}
-static int apts_if_call_store_buffer(struct amd_pmf_dev *pdev,
- u32 index, void *data, size_t out_sz)
+int apts_if_call_store_buffer(struct amd_pmf_dev *pdev, u32 index, void *data, size_t out_sz)
{
union acpi_object *info;
size_t size;
@@ -158,35 +157,6 @@ static int apts_if_call_store_buffer(struct amd_pmf_dev *pdev,
return err;
}
-int apts_get_static_slider_granular_v2(struct amd_pmf_dev *pdev,
- struct amd_pmf_apts_granular_output *data, u32 apts_idx)
-{
- if (!is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
- return -EINVAL;
-
- return apts_if_call_store_buffer(pdev, apts_idx, data, sizeof(*data));
-}
-
-int apmf_get_static_slider_granular_v2(struct amd_pmf_dev *pdev,
- struct apmf_static_slider_granular_output_v2 *data)
-{
- if (!is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
- return -EINVAL;
-
- return apmf_if_call_store_buffer(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR,
- data, sizeof(*data));
-}
-
-int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev,
- struct apmf_static_slider_granular_output *data)
-{
- if (!is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
- return -EINVAL;
-
- return apmf_if_call_store_buffer(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR,
- data, sizeof(*data));
-}
-
int apmf_os_power_slider_update(struct amd_pmf_dev *pdev, u8 event)
{
struct os_power_slider args;
@@ -302,27 +272,6 @@ static int apmf_notify_smart_pc_update(struct amd_pmf_dev *pdev, u32 val, u32 pr
return 0;
}
-int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_auto_mode *data)
-{
- return apmf_if_call_store_buffer(pdev, APMF_FUNC_AUTO_MODE, data, sizeof(*data));
-}
-
-int apmf_get_sbios_requests_v2(struct amd_pmf_dev *pdev, struct apmf_sbios_req_v2 *req)
-{
- return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS, req, sizeof(*req));
-}
-
-int apmf_get_sbios_requests_v1(struct amd_pmf_dev *pdev, struct apmf_sbios_req_v1 *req)
-{
- return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS, req, sizeof(*req));
-}
-
-int apmf_get_sbios_requests(struct amd_pmf_dev *pdev, struct apmf_sbios_req *req)
-{
- return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS,
- req, sizeof(*req));
-}
-
/* Store custom BIOS inputs data in ring buffer */
static void amd_pmf_custom_bios_inputs_rb(struct amd_pmf_dev *pmf_dev)
{
@@ -484,16 +433,6 @@ static int apmf_get_system_params(struct amd_pmf_dev *dev)
return 0;
}
-int apmf_get_dyn_slider_def_ac(struct amd_pmf_dev *pdev, struct apmf_dyn_slider_output *data)
-{
- return apmf_if_call_store_buffer(pdev, APMF_FUNC_DYN_SLIDER_AC, data, sizeof(*data));
-}
-
-int apmf_get_dyn_slider_def_dc(struct amd_pmf_dev *pdev, struct apmf_dyn_slider_output *data)
-{
- return apmf_if_call_store_buffer(pdev, APMF_FUNC_DYN_SLIDER_DC, data, sizeof(*data));
-}
-
static apmf_event_handler_t apmf_event_handlers[] = {
[PMF_IF_V1] = apmf_event_handler_v1,
[PMF_IF_V2] = apmf_event_handler_v2,
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 6d9963677a46..9f64ab833c08 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -17,6 +17,7 @@
#include <linux/circ_buf.h>
#include <linux/compiler_attributes.h>
#include <linux/compiler_types.h>
+#include <linux/errno.h>
#include <linux/input.h>
#include <linux/mutex_types.h>
#include <linux/power_supply.h>
@@ -1075,6 +1076,8 @@ 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 apmf_if_call_store_buffer(struct amd_pmf_dev *pdev, int fn, void *dest, size_t out_sz);
+int apts_if_call_store_buffer(struct amd_pmf_dev *pdev, u32 index, void *data, size_t out_sz);
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 apmf_install_handler(struct amd_pmf_dev *pmf_dev);
@@ -1124,17 +1127,43 @@ int amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf);
void amd_pmf_update_slider(struct amd_pmf_dev *dev, bool op, int idx,
struct amd_pmf_static_slider_granular *table);
int amd_pmf_init_sps(struct amd_pmf_dev *dev);
-int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev,
- struct apmf_static_slider_granular_output *output);
int amd_pmf_power_slider_update_event(struct amd_pmf_dev *dev);
const char *amd_pmf_source_as_str(unsigned int state);
int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx);
int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf);
-int apmf_get_static_slider_granular_v2(struct amd_pmf_dev *dev,
- struct apmf_static_slider_granular_output_v2 *data);
-int apts_get_static_slider_granular_v2(struct amd_pmf_dev *pdev,
- struct amd_pmf_apts_granular_output *data, u32 apts_idx);
+
+static inline int
+apts_get_static_slider_granular_v2(struct amd_pmf_dev *pdev,
+ struct amd_pmf_apts_granular_output *data, u32 apts_idx)
+{
+ if (!is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
+ return -EINVAL;
+
+ return apts_if_call_store_buffer(pdev, apts_idx, data, sizeof(*data));
+}
+
+static inline int
+apmf_get_static_slider_granular_v2(struct amd_pmf_dev *pdev,
+ struct apmf_static_slider_granular_output_v2 *data)
+{
+ if (!is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
+ return -EINVAL;
+
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR,
+ data, sizeof(*data));
+}
+
+static inline int
+apmf_get_static_slider_granular(struct amd_pmf_dev *pdev,
+ struct apmf_static_slider_granular_output *data)
+{
+ if (!is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
+ return -EINVAL;
+
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR,
+ data, sizeof(*data));
+}
static inline bool is_pprof_balanced(struct amd_pmf_dev *pmf)
{
@@ -1142,26 +1171,56 @@ static inline bool is_pprof_balanced(struct amd_pmf_dev *pmf)
}
/* Auto Mode Layer */
-int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_auto_mode *data);
void amd_pmf_init_auto_mode(struct amd_pmf_dev *dev);
void amd_pmf_deinit_auto_mode(struct amd_pmf_dev *dev);
void amd_pmf_trans_automode(struct amd_pmf_dev *dev, int socket_power, ktime_t time_elapsed_ms);
-int apmf_get_sbios_requests(struct amd_pmf_dev *pdev, struct apmf_sbios_req *req);
-int apmf_get_sbios_requests_v1(struct amd_pmf_dev *pdev, struct apmf_sbios_req_v1 *req);
-int apmf_get_sbios_requests_v2(struct amd_pmf_dev *pdev, struct apmf_sbios_req_v2 *req);
void amd_pmf_update_2_cql(struct amd_pmf_dev *dev, bool is_cql_event);
int amd_pmf_reset_amt(struct amd_pmf_dev *dev);
void amd_pmf_handle_amt(struct amd_pmf_dev *dev);
+static inline int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_auto_mode *data)
+{
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_AUTO_MODE, data, sizeof(*data));
+}
+
+static inline int apmf_get_sbios_requests_v2(struct amd_pmf_dev *pdev,
+ struct apmf_sbios_req_v2 *req)
+{
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS, req, sizeof(*req));
+}
+
+static inline int apmf_get_sbios_requests_v1(struct amd_pmf_dev *pdev,
+ struct apmf_sbios_req_v1 *req)
+{
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS, req, sizeof(*req));
+}
+
+static inline int apmf_get_sbios_requests(struct amd_pmf_dev *pdev,
+ struct apmf_sbios_req *req)
+{
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS,
+ req, sizeof(*req));
+}
+
/* CnQF Layer */
-int apmf_get_dyn_slider_def_ac(struct amd_pmf_dev *pdev, struct apmf_dyn_slider_output *data);
-int apmf_get_dyn_slider_def_dc(struct amd_pmf_dev *pdev, struct apmf_dyn_slider_output *data);
int amd_pmf_init_cnqf(struct amd_pmf_dev *dev);
void amd_pmf_deinit_cnqf(struct amd_pmf_dev *dev);
int amd_pmf_trans_cnqf(struct amd_pmf_dev *dev, int socket_power, ktime_t time_lapsed_ms);
extern const struct attribute_group cnqf_feature_attribute_group;
+static inline int apmf_get_dyn_slider_def_ac(struct amd_pmf_dev *pdev,
+ struct apmf_dyn_slider_output *data)
+{
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_DYN_SLIDER_AC, data, sizeof(*data));
+}
+
+static inline int apmf_get_dyn_slider_def_dc(struct amd_pmf_dev *pdev,
+ struct apmf_dyn_slider_output *data)
+{
+ return apmf_if_call_store_buffer(pdev, APMF_FUNC_DYN_SLIDER_DC, data, sizeof(*data));
+}
+
/* Smart PC builder Layer */
int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev);
void amd_pmf_deinit_smart_pc(struct amd_pmf_dev *dev);
--
2.55.0