iio: hid-sensors: Use software trigger
RFC PATCH 1/1 iio: hid-sensors: Use software trigger
Recent changes linux mainline resulted in warning:
"genirq: Warn about using IRQF_ONESHOT without a threaded handler" when HID sensor hub is used.
When INDIO_BUFFER_TRIGGERED is used, the core attaches a poll function when enabling the buffer. This poll function uses request_threaded_irq() with both bottom half and top half handlers. But when using HID sensor hub, bottom half (thread handler) is not registered.
In HID sensors, once a sensor is powered on, the hub collects samples and pushes data to the host when programmed thresholds are met. When this data is received for a sensor, it is pushed using iio_push_to_buffers_with_ts().
The sensor is powered ON or OFF based on the trigger callback set_trigger_state() when the poll function is attached. During the call to iio_triggered_buffer_setup_ext(), the HID sensor specifies only a handler function but provides no thread handler, as there is no data to read from the hub in thread context. Internally, this results in calling request_threaded_irq(). Recent kernel changes now warn when request_threaded_irq() is called without a thread handler.
To address this issue, fundamental changes are required to avoid using iio_triggered_buffer_setup_ext(). HID sensors can use INDIO_BUFFER_SOFTWARE instead of INDIO_BUFFER_TRIGGERED, as this can work in trigger-less mode.
In this approach, when user space opens the buffer, the sensor is powered on, and when the buffer is closed, the sensor is powered off using iio_buffer_setup_ops callbacks.
---
This is RFC, because
The current user space in distro "iio-sensor-proxy" is not working in trigerless mode as it expects /sys/bus/iio/devices/iio:device0/trigger/current_trigger. So, change needs to be submitted to fix that.
.../common/hid-sensors/hid-sensor-trigger.c | 62 ++++++------------- 1 file changed, 18 insertions(+), 44 deletions(-)
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +18 -44
@@ -14,6 +14,7 @@#include <linux/iio/triggered_buffer.h> #include <linux/iio/trigger_consumer.h> #include <linux/iio/sysfs.h> +#include <linux/iio/kfifo_buf.h> #include "hid-sensor-trigger.h" static ssize_t _hid_sensor_set_report_latency(struct device *dev,
@@ -202,12 +203,21 @@ static void hid_sensor_set_power_work(struct work_struct *work)_hid_sensor_power_state (attrb, true); } -static int hid_sensor_data_rdy_trigger_set_state (struct iio_trigger *trig, -bool state) +static int buffer_postenable (struct iio_dev *indio_dev) { -return hid_sensor_power_state (iio_trigger_get_drvdata (trig), state); +return hid_sensor_power_state (iio_device_get_drvdata (indio_dev),1 ); } +static int buffer_predisable (struct iio_dev *indio_dev) +{ +return hid_sensor_power_state (iio_device_get_drvdata (indio_dev),0 ); +} + +static const struct iio_buffer_setup_ops hid_sensor_buffer_ops = { + .postenable = buffer_postenable, + .predisable = buffer_predisable, +}; +void hid_sensor_remove_trigger (struct iio_dev *indio_dev,struct hid_sensor_common *attrb) {
@@ -217,59 +227,30 @@ void hid_sensor_remove_trigger(struct iio_dev *indio_dev,pm_runtime_set_suspended (&attrb->pdev->dev);cancel_work_sync (&attrb->work); -iio_trigger_unregister (attrb->trigger); -iio_trigger_free (attrb->trigger); -iio_triggered_buffer_cleanup (indio_dev); }EXPORT_SYMBOL_NS (hid_sensor_remove_trigger,"IIO_HID" ); -static const struct iio_trigger_ops hid_sensor_trigger_ops = { - .set_trigger_state = &hid_sensor_data_rdy_trigger_set_state, -}; -int hid_sensor_setup_trigger (struct iio_dev *indio_dev,const char *name,struct hid_sensor_common *attrb) {const struct iio_dev_attr **fifo_attrs;int ret; -struct iio_trigger *trig;if (hid_sensor_batch_mode_supported (attrb)) fifo_attrs = hid_sensor_fifo_attributes;else fifo_attrs =NULL ; - ret =iio_triggered_buffer_setup_ext (indio_dev, - &iio_pollfunc_store_time,NULL , -IIO_BUFFER_DIRECTION_IN , -NULL , fifo_attrs); + ret =devm_iio_kfifo_buffer_setup_ext (&indio_dev->dev, indio_dev, + &hid_sensor_buffer_ops, + fifo_attrs);if (ret) { -dev_err (&indio_dev->dev,"Triggered Buffer Setup Failed\n" ); +dev_err (&indio_dev->dev,"Kfifo Buffer Setup Failed\n" );return ret; } - - trig =iio_trigger_alloc (indio_dev->dev.parent, -"%s-dev%d" , name,iio_device_id (indio_dev)); -if (trig ==NULL ) { -dev_err (&indio_dev->dev,"Trigger Allocate Failed\n" ); - ret = -ENOMEM ; - goto error_triggered_buffer_cleanup; - } - -iio_trigger_set_drvdata (trig, attrb); - trig->ops = &hid_sensor_trigger_ops; - ret =iio_trigger_register (trig); - -if (ret) { -dev_err (&indio_dev->dev,"Trigger Register Failed\n" ); - goto error_free_trig; - } - attrb->trigger = trig; - indio_dev->trig =iio_trigger_get (trig); - ret =pm_runtime_set_active (&indio_dev->dev);if (ret) - goto error_unreg_trigger; +return ret;iio_device_set_drvdata (indio_dev, attrb);
@@ -280,13 +261,6 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,pm_runtime_set_autosuspend_delay (&attrb->pdev->dev,3000 );return ret; -error_unreg_trigger: -iio_trigger_unregister (trig); -error_free_trig: -iio_trigger_free (trig); -error_triggered_buffer_cleanup: -iio_triggered_buffer_cleanup (indio_dev); -return ret; }EXPORT_SYMBOL_NS (hid_sensor_setup_trigger,"IIO_HID" );
Signature · 1 line
2.52.0
Jonathan Cameron
maintainerQuoted 31 lines · On Mon, 9 Feb 2026 12:42:27 -0800 Srinivas Pandruvada…
Recent changes linux mainline resulted in warning:
"genirq: Warn about usingIRQF_ONESHOTwithout a threaded handler" when HID sensor hub is used.When
INDIO_BUFFER_TRIGGEREDis used, the core attaches a poll function when enabling the buffer. This poll function usesrequest_threaded_irq()with both bottom half and top half handlers. But when using HID sensor hub, bottom half (thread handler) is not registered.In HID sensors, once a sensor is powered on, the hub collects samples and pushes data to the host when programmed thresholds are met. When this data is received for a sensor, it is pushed using
iio_push_to_buffers_with_ts().The sensor is powered ON or OFF based on the trigger callback
set_trigger_state()when the poll function is attached. During the call toiio_triggered_buffer_setup_ext(), the HID sensor specifies only a handler function but provides no thread handler, as there is no data to read from the hub in thread context. Internally, this results in callingrequest_threaded_irq(). Recent kernel changes now warn whenrequest_threaded_irq()is called without a thread handler.To address this issue, fundamental changes are required to avoid using
iio_triggered_buffer_setup_ext(). HID sensors can useINDIO_BUFFER_SOFTWAREinstead ofINDIO_BUFFER_TRIGGERED, as this can work in trigger-less mode.In this approach, when user space opens the buffer, the sensor is powered on, and when the buffer is closed, the sensor is powered off using
iio_buffer_setup_opscallbacks.
Quoted 6 lines
Signed-off-by Srinivas Pandruvada <[email protected]>---
This is RFC, because
The current user space in distro "iio-sensor-proxy" is not working in trigerless mode as it expects /sys/bus/iio/devices/iio:device0/trigger/current_trigger. So, change needs to be submitted to fix that.
Sorry I took a while to reply to the previous thread - been off sick and just catching up again.
I think we can't make this change on it's own because of the backwards compatibility problem. Please can you try what you have here without removing the trigger adding chunk (as we still need that to exist) +
iio_dev->modes = INDIO_DIRECT | INDIO_HARDWARE_TRIGGERED;
It's been a while but I think that is there basically to hook up current_trigger. That was intended for cases where there are several to choose between but
I think it should do the job here of bringing back the interface. Add a comment
though on why it is there.
I've tried to say roughly what to keep and drop inline.
thanks,
Jonathan
Quoted 27 lines
.../common/hid-sensors/hid-sensor-trigger.c | 62 ++++++------------- 1 file changed, 18 insertions(+), 44 deletions(-)drivers/iio/common/hid-sensors/hid-sensor-trigger.c +3
-3@@ -14,6 +14,7 @@#include <linux/iio/triggered_buffer.h> #include <linux/iio/trigger_consumer.h> #include <linux/iio/sysfs.h> +#include <linux/iio/kfifo_buf.h> #include "hid-sensor-trigger.h" static ssize_t _hid_sensor_set_report_latency(struct device *dev,@@ -202,12 +203,21 @@ static void hid_sensor_set_power_work(struct work_struct *work)_hid_sensor_power_state (attrb, true); } -static int hid_sensor_data_rdy_trigger_set_state (struct iio_trigger *trig, -bool state) +static int buffer_postenable (struct iio_dev *indio_dev) { -return hid_sensor_power_state (iio_trigger_get_drvdata (trig), state); +return hid_sensor_power_state (iio_device_get_drvdata (indio_dev),1 ); }
drivers/iio/common/hid-sensors/hid-sensor-trigger.c static void hid_sensor_set_power_work(struct work_struct *work) · line 219
Quoted 10 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +9
-0+static int buffer_predisable (struct iio_dev *indio_dev) +{ +return hid_sensor_power_state (iio_device_get_drvdata (indio_dev),0 ); +} + +static const struct iio_buffer_setup_ops hid_sensor_buffer_ops = { + .postenable = buffer_postenable, + .predisable = buffer_predisable, +};
I think these changes all help simplify things anyway so probably good to have. Maybe we could do them in a follow up rather than the fix but I'll leave that up to you.
drivers/iio/common/hid-sensors/hid-sensor-trigger.c void hid_sensor_remove_trigger(struct iio_dev *indio_dev, · line 221
Quoted 10 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-2+void hid_sensor_remove_trigger (struct iio_dev *indio_dev,struct hid_sensor_common *attrb) {@@ -217,59 +227,30 @@ void hid_sensor_remove_trigger(struct iio_dev *indio_dev,pm_runtime_set_suspended (&attrb->pdev->dev);cancel_work_sync (&attrb->work); -iio_trigger_unregister (attrb->trigger); -iio_trigger_free (attrb->trigger);
Keep the trigger parts here.
drivers/iio/common/hid-sensors/hid-sensor-trigger.c void hid_sensor_remove_trigger(struct iio_dev *indio_dev, · line 228
Quoted 7 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-4-iio_triggered_buffer_cleanup (indio_dev); }EXPORT_SYMBOL_NS (hid_sensor_remove_trigger,"IIO_HID" ); -static const struct iio_trigger_ops hid_sensor_trigger_ops = { - .set_trigger_state = &hid_sensor_data_rdy_trigger_set_state, -};
and this.
Quoted 15 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-4-int hid_sensor_setup_trigger (struct iio_dev *indio_dev,const char *name,struct hid_sensor_common *attrb) {const struct iio_dev_attr **fifo_attrs;int ret; -struct iio_trigger *trig;if (hid_sensor_batch_mode_supported (attrb)) fifo_attrs = hid_sensor_fifo_attributes;else fifo_attrs =NULL ; - ret = iio_triggered_buffer_setup_ext(indio_dev, - &iio_pollfunc_store_time, NULL,
drivers/iio/common/hid-sensors/hid-sensor-trigger.c void hid_sensor_remove_trigger(struct iio_dev *indio_dev, · line 250
Quoted 10 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +4
-3-IIO_BUFFER_DIRECTION_IN , - NULL, fifo_attrs); + ret =devm_iio_kfifo_buffer_setup_ext (&indio_dev->dev, indio_dev, + &hid_sensor_buffer_ops, + fifo_attrs);if (ret) { -dev_err (&indio_dev->dev,"Triggered Buffer Setup Failed\n" ); +dev_err (&indio_dev->dev,"Kfifo Buffer Setup Failed\n" );return ret; }
Down to here is good but keep the trigger setup.
Quoted 41 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-28- - trig =iio_trigger_alloc (indio_dev->dev.parent, -"%s-dev%d" , name,iio_device_id (indio_dev)); -if (trig ==NULL ) { -dev_err (&indio_dev->dev,"Trigger Allocate Failed\n" ); - ret = -ENOMEM ; - goto error_triggered_buffer_cleanup; - } - -iio_trigger_set_drvdata (trig, attrb); - trig->ops = &hid_sensor_trigger_ops; - ret =iio_trigger_register (trig); - -if (ret) { -dev_err (&indio_dev->dev,"Trigger Register Failed\n" ); - goto error_free_trig; - } - attrb->trigger = trig; - indio_dev->trig =iio_trigger_get (trig); - ret =pm_runtime_set_active (&indio_dev->dev);if (ret) - goto error_unreg_trigger; +return ret;iio_device_set_drvdata (indio_dev, attrb);@@ -280,13 +261,6 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,pm_runtime_set_autosuspend_delay (&attrb->pdev->dev,3000 );return ret; -error_unreg_trigger: -iio_trigger_unregister (trig); -error_free_trig: -iio_trigger_free (trig); -error_triggered_buffer_cleanup: -iio_triggered_buffer_cleanup (indio_dev); -return ret; }EXPORT_SYMBOL_NS (hid_sensor_setup_trigger,"IIO_HID" );
Quoted 54 lines · Jonathan Cameron
Quoted 41 lines · On Mon, 9 Feb 2026 12:42:27 -0800 Srinivas Pandruvada…
Recent changes linux mainline resulted in warning:
"genirq: Warn about usingIRQF_ONESHOTwithout a threaded handler" when HID sensor hub is used.When
INDIO_BUFFER_TRIGGEREDis used, the core attaches a poll function
when enabling the buffer. This poll function usesrequest_threaded_irq()
with both bottom half and top half handlers. But when using HID sensor hub, bottom half (thread handler) is not registered.In HID sensors, once a sensor is powered on, the hub collects samples
and pushes data to the host when programmed thresholds are met. When
this data is received for a sensor, it is pushed usingiio_push_to_buffers_with_ts().The sensor is powered ON or OFF based on the trigger callback
set_trigger_state()when the poll function is attached. During the call
toiio_triggered_buffer_setup_ext(), the HID sensor specifies only a
handler function but provides no thread handler, as there is no data
to read from the hub in thread context. Internally, this results in callingrequest_threaded_irq(). Recent kernel changes now warn whenrequest_threaded_irq()is called without a thread handler.To address this issue, fundamental changes are required to avoid using
iio_triggered_buffer_setup_ext(). HID sensors can useINDIO_BUFFER_SOFTWAREinstead ofINDIO_BUFFER_TRIGGERED, as this can
work in trigger-less mode.In this approach, when user space opens the buffer, the sensor is powered
on, and when the buffer is closed, the sensor is powered off usingiio_buffer_setup_opscallbacks.Quoted 9 lines
Signed-off-by: Srinivas Pandruvada <[email protected]>
---
This is RFC, because
The current user space in distro "iio-sensor-proxy" is not working in
trigerless mode as it expects /sys/bus/iio/devices/iio:device0/trigger/current_trigger. So, change needs to be submitted to fix that.
Quoted 3 lines
Sorry I took a while to reply to the previous thread - been off sick and
just catching up again.
No problem. Hope you are feeling better.
Quoted 9 lines
I think we can't make this change on it's own because of the backwards compatibility
problem. Please can you try what you have here without removing the trigger adding
chunk (as we still need that to exist) +
iio_dev->modes=INDIO_DIRECT|INDIO_HARDWARE_TRIGGERED;
This is not enough as this will fail when buffer0 enable attribute is set to 1.
https://elixir.bootlin.com/linux/v6.18.6/source/drivers/iio/industrialio-buffer.c#L951
But
iio_dev->modes |= INDIO_DIRECT | INDIO_HARDWARE_TRIGGERED;
works.
Quoted 55 lines
It's been a while but I think that is there basically to hook up
current_trigger.
That was intended for cases where there are several to choose between but
I think it should do the job here of bringing back the interface. Add a comment
though on why it is there.I've tried to say roughly what to keep and drop inline.
thanks,
Jonathan
Quoted 39 lines
.../common/hid-sensors/hid-sensor-trigger.c | 62 ++++++---------
----1 file changed, 18 insertions(+), 44 deletions(-)drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0@@ -14,6 +14,7 @@ #include <linux/iio/triggered_buffer.h> #include <linux/iio/trigger_consumer.h> #include <linux/iio/sysfs.h> +#include <linux/iio/kfifo_buf.h> #include "hid-sensor-trigger.h"
staticssize_t_hid_sensor_set_report_latency(struct device *dev,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-0@@ -202,12 +203,21 @@ static void hid_sensor_set_power_work(struct work_struct *work) _hid_sensor_power_state(attrb, true); }
-static int hid_sensor_data_rdy_trigger_set_state(structiio_trigger*trig,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-1- bool state) +static int buffer_postenable (struct iio_dev *indio_dev){
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1-return
hid_sensor_power_state(iio_trigger_get_drvdata(trig), state);drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+return
hid_sensor_power_state(iio_device_get_drvdata(indio_dev), 1); }drivers/iio/common/hid-sensors/hid-sensor-trigger.c +3
-0+static int buffer_predisable (struct iio_dev *indio_dev) +{ +return
hid_sensor_power_state(iio_device_get_drvdata(indio_dev), 0); +}
Quoted 8 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c static void hid_sensor_set_power_work(struct work_struct *work) · line 219
Quoted 5 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +5
-0+ +static const struct iio_buffer_setup_ops hid_sensor_buffer_ops = { + .postenable = buffer_postenable, + .predisable = buffer_predisable, +};I think these changes all help simplify things anyway so probably good to have. Maybe we could do them in a follow up rather than the fix but I'll leave that up to you
This is required as the hid_sensor_trigger_ops.set_trigger_state() is not called once iio_triggered_buffer_setup_ext() is removed.
Quoted 14 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c void hid_sensor_remove_trigger(struct iio_dev *indio_dev, · line 221
Quoted 12 lines
+
voidhid_sensor_remove_trigger(struct iio_dev *indio_dev, struct hid_sensor_common *attrb){drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-0@@ -217,59 +227,30 @@ void hid_sensor_remove_trigger(struct iio_dev *indio_dev, pm_runtime_set_suspended(&attrb->pdev->dev);
cancel_work_sync(&attrb->work);drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-2-iio_trigger_unregister (attrb->trigger); -iio_trigger_free (attrb->trigger);Keep the trigger parts here.
Quoted 9 lines
Quoted 8 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1-iio_triggered_buffer_cleanup (indio_dev);}
EXPORT_SYMBOL_NS(hid_sensor_remove_trigger, "IIO_HID");drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-2-static const struct iio_trigger_ops hid_sensor_trigger_ops = { - .set_trigger_state =
&hid_sensor_data_rdy_trigger_set_state,
-};and this.
This callback is not called without iio_triggered_buffer_setup_ext().
Quoted 25 lines
Quoted 25 lines
-
int hid_sensor_setup_trigger(structiio_dev*indio_dev, const char *name,
structhid_sensor_common*attrb) {
const structiio_dev_attr**fifo_attrs;
int ret;drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1-struct iio_trigger *trig;
if (hid_sensor_batch_mode_supported(attrb))fifo_attrs=hid_sensor_fifo_attributes; else
fifo_attrs= NULL;drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-2- ret = iio_triggered_buffer_setup_ext(indio_dev, -
&iio_pollfunc_store_time, NULL,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1-
IIO_BUFFER_DIRECTION_IN,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-1- NULL, fifo_attrs); + ret = devm_iio_kfifo_buffer_setup_ext(&indio_dev->dev,
indio_dev,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+
&hid_sensor_buffer_ops,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+ fifo_attrs);
Quoted 8 lines
Quoted 7 lines
if (ret) {
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1- dev_err(&indio_dev->dev, "Triggered Buffer SetupFailed\n");
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+ dev_err(&indio_dev->dev, "Kfifo Buffer SetupFailed\n");
return ret;
}Down to here is good but keep the trigger setup.
I can keep with additional
iio_dev->modes |= INDIO_DIRECT | INDIO_HARDWARE_TRIGGERED;
I will send a patch with the changes.
Thanks,
Srinivas
Quoted 46 lines
Quoted 46 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-3- - trig = iio_trigger_alloc(indio_dev->dev.parent, - "%s-dev%d", name,
iio_device_id(indio_dev));drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-2-if (trig ==NULL ) { - dev_err(&indio_dev->dev, "Trigger AllocateFailed\n");
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-10- ret = -ENOMEM ; - goto error_triggered_buffer_cleanup; - } - -iio_trigger_set_drvdata (trig, attrb); - trig->ops = &hid_sensor_trigger_ops; - ret =iio_trigger_register (trig); - -if (ret) { - dev_err(&indio_dev->dev, "Trigger RegisterFailed\n");
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-5- goto error_free_trig; - } - attrb->trigger = trig; - indio_dev->trig =iio_trigger_get (trig); -ret =
pm_runtime_set_active(&indio_dev->dev); if (ret)drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-1- goto error_unreg_trigger; +return ret;
iio_device_set_drvdata(indio_dev, attrb);drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-7@@ -280,13 +261,6 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, pm_runtime_set_autosuspend_delay(&attrb->pdev->dev, 3000); return ret; -error_unreg_trigger: -iio_trigger_unregister (trig); -error_free_trig: -iio_trigger_free (trig); -error_triggered_buffer_cleanup: -iio_triggered_buffer_cleanup (indio_dev); -return ret; } EXPORT_SYMBOL_NS(hid_sensor_setup_trigger, "IIO_HID");
Jonathan Cameron
maintainerQuoted 73 lines · On Mon, 16 Feb 2026 14:49:38 -0800 srinivas pandruvada…
Quoted 54 lines · Jonathan Cameron
Quoted 41 lines · On Mon, 9 Feb 2026 12:42:27 -0800 Srinivas Pandruvada…
Recent changes linux mainline resulted in warning:
"genirq: Warn about usingIRQF_ONESHOTwithout a threaded handler" when HID sensor hub is used.When
INDIO_BUFFER_TRIGGEREDis used, the core attaches a poll function
when enabling the buffer. This poll function usesrequest_threaded_irq()
with both bottom half and top half handlers. But when using HID sensor hub, bottom half (thread handler) is not registered.In HID sensors, once a sensor is powered on, the hub collects samples
and pushes data to the host when programmed thresholds are met. When
this data is received for a sensor, it is pushed usingiio_push_to_buffers_with_ts().The sensor is powered ON or OFF based on the trigger callback
set_trigger_state()when the poll function is attached. During the call
toiio_triggered_buffer_setup_ext(), the HID sensor specifies only a
handler function but provides no thread handler, as there is no data
to read from the hub in thread context. Internally, this results in callingrequest_threaded_irq(). Recent kernel changes now warn whenrequest_threaded_irq()is called without a thread handler.To address this issue, fundamental changes are required to avoid using
iio_triggered_buffer_setup_ext(). HID sensors can useINDIO_BUFFER_SOFTWAREinstead ofINDIO_BUFFER_TRIGGERED, as this can
work in trigger-less mode.In this approach, when user space opens the buffer, the sensor is powered
on, and when the buffer is closed, the sensor is powered off usingiio_buffer_setup_opscallbacks.Quoted 9 lines
Signed-off-by: Srinivas Pandruvada <[email protected]>
---
This is RFC, because
The current user space in distro "iio-sensor-proxy" is not working in
trigerless mode as it expects /sys/bus/iio/devices/iio:device0/trigger/current_trigger. So, change needs to be submitted to fix that.Quoted 3 lines
Sorry I took a while to reply to the previous thread - been off sick and
just catching up again.No problem. Hope you are feeling better.
Quoted 9 lines
I think we can't make this change on it's own because of the backwards compatibility
problem. Please can you try what you have here without removing the trigger adding
chunk (as we still need that to exist) +
iio_dev->modes=INDIO_DIRECT|INDIO_HARDWARE_TRIGGERED;This is not enough as this will fail when buffer0 enable attribute is set to 1.
Quoted 8 lines
https://elixir.bootlin.com/linux/v6.18.6/source/drivers/iio/industrialio-buffer.c#L951
But
iio_dev->modes|=INDIO_DIRECT|INDIO_HARDWARE_TRIGGERED;works.
I'm lost. Which other mode is set? Maybe shift this up before
whatever sets that would be clearer?
J
Quoted 184 lines
Quoted 57 lines
It's been a while but I think that is there basically to hook up
current_trigger.
That was intended for cases where there are several to choose between but
I think it should do the job here of bringing back the interface. Add a comment
though on why it is there.I've tried to say roughly what to keep and drop inline.
thanks,
Jonathan
Quoted 39 lines
.../common/hid-sensors/hid-sensor-trigger.c | 62 ++++++---------
----1 file changed, 18 insertions(+), 44 deletions(-)drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0@@ -14,6 +14,7 @@ #include <linux/iio/triggered_buffer.h> #include <linux/iio/trigger_consumer.h> #include <linux/iio/sysfs.h> +#include <linux/iio/kfifo_buf.h> #include "hid-sensor-trigger.h"
staticssize_t_hid_sensor_set_report_latency(struct device *dev,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-0@@ -202,12 +203,21 @@ static void hid_sensor_set_power_work(struct work_struct *work) _hid_sensor_power_state(attrb, true); }
-static int hid_sensor_data_rdy_trigger_set_state(structiio_trigger*trig,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-1- bool state) +static int buffer_postenable (struct iio_dev *indio_dev){
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1-return
hid_sensor_power_state(iio_trigger_get_drvdata(trig), state);drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+return
hid_sensor_power_state(iio_device_get_drvdata(indio_dev), 1); }drivers/iio/common/hid-sensors/hid-sensor-trigger.c +3
-0+static int buffer_predisable (struct iio_dev *indio_dev) +{ +return
hid_sensor_power_state(iio_device_get_drvdata(indio_dev), 0); +}Quoted 8 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c static void hid_sensor_set_power_work(struct work_struct *work) · line 219
Quoted 5 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +5
-0+ +static const struct iio_buffer_setup_ops hid_sensor_buffer_ops = { + .postenable = buffer_postenable, + .predisable = buffer_predisable, +};I think these changes all help simplify things anyway so probably good to have. Maybe we could do them in a follow up rather than the fix but I'll leave that up to you
This is required as the
hid_sensor_trigger_ops.set_trigger_state()is not called onceiio_triggered_buffer_setup_ext()is removed.Quoted 14 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c void hid_sensor_remove_trigger(struct iio_dev *indio_dev, · line 221
Quoted 12 lines
+
voidhid_sensor_remove_trigger(struct iio_dev *indio_dev, struct hid_sensor_common *attrb){drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-0@@ -217,59 +227,30 @@ void hid_sensor_remove_trigger(struct iio_dev *indio_dev, pm_runtime_set_suspended(&attrb->pdev->dev);
cancel_work_sync(&attrb->work);drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-2-iio_trigger_unregister (attrb->trigger); -iio_trigger_free (attrb->trigger);Keep the trigger parts here.
Quoted 9 lines
Quoted 8 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1-iio_triggered_buffer_cleanup (indio_dev);}
EXPORT_SYMBOL_NS(hid_sensor_remove_trigger, "IIO_HID");drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-2-static const struct iio_trigger_ops hid_sensor_trigger_ops = { - .set_trigger_state =
&hid_sensor_data_rdy_trigger_set_state,
-};and this.
This callback is not called without
iio_triggered_buffer_setup_ext().Quoted 25 lines
Quoted 25 lines
-
int hid_sensor_setup_trigger(structiio_dev*indio_dev, const char *name,
structhid_sensor_common*attrb) {
const structiio_dev_attr**fifo_attrs;
int ret;drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1-struct iio_trigger *trig;
if (hid_sensor_batch_mode_supported(attrb))fifo_attrs=hid_sensor_fifo_attributes; else
fifo_attrs= NULL;drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-2- ret = iio_triggered_buffer_setup_ext(indio_dev, -
&iio_pollfunc_store_time, NULL,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1-
IIO_BUFFER_DIRECTION_IN,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-1- NULL, fifo_attrs); + ret = devm_iio_kfifo_buffer_setup_ext(&indio_dev->dev,
indio_dev,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+
&hid_sensor_buffer_ops,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+ fifo_attrs);Quoted 8 lines
Quoted 7 lines
if (ret) {
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1- dev_err(&indio_dev->dev, "Triggered Buffer SetupFailed\n");
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+ dev_err(&indio_dev->dev, "Kfifo Buffer SetupFailed\n");
return ret;
}Down to here is good but keep the trigger setup.
I can keep with additional
iio_dev->modes|=INDIO_DIRECT|INDIO_HARDWARE_TRIGGERED;I will send a patch with the changes.
Thanks,
SrinivasQuoted 46 lines
Quoted 46 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-3- - trig = iio_trigger_alloc(indio_dev->dev.parent, - "%s-dev%d", name,
iio_device_id(indio_dev));drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-2-if (trig ==NULL ) { - dev_err(&indio_dev->dev, "Trigger AllocateFailed\n");
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-10- ret = -ENOMEM ; - goto error_triggered_buffer_cleanup; - } - -iio_trigger_set_drvdata (trig, attrb); - trig->ops = &hid_sensor_trigger_ops; - ret =iio_trigger_register (trig); - -if (ret) { - dev_err(&indio_dev->dev, "Trigger RegisterFailed\n");
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-5- goto error_free_trig; - } - attrb->trigger = trig; - indio_dev->trig =iio_trigger_get (trig); -ret =
pm_runtime_set_active(&indio_dev->dev); if (ret)drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-1- goto error_unreg_trigger; +return ret;
iio_device_set_drvdata(indio_dev, attrb);drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-7@@ -280,13 +261,6 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, pm_runtime_set_autosuspend_delay(&attrb->pdev->dev, 3000); return ret; -error_unreg_trigger: -iio_trigger_unregister (trig); -error_free_trig: -iio_trigger_free (trig); -error_triggered_buffer_cleanup: -iio_triggered_buffer_cleanup (indio_dev); -return ret; } EXPORT_SYMBOL_NS(hid_sensor_setup_trigger, "IIO_HID");
Quoted 92 lines · Jonathan Cameron
Quoted 80 lines · On Mon, 16 Feb 2026 14:49:38 -0800 srinivas pandruvada…
Quoted 64 lines · Jonathan Cameron
On Mon, 9 Feb 2026 12:42:27 -0800
Srinivas Pandruvada <[email protected]> wrote:Quoted 50 lines
Recent changes linux mainline resulted in warning:
"genirq: Warn about usingIRQF_ONESHOTwithout a threaded handler"
when HID sensor hub is used.When
INDIO_BUFFER_TRIGGEREDis used, the core attaches a poll function
when enabling the buffer. This poll function usesrequest_threaded_irq()
with both bottom half and top half handlers. But when using HID sensor hub, bottom half (thread handler) is not registered.In HID sensors, once a sensor is powered on, the hub collects samples
and pushes data to the host when programmed thresholds are met. When
this data is received for a sensor, it is pushed usingiio_push_to_buffers_with_ts().The sensor is powered ON or OFF based on the trigger callback
set_trigger_state()when the poll function is attached. During the
call
toiio_triggered_buffer_setup_ext(), the HID sensor specifies only
a
handler function but provides no thread handler, as there is no data
to read from the hub in thread context. Internally, this results in
callingrequest_threaded_irq(). Recent kernel changes now warn whenrequest_threaded_irq()is called without a thread handler.To address this issue, fundamental changes are required to avoid
usingiio_triggered_buffer_setup_ext(). HID sensors can useINDIO_BUFFER_SOFTWAREinstead ofINDIO_BUFFER_TRIGGERED, as this
can
work in trigger-less mode.In this approach, when user space opens the buffer, the sensor is
powered
on, and when the buffer is closed, the sensor is powered off usingiio_buffer_setup_opscallbacks.Quoted 10 lines
Signed-off-by: Srinivas Pandruvada <[email protected]>
---
This is RFC, because
The current user space in distro "iio-sensor-proxy" is not working
in
trigerless mode as it expects /sys/bus/iio/devices/iio:device0/trigger/current_trigger. So, change needs to be submitted to fix that.Quoted 4 lines
Sorry I took a while to reply to the previous thread - been off sick
and
just catching up again.No problem. Hope you are feeling better.
Quoted 8 lines
I think we can't make this change on it's own because of the backwards compatibility
problem. Please can you try what you have here without removing the
trigger adding
chunk (as we still need that to exist) +Quoted 7 lines
Quoted 2 lines
iio_dev->modes=INDIO_DIRECT|INDIO_HARDWARE_TRIGGERED;This is not enough as this will fail when buffer0 enable attribute is
set to 1.https://elixir.bootlin.com/linux/v6.18.6/source/drivers/iio/industrialio-buffer.c#L951
Quoted 9 lines
Quoted 5 lines
But
iio_dev->modes|=INDIO_DIRECT|INDIO_HARDWARE_TRIGGERED;works.
I'm lost. Which other mode is set? Maybe shift this up before whatever sets that would be clearer?
Driver initialize this toiio_dev->modes = INDIO_DIRECT
Call to
https://elixir.bootlin.com/linux/v6.18.6/C/ident/devm_iio_kfifo_buffer_setup_ext
will set to
indio_dev->modes |= INDIO_BUFFER_SOFTWARE;
After if we doiio_dev->modes = INDIO_DIRECT | INDIO_HARDWARE_TRIGGERED;
INDIO_BUFFER_SOFTWARE will be overwritten.
I think we can setiio_dev->modes = INDIO_DIRECT | INDIO_HARDWARE_TRIGGERED;
before callingdevm_iio_kfifo_buffer_setup_ext(), then there is no need for "|".
Thanks,
Srinivas
Quoted 202 lines
J
Quoted 201 lines
Quoted 65 lines
It's been a while but I think that is there basically to hook up
current_trigger.
That was intended for cases where there are several to choose between
but
I think it should do the job here of bringing back the interface.
Add a comment
though on why it is there.I've tried to say roughly what to keep and drop inline.
thanks,
Jonathan
Quoted 45 lines
.../common/hid-sensors/hid-sensor-trigger.c | 62 ++++++-----
----
----1 file changed, 18 insertions(+), 44 deletions(-)(quoted diff) +0
-0
trigger.cb/drivers/iio/common/hid-sensors/hid-sensor-trigger.cindex5540e2d28f4a..113fd1361643100644drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0@@ -14,6 +14,7 @@ #include <linux/iio/triggered_buffer.h> #include <linux/iio/trigger_consumer.h> #include <linux/iio/sysfs.h> +#include <linux/iio/kfifo_buf.h> #include "hid-sensor-trigger.h"
staticssize_t_hid_sensor_set_report_latency(struct device *dev,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-0@@ -202,12 +203,21 @@ static voidhid_sensor_set_power_work(struct
work_struct*work)_hid_sensor_power_state(attrb, true); }
-static int hid_sensor_data_rdy_trigger_set_state(structiio_trigger*trig,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-1- bool state) +static int buffer_postenable (struct iio_dev *indio_dev){
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1-return
hid_sensor_power_state(iio_trigger_get_drvdata(trig), state);drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+return
hid_sensor_power_state(iio_device_get_drvdata(indio_dev), 1); }drivers/iio/common/hid-sensors/hid-sensor-trigger.c +3
-0+static int buffer_predisable (struct iio_dev *indio_dev) +{ +return
hid_sensor_power_state(iio_device_get_drvdata(indio_dev), 0);drivers/iio/common/hid-sensors/hid-sensor-trigger.c +3
-0+} + +static const struct iio_buffer_setup_ops hid_sensor_buffer_opsQuoted 8 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c static void hid_sensor_set_power_work(struct work_struct *work) · line 219
Quoted 4 lines
= {
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +3
-0+ .postenable = buffer_postenable, + .predisable = buffer_predisable, +};I think these changes all help simplify things anyway so probably good to have. Maybe we could do them in a follow up rather than the
fix but I'll leave that up to youThis is required as the
hid_sensor_trigger_ops.set_trigger_state()is
not called onceiio_triggered_buffer_setup_ext()is removed.Quoted 16 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c void hid_sensor_remove_trigger(struct iio_dev *indio_dev, · line 221
Quoted 13 lines
+
voidhid_sensor_remove_trigger(struct iio_dev *indio_dev, struct hid_sensor_common *attrb)
{drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-0@@ -217,59 +227,30 @@ void hid_sensor_remove_trigger(struct
iio_dev*indio_dev,pm_runtime_set_suspended(&attrb->pdev->dev);
cancel_work_sync(&attrb->work);drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-2-iio_trigger_unregister (attrb->trigger); - iio_trigger_free(attrb->trigger);Keep the trigger parts here.
Quoted 9 lines
Quoted 8 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1-iio_triggered_buffer_cleanup (indio_dev);}
EXPORT_SYMBOL_NS(hid_sensor_remove_trigger, "IIO_HID");drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-2-static const struct iio_trigger_ops hid_sensor_trigger_ops = { - .set_trigger_state =
&hid_sensor_data_rdy_trigger_set_state,
-};and this.
This callback is not called without
iio_triggered_buffer_setup_ext().Quoted 29 lines
Quoted 29 lines
-
int hid_sensor_setup_trigger(structiio_dev*indio_dev, const char
*name,
structhid_sensor_common*attrb)
{
const structiio_dev_attr**fifo_attrs;
int ret;drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1-struct iio_trigger *trig;
if (hid_sensor_batch_mode_supported(attrb))fifo_attrs=hid_sensor_fifo_attributes; else
fifo_attrs= NULL;drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-2- ret = iio_triggered_buffer_setup_ext(indio_dev, -
&iio_pollfunc_store_time, NULL,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1-
IIO_BUFFER_DIRECTION_IN,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1- NULL,
fifo_attrs);drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+ ret = devm_iio_kfifo_buffer_setup_ext(&indio_dev->dev,
indio_dev,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+
&hid_sensor_buffer_ops,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+ fifo_attrs);if (ret) {
Quoted 8 lines
Quoted 7 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1- dev_err(&indio_dev->dev, "Triggered BufferSetup
Failed\n");drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+ dev_err(&indio_dev->dev, "Kfifo Buffer SetupFailed\n");
return ret;
}Down to here is good but keep the trigger setup.
I can keep with additional
iio_dev->modes|=INDIO_DIRECT|INDIO_HARDWARE_TRIGGERED;I will send a patch with the changes.
Thanks,
SrinivasQuoted 47 lines
Quoted 46 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-3- - trig = iio_trigger_alloc(indio_dev->dev.parent, - "%s-dev%d", name,
iio_device_id(indio_dev));drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-2-if (trig ==NULL ) { - dev_err(&indio_dev->dev, "Trigger AllocateFailed\n");
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-10- ret = -ENOMEM ; - goto error_triggered_buffer_cleanup; - } - -iio_trigger_set_drvdata (trig, attrb); - trig->ops = &hid_sensor_trigger_ops; - ret =iio_trigger_register (trig); - -if (ret) { - dev_err(&indio_dev->dev, "Trigger RegisterFailed\n");
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-5- goto error_free_trig; - } - attrb->trigger = trig; - indio_dev->trig =iio_trigger_get (trig); -ret =
pm_runtime_set_active(&indio_dev->dev); if (ret)drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-1- goto error_unreg_trigger; +return ret;
iio_device_set_drvdata(indio_dev, attrb);drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-0@@ -280,13 +261,6 @@ int hid_sensor_setup_trigger(struct
iio_dev*indio_dev, const char *name,pm_runtime_set_autosuspend_delay(&attrb->pdev->dev, 3000); return ret;drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-7-error_unreg_trigger: -iio_trigger_unregister (trig); -error_free_trig: -iio_trigger_free (trig); -error_triggered_buffer_cleanup: -iio_triggered_buffer_cleanup (indio_dev); -return ret;}
EXPORT_SYMBOL_NS(hid_sensor_setup_trigger, "IIO_HID");
Jonathan Cameron
maintainerQuoted 115 lines · On Wed, 18 Feb 2026 15:47:09 -0800 srinivas pandruvada…
Quoted 92 lines · Jonathan Cameron
Quoted 80 lines · On Mon, 16 Feb 2026 14:49:38 -0800 srinivas pandruvada…
Quoted 64 lines · Jonathan Cameron
On Mon, 9 Feb 2026 12:42:27 -0800
Srinivas Pandruvada <[email protected]> wrote:Quoted 50 lines
Recent changes linux mainline resulted in warning:
"genirq: Warn about usingIRQF_ONESHOTwithout a threaded handler"
when HID sensor hub is used.When
INDIO_BUFFER_TRIGGEREDis used, the core attaches a poll function
when enabling the buffer. This poll function usesrequest_threaded_irq()
with both bottom half and top half handlers. But when using HID sensor hub, bottom half (thread handler) is not registered.In HID sensors, once a sensor is powered on, the hub collects samples
and pushes data to the host when programmed thresholds are met. When
this data is received for a sensor, it is pushed usingiio_push_to_buffers_with_ts().The sensor is powered ON or OFF based on the trigger callback
set_trigger_state()when the poll function is attached. During the
call
toiio_triggered_buffer_setup_ext(), the HID sensor specifies only
a
handler function but provides no thread handler, as there is no data
to read from the hub in thread context. Internally, this results in
callingrequest_threaded_irq(). Recent kernel changes now warn whenrequest_threaded_irq()is called without a thread handler.To address this issue, fundamental changes are required to avoid
usingiio_triggered_buffer_setup_ext(). HID sensors can useINDIO_BUFFER_SOFTWAREinstead ofINDIO_BUFFER_TRIGGERED, as this
can
work in trigger-less mode.In this approach, when user space opens the buffer, the sensor is
powered
on, and when the buffer is closed, the sensor is powered off usingiio_buffer_setup_opscallbacks.Quoted 10 lines
Signed-off-by: Srinivas Pandruvada <[email protected]>
---
This is RFC, because
The current user space in distro "iio-sensor-proxy" is not working
in
trigerless mode as it expects /sys/bus/iio/devices/iio:device0/trigger/current_trigger. So, change needs to be submitted to fix that.Quoted 4 lines
Sorry I took a while to reply to the previous thread - been off sick
and
just catching up again.No problem. Hope you are feeling better.
Quoted 8 lines
I think we can't make this change on it's own because of the backwards compatibility
problem. Please can you try what you have here without removing the
trigger adding
chunk (as we still need that to exist) +Quoted 7 lines
Quoted 2 lines
iio_dev->modes=INDIO_DIRECT|INDIO_HARDWARE_TRIGGERED;This is not enough as this will fail when buffer0 enable attribute is
set to 1.https://elixir.bootlin.com/linux/v6.18.6/source/drivers/iio/industrialio-buffer.c#L951
Quoted 9 lines
Quoted 5 lines
But
iio_dev->modes|=INDIO_DIRECT|INDIO_HARDWARE_TRIGGERED;works.
I'm lost. Which other mode is set? Maybe shift this up before whatever sets that would be clearer?
Driver initialize this to
iio_dev->modes=INDIO_DIRECTCall to
https://elixir.bootlin.com/linux/v6.18.6/C/ident/devm_iio_kfifo_buffer_setup_ext
will set to
indio_dev->modes|=INDIO_BUFFER_SOFTWARE;After if we do
iio_dev->modes=INDIO_DIRECT|INDIO_HARDWARE_TRIGGERED;
Quoted 7 lines
INDIO_BUFFER_SOFTWAREwill be overwritten.I think we can set
iio_dev->modes=INDIO_DIRECT|INDIO_HARDWARE_TRIGGERED;before calling
devm_iio_kfifo_buffer_setup_ext(), then there is no need for "|".
Thanks. That makes sense. At some point we should probably wrap
up seeing modes in a helper to ensure the ordering doesn't matter for cases like this one.
That will be a big job for fairly small gain though so maybe not worth the effort.
Jonathan
Quoted 207 lines
Thanks,
SrinivasQuoted 202 lines
J
Quoted 201 lines
Quoted 65 lines
It's been a while but I think that is there basically to hook up
current_trigger.
That was intended for cases where there are several to choose between
but
I think it should do the job here of bringing back the interface.
Add a comment
though on why it is there.I've tried to say roughly what to keep and drop inline.
thanks,
Jonathan
Quoted 45 lines
.../common/hid-sensors/hid-sensor-trigger.c | 62 ++++++-----
----
----1 file changed, 18 insertions(+), 44 deletions(-)(quoted diff) +0
-0
trigger.cb/drivers/iio/common/hid-sensors/hid-sensor-trigger.cindex5540e2d28f4a..113fd1361643100644drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0@@ -14,6 +14,7 @@ #include <linux/iio/triggered_buffer.h> #include <linux/iio/trigger_consumer.h> #include <linux/iio/sysfs.h> +#include <linux/iio/kfifo_buf.h> #include "hid-sensor-trigger.h"
staticssize_t_hid_sensor_set_report_latency(struct device *dev,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-0@@ -202,12 +203,21 @@ static voidhid_sensor_set_power_work(struct
work_struct*work)_hid_sensor_power_state(attrb, true); }
-static int hid_sensor_data_rdy_trigger_set_state(structiio_trigger*trig,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-1- bool state) +static int buffer_postenable (struct iio_dev *indio_dev){
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1-return
hid_sensor_power_state(iio_trigger_get_drvdata(trig), state);drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+return
hid_sensor_power_state(iio_device_get_drvdata(indio_dev), 1); }drivers/iio/common/hid-sensors/hid-sensor-trigger.c +3
-0+static int buffer_predisable (struct iio_dev *indio_dev) +{ +return
hid_sensor_power_state(iio_device_get_drvdata(indio_dev), 0);drivers/iio/common/hid-sensors/hid-sensor-trigger.c +3
-0+} + +static const struct iio_buffer_setup_ops hid_sensor_buffer_opsQuoted 8 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c static void hid_sensor_set_power_work(struct work_struct *work) · line 219
Quoted 4 lines
= {
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +3
-0+ .postenable = buffer_postenable, + .predisable = buffer_predisable, +};I think these changes all help simplify things anyway so probably good to have. Maybe we could do them in a follow up rather than the
fix but I'll leave that up to youThis is required as the
hid_sensor_trigger_ops.set_trigger_state()is
not called onceiio_triggered_buffer_setup_ext()is removed.Quoted 16 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c void hid_sensor_remove_trigger(struct iio_dev *indio_dev, · line 221
Quoted 13 lines
+
voidhid_sensor_remove_trigger(struct iio_dev *indio_dev, struct hid_sensor_common *attrb)
{drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-0@@ -217,59 +227,30 @@ void hid_sensor_remove_trigger(struct
iio_dev*indio_dev,pm_runtime_set_suspended(&attrb->pdev->dev);
cancel_work_sync(&attrb->work);drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-2-iio_trigger_unregister (attrb->trigger); - iio_trigger_free(attrb->trigger);Keep the trigger parts here.
Quoted 9 lines
Quoted 8 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1-iio_triggered_buffer_cleanup (indio_dev);}
EXPORT_SYMBOL_NS(hid_sensor_remove_trigger, "IIO_HID");drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-2-static const struct iio_trigger_ops hid_sensor_trigger_ops = { - .set_trigger_state =
&hid_sensor_data_rdy_trigger_set_state,
-};and this.
This callback is not called without
iio_triggered_buffer_setup_ext().Quoted 29 lines
Quoted 29 lines
-
int hid_sensor_setup_trigger(structiio_dev*indio_dev, const char
*name,
structhid_sensor_common*attrb)
{
const structiio_dev_attr**fifo_attrs;
int ret;drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1-struct iio_trigger *trig;
if (hid_sensor_batch_mode_supported(attrb))fifo_attrs=hid_sensor_fifo_attributes; else
fifo_attrs= NULL;drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-2- ret = iio_triggered_buffer_setup_ext(indio_dev, -
&iio_pollfunc_store_time, NULL,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1-
IIO_BUFFER_DIRECTION_IN,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1- NULL,
fifo_attrs);drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+ ret = devm_iio_kfifo_buffer_setup_ext(&indio_dev->dev,
indio_dev,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+
&hid_sensor_buffer_ops,drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+ fifo_attrs);if (ret) {
Quoted 8 lines
Quoted 7 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-1- dev_err(&indio_dev->dev, "Triggered BufferSetup
Failed\n");drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-0+ dev_err(&indio_dev->dev, "Kfifo Buffer SetupFailed\n");
return ret;
}Down to here is good but keep the trigger setup.
I can keep with additional
iio_dev->modes|=INDIO_DIRECT|INDIO_HARDWARE_TRIGGERED;I will send a patch with the changes.
Thanks,
SrinivasQuoted 47 lines
Quoted 46 lines
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-3- - trig = iio_trigger_alloc(indio_dev->dev.parent, - "%s-dev%d", name,
iio_device_id(indio_dev));drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-2-if (trig ==NULL ) { - dev_err(&indio_dev->dev, "Trigger AllocateFailed\n");
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-10- ret = -ENOMEM ; - goto error_triggered_buffer_cleanup; - } - -iio_trigger_set_drvdata (trig, attrb); - trig->ops = &hid_sensor_trigger_ops; - ret =iio_trigger_register (trig); - -if (ret) { - dev_err(&indio_dev->dev, "Trigger RegisterFailed\n");
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-5- goto error_free_trig; - } - attrb->trigger = trig; - indio_dev->trig =iio_trigger_get (trig); -ret =
pm_runtime_set_active(&indio_dev->dev); if (ret)drivers/iio/common/hid-sensors/hid-sensor-trigger.c +1
-1- goto error_unreg_trigger; +return ret;
iio_device_set_drvdata(indio_dev, attrb);drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-0@@ -280,13 +261,6 @@ int hid_sensor_setup_trigger(struct
iio_dev*indio_dev, const char *name,pm_runtime_set_autosuspend_delay(&attrb->pdev->dev, 3000); return ret;drivers/iio/common/hid-sensors/hid-sensor-trigger.c +0
-7-error_unreg_trigger: -iio_trigger_unregister (trig); -error_free_trig: -iio_trigger_free (trig); -error_triggered_buffer_cleanup: -iio_triggered_buffer_cleanup (indio_dev); -return ret;}
EXPORT_SYMBOL_NS(hid_sensor_setup_trigger, "IIO_HID");