spi: dw: Disable clock after unregistering the host
authorMarek Vasut <marex@denx.de>
Tue, 18 Apr 2017 18:09:06 +0000 (20:09 +0200)
committerMark Brown <broonie@kernel.org>
Tue, 18 Apr 2017 18:16:49 +0000 (19:16 +0100)
The dw_mmio driver disables the block clock before unregistering
the host. The code unregistering the host may access the SPI block
registers. If register access happens with block clock disabled,
this may lead to a bus hang. Disable the clock after unregistering
the host to prevent such situation.

This bug was observed on Altera Cyclone V SoC.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-dw-mmio.c

index 447497e9124c922a4e3ecc20af8ab7ee91062e99..d25cc4037e239d0df386a06253049dd25a79b2b2 100644 (file)
@@ -115,8 +115,8 @@ static int dw_spi_mmio_remove(struct platform_device *pdev)
 {
        struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev);
 
-       clk_disable_unprepare(dwsmmio->clk);
        dw_spi_remove_host(&dwsmmio->dws);
+       clk_disable_unprepare(dwsmmio->clk);
 
        return 0;
 }