qcom: sysmon: Replace sending strings as parameters to sysmon APIs

Currently, all the sysmon APIs use string names to derive the
information about subsystems that the events should be sent to.
To do so, a list of subsystems that support sysmon are stored
in a static array. This approach makes sysmon break when the
name of a subsystem changes or when new subsystems are added.

Instead, store the sysmon pdev id information that is read
from the subsystem's dt nodes in the subsys descriptor. These
descriptors are then passed as parameters to the sysmon APIs.

Change-Id: I0c0b68412acb4913e823586931a7fd0b8f03f15b
Signed-off-by: Deepak Katragadda <dkatraga@codeaurora.org>
This commit is contained in:
Deepak Katragadda 2014-07-03 11:50:04 -07:00
parent 1ec33670c6
commit 9250c4ca2e
13 changed files with 54 additions and 43 deletions

View File

@ -4642,6 +4642,7 @@
qcom,pas-id = <1>;
qcom,proxy-timeout-ms = <10000>;
qcom,smem-id = <423>;
qcom,sysmon-id = <1>;
qcom,firmware-name = "adsp";
/* GPIO inputs from lpass */

View File

@ -32,6 +32,7 @@
qcom,vddmin-drive-strength = <8>;
qcom,sfr-query;
qcom,support-shutdown;
qcom,sysmon-id = <20>;
status = "disabled";
};
@ -56,6 +57,7 @@
qcom,vddmin-drive-strength = <8>;
qcom,sfr-query;
qcom,support-shutdown;
qcom,sysmon-id = <20>;
status = "disabled";
};
};

View File

@ -452,6 +452,7 @@
qcom,firmware-name = "modem";
qcom,pil-self-auth;
qcom,mba-image-is-not-elf;
qcom,sysmon-id = <0>;
/* GPIO inputs from mss */
qcom,gpio-err-fatal = <&smp2pgpio_ssr_smp2p_1_in 0 0>;
@ -843,6 +844,7 @@
qcom,pas-id = <1>;
qcom,proxy-timeout-ms = <10000>;
qcom,smem-id = <423>;
qcom,sysmon-id = <1>;
qcom,firmware-name = "adsp";
/* GPIO inputs from lpass */

View File

@ -1147,6 +1147,7 @@
qcom,pas-id = <6>;
qcom,proxy-timeout-ms = <10000>;
qcom,smem-id = <422>;
qcom,sysmon-id = <6>;
qcom,firmware-name = "wcnss";
/* GPIO inputs from wcnss */
@ -1183,6 +1184,7 @@
qcom,pas-id = <1>;
qcom,proxy-timeout-ms = <10000>;
qcom,smem-id = <423>;
qcom,sysmon-id = <1>;
qcom,firmware-name = "adsp";
/* GPIO inputs from lpass */
@ -1216,6 +1218,7 @@
qcom,firmware-name = "modem";
qcom,pil-self-auth;
qcom,mba-image-is-not-elf;
qcom,sysmon-id = <0>;
/* GPIO inputs from mss */
qcom,gpio-err-fatal = <&smp2pgpio_ssr_smp2p_1_in 0 0>;

View File

@ -720,6 +720,7 @@
qcom,pas-id = <6>;
qcom,proxy-timeout-ms = <10000>;
qcom,smem-id = <422>;
qcom,sysmon-id = <6>;
qcom,firmware-name = "wcnss";
/* GPIO inputs from wcnss */
@ -949,6 +950,7 @@
qcom,firmware-name = "modem";
qcom,pil-self-auth;
qcom,mba-image-is-not-elf;
qcom,sysmon-id = <0>;
/* GPIO inputs from mss */
qcom,gpio-err-fatal = <&smp2pgpio_ssr_smp2p_1_in 0 0>;
@ -979,6 +981,7 @@
qcom,pas-id = <1>;
qcom,proxy-timeout-ms = <10000>;
qcom,smem-id = <423>;
qcom,sysmon-id = <1>;
qcom,firmware-name = "adsp";
/* GPIO inputs from lpass */

View File

@ -1583,6 +1583,7 @@
qcom,is-loadable;
qcom,firmware-name = "modem";
qcom,pil-self-auth;
qcom,sysmon-id = <0>;
/* GPIO inputs from mss */
qcom,gpio-err-fatal = <&smp2pgpio_ssr_smp2p_1_in 0 0>;
@ -1688,6 +1689,7 @@
qcom,pas-id = <6>;
qcom,proxy-timeout-ms = <10000>;
qcom,smem-id = <422>;
qcom,sysmon-id = <6>;
qcom,firmware-name = "wcnss";
/* GPIO inputs from wcnss */

View File

@ -1168,6 +1168,7 @@
qcom,firmware-name = "modem";
qcom,pil-self-auth;
qcom,sysmon-id = <0>;
/* GPIO inputs from mss */
qcom,gpio-err-fatal = <&smp2pgpio_ssr_smp2p_1_in 0 0>;
@ -1507,6 +1508,7 @@
qcom,pas-id = <6>;
qcom,proxy-timeout-ms = <10000>;
qcom,smem-id = <422>;
qcom,sysmon-id = <6>;
qcom,firmware-name = "wcnss";
/* GPIO inputs from wcnss */

View File

@ -1644,6 +1644,7 @@
qcom,pas-id = <1>;
qcom,proxy-timeout-ms = <10000>;
qcom,smem-id = <423>;
qcom,sysmon-id = <1>;
qcom,firmware-name = "adsp";
/* GPIO inputs from lpass */
@ -1919,6 +1920,7 @@
vdd_mx-uV = <1050000>;
vdd_pll-supply = <&pm8941_l12>;
qcom,vdd_pll = <1800000>;
qcom,sysmon-id = <0>;
qcom,firmware-name = "modem";
qcom,pil-self-auth;
qcom,mba-image-is-not-elf;
@ -1952,6 +1954,7 @@
qcom,pas-id = <6>;
qcom,proxy-timeout-ms = <10000>;
qcom,smem-id = <422>;
qcom,sysmon-id = <6>;
qcom,firmware-name = "wcnss";
/* GPIO inputs from wcnss */

View File

@ -1497,6 +1497,7 @@
qcom,firmware-name = "modem";
qcom,pil-self-auth;
qcom,mba-image-is-not-elf;
qcom,sysmon-id = <0>;
/* GPIO inputs from mss */
qcom,gpio-err-fatal = <&smp2pgpio_ssr_smp2p_1_in 0 0>;
@ -1530,6 +1531,7 @@
qcom,pas-id = <1>;
qcom,proxy-timeout-ms = <10000>;
qcom,smem-id = <423>;
qcom,sysmon-id = <1>;
qcom,firmware-name = "adsp";
/* GPIO inputs from lpass */

View File

@ -351,7 +351,7 @@ static int mdm_cmd_exe(enum esoc_cmd cmd, struct esoc_clink *esoc)
mdm->ready = false;
mdm->trig_cnt = 0;
ret = sysmon_send_shutdown(esoc->subsys.name);
ret = sysmon_send_shutdown(&esoc->subsys);
if (ret)
dev_err(mdm->dev, "Graceful shutdown fail, ret = %d\n",
ret);
@ -466,7 +466,7 @@ static void mdm_get_restart_reason(struct work_struct *work)
struct device *dev = mdm->dev;
do {
ret = sysmon_get_reason(mdm->esoc->subsys.name, sfr_buf,
ret = sysmon_get_reason(&mdm->esoc->subsys, sfr_buf,
sizeof(sfr_buf));
if (!ret) {
dev_err(dev, "mdm restart reason is %s\n", sfr_buf);

View File

@ -385,7 +385,7 @@ static void send_sysmon_notif(struct subsys_device *dev)
mutex_lock(&subsys_list_lock);
list_for_each_entry(subsys, &subsys_list, list)
if ((subsys->notif_state > 0) && (subsys != dev))
sysmon_send_event(dev->desc->name, subsys->desc->name,
sysmon_send_event(dev->desc, subsys->desc,
subsys->notif_state);
mutex_unlock(&subsys_list_lock);
}
@ -422,9 +422,8 @@ static void notify_each_subsys_device(struct subsys_device **list,
mutex_lock(&subsys_list_lock);
list_for_each_entry(subsys, &subsys_list, list)
if (dev != subsys)
sysmon_send_event(subsys->desc->name,
dev->desc->name,
notif);
sysmon_send_event(subsys->desc, dev->desc,
notif);
mutex_unlock(&subsys_list_lock);
if (notif == SUBSYS_AFTER_POWERUP)

View File

@ -26,7 +26,6 @@
#include <soc/qcom/subsystem_notif.h>
#include <soc/qcom/smd.h>
#define NAME_LENGTH 20
#define TX_BUF_SIZE 50
#define RX_BUF_SIZE 500
#define TIMEOUT_MS 5000
@ -44,8 +43,7 @@ struct sysmon_subsys {
char rx_buf[RX_BUF_SIZE];
enum transports transport;
struct device *dev;
char name[NAME_LENGTH];
int pid;
u32 pid;
struct list_head list;
};
@ -56,14 +54,6 @@ static const char *notif_name[SUBSYS_NOTIF_TYPE_COUNT] = {
[SUBSYS_AFTER_POWERUP] = "after_powerup",
};
static const char *subsys_name[SYSMON_NUM_SS] = {
[SYSMON_SS_WCNSS] = "wcnss",
[SYSMON_SS_MODEM] = "modem",
[SYSMON_SS_LPASS] = "adsp",
[SYSMON_SS_Q6FW] = "modem_fw",
[SYSMON_SS_EXT_MODEM] = "esoc0",
};
static LIST_HEAD(sysmon_list);
static DEFINE_MUTEX(sysmon_list_lock);
@ -126,8 +116,10 @@ static int sysmon_send_msg(struct sysmon_subsys *ss, const char *tx_buf,
/**
* sysmon_send_event() - Notify a subsystem of another's state change
* @dest_ss: String name of the subsystem the notification should be sent to
* @event_ss: String name of the subsystem that generated the notification
* @dest_desc: Subsystem descriptor of the subsystem the notification
* should be sent to
* @event_desc: Subsystem descriptor of the subsystem that generated the
* notification
* @notif: ID of the notification type (ex. SUBSYS_BEFORE_SHUTDOWN)
*
* Returns 0 for success, -EINVAL for invalid destination or notification IDs,
@ -137,17 +129,19 @@ static int sysmon_send_msg(struct sysmon_subsys *ss, const char *tx_buf,
*
* If CONFIG_MSM_SYSMON_COMM is not defined, always return success (0).
*/
int sysmon_send_event(const char *dest_ss, const char *event_ss,
enum subsys_notif_type notif)
int sysmon_send_event(struct subsys_desc *dest_desc,
struct subsys_desc *event_desc,
enum subsys_notif_type notif)
{
char tx_buf[TX_BUF_SIZE];
int ret;
struct sysmon_subsys *tmp, *ss = NULL;
const char *event_ss = event_desc->name;
mutex_lock(&sysmon_list_lock);
list_for_each_entry(tmp, &sysmon_list, list)
if (!strcmp(tmp->name, dest_ss))
if (tmp->pid == dest_desc->sysmon_pid)
ss = tmp;
mutex_unlock(&sysmon_list_lock);
@ -177,9 +171,8 @@ out:
}
/**
* sysmon_send_shutdown() - send shutdown command to a
* subsystem.
* @dest_ss: String name of the subsystem to send to.
* sysmon_send_shutdown() - send shutdown command to a subsystem.
* @dest_desc: Subsystem descriptor of the subsystem to send to
*
* Returns 0 for success, -EINVAL for an invalid destination, -ENODEV if
* the SMD transport channel is not open, -ETIMEDOUT if the destination
@ -188,7 +181,7 @@ out:
*
* If CONFIG_MSM_SYSMON_COMM is not defined, always return success (0).
*/
int sysmon_send_shutdown(const char *dest_ss)
int sysmon_send_shutdown(struct subsys_desc *dest_desc)
{
struct sysmon_subsys *tmp, *ss = NULL;
const char tx_buf[] = "system:shutdown";
@ -198,7 +191,7 @@ int sysmon_send_shutdown(const char *dest_ss)
mutex_lock(&sysmon_list_lock);
list_for_each_entry(tmp, &sysmon_list, list)
if (!strcmp(tmp->name, dest_ss))
if (tmp->pid == dest_desc->sysmon_pid)
ss = tmp;
mutex_unlock(&sysmon_list_lock);
@ -222,7 +215,7 @@ out:
/**
* sysmon_get_reason() - Retrieve failure reason from a subsystem.
* @dest_ss: String name of the subsystem to query
* @dest_desc: Subsystem descriptor of the subsystem to query
* @buf: Caller-allocated buffer for the returned NUL-terminated reason
* @len: Length of @buf
*
@ -233,7 +226,7 @@ out:
*
* If CONFIG_MSM_SYSMON_COMM is not defined, always return success (0).
*/
int sysmon_get_reason(const char *dest_ss, char *buf, size_t len)
int sysmon_get_reason(struct subsys_desc *dest_desc, char *buf, size_t len)
{
struct sysmon_subsys *tmp, *ss = NULL;
const char tx_buf[] = "ssr:retrieve:sfr";
@ -243,7 +236,7 @@ int sysmon_get_reason(const char *dest_ss, char *buf, size_t len)
mutex_lock(&sysmon_list_lock);
list_for_each_entry(tmp, &sysmon_list, list)
if (!strcmp(tmp->name, dest_ss))
if (tmp->pid == dest_desc->sysmon_pid)
ss = tmp;
mutex_unlock(&sysmon_list_lock);
@ -311,8 +304,6 @@ static int sysmon_probe(struct platform_device *pdev)
return ret;
}
} else if (pdev->id < SMD_NUM_TYPE) {
if (subsys_name[pdev->id] == NULL)
return -EINVAL;
ss->transport = TRANSPORT_SMD;
ret = smd_named_open_on_edge("sys_mon", pdev->id, &ss->chan,
ss, sysmon_smd_notify);
@ -326,7 +317,6 @@ static int sysmon_probe(struct platform_device *pdev)
ss->dev = &pdev->dev;
ss->pid = pdev->id;
strlcpy(ss->name, subsys_name[pdev->id], ARRAY_SIZE(ss->name));
mutex_lock(&sysmon_list_lock);
INIT_LIST_HEAD(&ss->list);

View File

@ -17,6 +17,7 @@
#include <soc/qcom/smd.h>
#include <soc/qcom/subsystem_notif.h>
#include <soc/qcom/subsystem_restart.h>
/**
* enum subsys_id - Destination subsystems for events.
@ -35,23 +36,24 @@ enum subsys_id {
};
#ifdef CONFIG_MSM_SYSMON_COMM
int sysmon_send_event(const char *dest_ss, const char *event_ss,
enum subsys_notif_type notif);
int sysmon_get_reason(const char *dest_ss, char *buf, size_t len);
int sysmon_send_shutdown(const char *dest_ss);
int sysmon_send_event(struct subsys_desc *dest_desc,
struct subsys_desc *event_desc,
enum subsys_notif_type notif);
int sysmon_get_reason(struct subsys_desc *dest_desc, char *buf, size_t len);
int sysmon_send_shutdown(struct subsys_desc *dest_desc);
#else
static inline int sysmon_send_event(const char *dest_ss,
const char *event_ss,
enum subsys_notif_type notif)
static inline int sysmon_send_event(struct subsys_desc *dest_desc,
struct subsys_desc *event_desc,
enum subsys_notif_type notif)
{
return 0;
}
static inline int sysmon_get_reason(const char *dest_ss, char *buf,
size_t len)
static inline int sysmon_get_reason(struct subsys_desc *dest_desc,
char *buf, size_t len)
{
return 0;
}
static inline int sysmon_send_shutdown(const char *dest_ss)
static inline int sysmon_send_shutdown(struct subsys_desc *dest_desc)
{
return 0;
}