Quoting Joonas Lahtinen (2017-11-24 07:30:17)
> In preparation for upcoming SKUs, allow more freedom in placement
> of the Intel graphics stolen memory by BIOS to full 64bit range.
> 
> Signed-off-by: Joonas Lahtinen <[email protected]>
> Cc: Matthew Auld <[email protected]>
> Cc: Chris Wilson <[email protected]>
> Cc: Paulo Zanoni <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: H. Peter Anvin <[email protected]>
> Cc: [email protected]
> ---
>  arch/x86/kernel/early-quirks.c | 75 
> +++++++++++++++++++++---------------------
>  1 file changed, 38 insertions(+), 37 deletions(-)
> 
> diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
> index 1e82f787c160..7b775f9afa16 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 << 16) + i845_tseg_size();

Uh oh, this is a u16 << 16, that's not going to work. (We have the same
bug in i915.ko, so you do get a told you so on the merits of bug
duplication.)

All the other cases are u16 * UL, which should be promoted to UL prior
to the calculation and so be safe.

Other than it looks fine,
Reviewed-by: Chris Wilson <[email protected]>
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to