Linux Documentation
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: David Laight <david.laight.linux@gmail.com>
Cc: Rodrigo Alencar via B4 Relay
	<devnull+rodrigo.alencar.analog.com@kernel.org>,
	rodrigo.alencar@analog.com, 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 v10 11/17] iio: frequency: ad9910: add basic parallel port support
Date: Wed, 5 Aug 2026 00:07:46 +0100	[thread overview]
Message-ID: <20260805000746.4a799d04@jic23-huawei> (raw)
In-Reply-To: <20260802100400.588fa107@pumpkin>

On Sun, 2 Aug 2026 10:04:00 +0100
David Laight <david.laight.linux@gmail.com> wrote:

> On Sun, 2 Aug 2026 01:56:07 +0100
> Jonathan Cameron <jic23@kernel.org> wrote:
> 
> > On Wed, 29 Jul 2026 09:25:38 +0100
> > Rodrigo Alencar via B4 Relay <devnull+rodrigo.alencar.analog.com@kernel.org> wrote:
> >   
> > > From: Rodrigo Alencar <rodrigo.alencar@analog.com>
> > > 
> > > Add parallel port support with amplitude, phase and frequency channels.
> > > Those will be buffered capable channels, but only basic control of offset
> > > and scale are implemented at this point. There are separate amplitude
> > > and phase control for polar destination, which will provide different scan
> > > types. Enabling and disabling of parallel mode will be implemented with
> > > buffer setup ops or with update_scan_mode() once IIO backend integration
> > > is in place.
> > > 
> > > Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>    
> > Hmm. Curious... clang --version gives 22.1.8 on x86_64.
> > 
> > make LLVM=1 LOCALVERSION= -j12 W=1 C=1
> >   DESCEND objtool
> > Documentation/.renames.txt: warning: ignored by one of the .gitignore files
> >   CC [M]  drivers/iio/frequency/ad9910.o
> > In file included from drivers/iio/frequency/ad9910.c:10:
> > In file included from ./include/linux/clk.h:13:
> > In file included from ./include/linux/kernel.h:26:
> > In file included from ./include/linux/math.h:6:
> > ./arch/x86/include/asm/div64.h:113:8: error: invalid operand for instruction
> >   113 |                 asm ("addq %[add], %[lo]; adcq $0, %[hi]" :
> >       |                      ^
> > <inline asm>:1:7: note: instantiated into assembly here
> >     1 |         addq $2147483648, %rax; adcq $0, %rdx
> >       |              ^~~~~~~~~~~~
> > 1 error generated.
> > make[5]: *** [scripts/Makefile.build:289: drivers/iio/frequency/ad9910.o] Error 1
> > make[4]: *** [scripts/Makefile.build:549: drivers/iio/frequency] Error 2
> > make[3]: *** [scripts/Makefile.build:549: drivers/iio] Error 2
> > make[2]: *** [scripts/Makefile.build:549: drivers] Error 2
> > make[1]: *** [/home/jic23/src/kernel/iio/Makefile:2184: .] Error 2
> > make: *** [Makefile:248: __sub-make] Error 2
> > 
> >   
> > > ---
> > >  drivers/iio/frequency/ad9910.c | 154 +++++++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 154 insertions(+)
> > > 
> > > diff --git a/drivers/iio/frequency/ad9910.c b/drivers/iio/frequency/ad9910.c
> > > index b41b011af281..aaeff2e7640e 100644
> > > --- a/drivers/iio/frequency/ad9910.c
> > > +++ b/drivers/iio/frequency/ad9910.c    
> > 
> >   
> > >  static int ad9910_read_raw(struct iio_dev *indio_dev,
> > > @@ -691,6 +753,48 @@ static int ad9910_read_raw(struct iio_dev *indio_dev,
> > >  			*val = 0;
> > >  			*val2 = tmp64 >> 14;
> > >  			return IIO_VAL_INT_PLUS_NANO;
> > > +		case AD9910_CHAN_IDX_PARALLEL_PHASE:
> > > +			*val = 0;
> > > +			*val2 = AD9910_PI_NANORAD >> 15;
> > > +			return IIO_VAL_INT_PLUS_NANO;
> > > +		case AD9910_CHAN_IDX_PARALLEL_FREQ:
> > > +			tmp32 = FIELD_GET(AD9910_CFR2_FM_GAIN_MSK,
> > > +					  st->reg[AD9910_REG_CFR2].val32);
> > > +			tmp64 = (u64)st->data.sysclk_freq_hz << tmp32;
> > > +			tmp64 = ad9910_rational_scale(tmp64, NANO, BIT_ULL(32));    
> > 
> > Process of elimination points me to this line which is a slim wrapper.
> > 
> > static inline u64 ad9910_rational_scale(u64 input, u64 scale, u64 reference)
> > {
> > 	return mul_u64_add_u64_div_u64(input, scale, reference >> 1, reference);
> > }
> > 
> > David, any thoughts?  
> 
> Lots of instructions only support sign extending 32bit immediates.
> The asm constraint for the ADCQ needs to be "erm" not "irm".
> I bet that is true elsewhere as well.
> 
> See source/arch/x86/include/asm/div64.h line 114
> 
> I'm actually surprised you see it with clang - it usually prefers the "m"
> constraint.
> 
> I'll try to find a source tree that is clean enough to generate a patch.
> 
Thanks!  For anyone following along:

https://lore.kernel.org/all/20260803094702.3852-1-david.laight.linux@gmail.com/

Until David's fix is in a tree I'll hold off on merging this series.

Given timing, that may unfortunately delay it a cycle,

Jonathan

> 	David
> 
> 
> > 
> > For now I'm backing out the series.
> >   
> > > +			*val = div_s64_rem(tmp64, NANO, val2);
> > > +			return IIO_VAL_INT_PLUS_NANO;
> > > +		case AD9910_CHAN_IDX_PARALLEL_POLAR_AMP:
> > > +			tmp64 = (u64)st->data.output_current_uA *
> > > +				AD9910_NANO_MILLIAMP_PER_MICROAMP;
> > > +			*val = 0;
> > > +			*val2 = tmp64 >> 8;
> > > +			return IIO_VAL_INT_PLUS_NANO;
> > > +		case AD9910_CHAN_IDX_PARALLEL_POLAR_PHASE:
> > > +			*val = 0;
> > > +			*val2 = AD9910_PI_NANORAD >> 7;
> > > +			return IIO_VAL_INT_PLUS_NANO;
> > > +		default:
> > > +			return -EINVAL;
> > > +		}    
> 


  reply	other threads:[~2026-08-04 23:07 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29  8:25 [PATCH v10 00/17] AD9910 Direct Digital Synthesizer Rodrigo Alencar via B4 Relay
2026-07-29  8:25 ` [PATCH v10 01/17] iio: ABI: add attributes for altcurrent channels Rodrigo Alencar via B4 Relay
2026-07-29  8:25 ` [PATCH v10 02/17] iio: ABI: raw, scale and offset for frequency/phase channels Rodrigo Alencar via B4 Relay
2026-07-29  8:25 ` [PATCH v10 03/17] iio: ABI: add parent entry for iio channels Rodrigo Alencar via B4 Relay
2026-07-29  8:25 ` [PATCH v10 04/17] iio: add IIO_FREQUENCY channel type Rodrigo Alencar via B4 Relay
2026-07-29  8:25 ` [PATCH v10 05/17] iio: core: support 64-bit register through debugfs Rodrigo Alencar via B4 Relay
2026-07-29  8:25 ` [PATCH v10 06/17] iio: core: create local __iio_chan_prefix_emit() for reuse Rodrigo Alencar via B4 Relay
2026-07-29  8:25 ` [PATCH v10 07/17] iio: test: add kunit tests for channel prefix naming generation Rodrigo Alencar via B4 Relay
2026-08-01 23:55   ` Jonathan Cameron
2026-07-29  8:25 ` [PATCH v10 08/17] iio: core: add hierarchical channel relationships Rodrigo Alencar via B4 Relay
2026-07-29  8:25 ` [PATCH v10 09/17] dt-bindings: iio: frequency: add ad9910 Rodrigo Alencar via B4 Relay
2026-07-29  8:25 ` [PATCH v10 10/17] iio: frequency: ad9910: initial driver implementation Rodrigo Alencar via B4 Relay
2026-08-04 15:12   ` Nuno Sá
2026-07-29  8:25 ` [PATCH v10 11/17] iio: frequency: ad9910: add basic parallel port support Rodrigo Alencar via B4 Relay
2026-08-02  0:56   ` Jonathan Cameron
2026-08-02  9:04     ` David Laight
2026-08-04 23:07       ` Jonathan Cameron [this message]
2026-07-29  8:25 ` [PATCH v10 12/17] iio: frequency: ad9910: add digital ramp generator support Rodrigo Alencar via B4 Relay
2026-07-29  8:25 ` [PATCH v10 13/17] iio: frequency: ad9910: add RAM mode support Rodrigo Alencar via B4 Relay
2026-07-29  8:25 ` [PATCH v10 14/17] iio: frequency: ad9910: add output shift keying support Rodrigo Alencar via B4 Relay
2026-07-29  8:25 ` [PATCH v10 15/17] iio: frequency: ad9910: show channel priority in debugfs Rodrigo Alencar via B4 Relay
2026-07-29  8:25 ` [PATCH v10 16/17] iio: ABI: add docs for ad9910 sysfs and debugfs entries Rodrigo Alencar via B4 Relay
2026-07-29  8:25 ` [PATCH v10 17/17] docs: iio: add documentation for ad9910 driver Rodrigo Alencar via B4 Relay
2026-08-02  0:09 ` [PATCH v10 00/17] AD9910 Direct Digital Synthesizer Jonathan Cameron
2026-08-02  0:58   ` Jonathan Cameron
2026-08-04 10:56     ` 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=20260805000746.4a799d04@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=david.laight.linux@gmail.com \
    --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=rodrigo.alencar@analog.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox