Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp287356lqj; Wed, 10 Apr 2024 10:20:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU7lWokz3ahStNQOoTihAe3N4k4yyd5LkA18PHzgTbMEEkhj8YkN/Yi81W8c1d13UQDwi/1omjrW7Rkp1WfL4vFTwVXkXla7Y10qcKLew== X-Google-Smtp-Source: AGHT+IF57GRU46mAhAe/eeBvO0/akX3kl9ByRPrYTnJTxQFtRPJbHLLVSZIZXqMgesNk787n5Wnd X-Received: by 2002:a17:903:2441:b0:1e4:1fb8:3216 with SMTP id l1-20020a170903244100b001e41fb83216mr3831174pls.52.1712769637299; Wed, 10 Apr 2024 10:20:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712769637; cv=pass; d=google.com; s=arc-20160816; b=1D79DNH+NeQUT5o3cb4AJupTZWFb8HX9mtNWarqBSHh0YDi9YDQEIxK3ENJJJB9hq8 g+7vySimSU/7pq4O44V0UPb+CpadqQV2prtx2Cw6ZXZ/YROaehZeCAcd0a1tfJ7Gisz1 fx4zV/O2XZiGGUQr9uTsK0jtNKJFOd7BZrGEixNM2dYLjPRica1yNrgQ2ZHnPQk0GG7U PURx63Dls4GjFrf0cuVWT78iNegStHUtXEB+jyM2QoRFh6AO0/7hceuPZY+G7LdGih3X fwMAQDvafYPvK/WwZTCnFPppRu/IVcNnJlkYRT6VxZ0SVMYpsQuoBmiUffwNSHG9ZeL3 3Ydg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:from :dkim-signature; bh=8MJgy2QNG6Do/XHnmClfxMed8Dnnl4i7sgJFhu0bIFo=; fh=DXOkfZHpslZtfWteWjTboHhstvkCcEshiz5c0rrh8l0=; b=JjFxW83SUatBPk1GxMgXpcajVNxNrT/YRjtqvmqN/qDvelD4uaWp7RdvKc7s9/pJcq ifbiIYdt5iYGy/TnqbylUQnD+mdJaiuI9OmyG2uOALu10KsvQ54V1uwi5tSsyD32AEog Vgsm3Jsfwqn1VfO72nye60QuKHOtLxqN+fnyad1E4d+ytm0eDfKKR8wlY1b20n3ym21A CuVKl3RissPXk4ncK6+dOnZ5+PW0r7czSjgE4VqvYdThK7jdGnh4N/+bKbJ3BZe6IkhD LXSjnV3+T+11Fhmu5jfxyRCIBhuaT5h05u/nc2v/zxw0Nlm91Gf51bFqYlTxmn1lRsQM IvLA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Iw3NnDtI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-139069-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139069-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id im16-20020a170902bb1000b001e23779a9edsi10198206plb.512.2024.04.10.10.20.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 10:20:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139069-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Iw3NnDtI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-139069-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139069-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8F85B286FE6 for ; Wed, 10 Apr 2024 17:20:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49A5717BB25; Wed, 10 Apr 2024 17:19:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Iw3NnDtI" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4934917BB0F; Wed, 10 Apr 2024 17:19:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712769592; cv=none; b=YBq0gznoXVn8+86nuPAMkmvBKS7YMrnY4BwOVZkiNU01rIypuo42GcTMF210Eg7eNzHq1A2s22j0mxU/UO3j7xUzMSlBFkWzWIUrFQjFbSYPuRey9D9tyzXvLPqtNn2hXq7GiKFSiNVQb9tcmIYzlRMEt9oHqRRm1KztTI8Eab4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712769592; c=relaxed/simple; bh=6Hn8w2/tHxyjB+9DMsHB0GAVTOXeeu71uZLUXMLz+MY=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=psRrZHwwR2EBbb1mO2/6+T4AistI3S+bmKUiOP7HrNbIt1A0vrpkS6bYxQ73+WKPBCxBqoVSb5j0qpRRHNSAIvBpedYt2FuyyKMjZ1ehDeTMPlpN83iIz/dZbX/xpwrvFQ+3ccBToBb3xl+HCfPLUiwZ6MFUM0JrkjPhpxg3yZ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Iw3NnDtI; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBCBAC433C7; Wed, 10 Apr 2024 17:19:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712769592; bh=6Hn8w2/tHxyjB+9DMsHB0GAVTOXeeu71uZLUXMLz+MY=; h=From:Subject:Date:To:Cc:From; b=Iw3NnDtIMq//xAo9OFKaD7T0kj/vRBXn46OJrE2/476IYB5LXdw1GgrE5R/jwUk8b AFwoxuJ1n0D/+s0eaInUMLzW1ZRy+CJ7DiaN0Xuz0FbAAzLwQXX6yOVdSDu/37PtGJ gxq9mAq498bsN9wlIvV4fqx5O4DI7os0SgVK01Z1UUX9U8H8ZiZaAtzp2YRqqeGk/0 YjKVDQOYm3sPznflP+a9c3achXJ3ZxQppeUtiWYoF4tcI5ozxhPki1874EfZUo+XT+ SFagDUVXJaMWqq919jYg5J4Ui7ly6AWR8cKU0sjDF8p9IvJWsNtfY9exW7b315SBbH ThQyM9LW6jUVw== From: Benjamin Tissoires Subject: [PATCH 00/18] HID: Include current HID-BPF fixes in tree Date: Wed, 10 Apr 2024 19:19:20 +0200 Message-Id: <20240410-bpf_sources-v1-0-a8bf16033ef8@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIABjKFmYC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxMDYyML3aSCtPji/NKi5NRi3aRUwzTjZDND82TTVCWgjoKi1LTMCrBp0bG 1tQDcwZGFXQAAAA== To: Jiri Kosina , Benjamin Tissoires , Shuah Khan , Peter Hutterer Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Martin Sivak , Ping Cheng , Jason Gerecke , Aaron Armstrong Skomra , Joshua Dickens X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712769589; l=4998; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=6Hn8w2/tHxyjB+9DMsHB0GAVTOXeeu71uZLUXMLz+MY=; b=4u3UJmMlfDaLYKJ4I0Ma//8KMyyoUN8KeH2/6JvseMZ2t+tHYRFsk4AWtNKrHvabriBx/1hlA H6sKRtFR2hzCXXOgazQhJqLwQ+Y+58hzd8P+YpnxD6KMjePxVfckorN X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= 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 [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