naca cleanups

Stephen Rothwell sfr at canb.auug.org.au
Thu Dec 9 01:28:27 EST 2004


On Thu, 9 Dec 2004 01:08:59 +1100 Anton Blanchard <anton at samba.org> wrote:
>
> > I have been "encouraged" to clean up the naca and as a first pass, I
> > have been looking at moving some of the fields out of the naca.  Of course,
> > my understanding of the naca is "incomplete" so first question:
> > 
> > Does anyone know if the [di]CacheL1LogLineSize and [di]LinesPerPage fields
> > need to be in the naca and would there be any problem in moving them to
> > the systemcfg structure?
> 
> I cant see why they need to be in there. I always wondered if we would
> be able to handle a change in cacheline size, if the *CacheL1* stuff
> doesnt cover it all then we may as well use #defines instead.
> 
> I _think_ only the first 4 fields in the NACA are architected by the
> OS/400 hypervisor, and none of them by phyp.

OK, so how about this as a first pass.  I have left the fields in
the naca just in case something reads them out of /proc/ppc64/naca.

Untested, not even compiled, just for comment (especially the asm bits).
-- 
Cheers,
Stephen Rothwell                    sfr at canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruN linus-bk/arch/ppc64/kernel/asm-offsets.c linus-bk-naca.1/arch/ppc64/kernel/asm-offsets.c
--- linus-bk/arch/ppc64/kernel/asm-offsets.c	2004-11-26 12:08:51.000000000 +1100
+++ linus-bk-naca.1/arch/ppc64/kernel/asm-offsets.c	2004-12-09 00:59:10.000000000 +1100
@@ -70,11 +70,11 @@
 	/* naca */
         DEFINE(PACA, offsetof(struct naca_struct, paca));
 	DEFINE(DCACHEL1LINESIZE, offsetof(struct systemcfg, dCacheL1LineSize));
-        DEFINE(DCACHEL1LOGLINESIZE, offsetof(struct naca_struct, dCacheL1LogLineSize));
-        DEFINE(DCACHEL1LINESPERPAGE, offsetof(struct naca_struct, dCacheL1LinesPerPage));
+        DEFINE(DCACHEL1LOGLINESIZE, offsetof(struct systemcfg, dCacheL1LogLineSize));
+        DEFINE(DCACHEL1LINESPERPAGE, offsetof(struct systemcfg, dCacheL1LinesPerPage));
         DEFINE(ICACHEL1LINESIZE, offsetof(struct systemcfg, iCacheL1LineSize));
-        DEFINE(ICACHEL1LOGLINESIZE, offsetof(struct naca_struct, iCacheL1LogLineSize));
-        DEFINE(ICACHEL1LINESPERPAGE, offsetof(struct naca_struct, iCacheL1LinesPerPage));
+        DEFINE(ICACHEL1LOGLINESIZE, offsetof(struct systemcfg, iCacheL1LogLineSize));
+        DEFINE(ICACHEL1LINESPERPAGE, offsetof(struct systemcfg, iCacheL1LinesPerPage));
 	DEFINE(PLATFORM, offsetof(struct systemcfg, platform));
 
 	/* paca */
diff -ruN linus-bk/arch/ppc64/kernel/iSeries_setup.c linus-bk-naca.1/arch/ppc64/kernel/iSeries_setup.c
--- linus-bk/arch/ppc64/kernel/iSeries_setup.c	2004-11-12 09:09:48.000000000 +1100
+++ linus-bk-naca.1/arch/ppc64/kernel/iSeries_setup.c	2004-12-09 01:01:44.000000000 +1100
@@ -568,20 +568,26 @@
 		xIoHriProcessorVpd[procIx].xDataL1CacheSizeKB * 1024;
 	systemcfg->dCacheL1LineSize =
 		xIoHriProcessorVpd[procIx].xDataCacheOperandSize;
-	naca->iCacheL1LinesPerPage = PAGE_SIZE / systemcfg->iCacheL1LineSize;
-	naca->dCacheL1LinesPerPage = PAGE_SIZE / systemcfg->dCacheL1LineSize;
+	systemcfg->iCacheL1LinesPerPage =
+		naca->iCacheL1LinesPerPage =
+			PAGE_SIZE / systemcfg->iCacheL1LineSize;
+	systemcfg->dCacheL1LinesPerPage =
+		naca->dCacheL1LinesPerPage =
+			PAGE_SIZE / systemcfg->dCacheL1LineSize;
 
 	i = systemcfg->iCacheL1LineSize;
 	n = 0;
 	while ((i = (i / 2)))
 		++n;
-	naca->iCacheL1LogLineSize = n;
+	systemcfg->iCacheL1LogLineSize =
+		naca->iCacheL1LogLineSize = n;
 
 	i = systemcfg->dCacheL1LineSize;
 	n = 0;
 	while ((i = (i / 2)))
 		++n;
-	naca->dCacheL1LogLineSize = n;
+	systemcfg->dCacheL1LogLineSize =
+		naca->dCacheL1LogLineSize = n;
 
 	printk("D-cache line size = %d\n",
 			(unsigned int)systemcfg->dCacheL1LineSize);
diff -ruN linus-bk/arch/ppc64/kernel/misc.S linus-bk-naca.1/arch/ppc64/kernel/misc.S
--- linus-bk/arch/ppc64/kernel/misc.S	2004-11-12 09:09:48.000000000 +1100
+++ linus-bk-naca.1/arch/ppc64/kernel/misc.S	2004-12-09 00:51:37.000000000 +1100
@@ -207,8 +207,6 @@
  * and in some cases i-cache and d-cache line sizes differ from
  * each other.
  */
-	LOADADDR(r10,naca)		/* Get Naca address */
-	ld	r10,0(r10)
 	LOADADDR(r11,systemcfg)		/* Get systemcfg address */
 	ld	r11,0(r11)
 	lwz	r7,DCACHEL1LINESIZE(r11)/* Get cache line size */
@@ -216,7 +214,7 @@
 	andc	r6,r3,r5		/* round low to line bdy */
 	subf	r8,r6,r4		/* compute length */
 	add	r8,r8,r5		/* ensure we get enough */
-	lwz	r9,DCACHEL1LOGLINESIZE(r10)	/* Get log-2 of cache line size */
+	lwz	r9,DCACHEL1LOGLINESIZE(r11)	/* Get log-2 of cache line size */
 	srw.	r8,r8,r9		/* compute line count */
 	beqlr				/* nothing to do? */
 	mtctr	r8
@@ -232,7 +230,7 @@
 	andc	r6,r3,r5		/* round low to line bdy */
 	subf	r8,r6,r4		/* compute length */
 	add	r8,r8,r5
-	lwz	r9,ICACHEL1LOGLINESIZE(r10)	/* Get log-2 of Icache line size */
+	lwz	r9,ICACHEL1LOGLINESIZE(r11)	/* Get log-2 of Icache line size */
 	srw.	r8,r8,r9		/* compute line count */
 	beqlr				/* nothing to do? */
 	mtctr	r8
@@ -256,8 +254,6 @@
  * 
  * Different systems have different cache line sizes
  */
-	LOADADDR(r10,naca)		/* Get Naca address */
-	ld	r10,0(r10)
 	LOADADDR(r11,systemcfg)		/* Get systemcfg address */
 	ld	r11,0(r11)
 	lwz	r7,DCACHEL1LINESIZE(r11)	/* Get dcache line size */
@@ -265,7 +261,7 @@
 	andc	r6,r3,r5		/* round low to line bdy */
 	subf	r8,r6,r4		/* compute length */
 	add	r8,r8,r5		/* ensure we get enough */
-	lwz	r9,DCACHEL1LOGLINESIZE(r10)	/* Get log-2 of dcache line size */
+	lwz	r9,DCACHEL1LOGLINESIZE(r11)	/* Get log-2 of dcache line size */
 	srw.	r8,r8,r9		/* compute line count */
 	beqlr				/* nothing to do? */
 	mtctr	r8
@@ -286,8 +282,6 @@
  *    flush all bytes from start to stop-1 inclusive
  */
 _GLOBAL(flush_dcache_phys_range)
-	LOADADDR(r10,naca)		/* Get Naca address */
-	ld	r10,0(r10)
 	LOADADDR(r11,systemcfg)		/* Get systemcfg address */
 	ld	r11,0(r11)
 	lwz	r7,DCACHEL1LINESIZE(r11)	/* Get dcache line size */
@@ -295,7 +289,7 @@
 	andc	r6,r3,r5		/* round low to line bdy */
 	subf	r8,r6,r4		/* compute length */
 	add	r8,r8,r5		/* ensure we get enough */
-	lwz	r9,DCACHEL1LOGLINESIZE(r10)	/* Get log-2 of dcache line size */
+	lwz	r9,DCACHEL1LOGLINESIZE(r11)	/* Get log-2 of dcache line size */
 	srw.	r8,r8,r9		/* compute line count */
 	beqlr				/* nothing to do? */
 	mfmsr	r5			/* Disable MMU Data Relocation */
@@ -332,12 +326,10 @@
  */
 
 /* Flush the dcache */
-	LOADADDR(r7,naca)
-	ld	r7,0(r7)
 	LOADADDR(r8,systemcfg)			/* Get systemcfg address */
 	ld	r8,0(r8)
 	clrrdi	r3,r3,12           	    /* Page align */
-	lwz	r4,DCACHEL1LINESPERPAGE(r7)	/* Get # dcache lines per page */
+	lwz	r4,DCACHEL1LINESPERPAGE(r8)	/* Get # dcache lines per page */
 	lwz	r5,DCACHEL1LINESIZE(r8)		/* Get dcache line size */
 	mr	r6,r3
 	mtctr	r4
@@ -348,7 +340,7 @@
 
 /* Now invalidate the icache */	
 
-	lwz	r4,ICACHEL1LINESPERPAGE(r7)	/* Get # icache lines per page */
+	lwz	r4,ICACHEL1LINESPERPAGE(r8)	/* Get # icache lines per page */
 	lwz	r5,ICACHEL1LINESIZE(r8)		/* Get icache line size */
 	mtctr	r4
 1:	icbi	0,r3
diff -ruN linus-bk/arch/ppc64/kernel/setup.c linus-bk-naca.1/arch/ppc64/kernel/setup.c
--- linus-bk/arch/ppc64/kernel/setup.c	2004-11-26 12:08:51.000000000 +1100
+++ linus-bk-naca.1/arch/ppc64/kernel/setup.c	2004-12-09 00:57:58.000000000 +1100
@@ -496,8 +496,10 @@
 
 			systemcfg->dCacheL1Size = size;
 			systemcfg->dCacheL1LineSize = lsize;
-			naca->dCacheL1LogLineSize = __ilog2(lsize);
-			naca->dCacheL1LinesPerPage = PAGE_SIZE/(lsize);
+			systemcfg->dCacheL1LogLineSize =
+				naca->dCacheL1LogLineSize = __ilog2(lsize);
+			systemcfg->dCacheL1LinesPerPage =
+				naca->dCacheL1LinesPerPage = PAGE_SIZE/(lsize);
 
 			size = 0;
 			lsize = cur_cpu_spec->icache_bsize;
@@ -513,8 +515,10 @@
 
 			systemcfg->iCacheL1Size = size;
 			systemcfg->iCacheL1LineSize = lsize;
-			naca->iCacheL1LogLineSize = __ilog2(lsize);
-			naca->iCacheL1LinesPerPage = PAGE_SIZE/(lsize);
+			systemcfg->iCacheL1LogLineSize
+				naca->iCacheL1LogLineSize = __ilog2(lsize);
+			systemcfg->iCacheL1LinesPerPage
+				naca->iCacheL1LinesPerPage = PAGE_SIZE/(lsize);
 
 		}
 	}
diff -ruN linus-bk/include/asm-ppc64/page.h linus-bk-naca.1/include/asm-ppc64/page.h
--- linus-bk/include/asm-ppc64/page.h	2004-10-29 07:03:22.000000000 +1000
+++ linus-bk-naca.1/include/asm-ppc64/page.h	2004-12-09 01:03:57.000000000 +1100
@@ -107,7 +107,7 @@
 	unsigned long lines, line_size;
 
 	line_size = systemcfg->dCacheL1LineSize; 
-	lines = naca->dCacheL1LinesPerPage;
+	lines = systemcfg->dCacheL1LinesPerPage;
 
 	__asm__ __volatile__(
 	"mtctr  	%1	# clear_page\n\
diff -ruN linus-bk/include/asm-ppc64/systemcfg.h linus-bk-naca.1/include/asm-ppc64/systemcfg.h
--- linus-bk/include/asm-ppc64/systemcfg.h	2004-09-29 08:25:16.000000000 +1000
+++ linus-bk-naca.1/include/asm-ppc64/systemcfg.h	2004-12-09 01:10:58.000000000 +1100
@@ -28,7 +28,7 @@
  * Minor version changes are a hint.
  */
 #define SYSTEMCFG_MAJOR 1
-#define SYSTEMCFG_MINOR 0
+#define SYSTEMCFG_MINOR 1
 
 #ifndef __ASSEMBLY__
 
@@ -54,7 +54,11 @@
 	__u32 dCacheL1LineSize;		/* L1 d-cache line size		0x64 */
 	__u32 iCacheL1Size;		/* L1 i-cache size		0x68 */
 	__u32 iCacheL1LineSize;		/* L1 i-cache line size		0x6C */
-	__u8  reserved0[3984];		/* Reserve rest of page		0x70 */
+	__u32 dCacheL1LogLineSize;	/* L1 d-cache line size Log2	0x70 */
+	__u32 dCacheL1LinesPerPage;	/* L1 d-cache lines / page	0x74 */
+	__u32 iCacheL1LogLineSize;	/* L1 i-cache line size Log2	0x78 */
+	__u32 iCacheL1LinesPerPage;	/* L1 i-cache lines / page	0x7c */
+	__u8  reserved0[3968];		/* Reserve rest of page		0x80 */
 };
 
 #ifdef __KERNEL__
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://ozlabs.org/pipermail/linuxppc64-dev/attachments/20041209/33faebe8/attachment.pgp 


More information about the Linuxppc64-dev mailing list