2024-05-31 22:53:23

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 0/8] spi: Rework DMA mapped flag

The first part of the series (patches 1 to 7) is an introduction
of a new helper followed by the user conversion.

This consolidates the same code and also makes patch 8 (last one)
be localised to the SPI core part.

The last patch is the main rework to get rid of a recently introduced
hack with a dummy SG list and move to the transfer-based DMA mapped
flag.

That said, the patches 1 to 7 may be applied right away since they
have no functional change intended, while the last one needs more
testing and reviewing.

Andy Shevchenko (8):
spi: Introduce internal spi_xfer_is_dma_mapped() helper
spi: dw: Use new spi_xfer_is_dma_mapped() helper
spi: ingenic: Use new spi_xfer_is_dma_mapped() helper
spi: omap2-mcspi: Use new spi_xfer_is_dma_mapped() helper
spi: pxa2xx: Use new spi_xfer_is_dma_mapped() helper
spi: pci1xxxx: Use new spi_xfer_is_dma_mapped() helper
spi: qup: Use new spi_xfer_is_dma_mapped() helper
spi: Rework per message DMA mapped flag to be per transfer

drivers/spi/internals.h | 8 ++++
drivers/spi/spi-dw-core.c | 4 +-
drivers/spi/spi-ingenic.c | 4 +-
drivers/spi/spi-omap2-mcspi.c | 8 ++--
drivers/spi/spi-pci1xxxx.c | 5 ++-
drivers/spi/spi-pxa2xx.c | 6 +--
drivers/spi/spi-qup.c | 9 ++---
drivers/spi/spi.c | 73 +++++++++++++----------------------
include/linux/spi/spi.h | 11 ++++--
9 files changed, 59 insertions(+), 69 deletions(-)

--
2.43.0.rc1.1336.g36b5255a03ac



2024-05-31 22:54:15

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 1/8] spi: Introduce internal spi_xfer_is_dma_mapped() helper

There are few drivers that use the same pattern to check if the transfer
is DMA mapped or not. Provide a helper.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/spi/internals.h | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/spi/internals.h b/drivers/spi/internals.h
index 4a28a8395552..47a87c2a6979 100644
--- a/drivers/spi/internals.h
+++ b/drivers/spi/internals.h
@@ -40,4 +40,12 @@ static inline void spi_unmap_buf(struct spi_controller *ctlr,
}
#endif /* CONFIG_HAS_DMA */

+static inline bool spi_xfer_is_dma_mapped(struct spi_controller *ctlr,
+ struct spi_device *spi,
+ struct spi_transfer *xfer)
+{
+ return ctlr->can_dma && ctlr->can_dma(ctlr, spi, xfer) &&
+ ctlr->cur_msg_mapped;
+}
+
#endif /* __LINUX_SPI_INTERNALS_H */
--
2.43.0.rc1.1336.g36b5255a03ac


2024-06-03 09:11:07

by Neil Armstrong

[permalink] [raw]
Subject: Re: [PATCH v1 0/8] spi: Rework DMA mapped flag

On 31/05/2024 21:42, Andy Shevchenko wrote:
> The first part of the series (patches 1 to 7) is an introduction
> of a new helper followed by the user conversion.
>
> This consolidates the same code and also makes patch 8 (last one)
> be localised to the SPI core part.
>
> The last patch is the main rework to get rid of a recently introduced
> hack with a dummy SG list and move to the transfer-based DMA mapped
> flag.
>
> That said, the patches 1 to 7 may be applied right away since they
> have no functional change intended, while the last one needs more
> testing and reviewing.
>
> Andy Shevchenko (8):
> spi: Introduce internal spi_xfer_is_dma_mapped() helper
> spi: dw: Use new spi_xfer_is_dma_mapped() helper
> spi: ingenic: Use new spi_xfer_is_dma_mapped() helper
> spi: omap2-mcspi: Use new spi_xfer_is_dma_mapped() helper
> spi: pxa2xx: Use new spi_xfer_is_dma_mapped() helper
> spi: pci1xxxx: Use new spi_xfer_is_dma_mapped() helper
> spi: qup: Use new spi_xfer_is_dma_mapped() helper
> spi: Rework per message DMA mapped flag to be per transfer
>
> drivers/spi/internals.h | 8 ++++
> drivers/spi/spi-dw-core.c | 4 +-
> drivers/spi/spi-ingenic.c | 4 +-
> drivers/spi/spi-omap2-mcspi.c | 8 ++--
> drivers/spi/spi-pci1xxxx.c | 5 ++-
> drivers/spi/spi-pxa2xx.c | 6 +--
> drivers/spi/spi-qup.c | 9 ++---
> drivers/spi/spi.c | 73 +++++++++++++----------------------
> include/linux/spi/spi.h | 11 ++++--
> 9 files changed, 59 insertions(+), 69 deletions(-)
>

