Uhmm. I assume this should be done in PciBus driver.
It will be a burden to let each PciHotPlugInitDxe to fix the smallest IO window.

+ PciBus maintainer: Ray Ni <[email protected]> and Hao A Wu <[email protected]>
What's your opinion?


> -----Original Message-----
> From: [email protected] <[email protected]> On Behalf Of Gerd
> Hoffmann
> Sent: Monday, November 28, 2022 2:26 PM
> To: [email protected]
> Cc: Oliver Steffen <[email protected]>; Gerd Hoffmann
> <[email protected]>; Pawel Polawski <[email protected]>; Ard
> Biesheuvel <[email protected]>; Justen, Jordan L
> <[email protected]>; Yao, Jiewen <[email protected]>
> Subject: [edk2-devel] [PATCH 1/1] OvmfPkg/PciHotPlugInitDxe: fix io
> window size
> 
> Smallest IO window size for PCI bridges is 0x1000.  Add a check and
> fixup the Exponent of needed.  Avoids broken resource assignments
> like this:
> 
>     [ ... ]
>     PciBus: Resource Map for Root Bridge PciRoot(0x0)
>     Type =   Io16; Base = 0x6000;   Length = 0x7000;        Alignment = 0xFFF
>     [ ... ]
>        Base = 0xC000;       Length = 0x200; Alignment = 0xFFF;      Owner = 
> PPB
> [00|02|00:**]
>        Base = 0xC200;       Length = 0x40;  Alignment = 0x3F;       Owner = 
> PCI
> [00|1F|03:20]
>        Base = 0xC240;       Length = 0x20;  Alignment = 0x1F;       Owner = 
> PCI
> [00|1F|02:20]
>     [ ... ]
> 
> ... which the linux kernel fixes up later:
> 
>     [    0.644657] pci 0000:00:1f.3: BAR 4: assigned [io  0x1000-0x103f]
>     [    0.646833] pci 0000:00:1f.2: BAR 4: assigned [io  0x1040-0x105f]
> 
> With the patch applied:
> 
>     { ... ]
>     PciBus: Resource Map for Root Bridge PciRoot(0x0)
>     Type =   Io16; Base = 0x6000;   Length = 0x8000;        Alignment = 0xFFF
>     [ ... ]
>        Base = 0xC000;       Length = 0x1000;        Alignment = 0xFFF;      
> Owner
> = PPB [00|02|00:**]
>        Base = 0xD000;       Length = 0x40;  Alignment = 0x3F;       Owner = 
> PCI
> [00|1F|03:20]
>        Base = 0xD040;       Length = 0x20;  Alignment = 0x1F;       Owner = 
> PCI
> [00|1F|02:20]
>     [ ... ]
> 
> Signed-off-by: Gerd Hoffmann <[email protected]>
> ---
>  OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c
> b/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c
> index 3f9c84cf2b54..6c8bbc3b199d 100644
> --- a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c
> +++ b/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c
> @@ -117,6 +117,10 @@ SetIoPadding (
>    IN     UINTN                              SizeExponent
>    )
>  {
> +  if (SizeExponent < 12) {
> +    SizeExponent = 12;
> +  }
> +
>    Descriptor->ResType      = ACPI_ADDRESS_SPACE_TYPE_IO;
>    Descriptor->AddrLen      = LShiftU64 (1, SizeExponent);
>    Descriptor->AddrRangeMax = Descriptor->AddrLen - 1;
> --
> 2.38.1
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97168): https://edk2.groups.io/g/devel/message/97168
Mute This Topic: https://groups.io/mt/95305405/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to