Skip to content

Commit 451bb7f

Browse files
arndbsuryasaimadhu
authored andcommitted
EDAC, xgene: Fix cpuid abuse
The new x-gene EDAC driver incorrectly tried to figure out the version of one of its IP blocks by looking at the version of the CPU core, which is only vagely related. This removes the incorrect code and instead uses the version of the IP block in the compatible string where it belongs. Found using build testing on x86, which does not provide the arm64 cpuid interface. Signed-off-by: Arnd Bergmann <arnd@arndb.de> [ Changed subnode to "apm,xgene-edac-pmd-v2", adjusted check. ] Signed-off-by: Loc Ho <lho@apm.com> Cc: devicetree@vger.kernel.org Cc: dougthompson@xmission.com Cc: ijc+devicetree@hellion.org.uk Cc: jcm@redhat.com Cc: linux-arm-kernel@lists.infradead.org Cc: linux-edac <linux-edac@vger.kernel.org> Cc: mark.rutland@arm.com Cc: mchehab@osg.samsung.com Cc: patches@apm.com Cc: robh+dt@kernel.org Link: http://lkml.kernel.org/r/3195065.IK73o60xya@wuerfel Signed-off-by: Borislav Petkov <bp@suse.de>
1 parent 2ce3910 commit 451bb7f

2 files changed

Lines changed: 10 additions & 48 deletions

File tree

‎Documentation/devicetree/bindings/edac/apm-xgene-edac.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ Required properties for memory controller subnode:
2525
- memory-controller : Instance number of the memory controller.
2626

2727
Required properties for PMD subnode:
28-
- compatible : Shall be "apm,xgene-edac-pmd".
28+
- compatible : Shall be "apm,xgene-edac-pmd" or
29+
"apm,xgene-edac-pmd-v2".
2930
- reg : First resource shall be the PMD resource.
3031
- pmd-controller : Instance number of the PMD controller.
3132

‎drivers/edac/xgene_edac.c‎

Lines changed: 8 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ struct xgene_edac_pmd_ctx {
523523
struct edac_device_ctl_info *edac_dev;
524524
void __iomem *pmd_csr;
525525
u32 pmd;
526+
int version;
526527
};
527528

528529
static void xgene_edac_pmd_l1_check(struct edac_device_ctl_info *edac_dev,
@@ -784,50 +785,6 @@ static void xgene_edac_pmd_cpu_hw_cfg(struct edac_device_ctl_info *edac_dev,
784785
writel(0x00000101, pg_f + MEMERR_CPU_MMUECR_PAGE_OFFSET);
785786
}
786787

787-
static bool xgene_edac_pmd_l2c_version1(void)
788-
{
789-
/* Check all chips with PMD L2C version 1 HW */
790-
#define REVIDR_MINOR_REV(revidr) ((revidr) & 0x00000007)
791-
792-
switch (MIDR_VARIANT(read_cpuid_id())) {
793-
case 0:
794-
switch (MIDR_REVISION(read_cpuid_id())) {
795-
case 0:
796-
797-
switch (REVIDR_MINOR_REV(read_cpuid(REVIDR_EL1))) {
798-
case 1:
799-
case 2:
800-
return true;
801-
};
802-
break;
803-
case 1:
804-
if (REVIDR_MINOR_REV(read_cpuid(REVIDR_EL1)) == 1)
805-
return true;
806-
break;
807-
}
808-
break;
809-
case 1:
810-
switch (MIDR_REVISION(read_cpuid_id())) {
811-
case 0:
812-
switch (REVIDR_MINOR_REV(read_cpuid(REVIDR_EL1))) {
813-
case 1:
814-
return true;
815-
};
816-
break;
817-
case 1:
818-
switch (REVIDR_MINOR_REV(read_cpuid(REVIDR_EL1))) {
819-
case 1:
820-
case 0:
821-
return true;
822-
};
823-
break;
824-
}
825-
break;
826-
}
827-
828-
return false;
829-
}
830-
831788
static void xgene_edac_pmd_hw_cfg(struct edac_device_ctl_info *edac_dev)
832789
{
833790
struct xgene_edac_pmd_ctx *ctx = edac_dev->pvt_info;
@@ -837,7 +794,7 @@ static void xgene_edac_pmd_hw_cfg(struct edac_device_ctl_info *edac_dev)
837794
/* Enable PMD memory error - MEMERR_L2C_L2ECR and L2C_L2RTOCR */
838795
writel(0x00000703, pg_e + MEMERR_L2C_L2ECR_PAGE_OFFSET);
839796
/* Configure L2C HW request time out feature if supported */
840-
if (!xgene_edac_pmd_l2c_version1())
797+
if (ctx->version > 1)
841798
writel(0x00000119, pg_d + CPUX_L2C_L2RTOCR_PAGE_OFFSET);
842799
}
843800

@@ -956,7 +913,8 @@ static int xgene_edac_pmd_available(u32 efuse, int pmd)
956913
return (efuse & (1 << pmd)) ? 0 : 1;
957914
}
958915

959-
static int xgene_edac_pmd_add(struct xgene_edac *edac, struct device_node *np)
916+
static int xgene_edac_pmd_add(struct xgene_edac *edac, struct device_node *np,
917+
int version)
960918
{
961919
struct edac_device_ctl_info *edac_dev;
962920
struct xgene_edac_pmd_ctx *ctx;
@@ -998,6 +956,7 @@ static int xgene_edac_pmd_add(struct xgene_edac *edac, struct device_node *np)
998956
ctx->edac = edac;
999957
ctx->edac_dev = edac_dev;
1000958
ctx->ddev = *edac->dev;
959+
ctx->version = version;
1001960
edac_dev->dev = &ctx->ddev;
1002961
edac_dev->ctl_name = ctx->name;
1003962
edac_dev->dev_name = ctx->name;
@@ -1169,7 +1128,9 @@ static int xgene_edac_probe(struct platform_device *pdev)
11691128
if (of_device_is_compatible(child, "apm,xgene-edac-mc"))
11701129
xgene_edac_mc_add(edac, child);
11711130
if (of_device_is_compatible(child, "apm,xgene-edac-pmd"))
1172-
xgene_edac_pmd_add(edac, child);
1131+
xgene_edac_pmd_add(edac, child, 1);
1132+
if (of_device_is_compatible(child, "apm,xgene-edac-pmd-v2"))
1133+
xgene_edac_pmd_add(edac, child, 2);
11731134
}
11741135

11751136
return 0;

0 commit comments

Comments
 (0)