From patchwork Wed Jan 31 12:13:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 194733 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1863641dyb; Wed, 31 Jan 2024 04:51:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFC1jOnnnVdnMTS0JQhJEzOEEOFZDxAf/QqGhuYj0KYX/9j7EfepT91+ZqxYF/a4mav6M4T X-Received: by 2002:a05:6358:261c:b0:176:a5c2:8f19 with SMTP id l28-20020a056358261c00b00176a5c28f19mr1465284rwc.30.1706705508993; Wed, 31 Jan 2024 04:51:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706705508; cv=pass; d=google.com; s=arc-20160816; b=QMHc4g7uLELPpU9qtrkNY1G3XtaQuMfH5rHakKRoGp7Ek9ael2S+vtQh8008AI+2GP I5tJ1tcTIaLUxjtulKFagbURegoWD+XQG0I1VsDUxdzmewCmpn+L+m5jG7r6gns0n3xq PGqnArnefFBvfb2MIt9vcmboN7SZcwIYtr1S6ESPIeYm8CptMeJ9uC5BvoHqFDBV4f6N dLtqxUvQ/bIhb6mCZhQ8WWA+pyBoH1zDpokrcO20pawCFUTuh5moGA9MkVjPYIBJw8Lo FHdSx0pjRFTxqgGLtLhDhJ8KvRxCZIRo92N6l+avwJp6elLiU77BMXGHSszcre17mANP u26Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=kS+BpSparmTZFECI8+NrYga88ifeVCqB16dHcwoPHcE=; fh=2uLUxCNWFACUKspdBhTFBOYPk4y3iS6YvuoMaJIb1C4=; b=aoo4UNoU/PHruXAEnf4qqgiQJhbNMQzO5IFZ5JLHt1G2IhWEO2X8UHmQGTnLt1uNrt oMc0lEnE34MCIsnCWS16WsXiMbi7Vb/NNmffvElHHad5CMLO4cvpvE6LxB2h9R1zQhJp HFqIrEGA4CFeSReG5ALCvKEhC6QBp7cXnI2Hpdpm95rPBHVnV4zz2Tbf9o3Hk/0L6pXS 05656FkhF9LCTUfmmDTm5zTeHsce3NCm6uNqsBUwD8ikbM0Z2+aYbpGkbFYWs7xyp2Xb DTEGF6gx3AL2PcF39wO43xRZc8fLgGDdN0YuHGXFzA/hwQ+TeQ7d6z44SvkvX7SqXk2y lfKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f8FcuXl0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-46405-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46405-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVsrCWmPB6xcUgfDB9SEFyomTqDz9ASMFACUw802N0SE/ddqKu8K6SBTEzHLGe0Cjyo5cWFX6cDDfkhaJNBL7IMQJv94Q== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id t20-20020a639554000000b005c6818b5a28si9366754pgn.517.2024.01.31.04.51.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 04:51:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46405-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f8FcuXl0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-46405-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46405-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D4382B27F02 for ; Wed, 31 Jan 2024 12:14:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A21AD7993A; Wed, 31 Jan 2024 12:14:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="f8FcuXl0" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 F1B61768F4; Wed, 31 Jan 2024 12:14:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706703243; cv=none; b=FJOewHZEPpMDuzYdFMWdgyDA7ZE7c5XsXHyW74SXnweZAjXyjxT5rY9/QG6XkY6RIms5HfwgyeY+LX28KWdOfdUPLw43Jbj9WVS0VJgei70jHaORcZmAjDcrxg8ZM65C3wRfTk4np/xPFx8Cp6Zhs5pBmlLmSo08L0Krnm6cYAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706703243; c=relaxed/simple; bh=7PA+jHjuL3dX/U2euxIHOazTkyVPO2EfIlsJ8MWjALE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=nJdlhgSditD7HZlJBx0HL8Vn5t3Gd707vTj94T3PND8pqTwuQdciGR93IpOCjv1NdyPE92TGpVNcMlb+LZFK7z0T+iHkGcLtoXiIoZLks5hcV2L+ttqMZDE68vAD8xcEl8N66C62dRxav9yXOoHNy3DPagzWBgLVY0V+5O+2iS0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f8FcuXl0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F101C433C7; Wed, 31 Jan 2024 12:14:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706703242; bh=7PA+jHjuL3dX/U2euxIHOazTkyVPO2EfIlsJ8MWjALE=; h=From:To:Cc:Subject:Date:From; b=f8FcuXl0L8EkWHgmObVu6ysB+ynvQZF2V/GFvjPb0JvXekn7dzZVNgmswGbQqUeTG 21N6i1yF+3OLJRbNNYwgFbU/Hv+7odV9FxtbRjISNk0sM9kGYgcyrOXtDnZeBOT+Ir tZ+EfItHUxVrewAPa3hToP8md/PXOkrcjboQZytnCeNZgUqUFqPRDGXG7OD/zeYoly RIC8oJizvqH/hauI8tn7kj2DGm+jTCvidG8Kk7sycaTSMRCjSTe9FZ8yKLfcu6bawh zseKpel9RjUl/jEaYGbpwEVRGJMS2u9gHDvjC78ZiiN56w2/fz8/gX8GOG4CiUtA/8 RhihayIhgx8+w== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Emil Kronborg Subject: [PATCH 1/2] serial: core: introduce uart_port_tx_flags() Date: Wed, 31 Jan 2024 13:13:57 +0100 Message-ID: <20240131121359.7855-1-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789608283244248974 X-GMAIL-MSGID: 1789610436049430528 And an enum with a flag: UART_TX_NOSTOP. To NOT call __port->ops->stop_tx() when the circular buffer is empty. mxs-uart needs this (see the next patch). Signed-off-by: Jiri Slaby (SUSE) Cc: Emil Kronborg --- include/linux/serial_core.h | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 536b2581d3e2..edefb6d73604 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -748,8 +748,17 @@ struct uart_driver { void uart_write_wakeup(struct uart_port *port); -#define __uart_port_tx(uport, ch, tx_ready, put_char, tx_done, for_test, \ - for_post) \ +/** + * enum UART_TX_FLAGS -- flags for uart_port_tx_flags() + * + * @UART_TX_NOSTOP: don't call port->ops->stop_tx() on empty buffer + */ +enum UART_TX_FLAGS { + UART_TX_NOSTOP = BIT(0), +}; + +#define __uart_port_tx(uport, ch, flags, tx_ready, put_char, tx_done, \ + for_test, for_post) \ ({ \ struct uart_port *__port = (uport); \ struct circ_buf *xmit = &__port->state->xmit; \ @@ -777,7 +786,7 @@ void uart_write_wakeup(struct uart_port *port); if (pending < WAKEUP_CHARS) { \ uart_write_wakeup(__port); \ \ - if (pending == 0) \ + if (((flags) & UART_TX_NOSTOP) && pending == 0) \ __port->ops->stop_tx(__port); \ } \ \ @@ -812,7 +821,7 @@ void uart_write_wakeup(struct uart_port *port); */ #define uart_port_tx_limited(port, ch, count, tx_ready, put_char, tx_done) ({ \ unsigned int __count = (count); \ - __uart_port_tx(port, ch, tx_ready, put_char, tx_done, __count, \ + __uart_port_tx(port, ch, 0, tx_ready, put_char, tx_done, __count, \ __count--); \ }) @@ -826,8 +835,21 @@ void uart_write_wakeup(struct uart_port *port); * See uart_port_tx_limited() for more details. */ #define uart_port_tx(port, ch, tx_ready, put_char) \ - __uart_port_tx(port, ch, tx_ready, put_char, ({}), true, ({})) + __uart_port_tx(port, ch, 0, tx_ready, put_char, ({}), true, ({})) + +/** + * uart_port_tx_flags -- transmit helper for uart_port with flags + * @port: uart port + * @ch: variable to store a character to be written to the HW + * @flags: %UART_TX_NOSTOP or similar + * @tx_ready: can HW accept more data function + * @put_char: function to write a character + * + * See uart_port_tx_limited() for more details. + */ +#define uart_port_tx_flags(port, ch, flags, tx_ready, put_char) \ + __uart_port_tx(port, ch, flags, tx_ready, put_char, ({}), true, ({})) /* * Baud rate helpers. */