Skip to contentSkip to conversation

Amazon's Annapurna Labs Memory Controller EDAC

PATCH Superseded Talel Shenhar 2 participants 7 messages Jul 28, 2020 – Aug 16, 2020

Subsystems (3)

v9 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Talel Shenhar

author maintainer
#0 lore raw

v9 cover Amazon's Annapurna Labs Memory Controller EDAC

This series introduces support for Amazon's Annapurna Labs Memory Controller EDAC driver.

Changes since v8:
================
- added cells address and size description to dt-binding yaml doc

Changes since v7:
=================
- rebased and retested for tag Linux 5.8-rc1

Changes since v6:
=================
- removed unused defines
- user-visible strings changed to capital
- removed static function names prefix from internal functions (external used function, such as devm/interrupts-handlers/probe, left with the prefix to allow stack trace visibility)
- sorted function local variables declaration in a reverse Christmas tree order
- fixed use of wrong syndrome defines
- added a comment to interrupts handling (polling mode with interrupt mode)
- added grain definition
- appended "or BSD-2-Clause" to dt binding SPDX

Changes since v5:
=================
- rebased and retested for tag Linux 5.6-rc2
- added Reviewed-By for dt-binding (Rob Herring <[email protected]>)
- added Reviewed-By for driver (James Morse <[email protected]>)

Changes since v4:
=================
- fixed dt-binding interrupt to have min of 1
- updated dt-binding GPL-2.0 to GPL-2.0-only
- changed writel to relaxed flavor
- added managed device driver unwind

Changes since v3:
=================
- removed quotation marks and hyphen from compatible dt-binding
- added interrupts and interrupt-names description to dt-binding
- added missing include to dt-binding

Changes since v2:
=================
- added missing includes
- aggregated variables to same line
- removed ranks read
- added spinlock to mc reporting
- made irq handler clearer
- freed irq before freeing device memory
- changed Kconfig to tristate
- added COMPILE_TEST to Kconfig
- converted dt binding to new scheme
- used devm_platform_ioremap_resource instead of get&ioremap

Changes since v1:
=================
- updated dt binding node name and added Rob Reviewed-By
- removed auto selecting of this driver

Talel Shenhar (2):
dt-bindings: edac: al-mc-edac: Amazon's Annapurna Labs Memory
Controller EDAC
EDAC: al-mc-edac: Introduce Amazon's Annapurna Labs Memory Controller
EDAC

 .../bindings/edac/amazon,al-mc-edac.yaml      |  67 ++++
 MAINTAINERS                                   |   7 +
 drivers/edac/Kconfig                          |   7 +
 drivers/edac/Makefile                         |   1 +
 drivers/edac/al_mc_edac.c                     | 354 ++++++++++++++++++
 5 files changed, 436 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/edac/amazon,al-mc-edac.yaml
 create mode 100644 drivers/edac/al_mc_edac.c
Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH v9 1/2 dt-bindings: edac: al-mc-edac: Amazon's Annapurna Labs Memory Controller EDAC

Document Amazon's Annapurna Labs Memory Controller EDAC SoC binding.

---
 .../bindings/edac/amazon,al-mc-edac.yaml      | 67 +++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/edac/amazon,al-mc-edac.yaml
Documentation/devicetree/bindings/edac/amazon,al-mc-edac.yaml new file +67 -0
new file mode 100644
index 000000000000..a25387df0865
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/edac/amazon,al-mc-edac.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amazon's Annapurna Labs Memory Controller EDAC
+
+maintainers:
+  - Talel Shenhar <[email protected]>
+  - Talel Shenhar <[email protected]>
+
+description: |
+  EDAC node is defined to describe on-chip error detection and correction for
+  Amazon's Annapurna Labs Memory Controller.
+
+properties:
+
+  compatible:
+    const: amazon,al-mc-edac
+
+  reg:
+    maxItems: 1
+
+  "#address-cells":
+    const: 2
+
+  "#size-cells":
+    const: 2
+
+  interrupts:
+    minItems: 1
+    maxItems: 2
+    items:
+      - description: uncorrectable error interrupt
+      - description: correctable error interrupt
+
+  interrupt-names:
+    minItems: 1
+    maxItems: 2
+    items:
+      - const: ue
+      - const: ce
+
+required:
+  - compatible
+  - reg
+  - "#address-cells"
+  - "#size-cells"
+
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+        edac@f0080000 {
+          #address-cells = <2>;
+          #size-cells = <2>;
+          compatible = "amazon,al-mc-edac";
+          reg = <0x0 0xf0080000 0x0 0x00010000>;
+          interrupt-parent = <&amazon_al_system_fabric>;
+          interrupt-names = "ue";
+          interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
+        };
+    };
Signature · 1 line
2.17.1
author maintainer
#2 lore raw

PATCH v9 2/2 EDAC: al-mc-edac: Introduce Amazon's Annapurna Labs Memory Controller EDAC

In reply to Talel Shenhar

The Amazon's Annapurna Labs Memory Controller EDAC supports ECC capability for error detection and correction (Single bit error correction, Double detection). This driver introduces EDAC driver for that capability.

---
 MAINTAINERS               |   7 +
 drivers/edac/Kconfig      |   7 +
 drivers/edac/Makefile     |   1 +
 drivers/edac/al_mc_edac.c | 354 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 369 insertions(+)
 create mode 100644 drivers/edac/al_mc_edac.c
MAINTAINERS +7 -0
index 68f21d46614c..0e6532c37bef 100644
@@ -802,6 +802,13 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/interrupt-controller/amazon,al-fic.txt
 F:	drivers/irqchip/irq-al-fic.c
 
+AMAZON ANNAPURNA LABS MEMORY CONTROLLER EDAC
+M:	Talel Shenhar <[email protected]>
+M:	Talel Shenhar <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/edac/amazon,al-mc-edac.yaml
+F:	drivers/edac/al_mc_edac.c
+
 AMAZON ANNAPURNA LABS THERMAL MMIO DRIVER
 M:	Talel Shenhar <[email protected]>
 S:	Maintained
drivers/edac/Kconfig +7 -0
index 7b6ec3014ba2..e3002718b1f5 100644
@@ -100,6 +100,13 @@ config EDAC_AMD64_ERROR_INJECTION
 	  In addition, there are two control files, inject_read and inject_write,
 	  which trigger the DRAM ECC Read and Write respectively.
 
+config EDAC_AL_MC
+	tristate "Amazon's Annapurna Lab EDAC Memory Controller"
+	depends on (ARCH_ALPINE || COMPILE_TEST)
+	help
+	  Support for error detection and correction for Amazon's Annapurna
+	  Labs Alpine chips which allows 1 bit correction and 2 bits detection.
+
 config EDAC_AMD76X
 	tristate "AMD 76x (760, 762, 768)"
 	depends on PCI && X86_32
drivers/edac/Makefile +1 -0
index 269e15118cea..3a849168780d 100644
@@ -22,6 +22,7 @@ obj-$(CONFIG_EDAC_GHES)			+= ghes_edac.o
 edac_mce_amd-y				:= mce_amd.o
 obj-$(CONFIG_EDAC_DECODE_MCE)		+= edac_mce_amd.o
 
+obj-$(CONFIG_EDAC_AL_MC)		+= al_mc_edac.o
 obj-$(CONFIG_EDAC_AMD76X)		+= amd76x_edac.o
 obj-$(CONFIG_EDAC_CPC925)		+= cpc925_edac.o
 obj-$(CONFIG_EDAC_I5000)		+= i5000_edac.o
drivers/edac/al_mc_edac.c new file +354 -0

354 lines not on this page · raw message

Signature · 1 line
2.17.1
maintainer
#3 lore raw

Re: [PATCH v9 2/2] EDAC: al-mc-edac: Introduce Amazon's Annapurna Labs Memory Controller EDAC

Quoted 42 lines · Talel Shenhar
drivers/edac/al_mc_edac.c new file +42 -0
+static void al_mc_edac_check(struct mem_ctl_info *mci)
+{
+	struct al_mc_edac *al_mc = mci->pvt_info;
+
+	if (al_mc->irq_ue <= 0)
+		handle_ue(mci);
+
+	if (al_mc->irq_ce <= 0)
+		handle_ce(mci);
+}
+
+static irqreturn_t al_mc_edac_irq_handler_ue(int irq, void *info)
+{
+	struct platform_device *pdev = info;
+	struct mem_ctl_info *mci = platform_get_drvdata(pdev);
+
+	if (handle_ue(mci))
+		return IRQ_HANDLED;
+	return IRQ_NONE;
+}
+
+static irqreturn_t al_mc_edac_irq_handler_ce(int irq, void *info)
+{
+	struct platform_device *pdev = info;
+	struct mem_ctl_info *mci = platform_get_drvdata(pdev);
+
+	if (handle_ce(mci))
+		return IRQ_HANDLED;
+	return IRQ_NONE;
+}
+
+static enum scrub_type al_mc_edac_get_scrub_mode(void __iomem *mmio_base)
+{
+	u32 ecccfg0;
+
+	ecccfg0 = readl(mmio_base + AL_MC_ECC_CFG);
+
+	if (FIELD_GET(AL_MC_ECC_CFG_SCRUB_DISABLED, ecccfg0))
+		return SCRUB_NONE;
+	else
+		return SCRUB_HW_SRC;
+}

