* [PATCH] PPC601 MQ handling
@ 2004-06-16 20:42 Stef Simoens
2004-06-16 20:44 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 4+ messages in thread
From: Stef Simoens @ 2004-06-16 20:42 UTC (permalink / raw)
To: linuxppc-dev; +Cc: benh, paulus
This is a patch to handle the MQ-register found on 601 CPU's. It's a diff against linux-2.6.7. Could this patch be included in further Linux kernels?
The patch can also be downloaded from http://users.tijd.com/~tdn46485/linux-2.6.7-mq.patch
I also wrote a small testcase (http://users.tijd.com/~tdn46485/mqtest.s)
The test makes a division, enters a for loop, and prints the contents of the MQ register.
Changes:
* Add a CONFIG_PPC601_MQ option
* Set CPU_FTR_MQ for 601 (arch/ppc/cputable.c, include/asm-ppc/cputable.h)
* Save and restore the MQ register (arch/ppc/entry.S, include/asm-ppc/reg.h)
* Delete the 'not used' message, mq debug (arch/ppc/kernel/ppc-stub.c, include/asm-ppc/ptrace.h)
Signed-off-by: Stef Simoens <stef.simoens@pi.be>
diff -upr linux-2.6.7/arch/ppc/Kconfig linux-2.6.7-mq/arch/ppc/Kconfig
--- linux-2.6.7/arch/ppc/Kconfig 2004-06-16 07:20:22.000000000 +0200
+++ linux-2.6.7-mq/arch/ppc/Kconfig 2004-06-16 13:00:08.000000000 +0200
@@ -197,6 +197,19 @@ config PPC601_SYNC_FIX
If in doubt, say Y here.
+config PPC601_MQ
+ bool "Enable MQ register on PPC601 CPU"
+ depends on 6xx && (PPC_PREP || PPC_PMAC)
+ help
+ The PPC601 (the first PowerPC chip) has a special MQ register.
+ This option enables kernel support for saving and restoring the MQ
+ register. This will allow to use gcc's -mcpu=601 option without
+ breaking executables.
+
+ This option is only useful if you have a 601 processor and does
+ not have any affect on other processors (it does, however, add
+ code to the kernel). Say Y here if you have a 601 chip.
+
source arch/ppc/platforms/4xx/Kconfig
config PPC64BRIDGE
diff -upr linux-2.6.7/arch/ppc/kernel/cputable.c linux-2.6.7-mq/arch/ppc/kernel/cputable.c
--- linux-2.6.7/arch/ppc/kernel/cputable.c 2004-06-16 07:19:26.000000000 +0200
+++ linux-2.6.7-mq/arch/ppc/kernel/cputable.c 2004-06-16 13:00:08.000000000 +0200
@@ -66,7 +66,7 @@ struct cpu_spec cpu_specs[] = {
{ /* 601 */
0xffff0000, 0x00010000, "601",
CPU_FTR_COMMON |
- CPU_FTR_601 | CPU_FTR_HPTE_TABLE,
+ CPU_FTR_601 | CPU_FTR_HPTE_TABLE | CPU_FTR_MQ,
COMMON_PPC | PPC_FEATURE_601_INSTR | PPC_FEATURE_UNIFIED_CACHE,
32, 32,
__setup_cpu_601
diff -upr linux-2.6.7/arch/ppc/kernel/entry.S linux-2.6.7-mq/arch/ppc/kernel/entry.S
--- linux-2.6.7/arch/ppc/kernel/entry.S 2004-06-16 07:19:52.000000000 +0200
+++ linux-2.6.7-mq/arch/ppc/kernel/entry.S 2004-06-16 13:00:08.000000000 +0200
@@ -104,6 +104,12 @@ transfer_to_handler:
mfspr r2,XER
stw r12,_CTR(r11)
stw r2,_XER(r11)
+#ifdef CONFIG_PPC601_MQ
+BEGIN_FTR_SECTION
+ mfspr r2,SPRN_MQ
+ stw r2,_MQ(r11)
+END_FTR_SECTION_IFSET(CPU_FTR_MQ)
+#endif /* CONFIG_PPC601_MQ */
mfspr r12,SPRG3
addi r2,r12,-THREAD
tovirt(r2,r2) /* set r2 to current */
@@ -641,6 +647,12 @@ restore:
lwz r11,_CTR(r1)
mtspr XER,r10
mtctr r11
+#ifdef CONFIG_PPC601_MQ
+BEGIN_FTR_SECTION
+ lwz r10,_MQ(r1)
+ mtspr SPRN_MQ,r10
+END_FTR_SECTION_IFSET(CPU_FTR_MQ)
+#endif /* CONFIG_PPC601_MQ */
PPC405_ERR77(0,r1)
stwcx. r0,0,r1 /* to clear the reservation */
@@ -738,6 +750,12 @@ ret_from_crit_exc:
lwz r11,_CTR(r1)
mtspr XER,r10
mtctr r11
+#ifdef CONFIG_PPC601_MQ
+BEGIN_FTR_SECTION
+ lwz r10,_MQ(r1)
+ mtspr SPRN_MQ,r10
+END_FTR_SECTION_IFSET(CPU_FTR_MQ)
+#endif /* CONFIG_PPC601_MQ */
PPC405_ERR77(0,r1)
stwcx. r0,0,r1 /* to clear the reservation */
diff -upr linux-2.6.7/arch/ppc/kernel/ppc-stub.c linux-2.6.7-mq/arch/ppc/kernel/ppc-stub.c
--- linux-2.6.7/arch/ppc/kernel/ppc-stub.c 2004-06-16 07:20:03.000000000 +0200
+++ linux-2.6.7-mq/arch/ppc/kernel/ppc-stub.c 2004-06-16 13:00:08.000000000 +0200
@@ -690,6 +690,7 @@ handle_exception (struct pt_regs *regs)
ptr = mem2hex((char *)®s->link, ptr, 4);
ptr = mem2hex((char *)®s->ctr, ptr, 4);
ptr = mem2hex((char *)®s->xer, ptr, 4);
+ ptr = mem2hex((char *)®s->mq, ptr, 4);
}
break;
@@ -709,13 +710,14 @@ handle_exception (struct pt_regs *regs)
/*ptr = hex2mem(ptr, ??, 32 * 8);*/
ptr += 32*8*2;
- /* pc, msr, cr, lr, ctr, xer, (mq is unused) */
+ /* pc, msr, cr, lr, ctr, xer, mq */
ptr = hex2mem(ptr, (char *)®s->nip, 4);
ptr = hex2mem(ptr, (char *)®s->msr, 4);
ptr = hex2mem(ptr, (char *)®s->ccr, 4);
ptr = hex2mem(ptr, (char *)®s->link, 4);
ptr = hex2mem(ptr, (char *)®s->ctr, 4);
ptr = hex2mem(ptr, (char *)®s->xer, 4);
+ ptr = hex2mem(ptr, (char *)®s->mq, 4);
strcpy(remcomOutBuffer,"OK");
}
diff -upr linux-2.6.7/include/asm-ppc/cputable.h linux-2.6.7-mq/include/asm-ppc/cputable.h
--- linux-2.6.7/include/asm-ppc/cputable.h 2004-06-16 07:19:22.000000000 +0200
+++ linux-2.6.7-mq/include/asm-ppc/cputable.h 2004-06-16 13:00:09.000000000 +0200
@@ -76,6 +76,7 @@ extern struct cpu_spec *cur_cpu_spec[];
#define CPU_FTR_NO_DPM 0x00008000
#define CPU_FTR_HAS_HIGH_BATS 0x00010000
#define CPU_FTR_NEED_COHERENT 0x00020000
+#define CPU_FTR_MQ 0x00040000
#ifdef __ASSEMBLY__
diff -upr linux-2.6.7/include/asm-ppc/ptrace.h linux-2.6.7-mq/include/asm-ppc/ptrace.h
--- linux-2.6.7/include/asm-ppc/ptrace.h 2004-06-16 07:19:23.000000000 +0200
+++ linux-2.6.7-mq/include/asm-ppc/ptrace.h 2004-06-16 13:00:09.000000000 +0200
@@ -27,7 +27,7 @@ struct pt_regs {
unsigned long link;
unsigned long xer;
unsigned long ccr;
- unsigned long mq; /* 601 only (not used at present) */
+ unsigned long mq; /* 601 only */
/* Used on APUS to hold IPL value. */
unsigned long trap; /* Reason for being here */
/* N.B. for critical exceptions on 4xx, the dar and dsisr
diff -upr linux-2.6.7/include/asm-ppc/reg.h linux-2.6.7-mq/include/asm-ppc/reg.h
--- linux-2.6.7/include/asm-ppc/reg.h 2004-06-16 07:19:52.000000000 +0200
+++ linux-2.6.7-mq/include/asm-ppc/reg.h 2004-06-16 13:00:09.000000000 +0200
@@ -316,6 +316,7 @@
#define SPRN_USIA 0x3AB /* User Sampled Instruction Address Register */
#define SPRN_VRSAVE 0x100 /* Vector Register Save Register */
#define SPRN_XER 0x001 /* Fixed Point Exception Register */
+#define SPRN_MQ 0x000 /* MQ Register */
/* Bit definitions for MMCR0 and PMC1 / PMC2. */
#define MMCR0_PMC1_CYCLES (1 << 7)
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] PPC601 MQ handling
2004-06-16 20:42 [PATCH] PPC601 MQ handling Stef Simoens
@ 2004-06-16 20:44 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2004-06-16 20:44 UTC (permalink / raw)
To: Stef Simoens; +Cc: linuxppc-dev list, Paul Mackerras
On Wed, 2004-06-16 at 15:42, Stef Simoens wrote:
> This is a patch to handle the MQ-register found on 601 CPU's. It's a diff against linux-2.6.7. Could this patch be included in further Linux kernels?
>
> The patch can also be downloaded from http://users.tijd.com/~tdn46485/linux-2.6.7-mq.patch
> I also wrote a small testcase (http://users.tijd.com/~tdn46485/mqtest.s)
> The test makes a division, enters a for loop, and prints the contents of the MQ register.
>
> Changes:
> * Add a CONFIG_PPC601_MQ option
> * Set CPU_FTR_MQ for 601 (arch/ppc/cputable.c, include/asm-ppc/cputable.h)
> * Save and restore the MQ register (arch/ppc/entry.S, include/asm-ppc/reg.h)
> * Delete the 'not used' message, mq debug (arch/ppc/kernel/ppc-stub.c, include/asm-ppc/ptrace.h)
>
> Signed-off-by: Stef Simoens <stef.simoens@pi.be>
Did you check it was actually saved/restored by the signal code ?
Ben.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PPC601 MQ handling
@ 2004-06-17 9:19 Stef Simoens
2004-06-17 16:27 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 4+ messages in thread
From: Stef Simoens @ 2004-06-17 9:19 UTC (permalink / raw)
To: benh; +Cc: linuxppc-dev, paulus
> Did you check it was actually saved/restored by the signal code ?
>
> Ben.
I looked up when XER gets saved/restored to save/restore MQ.
I tested my patch with
mqtest &
(start other programs which are 'MQ-enabled')
fg
^Z
...
and mqtest gave me the correct output.
I used the same principle to patch my 2.4 kernel and I'm running with the patch for over 3 months now.
If this isn't the answer you wanted, could you please point out what I should be testing?
Thanks
Stef
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PPC601 MQ handling
2004-06-17 9:19 Stef Simoens
@ 2004-06-17 16:27 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2004-06-17 16:27 UTC (permalink / raw)
To: Stef Simoens; +Cc: linuxppc-dev list, Paul Mackerras
On Thu, 2004-06-17 at 04:19, Stef Simoens wrote:
> > Did you check it was actually saved/restored by the signal code ?
> >
> > Ben.
>
> I looked up when XER gets saved/restored to save/restore MQ.
>
> I tested my patch with
> mqtest &
> (start other programs which are 'MQ-enabled')
> fg
> ^Z
> ...
> and mqtest gave me the correct output.
I was concerned about arch/ppc/kernel/signal.c but it seems that it's ok,
it will save & restore it properly.
Paul, do we want this patch in ?
Ben.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-06-17 16:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-16 20:42 [PATCH] PPC601 MQ handling Stef Simoens
2004-06-16 20:44 ` Benjamin Herrenschmidt
-- strict thread matches above, loose matches on Subject: below --
2004-06-17 9:19 Stef Simoens
2004-06-17 16:27 ` Benjamin Herrenschmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).