iio: add new backend framework
Subsystems (7)
Nuno Sa
maintainerv2 cover iio: add new backend framework
This series depends on [1] and it only build on top of it. The point is to already speed up the reviewing of the framework. That obviously means that all those pacthes were dropped in v2.
Changes in v2:
- Patch 1-2 and 5
* new patches.
- Patch 6:
* Fixed some docs failures;
* Fixed a legacy 'conv' name in one of the function parameters;
* Added .request_buffer() and .free_buffer() ops;
* Refactored the helper macros;
* Added Olivier as Reviewer.
- Patch 7:
* Use new devm_iio_backend_request_buffer().
- Patch 8:
* Implement new .request_buffer() and .free_buffer() ops;
Also would like to mention that in v2 I'm experimenting in having the DMA on the backend device (as discussed with David in v1). Does not look to bad but as I said before, I'm not seeing a big issue if we end up having the buffer allocation in the frontend.
For the bindings folks:
I'm introducing a new io-backends property in the ad9467 bindings but I'm not sure this is the way to do it. Ideally that new property become a generic schema and I'm guessing I should send a PULL to?
https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/iio/iio-consumer.yaml
(Jonathan, if you think that's not the right place, shout now :))
I'm also deprecating 'adi,adc-dev' as it is not relevant anymore. In the driver code, we are actually breaking ABI but I'm taking a more conservative approach in the bindings. Ideally I would also remove it in the bindings :).
As requested here we have a small diagram that illustrated on e typical usage of the new framework:
------------------------------------------------------- ------------------ | ----------- ------------ ------- FPGA | | ADC |------------------------| | AXI ADC |---------| DMA CORE |------| RAM | | | (Frontend/IIO) | Serial Data (eg: LVDS) | |(backend)|---------| |------| | | | |------------------------| ----------- ------------ ------- | ------------------ -------------------------------------------------------
The above is highly focused on ADI usecases. But one can see the idea... The frontend is the real converter and is the one registering and handling all the IIO interfaces. Such a device can then connect to a backend device for further services/configurations. In the above example, the backend device is an high speed core capable of handling the high sample rate of these ADCs so that it can push that data further in the pipeline (typically a DMA core) so the user can process the samples with minimal losses.
Jonathan, I was also tempted in including the diagram in the source file. Would that be a good idea?
[1]: https://lore.kernel.org/linux-iio/[email protected]
---
Nuno Sa (7):
dt-bindings: adc: ad9467: document io-backend property
dt-bindings: adc: axi-adc: deprecate 'adi,adc-dev'
driver: core: allow modifying device_links flags
iio: buffer-dmaengine: export buffer alloc and free functions
iio: add the IIO backend framework
iio: adc: ad9467: convert to backend framework
iio: adc: adi-axi-adc: move to backend framework
Olivier Moysan (1):
of: property: add device link support for io-backends
.../devicetree/bindings/iio/adc/adi,ad9467.yaml | 5 + .../devicetree/bindings/iio/adc/adi,axi-adc.yaml | 4 +- MAINTAINERS | 8 + drivers/base/core.c | 14 +- drivers/iio/Kconfig | 5 + drivers/iio/Makefile | 1 + drivers/iio/adc/Kconfig | 3 +- drivers/iio/adc/ad9467.c | 242 +++++++------ drivers/iio/adc/adi-axi-adc.c | 379 +++++--------------- drivers/iio/buffer/industrialio-buffer-dmaengine.c | 6 +- drivers/iio/industrialio-backend.c | 386 +++++++++++++++++++++ drivers/of/property.c | 2 + include/linux/iio/adc/adi-axi-adc.h | 68 ---- include/linux/iio/backend.h | 68 ++++ include/linux/iio/buffer-dmaengine.h | 4 +- 15 files changed, 727 insertions(+), 468 deletions(-)
---
base-commit: 330c0f834ccbdbe6a89da475cb1c56893f3a8363
change-id: 20231120-dev-iio-backend-d14b473a1d9f --
Thanks!
- Nuno Sá
Nuno Sa
maintainerPATCH v2 1/8 dt-bindings: adc: ad9467: document io-backend property
Add a new property to reference IIO backend devices.
--- Documentation/devicetree/bindings/iio/adc/adi,ad9467.yaml | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/iio/adc/adi,ad9467.yaml +5 -0
@@ -44,6 +44,10 @@ properties: Pin that controls the powerdown mode of the device. maxItems: 1 + io-backends: + description: Phandle to the IIO backend device. + $ref: /schemas/types.yaml#/definitions/phandle + reset-gpios: description: Reset pin for the device.
@@ -68,6 +72,7 @@ examples: reg = <0>; clocks = <&adc_clk>; clock-names = "adc-clk"; + io-backends = <&iio_backend>; }; }; ...
Signature · 1 line
2.43.0
Re: [PATCH v2 1/8] dt-bindings: adc: ad9467: document io-backend property
Quoted 3 lines · On 08/12/2023 16:14, Nuno Sa via B4 Relay wrote:
From: Nuno Sa <[email protected]>
Add a new property to reference IIO backend devices.
This we can see. But why?
Quoted 11 lines
Signed-off-by Nuno Sa <[email protected]>--- Documentation/devicetree/bindings/iio/adc/adi,ad9467.yaml | 5 +++++ 1 file changed, 5 insertions(+)Documentation/devicetree/bindings/iio/adc/adi,ad9467.yaml +0
-0
Documentation/devicetree/bindings/iio/adc/adi,ad9467.yaml properties: · line 48
Quoted 5 lines
Documentation/devicetree/bindings/iio/adc/adi,ad9467.yaml +2
-0@@ -44,6 +44,10 @@ properties: Pin that controls the powerdown mode of the device. maxItems: 1 + io-backends: + description: Phandle to the IIO backend device.
Looks like standard property. Where is it defined? What is the meaning (your description does not tell me anything more than property name and its type)
Documentation/devicetree/bindings/iio/adc/adi,ad9467.yaml properties: · line 50
Quoted 2 lines
Documentation/devicetree/bindings/iio/adc/adi,ad9467.yaml +2
-0+ $ref: /schemas/types.yaml#/definitions/phandle +
Best regards,
Krzysztof
Re: [PATCH v2 1/8] dt-bindings: adc: ad9467: document io-backend property
Quoted 13 lines · Krzysztof Kozlowski
Quoted 3 lines · On 08/12/2023 16:14, Nuno Sa via B4 Relay wrote:
From: Nuno Sa <[email protected]>
Add a new property to reference IIO backend devices.
This we can see. But why?
Quoted 6 lines
Signed-off-by Nuno Sa <[email protected]>---
Documentation/devicetree/bindings/iio/adc/adi,ad9467.yaml | 5 +++++1 file changed, 5 insertions(+)
Quoted 15 lines
Quoted 11 lines
Documentation/devicetree/bindings/iio/adc/adi,ad9467.yaml +0
-0@@ -44,6 +44,10 @@ properties:Pin that controls the powerdown mode of the device.
maxItems: 1
+ io-backends:
+ description: Phandle to the IIO backend device.Looks like standard property. Where is it defined? What is the meaning (your description does not tell me anything more than property name and its type)
Yeah, Conor already gave me some feedback in the cover where I mention this property. I'll improve on the description and send a PR for a generic schema.
Thanks!
- Nuno Sá
Nuno Sa
maintainerPATCH v2 2/8 dt-bindings: adc: axi-adc: deprecate 'adi,adc-dev'
In reply to Nuno Sa'adi,adc-dev' is now deprecated and must not be used anymore. Hence, also remove it from being required.
--- Documentation/devicetree/bindings/iio/adc/adi,axi-adc.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Documentation/devicetree/bindings/iio/adc/adi,axi-adc.yaml +1 -3
@@ -39,12 +39,12 @@ properties: $ref: /schemas/types.yaml#/definitions/phandle description: A reference to a the actual ADC to which this FPGA ADC interfaces to. + deprecated: true required: - compatible - dmas - reg - - adi,adc-dev additionalProperties: false
@@ -55,7 +55,5 @@ examples: reg = <0x44a00000 0x10000>; dmas = <&rx_dma 0>; dma-names = "rx"; - - adi,adc-dev = <&spi_adc>; }; ...
Signature · 1 line
2.43.0
Re: [PATCH v2 2/8] dt-bindings: adc: axi-adc: deprecate 'adi,adc-dev'
Quoted 4 lines · On 08/12/2023 16:14, Nuno Sa via B4 Relay wrote:
From: Nuno Sa <[email protected]>
'adi,adc-dev' is now deprecated and must not be used anymore. Hence, also remove it from being required.
Why did it become suddenly deprecated? Unfortunately the commit msg does not tell me more, except copying the code...
If this is result of previous patch, then squash it.
Best regards,
Krzysztof
Re: [PATCH v2 2/8] dt-bindings: adc: axi-adc: deprecate 'adi,adc-dev'
Quoted 11 lines · Krzysztof Kozlowski
Quoted 4 lines · On 08/12/2023 16:14, Nuno Sa via B4 Relay wrote:
From: Nuno Sa <[email protected]>
'adi,adc-dev' is now deprecated and must not be used anymore. Hence, also remove it from being required.
Why did it become suddenly deprecated? Unfortunately the commit msg does not tell me more, except copying the code...
If this is result of previous patch, then squash it.
This property will be deprecated by the generic property mentioned in the cover (basically the property in patch 1).
I'll improve the commit message on why it's being deprecated. It has a lot to do with the changes in the drivers and how we want to start handling these HW arrangements. I'll try to explain it in a way that makes sense from a bindings point of view.
Thanks!
- Nuno Sá
Nuno Sa
maintainerPATCH v2 3/8 driver: core: allow modifying device_links flags
In reply to Nuno SaIf a device_link is previously created (eg: via fw_devlink_create_devlink()) before the supplier + consumer are both present and bound to their respective drivers, there's no way to set DL_FLAG_AUTOREMOVE_CONSUMER anymore while one can still set DL_FLAG_AUTOREMOVE_SUPPLIER. Hence, rework the flags checks to allow for DL_FLAG_AUTOREMOVE_CONSUMER in the same way DL_FLAG_AUTOREMOVE_SUPPLIER is done.
While at it, make sure that we are never left with DL_FLAG_AUTOPROBE_CONSUMER set together with one of DL_FLAG_AUTOREMOVE_CONSUMER or DL_FLAG_AUTOREMOVE_SUPPLIER.
--- drivers/base/core.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/base/core.c +9 -5
@@ -807,11 +807,15 @@ struct device_link *device_link_add(struct device *consumer,* update the existing link to stay around longer. */ if (flags &DL_FLAG_AUTOREMOVE_SUPPLIER ) { -if (link->flags &DL_FLAG_AUTOREMOVE_CONSUMER ) { - link->flags &= ~DL_FLAG_AUTOREMOVE_CONSUMER ; - link->flags |=DL_FLAG_AUTOREMOVE_SUPPLIER ; - } - }else if (!(flags &DL_FLAG_AUTOREMOVE_CONSUMER )) { + link->flags &= ~DL_FLAG_AUTOREMOVE_CONSUMER ; + link->flags &= ~DL_FLAG_AUTOPROBE_CONSUMER ; + link->flags |=DL_FLAG_AUTOREMOVE_SUPPLIER ; + + }else if (flags &DL_FLAG_AUTOREMOVE_CONSUMER ) { + link->flags &= ~DL_FLAG_AUTOREMOVE_SUPPLIER ; + link->flags &= ~DL_FLAG_AUTOPROBE_CONSUMER ; + link->flags |=DL_FLAG_AUTOREMOVE_CONSUMER ; + }else { link->flags &= ~(DL_FLAG_AUTOREMOVE_CONSUMER |DL_FLAG_AUTOREMOVE_SUPPLIER ); }
Signature · 1 line
2.43.0
Jonathan Cameron
maintainerRe: [PATCH v2 3/8] driver: core: allow modifying device_links flags
Quoted 26 lines · On Fri, 08 Dec 2023 16:14:10 +0100 Nuno Sa via B4 Relay…
From: Nuno Sa <[email protected]>
If a
device_linkis previously created (eg: viafw_devlink_create_devlink()) before the supplier + consumer are both present and bound to their respective drivers, there's no way to setDL_FLAG_AUTOREMOVE_CONSUMERanymore while one can still setDL_FLAG_AUTOREMOVE_SUPPLIER. Hence, rework the flags checks to allow forDL_FLAG_AUTOREMOVE_CONSUMERin the same wayDL_FLAG_AUTOREMOVE_SUPPLIERis done.While at it, make sure that we are never left with
DL_FLAG_AUTOPROBE_CONSUMERset together with one ofDL_FLAG_AUTOREMOVE_CONSUMERorDL_FLAG_AUTOREMOVE_SUPPLIER.Signed-off-by Nuno Sa <[email protected]>--- drivers/base/core.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/base/core.c +0
-0@@ -807,11 +807,15 @@ struct device_link *device_link_add(struct device *consumer,* update the existing link to stay around longer. */
drivers/base/core.c struct device_link *device_link_add(struct device *consumer, · line 813
Quoted 10 lines
drivers/base/core.c +4
-5if (flags &DL_FLAG_AUTOREMOVE_SUPPLIER ) { -if (link->flags &DL_FLAG_AUTOREMOVE_CONSUMER ) { - link->flags &= ~DL_FLAG_AUTOREMOVE_CONSUMER ; - link->flags |=DL_FLAG_AUTOREMOVE_SUPPLIER ; - } - }else if (!(flags &DL_FLAG_AUTOREMOVE_CONSUMER )) { + link->flags &= ~DL_FLAG_AUTOREMOVE_CONSUMER ; + link->flags &= ~DL_FLAG_AUTOPROBE_CONSUMER ; + link->flags |=DL_FLAG_AUTOREMOVE_SUPPLIER ; +
Trivial but this blank line seems unwanted variation in formatting.
Quoted 9 lines
drivers/base/core.c +5
-0+ }else if (flags &DL_FLAG_AUTOREMOVE_CONSUMER ) { + link->flags &= ~DL_FLAG_AUTOREMOVE_SUPPLIER ; + link->flags &= ~DL_FLAG_AUTOPROBE_CONSUMER ; + link->flags |=DL_FLAG_AUTOREMOVE_CONSUMER ; + }else { link->flags &= ~(DL_FLAG_AUTOREMOVE_CONSUMER |DL_FLAG_AUTOREMOVE_SUPPLIER ); }
Nuno Sa
maintainerPATCH v2 4/8 of: property: add device link support for io-backends
In reply to Nuno SaFrom: Olivier Moysan <[email protected]>
Add support for creating device links out of more DT properties.
--- drivers/of/property.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/of/property.c +2 -0
@@ -1244,6 +1244,7 @@ DEFINE_SIMPLE_PROP(interconnects, "interconnects", "#interconnect-cells") DEFINE_SIMPLE_PROP(iommus, "iommus", "#iommu-cells") DEFINE_SIMPLE_PROP(mboxes, "mboxes", "#mbox-cells") DEFINE_SIMPLE_PROP(io_channels, "io-channel", "#io-channel-cells") +DEFINE_SIMPLE_PROP(io_backends, "io-backends", NULL) DEFINE_SIMPLE_PROP(interrupt_parent, "interrupt-parent", NULL) DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-cells")DEFINE_SIMPLE_PROP (power_domains,"power-domains" ,"#power-domain-cells" )
@@ -1334,6 +1335,7 @@ static const struct supplier_bindings of_supplier_bindings[] = { { .parse_prop = parse_iommu_maps, .optional = true, }, { .parse_prop = parse_mboxes, }, { .parse_prop = parse_io_channels, }, + { .parse_prop = parse_io_backends, }, { .parse_prop = parse_interrupt_parent, }, { .parse_prop = parse_dmas, .optional = true, }, { .parse_prop = parse_power_domains, },
Signature · 1 line
2.43.0
Nuno Sa
maintainerPATCH v2 5/8 iio: buffer-dmaengine: export buffer alloc and free functions
In reply to Nuno SaExport iio_dmaengine_buffer_free() and iio_dmaengine_buffer_alloc(). This is in preparation of introducing IIO backends support. This will allow us to allocate a buffer and control it's lifetime from a device different from the one holding the DMA firmware properties. Effectively, in this case the struct device holding the firmware information about the DMA channels is not the same as iio_dev->dev.parent (typical case).
--- drivers/iio/buffer/industrialio-buffer-dmaengine.c | 6 ++++-- include/linux/iio/buffer-dmaengine.h | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/iio/buffer/industrialio-buffer-dmaengine.c +4 -2
@@ -159,7 +159,7 @@ static const struct iio_dev_attr *iio_dmaengine_buffer_attrs[] = {* Once done using the buffer iio_dmaengine_buffer_free() should be used to * release it. */ -static struct iio_buffer *iio_dmaengine_buffer_alloc (struct device *dev, +struct iio_buffer *iio_dmaengine_buffer_alloc (struct device *dev,const char *channel) {struct dmaengine_buffer *dmaengine_buffer;
@@ -210,6 +210,7 @@ static struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev,kfree (dmaengine_buffer);return ERR_PTR (ret); } +EXPORT_SYMBOL_GPL (iio_dmaengine_buffer_alloc);/** * iio_dmaengine_buffer_free() - Free dmaengine buffer
@@ -217,7 +218,7 @@ static struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev,* * Frees a buffer previously allocated with iio_dmaengine_buffer_alloc(). */ -static void iio_dmaengine_buffer_free (struct iio_buffer *buffer) +void iio_dmaengine_buffer_free (struct iio_buffer *buffer) {struct dmaengine_buffer *dmaengine_buffer =iio_buffer_to_dmaengine_buffer (buffer);
@@ -227,6 +228,7 @@ static void iio_dmaengine_buffer_free(struct iio_buffer *buffer)iio_buffer_put (buffer); } +EXPORT_SYMBOL_GPL (iio_dmaengine_buffer_free);static void __devm_iio_dmaengine_buffer_free (void *buffer) {
include/linux/iio/buffer-dmaengine.h +3 -1
@@ -10,8 +10,10 @@struct iio_dev ;struct device ; +struct iio_buffer *iio_dmaengine_buffer_alloc (struct device *dev, +const char *channel); +void iio_dmaengine_buffer_free (struct iio_buffer *buffer);int devm_iio_dmaengine_buffer_setup (struct device *dev,struct iio_dev *indio_dev,const char *channel); -#endif
Signature · 1 line
2.43.0
Jonathan Cameron
maintainerRe: [PATCH v2 5/8] iio: buffer-dmaengine: export buffer alloc and free functions
Quoted 10 lines · On Fri, 08 Dec 2023 16:14:12 +0100 Nuno Sa via B4 Relay…
From: Nuno Sa <[email protected]>
Export
iio_dmaengine_buffer_free()andiio_dmaengine_buffer_alloc(). This is in preparation of introducing IIO backends support. This will allow us to allocate a buffer and control it's lifetime from a device different from the one holding the DMA firmware properties. Effectively, in this case the struct device holding the firmware information about the DMA channels is not the same asiio_dev->dev.parent(typical case).Signed-off-by Nuno Sa <[email protected]>
Probably a good idea to namespace these and existing exports related to buffer-dmaengine whilst you are at it.
Quoted 48 lines
--- drivers/iio/buffer/industrialio-buffer-dmaengine.c | 6 ++++-- include/linux/iio/buffer-dmaengine.h | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-)drivers/iio/buffer/industrialio-buffer-dmaengine.c +4
-2@@ -159,7 +159,7 @@ static const struct iio_dev_attr *iio_dmaengine_buffer_attrs[] = {* Once done using the buffer iio_dmaengine_buffer_free() should be used to * release it. */ -static struct iio_buffer *iio_dmaengine_buffer_alloc (struct device *dev, +struct iio_buffer *iio_dmaengine_buffer_alloc (struct device *dev,const char *channel) {struct dmaengine_buffer *dmaengine_buffer;@@ -210,6 +210,7 @@ static struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev,kfree (dmaengine_buffer);return ERR_PTR (ret); } +EXPORT_SYMBOL_GPL (iio_dmaengine_buffer_alloc);/** * iio_dmaengine_buffer_free() - Free dmaengine buffer @@ -217,7 +218,7 @@ static struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev,* * Frees a buffer previously allocated with iio_dmaengine_buffer_alloc(). */ -static void iio_dmaengine_buffer_free (struct iio_buffer *buffer) +void iio_dmaengine_buffer_free (struct iio_buffer *buffer) {struct dmaengine_buffer *dmaengine_buffer =iio_buffer_to_dmaengine_buffer (buffer);@@ -227,6 +228,7 @@ static void iio_dmaengine_buffer_free(struct iio_buffer *buffer)iio_buffer_put (buffer); } +EXPORT_SYMBOL_GPL (iio_dmaengine_buffer_free);static void __devm_iio_dmaengine_buffer_free (void *buffer) {include/linux/iio/buffer-dmaengine.h +0
-0
include/linux/iio/buffer-dmaengine.h line 16
Quoted 10 lines
include/linux/iio/buffer-dmaengine.h +3
-1@@ -10,8 +10,10 @@struct iio_dev ;struct device ; +struct iio_buffer *iio_dmaengine_buffer_alloc (struct device *dev, +const char *channel); +void iio_dmaengine_buffer_free (struct iio_buffer *buffer);int devm_iio_dmaengine_buffer_setup (struct device *dev,struct iio_dev *indio_dev,const char *channel); -
Unrelated change.
Quoted 2 lines
include/linux/iio/buffer-dmaengine.h +0
-0#endif
Re: [PATCH v2 5/8] iio: buffer-dmaengine: export buffer alloc and free functions
Quoted 12 lines · Jonathan Cameron
Quoted 9 lines · On Fri, 08 Dec 2023 16:14:12 +0100 Nuno Sa via B4 Relay…
From: Nuno Sa <[email protected]>
Export
iio_dmaengine_buffer_free()andiio_dmaengine_buffer_alloc(). This is in preparation of introducing IIO backends support. This will allow us to allocate a buffer and control it's lifetime from a device different from the one holding the DMA firmware properties. Effectively, in this case the struct device holding the firmware information about the DMA channels is not the same asiio_dev->dev.parent(typical case).
Quoted 5 lines
Quoted 1 line
Signed-off-by Nuno Sa <[email protected]>Probably a good idea to namespace these and existing exports related to buffer-dmaengine whilst you are at it.
Will do that...
Quoted 1 line
- Nuno Sá
Nuno Sa
maintainerPATCH v2 6/8 iio: add the IIO backend framework
In reply to Nuno SaThis is a Framework to handle complex IIO aggregate devices.
The typical architecture is to have one device as the frontend device which can be "linked" against one or multiple backend devices. All the IIO and userspace interface is expected to be registers/managed by the frontend device which will callback into the backends when needed (to get/set some configuration that it does not directly control).
The basic framework interface is pretty simple:
- Backends should register themselves with @devm_iio_backend_register()
- Frontend devices should get backends with @devm_iio_backend_get()
--- MAINTAINERS | 8 + drivers/iio/Kconfig | 5 + drivers/iio/Makefile | 1 + drivers/iio/industrialio-backend.c | 386 +++++++++++++++++++++++++++++++++++++ include/linux/iio/backend.h | 68 +++++++ 5 files changed, 468 insertions(+)
MAINTAINERS +8 -0
@@ -10320,6 +10320,14 @@ L: [email protected] S: Maintained F: drivers/media/rc/iguanair.c +IIO BACKEND FRAMEWORK +M: Nuno Sa <[email protected]> +R: Olivier Moysan <[email protected]> +L: [email protected] +S: Maintained +F: drivers/iio/industrialio-backend.c +F: include/linux/iio/backend.h + IIO DIGITAL POTENTIOMETER DAC M: Peter Rosin <[email protected]> L: [email protected]
drivers/iio/Kconfig +5 -0
@@ -71,6 +71,11 @@ config IIO_TRIGGERED_EVENT help Provides helper functions for setting up triggered events. +config IIO_BACKEND + tristate + help + Framework to handle complex IIO aggregate devices. + source "drivers/iio/accel/Kconfig" source "drivers/iio/adc/Kconfig" source "drivers/iio/addac/Kconfig"
drivers/iio/Makefile +1 -0
@@ -13,6 +13,7 @@ obj-$(CONFIG_IIO_GTS_HELPER) += industrialio-gts-helper.o obj-$(CONFIG_IIO_SW_DEVICE) += industrialio-sw-device.o obj-$(CONFIG_IIO_SW_TRIGGER) += industrialio-sw-trigger.o obj-$(CONFIG_IIO_TRIGGERED_EVENT) += industrialio-triggered-event.o +obj-$(CONFIG_IIO_BACKEND) += industrialio-backend.o obj-y += accel/ obj-y += adc/
drivers/iio/industrialio-backend.c new file +386 -0
386 lines not on this page · raw message
include/linux/iio/backend.h new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
2.43.0
Jonathan Cameron
maintainerRe: [PATCH v2 6/8] iio: add the IIO backend framework
Quoted 10 lines · On Fri, 08 Dec 2023 16:14:13 +0100 Nuno Sa via B4 Relay…
From: Nuno Sa <[email protected]>
This is a Framework to handle complex IIO aggregate devices.
The typical architecture is to have one device as the frontend device which can be "linked" against one or multiple backend devices. All the IIO and userspace interface is expected to be registers/managed by the frontend device which will callback into the backends when needed (to get/set some configuration that it does not directly control).
Quoted 5 lines
The basic framework interface is pretty simple:
- Backends should register themselves with @devm_iio_backend_register()
- Frontend devices should get backends with @devm_iio_backend_get()Signed-off-by Nuno Sa <[email protected]>
Name space all the Symbol Exports. Otherwise, no particular comments from me. I will take a deeper look at all the details at somepoint, but so far it looks basically fine to me.
Jonathan
Nuno Sa
maintainerPATCH v2 7/8 iio: adc: ad9467: convert to backend framework
In reply to Nuno SaConvert the driver to use the new IIO backend framework. The device functionality is expected to be the same (meaning no added or removed features).
Also note this patch effectively breaks ABI and that's needed so we can properly support this device and add needed features making use of the new IIO framework.
--- drivers/iio/adc/Kconfig | 2 +- drivers/iio/adc/ad9467.c | 242 +++++++++++++++++++++++++++-------------------- 2 files changed, 143 insertions(+), 101 deletions(-)
drivers/iio/adc/Kconfig +1 -1
@@ -275,7 +275,7 @@ config AD799X config AD9467 tristate "Analog Devices AD9467 High Speed ADC driver" depends on SPI - depends on ADI_AXI_ADC + select IIO_BACKEND help Say yes here to build support for Analog Devices: * AD9467 16-Bit, 200 MSPS/250 MSPS Analog-to-Digital Converter
drivers/iio/adc/ad9467.c +142 -100
428 lines not on this page · raw message
Signature · 1 line
2.43.0
Nuno Sa
maintainerPATCH v2 8/8 iio: adc: adi-axi-adc: move to backend framework
In reply to Nuno SaMove to the IIO backend framework. Devices supported by adi-axi-adc now register themselves as backend devices.
--- drivers/iio/adc/Kconfig | 1 + drivers/iio/adc/adi-axi-adc.c | 379 +++++++++--------------------------- include/linux/iio/adc/adi-axi-adc.h | 68 ------- 3 files changed, 92 insertions(+), 356 deletions(-)
drivers/iio/adc/Kconfig +1 -0
@@ -292,6 +292,7 @@ config ADI_AXI_ADC select IIO_BUFFER select IIO_BUFFER_HW_CONSUMER select IIO_BUFFER_DMAENGINE + select IIO_BACKEND depends on HAS_IOMEM depends on OF help
drivers/iio/adc/adi-axi-adc.c +91 -288
490 lines not on this page · raw message
include/linux/iio/adc/adi-axi-adc.h deleted +0 -68
68 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 26 lines · On Fri, Dec 08, 2023 at 04:14:07PM +0100, Nuno Sa via B4 Relay wrote:
This series depends on [1] and it only build on top of it. The point is to already speed up the reviewing of the framework. That obviously means that all those pacthes were dropped in v2.
Changes in v2:
- Patch 1-2 and 5
* new patches.
- Patch 6:
* Fixed some docs failures;
* Fixed a legacy 'conv' name in one of the function parameters;
* Added .request_buffer() and .free_buffer() ops;
* Refactored the helper macros;
* Added Olivier as Reviewer.
- Patch 7:
* Use newdevm_iio_backend_request_buffer().
- Patch 8:
* Implement new .request_buffer() and .free_buffer() ops;Also would like to mention that in v2 I'm experimenting in having the DMA on the backend device (as discussed with David in v1). Does not look to bad but as I said before, I'm not seeing a big issue if we end up having the buffer allocation in the frontend.
Quoted 7 lines
For the bindings folks:
I'm introducing a new io-backends property in the ad9467 bindings but I'm not sure this is the way to do it. Ideally that new property become a generic schema and I'm guessing I should send a PULL to?
https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/iio/iio-consumer.yaml
That seems like the right thing to do to me, depending on how widespread the use of these backends might be. What is seemingly missing though, from this cover and from the bindings patch in the series in particular, is an explanation of what the "iio-backends" hardware actually is.
There is some text below, but it does not seem complete to me. Is the idea that this "backend" is shared between multiple frontend consumers? The one example is described as being "highly focused on ADI usecases"
Thanks,
Conor.
Quoted 70 lines
(Jonathan, if you think that's not the right place, shout now :))
I'm also deprecating 'adi,adc-dev' as it is not relevant anymore. In the driver code, we are actually breaking ABI but I'm taking a more conservative approach in the bindings. Ideally I would also remove it in the bindings :).
As requested here we have a small diagram that illustrated on e typical usage of the new framework:
------------------------------------------------------- ------------------ | ----------- ------------ ------- FPGA | | ADC |------------------------| | AXI ADC |---------| DMA CORE |------| RAM | | | (Frontend/IIO) | Serial Data (eg: LVDS) | |(backend)|---------| |------| | | | |------------------------| ----------- ------------ ------- | ------------------ -------------------------------------------------------The above is highly focused on ADI usecases. But one can see the idea... The frontend is the real converter and is the one registering and handling all the IIO interfaces. Such a device can then connect to a backend device for further services/configurations. In the above example, the backend device is an high speed core capable of handling the high sample rate of these ADCs so that it can push that data further in the pipeline (typically a DMA core) so the user can process the samples with minimal losses.
Jonathan, I was also tempted in including the diagram in the source file. Would that be a good idea?
[1]: https://lore.kernel.org/linux-iio/[email protected]
---
Nuno Sa (7):
dt-bindings: adc: ad9467: document io-backend property
dt-bindings: adc: axi-adc: deprecate 'adi,adc-dev'
driver: core: allow modifyingdevice_linksflags
iio: buffer-dmaengine: export buffer alloc and free functions
iio: add the IIO backend framework
iio: adc: ad9467: convert to backend framework
iio: adc: adi-axi-adc: move to backend frameworkOlivier Moysan (1):
of: property: add device link support for io-backends.../devicetree/bindings/iio/adc/adi,ad9467.yaml | 5 + .../devicetree/bindings/iio/adc/adi,axi-adc.yaml | 4 +- MAINTAINERS | 8 + drivers/base/core.c | 14 +- drivers/iio/Kconfig | 5 + drivers/iio/Makefile | 1 + drivers/iio/adc/Kconfig | 3 +- drivers/iio/adc/ad9467.c | 242 +++++++------ drivers/iio/adc/adi-axi-adc.c | 379 +++++--------------- drivers/iio/buffer/industrialio-buffer-dmaengine.c | 6 +- drivers/iio/industrialio-backend.c | 386 +++++++++++++++++++++ drivers/of/property.c | 2 + include/linux/iio/adc/adi-axi-adc.h | 68 ---- include/linux/iio/backend.h | 68 ++++ include/linux/iio/buffer-dmaengine.h | 4 +- 15 files changed, 727 insertions(+), 468 deletions(-)---
base-commit:330c0f834ccbdbe6a89da475cb1c56893f3a8363
change-id: 20231120-dev-iio-backend-d14b473a1d9f --Thanks!
- Nuno Sá
Quoted 35 lines · Conor Dooley
Quoted 34 lines · On Fri, Dec 08, 2023 at 04:14:07PM +0100, Nuno Sa via B4 Relay wrote:
This series depends on [1] and it only build on top of it. The point is to already speed up the reviewing of the framework. That obviously means that all those pacthes were dropped in v2.
v1:
https://lore.kernel.org/linux-iio/20231204144925.4fe9922f@jic23-huawei/T/#m222f5175273b81dbfe40b7f0daffcdc67d6cb8ffChanges in v2:
- Patch 1-2 and 5
* new patches.
- Patch 6:
* Fixed some docs failures;
* Fixed a legacy 'conv' name in one of the function parameters;
* Added .request_buffer() and .free_buffer() ops;
* Refactored the helper macros;
* Added Olivier as Reviewer.
- Patch 7:
* Use newdevm_iio_backend_request_buffer().
- Patch 8:
* Implement new .request_buffer() and .free_buffer() ops;Also would like to mention that in v2 I'm experimenting in having the DMA on the backend device (as discussed with David in v1). Does not look to bad but as I said before, I'm not seeing a big issue if we end up having the buffer allocation in the frontend.
For the bindings folks:
I'm introducing a new io-backends property in the ad9467 bindings but I'm not sure this is the way to do it. Ideally that new property become a generic schema and I'm guessing I should send a PULL to?
Quoted 7 lines
Quoted 1 line
https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/iio/iio-consumer.yaml
That seems like the right thing to do to me, depending on how widespread the use of these backends might be. What is seemingly missing though, from this cover and from the bindings patch in the series in particular, is an explanation of what the "iio-backends" hardware actually is.
Yeah, sorry about the bindings patch but I was already with the feeling that a PR in devicetree-org to be the right place. I'll be adding more drivers needing that property and STM also wants make use this.
I'll improve on the explanation and send a PR for a generic schema.
Quoted 4 lines
There is some text below, but it does not seem complete to me. Is the idea that this "backend" is shared between multiple frontend consumers? The one example is described as being "highly focused on ADI usecases"
For now it cannot really be shared. The code is not prepared for it (we would need to keep enable/disable counters etc...). For now, I'm just adding the simpler cases of 1:1 and 1:n (1 frontend for multiple backends). Internally we do have 1:n designs that I definitely want (in time) to bring upstream.
That said, having a usecase for it in the future, it is something that can be added, yes...
Thanks for the feedback!
- Nuno Sá
Quoted 1 line
Quoted 55 lines · Nuno Sá
Quoted 35 lines · Conor Dooley
Quoted 34 lines · On Fri, Dec 08, 2023 at 04:14:07PM +0100, Nuno Sa via B4 Relay wrote:
This series depends on [1] and it only build on top of it. The point is to already speed up the reviewing of the framework. That obviously means that all those pacthes were dropped in v2.
v1:
https://lore.kernel.org/linux-iio/20231204144925.4fe9922f@jic23-huawei/T/#m222f5175273b81dbfe40b7f0daffcdc67d6cb8ffChanges in v2:
- Patch 1-2 and 5
* new patches.
- Patch 6:
* Fixed some docs failures;
* Fixed a legacy 'conv' name in one of the function parameters;
* Added .request_buffer() and .free_buffer() ops;
* Refactored the helper macros;
* Added Olivier as Reviewer.
- Patch 7:
* Use newdevm_iio_backend_request_buffer().
- Patch 8:
* Implement new .request_buffer() and .free_buffer() ops;Also would like to mention that in v2 I'm experimenting in having the DMA on the backend device (as discussed with David in v1). Does not look to bad but as I said before, I'm not seeing a big issue if we end up having the buffer allocation in the frontend.
For the bindings folks:
I'm introducing a new io-backends property in the ad9467 bindings but I'm not sure this is the way to do it. Ideally that new property become a generic schema and I'm guessing I should send a PULL to?
Quoted 7 lines
Quoted 1 line
https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/iio/iio-consumer.yaml
That seems like the right thing to do to me, depending on how widespread the use of these backends might be. What is seemingly missing though, from this cover and from the bindings patch in the series in particular, is an explanation of what the "iio-backends" hardware actually is.
Yeah, sorry about the bindings patch but I was already with the feeling that a PR in devicetree-org to be the right place. I'll be adding more drivers needing that property and STM also wants make use this.
I'll improve on the explanation and send a PR for a generic schema.
Quoted 4 lines
There is some text below, but it does not seem complete to me. Is the idea that this "backend" is shared between multiple frontend consumers? The one example is described as being "highly focused on ADI usecases"
Quoted 4 lines
For now it cannot really be shared. The code is not prepared for it (we would need to keep enable/disable counters etc...). For now, I'm just adding the simpler cases of 1:1 and 1:n (1 frontend for multiple backends). Internally we do have 1:n designs that I definitely want (in time) to bring upstream.
TBH, I am not really interested in whether or not the drivers support it at the moment, it just be great if the explanation of how these backends work (the hardware, not the linux implementation) included that detail.
Quoted 8 lines
That said, having a usecase for it in the future, it is something that can be added, yes...
Thanks for the feedback!
- Nuno SáQuoted 1 line