Exemplo n.º 1
0
void update_vsyscall(struct timespec *wall_time, struct timespec *wtm,
			struct clocksource *clock, u32 mult)
{
	struct timespec monotonic;

	write_seqcount_begin(&vsyscall_gtod_data.seq);

	/* copy vsyscall data */
	vsyscall_gtod_data.clock.vclock_mode	= clock->archdata.vclock_mode;
	vsyscall_gtod_data.clock.cycle_last	= clock->cycle_last;
	vsyscall_gtod_data.clock.mask		= clock->mask;
	vsyscall_gtod_data.clock.mult		= mult;
	vsyscall_gtod_data.clock.shift		= clock->shift;

	vsyscall_gtod_data.wall_time_sec	= wall_time->tv_sec;
	vsyscall_gtod_data.wall_time_nsec	= wall_time->tv_nsec;

	monotonic = timespec_add(*wall_time, *wtm);
	vsyscall_gtod_data.monotonic_time_sec	= monotonic.tv_sec;
	vsyscall_gtod_data.monotonic_time_nsec	= monotonic.tv_nsec;

	vsyscall_gtod_data.wall_time_coarse	= __current_kernel_time();
	vsyscall_gtod_data.monotonic_time_coarse =
		timespec_add(vsyscall_gtod_data.wall_time_coarse, *wtm);

	write_seqcount_end(&vsyscall_gtod_data.seq);
}
Exemplo n.º 2
0
static int xen_pvclock_gtod_notify(struct notifier_block *nb,
				   unsigned long was_set, void *priv)
{
	/* Protected by the calling core code serialization */
	static struct timespec next_sync;

	struct xen_platform_op op;
	struct timespec now;

	now = __current_kernel_time();

	/*
	 * We only take the expensive HV call when the clock was set
	 * or when the 11 minutes RTC synchronization time elapsed.
	 */
	if (!was_set && timespec_compare(&now, &next_sync) < 0)
		return NOTIFY_OK;

	op.cmd = XENPF_settime;
	op.u.settime.secs = now.tv_sec;
	op.u.settime.nsecs = now.tv_nsec;
	op.u.settime.system_time = xen_clocksource_read();

	(void)HYPERVISOR_dom0_op(&op);

	/*
	 * Move the next drift compensation time 11 minutes
	 * ahead. That's emulating the sync_cmos_clock() update for
	 * the hardware RTC.
	 */
	next_sync = now;
	next_sync.tv_sec += 11 * 60;

	return NOTIFY_OK;
}
Exemplo n.º 3
0
/*
 * Update the vDSO data page to keep in sync with kernel timekeeping.
 */
void update_vsyscall(struct timespec *ts, struct timespec *wtm,
		     struct clocksource *clock, u32 mult)
{
	struct timespec xtime_coarse;
	u32 use_syscall = strcmp(clock->name, "arch_sys_counter");

	++vdso_data->tb_seq_count;
	smp_wmb();

	xtime_coarse = __current_kernel_time();
	vdso_data->use_syscall			= use_syscall;
	vdso_data->xtime_coarse_sec		= xtime_coarse.tv_sec;
	vdso_data->xtime_coarse_nsec		= xtime_coarse.tv_nsec;

	if (!use_syscall) {
		vdso_data->cs_cycle_last	= clock->cycle_last;
		vdso_data->xtime_clock_sec	= ts->tv_sec;
		vdso_data->xtime_clock_nsec	= ts->tv_nsec;
		vdso_data->cs_mult		= mult;
		vdso_data->cs_shift		= clock->shift;
		vdso_data->wtm_clock_sec	= wtm->tv_sec;
		vdso_data->wtm_clock_nsec	= wtm->tv_nsec;
	}

	smp_wmb();
	++vdso_data->tb_seq_count;
}
Exemplo n.º 4
0
/*
 * Update the vDSO data page to keep in sync with kernel timekeeping.
 */
void update_vsyscall(struct timekeeper *tk)
{
	struct timespec xtime_coarse;
	u32 use_syscall = strcmp(tk->clock->name, "arch_sys_counter");

	++vdso_data->tb_seq_count;
	smp_wmb();

	xtime_coarse = __current_kernel_time();
	vdso_data->use_syscall			= use_syscall;
	vdso_data->xtime_coarse_sec		= xtime_coarse.tv_sec;
	vdso_data->xtime_coarse_nsec		= xtime_coarse.tv_nsec;
	vdso_data->wtm_clock_sec		= tk->wall_to_monotonic.tv_sec;
	vdso_data->wtm_clock_nsec		= tk->wall_to_monotonic.tv_nsec;

	if (!use_syscall) {
		vdso_data->cs_cycle_last	= tk->clock->cycle_last;
		vdso_data->xtime_clock_sec	= tk->xtime_sec;
		vdso_data->xtime_clock_nsec	= tk->xtime_nsec;
		vdso_data->cs_mult		= tk->mult;
		vdso_data->cs_shift		= tk->shift;
	}

	smp_wmb();
	++vdso_data->tb_seq_count;
}
static int ce1702_isp_event_store(struct device* dev, struct device_attribute* attr, const char* buf, size_t n)
{
	int val;
	struct timespec time;
	struct tm tm_result;
	uint8_t filename[128];

	time = __current_kernel_time();
	time_to_tm(time.tv_sec, sys_tz.tz_minuteswest * 60 * (-1), &tm_result);

	sprintf(filename, "/data/event_%02d%02d%02d%02d%02d.bin", tm_result.tm_mon + 1, tm_result.tm_mday, tm_result.tm_hour, tm_result.tm_min, tm_result.tm_sec);

	sscanf(buf,"%x", &val);
	if (val) {
		int32_t rc, num_read;
		uint8_t data[130];
		uint8_t packet_size[2] = {0, };

		rc = ce1702_i2c_read(ce1702_s_interface_ctrl->sensor_i2c_addr, 0xDB, NULL, 0, packet_size,  2);
		if (rc < 0)
		{
			LDBGE("%s: num_read reading error\n", __func__);
			return n;
		}
		num_read = packet_size[0] + (packet_size[1] << 8);
		LDBGE("%s: num_read : %d, [%x|%x]\n", __func__, num_read, packet_size[0], packet_size[1]);
		if (num_read > 0) {
			mm_segment_t old_fs;
			uint8_t *dump_data;
			int32_t dump_data_len, nloop, fd;

			dump_data_len = num_read * 128 * sizeof(uint8_t);
			dump_data = kmalloc(dump_data_len, GFP_KERNEL);
			for (nloop = 0; nloop < num_read; nloop++)
			{
				rc = ce1702_i2c_read(ce1702_s_interface_ctrl->sensor_i2c_addr, 0xDC, NULL, 0, data, 130);
				if (rc < 0) {
					LDBGE("%s: %d-th reading error\n", __func__, nloop);
					continue;
				}
				memcpy(&dump_data[nloop * 128], &data[2], sizeof(uint8_t) * 128);

			}
			old_fs = get_fs();
			set_fs(KERNEL_DS);
			fd = sys_open(filename, O_RDWR | O_CREAT , 0644);
			if (fd >= 0) {
				sys_write(fd, dump_data, dump_data_len);
				sys_close(fd);
				LDBGE("%s: isp eventlog (%s) successfully writed (%d)!! \n", __func__, filename, nloop);
			}
			set_fs(old_fs);
			kfree(dump_data);

		}
	}

	return n;
}
Exemplo n.º 6
0
/*
 * Get the coarse grained time at the softirq based on xtime and
 * wall_to_monotonic.
 */
static void hrtimer_get_softirq_time(struct hrtimer_cpu_base *base)
{
	ktime_t xtim, tomono;
	struct timespec xts, tom;
	unsigned long seq;

	do {
		seq = read_seqbegin(&xtime_lock);
		xts = __current_kernel_time();
		tom = __get_wall_to_monotonic();
	} while (read_seqretry(&xtime_lock, seq));

	xtim = timespec_to_ktime(xts);
	tomono = timespec_to_ktime(tom);
	base->clock_base[CLOCK_REALTIME].softirq_time = xtim;
	base->clock_base[CLOCK_MONOTONIC].softirq_time =
		ktime_add(xtim, tomono);
}
Exemplo n.º 7
0
void update_vsyscall(struct timespec *wall_time, struct timespec *wtm,
			struct clocksource *clock, u32 mult)
{
	unsigned long flags;

	write_seqlock_irqsave(&vsyscall_gtod_data.lock, flags);

	/* copy vsyscall data */
	vsyscall_gtod_data.clock.vclock_mode	= clock->archdata.vclock_mode;
	vsyscall_gtod_data.clock.cycle_last	= clock->cycle_last;
	vsyscall_gtod_data.clock.mask		= clock->mask;
	vsyscall_gtod_data.clock.mult		= mult;
	vsyscall_gtod_data.clock.shift		= clock->shift;
	vsyscall_gtod_data.wall_time_sec	= wall_time->tv_sec;
	vsyscall_gtod_data.wall_time_nsec	= wall_time->tv_nsec;
	vsyscall_gtod_data.wall_to_monotonic	= *wtm;
	vsyscall_gtod_data.wall_time_coarse	= __current_kernel_time();

	write_sequnlock_irqrestore(&vsyscall_gtod_data.lock, flags);
}
Exemplo n.º 8
0
static void modem_ssr_report_work_fn(struct work_struct *work)
{

    int fd, ret = 0;
    char report_index, index_to_write;
    char path_prefix[]="/data/logger/modem_ssr_report";
    char index_file_path[]="/data/logger/modem_ssr_index";
    char report_file_path[128];
#ifdef FEATURE_LGE_MODEM_CHIPVER_INFO
    char chip_info_path[]="/data/logger/modem_chip_info";
	struct timespec time;
	struct tm tmresult;
	char time_stamp[128];
#endif
    char watchdog_bite[]="Watchdog bite received from modem software!";
    char unexpected_reset1[]="unexpected reset external modem";
    char unexpected_reset2[]="MDM2AP_STATUS did not go high";

    mm_segment_t oldfs;

    oldfs = get_fs();
    set_fs(get_ds());

    fd = sys_open(index_file_path, O_RDONLY, 0664);
    if (fd < 0) {
        printk("%s : can't open the index file\n", __func__);
        report_index = '0';
    } else {
        ret = sys_read(fd, &report_index, 1);
        if (ret < 0) {
            printk("%s : can't read the index file\n", __func__);
            report_index = '0';
        }
        sys_close(fd);
    }

    if (report_index == '9') {
        index_to_write = '0';
    } else if (report_index >= '0' && report_index <= '8') {
        index_to_write = report_index + 1;
    } else {
        index_to_write = '1';
        report_index = '0';
    }

    fd = sys_open(index_file_path, O_WRONLY | O_CREAT | O_TRUNC, 0664);
    if (fd < 0) {
        printk("%s : can't open the index file\n", __func__);
        return;
    }

    ret = sys_write(fd, &index_to_write, 1);
    if (ret < 0) {
        printk("%s : can't write the index file\n", __func__);
        return;
    }

    ret = sys_close(fd);
    if (ret < 0) {
        printk("%s : can't close the index file\n", __func__);
        return;
    }

    sprintf(report_file_path, "%s%c", path_prefix, report_index);

    fd = sys_open(report_file_path, O_WRONLY | O_CREAT | O_TRUNC, 0664);

    if (fd < 0) {
        printk("%s : can't open the report file\n", __func__);
        return;
    }

#ifdef FEATURE_LGE_MODEM_CHIPVER_INFO
	time = __current_kernel_time();
	time_to_tm(time.tv_sec, sys_tz.tz_minuteswest * 60 * (-1),
			&tmresult);

    sprintf(time_stamp, "%02d-%02d %02d:%02d:%02d.%03lu\n",
		tmresult.tm_mon+1,tmresult.tm_mday,tmresult.tm_hour,
		tmresult.tm_min,tmresult.tm_sec,(unsigned long) time.tv_nsec/1000000);

	ret = sys_write(fd, time_stamp, strlen(time_stamp));

    if (ret < 0) {
        printk("%s : can't write the report file\n", __func__);
        return;
    }
#endif

    switch (modem_debug.modem_ssr_event) {
        case MODEM_SSR_ERR_FATAL:
            ret = sys_write(fd, modem_debug.save_ssr_reason, strlen(modem_debug.save_ssr_reason));
            break;
        case MODEM_SSR_WATCHDOG_BITE:
            ret = sys_write(fd, watchdog_bite, sizeof(watchdog_bite) - 1);
            break;
        case MODEM_SSR_UNEXPECTED_RESET1:
            ret = sys_write(fd, unexpected_reset1, sizeof(unexpected_reset1) - 1);
            break;
        case MODEM_SSR_UNEXPECTED_RESET2:
            ret = sys_write(fd, unexpected_reset2, sizeof(unexpected_reset2) - 1);
            break;
        default:
            printk("%s : modem_ssr_event error %d\n", __func__, modem_debug.modem_ssr_event);
            break;
    }

    if (ret < 0) {
        printk("%s : can't write the report file\n", __func__);
        return;
    }

    ret = sys_close(fd);

    if (ret < 0) {
        printk("%s : can't close the report file\n", __func__);
        return;
    }

#ifdef FEATURE_LGE_MODEM_CHIPVER_INFO
	fd = sys_open(chip_info_path, O_WRONLY | O_CREAT | O_TRUNC, 0664);
	if (fd < 0) {
		pr_err("can't open the report file\n");
		return;
	}

	ret = sys_write(fd, modem_debug.save_msm_chip_info, strlen(modem_debug.save_msm_chip_info));
	if (ret < 0) {
		pr_err("can't write the report file\n");
		return;
    }

    ret = sys_close(fd);
    if (ret < 0) {
        printk("%s : can't close the report file\n", __func__);
        return;
    }
#endif

    sys_sync();
    set_fs(oldfs);
}
void _write_time_log(char *filename, char *data, int data_include)
{
	struct file *file;
	loff_t pos = 0;
	char *fname = NULL;
	char time_string[64] = {0};
	struct timespec my_time;
	struct tm my_date;

	mm_segment_t old_fs = get_fs();

	my_time = __current_kernel_time();
	time_to_tm(my_time.tv_sec, sys_tz.tz_minuteswest * 60 * (-1), &my_date);
	snprintf(time_string,
			sizeof(time_string),
			"%02d-%02d %02d:%02d:%02d.%03lu\n\n",
			my_date.tm_mon + 1,
			my_date.tm_mday,
			my_date.tm_hour,
			my_date.tm_min,
			my_date.tm_sec,
			(unsigned long) my_time.tv_nsec / 1000000);

	set_fs(KERNEL_DS);

	if (filename == NULL) {
		switch (mfts_mode) {
		case 0:
			fname = "/mnt/sdcard/touch_self_test.txt";
			break;
		case 1:
			fname = "/mnt/sdcard/touch_self_test_mfts_folder.txt";
			break;
		case 2:
			fname = "/mnt/sdcard/touch_self_test_mfts_flat.txt";
			break;
		case 3:
			fname = "/mnt/sdcard/touch_self_test_mfts_curved.txt";
			break;
		default:
			TOUCH_I("%s : not support mfts_mode\n", __func__);
			break;
		}
	} else {
		fname = filename;
	}

	if (fname) {
		file = filp_open(fname,
			O_WRONLY|O_CREAT|O_APPEND, 0666);
	} else {
		TOUCH_E("%s : fname is NULL, can not open FILE\n", __func__);
		return;
	}

	if (IS_ERR(file)) {
		TOUCH_I("%s :  Open file error [%s], err = %ld\n",
				__func__, fname, PTR_ERR(file));

		set_fs(old_fs);
		return;
	}

	vfs_write(file, time_string, strlen(time_string), &pos);
	filp_close(file, 0);

	set_fs(old_fs);
}