linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/18] HID: Include current HID-BPF fixes in tree
@ 2024-04-10 17:19 Benjamin Tissoires
  2024-04-10 17:19 ` [PATCH 01/18] HID: do not assume HAT Switch logical max < 8 Benjamin Tissoires
                   ` (19 more replies)
  0 siblings, 20 replies; 23+ messages in thread
From: Benjamin Tissoires @ 2024-04-10 17:19 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, Shuah Khan, Peter Hutterer
  Cc: linux-input, linux-kernel, linux-kselftest, Martin Sivak,
	Ping Cheng, Jason Gerecke, Aaron Armstrong Skomra, Joshua Dickens

When I introduced HID-BPF, I mentioned that we should ship the HID-BPF
programs in the kernel when they are fixes so that everybody can benefit
from them.

I tried multiple times to do so but I was confronted to a tough problem:
how can I make the kernel load them automatically?

I went over a few solutions, but it always came down to something either
ugly, or either not satisfying (like forcing `bpftool` to be compiled
first, or not being able to insert them as a module).

OTOH, I was working with Peter on `udev-hid-bpf`[0] as a proof of
concept on how a minimal loader should look like. This allowed me to
experiment on the BPF files and how they should look like.

And after further thoughts, I realized that `udev-hid-bpf` could very
well be the `kmod load` that we currently have:
- the kernel handles the device normally
- a udev event is emitted
- a udev rule fires `udev-hid-bpf` and load the appropriate HID-BPF
  file(s) based on the modalias

Given that most HID devices are supposed to work to a minimal level when
connected without any driver, this makes the whole HID-BPF programs nice
to have but not critical. We can then postpone the HID-BPF loading when
userspace is ready.

Working with HID-BPF is also a much better user experience for end users
(as I predicted). All they have to do is to go to the `udev-hid-bpf`
project, fetch an artifact from the MR that concerns them, run
`install.sh` (no compilation required), and their devices are fixed
(minus some back and forth when the HID-BPF program needs some changes).

So I already have that loader available, and it works well enough for
our users. But the missing point was still how to "upstream" those BPF
fixes?

That's where this patch series comes in: we simply store the fixes in
the kernel under `drivers/hid/bpf/progs`, provide a way to compile them,
but also add tests for them in the selftests dir.

Once a program is accepted here, for convenience, the same program will
move from a "testing" directory to a "stable" directory on
`udev-hid-bpf`. This way, distributions don't need to follow when there
is a new program added here, they can just ship the "stable" ones from
`udev-hid-bpf`.

Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>

[0] https://gitlab.freedesktop.org/libevdev/udev-hid-bpf/

