From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/4] test: self: mmu: use constants for the hardcoded buffer sizes
Date: Fri, 13 Oct 2023 11:19:05 +0200 [thread overview]
Message-ID: <20231013091905.GR3359458@pengutronix.de> (raw)
In-Reply-To: <20231009115257.2371076-1-a.fatoum@pengutronix.de>
On Mon, Oct 09, 2023 at 01:52:54PM +0200, Ahmad Fatoum wrote:
> The code hardcodes the SZ_8M and SZ_2M constants for size and alignment
> at a number of places. In preparation for making them smaller, factor
> them out as TEST_BUFFER_SIZE and TEST_BUFFER_ALIGN.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> test/self/mmu.c | 45 +++++++++++++++++++++++++--------------------
> 1 file changed, 25 insertions(+), 20 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/test/self/mmu.c b/test/self/mmu.c
> index 4ca10affddd2..850c9f336f89 100644
> --- a/test/self/mmu.c
> +++ b/test/self/mmu.c
> @@ -10,6 +10,9 @@
> #include <zero_page.h>
> #include <linux/sizes.h>
>
> +#define TEST_BUFFER_SIZE SZ_8M
> +#define TEST_BUFFER_ALIGN SZ_2M
> +
> BSELFTEST_GLOBALS();
>
> #define __expect(ret, cond, fmt, ...) do { \
> @@ -64,33 +67,33 @@ static void test_remap(void)
> phys_addr_t buffer_phys;
> int i, ret;
>
> - buffer = memalign(SZ_2M, SZ_8M);
> + buffer = memalign(TEST_BUFFER_ALIGN, TEST_BUFFER_SIZE);
> if (WARN_ON(!buffer))
> goto out;
>
> buffer_phys = virt_to_phys(buffer);
>
> - mirror = memalign(SZ_2M, SZ_8M);
> + mirror = memalign(TEST_BUFFER_ALIGN, TEST_BUFFER_SIZE);
> if (WARN_ON(!mirror))
> goto out;
>
> pr_debug("allocated buffer = 0x%p, mirror = 0x%p\n", buffer, mirror);
>
> - memtest(buffer, SZ_8M, "cached buffer");
> - memtest(mirror, SZ_8M, "cached mirror");
> + memtest(buffer, TEST_BUFFER_SIZE, "cached buffer");
> + memtest(mirror, TEST_BUFFER_SIZE, "cached mirror");
>
> if (!arch_can_remap()) {
> skipped_tests += 18;
> goto out;
> }
>
> - ret = remap_range(buffer, SZ_8M, MAP_UNCACHED);
> - memtest(buffer, SZ_8M, "uncached buffer");
> + ret = remap_range(buffer, TEST_BUFFER_SIZE, MAP_UNCACHED);
> + memtest(buffer, TEST_BUFFER_SIZE, "uncached buffer");
>
> - ret = remap_range(mirror, SZ_8M, MAP_UNCACHED);
> - memtest(mirror, SZ_8M, "uncached mirror");
> + ret = remap_range(mirror, TEST_BUFFER_SIZE, MAP_UNCACHED);
> + memtest(mirror, TEST_BUFFER_SIZE, "uncached mirror");
>
> - for (i = 0; i < SZ_8M; i += sizeof(u32)) {
> + for (i = 0; i < TEST_BUFFER_SIZE; i += sizeof(u32)) {
> int m = i, b = i;
> writel(0xDEADBEEF, &mirror[m]);
> writel(i, &buffer[b]);
> @@ -101,10 +104,10 @@ static void test_remap(void)
>
> expect_success(ret, "asserting no mirror before remap");
>
> - ret = arch_remap_range(mirror, buffer_phys, SZ_8M, MAP_UNCACHED);
> + ret = arch_remap_range(mirror, buffer_phys, TEST_BUFFER_SIZE, MAP_UNCACHED);
> expect_success(ret, "remapping with mirroring");
>
> - for (i = 0; i < SZ_8M; i += sizeof(u32)) {
> + for (i = 0; i < TEST_BUFFER_SIZE; i += sizeof(u32)) {
> int m = i, b = i;
> writel(0xDEADBEEF, &mirror[m]);
> writel(i, &buffer[b]);
> @@ -115,10 +118,11 @@ static void test_remap(void)
>
> expect_success(ret, "asserting mirroring after remap");
>
> - ret = arch_remap_range(mirror, buffer_phys + SZ_4K, SZ_4M, MAP_UNCACHED);
> + ret = arch_remap_range(mirror, buffer_phys + SZ_4K,
> + TEST_BUFFER_SIZE / 2, MAP_UNCACHED);
> expect_success(ret, "remapping with mirroring (phys += 4K)");
>
> - for (i = 0; i < SZ_4M; i += sizeof(u32)) {
> + for (i = 0; i < TEST_BUFFER_SIZE / 2; i += sizeof(u32)) {
> int m = i, b = i + SZ_4K;
> writel(0xDEADBEEF, &mirror[m]);
> writel(i, &buffer[b]);
> @@ -129,10 +133,11 @@ static void test_remap(void)
>
> expect_success(ret, "asserting mirroring after remap (phys += 4K)");
>
> - ret = arch_remap_range(mirror + SZ_4K, buffer_phys, SZ_4M, MAP_UNCACHED);
> + ret = arch_remap_range(mirror + SZ_4K, buffer_phys,
> + TEST_BUFFER_SIZE / 2, MAP_UNCACHED);
> expect_success(ret, "remapping with mirroring (virt += 4K)");
>
> - for (i = 0; i < SZ_4M; i += sizeof(u32)) {
> + for (i = 0; i < TEST_BUFFER_SIZE / 2; i += sizeof(u32)) {
> int m = i + SZ_4K, b = i;
> writel(0xDEADBEEF, &mirror[m]);
> writel(i, &buffer[b]);
> @@ -143,15 +148,15 @@ static void test_remap(void)
>
> expect_success(ret, "asserting mirroring after remap (virt += 4K)");
>
> - ret = remap_range(buffer, SZ_8M, MAP_DEFAULT);
> + ret = remap_range(buffer, TEST_BUFFER_SIZE, MAP_DEFAULT);
> expect_success(ret, "remapping buffer with default attrs");
> - memtest(buffer, SZ_8M, "newly cached buffer");
> + memtest(buffer, TEST_BUFFER_SIZE, "newly cached buffer");
>
> - ret = remap_range(mirror, SZ_8M, MAP_DEFAULT);
> + ret = remap_range(mirror, TEST_BUFFER_SIZE, MAP_DEFAULT);
> expect_success(ret, "remapping mirror with default attrs");
> - memtest(mirror, SZ_8M, "newly cached mirror");
> + memtest(mirror, TEST_BUFFER_SIZE, "newly cached mirror");
>
> - for (i = 0; i < SZ_8M; i += sizeof(u32)) {
> + for (i = 0; i < TEST_BUFFER_SIZE; i += sizeof(u32)) {
> int m = i, b = i;
> writel(0xDEADBEEF, &mirror[m]);
> writel(i, &buffer[b]);
> --
> 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-10-13 9:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-09 11:52 Ahmad Fatoum
2023-10-09 11:52 ` [PATCH 2/4] test: self: mmu: reduce MMU test region size Ahmad Fatoum
2023-10-09 11:52 ` [PATCH 3/4] test: self: have SELFTEST_ENABLE_ALL select all tests Ahmad Fatoum
2023-10-09 11:52 ` [PATCH 4/4] test: self: warn and exit if device tree parsing fails Ahmad Fatoum
2023-10-13 9:19 ` 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=20231013091905.GR3359458@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