Index: sys/arch/mips/mips/bus_dma.c =================================================================== RCS file: /cvsroot/src/sys/arch/mips/mips/bus_dma.c,v retrieving revision 1.36 diff -u -p -r1.36 bus_dma.c --- sys/arch/mips/mips/bus_dma.c 22 Jul 2016 19:50:44 -0000 1.36 +++ sys/arch/mips/mips/bus_dma.c 29 Jul 2016 15:22:43 -0000 @@ -192,7 +192,7 @@ _bus_dmamap_load_buffer(bus_dma_tag_t t, * if we can use a direct-mapped VA for the segment. */ if (!mips_cache_badalias(curaddr, vaddr)) { -#ifdef __mips_o32 +#ifndef _LP64 if (MIPS_KSEG0_P(curaddr + sgsize - 1)) { ds->_ds_vaddr = MIPS_PHYS_TO_KSEG0(curaddr); @@ -207,6 +207,7 @@ _bus_dmamap_load_buffer(bus_dma_tag_t t, #endif } } + KASSERTMSG(((register_t)seg->_ds_vaddr) < 0, "_ds_vaddr %" PRIxBUSADDR); lastaddr = curaddr + sgsize; vaddr += sgsize; @@ -851,13 +852,13 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm * Now at the first segment to sync; nail each segment until we * have exhausted the length. */ - register_t vaddr = (intptr_t)seg->_ds_vaddr + offset; + register_t vaddr = (intptr_t)(seg->_ds_vaddr + offset); minlen = ulmin(len, seg->ds_len - offset); #ifdef BUS_DMA_DEBUG printf("bus_dmamap_sync: flushing segment %p " - "(0x%"PRIxBUSADDR"+%"PRIxBUSADDR - ", 0x%"PRIxBUSADDR"+0x%"PRIxBUSADDR + "(0x%"PRIxREGISTER"+%"PRIxBUSADDR + ", 0x%"PRIxREGISTER"+0x%"PRIxBUSADDR ") (olen = %"PRIxBUSADDR")...", seg, vaddr - offset, offset, vaddr - offset, offset + minlen - 1, len); @@ -884,14 +885,15 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm case BUS_DMASYNC_PREREAD: { struct mips_cache_info * const mci = &mips_cache_info; - register_t start = vaddr; - register_t end = vaddr + minlen; + register_t start = (intptr_t)vaddr; + register_t end = (intptr_t)(vaddr + minlen); register_t preboundary, firstboundary, lastboundary; register_t mask = mci->mci_dcache_align_mask; preboundary = start & ~mask; firstboundary = (start + mask) & ~mask; lastboundary = end & ~mask; + if (preboundary < start && preboundary < lastboundary) mips_dcache_wbinv_range(preboundary, mci->mci_dcache_align); Index: sys/arch/mips/mips/pmap_machdep.c =================================================================== RCS file: /cvsroot/src/sys/arch/mips/mips/pmap_machdep.c,v retrieving revision 1.1 diff -u -p -r1.1 pmap_machdep.c --- sys/arch/mips/mips/pmap_machdep.c 11 Jul 2016 16:15:36 -0000 1.1 +++ sys/arch/mips/mips/pmap_machdep.c 29 Jul 2016 15:22:45 -0000 @@ -181,7 +181,7 @@ pmap_md_map_ephemeral_page(struct vm_pag KASSERT(!locked_p || VM_PAGEMD_PVLIST_LOCKED_P(mdpg)); if (!MIPS_CACHE_VIRTUAL_ALIAS || !mips_cache_badalias(pv->pv_va, pa)) { -#ifndef __mips_o32 +#ifdef _LP64 va = MIPS_PHYS_TO_XKPHYS_CACHED(pa); #else if (pa < MIPS_PHYS_MASK) { @@ -198,13 +198,14 @@ pmap_md_map_ephemeral_page(struct vm_pag struct cpu_info * const ci = curcpu(); KASSERT(ci->ci_pmap_dstbase != 0); - va = (prot & VM_PROT_WRITE + vaddr_t nva = (prot & VM_PROT_WRITE ? ci->ci_pmap_dstbase : ci->ci_pmap_srcbase) + mips_cache_indexof(MIPS_CACHE_VIRTUAL_ALIAS ? pv->pv_va : pa); + va = (intptr_t)nva; /* * Now to make and write the new PTE to map the PA. */ @@ -229,8 +230,8 @@ pmap_md_map_ephemeral_page(struct vm_pag (void)VM_PAGEMD_PVLIST_READLOCK(mdpg); if (VM_PAGEMD_CACHED_P(mdpg) && mips_cache_badalias(pv->pv_va, va)) { - mips_dcache_wbinv_range_index(trunc_page(pv->pv_va), - PAGE_SIZE); + register_t ova = (intptr_t)trunc_page(pv->pv_va); + mips_dcache_wbinv_range_index(ova, PAGE_SIZE); /* * If there is no active mapping, remember this new one. */