1
0
Fork 0
alistair23-linux/drivers/spi
Vladimir Oltean b9da72cb70 spi: spi-fsl-dspi: Replace interruptible wait queue with a simple completion
[ Upstream commit 4f5ee75ea1 ]

Currently the driver puts the process in interruptible sleep waiting for
the interrupt train to finish transfer to/from the tx_buf and rx_buf.

But exiting the process with ctrl-c may make the kernel panic: the
wait_event_interruptible call will return -ERESTARTSYS, which a proper
driver implementation is perhaps supposed to handle, but nonetheless
this one doesn't, and aborts the transfer altogether.

Actually when the task is interrupted, there is still a high chance that
the dspi_interrupt is still triggering. And if dspi_transfer_one_message
returns execution all the way to the spi_device driver, that can free
the spi_message and spi_transfer structures, leaving the interrupts to
access a freed tx_buf and rx_buf.

hexdump -C /dev/mtd0
00000000  00 75 68 75 0a ff ff ff  ff ff ff ff ff ff ff ff
|.uhu............|
00000010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
|................|
*
^C[   38.495955] fsl-dspi 2120000.spi: Waiting for transfer to complete failed!
[   38.503097] spi_master spi2: failed to transfer one message from queue
[   38.509729] Unable to handle kernel paging request at virtual address ffff800095ab3377
[   38.517676] Mem abort info:
[   38.520474]   ESR = 0x96000045
[   38.523533]   EC = 0x25: DABT (current EL), IL = 32 bits
[   38.528861]   SET = 0, FnV = 0
[   38.531921]   EA = 0, S1PTW = 0
[   38.535067] Data abort info:
[   38.537952]   ISV = 0, ISS = 0x00000045
[   38.541797]   CM = 0, WnR = 1
[   38.544771] swapper pgtable: 4k pages, 48-bit VAs, pgdp=0000000082621000
[   38.551494] [ffff800095ab3377] pgd=00000020fffff003, p4d=00000020fffff003, pud=0000000000000000
[   38.560229] Internal error: Oops: 96000045 [#1] PREEMPT SMP
[   38.565819] Modules linked in:
[   38.568882] CPU: 0 PID: 2729 Comm: hexdump Not tainted 5.6.0-rc4-next-20200306-00052-gd8730cdc8a0b-dirty #193
[   38.578834] Hardware name: Kontron SMARC-sAL28 (Single PHY) on SMARC Eval 2.0 carrier (DT)
[   38.587129] pstate: 20000085 (nzCv daIf -PAN -UAO)
[   38.591941] pc : ktime_get_real_ts64+0x3c/0x110
[   38.596487] lr : spi_take_timestamp_pre+0x40/0x90
[   38.601203] sp : ffff800010003d90
[   38.604525] x29: ffff800010003d90 x28: ffff80001200e000
[   38.609854] x27: ffff800011da9000 x26: ffff002079c40400
[   38.615184] x25: ffff8000117fe018 x24: ffff800011daa1a0
[   38.620513] x23: ffff800015ab3860 x22: ffff800095ab3377
[   38.625841] x21: 000000000000146e x20: ffff8000120c3000
[   38.631170] x19: ffff0020795f6e80 x18: ffff800011da9948
[   38.636498] x17: 0000000000000000 x16: 0000000000000000
[   38.641826] x15: ffff800095ab3377 x14: 0720072007200720
[   38.647155] x13: 0720072007200765 x12: 0775076507750771
[   38.652483] x11: 0720076d076f0772 x10: 0000000000000040
[   38.657812] x9 : ffff8000108e2100 x8 : ffff800011dcabe8
[   38.663139] x7 : 0000000000000000 x6 : ffff800015ab3a60
[   38.668468] x5 : 0000000007200720 x4 : ffff800095ab3377
[   38.673796] x3 : 0000000000000000 x2 : 0000000000000ab0
[   38.679125] x1 : ffff800011daa000 x0 : 0000000000000026
[   38.684454] Call trace:
[   38.686905]  ktime_get_real_ts64+0x3c/0x110
[   38.691100]  spi_take_timestamp_pre+0x40/0x90
[   38.695470]  dspi_fifo_write+0x58/0x2c0
[   38.699315]  dspi_interrupt+0xbc/0xd0
[   38.702987]  __handle_irq_event_percpu+0x78/0x2c0
[   38.707706]  handle_irq_event_percpu+0x3c/0x90
[   38.712161]  handle_irq_event+0x4c/0xd0
[   38.716008]  handle_fasteoi_irq+0xbc/0x170
[   38.720115]  generic_handle_irq+0x2c/0x40
[   38.724135]  __handle_domain_irq+0x68/0xc0
[   38.728243]  gic_handle_irq+0xc8/0x160
[   38.732000]  el1_irq+0xb8/0x180
[   38.735149]  spi_nor_spimem_read_data+0xe0/0x140
[   38.739779]  spi_nor_read+0xc4/0x120
[   38.743364]  mtd_read_oob+0xa8/0xc0
[   38.746860]  mtd_read+0x4c/0x80
[   38.750007]  mtdchar_read+0x108/0x2a0
[   38.753679]  __vfs_read+0x20/0x50
[   38.757002]  vfs_read+0xa4/0x190
[   38.760237]  ksys_read+0x6c/0xf0
[   38.763471]  __arm64_sys_read+0x20/0x30
[   38.767319]  el0_svc_common.constprop.3+0x90/0x160
[   38.772125]  do_el0_svc+0x28/0x90
[   38.775449]  el0_sync_handler+0x118/0x190
[   38.779468]  el0_sync+0x140/0x180
[   38.782793] Code: 91000294 1400000f d50339bf f9405e80 (f90002c0)
[   38.788910] ---[ end trace 55da560db4d6bef7 ]---
[   38.793540] Kernel panic - not syncing: Fatal exception in interrupt
[   38.799914] SMP: stopping secondary CPUs
[   38.803849] Kernel Offset: disabled
[   38.807344] CPU features: 0x10002,20006008
[   38.811451] Memory Limit: none
[   38.814513] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---

So it is clear that the "interruptible" part isn't handled correctly.
When the process receives a signal, one could either attempt a clean
abort (which appears to be difficult with this hardware) or just keep
restarting the sleep until the wait queue really completes. But checking
in a loop for -ERESTARTSYS is a bit too complicated for this driver, so
just make the sleep uninterruptible, to avoid all that nonsense.

The wait queue was actually restructured as a completion, after polling
other drivers for the most "popular" approach.

Fixes: 349ad66c0a ("spi:Add Freescale DSPI driver for Vybrid VF610 platform")
Reported-by: Michael Walle <michael@walle.cc>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Michael Walle <michael@walle.cc>
Link: https://lore.kernel.org/r/20200318001603.9650-7-olteanv@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-04-17 10:50:05 +02:00
..
Kconfig It's a somewhat calmer cycle for docs this time, as the churn of the mass 2019-09-17 16:22:26 -07:00
Makefile ARM: SoC driver updates for v5.4 2019-09-16 15:52:38 -07:00
atmel-quadspi.c spi: atmel-quadspi: fix possible MMIO window size overrun 2020-03-12 13:00:26 +01:00
internals.h spi: Add an helper to flush the message queue 2018-04-23 15:48:18 +01:00
spi-altera.c spi: altera: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:14:50 +01:00
spi-armada-3700.c spi: a3700: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:15:09 +01:00
spi-at91-usart.c spi: at91-usart: add DMA support 2019-05-08 17:45:26 +09:00
spi-ath79.c spi: ath79: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:15:29 +01:00
spi-atmel.c spi: atmel: fix handling of cs_change set on non-last xfer 2020-01-17 19:49:01 +01:00
spi-au1550.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
spi-axi-spi-engine.c spi: spi-axi: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:15:49 +01:00
spi-bcm-qspi.c Merge branch 'spi-5.3' into spi-linus 2019-09-15 10:32:04 +01:00
spi-bcm-qspi.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 459 2019-06-19 17:09:09 +02:00
spi-bcm63xx-hsspi.c spi: bcm63xx-hsspi: Really keep pll clk enabled 2020-03-12 13:00:24 +01:00
spi-bcm63xx.c spi: Remove dev_err() usage after platform_get_irq() 2019-08-02 12:15:43 +01:00
spi-bcm2835.c Merge branch 'spi-5.4' into spi-next 2019-09-15 10:32:06 +01:00
spi-bcm2835aux.c spi: bcm2835aux: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:16:08 +01:00
spi-bitbang-txrx.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
spi-bitbang.c Linux 5.2-rc4 2019-06-10 18:52:53 +01:00
spi-brcmstb-qspi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 459 2019-06-19 17:09:09 +02:00
spi-butterfly.c spi: docs: convert to ReST and add it to the kABI bookset 2019-07-31 14:13:13 -06:00
spi-cadence.c spi: cadence: Correct handling of native chipselect 2019-12-31 16:45:59 +01:00
spi-cavium-octeon.c spi: octeon: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:17:27 +01:00
spi-cavium-thunderx.c spi: spi-cavium-thunderx: Add missing pci_release_regions() 2020-01-12 12:21:20 +01:00
spi-cavium.c
spi-cavium.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
spi-clps711x.c spi: clps711x: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:17:36 +01:00
spi-coldfire-qspi.c spi: coldfire-qspi: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:17:56 +01:00
spi-davinci.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
spi-dln2.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 372 2019-06-05 17:37:10 +02:00
spi-dw-mid.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
spi-dw-mmio.c spi: dw-mmio: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:18:05 +01:00
spi-dw-pci.c Merge branch 'spi-5.4' into spi-next 2019-09-15 10:32:06 +01:00
spi-dw.c spi: spi-dw: Add lock protect dw_spi rx/tx to prevent concurrent calls 2020-02-01 09:34:44 +00:00
spi-dw.h spi: spi-dw: Add lock protect dw_spi rx/tx to prevent concurrent calls 2020-02-01 09:34:44 +00:00
spi-efm32.c spi: Remove dev_err() usage after platform_get_irq() 2019-08-02 12:15:43 +01:00
spi-ep93xx.c spi: Remove dev_err() usage after platform_get_irq() 2019-08-02 12:15:43 +01:00
spi-falcon.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
spi-fsl-cpm.c spi: fsl-spi: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:24:26 +01:00
spi-fsl-cpm.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
spi-fsl-dspi.c spi: spi-fsl-dspi: Replace interruptible wait queue with a simple completion 2020-04-17 10:50:05 +02:00
spi-fsl-espi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
spi-fsl-lib.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
spi-fsl-lib.h spi: fsl: Convert to use CS GPIO descriptors 2019-08-28 14:10:41 +01:00
spi-fsl-lpspi.c spi: fsl-lpspi: fix only one cs-gpio working 2020-02-24 08:36:28 +01:00
spi-fsl-qspi.c spi: spi-fsl-qspi: Ensure width is respected in spi-mem operations 2020-02-24 08:36:54 +01:00
spi-fsl-spi.c spi: fsl: Handle the single hardwired chipselect case 2020-01-12 12:21:13 +01:00
spi-fsl-spi.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
spi-geni-qcom.c spi: spi-geni-qcom: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:18:25 +01:00
spi-gpio.c spi: gpio: prevent memory leak in spi_gpio_probe 2019-12-31 16:43:16 +01:00
spi-img-spfi.c spi: img-spfi: fix potential double release 2019-12-31 16:44:46 +01:00
spi-imx.c Merge branch 'spi-5.1' into spi-5.2 for stm32 2019-03-15 17:06:34 +00:00
spi-iproc-qspi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174 2019-05-30 11:26:41 -07:00
spi-jcore.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
spi-lantiq-ssc.c spi: Remove dev_err() usage after platform_get_irq() 2019-08-02 12:15:43 +01:00
spi-lm70llp.c spi: docs: convert to ReST and add it to the kABI bookset 2019-07-31 14:13:13 -06:00
spi-loopback-test.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
spi-lp8841-rtc.c spi: lp-8841: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:18:35 +01:00
spi-mem.c spi-mem: fix kernel-doc for spi_mem_dirmap_{read|write}() 2019-04-08 14:06:51 +07:00
spi-meson-spicc.c spi: meson-spicc: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:18:55 +01:00
spi-meson-spifc.c spi: spi-meson-spifc: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:19:14 +01:00
spi-mpc52xx-psc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
spi-mpc52xx.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 428 2019-06-05 17:37:16 +02:00
spi-mpc512x-psc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
spi-mt65xx.c spi: mediatek: support large PA 2019-09-13 10:41:10 +01:00
spi-mt7621.c spi: mt7621: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:19:34 +01:00
spi-mxic.c spi: mxic: simplify getting .driver_data 2019-03-20 17:20:29 +00:00
spi-mxs.c spi: mxs: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:19:54 +01:00
spi-npcm-fiu.c spi: npcm-fiu: remove set but not used variable 'retlen' 2019-09-05 18:19:45 +01:00
spi-npcm-pspi.c spi: npcm: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:20:03 +01:00
spi-nxp-fspi.c spi: nxp-fspi: Ensure width is respected in spi-mem operations 2020-01-12 12:21:34 +01:00
spi-oc-tiny.c spi: oc-tiny: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:20:33 +01:00
spi-omap-100k.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
spi-omap-uwire.c
spi-omap2-mcspi.c spi: spi-omap2-mcspi: Support probe deferral for DMA channels 2020-03-25 08:25:41 +01:00
spi-orion.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
spi-pic32-sqi.c spi: pic32-sqi: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:20:52 +01:00
spi-pic32.c spi: Remove dev_err() usage after platform_get_irq() 2019-08-02 12:15:43 +01:00
spi-pl022.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
spi-ppc4xx.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
spi-pxa2xx-dma.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
spi-pxa2xx-pci.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
spi-pxa2xx.c spi: pxa2xx: Add CS control clock quirk 2020-03-25 08:25:44 +01:00
spi-pxa2xx.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
spi-qcom-qspi.c spi: spi-qcom-qspi: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:21:12 +01:00
spi-qup.c spi: qup: call spi_qup_pm_resume_runtime before suspending 2020-03-25 08:25:42 +01:00
spi-rb4xx.c spi: rb4xx: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:21:21 +01:00
spi-rockchip.c Linux 5.2-rc4 2019-06-10 18:52:53 +01:00
spi-rspi.c spi: rspi: Use platform_get_irq_byname_optional() for optional irqs 2020-01-17 19:49:01 +01:00
spi-s3c24xx-fiq.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
spi-s3c24xx-fiq.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
spi-s3c24xx.c spi: s3c24xx: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:21:31 +01:00
spi-s3c64xx.c spi: spi-s3c64xx: Fix system resume support 2018-05-17 13:27:08 +09:00
spi-sc18is602.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
spi-sh-hspi.c spi: sh-hspi: Replace spi_master by spi_controller 2019-02-08 13:04:19 +00:00
spi-sh-msiof.c spi: sh-msiof: Use devm_platform_ioremap_resource() helper 2019-08-07 14:24:47 +01:00
spi-sh-sci.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
spi-sh.c spi: Remove dev_err() usage after platform_get_irq() 2019-08-02 12:15:43 +01:00
spi-sifive.c spi: sifive: disable clk when probe fails and remove 2019-12-31 16:44:34 +01:00
spi-sirf.c spi: sirf: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:22:00 +01:00
spi-slave-mt27xx.c spi: Remove dev_err() usage after platform_get_irq() 2019-08-02 12:15:43 +01:00
spi-slave-system-control.c spi: slave: Fix missing break in switch 2018-10-03 16:23:10 +01:00
spi-slave-time.c spi: slave: Add SPI slave handler reporting uptime at previous message 2017-05-26 13:12:04 +01:00
spi-sprd-adi.c spi: sprd: adi: Add missing lock protection when rebooting 2019-12-31 16:44:25 +01:00
spi-sprd.c spi: sprd: Fix the incorrect SPI register 2020-01-17 19:49:00 +01:00
spi-st-ssc4.c spi: st-ssc4: add missed pm_runtime_disable 2019-12-31 16:45:37 +01:00
spi-stm32-qspi.c spi: stm32-qspi: Fix kernel oops when unbinding driver 2019-12-13 08:43:13 +01:00
spi-stm32.c spi: stm32: return the get_irq error 2019-05-02 10:38:41 +09:00
spi-sun4i.c spi: sun4i: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:22:29 +01:00
spi-sun6i.c spi: sun6i: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:22:49 +01:00
spi-synquacer.c spi: Remove dev_err() usage after platform_get_irq() 2019-08-02 12:15:43 +01:00
spi-tegra20-sflash.c spi: tegra: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:22:58 +01:00
spi-tegra20-slink.c spi: tegra20-slink: add missed clk_unprepare 2019-12-31 16:45:33 +01:00
spi-tegra114.c Linux 5.2-rc4 2019-06-10 18:52:53 +01:00
spi-test.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
spi-ti-qspi.c spi: spi-ti-qspi: Fix a bug when accessing non default CS 2020-01-12 12:21:25 +01:00
spi-tle62x0.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
spi-topcliff-pch.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 285 2019-06-05 17:36:37 +02:00
spi-txx9.c
spi-uniphier.c spi: uniphier: Fix FIFO threshold 2020-01-09 10:20:04 +01:00
spi-xcomm.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 149 2019-05-30 11:25:18 -07:00
spi-xilinx.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
spi-xlp.c spi: xlp: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:23:28 +01:00
spi-xtensa-xtfpga.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
spi-zynq-qspi.c spi: zynq-qspi: use devm_platform_ioremap_resource() to simplify code 2019-09-04 17:24:07 +01:00
spi-zynqmp-gqspi.c spi/zynqmp: remove entry that causes a cs glitch 2020-03-25 08:25:45 +01:00
spi.c spi: spi_register_controller(): free bus id on error paths 2020-03-25 08:25:48 +01:00
spidev.c spi: spidev: Fix CS polarity if GPIO descriptors are used 2020-03-12 13:00:22 +01:00