Skip to content

Commit e664048

Browse files
committed
Merge tag 'spi-fix-v6.18-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi fixes from Mark Brown: "A disappointingly large set of device specific fixes that have built up since I've been a bit tardy with sending a pull requests as people kept sending me new new fixes. The bcm63xx and lpspi issues could lead to corruption so the fixes are fairly important for the affected parts, the other issues should all be relatively minor" * tag 'spi-fix-v6.18-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: nxp-fspi: Propagate fwnode in ACPI case as well spi: tegra114: remove Kconfig dependency on TEGRA20_APB_DMA spi: amlogic-spifc-a1: Handle devm_pm_runtime_enable() errors spi: spi-fsl-lpspi: fix watermark truncation caused by type cast spi: cadence-quadspi: Fix cqspi_probe() error handling for runtime pm spi: bcm63xx: fix premature CS deassertion on RX-only transactions spi: spi-cadence-quadspi: Remove duplicate pm_runtime_put_autosuspend() call spi: spi-cadence-quadspi: Enable pm runtime earlier to avoid imbalance
2 parents 82ebd4e + 40ad64a commit e664048

6 files changed

Lines changed: 39 additions & 19 deletions

File tree

drivers/spi/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,10 +1181,10 @@ config SPI_TEGRA210_QUAD
11811181

11821182
config SPI_TEGRA114
11831183
tristate "NVIDIA Tegra114 SPI Controller"
1184-
depends on (ARCH_TEGRA && TEGRA20_APB_DMA) || COMPILE_TEST
1184+
depends on ARCH_TEGRA || COMPILE_TEST
11851185
depends on RESET_CONTROLLER
11861186
help
1187-
SPI driver for NVIDIA Tegra114 SPI Controller interface. This controller
1187+
SPI controller driver for NVIDIA Tegra114 and later SoCs. This controller
11881188
is different than the older SoCs SPI controller and also register interface
11891189
get changed with this controller.
11901190

drivers/spi/spi-amlogic-spifc-a1.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,9 @@ static int amlogic_spifc_a1_probe(struct platform_device *pdev)
353353

354354
pm_runtime_set_autosuspend_delay(spifc->dev, 500);
355355
pm_runtime_use_autosuspend(spifc->dev);
356-
devm_pm_runtime_enable(spifc->dev);
356+
ret = devm_pm_runtime_enable(spifc->dev);
357+
if (ret)
358+
return ret;
357359

358360
ctrl->num_chipselect = 1;
359361
ctrl->dev.of_node = pdev->dev.of_node;

drivers/spi/spi-bcm63xx.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,20 @@ static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first,
247247

248248
if (t->rx_buf) {
249249
do_rx = true;
250+
251+
/*
252+
* In certain hardware implementations, there appears to be a
253+
* hidden accumulator that tracks the number of bytes written into
254+
* the hardware FIFO, and this accumulator overrides the length in
255+
* the SPI_MSG_CTL register.
256+
*
257+
* Therefore, for read-only transfers, we need to write some dummy
258+
* value into the FIFO to keep the accumulator tracking the correct
259+
* length.
260+
*/
261+
if (!t->tx_buf)
262+
memset_io(bs->tx_io + len, 0xFF, t->len);
263+
250264
/* prepend is half-duplex write only */
251265
if (t == first)
252266
prepend_len = 0;

drivers/spi/spi-cadence-quadspi.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,6 +1981,13 @@ static int cqspi_probe(struct platform_device *pdev)
19811981
cqspi->current_cs = -1;
19821982
cqspi->sclk = 0;
19831983

1984+
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
1985+
pm_runtime_enable(dev);
1986+
pm_runtime_set_autosuspend_delay(dev, CQSPI_AUTOSUSPEND_TIMEOUT);
1987+
pm_runtime_use_autosuspend(dev);
1988+
pm_runtime_get_noresume(dev);
1989+
}
1990+
19841991
ret = cqspi_setup_flash(cqspi);
19851992
if (ret) {
19861993
dev_err(dev, "failed to setup flash parameters %d\n", ret);
@@ -1995,14 +2002,7 @@ static int cqspi_probe(struct platform_device *pdev)
19952002
if (cqspi->use_direct_mode) {
19962003
ret = cqspi_request_mmap_dma(cqspi);
19972004
if (ret == -EPROBE_DEFER)
1998-
goto probe_dma_failed;
1999-
}
2000-
2001-
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
2002-
pm_runtime_enable(dev);
2003-
pm_runtime_set_autosuspend_delay(dev, CQSPI_AUTOSUSPEND_TIMEOUT);
2004-
pm_runtime_use_autosuspend(dev);
2005-
pm_runtime_get_noresume(dev);
2005+
goto probe_setup_failed;
20062006
}
20072007

