View | Details | Raw Unified | Return to bug 217408
Collapse All | Expand All

(-)sys/dev/vt/vt_core.c (-3 / +54 lines)
Lines 36-44 Link Here
36
#include "opt_compat.h"
36
#include "opt_compat.h"
37
37
38
#include <sys/param.h>
38
#include <sys/param.h>
39
#include <sys/systm.h>
40
#include <sys/bus.h>
39
#include <sys/consio.h>
41
#include <sys/consio.h>
40
#include <sys/eventhandler.h>
42
#include <sys/eventhandler.h>
41
#include <sys/fbio.h>
43
#include <sys/fbio.h>
44
#include <sys/interrupt.h>
42
#include <sys/kbio.h>
45
#include <sys/kbio.h>
43
#include <sys/kdb.h>
46
#include <sys/kdb.h>
44
#include <sys/kernel.h>
47
#include <sys/kernel.h>
Lines 50-56 Link Here
50
#include <sys/proc.h>
53
#include <sys/proc.h>
51
#include <sys/random.h>
54
#include <sys/random.h>
52
#include <sys/reboot.h>
55
#include <sys/reboot.h>
53
#include <sys/systm.h>
56
#include <sys/sched.h>
57
#include <sys/smp.h>
54
#include <sys/terminal.h>
58
#include <sys/terminal.h>
55
59
56
#include <dev/kbd/kbdreg.h>
60
#include <dev/kbd/kbdreg.h>
Lines 281-287 Link Here
281
		/* Default to initial value. */
285
		/* Default to initial value. */
282
		ms = 1000 / VT_TIMERFREQ;
286
		ms = 1000 / VT_TIMERFREQ;
283
287
284
	callout_schedule(&vd->vd_timer, hz / (1000 / ms));
288
	callout_schedule_delay(&vd->vd_timer, hz / (1000 / ms));
285
}
289
}
286
290
287
void
291
void
Lines 1565-1570 Link Here
1565
	return (0);
1569
	return (0);
1566
}
1570
}
1567
1571
1572
static void *mycookie;
1573
static bool vt_intr_init = false;
1574
volatile int in_change_font = 0;
1575
static int change_font_cpu;
1576
1577
1578
static void
1579
vt_dummy_intr(void *arg __unused)
1580
{
1581
	int count = 1000;
1582
1583
	while (count-- && in_change_font && curcpu != change_font_cpu)
1584
		printf("testing.\n");
1585
	if (curcpu == change_font_cpu)
1586
		printf("exiting early due to same CPU\n");
1587
}
1588
1589
static void
1590
do_vt_intr_init(void)
1591
{
1592
	struct intr_event *ie;
1593
	char name[16];
1594
	int cpu;
1595
1596
	if (vt_intr_init)
1597
		return;
1598
	vt_intr_init = true;
1599
	CPU_FOREACH(cpu) {
1600
		if (cpu == curcpu)
1601
			continue;
1602
		snprintf(name, sizeof(name), "test (%d)", cpu);
1603
		ie = NULL;
1604
		if (!swi_add(&ie, name, vt_dummy_intr, NULL, SWI_TTY,
1605
		    INTR_MPSAFE, &mycookie)) {
1606
			intr_event_bind(ie, cpu);
1607
			break;
1608
		}
1609
	}
1610
}
1611
1568
static int
1612
static int
1569
vt_change_font(struct vt_window *vw, struct vt_font *vf)
1613
vt_change_font(struct vt_window *vw, struct vt_font *vf)
1570
{
1614
{
Lines 2605-2610 Link Here
2605
		}
2649
		}
2606
2650
2607
	}
2651
	}
2652
	do_vt_intr_init();
2608
	VT_LOCK(vd);
2653
	VT_LOCK(vd);
2609
	if (vd->vd_curwindow == NULL)
2654
	if (vd->vd_curwindow == NULL)
2610
		vd->vd_curwindow = vd->vd_windows[VT_CONSWINDOW];
2655
		vd->vd_curwindow = vd->vd_windows[VT_CONSWINDOW];
Lines 2614-2627 Link Here
2614
		/* Attach keyboard. */
2659
		/* Attach keyboard. */
2615
		vt_allocate_keyboard(vd);
2660
		vt_allocate_keyboard(vd);
2616
2661
2662
		change_font_cpu = curcpu;
2663
		atomic_add_acq_int(&in_change_font, 1);
2664
		swi_sched(mycookie, 0);
2665
2617
		/* Init 25 Hz timer. */
2666
		/* Init 25 Hz timer. */
2618
		callout_init_mtx(&vd->vd_timer, &vd->vd_lock, 0);
2667
		callout_init_mtx(&vd->vd_timer, &vd->vd_lock, 0);
2619
2668
2620
		/* Start timer when everything ready. */
2669
		/* Start timer when everything ready. */
2621
		vd->vd_flags |= VDF_ASYNC;
2670
		vd->vd_flags |= VDF_ASYNC;
2622
		callout_reset(&vd->vd_timer, hz / VT_TIMERFREQ, vt_timer, vd);
2671
		callout_reset_delay(&vd->vd_timer, hz / VT_TIMERFREQ, vt_timer, vd);
2623
		vd->vd_timer_armed = 1;
2672
		vd->vd_timer_armed = 1;
2624
		register_handlers = 1;
2673
		register_handlers = 1;
2674
2675
		atomic_store_rel_int(&in_change_font, 0);
2625
	}
2676
	}
2626
2677
2627
	VT_UNLOCK(vd);
2678
	VT_UNLOCK(vd);
(-)sys/kern/kern_timeout.c (-2 / +10 lines)
Lines 1014-1021 Link Here
1014
 * callout_deactivate() - marks the callout as having been serviced
1014
 * callout_deactivate() - marks the callout as having been serviced
1015
 */
1015
 */
1016
int
1016
int
1017
callout_reset_sbt_on(struct callout *c, sbintime_t sbt, sbintime_t prec,
1017
callout_reset_sbt_on_(struct callout *c, sbintime_t sbt, sbintime_t prec,
1018
    void (*ftn)(void *), void *arg, int cpu, int flags)
1018
    void (*ftn)(void *), void *arg, int cpu, int flags, bool delay)
1019
{
1019
{
1020
	sbintime_t to_sbt, precision;
1020
	sbintime_t to_sbt, precision;
1021
	struct callout_cpu *cc;
1021
	struct callout_cpu *cc;
Lines 1149-1154 Link Here
1149
	}
1149
	}
1150
#endif
1150
#endif
1151
1151
1152
	if (delay)
1153
		DELAY(10000);
1152
	callout_cc_add(c, cc, to_sbt, precision, ftn, arg, cpu, flags);
1154
	callout_cc_add(c, cc, to_sbt, precision, ftn, arg, cpu, flags);
1153
	CTR6(KTR_CALLOUT, "%sscheduled %p func %p arg %p in %d.%08x",
1155
	CTR6(KTR_CALLOUT, "%sscheduled %p func %p arg %p in %d.%08x",
1154
	    cancelled ? "re" : "", c, c->c_func, c->c_arg, (int)(to_sbt >> 32),
1156
	    cancelled ? "re" : "", c, c->c_func, c->c_arg, (int)(to_sbt >> 32),
Lines 1174-1179 Link Here
1174
}
1176
}
1175
1177
1176
int
1178
int
1179
callout_schedule_delay(struct callout *c, int to_ticks)
1180
{
1181
	return callout_reset_on_delay(c, to_ticks, c->c_func, c->c_arg, c->c_cpu);
1182
}
1183
1184
int
1177
_callout_stop_safe(struct callout *c, int flags, void (*drain)(void *))
1185
_callout_stop_safe(struct callout *c, int flags, void (*drain)(void *))
1178
{
1186
{
1179
	struct callout_cpu *cc, *old_cc;
1187
	struct callout_cpu *cc, *old_cc;
(-)sys/sys/callout.h (-2 / +11 lines)
Lines 100-107 Link Here
100
	_callout_init_lock((c), ((rw) != NULL) ? &(rw)->lock_object :	\
100
	_callout_init_lock((c), ((rw) != NULL) ? &(rw)->lock_object :	\
101
	   NULL, (flags))
101
	   NULL, (flags))
102
#define	callout_pending(c)	((c)->c_iflags & CALLOUT_PENDING)
102
#define	callout_pending(c)	((c)->c_iflags & CALLOUT_PENDING)
103
int	callout_reset_sbt_on(struct callout *, sbintime_t, sbintime_t,
103
int	callout_reset_sbt_on_(struct callout *, sbintime_t, sbintime_t,
104
	    void (*)(void *), void *, int, int);
104
	    void (*)(void *), void *, int, int, bool);
105
#define	callout_reset_sbt_on(c, sbt, pr, fn, arg, cpu, flags)		\
106
    callout_reset_sbt_on_((c), (sbt), (pr), (fn), (arg), (cpu), (flags),\
107
        false)
105
#define	callout_reset_sbt(c, sbt, pr, fn, arg, flags)			\
108
#define	callout_reset_sbt(c, sbt, pr, fn, arg, flags)			\
106
    callout_reset_sbt_on((c), (sbt), (pr), (fn), (arg), -1, (flags))
109
    callout_reset_sbt_on((c), (sbt), (pr), (fn), (arg), -1, (flags))
107
#define	callout_reset_sbt_curcpu(c, sbt, pr, fn, arg, flags)		\
110
#define	callout_reset_sbt_curcpu(c, sbt, pr, fn, arg, flags)		\
Lines 110-117 Link Here
110
#define	callout_reset_on(c, to_ticks, fn, arg, cpu)			\
113
#define	callout_reset_on(c, to_ticks, fn, arg, cpu)			\
111
    callout_reset_sbt_on((c), tick_sbt * (to_ticks), 0, (fn), (arg),	\
114
    callout_reset_sbt_on((c), tick_sbt * (to_ticks), 0, (fn), (arg),	\
112
        (cpu), C_HARDCLOCK)
115
        (cpu), C_HARDCLOCK)
116
#define	callout_reset_on_delay(c, to_ticks, fn, arg, cpu)		\
117
    callout_reset_sbt_on_((c), tick_sbt * (to_ticks), 0, (fn), (arg),	\
118
        (cpu), C_HARDCLOCK, true)
113
#define	callout_reset(c, on_tick, fn, arg)				\
119
#define	callout_reset(c, on_tick, fn, arg)				\
114
    callout_reset_on((c), (on_tick), (fn), (arg), -1)
120
    callout_reset_on((c), (on_tick), (fn), (arg), -1)
121
#define callout_reset_delay(c, on_tick, fn, arg)			\
122
    callout_reset_on_delay((c), (on_tick), (fn), (arg), -1)
115
#define	callout_reset_curcpu(c, on_tick, fn, arg)			\
123
#define	callout_reset_curcpu(c, on_tick, fn, arg)			\
116
    callout_reset_on((c), (on_tick), (fn), (arg), PCPU_GET(cpuid))
124
    callout_reset_on((c), (on_tick), (fn), (arg), PCPU_GET(cpuid))
117
#define	callout_schedule_sbt_on(c, sbt, pr, cpu, flags)			\
125
#define	callout_schedule_sbt_on(c, sbt, pr, cpu, flags)			\
Lines 122-127 Link Here
122
#define	callout_schedule_sbt_curcpu(c, sbt, pr, flags)			\
130
#define	callout_schedule_sbt_curcpu(c, sbt, pr, flags)			\
123
    callout_schedule_sbt_on((c), (sbt), (pr), PCPU_GET(cpuid), (flags))
131
    callout_schedule_sbt_on((c), (sbt), (pr), PCPU_GET(cpuid), (flags))
124
int	callout_schedule(struct callout *, int);
132
int	callout_schedule(struct callout *, int);
133
int	callout_schedule_delay(struct callout *, int);
125
int	callout_schedule_on(struct callout *, int, int);
134
int	callout_schedule_on(struct callout *, int, int);
126
#define	callout_schedule_curcpu(c, on_tick)				\
135
#define	callout_schedule_curcpu(c, on_tick)				\
127
    callout_schedule_on((c), (on_tick), PCPU_GET(cpuid))
136
    callout_schedule_on((c), (on_tick), PCPU_GET(cpuid))

Return to bug 217408