From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.180.112 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796146974; b=BgfXgjOQcELpzOzANRX4VnKk8E4Swx7imIwXf+zsBA6nRqygPwLBBKJleImwY7eTpp1T alx0SUEv79zo4J7sdjMhaaUK6vWzaF3sspMN+gmHcBys0eAN3j46NuPKl0jViKRvWWWVE jOo+9Pa29HR2xDl8/UsU/pt7X7kHqNFRG8dpAkwtDHIIzleRbJPVJedg48Al9wZaUxUIq z568Sm+OBBh9Z+beTbd7tAwEw3WKhAkCsyH9FwQXFuYIRe+lxMoNNbDvboNI7wYAXabJI vd1GqpGNhZc7knJXMKygvV4C+wXqVS/oNAFLIa/aB4QcbaqrFl7pZidmFOgOAqfTlfA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796146974; h=DMARC-Filter:DKIM-Signature:Received:Message-ID:Subject:From:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date: MIME-Version:User-Agent:X-ZohoMailClient; bh=DIBxIwD0U8LI594MOLRFnmBq4UN/WK1pcnWWI8ynMJE=; b=O1uwqqAwcu5iP2ultniuTDJNBUGgQmi5MafACyQsYjICKTn8XSMGYpvzGht3aybjrkWu HRA8PRyIMDd+gJ66I2ufjEFAdXbC4EZbEjwwcWmj6Z8/Hl9cw8ZlS3V8RAbPCagPwFOEz G0Lv1NjMQ910+C1jDGrgDWI+y+3eMq1+TV6nV+xoefpuT3nGWryhy40R+p35z1rY+cp0v aEzl9ZRRbvamuR/mUiwdBEN/JraeftbJ7/39NzSYMajC4r32cRttc4gvuKjDY1YGbpfm6 XlKYrSbQBqKPfkiZ3KPYzeZ8wJ5yiRg4zcvKIOI5N+x45S/Q0/VgJXt0Ujr7V0NvhSQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass header.d=rong.moe header.i=@rong.moe header.a=rsa-sha256 header.s=zmail2048 header.b=qLr3LaxH; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.180.112 Received: from sender6-pp-f112.zoho.com (sender6-pp-f112.zoho.com [165.173.180.112]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32074606A325; Tue, 1 Dec 2026 17:42:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 32074606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=rong.moe header.i=@rong.moe header.a=rsa-sha256 header.s=zmail2048 header.b=qLr3LaxH ARC-Seal: i=1; a=rsa-sha256; t=1796146944; cv=none; d=zohomail.com; s=zohoarc; b=euhpFquKIghc0Bk+dFb2wuFfqWd4aIR4HoHpg08mSwEMGegBneuwqGQxex2BNat05FuPrRcXL0t+SKbJwHoBwKfZuDW4ozavzA+eVi37OQ3CYJprWtRKOYxnMei3HceMKQYXzqdEPJ+avjprxBacqtunvVve4pIsX3zUjlt8qn0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1796146944; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=DIBxIwD0U8LI594MOLRFnmBq4UN/WK1pcnWWI8ynMJE=; b=LJfjarkqfmg4RstmZtOQI5fWFTTluIKXlCOrp574fIriK8LQVQkrJoPwBFEAH+cY8NOP29X2d+17wwQHjdch8raUwekdpfCwOHfKCeXZ0jNqOEF4FYXDJ7dVAjahG345bvte/4BP6xz6E8D6msbVo77MK6fAbti6Jep8FiywAa4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: a=rsa-sha256; b=qLr3LaxH+xkd6o7n3FMvuD9v0Tl+f0cMR6uzdgymCpm7bKGIcDbtbJdYcChcsHXJ87Ux9NJUdi2Zv+ztrbWBL97xOmkyjHi8s9vtcCRSs/LImNNY4fFrb+jEMckLSzKk6hdqHmLmacVr9/vyflDjG5x2HO8YhjnOEHvAAemMA8RT8cSpK7JQvuMsvlU1uSYuAgDgxxi/yohYuk0eukydmhCCcBPDtxzzJc352Z11jJ5Rs7WdTqugbV/TRZ00wDHyczfun5djNM3nrq7dptFT/oU5/B8YDozYzJP51m319GmMS91B0/4u8FLwy5mA1LjKflvdJeM869PFTAUDmbat9A==; c=relaxed/relaxed; s=zmail2048; d=rong.moe; v=1; bh=DIBxIwD0U8LI594MOLRFnmBq4UN/WK1pcnWWI8ynMJE=; h=Content-Description:Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Resent-Sender:Resent-Cc:Resent-Date:Resent-To:Reply-To:Resent-Message-ID:Resent-From:Sender:Subject:To:Date:From:Message-Id:Reply-To:Subject:To:Cc; Received: by smtp.zohomail.com with SMTPS id 1796146941016602.9544724478043; Tue, 1 Dec 2026 09:42:21 -0800 (PST) Message-ID: <46649abf4d02743350f4358ca9ed4adc8be573da.camel@rong.moe> Subject: Re: On the hid-lamparray design (was: Re: [PATCH v5 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin) From: Rong Zhang To: Aaron Erhardt Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Benjamin Tissoires , Jiri Kosina , Dmitry Torokhov , Henrik Rydberg , Angela Czubak In-Reply-To: References: <20261130-hid-haptic-kmod-v5-0-4903f73d8cac@rong.moe> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 01:39:30 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Evolution 3.62.1-4 X-ZohoMailClient: External Hi Aaron, On Tue, 2026-12-01 at 12:07 +0100, Aaron Erhardt wrote: > Am 29.11.26 um 18:52 schrieb Rong Zhang: > > Several weeks ago, I bought a Logitech MX Master 4 with haptic feedback= . > > The hid-haptic already supports the Haptic usage page, but it only work= s > > with hid-multitouch. I am also working on adding support for the > > LampArray usage page recently [1]. > >=20 > > The two drivers have a common characteristic, i.e., they targets > > specific HID usage pages instead of specific devices. This leads to > > additional linkage dependences because the device drivers need to call > > functions provided by the usage page drivers. > >=20 > > Logically, the dependence should be reversed, i.e., a usage page driver > > should be an optional component of the associated device driver and is > > only loaded by the device driver when the device has the usage page. > >=20 > > Introduce hid-plugin framework for loadable plugin modules to achieve > > the said logical dependence. Each plugin has a unique hid_plugin_id whe= n > > enabled, so that HID drivers can connect to it accordingly. The > > framework loads the plugin module when needed. Once loaded (or if the > > plugin is builtin), plugin connection only requires an RCU dereference > > plusing an module refcount increment. Once connected, the plugin's > > private data is initialized with its pointer stored in hid_device. > >=20 > > On HID driver removal, all HID plugins are automatically disconnected. > > When a plugin turns out to be unsuitable for the associated HID device, > > it's disconnected early to release the resources. > >=20 > > When a plugin is disabled, its ID maps to HID_PLUGIN_DISABLED, and call= s > > to the plugin helper functions are eliminated by the compiler. > >=20 > > With the framework, convert hid-haptic to the first plugin. After the > > conversion, it connects to hid-input and becomes a generic plugin. > >=20 > > The first few patches fix pre-existing bugs in hid-haptic and > > hid-multitouch. Then the later patches refactor hid-haptic, implement > > the hid-plugin framework and finish the conversion. > >=20 > > I volunteer to maintain the framework as well as its plugins, including > > hid-haptic and future ones. > >=20 > > Thanks Benjamin Tissoires for the inspiration for the implementation. > >=20 > > [1]: I know Texudo folks are working on adding hid-lamparray to connect > > it to hid-generic. I am not in favor of their design, so I decided to > > write a new one. In my local tree, I've had an independent > > implementation with HIDRAW sniff, autonomous mode as an LED trigger, > > RGB/non-RGB LampArray support, per-key LED device support, etc. I will > > submit it once this series settles. >=20 > Thanks for your feedback! I would highly appreciate to hear your comments= on > our patch series.=C2=A0 >=20 Thanks for working on this, too. I am not replying there as I am busy these days and don't have the time to seriously review your series. I will share my opinions based on my recall when I read your series the last time. I originally noticed your series in July and tried it out, only to find it unable to work on my device because it overfit your devices. At that time I found myself very confusing about the design, so I try figured out my own design and implemented it. I am not an HID maintainer (though I have maintainership elsewhere) so I am just talking about my very personal opinion: I believe your latest series should work on my device based on my glance, but I am still not in favor of the design because it's still fragile. > The hid-lamparray module is designed is to make it easy for > other drivers to pick it up as a dependency.=C2=A0 >=20 It's not really easy. A standard HID usage page should be wired to hid- input, so most drivers can take the advantage of it without any modification, which is also why this series exists. The hid-plugin framework is designed for exactly these use cases. > The only reason to include it in > hid-generic is to keep the generic functionality of keyboards that are al= so > lamparray devices.=C2=A0 >=20 IMO this is where you made a mistake. hid-generic does not provide any "generic functionality", it's just a fallback wildcard driver that connects devices to hid-input which provides the things you said. Thinking about that, it's very natural to wire standard HID usage pages to hid-input. > Otherwise, a separate lamparray driver would take over the > device,=C2=A0leaving the keyboard in a bad state (LEDs working but no typ= ing). If > there was another solution but to hijack hid-generic I would also prefer = that. >=20 > On the other side, per-key LED support is not planned for our driver unle= ss the > maintainers agree that this is acceptable in the kernel.=C2=A0 >=20 I don't think the issue is about how it can be accept, but how correct the implementation can be. Handling so many LEDs is tricky, but it should be acceptable as long as we can synchronize everything correctly and expose correct semantics to userspace IMO. I have some experience of working with the leds subsystem so I believe per-key LEDs can be implemented right with its APIs. I can also extend the leds subsystem if, in case, it shows some shortages. > In general, we should > settle the debate what should be included in the kernel and what is suppo= sed to > be userspace.=C2=A0 >=20 No one is arguing about that, and the debate has settled years ago, or am I missing anything? > In the meanwhile, OpenRGB has already gone the hidraw route and I > think it's feasible to completely handle this in userspace.=C2=A0 >=20 I believe the result of the debate meant "we should honor hidraw whenever it takes control", and not "we can't provide more functionalities than userspace". Apparently, by deconflicting them correctly we can get *both* plentiful kernel control and plentiful userspace control. It's OK if you want to implement things step by step, but if the implementation is inherently broken you could accidentally break both. The use_leds_uapi attribute is such a broken thing: it can't really track userspace consumers. For example, if we have two processes, whateverRGB and howeverRGB, and both poke the attribute, we will be in a horrible mess: once whateverRGB writes 1 to use_leds_uapi before exiting, both howeverRGB and kernel now controls the LampArray! Besides, no one will recover the attribute when the process crashes. OTOH, the permissions of the hidraw character device and the attribute may be different so relying on the attribute is also prone to permission misalignment. The only reliable way to deconflict userspace and kernel is to snoop hidraw. > Either way, I would > like to have some clarity soon. The above comments are basically the same as Benjamin's replies in 2024, see: https://lore.kernel.org/all/vjd5xqgd2gsyz4ubgk6eusuyqdtxpdw6vogc5u537x2a245= xcj@m2twppbxea4p/ Before finishing this reply, I decided to have another glance at your v7 series, and had some very offensive and hypothetical thoughts about your series. If you don't want to hear them, please don't scroll below. ... ... ... ... ... I have no intention of undermining anyone, but you don't really seem to understand how an HID driver should work. In the earlier revisions of your series, you missed hid_device_io_start() and hid_hw_request(), so hid_hw_request(GET_REPORT) never receive anything. Unexpectedly, you decided to add a quirk table to work around it! I just checked v7, the quirk table is gone, but both calls are still missing, and you hack the issue by combining hid_hw_raw_request() and hid_report_raw_event(). What a misuse! Moreover, the implementation still overfits all sorts of things: uses u8 to store update channels, assumes all lamps to share the same attributes, etc. Not to mention the issues found by Sashiko. Sigh, now I can recall why I didn't send a review when I first saw the series, but decided to reimplement it myself following Benjamin's suggestions of which I am in favor. Speaking of my implementation, I will find some time to polish it and make it public in advance (I originally decided to defer it until this series settles). Sorry if my words were too offensive, Rong >=20 > >=20 > > Suggested-by: Benjamin Tissoires > > Link: https://lore.kernel.org/linux-input/auypydfkhx2eg7vp764way4batdil= zc35inqda3exwzs3tk3ff@oagat6g46zto/ > > Signed-off-by: Rong Zhang > > --- > > Changes in v5: > > - Manage HID plugins' private data in the framework > > - Disconnect all connected HID plugins on HID driver removal > > - Add debug printk()s to track (dis)connection and (un)registration > > - Only use HID_PLUGIN to build Kconfig menuconfig, rather than having > > plugins depend on it > > - Enable HID_PLUGIN by default to ease Kconfig migration > > - Build the hid-plugin framework only if HID_PLUGIN_CORE is selected > > - HID_HAPTIC selects it, so that olddefconfig preserves HID_HAPTIC's > > old value > > - Connect hid-haptic to hid-inpput > > - Convert hid-haptic to a generic plugin > > - Add a quirk flag for Logitech MX Master 4 > > - Link to v4: https://patch.msgid.link/20261125-hid-haptic-kmod-v4-0-03= 713a89f656@rong.moe > >=20 > > Changes in v4: > > - Drop get_device()/put_device() and try_module_get()/module_put() > > completely, as they are needless now (thanks Dmitry Torokhov) > > - Drop synchronize_rcu() during registration as other drivers do, as > > there is nothing to protect > > - Link to v3: https://patch.msgid.link/20261113-hid-haptic-kmod-v3-0-e7= dfa8766c0d@rong.moe > >=20 > > Changes in v3: > > - Correct the Fixes: tag of PATCH 4 (thanks Sashiko) > > - Add missing Return: to hid_plugin_register()'s kernel-doc (ditto) > > - Fix the return value of hid_haptic_connected_to_input() when > > hid-haptic is disabled (ditto) > > - Link to v2: https://patch.msgid.link/20261110-hid-haptic-kmod-v2-0-b8= 35a067cb62@rong.moe > >=20 > > Changes in v2: > > - Reject touchpad applications with non-force units (thanks Sashiko) > > - Only call runtime methods if the event source is the same input devic= e > > as the stored one (ditto) > > - Rebase on top of v7.4-rc2 due to the devm_kzalloc_obj() changes > > - Link to v1: https://patch.msgid.link/20261102-hid-haptic-kmod-v1-0-a3= de5626dade@rong.moe > >=20 > > --- > > Rong Zhang (13): > > HID: haptic: Get rid of input_ff_destroy() in error paths > > HID: haptic: Fix use-after-free when draining workqueue > > HID: haptic, multitouch: Check haptic prerequisite properly > > HID: haptic: Postpone GET_REPORT to init > > HID: Add hid-plugin framework for loadable plugin modules > > HID: haptic: Convert to a loadable plugin module > > HID: haptic: Adopt pr_fmt, dev_fmt and hid_*() printk helpers > > HID: Add Ordinal page defines > > HID: haptic: Handle list reports separately and make auto trigger= optional > > HID: haptic: Decouple from hid-multitouch and support other devic= es > > HID: haptic: Add quirk table > > HID: haptic: Add HID_HAPTIC_QUIRK_NO_RETRIGGER to disable retrigg= ering > > HID: haptic: Add quirk flag for Logitech MX Master 4 > >=20 > > MAINTAINERS | 7 + > > drivers/hid/Kconfig | 24 ++- > > drivers/hid/Makefile | 4 +- > > drivers/hid/hid-core.c | 3 + > > drivers/hid/hid-haptic.c | 444 ++++++++++++++++++++++++++++-------= -------- > > drivers/hid/hid-haptic.h | 181 ++++++++++++------ > > drivers/hid/hid-input.c | 50 ++++- > > drivers/hid/hid-multitouch.c | 41 +--- > > drivers/hid/hid-plugin.c | 172 +++++++++++++++++ > > drivers/hid/hid-plugin.h | 208 ++++++++++++++++++++ > > include/linux/hid.h | 25 +++ > > 11 files changed, 906 insertions(+), 253 deletions(-) > > --- > > base-commit: 4f069ab1ec243e6b60dc438772905855c60774e8 > > change-id: 9644469a-hid-haptic-kmod-4e8e420f8e5f > >=20 > > Thanks, > > Rong > >=20 > >=20