Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86/amd/pmf: Prevent TEE errors after hibernate

After resuming from hibernate, TEE commands can time out and cause PSP
disables. Fix this by reinitializing the Trusted Application (TA) and
cancelling the pb workqueue in the hibernate callbacks to avoid these
errors.

ccp 0000:c4:00.2: tee: command 0x5 timed out, disabling PSP
amd-pmf AMDI0107:00: TEE enact cmd failed. err: ffff000e, ret:0
amd-pmf AMDI0107:00: TEE enact cmd failed. err: ffff000e, ret:0
amd-pmf AMDI0107:00: TEE enact cmd failed. err: ffff000e, ret:0

Fixes: ae82cef7d9c5 ("platform/x86/amd/pmf: Add support for PMF-TA interaction")
Reported-by: Lars Francke <lars.francke@gmail.com>
Closes: https://lore.kernel.org/platform-driver-x86/CAD-Ua_gfJnQSo8ucS_7ZwzuhoBRJ14zXP7s8b-zX3ZcxcyWePw@mail.gmail.com/
Tested-by: Yijun Shen <Yijun.Shen@Dell.com>
Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
[ML: Add more tags]
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
Link: https://patch.msgid.link/20260116041132.153674-2-superm1@kernel.org
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Shyam Sundar S K and committed by
Ilpo Järvinen
48d229c7 51ed3428

+74 -10
+61 -1
drivers/platform/x86/amd/pmf/core.c
··· 315 315 return 0; 316 316 } 317 317 318 + static int amd_pmf_reinit_ta(struct amd_pmf_dev *pdev) 319 + { 320 + bool status; 321 + int ret, i; 322 + 323 + for (i = 0; i < ARRAY_SIZE(amd_pmf_ta_uuid); i++) { 324 + ret = amd_pmf_tee_init(pdev, &amd_pmf_ta_uuid[i]); 325 + if (ret) { 326 + dev_err(pdev->dev, "TEE init failed for UUID[%d] ret: %d\n", i, ret); 327 + return ret; 328 + } 329 + 330 + ret = amd_pmf_start_policy_engine(pdev); 331 + dev_dbg(pdev->dev, "start policy engine ret: %d (UUID idx: %d)\n", ret, i); 332 + status = ret == TA_PMF_TYPE_SUCCESS; 333 + if (status) 334 + break; 335 + amd_pmf_tee_deinit(pdev); 336 + } 337 + 338 + return 0; 339 + } 340 + 341 + static int amd_pmf_restore_handler(struct device *dev) 342 + { 343 + struct amd_pmf_dev *pdev = dev_get_drvdata(dev); 344 + int ret; 345 + 346 + if (pdev->buf) { 347 + ret = amd_pmf_set_dram_addr(pdev, false); 348 + if (ret) 349 + return ret; 350 + } 351 + 352 + if (pdev->smart_pc_enabled) 353 + amd_pmf_reinit_ta(pdev); 354 + 355 + return 0; 356 + } 357 + 358 + static int amd_pmf_freeze_handler(struct device *dev) 359 + { 360 + struct amd_pmf_dev *pdev = dev_get_drvdata(dev); 361 + 362 + if (!pdev->smart_pc_enabled) 363 + return 0; 364 + 365 + cancel_delayed_work_sync(&pdev->pb_work); 366 + /* Clear all TEE resources */ 367 + amd_pmf_tee_deinit(pdev); 368 + pdev->session_id = 0; 369 + 370 + return 0; 371 + } 372 + 318 373 static int amd_pmf_suspend_handler(struct device *dev) 319 374 { 320 375 struct amd_pmf_dev *pdev = dev_get_drvdata(dev); ··· 403 348 return 0; 404 349 } 405 350 406 - static DEFINE_SIMPLE_DEV_PM_OPS(amd_pmf_pm, amd_pmf_suspend_handler, amd_pmf_resume_handler); 351 + static const struct dev_pm_ops amd_pmf_pm = { 352 + .suspend = amd_pmf_suspend_handler, 353 + .resume = amd_pmf_resume_handler, 354 + .freeze = amd_pmf_freeze_handler, 355 + .restore = amd_pmf_restore_handler, 356 + }; 407 357 408 358 static void amd_pmf_init_features(struct amd_pmf_dev *dev) 409 359 {
+10
drivers/platform/x86/amd/pmf/pmf.h
··· 132 132 133 133 typedef void (*apmf_event_handler_t)(acpi_handle handle, u32 event, void *data); 134 134 135 + static const uuid_t amd_pmf_ta_uuid[] __used = { UUID_INIT(0xd9b39bf2, 0x66bd, 0x4154, 0xaf, 0xb8, 136 + 0x8a, 0xcc, 0x2b, 0x2b, 0x60, 0xd6), 137 + UUID_INIT(0x6fd93b77, 0x3fb8, 0x524d, 0xb1, 0x2d, 138 + 0xc5, 0x29, 0xb1, 0x3d, 0x85, 0x43), 139 + }; 140 + 135 141 /* APTS PMF BIOS Interface */ 136 142 struct amd_pmf_apts_output { 137 143 u16 table_version; ··· 921 915 void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); 922 916 void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); 923 917 int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev); 918 + 919 + int amd_pmf_tee_init(struct amd_pmf_dev *dev, const uuid_t *uuid); 920 + void amd_pmf_tee_deinit(struct amd_pmf_dev *dev); 921 + int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev); 924 922 925 923 #endif /* PMF_H */
+3 -9
drivers/platform/x86/amd/pmf/tee-if.c
··· 27 27 MODULE_PARM_DESC(pb_side_load, "Sideload policy binaries debug policy failures"); 28 28 #endif 29 29 30 - static const uuid_t amd_pmf_ta_uuid[] = { UUID_INIT(0xd9b39bf2, 0x66bd, 0x4154, 0xaf, 0xb8, 0x8a, 31 - 0xcc, 0x2b, 0x2b, 0x60, 0xd6), 32 - UUID_INIT(0x6fd93b77, 0x3fb8, 0x524d, 0xb1, 0x2d, 0xc5, 33 - 0x29, 0xb1, 0x3d, 0x85, 0x43), 34 - }; 35 - 36 30 static const char *amd_pmf_uevent_as_str(unsigned int state) 37 31 { 38 32 switch (state) { ··· 318 324 schedule_delayed_work(&dev->pb_work, msecs_to_jiffies(pb_actions_ms)); 319 325 } 320 326 321 - static int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev) 327 + int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev) 322 328 { 323 329 struct cookie_header *header; 324 330 int res; ··· 474 480 return 0; 475 481 } 476 482 477 - static int amd_pmf_tee_init(struct amd_pmf_dev *dev, const uuid_t *uuid) 483 + int amd_pmf_tee_init(struct amd_pmf_dev *dev, const uuid_t *uuid) 478 484 { 479 485 u32 size; 480 486 int ret; ··· 522 528 return ret; 523 529 } 524 530 525 - static void amd_pmf_tee_deinit(struct amd_pmf_dev *dev) 531 + void amd_pmf_tee_deinit(struct amd_pmf_dev *dev) 526 532 { 527 533 if (!dev->tee_ctx) 528 534 return;