20082008
ret = spi_register_controller(host);
@@ -2012,7 +2012,6 @@ static int cqspi_probe(struct platform_device *pdev)
20122012
}
20132013

20142014
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
2015-
pm_runtime_put_autosuspend(dev);
20162015
pm_runtime_mark_last_busy(dev);
20172016
pm_runtime_put_autosuspend(dev);
20182017
}
@@ -2021,7 +2020,6 @@ static int cqspi_probe(struct platform_device *pdev)
20212020
probe_setup_failed:
20222021
if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM)))
20232022
pm_runtime_disable(dev);
2024-
probe_dma_failed:
20252023
cqspi_controller_enable(cqspi, 0);
20262024
probe_reset_failed:
20272025
if (cqspi->is_jh7110)

drivers/spi/spi-fsl-lpspi.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,13 @@ static int fsl_lpspi_setup_transfer(struct spi_controller *controller,
486486
fsl_lpspi->tx = fsl_lpspi_buf_tx_u32;
487487
}
488488

489-
fsl_lpspi->watermark = min_t(typeof(fsl_lpspi->watermark),
489+
/*
490+
* t->len is 'unsigned' and txfifosize and watermrk is 'u8', force
491+
* type cast is inevitable. When len > 255, len will be truncated in min_t(),
492+
* it caused wrong watermark set. 'unsigned int' is as the designated type
493+
* for min_t() to avoid truncation.
494+
*/
495+
fsl_lpspi->watermark = min_t(unsigned int,
490496
fsl_lpspi->txfifosize,
491497
t->len);
492498

drivers/spi/spi-nxp-fspi.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ static int nxp_fspi_probe(struct platform_device *pdev)
12871287
{
12881288
struct spi_controller *ctlr;
12891289
struct device *dev = &pdev->dev;
1290-
struct device_node *np = dev->of_node;
1290+
struct fwnode_handle *fwnode = dev_fwnode(dev);
12911291
struct resource *res;
12921292
struct nxp_fspi *f;
12931293
int ret, irq;
@@ -1309,15 +1309,15 @@ static int nxp_fspi_probe(struct platform_device *pdev)
13091309
platform_set_drvdata(pdev, f);
13101310

13111311
/* find the resources - configuration register address space */
1312-
if (is_acpi_node(dev_fwnode(f->dev)))
1312+
if (is_acpi_node(fwnode))
13131313
f->iobase = devm_platform_ioremap_resource(pdev, 0);
13141314
else
13151315
f->iobase = devm_platform_ioremap_resource_byname(pdev, "fspi_base");
13161316
if (IS_ERR(f->iobase))
13171317
return PTR_ERR(f->iobase);
13181318

13191319
/* find the resources - controller memory mapped space */
1320-
if (is_acpi_node(dev_fwnode(f->dev)))
1320+
if (is_acpi_node(fwnode))
13211321
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
13221322
else
13231323
res = platform_get_resource_byname(pdev,
@@ -1330,7 +1330,7 @@ static int nxp_fspi_probe(struct platform_device *pdev)
13301330
f->memmap_phy_size = resource_size(res);
13311331

13321332
/* find the clocks */
1333-
if (dev_of_node(&pdev->dev)) {
1333+
if (is_of_node(fwnode)) {
13341334
f->clk_en = devm_clk_get(dev, "fspi_en");
13351335
if (IS_ERR(f->clk_en))
13361336
return PTR_ERR(f->clk_en);
@@ -1383,7 +1383,7 @@ static int nxp_fspi_probe(struct platform_device *pdev)
13831383
else
13841384
ctlr->mem_caps = &nxp_fspi_mem_caps;
13851385

1386-
ctlr->dev.of_node = np;
1386+
device_set_node(&ctlr->dev, fwnode);
13871387

13881388
ret = devm_add_action_or_reset(dev, nxp_fspi_cleanup, f);
13891389
if (ret)

0 commit comments

Comments
 (0)