Lines 52-57
Link Here
|
52 |
#include <sys/proc.h> |
52 |
#include <sys/proc.h> |
53 |
#include <sys/ucred.h> |
53 |
#include <sys/ucred.h> |
54 |
|
54 |
|
|
|
55 |
#include <machine/atomic.h> |
55 |
#include <machine/bus.h> |
56 |
#include <machine/bus.h> |
56 |
|
57 |
|
57 |
#include <dev/dcons/dcons.h> |
58 |
#include <dev/dcons/dcons.h> |
Lines 135-146
extern struct gdb_dbgport *gdb_cur;
Link Here
|
135 |
#endif |
136 |
#endif |
136 |
|
137 |
|
137 |
static tsw_outwakeup_t dcons_outwakeup; |
138 |
static tsw_outwakeup_t dcons_outwakeup; |
|
|
139 |
static tsw_free_t dcons_free; |
138 |
|
140 |
|
139 |
static struct ttydevsw dcons_ttydevsw = { |
141 |
static struct ttydevsw dcons_ttydevsw = { |
140 |
.tsw_flags = TF_NOPREFIX, |
142 |
.tsw_flags = TF_NOPREFIX, |
141 |
.tsw_outwakeup = dcons_outwakeup, |
143 |
.tsw_outwakeup = dcons_outwakeup, |
|
|
144 |
.tsw_free = dcons_free, |
142 |
}; |
145 |
}; |
143 |
|
146 |
|
|
|
147 |
static int dcons_close_refs; |
148 |
|
144 |
#if (defined(GDB) || defined(DDB)) |
149 |
#if (defined(GDB) || defined(DDB)) |
145 |
static int |
150 |
static int |
146 |
dcons_check_break(struct dcons_softc *dc, int c) |
151 |
dcons_check_break(struct dcons_softc *dc, int c) |
Lines 198-203
dcons_os_putc(struct dcons_softc *dc, int c)
Link Here
|
198 |
} |
203 |
} |
199 |
|
204 |
|
200 |
static void |
205 |
static void |
|
|
206 |
dcons_free(void *xsc __unused) |
207 |
{ |
208 |
|
209 |
/* Our deferred free has arrived, now we're waiting for one fewer. */ |
210 |
atomic_subtract_rel_int(&dcons_close_refs, 1); |
211 |
} |
212 |
|
213 |
static void |
201 |
dcons_outwakeup(struct tty *tp) |
214 |
dcons_outwakeup(struct tty *tp) |
202 |
{ |
215 |
{ |
203 |
struct dcons_softc *dc; |
216 |
struct dcons_softc *dc; |
Lines 396-401
dcons_detach(int port)
Link Here
|
396 |
dc = &sc[port]; |
409 |
dc = &sc[port]; |
397 |
tp = dc->tty; |
410 |
tp = dc->tty; |
398 |
|
411 |
|
|
|
412 |
/* tty_rel_gone() schedules a deferred free callback, count it. */ |
413 |
atomic_add_int(&dcons_close_refs, 1); |
399 |
tty_lock(tp); |
414 |
tty_lock(tp); |
400 |
tty_rel_gone(tp); |
415 |
tty_rel_gone(tp); |
401 |
|
416 |
|
Lines 430-435
dcons_modevent(module_t mode, int type, void *data
Link Here
|
430 |
contigfree(dg.buf, DCONS_BUF_SIZE, M_DEVBUF); |
445 |
contigfree(dg.buf, DCONS_BUF_SIZE, M_DEVBUF); |
431 |
} |
446 |
} |
432 |
|
447 |
|
|
|
448 |
/* Wait for tty deferred free callbacks to complete. */ |
449 |
while (atomic_load_acq_int(&dcons_close_refs) > 0) |
450 |
pause_sbt("dcunld", mstosbt(50), mstosbt(10), 0); |
433 |
break; |
451 |
break; |
434 |
case MOD_SHUTDOWN: |
452 |
case MOD_SHUTDOWN: |
435 |
#if 0 /* Keep connection after halt */ |
453 |
#if 0 /* Keep connection after halt */ |