aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Whitten <ben.whitten@gmail.com>2016-11-14 10:13:20 -0500
committerMark Brown <broonie@kernel.org>2016-11-15 13:51:35 -0500
commit39fe33f98b64501f5816f743c052215e7f66700b (patch)
treee936993c3f9cfa8719453b554154b70a6a4c1924
parent9610620078a3900e7fad82de620ce809fd29ba60 (diff)
spi: atmel: Fix scheduling while atomic
A call to clk_get_rate appears to be called in the context of an interrupt, cache the bus clock for the frequency calculations in transmission. This fixes a 'BUG: scheduling while atomic' and 'WARNING: CPU: 0 PID: 777 at kernel/sched/core.c:2960 atmel_spi_unlock' Signed-off-by: Ben Whitten <ben.whitten@lairdtech.com> Signed-off-by: Steve deRosier <steve.derosier@lairdtech.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/spi/spi-atmel.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index d3affa6afe7e..9fb00ac3ac2e 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -296,6 +296,7 @@ struct atmel_spi {
296 int irq; 296 int irq;
297 struct clk *clk; 297 struct clk *clk;
298 struct platform_device *pdev; 298 struct platform_device *pdev;
299 unsigned long spi_clk;
299 300
300 struct spi_transfer *current_transfer; 301 struct spi_transfer *current_transfer;
301 int current_remaining_bytes; 302 int current_remaining_bytes;
@@ -865,7 +866,7 @@ static int atmel_spi_set_xfer_speed(struct atmel_spi *as,
865 unsigned long bus_hz; 866 unsigned long bus_hz;
866 867
867 /* v1 chips start out at half the peripheral bus speed. */ 868 /* v1 chips start out at half the peripheral bus speed. */
868 bus_hz = clk_get_rate(as->clk); 869 bus_hz = as->spi_clk;
869 if (!atmel_spi_is_v2(as)) 870 if (!atmel_spi_is_v2(as))
870 bus_hz /= 2; 871 bus_hz /= 2;
871 872
@@ -1634,6 +1635,9 @@ static int atmel_spi_probe(struct platform_device *pdev)
1634 ret = clk_prepare_enable(clk); 1635 ret = clk_prepare_enable(clk);
1635 if (ret) 1636 if (ret)
1636 goto out_free_irq; 1637 goto out_free_irq;
1638
1639 as->spi_clk = clk_get_rate(clk);
1640
1637 spi_writel(as, CR, SPI_BIT(SWRST)); 1641 spi_writel(as, CR, SPI_BIT(SWRST));
1638 spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */ 1642 spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
1639 if (as->caps.has_wdrbt) { 1643 if (as->caps.has_wdrbt) {