Skip to content

Commit 87c301c

Browse files
committed
Merge tag 'spi-fix-v5.10-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi fixes from Mark Brown: "A few fixes for v5.10, one for the core which fixes some potential races for controllers with multiple chip selects when configuration of the chip select for one client device races with the addition and initial setup of an additional client" * tag 'spi-fix-v5.10-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: dw: Fix spi registration for controllers overriding CS spi: imx: fix the unbalanced spi runtime pm management spi: spi-nxp-fspi: fix fspi panic by unexpected interrupts spi: Take the SPI IO-mutex in the spi_setup() method
2 parents f594139 + 0abdb0f commit 87c301c

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

drivers/spi/spi-dw-core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,8 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
875875
master->set_cs = dw_spi_set_cs;
876876
master->transfer_one = dw_spi_transfer_one;
877877
master->handle_err = dw_spi_handle_err;
878-
master->mem_ops = &dws->mem_ops;
878+
if (dws->mem_ops.exec_op)
879+
master->mem_ops = &dws->mem_ops;
879880
master->max_speed_hz = dws->max_freq;
880881
master->dev.of_node = dev->of_node;
881882
master->dev.fwnode = dev->fwnode;

drivers/spi/spi-imx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,6 +1686,7 @@ static int spi_imx_probe(struct platform_device *pdev)
16861686

16871687
pm_runtime_set_autosuspend_delay(spi_imx->dev, MXC_RPM_TIMEOUT);
16881688
pm_runtime_use_autosuspend(spi_imx->dev);
1689+
pm_runtime_get_noresume(spi_imx->dev);
16891690
pm_runtime_set_active(spi_imx->dev);
16901691
pm_runtime_enable(spi_imx->dev);
16911692

drivers/spi/spi-nxp-fspi.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,7 @@ static int nxp_fspi_probe(struct platform_device *pdev)
10011001
struct resource *res;
10021002
struct nxp_fspi *f;
10031003
int ret;
1004+
u32 reg;
10041005

10051006
ctlr = spi_alloc_master(&pdev->dev, sizeof(*f));
10061007
if (!ctlr)
@@ -1032,6 +1033,12 @@ static int nxp_fspi_probe(struct platform_device *pdev)
10321033
goto err_put_ctrl;
10331034
}
10341035

1036+
/* Clear potential interrupts */
1037+
reg = fspi_readl(f, f->iobase + FSPI_INTR);
1038+
if (reg)
1039+
fspi_writel(f, reg, f->iobase + FSPI_INTR);
1040+
1041+
10351042
/* find the resources - controller memory mapped space */
10361043
if (is_acpi_node(f->dev->fwnode))
10371044
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);

drivers/spi/spi.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3372,12 +3372,15 @@ int spi_setup(struct spi_device *spi)
33723372
if (!spi->max_speed_hz)
33733373
spi->max_speed_hz = spi->controller->max_speed_hz;
33743374

3375+
mutex_lock(&spi->controller->io_mutex);
3376+
33753377
if (spi->controller->setup)
33763378
status = spi->controller->setup(spi);
33773379

33783380
if (spi->controller->auto_runtime_pm && spi->controller->set_cs) {
33793381
status = pm_runtime_get_sync(spi->controller->dev.parent);
33803382
if (status < 0) {
3383+
mutex_unlock(&spi->controller->io_mutex);
33813384
pm_runtime_put_noidle(spi->controller->dev.parent);
33823385
dev_err(&spi->controller->dev, "Failed to power device: %d\n",
33833386
status);
@@ -3399,6 +3402,8 @@ int spi_setup(struct spi_device *spi)
33993402
spi_set_cs(spi, false);
34003403
}
34013404

3405+
mutex_unlock(&spi->controller->io_mutex);
3406+
34023407
if (spi->rt && !spi->controller->rt) {
34033408
spi->controller->rt = true;
34043409
spi_set_thread_rt(spi->controller);

0 commit comments

Comments
 (0)