Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4761231rdb; Tue, 12 Dec 2023 08:36:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgmeHRCBAdxyXofL9C3YHswWcwbCB/BVIWMPOsEZRq9nQd2ztynSOKHc4uD30Yci2VZKsp X-Received: by 2002:a17:903:1c7:b0:1d0:6ffd:6109 with SMTP id e7-20020a17090301c700b001d06ffd6109mr7519066plh.43.1702398981971; Tue, 12 Dec 2023 08:36:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702398981; cv=none; d=google.com; s=arc-20160816; b=d1F/8tEC3q30qFYfaNwL1FCkuUKs7FVU5yJ7rjoYwei1JM709oxPNc6ChtelnnRaeO efUuw8+AoPIU4EE7Uv4MzfAiI2oYFzS56AS9Y4eSKK5RQ/ImQhp9aw2QjKWE8uL6kS79 TTrv3CMwaJOQSDgbO2Rx23288EO7Npxt77hbdDCLnAuCkfkeqKhaq6CPneW0YlNJft6w lPhs28cA6zkrdd0eI08+K/H+BdYZmSo/ymWmNwgTkyjgKzm2FXavaJFMbZumASzk9lcn uvoWnFKGPG6UusCImXFMMW8snpKLKou9M3R6Pi6P0NcxN3npELdwqKDfbrXNqFwR088a lUMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=csnOaxSt7JZQCahT2bN5IGKlGaknLCMr5TUNqVz3qJ8=; fh=jshYI2NwtEb4RFDet1CibhjijWOL1JdxV9n387woDuM=; b=maZsjZe5WIO79SwhdG1k5e0sxXw3zCORI+9KKpex7ytKC7rFzbPf3487I8WS6+e6Tu nH1AOrb8V/h4y30hTPXWfKTO+EaLJ2GgtAqXg1ce7x4xO0cqIihMGi47TOoEYVE1mUYy LYs289xi6T2wFgQ6k+rlsxclaDvK5SrL3L3xSTd3NcYK+zCgMYik7EyLG36x/v34ftzf ig4E2RtQdIBEjSRsZOc4ymzoLfar672RyEDr9a8PDaE6ZVQVdFJ7FlIl4qIwFqoOlbpY 8pOEj9ZKI0wqB6kc9/1IViwiLCIGKvHHHo6FXJ/4BkAhRpG/3rZ+I9y1Jh8QbBS+W7if B8+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=hIA5vBGh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id n2-20020a170902d2c200b001c3411c9b83si223764plc.454.2023.12.12.08.36.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 08:36:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=hIA5vBGh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 7265580A9145; Tue, 12 Dec 2023 08:36:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235081AbjLLQfx (ORCPT + 99 others); Tue, 12 Dec 2023 11:35:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232949AbjLLQf0 (ORCPT ); Tue, 12 Dec 2023 11:35:26 -0500 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 459A810E; Tue, 12 Dec 2023 08:35:31 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 1460E1BF20A; Tue, 12 Dec 2023 16:35:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702398930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=csnOaxSt7JZQCahT2bN5IGKlGaknLCMr5TUNqVz3qJ8=; b=hIA5vBGh5rMpBv0vKsUu7Rg7W7AO/jBlwSka/ljxzqaiEaB2ZkNbWXZAKSd5qB6VefULty LPCLV5sxclUHKu9XCVjae1NgsUuyK3AbUb5+z+svtLAHbND+JEILQC6UsVpXBB2qe89JFH ceDLGQUtQQh7Wg0QgeZu0u6EnoZzksEGwBAchn2SVLtg339fB1lCSfv4/4LZpCyReoF35w jgsgW7It+BOpuvuYSUGWLwwfzZXVOw8PiyLscZGbqmu1x0uM+W9KjGpDWS2XGPKSz3MEB7 HLIaXe6dSzxVuairq4z54zjYUbC6hqU6YsVv7ZVSl7Cmj9b/dUrsSSjdUqm2Tg== From: Gregory CLEMENT To: Paul Burton , Thomas Bogendoerfer , linux-mips@vger.kernel.org, Jiaxun Yang , Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vladimir Kondratiev , Tawfik Bayouk , Alexandre Belloni , =?UTF-8?q?Th=C3=A9o=20Lebrun?= , Thomas Petazzoni , Gregory CLEMENT Subject: [PATCH v5 07/22] MIPS: Fix cache issue with mips_cps_core_entry Date: Tue, 12 Dec 2023 17:34:39 +0100 Message-ID: <20231212163459.1923041-8-gregory.clement@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231212163459.1923041-1-gregory.clement@bootlin.com> References: <20231212163459.1923041-1-gregory.clement@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: gregory.clement@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 12 Dec 2023 08:36:19 -0800 (PST) Split setup_cps_vecs and move back the cache management latter in cps_smp_setup when the cache subsystem had been initialized. Without this the blast_inv_dcache_range() call can lead to a crash. Signed-off-by: Gregory CLEMENT --- arch/mips/kernel/smp-cps.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c index 9aad678a32bd7..6cbdff917d147 100644 --- a/arch/mips/kernel/smp-cps.c +++ b/arch/mips/kernel/smp-cps.c @@ -53,6 +53,7 @@ UASM_L_LA(_not_nmi) static DECLARE_BITMAP(core_power, NR_CPUS); static uint32_t core_entry_reg; +static phys_addr_t cps_vec_pa; struct core_boot_config *mips_cps_core_bootcfg; @@ -112,17 +113,8 @@ static void __init *mips_cps_build_core_entry(void *addr) return p; } -static int __init setup_cps_vecs(void) +static int __init allocate_cps_vecs(void) { - extern void excep_tlbfill(void); - extern void excep_xtlbfill(void); - extern void excep_cache(void); - extern void excep_genex(void); - extern void excep_intex(void); - extern void excep_ejtag(void); - phys_addr_t cps_vec_pa; - void *cps_vec; - /* Try to allocate in KSEG1 first */ cps_vec_pa = memblock_phys_alloc_range(BEV_VEC_SIZE, BEV_VEC_ALIGN, 0x0, KSEGX_SIZE - 1); @@ -142,6 +134,19 @@ static int __init setup_cps_vecs(void) if (!cps_vec_pa) return -ENOMEM; + return 0; +} + +static void __init setup_cps_vecs(void) +{ + extern void excep_tlbfill(void); + extern void excep_xtlbfill(void); + extern void excep_cache(void); + extern void excep_genex(void); + extern void excep_intex(void); + extern void excep_ejtag(void); + void *cps_vec; + /* We want to ensure cache is clean before writing uncached mem */ blast_dcache_range(TO_CAC(cps_vec_pa), TO_CAC(cps_vec_pa) + BEV_VEC_SIZE); bc_wback_inv(TO_CAC(cps_vec_pa), BEV_VEC_SIZE); @@ -161,8 +166,6 @@ static int __init setup_cps_vecs(void) blast_inv_dcache_range(TO_CAC(cps_vec_pa), TO_CAC(cps_vec_pa) + BEV_VEC_SIZE); bc_inv(TO_CAC(cps_vec_pa), BEV_VEC_SIZE); __sync(); - - return 0; } static void __init cps_smp_setup(void) @@ -224,8 +227,8 @@ static void __init cps_smp_setup(void) /* Make core 0 coherent with everything */ write_gcr_cl_coherence(0xff); - if (setup_cps_vecs()) - pr_err("Failed to setup CPS vectors\n"); + if (allocate_cps_vecs()) + pr_err("Failed to allocate CPS vectors\n"); if (core_entry_reg && mips_cm_revision() >= CM_REV_CM3) write_gcr_bev_base(core_entry_reg); @@ -280,6 +283,7 @@ static void __init cps_prepare_cpus(unsigned int max_cpus) (cca_unsuitable && cpu_has_dc_aliases) ? " & " : "", cpu_has_dc_aliases ? "dcache aliasing" : ""); + setup_cps_vecs(); /* Allocate core boot configuration structs */ ncores = mips_cps_numcores(0); -- 2.42.0