Message ID | 20201130125915.1315667-2-linus.walleij@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] iio: gyro: mpu3050: Use devm_ to set up buffer | expand |
On Mon, 30 Nov 2020 13:59:15 +0100 Linus Walleij <linus.walleij@linaro.org> wrote: > If something other than the MPU3050 itself is using this > trigger, the timestamp needs to be stored in the poll > function. > > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> I'm a bit confused here. pollfuncs are per device using the trigger, so writing to the timestamp of the one from this device, won't have an affect on any others. If it did, we'd still have an issue as there are no ordering guarantees amongst different consumers of a trigger. Jonathan > --- > drivers/iio/gyro/mpu3050-core.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c > index 0d0850945d3a..b892487394ea 100644 > --- a/drivers/iio/gyro/mpu3050-core.c > +++ b/drivers/iio/gyro/mpu3050-core.c > @@ -457,7 +457,7 @@ static int mpu3050_write_raw(struct iio_dev *indio_dev, > > static irqreturn_t mpu3050_trigger_handler(int irq, void *p) > { > - const struct iio_poll_func *pf = p; > + struct iio_poll_func *pf = p; > struct iio_dev *indio_dev = pf->indio_dev; > struct mpu3050 *mpu3050 = iio_priv(indio_dev); > int ret; > @@ -482,6 +482,9 @@ static irqreturn_t mpu3050_trigger_handler(int irq, void *p) > else > timestamp = iio_get_time_ns(indio_dev); > > + /* Someone else may be using us as trigger */ > + pf->timestamp = timestamp; > + > mutex_lock(&mpu3050->lock); > > /* Using the hardware IRQ trigger? Check the buffer then. */
On Mon, Nov 30, 2020 at 10:07 PM Jonathan Cameron <jic23@kernel.org> wrote: > I'm a bit confused here. Rightly so! > pollfuncs are per device using the trigger, so writing to the > timestamp of the one from this device, won't have an affect on > any others. > > If it did, we'd still have an issue as there are no ordering > guarantees amongst different consumers of a trigger. Yeah I got it all wrong. I'm trying to find the real bug (likely in the trigger consuming driver) and fix that instead. What do you use when stress testing IIO stuff? I have been using the tools from the kernel so mainly lsiio, iio_generic_buffer and iio_event_monitor so far. iio-sensor-proxy seems really nice, but I just haven't figured out what kind of programs people are in turn using that with.. Yours, Linus Walleij
diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c index 0d0850945d3a..b892487394ea 100644 --- a/drivers/iio/gyro/mpu3050-core.c +++ b/drivers/iio/gyro/mpu3050-core.c @@ -457,7 +457,7 @@ static int mpu3050_write_raw(struct iio_dev *indio_dev, static irqreturn_t mpu3050_trigger_handler(int irq, void *p) { - const struct iio_poll_func *pf = p; + struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct mpu3050 *mpu3050 = iio_priv(indio_dev); int ret; @@ -482,6 +482,9 @@ static irqreturn_t mpu3050_trigger_handler(int irq, void *p) else timestamp = iio_get_time_ns(indio_dev); + /* Someone else may be using us as trigger */ + pf->timestamp = timestamp; + mutex_lock(&mpu3050->lock); /* Using the hardware IRQ trigger? Check the buffer then. */
If something other than the MPU3050 itself is using this trigger, the timestamp needs to be stored in the poll function. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- drivers/iio/gyro/mpu3050-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)