linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/9] x86/early-quirks: Extend Intel graphics stolen memory placement to 64bit
       [not found] <20171207122839.29925-1-matthew.auld@intel.com>
@ 2017-12-07 12:28 ` Matthew Auld
  2017-12-08 22:58   ` Thomas Gleixner
  2017-12-07 12:28 ` [PATCH 2/9] x86/early-quirks: replace the magical increment start values Matthew Auld
  2017-12-07 12:28 ` [PATCH 3/9] x86/early-quirks: reverse the if ladders Matthew Auld
  2 siblings, 1 reply; 7+ messages in thread
From: Matthew Auld @ 2017-12-07 12:28 UTC (permalink / raw)
  To: intel-gfx
  Cc: Joonas Lahtinen, Ville Syrjälä,
	Chris Wilson, Paulo Zanoni, Thomas Gleixner, Ingo Molnar,
	H . Peter Anvin, x86, linux-kernel

From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

To give upcoming SKU BIOSes more flexibility in placing the Intel
graphics stolen memory, make all variables storing the placement or size
compatible with full 64 bit range. Also by exporting the stolen region
as a resource, we can then nuke the duplicated stolen discovery in i915.

v2: export the stolen region as a resource
    fix u16 << 16 (Chris)
v3: actually fix u16 << 16

Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Cc: linux-kernel@vger.kernel.org
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 arch/x86/kernel/early-quirks.c | 86 +++++++++++++++++++++++-------------------
 include/drm/i915_drm.h         |  3 ++
 2 files changed, 50 insertions(+), 39 deletions(-)

diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index 1e82f787c160..b5855b00a8cc 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -243,7 +243,7 @@ static void __init intel_remapping_check(int num, int slot, int func)
 #define KB(x)	((x) * 1024UL)
 #define MB(x)	(KB (KB (x)))
 
-static size_t __init i830_tseg_size(void)
+static resource_size_t __init i830_tseg_size(void)
 {
 	u8 esmramc = read_pci_config_byte(0, 0, 0, I830_ESMRAMC);
 
@@ -256,7 +256,7 @@ static size_t __init i830_tseg_size(void)
 		return KB(512);
 }
 
-static size_t __init i845_tseg_size(void)
+static resource_size_t __init i845_tseg_size(void)
 {
 	u8 esmramc = read_pci_config_byte(0, 0, 0, I845_ESMRAMC);
 	u8 tseg_size = esmramc & I845_TSEG_SIZE_MASK;
@@ -273,7 +273,7 @@ static size_t __init i845_tseg_size(void)
 	return 0;
 }
 
-static size_t __init i85x_tseg_size(void)
+static resource_size_t __init i85x_tseg_size(void)
 {
 	u8 esmramc = read_pci_config_byte(0, 0, 0, I85X_ESMRAMC);
 
@@ -283,12 +283,12 @@ static size_t __init i85x_tseg_size(void)
 	return MB(1);
 }
 
-static size_t __init i830_mem_size(void)
+static resource_size_t __init i830_mem_size(void)
 {
 	return read_pci_config_byte(0, 0, 0, I830_DRB3) * MB(32);
 }
 
-static size_t __init i85x_mem_size(void)
+static resource_size_t __init i85x_mem_size(void)
 {
 	return read_pci_config_byte(0, 0, 1, I85X_DRB3) * MB(32);
 }
@@ -297,36 +297,36 @@ static size_t __init i85x_mem_size(void)
  * On 830/845/85x the stolen memory base isn't available in any
  * register. We need to calculate it as TOM-TSEG_SIZE-stolen_size.
  */
-static phys_addr_t __init i830_stolen_base(int num, int slot, int func,
-					   size_t stolen_size)
+static resource_size_t __init i830_stolen_base(int num, int slot, int func,
+					       resource_size_t stolen_size)
 {
-	return (phys_addr_t)i830_mem_size() - i830_tseg_size() - stolen_size;
+	return i830_mem_size() - i830_tseg_size() - stolen_size;
 }
 
-static phys_addr_t __init i845_stolen_base(int num, int slot, int func,
-					   size_t stolen_size)
+static resource_size_t __init i845_stolen_base(int num, int slot, int func,
+					       resource_size_t stolen_size)
 {
-	return (phys_addr_t)i830_mem_size() - i845_tseg_size() - stolen_size;
+	return i830_mem_size() - i845_tseg_size() - stolen_size;
 }
 
-static phys_addr_t __init i85x_stolen_base(int num, int slot, int func,
-					   size_t stolen_size)
+static resource_size_t __init i85x_stolen_base(int num, int slot, int func,
+					       resource_size_t stolen_size)
 {
-	return (phys_addr_t)i85x_mem_size() - i85x_tseg_size() - stolen_size;
+	return i85x_mem_size() - i85x_tseg_size() - stolen_size;
 }
 
