From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4E04E203525F2 for ; Thu, 26 Oct 2017 07:06:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CE51DC13DA12; Thu, 26 Oct 2017 14:10:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CE51DC13DA12 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lersek@redhat.com Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-110.rdu2.redhat.com [10.10.120.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA1B77BAE4; Thu, 26 Oct 2017 14:09:58 +0000 (UTC) To: "Zeng, Star" , Ard Biesheuvel Cc: Brijesh Singh , edk2-devel-01 , "Yao, Jiewen" , "Dong, Eric" , Igor Mammedov References: <20170907224116.895-1-lersek@redhat.com> <20170907224116.895-4-lersek@redhat.com> <5bf829cb-4517-a579-ba7c-745c4ee89147@redhat.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B9AE2CE@shsmsx102.ccr.corp.intel.com> From: Laszlo Ersek Message-ID: Date: Thu, 26 Oct 2017 16:09:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B9AE2CE@shsmsx102.ccr.corp.intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 26 Oct 2017 14:10:01 +0000 (UTC) Subject: Re: [PATCH 03/10] MdeModulePkg/AtaAtapiPassThru: disable the device at ExitBootServices() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Oct 2017 14:06:16 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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:ard.biesheuvel@linaro.org] > Sent: Thursday, October 26, 2017 4:12 AM > To: Laszlo Ersek > Cc: Dong, Eric ; Zeng, Star ; edk2-devel-01 ; Yao, Jiewen ; Brijesh Singh > Subject: Re: [edk2] [PATCH 03/10] MdeModulePkg/AtaAtapiPassThru: disable the device at ExitBootServices() > > On 25 October 2017 at 16:26, Laszlo Ersek 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 >>> Cc: Brijesh Singh >>> Cc: Eric Dong >>> Cc: Jiewen Yao >>> Cc: Star Zeng >>> Contributed-under: TianoCore Contribution Agreement 1.1 >>> Signed-off-by: Laszlo Ersek >>> --- >>> 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 > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel >