From 72e3b852ded1c9221e9b98001172eb6deb44164f Mon Sep 17 00:00:00 2001 From: Dante Russo Date: Wed, 15 Aug 2012 15:06:22 -0700 Subject: [PATCH] loc_api_v02: Initialize the QMI notifier before looking for service Looking for a service results in opening and closing the IPC Router socket. This in turn involves IPC Router to trigger loading & unloading the modem. Sometimes this causes the race condition between modem unload and modem coming out of reset. CRs-fixed: 384906 Change-Id: I61767d3eeab5867f64f94c5d4cdee4272de2dc44 --- loc_api/loc_api_v02/loc_api_v02_client.c | 54 ++++++++++-------------- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/loc_api/loc_api_v02/loc_api_v02_client.c b/loc_api/loc_api_v02/loc_api_v02_client.c index 26ecfd26..12782b93 100644 --- a/loc_api/loc_api_v02/loc_api_v02_client.c +++ b/loc_api/loc_api_v02/loc_api_v02_client.c @@ -1543,6 +1543,8 @@ static locClientStatusEnumType locClientQmiCtrlPointInit( uint32_t num_services = 0, num_entries = 0; qmi_client_error_type rc = QMI_NO_ERR; bool nosignal = false; + qmi_client_os_params os_params; + int timeout = 0; // Get the service object for the qmiLoc Service qmi_idl_service_object_type locClientServiceObject = @@ -1557,46 +1559,34 @@ static locClientStatusEnumType locClientQmiCtrlPointInit( break; } - // get the service addressing information - rc = qmi_client_get_service_list( locClientServiceObject, NULL, NULL, - &num_services); - LOC_LOGV("%s:%d]: qmi_client_get_service_list() first try rc %d, " - "num_services %d", __func__, __LINE__, rc, num_services); + // register for service notification + rc = qmi_client_notifier_init(locClientServiceObject, &os_params, ¬ifier); + notifierInitFlag = (NULL != notifier); if (rc != QMI_NO_ERR) { - // bummer, service list is not up. - // We need to try again after a timed wait - qmi_client_os_params os_params; - int timeout = 0; - - // register for service notification - rc = qmi_client_notifier_init(locClientServiceObject, &os_params, ¬ifier); - notifierInitFlag = (NULL != notifier); + LOC_LOGE("%s:%d]: qmi_client_notifier_init failed %d\n", + __func__, __LINE__, rc); + status = eLOC_CLIENT_FAILURE_INTERNAL; + break; + } + do { + QMI_CCI_OS_SIGNAL_CLEAR(&os_params); + // get the service addressing information + rc = qmi_client_get_service_list(locClientServiceObject, NULL, NULL, + &num_services); + /* If service is not up wait on a signal until the service is up + * or a timeout occurs. */ if (rc != QMI_NO_ERR) { - LOC_LOGE("%s:%d]: qmi_client_notifier_init failed %d\n", - __func__, __LINE__, rc); - status = eLOC_CLIENT_FAILURE_INTERNAL; - break; - } - - do { - QMI_CCI_OS_SIGNAL_CLEAR(&os_params); - /* If service is not up wait on a signal until the service is up - * or a timeout occurs. */ QMI_CCI_OS_SIGNAL_WAIT(&os_params, LOC_CLIENT_SERVICE_TIMEOUT_UNIT); nosignal = QMI_CCI_OS_SIGNAL_TIMED_OUT(&os_params); + } - // get the service addressing information - rc = qmi_client_get_service_list(locClientServiceObject, NULL, NULL, - &num_services); + timeout += LOC_CLIENT_SERVICE_TIMEOUT_UNIT; - timeout += LOC_CLIENT_SERVICE_TIMEOUT_UNIT; - - LOC_LOGV("%s:%d]: qmi_client_get_service_list() rc %d, nosignal %d, " - "total timeout %d", __func__, __LINE__, rc, nosignal, timeout); - } while (timeout < LOC_CLIENT_SERVICE_TIMEOUT_TOTAL && nosignal && rc != QMI_NO_ERR); - } + LOC_LOGV("%s:%d]: qmi_client_get_service_list() rc %d, nosignal %d, " + "total timeout %d", __func__, __LINE__, rc, nosignal, timeout); + } while (timeout < LOC_CLIENT_SERVICE_TIMEOUT_TOTAL && nosignal && rc != QMI_NO_ERR); if (0 == num_services || rc != QMI_NO_ERR) { if (!nosignal) {