diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2010-04-07 20:40:19 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2010-04-07 20:40:19 +0000 |
commit | 2684741ec578fae605c877d6f1447b324df407dc (patch) | |
tree | 48ee0a8e9110c4ee6f1ac7db708f65e3fe133585 /sys/dev/pci | |
parent | 33f3b92741917542fce7e6f6d96299052f851827 (diff) |
Make intagp restore pgtbl_ctl and the scratch page to the gtt on resume.
When we move more towards kms we'll need to save/restore what is bound
to the aperture, but right now this is not needed (since we always
unbind everything before we go down anyway).
"can not hurt" deraadt@. tested by halex, deraadt and maybe some others.
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/agp_i810.c | 67 |
1 files changed, 46 insertions, 21 deletions
diff --git a/sys/dev/pci/agp_i810.c b/sys/dev/pci/agp_i810.c index 1d52e60ecc3..80a06307dae 100644 --- a/sys/dev/pci/agp_i810.c +++ b/sys/dev/pci/agp_i810.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_i810.c,v 1.59 2010/03/03 10:19:34 oga Exp $ */ +/* $OpenBSD: agp_i810.c,v 1.60 2010/04/07 20:40:18 oga Exp $ */ /*- * Copyright (c) 2000 Doug Rabson @@ -89,6 +89,8 @@ struct agp_i810_softc { }; void agp_i810_attach(struct device *, struct device *, void *); +int agp_i810_activate(struct device *arg, int act); +void agp_i810_configure(struct agp_i810_softc *); int agp_i810_probe(struct device *, void *, void *); int agp_i810_get_chiptype(struct pci_attach_args *); void agp_i810_bind_page(void *, bus_size_t, paddr_t, int); @@ -106,7 +108,8 @@ extern void intagp_dma_sync(bus_dma_tag_t, bus_dmamap_t, bus_addr_t, bus_size_t, int); struct cfattach intagp_ca = { - sizeof(struct agp_i810_softc), agp_i810_probe, agp_i810_attach + sizeof(struct agp_i810_softc), agp_i810_probe, agp_i810_attach, + NULL, agp_i810_activate, }; struct cfdriver intagp_cd = { @@ -464,16 +467,48 @@ agp_i810_attach(struct device *parent, struct device *self, void *aux) printf(": unknown initialisation\n"); return; } - agp_flush_cache(); - /* Install the GATT. */ - WRITE4(AGP_I810_PGTBL_CTL, gatt->ag_physical | 1); - /* Intel recommends that you have a fake page bound to the gtt always */ if (agp_alloc_dmamem(pa->pa_dmat, AGP_PAGE_SIZE, &isc->scrib_dmamap, &tmp, &isc->scrib_seg) != 0) { printf(": can't get scribble page\n"); return; } + agp_i810_configure(isc); + + isc->agpdev = (struct agp_softc *)agp_attach_bus(pa, &agp_i810_methods, + isc->isc_apaddr, isc->isc_apsize, &isc->dev); + return; +out: + + if (isc->gatt) + if (isc->gatt->ag_size != 0) + agp_free_dmamem(pa->pa_dmat, gatt->ag_size, + gatt->ag_dmamap, &gatt->ag_dmaseg); + free(isc->gatt, M_AGP); + if (isc->gtt_map != NULL) + vga_pci_bar_unmap(isc->gtt_map); + if (isc->map != NULL) + vga_pci_bar_unmap(isc->map); +} + +int +agp_i810_activate(struct device *arg, int act) +{ + struct agp_i810_softc *isc = (struct agp_i810_softc *)arg; + + switch(act) { + case DVACT_RESUME: + agp_i810_configure(isc); + break; + } + + return (0); +} +void +agp_i810_configure(struct agp_i810_softc *isc) +{ + bus_addr_t tmp; + tmp = isc->isc_apaddr; if (isc->chiptype == CHIP_I810) { tmp += isc->dcache_size; @@ -481,30 +516,20 @@ agp_i810_attach(struct device *parent, struct device *self, void *aux) tmp += isc->stolen << AGP_PAGE_SHIFT; } + agp_flush_cache(); + /* Install the GATT. */ + WRITE4(AGP_I810_PGTBL_CTL, isc->gatt->ag_physical | 1); + /* initialise all gtt entries to point to scribble page */ for (; tmp < (isc->isc_apaddr + isc->isc_apsize); tmp += AGP_PAGE_SIZE) agp_i810_unbind_page(isc, tmp); + /* XXX we'll need to restore the GTT contents when we go kms */ /* * Make sure the chipset can see everything. */ agp_flush_cache(); - - isc->agpdev = (struct agp_softc *)agp_attach_bus(pa, &agp_i810_methods, - isc->isc_apaddr, isc->isc_apsize, &isc->dev); - return; -out: - - if (isc->gatt) - if (isc->gatt->ag_size != 0) - agp_free_dmamem(pa->pa_dmat, gatt->ag_size, - gatt->ag_dmamap, &gatt->ag_dmaseg); - free(isc->gatt, M_AGP); - if (isc->gtt_map != NULL) - vga_pci_bar_unmap(isc->gtt_map); - if (isc->map != NULL) - vga_pci_bar_unmap(isc->map); } #if 0 |