Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] lib/igt_sysfs: move kick_snd_hda_intel() to igt_kmod.c
@ 2023-10-25  9:18 Mauro Carvalho Chehab
  2023-10-25 10:05 ` [igt-dev] ✗ Fi.CI.BUILD: failure for " Patchwork
  2023-10-25 10:10 ` [igt-dev] ✗ GitLab.Pipeline: warning " Patchwork
  0 siblings, 2 replies; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2023-10-25  9:18 UTC (permalink / raw)
  To: igt-dev

From: Mauro Carvalho Chehab <mchehab@kernel.org>

This unbind function is now used only inside igt_kmod, and
should be called only via igt_always_unload_audio_driver(),
which does other required steps to unbind the audio driver.

So, move it to igt_kmod and make it static.

Suggested-by: Andrzej Hajda <andrzej.hajda@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
 lib/igt_kmod.c  | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_sysfs.c | 52 -------------------------------------------------
 lib/igt_sysfs.h |  1 -
 3 files changed, 52 insertions(+), 53 deletions(-)

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index 4785d724aec8..55a9de4d725c 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -437,6 +437,58 @@ igt_intel_driver_load(const char *opts, const char *driver)
 	return 0;
 }
 
+/**
+ * kick_snd_hda_intel:
+ *
+ * This function unbinds the snd_hda_intel driver so the module cand be
+ * unloaded.
+ *
+ */
+static void kick_snd_hda_intel(void)
+{
+	DIR *dir;
+	struct dirent *snd_hda;
+	int fd; size_t len;
+
+	const char *dpath = "/sys/bus/pci/drivers/snd_hda_intel";
+	const char *path = "/sys/bus/pci/drivers/snd_hda_intel/unbind";
+	const char *devid = "0000:";
+
+	fd = open(path, O_WRONLY);
+	if (fd < 0) {
+		return;
+	}
+
+	dir = opendir(dpath);
+	if (!dir)
+		goto out;
+
+	len = strlen(devid);
+	while ((snd_hda = readdir(dir))) {
+		struct stat st;
+		char fpath[PATH_MAX];
+
+		if (*snd_hda->d_name == '.')
+			continue;
+
+		snprintf(fpath, sizeof(fpath), "%s/%s", dpath, snd_hda->d_name);
+		if (lstat(fpath, &st))
+			continue;
+
+		if (!S_ISLNK(st.st_mode))
+			continue;
+
+		if (!strncmp(devid, snd_hda->d_name, len)) {
+			igt_ignore_warn(write(fd, snd_hda->d_name,
+					strlen(snd_hda->d_name)));
+		}
+	}
+
+	closedir(dir);
+out:
+	close(fd);
+}
+
 static int igt_always_unload_audio_driver(char **who)
 {
 	int ret;
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 83182020b498..567b4f6d5f03 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -856,58 +856,6 @@ void bind_fbcon(bool enable)
 	bind_con("frame buffer device", enable);
 }
 
-/**
- * kick_snd_hda_intel:
- *
- * This functions unbinds the snd_hda_intel driver so the module cand be
- * unloaded.
- *
- */
-void kick_snd_hda_intel(void)
-{
-	DIR *dir;
-	struct dirent *snd_hda;
-	int fd; size_t len;
-
-	const char *dpath = "/sys/bus/pci/drivers/snd_hda_intel";
-	const char *path = "/sys/bus/pci/drivers/snd_hda_intel/unbind";
-	const char *devid = "0000:";
-
-	fd = open(path, O_WRONLY);
-	if (fd < 0) {
-		return;
-	}
-
-	dir = opendir(dpath);
-	if (!dir)
-		goto out;
-
-	len = strlen(devid);
-	while ((snd_hda = readdir(dir))) {
-		struct stat st;
-		char fpath[PATH_MAX];
-
-		if (*snd_hda->d_name == '.')
-			continue;
-
-		snprintf(fpath, sizeof(fpath), "%s/%s", dpath, snd_hda->d_name);
-		if (lstat(fpath, &st))
-			continue;
-
-		if (!S_ISLNK(st.st_mode))
-			continue;
-
-		if (!strncmp(devid, snd_hda->d_name, len)) {
-			igt_ignore_warn(write(fd, snd_hda->d_name,
-					strlen(snd_hda->d_name)));
-		}
-	}
-
-	closedir(dir);
-out:
-	close(fd);
-}
-
 static int fbcon_cursor_blink_fd = -1;
 static char fbcon_cursor_blink_prev_value[2];
 
diff --git a/lib/igt_sysfs.h b/lib/igt_sysfs.h
index 0087c03b706a..e804cf8e109d 100644
--- a/lib/igt_sysfs.h
+++ b/lib/igt_sysfs.h
@@ -135,7 +135,6 @@ bool __igt_sysfs_set_boolean(int dir, const char *attr, bool value);
 void igt_sysfs_set_boolean(int dir, const char *attr, bool value);
 
 void bind_fbcon(bool enable);
-void kick_snd_hda_intel(void);
 void fbcon_blink_enable(bool enable);
 
 /**
-- 
2.41.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [igt-dev] ✗ Fi.CI.BUILD: failure for lib/igt_sysfs: move kick_snd_hda_intel() to igt_kmod.c
  2023-10-25  9:18 [igt-dev] [PATCH i-g-t] lib/igt_sysfs: move kick_snd_hda_intel() to igt_kmod.c Mauro Carvalho Chehab
@ 2023-10-25 10:05 ` Patchwork
  2023-10-25 10:10 ` [igt-dev] ✗ GitLab.Pipeline: warning " Patchwork
  1 sibling, 0 replies; 5+ messages in thread
From: Patchwork @ 2023-10-25 10:05 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: igt-dev

== Series Details ==

Series: lib/igt_sysfs: move kick_snd_hda_intel() to igt_kmod.c
URL   : https://patchwork.freedesktop.org/series/125553/
State : failure

== Summary ==

IGT patchset build failed on latest successful build
cdc8d1fcd23c0480145f83af79a222fd9ca2eeb6 tests/device_reset: fix logic to unbind when snd_hda_intel is loaded

Tail of build.log:
[270/1645] Compiling C object 'lib/76b5a35@@igt-rendercopy_i915_c@sta/rendercopy_i915.c.o'.
[271/1645] Compiling C object 'lib/76b5a35@@igt-rendercopy_i830_c@sta/rendercopy_i830.c.o'.
[272/1645] Compiling C object 'lib/76b5a35@@igt-igt_msm_c@sta/igt_msm.c.o'.
[273/1645] Compiling C object 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o'.
[274/1645] Compiling C object 'lib/76b5a35@@igt-intel_aux_pgtable_c@sta/intel_aux_pgtable.c.o'.
[275/1645] Compiling C object 'lib/76b5a35@@igt-intel_allocator_simple_c@sta/intel_allocator_simple.c.o'.
[276/1645] Compiling C object 'lib/76b5a35@@igt-igt_vc4_c@sta/igt_vc4.c.o'.
[277/1645] Compiling C object 'tests/59830eb@@kms_atomic_transition@exe/kms_atomic_transition.c.o'.
[278/1645] Compiling C object 'lib/76b5a35@@igt-intel_compute_c@sta/intel_compute.c.o'.
[279/1645] Compiling C object 'lib/76b5a35@@igt-veboxcopy_gen12_c@sta/veboxcopy_gen12.c.o'.
[280/1645] Compiling C object 'lib/76b5a35@@igt-igt_draw_c@sta/igt_draw.c.o'.
[281/1645] Compiling C object 'tests/59830eb@@kms_lease@exe/kms_lease.c.o'.
[282/1645] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen4_c@sta/rendercopy_gen4.c.o'.
[283/1645] Compiling C object 'tests/59830eb@@kms_flip@exe/kms_flip.c.o'.
[284/1645] Compiling C object 'lib/76b5a35@@igt-igt_edid_c@sta/igt_edid.c.o'.
[285/1645] Compiling C object 'lib/76b5a35@@igt-xe_xe_spin_c@sta/xe_xe_spin.c.o'.
[286/1645] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen7_c@sta/rendercopy_gen7.c.o'.
[287/1645] Compiling C object 'lib/76b5a35@@igt-xe_xe_ioctl_c@sta/xe_xe_ioctl.c.o'.
[288/1645] Compiling C object 'lib/76b5a35@@igt-ioctl_wrappers_c@sta/ioctl_wrappers.c.o'.
[289/1645] Compiling C object 'lib/76b5a35@@igt-igt_frame_c@sta/igt_frame.c.o'.
[290/1645] Compiling C object 'lib/76b5a35@@igt-instdone_c@sta/instdone.c.o'.
[291/1645] Compiling C object 'lib/76b5a35@@igt-xe_xe_util_c@sta/xe_xe_util.c.o'.
[292/1645] Compiling C object 'lib/76b5a35@@igt-igt_device_scan_c@sta/igt_device_scan.c.o'.
[293/1645] Compiling C object 'lib/76b5a35@@igt-intel_allocator_c@sta/intel_allocator.c.o'.
[294/1645] Compiling C object 'lib/76b5a35@@igt-xe_xe_query_c@sta/xe_xe_query.c.o'.
[295/1645] Compiling C object 'lib/76b5a35@@igt-igt_dummyload_c@sta/igt_dummyload.c.o'.
[296/1645] Compiling C object 'lib/76b5a35@@igt-gpu_cmds_c@sta/gpu_cmds.c.o'.
[297/1645] Compiling C object 'lib/76b5a35@@igt-igt_v3d_c@sta/igt_v3d.c.o'.
[298/1645] Compiling C object 'lib/76b5a35@@igt-igt_aux_c@sta/igt_aux.c.o'.
[299/1645] Compiling C object 'lib/76b5a35@@igt-igt_pm_c@sta/igt_pm.c.o'.
[300/1645] Compiling C object 'lib/76b5a35@@igt-intel_bufops_c@sta/intel_bufops.c.o'.
[301/1645] Compiling C object 'lib/76b5a35@@igt-igt_vmwgfx_c@sta/igt_vmwgfx.c.o'.
[302/1645] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen6_c@sta/rendercopy_gen6.c.o'.
[303/1645] Compiling C object 'tests/59830eb@@kms_atomic@exe/kms_atomic.c.o'.
[304/1645] Compiling C object 'lib/76b5a35@@igt-intel_blt_c@sta/intel_blt.c.o'.
[305/1645] Compiling C object 'lib/76b5a35@@igt-igt_amd_c@sta/igt_amd.c.o'.
[306/1645] Generating i915-perf-registers-acmgt3 with a custom command.
[307/1645] Compiling C object 'lib/76b5a35@@igt-igt_core_c@sta/igt_core.c.o'.
[308/1645] Compiling C object 'lib/76b5a35@@igt-intel_batchbuffer_c@sta/intel_batchbuffer.c.o'.
[309/1645] Compiling C object 'lib/76b5a35@@igt-igt_chamelium_c@sta/igt_chamelium.c.o'.
[310/1645] Generating i915-perf-metrics-acmgt3 with a custom command.
[311/1645] Compiling C object 'tests/59830eb@@kms_cursor_legacy@exe/kms_cursor_legacy.c.o'.
[312/1645] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen8_c@sta/rendercopy_gen8.c.o'.
[313/1645] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen9_c@sta/rendercopy_gen9.c.o'.
[314/1645] Compiling C object 'lib/76b5a35@@igt-i915_intel_decode_c@sta/i915_intel_decode.c.o'.
[315/1645] Compiling C object 'lib/76b5a35@@igt-igt_fb_c@sta/igt_fb.c.o'.
[316/1645] Compiling C object 'lib/76b5a35@@igt-igt_kms_c@sta/igt_kms.c.o'.
[317/1645] Compiling C object 'tests/59830eb@@perf@exe/intel_perf.c.o'.
[318/1645] Generating i915-perf-equations with a custom command.
ninja: build stopped: subcommand failed.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [igt-dev] ✗ GitLab.Pipeline: warning for lib/igt_sysfs: move kick_snd_hda_intel() to igt_kmod.c
  2023-10-25  9:18 [igt-dev] [PATCH i-g-t] lib/igt_sysfs: move kick_snd_hda_intel() to igt_kmod.c Mauro Carvalho Chehab
  2023-10-25 10:05 ` [igt-dev] ✗ Fi.CI.BUILD: failure for " Patchwork
@ 2023-10-25 10:10 ` Patchwork
  1 sibling, 0 replies; 5+ messages in thread
From: Patchwork @ 2023-10-25 10:10 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: igt-dev

== Series Details ==

Series: lib/igt_sysfs: move kick_snd_hda_intel() to igt_kmod.c
URL   : https://patchwork.freedesktop.org/series/125553/
State : warning

== Summary ==

Pipeline status: FAILED.

see https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/1018404 for the overview.

build:tests-debian-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/50736039):
     if (!S_ISLNK(st.st_mode))
          ^~~~~~~
          S_IFLNK
  ../lib/igt_kmod.c:478:8: warning: nested extern declaration of ‘S_ISLNK’ [-Wnested-externs]
  ../lib/igt_kmod.c:469:8: warning: unused variable ‘fpath’ [-Wunused-variable]
     char fpath[PATH_MAX];
          ^~~~~
  ../lib/igt_kmod.c:487:2: error: implicit declaration of function ‘closedir’; did you mean ‘close’? [-Werror=implicit-function-declaration]
    closedir(dir);
    ^~~~~~~~
    close
  ../lib/igt_kmod.c:487:2: warning: nested extern declaration of ‘closedir’ [-Wnested-externs]
  cc1: some warnings being treated as errors
  ninja: build stopped: subcommand failed.
  section_end:1698228409:step_script
  section_start:1698228409:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1698228410:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-debian-meson-arm64 has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/50736042):
     if (!S_ISLNK(st.st_mode))
          ^~~~~~~
          S_IFLNK
  ../lib/igt_kmod.c:478:8: warning: nested extern declaration of ‘S_ISLNK’ [-Wnested-externs]
  ../lib/igt_kmod.c:469:8: warning: unused variable ‘fpath’ [-Wunused-variable]
     char fpath[PATH_MAX];
          ^~~~~
  ../lib/igt_kmod.c:487:2: error: implicit declaration of function ‘closedir’; did you mean ‘close’? [-Werror=implicit-function-declaration]
    closedir(dir);
    ^~~~~~~~
    close
  ../lib/igt_kmod.c:487:2: warning: nested extern declaration of ‘closedir’ [-Wnested-externs]
  cc1: some warnings being treated as errors
  ninja: build stopped: subcommand failed.
  section_end:1698228434:step_script
  section_start:1698228434:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1698228435:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-debian-meson-armhf has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/50736041):
     if (!S_ISLNK(st.st_mode))
          ^~~~~~~
          S_IFLNK
  ../lib/igt_kmod.c:478:8: warning: nested extern declaration of ‘S_ISLNK’ [-Wnested-externs]
  ../lib/igt_kmod.c:469:8: warning: unused variable ‘fpath’ [-Wunused-variable]
     char fpath[PATH_MAX];
          ^~~~~
  ../lib/igt_kmod.c:487:2: error: implicit declaration of function ‘closedir’; did you mean ‘close’? [-Werror=implicit-function-declaration]
    closedir(dir);
    ^~~~~~~~
    close
  ../lib/igt_kmod.c:487:2: warning: nested extern declaration of ‘closedir’ [-Wnested-externs]
  cc1: some warnings being treated as errors
  ninja: build stopped: subcommand failed.
  section_end:1698228425:step_script
  section_start:1698228425:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1698228426:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-debian-meson-mips has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/50736043):
     if (!S_ISLNK(st.st_mode))
          ^~~~~~~
          S_IFLNK
  ../lib/igt_kmod.c:478:8: warning: nested extern declaration of ‘S_ISLNK’ [-Wnested-externs]
  ../lib/igt_kmod.c:469:8: warning: unused variable ‘fpath’ [-Wunused-variable]
     char fpath[PATH_MAX];
          ^~~~~
  ../lib/igt_kmod.c:487:2: error: implicit declaration of function ‘closedir’; did you mean ‘close’? [-Werror=implicit-function-declaration]
    closedir(dir);
    ^~~~~~~~
    close
  ../lib/igt_kmod.c:487:2: warning: nested extern declaration of ‘closedir’ [-Wnested-externs]
  cc1: some warnings being treated as errors
  ninja: build stopped: subcommand failed.
  section_end:1698228420:step_script
  section_start:1698228420:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1698228420:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-debian-minimal has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/50736040):
     if (!S_ISLNK(st.st_mode))
          ^~~~~~~
          S_IFLNK
  ../lib/igt_kmod.c:478:8: warning: nested extern declaration of ‘S_ISLNK’ [-Wnested-externs]
  ../lib/igt_kmod.c:469:8: warning: unused variable ‘fpath’ [-Wunused-variable]
     char fpath[PATH_MAX];
          ^~~~~
  ../lib/igt_kmod.c:487:2: error: implicit declaration of function ‘closedir’; did you mean ‘close’? [-Werror=implicit-function-declaration]
    closedir(dir);
    ^~~~~~~~
    close
  ../lib/igt_kmod.c:487:2: warning: nested extern declaration of ‘closedir’ [-Wnested-externs]
  cc1: some warnings being treated as errors
  ninja: build stopped: subcommand failed.
  section_end:1698228405:step_script
  section_start:1698228405:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1698228406:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-fedora has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/50736034):
    478 |   if (!S_ISLNK(st.st_mode))
        |        ^~~~~~~
        |        S_IFLNK
  ../lib/igt_kmod.c:478:8: warning: nested extern declaration of ‘S_ISLNK’ [-Wnested-externs]
  ../lib/igt_kmod.c:469:8: warning: unused variable ‘fpath’ [-Wunused-variable]
    469 |   char fpath[PATH_MAX];
        |        ^~~~~
  ../lib/igt_kmod.c:487:2: error: implicit declaration of function ‘closedir’; did you mean ‘close’? [-Werror=implicit-function-declaration]
    487 |  closedir(dir);
        |  ^~~~~~~~
        |  close
  ../lib/igt_kmod.c:487:2: warning: nested extern declaration of ‘closedir’ [-Wnested-externs]
  cc1: some warnings being treated as errors
  ninja: build stopped: subcommand failed.
  section_end:1698228410:step_script
  section_start:1698228410:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1698228410:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-fedora-clang has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/50736038):
  /usr/include/stdlib.h:852:14: note: 'div' declared here
  extern div_t div (int __numer, int __denom)
               ^
  ../lib/igt_kmod.c:868:5: warning: declaration does not declare anything [-Wmissing-declarations]
                                  __attribute__ ((fallthrough));
                                  ^
  ../lib/igt_kmod.c:1044:5: warning: declaration does not declare anything [-Wmissing-declarations]
                                  __attribute__ ((fallthrough));
                                  ^
  ../lib/igt_kmod.c:1271:5: warning: declaration does not declare anything [-Wmissing-declarations]
                                  __attribute__ ((fallthrough));
                                  ^
  4 warnings and 18 errors generated.
  ninja: build stopped: subcommand failed.
  section_end:1698228421:step_script
  section_start:1698228421:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1698228424:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-fedora-no-libdrm-nouveau has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/50736037):
    478 |   if (!S_ISLNK(st.st_mode))
        |        ^~~~~~~
        |        S_IFLNK
  ../lib/igt_kmod.c:478:8: warning: nested extern declaration of ‘S_ISLNK’ [-Wnested-externs]
  ../lib/igt_kmod.c:469:8: warning: unused variable ‘fpath’ [-Wunused-variable]
    469 |   char fpath[PATH_MAX];
        |        ^~~~~
  ../lib/igt_kmod.c:487:2: error: implicit declaration of function ‘closedir’; did you mean ‘close’? [-Werror=implicit-function-declaration]
    487 |  closedir(dir);
        |  ^~~~~~~~
        |  close
  ../lib/igt_kmod.c:487:2: warning: nested extern declaration of ‘closedir’ [-Wnested-externs]
  cc1: some warnings being treated as errors
  ninja: build stopped: subcommand failed.
  section_end:1698228405:step_script
  section_start:1698228405:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1698228405:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-fedora-no-libunwind has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/50736035):
    478 |   if (!S_ISLNK(st.st_mode))
        |        ^~~~~~~
        |        S_IFLNK
  ../lib/igt_kmod.c:478:8: warning: nested extern declaration of ‘S_ISLNK’ [-Wnested-externs]
  ../lib/igt_kmod.c:469:8: warning: unused variable ‘fpath’ [-Wunused-variable]
    469 |   char fpath[PATH_MAX];
        |        ^~~~~
  ../lib/igt_kmod.c:487:2: error: implicit declaration of function ‘closedir’; did you mean ‘close’? [-Werror=implicit-function-declaration]
    487 |  closedir(dir);
        |  ^~~~~~~~
        |  close
  ../lib/igt_kmod.c:487:2: warning: nested extern declaration of ‘closedir’ [-Wnested-externs]
  cc1: some warnings being treated as errors
  ninja: build stopped: subcommand failed.
  section_end:1698228407:step_script
  section_start:1698228407:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1698228408:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-fedora-oldest-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/50736036):
    478 |   if (!S_ISLNK(st.st_mode))
        |        ^~~~~~~
        |        S_IFLNK
  ../lib/igt_kmod.c:478:8: warning: nested extern declaration of ‘S_ISLNK’ [-Wnested-externs]
  ../lib/igt_kmod.c:469:8: warning: unused variable ‘fpath’ [-Wunused-variable]
    469 |   char fpath[PATH_MAX];
        |        ^~~~~
  ../lib/igt_kmod.c:487:2: error: implicit declaration of function ‘closedir’; did you mean ‘close’? [-Werror=implicit-function-declaration]
    487 |  closedir(dir);
        |  ^~~~~~~~
        |  close
  ../lib/igt_kmod.c:487:2: warning: nested extern declaration of ‘closedir’ [-Wnested-externs]
  cc1: some warnings being treated as errors
  ninja: build stopped: subcommand failed.
  section_end:1698228410:step_script
  section_start:1698228410:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1698228411:cleanup_file_variables
  ERROR: Job failed: exit code 1

== Logs ==

For more details see: https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/1018404


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [igt-dev] [PATCH i-g-t] lib/igt_sysfs: move kick_snd_hda_intel() to igt_kmod.c
@ 2023-10-26  9:27 Mauro Carvalho Chehab
  2023-10-26 10:40 ` Kamil Konieczny
  0 siblings, 1 reply; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2023-10-26  9:27 UTC (permalink / raw)
  To: igt-dev

From: Mauro Carvalho Chehab <mchehab@kernel.org>

This unbind function is now used only inside igt_kmod, and
should be called only via igt_always_unload_audio_driver(),
which does other required steps to unbind the audio driver.

So, move it to igt_kmod and make it static.

Suggested-by: Andrzej Hajda <andrzej.hajda@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

---

v4: place includes in alphabetic order
v3: fix a typo on a message: cand ->can
v2: added some missing includes
---
 lib/igt_kmod.c  | 57 ++++++++++++++++++++++++++++++++++++++++++++++++-
 lib/igt_sysfs.c | 52 --------------------------------------------
 lib/igt_sysfs.h |  1 -
 3 files changed, 56 insertions(+), 54 deletions(-)

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index 4785d724aec8..e967c9bcdce0 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -22,12 +22,15 @@
  */
 
 #include <ctype.h>
-#include <signal.h>
+#include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <pthread.h>
+#include <signal.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 #include <sys/utsname.h>
 #include <unistd.h>
 
@@ -437,6 +440,58 @@ igt_intel_driver_load(const char *opts, const char *driver)
 	return 0;
 }
 
+/**
+ * kick_snd_hda_intel:
+ *
+ * This function unbinds the snd_hda_intel driver so the module can be
+ * unloaded.
+ *
+ */
+static void kick_snd_hda_intel(void)
+{
+	DIR *dir;
+	struct dirent *snd_hda;
+	int fd; size_t len;
+
+	const char *dpath = "/sys/bus/pci/drivers/snd_hda_intel";
+	const char *path = "/sys/bus/pci/drivers/snd_hda_intel/unbind";
+	const char *devid = "0000:";
+
+	fd = open(path, O_WRONLY);
+	if (fd < 0) {
+		return;
+	}
+
+	dir = opendir(dpath);
+	if (!dir)
+		goto out;
+
+	len = strlen(devid);
+	while ((snd_hda = readdir(dir))) {
+		struct stat st;
+		char fpath[PATH_MAX];
+
+		if (*snd_hda->d_name == '.')
+			continue;
+
+		snprintf(fpath, sizeof(fpath), "%s/%s", dpath, snd_hda->d_name);
+		if (lstat(fpath, &st))
+			continue;
+
+		if (!S_ISLNK(st.st_mode))
+			continue;
+
+		if (!strncmp(devid, snd_hda->d_name, len)) {
+			igt_ignore_warn(write(fd, snd_hda->d_name,
+					strlen(snd_hda->d_name)));
+		}
+	}
+
+	closedir(dir);
+out:
+	close(fd);
+}
+
 static int igt_always_unload_audio_driver(char **who)
 {
 	int ret;
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 83182020b498..567b4f6d5f03 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -856,58 +856,6 @@ void bind_fbcon(bool enable)
 	bind_con("frame buffer device", enable);
 }
 
-/**
- * kick_snd_hda_intel:
- *
- * This functions unbinds the snd_hda_intel driver so the module cand be
- * unloaded.
- *
- */
-void kick_snd_hda_intel(void)
-{
-	DIR *dir;
-	struct dirent *snd_hda;
-	int fd; size_t len;
-
-	const char *dpath = "/sys/bus/pci/drivers/snd_hda_intel";
-	const char *path = "/sys/bus/pci/drivers/snd_hda_intel/unbind";
-	const char *devid = "0000:";
-
-	fd = open(path, O_WRONLY);
-	if (fd < 0) {
-		return;
-	}
-
-	dir = opendir(dpath);
-	if (!dir)
-		goto out;
-
-	len = strlen(devid);
-	while ((snd_hda = readdir(dir))) {
-		struct stat st;
-		char fpath[PATH_MAX];
-
-		if (*snd_hda->d_name == '.')
-			continue;
-
-		snprintf(fpath, sizeof(fpath), "%s/%s", dpath, snd_hda->d_name);
-		if (lstat(fpath, &st))
-			continue;
-
-		if (!S_ISLNK(st.st_mode))
-			continue;
-
-		if (!strncmp(devid, snd_hda->d_name, len)) {
-			igt_ignore_warn(write(fd, snd_hda->d_name,
-					strlen(snd_hda->d_name)));
-		}
-	}
-
-	closedir(dir);
-out:
-	close(fd);
-}
-
 static int fbcon_cursor_blink_fd = -1;
 static char fbcon_cursor_blink_prev_value[2];
 
