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

Commit 1ca74799 authored by Isaac J. Manjarres's avatar Isaac J. Manjarres
Browse files

soc: qcom: sysmon-qmi: Fix duplicate BEFORE_POWERUP SSCTL events



Currently, when sending an SSCTL SSR event, the event is
obtained by blindly following a map from the notification ID
provided by the subsystem notifier framework to an SSCTL
SSR event.

Since all the entries in the map that are not explicitly defined
are initialized to 0 (SSCTL_SSR_EVENT_BEFORE_POWERUP), then
notifications, such as SUBSYS_PROXY_VOTE, that do not map
to an actual SSCTL event map to SSCTL_SSR_EVENT_BEFORE_POWERUP,
resulting in multiple SSCTL_SSR_EVENT_BEFORE_POWERUP
notifications being sent.

To avoid this, mark all the notification ID to SSCTL event
mappings that are not defined, as SSCTL_EVENT_SSR_INVALID,
and prior to sending an SSCTL SSR event for a notification ID,
check to ensure that the notification ID maps to a defined
SSCTL event.

Change-Id: If4e4fcd12f7acc6eb82f9776a9db8bc9066d3c4e
Signed-off-by: default avatarIsaac J. Manjarres <isaacm@codeaurora.org>
parent f136459e
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ static LIST_HEAD(sysmon_list);
static DEFINE_MUTEX(sysmon_list_lock);

static const int notif_map[SUBSYS_NOTIF_TYPE_COUNT] = {
	[0 ... SUBSYS_NOTIF_TYPE_COUNT - 1] = SSCTL_SSR_EVENT_INVALID,
	[SUBSYS_BEFORE_POWERUP] = SSCTL_SSR_EVENT_BEFORE_POWERUP,
	[SUBSYS_AFTER_POWERUP] = SSCTL_SSR_EVENT_AFTER_POWERUP,
	[SUBSYS_BEFORE_SHUTDOWN] = SSCTL_SSR_EVENT_BEFORE_SHUTDOWN,
@@ -118,6 +119,11 @@ static struct qmi_msg_handler qmi_indication_handler[] = {
	{}
};

static bool is_ssctl_event(enum subsys_notif_type notif)
{
	return notif_map[notif] != SSCTL_SSR_EVENT_INVALID;
}

static int ssctl_new_server(struct qmi_handle *qmi, struct qmi_service *svc)
{
	struct sysmon_qmi_data *data = container_of(qmi,
@@ -258,8 +264,8 @@ int sysmon_send_event(struct subsys_desc *dest_desc,
	int ret;
	struct qmi_txn txn;

	if (notif < 0 || notif >= SUBSYS_NOTIF_TYPE_COUNT || event_ss == NULL
		|| dest_ss == NULL)
	if (notif < 0 || notif >= SUBSYS_NOTIF_TYPE_COUNT ||
	    !is_ssctl_event(notif) || event_ss == NULL || dest_ss == NULL)
		return -EINVAL;

	mutex_lock(&sysmon_list_lock);
+2 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
 * Copyright (c) 2011-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -23,6 +23,7 @@
 */
enum ssctl_ssr_event_enum_type {
	SSCTL_SSR_EVENT_ENUM_TYPE_MIN_ENUM_VAL = -2147483647,
	SSCTL_SSR_EVENT_INVALID = -1,
	SSCTL_SSR_EVENT_BEFORE_POWERUP = 0,
	SSCTL_SSR_EVENT_AFTER_POWERUP = 1,
	SSCTL_SSR_EVENT_BEFORE_SHUTDOWN = 2,