[{"id":3682322,"web_url":"http://patchwork.ozlabs.org/comment/3682322/","msgid":"<20260425185413.0e81f521@jic23-huawei>","list_archive_url":null,"date":"2026-04-25T17:54:13","subject":"Re: [PATCH v8 4/6] iio: adc: ad4691: add SPI offload support","submitter":{"id":10151,"url":"http://patchwork.ozlabs.org/api/people/10151/","name":"Jonathan Cameron","email":"jic23@kernel.org"},"content":"On Thu, 16 Apr 2026 12:18:49 +0300\nRadu Sabau via B4 Relay <devnull+radu.sabau.analog.com@kernel.org> wrote:\n\n> From: Radu Sabau <radu.sabau@analog.com>\n> \n> Add SPI offload support to enable DMA-based, CPU-independent data\n> acquisition using the SPI Engine offload framework.\n> \n> When an SPI offload is available (devm_spi_offload_get() succeeds),\n> the driver registers a DMA engine IIO buffer and uses dedicated buffer\n> setup operations. If no offload is available the existing software\n> triggered buffer path is used unchanged.\n> \n> Both CNV Burst Mode and Manual Mode support offload, but use different\n> trigger mechanisms:\n> \n> CNV Burst Mode: the SPI Engine is triggered by the ADC's DATA_READY\n> signal on the GP pin specified by the trigger-source consumer reference\n> in the device tree (one cell = GP pin number 0-3). For this mode the\n> driver acts as both an SPI offload consumer (DMA RX stream, message\n> optimization) and a trigger source provider: it registers the\n> GP/DATA_READY output via devm_spi_offload_trigger_register() so the\n> offload framework can match the '#trigger-source-cells' phandle and\n> automatically fire the SPI Engine DMA transfer at end-of-conversion.\n> \n> Manual Mode: the SPI Engine is triggered by a periodic trigger at\n> the configured sampling frequency. The pre-built SPI message uses\n> the pipelined CNV-on-CS protocol: N+1 16-bit transfers are issued\n> for N active channels (the first result is discarded as garbage from\n> the pipeline flush) and the remaining N results are captured by DMA.\n> \n> All offload transfers use 16-bit frames (bits_per_word=16, len=2).\n> The channel scan_type (storagebits=16, shift=0, IIO_BE) is shared\n> between the software triggered-buffer and offload paths; no separate\n> scan_type or channel array is needed for the offload case. The\n> ad4691_manual_channels[] array introduced in the triggered-buffer\n> commit is reused here: it hides the IIO_CHAN_INFO_OVERSAMPLING_RATIO\n> attribute, which is not applicable in Manual Mode.\n> \n> Kconfig gains a dependency on IIO_BUFFER_DMAENGINE.\n> \n> Signed-off-by: Radu Sabau <radu.sabau@analog.com>\n\nAnother case where you would ideally have pushed the refactor\nback to where the original code was introduced. It might have looked\nslightly over the top there, but it would have been correct and reduce\nchurn in this later patch.\n\n> @@ -825,12 +1111,25 @@ static ssize_t sampling_frequency_store(struct device *dev,\n>  \tif (ret)\n>  \t\treturn ret;\n>  \n> -\tret = iio_device_claim_direct(indio_dev);\n> -\tif (ret)\n> -\t\treturn ret;\n> +\tIIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim);\n> +\tif (IIO_DEV_ACQUIRE_FAILED(claim))\n> +\t\treturn -EBUSY;\nIdeally this would have been pushed back into the patch that introduced\nthe code to reduce the churn here.  Fix that up if you end up doing a v9.\n\n> +\n> +\tif (st->manual_mode && st->offload) {\n> +\t\tstruct spi_offload_trigger_config config = {\n> +\t\t\t.type = SPI_OFFLOAD_TRIGGER_PERIODIC,\n> +\t\t\t.periodic = { .frequency_hz = freq },\n> +\t\t};\n> +\n> +\t\tret = spi_offload_trigger_validate(st->offload->trigger, &config);\n> +\t\tif (ret)\n> +\t\t\treturn ret;\n> +\n> +\t\tst->offload->trigger_hz = config.periodic.frequency_hz;\n> +\t\treturn len;\n> +\t}\n>  \n>  \tret = ad4691_set_pwm_freq(st, freq);\n> -\tiio_device_release_direct(indio_dev);\n>  \tif (ret)\n>  \t\treturn ret;","headers":{"Return-Path":"\n <linux-pwm+bounces-8692-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pwm@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=IFMvKtJk;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-pwm+bounces-8692-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"IFMvKtJk\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g2yLg38QPz1yHS\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 26 Apr 2026 04:01:15 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id DF64D303389F\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 25 Apr 2026 17:55:11 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 6CBCE3624AF;\n\tSat, 25 Apr 2026 17:54:27 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 441091AA1D2;\n\tSat, 25 Apr 2026 17:54:27 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 7BBD5C2BCB0;\n\tSat, 25 Apr 2026 17:54:18 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777139667; cv=none;\n b=ZbCnROJSM2DLWU+CvX7BNRGZ2dOdWAlbHzoYp4ueL/1+8RI6hgKmPjAOqYhNg1ZdRqlUaWvhBvL8jYAJJUf3kI5oAqXGTSSarDCqcOdR7/YEzIPOrZbj/EdckuL/t/6L3m1GbRO3eML9kajmLTtw0ftI9mdFZ0sKhZ6lEEIGXoM=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777139667; c=relaxed/simple;\n\tbh=dVYFfq9D/wPHM2YOAQmblEGgtktKpkqI+v2SbdR/LSY=;\n\th=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=Dzc7JbuErpvRxlazNAj/MdbP0gGpCCkKpfZMD48kwotHd9Orpk1jOklhUoBKxJbkpQlFjYESNwoOs+G1Mdz7R36Bg2en50lpnbDzkK4+gZazb1qzH2KYkmUO++K493MZW9kvcuUqe7Qg1ovsBl+mZ4rrfhB6DAZl0gGw64YKEHw=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=IFMvKtJk; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1777139666;\n\tbh=dVYFfq9D/wPHM2YOAQmblEGgtktKpkqI+v2SbdR/LSY=;\n\th=Date:From:To:Cc:Subject:In-Reply-To:References:From;\n\tb=IFMvKtJkcTHlKsenz2lPKpwjyrwXt5/kmVxJNxBViRDYLOp/lZWucRukWYnom4YEO\n\t dQuO5KaZM0/Tg/II6UEt5zZqfnqziugSXs/8W7FBAZcZZWLuJk+vNBPEO1J88fxewJ\n\t IxUeck+/um82msXOvpD+wXlhz0s9YfSKg+0IAGGSoZAQhZJ6BdqXfvLuTbChqP4rLa\n\t ++jvCn7sg7RyuSY8RVB7KtIy8/+X6GzdL4xEppyAjH3P1VNaEtoSN2xJvYdHA0RgfO\n\t yORpVn5W7334hfAs+GcBCvaWLzLJgvCl5j8U86JHajXB2LH7Am9lWS8Y4ootb1wDNV\n\t qsgAlbt6W8kLA==","Date":"Sat, 25 Apr 2026 18:54:13 +0100","From":"Jonathan Cameron <jic23@kernel.org>","To":"Radu Sabau via B4 Relay <devnull+radu.sabau.analog.com@kernel.org>","Cc":"radu.sabau@analog.com, Lars-Peter Clausen <lars@metafoo.de>,\n Michael Hennerich <Michael.Hennerich@analog.com>,\n David Lechner <dlechner@baylibre.com>,\n Nuno =?utf-8?b?U8Oh?= <nuno.sa@analog.com>,\n Andy Shevchenko <andy@kernel.org>, Rob Herring <robh@kernel.org>,\n Krzysztof Kozlowski <krzk+dt@kernel.org>, Conor Dooley <conor+dt@kernel.org>,\n Uwe =?utf-8?q?Kleine-K=C3=B6nig?= <ukleinek@kernel.org>,\n Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>,\n Linus Walleij <linusw@kernel.org>, Bartosz Golaszewski <brgl@kernel.org>,\n Philipp Zabel <p.zabel@pengutronix.de>, Jonathan Corbet <corbet@lwn.net>,\n Shuah Khan <skhan@linuxfoundation.org>, linux-iio@vger.kernel.org,\n devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,\n linux-pwm@vger.kernel.org, linux-gpio@vger.kernel.org,\n linux-doc@vger.kernel.org","Subject":"Re: [PATCH v8 4/6] iio: adc: ad4691: add SPI offload support","Message-ID":"<20260425185413.0e81f521@jic23-huawei>","In-Reply-To":"\n <20260416-ad4692-multichannel-sar-adc-driver-v8-4-c415bd048fa3@analog.com>","References":"\n <20260416-ad4692-multichannel-sar-adc-driver-v8-0-c415bd048fa3@analog.com>\n\t<20260416-ad4692-multichannel-sar-adc-driver-v8-4-c415bd048fa3@analog.com>","X-Mailer":"Claws Mail 4.4.0 (GTK 3.24.52; x86_64-pc-linux-gnu)","Precedence":"bulk","X-Mailing-List":"linux-pwm@vger.kernel.org","List-Id":"<linux-pwm.vger.kernel.org>","List-Subscribe":"<mailto:linux-pwm+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pwm+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=US-ASCII","Content-Transfer-Encoding":"7bit"}}]