2021-05-10 21:38:27

by Dmitry Osipenko

[permalink] [raw]
Subject: [PATCH v1 0/2] Enable compile-testing for Tegra memory drivers

Hi,

This small series enables compile-testing for all of NVIDIA Tegra memory
drivers.

Dmitry Osipenko (2):
soc/tegra: fuse: Add missing stubs
memory: tegra: Enable compile testing for all drivers

drivers/memory/tegra/Kconfig | 10 +++++-----
include/soc/tegra/fuse.h | 20 +++++++++++++++++---
2 files changed, 22 insertions(+), 8 deletions(-)

--
2.30.2


2021-05-10 21:38:40

by Dmitry Osipenko

[permalink] [raw]
Subject: [PATCH v1 1/2] soc/tegra: fuse: Add missing stubs

Add missing stubs that will allow Tegra memory driver to be compile-tested
by kernel build bots.

Signed-off-by: Dmitry Osipenko <[email protected]>
---
include/soc/tegra/fuse.h | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/include/soc/tegra/fuse.h b/include/soc/tegra/fuse.h
index 78cbc787a4dc..990701f788bc 100644
--- a/include/soc/tegra/fuse.h
+++ b/include/soc/tegra/fuse.h
@@ -52,14 +52,28 @@ struct tegra_sku_info {
enum tegra_revision revision;
};

+#ifdef CONFIG_ARCH_TEGRA
+extern struct tegra_sku_info tegra_sku_info;
u32 tegra_read_straps(void);
u32 tegra_read_ram_code(void);
int tegra_fuse_readl(unsigned long offset, u32 *value);
-
-#ifdef CONFIG_ARCH_TEGRA
-extern struct tegra_sku_info tegra_sku_info;
#else
static struct tegra_sku_info tegra_sku_info __maybe_unused;
+
+static inline u32 tegra_read_straps(void)
+{
+ return 0;
+}
+
+static inline u32 tegra_read_ram_code(void)
+{
+ return 0;
+}
+
+static inline int tegra_fuse_readl(unsigned long offset, u32 *value)
+{
+ return -ENODEV;
+}
#endif

struct device *tegra_soc_device_register(void);
--
2.30.2

2021-05-10 21:40:00

by Dmitry Osipenko

[permalink] [raw]
Subject: [PATCH v1 2/2] memory: tegra: Enable compile testing for all drivers

Enable compile testing for all Tegra memory drivers.

Signed-off-by: Dmitry Osipenko <[email protected]>
---
drivers/memory/tegra/Kconfig | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/memory/tegra/Kconfig b/drivers/memory/tegra/Kconfig
index a70967a56e52..a910f661105f 100644
--- a/drivers/memory/tegra/Kconfig
+++ b/drivers/memory/tegra/Kconfig
@@ -2,7 +2,7 @@
config TEGRA_MC
bool "NVIDIA Tegra Memory Controller support"
default y
- depends on ARCH_TEGRA
+ depends on (ARCH_TEGRA || COMPILE_TEST)
select INTERCONNECT
help
This driver supports the Memory Controller (MC) hardware found on
@@ -11,7 +11,7 @@ config TEGRA_MC
config TEGRA20_EMC
tristate "NVIDIA Tegra20 External Memory Controller driver"
default y
- depends on TEGRA_MC && ARCH_TEGRA_2x_SOC
+ depends on TEGRA_MC && (ARCH_TEGRA_2x_SOC || COMPILE_TEST)
select DEVFREQ_GOV_SIMPLE_ONDEMAND
select PM_DEVFREQ
help
@@ -23,7 +23,7 @@ config TEGRA20_EMC
config TEGRA30_EMC
tristate "NVIDIA Tegra30 External Memory Controller driver"
default y
- depends on TEGRA_MC && ARCH_TEGRA_3x_SOC
+ depends on TEGRA_MC && (ARCH_TEGRA_3x_SOC || COMPILE_TEST)
select PM_OPP
help
This driver is for the External Memory Controller (EMC) found on
@@ -34,7 +34,7 @@ config TEGRA30_EMC
config TEGRA124_EMC
tristate "NVIDIA Tegra124 External Memory Controller driver"
default y
- depends on TEGRA_MC && ARCH_TEGRA_124_SOC
+ depends on TEGRA_MC && (ARCH_TEGRA_124_SOC || COMPILE_TEST)
select TEGRA124_CLK_EMC
select PM_OPP
help
@@ -49,7 +49,7 @@ config TEGRA210_EMC_TABLE

config TEGRA210_EMC
tristate "NVIDIA Tegra210 External Memory Controller driver"
- depends on TEGRA_MC && ARCH_TEGRA_210_SOC
+ depends on TEGRA_MC && (ARCH_TEGRA_210_SOC || COMPILE_TEST)
select TEGRA210_EMC_TABLE
help
This driver is for the External Memory Controller (EMC) found on
--
2.30.2

2021-05-11 14:00:12

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] memory: tegra: Enable compile testing for all drivers

Hi Dmitry,

I love your patch! Perhaps something to improve:

[auto build test WARNING on tegra/for-next]
[also build test WARNING on v5.13-rc1 next-20210511]
[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]

url: https://github.com/0day-ci/linux/commits/Dmitry-Osipenko/Enable-compile-testing-for-Tegra-memory-drivers/20210511-053910
base: https://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux.git for-next
config: powerpc-randconfig-r032-20210511 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project a0fed635fe1701470062495a6ffee1c608f3f1bc)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install powerpc cross compiling tool for clang build
# apt-get install binutils-powerpc-linux-gnu
# https://github.com/0day-ci/linux/commit/ecd67b1d49eb33c9821130a2b3b896bab395118d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dmitry-Osipenko/Enable-compile-testing-for-Tegra-memory-drivers/20210511-053910
git checkout ecd67b1d49eb33c9821130a2b3b896bab395118d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=powerpc

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

__do_insb
^
arch/powerpc/include/asm/io.h:556:56: note: expanded from macro '__do_insb'
#define __do_insb(p, b, n) readsb((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from drivers/memory/tegra/tegra30-emc.c:18:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:10:
In file included from arch/powerpc/include/asm/hardirq.h:6:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:45:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:211:1: note: expanded from here
__do_insw
^
arch/powerpc/include/asm/io.h:557:56: note: expanded from macro '__do_insw'
#define __do_insw(p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from drivers/memory/tegra/tegra30-emc.c:18:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:10:
In file included from arch/powerpc/include/asm/hardirq.h:6:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:213:1: note: expanded from here
__do_insl
^
arch/powerpc/include/asm/io.h:558:56: note: expanded from macro '__do_insl'
#define __do_insl(p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from drivers/memory/tegra/tegra30-emc.c:18:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:10:
In file included from arch/powerpc/include/asm/hardirq.h:6:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:215:1: note: expanded from here
__do_outsb
^
arch/powerpc/include/asm/io.h:559:58: note: expanded from macro '__do_outsb'
#define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from drivers/memory/tegra/tegra30-emc.c:18:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:10:
In file included from arch/powerpc/include/asm/hardirq.h:6:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:217:1: note: expanded from here
__do_outsw
^
arch/powerpc/include/asm/io.h:560:58: note: expanded from macro '__do_outsw'
#define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from drivers/memory/tegra/tegra30-emc.c:18:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:10:
In file included from arch/powerpc/include/asm/hardirq.h:6:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:219:1: note: expanded from here
__do_outsl
^
arch/powerpc/include/asm/io.h:561:58: note: expanded from macro '__do_outsl'
#define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~~~~~~~~~~~~~~~~~~~~~^
>> drivers/memory/tegra/tegra30-emc.c:757:18: warning: implicit conversion from 'unsigned long' to 'u32' (aka 'unsigned int') changes value from 18446744071562067985 to 2147483665 [-Wconstant-conversion]
writel_relaxed(EMC_ZQ_CAL_LONG_CMD_DEV0,
~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/memory/tegra/tegra30-emc.c:161:36: note: expanded from macro 'EMC_ZQ_CAL_LONG_CMD_DEV0'
(DRAM_DEV_SEL_0 | EMC_ZQ_CAL_LONG | EMC_ZQ_CAL_CMD)
^
arch/powerpc/include/asm/io.h:679:40: note: expanded from macro 'writel_relaxed'
#define writel_relaxed(v, addr) writel(v, addr)
~~~~~~ ^
13 warnings generated.
--
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:203:1: note: expanded from here
__do_outl
^
arch/powerpc/include/asm/io.h:537:62: note: expanded from macro '__do_outl'
#define __do_outl(val, port) writel(val,(PCI_IO_ADDR)_IO_BASE+port);
~~~~~~~~~~~~~~~~~~~~~^
In file included from drivers/memory/tegra/tegra124-emc.c:16:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:43:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(insb, (unsigned long p, void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:217:1: note: expanded from here
__do_insb
^
arch/powerpc/include/asm/io.h:556:56: note: expanded from macro '__do_insb'
#define __do_insb(p, b, n) readsb((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from drivers/memory/tegra/tegra124-emc.c:16:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:45:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:219:1: note: expanded from here
__do_insw
^
arch/powerpc/include/asm/io.h:557:56: note: expanded from macro '__do_insw'
#define __do_insw(p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from drivers/memory/tegra/tegra124-emc.c:16:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:221:1: note: expanded from here
__do_insl
^
arch/powerpc/include/asm/io.h:558:56: note: expanded from macro '__do_insl'
#define __do_insl(p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from drivers/memory/tegra/tegra124-emc.c:16:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:223:1: note: expanded from here
__do_outsb
^
arch/powerpc/include/asm/io.h:559:58: note: expanded from macro '__do_outsb'
#define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from drivers/memory/tegra/tegra124-emc.c:16:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:225:1: note: expanded from here
__do_outsw
^
arch/powerpc/include/asm/io.h:560:58: note: expanded from macro '__do_outsw'
#define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from drivers/memory/tegra/tegra124-emc.c:16:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:227:1: note: expanded from here
__do_outsl
^
arch/powerpc/include/asm/io.h:561:58: note: expanded from macro '__do_outsl'
#define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~~~~~~~~~~~~~~~~~~~~~^
>> drivers/memory/tegra/tegra124-emc.c:802:26: warning: implicit conversion from 'unsigned long' to 'u32' (aka 'unsigned int') changes value from 18446744071562067985 to 2147483665 [-Wconstant-conversion]
emc_ccfifo_writel(emc, EMC_ZQ_CAL_LONG_CMD_DEV0, EMC_ZQ_CAL);
~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/memory/tegra/tegra124-emc.c:154:36: note: expanded from macro 'EMC_ZQ_CAL_LONG_CMD_DEV0'
(DRAM_DEV_SEL_0 | EMC_ZQ_CAL_LONG | EMC_ZQ_CAL_CMD)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
13 warnings generated.


vim +757 drivers/memory/tegra/tegra30-emc.c

e34212c75a6899 Dmitry Osipenko 2019-08-12 507
e34212c75a6899 Dmitry Osipenko 2019-08-12 508 static int emc_prepare_timing_change(struct tegra_emc *emc, unsigned long rate)
e34212c75a6899 Dmitry Osipenko 2019-08-12 509 {
e34212c75a6899 Dmitry Osipenko 2019-08-12 510 struct emc_timing *timing = emc_find_timing(emc, rate);
e34212c75a6899 Dmitry Osipenko 2019-08-12 511 enum emc_dll_change dll_change;
e34212c75a6899 Dmitry Osipenko 2019-08-12 512 enum emc_dram_type dram_type;
e34212c75a6899 Dmitry Osipenko 2019-08-12 513 bool schmitt_to_vref = false;
e34212c75a6899 Dmitry Osipenko 2019-08-12 514 unsigned int pre_wait = 0;
e34212c75a6899 Dmitry Osipenko 2019-08-12 515 bool qrst_used = false;
e34212c75a6899 Dmitry Osipenko 2019-08-12 516 unsigned int dram_num;
e34212c75a6899 Dmitry Osipenko 2019-08-12 517 unsigned int i;
e34212c75a6899 Dmitry Osipenko 2019-08-12 518 u32 fbio_cfg5;
e34212c75a6899 Dmitry Osipenko 2019-08-12 519 u32 emc_dbg;
e34212c75a6899 Dmitry Osipenko 2019-08-12 520 u32 val;
e34212c75a6899 Dmitry Osipenko 2019-08-12 521 int err;
e34212c75a6899 Dmitry Osipenko 2019-08-12 522
e34212c75a6899 Dmitry Osipenko 2019-08-12 523 if (!timing || emc->bad_state)
e34212c75a6899 Dmitry Osipenko 2019-08-12 524 return -EINVAL;
e34212c75a6899 Dmitry Osipenko 2019-08-12 525
e34212c75a6899 Dmitry Osipenko 2019-08-12 526 dev_dbg(emc->dev, "%s: using timing rate %lu for requested rate %lu\n",
e34212c75a6899 Dmitry Osipenko 2019-08-12 527 __func__, timing->rate, rate);
e34212c75a6899 Dmitry Osipenko 2019-08-12 528
e34212c75a6899 Dmitry Osipenko 2019-08-12 529 emc->bad_state = true;
e34212c75a6899 Dmitry Osipenko 2019-08-12 530
e34212c75a6899 Dmitry Osipenko 2019-08-12 531 err = emc_prepare_mc_clk_cfg(emc, rate);
e34212c75a6899 Dmitry Osipenko 2019-08-12 532 if (err) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 533 dev_err(emc->dev, "mc clock preparation failed: %d\n", err);
e34212c75a6899 Dmitry Osipenko 2019-08-12 534 return err;
e34212c75a6899 Dmitry Osipenko 2019-08-12 535 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 536
e34212c75a6899 Dmitry Osipenko 2019-08-12 537 emc->vref_cal_toggle = false;
e34212c75a6899 Dmitry Osipenko 2019-08-12 538 emc->mc_override = mc_readl(emc->mc, MC_EMEM_ARB_OVERRIDE);
e34212c75a6899 Dmitry Osipenko 2019-08-12 539 emc->emc_cfg = readl_relaxed(emc->regs + EMC_CFG);
e34212c75a6899 Dmitry Osipenko 2019-08-12 540 emc_dbg = readl_relaxed(emc->regs + EMC_DBG);
e34212c75a6899 Dmitry Osipenko 2019-08-12 541
e34212c75a6899 Dmitry Osipenko 2019-08-12 542 if (emc->dll_on == !!(timing->emc_mode_1 & 0x1))
e34212c75a6899 Dmitry Osipenko 2019-08-12 543 dll_change = DLL_CHANGE_NONE;
e34212c75a6899 Dmitry Osipenko 2019-08-12 544 else if (timing->emc_mode_1 & 0x1)
e34212c75a6899 Dmitry Osipenko 2019-08-12 545 dll_change = DLL_CHANGE_ON;
e34212c75a6899 Dmitry Osipenko 2019-08-12 546 else
e34212c75a6899 Dmitry Osipenko 2019-08-12 547 dll_change = DLL_CHANGE_OFF;
e34212c75a6899 Dmitry Osipenko 2019-08-12 548
e34212c75a6899 Dmitry Osipenko 2019-08-12 549 emc->dll_on = !!(timing->emc_mode_1 & 0x1);
e34212c75a6899 Dmitry Osipenko 2019-08-12 550
e34212c75a6899 Dmitry Osipenko 2019-08-12 551 if (timing->data[80] && !readl_relaxed(emc->regs + EMC_ZCAL_INTERVAL))
e34212c75a6899 Dmitry Osipenko 2019-08-12 552 emc->zcal_long = true;
e34212c75a6899 Dmitry Osipenko 2019-08-12 553 else
e34212c75a6899 Dmitry Osipenko 2019-08-12 554 emc->zcal_long = false;
e34212c75a6899 Dmitry Osipenko 2019-08-12 555
e34212c75a6899 Dmitry Osipenko 2019-08-12 556 fbio_cfg5 = readl_relaxed(emc->regs + EMC_FBIO_CFG5);
e34212c75a6899 Dmitry Osipenko 2019-08-12 557 dram_type = fbio_cfg5 & EMC_FBIO_CFG5_DRAM_TYPE_MASK;
e34212c75a6899 Dmitry Osipenko 2019-08-12 558
e34212c75a6899 Dmitry Osipenko 2019-08-12 559 dram_num = tegra_mc_get_emem_device_count(emc->mc);
e34212c75a6899 Dmitry Osipenko 2019-08-12 560
e34212c75a6899 Dmitry Osipenko 2019-08-12 561 /* disable dynamic self-refresh */
e34212c75a6899 Dmitry Osipenko 2019-08-12 562 if (emc->emc_cfg & EMC_CFG_DYN_SREF_ENABLE) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 563 emc->emc_cfg &= ~EMC_CFG_DYN_SREF_ENABLE;
e34212c75a6899 Dmitry Osipenko 2019-08-12 564 writel_relaxed(emc->emc_cfg, emc->regs + EMC_CFG);
e34212c75a6899 Dmitry Osipenko 2019-08-12 565
e34212c75a6899 Dmitry Osipenko 2019-08-12 566 pre_wait = 5;
e34212c75a6899 Dmitry Osipenko 2019-08-12 567 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 568
e34212c75a6899 Dmitry Osipenko 2019-08-12 569 /* update MC arbiter settings */
e34212c75a6899 Dmitry Osipenko 2019-08-12 570 val = mc_readl(emc->mc, MC_EMEM_ARB_OUTSTANDING_REQ);
e34212c75a6899 Dmitry Osipenko 2019-08-12 571 if (!(val & MC_EMEM_ARB_OUTSTANDING_REQ_HOLDOFF_OVERRIDE) ||
e34212c75a6899 Dmitry Osipenko 2019-08-12 572 ((val & MC_EMEM_ARB_OUTSTANDING_REQ_MAX_MASK) > 0x50)) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 573
e34212c75a6899 Dmitry Osipenko 2019-08-12 574 val = MC_EMEM_ARB_OUTSTANDING_REQ_LIMIT_ENABLE |
e34212c75a6899 Dmitry Osipenko 2019-08-12 575 MC_EMEM_ARB_OUTSTANDING_REQ_HOLDOFF_OVERRIDE | 0x50;
e34212c75a6899 Dmitry Osipenko 2019-08-12 576 mc_writel(emc->mc, val, MC_EMEM_ARB_OUTSTANDING_REQ);
e34212c75a6899 Dmitry Osipenko 2019-08-12 577 mc_writel(emc->mc, MC_TIMING_UPDATE, MC_TIMING_CONTROL);
e34212c75a6899 Dmitry Osipenko 2019-08-12 578 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 579
e34212c75a6899 Dmitry Osipenko 2019-08-12 580 if (emc->mc_override & MC_EMEM_ARB_OVERRIDE_EACK_MASK)
e34212c75a6899 Dmitry Osipenko 2019-08-12 581 mc_writel(emc->mc,
e34212c75a6899 Dmitry Osipenko 2019-08-12 582 emc->mc_override & ~MC_EMEM_ARB_OVERRIDE_EACK_MASK,
e34212c75a6899 Dmitry Osipenko 2019-08-12 583 MC_EMEM_ARB_OVERRIDE);
e34212c75a6899 Dmitry Osipenko 2019-08-12 584
e34212c75a6899 Dmitry Osipenko 2019-08-12 585 /* check DQ/DQS VREF delay */
e34212c75a6899 Dmitry Osipenko 2019-08-12 586 if (emc_dqs_preset(emc, timing, &schmitt_to_vref)) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 587 if (pre_wait < 3)
e34212c75a6899 Dmitry Osipenko 2019-08-12 588 pre_wait = 3;
e34212c75a6899 Dmitry Osipenko 2019-08-12 589 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 590
e34212c75a6899 Dmitry Osipenko 2019-08-12 591 if (pre_wait) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 592 err = emc_seq_update_timing(emc);
e34212c75a6899 Dmitry Osipenko 2019-08-12 593 if (err)
e34212c75a6899 Dmitry Osipenko 2019-08-12 594 return err;
e34212c75a6899 Dmitry Osipenko 2019-08-12 595
e34212c75a6899 Dmitry Osipenko 2019-08-12 596 udelay(pre_wait);
e34212c75a6899 Dmitry Osipenko 2019-08-12 597 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 598
e34212c75a6899 Dmitry Osipenko 2019-08-12 599 /* disable auto-calibration if VREF mode is switching */
e34212c75a6899 Dmitry Osipenko 2019-08-12 600 if (timing->emc_auto_cal_interval) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 601 val = readl_relaxed(emc->regs + EMC_XM2COMPPADCTRL);
e34212c75a6899 Dmitry Osipenko 2019-08-12 602 val ^= timing->data[74];
e34212c75a6899 Dmitry Osipenko 2019-08-12 603
e34212c75a6899 Dmitry Osipenko 2019-08-12 604 if (val & EMC_XM2COMPPADCTRL_VREF_CAL_ENABLE) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 605 writel_relaxed(0, emc->regs + EMC_AUTO_CAL_INTERVAL);
e34212c75a6899 Dmitry Osipenko 2019-08-12 606
e34212c75a6899 Dmitry Osipenko 2019-08-12 607 err = readl_relaxed_poll_timeout_atomic(
e34212c75a6899 Dmitry Osipenko 2019-08-12 608 emc->regs + EMC_AUTO_CAL_STATUS, val,
e34212c75a6899 Dmitry Osipenko 2019-08-12 609 !(val & EMC_AUTO_CAL_STATUS_ACTIVE), 1, 300);
e34212c75a6899 Dmitry Osipenko 2019-08-12 610 if (err) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 611 dev_err(emc->dev,
5e5eca6644873d Dmitry Osipenko 2019-12-20 612 "auto-cal finish timeout: %d\n", err);
e34212c75a6899 Dmitry Osipenko 2019-08-12 613 return err;
e34212c75a6899 Dmitry Osipenko 2019-08-12 614 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 615
e34212c75a6899 Dmitry Osipenko 2019-08-12 616 emc->vref_cal_toggle = true;
e34212c75a6899 Dmitry Osipenko 2019-08-12 617 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 618 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 619
e34212c75a6899 Dmitry Osipenko 2019-08-12 620 /* program shadow registers */
e34212c75a6899 Dmitry Osipenko 2019-08-12 621 for (i = 0; i < ARRAY_SIZE(timing->data); i++) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 622 /* EMC_XM2CLKPADCTRL should be programmed separately */
e34212c75a6899 Dmitry Osipenko 2019-08-12 623 if (i != 73)
e34212c75a6899 Dmitry Osipenko 2019-08-12 624 writel_relaxed(timing->data[i],
e34212c75a6899 Dmitry Osipenko 2019-08-12 625 emc->regs + emc_timing_registers[i]);
e34212c75a6899 Dmitry Osipenko 2019-08-12 626 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 627
e34212c75a6899 Dmitry Osipenko 2019-08-12 628 err = tegra_mc_write_emem_configuration(emc->mc, timing->rate);
e34212c75a6899 Dmitry Osipenko 2019-08-12 629 if (err)
e34212c75a6899 Dmitry Osipenko 2019-08-12 630 return err;
e34212c75a6899 Dmitry Osipenko 2019-08-12 631
e34212c75a6899 Dmitry Osipenko 2019-08-12 632 /* DDR3: predict MRS long wait count */
e34212c75a6899 Dmitry Osipenko 2019-08-12 633 if (dram_type == DRAM_TYPE_DDR3 && dll_change == DLL_CHANGE_ON) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 634 u32 cnt = 512;
e34212c75a6899 Dmitry Osipenko 2019-08-12 635
e34212c75a6899 Dmitry Osipenko 2019-08-12 636 if (emc->zcal_long)
e34212c75a6899 Dmitry Osipenko 2019-08-12 637 cnt -= dram_num * 256;
e34212c75a6899 Dmitry Osipenko 2019-08-12 638
e34212c75a6899 Dmitry Osipenko 2019-08-12 639 val = timing->data[82] & EMC_MRS_WAIT_CNT_SHORT_WAIT_MASK;
e34212c75a6899 Dmitry Osipenko 2019-08-12 640 if (cnt < val)
e34212c75a6899 Dmitry Osipenko 2019-08-12 641 cnt = val;
e34212c75a6899 Dmitry Osipenko 2019-08-12 642
e34212c75a6899 Dmitry Osipenko 2019-08-12 643 val = timing->data[82] & ~EMC_MRS_WAIT_CNT_LONG_WAIT_MASK;
e34212c75a6899 Dmitry Osipenko 2019-08-12 644 val |= (cnt << EMC_MRS_WAIT_CNT_LONG_WAIT_SHIFT) &
e34212c75a6899 Dmitry Osipenko 2019-08-12 645 EMC_MRS_WAIT_CNT_LONG_WAIT_MASK;
e34212c75a6899 Dmitry Osipenko 2019-08-12 646
e34212c75a6899 Dmitry Osipenko 2019-08-12 647 writel_relaxed(val, emc->regs + EMC_MRS_WAIT_CNT);
e34212c75a6899 Dmitry Osipenko 2019-08-12 648 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 649
e34212c75a6899 Dmitry Osipenko 2019-08-12 650 /* this read also completes the writes */
e34212c75a6899 Dmitry Osipenko 2019-08-12 651 val = readl_relaxed(emc->regs + EMC_SEL_DPD_CTRL);
e34212c75a6899 Dmitry Osipenko 2019-08-12 652
e34212c75a6899 Dmitry Osipenko 2019-08-12 653 if (!(val & EMC_SEL_DPD_CTRL_QUSE_DPD_ENABLE) && schmitt_to_vref) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 654 u32 cur_mode, new_mode;
e34212c75a6899 Dmitry Osipenko 2019-08-12 655
e34212c75a6899 Dmitry Osipenko 2019-08-12 656 cur_mode = fbio_cfg5 & EMC_CFG5_QUSE_MODE_MASK;
e34212c75a6899 Dmitry Osipenko 2019-08-12 657 cur_mode >>= EMC_CFG5_QUSE_MODE_SHIFT;
e34212c75a6899 Dmitry Osipenko 2019-08-12 658
e34212c75a6899 Dmitry Osipenko 2019-08-12 659 new_mode = timing->data[39] & EMC_CFG5_QUSE_MODE_MASK;
e34212c75a6899 Dmitry Osipenko 2019-08-12 660 new_mode >>= EMC_CFG5_QUSE_MODE_SHIFT;
e34212c75a6899 Dmitry Osipenko 2019-08-12 661
e34212c75a6899 Dmitry Osipenko 2019-08-12 662 if ((cur_mode != EMC_CFG5_QUSE_MODE_PULSE_INTERN &&
e34212c75a6899 Dmitry Osipenko 2019-08-12 663 cur_mode != EMC_CFG5_QUSE_MODE_INTERNAL_LPBK) ||
e34212c75a6899 Dmitry Osipenko 2019-08-12 664 (new_mode != EMC_CFG5_QUSE_MODE_PULSE_INTERN &&
e34212c75a6899 Dmitry Osipenko 2019-08-12 665 new_mode != EMC_CFG5_QUSE_MODE_INTERNAL_LPBK))
e34212c75a6899 Dmitry Osipenko 2019-08-12 666 qrst_used = true;
e34212c75a6899 Dmitry Osipenko 2019-08-12 667 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 668
e34212c75a6899 Dmitry Osipenko 2019-08-12 669 /* flow control marker 1 */
e34212c75a6899 Dmitry Osipenko 2019-08-12 670 writel_relaxed(0x1, emc->regs + EMC_STALL_THEN_EXE_BEFORE_CLKCHANGE);
e34212c75a6899 Dmitry Osipenko 2019-08-12 671
e34212c75a6899 Dmitry Osipenko 2019-08-12 672 /* enable periodic reset */
e34212c75a6899 Dmitry Osipenko 2019-08-12 673 if (qrst_used) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 674 writel_relaxed(emc_dbg | EMC_DBG_WRITE_MUX_ACTIVE,
e34212c75a6899 Dmitry Osipenko 2019-08-12 675 emc->regs + EMC_DBG);
e34212c75a6899 Dmitry Osipenko 2019-08-12 676 writel_relaxed(emc->emc_cfg | EMC_CFG_PERIODIC_QRST,
e34212c75a6899 Dmitry Osipenko 2019-08-12 677 emc->regs + EMC_CFG);
e34212c75a6899 Dmitry Osipenko 2019-08-12 678 writel_relaxed(emc_dbg, emc->regs + EMC_DBG);
e34212c75a6899 Dmitry Osipenko 2019-08-12 679 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 680
e34212c75a6899 Dmitry Osipenko 2019-08-12 681 /* disable auto-refresh to save time after clock change */
e34212c75a6899 Dmitry Osipenko 2019-08-12 682 writel_relaxed(EMC_REFCTRL_DISABLE_ALL(dram_num),
e34212c75a6899 Dmitry Osipenko 2019-08-12 683 emc->regs + EMC_REFCTRL);
e34212c75a6899 Dmitry Osipenko 2019-08-12 684
e34212c75a6899 Dmitry Osipenko 2019-08-12 685 /* turn off DLL and enter self-refresh on DDR3 */
e34212c75a6899 Dmitry Osipenko 2019-08-12 686 if (dram_type == DRAM_TYPE_DDR3) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 687 if (dll_change == DLL_CHANGE_OFF)
e34212c75a6899 Dmitry Osipenko 2019-08-12 688 writel_relaxed(timing->emc_mode_1,
e34212c75a6899 Dmitry Osipenko 2019-08-12 689 emc->regs + EMC_EMRS);
e34212c75a6899 Dmitry Osipenko 2019-08-12 690
e34212c75a6899 Dmitry Osipenko 2019-08-12 691 writel_relaxed(DRAM_BROADCAST(dram_num) |
e34212c75a6899 Dmitry Osipenko 2019-08-12 692 EMC_SELF_REF_CMD_ENABLED,
e34212c75a6899 Dmitry Osipenko 2019-08-12 693 emc->regs + EMC_SELF_REF);
e34212c75a6899 Dmitry Osipenko 2019-08-12 694 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 695
e34212c75a6899 Dmitry Osipenko 2019-08-12 696 /* flow control marker 2 */
e34212c75a6899 Dmitry Osipenko 2019-08-12 697 writel_relaxed(0x1, emc->regs + EMC_STALL_THEN_EXE_AFTER_CLKCHANGE);
e34212c75a6899 Dmitry Osipenko 2019-08-12 698
e34212c75a6899 Dmitry Osipenko 2019-08-12 699 /* enable write-active MUX, update unshadowed pad control */
e34212c75a6899 Dmitry Osipenko 2019-08-12 700 writel_relaxed(emc_dbg | EMC_DBG_WRITE_MUX_ACTIVE, emc->regs + EMC_DBG);
e34212c75a6899 Dmitry Osipenko 2019-08-12 701 writel_relaxed(timing->data[73], emc->regs + EMC_XM2CLKPADCTRL);
e34212c75a6899 Dmitry Osipenko 2019-08-12 702
e34212c75a6899 Dmitry Osipenko 2019-08-12 703 /* restore periodic QRST and disable write-active MUX */
e34212c75a6899 Dmitry Osipenko 2019-08-12 704 val = !!(emc->emc_cfg & EMC_CFG_PERIODIC_QRST);
e34212c75a6899 Dmitry Osipenko 2019-08-12 705 if (qrst_used || timing->emc_cfg_periodic_qrst != val) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 706 if (timing->emc_cfg_periodic_qrst)
e34212c75a6899 Dmitry Osipenko 2019-08-12 707 emc->emc_cfg |= EMC_CFG_PERIODIC_QRST;
e34212c75a6899 Dmitry Osipenko 2019-08-12 708 else
e34212c75a6899 Dmitry Osipenko 2019-08-12 709 emc->emc_cfg &= ~EMC_CFG_PERIODIC_QRST;
e34212c75a6899 Dmitry Osipenko 2019-08-12 710
e34212c75a6899 Dmitry Osipenko 2019-08-12 711 writel_relaxed(emc->emc_cfg, emc->regs + EMC_CFG);
e34212c75a6899 Dmitry Osipenko 2019-08-12 712 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 713 writel_relaxed(emc_dbg, emc->regs + EMC_DBG);
e34212c75a6899 Dmitry Osipenko 2019-08-12 714
e34212c75a6899 Dmitry Osipenko 2019-08-12 715 /* exit self-refresh on DDR3 */
e34212c75a6899 Dmitry Osipenko 2019-08-12 716 if (dram_type == DRAM_TYPE_DDR3)
e34212c75a6899 Dmitry Osipenko 2019-08-12 717 writel_relaxed(DRAM_BROADCAST(dram_num),
e34212c75a6899 Dmitry Osipenko 2019-08-12 718 emc->regs + EMC_SELF_REF);
e34212c75a6899 Dmitry Osipenko 2019-08-12 719
e34212c75a6899 Dmitry Osipenko 2019-08-12 720 /* set DRAM-mode registers */
e34212c75a6899 Dmitry Osipenko 2019-08-12 721 if (dram_type == DRAM_TYPE_DDR3) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 722 if (timing->emc_mode_1 != emc->emc_mode_1)
e34212c75a6899 Dmitry Osipenko 2019-08-12 723 writel_relaxed(timing->emc_mode_1,
e34212c75a6899 Dmitry Osipenko 2019-08-12 724 emc->regs + EMC_EMRS);
e34212c75a6899 Dmitry Osipenko 2019-08-12 725
e34212c75a6899 Dmitry Osipenko 2019-08-12 726 if (timing->emc_mode_2 != emc->emc_mode_2)
e34212c75a6899 Dmitry Osipenko 2019-08-12 727 writel_relaxed(timing->emc_mode_2,
e34212c75a6899 Dmitry Osipenko 2019-08-12 728 emc->regs + EMC_EMRS);
e34212c75a6899 Dmitry Osipenko 2019-08-12 729
e34212c75a6899 Dmitry Osipenko 2019-08-12 730 if (timing->emc_mode_reset != emc->emc_mode_reset ||
e34212c75a6899 Dmitry Osipenko 2019-08-12 731 dll_change == DLL_CHANGE_ON) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 732 val = timing->emc_mode_reset;
e34212c75a6899 Dmitry Osipenko 2019-08-12 733 if (dll_change == DLL_CHANGE_ON) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 734 val |= EMC_MODE_SET_DLL_RESET;
e34212c75a6899 Dmitry Osipenko 2019-08-12 735 val |= EMC_MODE_SET_LONG_CNT;
e34212c75a6899 Dmitry Osipenko 2019-08-12 736 } else {
e34212c75a6899 Dmitry Osipenko 2019-08-12 737 val &= ~EMC_MODE_SET_DLL_RESET;
e34212c75a6899 Dmitry Osipenko 2019-08-12 738 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 739 writel_relaxed(val, emc->regs + EMC_MRS);
e34212c75a6899 Dmitry Osipenko 2019-08-12 740 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 741 } else {
e34212c75a6899 Dmitry Osipenko 2019-08-12 742 if (timing->emc_mode_2 != emc->emc_mode_2)
e34212c75a6899 Dmitry Osipenko 2019-08-12 743 writel_relaxed(timing->emc_mode_2,
e34212c75a6899 Dmitry Osipenko 2019-08-12 744 emc->regs + EMC_MRW);
e34212c75a6899 Dmitry Osipenko 2019-08-12 745
e34212c75a6899 Dmitry Osipenko 2019-08-12 746 if (timing->emc_mode_1 != emc->emc_mode_1)
e34212c75a6899 Dmitry Osipenko 2019-08-12 747 writel_relaxed(timing->emc_mode_1,
e34212c75a6899 Dmitry Osipenko 2019-08-12 748 emc->regs + EMC_MRW);
e34212c75a6899 Dmitry Osipenko 2019-08-12 749 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 750
e34212c75a6899 Dmitry Osipenko 2019-08-12 751 emc->emc_mode_1 = timing->emc_mode_1;
e34212c75a6899 Dmitry Osipenko 2019-08-12 752 emc->emc_mode_2 = timing->emc_mode_2;
e34212c75a6899 Dmitry Osipenko 2019-08-12 753 emc->emc_mode_reset = timing->emc_mode_reset;
e34212c75a6899 Dmitry Osipenko 2019-08-12 754
e34212c75a6899 Dmitry Osipenko 2019-08-12 755 /* issue ZCAL command if turning ZCAL on */
e34212c75a6899 Dmitry Osipenko 2019-08-12 756 if (emc->zcal_long) {
e34212c75a6899 Dmitry Osipenko 2019-08-12 @757 writel_relaxed(EMC_ZQ_CAL_LONG_CMD_DEV0,
e34212c75a6899 Dmitry Osipenko 2019-08-12 758 emc->regs + EMC_ZQ_CAL);
e34212c75a6899 Dmitry Osipenko 2019-08-12 759
e34212c75a6899 Dmitry Osipenko 2019-08-12 760 if (dram_num > 1)
e34212c75a6899 Dmitry Osipenko 2019-08-12 761 writel_relaxed(EMC_ZQ_CAL_LONG_CMD_DEV1,
e34212c75a6899 Dmitry Osipenko 2019-08-12 762 emc->regs + EMC_ZQ_CAL);
e34212c75a6899 Dmitry Osipenko 2019-08-12 763 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 764
e34212c75a6899 Dmitry Osipenko 2019-08-12 765 /* flow control marker 3 */
e34212c75a6899 Dmitry Osipenko 2019-08-12 766 writel_relaxed(0x1, emc->regs + EMC_UNSTALL_RW_AFTER_CLKCHANGE);
e34212c75a6899 Dmitry Osipenko 2019-08-12 767
0f8bb9da5aee80 Dmitry Osipenko 2019-12-20 768 /*
0f8bb9da5aee80 Dmitry Osipenko 2019-12-20 769 * Read and discard an arbitrary MC register (Note: EMC registers
0f8bb9da5aee80 Dmitry Osipenko 2019-12-20 770 * can't be used) to ensure the register writes are completed.
0f8bb9da5aee80 Dmitry Osipenko 2019-12-20 771 */
0f8bb9da5aee80 Dmitry Osipenko 2019-12-20 772 mc_readl(emc->mc, MC_EMEM_ARB_OVERRIDE);
0f8bb9da5aee80 Dmitry Osipenko 2019-12-20 773
e34212c75a6899 Dmitry Osipenko 2019-08-12 774 return 0;
e34212c75a6899 Dmitry Osipenko 2019-08-12 775 }
e34212c75a6899 Dmitry Osipenko 2019-08-12 776

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (35.89 kB)
.config.gz (29.62 kB)
Download all attachments

2021-05-11 15:19:20

by Dmitry Osipenko

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] memory: tegra: Enable compile testing for all drivers

11.05.2021 16:58, kernel test robot пишет:
> Hi Dmitry,
>
> I love your patch! Perhaps something to improve:
>
> [auto build test WARNING on tegra/for-next]
> [also build test WARNING on v5.13-rc1 next-20210511]
> [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]
>
> url: https://github.com/0day-ci/linux/commits/Dmitry-Osipenko/Enable-compile-testing-for-Tegra-memory-drivers/20210511-053910
> base: https://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux.git for-next
> config: powerpc-randconfig-r032-20210511 (attached as .config)
> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project a0fed635fe1701470062495a6ffee1c608f3f1bc)
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # install powerpc cross compiling tool for clang build
> # apt-get install binutils-powerpc-linux-gnu
> # https://github.com/0day-ci/linux/commit/ecd67b1d49eb33c9821130a2b3b896bab395118d
> git remote add linux-review https://github.com/0day-ci/linux
> git fetch --no-tags linux-review Dmitry-Osipenko/Enable-compile-testing-for-Tegra-memory-drivers/20210511-053910
> git checkout ecd67b1d49eb33c9821130a2b3b896bab395118d
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=powerpc
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <[email protected]>
>
> All warnings (new ones prefixed by >>):
>
> __do_insb
> ^
> arch/powerpc/include/asm/io.h:556:56: note: expanded from macro '__do_insb'
> #define __do_insb(p, b, n) readsb((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
> ~~~~~~~~~~~~~~~~~~~~~^
> In file included from drivers/memory/tegra/tegra30-emc.c:18:
> In file included from include/linux/interrupt.h:11:
> In file included from include/linux/hardirq.h:10:
> In file included from arch/powerpc/include/asm/hardirq.h:6:
> In file included from include/linux/irq.h:20:
> In file included from include/linux/io.h:13:
> In file included from arch/powerpc/include/asm/io.h:619:
> arch/powerpc/include/asm/io-defs.h:45:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
> DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c),
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
> __do_##name al; \
> ^~~~~~~~~~~~~~
> <scratch space>:211:1: note: expanded from here
> __do_insw
> ^
> arch/powerpc/include/asm/io.h:557:56: note: expanded from macro '__do_insw'
> #define __do_insw(p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
> ~~~~~~~~~~~~~~~~~~~~~^
> In file included from drivers/memory/tegra/tegra30-emc.c:18:
> In file included from include/linux/interrupt.h:11:
> In file included from include/linux/hardirq.h:10:
> In file included from arch/powerpc/include/asm/hardirq.h:6:
> In file included from include/linux/irq.h:20:
> In file included from include/linux/io.h:13:
> In file included from arch/powerpc/include/asm/io.h:619:
> arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
> DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c),
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
> __do_##name al; \
> ^~~~~~~~~~~~~~
> <scratch space>:213:1: note: expanded from here
> __do_insl
> ^
> arch/powerpc/include/asm/io.h:558:56: note: expanded from macro '__do_insl'
> #define __do_insl(p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
> ~~~~~~~~~~~~~~~~~~~~~^
> In file included from drivers/memory/tegra/tegra30-emc.c:18:
> In file included from include/linux/interrupt.h:11:
> In file included from include/linux/hardirq.h:10:
> In file included from arch/powerpc/include/asm/hardirq.h:6:
> In file included from include/linux/irq.h:20:
> In file included from include/linux/io.h:13:
> In file included from arch/powerpc/include/asm/io.h:619:
> arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
> DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c),
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
> __do_##name al; \
> ^~~~~~~~~~~~~~
> <scratch space>:215:1: note: expanded from here
> __do_outsb
> ^
> arch/powerpc/include/asm/io.h:559:58: note: expanded from macro '__do_outsb'
> #define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
> ~~~~~~~~~~~~~~~~~~~~~^
> In file included from drivers/memory/tegra/tegra30-emc.c:18:
> In file included from include/linux/interrupt.h:11:
> In file included from include/linux/hardirq.h:10:
> In file included from arch/powerpc/include/asm/hardirq.h:6:
> In file included from include/linux/irq.h:20:
> In file included from include/linux/io.h:13:
> In file included from arch/powerpc/include/asm/io.h:619:
> arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
> DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
> __do_##name al; \
> ^~~~~~~~~~~~~~
> <scratch space>:217:1: note: expanded from here
> __do_outsw
> ^
> arch/powerpc/include/asm/io.h:560:58: note: expanded from macro '__do_outsw'
> #define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
> ~~~~~~~~~~~~~~~~~~~~~^
> In file included from drivers/memory/tegra/tegra30-emc.c:18:
> In file included from include/linux/interrupt.h:11:
> In file included from include/linux/hardirq.h:10:
> In file included from arch/powerpc/include/asm/hardirq.h:6:
> In file included from include/linux/irq.h:20:
> In file included from include/linux/io.h:13:
> In file included from arch/powerpc/include/asm/io.h:619:
> arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
> DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
> __do_##name al; \
> ^~~~~~~~~~~~~~
> <scratch space>:219:1: note: expanded from here
> __do_outsl
> ^
> arch/powerpc/include/asm/io.h:561:58: note: expanded from macro '__do_outsl'
> #define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
> ~~~~~~~~~~~~~~~~~~~~~^
>>> drivers/memory/tegra/tegra30-emc.c:757:18: warning: implicit conversion from 'unsigned long' to 'u32' (aka 'unsigned int') changes value from 18446744071562067985 to 2147483665 [-Wconstant-conversion]
> writel_relaxed(EMC_ZQ_CAL_LONG_CMD_DEV0,
> ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/memory/tegra/tegra30-emc.c:161:36: note: expanded from macro 'EMC_ZQ_CAL_LONG_CMD_DEV0'
> (DRAM_DEV_SEL_0 | EMC_ZQ_CAL_LONG | EMC_ZQ_CAL_CMD)
> ^
> arch/powerpc/include/asm/io.h:679:40: note: expanded from macro 'writel_relaxed'
> #define writel_relaxed(v, addr) writel(v, addr)
> ~~~~~~ ^
> 13 warnings generated.
> --
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
> __do_##name al; \
> ^~~~~~~~~~~~~~
> <scratch space>:203:1: note: expanded from here
> __do_outl
> ^
> arch/powerpc/include/asm/io.h:537:62: note: expanded from macro '__do_outl'
> #define __do_outl(val, port) writel(val,(PCI_IO_ADDR)_IO_BASE+port);
> ~~~~~~~~~~~~~~~~~~~~~^
> In file included from drivers/memory/tegra/tegra124-emc.c:16:
> In file included from include/linux/io.h:13:
> In file included from arch/powerpc/include/asm/io.h:619:
> arch/powerpc/include/asm/io-defs.h:43:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
> DEF_PCI_AC_NORET(insb, (unsigned long p, void *b, unsigned long c),
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
> __do_##name al; \
> ^~~~~~~~~~~~~~
> <scratch space>:217:1: note: expanded from here
> __do_insb
> ^
> arch/powerpc/include/asm/io.h:556:56: note: expanded from macro '__do_insb'
> #define __do_insb(p, b, n) readsb((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
> ~~~~~~~~~~~~~~~~~~~~~^
> In file included from drivers/memory/tegra/tegra124-emc.c:16:
> In file included from include/linux/io.h:13:
> In file included from arch/powerpc/include/asm/io.h:619:
> arch/powerpc/include/asm/io-defs.h:45:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
> DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c),
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
> __do_##name al; \
> ^~~~~~~~~~~~~~
> <scratch space>:219:1: note: expanded from here
> __do_insw
> ^
> arch/powerpc/include/asm/io.h:557:56: note: expanded from macro '__do_insw'
> #define __do_insw(p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
> ~~~~~~~~~~~~~~~~~~~~~^
> In file included from drivers/memory/tegra/tegra124-emc.c:16:
> In file included from include/linux/io.h:13:
> In file included from arch/powerpc/include/asm/io.h:619:
> arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
> DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c),
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
> __do_##name al; \
> ^~~~~~~~~~~~~~
> <scratch space>:221:1: note: expanded from here
> __do_insl
> ^
> arch/powerpc/include/asm/io.h:558:56: note: expanded from macro '__do_insl'
> #define __do_insl(p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
> ~~~~~~~~~~~~~~~~~~~~~^
> In file included from drivers/memory/tegra/tegra124-emc.c:16:
> In file included from include/linux/io.h:13:
> In file included from arch/powerpc/include/asm/io.h:619:
> arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
> DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c),
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
> __do_##name al; \
> ^~~~~~~~~~~~~~
> <scratch space>:223:1: note: expanded from here
> __do_outsb
> ^
> arch/powerpc/include/asm/io.h:559:58: note: expanded from macro '__do_outsb'
> #define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
> ~~~~~~~~~~~~~~~~~~~~~^
> In file included from drivers/memory/tegra/tegra124-emc.c:16:
> In file included from include/linux/io.h:13:
> In file included from arch/powerpc/include/asm/io.h:619:
> arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
> DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
> __do_##name al; \
> ^~~~~~~~~~~~~~
> <scratch space>:225:1: note: expanded from here
> __do_outsw
> ^
> arch/powerpc/include/asm/io.h:560:58: note: expanded from macro '__do_outsw'
> #define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
> ~~~~~~~~~~~~~~~~~~~~~^
> In file included from drivers/memory/tegra/tegra124-emc.c:16:
> In file included from include/linux/io.h:13:
> In file included from arch/powerpc/include/asm/io.h:619:
> arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
> DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
> __do_##name al; \
> ^~~~~~~~~~~~~~
> <scratch space>:227:1: note: expanded from here
> __do_outsl
> ^
> arch/powerpc/include/asm/io.h:561:58: note: expanded from macro '__do_outsl'
> #define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
> ~~~~~~~~~~~~~~~~~~~~~^
>>> drivers/memory/tegra/tegra124-emc.c:802:26: warning: implicit conversion from 'unsigned long' to 'u32' (aka 'unsigned int') changes value from 18446744071562067985 to 2147483665 [-Wconstant-conversion]
> emc_ccfifo_writel(emc, EMC_ZQ_CAL_LONG_CMD_DEV0, EMC_ZQ_CAL);
> ~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~
> drivers/memory/tegra/tegra124-emc.c:154:36: note: expanded from macro 'EMC_ZQ_CAL_LONG_CMD_DEV0'
> (DRAM_DEV_SEL_0 | EMC_ZQ_CAL_LONG | EMC_ZQ_CAL_CMD)
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
> 13 warnings generated.

