Add a bios_output[] to amd_pmf_dev struct and store the latest values for BIOS output policies when applying PMF policies. This enables the AMD PMF util layer to expose these BIOS outputs alongside selected thermal and power metrics to user space via /dev/amdpmf_interface and a new IOCTL, supporting real-time monitoring tools such as SystemDeck.
Unified · Split
| @@ -130,6 +130,7 @@ struct cookie_header { · 129 unmodified lines | ||
| 130 | 130 | #define GET_CMD true |
| 131 | 131 | |
| 132 | 132 | #define METRICS_TABLE_ID 7 |
| 133 | +#define BIOS_OUTPUT_MAX 10 | |
| 133 | 134 | |
| 134 | 135 | typedef void (*apmf_event_handler_t)(acpi_handle handle, u32 event, void *data); |
| 135 | 136 | |
| @@ -442,6 +443,7 @@ struct amd_pmf_dev { · 306 unmodified lines | ||
| 442 | 443 | struct pmf_cbi_ring_buffer cbi_buf; |
| 443 | 444 | struct mutex cbi_mutex; /* Protects ring buffer access */ |
| 444 | 445 | struct mutex metrics_mutex; |
| 446 | + u32 bios_output[BIOS_OUTPUT_MAX]; | |
| 445 | 447 | }; |
| 446 | 448 | |
| 447 | 449 | struct apmf_sps_prop_granular_v2 { |
| @@ -8,7 +8,9 @@ · 7 unmodified lines | ||
| 8 | 8 | * Author: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | +#include <linux/array_size.h> | |
| 11 | 12 | #include <linux/debugfs.h> |
| 13 | +#include <linux/dev_printk.h> | |
| 12 | 14 | #include <linux/tee_drv.h> |
| 13 | 15 | #include <linux/uuid.h> |
| 14 | 16 | #include "pmf.h" |
| @@ -97,11 +99,18 @@ static int amd_pmf_get_bios_output_idx(u32 action_idx) · 82 unmodified lines | ||
| 97 | 99 | |
| 98 | 100 | static void amd_pmf_update_bios_output(struct amd_pmf_dev *pdev, struct ta_pmf_action *action) |
| 99 | 101 | { |
| 100 | − u32 bios_idx; | |
| 102 | + int bios_idx; | |
| 103 | + int ret; | |
| 101 | 104 | |
| 102 | 105 | bios_idx = amd_pmf_get_bios_output_idx(action->action_index); |
| 106 | + if (bios_idx < 0 || bios_idx >= ARRAY_SIZE(pdev->bios_output)) { | |
| 107 | + dev_warn(pdev->dev, "BIOS output index %d out of bounds\n", bios_idx); | |
| 108 | + return; | |
| 109 | + } | |
| 103 | 110 | |
| 104 | − amd_pmf_smartpc_apply_bios_output(pdev, action->value, BIT(bios_idx), bios_idx); | |
| 111 | + ret = amd_pmf_smartpc_apply_bios_output(pdev, action->value, BIT(bios_idx), bios_idx); | |
| 112 | + if (!ret) | |
| 113 | + pdev->bios_output[bios_idx] = action->value; | |
| 105 | 114 | } |
| 106 | 115 | |
| 107 | 116 | static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_result *out) |
| @@ -66,6 +66,7 @@ struct amd_pmf_info { · 65 unmodified lines | ||
| 66 | 66 | |
| 67 | 67 | /* BIOS parameters */ |
| 68 | 68 | __u32 bios_input[AMD_PMF_BIOS_PARAMS_MAX]; |
| 69 | + __u32 bios_output[AMD_PMF_BIOS_PARAMS_MAX]; | |
| 69 | 70 | }; |
| 70 | 71 | |
| 71 | 72 | #endif /* _UAPI_LINUX_AMD_PMF_H */ |