From: Haren Myneni <haren@linux.vnet.ibm.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linuxppc-dev@lists.ozlabs.org, mikey@neuling.org,
paulus@samba.org, anton@samba.org
Subject: Re: [PATCH 5/6] powerpc: Macros for saving/restore PPR
Date: Mon, 10 Sep 2012 22:18:19 -0700 [thread overview]
Message-ID: <504EC99B.7000302@linux.vnet.ibm.com> (raw)
In-Reply-To: <1347251044.2385.144.camel@pasglop>
On 09/09/2012 09:24 PM, Benjamin Herrenschmidt wrote:
> On Sun, 2012-09-09 at 04:43 -0700, Haren Myneni wrote:
>> Several macros are defined for saving and restore user defined PPR value.
>>
>> Signed-off-by: Haren Myneni <haren@us.ibm.com>
>> ---
>> arch/powerpc/include/asm/exception-64s.h | 35 ++++++++++++++++++++++++++++++
>> arch/powerpc/include/asm/reg.h | 1 +
>> 2 files changed, 36 insertions(+)
>>
>> diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h
>> index bfd3f1f..618fd18 100644
>> --- a/arch/powerpc/include/asm/exception-64s.h
>> +++ b/arch/powerpc/include/asm/exception-64s.h
>> @@ -62,6 +62,41 @@
>> #define EXC_HV H
>> #define EXC_STD
>>
>> +/*
>> + * PPR save/restore macros - Used on P7 or later processors
>> + */
>> +#define SAVE_PPR(area, ra, rb) \
>> +BEGIN_FTR_SECTION_NESTED(940) \
>> + ld ra,area+EX_PPR(r13); /* Read PPR from paca */ \
>> + clrrdi rb,r1,THREAD_SHIFT; /* thread_info struct */ \
>> + std ra,TI_PPR(rb); /* Save PPR in thread_info */ \
>> +END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,940)
>
> Why the thread info and not the thread struct ?
We can also use thread struct, but the saved ppr is needed as long as
the process is in kernel context. Once the process exits, we do not need
this value - means the kernel or any other command will not be reading
this value. Even the process can change this value later. Need to add
ppr in thread_struct which uses extra 8 bytes for each task.
Whereas thread_info is at the top of stack. No need to allocate extra
memory. Since the saved process PPR value is needed temporarily whenever
the process is in kernel, thought thread_info is proper. Also easy to
read - one less load instruction.
Saving in thread_info:
ld r4,area+EX_PPR(r13);
clrrdi r5,r1,THREAD_SHIFT;
std r4,TI_PPR(r5);
Saving in thread_struct:
ld r4,PACACURRENT(r13)
addi r5,r4,THREAD
ld r4,paca+EX_PPR(r13);
std r4,THREAD_PPR(r5)
If you prefer thread_struct, I will change the patch. Please let me know.
Thanks
Haren
>
> Cheers,
> Ben.
>
>> +#define RESTORE_PPR(ra,rb) \
>> +BEGIN_FTR_SECTION_NESTED(941) \
>> + clrrdi ra,r1,THREAD_SHIFT; \
>> + ld rb,TI_PPR(ra); /* Read PPR from thread_info */ \
>> + mtspr SPRN_PPR,rb; /* Restore PPR */ \
>> +END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,941)
>> +
>> +#define RESTORE_PPR_PACA(area,ra) \
>> +BEGIN_FTR_SECTION_NESTED(942) \
>> + ld ra,area+EX_PPR(r13); \
>> + mtspr SPRN_PPR,ra; \
>> +END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,942)
>> +
>> +#define HMT_MEDIUM_NO_PPR \
>> +BEGIN_FTR_SECTION_NESTED(944) \
>> + HMT_MEDIUM; \
>> +END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,0,944) /*non P7*/
>> +
>> +#define HMT_MEDIUM_HAS_PPR(area, ra) \
>> +BEGIN_FTR_SECTION_NESTED(943) \
>> + mfspr ra,SPRN_PPR; \
>> + std ra,area+EX_PPR(r13); \
>> + HMT_MEDIUM; \
>> +END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,943) /* P7 */
>> +
>> #define __EXCEPTION_PROLOG_1(area, extra, vec) \
>> GET_PACA(r13); \
>> std r9,area+EX_R9(r13); /* save r9 - r12 */ \
>> diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
>> index 6386086..dff2f89 100644
>> --- a/arch/powerpc/include/asm/reg.h
>> +++ b/arch/powerpc/include/asm/reg.h
>> @@ -284,6 +284,7 @@
>> #define SPRN_DBAT6U 0x23C /* Data BAT 6 Upper Register */
>> #define SPRN_DBAT7L 0x23F /* Data BAT 7 Lower Register */
>> #define SPRN_DBAT7U 0x23E /* Data BAT 7 Upper Register */
>> +#define SPRN_PPR 0x380 /* SMT Thread status Register */
>>
>> #define SPRN_DEC 0x016 /* Decrement Register */
>> #define SPRN_DER 0x095 /* Debug Enable Regsiter */
>
>
next prev parent reply other threads:[~2012-09-11 5:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-09 11:43 [PATCH 5/6] powerpc: Macros for saving/restore PPR Haren Myneni
2012-09-10 4:24 ` Benjamin Herrenschmidt
2012-09-11 5:18 ` Haren Myneni [this message]
2012-09-11 5:37 ` Benjamin Herrenschmidt
-- strict thread matches above, loose matches on Subject: below --
2012-10-31 6:56 Haren Myneni
2012-11-23 3:39 ` Michael Neuling
2012-11-27 1:49 ` Haren Myneni
2012-12-11 2:41 ` Michael Ellerman
2012-12-07 7:50 Haren Myneni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=504EC99B.7000302@linux.vnet.ibm.com \
--to=haren@linux.vnet.ibm.com \
--cc=anton@samba.org \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mikey@neuling.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).