From nobody Sat May 4 21:43:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1509032907879872.2699792887647; Thu, 26 Oct 2017 08:48:27 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 36D772035260B; Thu, 26 Oct 2017 08:44:40 -0700 (PDT) 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 E50C421CEB141 for ; Thu, 26 Oct 2017 08:44:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B340F5F7B9; Thu, 26 Oct 2017 15:48:24 +0000 (UTC) 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 A719E8095D; Thu, 26 Oct 2017 15:48:22 +0000 (UTC) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; 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 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B340F5F7B9 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lersek@redhat.com From: Laszlo Ersek To: edk2-devel-01 Date: Thu, 26 Oct 2017 17:48:19 +0200 Message-Id: <20171026154819.20865-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 26 Oct 2017 15:48:24 +0000 (UTC) Subject: [edk2] [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: , Cc: Aleksei Kovura , Dann Frazier , Eric Dong , Star Zeng , Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reported-by: Aleksei Kovura > Reported-by: Dann Frazier > Reviewed-by: Star Zeng after the minor typo " isse " = is fixed to " issue ". Suggested-by: Ard Biesheuvel > Suggested-by: Star Zeng > Tested-by: Aleksei Kovura Tested-by: dann frazier --- 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/Mde= ModulePkg/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; =20 // - // 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/Mde= ModulePkg/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 ( } =20 /** - Disable the device (especially Bus Master DMA) when exiting the boot - services. + Disable Bus Master DMA on the device when exiting the boot services. =20 @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_MASTE= R, NULL ); } --=20 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel