On Mon, Sep 15, 2025 at 12:13:56PM +0300, Ilpo Järvinen wrote:
> Use pci_rebar_get_max_size() from PCI core in resize_vram_bar() to
> simplify code.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvi...@linux.intel.com>
> Acked-by: Christian König <christian.koe...@amd.com>
> ---
>  drivers/gpu/drm/xe/xe_vram.c | 15 +++++++--------


Acked-by: Rodrigo Vivi <rodrigo.v...@intel.com>

to get this patch merged through any other tree

>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_vram.c b/drivers/gpu/drm/xe/xe_vram.c
> index d4fbd7f74255..ca02744fb369 100644
> --- a/drivers/gpu/drm/xe/xe_vram.c
> +++ b/drivers/gpu/drm/xe/xe_vram.c
> @@ -54,16 +54,11 @@ static void resize_vram_bar(struct xe_device *xe)
>       resource_size_t current_size;
>       resource_size_t rebar_size;
>       struct resource *root_res;
> -     u32 bar_size_mask;
> +     int max_size, i;
>       u32 pci_cmd;
> -     int i;
>  
>       /* gather some relevant info */
>       current_size = pci_resource_len(pdev, LMEM_BAR);
> -     bar_size_mask = pci_rebar_get_possible_sizes(pdev, LMEM_BAR);
> -
> -     if (!bar_size_mask)
> -             return;
>  
>       if (force_vram_bar_size < 0)
>               return;
> @@ -77,7 +72,8 @@ static void resize_vram_bar(struct xe_device *xe)
>                       drm_info(&xe->drm,
>                                "Requested size: %lluMiB is not supported by 
> rebar sizes: 0x%x. Leaving default: %lluMiB\n",
>                                (u64)pci_rebar_size_to_bytes(rebar_size) >> 20,
> -                              bar_size_mask, (u64)current_size >> 20);
> +                              pci_rebar_get_possible_sizes(pdev, LMEM_BAR),
> +                              (u64)current_size >> 20);
>                       return;
>               }
>  
> @@ -85,7 +81,10 @@ static void resize_vram_bar(struct xe_device *xe)
>               if (rebar_size == current_size)
>                       return;
>       } else {
> -             rebar_size = pci_rebar_size_to_bytes(__fls(bar_size_mask));
> +             max_size = pci_rebar_get_max_size(pdev, LMEM_BAR);
> +             if (max_size < 0)
> +                     return;
> +             rebar_size = pci_rebar_size_to_bytes(max_size);
>  
>               /* only resize if larger than current */
>               if (rebar_size <= current_size)
> -- 
> 2.39.5
> 

Reply via email to