linux-2.6-block.git
4 months agoplatform/x86: thinkpad_acpi: Change hotkey_reserved_mask initialization
Hans de Goede [Wed, 24 Apr 2024 12:28:26 +0000 (14:28 +0200)]
platform/x86: thinkpad_acpi: Change hotkey_reserved_mask initialization

Change the hotkey_reserved_mask initialization to hardcode the list
of reserved keys. There are only a few reserved keys and the code to
iterate over the keymap will be removed when moving to sparse-keymaps.

Note only the 32 original hotkeys are affected by the hotkey_*_mask values:

if (i < sizeof(hotkey_reserved_mask)*8)
hotkey_reserved_mask |= 1 << i;

The (i < sizeof(hotkey_reserved_mask)*8) condition translates to (i < 32)
so this code only ever set bits in hotkey_reserved_mask for the 32 original
hotkeys. Therefor this patch does not set any bits in hotkey_reserved_mask
for the KEY_RESERVED mappings for the adaptive keyboard scancodes.

Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240424122834.19801-17-hdegoede@redhat.com
4 months agoplatform/x86: thinkpad_acpi: Do not send ACPI netlink events for unknown hotkeys
Hans de Goede [Wed, 24 Apr 2024 12:28:25 +0000 (14:28 +0200)]
platform/x86: thinkpad_acpi: Do not send ACPI netlink events for unknown hotkeys

Do not send ACPI netlink events for unknown hotkeys, to avoid userspace
starting to rely on them. Instead these should be added to the keymap to
send evdev events.

This should not cause a behavior change for existing laptop models since
all currently known 0x1xxx events have a mapping.

In hindsight the ACPI netlink events should have been suppressed for
the adaptive keyboard and extended hotkeys events too. But the kernel has
been sending ACPI netlink events for those for a long time now, so we
cannot just stop sending them without potentially causing issues for
existing users who may depend on these.

Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240424122834.19801-16-hdegoede@redhat.com
4 months agoplatform/x86: thinkpad_acpi: Move tpacpi_driver_event() call to tpacpi_input_send_key()
Hans de Goede [Wed, 24 Apr 2024 12:28:24 +0000 (14:28 +0200)]
platform/x86: thinkpad_acpi: Move tpacpi_driver_event() call to tpacpi_input_send_key()

All callers of tpacpi_input_send_key() first call tpacpi_driver_event(),
move the tpacpi_driver_event() inside tpacpi_input_send_key() to avoid
code duplication.

For the original hotkey codes 0x1001 - 0x1020 tpacpi_driver_event() never
returns true. So the added "return true;" inside tpacpi_input_send_key()
never happens when called from tpacpi_hotkey_send_key() so behavior does
not change.

Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240424122834.19801-15-hdegoede@redhat.com
4 months agoplatform/x86: thinkpad_acpi: Move hkey > scancode mapping to tpacpi_input_send_key()
Hans de Goede [Wed, 24 Apr 2024 12:28:23 +0000 (14:28 +0200)]
platform/x86: thinkpad_acpi: Move hkey > scancode mapping to tpacpi_input_send_key()

Move the mapping of hkey events to scancodes to tpacpi_input_send_key(),
this results in a nice cleanup and prepares things for adding sparse-keymap
support.

Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240424122834.19801-14-hdegoede@redhat.com
4 months agoplatform/x86: thinkpad_acpi: Drop tpacpi_input_send_key_masked() and hotkey_driver_ev...
Hans de Goede [Wed, 24 Apr 2024 12:28:22 +0000 (14:28 +0200)]
platform/x86: thinkpad_acpi: Drop tpacpi_input_send_key_masked() and hotkey_driver_event()

Both are only 1 / 2 lines and both only have 1 caller fold the contents
into tpacpi_hotkey_send_key() which is their single caller.

Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240424122834.19801-13-hdegoede@redhat.com
4 months agoplatform/x86: thinkpad_acpi: Always call tpacpi_driver_event() for hotkeys
Hans de Goede [Wed, 24 Apr 2024 12:28:21 +0000 (14:28 +0200)]
platform/x86: thinkpad_acpi: Always call tpacpi_driver_event() for hotkeys

Call tpacpi_driver_event() at the top of hotkey_notify_hotkey() for all
(orig / adaptive / extended) hotkey types, rather then having the orig
code path call tpacpi_input_send_key_masked() which calls it through
hotkey_driver_event() and having the adaptive / extended helpers call
it separately.

Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240424122834.19801-12-hdegoede@redhat.com
4 months agoplatform/x86: thinkpad_acpi: Move hotkey_user_mask check to tpacpi_input_send_key()
Hans de Goede [Wed, 24 Apr 2024 12:28:20 +0000 (14:28 +0200)]
platform/x86: thinkpad_acpi: Move hotkey_user_mask check to tpacpi_input_send_key()

Move hotkey_user_mask check to tpacpi_input_send_key(), this is
a preparation patch for further refactoring.

Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240424122834.19801-11-hdegoede@redhat.com
4 months agoplatform/x86: thinkpad_acpi: Move special original hotkeys handling out of switch...
Hans de Goede [Wed, 24 Apr 2024 12:28:19 +0000 (14:28 +0200)]
platform/x86: thinkpad_acpi: Move special original hotkeys handling out of switch-case

Move the special handling (send_acpi_ev = false, hotkey_source_mask check)
for original hotkeys out of the switch-case in hotkey_notify_hotkey().
This is a preparation patch for further refactoring.

Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240424122834.19801-10-hdegoede@redhat.com
4 months agoplatform/x86: thinkpad_acpi: Move adaptive kbd event handling to tpacpi_driver_event()
Hans de Goede [Wed, 24 Apr 2024 12:28:18 +0000 (14:28 +0200)]
platform/x86: thinkpad_acpi: Move adaptive kbd event handling to tpacpi_driver_event()

Factor out the adaptive kbd non hotkey event handling into
adaptive_keyboard_change_row() and adaptive_keyboard_s_quickview_row()
helpers and move the handling of TP_HKEY_EV_DFR_CHANGE_ROW and
TP_HKEY_EV_DFR_S_QUICKVIEW_ROW to tpacpi_driver_event().

This groups all the handling of hotkey events which do not emit
a key press event together in tpacpi_driver_event().

This also drops the returning of false as known-event value when
adaptive_keyboard_get_mode() / adaptive_keyboard_set_mode() fail.
These functions already log an error on failure, returning false just
leads to an extra messgae being logged about the hkey event being
unknown, which is wrong as the event is not unknown.

Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240424122834.19801-9-hdegoede@redhat.com
4 months agoplatform/x86: thinkpad_acpi: Make tpacpi_driver_event() return if it handled the...
Hans de Goede [Wed, 24 Apr 2024 12:28:17 +0000 (14:28 +0200)]
platform/x86: thinkpad_acpi: Make tpacpi_driver_event() return if it handled the event

tpacpi_driver_event() already only responds to hkey events which it knows
about. Make it return a bool and return true when it has handled the event.

This avoids the need to list TP_HKEY_EV_foo values to which it responds
both in its caller and in the function itself.

Instead callers can now call it unconditionally and check the return value.

Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240424122834.19801-8-hdegoede@redhat.com
4 months agoplatform/x86: thinkpad_acpi: Do hkey to scancode translation later
Hans de Goede [Wed, 24 Apr 2024 12:28:16 +0000 (14:28 +0200)]
platform/x86: thinkpad_acpi: Do hkey to scancode translation later

Modify hotkey_notify_hotkey() and it helpers to mostly directly operate
on hkey codes (TP_HKEY_EV_* returned by "MHKP") instead of on the 0 -
TPACPI_HOTKEY_MAP_LEN scancodes used for scancode -> keycode translation.

Keeping things in the hkey format as long a possible is a bit cleaner and
this patch prepares things for moving to sparse-keymaps.

Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240424122834.19801-7-hdegoede@redhat.com
4 months agoplatform/x86: thinkpad_acpi: Use tpacpi_input_send_key() in adaptive kbd code
Hans de Goede [Wed, 24 Apr 2024 12:28:15 +0000 (14:28 +0200)]
platform/x86: thinkpad_acpi: Use tpacpi_input_send_key() in adaptive kbd code

Use tpacpi_input_send_key() in adaptive_keyboard_hotkey_notify_hotkey()
instead of re-implementing it there.

Note this change will also result in a behavioral change, key presses on
the adaptive keyboard will now also send a EV_MSC event with the scancode,
just like all other hotkey presses already do. This is not a bug but
a feature.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Link: https://lore.kernel.org/r/20240424122834.19801-6-hdegoede@redhat.com
4 months agoplatform/x86: thinkpad_acpi: Drop ignore_acpi_ev
Hans de Goede [Wed, 24 Apr 2024 12:28:14 +0000 (14:28 +0200)]
platform/x86: thinkpad_acpi: Drop ignore_acpi_ev

Setting ignore_acpi_ev to true has the same result as setting
send_acpi_ev to false, so there is no need to have both.

Drop ignore_acpi_ev.

Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240424122834.19801-5-hdegoede@redhat.com
4 months agoplatform/x86: thinkpad_acpi: Drop setting send_/ignore_acpi_ev defaults twice
Hans de Goede [Wed, 24 Apr 2024 12:28:13 +0000 (14:28 +0200)]
platform/x86: thinkpad_acpi: Drop setting send_/ignore_acpi_ev defaults twice

send_acpi_ev and ignore_acpi_ev are already initialized to true and false
respectively by hotkey_notify() before calling the various helpers. Drop
the needless re-initialization from the helpers.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Link: https://lore.kernel.org/r/20240424122834.19801-4-hdegoede@redhat.com
4 months agoplatform/x86: thinkpad_acpi: Provide hotkey_poll_stop_sync() dummy
Hans de Goede [Wed, 24 Apr 2024 12:28:12 +0000 (14:28 +0200)]
platform/x86: thinkpad_acpi: Provide hotkey_poll_stop_sync() dummy

Provide a hotkey_poll_stop_sync() dummy implementation when
CONFIG_THINKPAD_ACPI_HOTKEY_POLL, so that the #ifdef-ery around
hotkey_poll_stop_sync() can be removed from hotkey_exit().

Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240424122834.19801-3-hdegoede@redhat.com
4 months agoplatform/x86: thinkpad_acpi: Take hotkey_mutex during hotkey_exit()
Hans de Goede [Wed, 24 Apr 2024 12:28:11 +0000 (14:28 +0200)]
platform/x86: thinkpad_acpi: Take hotkey_mutex during hotkey_exit()

hotkey_exit() already takes the mutex around the hotkey_poll_stop_sync()
call, but not around the other calls.

commit 38831eaf7d4c ("platform/x86: thinkpad_acpi: use lockdep
annotations") has added lockdep_assert_held() checks to various hotkey
functions.

These lockdep_assert_held() checks fail causing WARN() backtraces in
dmesg due to missing locking in hotkey_exit(), fix this.

Fixes: 38831eaf7d4c ("platform/x86: thinkpad_acpi: use lockdep annotations")
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240424122834.19801-2-hdegoede@redhat.com
4 months agoplatform/x86: asus-laptop: Use sysfs_emit() and sysfs_emit_at() to replace sprintf()
yunshui [Mon, 22 Apr 2024 06:29:15 +0000 (14:29 +0800)]
platform/x86: asus-laptop: Use sysfs_emit() and sysfs_emit_at() to replace sprintf()

As Documentation/filesystems/sysfs.rst suggested,
show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to be returned to user space.

Signed-off-by: yunshui <jiangyunshui@kylinos.cn>
Reviewed-by: Ai Chao <aichao@kylinos.cn>
Link: https://lore.kernel.org/r/20240422062915.3393480-1-jiangyunshui@kylinos.cn
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
4 months agoplatform/x86: samsung-laptop: Use sysfs_emit() to replace the old interface sprintf()
yunshui [Fri, 19 Apr 2024 06:41:06 +0000 (14:41 +0800)]
platform/x86: samsung-laptop: Use sysfs_emit() to replace the old interface sprintf()

    As Documentation/filesystems/sysfs.rst suggested,
    show() should only use sysfs_emit() or sysfs_emit_at() when formatting
    the value to be returned to user space.

Signed-off-by: yunshui <jiangyunshui@kylinos.cn>
Reviewed-by: Ai Chao <aichao@kylinos.cn>
Link: https://lore.kernel.org/r/20240419064106.2396705-1-jiangyunshui@kylinos.cn
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
4 months agoplatform/x86: msi-laptop: Use sysfs_emit() to replace sprintf()
yunshui [Fri, 19 Apr 2024 06:36:49 +0000 (14:36 +0800)]
platform/x86: msi-laptop: Use sysfs_emit() to replace sprintf()

As Documentation/filesystems/sysfs.rst suggested,
show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to be returned to user space.

Signed-off-by: yunshui <jiangyunshui@kylinos.cn>
Reviewed-by: Ai Chao <aichao@kylinos.cn>
Link: https://lore.kernel.org/r/20240419063649.2396461-1-jiangyunshui@kylinos.cn
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
4 months agoplatform/x86: thinkpad_acpi: change sprintf() to sysfs_emit()
yunshui [Wed, 17 Apr 2024 09:20:55 +0000 (17:20 +0800)]
platform/x86: thinkpad_acpi: change sprintf() to sysfs_emit()

As Documentation/filesystems/sysfs.rst suggested,
show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to be returned to user space.

Signed-off-by: yunshui <jiangyunshui@kylinos.cn>
Reviewed-by: Ai Chao <aichao@kylinos.cn>
Link: https://lore.kernel.org/r/20240417092055.1170586-1-jiangyunshui@kylinos.cn
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
4 months agoplatform/x86/intel/pmc: Fix PCH names in comments
Colin Ian King [Thu, 18 Apr 2024 21:52:02 +0000 (22:52 +0100)]
platform/x86/intel/pmc: Fix PCH names in comments

The PCH names in the pmc drivers are incorrect in the comments,
fix these.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Link: https://lore.kernel.org/r/20240418215202.879171-1-colin.i.king@gmail.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
4 months agoplatform/x86/intel-uncore-freq: Don't present root domain on error
Srinivas Pandruvada [Mon, 15 Apr 2024 21:52:10 +0000 (14:52 -0700)]
platform/x86/intel-uncore-freq: Don't present root domain on error

If none of the clusters are added because of some error, fail to load
driver without presenting root domain. In this case root domain will
present invalid data.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Fixes: 01c10f88c9b7 ("platform/x86/intel-uncore-freq: tpmi: Provide cluster level control")
Cc: <stable@vger.kernel.org> # 6.5+
Link: https://lore.kernel.org/r/20240415215210.2824868-1-srinivas.pandruvada@linux.intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
4 months agoplatform/x86/amd/pmc: Fix implicit declaration error on i386
Basavaraj Natikar [Tue, 16 Apr 2024 02:53:12 +0000 (08:23 +0530)]
platform/x86/amd/pmc: Fix implicit declaration error on i386

Add depended header file to fix error on i386 due to implicit declaration
of function ‘writeq’.

Fixes: 2dc77993cb5e ("platform/x86/amd/pmc: Add AMD MP2 STB functionality")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202404160320.QAHyZ0c3-lkp@intel.com/
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://lore.kernel.org/r/20240416025312.731809-1-Basavaraj.Natikar@amd.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
4 months agoplatform/x86/intel/ifs: Disable irq during one load stage
Jithu Joseph [Fri, 12 Apr 2024 17:23:49 +0000 (10:23 -0700)]
platform/x86/intel/ifs: Disable irq during one load stage

One of the stages in IFS image loading process involves loading individual
chunks (test patterns) from test image file to secure memory.

Driver issues a WRMSR(MSR_AUTHENTICATE_AND_COPY_CHUNK) operation to do
this. This operation can take up to 5 msec, and if an interrupt occurs
in between, the AUTH_AND_COPY_CHUNK u-code implementation aborts the
operation.

Interrupt sources such as NMI or SMI are handled by retrying. Regular
interrupts may occur frequently enough to prevent this operation from ever
completing. Disable irq on local cpu around the aforementioned WRMSR to
allow the operation to complete.

Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Ashok Raj <ashok.raj@intel.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://lore.kernel.org/r/20240412172349.544064-4-jithu.joseph@intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
4 months agoplatform/x86/intel/ifs: trace: display batch num in hex
Jithu Joseph [Fri, 12 Apr 2024 17:23:48 +0000 (10:23 -0700)]
platform/x86/intel/ifs: trace: display batch num in hex

In Field Scan test image files are named in ff-mm-ss-<batch02x>.scan
format. Current trace output, prints the batch number in decimal format.

Make it easier to correlate the trace line to a test image file by
showing the batch number also in hex format.

Add 0x prefix to all fields in the trace line to make the type explicit.

Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Ashok Raj <ashok.raj@intel.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://lore.kernel.org/r/20240412172349.544064-3-jithu.joseph@intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
4 months agoplatform/x86/intel/ifs: Classify error scenarios correctly
Jithu Joseph [Fri, 12 Apr 2024 17:23:47 +0000 (10:23 -0700)]
platform/x86/intel/ifs: Classify error scenarios correctly

"Scan controller error" means that scan hardware encountered an error
prior to doing an actual test on the target CPU. It does not mean that
there is an actual cpu/core failure. "scan signature failure" indicates
that the test result on the target core did not match the expected value
and should be treated as a cpu failure.

Current driver classifies both these scenarios as failures. Modify
the driver to classify this situation with a more appropriate "untested"
status instead of "fail" status.

Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Ashok Raj <ashok.raj@intel.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://lore.kernel.org/r/20240412172349.544064-2-jithu.joseph@intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
4 months agoplatform/x86: think-lmi: Convert container_of() macros to static inline
Ilpo Järvinen [Fri, 12 Apr 2024 13:09:03 +0000 (16:09 +0300)]
platform/x86: think-lmi: Convert container_of() macros to static inline

The macros to_tlmi_pwd_setting() and to_tlmi_attr_setting() are fragile
because they expect the variable name to be 'kobj', otherwise the build
will fail because container_of()'s 3rd parameter (member) is taken from
the parameter given to the macro.

While at it, move them into a more logical place.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by Mark Pearson <mpearson-lenovo@squebbb.ca>
Link: https://lore.kernel.org/r/20240412130903.2836-1-ilpo.jarvinen@linux.intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
4 months agotools/arch/x86/intel_sdsi: Add current meter support
David E. Box [Thu, 11 Apr 2024 02:58:56 +0000 (19:58 -0700)]
tools/arch/x86/intel_sdsi: Add current meter support

Add support to read the 'meter_current' file. The display is the same as
the 'meter_certificate', but will show the current snapshot of the
counters.

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240411025856.2782476-10-david.e.box@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
4 months agotools/arch/x86/intel_sdsi: Simplify ascii printing
David E. Box [Thu, 11 Apr 2024 02:58:55 +0000 (19:58 -0700)]
tools/arch/x86/intel_sdsi: Simplify ascii printing

Add #define for feature length and move NUL assignment from callers to
get_feature().

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240411025856.2782476-9-david.e.box@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
4 months agotools/arch/x86/intel_sdsi: Fix meter_certificate decoding
David E. Box [Thu, 11 Apr 2024 02:58:54 +0000 (19:58 -0700)]
tools/arch/x86/intel_sdsi: Fix meter_certificate decoding

Fix errors in the calculation of the start position of the counters and in
the display loop. While here, use a #define for the bundle count and size.

Fixes: 7fdc03a7370f ("tools/arch/x86: intel_sdsi: Add support for reading meter certificates")
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240411025856.2782476-8-david.e.box@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
4 months agotools/arch/x86/intel_sdsi: Fix meter_show display
David E. Box [Thu, 11 Apr 2024 02:58:53 +0000 (19:58 -0700)]
tools/arch/x86/intel_sdsi: Fix meter_show display

Fixes sdsi_meter_cert_show() to correctly decode and display the meter
certificate output. Adds and displays a missing version field, displays the
ASCII name of the signature, and fixes the print alignment.

Fixes: 7fdc03a7370f ("tools/arch/x86: intel_sdsi: Add support for reading meter certificates")
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240411025856.2782476-7-david.e.box@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
4 months agotools/arch/x86/intel_sdsi: Fix maximum meter bundle length
David E. Box [Thu, 11 Apr 2024 02:58:52 +0000 (19:58 -0700)]
tools/arch/x86/intel_sdsi: Fix maximum meter bundle length

The maximum number of bundles in the meter certificate was set to 8 which
is much less than the maximum. Instead, since the bundles appear at the end
of the file, set it based on the remaining file size from the bundle start
position.

Fixes: 7fdc03a7370f ("tools/arch/x86: intel_sdsi: Add support for reading meter certificates")
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240411025856.2782476-6-david.e.box@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86/intel/sdsi: Add attribute to read the current meter state
David E. Box [Thu, 11 Apr 2024 02:58:51 +0000 (19:58 -0700)]
platform/x86/intel/sdsi: Add attribute to read the current meter state

The meter_certificate file provides access to metering information that may
be attested but is only updated every 8 hours. Add new attribute,
meter_current, to allow reading an untested snapshot of the current values.

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240411025856.2782476-5-david.e.box@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86/intel/sdsi: Add in-band BIOS lock support
Kuppuswamy Sathyanarayanan [Thu, 11 Apr 2024 02:58:50 +0000 (19:58 -0700)]
platform/x86/intel/sdsi: Add in-band BIOS lock support

As per SDSi in-band interface specification, sec titled "BIOS lock for
in-band provisioning", when IB_LOCK bit is set in control qword, the
SDSI agent is only allowed to perform the read flow, but not allowed to
provision license blob or license key. So add check for it in
sdsi_provision().

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240411025856.2782476-4-david.e.box@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86/intel/sdsi: Combine read and write mailbox flows
David E. Box [Thu, 11 Apr 2024 02:58:49 +0000 (19:58 -0700)]
platform/x86/intel/sdsi: Combine read and write mailbox flows

The current mailbox commands are either read-only or write-only and the
flow is different for each. New commands will need to send and receive
data. In preparation for these commands, create a common polling function
to handle sending data and receiving in the same transaction.

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240411025856.2782476-3-david.e.box@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86/intel/sdsi: Set message size during writes
David E. Box [Thu, 11 Apr 2024 02:58:48 +0000 (19:58 -0700)]
platform/x86/intel/sdsi: Set message size during writes

New mailbox commands will support sending multi packet writes and updated
firmware now requires that the message size be written for all commands
along with the packet size. Since the driver doesn't perform writes larger
than the packet size, set the message size to the same value.

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://lore.kernel.org/r/20240411025856.2782476-2-david.e.box@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: thinkpad_acpi: use platform_profile_cycle()
Gergo Koteles [Mon, 8 Apr 2024 17:35:12 +0000 (19:35 +0200)]
platform/x86: thinkpad_acpi: use platform_profile_cycle()

Some Thinkpads have a 'mode' button that switches between platform
profiles.

Use the new platform_module_cycle function instead of the existing
switch-based one.

Signed-off-by: Gergo Koteles <soyer@irl.hu>
Link: https://lore.kernel.org/r/eb2484f5356786578d820301b714335221524839.1712597199.git.soyer@irl.hu
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: ideapad-laptop: switch platform profiles using thermal management key
Gergo Koteles [Mon, 8 Apr 2024 17:35:11 +0000 (19:35 +0200)]
platform/x86: ideapad-laptop: switch platform profiles using thermal management key

Ideapad laptops have thermal management or performance mode switch key
(Fn + Q). They report KEY_PROG4.

If supported, cycle between platform profiles instead.

Tested on Yoga7 14ARB7.

Signed-off-by: Gergo Koteles <soyer@irl.hu>
Link: https://lore.kernel.org/r/e5cf301ef731b037e211d468fe1d362fe3ea40ad.1712597199.git.soyer@irl.hu
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoACPI: platform-profile: add platform_profile_cycle()
Gergo Koteles [Mon, 8 Apr 2024 17:35:10 +0000 (19:35 +0200)]
ACPI: platform-profile: add platform_profile_cycle()

Some laptops have a key to switch platform profiles.

Add a platform_profile_cycle() function to cycle between the enabled
profiles.

Signed-off-by: Gergo Koteles <soyer@irl.hu>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/r/5a97deddf72aa5e764d881eb39a7ba35c01a903e.1712597199.git.soyer@irl.hu
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: android-tablets: Use GPIO_LOOKUP() macro
Andy Shevchenko [Mon, 8 Apr 2024 15:37:49 +0000 (18:37 +0300)]
platform/x86: android-tablets: Use GPIO_LOOKUP() macro

Use GPIO_LOOKUP() macro which provides a compound literal
and can be used with dynamic data.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240408153749.119394-1-andriy.shevchenko@linux.intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 Pro 1380F/L data
Hans de Goede [Sat, 6 Apr 2024 12:50:57 +0000 (14:50 +0200)]
platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 Pro 1380F/L data

The Lenovo Yoga Tablet 2 Pro 1380F/L is a x86 ACPI tablet which ships with
Android x86 as factory OS. Its DSDT contains a bunch of I2C devices which
are not actually there, causing various resource conflicts. Enumeration of
these is skipped through the acpi_quirk_skip_i2c_client_enumeration().

Add support for manually instantiating the I2C + other devices which are
actually present on this tablet by adding the necessary device info to
the x86-android-tablets module.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20240406125058.13624-2-hdegoede@redhat.com
5 months agoplatform/x86: x86-android-tablets: Unregister devices in reverse order
Hans de Goede [Sat, 6 Apr 2024 12:50:56 +0000 (14:50 +0200)]
platform/x86: x86-android-tablets: Unregister devices in reverse order

Not all subsystems support a device getting removed while there are
still consumers of the device with a reference to the device.

One example of this is the regulator subsystem. If a regulator gets
unregistered while there are still drivers holding a reference
a WARN() at drivers/regulator/core.c:5829 triggers, e.g.:

 WARNING: CPU: 1 PID: 1587 at drivers/regulator/core.c:5829 regulator_unregister
 Hardware name: Intel Corp. VALLEYVIEW C0 PLATFORM/BYT-T FFD8, BIOS BLADE_21.X64.0005.R00.1504101516 FFD8_X64_R_2015_04_10_1516 04/10/2015
 RIP: 0010:regulator_unregister
 Call Trace:
  <TASK>
  regulator_unregister
  devres_release_group
  i2c_device_remove
  device_release_driver_internal
  bus_remove_device
  device_del
  device_unregister
  x86_android_tablet_remove

On the Lenovo Yoga Tablet 2 series the bq24190 charger chip also provides
a 5V boost converter output for powering USB devices connected to the micro
USB port, the bq24190-charger driver exports this as a Vbus regulator.

On the 830 (8") and 1050 ("10") models this regulator is controlled by
a platform_device and x86_android_tablet_remove() removes platform_device-s
before i2c_clients so the consumer gets removed first.

But on the 1380 (13") model there is a lc824206xa micro-USB switch
connected over I2C and the extcon driver for that controls the regulator.
The bq24190 i2c-client *must* be registered first, because that creates
the regulator with the lc824206xa listed as its consumer. If the regulator
has not been registered yet the lc824206xa driver will end up getting
a dummy regulator.

Since in this case both the regulator provider and consumer are I2C
devices, the only way to ensure that the consumer is unregistered first
is to unregister the I2C devices in reverse order of in which they were
created.

For consistency and to avoid similar problems in the future change
x86_android_tablet_remove() to unregister all device types in reverse
order.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20240406125058.13624-1-hdegoede@redhat.com
5 months agoplatform/x86/amd/pmc: Add AMD MP2 STB functionality
Basavaraj Natikar [Thu, 4 Apr 2024 09:07:02 +0000 (14:37 +0530)]
platform/x86/amd/pmc: Add AMD MP2 STB functionality

AMD MP2 STB function provides a data buffer used to log debug information
about the system execution during S2Idle suspend/resume.

A data buffer known as the STB (Smart Trace Buffer) is a circular buffer
which is a low-level log to assist in debugging by providing insights
into any potential hangs or stalls that may occur during the S2Idle
suspend/resume processes.

The current PMC driver retrieves STB data from MP1, but there can be
scenarios where MP1 might hang or become unresponsive, leading to the
loss of critical data present in the STB buffer. This defeats the purpose
of the STB buffer, which was originally meant to help identify system
failures.

This feature creates stb_read_previous_boot debugfs allows users to
retrieve the STB log from MP2 specifically from the last occurrence of
the S2Idle suspend/resume. A userspace daemon can access STB log of last
S2Idle suspend/resume which can help to troubleshoot potential issues
related to hangs or stalls during the S2Idle suspend/resume sequence.

Reviewed-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://lore.kernel.org/r/20240404090702.325838-1-Basavaraj.Natikar@amd.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: ideapad-laptop: add FnLock LED class device
Gergo Koteles [Tue, 2 Apr 2024 13:21:02 +0000 (15:21 +0200)]
platform/x86: ideapad-laptop: add FnLock LED class device

Some Ideapad/Yoga Laptops have an FnLock LED in the Esc key.

Expose Fnlock as an LED class device for easier OSD support.

Signed-off-by: Gergo Koteles <soyer@irl.hu>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/2db08c948568a8d5352780864956c3271b4e42ce.1712063200.git.soyer@irl.hu
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: ideapad-laptop: add fn_lock_get/set functions
Gergo Koteles [Tue, 2 Apr 2024 13:21:01 +0000 (15:21 +0200)]
platform/x86: ideapad-laptop: add fn_lock_get/set functions

The FnLock is retrieved and set in several places in the code.

Move details into ideapad_fn_lock_get and ideapad_fn_lock_set functions.

Signed-off-by: Gergo Koteles <soyer@irl.hu>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/dfd3a62a2b71339bbddf01e8a2ccd5ca92ce7202.1712063200.git.soyer@irl.hu
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agodt-bindings: leds: Add LED_FUNCTION_FNLOCK
Gergo Koteles [Tue, 2 Apr 2024 13:21:00 +0000 (15:21 +0200)]
dt-bindings: leds: Add LED_FUNCTION_FNLOCK

Newer laptops have FnLock LED.

Add a define for this very common function.

Signed-off-by: Gergo Koteles <soyer@irl.hu>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: Lee Jones <lee@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/8ac95e85a53dc0b8cce1e27fc1cab6d19221543b.1712063200.git.soyer@irl.hu
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: asus-wmi: cleanup main struct to avoid some holes
Luke D. Jones [Thu, 4 Apr 2024 00:16:52 +0000 (13:16 +1300)]
platform/x86: asus-wmi: cleanup main struct to avoid some holes

Reorganises some attr-available calls to remove a few unrequired
booleans in the main driver struct which combined with some
reorganisation prevents a series of large holes seen with pahole.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Luke D. Jones <luke@ljones.dev>
Link: https://lore.kernel.org/r/20240404001652.86207-10-luke@ljones.dev
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: asus-wmi: Add support for MCU powersave
Luke D. Jones [Thu, 4 Apr 2024 00:16:51 +0000 (13:16 +1300)]
platform/x86: asus-wmi: Add support for MCU powersave

Add support for an MCU powersave WMI call. This is intended to set the
MCU in to a low-power mode when sleeping. This mode can cut sleep power
use by around half.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Luke D. Jones <luke@ljones.dev>
Link: https://lore.kernel.org/r/20240404001652.86207-9-luke@ljones.dev
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: asus-wmi: ROG Ally increase wait time, allow MCU powersave
Luke D. Jones [Thu, 4 Apr 2024 00:16:50 +0000 (13:16 +1300)]
platform/x86: asus-wmi: ROG Ally increase wait time, allow MCU powersave

The previous work to allow the MCU to be resumed correctly after sleep
and resume tried to take the shortest possible time. However as work
continues in various other parts of the s2idle subsystems it has shown
that it wasn't entirely reliable.

If the MCU disable/enable call is done correctly the MCU fully removes
its USB endpoints, and this shows as a full USB device reconnection on
resume. When we tried to short this as much as possible sometimes the
MCU doesn't get to complete what it needs to do before going to low-power
and this affected the reconnection.

Through trial it is found that the minimum time required is approx 1200ms
to allow a proper disconnect and disable, and the same amount of time on
resume is required to prevent a rapid disconnect/reconnect happening on
seemingly random occasions. To be safe the time is now 1500ms for msleep.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Luke D. Jones <luke@ljones.dev>
Link: https://lore.kernel.org/r/20240404001652.86207-8-luke@ljones.dev
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: asus-wmi: adjust formatting of ppt-<name>() functions
Luke D. Jones [Thu, 4 Apr 2024 00:16:49 +0000 (13:16 +1300)]
platform/x86: asus-wmi: adjust formatting of ppt-<name>() functions

Shift the call to dev_get_drvdata() up to top of the function block
in all of the ppt_<name>() functions as part of a minor cleanup.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Luke D. Jones <luke@ljones.dev>
Link: https://lore.kernel.org/r/20240404001652.86207-7-luke@ljones.dev
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: asus-wmi: store a min default for ppt options
Luke D. Jones [Thu, 4 Apr 2024 00:16:48 +0000 (13:16 +1300)]
platform/x86: asus-wmi: store a min default for ppt options

Laptops with any of the ppt or nv tunables default to the minimum setting
on boot so we can safely assume a stored value is correct.

This patch adds storing of those values in the local struct, and enables
reading of those values back. To prevent creating a series of byte holes
in the struct the "<name>_available" bool is removed and
`asus_sysfs_is_visible()` uses the `ASUS_WMI_DEVID_<name>` directly.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Luke D. Jones <luke@ljones.dev>
Link: https://lore.kernel.org/r/20240404001652.86207-6-luke@ljones.dev
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: asus-wmi: support toggling POST sound
Luke D. Jones [Thu, 4 Apr 2024 00:16:47 +0000 (13:16 +1300)]
platform/x86: asus-wmi: support toggling POST sound

Add support for toggling the BIOS POST sound on some ASUS laptops.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Luke D. Jones <luke@ljones.dev>
Link: https://lore.kernel.org/r/20240404001652.86207-5-luke@ljones.dev
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: asus-wmi: add support variant of TUF RGB
Luke D. Jones [Thu, 4 Apr 2024 00:16:46 +0000 (13:16 +1300)]
platform/x86: asus-wmi: add support variant of TUF RGB

Adds support for a second TUF RGB wmi call that some versions of the TUF
laptop come with. Also adjusts existing support to select whichever is
available.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Luke D. Jones <luke@ljones.dev>
Link: https://lore.kernel.org/r/20240404001652.86207-4-luke@ljones.dev
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: asus-wmi: add support for Vivobook GPU MUX
Luke D. Jones [Thu, 4 Apr 2024 00:16:45 +0000 (13:16 +1300)]
platform/x86: asus-wmi: add support for Vivobook GPU MUX

Add support for the Vivobook dgpu MUX available on the ASUS Viviobook
and some of the other ranges (Zen).

This MUX functions exactly the same as the existing ROG MUX support so
the existing functionality now detects which MUX is available and uses
that for control.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Luke D. Jones <luke@ljones.dev>
Link: https://lore.kernel.org/r/20240404001652.86207-3-luke@ljones.dev
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: asus-wmi: add support for 2024 ROG Mini-LED
Luke D. Jones [Thu, 4 Apr 2024 00:16:44 +0000 (13:16 +1300)]
platform/x86: asus-wmi: add support for 2024 ROG Mini-LED

Support the 2024 mini-led backlight and adjust the related functions
to select the relevant dev-id. Also add `available_mini_led_mode` to the
platform sysfs since the available mini-led levels can be different.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
signed-off-by: Luke D. Jones <luke@ljones.dev>
Link: https://lore.kernel.org/r/20240404001652.86207-2-luke@ljones.dev
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: wmi: Add driver development guide
Armin Wolf [Tue, 2 Apr 2024 14:30:59 +0000 (16:30 +0200)]
platform/x86: wmi: Add driver development guide

Since 2010, an LWN article covering WMI drivers exists:

https://lwn.net/Articles/391230/

Since the introduction of the modern bus-based interface
and other userspace tooling (bmfdec, lswmi, ...), this
article is outdated and causes people to still submit new
WMI drivers using the deprecated GUID-based interface.
Fix this by adding a short guide on how to develop WMI drivers
using the modern bus-based interface.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20240402143059.8456-4-W_Armin@gmx.de
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: xiaomi-wmi: Drop unnecessary NULL checks
Armin Wolf [Tue, 2 Apr 2024 14:30:58 +0000 (16:30 +0200)]
platform/x86: xiaomi-wmi: Drop unnecessary NULL checks

The WMI driver core already makes sure that:

- a valid WMI device is passed to each callback
- the notify() callback runs after the probe() callback succeeds

Remove the unnecessary NULL checks.

Compile-tested only.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20240402143059.8456-3-W_Armin@gmx.de
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: xiaomi-wmi: Fix race condition when reporting key events
Armin Wolf [Tue, 2 Apr 2024 14:30:57 +0000 (16:30 +0200)]
platform/x86: xiaomi-wmi: Fix race condition when reporting key events

Multiple WMI events can be received concurrently, so multiple instances
of xiaomi_wmi_notify() can be active at the same time. Since the input
device is shared between those handlers, the key input sequence can be
disturbed.

Fix this by protecting the key input sequence with a mutex.

Compile-tested only.

Fixes: edb73f4f0247 ("platform/x86: wmi: add Xiaomi WMI key driver")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20240402143059.8456-2-W_Armin@gmx.de
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: wmi: Mark simple WMI drivers as legacy-free
Armin Wolf [Tue, 2 Apr 2024 14:30:56 +0000 (16:30 +0200)]
platform/x86: wmi: Mark simple WMI drivers as legacy-free

The inspur_platform_profile driver and the xiaomi-wmi driver both
meet the requirements for modern WMI drivers, as they both do not
use the legacy GUID-based interface and can be safely instantiated
multiple times.

Mark them both as legacy-free using the no_singleton flag.

Compile-tested only.

Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20240402143059.8456-1-W_Armin@gmx.de
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/surface: aggregator_registry: Add support for thermal sensors on the Surface...
Maximilian Luz [Sat, 30 Mar 2024 11:24:02 +0000 (12:24 +0100)]
platform/surface: aggregator_registry: Add support for thermal sensors on the Surface Pro 9

The Surface Pro 9 has thermal sensors connected via the Surface
Aggregator Module. Add a device node to support those.

Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Link: https://lore.kernel.org/r/20240330112409.3402943-4-luzmaximilian@gmail.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: intel-vbtn: Log event code on unexpected button events
Hans de Goede [Wed, 27 Mar 2024 19:57:12 +0000 (20:57 +0100)]
platform/x86: intel-vbtn: Log event code on unexpected button events

When logging the warning about receiving a button event on a device
without buttons log the event code which triggered the warning.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://lore.kernel.org/r/20240327195712.43851-1-hdegoede@redhat.com
5 months agoplatform/x86: quickstart: Fix race condition when reporting input event
Armin Wolf [Wed, 27 Mar 2024 21:45:24 +0000 (22:45 +0100)]
platform/x86: quickstart: Fix race condition when reporting input event

Since commit e2ffcda16290 ("ACPI: OSL: Allow Notify () handlers to run
on all CPUs"), the ACPI core allows multiple notify calls to be active
at the same time. This means that two instances of quickstart_notify()
running at the same time can mess which each others input sequences.

Fix this by protecting the input sequence with a mutex.

Compile-tested only.

Fixes: afd66f2a739e ("platform/x86: Add ACPI quickstart button (PNP0C32) driver")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20240327214524.123935-1-W_Armin@gmx.de
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: quickstart: fix Kconfig selects
Arnd Bergmann [Thu, 4 Apr 2024 12:34:30 +0000 (14:34 +0200)]
platform/x86: quickstart: fix Kconfig selects

The new driver Kconfig entry has a typo that causes a link failure
when CONFIG_INPUT_SPARSEKMAP is disabled:

x86_64-linux-ld: drivers/platform/x86/quickstart.o: in function `quickstart_notify':
quickstart.c:(.text+0x96): undefined reference to `sparse_keymap_report_event'
x86_64-linux-ld: drivers/platform/x86/quickstart.o: in function `quickstart_probe':
quickstart.c:(.text+0x1da): undefined reference to `sparse_keymap_setup'

Select this symbol instead of the incorrect INPUT_SPARSE_KEYMAP.

Fixes: afd66f2a739e ("platform/x86: Add ACPI quickstart button (PNP0C32) driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://lore.kernel.org/r/20240404123435.2684819-1-arnd@kernel.org
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: quickstart: Miscellaneous improvements
Andy Shevchenko [Wed, 27 Mar 2024 21:52:08 +0000 (23:52 +0200)]
platform/x86: quickstart: Miscellaneous improvements

There is a mix of a few improvements to the driver.
I have done this instead of review, so it can quickly be
folded into the original code (partially or fully).

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20240327215208.649020-1-andy.shevchenko@gmail.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: MAINTAINERS: drop Daniel Oliveira Nascimento
Krzysztof Kozlowski [Wed, 27 Mar 2024 08:14:34 +0000 (09:14 +0100)]
platform/x86: MAINTAINERS: drop Daniel Oliveira Nascimento

Emails to Daniel Oliveira Nascimento bounce:

  "550 5.1.1 The email account that you tried to reach does not exist."

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Link: https://lore.kernel.org/r/20240327081434.306106-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86/amd/hsmp: switch to use device_add_groups()
Greg Kroah-Hartman [Wed, 27 Mar 2024 08:08:33 +0000 (09:08 +0100)]
platform/x86/amd/hsmp: switch to use device_add_groups()

devm_device_add_groups() is being removed from the kernel, so move the
hsmp driver to use device_add_groups() instead.  The logic is identical,
when the device is removed the driver core will properly clean up and
remove the groups, and the memory used by the attribute groups will be
freed because it was created with dev_* calls, so this is functionally
identical overall.

Cc: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
Cc: Carlos Bilbao <carlos.bilbao@amd.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/2024032732-thigh-smite-f5dd@gregkh
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: toshiba_acpi: Add quirk for buttons on Z830
Arvid Norlander [Wed, 31 Jan 2024 11:16:41 +0000 (12:16 +0100)]
platform/x86: toshiba_acpi: Add quirk for buttons on Z830

The Z830 has some buttons that will only work properly as "quickstart"
buttons. To enable them in that mode, a value between 1 and 7 must be
used for HCI_HOTKEY_EVENT. Windows uses 0x5 on this laptop so use that for
maximum predictability and compatibility.

As there is not yet a known way of auto detection, this patch uses a DMI
quirk table. A module parameter is exposed to allow setting this on other
models for testing.

Signed-off-by: Arvid Norlander <lkml@vorpal.se>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20240131111641.4418-3-W_Armin@gmx.de
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: Add ACPI quickstart button (PNP0C32) driver
Armin Wolf [Wed, 31 Jan 2024 11:16:40 +0000 (12:16 +0100)]
platform/x86: Add ACPI quickstart button (PNP0C32) driver

This drivers supports the ACPI quickstart button device, which
is used to send manufacturer-specific events to userspace.
Since the meaning of those events is not standardized, userspace
has to use for example hwdb to decode them.

The driver itself is based on an earlier proposal, but contains
some improvements and uses the device wakeup API instead of a
custom sysfs file.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20240131111641.4418-2-W_Armin@gmx.de
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: x86-android-tablets: Add swnode for Xiaomi pad2 indicator LED
Kate Hsuan [Fri, 22 Mar 2024 03:37:31 +0000 (11:37 +0800)]
platform/x86: x86-android-tablets: Add swnode for Xiaomi pad2 indicator LED

There is a KTD2026 LED controller to manage the indicator LED for Xiaomi
pad2. The ACPI for it is not properly made so the kernel can't get
a correct description of it.

This work adds a description for this RGB LED controller and also sets
a trigger to indicate the charging event (bq27520-0-charging). When it
is charging, the indicator LED will be turned on.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
Link: https://lore.kernel.org/r/20240322033736.9344-2-hpa@redhat.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5 months agoplatform/x86: add lenovo WMI camera button driver
Ai Chao [Wed, 27 Mar 2024 08:27:37 +0000 (16:27 +0800)]
platform/x86: add lenovo WMI camera button driver

Add lenovo WMI camera button driver to support camera button.
The Camera button is a GPIO device. This driver receives ACPI notifications
when the camera button is switched on/off. This driver is used in
Lenovo A70, it is a Computer integrated machine.

Signed-off-by: Ai Chao <aichao@kylinos.cn>
Link: https://lore.kernel.org/r/20240327082737.336992-1-aichao@kylinos.cn
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
6 months agoplatform/surface: platform_profile: add fan profile switching
Ivor Wanders [Thu, 14 Mar 2024 22:37:33 +0000 (18:37 -0400)]
platform/surface: platform_profile: add fan profile switching

Change naming from tmp to platform profile to clarify the module may
interact with both the TMP and FAN subystems. Add functionality that
switches the fan profile when the platform profile is changed when
a fan is present.

Signed-off-by: Ivor Wanders <ivor@iwanders.net>
Link: https://github.com/linux-surface/kernel/pull/145
Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>
Link: https://lore.kernel.org/r/20240314223733.6236-2-ivor@iwanders.net
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
6 months agoplatform/x86: wmi: Avoid returning AE_OK upon unknown error
Armin Wolf [Thu, 14 Mar 2024 18:45:38 +0000 (19:45 +0100)]
platform/x86: wmi: Avoid returning AE_OK upon unknown error

If an error code other than EINVAL, ENODEV or ETIME is returned
by ec_read()/ec_write(), then AE_OK is wrongly returned.

Fix this by only returning AE_OK if the return code is 0, and
return AE_ERROR otherwise.

Tested on a Dell Inspiron 3505 and a Asus Prime B650-Plus.

Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20240314184538.2933-2-W_Armin@gmx.de
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
6 months agoplatform/x86: wmi: Support reading/writing 16 bit EC values
Armin Wolf [Thu, 14 Mar 2024 18:45:37 +0000 (19:45 +0100)]
platform/x86: wmi: Support reading/writing 16 bit EC values

The ACPI EC address space handler currently only supports
reading/writing 8 bit values. Some firmware implementations however
want to access for example 16 bit values, which is perfectly legal
according to the ACPI spec.

Add support for reading/writing such values.

Tested on a Dell Inspiron 3505 and a Asus Prime B650-Plus.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://lore.kernel.org/r/20240314184538.2933-1-W_Armin@gmx.de
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
6 months agoarm64: dts: qcom: acer-aspire1: Add embedded controller
Nikita Travkin [Fri, 15 Mar 2024 13:51:18 +0000 (18:51 +0500)]
arm64: dts: qcom: acer-aspire1: Add embedded controller

The laptop contains an embedded controller that provides a set of
features:

- Battery and charger monitoring
- USB Type-C DP alt mode HPD monitoring
- Lid status detection
- Small amount of keyboard configuration*

[*] The keyboard is handled by the same EC but it has a dedicated i2c
bus and is already enabled. This port only provides fn key behavior
configuration.

Add the EC to the device tree and describe the relationship between the
EC-managed type-c port and the SoC DisplayPort.

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Nikita Travkin <nikita@trvn.ru>
Link: https://lore.kernel.org/r/20240315-aspire1-ec-v5-4-f93381deff39@trvn.ru
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
6 months agoplatform: arm64: Add Acer Aspire 1 embedded controller driver
Nikita Travkin [Fri, 15 Mar 2024 13:51:17 +0000 (18:51 +0500)]
platform: arm64: Add Acer Aspire 1 embedded controller driver

Acer Aspire 1 is a Snapdragon 7c based laptop. It uses an embedded
controller to perform a set of various functions, such as:

- Battery and charger monitoring;
- Keyboard layout control (i.e. fn_lock settings);
- USB Type-C DP alt mode HPD notifications;
- Laptop lid status.

Unfortunately, while all this functionality is implemented in ACPI, it's
currently not possible to use ACPI to boot Linux on such Qualcomm
devices. To allow Linux to still support the features provided by EC,
this driver reimplments the relevant ACPI parts. This allows us to boot
the laptop with Device Tree and retain all the features.

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Nikita Travkin <nikita@trvn.ru>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240315-aspire1-ec-v5-3-f93381deff39@trvn.ru
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
6 months agoplatform: Add ARM64 platform directory
Nikita Travkin [Fri, 15 Mar 2024 13:51:16 +0000 (18:51 +0500)]
platform: Add ARM64 platform directory

Some ARM64 based laptops and computers require vendor/board specific
drivers for their embedded controllers. Even though usually the most
important functionality of those devices is implemented inside ACPI,
unfortunately Linux doesn't currently have great support for ACPI on
platforms like Qualcomm Snapdragon that are used in most ARM64 laptops
today. Instead Linux relies on Device Tree for Qualcomm based devices
and it's significantly easier to reimplement the EC functionality in
a dedicated driver than to make use of ACPI code.

This commit introduces a new platform/arm64 subdirectory to give a
place to such drivers for EC-like devices.

A new MAINTAINERS entry is added for this directory. Patches to files in
this directory will be taken up by the platform-drivers-x86 team (i.e.
Hans de Goede and Ilpo Järvinen) with additional review from Bryan
O'Donoghue to represent ARM64 maintainers.

Signed-off-by: Nikita Travkin <nikita@trvn.ru>
Acked-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240315-aspire1-ec-v5-2-f93381deff39@trvn.ru
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
6 months agodt-bindings: platform: Add Acer Aspire 1 EC
Nikita Travkin [Fri, 15 Mar 2024 13:51:15 +0000 (18:51 +0500)]
dt-bindings: platform: Add Acer Aspire 1 EC

Add binding for the EC found in the Acer Aspire 1 laptop.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Nikita Travkin <nikita@trvn.ru>
Link: https://lore.kernel.org/r/20240315-aspire1-ec-v5-1-f93381deff39@trvn.ru
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
6 months agoplatform/x86: uv_sysfs: use sysfs_emit() instead of sprintf()
Ai Chao [Tue, 19 Mar 2024 07:00:38 +0000 (15:00 +0800)]
platform/x86: uv_sysfs: use sysfs_emit() instead of sprintf()

Follow the advice in Documentation/filesystems/sysfs.rst:
show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to be returned to user space.

Signed-off-by: Ai Chao <aichao@kylinos.cn>
Link: https://lore.kernel.org/r/20240319070038.309683-1-aichao@kylinos.cn
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
6 months agoplatform/x86: huawei-wmi: use sysfs_emit() instead of sprintf()
Ai Chao [Tue, 19 Mar 2024 06:42:43 +0000 (14:42 +0800)]
platform/x86: huawei-wmi: use sysfs_emit() instead of sprintf()

Follow the advice in Documentation/filesystems/sysfs.rst:
show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to be returned to user space.

Signed-off-by: Ai Chao <aichao@kylinos.cn>
Link: https://lore.kernel.org/r/20240319064243.297320-1-aichao@kylinos.cn
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
6 months agoplatform/x86: asus-wmi: use sysfs_emit() instead of sprintf()
Ai Chao [Tue, 19 Mar 2024 05:56:36 +0000 (13:56 +0800)]
platform/x86: asus-wmi: use sysfs_emit() instead of sprintf()

This changes all *_show attributes in asus-wmi.c to use sysfs_emit()
instead of the older method of writing to the output buffer manually.

Follow the advice in Documentation/filesystems/sysfs.rst:
show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to be returned to user space.

Signed-off-by: Ai Chao <aichao@kylinos.cn>
Link: https://lore.kernel.org/r/20240319055636.150289-1-aichao@kylinos.cn
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
6 months agoplatform/x86: hp-wmi: use sysfs_emit() instead of sprintf()
Ai Chao [Thu, 14 Mar 2024 06:37:03 +0000 (14:37 +0800)]
platform/x86: hp-wmi: use sysfs_emit() instead of sprintf()

Follow the advice in Documentation/filesystems/sysfs.rst:
show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to be returned to user space.

Signed-off-by: Ai Chao <aichao@kylinos.cn>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240314063703.315841-1-aichao@kylinos.cn
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
6 months agoplatform/x86: p2sb: Make p2sb_get_devfn() return void
Hans de Goede [Tue, 5 Mar 2024 09:45:00 +0000 (10:45 +0100)]
platform/x86: p2sb: Make p2sb_get_devfn() return void

p2sb_get_devfn() always succeeds, make it return void and
remove error checking from its callers.

Reviewed-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20240305094500.23778-1-hdegoede@redhat.com
6 months agoLinux 6.9-rc1 v6.9-rc1
Linus Torvalds [Sun, 24 Mar 2024 21:10:05 +0000 (14:10 -0700)]
Linux 6.9-rc1

6 months agoMerge tag 'efi-fixes-for-v6.9-2' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 24 Mar 2024 20:54:06 +0000 (13:54 -0700)]
Merge tag 'efi-fixes-for-v6.9-2' of git://git./linux/kernel/git/efi/efi

Pull EFI fixes from Ard Biesheuvel:

 - Fix logic that is supposed to prevent placement of the kernel image
   below LOAD_PHYSICAL_ADDR

 - Use the firmware stack in the EFI stub when running in mixed mode

 - Clear BSS only once when using mixed mode

 - Check efi.get_variable() function pointer for NULL before trying to
   call it

* tag 'efi-fixes-for-v6.9-2' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi:
  efi: fix panic in kdump kernel
  x86/efistub: Don't clear BSS twice in mixed mode
  x86/efistub: Call mixed mode boot services on the firmware's stack
  efi/libstub: fix efi_random_alloc() to allocate memory at alloc_min or higher address

6 months agoMerge tag 'x86-urgent-2024-03-24' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 24 Mar 2024 18:13:56 +0000 (11:13 -0700)]
Merge tag 'x86-urgent-2024-03-24' of git://git./linux/kernel/git/tip/tip

Pull x86 fixes from Thomas Gleixner:

 - Ensure that the encryption mask at boot is properly propagated on
   5-level page tables, otherwise the PGD entry is incorrectly set to
   non-encrypted, which causes system crashes during boot.

 - Undo the deferred 5-level page table setup as it cannot work with
   memory encryption enabled.

 - Prevent inconsistent XFD state on CPU hotplug, where the MSR is reset
   to the default value but the cached variable is not, so subsequent
   comparisons might yield the wrong result and as a consequence the
   result prevents updating the MSR.

 - Register the local APIC address only once in the MPPARSE enumeration
   to prevent triggering the related WARN_ONs() in the APIC and topology
   code.

 - Handle the case where no APIC is found gracefully by registering a
   fake APIC in the topology code. That makes all related topology
   functions work correctly and does not affect the actual APIC driver
   code at all.

 - Don't evaluate logical IDs during early boot as the local APIC IDs
   are not yet enumerated and the invoked function returns an error
   code. Nothing requires the logical IDs before the final CPUID
   enumeration takes place, which happens after the enumeration.

 - Cure the fallout of the per CPU rework on UP which misplaced the
   copying of boot_cpu_data to per CPU data so that the final update to
   boot_cpu_data got lost which caused inconsistent state and boot
   crashes.

 - Use copy_from_kernel_nofault() in the kprobes setup as there is no
   guarantee that the address can be safely accessed.

 - Reorder struct members in struct saved_context to work around another
   kmemleak false positive

 - Remove the buggy code which tries to update the E820 kexec table for
   setup_data as that is never passed to the kexec kernel.

 - Update the resource control documentation to use the proper units.

 - Fix a Kconfig warning observed with tinyconfig

* tag 'x86-urgent-2024-03-24' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/boot/64: Move 5-level paging global variable assignments back
  x86/boot/64: Apply encryption mask to 5-level pagetable update
  x86/cpu: Add model number for another Intel Arrow Lake mobile processor
  x86/fpu: Keep xfd_state in sync with MSR_IA32_XFD
  Documentation/x86: Document that resctrl bandwidth control units are MiB
  x86/mpparse: Register APIC address only once
  x86/topology: Handle the !APIC case gracefully
  x86/topology: Don't evaluate logical IDs during early boot
  x86/cpu: Ensure that CPU info updates are propagated on UP
  kprobes/x86: Use copy_from_kernel_nofault() to read from unsafe address
  x86/pm: Work around false positive kmemleak report in msr_build_context()
  x86/kexec: Do not update E820 kexec table for setup_data
  x86/config: Fix warning for 'make ARCH=x86_64 tinyconfig'

6 months agoMerge tag 'sched-urgent-2024-03-24' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 24 Mar 2024 18:11:05 +0000 (11:11 -0700)]
Merge tag 'sched-urgent-2024-03-24' of git://git./linux/kernel/git/tip/tip

Pull scheduler doc clarification from Thomas Gleixner:
 "A single update for the documentation of the base_slice_ns tunable to
  clarify that any value which is less than the tick slice has no effect
  because the scheduler tick is not guaranteed to happen within the set
  time slice"

* tag 'sched-urgent-2024-03-24' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  sched/doc: Update documentation for base_slice_ns and CONFIG_HZ relation

6 months agoMerge tag 'dma-mapping-6.9-2024-03-24' of git://git.infradead.org/users/hch/dma-mapping
Linus Torvalds [Sun, 24 Mar 2024 17:45:31 +0000 (10:45 -0700)]
Merge tag 'dma-mapping-6.9-2024-03-24' of git://git.infradead.org/users/hch/dma-mapping

Pull dma-mapping fixes from Christoph Hellwig:
 "This has a set of swiotlb alignment fixes for sometimes very long
  standing bugs from Will. We've been discussion them for a while and
  they should be solid now"

* tag 'dma-mapping-6.9-2024-03-24' of git://git.infradead.org/users/hch/dma-mapping:
  swiotlb: Reinstate page-alignment for mappings >= PAGE_SIZE
  iommu/dma: Force swiotlb_max_mapping_size on an untrusted device
  swiotlb: Fix alignment checks when both allocation and DMA masks are present
  swiotlb: Honour dma_alloc_coherent() alignment in swiotlb_alloc()
  swiotlb: Enforce page alignment in swiotlb_alloc()
  swiotlb: Fix double-allocation of slots due to broken alignment handling

6 months agoefi: fix panic in kdump kernel
Oleksandr Tymoshenko [Sat, 23 Mar 2024 06:33:33 +0000 (06:33 +0000)]
efi: fix panic in kdump kernel

Check if get_next_variable() is actually valid pointer before
calling it. In kdump kernel this method is set to NULL that causes
panic during the kexec-ed kernel boot.

Tested with QEMU and OVMF firmware.

Fixes: bad267f9e18f ("efi: verify that variable services are supported")
Signed-off-by: Oleksandr Tymoshenko <ovt@google.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
6 months agox86/efistub: Don't clear BSS twice in mixed mode
Ard Biesheuvel [Fri, 22 Mar 2024 16:01:45 +0000 (17:01 +0100)]
x86/efistub: Don't clear BSS twice in mixed mode

Clearing BSS should only be done once, at the very beginning.
efi_pe_entry() is the entrypoint from the firmware, which may not clear
BSS and so it is done explicitly. However, efi_pe_entry() is also used
as an entrypoint by the mixed mode startup code, in which case BSS will
already have been cleared, and doing it again at this point will corrupt
global variables holding the firmware's GDT/IDT and segment selectors.

So make the memset() conditional on whether the EFI stub is running in
native mode.

Fixes: b3810c5a2cc4a666 ("x86/efistub: Clear decompressor BSS in native EFI entrypoint")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
6 months agox86/efistub: Call mixed mode boot services on the firmware's stack
Ard Biesheuvel [Fri, 22 Mar 2024 15:03:58 +0000 (17:03 +0200)]
x86/efistub: Call mixed mode boot services on the firmware's stack

Normally, the EFI stub calls into the EFI boot services using the stack
that was live when the stub was entered. According to the UEFI spec,
this stack needs to be at least 128k in size - this might seem large but
all asynchronous processing and event handling in EFI runs from the same
stack and so quite a lot of space may be used in practice.

In mixed mode, the situation is a bit different: the bootloader calls
the 32-bit EFI stub entry point, which calls the decompressor's 32-bit
entry point, where the boot stack is set up, using a fixed allocation
of 16k. This stack is still in use when the EFI stub is started in
64-bit mode, and so all calls back into the EFI firmware will be using
the decompressor's limited boot stack.

Due to the placement of the boot stack right after the boot heap, any
stack overruns have gone unnoticed. However, commit

  5c4feadb0011983b ("x86/decompressor: Move global symbol references to C code")

moved the definition of the boot heap into C code, and now the boot
stack is placed right at the base of BSS, where any overruns will
corrupt the end of the .data section.

While it would be possible to work around this by increasing the size of
the boot stack, doing so would affect all x86 systems, and mixed mode
systems are a tiny (and shrinking) fraction of the x86 installed base.

So instead, record the firmware stack pointer value when entering from
the 32-bit firmware, and switch to this stack every time a EFI boot
service call is made.

Cc: <stable@kernel.org> # v6.1+
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
6 months agox86/boot/64: Move 5-level paging global variable assignments back
Tom Lendacky [Fri, 22 Mar 2024 15:41:07 +0000 (10:41 -0500)]
x86/boot/64: Move 5-level paging global variable assignments back

Commit 63bed9660420 ("x86/startup_64: Defer assignment of 5-level paging
global variables") moved assignment of 5-level global variables to later
in the boot in order to avoid having to use RIP relative addressing in
order to set them. However, when running with 5-level paging and SME
active (mem_encrypt=on), the variables are needed as part of the page
table setup needed to encrypt the kernel (using pgd_none(), p4d_offset(),
etc.). Since the variables haven't been set, the page table manipulation
is done as if 4-level paging is active, causing the system to crash on
boot.

While only a subset of the assignments that were moved need to be set
early, move all of the assignments back into check_la57_support() so that
these assignments aren't spread between two locations. Instead of just
reverting the fix, this uses the new RIP_REL_REF() macro when assigning
the variables.

Fixes: 63bed9660420 ("x86/startup_64: Defer assignment of 5-level paging global variables")
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/2ca419f4d0de719926fd82353f6751f717590a86.1711122067.git.thomas.lendacky@amd.com
6 months agox86/boot/64: Apply encryption mask to 5-level pagetable update
Tom Lendacky [Fri, 22 Mar 2024 15:41:06 +0000 (10:41 -0500)]
x86/boot/64: Apply encryption mask to 5-level pagetable update

When running with 5-level page tables, the kernel mapping PGD entry is
updated to point to the P4D table. The assignment uses _PAGE_TABLE_NOENC,
which, when SME is active (mem_encrypt=on), results in a page table
entry without the encryption mask set, causing the system to crash on
boot.

Change the assignment to use _PAGE_TABLE instead of _PAGE_TABLE_NOENC so
that the encryption mask is set for the PGD entry.

Fixes: 533568e06b15 ("x86/boot/64: Use RIP_REL_REF() to access early_top_pgt[]")
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/8f20345cda7dbba2cf748b286e1bc00816fe649a.1711122067.git.thomas.lendacky@amd.com
6 months agox86/cpu: Add model number for another Intel Arrow Lake mobile processor
Tony Luck [Fri, 22 Mar 2024 16:17:25 +0000 (09:17 -0700)]
x86/cpu: Add model number for another Intel Arrow Lake mobile processor

This one is the regular laptop CPU.

Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20240322161725.195614-1-tony.luck@intel.com
6 months agox86/fpu: Keep xfd_state in sync with MSR_IA32_XFD
Adamos Ttofari [Fri, 22 Mar 2024 23:04:39 +0000 (16:04 -0700)]
x86/fpu: Keep xfd_state in sync with MSR_IA32_XFD

Commit 672365477ae8 ("x86/fpu: Update XFD state where required") and
commit 8bf26758ca96 ("x86/fpu: Add XFD state to fpstate") introduced a
per CPU variable xfd_state to keep the MSR_IA32_XFD value cached, in
order to avoid unnecessary writes to the MSR.

On CPU hotplug MSR_IA32_XFD is reset to the init_fpstate.xfd, which
wipes out any stale state. But the per CPU cached xfd value is not
reset, which brings them out of sync.

As a consequence a subsequent xfd_update_state() might fail to update
the MSR which in turn can result in XRSTOR raising a #NM in kernel
space, which crashes the kernel.

To fix this, introduce xfd_set_state() to write xfd_state together
with MSR_IA32_XFD, and use it in all places that set MSR_IA32_XFD.

Fixes: 672365477ae8 ("x86/fpu: Update XFD state where required")
Signed-off-by: Adamos Ttofari <attofari@amazon.de>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20240322230439.456571-1-chang.seok.bae@intel.com
Closes: https://lore.kernel.org/lkml/20230511152818.13839-1-attofari@amazon.de

6 months agoDocumentation/x86: Document that resctrl bandwidth control units are MiB
Tony Luck [Fri, 22 Mar 2024 18:20:15 +0000 (11:20 -0700)]
Documentation/x86: Document that resctrl bandwidth control units are MiB

The memory bandwidth software controller uses 2^20 units rather than
10^6. See mbm_bw_count() which computes bandwidth using the "SZ_1M"
Linux define for 0x00100000.

Update the documentation to use MiB when describing this feature.
It's too late to fix the mount option "mba_MBps" as that is now an
established user interface.

Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20240322182016.196544-1-tony.luck@intel.com
6 months agoMerge tag 'timers-urgent-2024-03-23' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 23 Mar 2024 21:49:25 +0000 (14:49 -0700)]
Merge tag 'timers-urgent-2024-03-23' of git://git./linux/kernel/git/tip/tip

Pull timer fixes from Thomas Gleixner:
 "Two regression fixes for the timer and timer migration code:

   - Prevent endless timer requeuing which is caused by two CPUs racing
     out of idle. This happens when the last CPU goes idle and therefore
     has to ensure to expire the pending global timers and some other
     CPU come out of idle at the same time and the other CPU wins the
     race and expires the global queue. This causes the last CPU to
     chase ghost timers forever and reprogramming it's clockevent device
     endlessly.

     Cure this by re-evaluating the wakeup time unconditionally.

   - The split into local (pinned) and global timers in the timer wheel
     caused a regression for NOHZ full as it broke the idle tracking of
     global timers. On NOHZ full this prevents an self IPI being sent
     which in turn causes the timer to be not programmed and not being
     expired on time.

     Restore the idle tracking for the global timer base so that the
     self IPI condition for NOHZ full is working correctly again"

* tag 'timers-urgent-2024-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  timers: Fix removed self-IPI on global timer's enqueue in nohz_full
  timers/migration: Fix endless timer requeue after idle interrupts

6 months agoMerge tag 'timers-core-2024-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sat, 23 Mar 2024 21:42:45 +0000 (14:42 -0700)]
Merge tag 'timers-core-2024-03-23' of git://git./linux/kernel/git/tip/tip

Pull more clocksource updates from Thomas Gleixner:
 "A set of updates for clocksource and clockevent drivers:

   - A fix for the prescaler of the ARM global timer where the prescaler
     mask define only covered 4 bits while it is actully 8 bits wide.
     This obviously restricted the possible range of prescaler
     adjustments

   - A fix for the RISC-V timer which prevents a timer interrupt being
     raised while the timer is initialized

   - A set of device tree updates to support new system on chips in
     various drivers

   - Kernel-doc and other cleanups all over the place"

* tag 'timers-core-2024-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  clocksource/drivers/timer-riscv: Clear timer interrupt on timer initialization
  dt-bindings: timer: Add support for cadence TTC PWM
  clocksource/drivers/arm_global_timer: Simplify prescaler register access
  clocksource/drivers/arm_global_timer: Guard against division by zero
  clocksource/drivers/arm_global_timer: Make gt_target_rate unsigned long
  dt-bindings: timer: add Ralink SoCs system tick counter
  clocksource: arm_global_timer: fix non-kernel-doc comment
  clocksource/drivers/arm_global_timer: Remove stray tab
  clocksource/drivers/arm_global_timer: Fix maximum prescaler value
  clocksource/drivers/imx-sysctr: Add i.MX95 support
  clocksource/drivers/imx-sysctr: Drop use global variables
  dt-bindings: timer: nxp,sysctr-timer: support i.MX95
  dt-bindings: timer: renesas: ostm: Document RZ/Five SoC
  dt-bindings: timer: renesas,tmu: Document input capture interrupt
  clocksource/drivers/ti-32K: Fix misuse of "/**" comment
  clocksource/drivers/stm32: Fix all kernel-doc warnings
  dt-bindings: timer: exynos4210-mct: Add google,gs101-mct compatible
  clocksource/drivers/imx: Fix -Wunused-but-set-variable warning

6 months agoMerge tag 'irq-urgent-2024-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sat, 23 Mar 2024 21:30:38 +0000 (14:30 -0700)]
Merge tag 'irq-urgent-2024-03-23' of git://git./linux/kernel/git/tip/tip

Pull irq fixes from Thomas Gleixner:
 "A series of fixes for the Renesas RZG21 interrupt chip driver to
  prevent spurious and misrouted interrupts.

   - Ensure that posted writes are flushed in the eoi() callback

   - Ensure that interrupts are masked at the chip level when the
     trigger type is changed

   - Clear the interrupt status register when setting up edge type
     trigger modes

   - Ensure that the trigger type and routing information is set before
     the interrupt is enabled"

* tag 'irq-urgent-2024-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  irqchip/renesas-rzg2l: Do not set TIEN and TINT source at the same time
  irqchip/renesas-rzg2l: Prevent spurious interrupts when setting trigger type
  irqchip/renesas-rzg2l: Rename rzg2l_irq_eoi()
  irqchip/renesas-rzg2l: Rename rzg2l_tint_eoi()
  irqchip/renesas-rzg2l: Flush posted write in irq_eoi()

6 months agoMerge tag 'core-entry-2024-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sat, 23 Mar 2024 21:17:37 +0000 (14:17 -0700)]
Merge tag 'core-entry-2024-03-23' of git://git./linux/kernel/git/tip/tip

Pull core entry fix from Thomas Gleixner:
 "A single fix for the generic entry code:

  The trace_sys_enter() tracepoint can modify the syscall number via
  kprobes or BPF in pt_regs, but that requires that the syscall number
  is re-evaluted from pt_regs after the tracepoint.

  A seccomp fix in that area removed the re-evaluation so the change
  does not take effect as the code just uses the locally cached number.

  Restore the original behaviour by re-evaluating the syscall number
  after the tracepoint"

* tag 'core-entry-2024-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  entry: Respect changes to system call number by trace_sys_enter()

6 months agoMerge tag 'powerpc-6.9-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
Linus Torvalds [Sat, 23 Mar 2024 16:21:26 +0000 (09:21 -0700)]
Merge tag 'powerpc-6.9-2' of git://git./linux/kernel/git/powerpc/linux

Pull more powerpc updates from Michael Ellerman:

 - Handle errors in mark_rodata_ro() and mark_initmem_nx()

 - Make struct crash_mem available without CONFIG_CRASH_DUMP

Thanks to Christophe Leroy and Hari Bathini.

* tag 'powerpc-6.9-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
  powerpc/kdump: Split KEXEC_CORE and CRASH_DUMP dependency
  powerpc/kexec: split CONFIG_KEXEC_FILE and CONFIG_CRASH_DUMP
  kexec/kdump: make struct crash_mem available without CONFIG_CRASH_DUMP
  powerpc: Handle error in mark_rodata_ro() and mark_initmem_nx()