Skip to content

Commit

Permalink
Merge OpenBSD -current (2013-03-18 12:36 UTC).
Browse files Browse the repository at this point in the history
  • Loading branch information
gsutre committed Jul 13, 2013
1 parent dc12047 commit cff7cf8
Show file tree
Hide file tree
Showing 14 changed files with 238 additions and 107 deletions.
14 changes: 13 additions & 1 deletion 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 <oga@openbsd.org>
*
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion 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 $ */

/*-
Expand Down Expand Up @@ -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);

Expand Down
8 changes: 7 additions & 1 deletion 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 <oga@openbsd.org>
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 17 additions & 2 deletions 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 $ */

/*
Expand Down Expand Up @@ -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.
Expand All @@ -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) {
Expand All @@ -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);
}

Expand Down
14 changes: 13 additions & 1 deletion 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 <oga@openbsd.org>
*
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions 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 $ */

/*-
Expand Down Expand Up @@ -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_ */
8 changes: 7 additions & 1 deletion 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 <oga@openbsd.org>
Expand Down Expand Up @@ -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;
Expand Down
43 changes: 33 additions & 10 deletions 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
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
}

Expand Down
9 changes: 8 additions & 1 deletion 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 $ */

/*-
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 *);
Expand Down
8 changes: 7 additions & 1 deletion 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 $ */

/*
Expand Down Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions 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 $ */

/*
Expand Down Expand Up @@ -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
Expand All @@ -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);

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions 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 $ */

/*
Expand Down Expand Up @@ -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];
Expand All @@ -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
};

Expand Down

0 comments on commit cff7cf8

Please sign in to comment.