Anastasia Klimchuk submitted this change.

View Change


Approvals: build bot (Jenkins): Verified Thomas Heijligen: Looks good to me, approved Edward O'Callaghan: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved
flashrom.c: Add switch for legacy impl of erasure path

As part of a GSoC project to optimise the erasure path in flashrom
a completely different algorithm is used to perform erasure. Therefore
we need a mechanism to have the two implementations side by side to
allow for A/B testing and easy reverts should issue arise.

Change-Id: Ib5660db0067c1c799dcb5c8e83b4a4826b236442
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/71119
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
---
M flashrom.c
1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/flashrom.c b/flashrom.c
index f26bb47..1790ad9 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -34,6 +34,8 @@
#include "hwaccess_physmap.h"
#include "chipdrivers.h"

+static bool use_legacy_erase_path = true;
+
const char flashrom_version[] = FLASHROM_VERSION;

static const struct programmer_entry *programmer = NULL;
@@ -1528,13 +1530,20 @@
* @return 0 on success,
* 1 if all available erase functions failed.
*/
-static int erase_by_layout(struct flashctx *const flashctx)
+static int erase_by_layout_legacy(struct flashctx *const flashctx)
{
struct walk_info info = { 0 };
bool all_skipped = true;
return walk_by_layout(flashctx, &info, &erase_block, &all_skipped);
}

+static int erase_by_layout(struct flashctx *const flashctx)
+{
+ if (use_legacy_erase_path)
+ return erase_by_layout_legacy(flashctx);
+ return 1; /* unimplemented. */
+}
+
static int read_erase_write_block(struct flashctx *const flashctx,
const struct walk_info *const info, const erasefn_t erasefn,
bool *all_skipped)
@@ -1643,7 +1652,7 @@
* @return 0 on success,
* 1 if anything has gone wrong.
*/
-static int write_by_layout(struct flashctx *const flashctx,
+static int write_by_layout_legacy(struct flashctx *const flashctx,
void *const curcontents, const void *const newcontents,
bool *all_skipped)
{
@@ -1653,6 +1662,15 @@
return walk_by_layout(flashctx, &info, read_erase_write_block, all_skipped);
}

+static int write_by_layout(struct flashctx *const flashctx,
+ uint8_t *const curcontents, const uint8_t *const newcontents,
+ bool *all_skipped)
+{
+ if (use_legacy_erase_path)
+ return write_by_layout_legacy(flashctx, curcontents, newcontents, all_skipped);
+ return 1; /* unimplemented. */
+}
+
/**
* @brief Compares the included layout regions with content from a buffer.
*

To view, visit change 71119. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ib5660db0067c1c799dcb5c8e83b4a4826b236442
Gerrit-Change-Number: 71119
Gerrit-PatchSet: 15
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Aarya <aarya.chaumal@gmail.com>
Gerrit-Reviewer: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Felix Singer <felixsinger@posteo.net>
Gerrit-Reviewer: Thomas Heijligen <src@posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged