<p>Nico Huber has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/21914">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">cpu/x86/mtrr: Remove var-MTRR alignment optimization<br><br>The code used to split up ranges >64MiB into 64MiB-aligned and<br>unaligned parts. However in its current state the next step,<br>calc_var_mtrr_range(), results in the same allocation, no mat-<br>ter if we split the range up before. So just drop the split-up.<br><br>Change-Id: I5481fbf3168cdf789879064077b63bbfcaf122c9<br>Signed-off-by: Nico Huber <nico.h@gmx.de><br>---<br>M src/cpu/x86/mtrr/mtrr.c<br>1 file changed, 10 insertions(+), 38 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/21914/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/src/cpu/x86/mtrr/mtrr.c b/src/cpu/x86/mtrr/mtrr.c<br>index ef1bb31..c2c629c 100644<br>--- a/src/cpu/x86/mtrr/mtrr.c<br>+++ b/src/cpu/x86/mtrr/mtrr.c<br>@@ -552,60 +552,32 @@<br> static void calc_var_mtrrs_without_hole(struct var_mtrr_state *var_state,<br> struct range_entry *r)<br> {<br>- uint32_t a1, a2, b1, b2, c1, c2;<br>- int mtrr_type;<br>+ const int mtrr_type = range_entry_mtrr_type(r);<br> <br>- /*<br>- * For each range that meets the non-default type process it in the<br>- * following manner:<br>- * +------------------+ c2 = end<br>- * | 0 or more bytes |<br>- * +------------------+ b2 = c1 = ALIGN_DOWN(end)<br>- * | |<br>- * +------------------+ b1 = a2 = ALIGN_UP(begin)<br>- * | 0 or more bytes |<br>- * +------------------+ a1 = begin<br>- *<br>- * Thus, there are 3 sub-ranges to configure variable MTRRs for.<br>- */<br>- mtrr_type = range_entry_mtrr_type(r);<br>-<br>- a1 = range_entry_base_mtrr_addr(r);<br>- c2 = range_entry_end_mtrr_addr(r);<br>+ uint32_t base = range_entry_base_mtrr_addr(r);<br>+ uint32_t end = range_entry_end_mtrr_addr(r);<br> <br> /* The end address is within the first 1MiB. The fixed MTRRs take<br> * precedence over the variable ones. Therefore this range<br> * can be ignored. */<br>- if (c2 <= RANGE_1MB)<br>+ if (end <= RANGE_1MB)<br> return;<br> <br> /* Again, the fixed MTRRs take precedence so the beginning<br> * of the range can be set to 0 if it starts at or below 1MiB. */<br>- if (a1 <= RANGE_1MB)<br>- a1 = 0;<br>+ if (base <= RANGE_1MB)<br>+ base = 0;<br> <br> /* If the range starts above 4GiB the processing is done. */<br>- if (!var_state->above4gb && a1 >= RANGE_4GB)<br>+ if (!var_state->above4gb && base >= RANGE_4GB)<br> return;<br> <br> /* Clip the upper address to 4GiB if addresses above 4GiB<br> * are not being processed. */<br>- if (!var_state->above4gb && c2 > RANGE_4GB)<br>- c2 = RANGE_4GB;<br>+ if (!var_state->above4gb && end > RANGE_4GB)<br>+ end = RANGE_4GB;<br> <br>- /* Don't align up or down on the range if it is smaller<br>- * than the minimum granularity. */<br>- if ((c2 - a1) < MTRR_MIN_ALIGN) {<br>- calc_var_mtrr_range(var_state, a1, c2 - a1, mtrr_type);<br>- return;<br>- }<br>-<br>- b1 = a2 = ALIGN_UP(a1, MTRR_MIN_ALIGN);<br>- b2 = c1 = ALIGN_DOWN(c2, MTRR_MIN_ALIGN);<br>-<br>- calc_var_mtrr_range(var_state, a1, a2 - a1, mtrr_type);<br>- calc_var_mtrr_range(var_state, b1, b2 - b1, mtrr_type);<br>- calc_var_mtrr_range(var_state, c1, c2 - c1, mtrr_type);<br>+ calc_var_mtrr_range(var_state, base, end - base, mtrr_type);<br> }<br> <br> static void __calc_var_mtrrs(struct memranges *addr_space,<br></pre><p>To view, visit <a href="https://review.coreboot.org/21914">change 21914</a>. To unsubscribe, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/21914"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I5481fbf3168cdf789879064077b63bbfcaf122c9 </div>
<div style="display:none"> Gerrit-Change-Number: 21914 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Nico Huber <nico.h@gmx.de> </div>