]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
karo: fdt: fix panel-dpi support master KARO_TX6-2020-09-18
authorLothar Waßmann <LW@KARO-electronics.de>
Fri, 18 Sep 2020 09:18:53 +0000 (11:18 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 18 Sep 2020 09:18:53 +0000 (11:18 +0200)
commit fefe948bd273 ("karo: fdt: support 'panel-dpi' in DT")
inadvertedly copies the 'phandle' property from the 'display-timing'
node. This creates a new property in the 'panel-timing' node which
invalidates all FDT offsets being used by the
karo_fixup_panel_timing() routine.
Add a whitelist of properties to copy and recalculate all FDT offsets
after possible creation of a new property in the panel-timing node.
Also delete properties in the panel-timing node that don't exist in
the display-timings node.

Fixes: fefe948bd273 ("karo: fdt: support 'panel-dpi' in DT")
27 files changed:
Makefile
arch/arm/include/asm/imx-common/iomux-v3.h
board/karo/common/env.c
board/karo/common/fdt.c
board/karo/tx6/Kconfig
board/karo/tx6/rn5t567.c
board/karo/tx6/tx6qdl.c
board/karo/tx6/tx6ul.c
configs/tx6ul-5014_defconfig [new file with mode: 0644]
configs/tx6ul-5014_mfg_defconfig [new file with mode: 0644]
configs/tx6ul-5014_noenv_defconfig [new file with mode: 0644]
configs/tx6ul-5014_sec_defconfig [new file with mode: 0644]
drivers/pinctrl/pinctrl-uclass.c
drivers/usb/gadget/f_mass_storage.c
include/configs/tx6.h
include/linux/compiler-gcc.h
include/linux/compiler-gcc3.h [deleted file]
include/linux/compiler-gcc4.h [deleted file]
include/linux/compiler-gcc5.h [deleted file]
include/linux/compiler-intel.h
include/linux/compiler.h
include/net.h
net/bootp.c
net/bootp.h
net/dns.h
net/nfs.h
net/sntp.h

index 6aad39348323b293bdc18505787066fc693ee897..dcce4cbe4786c25a5a05e63bdca91ed037b043ce 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -576,6 +576,7 @@ ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-stack-usage.sh $(CC)),y)
 endif
 
 KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral)
+KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
 
 # turn jbsr into jsr for m68k
 ifeq ($(ARCH),m68k)
index 0ef633d07b7e27ae1b20e3f622ea2eda75db9d77..06a7ed321bf522678e16af6500268c2855b25bfd 100644 (file)
@@ -187,7 +187,7 @@ typedef u64 iomux_v3_cfg_t;
 #define GPIO_PORTE             (4 << GPIO_PORT_SHIFT)
 #define GPIO_PORTF             (5 << GPIO_PORT_SHIFT)
 
-void imx_iomux_v3_setup_pad(const iomux_v3_cfg_t const pad);
+void imx_iomux_v3_setup_pad(const iomux_v3_cfg_t pad);
 void imx_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t const *pad_list,
                                     unsigned count);
 /*
index 2b347cde3e728a968c3bcf268660995f3de397d1..d08b7f1a498311fb226b2275cf506717d78b11e1 100644 (file)
@@ -31,7 +31,7 @@ void env_cleanup(void)
        set_default_env(NULL);
 }
 #else
-static const char const *cleanup_vars[] = {
+static const char * const cleanup_vars[] = {
        "bootargs",
        "fileaddr",
        "filesize",
index 7f6ac56298894ec6fe59c92296fbd2e85bbdf4ff..909f0ca770a4df3dbb4a6c17e71697732265b372 100644 (file)
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
-*/
+ */
 
 #include <common.h>
 #include <errno.h>
@@ -418,10 +418,10 @@ void karo_fdt_fixup_flexcan(void *blob, int xcvr_present)
                debug("Disabling CAN XCVR\n");
                ret = fdt_find_and_setprop(blob, "reg-can-xcvr", "status",
                                        xcvr_status, strlen(xcvr_status) + 1, 1);
-               if (ret == -FDT_ERR_NOTFOUND)
+               if (ret == -FDT_ERR_NOTFOUND || ret == -FDT_ERR_BADPATH)
                        ret = fdt_find_and_setprop(blob, "reg_can_xcvr", "status",
                                                   xcvr_status, strlen(xcvr_status) + 1, 1);
-               if (ret != -FDT_ERR_NOTFOUND)
+               if (ret && ret != -FDT_ERR_NOTFOUND && ret != -FDT_ERR_BADPATH)
                        printf("Failed to disable CAN transceiver switch: %s\n",
                                fdt_strerror(ret));
        }
@@ -508,7 +508,7 @@ static int fdt_init_fb_mode(const void *blob, int off, struct fb_videomode *fb_m
 
        prop = fdt_getprop(blob, off, "pixelclk-active", NULL);
        if (prop)
-               fb_mode->sync |= *prop ? 0 : FB_SYNC_CLK_LAT_FALL;
+               fb_mode->sync |= *prop ? FB_SYNC_CLK_LAT_FALL : 0;
 
        return 0;
 }
@@ -722,13 +722,84 @@ out:
        return ret;
 }
 