---
Benjamin Tissoires (18):
      HID: do not assume HAT Switch logical max < 8
      HID: bpf: add first in-tree HID-BPF fix for the XPPen Artist 24
      HID: bpf: add in-tree HID-BPF fix for the XPPen Artist 16
      HID: bpf: add in-tree HID-BPF fix for the HP Elite Presenter Mouse
      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 Wacom ArtPen
      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 Huion Kamvas Pro 19
      HID: bpf: add in-tree HID-BPF fix for the Raptor Mach 2
      selftests/hid: import base_device.py from hid-tools
      selftests/hid: add support for HID-BPF pre-loading before starting a test
      selftests/hid: tablets: reduce the number of pen state
      selftests/hid: tablets: add a couple of XP-PEN tablets
      selftests/hid: tablets: also check for XP-Pen offset correction
      selftests/hid: add Huion Kamvas Pro 19 tests
      selftests/hid: import base_gamepad.py from hid-tools
      selftests/hid: move the gamepads definitions in the test file
      selftests/hid: add tests for the Raptor Mach 2 joystick

 drivers/hid/bpf/progs/FR-TEC__Raptor-Mach-2.bpf.c  | 185 ++++++
 drivers/hid/bpf/progs/HP__Elite-Presenter.bpf.c    |  58 ++
 drivers/hid/bpf/progs/Huion__Kamvas-Pro-19.bpf.c   | 290 +++++++++
 .../hid/bpf/progs/IOGEAR__Kaliber-MMOmentum.bpf.c  |  59 ++
 drivers/hid/bpf/progs/Makefile                     |  91 +++
 .../hid/bpf/progs/Microsoft__XBox-Elite-2.bpf.c    | 133 ++++
 drivers/hid/bpf/progs/README                       | 102 +++
 drivers/hid/bpf/progs/Wacom__ArtPen.bpf.c          | 173 +++++
 drivers/hid/bpf/progs/XPPen__Artist24.bpf.c        | 229 +++++++
 drivers/hid/bpf/progs/XPPen__ArtistPro16Gen2.bpf.c | 274 ++++++++
 drivers/hid/bpf/progs/hid_bpf.h                    |  15 +
 drivers/hid/bpf/progs/hid_bpf_helpers.h            | 170 +++++
 include/linux/hid.h                                |   6 +-
 tools/testing/selftests/hid/tests/base.py          |  87 ++-
 tools/testing/selftests/hid/tests/base_device.py   | 421 ++++++++++++
 tools/testing/selftests/hid/tests/base_gamepad.py  | 238 +++++++
 tools/testing/selftests/hid/tests/test_gamepad.py  | 457 ++++++++++++-
 tools/testing/selftests/hid/tests/test_tablet.py   | 723 +++++++++++++++------
 18 files changed, 3507 insertions(+), 204 deletions(-)
---
base-commit: 3e78a6c0d3e02e4cf881dc84c5127e9990f939d6
change-id: 20240328-bpf_sources-be1f3c617c5e

Best regards,
-- 
Benjamin Tissoires <bentiss@kernel.org>


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2024-05-07 15:02 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-10 17:19 [PATCH 00/18] HID: Include current HID-BPF fixes in tree Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 01/18] HID: do not assume HAT Switch logical max < 8 Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 02/18] HID: bpf: add first in-tree HID-BPF fix for the XPPen Artist 24 Benjamin Tissoires
2024-04-11  7:09   ` Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 03/18] HID: bpf: add in-tree HID-BPF fix for the XPPen Artist 16 Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 04/18] HID: bpf: add in-tree HID-BPF fix for the HP Elite Presenter Mouse Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 05/18] HID: bpf: add in-tree HID-BPF fix for the IOGear Kaliber Gaming MMOmentum mouse Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 06/18] HID: bpf: add in-tree HID-BPF fix for the Wacom ArtPen Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 07/18] HID: bpf: add in-tree HID-BPF fix for the XBox Elite 2 over Bluetooth Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 08/18] HID: bpf: add in-tree HID-BPF fix for the Huion Kamvas Pro 19 Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 09/18] HID: bpf: add in-tree HID-BPF fix for the Raptor Mach 2 Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 10/18] selftests/hid: import base_device.py from hid-tools Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 11/18] selftests/hid: add support for HID-BPF pre-loading before starting a test Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 12/18] selftests/hid: tablets: reduce the number of pen state Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 13/18] selftests/hid: tablets: add a couple of XP-PEN tablets Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 14/18] selftests/hid: tablets: also check for XP-Pen offset correction Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 15/18] selftests/hid: add Huion Kamvas Pro 19 tests Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 16/18] selftests/hid: import base_gamepad.py from hid-tools Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 17/18] selftests/hid: move the gamepads definitions in the test file Benjamin Tissoires
2024-04-10 17:19 ` [PATCH 18/18] selftests/hid: add tests for the Raptor Mach 2 joystick Benjamin Tissoires
2024-05-06 14:36 ` [PATCH 19/18] selftests/hid: skip tests with HID-BPF if udev-hid-bpf is not installed bentiss
2024-05-07  5:43   ` Peter Hutterer
2024-05-07 15:02 ` [PATCH 00/18] HID: Include current HID-BPF fixes in tree Benjamin Tissoires

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).