static inline int msm_rpmstats_append_data_to_buf(char *buf, struct msm_rpm_stats_data_v2 *data, int buflength) { char stat_type[5]; u64 time_in_last_mode; u64 time_since_last_mode; u64 actual_last_sleep; stat_type[4] = 0; memcpy(stat_type, &data->stat_type, sizeof(u32)); time_in_last_mode = data->last_exited_at - data->last_entered_at; time_in_last_mode = get_time_in_msec(time_in_last_mode); time_since_last_mode = arch_counter_get_cntpct() - data->last_exited_at; time_since_last_mode = get_time_in_sec(time_since_last_mode); actual_last_sleep = get_time_in_msec(data->accumulated); return snprintf(buf , buflength, "RPM Mode:%s\n\t count:%d\ntime in last mode(msec):%llu\n" "time since last mode(sec):%llu\nactual last sleep(msec):%llu\n" "client votes: %#010x\n\n", stat_type, data->count, time_in_last_mode, time_since_last_mode, actual_last_sleep, data->client_votes); }
static int rpm_stats_resume(struct device *dev) { void __iomem *reg =0; struct msm_rpm_stats_data_v2 data; int i, length; char stat_type[5]; u64 time_in_last_mode; u64 time_since_last_mode; u64 actual_last_sleep; reg = ioremap_nocache(g_phys_addr_base, g_phys_size); if(!reg) { return 0; } for (i = 0, length = 0; i < 2; i++) { data.stat_type = msm_rpmstats_read_long_register_v2(reg, i, offsetof(struct msm_rpm_stats_data_v2, stat_type)); data.count = msm_rpmstats_read_long_register_v2(reg, i, offsetof(struct msm_rpm_stats_data_v2, count)); data.last_entered_at = msm_rpmstats_read_quad_register_v2(reg, i, offsetof(struct msm_rpm_stats_data_v2, last_entered_at)); data.last_exited_at = msm_rpmstats_read_quad_register_v2(reg, i, offsetof(struct msm_rpm_stats_data_v2, last_exited_at)); data.accumulated = msm_rpmstats_read_quad_register_v2(reg, i, offsetof(struct msm_rpm_stats_data_v2, accumulated)); if(0 == i) { data.client_votes = msm_rpmstats_read_quad_register_v2(reg, i, offsetof(struct msm_rpm_stats_data_v2, client_votes)); data.subsystem_votes = msm_rpmstats_read_quad_register_v2(reg, i, offsetof(struct msm_rpm_stats_data_v2, subsystem_votes)); } stat_type[4] = 0; memcpy(stat_type, &data.stat_type, sizeof(u32)); time_in_last_mode = data.last_exited_at - data.last_entered_at; time_in_last_mode = get_time_in_msec(time_in_last_mode); time_since_last_mode = arch_counter_get_cntpct() - data.last_exited_at; time_since_last_mode = get_time_in_sec(time_since_last_mode); actual_last_sleep = get_time_in_msec(data.accumulated); if(0 == i) { printk("[RPM] Resume: RPM Mode:%s\n\t count:%d\n time in last mode(msec):%llu\n" "time since last mode(sec):%llu\n actual last sleep(msec):%llu\n" "Client votes: 0x%x, Subsystem votes: 0x%x\n", stat_type, data.count, time_in_last_mode, time_since_last_mode, actual_last_sleep, data.client_votes, data.subsystem_votes); } else { printk("[RPM] Resume: RPM Mode:%s\n\t count:%d\n time in last mode(msec):%llu\n" "time since last mode(sec):%llu\n actual last sleep(msec):%llu\n", stat_type, data.count, time_in_last_mode, time_since_last_mode, actual_last_sleep); } }
static inline int msm_rpmstats_append_data_to_buf_v3(char *buf, struct msm_rpm_stats_data_v3 *data, int buflength, int index) { u64 total_time; total_time = data->total_duration; if (data->is_sleep_mode) total_time += (arch_counter_get_cntpct() - data->sleep_timestamp); total_time = get_time_in_msec(total_time); return snprintf(buf , buflength, "sleep_info.%d (%d)\n count:%d\n total time(msec):%llu\n", index, data->is_sleep_mode, data->count, total_time); }
/* * Read QTimer clock ticks and scale down to 32KHz clock as used * in DSPS */ static u32 sns_read_qtimer(void) { u64 val; val = arch_counter_get_cntpct(); /* * To convert ticks from 19.2 Mhz clock to 32768 Hz clock: * x = (value * 32768) / 19200000 * This is same as first left shift the value by 4 bits, i.e. mutiply * by 16, and then divide by 9375. The latter is preferable since * QTimer tick (value) is 56-bit, so (value * 32768) could overflow, * while (value * 16) will never do */ val <<= 4; do_div(val, 9375); return (u32)val; }
/** * msm_bus_scale_client_update_request() - Update the request for bandwidth * from a particular client * * cl: Handle to the client * index: Index into the vector, to which the bw and clock values need to be * updated */ int msm_bus_scale_client_update_request(uint32_t cl, unsigned index) { int i, ret = 0; struct msm_bus_scale_pdata *pdata; int pnode, src, curr, ctx; uint64_t req_clk, req_bw, curr_clk, curr_bw; struct msm_bus_client *client = (struct msm_bus_client *)cl; #ifdef DEBUG_MSM_BUS_ARB_REQ static int log_cnt = 0; #endif if (IS_ERR_OR_NULL(client)) { MSM_BUS_ERR("msm_bus_scale_client update req error %d\n", (uint32_t)client); return -ENXIO; } #ifdef SEC_FEATURE_USE_RT_MUTEX rt_mutex_lock(&msm_bus_lock); #else mutex_lock(&msm_bus_lock); #endif if (client->curr == index) goto err; curr = client->curr; pdata = client->pdata; if (!pdata) { MSM_BUS_ERR("Null pdata passed to update-request\n"); return -ENXIO; } if (index >= pdata->num_usecases) { MSM_BUS_ERR("Client %u passed invalid index: %d\n", (uint32_t)client, index); ret = -ENXIO; goto err; } MSM_BUS_DBG("cl: %u index: %d curr: %d num_paths: %d\n", cl, index, client->curr, client->pdata->usecase->num_paths); for (i = 0; i < pdata->usecase->num_paths; i++) { src = msm_bus_board_get_iid(client->pdata->usecase[index]. vectors[i].src); if (src == -ENXIO) { MSM_BUS_ERR("Master %d not supported. Request cannot" " be updated\n", client->pdata->usecase-> vectors[i].src); goto err; } if (msm_bus_board_get_iid(client->pdata->usecase[index]. vectors[i].dst) == -ENXIO) { MSM_BUS_ERR("Slave %d not supported. Request cannot" " be updated\n", client->pdata->usecase-> vectors[i].dst); } pnode = client->src_pnode[i]; req_clk = client->pdata->usecase[index].vectors[i].ib; req_bw = client->pdata->usecase[index].vectors[i].ab; #ifdef DEBUG_MSM_BUS_ARB_REQ //Debug code to collect client info { struct msm_bus_fabric_device *fabdev_d = msm_bus_get_fabric_device(GET_FABID(src)); if (MSM_BUS_FAB_APPSS == fabdev_d->id) { if (log_cnt >= 1000) log_cnt = 0; log_req[log_cnt].ab = client->pdata->usecase[index].vectors[i].ab; log_req[log_cnt].ib = client->pdata->usecase[index].vectors[i].ib; log_req[log_cnt].src = client->pdata->usecase[index].vectors[i].src; log_req[log_cnt].dst = client->pdata->usecase[index].vectors[i].dst; log_req[log_cnt].cnt = arch_counter_get_cntpct(); strncpy(log_req[log_cnt].name, client->pdata->name, 19); log_cnt++; //printk("*** cl: %s ab: %llu ib: %llu\n", client->pdata->name, req_bw, req_clk); } } #endif if (curr < 0) { curr_clk = 0; curr_bw = 0; } else { curr_clk = client->pdata->usecase[curr].vectors[i].ib; curr_bw = client->pdata->usecase[curr].vectors[i].ab; MSM_BUS_DBG("ab: %llu ib: %llu\n", curr_bw, curr_clk); } if (!pdata->active_only) { ret = update_path(src, pnode, req_clk, req_bw, curr_clk, curr_bw, 0, pdata->active_only); if (ret) { MSM_BUS_ERR("Update path failed! %d\n", ret); goto err; } } ret = update_path(src, pnode, req_clk, req_bw, curr_clk, curr_bw, ACTIVE_CTX, pdata->active_only); if (ret) { MSM_BUS_ERR("Update Path failed! %d\n", ret); goto err; } } client->curr = index; ctx = ACTIVE_CTX; msm_bus_dbg_client_data(client->pdata, index, cl); bus_for_each_dev(&msm_bus_type, NULL, NULL, msm_bus_commit_fn); err: #ifdef SEC_FEATURE_USE_RT_MUTEX rt_mutex_unlock(&msm_bus_lock); #else mutex_unlock(&msm_bus_lock); #endif return ret; }
wpt_uint64 wpalGetArchCounterTime(void) { return arch_counter_get_cntpct(); }/*wpalGetArchCounterTime*/
static cycle_t arch_counter_read(void) { return arch_counter_get_cntpct(); }
int wlan_log_to_user(VOS_TRACE_LEVEL log_level, char *to_be_sent, int length) { /* Add the current time stamp */ char *ptr; char tbuf[100]; int tlen; int total_log_len; unsigned int *pfilled_length; bool wake_up_thread = false; unsigned long flags; struct timeval tv; struct rtc_time tm; unsigned long local_time; u64 qtimer_ticks; if (!vos_is_multicast_logging()) { /* * This is to make sure that we print the logs to kmsg console * when no logger app is running. This is also needed to * log the initial messages during loading of driver where even * if app is running it will not be able to * register with driver immediately and start logging all the * messages. */ pr_err("%s\n", to_be_sent); } else { /* Format the Log time [hr:min:sec.microsec] */ do_gettimeofday(&tv); /* Convert rtc to local time */ local_time = (u32)(tv.tv_sec - (sys_tz.tz_minuteswest * 60)); rtc_time_to_tm(local_time, &tm); /* Firmware Time Stamp */ qtimer_ticks = arch_counter_get_cntpct(); tlen = snprintf(tbuf, sizeof(tbuf), "[%02d:%02d:%02d.%06lu] [%016llX]" " [%.5s] ", tm.tm_hour, tm.tm_min, tm.tm_sec, tv.tv_usec, qtimer_ticks, current->comm); /* 1+1 indicate '\n'+'\0' */ total_log_len = length + tlen + 1 + 1; spin_lock_irqsave(&gwlan_logging.spin_lock, flags); // wlan logging svc resources are not yet initialized if (!gwlan_logging.pcur_node) { spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags); return -EIO; } pfilled_length = &gwlan_logging.pcur_node->filled_length; /* Check if we can accomodate more log into current node/buffer */ if (MAX_LOGMSG_LENGTH < (*pfilled_length + sizeof(tAniNlHdr) + total_log_len)) { wake_up_thread = true; wlan_queue_logmsg_for_app(); pfilled_length = &gwlan_logging.pcur_node->filled_length; } ptr = &gwlan_logging.pcur_node->logbuf[sizeof(tAniHdr)]; /* Assumption here is that we receive logs which is always less than * MAX_LOGMSG_LENGTH, where we can accomodate the * tAniNlHdr + [context][timestamp] + log * VOS_ASSERT if we cannot accomodate the the complete log into * the available buffer. * * Continue and copy logs to the available length and discard the rest. */ if (MAX_LOGMSG_LENGTH < (sizeof(tAniNlHdr) + total_log_len)) { VOS_ASSERT(0); total_log_len = MAX_LOGMSG_LENGTH - sizeof(tAniNlHdr) - 2; } vos_mem_copy(&ptr[*pfilled_length], tbuf, tlen); vos_mem_copy(&ptr[*pfilled_length + tlen], to_be_sent, min(length, (total_log_len - tlen))); *pfilled_length += tlen + min(length, total_log_len - tlen); ptr[*pfilled_length] = '\n'; *pfilled_length += 1; spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags); /* Wakeup logger thread */ if ((true == wake_up_thread)) { /* If there is logger app registered wakeup the logging * thread */ set_bit(HOST_LOG_POST, &gwlan_logging.event_flag); wake_up_interruptible(&gwlan_logging.wait_queue); } if (gwlan_logging.log_fe_to_console && ((VOS_TRACE_LEVEL_FATAL == log_level) || (VOS_TRACE_LEVEL_ERROR == log_level))) { pr_err("%s %s\n",tbuf, to_be_sent); } } return 0; }
int read_current_timer(unsigned long *timer_value) { *timer_value = arch_counter_get_cntpct(); return 0; }
static cycle_t arch_counter_read(struct clocksource *cs) { return arch_counter_get_cntpct(); }