[U-Boot] [PATCH 1/1] efi_loader: correct signature of GetPosition, SetPosition

2018-10-06 Thread Heinrich Schuchardt
The UEFI spec requires that file positions are passed as u64 in
GetPosition() and SetPosition().

Check if the file handle points to a directory in GetPosition().

Provide a unit test for GetPosition() and SetPosition().

Fix Coverity warning CID 184079 (CONSTANT_EXPRESSION_RESULT).

Add comments.

Fixes: b6dd57773719 ("efi_loader: use correct types in EFI_FILE_PROTOCOL")
Signed-off-by: Heinrich Schuchardt 
---
 include/efi_api.h|  4 +-
 lib/efi_loader/efi_file.c| 39 
 lib/efi_selftest/efi_selftest_block_device.c | 30 ++-
 3 files changed, 61 insertions(+), 12 deletions(-)

diff --git a/include/efi_api.h b/include/efi_api.h
index e6566bb358..3194db3517 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -1175,9 +1175,9 @@ struct efi_file_handle {
efi_status_t (EFIAPI *write)(struct efi_file_handle *file,
efi_uintn_t *buffer_size, void *buffer);
efi_status_t (EFIAPI *getpos)(struct efi_file_handle *file,
-   efi_uintn_t *pos);
+ u64 *pos);
efi_status_t (EFIAPI *setpos)(struct efi_file_handle *file,
-   efi_uintn_t pos);
+ u64 pos);
efi_status_t (EFIAPI *getinfo)(struct efi_file_handle *file,
const efi_guid_t *info_type, efi_uintn_t *buffer_size,
void *buffer);
diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
index f3226a8dc0..beb4fba917 100644
--- a/lib/efi_loader/efi_file.c
+++ b/lib/efi_loader/efi_file.c
@@ -443,28 +443,51 @@ error:
return EFI_EXIT(ret);
 }
 
+/**
+ * efi_file_getpos() - get current position in file
+ *
+ * This function implements the GetPosition service of the EFI file protocol.
+ * See the UEFI spec for details.
+ *
+ * @file:  file handle
+ * @pos:   pointer to file position
+ * Return: status code
+ */
 static efi_status_t EFIAPI efi_file_getpos(struct efi_file_handle *file,
-  efi_uintn_t *pos)
+  u64 *pos)
 {
+   efi_status_t ret = EFI_SUCCESS;
struct file_handle *fh = to_fh(file);
 
EFI_ENTRY("%p, %p", file, pos);
 
-   if (fh->offset <= SIZE_MAX) {
-   *pos = fh->offset;
-   return EFI_EXIT(EFI_SUCCESS);
-   } else {
-   return EFI_EXIT(EFI_DEVICE_ERROR);
+   if (fh->isdir) {
+   ret = EFI_UNSUPPORTED;
+   goto out;
}
+
+   *pos = fh->offset;
+out:
+   return EFI_EXIT(ret);
 }
 
+/**
+ * efi_file_setpos() - set current position in file
+ *
+ * This function implements the SetPosition service of the EFI file protocol.
+ * See the UEFI spec for details.
+ *
+ * @file:  file handle
+ * @pos:   new file position
+ * Return: status code
+ */
 static efi_status_t EFIAPI efi_file_setpos(struct efi_file_handle *file,
-   efi_uintn_t pos)
+  u64 pos)
 {
struct file_handle *fh = to_fh(file);
efi_status_t ret = EFI_SUCCESS;
 
-   EFI_ENTRY("%p, %zu", file, pos);
+   EFI_ENTRY("%p, %llu", file, pos);
 
if (fh->isdir) {
if (pos != 0) {
diff --git a/lib/efi_selftest/efi_selftest_block_device.c 
b/lib/efi_selftest/efi_selftest_block_device.c
index 1cd13042e9..d4e4fac1c7 100644
--- a/lib/efi_selftest/efi_selftest_block_device.c
+++ b/lib/efi_selftest/efi_selftest_block_device.c
@@ -308,6 +308,7 @@ static int execute(void)
} system_info;
efi_uintn_t buf_size;
char buf[16] __aligned(ARCH_DMA_MINALIGN);
+   u64 pos;
 
/* Connect controller to virtual disk */
ret = boottime->connect_controller(disk_handle, NULL, NULL, 1);
@@ -392,21 +393,36 @@ static int execute(void)
efi_st_error("Failed to open file\n");
return EFI_ST_FAILURE;
}
+   ret = file->setpos(file, 1);
+   if (ret != EFI_SUCCESS) {
+   efi_st_error("SetPosition failed\n");
+   return EFI_ST_FAILURE;
+   }
buf_size = sizeof(buf) - 1;
ret = file->read(file, _size, buf);
if (ret != EFI_SUCCESS) {
efi_st_error("Failed to read file\n");
return EFI_ST_FAILURE;
}
-   if (buf_size != 13) {
+   if (buf_size != 12) {
efi_st_error("Wrong number of bytes read: %u\n",
 (unsigned int)buf_size);
return EFI_ST_FAILURE;
}
-   if (efi_st_memcmp(buf, "Hello world!", 12)) {
+   if (efi_st_memcmp(buf, "ello world!", 11)) {
efi_st_error("Unexpected file content\n");
return EFI_ST_FAILURE;
}
+   ret = file->getpos(file, );
+   if (ret != EFI_SUCCESS) {
+   efi_st_error("GetPosition failed\n");
+   

Re: [U-Boot] [PATCH 1/3] spi: davinci: Add platdata support

2018-10-06 Thread Adam Ford
On Mon, Oct 1, 2018 at 4:57 PM Adam Ford  wrote:
>
> On Mon, Oct 1, 2018 at 7:54 AM Adam Ford  wrote:
> >
> > On Mon, Sep 3, 2018 at 5:22 PM Adam Ford  wrote:
> > >
> > > On Mon, Sep 3, 2018 at 5:21 PM Adam Ford  wrote:
> > > >
> > > > On Mon, Sep 3, 2018 at 12:30 PM Jagan Teki  
> > > > wrote:
> > > > >
> > > > > Davanci spi driver has DM support already, this patch
> > > > > add support for platdata so-that SPL can use it for
> > > > > low foot-print.
> > > > >
> > > >
> > > > In order for this to work, I had to apply a patch [1] that I submitted 
> > > > before.
> > > > That patch disabled the manual initialization of the UART in 
> > > > da850_lowlevel.c
> > > > to not conflict with the DM version of initialization.
> > > >
> > > > Assuming that [1] gets applied first then this, you can add me as
> > > > 'tested-by' on
> > > > both patches 1 of 3 and 2 of 3.  I don't have the hardware to test 3 of 
> > > > 3.
> > > >
> > > > [1] - https://patchwork.ozlabs.org/patch/957336/
> > > >
> > > > adam
> > > >
> > >
> > > I should have stated, that without the [1] patch, this does does not work.
> >
> > The patch I mentioned is applied.  I am back in the US and ready and
> > willing to test/retest  anything.
> > If you want me to just retest this patch as-is, I can do so, if you
> > want to rebase against master and sent out updated patches, I can do
> > that too.  If you have a git repo you want me to pull, I can test from
> > there too.
> >
> > As of 30 September 2018, the master branch booted the da850-evm and
> > the concern I had about DM_SERIAL has been applied, so I am confident
> > for at least the da850-evm your patch series should allow us to enable
> > DM and boot both SPL (with OF_PLATDATA) and U-Boot.
> >
> > adam
> >
> > >
> > > adam
> > > > > Signed-off-by: Jagan Teki 
>
> Tested-by: Adam Ford 
>

Is this patch series going to be acceptable as-is?  I'm very happy and
excited about it as it helps migrate more and more into DM.

thanks

adam
> > > > > ---
> > > > >  drivers/spi/davinci_spi.c  | 47 
> > > > > +++---
> > > > >  include/dm/platform_data/spi_davinci.h | 15 
> > > > >  2 files changed, 43 insertions(+), 19 deletions(-)
> > > > >  create mode 100644 include/dm/platform_data/spi_davinci.h
> > > > >
> > > > > diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c
> > > > > index a822858323..07fa5e3b8a 100644
> > > > > --- a/drivers/spi/davinci_spi.c
> > > > > +++ b/drivers/spi/davinci_spi.c
> > > > > @@ -14,6 +14,7 @@
> > > > >  #include 
> > > > >  #include 
> > > > >  #include 
> > > > > +#include 
> > > > >
> > > > >  /* SPIGCR0 */
> > > > >  #define SPIGCR0_SPIENA_MASK0x1
> > > > > @@ -529,50 +530,58 @@ static int davinci_spi_xfer(struct udevice 
> > > > > *dev, unsigned int bitlen,
> > > > > return __davinci_spi_xfer(ds, bitlen, dout, din, flags);
> > > > >  }
> > > > >
> > > > > +static const struct dm_spi_ops davinci_spi_ops = {
> > > > > +   .claim_bus  = davinci_spi_claim_bus,
> > > > > +   .release_bus= davinci_spi_release_bus,
> > > > > +   .xfer   = davinci_spi_xfer,
> > > > > +   .set_speed  = davinci_spi_set_speed,
> > > > > +   .set_mode   = davinci_spi_set_mode,
> > > > > +};
> > > > > +
> > > > >  static int davinci_spi_probe(struct udevice *bus)
> > > > >  {
> > > > > -   /* Nothing to do */
> > > > > +   struct davinci_spi_slave *ds = dev_get_priv(bus);
> > > > > +   struct davinci_spi_platdata *plat = bus->platdata;
> > > > > +   ds->regs = plat->regs;
> > > > > +   ds->num_cs = plat->num_cs;
> > > > > +
> > > > > return 0;
> > > > >  }
> > > > >
> > > > > +#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
> > > > >  static int davinci_ofdata_to_platadata(struct udevice *bus)
> > > > >  {
> > > > > -   struct davinci_spi_slave *ds = dev_get_priv(bus);
> > > > > -   const void *blob = gd->fdt_blob;
> > > > > -   int node = dev_of_offset(bus);
> > > > > +   struct davinci_spi_platdata *plat = bus->platdata;
> > > > > +   fdt_addr_t addr;
> > > > >
> > > > > -   ds->regs = devfdt_map_physmem(bus, sizeof(struct 
> > > > > davinci_spi_regs));
> > > > > -   if (!ds->regs) {
> > > > > -   printf("%s: could not map device address\n", 
> > > > > __func__);
> > > > > +   addr = devfdt_get_addr(bus);
> > > > > +   if (addr == FDT_ADDR_T_NONE)
> > > > > return -EINVAL;
> > > > > -   }
> > > > > -   ds->num_cs = fdtdec_get_int(blob, node, "num-cs", 4);
> > > > > +
> > > > > +   plat->regs = (struct davinci_spi_regs *)addr;
> > > > > +   plat->num_cs = fdtdec_get_int(gd->fdt_blob, 
> > > > > dev_of_offset(bus), "num-cs", 4);
> > > > >
> > > > > return 0;
> > > > >  }
> > > > >
> > > > > -static const struct dm_spi_ops davinci_spi_ops = {
> > > > > -   .claim_bus  = davinci_spi_claim_bus,
> > > > > -   .release_bus= 

Re: [U-Boot] [PATCH 1/4] Enable CONFIG_TIMER_EARLY with bootstage

2018-10-06 Thread Bin Meng
On Tue, Oct 2, 2018 at 9:25 PM Bin Meng  wrote:
>
> Hi Simon,
>
> On Thu, Sep 27, 2018 at 9:42 PM Simon Glass  wrote:
> >
> > Hi Bin,
> >
> > On 25 September 2018 at 23:39, Bin Meng  wrote:
> > > Hi Simon,
> > >
> > > On Wed, Sep 26, 2018 at 1:42 PM Simon Glass  wrote:
> > >>
> > >> Hi Bin,
> > >>
> > >> On 4 September 2018 at 03:06, Bin Meng  wrote:
> > >> > Hi Simon,
> > >> >
> > >> > On Mon, Sep 3, 2018 at 7:02 AM Simon Glass  wrote:
> > >> >>
> > >> >> In initr_bootstage() we call bootstage_mark_name() which ends up 
> > >> >> calling
> > >> >> timer_get_us(). This call happens before initr_dm(), which inits 
> > >> >> driver
> > >> >> model.
> > >> >>
> > >> >> On x86 we set gd->timer to NULL in the transition from board_init_f()
> > >> >
> > >> > It's not just x86 we set gd->timer to NULL. It applied to all
> > >> > architectures when CONFIG_TIMER is on.
> > >> >
> > >> >> to board_init_r(). See board_init_f_r() for this assignment. So U-Boot
> > >> >> knows there is no timer available in the period immediately after
> > >> >> relocation.
> > >> >>
> > >> >> On x86 the timer_get_us() call is implemented as calls to get_ticks() 
> > >> >> and
> > >> >> get_tbclk(). Both of these call dm_timer_init() to set up the timer, 
> > >> >> if
> > >> >> gd->timer is NULL and the early timer is not available.
> > >> >>
> > >> >> However dm_timer_init() cannot succeed before initr_dm() is called.
> > >> >>
> > >> >> So it seems that on x86 if we want to use CONFIG_BOOTSTAGE we must 
> > >> >> enable
> > >> >> CONFIG_TIMER_EARLY. Update the Kconfig to handle this.
> > >> >>
> > >> >> Note: On most architectures we can rely on the pre-relocation memory 
> > >> >> still
> > >> >> being available, so that gd->timer pointers to a valid timer device 
> > >> >> and
> > >> >> everything works correctly. Admittedly this is not strictly correct 
> > >> >> since
> > >> >> the timer device is set up by pre-relocation U-Boot, but normally 
> > >> >> this is
> > >> >> fine. On x86 the 'CAR' (cache-as-RAM) memory used by pre-relocation 
> > >> >> U-Boot
> > >> >> disappears in board_init_f_r() and any attempt to access it will hang.
> > >> >> This is the reason why we must mark the timer as invalid when we get 
> > >> >> to
> > >> >> board_init_f_r().
> > >> >>
> > >> >> Signed-off-by: Simon Glass 
> > >> >> ---
> > >> >>
> > >> >>  drivers/timer/Kconfig | 3 +++
> > >> >>  1 file changed, 3 insertions(+)
> > >> >>
> > >> >> diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig
> > >> >> index 5ab6749193c..ff434de6f7c 100644
> > >> >> --- a/drivers/timer/Kconfig
> > >> >> +++ b/drivers/timer/Kconfig
> > >> >> @@ -30,6 +30,9 @@ config TPL_TIMER
> > >> >>  config TIMER_EARLY
> > >> >> bool "Allow timer to be used early in U-Boot"
> > >> >> depends on TIMER
> > >> >> +   # initr_bootstage() requires a timer and is called before 
> > >> >> initr_dm()
> > >> >> +   # so only the early timer is available
> > >> >> +   default y if X86 && BOOTSTAGE
> > >> >
> > >> > Since this applies not only on x86, and given without TIMER_EARLY
> > >> > BOOTSTAGE is broken, shouldn't we do this in BOOTSTAGE config instead:
> > >> >
> > >> > config BOOTSTAGE
> > >> >  select TIMER_EARLY
> > >>
> > >> Well we could, but I suspect that would break things since the early
> > >> timer is not supported by many boards. Also for most boards this
> > >> doesn't actually work fine. x86 is really quite awful in that it has
> > >> no SRAM and the CAR becomes inaccessible as soon as you turn on the
> > >> cache!
> > >
> > > It's true that early timer is supported by some limited boards, but
> > > that's a different issue. For now that patch does not fix anything. If
> > > we add BOOTSTAGE from either defconfig or 'menuconfig' for a board,
> > > without adding TIMER_EARLY, it will for sure break.
> >
> > Is this because of code called in board_f.c ? I don't quite follow.
>
> I re-read the codes and your comments. I think what you said below:
>
> "Note: On most architectures we can rely on the pre-relocation memory
> still being available, so that gd->timer pointers to a valid timer
> device and everything works correctly."
>
> makes sense. So adding 'select TIMER_EARLY' to BOOTSTAGE seems
> over-killing things. Let's use your approach.
>
> Reviewed-by: Bin Meng 

applied to u-boot-x86, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] configs: move CONFIG_SPL_TEXT_BASE to Kconfig

2018-10-06 Thread Tom Rini
On Sun, Sep 30, 2018 at 02:31:53PM +0200, Simon Goldschmidt wrote:

> Moved CONFIG_SPL_TEXT_BASE to common/spl/Kconfig with
> help from moveconfig.py (only had to prepare socfpga,
> stm32f746 and am33x/43x manually)
> 
> Signed-off-by: Simon Goldschmidt 
> ---
> 
> This patch is in preparation for boot-from-FPGA for
> socfpga cyclone5, where we need a different SPL_TEXT_BASE.
> By moving this to Kconfig, this can then be done via
> defconfig.
> 
> I did notice that some defconfig files change more than
> necessary, it seems like they are out of sync?

So, I see at least one set of problems with the conversion, the am33*
family gets put to 0x0 which isn't right.  I'm going to pull out the
print tool I made and posted a while back and use that for conversion.
Thanks for the starting point!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] spl: spi: Do not hardcode fixed size for header

2018-10-06 Thread Tom Rini
On Thu, Oct 04, 2018 at 09:30:20AM +0200, Michal Simek wrote:

> Find out size directly from header structure.
> 
> Signed-off-by: Michal Simek 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] spl: ram: Fix u_boot_pos calculation

2018-10-06 Thread Tom Rini
On Thu, Oct 04, 2018 at 09:29:20AM +0200, Michal Simek wrote:

> The patch:
> "spl: Weed out CONFIG_SYS_TEXT_BASE usage"
> (sha1: 04ce5427bd3914cab8be78513275a20ab878520a)
> introduced bug where assigning to u_boot_pos variable wasn't done
> which end up in situation where SPL wasn't able to find out
> image on the selected address.
> 
> Signed-off-by: Michal Simek 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 1/5] ARM: DTS: LogicPD-SOM-LV & Torpedo: Resync DTS with Kernel

2018-10-06 Thread Tom Rini
On Sat, Sep 29, 2018 at 02:10:15PM -0500, Adam Ford wrote:

> The device tree entries are from linux-omap's for-next branch
> destined to me put into 4.20 (or whatever the version is after 4.19)
> 
> Signed-off-by: Adam Ford 
> 
> diff --git a/arch/arm/dts/logicpd-som-lv-37xx-devkit.dts 
> b/arch/arm/dts/logicpd-som-lv-37xx-devkit.dts
> index 2428373952..2aca9111c6 100644

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 5/5] ARM: LogicPD: omap3logic: Remove Torpedo/SOM-LV autodection

2018-10-06 Thread Tom Rini
On Sat, Sep 29, 2018 at 02:10:19PM -0500, Adam Ford wrote:

> With there now being four device tree files, and 4 separate
> defconfig files, the code necessary to determine which board is
> being used is no longer necessary as the corresponding pin-muxing
> and board names are determined by the device tree.
> 
> Signed-off-by: Adam Ford 
> 
> diff --git a/board/logicpd/omap3som/README b/board/logicpd/omap3som/README
> index b77b3d63db..5aaf58f0a6 100644

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, v3] misc: Add support for the Arm Versatile Express config bus

2018-10-06 Thread Tom Rini
On Fri, Sep 28, 2018 at 01:43:31PM +0100, Liviu Dudau wrote:

> Add support for the Arm Versatile Express config bus that is
> being used for exposing various subsystems via a generic
> configuration bus. This driver adds support for generating
> transactions on this configuration bus and can be used by
> other drivers to abstract the communication with the actual
> function providers.
> 
> Signed-off-by: Liviu Dudau 
> Reviewed-by: Heiko Schocher 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 2/5] ARM: DTS: Remove unnecessary u-boot.dtsi options from omap3/36xx

2018-10-06 Thread Tom Rini
On Sat, Sep 29, 2018 at 02:10:16PM -0500, Adam Ford wrote:

> With the introduction of the omap serial driver, the need for some
> of these U-Boot specific modifications is gone.  This cleans up
> this unnneeded stuff.
> 
> Signed-off-by: Adam Ford 
> 
> diff --git a/arch/arm/dts/logicpd-torpedo-37xx-devkit-u-boot.dtsi 
> b/arch/arm/dts/logicpd-torpedo-37xx-devkit-u-boot.dtsi
> index d584b4a9ab..41ed5d7e17 100644

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 4/5] ARM: DTS: Add Logic PD OMAP35/DM37 SOM-LV and OMAP35 Torpedo

2018-10-06 Thread Tom Rini
On Sat, Sep 29, 2018 at 02:10:18PM -0500, Adam Ford wrote:

> With the device trees doing most of the work of pin-muxing and
> DM doing much of the peripheral initialization, this creates
> new defconfig files for each of the Logic PD variants with
> proper register settings/pin-muxing.
> 
> Signed-off-by: Adam Ford 
> 
> diff --git a/arch/arm/dts/logicpd-som-lv-35xx-devkit-u-boot.dtsi 
> b/arch/arm/dts/logicpd-som-lv-35xx-devkit-u-boot.dtsi
> new file mode 100644
> index 00..6445048fe0

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 3/5] ARM: DTS: Add support for Logic PD OMAP35 Torpedo & SOM-LV

2018-10-06 Thread Tom Rini
On Sat, Sep 29, 2018 at 02:10:17PM -0500, Adam Ford wrote:

> The baseboards and SOM's are virtually identical to their DM37
> counterparts, but OMAP36/37 and OMAP3 have some minor register
> differences.  With the boards being mostly driven by device trees
> now, this synchronizes their respective device trees with linux-omap
> for-next branch destined for 4.20 (or whatever the version after 4.19
> will be called)
> 
> Signed-off-by: Adam Ford 
> 
> diff --git a/arch/arm/dts/logicpd-som-lv-35xx-devkit.dts 
> b/arch/arm/dts/logicpd-som-lv-35xx-devkit.dts
> new file mode 100644
> index 00..4cd72b5e61

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 2/2] test/py: test_fs: add docstring comments to helper functions

2018-10-06 Thread Tom Rini
On Thu, Sep 27, 2018 at 04:07:23PM +0900, Akashi, Takahiro wrote:

> From: "Akashi Takahiro" 
> 
> After Siomon's comment, add a descriptive comment (docstring) to each of
> helper functions in conftest.py. No functionality changed.
> 
> Signed-off-by: Akashi Takahiro 
> Reviewed-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot,1/1] fs: fat: fix set_cluster()

2018-10-06 Thread Tom Rini
On Tue, Oct 02, 2018 at 09:30:45AM +0200, Heinrich Schuchardt wrote:

> Avoid CoverityScan warning SIGN_EXTENSION CID 184096 by changing the
> type of parameter size of set_cluster().
> 
> Avoid leaking stack content when writing an incomplete last sector.
> 
> Reported-by: Tom Rini 
> Signed-off-by: Heinrich Schuchardt 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot,1/1] fs: fat: memory leak in fat_unlink()

2018-10-06 Thread Tom Rini
On Tue, Oct 02, 2018 at 06:58:00AM +0200, Heinrich Schuchardt wrote:

> Do not leak filename_copy in case of error.
> Catch out of memory when calling strdup.
> 
> This addresses Coverity Scan CID 184086.
> 
> Reported-by: Tom Rini 
> Signed-off-by: Heinrich Schuchardt 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] mach-stm32: Set MPU SDRAM size to 512MB for STM32F7/H7

2018-10-06 Thread Tom Rini
On Tue, Oct 02, 2018 at 09:03:10AM +0200, Patrice Chotard wrote:

> This allows to boot all STM32F7 and STM32H7 boards independently
> of the amount of embedded SDRAM.
> 
> Signed-off-by: Patrice Chotard 
> Reviewed-by: Vikas Manocha 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 1/2] test/py: test_fs: remove fs_type argument from umount_fs()

2018-10-06 Thread Tom Rini
On Thu, Sep 27, 2018 at 04:07:22PM +0900, Akashi, Takahiro wrote:

> From: "Akashi Takahiro" 
> 
> Since there is no use of fs_type in umount_fs(), just remove it.
> 
> Signed-off-by: Akashi Takahiro 
> Reviewed-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] configs: drop CONFIG_SYS_EXTRA_ENV_RELOC

2018-10-06 Thread Tom Rini
On Thu, Sep 27, 2018 at 12:38:34PM +0200, Simon Goldschmidt wrote:

> Instead of manually specifying CONFIG_SYS_EXTRA_ENV_RELOC
> for every board that needs it, it shouldn't hurt to let
> initr_reloc_global_data() always relocate gd->env_addr
> unless we know this pointer is outside the initial binary.
> 
> To achieve this, the relocation is omitted if
> CONFIG_ENV_ADDR is defined (and ENV_IS_EMBEDDED is not).
> 
> Signed-off-by: Simon Goldschmidt 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, V2] test/py: ignore console read exceptions after test failure

2018-10-06 Thread Tom Rini
On Thu, Sep 20, 2018 at 04:55:03PM -0600, Stephen Warren wrote:

> From: Stephen Warren 
> 
> After a test has failed, test/py drains the U-Boot console log to ensure
> that any relevant output is captured. At this point, we don't care about
> detecting any additional errors, since the test is already known to have
> failed, and U-Boot will be restarted. To ensure that the test cleanup code
> is not interrupted, and can correctly terminate the log sections for the
> failed test, ignore any exception that occurs while reading the U-Boot
> console output during this limited period of time.
> 
> Signed-off-by: Stephen Warren 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 3/9] dm: uclass: Add uclass_foreach_dev_probe

2018-10-06 Thread Simon Glass
On 1 October 2018 at 05:59, Patrice Chotard  wrote:
>
> Add uclass_foreach_dev_probe() which iterates through
> devices of a given uclass. Devices are probed if necessary
> and are ready to use.
>
> Signed-off-by: Patrice Chotard 
> ---
>
> Changes in v2: None
>
>  include/dm/uclass.h | 16 
>  1 file changed, 16 insertions(+)

Reviewed-by: Simon Glass 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] arm: socfpga: fix SPL booting from fpga OnChip RAM

2018-10-06 Thread Tom Rini
On Sat, Oct 06, 2018 at 10:33:42PM +0200, Simon Goldschmidt wrote:

> This patch prevents disabling the FPGA bridges when
> SPL or U-Boot is executed from FPGA onchip RAM.
> 
> Signed-off-by: Simon Goldschmidt 
> ---
> 
> 
> There are other patches required to make boot from
> FPGA work correctly:
> - CONFIG_SPL_TEXT_BASE needs to be set to 0xC000
>   ideally this is done by moving SPL_TEXT_BASE to Kconfig:
>   https://patchwork.ozlabs.org/patch/976918/
> - spl_ram.c needs this patch by Michal Simek:
>   https://patchwork.ozlabs.org/patch/978694/
> - For U-Boot to be run from FPGA onchip RAM, either
>   CONFIG_SYS_EXTRA_ENV_RELOC needs to be used or this patch
>   is required to relocate gd->env_addr:
>   https://patchwork.ozlabs.org/patch/975702/

For the record, I'm currently reviewing the last two parts here.  The
first one will come soon (I do Kconfig migrations separate so I can see
a lack of size change).

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] arm: socfpga: fix SPL booting from fpga OnChip RAM

2018-10-06 Thread Simon Goldschmidt
This patch prevents disabling the FPGA bridges when
SPL or U-Boot is executed from FPGA onchip RAM.

Signed-off-by: Simon Goldschmidt 
---


There are other patches required to make boot from
FPGA work correctly:
- CONFIG_SPL_TEXT_BASE needs to be set to 0xC000
  ideally this is done by moving SPL_TEXT_BASE to Kconfig:
  https://patchwork.ozlabs.org/patch/976918/
- spl_ram.c needs this patch by Michal Simek:
  https://patchwork.ozlabs.org/patch/978694/
- For U-Boot to be run from FPGA onchip RAM, either
  CONFIG_SYS_EXTRA_ENV_RELOC needs to be used or this patch
  is required to relocate gd->env_addr:
  https://patchwork.ozlabs.org/patch/975702/
---
 arch/arm/mach-socfpga/include/mach/base_addr_ac5.h | 1 +
 arch/arm/mach-socfpga/misc_gen5.c  | 8 
 arch/arm/mach-socfpga/spl_gen5.c   | 4 
 3 files changed, 13 insertions(+)

diff --git a/arch/arm/mach-socfpga/include/mach/base_addr_ac5.h 
b/arch/arm/mach-socfpga/include/mach/base_addr_ac5.h
index bb9e3faa29..2725e9fcc3 100644
--- a/arch/arm/mach-socfpga/include/mach/base_addr_ac5.h
+++ b/arch/arm/mach-socfpga/include/mach/base_addr_ac5.h
@@ -6,6 +6,7 @@
 #ifndef _SOCFPGA_BASE_ADDRS_H_
 #define _SOCFPGA_BASE_ADDRS_H_
 
+#define SOCFPGA_FPGA_SLAVES_ADDRESS0xc000
 #define SOCFPGA_STM_ADDRESS0xfc00
 #define SOCFPGA_DAP_ADDRESS0xff00
 #define SOCFPGA_EMAC0_ADDRESS  0xff70
diff --git a/arch/arm/mach-socfpga/misc_gen5.c 
b/arch/arm/mach-socfpga/misc_gen5.c
index 429c3d6cd5..fa66484783 100644
--- a/arch/arm/mach-socfpga/misc_gen5.c
+++ b/arch/arm/mach-socfpga/misc_gen5.c
@@ -187,7 +187,15 @@ void socfpga_sdram_remap_zero(void)
setbits_le32(_regs->sacr, 0xfff);
 
/* Configure the L2 controller to make SDRAM start at 0 */
+#if (defined(CONFIG_SPL_BUILD) && \
+   (CONFIG_SPL_TEXT_BASE == SOCFPGA_FPGA_SLAVES_ADDRESS)) || \
+   ((CONFIG_SYS_TEXT_BASE >= SOCFPGA_FPGA_SLAVES_ADDRESS) && \
+   (CONFIG_SYS_TEXT_BASE < SOCFPGA_STM_ADDRESS))
+   /* remap.mpuzero, keep fpga bridge enabled */
+   writel(0x9, _regs->remap);
+#else
writel(0x1, _regs->remap);   /* remap.mpuzero */
+#endif
writel(0x1, >pl310_addr_filter_start);
 }
 
diff --git a/arch/arm/mach-socfpga/spl_gen5.c b/arch/arm/mach-socfpga/spl_gen5.c
index be318cc0d9..41e7787f11 100644
--- a/arch/arm/mach-socfpga/spl_gen5.c
+++ b/arch/arm/mach-socfpga/spl_gen5.c
@@ -92,8 +92,10 @@ void board_init_f(ulong dummy)
 
/* Put everything into reset but L4WD0. */
socfpga_per_reset_all();
+#if CONFIG_SPL_TEXT_BASE != SOCFPGA_FPGA_SLAVES_ADDRESS
/* Put FPGA bridges into reset too. */
socfpga_bridges_reset(1);
+#endif
 
socfpga_per_reset(SOCFPGA_RESET(SDR), 0);
socfpga_per_reset(SOCFPGA_RESET(UART0), 0);
@@ -163,5 +165,7 @@ void board_init_f(ulong dummy)
hang();
}
 
+#if CONFIG_SPL_TEXT_BASE != SOCFPGA_FPGA_SLAVES_ADDRESS
socfpga_bridges_reset(1);
+#endif
 }
-- 
2.17.1

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


Re: [U-Boot] [PATCH] spl: ram: Fix u_boot_pos calculation

2018-10-06 Thread Simon Goldschmidt

On 06.10.2018 17:29, Simon Goldschmidt wrote:

On 04.10.2018 09:29, Michal Simek wrote:

The patch:
"spl: Weed out CONFIG_SYS_TEXT_BASE usage"
(sha1: 04ce5427bd3914cab8be78513275a20ab878520a)
introduced bug where assigning to u_boot_pos variable wasn't done
which end up in situation where SPL wasn't able to find out
image on the selected address.

Signed-off-by: Michal Simek 

I needed to apply this to boot my socfpga cyclone5 from FPGA (both SPL
and U-Boot in FPGA onchip RAM).

Tested-by: Simon Goldschmidt 


There's a typo in my mail address :-(
Here's the correct tag:

Tested-by: Simon Goldschmidt 





---

Lines are unfortunatelly longer then 80 char limits but
there is no nice way how to fix it.

---
   common/spl/spl_ram.c | 5 ++---
   1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/common/spl/spl_ram.c b/common/spl/spl_ram.c
index 619b39a53748..5fcc3b1504bb 100644
--- a/common/spl/spl_ram.c
+++ b/common/spl/spl_ram.c
@@ -63,9 +63,8 @@ static int spl_ram_load_image(struct spl_image_info 
*spl_image,
 * No binman support or no information. For now, fix it
 * to the address pointed to by U-Boot.
 */
-   header = spl_get_load_buffer(-sizeof(*header),
-sizeof(*header));
-
+   u_boot_pos = 
(ulong)spl_get_load_buffer(-sizeof(*header),
+   
sizeof(*header));
}
header = (struct image_header *)map_sysmem(u_boot_pos, 0);
   




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


[U-Boot] [PATCH] fs: fat: fix reading non-cluster-aligned root directory

2018-10-06 Thread Anssi Hannula
FAT16 root directory might not start at a cluster boundary (though it
always ends on one).

However, next_dent() always starts reading the directory at the
beginning of the cluster, causing no files to be found (at least if the
beginning of the cluster contains zeroes).

Fix that by skipping to the actual start of the root directory in such a
case.

This is a relatively common case as at least the filesystem formatter on
Win7 seems to create such filesystems by default on 2GB USB sticks
(cluster size 64 sectors, rootdir size 32 sectors).

dosfstools mkfs.vfat does not seem to create such filesystems.

Signed-off-by: Anssi Hannula 
---
 fs/fat/fat.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index b08949d370..4a0d4bb8bc 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -782,6 +782,20 @@ static dir_entry *next_dent(fat_itr *itr)
 
itr->remaining = nbytes / sizeof(dir_entry) - 1;
itr->dent = dent;
+
+   if (itr->fsdata->fatsize != 32 &&
+   itr->clust == itr->fsdata->root_cluster) {
+   /* rootdir might not start at cluster boundary */
+   u32 sect_offset = itr->fsdata->rootdir_sect -
+   clust_to_sect(itr->fsdata,
+ itr->fsdata->root_cluster);
+   u32 dirent_offset = itr->fsdata->sect_size /
+   sizeof(dir_entry) * sect_offset;
+
+   itr->remaining -= dirent_offset;
+   itr->dent += dirent_offset;
+   }
+
} else {
itr->remaining--;
itr->dent++;
-- 
2.17.1

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


Re: [U-Boot] ARM: da850evm: Remove DM_I2C_COMPAT

2018-10-06 Thread Tom Rini
On Sun, Sep 30, 2018 at 09:20:13AM -0500, Adam Ford wrote:


> The da850evm does not need this enabled, so this removes a
> notice that appears during compile time that says
> "Please remove"
> 
> Signed-off-by: Adam Ford 

NAK, this breaks da850_am18xxevm which, ahem, you're listed as the
maintainer of :)

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] 4 failures with 'ut dm'

2018-10-06 Thread Bin Meng
On Sat, Oct 6, 2018 at 9:14 PM Bin Meng  wrote:
>
> Hi Simon,
>
> With current u-boot/master, there are 4 failures with 'ut dm'. I was
> wondering is this not covered by travis-ci?
>
> Test: dm_test_bus_children: bus.c
> test/dm/bus.c:112, dm_test_bus_children(): num_devices ==
> list_count_items(>dev_head): Expected 7, got 6
>
> Test: dm_test_fdt: test-fdt.c
> test/dm/test-fdt.c:184, dm_test_fdt(): num_devices ==
> list_count_items(>dev_head): Expected 7, got 6
>

The above 2 failures are fixed with the following patch:
http://patchwork.ozlabs.org/patch/979952/

> Test: dm_test_spmi_access: spmi.c
> test/dm/spmi.c:55, dm_test_spmi_access(): 0 == device_get_child(bus,
> 0, ): Expected 0, got -22
>
> Test: dm_test_spmi_access_peripheral: spmi.c
> test/dm/spmi.c:82, dm_test_spmi_access_peripheral(): 0 ==
> gpio_lookup_name("spmi1", , , ): Expected 0, got -22

Regards,
Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 4/8] dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in lists_bind_fdt()

2018-10-06 Thread Bin Meng
Currently the comments of several APIs (eg: dm_init_and_scan()) say:

@pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
flag. If false bind all drivers.

The 'Pre-Relocation Support' chapter in doc/driver-model/README.txt
documents the same.

However the implementation only checks these special device tree
properties without checking the driver flag at all. This updates
lists_bind_fdt() to consider both scenarios.

Signed-off-by: Bin Meng 
---

 drivers/core/lists.c   |  9 -
 drivers/core/root.c| 12 
 drivers/serial/serial-uclass.c |  2 +-
 drivers/timer/timer-uclass.c   |  2 +-
 include/dm/lists.h |  5 -
 5 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index a167726..a1f8284 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -122,7 +122,8 @@ static int driver_check_compatible(const struct udevice_id 
*of_match,
return -ENOENT;
 }
 
-int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp)
+int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
+  bool pre_reloc_only)
 {
struct driver *driver = ll_entry_start(struct driver, driver);
const int n_ents = ll_entry_count(struct driver, driver);
@@ -171,6 +172,12 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, 
struct udevice **devp)
if (entry == driver + n_ents)
continue;
 
+   if (pre_reloc_only) {
+   if (!dm_ofnode_pre_reloc(node) &&
+   !(entry->flags & DM_FLAG_PRE_RELOC))
+   return 0;
+   }
+
pr_debug("   - found match at '%s'\n", entry->name);
ret = device_bind_with_driver_data(parent, entry, name,
   id->data, node, );
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 47d10b8..f918ee1 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -222,14 +222,12 @@ static int dm_scan_fdt_live(struct udevice *parent,
int ret = 0, err;
 
for (np = node_parent->child; np; np = np->sibling) {
-   if (pre_reloc_only &&
-   !of_find_property(np, "u-boot,dm-pre-reloc", NULL))
-   continue;
if (!of_device_is_available(np)) {
pr_debug("   - ignoring disabled device\n");
continue;
}
-   err = lists_bind_fdt(parent, np_to_ofnode(np), NULL);
+   err = lists_bind_fdt(parent, np_to_ofnode(np), NULL,
+pre_reloc_only);
if (err && !ret) {
ret = err;
debug("%s: ret=%d\n", np->name, ret);
@@ -276,14 +274,12 @@ static int dm_scan_fdt_node(struct udevice *parent, const 
void *blob,
continue;
}
 
-   if (pre_reloc_only &&
-   !dm_fdt_pre_reloc(blob, offset))
-   continue;
if (!fdtdec_get_is_enabled(blob, offset)) {
pr_debug("   - ignoring disabled device\n");
continue;
}
-   err = lists_bind_fdt(parent, offset_to_ofnode(offset), NULL);
+   err = lists_bind_fdt(parent, offset_to_ofnode(offset), NULL,
+pre_reloc_only);
if (err && !ret) {
ret = err;
debug("%s: ret=%d\n", fdt_get_name(blob, offset, NULL),
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index ffdcae0..cc11474 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -61,7 +61,7 @@ static int serial_check_stdout(const void *blob, struct 
udevice **devp)
 * anyway.
 */
if (node > 0 && !lists_bind_fdt(gd->dm_root, offset_to_ofnode(node),
-   devp)) {
+   devp, false)) {
if (!device_probe(*devp))
return 0;
}
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index fe73f71..12ee6eb 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -108,7 +108,7 @@ int notrace dm_timer_init(void)
 * If the timer is not marked to be bound before
 * relocation, bind it anyway.
 */
-   if (!lists_bind_fdt(dm_root(), node, )) {
+   if (!lists_bind_fdt(dm_root(), node, , false)) {
ret = device_probe(dev);
if (ret)
return ret;
diff --git a/include/dm/lists.h b/include/dm/lists.h
index 13d1516..59094d7 100644
--- 

[U-Boot] [PATCH 8/8] timer: Sort Kconfig driver entries

2018-10-06 Thread Bin Meng
This is currently out of order. Sort it.

Signed-off-by: Bin Meng 

---

 drivers/timer/Kconfig | 110 +-
 1 file changed, 55 insertions(+), 55 deletions(-)

diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig
index a7d600b..8c0f356 100644
--- a/drivers/timer/Kconfig
+++ b/drivers/timer/Kconfig
@@ -37,6 +37,12 @@ config TIMER_EARLY
  use an early timer. These functions must be supported by your timer
  driver: timer_early_get_count() and timer_early_get_rate().
 
+config AG101P_TIMER
+   bool "AG101P timer support"
+   depends on TIMER && NDS32
+   help
+ Select this to enable a timer for AG01P devices.
+
 config ALTERA_TIMER
bool "Altera timer support"
depends on TIMER
@@ -44,6 +50,34 @@ config ALTERA_TIMER
  Select this to enable a timer for Altera devices. Please find
  details on the "Embedded Peripherals IP User Guide" of Altera.
 
+config ARC_TIMER
+   bool "ARC timer support"
+   depends on TIMER && ARC && CLK
+   help
+ Select this to enable built-in ARC timers.
+ ARC cores may have up to 2 built-in timers: timer0 and timer1,
+ usually at least one of them exists. Either of them is supported
+ in U-Boot.
+
+config AST_TIMER
+   bool "Aspeed ast2400/ast2500 timer support"
+   depends on TIMER
+   default y if ARCH_ASPEED
+   help
+ Select this to enable timer for Aspeed ast2400/ast2500 devices.
+ This is a simple sys timer driver, it is compatible with lib/time.c,
+ but does not support any interrupts. Even though SoC has 8 hardware
+ counters, they are all treated as a single device by this driver.
+ This is mostly because they all share several registers which
+ makes it difficult to completely separate them.
+
+config ATCPIT100_TIMER
+   bool "ATCPIT100 timer support"
+   depends on TIMER
+   help
+ Select this to enable a ATCPIT100 timer which will be embedded
+ in AE3XX, AE250 boards.
+
 config ATMEL_PIT_TIMER
bool "Atmel periodic interval timer support"
depends on TIMER
@@ -66,18 +100,12 @@ config DESIGNWARE_APB_TIMER
  Enables support for the Designware APB Timer driver. This timer is
  present on Altera SoCFPGA SoCs.
 
-config SANDBOX_TIMER
-   bool "Sandbox timer support"
-   depends on SANDBOX && TIMER
-   help
- Select this to enable an emulated timer for sandbox. It gets
- time from host os.
-
-config X86_TSC_TIMER
-   bool "x86 Time-Stamp Counter (TSC) timer support"
-   depends on TIMER && X86
+config MPC83XX_TIMER
+   bool "MPC83xx timer support"
+   depends on TIMER
help
- Select this to enable Time-Stamp Counter (TSC) timer for x86.
+ Select this to enable support for the timer found on
+ devices based on the MPC83xx family of SoCs.
 
 config OMAP_TIMER
bool "Omap timer support"
@@ -85,17 +113,19 @@ config OMAP_TIMER
help
  Select this to enable an timer for Omap devices.
 
-config AST_TIMER
-   bool "Aspeed ast2400/ast2500 timer support"
+config ROCKCHIP_TIMER
+   bool "Rockchip timer support"
depends on TIMER
-   default y if ARCH_ASPEED
help
- Select this to enable timer for Aspeed ast2400/ast2500 devices.
- This is a simple sys timer driver, it is compatible with lib/time.c,
- but does not support any interrupts. Even though SoC has 8 hardware
- counters, they are all treated as a single device by this driver.
- This is mostly because they all share several registers which
- makes it difficult to completely separate them.
+ Select this to enable support for the timer found on
+ Rockchip devices.
+
+config SANDBOX_TIMER
+   bool "Sandbox timer support"
+   depends on SANDBOX && TIMER
+   help
+ Select this to enable an emulated timer for sandbox. It gets
+ time from host os.
 
 config STI_TIMER
bool "STi timer support"
@@ -104,47 +134,17 @@ config STI_TIMER
help
  Select this to enable a timer for STi devices.
 
-config ARC_TIMER
-   bool "ARC timer support"
-   depends on TIMER && ARC && CLK
-   help
- Select this to enable built-in ARC timers.
- ARC cores may have up to 2 built-in timers: timer0 and timer1,
- usually at least one of them exists. Either of them is supported
- in U-Boot.
-
-config AG101P_TIMER
-   bool "AG101P timer support"
-   depends on TIMER && NDS32
-   help
- Select this to enable a timer for AG01P devices.
-
-config ATCPIT100_TIMER
-   bool "ATCPIT100 timer support"
-   depends on TIMER
-   help
- Select this to enable a ATCPIT100 timer which will be embeded
-   in AE3XX, AE250 boards.
-
-config ROCKCHIP_TIMER
-bool "Rockchip 

[U-Boot] [PATCH 7/8] test: dm: core: Add a test case for driver marked with DM_FLAG_PRE_RELOC flag

2018-10-06 Thread Bin Meng
Now that we fixed the pre-relocation driver binding for driver marked
with DM_FLAG_PRE_RELOC flag, add a test case to cover that scenario.

Signed-off-by: Bin Meng 
---

 arch/sandbox/dts/test.dts |  4 
 test/dm/bus.c |  2 +-
 test/dm/test-fdt.c| 29 ++---
 3 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 491f889..f12410f 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -146,6 +146,10 @@
compatible = "denx,u-boot-fdt-test";
};
 
+   h-test {
+   compatible = "denx,u-boot-fdt-test1";
+   };
+
clocks {
clk_fixed: clk-fixed {
compatible = "fixed-clock";
diff --git a/test/dm/bus.c b/test/dm/bus.c
index e9a4028..c41bcf7 100644
--- a/test/dm/bus.c
+++ b/test/dm/bus.c
@@ -104,7 +104,7 @@ UCLASS_DRIVER(testbus) = {
 /* Test that we can probe for children */
 static int dm_test_bus_children(struct unit_test_state *uts)
 {
-   int num_devices = 7;
+   int num_devices = 8;
struct udevice *bus;
struct uclass *uc;
 
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 79b1f1d..3da384f 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -84,6 +84,25 @@ U_BOOT_DRIVER(testfdt_drv) = {
.platdata_auto_alloc_size = sizeof(struct dm_test_pdata),
 };
 
+static const struct udevice_id testfdt1_ids[] = {
+   {
+   .compatible = "denx,u-boot-fdt-test1",
+   .data = DM_TEST_TYPE_FIRST },
+   { }
+};
+
+U_BOOT_DRIVER(testfdt1_drv) = {
+   .name   = "testfdt1_drv",
+   .of_match   = testfdt1_ids,
+   .id = UCLASS_TEST_FDT,
+   .ofdata_to_platdata = testfdt_ofdata_to_platdata,
+   .probe  = testfdt_drv_probe,
+   .ops= _ops,
+   .priv_auto_alloc_size = sizeof(struct dm_test_priv),
+   .platdata_auto_alloc_size = sizeof(struct dm_test_pdata),
+   .flags = DM_FLAG_PRE_RELOC,
+};
+
 /* From here is the testfdt uclass code */
 int testfdt_ping(struct udevice *dev, int pingval, int *pingret)
 {
@@ -168,7 +187,7 @@ int dm_check_devices(struct unit_test_state *uts, int 
num_devices)
 /* Test that FDT-based binding works correctly */
 static int dm_test_fdt(struct unit_test_state *uts)
 {
-   const int num_devices = 7;
+   const int num_devices = 8;
struct udevice *dev;
struct uclass *uc;
int ret;
@@ -208,8 +227,12 @@ static int dm_test_fdt_pre_reloc(struct unit_test_state 
*uts)
ret = uclass_get(UCLASS_TEST_FDT, );
ut_assert(!ret);
 
-   /* These is only one pre-reloc device */
-   ut_asserteq(1, list_count_items(>dev_head));
+   /*
+* These are 2 pre-reloc devices:
+* one with "u-boot,dm-pre-reloc" property (a-test node), and the other
+* one whose driver marked with DM_FLAG_PRE_RELOC flag (h-test node).
+*/
+   ut_asserteq(2, list_count_items(>dev_head));
 
return 0;
 }
-- 
2.7.4

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


[U-Boot] [PATCH 2/8] cpu: mpc83xx: Remove unnecessary characters in the description string

2018-10-06 Thread Bin Meng
The description string should not contain unnecessary characters,
like the ending '\n' or the leading 'CPU:'.

Signed-off-by: Bin Meng 
---

 drivers/cpu/mpc83xx_cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpu/mpc83xx_cpu.c b/drivers/cpu/mpc83xx_cpu.c
index 31717af..7bc86bf 100644
--- a/drivers/cpu/mpc83xx_cpu.c
+++ b/drivers/cpu/mpc83xx_cpu.c
@@ -262,7 +262,7 @@ static int mpc83xx_cpu_get_desc(struct udevice *dev, char 
*buf, int size)
determine_cpu_data(dev);
 
snprintf(buf, size,
-"CPU:   %s, MPC%s%s%s, Rev: %d.%d at %s MHz, CSB: %s MHz\n",
+"%s, MPC%s%s%s, Rev: %d.%d at %s MHz, CSB: %s MHz",
 e300_names[priv->e300_type],
 cpu_type_names[priv->type],
 priv->is_e_processor ? "E" : "",
-- 
2.7.4

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


[U-Boot] [PATCH 5/8] dm: Correct pre_reloc_only parameter description in several APIs' comments

2018-10-06 Thread Bin Meng
The pre_reloc_only parameter description currently only mentions
drivers with the DM_FLAG_PRE_RELOC flag, but does not mention the
special device tree properties. Correct them.

Signed-off-by: Bin Meng 
---

 include/dm/device-internal.h |  4 ++--
 include/dm/lists.h   |  4 ++--
 include/dm/root.h| 17 +
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
index 02ac4c7..ee2b24a 100644
--- a/include/dm/device-internal.h
+++ b/include/dm/device-internal.h
@@ -74,8 +74,8 @@ int device_bind_with_driver_data(struct udevice *parent,
  * tree.
  *
  * @parent: Pointer to device's parent
- * @pre_reloc_only: If true, bind the driver only if its DM_INIT_F flag is set.
- * If false bind the driver always.
+ * @pre_reloc_only: If true, bind the driver only if its DM_FLAG_PRE_RELOC flag
+ * is set. If false bind the driver always.
  * @info: Name and platdata for this device
  * @devp: if non-NULL, returns a pointer to the bound device
  * @return 0 if OK, -ve on error
diff --git a/include/dm/lists.h b/include/dm/lists.h
index 59094d7..810e244 100644
--- a/include/dm/lists.h
+++ b/include/dm/lists.h
@@ -39,8 +39,8 @@ struct uclass_driver *lists_uclass_lookup(enum uclass_id id);
  * each one. The devices will have @parent as their parent.
  *
  * @parent: parent device (root)
- * @early_only: If true, bind only drivers with the DM_INIT_F flag. If false
- * bind all drivers.
+ * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC flag.
+ * If false bind all drivers.
  */
 int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only);
 
diff --git a/include/dm/root.h b/include/dm/root.h
index 2b9c6da..c8d629b 100644
--- a/include/dm/root.h
+++ b/include/dm/root.h
@@ -48,8 +48,8 @@ int dm_scan_platdata(bool pre_reloc_only);
  * the top-level subnodes are examined.
  *
  * @blob: Pointer to device tree blob
- * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
- * flag. If false bind all drivers.
+ * @pre_reloc_only: If true, bind only nodes with special devicetree 
properties,
+ * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
  * @return 0 if OK, -ve on error
  */
 int dm_scan_fdt(const void *blob, bool pre_reloc_only);
@@ -62,8 +62,8 @@ int dm_scan_fdt(const void *blob, bool pre_reloc_only);
  * of "clocks" node.
  *
  * @blob: Pointer to device tree blob
- * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
- * flag. If false bind all drivers.
+ * @pre_reloc_only: If true, bind only nodes with special devicetree 
properties,
+ * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
  * @return 0 if OK, -ve on error
  */
 int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only);
@@ -76,8 +76,9 @@ int dm_extended_scan_fdt(const void *blob, bool 
pre_reloc_only);
  * programmaticaly. They should do this by calling device_bind() on each
  * device.
  *
- * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
- * flag. If false bind all drivers.
+ * @pre_reloc_only: If true, bind only nodes with special devicetree 
properties,
+ * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
+ * @return 0 if OK, -ve on error
  */
 int dm_scan_other(bool pre_reloc_only);
 
@@ -88,8 +89,8 @@ int dm_scan_other(bool pre_reloc_only);
  * then scans and binds available devices from platform data and the FDT.
  * This calls dm_init() to set up Driver Model structures.
  *
- * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
- * flag. If false bind all drivers.
+ * @pre_reloc_only: If true, bind only nodes with special devicetree 
properties,
+ * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
  * @return 0 if OK, -ve on error
  */
 int dm_init_and_scan(bool pre_reloc_only);
-- 
2.7.4

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


[U-Boot] [PATCH 6/8] dm: core: Mirror the chosen node parse logic in the livetree scanning

2018-10-06 Thread Bin Meng
Commit f2006808f099: ("dm: core: parse chosen node") added a logic
to parse the chosen node during dm_scan_fdt_node(), but unfortunately
it missed adding the same logic in dm_scan_fdt_live(). This mirrors
the logic in the livetree version.

The weird thing is that commit f2006808f099 did update the test case
to test such logic, but I have no idea how the test case could pass.

With this fix, the following 2 test cases now pass:

Test: dm_test_bus_children: bus.c
test/dm/bus.c:112, dm_test_bus_children(): num_devices ==
list_count_items(>dev_head): Expected 7, got 6

Test: dm_test_fdt: test-fdt.c
test/dm/test-fdt.c:184, dm_test_fdt(): num_devices ==
list_count_items(>dev_head): Expected 7, got 6

Fixes: f2006808f099 ("dm: core: parse chosen node")
Signed-off-by: Bin Meng 
---

 drivers/core/root.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/core/root.c b/drivers/core/root.c
index f918ee1..535084e 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -222,6 +222,16 @@ static int dm_scan_fdt_live(struct udevice *parent,
int ret = 0, err;
 
for (np = node_parent->child; np; np = np->sibling) {
+   /* "chosen" node isn't a device itself but may contain some: */
+   if (!strcmp(np->name, "chosen")) {
+   pr_debug("parsing subnodes of \"chosen\"\n");
+
+   err = dm_scan_fdt_live(parent, np, pre_reloc_only);
+   if (err && !ret)
+   ret = err;
+   continue;
+   }
+
if (!of_device_is_available(np)) {
pr_debug("   - ignoring disabled device\n");
continue;
-- 
2.7.4

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


[U-Boot] [PATCH 3/8] dm: util: Add a livetree equivalent API of dm_fdt_pre_reloc()

2018-10-06 Thread Bin Meng
This adds a new API dm_ofnode_pre_reloc(), a livetree equivalent
API of dm_fdt_pre_reloc().

Signed-off-by: Bin Meng 
---

 drivers/core/util.c | 25 +
 include/dm/util.h   | 27 ++-
 2 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/drivers/core/util.c b/drivers/core/util.c
index 451d476..27a6848 100644
--- a/drivers/core/util.c
+++ b/drivers/core/util.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -53,3 +54,27 @@ bool dm_fdt_pre_reloc(const void *blob, int offset)
 
return false;
 }
+
+bool dm_ofnode_pre_reloc(ofnode node)
+{
+   if (ofnode_read_bool(node, "u-boot,dm-pre-reloc"))
+   return true;
+
+#ifdef CONFIG_TPL_BUILD
+   if (ofnode_read_bool(node, "u-boot,dm-tpl"))
+   return true;
+#elif defined(CONFIG_SPL_BUILD)
+   if (ofnode_read_bool(node, "u-boot,dm-spl"))
+   return true;
+#else
+   /*
+* In regular builds individual spl and tpl handling both
+* count as handled pre-relocation for later second init.
+*/
+   if (ofnode_read_bool(node, "u-boot,dm-spl") ||
+   ofnode_read_bool(node, "u-boot,dm-tpl"))
+   return true;
+#endif
+
+   return false;
+}
diff --git a/include/dm/util.h b/include/dm/util.h
index 898822e..9ff6531 100644
--- a/include/dm/util.h
+++ b/include/dm/util.h
@@ -55,7 +55,7 @@ static inline void dm_dump_devres(void)
  * There are 3 settings currently in use
  * -
  * - u-boot,dm-pre-reloc: legacy and indicates any of TPL or SPL
- *   Existing platforms only use it to indicate nodes needee in
+ *   Existing platforms only use it to indicate nodes needed in
  *   SPL. Should probably be replaced by u-boot,dm-spl for
  *   existing platforms.
  * @blob: devicetree
@@ -65,4 +65,29 @@ static inline void dm_dump_devres(void)
  */
 bool dm_fdt_pre_reloc(const void *blob, int offset);
 
+/**
+ * Check if an of node should be or was bound before relocation.
+ *
+ * Devicetree nodes can be marked as needed to be bound
+ * in the loader stages via special devicetree properties.
+ *
+ * Before relocation this function can be used to check if nodes
+ * are required in either SPL or TPL stages.
+ *
+ * After relocation and jumping into the real U-Boot binary
+ * it is possible to determine if a node was bound in one of
+ * SPL/TPL stages.
+ *
+ * There are 3 settings currently in use
+ * -
+ * - u-boot,dm-pre-reloc: legacy and indicates any of TPL or SPL
+ *   Existing platforms only use it to indicate nodes needed in
+ *   SPL. Should probably be replaced by u-boot,dm-spl for
+ *   existing platforms.
+ * @node: of node
+ *
+ * Returns true if node is needed in SPL/TL, false otherwise.
+ */
+bool dm_ofnode_pre_reloc(ofnode node);
+
 #endif
-- 
2.7.4

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


[U-Boot] [PATCH 1/8] dm: cpu: Fix print_cpuinfo() output

2018-10-06 Thread Bin Meng
Current output of print_cpuinfo() does not have an ending '\n',
neither have a leading 'CPU:' like others. However previously
this used to work on QEMU x86 targets.

It turns out commit c0434407b595 introduced a unified DM version
of print_cpuinfo() that exposed such issue.

Fixes: c0434407b595 ("board_f: Use static print_cpuinfo if CONFIG_CPU is 
active")
Signed-off-by: Bin Meng 
---

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

diff --git a/common/board_f.c b/common/board_f.c
index 213d044..96503ff 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -187,7 +187,7 @@ static int print_cpuinfo(void)
return ret;
}
 
-   printf("%s", desc);
+   printf("CPU:   %s\n", desc);
 
return 0;
 }
-- 
2.7.4

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


[U-Boot] [PATCH 0/8] dm: Various fixes in dm core/cpu/timer

2018-10-06 Thread Bin Meng
This fixed several issues identified in dm core/cpu/timer codes.

The issues were found during RISC-V cpu/timer driver development
for QEMU RISC-V port.

This series is available at u-boot-x86/dm-fixes for testing.


Bin Meng (8):
  dm: cpu: Fix print_cpuinfo() output
  cpu: mpc83xx: Remove unnecessary characters in the description string
  dm: util: Add a livetree equivalent API of dm_fdt_pre_reloc()
  dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in
lists_bind_fdt()
  dm: Correct pre_reloc_only parameter description in several APIs'
comments
  dm: core: Mirror the chosen node parse logic in the livetree scanning
  test: dm: core: Add a test case for driver marked with
DM_FLAG_PRE_RELOC flag
  timer: Sort Kconfig driver entries

 arch/sandbox/dts/test.dts  |   4 ++
 common/board_f.c   |   2 +-
 drivers/core/lists.c   |   9 +++-
 drivers/core/root.c|  20 +---
 drivers/core/util.c|  25 ++
 drivers/cpu/mpc83xx_cpu.c  |   2 +-
 drivers/serial/serial-uclass.c |   2 +-
 drivers/timer/Kconfig  | 110 -
 drivers/timer/timer-uclass.c   |   2 +-
 include/dm/device-internal.h   |   4 +-
 include/dm/lists.h |   9 ++--
 include/dm/root.h  |  17 ---
 include/dm/util.h  |  27 +-
 test/dm/bus.c  |   2 +-
 test/dm/test-fdt.c |  29 +--
 15 files changed, 179 insertions(+), 85 deletions(-)

-- 
2.7.4

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


Re: [U-Boot] [PATCH] spl: ram: Fix u_boot_pos calculation

2018-10-06 Thread Simon Goldschmidt

On 04.10.2018 09:29, Michal Simek wrote:

The patch:
"spl: Weed out CONFIG_SYS_TEXT_BASE usage"
(sha1: 04ce5427bd3914cab8be78513275a20ab878520a)
introduced bug where assigning to u_boot_pos variable wasn't done
which end up in situation where SPL wasn't able to find out
image on the selected address.

Signed-off-by: Michal Simek 


I needed to apply this to boot my socfpga cyclone5 from FPGA (both SPL 
and U-Boot in FPGA onchip RAM).


Tested-by: Simon Goldschmidt 


---

Lines are unfortunatelly longer then 80 char limits but
there is no nice way how to fix it.

---
  common/spl/spl_ram.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/common/spl/spl_ram.c b/common/spl/spl_ram.c
index 619b39a53748..5fcc3b1504bb 100644
--- a/common/spl/spl_ram.c
+++ b/common/spl/spl_ram.c
@@ -63,9 +63,8 @@ static int spl_ram_load_image(struct spl_image_info 
*spl_image,
 * No binman support or no information. For now, fix it
 * to the address pointed to by U-Boot.
 */
-   header = spl_get_load_buffer(-sizeof(*header),
-sizeof(*header));
-
+   u_boot_pos = 
(ulong)spl_get_load_buffer(-sizeof(*header),
+   
sizeof(*header));
}
header = (struct image_header *)map_sysmem(u_boot_pos, 0);
  



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


[U-Boot] [PATCH] sunxi: fix DRAM gate/reset sequence of H6

2018-10-06 Thread Icenowy Zheng
Currently the DRAM bus gate and reset is changed at the same time in
H6 DRAM initialization code, which disobeys the user manual's
programming guide.

Fix the sequence by follow the sequence suggested by the user manual
(ungate the bus clock after release the reset signal).

By some experiments it seems to fix the DRAM size detection failure that
rarely happens.

Signed-off-by: Icenowy Zheng 
---
 arch/arm/mach-sunxi/dram_sun50i_h6.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-sunxi/dram_sun50i_h6.c 
b/arch/arm/mach-sunxi/dram_sun50i_h6.c
index 6b94cf38c5..5da90a2835 100644
--- a/arch/arm/mach-sunxi/dram_sun50i_h6.c
+++ b/arch/arm/mach-sunxi/dram_sun50i_h6.c
@@ -299,6 +299,8 @@ static void mctl_sys_init(struct dram_para *para)
 
/* Put all DRAM-related blocks to reset state */
clrbits_le32(>mbus_cfg, MBUS_ENABLE | MBUS_RESET);
+   clrbits_le32(>dram_gate_reset, BIT(0));
+   udelay(5);
writel(0, >dram_gate_reset);
clrbits_le32(>pll5_cfg, CCM_PLL5_CTRL_EN);
clrbits_le32(>dram_clk_cfg, DRAM_MOD_RESET);
@@ -313,7 +315,9 @@ static void mctl_sys_init(struct dram_para *para)
/* Configure DRAM mod clock */
writel(DRAM_CLK_SRC_PLL5, >dram_clk_cfg);
setbits_le32(>dram_clk_cfg, DRAM_CLK_UPDATE);
-   writel(BIT(0) | BIT(RESET_SHIFT), >dram_gate_reset);
+   writel(BIT(RESET_SHIFT), >dram_gate_reset);
+   udelay(5);
+   setbits_le32(>dram_gate_reset, BIT(0));
 
/* Disable all channels */
writel(0, _com->maer0);
-- 
2.18.0

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


Re: [U-Boot] [PATCH] Revert "fdt: fdtdec_setup_memory_banksize() use livetree"

2018-10-06 Thread Patrice CHOTARD
Hi

I got same issue on STM32F746

Patrice

On 10/04/2018 09:24 AM, Michal Simek wrote:
> This reverts commit c35a7d375ec8f0a8ee343ae4868be3242172632e.
> This commit is breaking SPL on zc706.
> 
> Signed-off-by: Michal Simek 
> ---
> 
>  lib/fdtdec.c | 44 +++-
>  1 file changed, 23 insertions(+), 21 deletions(-)
> 
> diff --git a/lib/fdtdec.c b/lib/fdtdec.c
> index 74196ce7f9f7..bf5e0f6a57c0 100644
> --- a/lib/fdtdec.c
> +++ b/lib/fdtdec.c
> @@ -15,7 +15,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  
>  DECLARE_GLOBAL_DATA_PTR;
> @@ -1182,34 +1181,41 @@ int fdtdec_setup_mem_size_base(void)
>  
>  #if defined(CONFIG_NR_DRAM_BANKS)
>  
> -static ofnode get_next_memory_node(ofnode mem)
> +static int get_next_memory_node(const void *blob, int mem)
>  {
>   do {
> - mem = ofnode_by_prop_value(mem, "device_type", "memory", 7);
> - } while (ofnode_valid(mem) && !ofnode_is_available(mem));
> + mem = fdt_node_offset_by_prop_value(gd->fdt_blob, mem,
> + "device_type", "memory", 7);
> + } while (!fdtdec_get_is_enabled(blob, mem));
>  
>   return mem;
>  }
>  
>  int fdtdec_setup_memory_banksize(void)
>  {
> - int bank, reg = 0;
> - struct resource res;
> - ofnode mem;
> + int bank, ret, mem, reg = 0;
> + struct fdt_resource res;
>  
> - mem = get_next_memory_node(ofnode_null());
> - if (!ofnode_valid(mem))
> - goto missing_node;
> + mem = get_next_memory_node(gd->fdt_blob, -1);
> + if (mem < 0) {
> + debug("%s: Missing /memory node\n", __func__);
> + return -EINVAL;
> + }
>  
>   for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
> - while (ofnode_read_resource(mem, reg++, )) {
> + ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, );
> + if (ret == -FDT_ERR_NOTFOUND) {
>   reg = 0;
> - mem = get_next_memory_node(mem);
> - if (!ofnode_valid(mem)) {
> - if (bank)
> - return 0;
> - goto missing_node;
> - }
> + mem = get_next_memory_node(gd->fdt_blob, mem);
> + if (mem == -FDT_ERR_NOTFOUND)
> + break;
> +
> + ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, 
> );
> + if (ret == -FDT_ERR_NOTFOUND)
> + break;
> + }
> + if (ret != 0) {
> + return -EINVAL;
>   }
>  
>   gd->bd->bi_dram[bank].start = (phys_addr_t)res.start;
> @@ -1223,10 +1229,6 @@ int fdtdec_setup_memory_banksize(void)
>   }
>  
>   return 0;
> -
> -missing_node:
> - debug("%s: Missing /memory node\n", __func__);
> - return -EINVAL;
>  }
>  #endif
>  
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] 4 failures with 'ut dm'

2018-10-06 Thread Bin Meng
Hi Simon,

With current u-boot/master, there are 4 failures with 'ut dm'. I was
wondering is this not covered by travis-ci?

Test: dm_test_bus_children: bus.c
test/dm/bus.c:112, dm_test_bus_children(): num_devices ==
list_count_items(>dev_head): Expected 7, got 6

Test: dm_test_fdt: test-fdt.c
test/dm/test-fdt.c:184, dm_test_fdt(): num_devices ==
list_count_items(>dev_head): Expected 7, got 6

Test: dm_test_spmi_access: spmi.c
test/dm/spmi.c:55, dm_test_spmi_access(): 0 == device_get_child(bus,
0, ): Expected 0, got -22

Test: dm_test_spmi_access_peripheral: spmi.c
test/dm/spmi.c:82, dm_test_spmi_access_peripheral(): 0 ==
gpio_lookup_name("spmi1", , , ): Expected 0, got -22

Regards,
Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


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

2018-10-06 Thread Tom Rini
On Fri, Oct 05, 2018 at 11:26:55PM +0200, Marek Vasut wrote:

> The following changes since commit 592cd5defd4f71d34ffcbd8dd3326bc10f662e20:
> 
>   Merge branch 'master' of git://git.denx.de/u-boot-spi (2018-10-02
> 17:01:46 -0400)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-socfpga.git master
> 
> for you to fetch changes up to 8be11fb3c1d8d89ff6b60bd3937efcea2dc9c91d:
> 
>   arm: socfpga: stratix10: add sgmii in phymode setup (2018-10-03
> 12:56:50 +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


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

2018-10-06 Thread Tom Rini
On Fri, Oct 05, 2018 at 11:27:44PM +0200, Marek Vasut wrote:

> The following changes since commit 592cd5defd4f71d34ffcbd8dd3326bc10f662e20:
> 
>   Merge branch 'master' of git://git.denx.de/u-boot-spi (2018-10-02
> 17:01:46 -0400)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-sh.git master
> 
> for you to fetch changes up to 806df252c1dafea0bee40f70f7bae050c07ee0c9:
> 
>   ARM: rmobile: Enable PHY framework on Gen3 (2018-10-03 12:56:13 +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 3/4] sunxi: display: Also use the PWM controller for backlight on sun7i

2018-10-06 Thread Paul Kocialkowski
Using PWM to drive the backlight pin instead of a GPIO provides various
advantages, that are described in commit 421c98d7d2 ("sunxi: display:
Use PWM to drive backlight where applicable").

Defining SUNXI_PWM_PIN0 triggers the configuration of the PWM controller
in the display driver.

Signed-off-by: Paul Kocialkowski 
---
 arch/arm/include/asm/arch-sunxi/pwm.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-sunxi/pwm.h 
b/arch/arm/include/asm/arch-sunxi/pwm.h
index 47eb433fb6..a9588a04f3 100644
--- a/arch/arm/include/asm/arch-sunxi/pwm.h
+++ b/arch/arm/include/asm/arch-sunxi/pwm.h
@@ -15,7 +15,8 @@
 
 #define SUNXI_PWM_PERIOD_80PCT 0x04af03c0
 
-#if defined CONFIG_MACH_SUN4I || defined CONFIG_MACH_SUN5I
+#if defined CONFIG_MACH_SUN4I || defined CONFIG_MACH_SUN5I || \
+defined CONFIG_MACH_SUN7I
 #define SUNXI_PWM_PIN0 SUNXI_GPB(2)
 #define SUNXI_PWM_MUX  SUN4I_GPB_PWM
 #endif
-- 
2.19.0

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


[U-Boot] [PATCH 2/4] sunxi: display: Add support for panels with an active-low DE signal

2018-10-06 Thread Paul Kocialkowski
This introduces a Kconfig option for indicating that the panel requires
the data enable (DE) signal driven low. The associated display flag is
set when converting the mode to display timings. It is later used for
setting the relevant bit in the TCON configuration registers.

This new option is kept separate from the VIDEO_LCD_MODE string because
the string format is expected to be kept in sync with the Linux
framebuffer definitions, that do not include this indication.

Signed-off-by: Paul Kocialkowski 
---
 arch/arm/include/asm/arch-sunxi/lcdc.h | 1 +
 arch/arm/mach-sunxi/Kconfig| 8 
 drivers/video/sunxi/lcdc.c | 2 ++
 drivers/video/sunxi/sunxi_display.c| 4 
 4 files changed, 15 insertions(+)

diff --git a/arch/arm/include/asm/arch-sunxi/lcdc.h 
b/arch/arm/include/asm/arch-sunxi/lcdc.h
index 90216bcfd5..3ce450636a 100644
--- a/arch/arm/include/asm/arch-sunxi/lcdc.h
+++ b/arch/arm/include/asm/arch-sunxi/lcdc.h
@@ -64,6 +64,7 @@ struct sunxi_lcdc_reg {
 #define SUNXI_LCDC_Y(y)(((y) - 1) << 0)
 #define SUNXI_LCDC_TCON_VSYNC_MASK (1 << 24)
 #define SUNXI_LCDC_TCON_HSYNC_MASK (1 << 25)
+#define SUNXI_LCDC_TCON_DE_MASK(1 << 27)
 #define SUNXI_LCDC_CTRL_IO_MAP_MASK(1 << 0)
 #define SUNXI_LCDC_CTRL_IO_MAP_TCON0   (0 << 0)
 #define SUNXI_LCDC_CTRL_IO_MAP_TCON1   (1 << 0)
diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index b868f0e350..a9fe3e4ab5 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -771,6 +771,14 @@ config VIDEO_LCD_DCLK_PHASE
---help---
Select LCD panel display clock phase shift, range 0-3.
 
+config VIDEO_LCD_DE_LOW
+   bool "LCD panel active-low data enable signal"
+   depends on VIDEO_SUNXI
+   default n
+   ---help---
+   Make the data enable signal active-low when driving the LCD panel.
+   This should only be enabled if the panel actually needs it.
+
 config VIDEO_LCD_POWER
string "LCD panel power enable pin"
depends on VIDEO_SUNXI
diff --git a/drivers/video/sunxi/lcdc.c b/drivers/video/sunxi/lcdc.c
index ef851070b2..abcef81a45 100644
--- a/drivers/video/sunxi/lcdc.c
+++ b/drivers/video/sunxi/lcdc.c
@@ -135,6 +135,8 @@ void lcdc_tcon0_mode_set(struct sunxi_lcdc_reg * const lcdc,
val |= SUNXI_LCDC_TCON_HSYNC_MASK;
if (mode->flags & DISPLAY_FLAGS_VSYNC_HIGH)
val |= SUNXI_LCDC_TCON_VSYNC_MASK;
+   if (mode->flags & DISPLAY_FLAGS_DE_LOW)
+   val |= SUNXI_LCDC_TCON_DE_MASK;
 
 #ifdef CONFIG_VIDEO_VGA_VIA_LCD_FORCE_SYNC_ACTIVE_HIGH
if (for_ext_vga_dac)
diff --git a/drivers/video/sunxi/sunxi_display.c 
b/drivers/video/sunxi/sunxi_display.c
index 5c8f88c42f..4baefee070 100644
--- a/drivers/video/sunxi/sunxi_display.c
+++ b/drivers/video/sunxi/sunxi_display.c
@@ -637,6 +637,10 @@ static void sunxi_ctfb_mode_to_display_timing(const struct 
ctfb_res_modes *mode,
timing->flags |= DISPLAY_FLAGS_VSYNC_LOW;
if (mode->vmode == FB_VMODE_INTERLACED)
timing->flags |= DISPLAY_FLAGS_INTERLACED;
+
+#ifdef CONFIG_VIDEO_LCD_DE_LOW
+   timing->flags |= DISPLAY_FLAGS_DE_LOW;
+#endif
 }
 
 static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode,
-- 
2.19.0

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


[U-Boot] [PATCH 4/4] sunxi: Add defconfig for the BananaPi with BL035 LCD module

2018-10-06 Thread Paul Kocialkowski
This introduces a new defconfig for the BananaPi, which includes support
for the BL035 LCD module distributed by Lemaker for use with this board.

Signed-off-by: Paul Kocialkowski 
---
 configs/Bananapi_LCD_BL035_defconfig | 29 
 1 file changed, 29 insertions(+)
 create mode 100644 configs/Bananapi_LCD_BL035_defconfig

diff --git a/configs/Bananapi_LCD_BL035_defconfig 
b/configs/Bananapi_LCD_BL035_defconfig
new file mode 100644
index 00..b0a8fb9099
--- /dev/null
+++ b/configs/Bananapi_LCD_BL035_defconfig
@@ -0,0 +1,29 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_SPL=y
+CONFIG_MACH_SUN7I=y
+CONFIG_DRAM_CLK=432
+CONFIG_MACPWR="PH23"
+CONFIG_VIDEO_COMPOSITE=y
+CONFIG_VIDEO_LCD_MODE="x:320,y:240,depth:24,pclk_khz:7000,le:38,ri:20,up:15,lo:4,hs:30,vs:3,sync:0,vmode:0"
+CONFIG_VIDEO_LCD_DE_LOW=y
+CONFIG_VIDEO_LCD_POWER="PH12"
+CONFIG_VIDEO_LCD_BL_EN="PH8"
+CONFIG_VIDEO_LCD_BL_PWM="PB2"
+# CONFIG_VIDEO_LCD_BL_PWM_ACTIVE_LOW is not set
+CONFIG_GMAC_TX_DELAY=3
+CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-bananapi"
+CONFIG_AHCI=y
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SPL_I2C_SUPPORT=y
+# CONFIG_CMD_FLASH is not set
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_NETCONSOLE=y
+CONFIG_SCSI_AHCI=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_RGMII=y
+CONFIG_SUN7I_GMAC=y
+CONFIG_SCSI=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
-- 
2.19.0

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


[U-Boot] [PATCH 1/4] sunxi: display: Fix h/vsync TCON polarity bits to indicate active-high

2018-10-06 Thread Paul Kocialkowski
Contrary to what is implemented in the Linux kernel, the U-Boot driver
supporting the sunxi TCON was assuming that the TCON0_IO_POL bits
indicate active-low signals when set for the hsync and vsync signals.

After looking at it with a logic analyzer, it appears that the signals
are active-low with the bits unset and active-high with the bits set.

Fix this by looking for the right flag (high instead of low) and
inverting the sync bits in the VIDEO_LCD_MODE declarations.

Signed-off-by: Paul Kocialkowski 
---
 configs/A33-OLinuXino_defconfig   | 2 +-
 configs/Ainol_AW1_defconfig   | 2 +-
 configs/Ampe_A76_defconfig| 2 +-
 configs/Chuwi_V7_CW0825_defconfig | 2 +-
 configs/Colombus_defconfig| 2 +-
 configs/Empire_electronix_d709_defconfig  | 2 +-
 configs/Empire_electronix_m712_defconfig  | 2 +-
 configs/Hyundai_A7HD_defconfig| 2 +-
 configs/MSI_Primo73_defconfig | 2 +-
 configs/MSI_Primo81_defconfig | 2 +-
 configs/Sinlinx_SinA33_defconfig  | 2 +-
 configs/UTOO_P66_defconfig| 2 +-
 configs/Wexler_TAB7200_defconfig  | 2 +-
 configs/Wits_Pro_A20_DKT_defconfig| 2 +-
 configs/Yones_Toptech_BD1078_defconfig| 2 +-
 configs/Yones_Toptech_BS1078_V2_defconfig | 2 +-
 configs/colorfly_e708_q1_defconfig| 2 +-
 configs/difrnce_dit4350_defconfig | 2 +-
 configs/dserve_dsrv9703c_defconfig| 2 +-
 configs/ga10h_v1_1_defconfig  | 2 +-
 configs/gt90h_v4_defconfig| 2 +-
 configs/iNet_3F_defconfig | 2 +-
 configs/iNet_3W_defconfig | 2 +-
 configs/iNet_86VS_defconfig   | 2 +-
 configs/iNet_D978_rev2_defconfig  | 2 +-
 configs/icnova-a20-swac_defconfig | 2 +-
 configs/inet1_defconfig   | 2 +-
 configs/inet86dz_defconfig| 2 +-
 configs/inet97fv2_defconfig   | 2 +-
 configs/inet98v_rev2_defconfig| 2 +-
 configs/inet9f_rev03_defconfig| 2 +-
 configs/inet_q972_defconfig   | 2 +-
 configs/polaroid_mid2407pxe03_defconfig   | 2 +-
 configs/polaroid_mid2809pxe04_defconfig   | 2 +-
 configs/pov_protab2_ips9_defconfig| 2 +-
 configs/q8_a13_tablet_defconfig   | 2 +-
 configs/q8_a23_tablet_800x480_defconfig   | 2 +-
 configs/q8_a33_tablet_1024x600_defconfig  | 2 +-
 configs/q8_a33_tablet_800x480_defconfig   | 2 +-
 configs/sunxi_Gemei_G9_defconfig  | 2 +-
 drivers/video/sunxi/lcdc.c| 4 ++--
 41 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/configs/A33-OLinuXino_defconfig b/configs/A33-OLinuXino_defconfig
index 744e7ef511..e456703be7 100644
--- a/configs/A33-OLinuXino_defconfig
+++ b/configs/A33-OLinuXino_defconfig
@@ -10,7 +10,7 @@ CONFIG_USB0_VBUS_PIN="AXP0-VBUS-ENABLE"
 CONFIG_USB0_VBUS_DET="AXP0-VBUS-DETECT"
 CONFIG_USB0_ID_DET="PB3"
 CONFIG_AXP_GPIO=y
-CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:16,ri:209,up:22,lo:22,hs:30,vs:1,sync:3,vmode:0"
+CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:16,ri:209,up:22,lo:22,hs:30,vs:1,sync:0,vmode:0"
 CONFIG_VIDEO_LCD_DCLK_PHASE=0
 CONFIG_VIDEO_LCD_BL_EN="PB2"
 CONFIG_VIDEO_LCD_BL_PWM="PH0"
diff --git a/configs/Ainol_AW1_defconfig b/configs/Ainol_AW1_defconfig
index 3e47ca2466..0d449cc53d 100644
--- a/configs/Ainol_AW1_defconfig
+++ b/configs/Ainol_AW1_defconfig
@@ -8,7 +8,7 @@ CONFIG_MMC0_CD_PIN="PH1"
 CONFIG_USB0_VBUS_PIN="PB9"
 CONFIG_USB0_VBUS_DET="AXP0-VBUS-DETECT"
 CONFIG_AXP_GPIO=y
-CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:4,le:87,ri:112,up:38,lo:141,hs:1,vs:1,sync:3,vmode:0"
+CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:4,le:87,ri:112,up:38,lo:141,hs:1,vs:1,sync:0,vmode:0"
 CONFIG_VIDEO_LCD_POWER="PH8"
 CONFIG_VIDEO_LCD_BL_EN="PH7"
 CONFIG_VIDEO_LCD_BL_PWM="PB2"
diff --git a/configs/Ampe_A76_defconfig b/configs/Ampe_A76_defconfig
index b0d6047789..1e18458179 100644
--- a/configs/Ampe_A76_defconfig
+++ b/configs/Ampe_A76_defconfig
@@ -9,7 +9,7 @@ CONFIG_USB0_VBUS_DET="PG1"
 CONFIG_USB0_ID_DET="PG2"
 CONFIG_AXP_GPIO=y
 # CONFIG_VIDEO_HDMI is not set
-CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:45,ri:82,up:22,lo:22,hs:1,vs:1,sync:3,vmode:0"
+CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:45,ri:82,up:22,lo:22,hs:1,vs:1,sync:0,vmode:0"
 CONFIG_VIDEO_LCD_POWER="AXP0-0"
 CONFIG_VIDEO_LCD_BL_EN="AXP0-1"
 CONFIG_VIDEO_LCD_BL_PWM="PB2"
diff --git a/configs/Chuwi_V7_CW0825_defconfig 
b/configs/Chuwi_V7_CW0825_defconfig
index 645a759fc2..e08d1ac3cc 100644
--- a/configs/Chuwi_V7_CW0825_defconfig
+++ b/configs/Chuwi_V7_CW0825_defconfig
@@ -7,7 +7,7 @@ CONFIG_DRAM_EMR1=4
 CONFIG_USB0_VBUS_PIN="PB9"
 CONFIG_USB0_VBUS_DET="PH5"
 CONFIG_USB0_ID_DET="PH4"
-CONFIG_VIDEO_LCD_MODE="x:1024,y:768,depth:24,pclk_khz:51000,le:19,ri:300,up:6,lo:31,hs:1,vs:1,sync:3,vmode:0"

Re: [U-Boot] [PATCH 1/1] efi_loader: set image_base and image_size to correct values

2018-10-06 Thread Heinrich Schuchardt
On 10/06/2018 09:51 AM, Heinrich Schuchardt wrote:
> On 09/30/2018 07:26 AM, Heinrich Schuchardt wrote:
>> From: AKASHI Takahiro 
>>
>> Currently, image's image_base points to an address where the image was
>> temporarily uploaded for further loading. Since efi_loader relocates
>> the image to final destination, image_base and image_size should reflect
>> that.
>>
>> This bug was detected in UEFI SCT, "Loaded Image Protocol Test - test 2,"
>> which shows that 'Unload' function doesn't fit into a range suggested by
>> image_base and image_size.
>>  TestCase/UEFI/EFI/Protocol/LoadedImage/BlackBoxTest/
>>  LoadedImageBBTestMain.c:1002
>>
>> This patch also reverts a patch, "efi_loader: save image relocation address
>> and size" since newly added fields are no longer needed.
>>
>> Signed-off-by: AKASHI Takahiro 
>>
>> Rebase the patch. Keep the relocation address in struct efi_image_object.
>> We will use the address to free the image in UnloadImage.
>>
>> Signed-off-by: Heinrich Schuchardt 
>> ---
>>  lib/efi_loader/efi_image_loader.c | 7 ++-
>>  1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> diff --git a/lib/efi_loader/efi_image_loader.c 
>> b/lib/efi_loader/efi_image_loader.c
>> index a18ce0a5705..39902152f3c 100644
>> --- a/lib/efi_loader/efi_image_loader.c
>> +++ b/lib/efi_loader/efi_image_loader.c
>> @@ -212,7 +212,6 @@ void *efi_load_pe(struct efi_loaded_image_obj *handle, 
>> void *efi,
>>  int rel_idx = IMAGE_DIRECTORY_ENTRY_BASERELOC;
>>  void *entry;
>>  uint64_t image_base;
>> -uint64_t image_size;
>>  unsigned long virt_size = 0;
>>  int supported = 0;
>>  
>> @@ -256,7 +255,6 @@ void *efi_load_pe(struct efi_loaded_image_obj *handle, 
>> void *efi,
>>  IMAGE_NT_HEADERS64 *nt64 = (void *)nt;
>>  IMAGE_OPTIONAL_HEADER64 *opt = >OptionalHeader;
>>  image_base = opt->ImageBase;
>> -image_size = opt->SizeOfImage;
>>  efi_set_code_and_data_type(loaded_image_info, opt->Subsystem);
>>  efi_reloc = efi_alloc(virt_size,
>>loaded_image_info->image_code_type);
>> @@ -272,7 +270,6 @@ void *efi_load_pe(struct efi_loaded_image_obj *handle, 
>> void *efi,
>>  } else if (nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
>>  IMAGE_OPTIONAL_HEADER32 *opt = >OptionalHeader;
>>  image_base = opt->ImageBase;
>> -image_size = opt->SizeOfImage;
>>  efi_set_code_and_data_type(loaded_image_info, opt->Subsystem);
>>  efi_reloc = efi_alloc(virt_size,
>>loaded_image_info->image_code_type);
>> @@ -315,10 +312,10 @@ void *efi_load_pe(struct efi_loaded_image_obj *handle, 
>> void *efi,
>>  invalidate_icache_all();
>>  
>>  /* Populate the loaded image interface bits */
>> -loaded_image_info->image_base = efi;
>> -loaded_image_info->image_size = image_size;
>>  handle->reloc_base = efi_reloc;
>>  handle->reloc_size = virt_size;
>> +loaded_image_info->image_base = efi_reloc;
>> +loaded_image_info->image_size = virt_size;
>>  
>>  return entry;
>>  }
>>
> 
> With this patch GRUB is not able to load the modules which are included
> in grubaa64.efi
> 
> ## Starting EFI application at 4040 ...
> error: unknown filesystem.
> Entering rescue mode...
> grub rescue>
> 
> Function grub_efi_modules_addr() expects image_base to point to the
> unrelocated image:
> 
>   header = image->image_base;
>   coff_header = &(header->coff_header);
>   sections
> = (struct grub_pe32_section_table *) ((char *) coff_header
>   + sizeof (*coff_header)
>   +
> coff_header->optional_header_size);
> 
> The UEFI SCT II specifcation test 5.3.1.1.11 requires
> 
> Check on Application Images which have Unload function.
> Unload field should be valid and its entry address should be within
> the range of [ImageBase, ImageBase+ImageSize]
> 
> @Leif
> Any idea how to sort this out?
> 
> Best regards
> 
> Heinrich
> 

@Alex:

Why did you decide to copy all loaded image sections before relocation?
Couldn't we just apply the relocations in-situ?

When LoadImage() is called for a file path we always assign new memory.
To stay consistent when LoadImage() is called for a memory image we
should copy it. Then in both cases in-situ relocation will not mess up
the source of the loaded image. And in both cases we own the malloc()ed
memory location and can free() it on Unload() or Exit() in case of an
application.

Best regards

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


Re: [U-Boot] [PATCH 1/1] efi_loader: set image_base and image_size to correct values

2018-10-06 Thread Heinrich Schuchardt
On 09/30/2018 07:26 AM, Heinrich Schuchardt wrote:
> From: AKASHI Takahiro 
> 
> Currently, image's image_base points to an address where the image was
> temporarily uploaded for further loading. Since efi_loader relocates
> the image to final destination, image_base and image_size should reflect
> that.
> 
> This bug was detected in UEFI SCT, "Loaded Image Protocol Test - test 2,"
> which shows that 'Unload' function doesn't fit into a range suggested by
> image_base and image_size.
>   TestCase/UEFI/EFI/Protocol/LoadedImage/BlackBoxTest/
>   LoadedImageBBTestMain.c:1002
> 
> This patch also reverts a patch, "efi_loader: save image relocation address
> and size" since newly added fields are no longer needed.
> 
> Signed-off-by: AKASHI Takahiro 
> 
> Rebase the patch. Keep the relocation address in struct efi_image_object.
> We will use the address to free the image in UnloadImage.
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
>  lib/efi_loader/efi_image_loader.c | 7 ++-
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/efi_loader/efi_image_loader.c 
> b/lib/efi_loader/efi_image_loader.c
> index a18ce0a5705..39902152f3c 100644
> --- a/lib/efi_loader/efi_image_loader.c
> +++ b/lib/efi_loader/efi_image_loader.c
> @@ -212,7 +212,6 @@ void *efi_load_pe(struct efi_loaded_image_obj *handle, 
> void *efi,
>   int rel_idx = IMAGE_DIRECTORY_ENTRY_BASERELOC;
>   void *entry;
>   uint64_t image_base;
> - uint64_t image_size;
>   unsigned long virt_size = 0;
>   int supported = 0;
>  
> @@ -256,7 +255,6 @@ void *efi_load_pe(struct efi_loaded_image_obj *handle, 
> void *efi,
>   IMAGE_NT_HEADERS64 *nt64 = (void *)nt;
>   IMAGE_OPTIONAL_HEADER64 *opt = >OptionalHeader;
>   image_base = opt->ImageBase;
> - image_size = opt->SizeOfImage;
>   efi_set_code_and_data_type(loaded_image_info, opt->Subsystem);
>   efi_reloc = efi_alloc(virt_size,
> loaded_image_info->image_code_type);
> @@ -272,7 +270,6 @@ void *efi_load_pe(struct efi_loaded_image_obj *handle, 
> void *efi,
>   } else if (nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
>   IMAGE_OPTIONAL_HEADER32 *opt = >OptionalHeader;
>   image_base = opt->ImageBase;
> - image_size = opt->SizeOfImage;
>   efi_set_code_and_data_type(loaded_image_info, opt->Subsystem);
>   efi_reloc = efi_alloc(virt_size,
> loaded_image_info->image_code_type);
> @@ -315,10 +312,10 @@ void *efi_load_pe(struct efi_loaded_image_obj *handle, 
> void *efi,
>   invalidate_icache_all();
>  
>   /* Populate the loaded image interface bits */
> - loaded_image_info->image_base = efi;
> - loaded_image_info->image_size = image_size;
>   handle->reloc_base = efi_reloc;
>   handle->reloc_size = virt_size;
> + loaded_image_info->image_base = efi_reloc;
> + loaded_image_info->image_size = virt_size;
>  
>   return entry;
>  }
> 

With this patch GRUB is not able to load the modules which are included
in grubaa64.efi

## Starting EFI application at 4040 ...
error: unknown filesystem.
Entering rescue mode...
grub rescue>

Function grub_efi_modules_addr() expects image_base to point to the
unrelocated image:

  header = image->image_base;
  coff_header = &(header->coff_header);
  sections
= (struct grub_pe32_section_table *) ((char *) coff_header
  + sizeof (*coff_header)
  +
coff_header->optional_header_size);

The UEFI SCT II specifcation test 5.3.1.1.11 requires

Check on Application Images which have Unload function.
Unload field should be valid and its entry address should be within
the range of [ImageBase, ImageBase+ImageSize]

@Leif
Any idea how to sort this out?

Best regards

Heinrich



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