Skip to content

Commit e8878ab

Browse files
committed
Merge tag 'spi-fix-v5.9-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi fixes from Mark Brown: "There's some driver specific fixes here plus one core fix for memory leaks that could be triggered by a potential race condition when cleaning up after we have split transfers to fit into what the controller can support" * tag 'spi-fix-v5.9-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: stm32: fix pm_runtime_get_sync() error checking spi: Fix memory leak on splited transfers spi: spi-cadence-quadspi: Fix mapping of buffers for DMA reads spi: stm32: Rate-limit the 'Communication suspended' message spi: spi-loopback-test: Fix out-of-bounds read spi: spi-cadence-quadspi: Populate get_name() interface MAINTAINERS: add myself as maintainer for spi-fsl-dspi driver
2 parents 8b6ce25 + c170a5a commit e8878ab

File tree

5 files changed

+36
-8
lines changed

5 files changed

+36
-8
lines changed

MAINTAINERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6901,6 +6901,14 @@ L: linuxppc-dev@lists.ozlabs.org
69016901
S: Maintained
69026902
F: drivers/dma/fsldma.*
69036903

6904+
FREESCALE DSPI DRIVER
6905+
M: Vladimir Oltean <olteanv@gmail.com>
6906+
L: linux-spi@vger.kernel.org
6907+
S: Maintained
6908+
F: Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt
6909+
F: drivers/spi/spi-fsl-dspi.c
6910+
F: include/linux/spi/spi-fsl-dspi.h
6911+
69046912
FREESCALE ENETC ETHERNET DRIVERS
69056913
M: Claudiu Manoil <claudiu.manoil@nxp.com>
69066914
L: netdev@vger.kernel.org

drivers/spi/spi-cadence-quadspi.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,14 +907,16 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,
907907
struct dma_async_tx_descriptor *tx;
908908
dma_cookie_t cookie;
909909
dma_addr_t dma_dst;
910+
struct device *ddev;
910911

911912
if (!cqspi->rx_chan || !virt_addr_valid(buf)) {
912913
memcpy_fromio(buf, cqspi->ahb_base + from, len);
913914
return 0;
914915
}
915916

916-
dma_dst = dma_map_single(dev, buf, len, DMA_FROM_DEVICE);
917-
if (dma_mapping_error(dev, dma_dst)) {
917+
ddev = cqspi->rx_chan->device->dev;
918+
dma_dst = dma_map_single(ddev, buf, len, DMA_FROM_DEVICE);
919+
if (dma_mapping_error(ddev, dma_dst)) {
918920
dev_err(dev, "dma mapping failed\n");
919921
return -ENOMEM;
920922
}
@@ -948,7 +950,7 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,
948950
}
949951

950952
err_unmap:
951-
dma_unmap_single(dev, dma_dst, len, DMA_FROM_DEVICE);
953+
dma_unmap_single(ddev, dma_dst, len, DMA_FROM_DEVICE);
952954

953955
return ret;
954956
}
@@ -1128,8 +1130,17 @@ static int cqspi_request_mmap_dma(struct cqspi_st *cqspi)
11281130
return 0;
11291131
}
11301132

1133+
static const char *cqspi_get_name(struct spi_mem *mem)
1134+
{
1135+
struct cqspi_st *cqspi = spi_master_get_devdata(mem->spi->master);
1136+
struct device *dev = &cqspi->pdev->dev;
1137+
1138+
return devm_kasprintf(dev, GFP_KERNEL, "%s.%d", dev_name(dev), mem->spi->chip_select);
1139+
}
1140+
11311141
static const struct spi_controller_mem_ops cqspi_mem_ops = {
11321142
.exec_op = cqspi_exec_mem_op,
1143+
.get_name = cqspi_get_name,
11331144
};
11341145

11351146
static int cqspi_setup_flash(struct cqspi_st *cqspi)

drivers/spi/spi-loopback-test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static struct spi_test spi_tests[] = {
9090
{
9191
.description = "tx/rx-transfer - crossing PAGE_SIZE",
9292
.fill_option = FILL_COUNT_8,
93-
.iterate_len = { ITERATE_MAX_LEN },
93+
.iterate_len = { ITERATE_LEN },
9494
.iterate_tx_align = ITERATE_ALIGN,
9595
.iterate_rx_align = ITERATE_ALIGN,
9696
.transfer_count = 1,

drivers/spi/spi-stm32.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,11 @@ static irqreturn_t stm32h7_spi_irq_thread(int irq, void *dev_id)
936936
}
937937

938938
if (sr & STM32H7_SPI_SR_SUSP) {
939-
dev_warn(spi->dev, "Communication suspended\n");
939+
static DEFINE_RATELIMIT_STATE(rs,
940+
DEFAULT_RATELIMIT_INTERVAL * 10,
941+
1);
942+
if (__ratelimit(&rs))
943+
dev_dbg_ratelimited(spi->dev, "Communication suspended\n");
940944
if (!spi->cur_usedma && (spi->rx_buf && (spi->rx_len > 0)))
941945
stm32h7_spi_read_rxfifo(spi, false);
942946
/*
@@ -2060,7 +2064,7 @@ static int stm32_spi_resume(struct device *dev)
20602064
}
20612065

20622066
ret = pm_runtime_get_sync(dev);
2063-
if (ret) {
2067+
if (ret < 0) {
20642068
dev_err(dev, "Unable to power device:%d\n", ret);
20652069
return ret;
20662070
}

drivers/spi/spi.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,8 +1327,6 @@ static int spi_transfer_one_message(struct spi_controller *ctlr,
13271327
if (msg->status && ctlr->handle_err)
13281328
ctlr->handle_err(ctlr, msg);
13291329

1330-
spi_res_release(ctlr, msg);
1331-
13321330
spi_finalize_current_message(ctlr);
13331331

13341332
return ret;
@@ -1725,6 +1723,13 @@ void spi_finalize_current_message(struct spi_controller *ctlr)
17251723

17261724
spi_unmap_msg(ctlr, mesg);
17271725

1726+
/* In the prepare_messages callback the spi bus has the opportunity to
1727+
* split a transfer to smaller chunks.
1728+
* Release splited transfers here since spi_map_msg is done on the
1729+
* splited transfers.
1730+
*/
1731+
spi_res_release(ctlr, mesg);
1732+
17281733
if (ctlr->cur_msg_prepared && ctlr->unprepare_message) {
17291734
ret = ctlr->unprepare_message(ctlr, mesg);
17301735
if (ret) {

0 commit comments

Comments
 (0)