Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1428354rda; Mon, 23 Oct 2023 12:14:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/5BvPw5DqtmonenA6ohnKmBhRznWcjjKmIYrvIo08Yh+hhythJI0l5BKNcN8eECQr8J6Y X-Received: by 2002:a05:6a21:1a3:b0:16b:7602:15b1 with SMTP id le35-20020a056a2101a300b0016b760215b1mr626010pzb.12.1698088486389; Mon, 23 Oct 2023 12:14:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698088486; cv=none; d=google.com; s=arc-20160816; b=HJYgBEJcYGsNezldfPaR5FgAhT9Ba5+n1kFu9atKLAKoy/AjfpVc+Lp7D+0dUa7At8 LDByEmBWUP6xszGdJkQbsL22Y4mMLbNh1Sxw/WxlrC0numxMLLeRrtbCr2OMFm2qFqv+ eDhHInmPXlDRkQh6IUPMm6brAweJMLxZ3NyxM38/wNk/kWSKCcyCY2/pt01Wl5i1Wx00 C7x2VU62jxKKnyozAzuWucg+WHSTHstFVmRsHzoMW/wIY4L7fR7YFBkpBPC7XtIhN0OG 5brtgTn0+WrEA7ZvZ8QxNvKgsMKfhAdD4jP4XGVm1d/eLNCILPU3fKjDWjJmqymlusIG PMUg== 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 :feedback-id:dkim-signature:dkim-signature; bh=axCOXJ1HMSIUr/oFZjhnVtqXrX+b0q0P4G/a7WUwdbo=; fh=34VXqKbbbRVUWYKB0XlF9D4jmhXxe51P2+smd1zcTfU=; b=vxPvwzGjR5BozAOdoE31CniIdR3ZcXhisxqlanczfcytlZC/Rkh3POpivvRmwkFJSr D9I7u5vhSy2TKfOoo/oouAOgcJlDuOIy07CKrL1G9zybS2uwlKkBqbx6ZiMiSC1UbNIU I+JSv1xZOu0iavC9HEC1ZaaV73ANPz27j6lpYSrFjE2iZKPyyNurDFABFWs64BeHjSgJ l73lluIWwvdlXXOjUKx7ti7+TXuaBMWfSj4TnJuenrlwFBA2mcbTaGLyovoTKp1bukUI H8EWKj90T9jbzrSHAbNI4xFvZ0qH1hKDN8Wq8+3NC8VgGl/YE1uiPFHnShIBC68KUaPe bd0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=vsLaEWs9; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=H1HXqrR9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id i130-20020a639d88000000b00578b6e32b5dsi6653268pgd.405.2023.10.23.12.14.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 12:14:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=vsLaEWs9; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=H1HXqrR9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 279C580AFB8D; Mon, 23 Oct 2023 12:14:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231824AbjJWTOX (ORCPT + 99 others); Mon, 23 Oct 2023 15:14:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231661AbjJWTOO (ORCPT ); Mon, 23 Oct 2023 15:14:14 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44B81100; Mon, 23 Oct 2023 12:14:12 -0700 (PDT) Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.nyi.internal (Postfix) with ESMTP id 9546D5C0381; Mon, 23 Oct 2023 15:14:11 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 23 Oct 2023 15:14:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1698088451; x= 1698174851; bh=axCOXJ1HMSIUr/oFZjhnVtqXrX+b0q0P4G/a7WUwdbo=; b=v sLaEWs92HWTR+7DJmUj2C5j4L3zPRmjgOhMu51FdXoiwbWRGb/Vr9Yum7Sy9z9Ax QDizshS8CFvxX9KSLEC6K8RgBc5toBasXpaErwFUWlgCxIF2GRJsNi6ONkVJKhYP +1P9b1HCvOtXeP39IFh7gy0gLxI/cOLsC0BUk0HDFr8G+2LaYifAKHeWvUuuvtOq iW+wFNLZTT4y2NOSOIaXS3n4DemEcLhMk557ohgWpofuvKHlS66jjwVGNTahJiuT OIXwVdQi2Qt588OSbXYm0JfkXu9DJEpvqBesAnAkhLqIy2Y1aI9Kks5N4YEeV8mz 9Z6kOFIKmhU77BoEz+jjA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1698088451; x= 1698174851; bh=axCOXJ1HMSIUr/oFZjhnVtqXrX+b0q0P4G/a7WUwdbo=; b=H 1HXqrR9VDzPz5pGLgnhATMlkXnkYo86IZ9veC3/fX/6JB5Ld5oW3BBmazE5YeWBD oHTFg16AiKsjH/+voYWMYnv++Ul84E5BOdcG1AOniGBNobX9b3y1i86/Ebd1D+1J 4Z3VUh0hZpvJA7+/YTRHq9eHuqbG5Hbn8jfRupaMLkLHu4KUsgU+0FkJTpgTewta yH/I7lYLaaG/EGw/bcaCU5OG8h5vW7tNsQXkaeb4W4t7HxEdK3Smv0EnRExopxol DfdIe2JKMZTLJ/mo/Bs2wU/ts2Kf412st0cmoXRQRYN10IU5d+zAYProreRpejHy ej0t5GO+Z/Bhgvx/t0jCw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrkeeigddufeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghn ghesfhhlhihgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepfeeludefheegvdeuvd dvgeekgfdvtdettdelieeihfegtedugeekhfdvhfejfedtnecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 23 Oct 2023 15:14:10 -0400 (EDT) From: Jiaxun Yang To: linux-mips@vger.kernel.org Cc: linux-kernel@vger.kernel.org, tsbogend@alpha.franken.de, gregory.clement@bootlin.com, vladimir.kondratiev@intel.com, Jiaxun Yang Subject: [PATCH 4/5] MIPS: Handle mips_cps_core_entry within lower 4G Date: Mon, 23 Oct 2023 20:13:59 +0100 Message-Id: <20231023191400.170052-5-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231023191400.170052-1-jiaxun.yang@flygoat.com> References: <20231023191400.170052-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Mon, 23 Oct 2023 12:14:44 -0700 (PDT) Set CM_GCR_Cx_RESET_BASE_MODE and use XKPHYS base address for core_entry for 64bit CM when mips_cps_core_entry is beyond KSEG1. Also disable SMP and warn user if mips_cps_core_entry is unsuitable as reset vector. Signed-off-by: Jiaxun Yang --- Note: IMO it does not solve the problem of MobileEye, which have mips_cps_core_entry beyond lower 4G, it just enables me to test kernel in XKPHYS on boston. --- arch/mips/include/asm/mips-cm.h | 1 + arch/mips/kernel/smp-cps.c | 27 +++++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/arch/mips/include/asm/mips-cm.h b/arch/mips/include/asm/mips-cm.h index 23c67c0871b1..15d8d69de455 100644 --- a/arch/mips/include/asm/mips-cm.h +++ b/arch/mips/include/asm/mips-cm.h @@ -311,6 +311,7 @@ GCR_CX_ACCESSOR_RW(32, 0x018, other) /* GCR_Cx_RESET_BASE - Configure where powered up cores will fetch from */ GCR_CX_ACCESSOR_RW(32, 0x020, reset_base) #define CM_GCR_Cx_RESET_BASE_BEVEXCBASE GENMASK(31, 12) +#define CM_GCR_Cx_RESET_BASE_MODE BIT(1) /* GCR_Cx_ID - Identify the current core */ GCR_CX_ACCESSOR_RO(32, 0x028, id) diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c index dd55d59b88db..623dfd05585b 100644 --- a/arch/mips/kernel/smp-cps.c +++ b/arch/mips/kernel/smp-cps.c @@ -26,6 +26,7 @@ #include static DECLARE_BITMAP(core_power, NR_CPUS); +static uint32_t core_entry_reg; struct core_boot_config *mips_cps_core_bootcfg; @@ -37,7 +38,6 @@ static unsigned __init core_vpe_count(unsigned int cluster, unsigned core) static void __init cps_smp_setup(void) { unsigned int nclusters, ncores, nvpes, core_vpes; - unsigned long core_entry; int cl, c, v; /* Detect & record VPE topology */ @@ -94,10 +94,20 @@ static void __init cps_smp_setup(void) /* Make core 0 coherent with everything */ write_gcr_cl_coherence(0xff); - if (mips_cm_revision() >= CM_REV_CM3) { - core_entry = CKSEG1ADDR((unsigned long)mips_cps_core_entry); - write_gcr_bev_base(core_entry); - } + /* + * Set up the core entry address + * If accessible in KSEG1 just use KSEG1 + */ + if (__pa_symbol(mips_cps_core_entry) < SZ_512M) + core_entry_reg = CKSEG1ADDR(__pa_symbol(mips_cps_core_entry)); + + /* If CM is 64bit and with-in low 4G just use XKPHYS */ + if (mips_cm_is64 && __pa_symbol(mips_cps_core_entry) < SZ_4G) + core_entry_reg = __pa_symbol(mips_cps_core_entry) | + CM_GCR_Cx_RESET_BASE_MODE; + + if (core_entry_reg && mips_cm_revision() >= CM_REV_CM3) + write_gcr_bev_base(core_entry_reg); #ifdef CONFIG_MIPS_MT_FPAFF /* If we have an FPU, enroll ourselves in the FPU-full mask */ @@ -114,6 +124,11 @@ static void __init cps_prepare_cpus(unsigned int max_cpus) mips_mt_set_cpuoptions(); + if (!core_entry_reg) { + pr_err("core_entry address unsuitable, disabling smp-cps\n"); + goto err_out; + } + /* Detect whether the CCA is unsuited to multi-core SMP */ cca = read_c0_config() & CONF_CM_CMASK; switch (cca) { @@ -213,7 +228,7 @@ static void boot_core(unsigned int core, unsigned int vpe_id) mips_cm_lock_other(0, core, 0, CM_GCR_Cx_OTHER_BLOCK_LOCAL); /* Set its reset vector */ - write_gcr_co_reset_base(CKSEG1ADDR((unsigned long)mips_cps_core_entry)); + write_gcr_co_reset_base(core_entry_reg); /* Ensure its coherency is disabled */ write_gcr_co_coherence(0); -- 2.34.1