* [U-Boot] [PATCH] test: dm: regmap: Fix the long test delay
@ 2018-12-10 0:11 Simon Glass
2018-12-11 8:27 ` Neil Armstrong
2019-04-09 11:58 ` Faiz Abbas
0 siblings, 2 replies; 5+ messages in thread
From: Simon Glass @ 2018-12-10 0:11 UTC (permalink / raw)
To: u-boot
At present one of the regmap tests takes 5 seconds to run since it waits
for a timeout. This should be handled using sandbox_timer_add_offset()
which advances time for test purposes.
This requires a little change to make the regmap_read_poll_timeout()
testable.
Update the macro and the test.
Fixes: ebe3497c9c ("test: regmap: add regmap_read_poll_timeout test")
Signed-off-by: Simon Glass <sjg@chromium.org>
---
include/regmap.h | 14 +++++++++++++-
test/dm/regmap.c | 7 ++++---
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/include/regmap.h b/include/regmap.h
index a3afb72df51..8359c511d25 100644
--- a/include/regmap.h
+++ b/include/regmap.h
@@ -248,6 +248,8 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
* @cond: Break condition (usually involving @val)
* @sleep_us: Maximum time to sleep between reads in us (0 tight-loops).
* @timeout_ms: Timeout in ms, 0 means never timeout
+ * @test_add_time: Used for sandbox testing - amount of time to add after
+ * starting the loop (0 if not testing)
*
* Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
* error return value in case of a error read. In the two former cases,
@@ -256,8 +258,12 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
*
* This is modelled after the regmap_read_poll_timeout macros in linux but
* with millisecond timeout.
+ *
+ * The _test version is for sandbox testing only. Do not use this in normal
+ * code as it advances the timer.
*/
-#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_ms) \
+#define regmap_read_poll_timeout_test(map, addr, val, cond, sleep_us, \
+ timeout_ms, test_add_time) \
({ \
unsigned long __start = get_timer(0); \
int __ret; \
@@ -267,6 +273,8 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
break; \
if (cond) \
break; \
+ if (IS_ENABLED(CONFIG_SANDBOX) && test_add_time) \
+ sandbox_timer_add_offset(test_add_time); \
if ((timeout_ms) && get_timer(__start) > (timeout_ms)) { \
__ret = regmap_read((map), (addr), &(val)); \
break; \
@@ -277,6 +285,10 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
__ret ?: ((cond) ? 0 : -ETIMEDOUT); \
})
+#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_ms) \
+ regmap_read_poll_timeout_test(map, addr, val, cond, sleep_us, \
+ timeout_ms, 0) \
+
/**
* regmap_update_bits() - Perform a read/modify/write using a mask
*
diff --git a/test/dm/regmap.c b/test/dm/regmap.c
index 9a70c159ddb..82de295cb8f 100644
--- a/test/dm/regmap.c
+++ b/test/dm/regmap.c
@@ -160,9 +160,10 @@ static int dm_test_regmap_poll(struct unit_test_state *uts)
start = get_timer(0);
ut_asserteq(-ETIMEDOUT,
- regmap_read_poll_timeout(map, 0, reg,
- (reg == 0xcacafafa),
- 1, 5 * CONFIG_SYS_HZ));
+ regmap_read_poll_timeout_test(map, 0, reg,
+ (reg == 0xcacafafa),
+ 1, 5 * CONFIG_SYS_HZ,
+ 5 * CONFIG_SYS_HZ));
ut_assert(get_timer(start) > (5 * CONFIG_SYS_HZ));
--
2.20.0.rc2.403.gdbc3b29805-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] test: dm: regmap: Fix the long test delay
2018-12-10 0:11 [U-Boot] [PATCH] test: dm: regmap: Fix the long test delay Simon Glass
@ 2018-12-11 8:27 ` Neil Armstrong
2018-12-11 20:37 ` Simon Glass
2019-04-09 11:58 ` Faiz Abbas
1 sibling, 1 reply; 5+ messages in thread
From: Neil Armstrong @ 2018-12-11 8:27 UTC (permalink / raw)
To: u-boot
On 10/12/2018 01:11, Simon Glass wrote:
> At present one of the regmap tests takes 5 seconds to run since it waits
> for a timeout. This should be handled using sandbox_timer_add_offset()
> which advances time for test purposes.
>
> This requires a little change to make the regmap_read_poll_timeout()
> testable.
>
> Update the macro and the test.
>
> Fixes: ebe3497c9c ("test: regmap: add regmap_read_poll_timeout test")
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> include/regmap.h | 14 +++++++++++++-
> test/dm/regmap.c | 7 ++++---
> 2 files changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/include/regmap.h b/include/regmap.h
> index a3afb72df51..8359c511d25 100644
> --- a/include/regmap.h
> +++ b/include/regmap.h
> @@ -248,6 +248,8 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
> * @cond: Break condition (usually involving @val)
> * @sleep_us: Maximum time to sleep between reads in us (0 tight-loops).
> * @timeout_ms: Timeout in ms, 0 means never timeout
> + * @test_add_time: Used for sandbox testing - amount of time to add after
> + * starting the loop (0 if not testing)
> *
> * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
> * error return value in case of a error read. In the two former cases,
> @@ -256,8 +258,12 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
> *
> * This is modelled after the regmap_read_poll_timeout macros in linux but
> * with millisecond timeout.
> + *
> + * The _test version is for sandbox testing only. Do not use this in normal
> + * code as it advances the timer.
> */
> -#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_ms) \
> +#define regmap_read_poll_timeout_test(map, addr, val, cond, sleep_us, \
> + timeout_ms, test_add_time) \
Can't we use timeout_ms directly here when in SANDBOX mode ?
> ({ \
> unsigned long __start = get_timer(0); \
> int __ret; \
> @@ -267,6 +273,8 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
> break; \
> if (cond) \
> break; \
> + if (IS_ENABLED(CONFIG_SANDBOX) && test_add_time) \
> + sandbox_timer_add_offset(test_add_time); \
> if ((timeout_ms) && get_timer(__start) > (timeout_ms)) { \
> __ret = regmap_read((map), (addr), &(val)); \
> break; \
> @@ -277,6 +285,10 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
> __ret ?: ((cond) ? 0 : -ETIMEDOUT); \
> })
>
> +#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_ms) \
> + regmap_read_poll_timeout_test(map, addr, val, cond, sleep_us, \
> + timeout_ms, 0) \
> +
> /**
> * regmap_update_bits() - Perform a read/modify/write using a mask
> *
> diff --git a/test/dm/regmap.c b/test/dm/regmap.c
> index 9a70c159ddb..82de295cb8f 100644
> --- a/test/dm/regmap.c
> +++ b/test/dm/regmap.c
> @@ -160,9 +160,10 @@ static int dm_test_regmap_poll(struct unit_test_state *uts)
> start = get_timer(0);
>
> ut_asserteq(-ETIMEDOUT,
> - regmap_read_poll_timeout(map, 0, reg,
> - (reg == 0xcacafafa),
> - 1, 5 * CONFIG_SYS_HZ));
> + regmap_read_poll_timeout_test(map, 0, reg,
> + (reg == 0xcacafafa),
> + 1, 5 * CONFIG_SYS_HZ,
> + 5 * CONFIG_SYS_HZ));
>
> ut_assert(get_timer(start) > (5 * CONFIG_SYS_HZ));
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] test: dm: regmap: Fix the long test delay
2018-12-11 8:27 ` Neil Armstrong
@ 2018-12-11 20:37 ` Simon Glass
2018-12-28 20:47 ` sjg at google.com
0 siblings, 1 reply; 5+ messages in thread
From: Simon Glass @ 2018-12-11 20:37 UTC (permalink / raw)
To: u-boot
Hi Neil,
On Tue, 11 Dec 2018 at 01:27, Neil Armstrong <narmstrong@baylibre.com> wrote:
>
> On 10/12/2018 01:11, Simon Glass wrote:
> > At present one of the regmap tests takes 5 seconds to run since it waits
> > for a timeout. This should be handled using sandbox_timer_add_offset()
> > which advances time for test purposes.
> >
> > This requires a little change to make the regmap_read_poll_timeout()
> > testable.
> >
> > Update the macro and the test.
> >
> > Fixes: ebe3497c9c ("test: regmap: add regmap_read_poll_timeout test")
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> > include/regmap.h | 14 +++++++++++++-
> > test/dm/regmap.c | 7 ++++---
> > 2 files changed, 17 insertions(+), 4 deletions(-)
> >
> > diff --git a/include/regmap.h b/include/regmap.h
> > index a3afb72df51..8359c511d25 100644
> > --- a/include/regmap.h
> > +++ b/include/regmap.h
> > @@ -248,6 +248,8 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
> > * @cond: Break condition (usually involving @val)
> > * @sleep_us: Maximum time to sleep between reads in us (0 tight-loops).
> > * @timeout_ms: Timeout in ms, 0 means never timeout
> > + * @test_add_time: Used for sandbox testing - amount of time to add after
> > + * starting the loop (0 if not testing)
> > *
> > * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
> > * error return value in case of a error read. In the two former cases,
> > @@ -256,8 +258,12 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
> > *
> > * This is modelled after the regmap_read_poll_timeout macros in linux but
> > * with millisecond timeout.
> > + *
> > + * The _test version is for sandbox testing only. Do not use this in normal
> > + * code as it advances the timer.
> > */
> > -#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_ms) \
> > +#define regmap_read_poll_timeout_test(map, addr, val, cond, sleep_us, \
> > + timeout_ms, test_add_time) \
>
> Can't we use timeout_ms directly here when in SANDBOX mode ?
>
The problem is we don't know if we are in a test, or not. The argument
tells us that. Some sandbox code might actually use this macro as part
of normal non-test code.
Regards,
Simon
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] test: dm: regmap: Fix the long test delay
2018-12-11 20:37 ` Simon Glass
@ 2018-12-28 20:47 ` sjg at google.com
0 siblings, 0 replies; 5+ messages in thread
From: sjg at google.com @ 2018-12-28 20:47 UTC (permalink / raw)
To: u-boot
Hi Neil,
On Tue, 11 Dec 2018 at 01:27, Neil Armstrong <narmstrong@baylibre.com> wrote:
>
> On 10/12/2018 01:11, Simon Glass wrote:
> > At present one of the regmap tests takes 5 seconds to run since it waits
> > for a timeout. This should be handled using sandbox_timer_add_offset()
> > which advances time for test purposes.
> >
> > This requires a little change to make the regmap_read_poll_timeout()
> > testable.
> >
> > Update the macro and the test.
> >
> > Fixes: ebe3497c9c ("test: regmap: add regmap_read_poll_timeout test")
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> > include/regmap.h | 14 +++++++++++++-
> > test/dm/regmap.c | 7 ++++---
> > 2 files changed, 17 insertions(+), 4 deletions(-)
> >
Applied to u-boot-dm/master, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] test: dm: regmap: Fix the long test delay
2018-12-10 0:11 [U-Boot] [PATCH] test: dm: regmap: Fix the long test delay Simon Glass
2018-12-11 8:27 ` Neil Armstrong
@ 2019-04-09 11:58 ` Faiz Abbas
1 sibling, 0 replies; 5+ messages in thread
From: Faiz Abbas @ 2019-04-09 11:58 UTC (permalink / raw)
To: u-boot
Hi Simon,
On 10/12/18 5:41 AM, Simon Glass wrote:
> At present one of the regmap tests takes 5 seconds to run since it waits
> for a timeout. This should be handled using sandbox_timer_add_offset()
> which advances time for test purposes.
>
> This requires a little change to make the regmap_read_poll_timeout()
> testable.
>
> Update the macro and the test.
>
> Fixes: ebe3497c9c ("test: regmap: add regmap_read_poll_timeout test")
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> include/regmap.h | 14 +++++++++++++-
> test/dm/regmap.c | 7 ++++---
> 2 files changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/include/regmap.h b/include/regmap.h
> index a3afb72df51..8359c511d25 100644
> --- a/include/regmap.h
> +++ b/include/regmap.h
> @@ -248,6 +248,8 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
> * @cond: Break condition (usually involving @val)
> * @sleep_us: Maximum time to sleep between reads in us (0 tight-loops).
> * @timeout_ms: Timeout in ms, 0 means never timeout
> + * @test_add_time: Used for sandbox testing - amount of time to add after
> + * starting the loop (0 if not testing)
> *
> * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
> * error return value in case of a error read. In the two former cases,
> @@ -256,8 +258,12 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
> *
> * This is modelled after the regmap_read_poll_timeout macros in linux but
> * with millisecond timeout.
> + *
> + * The _test version is for sandbox testing only. Do not use this in normal
> + * code as it advances the timer.
> */
> -#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_ms) \
> +#define regmap_read_poll_timeout_test(map, addr, val, cond, sleep_us, \
> + timeout_ms, test_add_time) \
> ({ \
> unsigned long __start = get_timer(0); \
> int __ret; \
> @@ -267,6 +273,8 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
> break; \
> if (cond) \
> break; \
> + if (IS_ENABLED(CONFIG_SANDBOX) && test_add_time) \
> + sandbox_timer_add_offset(test_add_time); \
This causes a compilation warning here:
In file included from drivers/mmc/am654_sdhci.c:13:
drivers/mmc/am654_sdhci.c: In function ‘am654_sdhci_set_ios_post’:
include/regmap.h:277:4: warning: implicit declaration of function
‘sandbox_timer_add_offset’ [-Wimplicit-function-declaration]
sandbox_timer_add_offset(test_add_time); \
Thanks,
Faiz
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-04-09 11:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-10 0:11 [U-Boot] [PATCH] test: dm: regmap: Fix the long test delay Simon Glass
2018-12-11 8:27 ` Neil Armstrong
2018-12-11 20:37 ` Simon Glass
2018-12-28 20:47 ` sjg at google.com
2019-04-09 11:58 ` Faiz Abbas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox