Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp662482rdb; Fri, 22 Dec 2023 00:48:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IEvjJlriIvSVnkfu76FH4fW6OlHSoWYG9YuvXhejWb/xNj4i7diAu6Q1NpyZXeUHcaWdkjM X-Received: by 2002:a05:620a:4155:b0:77f:6b6:95ce with SMTP id k21-20020a05620a415500b0077f06b695cemr1387162qko.143.1703234925557; Fri, 22 Dec 2023 00:48:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703234925; cv=none; d=google.com; s=arc-20160816; b=oCaJLGYQbUD18VhaVkCfgvdKqcm6sDJkYrR4hBrIMKx4V0uzJ/PxlIQcafpZcVrOwN DgzAqwc6JIQ9dHIyRFSoj2TrJNycYBFsQUKDVBxPMFkPh7f85qkiG75sQYuSa+UljKkz ypXrswd8n+uwoK5U6Lr4uTOI/Y/TtbCuOr8YdLRnhem+USFqpJQGKEHRWddYXWt+MN4B w5yI6ZNt1S8lDC5p1NgN3sheOL7jx9LBem/5ncTx0bj1G6dlkHf90sgV9TlA1ngJV2O3 fXyYW3EMz70OqVyDs/mcL3RPQDGF+ZzybaMaJ2JOXXPO3Kjwhbvdk4QO6x/SmIpehTaZ ivkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=oWIp5InUGyUzaylWZZL5A5hNc9Ub4HLtupMi0ioFdMs=; fh=6qwwY8lwlJHLCBHrykD34Qg1plXAUErVhTVOejBEsF8=; b=Goxw2MKftxc/J9Q/bHLiUBTZFCtf6RjkAKsoOMueb+yNAldxUbXvKtl0ZH+LiA9uaq oHDv/m5CkgvGqfRKaDlRPv06J0NxZCmCq7UTRkPMrmMU7dU6gB00JtWJdfmHO/L+DLZE 7+dtdgng+dxmCaX3atnn0I/Xns43ZsZrIpg1gQWSMiHnm6xCA6u1BmRG3/wMJp/mUS/5 dEgXgJdT0tQ6sIICIQAYWh7sHZn+ZUOezRO5c0dKaDSXS0qaCTZQrnaTL+qlY6n3EOY3 STt5UfKCtjkfAv8m/o2vqP9xidjQzbVMo02BZX+VfWlG5Tt/UXi7TFkw9DvLP8LzNjDY BCOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tq-group.com header.s=key1 header.b=LwORYRx8; spf=pass (google.com: domain of linux-kernel+bounces-9518-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9518-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tq-group.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m8-20020a05620a24c800b0077db46030c0si4266616qkn.551.2023.12.22.00.48.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 00:48:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9518-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@tq-group.com header.s=key1 header.b=LwORYRx8; spf=pass (google.com: domain of linux-kernel+bounces-9518-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9518-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tq-group.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 42FCA1C21698 for ; Fri, 22 Dec 2023 08:48:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BC61CA5D; Fri, 22 Dec 2023 08:48:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tq-group.com header.i=@tq-group.com header.b="LwORYRx8" X-Original-To: linux-kernel@vger.kernel.org Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5663FC8C8 for ; Fri, 22 Dec 2023 08:48:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ew.tq-group.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1703234915; x=1734770915; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=oWIp5InUGyUzaylWZZL5A5hNc9Ub4HLtupMi0ioFdMs=; b=LwORYRx8paCLkq9EwBpPWT6TeBITPzYDInyrsMlMcmeCB6SnXVOWdOM9 Qxx5ACSjI2AqzaA/hywQZ1DrRIw3lyz1dVv3ividTJjDr24Ou/3US5VcY LKRuoa32Jw25PgOvSkZOi/EOTmqrUGo4E60k3AItSaTLFpEkcmyW4KM4o 1/EsWtYfqTA+MN0jOGT1ZR9ja27ndSd8OExHizt/QlbpxQkzrXXZpjlRZ qmKcQ48X5VLzM8AsiJwDzcfS6WaxpnuXf3RCqVnQ3/8SRx0FFXdRcLYND 42cdbNvklb8K0ypb0SdXgEF+JosuBFXBE6gDc6yIn821tUSRFaau8s43f A==; X-IronPort-AV: E=Sophos;i="6.04,294,1695679200"; d="scan'208";a="34649929" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 22 Dec 2023 09:48:32 +0100 Received: from [192.168.2.128] (SCHIFFERM-M2.tq-net.de [10.121.53.15]) by vtuxmail01.tq-net.de (Postfix) with ESMTPA id B4A8D280075; Fri, 22 Dec 2023 09:48:31 +0100 (CET) Message-ID: Subject: Re: [PATCH] powerpc/6xx: set High BAT Enable flag on G2 cores From: Matthias Schiffer To: Christophe Leroy Cc: Nicholas Piggin , "Aneesh Kumar K.V" , "Naveen N. Rao" , "linuxppc-dev@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" , "linux@ew.tq-group.com" , Michael Ellerman Date: Fri, 22 Dec 2023 09:48:31 +0100 In-Reply-To: <2fad9563-09ee-4017-8a67-5958475d56c8@csgroup.eu> References: <20231221124538.159706-1-matthias.schiffer@ew.tq-group.com> <2fad9563-09ee-4017-8a67-5958475d56c8@csgroup.eu> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Thu, 2023-12-21 at 13:57 +0000, Christophe Leroy wrote: >=20 >=20 > Le 21/12/2023 =C3=A0 13:45, Matthias Schiffer a =C3=A9crit=C2=A0: > > MMU_FTR_USE_HIGH_BATS is set for G2-based cores (G2_LE, e300cX), but th= e > > high BATs need to be enabled in HID2 to work. Add register definitions > > and introduce a G2 variant of __setup_cpu_603. >=20 > Well spotted. >=20 > I have a mpc8321, hence e300c2. I never had the problem you had. >=20 > But ... looks like U-boot configuration has CONFIG_HID2_HBE so that's=20 > set by U-boot indeed, that's the reason why I never had that problem. I'll extend the commit message to mention that U-Boot setting in v2. >=20 > >=20 > > This fixes boot on CPUs like the MPC5200B with STRICT_KERNEL_RWX enable= d. > >=20 > > Fixes: e4d6654ebe6e ("powerpc/mm/32s: rework mmu_mapin_ram()") > > Signed-off-by: Matthias Schiffer > > --- > > arch/powerpc/include/asm/cpu_setup.h | 1 + > > arch/powerpc/include/asm/reg.h | 2 ++ > > arch/powerpc/kernel/cpu_setup_6xx.S | 25 ++++++++++++++++++++++= - > > arch/powerpc/kernel/cpu_specs_book3s_32.h | 10 ++++----- > > 4 files changed, 32 insertions(+), 6 deletions(-) > >=20 > >=20 > > I have only tested this on the MPC5200B (G2_LE), but according to the > > e300 manual, e300cX cores should behave the same. > >=20 > > The Fixes tag is the best I could come up with - I believe that the > > underlying issue of setting USE_HIGH_BATS without actually enabling the= m > > is as old as Linux's PowerPC implementation, but the specific code > > causing the boot failure was added in the mentioned commit. >=20 > Agreed, before that only BATs 0 to 3 were used anyway. > There was also BAT 4 used by platforms/embedded6xx/wii.c , but that's= =20 > probably not a G2 ? >=20 > >=20 > > Another issue I found in the code is that > > arch/powerpc/platforms/52xx/lite5200_sleep.S uses the SPRN_HID2 definit= ion > > which does not refer to HID2 on the 5200... but that will be for someon= e > > else to fix, if there is still anyone left using that platform. >=20 > Maybe file an issue for it at https://github.com/linuxppc/issues/issues= =20 > if you don't plan to fix it ? >=20 > By the way, it looks like the SPRN_HID2 definition we have is very=20 > specific to the IBM 750. >=20 IBM 750GX even - googling for IBM 750 came up with several other cores that= either don't have HID2, or have it at a different SPR. > MPC 750 has SPRN_HID2 as 1011 =3D=3D 0x3f3 like others. > >=20 > >=20 > > diff --git a/arch/powerpc/include/asm/cpu_setup.h b/arch/powerpc/includ= e/asm/cpu_setup.h > > index 30e2fe3895024..68d804e74d221 100644 > > --- a/arch/powerpc/include/asm/cpu_setup.h > > +++ b/arch/powerpc/include/asm/cpu_setup.h > > @@ -35,6 +35,7 @@ void __setup_cpu_750fx(unsigned long offset, struct c= pu_spec *spec); > > void __setup_cpu_7400(unsigned long offset, struct cpu_spec *spec); > > void __setup_cpu_7410(unsigned long offset, struct cpu_spec *spec); > > void __setup_cpu_745x(unsigned long offset, struct cpu_spec *spec); > > +void __setup_cpu_g2(unsigned long offset, struct cpu_spec *spec); > >=20 > > void __setup_cpu_ppc970(unsigned long offset, struct cpu_spec *spec); > > void __setup_cpu_ppc970MP(unsigned long offset, struct cpu_spec *spec= ); > > diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/= reg.h > > index 4ae4ab9090a2d..f5641fcd1da85 100644 > > --- a/arch/powerpc/include/asm/reg.h > > +++ b/arch/powerpc/include/asm/reg.h > > @@ -617,6 +617,8 @@ > > #endif > > #define SPRN_HID2 0x3F8 /* Hardware Implementation Reg= ister 2 */ >=20 > Should that HID2 be renamed to SPRN_HID2_750 to avoid confusion ? Makes sense (should the suffix be "750GX"?). I can also add a FIXME comment= to lite5200_sleep.S as part of the rename. > > > #define SPRN_HID2_GEKKO 0x398 /* Gekko HID2 Register= */ > > +#define SPRN_HID2_G2 0x3F3 /* G2 HID2 Register */ > > +#define HID2_HBE_G2 (1<<18) /* High BAT Enable (G2) */ > > #define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Regi= ster */ > > #define SPRN_IABR2 0x3FA /* 83xx */ > > #define SPRN_IBCR 0x135 /* 83xx Insn Breakpoint Contro= l Reg */ > > diff --git a/arch/powerpc/kernel/cpu_setup_6xx.S b/arch/powerpc/kernel/= cpu_setup_6xx.S > > index f29ce3dd6140f..c67d32e04df9c 100644 > > --- a/arch/powerpc/kernel/cpu_setup_6xx.S > > +++ b/arch/powerpc/kernel/cpu_setup_6xx.S > > @@ -81,6 +81,20 @@ _GLOBAL(__setup_cpu_745x) > > bl setup_745x_specifics > > mtlr r5 > > blr > > +_GLOBAL(__setup_cpu_g2) > > + mflr r5 > > +BEGIN_MMU_FTR_SECTION > > + li r10,0 > > + mtspr SPRN_SPRG_603_LRU,r10 /* init SW LRU tracking= */ > > +END_MMU_FTR_SECTION_IFSET(MMU_FTR_NEED_DTLB_SW_LRU) >=20 > MMU_FTR_NEED_DTLB_SW_LRU is dedicated to e300 core. You should also=20 > remove it from __setup_cpu_603 Will do, thanks. >=20 > > + > > +BEGIN_FTR_SECTION > > + bl __init_fpu_registers > > +END_FTR_SECTION_IFCLR(CPU_FTR_FPU_UNAVAILABLE) > > + bl setup_common_caches > > + bl setup_g2_hid2 > > + mtlr r5 > > + blr > >=20 > > /* Enable caches for 603's, 604, 750 & 7400 */ > > SYM_FUNC_START_LOCAL(setup_common_caches) > > @@ -115,6 +129,16 @@ SYM_FUNC_START_LOCAL(setup_604_hid0) > > blr > > SYM_FUNC_END(setup_604_hid0) > >=20 > > +/* Enable high BATs for G2 (G2_LE, e300cX) */ > > +SYM_FUNC_START_LOCAL(setup_g2_hid2) > > + mfspr r11,SPRN_HID2_G2 > > + oris r11,r11,HID2_HBE_G2@h > > + mtspr SPRN_HID2_G2,r11 > > + sync > > + isync > > + blr > > +SYM_FUNC_END(setup_g2_hid2) > > + > > /* 7400 <=3D rev 2.7 and 7410 rev =3D 1.0 suffer from some > > * erratas we work around here. > > * Moto MPC710CE.pdf describes them, those are errata > > @@ -495,4 +519,3 @@ _GLOBAL(__restore_cpu_setup) > > mtcr r7 > > blr > > _ASM_NOKPROBE_SYMBOL(__restore_cpu_setup) > > - > > diff --git a/arch/powerpc/kernel/cpu_specs_book3s_32.h b/arch/powerpc/k= ernel/cpu_specs_book3s_32.h > > index 3714634d194a1..83f054fcf837c 100644 > > --- a/arch/powerpc/kernel/cpu_specs_book3s_32.h > > +++ b/arch/powerpc/kernel/cpu_specs_book3s_32.h > > @@ -69,7 +69,7 @@ static struct cpu_spec cpu_specs[] __initdata =3D { > > .mmu_features =3D MMU_FTR_USE_HIGH_BATS, > > .icache_bsize =3D 32, > > .dcache_bsize =3D 32, > > - .cpu_setup =3D __setup_cpu_603, > > + .cpu_setup =3D __setup_cpu_g2, > > .machine_check =3D machine_check_generic, > > .platform =3D "ppc603", > > }, > > @@ -83,7 +83,7 @@ static struct cpu_spec cpu_specs[] __initdata =3D { > > .mmu_features =3D MMU_FTR_USE_HIGH_BATS, > > .icache_bsize =3D 32, > > .dcache_bsize =3D 32, > > - .cpu_setup =3D __setup_cpu_603, > > + .cpu_setup =3D __setup_cpu_g2, > > .machine_check =3D machine_check_83xx, > > .platform =3D "ppc603", > > }, > > @@ -96,7 +96,7 @@ static struct cpu_spec cpu_specs[] __initdata =3D { > > .mmu_features =3D MMU_FTR_USE_HIGH_BATS | MM= U_FTR_NEED_DTLB_SW_LRU, > > .icache_bsize =3D 32, > > .dcache_bsize =3D 32, > > - .cpu_setup =3D __setup_cpu_603, > > + .cpu_setup =3D __setup_cpu_g2, > > .machine_check =3D machine_check_83xx, > > .platform =3D "ppc603", > > }, > > @@ -109,7 +109,7 @@ static struct cpu_spec cpu_specs[] __initdata =3D { > > .mmu_features =3D MMU_FTR_USE_HIGH_BATS | MM= U_FTR_NEED_DTLB_SW_LRU, > > .icache_bsize =3D 32, > > .dcache_bsize =3D 32, > > - .cpu_setup =3D __setup_cpu_603, > > + .cpu_setup =3D __setup_cpu_g2, > > .machine_check =3D machine_check_83xx, > > .num_pmcs =3D 4, > > .platform =3D "ppc603", > > @@ -123,7 +123,7 @@ static struct cpu_spec cpu_specs[] __initdata =3D { > > .mmu_features =3D MMU_FTR_USE_HIGH_BATS | MM= U_FTR_NEED_DTLB_SW_LRU, > > .icache_bsize =3D 32, > > .dcache_bsize =3D 32, > > - .cpu_setup =3D __setup_cpu_603, > > + .cpu_setup =3D __setup_cpu_g2, > > .machine_check =3D machine_check_83xx, > > .num_pmcs =3D 4, > > .platform =3D "ppc603", > > -- > > TQ-Systems GmbH | M=C3=BChlstra=C3=9Fe 2, Gut Delling | 82229 Seefeld, = Germany > > Amtsgericht M=C3=BCnchen, HRB 105018 > > Gesch=C3=A4ftsf=C3=BChrer: Detlef Schneider, R=C3=BCdiger Stahl, Stefan= Schneider > > https://www.tq-group.com/ --=20 TQ-Systems GmbH | M=C3=BChlstra=C3=9Fe 2, Gut Delling | 82229 Seefeld, Germ= any Amtsgericht M=C3=BCnchen, HRB 105018 Gesch=C3=A4ftsf=C3=BChrer: Detlef Schneider, R=C3=BCdiger Stahl, Stefan Sch= neider https://www.tq-group.com/