Jonathan Zhang has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: add function to find default boolean key value ......................................................................
drivers/vpd: add function to find default boolean key value
This change is based on the concept that system user's overwrite settings are held in VPD_RW region, while system owner's (default) settings are held in VPD_RO region.
Add vpd_get_bool_ex() to find value of boolean type vpd key. VPD_RW is searched first; If not found in VPD_RW, then search VPD_RO.
Signed-off-by: Jonathan Zhang jonzhang@fb.com Change-Id: I960688d1f6ab199768107ab73b8a7400a3fdf473 --- M src/drivers/vpd/vpd.c M src/drivers/vpd/vpd.h 2 files changed, 29 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/86/41586/1
diff --git a/src/drivers/vpd/vpd.c b/src/drivers/vpd/vpd.c index 7ed1255..74ac700 100644 --- a/src/drivers/vpd/vpd.c +++ b/src/drivers/vpd/vpd.c @@ -227,3 +227,22 @@ } else return false; } + +/* + * This function finds value of boolean type vpd key with the + * concept of default value being held in VPD_RO, and overwrite + * value being held in VPD_RW. + * + * True is returned if key found in VPD_RW, otherwise VPD_RO + * is searched. The value is held in *val if true is returned. + */ +bool vpd_get_bool_ex(const char *key, uint8_t *val) +{ + if (vpd_get_bool(key, VPD_RW, val)) + return true; + + if (vpd_get_bool(key, VPD_RO, val)) + return true; + + return false; +} diff --git a/src/drivers/vpd/vpd.h b/src/drivers/vpd/vpd.h index 05b7db8..cfc339d 100644 --- a/src/drivers/vpd/vpd.h +++ b/src/drivers/vpd/vpd.h @@ -76,4 +76,14 @@ bool vpd_get_bool(const char *key, enum vpd_region region, uint8_t *val);
+/* + * This function finds value of boolean type vpd key with the + * concept of default value being held in VPD_RO, and overwrite + * value being held in VPD_RW. + * + * True is returned if key found in VPD_RW, otherwise VPD_RO + * is searched. The value is held in *val if true is returned. + */ +bool vpd_get_bool_ex(const char *key, uint8_t *val) + #endif /* __VPD_H__ */
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: add function to find default boolean key value ......................................................................
Patch Set 1:
In comparison to adding a new function, I'd rather have this implemented as a new region enum.
Current VPD_ANY is actually having "RO first then RW", and we may rename that (or create a new one) as VPD_RO_OR_RW, and for your new usage we may call it VPD_RW_OR_RO.
I think that will be much easier for developers to figure out what it is doing than seeing a get_bool_ex.
Hello Hung-Te Lin, build bot (Jenkins), Johnny Lin, David Hendricks,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/41586
to look at the new patch set (#2).
Change subject: drivers/vpd: add support for VPD_RW_OR_RO ......................................................................
drivers/vpd: add support for VPD_RW_OR_RO
This change is based on the concept that system user's (overwrite) settings are held in VPD_RW region, while system owner's (default) settings are held in VPD_RO region.
Add VPD_RW_OR_RO, so that VPD_RW region is searched first to get overwrite setting, otherwise VPD_RO region is searched to get default setting.
Rename VPD_ANY to VPD_RO_OR_RW, to reflect the search preference. Update all existing code references to VPD_ANY.
Signed-off-by: Jonathan Zhang jonzhang@fb.com Change-Id: I960688d1f6ab199768107ab73b8a7400a3fdf473 --- M src/drivers/vpd/vpd.c M src/drivers/vpd/vpd.h M src/mainboard/google/reef/variants/snappy/mainboard.c M src/vendorcode/google/chromeos/sar.c M src/vendorcode/google/chromeos/vpd_calibration.c M src/vendorcode/google/chromeos/vpd_mac.c M src/vendorcode/google/chromeos/vpd_serialno.c M src/vendorcode/google/chromeos/wrdd.c 8 files changed, 71 insertions(+), 20 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/86/41586/2
Jonathan Zhang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: add support for VPD_RW_OR_RO ......................................................................
Patch Set 2:
Patch Set 1:
In comparison to adding a new function, I'd rather have this implemented as a new region enum.
Current VPD_ANY is actually having "RO first then RW", and we may rename that (or create a new one) as VPD_RO_OR_RW, and for your new usage we may call it VPD_RW_OR_RO.
I think that will be much easier for developers to figure out what it is doing than seeing a get_bool_ex.
This makes sense total, Hung-Te. I thought the same, but did not pursue because it involves change to src/vendorcode/google/chromeos. Thanks for your support.
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: add support for VPD_RW_OR_RO ......................................................................
Patch Set 2:
can you split this into 3 patches?
1. vpd: change VPD_ANY to VPD_RO_OR_RW 2. vpd: add new region "VPD_RW_OR_RO" 3. [your boards, or your modules]: use VPD RW region first then RO.
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: add support for VPD_RW_OR_RO ......................................................................
Patch Set 2:
(2 comments)
https://review.coreboot.org/c/coreboot/+/41586/2/src/drivers/vpd/vpd.c File src/drivers/vpd/vpd.c:
https://review.coreboot.org/c/coreboot/+/41586/2/src/drivers/vpd/vpd.c@208 PS2, Line 208: return NULL; Please add {} around this branch too.
https://doc.coreboot.org/coding_style.html#placing-braces-and-spaces
https://review.coreboot.org/c/coreboot/+/41586/2/src/drivers/vpd/vpd.c@223 PS2, Line 223: return NULL; Ditto.
Jonathan Zhang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: add support for VPD_RW_OR_RO ......................................................................
Patch Set 2:
Patch Set 2:
can you split this into 3 patches?
- vpd: change VPD_ANY to VPD_RO_OR_RW
- vpd: add new region "VPD_RW_OR_RO"
- [your boards, or your modules]: use VPD RW region first then RO.
Sure, will do. #3 is not ready yet (we are bringing up the board, VPD regions are not there yet), we will submit later.
Jonathan Zhang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: add support for VPD_RW_OR_RO ......................................................................
Patch Set 2:
(2 comments)
https://review.coreboot.org/c/coreboot/+/41586/2/src/drivers/vpd/vpd.c File src/drivers/vpd/vpd.c:
https://review.coreboot.org/c/coreboot/+/41586/2/src/drivers/vpd/vpd.c@208 PS2, Line 208: return NULL;
Please add {} around this branch too. […]
Done
https://review.coreboot.org/c/coreboot/+/41586/2/src/drivers/vpd/vpd.c@223 PS2, Line 223: return NULL;
Ditto.
Done
Hello Hung-Te Lin, build bot (Jenkins), Johnny Lin, David Hendricks,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/41586
to look at the new patch set (#3).
Change subject: drivers/vpd: rename VPD_ANY to VPD_RO_OR_RW ......................................................................
drivers/vpd: rename VPD_ANY to VPD_RO_OR_RW
Rename VPD_ANY to VPD_RO_OR_RW, to reflect the search preference. Update all existing code references to VPD_ANY.
Signed-off-by: Jonathan Zhang jonzhang@fb.com Change-Id: I960688d1f6ab199768107ab73b8a7400a3fdf473 --- M src/drivers/vpd/vpd.c M src/drivers/vpd/vpd.h M src/mainboard/google/reef/variants/snappy/mainboard.c M src/vendorcode/google/chromeos/sar.c M src/vendorcode/google/chromeos/vpd_calibration.c M src/vendorcode/google/chromeos/vpd_mac.c M src/vendorcode/google/chromeos/vpd_serialno.c M src/vendorcode/google/chromeos/wrdd.c 8 files changed, 51 insertions(+), 19 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/86/41586/3
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: rename VPD_ANY to VPD_RO_OR_RW ......................................................................
Patch Set 3:
the commit message indicates that we are simply renaming (e.g., there should be no logic changes) - so please move the vpd.c changes to the follow up changes, not this one. thanks!
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: rename VPD_ANY to VPD_RO_OR_RW ......................................................................
Patch Set 3:
(2 comments)
https://review.coreboot.org/c/coreboot/+/41586/3/src/drivers/vpd/vpd.h File src/drivers/vpd/vpd.h:
https://review.coreboot.org/c/coreboot/+/41586/3/src/drivers/vpd/vpd.h@18 PS3, Line 18: VPD_RO_OR_RW I think I would prefer something like VPD_RO_THEN_RW to make more clear that it's intentionally ordered.
https://review.coreboot.org/c/coreboot/+/41586/3/src/drivers/vpd/vpd.c File src/drivers/vpd/vpd.c:
https://review.coreboot.org/c/coreboot/+/41586/3/src/drivers/vpd/vpd.c@179 PS3, Line 179: consumed = 0; This is all... getting pretty hairy. I think this could look a lot cleaner by packing the actual lookup in a separate function like I did in https://review.coreboot.org/c/coreboot/+/41757/2/src/drivers/vpd/vpd.c#214. Then you could just do
if (region == VPD_RW_THEN_RO) vpd_find_in(&rw_vpd, &arg);
if (!arg.matched && region != VPD_RW) vpd_find_in(&ro_vpd, &arg);
if (!arg.matched && (region == VPD_RW || region == VPD_RO_THEN_RW)) vpd_find_in(&rw_vpd, &arg);
Alternatively, a little more wordy but just to make the ordering super clear it could be written as:
switch (region) { case VPD_RO: vpd_find_in(&ro_vpd, &arg); break; case VPD_RW: vpd_find_in(&rw_vpd, &arg); break; case VPD_RO_THEN_RW: vpd_find_in(&ro_vpd, &arg); if (!arg.matched) vpd_find_in(&rw_vpd, &arg); break; case VPD_RW_THEN_RO: vpd_find_in(&rw_vpd, &arg); if (!arg.matched) vpd_find_in(&ro_vpd, &arg); break; }
If you're not in a hurry maybe it would make things easier to get my patch in first?
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: rename VPD_ANY to VPD_RO_OR_RW ......................................................................
Patch Set 3:
(1 comment)
https://review.coreboot.org/c/coreboot/+/41586/3/src/drivers/vpd/vpd.c File src/drivers/vpd/vpd.c:
https://review.coreboot.org/c/coreboot/+/41586/3/src/drivers/vpd/vpd.c@179 PS3, Line 179: consumed = 0;
This is all... getting pretty hairy. […]
I was going to add the same comment - please rebase to jwerner's patch.
And yes, I have gave almost the same feedback (and similar implementation) in the follow up change...
Jonathan Zhang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: rename VPD_ANY to VPD_RO_OR_RW ......................................................................
Patch Set 3:
Patch Set 3:
the commit message indicates that we are simply renaming (e.g., there should be no logic changes) - so please move the vpd.c changes to the follow up changes, not this one. thanks!
Sure, will do,
Jonathan Zhang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: rename VPD_ANY to VPD_RO_OR_RW ......................................................................
Patch Set 3:
(1 comment)
Patch Set 3:
the commit message indicates that we are simply renaming (e.g., there should be no logic changes) - so please move the vpd.c changes to the follow up changes, not this one. thanks!
https://review.coreboot.org/c/coreboot/+/41586/3/src/drivers/vpd/vpd.c File src/drivers/vpd/vpd.c:
https://review.coreboot.org/c/coreboot/+/41586/3/src/drivers/vpd/vpd.c@179 PS3, Line 179: consumed = 0;
I was going to add the same comment - please rebase to jwerner's patch. […]
Sure, I will wait till Julius's patch was merged. I am not in hurry.
Hello Hung-Te Lin, build bot (Jenkins), Johnny Lin, David Hendricks,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/41586
to look at the new patch set (#4).
Change subject: drivers/vpd: rename VPD_ANY to VPD_RO_THEN_RW ......................................................................
drivers/vpd: rename VPD_ANY to VPD_RO_THEN_RW
Rename VPD_ANY to VPD_RO_THEN_RW, to reflect the VPD region search preference. Update all existing code references for VPD_ANY.
Signed-off-by: Jonathan Zhang jonzhang@fb.com Change-Id: I960688d1f6ab199768107ab73b8a7400a3fdf473 --- M src/drivers/vpd/vpd.h M src/mainboard/google/reef/variants/snappy/mainboard.c M src/vendorcode/google/chromeos/sar.c M src/vendorcode/google/chromeos/vpd_calibration.c M src/vendorcode/google/chromeos/vpd_mac.c M src/vendorcode/google/chromeos/vpd_serialno.c M src/vendorcode/google/chromeos/wrdd.c 7 files changed, 7 insertions(+), 7 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/86/41586/4
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: rename VPD_ANY to VPD_RO_THEN_RW ......................................................................
Patch Set 4: Code-Review+2
Jonathan Zhang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: rename VPD_ANY to VPD_RO_THEN_RW ......................................................................
Patch Set 4:
(2 comments)
Thanks!
https://review.coreboot.org/c/coreboot/+/41586/3/src/drivers/vpd/vpd.h File src/drivers/vpd/vpd.h:
https://review.coreboot.org/c/coreboot/+/41586/3/src/drivers/vpd/vpd.h@18 PS3, Line 18: VPD_RO_OR_RW
I think I would prefer something like VPD_RO_THEN_RW to make more clear that it's intentionally orde […]
Done
https://review.coreboot.org/c/coreboot/+/41586/3/src/drivers/vpd/vpd.c File src/drivers/vpd/vpd.c:
https://review.coreboot.org/c/coreboot/+/41586/3/src/drivers/vpd/vpd.c@179 PS3, Line 179: consumed = 0;
Sure, I will wait till Julius's patch was merged. I am not in hurry.
Done
Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: rename VPD_ANY to VPD_RO_THEN_RW ......................................................................
drivers/vpd: rename VPD_ANY to VPD_RO_THEN_RW
Rename VPD_ANY to VPD_RO_THEN_RW, to reflect the VPD region search preference. Update all existing code references for VPD_ANY.
Signed-off-by: Jonathan Zhang jonzhang@fb.com Change-Id: I960688d1f6ab199768107ab73b8a7400a3fdf473 Reviewed-on: https://review.coreboot.org/c/coreboot/+/41586 Reviewed-by: Julius Werner jwerner@chromium.org Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/drivers/vpd/vpd.h M src/mainboard/google/reef/variants/snappy/mainboard.c M src/vendorcode/google/chromeos/sar.c M src/vendorcode/google/chromeos/vpd_calibration.c M src/vendorcode/google/chromeos/vpd_mac.c M src/vendorcode/google/chromeos/vpd_serialno.c M src/vendorcode/google/chromeos/wrdd.c 7 files changed, 7 insertions(+), 7 deletions(-)
Approvals: build bot (Jenkins): Verified Julius Werner: Looks good to me, approved
diff --git a/src/drivers/vpd/vpd.h b/src/drivers/vpd/vpd.h index d54cef8..df7711a 100644 --- a/src/drivers/vpd/vpd.h +++ b/src/drivers/vpd/vpd.h @@ -8,7 +8,7 @@ #define GOOGLE_VPD_2_0_OFFSET 0x600
enum vpd_region { - VPD_ANY = 0, + VPD_RO_THEN_RW = 0, VPD_RO = 1, VPD_RW = 2 }; diff --git a/src/mainboard/google/reef/variants/snappy/mainboard.c b/src/mainboard/google/reef/variants/snappy/mainboard.c index 0dd7529..fc0652c 100644 --- a/src/mainboard/google/reef/variants/snappy/mainboard.c +++ b/src/mainboard/google/reef/variants/snappy/mainboard.c @@ -46,7 +46,7 @@ if (!CONFIG(CHROMEOS)) return board_sku_num;
- if (!vpd_gets(vpd_skuid, vpd_buffer, ARRAY_SIZE(vpd_buffer), VPD_ANY)) + if (!vpd_gets(vpd_skuid, vpd_buffer, ARRAY_SIZE(vpd_buffer), VPD_RO_THEN_RW)) return board_sku_num;
vpd_len = strlen(vpd_buffer); diff --git a/src/vendorcode/google/chromeos/sar.c b/src/vendorcode/google/chromeos/sar.c index ab4f3d2..b07d41d 100644 --- a/src/vendorcode/google/chromeos/sar.c +++ b/src/vendorcode/google/chromeos/sar.c @@ -70,7 +70,7 @@
/* Try to read the SAR limit entry from VPD */ if (!vpd_gets(wifi_sar_limit_key, wifi_sar_limit_str, - buffer_size, VPD_ANY)) { + buffer_size, VPD_RO_THEN_RW)) { printk(BIOS_ERR, "Error: Could not locate '%s' in VPD.\n", wifi_sar_limit_key);
diff --git a/src/vendorcode/google/chromeos/vpd_calibration.c b/src/vendorcode/google/chromeos/vpd_calibration.c index 3dc58d1..ab862c8 100644 --- a/src/vendorcode/google/chromeos/vpd_calibration.c +++ b/src/vendorcode/google/chromeos/vpd_calibration.c @@ -99,7 +99,7 @@ strcpy(cache->key_name, templates[i]); cache->key_name[index_location] = j + '0';
- payload = vpd_find(cache->key_name, &payload_size, VPD_ANY); + payload = vpd_find(cache->key_name, &payload_size, VPD_RO_THEN_RW); if (!payload) continue;
diff --git a/src/vendorcode/google/chromeos/vpd_mac.c b/src/vendorcode/google/chromeos/vpd_mac.c index 097afcb..385b9f4 100644 --- a/src/vendorcode/google/chromeos/vpd_mac.c +++ b/src/vendorcode/google/chromeos/vpd_mac.c @@ -73,7 +73,7 @@ * in the VPD - move on. */ if (!vpd_gets(mac_addr_key, mac_addr_str, - sizeof(mac_addr_str), VPD_ANY)) + sizeof(mac_addr_str), VPD_RO_THEN_RW)) break;
if (!macs) { diff --git a/src/vendorcode/google/chromeos/vpd_serialno.c b/src/vendorcode/google/chromeos/vpd_serialno.c index 9ee4f6f..9a3aa81 100644 --- a/src/vendorcode/google/chromeos/vpd_serialno.c +++ b/src/vendorcode/google/chromeos/vpd_serialno.c @@ -15,7 +15,7 @@ size_t len;
if (!vpd_gets(serialno_key, serialno, - sizeof(serialno), VPD_ANY)) { + sizeof(serialno), VPD_RO_THEN_RW)) { printk(BIOS_ERR, "no serial number in vpd\n"); return; } diff --git a/src/vendorcode/google/chromeos/wrdd.c b/src/vendorcode/google/chromeos/wrdd.c index e9d7247..524a7e0 100644 --- a/src/vendorcode/google/chromeos/wrdd.c +++ b/src/vendorcode/google/chromeos/wrdd.c @@ -48,7 +48,7 @@
/* If not found for any reason fall backto the default value */ if (!vpd_gets(wrdd_domain_key, wrdd_domain_code, - ARRAY_SIZE(wrdd_domain_code), VPD_ANY)) { + ARRAY_SIZE(wrdd_domain_code), VPD_RO_THEN_RW)) { printk(BIOS_DEBUG, "Error: Could not locate '%s' in VPD\n", wrdd_domain_key); return WRDD_DEFAULT_REGULATORY_DOMAIN;
9elements QA has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: rename VPD_ANY to VPD_RO_THEN_RW ......................................................................
Patch Set 5:
Automatic boot test returned (PASS/FAIL/TOTAL): 4/0/4 Emulation targets: "QEMU x86 q35/ich9" using payload TianoCore : SUCCESS : https://lava.9esec.io/r/4524 "QEMU x86 q35/ich9" using payload SeaBIOS : SUCCESS : https://lava.9esec.io/r/4523 "QEMU x86 i440fx/piix4" using payload SeaBIOS : SUCCESS : https://lava.9esec.io/r/4522 "QEMU AArch64" using payload LinuxBoot_u-root_kexec : SUCCESS : https://lava.9esec.io/r/4521
Please note: This test is under development and might not be accurate at all!