This doesn't look like a useful warning from clang, it should see that
the constant value itself isn't truncated, hence it should be a problem
of clang. Do you think it's okay to ignore this nonsense?

2021-05-11 15:32:50

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] memory: tegra: Enable compile testing for all drivers

On 11/05/2021 11:17, Dmitry Osipenko wrote:
> 11.05.2021 16:58, kernel test robot пишет:
>> Hi Dmitry,
>>
>> I love your patch! Perhaps something to improve:
>>
>> [auto build test WARNING on tegra/for-next]
>> [also build test WARNING on v5.13-rc1 next-20210511]
>> [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]
>>
>> url: https://github.com/0day-ci/linux/commits/Dmitry-Osipenko/Enable-compile-testing-for-Tegra-memory-drivers/20210511-053910
>> base: https://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux.git for-next
>> config: powerpc-randconfig-r032-20210511 (attached as .config)
>> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project a0fed635fe1701470062495a6ffee1c608f3f1bc)
>> reproduce (this is a W=1 build):
>> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>> chmod +x ~/bin/make.cross
>> # install powerpc cross compiling tool for clang build
>> # apt-get install binutils-powerpc-linux-gnu
>> # https://github.com/0day-ci/linux/commit/ecd67b1d49eb33c9821130a2b3b896bab395118d
>> git remote add linux-review https://github.com/0day-ci/linux
>> git fetch --no-tags linux-review Dmitry-Osipenko/Enable-compile-testing-for-Tegra-memory-drivers/20210511-053910
>> git checkout ecd67b1d49eb33c9821130a2b3b896bab395118d
>> # save the attached .config to linux build tree
>> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=powerpc
>>
>> If you fix the issue, kindly add following tag as appropriate
>> Reported-by: kernel test robot <[email protected]>
>>
>> All warnings (new ones prefixed by >>):
>>
>> __do_insb
>> ^
>> arch/powerpc/include/asm/io.h:556:56: note: expanded from macro '__do_insb'
>> #define __do_insb(p, b, n) readsb((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
>> ~~~~~~~~~~~~~~~~~~~~~^
>> In file included from drivers/memory/tegra/tegra30-emc.c:18:
>> In file included from include/linux/interrupt.h:11:
>> In file included from include/linux/hardirq.h:10:
>> In file included from arch/powerpc/include/asm/hardirq.h:6:
>> In file included from include/linux/irq.h:20:
>> In file included from include/linux/io.h:13:
>> In file included from arch/powerpc/include/asm/io.h:619:
>> arch/powerpc/include/asm/io-defs.h:45:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
>> DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c),
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
>> __do_##name al; \
>> ^~~~~~~~~~~~~~
>> <scratch space>:211:1: note: expanded from here
>> __do_insw
>> ^
>> arch/powerpc/include/asm/io.h:557:56: note: expanded from macro '__do_insw'
>> #define __do_insw(p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
>> ~~~~~~~~~~~~~~~~~~~~~^
>> In file included from drivers/memory/tegra/tegra30-emc.c:18:
>> In file included from include/linux/interrupt.h:11:
>> In file included from include/linux/hardirq.h:10:
>> In file included from arch/powerpc/include/asm/hardirq.h:6:
>> In file included from include/linux/irq.h:20:
>> In file included from include/linux/io.h:13:
>> In file included from arch/powerpc/include/asm/io.h:619:
>> arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
>> DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c),
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
>> __do_##name al; \
>> ^~~~~~~~~~~~~~
>> <scratch space>:213:1: note: expanded from here
>> __do_insl
>> ^
>> arch/powerpc/include/asm/io.h:558:56: note: expanded from macro '__do_insl'
>> #define __do_insl(p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
>> ~~~~~~~~~~~~~~~~~~~~~^
>> In file included from drivers/memory/tegra/tegra30-emc.c:18:
>> In file included from include/linux/interrupt.h:11:
>> In file included from include/linux/hardirq.h:10:
>> In file included from arch/powerpc/include/asm/hardirq.h:6:
>> In file included from include/linux/irq.h:20:
>> In file included from include/linux/io.h:13:
>> In file included from arch/powerpc/include/asm/io.h:619:
>> arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
>> DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c),
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
>> __do_##name al; \
>> ^~~~~~~~~~~~~~
>> <scratch space>:215:1: note: expanded from here
>> __do_outsb
>> ^
>> arch/powerpc/include/asm/io.h:559:58: note: expanded from macro '__do_outsb'
>> #define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
>> ~~~~~~~~~~~~~~~~~~~~~^
>> In file included from drivers/memory/tegra/tegra30-emc.c:18:
>> In file included from include/linux/interrupt.h:11:
>> In file included from include/linux/hardirq.h:10:
>> In file included from arch/powerpc/include/asm/hardirq.h:6:
>> In file included from include/linux/irq.h:20:
>> In file included from include/linux/io.h:13:
>> In file included from arch/powerpc/include/asm/io.h:619:
>> arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
>> DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
>> __do_##name al; \
>> ^~~~~~~~~~~~~~
>> <scratch space>:217:1: note: expanded from here
>> __do_outsw
>> ^
>> arch/powerpc/include/asm/io.h:560:58: note: expanded from macro '__do_outsw'
>> #define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
>> ~~~~~~~~~~~~~~~~~~~~~^
>> In file included from drivers/memory/tegra/tegra30-emc.c:18:
>> In file included from include/linux/interrupt.h:11:
>> In file included from include/linux/hardirq.h:10:
>> In file included from arch/powerpc/include/asm/hardirq.h:6:
>> In file included from include/linux/irq.h:20:
>> In file included from include/linux/io.h:13:
>> In file included from arch/powerpc/include/asm/io.h:619:
>> arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
>> DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
>> __do_##name al; \
>> ^~~~~~~~~~~~~~
>> <scratch space>:219:1: note: expanded from here
>> __do_outsl
>> ^
>> arch/powerpc/include/asm/io.h:561:58: note: expanded from macro '__do_outsl'
>> #define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
>> ~~~~~~~~~~~~~~~~~~~~~^
>>>> drivers/memory/tegra/tegra30-emc.c:757:18: warning: implicit conversion from 'unsigned long' to 'u32' (aka 'unsigned int') changes value from 18446744071562067985 to 2147483665 [-Wconstant-conversion]
>> writel_relaxed(EMC_ZQ_CAL_LONG_CMD_DEV0,
>> ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/memory/tegra/tegra30-emc.c:161:36: note: expanded from macro 'EMC_ZQ_CAL_LONG_CMD_DEV0'
>> (DRAM_DEV_SEL_0 | EMC_ZQ_CAL_LONG | EMC_ZQ_CAL_CMD)
>> ^
>> arch/powerpc/include/asm/io.h:679:40: note: expanded from macro 'writel_relaxed'
>> #define writel_relaxed(v, addr) writel(v, addr)
>> ~~~~~~ ^
>> 13 warnings generated.
>> --
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
>> __do_##name al; \
>> ^~~~~~~~~~~~~~
>> <scratch space>:203:1: note: expanded from here
>> __do_outl
>> ^
>> arch/powerpc/include/asm/io.h:537:62: note: expanded from macro '__do_outl'
>> #define __do_outl(val, port) writel(val,(PCI_IO_ADDR)_IO_BASE+port);
>> ~~~~~~~~~~~~~~~~~~~~~^
>> In file included from drivers/memory/tegra/tegra124-emc.c:16:
>> In file included from include/linux/io.h:13:
>> In file included from arch/powerpc/include/asm/io.h:619:
>> arch/powerpc/include/asm/io-defs.h:43:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
>> DEF_PCI_AC_NORET(insb, (unsigned long p, void *b, unsigned long c),
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
>> __do_##name al; \
>> ^~~~~~~~~~~~~~
>> <scratch space>:217:1: note: expanded from here
>> __do_insb
>> ^
>> arch/powerpc/include/asm/io.h:556:56: note: expanded from macro '__do_insb'
>> #define __do_insb(p, b, n) readsb((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
>> ~~~~~~~~~~~~~~~~~~~~~^
>> In file included from drivers/memory/tegra/tegra124-emc.c:16:
>> In file included from include/linux/io.h:13:
>> In file included from arch/powerpc/include/asm/io.h:619:
>> arch/powerpc/include/asm/io-defs.h:45:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
>> DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c),
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
>> __do_##name al; \
>> ^~~~~~~~~~~~~~
>> <scratch space>:219:1: note: expanded from here
>> __do_insw
>> ^
>> arch/powerpc/include/asm/io.h:557:56: note: expanded from macro '__do_insw'
>> #define __do_insw(p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
>> ~~~~~~~~~~~~~~~~~~~~~^
>> In file included from drivers/memory/tegra/tegra124-emc.c:16:
>> In file included from include/linux/io.h:13:
>> In file included from arch/powerpc/include/asm/io.h:619:
>> arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
>> DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c),
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
>> __do_##name al; \
>> ^~~~~~~~~~~~~~
>> <scratch space>:221:1: note: expanded from here
>> __do_insl
>> ^
>> arch/powerpc/include/asm/io.h:558:56: note: expanded from macro '__do_insl'
>> #define __do_insl(p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
>> ~~~~~~~~~~~~~~~~~~~~~^
>> In file included from drivers/memory/tegra/tegra124-emc.c:16:
>> In file included from include/linux/io.h:13:
>> In file included from arch/powerpc/include/asm/io.h:619:
>> arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
>> DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c),
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
>> __do_##name al; \
>> ^~~~~~~~~~~~~~
>> <scratch space>:223:1: note: expanded from here
>> __do_outsb
>> ^
>> arch/powerpc/include/asm/io.h:559:58: note: expanded from macro '__do_outsb'
>> #define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
>> ~~~~~~~~~~~~~~~~~~~~~^
>> In file included from drivers/memory/tegra/tegra124-emc.c:16:
>> In file included from include/linux/io.h:13:
>> In file included from arch/powerpc/include/asm/io.h:619:
>> arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
>> DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
>> __do_##name al; \
>> ^~~~~~~~~~~~~~
>> <scratch space>:225:1: note: expanded from here
>> __do_outsw
>> ^
>> arch/powerpc/include/asm/io.h:560:58: note: expanded from macro '__do_outsw'
>> #define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
>> ~~~~~~~~~~~~~~~~~~~~~^
>> In file included from drivers/memory/tegra/tegra124-emc.c:16:
>> In file included from include/linux/io.h:13:
>> In file included from arch/powerpc/include/asm/io.h:619:
>> arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
>> DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
>> __do_##name al; \
>> ^~~~~~~~~~~~~~
>> <scratch space>:227:1: note: expanded from here
>> __do_outsl
>> ^
>> arch/powerpc/include/asm/io.h:561:58: note: expanded from macro '__do_outsl'
>> #define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
>> ~~~~~~~~~~~~~~~~~~~~~^
>>>> drivers/memory/tegra/tegra124-emc.c:802:26: warning: implicit conversion from 'unsigned long' to 'u32' (aka 'unsigned int') changes value from 18446744071562067985 to 2147483665 [-Wconstant-conversion]
>> emc_ccfifo_writel(emc, EMC_ZQ_CAL_LONG_CMD_DEV0, EMC_ZQ_CAL);
>> ~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/memory/tegra/tegra124-emc.c:154:36: note: expanded from macro 'EMC_ZQ_CAL_LONG_CMD_DEV0'
>> (DRAM_DEV_SEL_0 | EMC_ZQ_CAL_LONG | EMC_ZQ_CAL_CMD)
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
>> 13 warnings generated.
>
> This doesn't look like a useful warning from clang, it should see that
> the constant value itself isn't truncated, hence it should be a problem
> of clang. Do you think it's okay to ignore this nonsense?

