From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796492144; b=TpkXAZ/jKAdivufJI1bjWrY4pF1wtGKK02btF0q/BLILkcCYj36TvTPXX3Ss5aTby6zL W1wiwlsly5pVGZJs4MEmvCECdGBXWPmH8yYFipQKCHrKhEzsmqRQDqkDvdZ/Kwr6dVuTM CCo8/psHM+S7brIzJDDiPC5e9wxrR94nbpgsiUoCIxGfItQGHVn0Wg3YORDtNYjEZMdlF Bpl7DLldKHntnrGInoW0kvpnwPzS5M5ILIzlN1AL094WpXBrzXc/4B3nJRYUmfVmG0iNa Uq0zwEx4fDoVYDP0YAZmeQ+zzzkamcFFDtlAXmFCRxzffLOnXindt18KjryF3g/m7vw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796492144; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=TqsLv2R1e2AKtzs03pVYBQNKwWdgubtgCpDefkthwPc=; b=xNaN+UpJWc+0nzbEztSFjCjhftIdC3y51/Wx1rWC3c7hyMXLnWOdm0eFAs1hrQ5ZIA/M vLeULpw1iamSBPzq5IWesZCeF79mMrxFsJmNmRLBfu+3PdNraRR1/MQbtnaQ2XccN6UHM O8+H0kbTy0hcV06zHPq18A64JpLKaCn1pSSWfnh1pigu7PVCmma/Vsrczrps/etCJN3vd +1A4Ne4QTAXbQX48RhzyWwm7uQOouIB+++qZFN6zfvUs/GibXCoM9qfMUDFhi003+AaNu 6mWJb3vwPcRLl1i+wuXP/mi16EbNGWOI3bjeKPmKEtZ09TpxdQp7/1jVy/VEyKNzgOw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WjPsoRBF; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CD41606A31F for ; Sat, 5 Dec 2026 17:35:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WjPsoRBF Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFCF01F0092B; Sat, 5 Dec 2026 17:35:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796492144; bh=TqsLv2R1e2AKtzs03pVYBQNKwWdgubtgCpDefkthwPc=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=WjPsoRBFg0WyW69fEVGmDjR6LB3ZChCQoNik8Xx08tL1Ysve6yiQfT0ElxspUoEnV 3mAU3tpEzmCUTt1Ms+B2LcfvwSHp6tpml8ZJ0QMucIIPRySDq4ys8Jqnuru6y09xpW DEUVmed+D2SgO8Toz7jme+dhDi7v04ofLnWE+6s5IGZ3AEtxqWBVCPR4eRA/QvkHEV CZvmk7ptsDVNqc6Zu962oH01k1fq6DUjIsfhihP6cAi9nhfLiuVQVkjHgHQxIpHZol QbuOXpbphYTi6LtkAZn1JIOVu04oyfcm46eUAqR4BD2uaz9Ityo69lTvS3b4ffTGRg nRqN4G2279TFA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] HID: logitech-hidpp: add raw touchpad support for the K400 Plus Reply-To: sashiko-reviews@lists.linux.dev To: "Damiano Ognissanti" Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com In-Reply-To: <20261205-k400plus-v2-1-35d4c17d0c9b@chalmers.se> References: <20261205-k400plus-v2-1-35d4c17d0c9b@chalmers.se> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 17:35:43 +0000 X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 6 potential issues to consider: - [Medium] HID: logitech-hidpp: dropping HID_GD_MOUSE breaks K400 Plus mouse fallback - [Medium] HID: logitech-hidpp: K400 Plus default mode change and module parameter - [Medium] HID: logitech-hidpp: probe race on hdev->name and raw-mode leak on error - [Low] HID: logitech-hidpp: duplicate WTP logic and K400 Plus fields in wtp_data - [Low] HID: logitech-hidpp: redundant evbit setup and generic input_event() use - [Low] HID: logitech-hidpp: k400p_raw_event() ignores end_of_frame on MT sync -- commit d3f967091f6c14c07b9e166f154750ea441d9ff0 Author: Damiano Ognissanti HID: logitech-hidpp: add raw touchpad support for the K400 Plus This commit adds a K400 Plus device class to hid-logitech-hidpp that enables HID++ 0x6100 raw touchpad reporting on a separate multitouch input device while dropping the default HID mouse collection, along with a disable_raw_touchpad module parameter to retain firmware mouse mode. > diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-= hidpp.c > index a170aaf635b0e..9e64e35724b04 100644 > --- a/drivers/hid/hid-logitech-hidpp.c > +++ b/drivers/hid/hid-logitech-hidpp.c > @@ -38,6 +38,11 @@ module_param(disable_tap_to_click, bool, 0644); > MODULE_PARM_DESC(disable_tap_to_click, > "Disable Tap-To-Click mode reporting for touchpads (only on the K400 cu= rrently)."); > =20 > +static bool disable_raw_touchpad; > +module_param(disable_raw_touchpad, bool, 0444); > +MODULE_PARM_DESC(disable_raw_touchpad, > + "Keep the firmware mouse mode for keyboards with a raw touchpad (only o= n the K400 Plus currently)."); [Severity: Medium] Does switching the K400 Plus (0x404d) from its default relative HID mouse to an absolute multitouch touchpad break existing userspace setups on kernel upgrade? Previously, 0x404d matched LDJ_DEVICE(HID_ANY_ID) and exposed a standard EV_REL mouse. Dropping HID_GD_MOUSE and exposing only an EV_ABS touchpad regresses pointer support and existing mouse rules on non-libinput setups (such as HTPC, console/GPM, or minimal X11) unless users pass disable_raw_touchpad=3D1. Adding a global read-only disable_raw_touchpad parameter also reintroduces a pattern removed in commit cae253d6033d ("Revert "HID: logitech-hidpp: add a module parameter to keep firmware gestures""). [ ... ] > @@ -2938,6 +2945,9 @@ struct wtp_data { > u8 maxcontacts; > bool flip_y; > unsigned int resolution; > + /* separate touchpad input node and its lock, only used by the K400 Plu= s */ > + struct input_dev *tp_input; > + spinlock_t tp_lock; > }; [Severity: Low] Can HIDPP_QUIRK_CLASS_WTP be generalized or share common helpers instead of adding K400-Plus-only fields to struct wtp_data and duplicating the WTP cla= ss as k400p_*? Duplicating wtp_allocate(), wtp_populate_input(), wtp_connect(), wtp_touch_event(), and wtp_raw_event() into a parallel class causes the two HID++ 0x6100 touchpad paths to diverge in protocol and lifecycle handling. Commit 3a61e97563d7 ("HID: logitech-hidpp: support combo keyboard touchpad TK820") previously layered combo-keyboard support onto HIDPP_QUIRK_CLASS_WT= P. [ ... ] > +static void k400p_populate_input(struct wtp_data *wd, struct input_dev *= input) > +{ > + __set_bit(EV_ABS, input->evbit); > + __set_bit(EV_KEY, input->evbit); > + > + input_set_abs_params(input, ABS_MT_POSITION_X, 0, wd->x_size, 0, 0); > + input_abs_set_res(input, ABS_MT_POSITION_X, wd->resolution); > + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, wd->y_size, 0, 0); > + input_abs_set_res(input, ABS_MT_POSITION_Y, wd->resolution); > + > + /* the physical buttons, taken over from the regular mouse report */ > + input_set_capability(input, EV_KEY, BTN_LEFT); > + input_set_capability(input, EV_KEY, BTN_RIGHT); > +} [Severity: Low] This isn't a bug, but __set_bit(EV_ABS, input->evbit) and __set_bit(EV_KEY, input->evbit) are redundant here because input_set_abs_params() and input_set_capability() already set those bits. Similarly, k400p_touch_event() uses generic input_event(input, EV_ABS, ...) where input_report_abs() is preferred. [ ... ] > +static int k400p_create_touchpad(struct hidpp_device *hidpp) > +{ > + struct hid_device *hdev =3D hidpp->hid_dev; > + struct wtp_data *wd =3D hidpp->private_data; > + struct input_dev *input; > + int ret; > + > + input =3D hidpp_allocate_input(hdev); > + if (!input) > + return -ENOMEM; > + > + input->name =3D devm_kasprintf(&hdev->dev, GFP_KERNEL, "%s Touchpad", > + hdev->name); [Severity: Medium] Can this race with hidpp_unifying_init() updating hdev->name during probe? In hidpp_probe(), hid_device_io_start(hdev) allows incoming HID++ reports before hidpp_unifying_init() writes hdev->name and before hid_connect() run= s. If a Unifying 0x41 connect notification arrives in that window, hidpp_raw_hidpp_event() schedules hidpp->work concurrently: CPU0 CPU1 hidpp_probe() hid_device_io_start(hdev) hidpp_raw_hidpp_event() schedule_work(&hidpp->work) hidpp_unifying_init(hidpp) hidpp_connect_event() snprintf(hdev->name, ...) k400p_connect() k400p_create_touchpad() devm_kasprintf(..., hdev->name) <-- data race on hdev->name That unlocked race can leave the touchpad permanently registered with a torn, truncated, or placeholder name. In the same window, if k400p_connect() enables raw mode and hid_connect() then fails, the hid_hw_init_fail error path in hidpp_probe() calls hid_hw_stop() before cancel_work_sync(&hidpp->work) and never calls k400p_stop_raw(), leaving the touchpad stuck in raw mode after probe failur= e. [ ... ] > + case REPORT_ID_HIDPP_LONG: > + /* size is already checked in hidpp_raw_event. */ > + if (report->fap.feature_index !=3D wd->mt_feature_index || > + report->fap.funcindex_clientid !=3D EVENT_TOUCHPAD_RAW_XY) > + return 0; > + > + hidpp_touchpad_raw_xy_event(hidpp, data + 4, &raw); > + > + spin_lock_irqsave(&wd->tp_lock, flags); > + for (i =3D 0; i < 2; i++) > + k400p_touch_event(wd, input, &raw.fingers[i]); > + > + /* fingers not reported in this frame have been lifted */ > + input_mt_sync_frame(input); > + input_sync(input); > + spin_unlock_irqrestore(&wd->tp_lock, flags); > + return 1; [Severity: Low] Should input_mt_sync_frame() and input_sync() be guarded with "if (raw.end_of_frame || raw.finger_count <=3D 2)" as in wtp_send_raw_xy_event()? Each HID++ 0x6100 report carries at most two fingers, while k400p_connect() accepts any non-zero wd->maxcontacts and initializes slots with INPUT_MT_DROP_UNUSED. If a firmware revision or another device using this class reports more than two fingers across multiple packets, syncing unconditionally on every packet will prematurely drop contacts carried in the remaining packets of the frame. [ ... ] > @@ -4032,6 +4308,10 @@ static int hidpp_input_mapping(struct hid_device *= hdev, struct hid_input *hi, > else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560 && > field->application !=3D HID_GD_MOUSE) > return m560_input_mapping(hdev, hi, field, usage, bit, max); > + else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400_PLUS && > + field->application =3D=3D HID_GD_MOUSE) > + /* replaced by the touchpad input, see k400p_raw_event() */ > + return -1; [Severity: Medium] Does unconditionally dropping HID_GD_MOUSE here break the fallback to firmware mouse mode when raw touchpad initialization fails? hid_connect() runs during probe before hidpp_connect_event() calls k400p_connect(). If wtp_get_config() or k400p_create_touchpad() fails, k400p_connect() leaves wd->tp_input NULL and disables raw reporting to retu= rn the hardware to firmware mouse mode, and hidpp_connect_event() ignores the error. Because k400p_raw_event() returns 0 when wd->tp_input is NULL and HID_GD_MOUSE was already unmapped, firmware mouse reports have no input device and the touchpad produces no pointer or button input at all. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205-k400plus-v= 2-1-35d4c17d0c9b@chalmers.se?part=3D1