From patchwork Fri Dec 1 11:14:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory CLEMENT X-Patchwork-Id: 172426 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp1041009vqy; Fri, 1 Dec 2023 03:16:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDN1wW46tnFVvRCY+72fewaxBlmY+tDnlr62aWPFq07JFzf3+JP0ARVjbD2BML7zQbz9e7 X-Received: by 2002:a05:6a00:1914:b0:6ce:30:7e23 with SMTP id y20-20020a056a00191400b006ce00307e23mr1377260pfi.24.1701429376325; Fri, 01 Dec 2023 03:16:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701429376; cv=none; d=google.com; s=arc-20160816; b=mnJYr7K9WxyFGMtcko3YMkwS7YnGvuZeRGfaIJdCLePy+ijNYbL41MW6Wqmu56fmSj k8iryPjR7ZMjgddFDOwdobcLiT7KBvUM5q41So4PXP6mr9Wn5RJjcfzrIfYqez+5kiya 0x0DuZD/fmcGgZ9KgBQ0ITWNmnk8zGyXTuuzC7Oz8Ypv3Oss+IEPtz5F0cGIt0jaReq1 JOR9btOiYztVuqDXHsrvODkPH+fAjy2Ay88x1+JdTPxj6YYTRG/O/aMPoGAu/C5DQIGp ppwJlcfZPxwDdOhXk+omrYlo7wJobdKPj2R+T717DSQNHaB81OEBvMIaWAl3iQXqNqOo 4FKg== 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=HMHvkFK/s6d6vN3hXXe7fshcLbIdmlq/lluCMLeWStbSmS6vYImUL8rTcXVi/QaJbe 7aER5wOK8Za+uaFQcnHij3MTxMQJzhNUxQXtxCXdbo4T9Z1i1ggderj5vk9VqH1diyEA mkzteVSCYxRB4rgDT3wtPbHIpLabp/6shHUu39SNG5psRm8oJttIpFhdGwfPXgFWsSzb xdHRjJ3EFmrk03mjETmpIzAPpS6AsmuQnYqP/QwxoH0ihktmlM53RSdWaDlMIHdScNfX uYNnXsqtLSLSY+LAFMsxAm6jH2Dqr36ho/RcLWHeCqi+cNda0pa5wQaxV2cM56UDPstE 3omA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=B3TbKRJ7; 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id m18-20020a056a00081200b006c3077a3400si3259188pfk.279.2023.12.01.03.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 03:16:16 -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=B3TbKRJ7; 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 600BF816EBDF; Fri, 1 Dec 2023 03:16:11 -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 S1378575AbjLALPy (ORCPT + 99 others); Fri, 1 Dec 2023 06:15:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378502AbjLALPY (ORCPT ); Fri, 1 Dec 2023 06:15:24 -0500 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF475170C; Fri, 1 Dec 2023 03:15:29 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 0B85820002; Fri, 1 Dec 2023 11:15:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701429328; 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=B3TbKRJ746g9k8YORjLbNQ2F+magN1zZo68eC9khy06Zv6uJeEPQ9a1ZkfpS8d3xfR4Rpv XuYckfhTHVf7GRhoESbrvqmuLM8bSwCL+G11ZmDPt7SI7vUZ/ndodv8ax3A+u/54+6q65z 8ESnXGcJGwcG+71wVfOu7qDv0uGEZv2QuFjaVyfCQXN9budwWuhJLEmOVobDfo1SofJ7qE rRPxNeOdtn0axyxhhoHhJ/5cdGTDVKBiLAcOlqm296d4EO//MchOJEdvb6ZolZoUcMmH7Q NY05lfYQaxo3MbAXNDj69lzQWx/43zP63Uh4Xsv40z35KKnQdJ/tGIhSdETQHw== 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_Lebr?= =?utf-8?q?un?= , Thomas Petazzoni , Gregory CLEMENT Subject: [PATCH v3 07/22] MIPS: Fix cache issue with mips_cps_core_entry Date: Fri, 1 Dec 2023 12:14:50 +0100 Message-ID: <20231201111512.803120-8-gregory.clement@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231201111512.803120-1-gregory.clement@bootlin.com> References: <20231201111512.803120-1-gregory.clement@bootlin.com> MIME-Version: 1.0 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, 01 Dec 2023 03:16:11 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784078009593086660 X-GMAIL-MSGID: 1784078009593086660 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);