Improve wwan qcdm compatibility with user-space tools
Subsystems (3)
v3 cover Improve wwan qcdm compatibility with user-space tools
Historically, Qualcomm diagnostic port was a serial device, so user-space tools were developed using tty specific features. One of the most common tool is, for example, ModemManager libqcdm, available at
https://gitlab.freedesktop.org/mobile-broadband/ModemManager
which requires tcgetattr/tcsetattr and the possibility to get exclusive device access to properly work.
The wwan qcdm is not really a tty device, but, besides the lack of tty functions, it behaves as a standard serial Qualcomm diagnostic port, so, as c230035c2f2f ("net: wwan: core: implement terminal ioctls for AT port"), this series add support for terminal ioctls also for qcdm ports and implement the exclusive open mode feature to improve compatibility with user-space tools.
This is an incremental change which should not affect the existing tools using wwan which do not rely on the implemented features.
V2: fixed race condition highlighted by Sashiko at
https://sashiko.dev/#/patchset/20260717081935.2071083-1-dnlplm%40gmail.com
V3: simplified patch 2 according to Loic's comment at
https://lore.kernel.org/netdev/CAFEp6-2UiSja11A6nLKqRX8A1eE=P4euEs+fbpKZxPE8fTX2QQ@mail.gmail.com/#t
Daniele Palmas (2):
net: wwan: add minimalistic IOCTls support also to QCDM port
net: wwan: add exclusive open mode capability to AT and QCDM ports
drivers/net/wwan/wwan_core.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.0
PATCH v3 1/2 net: wwan: add minimalistic IOCTls support also to QCDM port
Upstream libqcdm requires IOCTLs support to work, so add the current AT minimalistic support also to the QCDM port.
--- drivers/net/wwan/wwan_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wwan/wwan_core.c +2 -1
@@ -1046,7 +1046,8 @@ static long wwan_port_fops_ioctl(struct file *filp, unsigned int cmd,struct wwan_port *port = filp->private_data;int res; -if (port->type ==WWAN_PORT_AT ) {/* AT port specific IOCTLs */ +if (port->type ==WWAN_PORT_AT || port->type ==WWAN_PORT_QCDM ) { +/* AT and QCDM port specific IOCTLs */ res =wwan_port_fops_at_ioctl (port, cmd, arg);if (res != -ENOIOCTLCMD )return res;
Signature · 1 line
2.43.0
PATCH v3 2/2 net: wwan: add exclusive open mode capability to AT and QCDM ports
In reply to Daniele PalmasAdd exclusive open mode capability to AT and QCDM ports to improve compatibility with user-space tools using the Qualcomm diagnostic device (e.g. libqcdm).
--- drivers/net/wwan/wwan_core.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/net/wwan/wwan_core.c +24 -0
@@ -42,6 +42,7 @@ static struct dentry *wwan_debugfs_dir;/* WWAN port flags */ #define WWAN_PORT_TX_OFF 0 +#define WWAN_PORT_EXCLUSIVE 1/** * struct wwan_device - The structure that defines a WWAN device
@@ -748,6 +749,12 @@ static int wwan_port_op_start(struct wwan_port *port) goto out_unlock; } +if (test_bit (WWAN_PORT_EXCLUSIVE , &port->flags) && + !capable (CAP_SYS_ADMIN )) { + ret = -EBUSY ; + goto out_unlock; + } +/* If port is already started, don't start again */ if (!port->start_count) ret = port->ops->start (port);
@@ -769,6 +776,7 @@ static void wwan_port_op_stop(struct wwan_port *port)if (port->ops) port->ops->stop (port);skb_queue_purge (&port->rxq); +clear_bit (WWAN_PORT_EXCLUSIVE , &port->flags); }mutex_unlock (&port->ops_lock); }
@@ -1031,6 +1039,22 @@ static long wwan_port_fops_at_ioctl(struct wwan_port *port, unsigned int cmd,break ; } +case TIOCEXCL : +set_bit (WWAN_PORT_EXCLUSIVE , &port->flags); +break ; + +case TIOCNXCL : +clear_bit (WWAN_PORT_EXCLUSIVE , &port->flags); +break ; + +case TIOCGEXCL : + { +int excl =test_bit (WWAN_PORT_EXCLUSIVE , &port->flags); + + ret =put_user (excl, (int __user *)arg); +break ; + } +default : ret = -ENOIOCTLCMD ; }
Signature · 1 line
2.43.0
Re: [PATCH net-next v3 2/2] net: wwan: add exclusive open mode capability to AT and QCDM ports
Quoted 6 lines · Daniele Palmas
Add exclusive open mode capability to AT and QCDM ports to improve compatibility with user-space tools using the Qualcomm diagnostic device (e.g. libqcdm).
Signed-off-by Daniele Palmas <[email protected]>
This looks somewhat fragile in scenarios where a process does not properly release the bit, such as on a crash. That said, it appears to be consistent with the mechanism used by tty, so:
Quoted 63 lines
--- drivers/net/wwan/wwan_core.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)drivers/net/wwan/wwan_core.c +24
-1@@ -42,6 +42,7 @@ static struct dentry *wwan_debugfs_dir;/* WWAN port flags */ #define WWAN_PORT_TX_OFF 0 +#define WWAN_PORT_EXCLUSIVE 1/** * struct wwan_device - The structure that defines a WWAN device @@ -748,6 +749,12 @@ static int wwan_port_op_start(struct wwan_port *port) goto out_unlock; } +if (test_bit (WWAN_PORT_EXCLUSIVE , &port->flags) && + !capable (CAP_SYS_ADMIN )) { + ret = -EBUSY ; + goto out_unlock; + } +/* If port is already started, don't start again */ if (!port->start_count) ret = port->ops->start (port);@@ -769,6 +776,7 @@ static void wwan_port_op_stop(struct wwan_port *port)if (port->ops) port->ops->stop (port);skb_queue_purge (&port->rxq); +clear_bit (WWAN_PORT_EXCLUSIVE , &port->flags); }mutex_unlock (&port->ops_lock); }@@ -1031,6 +1039,22 @@ static long wwan_port_fops_at_ioctl(struct wwan_port *port, unsigned int cmd,break ; } +case TIOCEXCL : +set_bit (WWAN_PORT_EXCLUSIVE , &port->flags); +break ; + +case TIOCNXCL : +clear_bit (WWAN_PORT_EXCLUSIVE , &port->flags); +break ; + +case TIOCGEXCL : + { +int excl =test_bit (WWAN_PORT_EXCLUSIVE , &port->flags); + + ret =put_user (excl, (int __user *)arg); +break ; + } +default : ret = -ENOIOCTLCMD ; } --2.43.0
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 8 lines · On Fri, 24 Jul 2026 16:28:16 +0200 you wrote:
Historically, Qualcomm diagnostic port was a serial device, so user-space tools were developed using tty specific features. One of the most common tool is, for example, ModemManager libqcdm, available at
https://gitlab.freedesktop.org/mobile-broadband/ModemManager
which requires tcgetattr/tcsetattr and the possibility to get exclusive device access to properly work.[...]
Here is the summary with links:
- [net-next,v3,1/2] net: wwan: add minimalistic IOCTls support also to QCDM port
https://git.kernel.org/netdev/net-next/c/4762f405d041 - [net-next,v3,2/2] net: wwan: add exclusive open mode capability to AT and QCDM ports https://git.kernel.org/netdev/net-next/c/1a87048a4c68
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html