lkml.org 
[lkml]   [2008]   [Jun]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 5/5] x86: PAT: make pat_x_mtrr_type() more readable
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




\
 
 \ /
  Last update: 2008-06-10 16:11    [W:0.194 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site