summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-08-01 12:05:23 -0600
committerSimon Glass <sjg@chromium.org>2021-08-08 11:27:27 -0600
commit1e9ced28f18ed75bef96df08e47baad27dd51829 (patch)
tree68281ced12e3fb983c8e8acff3e0a73b9424c1af /test
parentb18b38f2ae3f54b906e0f2ab86789d9dd0110ed2 (diff)
downloadu-boot-1e9ced28f18ed75bef96df08e47baad27dd51829.tar.gz
u-boot-1e9ced28f18ed75bef96df08e47baad27dd51829.tar.bz2
u-boot-1e9ced28f18ed75bef96df08e47baad27dd51829.zip
dm: core: Don't allow uclass use before ready
At present it is possible to call uclass_get() before driver model is inited. In fact this happens on x86 boards which use Intel FSPv1, since mrccache_get_region() tries to get the SPI flash device very early during init. This has always been undefined behaviour. Previously it generally worked, i.e. returned an error code without crashing, because gd->uclass_root_s is zeroed and the uclass can be added despite driver model not being ready, due to the way lists are implemented. With the change to use a gd->uclass_root pointer, this no-longer works. For example, it causes a hang on minnowmax. Fix this by adding a check that driver model is ready when uclass_get() is called. This function is called in the process of locating any device, so it is a good place to add the check. This fixes booting on minnowmax. Signed-off-by: Simon Glass <sjg@chromium.org> Fixes: 8a715530bb1 ("dm: core: Allow the uclass list to move")
Diffstat (limited to 'test')
-rw-r--r--test/dm/core.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/test/dm/core.c b/test/dm/core.c
index 48e66b7333..c9a7606666 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -994,6 +994,7 @@ static int dm_test_uclass_before_ready(struct unit_test_state *uts)
memset(&gd->uclass_root, '\0', sizeof(gd->uclass_root));
ut_asserteq_ptr(NULL, uclass_find(UCLASS_TEST));
+ ut_asserteq(-EDEADLK, uclass_get(UCLASS_TEST, &uc));
return 0;
}