diff --git a/lib/igt_sysfs.h b/lib/igt_sysfs.h
index 0087c03b706a..e804cf8e109d 100644
--- a/lib/igt_sysfs.h
+++ b/lib/igt_sysfs.h
@@ -135,7 +135,6 @@ bool __igt_sysfs_set_boolean(int dir, const char *attr, bool value);
 void igt_sysfs_set_boolean(int dir, const char *attr, bool value);
 
 void bind_fbcon(bool enable);
-void kick_snd_hda_intel(void);
 void fbcon_blink_enable(bool enable);
 
 /**
-- 
2.41.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [igt-dev] [PATCH i-g-t] lib/igt_sysfs: move kick_snd_hda_intel() to igt_kmod.c
  2023-10-26  9:27 [igt-dev] [PATCH i-g-t] " Mauro Carvalho Chehab
@ 2023-10-26 10:40 ` Kamil Konieczny
  0 siblings, 0 replies; 5+ messages in thread
From: Kamil Konieczny @ 2023-10-26 10:40 UTC (permalink / raw)
  To: igt-dev

Hi Mauro,
On 2023-10-26 at 11:27:24 +0200, Mauro Carvalho Chehab wrote:
> From: Mauro Carvalho Chehab <mchehab@kernel.org>
> 
> This unbind function is now used only inside igt_kmod, and
> should be called only via igt_always_unload_audio_driver(),
> which does other required steps to unbind the audio driver.
> 
> So, move it to igt_kmod and make it static.
> 
> Suggested-by: Andrzej Hajda <andrzej.hajda@intel.com>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>

> 
> ---
> 
> v4: place includes in alphabetic order
> v3: fix a typo on a message: cand ->can
> v2: added some missing includes
> ---
>  lib/igt_kmod.c  | 57 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  lib/igt_sysfs.c | 52 --------------------------------------------
>  lib/igt_sysfs.h |  1 -
>  3 files changed, 56 insertions(+), 54 deletions(-)
> 
> diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
> index 4785d724aec8..e967c9bcdce0 100644
> --- a/lib/igt_kmod.c
> +++ b/lib/igt_kmod.c
> @@ -22,12 +22,15 @@
>   */
>  
>  #include <ctype.h>
> -#include <signal.h>
> +#include <dirent.h>
>  #include <errno.h>
>  #include <fcntl.h>
>  #include <pthread.h>
> +#include <signal.h>
>  #include <stdlib.h>
>  #include <string.h>
> +#include <sys/stat.h>
> +#include <sys/types.h>
>  #include <sys/utsname.h>
>  #include <unistd.h>
>  
> @@ -437,6 +440,58 @@ igt_intel_driver_load(const char *opts, const char *driver)
>  	return 0;
>  }
>  
> +/**
> + * kick_snd_hda_intel:
> + *
> + * This function unbinds the snd_hda_intel driver so the module can be
> + * unloaded.
> + *
> + */
> +static void kick_snd_hda_intel(void)
> +{
> +	DIR *dir;
> +	struct dirent *snd_hda;
> +	int fd; size_t len;
> +
> +	const char *dpath = "/sys/bus/pci/drivers/snd_hda_intel";
> +	const char *path = "/sys/bus/pci/drivers/snd_hda_intel/unbind";
> +	const char *devid = "0000:";
> +
> +	fd = open(path, O_WRONLY);
> +	if (fd < 0) {
> +		return;
> +	}
> +
> +	dir = opendir(dpath);
> +	if (!dir)
> +		goto out;
> +
> +	len = strlen(devid);
> +	while ((snd_hda = readdir(dir))) {
> +		struct stat st;
> +		char fpath[PATH_MAX];
> +
> +		if (*snd_hda->d_name == '.')
> +			continue;
> +
> +		snprintf(fpath, sizeof(fpath), "%s/%s", dpath, snd_hda->d_name);
> +		if (lstat(fpath, &st))
> +			continue;
> +
> +		if (!S_ISLNK(st.st_mode))
> +			continue;
> +
> +		if (!strncmp(devid, snd_hda->d_name, len)) {
> +			igt_ignore_warn(write(fd, snd_hda->d_name,
> +					strlen(snd_hda->d_name)));
> +		}
> +	}
> +
> +	closedir(dir);
> +out:
> +	close(fd);
> +}
> +
>  static int igt_always_unload_audio_driver(char **who)
>  {
>  	int ret;
> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> index 83182020b498..567b4f6d5f03 100644
> --- a/lib/igt_sysfs.c
> +++ b/lib/igt_sysfs.c
> @@ -856,58 +856,6 @@ void bind_fbcon(bool enable)
>  	bind_con("frame buffer device", enable);
>  }
>  
> -/**
> - * kick_snd_hda_intel:
> - *
> - * This functions unbinds the snd_hda_intel driver so the module cand be
> - * unloaded.
> - *
> - */
> -void kick_snd_hda_intel(void)
> -{
> -	DIR *dir;
> -	struct dirent *snd_hda;
> -	int fd; size_t len;
> -
> -	const char *dpath = "/sys/bus/pci/drivers/snd_hda_intel";
> -	const char *path = "/sys/bus/pci/drivers/snd_hda_intel/unbind";
> -	const char *devid = "0000:";
> -
> -	fd = open(path, O_WRONLY);
> -	if (fd < 0) {
> -		return;
> -	}
> -
> -	dir = opendir(dpath);
> -	if (!dir)
> -		goto out;
> -
> -	len = strlen(devid);
> -	while ((snd_hda = readdir(dir))) {
> -		struct stat st;
> -		char fpath[PATH_MAX];
> -
> -		if (*snd_hda->d_name == '.')
> -			continue;
> -
> -		snprintf(fpath, sizeof(fpath), "%s/%s", dpath, snd_hda->d_name);
> -		if (lstat(fpath, &st))
> -			continue;
> -
> -		if (!S_ISLNK(st.st_mode))
> -			continue;
> -
> -		if (!strncmp(devid, snd_hda->d_name, len)) {
> -			igt_ignore_warn(write(fd, snd_hda->d_name,
> -					strlen(snd_hda->d_name)));
> -		}
> -	}
> -
> -	closedir(dir);
> -out:
> -	close(fd);
> -}
> -
>  static int fbcon_cursor_blink_fd = -1;
>  static char fbcon_cursor_blink_prev_value[2];
>  
> diff --git a/lib/igt_sysfs.h b/lib/igt_sysfs.h
> index 0087c03b706a..e804cf8e109d 100644
> --- a/lib/igt_sysfs.h
> +++ b/lib/igt_sysfs.h
> @@ -135,7 +135,6 @@ bool __igt_sysfs_set_boolean(int dir, const char *attr, bool value);
>  void igt_sysfs_set_boolean(int dir, const char *attr, bool value);
>  
>  void bind_fbcon(bool enable);
> -void kick_snd_hda_intel(void);
>  void fbcon_blink_enable(bool enable);
>  
>  /**
> -- 
> 2.41.0
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-10-26 10:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-25  9:18 [igt-dev] [PATCH i-g-t] lib/igt_sysfs: move kick_snd_hda_intel() to igt_kmod.c Mauro Carvalho Chehab
2023-10-25 10:05 ` [igt-dev] ✗ Fi.CI.BUILD: failure for " Patchwork
2023-10-25 10:10 ` [igt-dev] ✗ GitLab.Pipeline: warning " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2023-10-26  9:27 [igt-dev] [PATCH i-g-t] " Mauro Carvalho Chehab
2023-10-26 10:40 ` Kamil Konieczny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox