linux-stable/drivers/spi
wuxu.wu b56f2a4a43 spi: spi-dw: Add lock protect dw_spi rx/tx to prevent concurrent calls
[ Upstream commit 19b61392c5 ]

dw_spi_irq() and dw_spi_transfer_one concurrent calls.

I find a panic in dw_writer(): txw = *(u8 *)(dws->tx), when dw->tx==null,
dw->len==4, and dw->tx_end==1.

When tpm driver's message overtime dw_spi_irq() and dw_spi_transfer_one
may concurrent visit dw_spi, so I think dw_spi structure lack of protection.

Otherwise dw_spi_transfer_one set dw rx/tx buffer and then open irq,
store dw rx/tx instructions and other cores handle irq load dw rx/tx
instructions may out of order.

	[ 1025.321302] Call trace:
	...
	[ 1025.321319]  __crash_kexec+0x98/0x148
	[ 1025.321323]  panic+0x17c/0x314
	[ 1025.321329]  die+0x29c/0x2e8
	[ 1025.321334]  die_kernel_fault+0x68/0x78
	[ 1025.321337]  __do_kernel_fault+0x90/0xb0
	[ 1025.321346]  do_page_fault+0x88/0x500
	[ 1025.321347]  do_translation_fault+0xa8/0xb8
	[ 1025.321349]  do_mem_abort+0x68/0x118
	[ 1025.321351]  el1_da+0x20/0x8c
	[ 1025.321362]  dw_writer+0xc8/0xd0
	[ 1025.321364]  interrupt_transfer+0x60/0x110
	[ 1025.321365]  dw_spi_irq+0x48/0x70
	...

