Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 902f2ac9 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'timers-fixes-for-linus' of...

Merge branch 'timers-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'timers-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  clockevents: make device shutdown robust
  clocksource, acpi_pm.c: fix check for monotonicity
  clockevents: remove WARN_ON which was used to gather information
parents 06d4a22b 2344abbc
Loading
Loading
Loading
Loading
+10 −11
Original line number Original line Diff line number Diff line
@@ -178,11 +178,13 @@ static int verify_pmtmr_rate(void)


/* Number of monotonicity checks to perform during initialization */
/* Number of monotonicity checks to perform during initialization */
#define ACPI_PM_MONOTONICITY_CHECKS 10
#define ACPI_PM_MONOTONICITY_CHECKS 10
/* Number of reads we try to get two different values */
#define ACPI_PM_READ_CHECKS 10000


static int __init init_acpi_pm_clocksource(void)
static int __init init_acpi_pm_clocksource(void)
{
{
	cycle_t value1, value2;
	cycle_t value1, value2;
	unsigned int i, j, good = 0;
	unsigned int i, j = 0;


	if (!pmtmr_ioport)
	if (!pmtmr_ioport)
		return -ENODEV;
		return -ENODEV;
@@ -192,30 +194,27 @@ static int __init init_acpi_pm_clocksource(void)


	/* "verify" this timing source: */
	/* "verify" this timing source: */
	for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) {
	for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) {
		udelay(100 * j);
		value1 = clocksource_acpi_pm.read();
		value1 = clocksource_acpi_pm.read();
		for (i = 0; i < 10000; i++) {
		for (i = 0; i < ACPI_PM_READ_CHECKS; i++) {
			value2 = clocksource_acpi_pm.read();
			value2 = clocksource_acpi_pm.read();
			if (value2 == value1)
			if (value2 == value1)
				continue;
				continue;
			if (value2 > value1)
			if (value2 > value1)
				good++;
				break;
				break;
			if ((value2 < value1) && ((value2) < 0xFFF))
			if ((value2 < value1) && ((value2) < 0xFFF))
				good++;
				break;
				break;
			printk(KERN_INFO "PM-Timer had inconsistent results:"
			printk(KERN_INFO "PM-Timer had inconsistent results:"
			       " 0x%#llx, 0x%#llx - aborting.\n",
			       " 0x%#llx, 0x%#llx - aborting.\n",
			       value1, value2);
			       value1, value2);
			return -EINVAL;
			return -EINVAL;
		}
		}
		udelay(300 * i);
		if (i == ACPI_PM_READ_CHECKS) {
	}

	if (good != ACPI_PM_MONOTONICITY_CHECKS) {
			printk(KERN_INFO "PM-Timer failed consistency check "
			printk(KERN_INFO "PM-Timer failed consistency check "
			       " (0x%#llx) - aborting.\n", value1);
			       " (0x%#llx) - aborting.\n", value1);
			return -ENODEV;
			return -ENODEV;
		}
		}
	}


	if (verify_pmtmr_rate() != 0)
	if (verify_pmtmr_rate() != 0)
		return -ENODEV;
		return -ENODEV;
+11 −1
Original line number Original line Diff line number Diff line
@@ -71,6 +71,16 @@ void clockevents_set_mode(struct clock_event_device *dev,
	}
	}
}
}


/**
 * clockevents_shutdown - shutdown the device and clear next_event
 * @dev:	device to shutdown
 */
void clockevents_shutdown(struct clock_event_device *dev)
{
	clockevents_set_mode(dev, CLOCK_EVT_MODE_SHUTDOWN);
	dev->next_event.tv64 = KTIME_MAX;
}

