Merge lp:~phablet-team/ofono/lp1430700 into lp:~phablet-team/ofono/ubuntu

Proposed by Tony Espy
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: 6890
Merged at revision: 6890
Proposed branch: lp:~phablet-team/ofono/lp1430700
Merge into: lp:~phablet-team/ofono/ubuntu
Diff against target: 230 lines (+95/-76)
2 files modified
debian/changelog (+7/-0)
plugins/mtk.c (+88/-76)
To merge this branch: bzr merge lp:~phablet-team/ofono/lp1430700
Reviewer Review Type Date Requested Status
Tony Espy Needs Fixing
Alfonso Sanchez-Beato Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+253136@code.launchpad.net

Commit message

 [ Alfonso Sanchez-Beato ]
  * mtk.c: Fix Set3g FlightMode regression on krillin (LP: #1430700 )

Description of the change

This fixes a regression introduced by the Set3G slot feature, which causes krillin's modem to become wedged if Set3G is called for the second slot when no SIM is inserted in the first slot.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) :
review: Approve
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Tested on krillin. Bug #1430700 is fixed, urfkill test plan passes:

https://wiki.ubuntu.com/Process/Merges/TestPlans/urfkill

(with the exception of test 9, that will be solved when a recent urfkill fix lands). Basic telephony sanity test performed too (mobile data, phone calls).

$ system-image-cli -i
current build number: 152
device name: krillin
channel: ubuntu-touch/vivid-proposed
last update: 2015-03-18 15:06:18
version version: 152
version ubuntu: 20150318.1
version device: 20150310-ae1ddec
version custom: 20150318.1

Revision history for this message
Tony Espy (awe) wrote :

As this change is specific to MTK devices only, my testing was performed on krillin/vivid/#152.

I had two T-Mobile SIMs installed; /ril_0 was a valid PIN-locked SIM, /ril_1 was an expired, unlocked SIM.

The code that was changed involves the MTK device plugin ( mtk.c ) and it's handling of power and SIM mode events/request/reply logic. As such I performed basic sanity testing of voice and data, and then focused on FlightMode.

Before I could even get to the bug scenario ( Set3g + FM ), I hammered on the indicator-network menu's FM switch a bit to see if I could get it to fail.

I managed to recreate bug #1336715 ( switch items in unity sometimes get out of sync with modem system settings ), an airplane was shown on the panel, however the switch showed FM disabled, but then after about 30s to 1m, the switch flipped back to enabled.

When I tried to reproduce this again, I ran into a situation where the modem wouldn't exit FlightMode. When I checked the state of the state of the modems, /ril_0 was offline, and /ril_1 was online.

Here's the output of list-modems:

[ /ril_1 ]
    Online = 1
    Lockdown = 0
    Emergency = 0
    Powered = 1
    Revision = MOLY.WR8.W1315.MD.WG.MP.V37.P5, 2014/05/15 11:49
    Manufacturer = Fake Manufacturer
    Features = rat sim
    Model = Fake Modem Model
    Serial = 354142060413640
    Type = hardware
    Interfaces = org.ofono.RadioSettings org.ofono.SimManager org.ofono.MtkSettings org.ofono.CallVolume org.ofono.VoiceCallManager org.ofono.NetworkTime
    [ org.ofono.RadioSettings ]
    [ org.ofono.SimManager ]
        PinRequired = none
        FixedDialing = 0
        CardIdentifier = 8901260981853207741
        LockedPins =
        Present = 1
        SubscriberNumbers =
        Retries =
        PreferredLanguages = en
        BarredDialing = 0
    [ org.ofono.MtkSettings ]
        Has3G = 0
    [ org.ofono.CallVolume ]
        SpeakerVolume = 0
        MicrophoneVolume = 0
        Muted = 0
    [ org.ofono.VoiceCallManager ]
        EmergencyNumbers = 112 911
    [ org.ofono.NetworkTime ]

[ /ril_0 ]
    Online = 0
    Lockdown = 0
    Emergency = 0
    Powered = 1
    Revision = MOLY.WR8.W1315.MD.WG.MP.V37.P5, 2014/05/15 11:49
    Manufacturer = Fake Manufacturer
    Features =
    Model = Fake Modem Model
    Serial = 354142060133644
    Type = hardware
    Interfaces = org.ofono.CallVolume org.ofono.VoiceCallManager org.ofono.NetworkTime
    [ org.ofono.CallVolume ]
        SpeakerVolume = 0
        MicrophoneVolume = 0
        Muted = 0
    [ org.ofono.VoiceCallManager ]
        EmergencyNumbers = 112 911
    [ org.ofono.NetworkTime ]

urfkill's flight-mode script reports enabled, and the saved-state file shows all devices ( including ALL ) with soft=true, so I don't think this is bug #1430700.

I saved the log file.

review: Needs Fixing
Revision history for this message
Tony Espy (awe) wrote :

Also, as this change affects all MTK devices, we need to make sure arale is tested too.

Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Tony, thanks for the testing. I have taken a look at syslog and I do not see any obvious errors, all looks fine. All FM operations finish with:

urf_arbitrator_flight_mode_cb: flight-mode operation succeeded

I am wondering if you executed list-modems in the middle of a FM unset, because /ril_1 does not show interfaces that are created when the ofono SIM atom is ready (netreg, connection manager...), so it is not completely initialized yet. So maybe it had just been onlined and /ril_0 had not been onlined yet. It might be the case that indicator-network had pending FM operations and was still processing those. I am trying to reproduce anyway.

Revision history for this message
Tony Espy (awe) wrote :

Re-tested on krillin ( same image as above ) and couldn't reproduce the modem hang.

Also tested that the modem comes up on boot, and that FlightMode works correctly on arale:

current build number: 143
device name: m75
channel: ubuntu-touch/vivid-proposed
last update: 2015-03-20 17:36:17
version version: 143

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-02-24 18:27:43 +0000
3+++ debian/changelog 2015-03-17 00:10:59 +0000
4@@ -1,3 +1,10 @@
5+ofono (1.12.bzr6890+15.04.20150224-0ubuntu1) UNRELEASED; urgency=medium
6+
7+ [ Alfonso Sanchez-Beato ]
8+ * mtk.c: Fix Set3g FlightMode regression on krillin (LP: #1430700 )
9+
10+ -- CI Train Bot <ci-train-bot@canonical.com> Mon, 16 Mar 2015 19:59:36 -0400
11+
12 ofono (1.12.bzr6888+15.04.20150224-0ubuntu1) vivid; urgency=medium
13
14 [ Alfonso Sanchez-Beato ]
15
16=== modified file 'plugins/mtk.c'
17--- plugins/mtk.c 2015-02-09 10:57:46 +0000
18+++ plugins/mtk.c 2015-03-17 00:10:59 +0000
19@@ -89,6 +89,7 @@
20 #define RILD_CONNECT_RETRY_TIME_S 5
21
22 #define T_WAIT_DISCONN_MS 1000
23+#define T_SIM_SWITCH_FAILSAFE_MS 1000
24
25 enum mtk_sim_type {
26 MTK_SIM_TYPE_1 = 1,
27@@ -167,6 +168,7 @@
28 static void socket_disconnected(gpointer user_data);
29 static void start_slot(struct mtk_data *md, struct socket_data *sock,
30 const char *hex_prefix);
31+static void exec_pending_online(struct mtk_data *md);
32
33 static void mtk_debug(const char *str, void *user_data)
34 {
35@@ -272,6 +274,30 @@
36 }
37 }
38
39+static void exec_online_callback(struct mtk_data *md)
40+{
41+ if (md->online_cb != NULL) {
42+ /*
43+ * We assume success, as the sim switch request was successful
44+ * too. Also, the SIM_* states can be returned independently of
45+ * the radio state, so we cannot reliably use it to know if the
46+ * sim switch command really did what was requested.
47+ */
48+ CALLBACK_WITH_SUCCESS(md->online_cb, md->online_data);
49+ md->online_cb = NULL;
50+ md->online_data = NULL;
51+
52+ if (md->ofono_online)
53+ md->mtk_settings =
54+ mtk_settings_create(md->modem, md->ril,
55+ md->has_3g);
56+ else
57+ mtk_settings_remove(md->mtk_settings);
58+
59+ exec_pending_online(md);
60+ }
61+}
62+
63 static void mtk_radio_state_changed(struct ril_msg *message, gpointer user_data)
64 {
65 struct ofono_modem *modem = user_data;
66@@ -279,48 +305,28 @@
67 int radio_state = g_ril_unsol_parse_radio_state_changed(md->ril,
68 message);
69
70- if (radio_state != md->radio_state) {
71- gboolean success = FALSE;
72-
73- ofono_info("%s, slot %d: state: %s md->ofono_online: %d",
74- __func__, md->slot,
75- ril_radio_state_to_string(radio_state),
76- md->ofono_online);
77-
78- md->radio_state = radio_state;
79-
80- switch (radio_state) {
81- case RADIO_STATE_ON:
82- /* Deprecated in AOSP, but still used by MTK */
83- case RADIO_STATE_SIM_NOT_READY:
84- case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
85- case RADIO_STATE_SIM_READY:
86- if (md->ofono_online)
87- success = TRUE;
88- break;
89-
90- case RADIO_STATE_UNAVAILABLE:
91- case RADIO_STATE_OFF:
92- if (!md->ofono_online)
93- success = TRUE;
94- break;
95- default:
96- /* Malformed parcel; no radio state == broken rild */
97- g_assert(FALSE);
98- }
99-
100- if (md->online_cb != NULL) {
101- if (success)
102- CALLBACK_WITH_SUCCESS(md->online_cb,
103- md->online_data);
104- else
105- CALLBACK_WITH_FAILURE(md->online_cb,
106- md->online_data);
107-
108- md->online_cb = NULL;
109- md->online_data = NULL;
110- }
111+ ofono_info("%s, slot %d: state: %s md->ofono_online: %d",
112+ __func__, md->slot,
113+ ril_radio_state_to_string(radio_state),
114+ md->ofono_online);
115+
116+ md->radio_state = radio_state;
117+
118+ switch (radio_state) {
119+ case RADIO_STATE_ON:
120+ /* RADIO_STATE_SIM_* are deprecated in AOSP, but still used by MTK */
121+ case RADIO_STATE_SIM_NOT_READY:
122+ case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
123+ case RADIO_STATE_SIM_READY:
124+ case RADIO_STATE_UNAVAILABLE:
125+ case RADIO_STATE_OFF:
126+ break;
127+ default:
128+ /* Malformed parcel; no radio state == broken rild */
129+ g_assert(FALSE);
130 }
131+
132+ exec_online_callback(md);
133 }
134
135 static void reg_suspended_cb(struct ril_msg *message, gpointer user_data)
136@@ -764,46 +770,14 @@
137 sim_inserted, modem);
138 }
139
140-static void mtk_sim_mode_cb(struct ril_msg *message, gpointer user_data)
141+static void exec_pending_online(struct mtk_data *md)
142 {
143- struct cb_data *cbd = user_data;
144- ofono_modem_online_cb_t cb = cbd->cb;
145- struct ofono_modem *modem = cbd->user;
146- struct mtk_data *md = ofono_modem_get_data(modem);
147 struct mtk_data *md_c;
148
149+ DBG("");
150+
151 mtk_data_0->pending_cb = NULL;
152
153- if (message->error == RIL_E_SUCCESS) {
154- g_ril_print_response_no_args(md->ril, message);
155-
156- /*
157- * Although the request was successful, radio state might not
158- * have changed yet. In that case we wait for the radio event,
159- * otherwise RIL requests that depend on radio state will fail.
160- */
161- if ((md->ofono_online && md->radio_state != RADIO_STATE_OFF) ||
162- (!md->ofono_online &&
163- md->radio_state == RADIO_STATE_OFF)) {
164- CALLBACK_WITH_SUCCESS(cb, cbd->data);
165- } else {
166- /* Wait for the radio state event */
167- md->online_cb = cb;
168- md->online_data = cbd->data;
169- }
170- } else {
171- ofono_error("%s: RIL error %s", __func__,
172- ril_error_to_string(message->error));
173- CALLBACK_WITH_FAILURE(cb, cbd->data);
174- }
175-
176- if (md->ofono_online)
177- md->mtk_settings =
178- mtk_settings_create(md->modem, md->ril,
179- md->has_3g);
180- else
181- mtk_settings_remove(md->mtk_settings);
182-
183 /* Execute possible pending operation on the other modem */
184
185 md_c = mtk_data_complement(md);
186@@ -820,6 +794,44 @@
187 }
188 }
189
190+static gboolean sim_switch_failsafe(gpointer user_data)
191+{
192+ struct mtk_data *md = user_data;
193+
194+ exec_online_callback(md);
195+
196+ return FALSE;
197+}
198+
199+static void mtk_sim_mode_cb(struct ril_msg *message, gpointer user_data)
200+{
201+ struct cb_data *cbd = user_data;
202+ ofono_modem_online_cb_t cb = cbd->cb;
203+ struct ofono_modem *modem = cbd->user;
204+ struct mtk_data *md = ofono_modem_get_data(modem);
205+
206+ if (message->error == RIL_E_SUCCESS) {
207+ g_ril_print_response_no_args(md->ril, message);
208+ /*
209+ * Although the request was successful, radio state might not
210+ * have changed yet. So we wait for the upcoming radio event,
211+ * otherwise RIL requests that depend on radio state will fail.
212+ * If we are switching the 3G slot, we cannot really trust this
213+ * behaviour, so we add a failsafe timer.
214+ */
215+ md->online_cb = cb;
216+ md->online_data = cbd->data;
217+
218+ g_timeout_add(T_SIM_SWITCH_FAILSAFE_MS,
219+ sim_switch_failsafe, md);
220+ } else {
221+ ofono_error("%s: RIL error %s", __func__,
222+ ril_error_to_string(message->error));
223+ CALLBACK_WITH_FAILURE(cb, cbd->data);
224+ exec_pending_online(md);
225+ }
226+}
227+
228 static int sim_state()
229 {
230 int state = mtk_data_0->ofono_online ? SIM_1_ACTIVE : NO_SIM_ACTIVE;

Subscribers

People subscribed via source and target branches

to all changes: