mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michael Zaidman <michael.zaidman@gmail.com>
To: Linus Walleij <linusw@kernel.org>
Cc: jikos@kernel.org, bentiss@kernel.org, brgl@kernel.org,
	germain.hebert@ca.abb.com, rio@r26.me, brunoceg1@gmail.com,
	contact@christina-quast.de, daniel.beer@igorinstitute.com,
	gregkh@linuxfoundation.org, jirislaby@kernel.org,
	linux-serial@vger.kernel.org, linux-input@vger.kernel.org,
	linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 08/13] HID: ft260: uart: add modem pins control via ioctl
Date: Sat, 26 Sep 2026 21:27:09 +0300	[thread overview]
Message-ID: <20260926182712.24576-1-michael.zaidman@gmail.com> (raw)
In-Reply-To: <CAD++jLksAPyfZz6d--n7a1KhPackigEucQJqbYiA-e9S835seA@mail.gmail.com>

Hi Linus,

On Mon, 14 Sep 2026 at 10:57 +0200, Linus Walleij wrote:

> Can't you just patch mctrl to use gpiod_set_array_value_cansleep()
> and gpiod_get_value_cansleep()?
>
> I don't think any of the users depend on call thing this
> in atomic context.

That change is in drivers/tty/serial/serial_mctrl_gpio.c, not in
hid-ft260.c. mctrl_gpio_set() calls gpiod_set_array_value() there, and
both mctrl_gpio_get() and mctrl_gpio_get_outputs() call
gpiod_get_value(). The FT260 gpiochip sets can_sleep, so calling those
three functions from this driver warns until that file uses the
_cansleep variants.

The switch is not only a rename. serial_core.c calls ops->set_mctrl()
under uart_port_lock_irqsave() in uart_update_mctrl(), and
ops->get_mctrl() under uart_port_lock_irq() in uart_tiocmget().
imx_uart_set_mctrl() and atmel_set_mctrl() call mctrl_gpio_set() from
there, and serial8250_do_get_mctrl() calls mctrl_gpio_get() from
there. These callers do run in atomic context, so _cansleep alone
would put a sleeping call under a spinlock with interrupts off. A
sleeping gpiochip also needs the serial core to call set_mctrl and
get_mctrl outside the port lock. I will not put that in the FT260 v2
series.

> > - mctrl_gpio_init() takes a struct uart_port and its IRQ handler
> >   needs it: uart_port_lock_irqsave(), uart_handle_dcd_change(),
> >   port->icount, delta_msr_wait. This UART is a plain tty_driver
> >   with a tty_port, so only mctrl_gpio_init_noauto() is left - and
> >   the FT260 GPIO lines have no interrupts anyway.
>
> I don't understand this :D
> But hopefully the TTY/serial maintainer does.

mctrl_gpio_init() in drivers/tty/serial/serial_mctrl_gpio.c takes a
struct uart_port. Its interrupt handler, mctrl_gpio_irq_handle(), uses
that port for uart_port_lock_irqsave(), uart_handle_dcd_change(),
port->icount and delta_msr_wait.

The FT260 UART is a tty_driver with a tty_port. It has no struct
uart_port, so it cannot call mctrl_gpio_init(). The function it can
call is mctrl_gpio_init_noauto(), which takes a struct device and does
not set up that handler.

The GPIO chip in hid-ft260.c registers no interrupt callback, so there
is no GPIO interrupt for that handler to bind to.

> Using software nodes is the way to go I think,
> <linux/gpio/property.h> contains PROPERTY_ENTRY_GPIO.

You are right. PROPERTY_ENTRY_GPIO has been available in
include/linux/gpio/property.h since v6.2-rc1, and hid-ft260.c does not
use it.

mctrl_gpio_init_noauto() skips a line if the device lacks the
corresponding property, such as cts-gpios. Providing these properties
requires registering a software node using PROPERTY_ENTRY_GPIO. I will
register that node in the patch that switches this driver to the
serial_mctrl_gpio.c helpers, so it is not part of v2 either.

> include "../tty/serial/serial_mctrl_gpio.h"
>
> Otherwise we just bite the bullet and move
> drivers/tty/serial/serial_mctrl_gpio.h
> to
> include/linux/serial_mctrl_gpio.h

That move belongs to the same serial core patches, not to v2. I will
ask Greg to say if he wants the relative include instead.

