aboutsummaryrefslogtreecommitdiff
path: root/src/mm-device.c
AgeCommit message (Collapse)Author
2023-09-27device: plug leak of the physdev stringAleksander Morgado
2023-09-18api,modem: new 'Physdev' propertyLukas Voegl
Signed-off-by: Lukas Voegl <lvoegl@tdt.de>
2022-11-04core,log: new 'MSG' log level between 'INFO' and 'WARN'Aleksander Morgado
We're bumping the current "INFO" level messages to the new "MSG" level, also making the new level the default. The old "INFO" level will be used to setup an intermediate level of logging which is not as verbose as "DEBUG" but still provides some capabilities to analyze the behavior of a modem.
2022-08-11bearer-mbim: enable multiplex support for wwan devicesDaniele Palmas
2022-05-24base-modem: add subsystem vendor ID propertyDaniele Palmas
Subsystem vendor ID can be used for identifying PCI modems, so expose the property.
2021-04-30core: strict return type in g_object_ref()Aleksander Morgado
This is now a requirement when using glib 2.56.
2021-03-10base-modem: allow grabbing link ports after modem is createdAleksander Morgado
We will grab the ports and make them available through find_ports() or peek_port() or get_port(). The link ports are not 'organized' so they won't be available in e.g. get_data_ports(), which is fine, because we don't want to mix them with the real data ports exposed by the device. Link port additions and removals are also notified via signals in the modem object, so that explicit wait for specific ports can be done.
2021-02-14device: avoid trying to remove source multiple timesAleksander Morgado
ModemManager[115879]: <debug> [1613341789.760031] [modem3] completely disposed (ModemManager:115879): GLib-CRITICAL **: 23:29:49.760: Source ID 2379 was not found when attempting to remove it Thread 1 "ModemManager" received signal SIGTRAP, Trace/breakpoint trap. 0x00007ffff774b343 in g_logv () from /usr/lib/libglib-2.0.so.0 (gdb) (gdb) bt #0 0x00007ffff774b343 in g_logv () at /usr/lib/libglib-2.0.so.0 #1 0x00007ffff774b5c0 in g_log () at /usr/lib/libglib-2.0.so.0 #2 0x00007ffff7741c9e in g_source_remove () at /usr/lib/libglib-2.0.so.0 #3 0x00005555555aad02 in dispose (object=0x555555831260) at mm-device.c:802 #4 0x00007ffff7843755 in g_object_unref () at /usr/lib/libgobject-2.0.so.0 #5 0x00005555555a5107 in glib_autoptr_clear_MMDevice (_ptr=0x555555831260) at mm-device.h:63 #6 0x00005555555a5125 in glib_autoptr_cleanup_MMDevice (_ptr=0x7fffffffe090) at mm-device.h:63 #7 0x00005555555a59ab in device_removed (self=0x555555769220, subsystem=0x55555577dc50 "tty", name=0x555555869a40 "ttyUSB3") at mm-base-manager.c:237 #8 0x00005555555a620d in handle_uevent (self=0x555555769220, action=0x5555558987b0 "remove", device=0x555555893840) at mm-base-manager.c:445 #9 0x00007ffff7381acd in () at /usr/lib/libffi.so.7 #10 0x00007ffff738103a in () at /usr/lib/libffi.so.7 #11 0x00007ffff783c8fe in g_cclosure_marshal_generic () at /usr/lib/libgobject-2.0.so.0 #12 0x00007ffff7837072 in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0 #13 0x00007ffff785fa85 in () at /usr/lib/libgobject-2.0.so.0 #14 0x00007ffff78535dd in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0 #15 0x00007ffff7853b40 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0 #16 0x00007ffff7e792aa in () at /usr/lib/libgudev-1.0.so.0 #17 0x00007ffff7742b84 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0 #18 0x00007ffff7796c21 in () at /usr/lib/libglib-2.0.so.0 #19 0x00007ffff77420d3 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0 #20 0x00005555555a1df4 in main (argc=2, argv=0x7fffffffea88) at main.c:213
2020-11-26base-sim: Reprobe modem if lock status cannot be read after sending pukPavan Holla
If the lock status cannot be read during a puk unblock attempt, reprobe the modem. It is likely that the SIM was permanently blocked if the lock status cannot be read.
2020-11-19base-manager: never create kernel device objects for remove eventsAleksander Morgado
There is no point in creating a new kernel device object just to process a remove event; instead, do any matching with existing kernel device objects by subsystem and name, which is what the generic backend already did anyway. This avoids unnecessary lookup of information in sysfs during removal events, because the port is anyway already gone when we try to look those up.
2020-04-08device: port to use object loggingAleksander Morgado
2020-04-08base-modem: set dbus id as soon as object is createdAleksander Morgado
2020-01-06device: don't reprobe if device is goneAleksander Morgado
When a QMI/MBIM device is unplugged, we first get the notification from the proxy that the communication is broken, and then we get the kernel event reporting that the cdc-wdm port is gone. If we reprobe the device as soon as the proxy notifies us that the communication is broken, we would end up trying to reprobe the cdc-wdm port when it's already gone, and we end up trying to create a modem object when we shouldn't: <debug> [1577963152.429386] (ttyUSB0) unexpected port hangup! <debug> [1577963152.429506] (ttyUSB0) forced to close port <debug> [1577963152.429546] (ttyUSB0) device open count is 0 (close) <debug> [1577963152.429582] (ttyUSB0) closing serial port... <debug> [1577963152.429653] (ttyUSB0) serial port closed <debug> [1577963152.430340] (ttyUSB2) unexpected port hangup! <debug> [1577963152.430391] (ttyUSB2) forced to close port <debug> [1577963152.430418] (ttyUSB2) device open count is 0 (close) <debug> [1577963152.430451] (ttyUSB2) closing serial port... <debug> [1577963152.430517] (ttyUSB2) serial port closed <info> [1577963152.436932] (tty/ttyUSB0): released by device '/sys/devices/pci0000:00/0000:00:14.0/usb2/2-3' <info> [1577963152.439176] (tty/ttyUSB1): released by device '/sys/devices/pci0000:00/0000:00:14.0/usb2/2-3' <info> [1577963152.440409] (tty/ttyUSB2): released by device '/sys/devices/pci0000:00/0000:00:14.0/usb2/2-3' <info> [1577963152.447977] (net/wwan1): released by device '/sys/devices/pci0000:00/0000:00:14.0/usb2/2-3' Cannot read from istream: connection broken <info> [1577963152.458878] Connection to qmi-proxy for /dev/cdc-wdm1 lost, reprobing <debug> [1577963152.459144] [device /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3] unexported modem from path '/org/freedesktop/ModemManager1/Modem/1' <debug> [1577963152.460151] (ttyUSB1) forced to close port <info> [1577963152.460182] [device /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3] creating modem with plugin 'Sierra' and '1' ports <debug> [1577963152.460199] QMI-powered Sierra modem found... <debug> [1577963152.460382] (cdc-wdm1) type 'qmi' claimed by /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3 <debug> [1577963152.460417] Modem (Sierra) '/sys/devices/pci0000:00/0000:00:14.0/usb2/2-3' completely disposed <warn> [1577963152.460431] Could not recreate modem for device '/sys/devices/pci0000:00/0000:00:14.0/usb2/2-3': Failed to find a net port in the QMI modem <debug> [1577963152.460526] Modem (Sierra) '/sys/devices/pci0000:00/0000:00:14.0/usb2/2-3' completely disposed <info> [1577963152.460627] (usbmisc/cdc-wdm1): released by device '/sys/devices/pci0000:00/0000:00:14.0/usb2/2-3' <debug> [1577963152.460666] Removing empty device '/sys/devices/pci0000:00/0000:00:14.0/usb2/2-3' Fix this by delaying the reprobing attempt some time, and make sure we cancel the reprobing if the device detects that all ports are gone.
2020-01-06device: keep reference to object manager serverAleksander Morgado
Instead of having the reference to the object manager server only while the modem is exported, just keep a reference for as long as the device object exists. This will make it easier to handle reprobing logic.
2019-01-03api,manager: new InhibitDevice() methodAleksander Morgado
This new method allows users of the ModemManager API to take full control of a given device. Unlike other operations in the API, the inhibition is maintained as long as the caller exists in the bus, or until the same caller uninhibits the device. https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/98
2017-06-23core: use g_list_copy_deep for deep copying a GListBen Chan
2017-03-29core: reset GList pointers to NULL when necessaryBen Chan
When calling g_list_free_full() to free a GList in dispose(), it is necessary to reset the GList pointer to NULL as dispose() may be called more than once.
2017-03-29core: remove explicit GDestroyNotify cast on g_free / g_object_unrefBen Chan
g_free and g_object_unref are in form of `void (*)(gpointer)`, which matches the GDestroyNotify signature. An explicit GDestroyNotify cast on g_free and g_object_unref is thus not needed.
2017-03-03device: add null check on `self->priv->modem' in clear_modemBen Chan
clear_modem() can be invoked from set_property() and dispose(), where `self->priv->modem' may be NULL. This patch adds a null check on the modem object to make sure we don't run g_object_run_dispose() on a null modem object.
2017-02-13device: disconnect signal handlers when modem object removedAleksander Morgado
Don't rely on the automatic disconnection of the signal as the last reference of the modem object may outlive the device object. Also, setup a common clear_modem() function to dispose the internal reference of the modem object, which will take care of the signal disconnection when required. https://lists.freedesktop.org/archives/modemmanager-devel/2017-February/003907.html
2016-12-20device: fixed crash in SIM hot swap when removing the SIMCarlo Lobrano
mm_device_create_modem needs a valid object_manager instance to create the new modem, while the one provided before was cleared out by a call to mm_device_remove_modem few lines before. Since the newly created modem refers to the same HW device, we can use the same object_manager also. https://bugs.freedesktop.org/show_bug.cgi?id=99160
2016-09-29core: new kernel device object instead of an explicit GUdevDeviceAleksander Morgado
Instead of relying constantly on GUdevDevice objects reported by GUdev, we now use a new generic object (MMKernelDevice) for which we provide an initial GUdev based backend.
2016-09-29core: allow identifying devices by a user-provided 'uid'Aleksander Morgado
All ports of the same modem reported by the kernel will all be associated with a common 'uid' (unique id), which uniquely identifies the physical device. This logic was already in place, what we do now is avoid calling it the 'sysfs path' of the physical device, because we may not want to use that to identify a device. This logic now also enables the possibility of "naming" the modems in a unique way by setting the "ID_MM_PHYSDEV_UID" property in the "usb_device" that owns all the ports. E.g. a custom device has 4 modems in 4 different USB ports. The device path of each USB device will always be the same, so the naming rules could go like this: $ vim /usr/lib/udev/rules.d/78-mm-naming.rules ACTION!="add|change|move", GOTO="mm_naming_rules_end" DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.1", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-1" DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.2", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-2" DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.3", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-3" DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.4", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-4" LABEL="mm_naming_rules_end" Each of the modems found will have a unique UID retrieved from the previous list of rules. Then, "mmcli" has also been updated to allow using the UID instead of the modem DBus path or index, e.g.: $ sudo mmcli -m USB-MODEM-1 /org/freedesktop/ModemManager1/Modem/0 (device id '988d83252c0598f670c2d69d5f41e077204a92fd') ------------------------- Hardware | manufacturer: 'ZTE CORPORATION' | model: 'MF637' | revision: 'BD_W7P673A3F3V1.0.0B04' | supported: 'gsm-umts' | current: 'gsm-umts' | equipment id: '356516027657837' ------------------------- System | device: 'USB-MODEM-1' | drivers: 'option' | plugin: 'ZTE' | primary port: 'ttyUSB5' | ports: 'ttyUSB5 (at)' ... $ sudo mmcli -m USB-MODEM-1 --enable ...
2016-08-10core: minor coding style changesAleksander Morgado
2016-08-10modem: support SIM hot swapCarlo Lobrano
BaseModem added reprobe property. MMDevice added logic to recreate the modem if it is set invalid and "to reprobe" MMBroadbandModem * added initialization step for SIM hot swap: 1. keep dedicated ports open to listen to modem's unsolicited 2. dedicated error management in case of initialization failure due to SIM missing * added function to be called in order to act upon SIM insertion/removal: 1. close dedicated ports 2. set the modem to be reprobed 3. disable modem * added SIM HOT SWAP boolean property MMIfaceModem * added initialization step for SIM hot swap, if supported by the plugin * dedicated error management in case of initialization failure due to SIM missing
2016-08-06device: ignored ports are also owned by the device, so include them in lookupAleksander Morgado
2016-03-27device: port probe may be in the ignored listAleksander Morgado
2015-01-29plugin: avoid segfault when port driver is unknownAleksander Morgado
Based on a patch from Bastiaan Jacques <bastiaan@bjacques.org> https://bugzilla.redhat.com/show_bug.cgi?id=1177799 https://bugs.freedesktop.org/show_bug.cgi?id=88864
2014-11-01device: Keep track of devices as they are move across sysfsLubomir Rintel
For certain devices the name changes with their status. Notably, RFCOMM devices move from /devices/virtual/ to underneath the HCI that is used for the connection as the session is estabilished, and return back when it's torn down.
2014-05-20core: minor coding style fixesBen Chan
2014-02-13manager: make Bluetooth rfcomm ports work againDan Williams
At some point rfcomm serial ports stopped having parents in sysfs, so checks to get the physical device fail because the rfcomm port is /sys/devices/virtual/rfcommX and has no parents. So we have to fall back on checking the interface name.
2014-02-13device: allow creating 'virtual' devicesAleksander Morgado
2014-02-13device: new 'hotplugged' propertyAleksander Morgado
2013-05-19device: check for NULL driver in add_port_driverBen Chan
This patch fixes a crash in MMDevice::add_port_driver() due to g_str_equal() dereferencing a NULL driver returned by mm_device_utils_get_port_driver(). Bug reported on https://code.google.com/p/chromium/issues/detail?id=241823
2013-04-17device: look for vendor/product ID on the grandparent for MBIM devicesAleksander Morgado
2013-04-10device: handle NULL returned by g_udev_device_get_driver() gracefullyBen Chan
This patch fixes a crash in mm_device_grab_port() when doing a string comparison on a NULL returned by g_udev_device_get_driver(). Thread 0 *CRASHED* ( SIGSEGV @ 0x00000000 ) 0x76b760b4 [libc-2.15.so] - strcmp.c:38 strcmp 0x76c66a7d [libglib-2.0.so.0.3200.4] - ghash.c:1704 g_str_equal 0x76ee0e5d [ModemManager] - mm-device.c:147 mm_device_grab_port 0x76edf9d9 [ModemManager] - mm-manager.c:313 device_added 0x76e95b2d [libgudev-1.0.so.0.1.0] - extras/gudev/gudevmarshal.c:84 g_udev_marshal_VOID__STRING_OBJECT 0x76d1fb2b [libgobject-2.0.so.0.3200.4] - gclosure.c:777 g_closure_invoke 0x76d2b88b [libgobject-2.0.so.0.3200.4] - gsignal.c:3551 signal_emit_unlocked_R 0x76d313c5 [libgobject-2.0.so.0.3200.4] - gsignal.c:3300 g_signal_emit_valist 0x76d31569 [libgobject-2.0.so.0.3200.4] - gsignal.c:3356 g_signal_emit 0x76e93bdd [libgudev-1.0.so.0.1.0] - extras/gudev/gudevclient.c:105 monitor_event 0x76c9beb7 [libglib-2.0.so.0.3200.4] - giounix.c:166 g_io_unix_dispatch 0x76c714c1 [libglib-2.0.so.0.3200.4] - gmain.c:2539 g_main_context_dispatch 0x76c71745 [libglib-2.0.so.0.3200.4] - gmain.c:3146 g_main_context_iterate 0x76c71a59 [libglib-2.0.so.0.3200.4] - gmain.c:3340 g_main_loop_run 0x76ede8ed [ModemManager] - main.c:142 main 0x76b35f79 [libc-2.15.so] - libc-start.c:226 __libc_start_main 0x76edea49 [ModemManager] + 0x00014a49 0x76eb4eab [ld-2.15.so] + 0x0000aeab
2013-03-28device: read PCI VID/PIDDan Williams
Nozomi devices are old Option NV CardBus devices with the ttys (nozX) hanging directly off the PCI device. We need to read the vendor and product IDs off them too. It appears that udev screws up the ID_MODEL_ID field (at least on F17, its set to the device path and not the PCI ID) so just skip looking at the TTY itself and read the PCI parent, where we're 100% sure to find the PCI IDs we want.
2013-01-18core: add 'hotplugged' flag to indicate if modem is newly plugged inBen Chan
This patch adds a 'hotplugged' flag to MMBaseModem to indicate if a modem is newly plugged in. A plugin can use this information to determine if, for example, the modem needs to be soft reset using the ATZ command. Dan Williams <dcbw@redhat.com> contributed the idea of implementation.
2012-12-27plugin: avoid QMI-managed net ports when compiling without QMI supportAleksander Morgado
2012-10-22device: only export modem if it is availableAleksander Morgado
2012-10-04libmm-glib: remove the `libmm-common.h' headerAleksander Morgado
Both the ModemManager daemon and the mmcli will now include `libmm-glib.h' only. We also handle two new special `_LIBMM_INSIDE_MM' and `LIBMM_INSIDE_MMCLI' symbols, which if included before the `libmm-glib.h' library allow us to: * Don't include the libmm-glib high level API in the ModemManager daemon, as the object names would clash with those in the core. * Define some of the methods of helper objects to be included only if compiling ModemManager daemon or the mmcli.
2012-09-19device: if failed to get VID/PID in first port, try the next oneAleksander Morgado
Don't rely only in the first grabbed port to get VID/PID. Some modems, e.g. Huawei E367, won't report a proper VID in the cdc-wdm port, which is the first one probed.
2012-09-14libmm-common: added common utils from coreAleksander Morgado
Moved the utils to play with binary to hex strings into libmm-common.
2012-08-29core: handle the 'usb'->'usbmisc' subsystem rename in the kernelAleksander Morgado
We'll try to cope with getting devices being reported in either 'usb' or 'usbmisc', trying to avoid the need of checking kernel version during runtime.
2012-08-29core: allow grabbing QMI portsAleksander Morgado
2012-08-24api,introspection: report list of drivers, not just oneAleksander Morgado
Different ports of the same modem may get handled by different drivers. We therefore need to provide a list of drivers (new `Modem.Drivers' property with signature 'as') instead of just one (removed `Modem.Driver' property with signature 's'). $ sudo mmcli -m 0 | grep drivers | drivers: 'qcserial, qmi_wwan'
2012-08-06device: keep all unsupported ports in a separate listAleksander Morgado
Ports being marked as unsupported should not be passed to the plugin specific create_modem() or grab_port() methods.
2012-08-06device: don't create devices with 0 portsAleksander Morgado
If for any reason we're requested to create a device with 0 ports, just return error.
2012-08-06port-probe: let us peek the `MMDevice' owning the probe from the probe itselfAleksander Morgado
2012-08-06device,plugin: let the `MMPlugin' API know about `MMDevice'Aleksander Morgado