drivers/edac/al_mc_edac.c line 215

Quoted 10 lines
drivers/edac/al_mc_edac.c new file +10 -0
+
+static void devm_al_mc_edac_free(void *data)
+{
+	edac_mc_free(data);
+}
+
+static void devm_al_mc_edac_del(void *data)
+{
+	edac_mc_del_mc(data);
+}

From a previous review:

Quoted 3 lines · I said:

Drop the "al_mc_edac_" prefix from most of the static functions. You can leave it in the probe function or the IRQ handler so that it is visible in stack traces but all those small functions don't need that prefix.

You replied with:

Quoted 1 line

Shall be part of v7.

and yet it ain't part of any v<num>.

Why?

Signature · 9 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author maintainer
#4 lore raw

Re: [PATCH v9 2/2] EDAC: al-mc-edac: Introduce Amazon's Annapurna Labs Memory Controller EDAC

Quoted 60 lines · Borislav Petkov
Quoted 42 lines · Talel Shenhar
drivers/edac/al_mc_edac.c new file +42 -0
+static void al_mc_edac_check(struct mem_ctl_info *mci)
+{
+     struct al_mc_edac *al_mc = mci->pvt_info;
+
+     if (al_mc->irq_ue <= 0)
+             handle_ue(mci);
+
+     if (al_mc->irq_ce <= 0)
+             handle_ce(mci);
+}
+
+static irqreturn_t al_mc_edac_irq_handler_ue(int irq, void *info)
+{
+     struct platform_device *pdev = info;
+     struct mem_ctl_info *mci = platform_get_drvdata(pdev);
+
+     if (handle_ue(mci))
+             return IRQ_HANDLED;
+     return IRQ_NONE;
+}
+
+static irqreturn_t al_mc_edac_irq_handler_ce(int irq, void *info)
+{
+     struct platform_device *pdev = info;
+     struct mem_ctl_info *mci = platform_get_drvdata(pdev);
+
+     if (handle_ce(mci))
+             return IRQ_HANDLED;
+     return IRQ_NONE;
+}
+
+static enum scrub_type al_mc_edac_get_scrub_mode(void __iomem *mmio_base)
+{
+     u32 ecccfg0;
+
+     ecccfg0 = readl(mmio_base + AL_MC_ECC_CFG);
+
+     if (FIELD_GET(AL_MC_ECC_CFG_SCRUB_DISABLED, ecccfg0))
+             return SCRUB_NONE;
+     else
+             return SCRUB_HW_SRC;
+}

drivers/edac/al_mc_edac.c line 215

Quoted 10 lines
drivers/edac/al_mc_edac.c new file +10 -0
+
+static void devm_al_mc_edac_free(void *data)
+{
+     edac_mc_free(data);
+}
+
+static void devm_al_mc_edac_del(void *data)
+{
+     edac_mc_del_mc(data);
+}

From a previous review:

Quoted 3 lines · I said:

Drop the "al_mc_edac_" prefix from most of the static functions. You can leave it in the probe function or the IRQ handler so that it is visible in stack traces but all those small functions don't need that prefix.

Quoted 6 lines

You replied with:

Quoted 1 line

Shall be part of v7.

and yet it ain't part of any v<num>.

Why?

Thanks for taking a look.

From cover letter:

- removed static function names prefix from internal functions (external used function, such as devm/interrupts-handlers/probe, left with the prefix to allow stack trace visibility)

As you can see, part of the functions got their prefix removed, e.g. prepare_msg, handle_ce, handle_ue.

I did take your advise for leaving prefix for having visibility for functions being used outside. hence, some were left with the prefix.

Let me know what you think.

Quoted 6 lines

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

maintainer
#5 lore raw

Re: [PATCH v9 2/2] EDAC: al-mc-edac: Introduce Amazon's Annapurna Labs Memory Controller EDAC

Quoted 1 line · Talel

Let me know what you think.

Well, devm_al_mc_edac_free() devm_al_mc_edac_del() look like useless wrappers to me and can be removed and you can use edac_mc_del_mc() and edac_mc_free() directly. But then you need to cast them in an ugly way so that it builds:

        ret = devm_add_action(&pdev->dev, (void (*)(void *data))edac_mc_free, mci);

