Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp2626813rwa; Mon, 22 Aug 2022 10:40:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR5+IUB4beNCTn/fPeptkf9PXCzMpLgNXl+eIob5mIDGZ/XyJlE2I//kx0U1E2itj0IqBnen X-Received: by 2002:a17:90a:1d0e:b0:1fa:bf2e:a56e with SMTP id c14-20020a17090a1d0e00b001fabf2ea56emr26530017pjd.23.1661190050709; Mon, 22 Aug 2022 10:40:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661190050; cv=none; d=google.com; s=arc-20160816; b=sH9bC0K6rl8SOYkk03/XfRa3He42hxlCyaGWy37WhQVQFtOnF+uNhDpoXTCHx+vsM1 MmVI8XkZJBcDTVZZBAdnbBWEczt3z59h8rqBWOYvaBvkofH0qL7UJqagTwova4bxGkRy kBPMlHvEBfhMaq6YsmwxoZTTcXDrbFaHBswUZy3bpr9IxiaVf8q8t5FAteOXown905p/ QekUXefCOntF5oB1OEdaOCpV1Z/cvHCNmBFjkuWhwF0KxXIjFrTJN1eLeOqiBojtdB1I 52ln9a1Fw16EAVEDSstZIcrWGRv9dAOOAT4+EorKkSetlb+neBFinnAl6nsekLBWVxvX SuGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:content-transfer-encoding :in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date; bh=P7Z6k3A8poRGgY/r2fVngWTDGFg6NAUY66Qf9n627IU=; b=JS0t0CtuM8evQgvyA2Uhqn/wh8V3O+Swn93sNyQiWoOuQbjSsPegzQ2ilkYRjeLfDX /m3atN6rU4DjRqyB4aqCiolQqOsN467m30G+wExX4LUPs7oTX+lwBmdi42wP0h1j03NM Q/zCgok9UGDBWBoLjoZp0XSsAcoMHhy/SjN/JSFZiEB9mtLBB73pkLkqSnQ6D4BUn07y a0dKaSOCn2tcoD+5aWefZGfap2x2DH8LB5HXde5qdxOFg490VDeo07yQlsw8Buxqhp7m Y+/rvaL87YsEG7w7RC30/wYJFnrjklcT91YAZ9fFaLvW8dUZQOqK8vYjbua+IcPL01tm VqvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@iram.es header.s=DKIM header.b=OyMQyYGz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a170903120700b0016ef1d39b5dsi14039104plh.224.2022.08.22.10.40.39; Mon, 22 Aug 2022 10:40:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@iram.es header.s=DKIM header.b=OyMQyYGz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236997AbiHVQ1W (ORCPT + 99 others); Mon, 22 Aug 2022 12:27:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbiHVQ1V (ORCPT ); Mon, 22 Aug 2022 12:27:21 -0400 X-Greylist: delayed 322 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 22 Aug 2022 09:27:18 PDT Received: from mx01.puc.rediris.es (outbound2mad.lav.puc.rediris.es [130.206.19.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBCA640E09 for ; Mon, 22 Aug 2022 09:27:18 -0700 (PDT) Received: from mta-out03.sim.rediris.es (mta-out03.sim.rediris.es [130.206.24.45]) by mx01.puc.rediris.es with ESMTP id 27MGL5av008437-27MGL5ax008437 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 22 Aug 2022 18:21:05 +0200 Received: from mta-out03.sim.rediris.es (localhost.localdomain [127.0.0.1]) by mta-out03.sim.rediris.es (Postfix) with ESMTPS id A76F0302A8C5; Mon, 22 Aug 2022 18:21:05 +0200 (CEST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mta-out03.sim.rediris.es (Postfix) with ESMTP id 932C63049C41; Mon, 22 Aug 2022 18:21:05 +0200 (CEST) X-Amavis-Modified: Mail body modified (using disclaimer) - mta-out03.sim.rediris.es Received: from mta-out03.sim.rediris.es ([127.0.0.1]) by localhost (mta-out03.sim.rediris.es [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id LBajIlpnifdK; Mon, 22 Aug 2022 18:21:05 +0200 (CEST) Received: from lt-gp.iram.es (haproxy02.sim.rediris.es [130.206.24.70]) by mta-out03.sim.rediris.es (Postfix) with ESMTPA id DD52C302A8C5; Mon, 22 Aug 2022 18:21:04 +0200 (CEST) Date: Mon, 22 Aug 2022 18:21:00 +0200 From: Gabriel Paubert To: Pali =?iso-8859-1?Q?Roh=E1r?= Cc: Christophe Leroy , Nick Child , "linux-kernel@vger.kernel.org" , Paul Mackerras , "linuxppc-dev@lists.ozlabs.org" Subject: Re: [PATCH] powerpc: Add support for early debugging via Serial 16550 console Message-ID: References: <20220819211254.22192-1-pali@kernel.org> <20220822153335.v5gc26jfbbqyj3et@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20220822153335.v5gc26jfbbqyj3et@pali> Content-Transfer-Encoding: quoted-printable X-FE-Policy-ID: 23:8:0:SYSTEM DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; d=iram.es; s=DKIM; c=relaxed/relaxed; h=date:from:to:cc:subject:message-id:references:mime-version:content-type; bh=P7Z6k3A8poRGgY/r2fVngWTDGFg6NAUY66Qf9n627IU=; b=OyMQyYGzrjUYNUmcunzhWkDUU5JjJFTOsKqT+SUVtt2g3UnIhxWU+iwHp0FTD8lRwEuEnymDs9vF 8EK3OI7gFDHC36L1qm6HHO4WcA93SesWX2QJvzkglm+3lguFSpQPiQ/+Q62vIoM4/X54Mzo7HMaw lZj1G7AVI8jASBE3EV0QpsKmpXVxys1JksNuF3CyKd2LLcYdMXRpmwQXrcnvKqhd8sYuLbRuhLMi j8N0Ncfrv2sdTd3NWghjMxUBNRu4gF4S03hGWZPLXFxrnpzXwxK0ZoT1WSW3MM3/Tn7tBb+4xRYj YRELdnG9Xm3v9zgH1rh48s36yf1JxyqSDiZGwg== X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 22, 2022 at 05:33:35PM +0200, Pali Roh=E1r wrote: > On Monday 22 August 2022 14:25:57 Christophe Leroy wrote: > > Le 19/08/2022 =E0 23:12, Pali Roh=E1r a =E9crit=A0: > > > Currently powerpc early debugging contains lot of platform specific > > > options, but does not support standard UART / serial 16550 console. > > >=20 > > > Later legacy_serial.c code supports registering UART as early debug= console > > > from device tree but it is not early during booting, but rather lat= er after > > > machine description code finishes. > > >=20 > > > So for real early debugging via UART is current code unsuitable. > > >=20 > > > Add support for new early debugging option CONFIG_PPC_EARLY_DEBUG_1= 6550 > > > which enable Serial 16550 console on address defined by new option > > > CONFIG_PPC_EARLY_DEBUG_16550_PHYSADDR and by stride by option > > > CONFIG_PPC_EARLY_DEBUG_16550_STRIDE. > > >=20 > > > With this change it is possible to debug powerpc machine descriptor= code. > > > For example this early debugging code can print on serial console a= lso > > > "No suitable machine description found" error which is done before > > > legacy_serial.c code. > > >=20 > > > Signed-off-by: Pali Roh=E1r > > > --- > > > Tested on P2020 board. It allowed me do debug and implement this pa= tch series: > > > https://lore.kernel.org/linuxppc-dev/20220819191557.28116-1-pali@ke= rnel.org/ > >=20 > > Build failure if I select it on mpc885_ads_defconfig : > >=20 > > LD vmlinux.o > > MODPOST vmlinux.symvers > > MODINFO modules.builtin.modinfo > > GEN modules.builtin > > CC .vmlinux.export.o > > LD .tmp_vmlinux.kallsyms1 > > powerpc64-linux-ld: arch/powerpc/kernel/udbg.o: in function=20 > > `udbg_early_init': > > /home/chleroy/linux-powerpc/arch/powerpc/kernel/udbg.c:71: undefined=20 > > reference to `udbg_init_debug_16550' > >=20 > >=20 > >=20 > > > --- > > > arch/powerpc/Kconfig.debug | 14 ++++++++++++++ > > > arch/powerpc/include/asm/udbg.h | 1 + > > > arch/powerpc/kernel/udbg.c | 2 ++ > > > arch/powerpc/kernel/udbg_16550.c | 33 +++++++++++++++++++++++++++= +++++ > > > 4 files changed, 50 insertions(+) > > >=20 > > > diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debu= g > > > index 9f363c143d86..a4e7d90a45d2 100644 > > > --- a/arch/powerpc/Kconfig.debug > > > +++ b/arch/powerpc/Kconfig.debug > > > @@ -276,6 +276,11 @@ config PPC_EARLY_DEBUG_OPAL_HVSI > > > Select this to enable early debugging for the PowerNV platform > > > using an "hvsi" console > > > =20 > > > +config PPC_EARLY_DEBUG_16550 > > > + bool "Serial 16550" > > > + help > > > + Select this to enable early debugging via Serial 16550 console > > > + > >=20 > > Putting it before EARLY_DEBUG_MEMCONS means that configs that were=20 > > previously selectiong EARLY_DEBUG_MEMCONS will now select=20 > > EARLY_DEBUG_16550 instead. > >=20 > > Add a dependency to PPC_UDBG_16550 to avoid the build failure I menti= onned ? >=20 > Yea, there is really missing dependency. I will fix it. >=20 > > > config PPC_EARLY_DEBUG_MEMCONS > > > bool "In memory console" > > > help > > > @@ -355,6 +360,15 @@ config PPC_EARLY_DEBUG_CPM_ADDR > > > platform probing is done, all platforms selected must > > > share the same address. > > > =20 > > > +config PPC_EARLY_DEBUG_16550_PHYSADDR > > > + hex "Early debug Serial 16550 physical address" > > > + depends on PPC_EARLY_DEBUG_16550 > >=20 > > A default value is necessary here to avoid prompts during defconfig b= uilds. > >=20 > > > + > > > +config PPC_EARLY_DEBUG_16550_STRIDE > > > + int "Early debug Serial 16550 stride" > > > + depends on PPC_EARLY_DEBUG_16550 > > > + default 1 > > > + > > > config FAIL_IOMMU > > > bool "Fault-injection capability for IOMMU" > > > depends on FAULT_INJECTION > > > diff --git a/arch/powerpc/include/asm/udbg.h b/arch/powerpc/include= /asm/udbg.h > > > index b4aa0d88ce2c..20b5a37ab772 100644 > > > --- a/arch/powerpc/include/asm/udbg.h > > > +++ b/arch/powerpc/include/asm/udbg.h > > > @@ -53,6 +53,7 @@ extern void __init udbg_init_ehv_bc(void); > > > extern void __init udbg_init_ps3gelic(void); > > > extern void __init udbg_init_debug_opal_raw(void); > > > extern void __init udbg_init_debug_opal_hvsi(void); > > > +extern void __init udbg_init_debug_16550(void); > >=20 > > 'extern' keywork is pointless and deprecated for function prototypes,= =20 > > please don't add new ones. >=20 > I used extern keyword to follow existing coding style. In this case it's better to remove existing extern specifications in the surrounding lines. Increasing a bit the footprint of the patch is justified, and does not significantly increase the risk of conflicts with other patches, unlike the gratuitous churn we see sometimes. Gabriel >=20 > > Checkpatch reports: > >=20 > > CHECK: extern prototypes should be avoided in .h files > > #77: FILE: arch/powerpc/include/asm/udbg.h:56: > > +extern void __init udbg_init_debug_16550(void); > >=20 > >=20 > > > =20 > > > #endif /* __KERNEL__ */ > > > #endif /* _ASM_POWERPC_UDBG_H */ > > > diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.= c > > > index b1544b2f6321..92b3fc258d11 100644 > > > --- a/arch/powerpc/kernel/udbg.c > > > +++ b/arch/powerpc/kernel/udbg.c > > > @@ -67,6 +67,8 @@ void __init udbg_early_init(void) > > > udbg_init_debug_opal_raw(); > > > #elif defined(CONFIG_PPC_EARLY_DEBUG_OPAL_HVSI) > > > udbg_init_debug_opal_hvsi(); > > > +#elif defined(CONFIG_PPC_EARLY_DEBUG_16550) > > > + udbg_init_debug_16550(); > > > #endif > > > =20 > > > #ifdef CONFIG_PPC_EARLY_DEBUG > > > diff --git a/arch/powerpc/kernel/udbg_16550.c b/arch/powerpc/kernel= /udbg_16550.c > > > index d3942de254c6..46f2d831d7c9 100644 > > > --- a/arch/powerpc/kernel/udbg_16550.c > > > +++ b/arch/powerpc/kernel/udbg_16550.c > > > @@ -8,6 +8,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > =20 > > > extern u8 real_readb(volatile u8 __iomem *addr); > > > extern void real_writeb(u8 data, volatile u8 __iomem *addr); > > > @@ -335,3 +336,35 @@ void __init udbg_init_debug_microwatt(void) > > > } > > > =20 > > > #endif /* CONFIG_PPC_EARLY_DEBUG_MICROWATT */ > > > + > > > +#ifdef CONFIG_PPC_EARLY_DEBUG_16550 > > > + > > > +static void __iomem *udbg_uart_early_addr; > > > + > > > +void __init udbg_init_debug_16550(void) > > > +{ > > > + udbg_uart_early_addr =3D early_ioremap(CONFIG_PPC_EARLY_DEBUG_165= 50_PHYSADDR, 0x1000); > > > + udbg_uart_init_mmio(udbg_uart_early_addr, CONFIG_PPC_EARLY_DEBUG_= 16550_STRIDE); > > > +} > > > + > > > +static int __init udbg_init_debug_16550_ioremap(void) > > > +{ > > > + void __iomem *addr; > > > + > > > + if (!udbg_uart_early_addr) > > > + return 0; > > > + > > > + addr =3D ioremap(CONFIG_PPC_EARLY_DEBUG_16550_PHYSADDR, 0x1000); > > > + if (WARN_ON(!addr)) > > > + return -ENOMEM; > > > + > > > + udbg_uart_init_mmio(addr, CONFIG_PPC_EARLY_DEBUG_16550_STRIDE); > > > + early_iounmap(udbg_uart_early_addr, 0x1000); > > > + udbg_uart_early_addr =3D NULL; > > > + > > > + return 0; > > > +} > > > + > > > +early_initcall(udbg_init_debug_16550_ioremap); > > > + > > > +#endif /* CONFIG_PPC_EARLY_DEBUG_16550 */