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.
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>
---
RFT->v2:
* Collected tags
* Fixed the buid error reported by the bot by guarding the code with
CONFIG_64BIT.
---
drivers/mmc/host/tmio_mmc.h | 14 +++++++++++++
drivers/mmc/host/tmio_mmc_core.c | 33 ++++++++++++++++++++++++++++++
include/linux/platform_data/tmio.h | 3 +++
3 files changed, 50 insertions(+)
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index d730b7633ae1..8cf9be9833b2 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -242,6 +242,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)
+{
+ ioread64_rep(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)
+{
+ iowrite64_rep(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 21c2f9095bac..775e0d9353d5 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -349,6 +349,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/platform_data/tmio.h b/include/linux/platform_data/tmio.h
index b060124ba1ae..426291713b83 100644
--- a/include/linux/platform_data/tmio.h
+++ b/include/linux/platform_data/tmio.h
@@ -47,6 +47,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)
+
struct tmio_mmc_data {
void *chan_priv_tx;
void *chan_priv_rx;
--
2.43.0
Hi Biju, kernel test robot noticed the following build errors: [auto build test ERROR on linus/master] [also build test ERROR on ulf-hansson-mmc-mirror/next v6.16 next-20250729] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Biju/mmc-tmio-Add-64-bit-read-write-support-for-SD_BUF0-in-polling-mode/20250728-001022 base: linus/master patch link: https://lore.kernel.org/r/20250727160731.106312-2-biju.das.jz%40bp.renesas.com patch subject: [PATCH v2 1/2] mmc: tmio: Add 64-bit read/write support for SD_BUF0 in polling mode config: powerpc64-randconfig-001-20250730 (https://download.01.org/0day-ci/archive/20250730/202507301421.AmWhOZBk-lkp@intel.com/config) compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 78c460bbe8f1fc17e2e66b37edf419ccecbfecba) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250730/202507301421.AmWhOZBk-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202507301421.AmWhOZBk-lkp@intel.com/ All errors (new ones prefixed by >>): In file included from drivers/mmc/host/uniphier-sd.c:21: >> drivers/mmc/host/tmio_mmc.h:249:2: error: call to undeclared function 'ioread64_rep'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 249 | ioread64_rep(host->ctl + (addr << host->bus_shift), buf, count); | ^ >> drivers/mmc/host/tmio_mmc.h:255:2: error: call to undeclared function 'iowrite64_rep'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 255 | iowrite64_rep(host->ctl + (addr << host->bus_shift), buf, count); | ^ 2 errors generated. vim +/ioread64_rep +249 drivers/mmc/host/tmio_mmc.h 244 245 #ifdef CONFIG_64BIT 246 static inline void sd_ctrl_read64_rep(struct tmio_mmc_host *host, int addr, 247 u64 *buf, int count) 248 { > 249 ioread64_rep(host->ctl + (addr << host->bus_shift), buf, count); 250 } 251 252 static inline void sd_ctrl_write64_rep(struct tmio_mmc_host *host, int addr, 253 const u64 *buf, int count) 254 { > 255 iowrite64_rep(host->ctl + (addr << host->bus_shift), buf, count); 256 } 257 #endif 258 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
> In file included from drivers/mmc/host/uniphier-sd.c:21: > >> drivers/mmc/host/tmio_mmc.h:249:2: error: call to undeclared function 'ioread64_rep'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] > 249 | ioread64_rep(host->ctl + (addr << host->bus_shift), buf, count); > | ^ > >> drivers/mmc/host/tmio_mmc.h:255:2: error: call to undeclared function 'iowrite64_rep'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] > 255 | iowrite64_rep(host->ctl + (addr << host->bus_shift), buf, count); > | ^ Sigh, then the guard seems to be ARM64 after all :(
Hi Wolfram, On Wed, 30 Jul 2025 at 11:17, Wolfram Sang <wsa-dev@sang-engineering.com> wrote: > > In file included from drivers/mmc/host/uniphier-sd.c:21: > > >> drivers/mmc/host/tmio_mmc.h:249:2: error: call to undeclared function 'ioread64_rep'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] > > 249 | ioread64_rep(host->ctl + (addr << host->bus_shift), buf, count); > > | ^ > > >> drivers/mmc/host/tmio_mmc.h:255:2: error: call to undeclared function 'iowrite64_rep'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] > > 255 | iowrite64_rep(host->ctl + (addr << host->bus_shift), buf, count); > > | ^ > > Sigh, then the guard seems to be ARM64 after all :( ioread64_rep() is defined in include/asm-generic/io.h, and powerpc does include that. Perhaps drivers/mmc/host/tmio_mmc.h should just include <linux/io.h>? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
© 2016 - 2025 Red Hat, Inc.