diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2024-07-17 17:05:21 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2024-07-17 17:05:21 -0700 |
commit | a5cb6b2bbff9cdd32aab635ad464a1ee299a63bd (patch) | |
tree | 67803af2631c8e015db8f466e906ff04617ec6dd /drivers/platform/x86/amd/pmf/tee-if.c | |
parent | e2f710f97f3544df08ebe608c8157536e0ffb494 (diff) | |
parent | d8b17a364ec48239fccb65efe74bb485e79e6743 (diff) |
Merge tag 'platform-drivers-x86-v6.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
Pull x86 platform driver updates from Ilpo Järvinen:
- amd/pmf: Report system state changes using existing input events
- asus-wmi: Zenbook 2023 camera LED disable support and fix TUF laptop
keyboard RGB LED sysfs interface
- dell-pc: Fan modes / platform profile support
- hp-wmi: Fix platform profile switching on Omen/Victus laptops
- intel/ISST: Use only TPMI interface when TPMI and legacy interfaces
are available
- intel/pmc: LTR restore support to pair with LTR ignore
- intel/tpmi: Performance Limit Reasons (PLR) and APIC <-> Punit CPU
numbering mapping support
- WMI: driver override support and docs improvements
- lenovo-yoga-c630: Support for EC (platform/arm64)
- platform/arm64: Fix build with COMPILE_TEST (broke after addition of
C630)
- tools: Intel Speed Select Turbo Ratio Limit fix
- Miscellaneous cleanups / refactoring / improvements
* tag 'platform-drivers-x86-v6.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: (65 commits)
platform/x86: asus-wmi: fix TUF laptop RGB variant
platform/x86/intel/tpmi/plr: Fix output in plr_print_bits()
Docs/admin-guide: Remove pmf leftover reference from the index
platform/x86: ideapad-laptop: use cleanup.h
platform/x86: hp-wmi: Fix implementation of the platform_profile_omen_get function
platform: arm64: EC_LENOVO_YOGA_C630 should depend on ARCH_QCOM
platform: arm64: EC_ACER_ASPIRE1 should depend on ARCH_QCOM
platform/x86/amd/pmf: Remove update system state document
platform/x86/amd/pmf: Use existing input event codes to update system states
platform/x86: hp-wmi: Fix platform profile option switch bug on Omen and Victus laptops
platform/x86:intel/pmc: Add support to undo ltr_ignore
platform/x86:intel/pmc: Use the Elvis operator
platform/x86:intel/pmc: Use DEFINE_SHOW_STORE_ATTRIBUTE macro
platform/x86:intel/pmc: Remove unneeded min_t check
platform/x86:intel/pmc: Add support to show ltr_ignore value
platform/x86:intel/pmc: Move pmc assignment closer to first usage
platform/x86:intel/pmc: Convert index variables to be unsigned
platform/x86:intel/pmc: Simplify mutex usage with cleanup helpers
platform/x86:intel/pmc: Use the return value of pmc_core_send_msg
tools/power/x86/intel-speed-select: v1.20 release
...
Diffstat (limited to 'drivers/platform/x86/amd/pmf/tee-if.c')
-rw-r--r-- | drivers/platform/x86/amd/pmf/tee-if.c | 73 |
1 files changed, 53 insertions, 20 deletions
diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c index b438de4d6bfc..e246367aacee 100644 --- a/drivers/platform/x86/amd/pmf/tee-if.c +++ b/drivers/platform/x86/amd/pmf/tee-if.c @@ -62,18 +62,12 @@ static void amd_pmf_prepare_args(struct amd_pmf_dev *dev, int cmd, param[0].u.memref.shm_offs = 0; } -static int amd_pmf_update_uevents(struct amd_pmf_dev *dev, u16 event) +static void amd_pmf_update_uevents(struct amd_pmf_dev *dev, u16 event) { - char *envp[2] = {}; - - envp[0] = kasprintf(GFP_KERNEL, "EVENT_ID=%d", event); - if (!envp[0]) - return -EINVAL; - - kobject_uevent_env(&dev->dev->kobj, KOBJ_CHANGE, envp); - - kfree(envp[0]); - return 0; + input_report_key(dev->pmf_idev, event, 1); /* key press */ + input_sync(dev->pmf_idev); + input_report_key(dev->pmf_idev, event, 0); /* key release */ + input_sync(dev->pmf_idev); } static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_result *out) @@ -149,7 +143,20 @@ static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_ break; case PMF_POLICY_SYSTEM_STATE: - amd_pmf_update_uevents(dev, val); + switch (val) { + case 0: + amd_pmf_update_uevents(dev, KEY_SLEEP); + break; + case 1: + amd_pmf_update_uevents(dev, KEY_SUSPEND); + break; + case 2: + amd_pmf_update_uevents(dev, KEY_SCREENLOCK); + break; + default: + dev_err(dev->dev, "Invalid PMF policy system state: %d\n", val); + } + dev_dbg(dev->dev, "update SYSTEM_STATE: %s\n", amd_pmf_uevent_as_str(val)); break; @@ -301,14 +308,9 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf, return -EINVAL; /* re-alloc to the new buffer length of the policy binary */ - new_policy_buf = kzalloc(length, GFP_KERNEL); - if (!new_policy_buf) - return -ENOMEM; - - if (copy_from_user(new_policy_buf, buf, length)) { - kfree(new_policy_buf); - return -EFAULT; - } + new_policy_buf = memdup_user(buf, length); + if (IS_ERR(new_policy_buf)) + return PTR_ERR(new_policy_buf); kfree(dev->policy_buf); dev->policy_buf = new_policy_buf; @@ -368,6 +370,30 @@ static int amd_pmf_ta_open_session(struct tee_context *ctx, u32 *id) return rc; } +static int amd_pmf_register_input_device(struct amd_pmf_dev *dev) +{ + int err; + + dev->pmf_idev = devm_input_allocate_device(dev->dev); + if (!dev->pmf_idev) + return -ENOMEM; + + dev->pmf_idev->name = "PMF-TA output events"; + dev->pmf_idev->phys = "amd-pmf/input0"; + + input_set_capability(dev->pmf_idev, EV_KEY, KEY_SLEEP); + input_set_capability(dev->pmf_idev, EV_KEY, KEY_SCREENLOCK); + input_set_capability(dev->pmf_idev, EV_KEY, KEY_SUSPEND); + + err = input_register_device(dev->pmf_idev); + if (err) { + dev_err(dev->dev, "Failed to register input device: %d\n", err); + return err; + } + + return 0; +} + static int amd_pmf_tee_init(struct amd_pmf_dev *dev) { u32 size; @@ -475,6 +501,10 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev) if (pb_side_load) amd_pmf_open_pb(dev, dev->dbgfs_dir); + ret = amd_pmf_register_input_device(dev); + if (ret) + goto error; + return 0; error: @@ -485,6 +515,9 @@ error: void amd_pmf_deinit_smart_pc(struct amd_pmf_dev *dev) { + if (dev->pmf_idev) + input_unregister_device(dev->pmf_idev); + if (pb_side_load && dev->esbin) amd_pmf_remove_pb(dev); |