From 3ae025193e9fd6baa03e59d38c835f7f14f5206e Mon Sep 17 00:00:00 2001 From: Shashi Kant Maurya Date: Wed, 26 Aug 2020 18:03:47 +0530 Subject: [PATCH] asoc: wcd-spi: Set the dma_mask for spi_device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wcd-spi multi read fails in umapping the dma memory(swiotlb_bounce). Memory is not allocating from CMA reserve which leading the failure. So forcing the driver to allocate memory from CMA by initializing the device’s coherent_dma_mask & dma_mask. Change-Id: I7c0dba83789ed3c18c336e564a9f06397af9f0e8 Signed-off-by: Shashi Kant Maurya --- asoc/codecs/wcd-spi.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/asoc/codecs/wcd-spi.c b/asoc/codecs/wcd-spi.c index 4c7a85338ed4..3834374a65a8 100644 --- a/asoc/codecs/wcd-spi.c +++ b/asoc/codecs/wcd-spi.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */ #include @@ -1531,6 +1531,17 @@ static const struct component_ops wcd_spi_component_ops = { .unbind = wcd_spi_component_unbind, }; +#ifdef CONFIG_WCD_SPI_DMA_MASKING +static void arch_setup_spi_archdata(struct spi_device *spi) +{ + if (spi->dev.coherent_dma_mask == DMA_MASK_NONE && + spi->dev.dma_mask == NULL) { + spi->dev.coherent_dma_mask = DMA_BIT_MASK(sizeof(dma_addr_t) * 8); + spi->dev.dma_mask = &spi->dev.coherent_dma_mask; + } +} +#endif + static int wcd_spi_probe(struct spi_device *spi) { struct wcd_spi_priv *wcd_spi; @@ -1557,8 +1568,11 @@ static int wcd_spi_probe(struct spi_device *spi) mutex_init(&wcd_spi->xfer_mutex); INIT_DELAYED_WORK(&wcd_spi->clk_dwork, wcd_spi_clk_work); init_completion(&wcd_spi->resume_comp); - arch_setup_dma_ops(&spi->dev, 0, 0, NULL, true); +#ifdef CONFIG_WCD_SPI_DMA_MASKING + arch_setup_spi_archdata(spi); +#endif + arch_setup_dma_ops(&spi->dev, 0, 0, NULL, true); wcd_spi->spi = spi; spi_set_drvdata(spi, wcd_spi);