From: Andreas Herrmann <andreas.herrmann3@amd.com>
To: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
"H. Peter Anvin" <hpa@zytor.com>
Cc: linux-kernel@vger.kernel.org,
Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>,
Suresh B Siddha <suresh.b.siddha@intel.com>
Subject: [PATCH 5/5] x86: PAT: make pat_x_mtrr_type() more readable
Date: Tue, 10 Jun 2008 16:07:55 +0200 [thread overview]
Message-ID: <20080610140755.GI5024@alberich.amd.com> (raw)
I've found it inconvenient to review pat_x_mtrr_type().
Thus I slightly changed it and added some comment to make it more
readable.
I've also added BUG statements for (some) unused/unhandled PAT/MTRR types.
Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
---
arch/x86/mm/pat.c | 30 +++++++++++++++++++++---------
1 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index 2f6c33d..fc0a397 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -185,18 +185,30 @@ static int pat_x_mtrr_type(u64 start, u64 end, unsigned long prot,
prot &= (~_PAGE_CACHE_MASK);
/* Currently doing intersection by hand. Optimize it later. */
- if (pat_type == _PAGE_CACHE_WC) {
+ /* effective type ret_prot
+ pat \ mtrr WB WC UC pat \ mtrr WB WC UC
+ WC WC WC WC WC WC WC WC
+ UC- UC WC UC UC- UC- UC- UC-
+ UC UC UC UC UC UC UC UC
+ WB WB WC UC WB WB WC UC
+ */
+ if (pat_type == _PAGE_CACHE_WC)
*ret_prot = prot | _PAGE_CACHE_WC;
- } else if (pat_type == _PAGE_CACHE_UC_MINUS) {
+ else if (pat_type == _PAGE_CACHE_UC_MINUS)
*ret_prot = prot | _PAGE_CACHE_UC_MINUS;
- } else if (pat_type == _PAGE_CACHE_UC ||
- mtrr_type == MTRR_TYPE_UNCACHABLE) {
+ else if (pat_type == _PAGE_CACHE_UC)
*ret_prot = prot | _PAGE_CACHE_UC;
- } else if (mtrr_type == MTRR_TYPE_WRCOMB) {
- *ret_prot = prot | _PAGE_CACHE_WC;
- } else {
- *ret_prot = prot | _PAGE_CACHE_WB;
- }
+ else if (pat_type == _PAGE_CACHE_WB) {
+ if (mtrr_type == MTRR_TYPE_WRBACK)
+ *ret_prot = prot | _PAGE_CACHE_WB;
+ else if (mtrr_type == MTRR_TYPE_WRCOMB)
+ *ret_prot = prot | _PAGE_CACHE_WC;
+ else if (mtrr_type == MTRR_TYPE_UNCACHABLE)
+ *ret_prot = prot | _PAGE_CACHE_UC;
+ else
+ BUG();
+ } else
+ BUG();
return 0;
}
--
1.5.5.3
next reply other threads:[~2008-06-10 14:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-10 14:07 Andreas Herrmann [this message]
2008-06-16 12:58 ` [PATCH 5/5 v2] " Andreas Herrmann
2008-06-16 17:42 ` Hugh Dickins
2008-06-18 9:51 ` Ingo Molnar
2008-06-18 13:38 ` Andreas Herrmann
2008-06-18 16:28 ` Hugh Dickins
2008-06-19 10:39 ` Ingo Molnar
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=20080610140755.GI5024@alberich.amd.com \
--to=andreas.herrmann3@amd.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=suresh.b.siddha@intel.com \
--cc=tglx@linutronix.de \
--cc=venkatesh.pallipadi@intel.com \
/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
Powered by JetHome