openbsd-bugs
[Top] [All Lists]

kernel/3150: kernel i810 AGP driver update for i830 support + bugfixes

To: gnats@openbsd.org
Subject: kernel/3150: kernel i810 AGP driver update for i830 support + bugfixes
From: Brian Fundakowski Feldman <green@FreeBSD.org>
Date: Fri, 14 Mar 2003 18:52:28 -0500
Reply-to: bfeldman@fla.fujitsu.com
Resent-date: Fri, 14 Mar 2003 17:05:03 -0700 (MST)
Resent-from: gnats@cvs.openbsd.org (GNATS Filer)
Resent-message-id: <200303150005.h2F053Qc008332@cvs.openbsd.org>
Resent-reply-to: gnats@cvs.openbsd.org, bfeldman@fla.fujitsu.com
Resent-to: bugs@cvs.openbsd.org
Sender: owner-bugs@openbsd.org
>Number:         3150
>Category:       kernel
>Synopsis:       i810 AGP driver support for i830+ hardware
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 15 00:00:01 GMT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Brian Fundakowski Feldman
>Release:        3.2
>Organization:
-- 
Brian Fundakowski Feldman                    |      http://www.fla.fujitsu.com/
Software Specialist                          |  Fujitsu Laboratories of America
>Environment:
        System      : OpenBSD 3.2
        Architecture: OpenBSD.i386
        Machine     : i386
>Description:
        The agp_i810 driver is too old to support i830+-based hardware.
        An updated driver from NetBSD was taken, style and OpenBSD-local
        changes applied, and driver fixed to actually work with i810
        hardware (that is, modified to do pci configuration with the
        host bridge and NOT the AGP adapter).
>How-To-Repeat:
        Recompile XFree86 4.3.0 with enabled support for OpenBSD agp GART.
        Run XFree86 on an i830+ video card, which will fail to allocate
        any extra memory and only be able to use modes with available
        stolen memory (most of 1MB).
>Fix:

Index: arch/i386/pci/agp_machdep.c
===================================================================
RCS file: /u/cvs/SNOWNET/Soekris/OpenBSD-src/sys/arch/i386/pci/agp_machdep.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 agp_machdep.c
--- arch/i386/pci/agp_machdep.c 12 Jul 2002 20:17:03 -0000      1.1.1.1
+++ arch/i386/pci/agp_machdep.c 14 Mar 2003 14:06:11 -0000
@@ -43,7 +43,8 @@
        { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82810_DC100_GC, agp_i810_attach },
        { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82810E_GC, agp_i810_attach },
        { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82815_FULL_GRAPH, agp_i810_attach 
},
-/*     { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82830MP_IV, agp_i810_attach }, */
+       { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82830MP_IV, agp_i810_attach },
+       { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82845G_IGD, agp_i810_attach },
        { PCI_VENDOR_INTEL, -1, agp_intel_attach },
        { PCI_VENDOR_SIS, -1, agp_sis_attach },
        { PCI_VENDOR_VIATECH, -1, agp_via_attach },
Index: dev/pci/agp_i810.c
===================================================================
RCS file: /u/cvs/SNOWNET/Soekris/OpenBSD-src/sys/dev/pci/agp_i810.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 agp_i810.c
--- dev/pci/agp_i810.c  25 Jul 2002 23:31:04 -0000      1.1.1.1
+++ dev/pci/agp_i810.c  14 Mar 2003 14:06:17 -0000
@@ -1,5 +1,5 @@
 /*     $OpenBSD: agp_i810.c,v 1.3 2002/07/25 23:31:04 fgsch Exp $      */
-/*     $NetBSD: agp_i810.c,v 1.8 2001/09/20 20:00:16 fvdl Exp $        */
+/*     $NetBSD: agp_i810.c,v 1.15 2003/01/31 00:07:39 thorpej Exp $    */
 
 /*-
  * Copyright (c) 2000 Doug Rabson
@@ -30,6 +30,7 @@
  *     $FreeBSD: src/sys/pci/agp_i810.c,v 1.4 2001/07/05 21:28:47 jhb Exp $
  */
 
+#include <sys/cdefs.h>
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -39,41 +40,49 @@
 #include <sys/proc.h>
 #include <sys/device.h>
 #include <sys/conf.h>
-#include <sys/agpio.h>
 
 #include <dev/pci/pcivar.h>
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcidevs.h>
 #include <dev/pci/agpvar.h>
 #include <dev/pci/agpreg.h>
-
 #include <dev/pci/vga_pcivar.h>
 
+#include <sys/agpio.h>
+
 #include <machine/bus.h>
 
 #define READ1(off)     bus_space_read_1(isc->bst, isc->bsh, off)
+#define READ4(off)     bus_space_read_4(isc->bst, isc->bsh, off)
 #define WRITE4(off,v)  bus_space_write_4(isc->bst, isc->bsh, off, v)
 
+#define CHIP_I810 0    /* i810/i815 */
+#define CHIP_I830 1    /* i830/i845 */
+
 struct agp_i810_softc {
-       u_int32_t initial_aperture;        /* aperture size at startup */
+       u_int32_t initial_aperture;     /* aperture size at startup */
        struct agp_gatt *gatt;
-       u_int32_t dcache_size;
-       bus_space_tag_t bst;                /* bus_space tag */
-       bus_space_handle_t bsh;             /* bus_space handle */
+       int chiptype;                   /* i810-like or i830 */
+       u_int32_t dcache_size;          /* i810 only */
+       u_int32_t stolen;               /* number of i830/845 gtt entries
+                                          for stolen memory */
+       bus_space_tag_t bst;            /* bus_space tag */
+       bus_space_handle_t bsh;         /* bus_space handle */
+       struct pci_attach_args bridge_pa;
 };
 
-u_int32_t agp_i810_get_aperture(struct vga_pci_softc *);
-int    agp_i810_set_aperture(struct vga_pci_softc *, u_int32_t);
-int    agp_i810_bind_page(struct vga_pci_softc *, off_t, bus_addr_t);
-int    agp_i810_unbind_page(struct vga_pci_softc *, off_t);
-void   agp_i810_flush_tlb(struct vga_pci_softc *);
-int    agp_i810_enable(struct vga_pci_softc *, u_int32_t mode);
-struct agp_memory *
-       agp_i810_alloc_memory(struct vga_pci_softc *, int, vsize_t);
-int    agp_i810_free_memory(struct vga_pci_softc *, struct agp_memory *);
-int    agp_i810_bind_memory(struct vga_pci_softc *, struct agp_memory *,
-           off_t);
-int    agp_i810_unbind_memory(struct vga_pci_softc *, struct agp_memory *);
+static u_int32_t agp_i810_get_aperture(struct vga_pci_softc *);
+static int agp_i810_set_aperture(struct vga_pci_softc *, u_int32_t);
+static int agp_i810_bind_page(struct vga_pci_softc *, off_t, bus_addr_t);
+static int agp_i810_unbind_page(struct vga_pci_softc *, off_t);
+static void agp_i810_flush_tlb(struct vga_pci_softc *);
+static int agp_i810_enable(struct vga_pci_softc *, u_int32_t mode);
+static struct agp_memory *agp_i810_alloc_memory(struct vga_pci_softc *, int,
+                                               vsize_t);
+static int agp_i810_free_memory(struct vga_pci_softc *, struct agp_memory *);
+static int agp_i810_bind_memory(struct vga_pci_softc *, struct agp_memory *,
+                               off_t);
+static int agp_i810_unbind_memory(struct vga_pci_softc *, struct agp_memory *);
 
 struct agp_methods agp_i810_methods = {
        agp_i810_get_aperture,
@@ -88,9 +97,8 @@
        agp_i810_unbind_memory,
 };
 
-
 int
-agp_i810_attach(struct vga_pci_softc* sc, struct pci_attach_args *pa,
+agp_i810_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa,
                struct pci_attach_args *pchb_pa)
 {
        struct agp_i810_softc *isc;
@@ -102,17 +110,31 @@
                printf(": can't allocate chipset-specific softc\n");
                return (ENOMEM);
        }
-       memset(isc, 0, sizeof *isc);
+       bzero(isc, sizeof *isc);
        sc->sc_chipc = isc;
        sc->sc_methods = &agp_i810_methods;
-       sc->sc_dmat = pa->pa_dmat;      /* XXX fvdl */
+       memcpy(&isc->bridge_pa, pchb_pa, sizeof *pchb_pa);
 
-       if ((error = agp_map_aperture(sc))) {
+       error = agp_map_aperture(sc);
+       if (error != 0) {
                printf(": can't map aperture\n");
                free(isc, M_DEVBUF);
                return (error);
        }
 
+       switch (PCI_PRODUCT(pa->pa_id)) {
+       case PCI_PRODUCT_INTEL_82810_GC:
+       case PCI_PRODUCT_INTEL_82810_DC100_GC:
+       case PCI_PRODUCT_INTEL_82810E_GC:
+       case PCI_PRODUCT_INTEL_82815_FULL_GRAPH:
+               isc->chiptype = CHIP_I810;
+               break;
+       case PCI_PRODUCT_INTEL_82830MP_IV:
+       case PCI_PRODUCT_INTEL_82845G_IGD:
+               isc->chiptype = CHIP_I830;
+               break;
+       }
+
        error = pci_mapreg_map(pa, AGP_I810_MMADR,
            PCI_MAPREG_TYPE_MEM, 0, &isc->bst, &isc->bsh, NULL, NULL, 0);
        if (error != 0) {
@@ -122,93 +144,242 @@
 
        isc->initial_aperture = AGP_GET_APERTURE(sc);
 
-       if (READ1(AGP_I810_DRT) & AGP_I810_DRT_POPULATED)
-               isc->dcache_size = 4 * 1024 * 1024;
-       else
-               isc->dcache_size = 0;
-
-       for (;;) {
-               gatt = agp_alloc_gatt(sc);
-               if (gatt)
-                       break;
+       gatt = malloc(sizeof(struct agp_gatt), M_DEVBUF, M_NOWAIT);
+       if (!gatt) {
+               agp_generic_detach(sc);
+               return (ENOMEM);
+       }
+       isc->gatt = gatt;
 
-               /*
-                * Probably contigmalloc failure. Try reducing the
-                * aperture so that the gatt size reduces.
-                */
-               if (AGP_SET_APERTURE(sc, AGP_GET_APERTURE(sc) / 2)) {
+       gatt->ag_entries = AGP_GET_APERTURE(sc) >> AGP_PAGE_SHIFT;
+
+       if (isc->chiptype == CHIP_I810) {
+               int dummyseg;
+               /* Some i810s have on-chip memory called dcache */
+               if (READ1(AGP_I810_DRT) & AGP_I810_DRT_POPULATED)
+                       isc->dcache_size = 4 * 1024 * 1024;
+               else
+                       isc->dcache_size = 0;
+
+               /* According to the specs the gatt on the i810 must be 64k */
+               if (agp_alloc_dmamem(sc->sc_dmat, 64 * 1024,
+                   0, &gatt->ag_dmamap, (caddr_t *)&gatt->ag_virtual,
+                   &gatt->ag_physical, &gatt->ag_dmaseg, 1, &dummyseg) != 0) {
+                       free(gatt, M_DEVBUF);
                        agp_generic_detach(sc);
                        return (ENOMEM);
                }
-       }
-       isc->gatt = gatt;
 
-       /* Install the GATT. */
-       WRITE4(AGP_I810_PGTBL_CTL, gatt->ag_physical | 1);
+               gatt->ag_size = gatt->ag_entries * sizeof(u_int32_t);
+               memset(gatt->ag_virtual, 0, gatt->ag_size);
+               
+               agp_flush_cache();
+               /* Install the GATT. */
+               WRITE4(AGP_I810_PGTBL_CTL, gatt->ag_physical | 1);
+       } else {
+               /* The i830 automatically initializes the 128k gatt on boot. */
+               pcireg_t reg;
+               u_int32_t pgtblctl;
+               u_int16_t gcc1;
+
+               reg = pci_conf_read(isc->bridge_pa.pa_pc,
+                   isc->bridge_pa.pa_tag, AGP_I830_GCC1);
+               gcc1 = (u_int16_t)(reg >> 16);
+               switch (gcc1 & AGP_I830_GCC1_GMS) {
+               case AGP_I830_GCC1_GMS_STOLEN_512:
+                       isc->stolen = (512 - 132) * 1024 / 4096;
+                       break;
+               case AGP_I830_GCC1_GMS_STOLEN_1024: 
+                       isc->stolen = (1024 - 132) * 1024 / 4096;
+                       break;
+               case AGP_I830_GCC1_GMS_STOLEN_8192: 
+                       isc->stolen = (8192 - 132) * 1024 / 4096;
+                       break;
+               default:
+                       isc->stolen = 0;
+                       printf(
+                           ": unknown memory configuration, disabling\n");
+                       agp_generic_detach(sc);
+                       return (EINVAL);
+               }
+               if (isc->stolen > 0) {
+                       printf(": detected %dk stolen memory\n",
+                           isc->stolen * 4);
+               }
+               printf("%s: aperture size is %dM\n", sc->sc_dev.dv_xname,
+                   isc->initial_aperture / 1024 / 1024);
+
+               /* GATT address is already in there, make sure it's enabled */
+               pgtblctl = READ4(AGP_I810_PGTBL_CTL);
+               pgtblctl |= 1;
+               WRITE4(AGP_I810_PGTBL_CTL, pgtblctl);
+
+               gatt->ag_physical = pgtblctl & ~1;
+       }
 
        /*
         * Make sure the chipset can see everything.
         */
        agp_flush_cache();
 
+       printf("%s", sc->sc_dev.dv_xname);
+
        return (0);
 }
 
-u_int32_t
+#if 0
+static int
+agp_i810_detach(struct vga_pci_softc *sc)
+{
+       int error;
+       struct agp_i810_softc *isc = sc->sc_chipc;
+
+       error = agp_generic_detach(sc);
+       if (error)
+               return (error);
+
+       /* Clear the GATT base. */
+       if (sc->chiptype == CHIP_I810) {
+               WRITE4(AGP_I810_PGTBL_CTL, 0);
+       } else {
+               unsigned int pgtblctl;
+               pgtblctl = READ4(AGP_I810_PGTBL_CTL);
+               pgtblctl &= ~1;
+               WRITE4(AGP_I810_PGTBL_CTL, pgtblctl);
+       }
+
+       /* Put the aperture back the way it started. */
+       AGP_SET_APERTURE(sc, isc->initial_aperture);
+
+       if (sc->chiptype == CHIP_I810) {
+               agp_free_dmamem(sc->sc_dmat, gatt->ag_size, gatt->ag_dmamap,
+                   (caddr_t)gatt->ag_virtual, &gatt->ag_dmaseg, 1);
+       }
+       free(sc->gatt, M_DEVBUF);
+
+       return (0);
+}
+#endif
+
+static u_int32_t
 agp_i810_get_aperture(struct vga_pci_softc *sc)
 {
-       u_int16_t miscc;
+       struct agp_i810_softc *isc = sc->sc_chipc;
+       pcireg_t reg;
 
-       miscc = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_I810_SMRAM) >> 16;
-       if ((miscc & AGP_I810_MISCC_WINSIZE) == AGP_I810_MISCC_WINSIZE_32)
-               return (32 * 1024 * 1024);
-       else
-               return (64 * 1024 * 1024);
+       if (isc->chiptype == CHIP_I810) {
+               u_int16_t miscc;
+
+               reg = pci_conf_read(isc->bridge_pa.pa_pc,
+                   isc->bridge_pa.pa_tag, AGP_I810_SMRAM);
+               miscc = (u_int16_t)(reg >> 16);
+               if ((miscc & AGP_I810_MISCC_WINSIZE) ==
+                   AGP_I810_MISCC_WINSIZE_32)
+                       return (32 * 1024 * 1024);
+               else
+                       return (64 * 1024 * 1024);
+       } else {                /* I830 */
+               u_int16_t gcc1;
+
+               reg = pci_conf_read(isc->bridge_pa.pa_pc,
+                   isc->bridge_pa.pa_tag, AGP_I830_GCC0);
+               gcc1 = (u_int16_t)(reg >> 16);
+               if ((gcc1 & AGP_I830_GCC1_GMASIZE) == AGP_I830_GCC1_GMASIZE_64)
+                       return (64 * 1024 * 1024);
+               else
+                       return (128 * 1024 * 1024);
+       }
 }
 
-int
+static int
 agp_i810_set_aperture(struct vga_pci_softc *sc, u_int32_t aperture)
 {
-       pcireg_t reg, miscc;
+       struct agp_i810_softc *isc = sc->sc_chipc;
+       pcireg_t reg;
 
-       /*
-        * Double check for sanity.
-        */
-       if (aperture != 32 * 1024 * 1024 && aperture != 64 * 1024 * 1024) {
-               printf("AGP: bad aperture size %d\n", aperture);
-               return (EINVAL);
-       }
+       if (isc->chiptype == CHIP_I810) {
+               u_int16_t miscc;
+
+               /*
+                * Double check for sanity.
+                */
+               if (aperture != (32 * 1024 * 1024) &&
+                   aperture != (64 * 1024 * 1024)) {
+                       printf("%s: bad aperture size %d\n",
+                           sc->sc_dev.dv_xname, aperture);
+                       return (EINVAL);
+               }
 
-       reg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_I810_SMRAM);
-       miscc = reg >> 16;
-       miscc &= ~AGP_I810_MISCC_WINSIZE;
-       if (aperture == 32 * 1024 * 1024)
-               miscc |= AGP_I810_MISCC_WINSIZE_32;
-       else
-               miscc |= AGP_I810_MISCC_WINSIZE_64;
-
-       reg &= 0x0000ffff;
-       reg |= (miscc << 16);
-       pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_I810_SMRAM, miscc);
+               reg = pci_conf_read(isc->bridge_pa.pa_pc,
+                   isc->bridge_pa.pa_tag, AGP_I810_SMRAM);
+               miscc = (u_int16_t)(reg >> 16);
+               miscc &= ~AGP_I810_MISCC_WINSIZE;
+               if (aperture == 32 * 1024 * 1024)
+                       miscc |= AGP_I810_MISCC_WINSIZE_32;
+               else
+                       miscc |= AGP_I810_MISCC_WINSIZE_64;
+
+               reg &= 0x0000ffff;
+               reg |= ((pcireg_t)miscc) << 16;
+               pci_conf_write(isc->bridge_pa.pa_pc,
+                   isc->bridge_pa.pa_tag, AGP_I810_SMRAM, reg);
+       } else {                /* I830 */
+               u_int16_t gcc1;
+
+               if (aperture != (64 * 1024 * 1024) &&
+                   aperture != (128 * 1024 * 1024)) {
+                       printf("%s: bad aperture size %d\n",
+                           sc->sc_dev.dv_xname, aperture);
+                       return (EINVAL);
+               }
+               reg = pci_conf_read(isc->bridge_pa.pa_pc,
+                   isc->bridge_pa.pa_tag, AGP_I830_GCC0);
+               gcc1 = (u_int16_t)(reg >> 16);
+               gcc1 &= ~AGP_I830_GCC1_GMASIZE;
+               if (aperture == 64 * 1024 * 1024)
+                       gcc1 |= AGP_I830_GCC1_GMASIZE_64;
+               else
+                       gcc1 |= AGP_I830_GCC1_GMASIZE_128;
+
+               reg &= 0x0000ffff;
+               reg |= ((pcireg_t)gcc1) << 16;
+               pci_conf_write(isc->bridge_pa.pa_pc,
+                   isc->bridge_pa.pa_tag, AGP_I830_GCC0, reg);
+       }
 
        return (0);
 }
 
