Skip to content

Commit 869e5eb

Browse files
BWhittenalexandrebelloni
authored andcommitted
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>
1 parent 47584c6 commit 869e5eb

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/spi/spi-atmel.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ struct atmel_spi {
296296
int irq;
297297
struct clk *clk;
298298
struct platform_device *pdev;
299+
unsigned long spi_clk;
299300

300301
struct spi_transfer *current_transfer;
301302
int current_remaining_bytes;
@@ -865,7 +866,7 @@ static int atmel_spi_set_xfer_speed(struct atmel_spi *as,
865866
unsigned long bus_hz;
866867

867868
/* v1 chips start out at half the peripheral bus speed. */
868-
bus_hz = clk_get_rate(as->clk);
869+
bus_hz = as->spi_clk;
869870
if (!atmel_spi_is_v2(as))
870871
bus_hz /= 2;
871872

@@ -1634,6 +1635,9 @@ static int atmel_spi_probe(struct platform_device *pdev)
16341635
ret = clk_prepare_enable(clk);
16351636
if (ret)
16361637
goto out_free_irq;
1638+
1639+
as->spi_clk = clk_get_rate(clk);
1640+
16371641
spi_writel(as, CR, SPI_BIT(SWRST));
16381642
spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
16391643
if (as->caps.has_wdrbt) {

0 commit comments

Comments
 (0)