From: Lino Sanfilippo <l.sanfilippo@kunbus.com>
To: Lino Sanfilippo <l.sanfilippo@kunbus.com>,
gregkh@linuxfoundation.org, jirislaby@kernel.org,
ilpo.jarvinen@linux.intel.com
Cc: u.kleine-koenig@pengutronix.de, shawnguo@kernel.org,
s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com,
alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
lukas@wunner.de, p.rosenberger@kunbus.com,
stable@vger.kernel.org,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Hugo Villeneuve <hugo@hugovil.com>
Subject: Re: [RESEND PATCH v4 1/7] serial: Do not hold the port lock when setting rx-during-tx GPIO
Date: Wed, 22 Nov 2023 12:55:49 +0100 [thread overview]
Message-ID: <a2b54b76-01ce-4aa2-a00b-e65e123ba7e9@kunbus.com> (raw)
In-Reply-To: <20231119112856.11587-2-l.sanfilippo@kunbus.com>
On 19.11.23 12:28, Lino Sanfilippo wrote:
> Both the imx and stm32 driver set the rx-during-tx GPIO in rs485_config().
> Since this function is called with the port lock held, this can be an
> problem in case that setting the GPIO line can sleep (e.g. if a GPIO
> expander is used which is connected via SPI or I2C).
>
> Avoid this issue by moving the GPIO setting outside of the port lock into
> the serial core and thus making it a generic feature.
>
> Since both setting the term and the rx-during-tx GPIO is done at the same
> code place, move it into a common function.
> - const struct serial_rs485 *rs485)
> +/*
> + * Set optional RS485 GPIOs for bus termination and data reception during
> + * transmission. These GPIOs are controlled by the serial core independently
> + * from the UART driver.
> + */
> +static void uart_set_rs485_gpios(struct uart_port *port,
> + const struct serial_rs485 *rs485)
> {
> if (!(rs485->flags & SER_RS485_ENABLED))
> return;
>
> gpiod_set_value_cansleep(port->rs485_term_gpio,
> !!(rs485->flags & SER_RS485_TERMINATE_BUS));
> + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio,
> + !!(rs485->flags & SER_RS485_RX_DURING_TX));
> }
>
Rasmus is about to add support for another RS485 related GPIO (see
https://lore.kernel.org/all/20231120151056.148450-3-linux@rasmusvillemoes.dk/ )
which has to be configured both before and after port->rs485_config(). This
does not fit very well with the idea of handling all these GPIOs in
one function.
So I would like to revise this patch and send an updated version in a v5
of this series in which the suggestion from Hugo
(see https://lore.kernel.org/all/20231011183656.5111ba32ec0c9d43171662a1@hugovil.com/)
is implemented to use separate functions for the GPIO configurations.
Regards,
Lino
next prev parent reply other threads:[~2023-11-22 11:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-19 11:28 [RESEND PATCH v4 0/7] Fixes and improvements for RS485 (RESEND) Lino Sanfilippo
2023-11-19 11:28 ` [RESEND PATCH v4 1/7] serial: Do not hold the port lock when setting rx-during-tx GPIO Lino Sanfilippo
2023-11-22 11:55 ` Lino Sanfilippo [this message]
2023-11-23 14:17 ` Greg KH
2023-11-19 11:28 ` [RESEND PATCH v4 2/7] serial: core: set missing supported flag for RX during TX GPIO Lino Sanfilippo
2023-11-19 11:28 ` [RESEND PATCH v4 3/7] serial: core: fix sanitizing check for RTS settings Lino Sanfilippo
2023-11-19 11:28 ` [RESEND PATCH v4 4/7] serial: core: make sure RS485 cannot be enabled when it is not supported Lino Sanfilippo
2023-11-19 11:28 ` [RESEND PATCH v4 5/7] serial: core, imx: do not set RS485 enabled if " Lino Sanfilippo
2023-11-19 11:28 ` [RESEND PATCH v4 6/7] serial: omap: do not override settings for RS485 support Lino Sanfilippo
2023-11-19 11:28 ` [RESEND PATCH v4 7/7] serial: 8250_exar: Set missing rs485_supported flag Lino Sanfilippo
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=a2b54b76-01ce-4aa2-a00b-e65e123ba7e9@kunbus.com \
--to=l.sanfilippo@kunbus.com \
--cc=alexandre.torgue@foss.st.com \
--cc=cniedermaier@dh-electronics.com \
--cc=gregkh@linuxfoundation.org \
--cc=hugo@hugovil.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=lukas@wunner.de \
--cc=mcoquelin.stm32@gmail.com \
--cc=p.rosenberger@kunbus.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=stable@vger.kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
/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