Ard, Star,

(CC Igor)

On 10/26/17 07:08, Zeng, Star wrote:
> Good point.
> 
> Could we find out what change causes the performance regression? Bus Master 
> disable / Memory Space disable / IO Space disable?
> How about to only disable Bus Master in the exit boot service event 
> notification? It seems the key point suggested by UEFI 
> Driver_Writer_Guide_V1.0.1_120308.pdf.
> 
> 7.7
> Examples from the EDK II that use this feature are the PCI device drivers for 
> USB Host
> Controllers. Some USB Host Controllers are PCI Bus Masters that continuously 
> access a
> memory buffer to poll for operation requests. Access to this memory buffer by 
> a USB
> Host Controller may be required to boot an operation system, but this 
> activity must be
> terminated when the OS calls ExitBootServices(). *The typical action in the 
> Exit Boot
> Services Event for these types of drivers is to disable the PCI bus master* 
> and place the
> USB Host Controller into a halted state

thank you for the ideas.

* Disabling only EFI_PCI_IO_ATTRIBUTE_BUS_MASTER at EBS mitigates the
  symptom.

* Disabling (EFI_PCI_IO_ATTRIBUTE_BUS_MASTER | EFI_PCI_IO_ATTRIBUTE_IO)
  at EBS preserves the symptom.

* Disabling
  (EFI_PCI_IO_ATTRIBUTE_BUS_MASTER | EFI_PCI_IO_ATTRIBUTE_MEMORY) at EBS
  also mitigates the symptom.

So it is as Ard suspected, disabling IO port decoding is what tickles
the bug in Windows.

(Now I'm vaguely recalling an earlier discussion from qemu-devel that
Windows has a bug in that, if any given PCI device is disabled at boot,
then Windows will not load drivers for it, or some such. I'm struggling
to recall the context; maybe it was related to ACPI generation in QEMU.
I'm CC'ing Igor; maybe he remembers better.)

I will post a patch, for disabling EFI_PCI_IO_ATTRIBUTE_BUS_MASTER only.
First, that's going to follow the driver writers' guide verbatim;
second, disabling BMDMA and MMIO, but not IO, would look weird in the
code. :/

Thank you both for the help!
Laszlo


> -----Original Message-----
> From: Ard Biesheuvel [mailto:[email protected]] 
> Sent: Thursday, October 26, 2017 4:12 AM
> To: Laszlo Ersek <[email protected]>
> Cc: Dong, Eric <[email protected]>; Zeng, Star <[email protected]>; 
> edk2-devel-01 <[email protected]>; Yao, Jiewen <[email protected]>; 
> Brijesh Singh <[email protected]>
> Subject: Re: [edk2] [PATCH 03/10] MdeModulePkg/AtaAtapiPassThru: disable the 
> device at ExitBootServices()
> 
> On 25 October 2017 at 16:26, Laszlo Ersek <[email protected]> wrote:
>> Hi Star, Eric,
>>
>> On 09/08/17 00:41, Laszlo Ersek wrote:
>>> The AtaAtapiPassThru driver maps three system memory regions for Bus 
>>> Master Common Buffer operation on the following call path, if the 
>>> controller has PCI_CLASS_MASS_STORAGE_SATADPA class code:
>>>
>>>   AtaAtapiPassThruStart()
>>>     EnumerateAttachedDevice()
>>>       AhciModeInitialization()
>>>         AhciCreateTransferDescriptor()
>>>
>>> The device is disabled (including Bus Master DMA) when the controller 
>>> is unbound, in AtaAtapiPassThruStop(). Then the regions are unmapped.
>>>
>>> The former step should also be done when we exit the boot services, 
>>> and the OS gains ownership of system memory.
>>>
>>> Cc: Ard Biesheuvel <[email protected]>
>>> Cc: Brijesh Singh <[email protected]>
>>> Cc: Eric Dong <[email protected]>
>>> Cc: Jiewen Yao <[email protected]>
>>> Cc: Star Zeng <[email protected]>
>>> Contributed-under: TianoCore Contribution Agreement 1.1
>>> Signed-off-by: Laszlo Ersek <[email protected]>
>>> ---
>>>  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h |  6 ++  
>>> MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 59 
>>> +++++++++++++++++++-
>>>  2 files changed, 64 insertions(+), 1 deletion(-)
>>
>> this patch -- that is, commit 6fb8ddd36bde
>> ("MdeModulePkg/AtaAtapiPassThru: disable the device at 
>> ExitBootServices()", 2017-09-03) -- has caused a performance 
>> regression in OVMF, in booting Windows installer ISOs from emulated IDE 
>> CD-ROMs.
>>
>> Interestingly, the performance regression only affects the "traditional"
>> IDE controller of the "pc" (i440fx) machine type of QEMU; it does not 
>> affect the AHCI/SATA controller of the "q35" machine type.
> 
> Does it make any difference if you only disable memory decoding and bus 
> mastering, but leave I/O port decoding enabled?
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.01.org/mailman/listinfo/edk2-devel
> 

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to