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.43795.1612220029594447957 for ; Mon, 01 Feb 2021 14:53:49 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: jeremy.linton@arm.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 3FF521516; Mon, 1 Feb 2021 14:53:49 -0800 (PST) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2DA883F718; Mon, 1 Feb 2021 14:53:49 -0800 (PST) From: "Jeremy Linton" 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 v2 3/4] Platform/RaspberryPi: User control of eMMC2 DMA Date: Mon, 1 Feb 2021 16:53:42 -0600 Message-Id: <20210201225343.2001835-4-jeremy.linton@arm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210201225343.2001835-1-jeremy.linton@arm.com> References: <20210201225343.2001835-1-jeremy.linton@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 --- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 16 +++++++++++++= ++- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf | 1 + Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni | 5 +++++ 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, 49 insertions(+), 1 deletion(-) diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/= RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index 7f26f7b4be..1b8b360ddc 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -346,6 +346,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 @@ -730,6 +739,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 @@ -741,7 +755,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..6abccc1fdb 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni @@ -94,6 +94,11 @@ #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 OS's that support ACPI _DMA() translations"=0D +=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