Hi everyone,

Requesting feedback on a recent edk2 change that is functionally correct, but 
is breaking some Video option ROMs.



The PR:
MdeModulePkg/PciBusDxe: Preserve Physical BAR numbering by apop5 * Pull Request 
#13258 * tianocore/edk2<https://github.com/tianocore/edk2/pull/13258>


It was intended to make the PciIo function according to UEFI specification: 14. 
Protocols - PCI Bus Support - UEFI Specification 2.11 
documentation<https://uefi.org/specs/UEFI/2.11/14_Protocols_PCI_Bus_Support.html#efi-pci-io-protocol-mem-write>

Specifically
"The BAR index of the standard PCI Configuration header to use as the base 
address for the memory operation to perform. This allows all drivers to use BAR 
relative addressing. The legal range for this field is 0..5."


Prior to this change, the internal PciBus.h structure PCI_IO_DEVICE  would pack 
BARs when placing them into `PCI_BAR  PciBar[PCI_MAX_BAR]`
This had impacts when accessing via PciIo->Mem.Read/Write, which accepts as a 
parameter the BAR index it is attempting to access.

example:

Pci Device A
  BAR0 - 32 bit memory, Placed in PciBar[0] in internal structure
  BAR1 - 32 bit memory, Placed in PciBar[1] in internal structure
  BAR2 - 64 bit memory, Placed in PciBar[2] in internal structure

PCI Device B
  BAR0 - 64 bit memory, Placed in PciBar[0] in internal structure
  BAR1 - nothing, upper 32 bits of BAR0
  BAR2 - 64 bit memory, Placed in PciBar[1] in internal structure


When attempting to access the BARs through PciIo->Mem.Read
 PciIo->Mem.Read (
                     PciIo,
                     EfiPciIoWidthUint32,
                     PCI_BAR_IDX2,
                     0,
                     1,
                     Value
                     );

Prior to the PR, Pci Device A would access internal structure offset [2]
Prior to the PR, Pci Device B would return EFI_UNSUPPORTED because there would 
be nothing at index 2 in the internal structure.

After the change, Pci Device A would work the same.
After the change Pci Device B would correctly access BAR2 and be able to read 
into the memory space.


Since this has gone into the project, there have been 2 reported problems. Both 
with Video Option Roms.
>From what can be collected, the video option roms, working around the existing 
>problems in the PCI driver, the option roms would pass in PCI_BAR_IDX1 when 
>attempting to access the second 64 bit BAR.




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


Reply via email to