+static const char *karo_panel_timing_props[] = {
+       "clock-frequency",
+       "hactive",
+       "vactive",
+       "hback-porch",
+       "hsync-len",
+       "hfront-porch",
+       "vback-porch",
+       "vsync-len",
+       "vfront-porch",
+       "hsync-active",
+       "vsync-active",
+       "de-active",
+       "pixelclk-active",
+};
+
+static int karo_fixup_panel_timing(void *fdt, int dest, int src)
+{
+       size_t i;
+
+       for (i = 0; i < ARRAY_SIZE(karo_panel_timing_props); i++) {
+               const char *name = karo_panel_timing_props[i];
+               int len;
+               int ret;
+               const void *val;
+               bool restart;
+
+               val = fdt_getprop(fdt, src, name, &len);
+               if (!val) {
+                       if (fdt_getprop(fdt, dest, name, NULL)) {
+                               printf("Removing '%s' from '%s'\n", name,
+                                      fdt_get_name(fdt, dest, NULL));
+                               fdt_delprop(fdt, dest, name);
+                               return -EAGAIN;
+                       }
+                       continue;
+               }
+               if (len != sizeof(u32)) {
+                       printf("Property '%s' has invalid size %u\n",
+                              name, len);
+                       return -EINVAL;
+               }
+               debug("setting '%s' to <0x%08x>\n", name, be32_to_cpup(val));
+
+               restart = !fdt_getprop(fdt, dest, name, &len);
+               restart |= len != sizeof(u32);
+               /* DTB offsets will change when adding a new property */
+               if (restart) {
+                       ret = fdt_increase_size(fdt, len);
+                       if (ret) {
+                               printf("Failed to increase FDT size by %u: %s\n", len,
+                                      fdt_strerror(ret));
+                               return -ENOMEM;
+                       }
+                       printf("Adding new property '%s' to '%s'\n",
+                              name, fdt_get_name(fdt, dest, NULL));
+               }
+               ret = fdt_setprop_u32(fdt, dest, name, be32_to_cpup(val));
+               if (ret) {
+                       printf("Failed to set %s property: %s\n", name,
+                              fdt_strerror(ret));
+                       return -EINVAL;
+               }
+               if (restart)
+                       return -EAGAIN;
+       }
+       return 0;
+}
+
 int karo_fdt_update_fb_mode(void *blob, const char *name,
                            const char *panel_name)
 {
        int ret;
        int off = fdt_path_offset(blob, "display");
+       int dt_node;
        int panel_off = -1;
        const char *subnode = "display-timings";
+       size_t i = 0;
 
        if (panel_name)
                panel_off = fdt_path_offset(blob, panel_name);
@@ -767,32 +838,61 @@ int karo_fdt_update_fb_mode(void *blob, const char *name,
                ret = 0;
        if (!panel_name)
                return ret;
-
-       off = fdt_path_offset(blob, "display/display-timings");
-       off = karo_fdt_find_panel(blob, off, name);
+ restart:
+       dt_node = fdt_path_offset(blob, "display/display-timings");
+       off = karo_fdt_find_panel(blob, dt_node, name);
        panel_off = fdt_path_offset(blob, panel_name);
        if (panel_off > 0) {
-               char *pn;
+               int node = fdt_subnode_offset(blob, dt_node, name);
 
-               name = fdt_getprop(blob, off, "u-boot,panel-name",
-                                  NULL);
-               if (!name)
-                       return 0;
-               pn = strdup(name);
-               if (!pn)
-                       return -ENOMEM;
-               debug("%s@%d: Updating 'compatible' property of '%s' from '%s' to '%s'\n",
-                     __func__, __LINE__, fdt_get_name(blob, panel_off, NULL),
-                     (char *)fdt_getprop(blob, panel_off, "compatible", NULL),
-                     pn);
-
-               ret = fdt_setprop_string(blob, panel_off, "compatible",
-                                        pn);
-               if (ret)
-                       printf("Failed to set 'compatible' property of node '%s': %s\n",
-                              fdt_get_name(blob, panel_off, NULL),
-                              fdt_strerror(off));
-               free(pn);
+               if (node < 0) {
+                       printf("Warning: No '%s' subnode found in 'display-timings'\n",
+                              name);
+                       return -ENOENT;
+               }
+               if (fdt_node_check_compatible(blob, panel_off, "panel-dpi") == 0) {
+                       int timing_node = fdt_subnode_offset(blob, panel_off,
+                                                            "panel-timing");
+
+                       if (timing_node < 0) {
+                               printf("Warning: No 'panel-timing' subnode found\n");
+                               return -ENOENT;
+                       }
+
+                       if (i == 0)
+                               printf("Copying video timing from %s\n", name);
+                       ret = karo_fixup_panel_timing(blob,
+                                                     timing_node,
+                                                     node);
+                       if (ret == -EAGAIN) {
+                               if (i++ > ARRAY_SIZE(karo_panel_timing_props))
+                                       return -EINVAL;
+                               goto restart;
+                       }
+               } else {
+                       char *pn;
+
+                       name = fdt_getprop(blob, off, "u-boot,panel-name",
+                                          NULL);
+                       if (!name)
+                               return 0;
+
+                       pn = strdup(name);
+                       if (!pn)
+                               return -ENOMEM;
+                       debug("%s@%d: Updating 'compatible' property of '%s' from '%s' to '%s'\n",
+                             __func__, __LINE__, fdt_get_name(blob, panel_off, NULL),
+                             (char *)fdt_getprop(blob, panel_off, "compatible", NULL),
+                             pn);
+
+                       ret = fdt_setprop_string(blob, panel_off, "compatible",
+                                                pn);
+                       if (ret)
+                               printf("Failed to set 'compatible' property of node '%s': %s\n",
+                                      fdt_get_name(blob, panel_off, NULL),
+                                      fdt_strerror(off));
+                       free(pn);
+               }
        }
        return ret;
 }
index 2c38e6af05dd4970949b313fb7ac136dea876ea2..ca7b4905c9084c0575be2560348004cf3ef4fd7f 100644 (file)
@@ -18,6 +18,7 @@ config TX6
        select APBH_DMA
        select APBH_DMA_BURST
        select APBH_DMA_BURST8
+       select BOOTP_RANDOM_ID
        select CC_OPTIMIZE_LIBS_FOR_SPEED
        select DM
        select DM_GPIO
index 7e159c0e46eccf182929596f1af6308716aa87f4..45cc87e1bb2b3d27513ad8c6ec6e67e7bbe4b5ee 100644 (file)
@@ -37,7 +37,7 @@ static int rn5t567_setup_regs(uchar slave_addr, struct pmic_regs *r,
                                __func__, r->addr, ret);
                        return ret;
                }
