Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2442163rdb; Fri, 8 Dec 2023 08:13:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWi1PbnY5Gl+E1Q3vS1eYKpx9QOkgLAbh7yVsJqXwn4HRkkPyBwQDooK55KOMs/tZgTzYI X-Received: by 2002:a05:6358:8809:b0:170:17eb:14bd with SMTP id hv9-20020a056358880900b0017017eb14bdmr187580rwb.45.1702052012039; Fri, 08 Dec 2023 08:13:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702052012; cv=none; d=google.com; s=arc-20160816; b=zm09qED32ioza1V6ckWmByUvfcP1GCAsOfSkSwVOV+0awvO8p79Tz6GTN2qcxxoL98 fXS+rDDZzBANDMaTPvllltkISnscE68zXDG59KQvhXs4YVuRbn0K4IByinOifJjZ9nER QyZOqI9l8qFTqBecCoGdkwbLjqSUQpIZrp0nQFqbcEhO5yrm+Ac0NdoOv/InnYMZ64lC scrURhbalybEWf81TZ1bfWAVFGi728/sdilUNrw0hKCwIjXPP4w+depedI/BAy1JergX m+mwch7VgYfgMgGG2uhapX6CpsEFp6p32PLP388NweNa069qmWdFDIHLpOMq+tUNK48g e8KA== 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=GDbB0emHRJtzstxqehbWZpNByM5KcAA3MiA/ST8TdBDJKLNA52NOoR9s68y6i5tJI3 Wi9o9N3UBGP4KCN4rwEN0tuxqZiUNn3A0B8hbyKoMKEQ/YIaN41rDN12GXrXe0w+1HmN HEV7/tcZmvVxGbQs31oJbSNpw4izQjaFUVWz2edZ1k44SGlKWtFMOnJadDBc9Vg9pUfp hIcADnPjgDrai6mXYoGsXKZmD96FJB0H6DgkXAs9oSd2RB0lQU3eBpW03s+CU6FWwCzP e+52WQoGa7U8Gl9PjE1B/ufSgzjD+xqNd3+evCias5ywqIMraPlY2yNL18Jw6EKgpzX2 9U0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="lfd/6isT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id 23-20020a630017000000b005c668dc2426si1788238pga.176.2023.12.08.08.13.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 08:13:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="lfd/6isT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id D9EAB81CFF3C; Fri, 8 Dec 2023 08:13:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574338AbjLHQNL (ORCPT + 99 others); Fri, 8 Dec 2023 11:13:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233712AbjLHQM7 (ORCPT ); Fri, 8 Dec 2023 11:12:59 -0500 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD81C1997; Fri, 8 Dec 2023 08:13:01 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id CF3E4E0007; Fri, 8 Dec 2023 16:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702051980; 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=lfd/6isT0VX4Egalf6Do3M7LwdsJAm7pZed++q2SqPXqXIm5iRn9Ab915SwnV5LwYI3jNR +qyOYjElMM8o5r71l9qrpOTGJE/sh0RIbCYKatsZOqFskdMpM6BKO6effwlc4MA/MANDKW 6YwStIHXFwifHg1GBuvjmYC9SxR9mFE3SwzbWkRxJqr0aAeRNj7IVIidl0/D8mOwAuwG02 lSLx5obyqorc+kgklKY1IvN8hPWvD/eOM4LIYfbn7Y9Rm3KzEzeP2zZvElKxlhYUxzoZps 3H1kz39R41mJRRRMh1DuOa490v9yJyPjDfkPMHwoskbVXOv0B2/IBUvYkKNGtA== 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 v4 07/22] MIPS: Fix cache issue with mips_cps_core_entry Date: Fri, 8 Dec 2023 17:12:23 +0100 Message-ID: <20231208161249.1827174-8-gregory.clement@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231208161249.1827174-1-gregory.clement@bootlin.com> References: <20231208161249.1827174-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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 08 Dec 2023 08:13:28 -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