2017-12-07 12:38:18

by Matthew Auld

[permalink] [raw]
Subject: [PATCH 3/9] x86/early-quirks: reverse the if ladders

Makes things a little easier to follow.

Suggested-by: Ville Syrjälä <[email protected]>
Signed-off-by: Matthew Auld <[email protected]>
Cc: Joonas Lahtinen <[email protected]>
Cc: Ville Syrjälä <[email protected]>
Cc: Chris Wilson <[email protected]>
Cc: Paulo Zanoni <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: [email protected]
Cc: [email protected]
Reviewed-by: Ville Syrjälä <[email protected]>
---
arch/x86/kernel/early-quirks.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index ef0f4190f290..f5083d82b67b 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -425,12 +425,12 @@ static resource_size_t __init chv_stolen_size(int num, int slot, int func)
* 0x11 to 0x16: 4MB increments starting at 8MB
* 0x17 to 0x1d: 4MB increments start at 36MB
*/
- if (gms < 0x11)
- return gms * MB(32);
- else if (gms < 0x17)
+ if (gms >= 0x17)
+ return (gms - 0x17) * MB(4) + MB(36);
+ else if (gms >= 0x11)
return (gms - 0x11) * MB(4) + MB(8);
else
- return (gms - 0x17) * MB(4) + MB(36);
+ return gms * MB(32);
}

static resource_size_t __init gen9_stolen_size(int num, int slot, int func)
@@ -443,10 +443,10 @@ static resource_size_t __init gen9_stolen_size(int num, int slot, int func)

/* 0x0 to 0xef: 32MB increments starting at 0MB */
/* 0xf0 to 0xfe: 4MB increments starting at 4MB */
- if (gms < 0xf0)
- return gms * MB(32);
- else
+ if (gms >= 0xf0)
return (gms - 0xf0) * MB(4) + MB(4);
+ else
+ return gms * MB(32);
}

struct intel_early_ops {
--
2.14.3


2017-12-08 23:05:19

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [PATCH 3/9] x86/early-quirks: reverse the if ladders

On Thu, 7 Dec 2017, Matthew Auld wrote:

> Makes things a little easier to follow.

I disagree. The comment explains gms (what ever that is) in ascending order
and the code has that implemented the same way. Now you change the code to
descending order.

How is that easier to follow? Not at all. That's just crap.

Thanks,

tglx

> * 0x11 to 0x16: 4MB increments starting at 8MB
> * 0x17 to 0x1d: 4MB increments start at 36MB
> */
> - if (gms < 0x11)
> - return gms * MB(32);
> - else if (gms < 0x17)
> + if (gms >= 0x17)
> + return (gms - 0x17) * MB(4) + MB(36);
> + else if (gms >= 0x11)
> return (gms - 0x11) * MB(4) + MB(8);
> else
> - return (gms - 0x17) * MB(4) + MB(36);
> + return gms * MB(32);
> }
>
> static resource_size_t __init gen9_stolen_size(int num, int slot, int func)
> @@ -443,10 +443,10 @@ static resource_size_t __init gen9_stolen_size(int num, int slot, int func)
>
> /* 0x0 to 0xef: 32MB increments starting at 0MB */
> /* 0xf0 to 0xfe: 4MB increments starting at 4MB */
> - if (gms < 0xf0)
> - return gms * MB(32);
> - else
> + if (gms >= 0xf0)
> return (gms - 0xf0) * MB(4) + MB(4);
> + else
> + return gms * MB(32);
> }
>
> struct intel_early_ops {
> --
> 2.14.3
>
>