[U-Boot] [PATCH] net: Protect net_state from reentrant net_loop()

2018-05-08 Thread Leonid Iziumtsev
Global variable "net_state" is used in net_loop() state-machine.
But it happens that some times the net_loop() can be called
multiple times in the same call stack. For example when the
netconsole is enabled and we print the message while some other
net protocol is in action. Netconsole will overwrite the "net_state"
and that will break the logic for earlier started protocol.

To protect the state save and restore "net_state" variable each
time when we enter and exit net_loop().

Signed-off-by: Leonid Iziumtsev <leonid.iziumt...@se.atlascopco.com>
---
 net/net.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/net.c b/net/net.c
index c3adba2..cb34c3b 100644
--- a/net/net.c
+++ b/net/net.c
@@ -417,6 +417,7 @@ void net_init(void)
 int net_loop(enum proto_t protocol)
 {
int ret = -EINVAL;
+   enum net_loop_state prev_net_state = net_state;

net_restarted = 0;
net_dev_exists = 0;
@@ -454,6 +455,7 @@ restart:
case 1:
/* network not configured */
eth_halt();
+   net_set_state(prev_net_state);
return -ENODEV;

case 2:
@@ -674,6 +676,7 @@ done:
net_set_udp_handler(NULL);
net_set_icmp_handler(NULL);
 #endif
+   net_set_state(prev_net_state);
return ret;
 }

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


[U-Boot] [PATCH] net: Fix netretry condition

2018-03-09 Thread Leonid Iziumtsev
The "net_try_count" counter starts from "1".
And the "retrycnt" contains requested amount of retries.

With current logic, that means that the actual retry amount
will be one time less then what we set in "netretry" env.
For example setting "netretry" to "once" will make "retrycnt"
equal "1", so no retries will be triggered at all.

Fix the logic by changing the statement of "if" condition.

Signed-off-by: Leonid Iziumtsev <leonid.iziumt...@se.atlascopco.com>
---
 net/net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/net.c b/net/net.c
index 4259c9e..8a9b69c 100644
--- a/net/net.c
+++ b/net/net.c
@@ -683,7 +683,7 @@ int net_start_again(void)
retry_forever = 0;
}

-   if ((!retry_forever) && (net_try_count >= retrycnt)) {
+   if ((!retry_forever) && (net_try_count > retrycnt)) {
eth_halt();
net_set_state(NETLOOP_FAIL);
/*
-- 
2.7.4
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] mx27: 16-bit wide watchdog registers

2016-03-20 Thread Leonid Iziumtsev
From: Leonid Iziumtsev <leonid.iziumt...@se.atlascopco.com>

Make the watchdog registers 16-bit wide, as they are according to TRM.

Signed-off-by: Leonid Iziumtsev <leonid.iziumt...@se.atlascopco.com>
---
 arch/arm/cpu/arm926ejs/mx27/reset.c   | 8 
 arch/arm/include/asm/arch-mx27/imx-regs.h | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/mx27/reset.c 
b/arch/arm/cpu/arm926ejs/mx27/reset.c
index f7b4a1c..e764986 100644
--- a/arch/arm/cpu/arm926ejs/mx27/reset.c
+++ b/arch/arm/cpu/arm926ejs/mx27/reset.c
@@ -27,14 +27,14 @@ void reset_cpu(ulong ignored)
 {
struct wdog_regs *regs = (struct wdog_regs *)IMX_WDT_BASE;
/* Disable watchdog and set Time-Out field to 0 */
-   writel(0x, >wcr);
+   writew(0x, >wcr);
 
/* Write Service Sequence */
-   writel(0x, >wsr);
-   writel(0x, >wsr);
+   writew(0x, >wsr);
+   writew(0x, >wsr);
 
/* Enable watchdog */
-   writel(WCR_WDE, >wcr);
+   writew(WCR_WDE, >wcr);
 
while (1);
/*NOTREACHED*/
diff --git a/arch/arm/include/asm/arch-mx27/imx-regs.h 
b/arch/arm/include/asm/arch-mx27/imx-regs.h
index baf1d29..40b76d2 100644
--- a/arch/arm/include/asm/arch-mx27/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx27/imx-regs.h
@@ -106,9 +106,9 @@ struct esdramc_regs {
 
 /* Watchdog Registers*/
 struct wdog_regs {
-   u32 wcr;
-   u32 wsr;
-   u32 wstr;
+   u16 wcr;
+   u16 wsr;
+   u16 wstr;
 };
 
 /* PLL registers */
-- 
1.9.1

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