Skip to content

Commit 6e8e2f8

Browse files
committed
Merge tag 'spi-fix-v6.14-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi fixes from Mark Brown: "A couple of driver specific fixes, an error handling fix for the Atmel QuadSPI driver and a fix for a nasty synchronisation issue in the data path for the Microchip driver which affects larger transfers. There's also a MAINTAINERS update for the Samsung driver" * tag 'spi-fix-v6.14-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: microchip-core: prevent RX overflows when transmit size > FIFO size MAINTAINERS: add tambarus as R for Samsung SPI spi: atmel-quadspi: remove references to runtime PM on error path
2 parents 0fed89a + 91cf42c commit 6e8e2f8

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21089,6 +21089,7 @@ F: include/linux/clk/samsung.h
2108921089

2109021090
SAMSUNG SPI DRIVERS
2109121091
M: Andi Shyti <andi.shyti@kernel.org>
21092+
R: Tudor Ambarus <tudor.ambarus@linaro.org>
2109221093
L: linux-spi@vger.kernel.org
2109321094
L: linux-samsung-soc@vger.kernel.org
2109421095
S: Maintained

drivers/spi/atmel-quadspi.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -930,11 +930,8 @@ static int atmel_qspi_sama7g5_transfer(struct spi_mem *mem,
930930

931931
/* Release the chip-select. */
932932
ret = atmel_qspi_reg_sync(aq);
933-
if (ret) {
934-
pm_runtime_mark_last_busy(&aq->pdev->dev);
935-
pm_runtime_put_autosuspend(&aq->pdev->dev);
933+
if (ret)
936934
return ret;
937-
}
938935
atmel_qspi_write(QSPI_CR_LASTXFER, aq, QSPI_CR);
939936

940937
return atmel_qspi_wait_for_completion(aq, QSPI_SR_CSRA);

drivers/spi/spi-microchip-core.c

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@
7070
#define INT_RX_CHANNEL_OVERFLOW BIT(2)
7171
#define INT_TX_CHANNEL_UNDERRUN BIT(3)
7272

73-
#define INT_ENABLE_MASK (CONTROL_RX_DATA_INT | CONTROL_TX_DATA_INT | \
74-
CONTROL_RX_OVER_INT | CONTROL_TX_UNDER_INT)
73+
#define INT_ENABLE_MASK (CONTROL_RX_OVER_INT | CONTROL_TX_UNDER_INT)
7574

7675
#define REG_CONTROL (0x00)
7776
#define REG_FRAME_SIZE (0x04)
@@ -133,10 +132,15 @@ static inline void mchp_corespi_disable(struct mchp_corespi *spi)
133132
mchp_corespi_write(spi, REG_CONTROL, control);
134133
}
135134

136-
static inline void mchp_corespi_read_fifo(struct mchp_corespi *spi)
135+
static inline void mchp_corespi_read_fifo(struct mchp_corespi *spi, int fifo_max)
137136
{
138-
while (spi->rx_len >= spi->n_bytes && !(mchp_corespi_read(spi, REG_STATUS) & STATUS_RXFIFO_EMPTY)) {
139-
u32 data = mchp_corespi_read(spi, REG_RX_DATA);
137+
for (int i = 0; i < fifo_max; i++) {
138+
u32 data;
139+
140+
while (mchp_corespi_read(spi, REG_STATUS) & STATUS_RXFIFO_EMPTY)
141+
;
142+
143+
data = mchp_corespi_read(spi, REG_RX_DATA);
140144

141145
spi->rx_len -= spi->n_bytes;
142146

@@ -211,11 +215,10 @@ static inline void mchp_corespi_set_xfer_size(struct mchp_corespi *spi, int len)
211215
mchp_corespi_write(spi, REG_FRAMESUP, len);
212216
}
213217

214-
static inline void mchp_corespi_write_fifo(struct mchp_corespi *spi)
218+
static inline void mchp_corespi_write_fifo(struct mchp_corespi *spi, int fifo_max)
215219
{
216-
int fifo_max, i = 0;
220+
int i = 0;
217221

218-
fifo_max = DIV_ROUND_UP(min(spi->tx_len, FIFO_DEPTH), spi->n_bytes);
219222
mchp_corespi_set_xfer_size(spi, fifo_max);
220223

221224
while ((i < fifo_max) && !(mchp_corespi_read(spi, REG_STATUS) & STATUS_TXFIFO_FULL)) {
@@ -413,19 +416,6 @@ static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id)
413416
if (intfield == 0)
414417
return IRQ_NONE;
415418

416-
if (intfield & INT_TXDONE)
417-
mchp_corespi_write(spi, REG_INT_CLEAR, INT_TXDONE);
418-
419-
if (intfield & INT_RXRDY) {
420-
mchp_corespi_write(spi, REG_INT_CLEAR, INT_RXRDY);
421-
422-
if (spi->rx_len)
423-
mchp_corespi_read_fifo(spi);
424-
}
425-
426-
if (!spi->rx_len && !spi->tx_len)
427-
finalise = true;
428-
429419
if (intfield & INT_RX_CHANNEL_OVERFLOW) {
430420
mchp_corespi_write(spi, REG_INT_CLEAR, INT_RX_CHANNEL_OVERFLOW);
431421
finalise = true;
@@ -512,9 +502,14 @@ static int mchp_corespi_transfer_one(struct spi_controller *host,
512502

513503
mchp_corespi_write(spi, REG_SLAVE_SELECT, spi->pending_slave_select);
514504

515-
while (spi->tx_len)
516-
mchp_corespi_write_fifo(spi);
505+
while (spi->tx_len) {
506+
int fifo_max = DIV_ROUND_UP(min(spi->tx_len, FIFO_DEPTH), spi->n_bytes);
507+
508+
mchp_corespi_write_fifo(spi, fifo_max);
509+
mchp_corespi_read_fifo(spi, fifo_max);
510+
}
517511

512+
spi_finalize_current_transfer(host);
518513
return 1;
519514
}
520515

0 commit comments

Comments
 (0)