* [PATCH i-g-t 1/3] lib/igt_device_scan: drop device scan cache logic
2025-01-23 9:22 [PATCH i-g-t 0/3] Drop device scan cache logic Zbigniew Kempczyński
@ 2025-01-23 9:22 ` Zbigniew Kempczyński
2025-01-23 9:22 ` [PATCH i-g-t 2/3] lib/igt_device_scan: change device list variable visibility Zbigniew Kempczyński
2025-01-23 9:22 ` [PATCH i-g-t 3/3] tests/xe_intel_bb: check multithreading rescans won't segfault Zbigniew Kempczyński
2 siblings, 0 replies; 7+ messages in thread
From: Zbigniew Kempczyński @ 2025-01-23 9:22 UTC (permalink / raw)
To: igt-dev; +Cc: Zbigniew Kempczyński, Lucas De Marchi, Kamil Konieczny
Tests which plays with module unload/load/reload must ensure scanned
device list cache is up-to-date. Missing direct calling of device scan
after module operations may lead to use stale data and use invalid
device name if it was changed in the meantime.
Lucas noticed device scanning overhead is minimal and we may drop
caching logic and scan (get drm data from udev) unconditionally.
From igt_runner perspective where single subtest is a separate process
device scan cost might likely be ignored.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
benchmarks/gem_wsim.c | 2 +-
lib/drmtest.c | 2 +-
lib/igt_device_scan.c | 18 ++++--------------
lib/igt_device_scan.h | 2 +-
lib/igt_multigpu.c | 2 +-
tests/core_hotunplug.c | 2 +-
tests/device_reset.c | 2 +-
tests/intel/i915_suspend.c | 4 ++--
tools/intel_gpu_top.c | 2 +-
tools/intel_pm_rpm.c | 2 +-
tools/lsgpu.c | 2 +-
11 files changed, 15 insertions(+), 25 deletions(-)
diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
index 454b6f017b..7a6b100288 100644
--- a/benchmarks/gem_wsim.c
+++ b/benchmarks/gem_wsim.c
@@ -3178,7 +3178,7 @@ int main(int argc, char **argv)
}
}
- igt_devices_scan(false);
+ igt_devices_scan();
if (list_devices_arg) {
struct igt_devices_print_format fmt = {
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 2dd4540b85..436b6de780 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -475,7 +475,7 @@ void drm_load_module(unsigned int chipset)
}
pthread_mutex_unlock(&mutex);
- igt_devices_scan(true);
+ igt_devices_scan();
}
static int __open_driver(const char *base, int offset, unsigned int chipset, int as_idx)
diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
index 8e2297087e..304cfa17a8 100644
--- a/lib/igt_device_scan.c
+++ b/lib/igt_device_scan.c
@@ -1083,30 +1083,20 @@ void igt_devices_free(void)
igt_device_free(dev);
free(dev);
}
- igt_devs.devs_scanned = false;
}
/**
* igt_devices_scan
* @force: enforce scanning devices
*
- * Function scans udev in search of gpu devices. For first run it can be
- * called with @force = false. If something changes during the the test
- * or test does some module loading (new drm devices occurs during execution)
- * function must be called again with @force = true to refresh device array.
+ * Function scans udev in search of gpu devices.
*/
-void igt_devices_scan(bool force)
+void igt_devices_scan(void)
{
- if (force && igt_devs.devs_scanned)
- igt_devices_free();
-
if (igt_devs.devs_scanned)
- return;
-
+ igt_devices_free();
prepare_scan();
scan_drm_devices();
-
- igt_devs.devs_scanned = true;
}
static inline void _pr_simple(const char *k, const char *v)
@@ -1983,7 +1973,7 @@ static bool __igt_device_card_match(const char *filter,
* Scan devices in case the user hasn't yet,
* but leave a decision on forced rescan on the user side.
*/
- igt_devices_scan(false);
+ igt_devices_scan();
if (igt_device_filter_apply(filter) == false)
return false;
diff --git a/lib/igt_device_scan.h b/lib/igt_device_scan.h
index 9087337458..fa90134aa3 100644
--- a/lib/igt_device_scan.h
+++ b/lib/igt_device_scan.h
@@ -63,7 +63,7 @@ struct igt_device_card {
uint16_t pci_vendor, pci_device;
};
-void igt_devices_scan(bool force);
+void igt_devices_scan(void);
void igt_devices_print(const struct igt_devices_print_format *fmt);
void igt_devices_print_vendors(void);
diff --git a/lib/igt_multigpu.c b/lib/igt_multigpu.c
index be0c113322..d4b89d706a 100644
--- a/lib/igt_multigpu.c
+++ b/lib/igt_multigpu.c
@@ -37,7 +37,7 @@ static int print_gpus(int count, int gpu_num)
igt_info("PCI devices available in the system:\n");
- igt_devices_scan(true);
+ igt_devices_scan();
devices = igt_device_filter_pci();
igt_devices_print(&fmt);
diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index 7f17f4423d..18e9dfc346 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -488,7 +488,7 @@ static bool healthcheck(struct hotunplug *priv, bool recover)
sleep(1);
/* device name may have changed, rebuild IGT device list */
- igt_devices_scan(true);
+ igt_devices_scan();
node_healthcheck(priv, recover ? FLAG_RECOVER : 0);
if (!priv->failure)
diff --git a/tests/device_reset.c b/tests/device_reset.c
index 40681931c2..6c93a96c21 100644
--- a/tests/device_reset.c
+++ b/tests/device_reset.c
@@ -399,7 +399,7 @@ static void healthcheck(struct device_fds *dev)
/* give the kernel a breath for re-creating device nodes in devtmpfs */
sleep(1);
/* refresh device list */
- igt_devices_scan(true);
+ igt_devices_scan();
igt_debug("reopen the device\n");
dev->fds.dev = __drm_open_driver(DRIVER_ANY);
}
diff --git a/tests/intel/i915_suspend.c b/tests/intel/i915_suspend.c
index 3398b372b5..fae1031a23 100644
--- a/tests/intel/i915_suspend.c
+++ b/tests/intel/i915_suspend.c
@@ -265,7 +265,7 @@ test_suspend_without_i915(int state)
int fd;
fd = __drm_open_driver(DRIVER_INTEL);
- igt_devices_scan(false);
+ igt_devices_scan();
/*
* When module is unloaded and s2idle is triggered, PCI core leaves the endpoint
@@ -317,7 +317,7 @@ igt_main
* instead of reloading the i915 module.
*/
if (igt_device_filter_count())
- igt_devices_scan(true);
+ igt_devices_scan();
fd = drm_open_driver(DRIVER_INTEL);
}
diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index a608b894d3..68d27089b9 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -2701,7 +2701,7 @@ int main(int argc, char **argv)
break;
};
- igt_devices_scan(false);
+ igt_devices_scan();
if (list_device) {
struct igt_devices_print_format fmt = {
diff --git a/tools/intel_pm_rpm.c b/tools/intel_pm_rpm.c
index 17cd2bc1d6..08c25ca8a6 100644
--- a/tools/intel_pm_rpm.c
+++ b/tools/intel_pm_rpm.c
@@ -142,7 +142,7 @@ int main(int argc, char *argv[])
}
env_device = getenv("IGT_DEVICE");
- igt_devices_scan(false);
+ igt_devices_scan();
if (env_device) {
if (!igt_device_card_match(env_device, &card)) {
diff --git a/tools/lsgpu.c b/tools/lsgpu.c
index 2bf2cf5f05..e482ca6b75 100644
--- a/tools/lsgpu.c
+++ b/tools/lsgpu.c
@@ -362,7 +362,7 @@ int main(int argc, char *argv[])
printf("Notice: Using filter from .igtrc\n");
}
- igt_devices_scan(false);
+ igt_devices_scan();
if (igt_device != NULL) {
struct igt_device_card card;
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH i-g-t 2/3] lib/igt_device_scan: change device list variable visibility
2025-01-23 9:22 [PATCH i-g-t 0/3] Drop device scan cache logic Zbigniew Kempczyński
2025-01-23 9:22 ` [PATCH i-g-t 1/3] lib/igt_device_scan: drop " Zbigniew Kempczyński
@ 2025-01-23 9:22 ` Zbigniew Kempczyński
2025-01-23 17:37 ` Lucas De Marchi
2025-01-23 9:22 ` [PATCH i-g-t 3/3] tests/xe_intel_bb: check multithreading rescans won't segfault Zbigniew Kempczyński
2 siblings, 1 reply; 7+ messages in thread
From: Zbigniew Kempczyński @ 2025-01-23 9:22 UTC (permalink / raw)
To: igt-dev; +Cc: Zbigniew Kempczyński, Lucas De Marchi, Kamil Konieczny
In commit: 2e8f3e06fb (tests/xe_evict|exec_threads: Use fd reopen
to avoid corrupting global data) I simply changed tests which
corrupted device list global variable. i915 didn't use opening
devices in multithreaded tests but this changed with xe.
Device scan is now unconditional so we may change device list
variable visibility to TLS. With this reverting of above commit
should be safe (but I'm not sure is it worth to do this).
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
lib/igt_device_scan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
index 304cfa17a8..c1b0e0e5ff 100644
--- a/lib/igt_device_scan.c
+++ b/lib/igt_device_scan.c
@@ -247,7 +247,7 @@ struct igt_device {
};
/* Scanned devices */
-static struct {
+static __thread struct {
struct igt_list_head all;
struct igt_list_head filtered;
bool devs_scanned;
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH i-g-t 2/3] lib/igt_device_scan: change device list variable visibility
2025-01-23 9:22 ` [PATCH i-g-t 2/3] lib/igt_device_scan: change device list variable visibility Zbigniew Kempczyński
@ 2025-01-23 17:37 ` Lucas De Marchi
0 siblings, 0 replies; 7+ messages in thread
From: Lucas De Marchi @ 2025-01-23 17:37 UTC (permalink / raw)
To: Zbigniew Kempczyński; +Cc: igt-dev, Kamil Konieczny
On Thu, Jan 23, 2025 at 10:22:09AM +0100, Zbigniew Kempczyński wrote:
>In commit: 2e8f3e06fb (tests/xe_evict|exec_threads: Use fd reopen
>to avoid corrupting global data) I simply changed tests which
>corrupted device list global variable. i915 didn't use opening
>devices in multithreaded tests but this changed with xe.
>
>Device scan is now unconditional so we may change device list
>variable visibility to TLS. With this reverting of above commit
>should be safe (but I'm not sure is it worth to do this).
>
>Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
>Cc: Lucas De Marchi <lucas.demarchi@intel.com>
>Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Lucas De Marchi
>---
> lib/igt_device_scan.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
>index 304cfa17a8..c1b0e0e5ff 100644
>--- a/lib/igt_device_scan.c
>+++ b/lib/igt_device_scan.c
>@@ -247,7 +247,7 @@ struct igt_device {
> };
>
> /* Scanned devices */
>-static struct {
>+static __thread struct {
> struct igt_list_head all;
> struct igt_list_head filtered;
> bool devs_scanned;
>--
>2.34.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH i-g-t 3/3] tests/xe_intel_bb: check multithreading rescans won't segfault
2025-01-23 9:22 [PATCH i-g-t 0/3] Drop device scan cache logic Zbigniew Kempczyński
2025-01-23 9:22 ` [PATCH i-g-t 1/3] lib/igt_device_scan: drop " Zbigniew Kempczyński
2025-01-23 9:22 ` [PATCH i-g-t 2/3] lib/igt_device_scan: change device list variable visibility Zbigniew Kempczyński
@ 2025-01-23 9:22 ` Zbigniew Kempczyński
2025-01-23 17:34 ` Lucas De Marchi
2 siblings, 1 reply; 7+ messages in thread
From: Zbigniew Kempczyński @ 2025-01-23 9:22 UTC (permalink / raw)
To: igt-dev; +Cc: Zbigniew Kempczyński, Lucas De Marchi, Kamil Konieczny
This test is likely only for checking purposes, it doesn't makes
sense to merge it after series review.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
tests/intel-ci/xe-fast-feedback.testlist | 1 +
tests/intel/xe_intel_bb.c | 47 ++++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/tests/intel-ci/xe-fast-feedback.testlist b/tests/intel-ci/xe-fast-feedback.testlist
index 0234d3e72d..7adb9a3436 100644
--- a/tests/intel-ci/xe-fast-feedback.testlist
+++ b/tests/intel-ci/xe-fast-feedback.testlist
@@ -7,6 +7,7 @@ igt@fbdev@nullptr
igt@fbdev@read
igt@fbdev@write
+igt@xe_intel_bb@multithread-open
igt@kms_addfb_basic@addfb25-4-tiled
igt@kms_addfb_basic@addfb25-bad-modifier
igt@kms_addfb_basic@addfb25-modifier-no-flag
diff --git a/tests/intel/xe_intel_bb.c b/tests/intel/xe_intel_bb.c
index 845052bf26..5df009f9ed 100644
--- a/tests/intel/xe_intel_bb.c
+++ b/tests/intel/xe_intel_bb.c
@@ -18,6 +18,7 @@
#include "igt.h"
#include "igt_crc.h"
+#include "igt_device_scan.h"
#include "intel_blt.h"
#include "intel_bufops.h"
#include "intel_mocs.h"
@@ -950,6 +951,49 @@ static int render(struct buf_ops *bops, uint32_t tiling,
return fails;
}
+/**
+ * SUBTEST: multithread-open
+ * Description: check device scanning when multiple threads are involved
+ */
+static void *__single_open(void *data)
+{
+ struct igt_device_card card;
+ int fd;
+
+ igt_info("Thread: %d\n", (int)to_user_pointer(data));
+
+ for (int i = 0; i < 5; i++)
+ igt_devices_scan();
+
+ igt_assert_eq(igt_device_card_match("pci:vendor=intel", &card), true);
+ igt_info("Device detail: %s, %s, %s\n", card.subsystem, card.card, card.render);
+
+ fd = igt_open_card(&card);
+ igt_info("Fd: %d\n", fd);
+ igt_assert(fd >= 0);
+ close(fd);
+
+ return NULL;
+}
+
+#define NUM_THREADS 100
+static void multithread_open(void)
+{
+ pthread_t pth[NUM_THREADS];
+ int i, ret;
+
+ for (i = 0; i < NUM_THREADS; i++) {
+ ret = pthread_create(&pth[i], NULL, __single_open,
+ from_user_pointer(i));
+ igt_assert_eq(ret, 0);
+ }
+
+ for (i = 0; i < NUM_THREADS; i++) {
+ ret = pthread_join(pth[i], NULL);
+ igt_assert_eq(ret, 0);
+ }
+}
+
static int opt_handler(int opt, int opt_index, void *data)
{
switch (opt) {
@@ -1063,6 +1107,9 @@ igt_main_args("dpib", NULL, help_str, opt_handler, NULL)
}
}
+ igt_subtest("multithread-open")
+ multithread_open();
+
igt_fixture {
buf_ops_destroy(bops);
drm_close_driver(xe);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH i-g-t 3/3] tests/xe_intel_bb: check multithreading rescans won't segfault
2025-01-23 9:22 ` [PATCH i-g-t 3/3] tests/xe_intel_bb: check multithreading rescans won't segfault Zbigniew Kempczyński
@ 2025-01-23 17:34 ` Lucas De Marchi
2025-01-23 17:37 ` Lucas De Marchi
0 siblings, 1 reply; 7+ messages in thread
From: Lucas De Marchi @ 2025-01-23 17:34 UTC (permalink / raw)
To: Zbigniew Kempczyński; +Cc: igt-dev, Kamil Konieczny
On Thu, Jan 23, 2025 at 10:22:10AM +0100, Zbigniew Kempczyński wrote:
>This test is likely only for checking purposes, it doesn't makes
>sense to merge it after series review.
>
>Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
>Cc: Lucas De Marchi <lucas.demarchi@intel.com>
>Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
>---
> tests/intel-ci/xe-fast-feedback.testlist | 1 +
> tests/intel/xe_intel_bb.c | 47 ++++++++++++++++++++++++
> 2 files changed, 48 insertions(+)
>
>diff --git a/tests/intel-ci/xe-fast-feedback.testlist b/tests/intel-ci/xe-fast-feedback.testlist
>index 0234d3e72d..7adb9a3436 100644
>--- a/tests/intel-ci/xe-fast-feedback.testlist
>+++ b/tests/intel-ci/xe-fast-feedback.testlist
>@@ -7,6 +7,7 @@ igt@fbdev@nullptr
> igt@fbdev@read
> igt@fbdev@write
>
>+igt@xe_intel_bb@multithread-open
> igt@kms_addfb_basic@addfb25-4-tiled
> igt@kms_addfb_basic@addfb25-bad-modifier
> igt@kms_addfb_basic@addfb25-modifier-no-flag
>diff --git a/tests/intel/xe_intel_bb.c b/tests/intel/xe_intel_bb.c
>index 845052bf26..5df009f9ed 100644
>--- a/tests/intel/xe_intel_bb.c
>+++ b/tests/intel/xe_intel_bb.c
>@@ -18,6 +18,7 @@
>
> #include "igt.h"
> #include "igt_crc.h"
>+#include "igt_device_scan.h"
> #include "intel_blt.h"
> #include "intel_bufops.h"
> #include "intel_mocs.h"
>@@ -950,6 +951,49 @@ static int render(struct buf_ops *bops, uint32_t tiling,
> return fails;
> }
>
>+/**
>+ * SUBTEST: multithread-open
>+ * Description: check device scanning when multiple threads are involved
>+ */
>+static void *__single_open(void *data)
>+{
>+ struct igt_device_card card;
>+ int fd;
>+
>+ igt_info("Thread: %d\n", (int)to_user_pointer(data));
>+
>+ for (int i = 0; i < 5; i++)
>+ igt_devices_scan();
>+
>+ igt_assert_eq(igt_device_card_match("pci:vendor=intel", &card), true);
>+ igt_info("Device detail: %s, %s, %s\n", card.subsystem, card.card, card.render);
>+
>+ fd = igt_open_card(&card);
can you point what test needs this? In this scenario, don't we usually
use igt_fork() for the tests?
Lucas De Marchi
>+ igt_info("Fd: %d\n", fd);
>+ igt_assert(fd >= 0);
>+ close(fd);
>+
>+ return NULL;
>+}
>+
>+#define NUM_THREADS 100
>+static void multithread_open(void)
>+{
>+ pthread_t pth[NUM_THREADS];
>+ int i, ret;
>+
>+ for (i = 0; i < NUM_THREADS; i++) {
>+ ret = pthread_create(&pth[i], NULL, __single_open,
>+ from_user_pointer(i));
>+ igt_assert_eq(ret, 0);
>+ }
>+
>+ for (i = 0; i < NUM_THREADS; i++) {
>+ ret = pthread_join(pth[i], NULL);
>+ igt_assert_eq(ret, 0);
>+ }
>+}
>+
> static int opt_handler(int opt, int opt_index, void *data)
> {
> switch (opt) {
>@@ -1063,6 +1107,9 @@ igt_main_args("dpib", NULL, help_str, opt_handler, NULL)
> }
> }
>
>+ igt_subtest("multithread-open")
>+ multithread_open();
>+
> igt_fixture {
> buf_ops_destroy(bops);
> drm_close_driver(xe);
>--
>2.34.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH i-g-t 3/3] tests/xe_intel_bb: check multithreading rescans won't segfault
2025-01-23 17:34 ` Lucas De Marchi
@ 2025-01-23 17:37 ` Lucas De Marchi
0 siblings, 0 replies; 7+ messages in thread
From: Lucas De Marchi @ 2025-01-23 17:37 UTC (permalink / raw)
To: Zbigniew Kempczyński; +Cc: igt-dev, Kamil Konieczny
On Thu, Jan 23, 2025 at 11:34:36AM -0600, Lucas De Marchi wrote:
>On Thu, Jan 23, 2025 at 10:22:10AM +0100, Zbigniew Kempczyński wrote:
>>This test is likely only for checking purposes, it doesn't makes
>>sense to merge it after series review.
>>
>>Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
>>Cc: Lucas De Marchi <lucas.demarchi@intel.com>
>>Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
>>---
>>tests/intel-ci/xe-fast-feedback.testlist | 1 +
>>tests/intel/xe_intel_bb.c | 47 ++++++++++++++++++++++++
>>2 files changed, 48 insertions(+)
>>
>>diff --git a/tests/intel-ci/xe-fast-feedback.testlist b/tests/intel-ci/xe-fast-feedback.testlist
>>index 0234d3e72d..7adb9a3436 100644
>>--- a/tests/intel-ci/xe-fast-feedback.testlist
>>+++ b/tests/intel-ci/xe-fast-feedback.testlist
>>@@ -7,6 +7,7 @@ igt@fbdev@nullptr
>>igt@fbdev@read
>>igt@fbdev@write
>>
>>+igt@xe_intel_bb@multithread-open
>>igt@kms_addfb_basic@addfb25-4-tiled
>>igt@kms_addfb_basic@addfb25-bad-modifier
>>igt@kms_addfb_basic@addfb25-modifier-no-flag
>>diff --git a/tests/intel/xe_intel_bb.c b/tests/intel/xe_intel_bb.c
>>index 845052bf26..5df009f9ed 100644
>>--- a/tests/intel/xe_intel_bb.c
>>+++ b/tests/intel/xe_intel_bb.c
>>@@ -18,6 +18,7 @@
>>
>>#include "igt.h"
>>#include "igt_crc.h"
>>+#include "igt_device_scan.h"
>>#include "intel_blt.h"
>>#include "intel_bufops.h"
>>#include "intel_mocs.h"
>>@@ -950,6 +951,49 @@ static int render(struct buf_ops *bops, uint32_t tiling,
>> return fails;
>>}
>>
>>+/**
>>+ * SUBTEST: multithread-open
>>+ * Description: check device scanning when multiple threads are involved
>>+ */
>>+static void *__single_open(void *data)
>>+{
>>+ struct igt_device_card card;
>>+ int fd;
>>+
>>+ igt_info("Thread: %d\n", (int)to_user_pointer(data));
>>+
>>+ for (int i = 0; i < 5; i++)
>>+ igt_devices_scan();
>>+
>>+ igt_assert_eq(igt_device_card_match("pci:vendor=intel", &card), true);
>>+ igt_info("Device detail: %s, %s, %s\n", card.subsystem, card.card, card.render);
>>+
>>+ fd = igt_open_card(&card);
>
>can you point what test needs this? In this scenario, don't we usually
>use igt_fork() for the tests?
I re-read patch 2 and they are mentioned there. Yeah, makes sense.
Lucas De Marchi
>
>Lucas De Marchi
>
>>+ igt_info("Fd: %d\n", fd);
>>+ igt_assert(fd >= 0);
>>+ close(fd);
>>+
>>+ return NULL;
>>+}
>>+
>>+#define NUM_THREADS 100
>>+static void multithread_open(void)
>>+{
>>+ pthread_t pth[NUM_THREADS];
>>+ int i, ret;
>>+
>>+ for (i = 0; i < NUM_THREADS; i++) {
>>+ ret = pthread_create(&pth[i], NULL, __single_open,
>>+ from_user_pointer(i));
>>+ igt_assert_eq(ret, 0);
>>+ }
>>+
>>+ for (i = 0; i < NUM_THREADS; i++) {
>>+ ret = pthread_join(pth[i], NULL);
>>+ igt_assert_eq(ret, 0);
>>+ }
>>+}
>>+
>>static int opt_handler(int opt, int opt_index, void *data)
>>{
>> switch (opt) {
>>@@ -1063,6 +1107,9 @@ igt_main_args("dpib", NULL, help_str, opt_handler, NULL)
>> }
>> }
>>
>>+ igt_subtest("multithread-open")
>>+ multithread_open();
>>+
>> igt_fixture {
>> buf_ops_destroy(bops);
>> drm_close_driver(xe);
>>--
>>2.34.1
>>
^ permalink raw reply [flat|nested] 7+ messages in thread