xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Cc: ian.campbell@citrix.com, Anup Patel <anup.patel@linaro.org>,
	patches@linaro.org, patches@apm.com, xen-devel@lists.xen.org,
	stefano.stabellini@citrix.com
Subject: Re: [PATCH V6] xen: arm: platforms: Adding reset support for xgene arm64 platform.
Date: Mon, 27 Jan 2014 13:36:15 +0000	[thread overview]
Message-ID: <52E660CF.4010606@linaro.org> (raw)
In-Reply-To: <1390822488-22183-1-git-send-email-pranavkumar@linaro.org>

On 01/27/2014 11:34 AM, Pranavkumar Sawargaonkar wrote:
> This patch adds a reset support for xgene arm64 platform.
> 
> V6:
> - Incorporating comments received on V5 patch.
> V5:
> - Incorporating comments received on V4 patch.
> V4:
> - Removing TODO comment about retriving reset base address from dts
>   as that is done now.
> V3:
> - Retriving reset base address and reset mask from device tree.
> - Removed unnecssary header files included earlier.
> V2:
> - Removed unnecssary mdelay in code.
> - Adding iounmap of the base address.
> V1:
> -Initial patch.
> 
> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
> Signed-off-by: Anup Patel <anup.patel@linaro.org>
> ---
>  xen/arch/arm/platforms/xgene-storm.c |   72 ++++++++++++++++++++++++++++++++++
>  1 file changed, 72 insertions(+)
> 
> diff --git a/xen/arch/arm/platforms/xgene-storm.c b/xen/arch/arm/platforms/xgene-storm.c
> index 5b0bd5f..4fc185b 100644
> --- a/xen/arch/arm/platforms/xgene-storm.c
> +++ b/xen/arch/arm/platforms/xgene-storm.c
> @@ -20,8 +20,16 @@
>  
>  #include <xen/config.h>
>  #include <asm/platform.h>
> +#include <xen/stdbool.h>
> +#include <xen/vmap.h>
> +#include <asm/io.h>
>  #include <asm/gic.h>
>  
> +/* Variables to save reset address of soc during platform initialization. */
> +static u64 reset_addr, reset_size;
> +static u32 reset_mask;
> +static bool reset_vals_valid = false;
> +
>  static uint32_t xgene_storm_quirks(void)
>  {
>      return PLATFORM_QUIRK_GIC_64K_STRIDE;
> @@ -107,6 +115,68 @@ err:
>      return ret;
>  }
>  
> +static void xgene_storm_reset(void)
> +{

I'm concerned about reset function in general, in common code we have
this code (arch/arm/shutdown.c machine_restart).

while (1)
{
   raw_machine_reset(); // which call platform_reset()
   mdelay(100);
}

If platform_reset failed, it's possible with this code, the console will
be spam with "XGENE: ...".

Do we really need to call raw_machine_reset multiple time?
Would it be more suitable to have this code:

raw_machine_reset();
mdelay(100);
printk("Failed to reset\n");
while (1);

Or even better, moving the mdelay  per platform...

> +    void __iomem *addr;
> +
> +    if ( !reset_vals_valid )
> +    {
> +        printk("XGENE: Invalid reset values, can not reset XGENE...\n");
> +        return;
> +    }
> +
> +    addr = ioremap_nocache(reset_addr, reset_size);
> +
> +    if ( !addr )
> +    {
> +        printk("XGENE: Unable to map xgene reset address, can not reset XGENE...\n");
> +        return;
> +    }
> +
> +    /* Write reset mask to base address */
> +    writel(reset_mask, addr);
> +
> +    iounmap(addr);
> +}
> +
> +static int xgene_storm_init(void)
> +{
> +    static const struct dt_device_match reset_ids[] __initconst =
> +    {
> +        DT_MATCH_COMPATIBLE("apm,xgene-reboot"),
> +        {},

Do you plan to have other ids in the future? If not, I would directly
use dt_find_compatible_node(NULL, NULL "arm,xgene-reboot"); instead of
dt_find_matching_node(...).

> +    };
> +    struct dt_device_node *dev;
> +    int res;
> +
> +    dev = dt_find_matching_node(NULL, reset_ids);
> +    if ( !dev )
> +    {
> +        printk("XGENE: Unable to find a compatible reset node in the device tree");
> +        return 0;
> +    }
> +
> +    dt_device_set_used_by(dev, DOMID_XEN);
> +
> +    /* Retrieve base address and size */
> +    res = dt_device_get_address(dev, 0, &reset_addr, &reset_size);
> +    if ( res )
> +    {
> +        printk("XGENE: Unable to retrieve the base address for reset\n");
> +        return 0;
> +    }
> +
> +    /* Get reset mask */
> +    res = dt_property_read_u32(dev, "mask", &reset_mask);
> +    if ( !res )
> +    {
> +        printk("XGENE: Unable to retrieve the reset mask\n");
> +        return 0;
> +    }
> +
> +    reset_vals_valid = true;
> +    return 0;
> +}
>  
>  static const char * const xgene_storm_dt_compat[] __initconst =
>  {
> @@ -116,6 +186,8 @@ static const char * const xgene_storm_dt_compat[] __initconst =
>  
>  PLATFORM_START(xgene_storm, "APM X-GENE STORM")
>      .compatible = xgene_storm_dt_compat,
> +    .init = xgene_storm_init,
> +    .reset = xgene_storm_reset,
>      .quirks = xgene_storm_quirks,
>      .specific_mapping = xgene_storm_specific_mapping,
>  
> 


-- 
Julien Grall

  parent reply	other threads:[~2014-01-27 13:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-27 11:34 [PATCH V6] xen: arm: platforms: Adding reset support for xgene arm64 platform Pranavkumar Sawargaonkar
2014-01-27 11:38 ` Ian Campbell
2014-01-27 12:01   ` George Dunlap
2014-01-27 12:04     ` Ian Campbell
2014-01-27 12:07       ` George Dunlap
2014-01-28 11:49         ` Ian Campbell
2014-01-27 13:36 ` Julien Grall [this message]
2014-01-27 14:13   ` Ian Campbell
2014-01-27 14:24     ` Julien Grall
2014-01-27 14:27       ` Ian Campbell
2014-01-27 14:36         ` Julien Grall
2014-01-27 14:39           ` Ian Campbell
2014-01-28 15:47 ` Ian Campbell
2014-01-28 17:35   ` Pranavkumar Sawargaonkar
2014-01-28 17:43     ` Ian Campbell
2014-01-28 17:57       ` Pranavkumar Sawargaonkar
2014-01-29 12:38         ` Ian Campbell
2014-01-30  6:08           ` Pranavkumar Sawargaonkar
2014-02-03 17:04             ` Ian Campbell
2014-02-03 17:25               ` Pranavkumar Sawargaonkar
2014-02-05 14:48               ` George Dunlap

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=52E660CF.4010606@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=anup.patel@linaro.org \
    --cc=ian.campbell@citrix.com \
    --cc=patches@apm.com \
    --cc=patches@linaro.org \
    --cc=pranavkumar@linaro.org \
    --cc=stefano.stabellini@citrix.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).