From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.3400.1649406237059714623 for ; Fri, 08 Apr 2022 01:23:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UOqawv3d; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649406236; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cCAKqKCHteQUj0RegdAbWbuNtv7jHpg1qsvxcxHrd24=; b=UOqawv3d+PiFdmqs5sQTX8PaXNBu45n0+A6FvsmLpejJE9BczaGfRc1kgSu4mkrHnCoBhO Czo41lURVSYvuUdxyIgBGq3WiBzbWC+ayvSR+/q9Z5UOb9O0/obPkLXmY5sPN/8S7A0FPQ XyxpBJkcdfspeFB8gEAb69UkIReoakk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-367-aja8F9ToMSC0ERQ_0Lz2GQ-1; Fri, 08 Apr 2022 04:23:50 -0400 X-MC-Unique: aja8F9ToMSC0ERQ_0Lz2GQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CA80286B8A3; Fri, 8 Apr 2022 08:23:49 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6CFFC2166BA2; Fri, 8 Apr 2022 08:23:38 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D23F91800989; Fri, 8 Apr 2022 10:23:33 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jordan Justen , Gerd Hoffmann , Jiewen Yao , Pawel Polawski , Oliver Steffen , Ard Biesheuvel Subject: [PATCH v3 4/6] OvmfPkg/VirtioGpuDxe: use GopQueryMode in GopSetMode Date: Fri, 8 Apr 2022 10:23:31 +0200 Message-Id: <20220408082333.3023758-5-kraxel@redhat.com> In-Reply-To: <20220408082333.3023758-1-kraxel@redhat.com> References: <20220408082333.3023758-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Call GopQueryMode() in GopSetMode(), use the ModeInfo returned when setting the mode. This is needed to properly handle modes which are not on the static mGopResolutions list. Signed-off-by: Gerd Hoffmann --- OvmfPkg/VirtioGpuDxe/Gop.c | 60 ++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c index 2c15d542e3b1..337a7e19bffa 100644 --- a/OvmfPkg/VirtioGpuDxe/Gop.c +++ b/OvmfPkg/VirtioGpuDxe/Gop.c @@ -234,19 +234,22 @@ GopSetMode ( IN UINT32 ModeNumber ) { - VGPU_GOP *VgpuGop; - UINT32 NewResourceId; - UINTN NewNumberOfBytes; - UINTN NewNumberOfPages; - VOID *NewBackingStore; - EFI_PHYSICAL_ADDRESS NewBackingStoreDeviceAddress; - VOID *NewBackingStoreMap; + VGPU_GOP *VgpuGop; + UINT32 NewResourceId; + UINTN NewNumberOfBytes; + UINTN NewNumberOfPages; + VOID *NewBackingStore; + EFI_PHYSICAL_ADDRESS NewBackingStoreDeviceAddress; + VOID *NewBackingStoreMap; + UINTN SizeOfInfo; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GopModeInfo; EFI_STATUS Status; EFI_STATUS Status2; - if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) { - return EFI_UNSUPPORTED; + Status = GopQueryMode (This, ModeNumber, &SizeOfInfo, &GopModeInfo); + if (Status != EFI_SUCCESS) { + return Status; } VgpuGop = VGPU_GOP_FROM_GOP (This); @@ -292,8 +295,8 @@ GopSetMode ( VgpuGop->ParentBus, // VgpuDev NewResourceId, // ResourceId VirtioGpuFormatB8G8R8X8Unorm, // Format - mGopResolutions[ModeNumber].Width, // Width - mGopResolutions[ModeNumber].Height // Height + GopModeInfo->HorizontalResolution, // Width + GopModeInfo->VerticalResolution // Height ); if (EFI_ERROR (Status)) { return Status; @@ -303,8 +306,8 @@ GopSetMode ( // Allocate, zero and map guest backing store, for bus master common buffer // operation. // - NewNumberOfBytes = mGopResolutions[ModeNumber].Width * - mGopResolutions[ModeNumber].Height * sizeof (UINT32); + NewNumberOfBytes = GopModeInfo->HorizontalResolution * + GopModeInfo->VerticalResolution * sizeof (UINT32); NewNumberOfPages = EFI_SIZE_TO_PAGES (NewNumberOfBytes); Status = VirtioGpuAllocateZeroAndMapBackingStore ( VgpuGop->ParentBus, // VgpuDev @@ -337,8 +340,8 @@ GopSetMode ( VgpuGop->ParentBus, // VgpuDev 0, // X 0, // Y - mGopResolutions[ModeNumber].Width, // Width - mGopResolutions[ModeNumber].Height, // Height + GopModeInfo->HorizontalResolution, // Width + GopModeInfo->VerticalResolution, // Height 0, // ScanoutId NewResourceId // ResourceId ); @@ -356,8 +359,8 @@ GopSetMode ( VgpuGop->ParentBus, // VgpuDev 0, // X 0, // Y - mGopResolutions[ModeNumber].Width, // Width - mGopResolutions[ModeNumber].Height, // Height + GopModeInfo->HorizontalResolution, // Width + GopModeInfo->VerticalResolution, // Height NewResourceId // ResourceId ); if (EFI_ERROR (Status)) { @@ -367,13 +370,13 @@ GopSetMode ( // therefore non-recoverable. // Status2 = VirtioGpuSetScanout ( - VgpuGop->ParentBus, // VgpuDev - 0, // X - 0, // Y - mGopResolutions[This->Mode->Mode].Width, // Width - mGopResolutions[This->Mode->Mode].Height, // Height - 0, // ScanoutId - VgpuGop->ResourceId // ResourceId + VgpuGop->ParentBus, // VgpuDev + 0, // X + 0, // Y + VgpuGop->GopModeInfo.HorizontalResolution, // Width + VgpuGop->GopModeInfo.VerticalResolution, // Height + 0, // ScanoutId + VgpuGop->ResourceId // ResourceId ); ASSERT_EFI_ERROR (Status2); if (EFI_ERROR (Status2)) { @@ -406,11 +409,9 @@ GopSetMode ( // // Populate Mode and ModeInfo (mutable fields only). // - VgpuGop->GopMode.Mode = ModeNumber; - VgpuGop->GopModeInfo.HorizontalResolution = - mGopResolutions[ModeNumber].Width; - VgpuGop->GopModeInfo.VerticalResolution = mGopResolutions[ModeNumber].Height; - VgpuGop->GopModeInfo.PixelsPerScanLine = mGopResolutions[ModeNumber].Width; + VgpuGop->GopMode.Mode = ModeNumber; + VgpuGop->GopModeInfo = *GopModeInfo; + FreePool (GopModeInfo); return EFI_SUCCESS; DetachBackingStore: @@ -435,6 +436,7 @@ GopSetMode ( CpuDeadLoop (); } + FreePool (GopModeInfo); return Status; } -- 2.35.1