From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.4150.1613542707845663894 for ; Tue, 16 Feb 2021 22:18:28 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=softfail (domain: gmail.com, ip: 217.140.110.172, mailfrom: lintonrjeremy@gmail.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 79CEF31B; Tue, 16 Feb 2021 22:18:27 -0800 (PST) Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2B0B43F73B; Tue, 16 Feb 2021 22:18:27 -0800 (PST) From: jlinton To: devel@edk2.groups.io Cc: pete@akeo.ie, awarkentin@vmware.com, samer.el-haj-mahmoud@arm.com, leif@nuviainc.com, ardb+tianocore@kernel.org, Jeremy Linton Subject: [PATCH v3 3/4] Platform/RaspberryPi: User control of eMMC2 DMA Date: Wed, 17 Feb 2021 00:18:08 -0600 Message-Id: <20210217061809.307479-4-lintonrjeremy@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210217061809.307479-1-lintonrjeremy@gmail.com> References: <20210217061809.307479-1-lintonrjeremy@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jeremy Linton DMA translation on the eMMC2 vary based on SoC, and this is made worse by the poor _DMA support in Linux. For now the "safe" option is to simply run the eMMC2 controller in PIO mode. More advanced users or !Linux operating systems may choose to enable this to gain a perf boost. Signed-off-by: Jeremy Linton Reviewed-by: Pete Batard Reviewed-by: Andrei Warkentin --- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 16 +++++++++++++= ++- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf | 1 + Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni | 4 ++++ Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 17 +++++++++++++= ++++ Platform/RaspberryPi/Include/ConfigVars.h | 8 ++++++++ Platform/RaspberryPi/RPi3/RPi3.dsc | 1 + Platform/RaspberryPi/RPi4/RPi4.dsc | 1 + Platform/RaspberryPi/RaspberryPi.dec | 1 + 8 files changed, 48 insertions(+), 1 deletion(-) diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/= RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index 402a2996b3..22f86d4d44 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -336,6 +336,15 @@ SetupVariables ( }=0D =0D Size =3D sizeof (UINT32);=0D + Status =3D gRT->GetVariable (L"MmcEnableDma",=0D + &gConfigDxeFormSetGuid,=0D + NULL, &Size, &Var32);=0D + if (EFI_ERROR (Status)) {=0D + Status =3D PcdSet32S (PcdMmcEnableDma, PcdGet32 (PcdMmcEnableDma));=0D + ASSERT_EFI_ERROR (Status);=0D + }=0D +=0D + Size =3D sizeof (UINT32);=0D Status =3D gRT->GetVariable (L"DebugEnableJTAG",=0D &gConfigDxeFormSetGuid,=0D NULL, &Size, &Var32);=0D @@ -720,6 +729,11 @@ STATIC CONST AML_NAME_OP_REPLACE SsdtNameOpReplace[] = =3D { { }=0D };=0D =0D +STATIC CONST AML_NAME_OP_REPLACE SsdtEmmcNameOpReplace[] =3D {=0D + { "SDMA", PcdToken (PcdMmcEnableDma) },=0D + { }=0D +};=0D +=0D STATIC CONST NAMESPACE_TABLES SdtTables[] =3D {=0D {=0D SIGNATURE_64 ('R', 'P', 'I', 'T', 'H', 'F', 'A', 'N'),=0D @@ -731,7 +745,7 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] =3D { SIGNATURE_64 ('R', 'P', 'I', '4', 'E', 'M', 'M', 'C'),=0D 0,=0D PcdToken(PcdSdIsArasan),=0D - NULL=0D + SsdtEmmcNameOpReplace=0D },=0D {=0D SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0),=0D diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platfor= m/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf index 544e3b3e10..d51e54e010 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf @@ -84,6 +84,7 @@ gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz=0D gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz=0D gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti=0D + gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma=0D gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG=0D gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes=0D gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot=0D diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni b/Plat= form/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni index 2afe8f32ae..466fa852cb 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni @@ -94,6 +94,10 @@ #string STR_MMC_SD_HS_PROMPT #language en-US "SD High Speed (MHz)"=0D #string STR_MMC_SD_HS_HELP #language en-US "Override default 50Mhz"= =0D =0D +#string STR_MMC_EMMC_PROMPT #language en-US "Enable eMMC DMA modes"=0D +#string STR_MMC_EMMC_PIO #language en-US "PIO"=0D +#string STR_MMC_EMMC_DMA #language en-US "SDMA/ADMA2"=0D +#string STR_MMC_EMMC_HELP #language en-US "Enable eMMC DMA modes fo= r OSes that support ACPI _DMA() translations"=0D =0D /*=0D * Display settings.=0D diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Plat= form/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr index de5e43471a..cc7a09cfb7 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr @@ -96,6 +96,11 @@ formset name =3D MmcSdHighSpeedMHz,=0D guid =3D CONFIGDXE_FORM_SET_GUID;=0D =0D + efivarstore MMC_EMMC_DMA_VARSTORE_DATA,=0D + attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME= _ACCESS | EFI_VARIABLE_NON_VOLATILE,=0D + name =3D MmcEnableDma,=0D + guid =3D CONFIGDXE_FORM_SET_GUID;=0D +=0D efivarstore DEBUG_ENABLE_JTAG_VARSTORE_DATA,=0D attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME= _ACCESS | EFI_VARIABLE_NON_VOLATILE,=0D name =3D DebugEnableJTAG,=0D @@ -275,6 +280,18 @@ formset maximum =3D 100,=0D default =3D 50,=0D endnumeric;=0D +#if (RPI_MODEL =3D=3D 4)=0D + grayoutif ideqval SdIsArasan.Routing =3D=3D 1;=0D + oneof varid =3D MmcEnableDma.EnableDma,=0D + prompt =3D STRING_TOKEN(STR_MMC_EMMC_PROMPT),=0D + help =3D STRING_TOKEN(STR_MMC_EMMC_HELP),=0D + flags =3D NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,= =0D + option text =3D STRING_TOKEN(STR_MMC_EMMC_PIO), value =3D 0, f= lags =3D DEFAULT;=0D + option text =3D STRING_TOKEN(STR_MMC_EMMC_DMA), value =3D 1, f= lags =3D 0;=0D + endoneof;=0D + endif;=0D +#endif=0D +=0D endform;=0D =0D form formid =3D 0x1004,=0D diff --git a/Platform/RaspberryPi/Include/ConfigVars.h b/Platform/Raspberry= Pi/Include/ConfigVars.h index c185bfe28b..142317985a 100644 --- a/Platform/RaspberryPi/Include/ConfigVars.h +++ b/Platform/RaspberryPi/Include/ConfigVars.h @@ -135,4 +135,12 @@ typedef struct { UINT32 MHz;=0D } MMC_SD_HS_MHZ_VARSTORE_DATA;=0D =0D +typedef struct {=0D + /*=0D + * 0 - eMMC PIO mode=0D + * 1 - eMMC DMA mode=0D + */=0D + UINT32 EnableDma;=0D +} MMC_EMMC_DMA_VARSTORE_DATA;=0D +=0D #endif /* CONFIG_VARS_H */=0D diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3= /RPi3.dsc index 530b42796a..107cbda297 100644 --- a/Platform/RaspberryPi/RPi3/RPi3.dsc +++ b/Platform/RaspberryPi/RPi3/RPi3.dsc @@ -470,6 +470,7 @@ gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|L"MmcSdDefaultSpeedMH= z"|gConfigDxeFormSetGuid|0x0|25=0D gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|L"MmcSdHighSpeedMHz"|gCo= nfigDxeFormSetGuid|0x0|50=0D gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|L"MmcDisableMulti"|gConfig= DxeFormSetGuid|0x0|0=0D + gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|L"MmcEnableDma"|gConfigDxeFor= mSetGuid|0x0|0=0D =0D #=0D # Debug-related.=0D diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4= /RPi4.dsc index 5f8452aa0b..9962df0076 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.dsc +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc @@ -481,6 +481,7 @@ gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|L"MmcSdDefaultSpeedMH= z"|gConfigDxeFormSetGuid|0x0|25=0D gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|L"MmcSdHighSpeedMHz"|gCo= nfigDxeFormSetGuid|0x0|50=0D gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|L"MmcDisableMulti"|gConfig= DxeFormSetGuid|0x0|0=0D + gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|L"MmcEnableDma"|gConfigDxeFor= mSetGuid|0x0|0=0D =0D #=0D # Debug-related.=0D diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/Ra= spberryPi.dec index 10723036aa..08135717ed 100644 --- a/Platform/RaspberryPi/RaspberryPi.dec +++ b/Platform/RaspberryPi/RaspberryPi.dec @@ -69,3 +69,4 @@ gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|0|UINT32|0x0000001C=0D gRaspberryPiTokenSpaceGuid.PcdFanTemp|0|UINT32|0x0000001D=0D gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay|0|UINT32|0x0000001E=0D + gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|0|UINT32|0x0000001F=0D --=20 2.13.7