linux-edac.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: Hanna Hawa <hhhawa@amazon.com>, Sudeep.Holla@arm.com
Cc: bp@alien8.de, mchehab@kernel.org, mark.rutland@arm.com,
	robh+dt@kernel.org, frowand.list@gmail.com, davem@davemloft.net,
	gregkh@linuxfoundation.org, linus.walleij@linaro.org,
	daniel@iogearbox.net, paulmck@linux.ibm.com,
	linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org,
	devicetree@vger.kernel.org, dwmw@amazon.co.uk, benh@amazon.com,
	ronenk@amazon.com, talel@amazon.com, jonnyc@amazon.com,
	hanochu@amazon.com
Subject: Re: [PATCH v7 1/3] edac: Add support for Amazon's Annapurna Labs L1 EDAC
Date: Wed, 15 Jan 2020 18:49:47 +0000	[thread overview]
Message-ID: <9ef0917d-b1d1-53c1-e459-309e509c2ff2@arm.com> (raw)
In-Reply-To: <20191015120927.10470-2-hhhawa@amazon.com>

Hi Hanna,

(This was still on my list. I've not seen a newer version, its not in next, and it still
applies, so:)

On 15/10/2019 13:09, Hanna Hawa wrote:
> Adds support for Amazon's Annapurna Labs L1 EDAC driver to detect and
> report L1 errors.

> diff --git a/drivers/edac/al_l1_edac.c b/drivers/edac/al_l1_edac.c
> new file mode 100644
> index 000000000000..e363a80b4d13
> --- /dev/null
> +++ b/drivers/edac/al_l1_edac.c
> @@ -0,0 +1,190 @@

> +#include <asm/sysreg.h>
> +#include <linux/bitfield.h>
> +#include <linux/of.h>
> +#include <linux/smp.h>

You need <linux/platform_device.h> for platform_device_register_simple().

[...]

> +static void al_l1_edac_cpumerrsr_read_status(void *arg)
> +{

> +	for (i = 0; i < repeat; i++) {
> +		if (fatal)
> +			edac_device_handle_ue(edac_dev, 0, 0, msg);
> +		else
> +			edac_device_handle_ce(edac_dev, 0, 0, msg);
> +	}

What serialises these? You kick this off from on_each_cpu(), what stops two CPUs calling
this at the same time? 'edac_dev->counters.ce_count += count;' will go wrong in this case.

I think you need a spinlock around the edac_device_* calls that take edac_dev so that only
one occurs at a time.


> +}
> +
> +static void al_l1_edac_check(struct edac_device_ctl_info *edac_dev)
> +{
> +	on_each_cpu(al_l1_edac_cpumerrsr_read_status, edac_dev, 1);
> +}
> +
> +static int al_l1_edac_probe(struct platform_device *pdev)
> +{
> +	struct edac_device_ctl_info *edac_dev;
> +	struct device *dev = &pdev->dev;
> +	int ret;
> +
> +	edac_dev = edac_device_alloc_ctl_info(0, DRV_NAME, 1, "L", 1, 1, NULL,
> +					      0, edac_device_alloc_index());
> +	if (!edac_dev)
> +		return -ENOMEM;
> +
> +	edac_dev->edac_check = al_l1_edac_check;
> +	edac_dev->dev = dev;
> +	edac_dev->mod_name = DRV_NAME;
> +	edac_dev->dev_name = dev_name(dev);
> +	edac_dev->ctl_name = "L1_cache";
> +	platform_set_drvdata(pdev, edac_dev);
> +
> +	ret = edac_device_add_device(edac_dev);
> +	if (ret)
> +		goto err;
> +
> +	return 0;
> +err:

(this goto has one user, meaning you can remove it by restructuring the code)


> +	dev_err(dev, "Failed to add L1 edac device (%d)\n", ret);
> +	edac_device_free_ctl_info(edac_dev);
> +
> +	return ret;
> +}
> +

> +static const struct of_device_id al_l1_edac_of_match[] = {
> +	{ .compatible = "al,alpine-v2" },
> +	{ .compatible = "amazon,alpine-v3" },
> +	{}
> +};

Unusually these are machine compatibles. It may be worth a comment that these are the
platforms which are known to have Cortex-A57/A72 configured with this support, and access
to the registers enabled by firmware.


> +MODULE_DEVICE_TABLE(of, al_l1_edac_of_match);

[..]

> +static int __init al_l1_init(void)
> +{
> +	struct device_node *root = of_find_node_by_path("/");
> +	int ret;

root could be NULL here.


> +	if (!of_match_node(al_l1_edac_of_match, root))
> +		return 0;
> +
> +	ret = platform_driver_register(&al_l1_edac_driver);
> +	if (ret) {
> +		pr_err("Failed to register %s (%d)\n", DRV_NAME, ret);
> +		return ret;
> +	}
> +
> +	edac_l1_device = platform_device_register_simple(DRV_NAME, -1, NULL, 0);
> +	if (IS_ERR(edac_l1_device)) {
> +		pr_err("Failed to register EDAC AL L1 platform device\n");
> +		return PTR_ERR(edac_l1_device);
> +	}
> +
> +	return 0;
> +}

With the edac_device_handle_ce() race fixed:
Reviewed-by: James Morse <james.morse@arm.com>


Thanks,

James

  reply	other threads:[~2020-01-15 18:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15 12:09 [PATCH v7 0/3] Add support for Amazon's Annapurna Labs EDAC for L1/L2 Hanna Hawa
2019-10-15 12:09 ` [PATCH v7 1/3] edac: Add support for Amazon's Annapurna Labs L1 EDAC Hanna Hawa
2020-01-15 18:49   ` James Morse [this message]
2020-01-20 14:41     ` Hawa, Hanna
2019-10-15 12:09 ` [PATCH v7 2/3] of: EXPORT_SYMBOL_GPL of_find_next_cache_node Hanna Hawa
2019-10-17 14:09   ` Rob Herring
2019-10-15 12:09 ` [PATCH v7 3/3] edac: Add support for Amazon's Annapurna Labs L2 EDAC Hanna Hawa
2020-01-15 18:50   ` James Morse
2020-01-20 14:52     ` Hawa, Hanna

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=9ef0917d-b1d1-53c1-e459-309e509c2ff2@arm.com \
    --to=james.morse@arm.com \
    --cc=Sudeep.Holla@arm.com \
    --cc=benh@amazon.com \
    --cc=bp@alien8.de \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=dwmw@amazon.co.uk \
    --cc=frowand.list@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hanochu@amazon.com \
    --cc=hhhawa@amazon.com \
    --cc=jonnyc@amazon.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mchehab@kernel.org \
    --cc=paulmck@linux.ibm.com \
    --cc=robh+dt@kernel.org \
    --cc=ronenk@amazon.com \
    --cc=talel@amazon.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).