I admit I also do not see the real issue here. The DRAM_DEV_SEL_0 fits
in u32 and there is no other bitwise arithmetic than just OR, so why
clang assumes it can have 32 most signifcant bits toggled on?

+Cc Nathan and Nick,
Maybe you could shed some light here on this warning?

Dmitry,
In general you should not ignore it because:
1. This breaks allyesconfig with clang on powerpc (or it is one of the
stoppers),
2. We might want in some future to build it with clang.


Best regards,
Krzysztof

2021-05-11 15:47:05

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] memory: tegra: Enable compile testing for all drivers

Hi Dmitry,

I love your patch! Yet something to improve:

[auto build test ERROR on tegra/for-next]
[also build test ERROR on v5.13-rc1 next-20210511]
[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]

url: https://github.com/0day-ci/linux/commits/Dmitry-Osipenko/Enable-compile-testing-for-Tegra-memory-drivers/20210511-053910
base: https://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux.git for-next
config: parisc-randconfig-r011-20210511 (attached as .config)
compiler: hppa64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/ecd67b1d49eb33c9821130a2b3b896bab395118d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dmitry-Osipenko/Enable-compile-testing-for-Tegra-memory-drivers/20210511-053910
git checkout ecd67b1d49eb33c9821130a2b3b896bab395118d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=parisc

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

