From owner-p4-projects@FreeBSD.ORG Sat Apr 8 05:18:43 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D60FA16A402; Sat, 8 Apr 2006 05:18:42 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9C98716A400 for ; Sat, 8 Apr 2006 05:18:42 +0000 (UTC) (envelope-from jmg@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6440143D53 for ; Sat, 8 Apr 2006 05:18:42 +0000 (GMT) (envelope-from jmg@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k385Igqi081748 for ; Sat, 8 Apr 2006 05:18:42 GMT (envelope-from jmg@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k385IgN3081745 for perforce@freebsd.org; Sat, 8 Apr 2006 05:18:42 GMT (envelope-from jmg@freebsd.org) Date: Sat, 8 Apr 2006 05:18:42 GMT Message-Id: <200604080518.k385IgN3081745@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jmg@freebsd.org using -f From: John-Mark Gurney To: Perforce Change Reviews Cc: Subject: PERFORCE change 94788 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Apr 2006 05:18:43 -0000 http://perforce.freebsd.org/chv.cgi?CH=94788 Change 94788 by jmg@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); }