[U-Boot] [PATCH v2 3/3] rockchip: rk3288: Move rockchip_get_cru() out of the driver

2016-10-01 Thread Simon Glass
This function is called from outside the driver. It should be placed into
common SoC code. Move it.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Rebase to mainline and fix resulting build error
- Add a similar change for rk3036 and rk3399

 arch/arm/include/asm/arch-rockchip/cru_rk3288.h |  7 +++
 arch/arm/mach-rockchip/rk3288/clk_rk3288.c  | 16 
 drivers/clk/rockchip/clk_rk3288.c   | 21 -
 3 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/arch/arm/include/asm/arch-rockchip/cru_rk3288.h 
b/arch/arm/include/asm/arch-rockchip/cru_rk3288.h
index 8a8ca9c..d575f4a 100644
--- a/arch/arm/include/asm/arch-rockchip/cru_rk3288.h
+++ b/arch/arm/include/asm/arch-rockchip/cru_rk3288.h
@@ -25,6 +25,13 @@
 #define PERI_HCLK_HZ   14850
 #define PERI_PCLK_HZ   7425
 
+/* Private data for the clock driver - used by rockchip_get_cru() */
+struct rk3288_clk_priv {
+   struct rk3288_grf *grf;
+   struct rk3288_cru *cru;
+   ulong rate;
+};
+
 struct rk3288_cru {
struct rk3288_pll {
u32 con0;
diff --git a/arch/arm/mach-rockchip/rk3288/clk_rk3288.c 
b/arch/arm/mach-rockchip/rk3288/clk_rk3288.c
index 2099e34..a45b923 100644
--- a/arch/arm/mach-rockchip/rk3288/clk_rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/clk_rk3288.c
@@ -9,9 +9,25 @@
 #include 
 #include 
 #include 
+#include 
 
 int rockchip_get_clk(struct udevice **devp)
 {
return uclass_get_device_by_driver(UCLASS_CLK,
DM_GET_DRIVER(rockchip_rk3288_cru), devp);
 }
+
+void *rockchip_get_cru(void)
+{
+   struct rk3288_clk_priv *priv;
+   struct udevice *dev;
+   int ret;
+
+   ret = rockchip_get_clk();
+   if (ret)
+   return ERR_PTR(ret);
+
+   priv = dev_get_priv(dev);
+
+   return priv->cru;
+}
diff --git a/drivers/clk/rockchip/clk_rk3288.c 
b/drivers/clk/rockchip/clk_rk3288.c
index bd71a96..ed97e87 100644
--- a/drivers/clk/rockchip/clk_rk3288.c
+++ b/drivers/clk/rockchip/clk_rk3288.c
@@ -30,12 +30,6 @@ struct rk3288_clk_plat {
 #endif
 };
 
-struct rk3288_clk_priv {
-   struct rk3288_grf *grf;
-   struct rk3288_cru *cru;
-   ulong rate;
-};
-
 struct pll_div {
u32 nr;
u32 nf;
@@ -140,21 +134,6 @@ static const struct pll_div apll_init_cfg = 
PLL_DIVISORS(APLL_HZ, 1, 1);
 static const struct pll_div gpll_init_cfg = PLL_DIVISORS(GPLL_HZ, 2, 2);
 static const struct pll_div cpll_init_cfg = PLL_DIVISORS(CPLL_HZ, 1, 2);
 
-void *rockchip_get_cru(void)
-{
-   struct rk3288_clk_priv *priv;
-   struct udevice *dev;
-   int ret;
-
-   ret = rockchip_get_clk();
-   if (ret)
-   return ERR_PTR(ret);
-
-   priv = dev_get_priv(dev);
-
-   return priv->cru;
-}
-
 static int rkclk_set_pll(struct rk3288_cru *cru, enum rk_clk_id clk_id,
 const struct pll_div *div)
 {
-- 
2.8.0.rc3.226.g39d4020

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/3] rockchip: rk3036: Move rockchip_get_cru() out of the driver

2016-10-01 Thread Simon Glass
This function is called from outside the driver. It should be placed into
common SoC code. Move it.

Also rename the driver symbol to be more consistent with the other rockchip
clock drivers.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/arm/include/asm/arch-rockchip/cru_rk3036.h |  6 +
 arch/arm/mach-rockchip/rk3036/Makefile  |  2 ++
 arch/arm/mach-rockchip/rk3036/clk_rk3036.c  | 33 +
 drivers/clk/rockchip/clk_rk3036.c   | 24 +-
 4 files changed, 42 insertions(+), 23 deletions(-)
 create mode 100644 arch/arm/mach-rockchip/rk3036/clk_rk3036.c

diff --git a/arch/arm/include/asm/arch-rockchip/cru_rk3036.h 
b/arch/arm/include/asm/arch-rockchip/cru_rk3036.h
index 7ecc8ee..aaef4b9 100644
--- a/arch/arm/include/asm/arch-rockchip/cru_rk3036.h
+++ b/arch/arm/include/asm/arch-rockchip/cru_rk3036.h
@@ -24,6 +24,12 @@
 #define PERI_HCLK_HZ   14850
 #define PERI_PCLK_HZ   7425
 
+/* Private data for the clock driver - used by rockchip_get_cru() */
+struct rk3036_clk_priv {
+   struct rk3036_cru *cru;
+   ulong rate;
+};
+
 struct rk3036_cru {
struct rk3036_pll {
unsigned int con0;
diff --git a/arch/arm/mach-rockchip/rk3036/Makefile 
b/arch/arm/mach-rockchip/rk3036/Makefile
index 916a7a4..20d28f7 100644
--- a/arch/arm/mach-rockchip/rk3036/Makefile
+++ b/arch/arm/mach-rockchip/rk3036/Makefile
@@ -4,6 +4,8 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
+obj-y += clk_rk3036.o
+
 ifndef CONFIG_SPL_BUILD
 obj-y += syscon_rk3036.o
 endif
diff --git a/arch/arm/mach-rockchip/rk3036/clk_rk3036.c 
b/arch/arm/mach-rockchip/rk3036/clk_rk3036.c
new file mode 100644
index 000..6a06afb
--- /dev/null
+++ b/arch/arm/mach-rockchip/rk3036/clk_rk3036.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016 Google, Inc
+ * Written by Simon Glass 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int rockchip_get_clk(struct udevice **devp)
+{
+   return uclass_get_device_by_driver(UCLASS_CLK,
+   DM_GET_DRIVER(rockchip_rk3036_cru), devp);
+}
+
+void *rockchip_get_cru(void)
+{
+   struct rk3036_clk_priv *priv;
+   struct udevice *dev;
+   int ret;
+
+   ret = rockchip_get_clk();
+   if (ret)
+   return ERR_PTR(ret);
+
+   priv = dev_get_priv(dev);
+
+   return priv->cru;
+}
diff --git a/drivers/clk/rockchip/clk_rk3036.c 
b/drivers/clk/rockchip/clk_rk3036.c
index 8899b0c..7e3bf96 100644
--- a/drivers/clk/rockchip/clk_rk3036.c
+++ b/drivers/clk/rockchip/clk_rk3036.c
@@ -19,11 +19,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-struct rk3036_clk_priv {
-   struct rk3036_cru *cru;
-   ulong rate;
-};
-
 enum {
VCO_MAX_HZ  = 2400U * 100,
VCO_MIN_HZ  = 600 * 100,
@@ -49,23 +44,6 @@ enum {
 static const struct pll_div apll_init_cfg = PLL_DIVISORS(APLL_HZ, 1, 3, 1);
 static const struct pll_div gpll_init_cfg = PLL_DIVISORS(GPLL_HZ, 2, 2, 1);
 
-void *rockchip_get_cru(void)
-{
-   struct udevice *dev;
-   fdt_addr_t addr;
-   int ret;
-
-   ret = uclass_get_device(UCLASS_CLK, 0, );
-   if (ret)
-   return ERR_PTR(ret);
-
-   addr = dev_get_addr(dev);
-   if (addr == FDT_ADDR_T_NONE)
-   return ERR_PTR(-EINVAL);
-
-   return (void *)addr;
-}
-
 static int rkclk_set_pll(struct rk3036_cru *cru, enum rk_clk_id clk_id,
 const struct pll_div *div)
 {
@@ -371,7 +349,7 @@ static const struct udevice_id rk3036_clk_ids[] = {
{ }
 };
 
-U_BOOT_DRIVER(clk_rk3036) = {
+U_BOOT_DRIVER(rockchip_rk3036_cru) = {
.name   = "clk_rk3036",
.id = UCLASS_CLK,
.of_match   = rk3036_clk_ids,
-- 
2.8.0.rc3.226.g39d4020

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 2/3] rockchip: rk3399: Move rockchip_get_cru() out of the driver

2016-10-01 Thread Simon Glass
This function is called from outside the driver. It should be placed into
common SoC code. Move it.

Also rename the driver symbol to be more consistent with the other rockchip
clock drivers.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/arm/include/asm/arch-rockchip/cru_rk3399.h |  6 +
 arch/arm/mach-rockchip/rk3399/Makefile  |  1 +
 arch/arm/mach-rockchip/rk3399/clk_rk3399.c  | 33 +
 drivers/clk/rockchip/clk_rk3399.c   | 24 +-
 4 files changed, 41 insertions(+), 23 deletions(-)
 create mode 100644 arch/arm/mach-rockchip/rk3399/clk_rk3399.c

diff --git a/arch/arm/include/asm/arch-rockchip/cru_rk3399.h 
b/arch/arm/include/asm/arch-rockchip/cru_rk3399.h
index 6776e48..98fba2b 100644
--- a/arch/arm/include/asm/arch-rockchip/cru_rk3399.h
+++ b/arch/arm/include/asm/arch-rockchip/cru_rk3399.h
@@ -9,6 +9,12 @@
 
 #include 
 
+/* Private data for the clock driver - used by rockchip_get_cru() */
+struct rk3399_clk_priv {
+   struct rk3399_cru *cru;
+   ulong rate;
+};
+
 struct rk3399_pmucru {
u32 ppll_con[6];
u32 reserved[0x1a];
diff --git a/arch/arm/mach-rockchip/rk3399/Makefile 
b/arch/arm/mach-rockchip/rk3399/Makefile
index 607f9c9..98ebeac 100644
--- a/arch/arm/mach-rockchip/rk3399/Makefile
+++ b/arch/arm/mach-rockchip/rk3399/Makefile
@@ -4,5 +4,6 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
+obj-y += clk_rk3399.o
 obj-y += rk3399.o
 obj-y += syscon_rk3399.o
diff --git a/arch/arm/mach-rockchip/rk3399/clk_rk3399.c 
b/arch/arm/mach-rockchip/rk3399/clk_rk3399.c
new file mode 100644
index 000..7663591
--- /dev/null
+++ b/arch/arm/mach-rockchip/rk3399/clk_rk3399.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016 Google, Inc
+ * Written by Simon Glass 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int rockchip_get_clk(struct udevice **devp)
+{
+   return uclass_get_device_by_driver(UCLASS_CLK,
+   DM_GET_DRIVER(rockchip_rk3399_pmuclk), devp);
+}
+
+void *rockchip_get_cru(void)
+{
+   struct rk3399_clk_priv *priv;
+   struct udevice *dev;
+   int ret;
+
+   ret = rockchip_get_clk();
+   if (ret)
+   return ERR_PTR(ret);
+
+   priv = dev_get_priv(dev);
+
+   return priv->cru;
+}
diff --git a/drivers/clk/rockchip/clk_rk3399.c 
b/drivers/clk/rockchip/clk_rk3399.c
index ea0ce2a..2e87e4b 100644
--- a/drivers/clk/rockchip/clk_rk3399.c
+++ b/drivers/clk/rockchip/clk_rk3399.c
@@ -18,11 +18,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-struct rk3399_clk_priv {
-   struct rk3399_cru *cru;
-   ulong rate;
-};
-
 struct rk3399_pmuclk_priv {
struct rk3399_pmucru *pmucru;
 };
@@ -780,23 +775,6 @@ static struct clk_ops rk3399_clk_ops = {
.set_rate = rk3399_clk_set_rate,
 };
 
-void *rockchip_get_cru(void)
-{
-   struct udevice *dev;
-   fdt_addr_t *addr;
-   int ret;
-
-   ret = uclass_get_device_by_name(UCLASS_CLK, "clk_rk3399", );
-   if (ret)
-   return ERR_PTR(ret);
-
-   addr = dev_get_addr_ptr(dev);
-   if ((fdt_addr_t)addr == FDT_ADDR_T_NONE)
-   return ERR_PTR(-EINVAL);
-
-   return addr;
-}
-
 static int rk3399_clk_probe(struct udevice *dev)
 {
struct rk3399_clk_priv *priv = dev_get_priv(dev);
@@ -990,7 +968,7 @@ static const struct udevice_id rk3399_pmuclk_ids[] = {
{ }
 };
 
-U_BOOT_DRIVER(pmuclk_rk3399) = {
+U_BOOT_DRIVER(rockchip_rk3399_pmuclk) = {
.name   = "pmuclk_rk3399",
.id = UCLASS_CLK,
.of_match   = rk3399_pmuclk_ids,
-- 
2.8.0.rc3.226.g39d4020

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] S5PV210 boot problem

2016-10-01 Thread nader last
Good day,
I have a custom HW around an s5pv210 soc. It's based on mini210 board and uses 
u-boot v1.3.4 as its bootloader. I want to use a newer version of u-boot to 
boot my HW. AFAIK in recent version of u-boot (e.g. v2016.09) GONI board is the 
only supported HW which is based on s5pv210 too. I can successfully compile the 
source with this configuration and burn it on an SD card. But when I try to 
boot the HW, it complains about the checksum with "SD checksum error" message. 
The script used to burn u-boot on the SD card, calculates the checksum for the 
first 8192 bytes of u-boot.bin and adds it somewhere which used to be working 
when the u-boot version was v1.3.4.Any help would greatly be appreciated.
Thank you for your time.
Nasser
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 11/12] RFC: Use binman for a sunxi board

2016-10-01 Thread Tom Rini
On Sat, Oct 01, 2016 at 06:29:42PM -0600, Simon Glass wrote:
> Hi Tom,
> 
> On 1 October 2016 at 18:15, Tom Rini  wrote:
> > On Wed, Sep 28, 2016 at 09:46:25AM -0600, Simon Glass wrote:
> >> Hi Tom,
> >>
> >> On 27 September 2016 at 19:55, Tom Rini  wrote:
> >> > On Sun, Sep 25, 2016 at 03:52:27PM -0600, Simon Glass wrote:
> >> >
> >> >> Add an example usage of binman for a sunxi board. This involves adding 
> >> >> the
> >> >> image definition to the device tree and using it in the Makefile.
> >> >>
> >> >> This is for example only.
> >> >>
> >> >> Signed-off-by: Simon Glass 
> >> >> ---
> >> >>
> >> >> Changes in v2: None
> >> >>
> >> >>  Makefile|  4 +---
> >> >>  arch/arm/dts/sun7i-a20-pcduino3.dts | 12 
> >> >
> >> > I think this shows the big problem with using binman today.  For the
> >> > common case of ARM, where we sync in the dts* files from upstream, this
> >> > will add hunks that must not be overwritten each time.
> >> >
> >> > Looking at scripts/Makefile.lib::cmd_fdt I wonder if we couldn't come up
> >> > with some wildcard rule and check if, somewhere CONFIG'd ? $(BOARDDIR)/
> >> > ? u-boot.dtsi exists add in -include that/file.dtsi to the CPP rule so
> >> > that we can keep the parts that will never get upstream separate.
> >>
> >> We can do that, but I have found that most boards with the same SoC
> >> are the same, or similar. So for x86 [1] I put it in a separate patch
> >> with just an #include in the .dts file.
> >>
> >> We could have binman be a bit smarter about where it looks - e.g. if
> >> there is no binman node, it could look in the same directory for a
> >> file that matches the board name, or part of it?
> >
> > I'd really like to try and better solve the generic problem we have tho
> > too while we're at it.  ie the u-boot,dm-pre-reloc tag on various nodes
> > could also go into this file.
> 
> What sort of solution are you thinking of? A U-Boot .dtsi include that
> is #included at the top of all files?

Something like:
ifneq ($(wildcard 
$(srctree)/arch/$(CONFIG_SYS_ARCH)/cpu/$(CONFIG_SYS_CPU)/$(CONFIG_SYS_SOC)/u-boot.dtsi),)
dtc_cpp_flags += -include
$(srctree)/arch/$(CONFIG_SYS_ARCH)/cpu/$(CONFIG_SYS_CPU)/$(CONFIG_SYS_SOC)/u-boot.dtsi
endif

And maybe a few other wildcards, I'm not sure, so that for everything
rockchip related, ie what binman needs, what nodes need to be pre-reloc,
etc, can end up in that one file.  And we use -include to get it so that
arch/arm/dts/ can be unmodified from upstream.

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 3/4] rockchip: move common function from board-file to rk3036-board.c

2016-10-01 Thread Simon Glass
On 22 September 2016 at 20:58, Simon Glass  wrote:
> On 19 September 2016 at 04:46, Jacob Chen  wrote:
>> To keep it same with 3288
>>
>> Signed-off-by: Jacob Chen 
>> ---
>>
>>  arch/arm/mach-rockchip/Makefile|  1 +
>>  arch/arm/mach-rockchip/rk3036-board.c  | 83 
>> ++
>>  board/rockchip/evb_rk3036/evb_rk3036.c | 66 
>>  board/rockchip/kylin_rk3036/kylin_rk3036.c | 66 
>>  4 files changed, 84 insertions(+), 132 deletions(-)
>>  create mode 100644 arch/arm/mach-rockchip/rk3036-board.c
>
> Acked-by: Simon Glass 

Applied to u-boot-rockchip, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/4] rockchip: rename board.c to rk3288-board.c

2016-10-01 Thread Simon Glass
On 22 September 2016 at 20:58, Simon Glass  wrote:
> On 19 September 2016 at 04:46, Jacob Chen  wrote:
>> Signed-off-by: Jacob Chen 
>> ---
>>
>>  arch/arm/mach-rockchip/Makefile| 2 +-
>>  arch/arm/mach-rockchip/{board.c => rk3288-board.c} | 0
>>  2 files changed, 1 insertion(+), 1 deletion(-)
>>  rename arch/arm/mach-rockchip/{board.c => rk3288-board.c} (100%)
>
> Acked-by: Simon Glass 

Applied to u-boot-rockchip, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 4/4] rockchip: add boot-mode support for rk3288, rk3036

2016-10-01 Thread Simon Glass
On 22 September 2016 at 20:58, Simon Glass  wrote:
> On 19 September 2016 at 04:46, Jacob Chen  wrote:
>> rockchip platform have a protocol to pass the the kernel reboot mode to 
>> bootloader
>> by some special registers when system reboot. In bootloader we should read 
>> it and take action.
>>
>> We can only setup boot_mode in board_late_init becasue "setenv" need env 
>> setuped.
>> So add CONFIG_BOARD_LATE_INIT to common header and use a entry 
>> "rk_board_late_init"
>> to replace "board_late_init" in board file.
>>
>> Signed-off-by: Jacob Chen 
>> ---
>>
>>  arch/arm/include/asm/arch-rockchip/boot_mode.h | 19 ++
>>  arch/arm/mach-rockchip/rk3036-board.c  | 39 
>>  arch/arm/mach-rockchip/rk3288-board.c  | 50 
>> +++---
>>  board/rockchip/kylin_rk3036/kylin_rk3036.c | 14 ++--
>>  include/configs/kylin_rk3036.h |  3 --
>>  include/configs/rk3036_common.h|  3 ++
>>  include/configs/rk3288_common.h|  3 ++
>>  7 files changed, 111 insertions(+), 20 deletions(-)
>>  create mode 100644 arch/arm/include/asm/arch-rockchip/boot_mode.h
>
> Acked-by: Simon Glass 

Applied to u-boot-rockchip, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/4] rockchip: move partitons define from 3036-kylin to 3036-common

2016-10-01 Thread Simon Glass
On 22 September 2016 at 20:58, Simon Glass  wrote:
> On 19 September 2016 at 04:46, Jacob Chen  wrote:
>> To keep it same with 3288.
>>
>> Signed-off-by: Jacob Chen 
>> ---
>>
>>  include/configs/kylin_rk3036.h  | 24 
>>  include/configs/rk3036_common.h | 10 ++
>>  2 files changed, 10 insertions(+), 24 deletions(-)
>
> Acked-by: Simon Glass 

Applied to u-boot-rockchip, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] cros_ec: Fix issue with cros_ec_flash_write command

2016-10-01 Thread Simon Glass
On 22 September 2016 at 22:15, Simon Glass  wrote:
> On 12 September 2016 at 13:57, Moritz Fischer  
> wrote:
>> This commit fixes an issue where data is written to an
>> invalid memory location.
>> The issue has been introduced in commit
>> (88364387 cros: add cros_ec_driver)
>>
>> Cc: Simon Glass 
>> Cc: u-boot@lists.denx.de
>> Signed-off-by: Moritz Fischer 
>> ---
>> Changes from v1:
>>  - Fixed accidential change of command version
>>  - Removed added whitespace
>> ---
>>  drivers/misc/cros_ec.c | 23 ---
>>  1 file changed, 16 insertions(+), 7 deletions(-)
>
> Reviewed-by: Simon Glass 

Applied to u-boot-dm, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] cros_ec: Add function to read back flash parameters

2016-10-01 Thread Simon Glass
On 18 September 2016 at 18:58, Simon Glass  wrote:
> On 13 September 2016 at 15:44, Moritz Fischer  
> wrote:
>> Add support for reading back flash parameters as reported by
>> the ec.
>>
>> Signed-off-by: Moritz Fischer 
>> Cc: Simon Glass 
>> Cc: u-boot@lists.denx.de
>> ---
>>  drivers/misc/cros_ec.c | 21 +
>>  1 file changed, 21 insertions(+)
>
> Acked-by: Simon Glass 

Applied to u-boot-dm, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] cros_ec: Add crosec flashinfo command

2016-10-01 Thread Simon Glass
On 18 September 2016 at 18:58, Simon Glass  wrote:
> Hi Moritz,
>
> On 13 September 2016 at 15:44, Moritz Fischer  
> wrote:
>> Add command to print out the flash info as reported by the
>> ec. The data read back includes size, write block size,
>> erase block size.
>>
>> Signed-off-by: Moritz Fischer 
>> Cc: Simon Glass 
>> Cc: u-boot@lists.denx.de
>> ---
>>  drivers/misc/cros_ec.c | 10 ++
>>  1 file changed, 10 insertions(+)
>
> Acked-by: Simon Glass 
>
> If you have the energy, it might be useful to move the command code
> from this file into cmd/cros_ec.c
>
> Regards,
> Simon

Applied to u-boot-dm, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 12/13] buildman: Don't show a stacktrace on Ctrl-C

2016-10-01 Thread Simon Glass
On 18 September 2016 at 16:48, Simon Glass  wrote:
> When Ctrl-C is pressed, just exited quietly. There is no sense in displaying
> a stack trace since buildman will always be in the same place: waiting for
> threads to complete building all the jobs on the queue.
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/buildman/builder.py | 7 +++
>  1 file changed, 7 insertions(+)

Applied to u-boot-dm.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 11/13] buildman: Drop the 'active' flag in the builder

2016-10-01 Thread Simon Glass
On 18 September 2016 at 16:48, Simon Glass  wrote:
> This serves no real purpose, since when we are not active, we exit. Drop it.
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/buildman/builder.py   |  7 ---
>  tools/buildman/builderthread.py | 10 +-
>  2 files changed, 1 insertion(+), 16 deletions(-)

Applied to u-boot-dm.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 11/12] RFC: Use binman for a sunxi board

2016-10-01 Thread Simon Glass
Hi Tom,

On 1 October 2016 at 18:15, Tom Rini  wrote:
> On Wed, Sep 28, 2016 at 09:46:25AM -0600, Simon Glass wrote:
>> Hi Tom,
>>
>> On 27 September 2016 at 19:55, Tom Rini  wrote:
>> > On Sun, Sep 25, 2016 at 03:52:27PM -0600, Simon Glass wrote:
>> >
>> >> Add an example usage of binman for a sunxi board. This involves adding the
>> >> image definition to the device tree and using it in the Makefile.
>> >>
>> >> This is for example only.
>> >>
>> >> Signed-off-by: Simon Glass 
>> >> ---
>> >>
>> >> Changes in v2: None
>> >>
>> >>  Makefile|  4 +---
>> >>  arch/arm/dts/sun7i-a20-pcduino3.dts | 12 
>> >
>> > I think this shows the big problem with using binman today.  For the
>> > common case of ARM, where we sync in the dts* files from upstream, this
>> > will add hunks that must not be overwritten each time.
>> >
>> > Looking at scripts/Makefile.lib::cmd_fdt I wonder if we couldn't come up
>> > with some wildcard rule and check if, somewhere CONFIG'd ? $(BOARDDIR)/
>> > ? u-boot.dtsi exists add in -include that/file.dtsi to the CPP rule so
>> > that we can keep the parts that will never get upstream separate.
>>
>> We can do that, but I have found that most boards with the same SoC
>> are the same, or similar. So for x86 [1] I put it in a separate patch
>> with just an #include in the .dts file.
>>
>> We could have binman be a bit smarter about where it looks - e.g. if
>> there is no binman node, it could look in the same directory for a
>> file that matches the board name, or part of it?
>
> I'd really like to try and better solve the generic problem we have tho
> too while we're at it.  ie the u-boot,dm-pre-reloc tag on various nodes
> could also go into this file.

What sort of solution are you thinking of? A U-Boot .dtsi include that
is #included at the top of all files?

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 13/13] buildman: Drop the 'alive' flag in BuilderThread

