public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: jlinton <lintonrjeremy@gmail.com>
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 <jeremy.linton@arm.com>
Subject: [PATCH v3 3/4] Platform/RaspberryPi: User control of eMMC2 DMA
Date: Wed, 17 Feb 2021 00:18:08 -0600	[thread overview]
Message-ID: <20210217061809.307479-4-lintonrjeremy@gmail.com> (raw)
In-Reply-To: <20210217061809.307479-1-lintonrjeremy@gmail.com>

From: Jeremy Linton <jeremy.linton@arm.com>

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 <jeremy.linton@arm.com>
Reviewed-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
---
 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 (
   }
 
   Size = sizeof (UINT32);
+  Status = gRT->GetVariable (L"MmcEnableDma",
+                  &gConfigDxeFormSetGuid,
+                  NULL, &Size, &Var32);
+  if (EFI_ERROR (Status)) {
+    Status = PcdSet32S (PcdMmcEnableDma, PcdGet32 (PcdMmcEnableDma));
+    ASSERT_EFI_ERROR (Status);
+  }
+
+  Size = sizeof (UINT32);
   Status = gRT->GetVariable (L"DebugEnableJTAG",
                   &gConfigDxeFormSetGuid,
                   NULL, &Size, &Var32);
@@ -720,6 +729,11 @@ STATIC CONST AML_NAME_OP_REPLACE SsdtNameOpReplace[] = {
   { }
 };
 
+STATIC CONST AML_NAME_OP_REPLACE SsdtEmmcNameOpReplace[] = {
+  { "SDMA", PcdToken (PcdMmcEnableDma) },
+  { }
+};
+
 STATIC CONST NAMESPACE_TABLES SdtTables[] = {
   {
     SIGNATURE_64 ('R', 'P', 'I', 'T', 'H', 'F', 'A', 'N'),
@@ -731,7 +745,7 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] = {
     SIGNATURE_64 ('R', 'P', 'I', '4', 'E', 'M', 'M', 'C'),
     0,
     PcdToken(PcdSdIsArasan),
-    NULL
+    SsdtEmmcNameOpReplace
   },
   {
     SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0),
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/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
   gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz
   gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti
+  gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma
   gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG
   gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes
   gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni b/Platform/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)"
 #string STR_MMC_SD_HS_HELP       #language en-US "Override default 50Mhz"
 
+#string STR_MMC_EMMC_PROMPT      #language en-US "Enable eMMC DMA modes"
+#string STR_MMC_EMMC_PIO         #language en-US "PIO"
+#string STR_MMC_EMMC_DMA         #language en-US "SDMA/ADMA2"
+#string STR_MMC_EMMC_HELP        #language en-US "Enable eMMC DMA modes for OSes that support ACPI _DMA() translations"
 
 /*
  * Display settings.
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Platform/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  = MmcSdHighSpeedMHz,
       guid  = CONFIGDXE_FORM_SET_GUID;
 
+    efivarstore MMC_EMMC_DMA_VARSTORE_DATA,
+      attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+      name  = MmcEnableDma,
+      guid  = CONFIGDXE_FORM_SET_GUID;
+
     efivarstore DEBUG_ENABLE_JTAG_VARSTORE_DATA,
       attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
       name  = DebugEnableJTAG,
@@ -275,6 +280,18 @@ formset
              maximum = 100,
              default = 50,
         endnumeric;
+#if (RPI_MODEL == 4)
+        grayoutif ideqval SdIsArasan.Routing == 1;
+        oneof varid = MmcEnableDma.EnableDma,
+            prompt      = STRING_TOKEN(STR_MMC_EMMC_PROMPT),
+            help        = STRING_TOKEN(STR_MMC_EMMC_HELP),
+            flags       = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
+            option text = STRING_TOKEN(STR_MMC_EMMC_PIO), value = 0, flags = DEFAULT;
+            option text = STRING_TOKEN(STR_MMC_EMMC_DMA), value = 1, flags = 0;
+        endoneof;
+        endif;
+#endif
+
     endform;
 
     form formid = 0x1004,
diff --git a/Platform/RaspberryPi/Include/ConfigVars.h b/Platform/RaspberryPi/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;
 } MMC_SD_HS_MHZ_VARSTORE_DATA;
 
+typedef struct {
+  /*
+   * 0 - eMMC PIO mode
+   * 1 - eMMC DMA mode
+   */
+  UINT32 EnableDma;
+} MMC_EMMC_DMA_VARSTORE_DATA;
+
 #endif /* CONFIG_VARS_H */
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"MmcSdDefaultSpeedMHz"|gConfigDxeFormSetGuid|0x0|25
   gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|L"MmcSdHighSpeedMHz"|gConfigDxeFormSetGuid|0x0|50
   gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|L"MmcDisableMulti"|gConfigDxeFormSetGuid|0x0|0
+  gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|L"MmcEnableDma"|gConfigDxeFormSetGuid|0x0|0
 
   #
   # Debug-related.
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"MmcSdDefaultSpeedMHz"|gConfigDxeFormSetGuid|0x0|25
   gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|L"MmcSdHighSpeedMHz"|gConfigDxeFormSetGuid|0x0|50
   gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|L"MmcDisableMulti"|gConfigDxeFormSetGuid|0x0|0
+  gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|L"MmcEnableDma"|gConfigDxeFormSetGuid|0x0|0
 
   #
   # Debug-related.
diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/RaspberryPi.dec
index 10723036aa..08135717ed 100644
--- a/Platform/RaspberryPi/RaspberryPi.dec
+++ b/Platform/RaspberryPi/RaspberryPi.dec
@@ -69,3 +69,4 @@
   gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|0|UINT32|0x0000001C
   gRaspberryPiTokenSpaceGuid.PcdFanTemp|0|UINT32|0x0000001D
   gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay|0|UINT32|0x0000001E
+  gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|0|UINT32|0x0000001F
-- 
2.13.7


  parent reply	other threads:[~2021-02-17  6:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-17  6:18 [PATCH v3 0/4] RPi: SD/WiFi ACPI updates jlinton
2021-02-17  6:18 ` [PATCH v3 1/4] Platform/RaspberryPi: Add Negative table check jlinton
2021-02-17  6:18 ` [PATCH v3 2/4] Platform/RaspberryPi/Acpitables: Add eMMC2 device and tweak Arasan jlinton
2021-02-17  6:18 ` jlinton [this message]
2021-02-17  6:18 ` [PATCH v3 4/4] Platform/RaspberryPi: Invert default Arasan, eMMC2 routing jlinton
2021-02-17  6:56 ` [PATCH v3 0/4] RPi: SD/WiFi ACPI updates Ard Biesheuvel
2021-02-17  7:30   ` Jeremy Linton
2021-02-17  7:55     ` Ard Biesheuvel
2021-02-17  7:59       ` Andrei Warkentin
2021-02-17  8:08         ` Ard Biesheuvel
2021-02-17 17:16       ` [edk2-devel] " Jeremy Linton
2021-02-17 17:57         ` Ard Biesheuvel
2021-02-18 16:47           ` Jeremy Linton
2021-02-18 16:52             ` Ard Biesheuvel
2021-02-18 19:44               ` Jeremy Linton
2021-02-18 18:49 ` Ard Biesheuvel
2021-02-19 16:51   ` Jeremy Linton
2021-02-20 14:38     ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210217061809.307479-4-lintonrjeremy@gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox