All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>,
	xen-devel@lists.xen.org
Cc: Stefano Stabellini <stefano.stabellini@citrix.com>,
	Tim Deegan <tim@xen.org>, Ian Campbell <ian.campbell@citrix.com>
Subject: Re: [RFC PATCH v3 07/12] arch/arm: create device tree nodes for hwdom cpufreq cpu driver
Date: Thu, 23 Oct 2014 16:49:25 +0100	[thread overview]
Message-ID: <54492385.5030602@linaro.org> (raw)
In-Reply-To: <1414076867-2148-8-git-send-email-oleksandr.dmytryshyn@globallogic.com>

Hi Oleksandr,

On 10/23/2014 04:07 PM, Oleksandr Dmytryshyn wrote:
> This patch copies all cpu@0..cpu@N nodes (from input
> device tree) with properties to /hypervisor/pcpus
> node (device tree for hwdom). Thus we can give all
> information about all physical CPUs in the pcpus node.
> Driver in hwdom should parse /hypervisor/pcpus path
> instead of the /cpus path in the device tree.
> 
> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
> ---
>  xen/arch/arm/domain_build.c | 67 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 67 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 2db0236..2186514 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -326,6 +326,69 @@ static int make_memory_node(const struct domain *d,
>      return res;
>  }
>  
> +#ifdef HAS_CPUFREQ
> +static int fdt_copy_phys_cpus_nodes(void *fdt)
> +{
> +    int res;
> +    const struct dt_device_node *cpus = dt_find_node_by_path("/cpus");
> +    const struct dt_device_node *npcpu;
> +    const struct dt_property *pp;
> +    char *node_name;
> +
> +    if ( !cpus )
> +    {
> +        dprintk(XENLOG_ERR, "Missing /cpus node in the device tree?\n");
> +        return -ENOENT;
> +    }
> +
> +    /*
> +     * create pcpus node and copy to it
> +     * original cpu@0..cpu@N nodes with its properties.
> +     * This is needed for the cpufreq cpu driver in Dom0
> +     */
> +    DPRINT("Create pcpus node\n");
> +
> +    res = fdt_begin_node(fdt, "pcpus");

This new bindings has to be documented somewhere. The best places would
be in Documentation/devicetree/bindins/arm/xen.txt (see Linux repo).

> +    if ( res )
> +        return res;
> +
> +    dt_for_each_child_node( cpus, npcpu )
> +    {
> +        if ( dt_device_type_is_equal(npcpu, "cpu") )
> +        {
> +            node_name = strrchr(dt_node_full_name(npcpu), '/');
> +            node_name++;
> +
> +            ASSERT(node_name && *node_name);

The first check on node_name is pointless because of the node_name++ above.

I would divide the ASSERT in 2 parts, and do the first check before
node_name++;

> +
> +            DPRINT("Copy %s node to the pcpus\n", node_name);
> +
> +            res = fdt_begin_node(fdt, node_name);
> +            if ( res )
> +                return res;
> +
> +            dt_for_each_property_node( npcpu, pp )
> +            {
> +                if ( pp->length )
> +                {
> +                    res = fdt_property(fdt, pp->name, pp->value,
> +                                        pp->length);
> +                    if ( res )
> +                        return res;
> +                }
> +            }
> +

You can use write_properties to replace this loop.

> +            res = fdt_end_node(fdt);
> +            if ( res )
> +                return res;
> +        }
> +    }
> +
> +    res = fdt_end_node(fdt);
> +    return res;
> +}
> +#endif /* HAS_CPUFREQ */
> +
>  static int make_hypervisor_node(struct domain *d,
>                                  void *fdt, const struct dt_device_node *parent)
>  {
> @@ -386,6 +449,10 @@ static int make_hypervisor_node(struct domain *d,
>      if ( res )
>          return res;
>  
> +    #ifdef HAS_CPUFREQ
> +    fdt_copy_phys_cpus_nodes(fdt);

You forgot to check the return value of the function.

Regards,

-- 
Julien Grall

  reply	other threads:[~2014-10-23 15:49 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-23 15:07 [RFC PATCH v3 00/12]xen_cpufreq implementation in Xen hypervisor Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 01/12] cpufreq: move cpufreq.h file to the xen/include/xen location Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 02/12] pm: move processor_perf.h " Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 03/12] pmstat: move pmstat.c file to the xen/drivers/pm/stat.c location Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 04/12] cpufreq: make turbo settings to be configurable Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 05/12] pmstat: make pmstat functions more generalizable Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 06/12] cpufreq: make cpufreq driver " Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 07/12] arch/arm: create device tree nodes for hwdom cpufreq cpu driver Oleksandr Dmytryshyn
2014-10-23 15:49   ` Julien Grall [this message]
2014-10-24 10:24     ` Oleksandr Dmytryshyn
2014-10-27 10:52       ` Oleksandr Dmytryshyn
2014-10-27 13:15         ` Julien Grall
2014-10-27 13:32           ` Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 08/12] xsm: enable xsm_platform_op hook for all architectures Oleksandr Dmytryshyn
2014-10-23 16:11   ` Julien Grall
2014-10-24 10:24     ` Oleksandr Dmytryshyn
2014-10-24 10:27       ` Oleksandr Dmytryshyn
2014-10-24 11:38         ` Julien Grall
2014-10-23 15:07 ` [RFC PATCH v3 09/12] xen: arm: implement platform hypercall Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 10/12] cpufreq: add hwdom-cpufreq driver Oleksandr Dmytryshyn
2014-10-23 16:42   ` Julien Grall
2014-10-24 10:30     ` Oleksandr Dmytryshyn
2014-10-24 11:45       ` Julien Grall
2014-10-24 13:05         ` Oleksandr Dmytryshyn
2014-10-24 13:08           ` Julien Grall
2014-10-27 13:29             ` Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 11/12] xen: arm: implement XEN_SYSCTL_cpufreq_op Oleksandr Dmytryshyn
2014-10-23 16:27   ` Julien Grall
2014-10-24 10:37     ` Oleksandr Dmytryshyn
2014-10-26 17:41   ` Stefano Stabellini
2014-10-27 16:27     ` Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 12/12] xen/arm: enable cpufreq functionality for ARM Oleksandr Dmytryshyn

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=54492385.5030602@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=ian.campbell@citrix.com \
    --cc=oleksandr.dmytryshyn@globallogic.com \
    --cc=stefano.stabellini@citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.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.