void rpc_print_iostats(struct seq_file *seq, struct rpc_clnt *clnt) { struct rpc_iostats *stats = clnt->cl_metrics; struct rpc_xprt *xprt = clnt->cl_xprt; unsigned int op, maxproc = clnt->cl_maxproc; if (!stats) return; seq_printf(seq, "\tRPC iostats version: %s ", RPC_IOSTATS_VERS); seq_printf(seq, "p/v: %u/%u (%s)\n", clnt->cl_prog, clnt->cl_vers, clnt->cl_protname); if (xprt) xprt->ops->print_stats(xprt, seq); seq_printf(seq, "\tper-op statistics\n"); for (op = 0; op < maxproc; op++) { struct rpc_iostats *metrics = &stats[op]; _print_name(seq, op, clnt->cl_procinfo); seq_printf(seq, "%lu %lu %lu %Lu %Lu %Lu %Lu %Lu\n", metrics->om_ops, metrics->om_ntrans, metrics->om_timeouts, metrics->om_bytes_sent, metrics->om_bytes_recv, ktime_to_ms(metrics->om_queue), ktime_to_ms(metrics->om_rtt), ktime_to_ms(metrics->om_execute)); } }
static int do_fsync(unsigned int fd, int datasync) { struct file *file; int ret = -EBADF; ktime_t fsync_t, fsync_diff; char pathname[256], *path; file = fget(fd); if (file) { path = d_path(&(file->f_path), pathname, sizeof(pathname)); if (IS_ERR(path)) path = "(unknown)"; fsync_t = ktime_get(); ret = vfs_fsync(file, datasync); fput(file); fsync_diff = ktime_sub(ktime_get(), fsync_t); if (ktime_to_ms(fsync_diff) >= 5000) { pr_info("VFS: %s pid:%d(%s)(parent:%d/%s) takes %lld ms to fsync %s.\n", __func__, current->pid, current->comm, current->parent->pid, current->parent->comm, ktime_to_ms(fsync_diff), path); } } return ret; }
void aic3008_CodecInit() { AUD_DBG("aic3008_CodecInit: start\n"); pwr_up_time = ktime_to_ms(ktime_get()); pr_device_power_on(); // aic3008 power up aic3008_power_ctl->powerinit(); // close mic aic3008_MicSwitch(0); spi_write_table_parsepage(POWER_UP_SEQ, ARRAY_SIZE(POWER_UP_SEQ)); AUD_DBG("***** SPI CMD: Power Up Seq *****\n"); AUD_DBG("Audio Codec Power Up takes %lld ms\n", ktime_to_ms(ktime_get()) - pwr_up_time); #if AUDIO_DEBUG_BEEP mdelay(100); spi_write_table_parsepage(GENERATE_BEEP_LEFT_SPK, ARRAY_SIZE(GENERATE_BEEP_LEFT_SPK)); AUD_DBG("***** SPI CMD: BEEP *****\n"); mdelay(300); spi_write_table_parsepage(CODEC_SW_RESET, ARRAY_SIZE(CODEC_SW_RESET)); #endif aic3008_rx_mode = DOWNLINK_PATH_OFF; aic3008_tx_mode = UPLINK_PATH_OFF; }
static int do_fsync(unsigned int fd, int datasync) { struct file *file; int ret = -EBADF; int fput_needed; #ifdef CONFIG_ASYNC_FSYNC struct fsync_work *fwork; #endif if (!fsync_enabled) return 0; file = fget_light(fd, &fput_needed); if (file) { #ifdef CONFIG_ASYNC_FSYNC ktime_t fsync_t, fsync_diff; char pathname[256], *path; path = d_path(&(file->f_path), pathname, sizeof(pathname)); if (IS_ERR(path)) path = "(unknown)"; else if (async_fsync(file, fd)) { if (!fsync_workqueue) fsync_workqueue = create_singlethread_workqueue("fsync"); if (!fsync_workqueue) goto no_async; if (IS_ERR(path)) goto no_async; fwork = kmalloc(sizeof(*fwork), GFP_KERNEL); if (fwork) { strncpy(fwork->pathname, path, sizeof(fwork->pathname) - 1); INIT_WORK(&fwork->work, do_afsync_work); queue_work(fsync_workqueue, &fwork->work); fput_light(file, fput_needed); return 0; } } no_async: fsync_t = ktime_get(); #endif ret = vfs_fsync(file, datasync); fput_light(file, fput_needed); #ifdef CONFIG_ASYNC_FSYNC fsync_diff = ktime_sub(ktime_get(), fsync_t); if (ktime_to_ms(fsync_diff) >= 5000) { pr_info("VFS: %s pid:%d(%s)(parent:%d/%s)\ takes %lld ms to fsync %s.\n", __func__, current->pid, current->comm, current->parent->pid, current->parent->comm, ktime_to_ms(fsync_diff), path); } #endif } return ret; }
static void aic3008_powerup(void) { int64_t t1, t2; t1 = ktime_to_ms(ktime_get()); aic3008_power_ctl->resume(); t2 = ktime_to_ms(ktime_get()) - t1; AUD_INFO("[PWR] power on AIC3008 %lldms\n", t2); return; }
static int mp_decision(void) { static bool first_call = true; int new_state = TEGRA_HP_IDLE; int nr_cpu_online; int index; unsigned int rq_depth; static cputime64_t total_time = 0; static cputime64_t last_time; cputime64_t current_time; cputime64_t this_time = 0; current_time = ktime_to_ms(ktime_get()); if (first_call) { first_call = false; } else { this_time = current_time - last_time; } total_time += this_time; rq_depth = get_rq_info(); nr_cpu_online = num_online_cpus(); mutex_lock(&tegra3_mp_lock); if (nr_cpu_online) { index = (nr_cpu_online - 1) * 2; if ((nr_cpu_online < 4) && (rq_depth >= NwNs_Threshold[index])) { if (total_time >= TwTs_Threshold[index]) { new_state = TEGRA_HP_UP; } } else if (rq_depth <= NwNs_Threshold[index+1]) { if (total_time >= TwTs_Threshold[index+1] ) { new_state = TEGRA_HP_DOWN; } } else { total_time = 0; } } else { total_time = 0; } mutex_unlock(&tegra3_mp_lock); if (new_state != TEGRA_HP_IDLE) { total_time = 0; } last_time = ktime_to_ms(ktime_get()); return new_state; }
static void therm_est_update_timer_trips(struct therm_estimator *est) { struct thermal_trip_info *trip_state; struct therm_est_timer_trip_info *timer_info; s64 now, delay, min_delay; int i; mutex_lock(&est->timer_trip_lock); min_delay = LLONG_MAX; now = ktime_to_ms(ktime_get()); for (i = 0; i < est->num_timer_trips; i++) { timer_info = &est->timer_trips[i]; trip_state = &est->trips[timer_info->trip]; pr_debug("%s: i %d, trip %d, tripped %d, cur %d\n", __func__, i, timer_info->trip, trip_state->tripped, timer_info->cur); if ((timer_info->cur == TIMER_TRIP_INACTIVE) || (__get_timer_trip_delay(timer_info, now, &delay) < 0)) continue; if (delay > 0) min_delay = min(min_delay, delay); pr_debug("%s: delay %lld, min_delay %lld\n", __func__, delay, min_delay); } mutex_unlock(&est->timer_trip_lock); cancel_delayed_work(&est->timer_trip_work); if (min_delay != LLONG_MAX) queue_delayed_work(est->workqueue, &est->timer_trip_work, msecs_to_jiffies(min_delay)); }
static ssize_t cm3323_poll_delay_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct cm3323_p *data = dev_get_drvdata(dev); int64_t new_delay; int ret; ret = kstrtoll(buf, 10, &new_delay); if (ret) { pr_err("[SENSOR]: %s - Invalid Argument\n", __func__); return ret; } mutex_lock(&data->power_lock); if (new_delay != ktime_to_ms(data->poll_delay)) { data->poll_delay = ns_to_ktime(new_delay * NSEC_PER_MSEC); if (data->power_state & LIGHT_ENABLED) { cm3323_light_disable(data); cm3323_light_enable(data); } pr_info("[SENSOR]: %s - poll_delay = %lld\n", __func__, new_delay); } mutex_unlock(&data->power_lock); return size; }
static void cm3323_work_func_light(struct work_struct *work) { struct cm3323_p *data = container_of(work, struct cm3323_p, work_light); mutex_lock(&data->read_lock); cm3323_i2c_read_word(data, REG_RED, &data->color[0]); cm3323_i2c_read_word(data, REG_GREEN, &data->color[1]); cm3323_i2c_read_word(data, REG_BLUE, &data->color[2]); cm3323_i2c_read_word(data, REG_WHITE, &data->color[3]); mutex_unlock(&data->read_lock); input_report_rel(data->input, REL_RED, data->color[0] + 1); input_report_rel(data->input, REL_GREEN, data->color[1] + 1); input_report_rel(data->input, REL_BLUE, data->color[2] + 1); input_report_rel(data->input, REL_WHITE, data->color[3] + 1); input_sync(data->input); if ((ktime_to_ms(data->poll_delay) * (int64_t)data->time_count) >= ((int64_t)LIGHT_LOG_TIME * MSEC_PER_SEC)) { pr_info("[SENSOR]: %s - r = %u g = %u b = %u w = %u\n", __func__, data->color[0], data->color[1], data->color[2], data->color[3]); data->time_count = 0; } else data->time_count++; }
static int __init aic3008_modinit(void) { AUD_DBG("Start aic3008_modinit\n"); drv_up_time = ktime_to_ms(ktime_get()); spi_aic3008_init(); return 0; }
static int therm_est_get_trip_temp(struct thermal_zone_device *thz, int trip, unsigned long *temp) { struct therm_estimator *est = thz->devdata; struct therm_est_timer_trip_info *timer_info; int ret; ret = __get_trip_temp(thz, trip, temp); if (ret & (TIMER_TRIP_STATE_START | TIMER_TRIP_STATE_DOWN)) { timer_info = __find_timer_trip(est, trip); mutex_lock(&est->timer_trip_lock); timer_info->last_tripped = ktime_to_ms(ktime_get()); if (ret & TIMER_TRIP_STATE_START) { timer_info->cur = TIMER_TRIP_INACTIVE + 1; } else if (ret & TIMER_TRIP_STATE_DOWN) { if (--timer_info->cur < TIMER_TRIP_INACTIVE) timer_info->cur = TIMER_TRIP_INACTIVE; } mutex_unlock(&est->timer_trip_lock); /* Update limits, because trip temp was changed by timer trip * changing. */ therm_est_update_limits(est); } return 0; }
int cq_item_1_func(void* data) { int i; ktime_t start_time, stop_time,delta; long long delta_us, delta_ms; struct ts_cmd_node cmd; cmd.command = TS_TEST_CMD; cmd.cmd_param.prv_params = data; TS_LOG_INFO("called paras:%d\n", (int)cmd.cmd_param.prv_params); for(i=0; i<100; i++) { init_completion(&cq_test_sync_1); start_time = ktime_get(); if (NO_ERR == put_one_cmd(&cmd)) { if(wait_for_completion_timeout(&cq_test_sync_1, 5*HZ)){ stop_time = ktime_get(); delta = ktime_sub(stop_time, start_time); delta_us = (long long)ktime_to_us(delta); delta_ms = (long long)ktime_to_ms(delta); TS_LOG_INFO("CMD PROCESS ELAPSED TIME: %lldms%lldus\n", delta_ms, delta_us); } else TS_LOG_ERR("ts thread process TEST CMD expire 5 sec\n"); }else TS_LOG_ERR("put cmd error\n"); } return 0; }
static int k303c_acc_set_odr(struct k303c_acc_p *data) { int ret = 0, i; unsigned char buf, new_odr, mask, temp; pr_info("%s\n", __func__); /* Following, looks for the longest possible odr interval scrolling the * odr_table vector from the end (shortest interval) backward (longest * interval), to support the poll_interval requested by the system. * It must be the longest interval lower then the poll interval.*/ for (i = ARRAY_SIZE(k303c_acc_odr_table) - 1; i >= 0; i--) { if ((k303c_acc_odr_table[i].cutoff_ms <= ktime_to_ms(data->poll_delay)) || (i == 0)) break; } if (data->recog_flag == ON) i = ARRAY_SIZE(k303c_acc_odr_table) - 1; new_odr = k303c_acc_odr_table[i].mask; mask = K303C_ACC_ODR_MASK; ret = k303c_acc_i2c_read(data, CTRL1_REG, &temp, 1); buf = ((mask & new_odr) | ((~mask) & temp)); ret += k303c_acc_i2c_write(data, CTRL1_REG, buf); pr_info("%s - change odr %d\n", __func__, i); return ret; }
int tegra_cpuquiet_force_gmode(void) { cputime64_t on_time = 0; if (no_lp) return -EBUSY; if (!is_g_cluster_present()) return -EBUSY; if (cpq_state == TEGRA_CPQ_DISABLED) return -EBUSY; if (is_lp_cluster()) { mutex_lock(tegra3_cpu_lock); if (switch_clk_to_gmode()) { pr_err(CPUQUIET_TAG "tegra_cpuquiet_force_gmode - switch_clk_to_gmode failed\n"); mutex_unlock(tegra3_cpu_lock); return -EBUSY; } on_time = ktime_to_ms(ktime_get()) - lp_on_time; show_status("LP -> off - force", on_time, -1); mutex_unlock(tegra3_cpu_lock); if (!manual_hotplug) cpuquiet_device_free(); } return 0; }
/* * row_add_request() - Add request to the scheduler * @q: requests queue * @rq: request to add * */ static void row_add_request(struct request_queue *q, struct request *rq) { struct row_data *rd = (struct row_data *)q->elevator->elevator_data; struct row_queue *rqueue = RQ_ROWQ(rq); list_add_tail(&rq->queuelist, &rqueue->fifo); rd->nr_reqs[rq_data_dir(rq)]++; rq_set_fifo_time(rq, jiffies); /* for statistics*/ if (queue_idling_enabled[rqueue->prio]) { if (delayed_work_pending(&rd->read_idle.idle_work)) (void)cancel_delayed_work( &rd->read_idle.idle_work); if (ktime_to_ms(ktime_sub(ktime_get(), rqueue->idle_data.last_insert_time)) < rd->read_idle.freq) { rqueue->idle_data.begin_idling = true; row_log_rowq(rd, rqueue->prio, "Enable idling"); } else { rqueue->idle_data.begin_idling = false; row_log_rowq(rd, rqueue->prio, "Disable idling"); } rqueue->idle_data.last_insert_time = ktime_get(); } row_log_rowq(rd, rqueue->prio, "added request"); }
/* Doubletap2wake main function */ static void detect_doubletap2wake(int x, int y, bool st) { bool single_touch = st; #if DT2W_DEBUG pr_info(LOGTAG"x,y(%4d,%4d) single:%s\n", x, y, (single_touch) ? "true" : "false"); #endif if ((single_touch) && (dt2w_switch > 0) && (exec_count) && (touch_cnt)) { touch_cnt = false; if (touch_nr == 0) { new_touch(x, y); } else if (touch_nr == 1) { if ((calc_feather(x, x_pre) < DT2W_FEATHER) && (calc_feather(y, y_pre) < DT2W_FEATHER) && ((ktime_to_ms(ktime_get())-tap_time_pre) < DT2W_TIME)) touch_nr++; else { doubletap2wake_reset(); new_touch(x, y); } } else { doubletap2wake_reset(); new_touch(x, y); } if ((touch_nr > 1)) { pr_info(LOGTAG"ON\n"); exec_count = false; doubletap2wake_pwrtrigger(); doubletap2wake_reset(); } } }
static u32 get_num_interrupts_per_s(void) { int cpu; int i; u64 num_irqs = 0; ktime_t now; static ktime_t last; unsigned int delta; u32 irqs = 0; now = ktime_get(); for_each_possible_cpu(cpu) { for (i = 0; i < NR_IRQS; i++) num_irqs += kstat_irqs_cpu(i, cpu); } pr_debug("%s: total num irqs: %lld, previous %lld\n", __func__, num_irqs, old_num_irqs); if (old_num_irqs > 0) { delta = (u32)ktime_to_ms(ktime_sub(now, last)) / 1000; delta = (delta > 0) ? delta : 1; irqs = ((u32)(num_irqs - old_num_irqs)) / delta; } old_num_irqs = num_irqs; last = now; pr_debug("delta irqs per sec:%d\n", irqs); return irqs; }
static void min_cpus_change(void) { bool g_cluster = false; cputime64_t on_time = 0; if (cpq_state == TEGRA_CPQ_DISABLED) return; mutex_lock(tegra3_cpu_lock); if ((tegra_cpq_min_cpus() >= 2) && is_lp_cluster()) { if (switch_clk_to_gmode()){ pr_err(CPUQUIET_TAG "min_cpus_change - switch_clk_to_gmode failed\n"); mutex_unlock(tegra3_cpu_lock); return; } on_time = ktime_to_ms(ktime_get()) - lp_on_time; show_status("LP -> off - min_cpus_change", on_time, -1); g_cluster = true; } tegra_cpu_set_speed_cap(NULL); mutex_unlock(tegra3_cpu_lock); schedule_work(&minmax_work); if (g_cluster && !manual_hotplug) cpuquiet_device_free(); }
static int long_seq_test_calc_throughput(struct test_data *td) { unsigned long fraction, integer; unsigned long mtime, byte_count; mtime = ktime_to_ms(utd->test_info.test_duration); byte_count = utd->test_info.test_byte_count; pr_info("%s: time is %lu msec, size is %lu.%lu MiB", __func__, mtime, LONG_TEST_SIZE_INTEGER(byte_count), LONG_TEST_SIZE_FRACTION(byte_count)); /* we first multiply in order not to lose precision */ mtime *= MB_MSEC_RATIO_APPROXIMATION; /* divide values to get a MiB/sec integer value with one digit of precision */ fraction = integer = (byte_count * 10) / mtime; integer /= 10; /* and calculate the MiB value fraction */ fraction -= integer * 10; pr_info("%s: Throughput: %lu.%lu MiB/sec\n", __func__, integer, fraction); return 0; }
static int __devinit aic3008_probe(struct snd_soc_codec *codec) { AUD_INFO("aic3008_probe() start... aic3008_codec:%p", codec); int ret = 0; struct aic3008_priv *aic3008 = snd_soc_codec_get_drvdata(codec); aic3008->codec = codec; aic3008->codec->control_data = (void *)codec_spi_dev; if (!aic3008) { AUD_ERR("%s: Codec not registered, SPI device not yet probed\n", &aic3008->codec->name); return -ENODEV; } aic3008_sw_reset(codec); // local call to reset codec aic3008_set_bias_level(codec, SND_SOC_BIAS_STANDBY); // request space for SPI commands data of AIC3008 aic3008_uplink = init_2d_array(IO_CTL_ROW_MAX, IO_CTL_COL_MAX); aic3008_downlink = init_2d_array(IO_CTL_ROW_MAX, IO_CTL_COL_MAX); aic3008_minidsp = init_2d_array(MINIDSP_ROW_MAX, MINIDSP_COL_MAX); bulk_tx = kcalloc(MINIDSP_COL_MAX * 2 , sizeof(uint8_t), GFP_KERNEL); AUD_INFO("Audio Codec Driver init complete in %lld ms\n", ktime_to_ms(ktime_get()) - drv_up_time); return ret; }
void mdss_qpic_reset(void) { u32 time_end; QPIC_OUTP(QPIC_REG_QPIC_LCDC_RESET, 1 << 0); /* */ usleep(100); time_end = (u32)ktime_to_ms(ktime_get()) + QPIC_MAX_VSYNC_WAIT_TIME; while (((QPIC_INP(QPIC_REG_QPIC_LCDC_STTS) & (1 << 8)) == 0)) { if ((u32)ktime_to_ms(ktime_get()) > time_end) { pr_err("%s reset not finished", __func__); break; } /* */ usleep(100); } }
static int mp_decision(void) { static bool first_call = true; int new_state = 0; int nr_cpu_online; int index; unsigned int rq_depth; static cputime64_t total_time = 0; static cputime64_t last_time; cputime64_t current_time; cputime64_t this_time = 0; current_time = ktime_to_ms(ktime_get()); if (first_call) { first_call = false; } else { this_time = current_time - last_time; } total_time += this_time; rq_depth = rq_info.rq_avg; //pr_info(" rq_deptch = %u", rq_depth); nr_cpu_online = num_online_cpus(); if (nr_cpu_online) { index = (nr_cpu_online - 1) * 2; if ((nr_cpu_online < 4) && (rq_depth >= NwNs_Threshold[index])) { if (total_time >= TwTs_Threshold[index]) { new_state = 1; } } else if (rq_depth <= NwNs_Threshold[index+1]) { if (total_time >= TwTs_Threshold[index+1] ) { new_state = 0; } } else { total_time = 0; } } else { total_time = 0; } last_time = ktime_to_ms(ktime_get()); return new_state; }
void mdss_qpic_reset(void) { u32 time_end; QPIC_OUTP(QPIC_REG_QPIC_LCDC_RESET, 1 << 0); /* wait 100 us after reset as suggested by hw */ usleep(100); time_end = (u32)ktime_to_ms(ktime_get()) + QPIC_MAX_VSYNC_WAIT_TIME; while (((QPIC_INP(QPIC_REG_QPIC_LCDC_STTS) & (1 << 8)) == 0)) { if ((u32)ktime_to_ms(ktime_get()) > time_end) { pr_err("%s reset not finished", __func__); break; } /* yield 100 us for next polling by experiment*/ usleep(100); } }
static int vibrator_get_time(struct timed_output_dev *dev) { if (hrtimer_active(&vibe_timer)) { ktime_t r = hrtimer_get_remaining(&vibe_timer); return ktime_to_ms(r); } else return 0; }
static int drv2667_get_time(struct timed_output_dev *dev) { struct drv2667_data *data = container_of(dev, struct drv2667_data, dev); if (hrtimer_active(&data->timer)) return data->runtime_left + ktime_to_ms(hrtimer_get_remaining(&data->timer)); return 0; }
static int herring_vibrator_get_time(struct timed_output_dev *dev) { if (hrtimer_active(&vibdata.timer)) { ktime_t r = hrtimer_get_remaining(&vibdata.timer); return ktime_to_ms(r); } return 0; }
static int vibrator_get_time(struct timed_output_dev *dev) { struct timed_vibrator_data *vib = container_of(dev, struct timed_vibrator_data, dev); if (hrtimer_active(&vib->timer)) { ktime_t r = hrtimer_get_remaining(&vib->timer); return ktime_to_ms(r); } else return 0; }
static void aic3254_powerdown(void) { int64_t t1, t2; #if defined(CONFIG_ARCH_MSM7X30) struct ecodec_aic3254_state *drv = &codec_clk; #endif if (aic3254_tx_mode != UPLINK_OFF || aic3254_rx_mode != DOWNLINK_OFF) return; t1 = ktime_to_ms(ktime_get()); spi_aic3254_prevent_sleep(); if (aic3254_uplink != NULL) { pr_aud_info("power off AIC3254 len(%d)++\n", (aic3254_uplink[POWER_OFF][0].data-1)); aic3254_config(&aic3254_uplink[POWER_OFF][1], aic3254_uplink[POWER_OFF][0].data); } else { pr_aud_info("power off AIC3254 len(%d)++\n", (ARRAY_SIZE(CODEC_POWER_OFF))); aic3254_config(CODEC_POWER_OFF, ARRAY_SIZE(CODEC_POWER_OFF)); } #if defined(CONFIG_ARCH_MSM7X30) if (drv->enabled) { /* Disable MI2S RX master block */ /* Disable MI2S RX bit clock */ clk_disable(drv->rx_sclk); clk_disable(drv->rx_mclk); drv->enabled = 0; pr_aud_info("%s: disable CLK\n", __func__); } #endif spi_aic3254_allow_sleep(); t2 = ktime_to_ms(ktime_get())-t1; pr_aud_info("power off AIC3254 %lldms --\n", t2); return; }
static int vibrator_get_time(struct timed_output_dev *dev) { //struct Haptics *pvibdata = container_of(dev, struct Haptics, to_dev); if (hrtimer_active(&vibdata.timer)) { ktime_t r = hrtimer_get_remaining(&vibdata.timer); return ktime_to_ms(r); } return 0; }
static int vibrator_get_time(struct timed_output_dev *dev) { printk("[tspdrv] %s\n", __func__); if (hrtimer_active(&vibe_timer)) { ktime_t r = hrtimer_get_remaining(&vibe_timer); return ktime_to_ms(r); } return 0; }