Linux Input/HID development
 help / color / mirror / Atom feed
* iio: hid-sensor-trigger: unclamped msleep_interruptible(poll_value * 2) stalls runtime PM for hours on Chicony 04F2:B872 secondary proximity sensor
@ 2026-11-29  2:03 Shan Rizvi
  2026-11-29 14:37 ` Srinivas Pandruvada
  0 siblings, 1 reply; 5+ messages in thread
From: Shan Rizvi @ 2026-11-29  2:03 UTC (permalink / raw)
  To: Jonathan Cameron, Srinivas Pandruvada, Jiri Kosina,
	Benjamin Tissoires
  Cc: linux-iio, linux-input

[-- Attachment #1: Type: text/plain, Size: 8859 bytes --]

Hi Jonathan, Srinivas, Jiri, Benjamin, and all,

On an HP OmniBook X Flip Laptop 16-cc0xxx (board HP 8EA2, BIOS Insyde
F.07), the integrated USB 2.0 camera (04f2:b872, "SunplusIT Inc HP 5MP
Camera", interface 1-1:1.4) binds hid-sensor-hub and exposes two
hid_sensor_prox (HID-SENSOR-200011) IIO devices:

  1. iio:device0 (HID-SENSOR-200011.3.auto)
     - Physical 0x20:0x11 inside standard Sensor Application 0x20:0x01
       (REPORT_ID 1).
     - in_proximity0_sampling_frequency = 10.000000 Hz (100 ms).
     - Works normally (live presence, distance, and attention readings).

  2. iio:device2 (HID-SENSOR-200011.6.auto)
     - Physical 0x20:0x11 nested inside Vendor-Defined Application
       Collection 0xff00:0x01 (HID-SENSOR-ff000001.5.auto, REPORT_ID
       17, 19, 18).
     - in_{proximity0,proximity1,attention}_sampling_frequency =
       0.000100 Hz.
     - Reading any value channel stalls runtime PM for hours and wedges
       any second concurrent reader in unkillable D-state inside
       rpm_resume().

Root cause
----------
In drivers/iio/common/hid-sensors/hid-sensor-trigger.c,
_hid_sensor_power_state() (lines 106, 146-147 on mainline master) does:

    poll_value = hid_sensor_read_poll_value(st);
    ...
    if (state && poll_value)
        msleep_interruptible(poll_value * 2);

There is no upper bound on poll_value * 2 (and checking poll_value
rather than poll_value > 0 would also pass a negative error such as
-EINVAL as a huge unsigned millisecond count to msleep_interruptible()).

On iio:device2, REPORT_ID 17 defines 0x20:0x30e (Property: Report
Interval, 32-bit, unit=0 -> ms, max=2147483647) and the device reports
sampling_frequency = 0.000100 Hz, corresponding to a poll_value in
[5,000,001 .. 10,000,000] ms (1.39 to 2.78 hours). When a reader
triggers hid_sensor_runtime_resume():

  - Reader 1 enters hid_sensor_runtime_resume() ->
    _hid_sensor_power_state(st, true) while dev->power.runtime_status
    is RPM_RESUMING, and sleeps in msleep_interruptible(poll_value * 2)
    for 2.78 to 5.56 hours (TASK_INTERRUPTIBLE).
  - Any concurrent Reader 2 (e.g., a second sysfs read or sensor
    daemon) enters prox_read_raw() -> hid_sensor_power_state() ->
    __pm_runtime_resume() -> rpm_resume(), sees RPM_RESUMING, and
    sleeps on &dev->power.wait_queue in TASK_UNINTERRUPTIBLE (D-state)
    until Reader 1's multi-hour sleep completes or is signaled.

In our observation on Nov 27, a concurrent cat (pid 858946) started
around 19:46 EST and hung in unkillable D-state for ~2h 14m (triggering
10 hung-task warnings from 19:49:05 at 122s through 20:07:30 at 1228s)
until system s2idle entry at 22:00:43, when the userspace freezer
signaled Reader 1 out of msleep_interruptible(), completed rpm_resume(),
and unblocked pid 858946 (freezing completed in 0.039s).

Environment
-----------
- Machine: HP OmniBook X Flip Laptop 16-cc0xxx (board HP 8EA2 rev 61.26,
  SKU D31MPUA#ABA, BIOS Insyde F.07 08/31/2026)
- Kernel: Linux 7.2.15-4-omarchy #1 SMP PREEMPT_DYNAMIC x86_64
  (untainted; downstream Arch/Omarchy kernel with out-of-tree BORE/ADIOS
  schedulers; hid-sensor-trigger/prox/hub behavior matches current
  mainline drivers/iio/common/hid-sensors/hid-sensor-trigger.c:146-147
  and I am happy to retest on vanilla mainline/rc or a test patch)
- Modules (srcversion):
    hid_sensor_trigger:    DC4B969EEA8A8985CCBB823
    hid_sensor_iio_common: 7B46F870DC1767B69877366
    hid_sensor_prox:       A2D3710A71BC0FCE010B937
    hid_sensor_hub:        B81ADED19C3243EFB66F46B
- USB device 1-1 / interface 1-1:1.4:
    idVendor=04f2, idProduct=b872, bcdDevice=10.20
    manufacturer="SunplusIT Inc", product="HP 5MP Camera"
    MODALIAS=usb:v04F2pB872d1020dcEFdsc02dp01ic03isc00ip00in04

HID report descriptor summary (1,846 bytes)
-------------------------------------------
(Full hex dump attached as 04f2-b872-report-descriptor.hex.)

  COLLECTION(Application) [0xff1b:0x8000]        # HID-SENSOR-ff1b8000.1.auto
  COLLECTION(Application) [0x20:0x01]            # HID-SENSOR-200001.2.auto
    REPORT_ID 1 (0x01)
    COLLECTION(Physical) [0x20:0x11]             # HID-SENSOR-200011.3.auto (iio:device0, 10.000000 Hz)
      Logical 0x20:0x309 (Property: Sensor Connection Type)
      Logical 0x20:0x31f (Property: Human Presence Detection Type)
      Logical 0x20:0x316 (Property: Reporting State)
      Logical 0x20:0x319 (Property: Power State)
      Feature 0x20:0x30e (Property: Report Interval, 32-bit, unit=0, max=2147483647)
      Input   0x20:0x4b1 (Human Presence), 0x20:0x4b2 (Human Proximity Range)
  COLLECTION(Physical) [0x20:0x41]               # HID-SENSOR-200041.4.auto (iio:device1, ALS)
  COLLECTION(Application) [0xff00:0x01]          # HID-SENSOR-ff000001.5.auto (vendor-defined)
    REPORT_ID 17 (0x11)
    COLLECTION(Physical) [0x20:0x11]             # HID-SENSOR-200011.6.auto (iio:device2, 0.000100 Hz)
      Logical 0x20:0x309 (Property: Sensor Connection Type)
      Logical 0x20:0x319 (Property: Power State)
      Logical 0x20:0x31f (Property: Human Presence Detection Type)
      Logical 0x20:0x316 (Property: Reporting State)
      Feature 0x20:0x30e (Property: Report Interval, 32-bit, unit=0, max=2147483647)
      REPORT_ID 19 (0x13), REPORT_ID 18 (0x12)
      Input   0x20:0x4b1 (Human Presence), 0x20:0x4b2 (Human Proximity Range)
  COLLECTION(Application) [0xff99:0x01]          # HID-SENSOR-ff990001.7.auto

Reproduction
------------
1. Start Reader 1 on iio:device2 (it stalls in msleep_interruptible()
   holding RPM_RESUMING):
     cat /sys/bus/iio/devices/iio:device2/in_proximity0_raw &
2. Start Reader 2 concurrently:
     cat /sys/bus/iio/devices/iio:device2/in_proximity0_raw
   Reader 2 enters uninterruptible D-state in rpm_resume() (unkillable
   by SIGKILL until Reader 1 is killed/signaled or the multi-hour sleep
   expires).

Hung-task call trace (Reader 2, pid 858946)
-------------------------------------------
Nov 27 19:49:05 sophia kernel: INFO: task cat:858946 blocked for more than 122 seconds.
Nov 27 19:49:05 sophia kernel:       Not tainted 7.2.15-4-omarchy #1
Nov 27 19:49:05 sophia kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Nov 27 19:49:05 sophia kernel: task:cat             state:D stack:0     pid:858946 tgid:858946 ppid:858816 task_flags:0x400000 flags:0x00080000
Nov 27 19:49:05 sophia kernel: Call Trace:
Nov 27 19:49:05 sophia kernel:  <TASK>
Nov 27 19:49:05 sophia kernel:  __schedule+0x40f/0x1780
Nov 27 19:49:05 sophia kernel:  schedule+0x27/0xa0
Nov 27 19:49:05 sophia kernel:  rpm_resume+0x1cf/0x860
Nov 27 19:49:05 sophia kernel:  ? __pfx_autoremove_wake_function+0x10/0x10
Nov 27 19:49:05 sophia kernel:  __pm_runtime_resume+0x52/0x90
Nov 27 19:49:05 sophia kernel:  hid_sensor_power_state+0x55/0xe0 [hid_sensor_trigger 377a49e4e9428c72b857ea6ddd3ff77490c88f22]
Nov 27 19:49:05 sophia kernel:  prox_read_raw+0x159/0x350 [hid_sensor_prox 791fda5099b57d4de72068c9268ea72b5ae63472]
Nov 27 19:49:05 sophia kernel:  iio_read_channel_info+0x1b3/0x3f0 [industrialio df90c867801c29de6d58c14a6d53db307f32a0b7]
Nov 27 19:49:05 sophia kernel:  ? __kvmalloc_node_noprof+0x674/0x7d0
Nov 27 19:49:05 sophia kernel:  dev_attr_show+0x1f/0x50
Nov 27 19:49:05 sophia kernel:  sysfs_kf_seq_show+0xa8/0x110
Nov 27 19:49:05 sophia kernel:  seq_read_iter+0x131/0x4c0
Nov 27 19:49:05 sophia kernel:  ? security_file_permission+0x55/0x170
Nov 27 19:49:05 sophia kernel:  vfs_read+0x375/0x600
Nov 27 19:49:05 sophia kernel:  __x64_sys_read+0x7e/0x110
Nov 27 19:49:05 sophia kernel:  do_syscall_64+0xaa/0x630
Nov 27 19:49:05 sophia kernel:  ? do_syscall_64+0xaa/0x630
Nov 27 19:49:05 sophia kernel:  ? handle_mm_fault+0x1dd/0x2c0
Nov 27 19:49:05 sophia kernel:  ? do_syscall_64+0x5f/0x630
Nov 27 19:49:05 sophia kernel:  ? exc_page_fault+0x90/0x1c0
Nov 27 19:49:05 sophia kernel:  entry_SYSCALL_64_after_hwframe+0x76/0x7e
Nov 27 19:49:05 sophia kernel: RIP: 0033:0x7f4d25511b0d
[registers omitted]
Nov 27 19:49:05 sophia kernel:  </TASK>

Questions / possible fix directions
-----------------------------------
1. In drivers/iio/common/hid-sensors/hid-sensor-trigger.c:
   Should _hid_sensor_power_state() check poll_value > 0 (avoiding
   huge unsigned sleeps on negative errors) and clamp poll_value * 2
   to a reasonable upper bound (e.g., min(poll_value * 2, ...)), so a
   sensor reporting a multi-hour Report Interval cannot hold
   RPM_RESUMING for hours and wedge concurrent readers in D-state?
2. In drivers/hid/hid-sensor-hub.c:
   Should sensor_hub_probe() skip standard Sensor Physical collections
   (0x20:*) nested inside vendor-defined Application Collections
   (0xff00:0x01), or is a device quirk for 04f2:b872 preferred?

Happy to attach the raw binary descriptor, test a patch on vanilla
mainline/rc on this hardware, or submit a patch for (1) if you agree on
an appropriate cap.

Thanks,
Shan Rizvi

[-- Attachment #2: 04f2-b872-report-descriptor.hex --]
[-- Type: text/plain, Size: 7878 bytes --]

00000000: 061b ff0a 0080 a101 85f0 0900 1500 26ff  ..............&.
00000010: 0075 0895 3081 0285 f209 0195 3fb1 0285  .u..0.......?...
00000020: f309 0196 ff01 b102 85e0 0901 951f b102  ................
00000030: c005 2009 01a1 0185 0105 2009 11a1 0005  .. ....... .....
00000040: 200a 0903 1500 2502 7508 9501 a102 0a30   .....%.u......0
00000050: 080a 3108 0a32 08b1 00c0 0a1f 0315 0025  ..1..2.........%
00000060: 0375 0895 01a1 020a c009 0ac1 090a c209  .u..............
00000070: 0ac3 09b1 00c0 0a16 0315 0025 0575 0895  ...........%.u..
00000080: 01a1 020a 4008 0a41 080a 4208 0a43 080a  ....@..A..B..C..
00000090: 4408 0a45 08b1 00c0 0a19 0315 0025 0575  D..E.........%.u
000000a0: 0895 01a1 020a 5008 0a51 080a 5208 0a53  ......P..Q..R..S
000000b0: 080a 5408 0a55 08b1 00c0 0a01 0215 0025  ..T..U.........%
000000c0: 0675 0895 01a1 020a 0008 0a01 080a 0208  .u..............
000000d0: 0a03 080a 0408 0a05 080a 0608 b100 c00a  ................
000000e0: 0e03 1500 27ff ffff 7f75 2095 0155 00b1  ....'....u ..U..
000000f0: 020a 0403 1500 27ff ffff 7f75 2095 0155  ......'....u ..U
00000100: 00b1 020a b124 1500 26fe ff75 1095 0155  .....$..&..u...U
00000110: 0db1 020a b134 1500 26fe ff75 1095 0155  .....4..&..u...U
00000120: 0db1 020a b214 1500 26fe ff75 1095 0155  ........&..u...U
00000130: 0db1 020a b174 1500 26fe ff75 1095 0155  .....t..&..u...U
00000140: 0db1 020a be24 15a6 255a 7508 9501 5500  .....$..%Zu...U.
00000150: b102 0abe 3415 a625 5a75 0895 0155 00b1  ....4..%Zu...U..
00000160: 020a be14 1500 25b4 7508 9501 5500 b102  ......%.u...U...
00000170: 0abf 2415 a625 5a75 0895 0155 00b1 020a  ..$..%Zu...U....
00000180: bf34 15a6 255a 7508 9501 5500 b102 0abf  .4..%Zu...U.....
00000190: 1415 0025 b475 0895 0155 00b1 020a c014  ...%.u...U......
000001a0: 1500 2668 0175 1095 0155 00b1 020a c114  ..&h.u...U......
000001b0: 1500 2668 0175 1095 0155 00b1 020a c214  ..&h.u...U......
000001c0: 1500 25b4 7508 9501 5500 b102 0a01 0315  ..%.u...U.......
000001d0: 0026 ff7f 7510 9510 5500 b102 0a02 0315  .&..u...U.......
000001e0: 0026 ff7f 7510 9520 5500 b102 0520 0a01  .&..u.. U.... ..
000001f0: 0215 0025 0675 0895 01a1 020a 0008 0a01  ...%.u..........
00000200: 080a 0208 0a03 080a 0408 0a05 080a 0608  ................
00000210: 8100 c00a 0202 1500 2505 7508 9501 a102  ........%.u.....
00000220: 0a10 080a 1108 0a12 080a 1308 0a14 080a  ................
00000230: 1508 8100 c00a b104 1500 2501 7508 9501  ..........%.u...
00000240: 5500 8102 0abd 0415 0025 0175 0895 0155  U........%.u...U
00000250: 0081 020a b204 1500 26fe ff75 1095 0155  ........&..u...U
00000260: 0d81 0205 0a09 01a1 0205 200a b204 1500  .......... .....
00000270: 26fe ff75 1095 0155 0d81 420a bd04 1500  &..u...U..B.....
00000280: 2501 7508 9501 5500 8142 0abe 0415 a625  %.u...U..B.....%
00000290: 5a75 0895 0155 0081 420a bf04 15a6 255a  Zu...U..B.....%Z
000002a0: 7508 9501 5500 8142 0ac0 0416 0000 2668  u...U..B......&h
000002b0: 0175 1095 0155 0081 420a c104 164c ff26  .u...U..B....L.&
000002c0: b400 7510 9501 5500 8142 0ac2 0415 a625  ..u...U..B.....%
000002d0: 5a75 0895 0155 0081 420a c304 1500 26fe  Zu...U..B.....&.
000002e0: ff75 1095 0155 0081 42c0 050a 0902 a102  .u...U..B.......
000002f0: 0520 0ab2 0415 0026 feff 7510 9501 550d  . .....&..u...U.
00000300: 8142 0abd 0415 0025 0175 0895 0155 0081  .B.....%.u...U..
00000310: 420a be04 15a6 255a 7508 9501 5500 8142  B.....%Zu...U..B
00000320: 0abf 0415 a625 5a75 0895 0155 0081 420a  .....%Zu...U..B.
00000330: c004 1600 0026 6801 7510 9501 5500 8142  .....&h.u...U..B
00000340: 0ac1 0416 4cff 26b4 0075 1095 0155 0081  ....L.&..u...U..
00000350: 420a c204 15a6 255a 7508 9501 5500 8142  B.....%Zu...U..B
00000360: 0ac3 0415 0026 feff 7510 9501 5500 8142  .....&..u...U..B
00000370: c005 0a09 03a1 0205 200a b204 1500 26fe  ........ .....&.
00000380: ff75 1095 0155 0d81 420a bd04 1500 2501  .u...U..B.....%.
00000390: 7508 9501 5500 8142 0abe 0415 a625 5a75  u...U..B.....%Zu
000003a0: 0895 0155 0081 420a bf04 15a6 255a 7508  ...U..B.....%Zu.
000003b0: 9501 5500 8142 0ac0 0416 0000 2668 0175  ..U..B......&h.u
000003c0: 1095 0155 0081 420a c104 164c ff26 b400  ...U..B....L.&..
000003d0: 7510 9501 5500 8142 0ac2 0415 a625 5a75  u...U..B.....%Zu
000003e0: 0895 0155 0081 420a c304 1500 26fe ff75  ...U..B.....&..u
000003f0: 1095 0155 0081 42c0 c0c0 0520 0941 a100  ...U..B.... .A..
00000400: 850a 0520 0a09 0315 0025 0275 0895 01a1  ... .....%.u....
00000410: 020a 3008 0a31 080a 3208 b100 c00a 1603  ..0..1..2.......
00000420: 1500 2505 7508 9501 a102 0a40 080a 4108  ..%.u......@..A.
00000430: 0a42 080a 4308 0a44 080a 4508 b100 c00a  .B..C..D..E.....
00000440: 1903 1500 2505 7508 9501 a102 0a50 080a  ....%.u......P..
00000450: 5108 0a52 080a 5308 0a54 080a 5508 b100  Q..R..S..T..U...
00000460: c00a 0102 1500 2506 7508 9501 a102 0a00  ......%.u.......
00000470: 080a 0108 0a02 080a 0308 0a04 080a 0508  ................
00000480: 0a06 08b1 00c0 0a0e 0315 0027 ffff ffff  ...........'....
00000490: 7520 9501 5500 b102 0ad1 e415 0026 1027  u ..U........&.'
000004a0: 7510 9501 550e b102 0ad1 2415 0026 ff7f  u...U.....$..&..
000004b0: 7510 9501 550f b102 0ad1 3415 0026 ff7f  u...U.....4..&..
000004c0: 7510 9501 550f b102 0a01 0315 0026 ff7f  u...U........&..
000004d0: 7510 9510 5500 b102 0520 0a01 0215 0025  u...U.... .....%
000004e0: 0675 0895 01a1 020a 0008 0a01 080a 0208  .u..............
000004f0: 0a03 080a 0408 0a05 080a 0608 8100 c00a  ................
00000500: 0202 1500 2505 7508 9501 a102 0a10 080a  ....%.u.........
00000510: 1108 0a12 080a 1308 0a14 080a 1508 8100  ................
00000520: c00a d104 1500 26ff 7f55 0f75 1095 0181  ......&..U.u....
00000530: 020a d204 1500 26ff 7f55 0075 1095 0181  ......&..U.u....
00000540: 020a d404 1500 26ff 7f55 0c75 1095 0181  ......&..U.u....
00000550: 020a d504 1500 26ff 7f55 0c75 1095 0181  ......&..U.u....
00000560: 02c0 0600 ff09 01a1 0185 1105 2009 11a1  ............ ...
00000570: 0005 200a 0903 1500 2502 7508 9501 a102  .. .....%.u.....
00000580: 0a30 080a 3108 0a32 08b1 00c0 0a19 0315  .0..1..2........
00000590: 0025 0575 0895 01a1 020a 5008 0a51 080a  .%.u......P..Q..
000005a0: 5208 0a53 080a 5408 0a55 08b1 00c0 0a1f  R..S..T..U......
000005b0: 0315 0025 0375 0895 01a1 020a c009 0ac1  ...%.u..........
000005c0: 090a c209 0ac3 09b1 00c0 0a16 0315 0025  ...............%
000005d0: 0575 0895 01a1 020a 4008 0a41 080a 4208  .u......@..A..B.
000005e0: 0a43 080a 4408 0a45 08b1 00c0 0a01 0215  .C..D..E........
000005f0: 0025 0675 0895 01a1 020a 0008 0a01 080a  .%.u............
00000600: 0208 0a03 080a 0408 0a05 080a 0608 b100  ................
00000610: c00a 0e03 1500 27ff ffff 7f75 2095 0155  ......'....u ..U
00000620: 00b1 020a 0403 1500 27ff ffff 7f75 2095  ........'....u .
00000630: 0155 00b1 020a b124 1601 8026 ff7f 7510  .U.....$...&..u.
00000640: 9501 550d b102 0ab1 3416 0180 26ff 7f75  ..U.....4...&..u
00000650: 1095 0155 0db1 020a b214 1601 8026 ffff  ...U.........&..
00000660: 7510 9501 550d b102 0ab1 7416 0180 26ff  u...U.....t...&.
00000670: ff75 1095 0155 0db1 020a f103 1500 27ff  .u...U........'.
00000680: ffff 7f75 2095 0155 00b1 020a 0103 1500  ...u ..U........
00000690: 26ff 7f75 1095 1055 00b1 020a 0203 1500  &..u...U........
000006a0: 26ff 7f75 1095 2055 00b1 0285 130a f203  &..u.. U........
000006b0: 1500 26ff 7f75 1095 0155 00b1 0285 1205  ..&..u...U......
000006c0: 200a 0102 1500 2506 7508 9501 a102 0a00   .....%.u.......
000006d0: 080a 0108 0a02 080a 0308 0a04 080a 0508  ................
000006e0: 0a06 0881 00c0 0ab1 0415 0025 0175 0895  ...........%.u..
000006f0: 0155 0081 020a bd04 1500 2501 7508 9501  .U........%.u...
00000700: 5500 8102 0ab2 0416 0180 26ff 7f75 1095  U.........&..u..
00000710: 0155 0d81 02c0 c006 99ff 0901 a101 859a  .U..............
00000720: 0903 7508 957f 1500 26ff 00b1 0285 9b09  ..u.....&.......
00000730: 0495 7f81 02c0                           ......

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-29 19:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29  2:03 iio: hid-sensor-trigger: unclamped msleep_interruptible(poll_value * 2) stalls runtime PM for hours on Chicony 04F2:B872 secondary proximity sensor Shan Rizvi
2026-11-29 14:37 ` Srinivas Pandruvada
2026-11-29 17:26   ` Shan Rizvi
2026-11-29 17:54     ` Srinivas Pandruvada
2026-11-29 19:18       ` Shan Rizvi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox