All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Rodrigo Alencar <455.rodrigo.alencar@gmail.com>
Cc: Rodrigo Alencar via B4 Relay
	<devnull+rodrigo.alencar.analog.com@kernel.org>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-hardening@vger.kernel.org,
	Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	David Lechner <dlechner@baylibre.com>,
	Andy Shevchenko <andy@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>
Subject: Re: [PATCH v9 13/17] iio: frequency: ad9910: add RAM mode support
Date: Mon, 27 Jul 2026 22:11:34 +0100	[thread overview]
Message-ID: <20260727221134.77d269b6@jic23-huawei> (raw)
In-Reply-To: <fv4zpxtmvobho3xna2pvmgdnpnwleil33bp2z6w3grzonxf6fq@yukanjhc5fsz>

On Mon, 27 Jul 2026 10:28:44 +0100
Rodrigo Alencar <455.rodrigo.alencar@gmail.com> wrote:

> On 25/07/26 23:46, Jonathan Cameron wrote:
> > On Wed, 22 Jul 2026 16:50:22 +0100
> > Rodrigo Alencar via B4 Relay <devnull+rodrigo.alencar.analog.com@kernel.org> wrote:
> >   
> > > From: Rodrigo Alencar <rodrigo.alencar@analog.com>
> > > 
> > > Add RAM control channel, which includes:
> > > - RAM data loading via firmware upload interface;
> > > - Per-profile configuration and DDS core parameter destination as firmware
> > >   metadata;
> > > - Profile switching relying on profile channels;
> > > - Sampling frequency control of the active profile;
> > > - ram-enable-aware read/write paths that redirect single tone
> > >   frequency/phase/amplitude access through reg_profile cache when RAM is
> > >   active;
> > > 
> > > When RAM is enabled, the DDS profile parameters (frequency, phase,
> > > amplitude) for the single tone mode are sourced from a shadow register
> > > cache (reg_profile[]) since the profile registers are repurposed for RAM
> > > control.
> > > 
> > > Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>  
> > As mentioned in reply to an earlier patch, I haven't looked in detail
> > at the firmware cancel path stuff sashiko is unhappy with.  Whilst
> > it looks like the sort of esoteric path where maybe it is fine to fail
> > good to take one more look.  
> 
> Yeah.. it is considering a cancel request right after the fw-update starts,
> with the fw-update failing for an invalid format before the check of the
> cancellation flag. With this, a second attempt on fw-update would fail again
> because the flag would not have been cleared.
> 
> Unusual, but I can have that handled.
> 
> > One other thing Sashiko commented on inline. I think that is either right
> > or a bit more detail is needed in the comment.
> > 
> > Thanks,
> > 
> > Jonathan
> > 
> >   
> > > diff --git a/drivers/iio/frequency/ad9910.c b/drivers/iio/frequency/ad9910.c
> > > index 6c794e1b4b1c..844cc0cc8f3e 100644
> > > --- a/drivers/iio/frequency/ad9910.c
> > > +++ b/drivers/iio/frequency/ad9910.c  
> > ...
> >   
> > > @@ -1119,7 +1220,7 @@ static int ad9910_write_raw(struct iio_dev *indio_dev,
> > >  	struct ad9910_state *st = iio_priv(indio_dev);
> > >  	u64 tmp64;
> > >  	u32 tmp32;
> > > -	int ret;
> > > +	int ret, i;
> > >  
> > >  	guard(mutex)(&st->lock);
> > >  
> > > @@ -1156,6 +1257,41 @@ static int ad9910_write_raw(struct iio_dev *indio_dev,
> > >  						   AD9910_CFR2_DRG_DEST_MSK |
> > >  						   AD9910_CFR2_DRG_ENABLE_MSK,
> > >  						   tmp32, true);
> > > +		case AD9910_CHANNEL_RAM:
> > > +			if (AD9910_RAM_ENABLED(st) == !!val)
> > > +				return 0;
> > > +
> > > +			/* swap profile configs */
> > > +			for (i = 0; i < AD9910_NUM_PROFILES; i++) {
> > > +				tmp64 = st->reg[AD9910_REG_PROFILE(i)].val64;
> > > +				ret = ad9910_reg64_write(st,
> > > +							 AD9910_REG_PROFILE(i),
> > > +							 st->reg_profile[i],
> > > +							 false);
> > > +				if (ret)
> > > +					break;
> > > +				st->reg_profile[i] = tmp64;
> > > +			}
> > > +
> > > +			if (ret) {
> > > +				/*
> > > +				 * After the write failure, profiles 0..i-1 were
> > > +				 * already swapped in SW, but Hw registers are
> > > +				 * still pending an IO update, so swap them back
> > > +				 * in SW to keep the state consistent.  
> > 
> > Sashiko's follow up question about whether a subsequent use of IO update might
> > end up with these stale values seems like a reasonable one. Perhaps a little
> > more detail on why that doesn't matter is needed here?  
> 
> Here, I focus on protecting the cached states (reverting the successful writes)
> rather than reverting stuff in HW after a SPI failure. The spi failure is delivered
> to userspace, so user should be aware that something is off.
> 
> What would happen if reverting HW states fails for nother SPI failure... I don't
> want to go into that...
> 
> If SPI starts to work again, other write attempts should be able to sync cached
> configs with HW.
Ok. That's fair. 

J
>  
> > > +				 */
> > > +				while (i--) {
> > > +					tmp64 = st->reg[AD9910_REG_PROFILE(i)].val64;
> > > +					st->reg[AD9910_REG_PROFILE(i)].val64 = st->reg_profile[i];
> > > +					st->reg_profile[i] = tmp64;
> > > +				}
> > > +				return ret;
> > > +			}
> > > +
> > > +			tmp32 = FIELD_PREP(AD9910_CFR1_RAM_ENABLE_MSK, !!val);
> > > +			return ad9910_reg32_update(st, AD9910_REG_CFR1,
> > > +						   AD9910_CFR1_RAM_ENABLE_MSK,
> > > +						   tmp32, true);
> > >  		default:
> > >  			return -EINVAL;
> > >  		}  
> >   
> 


  reply	other threads:[~2026-07-27 21:11 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 15:50 [PATCH v9 00/17] AD9910 Direct Digital Synthesizer Rodrigo Alencar via B4 Relay
2026-07-22 15:50 ` Rodrigo Alencar
2026-07-22 15:50 ` [PATCH v9 01/17] iio: ABI: add attributes for altcurrent channels Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar
2026-07-22 15:50 ` [PATCH v9 02/17] iio: ABI: raw, scale and offset for frequency/phase channels Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar
2026-07-22 15:50 ` [PATCH v9 03/17] iio: ABI: add parent entry for iio channels Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar
2026-07-22 15:50 ` [PATCH v9 04/17] iio: add IIO_FREQUENCY channel type Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar
2026-07-22 15:50 ` [PATCH v9 05/17] iio: core: support 64-bit register through debugfs Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar
2026-07-22 15:50 ` [PATCH v9 06/17] iio: core: create local __iio_chan_prefix_emit() for reuse Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar
2026-07-22 15:50 ` [PATCH v9 07/17] iio: test: add kunit tests for channel prefix naming generation Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar
2026-07-22 16:13   ` sashiko-bot
2026-07-25 22:15   ` Jonathan Cameron
2026-07-22 15:50 ` [PATCH v9 08/17] iio: core: add hierarchical channel relationships Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar
2026-07-25 22:24   ` Jonathan Cameron
2026-07-27  9:40     ` Rodrigo Alencar
2026-07-27 21:08       ` Jonathan Cameron
2026-07-22 15:50 ` [PATCH v9 09/17] dt-bindings: iio: frequency: add ad9910 Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar
2026-07-22 15:50 ` [PATCH v9 10/17] iio: frequency: ad9910: initial driver implementation Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar
2026-07-22 16:24   ` sashiko-bot
2026-07-25 22:33   ` Jonathan Cameron
2026-07-27  9:37     ` Rodrigo Alencar
2026-07-27 21:10       ` Jonathan Cameron
2026-07-22 15:50 ` [PATCH v9 11/17] iio: frequency: ad9910: add basic parallel port support Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar
2026-07-22 15:50 ` [PATCH v9 12/17] iio: frequency: ad9910: add digital ramp generator support Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar
2026-07-22 15:50 ` [PATCH v9 13/17] iio: frequency: ad9910: add RAM mode support Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar
2026-07-22 16:44   ` sashiko-bot
2026-07-25 22:46   ` Jonathan Cameron
2026-07-27  9:28     ` Rodrigo Alencar
2026-07-27 21:11       ` Jonathan Cameron [this message]
2026-07-22 15:50 ` [PATCH v9 14/17] iio: frequency: ad9910: add output shift keying support Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar
2026-07-22 15:50 ` [PATCH v9 15/17] iio: frequency: ad9910: show channel priority in debugfs Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar
2026-07-22 16:52   ` sashiko-bot
2026-07-25 22:56   ` Jonathan Cameron
2026-07-27  9:05     ` Rodrigo Alencar
2026-07-22 15:50 ` [PATCH v9 16/17] iio: ABI: add docs for ad9910 sysfs and debugfs entries Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar
2026-07-22 16:50   ` sashiko-bot
2026-07-22 15:50 ` [PATCH v9 17/17] docs: iio: add documentation for ad9910 driver Rodrigo Alencar via B4 Relay
2026-07-22 15:50   ` Rodrigo Alencar

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=20260727221134.77d269b6@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=455.rodrigo.alencar@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=devnull+rodrigo.alencar.analog.com@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=gustavoars@kernel.org \
    --cc=kees@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=skhan@linuxfoundation.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 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.