From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=135.84.80.237; helo=sender-pp-092.zoho.com; envelope-from=alex3kov@zoho.com; receiver=edk2-devel@lists.01.org Received: from sender-pp-092.zoho.com (sender-pp-092.zoho.com [135.84.80.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 202782034A890 for ; Fri, 27 Oct 2017 07:53:36 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=subject:to:cc:references:from:message-id:date:user-agent:mime-version:in-reply-to:content-type; b=RDWG3zX2l1xzqrgkFqWGW8qtXQ6uQLFhNTbNDkhuMI1Ax84YIEwChdxRW3Z+m8JbrVzskBW1MsN+ VCeNuujsLnaJcR6gLnBdHyoOmlLotg1DPd14dm4bK8MEScfhTOrF Received: from [192.168.0.194] (46.39.230.54 [46.39.230.54]) by mx.zohomail.com with SMTPS id 1509116239962138.15548017024048; Fri, 27 Oct 2017 07:57:19 -0700 (PDT) To: Laszlo Ersek , edk2-devel-01 Cc: Ard Biesheuvel , Dann Frazier , Eric Dong , Star Zeng References: <20171026154819.20865-1-lersek@redhat.com> From: Aleksei Message-ID: <1f52bc1c-7df6-ae81-b2e0-62cfd9840832@zoho.com> Date: Fri, 27 Oct 2017 17:57:17 +0300 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: <20171026154819.20865-1-lersek@redhat.com> X-ZohoMailClient: External X-Content-Filtered-By: Mailman/MimeDel 2.1.22 Subject: Re: [PATCH] MdeModulePkg/AtaAtapiPassThru: disable only BM-DMA 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: Fri, 27 Oct 2017 14:53:37 -0000 Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Tested combinations i440fx/IDE, i440fx/AHCI, Q35/IDE, Q35/AHCI for booting Windows 7 sp1 x64 installation - all boot in reasonable time. Thanks Laszlo. Tested-by: Aleksei Kovura /--Regards, Aleksei / On 26/10/17 18:48, Laszlo Ersek wrote: Clearing I/O port decoding in the PCI command register at ExitBootServices() breaks IDE boot in Windows, on QEMU's "pc" (i440fx) machine type. (AHCI boot on "q35" is unaffected.) Windows seems repeatedly stuck, apparently waiting for a timeout of sorts. This is arguably a Windows bug; a native OS driver should not expect the firmware to leave the PCI command register in any particular state. Strictly speaking, we only need to disable BM-DMA at ExitBootServices(), in order to abort pending transfers to/from RAM, which is soon to be owned by the OS. BM-DMA is also the only bit that's explicitly named by the UEFI Driver Writers' Guide, for clearing at ExitBootServices(). I've verified that clearing only BM-DMA fixes the isse (boot time) on i440fx, and does not regress q35/AHCI. Cc: Aleksei Kovura Cc: Ard Biesheuvel Cc: Dann Frazier Cc: Eric Dong Cc: Star Zeng Reported-by: Aleksei Kovura Reported-by: Dann Frazier Reported-by: https://launchpad.net/~cjkrupp Bisected-by: Dann Frazier Bisected-by: https://launchpad.net/~cjkrupp Suggested-by: Ard Biesheuvel Suggested-by: Star Zeng Ref: https://bugs.launchpad.net/ubuntu/+source/edk2/+bug/1725560 Fixes: 6fb8ddd36bde45614b0a069528cdc97077835a74 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek --- Notes: Repo: https://github.com/lersek/edk2.git Branch: ata_disable_only_bmdma MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h | 3 +-- MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h index 8d6eac706c0b..92c5bf2001cd 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h @@ -123,8 +123,7 @@ typedef struct { LIST_ENTRY NonBlockingTaskList; // - // For disabling the device (especially Bus Master DMA) at - // ExitBootServices(). + // For disabling Bus Master DMA on the device at ExitBootServices(). // EFI_EVENT ExitBootEvent; } ATA_ATAPI_PASS_THRU_INSTANCE; diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c index 09064dda18b7..e10e0d4e65f6 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c @@ -480,8 +480,7 @@ InitializeAtaAtapiPassThru ( } /** - Disable the device (especially Bus Master DMA) when exiting the boot - services. + Disable Bus Master DMA on the device when exiting the boot services. @param[in] Event Event for which this notification function is being called. @@ -506,7 +505,7 @@ AtaPassThruExitBootServices ( PciIo->Attributes ( PciIo, EfiPciIoAttributeOperationDisable, - Instance->EnabledPciAttributes, + Instance->EnabledPciAttributes & EFI_PCI_IO_ATTRIBUTE_BUS_MASTER, NULL ); }