platform/x86: thinkpad_acpi: Add USB-C Security (USCS) support
Subsystems (5)
PATCH v4 1/1 platform/x86: thinkpad_acpi: Add USB-C Security (USCS) support
Newer ThinkPad systems expose a USB-C Security (Restricted Mode) feature. When active, USB-C data connections are disabled while power delivery is preserved. This is useful for kiosk and physically-secured deployments.
Hardware interface:
The HKEY device exposes a read-only ACPI method USCS():
Return value bit layout:
Bit 16 : Capability flag (1 = feature present on this SKU) Bit 0 : Current state (0 = security OFF, 1 = security ON)
The sysfs attribute is read-only.
The Fn+U followed by Fn+S hotkey chord is the only way to toggle the hardware state.
Hotkey:
Fn+U followed by Fn+S generates HKEY event 0x131e.
sysfs interface:
/sys/devices/platform/thinkpad_acpi/usb_c_security (read-only) "enabled\n" -- data connections are currently blocked "disabled\n" -- data connections are currently allowed
The attribute is hidden on SKUs where the USCS capability bit (bit 16) is not set, so there is no ABI impact on unsupported hardware.
---
Changes since v3:
- Add comment to usbc_security_mutex documenting what the lock protects
Changes since v2:
- Move usbc_security_enabled out of tp_features bitfield to a bool member of tp_features to avoid unsafe concurrent bitfield RMW; usbc_security_supported remains a bitfield as it is init-only.
- Pass &tp_features.usbc_security_enabled directly to usbc_security_query() removing the local bool intermediary in both init and hotkey paths.
- Remove extra blank line before */ in block comment.
- Fix kerneldoc Returns: syntax and rewrite return value description to match the int return type.
- Split ternary return into two separate if statements for clarity
Changes since v1:
- Use guard(mutex) from cleanup.h instead of manual mutex_lock/unlock
- Revert usbc_security_query() to return int (-EIO/-ENODEV/0) instead of bool to avoid uninitialized *enabled bug on unsupported platforms
- Remove !! when assigning to bool in usbc_security_query()
- Remove dead tp_features.usbc_security_supported check in show() since is_visible() already gates the attribute on unsupported SKUs
- Use str_enabled_disabled() from string_choices.h in show()
- Fix uninitialized *enabled bug in tpacpi_usbc_security_init() by only assigning usbc_security_enabled after a successful query
--- .../admin-guide/laptops/thinkpad-acpi.rst | 24 ++++ drivers/platform/x86/lenovo/thinkpad_acpi.c | 117 ++++++++++++++++++ 2 files changed, 141 insertions(+)
Documentation/admin-guide/laptops/thinkpad-acpi.rst +24 -0
@@ -1543,6 +1543,30 @@ Values: This setting can also be toggled via the Fn+doubletap hotkey. +USB-C Security +-------------- + +sysfs: usb_c_security + +Reports the current state of the USB-C Security (Restricted Mode) feature +on supported ThinkPad systems. When enabled, USB-C data connections are +disabled while power delivery is preserved. + +The available command is:: + + cat /sys/devices/platform/thinkpad_acpi/usb_c_security + +Values: + + * ``enabled`` - USB-C data connections are currently blocked + * ``disabled`` - USB-C data connections are currently allowed + +The attribute is read-only. The USB-C Security state can only be toggled +via the Fn+U followed by Fn+S hotkey chord. + +The sysfs attribute is not created on platforms that do not support this +feature. + Auxmac ------
drivers/platform/x86/lenovo/thinkpad_acpi.c +117 -0
165 lines not on this page · raw message
Signature · 1 line
2.51.0
Ilpo Järvinen
maintainerQuoted 9 lines · Vishnu Sankar
Newer ThinkPad systems expose a USB-C Security (Restricted Mode) feature. When active, USB-C data connections are disabled while power delivery is preserved. This is useful for kiosk and physically-secured deployments.
Hardware interface:
The HKEY device exposes a read-only ACPI method
USCS():[...]
Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.
FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.
The list of commits applied:
[1/1] platform/x86: thinkpad_acpi: Add USB-C Security (USCS) support
commit: 740f324f8f036607d59c05ab2b2fc22231c9641d
--
i.
Quoted 9 lines · Ilpo Järvinen
Quoted 6 lines · Vishnu Sankar
Newer ThinkPad systems expose a USB-C Security (Restricted Mode) feature. When active, USB-C data connections are disabled while power delivery is preserved. This is useful for kiosk and physically-secured deployments.
Hardware interface:
Quoted 9 lines
Quoted 3 lines
The HKEY device exposes a read-only ACPI method
USCS():[...]
Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.
Thank you for accepting this.
Understood.
Quoted 5 lines
FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.
Got it.
Quoted 7 lines
The list of commits applied:
[1/1] platform/x86:thinkpad_acpi: Add USB-C Security (USCS) supportcommit: 740f324f8f036607d59c05ab2b2fc22231c9641d--
i.
Signature · 3 lines
Regards,
Vishnu SankarHi Vishnu,
I tested v4 on a Lenovo ThinkPad P15 Gen 1.
System:
- Lenovo ThinkPad P15 Gen 1
- BIOS: N30ET47W (1.30)
- Kernel: 7.2.0-rc2 + this patch
I checked the BIOS setup and could not find any USB-C Security (USCS) option.
During boot, I get:
``` thinkpad_acpi: acpi_evalf(USCS, dd, ...) failed: AE_NOT_FOUND thinkpad_acpi: required events 0x00720000 not enabled! thinkpad_acpi: probe with driver thinkpad_acpi failed with error -5 thinkpad_acpi: unable to register main platform driver ```
As a result, thinkpad_acpi fails to probe and /sys/devices/platform/thinkpad_acpi/ is not created.
It looks like systems without the USCS ACPI method may fail to load thinkpad_acpi with this patch applied.
Please let me know if you would like me to provide the full dmesg log or
test a revised version.
If needed, I can also test on a ThinkPad P50s.
Thanks,
Oliver Lin
Hi Oliver,
Thank you for testing and reporting this.
On systems where the USCS ACPI method does not exist, acpi_evalf() returns AE_NOT_FOUND which maps to -EIO rather than -ENODEV. This causes tpacpi_usbc_security_init() to propagate the error and thinkpad_acpi fails to probe entirely.
Apologies for missing this — I only tested on a system that has the USCS method present.
I believe the fix is to check for USCS method presence before attempting to call it, using acpi_has_method() which is already used elsewhere in the driver for the same purpose:
static int tpacpi_usbc_security_init(struct ibm_init_struct *iibm)
{
int err; if (!acpi_has_method(hkey_handle, "USCS"))
return -ENODEV;
err = usbc_security_query(&tp_features.usbc_security_enabled);
if (err == -ENODEV)
return -ENODEV;
if (err)
return err;
tp_features.usbc_security_supported = true;
return 0;}
I am expecting this change to fix the issue (not yet tested).
Ilpo,
since this is already in your tree, please let me know if you would like me to send a fixup patch or if you prefer to handle it directly or if you prefer a v5 with this addressed.
Sorry for the inconvenience caused.
Thanks and regards,
Vishnu
Quoted 42 lines · Oliver Lin
Hi Vishnu,
I tested v4 on a Lenovo ThinkPad P15 Gen 1.
System:
- Lenovo ThinkPad P15 Gen 1
- BIOS: N30ET47W (1.30)
- Kernel: 7.2.0-rc2 + this patchI checked the BIOS setup and could not find any USB-C Security (USCS) option.
During boot, I get:
``` thinkpad_acpi: acpi_evalf(USCS, dd, ...) failed: AE_NOT_FOUND thinkpad_acpi: required events 0x00720000 not enabled! thinkpad_acpi: probe with driver thinkpad_acpi failed with error -5 thinkpad_acpi: unable to register main platform driver ```As a result,
thinkpad_acpifails to probe and/sys/devices/platform/thinkpad_acpi/is not created.It looks like systems without the USCS ACPI method may fail to load
thinkpad_acpiwith this patch applied.Please let me know if you would like me to provide the full dmesg log or
test a revised version.
If needed, I can also test on a ThinkPad P50s.
Thanks,
Oliver Lin
Signature · 3 lines
Regards,
Vishnu SankarHi Vishnu,
Thanks for the quick analysis.
Your proposed fix makes sense to me.
Please send a follow-up patch and I'll be happy to test it on both my ThinkPad P15 Gen 1 and ThinkPad P50s.
Thanks!
Oliver Lin