Skip to content

Commit 6262938

Browse files
Shyam Sundar S Kij-intel
authored andcommitted
platform/x86/amd/pmf: Add support to notify sbios heart beat event
Add support for newer revision of the heart beat notify events. This event is used to notify to the OEM BIOS on driver load/unload/suspend/resume scenarios. If OEM BIOS does not receive the heart beat event from PMF driver, OEM BIOS shall conclude that PMF driver is no more active and BIOS will update to the legacy system power thermals. Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]> Co-developed-by: Patil Rajesh Reddy <[email protected]> Signed-off-by: Patil Rajesh Reddy <[email protected]> Signed-off-by: Shyam Sundar S K <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 5fdc8b8 commit 6262938

File tree

3 files changed

+66
-2
lines changed

3 files changed

+66
-2
lines changed

drivers/platform/x86/amd/pmf/acpi.c

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,43 @@ static void apmf_sbios_heartbeat_notify(struct work_struct *work)
140140
kfree(info);
141141
}
142142

143+
int amd_pmf_notify_sbios_heartbeat_event_v2(struct amd_pmf_dev *dev, u8 flag)
144+
{
145+
struct sbios_hb_event_v2 args = { };
146+
struct acpi_buffer params;
147+
union acpi_object *info;
148+
149+
args.size = sizeof(args);
150+
151+
switch (flag) {
152+
case ON_LOAD:
153+
args.load = 1;
154+
break;
155+
case ON_UNLOAD:
156+
args.unload = 1;
157+
break;
158+
case ON_SUSPEND:
159+
args.suspend = 1;
160+
break;
161+
case ON_RESUME:
162+
args.resume = 1;
163+
break;
164+
default:
165+
dev_dbg(dev->dev, "Failed to send v2 heartbeat event, flag:0x%x\n", flag);
166+
return -EINVAL;
167+
}
168+
169+
params.length = sizeof(args);
170+
params.pointer = &args;
171+
172+
info = apmf_if_call(dev, APMF_FUNC_SBIOS_HEARTBEAT_V2, &params);
173+
if (!info)
174+
return -EIO;
175+
176+
kfree(info);
177+
return 0;
178+
}
179+
143180
int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx)
144181
{
145182
union acpi_object *info;
@@ -327,7 +364,7 @@ void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev)
327364
{
328365
acpi_handle ahandle = ACPI_HANDLE(pmf_dev->dev);
329366

330-
if (pmf_dev->hb_interval)
367+
if (pmf_dev->hb_interval && pmf_dev->pmf_if_version == PMF_IF_V1)
331368
cancel_delayed_work_sync(&pmf_dev->heart_beat);
332369

333370
if (is_apmf_func_supported(pmf_dev, APMF_FUNC_AUTO_MODE) &&
@@ -351,7 +388,7 @@ int apmf_acpi_init(struct amd_pmf_dev *pmf_dev)
351388
goto out;
352389
}
353390

354-
if (pmf_dev->hb_interval) {
391+
if (pmf_dev->hb_interval && pmf_dev->pmf_if_version == PMF_IF_V1) {
355392
/* send heartbeats only if the interval is not zero */
356393
INIT_DELAYED_WORK(&pmf_dev->heart_beat, apmf_sbios_heartbeat_notify);
357394
schedule_delayed_work(&pmf_dev->heart_beat, 0);

drivers/platform/x86/amd/pmf/core.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ static int amd_pmf_suspend_handler(struct device *dev)
299299

300300
kfree(pdev->buf);
301301

302+
if (is_apmf_func_supported(pdev, APMF_FUNC_SBIOS_HEARTBEAT_V2))
303+
amd_pmf_notify_sbios_heartbeat_event_v2(pdev, ON_SUSPEND);
304+
302305
return 0;
303306
}
304307

@@ -313,6 +316,9 @@ static int amd_pmf_resume_handler(struct device *dev)
313316
return ret;
314317
}
315318

319+
if (is_apmf_func_supported(pdev, APMF_FUNC_SBIOS_HEARTBEAT_V2))
320+
amd_pmf_notify_sbios_heartbeat_event_v2(pdev, ON_RESUME);
321+
316322
return 0;
317323
}
318324

@@ -435,6 +441,8 @@ static int amd_pmf_probe(struct platform_device *pdev)
435441
amd_pmf_dbgfs_register(dev);
436442
amd_pmf_init_features(dev);
437443
apmf_install_handler(dev);
444+
if (is_apmf_func_supported(dev, APMF_FUNC_SBIOS_HEARTBEAT_V2))
445+
amd_pmf_notify_sbios_heartbeat_event_v2(dev, ON_LOAD);
438446

439447
dev_info(dev->dev, "registered PMF device successfully\n");
440448

@@ -446,6 +454,8 @@ static void amd_pmf_remove(struct platform_device *pdev)
446454
struct amd_pmf_dev *dev = platform_get_drvdata(pdev);
447455

448456
amd_pmf_deinit_features(dev);
457+
if (is_apmf_func_supported(dev, APMF_FUNC_SBIOS_HEARTBEAT_V2))
458+
amd_pmf_notify_sbios_heartbeat_event_v2(dev, ON_UNLOAD);
449459
apmf_acpi_deinit(dev);
450460
amd_pmf_dbgfs_unregister(dev);
451461
mutex_destroy(&dev->lock);

drivers/platform/x86/amd/pmf/pmf.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct cookie_header {
3434
#define APMF_FUNC_STATIC_SLIDER_GRANULAR 9
3535
#define APMF_FUNC_DYN_SLIDER_AC 11
3636
#define APMF_FUNC_DYN_SLIDER_DC 12
37+
#define APMF_FUNC_SBIOS_HEARTBEAT_V2 16
3738

3839
/* Message Definitions */
3940
#define SET_SPL 0x03 /* SPL: Sustained Power Limit */
@@ -89,6 +90,21 @@ struct cookie_header {
8990

9091
#define PMF_IF_V1 1
9192

93+
struct sbios_hb_event_v2 {
94+
u16 size;
95+
u8 load;
96+
u8 unload;
97+
u8 suspend;
98+
u8 resume;
99+
} __packed;
100+
101+
enum sbios_hb_v2 {
102+
ON_LOAD,
103+
ON_UNLOAD,
104+
ON_SUSPEND,
105+
ON_RESUME,
106+
};
107+
92108
/* AMD PMF BIOS interfaces */
93109
struct apmf_verify_interface {
94110
u16 size;
@@ -609,6 +625,7 @@ int amd_pmf_get_power_source(void);
609625
int apmf_install_handler(struct amd_pmf_dev *pmf_dev);
610626
int apmf_os_power_slider_update(struct amd_pmf_dev *dev, u8 flag);
611627
int amd_pmf_set_dram_addr(struct amd_pmf_dev *dev, bool alloc_buffer);
628+
int amd_pmf_notify_sbios_heartbeat_event_v2(struct amd_pmf_dev *dev, u8 flag);
612629

613630
/* SPS Layer */
614631
int amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf);

0 commit comments

Comments
 (0)