diff --git a/openbsd/src/sys/arch/amd64/amd64/sg_dma.c b/openbsd/src/sys/arch/amd64/amd64/sg_dma.c index 67d6eee..7f5f33e 100644 --- a/openbsd/src/sys/arch/amd64/amd64/sg_dma.c +++ b/openbsd/src/sys/arch/amd64/amd64/sg_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sg_dma.c,v 1.10 2011/04/07 15:30:13 miod Exp $ */ +/* $OpenBSD: sg_dma.c,v 1.11 2013/03/17 21:49:00 kettenis Exp $ */ /* * Copyright (c) 2009 Owain G. Ainsworth * @@ -786,6 +786,18 @@ sg_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map) _bus_dmamap_unload(t, map); } +/* + * Reload a dvmamap. + */ +void +sg_dmamap_reload(bus_dma_tag_t t, bus_dmamap_t map, int flags) +{ + struct sg_cookie *is = t->_cookie; + struct sg_page_map *spm = map->_dm_cookie; + + sg_iomap_load_map(is, spm, spm->spm_start, flags); +} + /* * Alloc dma safe memory, telling the backend that we're scatter gather * to ease pressure on the vm. diff --git a/openbsd/src/sys/arch/amd64/include/bus.h b/openbsd/src/sys/arch/amd64/include/bus.h index 4cd23ba..4ae57e5 100644 --- a/openbsd/src/sys/arch/amd64/include/bus.h +++ b/openbsd/src/sys/arch/amd64/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.28 2013/01/29 01:15:57 dlg Exp $ */ +/* $OpenBSD: bus.h,v 1.29 2013/03/17 21:49:00 kettenis Exp $ */ /* $NetBSD: bus.h,v 1.6 1996/11/10 03:19:25 thorpej Exp $ */ /*- @@ -753,6 +753,7 @@ int sg_dmamap_load_buffer(bus_dma_tag_t, bus_dmamap_t, void *, bus_size_t, struct proc *, int, int *, int); int sg_dmamap_load_physarray(bus_dma_tag_t, bus_dmamap_t, paddr_t *, int, int, int *, int); +void sg_dmamap_reload(bus_dma_tag_t, bus_dmamap_t, int); int sg_dmamem_alloc(bus_dma_tag_t, bus_size_t, bus_size_t, bus_size_t, bus_dma_segment_t *, int, int *, int); diff --git a/openbsd/src/sys/arch/amd64/pci/agp_machdep.c b/openbsd/src/sys/arch/amd64/pci/agp_machdep.c index 94a94d5..b59377e 100644 --- a/openbsd/src/sys/arch/amd64/pci/agp_machdep.c +++ b/openbsd/src/sys/arch/amd64/pci/agp_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_machdep.c,v 1.6 2010/05/10 22:06:04 oga Exp $ */ +/* $OpenBSD: agp_machdep.c,v 1.7 2013/03/17 21:49:00 kettenis Exp $ */ /* * Copyright (c) 2008 - 2009 Owain G. Ainsworth @@ -174,6 +174,12 @@ agp_bus_dma_set_alignment(bus_dma_tag_t tag, bus_dmamap_t dmam, sg_dmamap_set_alignment(tag, dmam, alignment); } +void +agp_bus_dma_rebind(bus_dma_tag_t tag, bus_dmamap_t dmam, int flags) +{ + sg_dmamap_reload(tag, dmam, flags); +} + struct agp_map { bus_space_tag_t bst; bus_space_handle_t bsh; diff --git a/openbsd/src/sys/arch/i386/i386/pmap.c b/openbsd/src/sys/arch/i386/i386/pmap.c index f8f05cb..1fc5261 100644 --- a/openbsd/src/sys/arch/i386/i386/pmap.c +++ b/openbsd/src/sys/arch/i386/i386/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.157 2012/03/09 13:01:28 ariane Exp $ */ +/* $OpenBSD: pmap.c,v 1.158 2013/02/13 20:45:41 kurt Exp $ */ /* $NetBSD: pmap.c,v 1.91 2000/06/02 17:46:37 thorpej Exp $ */ /* @@ -589,6 +589,8 @@ pmap_exec_account(struct pmap *pm, vaddr_t va, } } +#define SEGDESC_LIMIT(sd) (ptoa(((sd).sd_hilimit << 16) | (sd).sd_lolimit)) + /* * Fixup the code segment to cover all potential executable mappings. * Called by kernel SEGV trap handler. @@ -600,6 +602,7 @@ pmap_exec_fixup(struct vm_map *map, struct trapframe *tf, struct pcb *pcb) struct vm_map_entry *ent; struct pmap *pm = vm_map_pmap(map); vaddr_t va = 0; + vaddr_t pm_cs, gdt_cs; vm_map_lock(map); RB_FOREACH_REVERSE(ent, uvm_map_addr, &map->addr) { @@ -614,7 +617,19 @@ pmap_exec_fixup(struct vm_map *map, struct trapframe *tf, struct pcb *pcb) va = trunc_page(ent->end - 1); vm_map_unlock(map); - if (va <= pm->pm_hiexec) { + pm_cs = SEGDESC_LIMIT(pm->pm_codeseg); + gdt_cs = SEGDESC_LIMIT(curcpu()->ci_gdt[GUCODE_SEL].sd); + + /* + * Another thread running on another cpu can change + * pm_hiexec and pm_codeseg. If this has happened + * during our timeslice, our gdt code segment will + * be stale. So only allow the fault through if the + * faulting address is less then pm_hiexec and our + * gdt code segment is not stale. + */ + if (va <= pm->pm_hiexec && pm_cs == pm->pm_hiexec && + gdt_cs == pm->pm_hiexec) { return (0); } diff --git a/openbsd/src/sys/arch/i386/i386/sg_dma.c b/openbsd/src/sys/arch/i386/i386/sg_dma.c index 1f45bf2..afbfb0a 100644 --- a/openbsd/src/sys/arch/i386/i386/sg_dma.c +++ b/openbsd/src/sys/arch/i386/i386/sg_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sg_dma.c,v 1.7 2011/04/07 15:30:15 miod Exp $ */ +/* $OpenBSD: sg_dma.c,v 1.8 2013/03/17 21:49:00 kettenis Exp $ */ /* * Copyright (c) 2009 Owain G. Ainsworth * @@ -786,6 +786,18 @@ sg_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map) _bus_dmamap_unload(t, map); } +/* + * Reload a dvmamap. + */ +void +sg_dmamap_reload(bus_dma_tag_t t, bus_dmamap_t map, int flags) +{ + struct sg_cookie *is = t->_cookie; + struct sg_page_map *spm = map->_dm_cookie; + + sg_iomap_load_map(is, spm, spm->spm_start, flags); +} + /* * Alloc dma safe memory, telling the backend that we're scatter gather * to ease pressure on the vm. diff --git a/openbsd/src/sys/arch/i386/include/bus.h b/openbsd/src/sys/arch/i386/include/bus.h index a6b79e9..a0bfb33 100644 --- a/openbsd/src/sys/arch/i386/include/bus.h +++ b/openbsd/src/sys/arch/i386/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.57 2013/01/29 01:15:57 dlg Exp $ */ +/* $OpenBSD: bus.h,v 1.58 2013/03/17 21:49:00 kettenis Exp $ */ /* $NetBSD: bus.h,v 1.6 1996/11/10 03:19:25 thorpej Exp $ */ /*- @@ -693,8 +693,8 @@ int sg_dmamap_load_buffer(bus_dma_tag_t, bus_dmamap_t, void *, bus_size_t, struct proc *, int, int *, int); int sg_dmamap_load_physarray(bus_dma_tag_t, bus_dmamap_t, paddr_t *, int, int, int *, int); +void sg_dmamap_reload(bus_dma_tag_t, bus_dmamap_t, int); int sg_dmamem_alloc(bus_dma_tag_t, bus_size_t, bus_size_t, bus_size_t, bus_dma_segment_t *, int, int *, int); - #endif /* _MACHINE_BUS_H_ */ diff --git a/openbsd/src/sys/arch/i386/pci/agp_machdep.c b/openbsd/src/sys/arch/i386/pci/agp_machdep.c index e6eaa41..c6634a9 100644 --- a/openbsd/src/sys/arch/i386/pci/agp_machdep.c +++ b/openbsd/src/sys/arch/i386/pci/agp_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_machdep.c,v 1.12 2010/05/10 22:06:04 oga Exp $ */ +/* $OpenBSD: agp_machdep.c,v 1.13 2013/03/17 21:49:00 kettenis Exp $ */ /* * Copyright (c) 2008 - 2009 Owain G. Ainsworth @@ -174,6 +174,12 @@ agp_bus_dma_set_alignment(bus_dma_tag_t tag, bus_dmamap_t dmam, sg_dmamap_set_alignment(tag, dmam, alignment); } +void +agp_bus_dma_rebind(bus_dma_tag_t tag, bus_dmamap_t dmam, int flags) +{ + sg_dmamap_reload(tag, dmam, flags); +} + struct agp_map { bus_space_tag_t bst; bus_addr_t addr; diff --git a/openbsd/src/sys/dev/pci/agp_i810.c b/openbsd/src/sys/dev/pci/agp_i810.c index e57ee91..c2485c9 100644 --- a/openbsd/src/sys/dev/pci/agp_i810.c +++ b/openbsd/src/sys/dev/pci/agp_i810.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_i810.c,v 1.71 2012/09/25 10:19:46 jsg Exp $ */ +/* $OpenBSD: agp_i810.c,v 1.74 2013/03/18 12:02:56 jsg Exp $ */ /*- * Copyright (c) 2000 Doug Rabson @@ -60,6 +60,10 @@ /* Memory is snooped, must not be accessed through gtt from the cpu. */ #define INTEL_COHERENT 0x6 +#define GEN6_PTE_UNCACHED (1 << 1) +#define GEN6_PTE_CACHE_LLC (2 << 1) +#define GEN6_PTE_CACHE_LLC_MLC (3 << 1) + enum { CHIP_NONE = 0, /* not integrated graphics */ CHIP_I810 = 1, /* i810/i815 */ @@ -594,6 +598,7 @@ agp_i810_attach(struct device *parent, struct device *self, void *aux) isc->agpdev = (struct agp_softc *)agp_attach_bus(pa, &agp_i810_methods, isc->isc_apaddr, isc->isc_apsize, &isc->dev); + isc->agpdev->sc_stolen_entries = isc->stolen; return; out: @@ -725,8 +730,21 @@ agp_i810_bind_page(void *sc, bus_addr_t offset, paddr_t physical, int flags) * COHERENT mappings mean set the snoop bit. this should never be * accessed by the gpu through the gtt. */ - if (flags & BUS_DMA_COHERENT) - physical |= INTEL_COHERENT; + switch (isc->chiptype) { + case CHIP_SANDYBRIDGE: + case CHIP_IVYBRIDGE: + if (flags & BUS_DMA_GTT_NOCACHE) + physical |= GEN6_PTE_UNCACHED; + if (flags & BUS_DMA_GTT_CACHE_LLC) + physical |= GEN6_PTE_CACHE_LLC; + if (flags & BUS_DMA_GTT_CACHE_LLC_MLC) + physical |= GEN6_PTE_CACHE_LLC_MLC; + break; + default: + if (flags & BUS_DMA_COHERENT) + physical |= INTEL_COHERENT; + break; + } intagp_write_gtt(isc, offset - isc->isc_apaddr, physical); } @@ -945,14 +963,19 @@ intagp_write_gtt(struct agp_i810_softc *isc, bus_size_t off, paddr_t v) if (v != 0) { pte = v | INTEL_ENABLED; /* 965+ can do 36-bit addressing, add in the extra bits */ - if (isc->chiptype == CHIP_I965 || - isc->chiptype == CHIP_G4X || - isc->chiptype == CHIP_PINEVIEW || - isc->chiptype == CHIP_G33 || - isc->chiptype == CHIP_IRONLAKE || - isc->chiptype == CHIP_SANDYBRIDGE || - isc->chiptype == CHIP_IVYBRIDGE) { + switch (isc->chiptype) { + case CHIP_I965: + case CHIP_G4X: + case CHIP_PINEVIEW: + case CHIP_G33: + case CHIP_IRONLAKE: pte |= (v & 0x0000000f00000000ULL) >> 28; + break; + /* gen6+ can do 40 bit addressing */ + case CHIP_SANDYBRIDGE: + case CHIP_IVYBRIDGE: + pte |= (v & 0x000000ff00000000ULL) >> 28; + break; } } diff --git a/openbsd/src/sys/dev/pci/agpvar.h b/openbsd/src/sys/dev/pci/agpvar.h index d394060..556d019 100644 --- a/openbsd/src/sys/dev/pci/agpvar.h +++ b/openbsd/src/sys/dev/pci/agpvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: agpvar.h,v 1.23 2012/12/06 15:05:21 mpi Exp $ */ +/* $OpenBSD: agpvar.h,v 1.26 2013/03/18 12:02:56 jsg Exp $ */ /* $NetBSD: agpvar.h,v 1.4 2001/10/01 21:54:48 fvdl Exp $ */ /*- @@ -43,6 +43,11 @@ #define AGPUNIT(x) minor(x) +/* we can't use the BUS_DMA_NOCACHE here or it won't get mapped via the gtt */ +#define BUS_DMA_GTT_NOCACHE (1 << 30) +#define BUS_DMA_GTT_CACHE_LLC (1 << 29) +#define BUS_DMA_GTT_CACHE_LLC_MLC (1 << 28) + struct agp_attach_args { char *aa_busname; struct pci_attach_args *aa_pa; @@ -131,6 +136,7 @@ struct agp_softc { pcitag_t sc_pcitag; bus_addr_t sc_apaddr; bus_size_t sc_apsize; + uint32_t sc_stolen_entries; pcireg_t sc_id; int sc_opened; @@ -187,6 +193,7 @@ int agp_bus_dma_init(struct agp_softc *, bus_addr_t, bus_addr_t, void agp_bus_dma_destroy(struct agp_softc *, bus_dma_tag_t); void agp_bus_dma_set_alignment(bus_dma_tag_t, bus_dmamap_t, u_long); +void agp_bus_dma_rebind(bus_dma_tag_t, bus_dmamap_t, int); void *agp_map(struct agp_softc *, bus_addr_t, bus_size_t, bus_space_handle_t *); diff --git a/openbsd/src/sys/dev/pci/pcidevs b/openbsd/src/sys/dev/pci/pcidevs index 6db7979..65ff0eb 100644 --- a/openbsd/src/sys/dev/pci/pcidevs +++ b/openbsd/src/sys/dev/pci/pcidevs @@ -1,4 +1,4 @@ -$OpenBSD: pcidevs,v 1.1669 2013/02/08 07:58:18 jasper Exp $ +$OpenBSD: pcidevs,v 1.1670 2013/03/14 14:47:00 brynet Exp $ /* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */ /* @@ -693,6 +693,12 @@ product AMD AMD64_14_PCIE_2 0x1513 AMD64 14h PCIE product AMD AMD64_14_PCIE_3 0x1514 AMD64 14h PCIE product AMD AMD64_14_PCIE_4 0x1515 AMD64 14h PCIE product AMD AMD64_14_PCIE_5 0x1516 AMD64 14h PCIE +product AMD AMD64_15_LINK 0x1600 AMD64 15h Link Cfg +product AMD AMD64_15_ADDR 0x1601 AMD64 15h Address Map +product AMD AMD64_15_DRAM 0x1602 AMD64 15h DRAM Cfg +product AMD AMD64_15_MISC 0x1603 AMD64 15h Misc Cfg +product AMD AMD64_15_CPU_PM 0x1604 AMD64 15h CPU Power +product AMD AMD64_15_HB 0x1605 AMD64 15h Host product AMD AMD64_14_LINK 0x1700 AMD64 14h Link Cfg product AMD AMD64_14_ADDR 0x1701 AMD64 14h Address Map product AMD AMD64_14_DRAM 0x1702 AMD64 14h DRAM Cfg diff --git a/openbsd/src/sys/dev/pci/vga_pci.c b/openbsd/src/sys/dev/pci/vga_pci.c index 56f977a..e4fcbf4 100644 --- a/openbsd/src/sys/dev/pci/vga_pci.c +++ b/openbsd/src/sys/dev/pci/vga_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vga_pci.c,v 1.69 2012/10/08 21:47:50 deraadt Exp $ */ +/* $OpenBSD: vga_pci.c,v 1.71 2013/03/18 10:12:40 kettenis Exp $ */ /* $NetBSD: vga_pci.c,v 1.3 1998/06/08 06:55:58 thorpej Exp $ */ /* @@ -227,7 +227,6 @@ vga_pci_attach(struct device *parent, struct device *self, void *aux) struct pci_attach_args *pa = aux; pcireg_t reg; struct vga_pci_softc *sc = (struct vga_pci_softc *)self; - #if !defined(SMALL_KERNEL) && NACPI > 0 int prod, vend, subid, subprod, subvend, i; #endif @@ -239,18 +238,18 @@ vga_pci_attach(struct device *parent, struct device *self, void *aux) reg |= PCI_COMMAND_MASTER_ENABLE; pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, reg); + sc->sc_type = WSDISPLAY_TYPE_PCIVGA; + #ifdef VESAFB if (vesabios_softc != NULL && vesabios_softc->sc_nmodes > 0) { sc->sc_textmode = vesafb_get_mode(sc); printf(", vesafb\n"); sc->sc_vc = vga_extended_attach(self, pa->pa_iot, pa->pa_memt, - WSDISPLAY_TYPE_PCIVGA, vga_pci_mmap); + sc->sc_type, vga_pci_mmap); return; } #endif printf("\n"); - sc->sc_vc = vga_common_attach(self, pa->pa_iot, pa->pa_memt, - WSDISPLAY_TYPE_PCIVGA); vga_pci_bar_init(sc, pa); @@ -294,6 +293,9 @@ vga_pci_attach(struct device *parent, struct device *self, void *aux) #if NDRM > 0 config_found_sm(self, aux, NULL, drmsubmatch); #endif + + sc->sc_vc = vga_common_attach(self, pa->pa_iot, pa->pa_memt, + sc->sc_type); } int diff --git a/openbsd/src/sys/dev/pci/vga_pcivar.h b/openbsd/src/sys/dev/pci/vga_pcivar.h index defbc7a..ed3ec62 100644 --- a/openbsd/src/sys/dev/pci/vga_pcivar.h +++ b/openbsd/src/sys/dev/pci/vga_pcivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vga_pcivar.h,v 1.15 2012/08/22 20:58:30 mpi Exp $ */ +/* $OpenBSD: vga_pcivar.h,v 1.16 2013/03/18 10:12:40 kettenis Exp $ */ /* $NetBSD: vga_pcivar.h,v 1.1 1998/03/22 15:16:19 drochner Exp $ */ /* @@ -55,6 +55,7 @@ struct vga_pci_bar { struct vga_pci_softc { struct device sc_dev; struct vga_config *sc_vc; + int sc_type; struct pci_attach_args pa; struct vga_pci_bar *bars[VGA_PCI_MAX_BARS]; @@ -79,7 +80,6 @@ struct vga_pci_softc { u_char sc_cmap_red[256]; /* saved color map */ u_char sc_cmap_green[256]; u_char sc_cmap_blue[256]; - #endif }; diff --git a/openbsd/src/sys/uvm/uvm_page.c b/openbsd/src/sys/uvm/uvm_page.c index 7834b55..be1eb53 100644 --- a/openbsd/src/sys/uvm/uvm_page.c +++ b/openbsd/src/sys/uvm/uvm_page.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_page.c,v 1.115 2013/02/07 17:38:12 beck Exp $ */ +/* $OpenBSD: uvm_page.c,v 1.122 2013/03/12 21:10:11 deraadt Exp $ */ /* $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $ */ /* @@ -191,9 +191,10 @@ void uvm_page_init(vaddr_t *kvm_startp, vaddr_t *kvm_endp) { vsize_t freepages, pagecount, n; - vm_page_t pagearray; + vm_page_t pagearray, curpg; int lcv, i; - paddr_t paddr; + paddr_t paddr, pgno; + struct vm_physseg *seg; /* * init the page queues and page queue locks @@ -229,8 +230,8 @@ uvm_page_init(vaddr_t *kvm_startp, vaddr_t *kvm_endp) */ freepages = 0; - for (lcv = 0 ; lcv < vm_nphysseg ; lcv++) - freepages += (vm_physmem[lcv].end - vm_physmem[lcv].start); + for (lcv = 0, seg = vm_physmem; lcv < vm_nphysseg ; lcv++, seg++) + freepages += (seg->end - seg->start); /* * we now know we have (PAGE_SIZE * freepages) bytes of memory we can @@ -252,8 +253,8 @@ uvm_page_init(vaddr_t *kvm_startp, vaddr_t *kvm_endp) * init the vm_page structures and put them in the correct place. */ - for (lcv = 0 ; lcv < vm_nphysseg ; lcv++) { - n = vm_physmem[lcv].end - vm_physmem[lcv].start; + for (lcv = 0, seg = vm_physmem; lcv < vm_nphysseg ; lcv++, seg++) { + n = seg->end - seg->start; if (n > pagecount) { panic("uvm_page_init: lost %ld page(s) in init", (long)(n - pagecount)); @@ -262,20 +263,22 @@ uvm_page_init(vaddr_t *kvm_startp, vaddr_t *kvm_endp) } /* set up page array pointers */ - vm_physmem[lcv].pgs = pagearray; + seg->pgs = pagearray; pagearray += n; pagecount -= n; - vm_physmem[lcv].lastpg = vm_physmem[lcv].pgs + (n - 1); + seg->lastpg = seg->pgs + (n - 1); /* init and free vm_pages (we've already zeroed them) */ - paddr = ptoa(vm_physmem[lcv].start); - for (i = 0 ; i < n ; i++, paddr += PAGE_SIZE) { - vm_physmem[lcv].pgs[i].phys_addr = paddr; + pgno = seg->start; + paddr = ptoa(pgno); + for (i = 0, curpg = seg->pgs; i < n; + i++, curpg++, pgno++, paddr += PAGE_SIZE) { + curpg->phys_addr = paddr; #ifdef __HAVE_VM_PAGE_MD - VM_MDPAGE_INIT(&vm_physmem[lcv].pgs[i]); + VM_MDPAGE_INIT(curpg); #endif - if (atop(paddr) >= vm_physmem[lcv].avail_start && - atop(paddr) <= vm_physmem[lcv].avail_end) { + if (pgno >= seg->avail_start && + pgno <= seg->avail_end) { uvmexp.npages++; } } @@ -283,9 +286,8 @@ uvm_page_init(vaddr_t *kvm_startp, vaddr_t *kvm_endp) /* * Add pages to free pool. */ - uvm_pmr_freepages(&vm_physmem[lcv].pgs[ - vm_physmem[lcv].avail_start - vm_physmem[lcv].start], - vm_physmem[lcv].avail_end - vm_physmem[lcv].avail_start); + uvm_pmr_freepages(&seg->pgs[seg->avail_start - seg->start], + seg->avail_end - seg->avail_start); } /* @@ -448,54 +450,53 @@ uvm_pageboot_alloc(vsize_t size) boolean_t uvm_page_physget(paddr_t *paddrp) { - int lcv, x; + int lcv; + struct vm_physseg *seg; /* pass 1: try allocating from a matching end */ #if (VM_PHYSSEG_STRAT == VM_PSTRAT_BIGFIRST) || \ (VM_PHYSSEG_STRAT == VM_PSTRAT_BSEARCH) - for (lcv = vm_nphysseg - 1 ; lcv >= 0 ; lcv--) + for (lcv = vm_nphysseg - 1, seg = vm_physmem + lcv; lcv >= 0; + lcv--, seg--) #else - for (lcv = 0 ; lcv < vm_nphysseg ; lcv++) + for (lcv = 0, seg = vm_physmem; lcv < vm_nphysseg ; lcv++, seg++) #endif { - if (uvm.page_init_done == TRUE) panic("uvm_page_physget: called _after_ bootstrap"); /* try from front */ - if (vm_physmem[lcv].avail_start == vm_physmem[lcv].start && - vm_physmem[lcv].avail_start < vm_physmem[lcv].avail_end) { - *paddrp = ptoa(vm_physmem[lcv].avail_start); - vm_physmem[lcv].avail_start++; - vm_physmem[lcv].start++; + if (seg->avail_start == seg->start && + seg->avail_start < seg->avail_end) { + *paddrp = ptoa(seg->avail_start); + seg->avail_start++; + seg->start++; /* nothing left? nuke it */ - if (vm_physmem[lcv].avail_start == - vm_physmem[lcv].end) { + if (seg->avail_start == seg->end) { if (vm_nphysseg == 1) panic("uvm_page_physget: out of memory!"); vm_nphysseg--; - for (x = lcv ; x < vm_nphysseg ; x++) + for (; lcv < vm_nphysseg; lcv++, seg++) /* structure copy */ - vm_physmem[x] = vm_physmem[x+1]; + seg[0] = seg[1]; } return (TRUE); } /* try from rear */ - if (vm_physmem[lcv].avail_end == vm_physmem[lcv].end && - vm_physmem[lcv].avail_start < vm_physmem[lcv].avail_end) { - *paddrp = ptoa(vm_physmem[lcv].avail_end - 1); - vm_physmem[lcv].avail_end--; - vm_physmem[lcv].end--; + if (seg->avail_end == seg->end && + seg->avail_start < seg->avail_end) { + *paddrp = ptoa(seg->avail_end - 1); + seg->avail_end--; + seg->end--; /* nothing left? nuke it */ - if (vm_physmem[lcv].avail_end == - vm_physmem[lcv].start) { + if (seg->avail_end == seg->start) { if (vm_nphysseg == 1) panic("uvm_page_physget: out of memory!"); vm_nphysseg--; - for (x = lcv ; x < vm_nphysseg ; x++) + for (; lcv < vm_nphysseg ; lcv++, seg++) /* structure copy */ - vm_physmem[x] = vm_physmem[x+1]; + seg[0] = seg[1]; } return (TRUE); } @@ -504,29 +505,30 @@ uvm_page_physget(paddr_t *paddrp) /* pass2: forget about matching ends, just allocate something */ #if (VM_PHYSSEG_STRAT == VM_PSTRAT_BIGFIRST) || \ (VM_PHYSSEG_STRAT == VM_PSTRAT_BSEARCH) - for (lcv = vm_nphysseg - 1 ; lcv >= 0 ; lcv--) + for (lcv = vm_nphysseg - 1, seg = vm_physmem + lcv; lcv >= 0; + lcv--, seg--) #else - for (lcv = 0 ; lcv < vm_nphysseg ; lcv++) + for (lcv = 0, seg = vm_physmem; lcv < vm_nphysseg ; lcv++, seg++) #endif { /* any room in this bank? */ - if (vm_physmem[lcv].avail_start >= vm_physmem[lcv].avail_end) + if (seg->avail_start >= seg->avail_end) continue; /* nope */ - *paddrp = ptoa(vm_physmem[lcv].avail_start); - vm_physmem[lcv].avail_start++; + *paddrp = ptoa(seg->avail_start); + seg->avail_start++; /* truncate! */ - vm_physmem[lcv].start = vm_physmem[lcv].avail_start; + seg->start = seg->avail_start; /* nothing left? nuke it */ - if (vm_physmem[lcv].avail_start == vm_physmem[lcv].end) { + if (seg->avail_start == seg->end) { if (vm_nphysseg == 1) panic("uvm_page_physget: out of memory!"); vm_nphysseg--; - for (x = lcv ; x < vm_nphysseg ; x++) + for (; lcv < vm_nphysseg ; lcv++, seg++) /* structure copy */ - vm_physmem[x] = vm_physmem[x+1]; + seg[0] = seg[1]; } return (TRUE); } @@ -552,13 +554,15 @@ uvm_page_physload(paddr_t start, paddr_t end, paddr_t avail_start, int preload, lcv; psize_t npages; struct vm_page *pgs; - struct vm_physseg *ps; + struct vm_physseg *ps, *seg; +#ifdef DIAGNOSTIC if (uvmexp.pagesize == 0) panic("uvm_page_physload: page size not set!"); if (start >= end) panic("uvm_page_physload: start >= end"); +#endif /* * do we have room? @@ -576,8 +580,8 @@ uvm_page_physload(paddr_t start, paddr_t end, paddr_t avail_start, * check to see if this is a "preload" (i.e. uvm_mem_init hasn't been * called yet, so malloc is not available). */ - for (lcv = 0 ; lcv < vm_nphysseg ; lcv++) { - if (vm_physmem[lcv].pgs) + for (lcv = 0, seg = vm_physmem; lcv < vm_nphysseg; lcv++, seg++) { + if (seg->pgs) break; } preload = (lcv == vm_nphysseg); @@ -654,14 +658,15 @@ uvm_page_physload(paddr_t start, paddr_t end, paddr_t avail_start, { int x; /* sort by address for binary search */ - for (lcv = 0 ; lcv < vm_nphysseg ; lcv++) - if (start < vm_physmem[lcv].start) + for (lcv = 0, seg = vm_physmem; lcv < vm_nphysseg; lcv++, seg++) + if (start < seg->start) break; - ps = &vm_physmem[lcv]; + ps = seg; /* move back other entries, if necessary ... */ - for (x = vm_nphysseg ; x > lcv ; x--) + for (x = vm_nphysseg, seg = vm_physmem + x - 1; x > lcv; + x--, seg--) /* structure copy */ - vm_physmem[x] = vm_physmem[x - 1]; + seg[1] = seg[0]; } #elif (VM_PHYSSEG_STRAT == VM_PSTRAT_BIGFIRST) @@ -669,15 +674,16 @@ uvm_page_physload(paddr_t start, paddr_t end, paddr_t avail_start, { int x; /* sort by largest segment first */ - for (lcv = 0 ; lcv < vm_nphysseg ; lcv++) + for (lcv = 0, seg = vm_physmem; lcv < vm_nphysseg; lcv++, seg++) if ((end - start) > - (vm_physmem[lcv].end - vm_physmem[lcv].start)) + (seg->end - seg->start)) break; ps = &vm_physmem[lcv]; /* move back other entries, if necessary ... */ - for (x = vm_nphysseg ; x > lcv ; x--) + for (x = vm_nphysseg, seg = vm_physmem + x - 1; x > lcv; + x--, seg--) /* structure copy */ - vm_physmem[x] = vm_physmem[x - 1]; + seg[1] = seg[0]; } #else @@ -714,15 +720,16 @@ void uvm_page_physdump(void) { int lcv; + struct vm_physseg *seg; printf("uvm_page_physdump: physical memory config [segs=%d of %d]:\n", vm_nphysseg, VM_PHYSSEG_MAX); - for (lcv = 0 ; lcv < vm_nphysseg ; lcv++) + for (lcv = 0, seg = vm_physmem; lcv < vm_nphysseg ; lcv++, seg++) printf("0x%llx->0x%llx [0x%llx->0x%llx]\n", - (long long)vm_physmem[lcv].start, - (long long)vm_physmem[lcv].end, - (long long)vm_physmem[lcv].avail_start, - (long long)vm_physmem[lcv].avail_end); + (long long)seg->start, + (long long)seg->end, + (long long)seg->avail_start, + (long long)seg->avail_end); printf("STRATEGY = "); switch (VM_PHYSSEG_STRAT) { case VM_PSTRAT_RANDOM: printf("RANDOM\n"); break; @@ -798,6 +805,8 @@ uvm_pglistalloc(psize_t size, paddr_t low, paddr_t high, paddr_t alignment, if (size == 0) return (EINVAL); + size = atop(round_page(size)); + /* * check to see if we need to generate some free pages waking * the pagedaemon. @@ -816,10 +825,10 @@ uvm_pglistalloc(psize_t size, paddr_t low, paddr_t high, paddr_t alignment, * recover in the page daemon. */ again: - if ((uvmexp.free <= uvmexp.reserve_pagedaemon && + if ((uvmexp.free <= uvmexp.reserve_pagedaemon + size && !((curproc == uvm.pagedaemon_proc) || (curproc == syncerproc)))) { - if (UVM_PLA_WAITOK) { + if (flags & UVM_PLA_WAITOK) { uvm_wait("uvm_pglistalloc"); goto again; } @@ -846,7 +855,6 @@ uvm_pglistalloc(psize_t size, paddr_t low, paddr_t high, paddr_t alignment, * lowpg_flags & PG_DEV) == 0); - atomic_setbits_int(&pg->pg_flags, PG_BUSY|PG_CLEAN|PG_FAKE); if (flags & UVM_PGA_ZERO) atomic_clearbits_int(&pg->pg_flags, PG_CLEAN); + else + atomic_setbits_int(&pg->pg_flags, PG_CLEAN); return(pg); @@ -1329,6 +1338,7 @@ uvm_pageidlezero(void) int vm_physseg_find(paddr_t pframe, int *offp) { + struct vm_physseg *seg; #if (VM_PHYSSEG_STRAT == VM_PSTRAT_BSEARCH) /* binary search for it */ @@ -1349,13 +1359,14 @@ vm_physseg_find(paddr_t pframe, int *offp) for (start = 0, len = vm_nphysseg ; len != 0 ; len = len / 2) { try = start + (len / 2); /* try in the middle */ + seg = vm_physmem + try; /* start past our try? */ - if (pframe >= vm_physmem[try].start) { + if (pframe >= seg->start) { /* was try correct? */ - if (pframe < vm_physmem[try].end) { + if (pframe < seg->end) { if (offp) - *offp = pframe - vm_physmem[try].start; + *offp = pframe - seg->start; return(try); /* got it */ } start = try + 1; /* next time, start here */ @@ -1373,11 +1384,10 @@ vm_physseg_find(paddr_t pframe, int *offp) /* linear search for it */ int lcv; - for (lcv = 0; lcv < vm_nphysseg; lcv++) { - if (pframe >= vm_physmem[lcv].start && - pframe < vm_physmem[lcv].end) { + for (lcv = 0, seg = vm_physmem; lcv < vm_nphysseg ; lcv++, seg++) { + if (pframe >= seg->start && pframe < seg->end) { if (offp) - *offp = pframe - vm_physmem[lcv].start; + *offp = pframe - seg->start; return(lcv); /* got it */ } } diff --git a/openbsd/xenocara/driver/xf86-video-intel/src/legacy/i810/i810_driver.c b/openbsd/xenocara/driver/xf86-video-intel/src/legacy/i810/i810_driver.c index fc6369e..5ac6463 100644 --- a/openbsd/xenocara/driver/xf86-video-intel/src/legacy/i810/i810_driver.c +++ b/openbsd/xenocara/driver/xf86-video-intel/src/legacy/i810/i810_driver.c @@ -152,7 +152,7 @@ static int i810_pitches[] = { static Bool I810GetRec(ScrnInfoPtr scrn) { - if (((uintptr_t)scrn->driverPrivate & 1) == 0) + if (scrn->driverPrivate != NULL) return TRUE; scrn->driverPrivate = xnfcalloc(sizeof(I810Rec), 1); @@ -232,6 +232,7 @@ I810DoDDC(ScrnInfoPtr scrn, int index) static Bool I810PreInit(ScrnInfoPtr scrn, int flags) { + vgaHWPtr hwp; I810Ptr pI810; ClockRangePtr clockRanges; int i; @@ -240,6 +241,7 @@ I810PreInit(ScrnInfoPtr scrn, int flags) rgb defaultWeight = { 0, 0, 0 }; int mem; Bool enable; + struct intel_chipset chipset; if (scrn->numEntities != 1) return FALSE; @@ -267,6 +269,9 @@ I810PreInit(ScrnInfoPtr scrn, int flags) if (!vgaHWGetHWRec(scrn)) return FALSE; + hwp = VGAHWPTR(scrn); + vgaHWSetStdFuncs(hwp); + pI810->PciInfo = xf86GetPciInfoForEntity(pI810->pEnt->index); /* Set scrn->monitor */ @@ -364,8 +369,34 @@ I810PreInit(ScrnInfoPtr scrn, int flags) */ I810DoDDC(scrn, pI810->pEnt->index); - intel_detect_chipset(scrn, pI810->pEnt, pI810->PciInfo); + intel_detect_chipset(scrn, pI810->PciInfo, &chipset); + /* + * Set the Chipset and ChipRev, allowing config file entries to + * override. + */ + if (pI810->pEnt->device->chipset && *pI810->pEnt->device->chipset) { + scrn->chipset = pI810->pEnt->device->chipset; + from = X_CONFIG; + } else if (pI810->pEnt->device->chipID >= 0) { + scrn->chipset = (char *)xf86TokenToString(intel_chipsets, + pI810->pEnt->device->chipID); + from = X_CONFIG; + xf86DrvMsg(scrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n", + pI810->pEnt->device->chipID); + } else { + from = X_PROBED; + scrn->chipset = (char *)xf86TokenToString(intel_chipsets, + DEVICE_ID(pI810->PciInfo)); + } + if (pI810->pEnt->device->chipRev >= 0) { + xf86DrvMsg(scrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n", + pI810->pEnt->device->chipRev); + } + + xf86DrvMsg(scrn->scrnIndex, from, "Chipset: \"%s\"\n", + (scrn->chipset != NULL) ? scrn->chipset : "Unknown i810"); + pI810->LinearAddr = pI810->PciInfo->regions[0].base_addr; xf86DrvMsg(scrn->scrnIndex, X_PROBED, "Linear framebuffer at 0x%lX\n", (unsigned long)pI810->LinearAddr);