/**
/**
 * clockevents_program_event - Reprogram the clock event device.
 * clockevents_program_event - Reprogram the clock event device.
 * @expires:	absolute expiry time (monotonic clock)
 * @expires:	absolute expiry time (monotonic clock)
@@ -206,7 +216,7 @@ void clockevents_exchange_device(struct clock_event_device *old,


	if (new) {
	if (new) {
		BUG_ON(new->mode != CLOCK_EVT_MODE_UNUSED);
		BUG_ON(new->mode != CLOCK_EVT_MODE_UNUSED);
		clockevents_set_mode(new, CLOCK_EVT_MODE_SHUTDOWN);
		clockevents_shutdown(new);
	}
	}
	local_irq_restore(flags);
	local_irq_restore(flags);
}
}
+4 −5
Original line number Original line Diff line number Diff line
@@ -236,8 +236,7 @@ static void tick_do_broadcast_on_off(void *why)
		if (!cpu_isset(cpu, tick_broadcast_mask)) {
		if (!cpu_isset(cpu, tick_broadcast_mask)) {
			cpu_set(cpu, tick_broadcast_mask);
			cpu_set(cpu, tick_broadcast_mask);
			if (td->mode == TICKDEV_MODE_PERIODIC)
			if (td->mode == TICKDEV_MODE_PERIODIC)
				clockevents_set_mode(dev,
				clockevents_shutdown(dev);
						     CLOCK_EVT_MODE_SHUTDOWN);
		}
		}
		if (*reason == CLOCK_EVT_NOTIFY_BROADCAST_FORCE)
		if (*reason == CLOCK_EVT_NOTIFY_BROADCAST_FORCE)
			tick_broadcast_force = 1;
			tick_broadcast_force = 1;
@@ -254,7 +253,7 @@ static void tick_do_broadcast_on_off(void *why)


	if (cpus_empty(tick_broadcast_mask)) {
	if (cpus_empty(tick_broadcast_mask)) {
		if (!bc_stopped)
		if (!bc_stopped)
			clockevents_set_mode(bc, CLOCK_EVT_MODE_SHUTDOWN);
			clockevents_shutdown(bc);
	} else if (bc_stopped) {
	} else if (bc_stopped) {
		if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC)
		if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC)
			tick_broadcast_start_periodic(bc);
			tick_broadcast_start_periodic(bc);
@@ -306,7 +305,7 @@ void tick_shutdown_broadcast(unsigned int *cpup)


	if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) {
	if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) {
		if (bc && cpus_empty(tick_broadcast_mask))
		if (bc && cpus_empty(tick_broadcast_mask))
			clockevents_set_mode(bc, CLOCK_EVT_MODE_SHUTDOWN);
			clockevents_shutdown(bc);
	}
	}


	spin_unlock_irqrestore(&tick_broadcast_lock, flags);
	spin_unlock_irqrestore(&tick_broadcast_lock, flags);
@@ -321,7 +320,7 @@ void tick_suspend_broadcast(void)


	bc = tick_broadcast_device.evtdev;
	bc = tick_broadcast_device.evtdev;
	if (bc)
	if (bc)
		clockevents_set_mode(bc, CLOCK_EVT_MODE_SHUTDOWN);
		clockevents_shutdown(bc);


	spin_unlock_irqrestore(&tick_broadcast_lock, flags);
	spin_unlock_irqrestore(&tick_broadcast_lock, flags);
}
}
+2 −2
Original line number Original line Diff line number Diff line
@@ -249,7 +249,7 @@ static int tick_check_new_device(struct clock_event_device *newdev)
	 * not give it back to the clockevents layer !
	 * not give it back to the clockevents layer !
	 */
	 */
	if (tick_is_broadcast_device(curdev)) {
	if (tick_is_broadcast_device(curdev)) {
		clockevents_set_mode(curdev, CLOCK_EVT_MODE_SHUTDOWN);
		clockevents_shutdown(curdev);
		curdev = NULL;
		curdev = NULL;
	}
	}
	clockevents_exchange_device(curdev, newdev);
	clockevents_exchange_device(curdev, newdev);
@@ -311,7 +311,7 @@ static void tick_suspend(void)
	unsigned long flags;
	unsigned long flags;


	spin_lock_irqsave(&tick_device_lock, flags);
	spin_lock_irqsave(&tick_device_lock, flags);
	clockevents_set_mode(td->evtdev, CLOCK_EVT_MODE_SHUTDOWN);
	clockevents_shutdown(td->evtdev);
	spin_unlock_irqrestore(&tick_device_lock, flags);
	spin_unlock_irqrestore(&tick_device_lock, flags);
}
}


+2 −0
Original line number Original line Diff line number Diff line
@@ -10,6 +10,8 @@ extern int tick_do_timer_cpu __read_mostly;
extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast);
extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast);
extern void tick_handle_periodic(struct clock_event_device *dev);
extern void tick_handle_periodic(struct clock_event_device *dev);


extern void clockevents_shutdown(struct clock_event_device *dev);

/*
/*
 * NO_HZ / high resolution timer shared code
 * NO_HZ / high resolution timer shared code
 */
 */