[PATCH net-next v2 0/3] net: wwan: support DTR/RTS on AT ports via MHI IP_CTRL

Peter Hunt <[email protected]>
Newsgroups dev.linux.lists.mhi,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-kernel,org.kernel.vger.netdev
Message-ID <[email protected]>
The WWAN character device emulates the TTY modem-control ioctls
(TIOCMGET/TIOCMSET/...) for AT and QCDM ports, but the result is only
stored in port->at_data.mdmbits and never reaches the port driver. A
driver therefore cannot act on the host raising or dropping DTR/RTS.

This matters for Qualcomm/Sierra SDX55/SDX65 MHI modems (e.g. Sierra
EM9291): they withhold unsolicited AT result codes (URCs such as +CREG,
and OMA-DM/LwM2M session indications) on an AT port until the host
asserts DTR, while still answering solicited commands. mhi_wwan_ctrl
exposes the DUN (AT) ports but had no way to signal DTR, so URCs never
reached userspace -- unlike the TTY-based USB and legacy PCIe drivers for
the same hardware, where the TTY layer raises DTR on open.

Patch 1 adds optional ->tiocmget/->tiocmset ops to wwan_port_ops and
wires them into the AT/QCDM ioctl path (drivers without them keep today's
store-only behaviour). Patch 2 enumerates the IP_CTRL channel -- a
standard Qualcomm MHI control channel, not Sierra-specific -- on the
Sierra em919x/em929x config, which is the device tested. Patch 3
implements ->tiocmset in mhi_wwan_ctrl over IP_CTRL, and mirrors TTY
semantics by raising DTR/RTS on open and dropping on close, so existing
userspace (ModemManager, terminal tools) behaves as it does with the
TTY-based stacks.

The IP_CTRL channel is bound by a second mhi_driver inside mhi_wwan_ctrl
with its own callbacks, leaving the AT/QMI/MBIM data path untouched; the
control device for each MHI controller is tracked per-controller so
multiple modems are supported. The consumer is device-agnostic (it binds
purely by channel name), so any Qualcomm modem whose pci_generic config
enumerates IP_CTRL gets DTR support with no driver change.

Note: the series spans two subsystems -- patch 2 touches drivers/bus/mhi
(MHI BUS), patches 1 and 3 touch drivers/net/wwan and include/linux/wwan.h
(WWAN / netdev). Patch 3 depends on patch 1 at build time; patch 2 is
independent (without it, ->tiocmset simply returns -EIO). Suggest taking
the series through net-next with an Ack from the MHI maintainer on patch 2,
but happy to split if the maintainers prefer.

Tested on a Sierra EM9291 (SDX65) over PCIe/MHI: with the series, opening
/dev/wwan0at0 raises DTR and +CREG / +DMI OMA-DM URCs stream, including a
successful LwM2M server registration; without it, no URCs appear.

Changes in v2 (patch 3 only):
- Use __le32 for mhi_dtr_ctrl_msg fields and cpu_to_le32() on assignment
  (Loic Poulain)
- Use guard(mutex) instead of manual lock/unlock in mhi_wwan_ctrl_send_dtr
  (Loic Poulain)
- Return 0 (not -EIO) when IP_CTRL channel is not enumerated so that
  TIOCMSET does not regress for devices without IP_CTRL (Loic Poulain)

v1: https://lore.kernel.org/netdev/[email protected]/

Peter Hunt (3):
  net: wwan: core: propagate modem control signals to port drivers
  bus: mhi: host: pci_generic: enumerate IP_CTRL channel for Sierra
    EM919x/EM929x
  net: wwan: mhi_wwan_ctrl: drive DTR/RTS via the IP_CTRL channel

 drivers/bus/mhi/host/pci_generic.c |   2 +
 drivers/net/wwan/mhi_wwan_ctrl.c   | 183 ++++++++++++++++++++++++++++-
 drivers/net/wwan/wwan_core.c       |  12 +-
 include/linux/wwan.h               |   4 +
 4 files changed, 199 insertions(+), 2 deletions(-)

-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.