[PATCH 02/10] common: allow requesting SDRAM regions with custom flags
Ulrich Ölmann
u.oelmann at pengutronix.de
Tue Aug 16 00:35:41 PDT 2022
Hi Ahmad,
On Mon, Aug 15 2022 at 17:32 +0200, Ahmad Fatoum <a.fatoum at pengutronix.de> wrote:
> 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 at pengutronix.de>
> ---
> common/memory.c | 8 +++++---
> common/resource.c | 2 +-
> include/memory.h | 13 +++++++++++--
> 3 files changed, 17 insertions(+), 6 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/common/resource.c b/common/resource.c
> index 81f337668ef1..8678609229ab 100644
> --- a/common/resource.c
> +++ b/common/resource.c
> @@ -73,7 +73,7 @@ struct resource *__request_region(struct resource *parent,
> }
>
> ok:
> - debug("%s ok: 0x%08llx:0x%08llx flags=%u\n", __func__,
> + debug("%s ok: 0x%08llx:0x%08llx flags=0x%x\n", __func__,
this hunk should be squashed/amended into patch 01/10 where the flags
parameter has originally been introduced into this debug message.
Best regards
Ulrich
> (unsigned long long)start,
> (unsigned long long)end, flags);
>
> 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,
--
Pengutronix e.K. | Ulrich Ölmann |
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 |
More information about the barebox
mailing list