From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] test: self: mmu: skip false positive test fail when no RAM at address 0
Date: Fri, 10 Nov 2023 14:29:56 +0100 [thread overview]
Message-ID: <20231110132956.GI3359458@pengutronix.de> (raw)
In-Reply-To: <20231109152946.2299755-1-a.fatoum@pengutronix.de>
On Thu, Nov 09, 2023 at 04:29:46PM +0100, Ahmad Fatoum wrote:
> Testing zero_page_access only makes sense if we actually have RAM at
> address 0 that we may read from. If it happens to I/O memory, the SoC
> may hang or a data abort may be raised, which would make the test fail.
>
> Avoid this by explicitly checking for that case and skipping the test
> without running.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> test/self/mmu.c | 33 ++++++++++++++++++++++++++++++---
> 1 file changed, 30 insertions(+), 3 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/test/self/mmu.c b/test/self/mmu.c
> index ca58d718ffb3..58961daaab95 100644
> --- a/test/self/mmu.c
> +++ b/test/self/mmu.c
> @@ -9,6 +9,7 @@
> #include <abort.h>
> #include <zero_page.h>
> #include <linux/sizes.h>
> +#include <memory.h>
>
> #define TEST_BUFFER_SIZE SZ_1M
> #define TEST_BUFFER_ALIGN SZ_4K
> @@ -171,6 +172,34 @@ static void test_remap(void)
> free(mirror);
> }
>
> +static bool zero_page_access_ok(void)
> +{
> + struct memory_bank *bank;
> + const char *reason;
> + struct resource null_res = {
> + .name = "null",
> + .flags = IORESOURCE_MEM,
> + .start = 0,
> + .end = sizeof(int) - 1,
> + };
> +
> + if (!IS_ENABLED(CONFIG_ARCH_HAS_ZERO_PAGE)) {
> + reason = "CONFIG_ARCH_HAS_ZERO_PAGE=n";
> + goto not_ok;
> + }
> +
> + for_each_memory_bank(bank) {
> + if (resource_contains(bank->res, &null_res))
> + return true;
> + }
> +
> + reason = "no memory at address zero";
> +
> +not_ok:
> + pr_info("skipping rest of zero page tests because %s\n", reason);
> + return false;
> +}
> +
> static void test_zero_page(void)
> {
> void __iomem *null = NULL;
> @@ -197,9 +226,7 @@ static void test_zero_page(void)
> failed_tests++;
> }
>
> - if (!IS_ENABLED(CONFIG_ARCH_HAS_ZERO_PAGE)) {
> - pr_info("skipping %s because %s=n\n",
> - "CONFIG_ARCH_HAS_ZERO_PAGE", __func__);
> + if (!zero_page_access_ok()) {
> skipped_tests += 2;
> return;
> }
> --
> 2.39.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2023-11-10 13:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-09 15:29 Ahmad Fatoum
2023-11-10 13:29 ` Sascha Hauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231110132956.GI3359458@pengutronix.de \
--to=sha@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox