summaryrefslogtreecommitdiff
path: root/sys/dev/pci/agp_amd.c
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2009-04-20 01:28:46 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2009-04-20 01:28:46 +0000
commitd5500d36a0181d72b896403311ff144ddf639ae0 (patch)
treefddb6f174c7deed1cdc511d580c419839c941b35 /sys/dev/pci/agp_amd.c
parent8c6f93358f3f400eb044a708e4fef86d4d2e61f0 (diff)
Don't map all agp memory we allocate.
If we're just going to be making it available to userland (the X server), just use load_raw and make sure it's zeroed with BUS_DMA_ZERO. Should save $AMOUNT_BOUND_TO_GART kva. Most kernel users also write through the gart, so no mapping there either. tested by sthen and todd a while back.
Diffstat (limited to 'sys/dev/pci/agp_amd.c')
-rw-r--r--sys/dev/pci/agp_amd.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/sys/dev/pci/agp_amd.c b/sys/dev/pci/agp_amd.c
index 714213f7b00..e33573e789e 100644
--- a/sys/dev/pci/agp_amd.c
+++ b/sys/dev/pci/agp_amd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp_amd.c,v 1.9 2008/11/09 15:11:19 oga Exp $ */
+/* $OpenBSD: agp_amd.c,v 1.10 2009/04/20 01:28:45 oga Exp $ */
/* $NetBSD: agp_amd.c,v 1.6 2001/10/06 02:48:50 thorpej Exp $ */
/*-
@@ -111,25 +111,30 @@ agp_amd_alloc_gatt(bus_dma_tag_t dmat, bus_size_t apsize)
gatt = malloc(sizeof(struct agp_amd_gatt), M_AGP, M_NOWAIT);
if (!gatt)
return (0);
+ gatt->ag_size = AGP_PAGE_SIZE + entries * sizeof(u_int32_t);
- if (agp_alloc_dmamem(dmat,
- AGP_PAGE_SIZE + entries * sizeof(u_int32_t), 0,
- &gatt->ag_dmamap, &vdir, &gatt->ag_pdir,
- &gatt->ag_dmaseg, 1, &gatt->ag_nseg) != 0) {
+ if (agp_alloc_dmamem(dmat, gatt->ag_size, &gatt->ag_dmamap,
+ &gatt->ag_pdir, &gatt->ag_dmaseg) != 0) {
printf("failed to allocate GATT\n");
free(gatt, M_AGP);
return (NULL);
}
+ if (bus_dmamem_map(dmat, &gatt->ag_dmaseg, 1, gatt->ag_size,
+ &vdir, BUS_DMA_NOWAIT) != 0) {
+ printf("failed to map GATT\n");
+ agp_free_dmamem(dmat, gatt->ag_size, gatt->ag_dmamap,
+ &gatt->ag_dmaseg);
+ free(gatt, M_AGP);
+ return (NULL);
+ }
+
gatt->ag_vdir = (u_int32_t *)vdir;
gatt->ag_entries = entries;
gatt->ag_virtual = (u_int32_t *)(vdir + AGP_PAGE_SIZE);
gatt->ag_physical = gatt->ag_pdir + AGP_PAGE_SIZE;
gatt->ag_size = AGP_PAGE_SIZE + entries * sizeof(u_int32_t);
- memset(gatt->ag_vdir, 0, AGP_PAGE_SIZE);
- memset(gatt->ag_virtual, 0, entries * sizeof(u_int32_t));
-
/*
* Map the pages of the GATT into the page directory.
*/
@@ -151,6 +156,7 @@ agp_amd_alloc_gatt(bus_dma_tag_t dmat, bus_size_t apsize)
void
agp_amd_free_gatt(bus_dma_tag_t dmat, struct agp_amd_gatt *gatt)
{
+ bus_dmamem_unmap(dmat, gatt->ag_virtual, gatt->ag_size);
agp_free_dmamem(dmat, gatt->ag_size,
gatt->ag_dmamap, (caddr_t)gatt->ag_virtual, &gatt->ag_dmaseg,
gatt->ag_nseg);