All of lore.kernel.org
 help / color / mirror / Atom feed
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv5 4/5] edac: altera: Add Altera L2 Cache and OCRAM EDAC Support
Date: Tue, 2 Dec 2014 15:25:07 +0000	[thread overview]
Message-ID: <20141202152507.GO23671@leverpostej> (raw)
In-Reply-To: <1415751263-1830-5-git-send-email-tthayer@opensource.altera.com>

Hi,

> +/* MPU L2 Register Defines */
> +#define ALTR_MPUL2_CONTROL_OFFSET       0x100
> +#define ALTR_MPUL2_CTL_CACHE_EN_MASK    BIT(0)

These are just standard PL310 register definitions, no?

[...]

> +static void *ocram_alloc_mem(size_t size, void **other)
> +{
> +       struct device_node *np;
> +       struct gen_pool *gp;
> +       void *sram_addr;
> +
> +       np = of_find_compatible_node(NULL, NULL, "altr,ocram-edac");
> +       if (!np)
> +               return NULL;

Don't you need to have a corresponding of_node_put?

Is this ever called before the code above has probed? Can't you keep
this information around rather than probing it every time?

> +
> +       gp = of_get_named_gen_pool(np, "iram", 0);
> +       if (!gp)
> +               return NULL;
> +
> +       sram_addr = (void *)gen_pool_alloc(gp, size);
> +       if (!sram_addr)
> +               return NULL;
> +
> +       memset(sram_addr, 0, size);

Is it safe to do a memset to the sram? How is it mapped?

[...]

> +static void *l2_alloc_mem(size_t size, void **other)
> +{
> +       struct device *dev = *other;
> +       void *ptemp = devm_kzalloc(dev, size, GFP_KERNEL);
> +
> +       if (!ptemp)
> +               return NULL;
> +
> +       /* Make sure everything is written out */
> +       wmb();
> +       flush_cache_all();

Doesn't this just flush out _to_ the L2 (and not beyond)? Even then I
don't think that's safe with the MMU enabled.

Why is the flush necessary?

[...]

> +static int altr_l2_dependencies(struct platform_device *pdev,
> +                               void __iomem *base)
> +{
> +       u32 control;
> +       struct regmap *l2_vbase;
> +
> +       control = readl(base) & ALTR_L2_ECC_EN_MASK;
> +       if (!control) {
> +               edac_printk(KERN_ERR, EDAC_DEVICE,
> +                           "L2: No ECC present, or ECC disabled\n");
> +               return -ENODEV;
> +       }
> +
> +       l2_vbase = syscon_regmap_lookup_by_compatible("arm,pl310-cache");
> +       if (IS_ERR(l2_vbase)) {
> +               edac_printk(KERN_ERR, EDAC_DEVICE,
> +                           "L2:regmap for arm,pl310-cache lookup failed.\n");
> +               return -ENODEV;
> +       }

I must NAK any use of the L2 as a syscon device. It's simply not a
register file that was intended to be shared. I appreciate that you only
want to check something very simple, but we should use a higher level
API for that (and we should add one if we do not already have one)

> +
> +       regmap_read(l2_vbase, ALTR_MPUL2_CONTROL_OFFSET, &control);
> +       if (!(control & ALTR_MPUL2_CTL_CACHE_EN_MASK)) {
> +               edac_printk(KERN_ERR, EDAC_DEVICE, "L2: Cache disabled\n");
> +               return -ENODEV;
> +       }
> +
> +       return 0;
> +}
> +
> +const struct edac_device_prv_data l2ecc_data = {
> +       .setup = altr_l2_dependencies,
> +       .ce_clear_mask = 0,
> +       .ue_clear_mask = 0,
> +#ifdef CONFIG_EDAC_DEBUG
> +       .eccmgr_sysfs_attr = altr_l2_sysfs_attributes,
> +       .alloc_mem = l2_alloc_mem,
> +       .free_mem = l2_free_mem,
> +       .ecc_enable_mask = ALTR_L2_ECC_EN_MASK,
> +       .ce_set_mask = (ALTR_L2_ECC_EN_MASK | ALTR_L2_ECC_INJS_MASK),
> +       .ue_set_mask = (ALTR_L2_ECC_EN_MASK | ALTR_L2_ECC_INJD_MASK),
> +       .trig_alloc_sz = ALTR_TRIG_L2C_BYTE_SIZE,
> +#endif
> +};
> +
> +#endif /* #ifdef CONFIG_EDAC_ALTERA_L2C */
> +
>  MODULE_LICENSE("GPL v2");
>  MODULE_AUTHOR("Thor Thayer");
> -MODULE_DESCRIPTION("EDAC Driver for Altera SDRAM Controller");
> +MODULE_DESCRIPTION("EDAC Driver for Altera Memories");
> --
> 1.7.9.5
> 
> 

WARNING: multiple messages have this Message-ID (diff)
From: Mark Rutland <mark.rutland@arm.com>
To: "tthayer@opensource.altera.com" <tthayer@opensource.altera.com>
Cc: "bp@alien8.de" <bp@alien8.de>,
	"dougthompson@xmission.com" <dougthompson@xmission.com>,
	"m.chehab@samsung.com" <m.chehab@samsung.com>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	Pawel Moll <Pawel.Moll@arm.com>,
	"ijc+devicetree@hellion.org.uk" <ijc+devicetree@hellion.org.uk>,
	"galak@codeaurora.org" <galak@codeaurora.org>,
	"linux@arm.linux.org.uk" <linux@arm.linux.org.uk>,
	"dinguyen@opensource.altera.com" <dinguyen@opensource.altera.com>,
	"grant.likely@linaro.org" <grant.likely@linaro.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"linux-edac@vger.kernel.org" <linux-edac@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"tthayer.linux@gmail.com" <tthayer.linux@gmail.com>
Subject: Re: [PATCHv5 4/5] edac: altera: Add Altera L2 Cache and OCRAM EDAC Support
Date: Tue, 2 Dec 2014 15:25:07 +0000	[thread overview]
Message-ID: <20141202152507.GO23671@leverpostej> (raw)
In-Reply-To: <1415751263-1830-5-git-send-email-tthayer@opensource.altera.com>

Hi,

> +/* MPU L2 Register Defines */
> +#define ALTR_MPUL2_CONTROL_OFFSET       0x100
> +#define ALTR_MPUL2_CTL_CACHE_EN_MASK    BIT(0)

These are just standard PL310 register definitions, no?

[...]

> +static void *ocram_alloc_mem(size_t size, void **other)
> +{
> +       struct device_node *np;
> +       struct gen_pool *gp;
> +       void *sram_addr;
> +
> +       np = of_find_compatible_node(NULL, NULL, "altr,ocram-edac");
> +       if (!np)
> +               return NULL;

Don't you need to have a corresponding of_node_put?

Is this ever called before the code above has probed? Can't you keep
this information around rather than probing it every time?

> +
> +       gp = of_get_named_gen_pool(np, "iram", 0);
> +       if (!gp)
> +               return NULL;
> +
> +       sram_addr = (void *)gen_pool_alloc(gp, size);
> +       if (!sram_addr)
> +               return NULL;
> +
> +       memset(sram_addr, 0, size);

Is it safe to do a memset to the sram? How is it mapped?

[...]

> +static void *l2_alloc_mem(size_t size, void **other)
> +{
> +       struct device *dev = *other;
> +       void *ptemp = devm_kzalloc(dev, size, GFP_KERNEL);
> +
> +       if (!ptemp)
> +               return NULL;
> +
> +       /* Make sure everything is written out */
> +       wmb();
> +       flush_cache_all();

Doesn't this just flush out _to_ the L2 (and not beyond)? Even then I
don't think that's safe with the MMU enabled.

Why is the flush necessary?

[...]

> +static int altr_l2_dependencies(struct platform_device *pdev,
> +                               void __iomem *base)
> +{
> +       u32 control;
> +       struct regmap *l2_vbase;
> +
> +       control = readl(base) & ALTR_L2_ECC_EN_MASK;
> +       if (!control) {
> +               edac_printk(KERN_ERR, EDAC_DEVICE,
> +                           "L2: No ECC present, or ECC disabled\n");
> +               return -ENODEV;
> +       }
> +
> +       l2_vbase = syscon_regmap_lookup_by_compatible("arm,pl310-cache");
> +       if (IS_ERR(l2_vbase)) {
> +               edac_printk(KERN_ERR, EDAC_DEVICE,
> +                           "L2:regmap for arm,pl310-cache lookup failed.\n");
> +               return -ENODEV;
> +       }

I must NAK any use of the L2 as a syscon device. It's simply not a
register file that was intended to be shared. I appreciate that you only
want to check something very simple, but we should use a higher level
API for that (and we should add one if we do not already have one)

> +
> +       regmap_read(l2_vbase, ALTR_MPUL2_CONTROL_OFFSET, &control);
> +       if (!(control & ALTR_MPUL2_CTL_CACHE_EN_MASK)) {
> +               edac_printk(KERN_ERR, EDAC_DEVICE, "L2: Cache disabled\n");
> +               return -ENODEV;
> +       }
> +
> +       return 0;
> +}
> +
> +const struct edac_device_prv_data l2ecc_data = {
> +       .setup = altr_l2_dependencies,
> +       .ce_clear_mask = 0,
> +       .ue_clear_mask = 0,
> +#ifdef CONFIG_EDAC_DEBUG
> +       .eccmgr_sysfs_attr = altr_l2_sysfs_attributes,
> +       .alloc_mem = l2_alloc_mem,
> +       .free_mem = l2_free_mem,
> +       .ecc_enable_mask = ALTR_L2_ECC_EN_MASK,
> +       .ce_set_mask = (ALTR_L2_ECC_EN_MASK | ALTR_L2_ECC_INJS_MASK),
> +       .ue_set_mask = (ALTR_L2_ECC_EN_MASK | ALTR_L2_ECC_INJD_MASK),
> +       .trig_alloc_sz = ALTR_TRIG_L2C_BYTE_SIZE,
> +#endif
> +};
> +
> +#endif /* #ifdef CONFIG_EDAC_ALTERA_L2C */
> +
>  MODULE_LICENSE("GPL v2");
>  MODULE_AUTHOR("Thor Thayer");
> -MODULE_DESCRIPTION("EDAC Driver for Altera SDRAM Controller");
> +MODULE_DESCRIPTION("EDAC Driver for Altera Memories");
> --
> 1.7.9.5
> 
> 

  reply	other threads:[~2014-12-02 15:25 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-12  0:14 [PATCHv5 0/5] Add Altera peripheral memories to EDAC framework tthayer at opensource.altera.com
2014-11-12  0:14 ` tthayer
2014-11-12  0:14 ` tthayer
2014-11-12  0:14 ` [PATCHv5 1/5] arm: socfpga: Enable L2 Cache ECC on startup tthayer at opensource.altera.com
2014-11-12  0:14   ` tthayer
2014-11-12  0:14   ` tthayer
2014-11-12  7:32   ` Dinh Nguyen
2014-11-12  7:32     ` Dinh Nguyen
2014-11-12  7:32     ` Dinh Nguyen
2014-11-12  0:14 ` [PATCHv5 2/5] arm: socfpga: Enable OCRAM " tthayer at opensource.altera.com
2014-11-12  0:14   ` tthayer
2014-11-12  0:14   ` tthayer
2014-11-12  7:33   ` Dinh Nguyen
2014-11-12  7:33     ` Dinh Nguyen
2014-11-12  7:33     ` Dinh Nguyen
2014-12-02 15:11   ` Mark Rutland
2014-12-02 15:11     ` Mark Rutland
2014-12-02 15:11     ` Mark Rutland
2014-12-02 17:54     ` Thor Thayer
2014-12-02 17:54       ` Thor Thayer
2014-12-02 17:54       ` Thor Thayer
2014-11-12  0:14 ` [PATCHv5 3/5] edac: altera: Remove SDRAM module compile tthayer at opensource.altera.com
2014-11-12  0:14   ` tthayer
2014-11-12  0:14   ` tthayer
2014-11-12  0:14 ` [PATCHv5 4/5] edac: altera: Add Altera L2 Cache and OCRAM EDAC Support tthayer at opensource.altera.com
2014-11-12  0:14   ` tthayer
2014-11-12  0:14   ` tthayer
2014-12-02 15:25   ` Mark Rutland [this message]
2014-12-02 15:25     ` Mark Rutland
2014-12-02 17:55     ` Thor Thayer
2014-12-02 17:55       ` Thor Thayer
2014-11-12  0:14 ` [PATCHv5 5/5] arm: dts: Add Altera L2 Cache and OCRAM EDAC tthayer at opensource.altera.com
2014-11-12  0:14   ` tthayer
2014-11-12  0:14   ` tthayer
2014-11-18 20:56   ` [RESEND PATCHv5 " Thor Thayer
2014-11-18 20:56     ` Thor Thayer
2014-11-18 20:56     ` Thor Thayer
2014-12-01 20:47     ` Thor Thayer
2014-12-01 20:47       ` Thor Thayer
2014-12-01 20:47       ` Thor Thayer
2014-12-02 15:01       ` Mark Rutland
2014-12-02 15:01         ` Mark Rutland
2014-12-02 17:51         ` Thor Thayer
2014-12-02 17:51           ` Thor Thayer
2014-12-02 14:57   ` [PATCHv5 " Mark Rutland
2014-12-02 14:57     ` Mark Rutland
2014-12-02 17:55     ` Thor Thayer
2014-12-02 17:55       ` Thor Thayer

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=20141202152507.GO23671@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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.