public inbox for cip-dev@lists.cip-project.org
 help / color / mirror / Atom feed
* [PATCH 5.10.y-cip 0/3] Add 64-bit polling support
@ 2025-12-15 12:52 Biju
  2025-12-15 12:53 ` [PATCH 5.10.y-cip 1/3] mmc: tmio: Add 64-bit read/write support for SD_BUF0 in polling mode Biju
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Biju @ 2025-12-15 12:52 UTC (permalink / raw)
  To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek; +Cc: Biju Das, Lad Prabhakar

From: Biju Das <biju.das.jz@bp.renesas.com>

As per the RZ/{G2L,G3E} HW manual SD_BUF0 can be accessed by 16/32/64
bits. Most of the data transfer in SD/SDIO/eMMC mode is more than 8 bytes.
During testing it is found that, if the DMA buffer is not aligned to 128
bit it fallback to PIO mode. In such cases, 64-bit access is much more
efficient than the current 16-bit.

Biju Das (3):
  mmc: tmio: Add 64-bit read/write support for SD_BUF0 in polling mode
  mmc: renesas_sdhi: Enable 64-bit polling mode
  mmc: renesas_sdhi: Replace magic number '0xff' in
    renesas_sdhi_set_clock()

 drivers/mmc/host/renesas_sdhi_core.c          |  2 +-
 drivers/mmc/host/renesas_sdhi_internal_dmac.c |  3 +-
 drivers/mmc/host/tmio_mmc.h                   | 15 +++++++++
 drivers/mmc/host/tmio_mmc_core.c              | 33 +++++++++++++++++++
 include/linux/mfd/tmio.h                      |  3 ++
 5 files changed, 54 insertions(+), 2 deletions(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 5.10.y-cip 1/3] mmc: tmio: Add 64-bit read/write support for SD_BUF0 in polling mode
  2025-12-15 12:52 [PATCH 5.10.y-cip 0/3] Add 64-bit polling support Biju
@ 2025-12-15 12:53 ` Biju
  2025-12-15 12:53 ` [PATCH 5.10.y-cip 2/3] mmc: renesas_sdhi: Enable 64-bit " Biju
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Biju @ 2025-12-15 12:53 UTC (permalink / raw)
  To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek; +Cc: Biju Das, Lad Prabhakar

From: Biju Das <biju.das.jz@bp.renesas.com>

[ Upstream commit 74f44ad07d1063933c237a7db16f6a4036643d60 ]

As per the RZ/{G2L,G3E} HW manual SD_BUF0 can be accessed by 16/32/64
bits. Most of the data transfer in SD/SDIO/eMMC mode is more than 8 bytes.
During testing it is found that, if the DMA buffer is not aligned to 128
bit it fallback to PIO mode. In such cases, 64-bit access is much more
efficient than the current 16-bit.

Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20250730164618.233117-2-biju.das.jz@bp.renesas.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
[Biju: Moved the macro definition from platform_data/tmio.h->mfd/tmio.h]
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc.h      | 15 +++++++++++++++
 drivers/mmc/host/tmio_mmc_core.c | 33 ++++++++++++++++++++++++++++++++
 include/linux/mfd/tmio.h         |  3 +++
 3 files changed, 51 insertions(+)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index da63193dd45b..92e9bfd92bf7 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -16,6 +16,7 @@
 
 #include <linux/dmaengine.h>
 #include <linux/highmem.h>
+#include <linux/io.h>
 #include <linux/mutex.h>
 #include <linux/pagemap.h>
 #include <linux/scatterlist.h>
@@ -251,6 +252,20 @@ static inline void sd_ctrl_read32_rep(struct tmio_mmc_host *host, int addr,
 	ioread32_rep(host->ctl + (addr << host->bus_shift), buf, count);
 }
 
+#ifdef CONFIG_64BIT
+static inline void sd_ctrl_read64_rep(struct tmio_mmc_host *host, int addr,
+				      u64 *buf, int count)
+{
+	readsq(host->ctl + (addr << host->bus_shift), buf, count);
+}
+
+static inline void sd_ctrl_write64_rep(struct tmio_mmc_host *host, int addr,
+				       const u64 *buf, int count)
+{
+	writesq(host->ctl + (addr << host->bus_shift), buf, count);
+}
+#endif
+
 static inline void sd_ctrl_write16(struct tmio_mmc_host *host, int addr,
 				   u16 val)
 {
diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index 7bc292e78100..a000ce001994 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -350,6 +350,39 @@ static void tmio_mmc_transfer_data(struct tmio_mmc_host *host,
 	/*
 	 * Transfer the data
 	 */
+#ifdef CONFIG_64BIT
+	if (host->pdata->flags & TMIO_MMC_64BIT_DATA_PORT) {
+		u64 *buf64 = (u64 *)buf;
+		u64 data = 0;
+
+		if (count >= 8) {
+			if (is_read)
+				sd_ctrl_read64_rep(host, CTL_SD_DATA_PORT,
+						   buf64, count >> 3);
+			else
+				sd_ctrl_write64_rep(host, CTL_SD_DATA_PORT,
+						    buf64, count >> 3);
+		}
+
+		/* if count was multiple of 8 */
+		if (!(count & 0x7))
+			return;
+
+		buf64 += count >> 3;
+		count %= 8;
+
+		if (is_read) {
+			sd_ctrl_read64_rep(host, CTL_SD_DATA_PORT, &data, 1);
+			memcpy(buf64, &data, count);
+		} else {
+			memcpy(&data, buf64, count);
+			sd_ctrl_write64_rep(host, CTL_SD_DATA_PORT, &data, 1);
+		}
+
+		return;
+	}
+#endif
+
 	if (host->pdata->flags & TMIO_MMC_32BIT_DATA_PORT) {
 		u32 data = 0;
 		u32 *buf32 = (u32 *)buf;
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index 27264fe4b3b9..566cc9ad0363 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -84,6 +84,9 @@
 /* Some controllers have a CBSY bit */
 #define TMIO_MMC_HAVE_CBSY		BIT(11)
 
+/* Some controllers have a 64-bit wide data port register */
+#define TMIO_MMC_64BIT_DATA_PORT	BIT(12)
+
 int tmio_core_mmc_enable(void __iomem *cnf, int shift, unsigned long base);
 int tmio_core_mmc_resume(void __iomem *cnf, int shift, unsigned long base);
 void tmio_core_mmc_pwr(void __iomem *cnf, int shift, int state);
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5.10.y-cip 2/3] mmc: renesas_sdhi: Enable 64-bit polling mode
  2025-12-15 12:52 [PATCH 5.10.y-cip 0/3] Add 64-bit polling support Biju
  2025-12-15 12:53 ` [PATCH 5.10.y-cip 1/3] mmc: tmio: Add 64-bit read/write support for SD_BUF0 in polling mode Biju
@ 2025-12-15 12:53 ` Biju
  2025-12-15 12:53 ` [PATCH 5.10.y-cip 3/3] mmc: renesas_sdhi: Replace magic number '0xff' in renesas_sdhi_set_clock() Biju
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Biju @ 2025-12-15 12:53 UTC (permalink / raw)
  To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek; +Cc: Biju Das, Lad Prabhakar

From: Biju Das <biju.das.jz@bp.renesas.com>

[ Upstream commit 709fe7aa5aaf8047b528561a0082db8a3a29010c ]

Enable 64-bit polling mode for R-Car gen3 and RZ/G2L SoCs.

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20250730164618.233117-3-biju.das.jz@bp.renesas.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/mmc/host/renesas_sdhi_internal_dmac.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
index c6ddfe8215c7..17d693ba90b1 100644
--- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c
+++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
@@ -109,7 +109,8 @@ static const struct renesas_sdhi_of_data of_rza2_compatible = {
 
 static const struct renesas_sdhi_of_data of_rcar_gen3_compatible = {
 	.tmio_flags	= TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL |
-			  TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,
+			  TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2 |
+			  TMIO_MMC_64BIT_DATA_PORT,
 	.capabilities	= MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
 			  MMC_CAP_CMD23,
 	.capabilities2	= MMC_CAP2_NO_WRITE_PROTECT | MMC_CAP2_MERGE_CAPABLE,
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5.10.y-cip 3/3] mmc: renesas_sdhi: Replace magic number '0xff' in renesas_sdhi_set_clock()
  2025-12-15 12:52 [PATCH 5.10.y-cip 0/3] Add 64-bit polling support Biju
  2025-12-15 12:53 ` [PATCH 5.10.y-cip 1/3] mmc: tmio: Add 64-bit read/write support for SD_BUF0 in polling mode Biju
  2025-12-15 12:53 ` [PATCH 5.10.y-cip 2/3] mmc: renesas_sdhi: Enable 64-bit " Biju
@ 2025-12-15 12:53 ` Biju
  2025-12-16 10:25 ` [PATCH 5.10.y-cip 0/3] Add 64-bit polling support Pavel Machek
  2025-12-16 13:09 ` nobuhiro.iwamatsu.x90
  4 siblings, 0 replies; 7+ messages in thread
From: Biju @ 2025-12-15 12:53 UTC (permalink / raw)
  To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek; +Cc: Biju Das, Lad Prabhakar

From: Biju Das <biju.das.jz@bp.renesas.com>

[ Upstream commit 5d0702dc9c2f6700140b7366dd9ec6c78cde3aa1 ]

Replace the magic number '0xff' with CLK_CTL_DIV_MASK macro for finding
actual clock in renesas_sdhi_set_clock().

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20250820104808.94562-1-biju.das.jz@bp.renesas.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/mmc/host/renesas_sdhi_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index 37b8155c93a0..06c1fdf51250 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -209,7 +209,7 @@ static void renesas_sdhi_set_clock(struct tmio_mmc_host *host,
 	}
 
 	clock = clk & CLK_CTL_DIV_MASK;
-	if (clock != 0xff)
+	if (clock != CLK_CTL_DIV_MASK)
 		host->mmc->actual_clock /= (1 << (ffs(clock) + 1));
 
 	sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, clock);
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 5.10.y-cip 0/3] Add 64-bit polling support
  2025-12-15 12:52 [PATCH 5.10.y-cip 0/3] Add 64-bit polling support Biju
                   ` (2 preceding siblings ...)
  2025-12-15 12:53 ` [PATCH 5.10.y-cip 3/3] mmc: renesas_sdhi: Replace magic number '0xff' in renesas_sdhi_set_clock() Biju
@ 2025-12-16 10:25 ` Pavel Machek
  2025-12-16 13:09 ` nobuhiro.iwamatsu.x90
  4 siblings, 0 replies; 7+ messages in thread
From: Pavel Machek @ 2025-12-16 10:25 UTC (permalink / raw)
  To: Biju; +Cc: cip-dev, Nobuhiro Iwamatsu, Biju Das, Lad Prabhakar

[-- Attachment #1: Type: text/plain, Size: 659 bytes --]

Hi!

> As per the RZ/{G2L,G3E} HW manual SD_BUF0 can be accessed by 16/32/64
> bits. Most of the data transfer in SD/SDIO/eMMC mode is more than 8 bytes.
> During testing it is found that, if the DMA buffer is not aligned to 128
> bit it fallback to PIO mode. In such cases, 64-bit access is much more
> efficient than the current 16-bit.

This looks okay to me. I can apply it if it passes testing and there
are no other comments.

Best regards,
                                                                Pavel
-- 
In cooperation with DENX Software Engineering GmbH, HRB 165235 Munich,
Office: Kirchenstr.5, D-82194 Groebenzell, Germany

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH 5.10.y-cip 0/3] Add 64-bit polling support
  2025-12-15 12:52 [PATCH 5.10.y-cip 0/3] Add 64-bit polling support Biju
                   ` (3 preceding siblings ...)
  2025-12-16 10:25 ` [PATCH 5.10.y-cip 0/3] Add 64-bit polling support Pavel Machek
@ 2025-12-16 13:09 ` nobuhiro.iwamatsu.x90
  2025-12-16 20:45   ` Pavel Machek
  4 siblings, 1 reply; 7+ messages in thread
From: nobuhiro.iwamatsu.x90 @ 2025-12-16 13:09 UTC (permalink / raw)
  To: biju.das.au, cip-dev, pavel; +Cc: biju.das.jz, prabhakar.mahadev-lad.rj

Hi all,

> -----Original Message-----
> From: Biju <biju.das.au@gmail.com>
> Sent: Monday, December 15, 2025 9:53 PM
> To: cip-dev@lists.cip-project.org; iwamatsu nobuhiro(岩松 信洋 □DITC○C
> PT) <nobuhiro.iwamatsu.x90@mail.toshiba>; Pavel Machek
> <pavel@denx.de>
> Cc: Biju Das <biju.das.jz@bp.renesas.com>; Lad Prabhakar
> <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Subject: [PATCH 5.10.y-cip 0/3] Add 64-bit polling support
> 
> From: Biju Das <biju.das.jz@bp.renesas.com>
> 
> As per the RZ/{G2L,G3E} HW manual SD_BUF0 can be accessed by 16/32/64
> bits. Most of the data transfer in SD/SDIO/eMMC mode is more than 8 bytes.
> During testing it is found that, if the DMA buffer is not aligned to 128 bit it
> fallback to PIO mode. In such cases, 64-bit access is much more efficient than
> the current 16-bit.
> 
> Biju Das (3):
>   mmc: tmio: Add 64-bit read/write support for SD_BUF0 in polling mode
>   mmc: renesas_sdhi: Enable 64-bit polling mode
>   mmc: renesas_sdhi: Replace magic number '0xff' in
>     renesas_sdhi_set_clock()
> 
>  drivers/mmc/host/renesas_sdhi_core.c          |  2 +-
>  drivers/mmc/host/renesas_sdhi_internal_dmac.c |  3 +-
>  drivers/mmc/host/tmio_mmc.h                   | 15 +++++++++
>  drivers/mmc/host/tmio_mmc_core.c              | 33
> +++++++++++++++++++
>  include/linux/mfd/tmio.h                      |  3 ++
>  5 files changed, 54 insertions(+), 2 deletions(-)
> 

I reviewed this series, looks good to me.
I can apply this series if there are no other comments.

Reviewed-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.x90@mail.toshiba>

Best regards,
  Nobuhiro



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 5.10.y-cip 0/3] Add 64-bit polling support
  2025-12-16 13:09 ` nobuhiro.iwamatsu.x90
@ 2025-12-16 20:45   ` Pavel Machek
  0 siblings, 0 replies; 7+ messages in thread
From: Pavel Machek @ 2025-12-16 20:45 UTC (permalink / raw)
  To: nobuhiro.iwamatsu.x90
  Cc: biju.das.au, cip-dev, biju.das.jz, prabhakar.mahadev-lad.rj

[-- Attachment #1: Type: text/plain, Size: 1465 bytes --]

Hi!

> > From: Biju Das <biju.das.jz@bp.renesas.com>
> > 
> > As per the RZ/{G2L,G3E} HW manual SD_BUF0 can be accessed by 16/32/64
> > bits. Most of the data transfer in SD/SDIO/eMMC mode is more than 8 bytes.
> > During testing it is found that, if the DMA buffer is not aligned to 128 bit it
> > fallback to PIO mode. In such cases, 64-bit access is much more efficient than
> > the current 16-bit.
> > 
> > Biju Das (3):
> >   mmc: tmio: Add 64-bit read/write support for SD_BUF0 in polling mode
> >   mmc: renesas_sdhi: Enable 64-bit polling mode
> >   mmc: renesas_sdhi: Replace magic number '0xff' in
> >     renesas_sdhi_set_clock()
> > 
> >  drivers/mmc/host/renesas_sdhi_core.c          |  2 +-
> >  drivers/mmc/host/renesas_sdhi_internal_dmac.c |  3 +-
> >  drivers/mmc/host/tmio_mmc.h                   | 15 +++++++++
> >  drivers/mmc/host/tmio_mmc_core.c              | 33
> > +++++++++++++++++++
> >  include/linux/mfd/tmio.h                      |  3 ++
> >  5 files changed, 54 insertions(+), 2 deletions(-)
> > 
> 
> I reviewed this series, looks good to me.
> I can apply this series if there are no other comments.
> 
> Reviewed-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.x90@mail.toshiba>

Thank you, I added your "Reviewed-by" tag and pushed the series.

Best regards,
								Pavel
-- 
In cooperation with DENX Software Engineering GmbH, HRB 165235 Munich,
Office: Kirchenstr.5, D-82194 Groebenzell, Germany

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-12-16 20:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-15 12:52 [PATCH 5.10.y-cip 0/3] Add 64-bit polling support Biju
2025-12-15 12:53 ` [PATCH 5.10.y-cip 1/3] mmc: tmio: Add 64-bit read/write support for SD_BUF0 in polling mode Biju
2025-12-15 12:53 ` [PATCH 5.10.y-cip 2/3] mmc: renesas_sdhi: Enable 64-bit " Biju
2025-12-15 12:53 ` [PATCH 5.10.y-cip 3/3] mmc: renesas_sdhi: Replace magic number '0xff' in renesas_sdhi_set_clock() Biju
2025-12-16 10:25 ` [PATCH 5.10.y-cip 0/3] Add 64-bit polling support Pavel Machek
2025-12-16 13:09 ` nobuhiro.iwamatsu.x90
2025-12-16 20:45   ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox