diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2015-06-27 07:29:20 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-06-27 07:29:20 -0700 |
commit | 4fb9a0ed1338c51898f3b89836895bd583a7b7b4 (patch) | |
tree | 15cea168ac5aa73015d4f8a2f60f0457de9a43fa | |
parent | 599f4bf2b46a6a32650f3bb28ae07b7d97b5f128 (diff) | |
parent | c111b2a4e76d4d183335e5d23e6d2a2112a70daa (diff) | |
download | qcom-4fb9a0ed1338c51898f3b89836895bd583a7b7b4.tar.gz |
Merge "qcom:rpm-smd: Add debug ftrace events"
-rw-r--r-- | drivers/soc/qcom/rpm-smd.c | 182 | ||||
-rw-r--r-- | include/trace/events/trace_rpm_smd.h | 74 |
2 files changed, 148 insertions, 108 deletions
diff --git a/drivers/soc/qcom/rpm-smd.c b/drivers/soc/qcom/rpm-smd.c index e57d0229f86..8035a880c0b 100644 --- a/drivers/soc/qcom/rpm-smd.c +++ b/drivers/soc/qcom/rpm-smd.c @@ -309,12 +309,87 @@ static void tr_update(struct slp_buf *s, char *buf) } } } +static atomic_t msm_rpm_msg_id = ATOMIC_INIT(0); + +struct msm_rpm_request { + struct rpm_request_header req_hdr; + struct rpm_message_header msg_hdr; + struct msm_rpm_kvp_data *kvp; + uint32_t num_elements; + uint32_t write_idx; + uint8_t *buf; + uint32_t numbytes; +}; + +/* + * Data related to message acknowledgement + */ + +LIST_HEAD(msm_rpm_wait_list); + +struct msm_rpm_wait_data { + struct list_head list; + uint32_t msg_id; + bool ack_recd; + int errno; + struct completion ack; +}; +DEFINE_SPINLOCK(msm_rpm_list_lock); + +struct msm_rpm_ack_msg { + uint32_t req; + uint32_t req_len; + uint32_t rsc_id; + uint32_t msg_len; + uint32_t id_ack; +}; + +LIST_HEAD(msm_rpm_ack_list); + +static DECLARE_COMPLETION(data_ready); -int msm_rpm_smd_buffer_request(char *buf, uint32_t size, gfp_t flag) +static inline uint32_t msm_rpm_get_msg_id_from_ack(uint8_t *buf) +{ + return ((struct msm_rpm_ack_msg *)buf)->id_ack; +} + +static inline int msm_rpm_get_error_from_ack(uint8_t *buf) +{ + uint8_t *tmp; + uint32_t req_len = ((struct msm_rpm_ack_msg *)buf)->req_len; + + int rc = -ENODEV; + + req_len -= sizeof(struct msm_rpm_ack_msg); + req_len += 2 * sizeof(uint32_t); + if (!req_len) + return 0; + + tmp = buf + sizeof(struct msm_rpm_ack_msg); + + BUG_ON(memcmp(tmp, ERR, sizeof(uint32_t))); + + tmp += 2 * sizeof(uint32_t); + + if (!(memcmp(tmp, INV_RSC, min_t(uint32_t, req_len, + sizeof(INV_RSC))-1))) { + pr_err("%s(): RPM NACK Unsupported resource\n", __func__); + rc = -EINVAL; + } else { + pr_err("%s(): RPM NACK Invalid header\n", __func__); + } + + return rc; +} + +int msm_rpm_smd_buffer_request(struct msm_rpm_request *cdata, + uint32_t size, gfp_t flag) { struct slp_buf *slp; static DEFINE_SPINLOCK(slp_buffer_lock); unsigned long flags; + char *buf; + buf = cdata->buf; if (size > MAX_SLEEP_BUFFER) return -ENOMEM; @@ -337,6 +412,9 @@ int msm_rpm_smd_buffer_request(char *buf, uint32_t size, gfp_t flag) /* handle unsent requests */ tr_update(slp, buf); } + trace_rpm_smd_sleep_set(cdata->msg_hdr.msg_id, + cdata->msg_hdr.resource_type, + cdata->msg_hdr.resource_id); spin_unlock_irqrestore(&slp_buffer_lock, flags); @@ -412,15 +490,13 @@ static int msm_rpm_flush_requests(bool print) get_buf_len(s->buf), true); WARN_ON(ret != get_buf_len(s->buf)); + trace_rpm_smd_send_sleep_set(get_msg_id(s->buf), + get_rsc_type(s->buf), + get_rsc_id(s->buf)); s->valid = false; count++; - trace_rpm_send_message(true, MSM_RPM_CTX_SLEEP_SET, - get_rsc_type(s->buf), - get_rsc_id(s->buf), - get_msg_id(s->buf)); - /* * RPM acks need to be handled here if we have sent 24 * messages such that we do not overrun SMD buffer. Since @@ -464,44 +540,6 @@ static int msm_rpm_flush_requests(bool print) return 0; } -static atomic_t msm_rpm_msg_id = ATOMIC_INIT(0); - -struct msm_rpm_request { - struct rpm_request_header req_hdr; - struct rpm_message_header msg_hdr; - struct msm_rpm_kvp_data *kvp; - uint32_t num_elements; - uint32_t write_idx; - uint8_t *buf; - uint32_t numbytes; -}; - -/* - * Data related to message acknowledgement - */ - -LIST_HEAD(msm_rpm_wait_list); - -struct msm_rpm_wait_data { - struct list_head list; - uint32_t msg_id; - bool ack_recd; - int errno; - struct completion ack; -}; -DEFINE_SPINLOCK(msm_rpm_list_lock); - -struct msm_rpm_ack_msg { - uint32_t req; - uint32_t req_len; - uint32_t rsc_id; - uint32_t msg_len; - uint32_t id_ack; -}; - -LIST_HEAD(msm_rpm_ack_list); - -static DECLARE_COMPLETION(data_ready); static void msm_rpm_notify_sleep_chain(struct rpm_message_header *hdr, struct msm_rpm_kvp_data *kvp) @@ -697,6 +735,7 @@ static void msm_rpm_notify(void *data, unsigned event) switch (event) { case SMD_EVENT_DATA: + trace_rpm_smd_interrupt_notify("interrupt notification"); complete(&data_ready); break; case SMD_EVENT_OPEN: @@ -813,7 +852,7 @@ static void msm_rpm_process_ack(uint32_t msg_id, int errno) * entering RPM assisted power collapse. */ if (!elem) - trace_rpm_ack_recd(0, msg_id); + trace_rpm_smd_ack_recvd(0, msg_id, 0xDEADBEEF); spin_unlock_irqrestore(&msm_rpm_list_lock, flags); } @@ -824,39 +863,6 @@ struct msm_rpm_kvp_packet { uint32_t val; }; -static inline uint32_t msm_rpm_get_msg_id_from_ack(uint8_t *buf) -{ - return ((struct msm_rpm_ack_msg *)buf)->id_ack; -} - -static inline int msm_rpm_get_error_from_ack(uint8_t *buf) -{ - uint8_t *tmp; - uint32_t req_len = ((struct msm_rpm_ack_msg *)buf)->req_len; - - int rc = -ENODEV; - - req_len -= sizeof(struct msm_rpm_ack_msg); - req_len += 2 * sizeof(uint32_t); - if (!req_len) - return 0; - - tmp = buf + sizeof(struct msm_rpm_ack_msg); - - BUG_ON(memcmp(tmp, ERR, sizeof(uint32_t))); - - tmp += 2 * sizeof(uint32_t); - - if (!(memcmp(tmp, INV_RSC, min_t(uint32_t, req_len, - sizeof(INV_RSC))-1))) { - pr_err("%s(): RPM NACK Unsupported resource\n", __func__); - rc = -EINVAL; - } else { - pr_err("%s(): RPM NACK Invalid header\n", __func__); - } - - return rc; -} static int msm_rpm_read_smd_data(char *buf) { @@ -901,7 +907,8 @@ static void msm_rpm_smd_work(struct work_struct *work) if (msm_rpm_read_smd_data(buf)) break; msg_id = msm_rpm_get_msg_id_from_ack(buf); - errno = msm_rpm_get_error_from_ack(buf); + errno = msm_rpm_get_error_from_ack((uint8_t *)buf); + trace_rpm_smd_ack_recvd(0, msg_id, errno); msm_rpm_process_ack(msg_id, errno); } spin_unlock(&msm_rpm_data.smd_lock_read); @@ -1135,7 +1142,7 @@ static int msm_rpm_send_data(struct msm_rpm_request *cdata, memcpy(cdata->buf, &cdata->req_hdr, req_hdr_sz + msg_hdr_sz); if ((cdata->msg_hdr.set == MSM_RPM_CTX_SLEEP_SET) && - !msm_rpm_smd_buffer_request(cdata->buf, msg_size, + !msm_rpm_smd_buffer_request(cdata, msg_size, GFP_FLAG(noirq))) return 1; @@ -1161,19 +1168,18 @@ static int msm_rpm_send_data(struct msm_rpm_request *cdata, ret = msm_rpm_send_smd_buffer(&cdata->buf[0], msg_size, noirq); if (ret == msg_size) { - trace_rpm_send_message(noirq, cdata->msg_hdr.set, - cdata->msg_hdr.resource_type, - cdata->msg_hdr.resource_id, - cdata->msg_hdr.msg_id); for (i = 0; (i < cdata->write_idx); i++) cdata->kvp[i].valid = false; cdata->msg_hdr.data_len = 0; ret = cdata->msg_hdr.msg_id; + trace_rpm_smd_send_active_set(cdata->msg_hdr.msg_id, + cdata->msg_hdr.resource_type, + cdata->msg_hdr.resource_id); } else if (ret < msg_size) { struct msm_rpm_wait_data *rc; ret = 0; - pr_err("Failed to write data msg_size:%d ret:%d\n", - msg_size, ret); + pr_err("Failed to write data msg_size:%d ret:%d msg_id:%d\n", + msg_size, ret, cdata->msg_hdr.msg_id); rc = msm_rpm_get_entry_from_msg_id(cdata->msg_hdr.msg_id); if (rc) msm_rpm_free_list_entry(rc); @@ -1221,7 +1227,7 @@ int msm_rpm_wait_for_ack(uint32_t msg_id) return rc; wait_for_completion(&elem->ack); - trace_rpm_ack_recd(0, msg_id); + trace_rpm_smd_ack_recvd(0, msg_id, 0xDEADFEED); rc = elem->errno; msm_rpm_free_list_entry(elem); @@ -1272,12 +1278,12 @@ int msm_rpm_wait_for_ack_noirq(uint32_t msg_id) msm_rpm_read_smd_data(buf); id = msm_rpm_get_msg_id_from_ack(buf); errno = msm_rpm_get_error_from_ack(buf); + trace_rpm_smd_ack_recvd(1, msg_id, errno); msm_rpm_process_ack(id, errno); } } rc = elem->errno; - trace_rpm_ack_recd(1, msg_id); msm_rpm_free_list_entry(elem); wait_ack_cleanup: diff --git a/include/trace/events/trace_rpm_smd.h b/include/trace/events/trace_rpm_smd.h index f93baf4228b..c43f03058e5 100644 --- a/include/trace/events/trace_rpm_smd.h +++ b/include/trace/events/trace_rpm_smd.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2012, 2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012, 2014-2015, 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 @@ -18,60 +18,94 @@ #include <linux/tracepoint.h> -TRACE_EVENT(rpm_ack_recd, +TRACE_EVENT(rpm_smd_ack_recvd, - TP_PROTO(unsigned int irq, unsigned int msg_id), + TP_PROTO(unsigned int irq, unsigned int msg_id, int errno), - TP_ARGS(irq, msg_id), + TP_ARGS(irq, msg_id, errno), TP_STRUCT__entry( __field(int, irq) __field(int, msg_id) + __field(int, errno) ), TP_fast_assign( __entry->irq = irq; __entry->msg_id = msg_id; + __entry->errno = errno; ), - TP_printk("ctx:%s id:%d", + TP_printk("ctx:%s msg_id:%d errno:%08x", __entry->irq ? "noslp" : "sleep", - __entry->msg_id) + __entry->msg_id, + __entry->errno) ); -TRACE_EVENT(rpm_send_message, +TRACE_EVENT(rpm_smd_interrupt_notify, - TP_PROTO(unsigned int irq, unsigned int set, unsigned int rsc_type, - unsigned int rsc_id, unsigned int msg_id), + TP_PROTO(char *dummy), - TP_ARGS(irq, set, rsc_type, rsc_id, msg_id), + TP_ARGS(dummy), TP_STRUCT__entry( - __field(u32, irq) - __field(u32, set) + __field(char *, dummy) + ), + + TP_fast_assign( + __entry->dummy = dummy; + ), + + TP_printk("%s", __entry->dummy) +); + +DECLARE_EVENT_CLASS(rpm_send_msg, + + TP_PROTO(unsigned int msg_id, unsigned int rsc_type, + unsigned int rsc_id), + + TP_ARGS(msg_id, rsc_type, rsc_id), + + TP_STRUCT__entry( + __field(u32, msg_id) __field(u32, rsc_type) __field(u32, rsc_id) - __field(u32, msg_id) __array(char, name, 5) ), TP_fast_assign( - __entry->irq = irq; + __entry->msg_id = msg_id; __entry->name[4] = 0; - __entry->set = set; __entry->rsc_type = rsc_type; __entry->rsc_id = rsc_id; - __entry->msg_id = msg_id; memcpy(__entry->name, &rsc_type, sizeof(uint32_t)); ), - TP_printk("ctx:%s set:%s rsc_type:0x%08x(%s), rsc_id:0x%08x, id:%d", - __entry->irq ? "noslp" : "sleep", - __entry->set ? "slp" : "act", + TP_printk("msg_id:%d, rsc_type:0x%08x(%s), rsc_id:0x%08x", + __entry->msg_id, __entry->rsc_type, __entry->name, - __entry->rsc_id, __entry->msg_id) + __entry->rsc_id) +); + +DEFINE_EVENT(rpm_send_msg, rpm_smd_sleep_set, + TP_PROTO(unsigned int msg_id, unsigned int rsc_type, + unsigned int rsc_id), + TP_ARGS(msg_id, rsc_type, rsc_id) ); + +DEFINE_EVENT(rpm_send_msg, rpm_smd_send_sleep_set, + TP_PROTO(unsigned int msg_id, unsigned int rsc_type, + unsigned int rsc_id), + TP_ARGS(msg_id, rsc_type, rsc_id) +); + +DEFINE_EVENT(rpm_send_msg, rpm_smd_send_active_set, + TP_PROTO(unsigned int msg_id, unsigned int rsc_type, + unsigned int rsc_id), + TP_ARGS(msg_id, rsc_type, rsc_id) +); + #endif #define TRACE_INCLUDE_FILE trace_rpm_smd #include <trace/define_trace.h> |