From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 3B59421144CE0 for ; Mon, 4 Jun 2018 22:16:50 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jun 2018 22:16:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,477,1520924400"; d="scan'208";a="234424158" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga005.fm.intel.com with ESMTP; 04 Jun 2018 22:16:49 -0700 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 4 Jun 2018 22:16:49 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 4 Jun 2018 22:16:49 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.223]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.116]) with mapi id 14.03.0319.002; Tue, 5 Jun 2018 13:16:47 +0800 From: "Zeng, Star" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Chiu, Chasel" , "Zeng, Star" Thread-Topic: [PATCH v2 3/4] MdeModulePkg/AtaAtapiPassThru: enable/disable PUIS per policy Thread-Index: AQHT+9I0Hw0FYjEnD021eeTPZn+84KRRBJBw//97pgCAAKDAkA== Date: Tue, 5 Jun 2018 05:16:46 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BB5349E@shsmsx102.ccr.corp.intel.com> References: <20180604070337.164836-1-ruiyu.ni@intel.com> <20180604070337.164836-4-ruiyu.ni@intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103BB533AC@shsmsx102.ccr.corp.intel.com> <734D49CCEBEEF84792F5B80ED585239D5BD249C6@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5BD249C6@SHSMSX104.ccr.corp.intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 3/4] MdeModulePkg/AtaAtapiPassThru: enable/disable PUIS per policy X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jun 2018 05:16:50 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Yes, that is why I was saying to use AhciSetFeaturePuis as the function nam= e. Thanks, Star -----Original Message----- From: Ni, Ruiyu=20 Sent: Tuesday, June 5, 2018 11:41 AM To: Zeng, Star ; edk2-devel@lists.01.org Cc: Chiu, Chasel Subject: RE: [PATCH v2 3/4] MdeModulePkg/AtaAtapiPassThru: enable/disable P= UIS per policy The Set Feature cmd is used to enable/disable PUIS. Thanks/Ray > -----Original Message----- > From: Zeng, Star > Sent: Tuesday, June 5, 2018 11:35 AM > To: Ni, Ruiyu ; edk2-devel@lists.01.org > Cc: Chiu, Chasel ; Zeng, Star=20 > > Subject: RE: [PATCH v2 3/4] MdeModulePkg/AtaAtapiPassThru: > enable/disable PUIS per policy >=20 > Reviewed-by: Star Zeng >=20 > How about using function name AhciSetFeaturePuis instead of=20 > AhciPuisEnable as the function is not just to enable Puis? >=20 >=20 > Thanks, > Star > -----Original Message----- > From: Ni, Ruiyu > Sent: Monday, June 4, 2018 3:04 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Chiu, Chasel=20 > > Subject: [PATCH v2 3/4] MdeModulePkg/AtaAtapiPassThru: enable/disable=20 > PUIS per policy >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ruiyu Ni > Cc: Star Zeng > Cc: Chasel Chiu > --- > MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c | 48 > ++++++++++++++++++++++ > .../Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 19 ++++++++- > .../Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h | 3 ++ > .../Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf | 3 +- > 4 files changed, 71 insertions(+), 2 deletions(-) >=20 > diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c > b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c > index 14578c0f94..841b6a0e60 100644 > --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c > +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c > @@ -2316,6 +2316,38 @@ AhciSpinUpDisk ( > return EFI_SUCCESS; > } >=20 > +/** > + Enable/disable/skip PUIS of the disk according to policy. > + > + @param PciIo The PCI IO protocol instance. > + @param AhciRegisters The pointer to the EFI_AHCI_REGISTERS. > + @param Port The number of port. > + @param PortMultiplier The multiplier of port. > + > +**/ > +EFI_STATUS > +AhciPuisEnable ( > + IN EFI_PCI_IO_PROTOCOL *PciIo, > + IN EFI_AHCI_REGISTERS *AhciRegisters, > + IN UINT8 Port, > + IN UINT8 PortMultiplier > + ) > +{ > + EFI_STATUS Status; > + > + Status =3D EFI_SUCCESS; > + if (mAtaAtapiPolicy->PuisEnable =3D=3D 0) { > + Status =3D AhciDeviceSetFeature (PciIo, AhciRegisters, Port,=20 > +PortMultiplier, ATA_SUB_CMD_DISABLE_PUIS, 0x00, > ATA_ATAPI_TIMEOUT); > + } else if (mAtaAtapiPolicy->PuisEnable =3D=3D 1) { > + Status =3D AhciDeviceSetFeature (PciIo, AhciRegisters, Port,=20 > +PortMultiplier, ATA_SUB_CMD_ENABLE_PUIS, 0x00, > ATA_ATAPI_TIMEOUT); > + } > + DEBUG ((DEBUG_INFO, "%a PUIS feature at port [%d] PortMultiplier=20 > + [%d] - > %r!\n", > + (mAtaAtapiPolicy->PuisEnable =3D=3D 0) ? "Disable" : ( > + (mAtaAtapiPolicy->PuisEnable =3D=3D 1) ? "Enable" : "Skip" > + ), Port, PortMultiplier, Status)); > + return Status; > +} > + > /** > Initialize ATA host controller at AHCI mode. >=20 > @@ -2658,6 +2690,22 @@ AhciModeInitialization ( > if (DeviceType =3D=3D EfiIdeHarddisk) { > REPORT_STATUS_CODE (EFI_PROGRESS_CODE,=20 > (EFI_PERIPHERAL_FIXED_MEDIA | EFI_P_PC_ENABLE)); > } > + > + // > + // Enable/disable PUIS according to policy setting if PUIS is=20 > + capable > (Word[83].BIT5 is set). > + // > + if ((Buffer.AtaData.command_set_supported_83 & BIT5) !=3D 0) { > + Status =3D AhciPuisEnable ( > + PciIo, > + AhciRegisters, > + Port, > + 0 > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "PUIS enable/disable failed, Status =3D=20 > + %r\n", > Status)); > + continue; > + } > + } > } > } >=20 > diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c > b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c > index a48b295d26..aab704bcd3 100644 > --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c > +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c > @@ -2,7 +2,7 @@ > This file implements ATA_PASSTHRU_PROCTOCOL and=20 > EXT_SCSI_PASSTHRU_PROTOCOL interfaces > for managed ATA controllers. >=20 > - Copyright (c) 2010 - 2016, Intel Corporation. All rights=20 > reserved.
> + Copyright (c) 2010 - 2018, Intel Corporation. All rights=20 > + reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of=20 > the BSD License > which accompanies this distribution. The full text of the license=20 > may be found at @@ -142,6 +142,15 @@ UINT8 mScsiId[TARGET_MAX_BYTES] =3D = { > 0xFF, 0xFF, 0xFF, 0xFF > }; >=20 > +EDKII_ATA_ATAPI_POLICY_PROTOCOL *mAtaAtapiPolicy;=20 > +EDKII_ATA_ATAPI_POLICY_PROTOCOL mDefaultAtaAtapiPolicy =3D { > + EDKII_ATA_ATAPI_POLICY_VERSION, > + 2, // PuisEnable > + 0, // DeviceSleepEnable > + 0, // AggressiveDeviceSleepEnable > + 0 // Reserved > +}; > + > /** > Sends an ATA command to an ATA device that is attached to the ATA=20 > controller. This function > supports both blocking I/O and non-blocking I/O. The blocking I/O=20 > functionality is required, @@ -739,6 +748,14 @@ AtaAtapiPassThruStart ( > goto ErrorExit; > } >=20 > + Status =3D gBS->LocateProtocol (&gEdkiiAtaAtapiPolicyProtocolGuid, > + NULL, (VOID **)&mAtaAtapiPolicy); if (EFI_ERROR (Status)) { > + // > + // If there is no AtaAtapiPolicy exposed, use the default policy. > + // > + mAtaAtapiPolicy =3D &mDefaultAtaAtapiPolicy; } > + > // > // Allocate a buffer to store the ATA_ATAPI_PASS_THRU_INSTANCE data=20 > structure > // > diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h > b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h > index 31b005f2f6..b07bcbbb3e 100644 > --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h > +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h > @@ -24,6 +24,7 @@ > #include #include=20 > #include > +#include >=20 > #include > #include > @@ -45,6 +46,8 @@ extern EFI_DRIVER_BINDING_PROTOCOL=20 > gAtaAtapiPassThruDriverBinding; extern EFI_COMPONENT_NAME_PROTOCOL =20 > gAtaAtapiPassThruComponentName; extern EFI_COMPONENT_NAME2_PROTOCOL=20 > gAtaAtapiPassThruComponentName2; >=20 > +extern EDKII_ATA_ATAPI_POLICY_PROTOCOL *mAtaAtapiPolicy; > + > #define ATA_ATAPI_PASS_THRU_SIGNATURE SIGNATURE_32 ('a', 'a', 'p', 't') > #define ATA_ATAPI_DEVICE_SIGNATURE SIGNATURE_32 ('a', 'd', 'e', 'v') > #define ATA_NONBLOCKING_TASK_SIGNATURE SIGNATURE_32 ('a', 't', 's', > 'k') diff --git > a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf > b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf > index 82d5f7a46c..d1ce859091 100644 > --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf > +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf > @@ -4,7 +4,7 @@ > # This driver installs AtaPassThru and ExtScsiPassThru protocol in=20 > each ide/sata controller # to access to all attached Ata/Atapi devices. > # > -# Copyright (c) 2010 - 2014, Intel Corporation. All rights=20 > reserved.
> +# Copyright (c) 2010 - 2018, Intel Corporation. All rights=20 > +reserved.
> # > # This program and the accompanying materials # are licensed and=20 > made available under the terms and conditions of the BSD License @@=20 > -67,6 +67,7 @@ [Protocols] > gEfiIdeControllerInitProtocolGuid ## TO_START > gEfiDevicePathProtocolGuid ## TO_START > gEfiPciIoProtocolGuid ## TO_START > + gEdkiiAtaAtapiPolicyProtocolGuid ## CONSUMES >=20 > [Pcd] > gEfiMdeModulePkgTokenSpaceGuid.PcdAtaSmartEnable ## > SOMETIMES_CONSUMES > -- > 2.16.1.windows.1