From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795903219; b=me0lO6wDaOTXHfi32j0nxHm2/zcw1YkVmDOiDChKaoEzDGY8G9BQ1eaZWmytuSfL9rXZ z9KA7rK4VXHbSd+45J+1a7wXK6CoRN90rKD96xI+pA84YvPRRsKYl+S9e2QjfWlyWR1L8 FERHXQ+aQMoHF7k+XQjS3nESRwdYYvnSbvcK5y1plM9PHtS6bZqycyGyJAklnzNsIrCp+ hZlSaXqBHGn2QdQ0KsgieM3T2Ju73nTvbYogoNnRFoOuv+uQobivHzA4FIZvhy79BgsrF W37e125twCaqrOwbGKYg36izQ9JYoFWWn1m2xNL4Gx9onwH4J1tr4U9EGbpv+JKFS7g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795903219; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: In-Reply-To:References:X-Mailer:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=61fNCQkXc1ZzCjgd1W718WD8MQWP4E/rMXfAFIaFiKQ=; b=nNaCFhD3J2F7C3+CUpqxQU1Hks1DCd88DyUk40YUFCXMwfG4on8TyufDG8WLAcbnfXVL h2aBdtveKXeS3W3GoqHO4ItCi3UGN4WI36imua5ob2D0oRUP4DfNRLog0kHN2xKoDrtsO /kNIiDjo1KyFf9T0dZRnJHnocAUbW/2CooigWNklaRQc3sIp/mBqtzs5cfnVWW/mNSw4H +9DsqYAB58dX7vt5gKh1wXK4E/onag9bNJ6sgkbjcFy5VZ+5xj2q0/yjiURBXL98KH5Fm avJiSph4OdS1sVzXZ+gDlRDeOcIlxX1qNLfRP3iVubhLezADsUJ5xLgrZVCgRLp90hQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="JGMNDh/M"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 325FD606A323; Sat, 28 Nov 2026 22:00:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JGMNDh/M Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D84E1F000C1; Sat, 28 Nov 2026 22:00:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795903218; bh=61fNCQkXc1ZzCjgd1W718WD8MQWP4E/rMXfAFIaFiKQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=JGMNDh/MEkA0qhC1orhe6uduVZJ5TChxHTqkx7bQkonoRxe/6PoQLFcH9CYo46AJd o2tUVBQYSY3+PoxlT1aXgBXApcfH09g7X/5MChm3PX03WqLOkR7gokp7Ers9stZEH2 tfdcK6kcSwMJg1JsGBiQ7zmLpDG+8QabdMsWslWTEr9SkBQyvkJomCBJ2q4NV6wKX8 B+cJe9wiV8Gc9rkYx+Bt5D//aUfsMnxlUMKVKToxDjXUZgXZj87+CeZcdK2NoILhL9 dOSqiJjkn3r35d279J29+kdUNgQ05FmzbbyNF6Hm/WY9YqivLe86hDWBHmw0DZzYG6 4TifW3IUDa0Aw== Date: Sat, 28 Nov 2026 22:00:10 +0000 From: Jonathan Cameron To: Radu Sabau via B4 Relay Cc: radu.sabau@analog.com, Nuno =?UTF-8?B?U8Oh?= , Michael Hennerich , David Lechner , Andy Shevchenko , Ramona Gradinariu , linux-iio@vger.kernel.org, linux@analog.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 6/7] iio: imu: adis16607: Add FIFO-based buffered capture Message-ID: <20261128220010.5d1235fe@jic23-hlaptop> In-Reply-To: <20261123-adis-fifo-v1-6-f6ad9e493e19@analog.com> References: <20261123-adis-fifo-v1-0-f6ad9e493e19@analog.com> <20261123-adis-fifo-v1-6-f6ad9e493e19@analog.com> X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-pc-linux-gnu) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 23 Nov 2026 15:25:30 +0200 Radu Sabau via B4 Relay wrote: > From: Radu Sabau > > Add buffered capture via the device's hardware FIFO, the only capture > mode this driver supports. Popping the FIFO uses a dedicated command and > payload format (FIFO_DATA_CMD, 52 bytes, no checksum). The channels are > described as big endian words with the value in their upper bits, as the > device sends them, so the samples are copied to the buffer unchanged. > > The samples go to a kfifo buffer set up with the adislib kfifo helper, > filled from a threaded interrupt: the device raises one interrupt per > watermark, not per sample, so there is nothing to trigger on. The > watermark-met condition is signaled via DEV_NOK on the device's one > interrupt pin, which stays asserted until DIAG_STAT is read and cleared. > The interrupt is therefore level-triggered and oneshot, and it is enabled > only while the buffer is. DEV_NOK fires on any DIAG_STAT flag, not just > FIFO_THRESH_MET, so the handler checks that specific bit before popping > anything and leaves interrupts it did not raise to the core. DR_GPIO_MASK > stays enabled unconditionally: DR pulses drive the FIFO controller's > internal sample enqueue, independent of pin routing. > > Watermark is configurable via the standard hwfifo_set_watermark callback > and the usual hwfifo_* sysfs attributes. Changing the sampling frequency > while the buffer is enabled returns -EBUSY, as the decimation can't change > during capture. Unless I read it wrong, this changes the driver from doing some useful stuff without interrupts being wired, to nothing at all. That is not a change we should make in an upstream driver (even if maybe this lands in the same cycle). Jonathan > > Signed-off-by: Radu Sabau > diff --git a/drivers/iio/imu/adis16607.c b/drivers/iio/imu/adis16607.c > index 749ed7445f73..60433c97a855 100644 > --- a/drivers/iio/imu/adis16607.c > +++ b/drivers/iio/imu/adis16607.c > +static int adis16607_buffer_postenable(struct iio_dev *indio_dev) > +{ > + struct adis16607 *st = iio_priv(indio_dev); > + struct adis *adis = &st->adis; > + u16 threshold; > + int ret; > + > + adis_dev_auto_lock(adis); > + > + /* Flush FIFO to start clean */ > + ret = __adis_write_reg_16(adis, ADIS16607_REG_USER_FIFO_CFG, > + ADIS16607_FIFO_FLUSH_MASK); > + if (ret) > + return ret; > + > + /* Enable FIFO with watermark threshold (in word count) */ > + threshold = st->fifo_watermark * ADIS16607_FIFO_WORDS_PER_SAMPLE; > + ret = __adis_write_reg_16(adis, ADIS16607_REG_USER_FIFO_CFG, > + threshold & ADIS16607_FIFO_THR_MASK); > + if (ret) > + return ret; > + > + /* > + * The device cannot mask DEV_NOK for us: unrouting it leaves the pin > + * on its weak pull-up, which reads as asserted. Mask it on the host. > + */ Ah. This is the comment we need for the earlier patches. Is that generally true for all the kfifo supported devices, or should we be using some sort of flag to let the adis helper know if this is required? > + enable_irq(adis->spi->irq); > + > + return 0; > +} > > /* > @@ -814,6 +1158,7 @@ static const struct adis_data adis16607_data = { > .diag_stat_size = 2, > .prod_id_reg = ADIS16607_REG_DEV_ID, > .prod_id = 0x6000, > + .has_fifo = true, > .unmasked_drdy = true, > .init = adis16607_init, > .self_test = adis16607_self_test, > @@ -972,7 +1317,19 @@ static int adis16607_probe(struct spi_device *spi) > indio_dev->info = &adis16607_info; > indio_dev->modes = INDIO_DIRECT_MODE; > > + if (!spi->irq) > + return dev_err_probe(dev, -EINVAL, "interrupt is required\n"); The driver is upstream without that requirement. We should not add it now as I assume it works to some degree without it? Just modify the reported channels etc to have it support current functionality if no irq. That probably means multiple iio_info, possibly channels etc. > + > + /* The core's default; the device watermark follows buffer/watermark */ > + st->fifo_watermark = 1; > + > st->adis.ops = &adis16607_ops; > + /* > + * DEV_NOK is the OR of the DIAG_STAT flags and stays high until > + * DIAG_STAT is read. Use a level interrupt so a flag raised while it > + * is already high is not lost. > + */ > + st->adis.irq_flag = IRQF_TRIGGER_HIGH; For a modern driver explain why we don't get this from the firmware. Thanks, Jonathan >