From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 E882420356266 for ; Tue, 5 Dec 2017 04:41:45 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Dec 2017 04:46:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,364,1508828400"; d="scan'208";a="184208152" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga006.fm.intel.com with ESMTP; 05 Dec 2017 04:46:14 -0800 Received: from fmsmsx125.amr.corp.intel.com (10.18.125.40) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 5 Dec 2017 04:46:14 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX125.amr.corp.intel.com (10.18.125.40) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 5 Dec 2017 04:46:14 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.159]) with mapi id 14.03.0319.002; Tue, 5 Dec 2017 20:46:12 +0800 From: "Wu, Hao A" To: Ard Biesheuvel , "edk2-devel@lists.01.org" CC: "leif.lindholm@linaro.org" , "Zeng, Star" , "Tian, Feng" , "Ni, Ruiyu" Thread-Topic: [PATCH v2 2/2] MdeModulePkg/SdMmcPciHcDxe: allow HC capabilities to be overridden Thread-Index: AQHTacOxzBs80weulUGGSzdpgOWxRaM0uhZg Date: Tue, 5 Dec 2017 12:46:11 +0000 Message-ID: References: <20171130101132.18317-1-ard.biesheuvel@linaro.org> <20171130101132.18317-3-ard.biesheuvel@linaro.org> In-Reply-To: <20171130101132.18317-3-ard.biesheuvel@linaro.org> 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 2/2] MdeModulePkg/SdMmcPciHcDxe: allow HC capabilities to be overridden 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: Tue, 05 Dec 2017 12:41:46 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable One small comment below. Best Regards, Hao Wu > -----Original Message----- > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > Sent: Thursday, November 30, 2017 6:12 PM > To: edk2-devel@lists.01.org > Cc: leif.lindholm@linaro.org; Zeng, Star; Wu, Hao A; Tian, Feng; Ard Bies= heuvel > Subject: [PATCH v2 2/2] MdeModulePkg/SdMmcPciHcDxe: allow HC capabilities > to be overridden >=20 > Invoke the newly introduced SD/MMC override protocol to override > the capabilities register after reading it from the device registers, > and to call the pre/post host init and reset hooks at the appropriate > times. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 116 > +++++++++++++++++++- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h | 6 + > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf | 2 + > 3 files changed, 119 insertions(+), 5 deletions(-) >=20 > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > index 0be8828abfcc..61f64285807d 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > @@ -60,7 +60,8 @@ SD_MMC_HC_PRIVATE_DATA gSdMmcPciHcTemplate =3D { > { // MaxCurrent > 0, > }, > - 0 // ControllerVersion > + 0, // ControllerVersion > + NULL // Override > }; >=20 > SD_DEVICE_PATH mSdDpTemplate =3D { > @@ -213,6 +214,92 @@ Done: > return; > } >=20 Please help to add the function description comments for function: SdMmcPciHcResetHost() & SdMmcPciHcInitHost() > +STATIC > +EFI_STATUS > +SdMmcPciHcResetHost ( > + IN SD_MMC_HC_PRIVATE_DATA *Private, > + IN UINT8 Slot > + ) > +{ > + EFI_STATUS Status; > + > + if (Private->Override !=3D NULL && > + Private->Override->InvokeHook !=3D NULL) { > + Status =3D Private->Override->InvokeHook ( > + &Private->PassThru, > + Private->ControllerHandle, > + Slot, > + SD_MMC_OVERRIDE_RESET_PRE_HOOK); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_WARN, "%a: SD/MMC pre reset hook failed - %r\n", > + __FUNCTION__, Status)); > + return Status; > + } > + } > + > + Status =3D SdMmcHcReset (Private->PciIo, Slot); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + if (Private->Override !=3D NULL && > + Private->Override->InvokeHook !=3D NULL) { > + Status =3D Private->Override->InvokeHook ( > + &Private->PassThru, > + Private->ControllerHandle, > + Slot, > + SD_MMC_OVERRIDE_RESET_POST_HOOK); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_WARN, "%a: SD/MMC post reset hook failed - %r\n", > + __FUNCTION__, Status)); > + } > + } > + return Status; > +} > + > +STATIC > +EFI_STATUS > +SdMmcPciHcInitHost ( > + IN SD_MMC_HC_PRIVATE_DATA *Private, > + IN UINT8 Slot > + ) > +{ > + EFI_STATUS Status; > + > + if (Private->Override !=3D NULL && > + Private->Override->InvokeHook !=3D NULL) { > + Status =3D Private->Override->InvokeHook ( > + &Private->PassThru, > + Private->ControllerHandle, > + Slot, > + SD_MMC_OVERRIDE_INIT_HOST_PRE_HOOK); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_WARN, "%a: SD/MMC pre init hook failed - %r\n", > + __FUNCTION__, Status)); > + return Status; > + } > + } > + > + Status =3D SdMmcHcInitHost (Private->PciIo, Slot, Private->Capability[= Slot]); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + if (Private->Override !=3D NULL && > + Private->Override->InvokeHook !=3D NULL) { > + Status =3D Private->Override->InvokeHook ( > + &Private->PassThru, > + Private->ControllerHandle, > + Slot, > + SD_MMC_OVERRIDE_INIT_HOST_POST_HOOK); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_WARN, "%a: SD/MMC post init hook failed - %r\n", > + __FUNCTION__, Status)); > + } > + } > + return Status; > +} > + > /** > Sd removable device enumeration callback function when the timer event= is > signaled. >=20 > @@ -281,14 +368,14 @@ SdMmcPciHcEnumerateDevice ( > // > // Reset the specified slot of the SD/MMC Pci Host Controller > // > - Status =3D SdMmcHcReset (Private->PciIo, Slot); > + Status =3D SdMmcPciHcResetHost (Private, Slot); > if (EFI_ERROR (Status)) { > continue; > } > // > // Reinitialize slot and restart identification process for the = new attached > device > // > - Status =3D SdMmcHcInitHost (Private->PciIo, Slot, Private->Capab= ility[Slot]); > + Status =3D SdMmcPciHcInitHost (Private, Slot); > if (EFI_ERROR (Status)) { > continue; > } > @@ -601,6 +688,12 @@ SdMmcPciHcDriverBindingStart ( > goto Done; > } >=20 > + Status =3D gBS->HandleProtocol (Controller, > &gEdkiiSdMmcOverrideProtocolGuid, > + (VOID **)&Private->Override); > + if (!EFI_ERROR (Status)) { > + DEBUG ((DEBUG_INFO, "%a: using SD/MMC override protocol\n", > __FUNCTION__)); > + } > + > Support64BitDma =3D TRUE; > for (Slot =3D FirstBar; Slot < (FirstBar + SlotNum); Slot++) { > Private->Slot[Slot].Enable =3D TRUE; > @@ -609,6 +702,19 @@ SdMmcPciHcDriverBindingStart ( > if (EFI_ERROR (Status)) { > continue; > } > + if (Private->Override !=3D NULL && > + Private->Override->OverrideCapability !=3D NULL) { > + Status =3D Private->Override->OverrideCapability ( > + &Private->PassThru, > + Controller, > + Slot, > + (VOID *)&Private->Capability[Slot]); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_WARN, "%a: Failed to override capability - %r\n", > + __FUNCTION__, Status)); > + continue; > + } > + } > DumpCapabilityReg (Slot, &Private->Capability[Slot]); >=20 > Support64BitDma &=3D Private->Capability[Slot].SysBus64; > @@ -627,7 +733,7 @@ SdMmcPciHcDriverBindingStart ( > // > // Reset the specified slot of the SD/MMC Pci Host Controller > // > - Status =3D SdMmcHcReset (PciIo, Slot); > + Status =3D SdMmcPciHcResetHost (Private, Slot); > if (EFI_ERROR (Status)) { > continue; > } > @@ -642,7 +748,7 @@ SdMmcPciHcDriverBindingStart ( > continue; > } >=20 > - Status =3D SdMmcHcInitHost (PciIo, Slot, Private->Capability[Slot]); > + Status =3D SdMmcPciHcInitHost (Private, Slot); > if (EFI_ERROR (Status)) { > continue; > } > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > index 6a2a27969936..b51e0529f885 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > @@ -35,6 +35,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY > KIND, EITHER EXPRESS OR IMPLIED. > #include > #include > #include > +#include > #include >=20 > #include "SdMmcPciHci.h" > @@ -115,6 +116,11 @@ typedef struct { > UINT64 MaxCurrent[SD_MMC_HC_MAX_SLOT]; >=20 > UINT32 ControllerVersion; > + > + // > + // Optional protcol to deal with non-standard SDHCI implementations > + // > + SD_MMC_OVERRIDE *Override; > } SD_MMC_HC_PRIVATE_DATA; >=20 > #define SD_MMC_HC_TRB_SIG SIGNATURE_32 ('T', 'R', 'B', 'T') > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf > index e26e6a098c17..154ce45d8223 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf > @@ -48,6 +48,7 @@ [Sources] >=20 > [Packages] > MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec >=20 > [LibraryClasses] > DevicePathLib > @@ -61,6 +62,7 @@ [LibraryClasses] > DebugLib >=20 > [Protocols] > + gEdkiiSdMmcOverrideProtocolGuid ## SOMETIMES_CONSUMES > gEfiDevicePathProtocolGuid ## TO_START > gEfiPciIoProtocolGuid ## TO_START > gEfiSdMmcPassThruProtocolGuid ## BY_START > -- > 2.11.0