Skip to content

Commit 8cd079e

Browse files
RajuRangojubroonie
authored andcommitted
spi: spi_amd: Remove read{q,b} usage on DMA buffer
Add changes to replace the usage of read{q,b} MMIO accessors with direct memory copy logic for reading data from DMA buffer. Co-developed-by: Krishnamoorthi M <[email protected]> Signed-off-by: Krishnamoorthi M <[email protected]> Signed-off-by: Raju Rangoju <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 4614fd6 commit 8cd079e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

drivers/spi/spi-amd.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -590,15 +590,21 @@ static void amd_spi_mem_data_in(struct amd_spi *amd_spi,
590590
* Use index mode otherwise.
591591
*/
592592
if (amd_spi->version == AMD_HID2_SPI && amd_is_spi_read_cmd(op->cmd.opcode)) {
593+
u64 *dma_buf64 = (u64 *)amd_spi->dma_virt_addr;
594+
u8 *dma_buf;
595+
593596
amd_spi_hiddma_read(amd_spi, op);
594597

595-
for (i = 0; left_data >= 8; i++, left_data -= 8)
596-
*buf_64++ = readq((u8 __iomem *)amd_spi->dma_virt_addr + (i * 8));
598+
/* Copy data from DMA buffer */
599+
while (left_data >= 8) {
600+
*buf_64++ = *dma_buf64++;
601+
left_data -= 8;
602+
}
597603

598604
buf = (u8 *)buf_64;
599-
for (i = 0; i < left_data; i++)
600-
buf[i] = readb((u8 __iomem *)amd_spi->dma_virt_addr +
601-
(nbytes - left_data + i));
605+
dma_buf = (u8 *)dma_buf64;
606+
while (left_data--)
607+
*buf++ = *dma_buf++;
602608

603609
/* Reset HID RX memory logic */
604610
data = amd_spi_readreg32(amd_spi, AMD_SPI_HID2_CNTRL);

0 commit comments

Comments
 (0)