I applied the serie on next-20240603, it worked fine:

Tested-by: Neil Armstrong <[email protected]> # on SM8650-QRD

Thanks,
Neil

2024-06-03 19:52:21

by Nícolas F. R. A. Prado

[permalink] [raw]
Subject: Re: [PATCH v1 0/8] spi: Rework DMA mapped flag

On Fri, May 31, 2024 at 10:42:32PM +0300, Andy Shevchenko wrote:
> The first part of the series (patches 1 to 7) is an introduction
> of a new helper followed by the user conversion.
>
> This consolidates the same code and also makes patch 8 (last one)
> be localised to the SPI core part.
>
> The last patch is the main rework to get rid of a recently introduced
> hack with a dummy SG list and move to the transfer-based DMA mapped
> flag.
>
> That said, the patches 1 to 7 may be applied right away since they
> have no functional change intended, while the last one needs more
> testing and reviewing.
>
> Andy Shevchenko (8):
> spi: Introduce internal spi_xfer_is_dma_mapped() helper
> spi: dw: Use new spi_xfer_is_dma_mapped() helper
> spi: ingenic: Use new spi_xfer_is_dma_mapped() helper
> spi: omap2-mcspi: Use new spi_xfer_is_dma_mapped() helper
> spi: pxa2xx: Use new spi_xfer_is_dma_mapped() helper
> spi: pci1xxxx: Use new spi_xfer_is_dma_mapped() helper
> spi: qup: Use new spi_xfer_is_dma_mapped() helper
> spi: Rework per message DMA mapped flag to be per transfer

Tested on next-20240603. No issue noticed on sc7180-trogdor-kingoftown and
sc7180-trogdor-lazor-limozeen. So,

Tested-by: N?colas F. R. A. Prado <[email protected]>

Although patch 5 (pxa2xx) didn't apply, so I skipped it (but it's not used on
my platforms).

Thanks,
N?colas

2024-06-03 19:53:54

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 0/8] spi: Rework DMA mapped flag

On Mon, Jun 03, 2024 at 03:49:04PM -0400, N?colas F. R. A. Prado wrote:
> On Fri, May 31, 2024 at 10:42:32PM +0300, Andy Shevchenko wrote:

...

> Tested on next-20240603. No issue noticed on sc7180-trogdor-kingoftown and
> sc7180-trogdor-lazor-limozeen. So,
>
> Tested-by: N?colas F. R. A. Prado <[email protected]>

Thank you!

> Although patch 5 (pxa2xx) didn't apply, so I skipped it (but it's not used on
> my platforms).

Yeah, I just commented on that, it appears that I have based this on the
previous driver cleanups (it was published a week ago).

--
With Best Regards,
Andy Shevchenko



2024-06-03 19:54:38

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 0/8] spi: Rework DMA mapped flag

On Mon, Jun 03, 2024 at 11:10:54AM +0200, Neil Armstrong wrote:
> On 31/05/2024 21:42, Andy Shevchenko wrote:

...

> I applied the serie on next-20240603, it worked fine:
>
> Tested-by: Neil Armstrong <[email protected]> # on SM8650-QRD

Thank you!

--
With Best Regards,
Andy Shevchenko



2024-06-03 22:54:35

by Bryan O'Donoghue

[permalink] [raw]
Subject: Re: [PATCH v1 1/8] spi: Introduce internal spi_xfer_is_dma_mapped() helper

On 31/05/2024 20:42, Andy Shevchenko wrote:
> There are few drivers that use the same pattern to check if the transfer
> is DMA mapped or not. Provide a helper.
>
> Signed-off-by: Andy Shevchenko <[email protected]>
> ---
> drivers/spi/internals.h | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/spi/internals.h b/drivers/spi/internals.h
> index 4a28a8395552..47a87c2a6979 100644
> --- a/drivers/spi/internals.h
> +++ b/drivers/spi/internals.h
> @@ -40,4 +40,12 @@ static inline void spi_unmap_buf(struct spi_controller *ctlr,
> }
> #endif /* CONFIG_HAS_DMA */
>
> +static inline bool spi_xfer_is_dma_mapped(struct spi_controller *ctlr,
> + struct spi_device *spi,
> + struct spi_transfer *xfer)
> +{
> + return ctlr->can_dma && ctlr->can_dma(ctlr, spi, xfer) &&
> + ctlr->cur_msg_mapped;
> +}
> +
> #endif /* __LINUX_SPI_INTERNALS_H */

Reviewed-by: Bryan O'Donoghue <[email protected]>