Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Arnd Bergmann and committed by
Borislav Petkov
451bb7fb 2ce39109

+10 -48
+2 -1
Documentation/devicetree/bindings/edac/apm-xgene-edac.txt
··· 25 25 - memory-controller : Instance number of the memory controller. 26 26 27 27 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". 29 30 - reg : First resource shall be the PMD resource. 30 31 - pmd-controller : Instance number of the PMD controller. 31 32
+8 -47
drivers/edac/xgene_edac.c
··· 523 523 struct edac_device_ctl_info *edac_dev; 524 524 void __iomem *pmd_csr; 525 525 u32 pmd; 526 + int version; 526 527 }; 527 528 528 529 static void xgene_edac_pmd_l1_check(struct edac_device_ctl_info *edac_dev, ··· 785 784 writel(0x00000101, pg_f + MEMERR_CPU_MMUECR_PAGE_OFFSET); 786 785 } 787 786 788 - static bool xgene_edac_pmd_l2c_version1(void) 789 - { 790 - /* Check all chips with PMD L2C version 1 HW */ 791 - #define REVIDR_MINOR_REV(revidr) ((revidr) & 0x00000007) 792 - 793 - switch (MIDR_VARIANT(read_cpuid_id())) { 794 - case 0: 795 - switch (MIDR_REVISION(read_cpuid_id())) { 796 - case 0: 797 - 798 - switch (REVIDR_MINOR_REV(read_cpuid(REVIDR_EL1))) { 799 - case 1: 800 - case 2: 801 - return true; 802 - }; 803 - break; 804 - case 1: 805 - if (REVIDR_MINOR_REV(read_cpuid(REVIDR_EL1)) == 1) 806 - return true; 807 - break; 808 - } 809 - break; 810 - case 1: 811 - switch (MIDR_REVISION(read_cpuid_id())) { 812 - case 0: 813 - switch (REVIDR_MINOR_REV(read_cpuid(REVIDR_EL1))) { 814 - case 1: 815 - return true; 816 - }; 817 - break; 818 - case 1: 819 - switch (REVIDR_MINOR_REV(read_cpuid(REVIDR_EL1))) { 820 - case 1: 821 - case 0: 822 - return true; 823 - }; 824 - break; 825 - } 826 - break; 827 - } 828 - 829 - return false; 830 - } 831 - 832 787 static void xgene_edac_pmd_hw_cfg(struct edac_device_ctl_info *edac_dev) 833 788 { 834 789 struct xgene_edac_pmd_ctx *ctx = edac_dev->pvt_info; ··· 794 837 /* Enable PMD memory error - MEMERR_L2C_L2ECR and L2C_L2RTOCR */ 795 838 writel(0x00000703, pg_e + MEMERR_L2C_L2ECR_PAGE_OFFSET); 796 839 /* Configure L2C HW request time out feature if supported */ 797 - if (!xgene_edac_pmd_l2c_version1()) 840 + if (ctx->version > 1) 798 841 writel(0x00000119, pg_d + CPUX_L2C_L2RTOCR_PAGE_OFFSET); 799 842 } 800 843 ··· 913 956 return (efuse & (1 << pmd)) ? 0 : 1; 914 957 } 915 958 916 - static int xgene_edac_pmd_add(struct xgene_edac *edac, struct device_node *np) 959 + static int xgene_edac_pmd_add(struct xgene_edac *edac, struct device_node *np, 960 + int version) 917 961 { 918 962 struct edac_device_ctl_info *edac_dev; 919 963 struct xgene_edac_pmd_ctx *ctx; ··· 956 998 ctx->edac = edac; 957 999 ctx->edac_dev = edac_dev; 958 1000 ctx->ddev = *edac->dev; 1001 + ctx->version = version; 959 1002 edac_dev->dev = &ctx->ddev; 960 1003 edac_dev->ctl_name = ctx->name; 961 1004 edac_dev->dev_name = ctx->name; ··· 1128 1169 if (of_device_is_compatible(child, "apm,xgene-edac-mc")) 1129 1170 xgene_edac_mc_add(edac, child); 1130 1171 if (of_device_is_compatible(child, "apm,xgene-edac-pmd")) 1131 - xgene_edac_pmd_add(edac, child); 1172 + xgene_edac_pmd_add(edac, child, 1); 1173 + if (of_device_is_compatible(child, "apm,xgene-edac-pmd-v2")) 1174 + xgene_edac_pmd_add(edac, child, 2); 1132 1175 } 1133 1176 1134 1177 return 0;