[PATCH] drm/radeon: Fix VRAM size calculation for VRAM >= 4GB

Alex Deucher alexdeucher at gmail.com
Mon May 20 07:02:06 PDT 2013


On Sat, May 18, 2013 at 3:19 PM, Niels Ole Salscheider
<niels_ole at salscheider-online.de> wrote:
> Add ULL prefix to avoid overflow.
>
> Signed-off-by: Niels Ole Salscheider <niels_ole at salscheider-online.de>

Applied.  thanks!

Alex

> ---
>  drivers/gpu/drm/radeon/evergreen.c  | 4 ++--
>  drivers/gpu/drm/radeon/radeon_ttm.c | 2 +-
>  drivers/gpu/drm/radeon/si.c         | 4 ++--
>  3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
> index 105bafb..06c261b 100644
> --- a/drivers/gpu/drm/radeon/evergreen.c
> +++ b/drivers/gpu/drm/radeon/evergreen.c
> @@ -3405,8 +3405,8 @@ int evergreen_mc_init(struct radeon_device *rdev)
>                 rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE);
>         } else {
>                 /* size in MB on evergreen/cayman/tn */
> -               rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024;
> -               rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024;
> +               rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024ULL * 1024ULL;
> +               rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024ULL * 1024ULL;
>         }
>         rdev->mc.visible_vram_size = rdev->mc.aper_size;
>         r700_vram_gtt_location(rdev, &rdev->mc);
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index 93f760e..6c0ce89 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -726,7 +726,7 @@ int radeon_ttm_init(struct radeon_device *rdev)
>                 return r;
>         }
>         DRM_INFO("radeon: %uM of VRAM memory ready\n",
> -                (unsigned)rdev->mc.real_vram_size / (1024 * 1024));
> +                (unsigned) (rdev->mc.real_vram_size / (1024 * 1024)));
>         r = ttm_bo_init_mm(&rdev->mman.bdev, TTM_PL_TT,
>                                 rdev->mc.gtt_size >> PAGE_SHIFT);
>         if (r) {
> diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
> index f0b6c2f..113ed9f 100644
> --- a/drivers/gpu/drm/radeon/si.c
> +++ b/drivers/gpu/drm/radeon/si.c
> @@ -3397,8 +3397,8 @@ static int si_mc_init(struct radeon_device *rdev)
>         rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
>         rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
>         /* size in MB on si */
> -       rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024;
> -       rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024;
> +       rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024ULL * 1024ULL;
> +       rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024ULL * 1024ULL;
>         rdev->mc.visible_vram_size = rdev->mc.aper_size;
>         si_vram_gtt_location(rdev, &rdev->mc);
>         radeon_update_bandwidth_info(rdev);
> --
> 1.8.2.3
>
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


More information about the dri-devel mailing list