Signed-off-by: wuxu.wu <wuxu.wu@huawei.com>
Link: https://lore.kernel.org/r/1577849981-31489-1-git-send-email-wuxu.wu@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-02-05 14:18:06 +00:00
..
Kconfig Merge remote-tracking branches 'spi/topic/pxa', 'spi/topic/pxa2xx', 'spi/topic/qup', 'spi/topic/rockchip' and 'spi/topic/sh' into spi-next 2017-09-04 15:51:26 +01:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
spi-adi-v3.c
spi-altera.c spi: altera: Consolidate TX/RX data register access 2017-08-16 11:53:31 +01:00
spi-armada-3700.c spi: a3700: Clear DATA_OUT when performing a read 2018-04-26 11:02:07 +02:00
spi-ath79.c
spi-atmel.c spi: atmel: fix handling of cs_change set on non-last xfer 2020-01-17 19:45:52 +01:00
spi-au1550.c
spi-axi-spi-engine.c spi: spi-axi: fix potential use-after-free after deregistration 2017-12-10 13:40:39 +01:00
spi-bcm-qspi.c spi: bcm-qspi: switch back to reading flash using smaller chunks 2018-11-13 11:14:45 -08:00
spi-bcm-qspi.h
spi-bcm53xx.c
spi-bcm53xx.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
spi-bcm63xx-hsspi.c Merge remote-tracking branches 'spi/topic/altera', 'spi/topic/at79', 'spi/topic/bcm-qspi', 'spi/topic/bcm63xx' and 'spi/topic/bcm63xx-hspi' into spi-next 2017-09-04 15:51:14 +01:00
spi-bcm63xx.c
spi-bcm2835.c spi: bcm2835: Fix 3-wire mode if DMA is enabled 2019-08-09 17:53:37 +02:00
spi-bcm2835aux.c spi: bcm2835aux: fix driver to not allow 65535 (=-1) cs-gpios 2020-01-27 14:46:28 +01:00
spi-bfin-sport.c
spi-bfin5xx.c
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 spi: bitbang: Fix NULL pointer dereference in spi_unregister_master 2019-07-10 09:54:31 +02:00
spi-brcmstb-qspi.c
spi-butterfly.c
spi-cadence.c spi: cadence: Correct initialisation of runtime PM 2020-01-27 14:46:12 +01:00
spi-cavium-octeon.c
spi-cavium-thunderx.c spi: spi-cavium-thunderx: Add missing pci_release_regions() 2020-01-12 12:11:53 +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-coldfire-qspi.c
spi-davinci.c spi: davinci: fix a NULL pointer dereference 2018-09-09 19:55:52 +02:00
spi-dln2.c
spi-dw-mid.c
spi-dw-mmio.c
spi-dw-pci.c
spi-dw.c spi: spi-dw: Add lock protect dw_spi rx/tx to prevent concurrent calls 2020-02-05 14:18:06 +00:00
spi-dw.h spi: spi-dw: Add lock protect dw_spi rx/tx to prevent concurrent calls 2020-02-05 14:18:06 +00:00
spi-efm32.c
spi-ep93xx.c spi: spi-ep93xx: Use dma_data_direction for ep93xx_spi_dma_{finish,prepare} 2018-11-13 11:14:52 -08:00
spi-falcon.c spi: spi-falcon: drop check of boot select 2017-09-01 11:33:22 +01:00
spi-fsl-cpm.c
spi-fsl-cpm.h
spi-fsl-dspi.c spi: spi-fsl-dspi: Fix imprecise abort on VF500 during probe 2018-09-09 19:55:53 +02:00
spi-fsl-espi.c
spi-fsl-lib.c
spi-fsl-lib.h
spi-fsl-lpspi.c spi: fsl-lpspi: Prevent FIFO under/overrun by default 2019-11-24 08:23:28 +01:00
spi-fsl-spi.c spi: spi-fsl-spi: call spi_finalize_current_message() at the end 2020-01-27 14:46:35 +01:00
spi-fsl-spi.h
spi-gpio.c
spi-img-spfi.c spi: img-spfi: fix potential double release 2019-12-31 12:37:22 +01:00
spi-imx.c spi: imx: mx51-ecspi: Move some initialisation to prepare_message hook. 2018-12-29 13:39:11 +01:00
spi-iproc-qspi.c
spi-jcore.c
spi-lantiq-ssc.c
spi-lm70llp.c
spi-loopback-test.c
spi-lp8841-rtc.c
spi-meson-spicc.c spi: meson-spicc: Fix error handling in meson_spicc_probe() 2018-08-03 07:50:38 +02:00
spi-meson-spifc.c
spi-mpc52xx-psc.c
spi-mpc52xx.c
spi-mpc512x-psc.c
spi-mt65xx.c spi: mediatek: use correct mata->xfer_len when in fifo transfer 2019-11-24 08:22:43 +01:00
spi-mxs.c
spi-nuc900.c
spi-oc-tiny.c
spi-omap-100k.c
spi-omap-uwire.c
spi-omap2-mcspi.c spi: omap2-mcspi: Fix DMA and FIFO event trigger size mismatch 2019-12-01 09:14:14 +01:00
spi-orion.c
spi-pic32-sqi.c
spi-pic32.c spi: pic32: Use proper enum in dmaengine_prep_slave_rg 2019-11-20 18:00:22 +01:00
spi-pl022.c spi: pl022: constify amba_id 2017-08-23 17:12:05 +01:00
spi-ppc4xx.c
spi-pxa2xx-dma.c
spi-pxa2xx-pci.c
spi-pxa2xx.c spi: pxa2xx: Add missed security checks 2019-12-31 12:37:37 +01:00
spi-pxa2xx.h spi: pxa2xx: Allow 64-bit DMA 2018-05-22 18:53:56 +02:00
spi-qup.c spi: qup: fix 64-bit build warning 2017-08-10 15:50:23 +01:00
spi-rb4xx.c
spi-rockchip.c spi: rockchip: initialize dma_slave_config properly 2019-11-24 08:23:33 +01:00
spi-rspi.c spi: rspi: Fix sequencer reset during initialization 2019-05-31 06:47:35 -07:00
spi-s3c24xx-fiq.h
spi-s3c24xx-fiq.S
spi-s3c24xx.c
spi-s3c64xx.c spi: spi-s3c64xx: Fix system resume support 2018-08-03 07:50:20 +02:00
spi-sc18is602.c
spi-sh-hspi.c
spi-sh-msiof.c spi: sh-msiof: fix deferred probing 2019-12-01 09:13:21 +01:00
spi-sh-sci.c
spi-sh.c spi: spi-sh: fix error return code in spi_sh_probe() 2017-08-09 17:18:06 +01:00
spi-sirf.c
spi-slave-system-control.c
spi-slave-time.c
spi-st-ssc4.c spi: st-ssc4: add missed pm_runtime_disable 2019-12-31 12:37:45 +01:00
spi-stm32.c spi: stm32: Fix logical error in stm32_spi_prepare_mbr() 2017-09-13 09:42:27 -07:00
spi-sun4i.c spi: sun4i: disable clocks in the remove function 2018-02-25 11:08:02 +01:00
spi-sun6i.c spi: sun6i: disable/unprepare clocks on remove 2018-03-19 08:42:53 +01:00
spi-tegra20-sflash.c
spi-tegra20-slink.c spi: tegra20-slink: add missed clk_unprepare 2019-12-31 12:37:42 +01:00
spi-tegra114.c spi: tegra114: configure dma burst size to fifo trig level 2020-01-27 14:46:28 +01:00
spi-test.h
spi-ti-qspi.c spi: ti-qspi: Fix mmap read when more than one CS in use 2019-03-23 14:35:19 +01:00
spi-tle62x0.c
spi-topcliff-pch.c spi/topcliff_pch: Fix potential NULL dereference on allocation error 2020-01-27 14:46:14 +01:00
spi-txx9.c
spi-xcomm.c
spi-xilinx.c spi: xilinx: Detect stall with Unknown commands 2017-12-29 17:53:47 +01:00
spi-xlp.c
spi-xtensa-xtfpga.c
spi-zynqmp-gqspi.c
spi.c spi: Fix zero length xfer bug 2019-05-31 06:47:35 -07:00
spidev.c spi: Add call to spi_slave_abort() function when spidev driver is released 2019-12-31 12:36:47 +01:00