|
@@ -64,6 +64,33 @@ static inline void k8_check_syscfg_dram_mod_en(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
+ * Check and return the effective type for MTRR-MTRR type overlap.
|
|
|
+ * Returns 1 if the effective type is UNCACHEABLE, else returns 0
|
|
|
+ */
|
|
|
+static int check_type_overlap(u8 *prev, u8 *curr)
|
|
|
+{
|
|
|
+ if (*prev == MTRR_TYPE_UNCACHABLE || *curr == MTRR_TYPE_UNCACHABLE) {
|
|
|
+ *prev = MTRR_TYPE_UNCACHABLE;
|
|
|
+ *curr = MTRR_TYPE_UNCACHABLE;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((*prev == MTRR_TYPE_WRBACK && *curr == MTRR_TYPE_WRTHROUGH) ||
|
|
|
+ (*prev == MTRR_TYPE_WRTHROUGH && *curr == MTRR_TYPE_WRBACK)) {
|
|
|
+ *prev = MTRR_TYPE_WRTHROUGH;
|
|
|
+ *curr = MTRR_TYPE_WRTHROUGH;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (*prev != *curr) {
|
|
|
+ *prev = MTRR_TYPE_UNCACHABLE;
|
|
|
+ *curr = MTRR_TYPE_UNCACHABLE;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
/*
|
|
|
* Returns the effective MTRR type for the region
|
|
|
* Error returns:
|
|
@@ -138,21 +165,8 @@ u8 mtrr_type_lookup(u64 start, u64 end)
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- if (prev_match == MTRR_TYPE_UNCACHABLE ||
|
|
|
- curr_match == MTRR_TYPE_UNCACHABLE) {
|
|
|
- return MTRR_TYPE_UNCACHABLE;
|
|
|
- }
|
|
|
-
|
|
|
- if ((prev_match == MTRR_TYPE_WRBACK &&
|
|
|
- curr_match == MTRR_TYPE_WRTHROUGH) ||
|
|
|
- (prev_match == MTRR_TYPE_WRTHROUGH &&
|
|
|
- curr_match == MTRR_TYPE_WRBACK)) {
|
|
|
- prev_match = MTRR_TYPE_WRTHROUGH;
|
|
|
- curr_match = MTRR_TYPE_WRTHROUGH;
|
|
|
- }
|
|
|
-
|
|
|
- if (prev_match != curr_match)
|
|
|
- return MTRR_TYPE_UNCACHABLE;
|
|
|
+ if (check_type_overlap(&prev_match, &curr_match))
|
|
|
+ return curr_match;
|
|
|
}
|
|
|
|
|
|
if (mtrr_tom2) {
|