Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 27cbb306 authored by Jitendra Sharma's avatar Jitendra Sharma Committed by Isaac J. Manjarres
Browse files

soc: qcom: service-locator: Use interruptible wait for locator



Using uninterruptible wait for locator service can lead to
the task disk-sleeping indefinitely in cases where pd-mapper
service is not going to be available.
Use interruptible wait with timeout to skip the wait
gracefully in those cases.

Change-Id: Id5cd3ad716a164ecb86f816111cba90e3b105c3e
Signed-off-by: default avatarJitendra Sharma <shajit@codeaurora.org>
[isaacm@codeaurora.org: resolve trivial merge conflicts]
Signed-off-by: default avatarIsaac J. Manjarres <isaacm@codeaurora.org>
parent c0c89b3b
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#define QMI_SERVREG_LOC_SERVER_INITIAL_TIMEOUT		2000
#define QMI_SERVREG_LOC_SERVER_TIMEOUT			2000
#define INITIAL_TIMEOUT					100000
#define LOCATOR_SERVICE_TIMEOUT				300000

#define LOCATOR_NOT_PRESENT	0
#define LOCATOR_PRESENT		1
@@ -244,13 +245,20 @@ static int service_locator_send_msg(struct pd_qmi_client_data *pd)
static int init_service_locator(void)
{
	int rc = 0;
	static bool service_timedout;

	mutex_lock(&service_init_mutex);
	rc = mutex_lock_interruptible(&service_init_mutex);
	if (rc)
		return rc;
	if (locator_status == LOCATOR_NOT_PRESENT) {
		pr_err("Service Locator not enabled\n");
		rc = -ENODEV;
		goto inited;
	}
	if (service_timedout) {
		rc = -ETIME;
		goto inited;
	}
	if (service_inited)
		goto inited;

@@ -271,7 +279,20 @@ static int init_service_locator(void)
			SERVREG_LOC_SERVICE_VERS_V01,
			SERVREG_LOC_SERVICE_INSTANCE_ID);

	wait_for_completion(&service_locator.service_available);
	rc = wait_for_completion_interruptible_timeout(
				&service_locator.service_available,
				msecs_to_jiffies(LOCATOR_SERVICE_TIMEOUT));
	if (rc < 0) {
		pr_err("Wait for locator service interrupted by signal\n");
		goto inited;
	}
	if (!rc) {
		pr_err("%s: wait for locator service timed out\n", __func__);
		service_timedout = true;
		rc = -ETIME;
		goto inited;
	}

	service_inited = true;
	mutex_unlock(&service_init_mutex);
	pr_info("Service locator initialized\n");