? sys/dev/pci/drm/drm_pciids.txt Index: sys/dev/pci/agp.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/agp.c,v retrieving revision 1.59 diff -u -b -r1.59 agp.c --- sys/dev/pci/agp.c 9 Jun 2008 06:49:54 -0000 1.59 +++ sys/dev/pci/agp.c 24 Jun 2008 16:46:54 -0000 @@ -276,7 +276,7 @@ return (1); } -static const int agp_max[][2] = { +static const unsigned int agp_max[][2] = { {0, 0}, {32, 4}, {64, 28}, @@ -543,7 +543,7 @@ int error; bus_dma_segment_t *segs, *seg; bus_addr_t pa; - int contigpages, nseg; + int nseg; mutex_enter(&sc->as_mtx); @@ -564,57 +564,40 @@ } /* - * XXXfvdl * The memory here needs to be directly accessable from the * AGP video card, so it should be allocated using bus_dma. * However, it need not be contiguous, since individual pages * are translated using the GATT. - * - * Using a large chunk of contiguous memory may get in the way - * of other subsystems that may need one, so we try to be friendly - * and ask for allocation in chunks of a minimum of 8 pages - * of contiguous memory on average, falling back to 4, 2 and 1 - * if really needed. Larger chunks are preferred, since allocating - * a bus_dma_segment per page would be overkill. */ - for (contigpages = 8; contigpages > 0; contigpages >>= 1) { - nseg = (mem->am_size / (contigpages * PAGE_SIZE)) + 1; + nseg = (mem->am_size + PAGE_SIZE - 1) / PAGE_SIZE; segs = malloc(nseg * sizeof *segs, M_AGP, M_WAITOK); - if (segs == NULL) { - mutex_exit(&sc->as_mtx); - return ENOMEM; - } - if (bus_dmamem_alloc(sc->as_dmat, mem->am_size, PAGE_SIZE, 0, - segs, nseg, &mem->am_nseg, - contigpages > 1 ? - BUS_DMA_NOWAIT : BUS_DMA_WAITOK) != 0) { + + if ((error = bus_dmamem_alloc(sc->as_dmat, mem->am_size, + PAGE_SIZE, 0, segs, nseg, &mem->am_nseg, + BUS_DMA_WAITOK)) != 0) { free(segs, M_AGP); - continue; + mutex_exit(&sc->as_mtx); + return (error); } - if (bus_dmamem_map(sc->as_dmat, segs, mem->am_nseg, - mem->am_size, &mem->am_virtual, BUS_DMA_WAITOK) != 0) { + if ((error = bus_dmamem_map(sc->as_dmat, segs, mem->am_nseg, + mem->am_size, &mem->am_virtual, BUS_DMA_WAITOK)) != 0) { bus_dmamem_free(sc->as_dmat, segs, mem->am_nseg); free(segs, M_AGP); - continue; + mutex_exit(&sc->as_mtx); + return (error); } - if (bus_dmamap_load(sc->as_dmat, mem->am_dmamap, - mem->am_virtual, mem->am_size, NULL, BUS_DMA_WAITOK) != 0) { + if ((error = bus_dmamap_load(sc->as_dmat, mem->am_dmamap, + mem->am_virtual, mem->am_size, NULL, BUS_DMA_WAITOK)) != 0) { bus_dmamem_unmap(sc->as_dmat, mem->am_virtual, mem->am_size); bus_dmamem_free(sc->as_dmat, segs, mem->am_nseg); free(segs, M_AGP); - continue; - } - mem->am_dmaseg = segs; - break; - } - - if (contigpages == 0) { mutex_exit(&sc->as_mtx); - return ENOMEM; + return (error); } + mem->am_dmaseg = segs; /* * Bind the individual pages and flush the chipset's Index: sys/dev/pci/agp_i810.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/agp_i810.c,v retrieving revision 1.54 diff -u -b -r1.54 agp_i810.c --- sys/dev/pci/agp_i810.c 9 Jun 2008 06:49:54 -0000 1.54 +++ sys/dev/pci/agp_i810.c 24 Jun 2008 16:46:55 -0000 @@ -571,7 +571,7 @@ { struct agp_i810_softc *isc = sc->as_chipc; pcireg_t reg; - u_int16_t miscc, gcc1, msac; + u_int16_t miscc, gcc1; switch (isc->chiptype) { case CHIP_I810: @@ -593,14 +593,8 @@ return 128 * 1024 * 1024; case CHIP_I915: case CHIP_G33: - reg = pci_conf_read(sc->as_pc, sc->as_tag, AGP_I915_MSAC); - msac = (u_int16_t)(reg >> 16); - if (msac & AGP_I915_MSAC_APER_128M) - return 128 * 1024 * 1024; - else - return 256 * 1024 * 1024; case CHIP_I965: - return 512 * 1024 * 1024; + return sc->as_apsize; default: aprint_error(": Unknown chipset\n"); }