diff options
author | Suraj Jitindar Singh <sjitindarsingh@gmail.com> | 2017-09-21 14:29:06 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2017-10-06 01:21:02 -0500 |
commit | b987d1a97632d19e50e1a4858408444c1ae01351 (patch) | |
tree | c2c00ea6bd9edecf7f6f7ce0887532ca12e5fb47 /external | |
parent | 25e041a577616f80b7bf0553a50043e422f0296c (diff) | |
download | skiboot-b987d1a97632d19e50e1a4858408444c1ae01351.zip skiboot-b987d1a97632d19e50e1a4858408444c1ae01351.tar.gz skiboot-b987d1a97632d19e50e1a4858408444c1ae01351.tar.bz2 |
external/gard: Clear entire guard partition instead of entry by entry
When using the current implementation of the gard tool to ecc clear the
entire GUARD partition it is done one gard record at a time. While this
may be ok when accessing the actual flash this is very slow when done
from the host over the mbox protocol (on the order of 4 minutes) because
the bmc side is required to do many read, erase, writes under the hood.
Fix this by rewriting the gard tool reset_partition() function. Now we
allocate all the erased guard entries and (if required) apply ecc to the
entire buffer. Then we can do one big erase and write of the entire
partition. This reduces the time to clear the guard partition to on the
order of 4 seconds.
Reported-by: Pridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com>
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external')
-rw-r--r-- | external/gard/gard.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/external/gard/gard.c b/external/gard/gard.c index 5dc14c5..88916c2 100644 --- a/external/gard/gard.c +++ b/external/gard/gard.c @@ -454,24 +454,31 @@ static int do_clear_i(struct gard_ctx *ctx, int pos, struct gard_record *gard, v static int reset_partition(struct gard_ctx *ctx) { - int i, rc; - struct gard_record gard; - memset(&gard, 0xFF, sizeof(gard)); + int len, num_entries, rc = 0; + struct gard_record *gard; + + num_entries = ctx->gard_data_len / sizeof_gard(ctx); + len = num_entries * sizeof(*gard); + gard = malloc(len); + if (!gard) { + return FLASH_ERR_MALLOC_FAILED; + } + memset(gard, 0xFF, len); rc = blocklevel_smart_erase(ctx->bl, ctx->gard_data_pos, ctx->gard_data_len); if (rc) { fprintf(stderr, "Couldn't erase the gard partition. Bailing out\n"); - return rc; + goto out; } - for (i = 0; i + sizeof_gard(ctx) < ctx->gard_data_len; i += sizeof_gard(ctx)) { - rc = blocklevel_write(ctx->bl, ctx->gard_data_pos + i, &gard, sizeof(gard)); - if (rc) { - fprintf(stderr, "Couldn't reset the entire gard partition. Bailing out\n"); - return rc; - } + rc = blocklevel_write(ctx->bl, ctx->gard_data_pos, gard, len); + if (rc) { + fprintf(stderr, "Couldn't reset the entire gard partition. Bailing out\n"); + goto out; } - return 0; +out: + free(gard); + return rc; } static int do_clear(struct gard_ctx *ctx, int argc, char **argv) |