[PATCH v2] spi: spi-geni-qcom: enable SPI_CONTROLLER_MUST_TX for GPI DMA mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The GPI DMA mode requires for TX DMA to be prepared. Force SPI core to
provide TX buffer even if the caller didn't provide one by setting the
SPI_CONTROLLER_MUST_TX flag.

This fixes the following oops:

Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010
[....]
Call trace:
 gpi_prep_slave_sg+0x3a4/0x5a8
 spi_geni_transfer_one+0x190/0x558
 spi_transfer_one_message+0x424/0x800
 __spi_pump_transfer_message+0x248/0x670
 __spi_sync+0x2cc/0x3a8
 spi_sync+0x3c/0x68
 spidev_sync_read+0xb0/0x108
 spidev_read+0x54/0x110
 vfs_read+0xc8/0x270
 ksys_read+0xec/0x110
 __arm64_sys_read+0x24/0x38
 invoke_syscall+0x50/0x128
 el0_svc_common.constprop.0+0xd4/0x100
 do_el0_svc+0x40/0xa8
 el0_svc+0x34/0x108
 el0t_64_sync_handler+0xf4/0x120
 el0t_64_sync+0x190/0x198
Code: 94079d2b 17ffff94 a90573fb f940a660 (f9400b06)

Fixes: b59c122484ec ("spi: spi-geni-qcom: Add support for GPI dma")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx>
---

Changes from v1:
- Trimmed the backtrace to include only the relevant information

---
 drivers/spi/spi-geni-qcom.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
index b293428760bc..631c17e629dd 100644
--- a/drivers/spi/spi-geni-qcom.c
+++ b/drivers/spi/spi-geni-qcom.c
@@ -1100,6 +1100,12 @@ static int spi_geni_probe(struct platform_device *pdev)
 	if (mas->cur_xfer_mode == GENI_SE_FIFO)
 		spi->set_cs = spi_geni_set_cs;
 
+	/*
+	 * TX is required per GSI spec, see setup_gsi_xfer().
+	 */
+	if (mas->cur_xfer_mode == GENI_GPI_DMA)
+		spi->flags = SPI_CONTROLLER_MUST_TX;
+
 	ret = request_irq(mas->irq, geni_spi_isr, 0, dev_name(dev), spi);
 	if (ret)
 		goto spi_geni_release_dma;
-- 
2.40.1




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux