mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Rupesh Majhi <zoone.rupert@gmail.com>
Cc: "Andy Shevchenko" <andy@kernel.org>,
	"Bill Wendling" <morbo@google.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Eddie James" <eajames@linux.ibm.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Justin Stitt" <justinstitt@google.com>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev
Subject: Re: [PATCH v10 2/4] iio: pressure: dps310: derive the drain interval from the watermark
Date: Wed, 30 Sep 2026 17:01:47 +0300	[thread overview]
Message-ID: <ar0WS5MGL3mqBQHY@ashevche-desk.local> (raw)
In-Reply-To: <20260930100158.957977-3-zoone.rupert@gmail.com>

On Wed, Sep 30, 2026 at 01:01:56PM +0300, Rupesh Majhi wrote:
> The drain interval only tracked how fast the FIFO fills, so a small
> watermark still waited half a FIFO for its samples. Take the watermark
> as the number of scans to wait for, but never drain slower than half a
> fill.

...

> -	unsigned int fill_ms;
> +	unsigned int fill_ms, want_ms;

What about

	unsigned int drain_interval_ms, fill_ms, want_ms;

> +	int scan_rate;

>  	fill_ms = MSEC_PER_SEC * DPS310_FIFO_DEPTH / (prs_rate + tmp_rate);
>  
> -	return clamp(fill_ms / 2, DPS310_DRAIN_MIN_MS, DPS310_DRAIN_MAX_MS);
> +	/*
> +	 * There is no hardware watermark, so take it as the number of scans
> +	 * the user will wait for and drain at that rate. Scans come from
> +	 * whichever measurement drives them.
> +	 */
> +	if (test_bit(DPS310_SCAN_PRESSURE, data->iio->active_scan_mask))
> +		scan_rate = prs_rate;
> +	else
> +		scan_rate = tmp_rate;
> +
> +	want_ms = data->watermark * MSEC_PER_SEC / scan_rate;

> +	return clamp(min(want_ms, fill_ms / 2), DPS310_DRAIN_MIN_MS,
> +		     DPS310_DRAIN_MAX_MS);

	drain_interval_ms = min(want_ms, fill_ms / 2);

	return clamp(drain_interval_ms, DPS310_DRAIN_MIN_MS, DPS310_DRAIN_MAX_MS);

?

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-09-30 14:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 10:01 [PATCH v10 0/4] iio: pressure: dps310: hardware FIFO support Rupesh Majhi
2026-09-30 10:01 ` [PATCH v10 1/4] iio: pressure: dps310: read buffered samples from the hardware FIFO Rupesh Majhi
2026-09-30 10:35   ` Andy Shevchenko
2026-09-30 10:01 ` [PATCH v10 2/4] iio: pressure: dps310: derive the drain interval from the watermark Rupesh Majhi
2026-09-30 14:01   ` Andy Shevchenko [this message]
2026-09-30 10:01 ` [PATCH v10 3/4] iio: pressure: dps310: implement .hwfifo_flush_to_buffer() Rupesh Majhi
2026-09-30 10:01 ` [PATCH v10 4/4] iio: pressure: dps310: assert the lock at runtime too Rupesh Majhi
2026-09-30 12:08   ` Andy Shevchenko

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=ar0WS5MGL3mqBQHY@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=eajames@linux.ibm.com \
    --cc=jic23@kernel.org \
    --cc=justinstitt@google.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nuno.sa@analog.com \
    --cc=zoone.rupert@gmail.com \
    /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

all inboxes | Powered by JetHome®