Subject: Re: PXA250 Xscale and page tables
To: Colin Cook <colin@cook-tech.com>
From: Jason R Thorpe <thorpej@wasabisystems.com>
List: tech-kern
Date: 03/07/2003 15:53:44
--VS++wcV0S1rZb1Fb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Mon, Feb 03, 2003 at 09:32:29AM -0700, Colin Cook wrote:

 > Thanks for the education, I think I get the picture. However, I am still
 > lost as to the proper fix. Can you guys think of why the pages are being
 > mapped to more than one place? I am using 1.6 now and it still happens.
 > There is no hard disk on this system, everything is read directly from a RAM
 > drive which was decompressed from flash on boot. It's a very basic setup. Is
 > there a debug command I can use to find out where the other pages are mapped
 > to and who/why allocated them?

FWIW...

Steve Woodford did some legwork, and was able to reproduce the bug.  The
test case relied on using a disk, which may be why some of us didn't see
it; many developers use NFS root for their ARM development systems.

In any case, once Steve was able to describe the scenario that his test
case revealed, I was able to fix the problem rather quickly.

Please back out any local patches you have already made to work around
the problem, and instead apply the following patch, and please tell me
if it fixes the problem for you or if the problem still persists.  This
patch *did* fix Steve's test case.

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>

--VS++wcV0S1rZb1Fb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=ubc-cache-patch

Index: uvm_bio.c
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm_bio.c,v
retrieving revision 1.26
diff -c -r1.26 uvm_bio.c
*** uvm_bio.c	2002/09/27 15:38:08	1.26
--- uvm_bio.c	2003/03/07 15:40:43
***************
*** 117,130 ****
  int ubc_nwins = UBC_NWINS;
  int ubc_winshift = UBC_WINSHIFT;
  int ubc_winsize;
! #ifdef PMAP_PREFER
  int ubc_nqueues;
  boolean_t ubc_release_unmap = FALSE;
  #define UBC_NQUEUES ubc_nqueues
! #define UBC_RELEASE_UNMAP ubc_release_unmap
  #else
  #define UBC_NQUEUES 1
! #define UBC_RELEASE_UNMAP FALSE
  #endif
  
  /*
--- 117,134 ----
  int ubc_nwins = UBC_NWINS;
  int ubc_winshift = UBC_WINSHIFT;
  int ubc_winsize;
! #if defined(PMAP_PREFER)
  int ubc_nqueues;
  boolean_t ubc_release_unmap = FALSE;
  #define UBC_NQUEUES ubc_nqueues
! #define UBC_RELEASE_UNMAP(uobj) \
! 	(ubc_release_unmap && (((struct vnode *)uobj)->v_flag & VTEXT))
! #elif defined(PMAP_CACHE_VIVT)
! #define UBC_NQUEUES 1
! #define UBC_RELEASE_UNMAP(uobj) TRUE
  #else
  #define UBC_NQUEUES 1
! #define UBC_RELEASE_UNMAP(uobj) FALSE
  #endif
  
  /*
***************
*** 529,546 ****
  	umap->writelen = 0;
  	umap->refcount--;
  	if (umap->refcount == 0) {
! 		if (UBC_RELEASE_UNMAP &&
! 		    (((struct vnode *)uobj)->v_flag & VTEXT)) {
  
  			/*
  			 * if this file is the executable image of
  			 * some process, that process will likely have
  			 * the file mapped at an alignment other than
  			 * what PMAP_PREFER() would like.  we'd like
  			 * to have process text be able to use the
  			 * cache even if someone is also reading the
! 			 * file, so invalidate mappings of such files
! 			 * as soon as possible.
  			 */
  
  			pmap_remove(pmap_kernel(), umapva,
--- 533,554 ----
  	umap->writelen = 0;
  	umap->refcount--;
  	if (umap->refcount == 0) {
! 		if (UBC_RELEASE_UNMAP(uobj)) {
  
  			/*
+ 			 * if the cache is virtually indexed and virtually
+ 			 * tagged, we cannot create a compatible cache alias.
+ 			 *
  			 * if this file is the executable image of
  			 * some process, that process will likely have
  			 * the file mapped at an alignment other than
  			 * what PMAP_PREFER() would like.  we'd like
  			 * to have process text be able to use the
  			 * cache even if someone is also reading the
! 			 * file.
! 			 *
! 			 * so invalidate mappings of such files as soon as
! 			 * possible.
  			 */
  
  			pmap_remove(pmap_kernel(), umapva,

--VS++wcV0S1rZb1Fb--