Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1522633

Re: [PATCH 2/2] x86/sysfb: fix lfb_size calculation

From Tom Gundersen <teg@jklm.no>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] x86/sysfb: fix lfb_size calculation
Date 2016-11-15 13:20 +0100
Message-ID <sDKSt-4PB-19@gated-at.bofh.it> (permalink)
References <sDKIN-4KT-5@gated-at.bofh.it> <sDKIO-4KT-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Nov 15, 2016 at 1:01 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
> The screen_info.lfb_size field is shifted by 16 bits *only* in case of
> VBE. This has historical reasons since VBE advertised it similarly.
> However, in case of EFI framebuffers, the size is no longer shifted. Fix
> the x86 simple-framebuffer setup code to use the correct size in the
> non-VBE case.
>
> While at it, avoid variable abbreviations and rename 'len' to 'length',
> and use the correct types matching the screen_info definition.
>
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>

Reviewed-by: Tom Gundersen <teg@jklm.no>

> ---
>  arch/x86/kernel/sysfb_simplefb.c | 25 +++++++++++++++++--------
>  1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/arch/x86/kernel/sysfb_simplefb.c b/arch/x86/kernel/sysfb_simplefb.c
> index 35b8641..85195d4 100644
> --- a/arch/x86/kernel/sysfb_simplefb.c
> +++ b/arch/x86/kernel/sysfb_simplefb.c
> @@ -66,8 +66,8 @@ __init int create_simplefb(const struct screen_info *si,
>  {
>         struct platform_device *pd;
>         struct resource res;
> -       unsigned long len;
> -       u64 base;
> +       u64 base, size;
> +       u32 length;
>
>         /*
>          * If the 64BIT_BASE capability is set, ext_lfb_base will contain the
> @@ -82,11 +82,20 @@ __init int create_simplefb(const struct screen_info *si,
>                 return -EINVAL;
>         }
>
> -       /* don't use lfb_size as it may contain the whole VMEM instead of only
> -        * the part that is occupied by the framebuffer */
> -       len = mode->height * mode->stride;
> -       len = PAGE_ALIGN(len);
> -       if (len > (u64)si->lfb_size << 16) {
> +       /*
> +        * Don't use lfb_size as IORESOURCE size, since it may contain the
> +        * entire VMEM, and thus require huge mappings. Use just the part we
> +        * need, that is, the part where the framebuffer is located. But verify
> +        * that it does not exceed the advertised VMEM.
> +        * Note that in case of VBE, the lfb_size is shifted by 16 bits for
> +        * historical reasons.
> +        */
> +       size = si->lfb_size;
> +       if (si->orig_video_isVGA == VIDEO_TYPE_VLFB)
> +               size <<= 16;
> +       length = mode->height * mode->stride;
> +       length = PAGE_ALIGN(length);
> +       if (length > size) {
>                 printk(KERN_WARNING "sysfb: VRAM smaller than advertised\n");
>                 return -EINVAL;
>         }
> @@ -96,7 +105,7 @@ __init int create_simplefb(const struct screen_info *si,
>         res.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
>         res.name = simplefb_resname;
>         res.start = base;
> -       res.end = res.start + len - 1;
> +       res.end = res.start + length - 1;
>         if (res.end <= res.start)
>                 return -EINVAL;
>
> --
> 2.10.2
>

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] x86 Simplefb Fixes David Herrmann <dh.herrmann@gmail.com> - 2016-11-15 13:10 +0100
  [PATCH 2/2] x86/sysfb: fix lfb_size calculation David Herrmann <dh.herrmann@gmail.com> - 2016-11-15 13:10 +0100
    Re: [PATCH 2/2] x86/sysfb: fix lfb_size calculation Tom Gundersen <teg@jklm.no> - 2016-11-15 13:20 +0100
    [tip:x86/urgent] x86/sysfb: Fix lfb_size calculation tip-bot for David Herrmann <tipbot@zytor.com> - 2016-11-16 13:20 +0100
  [PATCH 1/2] x86/sysfb: add support for 64bit EFI lfb_base David Herrmann <dh.herrmann@gmail.com> - 2016-11-15 13:10 +0100
    [tip:x86/urgent] x86/sysfb: Add support for 64bit EFI lfb_base tip-bot for David Herrmann <tipbot@zytor.com> - 2016-11-16 13:10 +0100

csiph-web