summaryrefslogtreecommitdiff
path: root/sys/arch/sgi
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2017-05-11 15:47:46 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2017-05-11 15:47:46 +0000
commit19de39afe0dd1f03d5f2eba7cc35807f9fd1d014 (patch)
treea7e856c0805c34adf4ba65538f9fa7863986a76e /sys/arch/sgi
parent215ce2bf3c3fca0d7c94d6e92adc31891633dd13 (diff)
The device_to_pa routine really isn't needed. We always have physical
addresses. While there, pave the way for BUS_DMA_64BIT (not working yet). Diff from miod@; OK dlg@
Diffstat (limited to 'sys/arch/sgi')
-rw-r--r--sys/arch/sgi/include/bus.h8
-rw-r--r--sys/arch/sgi/localbus/imc.c14
-rw-r--r--sys/arch/sgi/localbus/macebus.c19
-rw-r--r--sys/arch/sgi/pci/macepcibridge.c19
-rw-r--r--sys/arch/sgi/sgi/bus_dma.c41
-rw-r--r--sys/arch/sgi/xbow/xbridge.c17
6 files changed, 40 insertions, 78 deletions
diff --git a/sys/arch/sgi/include/bus.h b/sys/arch/sgi/include/bus.h
index 7a017dc5d17..4f431cd195c 100644
--- a/sys/arch/sgi/include/bus.h
+++ b/sys/arch/sgi/include/bus.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus.h,v 1.27 2017/05/08 00:27:45 dlg Exp $ */
+/* $OpenBSD: bus.h,v 1.28 2017/05/11 15:47:45 visa Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB Sweden. All rights reserved.
@@ -344,7 +344,8 @@ struct machine_bus_dma_segment {
bus_size_t ds_len; /* length of transfer */
paddr_t _ds_paddr; /* CPU address */
- vaddr_t _ds_vaddr; /* CPU address */
+ vaddr_t _ds_vaddr; /* CPU address - only valid after
+ calling bus_dmamap_load*() */
};
typedef struct machine_bus_dma_segment bus_dma_segment_t;
@@ -393,8 +394,7 @@ struct machine_bus_dma_tag {
/*
* internal memory address translation information.
*/
- bus_addr_t (*_pa_to_device)(paddr_t);
- paddr_t (*_device_to_pa)(bus_addr_t);
+ bus_addr_t (*_pa_to_device)(paddr_t, int);
bus_addr_t _dma_mask;
};
diff --git a/sys/arch/sgi/localbus/imc.c b/sys/arch/sgi/localbus/imc.c
index f4ed8688f4f..bd8813eba03 100644
--- a/sys/arch/sgi/localbus/imc.c
+++ b/sys/arch/sgi/localbus/imc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imc.c,v 1.21 2016/03/06 19:42:27 mpi Exp $ */
+/* $OpenBSD: imc.c,v 1.22 2017/05/11 15:47:45 visa Exp $ */
/* $NetBSD: imc.c,v 1.32 2011/07/01 18:53:46 dyoung Exp $ */
/*
@@ -157,8 +157,7 @@ static bus_space_t imcbus_eisa_mem_tag = {
};
#endif
-bus_addr_t imc_pa_to_device(paddr_t);
-paddr_t imc_device_to_pa(bus_addr_t);
+bus_addr_t imc_pa_to_device(paddr_t, int);
/* can't be static for gio_cnattach() */
struct machine_bus_dma_tag imc_bus_dma_tag = {
@@ -178,7 +177,6 @@ struct machine_bus_dma_tag imc_bus_dma_tag = {
_dmamem_unmap,
_dmamem_mmap,
imc_pa_to_device,
- imc_device_to_pa,
0
};
@@ -465,17 +463,11 @@ imc_eisa_mem_region(bus_space_tag_t t, bus_space_handle_t bsh,
#endif
bus_addr_t
-imc_pa_to_device(paddr_t pa)
+imc_pa_to_device(paddr_t pa, int flags)
{
return (bus_addr_t)pa;
}
-paddr_t
-imc_device_to_pa(bus_addr_t addr)
-{
- return (paddr_t)addr;
-}
-
/*
* For some reason, reading the arbitration register sometimes returns
* wrong values, at least on IP20 (where the usual value is 0x400, but
diff --git a/sys/arch/sgi/localbus/macebus.c b/sys/arch/sgi/localbus/macebus.c
index 9fb2f72dcae..7d5a1650db9 100644
--- a/sys/arch/sgi/localbus/macebus.c
+++ b/sys/arch/sgi/localbus/macebus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: macebus.c,v 1.65 2017/02/11 03:44:22 visa Exp $ */
+/* $OpenBSD: macebus.c,v 1.66 2017/05/11 15:47:45 visa Exp $ */
/*
* Copyright (c) 2000-2004 Opsycon AB (www.opsycon.se)
@@ -99,8 +99,7 @@ void *mace_space_vaddr(bus_space_tag_t, bus_space_handle_t);
void mace_space_barrier(bus_space_tag_t, bus_space_handle_t, bus_size_t,
bus_size_t, int);
-bus_addr_t macebus_pa_to_device(paddr_t);
-paddr_t macebus_device_to_pa(bus_addr_t);
+bus_addr_t macebus_pa_to_device(paddr_t, int);
struct cfattach macebus_ca = {
sizeof(struct device), macebusmatch, macebusattach
@@ -158,7 +157,6 @@ struct machine_bus_dma_tag mace_bus_dma_tag = {
_dmamem_unmap,
_dmamem_mmap,
macebus_pa_to_device,
- macebus_device_to_pa,
CRIME_MEMORY_MASK
};
@@ -457,22 +455,11 @@ mace_space_barrier(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offs,
*/
bus_addr_t
-macebus_pa_to_device(paddr_t pa)
+macebus_pa_to_device(paddr_t pa, int flags)
{
return (pa | CRIME_MEMORY_OFFSET);
}
-paddr_t
-macebus_device_to_pa(bus_addr_t addr)
-{
- paddr_t pa = (paddr_t)addr & CRIME_MEMORY_MASK;
-
- if (pa >= 256 * 1024 * 1024)
- pa |= CRIME_MEMORY_OFFSET;
-
- return (pa);
-}
-
/*
* Macebus interrupt handler driver.
*/
diff --git a/sys/arch/sgi/pci/macepcibridge.c b/sys/arch/sgi/pci/macepcibridge.c
index 27c4bb21a0b..a7c156b15d3 100644
--- a/sys/arch/sgi/pci/macepcibridge.c
+++ b/sys/arch/sgi/pci/macepcibridge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: macepcibridge.c,v 1.47 2014/05/19 21:18:42 miod Exp $ */
+/* $OpenBSD: macepcibridge.c,v 1.48 2017/05/11 15:47:45 visa Exp $ */
/*
* Copyright (c) 2009 Miodrag Vallat.
@@ -101,8 +101,7 @@ void *mace_pcibr_rbus_parent_mem(struct pci_attach_args *);
void *mace_pcib_space_vaddr(bus_space_tag_t, bus_space_handle_t);
void mace_pcib_space_barrier(bus_space_tag_t, bus_space_handle_t,
bus_size_t, bus_size_t, int);
-bus_addr_t mace_pcibr_pa_to_device(paddr_t);
-paddr_t mace_pcibr_device_to_pa(bus_addr_t);
+bus_addr_t mace_pcibr_pa_to_device(paddr_t, int);
int mace_pcibr_rbus_space_map(bus_space_tag_t, bus_addr_t, bus_size_t,
int, bus_space_handle_t *);
@@ -193,7 +192,6 @@ struct machine_bus_dma_tag mace_pci_bus_dma_tag = {
_dmamem_unmap,
_dmamem_mmap,
mace_pcibr_pa_to_device,
- mace_pcibr_device_to_pa,
CRIME_MEMORY_MASK
};
@@ -709,22 +707,11 @@ mace_pcib_space_barrier(bus_space_tag_t t, bus_space_handle_t h,
*/
bus_addr_t
-mace_pcibr_pa_to_device(paddr_t pa)
+mace_pcibr_pa_to_device(paddr_t pa, int flags)
{
return (pa & CRIME_MEMORY_MASK);
}
-paddr_t
-mace_pcibr_device_to_pa(bus_addr_t addr)
-{
- paddr_t pa = (paddr_t)addr & CRIME_MEMORY_MASK;
-
- if (pa >= 256 * 1024 * 1024)
- pa |= CRIME_MEMORY_OFFSET;
-
- return (pa);
-}
-
/*
* PCI configuration.
*/
diff --git a/sys/arch/sgi/sgi/bus_dma.c b/sys/arch/sgi/sgi/bus_dma.c
index 0bd28cba10f..62ee440901a 100644
--- a/sys/arch/sgi/sgi/bus_dma.c
+++ b/sys/arch/sgi/sgi/bus_dma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus_dma.c,v 1.40 2015/09/05 21:13:24 miod Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.41 2017/05/11 15:47:45 visa Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -421,7 +421,7 @@ void
_dmamem_free(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs)
{
vm_page_t m;
- bus_addr_t addr;
+ paddr_t pa;
struct pglist mlist;
int curseg;
@@ -430,10 +430,10 @@ _dmamem_free(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs)
*/
TAILQ_INIT(&mlist);
for (curseg = 0; curseg < nsegs; curseg++) {
- for (addr = segs[curseg].ds_addr;
- addr < (segs[curseg].ds_addr + segs[curseg].ds_len);
- addr += PAGE_SIZE) {
- m = PHYS_TO_VM_PAGE((*t->_device_to_pa)(addr));
+ for (pa = segs[curseg]._ds_paddr;
+ pa < (segs[curseg]._ds_paddr + segs[curseg].ds_len);
+ pa += PAGE_SIZE) {
+ m = PHYS_TO_VM_PAGE(pa);
TAILQ_INSERT_TAIL(&mlist, m, pageq);
}
}
@@ -452,7 +452,6 @@ _dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, size_t size,
vaddr_t va, sva;
size_t ssize;
paddr_t pa;
- bus_addr_t addr;
int curseg, error, pmap_flags;
const struct kmem_dyn_mode *kd;
@@ -472,7 +471,7 @@ _dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, size_t size,
#endif
if (nsegs == 1) {
- pa = (*t->_device_to_pa)(segs[0].ds_addr);
+ pa = segs[0]._ds_paddr;
if (flags & (BUS_DMA_COHERENT | BUS_DMA_NOCACHE))
*kvap = (caddr_t)PHYS_TO_XKPHYS(pa, CCA_NC);
else
@@ -494,14 +493,13 @@ _dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, size_t size,
if (flags & (BUS_DMA_COHERENT | BUS_DMA_NOCACHE))
pmap_flags |= PMAP_NOCACHE;
for (curseg = 0; curseg < nsegs; curseg++) {
- for (addr = segs[curseg].ds_addr;
- addr < (segs[curseg].ds_addr + segs[curseg].ds_len);
- addr += NBPG, va += NBPG, size -= NBPG) {
+ for (pa = segs[curseg]._ds_paddr;
+ pa < (segs[curseg]._ds_paddr + segs[curseg].ds_len);
+ pa += PAGE_SIZE, va += PAGE_SIZE, size -= PAGE_SIZE) {
#ifdef DIAGNOSTIC
if (size == 0)
panic("_dmamem_map: size botch");
#endif
- pa = (*t->_device_to_pa)(addr);
error = pmap_enter(pmap_kernel(), va, pa,
PROT_READ | PROT_WRITE,
PROT_READ | PROT_WRITE | pmap_flags);
@@ -567,7 +565,7 @@ _dmamem_mmap(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, off_t off,
continue;
}
- return ((*t->_device_to_pa)(segs[i].ds_addr) + off);
+ return segs[i]._ds_paddr + off;
}
/* Page not found. */
@@ -644,7 +642,7 @@ _dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
*/
if (first) {
map->dm_segs[seg].ds_addr =
- (*t->_pa_to_device)(curaddr);
+ (*t->_pa_to_device)(curaddr, map->_dm_flags);
map->dm_segs[seg].ds_len = sgsize;
map->dm_segs[seg]._ds_paddr = curaddr;
map->dm_segs[seg]._ds_vaddr = vaddr;
@@ -661,7 +659,8 @@ _dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
if (++seg >= map->_dm_segcnt)
break;
map->dm_segs[seg].ds_addr =
- (*t->_pa_to_device)(curaddr);
+ (*t->_pa_to_device)(curaddr,
+ map->_dm_flags);
map->dm_segs[seg].ds_len = sgsize;
map->dm_segs[seg]._ds_paddr = curaddr;
map->dm_segs[seg]._ds_vaddr = vaddr;
@@ -721,25 +720,27 @@ _dmamem_alloc_range(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment,
*/
m = TAILQ_FIRST(&mlist);
curseg = 0;
+ segs[curseg]._ds_paddr = VM_PAGE_TO_PHYS(m);
lastaddr = segs[curseg].ds_addr =
- (*t->_pa_to_device)(VM_PAGE_TO_PHYS(m));
+ (*t->_pa_to_device)(segs[curseg]._ds_paddr, flags);
segs[curseg].ds_len = PAGE_SIZE;
m = TAILQ_NEXT(m, pageq);
for (; m != NULL; m = TAILQ_NEXT(m, pageq)) {
- curaddr = VM_PAGE_TO_PHYS(m);
+ paddr_t pa = VM_PAGE_TO_PHYS(m);
#ifdef DIAGNOSTIC
- if (curaddr < low || curaddr >= high) {
+ if (pa < low || pa >= high) {
printf("vm_page_alloc_memory returned non-sensical"
- " address 0x%lx\n", curaddr);
+ " address 0x%lx\n", pa);
panic("_dmamem_alloc_range");
}
#endif
- curaddr = (*t->_pa_to_device)(curaddr);
+ curaddr = (*t->_pa_to_device)(pa, flags);
if (curaddr == (lastaddr + PAGE_SIZE))
segs[curseg].ds_len += PAGE_SIZE;
else {
curseg++;
+ segs[curseg]._ds_paddr = pa;
segs[curseg].ds_addr = curaddr;
segs[curseg].ds_len = PAGE_SIZE;
}
diff --git a/sys/arch/sgi/xbow/xbridge.c b/sys/arch/sgi/xbow/xbridge.c
index e23e30459e6..7787e7a76e3 100644
--- a/sys/arch/sgi/xbow/xbridge.c
+++ b/sys/arch/sgi/xbow/xbridge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xbridge.c,v 1.101 2017/02/11 03:44:22 visa Exp $ */
+/* $OpenBSD: xbridge.c,v 1.102 2017/05/11 15:47:45 visa Exp $ */
/*
* Copyright (c) 2008, 2009, 2011 Miodrag Vallat.
@@ -483,8 +483,7 @@ int xbridge_space_region_mem(bus_space_tag_t, bus_space_handle_t,
void xbridge_space_barrier(bus_space_tag_t, bus_space_handle_t,
bus_size_t, bus_size_t, int);
-bus_addr_t xbridge_pa_to_device(paddr_t);
-paddr_t xbridge_device_to_pa(bus_addr_t);
+bus_addr_t xbridge_pa_to_device(paddr_t, int);
int xbridge_rbus_space_map(bus_space_tag_t, bus_addr_t, bus_size_t,
int, bus_space_handle_t *);
@@ -553,7 +552,6 @@ static const struct machine_bus_dma_tag xbridge_dma_tag = {
_dmamem_unmap,
_dmamem_mmap,
xbridge_pa_to_device,
- xbridge_device_to_pa,
BRIDGE_DMA_DIRECT_LENGTH - 1
};
@@ -1987,17 +1985,14 @@ xbridge_space_barrier(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offs,
*/
bus_addr_t
-xbridge_pa_to_device(paddr_t pa)
+xbridge_pa_to_device(paddr_t pa, int flags)
{
+ KASSERTMSG(pa - dma_constraint.ucr_low < BRIDGE_DMA_DIRECT_LENGTH,
+ "pa 0x%lx not in dma constraint range! (0x%lx-0x%lx)",
+ pa, dma_constraint.ucr_low, dma_constraint.ucr_high);
return (pa - dma_constraint.ucr_low) + BRIDGE_DMA_DIRECT_BASE;
}
-paddr_t
-xbridge_device_to_pa(bus_addr_t addr)
-{
- return (addr - BRIDGE_DMA_DIRECT_BASE) + dma_constraint.ucr_low;
-}
-
/*
********************* Bridge configuration code.
*/