-int
-agp_i810_bind_page(struct vga_pci_softc *sc, off_t offset, bus_addr_t pa)
+static int
+agp_i810_bind_page(struct vga_pci_softc *sc, off_t offset, bus_addr_t physical)
 {
        struct agp_i810_softc *isc = sc->sc_chipc;
 
-       if (offset < 0 || offset >= (isc->gatt->ag_entries << AGP_PAGE_SHIFT))
+       if (offset < 0 || offset >= (isc->gatt->ag_entries << AGP_PAGE_SHIFT)) {
+#ifdef DEBUG
+               printf("%s: failed: offset 0x%08x, shift %d, entries %d\n",
+                   sc->sc_dev.dv_xname, (int)offset, AGP_PAGE_SHIFT,
+                   isc->gatt->ag_entries);
+#endif
                return (EINVAL);
+       }
 
-       WRITE4(AGP_I810_GTT + (u_int32_t)(offset >> AGP_PAGE_SHIFT) * 4,
-           pa | 1);
+       if (isc->chiptype == CHIP_I810) {
+               if ((offset >> AGP_PAGE_SHIFT) < isc->stolen) {
+#ifdef DEBUG
+                       printf("%s: trying to bind into stolen memory",
+                           sc->sc_dev.dv_xname);
+#endif
+                       return (EINVAL);
+               }
+       }
 
+       WRITE4(AGP_I810_GTT + (u_int32_t)(offset >> AGP_PAGE_SHIFT) * 4,
+           physical | 1);
        return (0);
 }
 
