projects/linux·commit 614da38e

Merge tag 'hid-for-linus-2024051401' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid

614da38e · Linus Torvalds <[email protected]> · 2024-05-14 15:12:46 -07:00

Pull HID updates from Jiri Kosina:

 - Firmware loading from host support in intel-ish driver, needed to
   support Lunar Lake and later (Zhang Lixu)

 - updates to HID-BPF infrastructure, with some of the specific fixes
   (e.g. rdesc fixups) abstracted into separate BPF programs for
   consumption from libevdev/udev-hid-bpf (Benjamin Tissoires)

 - support for Deck IMU in hid-steam (Max Maisel)

 - fixes for better support of 3rd party playstation DS4 controllers
   (Max Staudt)

 - support for missing mappings and codes from HUT 1.5 in hid-debug
   (Thomas Kuehne)

 - initial support for ROG Ally and ROG X13 devices (Luke D. Jones)

 - full support for WinWing Orion2 (Ivan Gorinov)

* tag 'hid-for-linus-2024051401' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: (74 commits)
  selftests/hid: skip tests with HID-BPF if udev-hid-bpf is not installed
  selftests/hid: add tests for the Raptor Mach 2 joystick
  selftests/hid: move the gamepads definitions in the test file
  selftests/hid: import base_gamepad.py from hid-tools
  selftests/hid: add Huion Kamvas Pro 19 tests
  selftests/hid: tablets: also check for XP-Pen offset correction
  selftests/hid: tablets: add a couple of XP-PEN tablets
  selftests/hid: tablets: reduce the number of pen state
  selftests/hid: add support for HID-BPF pre-loading before starting a test
  selftests/hid: import base_device.py from hid-tools
  HID: bpf: add in-tree HID-BPF fix for the Raptor Mach 2
  HID: bpf: add in-tree HID-BPF fix for the Huion Kamvas Pro 19
  HID: bpf: add in-tree HID-BPF fix for the XBox Elite 2 over Bluetooth
  HID: bpf: add in-tree HID-BPF fix for the Wacom ArtPen
  HID: bpf: add in-tree HID-BPF fix for the IOGear Kaliber Gaming MMOmentum mouse
  HID: bpf: add in-tree HID-BPF fix for the HP Elite Presenter Mouse
  HID: bpf: add in-tree HID-BPF fix for the XPPen Artist 16
  HID: bpf: add first in-tree HID-BPF fix for the XPPen Artist 24
  HID: do not assume HAT Switch logical max < 8
  HID: amd_sfh: Use amd_get_c2p_val() to read C2P register
  ...
Commit
614da38e2f7afe9e01c6e359dfa09285f26fa381
Parents
ce952d8f · c9c92fc4

Merge commit. Changes below are compared with the first parent: ce952d8f.

Changes

66 files changed · +8301 −1093

FileStatusAddDelContent
Documentation/hid/hid-bpf.rstmodified+1−1View file
Documentation/hid/intel-ish-hid.rstmodified+101−36View file
drivers/hid/Kconfigmodified+16−0View file
drivers/hid/Makefilemodified+1−0View file
drivers/hid/amd-sfh-hid/amd_sfh_pcie.cmodified+1−4View file
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.cmodified+14−3View file
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.cmodified+1−1View file
drivers/hid/bpf/hid_bpf_dispatch.cmodified+155−71View file
drivers/hid/bpf/progs/FR-TEC__Raptor-Mach-2.bpf.cadded+185−0View file
drivers/hid/bpf/progs/HP__Elite-Presenter.bpf.cadded+58−0View file
drivers/hid/bpf/progs/Huion__Kamvas-Pro-19.bpf.cadded+290−0View file
drivers/hid/bpf/progs/IOGEAR__Kaliber-MMOmentum.bpf.cadded+59−0View file
drivers/hid/bpf/progs/Makefileadded+91−0View file
drivers/hid/bpf/progs/Microsoft__XBox-Elite-2.bpf.cadded+133−0View file
drivers/hid/bpf/progs/READMEadded+102−0View file
drivers/hid/bpf/progs/Wacom__ArtPen.bpf.cadded+173−0View file
drivers/hid/bpf/progs/XPPen__Artist24.bpf.cadded+229−0View file
drivers/hid/bpf/progs/XPPen__ArtistPro16Gen2.bpf.cadded+274−0View file
drivers/hid/bpf/progs/hid_bpf.hadded+15−0View file
drivers/hid/bpf/progs/hid_bpf_helpers.hadded+168−0View file
drivers/hid/hid-asus.cmodified+52−80View file
drivers/hid/hid-core.cmodified+2−0View file
drivers/hid/hid-corsair.cmodified+2−2View file
drivers/hid/hid-debug.cmodified+2995−442View file
drivers/hid/hid-google-hammer.cmodified+2−3View file
drivers/hid/hid-ids.hmodified+3−0View file
drivers/hid/hid-kye.cmodified+44−31View file
drivers/hid/hid-lenovo.cmodified+10−13View file
drivers/hid/hid-logitech-hidpp.cmodified+12−2View file
drivers/hid/hid-multitouch.cmodified+6−0View file
drivers/hid/hid-nintendo.cmodified+33−24View file
drivers/hid/hid-picolcd_core.cmodified+3−3View file
drivers/hid/hid-picolcd_fb.cmodified+3−5View file
drivers/hid/hid-playstation.cmodified+93−45View file
drivers/hid/hid-roccat-isku.cmodified+1−1View file
drivers/hid/hid-roccat-kone.cmodified+6−6View file
drivers/hid/hid-roccat-koneplus.cmodified+2−2View file
drivers/hid/hid-roccat-kovaplus.cmodified+5−5View file
drivers/hid/hid-roccat-pyra.cmodified+3−3View file
drivers/hid/hid-sensor-custom.cmodified+7−10View file
drivers/hid/hid-sony.cmodified+2−5View file
drivers/hid/hid-steam.cmodified+147−8View file
drivers/hid/hid-uclogic-params.cmodified+3−0View file
drivers/hid/hid-winwing.cadded+226−0View file
drivers/hid/i2c-hid/i2c-hid-core.cmodified+27−17View file
drivers/hid/intel-ish-hid/Makefilemodified+1−0View file
drivers/hid/intel-ish-hid/ipc/hw-ish.hmodified+23−22View file
drivers/hid/intel-ish-hid/ipc/ipc.cmodified+11−10View file
drivers/hid/intel-ish-hid/ipc/pci-ish.cmodified+51−29View file
drivers/hid/intel-ish-hid/ishtp/hbm.cmodified+21−0View file
drivers/hid/intel-ish-hid/ishtp/init.cmodified+8−0View file
drivers/hid/intel-ish-hid/ishtp/ishtp-dev.hmodified+28−0View file
drivers/hid/intel-ish-hid/ishtp/loader.cadded+275−0View file
drivers/hid/intel-ish-hid/ishtp/loader.hadded+226−0View file
drivers/hid/surface-hid/surface_kbd.cmodified+2−3View file
include/linux/hid.hmodified+3−3View file
include/linux/hid_bpf.hmodified+3−0View file
tools/testing/selftests/hid/config.commonmodified+1−0View file
tools/testing/selftests/hid/hid_bpf.cmodified+110−2View file
tools/testing/selftests/hid/progs/hid.cmodified+46−0View file
tools/testing/selftests/hid/progs/hid_bpf_helpers.hmodified+6−0View file
tools/testing/selftests/hid/tests/base.pymodified+83−9View file
tools/testing/selftests/hid/tests/base_device.pyadded+421−0View file
tools/testing/selftests/hid/tests/base_gamepad.pyadded+238−0View file
tools/testing/selftests/hid/tests/test_gamepad.pymodified+456−1View file
tools/testing/selftests/hid/tests/test_tablet.pymodified+532−191View file

Only the first 600 diff lines are shown. Download the complete patch.

Documentation/hid/hid-bpf.rst

View file
diff --git a/Documentation/hid/hid-bpf.rst b/Documentation/hid/hid-bpf.rst
index 4fad83a..0765b32 100644
--- a/Documentation/hid/hid-bpf.rst
+++ b/Documentation/hid/hid-bpf.rst
@@ -179,7 +179,7 @@ Available API that can be used in syscall HID-BPF programs:
-----------------------------------------------------------
.. kernel-doc:: drivers/hid/bpf/hid_bpf_dispatch.c
- :functions: hid_bpf_attach_prog hid_bpf_hw_request hid_bpf_allocate_context hid_bpf_release_context
+ :functions: hid_bpf_attach_prog hid_bpf_hw_request hid_bpf_hw_output_report hid_bpf_input_report hid_bpf_allocate_context hid_bpf_release_context
General overview of a HID-BPF program
=====================================

Documentation/hid/intel-ish-hid.rst

View file
diff --git a/Documentation/hid/intel-ish-hid.rst b/Documentation/hid/intel-ish-hid.rst
index 42dc77b..55cbaa7 100644
--- a/Documentation/hid/intel-ish-hid.rst
+++ b/Documentation/hid/intel-ish-hid.rst
@@ -18,8 +18,8 @@ These ISH also comply to HID sensor specification, but the difference is the
transport protocol used for communication. The current external sensor hubs
mainly use HID over I2C or USB. But ISH doesn't use either I2C or USB.
-1. Overview
-===========
+Overview
+========
Using a analogy with a usbhid implementation, the ISH follows a similar model
for a very high speed communication::
@@ -58,8 +58,8 @@ implemented as a bus. Each client application executing in the ISH processor
is registered as a device on this bus. The driver, which binds each device
(ISH HID driver) identifies the device type and registers with the HID core.
-2. ISH Implementation: Block Diagram
-====================================
+ISH Implementation: Block Diagram
+=================================
::
@@ -96,27 +96,27 @@ is registered as a device on this bus. The driver, which binds each device
| ISH Hardware/Firmware(FW) |
----------------------------
-3. High level processing in above blocks
-========================================
+High level processing in above blocks
+=====================================
-3.1 Hardware Interface
-----------------------
+Hardware Interface
+------------------
The ISH is exposed as "Non-VGA unclassified PCI device" to the host. The PCI
product and vendor IDs are changed from different generations of processors. So
the source code which enumerates drivers needs to update from generation to
generation.
-3.2 Inter Processor Communication (IPC) driver
-----------------------------------------------
+Inter Processor Communication (IPC) driver
+------------------------------------------
Location: drivers/hid/intel-ish-hid/ipc
The IPC message uses memory mapped I/O. The registers are defined in
hw-ish-regs.h.
-3.2.1 IPC/FW message types
-^^^^^^^^^^^^^^^^^^^^^^^^^^
+IPC/FW message types
+^^^^^^^^^^^^^^^^^^^^
There are two types of messages, one for management of link and another for
messages to and from transport layers.
@@ -142,20 +142,20 @@ register has the following format::
Bit 31: doorbell trigger (signal H/W interrupt to the other side)
Other bits are reserved, should be 0.
-3.2.2 Transport layer interface
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Transport layer interface
+^^^^^^^^^^^^^^^^^^^^^^^^^
To abstract HW level IPC communication, a set of callbacks is registered.
The transport layer uses them to send and receive messages.
Refer to struct ishtp_hw_ops for callbacks.
-3.3 ISH Transport layer
------------------------
+ISH Transport layer
+-------------------
Location: drivers/hid/intel-ish-hid/ishtp/
-3.3.1 A Generic Transport Layer
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+A Generic Transport Layer
+^^^^^^^^^^^^^^^^^^^^^^^^^
The transport layer is a bi-directional protocol, which defines:
- Set of commands to start, stop, connect, disconnect and flow control
@@ -166,8 +166,8 @@ This protocol resembles bus messages described in the following document:
http://www.intel.com/content/dam/www/public/us/en/documents/technical-\
specifications/dcmi-hi-1-0-spec.pdf "Chapter 7: Bus Message Layer"
-3.3.2 Connection and Flow Control Mechanism
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Connection and Flow Control Mechanism
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Each FW client and a protocol is identified by a UUID. In order to communicate
to a FW client, a connection must be established using connect request and
@@ -181,8 +181,8 @@ before receiving the next flow control credit.
Either side can send disconnect request bus message to end communication. Also
the link will be dropped if major FW reset occurs.
-3.3.3 Peer to Peer data transfer
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Peer to Peer data transfer
+^^^^^^^^^^^^^^^^^^^^^^^^^^
Peer to Peer data transfer can happen with or without using DMA. Depending on
the sensor bandwidth requirement DMA can be enabled by using module parameter
@@ -217,8 +217,8 @@ In principle, multiple DMA_XFER and DMA_XFER_ACK messages may be sent at once
Currently, ISH FW decides to send over DMA if ISHTP message is more than 3 IPC
fragments and via IPC otherwise.
-3.3.4 Ring Buffers
-^^^^^^^^^^^^^^^^^^
+Ring Buffers
+^^^^^^^^^^^^
When a client initiates a connection, a ring of RX and TX buffers is allocated.
The size of ring can be specified by the client. HID client sets 16 and 32 for
@@ -228,8 +228,8 @@ bus message protocol. These buffers are required because the FW may have not
have processed the last message and may not have enough flow control credits
to send. Same thing holds true on receive side and flow control is required.
-3.3.5 Host Enumeration
-^^^^^^^^^^^^^^^^^^^^^^
+Host Enumeration
+^^^^^^^^^^^^^^^^
The host enumeration bus command allows discovery of clients present in the FW.
There can be multiple sensor clients and clients for calibration function.
@@ -252,8 +252,8 @@ Enumeration sequence of messages:
- Once host received properties for that last discovered client, it considers
ISHTP device fully functional (and allocates DMA buffers)
-3.4 HID over ISH Client
------------------------
+HID over ISH Client
+-------------------
Location: drivers/hid/intel-ish-hid
@@ -265,16 +265,16 @@ The ISHTP client driver is responsible for:
- Process Get/Set feature request
- Get input reports
-3.5 HID Sensor Hub MFD and IIO sensor drivers
----------------------------------------------
+HID Sensor Hub MFD and IIO sensor drivers
+-----------------------------------------
The functionality in these drivers is the same as an external sensor hub.
Refer to
Documentation/hid/hid-sensor.rst for HID sensor
Documentation/ABI/testing/sysfs-bus-iio for IIO ABIs to user space.
-3.6 End to End HID transport Sequence Diagram
----------------------------------------------
+End to End HID transport Sequence Diagram
+-----------------------------------------
::
@@ -339,16 +339,81 @@ Documentation/ABI/testing/sysfs-bus-iio for IIO ABIs to user space.
| | | |
-3.7 ISH Debugging
------------------
+ISH Firmware Loading from Host Flow
+-----------------------------------
+
+Starting from the Lunar Lake generation, the ISH firmware has been divided into two components for better space optimization and increased flexibility. These components include a bootloader that is integrated into the BIOS, and a main firmware that is stored within the operating system's file system.
+
+The process works as follows:
+
+- Initially, the ISHTP driver sends a command, HOST_START_REQ_CMD, to the ISH bootloader. In response, the bootloader sends back a HOST_START_RES_CMD. This response includes the ISHTP_SUPPORT_CAP_LOADER bit. Subsequently, the ISHTP driver checks if this bit is set. If it is, the firmware loading process from the host begins.
+
+- During this process, the ISHTP driver first invokes the request_firmware() function, followed by sending a LOADER_CMD_XFER_QUERY command. Upon receiving a response from the bootloader, the ISHTP driver sends a LOADER_CMD_XFER_FRAGMENT command. After receiving another response, the ISHTP driver sends a LOADER_CMD_START command. The bootloader responds and then proceeds to the Main Firmware.
+
+- After the process concludes, the ISHTP driver calls the release_firmware() function.
+
+For more detailed information, please refer to the flow descriptions provided below:
+
+::
+
+ +---------------+ +-----------------+
+ | ISHTP Driver | | ISH Bootloader |
+ +---------------+ +-----------------+
+ | |
+ |~~~Send HOST_START_REQ_CMD~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>|
+ | |
+ |<--Send HOST_START_RES_CMD(Includes ISHTP_SUPPORT_CAP_LOADER bit)----|
+ | |
+ ****************************************************************************************
+ * if ISHTP_SUPPORT_CAP_LOADER bit is set *
+ ****************************************************************************************
+ | |
+ |~~~start loading firmware from host process~~~+ |
+ | | |
+ |<---------------------------------------------+ |
+ | |
+ --------------------------- |
+ | Call request_firmware() | |
+ --------------------------- |
+ | |
+ |~~~Send LOADER_CMD_XFER_QUERY~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>|
+ | |
+ |<--Send response-----------------------------------------------------|
+ | |
+ |~~~Send LOADER_CMD_XFER_FRAGMENT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>|
+ | |
+ |<--Send response-----------------------------------------------------|
+ | |
+ |~~~Send LOADER_CMD_START~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>|
+ | |
+ |<--Send response-----------------------------------------------------|
+ | |
+ | |~~~Jump to Main Firmware~~~+
+ | | |
+ | |<--------------------------+
+ | |
+ --------------------------- |
+ | Call release_firmware() | |
+ --------------------------- |
+ | |
+ ****************************************************************************************
+ * end if *
+ ****************************************************************************************
+ | |
+ +---------------+ +-----------------+
+ | ISHTP Driver | | ISH Bootloader |
+ +---------------+ +-----------------+
+
+ISH Debugging
+-------------
To debug ISH, event tracing mechanism is used. To enable debug logs::
echo 1 > /sys/kernel/tracing/events/intel_ish/enable
cat /sys/kernel/tracing/trace
-3.8 ISH IIO sysfs Example on Lenovo thinkpad Yoga 260
------------------------------------------------------
+ISH IIO sysfs Example on Lenovo thinkpad Yoga 260
+-------------------------------------------------
::

drivers/hid/Kconfig

View file
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 4c682c6..08446c8 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -1236,6 +1236,22 @@ config HID_WIIMOTE
To compile this driver as a module, choose M here: the
module will be called hid-wiimote.
+config HID_WINWING
+ tristate "WinWing Orion2 throttle support"
+ depends on USB_HID
+ depends on NEW_LEDS
+ depends on LEDS_CLASS
+ help
+ Support for WinWing Orion2 throttle base with the following grips:
+
+ * TGRIP-16EX
+ * TGRIP-18
+
+ This driver enables all buttons and switches on the throttle base.
+
+ To compile this driver as a module, choose M here: the
+ module will be called hid-winwing.
+
config HID_XINMO
tristate "Xin-Mo non-fully compliant devices"
help

drivers/hid/Makefile

View file
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 082a728..ce71b53 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -150,6 +150,7 @@ wacom-objs := wacom_wac.o wacom_sys.o
obj-$(CONFIG_HID_WACOM) += wacom.o
obj-$(CONFIG_HID_WALTOP) += hid-waltop.o
obj-$(CONFIG_HID_WIIMOTE) += hid-wiimote.o
+obj-$(CONFIG_HID_WINWING) += hid-winwing.o
obj-$(CONFIG_HID_SENSOR_HUB) += hid-sensor-hub.o
obj-$(CONFIG_HID_SENSOR_CUSTOM_SENSOR) += hid-sensor-custom.o

drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

View file
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
index 9e97c26..0c28ca3 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
@@ -333,14 +333,11 @@ static const struct dmi_system_id dmi_nodevs[] = {
static void sfh1_1_init_work(struct work_struct *work)
{
struct amd_mp2_dev *mp2 = container_of(work, struct amd_mp2_dev, work);
- struct pci_dev *pdev = mp2->pdev;
int rc;
rc = mp2->sfh1_1_ops->init(mp2);
- if (rc) {
- dev_err(&pdev->dev, "sfh1_1_init failed err %d\n", rc);
+ if (rc)
return;
- }
amd_sfh_clear_intr(mp2);
mp2->init_done = 1;

drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c

View file
diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c
index 5b24d5f..621793d 100644
--- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c
+++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c
@@ -202,7 +202,7 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
}
if (!cl_data->is_any_sensor_enabled) {
- dev_warn(dev, "Failed to discover, sensors not enabled is %d\n",
+ dev_warn(dev, "No sensor registered, sensors not enabled is %d\n",
cl_data->is_any_sensor_enabled);
rc = -EOPNOTSUPP;
goto cleanup;
@@ -227,6 +227,11 @@ static void amd_sfh_resume(struct amd_mp2_dev *mp2)
struct amd_mp2_sensor_info info;
int i, status;
+ if (!cl_data->is_any_sensor_enabled) {
+ amd_sfh_clear_intr(mp2);
+ return;
+ }
+
for (i = 0; i < cl_data->num_hid_devices; i++) {
if (cl_data->sensor_sts[i] == SENSOR_DISABLED) {
info.sensor_idx = cl_data->sensor_idx[i];
@@ -252,6 +257,11 @@ static void amd_sfh_suspend(struct amd_mp2_dev *mp2)
struct amdtp_cl_data *cl_data = mp2->cl_data;
int i, status;
+ if (!cl_data->is_any_sensor_enabled) {
+ amd_sfh_clear_intr(mp2);
+ return;
+ }
+
for (i = 0; i < cl_data->num_hid_devices; i++) {
if (cl_data->sensor_idx[i] != HPD_IDX &&
cl_data->sensor_sts[i] == SENSOR_ENABLED) {
@@ -320,7 +330,7 @@ int amd_sfh1_1_init(struct amd_mp2_dev *mp2)
memcpy_fromio(&binfo, mp2->vsbase, sizeof(struct sfh_base_info));
if (binfo.sbase.fw_info.fw_ver == 0 || binfo.sbase.s_list.sl.sensors == 0) {
- dev_dbg(dev, "failed to get sensors\n");
+ dev_dbg(dev, "No sensor registered\n");
return -EOPNOTSUPP;
}
dev_dbg(dev, "firmware version 0x%x\n", binfo.sbase.fw_info.fw_ver);
@@ -337,7 +347,8 @@ int amd_sfh1_1_init(struct amd_mp2_dev *mp2)
rc = amd_sfh1_1_hid_client_init(mp2);
if (rc) {
sfh_deinit_emp2();
- dev_err(dev, "amd_sfh1_1_hid_client_init failed\n");
+ if ((rc != -ENODEV) && (rc != -EOPNOTSUPP))
+ dev_err(dev, "amd_sfh1_1_hid_client_init failed\n");
return rc;
}

drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c

View file
diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c
index 2de2668..4676f06 100644
--- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c
+++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c
@@ -97,7 +97,7 @@ static int amd_sfh_hpd_info(u8 *user_present)
if (!emp2 || !emp2->dev_en.is_hpd_present)
return -ENODEV;
- hpdstatus.val = readl(emp2->mmio + AMD_C2P_MSG(4));
+ hpdstatus.val = readl(emp2->mmio + amd_get_c2p_val(emp2, 4));
*user_present = hpdstatus.shpd.presence;
return 0;

drivers/hid/bpf/hid_bpf_dispatch.c

View file
diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c b/drivers/hid/bpf/hid_bpf_dispatch.c
index e630caf..10289f4 100644
--- a/drivers/hid/bpf/hid_bpf_dispatch.c
+++ b/drivers/hid/bpf/hid_bpf_dispatch.c
@@ -143,48 +143,6 @@ u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, u8 *rdesc, unsigned int *s
}
EXPORT_SYMBOL_GPL(call_hid_bpf_rdesc_fixup);
-/* Disables missing prototype warnings */
-__bpf_kfunc_start_defs();
-
-/**
- * hid_bpf_get_data - Get the kernel memory pointer associated with the context @ctx
- *
- * @ctx: The HID-BPF context
- * @offset: The offset within the memory
- * @rdwr_buf_size: the const size of the buffer
- *
- * @returns %NULL on error, an %__u8 memory pointer on success
- */
-__bpf_kfunc __u8 *
-hid_bpf_get_data(struct hid_bpf_ctx *ctx, unsigned int offset, const size_t rdwr_buf_size)
-{
- struct hid_bpf_ctx_kern *ctx_kern;
-
- if (!ctx)
- return NULL;
-
- ctx_kern = container_of(ctx, struct hid_bpf_ctx_kern, ctx);
-
- if (rdwr_buf_size + offset > ctx->allocated_size)
- return NULL;
-
- return ctx_kern->data + offset;
-}
-__bpf_kfunc_end_defs();
-
-/*
- * The following set contains all functions we agree BPF programs
- * can use.
- */
-BTF_KFUNCS_START(hid_bpf_kfunc_ids)
-BTF_ID_FLAGS(func, hid_bpf_get_data, KF_RET_NULL)
-BTF_KFUNCS_END(hid_bpf_kfunc_ids)
-
-static const struct btf_kfunc_id_set hid_bpf_kfunc_set = {
- .owner = THIS_MODULE,
- .set = &hid_bpf_kfunc_ids,
-};
-
static int device_match_id(struct device *dev, const void *id)
{
struct hid_device *hdev = to_hid_device(dev);
@@ -282,6 +240,31 @@ static int do_hid_bpf_attach_prog(struct hid_device *hdev, int prog_fd, struct b
__bpf_kfunc_start_defs();
/**
+ * hid_bpf_get_data - Get the kernel memory pointer associated with the context @ctx
+ *
+ * @ctx: The HID-BPF context
+ * @offset: The offset within the memory
+ * @rdwr_buf_size: the const size of the buffer
+ *
+ * @returns %NULL on error, an %__u8 memory pointer on success
+ */
+__bpf_kfunc __u8 *
+hid_bpf_get_data(struct hid_bpf_ctx *ctx, unsigned int offset, const size_t rdwr_buf_size)
+{
+ struct hid_bpf_ctx_kern *ctx_kern;
+
+ if (!ctx)
+ return NULL;
+
+ ctx_kern = container_of(ctx, struct hid_bpf_ctx_kern, ctx);
+
+ if (rdwr_buf_size + offset > ctx->allocated_size)
+ return NULL;
+
+ return ctx_kern->data + offset;
+}
+
+/**
* hid_bpf_attach_prog - Attach the given @prog_fd to the given HID device
*
* @hid_id: the system unique identifier of the HID device
@@ -393,6 +376,46 @@ hid_bpf_release_context(struct hid_bpf_ctx *ctx)
put_device(&hid->dev);
}
+static int
+__hid_bpf_hw_check_params(struct hid_bpf_ctx *ctx, __u8 *buf, size_t *buf__sz,
+ enum hid_report_type rtype)
+{
+ struct hid_report_enum *report_enum;
+ struct hid_report *report;
+ struct hid_device *hdev;
+ u32 report_len;
+
+ /* check arguments */
+ if (!ctx || !hid_bpf_ops || !buf)
+ return -EINVAL;
+
+ switch (rtype) {
+ case HID_INPUT_REPORT:
+ case HID_OUTPUT_REPORT:
+ case HID_FEATURE_REPORT:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (*buf__sz < 1)
+ return -EINVAL;
+
+ hdev = (struct hid_device *)ctx->hid; /* discard const */
+
+ report_enum = hdev->report_enum + rtype;
+ report = hid_bpf_ops->hid_get_report(report_enum, buf);
+ if (!report)
+ return -EINVAL;
+
+ report_len = hid_report_len(report);
+
+ if (*buf__sz > report_len)
+ *buf__sz = report_len;
+
+ return 0;
+}
+
/**
* hid_bpf_hw_request - Communicate with a HID device
*
@@ -409,24 +432,14 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz,
enum hid_report_type rtype, enum hid_class_request reqtype)
{
struct hid_device *hdev;
- struct hid_report *report;
- struct hid_report_enum *report_enum;
+ size_t size = buf__sz;
u8 *dma_data;
- u32 report_len;
int ret;
/* check arguments */
- if (!ctx || !hid_bpf_ops || !buf)
- return -EINVAL;
-
- switch (rtype) {
- case HID_INPUT_REPORT:
- case HID_OUTPUT_REPORT:
- case HID_FEATURE_REPORT:
- break;
- default:
- return -EINVAL;
- }
+ ret = __hid_bpf_hw_check_params(ctx, buf, &size, rtype);
+ if (ret)
+ return ret;
switch (reqtype) {
case HID_REQ_GET_REPORT:
@@ -440,29 +453,16 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz,
return -EINVAL;
}
- if (buf__sz < 1)
- return -EINVAL;
-
hdev = (struct hid_device *)ctx->hid; /* discard const */
- report_enum = hdev->report_enum + rtype;
- report = hid_bpf_ops->hid_get_report(report_enum, buf);
- if (!report)
- return -EINVAL;
-
- report_len = hid_report_len(report);
-
- if (buf__sz > report_len)
- buf__sz = report_len;
-
- dma_data = kmemdup(buf, buf__sz, GFP_KERNEL);
+ dma_data = kmemdup(buf, size, GFP_KERNEL);
if (!dma_data)
return -ENOMEM;
ret = hid_bpf_ops->hid_hw_raw_request(hdev,
dma_data[0],
dma_data,
- buf__sz,
+ size,
rtype,
reqtype);
@@ -472,8 +472,90 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz,
kfree(dma_data);
return ret;
}
+
+/**
+ * hid_bpf_hw_output_report - Send an output report to a HID device
+ *
+ * @ctx: the HID-BPF context previously allocated in hid_bpf_allocate_context()
+ * @buf: a %PTR_TO_MEM buffer
+ * @buf__sz: the size of the data to transfer
+ *
+ * Returns the number of bytes transferred on success, a negative error code otherwise.
+ */
+__bpf_kfunc int

This diff is incomplete. Download the complete patch.

drivers/hid/bpf/progs/FR-TEC__Raptor-Mach-2.bpf.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/bpf/progs/HP__Elite-Presenter.bpf.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/bpf/progs/Huion__Kamvas-Pro-19.bpf.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/bpf/progs/IOGEAR__Kaliber-MMOmentum.bpf.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/bpf/progs/Makefile

View file

This diff is incomplete. Download the complete patch.

drivers/hid/bpf/progs/Microsoft__XBox-Elite-2.bpf.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/bpf/progs/README

View file

This diff is incomplete. Download the complete patch.

drivers/hid/bpf/progs/Wacom__ArtPen.bpf.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/bpf/progs/XPPen__Artist24.bpf.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/bpf/progs/XPPen__ArtistPro16Gen2.bpf.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/bpf/progs/hid_bpf.h

View file

This diff is incomplete. Download the complete patch.

drivers/hid/bpf/progs/hid_bpf_helpers.h

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-asus.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-core.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-corsair.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-debug.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-google-hammer.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-ids.h

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-kye.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-lenovo.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-logitech-hidpp.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-multitouch.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-nintendo.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-picolcd_core.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-picolcd_fb.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-playstation.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-roccat-isku.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-roccat-kone.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-roccat-koneplus.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-roccat-kovaplus.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-roccat-pyra.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-sensor-custom.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-sony.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-steam.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-uclogic-params.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/hid-winwing.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/i2c-hid/i2c-hid-core.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/intel-ish-hid/Makefile

View file

This diff is incomplete. Download the complete patch.

drivers/hid/intel-ish-hid/ipc/hw-ish.h

View file

This diff is incomplete. Download the complete patch.

drivers/hid/intel-ish-hid/ipc/ipc.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/intel-ish-hid/ipc/pci-ish.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/intel-ish-hid/ishtp/hbm.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/intel-ish-hid/ishtp/init.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h

View file

This diff is incomplete. Download the complete patch.

drivers/hid/intel-ish-hid/ishtp/loader.c

View file

This diff is incomplete. Download the complete patch.

drivers/hid/intel-ish-hid/ishtp/loader.h

View file

This diff is incomplete. Download the complete patch.

drivers/hid/surface-hid/surface_kbd.c

View file

This diff is incomplete. Download the complete patch.

include/linux/hid.h

View file

This diff is incomplete. Download the complete patch.

include/linux/hid_bpf.h

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/hid/config.common

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/hid/hid_bpf.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/hid/progs/hid.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/hid/progs/hid_bpf_helpers.h

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/hid/tests/base.py

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/hid/tests/base_device.py

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/hid/tests/base_gamepad.py

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/hid/tests/test_gamepad.py

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/hid/tests/test_tablet.py

View file

This diff is incomplete. Download the complete patch.