Module Name: src
Committed By: gsutre
Date: Tue Jan 25 10:52:11 UTC 2011
Modified Files:
src/sys/dev/pci: agp_i810.c
Log Message:
Typos, fix memory binding for memory type 2, and add consistency checks.
>From OpenBSD.
ok jmcneill@
To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/dev/pci/agp_i810.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/agp_i810.c
diff -u src/sys/dev/pci/agp_i810.c:1.69 src/sys/dev/pci/agp_i810.c:1.70
--- src/sys/dev/pci/agp_i810.c:1.69 Sat Nov 13 13:52:04 2010
+++ src/sys/dev/pci/agp_i810.c Tue Jan 25 10:52:11 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: agp_i810.c,v 1.69 2010/11/13 13:52:04 uebayasi Exp $ */
+/* $NetBSD: agp_i810.c,v 1.70 2011/01/25 10:52:11 gsutre Exp $ */
/*-
* Copyright (c) 2000 Doug Rabson
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v 1.69 2010/11/13 13:52:04 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v 1.70 2011/01/25 10:52:11 gsutre Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -819,10 +819,10 @@
return EINVAL;
}
- if (isc->chiptype != CHIP_I830) {
+ if (isc->chiptype != CHIP_I810) {
if ((offset >> AGP_PAGE_SHIFT) < isc->stolen) {
#ifdef AGP_DEBUG
- printf("%s: trying to bind into stolen memory",
+ printf("%s: trying to bind into stolen memory\n",
device_xname(sc->as_dev));
#endif
return EINVAL;
@@ -844,7 +844,7 @@
if (isc->chiptype != CHIP_I810 ) {
if ((offset >> AGP_PAGE_SHIFT) < isc->stolen) {
#ifdef AGP_DEBUG
- printf("%s: trying to unbind from stolen memory",
+ printf("%s: trying to unbind from stolen memory\n",
device_xname(sc->as_dev));
#endif
return EINVAL;
@@ -968,6 +968,9 @@
struct agp_i810_softc *isc = sc->as_chipc;
u_int32_t regval, i;
+ if (mem->am_is_bound != 0)
+ return EINVAL;
+
/*
* XXX evil hack: the PGTBL_CTL appearently gets overwritten by the
* X server for mysterious reasons which leads to crashes if we write
@@ -983,7 +986,9 @@
}
if (mem->am_type == 2) {
- agp_i810_write_gtt_entry(isc, offset, mem->am_physical | 1);
+ for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE)
+ agp_i810_bind_page(sc, offset + i,
+ mem->am_physical + i);
mem->am_offset = offset;
mem->am_is_bound = 1;
return 0;
@@ -996,7 +1001,7 @@
return EINVAL;
for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE)
- agp_i810_write_gtt_entry(isc, offset, i | 3);
+ agp_i810_write_gtt_entry(isc, i, i | 3);
mem->am_is_bound = 1;
return 0;
}
@@ -1007,8 +1012,12 @@
struct agp_i810_softc *isc = sc->as_chipc;
u_int32_t i;
+ if (mem->am_is_bound == 0)
+ return EINVAL;
+
if (mem->am_type == 2) {
- agp_i810_write_gtt_entry(isc, mem->am_offset, 0);
+ for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE)
+ agp_i810_unbind_page(sc, mem->am_offset + i);
mem->am_offset = 0;
mem->am_is_bound = 0;
return 0;