Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp808892pxm; Thu, 3 Mar 2022 05:10:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYIMRkZ4YZCz51vXii8ysJrOXC5YVneTlw3BePSNctiQ+X+VHnv5grK+ih3W1VCscOhrRN X-Received: by 2002:a17:906:1294:b0:6ce:51b:f213 with SMTP id k20-20020a170906129400b006ce051bf213mr26044407ejb.303.1646313023729; Thu, 03 Mar 2022 05:10:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646313023; cv=none; d=google.com; s=arc-20160816; b=duAOOck0VeU2PVpV8kkmU3DFUTYtixHmd07wKH0bA2zxEbBQX9kpjGaWHXyYGzqkvk VkK8AKXQqhiONyosid0zeeX7029U3KkPiawEaV7DQTGMx1np45L2BGNIuSqGIdSbdZ4Q MCPJuzx97g+jgGHF799rW/6gUy4HEPMwt+aIxZ6Q9tLKMx/UkvguVVRtVmhvxhlAp4j6 Sguxs4cqZT7QF5xW3tnB3PP4HISGJ+16A4ytHsmBh72/pSuuIHc77AssPydiINkABMgl WnXSaV3X9lz5gbfR/umt1QZ5QnGrXvlaOW9B2ZD8VpW5zEuZqvNP1HJlkquInvckzNG/ K+ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=em331SWrShLUX8YLSF4ONE3xnXeoFhxPTk7kCdTUTmo=; b=qssEHxUNOBUXnqX9qeKhCsm37KirPeyE0JSj7X/Kt5QCBv4r0gfelSTKr5dAa/bdY4 TuoIGTBW14pFsArzXybsyinTuG2o98LH1jLGIblsff702vpqhb2NzJgDJRFx8dy6Y1ID myUPxBVSEw1QFcfwubhWkIU2aTI9t0ZYxT8awjeTLzF/yuh7Y5PfbtQwwDXkiGLeBEX7 5dyIja3f5xiE4uPJBVrocJgc1gM19TaRYpzMPn3Tmiwvd2Ct8QPHA1/GtQ96un5hsBaH X+KkTKzG1c5TL/0gxbcG9e+NRjKolu1DLqnPYh6lwPhWmKovWUr6okH35xnqS/A4cop5 k75Q== ARC-Authentication-Results: i=1; mx.google.com; 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 ck5-20020a0564021c0500b00412e376acd4si1145046edb.623.2022.03.03.05.09.59; Thu, 03 Mar 2022 05:10:23 -0800 (PST) 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; 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 S231570AbiCCLfC (ORCPT + 99 others); Thu, 3 Mar 2022 06:35:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232866AbiCCLbo (ORCPT ); Thu, 3 Mar 2022 06:31:44 -0500 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C9F2717DBAF; Thu, 3 Mar 2022 03:30:47 -0800 (PST) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 2904692009C; Thu, 3 Mar 2022 12:30:46 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 224A792009B; Thu, 3 Mar 2022 11:30:46 +0000 (GMT) Date: Thu, 3 Mar 2022 11:30:46 +0000 (GMT) From: "Maciej W. Rozycki" To: Paul Cercueil cc: Jiri Slaby , David Laight , =?UTF-8?Q?'Uwe_Kleine-K=C3=B6nig'?= , gregkh@linuxfoundation.org, Alexandre Belloni , Mateusz Holenko , Neil Armstrong , Benjamin Herrenschmidt , Liviu Dudau , Baruch Siach , linux-kernel@vger.kernel.org, Paul Mackerras , Michael Ellerman , Michal Simek , Karol Gugala , Jerome Brunet , Peter Korsgaard , Florian Fainelli , Alexander Shiyan , Krzysztof Kozlowski , Alexandre Torgue , Fabio Estevam , Russell King , Ludovic Desroches , Andy Gross , bcm-kernel-feedback-list@broadcom.com, NXP Linux Team , linux-serial@vger.kernel.org, Vineet Gupta , Orson Zhai , Tobias Klauser , Patrice Chotard , Albert Ou , Maxime Coquelin , Manivannan Sadhasivam , Martin Blumenstingl , Sascha Hauer , Takao Orito , Vladimir Zapolskiy , Lorenzo Pieralisi , Paul Walmsley , Bjorn Andersson , Sudeep Holla , Richard Genoud , Chunyan Zhang , Nicolas Ferre , "David S. Miller" , Taichi Sugaya , Palmer Dabbelt , Pengutronix Kernel Team , Kevin Hilman , Baolin Wang , Shawn Guo , =?UTF-8?Q?Andreas_F=C3=A4rber?= Subject: Re: [PATCH v3] serial: make uart_console_write->putchar()'s character an unsigned char In-Reply-To: Message-ID: References: <20220302072732.1916-1-jslaby@suse.cz> <20220302175242.ejiaf36vszr4xvou@pengutronix.de> <5c7045c1910143e08ced432d938b5825@AcuMS.aculab.com> <84ad3854-28b9-e450-f0a2-f1448f32f137@suse.cz> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,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 Thu, 3 Mar 2022, Paul Cercueil wrote: > > We do have an issue, because we still have this: > > > > void uart_console_write(struct uart_port *port, const char *s, > > unsigned int count, > > void (*putchar)(struct uart_port *, int)) > > > > and then: > > > > putchar(port, *s); > > > > there. Consequently on targets where plain `char' type is signed the > > value retrieved from `*s' has to be truncated in the call to `putchar'. > > And indeed it happens with the MIPS target: > > > > 803ae47c: 82050000 lb a1,0(s0) > > 803ae480: 26100001 addiu s0,s0,1 > > 803ae484: 02402025 move a0,s2 > > 803ae488: 0220f809 jalr s1 > > 803ae48c: 30a500ff andi a1,a1,0xff > > > > vs current code: > > > > 803ae47c: 82050000 lb a1,0(s0) > > 803ae480: 26100001 addiu s0,s0,1 > > 803ae484: 0220f809 jalr s1 > > 803ae488: 02402025 move a0,s2 > > And how is that at all a problem? It wastes an instruction. An instruction wasted here, an instruction wasted there, and suddenly we have grown bloatware. :( > > So I'd recommend changing `s' here to `const unsigned char *' or, as I > > previously suggested, maybe to `const u8 *' even. > > Just cast the string to "const u8 *" within the function, while keeping a > "const char *s" argument. The compiler will then most likely generate LBUs. It does, but, oh dear, it's a "solution" to a problem we have created in the first place. Why do we ever want to have signed characters in the TTY layer, and then to vary between platforms? It's asking for portability issues. Maciej