Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ae02519 authored by Shashi Kant Maurya's avatar Shashi Kant Maurya
Browse files

asoc: wcd-spi: Set the dma_mask for spi_device



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: default avatarShashi Kant Maurya <smaury@codeaurora.org>
parent 8cc24b22
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
// 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 <linux/init.h>
@@ -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);