2016-10-01 Thread Simon Glass
On 18 September 2016 at 16:48, Simon Glass  wrote:
> This is not used, so drop it.
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/buildman/builderthread.py | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)

Applied to u-boot-dm.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 09/13] buildman: Put our local libraries first in the path

2016-10-01 Thread Simon Glass
On 18 September 2016 at 16:48, Simon Glass  wrote:
> If patman is installed on the machine (e.g. in the standard dist-packages
> directory), it will find libraries from there in preference to our local
> libraries. Adjust the order of the path to ensure that local libraries are
> found first.
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/buildman/buildman.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-dm.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 10/13] buildman: Allow builds to terminate cleanly

2016-10-01 Thread Simon Glass
Hi Tom,

On 19 September 2016 at 13:16, Tom Rini  wrote:
> On Sun, Sep 18, 2016 at 04:48:35PM -0600, Simon Glass wrote:
>
>> It is annoying that buildman does not respond cleanly to Ctrl-C or SIGINT,
>> particularly on machines with lots of CPUS. Unfortunately queue.join()
>> blocks the main thread and does not allow it to see the signal. Use a
>> separate thread instead,
>>
>> Signed-off-by: Simon Glass 
>
> Yay for fixing this, killing off the running make's when I have a bad
> test build going is one of the minor pitas in my workflow :)

Yes, me too.

Applied to u-boot-dm.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 08/13] buildman: Print a message indicating the build is starting

2016-10-01 Thread Simon Glass
On 18 September 2016 at 16:48, Simon Glass  wrote:
> Make it clear when buildman actually starts building. This happens when it
> has prepared the threads, working directory and output directories.
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/buildman/builder.py | 1 +
>  tools/buildman/test.py| 4 ++--
>  2 files changed, 3 insertions(+), 2 deletions(-)

Applied to u-boot-dm.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 07/13] buildman: Print a message when removing old directories

2016-10-01 Thread Simon Glass
On 18 September 2016 at 16:48, Simon Glass  wrote:
> When buildman starts, it prepares its output directory by removing any old
> build directories which will not be used this time. This can happen if a
> previous build left directories around for commit hashes which are no-longer
> part of the branch.
>
> This can take quite a while, so print a message to indicate what is going
> on.
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/buildman/builder.py | 6 ++
>  1 file changed, 6 insertions(+)

Applied to u-boot-dm.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 05/13] patman: Flush output when there is no newline

2016-10-01 Thread Simon Glass
On 18 September 2016 at 16:48, Simon Glass  wrote:
> Output which does not include a newline will not be displayed unless
> flushed. Add a flush to ensure that it becomes visible.
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/patman/terminal.py | 2 ++
>  1 file changed, 2 insertions(+)

Applied to u-boot-dm.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 06/13] buildman: Tidy up the 'cloning' message

2016-10-01 Thread Simon Glass
On 18 September 2016 at 16:48, Simon Glass  wrote:
> On a machine with a lot of CPUs this prints a lot of useless lines of the
> form:
>
>Cloning repo for thread 
>
> Adjust the output so that these all appear on one line, and disappear when
> the cloning is complete.
>
> Note: This cloning is actually unnecessary and very wasteful on disk space
> (about 3.5GB each time). It would be better to create symlinks.
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/buildman/builder.py | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Applied to u-boot-dm.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 11/12] RFC: Use binman for a sunxi board

2016-10-01 Thread Tom Rini
On Wed, Sep 28, 2016 at 09:46:25AM -0600, Simon Glass wrote:
> Hi Tom,
> 
> On 27 September 2016 at 19:55, Tom Rini  wrote:
> > On Sun, Sep 25, 2016 at 03:52:27PM -0600, Simon Glass wrote:
> >
> >> Add an example usage of binman for a sunxi board. This involves adding the
> >> image definition to the device tree and using it in the Makefile.
> >>
> >> This is for example only.
> >>
> >> Signed-off-by: Simon Glass 
> >> ---
> >>
> >> Changes in v2: None
> >>
> >>  Makefile|  4 +---
> >>  arch/arm/dts/sun7i-a20-pcduino3.dts | 12 
> >
> > I think this shows the big problem with using binman today.  For the
> > common case of ARM, where we sync in the dts* files from upstream, this
> > will add hunks that must not be overwritten each time.
> >
> > Looking at scripts/Makefile.lib::cmd_fdt I wonder if we couldn't come up
> > with some wildcard rule and check if, somewhere CONFIG'd ? $(BOARDDIR)/
> > ? u-boot.dtsi exists add in -include that/file.dtsi to the CPP rule so
> > that we can keep the parts that will never get upstream separate.
> 
> We can do that, but I have found that most boards with the same SoC
> are the same, or similar. So for x86 [1] I put it in a separate patch
> with just an #include in the .dts file.
> 
> We could have binman be a bit smarter about where it looks - e.g. if
> there is no binman node, it could look in the same directory for a
> file that matches the board name, or part of it?

I'd really like to try and better solve the generic problem we have tho
too while we're at it.  ie the u-boot,dm-pre-reloc tag on various nodes
could also go into this file.

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 5/7] efi_loader: Readd freed pages to memory pool

2016-10-01 Thread Stefan Brüns
Currently each allocation creates a new mapping. Readding the mapping
as free memory (EFI_CONVENTIONAL_MEMORY) potentially allows to hand out
an existing mapping, thus limiting the number of mapping descriptors in
the memory map.

Mitigates a problem with current (4.8rc7) linux kernels when doing an
efi_get_memory map, resulting in an infinite loop. Space for the memory
map is reserved with allocate_pool (implicitly creating a new mapping) and
filled. If there is insufficient slack space (8 entries) in the map, the
space is freed and a new round is started, with space for one more entry.
As each round increases requirement and allocation by exactly one, there
is never enough slack space. (At least 32 entries are allocated, so as
long as there are less than 24 entries, there is enough slack).
Earlier kernels reserved no slack, and did less allocations, so this
problem was not visible.

Signed-off-by: Stefan Brüns 
Reviewed-by: Alexander Graf 
---
 include/efi_loader.h|  2 +-
 lib/efi_loader/efi_memory.c | 11 +--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 341d4a4..6d64f4b 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -117,7 +117,7 @@ void *efi_alloc(uint64_t len, int memory_type);
 /* More specific EFI memory allocator, called by EFI payloads */
 efi_status_t efi_allocate_pages(int type, int memory_type, unsigned long pages,
uint64_t *memory);
-/* EFI memory free function. Not implemented today */
+/* EFI memory free function. */
 efi_status_t efi_free_pages(uint64_t memory, unsigned long pages);
 /* EFI memory allocator for small allocations, called by EFI payloads */
 efi_status_t efi_allocate_pool(int pool_type, unsigned long size,
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index fa5c639..7051948 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -335,8 +335,15 @@ void *efi_alloc(uint64_t len, int memory_type)
 
 efi_status_t efi_free_pages(uint64_t memory, unsigned long pages)
 {
-   /* We don't free, let's cross our fingers we have plenty RAM */
-   return EFI_SUCCESS;
+   uint64_t r = 0;
+
+   r = efi_add_memory_map(memory, pages, EFI_CONVENTIONAL_MEMORY, false);
+   /* Merging of adjacent free regions is missing */
+
+   if (r == memory)
+   return EFI_SUCCESS;
+
+   return EFI_NOT_FOUND;
 }
 
 efi_status_t efi_allocate_pool(int pool_type, unsigned long size,
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 7/7] efi_loader: Do not leak memory when unlinking a mapping

2016-10-01 Thread Stefan Brüns
As soon as a mapping is unlinked from the list, there are no further
references to it, so it should be freed. If it not unlinked,
update the start address and length.

Signed-off-by: Stefan Brüns 
Reviewed-by: Alexander Graf 
---
 lib/efi_loader/efi_memory.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 2bbf8eb..7e4ee01 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -115,10 +115,13 @@ static int efi_mem_carve_out(struct efi_mem_list *map,
if (map_end == carve_end) {
/* Full overlap, just remove map */
list_del(>link);
+   free(map);
+   } else {
+   map->desc.physical_start = carve_end;
+   map->desc.num_pages = (map_end - carve_end)
+ >> EFI_PAGE_SHIFT;
}
 
-   map_desc->physical_start = carve_end;
-   map_desc->num_pages = (map_end - carve_end) >> EFI_PAGE_SHIFT;
return (carve_end - carve_start) >> EFI_PAGE_SHIFT;
}
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 0/6] efi_loader: implement BS.FreePages()/BS.FreePool, some cleanup

2016-10-01 Thread Stefan Brüns
Linux 4.8 no longer boots, as it runs out of descriptor space. Readding
the mapping allows reuse, and the next AllocatePool will likely not add
a new mapping.

Also fix some small issues found while debugging.

v2, updated:
  efi_loader: Fix memory map size check to avoid out-of-bounds access
  - (Hopefully) clarified commit message
  efi_loader: Track size of pool allocations to allow freeing
  - rebased on top of 'efi_loader: Fix crash on 32-bit systems'
  - assert correct address in efi_free_pool
  - use EFI_PAGE_MASK instead of 0xfff, EFI_PAGE_SHIFT likewise

v3, added:
  efi_loader: Move efi_allocate_pool implementation to efi_memory.c
v3, updated:
  efi_loader: Fix memory map size check to avoid out-of-bounds access
  - set descriptor_size/_version even if EFI_BUFFER_TOO_SMALL
  efi_loader: Track size of pool allocations to allow freeing
  - use a struct instead of pointer arithmetic, add some comments

Stefan Brüns (7):
  efi_loader: Update description of internal efi_mem_carve_out
  efi_loader: Fix memory map size check to avoid out-of-bounds access
  efi_loader: Move efi_allocate_pool implementation to efi_memory.c
  efi_loader: Track size of pool allocations to allow freeing
  efi_loader: Readd freed pages to memory pool
  efi_loader: Keep memory mapping sorted when splitting an entry
  efi_loader: Do not leak memory when unlinking a mapping

 include/efi_loader.h  |  7 +++-
 lib/efi_loader/efi_boottime.c | 17 
 lib/efi_loader/efi_memory.c   | 92 +--
 3 files changed, 95 insertions(+), 21 deletions(-)

-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 3/7] efi_loader: Move efi_allocate_pool implementation to efi_memory.c

2016-10-01 Thread Stefan Brüns
Implementation essentially unchanged, but use EFI_PAGE_MASK/SHIFT
instead of numeric constants.

Signed-off-by: Stefan Brüns 
---
 include/efi_loader.h  |  3 +++
 lib/efi_loader/efi_boottime.c | 11 +--
 lib/efi_loader/efi_memory.c   | 11 +++
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 9738835..40e7beb 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -119,6 +119,9 @@ efi_status_t efi_allocate_pages(int type, int memory_type, 
unsigned long pages,
uint64_t *memory);
 /* EFI memory free function. Not implemented today */
 efi_status_t efi_free_pages(uint64_t memory, unsigned long pages);
+/* EFI memory allocator for small allocations, called by EFI payloads */
+efi_status_t efi_allocate_pool(int pool_type, unsigned long size,
+  void **buffer);
 /* Returns the EFI memory map */
 efi_status_t efi_get_memory_map(unsigned long *memory_map_size,
struct efi_mem_desc *memory_map,
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 784891b..eb74cb0 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -130,15 +130,14 @@ efi_status_t EFIAPI efi_get_memory_map_ext(unsigned long 
*memory_map_size,
return EFI_EXIT(r);
 }
 
-static efi_status_t EFIAPI efi_allocate_pool(int pool_type, unsigned long size,
-void **buffer)
+static efi_status_t EFIAPI efi_allocate_pool_ext(int pool_type,
+unsigned long size,
+void **buffer)
 {
efi_status_t r;
-   efi_physical_addr_t t;
 
EFI_ENTRY("%d, %ld, %p", pool_type, size, buffer);
-   r = efi_allocate_pages(0, pool_type, (size + 0xfff) >> 12, );
-   *buffer = (void *)(uintptr_t)t;
+   r = efi_allocate_pool(pool_type, size, buffer);
return EFI_EXIT(r);
 }
 
@@ -736,7 +735,7 @@ static const struct efi_boot_services efi_boot_services = {
.allocate_pages = efi_allocate_pages_ext,
.free_pages = efi_free_pages_ext,
.get_memory_map = efi_get_memory_map_ext,
-   .allocate_pool = efi_allocate_pool,
+   .allocate_pool = efi_allocate_pool_ext,
.free_pool = efi_free_pool,
.create_event = efi_create_event,
.set_timer = efi_set_timer,
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 5d71fdf..045558d 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -327,6 +327,17 @@ efi_status_t efi_free_pages(uint64_t memory, unsigned long 
pages)
return EFI_SUCCESS;
 }
 
+efi_status_t efi_allocate_pool(int pool_type, unsigned long size,
+  void **buffer)
+{
+   efi_status_t r;
+   efi_physical_addr_t t;
+   u64 num_pages = (size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
+
+   r = efi_allocate_pages(0, pool_type, num_pages, );
+   return EFI_EXIT(r);
+}
+
 efi_status_t efi_get_memory_map(unsigned long *memory_map_size,
   struct efi_mem_desc *memory_map,
   unsigned long *map_key,
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 4/7] efi_loader: Track size of pool allocations to allow freeing

2016-10-01 Thread Stefan Brüns
allocate_pool has to return a buffer which is 8-byte aligned. Shift the
region returned by allocate_pages by 8 byte and store the size in the
headroom. The 8 byte overhead is neglegible, but provides the required
size when freeing the allocation later.

Signed-off-by: Stefan Brüns 
---
 include/efi_loader.h  |  2 ++
 lib/efi_loader/efi_boottime.c |  6 +++---
 lib/efi_loader/efi_memory.c   | 40 +++-
 3 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 40e7beb..341d4a4 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -122,6 +122,8 @@ efi_status_t efi_free_pages(uint64_t memory, unsigned long 
pages);
 /* EFI memory allocator for small allocations, called by EFI payloads */
 efi_status_t efi_allocate_pool(int pool_type, unsigned long size,
   void **buffer);
+/* EFI pool memory free function. */
+efi_status_t efi_free_pool(void *buffer);
 /* Returns the EFI memory map */
 efi_status_t efi_get_memory_map(unsigned long *memory_map_size,
struct efi_mem_desc *memory_map,
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index eb74cb0..8274d8e 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -141,12 +141,12 @@ static efi_status_t EFIAPI efi_allocate_pool_ext(int 
pool_type,
return EFI_EXIT(r);
 }
 
-static efi_status_t EFIAPI efi_free_pool(void *buffer)
+static efi_status_t EFIAPI efi_free_pool_ext(void *buffer)
 {
efi_status_t r;
 
EFI_ENTRY("%p", buffer);
-   r = efi_free_pages((ulong)buffer, 0);
+   r = efi_free_pool(buffer);
return EFI_EXIT(r);
 }
 
@@ -736,7 +736,7 @@ static const struct efi_boot_services efi_boot_services = {
.free_pages = efi_free_pages_ext,
.get_memory_map = efi_get_memory_map_ext,
.allocate_pool = efi_allocate_pool_ext,
-   .free_pool = efi_free_pool,
+   .free_pool = efi_free_pool_ext,
.create_event = efi_create_event,
.set_timer = efi_set_timer,
.wait_for_event = efi_wait_for_event,
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 045558d..fa5c639 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -34,6 +34,18 @@ void *efi_bounce_buffer;
 #endif
 
 /*
+ * U-Boot services each EFI AllocatePool request as a separate
+ * (multiple) page allocation.  We have to track the number of pages
+ * to be able to free the correct amount later.
+ * EFI requires 8 byte alignement for pool allocations, so it is
+ * possible to reserve some headroom and serve the remainder.
+ */
+struct efi_pool_allocation {
+   u64 num_pages;
+   char data[];
+};
+
+/*
  * Sorts the memory list from highest address to lowest address
  *
  * When allocating memory we should always start from the highest
@@ -332,9 +344,35 @@ efi_status_t efi_allocate_pool(int pool_type, unsigned 
long size,
 {
efi_status_t r;
efi_physical_addr_t t;
-   u64 num_pages = (size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
+   u64 num_pages = (size + sizeof(u64) + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
+
+   if (size == 0) {
+   *buffer = NULL;
+   return EFI_EXIT(EFI_SUCCESS);
+   }
 
r = efi_allocate_pages(0, pool_type, num_pages, );
+
+   if (r == EFI_SUCCESS) {
+   struct efi_pool_allocation *alloc = (void *)(uintptr_t)t;
+   alloc->num_pages = num_pages;
+   *buffer = &(alloc->data);
+   assert(((uintptr_t)(*buffer) & 0x7) == 0);
+   }
+
+   return EFI_EXIT(r);
+}
+
+efi_status_t efi_free_pool(void *buffer)
+{
+   efi_status_t r;
+   struct efi_pool_allocation *alloc;
+
+   alloc = container_of(buffer, struct efi_pool_allocation, data);
+   assert(((uintptr_t)alloc & EFI_PAGE_MASK) == 0);
+
+   r = efi_free_pages((uintptr_t)alloc, alloc->num_pages);
+
return EFI_EXIT(r);
 }
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 1/7] efi_loader: Update description of internal efi_mem_carve_out

2016-10-01 Thread Stefan Brüns
In 74c16acce30bb882ad5951829d8dafef8eea564c the return values where
changed, but the description was kept.

Signed-off-by: Stefan Brüns 
---
 lib/efi_loader/efi_memory.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 80e4e26..ebe8e94 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -62,9 +62,17 @@ static void efi_mem_sort(void)
  * Unmaps all memory occupied by the carve_desc region from the
  * list entry pointed to by map.
  *
- * Returns 1 if carving was performed or 0 if the regions don't overlap.
- * Returns -1 if it would affect non-RAM regions but overlap_only_ram is set.
- * Carving is only guaranteed to complete when all regions return 0.
+ * Returns EFI_CARVE_NO_OVERLAP if the regions don't overlap.
+ * Returns EFI_CARVE_OVERLAPS_NONRAM if the carve and map overlap,
+ *and the map contains anything but free ram.
+ *(only when overlap_only_ram is true)
+ * Returns EFI_CARVE_LOOP_AGAIN if the mapping list should be traversed
+ *again, as it has been altered
+ * Returns the number of overlapping pages. The pages are removed from
+ * the mapping list.
+ *
+ * In case of EFI_CARVE_OVERLAPS_NONRAM it is the callers responsibility
+ * to readd the already carved out pages to the mapping.
  */
 static int efi_mem_carve_out(struct efi_mem_list *map,
 struct efi_mem_desc *carve_desc,
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 6/7] efi_loader: Keep memory mapping sorted when splitting an entry

2016-10-01 Thread Stefan Brüns
The code assumes sorted mappings in descending address order. When
splitting a mapping, insert the new part next to the current mapping.

Signed-off-by: Stefan Brüns 
Reviewed-by: Alexander Graf 
---
 lib/efi_loader/efi_memory.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 7051948..2bbf8eb 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -134,7 +134,8 @@ static int efi_mem_carve_out(struct efi_mem_list *map,
newmap->desc = map->desc;
newmap->desc.physical_start = carve_start;
newmap->desc.num_pages = (map_end - carve_start) >> EFI_PAGE_SHIFT;
-list_add_tail(>link, _mem);
+   /* Insert before current entry (descending address order) */
+   list_add_tail(>link, >link);
 
/* Shrink the map to [ map_start ... carve_start ] */
map_desc->num_pages = (carve_start - map_start) >> EFI_PAGE_SHIFT;
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 2/7] efi_loader: Fix memory map size check to avoid out-of-bounds access

2016-10-01 Thread Stefan Brüns
Do not overwrite the specified size of the provided buffer without
having checked it is sufficient.

If the buffer is to small, memory_map_size is updated to indicate the
required size, and an error code is returned.

Signed-off-by: Stefan Brüns 
---
 lib/efi_loader/efi_memory.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index ebe8e94..5d71fdf 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -342,16 +342,18 @@ efi_status_t efi_get_memory_map(unsigned long 
*memory_map_size,
 
map_size = map_entries * sizeof(struct efi_mem_desc);
 
-   *memory_map_size = map_size;
-
if (descriptor_size)
*descriptor_size = sizeof(struct efi_mem_desc);
 
if (descriptor_version)
*descriptor_version = EFI_MEMORY_DESCRIPTOR_VERSION;
 
-   if (*memory_map_size < map_size)
+   if (*memory_map_size < map_size) {
+   *memory_map_size = map_size;
return EFI_BUFFER_TOO_SMALL;
+   }
+
+   *memory_map_size = map_size;
 
/* Copy list into array */
if (memory_map) {
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 1/3] dm: mmc: Support erase

2016-10-01 Thread Simon Glass
At present erase is not suported with CONFIG_DM_OPS. Add it so that MMC
devices can be erased.

Signed-off-by: Simon Glass 
---

Changes in v3: None

 drivers/mmc/mmc-uclass.c  |  1 +
 drivers/mmc/mmc_private.h |  5 ++---
 drivers/mmc/mmc_write.c   | 10 --
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 425abb1..77424cd 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -262,6 +262,7 @@ static const struct blk_ops mmc_blk_ops = {
.read   = mmc_bread,
 #ifndef CONFIG_SPL_BUILD
.write  = mmc_bwrite,
+   .erase  = mmc_berase,
 #endif
.select_hwpart  = mmc_select_hwpart,
 };
diff --git a/drivers/mmc/mmc_private.h b/drivers/mmc/mmc_private.h
index 49ec022..8c0b993 100644
--- a/drivers/mmc/mmc_private.h
+++ b/drivers/mmc/mmc_private.h
@@ -30,15 +30,14 @@ ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, 
lbaint_t blkcnt,
 
 #ifndef CONFIG_SPL_BUILD
 
-unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start,
-lbaint_t blkcnt);
-
 #ifdef CONFIG_BLK
 ulong mmc_bwrite(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
 const void *src);
+ulong mmc_berase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt);
 #else
 ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
 const void *src);
+ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt);
 #endif
 
 #else /* CONFIG_SPL_BUILD */
diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c
index 2289640..54acbf7 100644
--- a/drivers/mmc/mmc_write.c
+++ b/drivers/mmc/mmc_write.c
@@ -66,9 +66,15 @@ err_out:
return err;
 }
 
-unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start,
-lbaint_t blkcnt)
+#ifdef CONFIG_BLK
+ulong mmc_berase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt)
+#else
+ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt)
+#endif
 {
+#ifdef CONFIG_BLK
+   struct blk_desc *block_dev = dev_get_uclass_platdata(dev);
+#endif
int dev_num = block_dev->devnum;
int err = 0;
u32 start_rem, blkcnt_rem;
-- 
2.8.0.rc3.226.g39d4020

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 3/3] dm: mmc: Enable DM_MMC_OPS by default with DM_MMC

2016-10-01 Thread Simon Glass
These two options go together and it is best to do the conversion in one
step. So enable DM_MMC_OPS by default if DM_MMC is enabled.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Updates to remove build errors from tegra and other boards

 configs/am335x_boneblack_vboot_defconfig  | 1 +
 configs/am335x_evm_defconfig  | 1 +
 configs/am43xx_evm_defconfig  | 1 +
 configs/am43xx_evm_usbhost_boot_defconfig | 1 +
 configs/am43xx_hs_evm_defconfig   | 1 +
 configs/am57xx_evm_defconfig  | 1 +
 configs/am57xx_hs_evm_defconfig   | 1 +
 configs/apalis_t30_defconfig  | 1 +
 configs/beaver_defconfig  | 1 +
 configs/cardhu_defconfig  | 1 +
 configs/cei-tk1-som_defconfig | 1 +
 configs/colibri_t20_defconfig | 1 +
 configs/colibri_t30_defconfig | 1 +
 configs/dalmore_defconfig | 1 +
 configs/dra7xx_evm_defconfig  | 1 +
 configs/dra7xx_hs_evm_defconfig   | 1 +
 configs/e2220-1170_defconfig  | 1 +
 configs/harmony_defconfig | 1 +
 configs/jetson-tk1_defconfig  | 1 +
 configs/k2g_evm_defconfig | 1 +
 configs/medcom-wide_defconfig | 1 +
 configs/nyan-big_defconfig| 1 +
 configs/p2371-_defconfig  | 1 +
 configs/p2371-2180_defconfig  | 1 +
 configs/p2571_defconfig   | 1 +
 configs/p2771--000_defconfig  | 1 +
 configs/p2771--500_defconfig  | 1 +
 configs/paz00_defconfig   | 1 +
 configs/plutux_defconfig  | 1 +
 configs/seaboard_defconfig| 1 +
 configs/tec-ng_defconfig  | 1 +
 configs/tec_defconfig | 1 +
 configs/trimslice_defconfig   | 1 +
 configs/venice2_defconfig | 1 +
 configs/ventana_defconfig | 1 +
 configs/whistler_defconfig| 1 +
 drivers/mmc/Kconfig   | 1 +
 37 files changed, 37 insertions(+)

diff --git a/configs/am335x_boneblack_vboot_defconfig 
b/configs/am335x_boneblack_vboot_defconfig
index bcd977b..d33e3b6 100644
--- a/configs/am335x_boneblack_vboot_defconfig
+++ b/configs/am335x_boneblack_vboot_defconfig
@@ -42,6 +42,7 @@ CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
+# CONFIG_DM_MMC_OPS is not set
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_DM_ETH=y
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig
index 9f91397..8bdfc2b 100644
--- a/configs/am335x_evm_defconfig
+++ b/configs/am335x_evm_defconfig
@@ -39,6 +39,7 @@ CONFIG_DFU_NAND=y
 CONFIG_DFU_RAM=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
+# CONFIG_DM_MMC_OPS is not set
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_DM_ETH=y
diff --git a/configs/am43xx_evm_defconfig b/configs/am43xx_evm_defconfig
index c423362..304743d 100644
--- a/configs/am43xx_evm_defconfig
+++ b/configs/am43xx_evm_defconfig
@@ -42,6 +42,7 @@ CONFIG_DFU_SF=y
 CONFIG_DM_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
+# CONFIG_DM_MMC_OPS is not set
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_BAR=y
 CONFIG_SPI_FLASH_MACRONIX=y
diff --git a/configs/am43xx_evm_usbhost_boot_defconfig 
b/configs/am43xx_evm_usbhost_boot_defconfig
index aa0effb..f385371 100644
--- a/configs/am43xx_evm_usbhost_boot_defconfig
+++ b/configs/am43xx_evm_usbhost_boot_defconfig
@@ -44,6 +44,7 @@ CONFIG_DFU_RAM=y
 CONFIG_DFU_SF=y
 CONFIG_DM_GPIO=y
 CONFIG_DM_MMC=y
+# CONFIG_DM_MMC_OPS is not set
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_DM_SERIAL=y
diff --git a/configs/am43xx_hs_evm_defconfig b/configs/am43xx_hs_evm_defconfig
index 0f7b887..ad7c842 100644
--- a/configs/am43xx_hs_evm_defconfig
+++ b/configs/am43xx_hs_evm_defconfig
@@ -45,6 +45,7 @@ CONFIG_DFU_SF=y
 CONFIG_DM_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
+# CONFIG_DM_MMC_OPS is not set
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_DM_ETH=y
diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig
index a8d1a47..c672017 100644
--- a/configs/am57xx_evm_defconfig
+++ b/configs/am57xx_evm_defconfig
@@ -40,6 +40,7 @@ CONFIG_DM=y
 CONFIG_DM_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
+# CONFIG_DM_MMC_OPS is not set
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_BAR=y
diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig
index 6a17470..a80e882 100644
--- a/configs/am57xx_hs_evm_defconfig
+++ b/configs/am57xx_hs_evm_defconfig
@@ -42,6 +42,7 @@ CONFIG_DM=y
 CONFIG_DM_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
+# CONFIG_DM_MMC_OPS is not set
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_BAR=y
diff --git a/configs/apalis_t30_defconfig b/configs/apalis_t30_defconfig
index 3c67b90..ec33397 100644
--- a/configs/apalis_t30_defconfig
+++ b/configs/apalis_t30_defconfig
@@ -30,6 +30,7 @@ CONFIG_SPL_DM=y
 # CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
 

[U-Boot] [PATCH v3 2/3] dm: blk: Enable CONFIG_BLK if DM_MMC is enabled

2016-10-01 Thread Simon Glass
To speed up conversion to CONFIG_BLK, enable it by default when DM_MMC is
enabled.

Signed-off-by: Simon Glass 
---

Changes in v3: None

 configs/am335x_boneblack_vboot_defconfig  | 1 +
 configs/am335x_evm_defconfig  | 1 +
 configs/am43xx_evm_defconfig  | 1 +
 configs/am43xx_evm_usbhost_boot_defconfig | 1 +
 configs/am43xx_hs_evm_defconfig   | 1 +
 configs/am57xx_evm_defconfig  | 1 +
 configs/am57xx_hs_evm_defconfig   | 1 +
 configs/apalis_t30_defconfig  | 1 +
 configs/beaver_defconfig  | 1 +
 configs/cardhu_defconfig  | 1 +
 configs/cei-tk1-som_defconfig | 1 +
 configs/colibri_t20_defconfig | 1 +
 configs/colibri_t30_defconfig | 1 +
 configs/dalmore_defconfig | 1 +
 configs/dra7xx_evm_defconfig  | 1 +
 configs/dra7xx_hs_evm_defconfig   | 1 +
 configs/e2220-1170_defconfig  | 1 +
 configs/harmony_defconfig | 1 +
 configs/jetson-tk1_defconfig  | 1 +
 configs/k2g_evm_defconfig | 1 +
 configs/medcom-wide_defconfig | 1 +
 configs/nyan-big_defconfig| 1 +
 configs/p2371-_defconfig  | 1 +
 configs/p2371-2180_defconfig  | 1 +
 configs/p2571_defconfig   | 1 +
 configs/p2771--000_defconfig  | 1 +
 configs/p2771--500_defconfig  | 1 +
 configs/paz00_defconfig   | 1 +
 configs/pic32mzdask_defconfig | 1 +
 configs/plutux_defconfig  | 1 +
 configs/sandbox_noblk_defconfig   | 1 +
 configs/seaboard_defconfig| 1 +
 configs/tec-ng_defconfig  | 1 +
 configs/tec_defconfig | 1 +
 configs/trimslice_defconfig   | 1 +
 configs/venice2_defconfig | 1 +
 configs/ventana_defconfig | 1 +
 configs/whistler_defconfig| 1 +
 drivers/block/Kconfig | 1 +
 39 files changed, 39 insertions(+)

diff --git a/configs/am335x_boneblack_vboot_defconfig 
b/configs/am335x_boneblack_vboot_defconfig
index 15b33a4..bcd977b 100644
--- a/configs/am335x_boneblack_vboot_defconfig
+++ b/configs/am335x_boneblack_vboot_defconfig
@@ -37,6 +37,7 @@ CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
+# CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DM_I2C=y
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig
index 67c458f..9f91397 100644
--- a/configs/am335x_evm_defconfig
+++ b/configs/am335x_evm_defconfig
@@ -33,6 +33,7 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_LIST="am335x-evm am335x-bone am335x-boneblack am335x-evmsk 
am335x-bonegreen am335x-icev2"
+# CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
 CONFIG_DFU_NAND=y
 CONFIG_DFU_RAM=y
diff --git a/configs/am43xx_evm_defconfig b/configs/am43xx_evm_defconfig
index 64e48e9..c423362 100644
--- a/configs/am43xx_evm_defconfig
+++ b/configs/am43xx_evm_defconfig
@@ -35,6 +35,7 @@ CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_LIST="am437x-gp-evm am437x-sk-evm am43x-epos-evm am437x-idk-evm"
 CONFIG_DM=y
+# CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DFU_SF=y
diff --git a/configs/am43xx_evm_usbhost_boot_defconfig 
b/configs/am43xx_evm_usbhost_boot_defconfig
index 14d874f..aa0effb 100644
--- a/configs/am43xx_evm_usbhost_boot_defconfig
+++ b/configs/am43xx_evm_usbhost_boot_defconfig
@@ -38,6 +38,7 @@ CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_LIST="am437x-gp-evm am437x-sk-evm am43x-epos-evm am437x-idk-evm"
 CONFIG_DM=y
+# CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DFU_SF=y
diff --git a/configs/am43xx_hs_evm_defconfig b/configs/am43xx_hs_evm_defconfig
index 6c5b409..0f7b887 100644
--- a/configs/am43xx_hs_evm_defconfig
+++ b/configs/am43xx_hs_evm_defconfig
@@ -38,6 +38,7 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_DM=y
+# CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DFU_SF=y
diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig
index 27ea472..a8d1a47 100644
--- a/configs/am57xx_evm_defconfig
+++ b/configs/am57xx_evm_defconfig
@@ -36,6 +36,7 @@ CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_LIST="am57xx-beagle-x15 am572x-idk"
 CONFIG_DM=y
+# CONFIG_BLK is not set
 CONFIG_DM_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig
index 192997a..6a17470 100644
--- a/configs/am57xx_hs_evm_defconfig
+++ b/configs/am57xx_hs_evm_defconfig
@@ -38,6 +38,7 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_DM=y
+# CONFIG_BLK is not set
 CONFIG_DM_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
diff --git a/configs/apalis_t30_defconfig b/configs/apalis_t30_defconfig
index a22e6b6..3c67b90 100644
--- 

[U-Boot] [PATCH v3 0/3] dm: mmc: Default to DM_MMC_OPS and BLK

2016-10-01 Thread Simon Glass
Two of these patches have been around for a while, but I've been waiting
to apply them early in the release cycle to permit testing.

The goal is to make CONFIG_DM_MMC_OPS and CONFIG_BLK enabled by default
when driver model is used for mmc. Then these options can be removed. All
mmc drivers should move to using these options.

Changes in v3:
- Updates to remove build errors from tegra and other boards

Simon Glass (3):
  dm: mmc: Support erase
  dm: blk: Enable CONFIG_BLK if DM_MMC is enabled
  dm: mmc: Enable DM_MMC_OPS by default with DM_MMC

 configs/am335x_boneblack_vboot_defconfig  |  2 ++
 configs/am335x_evm_defconfig  |  2 ++
 configs/am43xx_evm_defconfig  |  2 ++
 configs/am43xx_evm_usbhost_boot_defconfig |  2 ++
 configs/am43xx_hs_evm_defconfig   |  2 ++
 configs/am57xx_evm_defconfig  |  2 ++
 configs/am57xx_hs_evm_defconfig   |  2 ++
 configs/apalis_t30_defconfig  |  2 ++
 configs/beaver_defconfig  |  2 ++
 configs/cardhu_defconfig  |  2 ++
 configs/cei-tk1-som_defconfig |  2 ++
 configs/colibri_t20_defconfig |  2 ++
 configs/colibri_t30_defconfig |  2 ++
 configs/dalmore_defconfig |  2 ++
 configs/dra7xx_evm_defconfig  |  2 ++
 configs/dra7xx_hs_evm_defconfig   |  2 ++
 configs/e2220-1170_defconfig  |  2 ++
 configs/harmony_defconfig |  2 ++
 configs/jetson-tk1_defconfig  |  2 ++
 configs/k2g_evm_defconfig |  2 ++
 configs/medcom-wide_defconfig |  2 ++
 configs/nyan-big_defconfig|  2 ++
 configs/p2371-_defconfig  |  2 ++
 configs/p2371-2180_defconfig  |  2 ++
 configs/p2571_defconfig   |  2 ++
 configs/p2771--000_defconfig  |  2 ++
 configs/p2771--500_defconfig  |  2 ++
 configs/paz00_defconfig   |  2 ++
 configs/pic32mzdask_defconfig |  1 +
 configs/plutux_defconfig  |  2 ++
 configs/sandbox_noblk_defconfig   |  1 +
 configs/seaboard_defconfig|  2 ++
 configs/tec-ng_defconfig  |  2 ++
 configs/tec_defconfig |  2 ++
 configs/trimslice_defconfig   |  2 ++
 configs/venice2_defconfig |  2 ++
 configs/ventana_defconfig |  2 ++
 configs/whistler_defconfig|  2 ++
 drivers/block/Kconfig |  1 +
 drivers/mmc/Kconfig   |  1 +
 drivers/mmc/mmc-uclass.c  |  1 +
 drivers/mmc/mmc_private.h |  5 ++---
 drivers/mmc/mmc_write.c   | 10 --
 43 files changed, 87 insertions(+), 5 deletions(-)

-- 
2.8.0.rc3.226.g39d4020

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] sandbox: Use the address in readl/writel() functions

2016-10-01 Thread Simon Glass
At present these functions do not touch addr, which can raising warnings
about unused variables.

This fixes the following warnings:

sandbox_spl defconfig
drivers/core/regmap.c: In function ‘regmap_read’:
drivers/core/regmap.c:125:12: warning: unused variable ‘ptr’ [-Wunused-variable]
  uint32_t *ptr = map_physmem(map->base + offset, 4, MAP_NOCACHE);
^
drivers/core/regmap.c: In function ‘regmap_write’:
drivers/core/regmap.c:134:12: warning: unused variable ‘ptr’ [-Wunused-variable]
  uint32_t *ptr = map_physmem(map->base + offset, 4, MAP_NOCACHE);

Signed-off-by: Simon Glass 
Fixes: 3bfb8cb4 (dm: regmap: Implement simple regmap_read & regmap_write)
---

 arch/sandbox/include/asm/io.h | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h
index 6919632..a685635 100644
--- a/arch/sandbox/include/asm/io.h
+++ b/arch/sandbox/include/asm/io.h
@@ -40,12 +40,12 @@ static inline void unmap_sysmem(const void *vaddr)
 phys_addr_t map_to_sysmem(const void *ptr);
 
 /* Define nops for sandbox I/O access */
-#define readb(addr) 0
-#define readw(addr) 0
-#define readl(addr) 0
-#define writeb(v, addr)
-#define writew(v, addr)
-#define writel(v, addr)
+#define readb(addr) ((void)addr, 0)
+#define readw(addr) ((void)addr, 0)
+#define readl(addr) ((void)addr, 0)
+#define writeb(v, addr) ((void)addr)
+#define writew(v, addr) ((void)addr)
+#define writel(v, addr) ((void)addr)
 
 /* I/O access functions */
 int inl(unsigned int addr);
-- 
2.8.0.rc3.226.g39d4020

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 03/29] Convert CONSOLE_PRE_CONSOLE_BUFFER options to Kconfig

2016-10-01 Thread Simon Glass
Hi Siarhei,

On 30 September 2016 at 00:00, Siarhei Siamashka
 wrote:
