Author: gonzo
Date: Wed May 26 22:38:45 2010
New Revision: 208581
URL: http://svn.freebsd.org/changeset/base/208581

Log:
  - Fix kseg0 address calculation - it doesn't always start at
      page boundary
  - Add cache ops to ensure memory validity before/after
      copy operation

Modified:
  head/sys/mips/mips/uio_machdep.c

Modified: head/sys/mips/mips/uio_machdep.c
==============================================================================
--- head/sys/mips/mips/uio_machdep.c    Wed May 26 19:26:28 2010        
(r208580)
+++ head/sys/mips/mips/uio_machdep.c    Wed May 26 22:38:45 2010        
(r208581)
@@ -51,6 +51,8 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm_page.h>
 #include <vm/vm_param.h>
 
+#include <machine/cache.h>
+
 /*
  * Implement uiomove(9) from physical memory using a combination
  * of the direct mapping and sf_bufs to reduce the creation and
@@ -91,8 +93,14 @@ uiomove_fromphys(vm_page_t ma[], vm_offs
                m = ma[offset >> PAGE_SHIFT];
                pa = VM_PAGE_TO_PHYS(m);
                if (pa < MIPS_KSEG0_LARGEST_PHYS) {
-                       cp = (char *)MIPS_PHYS_TO_KSEG0(pa);
                        sf = NULL;
+                       cp = (char *)MIPS_PHYS_TO_KSEG0(pa) + page_offset;
+                       /*
+                        * flush all mappings to this page, KSEG0 address first
+                        * in order to get it overwritten by correct data
+                        */
+                       mips_dcache_wbinv_range((vm_offset_t)cp, cnt);
+                       pmap_flush_pvcache(m);
                } else {
                        sf = sf_buf_alloc(m, 0);
                        cp = (char *)sf_buf_kva(sf) + page_offset;
@@ -122,6 +130,8 @@ uiomove_fromphys(vm_page_t ma[], vm_offs
                }
                if (sf != NULL)
                        sf_buf_free(sf);
+               else
+                       mips_dcache_wbinv_range((vm_offset_t)cp, cnt);
                iov->iov_base = (char *)iov->iov_base + cnt;
                iov->iov_len -= cnt;
                uio->uio_resid -= cnt;
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to