Merge "qcom: sysmon: Add support to skip transaction_id on old ssctl event"

This commit is contained in:
qctecmdr 2023-09-09 03:31:11 -07:00 committed by Gerrit - the friendly Code Review server
commit 0f32661228

View File

@ -212,9 +212,10 @@ struct ssctl_subsys_event_with_tid_req {
u8 subsys_name_len; u8 subsys_name_len;
char subsys_name[SSCTL_SUBSYS_NAME_LENGTH]; char subsys_name[SSCTL_SUBSYS_NAME_LENGTH];
u32 event; u32 event;
uint32_t transaction_id;
u8 evt_driven_valid; u8 evt_driven_valid;
u32 evt_driven; u32 evt_driven;
u8 transaction_id_valid;
uint32_t transaction_id;
}; };
static struct qmi_elem_info ssctl_subsys_event_with_tid_req_ei[] = { static struct qmi_elem_info ssctl_subsys_event_with_tid_req_ei[] = {
@ -248,6 +249,16 @@ static struct qmi_elem_info ssctl_subsys_event_with_tid_req_ei[] = {
event), event),
.ei_array = NULL, .ei_array = NULL,
}, },
{
.data_type = QMI_OPT_FLAG,
.elem_len = 1,
.elem_size = sizeof(uint8_t),
.array_type = NO_ARRAY,
.tlv_type = 0x03,
.offset = offsetof(struct ssctl_subsys_event_with_tid_req,
transaction_id_valid),
.ei_array = NULL,
},
{ {
.data_type = QMI_UNSIGNED_4_BYTE, .data_type = QMI_UNSIGNED_4_BYTE,
.elem_len = 1, .elem_len = 1,
@ -392,22 +403,22 @@ static bool ssctl_request_shutdown(struct qcom_sysmon *sysmon)
* @sysmon: sysmon context * @sysmon: sysmon context
* @event: sysmon event context * @event: sysmon event context
*/ */
static void ssctl_send_event(struct qcom_sysmon *sysmon, static int ssctl_send_event(struct qcom_sysmon *sysmon,
const struct qcom_sysmon *source) const struct qcom_sysmon *source, bool is_tid_valid)
{ {
struct ssctl_subsys_event_with_tid_resp resp; struct ssctl_subsys_event_with_tid_resp resp;
struct ssctl_subsys_event_with_tid_req req; struct ssctl_subsys_event_with_tid_req req;
struct qmi_txn txn; struct qmi_txn txn;
int ret; int ret, ssctl_event;
if (sysmon->ssctl_instance == -EINVAL) if (sysmon->ssctl_instance == -EINVAL)
return; return -EINVAL;
memset(&resp, 0, sizeof(resp)); memset(&resp, 0, sizeof(resp));
ret = qmi_txn_init(&sysmon->qmi, &txn, ssctl_subsys_event_with_tid_resp_ei, &resp); ret = qmi_txn_init(&sysmon->qmi, &txn, ssctl_subsys_event_with_tid_resp_ei, &resp);
if (ret < 0) { if (ret < 0) {
dev_err(sysmon->dev, "failed to allocate QMI txn\n"); dev_err(sysmon->dev, "failed to allocate QMI txn\n");
return; return ret;
} }
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
@ -416,26 +427,34 @@ static void ssctl_send_event(struct qcom_sysmon *sysmon,
req.event = source->state; req.event = source->state;
req.evt_driven_valid = true; req.evt_driven_valid = true;
req.evt_driven = SSCTL_SSR_EVENT_FORCED; req.evt_driven = SSCTL_SSR_EVENT_FORCED;
req.transaction_id_valid = is_tid_valid ? false : true;
req.transaction_id = sysmon->transaction_id; req.transaction_id = sysmon->transaction_id;
ssctl_event = is_tid_valid ? SSCTL_SUBSYS_EVENT_REQ : SSCTL_SUBSYS_EVENT_WITH_TID_REQ;
ret = qmi_send_request(&sysmon->qmi, &sysmon->ssctl, &txn, ret = qmi_send_request(&sysmon->qmi, &sysmon->ssctl, &txn,
SSCTL_SUBSYS_EVENT_WITH_TID_REQ, 40, ssctl_event, 40, ssctl_subsys_event_with_tid_req_ei, &req);
ssctl_subsys_event_with_tid_req_ei, &req);
if (ret < 0) { if (ret < 0) {
dev_err(sysmon->dev, "failed to send shutdown request\n"); dev_err(sysmon->dev, "failed to send shutdown request\n");
qmi_txn_cancel(&txn); qmi_txn_cancel(&txn);
return; return ret;
} }
ret = qmi_txn_wait(&txn, 5 * HZ); ret = qmi_txn_wait(&txn, 5 * HZ);
if (ret < 0) if (ret < 0) {
dev_err(sysmon->dev, "failed receiving QMI response\n"); dev_err(sysmon->dev, "failed receiving QMI response\n");
else if (resp.resp.result) return ret;
dev_err(sysmon->dev, "failed to receive %s ssr %s event. response result: %d\n", }
if (resp.resp.result) {
dev_err(sysmon->dev, "failed to receive %s ssr %s event. response result: %d error: %d\n",
source->name, subdevice_state_string[source->state], source->name, subdevice_state_string[source->state],
resp.resp.result); resp.resp.result, resp.resp.error);
else return resp.resp.result;
dev_dbg(sysmon->dev, "ssr event send completed\n"); }
dev_dbg(sysmon->dev, "ssr event send completed\n");
return 0;
} }
/** /**
@ -529,6 +548,7 @@ static void sysmon_shutdown_notif_timeout_handler(struct timer_list *t)
static inline void send_event(struct qcom_sysmon *sysmon, struct qcom_sysmon *source) static inline void send_event(struct qcom_sysmon *sysmon, struct qcom_sysmon *source)
{ {
unsigned long timeout; unsigned long timeout;
int ret;
source->timeout_data.timer.function = sysmon_notif_timeout_handler; source->timeout_data.timer.function = sysmon_notif_timeout_handler;
source->timeout_data.dest = sysmon; source->timeout_data.dest = sysmon;
@ -536,8 +556,17 @@ static inline void send_event(struct qcom_sysmon *sysmon, struct qcom_sysmon *so
mod_timer(&source->timeout_data.timer, timeout); mod_timer(&source->timeout_data.timer, timeout);
/* Only SSCTL version 2 supports SSR events */ /* Only SSCTL version 2 supports SSR events */
if (sysmon->ssctl_version == 2) if (sysmon->ssctl_version == 2) {
ssctl_send_event(sysmon, source); ret = ssctl_send_event(sysmon, source, false);
if (ret == QMI_RESULT_FAILURE_V01) {
/* Retry with older ssctl event */
dev_dbg(sysmon->dev, "Retrying with no trascation id request\n");
ret = ssctl_send_event(sysmon, source, true);
}
/* if ret !=1 we don't retry */
if (ret)
pr_err("Failed to send event\n");
}
else if (sysmon->ept) else if (sysmon->ept)
sysmon_send_event(sysmon, source); sysmon_send_event(sysmon, source);