From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by mx.groups.io with SMTP id smtpd.web11.3203.1575302697026857144 for ; Mon, 02 Dec 2019 08:04:57 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=W16/X2gH; spf=pass (domain: linaro.org, ip: 209.85.128.67, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wm1-f67.google.com with SMTP id p17so371360wma.1 for ; Mon, 02 Dec 2019 08:04:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=KQ9oXg2J3u4QDr9+E0zoMwOlPi0uZ7LBUjfBokEE3sM=; b=W16/X2gHkFhAitrzAyS+1KTxTfJ5dYOh+NVlZtxK38ObgXvs+nYOAC4tvcr4Mt9nz9 Up5fFXpL46j6AX4GMTNlvp5d4ZzOFYMHyX5y0Pk0cHiSEEY5mm/BWQlIRRGANeVG3NGa nq8IEJIwp4yUYAHekTn/nA/QiMpAQafEuTA7hUYD4t0jngwV4beVi/c3oDpx87cPMMq0 GQR3Cc/tHDY0kObqYZBE24knThpDOV7O1vaB8Ou7g0RNGDAbkgIJwBigKe3B1zuL8+op iUA7fwkynrj1PZMagOCp44JHS8D/koDcboenBYPBW3UUR28PMvwhr+j1UGpQHq0I1JxK f/kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=KQ9oXg2J3u4QDr9+E0zoMwOlPi0uZ7LBUjfBokEE3sM=; b=M0ItzZCwFJAzj4zL873Z7UDRsb5qsbKICLQcjVK7qjGtry3Qv+sGQT640iDPFgsviP ydQpqZNEHtm4771iC1Jo5+yJHQ9lKF7NxxHTIoO6UL96kf1C4qkGPwGsfichbGrW9IVo CLjyE1uJ96Z2EAgxdqus2iceQtX9kfmqfPdAriA1nOirrw1ULxZCYp1J15APSTj5d8vF XrEVLMUdSPKiIhs2kQF/Zv0PSjCxVkoLk5gGp/URbxOlPFcCmJCtP8Vk/vIxj+VriHAS bf1bpONRx1VSajbgs6bQfE/PI8mthM6Pgy4U683WltMzzGYdlbXYn+BnZYNnMO+LD5sr GHqw== X-Gm-Message-State: APjAAAXxWa8q2xYyIrq3GlpOoaNq/SZcsyfhDd18TD2c8vlGbPuB2+Jz O0vyhMxUpAIiQwnI5yNKGmfDSK0SNn8wqw8crKEeAZy2+pvWjg== X-Google-Smtp-Source: APXvYqyc+PuVSYpngGegkyNtPgujV4xqoXs+v9SfcFsRNvDLWL0semauRVs/3DCqW/DZeWWZtUq5QWPMID284dCBv10= X-Received: by 2002:a1c:49c3:: with SMTP id w186mr29528996wma.53.1575302695511; Mon, 02 Dec 2019 08:04:55 -0800 (PST) MIME-Version: 1.0 References: <20191129104716.819-1-ard.biesheuvel@linaro.org> <20191129104716.819-2-ard.biesheuvel@linaro.org> <83f215c8-1608-7f40-48bf-6f1f12610c5b@redhat.com> In-Reply-To: <83f215c8-1608-7f40-48bf-6f1f12610c5b@redhat.com> From: "Ard Biesheuvel" Date: Mon, 2 Dec 2019 16:04:49 +0000 Message-ID: Subject: Re: [edk2-devel] [PATCH edk2-platforms 1/2] Silicon/SynQuacer/PlatformDxe: move EMMC SSDT handling to core routine To: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Cc: edk2-devel-groups-io , Leif Lindholm Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, 2 Dec 2019 at 10:26, Philippe Mathieu-Daud=C3=A9 wrote: > > On 11/29/19 11:47 AM, Ard Biesheuvel via Groups.Io wrote: > > In preparation of adding support for describing the presence of OP-TEE > > via a SSDT ACPI table, refactor the existing code so we will be able to > > reuse it more easily. > > > > Signed-off-by: Ard Biesheuvel > > --- > > Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c | 55 --= --------------- > > Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c | 65 ++= ++++++++++++++++++ > > 2 files changed, 65 insertions(+), 55 deletions(-) > > > > diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c b/S= ilicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c > > index 0d0e5edad901..90b67152c768 100644 > > --- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c > > +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c > > @@ -53,10 +53,6 @@ > > > > STATIC EFI_HANDLE mSdMmcControllerHandle; > > > > -STATIC EFI_ACPI_DESCRIPTION_HEADER *mSsdt; > > -STATIC UINTN mSsdtSize; > > -STATIC VOID *mEventRegistration; > > - > > /** > > > > Override function for SDHCI capability bits > > @@ -185,31 +181,6 @@ STATIC EDKII_SD_MMC_OVERRIDE mSdMmcOverride =3D { > > SynQuacerSdMmcNotifyPhase, > > }; > > > > -STATIC > > -VOID > > -EFIAPI > > -InstallAcpiTable ( > > - IN EFI_EVENT Event, > > - IN VOID* Context > > - ) > > -{ > > - UINTN TableKey; > > - EFI_STATUS Status; > > - EFI_ACPI_TABLE_PROTOCOL *AcpiTable; > > - > > - Status =3D gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, > > - (VOID **)&AcpiTable); > > - if (EFI_ERROR (Status)) { > > - return; > > - } > > - > > - Status =3D AcpiTable->InstallAcpiTable (AcpiTable, mSsdt, mSsdtSize,= &TableKey); > > - if (EFI_ERROR (Status)) { > > - DEBUG ((DEBUG_WARN, "%a: failed to install SSDT table for eMMC - %= r\n", > > - __FUNCTION__, Status)); > > - } > > -} > > - > > EFI_STATUS > > EFIAPI > > RegisterEmmc ( > > @@ -218,32 +189,6 @@ RegisterEmmc ( > > { > > EFI_STATUS Status; > > EFI_HANDLE Handle; > > - UINTN Index; > > - > > - if (mHiiSettings->AcpiPref =3D=3D ACPIPREF_ACPI) { > > - // > > - // Load the SSDT table from a raw section in this FFS file. > > - // > > - for (Index =3D 0;; Index++) { > > - Status =3D GetSectionFromFv (&gEfiCallerIdGuid, EFI_SECTION_RAW,= Index, > > - (VOID **)&mSsdt, &mSsdtSize); > > - if (EFI_ERROR (Status)) { > > - break; > > - } > > - > > - if (mSsdt->OemTableId !=3D EMMC_TABLE_ID) { > > - continue; > > - } > > - > > - // > > - // Register for the ACPI table protocol > > - // > > - EfiCreateProtocolNotifyEvent (&gEfiAcpiTableProtocolGuid, TPL_CA= LLBACK, > > - InstallAcpiTable, NULL, &mEventRegistration); > > - > > - break; > > - } > > - } > > > > Status =3D RegisterNonDiscoverableMmioDevice ( > > NonDiscoverableDeviceTypeSdhci, > > diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDx= e.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c > > index 73cc560fa8d8..c9cc37dd2478 100644 > > --- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c > > +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c > > @@ -113,6 +113,11 @@ STATIC EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR mI2c1Desc= [] =3D { > > } > > }; > > > > +STATIC EFI_ACPI_DESCRIPTION_HEADER *mEmmcSsdt; > > +STATIC UINTN mEmmcSsdtSize; > > + > > +STATIC VOID *mAcpiTableEventRegistration; > > + > > STATIC > > EFI_STATUS > > RegisterDevice ( > > @@ -256,6 +261,32 @@ EnableSettingsForm ( > > return InstallHiiPages (); > > } > > > > +STATIC > > +VOID > > +EFIAPI > > +InstallAcpiTables ( > > Maybe rename as InstallEmmcSsdtAcpiTables? > The next patch adds a caller that uses it for another SSDT, but I take your point - it could be more precise. > Regardless the name chosen: > Reviewed-by: Philippe Mathieu-Daude > Thanks, > > + IN EFI_EVENT Event, > > + IN VOID* Context > > + ) > > +{ > > + UINTN TableKey; > > + EFI_STATUS Status; > > + EFI_ACPI_TABLE_PROTOCOL *AcpiTable; > > + > > + Status =3D gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, > > + (VOID **)&AcpiTable); > > + if (EFI_ERROR (Status)) { > > + return; > > + } > > + > > + Status =3D AcpiTable->InstallAcpiTable (AcpiTable, mEmmcSsdt, mEmmcS= sdtSize, > > + &TableKey); > > + if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_WARN, "%a: failed to install SSDT table for eMMC - %= r\n", > > + __FUNCTION__, Status)); > > + } > > +} > > + > > EFI_STATUS > > EFIAPI > > PlatformDxeEntryPoint ( > > @@ -267,6 +298,9 @@ PlatformDxeEntryPoint ( > > VOID *Dtb; > > UINTN DtbSize; > > EFI_HANDLE Handle; > > + EFI_ACPI_DESCRIPTION_HEADER *Ssdt; > > + UINTN SsdtSize; > > + UINTN Index; > > > > mHiiSettingsVal =3D PcdGet64 (PcdPlatformSettings); > > mHiiSettings =3D (SYNQUACER_PLATFORM_VARSTORE_DATA *)&mHiiSettingsV= al; > > @@ -344,5 +378,36 @@ PlatformDxeEntryPoint ( > > ASSERT_EFI_ERROR (Status); > > } > > > > + if (mHiiSettings->AcpiPref =3D=3D ACPIPREF_ACPI) { > > + // > > + // Load the SSDT tables from a raw section in this FFS file. > > + // > > + for (Index =3D 0;; Index++) { > > + Status =3D GetSectionFromFv (&gEfiCallerIdGuid, EFI_SECTION_RAW,= Index, > > + (VOID **)&Ssdt, &SsdtSize); > > + if (EFI_ERROR (Status)) { > > + break; > > + } > > + > > + switch (Ssdt->OemTableId) { > > + case EMMC_TABLE_ID: > > + if (mHiiSettings->EnableEmmc !=3D EMMC_ENABLED) { > > + break; > > + } > > + mEmmcSsdt =3D Ssdt; > > + mEmmcSsdtSize =3D SsdtSize; > > + break; > > + } > > + } > > + > > + if (mEmmcSsdtSize > 0) { > > + // > > + // Register for the ACPI table protocol if we found any SSDTs to= install > > + // > > + EfiCreateProtocolNotifyEvent (&gEfiAcpiTableProtocolGuid, TPL_CA= LLBACK, > > + InstallAcpiTables, NULL, &mAcpiTableEventRegistration); > > + } > > + } > > + > > return EFI_SUCCESS; > > } > > >