All of lore.kernel.org
 help / color / mirror / Atom feed
From: Raju Rangoju <Raju.Rangoju@amd.com>
To: <broonie@kernel.org>
Cc: <linux-spi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<krishnamoorthi.m@amd.com>, <akshata.mukundshetty@amd.com>,
	Raju Rangoju <Raju.Rangoju@amd.com>
Subject: [PATCH v2 1/3] spi: spi_amd: Remove read{q,b} usage on DMA buffer
Date: Fri, 16 May 2025 15:36:56 +0530	[thread overview]
Message-ID: <20250516100658.585654-2-Raju.Rangoju@amd.com> (raw)
In-Reply-To: <20250516100658.585654-1-Raju.Rangoju@amd.com>

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 <krishnamoorthi.m@amd.com>
Signed-off-by: Krishnamoorthi M <krishnamoorthi.m@amd.com>
Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
---
 drivers/spi/spi-amd.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-amd.c b/drivers/spi/spi-amd.c
index 90b1f7daa072..52d893d41b12 100644
--- a/drivers/spi/spi-amd.c
+++ b/drivers/spi/spi-amd.c
@@ -590,15 +590,21 @@ static void amd_spi_mem_data_in(struct amd_spi *amd_spi,
 	 * Use index mode otherwise.
 	 */
 	if (amd_spi->version == AMD_HID2_SPI && amd_is_spi_read_cmd(op->cmd.opcode)) {
+		u64 *dma_buf64 = (u64 *)amd_spi->dma_virt_addr;
+		u8 *dma_buf;
+
 		amd_spi_hiddma_read(amd_spi, op);
 
-		for (i = 0; left_data >= 8; i++, left_data -= 8)
-			*buf_64++ = readq((u8 __iomem *)amd_spi->dma_virt_addr + (i * 8));
+		/* Copy data from DMA buffer */
+		while (left_data >= 8) {
+			*buf_64++ = *dma_buf64++;
+			left_data -= 8;
+		}
 
 		buf = (u8 *)buf_64;
-		for (i = 0; i < left_data; i++)
-			buf[i] = readb((u8 __iomem *)amd_spi->dma_virt_addr +
-				       (nbytes - left_data + i));
+		dma_buf = (u8 *)dma_buf64;
+		while (left_data--)
+			*buf++ = *dma_buf++;
 
 		/* Reset HID RX memory logic */
 		data = amd_spi_readreg32(amd_spi, AMD_SPI_HID2_CNTRL);
-- 
2.34.1


  reply	other threads:[~2025-05-16 10:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-16 10:06 [PATCH v2 0/3] spi: spi_amd: Add DMA write and Kconfig changes Raju Rangoju
2025-05-16 10:06 ` Raju Rangoju [this message]
2025-05-16 10:06 ` [PATCH v2 2/3] spi: spi_amd: Add HIDDMA basic write support Raju Rangoju
2025-05-16 10:06 ` [PATCH v2 3/3] spi: spi_amd: Update Kconfig dependencies Raju Rangoju
2025-05-28  7:32   ` Geert Uytterhoeven
2025-06-09 10:47     ` Rangoju, Raju
2025-05-20 11:05 ` [PATCH v2 0/3] spi: spi_amd: Add DMA write and Kconfig changes Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250516100658.585654-2-Raju.Rangoju@amd.com \
    --to=raju.rangoju@amd.com \
    --cc=akshata.mukundshetty@amd.com \
    --cc=broonie@kernel.org \
    --cc=krishnamoorthi.m@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.