Wed Jun 11 17:01:31 2014 UTC ()
Back out previous mistake.

If you mixed `cvs diff' and `cvs commit' in your shell history,
remember to hit C-p the right number of times before RET.  Oops.


(riastradh)
diff -r1.91 -r1.92 src/sys/dev/pci/agp_i810.c

cvs diff -r1.91 -r1.92 src/sys/dev/pci/agp_i810.c (expand / switch to unified diff)

--- src/sys/dev/pci/agp_i810.c 2014/06/11 16:58:29 1.91
+++ src/sys/dev/pci/agp_i810.c 2014/06/11 17:01:31 1.92
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: agp_i810.c,v 1.91 2014/06/11 16:58:29 riastradh Exp $ */ 1/* $NetBSD: agp_i810.c,v 1.92 2014/06/11 17:01:31 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2000 Doug Rabson 4 * Copyright (c) 2000 Doug Rabson
5 * Copyright (c) 2000 Ruslan Ermilov 5 * Copyright (c) 2000 Ruslan Ermilov
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. 27 * SUCH DAMAGE.
28 * 28 *
29 * $FreeBSD$ 29 * $FreeBSD$
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v 1.91 2014/06/11 16:58:29 riastradh Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v 1.92 2014/06/11 17:01:31 riastradh Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/systm.h> 36#include <sys/systm.h>
37#include <sys/malloc.h> 37#include <sys/malloc.h>
38#include <sys/kernel.h> 38#include <sys/kernel.h>
39#include <sys/proc.h> 39#include <sys/proc.h>
40#include <sys/device.h> 40#include <sys/device.h>
41#include <sys/conf.h> 41#include <sys/conf.h>
42#include <sys/xcall.h> 42#include <sys/xcall.h>
43 43
44#include <dev/pci/pcivar.h> 44#include <dev/pci/pcivar.h>
45#include <dev/pci/pcireg.h> 45#include <dev/pci/pcireg.h>
46#include <dev/pci/pcidevs.h> 46#include <dev/pci/pcidevs.h>
@@ -1232,46 +1232,46 @@ agp_i810_bind_memory(struct agp_softc *s @@ -1232,46 +1232,46 @@ agp_i810_bind_memory(struct agp_softc *s
1232 * to the GTT through the MMIO window. 1232 * to the GTT through the MMIO window.
1233 * Until the issue is solved, simply restore it. 1233 * Until the issue is solved, simply restore it.
1234 */ 1234 */
1235 pgtblctl = bus_space_read_4(isc->bst, isc->bsh, AGP_I810_PGTBL_CTL); 1235 pgtblctl = bus_space_read_4(isc->bst, isc->bsh, AGP_I810_PGTBL_CTL);
1236 if (pgtblctl != isc->pgtblctl) { 1236 if (pgtblctl != isc->pgtblctl) {
1237 printf("agp_i810_bind_memory: PGTBL_CTL is 0x%"PRIx32 1237 printf("agp_i810_bind_memory: PGTBL_CTL is 0x%"PRIx32
1238 " - fixing\n", pgtblctl); 1238 " - fixing\n", pgtblctl);
1239 bus_space_write_4(isc->bst, isc->bsh, AGP_I810_PGTBL_CTL, 1239 bus_space_write_4(isc->bst, isc->bsh, AGP_I810_PGTBL_CTL,
1240 isc->pgtblctl); 1240 isc->pgtblctl);
1241 } 1241 }
1242 1242
1243 switch (mem->am_type) { 1243 switch (mem->am_type) {
1244 case AGP_I810_MEMTYPE_MAIN: 1244 case AGP_I810_MEMTYPE_MAIN:
1245 error = agp_generic_bind_memory(sc, mem, offset); 1245 error = agp_i810_bind_memory_main(sc, mem, offset);
1246 break; 1246 break;
1247 case AGP_I810_MEMTYPE_DCACHE: 1247 case AGP_I810_MEMTYPE_DCACHE:
1248 error = agp_i810_bind_memory_dcache(sc, mem, offset); 1248 error = agp_i810_bind_memory_dcache(sc, mem, offset);
1249 break; 1249 break;
1250 case AGP_I810_MEMTYPE_HWCURSOR: 1250 case AGP_I810_MEMTYPE_HWCURSOR:
1251 error = agp_i810_bind_memory_hwcursor(sc, mem, offset); 1251 error = agp_i810_bind_memory_hwcursor(sc, mem, offset);
1252 break; 1252 break;
1253 default: 1253 default:
1254 panic("invalid agp i810 memory type: %d", mem->am_type); 1254 panic("invalid agp i810 memory type: %d", mem->am_type);
1255 } 1255 }
1256 if (error) 1256 if (error)
1257 return error; 1257 return error;
1258 1258
1259 /* Success! */ 1259 /* Success! */
1260 mem->am_is_bound = 1; 1260 mem->am_is_bound = 1;
1261 return 0; 1261 return 0;
1262} 1262}
1263 1263
1264static int __unused 1264static int
1265agp_i810_bind_memory_main(struct agp_softc *sc, struct agp_memory *mem, 1265agp_i810_bind_memory_main(struct agp_softc *sc, struct agp_memory *mem,
1266 off_t offset) 1266 off_t offset)
1267{ 1267{
1268 struct agp_i810_softc *const isc = sc->as_chipc; 1268 struct agp_i810_softc *const isc = sc->as_chipc;
1269 bus_dma_segment_t *segs; 1269 bus_dma_segment_t *segs;
1270 int nseg_alloc, nseg; 1270 int nseg_alloc, nseg;
1271 uint32_t i, j; 1271 uint32_t i, j;
1272 unsigned seg; 1272 unsigned seg;
1273 bus_addr_t addr; 1273 bus_addr_t addr;
1274 bus_size_t len; 1274 bus_size_t len;
1275 int error; 1275 int error;
1276 1276
1277 /* Ensure we have a sane size/offset that will fit. */ 1277 /* Ensure we have a sane size/offset that will fit. */
@@ -1284,27 +1284,27 @@ agp_i810_bind_memory_main(struct agp_sof @@ -1284,27 +1284,27 @@ agp_i810_bind_memory_main(struct agp_sof
1284 if (offset > (((isc->gtt_size/4) << AGP_PAGE_SHIFT) - 1284 if (offset > (((isc->gtt_size/4) << AGP_PAGE_SHIFT) -
1285 mem->am_size)) 1285 mem->am_size))
1286 return EINVAL; 1286 return EINVAL;
1287 1287
1288 /* Allocate an array of DMA segments. */ 1288 /* Allocate an array of DMA segments. */
1289 nseg_alloc = (mem->am_size >> AGP_PAGE_SHIFT); 1289 nseg_alloc = (mem->am_size >> AGP_PAGE_SHIFT);
1290 if (nseg_alloc > (SIZE_MAX / sizeof(*segs))) { 1290 if (nseg_alloc > (SIZE_MAX / sizeof(*segs))) {
1291 error = ENOMEM; 1291 error = ENOMEM;
1292 goto fail0; 1292 goto fail0;
1293 } 1293 }
1294 segs = malloc(nseg_alloc * sizeof(*segs), M_AGP, M_WAITOK); 1294 segs = malloc(nseg_alloc * sizeof(*segs), M_AGP, M_WAITOK);
1295 1295
1296 /* Allocate DMA-safe physical segments. */ 1296 /* Allocate DMA-safe physical segments. */
1297 error = bus_dmamem_alloc(sc->as_dmat, mem->am_size, AGP_PAGE_SIZE, 1297 error = bus_dmamem_alloc(sc->as_dmat, mem->am_size, PAGE_SIZE,
1298 0, segs, nseg_alloc, &nseg, BUS_DMA_WAITOK); 1298 0, segs, nseg_alloc, &nseg, BUS_DMA_WAITOK);
1299 if (error) 1299 if (error)
1300 goto fail1; 1300 goto fail1;
1301 KASSERT(nseg <= nseg_alloc); 1301 KASSERT(nseg <= nseg_alloc);
1302 1302
1303 /* Shrink the array of DMA segments if we can. */ 1303 /* Shrink the array of DMA segments if we can. */
1304 if (nseg < nseg_alloc) { 1304 if (nseg < nseg_alloc) {
1305 segs = realloc(segs, nseg, M_AGP, M_WAITOK); 1305 segs = realloc(segs, nseg, M_AGP, M_WAITOK);
1306 nseg_alloc = nseg; 1306 nseg_alloc = nseg;
1307 } 1307 }
1308 1308
1309 /* Load the DMA map. */ 1309 /* Load the DMA map. */
1310 error = bus_dmamap_load_raw(sc->as_dmat, mem->am_dmamap, 1310 error = bus_dmamap_load_raw(sc->as_dmat, mem->am_dmamap,
@@ -1404,27 +1404,27 @@ fail0: for (j = 0; j < i; j += AGP_PAGE_ @@ -1404,27 +1404,27 @@ fail0: for (j = 0; j < i; j += AGP_PAGE_
1404static int 1404static int
1405agp_i810_unbind_memory(struct agp_softc *sc, struct agp_memory *mem) 1405agp_i810_unbind_memory(struct agp_softc *sc, struct agp_memory *mem)
1406{ 1406{
1407 struct agp_i810_softc *isc = sc->as_chipc; 1407 struct agp_i810_softc *isc = sc->as_chipc;
1408 u_int32_t i; 1408 u_int32_t i;
1409 1409
1410 if (!mem->am_is_bound) 1410 if (!mem->am_is_bound)
1411 return EINVAL; 1411 return EINVAL;
1412 1412
1413 switch (mem->am_type) { 1413 switch (mem->am_type) {
1414 case AGP_I810_MEMTYPE_MAIN: 1414 case AGP_I810_MEMTYPE_MAIN:
1415 case AGP_I810_MEMTYPE_HWCURSOR: 1415 case AGP_I810_MEMTYPE_HWCURSOR:
1416 for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE) 1416 for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE)
1417 (void)agp_i810_unbind_page(sc, mem->am_offset + i); 1417 agp_i810_unbind_page(sc, mem->am_offset + i);
1418 break; 1418 break;
1419 case AGP_I810_MEMTYPE_DCACHE: 1419 case AGP_I810_MEMTYPE_DCACHE:
1420 KASSERT(isc->chiptype == CHIP_I810); 1420 KASSERT(isc->chiptype == CHIP_I810);
1421 for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE) 1421 for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE)
1422 (void)agp_i810_write_gtt_entry(isc, i, 0); 1422 (void)agp_i810_write_gtt_entry(isc, i, 0);
1423 break; 1423 break;
1424 default: 1424 default:
1425 panic("invalid agp i810 memory type: %d", mem->am_type); 1425 panic("invalid agp i810 memory type: %d", mem->am_type);
1426 } 1426 }
1427 1427
1428 mem->am_is_bound = 0; 1428 mem->am_is_bound = 0;
1429 return 0; 1429 return 0;
1430} 1430}