Re: [U-Boot] [BUG] divide by 0 in spi flash probe

2016-08-28 Thread Vignesh R


On Monday 29 August 2016 11:19 AM, Chris Packham wrote:
> Hi,
> 
> I'm updating support for a board which uses the Armada-385 from u-boot
> v2016.05 to use the latest master (v2016.09-rc2 plus a bit).
> 
> When I run "sf probe" I get a divide by 0 in mvebu_spi_set_speed
> because hz has made it through as 0.
> 

There is a bug when sf probe is called second time. This bug is fixed
by: https://patchwork.ozlabs.org/patch/659979/

Could you try if this patch helps?


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


Re: [U-Boot] [BUG] divide by 0 in spi flash probe

2016-08-28 Thread Stefan Roese

Hi Chris,

(added Tom to Cc)

On 29.08.2016 07:49, Chris Packham wrote:

I'm updating support for a board which uses the Armada-385 from u-boot
v2016.05 to use the latest master (v2016.09-rc2 plus a bit).

When I run "sf probe" I get a divide by 0 in mvebu_spi_set_speed
because hz has made it through as 0.

When I run saveenv (env is in SPI) I don't get the divide by 0.

I'll do some more digging tomorrow but just thought I'd get this email
off now in case it rings any bells for anyone.


I've also stumbled over this issue last week. You (and everyone else)
need this patch:

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

Jagan or Tom, please make sure that this patch gets added really soon.
Its really annoying. As updating the image in SPI nor does not work
without it.

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


[U-Boot] [BUG] divide by 0 in spi flash probe

2016-08-28 Thread Chris Packham
Hi,

I'm updating support for a board which uses the Armada-385 from u-boot
v2016.05 to use the latest master (v2016.09-rc2 plus a bit).

When I run "sf probe" I get a divide by 0 in mvebu_spi_set_speed
because hz has made it through as 0.

When I run saveenv (env is in SPI) I don't get the divide by 0.

I'll do some more digging tomorrow but just thought I'd get this email
off now in case it rings any bells for anyone.

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


[U-Boot] [PATCH] net, cmd: fix misaligned cache operation warning

2016-08-28 Thread Heiko Schocher
when using tftp on the smartweb board, it prints, when
using the tftp command:

Using ethernet@fffc4000 device
TFTP from server 192.168.1.1; our IP address is 192.168.20.80
Filename '/tftpboot/smartweb_hw/tbot/u-boot.bin'.
Load address: 0x2100
Loading: ###
 73.2 KiB/s
done
Bytes transferred = 391560 (5f988 hex)
CACHE: Misaligned operation at range [2100, 2105f988]
U-Boot#

Fixing this.

Signed-off-by: Heiko Schocher 
---

 cmd/net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/net.c b/cmd/net.c
index b2f3c7b..540daeb 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -244,7 +244,7 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t 
*cmdtp, int argc,
}
 
/* flush cache */
-   flush_cache(load_addr, size);
+   flush_cache(load_addr, ALIGN(size, CONFIG_SYS_CACHELINE_SIZE));
 
bootstage_mark(BOOTSTAGE_ID_NET_LOADED);
 
-- 
2.5.5

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


[U-Boot] [PATCH] net, macb: fix misaligned cache operation warning

2016-08-28 Thread Heiko Schocher
when using tftp on the smartweb board, it prints a lot of

CACHE: Misaligned operation at range [23b2e000, 23b2e100]

warnings ... fixed them.

Signed-off-by: Heiko Schocher 
---
detected with automated build and testing with tbot, see
a log here:
http://xeidos.ddns.net/buildbot/builders/smartweb_dfu/builds/77/steps/shell/logs/tbotlog

There are 2 checkpatch warnings in this patch, for example:
CHECK: Alignment should match open parenthesis
+   invalidate_dcache_range(macb->rx_ring_dma,
+   ALIGN(macb->rx_ring_dma + MACB_RX_DMA_DESC_SIZE,

But if I align this, it gets unreadable ...


 drivers/net/macb.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 921537f..79b56ff 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -251,33 +251,35 @@ int macb_miiphy_write(struct mii_dev *bus, int phy_adr, 
int devad, int reg,
 static inline void macb_invalidate_ring_desc(struct macb_device *macb, bool rx)
 {
if (rx)
-   invalidate_dcache_range(macb->rx_ring_dma, macb->rx_ring_dma +
-   MACB_RX_DMA_DESC_SIZE);
+   invalidate_dcache_range(macb->rx_ring_dma,
+   ALIGN(macb->rx_ring_dma + MACB_RX_DMA_DESC_SIZE,
+ PKTALIGN));
else
-   invalidate_dcache_range(macb->tx_ring_dma, macb->tx_ring_dma +
-   MACB_TX_DMA_DESC_SIZE);
+   invalidate_dcache_range(macb->tx_ring_dma,
+   ALIGN(macb->tx_ring_dma + MACB_TX_DMA_DESC_SIZE,
+ PKTALIGN));
 }
 
 static inline void macb_flush_ring_desc(struct macb_device *macb, bool rx)
 {
if (rx)
flush_dcache_range(macb->rx_ring_dma, macb->rx_ring_dma +
-   MACB_RX_DMA_DESC_SIZE);
+  ALIGN(MACB_RX_DMA_DESC_SIZE, PKTALIGN));
else
flush_dcache_range(macb->tx_ring_dma, macb->tx_ring_dma +
-   MACB_TX_DMA_DESC_SIZE);
+  ALIGN(MACB_TX_DMA_DESC_SIZE, PKTALIGN));
 }
 
 static inline void macb_flush_rx_buffer(struct macb_device *macb)
 {
flush_dcache_range(macb->rx_buffer_dma, macb->rx_buffer_dma +
-   MACB_RX_BUFFER_SIZE);
+  ALIGN(MACB_RX_BUFFER_SIZE, PKTALIGN));
 }
 
 static inline void macb_invalidate_rx_buffer(struct macb_device *macb)
 {
invalidate_dcache_range(macb->rx_buffer_dma, macb->rx_buffer_dma +
-   MACB_RX_BUFFER_SIZE);
+   ALIGN(MACB_RX_BUFFER_SIZE, PKTALIGN));
 }
 
 #if defined(CONFIG_CMD_NET)
@@ -596,7 +598,7 @@ static int gmac_init_multi_queues(struct macb_device *macb)
macb->dummy_desc->ctrl = TXBUF_USED;
macb->dummy_desc->addr = 0;
flush_dcache_range(macb->dummy_desc_dma, macb->dummy_desc_dma +
-   MACB_TX_DUMMY_DMA_DESC_SIZE);
+   ALIGN(MACB_TX_DUMMY_DMA_DESC_SIZE, PKTALIGN));
 
for (i = 1; i < num_queues; i++)
gem_writel_queue_TBQP(macb, macb->dummy_desc_dma, i - 1);
-- 
2.5.5

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


Re: [U-Boot] [PATCH] mx6ul_14x14_evk: Fix DDR calibration values

2016-08-28 Thread Peng Fan
Hi Fabio,
On Mon, Aug 29, 2016 at 12:20:12AM -0300, Fabio Estevam wrote:
>From: Fabio Estevam 
>
>When running NXP 4.1 kernel with U-Boot mainline we observe a
>hang when going into the lowest operational point of cpufreq.
>
>Comparing the DDR calibration values against NXP U-Boot showed
>that the values were incorrect.
>
>Adjust the calibration values so that we can avoid such system hang.
>
>Reported-by: Eric Nelson 
>Signed-off-by: Fabio Estevam 

Acked-by: Peng Fan 

Thanks,
Peng.
>---
> board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c | 8 
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
>diff --git a/board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c 
>b/board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c
>index c213861..77c561d 100644
>--- a/board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c
>+++ b/board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c
>@@ -784,10 +784,10 @@ static struct mx6ul_iomux_ddr_regs mx6_ddr_ioregs = {
> };
> 
> static struct mx6_mmdc_calibration mx6_mmcd_calib = {
>-  .p0_mpwldectrl0 = 0x00070007,
>-  .p0_mpdgctrl0 = 0x41490145,
>-  .p0_mprddlctl = 0x40404546,
>-  .p0_mpwrdlctl = 0x4040524D,
>+  .p0_mpwldectrl0 = 0x,
>+  .p0_mpdgctrl0 = 0x41570155,
>+  .p0_mprddlctl = 0x4040474A,
>+  .p0_mpwrdlctl = 0x40405550,
> };
> 
> struct mx6_ddr_sysinfo ddr_sysinfo = {
>-- 
>2.7.4
>
>___
>U-Boot mailing list
>U-Boot@lists.denx.de
>http://lists.denx.de/mailman/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] configs: ti: armv7_common: Enable DISPLAY_{CPU/BOARD}INFO

2016-08-28 Thread Lokesh Vutla


On Monday 29 August 2016 01:46 AM, Tom Rini wrote:
> On Sat, Aug 27, 2016 at 05:23:55PM +0530, Lokesh Vutla wrote:
> 
>> Enable CONFIG_DISPLAY_{CPU/BOARD}INFO on all TI platforms.
>> Also removing the duplicated configs.
>>
>> Signed-off-by: Lokesh Vutla 
>> ---
>>  include/configs/ti_armv7_common.h| 4 
>>  include/configs/ti_armv7_keystone2.h | 1 -
>>  include/configs/ti_omap4_common.h| 2 --
>>  include/configs/ti_omap5_common.h| 3 ---
>>  4 files changed, 4 insertions(+), 6 deletions(-)
> 
> This is the wrong direction.  Please add an entry to common/Kconfig (a
> "hidden" one) and select it from board/ti/*/Kconfig.  And this will need

Sure, will update the patch to add a common Kconfig entry. But I am not
sure about the statement "select it from board/ti/*/Kconfig". You meant
it should be selected by every config TARGET_XXX_EVM or something else?

> some cleaning up of some other boards/ Kconfig files that introduced it
> locally and instead should select this new option.  Thanks!

okay, will do it.

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


[U-Boot] [PATCH v1] mtd: nand: pxa3xx: use nand_set_controller_data

2016-08-28 Thread Chris Packham
In commit 17cb4b8f327e ("mtd: nand: Add+use mtd_to/from_nand and
nand_get/set_controller_data") the assignment of mtd->priv was removed
but was not replaced. This adds the required nand_set_controller_data()
call.

Signed-off-by: Chris Packham 
---

 drivers/mtd/nand/pxa3xx_nand.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index d3ac5391f156..b1d58e036a1d 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -1496,6 +1496,7 @@ static int alloc_nand_resource(struct pxa3xx_nand_info 
*info)
host->read_id_bytes = 4;
mtd->owner = THIS_MODULE;
 
+   nand_set_controller_data(chip, host);
chip->ecc.read_page = pxa3xx_nand_read_page_hwecc;
chip->ecc.write_page= pxa3xx_nand_write_page_hwecc;
chip->controller= >controller;
-- 
2.9.2.518.ged577c6.dirty

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


[U-Boot] [PATCH] mx6ul_14x14_evk: Fix DDR calibration values

2016-08-28 Thread Fabio Estevam
From: Fabio Estevam 

When running NXP 4.1 kernel with U-Boot mainline we observe a
hang when going into the lowest operational point of cpufreq.

Comparing the DDR calibration values against NXP U-Boot showed
that the values were incorrect.

Adjust the calibration values so that we can avoid such system hang.

Reported-by: Eric Nelson 
Signed-off-by: Fabio Estevam 
---
 board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c 
b/board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c
index c213861..77c561d 100644
--- a/board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c
+++ b/board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c
@@ -784,10 +784,10 @@ static struct mx6ul_iomux_ddr_regs mx6_ddr_ioregs = {
 };
 
 static struct mx6_mmdc_calibration mx6_mmcd_calib = {
-   .p0_mpwldectrl0 = 0x00070007,
-   .p0_mpdgctrl0 = 0x41490145,
-   .p0_mprddlctl = 0x40404546,
-   .p0_mpwrdlctl = 0x4040524D,
+   .p0_mpwldectrl0 = 0x,
+   .p0_mpdgctrl0 = 0x41570155,
+   .p0_mprddlctl = 0x4040474A,
+   .p0_mpwrdlctl = 0x40405550,
 };
 
 struct mx6_ddr_sysinfo ddr_sysinfo = {
-- 
2.7.4

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


Re: [U-Boot] mx6ul_14x14_evk

2016-08-28 Thread Fabio Estevam
Hi Eric,

On Sun, Aug 28, 2016 at 11:47 PM, Fabio Estevam  wrote:

> I was able to reproduce this problem here.
>
> The major difference between mainline U-Boot and NXP U-Boot is that
> mainline U-Boot uses SPL and NXP U-Boot uses imximage.cfg to configure
> the DDR.
>
> I have just created and tested the patch below against Stefano's tree:
> http://pastebin.com/crAe1Yr1
>
> , which basically uses imximage.cfg from NXP U-Boot instead of SPL and
> the hang does not occur.
>
> It seems to me that we need to carefully review the SPL DDR init code
> in mainline in order to fix this problem.
>
> I will try to take a look at it tomorrow, but if anyone spots the DDR
> problem in the SPL code, then feel free to submit the patch :-)

I managed to fix the SPL DDR and now I don't see the hang.

Will send a formal patch.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] mx6ul_14x14_evk

2016-08-28 Thread Fabio Estevam
Hi Eric,

On Sun, Aug 28, 2016 at 6:04 PM, Eric Nelson  wrote:
> On 08/28/2016 01:59 PM, Eric Nelson wrote:
>> Hi Fabio, Peng, and all.
>>
>> I just ran into a problem with bus frequency switching
>> on the EVK and there appears to be a U-Boot component.
>>
>> Using the 4.1.15 kernel from git.freescale.com (commit a4d2a08)
>> and the latest U-Boot from Stefano's imx tree (commit a3e5519)
>> causes the EVK to hang during a bus frequency switch to LOW_POWER
>> mode.
>>
>> The last gasp is this:
>>   Bus freq set to 2400 start...
>>
>> And the code block in question is here:
>>   
>> http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/arch/arm/mach-imx/busfreq_ddr3.c?h=imx_4.1.15_1.0.0_ga#n386
>>
>> When using the binary U-Boot 2015.07 from the EVK package (commit
>> d7d7c43 from git.freescale.com), the kernel gets through the
>> frequency switch and produces this message.
>>
>>   Bus freq set to 2400 done!
>>
>> I first saw this problem with u-boot-fslc branch v2016.07
>> and linux-fslc (4.1.29 and 4.1.30).
>>
>> Has anybody else experienced this?
>>
>
> I forgot to mention it, but this is easy to reproduce
> by downing both ethernet interfaces and blanking the
> display.
>
> ifconfig eth0 down
> ifconfig eth1 down
> echo 1 > /sys/class/graphics/fb0/blank

I was able to reproduce this problem here.

The major difference between mainline U-Boot and NXP U-Boot is that
mainline U-Boot uses SPL and NXP U-Boot uses imximage.cfg to configure
the DDR.

I have just created and tested the patch below against Stefano's tree:
http://pastebin.com/crAe1Yr1

, which basically uses imximage.cfg from NXP U-Boot instead of SPL and
the hang does not occur.

It seems to me that we need to carefully review the SPL DDR init code
in mainline in order to fix this problem.

I will try to take a look at it tomorrow, but if anyone spots the DDR
problem in the SPL code, then feel free to submit the patch :-)

Thanks,

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


Re: [U-Boot] [PATCH v2 2/2] Enable ROCKCHIP_SPL_BACK_TO_BROM for rock2 board

2016-08-28 Thread Sandy Patterson
On Sun, Aug 28, 2016 at 10:01 PM, Ziyuan Xu  wrote:

> Hi,
>
>
> On 2016年08月28日 03:39, Sandy Patterson wrote:
>
>> Rock2 has been tested with back to brom feature. The tricky part is that
>> with this feature the default environment is inside u-boot, and it's
>> defined for every rk3288 board independetly. So I just changed it for
>> rock2 here.
>>
>> Solve by moving environment after u-boot before 1M boundary
>>
>> Signed-off-by: Sandy Patterson 
>> ---
>>
>
> According to your change, I think your commit message is not match.
> Enable ROCKCHIP_SPL_BACK_TO_BROM for rock2 board???


Oops. It looks like my change to the rock2_defconfig ended up in the other
patch. I'll resubmit with the defconfig in this patch.

>
>
>
>> Changes in v2: None
>>
>>   include/configs/rock2.h | 8 
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/include/configs/rock2.h b/include/configs/rock2.h
>> index ee924c3..946367f 100644
>> --- a/include/configs/rock2.h
>> +++ b/include/configs/rock2.h
>> @@ -16,11 +16,11 @@
>> #define CONFIG_ENV_IS_IN_MMC
>>   #define CONFIG_SYS_MMC_ENV_DEV 0
>> -/* SPL @ 32k for ~36k
>> - * ENV @ 96k
>> - * u-boot @ 128K
>> +/* SPL @ 32k for 34k
>> + * u-boot directly after @ 68k for 400k or so
>> + * ENV @ 992k
>>*/
>> -#define CONFIG_ENV_OFFSET (96 * 1024)
>> +#define CONFIG_ENV_OFFSET ((1024-32) * 1024)
>> #define CONFIG_SYS_WHITE_ON_BLACK
>>   #define CONFIG_CONSOLE_SCROLL_LINES   10
>>
>
>
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/2] Enable ROCKCHIP_SPL_BACK_TO_BROM for rock2 board

2016-08-28 Thread Ziyuan Xu

Hi,


On 2016年08月28日 03:39, Sandy Patterson wrote:

Rock2 has been tested with back to brom feature. The tricky part is that
with this feature the default environment is inside u-boot, and it's
defined for every rk3288 board independetly. So I just changed it for
rock2 here.

Solve by moving environment after u-boot before 1M boundary

Signed-off-by: Sandy Patterson 
---


According to your change, I think your commit message is not match.
Enable ROCKCHIP_SPL_BACK_TO_BROM for rock2 board???



Changes in v2: None

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

diff --git a/include/configs/rock2.h b/include/configs/rock2.h
index ee924c3..946367f 100644
--- a/include/configs/rock2.h
+++ b/include/configs/rock2.h
@@ -16,11 +16,11 @@
  
  #define CONFIG_ENV_IS_IN_MMC

  #define CONFIG_SYS_MMC_ENV_DEV 0
-/* SPL @ 32k for ~36k
- * ENV @ 96k
- * u-boot @ 128K
+/* SPL @ 32k for 34k
+ * u-boot directly after @ 68k for 400k or so
+ * ENV @ 992k
   */
-#define CONFIG_ENV_OFFSET (96 * 1024)
+#define CONFIG_ENV_OFFSET ((1024-32) * 1024)
  
  #define CONFIG_SYS_WHITE_ON_BLACK

  #define CONFIG_CONSOLE_SCROLL_LINES   10



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


Re: [U-Boot] [PATCH v2 1/2] Disable SPL_MMC_SUPPORT if ROCKCHIP_SPL_BACK_TO_BROM is enabled.

2016-08-28 Thread Ziyuan Xu



On 2016年08月28日 03:39, Sandy Patterson wrote:

Default SPL_MMC_SUPPORT to false when ROCKCHIP_SPL_BACK_TO_BROM is enabled.

Signed-off-by: Sandy Patterson 


Acked-by: Ziyuan Xu 


---

Changes in v2:
  - Rebase after "Kconfig: Move CONFIG_SPL_..._SUPPORT to Kconfig."
  - Remove all the refactoring in the configs.
  - Split enabling featuring in rock2 into separate commit.




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


Re: [U-Boot] [PATCH v2 2/3] x86: efi: Fix EFI 64-bit payload build warnings

2016-08-28 Thread Bin Meng
Hi Simon,

On Thu, Aug 25, 2016 at 4:47 PM, Bin Meng  wrote:
> There are lots of warnings when building EFI 64-bit payload.
>
> include/asm-generic/bitops/__fls.h:17:2:
>   warning: left shift count >= width of type
> if (!(word & (~0ul << 32))) {
> ^
>
> In fact, U-Boot itself as EFI payload is running in 32-bit mode.
> So BITS_PER_LONG needs to still be 32, but EFI status codes are
> 64-bit when booting from 64-bit EFI. Introduce EFI_BITS_PER_LONG
> to bridge those status codes with U-Boot's BITS_PER_LONG.
>
> Signed-off-by: Bin Meng 
>
> ---
>
> Changes in v2:
> - Rework the patch to fix 64-bit payload boot issue
>
>  arch/x86/include/asm/types.h |  4 
>  include/efi.h| 32 
>  2 files changed, 20 insertions(+), 16 deletions(-)
>

Please have a look at this.

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


Re: [U-Boot] [PATCH 02/30] x86: ivybridge: Allow microcode to be collated

2016-08-28 Thread Bin Meng
On Thu, Jul 28, 2016 at 2:53 PM, Bin Meng  wrote:
> On Tue, Jul 26, 2016 at 8:58 AM, Simon Glass  wrote:
>> Generally the microcode is combined into a single block only (and removed
>> from the device tree) when there are multiple blocks. But this is not a
>> requirement.
>>
>> Adjust the ivybridge code to avoid assuming this.
>>
>> Signed-off-by: Simon Glass 
>> ---
>>
>>  arch/x86/cpu/intel_common/microcode.c | 12 +++-
>>  1 file changed, 11 insertions(+), 1 deletion(-)
>>
>
> Reviewed-by: Bin Meng 

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


Re: [U-Boot] [PATCH 03/30] x86: Add debugging when cpu_common_init() fails

2016-08-28 Thread Bin Meng
On Thu, Jul 28, 2016 at 2:53 PM, Bin Meng  wrote:
> On Tue, Jul 26, 2016 at 8:58 AM, Simon Glass  wrote:
>> Add a debug() at this point to help figure out what is wrong.
>>
>> Signed-off-by: Simon Glass 
>> ---
>>
>>  arch/x86/cpu/ivybridge/cpu.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>
> Reviewed-by: Bin Meng 

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


Re: [U-Boot] [PATCH 01/30] x86: Add debugging when a microcode update fails

2016-08-28 Thread Bin Meng
On Thu, Jul 28, 2016 at 2:53 PM, Bin Meng  wrote:
> On Tue, Jul 26, 2016 at 8:58 AM, Simon Glass  wrote:
>> Add a debug() at this point to help figure out what is wrong.
>>
>> Signed-off-by: Simon Glass 
>> ---
>>
>>  arch/x86/cpu/intel_common/cpu.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>
> Reviewed-by: Bin Meng 

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


Re: [U-Boot] [PATCH v2 3/4] usb: dwc3: add support for 16 bit UTMI+ interface

2016-08-28 Thread Marek Vasut
On 08/29/2016 02:55 AM, Kever Yang wrote:
> Hi Marek,
> 
> On 08/26/2016 05:09 PM, Marek Vasut wrote:
>> On 08/25/2016 03:17 AM, Kever Yang wrote:
>>> Hi Marek,
>>>
>>> On 08/24/2016 07:38 PM, Marek Vasut wrote:
 On 08/24/2016 05:46 AM, Kever Yang wrote:
> The dwc3 controller is using 8 bit UTMI+ interface for USB2.0 PHY,
> add one variable in dwc3/dwc3_device struct to support 16 bit
> UTMI+ interface on some SoCs like Rockchip rk3399.
>
> Signed-off-by: Kever Yang 
> ---
>
> Changes in v2:
> - use a variable to identify utmi+ bus width instead of CONFIG MACRO
>
>drivers/usb/dwc3/core.c |  6 ++
>drivers/usb/dwc3/core.h | 12 
>include/dwc3-uboot.h|  1 +
>3 files changed, 19 insertions(+)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 85cc96a..0613508 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -388,6 +388,11 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
>if (dwc->dis_u2_susphy_quirk)
>reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
>+if (dwc->usb2_phyif_utmi_width == 16) {
> +reg &= ~DWC3_GUSB2PHYCFG_USBTRDTIM_MASK;
> +reg |= DWC3_GUSB2PHYCFG_USBTRDTIM_16BIT;
> +reg |= DWC3_GUSB2PHYCFG_PHYIF_16BIT;
> +}
 Didn't we agree to pull this info from OF ?
>>> Yes, the dwc->usb2_phyif_utmi_width is from OF,  but I make the DT parse
>>> in board file instead of in the dwc3 driver,  see my patch:
>>> [PATCH v2 2/4] board: evb-rk3399: add api to support dwc3 gadget
>> So this is basically a passing of platform data ?
> 
> Yes, this is what other platform do, I just extend one more setting.

Platform data should go away in favor of the DT probing.

>>> I think implement in this way won't affect other soc also using dwc3
>>> controller,
>>> the DT parse would cost some time which may not necessary for other soc.
>> The time needed to run the DT parsing is completely insignificant.
>> This sounds like a premature optimization.
> 
> Which way of implement this DT parse do you prefer and more reasonable,
> in dwc3 driver or in board init and dwc3 driver use it as platform data?

Driver should parse the DT.

> Thanks,
> - Kever

[...]

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/4] board: evb-rk3399: add api to support dwc3 gadget

2016-08-28 Thread Kever Yang

Hi Marek,

On 08/26/2016 05:11 PM, Marek Vasut wrote:

On 08/25/2016 03:07 AM, Kever Yang wrote:

+ Marek

On 08/24/2016 11:46 AM, Kever Yang wrote:

This patch add board_usb_init() and interrupt callback
for dwc3 gadget.

Signed-off-by: Kever Yang 
Reviewed-by: Simon Glass 
---

Changes in v2:
- parse dt for utmi width

   board/rockchip/evb_rk3399/evb-rk3399.c | 33
+
   1 file changed, 33 insertions(+)

diff --git a/board/rockchip/evb_rk3399/evb-rk3399.c
b/board/rockchip/evb_rk3399/evb-rk3399.c
index d394276..5d3a09a 100644
--- a/board/rockchip/evb_rk3399/evb-rk3399.c
+++ b/board/rockchip/evb_rk3399/evb-rk3399.c
@@ -7,6 +7,8 @@
   #include 
   #include 
   #include 
+#include 
+#include 
 DECLARE_GLOBAL_DATA_PTR;
   @@ -54,3 +56,34 @@ void dram_init_banksize(void)
   gd->bd->bi_dram[0].start = 0x20;
   gd->bd->bi_dram[0].size = 0x8000;
   }
+
+#ifdef CONFIG_USB_DWC3
+static struct dwc3_device dwc3_device_data = {
+.maximum_speed = USB_SPEED_HIGH,
+.base = 0xfe80,
+.dr_mode = USB_DR_MODE_PERIPHERAL,

Why don't you parse all of this from DT ? You already parse DT below.


I add these code by reference to exynos5 and zynqmp platform, I can parse
all information from DT which including in DT, but maximum_speed still 
defined

here, because it's not in DT node, is that OK?

Thanks,
- Kever



+.index = 0,
+};
+
+int usb_gadget_handle_interrupts(void)
+{
+dwc3_uboot_handle_interrupt(0);
+return 0;
+}
+
+int board_usb_init(int index, enum usb_init_type init)
+{
+const void *blob = gd->fdt_blob;
+int node;
+
+node = fdt_node_offset_by_compatible(blob, -1,
+"rockchip,rk3399-xhci");
+if (node < 0)
+debug("%s node not found\n", __func__);
+else
+dwc3_device_data.usb2_phyif_utmi_width =
+fdtdec_get_int(blob, node, "snps,phyif-utmi-bits", -1);
+
+return dwc3_uboot_init(_device_data);
+}
+#endif







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


Re: [U-Boot] [PATCH v2 4/4] config: rk3399: add support for dwc3 gadget

2016-08-28 Thread Kever Yang

Hi Steve,


On 08/28/2016 06:22 AM, Steve Rae wrote:


Hi Kever,

On Aug 23, 2016 20:48, "Kever Yang" > wrote:

>
> To support fastboot, we need to enable the controller first.
> rk3399 is using dwc3 as usb device controller, this patch enable
> the configs for dwc3 gadget.
>
> Signed-off-by: Kever Yang >

> Reviewed-by: Simon Glass >
> ---
>
> Changes in v2:
> - remove config for USB2PHY UTMI BITS
>
>  include/configs/rk3399_common.h | 20 
>  1 file changed, 20 insertions(+)
>
> diff --git a/include/configs/rk3399_common.h 
b/include/configs/rk3399_common.h

> index 6875308..fcd1700 100644
> --- a/include/configs/rk3399_common.h
> +++ b/include/configs/rk3399_common.h
> @@ -27,6 +27,26 @@
>
>  #define CONFIG_SYS_BOOTM_LEN   (64 << 20)  /* 64M */
>
> +/*  usb device */
> +#define CONFIG_USB_DWC3
> +#define CONFIG_USB_DWC3_GADGET
> +#define CONFIG_USB_GADGET
> +#define CONFIG_USB_GADGET_DUALSPEED
> +#define CONFIG_USB_GADGET_VBUS_DRAW0
> +
> +/*  fastboot  */
> +#define CONFIG_CMD_FASTBOOT
> +#define CONFIG_USB_FUNCTION_FASTBOOT
> +#define CONFIG_FASTBOOT_FLASH
> +#define CONFIG_FASTBOOT_FLASH_MMC_DEV  1   /* eMMC */
> +#define CONFIG_FASTBOOT_BUF_ADDR  CONFIG_SYS_LOAD_ADDR
> +#define CONFIG_FASTBOOT_BUF_SIZE   0x0800
> +
> +#define CONFIG_USB_GADGET_DOWNLOAD
> +#define CONFIG_G_DNL_MANUFACTURER  "Rockchip"
> +#define CONFIG_G_DNL_VENDOR_NUM0x2207
> +#define CONFIG_G_DNL_PRODUCT_NUM   0x330a
> +
FYI - All of these new defines are now in Kconfig



Thanks for point out, I will rebase this patch and move these defines 
into Kconfig.


Regards,
- Kever


Thanks, Steve

>  /* MMC/SD IP block */
>  #define CONFIG_MMC
>  #define CONFIG_GENERIC_MMC
> --
> 1.9.1
>
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de 
> http://lists.denx.de/mailman/listinfo/u-boot



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


Re: [U-Boot] [PATCH v2 3/4] usb: dwc3: add support for 16 bit UTMI+ interface

2016-08-28 Thread Kever Yang

Hi Marek,

On 08/26/2016 05:09 PM, Marek Vasut wrote:

On 08/25/2016 03:17 AM, Kever Yang wrote:

Hi Marek,

On 08/24/2016 07:38 PM, Marek Vasut wrote:

On 08/24/2016 05:46 AM, Kever Yang wrote:

The dwc3 controller is using 8 bit UTMI+ interface for USB2.0 PHY,
add one variable in dwc3/dwc3_device struct to support 16 bit
UTMI+ interface on some SoCs like Rockchip rk3399.

Signed-off-by: Kever Yang 
---

Changes in v2:
- use a variable to identify utmi+ bus width instead of CONFIG MACRO

   drivers/usb/dwc3/core.c |  6 ++
   drivers/usb/dwc3/core.h | 12 
   include/dwc3-uboot.h|  1 +
   3 files changed, 19 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 85cc96a..0613508 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -388,6 +388,11 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
   if (dwc->dis_u2_susphy_quirk)
   reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
   +if (dwc->usb2_phyif_utmi_width == 16) {
+reg &= ~DWC3_GUSB2PHYCFG_USBTRDTIM_MASK;
+reg |= DWC3_GUSB2PHYCFG_USBTRDTIM_16BIT;
+reg |= DWC3_GUSB2PHYCFG_PHYIF_16BIT;
+}

Didn't we agree to pull this info from OF ?

Yes, the dwc->usb2_phyif_utmi_width is from OF,  but I make the DT parse
in board file instead of in the dwc3 driver,  see my patch:
[PATCH v2 2/4] board: evb-rk3399: add api to support dwc3 gadget

So this is basically a passing of platform data ?


Yes, this is what other platform do, I just extend one more setting.




I think implement in this way won't affect other soc also using dwc3
controller,
the DT parse would cost some time which may not necessary for other soc.

The time needed to run the DT parsing is completely insignificant.
This sounds like a premature optimization.


Which way of implement this DT parse do you prefer and more reasonable,
in dwc3 driver or in board init and dwc3 driver use it as platform data?

Thanks,
- Kever




   dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
 mdelay(100);
@@ -676,6 +681,7 @@ int dwc3_uboot_init(struct dwc3_device *dwc3_dev)
 dwc->lpm_nyet_threshold = lpm_nyet_threshold;
   dwc->tx_de_emphasis = tx_de_emphasis;
+dwc->usb2_phyif_utmi_width = dwc3_dev->usb2_phyif_utmi_width;
 dwc->hird_threshold = hird_threshold
   | (dwc->is_utmi_l1_suspend << 4);
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 72d2fcd..d5bdf97 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -74,6 +74,7 @@
   #define DWC3_GCTL0xc110
   #define DWC3_GEVTEN0xc114
   #define DWC3_GSTS0xc118
+#define DWC3_GUCTL10xc11c
   #define DWC3_GSNPSID0xc120
   #define DWC3_GGPIO0xc124
   #define DWC3_GUID0xc128
@@ -162,7 +163,17 @@
 /* Global USB2 PHY Configuration Register */
   #define DWC3_GUSB2PHYCFG_PHYSOFTRST(1 << 31)
+#define DWC3_GUSB2PHYCFG_ENBLSLPM   (1 << 8)
   #define DWC3_GUSB2PHYCFG_SUSPHY(1 << 6)
+#define DWC3_GUSB2PHYCFG_PHYIF_8BIT(0 << 3)
+#define DWC3_GUSB2PHYCFG_PHYIF_16BIT(1 << 3)
+#define DWC3_GUSB2PHYCFG_USBTRDTIM_SHIFT(10)
+#define DWC3_GUSB2PHYCFG_USBTRDTIM_MASK(0xf << \
+DWC3_GUSB2PHYCFG_USBTRDTIM_SHIFT)
+#define DWC3_GUSB2PHYCFG_USBTRDTIM_16BIT (0x5 << \
+DWC3_GUSB2PHYCFG_USBTRDTIM_SHIFT)
+#define DWC3_GUSB2PHYCFG_USBTRDTIM_8BIT (0x9 << \
+DWC3_GUSB2PHYCFG_USBTRDTIM_SHIFT)
 /* Global USB3 PIPE Control Register */
   #define DWC3_GUSB3PIPECTL_PHYSOFTRST(1 << 31)
@@ -813,6 +824,7 @@ struct dwc3 {
 unsignedtx_de_emphasis_quirk:1;
   unsignedtx_de_emphasis:2;
+unsignedusb2_phyif_utmi_width;
   intindex;
   struct list_headlist;
   };
diff --git a/include/dwc3-uboot.h b/include/dwc3-uboot.h
index 7af2ad1..cc9ffe8 100644
--- a/include/dwc3-uboot.h
+++ b/include/dwc3-uboot.h
@@ -33,6 +33,7 @@ struct dwc3_device {
   unsigned dis_u2_susphy_quirk;
   unsigned tx_de_emphasis_quirk;
   unsigned tx_de_emphasis;
+unsigned usb2_phyif_utmi_width;

The utmi width is either 8 or 16, so you can continue the bitfield
instead of wasting 32 bits.

I think you mean the usb2_phyif_utmi_width in struct dwc3, but not
struct dwc3_device, right?

Yes, sorry.


Thanks,
-Kever

   int index;
   };
  







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


Re: [U-Boot] [PATCH v2 2/4] board: evb-rk3399: add api to support dwc3 gadget

2016-08-28 Thread Marek Vasut
On 08/29/2016 02:49 AM, Kever Yang wrote:
> Hi Marek,
> 
> On 08/26/2016 05:11 PM, Marek Vasut wrote:
>> On 08/25/2016 03:07 AM, Kever Yang wrote:
>>> + Marek
>>>
>>> On 08/24/2016 11:46 AM, Kever Yang wrote:
 This patch add board_usb_init() and interrupt callback
 for dwc3 gadget.

 Signed-off-by: Kever Yang 
 Reviewed-by: Simon Glass 
 ---

 Changes in v2:
 - parse dt for utmi width

board/rockchip/evb_rk3399/evb-rk3399.c | 33
 +
1 file changed, 33 insertions(+)

 diff --git a/board/rockchip/evb_rk3399/evb-rk3399.c
 b/board/rockchip/evb_rk3399/evb-rk3399.c
 index d394276..5d3a09a 100644
 --- a/board/rockchip/evb_rk3399/evb-rk3399.c
 +++ b/board/rockchip/evb_rk3399/evb-rk3399.c
 @@ -7,6 +7,8 @@
#include 
#include 
#include 
 +#include 
 +#include 
  DECLARE_GLOBAL_DATA_PTR;
@@ -54,3 +56,34 @@ void dram_init_banksize(void)
gd->bd->bi_dram[0].start = 0x20;
gd->bd->bi_dram[0].size = 0x8000;
}
 +
 +#ifdef CONFIG_USB_DWC3
 +static struct dwc3_device dwc3_device_data = {
 +.maximum_speed = USB_SPEED_HIGH,
 +.base = 0xfe80,
 +.dr_mode = USB_DR_MODE_PERIPHERAL,
>> Why don't you parse all of this from DT ? You already parse DT below.
> 
> I add these code by reference to exynos5 and zynqmp platform, I can parse
> all information from DT which including in DT, but maximum_speed still
> defined
> here, because it's not in DT node, is that OK?

Sorry, can you please rephrase ?

Linux already has maximum-speed binding, see
Documentation/devicetree/bindings/usb/generic.txt

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 01/10] dm: imx: serial: support device tree

2016-08-28 Thread Stefan Agner
On 2016-08-26 07:10, Stefano Babic wrote:
> On 26/07/2016 08:22, Stefan Agner wrote:
>> From: Stefan Agner 
>>
>> Support instatiation through device tree. Also parse the fsl,dte-mode
>> property to determine whether DTE mode shall be used.
>>
>> Signed-off-by: Stefan Agner 
>> ---
>> The kernel uses fsl,imx21-uart as "base" compatible, should we follow
>> that?
>>
>>  doc/device-tree-bindings/serial/mxc-serial.txt |  8 
>>  drivers/serial/serial_mxc.c| 28 
>> --
>>  2 files changed, 34 insertions(+), 2 deletions(-)
>>  create mode 100644 doc/device-tree-bindings/serial/mxc-serial.txt
>>
>> diff --git a/doc/device-tree-bindings/serial/mxc-serial.txt 
>> b/doc/device-tree-bindings/serial/mxc-serial.txt
>> new file mode 100644
>> index 000..ede92a4
>> --- /dev/null
>> +++ b/doc/device-tree-bindings/serial/mxc-serial.txt
>> @@ -0,0 +1,8 @@
>> +NXP i.MX (MXC) UART
>> +
>> +Required properties:
>> +- compatible: must be "fsl,imx7d-uart"
>> +- reg: start address and size of the registers
>> +
>> +Optional properties:
>> +- fsl,dte-mode: use DTE mode
>> diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
>> index 1960bbc..bd850d7 100644
>> --- a/drivers/serial/serial_mxc.c
>> +++ b/drivers/serial/serial_mxc.c
>> @@ -108,6 +108,8 @@
>>  #define  UTS_RXFULL  (1<<3)  /* RxFIFO full */
>>  #define  UTS_SOFTRST (1<<0)  /* Software reset */
>>
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>>  #ifndef CONFIG_DM_SERIAL
>>
>>  #ifndef CONFIG_MXC_UART_BASE
>> @@ -135,8 +137,6 @@
>>  #define UBRC  0xac /* Baud Rate Count Register */
>>  #define UTS   0xb4 /* UART Test Register (mx31) */
>>
>> -DECLARE_GLOBAL_DATA_PTR;
>> -
>>  #define TXTL  2 /* reset default */
>>  #define RXTL  1 /* reset default */
>>  #define RFDIV 4 /* divide input clock by 2 */
>> @@ -348,9 +348,33 @@ static const struct dm_serial_ops mxc_serial_ops = {
>>  .setbrg = mxc_serial_setbrg,
>>  };
>>
>> +static int mxc_serial_ofdata_to_platdata(struct udevice *dev)
>> +{
>> +struct mxc_serial_platdata *plat = dev->platdata;
>> +fdt_addr_t addr;
>> +
>> +addr = dev_get_addr(dev);
>> +if (addr == FDT_ADDR_T_NONE)
>> +return -EINVAL;
>> +
>> +plat->reg = (struct mxc_uart *)addr;
>> +
>> +plat->use_dte = fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
>> +"fsl,dte-mode");
> 
> I have applied it, I just noted a slight drawback because this breaks
> boards that do not have CONFIG_FIT set.

Hm, maybe due to missing CONFIG_OF_LIBFDT? Do you want me to fix it, do
you have a certain board you can reproduce it?

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


Re: [U-Boot] [RFC] mmc: fsl_esdhc: fix misaligned cache operation warning

2016-08-28 Thread Stefan Agner
On 2016-08-27 15:39, Clemens Gruber wrote:
> When using gzwrite to eMMC on an i.MX6Q board, the following warning
> occurs repeatedly:
> CACHE: Misaligned operation at range [4fd63318, 4fe63318]
> 
> I tried to cache-line align the start and end parameter for
> flush_dcache_range in esdhc_setup_data.
> (Same approach as in https://patchwork.ozlabs.org/patch/656470/)
> 
> After that, the "Misaligned operation" error message disappeared and
> everything still works for me.
> 
> But is this safe and should I send the patch again with [PATCH] ?
> 
> Signed-off-by: Clemens Gruber 
> ---
>  drivers/mmc/fsl_esdhc.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
> index 103b32e..f40b424 100644
> --- a/drivers/mmc/fsl_esdhc.c
> +++ b/drivers/mmc/fsl_esdhc.c
> @@ -222,6 +222,7 @@ static int esdhc_setup_data(struct mmc *mmc,
> struct mmc_data *data)
>   dma_addr_t addr;
>  #endif
>   uint wml_value;
> + ulong start, end;
>  
>   wml_value = data->blocksize/4;
>  
> @@ -243,9 +244,11 @@ static int esdhc_setup_data(struct mmc *mmc,
> struct mmc_data *data)
>  #endif
>   } else {
>  #ifndef CONFIG_SYS_FSL_ESDHC_USE_PIO
> - flush_dcache_range((ulong)data->src,
> -(ulong)data->src+data->blocks
> -  *data->blocksize);
> + start = (ulong)data->src;
> + start &= ~(CONFIG_SYS_CACHELINE_SIZE - 1);
> + end = ALIGN((ulong)data->src + data->blocks * data->blocksize,
> + CONFIG_SYS_CACHELINE_SIZE);
> + flush_dcache_range(start, end);

Hm, that seems dangerous to me, especially the src rounding...

Not sure where that memory gets aligned, but I guess we should use
memalign and align the length to cache size or the like... 

--
Stefan

>  #endif
>   if (wml_value > WML_WR_WML_MAX)
>   wml_value = WML_WR_WML_MAX_VAL;
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] mx6ul_14x14_evk

2016-08-28 Thread Eric Nelson
On 08/28/2016 01:59 PM, Eric Nelson wrote:
> Hi Fabio, Peng, and all.
> 
> I just ran into a problem with bus frequency switching
> on the EVK and there appears to be a U-Boot component.
> 
> Using the 4.1.15 kernel from git.freescale.com (commit a4d2a08)
> and the latest U-Boot from Stefano's imx tree (commit a3e5519)
> causes the EVK to hang during a bus frequency switch to LOW_POWER
> mode.
> 
> The last gasp is this:
>   Bus freq set to 2400 start...
> 
> And the code block in question is here:
>   
> http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/arch/arm/mach-imx/busfreq_ddr3.c?h=imx_4.1.15_1.0.0_ga#n386
> 
> When using the binary U-Boot 2015.07 from the EVK package (commit
> d7d7c43 from git.freescale.com), the kernel gets through the
> frequency switch and produces this message.
> 
>   Bus freq set to 2400 done!
> 
> I first saw this problem with u-boot-fslc branch v2016.07
> and linux-fslc (4.1.29 and 4.1.30).
> 
> Has anybody else experienced this?
> 

I forgot to mention it, but this is easy to reproduce
by downing both ethernet interfaces and blanking the
display.

ifconfig eth0 down
ifconfig eth1 down
echo 1 > /sys/class/graphics/fb0/blank

Regards,


Eric

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


[U-Boot] mx6ul_14x14_evk

2016-08-28 Thread Eric Nelson
Hi Fabio, Peng, and all.

I just ran into a problem with bus frequency switching
on the EVK and there appears to be a U-Boot component.

Using the 4.1.15 kernel from git.freescale.com (commit a4d2a08)
and the latest U-Boot from Stefano's imx tree (commit a3e5519)
causes the EVK to hang during a bus frequency switch to LOW_POWER
mode.

The last gasp is this:
Bus freq set to 2400 start...

And the code block in question is here:

http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/arch/arm/mach-imx/busfreq_ddr3.c?h=imx_4.1.15_1.0.0_ga#n386

When using the binary U-Boot 2015.07 from the EVK package (commit
d7d7c43 from git.freescale.com), the kernel gets through the
frequency switch and produces this message.

Bus freq set to 2400 done!

I first saw this problem with u-boot-fslc branch v2016.07
and linux-fslc (4.1.29 and 4.1.30).

Has anybody else experienced this?

Please advise,


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


Re: [U-Boot] [PATCH v2 5/5] ext4: optimize direntlen loops

2016-08-28 Thread Stefan Bruens
On Dienstag, 23. August 2016 10:27:42 CEST Michael Walle wrote:
> direntlen is always >= 8. Therefore, the loop condition is always true.
> 
> Signed-off-by: Michael Walle 
> Suggested-by: Stefan Brüns 

Thinking again about it, direntlen is read from disk, and as any outside data 
should be untrusted. In case the direntlen is 0, we get an infinite loop here.

Also see commit 54d68e9333ff65d135faac68fa01be4276f1371f :
fs: ext4: Prevent infinite loop in ext4fs_iterate_dir

So better drop this patch.

Kind regards,

Stefan

-- 
Stefan Brüns  /  Bergstraße 21  /  52062 Aachen
home: +49 241 53809034 mobile: +49 151 50412019
work: +49 2405 49936-424
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 13/13] ext4: initialize full inode for inodes bigger than 128 bytes

2016-08-28 Thread Stefan Brüns
Make sure the the extra_isize field (offset 128) is initialized to 0 to
mark any extra data as invalid.

Signed-off-by: Stefan Brüns 
---
 fs/ext4/ext4_write.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

v3: Patch added to series

diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index 81a750b..38fbf68 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -454,7 +454,7 @@ static int ext4fs_delete_file(int inodeno)
node_inode->data = ext4fs_root;
node_inode->ino = inodeno;
node_inode->inode_read = 0;
-   memcpy(&(node_inode->inode), , sizeof(struct ext2_inode));
+   memcpy(&(node_inode->inode), , fs->inodesz);
 
for (i = 0; i < no_blocks; i++) {
blknr = read_allocated_block(&(node_inode->inode), i);
@@ -560,7 +560,7 @@ static int ext4fs_delete_file(int inodeno)
 
read_buffer = read_buffer + blkoff;
inode_buffer = (struct ext2_inode *)read_buffer;
-   memset(inode_buffer, '\0', sizeof(struct ext2_inode));
+   memset(inode_buffer, '\0', fs->inodesz);
 
/* write the inode to original position in inode table */
if (ext4fs_put_metadata(start_block_address, blkno))
@@ -866,7 +866,7 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
ALLOC_CACHE_ALIGN_BUFFER(char, filename, 256);
memset(filename, 0x00, 256);
 
-   g_parent_inode = zalloc(sizeof(struct ext2_inode));
+   g_parent_inode = zalloc(fs->inodesz);
if (!g_parent_inode)
goto fail;
 
@@ -969,8 +969,7 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
if (ext4fs_log_journal(temp_ptr, parent_itable_blkno))
goto fail;
 
-   memcpy(temp_ptr + blkoff, g_parent_inode,
-   sizeof(struct ext2_inode));
+   memcpy(temp_ptr + blkoff, g_parent_inode, fs->inodesz);
if (ext4fs_put_metadata(temp_ptr, parent_itable_blkno))
goto fail;
} else {
@@ -978,8 +977,7 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
 * If parent and child fall in same inode table block
 * both should be kept in 1 buffer
 */
-   memcpy(temp_ptr + blkoff, g_parent_inode,
-  sizeof(struct ext2_inode));
+   memcpy(temp_ptr + blkoff, g_parent_inode, fs->inodesz);
gd_index--;
if (ext4fs_put_metadata(temp_ptr, itable_blkno))
goto fail;
-- 
2.9.3

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


[U-Boot] [PATCH v3 12/13] ext4: Use correct value for inode size even on revision 0 filesystems

2016-08-28 Thread Stefan Brüns
fs->inodesz is already correctly (i.e. dependent on fs revision)
initialized in ext4fs_mount.

Signed-off-by: Stefan Brüns 
---
 fs/ext4/ext4_write.c | 1 -
 include/ext_common.h | 2 --
 2 files changed, 3 deletions(-)

v3: Patch added to series

diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index 5e208ef..81a750b 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -609,7 +609,6 @@ int ext4fs_init(void)
 
/* populate fs */
fs->blksz = EXT2_BLOCK_SIZE(ext4fs_root);
-   fs->inodesz = INODE_SIZE_FILESYSTEM(ext4fs_root);
fs->sect_perblk = fs->blksz >> fs->dev_desc->log2blksz;
 
/* get the superblock */
diff --git a/include/ext_common.h b/include/ext_common.h
index 4cd2aa7..25216ca 100644
--- a/include/ext_common.h
+++ b/include/ext_common.h
@@ -52,8 +52,6 @@
 #define LOG2_BLOCK_SIZE(data) (le32_to_cpu\
(data->sblock.log2_block_size) \
+ EXT2_MIN_BLOCK_LOG_SIZE)
-#define INODE_SIZE_FILESYSTEM(data)(le16_to_cpu \
-   (data->sblock.inode_size))
 
 #define EXT2_FT_DIR2
 #define SUCCESS1
-- 
2.9.3

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


[U-Boot] [PATCH v3 11/13] ext4: Fix memory leak in case of failure

2016-08-28 Thread Stefan Brüns
temp_ptr should always be freed, even if the function is left via
goto fail.

Signed-off-by: Stefan Brüns 
---
 fs/ext4/ext4_write.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

v3: Patch added to series

diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index 50c8415..5e208ef 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -974,7 +974,6 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
sizeof(struct ext2_inode));
if (ext4fs_put_metadata(temp_ptr, parent_itable_blkno))
goto fail;
-   free(temp_ptr);
} else {
/*
 * If parent and child fall in same inode table block
@@ -985,7 +984,6 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
gd_index--;
if (ext4fs_put_metadata(temp_ptr, itable_blkno))
goto fail;
-   free(temp_ptr);
}
ext4fs_update();
ext4fs_deinit();
@@ -996,6 +994,7 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
fs->curr_inode_no = 0;
free(inode_buffer);
free(g_parent_inode);
+   free(temp_ptr);
g_parent_inode = NULL;
 
return 0;
@@ -1003,6 +1002,7 @@ fail:
ext4fs_deinit();
free(inode_buffer);
free(g_parent_inode);
+   free(temp_ptr);
g_parent_inode = NULL;
 
return -1;
-- 
2.9.3

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


[U-Boot] [PATCH v3 10/13] ext4: Avoid out-of-bounds access of block bitmap

2016-08-28 Thread Stefan Brüns
If the blocksize is 1024, count is initialized with 1. Incrementing count
by 8 will never match (count == fs->blksz * 8), and ptr may be
incremented beyond the buffer end if the bitmap is filled. Add the
startblock offset after the loop.

Remove the second loop, as only the first iteration will be done.

Signed-off-by: Stefan Brüns 
---
 fs/ext4/ext4_common.c | 34 --
 1 file changed, 12 insertions(+), 22 deletions(-)

v3: Patch added to series

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 362668b..11da6fa 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -158,18 +158,12 @@ static int _get_new_inode_no(unsigned char *buffer)
 
 static int _get_new_blk_no(unsigned char *buffer)
 {
-   unsigned char input;
-   int operand, status;
+   int operand;
int count = 0;
-   int j = 0;
+   int i;
unsigned char *ptr = buffer;
struct ext_filesystem *fs = get_fs();
 
-   if (fs->blksz != 1024)
-   count = 0;
-   else
-   count = 1;
-
while (*ptr == 255) {
ptr++;
count += 8;
@@ -177,21 +171,17 @@ static int _get_new_blk_no(unsigned char *buffer)
return -1;
}
 
-   for (j = 0; j < fs->blksz; j++) {
-   input = *ptr;
-   int i = 0;
-   while (i <= 7) {
-   operand = 1 << i;
-   status = input & operand;
-   if (status) {
-   i++;
-   count++;
-   } else {
-   *ptr |= operand;
-   return count;
-   }
+   if (fs->blksz == 1024)
+   count += 1;
+
+   for (i = 0; i <= 7; i++) {
+   operand = 1 << i;
+   if (*ptr & operand) {
+   count++;
+   } else {
+   *ptr |= operand;
+   return count;
}
-   ptr = ptr + 1;
}
 
return -1;
-- 
2.9.3

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


[U-Boot] [PATCH v3 06/13] ext4: scan all directory blocks when looking up an entry

2016-08-28 Thread Stefan Brüns
Scanning only the direct blocks of the directory file may falsely report
an existing file as nonexisting, and worse can also lead to creation
of a duplicate entry on file creation.

Signed-off-by: Stefan Brüns 
Reviewed-by: Lukasz Majewski 
---
 fs/ext4/ext4_common.c | 77 ---
 1 file changed, 36 insertions(+), 41 deletions(-)

v2: unchanged
v3: Added Reviewed-by
use parent_inode instead of g_parent_inode when determining directory size

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 96dc371..eae23b7 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -518,64 +518,56 @@ static int search_dir(struct ext2_inode *parent_inode, 
char *dirname)
 {
int status;
int inodeno = 0;
-   int totalbytes;
-   int templength;
-   int direct_blk_idx;
+   int offset;
+   int blk_idx;
long int blknr;
-   char *ptr = NULL;
unsigned char *block_buffer = NULL;
struct ext2_dirent *dir = NULL;
struct ext_filesystem *fs = get_fs();
+   uint32_t directory_blocks;
+   char *direntname;
 
-   /* read the block no allocated to a file */
-   for (direct_blk_idx = 0; direct_blk_idx < INDIRECT_BLOCKS;
-   direct_blk_idx++) {
-   blknr = read_allocated_block(parent_inode, direct_blk_idx);
-   if (blknr == 0)
-   goto fail;
+   directory_blocks = le32_to_cpu(parent_inode->size) >>
+   LOG2_BLOCK_SIZE(ext4fs_root);
+
+   block_buffer = zalloc(fs->blksz);
+   if (!block_buffer)
+   goto fail;
 
-   /* read the blocks of parent inode */
-   block_buffer = zalloc(fs->blksz);
-   if (!block_buffer)
+   /* get the block no allocated to a file */
+   for (blk_idx = 0; blk_idx < directory_blocks; blk_idx++) {
+   blknr = read_allocated_block(parent_inode, blk_idx);
+   if (blknr == 0)
goto fail;
 
+   /* read the directory block */
status = ext4fs_devread((lbaint_t)blknr * fs->sect_perblk,
0, fs->blksz, (char *)block_buffer);
if (status == 0)
goto fail;
 
+   offset = 0;
dir = (struct ext2_dirent *)block_buffer;
-   ptr = (char *)dir;
-   totalbytes = 0;
-   while (le16_to_cpu(dir->direntlen) >= 0) {
-   /*
-* blocksize-totalbytes because last directory
-* length i.e.,*dir->direntlen is free availble
-* space in the block that means
-* it is a last entry of directory entry
-*/
-   if (dir->inode && (strlen(dirname) == dir->namelen)) {
-   if (strncmp(dirname, ptr + sizeof(struct 
ext2_dirent), dir->namelen) == 0) {
-   inodeno = le32_to_cpu(dir->inode);
-   break;
-   }
+   direntname = (char *)block_buffer + sizeof(struct ext2_dirent);
+   while (le16_to_cpu(dir->direntlen) >= 8) {
+   if (dir->inode && (strlen(dirname) == dir->namelen) &&
+   (strncmp(dirname, direntname, dir->namelen) == 0)) {
+   inodeno = le32_to_cpu(dir->inode);
+   break;
}
 
-   if (fs->blksz - totalbytes == 
le16_to_cpu(dir->direntlen))
+   offset += le16_to_cpu(dir->direntlen);
+   if (offset >= fs->blksz)
break;
 
-   /* traversing the each directory entry */
-   templength = le16_to_cpu(dir->direntlen);
-   totalbytes = totalbytes + templength;
-   dir = (struct ext2_dirent *)((char *)dir + templength);
-   ptr = (char *)dir;
+   dir = (struct ext2_dirent *)(block_buffer + offset);
+   direntname += offset;
}
 
-   free(block_buffer);
-   block_buffer = NULL;
-
-   if (inodeno > 0)
+   if (inodeno > 0) {
+   free(block_buffer);
return inodeno;
+   }
}
 
 fail:
@@ -827,14 +819,17 @@ fail:
 
 int ext4fs_filename_unlink(char *filename)
 {
-   short direct_blk_idx = 0;
+   int blk_idx;
long int blknr = -1;
int inodeno = -1;
+   uint32_t directory_blocks;
+
+   directory_blocks = le32_to_cpu(g_parent_inode->size) >>
+   LOG2_BLOCK_SIZE(ext4fs_root);
 
/* read the block no 

[U-Boot] [PATCH v3 07/13] ext4: only update number of of unused inodes if GDT_CSUM feature is set

2016-08-28 Thread Stefan Brüns
e2fsck warns about "Group descriptor 0 marked uninitialized without
feature set."
The bg_itable_unused field is only defined if FEATURE_RO_COMPAT_GDT_CSUM
is set, and should be set (kept) zero otherwise.

Signed-off-by: Stefan Brüns 
---
 fs/ext4/ext4_common.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

v3: Patch added to series

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index eae23b7..0018937 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -980,12 +980,13 @@ int ext4fs_get_new_inode_no(void)
if (!journal_buffer || !zero_buffer)
goto fail;
struct ext2_block_group *bgd = (struct ext2_block_group *)fs->gdtable;
+   int has_gdt_chksum = le32_to_cpu(fs->sb->feature_ro_compat) &
+   EXT4_FEATURE_RO_COMPAT_GDT_CSUM ? 1 : 0;
 
if (fs->first_pass_ibmap == 0) {
for (i = 0; i < fs->no_blkgrp; i++) {
if (bgd[i].free_inodes) {
-   if (bgd[i].bg_itable_unused !=
-   bgd[i].free_inodes)
+   if (has_gdt_chksum)
bgd[i].bg_itable_unused =
bgd[i].free_inodes;
if (le16_to_cpu(bgd[i].bg_flags) & 
EXT4_BG_INODE_UNINIT) {
@@ -1006,7 +1007,8 @@ int ext4fs_get_new_inode_no(void)
(i * inodes_per_grp);
fs->first_pass_ibmap++;
ext4fs_bg_free_inodes_dec([i]);
-   ext4fs_bg_itable_unused_dec([i]);
+   if (has_gdt_chksum)
+   ext4fs_bg_itable_unused_dec([i]);
ext4fs_sb_free_inodes_dec(fs->sb);
status = ext4fs_devread(

(lbaint_t)le32_to_cpu(bgd[i].inode_id) *
@@ -1061,12 +1063,10 @@ restart:
goto fail;
prev_inode_bitmap_index = ibmap_idx;
}
-   if (bgd[ibmap_idx].bg_itable_unused !=
-   bgd[ibmap_idx].free_inodes)
+   ext4fs_bg_free_inodes_dec([ibmap_idx]);
+   if (has_gdt_chksum)
bgd[ibmap_idx].bg_itable_unused =
bgd[ibmap_idx].free_inodes;
-   ext4fs_bg_free_inodes_dec([ibmap_idx]);
-   ext4fs_bg_itable_unused_dec([ibmap_idx]);
ext4fs_sb_free_inodes_dec(fs->sb);
goto success;
}
-- 
2.9.3

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


[U-Boot] [PATCH v3 09/13] ext4: After completely filled group, scan next group from the beginning

2016-08-28 Thread Stefan Brüns
The last free block of a block group may be in its middle. After it has
been allocated, the next block group should be scanned from its beginning.

The following command triggers the bad behaviour (on a blocksize 1024 fs):

./sandbox/u-boot -c 'i=0; host bind 0 ./disk.raw ;
while test $i -lt 260 ; do echo $i; setexpr i $i + 1;
ext4write host 0:2 0 /X${i} 0x1450; done ;
ext4write host 0:2 0 /X240 0x2000 ; '

When 'X240' is extended from 5200 byte to 8192 byte, the new blocks should
start from the first free block (8811), but it uses the blocks 8098-8103
and 16296-16297 -- 8103 + 1 + 8192 = 16296. This can be shown with
debugfs, commands 'ffb' and 'stat X240'.

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

v3: Patch added to series

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 1ebdbe6..362668b 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -895,8 +895,8 @@ uint32_t ext4fs_get_new_blk_no(void)
 
goto fail;
} else {
-restart:
fs->curr_blkno++;
+restart:
/* get the blockbitmap index respective to blockno */
bg_idx = fs->curr_blkno / blk_per_grp;
if (fs->blksz == 1024) {
@@ -914,8 +914,9 @@ restart:
 
if (bgd[bg_idx].free_blocks == 0) {
debug("block group %u is full. Skipping\n", bg_idx);
-   fs->curr_blkno = fs->curr_blkno + blk_per_grp;
-   fs->curr_blkno--;
+   fs->curr_blkno = (bg_idx + 1) * blk_per_grp;
+   if (fs->blksz == 1024)
+   fs->curr_blkno += 1;
goto restart;
}
 
@@ -932,6 +933,7 @@ restart:
   bg_idx) != 0) {
debug("going for restart for the block no %ld %u\n",
  fs->curr_blkno, bg_idx);
+   fs->curr_blkno++;
goto restart;
}
 
-- 
2.9.3

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


[U-Boot] [PATCH v3 05/13] ext4: Avoid corruption of directories with hash tree indexes

2016-08-28 Thread Stefan Brüns
While directories can be read using the old linear scan method, adding a
new file would require updating the index tree (alternatively, the whole
tree could be removed).

Signed-off-by: Stefan Brüns 
Reviewed-by: Lukasz Majewski 
---
 fs/ext4/ext4_write.c | 5 +
 include/ext4fs.h | 1 +
 2 files changed, 6 insertions(+)

v2: unchanged
v3: Added Reviewed-by

diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index 42abd8d..50c8415 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -881,6 +881,11 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
goto fail;
if (ext4fs_iget(parent_inodeno, g_parent_inode))
goto fail;
+   /* do not mess up a directory using hash trees */
+   if (le32_to_cpu(g_parent_inode->flags) & EXT4_INDEX_FL) {
+   printf("hash tree directory\n");
+   goto fail;
+   }
/* check if the filename is already present in root */
existing_file_inodeno = ext4fs_filename_unlink(filename);
if (existing_file_inodeno != -1) {
diff --git a/include/ext4fs.h b/include/ext4fs.h
index e3f6216..6e31c73 100644
--- a/include/ext4fs.h
+++ b/include/ext4fs.h
@@ -28,6 +28,7 @@
 #define __EXT4__
 #include 
 
+#define EXT4_INDEX_FL  0x1000 /* Inode uses hash tree index */
 #define EXT4_EXTENTS_FL0x0008 /* Inode uses extents */
 #define EXT4_EXT_MAGIC 0xf30a
 #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM0x0010
-- 
2.9.3

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


[U-Boot] [PATCH v3 04/13] ext4: Scan all directory blocks for space when inserting a new entry

2016-08-28 Thread Stefan Brüns
Previously, only the last directory block was scanned for available space.
Instead, scan all blocks back to front, and if no sufficient space is
found, eventually append a new block.
Blocks are only appended if the directory does not use extents or the new
block would require insertion of indirect blocks, as the old code does.

Signed-off-by: Stefan Brüns 
---
 fs/ext4/ext4_common.c | 72 ---
 1 file changed, 28 insertions(+), 44 deletions(-)

v3: Patch added to series

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 49d6465..96dc371 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -365,14 +365,10 @@ int ext4fs_update_parent_dentry(char *filename, int 
file_type)
 {
unsigned int *zero_buffer = NULL;
char *root_first_block_buffer = NULL;
-   int direct_blk_idx;
-   long int root_blknr;
+   int blk_idx;
long int first_block_no_of_root = 0;
-   long int previous_blknr = -1;
int totalbytes = 0;
-   short int padding_factor = 0;
unsigned int new_entry_byte_reqd;
-   unsigned int last_entry_dirlen;
int sizeof_void_space = 0;
int templength = 0;
int inodeno = -1;
@@ -384,6 +380,7 @@ int ext4fs_update_parent_dentry(char *filename, int 
file_type)
uint32_t new_blk_no;
uint32_t new_size;
uint32_t new_blockcnt;
+   uint32_t directory_blocks;
 
zero_buffer = zalloc(fs->blksz);
if (!zero_buffer) {
@@ -396,19 +393,16 @@ int ext4fs_update_parent_dentry(char *filename, int 
file_type)
printf("No Memory\n");
return -1;
}
+   new_entry_byte_reqd = ROUND(strlen(filename) +
+   sizeof(struct ext2_dirent), 4);
 restart:
+   directory_blocks = le32_to_cpu(g_parent_inode->size) >>
+   LOG2_BLOCK_SIZE(ext4fs_root);
+   blk_idx = directory_blocks - 1;
 
+restart_read:
/* read the block no allocated to a file */
-   for (direct_blk_idx = 0; direct_blk_idx < INDIRECT_BLOCKS;
-direct_blk_idx++) {
-   root_blknr = read_allocated_block(g_parent_inode,
- direct_blk_idx);
-   if (root_blknr == 0) {
-   first_block_no_of_root = previous_blknr;
-   break;
-   }
-   previous_blknr = root_blknr;
-   }
+   first_block_no_of_root = read_allocated_block(g_parent_inode, blk_idx);
 
status = ext4fs_devread((lbaint_t)first_block_no_of_root
* fs->sect_perblk,
@@ -420,42 +414,33 @@ restart:
goto fail;
dir = (struct ext2_dirent *)root_first_block_buffer;
totalbytes = 0;
+
while (le16_to_cpu(dir->direntlen) > 0) {
-   /*
-* blocksize-totalbytes because last directory length
-* i.e. dir->direntlen is free availble space in the
-* block that means  it is a last entry of directory
-* entry
-*/
+   unsigned short used_len = ROUND(dir->namelen +
+   sizeof(struct ext2_dirent), 4);
 
-   /* traversing the each directory entry */
+   /* last entry of block */
if (fs->blksz - totalbytes == le16_to_cpu(dir->direntlen)) {
-   if (strlen(filename) % 4 != 0)
-   padding_factor = 4 - (strlen(filename) % 4);
-
-   new_entry_byte_reqd = strlen(filename) +
-   sizeof(struct ext2_dirent) + padding_factor;
-   padding_factor = 0;
-   /*
-* update last directory entry length to its
-* length because we are creating new directory
-* entry
-*/
-   if (dir->namelen % 4 != 0)
-   padding_factor = 4 - (dir->namelen % 4);
 
-   last_entry_dirlen = dir->namelen +
-   sizeof(struct ext2_dirent) + padding_factor;
-   if ((fs->blksz - totalbytes - last_entry_dirlen) <
-   new_entry_byte_reqd) {
-   printf("Last Block Full:Allocate new block\n");
+   /* check if new entry fits */
+   if ((used_len + new_entry_byte_reqd) <=
+   le16_to_cpu(dir->direntlen)) {
+   dir->direntlen = cpu_to_le16(used_len);
+   break;
+   } else {
+   if (blk_idx > 0) {
+   printf("Block full, trying previous\n");
+   blk_idx--;
+  

[U-Boot] [PATCH v3 02/13] ext4: propagate error if creation of directory entry fails

2016-08-28 Thread Stefan Brüns
In case the dir entry creation failed, ext4fs_write would later overwrite
a random inode, as inodeno was never initialized.

Signed-off-by: Stefan Brüns 
Reviewed-by: Lukasz Majewski 
---
 fs/ext4/ext4_common.c | 12 ++--
 fs/ext4/ext4_common.h |  2 +-
 fs/ext4/ext4_write.c  |  4 +++-
 3 files changed, 10 insertions(+), 8 deletions(-)

v2: unchanged
v3: Added Reviewed-by

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 3736533..fd3522e 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -361,7 +361,7 @@ static int check_void_in_dentry(struct ext2_dirent *dir, 
char *filename)
return 0;
 }
 
-void ext4fs_update_parent_dentry(char *filename, int *p_ino, int file_type)
+int ext4fs_update_parent_dentry(char *filename, int file_type)
 {
unsigned int *zero_buffer = NULL;
char *root_first_block_buffer = NULL;
@@ -375,7 +375,7 @@ void ext4fs_update_parent_dentry(char *filename, int 
*p_ino, int file_type)
unsigned int last_entry_dirlen;
int sizeof_void_space = 0;
int templength = 0;
-   int inodeno;
+   int inodeno = -1;
int status;
struct ext_filesystem *fs = get_fs();
/* directory entry */
@@ -388,13 +388,13 @@ void ext4fs_update_parent_dentry(char *filename, int 
*p_ino, int file_type)
zero_buffer = zalloc(fs->blksz);
if (!zero_buffer) {
printf("No Memory\n");
-   return;
+   return -1;
}
root_first_block_buffer = zalloc(fs->blksz);
if (!root_first_block_buffer) {
free(zero_buffer);
printf("No Memory\n");
-   return;
+   return -1;
}
 restart:
 
@@ -513,8 +513,6 @@ restart:
temp_dir = temp_dir + sizeof(struct ext2_dirent);
memcpy(temp_dir, filename, strlen(filename));
 
-   *p_ino = inodeno;
-
/* update or write  the 1st block of root inode */
if (ext4fs_put_metadata(root_first_block_buffer,
first_block_no_of_root))
@@ -523,6 +521,8 @@ restart:
 fail:
free(zero_buffer);
free(root_first_block_buffer);
+
+   return inodeno;
 }
 
 static int search_dir(struct ext2_inode *parent_inode, char *dirname)
diff --git a/fs/ext4/ext4_common.h b/fs/ext4/ext4_common.h
index 370a717..cc9d0c5 100644
--- a/fs/ext4/ext4_common.h
+++ b/fs/ext4/ext4_common.h
@@ -61,7 +61,7 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name,
 uint32_t ext4fs_div_roundup(uint32_t size, uint32_t n);
 uint16_t ext4fs_checksum_update(unsigned int i);
 int ext4fs_get_parent_inode_num(const char *dirname, char *dname, int flags);
-void ext4fs_update_parent_dentry(char *filename, int *p_ino, int file_type);
+int ext4fs_update_parent_dentry(char *filename, int file_type);
 uint32_t ext4fs_get_new_blk_no(void);
 int ext4fs_get_new_inode_no(void);
 void ext4fs_reset_block_bmap(long int blockno, unsigned char *buffer,
diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index 70a3b5b..42abd8d 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -907,7 +907,9 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
goto fail;
}
 
-   ext4fs_update_parent_dentry(filename, , FILETYPE_REG);
+   inodeno = ext4fs_update_parent_dentry(filename, FILETYPE_REG);
+   if (inodeno == -1)
+   goto fail;
/* prepare file inode */
inode_buffer = zalloc(fs->inodesz);
if (!inode_buffer)
-- 
2.9.3

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


[U-Boot] [PATCH v3 08/13] ext4: do not clear zalloc'ed buffers a second time

2016-08-28 Thread Stefan Brüns
zero_buffer is never written, thus clearing it is pointless.
journal_buffer is completely initialized by ext4fs_devread (or in case
of failure, not used).

Signed-off-by: Stefan Brüns 
---
 fs/ext4/ext4_common.c | 3 ---
 1 file changed, 3 deletions(-)

v3: Patch added to series

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 0018937..1ebdbe6 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -921,7 +921,6 @@ restart:
 
if (le16_to_cpu(bgd[bg_idx].bg_flags) & EXT4_BG_BLOCK_UNINIT) {
uint16_t new_flags;
-   memset(zero_buffer, '\0', fs->blksz);
put_ext4((uint64_t)le32_to_cpu(bgd[bg_idx].block_id) * 
fs->blksz,
 zero_buffer, fs->blksz);
memcpy(fs->blk_bmaps[bg_idx], zero_buffer, fs->blksz);
@@ -938,7 +937,6 @@ restart:
 
/* journal backup */
if (prev_bg_bitmap_index != bg_idx) {
-   memset(journal_buffer, '\0', fs->blksz);
status = ext4fs_devread(

(lbaint_t)le32_to_cpu(bgd[bg_idx].block_id)
* fs->sect_perblk,
@@ -1032,7 +1030,6 @@ restart:
ibmap_idx = fs->curr_inode_no / inodes_per_grp;
if (le16_to_cpu(bgd[ibmap_idx].bg_flags) & 
EXT4_BG_INODE_UNINIT) {
int new_flags;
-   memset(zero_buffer, '\0', fs->blksz);
put_ext4((uint64_t)le32_to_cpu(bgd[ibmap_idx].inode_id) 
* fs->blksz,
 zero_buffer, fs->blksz);
new_flags = le16_to_cpu(bgd[ibmap_idx].bg_flags) & 
~EXT4_BG_INODE_UNINIT;
-- 
2.9.3

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


[U-Boot] [PATCH v3 01/13] ext4: fix possible crash on directory traversal, ignore deleted entries

2016-08-28 Thread Stefan Brüns
The following command triggers a segfault in search_dir:
./sandbox/u-boot -c 'host bind 0 ./sandbox/test/fs/3GB.ext4.img ;
ext4write host 0 0 /./foo 0x10'

The following command triggers a segfault in check_filename:
./sandbox/u-boot -c 'host bind 0 ./sandbox/test/fs/3GB.ext4.img ;
ext4write host 0 0 /. 0x10'

"." is the first entry in the directory, thus previous_dir is NULL. The
whole previous_dir block in search_dir seems to be a bad copy from
check_filename(...). As the changed data is not written to disk, the
statement is mostly harmless, save the possible NULL-ptr reference.

Typically a file is unlinked by extending the direntlen of the previous
entry. If the entry is the first entry in the directory block, it is
invalidated by setting inode=0.

The inode==0 case is hard to trigger without crafted filesystems. It only
hits if the first entry in a directory block is deleted and later a lookup
for the entry (by name) is done.

Signed-off-by: Stefan Brüns 
Reviewed-by: Lukasz Majewski 
---
 fs/ext4/ext4_common.c | 58 +++
 fs/ext4/ext4_write.c  |  2 +-
 include/ext4fs.h  |  2 +-
 3 files changed, 23 insertions(+), 39 deletions(-)

v2: Fix bad filename compare on delete, used substring only
v3: Added Reviewed-by

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 4a003cf..3736533 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -528,16 +528,14 @@ fail:
 static int search_dir(struct ext2_inode *parent_inode, char *dirname)
 {
int status;
-   int inodeno;
+   int inodeno = 0;
int totalbytes;
int templength;
int direct_blk_idx;
long int blknr;
-   int found = 0;
char *ptr = NULL;
unsigned char *block_buffer = NULL;
struct ext2_dirent *dir = NULL;
-   struct ext2_dirent *previous_dir = NULL;
struct ext_filesystem *fs = get_fs();
 
/* read the block no allocated to a file */
@@ -547,7 +545,7 @@ static int search_dir(struct ext2_inode *parent_inode, char 
*dirname)
if (blknr == 0)
goto fail;
 
-   /* read the blocks of parenet inode */
+   /* read the blocks of parent inode */
block_buffer = zalloc(fs->blksz);
if (!block_buffer)
goto fail;
@@ -567,15 +565,9 @@ static int search_dir(struct ext2_inode *parent_inode, 
char *dirname)
 * space in the block that means
 * it is a last entry of directory entry
 */
-   if (strlen(dirname) == dir->namelen) {
+   if (dir->inode && (strlen(dirname) == dir->namelen)) {
if (strncmp(dirname, ptr + sizeof(struct 
ext2_dirent), dir->namelen) == 0) {
-   uint16_t new_len;
-   new_len = 
le16_to_cpu(previous_dir->direntlen);
-   new_len += le16_to_cpu(dir->direntlen);
-   previous_dir->direntlen = 
cpu_to_le16(new_len);
inodeno = le32_to_cpu(dir->inode);
-   dir->inode = 0;
-   found = 1;
break;
}
}
@@ -586,19 +578,15 @@ static int search_dir(struct ext2_inode *parent_inode, 
char *dirname)
/* traversing the each directory entry */
templength = le16_to_cpu(dir->direntlen);
totalbytes = totalbytes + templength;
-   previous_dir = dir;
dir = (struct ext2_dirent *)((char *)dir + templength);
ptr = (char *)dir;
}
 
-   if (found == 1) {
-   free(block_buffer);
-   block_buffer = NULL;
-   return inodeno;
-   }
-
free(block_buffer);
block_buffer = NULL;
+
+   if (inodeno > 0)
+   return inodeno;
}
 
 fail:
@@ -774,15 +762,13 @@ fail:
return result_inode_no;
 }
 
-static int check_filename(char *filename, unsigned int blknr)
+static int unlink_filename(char *filename, unsigned int blknr)
 {
-   unsigned int first_block_no_of_root;
int totalbytes = 0;
int templength = 0;
int status, inodeno;
int found = 0;
char *root_first_block_buffer = NULL;
-   char *root_first_block_addr = NULL;
struct ext2_dirent *dir = NULL;
struct ext2_dirent *previous_dir = NULL;
char *ptr = NULL;
@@ -790,18 +776,15 @@ static int check_filename(char *filename, unsigned int 
blknr)
 

[U-Boot] [PATCH v3 00/13] Fix several possible crashes/corruptions in ext4

2016-08-28 Thread Stefan Brüns
The U-Boot ext4 support has some bugs which either cause U-Boot crashes
or lead to filesystem corruption.

This series goes on top of the endian patch series by Michael Walle.
It has been rebased against v2 of the series.

The first 6 patches have already been reviewed, all later patches are
new. Revieved-by has been added as appropriate.

Stefan Brüns (13):
  ext4: fix possible crash on directory traversal, ignore deleted
entries
  ext4: propagate error if creation of directory entry fails
  ext4: Do not crash when trying to grow a directory using extents
  ext4: Scan all directory blocks for space when inserting a new entry
  ext4: Avoid corruption of directories with hash tree indexes
  ext4: scan all directory blocks when looking up an entry
  ext4: only update number of of unused inodes if GDT_CSUM feature is
set
  ext4: do not clear zalloc'ed buffers a second time
  ext4: After completely filled group, scan next group from the
beginning
  ext4: Avoid out-of-bounds access of block bitmap
  ext4: Fix memory leak in case of failure
  ext4: Use correct value for inode size even on revision 0 filesystems
  ext4: initialize full inode for inodes bigger than 128 bytes

 fs/ext4/ext4_common.c | 273 +-
 fs/ext4/ext4_common.h |   2 +-
 fs/ext4/ext4_write.c  |  28 +++---
 include/ext4fs.h  |   3 +-
 include/ext_common.h  |   2 -
 5 files changed, 134 insertions(+), 174 deletions(-)

-- 
2.9.3

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


[U-Boot] [PATCH v3 03/13] ext4: Do not crash when trying to grow a directory using extents

2016-08-28 Thread Stefan Brüns
The following command crashes u-boot:
./sandbox/u-boot -c 'i=0; host bind 0 ./sandbox/test/fs/3GB.ext4.img ;
  while test $i -lt 200 ; do echo $i; setexpr i $i + 1;
  ext4write host 0 0 /foobar${i} 0; done'

Previously, the code updated the direct_block even for extents, and
fortunately crashed before pushing garbage to the disk.

Signed-off-by: Stefan Brüns 
Reviewed-by: Lukasz Majewski 
---
 fs/ext4/ext4_common.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

v2: unchanged
v3: Added Reviewed-by

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index fd3522e..49d6465 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -448,8 +448,13 @@ restart:
sizeof(struct ext2_dirent) + padding_factor;
if ((fs->blksz - totalbytes - last_entry_dirlen) <
new_entry_byte_reqd) {
-   printf("1st Block Full:Allocate new block\n");
+   printf("Last Block Full:Allocate new block\n");
 
+   if (le32_to_cpu(g_parent_inode->flags) &
+   EXT4_EXTENTS_FL) {
+   printf("Directory uses extents\n");
+   goto fail;
+   }
if (direct_blk_idx == INDIRECT_BLOCKS - 1) {
printf("Directory exceeds limit\n");
goto fail;
-- 
2.9.3

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


Re: [U-Boot] [PATCH 2/2] configs: ti: armv7_common: Enable DISPLAY_{CPU/BOARD}INFO

2016-08-28 Thread Tom Rini
On Sat, Aug 27, 2016 at 05:23:55PM +0530, Lokesh Vutla wrote:

> Enable CONFIG_DISPLAY_{CPU/BOARD}INFO on all TI platforms.
> Also removing the duplicated configs.
> 
> Signed-off-by: Lokesh Vutla 
> ---
>  include/configs/ti_armv7_common.h| 4 
>  include/configs/ti_armv7_keystone2.h | 1 -
>  include/configs/ti_omap4_common.h| 2 --
>  include/configs/ti_omap5_common.h| 3 ---
>  4 files changed, 4 insertions(+), 6 deletions(-)

This is the wrong direction.  Please add an entry to common/Kconfig (a
"hidden" one) and select it from board/ti/*/Kconfig.  And this will need
some cleaning up of some other boards/ Kconfig files that introduced it
locally and instead should select this new option.  Thanks!

-- 
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] [Bug] Crash when running "./sandbox/u-boot -c done"

2016-08-28 Thread Stefan Bruens
Hi everyone,

although 'done' by itself is not a syntactically correct command, it should 
not crash u-boot.

Kind regards,

Stefan

-
(gdb) r
Starting program: /home/stefan/Documents/Sources/u-boot/sandbox/u-boot -c done
Missing separate debuginfos, use: zypper install glibc-
debuginfo-2.23-6.1.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".


U-Boot 2016.09-rc1-00480-g5052847-dirty (Aug 26 2016 - 02:06:58 +0200)

DRAM:  128 MiB
MMC:   
Using default environment

In:serial
Out:   serial
Err:   serial
SCSI:  Net:   No ethernet found.
IDE:   Bus 0: not available  
syntax error

Program received signal SIGSEGV, Segmentation fault.
0x004167be in static_peek () at ../common/cli_hush.c:920
920 }
Missing separate debuginfos, use: zypper install libFLAC8-
debuginfo-1.3.1-2.5.x86_64 libSDL-1_2-0-debuginfo-1.2.15-19.6.x86_64 libX11-6-
debuginfo-1.6.3-2.15.x86_64 libXau6-debuginfo-1.0.8-6.5.x86_64 libXext6-
debuginfo-1.3.3-3.17.x86_64 libXrandr2-debuginfo-1.5.0-2.3.x86_64 libXrender1-
debuginfo-0.9.9-1.18.x86_64 libasound2-debuginfo-1.1.2-1.1.x86_64 libcap2-
debuginfo-2.22-14.100.x86_64 libdbus-1-3-debuginfo-1.10.8-1.3.x86_64 
libgcrypt20-debuginfo-1.6.5-2.2.x86_64 libgpg-error0-debuginfo-1.24-1.1.x86_64 
libjson-c2-debuginfo-0.12.1-1.1.x86_64 liblzma5-debuginfo-5.2.2-4.87.x86_64 
libogg0-debuginfo-1.3.2-1.5.x86_64 libpcre1-debuginfo-8.39-2.1.x86_64 
libpulse0-debuginfo-9.0-1.1.x86_64 libselinux1-debuginfo-2.5-2.1.x86_64 
libsndfile1-debuginfo-1.0.26-2.2.x86_64 libspeex1-debuginfo-1.2~rc2-2.4.x86_64 
libsystemd0-debuginfo-228-11.1.x86_64 libvorbis0-debuginfo-1.3.5-1.7.x86_64 
libvorbisenc2-debuginfo-1.3.5-1.7.x86_64 libxcb1-debuginfo-1.12-1.3.x86_64
(gdb) bt
#0  0x004167be in static_peek () at ../common/cli_hush.c:920
#1  0x00417abf in parse_stream_outer (inp=inp@entry=0x7fffd910, 
flag=flag@entry=2) at ../common/cli_hush.c:3248
#2  0x00416d88 in parse_string_outer (s=s@entry=0x7fffe165 "done", 
flag=flag@entry=2) at ../common/cli_hush.c:3275
#3  0x00426830 in run_command_list (cmd=0x7fffe165 "done", 
len=, len@entry=-1, flag=flag@entry=0) at ../common/cli.c:98
#4  0x00403191 in sandbox_main_loop_init () at ../arch/sandbox/cpu/
start.c:89
#5  0x00418162 in run_main_loop () at ../common/board_r.c:743
#6  0x00466941 in initcall_run_list 
(init_sequence=init_sequence@entry=0x7120e0 ) at ../lib/
initcall.c:31
#7  0x0041833b in board_init_r (new_gd=, 
dest_addr=dest_addr@entry=0) at ../common/board_r.c:994
#8  0x004021b9 in main (argc=3, argv=0x7fffdc58) at ../arch/
sandbox/cpu/start.c:309
(gdb) list
915 int rc;
916 rc = b_addchr(o, '\\');
917 if (rc) return rc;
918 }
919 return b_addchr(o, ch);
920 }
921
922 #ifndef __U_BOOT__
923 static int b_adduint(o_string *o, unsigned int i)
924 {
(gdb) Quit

--
-- 
Stefan Brüns  /  Bergstraße 21  /  52062 Aachen
home: +49 241 53809034 mobile: +49 151 50412019
work: +49 2405 49936-424

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


Re: [U-Boot] [PATCH] ext4: fix possible crash on directory traversal, ignore deleted entries

2016-08-28 Thread Stefan Bruens
On Freitag, 19. August 2016 15:54:51 CEST you wrote:
> On Sun, Aug 14, 2016 at 05:11:04AM +0200, Stefan Brüns wrote:
> > The following command triggers a segfault in search_dir:
> > ./sandbox/u-boot -c 'host bind 0 ./sandbox/test/fs/3GB.ext4.img ;
> > 
> > ext4write host 0 0 /./foo 0x10'
> > 
> > The following command triggers a segfault in check_filename:
> > ./sandbox/u-boot -c 'host bind 0 ./sandbox/test/fs/3GB.ext4.img ;
> > 
> > ext4write host 0 0 /. 0x10'
> > 
> > "." is the first entry in the directory, thus previous_dir is NULL. The
> > whole previous_dir block in search_dir seems to be a bad copy from
> > check_filename(...). As the changed data is not written to disk, the
> > statement is mostly harmless, save the possible NULL-ptr reference.
> > 
> > Typically a file is unlinked by extending the direntlen of the previous
> > entry. If the entry is the first entry in the directory block, it is
> > invalidated by setting inode=0.
> > 
> > The inode==0 case is hard to trigger without crafted filesystems. It only
> > hits if the first entry in a directory block is deleted and later a lookup
> > for the entry (by name) is done.
> > 
> > Signed-off-by: Stefan Brüns 
> > ---
> > 
> >  fs/ext4/ext4_common.c | 57
> >  ++- fs/ext4/ext4_write.c
> >   |  2 +-
> >  include/ext4fs.h  |  2 +-
> >  3 files changed, 22 insertions(+), 39 deletions(-)
> 
> Can you please add the test case to the existing scripts?  Thanks!

Adding this to the current test script is somewhat problematic. The test runs 
all tests for fat and ext4, so each testcase should be file system agnostic. 
Unfortunately fat and ext4 (at least as implemented in U-Boot) have different 
semantics, as ext4 in U-Boot requires all path to absolute paths, whereas fat 
seems to require something else (relative path? absolute path, but without 
leading '/'?).

Calling 'fatwrite host 0 0 /. 0x10' happily creates a directory! called '/.', 
'fatwrite host 0 0 /./foo 0x10' creates a file and copletely messes up the 
filesystem (according to fsck.vfat and mounting the fs in linux).

Any advise?

Kind regards,

Stefan

-- 
Stefan Brüns  /  Bergstraße 21  /  52062 Aachen
home: +49 241 53809034 mobile: +49 151 50412019
work: +49 2405 49936-424
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] imx: mx7dsabresd: consolidate BOOT_FROM

2016-08-28 Thread Stefano Babic
Hi Peng,

On 28/08/2016 13:52, Peng Fan wrote:
> Hi Stefano,
> 
> On Fri, Aug 26, 2016 at 04:03:00PM +0200, Stefano Babic wrote:
>> Hi Peng,
>>
>> On 11/08/2016 08:09, Peng Fan wrote:
>>> To i.MX7, different boot medias' IVT offset is fixed at 0x400.
>>> So consolidate BOOT_FROM to use FLASH_OFFSET_STANDARD.
>>>
>>> Signed-off-by: Peng Fan 
>>> Cc: Stefano Babic 
>>> ---
>>>  board/freescale/mx7dsabresd/imximage.cfg | 7 ++-
>>>  1 file changed, 2 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/board/freescale/mx7dsabresd/imximage.cfg 
>>> b/board/freescale/mx7dsabresd/imximage.cfg
>>> index 76574ff..7314316 100644
>>> --- a/board/freescale/mx7dsabresd/imximage.cfg
>>> +++ b/board/freescale/mx7dsabresd/imximage.cfg
>>> @@ -16,11 +16,8 @@
>>>  
>>>  IMAGE_VERSION 2
>>>  
>>> -/*
>>> - * Boot Device : sd
>>> - */
>>> -
>>> -BOOT_FROM  sd
>>> +/* valid for various boot medias */
>>> +BOOT_FROM  FLASH_OFFSET_STANDARD
>>>  
>>
>> But this is not:
>>
>>
>> BOOT_OFFSET  FLASH_OFFSET_STANDARD
>>
>> istead of BOTT_FROM ? It looks to me wrong.
> 
> My bad. You are right. I missed to do a compile test for this.

Ok, no problem. I fix it myself and I apply it.

Best regards,
Stefano

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: board: cm_fx6: fix mtd partition fixup

2016-08-28 Thread Nikita Kiryanov
Hi Christopher,

On Tue, Aug 23, 2016 at 04:08:52PM +0200, christopher.spinr...@rwth-aachen.de 
wrote:
> From: Christopher Spinrath 
> 
> ft_board_setup may return early in the case that the board revision
> cannot be obtained. In that case it is assumed that no revision
> specific correction in the fdt is neccessary. But the mtd partitions
> will not be fixed up either altough they are not revision specific.
> 
> Move the call to fdt_fixup_mtdparts in front of the revision specific
> part to ensure that the partitions are fixed up even if the board
> revision cannot be obtained.
> 
> While on it, fix a spelling mistake in a comment introduced by the
> same commit.

Reviewed-by: Nikita Kiryanov 

> 
> Fixes: 62d6bac66038 ("ARM: board: cm_fx6: fixup mtd partitions in the fdt")
> Signed-off-by: Christopher Spinrath 
> ---
>  board/compulab/cm_fx6/cm_fx6.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] imx: mx7dsabresd: consolidate BOOT_FROM

2016-08-28 Thread Peng Fan
Hi Stefano,

On Fri, Aug 26, 2016 at 04:03:00PM +0200, Stefano Babic wrote:
>Hi Peng,
>
>On 11/08/2016 08:09, Peng Fan wrote:
>> To i.MX7, different boot medias' IVT offset is fixed at 0x400.
>> So consolidate BOOT_FROM to use FLASH_OFFSET_STANDARD.
>> 
>> Signed-off-by: Peng Fan 
>> Cc: Stefano Babic 
>> ---
>>  board/freescale/mx7dsabresd/imximage.cfg | 7 ++-
>>  1 file changed, 2 insertions(+), 5 deletions(-)
>> 
>> diff --git a/board/freescale/mx7dsabresd/imximage.cfg 
>> b/board/freescale/mx7dsabresd/imximage.cfg
>> index 76574ff..7314316 100644
>> --- a/board/freescale/mx7dsabresd/imximage.cfg
>> +++ b/board/freescale/mx7dsabresd/imximage.cfg
>> @@ -16,11 +16,8 @@
>>  
>>  IMAGE_VERSION 2
>>  
>> -/*
>> - * Boot Device : sd
>> - */
>> -
>> -BOOT_FROM   sd
>> +/* valid for various boot medias */
>> +BOOT_FROM   FLASH_OFFSET_STANDARD
>>  
>
>But this is not:
>
>
>BOOT_OFFSETFLASH_OFFSET_STANDARD
>
>istead of BOTT_FROM ? It looks to me wrong.

My bad. You are right. I missed to do a compile test for this.

Thanks,
Peng.

>
>Best regards,
>Stefano Babic
>
>-- 
>=
>DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
>HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
>=
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot