PERFORCE change 94788 for review
John-Mark Gurney
jmg at FreeBSD.org
Sat Apr 8 05:18:43 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=94788
Change 94788 by jmg at jmg_carbon-60 on 2006/04/08 05:18:33
add ability to enter mappings into the iotte... we'll see if this
works..
Affected files ...
.. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/hviommu.c#3 edit
Differences ...
==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/hviommu.c#3 (text+ko) ====
@@ -225,7 +225,7 @@
return him;
}
-/* XXX - vm_stat_t better be signed */
+/* XXX - vm_size_t better be signed */
static void
hviommu_remove(struct hviommu *him, vm_offset_t va, vm_size_t len)
{
@@ -233,11 +233,11 @@
pages_t demapped;
KASSERT(va >= him->him_dvmabase,
- ("hviommu_remove: va 0x%lx not in DVMA space", (u_long)va));
+ ("%s: va 0x%lx not in DVMA space", __func__, (u_long)va));
KASSERT(va + len >= va,
- ("hviommu_remove: va 0x%lx + len 0x%lx wraps", (long)va, (long)len));
+ ("%s: va 0x%lx + len 0x%lx wraps", __func__, (long)va, (long)len));
va = trunc_io_page(va);
- while (len >= 0) {
+ while (len > 0) {
if ((error = hvio_iommu_demap(him->him_handle,
VA_TO_TSBID(him, va), len >> IO_PAGE_SHIFT, &demapped))) {
printf("%s: demap: va: %#lx, npages: %#lx, err: %ld\n",
@@ -527,6 +527,35 @@
return (0);
}
+#define IOTTE_CNT 64
+#define HVIOMMU_TSBID(him, dvmaddr) \
+ (((dvmaddr) - (him)->him_dvmabase) >> IO_PAGE_SHIFT)
+
+static void
+hviommu_map_pages(struct hviommu *him, bus_addr_t dvmaddr, uint64_t *iottes, pages_t iottecnt)
+{
+ uint64_t iotteaddr[IOTTE_CNT];
+ uint64_t err;
+ pages_t mapcnt;
+ int cntdone;
+ int i;
+
+ for (i = 0; i < cnt; i++)
+ iotteaddr[i] = pmap_kextract(&iottes[i]);
+
+ /* push tte's */
+ cntdone = 0;
+ while (cntdone < iottecnt) {
+ if ((err = hvio_iommu_map(him->him_handle, HVIOMMU_TSBID(him,
+ dvmaddr), iottecnt, PCI_MAP_ATTR_READ | PCI_MAP_ATTR_WRITE,
+ pmap_kextract(&iotteaddr[0]), &mapcnt))) {
+ printf("iommu_map: err: %ld\n", err);
+ mapcnt = 1;
+ }
+ cntdone += mapcnt;
+ }
+}
+
/*
* IOMMU DVMA operations, common to SBUS and PCI.
*/
@@ -535,12 +564,14 @@
bus_dmamap_t map, void *buf, bus_size_t buflen, struct thread *td,
int flags, bus_dma_segment_t *segs, int *segp, int align)
{
- bus_addr_t amask, dvmaddr;
+ uint64_t iottes[IOTTE_CNT];
+ bus_addr_t amask, dvmaddr, iottebase;
bus_size_t sgsize, esize;
vm_offset_t vaddr, voffs;
vm_paddr_t curaddr;
int error, sgcnt, firstpg;
pmap_t pmap = NULL;
+ pages_t iottecnt;
KASSERT(buflen != 0, ("hviommu_dvmamap_load_buffer: buflen == 0!"));
if (buflen > dt->dt_maxsize)
@@ -561,6 +592,7 @@
sgcnt = *segp;
firstpg = 1;
+ iottecnt = 0;
for (; buflen > 0; ) {
/*
* Get the physical address for this page.
@@ -584,7 +616,13 @@
hviommu_enter(him, trunc_io_page(dvmaddr), trunc_io_page(curaddr),
flags);
#else
- panic("enter page into iommu");
+ if (iottecnt == 0)
+ iottebase = trunc_io_page(dvmaddr);
+ iottes[iottecnt] = MAKEIOTTE(trunc_io_page(curaddr)
+ if (iottecnt >= IOTTE_CNT) {
+ hviommu_map_pages(him, dvmaddr, iottes, iottecnt);
+ iottecnt = 0;
+ }
#endif
/*
@@ -618,6 +656,7 @@
firstpg = 0;
}
+ hviommu_map_pages(him, dvmaddr, iottes, iottecnt);
*segp = sgcnt;
return (0);
}
More information about the p4-projects
mailing list