From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by mx.groups.io with SMTP id smtpd.web10.1087.1685143068705126225 for ; Fri, 26 May 2023 16:17:48 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ventanamicro.com header.s=google header.b=eOyDAw+Y; spf=pass (domain: ventanamicro.com, ip: 209.85.210.173, mailfrom: tphan@ventanamicro.com) Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-64d604cc0aaso1238696b3a.2 for ; Fri, 26 May 2023 16:17:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1685143068; x=1687735068; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GhZExCzcnucD5afmNyPIaHnXU5Ja5xMc/IQwzTVnHc0=; b=eOyDAw+Y0neBedqeJbPUvDDCTMXPZ5Afp8it5qjdhQr7ckRyxyQVk6WELoH4U0yw2w zzzLeqiDDXpWDA6EWTOPSnKGkR+AWc1WbNR/bwI1nOLSJgV6oDJBlcTdpDenTVTaJCn+ QJr7fcWrua9f2UrGLcdNIT94nEGnkRNRUF3XMlg7vfBrlowBUFfS3rhMVyBBdd5nskmT 7FxnV0+k1oWrUIEWWiyWAYwjGtxSSopHlcVUEQFaegFAk+JbKO3sHAmgTrlS/KVh+PeP Aknsu2o+Ba90WItw1x5jRh4ZTIO3qqugAh8G5V643+/fvSOkhx7f+sRTmXUN10kA+RuX C0ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685143068; x=1687735068; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GhZExCzcnucD5afmNyPIaHnXU5Ja5xMc/IQwzTVnHc0=; b=LxAW3G2sWrbzVJQiEtD2Z9helDcBImeSzwxzNh0ECqvEil+2Nagli8w8onuRbdPPeP sROAG8O6Q94RJO6fw7dIOWbWrXAcpzqb0V3Vaw2At1U5C/XYv9XBPMzGOTfMNVX7bBsk blMcGGdwN1Fw9UwqKB0p953tAFFxA7fCBNsN7G+aMg6hNu05tIh8G8zS051YQX/nMJss y/qY7Mr8IDKjdspkXjIMIms98Wn6257JZYfojE+FTVTaJz7fVcin/LyF0E+BDioD89au +J6gYclsvjpx4Ieswa8n89A+IwSYu4gfLBDPzIK1F5BaF5sLF+R72YaBl9fdh36effvt MgIA== X-Gm-Message-State: AC+VfDwVbsENciwvCrSjKeb+4FHywN8nyC1WM8BakLrOoAOrg0H8zwns PSBzdFHIkzFYlqFMLPpXiY7YmPxWDXaTHE3DPNM= X-Google-Smtp-Source: ACHHUZ75Za2GdfmwKFg31sIQ5oJqV0JX/Qg4Ms/F2pcbHaGPjICQzfcdaBN9bZxEQMbmjDc1Rnu4cQ== X-Received: by 2002:a05:6a20:8408:b0:10b:97c8:2e16 with SMTP id c8-20020a056a20840800b0010b97c82e16mr1432705pzd.29.1685143067407; Fri, 26 May 2023 16:17:47 -0700 (PDT) Return-Path: Received: from localhost.localdomain (c-174-50-177-95.hsd1.ca.comcast.net. [174.50.177.95]) by smtp.gmail.com with ESMTPSA id k3-20020aa792c3000000b005d22639b577sm3106308pfa.165.2023.05.26.16.17.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 16:17:47 -0700 (PDT) From: "Tuan Phan" To: devel@edk2.groups.io Cc: michael.d.kinney@intel.com, gaoliming@byosoft.com.cn, zhiguang.liu@intel.com, sunilvl@ventanamicro.com, git@danielschaefer.me, andrei.warkentin@intel.com, Tuan Phan Subject: [PATCH v3 6/7] OvmfPkg/VirtNorFlashDxe: Not add memory space if it exists Date: Fri, 26 May 2023 16:17:32 -0700 Message-Id: <20230526231733.6755-7-tphan@ventanamicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230526231733.6755-1-tphan@ventanamicro.com> References: <20230526231733.6755-1-tphan@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable The flash base address can be added to GCD before this driver run. So only add it if it has not been done. Signed-off-by: Tuan Phan Reviewed-by: Andrei Warkentin --- OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c | 25 +++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c b/OvmfPkg/VirtNorFla= shDxe/VirtNorFlashDxe.c index 6b9ef261335e..bbd1697a51dd 100644 --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c @@ -372,10 +372,11 @@ NorFlashFvbInitialize ( IN NOR_FLASH_INSTANCE *Instance=0D )=0D {=0D - EFI_STATUS Status;=0D - UINT32 FvbNumLba;=0D - EFI_BOOT_MODE BootMode;=0D - UINTN RuntimeMmioRegionSize;=0D + EFI_STATUS Status;=0D + UINT32 FvbNumLba;=0D + EFI_BOOT_MODE BootMode;=0D + UINTN RuntimeMmioRegionSize;=0D + EFI_GCD_MEMORY_SPACE_DESCRIPTOR Desc;=0D =0D DEBUG ((DEBUG_BLKIO, "NorFlashFvbInitialize\n"));=0D ASSERT ((Instance !=3D NULL));=0D @@ -390,13 +391,19 @@ NorFlashFvbInitialize ( // is written as the base of the flash region (ie: Instance->Devic= eBaseAddress)=0D RuntimeMmioRegionSize =3D (Instance->RegionBaseAddress - Instance->Devic= eBaseAddress) + Instance->Size;=0D =0D - Status =3D gDS->AddMemorySpace (=0D - EfiGcdMemoryTypeMemoryMappedIo,=0D + Status =3D gDS->GetMemorySpaceDescriptor (=0D Instance->DeviceBaseAddress,=0D - RuntimeMmioRegionSize,=0D - EFI_MEMORY_UC | EFI_MEMORY_RUNTIME=0D + &Desc=0D );=0D - ASSERT_EFI_ERROR (Status);=0D + if (Status =3D=3D EFI_NOT_FOUND) {=0D + Status =3D gDS->AddMemorySpace (=0D + EfiGcdMemoryTypeMemoryMappedIo,=0D + Instance->DeviceBaseAddress,=0D + RuntimeMmioRegionSize,=0D + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME=0D + );=0D + ASSERT_EFI_ERROR (Status);=0D + }=0D =0D Status =3D gDS->SetMemorySpaceAttributes (=0D Instance->DeviceBaseAddress,=0D --=20 2.25.1