linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Doug Thompson <dougthompson@xmission.com>
Cc: Harry Ciao <qingtao.cao@windriver.com>,
	Paul Mackerras <paulus@samba.org>,
	Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH V3 2/2] cpc925_edac: support single-processor configurations
Date: Wed, 29 Jun 2011 13:35:59 +1000	[thread overview]
Message-ID: <1309318559.32158.521.camel@pasglop> (raw)
In-Reply-To: <1308315107-29182-3-git-send-email-dbaryshkov@gmail.com>

On Fri, 2011-06-17 at 16:51 +0400, Dmitry Eremin-Solenikov wrote:
> If second CPU is not enabled, CPC925 EDAC driver will spill out warnings
> about errors on second Processor Interface. Support masking that out,
> by detecting at runtime which CPUs are present in device tree.

Doug ? Are you going to carry this or should I via powerpc.git ? There's
a dependency on another patch that's going into powerpc-next ...

Cheers,
Ben.

> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> Cc: Harry Ciao <qingtao.cao@windriver.com>
> Cc: Doug Thompson <dougthompson@xmission.com>
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
>  drivers/edac/cpc925_edac.c |   67 ++++++++++++++++++++++++++++++++++++++++++--
>  1 files changed, 64 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/edac/cpc925_edac.c b/drivers/edac/cpc925_edac.c
> index a687a0d..a774c0d 100644
> --- a/drivers/edac/cpc925_edac.c
> +++ b/drivers/edac/cpc925_edac.c
> @@ -90,6 +90,7 @@ enum apimask_bits {
>  	ECC_MASK_ENABLE = (APIMASK_ECC_UE_H | APIMASK_ECC_CE_H |
>  			   APIMASK_ECC_UE_L | APIMASK_ECC_CE_L),
>  };
> +#define APIMASK_ADI(n)		CPC925_BIT(((n)+1))
>  
>  /************************************************************
>   *	Processor Interface Exception Register (APIEXCP)
> @@ -581,16 +582,73 @@ static void cpc925_mc_check(struct mem_ctl_info *mci)
>  }
>  
>  /******************** CPU err device********************************/
> +static u32 cpc925_cpu_mask_disabled(void)
> +{
> +	struct device_node *cpus;
> +	struct device_node *cpunode = NULL;
> +	static u32 mask = 0;
> +
> +	/* use cached value if available */
> +	if (mask != 0)
> +		return mask;
> +
> +	mask = APIMASK_ADI0 | APIMASK_ADI1;
> +
> +	cpus = of_find_node_by_path("/cpus");
> +	if (cpus == NULL) {
> +		cpc925_printk(KERN_DEBUG, "No /cpus node !\n");
> +		return 0;
> +	}
> +
> +	while ((cpunode = of_get_next_child(cpus, cpunode)) != NULL) {
> +		const u32 *reg = of_get_property(cpunode, "reg", NULL);
> +
> +		if (strcmp(cpunode->type, "cpu")) {
> +			cpc925_printk(KERN_ERR, "Not a cpu node in /cpus: %s\n", cpunode->name);
> +			continue;
> +		}
> +
> +		if (reg == NULL || *reg > 2) {
> +			cpc925_printk(KERN_ERR, "Bad reg value at %s\n", cpunode->full_name);
> +			continue;
> +		}
> +
> +		mask &= ~APIMASK_ADI(*reg);
> +	}
> +
> +	if (mask != (APIMASK_ADI0 | APIMASK_ADI1)) {
> +		/* We assume that each CPU sits on it's own PI and that
> +		 * for present CPUs the reg property equals to the PI
> +		 * interface id */
> +		cpc925_printk(KERN_WARNING,
> +				"Assuming PI id is equal to CPU MPIC id!\n");
> +	}
> +
> +	of_node_put(cpunode);
> +	of_node_put(cpus);
> +
> +	return mask;
> +}
> +
>  /* Enable CPU Errors detection */
>  static void cpc925_cpu_init(struct cpc925_dev_info *dev_info)
>  {
>  	u32 apimask;
> +	u32 cpumask;
>  
>  	apimask = __raw_readl(dev_info->vbase + REG_APIMASK_OFFSET);
> -	if ((apimask & CPU_MASK_ENABLE) == 0) {
> -		apimask |= CPU_MASK_ENABLE;
> -		__raw_writel(apimask, dev_info->vbase + REG_APIMASK_OFFSET);
> +
> +	cpumask = cpc925_cpu_mask_disabled();
> +	if (apimask & cpumask) {
> +		cpc925_printk(KERN_WARNING, "CPU(s) not present, "
> +				"but enabled in APIMASK, disabling\n");
> +		apimask &= ~cpumask;
>  	}
> +
> +	if ((apimask & CPU_MASK_ENABLE) == 0)
> +		apimask |= CPU_MASK_ENABLE;
> +
> +	__raw_writel(apimask, dev_info->vbase + REG_APIMASK_OFFSET);
>  }
>  
>  /* Disable CPU Errors detection */
> @@ -622,6 +680,9 @@ static void cpc925_cpu_check(struct edac_device_ctl_info *edac_dev)
>  	if ((apiexcp & CPU_EXCP_DETECTED) == 0)
>  		return;
>  
> +	if ((apiexcp & ~cpc925_cpu_mask_disabled()) == 0)
> +		return;
> +
>  	apimask = __raw_readl(dev_info->vbase + REG_APIMASK_OFFSET);
>  	cpc925_printk(KERN_INFO, "Processor Interface Fault\n"
>  				 "Processor Interface register dump:\n");

  reply	other threads:[~2011-06-29  3:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-17 12:51 [PATCH V3 0/2] Improve CPC925 EDAC handling code on Maple Dmitry Eremin-Solenikov
2011-06-17 12:51 ` [PATCH V3 1/2] Maple: register CPC925 EDAC device on all boards with CPC925 Dmitry Eremin-Solenikov
2011-06-17 12:51 ` [PATCH V3 2/2] cpc925_edac: support single-processor configurations Dmitry Eremin-Solenikov
2011-06-29  3:35   ` Benjamin Herrenschmidt [this message]
2011-07-22 21:56     ` Dmitry Eremin-Solenikov
2011-07-22 22:06       ` Benjamin Herrenschmidt
2011-07-22 22:34         ` Dmitry Eremin-Solenikov
2011-06-27 14:07 ` [PATCH V3 0/2] Improve CPC925 EDAC handling code on Maple Dmitry Eremin-Solenikov

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=1309318559.32158.521.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=dbaryshkov@gmail.com \
    --cc=dougthompson@xmission.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    --cc=qingtao.cao@windriver.com \
    /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).