-int
+static int
 agp_i810_unbind_page(struct vga_pci_softc *sc, off_t offset)
 {
        struct agp_i810_softc *isc = sc->sc_chipc;
@@ -216,6 +387,16 @@
        if (offset < 0 || offset >= (isc->gatt->ag_entries << AGP_PAGE_SHIFT))
                return (EINVAL);
 
+       if (isc->chiptype == CHIP_I830 ) {
+               if ((offset >> AGP_PAGE_SHIFT) < isc->stolen) {
+#ifdef DEBUG
+                       printf("%s: trying to unbind from stolen memory",
+                           sc->sc_dev.dv_xname);
+#endif
+                       return (EINVAL);
+               }
+       }
+
        WRITE4(AGP_I810_GTT + (u_int32_t)(offset >> AGP_PAGE_SHIFT) * 4, 0);
        return (0);
 }
@@ -223,18 +404,19 @@
 /*
  * Writing via memory mapped registers already flushes all TLBs.
  */
-void
+static void
 agp_i810_flush_tlb(struct vga_pci_softc *sc)
 {
 }
 
-int
+static int
 agp_i810_enable(struct vga_pci_softc *sc, u_int32_t mode)
 {
+
        return (0);
 }
 
-struct agp_memory *
+static struct agp_memory *
 agp_i810_alloc_memory(struct vga_pci_softc *sc, int type, vsize_t size)
 {
        struct agp_i810_softc *isc = sc->sc_chipc;
@@ -245,6 +427,8 @@
                /*
                 * Mapping local DRAM into GATT.
                 */
+               if (isc->chiptype == CHIP_I830 )
+                       return (NULL);
                if (size != isc->dcache_size)
                        return (NULL);
        } else if (type == 2) {
@@ -260,17 +444,21 @@
        mem->am_id = sc->sc_nextid++;
        mem->am_size = size;
        mem->am_type = type;
-       
+
        if (type == 2) {
+               /*
+                * Allocate and wire down the page now so that we can
+                * get its physical address.
+                */
                mem->am_dmaseg = malloc(sizeof *mem->am_dmaseg, M_DEVBUF,
                    M_WAITOK);
-
                if ((error = agp_alloc_dmamem(sc->sc_dmat, size, 0,
                    &mem->am_dmamap, &mem->am_virtual, &mem->am_physical,
                    mem->am_dmaseg, 1, &mem->am_nseg)) != 0) {
-                       free(mem, M_DEVBUF);
                        free(mem->am_dmaseg, M_DEVBUF);
-                       printf("agp: agp_alloc_dmamem(%d)\n", error);
+                       free(mem, M_DEVBUF);
+                       printf("%s: agp_alloc_dmamem(%d)\n",
+                           sc->sc_dev.dv_xname, error);
                        return (NULL);
                }
        } else if (type != 1) {
@@ -278,7 +466,8 @@
                    size / PAGE_SIZE + 1, size, 0, BUS_DMA_NOWAIT,
                    &mem->am_dmamap)) != 0) {
                        free(mem, M_DEVBUF);
-                       printf("agp: bus_dmamap_create(%d)\n", error);
+                       printf("%s: bus_dmamap_create(%d)\n",
+                           sc->sc_dev.dv_xname, error);
                        return (NULL);
                }
        }
@@ -289,12 +478,12 @@
        return (mem);
 }
 
-int
+static int
 agp_i810_free_memory(struct vga_pci_softc *sc, struct agp_memory *mem)
 {
        if (mem->am_is_bound)
                return (EBUSY);
-       
+
        if (mem->am_type == 2) {
                agp_free_dmamem(sc->sc_dmat, mem->am_size, mem->am_dmamap,
                    mem->am_virtual, mem->am_dmaseg, mem->am_nseg);
@@ -307,7 +496,7 @@
        return (0);
 }
 
-int
+static int
 agp_i810_bind_memory(struct vga_pci_softc *sc, struct agp_memory *mem,
                     off_t offset)
 {
@@ -322,10 +511,8 @@
         */
        regval = bus_space_read_4(isc->bst, isc->bsh, AGP_I810_PGTBL_CTL);
        if (regval != (isc->gatt->ag_physical | 1)) {
-#if 0
                printf("agp_i810_bind_memory: PGTBL_CTL is 0x%x - fixing\n",
                    regval);
-#endif
                bus_space_write_4(isc->bst, isc->bsh, AGP_I810_PGTBL_CTL,
                    isc->gatt->ag_physical | 1);
        }
@@ -339,16 +526,20 @@
        }
 
        if (mem->am_type != 1)
-               return agp_generic_bind_memory(sc, mem, offset);
+               return (agp_generic_bind_memory(sc, mem, offset));
 
-       for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE)
+       if (isc->chiptype == CHIP_I830)
+               return (EINVAL);
+
+       for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE) {
                WRITE4(AGP_I810_GTT +
                    (u_int32_t)(offset >> AGP_PAGE_SHIFT) * 4, i | 3);
-
+       }
+       mem->am_is_bound = 1;
        return (0);
 }
 
-int
+static int
 agp_i810_unbind_memory(struct vga_pci_softc *sc, struct agp_memory *mem)
 {
        struct agp_i810_softc *isc = sc->sc_chipc;
@@ -365,8 +556,11 @@
        if (mem->am_type != 1)
                return (agp_generic_unbind_memory(sc, mem));
 
+       if (isc->chiptype == CHIP_I830)
+               return (EINVAL);
+
        for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE)
                WRITE4(AGP_I810_GTT + (i >> AGP_PAGE_SHIFT) * 4, 0);
-
+       mem->am_is_bound = 0;
        return (0);
 }
Index: dev/pci/agpreg.h
===================================================================
RCS file: /u/cvs/SNOWNET/Soekris/OpenBSD-src/sys/dev/pci/agpreg.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 agpreg.h
--- dev/pci/agpreg.h    12 Jul 2002 20:17:03 -0000      1.1.1.1
+++ dev/pci/agpreg.h    14 Mar 2003 14:06:17 -0000
@@ -154,4 +154,20 @@
 #define AGP_I810_DRT_POPULATED 0x01
 #define AGP_I810_GTT           0x10000
 
+/*
+ * Config registers for i830MG device 0
+ */
+#define AGP_I830_GCC0                   0x50
+#define AGP_I830_GCC1                   0x52
+#define AGP_I830_GCC1_DEV2              0x08
+#define AGP_I830_GCC1_DEV2_ENABLED      0x00
+#define AGP_I830_GCC1_DEV2_DISABLED     0x08
+#define AGP_I830_GCC1_GMS               0x70
+#define AGP_I830_GCC1_GMS_STOLEN_512    0x20
+#define AGP_I830_GCC1_GMS_STOLEN_1024   0x30
+#define AGP_I830_GCC1_GMS_STOLEN_8192   0x40
+#define AGP_I830_GCC1_GMASIZE           0x01
+#define AGP_I830_GCC1_GMASIZE_64        0x01
+#define AGP_I830_GCC1_GMASIZE_128       0x00
+
 #endif /* !_PCI_AGPREG_H_ */
Index: dev/pci/pcidevs
===================================================================
RCS file: /u/cvs/SNOWNET/Soekris/OpenBSD-src/sys/dev/pci/pcidevs,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 pcidevs
--- dev/pci/pcidevs     30 Sep 2002 19:50:32 -0000      1.1.1.1
+++ dev/pci/pcidevs     14 Mar 2003 14:06:17 -0000
@@ -1439,7 +1439,7 @@
 product INTEL 82860_PCI3       0x2535  82860 PCI-PCI
 product INTEL 82860_PCI4       0x2536  82860 PCI-PCI
 product INTEL 82845G           0x2560  82845G/GL
-product INTEL 82845G_IV                0x2562  82845G/GL Video
+product INTEL 82845G_IGD       0x2562  82845G/GL Video
 product INTEL 82830MP_IO_1     0x3575  82830MP CPU to I/O Bridge 1
 product INTEL 82830MP_AGP      0x3576  82830MP CPU to AGP Bridge
 product INTEL 82830MP_IV       0x3577  82830MP Integrated Video
Index: dev/pci/pcidevs.h
===================================================================
RCS file: /u/cvs/SNOWNET/Soekris/OpenBSD-src/sys/dev/pci/pcidevs.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 pcidevs.h
--- dev/pci/pcidevs.h   30 Sep 2002 19:50:40 -0000      1.1.1.1
+++ dev/pci/pcidevs.h   14 Mar 2003 14:06:17 -0000
@@ -1444,7 +1444,7 @@
 #define        PCI_PRODUCT_INTEL_82860_PCI3    0x2535          /* 82860 
PCI-PCI */
 #define        PCI_PRODUCT_INTEL_82860_PCI4    0x2536          /* 82860 
PCI-PCI */
 #define        PCI_PRODUCT_INTEL_82845G        0x2560          /* 82845G/GL */
-#define        PCI_PRODUCT_INTEL_82845G_IV     0x2562          /* 82845G/GL 
Video */
+#define        PCI_PRODUCT_INTEL_82845G_IGD    0x2562          /* 82845G/GL 
Video */
 #define        PCI_PRODUCT_INTEL_82830MP_IO_1  0x3575          /* 82830MP CPU 
to I/O Bridge 1 */
 #define        PCI_PRODUCT_INTEL_82830MP_AGP   0x3576          /* 82830MP CPU 
to AGP Bridge */
 #define        PCI_PRODUCT_INTEL_82830MP_IV    0x3577          /* 82830MP 
Integrated Video */
Index: dev/pci/pcidevs_data.h
===================================================================
RCS file: /u/cvs/SNOWNET/Soekris/OpenBSD-src/sys/dev/pci/pcidevs_data.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 pcidevs_data.h
--- dev/pci/pcidevs_data.h      30 Sep 2002 19:50:40 -0000      1.1.1.1
+++ dev/pci/pcidevs_data.h      14 Mar 2003 14:06:18 -0000
@@ -2755,7 +2755,7 @@
            "82845G/GL",
        },
        {
-           PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82845G_IV,
+           PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82845G_IGD,
            "82845G/GL Video",
        },
        {

>Release-Note:
>Audit-Trail:
>Unformatted:
 >From MAILER-DAEMON Fri Mar 14 18:48:26 2003
 Received: from localhost (localhost)
        by bfeldman.my.domain (8.12.6/8.12.6) id h2ENmJoI025286;
        Fri, 14 Mar 2003 18:48:25 -0500 (EST)
 Date: Fri, 14 Mar 2003 18:48:25 -0500 (EST)
 From: Mail Delivery Subsystem <MAILER-DAEMON>
 Message-Id: <200303142348.h2ENmJoI025286@bfeldman.my.domain>
 To: <bfeldman@bfeldman.my.domain>
 MIME-Version: 1.0
 Content-Type: multipart/report; report-type=delivery-status;
        boundary="h2ENmJoI025286.1047685705/bfeldman.my.domain"
 Subject: Returned mail: see transcript for details
 Auto-Submitted: auto-generated (failure)
 Status: RO
 
 This is a MIME-encapsulated message
 
 --h2ENmJoI025286.1047685705/bfeldman.my.domain
 
 The original message was received at Fri, 14 Mar 2003 18:35:34 -0500 (EST)
 from bfeldman@localhost.my.domain [IPv6:::1]
 
    ----- The following addresses had permanent fatal errors -----
 <green@FreeBSD.org>
     (reason: 553 5.1.8 <bfeldman@bfeldman.my.domain>... Domain of sender 
address bfeldman@bfeldman.my.domain does not exist)
 
    ----- Transcript of session follows -----
 ... while talking to mailserv2.fla.fujitsu.com.:
 >>> MAIL From:<bfeldman@bfeldman.my.domain> SIZE=22285
 <<< 553 5.1.8 <bfeldman@bfeldman.my.domain>... Domain of sender address 
bfeldman@bfeldman.my.domain does not exist
 501 5.6.0 Data format error
 
 --h2ENmJoI025286.1047685705/bfeldman.my.domain
 Content-Type: message/delivery-status
 
 Reporting-MTA: dns; bfeldman.my.domain
 Arrival-Date: Fri, 14 Mar 2003 18:35:34 -0500 (EST)
 
 Final-Recipient: RFC822; green@FreeBSD.org
 Action: failed
 Status: 5.1.8
 Diagnostic-Code: SMTP; 553 5.1.8 <bfeldman@bfeldman.my.domain>... Domain of 
sender address bfeldman@bfeldman.my.domain does not exist
 Last-Attempt-Date: Fri, 14 Mar 2003 18:48:25 -0500 (EST)
 
 --h2ENmJoI025286.1047685705/bfeldman.my.domain
 Content-Type: message/rfc822
 
 Return-Path: <bfeldman@bfeldman.my.domain>
 Received: from bfeldman.my.domain (bfeldman@localhost.my.domain [IPv6:::1])
        by bfeldman.my.domain (8.12.6/8.12.6) with ESMTP id h2ENZYuR030788;
        Fri, 14 Mar 2003 18:35:34 -0500 (EST)
 Received: (from bfeldman@localhost)
        by bfeldman.my.domain (8.12.6/8.12.6/Submit) id h2ENZYxp016088;
        Fri, 14 Mar 2003 18:35:34 -0500 (EST)
 Date: Fri, 14 Mar 2003 18:35:34 -0500 (EST)
 Message-Id: <200303142335.h2ENZYxp016088@bfeldman.my.domain>
 To: gnats@openbsd.org
 Subject: kernel i810 AGP driver update for i830 support + bugfixes
 From: bfeldman@fla.fujitsu.com
 Cc: green@FreeBSD.org
 X-sendbug-version: 3.97

<Prev in Thread] Current Thread [Next in Thread>
  • kernel/3150: kernel i810 AGP driver update for i830 support + bugfixes, Brian Fundakowski Feldman <=