-static phys_addr_t __init i865_stolen_base(int num, int slot, int func,
-					   size_t stolen_size)
+static resource_size_t __init i865_stolen_base(int num, int slot, int func,
+					       resource_size_t stolen_size)
 {
 	u16 toud = 0;
 
 	toud = read_pci_config_16(0, 0, 0, I865_TOUD);
 
-	return (phys_addr_t)(toud << 16) + i845_tseg_size();
+	return toud * KB(64) + i845_tseg_size();
 }
 
-static phys_addr_t __init gen3_stolen_base(int num, int slot, int func,
-					   size_t stolen_size)
+static resource_size_t __init gen3_stolen_base(int num, int slot, int func,
+					       resource_size_t stolen_size)
 {
 	u32 bsm;
 
@@ -337,10 +337,10 @@ static phys_addr_t __init gen3_stolen_base(int num, int slot, int func,
 	 */
 	bsm = read_pci_config(num, slot, func, INTEL_BSM);
 
-	return (phys_addr_t)bsm & INTEL_BSM_MASK;
+	return bsm & INTEL_BSM_MASK;
 }
 
-static size_t __init i830_stolen_size(int num, int slot, int func)
+static resource_size_t __init i830_stolen_size(int num, int slot, int func)
 {
 	u16 gmch_ctrl;
 	u16 gms;
@@ -361,7 +361,7 @@ static size_t __init i830_stolen_size(int num, int slot, int func)
 	return 0;
 }
 
-static size_t __init gen3_stolen_size(int num, int slot, int func)
+static resource_size_t __init gen3_stolen_size(int num, int slot, int func)
 {
 	u16 gmch_ctrl;
 	u16 gms;
@@ -390,7 +390,7 @@ static size_t __init gen3_stolen_size(int num, int slot, int func)
 	return 0;
 }
 
-static size_t __init gen6_stolen_size(int num, int slot, int func)
+static resource_size_t __init gen6_stolen_size(int num, int slot, int func)
 {
 	u16 gmch_ctrl;
 	u16 gms;
@@ -398,10 +398,10 @@ static size_t __init gen6_stolen_size(int num, int slot, int func)
 	gmch_ctrl = read_pci_config_16(num, slot, func, SNB_GMCH_CTRL);
 	gms = (gmch_ctrl >> SNB_GMCH_GMS_SHIFT) & SNB_GMCH_GMS_MASK;
 
-	return (size_t)gms * MB(32);
+	return gms * MB(32);
 }
 
-static size_t __init gen8_stolen_size(int num, int slot, int func)
+static resource_size_t __init gen8_stolen_size(int num, int slot, int func)
 {
 	u16 gmch_ctrl;
 	u16 gms;
@@ -409,10 +409,10 @@ static size_t __init gen8_stolen_size(int num, int slot, int func)
 	gmch_ctrl = read_pci_config_16(num, slot, func, SNB_GMCH_CTRL);
 	gms = (gmch_ctrl >> BDW_GMCH_GMS_SHIFT) & BDW_GMCH_GMS_MASK;
 
-	return (size_t)gms * MB(32);
+	return gms * MB(32);
 }
 
-static size_t __init chv_stolen_size(int num, int slot, int func)
+static resource_size_t __init chv_stolen_size(int num, int slot, int func)
 {
 	u16 gmch_ctrl;
 	u16 gms;
@@ -426,14 +426,14 @@ static size_t __init chv_stolen_size(int num, int slot, int func)
 	 * 0x17 to 0x1d: 4MB increments start at 36MB
 	 */
 	if (gms < 0x11)
-		return (size_t)gms * MB(32);
+		return gms * MB(32);
 	else if (gms < 0x17)
-		return (size_t)(gms - 0x11 + 2) * MB(4);
+		return (gms - 0x11 + 2) * MB(4);
 	else
-		return (size_t)(gms - 0x17 + 9) * MB(4);
+		return (gms - 0x17 + 9) * MB(4);
 }
 
-static size_t __init gen9_stolen_size(int num, int slot, int func)
+static resource_size_t __init gen9_stolen_size(int num, int slot, int func)
 {
 	u16 gmch_ctrl;
 	u16 gms;
@@ -444,14 +444,15 @@ static 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 (size_t)gms * MB(32);
+		return gms * MB(32);
 	else
-		return (size_t)(gms - 0xf0 + 1) * MB(4);
+		return (gms - 0xf0 + 1) * MB(4);
 }
 
 struct intel_early_ops {
-	size_t (*stolen_size)(int num, int slot, int func);
-	phys_addr_t (*stolen_base)(int num, int slot, int func, size_t size);
+	resource_size_t (*stolen_size)(int num, int slot, int func);
+	resource_size_t (*stolen_base)(int num, int slot, int func,
+				       resource_size_t size);
 };
 
 static const struct intel_early_ops i830_early_ops __initconst = {
@@ -531,12 +532,15 @@ static const struct pci_device_id intel_early_ids[] __initconst = {
 	INTEL_CNL_IDS(&gen9_early_ops),
 };
 
+struct resource intel_graphics_stolen_res = DEFINE_RES_MEM(0, 0);
+EXPORT_SYMBOL(intel_graphics_stolen_res);
+
 static void __init
 intel_graphics_stolen(int num, int slot, int func,
 		      const struct intel_early_ops *early_ops)
 {
-	phys_addr_t base, end;
-	size_t size;
+	resource_size_t base, size;
+	resource_size_t end;
 
 	size = early_ops->stolen_size(num, slot, func);
 	base = early_ops->stolen_base(num, slot, func, size);
@@ -545,8 +549,12 @@ intel_graphics_stolen(int num, int slot, int func,
 		return;
 
 	end = base + size - 1;
-	printk(KERN_INFO "Reserving Intel graphics memory at %pa-%pa\n",
-	       &base, &end);
+
+	intel_graphics_stolen_res.start = base;
+	intel_graphics_stolen_res.end = end;
+
+	printk(KERN_INFO "Reserving Intel graphics memory at %pR\n",
+	       &intel_graphics_stolen_res);
 
 	/* Mark this space as reserved */
 	e820__range_add(base, size, E820_TYPE_RESERVED);
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index 4e1b274e1164..c9e5a6621b95 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -36,6 +36,9 @@ extern bool i915_gpu_lower(void);
 extern bool i915_gpu_busy(void);
 extern bool i915_gpu_turbo_disable(void);
 
+/* Exported from arch/x86/kernel/early-quirks.c */
+extern struct resource intel_graphics_stolen_res;
+
 /*
  * The Bridge device's PCI config space has information about the
  * fb aperture size and the amount of pre-reserved memory.
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/9] x86/early-quirks: replace the magical increment start values
       [not found] <20171207122839.29925-1-matthew.auld@intel.com>
  2017-12-07 12:28 ` [PATCH 1/9] x86/early-quirks: Extend Intel graphics stolen memory placement to 64bit Matthew Auld
@ 2017-12-07 12:28 ` Matthew Auld
  2017-12-07 12:28 ` [PATCH 3/9] x86/early-quirks: reverse the if ladders Matthew Auld
  2 siblings, 0 replies; 7+ messages in thread
From: Matthew Auld @ 2017-12-07 12:28 UTC (permalink / raw)
  To: intel-gfx
  Cc: Joonas Lahtinen, Ville Syrjälä,
	Chris Wilson, Paulo Zanoni, Thomas Gleixner, Ingo Molnar,
	H . Peter Anvin, x86, linux-kernel

Replace the magical +2, +9 etc. with +MB, which is far easier to read.

Suggested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Cc: linux-kernel@vger.kernel.org
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 arch/x86/kernel/early-quirks.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index b5855b00a8cc..ef0f4190f290 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -428,9 +428,9 @@ static resource_size_t __init chv_stolen_size(int num, int slot, int func)
 	if (gms < 0x11)
 		return gms * MB(32);
 	else if (gms < 0x17)
-		return (gms - 0x11 + 2) * MB(4);
+		return (gms - 0x11) * MB(4) + MB(8);
 	else
-		return (gms - 0x17 + 9) * MB(4);
+		return (gms - 0x17) * MB(4) + MB(36);
 }
 
 static resource_size_t __init gen9_stolen_size(int num, int slot, int func)
@@ -446,7 +446,7 @@ static resource_size_t __init gen9_stolen_size(int num, int slot, int func)
 	if (gms < 0xf0)
 		return gms * MB(32);
 	else
-		return (gms - 0xf0 + 1) * MB(4);
+		return (gms - 0xf0) * MB(4) + MB(4);
 }
 
 struct intel_early_ops {
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/9] x86/early-quirks: reverse the if ladders
       [not found] <20171207122839.29925-1-matthew.auld@intel.com>
  2017-12-07 12:28 ` [PATCH 1/9] x86/early-quirks: Extend Intel graphics stolen memory placement to 64bit Matthew Auld
  2017-12-07 12:28 ` [PATCH 2/9] x86/early-quirks: replace the magical increment start values Matthew Auld
@ 2017-12-07 12:28 ` Matthew Auld
  2017-12-08 23:05   ` Thomas Gleixner
  2 siblings, 1 reply; 7+ messages in thread
From: Matthew Auld @ 2017-12-07 12:28 UTC (permalink / raw)
  To: intel-gfx
  Cc: Joonas Lahtinen, Ville Syrjälä,
	Chris Wilson, Paulo Zanoni, Thomas Gleixner, Ingo Molnar,
	H . Peter Anvin, x86, linux-kernel

Makes things a little easier to follow.

Suggested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Cc: linux-kernel@vger.kernel.org
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/9] x86/early-quirks: Extend Intel graphics stolen memory placement to 64bit
  2017-12-07 12:28 ` [PATCH 1/9] x86/early-quirks: Extend Intel graphics stolen memory placement to 64bit Matthew Auld
@ 2017-12-08 22:58   ` Thomas Gleixner
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Gleixner @ 2017-12-08 22:58 UTC (permalink / raw)
  To: Matthew Auld
  Cc: intel-gfx, Joonas Lahtinen, Ville Syrjälä,
	Chris Wilson, Paulo Zanoni, Ingo Molnar, H . Peter Anvin, x86,
	linux-kernel

Matthew,

On Thu, 7 Dec 2017, Matthew Auld wrote:

Can you please add a version number to your patches? Having the same
subject line five times is just annoying.

> From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
 
> To give upcoming SKU BIOSes more flexibility in placing the Intel
> graphics stolen memory, make all variables storing the placement or size
> compatible with full 64 bit range. Also by exporting the stolen region
> as a resource, we can then nuke the duplicated stolen discovery in i915.
> 
> v2: export the stolen region as a resource
>     fix u16 << 16 (Chris)
> v3: actually fix u16 << 16

And please move the version thing below the --- separator so it can be
discarded by tools. It's not part of the changelog.

> +struct resource intel_graphics_stolen_res = DEFINE_RES_MEM(0, 0);

This is updated in __init so the variable should be marked __ro_after_init.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/9] x86/early-quirks: reverse the if ladders
  2017-12-07 12:28 ` [PATCH 3/9] x86/early-quirks: reverse the if ladders Matthew Auld
@ 2017-12-08 23:05   ` Thomas Gleixner
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Gleixner @ 2017-12-08 23:05 UTC (permalink / raw)
  To: Matthew Auld
  Cc: intel-gfx, Joonas Lahtinen, Ville Syrjälä,
	Chris Wilson, Paulo Zanoni, Ingo Molnar, H . Peter Anvin, x86,
	linux-kernel

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
> 
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/9] x86/early-quirks: reverse the if ladders
  2017-12-05 21:02 ` Matthew Auld
@ 2017-12-05 21:08   ` Ville Syrjälä
  0 siblings, 0 replies; 7+ messages in thread
From: Ville Syrjälä @ 2017-12-05 21:08 UTC (permalink / raw)
  To: Matthew Auld
  Cc: intel-gfx, Joonas Lahtinen, Chris Wilson, Paulo Zanoni,
	Thomas Gleixner, Ingo Molnar, H . Peter Anvin, x86, linux-kernel

On Tue, Dec 05, 2017 at 09:02:43PM +0000, Matthew Auld wrote:
> Makes things a little easier to follow.
> 
> Suggested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: x86@kernel.org
> Cc: linux-kernel@vger.kernel.org

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> ---
>  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 b5b912f3dce8..ba6e96381bfc 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

-- 
Ville Syrjälä
Intel OTC

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/9] x86/early-quirks: reverse the if ladders
       [not found] <20171205210249.8875-1-matthew.auld@intel.com>
@ 2017-12-05 21:02 ` Matthew Auld
  2017-12-05 21:08   ` Ville Syrjälä
  0 siblings, 1 reply; 7+ messages in thread
From: Matthew Auld @ 2017-12-05 21:02 UTC (permalink / raw)
  To: intel-gfx
  Cc: Joonas Lahtinen, Ville Syrjälä,
	Chris Wilson, Paulo Zanoni, Thomas Gleixner, Ingo Molnar,
	H . Peter Anvin, x86, linux-kernel

Makes things a little easier to follow.

Suggested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Cc: linux-kernel@vger.kernel.org
---
 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 b5b912f3dce8..ba6e96381bfc 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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-12-08 23:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20171207122839.29925-1-matthew.auld@intel.com>
2017-12-07 12:28 ` [PATCH 1/9] x86/early-quirks: Extend Intel graphics stolen memory placement to 64bit Matthew Auld
2017-12-08 22:58   ` Thomas Gleixner
2017-12-07 12:28 ` [PATCH 2/9] x86/early-quirks: replace the magical increment start values Matthew Auld
2017-12-07 12:28 ` [PATCH 3/9] x86/early-quirks: reverse the if ladders Matthew Auld
2017-12-08 23:05   ` Thomas Gleixner
     [not found] <20171205210249.8875-1-matthew.auld@intel.com>
2017-12-05 21:02 ` Matthew Auld
2017-12-05 21:08   ` Ville Syrjälä

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).