linux-stable/drivers/soc
Douglas Anderson 4b6ea87be4 soc: qcom: geni: More properly switch to DMA mode
On geni-i2c transfers using DMA, it was seen that if you program the
command (I2C_READ) before calling geni_se_rx_dma_prep() that it could
cause interrupts to fire.  If we get unlucky, these interrupts can
just keep firing (and not be handled) blocking further progress and
hanging the system.

In commit 02b9aec592 ("i2c: i2c-qcom-geni: Fix DMA transfer race")
we avoided that by making sure we didn't program the command until
after geni_se_rx_dma_prep() was called.  While that avoided the
problems, it also turns out to be invalid.  At least in the TX case we
started seeing sporadic corrupted transfers.  This is easily seen by
adding an msleep() between the DMA prep and the writing of the
command, which makes the problem worse.  That means we need to revert
that commit and find another way to fix the bogus IRQs.

Specifically, after reverting commit 02b9aec592 ("i2c:
i2c-qcom-geni: Fix DMA transfer race"), I put some traces in.  I found
that the when the interrupts were firing like crazy:
- "m_stat" had bits for M_RX_IRQ_EN, M_RX_FIFO_WATERMARK_EN set.
- "dma" was set.

Further debugging showed that I could make the problem happen more
reliably by adding an "msleep(1)" any time after geni_se_setup_m_cmd()
ran up until geni_se_rx_dma_prep() programmed the length.

A rather simple fix is to change geni_se_select_dma_mode() so it's a
true inverse of geni_se_select_fifo_mode() and disables all the FIFO
related interrupts.  Now the problematic interrupts can't fire and we
can program things in the correct order without worrying.

As part of this, let's also change the writel_relaxed() in the prepare
function to a writel() so that our DMA is guaranteed to be prepared
now that we can't rely on geni_se_setup_m_cmd()'s writel().

NOTE: the only current user of GENI_SE_DMA in mainline is i2c.

Fixes: 37692de5d5 ("i2c: i2c-qcom-geni: Add bus driver for the Qualcomm GENI I2C controller")
Fixes: 02b9aec592 ("i2c: i2c-qcom-geni: Fix DMA transfer race")
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Akash Asthana <akashast@codeaurora.org>
Tested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20201013142448.v2.1.Ifdb1b69fa3367b81118e16e9e4e63299980ca798@changeid
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-10-26 10:29:12 -05:00
..
actions soc: actions: include header to fix missing prototype 2020-09-22 12:45:16 +05:30
amlogic soc: amlogic: pm-domains: use always-on flag 2020-09-24 09:50:01 -07:00
aspeed treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
atmel
bcm soc: bcm: brcmstb: biuctrl: Change RAC data line prefetching after 4 consecutive lines 2020-09-06 12:43:02 -07:00
dove
fsl soc: fsl: qe: Remove unnessesary check in ucc_set_tdm_rxtx_clk 2020-09-22 18:25:29 -05:00
gemini
imx soc: imx: gpcv2: Use dev_err_probe() to simplify error handling 2020-08-22 20:57:57 +08:00
ixp4xx
kendryte riscv: K210: Add a built-in device tree 2020-05-18 11:38:06 -07:00
lantiq soc: lantiq: convert to devm_platform_ioremap_resource 2020-01-10 11:44:52 -08:00
mediatek soc: mediatek: cmdq: add clear option in cmdq_pkt_wfe api 2020-09-25 17:27:39 +02:00
qcom soc: qcom: geni: More properly switch to DMA mode 2020-10-26 10:29:12 -05:00
renesas soc: renesas: r8a779a0-sysc: Add r8a779a0 support 2020-09-16 08:57:31 +02:00
rockchip PM: AVS: rockchip-io: Move the driver to the rockchip specific drivers 2020-10-16 18:23:15 +02:00
samsung ARM: SoC platform updates 2020-10-24 10:33:08 -07:00
sifive soc: sifive: l2 cache: Mark l2_get_priv_group as static 2020-05-28 15:57:49 -07:00
sunxi soc: sunxi: sram: remove unneeded semicolon 2020-09-11 17:02:39 +02:00
tegra ARM: Devicetree updates 2020-10-24 10:44:18 -07:00
ti ARM: SoC-related driver updates 2020-10-24 10:39:22 -07:00
ux500 soc: ux500: Use custom soc attribute group instead of device_create_file 2020-07-06 09:48:06 +01:00
versatile soc: integrator: Drop pointless static qualifier in integrator_soc_init() 2020-08-20 08:57:05 +02:00
xilinx soc: xilinx: Fix error code in zynqmp_pm_probe() 2020-06-18 10:07:17 +02:00
zte
Kconfig riscv: Add Kendryte K210 SoC support 2020-04-03 10:49:52 -07:00
Makefile RISC-V Patches for the 5.7 Merge Window, Part 1 2020-04-09 10:51:30 -07:00