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.133.124]) by mx.groups.io with SMTP id smtpd.web12.10831.1664891256726628098 for ; Tue, 04 Oct 2022 06:47:36 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QKy9rdxk; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664891255; 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=c5CTp0KutmEg8w/FMMsUdkgM7srsItcfxx8wE7ydonk=; b=QKy9rdxkAd328xG2UEXMSDGhdcc1gtSozOmS7oOQ9MxkHxJBVBMgXfRCfd6gu7ALtO/0b7 XHZXvKTDhsWL6D9pgyvlfXJueIlqcfmW1a9IpIjG1hBNNpgusy6DiVCR/ktxeNWDsK8eHe 3MFiqAqzZ6OgSz1LlLkJlVaPEorVaSM= 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-606-flDFvIPJMw6AP8y2ihmamA-1; Tue, 04 Oct 2022 09:47:33 -0400 X-MC-Unique: flDFvIPJMw6AP8y2ihmamA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A79E38027FE; Tue, 4 Oct 2022 13:47:32 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.193.173]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 52ADD40EFB00; Tue, 4 Oct 2022 13:47:32 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 203C41801F26; Tue, 4 Oct 2022 15:47:28 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jordan Justen , Gerd Hoffmann , Pawel Polawski , Jiewen Yao , Oliver Steffen , Ard Biesheuvel , Laszlo Ersek Subject: [PATCH v2 4/4] OvmfPkg/PciHotPlugInitDxe: reserve more mmio space Date: Tue, 4 Oct 2022 15:47:28 +0200 Message-Id: <20221004134728.55499-5-kraxel@redhat.com> In-Reply-To: <20221004134728.55499-1-kraxel@redhat.com> References: <20221004134728.55499-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true In case the 64-bit pci mmio window is larger than the default size of 32G be generous and hand out larger chunks of address space for prefetchable mmio bridge windows. Cc: Laszlo Ersek Signed-off-by: Gerd Hoffmann --- OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf | 1 + OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c | 21 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf b/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf index 78b95faa7a7a..f56b1de6fd92 100644 --- a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf +++ b/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf @@ -40,6 +40,7 @@ [Protocols] [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId ## CONSUMES + gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size ## CONSUMES [Depex] TRUE diff --git a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c b/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c index c122855b735d..3f9c84cf2b54 100644 --- a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c +++ b/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c @@ -556,6 +556,7 @@ GetResourcePadding ( EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS *Address; BOOLEAN DefaultIo; BOOLEAN DefaultMmio; + BOOLEAN DefaultPrefMmio; RESOURCE_PADDING ReservationRequest; EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *FirstResource; EFI_STATUS ReservationHintStatus; @@ -588,8 +589,9 @@ GetResourcePadding ( return EFI_INVALID_PARAMETER; } - DefaultIo = TRUE; - DefaultMmio = TRUE; + DefaultIo = TRUE; + DefaultMmio = TRUE; + DefaultPrefMmio = TRUE; // // Init ReservationRequest, and point FirstResource one past the last @@ -722,6 +724,7 @@ GetResourcePadding ( HighBit = HighBitSetRoundUp32 (ReservationHint.Prefetchable32BitMmio); if (HighBit != -1) { SetMmioPadding (--FirstResource, TRUE, TRUE, (UINTN)HighBit); + DefaultPrefMmio = FALSE; } } else if ((ReservationHint.Prefetchable64BitMmio > 0) && (ReservationHint.Prefetchable64BitMmio < MAX_UINT64)) @@ -729,6 +732,7 @@ GetResourcePadding ( HighBit = HighBitSetRoundUp64 (ReservationHint.Prefetchable64BitMmio); if (HighBit != -1) { SetMmioPadding (--FirstResource, TRUE, FALSE, (UINTN)HighBit); + DefaultPrefMmio = FALSE; } } } @@ -752,6 +756,19 @@ GetResourcePadding ( ); } + if (DefaultPrefMmio) { + UINT64 Pci64Size = PcdGet64 (PcdPciMmio64Size); + + if (Pci64Size > SIZE_32GB) { + SetMmioPadding ( + --FirstResource, + TRUE, + FALSE, + (UINTN)HighBitSetRoundUp64 (RShiftU64 (Pci64Size, 8)) + ); + } + } + // // Output a copy of ReservationRequest from the lowest-address populated // entry until the end of the structure (including -- 2.37.3