All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: Penny Zheng <penny.zheng@arm.com>,
	xen-devel@lists.xenproject.org, sstabellini@kernel.org
Cc: Bertrand.Marquis@arm.com, Wei.Chen@arm.com, nd@arm.com
Subject: Re: [PATCH v5 1/7] xen/arm: introduce new helper device_tree_get_meminfo
Date: Wed, 1 Sep 2021 09:57:06 +0100	[thread overview]
Message-ID: <06395a17-24fb-35d5-8332-a6ca42dbc183@xen.org> (raw)
In-Reply-To: <20210824095045.2281500-2-penny.zheng@arm.com>

Hi Penny,

On 24/08/2021 10:50, Penny Zheng wrote:
> A few functions iterate over the device tree property to get memory info,
> like "reg" or the later "xen,static-mem", so this commit creates a new helper
> device_tree_get_meminfo to extract the common codes.

The commit message needs to be updated as the patch has been reshuffled.

> Signed-off-by: Penny Zheng <penny.zheng@arm.com>
> ---
>   xen/arch/arm/bootfdt.c | 68 ++++++++++++++++++++++++------------------
>   1 file changed, 39 insertions(+), 29 deletions(-)
> 
> diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
> index 476e32e0f5..8c81be3379 100644
> --- a/xen/arch/arm/bootfdt.c
> +++ b/xen/arch/arm/bootfdt.c
> @@ -63,6 +63,44 @@ void __init device_tree_get_reg(const __be32 **cell, u32 address_cells,
>       *size = dt_next_cell(size_cells, cell);
>   }
>   
> +static int __init device_tree_get_meminfo(const void *fdt, int node,
> +                                          const char *prop_name,
> +                                          u32 address_cells, u32 size_cells,
> +                                          void *data)
> +{
> +    const struct fdt_property *prop;
> +    unsigned int i, banks;
> +    const __be32 *cell;
> +    u32 reg_cells = address_cells + size_cells;
> +    paddr_t start, size;
> +    struct meminfo *mem = data;
> +
> +    prop = fdt_get_property(fdt, node, prop_name, NULL);
> +    if ( !prop )
> +        return -ENOENT;
> +
> +    cell = (const __be32 *)prop->data;
> +    banks = fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32));
> +
> +    for ( i = 0; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ )
> +    {
> +        device_tree_get_reg(&cell, address_cells, size_cells, &start, &size);
> +        /* Some DT may describe empty bank, ignore them */
> +        if ( !size )
> +            continue;
> +        mem->bank[mem->nr_banks].start = start;
> +        mem->bank[mem->nr_banks].size = size;
> +        mem->nr_banks++;
> +    }
> +
> +    if ( i < banks )
> +    {
> +        printk("Warning: Max number of supported memory regions reached.\n");
> +        return -ENOSPC;
> +    }
> +    return 0;
> +}
> +
>   u32 __init device_tree_get_u32(const void *fdt, int node,
>                                  const char *prop_name, u32 dflt)
>   {
> @@ -139,14 +177,6 @@ static int __init process_memory_node(const void *fdt, int node,
>                                         u32 address_cells, u32 size_cells,
>                                         void *data)
>   {
> -    const struct fdt_property *prop;
> -    int i;
> -    int banks;
> -    const __be32 *cell;
> -    paddr_t start, size;
> -    u32 reg_cells = address_cells + size_cells;
> -    struct meminfo *mem = data;
> -
>       if ( address_cells < 1 || size_cells < 1 )

This check will be the same for "xen,static-mem". So can it be moved to 
device_tree_get_meminfo()?

>       {
>           printk("fdt: node `%s': invalid #address-cells or #size-cells",
> @@ -154,27 +184,7 @@ static int __init process_memory_node(const void *fdt, int node,
>           return -EINVAL;
>       }
>   
> -    prop = fdt_get_property(fdt, node, "reg", NULL);
> -    if ( !prop )
> -        return -ENOENT;
> -
> -    cell = (const __be32 *)prop->data;
> -    banks = fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32));
> -
> -    for ( i = 0; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ )
> -    {
> -        device_tree_get_reg(&cell, address_cells, size_cells, &start, &size);
> -        /* Some DT may describe empty bank, ignore them */
> -        if ( !size )
> -            continue;
> -        mem->bank[mem->nr_banks].start = start;
> -        mem->bank[mem->nr_banks].size = size;
> -        mem->nr_banks++;
> -    }
> -
> -    if ( i < banks )
> -        return -ENOSPC;
> -    return 0;
> +    return device_tree_get_meminfo(fdt, node, "reg", address_cells, size_cells, data);
>   }
>   
>   static int __init process_reserved_memory_node(const void *fdt, int node,
> 

Cheers,

-- 
Julien Grall


  reply	other threads:[~2021-09-01  8:57 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24  9:50 [PATCH v5 0/7] Domain on Static Allocation Penny Zheng
2021-08-24  9:50 ` [PATCH v5 1/7] xen/arm: introduce new helper device_tree_get_meminfo Penny Zheng
2021-09-01  8:57   ` Julien Grall [this message]
2021-09-07  3:05     ` Penny Zheng
2021-08-24  9:50 ` [PATCH v5 2/7] xen/arm: introduce domain on Static Allocation Penny Zheng
2021-09-02 21:30   ` Stefano Stabellini
2021-09-07  3:18     ` Penny Zheng
2021-08-24  9:50 ` [PATCH v5 3/7] xen: introduce mark_page_free Penny Zheng
2021-08-24  9:50 ` [PATCH v5 4/7] xen/arm: static memory initialization Penny Zheng
2021-08-24 11:59   ` Jan Beulich
2021-09-02 21:23   ` Stefano Stabellini
2021-08-24  9:50 ` [PATCH v5 5/7] xen: re-define assign_pages and introduce assign_page Penny Zheng
2021-08-24 10:54   ` Jan Beulich
2021-08-24  9:50 ` [PATCH v5 6/7] xen/arm: introduce acquire_staticmem_pages and acquire_domstatic_pages Penny Zheng
2021-08-24 11:03   ` Jan Beulich
2021-08-24  9:50 ` [PATCH v5 7/7] xen/arm: introduce allocate_static_memory Penny Zheng
2021-09-02 21:32   ` Stefano Stabellini
2021-09-02 21:52     ` Stefano Stabellini
2021-09-02 22:07     ` Julien Grall
2021-09-03  0:39       ` Stefano Stabellini
2021-09-03  7:41         ` Julien Grall
2021-09-07  3:13           ` Penny Zheng
2021-09-02 21:33 ` [PATCH v5 0/7] Domain on Static Allocation Stefano Stabellini

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=06395a17-24fb-35d5-8332-a6ca42dbc183@xen.org \
    --to=julien@xen.org \
    --cc=Bertrand.Marquis@arm.com \
    --cc=Wei.Chen@arm.com \
    --cc=nd@arm.com \
    --cc=penny.zheng@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.