summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Hunter <jonathanh@nvidia.com>2019-05-16 11:53:52 -0400
committerVinod Koul <vkoul@kernel.org>2019-05-21 04:56:00 -0400
commitb53611fb1ce9b1786bd18205473e0c1d6bfa8934 (patch)
treea8c3729dcdb86846970758f3fd1bc9ede5779b81
parent069b3c4214f27b130d0642f32438560db30f452e (diff)
dmaengine: tegra210-adma: Fix crash during probe
Commit f33e7bb3eb92 ("dmaengine: tegra210-adma: restore channel status") added support to save and restore the DMA channel registers when runtime suspending the ADMA. This change is causing the kernel to crash when probing the ADMA, if the device is probed deferred when looking up the channel interrupts. The crash occurs because not all of the channel base addresses have been setup at this point and in the clean-up path of the probe, pm_runtime_suspend() is called invoking its callback which expects all the channel base addresses to be initialised. Although this could be fixed by simply checking for a NULL address, on further review of the driver it seems more appropriate that we only call pm_runtime_get_sync() after all the channel interrupts and base addresses have been configured. Therefore, fix this crash by moving the calls to pm_runtime_enable(), pm_runtime_get_sync() and tegra_adma_init() after the DMA channels have been initialised. Fixes: f33e7bb3eb92 ("dmaengine: tegra210-adma: restore channel status") Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Vinod Koul <vkoul@kernel.org>
-rw-r--r--drivers/dma/tegra210-adma.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
index 21f6be16d013..3ec3d71acd25 100644
--- a/drivers/dma/tegra210-adma.c
+++ b/drivers/dma/tegra210-adma.c
@@ -845,16 +845,6 @@ static int tegra_adma_probe(struct platform_device *pdev)
845 return PTR_ERR(tdma->ahub_clk); 845 return PTR_ERR(tdma->ahub_clk);
846 } 846 }
847 847
848 pm_runtime_enable(&pdev->dev);
849
850 ret = pm_runtime_get_sync(&pdev->dev);
851 if (ret < 0)
852 goto rpm_disable;
853
854 ret = tegra_adma_init(tdma);
855 if (ret)
856 goto rpm_put;
857
858 INIT_LIST_HEAD(&tdma->dma_dev.channels); 848 INIT_LIST_HEAD(&tdma->dma_dev.channels);
859 for (i = 0; i < tdma->nr_channels; i++) { 849 for (i = 0; i < tdma->nr_channels; i++) {
860 struct tegra_adma_chan *tdc = &tdma->channels[i]; 850 struct tegra_adma_chan *tdc = &tdma->channels[i];
@@ -873,6 +863,16 @@ static int tegra_adma_probe(struct platform_device *pdev)
873 tdc->tdma = tdma; 863 tdc->tdma = tdma;
874 } 864 }
875 865
866 pm_runtime_enable(&pdev->dev);
867
868 ret = pm_runtime_get_sync(&pdev->dev);
869 if (ret < 0)
870 goto rpm_disable;
871
872 ret = tegra_adma_init(tdma);
873 if (ret)
874 goto rpm_put;
875
876 dma_cap_set(DMA_SLAVE, tdma->dma_dev.cap_mask); 876 dma_cap_set(DMA_SLAVE, tdma->dma_dev.cap_mask);
877 dma_cap_set(DMA_PRIVATE, tdma->dma_dev.cap_mask); 877 dma_cap_set(DMA_PRIVATE, tdma->dma_dev.cap_mask);
878 dma_cap_set(DMA_CYCLIC, tdma->dma_dev.cap_mask); 878 dma_cap_set(DMA_CYCLIC, tdma->dma_dev.cap_mask);
@@ -916,13 +916,13 @@ static int tegra_adma_probe(struct platform_device *pdev)
916 916
917dma_remove: 917dma_remove:
918 dma_async_device_unregister(&tdma->dma_dev); 918 dma_async_device_unregister(&tdma->dma_dev);
919irq_dispose:
920 while (--i >= 0)
921 irq_dispose_mapping(tdma->channels[i].irq);
922rpm_put: 919rpm_put:
923 pm_runtime_put_sync(&pdev->dev); 920 pm_runtime_put_sync(&pdev->dev);
924rpm_disable: 921rpm_disable:
925 pm_runtime_disable(&pdev->dev); 922 pm_runtime_disable(&pdev->dev);
923irq_dispose:
924 while (--i >= 0)
925 irq_dispose_mapping(tdma->channels[i].irq);
926 926
927 return ret; 927 return ret;
928} 928}