lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251117023959.594514-1-Qing-wu.Li@leica-geosystems.com.cn>
Date: Mon, 17 Nov 2025 02:39:58 +0000
From: LI Qingwu <Qing-wu.Li@...ca-geosystems.com.cn>
To: jikos@...nel.org,
	bentiss@...nel.org,
	dianders@...omium.org,
	treapking@...omium.org,
	alex.vinarskis@...il.com,
	dan.carpenter@...aro.org,
	superm1@...nel.org,
	guanwentao@...ontech.com,
	kl@...wtf,
	Qing-wu.Li@...ca-geosystems.com.cn,
	linux-input@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: liqind@....com
Subject: [PATCH V2 0/1] HID: i2c-hid: Add API to wait for device reset completion

Some HID over I2C devices need to signal reset completion to the host
after firmware updates or device resets. Per the HID over I2C spec
(v1.0 section 7.2.2), devices signal completion by sending an empty
input report (0x0000).

Problem:
Currently, i2c-hid-core consumes this signal internally for host-
initiated reset synchronization, but device-initiated resets (such
as after firmware updates) are never exposed to drivers.

In i2c_hid_get_input():
  ret_size = le16_to_cpup((__le16 *)ihid->inbuf);
  if (!ret_size) {
      if (test_and_clear_bit(I2C_HID_RESET_PENDING, &ihid->flags))
          wake_up(&ihid->wait);
      return; [1]  /* Signal consumed, driver never notified */
  }
Why drivers need this:
During firmware updates, the device becomes unresponsive and will
reject commands until reset completes. Drivers need to synchronize
with device reset to avoid command failures and properly reinitialize
device state.

Real-world use case (HID client firmware update):
static void hgs_fw_upload_cleanup(struct fw_upload *fw_upload)
{
	struct hgs_ctx *ctx = fw_upload->dd_handle;
	struct device *dev = &ctx->hid->dev;
	dev_info(dev, "waiting for HID client reset\n");
	
	i2c_hid_wait_reset_complete(ctx->hid->dev.parent, 10000);
	
	mutex_unlock(&ctx->lock);
	hid_driver_reset_resume(ctx->hid);
	dev_info(dev, "fwl_cleanup: Cleaning up firmware upload state\n");
}

static const struct fw_upload_ops hgs_fw_upload_ops = {
	.prepare = hgs_fw_upload_prepare,
	.write = hgs_fw_upload_write,
	.poll_complete = hgs_fw_upload_poll_complete,
	.cancel = hgs_fw_upload_cancel,
	.cleanup = hgs_fw_upload_cleanup,
};

The full driver is currently under development and will be
submitted separately once complet.

Without this API, drivers must either:
- Use arbitrary delays (unreliable, may timeout or waste time)
- Poll device status (inefficient, increases bus traffic)
- Risk sending commands to unresponsive device (causes errors)

Why existing APIs don't work:
The empty report (0x0000) has no report ID and is not defined in the
HID report descriptor. Calling hid_input_report() would fail during
report lookup in the HID core and the event would be silently dropped
before reaching the driver's raw_event callback.

Solution:
Add i2c_hid_wait_reset_complete() that leverages the existing
I2C_HID_RESET_PENDING mechanism. This provides a clean synchronization
point for device-initiated resets without requiring protocol violations
or invasive changes to the HID core.

The API is I2C HID-specific and requires no changes to other HID
transport drivers or subsystems.


[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/hid/i2c-hid/i2c-hid-core.c#n548

LI Qingwu (1):
  HID: i2c-hid: Add API to wait for device reset completion

 drivers/hid/i2c-hid/i2c-hid-core.c | 28 ++++++++++++++++++++++++++++
 drivers/hid/i2c-hid/i2c-hid.h      |  1 +
 2 files changed, 29 insertions(+)

-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