Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp409170rdb; Tue, 5 Dec 2023 08:37:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFB8QQOizAjzfPsRNpxoDHZbLjt9X1ctej0/+eu/hMOR1nhr/EQn47jNNMgDupFFEjM+EnX X-Received: by 2002:a17:903:489:b0:1d0:84f1:6fb8 with SMTP id jj9-20020a170903048900b001d084f16fb8mr2500897plb.68.1701794246737; Tue, 05 Dec 2023 08:37:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701794246; cv=none; d=google.com; s=arc-20160816; b=tp7dSkipqZ2oRUnq6A8bw6WNGEXUPTkJMgFGOjC5gaA4X7tzw3ruyaplFymWDsX8u9 1NPygCq7OZ+25/SXsI0TwK3VbPfBBB25jJ+qUw11QvkPhSiKBi5yMq3rLPyFfb3CaIJg aXC8g1E3ukvUCMBlcihOBQzHXEc4ItyLo3kVzBIt6N8LdxAnrJOlEp+z2Gm7aCKW2f3u rEuYkw8vuKjxBQ5Aw9QkIGmqEHjAx/woY45LqWHsn/i3L7ZZR4I7o4cyCFWVVyzZesJR SlMa7wm/jJZSExgLCWVgk0mQsAdYOX/RWxLG9UI01/XYIeG54uTKjMlXTemwY75AoMAI MBtw== 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 :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=Uwdqih8d4ChJEVJBX1tE0PIM7+9cgSue2Go+/HkBFxA=; fh=dpZCLFHEZ/lTrkwYNKTsHLswduBVOBZ3QQnbn3JgFRA=; b=O7BlTVv5o9nOlkT/ICuhuDUAafRLucGAr0YrGb8Lh6oeP+lLXVFphtQAPm98NzNT+r 1kAQRmO1pVX+LHBN5PeAKUsqNk+vq58CUG2OH6jg6YIva64CEdxMbVI4wx40GztOwm6E HFi6wlNz9IGL9n957u1/xQbtZthQJlHMjsq3zYlNfcNz77W3NZ3hy0jw53kzJQg1f6iE aonHE5X7bTe9pUcyEB2YQI187T3b1WsLtHBDIFs6gFGJuEUZFxAI3xF7ofVDFhAg05kH CVZ29CtuZapca81SyNp/gO6zqV+Tk2BHwnrX/niojKnU+xx6WdbIAoRQwfTWpi1YXaJO P1Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=QnLp8DxB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id b12-20020a170903228c00b001d0b1a08a0asi3149061plh.535.2023.12.05.08.37.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 08:37:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=QnLp8DxB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id E27ED80B02BD; Tue, 5 Dec 2023 08:35:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232025AbjLEQen (ORCPT + 99 others); Tue, 5 Dec 2023 11:34:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229971AbjLEQem (ORCPT ); Tue, 5 Dec 2023 11:34:42 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3F8A129; Tue, 5 Dec 2023 08:34:47 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id CAC49FF805; Tue, 5 Dec 2023 16:34:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701794086; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Uwdqih8d4ChJEVJBX1tE0PIM7+9cgSue2Go+/HkBFxA=; b=QnLp8DxBW+vkkFhgEGG5u30oDPIp1UJ1ZIgMiIHL6+ulgLjy0fhQKhNulokopgfNUdsCds I2owO3Rqq562ImCeO6pWMbaCXyD9QSk+etF1ovgJDyJwt/zxrtoxsGJtHhEBaoylHnslR0 KR/bZcCkV92lwJ0RZ97+LcqYP8JMNoB/Wh8gpv1VHjYJqWZvYrDPcHSk4lC6pxQHgb4G9u vk4HCxcd8MQq09dR2qupsSdF7vT1ZqWZRAiYPCneHu+snktyVXG3Yb6A826GJZS1KrvGbH D+etNxgfJktOAsN1WeYsDX3R6bdnhJw2HB26Nx42jFhMRjOhe4Or6Df84QjKpQ== From: Gregory CLEMENT To: Jiaxun Yang Cc: Paul Burton , Thomas Bogendoerfer , linux-mips@vger.kernel.org, Vladimir Kondratiev , Tawfik Bayouk , Alexandre Belloni , =?utf-8?Q?Th=C3=A9o?= Lebrun , Thomas Petazzoni , Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 06/22] MIPS: Refactor mips_cps_core_entry implementation In-Reply-To: <20231201111512.803120-7-gregory.clement@bootlin.com> References: <20231201111512.803120-1-gregory.clement@bootlin.com> <20231201111512.803120-7-gregory.clement@bootlin.com> Date: Tue, 05 Dec 2023 17:34:45 +0100 Message-ID: <87lea8ehga.fsf@BL-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 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]); Tue, 05 Dec 2023 08:35:06 -0800 (PST) Hello Jiaxun, > From: Jiaxun Yang > > Now the exception vector for CPS systems are allocated on-fly > with memblock as well. > > It will try to allocate from KSEG1 first, and then try to allocate > in low 4G if possible. > > The main reset vector is now generated by uasm, to avoid tons > of patches to the code. Other vectors are copied to the location > later. > > Signed-off-by: Jiaxun Yang > --- [...] > diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c [...] > +static int __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); > + phys_addr_t cps_vec_pa; > + void *cps_vec; > + > + /* Try to allocate in KSEG1 first */ > + cps_vec_pa =3D memblock_phys_alloc_range(BEV_VEC_SIZE, BEV_VEC_ALIGN, > + 0x0, KSEGX_SIZE - 1); > + > + if (cps_vec_pa) > + core_entry_reg =3D CKSEG1ADDR(cps_vec_pa) & > + CM_GCR_Cx_RESET_BASE_BEVEXCBASE; > + > + if (!cps_vec_pa && mips_cm_is64) { > + cps_vec_pa =3D memblock_phys_alloc_range(BEV_VEC_SIZE, BEV_VEC_ALIGN, > + 0x0, SZ_4G - 1); > + if (cps_vec_pa) > + core_entry_reg =3D (cps_vec_pa & CM_GCR_Cx_RESET_BASE_BEVEXCBASE) | > + CM_GCR_Cx_RESET_BASE_MODE; > + } > + > + if (!cps_vec_pa) > + return -ENOMEM; > + > + /* 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_SIZ= E); > + bc_wback_inv(TO_CAC(cps_vec_pa), BEV_VEC_SIZE); > + __sync(); > + > + cps_vec =3D (void *)TO_UNCAC(cps_vec_pa); Following your remark about the configuration for generic mips32[1]. I made some changes and tried to build with the following command: make 32r6el_defconfig; make I got the follower error: arch/mips/kernel/smp-cps.c: In function =E2=80=98setup_cps_vecs=E2=80=99: arch/mips/kernel/smp-cps.c:162:19: error: cast to pointer from integer of d= ifferent size [-Werror=3Dint-to-pointer-cast] The issue comes from the TO_UNCAC macro that use the TO_PHYS_MASK macro which is 64 bits, so it turn the size of TO_UNCAC() to 8 bytes while the size of a pointer is 4 bytes. Actually it show that TO_UNCAC was created to be only used for 64 bits, and it was only your patch "MIPS: spaces: Define a couple of handy macros" that made possible to use in 32 bit case. Did you mange to build a kernel in 32 bits configuration ? Maybe you had a local patch that made it possible. I propose the following fix to squash into the patch "MIPS: spaces: Define a couple of handy macros" , what do you think of it? diff --git a/arch/mips/include/asm/mach-generic/spaces.h b/arch/mips/includ= e/asm/mach-generic/spaces.h index 05db19521e817..4884199d8b8c4 100644 --- a/arch/mips/include/asm/mach-generic/spaces.h +++ b/arch/mips/include/asm/mach-generic/spaces.h @@ -49,6 +49,9 @@ #define HIGHMEM_START _AC(0x20000000, UL) #endif =20 +#define TO_UNCAC(x) CKSEG1ADDR(x) +#define TO_CAC(x) CKSEG0ADDR(x) + #endif /* CONFIG_32BIT */ =20 #ifdef CONFIG_64BIT @@ -78,12 +81,12 @@ #define HIGHMEM_START (_AC(1, UL) << _AC(59, UL)) #endif =20 +#define TO_UNCAC(x) (UNCAC_BASE | ((x) & TO_PHYS_MASK)) +#define TO_CAC(x) (CAC_BASE | ((x) & TO_PHYS_MASK)) #define TO_PHYS(x) ( ((x) & TO_PHYS_MASK)) =20 #endif /* CONFIG_64BIT */ =20 -#define TO_CAC(x) (CAC_BASE | ((x) & TO_PHYS_MASK)) -#define TO_UNCAC(x) (UNCAC_BASE | ((x) & TO_PHYS_MASK)) =20 /* * This handles the memory map. [1]:https://lore.kernel.org/linux-mips/4eb150cf-3fb7-41c8-accc-06b13e46f086= @app.fastmail.com/ --=20 Gregory Clement, Bootlin Embedded Linux and Kernel engineering http://bootlin.com