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 <lkp@xxxxxxxxx> 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/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip