From: Greg KH <gregkh@linuxfoundation.org>
To: Jiri Slaby <jslaby@suse.cz>
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/3] tty: serial: introduce transmit helper generators
Date: Thu, 1 Sep 2022 14:25:14 +0200 [thread overview]
Message-ID: <YxCkqmz32qMAZAPh@kroah.com> (raw)
In-Reply-To: <20220901110657.3305-2-jslaby@suse.cz>
On Thu, Sep 01, 2022 at 01:06:55PM +0200, Jiri Slaby wrote:
> Many serial drivers do the same thing:
> * send x_char if set
> * keep sending from the xmit circular buffer until either
> - the loop reaches the end of the xmit buffer
> - TX is stopped
> - HW fifo is full
> * check for pending characters and:
> - wake up tty writers to fill for more data into xmit buffer
> - stop TX if there is nothing in the xmit buffer
>
> The only differences are:
> * how to write the character to the HW fifo
> * the check of the end condition:
> - is the HW fifo full?
> - is limit of the written characters reached?
>
> So unify the above into two helper generators:
> * DEFINE_UART_PORT_TX_HELPER_LIMITED() -- it performs the above taking
> the written characters limit into account, and
> * DEFINE_UART_PORT_TX_HELPER() -- the same as above, except it only
> checks the HW readiness, not the characters limit.
>
> The HW specific operations (as stated as "differences" above) are passed
> as arguments to the macros. They are:
> * tx_ready() -- returns true if HW can accept more data.
> * put_char() -- write a character to the device.
> * tx_done() -- when the write loop is done, perform arbitrary action
> before potential invocation of ops->stop_tx() happens.
>
> Note that the above macros are generators. This means the code is
> generated in place and the above 3 arguments are "inlined". I.e. no
> added penalty by generating call instructions for every single
> character. Nor any indirect calls. (As in previous versions of this
> patchset.)
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> ---
>
> Notes:
> [v2] instead of a function (uart_port_tx_limit()) in serial_core,
> generate these in-place using macros. Thus eliminating "call"
> penalty.
Much nicer, but:
> +#define __DEFINE_UART_PORT_TX_HELPER(name, port, ch, tx_ready, put_char, \
> + tx_done, for_test, for_post, ...) \
Do you really need "port" and "ch" as part of this macro? You always
set that to the same thing in your patches, so is it really needed?
thanks,
greg k-h
next prev parent reply other threads:[~2022-09-01 12:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-01 11:06 [PATCH v2 0/3] tty: TX helpers Jiri Slaby
2022-09-01 11:06 ` [PATCH v2 1/3] tty: serial: introduce transmit helper generators Jiri Slaby
2022-09-01 12:25 ` Greg KH [this message]
2022-09-02 5:16 ` Jiri Slaby
2022-09-02 5:23 ` Greg KH
2022-09-02 8:02 ` Jiri Slaby
2022-09-02 10:22 ` Ilpo Järvinen
2022-09-02 10:24 ` Jiri Slaby
2022-09-01 11:06 ` [PATCH v2 2/3] tty: serial: use DEFINE_UART_PORT_TX_HELPER() Jiri Slaby
2022-09-02 14:21 ` Ilpo Järvinen
2022-09-06 10:50 ` Jiri Slaby
2022-09-01 11:06 ` [PATCH v2 3/3] tty: serial: use DEFINE_UART_PORT_TX_HELPER_LIMITED() Jiri Slaby
2022-09-02 14:56 ` Ilpo Järvinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YxCkqmz32qMAZAPh@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox