Skip to content

Add SW_TABLET_MODE support for AMD SFH convertibles

Basavaraj Natikar linux-input 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest5 patches 2 repliesIn review
  2. v25 patches 2 repliesSuperseded
  3. v13 patches 0 repliesSuperseded

Changes in v3 from the cover letter

- Destroy the tablet-mode auxiliary device before the hardware teardown in .remove(), instead of from a devres action that runs afterwards, closing a use-after-teardown window (Sashiko review).
- Move the Makefile entry to its correct alphabetical position (Dmitry Torokhov).

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5HID: amd_sfh: Track MP2 version explicitlydrivers/hid/amd-sfh-hid/amd_sfh_common.h drivers/hid/amd-sfh-hid/amd_sfh_pcie.c+11 -40 replies
2/5HID: amd_sfh: Serialize access to the shared emp2 pointerdrivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c+6 -00 replies
3/5HID: amd_sfh: Add accessor to read the operating-mode sensordrivers/hid/amd-sfh-hid/amd_sfh_client.c drivers/hid/amd-sfh-hid/amd_sfh_common.h drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +3 more+72 -10 replies
4/5HID: amd_sfh: Register tablet-mode auxiliary devicedrivers/hid/amd-sfh-hid/Kconfig drivers/hid/amd-sfh-hid/amd_sfh_common.h drivers/hid/amd-sfh-hid/amd_sfh_pcie.c+53 -00 replies
5/5Input: misc: Add AMD SFH tablet-mode switch driverMAINTAINERS drivers/input/misc/Kconfig drivers/input/misc/Makefile +1 more+98 -00 replies

Reviews trailers per patch

1 of 5 patches has a Reviewed-by or Acked-by.

PatchDmitry Torokhov
1/5
2/5
3/5
4/5
5/5A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/5] Add SW_TABLET_MODE support for AMD SFH convertibles

Add SW_TABLET_MODE support for AMD convertibles whose operating mode (laptop or tablet) is reported by the Sensor Fusion Hub.

Patches 1 and 2 are preparation: the first tracks the MP2 version explicitly and the second serializes access to the shared emp2 pointer. The third adds a way to read the operating mode. The fourth registers an auxiliary device when the sensor is present, and the fifth is a small input driver that binds to it and reports the posture to userspace. Keeping the input handling in its own driver avoids pulling input/evdev into the sensor transport driver.

Changes in v3:
- Destroy the tablet-mode auxiliary device before the hardware teardown in .remove(), instead of from a devres action that runs afterwards, closing a use-after-teardown window (Sashiko review).
- Move the Makefile entry to its correct alphabetical position (Dmitry Torokhov).

Changes in v2 (address the Sashiko review of v1):
- Read the operating-mode register only on confirmed MP2 v2, by tracking the MP2 version explicitly. On v1.0 that register overlaps the 64-bit DMA address programmed through C2P, so the earlier unconditional read could return DMA bits instead of the operating mode.
- Serialize the shared emp2 pointer and all exported readers under a mutex, so a concurrent unbind can no longer free the device while a reader is still dereferencing it.
- Publish emp2 only after initialization has populated the client data, and clear it early on the MP2 v2 remove path instead of from a prematurely registered devres action; this removes both the publish-before-init data race and the unconditional global clear on a probe failure.
- Destroy the tablet-mode auxiliary device and release its id on removal, and allocate the id dynamically so multiple instances cannot collide.
- Report the initial tablet-mode state before registering the input device, so userspace never observes a stale default posture.
- Rename the error variable from 'rc' to 'error' to follow the input-subsystem convention.

v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

Basavaraj Natikar (5):
HID: amd_sfh: Track MP2 version explicitly
HID: amd_sfh: Serialize access to the shared emp2 pointer
HID: amd_sfh: Add accessor to read the operating-mode sensor
HID: amd_sfh: Register tablet-mode auxiliary device
Input: misc: Add AMD SFH tablet-mode switch driver

 MAINTAINERS                                   |  1 +
 drivers/hid/amd-sfh-hid/Kconfig               |  1 +
 drivers/hid/amd-sfh-hid/amd_sfh_client.c      | 16 ++++
 drivers/hid/amd-sfh-hid/amd_sfh_common.h      | 13 +++
 drivers/hid/amd-sfh-hid/amd_sfh_pcie.c        | 63 ++++++++++++++-
 .../amd-sfh-hid/sfh1_1/amd_sfh_interface.c    | 39 +++++++++
 .../amd-sfh-hid/sfh1_1/amd_sfh_interface.h    |  1 -
 drivers/input/misc/Kconfig                    | 15 ++++
 drivers/input/misc/Makefile                   |  1 +
 drivers/input/misc/amd_sfh_tabletmode.c       | 81 +++++++++++++++++++
 include/linux/amd-pmf-io.h                    | 14 ++++
 11 files changed, 240 insertions(+), 5 deletions(-)
 create mode 100644 drivers/input/misc/amd_sfh_tabletmode.c
Signature · 1 line
2.34.1