hppa64-linux-ld: drivers/memory/tegra/tegra20-emc.o: in function `.LC9':
>> (.data.rel.ro+0x30): undefined reference to `tegra20_clk_set_emc_round_callback'
hppa64-linux-ld: drivers/memory/tegra/tegra20-emc.o: in function `.LC52':
(.data.rel.ro+0xe0): undefined reference to `tegra20_clk_set_emc_round_callback'
hppa64-linux-ld: drivers/memory/tegra/tegra30-emc.o: in function `.LC11':
>> (.data.rel.ro+0x30): undefined reference to `tegra20_clk_set_emc_round_callback'
hppa64-linux-ld: drivers/memory/tegra/tegra30-emc.o: in function `.LC48':
(.data.rel.ro+0xd0): undefined reference to `tegra20_clk_set_emc_round_callback'
hppa64-linux-ld: drivers/memory/tegra/tegra30-emc.o: in function `.LC60':
>> (.data.rel.ro+0x118): undefined reference to `tegra20_clk_prepare_emc_mc_same_freq'
hppa64-linux-ld: drivers/memory/tegra/tegra124-emc.o: in function `.LC3':
>> (.data.rel.ro+0x10): undefined reference to `tegra124_clk_set_emc_callbacks'
hppa64-linux-ld: drivers/memory/tegra/tegra124-emc.o: in function `.LC55':
(.data.rel.ro+0x110): undefined reference to `tegra124_clk_set_emc_callbacks'

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for TEGRA124_CLK_EMC
Depends on COMMON_CLK
Selected by
- TEGRA124_EMC && MEMORY && TEGRA_MC && (ARCH_TEGRA_124_SOC || COMPILE_TEST

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (2.91 kB)
.config.gz (26.94 kB)
Download all attachments

2021-05-11 16:02:22

by Dmitry Osipenko

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] memory: tegra: Enable compile testing for all drivers

11.05.2021 18:31, Krzysztof Kozlowski пишет:
...
~~~~~~~~~~~~~~~~~~~~~^
>>>>> drivers/memory/tegra/tegra124-emc.c:802:26: warning: implicit conversion from 'unsigned long' to 'u32' (aka 'unsigned int') changes value from 18446744071562067985 to 2147483665 [-Wconstant-conversion]
>>> emc_ccfifo_writel(emc, EMC_ZQ_CAL_LONG_CMD_DEV0, EMC_ZQ_CAL);
>>> ~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~
>>> drivers/memory/tegra/tegra124-emc.c:154:36: note: expanded from macro 'EMC_ZQ_CAL_LONG_CMD_DEV0'
>>> (DRAM_DEV_SEL_0 | EMC_ZQ_CAL_LONG | EMC_ZQ_CAL_CMD)
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
>>> 13 warnings generated.
>>
>> This doesn't look like a useful warning from clang, it should see that
>> the constant value itself isn't truncated, hence it should be a problem
>> of clang. Do you think it's okay to ignore this nonsense?
>
> I admit I also do not see the real issue here. The DRAM_DEV_SEL_0 fits
> in u32 and there is no other bitwise arithmetic than just OR, so why
> clang assumes it can have 32 most signifcant bits toggled on?
>
> +Cc Nathan and Nick,
> Maybe you could shed some light here on this warning?
>
> Dmitry,
> In general you should not ignore it because:
> 1. This breaks allyesconfig with clang on powerpc (or it is one of the
> stoppers),
> 2. We might want in some future to build it with clang.