I guess we can leave them as is and then lift them into the EDAC core if someone else wants to do the same devm_* thing.

al_mc_edac_get_scrub_mode() doesn't need a prefix because it is used only once and the compiler is simply inlining it so you can forget the stack trace visibility:

$ readelf -s drivers/edac/al_mc_edac.ko | grep scrub
$

The others are fine, I guess, since they're function pointers and cannot be inlined as such so you want them prefixed:

$ readelf -s drivers/edac/al_mc_edac.ko | grep al_mc_edac
    23: 00000000     0 FILE    LOCAL  DEFAULT  ABS al_mc_edac.c
    25: 00000000     4 FUNC    LOCAL  DEFAULT    1 devm_al_mc_edac_free
    27: 00000004     4 FUNC    LOCAL  DEFAULT    1 devm_al_mc_edac_del
    31: 00000124    24 FUNC    LOCAL  DEFAULT    1 al_mc_edac_irq_handler_ce
    35: 00000260    24 FUNC    LOCAL  DEFAULT    1 al_mc_edac_irq_handler_ue
    36: 00000278    56 FUNC    LOCAL  DEFAULT    1 al_mc_edac_check
    37: 000002b0   680 FUNC    LOCAL  DEFAULT    1 al_mc_edac_probe
    47: 00000000    20 FUNC    LOCAL  DEFAULT    3 al_mc_edac_driver_init
    51: 00000000    12 FUNC    LOCAL  DEFAULT    5 al_mc_edac_driver_exit
    53: 00000000   392 OBJECT  LOCAL  DEFAULT   16 al_mc_edac_of_match
    59: 00000000   104 OBJECT  LOCAL  DEFAULT   20 al_mc_edac_driver
    61: 00000000     0 FILE    LOCAL  DEFAULT  ABS al_mc_edac.mod.c
    88: 00000000   392 OBJECT  GLOBAL DEFAULT   16 __mod_of__al_mc_edac_of_m

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
author maintainer
#6 lore raw

Re: [PATCH v9 2/2] EDAC: al-mc-edac: Introduce Amazon's Annapurna Labs Memory Controller EDAC

Quoted 41 lines · Borislav Petkov

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.

Quoted 1 line · Talel

Let me know what you think.

Well, devm_al_mc_edac_free() devm_al_mc_edac_del() look like useless wrappers to me and can be removed and you can use edac_mc_del_mc() and edac_mc_free() directly. But then you need to cast them in an ugly way so that it builds:

         ret = devm_add_action(&pdev->dev, (void (*)(void *data))edac_mc_free, mci);

I guess we can leave them as is and then lift them into the EDAC core if someone else wants to do the same devm_* thing.

al_mc_edac_get_scrub_mode() doesn't need a prefix because it is used only once and the compiler is simply inlining it so you can forget the stack trace visibility:

$ readelf -s drivers/edac/al_mc_edac.ko | grep scrub
$

The others are fine, I guess, since they're function pointers and cannot be inlined as such so you want them prefixed:

$ readelf -s drivers/edac/al_mc_edac.ko | grep al_mc_edac
     23: 00000000     0 FILE    LOCAL  DEFAULT  ABS al_mc_edac.c
     25: 00000000     4 FUNC    LOCAL  DEFAULT    1 devm_al_mc_edac_free
     27: 00000004     4 FUNC    LOCAL  DEFAULT    1 devm_al_mc_edac_del
     31: 00000124    24 FUNC    LOCAL  DEFAULT    1 al_mc_edac_irq_handler_ce
     35: 00000260    24 FUNC    LOCAL  DEFAULT    1 al_mc_edac_irq_handler_ue
     36: 00000278    56 FUNC    LOCAL  DEFAULT    1 al_mc_edac_check
     37: 000002b0   680 FUNC    LOCAL  DEFAULT    1 al_mc_edac_probe
     47: 00000000    20 FUNC    LOCAL  DEFAULT    3 al_mc_edac_driver_init
     51: 00000000    12 FUNC    LOCAL  DEFAULT    5 al_mc_edac_driver_exit
     53: 00000000   392 OBJECT  LOCAL  DEFAULT   16 al_mc_edac_of_match
     59: 00000000   104 OBJECT  LOCAL  DEFAULT   20 al_mc_edac_driver
     61: 00000000     0 FILE    LOCAL  DEFAULT  ABS al_mc_edac.mod.c
     88: 00000000   392 OBJECT  GLOBAL DEFAULT   16 __mod_of__al_mc_edac_of_m
Quoted 1 line

Thx.

Thanks. shall be part of v10.

Quoted 6 lines

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel