ddcutil/ddcutil-2.1.0-upstream-fix-with-powerdevil-1.patch

67 lines
3.3 KiB
Diff
Raw Permalink Normal View History

From 7f157f620b7f4c3862e140b5b77ff9215f0b7497 Mon Sep 17 00:00:00 2001
From: Sanford Rockowitz <rockowitz@minsoft.com>
Date: Sat, 20 Jan 2024 10:04:36 -0500
Subject: [PATCH] ddci_init(): submaster_initializer not called if implicit
initialization
ddci_init() can be called "explicitly" or "implicitly". An explicit
call is when it is called either from ddca_init() or ddca_init2().
If an API function dependent on initialization is called before
explicit initialization, ddci_init() is called with arguments such
that it can never fail. This is an implicit call. In particular,
it is called with option DDCA_INIT_OPTIONS_DISABLE_CONFIG_FILE and
a null libopts string. Otherwise failure would be possible.
The bug was that some initialization did not occur with this
combination of ddci_init() args. In particular,
submaster_initializer(), which among other things sets the value of
sys_drm_connectors, was not called. Also any options in the
ddcutilrc configuration file that turned on tracing were not
processed, making debugging more difficult.
PowerDevil calls API functions requiring initialization before calling
ddca_init(). As a result, there's an implicit call to ddci_init(),
and because of the bug sys_drm_connectors is not set, resulting
in the "assert(sys_drm_connectors)" failure in function i2c_check_bus().
---
src/libmain/api_base.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/src/libmain/api_base.c b/src/libmain/api_base.c
index 8f2c6e06..d862a361 100644
--- a/src/libmain/api_base.c
+++ b/src/libmain/api_base.c
@@ -660,20 +660,19 @@ ddci_init(const char * libopts,
*infomsg_loc = g_ptr_array_to_ntsa(infomsgs, /*duplicate=*/true);
}
g_ptr_array_free(infomsgs, true);
-
- if (!master_error) {
- if (parsed_cmd->trace_destination) {
- DBGF(debug, "Setting library trace file: %s", parsed_cmd->trace_destination);
- init_library_trace_file(parsed_cmd->trace_destination, enable_syslog, debug);
- }
- master_error = init_tracing(parsed_cmd);
- requested_stats = parsed_cmd->stats_types;
- ptd_api_profiling_enabled = parsed_cmd->flags & CMD_FLAG_PROFILE_API;
- per_display_stats = parsed_cmd->flags & CMD_FLAG_VERBOSE_STATS;
- dsa_detail_stats = parsed_cmd->flags & CMD_FLAG_INTERNAL_STATS;
- if (!submaster_initializer(parsed_cmd))
- master_error = ERRINFO_NEW(DDCRC_UNINITIALIZED, "Initialization failed");
+ }
+ if (!master_error) {
+ if (parsed_cmd->trace_destination) {
+ DBGF(debug, "Setting library trace file: %s", parsed_cmd->trace_destination);
+ init_library_trace_file(parsed_cmd->trace_destination, enable_syslog, debug);
}
+ master_error = init_tracing(parsed_cmd);
+ requested_stats = parsed_cmd->stats_types;
+ ptd_api_profiling_enabled = parsed_cmd->flags & CMD_FLAG_PROFILE_API;
+ per_display_stats = parsed_cmd->flags & CMD_FLAG_VERBOSE_STATS;
+ dsa_detail_stats = parsed_cmd->flags & CMD_FLAG_INTERNAL_STATS;
+ if (!submaster_initializer(parsed_cmd))
+ master_error = ERRINFO_NEW(DDCRC_UNINITIALIZED, "Initialization failed");
}
}