* [PATCH 1/2] memtest: Adjust code for 64-bit architectures
@ 2018-09-18 5:03 Andrey Smirnov
2018-09-18 5:03 ` [PATCH 2/2] memtest: Make use of resource_size() Andrey Smirnov
2018-09-19 7:32 ` [PATCH 1/2] memtest: Adjust code for 64-bit architectures Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Andrey Smirnov @ 2018-09-18 5:03 UTC (permalink / raw)
To: barebox; +Cc: Andrey Smirnov
Make use of %pa specifier to avoid warnings when building against
64-bit CPU (specifically AArch64) as well as adjust a number of
patterns to be 64-bits wide.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
commands/memtest.c | 5 ++---
common/memtest.c | 35 ++++++++++++++++++++---------------
2 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/commands/memtest.c b/commands/memtest.c
index 99d4864e7..403ab91f6 100644
--- a/commands/memtest.c
+++ b/commands/memtest.c
@@ -33,9 +33,8 @@ static int do_test_one_area(struct mem_test_resource *r, int bus_only,
{
int ret;
- printf("Testing memory space: "
- "0x%08x -> 0x%08x:\n",
- r->r->start, r->r->end);
+ printf("Testing memory space: %pa -> %pa:\n",
+ &r->r->start, &r->r->end);
remap_range((void *)r->r->start, r->r->end -
r->r->start + 1, cache_flag);
diff --git a/common/memtest.c b/common/memtest.c
index 0fc204675..5c96d46e9 100644
--- a/common/memtest.c
+++ b/common/memtest.c
@@ -160,24 +160,29 @@ static void mem_test_report_failure(const char *failure_description,
resource_size_t actual_value,
volatile resource_size_t *address)
{
+ /*
+ * expected_value and actual_value below are not really
+ * pointers, but we want them to be printed exactly the same
+ * as pointers would, so we use %pa regardless
+ */
printf("FAILURE (%s): "
- "expected 0x%08x, actual 0x%08x at address 0x%08x.\n",
- failure_description, expected_value, actual_value,
- (resource_size_t)address);
+ "expected %pa, actual %pa at address %pa.\n",
+ failure_description, &expected_value, &actual_value,
+ &address);
}
int mem_test_bus_integrity(resource_size_t _start,
resource_size_t _end)
{
- static const resource_size_t bitpattern[] = {
- 0x00000001, /* single bit */
- 0x00000003, /* two adjacent bits */
- 0x00000007, /* three adjacent bits */
- 0x0000000F, /* four adjacent bits */
- 0x00000005, /* two non-adjacent bits */
- 0x00000015, /* three non-adjacent bits */
- 0x00000055, /* four non-adjacent bits */
- 0xAAAAAAAA, /* alternating 1/0 */
+ static const uint64_t bitpattern[] = {
+ 0x0000000000000001ULL, /* single bit */
+ 0x0000000000000003ULL, /* two adjacent bits */
+ 0x0000000000000007ULL, /* three adjacent bits */
+ 0x000000000000000FULL, /* four adjacent bits */
+ 0x0000000000000005ULL, /* two non-adjacent bits */
+ 0x0000000000000015ULL, /* three non-adjacent bits */
+ 0x0000000000000055ULL, /* four non-adjacent bits */
+ 0xAAAAAAAAAAAAAAAAULL, /* alternating 1/0 */
};
volatile resource_size_t *start, *dummy, num_words, val, readback, offset,
@@ -217,7 +222,7 @@ int mem_test_bus_integrity(resource_size_t _start,
* pattern and ~pattern).
*/
for (i = 0; i < ARRAY_SIZE(bitpattern); i++) {
- val = bitpattern[i];
+ val = (resource_size_t)bitpattern[i];
for (; val != 0; val <<= 1) {
*start = val;
@@ -282,8 +287,8 @@ int mem_test_bus_integrity(resource_size_t _start,
* 01ffffff is perfect.
*/
- pattern = 0xAAAAAAAA;
- anti_pattern = 0x55555555;
+ pattern = (resource_size_t)0xAAAAAAAAAAAAAAAAULL;
+ anti_pattern = (resource_size_t)0x5555555555555555ULL;
/*
* Write the default pattern at each of the
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] memtest: Make use of resource_size()
2018-09-18 5:03 [PATCH 1/2] memtest: Adjust code for 64-bit architectures Andrey Smirnov
@ 2018-09-18 5:03 ` Andrey Smirnov
2018-09-19 7:32 ` [PATCH 1/2] memtest: Adjust code for 64-bit architectures Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Andrey Smirnov @ 2018-09-18 5:03 UTC (permalink / raw)
To: barebox; +Cc: Andrey Smirnov
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
commands/memtest.c | 3 +--
common/memtest.c | 4 ++--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/commands/memtest.c b/commands/memtest.c
index 403ab91f6..dc8f7db27 100644
--- a/commands/memtest.c
+++ b/commands/memtest.c
@@ -36,8 +36,7 @@ static int do_test_one_area(struct mem_test_resource *r, int bus_only,
printf("Testing memory space: %pa -> %pa:\n",
&r->r->start, &r->r->end);
- remap_range((void *)r->r->start, r->r->end -
- r->r->start + 1, cache_flag);
+ remap_range((void *)r->r->start, resource_size(r->r), cache_flag);
ret = mem_test_bus_integrity(r->r->start, r->r->end);
if (ret < 0)
diff --git a/common/memtest.c b/common/memtest.c
index 5c96d46e9..44ddedd3d 100644
--- a/common/memtest.c
+++ b/common/memtest.c
@@ -131,8 +131,8 @@ void mem_test_release_regions(struct list_head *list)
/*
* Ensure to leave with a cached on non used sdram regions.
*/
- remap_range((void *)r->r->start, r->r->end -
- r->r->start + 1, MAP_DEFAULT);
+ remap_range((void *)r->r->start, resource_size(r->r),
+ MAP_DEFAULT);
release_sdram_region(r->r);
free(r);
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] memtest: Adjust code for 64-bit architectures
2018-09-18 5:03 [PATCH 1/2] memtest: Adjust code for 64-bit architectures Andrey Smirnov
2018-09-18 5:03 ` [PATCH 2/2] memtest: Make use of resource_size() Andrey Smirnov
@ 2018-09-19 7:32 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2018-09-19 7:32 UTC (permalink / raw)
To: Andrey Smirnov; +Cc: barebox
On Mon, Sep 17, 2018 at 10:03:42PM -0700, Andrey Smirnov wrote:
> Make use of %pa specifier to avoid warnings when building against
> 64-bit CPU (specifically AArch64) as well as adjust a number of
> patterns to be 64-bits wide.
>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
> commands/memtest.c | 5 ++---
> common/memtest.c | 35 ++++++++++++++++++++---------------
> 2 files changed, 22 insertions(+), 18 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/commands/memtest.c b/commands/memtest.c
> index 99d4864e7..403ab91f6 100644
> --- a/commands/memtest.c
> +++ b/commands/memtest.c
> @@ -33,9 +33,8 @@ static int do_test_one_area(struct mem_test_resource *r, int bus_only,
> {
> int ret;
>
> - printf("Testing memory space: "
> - "0x%08x -> 0x%08x:\n",
> - r->r->start, r->r->end);
> + printf("Testing memory space: %pa -> %pa:\n",
> + &r->r->start, &r->r->end);
>
> remap_range((void *)r->r->start, r->r->end -
> r->r->start + 1, cache_flag);
> diff --git a/common/memtest.c b/common/memtest.c
> index 0fc204675..5c96d46e9 100644
> --- a/common/memtest.c
> +++ b/common/memtest.c
> @@ -160,24 +160,29 @@ static void mem_test_report_failure(const char *failure_description,
> resource_size_t actual_value,
> volatile resource_size_t *address)
> {
> + /*
> + * expected_value and actual_value below are not really
> + * pointers, but we want them to be printed exactly the same
> + * as pointers would, so we use %pa regardless
> + */
> printf("FAILURE (%s): "
> - "expected 0x%08x, actual 0x%08x at address 0x%08x.\n",
> - failure_description, expected_value, actual_value,
> - (resource_size_t)address);
> + "expected %pa, actual %pa at address %pa.\n",
> + failure_description, &expected_value, &actual_value,
> + &address);
> }
>
> int mem_test_bus_integrity(resource_size_t _start,
> resource_size_t _end)
> {
> - static const resource_size_t bitpattern[] = {
> - 0x00000001, /* single bit */
> - 0x00000003, /* two adjacent bits */
> - 0x00000007, /* three adjacent bits */
> - 0x0000000F, /* four adjacent bits */
> - 0x00000005, /* two non-adjacent bits */
> - 0x00000015, /* three non-adjacent bits */
> - 0x00000055, /* four non-adjacent bits */
> - 0xAAAAAAAA, /* alternating 1/0 */
> + static const uint64_t bitpattern[] = {
> + 0x0000000000000001ULL, /* single bit */
> + 0x0000000000000003ULL, /* two adjacent bits */
> + 0x0000000000000007ULL, /* three adjacent bits */
> + 0x000000000000000FULL, /* four adjacent bits */
> + 0x0000000000000005ULL, /* two non-adjacent bits */
> + 0x0000000000000015ULL, /* three non-adjacent bits */
> + 0x0000000000000055ULL, /* four non-adjacent bits */
> + 0xAAAAAAAAAAAAAAAAULL, /* alternating 1/0 */
> };
>
> volatile resource_size_t *start, *dummy, num_words, val, readback, offset,
> @@ -217,7 +222,7 @@ int mem_test_bus_integrity(resource_size_t _start,
> * pattern and ~pattern).
> */
> for (i = 0; i < ARRAY_SIZE(bitpattern); i++) {
> - val = bitpattern[i];
> + val = (resource_size_t)bitpattern[i];
>
> for (; val != 0; val <<= 1) {
> *start = val;
> @@ -282,8 +287,8 @@ int mem_test_bus_integrity(resource_size_t _start,
> * 01ffffff is perfect.
> */
>
> - pattern = 0xAAAAAAAA;
> - anti_pattern = 0x55555555;
> + pattern = (resource_size_t)0xAAAAAAAAAAAAAAAAULL;
> + anti_pattern = (resource_size_t)0x5555555555555555ULL;
>
> /*
> * Write the default pattern at each of the
> --
> 2.17.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-09-19 7:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-18 5:03 [PATCH 1/2] memtest: Adjust code for 64-bit architectures Andrey Smirnov
2018-09-18 5:03 ` [PATCH 2/2] memtest: Make use of resource_size() Andrey Smirnov
2018-09-19 7:32 ` [PATCH 1/2] memtest: Adjust code for 64-bit architectures Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox