From patchwork Tue Jun 2 19:10:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 6530951 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6635E9F1C1 for ; Tue, 2 Jun 2015 19:14:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3CDA72051F for ; Tue, 2 Jun 2015 19:13:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 242FB2049D for ; Tue, 2 Jun 2015 19:13:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yzrb2-0003NR-Cz; Tue, 02 Jun 2015 19:11:32 +0000 Received: from mail.skyhub.de ([2a01:4f8:120:8448::d00d]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yzraw-0003CA-BF for linux-arm-kernel@lists.infradead.org; Tue, 02 Jun 2015 19:11:28 +0000 X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alien8.de; s=alien8; t=1433272259; bh=6n/vKBhS6BFXTGFLAdG4wdwoxWKxry9B2dzx3qPfNUg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To; b=SVXC8C6db4O0TkVzkr+6k4b21R3/WJMSQ+uZg3 0Qs23c+aF0PBlaRpi59lqmiYsjlesbg9kIkWqbeZa3CWZA7v9ASZ+hldBIegsQQNv7q rtFVZfgLXLr8UPRRn9oAGwx4VjrqHvUqcsPNGhuAj31AEKr+R/F/j1SjCS2yykoofg= Received: from mail.skyhub.de ([127.0.0.1]) by localhost (door.skyhub.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id NKl8p7r0BKRV; Tue, 2 Jun 2015 21:10:58 +0200 (CEST) Received: from pd.tnic (p5DDC6EDB.dip0.t-ipconnect.de [93.220.110.219]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id CC3B41DA236; Tue, 2 Jun 2015 21:10:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alien8.de; s=alien8; t=1433272258; bh=6n/vKBhS6BFXTGFLAdG4wdwoxWKxry9B2dzx3qPfNUg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To; b=iHL5JoEHo/o9yMFPg0lol8wJ/HpxQfAHHTzeiE fIISWutN3KYpoUYDmBzaR9MxnLdr+M9EiwqeM7ZYU14YoQsnTEyxLJ1o880icEIxABy fZlah8aELTHVyC+ondrZQjB/hVqv3hzey/zuaCmrL7AwVfwGSPcgPGjau8IyJGwrDc= Received: by pd.tnic (Postfix, from userid 1000) id 7BEBA16061A; Tue, 2 Jun 2015 21:10:51 +0200 (CEST) Date: Tue, 2 Jun 2015 21:10:51 +0200 From: Borislav Petkov To: Loc Ho Subject: Re: [PATCH] edac: xgene: fix cpuid abuse Message-ID: <20150602191051.GE19887@pd.tnic> References: <1433196575-9455-1-git-send-email-lho@apm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1433196575-9455-1-git-send-email-lho@apm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150602_121126_868760_4438AFA4 X-CRM114-Status: GOOD ( 21.12 ) X-Spam-Score: -0.1 (/) Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, arnd@arndb.de, ijc+devicetree@hellion.org.uk, jcm@redhat.com, mchehab@osg.samsung.com, patches@apm.com, robh+dt@kernel.org, dougthompson@xmission.com, linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Jun 01, 2015 at 04:09:35PM -0600, Loc Ho wrote: > 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. > > This version is based on Arnd original version. ... and I applied it and restored Arnd's authorship as this is his patch. I have added you to the Signed-off-by chain and documented the changes you did, as such handling should be documented properly in the history and the path of this patch upstream, see below. It passes all *config builds on x86 so I'd guess we're ok. Will appear in linux-next tomorrow, let's see what breaks now. :-) --- From: Arnd Bergmann Date: Mon, 1 Jun 2015 16:09:35 -0600 Subject: [PATCH] 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 [ Changed subnode to "apm,xgene-edac-pmd-v2", adjusted check. ] Signed-off-by: Loc Ho 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 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 --- .../devicetree/bindings/edac/apm-xgene-edac.txt | 3 +- drivers/edac/xgene_edac.c | 55 ++++------------------ 2 files changed, 10 insertions(+), 48 deletions(-) diff --git a/Documentation/devicetree/bindings/edac/apm-xgene-edac.txt b/Documentation/devicetree/bindings/edac/apm-xgene-edac.txt index 480911c38ff9..78edb80002c8 100644 --- a/Documentation/devicetree/bindings/edac/apm-xgene-edac.txt +++ b/Documentation/devicetree/bindings/edac/apm-xgene-edac.txt @@ -25,7 +25,8 @@ Required properties for memory controller subnode: - memory-controller : Instance number of the memory controller. Required properties for PMD subnode: -- compatible : Shall be "apm,xgene-edac-pmd". +- compatible : Shall be "apm,xgene-edac-pmd" or + "apm,xgene-edac-pmd-v2". - reg : First resource shall be the PMD resource. - pmd-controller : Instance number of the PMD controller. diff --git a/drivers/edac/xgene_edac.c b/drivers/edac/xgene_edac.c index b5158572f6ab..14636e4b6a08 100644 --- a/drivers/edac/xgene_edac.c +++ b/drivers/edac/xgene_edac.c @@ -523,6 +523,7 @@ struct xgene_edac_pmd_ctx { struct edac_device_ctl_info *edac_dev; void __iomem *pmd_csr; u32 pmd; + int version; }; 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, writel(0x00000101, pg_f + MEMERR_CPU_MMUECR_PAGE_OFFSET); } -static bool xgene_edac_pmd_l2c_version1(void) -{ - /* Check all chips with PMD L2C version 1 HW */ - #define REVIDR_MINOR_REV(revidr) ((revidr) & 0x00000007) - - switch (MIDR_VARIANT(read_cpuid_id())) { - case 0: - switch (MIDR_REVISION(read_cpuid_id())) { - case 0: - - switch (REVIDR_MINOR_REV(read_cpuid(REVIDR_EL1))) { - case 1: - case 2: - return true; - }; - break; - case 1: - if (REVIDR_MINOR_REV(read_cpuid(REVIDR_EL1)) == 1) - return true; - break; - } - break; - case 1: - switch (MIDR_REVISION(read_cpuid_id())) { - case 0: - switch (REVIDR_MINOR_REV(read_cpuid(REVIDR_EL1))) { - case 1: - return true; - }; - break; - case 1: - switch (REVIDR_MINOR_REV(read_cpuid(REVIDR_EL1))) { - case 1: - case 0: - return true; - }; - break; - } - break; - } - - return false; -} - static void xgene_edac_pmd_hw_cfg(struct edac_device_ctl_info *edac_dev) { 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) /* Enable PMD memory error - MEMERR_L2C_L2ECR and L2C_L2RTOCR */ writel(0x00000703, pg_e + MEMERR_L2C_L2ECR_PAGE_OFFSET); /* Configure L2C HW request time out feature if supported */ - if (!xgene_edac_pmd_l2c_version1()) + if (ctx->version > 1) writel(0x00000119, pg_d + CPUX_L2C_L2RTOCR_PAGE_OFFSET); } @@ -956,7 +913,8 @@ static int xgene_edac_pmd_available(u32 efuse, int pmd) return (efuse & (1 << pmd)) ? 0 : 1; } -static int xgene_edac_pmd_add(struct xgene_edac *edac, struct device_node *np) +static int xgene_edac_pmd_add(struct xgene_edac *edac, struct device_node *np, + int version) { struct edac_device_ctl_info *edac_dev; struct xgene_edac_pmd_ctx *ctx; @@ -998,6 +956,7 @@ static int xgene_edac_pmd_add(struct xgene_edac *edac, struct device_node *np) ctx->edac = edac; ctx->edac_dev = edac_dev; ctx->ddev = *edac->dev; + ctx->version = version; edac_dev->dev = &ctx->ddev; edac_dev->ctl_name = ctx->name; edac_dev->dev_name = ctx->name; @@ -1169,7 +1128,9 @@ static int xgene_edac_probe(struct platform_device *pdev) if (of_device_is_compatible(child, "apm,xgene-edac-mc")) xgene_edac_mc_add(edac, child); if (of_device_is_compatible(child, "apm,xgene-edac-pmd")) - xgene_edac_pmd_add(edac, child); + xgene_edac_pmd_add(edac, child, 1); + if (of_device_is_compatible(child, "apm,xgene-edac-pmd-v2")) + xgene_edac_pmd_add(edac, child, 2); } return 0;