* [Intel-gfx] [PATCH i-g-t 1/2] Always pass device to igt_params_set
@ 2020-05-18 23:32 Chris Wilson
2020-05-18 23:32 ` [Intel-gfx] [PATCH i-g-t 2/2] lib: Cleanup __igt_params_open() Chris Wilson
0 siblings, 1 reply; 2+ messages in thread
From: Chris Wilson @ 2020-05-18 23:32 UTC (permalink / raw)
To: igt-dev; +Cc: intel-gfx, Chris Wilson
Don't second guess, require the user to provide the device that wish to
set the module parameter for.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
lib/igt_params.c | 8 ++++----
lib/igt_params.h | 4 ++--
lib/igt_psr.c | 18 ++++++++---------
lib/igt_psr.h | 6 +++---
tests/i915/i915_pm_dc.c | 12 ++++++------
tests/kms_busy.c | 8 ++++----
tests/kms_fbcon_fbt.c | 32 +++++++++++++++----------------
tests/kms_force_connector_basic.c | 6 +++---
tests/kms_frontbuffer_tracking.c | 10 +++++-----
tests/kms_panel_fitting.c | 2 +-
tests/kms_psr.c | 6 +++---
tests/kms_psr2_su.c | 6 ++++--
12 files changed, 60 insertions(+), 58 deletions(-)
diff --git a/lib/igt_params.c b/lib/igt_params.c
index d8649dfd9..3decc5b2a 100644
--- a/lib/igt_params.c
+++ b/lib/igt_params.c
@@ -343,9 +343,9 @@ bool igt_params_save_and_set(int device, const char *parameter, const char *fmt,
* Please consider using igt_set_module_param_int() for the integer and bool
* parameters.
*/
-void igt_set_module_param(const char *name, const char *val)
+void igt_set_module_param(int device, const char *name, const char *val)
{
- igt_assert(igt_params_save_and_set(-1, name, "%s", val));
+ igt_assert(igt_params_save_and_set(device, name, "%s", val));
}
/**
@@ -356,7 +356,7 @@ void igt_set_module_param(const char *name, const char *val)
* This is a wrapper for igt_set_module_param() that takes an integer instead of
* a string. Please see igt_set_module_param().
*/
-void igt_set_module_param_int(const char *name, int val)
+void igt_set_module_param_int(int device, const char *name, int val)
{
- igt_assert(igt_params_save_and_set(-1, name, "%d", val));
+ igt_assert(igt_params_save_and_set(device, name, "%d", val));
}
diff --git a/lib/igt_params.h b/lib/igt_params.h
index ed17f34a5..bbd6f3ee6 100644
--- a/lib/igt_params.h
+++ b/lib/igt_params.h
@@ -34,7 +34,7 @@ bool igt_params_set(int device, const char *parameter, const char *fmt, ...);
__attribute__((format(printf, 3, 4)))
bool igt_params_save_and_set(int device, const char *parameter, const char *fmt, ...);
-void igt_set_module_param(const char *name, const char *val);
-void igt_set_module_param_int(const char *name, int val);
+void igt_set_module_param(int device, const char *name, const char *val);
+void igt_set_module_param_int(int device, const char *name, int val);
#endif /* __IGT_PARAMS_H__ */
diff --git a/lib/igt_psr.c b/lib/igt_psr.c
index c2a8d0e11..4109b5295 100644
--- a/lib/igt_psr.c
+++ b/lib/igt_psr.c
@@ -94,11 +94,11 @@ static int has_psr_debugfs(int debugfs_fd)
return -EINVAL;
}
-static bool psr_modparam_set(int val)
+static bool psr_modparam_set(int device, int val)
{
static int oldval = -1;
- igt_set_module_param_int("enable_psr", val);
+ igt_set_module_param_int(device, "enable_psr", val);
if (val == oldval)
return false;
@@ -114,7 +114,7 @@ static void restore_psr_debugfs(int sig)
psr_write(psr_restore_debugfs_fd, "0");
}
-static bool psr_set(int debugfs_fd, int mode)
+static bool psr_set(int device, int debugfs_fd, int mode)
{
int ret;
@@ -131,7 +131,7 @@ static bool psr_set(int debugfs_fd, int mode)
* version enabled and the PSR version of the test, it will
* fail in the first psr_wait_entry() of the test.
*/
- ret = psr_modparam_set(mode >= PSR_MODE_1);
+ ret = psr_modparam_set(device, mode >= PSR_MODE_1);
} else {
const char *debug_val;
@@ -161,18 +161,18 @@ static bool psr_set(int debugfs_fd, int mode)
return ret;
}
-bool psr_enable(int debugfs_fd, enum psr_mode mode)
+bool psr_enable(int device, int debugfs_fd, enum psr_mode mode)
{
- return psr_set(debugfs_fd, mode);
+ return psr_set(device, debugfs_fd, mode);
}
-bool psr_disable(int debugfs_fd)
+bool psr_disable(int device, int debugfs_fd)
{
/* Any mode different than PSR_MODE_1/2 will disable PSR */
- return psr_set(debugfs_fd, -1);
+ return psr_set(device, debugfs_fd, -1);
}
-bool psr_sink_support(int debugfs_fd, enum psr_mode mode)
+bool psr_sink_support(int device, int debugfs_fd, enum psr_mode mode)
{
char buf[PSR_STATUS_MAX_LEN];
int ret;
diff --git a/lib/igt_psr.h b/lib/igt_psr.h
index 02ce760b2..b2afb6119 100644
--- a/lib/igt_psr.h
+++ b/lib/igt_psr.h
@@ -39,9 +39,9 @@ bool psr_disabled_check(int debugfs_fd);
bool psr_wait_entry(int debugfs_fd, enum psr_mode mode);
bool psr_wait_update(int debugfs_fd, enum psr_mode mode);
bool psr_long_wait_update(int debugfs_fd, enum psr_mode mode);
-bool psr_enable(int debugfs_fd, enum psr_mode);
-bool psr_disable(int debugfs_fd);
-bool psr_sink_support(int debugfs_fd, enum psr_mode);
+bool psr_enable(int device, int debugfs_fd, enum psr_mode);
+bool psr_disable(int device, int debugfs_fd);
+bool psr_sink_support(int device, int debugfs_fd, enum psr_mode mode);
bool psr2_wait_su(int debugfs_fd, uint16_t *num_su_blocks);
#endif
diff --git a/tests/i915/i915_pm_dc.c b/tests/i915/i915_pm_dc.c
index 2dd6191d6..3a3027291 100644
--- a/tests/i915/i915_pm_dc.c
+++ b/tests/i915/i915_pm_dc.c
@@ -291,7 +291,7 @@ static void require_dc_counter(int debugfs_fd, int dc_flag)
static void setup_dc3co(data_t *data)
{
data->op_psr_mode = PSR_MODE_2;
- psr_enable(data->debugfs_fd, data->op_psr_mode);
+ psr_enable(data->drm_fd, data->debugfs_fd, data->op_psr_mode);
igt_require_f(psr_wait_entry(data->debugfs_fd, data->op_psr_mode),
"PSR2 is not enabled\n");
}
@@ -408,25 +408,25 @@ int main(int argc, char *argv[])
igt_describe("In this test we make sure that system enters DC3CO "
"when PSR2 is active and system is in SLEEP state");
igt_subtest("dc3co-vpb-simulation") {
- igt_require(psr_sink_support(data.debugfs_fd, PSR_MODE_2));
+ igt_require(psr_sink_support(data.drm_fd, data.debugfs_fd, PSR_MODE_2));
test_dc3co_vpb_simulation(&data);
}
igt_describe("This test validates display engine entry to DC5 state "
"while PSR is active");
igt_subtest("dc5-psr") {
- igt_require(psr_sink_support(data.debugfs_fd, PSR_MODE_1));
+ igt_require(psr_sink_support(data.drm_fd, data.debugfs_fd, PSR_MODE_1));
data.op_psr_mode = PSR_MODE_1;
- psr_enable(data.debugfs_fd, data.op_psr_mode);
+ psr_enable(data.drm_fd, data.debugfs_fd, data.op_psr_mode);
test_dc_state_psr(&data, CHECK_DC5);
}
igt_describe("This test validates display engine entry to DC6 state "
"while PSR is active");
igt_subtest("dc6-psr") {
- igt_require(psr_sink_support(data.debugfs_fd, PSR_MODE_1));
+ igt_require(psr_sink_support(data.drm_fd, data.debugfs_fd, PSR_MODE_1));
data.op_psr_mode = PSR_MODE_1;
- psr_enable(data.debugfs_fd, data.op_psr_mode);
+ psr_enable(data.drm_fd, data.debugfs_fd, data.op_psr_mode);
igt_require_f(igt_pm_pc8_plus_residencies_enabled(data.msr_fd),
"PC8+ residencies not supported\n");
test_dc_state_psr(&data, CHECK_DC6);
diff --git a/tests/kms_busy.c b/tests/kms_busy.c
index be4273bc4..222612e79 100644
--- a/tests/kms_busy.c
+++ b/tests/kms_busy.c
@@ -374,20 +374,20 @@ igt_main
igt_subtest_f("extended-modeset-hang-oldfb-with-reset-%s-pipe-%s",
e->name, kmstest_pipe_name(n)) {
- igt_set_module_param_int("force_reset_modeset_test", 1);
+ igt_set_module_param_int(display.drm_fd, "force_reset_modeset_test", 1);
test_hang(&display, eb_ring(e), n, true, false);
- igt_set_module_param_int("force_reset_modeset_test", 0);
+ igt_set_module_param_int(display.drm_fd, "force_reset_modeset_test", 0);
}
igt_subtest_f("extended-modeset-hang-newfb-with-reset-%s-pipe-%s",
e->name, kmstest_pipe_name(n)) {
- igt_set_module_param_int("force_reset_modeset_test", 1);
+ igt_set_module_param_int(display.drm_fd, "force_reset_modeset_test", 1);
test_hang(&display, eb_ring(e), n, true, true);
- igt_set_module_param_int("force_reset_modeset_test", 0);
+ igt_set_module_param_int(display.drm_fd, "force_reset_modeset_test", 0);
}
igt_fixture {
diff --git a/tests/kms_fbcon_fbt.c b/tests/kms_fbcon_fbt.c
index 143be3e37..7eba4ac5d 100644
--- a/tests/kms_fbcon_fbt.c
+++ b/tests/kms_fbcon_fbt.c
@@ -89,7 +89,7 @@ static void teardown_drm(struct drm_info *drm)
drm->fd = -1;
}
-static bool fbc_supported_on_chipset(int debugfs_fd)
+static bool fbc_supported_on_chipset(int device, int debugfs_fd)
{
char buf[128];
int ret;
@@ -266,9 +266,9 @@ static bool psr_is_disabled(int debugfs_fd)
return r;
}
-static bool psr_supported_on_chipset(int debugfs_fd)
+static bool psr_supported_on_chipset(int device, int debugfs_fd)
{
- return psr_sink_support(debugfs_fd, PSR_MODE_1);
+ return psr_sink_support(device, debugfs_fd, PSR_MODE_1);
}
static bool psr_wait_until_update(struct drm_info *drm)
@@ -276,30 +276,30 @@ static bool psr_wait_until_update(struct drm_info *drm)
return psr_long_wait_update(drm->debugfs_fd, PSR_MODE_1);
}
-static void disable_features(int debugfs_fd)
+static void disable_features(int device, int debugfs_fd)
{
- igt_set_module_param_int("enable_fbc", 0);
- if (psr_sink_support(debugfs_fd, PSR_MODE_1))
- psr_disable(debugfs_fd);
+ igt_set_module_param_int(device, "enable_fbc", 0);
+ if (psr_sink_support(device, debugfs_fd, PSR_MODE_1))
+ psr_disable(device, debugfs_fd);
}
-static inline void fbc_modparam_enable(int debugfs_fd)
+static inline void fbc_modparam_enable(int device, int debugfs_fd)
{
- igt_set_module_param_int("enable_fbc", 1);
+ igt_set_module_param_int(device, "enable_fbc", 1);
}
-static inline void psr_debugfs_enable(int debugfs_fd)
+static inline void psr_debugfs_enable(int device, int debugfs_fd)
{
- psr_enable(debugfs_fd, PSR_MODE_1);
+ psr_enable(device, debugfs_fd, PSR_MODE_1);
}
struct feature {
- bool (*supported_on_chipset)(int debugfs_fd);
+ bool (*supported_on_chipset)(int device, int debugfs_fd);
bool (*wait_until_enabled)(int debugfs_fd);
bool (*is_disabled)(int debugfs_fd);
bool (*wait_until_update)(struct drm_info *drm);
bool (*connector_possible_fn)(drmModeConnectorPtr connector);
- void (*enable)(int debugfs_fd);
+ void (*enable)(int device, int debugfs_fd);
} fbc = {
.supported_on_chipset = fbc_supported_on_chipset,
.wait_until_enabled = fbc_wait_until_enabled,
@@ -322,10 +322,10 @@ static void subtest(struct drm_info *drm, struct feature *feature, bool suspend)
setup_drm(drm);
- igt_require(feature->supported_on_chipset(drm->debugfs_fd));
+ igt_require(feature->supported_on_chipset(drm->fd, drm->debugfs_fd));
- disable_features(drm->debugfs_fd);
- feature->enable(drm->debugfs_fd);
+ disable_features(drm->fd, drm->debugfs_fd);
+ feature->enable(drm->fd, drm->debugfs_fd);
kmstest_unset_all_crtcs(drm->fd, drm->res);
wait_user("Modes unset.");
diff --git a/tests/kms_force_connector_basic.c b/tests/kms_force_connector_basic.c
index ddbd97efd..b1a5bac19 100644
--- a/tests/kms_force_connector_basic.c
+++ b/tests/kms_force_connector_basic.c
@@ -53,7 +53,7 @@ static void reset_connectors(void)
drmModeFreeConnector(connector);
}
- igt_set_module_param_int("load_detect_test", 0);
+ igt_set_module_param_int(drm_fd, "load_detect_test", 0);
}
static int opt_handler(int opt, int opt_index, void *data)
@@ -158,7 +158,7 @@ igt_main_args("", long_opts, help_str, opt_handler, NULL)
kmstest_set_vt_graphics_mode();
kmstest_unset_all_crtcs(drm_fd, res);
- igt_set_module_param_int("load_detect_test", 1);
+ igt_set_module_param_int(drm_fd, "load_detect_test", 1);
plane_resources = drmModeGetPlaneResources(drm_fd);
igt_assert(plane_resources);
@@ -201,7 +201,7 @@ igt_main_args("", long_opts, help_str, opt_handler, NULL)
*/
temp = drmModeGetConnector(drm_fd, connector->connector_id);
- igt_set_module_param_int("load_detect_test", 0);
+ igt_set_module_param_int(drm_fd, "load_detect_test", 0);
igt_assert(temp->connection != DRM_MODE_UNKNOWNCONNECTION);
diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index 5d55560d5..780fecfe8 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -938,8 +938,8 @@ static bool drrs_wait_until_rr_switch_to_low(void)
return igt_wait(is_drrs_low(), 5000, 1);
}
-#define fbc_enable() igt_set_module_param_int("enable_fbc", 1)
-#define fbc_disable() igt_set_module_param_int("enable_fbc", 0)
+#define fbc_enable() igt_set_module_param_int(drm.fd, "enable_fbc", 1)
+#define fbc_disable() igt_set_module_param_int(drm.fd, "enable_fbc", 0)
#define drrs_enable() drrs_set(1)
#define drrs_disable() drrs_set(0)
@@ -1135,7 +1135,7 @@ static bool disable_features(const struct test_mode *t)
fbc_disable();
drrs_disable();
- return psr.can_test ? psr_disable(drm.debugfs) : false;
+ return psr.can_test ? psr_disable(drm.fd, drm.debugfs) : false;
}
static void *busy_thread_func(void *data)
@@ -1427,7 +1427,7 @@ static void setup_psr(void)
return;
}
- if (!psr_sink_support(drm.debugfs, PSR_MODE_1)) {
+ if (!psr_sink_support(drm.fd, drm.debugfs, PSR_MODE_1)) {
igt_info("Can't test PSR: not supported by sink.\n");
return;
}
@@ -1725,7 +1725,7 @@ static bool enable_features_for_test(const struct test_mode *t)
if (t->feature & FEATURE_FBC)
fbc_enable();
if (t->feature & FEATURE_PSR)
- ret = psr_enable(drm.debugfs, PSR_MODE_1);
+ ret = psr_enable(drm.fd, drm.debugfs, PSR_MODE_1);
if (t->feature & FEATURE_DRRS)
drrs_enable();
diff --git a/tests/kms_panel_fitting.c b/tests/kms_panel_fitting.c
index 065fc2df8..4f4c56087 100644
--- a/tests/kms_panel_fitting.c
+++ b/tests/kms_panel_fitting.c
@@ -231,7 +231,7 @@ static void test_atomic_fastset(data_t *data)
/* Until this is force enabled, force modeset evasion. */
if (stat("/sys/module/i915/parameters/fastboot", &sb) == 0)
- igt_set_module_param_int("fastboot", 1);
+ igt_set_module_param_int(data->drm_fd, "fastboot", 1);
igt_require(display->is_atomic);
igt_require(intel_gen(intel_get_drm_devid(display->drm_fd)) >= 5);
diff --git a/tests/kms_psr.c b/tests/kms_psr.c
index 13ed02f46..f40902fbb 100644
--- a/tests/kms_psr.c
+++ b/tests/kms_psr.c
@@ -195,7 +195,7 @@ static void fill_render(data_t *data, uint32_t handle, unsigned char color)
static bool sink_support(data_t *data, enum psr_mode mode)
{
return data->with_psr_disabled ||
- psr_sink_support(data->debugfs_fd, mode);
+ psr_sink_support(data->drm_fd, data->debugfs_fd, mode);
}
static bool psr_wait_entry_if_enabled(data_t *data)
@@ -219,7 +219,7 @@ static bool psr_enable_if_enabled(data_t *data)
if (data->with_psr_disabled)
return true;
- return psr_enable(data->debugfs_fd, data->op_psr_mode);
+ return psr_enable(data->drm_fd, data->debugfs_fd, data->op_psr_mode);
}
static inline void manual(const char *expected)
@@ -525,7 +525,7 @@ igt_main_args("", long_options, help_str, opt_handler, &data)
igt_fixture {
if (!data.with_psr_disabled)
- psr_disable(data.debugfs_fd);
+ psr_disable(data.drm_fd, data.debugfs_fd);
close(data.debugfs_fd);
drm_intel_bufmgr_destroy(data.bufmgr);
diff --git a/tests/kms_psr2_su.c b/tests/kms_psr2_su.c
index 9f40c7355..a834a96e3 100644
--- a/tests/kms_psr2_su.c
+++ b/tests/kms_psr2_su.c
@@ -243,7 +243,8 @@ igt_main
data.debugfs_fd = igt_debugfs_dir(data.drm_fd);
kmstest_set_vt_graphics_mode();
- igt_require_f(psr_sink_support(data.debugfs_fd, PSR_MODE_2),
+ igt_require_f(psr_sink_support(data.drm_fd,
+ data.debugfs_fd, PSR_MODE_2),
"Sink does not support PSR2\n");
data.bufmgr = drm_intel_bufmgr_gem_init(data.drm_fd, 4096);
@@ -253,7 +254,8 @@ igt_main
display_init(&data);
/* Test if PSR2 can be enabled */
- igt_require_f(psr_enable(data.debugfs_fd, PSR_MODE_2),
+ igt_require_f(psr_enable(data.drm_fd,
+ data.debugfs_fd, PSR_MODE_2),
"Error enabling PSR2\n");
data.op = FRONTBUFFER;
prepare(&data);
--
2.26.2
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Intel-gfx] [PATCH i-g-t 2/2] lib: Cleanup __igt_params_open()
2020-05-18 23:32 [Intel-gfx] [PATCH i-g-t 1/2] Always pass device to igt_params_set Chris Wilson
@ 2020-05-18 23:32 ` Chris Wilson
0 siblings, 0 replies; 2+ messages in thread
From: Chris Wilson @ 2020-05-18 23:32 UTC (permalink / raw)
To: igt-dev; +Cc: Jani Nikula, intel-gfx, Chris Wilson
The device always exist, so use it to derive the module name required to
lookup either the debugfs params directory or the sysfs module parameters.
Fixes: 2f5cee33ce55 ("igt/params: use igt_params_set_save for igt_set_module_param*")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
---
lib/igt_params.c | 165 +++++++++--------------------------------------
1 file changed, 29 insertions(+), 136 deletions(-)
diff --git a/lib/igt_params.c b/lib/igt_params.c
index 3decc5b2a..c06416988 100644
--- a/lib/igt_params.c
+++ b/lib/igt_params.c
@@ -80,9 +80,18 @@ static void igt_params_exit_handler(int sig)
* Notice that this function is called by igt_set_module_param(), so that one -
* or one of its wrappers - is the only function the test programs need to call.
*/
-static void igt_params_save(int dir, const char *path, const char *name)
+static void igt_params_save(int dir, const char *name)
{
struct module_param_data *data;
+ char path[PATH_MAX];
+ char buf[80];
+ int len;
+
+ snprintf(buf, sizeof(buf), "/proc/self/fd/%d", dir);
+ len = readlink(buf, path, sizeof(path) - 1);
+ if (len < 0)
+ return;
+ path[len] = '\0';
/* Check if this parameter is already saved. */
for (data = module_params; data != NULL; data = data->next)
@@ -110,175 +119,59 @@ static void igt_params_save(int dir, const char *path, const char *name)
}
/**
- * __igt_params_open:
- * @device: fd of the device or -1 for default
- * @outpath: full path to the sysfs directory if not NULL
- * @param: name of parameter of interest
- *
- * Find parameter of interest and return parameter directory fd, parameter
- * is first searched at debugfs/dri/N/<device>_params and if not found will
- * look for parameter at /sys/module/<device>/parameters.
- *
- * Giving -1 here for default device will search for matching device from
- * debugfs/dri/N where N go from 0 to 63. First device found from debugfs
- * which exist also at /sys/module/<device> will be 'default'.
- * Default device will only be used for sysfs, not for debugfs.
+ * igt_params_open:
+ * @device: fd of the device
*
- * If outpath is not NULL caller is responsible to free given pointer.
+ * This opens the module parameters directory (under sysfs) corresponding
+ * to the device for use with igt_sysfs_set() and igt_sysfs_get().
*
* Returns:
- * Directory fd, or -1 on failure.
+ * The directory fd, or -1 on failure.
*/
-static int __igt_params_open(int device, char **outpath, const char *param)
+int igt_params_open(int device)
{
+ drm_version_t version;
int dir, params = -1;
- struct stat buffer;
- char searchname[64];
- char searchpath[PATH_MAX];
- char *foundname, *ctx;
+ char path[PATH_MAX];
+ char name[32] = "";
+
+ memset(&version, 0, sizeof(version));
+ version.name_len = sizeof(name);
+ version.name = name;
+ if (ioctl(device, DRM_IOCTL_VERSION, &version))
+ return -1;
dir = igt_debugfs_dir(device);
if (dir >= 0) {
- int devname;
-
- devname = openat(dir, "name", O_RDONLY);
- igt_require_f(devname >= 0,
- "Driver need to name itself in debugfs!");
-
- read(devname, searchname, sizeof(searchname));
- close(devname);
-
- foundname = strtok_r(searchname, " ", &ctx);
- igt_require_f(foundname,
- "Driver need to name itself in debugfs!");
-
- snprintf(searchpath, PATH_MAX, "%s_params", foundname);
- params = openat(dir, searchpath, O_RDONLY);
-
- if (params >= 0) {
- char *debugfspath = malloc(PATH_MAX);
-
- igt_debugfs_path(device, debugfspath, PATH_MAX);
- if (param != NULL) {
- char filepath[PATH_MAX];
-
- snprintf(filepath, PATH_MAX, "%s/%s",
- debugfspath, param);
-
- if (stat(filepath, &buffer) == 0) {
- if (outpath != NULL)
- *outpath = debugfspath;
- else
- free(debugfspath);
- } else {
- free(debugfspath);
- close(params);
- params = -1;
- }
- } else if (outpath != NULL) {
- /*
- * Caller is responsible to free this.
- */
- *outpath = debugfspath;
- } else {
- free(debugfspath);
- }
- }
+ snprintf(path, PATH_MAX, "%s_params", name);
+ params = openat(dir, path, O_RDONLY);
close(dir);
}
if (params < 0) { /* builtin? */
- drm_version_t version;
- char name[32] = "";
- char path[PATH_MAX];
-
- if (device == -1) {
- /*
- * find default device
- */
- int file, i;
- const char *debugfs_root = igt_debugfs_mount();
-
- igt_assert(debugfs_root);
-
- for (i = 0; i < 63; i++) {
- char testpath[PATH_MAX];
-
- snprintf(searchpath, PATH_MAX,
- "%s/dri/%d/name", debugfs_root, i);
-
- file = open(searchpath, O_RDONLY);
-
- if (file < 0)
- continue;
-
- read(file, searchname, sizeof(searchname));
- close(file);
-
- foundname = strtok_r(searchname, " ", &ctx);
- if (!foundname)
- continue;
-
- snprintf(testpath, PATH_MAX,
- "/sys/module/%s/parameters",
- foundname);
-
- if (stat(testpath, &buffer) == 0 &&
- S_ISDIR(buffer.st_mode)) {
- snprintf(name, sizeof(name), "%s",
- foundname);
- break;
- }
- }
- } else {
- memset(&version, 0, sizeof(version));
- version.name_len = sizeof(name);
- version.name = name;
- ioctl(device, DRM_IOCTL_VERSION, &version);
- }
snprintf(path, sizeof(path), "/sys/module/%s/parameters", name);
params = open(path, O_RDONLY);
- if (params >= 0 && outpath)
- *outpath = strdup(path);
}
return params;
}
-/**
- * igt_params_open:
- * @device: fd of the device
- *
- * This opens the module parameters directory (under sysfs) corresponding
- * to the device for use with igt_sysfs_set() and igt_sysfs_get().
- *
- * Returns:
- * The directory fd, or -1 on failure.
- */
-int igt_params_open(int device)
-{
- return __igt_params_open(device, NULL, NULL);
-}
-
__attribute__((format(printf, 3, 0)))
static bool __igt_params_set(int device, const char *parameter,
const char *fmt, va_list ap, bool save)
{
- char *path = NULL;
int dir;
int ret;
- dir = __igt_params_open(device, save ? &path : NULL, parameter);
+ dir = igt_params_open(device);
if (dir < 0)
return false;
if (save)
- igt_params_save(dir, path, parameter);
+ igt_params_save(dir, parameter);
ret = igt_sysfs_vprintf(dir, parameter, fmt, ap);
-
close(dir);
- free(path);
return ret > 0;
}
--
2.26.2
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-18 23:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-18 23:32 [Intel-gfx] [PATCH i-g-t 1/2] Always pass device to igt_params_set Chris Wilson
2020-05-18 23:32 ` [Intel-gfx] [PATCH i-g-t 2/2] lib: Cleanup __igt_params_open() Chris Wilson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).