summaryrefslogtreecommitdiffstats
path: root/sys/dev/dcons/dcons_os.c
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2009-01-07 21:25:44 +0000
committermarius <marius@FreeBSD.org>2009-01-07 21:25:44 +0000
commit325428c5284e98d68582a2629bcfbbbde1a274ae (patch)
tree5f438ca530f7116355200da08ff6ca3468c15a38 /sys/dev/dcons/dcons_os.c
parentf885f01ae19df45aece1f108bd6c756e6b12b4f4 (diff)
downloadFreeBSD-src-325428c5284e98d68582a2629bcfbbbde1a274ae.zip
FreeBSD-src-325428c5284e98d68582a2629bcfbbbde1a274ae.tar.gz
Check the return values of contigmalloc(9) as well as bus_dma(9)
functions and stop attaching of dcons(4) and dcons_crom(4) if they indicate failure. This fixes a panic seen on sparc64 machines with no free physical memory in the requested 32-bit region but still doesn't make dcons(4)/dcons_crom(4) these work. I think the latter can be fixed by simply specifying ~0UL as the upper limit for contigmalloc(9) and letting the bounce pages and the IOMMU respectively handle limitations of the DMA engine. I didn't want to change that without the consensus of simokawa@ though, who unfortunately didn't reply so far. MFC after: 1 week
Diffstat (limited to 'sys/dev/dcons/dcons_os.c')
-rw-r--r--sys/dev/dcons/dcons_os.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/sys/dev/dcons/dcons_os.c b/sys/dev/dcons/dcons_os.c
index 466f7a0..f4d4181 100644
--- a/sys/dev/dcons/dcons_os.c
+++ b/sys/dev/dcons/dcons_os.c
@@ -336,6 +336,8 @@ dcons_drv_init(int stage)
*/
dg.buf = (struct dcons_buf *) contigmalloc(dg.size,
M_DEVBUF, 0, 0x10000, 0xffffffff, PAGE_SIZE, 0ul);
+ if (dg.buf == NULL)
+ return (-1);
dcons_init(dg.buf, dg.size, sc);
}
@@ -400,8 +402,8 @@ dcons_modevent(module_t mode, int type, void *data)
switch (type) {
case MOD_LOAD:
ret = dcons_drv_init(1);
- dcons_attach();
if (ret == 0) {
+ dcons_attach();
dcons_cnprobe(&dcons_consdev);
dcons_cninit(&dcons_consdev);
cnadd(&dcons_consdev);
@@ -409,13 +411,15 @@ dcons_modevent(module_t mode, int type, void *data)
break;
case MOD_UNLOAD:
printf("dcons: unload\n");
- callout_stop(&dcons_callout);
- cnremove(&dcons_consdev);
- dcons_detach(DCONS_CON);
- dcons_detach(DCONS_GDB);
- dg.buf->magic = 0;
-
- contigfree(dg.buf, DCONS_BUF_SIZE, M_DEVBUF);
+ if (drv_init == 1) {
+ callout_stop(&dcons_callout);
+ cnremove(&dcons_consdev);
+ dcons_detach(DCONS_CON);
+ dcons_detach(DCONS_GDB);
+ dg.buf->magic = 0;
+
+ contigfree(dg.buf, DCONS_BUF_SIZE, M_DEVBUF);
+ }
break;
case MOD_SHUTDOWN:
OpenPOWER on IntegriCloud