From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 8624021D492EE for ; Thu, 7 Sep 2017 15:38:33 -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 B4367806A7; Thu, 7 Sep 2017 22:41:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B4367806A7 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lersek@redhat.com Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-54.rdu2.redhat.com [10.10.120.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id 443595D976; Thu, 7 Sep 2017 22:41:23 +0000 (UTC) From: Laszlo Ersek To: edk2-devel-01 Cc: Ard Biesheuvel , Brijesh Singh , Eric Dong , Jiewen Yao , Star Zeng Date: Fri, 8 Sep 2017 00:41:08 +0200 Message-Id: <20170907224116.895-3-lersek@redhat.com> In-Reply-To: <20170907224116.895-1-lersek@redhat.com> References: <20170907224116.895-1-lersek@redhat.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, 07 Sep 2017 22:41:24 +0000 (UTC) Subject: [PATCH 02/10] MdeModulePkg/AtaAtapiPassThru: unmap DMA buffers after disabling BM DMA 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, 07 Sep 2017 22:38:33 -0000 In AtaAtapiPassThruStop(), if the device has been operating in AHCI mode, we unmap the DMA buffers and then disable the device (including bus master DMA). The order of these actions is wrong; we shouldn't unmap DMA buffers until bus master DMA is turned off. Reverse the steps. 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.c | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c index b7fdb8dd4876..a48b295d26aa 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c @@ -911,16 +911,26 @@ AtaAtapiPassThruStop ( // // Free allocated resource // DestroyDeviceInfoList (Instance); + PciIo = Instance->PciIo; + + // + // Disable this ATA host controller. + // + PciIo->Attributes ( + PciIo, + EfiPciIoAttributeOperationDisable, + Instance->EnabledPciAttributes, + NULL + ); + // // If the current working mode is AHCI mode, then pre-allocated resource // for AHCI initialization should be released. // - PciIo = Instance->PciIo; - if (Instance->Mode == EfiAtaAhciMode) { AhciRegisters = &Instance->AhciRegisters; PciIo->Unmap ( PciIo, AhciRegisters->MapCommandTable @@ -948,20 +958,10 @@ AtaAtapiPassThruStop ( EFI_SIZE_TO_PAGES ((UINTN) AhciRegisters->MaxReceiveFisSize), AhciRegisters->AhciRFis ); } - // - // Disable this ATA host controller. - // - PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationDisable, - Instance->EnabledPciAttributes, - NULL - ); - // // Restore original PCI attributes // Status = PciIo->Attributes ( PciIo, -- 2.14.1.3.gb7cf6e02401b