Commit Graph

33 Commits

Author SHA1 Message Date
Alexander Couzens 43febf13a4 qmimodem: sync the modem on enable
The qmi sync call release all previous resources.
qmi/discovery: only do the sync call when ctl service version >= 1.5
2017-10-02 06:56:15 +02:00
Alexander Couzens d7fda89cbc qmi/discovery: include control service into service list
There is no need to exclude it. It helps debugging because the service is now logged.
2017-10-02 06:56:15 +02:00
Alexander Couzens bfb71b4829 qmi/discovery: remove useless code 2017-10-02 06:56:15 +02:00
Jonas Bonn 76689b81d4 qmi: add helper to get int16_t result 2017-09-07 11:57:31 -05:00
Alexander Couzens b5cc57775f qmimodem: add debug helper qmi_result_print_tlvs
qmi_result_print_tlvs prints the type and length field
of a result to DBG()
2017-05-30 17:29:13 -05:00
Denis Kenzior 2d6c4f9d02 qmi: Fix invalid memory access
When qmi_device_shutdown is used and the callback provided utilizes
qmi_device_unref, an access into already freed memory is triggered.

Sequence of events is:

1. timeout fires
2. glib calls timeout callback (e.g. shutdown_callback) which in turn
calls shutdown_func (gobi shutdown_cb) which in turn calls
qmi_device_unref()
3. qmi_device_unref calls g_source_remove, which doesn't call the
destroy callback (it is blocked)
4. qmi_device_unref then frees the memory used by device
5. glib then calls the source destroy callback (e.g. shutdown_destroy)
which results in just freed memory being used.

glib appears to always call the destroy callback, even if the source has
been removed previously.  So to work around the issue, delay the actual
g_free until the destroy callback is invoked.
2017-05-11 14:41:43 -05:00
Denis Kenzior 829fc23137 qmi: Fix qmi_device_shutdown
qmi_device_shutdown allocated a new orphaned data structure and kicked
off a timeout to wait for the shutdown to complete.  The logic was quite
racy, but the main issue was that the timeouts could not be canceled
when the underlying qmi_device object was destroyed.  This resulted in
crashes.

This patch switches to first-past-the-gate mechanism.  Since only the
modem driver should be issuing a qmi_device_shutdown call, this should
not be a limitation.  The shutdown source is then tracked on the
qmi_device object itself and is canceled when the qmi_device object is
freed.

As an added bonus, the shutdown_destroy callback should now actually
function.  Before it was simply never called.
2017-04-04 10:24:13 -05:00
Denis Kenzior 2701dd8919 qmi: Optimize structure allocations
struct discovery was allocated for every discovery procedure that was
kicked off, which itself allocated a structure.  This patch uses a
class/subclass concept to only allocate a single structure per discovery
procedure.
2017-04-03 12:56:26 -05:00
Jonas Bonn 1e39a9d26d qmi: fix bad lookup and double free
This function was never removing discovery instances because it was looking
them up in the wrong list.  This led to some strangeness with the discovery
callbacks being invoked after the "failure" timeout of 5 seconds and
consequent failures with everything getting out of sync.

With this patch we fix the lookup to use the correct queue.  There's also
a double-free in the function that was never being hit before because the
lookups never succeeded; fix that as well.

With this, service discovery and creation work as expected when testing with
an EC21.
2017-04-03 09:23:53 -05:00
Jonas Bonn 529afeb67f qmi: add service ID's 2017-04-03 09:23:53 -05:00
Denis Kenzior 4c46605f6b qmi: track discovery tasks so clean up is possible
There are various device & service discovery tasks that are initiated
based on a qmi_device object.  qmi_device object does not currently
keep track of these tasks.  Unfortunately the qmi_device object can
go away at any time, and these tasks can become orphaned.

The result of this can lead to crashes.  E.g. a discovery task timeout fires
after the qmi_device object has been destroyed.  Since the object is no
longer valid, any accesses to it will likely result in a SEGFAULT.

This patch attempts to track all discovery tasks on the qmi_device
object itself, so that they can be cleaned up properly.  This patch does
not handle the qmi_device_shutdown functionality.
2017-03-28 14:21:07 -05:00
Jonas Bonn f3911b1669 qmimodem: add WDA service string 2017-03-25 16:01:21 -05:00
Jonas Bonn c548fe2eb5 qmimodem: fix typo 2017-03-25 16:01:06 -05:00
Denis Kenzior 0fbc802845 qmi: Fix typo 2017-02-02 11:41:36 -06:00
Christophe Ronco 8dffd365a2 qmimodem: get/set kernel device driver data format
Add a way to get and set data format expected by kernel device driver.
This is inspired by what is done in qmicli (package libqmi).
It does not use QMI protocol but a sysfs exported by kernel driver.
To use this feature, kernel version must be equal or more than 4.5.
2017-02-02 11:41:27 -06:00
Christophe Ronco 567e5ec9fc qmimodem: fix QMI notification messages handling
QMI notification messages handlers are never called on MC7430 without this fix.

- Do not test transaction id before calling notification handler.  On MC7430,
notification messages contain a not null transaction id (starts with 1,
increased at each message for a particular client).
- On MC7304 transaction id in notification messages is always 0.
2016-12-30 18:38:29 -06:00
Marcel Holtmann 788922cbdf qmi: Include persistent device configuration service 2012-12-04 05:42:14 +01:00
Marcel Holtmann 15f309742c qmi: Print service number if name is not known 2012-12-01 21:37:22 +01:00
Marcel Holtmann 56e4798e1e qmimodem: Print error string instead of code if available 2012-11-25 10:19:40 +01:00
Marcel Holtmann 9b4d69cf8d qmimodem: Pretty print service name in debug logs 2012-11-25 00:05:54 +01:00
Marcel Holtmann 535e16c8a4 qmimodem: Fix debug printing of messages 2012-11-25 00:05:15 +01:00
Marcel Holtmann 7feb9e2711 qmimodem: Add helper for error message strings 2012-11-25 00:04:14 +01:00
Marcel Holtmann a04341cdb6 qmimodem: Make sure all service destroy functions are called 2012-06-25 10:25:03 -07:00
Marcel Holtmann a41b7a246b qmimodem: Add support for canceling all service requests 2012-06-25 10:20:08 -07:00
Marcel Holtmann a19dc51227 qmimodem: Add support for shared services with same client id 2012-06-25 09:30:31 -07:00
Marcel Holtmann 18fb4817f7 qmimodem: Use unsigned int for notify id to make GUINT_TO_POINTER happy 2012-06-25 01:57:15 -07:00
Marcel Holtmann 8f2549416a qmimodem: Use unsigned int for tid to make GUINT_TO_POINTER happy 2012-06-25 01:23:14 -07:00
Marcel Holtmann 2c00dfb0fe qmimodem: Use unsigned int for hash_id to make GUINT_TO_POINTER happy 2012-06-25 01:18:48 -07:00
Marcel Holtmann b168c0f953 qmimodem: Add support for unregister of individual notifications 2012-06-24 23:31:49 -07:00
Marcel Holtmann 29067f75bc qmimodem: Add support for canceling service requests 2012-06-24 23:20:25 -07:00
Marcel Holtmann 1631d21e35 qmimodem: Return transaction identifier from service requests 2012-06-24 22:38:26 -07:00
Marcel Holtmann 74d208768a qmimodem: Add helper function for accessing 64-bit integers 2012-06-24 22:24:56 -07:00
Marcel Holtmann 0e6fc7aee4 qmimodem: Add support for QMI control point handling 2012-06-21 15:18:36 -07:00