[edk2] [PATCH v2] OvmfPkg/QemuVideoDxe: round up FrameBufferSize to full page

Gerd Hoffmann posted 1 patch 5 years, 12 months ago
Failed in applying to current master (apply log)
OvmfPkg/QemuVideoDxe/Gop.c | 2 ++
1 file changed, 2 insertions(+)
[edk2] [PATCH v2] OvmfPkg/QemuVideoDxe: round up FrameBufferSize to full page
Posted by Gerd Hoffmann 5 years, 12 months ago
Guests do the same, because the framebuffer is mapped somewhere, which
obviously works with page granularity only.

When not rounding up to full page size we get messages like this one
(linux kernel):

    efifb: framebuffer at 0x80000000, using 1876k, total 1875k
                                            ^^^^^        ^^^^^
Also sysfb is confused and throws an error:

    sysfb: VRAM smaller than advertised

Cc: Phil Dennis-Jordan <phil@philjordan.eu>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 OvmfPkg/QemuVideoDxe/Gop.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c
index d51efc2a83..88142bf376 100644
--- a/OvmfPkg/QemuVideoDxe/Gop.c
+++ b/OvmfPkg/QemuVideoDxe/Gop.c
@@ -69,6 +69,7 @@ QemuVideoCompleteModeData (
   Mode->FrameBufferBase = FrameBufDesc->AddrRangeMin;
   Mode->FrameBufferSize = Info->HorizontalResolution * Info->VerticalResolution;
   Mode->FrameBufferSize = Mode->FrameBufferSize * ((ModeData->ColorDepth + 7) / 8);
+  Mode->FrameBufferSize = EFI_PAGES_TO_SIZE(EFI_SIZE_TO_PAGES(Mode->FrameBufferSize));
   DEBUG ((EFI_D_INFO, "FrameBufferBase: 0x%Lx, FrameBufferSize: 0x%Lx\n",
     Mode->FrameBufferBase, (UINT64)Mode->FrameBufferSize));
 
@@ -107,6 +108,7 @@ QemuVideoVmwareSvgaCompleteModeData (
 
   Mode->FrameBufferBase = FrameBufDesc->AddrRangeMin + FbOffset;
   Mode->FrameBufferSize = BytesPerLine * Info->VerticalResolution;
+  Mode->FrameBufferSize = EFI_PAGES_TO_SIZE(EFI_SIZE_TO_PAGES(Mode->FrameBufferSize));
 
   FreePool (FrameBufDesc);
   return Status;
-- 
2.9.3

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH v2] OvmfPkg/QemuVideoDxe: round up FrameBufferSize to full page
Posted by Laszlo Ersek 5 years, 12 months ago
On 04/26/18 09:02, Gerd Hoffmann wrote:
> Guests do the same, because the framebuffer is mapped somewhere, which
> obviously works with page granularity only.
> 
> When not rounding up to full page size we get messages like this one
> (linux kernel):
> 
>     efifb: framebuffer at 0x80000000, using 1876k, total 1875k
>                                             ^^^^^        ^^^^^
> Also sysfb is confused and throws an error:
> 
>     sysfb: VRAM smaller than advertised
> 
> Cc: Phil Dennis-Jordan <phil@philjordan.eu>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  OvmfPkg/QemuVideoDxe/Gop.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c
> index d51efc2a83..88142bf376 100644
> --- a/OvmfPkg/QemuVideoDxe/Gop.c
> +++ b/OvmfPkg/QemuVideoDxe/Gop.c
> @@ -69,6 +69,7 @@ QemuVideoCompleteModeData (
>    Mode->FrameBufferBase = FrameBufDesc->AddrRangeMin;
>    Mode->FrameBufferSize = Info->HorizontalResolution * Info->VerticalResolution;
>    Mode->FrameBufferSize = Mode->FrameBufferSize * ((ModeData->ColorDepth + 7) / 8);
> +  Mode->FrameBufferSize = EFI_PAGES_TO_SIZE(EFI_SIZE_TO_PAGES(Mode->FrameBufferSize));
>    DEBUG ((EFI_D_INFO, "FrameBufferBase: 0x%Lx, FrameBufferSize: 0x%Lx\n",
>      Mode->FrameBufferBase, (UINT64)Mode->FrameBufferSize));
>  
> @@ -107,6 +108,7 @@ QemuVideoVmwareSvgaCompleteModeData (
>  
>    Mode->FrameBufferBase = FrameBufDesc->AddrRangeMin + FbOffset;
>    Mode->FrameBufferSize = BytesPerLine * Info->VerticalResolution;
> +  Mode->FrameBufferSize = EFI_PAGES_TO_SIZE(EFI_SIZE_TO_PAGES(Mode->FrameBufferSize));
>  
>    FreePool (FrameBufDesc);
>    return Status;
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
[lersek@redhat.com: fix coding style]

Commit dd7760470fce.

Thanks!
Laszlo
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel