From owner-svn-src-stable@FreeBSD.ORG  Mon Mar 15 19:59:16 2010
Return-Path: <owner-svn-src-stable@FreeBSD.ORG>
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E6442106566B;
	Mon, 15 Mar 2010 19:59:16 +0000 (UTC) (envelope-from raj@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id BA0298FC18;
	Mon, 15 Mar 2010 19:59:16 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2FJxGST061942;
	Mon, 15 Mar 2010 19:59:16 GMT (envelope-from raj@svn.freebsd.org)
Received: (from raj@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2FJxGHI061939;
	Mon, 15 Mar 2010 19:59:16 GMT (envelope-from raj@svn.freebsd.org)
Message-Id: <201003151959.o2FJxGHI061939@svn.freebsd.org>
From: Rafal Jaworowski <raj@FreeBSD.org>
Date: Mon, 15 Mar 2010 19:59:16 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r205193 - stable/8/sys/arm/arm
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	<svn-src-stable.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-stable>, 
	<mailto:svn-src-stable-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-stable>
List-Post: <mailto:svn-src-stable@freebsd.org>
List-Help: <mailto:svn-src-stable-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-stable>,
	<mailto:svn-src-stable-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 15 Mar 2010 19:59:17 -0000

Author: raj
Date: Mon Mar 15 19:59:16 2010
New Revision: 205193
URL: http://svn.freebsd.org/changeset/base/205193

Log:
  MFC r205028
  
   Fix ARM cache handling yet more.
  
   1) vm_machdep.c: remove the dangling allocations so they do not
      un-necessarily turn off the cache upon consecutive access.
  
   2) busdma_machdep.c: remove the same amount than shadow mapped.
  
  Reported by:	Maks Verver
  Submitted by:	Mark Tinguely
  Reviewed by:	Grzegorz Bernacki

Modified:
  stable/8/sys/arm/arm/busdma_machdep.c
  stable/8/sys/arm/arm/vm_machdep.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/arm/arm/busdma_machdep.c
==============================================================================
--- stable/8/sys/arm/arm/busdma_machdep.c	Mon Mar 15 19:51:24 2010	(r205192)
+++ stable/8/sys/arm/arm/busdma_machdep.c	Mon Mar 15 19:59:16 2010	(r205193)
@@ -649,7 +649,8 @@ bus_dmamem_free(bus_dma_tag_t dmat, void
 		KASSERT(map->allocbuffer == vaddr,
 		    ("Trying to freeing the wrong DMA buffer"));
 		vaddr = map->origbuffer;
-		arm_unmap_nocache(map->allocbuffer, dmat->maxsize);
+		arm_unmap_nocache(map->allocbuffer,
+		    dmat->maxsize + ((vm_offset_t)vaddr & PAGE_MASK));
 	}
         if (dmat->maxsize <= PAGE_SIZE &&
 	   dmat->alignment < dmat->maxsize &&

Modified: stable/8/sys/arm/arm/vm_machdep.c
==============================================================================
--- stable/8/sys/arm/arm/vm_machdep.c	Mon Mar 15 19:51:24 2010	(r205192)
+++ stable/8/sys/arm/arm/vm_machdep.c	Mon Mar 15 19:59:16 2010	(r205193)
@@ -171,6 +171,9 @@ sf_buf_free(struct sf_buf *sf)
 	 if (sf->ref_count == 0) {
 		 TAILQ_INSERT_TAIL(&sf_buf_freelist, sf, free_entry);
 		 nsfbufsused--;
+		 pmap_kremove(sf->kva);
+		 sf->m = NULL;
+		 LIST_REMOVE(sf, list_entry);
 		 if (sf_buf_alloc_want > 0)
 			 wakeup_one(&sf_buf_freelist);
 	 }
@@ -502,9 +505,12 @@ arm_unmap_nocache(void *addr, vm_size_t 
 
 	size = round_page(size);
 	i = (raddr - arm_nocache_startaddr) / (PAGE_SIZE);
-	for (; size > 0; size -= PAGE_SIZE, i++)
+	for (; size > 0; size -= PAGE_SIZE, i++) {
 		arm_nocache_allocated[i / BITS_PER_INT] &= ~(1 << (i % 
 		    BITS_PER_INT));
+		pmap_kremove(raddr);
+		raddr += PAGE_SIZE;
+	}
 }
 
 #ifdef ARM_USE_SMALL_ALLOC