diff mbox series

[V4,2/7] mmc: sdhci: Change SDMA address register for v4 mode

Message ID 1532340508-8749-3-git-send-email-zhang.chunyan@linaro.org
State Superseded
Headers show
Series mmc: add support for sdhci 4.0 | expand

Commit Message

Chunyan Zhang July 23, 2018, 10:08 a.m. UTC
According to the SD host controller specification version 4.10, when
Host Version 4 is enabled, SDMA uses ADMA System Address register
(05Fh-058h) instead of using SDMA System Address register to
support both 32-bit and 64-bit addressing.

Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>

---
 drivers/mmc/host/sdhci.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

kernel test robot July 23, 2018, 10:26 p.m. UTC | #1
Hi Chunyan,

I love your patch! Perhaps something to improve:

[auto build test WARNING on ulf.hansson-mmc/next]
[also build test WARNING on v4.18-rc6 next-20180723]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Chunyan-Zhang/mmc-add-support-for-sdhci-4-0/20180724-045328
base:   git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git next
config: arm-exynos_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=arm 

All warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:14:0,
                    from include/linux/delay.h:22,
                    from drivers/mmc/host/sdhci.c:16:
   drivers/mmc/host/sdhci.c: In function 'sdhci_data_irq':
>> drivers/mmc/host/sdhci.c:43:11: warning: format '%p' expects argument of type 'void *', but argument 4 has type 'dma_addr_t {aka unsigned int}' [-Wformat=]

     pr_debug("%s: " DRIVER_NAME ": " f, mmc_hostname(host->mmc), ## x)
              ^
   include/linux/printk.h:288:21: note: in definition of macro 'pr_fmt'
    #define pr_fmt(fmt) fmt
                        ^~~
   include/linux/printk.h:336:2: note: in expansion of macro 'dynamic_pr_debug'
     dynamic_pr_debug(fmt, ##__VA_ARGS__)
     ^~~~~~~~~~~~~~~~
   drivers/mmc/host/sdhci.c:43:2: note: in expansion of macro 'pr_debug'
     pr_debug("%s: " DRIVER_NAME ": " f, mmc_hostname(host->mmc), ## x)
     ^~~~~~~~
   drivers/mmc/host/sdhci.c:2849:4: note: in expansion of macro 'DBG'
       DBG("DMA base %pad, transferred 0x%06x bytes, next %pad\n",
       ^~~
   drivers/mmc/host/sdhci.c:2849:19: note: format string is defined here
       DBG("DMA base %pad, transferred 0x%06x bytes, next %pad\n",
                     ~^
                     %d
   In file included from include/linux/kernel.h:14:0,
                    from include/linux/delay.h:22,
                    from drivers/mmc/host/sdhci.c:16:
   drivers/mmc/host/sdhci.c:43:11: warning: format '%p' expects argument of type 'void *', but argument 6 has type 'dma_addr_t {aka unsigned int}' [-Wformat=]
     pr_debug("%s: " DRIVER_NAME ": " f, mmc_hostname(host->mmc), ## x)
              ^
   include/linux/printk.h:288:21: note: in definition of macro 'pr_fmt'
    #define pr_fmt(fmt) fmt
                        ^~~
   include/linux/printk.h:336:2: note: in expansion of macro 'dynamic_pr_debug'
     dynamic_pr_debug(fmt, ##__VA_ARGS__)
     ^~~~~~~~~~~~~~~~
   drivers/mmc/host/sdhci.c:43:2: note: in expansion of macro 'pr_debug'
     pr_debug("%s: " DRIVER_NAME ": " f, mmc_hostname(host->mmc), ## x)
     ^~~~~~~~
   drivers/mmc/host/sdhci.c:2849:4: note: in expansion of macro 'DBG'
       DBG("DMA base %pad, transferred 0x%06x bytes, next %pad\n",
       ^~~
   drivers/mmc/host/sdhci.c:2849:56: note: format string is defined here
       DBG("DMA base %pad, transferred 0x%06x bytes, next %pad\n",
                                                          ~^
                                                          %d

vim +43 drivers/mmc/host/sdhci.c

d129bceb1 drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24 @16  #include <linux/delay.h>
5a436cc0a drivers/mmc/host/sdhci.c Adrian Hunter         2017-03-20  17  #include <linux/ktime.h>
d129bceb1 drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  18  #include <linux/highmem.h>
b8c86fc5d drivers/mmc/host/sdhci.c Pierre Ossman         2008-03-18  19  #include <linux/io.h>
88b476797 drivers/mmc/host/sdhci.c Paul Gortmaker        2011-07-03  20  #include <linux/module.h>
d129bceb1 drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  21  #include <linux/dma-mapping.h>
5a0e3ad6a drivers/mmc/host/sdhci.c Tejun Heo             2010-03-24  22  #include <linux/slab.h>
117636092 drivers/mmc/host/sdhci.c Ralf Baechle          2007-10-23  23  #include <linux/scatterlist.h>
bd9b90279 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  24  #include <linux/sizes.h>
250dcd114 drivers/mmc/host/sdhci.c Ulf Hansson           2017-11-27  25  #include <linux/swiotlb.h>
9bea3c850 drivers/mmc/host/sdhci.c Marek Szyprowski      2010-08-10  26  #include <linux/regulator/consumer.h>
66fd8ad51 drivers/mmc/host/sdhci.c Adrian Hunter         2011-10-03  27  #include <linux/pm_runtime.h>
92e0c44b9 drivers/mmc/host/sdhci.c Zach Brown            2016-11-02  28  #include <linux/of.h>
d129bceb1 drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  29  
2f730fec8 drivers/mmc/host/sdhci.c Pierre Ossman         2008-03-17  30  #include <linux/leds.h>
2f730fec8 drivers/mmc/host/sdhci.c Pierre Ossman         2008-03-17  31  
22113efd0 drivers/mmc/host/sdhci.c Aries Lee             2010-12-15  32  #include <linux/mmc/mmc.h>
d129bceb1 drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  33  #include <linux/mmc/host.h>
473b095a7 drivers/mmc/host/sdhci.c Aaron Lu              2012-07-03  34  #include <linux/mmc/card.h>
85cc1c331 drivers/mmc/host/sdhci.c Corneliu Doban        2015-02-09  35  #include <linux/mmc/sdio.h>
bec9d4e59 drivers/mmc/host/sdhci.c Guennadi Liakhovetski 2012-09-17  36  #include <linux/mmc/slot-gpio.h>
d129bceb1 drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  37  
d129bceb1 drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  38  #include "sdhci.h"
d129bceb1 drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  39  
d129bceb1 drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  40  #define DRIVER_NAME "sdhci"
d129bceb1 drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  41  
d129bceb1 drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  42  #define DBG(f, x...) \
f421865d5 drivers/mmc/host/sdhci.c Adrian Hunter         2017-03-20 @43  	pr_debug("%s: " DRIVER_NAME ": " f, mmc_hostname(host->mmc), ## x)
d129bceb1 drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  44  

:::::: The code at line 43 was first introduced by commit
:::::: f421865d5b4ce57013040fb1700edceb43a14b42 mmc: sdhci: Improve debug print format

:::::: TO: Adrian Hunter <adrian.hunter@intel.com>
:::::: CC: Ulf Hansson <ulf.hansson@linaro.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot July 23, 2018, 10:28 p.m. UTC | #2
Hi Chunyan,

I love your patch! Perhaps something to improve:

[auto build test WARNING on ulf.hansson-mmc/next]
[also build test WARNING on v4.18-rc6 next-20180723]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Chunyan-Zhang/mmc-add-support-for-sdhci-4-0/20180724-045328
base:   git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git next
config: arm-multi_v7_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=arm 

All warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:14:0,
                    from include/linux/delay.h:22,
                    from drivers/mmc//host/sdhci.c:16:
   drivers/mmc//host/sdhci.c: In function 'sdhci_data_irq':
>> include/linux/kern_levels.h:5:18: warning: format '%p' expects argument of type 'void *', but argument 3 has type 'dma_addr_t {aka unsigned int}' [-Wformat=]

    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/printk.h:136:10: note: in definition of macro 'no_printk'
      printk(fmt, ##__VA_ARGS__);  \
             ^~~
   include/linux/kern_levels.h:15:20: note: in expansion of macro 'KERN_SOH'
    #define KERN_DEBUG KERN_SOH "7" /* debug-level messages */
                       ^~~~~~~~
   include/linux/printk.h:342:12: note: in expansion of macro 'KERN_DEBUG'
     no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
               ^~~~~~~~~~
   drivers/mmc//host/sdhci.c:43:2: note: in expansion of macro 'pr_debug'
     pr_debug("%s: " DRIVER_NAME ": " f, mmc_hostname(host->mmc), ## x)
     ^~~~~~~~
   drivers/mmc//host/sdhci.c:2849:4: note: in expansion of macro 'DBG'
       DBG("DMA base %pad, transferred 0x%06x bytes, next %pad\n",
       ^~~
   drivers/mmc//host/sdhci.c:2849:19: note: format string is defined here
       DBG("DMA base %pad, transferred 0x%06x bytes, next %pad\n",
                     ~^
                     %d
   In file included from include/linux/kernel.h:14:0,
                    from include/linux/delay.h:22,
                    from drivers/mmc//host/sdhci.c:16:
   include/linux/kern_levels.h:5:18: warning: format '%p' expects argument of type 'void *', but argument 5 has type 'dma_addr_t {aka unsigned int}' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/printk.h:136:10: note: in definition of macro 'no_printk'
      printk(fmt, ##__VA_ARGS__);  \
             ^~~
   include/linux/kern_levels.h:15:20: note: in expansion of macro 'KERN_SOH'
    #define KERN_DEBUG KERN_SOH "7" /* debug-level messages */
                       ^~~~~~~~
   include/linux/printk.h:342:12: note: in expansion of macro 'KERN_DEBUG'
     no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
               ^~~~~~~~~~
   drivers/mmc//host/sdhci.c:43:2: note: in expansion of macro 'pr_debug'
     pr_debug("%s: " DRIVER_NAME ": " f, mmc_hostname(host->mmc), ## x)
     ^~~~~~~~
   drivers/mmc//host/sdhci.c:2849:4: note: in expansion of macro 'DBG'
       DBG("DMA base %pad, transferred 0x%06x bytes, next %pad\n",
       ^~~
   drivers/mmc//host/sdhci.c:2849:56: note: format string is defined here
       DBG("DMA base %pad, transferred 0x%06x bytes, next %pad\n",
                                                          ~^
                                                          %d
--
   In file included from include/linux/kernel.h:14:0,
                    from include/linux/delay.h:22,
                    from drivers/mmc/host/sdhci.c:16:
   drivers/mmc/host/sdhci.c: In function 'sdhci_data_irq':
>> include/linux/kern_levels.h:5:18: warning: format '%p' expects argument of type 'void *', but argument 3 has type 'dma_addr_t {aka unsigned int}' [-Wformat=]

    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/printk.h:136:10: note: in definition of macro 'no_printk'
      printk(fmt, ##__VA_ARGS__);  \
             ^~~
   include/linux/kern_levels.h:15:20: note: in expansion of macro 'KERN_SOH'
    #define KERN_DEBUG KERN_SOH "7" /* debug-level messages */
                       ^~~~~~~~
   include/linux/printk.h:342:12: note: in expansion of macro 'KERN_DEBUG'
     no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
               ^~~~~~~~~~
   drivers/mmc/host/sdhci.c:43:2: note: in expansion of macro 'pr_debug'
     pr_debug("%s: " DRIVER_NAME ": " f, mmc_hostname(host->mmc), ## x)
     ^~~~~~~~
   drivers/mmc/host/sdhci.c:2849:4: note: in expansion of macro 'DBG'
       DBG("DMA base %pad, transferred 0x%06x bytes, next %pad\n",
       ^~~
   drivers/mmc/host/sdhci.c:2849:19: note: format string is defined here
       DBG("DMA base %pad, transferred 0x%06x bytes, next %pad\n",
                     ~^
                     %d
   In file included from include/linux/kernel.h:14:0,
                    from include/linux/delay.h:22,
                    from drivers/mmc/host/sdhci.c:16:
   include/linux/kern_levels.h:5:18: warning: format '%p' expects argument of type 'void *', but argument 5 has type 'dma_addr_t {aka unsigned int}' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/printk.h:136:10: note: in definition of macro 'no_printk'
      printk(fmt, ##__VA_ARGS__);  \
             ^~~
   include/linux/kern_levels.h:15:20: note: in expansion of macro 'KERN_SOH'
    #define KERN_DEBUG KERN_SOH "7" /* debug-level messages */
                       ^~~~~~~~
   include/linux/printk.h:342:12: note: in expansion of macro 'KERN_DEBUG'
     no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
               ^~~~~~~~~~
   drivers/mmc/host/sdhci.c:43:2: note: in expansion of macro 'pr_debug'
     pr_debug("%s: " DRIVER_NAME ": " f, mmc_hostname(host->mmc), ## x)
     ^~~~~~~~
   drivers/mmc/host/sdhci.c:2849:4: note: in expansion of macro 'DBG'
       DBG("DMA base %pad, transferred 0x%06x bytes, next %pad\n",
       ^~~
   drivers/mmc/host/sdhci.c:2849:56: note: format string is defined here
       DBG("DMA base %pad, transferred 0x%06x bytes, next %pad\n",
                                                          ~^
                                                          %d

vim +5 include/linux/kern_levels.h

314ba352 Joe Perches 2012-07-30  4  
04d2c8c8 Joe Perches 2012-07-30 @5  #define KERN_SOH	"\001"		/* ASCII Start Of Header */
04d2c8c8 Joe Perches 2012-07-30  6  #define KERN_SOH_ASCII	'\001'
04d2c8c8 Joe Perches 2012-07-30  7  

:::::: The code at line 5 was first introduced by commit
:::::: 04d2c8c83d0e3ac5f78aeede51babb3236200112 printk: convert the format for KERN_<LEVEL> to a 2 byte pattern

:::::: TO: Joe Perches <joe@perches.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index cab5350..9cb17c0 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -729,7 +729,7 @@  static void sdhci_adma_table_post(struct sdhci_host *host,
 	}
 }
 
-static u32 sdhci_sdma_address(struct sdhci_host *host)
+static dma_addr_t sdhci_sdma_address(struct sdhci_host *host)
 {
 	if (host->bounce_buffer)
 		return host->bounce_addr;
@@ -737,6 +737,18 @@  static u32 sdhci_sdma_address(struct sdhci_host *host)
 		return sg_dma_address(host->data->sg);
 }
 
+static void sdhci_set_sdma_addr(struct sdhci_host *host, dma_addr_t addr)
+{
+	if (host->v4_mode) {
+		sdhci_writel(host, addr, SDHCI_ADMA_ADDRESS);
+		if (host->flags & SDHCI_USE_64_BIT_DMA)
+			sdhci_writel(host, (u64)addr >> 32, SDHCI_ADMA_ADDRESS_HI);
+	} else {
+		sdhci_writel(host, addr, SDHCI_DMA_ADDRESS);
+	}
+
+}
+
 static unsigned int sdhci_target_timeout(struct sdhci_host *host,
 					 struct mmc_command *cmd,
 					 struct mmc_data *data)
@@ -996,8 +1008,7 @@  static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd)
 					     SDHCI_ADMA_ADDRESS_HI);
 		} else {
 			WARN_ON(sg_cnt != 1);
-			sdhci_writel(host, sdhci_sdma_address(host),
-				     SDHCI_DMA_ADDRESS);
+			sdhci_set_sdma_addr(host, sdhci_sdma_address(host));
 		}
 	}
 
@@ -2824,7 +2835,7 @@  static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
 		 * some controllers are faulty, don't trust them.
 		 */
 		if (intmask & SDHCI_INT_DMA_END) {
-			u32 dmastart, dmanow;
+			dma_addr_t dmastart, dmanow;
 
 			dmastart = sdhci_sdma_address(host);
 			dmanow = dmastart + host->data->bytes_xfered;
@@ -2832,12 +2843,12 @@  static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
 			 * Force update to the next DMA block boundary.
 			 */
 			dmanow = (dmanow &
-				~(SDHCI_DEFAULT_BOUNDARY_SIZE - 1)) +
+				~((dma_addr_t)SDHCI_DEFAULT_BOUNDARY_SIZE - 1)) +
 				SDHCI_DEFAULT_BOUNDARY_SIZE;
 			host->data->bytes_xfered = dmanow - dmastart;
-			DBG("DMA base 0x%08x, transferred 0x%06x bytes, next 0x%08x\n",
+			DBG("DMA base %pad, transferred 0x%06x bytes, next %pad\n",
 			    dmastart, host->data->bytes_xfered, dmanow);
-			sdhci_writel(host, dmanow, SDHCI_DMA_ADDRESS);
+			sdhci_set_sdma_addr(host, dmanow);
 		}
 
 		if (intmask & SDHCI_INT_DATA_END) {
@@ -3581,8 +3592,8 @@  int sdhci_setup_host(struct sdhci_host *host)
 		}
 	}
 
-	/* SDMA does not support 64-bit DMA */
-	if (host->flags & SDHCI_USE_64_BIT_DMA)
+	/* SDMA does not support 64-bit DMA if v4 mode not set */
+	if ((host->flags & SDHCI_USE_64_BIT_DMA) && !host->v4_mode)
 		host->flags &= ~SDHCI_USE_SDMA;
 
 	if (host->flags & SDHCI_USE_ADMA) {