linux_dsm_epyc7002/drivers/soc/qcom
Douglas Anderson 614199a8d1 soc: qcom: geni: More properly switch to DMA mode
[ Upstream commit 4b6ea87be44ef34732846fc71e44c41125f0c4fa ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-12-30 11:52:57 +01:00
..
apr.c soc: qcom: apr: Fixup the error displayed on lookup failure 2020-09-15 16:12:59 +00:00
cmd-db.c
cpr.c PM: AVS: qcom-cpr: Move the driver to the qcom specific drivers 2020-10-22 18:38:21 +02:00
Kconfig PM: AVS: qcom-cpr: Move the driver to the qcom specific drivers 2020-10-22 18:38:21 +02:00
kryo-l2-accessors.c
llcc-qcom.c soc: qcom: llcc: use devm_platform_ioremap_resource_byname() 2020-09-17 04:24:49 +00:00
Makefile PM: AVS: qcom-cpr: Move the driver to the qcom specific drivers 2020-10-22 18:38:21 +02:00
mdt_loader.c
ocmem.c
pdr_interface.c Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2020-08-07 21:14:30 -07:00
pdr_internal.h soc: qcom: pdr: Fixup array type of get_domain_list_resp message 2020-09-14 23:53:29 +00:00
qcom_aoss.c
qcom_gsbi.c
qcom-geni-se.c soc: qcom: geni: More properly switch to DMA mode 2020-12-30 11:52:57 +01:00
qmi_encdec.c
qmi_interface.c
rmtfs_mem.c
rpmh-internal.h soc: qcom: rpmh-rsc: Sleep waiting for tcs slots to be free 2020-09-10 16:56:12 +00:00
rpmh-rsc.c soc: qcom: rpmh-rsc: Sleep waiting for tcs slots to be free 2020-09-10 16:56:12 +00:00
rpmh.c
rpmhpd.c
rpmpd.c
smd-rpm.c
smem_state.c
smem.c
smp2p.c
smsm.c
socinfo.c ARM: SoC-related driver updates 2020-10-24 10:39:22 -07:00
trace-rpmh.h
wcnss_ctrl.c