* iio_trigger_poll_chained stop and trig->use_count always equals to 1
@ 2013-07-16 9:26 Denis CIOCCA
2013-07-16 10:28 ` Lars-Peter Clausen
0 siblings, 1 reply; 4+ messages in thread
From: Denis CIOCCA @ 2013-07-16 9:26 UTC (permalink / raw)
To: linux-iio; +Cc: jonathan cameron
Hi all,
I need your help to understanding my strange issue...
The scenario is that:
- I have one I2C device (microcontroller) that expose some sensors.
- I wrote one driver that create one IIO device for each sensor.
- There is only one trigger associated to all IIO devices, and one buffer f=
or=20
each device.
When interrupt appear (DRDY of one or more sensors), the driver reads a mas=
k=20
from micro to understand how many sensors have new data. After that, the=20
driver reads all new data from micro and save all data to one buffer. This =
is=20
done in a threaded irq function.
When iio_trigger_poll_chained is called, all data are saved to one common=20
buffer, each iio_triggered_buffer_setup functions is called and can split a=
nd=20
push their data to iio_buffer.
The issue is that: after some samples (about 50:100) the=20
iio_trigger_poll_chained doesn't call the iio_triggered_buffer_setup functi=
ons=20
and trig->use_count is always equals to 1.
To well understanding:
static irqreturn_t st_drdy_poll(int irq, void *private)
{
// stuff statements
// i2c read mask
// i2c read sensors data
iio_trigger_poll_chained(trig, 0);
return IRQ_HANDLED;
}
static irqreturn_t st_trigger_handler(int irq, void *p)
{
// stuff statements
// only check operations
iio_push_to_buffers(sensor_iio_dev, sdata->buffer_data);
iio_trigger_notify_done(sensor_iio_dev->trig);
return IRQ_HANDLED;
}
trigger_allocate()
{
err =3D request_threaded_irq(client->irq,
NULL,
st_drdy_poll,
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
name,
trig);
}
buffer_allocate()
{
return iio_triggered_buffer_setup(sensor_iio_dev,
&iio_pollfunc_store_time,
&st_trigger_handler,
&st_buffer_setup_ops);
}
If you have any comments...Thanks for your time!
Denis
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: iio_trigger_poll_chained stop and trig->use_count always equals to 1
2013-07-16 9:26 iio_trigger_poll_chained stop and trig->use_count always equals to 1 Denis CIOCCA
@ 2013-07-16 10:28 ` Lars-Peter Clausen
2013-07-16 13:26 ` Denis CIOCCA
0 siblings, 1 reply; 4+ messages in thread
From: Lars-Peter Clausen @ 2013-07-16 10:28 UTC (permalink / raw)
To: Denis CIOCCA; +Cc: linux-iio, jonathan cameron
On 07/16/2013 11:26 AM, Denis CIOCCA wrote:
> Hi all,
>
> I need your help to understanding my strange issue...
> The scenario is that:
>
> - I have one I2C device (microcontroller) that expose some sensors.
> - I wrote one driver that create one IIO device for each sensor.
> - There is only one trigger associated to all IIO devices, and one buffer for
> each device.
>
> When interrupt appear (DRDY of one or more sensors), the driver reads a mask
> from micro to understand how many sensors have new data. After that, the
> driver reads all new data from micro and save all data to one buffer. This is
> done in a threaded irq function.
>
> When iio_trigger_poll_chained is called, all data are saved to one common
> buffer, each iio_triggered_buffer_setup functions is called and can split and
> push their data to iio_buffer.
>
> The issue is that: after some samples (about 50:100) the
> iio_trigger_poll_chained doesn't call the iio_triggered_buffer_setup functions
> and trig->use_count is always equals to 1.
>
Yea, there is a race condition. Try this patch:
http://www.spinics.net/lists/linux-iio/msg08710.html
- Lars
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: iio_trigger_poll_chained stop and trig->use_count always equals to 1
2013-07-16 10:28 ` Lars-Peter Clausen
@ 2013-07-16 13:26 ` Denis CIOCCA
2013-07-16 14:26 ` Lars-Peter Clausen
0 siblings, 1 reply; 4+ messages in thread
From: Denis CIOCCA @ 2013-07-16 13:26 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio, jonathan cameron
Hi Lars,
thank you very much, now it works fine!
Only one thing:
- In your patch I think there is a mistake on iio_trigger_poll_chained
function: generic_handle_irq should be replaced by handle_nested_irq.
Thanks,
Denis
On Tuesday, July 16, 2013 12:28:06 PM Lars-Peter Clausen wrote:
> On 07/16/2013 11:26 AM, Denis CIOCCA wrote:
> > Hi all,
> >
> > I need your help to understanding my strange issue...
> > The scenario is that:
> >
> > - I have one I2C device (microcontroller) that expose some sensors.
> > - I wrote one driver that create one IIO device for each sensor.
> > - There is only one trigger associated to all IIO devices, and one buffer
> > for each device.
> >
> > When interrupt appear (DRDY of one or more sensors), the driver reads a
> > mask from micro to understand how many sensors have new data. After that,
> > the driver reads all new data from micro and save all data to one buffer.
> > This is done in a threaded irq function.
> >
> > When iio_trigger_poll_chained is called, all data are saved to one common
> > buffer, each iio_triggered_buffer_setup functions is called and can split
> > and push their data to iio_buffer.
> >
> > The issue is that: after some samples (about 50:100) the
> > iio_trigger_poll_chained doesn't call the iio_triggered_buffer_setup
> > functions and trig->use_count is always equals to 1.
>
> Yea, there is a race condition. Try this patch:
> http://www.spinics.net/lists/linux-iio/msg08710.html
>
> - Lars
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: iio_trigger_poll_chained stop and trig->use_count always equals to 1
2013-07-16 13:26 ` Denis CIOCCA
@ 2013-07-16 14:26 ` Lars-Peter Clausen
0 siblings, 0 replies; 4+ messages in thread
From: Lars-Peter Clausen @ 2013-07-16 14:26 UTC (permalink / raw)
To: Denis CIOCCA; +Cc: linux-iio, jonathan cameron
On 07/16/2013 03:26 PM, Denis CIOCCA wrote:
> Hi Lars,
>
> thank you very much, now it works fine!
>
> Only one thing:
> - In your patch I think there is a mistake on iio_trigger_poll_chained
> function: generic_handle_irq should be replaced by handle_nested_irq.
>
Yep, thanks. Will fix that in v2. Can you give v2 a try?
- Lars
>
>
> On Tuesday, July 16, 2013 12:28:06 PM Lars-Peter Clausen wrote:
>> On 07/16/2013 11:26 AM, Denis CIOCCA wrote:
>>> Hi all,
>>>
>>> I need your help to understanding my strange issue...
>>> The scenario is that:
>>>
>>> - I have one I2C device (microcontroller) that expose some sensors.
>>> - I wrote one driver that create one IIO device for each sensor.
>>> - There is only one trigger associated to all IIO devices, and one buffer
>>> for each device.
>>>
>>> When interrupt appear (DRDY of one or more sensors), the driver reads a
>>> mask from micro to understand how many sensors have new data. After that,
>>> the driver reads all new data from micro and save all data to one buffer.
>>> This is done in a threaded irq function.
>>>
>>> When iio_trigger_poll_chained is called, all data are saved to one common
>>> buffer, each iio_triggered_buffer_setup functions is called and can split
>>> and push their data to iio_buffer.
>>>
>>> The issue is that: after some samples (about 50:100) the
>>> iio_trigger_poll_chained doesn't call the iio_triggered_buffer_setup
>>> functions and trig->use_count is always equals to 1.
>>
>> Yea, there is a race condition. Try this patch:
>> http://www.spinics.net/lists/linux-iio/msg08710.html
>>
>> - Lars
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-07-16 14:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-16 9:26 iio_trigger_poll_chained stop and trig->use_count always equals to 1 Denis CIOCCA
2013-07-16 10:28 ` Lars-Peter Clausen
2013-07-16 13:26 ` Denis CIOCCA
2013-07-16 14:26 ` Lars-Peter Clausen
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.