On Wed, 11 Dec 2024 14:54:42 -0600 David Lechner <dlechner@xxxxxxxxxxxx> wrote: > Most configuration of SPI offloads is handled opaquely using the offload > pointer that is passed to the various offload functions. However, there > are some offload features that need to be controlled on a per transfer > basis. > > This patch adds a flag field to struct spi_transfer to allow specifying > such features. The first feature to be added is the ability to stream > data to/from a hardware sink/source rather than using a tx or rx buffer. > Additional flags can be added in the future as needed. > > A flags field is also added to the offload struct for providers to > indicate which flags are supported. This allows for generic checking of > offload capabilities during __spi_validate() so that each offload > provider doesn't have to implement their own validation. > > As a first users of this streaming capability, getter functions are > added to get a DMA channel that is directly connected to the offload. > Peripheral drivers will use this to get a DMA channel and configure it > to suit their needs. > > Signed-off-by: David Lechner <dlechner@xxxxxxxxxxxx> Really really minor comment inline. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> > diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c > index ff1add2ecb91f18cf82e6f1e9595584c11adf9d8..4a871db9ee636aba64c866ebdd8bb1dbf82e0f42 100644 > --- a/drivers/spi/spi.c > +++ b/drivers/spi/spi.c > @@ -31,6 +31,7 @@ > #include <linux/ptp_clock_kernel.h> > #include <linux/sched/rt.h> > #include <linux/slab.h> > +#include <linux/spi/offload/types.h> > #include <linux/spi/spi.h> > #include <linux/spi/spi-mem.h> > #include <uapi/linux/sched/types.h> > @@ -4163,6 +4164,15 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message) > > if (_spi_xfer_word_delay_update(xfer, spi)) > return -EINVAL; > + > + /* make sure controller supports required offload features */ Comment syntax seems inconsistent with local code. /* Make sure controller supports required offload features. */ > + if (xfer->offload_flags) { > + if (!message->offload) > + return -EINVAL; > + > + if (xfer->offload_flags & ~message->offload->xfer_flags) > + return -EINVAL; > + } > } > > message->status = -EINPROGRESS;