Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rong Zhang" <i@rong.moe>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v7 10/13] HID: haptic: Decouple from hid-multitouch and support other devices
Date: Sat, 05 Dec 2026 19:08:33 +0000	[thread overview]
Message-ID: <sashiko-outbox-251849@kernel.org> (raw)
In-Reply-To: <20261206-hid-haptic-kmod-v7-10-3eea47035836@rong.moe>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] HID: haptic: input_ff_create() clobbers dev->event and breaks
  EV_LED output
- [Medium] HID: mt_input_mapping() drops HID_HP_SIMPLECONTROLLER manual
  trigger report
- [Medium] HID: haptic: hid_haptic_check_prerequisites() misses
  hid-multitouch stylus
--

commit d155e51e55b92ebbcc18762778f9eccc7eddda48
Author: Rong Zhang <i@rong.moe>

HID: haptic: Decouple from hid-multitouch and support other devices

This commit decouples hid-haptic from hid-multitouch by adding fallback
input device selection based on whether the Simple Haptic Controller is a
Collection Application or a Collection Logical, and logs an info message
when the haptic force-feedback device is connected.

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-guidelines/input-haptics-implementation-guide [2]
Link: https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/haptic-pen-implementation-guide [3]

> diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
> index 40bb641fc1f5d..aae4ff1f0ccaa 100644
> --- a/drivers/hid/hid-haptic.c
> +++ b/drivers/hid/hid-haptic.c

[ ... ]

> @@ -566,19 +567,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)
>  {

[ ... ]

> +	if (haptic->manual_trigger_report->application == HID_HP_SIMPLECONTROLLER ||
> +	    hdev->quirks & HID_QUIRK_MULTI_INPUT) {
> +		if (list_is_first(&hi->list, &hdev->inputs))
> +			return 0;

[Severity: Medium]
Can a standalone HID_HP_SIMPLECONTROLLER collection on a hid-multitouch
device reach this check if its mt_class does not set export_all_inputs?

In hidinput_configure_usage(), device->driver->input_mapping() runs
before HID_UP_HAPTIC is dispatched to hid_haptic_input_mapping() and
ignores the usage on a negative return.  When export_all_inputs is false
(e.g. MT_CLS_DEFAULT), mt_input_mapping() rejects HID_HP_SIMPLECONTROLLER.

As a result, haptic->manual_trigger_report remains NULL and
hid_haptic_check_prerequisites() fails with -ENOENT, leaving haptic
force-feedback uninitialized on those devices.

> +	} else {
> +		list_for_each_entry(report, &hi->reports, hidinput_list) {
> +			if (report == haptic->manual_trigger_report)
> +				return 0;
> +		}
> +	}

[Severity: Medium]
Does requiring exact pointer equality against haptic->manual_trigger_report
miss the stylus hid_input on composite Windows 8 touchscreen and haptic pen
devices bound to hid-multitouch?

In hidinput_connect(), input reports are mapped before output reports.
For a HID_DG_PEN application containing a HID_DG_STYLUS physical
collection, mt_input_mapping() overwrites hi->application to HID_DG_STYLUS
while leaving report->application as HID_DG_PEN.

When manual_trigger_report is mapped next under HID_QUIRK_INPUT_PER_APP,
hidinput_match_application() compares hidinput->application
(HID_DG_STYLUS) against report->application (HID_DG_PEN) and puts
manual_trigger_report on a separate hid_input.

That separate hid_input is either discarded by hidinput_cleanup_hidinput()
(dropping haptic force-feedback) or populated with only BTN_STYLUS by
mt_input_configured() (attaching FF_HAPTIC to a separate input device).

Matching report->application against
haptic->manual_trigger_report->application, or avoiding the mismatch in
hid-multitouch, would attach force-feedback to the stylus.

[ ... ]

> @@ -586,17 +623,22 @@ static int hid_haptic_check_prerequisites(struct hid_device *hdev,
>  static int __hid_haptic_input_configured(struct hid_device *hdev,
>  					 struct hid_haptic_device *haptic, struct hid_input *hi)
>  {
> +	bool driver_integration;
>  	int ret;
>  
>  	ret = hid_haptic_check_prerequisites(hdev, haptic, hi);
>  	if (ret)
>  		return ret;
>  
> +	driver_integration = haptic->input_dev == hi->input;
> +
>  	ret = hid_haptic_init(hdev, haptic, hi->input);

[Severity: Medium]
Will hid_haptic_init() break EV_LED output now that hid-haptic can attach
to generic HID input devices such as composite keyboard and haptic devices?

hidinput_allocate() sets dev->event = hidinput_input_event, which handles
both EV_LED output and EV_FF (by delegating to input_ff_event()).
However, hid_haptic_init() calls input_ff_create(), which unconditionally
overwrites dev->event with input_ff_event().

Because input_ff_event() returns 0 for non-EV_FF events, all EV_LED output
such as Caps Lock or indicator LEDs is silently dropped on the attached
input device.  Restoring dev->event after input_ff_create() would keep
EV_LED working.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261206-hid-haptic-kmod-v7-0-3eea47035836@rong.moe?part=10

  reply	other threads:[~2026-12-05 19:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 18:41 [PATCH v7 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin Rong Zhang
2026-12-05 18:41 ` [PATCH v7 01/13] HID: haptic: Get rid of input_ff_destroy() in error paths Rong Zhang
2026-12-05 18:58   ` sashiko-bot
2026-12-05 19:24     ` Rong Zhang
2026-12-05 18:41 ` [PATCH v7 02/13] HID: haptic: Fix use-after-free when draining workqueue Rong Zhang
2026-12-05 18:41 ` [PATCH v7 03/13] HID: haptic, multitouch: Check haptic prerequisite properly Rong Zhang
2026-12-05 19:03   ` sashiko-bot
2026-12-05 19:26     ` Rong Zhang
2026-12-05 18:41 ` [PATCH v7 04/13] HID: haptic: Postpone GET_REPORT to init Rong Zhang
2026-12-05 19:02   ` sashiko-bot
2026-12-05 18:41 ` [PATCH v7 05/13] HID: Add hid-plugin framework for loadable plugin modules Rong Zhang
2026-12-05 19:12   ` sashiko-bot
2026-12-05 18:41 ` [PATCH v7 06/13] HID: haptic: Convert to a loadable plugin module Rong Zhang
2026-12-05 19:11   ` sashiko-bot
2026-12-05 18:41 ` [PATCH v7 07/13] HID: haptic: Adopt pr_fmt, dev_fmt and hid_*() printk helpers Rong Zhang
2026-12-05 18:41 ` [PATCH v7 08/13] HID: Add Ordinal page defines Rong Zhang
2026-12-05 18:41 ` [PATCH v7 09/13] HID: haptic: Handle list reports separately and make auto trigger optional Rong Zhang
2026-12-05 18:41 ` [PATCH v7 10/13] HID: haptic: Decouple from hid-multitouch and support other devices Rong Zhang
2026-12-05 19:08   ` sashiko-bot [this message]
2026-12-05 18:42 ` [PATCH v7 11/13] HID: haptic: Add quirk table Rong Zhang
2026-12-05 18:42 ` [PATCH v7 12/13] HID: haptic: Add HID_HAPTIC_QUIRK_NO_RETRIGGER to disable retriggering Rong Zhang
2026-12-05 18:42 ` [PATCH v7 13/13] HID: haptic: Add quirk flag for Logitech MX Master 4 Rong Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-251849@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=i@rong.moe \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox