mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-07 02:54:26 +00:00
trivial: Add FuProgress to fu_context_load_hwinfo()
TIL: fu_bios_settings_setup() takes over 50ms (10%!) at startup.
This commit is contained in:
parent
4d4c56fa75
commit
6e34a90a12
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "fu-context.h"
|
#include "fu-context.h"
|
||||||
#include "fu-hwids.h"
|
#include "fu-hwids.h"
|
||||||
|
#include "fu-progress.h"
|
||||||
#include "fu-quirks.h"
|
#include "fu-quirks.h"
|
||||||
#include "fu-volume.h"
|
#include "fu-volume.h"
|
||||||
|
|
||||||
@ -26,7 +27,10 @@ fu_context_new(void);
|
|||||||
gboolean
|
gboolean
|
||||||
fu_context_reload_bios_settings(FuContext *self, GError **error);
|
fu_context_reload_bios_settings(FuContext *self, GError **error);
|
||||||
gboolean
|
gboolean
|
||||||
fu_context_load_hwinfo(FuContext *self, FuContextHwidFlags flags, GError **error);
|
fu_context_load_hwinfo(FuContext *self,
|
||||||
|
FuProgress *progress,
|
||||||
|
FuContextHwidFlags flags,
|
||||||
|
GError **error);
|
||||||
gboolean
|
gboolean
|
||||||
fu_context_load_quirks(FuContext *self, FuQuirksLoadFlags flags, GError **error);
|
fu_context_load_quirks(FuContext *self, FuQuirksLoadFlags flags, GError **error);
|
||||||
void
|
void
|
||||||
|
@ -772,6 +772,7 @@ typedef gboolean (*FuContextHwidsSetupFunc)(FuContext *self, FuHwids *hwids, GEr
|
|||||||
/**
|
/**
|
||||||
* fu_context_load_hwinfo:
|
* fu_context_load_hwinfo:
|
||||||
* @self: a #FuContext
|
* @self: a #FuContext
|
||||||
|
* @progress: a #FuProgress
|
||||||
* @flags: a #FuContextHwidFlags, e.g. %FU_CONTEXT_HWID_FLAG_LOAD_SMBIOS
|
* @flags: a #FuContextHwidFlags, e.g. %FU_CONTEXT_HWID_FLAG_LOAD_SMBIOS
|
||||||
* @error: (nullable): optional return location for an error
|
* @error: (nullable): optional return location for an error
|
||||||
*
|
*
|
||||||
@ -782,7 +783,10 @@ typedef gboolean (*FuContextHwidsSetupFunc)(FuContext *self, FuHwids *hwids, GEr
|
|||||||
* Since: 1.8.10
|
* Since: 1.8.10
|
||||||
**/
|
**/
|
||||||
gboolean
|
gboolean
|
||||||
fu_context_load_hwinfo(FuContext *self, FuContextHwidFlags flags, GError **error)
|
fu_context_load_hwinfo(FuContext *self,
|
||||||
|
FuProgress *progress,
|
||||||
|
FuContextHwidFlags flags,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
FuContextPrivate *priv = GET_PRIVATE(self);
|
FuContextPrivate *priv = GET_PRIVATE(self);
|
||||||
GPtrArray *guids;
|
GPtrArray *guids;
|
||||||
@ -802,6 +806,13 @@ fu_context_load_hwinfo(FuContext *self, FuContextHwidFlags flags, GError **error
|
|||||||
g_return_val_if_fail(FU_IS_CONTEXT(self), FALSE);
|
g_return_val_if_fail(FU_IS_CONTEXT(self), FALSE);
|
||||||
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
|
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
|
/* progress */
|
||||||
|
fu_progress_set_id(progress, G_STRLOC);
|
||||||
|
fu_progress_add_step(progress, FWUPD_STATUS_LOADING, 1, "hwids-setup-funcs");
|
||||||
|
fu_progress_add_step(progress, FWUPD_STATUS_LOADING, 1, "hwids-setup");
|
||||||
|
fu_progress_add_step(progress, FWUPD_STATUS_LOADING, 3, "set-flags");
|
||||||
|
fu_progress_add_step(progress, FWUPD_STATUS_LOADING, 95, "reload-bios-settings");
|
||||||
|
|
||||||
/* run all the HWID setup funcs */
|
/* run all the HWID setup funcs */
|
||||||
for (guint i = 0; hwids_setup_map[i].name != NULL; i++) {
|
for (guint i = 0; hwids_setup_map[i].name != NULL; i++) {
|
||||||
if ((flags & hwids_setup_map[i].flag) > 0) {
|
if ((flags & hwids_setup_map[i].flag) > 0) {
|
||||||
@ -815,8 +826,11 @@ fu_context_load_hwinfo(FuContext *self, FuContextHwidFlags flags, GError **error
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
priv->loaded_hwinfo = TRUE;
|
priv->loaded_hwinfo = TRUE;
|
||||||
|
fu_progress_step_done(progress);
|
||||||
|
|
||||||
if (!fu_hwids_setup(priv->hwids, &error_hwids))
|
if (!fu_hwids_setup(priv->hwids, &error_hwids))
|
||||||
g_warning("Failed to load HWIDs: %s", error_hwids->message);
|
g_warning("Failed to load HWIDs: %s", error_hwids->message);
|
||||||
|
fu_progress_step_done(progress);
|
||||||
|
|
||||||
/* set the hwid flags */
|
/* set the hwid flags */
|
||||||
guids = fu_context_get_hwid_guids(self);
|
guids = fu_context_get_hwid_guids(self);
|
||||||
@ -832,10 +846,12 @@ fu_context_load_hwinfo(FuContext *self, FuContextHwidFlags flags, GError **error
|
|||||||
g_hash_table_add(priv->hwid_flags, g_strdup(values[j]));
|
g_hash_table_add(priv->hwid_flags, g_strdup(values[j]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fu_progress_step_done(progress);
|
||||||
|
|
||||||
fu_context_add_udev_subsystem(self, "firmware-attributes");
|
fu_context_add_udev_subsystem(self, "firmware-attributes");
|
||||||
if (!fu_context_reload_bios_settings(self, &error_bios_settings))
|
if (!fu_context_reload_bios_settings(self, &error_bios_settings))
|
||||||
g_debug("%s", error_bios_settings->message);
|
g_debug("%s", error_bios_settings->message);
|
||||||
|
fu_progress_step_done(progress);
|
||||||
|
|
||||||
/* always */
|
/* always */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -435,10 +435,11 @@ static void
|
|||||||
fu_context_hwids_dmi_func(void)
|
fu_context_hwids_dmi_func(void)
|
||||||
{
|
{
|
||||||
g_autoptr(FuContext) ctx = fu_context_new();
|
g_autoptr(FuContext) ctx = fu_context_new();
|
||||||
|
g_autoptr(FuProgress) progress = fu_progress_new(G_STRLOC);
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
ret = fu_context_load_hwinfo(ctx, FU_CONTEXT_HWID_FLAG_LOAD_DMI, &error);
|
ret = fu_context_load_hwinfo(ctx, progress, FU_CONTEXT_HWID_FLAG_LOAD_DMI, &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_true(ret);
|
g_assert_true(ret);
|
||||||
if (g_getenv("FWUPD_VERBOSE") != NULL) {
|
if (g_getenv("FWUPD_VERBOSE") != NULL) {
|
||||||
@ -559,6 +560,7 @@ fu_hwids_func(void)
|
|||||||
{
|
{
|
||||||
g_autofree gchar *testdatadir = NULL;
|
g_autofree gchar *testdatadir = NULL;
|
||||||
g_autoptr(FuContext) context = NULL;
|
g_autoptr(FuContext) context = NULL;
|
||||||
|
g_autoptr(FuProgress) progress = fu_progress_new(G_STRLOC);
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
@ -593,7 +595,7 @@ fu_hwids_func(void)
|
|||||||
(void)g_setenv("FWUPD_SYSFSFWDIR", testdatadir, TRUE);
|
(void)g_setenv("FWUPD_SYSFSFWDIR", testdatadir, TRUE);
|
||||||
|
|
||||||
context = fu_context_new();
|
context = fu_context_new();
|
||||||
ret = fu_context_load_hwinfo(context, FU_CONTEXT_HWID_FLAG_LOAD_SMBIOS, &error);
|
ret = fu_context_load_hwinfo(context, progress, FU_CONTEXT_HWID_FLAG_LOAD_SMBIOS, &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_true(ret);
|
g_assert_true(ret);
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ fu_test_self_init(FuTest *self, GError **error_global)
|
|||||||
&error);
|
&error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_true(ret);
|
g_assert_true(ret);
|
||||||
ret = fu_context_load_hwinfo(ctx, FU_CONTEXT_HWID_FLAG_LOAD_CONFIG, &error);
|
ret = fu_context_load_hwinfo(ctx, progress, FU_CONTEXT_HWID_FLAG_LOAD_CONFIG, &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_true(ret);
|
g_assert_true(ret);
|
||||||
ret = fu_context_reload_bios_settings(ctx, &error);
|
ret = fu_context_reload_bios_settings(ctx, &error);
|
||||||
|
@ -32,7 +32,7 @@ fu_test_mtd_device_func(void)
|
|||||||
ret = fu_context_load_quirks(ctx, FU_QUIRKS_LOAD_FLAG_NO_CACHE, &error);
|
ret = fu_context_load_quirks(ctx, FU_QUIRKS_LOAD_FLAG_NO_CACHE, &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_true(ret);
|
g_assert_true(ret);
|
||||||
ret = fu_context_load_hwinfo(ctx, FU_CONTEXT_HWID_FLAG_LOAD_SMBIOS, &error);
|
ret = fu_context_load_hwinfo(ctx, progress, FU_CONTEXT_HWID_FLAG_LOAD_SMBIOS, &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_true(ret);
|
g_assert_true(ret);
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ _test_add_fake_devices_from_dir(FuPlugin *plugin, const gchar *path)
|
|||||||
const gchar *basename;
|
const gchar *basename;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
g_autoptr(FuContext) ctx = fu_context_new();
|
g_autoptr(FuContext) ctx = fu_context_new();
|
||||||
|
g_autoptr(FuProgress) progress = fu_progress_new(G_STRLOC);
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(GDir) dir = g_dir_open(path, 0, &error);
|
g_autoptr(GDir) dir = g_dir_open(path, 0, &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
@ -37,13 +38,13 @@ _test_add_fake_devices_from_dir(FuPlugin *plugin, const gchar *path)
|
|||||||
ret = fu_context_load_quirks(ctx, FU_QUIRKS_LOAD_FLAG_NO_CACHE, &error);
|
ret = fu_context_load_quirks(ctx, FU_QUIRKS_LOAD_FLAG_NO_CACHE, &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_true(ret);
|
g_assert_true(ret);
|
||||||
ret = fu_context_load_hwinfo(ctx, FU_CONTEXT_HWID_FLAG_NONE, &error);
|
ret = fu_context_load_hwinfo(ctx, progress, FU_CONTEXT_HWID_FLAG_NONE, &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_true(ret);
|
g_assert_true(ret);
|
||||||
|
|
||||||
while ((basename = g_dir_read_name(dir)) != NULL) {
|
while ((basename = g_dir_read_name(dir)) != NULL) {
|
||||||
g_autofree gchar *fn = g_build_filename(path, basename, NULL);
|
g_autofree gchar *fn = g_build_filename(path, basename, NULL);
|
||||||
g_autoptr(FuProgress) progress = fu_progress_new(G_STRLOC);
|
g_autoptr(FuProgress) progress_local = fu_progress_new(G_STRLOC);
|
||||||
g_autoptr(FuUdevDevice) dev = NULL;
|
g_autoptr(FuUdevDevice) dev = NULL;
|
||||||
if (!g_str_has_prefix(basename, "drm_dp_aux"))
|
if (!g_str_has_prefix(basename, "drm_dp_aux"))
|
||||||
continue;
|
continue;
|
||||||
@ -60,8 +61,10 @@ _test_add_fake_devices_from_dir(FuPlugin *plugin, const gchar *path)
|
|||||||
fn,
|
fn,
|
||||||
NULL);
|
NULL);
|
||||||
g_debug("creating drm_dp_aux_dev object backed by %s", fn);
|
g_debug("creating drm_dp_aux_dev object backed by %s", fn);
|
||||||
ret =
|
ret = fu_plugin_runner_backend_device_added(plugin,
|
||||||
fu_plugin_runner_backend_device_added(plugin, FU_DEVICE(dev), progress, &error);
|
FU_DEVICE(dev),
|
||||||
|
progress_local,
|
||||||
|
&error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_true(ret);
|
g_assert_true(ret);
|
||||||
}
|
}
|
||||||
@ -84,7 +87,7 @@ fu_plugin_synaptics_mst_none_func(void)
|
|||||||
ret = fu_context_load_quirks(ctx, FU_QUIRKS_LOAD_FLAG_NO_CACHE, &error);
|
ret = fu_context_load_quirks(ctx, FU_QUIRKS_LOAD_FLAG_NO_CACHE, &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_true(ret);
|
g_assert_true(ret);
|
||||||
ret = fu_context_load_hwinfo(ctx, FU_CONTEXT_HWID_FLAG_NONE, &error);
|
ret = fu_context_load_hwinfo(ctx, progress, FU_CONTEXT_HWID_FLAG_NONE, &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_true(ret);
|
g_assert_true(ret);
|
||||||
|
|
||||||
@ -127,7 +130,7 @@ fu_plugin_synaptics_mst_tb16_func(void)
|
|||||||
ret = fu_context_load_quirks(ctx, FU_QUIRKS_LOAD_FLAG_NO_CACHE, &error);
|
ret = fu_context_load_quirks(ctx, FU_QUIRKS_LOAD_FLAG_NO_CACHE, &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_true(ret);
|
g_assert_true(ret);
|
||||||
ret = fu_context_load_hwinfo(ctx, FU_CONTEXT_HWID_FLAG_NONE, &error);
|
ret = fu_context_load_hwinfo(ctx, progress, FU_CONTEXT_HWID_FLAG_NONE, &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_true(ret);
|
g_assert_true(ret);
|
||||||
|
|
||||||
|
@ -336,7 +336,10 @@ main(int argc, char *argv[])
|
|||||||
g_autoptr(GError) error_local = NULL;
|
g_autoptr(GError) error_local = NULL;
|
||||||
|
|
||||||
/* load SMBIOS */
|
/* load SMBIOS */
|
||||||
if (!fu_context_load_hwinfo(ctx, FU_CONTEXT_HWID_FLAG_LOAD_ALL, &error_local)) {
|
if (!fu_context_load_hwinfo(ctx,
|
||||||
|
progress,
|
||||||
|
FU_CONTEXT_HWID_FLAG_LOAD_ALL,
|
||||||
|
&error_local)) {
|
||||||
g_printerr("failed: %s\n", error_local->message);
|
g_printerr("failed: %s\n", error_local->message);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
@ -459,15 +462,20 @@ main(int argc, char *argv[])
|
|||||||
/* progress */
|
/* progress */
|
||||||
fu_progress_set_id(progress, G_STRLOC);
|
fu_progress_set_id(progress, G_STRLOC);
|
||||||
fu_progress_add_flag(progress, FU_PROGRESS_FLAG_NO_PROFILE);
|
fu_progress_add_flag(progress, FU_PROGRESS_FLAG_NO_PROFILE);
|
||||||
|
fu_progress_add_step(progress, FWUPD_STATUS_LOADING, 1, "hwinfo");
|
||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_BUSY, 1, "prepare");
|
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_BUSY, 1, "prepare");
|
||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 98, NULL);
|
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 98, NULL);
|
||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_BUSY, 1, "cleanup");
|
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_BUSY, 1, "cleanup");
|
||||||
|
|
||||||
/* load SMBIOS */
|
/* load SMBIOS */
|
||||||
if (!fu_context_load_hwinfo(ctx, FU_CONTEXT_HWID_FLAG_LOAD_ALL, &error_local)) {
|
if (!fu_context_load_hwinfo(ctx,
|
||||||
|
fu_progress_get_child(progress),
|
||||||
|
FU_CONTEXT_HWID_FLAG_LOAD_ALL,
|
||||||
|
&error_local)) {
|
||||||
g_printerr("failed: %s\n", error_local->message);
|
g_printerr("failed: %s\n", error_local->message);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
fu_progress_step_done(progress);
|
||||||
|
|
||||||
/* type is specified, otherwise use default */
|
/* type is specified, otherwise use default */
|
||||||
if (type != NULL) {
|
if (type != NULL) {
|
||||||
|
@ -8036,7 +8036,10 @@ fu_engine_load(FuEngine *self, FuEngineLoadFlags flags, FuProgress *progress, GE
|
|||||||
|
|
||||||
/* load SMBIOS and the hwids */
|
/* load SMBIOS and the hwids */
|
||||||
if (flags & FU_ENGINE_LOAD_FLAG_HWINFO) {
|
if (flags & FU_ENGINE_LOAD_FLAG_HWINFO) {
|
||||||
if (!fu_context_load_hwinfo(self->ctx, FU_CONTEXT_HWID_FLAG_LOAD_ALL, error))
|
if (!fu_context_load_hwinfo(self->ctx,
|
||||||
|
fu_progress_get_child(progress),
|
||||||
|
FU_CONTEXT_HWID_FLAG_LOAD_ALL,
|
||||||
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
self->has_hwinfo = TRUE;
|
self->has_hwinfo = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1988,7 +1988,7 @@ fu_util_export_hwids(FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* setup default hwids */
|
/* setup default hwids */
|
||||||
if (!fu_context_load_hwinfo(ctx, FU_CONTEXT_HWID_FLAG_LOAD_ALL, error))
|
if (!fu_context_load_hwinfo(ctx, priv->progress, FU_CONTEXT_HWID_FLAG_LOAD_ALL, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* save all keys */
|
/* save all keys */
|
||||||
@ -2022,7 +2022,7 @@ fu_util_hwids(FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
fu_hwids_add_value(hwids, hwid_key, tmp);
|
fu_hwids_add_value(hwids, hwid_key, tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!fu_context_load_hwinfo(ctx, FU_CONTEXT_HWID_FLAG_LOAD_ALL, error))
|
if (!fu_context_load_hwinfo(ctx, priv->progress, FU_CONTEXT_HWID_FLAG_LOAD_ALL, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* show debug output */
|
/* show debug output */
|
||||||
|
Loading…
Reference in New Issue
Block a user