memory: tegra: Check whether reset is already asserted
authorDmitry Osipenko <digetx@gmail.com>
Tue, 19 Jan 2021 23:52:10 +0000 (02:52 +0300)
committerKrzysztof Kozlowski <krzk@kernel.org>
Fri, 22 Jan 2021 23:10:40 +0000 (00:10 +0100)
Check whether memory client reset is already asserted in order to prevent
DMA-flush error on trying to re-assert an already asserted reset.

This becomes a problem once PMC GENPD is enabled to use memory resets
since GENPD will get a error and fail to toggle power domain. PMC GENPDs
can't be toggled safely without holding memory reset on Tegra and we're
about to fix this.

Tested-by: Peter Geis <pgwipeout@gmail.com> # Ouya T30
Tested-by: Nicolas Chauvet <kwizart@gmail.com> # PAZ00 T20
Tested-by: Matt Merhar <mattmerhar@protonmail.com> # Ouya T30
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20210119235210.13006-1-digetx@gmail.com
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
drivers/memory/tegra/mc.c

index 44064de..a21163c 100644 (file)
@@ -176,6 +176,13 @@ static int tegra_mc_hotreset_assert(struct reset_controller_dev *rcdev,
        if (!rst_ops)
                return -ENODEV;
 
+       /* DMA flushing will fail if reset is already asserted */
+       if (rst_ops->reset_status) {
+               /* check whether reset is asserted */
+               if (rst_ops->reset_status(mc, rst))
+                       return 0;
+       }
+
        if (rst_ops->block_dma) {
                /* block clients DMA requests */
                err = rst_ops->block_dma(mc, rst);