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=1795976992; b=ge6vaLnCyg9YikIGFqzhI6uUhn8GawYcN8lv3wjiMyVldqfMzG1g+s0P9+8cDpf3H5v1 GpypxlHlJfFHp4Fn0g5J2fMue88MpmlW6eE42i09n+h/H3m+VRSNXMq703WUbfACdmFmE KktwY/NDhLO0CHrux9R+CuCW2MKscUxYoCf15LW64hruqIWQSzBcKjeFjY/xLKelxyG/q Ae9dkVOQ4Onguw1pgCI5OGTxRt3ANNNPMnvy0/GYnI/ZOIUSBm7QnCPEU8qzj6Is7/3Ag z6LvL7RoHUGk/LdeJIf4FnOilDLjw9STXnde2L7+5sb2w7GmmP1fFUD4t7uGrs95bug== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795976992; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=o3c3aPvlPXJ8kMDVWvXqiByt/qrAPAXUDx9OX+uBMNY=; b=i+gbAgTFuB0wrpeVFr6txGVgSkDmh+R56IKhhjZO/hAG5DiQPUmxJ+AAGv1Re/Hv5yZX eMTDe1bM9XaMkuXAlBVyTNtwKB6zk2l22Swk85fY4cZJvs7S/7H3Moz7hEfFN0lInRg7k KwqfCGPWIxgk2gY7gSQM6rAJuMdrqtixsJ5DnOfRdt3yfXnLEs7VJkWUmXQFs0nkfel6t xp23n/TVUwaGBQRRTpID3OfVDlRKetNEtmxH0Cm6QiGbXMe6xjijhZsHqhzXd9z9Jyrbe pzd1XJPsVyoDnqOFKIHbMH52w13N+ad96yRmI6G1iLjMX6krqQwu1jpvnuR98Ie/j+g== 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=ZIakzlxN; 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 463AA606A325 for ; Sun, 29 Nov 2026 18:29:52 +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=ZIakzlxN Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A09D1F000C1; Sun, 29 Nov 2026 18:29:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795976991; bh=o3c3aPvlPXJ8kMDVWvXqiByt/qrAPAXUDx9OX+uBMNY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=ZIakzlxNOF9J89ph0C+8o/MsARIGILPyRhLWv/d0wj1uCjE7+KvjI6OwaADbg/Klk HFWkykbNDEPQp6c+g3XdtQQIH1jb1CWt0SJ/21XgSituMckIQSwYqe9VocaJEQZ01s SkIVw/qxvlmeyF3KGHoRRZXhT4yROiYAVTZLtSp/+iMRsbCOTFVqmzVwVwsAlOkUa+ e/2/x4reLbFRE3m62wj/XG7F+7mcE4EDi6LlWTrraYYsjjgPj8jobjXMaIlRbZKC8A 0yJkrJNE6qx21/PLMujkLA+r1rKsXnqdZ9tLGLd0OzK/hdg8qIY7lmbIfgJNevdpTR pXzKQwVneHycQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 10/13] HID: haptic: Decouple from hid-multitouch and support other devices Reply-To: sashiko-reviews@lists.linux.dev To: "Rong Zhang" Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com In-Reply-To: <20261130-hid-haptic-kmod-v5-10-4903f73d8cac@rong.moe> References: <20261130-hid-haptic-kmod-v5-0-4903f73d8cac@rong.moe> <20261130-hid-haptic-kmod-v5-10-4903f73d8cac@rong.moe> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 18:29:51 +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 2 potential issues to consider: - [High] HID: haptic: hid_haptic_check_prerequisites() attaches FF to unpopulated input - [Medium] HID: haptic: broken stylus matching on composite hid-multitouch devices -- commit 5e7c8d80793026eea1a44d7350febde68e4e4d18 Author: Rong Zhang HID: haptic: Decouple from hid-multitouch and support other devices This commit allows hid-haptic to fall back to selecting an input device based on collection type or multi-input quirks when the HID driver has not chosen one, enabling haptic support on devices other than multitouch touchpads. Link: https://usb.org/sites/default/files/hutrr63b_-_haptics_page_redline_0= .pdf [1] Link: https://learn.microsoft.com/en-us/windows-hardware/design/component-g= uidelines/input-haptics-implementation-guide [2] Link: https://learn.microsoft.com/en-us/windows-hardware/design/component-g= uidelines/haptic-pen-implementation-guide [3] > diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c > index 84b35ec8365a3..eab7bbaaf504a 100644 > --- a/drivers/hid/hid-haptic.c > +++ b/drivers/hid/hid-haptic.c > @@ -566,19 +566,55 @@ static int hid_haptic_init(struct hid_device *hdev,= struct hid_haptic_device *ha > static int hid_haptic_check_prerequisites(struct hid_device *hdev, > struct hid_haptic_device *haptic, struct hid_input *hi) > { > + struct hid_report *report; > + > if (!haptic->waveform_list_report || !haptic->duration_list_report || > !haptic->manual_trigger_report) > return -ENOENT; > =20 > - if (IS_ERR_OR_NULL(haptic->input_dev)) > - return PTR_ERR(haptic->input_dev) ?: -EXDEV; > - > /* Check the prerequisites only. */ > if (!hi) > return 1; > =20 > - if (haptic->input_dev =3D=3D hi->input) > - return 0; > + /* > + * Honor the HID driver's choice. > + * > + * If the driver didn't choose an input device or failed its > + * prerequisites check, initialize the haptic device without the > + * integration with the driver. > + */ > + if (IS_ERR_OR_NULL(haptic->input_dev)) > + haptic->input_dev =3D NULL; > + else > + return haptic->input_dev !=3D hi->input; > + > + /* > + * A Simple Haptic Controller may be either a Collection Application > + * (CA) or a Collection Logical (CL): > + * > + * A CA is a dedicated HID application, i.e., not associated with other > + * HID applications. Choose the first HID input device to attach the FF > + * device, as other FF drivers do. Haptic Mouse usually falls into this > + * category. > + * > + * A CL is contained within another HID application. The HID input > + * device handling the manual trigger report must be the one handling > + * the associated HID application. Haptic Touchpad and Stylus usually > + * fall into this category. > + * > + * When HID_QUIRK_MULTI_INPUT is set, the quirky collection hierarchy > + * makes no sense anyway, so the first input device is chosen instead. > + */ > + if (haptic->manual_trigger_report->application =3D=3D HID_HP_SIMPLECONT= ROLLER || > + hdev->quirks & HID_QUIRK_MULTI_INPUT) { > + if (list_is_first(&hi->list, &hdev->inputs)) > + return 0; [Severity: High] Can this attach the force-feedback device to an unpopulated hid_input? In hidinput_connect(), hid_haptic_input_configured() runs before hidinput_has_been_populated() removes and frees empty hid_input entries from hdev->inputs: drivers/hid/hid-input.c:hidinput_connect() { ... if (haptic_ff) haptic_ff =3D hid_haptic_input_configured(hid, hidinput) >=3D 0; if (!hidinput_has_been_populated(hidinput)) { /* no need to register an input device not populated */ hidinput_cleanup_hidinput(hid, hidinput); continue; } ... } If the first hid_input in hdev->inputs has no mapped input usages (such as an unmapped vendor collection or battery report), matching it here causes hid_haptic_init() to set EV_FF and FF_HAPTIC on hi->input. hidinput_has_been_populated() then sees EV_FF set and registers an empty, EV_FF-only input device while leaving the actual input device without haptic support. Checking hidinput_has_been_populated(hi) before running hid_haptic_input_configured() (or inside hid_haptic_check_prerequisites()) would avoid selecting unpopulated hid_input instances. > + } else { > + list_for_each_entry(report, &hi->reports, hidinput_list) { > + if (report =3D=3D haptic->manual_trigger_report) > + return 0; > + } > + } [Severity: Medium] Does matching hi->reports against haptic->manual_trigger_report work for a haptic stylus on a composite hid-multitouch device? On composite touchscreen and pen devices bound to hid-multitouch (HID_QUIRK_INPUT_PER_APP with maxapplication > 1), the pen top-level collection has application HID_DG_PEN, while its stylus input fields have physical usage HID_DG_STYLUS. When hidinput_connect() processes HID_INPUT_REPORT first, mt_input_mapping() changes hi->application on the pen hid_input from HID_DG_PEN to HID_DG_STYLUS: drivers/hid/hid-multitouch.c:mt_input_mapping() { ... if (field->physical =3D=3D HID_DG_STYLUS) hi->application =3D HID_DG_STYLUS; ... } When hidinput_connect() then processes HID_OUTPUT_REPORT, manual_trigger_report still has report->application =3D=3D HID_DG_PEN, so hidinput_match_application() does not match the stylus hid_input (now HID_DG_STYLUS) and instead allocates a second, unpopulated hid_input for manual_trigger_report. Searching hi->reports here then matches that second hid_input rather than the stylus hid_input, registering a separate EV_FF-only input device and leaving the stylus input device without haptic support. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130-hid-haptic= -kmod-v5-0-4903f73d8cac@rong.moe?part=3D10