From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::244; helo=mail-wr0-x244.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B7E542034BBD9 for ; Thu, 9 Nov 2017 05:34:50 -0800 (PST) Received: by mail-wr0-x244.google.com with SMTP id l8so5601977wre.12 for ; Thu, 09 Nov 2017 05:38:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=x+xbOiNmjyHe5yq2Cizoz2vhjx0MSV0/4bZPOtMVCR8=; b=bfFvbmk0tUDa/qsW5/O6pABIGqaeQ+rSn6xv/OEK2ukjjygMFEMYI/B8PK/+I4qunE 7PW0qHdDU2Tynm7ZAi+8CiLu/Uo07yMP09YsmKtDEiruj/8BLiUG+tU0Tzj5Lg0W/l6+ ETIkxPMmCf/I3qoartsJxRTqTRTG5O+KWGGPs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=x+xbOiNmjyHe5yq2Cizoz2vhjx0MSV0/4bZPOtMVCR8=; b=sDETuG4rOyeYYk5k6QClZ3vcvZ/Ql8rouWgzWUp/bh/PBSI3IcWwg69a0ahI9450pN SlZYisr+kNFQAmrttWxqkMIxBDiYHxT+O7f4FCBpFg24L4whzgDtRKFEyGrvYXrQ3Fhn P3tXqN7TzgmD2n8n6aKom/Ngngiq7uG8xZmNVkTiI16MC3tzDEfPKsvKgeukoojjyo0M 6gfDQqgUiI4DKPHOjElQOXvGluE4gTA9SjsROqq0PwW1SwJrdeobE2E7GmWkOgmeS5EQ 10U2o0qoxIQavRtVzxWZSDURIPHpvaaAN9cXv5RUiPIYSoyokALhiciFk8PKQgoX12s6 nswg== X-Gm-Message-State: AJaThX57DhN4iqAbUqA/P8WdTgdqn9w5YkPITagRsWEIMQ1SWA951CD9 35KlZsR2ZqyZbue4TpzwGg4PyQ== X-Google-Smtp-Source: ABhQp+QECfMORnHiVQZ0jdyMWqmTAJPYzgXte3ryCwfQbOKRULz2RJGsoJh1kF8EEpZ6ljOLkI7VEA== X-Received: by 10.223.128.162 with SMTP id 31mr489477wrl.258.1510234730420; Thu, 09 Nov 2017 05:38:50 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id m198sm13368498wmg.20.2017.11.09.05.38.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Nov 2017 05:38:49 -0800 (PST) Date: Thu, 9 Nov 2017 13:38:47 +0000 From: Leif Lindholm To: Marcin Wojtas Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org, nadavh@marvell.com, neta@marvell.com, kostap@marvell.com, jinghua@marvell.com, jsd@semihalf.com Message-ID: <20171109133847.5u35pqpqudjyygow@bivouac.eciton.net> References: <1509879339-10516-1-git-send-email-mw@semihalf.com> <1509879339-10516-2-git-send-email-mw@semihalf.com> MIME-Version: 1.0 In-Reply-To: <1509879339-10516-2-git-send-email-mw@semihalf.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [platforms: PATCH 1/4] Marvell/Drivers: MvSpiFlash: Enable using driver in RT 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, 09 Nov 2017 13:34:51 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Nov 05, 2017 at 11:55:36AM +0100, Marcin Wojtas wrote: > This patch applies necessary modifications, which allow to use > MvSpiFlash driver in variable support as a runtime service. > Its type is modified to DXE_RUNTIME_DRIVER, as well as > an event is created, which converts the pointers to the > SpiMasterProtocol and its routines. Please also move the Depex addition here from 4/4. The rest looks fine. / Leif > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Marcin Wojtas > --- > Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c | 58 ++++++++++++++++++-- > Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h | 1 + > Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.inf | 6 +- > 3 files changed, 60 insertions(+), 5 deletions(-) > > diff --git a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c > index 456d9f9..6886d01 100755 > --- a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c > +++ b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.c > @@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > *******************************************************************************/ > #include "MvSpiFlash.h" > > +STATIC EFI_EVENT mMvSpiFlashVirtualAddrChangeEvent; > MARVELL_SPI_MASTER_PROTOCOL *SpiMasterProtocol; > SPI_FLASH_INSTANCE *mSpiFlashInstance; > > @@ -503,6 +504,33 @@ MvSpiFlashInitProtocol ( > return EFI_SUCCESS; > } > > +/** > + Fixup internal data so that EFI can be call in virtual mode. > + Call the passed in Child Notify event and convert any pointers in > + lib to virtual mode. > + > + @param[in] Event The Event that is being processed > + @param[in] Context Event Context > +**/ > +STATIC > +VOID > +EFIAPI > +MvSpiFlashVirtualNotifyEvent ( > + IN EFI_EVENT Event, > + IN VOID *Context > + ) > +{ > + // > + // Convert SpiMasterProtocol callbacks in MvSpiFlashErase and > + // MvSpiFlashWrite required by runtime variable support. > + // > + EfiConvertPointer (0x0, (VOID**)&SpiMasterProtocol->ReadWrite); > + EfiConvertPointer (0x0, (VOID**)&SpiMasterProtocol->Transfer); > + EfiConvertPointer (0x0, (VOID**)&SpiMasterProtocol); > + > + return; > +} > + > EFI_STATUS > EFIAPI > MvSpiFlashEntryPoint ( > @@ -522,8 +550,7 @@ MvSpiFlashEntryPoint ( > return EFI_DEVICE_ERROR; > } > > - mSpiFlashInstance = AllocateZeroPool (sizeof (SPI_FLASH_INSTANCE)); > - > + mSpiFlashInstance = AllocateRuntimeZeroPool (sizeof (SPI_FLASH_INSTANCE)); > if (mSpiFlashInstance == NULL) { > DEBUG((DEBUG_ERROR, "SpiFlash: Cannot allocate memory\n")); > return EFI_OUT_OF_RESOURCES; > @@ -540,10 +567,33 @@ MvSpiFlashEntryPoint ( > NULL > ); > if (EFI_ERROR (Status)) { > - FreePool (mSpiFlashInstance); > DEBUG((DEBUG_ERROR, "SpiFlash: Cannot install SPI flash protocol\n")); > - return EFI_DEVICE_ERROR; > + goto ErrorInstallProto; > + } > + > + // > + // Register for the virtual address change event > + // > + Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, > + TPL_NOTIFY, > + MvSpiFlashVirtualNotifyEvent, > + NULL, > + &gEfiEventVirtualAddressChangeGuid, > + &mMvSpiFlashVirtualAddrChangeEvent); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Failed to register VA change event\n", __FUNCTION__)); > + goto ErrorCreateEvent; > } > > return EFI_SUCCESS; > + > +ErrorCreateEvent: > + gBS->UninstallMultipleProtocolInterfaces (&mSpiFlashInstance->Handle, > + &gMarvellSpiFlashProtocolGuid, > + NULL); > + > +ErrorInstallProto: > + FreePool (mSpiFlashInstance); > + > + return EFI_SUCCESS; > } > diff --git a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h > index f09ff50..f69c562 100755 > --- a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h > +++ b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.h > @@ -42,6 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > #include > #include > #include > +#include > > #include > #include > diff --git a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.inf b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.inf > index 6587f69..200a00c 100644 > --- a/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.inf > +++ b/Platform/Marvell/Drivers/Spi/Devices/MvSpiFlash.inf > @@ -33,7 +33,7 @@ > INF_VERSION = 0x00010005 > BASE_NAME = SpiFlashDxe > FILE_GUID = 49d7fb74-306d-42bd-94c8-c0c54b181dd7 > - MODULE_TYPE = DXE_DRIVER > + MODULE_TYPE = DXE_RUNTIME_DRIVER > VERSION_STRING = 1.0 > ENTRY_POINT = MvSpiFlashEntryPoint > > @@ -54,6 +54,10 @@ > UefiLib > DebugLib > MemoryAllocationLib > + UefiRuntimeLib > + > +[Guids] > + gEfiEventVirtualAddressChangeGuid > > [Protocols] > gMarvellSpiMasterProtocolGuid > -- > 2.7.4 >