Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5537478pxb; Wed, 26 Jan 2022 14:27:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNv9ulz4JB7V6bAPjaHOyVD+/E5NGH43Sk3/ZVzEcIEQmSKVO5l7a0XeFYIQuOiypI3fhk X-Received: by 2002:a50:ed8e:: with SMTP id h14mr1027858edr.398.1643236046261; Wed, 26 Jan 2022 14:27:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643236046; cv=none; d=google.com; s=arc-20160816; b=tgciMa/mc0mN8XPHL/j4qsThItvOM5epRV66onystSsQTDX0sYFHjHqaX53QF1VnIc LOyqt0i+TlrO02xeEms+fm3Ya2cDN/4eIj5EXajbrz7e82Q8GwWbb4mfnu+jBDbaxUTH N1lkzmJcGR6PdVFgOZYtaOOEyPlhzzfkzjZ0LpnNGStJZd6bOfIu6p3Y5GcRI/JNK5bi dczlFe8a3Na8E9uGgghb2Xk9MnZJ1KfR+X2xhaSUvewYr6KI5g3biJ1e2qqMrmC3HHA6 +3BdRhykW+v1/wDdjvJYal8UFiOutSvcywtWBLsJMeVDH/DWBtMX8B/gmcplhzggm6o8 g4WQ== 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=L5lo3SoXQwd1HOO/JXVu6IwsMdm4BPmGrNG7Zu6NPa0=; b=eetsvmA4N0bO7bLPFa5KCN+acocggffKjwdQi11NrVUx708l9sZkLrFMfhGpKPYFOp 2YF9eVTojWsfS93XMO/1NoWzv0bephPzX0HIhkfB+B6u8HTHWw4bgOIk06CzW1BU6QwN zZZhq7NTgBoF2gqji9wYSotqRez1v6yC2vRAosCJB/A3uQ6yjdAAmQeoHvI64FN1aTA7 MGYf3cw1VzNFj9wBuqr+1ogr2w7EEBByrRDdRqLtJ1H0/u7CGTfgGy42sWAOQEMDiNIk ZBfZYy1ciC+zT0VjMUuwNiwxEfHztvoaRHFKwlU0hWNgvFLziPML2BGqbpMHcuTIAr7x /8VQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gm1si304899ejc.549.2022.01.26.14.27.00; Wed, 26 Jan 2022 14:27:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237400AbiAZR5b (ORCPT + 99 others); Wed, 26 Jan 2022 12:57:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244063AbiAZR5R (ORCPT ); Wed, 26 Jan 2022 12:57:17 -0500 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B4572C06161C for ; Wed, 26 Jan 2022 09:57:16 -0800 (PST) Received: by angie.orcam.me.uk (Postfix, from userid 500) id BD0C392009C; Wed, 26 Jan 2022 18:57:13 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id B869E92009B; Wed, 26 Jan 2022 17:57:13 +0000 (GMT) Date: Wed, 26 Jan 2022 17:57:13 +0000 (GMT) From: "Maciej W. Rozycki" To: Jiri Slaby cc: Greg Kroah-Hartman , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, johan@kernel.org, Paul Cercueil , Tobias Klauser , Russell King , Vineet Gupta , Richard Genoud , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , Florian Fainelli , Alexander Shiyan , Baruch Siach , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Karol Gugala , Mateusz Holenko , Vladimir Zapolskiy , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Taichi Sugaya , Takao Orito , Liviu Dudau , Sudeep Holla , Lorenzo Pieralisi , =?UTF-8?Q?Andreas_F=C3=A4rber?= , Manivannan Sadhasivam , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Andy Gross , Bjorn Andersson , Krzysztof Kozlowski , Orson Zhai , Baolin Wang , Chunyan Zhang , Patrice Chotard , Maxime Coquelin , Alexandre Torgue , "David S. Miller" , Peter Korsgaard , Michal Simek Subject: Re: [PATCH 10/11] serial: make uart_console_write->putchar()'s character a char In-Reply-To: <20220124071430.14907-11-jslaby@suse.cz> Message-ID: References: <20220124071430.14907-1-jslaby@suse.cz> <20220124071430.14907-11-jslaby@suse.cz> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 24 Jan 2022, Jiri Slaby wrote: > diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c > index e9edabc5a211..3493e201d67f 100644 > --- a/drivers/tty/serial/dz.c > +++ b/drivers/tty/serial/dz.c > @@ -802,7 +802,7 @@ static void __init dz_init_ports(void) > * restored. Welcome to the world of PDP-11! > * ------------------------------------------------------------------- > */ > -static void dz_console_putchar(struct uart_port *uport, int ch) > +static void dz_console_putchar(struct uart_port *uport, char ch) > { > struct dz_port *dport = to_dport(uport); > unsigned long flags; Hmm, this is unsafe, because on the MIPS target the lone `char' type is signed and therefore a call to `->putchar' will see `ch' sign-extended from bit #7 to the width of the argument register used. Which means that if a character is sent to the console that has its bit #7 set, then the call to: dz_out(dport, DZ_TDR, ch); i.e.: static void dz_out(struct dz_port *dport, unsigned offset, u16 value) will send a value to DZ_TDR with bits #15:8 set to all-ones. And bits #11:8 there are the BREAK control bits, active high, for serial lines #3:0 respectively. We could handle this with a preparatory change by calling: dz_out(dport, DZ_TDR, ch & 0xffu); instead, but perhaps `->putchar' should simply take `unsigned char' or maybe even `u8' as its third argument? > diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h > index c58cc142d23f..68e62703eaa6 100644 > --- a/include/linux/serial_core.h > +++ b/include/linux/serial_core.h > @@ -399,7 +399,7 @@ int uart_set_options(struct uart_port *port, struct console > *co, int baud, > struct tty_driver *uart_console_device(struct console *co, int *index); > void uart_console_write(struct uart_port *port, const char *s, > unsigned int count, > - void (*putchar)(struct uart_port *, int)); > + void (*putchar)(struct uart_port *, char)); > > /* > * Port/driver registration/removal I.e.: void (*putchar)(struct uart_port *, unsigned char)); I can see we get it right already with: unsigned char x_char; /* xon/xoff char */ and for `dz_transmit_chars' we have: unsigned char tmp; [...] tmp = xmit->buf[xmit->tail]; xmit->tail = (xmit->tail + 1) & (DZ_XMIT_SIZE - 1); dz_out(dport, DZ_TDR, tmp); (because `struct circ_buf' is generic and not limited to unsigned buffer contents interpretation; it's not clear to me if that has been intended though). Maciej