I meant to ignore it from the perspective of the memory drivers, i.e. it
likely should be fixed in clang and not worked around in the code. Thank
you for pinging the right people.

2021-05-11 16:24:32

by Dmitry Osipenko

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] memory: tegra: Enable compile testing for all drivers

11.05.2021 18:43, kernel test robot пишет:
> Hi Dmitry,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on tegra/for-next]
> [also build test ERROR on v5.13-rc1 next-20210511]
> [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]
>
> url: https://github.com/0day-ci/linux/commits/Dmitry-Osipenko/Enable-compile-testing-for-Tegra-memory-drivers/20210511-053910
> base: https://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux.git for-next
> config: parisc-randconfig-r011-20210511 (attached as .config)
> compiler: hppa64-linux-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # https://github.com/0day-ci/linux/commit/ecd67b1d49eb33c9821130a2b3b896bab395118d
> git remote add linux-review https://github.com/0day-ci/linux
> git fetch --no-tags linux-review Dmitry-Osipenko/Enable-compile-testing-for-Tegra-memory-drivers/20210511-053910
> git checkout ecd67b1d49eb33c9821130a2b3b896bab395118d
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=parisc
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <[email protected]>
>
> All errors (new ones prefixed by >>):
>
> hppa64-linux-ld: drivers/memory/tegra/tegra20-emc.o: in function `.LC9':
>>> (.data.rel.ro+0x30): undefined reference to `tegra20_clk_set_emc_round_callback'
> hppa64-linux-ld: drivers/memory/tegra/tegra20-emc.o: in function `.LC52':
> (.data.rel.ro+0xe0): undefined reference to `tegra20_clk_set_emc_round_callback'
> hppa64-linux-ld: drivers/memory/tegra/tegra30-emc.o: in function `.LC11':
>>> (.data.rel.ro+0x30): undefined reference to `tegra20_clk_set_emc_round_callback'
> hppa64-linux-ld: drivers/memory/tegra/tegra30-emc.o: in function `.LC48':
> (.data.rel.ro+0xd0): undefined reference to `tegra20_clk_set_emc_round_callback'
> hppa64-linux-ld: drivers/memory/tegra/tegra30-emc.o: in function `.LC60':
>>> (.data.rel.ro+0x118): undefined reference to `tegra20_clk_prepare_emc_mc_same_freq'
> hppa64-linux-ld: drivers/memory/tegra/tegra124-emc.o: in function `.LC3':
>>> (.data.rel.ro+0x10): undefined reference to `tegra124_clk_set_emc_callbacks'
> hppa64-linux-ld: drivers/memory/tegra/tegra124-emc.o: in function `.LC55':
> (.data.rel.ro+0x110): undefined reference to `tegra124_clk_set_emc_callbacks'
>
> Kconfig warnings: (for reference only)
> WARNING: unmet direct dependencies detected for TEGRA124_CLK_EMC
> Depends on COMMON_CLK
> Selected by
> - TEGRA124_EMC && MEMORY && TEGRA_MC && (ARCH_TEGRA_124_SOC || COMPILE_TEST

I'll fix these missing stubs in v2.

2021-05-11 16:44:06

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] memory: tegra: Enable compile testing for all drivers

On 10/05/2021 17:37, Dmitry Osipenko wrote:
> Enable compile testing for all Tegra memory drivers.
>
> Signed-off-by: Dmitry Osipenko <[email protected]>
> ---
> drivers/memory/tegra/Kconfig | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/memory/tegra/Kconfig b/drivers/memory/tegra/Kconfig
> index a70967a56e52..a910f661105f 100644
> --- a/drivers/memory/tegra/Kconfig
> +++ b/drivers/memory/tegra/Kconfig
> @@ -2,7 +2,7 @@
> config TEGRA_MC
> bool "NVIDIA Tegra Memory Controller support"
> default y
> - depends on ARCH_TEGRA
> + depends on (ARCH_TEGRA || COMPILE_TEST)

No need for ().

> select INTERCONNECT
> help
> This driver supports the Memory Controller (MC) hardware found on
> @@ -11,7 +11,7 @@ config TEGRA_MC
> config TEGRA20_EMC
> tristate "NVIDIA Tegra20 External Memory Controller driver"
> default y
> - depends on TEGRA_MC && ARCH_TEGRA_2x_SOC
> + depends on TEGRA_MC && (ARCH_TEGRA_2x_SOC || COMPILE_TEST)

There is a lot of "depends on TEGRA_MC". How about making it a "if
TEGRA_MC" block?

Best regards,
Krzysztof

2021-05-11 17:37:33

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] memory: tegra: Enable compile testing for all drivers

On Tue, May 11, 2021 at 07:00:34PM +0300, Dmitry Osipenko wrote:
> 11.05.2021 18:31, Krzysztof Kozlowski пишет:
> ...
> ~~~~~~~~~~~~~~~~~~~~~^
> >>>>> drivers/memory/tegra/tegra124-emc.c:802:26: warning: implicit conversion from 'unsigned long' to 'u32' (aka 'unsigned int') changes value from 18446744071562067985 to 2147483665 [-Wconstant-conversion]
> >>> emc_ccfifo_writel(emc, EMC_ZQ_CAL_LONG_CMD_DEV0, EMC_ZQ_CAL);
> >>> ~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~
> >>> drivers/memory/tegra/tegra124-emc.c:154:36: note: expanded from macro 'EMC_ZQ_CAL_LONG_CMD_DEV0'
> >>> (DRAM_DEV_SEL_0 | EMC_ZQ_CAL_LONG | EMC_ZQ_CAL_CMD)
> >>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
> >>> 13 warnings generated.
> >>
> >> This doesn't look like a useful warning from clang, it should see that
> >> the constant value itself isn't truncated, hence it should be a problem
> >> of clang. Do you think it's okay to ignore this nonsense?
> >
> > I admit I also do not see the real issue here. The DRAM_DEV_SEL_0 fits
> > in u32 and there is no other bitwise arithmetic than just OR, so why
> > clang assumes it can have 32 most signifcant bits toggled on?
> >
> > +Cc Nathan and Nick,
> > Maybe you could shed some light here on this warning?
> >
> > Dmitry,
> > In general you should not ignore it because:
> > 1. This breaks allyesconfig with clang on powerpc (or it is one of the
> > stoppers),
> > 2. We might want in some future to build it with clang.
>
> I meant to ignore it from the perspective of the memory drivers, i.e. it
> likely should be fixed in clang and not worked around in the code. Thank
> you for pinging the right people.

I do not think this is a bug in clang, gcc warns the same (just not here
in this case): https://godbolt.org/z/e9GWobMnd

DRAM_DEV_SEL_0 and DRAM_DEV_SEL_1 are implicitly signed integers because
there is no suffix on the literal 1. DRAM_DEV_SEL_0 is 2 << 30, which
can be turned into 1 << 31. That is equal to INT_MAX + 1, which then
overflows and becomes INT_MIN (undefined behavior). INT_MIN is then
promoted to unsigned long because EMC_ZQ_CAL_LONG and EMC_ZQ_CAL_CMD are
unsigned long due to the BIT macro, resulting in the gigantic number
that clang reports above.

I assume that this driver only runs on hardware where unsigned int is
the same size as unsigned long, meaning this problem is merely
theoretical?

Regardless, defining DRAM_DEV_SEL_{0,1} with the BIT macro fixes the
warning for me and should make everything work as expected.

diff --git a/drivers/memory/tegra/tegra124-emc.c b/drivers/memory/tegra/tegra124-emc.c
index 5699d909abc2..a21ca8e0841a 100644
--- a/drivers/memory/tegra/tegra124-emc.c
+++ b/drivers/memory/tegra/tegra124-emc.c
@@ -272,8 +272,8 @@
#define EMC_PUTERM_ADJ 0x574

#define DRAM_DEV_SEL_ALL 0
-#define DRAM_DEV_SEL_0 (2 << 30)
-#define DRAM_DEV_SEL_1 (1 << 30)
+#define DRAM_DEV_SEL_0 BIT(31)
+#define DRAM_DEV_SEL_1 BIT(30)

#define EMC_CFG_POWER_FEATURES_MASK \
(EMC_CFG_DYN_SREF | EMC_CFG_DRAM_ACPD | EMC_CFG_DRAM_CLKSTOP_SR | \

2021-05-11 18:01:43

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] memory: tegra: Enable compile testing for all drivers

On 11/05/2021 13:35, Nathan Chancellor wrote:
> On Tue, May 11, 2021 at 07:00:34PM +0300, Dmitry Osipenko wrote:
>> 11.05.2021 18:31, Krzysztof Kozlowski пишет:
>> ...
>> ~~~~~~~~~~~~~~~~~~~~~^
>>>>>>> drivers/memory/tegra/tegra124-emc.c:802:26: warning: implicit conversion from 'unsigned long' to 'u32' (aka 'unsigned int') changes value from 18446744071562067985 to 2147483665 [-Wconstant-conversion]
>>>>> emc_ccfifo_writel(emc, EMC_ZQ_CAL_LONG_CMD_DEV0, EMC_ZQ_CAL);
>>>>> ~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~
>>>>> drivers/memory/tegra/tegra124-emc.c:154:36: note: expanded from macro 'EMC_ZQ_CAL_LONG_CMD_DEV0'
>>>>> (DRAM_DEV_SEL_0 | EMC_ZQ_CAL_LONG | EMC_ZQ_CAL_CMD)
>>>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
>>>>> 13 warnings generated.
>>>>
>>>> This doesn't look like a useful warning from clang, it should see that
>>>> the constant value itself isn't truncated, hence it should be a problem
>>>> of clang. Do you think it's okay to ignore this nonsense?
>>>
>>> I admit I also do not see the real issue here. The DRAM_DEV_SEL_0 fits
>>> in u32 and there is no other bitwise arithmetic than just OR, so why
>>> clang assumes it can have 32 most signifcant bits toggled on?
>>>
>>> +Cc Nathan and Nick,
>>> Maybe you could shed some light here on this warning?
>>>
>>> Dmitry,
>>> In general you should not ignore it because:
>>> 1. This breaks allyesconfig with clang on powerpc (or it is one of the
>>> stoppers),
>>> 2. We might want in some future to build it with clang.
>>
>> I meant to ignore it from the perspective of the memory drivers, i.e. it
>> likely should be fixed in clang and not worked around in the code. Thank
>> you for pinging the right people.
>
> I do not think this is a bug in clang, gcc warns the same (just not here
> in this case): https://godbolt.org/z/e9GWobMnd
>
> DRAM_DEV_SEL_0 and DRAM_DEV_SEL_1 are implicitly signed integers because
> there is no suffix on the literal 1. DRAM_DEV_SEL_0 is 2 << 30, which
> can be turned into 1 << 31. That is equal to INT_MAX + 1, which then
> overflows and becomes INT_MIN (undefined behavior). INT_MIN is then
> promoted to unsigned long because EMC_ZQ_CAL_LONG and EMC_ZQ_CAL_CMD are
> unsigned long due to the BIT macro, resulting in the gigantic number
> that clang reports above.
>
Thanks, good point.

Best regards,
Krzysztof

2021-05-11 18:32:37

by Dmitry Osipenko

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] memory: tegra: Enable compile testing for all drivers

11.05.2021 19:41, Krzysztof Kozlowski пишет:
> On 10/05/2021 17:37, Dmitry Osipenko wrote:
>> Enable compile testing for all Tegra memory drivers.
>>
>> Signed-off-by: Dmitry Osipenko <[email protected]>
>> ---
>> drivers/memory/tegra/Kconfig | 10 +++++-----
>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/memory/tegra/Kconfig b/drivers/memory/tegra/Kconfig
>> index a70967a56e52..a910f661105f 100644
>> --- a/drivers/memory/tegra/Kconfig
>> +++ b/drivers/memory/tegra/Kconfig
>> @@ -2,7 +2,7 @@
>> config TEGRA_MC
>> bool "NVIDIA Tegra Memory Controller support"
>> default y
>> - depends on ARCH_TEGRA
>> + depends on (ARCH_TEGRA || COMPILE_TEST)
>
> No need for ().

Okay

>> select INTERCONNECT
>> help
>> This driver supports the Memory Controller (MC) hardware found on
>> @@ -11,7 +11,7 @@ config TEGRA_MC
>> config TEGRA20_EMC
>> tristate "NVIDIA Tegra20 External Memory Controller driver"
>> default y
>> - depends on TEGRA_MC && ARCH_TEGRA_2x_SOC
>> + depends on TEGRA_MC && (ARCH_TEGRA_2x_SOC || COMPILE_TEST)
>
> There is a lot of "depends on TEGRA_MC". How about making it a "if
> TEGRA_MC" block?

The explicit dependencies are also good to me. Either variant is fine to
me. I can implement yours suggestion in v2 if Thierry doesn't have
objections.

2021-05-11 18:39:43

by Dmitry Osipenko

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] memory: tegra: Enable compile testing for all drivers

11.05.2021 20:35, Nathan Chancellor пишет:
> On Tue, May 11, 2021 at 07:00:34PM +0300, Dmitry Osipenko wrote:
>> 11.05.2021 18:31, Krzysztof Kozlowski пишет:
>> ...
>> ~~~~~~~~~~~~~~~~~~~~~^
>>>>>>> drivers/memory/tegra/tegra124-emc.c:802:26: warning: implicit conversion from 'unsigned long' to 'u32' (aka 'unsigned int') changes value from 18446744071562067985 to 2147483665 [-Wconstant-conversion]
>>>>> emc_ccfifo_writel(emc, EMC_ZQ_CAL_LONG_CMD_DEV0, EMC_ZQ_CAL);
>>>>> ~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~
>>>>> drivers/memory/tegra/tegra124-emc.c:154:36: note: expanded from macro 'EMC_ZQ_CAL_LONG_CMD_DEV0'
>>>>> (DRAM_DEV_SEL_0 | EMC_ZQ_CAL_LONG | EMC_ZQ_CAL_CMD)
>>>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
>>>>> 13 warnings generated.
>>>>
>>>> This doesn't look like a useful warning from clang, it should see that
>>>> the constant value itself isn't truncated, hence it should be a problem
>>>> of clang. Do you think it's okay to ignore this nonsense?
>>>
>>> I admit I also do not see the real issue here. The DRAM_DEV_SEL_0 fits
>>> in u32 and there is no other bitwise arithmetic than just OR, so why
>>> clang assumes it can have 32 most signifcant bits toggled on?
>>>
>>> +Cc Nathan and Nick,
>>> Maybe you could shed some light here on this warning?
>>>
>>> Dmitry,
>>> In general you should not ignore it because:
>>> 1. This breaks allyesconfig with clang on powerpc (or it is one of the
>>> stoppers),
>>> 2. We might want in some future to build it with clang.
>>
>> I meant to ignore it from the perspective of the memory drivers, i.e. it
>> likely should be fixed in clang and not worked around in the code. Thank
>> you for pinging the right people.
>
> I do not think this is a bug in clang, gcc warns the same (just not here
> in this case): https://godbolt.org/z/e9GWobMnd
>
> DRAM_DEV_SEL_0 and DRAM_DEV_SEL_1 are implicitly signed integers because
> there is no suffix on the literal 1. DRAM_DEV_SEL_0 is 2 << 30, which
> can be turned into 1 << 31. That is equal to INT_MAX + 1, which then
> overflows and becomes INT_MIN (undefined behavior). INT_MIN is then
> promoted to unsigned long because EMC_ZQ_CAL_LONG and EMC_ZQ_CAL_CMD are
> unsigned long due to the BIT macro, resulting in the gigantic number
> that clang reports above.
>
> I assume that this driver only runs on hardware where unsigned int is
> the same size as unsigned long, meaning this problem is merely
> theoretical?

Yes and no. The driver is built only for ARM32 today, but it's also
usable on ARM64, we just never got around to enable it for the 64bit
Tegra132 SoC.

> Regardless, defining DRAM_DEV_SEL_{0,1} with the BIT macro fixes the
> warning for me and should make everything work as expected.
>
> diff --git a/drivers/memory/tegra/tegra124-emc.c b/drivers/memory/tegra/tegra124-emc.c
> index 5699d909abc2..a21ca8e0841a 100644
> --- a/drivers/memory/tegra/tegra124-emc.c
> +++ b/drivers/memory/tegra/tegra124-emc.c
> @@ -272,8 +272,8 @@
> #define EMC_PUTERM_ADJ 0x574
>
> #define DRAM_DEV_SEL_ALL 0
> -#define DRAM_DEV_SEL_0 (2 << 30)
> -#define DRAM_DEV_SEL_1 (1 << 30)
> +#define DRAM_DEV_SEL_0 BIT(31)
> +#define DRAM_DEV_SEL_1 BIT(30)
>
> #define EMC_CFG_POWER_FEATURES_MASK \
> (EMC_CFG_DYN_SREF | EMC_CFG_DRAM_ACPD | EMC_CFG_DRAM_CLKSTOP_SR | \
>

Thank you for the clarification. So it's actually the code which needs
to be fixed.

The DRAM_DEV_SEL is a enum, hence I'll add patch in v2 that will make
the values unsigned.