From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c0b::241; helo=mail-it0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it0-x241.google.com (mail-it0-x241.google.com [IPv6:2607:f8b0:4001:c0b::241]) (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 9C70E2112294C for ; Thu, 6 Sep 2018 07:04:20 -0700 (PDT) Received: by mail-it0-x241.google.com with SMTP id j81-v6so14905052ite.0 for ; Thu, 06 Sep 2018 07:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=6uomr1mTumoiTt9T/Rm6HfIL+nTXBmaG3P8s8F5+TC8=; b=giT2P7amA2rZAvYE9selVZanPQgyLehcyAGwY3cPm241/lc+TCO4zI4ogZp4GrtOfA L6YFUl8JZFWWMK+x4rR8QhdTqr4Z01Z6EkmeMHJcSF+hLDC5uN17t8Palb4vMWJgHJkB BoEtiAFjzA47axPvfNB9Cf4+uDk+7IuwGbloM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=6uomr1mTumoiTt9T/Rm6HfIL+nTXBmaG3P8s8F5+TC8=; b=PRqsMZtiqPxAxyk6DB/pIMQRl9XAdyNi2icdlFe9k/OnIHFeiqbyYpmFCJJ6QRwlv3 n3psrByf0hGkMGjkEuvuKviyt1QBHCPpEdRMVeEhsx0jN9bQvOFZI+IJo+TWkR9df4Do 6U/y8LDm1qb6JnnTWj9DxqPkuhCh7Rh4DXcC1aJcFQMf3sxMQd2FRNIKlPru5m0OHPNK oFvjBkTYXaDc+I+C1w+lRRkJE++8Lt5CQODZRMpo468gbo5OQfWmDhVKJDvwmVsa9DyT hc6TxYux2rbDqI4rpNNZIkueGDmlb0494rK83VEafBCl8GsXoS5EMo8KMmdwY/DT2aWX fyMg== X-Gm-Message-State: APzg51DnPsppNz83nGS4R348esNrc5vWCksfZHZ4NcOSiLLB9wKN08nT uhQlmA1B4FyVqd6kMDPcVQc31yrRkcl8mFdseca8QkjpOD97lg== X-Google-Smtp-Source: ANB0VdYFIlGYNiJ+UQNsEX0Co6UtPKYwphzJ8ij/S9VqfJsvcxSOMqJTQlq+rKBx5p+RuvKZkF9CZuz/Vfe2Y5hf5qQ= X-Received: by 2002:a24:8309:: with SMTP id d9-v6mr2630818ite.123.1536242659503; Thu, 06 Sep 2018 07:04:19 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:1c06:0:0:0:0:0 with HTTP; Thu, 6 Sep 2018 07:04:19 -0700 (PDT) In-Reply-To: <1535950443-27106-2-git-send-email-mw@semihalf.com> References: <1535950443-27106-1-git-send-email-mw@semihalf.com> <1535950443-27106-2-git-send-email-mw@semihalf.com> From: Ard Biesheuvel Date: Thu, 6 Sep 2018 16:04:19 +0200 Message-ID: To: Marcin Wojtas Cc: "edk2-devel@lists.01.org" , Leif Lindholm , Nadav Haklai , =?UTF-8?B?SmFuIETEhWJyb8Wb?= , Grzegorz Jaszczyk , Tomasz Michalec Subject: Re: [platforms: PATCH 1/7] Silicon/SynQuacer/PlatformDxe: Modify initialization of SdMmcOverride X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Sep 2018 14:04:20 -0000 Content-Type: text/plain; charset="UTF-8" On 3 September 2018 at 06:53, Marcin Wojtas wrote: > From: Tomasz Michalec > > This patch changes way the EDKII_SD_MMC_OVERRIDE protocol > sturcture is allocated. Using AllocateZeroPool and then > seting callbacks in the structure allow driver to be immune to > adding new callbacks in SdMmcOveride protocol in future. > What is the point of this patch? Statically allocating the structure will zero initialize the members that are not initialized explicitly, but only the members that are known to exist at compile time. I guess the idea of this patch is to work around the latter limitation, but unfortunately, using sizeof(EDKII_SD_MMC_OVERRIDE) puts you in the exact same situation. This is the reason I added the version field. New hooks should only be added after incrementing the version, and calling the new hooks should only occur if the runtime version of the protocol implementation is greater than or equal to the version where those hooks were first introduced. > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Marcin Wojtas > --- > Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c | 20 +++++++++++++------- > 1 file changed, 13 insertions(+), 7 deletions(-) > > diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c > index e0987c9..1ad8b88 100644 > --- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c > +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c > @@ -59,6 +59,8 @@ > > STATIC EFI_HANDLE mSdMmcControllerHandle; > > +STATIC EDKII_SD_MMC_OVERRIDE *mSdMmcOverride; > + > STATIC EFI_ACPI_DESCRIPTION_HEADER *mSsdt; > STATIC UINTN mSsdtSize; > STATIC VOID *mEventRegistration; > @@ -180,12 +182,6 @@ SynQuacerSdMmcNotifyPhase ( > return EFI_SUCCESS; > } > > -STATIC EDKII_SD_MMC_OVERRIDE mSdMmcOverride = { > - EDKII_SD_MMC_OVERRIDE_PROTOCOL_VERSION, > - SynQuacerSdMmcCapability, > - SynQuacerSdMmcNotifyPhase, > -}; > - > STATIC > VOID > EFIAPI > @@ -255,10 +251,20 @@ RegisterEmmc ( > SYNQUACER_EMMC_BASE, SYNQUACER_EMMC_BASE_SZ); > ASSERT_EFI_ERROR (Status); > > + mSdMmcOverride = AllocateZeroPool (sizeof (EDKII_SD_MMC_OVERRIDE)); > + if (mSdMmcOverride == NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", __FUNCTION__)); > + return EFI_OUT_OF_RESOURCES; > + } > + > + mSdMmcOverride->Version = EDKII_SD_MMC_OVERRIDE_PROTOCOL_VERSION; > + mSdMmcOverride->Capability = SynQuacerSdMmcCapability; > + mSdMmcOverride->NotifyPhase = SynQuacerSdMmcNotifyPhase; > + > Handle = NULL; > Status = gBS->InstallProtocolInterface (&Handle, > &gEdkiiSdMmcOverrideProtocolGuid, > - EFI_NATIVE_INTERFACE, (VOID **)&mSdMmcOverride); > + EFI_NATIVE_INTERFACE, mSdMmcOverride); > ASSERT_EFI_ERROR (Status); > > return EFI_SUCCESS; > -- > 2.7.4 >