From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm2-f12.google.com (mail-wm2-f12.google.com [74.125.225.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5662137475D for ; Sat, 26 Sep 2026 18:27:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.140 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790447244; cv=none; b=PYVykwi8SdOJuBqLZ0UKpD8KrL+26ihhrgY3IJmLY7SY94JrhJMNXpVSrftZTD7yxLg/7h4QilKNIKVOURu1gEuwMjZJMEi+F84MkEhtwLsZreTsFrM3np1+Kld04hJHE0aJyXpCb+G+FqziBHa2lA5i+Z4hA3M9qC8MP7L3tNc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790447244; c=relaxed/simple; bh=qzwNqOoq5gIEteD6ff9IatsKKQaGCWKJS6LMm1QwduY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z8O+mPZQNiKZGatUh2vlIUG1SOxhfJ2qee7fwdnqFYxoBEk3cdfabGg1TEeyrLpaCCn4yiaFewdXEaT+aFqMzND3mDeKd0c8QTfTbZjTEiVHQmGxAQUY2Tzf5Cj57qBRsVeqvty+zVYWN1MjWDXOy12HqX8UsmZ87PLs3U8KLm8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=pr9e0W8B; arc=none smtp.client-ip=74.125.225.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pr9e0W8B" Received: by mail-wm2-f12.google.com with SMTP id 5b1f17b1804b1-49ccf3ca626so10558585e9.0 for ; Sat, 26 Sep 2026 11:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790447240; x=1791052040; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=6zdetyxBKfTailvjdRzmjKkVNkh5L3fgaPZNlolghpE=; b=pr9e0W8BwBr+4bE4dLBrjXu491trlOXwULzGbiRhh/qygDhLJEC54qeUjBs2W2n6Aw UkLtVWVPfeZkYRjU+C1/s116TY25w8IO5AwD6WJsJMKd/e5WY1DPlWAPkVKpZo48idgL BLdCgX1hDaMJSh9X7nYO5ddVmod0BJc/cXyv10n1ZMaMIgMEnHtkaalociCKn3tP2j9I iEQW6DtA1+xMmAt0SlhXmqSb9wIaWZ7luTGM+LdW1DAcpV/meY2ZSBqsSt28G9PuHvUt 1P4NkI7+pomYFdIZ5+O2KUwiUvnYLunvjvyyrE2ipRahtuCAmZ4R7TcU0Mb+7EZiDKrO 251w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790447240; x=1791052040; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=6zdetyxBKfTailvjdRzmjKkVNkh5L3fgaPZNlolghpE=; b=BnyXlHTGE2ZfTKvM50nMjiuUTb3/YfQy7l/V0JeFTOzu789IW3TQBoEvKzzfkY12Te 6MahyLQeQIxF1jsleEWj1o0U15qJgIPO0Z3LicQ1W/5Y+0tGHf8txvO5Wpd/YTnevUcH V9vvjf3L74JGuJO+YuVw1gvGsjvNecp1LDrNRjaXuLVr+xYTHTM+VVSmtZY96whF67ik cp47PRV/6yizMcuDVXDAM3HfS8E3t3VOODAYaUbUuthMKL3VCIoIimQLFsPiSX9aqUrC pJFnt0izBB8+pWDF734KRvhoawIskUY4p5MYFLIVsojgR0pW8GHaiE2ju+UOjlkxNWGp oLow== X-Forwarded-Encrypted: i=1; AKwUvBzX0f4Q2ClUZPdRQHXL8hlO4W6cU62DTBN3713CqT5PTLc9G8dsczFBF23RjZhttQqNdRjzi6BQ2NQW@vger.kernel.org X-Gm-Message-State: AFuF++laf7bt1x67rO0F8XG7xzHTpmZJTnQ/+LPtzjW1nxY1AE7wTSQ5 SKCyeKRnOwZKv9oBroaIDoLLxu/eexYtLOgxr1MIlpo/X9z7XFZ5gO1W X-Gm-Gg: AYBFou1X99cSAfHJFkEaRzowffVWkmwN2YBLMR0HcEkSeT90/8r7eJDHI9O5f3CeO5Y hLDqIoSRbPLaKRtypVIwo/qBqFybdsTuZ8e06NPnxQ3c8SC0gwFa81w0yAz4BPcKzUYRMpArsF/ KGcyIoXFXNKG1Fq9a3I3YBwU794Nx6LnkiPAdwssV811irdl3e8k0rQ2GXC74UoYEfy9qc4qz7J R/aXHDUU0Uiw+ZV+965GY2kirqYRQGPPwg2tyKDM5rPdBhMqu1Ts7ZCG7SwvpSpvNNzfuhodaym Bx8sEFxeMVL83Vlon6kvWevu+dB+ZnKkijpXzyHhiBil4NkZ+KDShGPaevs0H1mMv7lKk4uv8pw i3yjz8P0xc+3Oh6TL/POoyCwGjOLx2FHbO/fzPwm5B02llwvW7RiB/CkTaqIbQgb5IV/hIh+fmh 2GvoPgSaSNz2uk/WLCjfPZaRbvFtEsgxZUVL8yNEvU9u5JZ8/DhXEcK3DmlJ5WM/L41dqKWmoHW 43AUEYq X-Received: by 2002:a05:600c:138f:b0:49f:cbf3:551c with SMTP id 5b1f17b1804b1-49fe66cc5camr155431025e9.12.1790447240357; Sat, 26 Sep 2026 11:27:20 -0700 (PDT) Received: from m2.. ([37.142.154.181]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4a000901b07sm11834725e9.9.2026.09.26.11.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Sep 2026 11:27:19 -0700 (PDT) From: Michael Zaidman To: Linus Walleij 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 Message-ID: <20260926182712.24576-1-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: <20260827220805.23112-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, > 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