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 2F799220C1C47 for ; Thu, 23 Nov 2017 09:15:07 -0800 (PST) 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 765E9883D2; Thu, 23 Nov 2017 17:19:24 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-221.rdu2.redhat.com [10.10.120.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD24E5D9C7; Thu, 23 Nov 2017 17:19:22 +0000 (UTC) To: "Ni, Ruiyu" , "Zeng, Star" , edk2-devel-01 Cc: Ard Biesheuvel , "Dong, Eric" , Dann Frazier References: <20171026154819.20865-1-lersek@redhat.com> <734D49CCEBEEF84792F5B80ED585239D5BACC0A1@SHSMSX104.ccr.corp.intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B9BABBA@shsmsx102.ccr.corp.intel.com> <734D49CCEBEEF84792F5B80ED585239D5BACDEC2@SHSMSX104.ccr.corp.intel.com> <734D49CCEBEEF84792F5B80ED585239D5BACEB5A@SHSMSX104.ccr.corp.intel.com> From: Laszlo Ersek Message-ID: Date: Thu, 23 Nov 2017 18:19:21 +0100 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: <734D49CCEBEEF84792F5B80ED585239D5BACEB5A@SHSMSX104.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.26]); Thu, 23 Nov 2017 17:19:24 +0000 (UTC) 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: Thu, 23 Nov 2017 17:15:07 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 11/23/17 15:58, Ni, Ruiyu wrote: > Laszlo, > A S3 flag PCD was added to optimize boot flow. Let's say, > setting the flag to false is to remove some unnecessary code. > setting to true is also fine. > > But in this case, setting S4 flag to false is to add some incompatible code. > It's a bit different. > > If you check the two patches to revert the PciBus change, Microsoft gave > their Signed-off. Of course they did: Windows 10 is a Microsoft OS; they obviously will not want to break their own OS with firmware changes. :) Anyway, joking aside, as I said, I *do* want to keep Windows 10 in working shape. I'm just saying that this should be a platform choice. On some platforms, the AtaAtapiPassThru EBS handler does not tickle the bug in Windows 10, so on those platforms, it makes sense to do what the DWG recommends (and keep the code). If you strongly disagree with allowing customization for this code, then: (1) Can you please submit a two part series that reverts the following patches (in this order): (a) revert 76fd5a660d704538a1b14a58d03a4eef9682b01c (b) revert 6fb8ddd36bde45614b0a069528cdc97077835a74 This will keep a good git history, and I'll ACK these reverts. (2) I'll file a down-stream (Red Hat) Bugzilla to make sure we keep the EBS handler as it is now (at 8284b1791ea9) when we next rebase to upstream edk2 (as long as we don't support S4). Thanks, Laszlo > > /Ray > >> -----Original Message----- >> From: Laszlo Ersek [mailto:lersek@redhat.com] >> Sent: Thursday, November 23, 2017 9:08 PM >> To: Ni, Ruiyu ; Zeng, Star ; edk2- >> devel-01 >> Cc: Ard Biesheuvel ; Dong, Eric >> ; Dann Frazier >> Subject: Re: [edk2] [PATCH] MdeModulePkg/AtaAtapiPassThru: disable only BM- >> DMA at ExitBootServices() >> >> On 11/23/17 03:20, Ni, Ruiyu wrote: >>> I cannot explain precisely why the S4 resume fails. >>> I can just guess: Windows might have some assumptions on the BM bit. >> >> Can we make this configurable on the platform level somehow? >> >> On one hand, I certainly don't want to break Windows 10, even in case this issue >> ultimately turns out to be a Windows 10 bug. >> >> On the other hand, OVMF does not support S4, and disabling BMDMA at >> ExitBootServices() in PCI drivers is specifically what the Driver Writers' Guide >> recommends. Otherwise pending DMA could corrupt OS memory. >> >> So, for OVMF at least, I'd like to keep the present behavior, but for other >> platforms, I don't insist on disabling BMDMA, of course. >> >> We already have a PCD called "PcdAcpiS3Enable" in "MdeModulePkg.dec"; >> maybe we can introduce "PcdAcpiS4Enable" too. >> >> BTW, has anyone reported this S4 issue to Microsoft? (Personally I'm totally >> unable to talk to Microsoft -- no working communication channels seem to be >> accessible to me. I hope Intel might fare better.) I wonder what their opinion >> would be on the issue. >> >> Thanks, >> Laszlo >> >>>> -----Original Message----- >>>> From: Zeng, Star >>>> Sent: Wednesday, November 22, 2017 6:26 PM >>>> To: Ni, Ruiyu ; Laszlo Ersek ; >>>> edk2-devel-01 >>>> Cc: Ard Biesheuvel ; Dong, Eric >>>> ; Dann Frazier ; Zeng, Star >>>> >>>> Subject: RE: [edk2] [PATCH] MdeModulePkg/AtaAtapiPassThru: disable >>>> only BM-DMA at ExitBootServices() >>>> >>>> Ray, >>>> >>>> You may explain more why Win10 S4 resume fails with only BM disabled, >>>> then Laszlo can know the issue well. >>>> >>>> >>>> Thanks, >>>> Star >>>> -----Original Message----- >>>> From: Ni, Ruiyu >>>> Sent: Wednesday, November 22, 2017 6:06 PM >>>> To: Laszlo Ersek ; edk2-devel-01 >>> devel@lists.01.org> >>>> Cc: Ard Biesheuvel ; Dong, Eric >>>> ; Zeng, Star ; Dann Frazier >>>> >>>> Subject: RE: [edk2] [PATCH] MdeModulePkg/AtaAtapiPassThru: disable >>>> only BM-DMA at ExitBootServices() >>>> >>>> Laszlo, >>>> Our QA found Win10 S4 resume fails due to your change. >>>> As you might notice that I just rolled back the BM disabling patches >>>> in PciBus module, I am thinking about maybe you need to rollback the >>>> whole ExitBootServices callback as well to fix the compatibility issue. >>>> >>>> Thanks/Ray >>>> >>>>> -----Original Message----- >>>>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf >>>>> Of Laszlo Ersek >>>>> Sent: Saturday, October 28, 2017 12:10 AM >>>>> To: edk2-devel-01 >>>>> Cc: Ard Biesheuvel ; Dong, Eric >>>>> ; Zeng, Star ; Dann >>>>> Frazier >>>>> Subject: Re: [edk2] [PATCH] MdeModulePkg/AtaAtapiPassThru: disable >>>>> only BM-DMA at ExitBootServices() >>>>> >>>>> On 10/26/17 17: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 >>>>>> ); >>>>>> } >>>>>> >>>>> >>>>> Thanks Everyone for the feedback; I fixed the typo pointed out by >>>>> Star and pushed the patch as commit 76fd5a660d70. >>>>> >>>>> Cheers >>>>> Laszlo >>>>> _______________________________________________ >>>>> edk2-devel mailing list >>>>> edk2-devel@lists.01.org >>>>> https://lists.01.org/mailman/listinfo/edk2-devel >