>
> Hello Simon,
>
> On Thu, 29 Sep 2016 14:23:02 -0600
> Simon Glass  wrote:
>
> > Move these option to Kconfig and tidy up existing uses.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > Changes in v3: None
> > Changes in v2:
> > - Change CONFIG_PRE_CON_BUF_SZ default to 4096
> > - Change CONFIG_PRE_CON_BUF_SZ to 'int' type
> > - Drop the depend clause on the CONFIG_PRE_CON_BUF_SZ default
> > - Move CONFIG_PRE_CON_BUF_ADDR default to common/Kconfig
>
> What is the point moving these defines to Kconfig? They are neither
> user configurable, nor board specific. The location of the buffer is
> defined per platform or per SoC type and is a part of the global memory
> map. Similar to such things as the malloc heap and the stack.
>
> Allowing the users to redefine the buffer location is a dangerous thing
> because everything may go out of control very easily (it may overlap
> with some other memory buffer). IMHO it only makes sense to have a
> single user configurable boolean flag in Kconfig (the one which
> enables/disables the pre-console functionality).
>
> Regarding the buffer size. It was originally picked rather arbitrarily
> as 1MB at least for the sunxi platform:
>
> https://patchwork.ozlabs.org/patch/426526/
>
> Just because making it several orders of magnitude larger than
> necessary makes it extremely unlikely that anyone ever gets into
> a buffer wraparound situation. Picking smallish sizes does not gain
> us anything, but just adds an extra hassle because now one needs to
> make some estimations whether the size is large enough or not.
> Especially considering that this functionality may be sometimes
> used for debugging prints when troubleshooting something. And one
> can't easily predict how much debugging output would be actually
> necessary.

All CONFIGs need to move to Kconfig or be deleted.

I also don't like the idea of specifying an address for a pre-console
buffer. As mentioned I think it is better to allocate it
automatically. But that is a separate issue from the Kconfig
conversion. if we re-litigate every CONFIG that we move, it will never
happen.

>
> >  README| 17 
> >  board/sunxi/Kconfig   |  3 +++
> >  common/Kconfig| 42 
> > +++
> >  common/console.c  |  6 +++---
> >  configs/tbs2910_defconfig |  2 ++
> >  include/asm-generic/global_data.h |  2 +-
> >  include/configs/sunxi-common.h|  6 --
> >  include/configs/tbs2910.h |  4 
> >  scripts/config_whitelist.txt  |  3 ---
> >  9 files changed, 51 insertions(+), 34 deletions(-)
> >
> > diff --git a/README b/README
> > index 0a1f3fe..8f93dad 100644
> > --- a/README
> > +++ b/README
> > @@ -872,23 +872,6 @@ The following options need to be configured:
> >   must be defined, to setup the maximum idle timeout for
> >   the SMC.
> >
> > -- Pre-Console Buffer:
> > - Prior to the console being initialised (i.e. serial UART
> > - initialised etc) all console output is silently discarded.
> > - Defining CONFIG_PRE_CONSOLE_BUFFER will cause U-Boot to
> > - buffer any console messages prior to the console being
> > - initialised to a buffer of size CONFIG_PRE_CON_BUF_SZ
> > - bytes located at CONFIG_PRE_CON_BUF_ADDR. The buffer is
> > - a circular buffer, so if more than CONFIG_PRE_CON_BUF_SZ
> > - bytes are output before the console is initialised, the
> > - earlier bytes are discarded.
> > -
> > - Note that when printing the buffer a copy is made on the
> > - stack so CONFIG_PRE_CON_BUF_SZ must fit on the stack.
> > -
> > - 'Sane' compilers will generate smaller code if
> > - CONFIG_PRE_CON_BUF_SZ is a power of 2
> > -
> >  - Autoboot Command:
> >   CONFIG_BOOTCOMMAND
> >   Only needed when CONFIG_BOOTDELAY is enabled;
> > diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
> > index b139d1c..c0ffeb3 100644
> > --- a/board/sunxi/Kconfig
> > +++ b/board/sunxi/Kconfig
> > @@ -3,6 +3,9 @@ if ARCH_SUNXI
> >  config IDENT_STRING
> >   default " Allwinner Technology"
> >
> > +config PRE_CONSOLE_BUFFER
> > + default y
> > +
> >  config SPL_GPIO_SUPPORT
> >   default y
> >
> > diff --git a/common/Kconfig b/common/Kconfig
> > index bbd5633..6ee67ac 100644
> > --- a/common/Kconfig
> > +++ b/common/Kconfig
> > @@ -246,6 +246,48 @@ config SILENT_CONSOLE_UPDATE_ON_RELOC
> > (e.g. NAND). This option makes the value of the 'silent'
> > environment variable take effect at relocation.
> >
> > +config PRE_CONSOLE_BUFFER
> > + bool "Buffer characters before the console is available"
> > + help
> > +   Prior to the 

[U-Boot] [PATCH 4/5] sandbox/fs: Set correct filetype for unknown filetype

2016-10-01 Thread Stefan Brüns
Signed-off-by: Stefan Brüns 
---
 arch/sandbox/cpu/os.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 16af3f5..df2bd4c 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -363,6 +363,8 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node 
**headp)
case DT_LNK:
next->type = OS_FILET_LNK;
break;
+   default:
+   next->type = OS_FILET_UNKNOWN;
}
next->size = 0;
snprintf(fname, len, "%s/%s", dirname, next->name);
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 5/5] sandbox/fs: Use readdir instead of deprecated readdir_r

2016-10-01 Thread Stefan Brüns
Using readdir_r limits the maximum file name length and may even be
unsafe, and is thus deprecated in since glibc 2.24.

Signed-off-by: Stefan Brüns 
---
 arch/sandbox/cpu/os.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index df2bd4c..35ea00c 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -313,7 +313,7 @@ void os_dirent_free(struct os_dirent_node *node)
 
 int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
 {
-   struct dirent entry, *result;
+   struct dirent *entry;
struct os_dirent_node *head, *node, *next;
struct stat buf;
DIR *dir;
@@ -337,12 +337,15 @@ int os_dirent_ls(const char *dirname, struct 
os_dirent_node **headp)
}
 
for (node = head = NULL;; node = next) {
-   ret = readdir_r(dir, , );
-   if (ret || !result)
+   errno = 0;
+   entry = readdir(dir);
+   if (!entry) {
+   ret = errno;
break;
-   next = malloc(sizeof(*node) + strlen(entry.d_name) + 1);
-   if (dirlen + strlen(entry.d_name) > len) {
-   len = dirlen + strlen(entry.d_name);
+   }
+   next = malloc(sizeof(*node) + strlen(entry->d_name) + 1);
+   if (dirlen + strlen(entry->d_name) > len) {
+   len = dirlen + strlen(entry->d_name);
fname = realloc(fname, len);
}
if (!next || !fname) {
@@ -352,8 +355,8 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node 
**headp)
goto done;
}
next->next = NULL;
-   strcpy(next->name, entry.d_name);
-   switch (entry.d_type) {
+   strcpy(next->name, entry->d_name);
+   switch (entry->d_type) {
case DT_REG:
next->type = OS_FILET_REG;
break;
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 0/5] Fix some trivial issues in sandbox/fs

2016-10-01 Thread Stefan Brüns
Stefan Brüns (5):
  sandbox/fs: Free memory allocated by os_dirent_ls
  sandbox/fs: Make linking of nodes in os_dirent_ls more obvious
  sandbox/fs: Use correct size path name buffer
  sandbox/fs: Set correct filetype for unknown filetype
  sandbox/fs: Use readdir instead of deprecated readdir_r

 arch/sandbox/cpu/os.c  | 34 +++---
 fs/sandbox/sandboxfs.c |  1 +
 include/os.h   | 11 ++-
 3 files changed, 34 insertions(+), 12 deletions(-)

-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 3/5] sandbox/fs: Use correct size path name buffer

2016-10-01 Thread Stefan Brüns
The readdir linux manpage explicitly states (quoting POSIX.1) that
sizeof(d_name) is not correct for determining the required size, but to
always use strlen. Grow the buffer if needed.

Signed-off-by: Stefan Brüns 
---
 arch/sandbox/cpu/os.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index c71882a..16af3f5 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -320,14 +320,16 @@ int os_dirent_ls(const char *dirname, struct 
os_dirent_node **headp)
int ret;
char *fname;
int len;
+   int dirlen;
 
*headp = NULL;
dir = opendir(dirname);
if (!dir)
return -1;
 
-   /* Create a buffer for the maximum filename length */
-   len = sizeof(entry.d_name) + strlen(dirname) + 2;
+   /* Create a buffer upfront, with typically sufficient size */
+   dirlen = strlen(dirname) + 2;
+   len = dirlen + 256;
fname = malloc(len);
if (!fname) {
ret = -ENOMEM;
@@ -339,7 +341,12 @@ int os_dirent_ls(const char *dirname, struct 
os_dirent_node **headp)
if (ret || !result)
break;
next = malloc(sizeof(*node) + strlen(entry.d_name) + 1);
-   if (!next) {
+   if (dirlen + strlen(entry.d_name) > len) {
+   len = dirlen + strlen(entry.d_name);
+   fname = realloc(fname, len);
+   }
+   if (!next || !fname) {
+   free(next);
os_dirent_free(head);
ret = -ENOMEM;
goto done;
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/5] sandbox/fs: Make linking of nodes in os_dirent_ls more obvious

2016-10-01 Thread Stefan Brüns
Previously, after reading/creating the second dirent, the second entry
would be chained to the first entry and the first entry would be linked
to head. Instead, immediately link the first entry to head.

Signed-off-by: Stefan Brüns 
---
 arch/sandbox/cpu/os.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 2d63dd8..c71882a 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -363,8 +363,8 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node 
**headp)
next->size = buf.st_size;
if (node)
node->next = next;
-   if (!head)
-   head = node;
+   else
+   head = next;
}
*headp = head;
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/5] sandbox/fs: Free memory allocated by os_dirent_ls

2016-10-01 Thread Stefan Brüns
Signed-off-by: Stefan Brüns 
---
 fs/sandbox/sandboxfs.c |  1 +
 include/os.h   | 11 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/fs/sandbox/sandboxfs.c b/fs/sandbox/sandboxfs.c
index 2703eed..cd10fd6 100644
--- a/fs/sandbox/sandboxfs.c
+++ b/fs/sandbox/sandboxfs.c
@@ -94,6 +94,7 @@ int sandbox_fs_ls(const char *dirname)
printf("%s %10lu %s\n", os_dirent_get_typename(node->type),
   node->size, node->name);
}
+   os_dirent_free(head);
 
return 0;
 }
diff --git a/include/os.h b/include/os.h
index 1782e50..049b248 100644
--- a/include/os.h
+++ b/include/os.h
@@ -215,9 +215,18 @@ struct os_dirent_node {
 int os_dirent_ls(const char *dirname, struct os_dirent_node **headp);
 
 /**
+ * Free directory list
+ *
+ * This frees a linked list containing a directory listing.
+ *
+ * @param node Pointer to head of linked list
+ */
+void os_dirent_free(struct os_dirent_node *node);
+
+/**
  * Get the name of a directory entry type
  *
- * @param type Type to cehck
+ * @param type Type to check
  * @return string containing the name of that type, or "???" if none/invalid
  */
 const char *os_dirent_get_typename(enum os_dirent_t type);
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 3/6] efi_loader: Track size of pool allocations to allow freeing

2016-10-01 Thread Alexander Graf


On 01.10.16 19:31, Stefan Brüns wrote:
> allocate_pool has to return a buffer which is 8-byte aligned. Shift the
> region returned by allocate_pages by 8 byte and store the size in the
> headroom. The 8 byte overhead is neglegible, but provides the required
> size when freeing the allocation later.
> 
> Signed-off-by: Stefan Brüns 
> ---
>  lib/efi_loader/efi_boottime.c | 24 +---
>  1 file changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> index 784891b..c413ecb 100644
> --- a/lib/efi_loader/efi_boottime.c
> +++ b/lib/efi_loader/efi_boottime.c
> @@ -135,19 +135,37 @@ static efi_status_t EFIAPI efi_allocate_pool(int 
> pool_type, unsigned long size,
>  {
>   efi_status_t r;
>   efi_physical_addr_t t;
> + u64 num_pages = (size + 8 + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;

Would it make things more readable if you used sizeof(u64) here?

Also, it's great to have a nice patch description which described why we
have the 8 byte padding here, but we definitely need it as comment in
the code as well. Otherwise people 2 years from now will have no idea
why we allocate 8 bytes more ;). At least not without reverse
engineering the source.

>  
>   EFI_ENTRY("%d, %ld, %p", pool_type, size, buffer);
> - r = efi_allocate_pages(0, pool_type, (size + 0xfff) >> 12, );
> - *buffer = (void *)(uintptr_t)t;
> +
> + if (size == 0) {
> + *buffer = NULL;
> + return EFI_EXIT(EFI_SUCCESS);
> + }
> +
> + r = efi_allocate_pages(0, pool_type, num_pages, );
> +
> + if (r == EFI_SUCCESS) {
> + *(u64 *)(uintptr_t)t = num_pages;

I would prefer if we could make that cast a bit more expressive. How about

  u64 *num_pages_hint = (void *)(uintptr_t)t;

  *num_pages_hint = num_pages;
  *buffer = _pages_hint[1];

or maybe even better would be a trivial struct. Something like

  struct efi_pool_allocation {
u64 num_pages;
char data[];
  };

Then you could basically write mostly self-documenting code:

  struct efi_pool_alloction *alloc = (void *)(uintptr_t)t;

  alloc->num_pages = num_pages;
  *buffer = alloc->data;

I would still prefer if you could write a comment about what's going on,
but with this it's much more obvious IMHO.

> + *buffer = (void *)(uintptr_t)(t + 8);
> + }
> +
>   return EFI_EXIT(r);
>  }
>  
>  static efi_status_t EFIAPI efi_free_pool(void *buffer)
>  {
>   efi_status_t r;
> + u64 num_pages;
>  
>   EFI_ENTRY("%p", buffer);
> - r = efi_free_pages((ulong)buffer, 0);
> +
> + buffer = (char *)(buffer) - 8;
> + assert(((ulong)buffer & EFI_PAGE_MASK) == 0);
> + num_pages = *(u64 *)buffer;

With the struct, this could look a lot cleaner too:

  struct efi_pool_alloction *alloc = container_of(buffer, struct
efi_pool_alloction, data);

  /* Pool allocations always happen on page boundaries */
  assert(!((uintptr_t)alloc & EFI_PAGE_MASK));
  r = efi_free_pages((uintptr_t)alloc->data, alloc->num_pages);


Alex

> +
> + r = efi_free_pages((ulong)buffer, num_pages);
>   return EFI_EXIT(r);
>  }
>  
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/6] efi_loader: Fix memory map size check to avoid out-of-bounds access

2016-10-01 Thread Alexander Graf


On 01.10.16 19:31, Stefan Brüns wrote:
> Do not overwrite the specified size of the provided buffer without
> having checked it is sufficient.
> 
> If the buffer is to small, memory_map_size is updated to indicate the
> required size, and an error code is returned.
> 
> Signed-off-by: Stefan Brüns 
> ---
>  lib/efi_loader/efi_memory.c | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
> index ebe8e94..72a5870 100644
> --- a/lib/efi_loader/efi_memory.c
> +++ b/lib/efi_loader/efi_memory.c
> @@ -342,6 +342,11 @@ efi_status_t efi_get_memory_map(unsigned long 
> *memory_map_size,
>  
>   map_size = map_entries * sizeof(struct efi_mem_desc);
>  
> + if (*memory_map_size < map_size) {
> + *memory_map_size = map_size;
> + return EFI_BUFFER_TOO_SMALL;

IIRC I had issues with that approach in the past with payloads that
wanted to determine the descriptor size regardless of the error output.
I liked your previous version better - it really just needed a
description overhaul :)


Alex
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 5/6] efi_loader: Keep memory mapping sorted when splitting an entry

2016-10-01 Thread Stefan Brüns
The code assumes sorted mappings in descending address order. When
splitting a mapping, insert the new part next to the current mapping.

Signed-off-by: Stefan Brüns 
Reviewed-by: Alexander Graf 
---
 lib/efi_loader/efi_memory.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 9c785dd..26a5d50 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -122,7 +122,8 @@ static int efi_mem_carve_out(struct efi_mem_list *map,
newmap->desc = map->desc;
newmap->desc.physical_start = carve_start;
newmap->desc.num_pages = (map_end - carve_start) >> EFI_PAGE_SHIFT;
-list_add_tail(>link, _mem);
+   /* Insert before current entry (descending address order) */
+   list_add_tail(>link, >link);
 
/* Shrink the map to [ map_start ... carve_start ] */
map_desc->num_pages = (carve_start - map_start) >> EFI_PAGE_SHIFT;
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 3/6] efi_loader: Track size of pool allocations to allow freeing

2016-10-01 Thread Stefan Brüns
allocate_pool has to return a buffer which is 8-byte aligned. Shift the
region returned by allocate_pages by 8 byte and store the size in the
headroom. The 8 byte overhead is neglegible, but provides the required
size when freeing the allocation later.

Signed-off-by: Stefan Brüns 
---
 lib/efi_loader/efi_boottime.c | 24 +---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 784891b..c413ecb 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -135,19 +135,37 @@ static efi_status_t EFIAPI efi_allocate_pool(int 
pool_type, unsigned long size,
 {
efi_status_t r;
efi_physical_addr_t t;
+   u64 num_pages = (size + 8 + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
 
EFI_ENTRY("%d, %ld, %p", pool_type, size, buffer);
-   r = efi_allocate_pages(0, pool_type, (size + 0xfff) >> 12, );
-   *buffer = (void *)(uintptr_t)t;
+
+   if (size == 0) {
+   *buffer = NULL;
+   return EFI_EXIT(EFI_SUCCESS);
+   }
+
+   r = efi_allocate_pages(0, pool_type, num_pages, );
+
+   if (r == EFI_SUCCESS) {
+   *(u64 *)(uintptr_t)t = num_pages;
+   *buffer = (void *)(uintptr_t)(t + 8);
+   }
+
return EFI_EXIT(r);
 }
 
 static efi_status_t EFIAPI efi_free_pool(void *buffer)
 {
efi_status_t r;
+   u64 num_pages;
 
EFI_ENTRY("%p", buffer);
-   r = efi_free_pages((ulong)buffer, 0);
+
+   buffer = (char *)(buffer) - 8;
+   assert(((ulong)buffer & EFI_PAGE_MASK) == 0);
+   num_pages = *(u64 *)buffer;
+
+   r = efi_free_pages((ulong)buffer, num_pages);
return EFI_EXIT(r);
 }
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/6] efi_loader: Update description of internal efi_mem_carve_out

2016-10-01 Thread Stefan Brüns
In 74c16acce30bb882ad5951829d8dafef8eea564c the return values where
changed, but the description was kept.

Signed-off-by: Stefan Brüns 
---
 lib/efi_loader/efi_memory.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 80e4e26..ebe8e94 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -62,9 +62,17 @@ static void efi_mem_sort(void)
  * Unmaps all memory occupied by the carve_desc region from the
  * list entry pointed to by map.
  *
- * Returns 1 if carving was performed or 0 if the regions don't overlap.
- * Returns -1 if it would affect non-RAM regions but overlap_only_ram is set.
- * Carving is only guaranteed to complete when all regions return 0.
+ * Returns EFI_CARVE_NO_OVERLAP if the regions don't overlap.
+ * Returns EFI_CARVE_OVERLAPS_NONRAM if the carve and map overlap,
+ *and the map contains anything but free ram.
+ *(only when overlap_only_ram is true)
+ * Returns EFI_CARVE_LOOP_AGAIN if the mapping list should be traversed
+ *again, as it has been altered
+ * Returns the number of overlapping pages. The pages are removed from
+ * the mapping list.
+ *
+ * In case of EFI_CARVE_OVERLAPS_NONRAM it is the callers responsibility
+ * to readd the already carved out pages to the mapping.
  */
 static int efi_mem_carve_out(struct efi_mem_list *map,
 struct efi_mem_desc *carve_desc,
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 2/6] efi_loader: Fix memory map size check to avoid out-of-bounds access

2016-10-01 Thread Stefan Brüns
Do not overwrite the specified size of the provided buffer without
having checked it is sufficient.

If the buffer is to small, memory_map_size is updated to indicate the
required size, and an error code is returned.

Signed-off-by: Stefan Brüns 
---
 lib/efi_loader/efi_memory.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index ebe8e94..72a5870 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -342,6 +342,11 @@ efi_status_t efi_get_memory_map(unsigned long 
*memory_map_size,
 
map_size = map_entries * sizeof(struct efi_mem_desc);
 
+   if (*memory_map_size < map_size) {
+   *memory_map_size = map_size;
+   return EFI_BUFFER_TOO_SMALL;
+   }
+
*memory_map_size = map_size;
 
if (descriptor_size)
@@ -350,9 +355,6 @@ efi_status_t efi_get_memory_map(unsigned long 
*memory_map_size,
if (descriptor_version)
*descriptor_version = EFI_MEMORY_DESCRIPTOR_VERSION;
 
-   if (*memory_map_size < map_size)
-   return EFI_BUFFER_TOO_SMALL;
-
/* Copy list into array */
if (memory_map) {
/* Return the list in ascending order */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 4/6] efi_loader: Readd freed pages to memory pool

2016-10-01 Thread Stefan Brüns
Currently each allocation creates a new mapping. Readding the mapping
as free memory (EFI_CONVENTIONAL_MEMORY) potentially allows to hand out
an existing mapping, thus limiting the number of mapping descriptors in
the memory map.

Mitigates a problem with current (4.8rc7) linux kernels when doing an
efi_get_memory map, resulting in an infinite loop. Space for the memory
map is reserved with allocate_pool (implicitly creating a new mapping) and
filled. If there is insufficient slack space (8 entries) in the map, the
space is freed and a new round is started, with space for one more entry.
As each round increases requirement and allocation by exactly one, there
is never enough slack space. (At least 32 entries are allocated, so as
long as there are less than 24 entries, there is enough slack).
Earlier kernels reserved no slack, and did less allocations, so this
problem was not visible.

Signed-off-by: Stefan Brüns 
Reviewed-by: Alexander Graf 
---
 lib/efi_loader/efi_memory.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 72a5870..9c785dd 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -323,8 +323,15 @@ void *efi_alloc(uint64_t len, int memory_type)
 
 efi_status_t efi_free_pages(uint64_t memory, unsigned long pages)
 {
-   /* We don't free, let's cross our fingers we have plenty RAM */
-   return EFI_SUCCESS;
+   uint64_t r = 0;
+
+   r = efi_add_memory_map(memory, pages, EFI_CONVENTIONAL_MEMORY, false);
+   /* Merging of adjacent free regions is missing */
+
+   if (r == memory)
+   return EFI_SUCCESS;
+
+   return EFI_NOT_FOUND;
 }
 
 efi_status_t efi_get_memory_map(unsigned long *memory_map_size,
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 6/6] efi_loader: Do not leak memory when unlinking a mapping

2016-10-01 Thread Stefan Brüns
As soon as a mapping is unlinked from the list, there are no further
references to it, so it should be freed. If it not unlinked,
update the start address and length.

Signed-off-by: Stefan Brüns 
Reviewed-by: Alexander Graf 
---
 lib/efi_loader/efi_memory.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 26a5d50..000e776 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -103,10 +103,13 @@ static int efi_mem_carve_out(struct efi_mem_list *map,
if (map_end == carve_end) {
/* Full overlap, just remove map */
list_del(>link);
+   free(map);
+   } else {
+   map->desc.physical_start = carve_end;
+   map->desc.num_pages = (map_end - carve_end)
+ >> EFI_PAGE_SHIFT;
}
 
-   map_desc->physical_start = carve_end;
-   map_desc->num_pages = (map_end - carve_end) >> EFI_PAGE_SHIFT;
return (carve_end - carve_start) >> EFI_PAGE_SHIFT;
}
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 0/6] efi_loader: implement BS.FreePages()/BS.FreePool, some cleanup

2016-10-01 Thread Stefan Brüns
Linux 4.8 no longer boots, as it runs out of descriptor space. Readding
the mapping allows reuse, and the next AllocatePool will likely not add
a new mapping.

Also fix some small issues found while debugging.

v2, updated:
  efi_loader: Fix memory map size check to avoid out-of-bounds access
  - (Hopefully) clarified commit message
  efi_loader: Track size of pool allocations to allow freeing
  - rebased on top of 'efi_loader: Fix crash on 32-bit systems'
  - assert correct address in efi_free_pool
  - use EFI_PAGE_MASK instead of 0xfff, EFI_PAGE_SHIFT likewise

Stefan Brüns (6):
  efi_loader: Update description of internal efi_mem_carve_out
  efi_loader: Fix memory map size check to avoid out-of-bounds access
  efi_loader: Track size of pool allocations to allow freeing
  efi_loader: Readd freed pages to memory pool
  efi_loader: Keep memory mapping sorted when splitting an entry
  efi_loader: Do not leak memory when unlinking a mapping

 lib/efi_loader/efi_boottime.c | 24 +---
 lib/efi_loader/efi_memory.c   | 43 ---
 2 files changed, 53 insertions(+), 14 deletions(-)

-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 07/23] pci: Handle MIPS systems with virtual CONFIG_SYS_SDRAM_BASE

2016-10-01 Thread Paul Burton
On Tuesday, 27 September 2016 12:01:32 BST Daniel Schwierzeck wrote:
> 2016-09-27 2:35 GMT+02:00 Simon Glass :
> > Hi Paul,
> > 
> > On 26 September 2016 at 12:29, Paul Burton  wrote:
> >> The decode_regions() function in the PCI code presumes that
> >> CONFIG_SYS_SDRAM_BASE is a physical address, which seems reasonable
> >> given that README states that it should be.
> >> 
> >> However there is also common code which expects CONFIG_SYS_SDRAM_BASE to
> >> be an address accessible by the CPU, ie. a valid virtual address -
> >> notably gd->ram_top is set to it & various pieces of data are located
> >> relative to that, and getenv_bootm_low() defaults to
> >> CONFIG_SYS_SDRAM_BASE as the lower bound on addresses to load into. Thus
> >> on MIPS CONFIG_SYS_SDRAM_BASE is a virtual address.
> >> 
> >> This patch takes the simple approach to fixing this & converts
> >> CONFIG_SYS_SDRAM_BASE to a physical address for use by the PCI code when
> >> built for MIPS.
> >> 
> >> Signed-off-by: Paul Burton 
> >> 
> >> ---
> >> 
> >>  drivers/pci/pci-uclass.c | 4 +++-
> >>  1 file changed, 3 insertions(+), 1 deletion(-)
> >> 
> >> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
> >> index 415c632..26fe0f4 100644
> >> --- a/drivers/pci/pci-uclass.c
> >> +++ b/drivers/pci/pci-uclass.c
> >> @@ -848,7 +848,9 @@ static int decode_regions(struct pci_controller
> >> *hose, const void *blob,>> 
> >> /* Add a region for our local memory */
> >> size = gd->ram_size;
> >> 
> >> -#ifdef CONFIG_SYS_SDRAM_BASE
> >> +#if defined(CONFIG_MIPS)
> >> +   base = virt_to_phys((void *)CONFIG_SYS_SDRAM_BASE);
> >> +#elif defined(CONFIG_SYS_SDRAM_BASE)
> >> 
> >> base = CONFIG_SYS_SDRAM_BASE;
> >>  
> >>  #endif
> >>  
> >> if (gd->pci_ram_top && gd->pci_ram_top < base + size)
> >> 
> >> --
> >> 2.10.0
> > 
> > Can you find another way? We don't want arch- or board-specific
> > #ifdefs in uclasses or driver code.
> 
> I suggest that we fix all MIPS boards to configure
> CONFIG_SYS_SDRAM_BASE as physical address. I guess that would be
> simply 0 for all current supported MIPS boards. In "arch/mips/" there
> are only two users ("arch/mips/cpu/start.S" and
> "arch/mips/lib/bootm.c") which could be easily fixed to map
> CONFIG_SYS_SDRAM_BASE to KSEG0.

Hi Daniel & Simon,

So doing that led to the 27 patch series I just sent out. It's never simple :) 
It's not so much 
the 2 users in arch/mips/ as the generic uses which cause the trouble - and 
avoiding them 
needs something like phys_to_virt() so the bulk of that series is about 
providing that for all 
architectures.

FYI CONFIG_SYS_SDRAM_BASE is zero for all MIPS boards except the PIC32 one. 
I've tested 
the series on a 32 bit Malta & a 64 bit boston, and build tested a bunch of 
other boards. The 
only thing to really take note of is that for MIPS64 systems using a physical 
CONFIG_SYS_SDRAM_BASE and phys_to_virt we end up accessing memory through 
xkphys 
instead of ckseg0. Nothing seems to have exploded too badly from that (just the 
boston 
board_get_usable_ram_top() needed adjusting) but it's probably worth pointing 
out.

Thanks,
Paul


signature.asc
Description: This is a digitally signed message part.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 26/27] mips: Use a physical CONFIG_SYS_SDRAM_BASE for remaining boards

2016-10-01 Thread Paul Burton
README states that CONFIG_SYS_SDRAM_BASE should the physical base
address of SDRAM, whilst up until now various pieces of generic code
have presumed that it can be directly accessed by the CPU & MIPS has
provided a virtual address for CONFIG_SYS_SDRAM_BASE. Other generic code
expects CONFIG_SYS_SDRAM_BASE to be a physical address, which makes the
inconsistency a mess.

Now that the preceding patches have prepared us to handle using a
physical CONFIG_SYS_SDRAM_BASE, clean up the inconsistency for the
remaining MIPS boards by providing a physical CONFIG_SYS_SDRAM_BASE.

None of these boards use CONFIG_SYS_SDRAM_BASE in their code, so they're
handled together.

This has only been build-tested, feedback welcome.

Signed-off-by: Paul Burton 
Cc: Daniel Schwierzeck 
Cc: Marek Vasut 
Cc: Purna Chandra Mandal 
Cc: Wills Wang 
---

 include/configs/ap121.h  | 2 +-
 include/configs/ap143.h  | 2 +-
 include/configs/dbau1x00.h   | 2 +-
 include/configs/pb1x00.h | 2 +-
 include/configs/pic32mzdask.h| 2 +-
 include/configs/qemu-mips.h  | 2 +-
 include/configs/qemu-mips64.h| 2 +-
 include/configs/tplink_wdr4300.h | 2 +-
 include/configs/vct.h| 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/configs/ap121.h b/include/configs/ap121.h
index bf5746f..63e0015 100644
--- a/include/configs/ap121.h
+++ b/include/configs/ap121.h
@@ -20,7 +20,7 @@
 #define CONFIG_SYS_MALLOC_LEN   0x4
 #define CONFIG_SYS_BOOTPARAMS_LEN   0x2
 
-#define CONFIG_SYS_SDRAM_BASE   0x8000
+#define CONFIG_SYS_SDRAM_BASE   0x0
 #define CONFIG_SYS_LOAD_ADDR0x8100
 
 #define CONFIG_SYS_NO_FLASH
diff --git a/include/configs/ap143.h b/include/configs/ap143.h
index 5d7e49e..a8721e6 100644
--- a/include/configs/ap143.h
+++ b/include/configs/ap143.h
@@ -20,7 +20,7 @@
 #define CONFIG_SYS_MALLOC_LEN   0x4
 #define CONFIG_SYS_BOOTPARAMS_LEN   0x2
 
-#define CONFIG_SYS_SDRAM_BASE   0x8000
+#define CONFIG_SYS_SDRAM_BASE   0x0
 #define CONFIG_SYS_LOAD_ADDR0x8100
 
 #define CONFIG_SYS_NO_FLASH
diff --git a/include/configs/dbau1x00.h b/include/configs/dbau1x00.h
index dbd2bb3..b369d71 100644
--- a/include/configs/dbau1x00.h
+++ b/include/configs/dbau1x00.h
@@ -105,7 +105,7 @@
 
 #define CONFIG_SYS_MIPS_TIMER_FREQ (CONFIG_SYS_MHZ * 100)
 
-#define CONFIG_SYS_SDRAM_BASE  0x8000 /* Cached addr */
+#define CONFIG_SYS_SDRAM_BASE  0x0/* Cached addr */
 
 #defineCONFIG_SYS_LOAD_ADDR0x8100 /* default load 
address  */
 
diff --git a/include/configs/pb1x00.h b/include/configs/pb1x00.h
index fb5278f..8ef334f 100644
--- a/include/configs/pb1x00.h
+++ b/include/configs/pb1x00.h
@@ -61,7 +61,7 @@
 
 #define CONFIG_SYS_MIPS_TIMER_FREQ 39600
 
-#define CONFIG_SYS_SDRAM_BASE  0x8000 /* Cached addr */
+#define CONFIG_SYS_SDRAM_BASE  0x0/* Cached addr */
 
 #defineCONFIG_SYS_LOAD_ADDR0x8100 /* default load 
address  */
 
diff --git a/include/configs/pic32mzdask.h b/include/configs/pic32mzdask.h
index 49c98d8..5b80b46 100644
--- a/include/configs/pic32mzdask.h
+++ b/include/configs/pic32mzdask.h
@@ -35,7 +35,7 @@
(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE - 1)
 
 /* SDRAM Configuration (for final code, data, stack, heap) */
-#define CONFIG_SYS_SDRAM_BASE  0x8800
+#define CONFIG_SYS_SDRAM_BASE  0x0800
 #define CONFIG_SYS_MALLOC_LEN  (256 << 10)
 #define CONFIG_SYS_BOOTPARAMS_LEN  (4 << 10)
 #define CONFIG_STACKSIZE   (4 << 10) /* regular stack */
diff --git a/include/configs/qemu-mips.h b/include/configs/qemu-mips.h
index 546c508..7e839a8 100644
--- a/include/configs/qemu-mips.h
+++ b/include/configs/qemu-mips.h
@@ -94,7 +94,7 @@
 #define CONFIG_SYS_MIPS_TIMER_FREQ (CONFIG_SYS_MHZ * 100)
 
 /* Cached addr */
-#define CONFIG_SYS_SDRAM_BASE  0x8000
+#define CONFIG_SYS_SDRAM_BASE  0x0
 
 /* default load address */
 #define CONFIG_SYS_LOAD_ADDR   0x8100
diff --git a/include/configs/qemu-mips64.h b/include/configs/qemu-mips64.h
index 6cab719..18e3294 100644
--- a/include/configs/qemu-mips64.h
+++ b/include/configs/qemu-mips64.h
@@ -94,7 +94,7 @@
 #define CONFIG_SYS_MIPS_TIMER_FREQ (CONFIG_SYS_MHZ * 100)
 
 /* Cached addr */
-#define CONFIG_SYS_SDRAM_BASE  0x8000
+#define CONFIG_SYS_SDRAM_BASE  0x0
 
 /* default load address */
 #define CONFIG_SYS_LOAD_ADDR   0x8100
diff --git a/include/configs/tplink_wdr4300.h b/include/configs/tplink_wdr4300.h
index 7bf8e4c..5a6a0d4 100644
--- a/include/configs/tplink_wdr4300.h
+++ b/include/configs/tplink_wdr4300.h
@@ -20,7 +20,7 @@
 #define 

[U-Boot] [PATCH 27/27] mips: Remove virt_to_phys call on bi_memstart

2016-10-01 Thread Paul Burton
CONFIG_SYS_SDRAM_BASE & by extension bi_memstart are now physical
addresses, so there's no need to call virt_to_phys in arch_fixup_fdt.
Remove the call.

Signed-off-by: Paul Burton 
Cc: Daniel Schwierzeck 

---

 arch/mips/lib/bootm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 9fec4ad..00991cb 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -257,7 +257,7 @@ static int boot_reloc_fdt(bootm_headers_t *images)
 int arch_fixup_fdt(void *blob)
 {
 #if CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && CONFIG_IS_ENABLED(OF_LIBFDT)
-   u64 mem_start = virt_to_phys((void *)gd->bd->bi_memstart);
+   u64 mem_start = gd->bd->bi_memstart;
u64 mem_size = gd->ram_size;
 
return fdt_fixup_memory_banks(blob, _start, _size, 1);
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 24/27] malta: Use a physical CONFIG_SYS_SDRAM_BASE

2016-10-01 Thread Paul Burton
README states that CONFIG_SYS_SDRAM_BASE should the physical base
address of SDRAM, whilst up until now various pieces of generic code
have presumed that it can be directly accessed by the CPU & MIPS has
provided a virtual address for CONFIG_SYS_SDRAM_BASE. Other generic code
expects CONFIG_SYS_SDRAM_BASE to be a physical address, which makes the
inconsistency a mess.

Now that the preceding patches have prepared us to handle using a
physical CONFIG_SYS_SDRAM_BASE, clean up the inconsistency for malta by
providing a physical CONFIG_SYS_SDRAM_BASE.

Signed-off-by: Paul Burton 
Cc: Daniel Schwierzeck 
---

 include/configs/malta.h | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/include/configs/malta.h b/include/configs/malta.h
index fc4baba..5bc9f23 100644
--- a/include/configs/malta.h
+++ b/include/configs/malta.h
@@ -39,18 +39,20 @@
  */
 #define CONFIG_SYS_MONITOR_BASECONFIG_SYS_TEXT_BASE
 
-#ifdef CONFIG_64BIT
-# define CONFIG_SYS_SDRAM_BASE 0x8000
-#else
-# define CONFIG_SYS_SDRAM_BASE 0x8000
-#endif
+#define CONFIG_SYS_SDRAM_BASE  0x0
 #define CONFIG_SYS_MEM_SIZE(256 * 1024 * 1024)
 
 #define CONFIG_SYS_INIT_SP_OFFSET  0x40
 
-#define CONFIG_SYS_LOAD_ADDR   (CONFIG_SYS_SDRAM_BASE + 0x0100)
-#define CONFIG_SYS_MEMTEST_START   (CONFIG_SYS_SDRAM_BASE + 0x0010)
-#define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_SDRAM_BASE + 0x0080)
+#ifdef CONFIG_64BIT
+# define CONFIG_SYS_LOAD_ADDR  0x8100
+# define CONFIG_SYS_MEMTEST_START  0x8010
+# define CONFIG_SYS_MEMTEST_END0x8080
+#else
+# define CONFIG_SYS_LOAD_ADDR  0x8100
+# define CONFIG_SYS_MEMTEST_START  0x8010
+# define CONFIG_SYS_MEMTEST_END0x8080
+#endif
 
 #define CONFIG_SYS_MALLOC_LEN  (128 * 1024)
 #define CONFIG_SYS_BOOTPARAMS_LEN  (128 * 1024)
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 25/27] xilfpga: Use a physical CONFIG_SYS_SDRAM_BASE

2016-10-01 Thread Paul Burton
README states that CONFIG_SYS_SDRAM_BASE should the physical base
address of SDRAM, whilst up until now various pieces of generic code
have presumed that it can be directly accessed by the CPU & MIPS has
provided a virtual address for CONFIG_SYS_SDRAM_BASE. Other generic code
expects CONFIG_SYS_SDRAM_BASE to be a physical address, which makes the
inconsistency a mess.

Now that the preceding patches have prepared us to handle using a
physical CONFIG_SYS_SDRAM_BASE, clean up the inconsistency for malta by
providing a physical CONFIG_SYS_SDRAM_BASE.

This has only been build-tested, feedback welcome.

Signed-off-by: Paul Burton 
Cc: Daniel Schwierzeck 
Cc: Zubair Lutfullah Kakakhel 
---

 include/configs/imgtec_xilfpga.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/configs/imgtec_xilfpga.h b/include/configs/imgtec_xilfpga.h
index 0a7fe60..1583f21 100644
--- a/include/configs/imgtec_xilfpga.h
+++ b/include/configs/imgtec_xilfpga.h
@@ -28,10 +28,10 @@
  */
 
 /* SDRAM Configuration (for final code, data, stack, heap) */
-#define CONFIG_SYS_SDRAM_BASE  0x8000
+#define CONFIG_SYS_SDRAM_BASE  0x0
 #define CONFIG_SYS_SDRAM_SIZE  0x0800  /* 128 Mbytes */
 #define CONFIG_SYS_INIT_SP_ADDR\
-   (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_SDRAM_SIZE - 0x1000)
+   (0x8000 + CONFIG_SYS_SDRAM_SIZE - 0x1000)
 
 #define CONFIG_SYS_MALLOC_LEN  (256 << 10)
 #define CONFIG_SYS_MONITOR_BASECONFIG_SYS_TEXT_BASE
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 22/27] mips: Ensure stack is at a virtual address

2016-10-01 Thread Paul Burton
In preparation for making CONFIG_SYS_SDRAM_BASE a physical address on
MIPS as README says it should be, ensure that our default
CONFIG_SYS_INIT_SP_ADDR is placed in (c)kseg0 rather than being a simple
offset addition to CONFIG_SYS_SDRAM_BASE.

Signed-off-by: Paul Burton 
Cc: Daniel Schwierzeck 
---

 arch/mips/cpu/start.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/mips/cpu/start.S b/arch/mips/cpu/start.S
index 3f0fc12..936d63c 100644
--- a/arch/mips/cpu/start.S
+++ b/arch/mips/cpu/start.S
@@ -8,12 +8,13 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 
 #ifndef CONFIG_SYS_INIT_SP_ADDR
-#define CONFIG_SYS_INIT_SP_ADDR(CONFIG_SYS_SDRAM_BASE + \
+#define CONFIG_SYS_INIT_SP_ADDRCKSEG0ADDR(CONFIG_SYS_SDRAM_BASE + \
CONFIG_SYS_INIT_SP_OFFSET)
 #endif
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 23/27] boston: Provide physical CONFIG_SYS_SDRAM_BASE

2016-10-01 Thread Paul Burton
README states that CONFIG_SYS_SDRAM_BASE should the physical base
address of SDRAM, whilst up until now various pieces of generic code
have presumed that it can be directly accessed by the CPU & MIPS has
provided a virtual address for CONFIG_SYS_SDRAM_BASE. Other generic code
expects CONFIG_SYS_SDRAM_BASE to be a physical address, which makes the
inconsistency a mess.

Now that the preceding patches have prepared us to handle using a
physical CONFIG_SYS_SDRAM_BASE, clean up the inconsistency for boston by
providing a physical CONFIG_SYS_SDRAM_BASE. A side effect of this & use
of phys_to_virt is that on MIPS64 U-Boot will now access DDR through the
xkphys region of the virtual address space rather than ckseg0, which
necessitates the change to board_get_usable_ram_top().

Signed-off-by: Paul Burton 
Cc: Daniel Schwierzeck 
---

 board/imgtec/boston/ddr.c |  8 ++--
 include/configs/boston.h  | 21 ++---
 2 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/board/imgtec/boston/ddr.c b/board/imgtec/boston/ddr.c
index ceffef6..e765627 100644
--- a/board/imgtec/boston/ddr.c
+++ b/board/imgtec/boston/ddr.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 
 #include 
 
@@ -21,10 +22,5 @@ ulong board_get_usable_ram_top(ulong total_size)
 {
DECLARE_GLOBAL_DATA_PTR;
 
-   if (gd->ram_top < CONFIG_SYS_SDRAM_BASE) {
-   /* 2GB wrapped around to 0 */
-   return CKSEG0ADDR(256 << 20);
-   }
-
-   return min_t(unsigned long, gd->ram_top, CKSEG0ADDR(256 << 20));
+   return min_t(ulong, gd->ram_top, (ulong)phys_to_virt(SZ_256M));
 }
diff --git a/include/configs/boston.h b/include/configs/boston.h
index e958054..37060b0 100644
--- a/include/configs/boston.h
+++ b/include/configs/boston.h
@@ -27,20 +27,19 @@
 /*
  * Memory map
  */
-#ifdef CONFIG_64BIT
-# define CONFIG_SYS_SDRAM_BASE 0x8000
-#else
-# define CONFIG_SYS_SDRAM_BASE 0x8000
-#endif
-
+#define CONFIG_SYS_SDRAM_BASE  0x0
 #define CONFIG_SYS_INIT_SP_OFFSET  0x40
-
 #define CONFIG_SYS_MONITOR_BASECONFIG_SYS_TEXT_BASE
 
-#define CONFIG_SYS_LOAD_ADDR   (CONFIG_SYS_SDRAM_BASE + 0x10)
-
-#define CONFIG_SYS_MEMTEST_START   (CONFIG_SYS_SDRAM_BASE + 0)
-#define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_SDRAM_BASE + 0x1000)
+#ifdef CONFIG_64BIT
+# define CONFIG_SYS_LOAD_ADDR  0x8010
+# define CONFIG_SYS_MEMTEST_START  0x8000
+# define CONFIG_SYS_MEMTEST_END0x9000
+#else
+# define CONFIG_SYS_LOAD_ADDR  0x8010
+# define CONFIG_SYS_MEMTEST_START  0x8000
+# define CONFIG_SYS_MEMTEST_END0x9000
+#endif
 
 #define CONFIG_SYS_MALLOC_LEN  (256 * 1024)
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 21/27] mips: Use ram_top, not bi_memsize, in arch_lmb_reserve

2016-10-01 Thread Paul Burton
When calculating the region to reserve for the stack in
arch_lmb_reserve, make use of ram_top instead of adding bi_memsize to
CONFIG_SYS_SDRAM_BASE. This avoids overflow if the system has enough
memory to reach the end of the address space.

Signed-off-by: Paul Burton 
Cc: Daniel Schwierzeck 
---

 arch/mips/lib/bootm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 0c6a4ab..9fec4ad 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -42,7 +42,7 @@ void arch_lmb_reserve(struct lmb *lmb)
 
/* adjust sp by 4K to be safe */
sp -= 4096;
-   lmb_reserve(lmb, sp, CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp);
+   lmb_reserve(lmb, sp, gd->ram_top - sp);
 }
 
 static void linux_cmdline_init(void)
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 20/27] image: Use ram_top, not bi_memsize, in getenv_bootm_size

2016-10-01 Thread Paul Burton
When determining the region of memory to allow for use by bootm, using
bi_memstart & adding bi_memsize can cause problems if that leads to an
integer overflow. For example on some MIPS systems bi_memstart would be
0x8000 (ie. the start of the MIPS ckseg0 region) and if the
system has 2GB of memory then the addition would wrap around to 0.

The maximum amount of memory to be used by U-Boot is already accounted
for by the ram_top field of struct global_data, so make use of that for
the calculation instead.

Signed-off-by: Paul Burton 
---

 common/image.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/image.c b/common/image.c
index 1581022..25e632b 100644
--- a/common/image.c
+++ b/common/image.c
@@ -489,7 +489,7 @@ phys_size_t getenv_bootm_size(void)
size = gd->bd->bi_dram[0].size;
 #else
start = (ulong)phys_to_virt(gd->bd->bi_memstart);
-   size = gd->bd->bi_memsize;
+   size = gd->ram_top - start;
 #endif
 
s = getenv("bootm_low");
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 19/27] image: Account for CONFIG_SYS_SDRAM_BASE being physical

2016-10-01 Thread Paul Burton
README declares that CONFIG_SYS_SDRAM_BASE is meant to be the physical
address of SDRAM, but right now that is not the case on MIPS systems,
where it is instead a virtual address. In preparation for making it
physical, use phys_to_virt to translate CONFIG_SYS_SDRAM_BASE & the
associated bi_memstart field of struct bd_info to virtual addresses for
use.

Signed-off-by: Paul Burton 
---

 common/image.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/image.c b/common/image.c
index a5d19ab..1581022 100644
--- a/common/image.c
+++ b/common/image.c
@@ -466,7 +466,7 @@ ulong getenv_bootm_low(void)
}
 
 #if defined(CONFIG_SYS_SDRAM_BASE)
-   return CONFIG_SYS_SDRAM_BASE;
+   return (ulong)phys_to_virt(CONFIG_SYS_SDRAM_BASE);
 #elif defined(CONFIG_ARM)
return gd->bd->bi_dram[0].start;
 #else
@@ -488,7 +488,7 @@ phys_size_t getenv_bootm_size(void)
start = gd->bd->bi_dram[0].start;
size = gd->bd->bi_dram[0].size;
 #else
-   start = gd->bd->bi_memstart;
+   start = (ulong)phys_to_virt(gd->bd->bi_memstart);
size = gd->bd->bi_memsize;
 #endif
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 18/27] board_f: Account for CONFIG_SYS_SDRAM_BASE being physical

2016-10-01 Thread Paul Burton
README declares that CONFIG_SYS_SDRAM_BASE is meant to be the physical
address of SDRAM, but right now that is not the case on MIPS systems. In
preparation for making it so, use phys_to_virt to translate
CONFIG_SYS_SDRAM_BASE to the ram_top field of struct global_data which
is then used to calculate most memory addresses used by U-Boot.

Signed-off-by: Paul Burton 
---

 common/board_f.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/board_f.c b/common/board_f.c
index 2c88595..1afc80d 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -315,7 +315,7 @@ __weak ulong board_get_usable_ram_top(ulong total_size)
 * Detect whether we have so much RAM that it goes past the end of our
 * 32-bit address space. If so, clip the usable RAM so it doesn't.
 */
-   if (gd->ram_top < CONFIG_SYS_SDRAM_BASE)
+   if (gd->ram_top < (ulong)phys_to_virt(CONFIG_SYS_SDRAM_BASE))
/*
 * Will wrap back to top of 32-bit space when reservations
 * are made.
@@ -362,7 +362,7 @@ static int setup_dest_addr(void)
gd->ram_size = board_reserve_ram_top(gd->ram_size);
 
 #ifdef CONFIG_SYS_SDRAM_BASE
-   gd->ram_top = CONFIG_SYS_SDRAM_BASE;
+   gd->ram_top = (ulong)phys_to_virt(CONFIG_SYS_SDRAM_BASE);
 #endif
gd->ram_top += get_effective_memsize();
gd->ram_top = board_get_usable_ram_top(gd->mon_len);
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 17/27] sandbox: Use asm-generic/io.h

2016-10-01 Thread Paul Burton
Convert the sandbox architecture to make use of the new asm-generic/io.h
to provide address mapping functions. As sandbox actually performs
non-identity mapping between physical & virtual addresses we can't
simply make use of the generic mapping functions, but are able to
implement phys_to_virt() & make use of it from map_physmem().

Signed-off-by: Paul Burton 
Cc: Simon Glass 
---

 arch/sandbox/cpu/cpu.c| 12 +++-
 arch/sandbox/include/asm/io.h | 17 -
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 2def722..e160f62 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -55,6 +55,16 @@ int cleanup_before_linux_select(int flags)
return 0;
 }
 
+void *phys_to_virt(phys_addr_t paddr)
+{
+   return (void *)(gd->arch.ram_buf + paddr);
+}
+
+phys_addr_t virt_to_phys(void *vaddr)
+{
+   return (phys_addr_t)(vaddr - gd->arch.ram_buf);
+}
+
 void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
 {
 #if defined(CONFIG_PCI) && !defined(CONFIG_SPL_BUILD)
@@ -72,7 +82,7 @@ void *map_physmem(phys_addr_t paddr, unsigned long len, 
unsigned long flags)
}
 #endif
 
-   return (void *)(gd->arch.ram_buf + paddr);
+   return phys_to_virt(paddr);
 }
 
 void unmap_physmem(const void *vaddr, unsigned long flags)
diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h
index 6919632..3afbcea 100644
--- a/arch/sandbox/include/asm/io.h
+++ b/arch/sandbox/include/asm/io.h
@@ -7,22 +7,20 @@
 #ifndef __SANDBOX_ASM_IO_H
 #define __SANDBOX_ASM_IO_H
 
-/*
- * Given a physical address and a length, return a virtual address
- * that can be used to access the memory range with the caching
- * properties specified by "flags".
- */
-#define MAP_NOCACHE(0)
-#define MAP_WRCOMBINE  (0)
-#define MAP_WRBACK (0)
-#define MAP_WRTHROUGH  (0)
+void *phys_to_virt(phys_addr_t paddr);
+#define phys_to_virt phys_to_virt
+
+phys_addr_t virt_to_phys(void *vaddr);
+#define virt_to_phys virt_to_phys
 
 void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags);
+#define map_physmem map_physmem
 
 /*
  * Take down a mapping set up by map_physmem().
  */
 void unmap_physmem(const void *vaddr, unsigned long flags);
+#define unmap_physmem unmap_physmem
 
 /* For sandbox, we want addresses to point into our RAM buffer */
 static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)
@@ -71,6 +69,7 @@ static inline void _outsw(volatile u16 *port, const void 
*buf, int ns)
 #define out16(addr, val)
 #define in16(addr) 0
 
+#include 
 #include 
 #include 
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 16/27] powerpc: Use asm-generic/io.h

2016-10-01 Thread Paul Burton
Convert the powerpc architecture to make use of the new asm-generic/io.h
to provide address mapping functions. As powerpc can actually perform
non-identity mapping between physical & virtual addresses we can't
simply make use of the generic phys_to_virt() & virt_to_phys()
functions. However since map_physmem() already effectively implemented
the same thing as virt_to_phys() we can simply implement virt_to_phys()
instead of map_physmem() & use the generic map_physmem(). We also drop
the no-op unmap_physmem().

This has only been build-tested, feedback from architecture maintainers
is welcome.

Signed-off-by: Paul Burton 
Cc: Wolfgang Denk 
---

 arch/powerpc/include/asm/io.h | 25 +
 1 file changed, 5 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index a54fc46..34fbfdf 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -282,18 +282,7 @@ static inline void out_be32(volatile unsigned __iomem 
*addr, u32 val)
 #define setbits_8(addr, set) setbits(8, addr, set)
 #define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
 
-/*
- * Given a physical address and a length, return a virtual address
- * that can be used to access the memory range with the caching
- * properties specified by "flags".
- */
-#define MAP_NOCACHE(0)
-#define MAP_WRCOMBINE  (0)
-#define MAP_WRBACK (0)
-#define MAP_WRTHROUGH  (0)
-
-static inline void *
-map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
+static inline void *phys_to_virt(phys_addr_t paddr)
 {
 #ifdef CONFIG_ADDR_MAP
return addrmap_phys_to_virt(paddr);
@@ -301,14 +290,7 @@ map_physmem(phys_addr_t paddr, unsigned long len, unsigned 
long flags)
return (void *)((unsigned long)paddr);
 #endif
 }
-
-/*
- * Take down a mapping set up by map_physmem().
- */
-static inline void unmap_physmem(void *vaddr, unsigned long flags)
-{
-
-}
+#define phys_to_virt phys_to_virt
 
 static inline phys_addr_t virt_to_phys(void * vaddr)
 {
@@ -318,5 +300,8 @@ static inline phys_addr_t virt_to_phys(void * vaddr)
return (phys_addr_t)((unsigned long)vaddr);
 #endif
 }
+#define virt_to_phys virt_to_phys
+
+#include 
 
 #endif
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 15/27] nios2: Use asm-generic/io.h

2016-10-01 Thread Paul Burton
Convert the nios2 architecture to make use of the new asm-generic/io.h to
provide address mapping functions. As nios2 actually performs
non-identity mapping between physical & virtual addresses we can't
simply make use of the generic functions, with the exception of being
able to drop our no-op unmap_physmem() and definitions of unused map
flags.

Feedback from architecture maintainers is welcome.

Signed-off-by: Paul Burton 
Cc: Thomas Chou 
---

 arch/nios2/include/asm/io.h | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/arch/nios2/include/asm/io.h b/arch/nios2/include/asm/io.h
index e951500..4e5b44a 100644
--- a/arch/nios2/include/asm/io.h
+++ b/arch/nios2/include/asm/io.h
@@ -19,9 +19,6 @@ static inline void sync(void)
  * properties specified by "flags".
  */
 #define MAP_NOCACHE1
-#define MAP_WRCOMBINE  0
-#define MAP_WRBACK 0
-#define MAP_WRTHROUGH  0
 
 static inline void *
 map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
@@ -32,20 +29,22 @@ map_physmem(phys_addr_t paddr, unsigned long len, unsigned 
long flags)
else
return (void *)(paddr | gd->arch.mem_region_base);
 }
+#define map_physmem map_physmem
 
-/*
- * Take down a mapping set up by map_physmem().
- */
-static inline void unmap_physmem(void *vaddr, unsigned long flags)
+static inline void *phys_to_virt(phys_addr_t paddr)
 {
+   DECLARE_GLOBAL_DATA_PTR;
 
+   return (void *)(paddr | gd->arch.mem_region_base);
 }
+#define phys_to_virt phys_to_virt
 
 static inline phys_addr_t virt_to_phys(void * vaddr)
 {
DECLARE_GLOBAL_DATA_PTR;
return (phys_addr_t)vaddr & gd->arch.physaddr_mask;
 }
+#define virt_to_phys virt_to_phys
 
 #define __raw_writeb(v,a)   (*(volatile unsigned char  *)(a) = (v))
 #define __raw_writew(v,a)   (*(volatile unsigned short *)(a) = (v))
@@ -171,4 +170,6 @@ static inline void outsl (unsigned long port, const void 
*src, unsigned long cou
 #define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c))
 #define memcpy_toio(a, b, c)   memcpy((void *)(a), (b), (c))
 
+#include 
+
 #endif /* __ASM_NIOS2_IO_H_ */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 14/27] mips: Fix map_physmem for cached mappings

2016-10-01 Thread Paul Burton
map_physmem should return a pointer that can be used by the CPU to
access the given memory - on MIPS simply returning the physical address
as it does prior to this patch doesn't achieve that. Instead return a
pointer to the memory within (c)kseg0, which matches up consistently
with the (c)kseg1 pointer that uncached mappings return via ioremap.

Signed-off-by: Paul Burton 
Cc: Daniel Schwierzeck 
---

 arch/mips/include/asm/io.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index be9616a..45d7ca0 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -500,7 +500,7 @@ map_physmem(phys_addr_t paddr, unsigned long len, unsigned 
long flags)
if (flags == MAP_NOCACHE)
return ioremap(paddr, len);
 
-   return (void *)paddr;
+   return (void *)CKSEG0ADDR(paddr);
 }
 #define map_physmem map_physmem
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 13/27] mips: Use asm-generic/io.h

2016-10-01 Thread Paul Burton
Convert the mips architecture to make use of the new asm-generic/io.h to
provide address mapping functions. As mips actually performs
non-identity mapping between physical & virtual addresses we can't
simply make use of the generic functions, with the exception of being
able to drop our no-op unmap_physmem() and definitions of unused map
flags.

Signed-off-by: Paul Burton 
Cc: Daniel Schwierzeck 
---

 arch/mips/include/asm/io.h | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index 5b86386..be9616a 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -95,6 +95,7 @@ static inline unsigned long virt_to_phys(volatile const void 
*address)
 #endif
return CPHYSADDR(addr);
 }
+#define virt_to_phys virt_to_phys
 
 /*
  * phys_to_virt-   map physical address to virtual
@@ -112,6 +113,7 @@ static inline void *phys_to_virt(unsigned long address)
 {
return (void *)(address + PAGE_OFFSET - PHYS_OFFSET);
 }
+#define phys_to_virt phys_to_virt
 
 /*
  * ISA I/O bus memory addresses are 1:1 with the physical address.
@@ -490,10 +492,7 @@ static inline void memcpy_toio(volatile void __iomem *dst, 
const void *src, int
  */
 #define sync() mmiowb()
 
-#define MAP_NOCACHE(1)
-#define MAP_WRCOMBINE  (0)
-#define MAP_WRBACK (0)
-#define MAP_WRTHROUGH  (0)
+#define MAP_NOCACHE1
 
 static inline void *
 map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
@@ -503,13 +502,7 @@ map_physmem(phys_addr_t paddr, unsigned long len, unsigned 
long flags)
 
return (void *)paddr;
 }
-
-/*
- * Take down a mapping set up by map_physmem().
- */
-static inline void unmap_physmem(void *vaddr, unsigned long flags)
-{
-}
+#define map_physmem map_physmem
 
 #define __BUILD_CLRBITS(bwlq, sfx, end, type)  \
\
@@ -566,4 +559,6 @@ BUILD_CLRSETBITS(q, le64, le64, u64)
 BUILD_CLRSETBITS(q, be64, be64, u64)
 BUILD_CLRSETBITS(q, 64, _, u64)
 
+#include 
+
 #endif /* _ASM_IO_H */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 12/27] xtensa: Use asm-generic/io.h

2016-10-01 Thread Paul Burton
Convert the xtensa architecture to make use of the new asm-generic/io.h
to provide address mapping functions. As the generic implementations are
suitable for xtensa this is primarily a matter of moving code.

This has only been build-tested, feedback from architecture maintainers
is welcome.

Signed-off-by: Paul Burton 
Cc: Max Filippov 
---

 arch/xtensa/include/asm/io.h | 25 ++---
 1 file changed, 2 insertions(+), 23 deletions(-)

diff --git a/arch/xtensa/include/asm/io.h b/arch/xtensa/include/asm/io.h
index e34d6e1..c9e335f 100644
--- a/arch/xtensa/include/asm/io.h
+++ b/arch/xtensa/include/asm/io.h
@@ -115,29 +115,6 @@ void outsl(unsigned long port, const void *src, unsigned 
long count);
  */
 #define xlate_dev_kmem_ptr(p)   p
 
-#define MAP_NOCACHE(0)
-#define MAP_WRCOMBINE  (0)
-#define MAP_WRBACK (0)
-#define MAP_WRTHROUGH  (0)
-
-static inline void *
-map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
-{
-   return (void *)paddr;
-}
-
-/*
- * Take down a mapping set up by map_physmem().
- */
-static inline void unmap_physmem(void *vaddr, unsigned long flags)
-{
-}
-
-static inline phys_addr_t virt_to_phys(void *vaddr)
-{
-   return (phys_addr_t)((unsigned long)vaddr);
-}
-
 /*
  * Dummy function to keep U-Boot's cfi_flash.c driver happy.
  */
@@ -145,4 +122,6 @@ static inline void sync(void)
 {
 }
 
+#include 
+
 #endif /* _XTENSA_IO_H */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 11/27] x86: Use asm-generic/io.h

2016-10-01 Thread Paul Burton
Convert the x86 architecture to make use of the new asm-generic/io.h to
provide address mapping functions. As the generic implementations are
suitable for x86 this is primarily a matter of moving code.

This has only been build-tested, feedback from architecture maintainers
is welcome.

Signed-off-by: Paul Burton 
Cc: Simon Glass 
---

 arch/x86/include/asm/io.h | 31 ++-
 1 file changed, 2 insertions(+), 29 deletions(-)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 3156781..6f29a73 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -289,35 +289,6 @@ static inline void sync(void)
 }
 
 /*
- * Given a physical address and a length, return a virtual address
- * that can be used to access the memory range with the caching
- * properties specified by "flags".
- */
-#define MAP_NOCACHE(0)
-#define MAP_WRCOMBINE  (0)
-#define MAP_WRBACK (0)
-#define MAP_WRTHROUGH  (0)
-
-static inline void *
-map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
-{
-   return (void *)(uintptr_t)paddr;
-}
-
-/*
- * Take down a mapping set up by map_physmem().
- */
-static inline void unmap_physmem(void *vaddr, unsigned long flags)
-{
-
-}
-
-static inline phys_addr_t virt_to_phys(void * vaddr)
-{
-   return (phys_addr_t)(uintptr_t)(vaddr);
-}
-
-/*
  * TODO: The kernel offers some more advanced versions of barriers, it might
  * have some advantages to use them instead of the simple one here.
  */
@@ -325,4 +296,6 @@ static inline phys_addr_t virt_to_phys(void * vaddr)
 #define __iormb()  dmb()
 #define __iowmb()  dmb()
 
+#include 
+
 #endif
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 08/27] openrisc: Use asm-generic/io.h

2016-10-01 Thread Paul Burton
Convert the openrisc architecture to make use of the new
asm-generic/io.h to provide address mapping functions. As the generic
implementations are suitable for openrisc this is primarily a matter of
removing code.

Feedback from architecture maintainers is welcome.

Signed-off-by: Paul Burton 
Cc: Stefan Kristiansson 
---

 arch/openrisc/include/asm/io.h | 35 ++-
 1 file changed, 2 insertions(+), 33 deletions(-)

diff --git a/arch/openrisc/include/asm/io.h b/arch/openrisc/include/asm/io.h
index 86fbbc4..45c41b7 100644
--- a/arch/openrisc/include/asm/io.h
+++ b/arch/openrisc/include/asm/io.h
@@ -8,39 +8,6 @@
 #define __ASM_OPENRISC_IO_H
 
 /*
- * Given a physical address and a length, return a virtual address
- * that can be used to access the memory range with the caching
- * properties specified by "flags".
- */
-#define MAP_NOCACHE(0)
-#define MAP_WRCOMBINE  (0)
-#define MAP_WRBACK (0)
-#define MAP_WRTHROUGH  (0)
-
-static inline void *
-map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
-{
-   return (void *)paddr;
-}
-
-/*
- * Take down a mapping set up by map_physmem().
- */
-static inline void unmap_physmem(void *vaddr, unsigned long flags)
-{
-
-}
-
-/*
- * Change virtual addresses to physical addresses
- */
-static inline phys_addr_t virt_to_phys(void *vaddr)
-{
-   return (phys_addr_t)(vaddr);
-}
-
-
-/*
  * readX/writeX() are used to access memory mapped devices. On some
  * architectures the memory mapped IO stuff needs to be accessed
  * differently. On the openrisc architecture, we just read/write the
@@ -96,4 +63,6 @@ static inline phys_addr_t virt_to_phys(void *vaddr)
 #define iowrite16(v, addr) writew((v), (addr))
 #define iowrite32(v, addr) writel((v), (addr))
 
+#include 
+
 #endif
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 09/27] sh: Use asm-generic/io.h

2016-10-01 Thread Paul Burton
Convert the sh architecture to make use of the new asm-generic/io.h to
provide address mapping functions. As the generic implementations are
suitable for sh this is primarily a matter of moving code.

Feedback from architecture maintainers is welcome.

Signed-off-by: Paul Burton 
Cc: Nobuhiro Iwamatsu 
---

 arch/sh/include/asm/io.h | 29 +
 1 file changed, 1 insertion(+), 28 deletions(-)

diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h
index 5dc27be..2847d8d 100644
--- a/arch/sh/include/asm/io.h
+++ b/arch/sh/include/asm/io.h
@@ -241,34 +241,7 @@ static inline void sync(void)
 #define setbits_8(addr, set) setbits(8, addr, set)
 #define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
 
-/*
- * Given a physical address and a length, return a virtual address
- * that can be used to access the memory range with the caching
- * properties specified by "flags".
- */
-#define MAP_NOCACHE (0)
-#define MAP_WRCOMBINE   (0)
-#define MAP_WRBACK  (0)
-#define MAP_WRTHROUGH   (0)
-
-static inline void *
-map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
-{
-   return (void *)paddr;
-}
-
-/*
- * Take down a mapping set up by map_physmem().
- */
-static inline void unmap_physmem(void *vaddr, unsigned long flags)
-{
-
-}
-
-static inline phys_addr_t virt_to_phys(void *vaddr)
-{
-   return (phys_addr_t)(vaddr);
-}
+#include 
 
 #endif /* __KERNEL__ */
 #endif /* __ASM_SH_IO_H */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 10/27] sparc: Use asm-generic/io.h

2016-10-01 Thread Paul Burton
Convert the sparc architecture to make use of the new asm-generic/io.h
to provide address mapping functions. As the generic implementations are
suitable for sparc this is primarily a matter of moving code.

Feedback from architecture maintainers is welcome.

Signed-off-by: Paul Burton 
---

 arch/sparc/include/asm/io.h | 30 +-
 1 file changed, 1 insertion(+), 29 deletions(-)

diff --git a/arch/sparc/include/asm/io.h b/arch/sparc/include/asm/io.h
index a317d13..08ec7d5 100644
--- a/arch/sparc/include/asm/io.h
+++ b/arch/sparc/include/asm/io.h
@@ -63,34 +63,6 @@
 #define readl  __raw_readl
 #define readq  __raw_readq
 
-/*
- * Given a physical address and a length, return a virtual address
- * that can be used to access the memory range with the caching
- * properties specified by "flags".
- */
-
-#define MAP_NOCACHE(0)
-#define MAP_WRCOMBINE  (0)
-#define MAP_WRBACK (0)
-#define MAP_WRTHROUGH  (0)
-
-static inline void *map_physmem(phys_addr_t paddr, unsigned long len,
-   unsigned long flags)
-{
-   return (void *)paddr;
-}
-
-/*
- * Take down a mapping set up by map_physmem().
- */
-static inline void unmap_physmem(void *vaddr, unsigned long flags)
-{
-
-}
-
-static inline phys_addr_t virt_to_phys(void * vaddr)
-{
-   return (phys_addr_t)(vaddr);
-}
+#include 
 
 #endif
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 07/27] nds32: Use asm-generic/io.h

2016-10-01 Thread Paul Burton
Convert the nds32 architecture to make use of the new asm-generic/io.h
to provide address mapping functions. As the generic implementations are
suitable for nds32 this is primarily a matter of removing code.

Feedback from architecture maintainers is welcome.

Signed-off-by: Paul Burton 
Cc: Macpaul Lin 
---

 arch/nds32/include/asm/io.h | 32 +++-
 1 file changed, 3 insertions(+), 29 deletions(-)

diff --git a/arch/nds32/include/asm/io.h b/arch/nds32/include/asm/io.h
index b2c4d0e..46ce8c4 100644
--- a/arch/nds32/include/asm/io.h
+++ b/arch/nds32/include/asm/io.h
@@ -39,35 +39,6 @@ static inline void sync(void)
 }
 
 /*
- * Given a physical address and a length, return a virtual address
- * that can be used to access the memory range with the caching
- * properties specified by "flags".
- */
-#define MAP_NOCACHE(0)
-#define MAP_WRCOMBINE  (0)
-#define MAP_WRBACK (0)
-#define MAP_WRTHROUGH  (0)
-
-static inline void *
-map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
-{
-   return (void *)paddr;
-}
-
-/*
- * Take down a mapping set up by map_physmem().
- */
-static inline void unmap_physmem(void *vaddr, unsigned long flags)
-{
-
-}
-
-static inline phys_addr_t virt_to_phys(void *vaddr)
-{
-   return (phys_addr_t)(vaddr);
-}
-
-/*
  * Generic virtual read/write.  Note that we don't support half-word
  * read/writes.  We define __arch_*[bl] here, and leave __arch_*w
  * to the architecture specific code.
@@ -459,5 +430,8 @@ out:
 #define isa_check_signature(io, sig, len)  (0)
 
 #endif /* __mem_isa */
+
+#include 
+
 #endif /* __KERNEL__ */
 #endif /* __ASM_NDS_IO_H */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 06/27] microblaze: Use asm-generic/io.h

2016-10-01 Thread Paul Burton
Convert the microblaze architecture to make use of the new
asm-generic/io.h to provide address mapping functions. As the generic
implementations are suitable for microblaze this is primarily a matter
of removing code.

Feedback from architecture maintainers is welcome.

Signed-off-by: Paul Burton 
Cc: Michal Simek 
---

 arch/microblaze/include/asm/io.h | 29 +
 1 file changed, 1 insertion(+), 28 deletions(-)

diff --git a/arch/microblaze/include/asm/io.h b/arch/microblaze/include/asm/io.h
index 584cbce..c7516a4 100644
--- a/arch/microblaze/include/asm/io.h
+++ b/arch/microblaze/include/asm/io.h
@@ -131,33 +131,6 @@ static inline void sync(void)
 {
 }
 
-/*
- * Given a physical address and a length, return a virtual address
- * that can be used to access the memory range with the caching
- * properties specified by "flags".
- */
-#define MAP_NOCACHE(0)
-#define MAP_WRCOMBINE  (0)
-#define MAP_WRBACK (0)
-#define MAP_WRTHROUGH  (0)
-
-static inline void *
-map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
-{
-   return (void *)paddr;
-}
-
-/*
- * Take down a mapping set up by map_physmem().
- */
-static inline void unmap_physmem(void *vaddr, unsigned long flags)
-{
-
-}
-
-static inline phys_addr_t virt_to_phys(void * vaddr)
-{
-   return (phys_addr_t)(vaddr);
-}
+#include 
 
 #endif /* __MICROBLAZE_IO_H__ */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 04/27] blackfin: Use asm-generic/io.h

2016-10-01 Thread Paul Burton
Convert the blackfin architecture to make use of the new
asm-generic/io.h to provide address mapping functions. As the generic
implementations are suitable for blackfin this is primarily a matter of
removing code.

Feedback from architecture maintainers is welcome.

Signed-off-by: Paul Burton 
Cc: Sonic Zhang 
---

 arch/blackfin/include/asm/io.h | 31 ++-
 1 file changed, 2 insertions(+), 29 deletions(-)

diff --git a/arch/blackfin/include/asm/io.h b/arch/blackfin/include/asm/io.h
index d3337e4..dad8ac6 100644
--- a/arch/blackfin/include/asm/io.h
+++ b/arch/blackfin/include/asm/io.h
@@ -20,35 +20,6 @@ static inline void sync(void)
 }
 
 /*
- * Given a physical address and a length, return a virtual address
- * that can be used to access the memory range with the caching
- * properties specified by "flags".
- */
-#define MAP_NOCACHE(0)
-#define MAP_WRCOMBINE  (0)
-#define MAP_WRBACK (0)
-#define MAP_WRTHROUGH  (0)
-
-static inline void *
-map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
-{
-   return (void *)paddr;
-}
-
-/*
- * Take down a mapping set up by map_physmem().
- */
-static inline void unmap_physmem(void *vaddr, unsigned long flags)
-{
-
-}
-
-static inline phys_addr_t virt_to_phys(void * vaddr)
-{
-   return (phys_addr_t)(vaddr);
-}
-
-/*
  * These are for ISA/PCI shared memory _only_ and should never be used
  * on any other type of memory, including Zorro memory. They are meant to
  * access the bus in the bus byte order which is little-endian!.
@@ -223,6 +194,8 @@ extern void cf_outb(unsigned char val, volatile unsigned 
char *addr);
 
 #endif
 
+#include 
+
 #endif /* __KERNEL__ */
 
 #endif
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 05/27] m68k: Use asm-generic/io.h

2016-10-01 Thread Paul Burton
Convert the m68k architecture to make use of the new asm-generic/io.h to
provide address mapping functions. As the generic implementations are
suitable for m68k this is primarily a matter of emoving code.

Feedback from architecture maintainers is welcome.

Signed-off-by: Paul Burton 
Cc: Huan Wang 
Cc: Angelo Dureghello 
---

 arch/m68k/include/asm/io.h | 29 +
 1 file changed, 1 insertion(+), 28 deletions(-)

diff --git a/arch/m68k/include/asm/io.h b/arch/m68k/include/asm/io.h
index 384308b..dfe77f0 100644
--- a/arch/m68k/include/asm/io.h
+++ b/arch/m68k/include/asm/io.h
@@ -253,33 +253,6 @@ static inline void sync(void)
 */
 }
 
-/*
- * Given a physical address and a length, return a virtual address
- * that can be used to access the memory range with the caching
- * properties specified by "flags".
- */
-#define MAP_NOCACHE(0)
-#define MAP_WRCOMBINE  (0)
-#define MAP_WRBACK (0)
-#define MAP_WRTHROUGH  (0)
-
-static inline void *map_physmem(phys_addr_t paddr, unsigned long len,
-   unsigned long flags)
-{
-   return (void *)paddr;
-}
-
-/*
- * Take down a mapping set up by map_physmem().
- */
-static inline void unmap_physmem(void *vaddr, unsigned long flags)
-{
-
-}
-
-static inline phys_addr_t virt_to_phys(void * vaddr)
-{
-   return (phys_addr_t)(vaddr);
-}
+#include 
 
 #endif /* __ASM_M68K_IO_H__ */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 03/27] arm: Use asm-generic/io.h

2016-10-01 Thread Paul Burton
Convert the arm architecture to make use of the new asm-generic/io.h to
provide address mapping functions. As the generic implementations are
suitable for arm this is primarily a matter of removing code.

This has only been build-tested, feedback from architecture maintainers
is welcome.

Signed-off-by: Paul Burton 
Cc: Albert Aribaud 
---

 arch/arm/include/asm/io.h | 30 +-
 1 file changed, 1 insertion(+), 29 deletions(-)

diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 5834f5b..5df7472 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -35,35 +35,6 @@ static inline void sync(void)
 }
 
 /*
- * Given a physical address and a length, return a virtual address
- * that can be used to access the memory range with the caching
- * properties specified by "flags".
- */
-#define MAP_NOCACHE(0)
-#define MAP_WRCOMBINE  (0)
-#define MAP_WRBACK (0)
-#define MAP_WRTHROUGH  (0)
-
-static inline void *
-map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
-{
-   return (void *)((unsigned long)paddr);
-}
-
-/*
- * Take down a mapping set up by map_physmem().
- */
-static inline void unmap_physmem(void *vaddr, unsigned long flags)
-{
-
-}
-
-static inline phys_addr_t virt_to_phys(void * vaddr)
-{
-   return (phys_addr_t)((unsigned long)vaddr);
-}
-
-/*
  * Generic virtual read/write.  Note that we don't support half-word
  * read/writes.  We define __arch_*[bl] here, and leave __arch_*w
  * to the architecture specific code.
@@ -426,6 +397,7 @@ out:
 #endif /* __mem_isa */
 #endif /* __KERNEL__ */
 
+#include 
 #include 
 
 #endif /* __ASM_ARM_IO_H */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 02/27] arc: Use asm-generic/io.h

2016-10-01 Thread Paul Burton
Convert the arc architecture to make use of the new asm-generic/io.h to
provide address mapping functions. As the generic implementations are
suitable for arc this is primarily a matter of removing code.

Feedback from architecture maintainers is welcome.

Signed-off-by: Paul Burton 
Cc: Alexey Brodkin 
---

 arch/arc/include/asm/io.h | 29 +
 1 file changed, 1 insertion(+), 28 deletions(-)

diff --git a/arch/arc/include/asm/io.h b/arch/arc/include/asm/io.h
index 42e7f22..a12303b 100644
--- a/arch/arc/include/asm/io.h
+++ b/arch/arc/include/asm/io.h
@@ -50,30 +50,6 @@
 #define __iowmb()  do { } while (0)
 #endif
 
-/*
- * Given a physical address and a length, return a virtual address
- * that can be used to access the memory range with the caching
- * properties specified by "flags".
- */
-#define MAP_NOCACHE(0)
-#define MAP_WRCOMBINE  (0)
-#define MAP_WRBACK (0)
-#define MAP_WRTHROUGH  (0)
-
-static inline void *
-map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
-{
-   return (void *)((unsigned long)paddr);
-}
-
-/*
- * Take down a mapping set up by map_physmem().
- */
-static inline void unmap_physmem(void *vaddr, unsigned long flags)
-{
-
-}
-
 static inline void sync(void)
 {
/* Not yet implemented */
@@ -302,9 +278,6 @@ static inline int __raw_writesl(unsigned int addr, void 
*data, int longlen)
 #define setbits_8(addr, set) setbits(8, addr, set)
 #define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
 
-static inline phys_addr_t virt_to_phys(void *vaddr)
-{
-   return (phys_addr_t)((unsigned long)vaddr);
-}
+#include 
 
 #endif /* __ASM_ARC_IO_H */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 00/27] Clean up address mapping functions & CONFIG_SYS_SDRAM_BASE

2016-10-01 Thread Paul Burton
README states that CONFIG_SYS_SDRAM_BASE should be the physical address
of the base of SDRAM memory. This is expected by some code such as the
PCI layer, which uses CONFIG_SYS_SDRAM_BASE to set up a region for
system memory. Other code such as the image loading code used by bootm
or the generic board_f.c expect CONFIG_SYS_SDRAM_BASE to be directly
accessible by the CPU, which necessitates that it be a virtual address.

Where virtual & physical addresses aren't identity mapped, as is the
case for MIPS, we cannot possibly satisfy both. Until now MIPS has used
a virtual CONFIG_SYS_SDRAM_BASE. This series fixes up the mess by doing
a few things:

  - Ensuring that we provide virt_to_phys() on all architectures.

  - Fixing code that expects to use CONFIG_SYS_SDRAM_BASE as a virtual
address to instead convert it to a physical address using
virt_to_phys().

  - Converts MIPS code & all MIPS boards to provide a physical
CONFIG_SYS_SDRAM_BASE, which typically is zero.


Paul Burton (27):
  Provide a generic io.h & address mapping functions
  arc: Use asm-generic/io.h
  arm: Use asm-generic/io.h
  blackfin: Use asm-generic/io.h
  m68k: Use asm-generic/io.h
  microblaze: Use asm-generic/io.h
  nds32: Use asm-generic/io.h
  openrisc: Use asm-generic/io.h
  sh: Use asm-generic/io.h
  sparc: Use asm-generic/io.h
  x86: Use asm-generic/io.h
  xtensa: Use asm-generic/io.h
  mips: Use asm-generic/io.h
  mips: Fix map_physmem for cached mappings
  nios2: Use asm-generic/io.h
  powerpc: Use asm-generic/io.h
  sandbox: Use asm-generic/io.h
  board_f: Account for CONFIG_SYS_SDRAM_BASE being physical
  image: Account for CONFIG_SYS_SDRAM_BASE being physical
  image: Use ram_top, not bi_memsize, in getenv_bootm_size
  mips: Use ram_top, not bi_memsize, in arch_lmb_reserve
  mips: Ensure stack is at a virtual address
  boston: Provide physical CONFIG_SYS_SDRAM_BASE
  malta: Use a physical CONFIG_SYS_SDRAM_BASE
  xilfpga: Use a physical CONFIG_SYS_SDRAM_BASE
  mips: Use a physical CONFIG_SYS_SDRAM_BASE for remaining boards
  mips: Remove virt_to_phys call on bi_memstart

 arch/arc/include/asm/io.h|  29 +--
 arch/arm/include/asm/io.h|  30 +--
 arch/blackfin/include/asm/io.h   |  31 +--
 arch/m68k/include/asm/io.h   |  29 +--
 arch/microblaze/include/asm/io.h |  29 +--
 arch/mips/cpu/start.S|   3 +-
 arch/mips/include/asm/io.h   |  19 +++
 arch/mips/lib/bootm.c|   4 +-
 arch/nds32/include/asm/io.h  |  32 ++--
 arch/nios2/include/asm/io.h  |  15 +++---
 arch/openrisc/include/asm/io.h   |  35 +
 arch/powerpc/include/asm/io.h|  25 ++---
 arch/sandbox/cpu/cpu.c   |  12 -
 arch/sandbox/include/asm/io.h|  17 +++---
 arch/sh/include/asm/io.h |  29 +--
 arch/sparc/include/asm/io.h  |  30 +--
 arch/x86/include/asm/io.h|  31 +--
 arch/xtensa/include/asm/io.h |  25 +
 board/imgtec/boston/ddr.c|   8 +--
 common/board_f.c |   4 +-
 common/image.c   |   6 +--
 include/asm-generic/io.h | 110 +++
 include/configs/ap121.h  |   2 +-
 include/configs/ap143.h  |   2 +-
 include/configs/boston.h |  21 
 include/configs/dbau1x00.h   |   2 +-
 include/configs/imgtec_xilfpga.h |   4 +-
 include/configs/malta.h  |  18 ---
 include/configs/pb1x00.h |   2 +-
 include/configs/pic32mzdask.h|   2 +-
 include/configs/qemu-mips.h  |   2 +-
 include/configs/qemu-mips64.h|   2 +-
 include/configs/tplink_wdr4300.h |   2 +-
 include/configs/vct.h|   2 +-
 34 files changed, 208 insertions(+), 406 deletions(-)
 create mode 100644 include/asm-generic/io.h

-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 01/27] Provide a generic io.h & address mapping functions

2016-10-01 Thread Paul Burton
Most architectures currently supported by U-Boot use trivial
implementations of map_to_physmem & virt_to_phys which simply cast a
physical address to a pointer for use a virtual address & vice-versa.
This results in a lot of duplicate implementations of these mapping
functions.

The functions provided by different architectures also differs, with
some having implementations of phys_to_virt & others not. A later patch
in this series will make use of phys_to_virt, so requires that it be
provided for all architectures.

This patch introduces an asm-generic/io.h which provides generic
implementations of address mapping functions, allowing the duplication
of them between architectures to be removed. Once architectures are
converted to make use of this generic header it will also ensure that
all of phys_to_virt, virt_to_phys, map_physmem & unmap_physmem are
provided. The 2 families of functions differ in that map_physmem may
create dynamic mappings whilst phys_to_virt may not & therefore is more
limited in scope but doesn't require information such as a length &
flags.

This patch doesn't convert any architectures to make use of this generic
header - later patches in the series will do so.

Signed-off-by: Paul Burton 
Cc: Albert Aribaud 
Cc: Alexey Brodkin 
Cc: Alison Wang 
Cc: Angelo Dureghello 
Cc: Bin Meng 
Cc: Daniel Schwierzeck 
Cc: Francois Retief 
Cc: Macpaul Lin 
Cc: Michal Simek 
Cc: Mike Frysinger 
Cc: Nobuhiro Iwamatsu 
Cc: Scott McNutt 
Cc: Sonic Zhang 
Cc: Thomas Chou 
Cc: Wolfgang Denk 
---

 include/asm-generic/io.h | 110 +++
 1 file changed, 110 insertions(+)
 create mode 100644 include/asm-generic/io.h

diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
new file mode 100644
index 000..dd3a46d
--- /dev/null
+++ b/include/asm-generic/io.h
@@ -0,0 +1,110 @@
+/*
+ * Generic I/O functions.
+ *
+ * Copyright (c) 2016 Imagination Technologies Ltd.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef __ASM_GENERIC_IO_H__
+#define __ASM_GENERIC_IO_H__
+
+/*
+ * This file should be included at the end of each architecture-specific
+ * asm/io.h such that we may provide generic implementations without
+ * conflicting with architecture-specific code.
+ */
+
+#ifndef __ASSEMBLY__
+
+/**
+ * phys_to_virt() - Return a virtual address mapped to a given physical address
+ * @paddr: the physical address
+ *
+ * Returns a virtual address which the CPU can access that maps to the physical
+ * address @paddr. This should only be used where it is known that no dynamic
+ * mapping is required. In general, map_physmem should be used instead.
+ *
+ * Returns: a virtual address which maps to @paddr
+ */
+#ifndef phys_to_virt
+static inline void *phys_to_virt(phys_addr_t paddr)
+{
+   return (void *)(unsigned long)paddr;
+}
+#endif
+
+/**
+ * virt_to_phys() - Return the physical address that a virtual address maps to
+ * @vaddr: the virtual address
+ *
+ * Returns the physical address which the CPU-accessible virtual address @vaddr
+ * maps to.
+ *
+ * Returns: the physical address which @vaddr maps to
+ */
+#ifndef virt_to_phys
+static inline phys_addr_t virt_to_phys(void *vaddr)
+{
+   return (phys_addr_t)((unsigned long)vaddr);
+}
+#endif
+
+/*
+ * Flags for use with map_physmem() & unmap_physmem(). Architectures need not
+ * support all of these, in which case they will be defined as zero here &
+ * ignored. Callers that may run on multiple architectures should therefore
+ * treat them as hints rather than requirements.
+ */
+#ifndef MAP_NOCACHE
+# define MAP_NOCACHE   0   /* Produce an uncached mapping */
+#endif
+#ifndef MAP_WRCOMBINE
+# define MAP_WRCOMBINE 0   /* Allow write-combining on the mapping */
+#endif
+#ifndef MAP_WRBACK
+# define MAP_WRBACK0   /* Map using write-back caching */
+#endif
+#ifndef MAP_WRTHROUGH
+# define MAP_WRTHROUGH 0   /* Map using write-through caching */
+#endif
+
+/**
+ * map_physmem() - Return a virtual address mapped to a given physical address
+ * @paddr: the physical address
+ * @len: the length of the required mapping
+ * @flags: flags affecting the type of mapping
+ *
+ * Return a virtual address through which the CPU may access the memory at
+ * physical address @paddr. The mapping will be valid for at least @len bytes,
+ * and may be affected by flags passed to the @flags argument. This function
+ * may create new mappings, so should generally be paired with a matching call
+ * to unmap_physmem once the caller is finished with the memory in question.
+ *
+ * Returns: a virtual address suitably mapped to @paddr
+ */
+#ifndef 

Re: [U-Boot] [PATCH v3 03/29] Convert CONSOLE_PRE_CONSOLE_BUFFER options to Kconfig

2016-10-01 Thread Soeren Moch

>> > Hello Simon,
>> > 
>> > On Thu, 29 Sep 2016 14:23:02 -0600
>> > Simon Glass  wrote:
>> > 
>>> > > Move these option to Kconfig and tidy up existing uses.
>>> > > 
>>> > > Signed-off-by: Simon Glass 
>>> > > ---
>>> > > 
>>> > > Changes in v3: None
>>> > > Changes in v2:
>>> > > - Change CONFIG_PRE_CON_BUF_SZ default to 4096
>>> > > - Change CONFIG_PRE_CON_BUF_SZ to 'int' type
>>> > > - Drop the depend clause on the CONFIG_PRE_CON_BUF_SZ default
>>> > > - Move CONFIG_PRE_CON_BUF_ADDR default to common/Kconfig
>> > 
>> > What is the point moving these defines to Kconfig? They are neither
>> > user configurable, nor board specific. The location of the buffer is
>> > defined per platform or per SoC type and is a part of the global memory
>> > map. Similar to such things as the malloc heap and the stack.
> This is a good point to bring up.  As we're discussing in another thread
> about moving FSL things out of CONFIG_SYS_... and into Kconfig or a
> different namespace, we have other examples today where there's
> addresses in Kconfig.  Looking harder still at this code, perhaps as a
> follow-up CONFIG_PRE_CON_BUF_SZ should just be 'PRE_CON_BUF_SIZE' in the
> code and 4096, and not in Kconfig at all.  And for this series, make the
> default tbs2910 uses the default for ARCH_MX6.
I don't think that my arbitrarily chosen PRE_CON_BUF_ADDR for tbs2910
(0x7C00) is a good default for ARCH_MX6. On tbs2910 we have 2GB of
DDR memory, there are lots of other imx6 boards with less memory available.
So a lower PRE_CON_BUF_ADDR (as for sunxi) might be a better choice.

The only constraint for this buffer (besides being located in DDR) is,
that it must not overlap with u-boot text and data.
As I understand it, this buffer is only used very early in the boot process
and not needed anymore, when the vga console is set up. So this buffer can
not interfere with user commands (even pre-boot commands).
> > Allowing the users to redefine the buffer location is a dangerous thing
> > because everything may go out of control very easily (it may overlap
> > with some other memory buffer). IMHO it only makes sense to have a
> > single user configurable boolean flag in Kconfig (the one which
> > enables/disables the pre-console functionality).
> > 
> > Regarding the buffer size. It was originally picked rather arbitrarily
> > as 1MB at least for the sunxi platform:
> > 
> > https://patchwork.ozlabs.org/patch/426526/
> > 
> > Just because making it several orders of magnitude larger than
> > necessary makes it extremely unlikely that anyone ever gets into
> > a buffer wraparound situation. Picking smallish sizes does not gain
> > us anything, but just adds an extra hassle because now one needs to
> > make some estimations whether the size is large enough or not.
> > Especially considering that this functionality may be sometimes
> > used for debugging prints when troubleshooting something. And one
> > can't easily predict how much debugging output would be actually
> > necessary.
> So maybe we should hide the size option under EXPERT?
Just curious, can this address be generated automatically, e.g. just below
the malloc area? Or is this too complicated, e.g. because the buffer is
used already before relocation?

However, if this address is configurable in Kconfig at all, for me it makes
sense to hide it somehow.

I can test other PRE_CON_BUF_ADDR settings on tbs2910 if this would help
to find more general default values.

Regards,
Soeren

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Uboot send pull request

2016-10-01 Thread Tom Rini
On Thu, Sep 29, 2016 at 04:22:45PM +0800, ub...@andestech.com wrote:

>  Hi Tom,
> 
>  Please pull the following patch from u-boot-nds32 into your tree.
>  Thanks!
> 
> The following changes since commit 06572f0301c18e63b887efc91803bb9467e55dbe:
> 
>   Merge git://www.denx.de/git/u-boot-ppc4xx (2016-09-27 12:48:18 -0400)
> 
> are available in the git repository at:
> 
> 
>   git://git.denx.de/u-boot-nds32.git master
> 
> for you to fetch changes up to d607f6fa99a67dd1b40c08ba21ca6f3aaff933ce:
> 
>   nds32: Support relocation. (2016-09-29 15:38:10 +0800)
> 

Applied to u-boot/master, thanks!


-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Please pull u-boot-85xx master

2016-10-01 Thread Tom Rini
On Wed, Sep 28, 2016 at 05:49:26PM +, york sun wrote:

> Tom,
> 
> The following changes since commit 06572f0301c18e63b887efc91803bb9467e55dbe:
> 
>Merge git://www.denx.de/git/u-boot-ppc4xx (2016-09-27 12:48:18 -0400)
> 
> are available in the git repository at:
> 
>git://git.denx.de/u-boot-mpc85xx.git
> 
> for you to fetch changes up to f413d1cae89143ad45b066b3d3bc602deafcb50a:
> 
>mpc85xx: powerpc: usb: Update the list of Socs afftected by erratum 
> A006261 (2016-09-28 09:08:16 -0700)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PULL] u-boot-usb/master

2016-10-01 Thread Tom Rini
On Wed, Sep 28, 2016 at 07:53:52PM +0200, Marek Vasut wrote:

> The following changes since commit cbe7706ab8aab06c18edaa9b120371f9c8012728:
> 
>   Merge git://git.denx.de/u-boot-fsl-qoriq (2016-09-26 17:10:56 -0400)
> 
> are available in the git repository at:
> 
>   git://git.denx.de/u-boot-usb.git master
> 
> for you to fetch changes up to 4c043712e9910ef1d612aedbd8304a1f7348ef5f:
> 
>   drivers: usb: xhci-fsl: Implement Erratum A-010151 for FSL USB3
> controller (2016-09-27 23:30:49 +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] is there any issue with creating and using more than one hashtable?

2016-10-01 Thread Wolfgang Denk
Dear Robert,

In message  you wrote:
>
> > 244 /* If there is a callback, call it */
> > 245 if (htab->table[idx].entry.callback &&
> > 246 htab->table[idx].entry.callback(item.key,
...

>   just to follow up, the simple solution for me would be to *not*
> create that second hashtable with recognized u-boot variable names
> like "ipaddr", "gatewayip", "serverip" unless i absolutely plan on
> using those new values.

Well, I guess you don't need the callback funtionality for your
purposes, and you will probably not pull the data from the second
hash table back into the primary one, so why can you not just clear
the "callback" for any entries you process?

That would suppress the unwanted actions...

>   this is what i use to add/modify a new env variable -- is this the
> correct approach, to add it to the "env_htab" hashtable?
> 
>   int
>   add_entry_to_env(ENTRY* e)
>   {
> ENTRY*  ep;
> 
> printf("Adding stuff k: [%s], d: [%s] to env.\n", e->key, e->data);

Insert:

e->callback = NULL;

here?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Carelessly planned projects take three times longer to complete  than
expected.  Carefully  planned  projects  take  four  times  longer to
complete than expected, mostly  because  the  planners  expect  their
planning to reduce the time it takes.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] is there any issue with creating and using more than one hashtable?

2016-10-01 Thread Robert P. J. Day
On Sat, 1 Oct 2016, Wolfgang Denk wrote:

> Dear Robert,

... snip ...

> Actually the TFTP will not access the environment directly to
> determine the boot parameters like bootfile, ipaddr, gatewayip,
> netmask, serverip, etc.; instead, it uses internal variables.  So
> your environment settings for "ipaddr" and "gatewayip" may contain
> totally different values than the variables net_ip resp.
> net_gateway which get used by the TFTP code.
>
> These variables get set through the U_BOOT_ENV_CALLBACK functionality,
> i. e. as a callback whenever the corresponfing variable gets set.
> "setting" here means that the value in the hash table gets changed -
> see function _compare_and_overwrite_entry() in "hashtable.c":
>
> 244 /* If there is a callback, call it */
> 245 if (htab->table[idx].entry.callback &&
> 246 htab->table[idx].entry.callback(item.key,
> 247 item.data, env_op_overwrite, flag)) {
> 248 debug("callback() rejected setting 
> variable "
> 249 "%s, skipping it!\n", item.key);
> 250 __set_errno(EINVAL);
> 251 *retval = NULL;
> 252 return 0;
> 253 }
>
>
> So when you insert variable sof these registered names into your
> alternative hash table using the common code, then the respective
> callbacks will fire in the same way as if you had changed the
> environment settings through a setenv command.

  just to follow up, the simple solution for me would be to *not*
create that second hashtable with recognized u-boot variable names
like "ipaddr", "gatewayip", "serverip" unless i absolutely plan on
using those new values.

  an even simpler solution would be to skip the second hashtable
creation altogether, walk through my first hashtable (which should
have no conflicting variable names), and in one step, translate those
names and add them to the current environment.

  this is what i use to add/modify a new env variable -- is this the
correct approach, to add it to the "env_htab" hashtable?

  int
  add_entry_to_env(ENTRY* e)
  {
ENTRY*  ep;

printf("Adding stuff k: [%s], d: [%s] to env.\n", e->key, e->data);
hsearch_r(*e, ENTER, , _htab, 0);

return 0;
  }

if that's the way to do it, i'll just do away with the second
hashtable and avoid the issue altogether.

rday

-- 


Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca

Twitter:   http://twitter.com/rpjday
LinkedIn:   http://ca.linkedin.com/in/rpjday


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] is there any issue with creating and using more than one hashtable?

2016-10-01 Thread Robert P. J. Day
On Sat, 1 Oct 2016, Wolfgang Denk wrote:

> Dear Robert,
>
> In message  you 
> wrote:
> >
> >   in misc_init_r(), i create a new hashtable to just grab the
> > contents of that bootline as is. i then create a *second*
> > hashtable and selectively move over just those keys i want from
> > the first hashtable, possibly renaming them in the process.
>
> I'm not sure how you implemented this "move over" thing...

  oh, nothing fancy, it's manual ... if i find an initial string of
"g=a.b.c.d", i translate that to the u-boot required "gatewayip"
variable name, and add that to the second hashtable. here's a snippet
of the routine that populates the second hash table given an ENTRY
corresponding to an original "var=value" -- you can see that it just
checks possible initial keys, and writes the transformed value to the
second table -- pure brute force, and it seems to work just fine:

populate_htab_2(ENTRY* e)
{
const char* k = e->key;
ENTRY*  entry_ptr;

if (!strcmp(k, "h")) {
ENTRY he = {
.key = "serverip",
.data = e->data
};
printf("found h, translating to serverip.\n");
hsearch_r(he, ENTER, _ptr, _htab_2, 0);
}

if (!strcmp(k, "g")) {
ENTRY ge = {
.key = "gatewayip",
.data = e->data
};
printf("found g, translating to gatewayip.\n");
hsearch_r(ge, ENTER, _ptr, _htab_2, 0);
}

... snip ...

> > now here's the thing ... after all that, i manually check whether
> > the CRC for the env table in persistent storage is valid and, if
> > it is, i do *nothing* with all that hashtable content -- that was
> > all wasted cycles, but it should not do any harm.
> >
> >   but it does, because this is what happens:
> >
> >   TFTP from server 10.35.5.37; our IP address is 192.168.1.2; sending
> >   through gateway 192.168.1.1
> >
> > the server address is correct, but the IP address and gateway are
> > totally wrong -- they should have been untouched and been completely
> > different values; instead, they now equal the values in that second
> > hashtable, which i chose to do nothing with.

  one thing i want to emphasize about the above -- the example i was
working with pulled out and transformed just the ip address and
gateway loading them into the second hashtable, and those are the
values that are now "incorrect." there was no server setting in that
original data, hence "serverip" was not loaded into the second
hashtable, so it's fine. it seems that only u-boot variables i put in
the second hashtable somehow "bleed" into my working environment,
whatever that might mean.

> For a test, I would like to ask you to run the following commands
> before the TFTP command:
>
>   printenv serverip;setenv serverip ${serverip};printenv serverip
>   printenv ipaddr;setenv ipaddr ${ipaddr};printenv ipaddr
>   printenv gatewayip;setenv gatewayip ${gatewayip};printenv gatewayip
>
> Does this change anything?

  i'll have to wait until later to try this, but i'm pretty sure i
tried the above yesterday, and everything looked fine ... i would
"print" the variables, they seemed fine, i'd "env save", i'd reset,
check again, all looked good, and yet ... same problem.

  wait, maybe i didn't explicitlt "setenv" in the middle, because it
didn't seem necessary. that might be something i didn't test.

> >   is there some weird issue with re-entrancy here? if i print "ipaddr"
> > and "gatewayip", they seem correct. if i "md" the environment in
> > persistent storage, again, they seem correct. and yet, when TFTP kicks
> > in, it seems to pick up the values from that hashtable.
>
> Actually the TFTP will not access the environment directly to
> determine the boot parameters like bootfile, ipaddr, gatewayip,
> netmask, serverip, etc.; instead, it uses internal variables.  So
> your environment settings for "ipaddr" and "gatewayip" may contain
> totally different values than the variables net_ip resp.
> net_gateway which get used by the TFTP code.

  ah ... would this also apply to other net-related commands like
ping? because, weirdly, even ping doesn't seem to work, unable to ping
even its own gateway, but if that command is *also* quietly picking up
the incorrect "gatewayip" setting from that second hashtable, that
would also explain its failure.

> These variables get set through the U_BOOT_ENV_CALLBACK
> functionality, i. e. as a callback whenever the corresponding
> variable gets set. "setting" here means that the value in the hash
> table gets changed - see function _compare_and_overwrite_entry() in
> "hashtable.c":
>
> 244 /* If there is a callback, call it */
> 245 if (htab->table[idx].entry.callback &&
> 246 

Re: [U-Boot] x86: Booting Linux v4.7+ broken

2016-10-01 Thread Stefan Roese

On 01.10.2016 05:52, Yinghai Lu wrote:

On Tue, Sep 27, 2016 at 2:28 AM, Stefan Roese  wrote:

Hi!

I just tried to boot a recent Linux kernel on a BayTrail based
x86 board and noticed that booting Linux kernel version v4.7+
does not work. git bisecting leads to this kernel commit
changing the compressed image format:

974f221c:
x86/boot: Move compressed kernel to the end of the decompression buffer

Before digging deeper into this, I would like to check if
someone else has been hit by this problem and perhaps already
has a solution / fix for U-Boots zimage command. Or a quick
idea how to solve this.



could be u-boot does not copy whole setup header that include _init_size.

in kexec the code like:


/* only copy setup_header */
setup_header_size = kernel[0x201] + 0x202 - 0x1f1;
if (setup_header_size > 0x7f)
setup_header_size = 0x7f;
memcpy((unsigned char *)real_mode + 0x1f1, kernel + 0x1f1,
 setup_header_size);



Thanks for the notice. I've already sent this patch to the
U-Boot list to fix this issue:

https://patchwork.ozlabs.org/patch/676896/

Thanks,
Stefan
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] is there any issue with creating and using more than one hashtable?

2016-10-01 Thread Wolfgang Denk
Dear Robert,

In message  you 
wrote:
> 
>   in misc_init_r(), i create a new hashtable to just grab the contents
> of that bootline as is. i then create a *second* hashtable and
> selectively move over just those keys i want from the first hashtable,
> possibly renaming them in the process.

I'm not sure how you implemented this "move over" thing...

> now here's the thing ... after all that, i manually check whether the
> CRC for the env table in persistent storage is valid and, if it is, i
> do *nothing* with all that hashtable content -- that was all wasted
> cycles, but it should not do any harm.
> 
>   but it does, because this is what happens:
> 
>   TFTP from server 10.35.5.37; our IP address is 192.168.1.2; sending
>   through gateway 192.168.1.1
> 
> the server address is correct, but the IP address and gateway are
> totally wrong -- they should have been untouched and been completely
> different values; instead, they now equal the values in that second
> hashtable, which i chose to do nothing with.

For a test, I would like to ask you to run the following commands
beofre the TFTP command:

printenv serverip;setenv serverip ${serverip};printenv serverip
printenv ipaddr;setenv ipaddr ${ipaddr};printenv ipaddr
printenv gatewayip;setenv gatewayip ${gatewayip};printenv gatewayip

Does this change anything?

>   is there some weird issue with re-entrancy here? if i print "ipaddr"
> and "gatewayip", they seem correct. if i "md" the environment in
> persistent storage, again, they seem correct. and yet, when TFTP kicks
> in, it seems to pick up the values from that hashtable.

Actually the TFTP will not access the environment directly to determine the
boot  parameters like bootfile, ipaddr, gatewayip, netmask, serverip,
etc.; instead, it uses internal variables.  So your environment
settings for "ipaddr" and "gatewayip" may contain totally different
values than the variables  net_ip  resp.  net_gateway  which get used
by the TFTP code.

These variables get set through the U_BOOT_ENV_CALLBACK functionality,
i. e. as a callback whenever the corresponfing variable gets set.
"setting" here means that the value in the hash table gets changed -
see function _compare_and_overwrite_entry() in "hashtable.c":

244 /* If there is a callback, call it */
245 if (htab->table[idx].entry.callback &&
246 htab->table[idx].entry.callback(item.key,
247 item.data, env_op_overwrite, flag)) {
248 debug("callback() rejected setting variable 
"
249 "%s, skipping it!\n", item.key);
250 __set_errno(EINVAL);
251 *retval = NULL;
252 return 0;
253 }


So when you insert variable sof these registered names into your
alternative hash table using the common code, then the respective
callbacks will fire in the same way as if you had changed the
environment settings through a setenv command.


It is obvious that the U-Boot design did not anticipate a situation
where an alternative hash table with different settings would be
created.

A quick but ugly workaround could be to re-set the variables to the
values stored in the environment by running something like

setenv ipaddr ${ipaddr}

etc.


Hope this helps.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Do not simplify the design of a program if a way can be found to make
it complex and wonderful.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] x86: Booting Linux v4.7+ broken

2016-10-01 Thread Yinghai Lu
On Tue, Sep 27, 2016 at 2:28 AM, Stefan Roese  wrote:
> Hi!
>
> I just tried to boot a recent Linux kernel on a BayTrail based
> x86 board and noticed that booting Linux kernel version v4.7+
> does not work. git bisecting leads to this kernel commit
> changing the compressed image format:
>
> 974f221c:
> x86/boot: Move compressed kernel to the end of the decompression buffer
>
> Before digging deeper into this, I would like to check if
> someone else has been hit by this problem and perhaps already
> has a solution / fix for U-Boots zimage command. Or a quick
> idea how to solve this.
>

could be u-boot does not copy whole setup header that include _init_size.

in kexec the code like:


/* only copy setup_header */
setup_header_size = kernel[0x201] + 0x202 - 0x1f1;
if (setup_header_size > 0x7f)
setup_header_size = 0x7f;
memcpy((unsigned char *)real_mode + 0x1f1, kernel + 0x1f1,
 setup_header_size);
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot