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 763B621D492FD for ; Thu, 7 Sep 2017 15:38:31 -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 AA0FD4E334; Thu, 7 Sep 2017 22:41:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AA0FD4E334 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.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 39D9D5D967; Thu, 7 Sep 2017 22:41:21 +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:07 +0200 Message-Id: <20170907224116.895-2-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.38]); Thu, 07 Sep 2017 22:41:22 +0000 (UTC) Subject: [PATCH 01/10] MdeModulePkg/AtaAtapiPassThru: cache EnabledPciAttributes 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:31 -0000 Both AtaAtapiPassThruStart() and AtaAtapiPassThruStop() fetch the supported attributes of the device, just so they can toggle the IO+MMIO+BusMaster subset. After we compute this bitmask in AtaAtapiPassThruStart(), we can cache it for later, and save the fetch in AtaAtapiPassThruStop(). 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 | 1 + MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 32 ++++++++------------ 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h index 4f327dc30b60..85e5a5553953 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h @@ -98,10 +98,11 @@ typedef struct { // // The attached device list // LIST_ENTRY DeviceList; + UINT64 EnabledPciAttributes; UINT64 OriginalPciAttributes; // // For AtaPassThru protocol, using the following bytes to record the previous call in // GetNextPort()/GetNextDevice(). diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c index 795443ef74f6..b7fdb8dd4876 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c @@ -92,10 +92,11 @@ ATA_ATAPI_PASS_THRU_INSTANCE gAtaAtapiPassThruInstanceTemplate = { }, { // DeviceList NULL, NULL }, + 0, // EnabledPciAttributes 0, // OriginalAttributes 0, // PreviousPort 0, // PreviousPortMultiplier 0, // PreviousTargetId 0, // PreviousLun @@ -668,11 +669,11 @@ AtaAtapiPassThruStart ( { EFI_STATUS Status; EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeControllerInit; ATA_ATAPI_PASS_THRU_INSTANCE *Instance; EFI_PCI_IO_PROTOCOL *PciIo; - UINT64 Supports; + UINT64 EnabledPciAttributes; UINT64 OriginalPciAttributes; Status = EFI_SUCCESS; IdeControllerInit = NULL; Instance = NULL; @@ -720,18 +721,18 @@ AtaAtapiPassThruStart ( Status = PciIo->Attributes ( PciIo, EfiPciIoAttributeOperationSupported, 0, - &Supports + &EnabledPciAttributes ); if (!EFI_ERROR (Status)) { - Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE; + EnabledPciAttributes &= (UINT64)EFI_PCI_DEVICE_ENABLE; Status = PciIo->Attributes ( PciIo, EfiPciIoAttributeOperationEnable, - Supports, + EnabledPciAttributes, NULL ); } if (EFI_ERROR (Status)) { @@ -747,10 +748,11 @@ AtaAtapiPassThruStart ( } Instance->ControllerHandle = Controller; Instance->IdeControllerInit = IdeControllerInit; Instance->PciIo = PciIo; + Instance->EnabledPciAttributes = EnabledPciAttributes; Instance->OriginalPciAttributes = OriginalPciAttributes; Instance->AtaPassThru.Mode = &Instance->AtaPassThruMode; Instance->ExtScsiPassThru.Mode = &Instance->ExtScsiPassThruMode; InitializeListHead(&Instance->DeviceList); InitializeListHead(&Instance->NonBlockingTaskList); @@ -857,11 +859,10 @@ AtaAtapiPassThruStop ( EFI_STATUS Status; ATA_ATAPI_PASS_THRU_INSTANCE *Instance; EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru; EFI_PCI_IO_PROTOCOL *PciIo; EFI_AHCI_REGISTERS *AhciRegisters; - UINT64 Supports; DEBUG ((EFI_D_INFO, "==AtaAtapiPassThru Stop== Controller = %x\n", Controller)); Status = gBS->OpenProtocol ( Controller, @@ -950,25 +951,16 @@ AtaAtapiPassThruStop ( } // // Disable this ATA host controller. // - Status = PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationSupported, - 0, - &Supports - ); - if (!EFI_ERROR (Status)) { - Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE; - PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationDisable, - Supports, - NULL - ); - } + PciIo->Attributes ( + PciIo, + EfiPciIoAttributeOperationDisable, + Instance->EnabledPciAttributes, + NULL + ); // // Restore original PCI attributes // Status = PciIo->Attributes ( -- 2.14.1.3.gb7cf6e02401b