From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: Shan Rizvi <shan@rizvi.nu>, Jonathan Cameron <jic23@kernel.org>,
Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>
Cc: linux-iio@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: iio: hid-sensor-trigger: unclamped msleep_interruptible(poll_value * 2) stalls runtime PM for hours on Chicony 04F2:B872 secondary proximity sensor
Date: Sun, 29 Nov 2026 06:37:54 -0800 [thread overview]
Message-ID: <a3ecc200f5d706c1436a3437043fccf44f1aeebf.camel@linux.intel.com> (raw)
In-Reply-To: <179591783777.39.15448655394533903125@rizvi.nu>
On Sat, 2026-11-28 at 21:03 -0500, Shan Rizvi wrote:
> 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.
A huge value for report interval. One report per 10K seconds.
Not sure why add this optional field here.
> - 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);
>
I think hung task warning when task is uninterruptible state:
:
Say Y here to enable the kernel to detect 'hung tasks', which are bugs
that cause the task to be stuck in uninterruptible 'D' state
indefinitely."
"
Anyway negative value check will not help, but should be added.
We can break msleep to 1 second loop to avoid hung task.
But "cat" will still wait for very long time here.
Try this:
Replace:
if (state && poll_value)
msleep_interruptible(poll_value * 2);
with
if (state && poll_value > 0) {
unsigned long max_sleep_ms = 120 * MSEC_PER_SEC;
unsigned long sleep_ms;
if (IS_ENABLED(CONFIG_DETECT_HUNG_TASK) &&
CONFIG_DEFAULT_HUNG_TASK_TIMEOUT > 0)
max_sleep_ms = CONFIG_DEFAULT_HUNG_TASK_TIMEOUT *
MSEC_PER_SEC;
if (poll_value * 2 > max_sleep_ms)
return -EIO;
sleep_ms = min_t(u64, (u64)poll_value * 2, max_sleep_ms);
msleep_interruptible(sleep_ms);
}
Thanks,
Srinivas
> 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
next prev parent reply other threads:[~2026-11-29 14:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-11-29 17:26 ` Shan Rizvi
2026-11-29 17:54 ` Srinivas Pandruvada
2026-11-29 19:18 ` Shan Rizvi
2026-11-30 13:07 ` Srinivas Pandruvada
2026-11-30 17:45 ` Shan Rizvi
2026-11-30 19:03 ` Srinivas Pandruvada
2026-12-01 19:52 ` Shan Rizvi
2026-12-01 20:08 ` Srinivas Pandruvada
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=a3ecc200f5d706c1436a3437043fccf44f1aeebf.camel@linux.intel.com \
--to=srinivas.pandruvada@linux.intel.com \
--cc=bentiss@kernel.org \
--cc=jic23@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=shan@rizvi.nu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.