-               newval = (value & ~r->mask) | r->val;
+               newval = (value & r->mask) | r->val;
 #ifdef DEBUG
                if (value != newval) {
                        printf("Changing PMIC reg %02x from %02x to %02x\n",
index ffd300eb8e40f015a2770f62e23bd4686e3a1b67..930bed82aee184e71a244ae2780b71677a2d92bf 100644 (file)
@@ -82,7 +82,7 @@ char __csf_data[0] __attribute__((section(".__csf_data")));
                                             PAD_CTL_DSE_40ohm |        \
                                             PAD_CTL_SRE_SLOW)
 
-static const iomux_v3_cfg_t const tx6qdl_pads[] = {
+static const iomux_v3_cfg_t tx6qdl_pads[] = {
        /* RESET_OUT */
        MX6_PAD_GPIO_17__GPIO7_IO12 | TX6_DEFAULT_PAD_CTRL,
 
@@ -117,7 +117,7 @@ static const iomux_v3_cfg_t const tx6qdl_pads[] = {
        MX6_PAD_SD3_DAT4__GPIO7_IO01 | TX6_DEFAULT_PAD_CTRL, /* PHY INT */
 };
 
-static const iomux_v3_cfg_t const tx6qdl_fec_pads[] = {
+static const iomux_v3_cfg_t tx6qdl_fec_pads[] = {
        /* FEC functions */
        MX6_PAD_ENET_MDC__ENET_MDC | TX6_FEC_PAD_CTRL,
        MX6_PAD_ENET_MDIO__ENET_MDIO | TX6_FEC_PAD_CTRL,
@@ -134,7 +134,7 @@ static const iomux_v3_cfg_t const tx6qdl_fec_pads[] = {
        MX6_PAD_ENET_TXD0__ENET_TX_DATA0 | TX6_FEC_PAD_CTRL,
 };
 
-static const iomux_v3_cfg_t const tx6_i2c_gpio_pads[] = {
+static const iomux_v3_cfg_t tx6_i2c_gpio_pads[] = {
        /* internal I2C */
        MX6_PAD_EIM_D28__GPIO3_IO28 | MUX_CFG_SION |
        TX6_GPIO_PAD_CTRL,
@@ -142,13 +142,13 @@ static const iomux_v3_cfg_t const tx6_i2c_gpio_pads[] = {
        TX6_GPIO_PAD_CTRL,
 };
 
-static const iomux_v3_cfg_t const tx6_i2c_pads[] = {
+static const iomux_v3_cfg_t tx6_i2c_pads[] = {
        /* internal I2C */
        MX6_PAD_EIM_D28__I2C1_SDA | TX6_I2C_PAD_CTRL,
        MX6_PAD_EIM_D21__I2C1_SCL | TX6_I2C_PAD_CTRL,
 };
 
-static const struct gpio const tx6qdl_gpios[] = {
+static const struct gpio tx6qdl_gpios[] = {
        /* These two entries are used to forcefully reinitialize the I2C bus */
        { TX6_I2C1_SCL_GPIO, GPIOFLAG_INPUT, "I2C1 SCL", },
        { TX6_I2C1_SDA_GPIO, GPIOFLAG_INPUT, "I2C1 SDA", },
index b12e8017897cd0e0c1194c27e4864389051b438e..ceabaa2a5a9bbc3cedead84a18040b0f4b97f784 100644 (file)
@@ -92,7 +92,7 @@ char __csf_data[0] __attribute__((section(".__csf_data")));
                                        PAD_CTL_PUS_47K_UP)
 
 
-static const iomux_v3_cfg_t const tx6ul_pads[] = {
+static const iomux_v3_cfg_t tx6ul_pads[] = {
        /* UART pads */
 #if CONFIG_MXC_UART_BASE == UART1_BASE
        MX6_PAD_UART1_TX_DATA__UART1_DCE_TX | TX6UL_DEFAULT_PAD_CTRL,
@@ -118,7 +118,7 @@ static const iomux_v3_cfg_t const tx6ul_pads[] = {
        MX6_PAD_SNVS_TAMPER5__GPIO5_IO05 | TX6UL_GPIO_IN_PAD_CTRL, /* PHY INT */
 };
 
-static const iomux_v3_cfg_t const tx6ul_enet1_pads[] = {
+static const iomux_v3_cfg_t tx6ul_enet1_pads[] = {
        /* FEC functions */
        MX6_PAD_GPIO1_IO07__ENET1_MDC | MUX_PAD_CTRL(PAD_CTL_DSE_120ohm |
                                                     PAD_CTL_SPEED_LOW),
@@ -138,7 +138,7 @@ static const iomux_v3_cfg_t const tx6ul_enet1_pads[] = {
        MX6_PAD_ENET1_TX_DATA0__ENET1_TDATA00 | TX6UL_ENET_PAD_CTRL,
 };
 
-static const iomux_v3_cfg_t const tx6ul_enet2_pads[] = {
+static const iomux_v3_cfg_t tx6ul_enet2_pads[] = {
        MX6_PAD_ENET2_TX_CLK__ENET2_REF_CLK2 | MUX_PAD_CTRL(PAD_CTL_SPEED_LOW |
                                                            PAD_CTL_DSE_80ohm |
                                                            PAD_CTL_SRE_SLOW),
@@ -151,7 +151,7 @@ static const iomux_v3_cfg_t const tx6ul_enet2_pads[] = {
        MX6_PAD_ENET2_TX_DATA0__ENET2_TDATA00 | TX6UL_ENET_PAD_CTRL,
 };
 
-static const iomux_v3_cfg_t const tx6ul_i2c_pads[] = {
+static const iomux_v3_cfg_t tx6ul_i2c_pads[] = {
        /* internal I2C */
        MX6_PAD_SNVS_TAMPER1__GPIO5_IO01 | MUX_CFG_SION |
                        TX6UL_I2C_PAD_CTRL, /* I2C SCL */
@@ -159,7 +159,7 @@ static const iomux_v3_cfg_t const tx6ul_i2c_pads[] = {
                        TX6UL_I2C_PAD_CTRL, /* I2C SDA */
 };
 
-static const struct gpio const tx6ul_gpios[] = {
+static const struct gpio tx6ul_gpios[] = {
 #ifdef CONFIG_SYS_I2C_SOFT
        /* These two entries are used to forcefully reinitialize the I2C bus */
        { TX6UL_I2C1_SCL_GPIO, GPIOFLAG_INPUT, "I2C1 SCL", },
@@ -170,7 +170,7 @@ static const struct gpio const tx6ul_gpios[] = {
        { TX6UL_FEC_INT_GPIO, GPIOFLAG_INPUT, "FEC PHY INT", },
 };
 
-static const struct gpio const tx6ul_fec2_gpios[] = {
+static const struct gpio tx6ul_fec2_gpios[] = {
        { TX6UL_FEC2_RST_GPIO, GPIOFLAG_OUTPUT_INIT_LOW, "FEC2 PHY RESET", },
        { TX6UL_FEC2_INT_GPIO, GPIOFLAG_INPUT, "FEC2 PHY INT", },
 };
@@ -418,10 +418,15 @@ static bool tx6ul_temp_check_enabled = true;
 #define tx6ul_temp_check_enabled       0
 #endif
 
+#ifndef CONFIG_SYS_NAND_BLOCKS
+#define CONFIG_SYS_NAND_BLOCKS 0
+#endif
+
 static inline u8 tx6ul_mem_suffix(void)
 {
        return '0' + CONFIG_SYS_SDRAM_CHIP_SIZE / 1024 * 2 +
-               IS_ENABLED(CONFIG_TX6_EMMC);
+               IS_ENABLED(CONFIG_TX6_EMMC) +
+               CONFIG_SYS_NAND_BLOCKS / 2048 * 4;
 }
 
 #ifdef CONFIG_RN5T567
@@ -1387,7 +1392,8 @@ static void tx_tester_board_init(void)
                printf("Failed to request TX-Tester GPIOs: %d\n", ret);
                return;
        }
-       imx_iomux_v3_setup_multiple_pads(stk5_pads, ARRAY_SIZE(stk5_pads));
+       imx_iomux_v3_setup_multiple_pads(tx_tester_pads,
+                                        ARRAY_SIZE(tx_tester_pads));
 
        if (wrsr & WRSR_TOUT)
                gpio_set_value(IMX_GPIO_NR(5, 4), 1);
diff --git a/configs/tx6ul-5014_defconfig b/configs/tx6ul-5014_defconfig
new file mode 100644 (file)
index 0000000..7b32320
--- /dev/null
@@ -0,0 +1,30 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MX6=y
+CONFIG_TARGET_TX6=y
+CONFIG_SYS_SDRAM_CHIP_SIZE=512
+CONFIG_TARGET_TX6UL_NAND=y
+CONFIG_SYS_EXTRA_OPTIONS="SYS_NAND_BLOCKS=2048"
+CONFIG_SYS_PROMPT="TX6UL U-Boot > "
+CONFIG_CMD_BOOTCE=y
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_NAND=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_DHCP=y
+CONFIG_BOOTP_DNS=y
+CONFIG_BOOTP_GATEWAY=y
+CONFIG_BOOTP_SUBNETMASK=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_TIME=y
+CONFIG_CMD_FUSE=y
+CONFIG_ENV_IS_IN_NAND=y
+CONFIG_LCD=y
+CONFIG_DOS_PARTITION=y
+CONFIG_MMC=y
+CONFIG_NETDEVICES=y
+CONFIG_FEC_MXC=y
+CONFIG_PHY_SMSC=y
+CONFIG_IMX_WATCHDOG=y
diff --git a/configs/tx6ul-5014_mfg_defconfig b/configs/tx6ul-5014_mfg_defconfig
new file mode 100644 (file)
index 0000000..ef5b7d8
--- /dev/null
@@ -0,0 +1,29 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MX6=y
+CONFIG_TARGET_TX6=y
+CONFIG_SYS_SDRAM_CHIP_SIZE=512
+CONFIG_TARGET_TX6UL_NAND=y
+CONFIG_TX6_UBOOT_MFG=y
+CONFIG_SYS_EXTRA_OPTIONS="SYS_NAND_BLOCKS=2048"
+CONFIG_SYS_PROMPT="TX6UL U-Boot > "
+CONFIG_CMD_BOOTCE=y
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_NAND=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_DHCP=y
+CONFIG_BOOTP_DNS=y
+CONFIG_BOOTP_GATEWAY=y
+CONFIG_BOOTP_SUBNETMASK=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_TIME=y
+CONFIG_CMD_FUSE=y
+CONFIG_ENV_IS_IN_NAND=y
+CONFIG_DOS_PARTITION=y
+CONFIG_MMC=y
+CONFIG_NETDEVICES=y
+CONFIG_FEC_MXC=y
+CONFIG_PHY_SMSC=y
+CONFIG_IMX_WATCHDOG=y
diff --git a/configs/tx6ul-5014_noenv_defconfig b/configs/tx6ul-5014_noenv_defconfig
new file mode 100644 (file)
index 0000000..6c87d6e
--- /dev/null
@@ -0,0 +1,29 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MX6=y
+CONFIG_TARGET_TX6=y
+CONFIG_SYS_SDRAM_CHIP_SIZE=512
+CONFIG_TARGET_TX6UL_NAND=y
+CONFIG_TX6_UBOOT_NOENV=y
+CONFIG_SYS_EXTRA_OPTIONS="SYS_NAND_BLOCKS=2048"
+CONFIG_SYS_PROMPT="TX6UL U-Boot > "
+CONFIG_CMD_BOOTCE=y
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_NAND=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_DHCP=y
+CONFIG_BOOTP_DNS=y
+CONFIG_BOOTP_GATEWAY=y
+CONFIG_BOOTP_SUBNETMASK=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_TIME=y
+CONFIG_CMD_FUSE=y
+CONFIG_ENV_IS_IN_NAND=y
+CONFIG_DOS_PARTITION=y
+CONFIG_MMC=y
+CONFIG_NETDEVICES=y
+CONFIG_FEC_MXC=y
+CONFIG_PHY_SMSC=y
+CONFIG_IMX_WATCHDOG=y
diff --git a/configs/tx6ul-5014_sec_defconfig b/configs/tx6ul-5014_sec_defconfig
new file mode 100644 (file)
index 0000000..195bede
--- /dev/null
@@ -0,0 +1,29 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MX6=y
+CONFIG_TARGET_TX6=y
+CONFIG_SYS_SDRAM_CHIP_SIZE=512
+CONFIG_TARGET_TX6UL_NAND=y
+CONFIG_SYS_EXTRA_OPTIONS="SECURE_BOOT,SYS_NAND_BLOCKS=2048"
+CONFIG_SYS_PROMPT="TX6UL U-Boot > "
+CONFIG_CMD_BOOTCE=y
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_NAND=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_DHCP=y
+CONFIG_BOOTP_DNS=y
+CONFIG_BOOTP_GATEWAY=y
+CONFIG_BOOTP_SUBNETMASK=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_TIME=y
+CONFIG_CMD_FUSE=y
+CONFIG_ENV_IS_IN_NAND=y
+CONFIG_LCD=y
+CONFIG_DOS_PARTITION=y
+CONFIG_MMC=y
+CONFIG_NETDEVICES=y
+CONFIG_FEC_MXC=y
+CONFIG_PHY_SMSC=y
+CONFIG_IMX_WATCHDOG=y
index d96c201e8316b7ae8e950eba0d807aa5fe1403f9..4b250e14a93ce424b6caef75b3978859c2199027 100644 (file)
@@ -217,7 +217,7 @@ static int pinctrl_post_bind(struct udevice *dev)
        const struct pinctrl_ops *ops = pinctrl_get_ops(dev);
 
        if (!ops) {
-               dev_dbg(dev, "ops is not set.  Do not bind.\n");
+               dev_err(dev, "ops is not set.  Do not bind.\n");
                return -EINVAL;
        }
 
index abe9391d3d66bf9f2b2e3f36757c5c8e3c95a215..f30b4f812e6d4b8495e8b08fc0c59bb84e9ce851 100644 (file)
 #include <malloc.h>
 #include <common.h>
 #include <g_dnl.h>
+#include <watchdog.h>
 
 #include <linux/err.h>
 #include <linux/usb/ch9.h>
@@ -682,6 +683,8 @@ static int sleep_thread(struct fsg_common *common)
                        if (ctrlc())
                                return -EPIPE;
 
+                       WATCHDOG_RESET();
+
                        /* Check cable connection */
                        if (!g_dnl_board_usb_cable_connected())
                                return -EIO;
index 72505eda935451d60c4ba3fcfeb2a167298181ea..3cc0c6a65db500c92490d41b0c33fb481b0be7ba 100644 (file)
 #define CONFIG_SYS_MALLOC_LEN          SZ_8M
 #define CONFIG_SYS_MEMTEST_START       PHYS_SDRAM_1    /* Memtest start address */
 #define CONFIG_SYS_MEMTEST_END         (CONFIG_SYS_MEMTEST_START + SZ_4M)
+#define CONFIG_SYS_BOOTM_LEN           SZ_32M
 
 /*
  * U-Boot general configurations
 #define CONFIG_FAT_WRITE
 #define CONFIG_CMD_EXT2
 #define CONFIG_CMD_GPT
+#define CONFIG_CMD_FS_GENERIC
 #define CONFIG_PARTITION_UUIDS
 #define CONFIG_EFI_PARTITION
 
index e057bd2a844d685b7b30b7f3de2f49a5a8495ccf..22ab246feed34c104038d3f94e1401ea9a587f8f 100644 (file)
@@ -5,14 +5,28 @@
 /*
  * Common definitions for all gcc versions go here.
  */
-#define GCC_VERSION (__GNUC__ * 10000 \
-                  + __GNUC_MINOR__ * 100 \
-                  + __GNUC_PATCHLEVEL__)
-
+#define GCC_VERSION (__GNUC__ * 10000          \
+                    + __GNUC_MINOR__ * 100     \
+                    + __GNUC_PATCHLEVEL__)
 
 /* Optimization barrier */
+
 /* The "volatile" is due to gcc bugs */
 #define barrier() __asm__ __volatile__("": : :"memory")
+/*
+ * This version is i.e. to prevent dead stores elimination on @ptr
+ * where gcc and llvm may behave differently when otherwise using
+ * normal barrier(): while gcc behavior gets along with a normal
+ * barrier(), llvm needs an explicit input variable to be assumed
+ * clobbered. The issue is as follows: while the inline asm might
+ * access any memory it wants, the compiler could have fit all of
+ * @ptr into memory registers instead, and since @ptr never escaped
+ * from that, it proofed that the inline asm wasn't touching any of
+ * it. This version works well with both compilers, i.e. we're telling
+ * the compiler that the inline asm absolutely may see the contents
+ * of @ptr. See also: https://llvm.org/bugs/show_bug.cgi?id=15495
+ */
+#define barrier_data(ptr) __asm__ __volatile__("": :"r"(ptr) :"memory")
 
 /*
  * This macro obfuscates arithmetic on a variable address so that gcc
  * the inline assembly constraint from =g to =r, in this particular
  * case either is valid.
  */
-#define RELOC_HIDE(ptr, off)                                   \
-  ({ unsigned long __ptr;                                      \
-    __asm__ ("" : "=r"(__ptr) : "0"(ptr));             \
-    (typeof(ptr)) (__ptr + (off)); })
+#define RELOC_HIDE(ptr, off)                                           \
+({                                                                     \
+       unsigned long __ptr;                                            \
+       __asm__ ("" : "=r"(__ptr) : "0"(ptr));                          \
+       (typeof(ptr)) (__ptr + (off));                                  \
+})
 
 /* Make the optimizer believe the variable can be manipulated arbitrarily. */
-#define OPTIMIZER_HIDE_VAR(var) __asm__ ("" : "=r" (var) : "0" (var))
+#define OPTIMIZER_HIDE_VAR(var)                                                \
+       __asm__ ("" : "=r" (var) : "0" (var))
 
 #ifdef __CHECKER__
-#define __must_be_array(arr) 0
+#define __must_be_array(a)     0
 #else
 /* &a[0] degrades to a pointer: a different type from an array */
-#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
+#define __must_be_array(a)     BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
 #endif
 
 /*
  * Force always-inline if the user requests it so via the .config,
  * or if gcc is too old:
  */
-#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
+#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) ||               \
     !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
-# define inline                inline          __attribute__((always_inline)) notrace
-# define __inline__    __inline__      __attribute__((always_inline)) notrace
-# define __inline      __inline        __attribute__((always_inline)) notrace
+#define inline         inline          __attribute__((always_inline)) notrace
+#define __inline__     __inline__      __attribute__((always_inline)) notrace
+#define __inline       __inline        __attribute__((always_inline)) notrace
 #else
 /* A lot of inline functions can cause havoc with function tracing */
-# define inline                inline          notrace
-# define __inline__    __inline__      notrace
-# define __inline      __inline        notrace
+#define inline         inline          notrace
+#define __inline__     __inline__      notrace
+#define __inline       __inline        notrace
 #endif
 
-#define __deprecated                   __attribute__((deprecated))
-#ifndef __packed
-#define __packed                       __attribute__((packed))
-#endif
-#ifndef __weak
-#define __weak                         __attribute__((weak))
-#endif
+#define __always_inline        inline __attribute__((always_inline))
+#define  noinline      __attribute__((noinline))
+
+#define __deprecated   __attribute__((deprecated))
+#define __packed       __attribute__((packed))
+#define __weak         __attribute__((weak))
+#define __alias(symbol)        __attribute__((alias(#symbol)))
 
 /*
- * it doesn't make sense on ARM (currently the only user of __naked) to trace
- * naked functions because then mcount is called without stack and frame pointer
- * being set up and there is no chance to restore the lr register to the value
- * before mcount was called.
+ * it doesn't make sense on ARM (currently the only user of __naked)
+ * to trace naked functions because then mcount is called without
+ * stack and frame pointer being set up and there is no chance to
+ * restore the lr register to the value before mcount was called.
+ *
+ * The asm() bodies of naked functions often depend on standard calling
+ * conventions, therefore they must be noinline and noclone.
  *
- * The asm() bodies of naked functions often depend on standard calling conventions,
- * therefore they must be noinline and noclone.  GCC 4.[56] currently fail to enforce
- * this, so we must do so ourselves.  See GCC PR44290.
+ * GCC 4.[56] currently fail to enforce this, so we must do so ourselves.
+ * See GCC PR44290.
  */
-#define __naked                                __attribute__((naked)) noinline __noclone notrace
+#define __naked                __attribute__((naked)) noinline __noclone notrace
 
-#define __noreturn                     __attribute__((noreturn))
+#define __noreturn     __attribute__((noreturn))
 
 /*
  * From the GCC manual:
  * would be.
  * [...]
  */
-#ifndef __pure
-#define __pure                         __attribute__((pure))
+#define __pure                 __attribute__((pure))
+#define __aligned(x)           __attribute__((aligned(x)))
+#define __printf(a, b)         __attribute__((format(printf, a, b)))
+#define __scanf(a, b)          __attribute__((format(scanf, a, b)))
+#define __attribute_const__    __attribute__((__const__))
+#define __maybe_unused         __attribute__((unused))
+#define __always_unused                __attribute__((unused))
+
+/* gcc version specific checks */
+
+#if GCC_VERSION < 30200
+# error Sorry, your compiler is too old - please upgrade it.
+#endif
+
+#if GCC_VERSION < 30300
+# define __used                        __attribute__((__unused__))
+#else
+# define __used                        __attribute__((__used__))
+#endif
+
+#ifdef CONFIG_GCOV_KERNEL
+# if GCC_VERSION < 30400
+#   error "GCOV profiling support for gcc versions below 3.4 not included"
+# endif /* __GNUC_MINOR__ */
+#endif /* CONFIG_GCOV_KERNEL */
+
+#if GCC_VERSION >= 30400
+#define __must_check           __attribute__((warn_unused_result))
+#endif
+
+#if GCC_VERSION >= 40000
+
+/* GCC 4.1.[01] miscompiles __weak */
+#ifdef __KERNEL__
+# if GCC_VERSION >= 40100 &&  GCC_VERSION <= 40101
+#  error Your version of gcc miscompiles the __weak directive
+# endif
+#endif
+
+#define __used                 __attribute__((__used__))
+#define __compiler_offsetof(a, b)                                      \
+       __builtin_offsetof(a, b)
+
+#if GCC_VERSION >= 40100 && GCC_VERSION < 40600
+# define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
+#endif
+
+#if GCC_VERSION >= 40300
+/* Mark functions as cold. gcc will assume any path leading to a call
+ * to them will be unlikely.  This means a lot of manual unlikely()s
+ * are unnecessary now for any paths leading to the usual suspects
+ * like BUG(), printk(), panic() etc. [but let's keep them for now for
+ * older compilers]
+ *
+ * Early snapshots of gcc 4.3 don't support this and we can't detect this
+ * in the preprocessor, but we can live with this because they're unreleased.
+ * Maketime probing would be overkill here.
+ *
+ * gcc also has a __attribute__((__hot__)) to move hot functions into
+ * a special section, but I don't see any sense in this right now in
+ * the kernel context
+ */
+#define __cold                 __attribute__((__cold__))
+
+#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
+
+#ifndef __CHECKER__
+# define __compiletime_warning(message) __attribute__((warning(message)))
+# define __compiletime_error(message) __attribute__((error(message)))
+#endif /* __CHECKER__ */
+#endif /* GCC_VERSION >= 40300 */
+
+#if GCC_VERSION >= 40500
+/*
+ * Mark a position in code as unreachable.  This can be used to
+ * suppress control flow warnings after asm blocks that transfer
+ * control elsewhere.
+ *
+ * Early snapshots of gcc 4.5 don't support this and we can't detect
+ * this in the preprocessor, but we can live with this because they're
+ * unreleased.  Really, we need to have autoconf for the kernel.
+ */
+#define unreachable() __builtin_unreachable()
+
+/* Mark a function definition as prohibited from being cloned. */
+#define __noclone      __attribute__((__noclone__))
+
+#endif /* GCC_VERSION >= 40500 */
+
+#if GCC_VERSION >= 40600
+/*
+ * When used with Link Time Optimization, gcc can optimize away C functions or
+ * variables which are referenced only from assembly code.  __visible tells the
+ * optimizer that something else uses this function or variable, thus preventing
+ * this.
+ */
+#define __visible      __attribute__((externally_visible))
 #endif
-#ifndef __aligned
-#define __aligned(x)                   __attribute__((aligned(x)))
+
+
+#if GCC_VERSION >= 40900 && !defined(__CHECKER__)
+/*
+ * __assume_aligned(n, k): Tell the optimizer that the returned
+ * pointer can be assumed to be k modulo n. The second argument is
+ * optional (default 0), so we use a variadic macro to make the
+ * shorthand.
+ *
+ * Beware: Do not apply this to functions which may return
+ * ERR_PTRs. Also, it is probably unwise to apply it to functions
+ * returning extra information in the low bits (but in that case the
+ * compiler should see some alignment anyway, when the return value is
+ * massaged by 'flags = ptr & 3; ptr &= ~3;').
+ */
+#define __assume_aligned(a, ...) __attribute__((__assume_aligned__(a, ## __VA_ARGS__)))
 #endif
-#define __printf(a, b)                 __attribute__((format(printf, a, b)))
-#define __scanf(a, b)                  __attribute__((format(scanf, a, b)))
-#define  noinline                      __attribute__((noinline))
-#define __attribute_const__            __attribute__((__const__))
-#define __maybe_unused                 __attribute__((unused))
-#define __always_unused                        __attribute__((unused))
 
-#define __gcc_header(x) #x
-#define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h)
-#define gcc_header(x) _gcc_header(x)
-#include gcc_header(__GNUC__)
+/*
+ * GCC 'asm goto' miscompiles certain code sequences:
+ *
+ *   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
+ *
+ * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
+ *
+ * (asm goto is automatically volatile - the naming reflects this.)
+ */
+#define asm_volatile_goto(x...)        do { asm goto(x); asm (""); } while (0)
+
+#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
+#if GCC_VERSION >= 40400
+#define __HAVE_BUILTIN_BSWAP32__
+#define __HAVE_BUILTIN_BSWAP64__
+#endif
+#if GCC_VERSION >= 40800 || (defined(__powerpc__) && GCC_VERSION >= 40600)
+#define __HAVE_BUILTIN_BSWAP16__
+#endif
+#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
+
+#if GCC_VERSION >= 50000
+#define KASAN_ABI_VERSION 4
+#elif GCC_VERSION >= 40902
+#define KASAN_ABI_VERSION 3
+#endif
+
+#if GCC_VERSION >= 40902
+/*
+ * Tell the compiler that address safety instrumentation (KASAN)
+ * should not be applied to that function.
+ * Conflicts with inlining: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368
+ */
+#define __no_sanitize_address __attribute__((no_sanitize_address))
+#endif
+
+#endif /* gcc version >= 40000 specific checks */
 
 #if !defined(__noclone)
 #define __noclone      /* not needed */
 #endif
 
+#if !defined(__no_sanitize_address)
+#define __no_sanitize_address
+#endif
+
 /*
  * A trick to suppress uninitialized variable warning without generating any
  * code
  */
 #define uninitialized_var(x) x = x
-
-#ifndef __always_inline
-#define __always_inline                inline __attribute__((always_inline))
-#endif
diff --git a/include/linux/compiler-gcc3.h b/include/linux/compiler-gcc3.h
deleted file mode 100644 (file)
index 7d89feb..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef __LINUX_COMPILER_H
-#error "Please don't include <linux/compiler-gcc3.h> directly, include <linux/compiler.h> instead."
-#endif
-
-#if GCC_VERSION < 30200
-# error Sorry, your compiler is too old - please upgrade it.
-#endif
-
-#if GCC_VERSION >= 30300
-# define __used                        __attribute__((__used__))
-#else
-# define __used                        __attribute__((__unused__))
-#endif
-
-#if GCC_VERSION >= 30400
-#define __must_check           __attribute__((warn_unused_result))
-#endif
-
-#ifdef CONFIG_GCOV_KERNEL
-# if GCC_VERSION < 30400
-#   error "GCOV profiling support for gcc versions below 3.4 not included"
-# endif /* __GNUC_MINOR__ */
-#endif /* CONFIG_GCOV_KERNEL */
diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
deleted file mode 100644 (file)
index 2507fd2..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef __LINUX_COMPILER_H
-#error "Please don't include <linux/compiler-gcc4.h> directly, include <linux/compiler.h> instead."
-#endif
-
-/* GCC 4.1.[01] miscompiles __weak */
-#ifdef __KERNEL__
-# if GCC_VERSION >= 40100 &&  GCC_VERSION <= 40101
-#  error Your version of gcc miscompiles the __weak directive
-# endif
-#endif
-
-#define __used                 __attribute__((__used__))
-#define __must_check           __attribute__((warn_unused_result))
-#define __compiler_offsetof(a,b) __builtin_offsetof(a,b)
-
-#if GCC_VERSION >= 40100 && GCC_VERSION < 40600
-# define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
-#endif
-
-#if GCC_VERSION >= 40300
-/* Mark functions as cold. gcc will assume any path leading to a call
-   to them will be unlikely.  This means a lot of manual unlikely()s
-   are unnecessary now for any paths leading to the usual suspects
-   like BUG(), printk(), panic() etc. [but let's keep them for now for
-   older compilers]
-
-   Early snapshots of gcc 4.3 don't support this and we can't detect this
-   in the preprocessor, but we can live with this because they're unreleased.
-   Maketime probing would be overkill here.
-
-   gcc also has a __attribute__((__hot__)) to move hot functions into
-   a special section, but I don't see any sense in this right now in
-   the kernel context */
-#define __cold                 __attribute__((__cold__))
-
-#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
-
-#ifndef __CHECKER__
-# define __compiletime_warning(message) __attribute__((warning(message)))
-# define __compiletime_error(message) __attribute__((error(message)))
-#endif /* __CHECKER__ */
-#endif /* GCC_VERSION >= 40300 */
-
-#if GCC_VERSION >= 40500
-/*
- * Mark a position in code as unreachable.  This can be used to
- * suppress control flow warnings after asm blocks that transfer
- * control elsewhere.
- *
- * Early snapshots of gcc 4.5 don't support this and we can't detect
- * this in the preprocessor, but we can live with this because they're
- * unreleased.  Really, we need to have autoconf for the kernel.
- */
-#define unreachable() __builtin_unreachable()
-
-/* Mark a function definition as prohibited from being cloned. */
-#define __noclone      __attribute__((__noclone__))
-
-#endif /* GCC_VERSION >= 40500 */
-
-#if GCC_VERSION >= 40600
-/*
- * Tell the optimizer that something else uses this function or variable.
- */
-#define __visible __attribute__((externally_visible))
-#endif
-
-/*
- * GCC 'asm goto' miscompiles certain code sequences:
- *
- *   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
- *
- * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
- * Fixed in GCC 4.8.2 and later versions.
- *
- * (asm goto is automatically volatile - the naming reflects this.)
- */
-#define asm_volatile_goto(x...)        do { asm goto(x); asm (""); } while (0)
-
-#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
-#if GCC_VERSION >= 40400
-#define __HAVE_BUILTIN_BSWAP32__
-#define __HAVE_BUILTIN_BSWAP64__
-#endif
-#if GCC_VERSION >= 40800 || (defined(__powerpc__) && GCC_VERSION >= 40600)
-#define __HAVE_BUILTIN_BSWAP16__
-#endif
-#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
diff --git a/include/linux/compiler-gcc5.h b/include/linux/compiler-gcc5.h
deleted file mode 100644 (file)
index c8c5659..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#ifndef __LINUX_COMPILER_H
-#error "Please don't include <linux/compiler-gcc5.h> directly, include <linux/compiler.h> instead."
-#endif
-
-#define __used                         __attribute__((__used__))
-#define __must_check                   __attribute__((warn_unused_result))
-#define __compiler_offsetof(a, b)      __builtin_offsetof(a, b)
-
-/* Mark functions as cold. gcc will assume any path leading to a call
-   to them will be unlikely.  This means a lot of manual unlikely()s
-   are unnecessary now for any paths leading to the usual suspects
-   like BUG(), printk(), panic() etc. [but let's keep them for now for
-   older compilers]
-
-   Early snapshots of gcc 4.3 don't support this and we can't detect this
-   in the preprocessor, but we can live with this because they're unreleased.
-   Maketime probing would be overkill here.
-
-   gcc also has a __attribute__((__hot__)) to move hot functions into
-   a special section, but I don't see any sense in this right now in
-   the kernel context */
-#define __cold                 __attribute__((__cold__))
-
-#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
-
-#ifndef __CHECKER__
-# define __compiletime_warning(message) __attribute__((warning(message)))
-# define __compiletime_error(message) __attribute__((error(message)))
-#endif /* __CHECKER__ */
-
-/*
- * Mark a position in code as unreachable.  This can be used to
- * suppress control flow warnings after asm blocks that transfer
- * control elsewhere.
- *
- * Early snapshots of gcc 4.5 don't support this and we can't detect
- * this in the preprocessor, but we can live with this because they're
- * unreleased.  Really, we need to have autoconf for the kernel.
- */
-#define unreachable() __builtin_unreachable()
-
-/* Mark a function definition as prohibited from being cloned. */
-#define __noclone      __attribute__((__noclone__))
-
-/*
- * Tell the optimizer that something else uses this function or variable.
- */
-#define __visible __attribute__((externally_visible))
-
-/*
- * GCC 'asm goto' miscompiles certain code sequences:
- *
- *   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
- *
- * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
- *
- * (asm goto is automatically volatile - the naming reflects this.)
- */
-#define asm_volatile_goto(x...)        do { asm goto(x); asm (""); } while (0)
-
-#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
-#define __HAVE_BUILTIN_BSWAP32__
-#define __HAVE_BUILTIN_BSWAP64__
-#define __HAVE_BUILTIN_BSWAP16__
-#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
index ba147a1727e6d2fc22c7899fcb5830803c629f41..d4c71132d07f0bd03b22766310455b8c133b6070 100644 (file)
 /* Intel ECC compiler doesn't support gcc specific asm stmts.
  * It uses intrinsics to do the equivalent things.
  */
+#undef barrier
+#undef barrier_data
 #undef RELOC_HIDE
 #undef OPTIMIZER_HIDE_VAR
 
+#define barrier() __memory_barrier()
+#define barrier_data(ptr) barrier()
+
 #define RELOC_HIDE(ptr, off)                                   \
   ({ unsigned long __ptr;                                      \
      __ptr = (unsigned long) (ptr);                            \
index d5ad7b1118fc10748377d9a90d2e960e0f7b611a..020ad16a0493e0348608d7f98c529d249cb6d609 100644 (file)
@@ -17,6 +17,7 @@
 # define __release(x)  __context__(x,-1)
 # define __cond_lock(x,c)      ((c) ? ({ __acquire(x); 1; }) : 0)
 # define __percpu      __attribute__((noderef, address_space(3)))
+# define __pmem                __attribute__((noderef, address_space(5)))
 #ifdef CONFIG_SPARSE_RCU_POINTER
 # define __rcu         __attribute__((noderef, address_space(4)))
 #else
@@ -42,6 +43,7 @@ extern void __chk_io_ptr(const volatile void __iomem *);
 # define __cond_lock(x,c) (c)
 # define __percpu
 # define __rcu
+# define __pmem
 #endif
 
 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
@@ -54,7 +56,11 @@ extern void __chk_io_ptr(const volatile void __iomem *);
 #include <linux/compiler-gcc.h>
 #endif
 
+#if defined(CC_USING_HOTPATCH) && !defined(__CHECKER__)
+#define notrace __attribute__((hotpatch(0,0)))
+#else
 #define notrace __attribute__((no_instrument_function))
+#endif
 
 /* Intel compiler defines __GNUC__. So we will overwrite implementations
  * coming from above header files here
@@ -138,7 +144,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
  */
 #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
 #define __trace_if(cond) \
-       if (__builtin_constant_p((cond)) ? !!(cond) :                   \
+       if (__builtin_constant_p(!!(cond)) ? !!(cond) :                 \
        ({                                                              \
                int ______r;                                            \
                static struct ftrace_branch_data                        \
@@ -165,6 +171,10 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
 # define barrier() __memory_barrier()
 #endif
 
+#ifndef barrier_data
+# define barrier_data(ptr) barrier()
+#endif
+
 /* Unreachable code */
 #ifndef unreachable
 # define unreachable() do { } while (1)
@@ -186,6 +196,126 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
 # define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __LINE__)
 #endif
 
+#include <linux/types.h>
+
+#define __READ_ONCE_SIZE                                               \
+({                                                                     \
+       switch (size) {                                                 \
+       case 1: *(__u8 *)res = *(volatile __u8 *)p; break;              \
+       case 2: *(__u16 *)res = *(volatile __u16 *)p; break;            \
+       case 4: *(__u32 *)res = *(volatile __u32 *)p; break;            \
+       case 8: *(__u64 *)res = *(volatile __u64 *)p; break;            \
+       default:                                                        \
+               barrier();                                              \
+               __builtin_memcpy((void *)res, (const void *)p, size);   \
+               barrier();                                              \
+       }                                                               \
+})
+
+static __always_inline
+void __read_once_size(const volatile void *p, void *res, int size)
+{
+       __READ_ONCE_SIZE;
+}
+
+#ifdef CONFIG_KASAN
+/*
+ * This function is not 'inline' because __no_sanitize_address confilcts
+ * with inlining. Attempt to inline it may cause a build failure.
+ *     https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368
+ * '__maybe_unused' allows us to avoid defined-but-not-used warnings.
+ */
+static __no_sanitize_address __maybe_unused
+void __read_once_size_nocheck(const volatile void *p, void *res, int size)
+{
+       __READ_ONCE_SIZE;
+}
+#else
+static __always_inline
+void __read_once_size_nocheck(const volatile void *p, void *res, int size)
+{
+       __READ_ONCE_SIZE;
+}
+#endif
+
+static __always_inline void __write_once_size(volatile void *p, void *res, int size)
+{
+       switch (size) {
+       case 1: *(volatile __u8 *)p = *(__u8 *)res; break;
+       case 2: *(volatile __u16 *)p = *(__u16 *)res; break;
+       case 4: *(volatile __u32 *)p = *(__u32 *)res; break;
+       case 8: *(volatile __u64 *)p = *(__u64 *)res; break;
+       default:
+               barrier();
+               __builtin_memcpy((void *)p, (const void *)res, size);
+               barrier();
+       }
+}
+
+/*
+ * Prevent the compiler from merging or refetching reads or writes. The
+ * compiler is also forbidden from reordering successive instances of
+ * READ_ONCE, WRITE_ONCE and ACCESS_ONCE (see below), but only when the
+ * compiler is aware of some particular ordering.  One way to make the
+ * compiler aware of ordering is to put the two invocations of READ_ONCE,
+ * WRITE_ONCE or ACCESS_ONCE() in different C statements.
+ *
+ * In contrast to ACCESS_ONCE these two macros will also work on aggregate
+ * data types like structs or unions. If the size of the accessed data
+ * type exceeds the word size of the machine (e.g., 32 bits or 64 bits)
+ * READ_ONCE() and WRITE_ONCE()  will fall back to memcpy and print a
+ * compile-time warning.
+ *
+ * Their two major use cases are: (1) Mediating communication between
+ * process-level code and irq/NMI handlers, all running on the same CPU,
+ * and (2) Ensuring that the compiler does not  fold, spindle, or otherwise
+ * mutilate accesses that either do not require ordering or that interact
+ * with an explicit memory barrier or atomic instruction that provides the
+ * required ordering.
+ */
+
+#define __READ_ONCE(x, check)                                          \
+({                                                                     \
+       union { typeof(x) __val; char __c[1]; } __u;                    \
+       if (check)                                                      \
+               __read_once_size(&(x), __u.__c, sizeof(x));             \
+       else                                                            \
+               __read_once_size_nocheck(&(x), __u.__c, sizeof(x));     \
+       __u.__val;                                                      \
+})
+#define READ_ONCE(x) __READ_ONCE(x, 1)
+
+/*
+ * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need
+ * to hide memory access from KASAN.
+ */
+#define READ_ONCE_NOCHECK(x) __READ_ONCE(x, 0)
+
+#define WRITE_ONCE(x, val) \
+({                                                     \
+       union { typeof(x) __val; char __c[1]; } __u =   \
+               { .__val = (__force typeof(x)) (val) }; \
+       __write_once_size(&(x), __u.__c, sizeof(x));    \
+       __u.__val;                                      \
+})
+
+/**
+ * smp_cond_acquire() - Spin wait for cond with ACQUIRE ordering
+ * @cond: boolean expression to wait for
+ *
+ * Equivalent to using smp_load_acquire() on the condition variable but employs
+ * the control dependency of the wait to reduce the barrier on many platforms.
+ *
+ * The control dependency provides a LOAD->STORE order, the additional RMB
+ * provides LOAD->LOAD order, together they provide LOAD->{LOAD,STORE} order,
+ * aka. ACQUIRE.
+ */
+#define smp_cond_acquire(cond) do {            \
+       while (!(cond))                         \
+               cpu_relax();                    \
+       smp_rmb(); /* ctrl + rmb := acquire */  \
+} while (0)
+
 #endif /* __KERNEL__ */
 
 #endif /* __ASSEMBLY__ */
@@ -304,6 +434,14 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
 #define __visible
 #endif
 
+/*
+ * Assume alignment of return value.
+ */
+#ifndef __assume_aligned
+#define __assume_aligned(a, ...)
+#endif
+
+
 /* Are two types/vars the same type (ignoring qualifiers)? */
 #ifndef __same_type
 # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
@@ -311,7 +449,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
 
 /* Is this type a native word size -- useful for atomic operations */
 #ifndef __native_word
-# define __native_word(t) (sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
+# define __native_word(t) (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
 #endif
 
 /* Compile time object size, -1 for unknown */
@@ -373,12 +511,38 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
  * to make the compiler aware of ordering is to put the two invocations of
  * ACCESS_ONCE() in different C statements.
  *
- * This macro does absolutely -nothing- to prevent the CPU from reordering,
- * merging, or refetching absolutely anything at any time.  Its main intended
- * use is to mediate communication between process-level code and irq/NMI
- * handlers, all running on the same CPU.
+ * ACCESS_ONCE will only work on scalar types. For union types, ACCESS_ONCE
+ * on a union member will work as long as the size of the member matches the
+ * size of the union and the size is smaller than word size.
+ *
+ * The major use cases of ACCESS_ONCE used to be (1) Mediating communication
+ * between process-level code and irq/NMI handlers, all running on the same CPU,
+ * and (2) Ensuring that the compiler does not  fold, spindle, or otherwise
+ * mutilate accesses that either do not require ordering or that interact
+ * with an explicit memory barrier or atomic instruction that provides the
+ * required ordering.
+ *
+ * If possible use READ_ONCE()/WRITE_ONCE() instead.
+ */
+#define __ACCESS_ONCE(x) ({ \
+        __maybe_unused typeof(x) __var = (__force typeof(x)) 0; \
+       (volatile typeof(x) *)&(x); })
+#define ACCESS_ONCE(x) (*__ACCESS_ONCE(x))
+
+/**
+ * lockless_dereference() - safely load a pointer for later dereference
+ * @p: The pointer to load
+ *
+ * Similar to rcu_dereference(), but for situations where the pointed-to
+ * object's lifetime is managed by something other than RCU.  That
+ * "something other" might be reference counting or simple immortality.
  */
-#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
+#define lockless_dereference(p) \
+({ \
+       typeof(p) _________p1 = READ_ONCE(p); \
+       smp_read_barrier_depends(); /* Dependency order vs. p above. */ \
+       (_________p1); \
+})
 
 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
 #ifdef CONFIG_KPROBES
index af8617bea6c51b5da319860c938ff64bb42aea6c..9a34360fc5ed92bad58bf16f36d2ceec7d0bfe06 100644 (file)
@@ -271,10 +271,10 @@ u32 ether_crc(size_t len, unsigned char const *p);
  */
 
 struct ethernet_hdr {
-       u8              et_dest[6];     /* Destination node             */
-       u8              et_src[6];      /* Source node                  */
-       u16             et_protlen;     /* Protocol or length           */
-};
+       u8              et_dest[6];     /* Destination node     */
+       u8              et_src[6];      /* Source node          */
+       u16             et_protlen;             /* Protocol or length   */
+} __attribute__((packed));
 
 /* Ethernet header size */
 #define ETHER_HDR_SIZE (sizeof(struct ethernet_hdr))
@@ -291,8 +291,8 @@ struct e802_hdr {
        u8              et_snap1;       /* SNAP                         */
        u8              et_snap2;
        u8              et_snap3;
-       u16             et_prot;        /* 802 protocol                 */
-};
+       u16             et_prot;                /* 802 protocol         */
+} __attribute__((packed));
 
 /* 802 + SNAP + ethernet header size */
 #define E802_HDR_SIZE  (sizeof(struct e802_hdr))
@@ -301,12 +301,12 @@ struct e802_hdr {
  *     Virtual LAN Ethernet header
  */
 struct vlan_ethernet_hdr {
-       u8              vet_dest[6];    /* Destination node             */
-       u8              vet_src[6];     /* Source node                  */
-       u16             vet_vlan_type;  /* PROT_VLAN                    */
-       u16             vet_tag;        /* TAG of VLAN                  */
-       u16             vet_type;       /* protocol type                */
-};
+       u8              vet_dest[6];    /* Destination node     */
+       u8              vet_src[6];     /* Source node          */
+       u16             vet_vlan_type;          /* PROT_VLAN            */
+       u16             vet_tag;                /* TAG of VLAN          */
+       u16             vet_type;               /* protocol type        */
+} __attribute__((packed));
 
 /* VLAN Ethernet header size */
 #define VLAN_ETHER_HDR_SIZE    (sizeof(struct vlan_ethernet_hdr))
@@ -333,7 +333,7 @@ struct ip_hdr {
        u16             ip_sum;         /* checksum                     */
        struct in_addr  ip_src;         /* Source IP address            */
        struct in_addr  ip_dst;         /* Destination IP address       */
-};
+} __attribute__((packed));
 
 #define IP_OFFS                0x1fff /* ip offset *= 8 */
 #define IP_FLAGS       0xe000 /* first 3 bits */
@@ -361,7 +361,7 @@ struct ip_udp_hdr {
        u16             udp_dst;        /* UDP destination port         */
        u16             udp_len;        /* Length of UDP packet         */
        u16             udp_xsum;       /* Checksum                     */
-};
+} __attribute__((packed));
 
 #define IP_UDP_HDR_SIZE                (sizeof(struct ip_udp_hdr))
 #define UDP_HDR_SIZE           (IP_UDP_HDR_SIZE - IP_HDR_SIZE)
@@ -400,7 +400,7 @@ struct arp_hdr {
        u8              ar_tha[];       /* Target hardware address      */
        u8              ar_tpa[];       /* Target protocol address      */
 #endif /* 0 */
-};
+} __attribute__((packed));
 
 #define ARP_HDR_SIZE   (8+20)          /* Size assuming ethernet       */
 
@@ -435,7 +435,7 @@ struct icmp_hdr {
                } frag;
                u8 data[0];
        } un;
-};
+} __attribute__((packed));
 
 #define ICMP_HDR_SIZE          (sizeof(struct icmp_hdr))
 #define IP_ICMP_HDR_SIZE       (IP_HDR_SIZE + ICMP_HDR_SIZE)
index 53f83626e13b19b500a399cbfbbbf315a9376793..44917e4807d2250ebf87c75aa03619bb2e5a8c2d 100644 (file)
@@ -863,8 +863,8 @@ static void dhcp_process_options(uchar *popt, struct bootp_hdr *bp)
                        if (dhcp_vendorex_proc(popt))
                                break;
 #endif
-                       printf("*** Unhandled DHCP Option in OFFER/ACK:"
-                              " %d\n", *popt);
+                       debug("*** Unhandled DHCP Option in OFFER/ACK: %d\n",
+                             *popt);
                        break;
                }
                popt += oplen + 2;      /* Process next option */
index fcb0a64e6143c550e101e0fd7597a56804e1ef32..567340ec5d4a250498c7c8bdf30675552ab5b831 100644 (file)
@@ -49,7 +49,7 @@ struct bootp_hdr {
        char            bp_sname[64];   /* Server host name             */
        char            bp_file[128];   /* Boot file name               */
        char            bp_vend[OPT_FIELD_SIZE]; /* Vendor information  */
-};
+} __attribute__((packed));
 
 #define BOOTP_HDR_SIZE sizeof(struct bootp_hdr)
 
index c4e96afa0621d783482f8f04865d6f576d5460bf..c55a5c1b04660ab4bf49a73d26a71f1005f2e2b3 100644 (file)
--- a/net/dns.h
+++ b/net/dns.h
@@ -29,7 +29,7 @@ struct header {
        uint16_t        nauth;          /* Authority PRs */
        uint16_t        nother;         /* Other PRs */
        unsigned char   data[1];        /* Data, variable length */
-};
+} __attribute__((packed));
 
 void dns_start(void);          /* Begin DNS */
 
index d69b422f5209da05b6204183c3a59bd6e294c95f..09b387e4c9a35da2a10e53c72286e1991a361919 100644 (file)
--- a/net/nfs.h
+++ b/net/nfs.h
@@ -68,7 +68,7 @@ struct rpc_t {
                        uint32_t data[19];
                } reply;
        } u;
-};
+} __attribute__((packed));
 void nfs_start(void);  /* Begin NFS */
 
 
index 6a9c6bb82fb9bbfe2235a232b29569ce2b85c113..c38bceed3f6a2044a91b970ada43eb2ef95d5889 100644 (file)
@@ -51,7 +51,7 @@ struct sntp_pkt_t {
        unsigned long long originate_timestamp;
        unsigned long long receive_timestamp;
        unsigned long long transmit_timestamp;
-};
+} __attribute__((packed));
 
 void sntp_start(void); /* Begin SNTP */