diff options
author | Venkatesh Pallipadi <venki@google.com> | 2010-09-10 18:55:49 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2010-09-10 19:11:10 -0400 |
commit | a7f07cfbaa1dd5bf9e615948f280c92e7928e6f7 (patch) | |
tree | 68cce2213ae78a365b5ce35121fef75841b38675 /arch/x86/kernel/cpu/mtrr | |
parent | 2bfc96a127bc1cc94d26bfaa40159966064f9c8c (diff) |
x86, mtrr: Refactor MTRR type overlap check code
Move the MTRR type overlap check into a new function. No functional change in
this patch. Just making it easier to add multiple region overlap check in
the following patch.
Signed-off-by: Venkatesh Pallipadi <venki@google.com>
LKML-Reference: <1284159350-19841-2-git-send-email-venki@google.com>
Reviewed-by: Suresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch/x86/kernel/cpu/mtrr')
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/generic.c | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c index 7d28d7d03885..14f4f0c0329a 100644 --- a/arch/x86/kernel/cpu/mtrr/generic.c +++ b/arch/x86/kernel/cpu/mtrr/generic.c | |||
@@ -65,6 +65,33 @@ static inline void k8_check_syscfg_dram_mod_en(void) | |||
65 | } | 65 | } |
66 | 66 | ||
67 | /* | 67 | /* |
68 | * Check and return the effective type for MTRR-MTRR type overlap. | ||
69 | * Returns 1 if the effective type is UNCACHEABLE, else returns 0 | ||
70 | */ | ||
71 | static int check_type_overlap(u8 *prev, u8 *curr) | ||
72 | { | ||
73 | if (*prev == MTRR_TYPE_UNCACHABLE || *curr == MTRR_TYPE_UNCACHABLE) { | ||
74 | *prev = MTRR_TYPE_UNCACHABLE; | ||
75 | *curr = MTRR_TYPE_UNCACHABLE; | ||
76 | return 1; | ||
77 | } | ||
78 | |||
79 | if ((*prev == MTRR_TYPE_WRBACK && *curr == MTRR_TYPE_WRTHROUGH) || | ||
80 | (*prev == MTRR_TYPE_WRTHROUGH && *curr == MTRR_TYPE_WRBACK)) { | ||
81 | *prev = MTRR_TYPE_WRTHROUGH; | ||
82 | *curr = MTRR_TYPE_WRTHROUGH; | ||
83 | } | ||
84 | |||
85 | if (*prev != *curr) { | ||
86 | *prev = MTRR_TYPE_UNCACHABLE; | ||
87 | *curr = MTRR_TYPE_UNCACHABLE; | ||
88 | return 1; | ||
89 | } | ||
90 | |||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | /* | ||
68 | * Returns the effective MTRR type for the region | 95 | * Returns the effective MTRR type for the region |
69 | * Error returns: | 96 | * Error returns: |
70 | * - 0xFE - when the range is "not entirely covered" by _any_ var range MTRR | 97 | * - 0xFE - when the range is "not entirely covered" by _any_ var range MTRR |
@@ -138,21 +165,8 @@ u8 mtrr_type_lookup(u64 start, u64 end) | |||
138 | continue; | 165 | continue; |
139 | } | 166 | } |
140 | 167 | ||
141 | if (prev_match == MTRR_TYPE_UNCACHABLE || | 168 | if (check_type_overlap(&prev_match, &curr_match)) |
142 | curr_match == MTRR_TYPE_UNCACHABLE) { | 169 | return curr_match; |
143 | return MTRR_TYPE_UNCACHABLE; | ||
144 | } | ||
145 | |||
146 | if ((prev_match == MTRR_TYPE_WRBACK && | ||
147 | curr_match == MTRR_TYPE_WRTHROUGH) || | ||
148 | (prev_match == MTRR_TYPE_WRTHROUGH && | ||
149 | curr_match == MTRR_TYPE_WRBACK)) { | ||
150 | prev_match = MTRR_TYPE_WRTHROUGH; | ||
151 | curr_match = MTRR_TYPE_WRTHROUGH; | ||
152 | } | ||
153 | |||
154 | if (prev_match != curr_match) | ||
155 | return MTRR_TYPE_UNCACHABLE; | ||
156 | } | 170 | } |
157 | 171 | ||
158 | if (mtrr_tom2) { | 172 | if (mtrr_tom2) { |