aboutsummaryrefslogtreecommitdiff
path: root/src/kerneldevice
AgeCommit message (Collapse)Author
2022-05-24kernel-device, generic: add subsystem vendor ID supportDaniele Palmas
Add subsystem vendor ID support, that can be used in pci devices instead of vendor ID customization.
2022-01-26mm-kernel-device-helpers: fix memory leakNagi Marupaka
Newly refactored string manipulation function is leaking memory as per our tests. This submission fixes that memory leak.
2021-11-09kerneldevice,generic: simplify DEVPATH matching logicAleksander Morgado
Use autoptr to avoid the embedded goto.
2021-11-09kerneldevice,generic: input pattern to string match is not regexAleksander Morgado
The input pattern given to the string_match() method is not a regex pattern and we cannot use it as that, because all the special characters (e.g. '.') would not be treated correctly. Also, the prefix matching with the wildcard at the end of the string needs to be converted to a proper regex wildcard, i.e. '.*'. This logic also adds support for suffix matching, with a wildcard at the beginning of the string, e.g. as the ones used for the wwan kernel device name matching rules (i.e. '*MBIM'). Unit tests are added to cover all cases, most of these tests were failing without the fixes implemented here.
2021-11-09kerneldevice,generic: move string match method to helpersAleksander Morgado
So that we can propertly unit-test it.
2021-10-14qcom-soc: require udev tag for portsAleksander Morgado
Since the 'wwan' subsystem addition to the qcom-soc plugin, the rules to say a modem is handled by this plugin are too broad, and the plugin attempts to support any kind of device exposed by the WWAN subsystem, not just those from Qualcomm SoCs. Update the plugin to require a new ID_MM_QCOM_SOC udev tag that is set in the plugin udev rules, given that these rules already check for the expected SoC drivers (bam-dmux, ipa, qcom-q6v5-mss).
2021-08-04kernel-device-generic: Fix ptr_array_add_sysfs_attribute_link_basenameLoic Poulain
A pointer can not be used anymore after its ownership has been transfered using the g_steal_pointer function (pointer is nullified). In this function, g_steal_pointer() is used when inserting 'value' inside the array but can also be subsequently used when dumping 'value' to 'out_value' via g_strdup(). Fix that with simple reordering. Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2021-07-30kernel-device: generic: Support ATTR conditionLoic Poulain
Only the plural ATTRS form was checked but we also need to support the single ATTR for matching device's attribute only. Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2021-07-26kernel-device: Add get_wwandev_sysfs_pathLoic Poulain
The wwan subsystem is a new bus agnostic framework exposing wwan device and its components (ports, netdev...). It can be useful to get the wwan device a device belongs to Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2021-04-14kernel-device,qrtr: common physdev UID for all QRTR nodesAleksander Morgado
Add a common physdev UID to all ports in the Qualcomm SoC, so that they are all bound together to the same modem object. This change assumes that no external plugged device ever exports a QRTR node in the QRTR bus (e.g. that no PCI or USB device would ever do that). This assumption is likely wrong, but given that we're currently limiting the QRTR support to the Qualcomm SoC plugin, the assumption is valid for us for now.
2021-04-14kernel-device,qrtr: add MMKernelDeviceQrtr skeletonAndrew Lassalle
Add the skeleton of MMKernelDeviceQrtr and allow building it by the introduction of with-qrtr.
2021-04-12kerneldevice: fix segfault when processing event for non-existing portAleksander Morgado
ModemManager[6954]: <warn> [1618260091.319919] [br0] invalid sysfs path read for net/br0 ** ERROR:kerneldevice/mm-kernel-device-generic.c:235:ptr_array_add_sysfs_attribute_link_basename: assertion failed: (array && sysfs_path && attribute) Bail out! ERROR:kerneldevice/mm-kernel-device-generic.c:235:ptr_array_add_sysfs_attribute_link_basename: assertion failed: (array && sysfs_path && attribute) Thread 1 "ModemManager" received signal SIGABRT, Aborted. (gdb) bt #0 0x00007ffff7438ef5 in raise () at /usr/lib/libc.so.6 #1 0x00007ffff7422862 in abort () at /usr/lib/libc.so.6 #2 0x00007ffff76c2084 in () at /usr/lib/libglib-2.0.so.0 #3 0x00007ffff771d85d in g_assertion_message_expr () at /usr/lib/libglib-2.0.so.0 #4 0x00005555556a5337 in ptr_array_add_sysfs_attribute_link_basename (array=0x5555557de520, sysfs_path=0x0, attribute=0x555555703bd8 "driver", out_value=0x0) at kerneldevice/mm-kernel-device-generic.c:235 #5 0x00005555556a542b in preload_contents_other (self=0x5555557a6c60) at kerneldevice/mm-kernel-device-generic.c:255 #6 0x00005555556a6485 in preload_contents (self=0x5555557a6c60) at kerneldevice/mm-kernel-device-generic.c:517 #7 0x00005555556a7fb6 in check_preload (self=0x5555557a6c60) at kerneldevice/mm-kernel-device-generic.c:980 #8 0x00005555556a855f in initable_init (initable=0x5555557a6c60, cancellable=0x0, error=0x7fffffffe5c8) at kerneldevice/mm-kernel-device-generic.c:1127 #9 0x00007ffff78a2f41 in g_initable_new_valist () at /usr/lib/libgio-2.0.so.0 #10 0x00007ffff78a2ffa in g_initable_new () at /usr/lib/libgio-2.0.so.0 #11 0x00005555556a8205 in mm_kernel_device_generic_new_with_rules (props=0x5555557a5fa0, rules=0x7fffec001e30, error=0x7fffffffe5c8) at kerneldevice/mm-kernel-device-generic.c:1042 #12 0x00005555556a827d in mm_kernel_device_generic_new (props=0x5555557a5fa0, error=0x7fffffffe5c8) at kerneldevice/mm-kernel-device-generic.c:1063 #13 0x00005555555aba9c in handle_kernel_event (self=0x555555793220, properties=0x5555557a5fa0, error=0x7fffffffe5c8) at mm-base-manager.c:414
2021-03-18kernel-device-helpers: Remove unused variableAndrew Lassalle
2021-03-10kernel-device-generic: setup 'lower device' for virtual portsAleksander Morgado
2021-03-10kernel-device-udev: setup 'lower device' for virtual portsAleksander Morgado
2021-03-10kernel-device: new helper to load lower device link namesAleksander Morgado
Based exclusively on sysfs for now. We could do this via netlink if needed as well.
2021-03-10kernel-device: new 'lower device' property for physdev infoAleksander Morgado
We can now setup a 'lower device' object that will be the one providing all physdev info. This is useful when using virtual ports that refer to a 'lower' real physical device, in order to bind together all those ports on the same modem object.
2021-03-01utils: import ptr array lookup with GEqualFunc from GLib 2.54Aleksander Morgado
This fixes the build when using GLib < 2.54.
2021-02-25kernel-device-udev: keep track of the client objectAleksander Morgado
Instead of creating new clients internally whenever we need them, just make sure each MMKernelDeviceUdev object keeps a full reference to the GUdevClient that generated all GUdevDevices.
2021-02-24kernel-device: add get_interface_number() methodAleksander Morgado
We already have methods to query for interface specific attributes like class/subclass/protocol, so add a new one for the interface number, and make sure we use ATTRS{bInterfaceNumber} to load it always, instead of assuming the ID_USB_INTERFACE_NUM property is set.
2020-11-20kerneldevice: allow loading port attributesAleksander Morgado
In addition to loading port and device properties, we now also allow loading sysfs properties that are assumed to be static (i.e. their values won't change since loaded the first time).
2020-11-14kerneldevice,generic: use regex to implement string matchingAleksander Morgado
Instead of the custom simple implementation which only supported the '*' modifier in the pattern. This allows us to support e.g. attribute value matches like e.g. 'DATA[0-9]*_CNTL'.
2020-11-14kerneldevice,generic: implement ATTRS matching for any attributeAleksander Morgado
Until now we did not support ATTRS{} matches against attributes we don't support in the core codebase. Implement now a simple lookup mechanism which traverses the tree of sysfs path from the port sysfs path to the physical device sysfs path, looking up the attribute requested. This is not completely equivalent to what udev does, because the udev rules matching ATTRS would usually also include an additional previous matching e.g. SUBSYSTEMS and such, so that the ATTRS is looked up exactly in the device that also matches the additional previous rules. In our case, we just simplify the logic and return the first one found.
2020-11-14kerneldevice,generic: fix DRIVERS and SUBSYSTEMS checksAleksander Morgado
We were applying the DRIVERS check looking only at the single port driver. Instead, we now lookup and cache all drivers found in the device tree, and apply the loose DRIVERS check properly looking at all of them. We were applying the SUBSYSTEMS and SUBSYSTEM check looking at the sysfs path and just hoping the subsystem we're looking for is included in the path itself. Instead, we now lookup and cache all susystems found in the device tree, and apply the loose SUBSYSTEMS check properly looking at all of them. E.g. we can now match SUBSYSTEMS="mhi_q" in the following device tree, without needing it to be found in the sysfs path: looking at device '/devices/pci0000:00/0000:00:1b.0/0000:01:00.0/1001_00.01.00_MBIM/mhi_uci_q/mhi_MBIM': SUBSYSTEM=="mhi_uci_q" looking at parent device '/devices/pci0000:00/0000:00:1b.0/0000:01:00.0/1001_00.01.00_MBIM': SUBSYSTEMS=="mhi_q" looking at parent device '/devices/pci0000:00/0000:00:1b.0/0000:01:00.0': SUBSYSTEMS=="pci"
2020-11-14kerneldevice,generic: support PCI device common attribute namesAleksander Morgado
The vendor and product IDs stored for the MMKernelDevice object in the PCI subsystem are mapped to the "vendor" and "device" attributes.
2020-11-14kerneldevice,generic: preload port info based on the system busAleksander Morgado
The generic backend implementation was really based on detecting USB devices, not so much devices in other subsystems. This patch puts the generic backend at the same level as the udev backend to support non-USB modems.
2020-11-14kerneldevice,udev: preload port info based on the system busAleksander Morgado
USB, PCI, PCMCIA... all these different system buses expose modems in different ways. Instead of having single methods to attempt to load different things for all these device types, detect first which is the system bus in use, and then perform a bus-specific operation to preload the different things.
2020-11-14kerneldevice: no need to subclass the type gettersAleksander Morgado
We can just subclass the methods to check whether a given property exists and to get it as a string, and then implement in the generic class the actual boolean/int/hex type getters common for all.
2020-11-14kerneldevice: remove all unneeded g_return_if_fail() checksAleksander Morgado
These kind of checks are only useful on public APIs really, there should be no need to have them in internal code.
2020-11-09kerneldevice,generic: plug cached string leaksAleksander Morgado
Both 'physdev_subsystem' and 'interface_description' were leaking.
2020-11-05mm-kernel-device: Fix cmp to exclude subtypesAndrew Lassalle
If multiple kernel device types inherit from MMKernerDevice, and those are compared against each other, the current logic returns TRUE if the G_OBJECT_TYPE of one of them is smaller than the other. This function is checking for equality, so returning FALSE is enough.
2020-09-19core: add autoptr cleanup methods to all internal typesAleksander Morgado
2020-06-17mm-kernel-device: give cmp a total orderEric Caruso
This allows MMKernelDevice::cmp to compare two kernel devices with different object types, which means that subclasses can continue to only handle comparisons with their own type. The order may not be stable across builds.
2020-04-08kerneldevice,generic: remove loggingAleksander Morgado
2020-04-08kerneldevice: port to object loggingAleksander Morgado
2020-03-03kerneldevice,udev: don't assume interface is the direct parent objectAleksander Morgado
E.g. it may be one more layer up: looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8.4/1-8.4:1.1/ttyUSB1/tty/ttyUSB1': KERNEL=="ttyUSB1" SUBSYSTEM=="tty" DRIVER=="" looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8.4/1-8.4:1.1/ttyUSB1': KERNELS=="ttyUSB1" SUBSYSTEMS=="usb-serial" DRIVERS=="option1" ATTRS{port_number}=="0" looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8.4/1-8.4:1.1': KERNELS=="1-8.4:1.1" SUBSYSTEMS=="usb" DRIVERS=="option" ATTRS{bNumEndpoints}=="02" ATTRS{supports_autosuspend}=="1" ATTRS{bInterfaceNumber}=="01" ATTRS{bAlternateSetting}==" 0" ATTRS{bInterfaceSubClass}=="06" ATTRS{bInterfaceProtocol}=="13" ATTRS{interface}=="Huawei Mobile Connect - Application" ATTRS{bInterfaceClass}=="ff" ATTRS{authorized}=="1"
2020-03-03kerneldevice: support reading interface 'description'Aleksander Morgado
2020-01-31kernel-device-udev: fix warnings with -WshadowAleksander Morgado
kerneldevice/mm-kernel-device-udev.c: In function ‘mm_kernel_device_udev_new_from_properties’: kerneldevice/mm-kernel-device-udev.c:770:70: error: declaration of ‘properties’ shadows a global declaration [-Werror=shadow] 770 | mm_kernel_device_udev_new_from_properties (MMKernelEventProperties *properties, | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~ kerneldevice/mm-kernel-device-udev.c:38:20: note: shadowed declaration is here 38 | static GParamSpec *properties[PROP_LAST]; | ^~~~~~~~~~
2020-01-31kernel-device-generic-rules: fix warnings with -Wswitch-defaultAleksander Morgado
kerneldevice/mm-kernel-device-generic-rules.c: In function ‘udev_rule_clear’: kerneldevice/mm-kernel-device-generic-rules.c:40:5: error: switch missing default case [-Werror=switch-default] 40 | switch (rule->result.type) { | ^~~~~~
2020-01-31kernel-device-generic: fix warnings with -WshadowAleksander Morgado
kerneldevice/mm-kernel-device-generic.c: In function ‘mm_kernel_device_generic_new_with_rules’: kerneldevice/mm-kernel-device-generic.c:954:68: error: declaration of ‘properties’ shadows a global declaration [-Werror=shadow] 954 | mm_kernel_device_generic_new_with_rules (MMKernelEventProperties *properties, | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~ kerneldevice/mm-kernel-device-generic.c:46:20: note: shadowed declaration is here 46 | static GParamSpec *properties[PROP_LAST]; | ^~~~~~~~~~ kerneldevice/mm-kernel-device-generic.c: In function ‘mm_kernel_device_generic_new’: kerneldevice/mm-kernel-device-generic.c:971:57: error: declaration of ‘properties’ shadows a global declaration [-Werror=shadow] 971 | mm_kernel_device_generic_new (MMKernelEventProperties *properties, | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~ kerneldevice/mm-kernel-device-generic.c:46:20: note: shadowed declaration is here 46 | static GParamSpec *properties[PROP_LAST]; | ^~~~~~~~~~
2020-01-31kernel-device-generic: fix warnings with -Wswitch-defaultAleksander Morgado
kerneldevice/mm-kernel-device-generic.c: In function ‘check_rule’: kerneldevice/mm-kernel-device-generic.c:802:9: error: switch missing default case [-Werror=switch-default] 802 | switch (rule->result.type) { | ^~~~~~
2019-01-03kerneldevice: allow loading device revisionAleksander Morgado
2018-09-25udev: define all generic tags as symbolsAleksander Morgado
This prevents errors due to nasty typos in the strings. We define all symbols in a single header file that is NOT considered part of the API, as there is no need for MM clients to know about these tags code-wise. These tags are only meaningful when associated to devices in udev. Information of each tag is included in the general API documentation. https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/88
2018-07-19kerneldevice: allow loading physdev product stringAleksander Morgado
2018-06-17kerneldevice: fix build with musl libcBaruch Siach
musl libc does not implement the canonicalize_file_name() GNU extension. Use the POSIX standard realpath() instead.
2017-12-05kerneldevice: allow getting interface class/subclass/protocolAleksander Morgado
2017-12-05filter: new object to run the port/device filter logicAleksander Morgado
This new object allows configuring the filter rules applied to the device ports. By default, for now, it implements the same rules as the MMKernelDevice is_candidate() method, which is obsoleted.
2017-12-05kerneldevice: consolidate candidate rules in the base deviceAleksander Morgado
This patch implicitly enables in the generic device backend the manual-only greylist (ID_MM_DEVICE_MANUAL_SCAN_ONLY tag) and the platform TTY whitelist (ID_MM_PLATFORM_DRIVER_PROBE), which were not being applied.
2017-12-05kerneldevice: allow loading physdev sysfs pathAleksander Morgado
2017-12-05kerneldevice: allow loading physdev subsystemAleksander Morgado
Used to filter out TTYs when not explicitly whitelisted.