aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/vpd/vpd_cbmem.c
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2020-05-26 19:03:31 -0700
committerPatrick Georgi <pgeorgi@google.com>2020-05-28 09:46:17 +0000
commit5f17458cfbe90171bf6d20d9c36470ebbfb3842f (patch)
treeb711f3d50410500df9be7141529dd43b6140652d /src/drivers/vpd/vpd_cbmem.c
parent4cabf789fd7615318cd0552e490c252ba0f142a6 (diff)
drivers/vpd: Fix VPD speed regressions on non-x86 devices
CB:34634 expanded the VPD code to also be usable from romstage, shuffling a few things around and adding some extra infrastructure in the process. Unfortunately, the changes seem to have only been written with x86 devices in mind and make coreboot always load the whole VPD FMAP section (not just the used part) on devices where rdev_mmap() is not a no-op. This patch rewrites the VPD code to be based on region_device structures that only represent the VPD area actually used (rather than the whole FMAP section), and that only get mapped when accessed. (It would be even better to pull this concept into the VPD decoder itself, but since that is taken from third-party code and accesses in early stages aren't very common, let's not go there for now.) It also moves the copying into CBMEM to romstage so that late romstage accesses can already benefit from it, and makes early decoding available in all stages because at this point, why not. Also fix a long-standing bug where the 'consumed' counter was not reset between vpd_decode_string() calls to the RO and the RW VPD. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I55a103180b290c1563e35a25496188b6a82e49ff Reviewed-on: https://review.coreboot.org/c/coreboot/+/41757 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Diffstat (limited to 'src/drivers/vpd/vpd_cbmem.c')
-rw-r--r--src/drivers/vpd/vpd_cbmem.c81
1 files changed, 0 insertions, 81 deletions
diff --git a/src/drivers/vpd/vpd_cbmem.c b/src/drivers/vpd/vpd_cbmem.c
deleted file mode 100644
index eadda525d6..0000000000
--- a/src/drivers/vpd/vpd_cbmem.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
-
-#include <console/console.h>
-#include <cbmem.h>
-#include <fmap.h>
-#include <string.h>
-#include <timestamp.h>
-
-#include "vpd_tables.h"
-#include "vpd.h"
-
-/* Currently we only support Google VPD 2.0, which has a fixed offset. */
-enum {
- CROSVPD_CBMEM_MAGIC = 0x43524f53,
- CROSVPD_CBMEM_VERSION = 0x0001,
-};
-
-struct vpd_cbmem {
- uint32_t magic;
- uint32_t version;
- uint32_t ro_size;
- uint32_t rw_size;
- uint8_t blob[0];
- /* The blob contains both RO and RW data. It starts with RO (0 ..
- * ro_size) and then RW (ro_size .. ro_size+rw_size).
- */
-};
-
-static void cbmem_add_cros_vpd(int is_recovery)
-{
- struct vpd_cbmem *cbmem;
- const struct vpd_blob *blob;
-
- timestamp_add_now(TS_START_COPYVPD);
-
- blob = vpd_load_blob();
-
- /* Return if no VPD at all */
- if (blob->ro_size == 0 && blob->rw_size == 0)
- return;
-
- cbmem = cbmem_add(CBMEM_ID_VPD, sizeof(*cbmem) + blob->ro_size +
- blob->rw_size);
- if (!cbmem) {
- printk(BIOS_ERR, "%s: Failed to allocate CBMEM (%u+%u).\n",
- __func__, blob->ro_size, blob->rw_size);
- return;
- }
-
- cbmem->magic = CROSVPD_CBMEM_MAGIC;
- cbmem->version = CROSVPD_CBMEM_VERSION;
- cbmem->ro_size = blob->ro_size;
- cbmem->rw_size = blob->rw_size;
-
- if (blob->ro_size) {
- memcpy(cbmem->blob, blob->ro_base, blob->ro_size);
- timestamp_add_now(TS_END_COPYVPD_RO);
- }
-
- if (blob->rw_size) {
- memcpy(cbmem->blob + blob->ro_size, blob->rw_base,
- blob->rw_size);
- timestamp_add_now(TS_END_COPYVPD_RW);
- }
-}
-
-void vpd_get_buffers(struct vpd_blob *blob)
-{
- const struct vpd_cbmem *vpd;
-
- vpd = cbmem_find(CBMEM_ID_VPD);
- if (!vpd || !vpd->ro_size)
- return;
-
- blob->ro_base = (void *)vpd->blob;
- blob->ro_size = vpd->ro_size;
- blob->rw_base = (void *)vpd->blob + vpd->ro_size;
- blob->rw_size = vpd->rw_size;
-}
-
-RAMSTAGE_CBMEM_INIT_HOOK(cbmem_add_cros_vpd)