From: Jonathan Cameron <jic23@kernel.org>
To: Ramona Gradinariu <ramona.bolboaca13@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org, conor+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org, robh@kernel.org,
nuno.sa@analog.com
Subject: Re: [PATCH v2 8/8] drivers: iio: imu: Add support for adis1657x family
Date: Sun, 19 May 2024 18:43:30 +0100 [thread overview]
Message-ID: <20240519184330.6d575cb8@jic23-huawei> (raw)
In-Reply-To: <ec8174c5-723d-43ad-beaf-0930d1b2c19e@gmail.com>
On Fri, 17 May 2024 11:00:36 +0300
Ramona Gradinariu <ramona.bolboaca13@gmail.com> wrote:
> >> + * device will send the data popped with the (n-1)th consecutive burst request.
> >> + * In order to read the data which was popped previously, without popping the FIFO,
> >> + * the 0x00 0x00 burst request has to be sent.
> >> + * If after a 0x68 0x00 FIFO pop burst request, there is any other device access
> >> + * different from a 0x68 0x00 or a 0x00 0x00 burst request, the FIFO data popped
> >> + * previously will be lost.
> >> + */
> >> +static irqreturn_t adis16475_trigger_handler_with_fifo(int irq, void *p)
> >> {
> >> struct iio_poll_func *pf = p;
> >> struct iio_dev *indio_dev = pf->indio_dev;
> >> + struct adis16475 *st = iio_priv(indio_dev);
> >> + struct adis *adis = &st->adis;
> >> + int ret;
> >> + u16 fifo_cnt, i;
> >>
> >> - adis16475_push_single_sample(pf);
> >> + adis_dev_lock(&st->adis);
> >> +
> >> + ret = __adis_read_reg_16(adis, ADIS16575_REG_FIFO_CNT, &fifo_cnt);
> >> + if (ret)
> >> + goto unlock;
> >> +
> >> + /*
> >> + * If no sample is available, nothing can be read. This can happen if
> >> + * a the used trigger has a higher frequency than the selected sample rate.
> >> + */
> >> + if (!fifo_cnt)
> >> + goto unlock;
> >> +
> >> + /*
> >> + * First burst request - FIFO pop: popped data will be returned in the
> >> + * next burst request.
> >> + */
> >> + ret = adis16575_custom_burst_read(pf, adis->data->burst_reg_cmd);
> >> + if (ret)
> >> + goto unlock;
> >> +
> >> + for (i = 0; i < fifo_cnt - 1; i++) {
> >> + ret = adis16475_push_single_sample(pf);
> >> + if (ret)
> >> + goto unlock;
> >> + }
> >> +
> > My paranoid instincts for potential race conditions kick in.
> > Is this one of those annoying devices where the fifo interrupt will only occur
> > again if we successfully read enough data to get below the threshold?
> > Snag with no public datasheet is I can't just look it up!
> > If it's a level interrupt this won't be a problem.
> >
> > If so the race is the following.
> > 1. Interrupt happens, we read the number of entries in fifo.
> > 2. We read out the fifo, but for some reason our read is slow... (contention on
> > bus, CPU overheating, who knows). The data fills up at roughly the
> > same rate as we are reading.
> > 3. We try to carry on but in reality the fifo contents never dropped below
> > the watermark, so not more interrupts ever occur.
> >
> > Solution normally is to put this read sequence in a while (fifo_cnt)
> > and reread that after you've done the burst read. If there is more data
> > go around again. That way we drive for definitely having gotten to zero
> > at some stage - and hence whatever the threshold is set to a new interrupt
> > will occur.
>
> Hello Jonathan,
>
> Indeed the watermark interrupt is a level interrupt. However adis lib does not
> allow for level interrupts, so I had to create a new patch in v3 to handle it.
> Until now I tested the watermark interrupt as and edge interrupt and I did not
> see any issues, but indeed if the FIFO is not read fast enough the watermark pin
> will stay high (or low depending on the configured polarity), so the correct
> implementation is to use level interrupts for FIFO watermark interrupts.
That is the easy way certainly!
Sounds good to me.
Jonathan
>
> Ramona G.
>
>
prev parent reply other threads:[~2024-05-19 17:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-08 13:13 [PATCH v2 0/8] adis16501 and adis1657x support Ramona Gradinariu
2024-05-08 13:13 ` [PATCH v2 1/8] dt-bindings: iio: imu: Add ADIS16501 compatibles Ramona Gradinariu
2024-05-08 13:13 ` [PATCH v2 2/8] drivers: iio: imu: Add support for ADIS16501 Ramona Gradinariu
2024-05-08 13:13 ` [PATCH v2 3/8] iio: imu: adis16475: Re-define ADIS16475_DATA Ramona Gradinariu
2024-05-08 13:13 ` [PATCH v2 4/8] iio: imu: adis_buffer: Add buffer setup API with buffer attributes Ramona Gradinariu
2024-05-10 22:21 ` kernel test robot
2024-05-11 13:22 ` Jonathan Cameron
2024-05-08 13:13 ` [PATCH v2 5/8] iio: imu: adis16475: Create push single sample API Ramona Gradinariu
2024-05-08 13:13 ` [PATCH v2 6/8] drivers: iio: imu: adis16475: generic computation for sample rate Ramona Gradinariu
2024-05-08 13:13 ` [PATCH v2 7/8] dt-bindings: iio: imu: Add ADIS1657X family devices compatibles Ramona Gradinariu
2024-05-08 17:18 ` Conor Dooley
2024-05-08 13:13 ` [PATCH v2 8/8] drivers: iio: imu: Add support for adis1657x family Ramona Gradinariu
2024-05-10 23:24 ` kernel test robot
2024-05-11 13:24 ` Jonathan Cameron
2024-05-11 13:54 ` Jonathan Cameron
2024-05-17 8:00 ` Ramona Gradinariu
2024-05-19 17:43 ` Jonathan Cameron [this message]
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=20240519184330.6d575cb8@jic23-huawei \
--to=jic23@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=ramona.bolboaca13@gmail.com \
--cc=robh@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).