> > That is a serial subsystem
> > series to agree with Greg and Jiri Slaby, so I propose keeping
> > the ioctl implementation in this series and doing the conversion
> > as a follow-up.
>
> These things have a tendency to never happen and it's
> not like we have a shortage of technical debt.

Fair point, a follow-up can stall. I will send the serial core
RFC as its own thread, after this series is merged, and I ask that it
not gate this series: it changes drivers/tty/serial, and the FT260
UART works without it. If the serial core does not take it, what
stays is ft260_uart_tiocmget() and ft260_uart_tiocmset() in
hid-ft260.c, and nothing in drivers/tty.

Thanks,
Michael

  reply	other threads:[~2026-09-26 18:27 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-22 21:39 [PATCH 00/13] HID: ft260: add UART and GPIO support, plus I2C fixes Michael Zaidman
2026-08-22 21:39 ` [PATCH 01/13] HID: ft260: add serial driver Michael Zaidman
2026-08-25  7:49   ` Linus Walleij
2026-08-25  8:12   ` Linus Walleij
2026-08-27 19:16     ` Michael Zaidman
2026-08-22 21:39 ` [PATCH 02/13] HID: ft260: uart: bring-up fixes Michael Zaidman
2026-08-22 21:39 ` [PATCH 03/13] HID: ft260: add GPIO support on top of UART Michael Zaidman
2026-08-25  7:44   ` Linus Walleij
2026-08-27 20:39     ` Michael Zaidman
2026-08-22 21:39 ` [PATCH 04/13] HID: ft260: i2c: reduce driver module loading time Michael Zaidman
2026-08-22 21:39 ` [PATCH 05/13] HID: ft260: i2c: silence sysfs store big-numbers Michael Zaidman
2026-08-22 21:39 ` [PATCH 06/13] HID: ft260: i2c: reduce bus-error message severity Michael Zaidman
2026-08-22 21:39 ` [PATCH 07/13] HID: ft260: uart: enable flow control Michael Zaidman
2026-08-22 21:39 ` [PATCH 08/13] HID: ft260: uart: add modem pins control via ioctl Michael Zaidman
2026-08-25  8:08   ` Linus Walleij
2026-08-27 22:08     ` Michael Zaidman
2026-09-14  8:57       ` Linus Walleij
2026-09-26 18:27         ` Michael Zaidman [this message]
2026-08-22 21:39 ` [PATCH 09/13] HID: ft260: gpio: group sysfs attrs per HID interface Michael Zaidman
2026-08-25  8:13   ` Linus Walleij
2026-08-27 20:50     ` Michael Zaidman
2026-08-22 21:39 ` [PATCH 10/13] HID: ft260: uart: fix active-low RTS/CTS/DTR/DSR polarity Michael Zaidman
2026-08-25  8:16   ` Linus Walleij
2026-08-27 21:08     ` Michael Zaidman
2026-08-22 21:39 ` [PATCH 11/13] HID: ft260: i2c: fix large write transaction failure Michael Zaidman
2026-08-22 21:39 ` [PATCH 12/13] HID: ft260: workaround for TN_189 errata endpoint STALL after enumeration Michael Zaidman
2026-08-22 21:39 ` [PATCH 13/13] HID: ft260: i2c: abort in-flight transfers with STOP before reset Michael Zaidman
2026-08-25  8:21 ` [PATCH 00/13] HID: ft260: add UART and GPIO support, plus I2C fixes Linus Walleij
2026-08-27 13:27   ` Lee Jones
2026-08-27 18:53     ` Michael Zaidman
2026-08-27 20:51       ` Lee Jones
2026-08-27 22:25         ` Michael Zaidman
2026-09-01 14:02           ` Benjamin Tissoires
2026-09-14  9:27             ` Linus Walleij
2026-09-16 12:58               ` Lee Jones
2026-09-17  8:00                 ` Benjamin Tissoires
2026-09-17 10:04                   ` Lee Jones
2026-09-17 11:07                     ` Benjamin Tissoires
2026-09-26 18:31                       ` Michael Zaidman

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=20260926182712.24576-1-michael.zaidman@gmail.com \
    --to=michael.zaidman@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=brgl@kernel.org \
    --cc=brunoceg1@gmail.com \
    --cc=contact@christina-quast.de \
    --cc=daniel.beer@igorinstitute.com \
    --cc=germain.hebert@ca.abb.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jikos@kernel.org \
    --cc=jirislaby@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=rio@r26.me \
    /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

all inboxes | Powered by JetHome®