From patchwork Tue Apr 16 17:10:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 1086431 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="R38S8itF"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="BdNq0pIm"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44kBhb37VCz9s9N for ; Wed, 17 Apr 2019 03:10:39 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=npAVol84dm6oRrcd9oi6OUnBMlGG/c/S3A2+lwm7X9A=; b=R38S8itFPD2ogT8RVj8aDNMw8Z 70gwPvktu8hScn6IeYxCzinsIOWhsL8arWXUw1rv70Io6ClpG6fdUenR+zB31tsXBW5AmdRPZ5RPA VI4OKWDqnBAvgxXYwdyvWLbbqgLGl4sBWTkdHz2cgmc8pGprLJGsW3Jyh7dXfCFtxjNe60x5OpUMw LcvQMkNfcCegXwAwa53vE2sRjMdnOc3lSod8fQCOJYwHXhcOzqbUgAwfcLffzwFIS6pHE6XLip6eO 1ytUq2YY+ppW4Av7SagEJJuh92YlXAs6gO42LraiRKiR1SAKfP3NQ8jstTDNm7nbdg0M1XB3zxigj shdMIljw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGRbR-0005F8-Fk; Tue, 16 Apr 2019 17:10:37 +0000 Received: from smtprelay.synopsys.com ([198.182.60.111]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGRbO-0005Cb-J9 for linux-snps-arc@lists.infradead.org; Tue, 16 Apr 2019 17:10:36 +0000 Received: from mailhost.synopsys.com (dc8-mailhost2.synopsys.com [10.13.135.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtprelay.synopsys.com (Postfix) with ESMTPS id 74F3D10C130D; Tue, 16 Apr 2019 10:10:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1555434634; bh=r/ZPkalgTfT4ORTmItFJrcwFrTVw4C497BKL2kqKcLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BdNq0pImhh0HZM5CiqH+b6smCHVZ3F/375HBiq1q2pXPPfKVpViOjGAUDIVyx8chG VWGhTKWDSakln8bIcjbyg6a1Ax3QJkcp0imX53PIzHVWaZb8bWm5lHm7jbWBonw8D+ 2N7pRtQxD2CV1fWwd+2hFWCTurRgf+lg3lJ5Bl2MeY9svCLHwayJ/SWDIa7K0f8LLe so1NrPF2qLUQeCnvUUzv5L+OUQT0Sl7YO9Dv798dK83iYDw0DQx6Yfd6jOQsthB5QM KZgfb5HWYDm9VPuq6DZs5ZZuKP6FAzzfDTr39NDBNwGhaNLhPG32+hcJVDODuPzLYD ijgyWua72isgg== Received: from paltsev-e7480.internal.synopsys.com (paltsev-e7480.internal.synopsys.com [10.121.8.106]) by mailhost.synopsys.com (Postfix) with ESMTP id 3C964A023C; Tue, 16 Apr 2019 17:10:33 +0000 (UTC) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org, Vineet Gupta Subject: [PATCH 2/3] ARC: cache: check cache configuration on each CPU Date: Tue, 16 Apr 2019 20:10:20 +0300 Message-Id: <20190416171021.20049-3-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20190416171021.20049-1-Eugeniy.Paltsev@synopsys.com> References: <20190416171021.20049-1-Eugeniy.Paltsev@synopsys.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190416_101034_642025_057E40E4 X-CRM114-Status: GOOD ( 14.46 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [198.182.60.111 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Brodkin , Eugeniy Paltsev , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org ARC kernel code assumes that all cores have same cache config but as of today we check cache configuration only on master CPU. Fix that and check cache configuration on each CPU. Also while I'm at it, split cache_init_master() for two parts: * checks/setups related to master L1 caches * the rest of cache checks/setups which need to be done once (like IOC / SLC / dma callbacks setup) Both of these changes are prerequisites for autodetecting cache line size in runtime. Signed-off-by: Eugeniy Paltsev --- arch/arc/mm/cache.c | 66 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c index 4135abec3fb0..1036bd56f518 100644 --- a/arch/arc/mm/cache.c +++ b/arch/arc/mm/cache.c @@ -1208,27 +1208,43 @@ noinline void __init arc_ioc_setup(void) __dc_enable(); } +#if IS_ENABLED(CONFIG_ARC_HAS_ICACHE) || IS_ENABLED(CONFIG_ARC_HAS_DCACHE) +static void arc_l1_line_check(unsigned int line_len, const char *cache_name) +{ + if (!line_len) + panic("%s support enabled but non-existent cache\n", + cache_name); + + if (line_len != L1_CACHE_BYTES) + panic("%s line size [%u] != expected [%u]", + cache_name, line_len, L1_CACHE_BYTES); +} +#endif /* IS_ENABLED(CONFIG_ARC_HAS_ICACHE) || IS_ENABLED(CONFIG_ARC_HAS_DCACHE) */ + /* - * Cache related boot time checks/setups only needed on master CPU: - * - Geometry checks (kernel build and hardware agree: e.g. L1_CACHE_BYTES) - * Assume SMP only, so all cores will have same cache config. A check on - * one core suffices for all - * - IOC setup / dma callbacks only need to be done once + * Cache related boot time checks needed on every CPU. */ -void __init arc_cache_init_master(void) +static void arc_l1_cache_check(unsigned int cpu) { - unsigned int __maybe_unused cpu = smp_processor_id(); + if (IS_ENABLED(CONFIG_ARC_HAS_ICACHE)) + arc_l1_line_check(cpuinfo_arc700[cpu].icache.line_len, "ICache"); + + if (IS_ENABLED(CONFIG_ARC_HAS_DCACHE)) + arc_l1_line_check(cpuinfo_arc700[cpu].dcache.line_len, "DCache"); +} +/* + * L1 Cache related boot time checks/setups needed on master CPU: + * This checks/setups are done in assumption that all CPU have same cache + * configuration (we validate this in arc_cache_check()): + * - Geometry checks + * - L1 cache line loop callbacks + */ +void __init arc_l1_cache_init_master(unsigned int cpu) +{ if (IS_ENABLED(CONFIG_ARC_HAS_ICACHE)) { struct cpuinfo_arc_cache *ic = &cpuinfo_arc700[cpu].icache; - if (!ic->line_len) - panic("cache support enabled but non-existent cache\n"); - - if (ic->line_len != L1_CACHE_BYTES) - panic("ICache line [%d] != kernel Config [%d]", - ic->line_len, L1_CACHE_BYTES); - /* * In MMU v4 (HS38x) the aliasing icache config uses IVIL/PTAG * pair to provide vaddr/paddr respectively, just as in MMU v3 @@ -1242,13 +1258,6 @@ void __init arc_cache_init_master(void) if (IS_ENABLED(CONFIG_ARC_HAS_DCACHE)) { struct cpuinfo_arc_cache *dc = &cpuinfo_arc700[cpu].dcache; - if (!dc->line_len) - panic("cache support enabled but non-existent cache\n"); - - if (dc->line_len != L1_CACHE_BYTES) - panic("DCache line [%d] != kernel Config [%d]", - dc->line_len, L1_CACHE_BYTES); - /* check for D-Cache aliasing on ARCompact: ARCv2 has PIPT */ if (is_isa_arcompact()) { int handled = IS_ENABLED(CONFIG_ARC_CACHE_VIPT_ALIASING); @@ -1271,6 +1280,14 @@ void __init arc_cache_init_master(void) */ BUILD_BUG_ON_MSG(L1_CACHE_BYTES > SMP_CACHE_BYTES, "SMP_CACHE_BYTES must be >= any cache line length"); +} + +/* + * Cache related boot time checks/setups needed on master CPU: + * - IOC setup / SLC setup / dma callbacks only need to be done once + */ +void __init arc_cache_init_master(void) +{ if (is_isa_arcv2() && (l2_line_sz > SMP_CACHE_BYTES)) panic("L2 Cache line [%d] > kernel Config [%d]\n", l2_line_sz, SMP_CACHE_BYTES); @@ -1301,11 +1318,16 @@ void __init arc_cache_init_master(void) void __ref arc_cache_init(void) { - unsigned int __maybe_unused cpu = smp_processor_id(); + unsigned int cpu = smp_processor_id(); char str[256]; pr_info("%s", arc_cache_mumbojumbo(0, str, sizeof(str))); + if (!cpu) + arc_l1_cache_init_master(cpu); + + arc_l1_cache_check(cpu); + if (!cpu) arc_cache_init_master();