From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 21016C38142 for ; Tue, 17 Jan 2023 23:36:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7219F855A9; Wed, 18 Jan 2023 00:36:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 5DE26855BA; Wed, 18 Jan 2023 00:36:16 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id BFE2685531 for ; Wed, 18 Jan 2023 00:36:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=andre.przywara@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3404114BF; Tue, 17 Jan 2023 15:36:55 -0800 (PST) Received: from slackpad.lan (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 25CCF3F67D; Tue, 17 Jan 2023 15:36:11 -0800 (PST) Date: Tue, 17 Jan 2023 23:34:04 +0000 From: Andre Przywara To: Tom Rini Cc: u-boot@lists.denx.de, Simon Glass , Sergei Antonov , Quentin Schulz Subject: Re: [PATCHv2 05/19] dm: ns16550: Restore how we define UART_REG Message-ID: <20230117233404.20913d18@slackpad.lan> In-Reply-To: <20230117221050.630746-1-trini@konsulko.com> References: <20230110161946.3816866-5-trini@konsulko.com> <20230117221050.630746-1-trini@konsulko.com> Organization: Arm Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.31; x86_64-slackware-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On Tue, 17 Jan 2023 17:10:50 -0500 Tom Rini wrote: > Prior to commit 9591b63531fa ("Convert CONFIG_SYS_NS16550_MEM32 et al to > Kconfig") we had defined CONFIG_SYS_NS16550_REG_SIZE to -1 with > DM_SERIAL such that we would then have a size 0 character array. This > resulted in functionally no padding. The confusion on my part came from > dealing with the constraints around platforms that do not use DM_SERIAL > in SPL/TPL. After Andre Przywara reported that sunxi was broken, I've > re-read the code and comments again and thought on this harder. What we > want I believe is what this patch does now. > > If DM_SERIAL is defined for this stage, regardless of > CONFIG_SYS_NS16550_REG_SIZE then we will dynamically handle reg shifts > and 'struct ns16550' needs no padding (which is functionally what > unsigned char foo[0] provides). This is the same case as NS16550_DYNAMIC > and DEBUG_UART. Expand the existing comment here slightly. > > Otherwise, we will have CONFIG_SYS_NS16550_REG_SIZE set to a non-zero > value, and handle padding within the struct. > > Cc: Simon Glass > Cc: Sergei Antonov > Cc: Quentin Schulz > Cc: Andre Przywara > Fixes: 9591b63531fa ("Convert CONFIG_SYS_NS16550_MEM32 et al to Kconfig") > Signed-off-by: Tom Rini Thanks, that indeed fixes the issue for me, booted on LicheePi Nano and Pine64-LTS: Reviewed-by: Andre Przywara Tested-by: Andre Przywara Cheers, Andre > --- > include/ns16550.h | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/include/ns16550.h b/include/ns16550.h > index 243226fc3d94..e7e68663d030 100644 > --- a/include/ns16550.h > +++ b/include/ns16550.h > @@ -26,15 +26,13 @@ > > #include > > -#if CONFIG_IS_ENABLED(DM_SERIAL) && !defined(CONFIG_SYS_NS16550_REG_SIZE) > +#if CONFIG_IS_ENABLED(DM_SERIAL) || defined(CONFIG_NS16550_DYNAMIC) || \ > + defined(CONFIG_DEBUG_UART) > /* > * For driver model we always use one byte per register, and sort out the > - * differences in the driver > + * differences in the driver. In the case of CONFIG_NS16550_DYNAMIC we do > + * similar, and CONFIG_DEBUG_UART is responsible for shifts in its own manner. > */ > -#define CONFIG_SYS_NS16550_REG_SIZE (-1) > -#endif > - > -#if defined(CONFIG_NS16550_DYNAMIC) || defined(CONFIG_DEBUG_UART) > #define UART_REG(x) unsigned char x > #else > #if !defined(CONFIG_SYS_NS16550_REG_SIZE) || (CONFIG_SYS_NS16550_REG_SIZE == 0)