mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: uol@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2 02/10] common: allow requesting SDRAM regions with custom flags
Date: Wed, 17 Aug 2022 13:42:36 +0200	[thread overview]
Message-ID: <20220817114244.1810531-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220817114244.1810531-1-a.fatoum@pengutronix.de>

Now that __request_region accepts a flag parameter, define
__request_sdram_region, which also accepts a flag parameter and passes
it through. The default flags for request_sdram_region() will be
IORESOURCE_MEM as that ensures resource_contains behaves correctly when
comparing against another memory resource.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/memory.c  |  8 +++++---
 include/memory.h | 13 +++++++++++--
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/common/memory.c b/common/memory.c
index 03fec1f1eb0e..347f83fd4cf8 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -200,16 +200,18 @@ mmu_initcall(add_mem_devices);
 /*
  * Request a region from the registered sdram
  */
-struct resource *request_sdram_region(const char *name, resource_size_t start,
-		resource_size_t size)
+struct resource *__request_sdram_region(const char *name, unsigned flags,
+					resource_size_t start, resource_size_t size)
 {
 	struct memory_bank *bank;
 
+	flags |= IORESOURCE_MEM;
+
 	for_each_memory_bank(bank) {
 		struct resource *res;
 
 		res = __request_region(bank->res, start, start + size - 1,
-				       name, 0);
+				       name, flags);
 		if (!IS_ERR(res))
 			return res;
 	}
diff --git a/include/memory.h b/include/memory.h
index c793bb51ed77..31da5d74d568 100644
--- a/include/memory.h
+++ b/include/memory.h
@@ -23,8 +23,17 @@ int barebox_add_memory_bank(const char *name, resource_size_t start,
 
 #define for_each_memory_bank(mem)	list_for_each_entry(mem, &memory_banks, list)
 
-struct resource *request_sdram_region(const char *name, resource_size_t start,
-		resource_size_t size);
+struct resource *__request_sdram_region(const char *name, unsigned flags,
+					resource_size_t start, resource_size_t size);
+
+static inline struct resource *request_sdram_region(const char *name,
+						    resource_size_t start,
+						    resource_size_t size)
+{
+	/* IORESOURCE_MEM is implicit for all SDRAM regions */
+	return __request_sdram_region(name, 0, start, size);
+}
+
 int release_sdram_region(struct resource *res);
 
 void memory_bank_find_space(struct memory_bank *bank, resource_size_t *retstart,
-- 
2.30.2




  parent reply	other threads:[~2022-08-17 11:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17 11:42 [PATCH v2 00/10] ARM: mmu: inhibit speculation into secure memory Ahmad Fatoum
2022-08-17 11:42 ` [PATCH v2 01/10] resource: add flags parameter to __request_region Ahmad Fatoum
2022-08-17 11:42 ` Ahmad Fatoum [this message]
2022-08-17 11:42 ` [PATCH v2 03/10] memory: define reserve_sdram_region helper Ahmad Fatoum
2022-08-17 11:42 ` [PATCH v2 04/10] init: define new postmem_initcall() Ahmad Fatoum
2022-08-17 11:42 ` [PATCH v2 05/10] of: reserved-mem: reserve regions prior to mmu_initcall() Ahmad Fatoum
2022-08-17 11:42 ` [PATCH v2 06/10] ARM: mmu64: map reserved regions uncached Ahmad Fatoum
2022-08-17 11:42 ` [PATCH v2 07/10] ARM: mmu: define attrs_uncached_mem() helper Ahmad Fatoum
2022-08-17 11:42 ` [PATCH v2 08/10] ARM: mmu: use reserve mem entries to modify maps Ahmad Fatoum
2022-09-12 12:01   ` Sascha Hauer
2022-09-12 15:15     ` Ahmad Fatoum
2022-09-12 16:36       ` Sascha Hauer
2022-08-17 11:42 ` [PATCH v2 09/10] ARM: early-mmu: don't cache/prefetch OPTEE_SIZE bytes from end of memory Ahmad Fatoum
2022-08-17 11:42 ` [PATCH v2 10/10] commands: iomem: point out [R]eserved regions Ahmad Fatoum
2022-08-18 12:39 ` [PATCH v2 00/10] ARM: mmu: inhibit speculation into secure memory Sascha Hauer

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=20220817114244.1810531-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=uol@pengutronix.de \
    /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