Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Typos, fix memory binding for memory type 2, and...



details:   https://anonhg.NetBSD.org/src/rev/0fc87af39017
branches:  trunk
changeset: 761353:0fc87af39017
user:      gsutre <gsutre%NetBSD.org@localhost>
date:      Tue Jan 25 10:52:11 2011 +0000

description:
Typos, fix memory binding for memory type 2, and add consistency checks.
>From OpenBSD.

ok jmcneill@

diffstat:

 sys/dev/pci/agp_i810.c |  25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diffs (84 lines):

diff -r a3d3dd6ac0aa -r 0fc87af39017 sys/dev/pci/agp_i810.c
--- a/sys/dev/pci/agp_i810.c    Tue Jan 25 10:28:56 2011 +0000
+++ b/sys/dev/pci/agp_i810.c    Tue Jan 25 10:52:11 2011 +0000
@@ -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;



Home | Main Index | Thread Index | Old Index