1
- // SPDX-License-Identifier: GPL-2.0
1
+ // SPDX-License-Identifier: GPL-2.0-or-later
2
2
/*
3
3
* Copyright (C) 2018 SUSE LLC <[email protected] >
4
4
* Copyright (C) 2020 SUSE LLC <[email protected] >
26
26
27
27
static int fd = -1 ;
28
28
static int client_id ;
29
+ static struct snd_seq_remove_events rminfo = {
30
+ .remove_mode = SNDRV_SEQ_REMOVE_OUTPUT
31
+ };
32
+ static struct snd_seq_event ssev = {
33
+ .flags = SNDRV_SEQ_TIME_STAMP_TICK | SNDRV_SEQ_TIME_MODE_REL ,
34
+ .queue = 0 ,
35
+ .type = SNDRV_SEQ_EVENT_USR0 ,
36
+ .time = { .tick = 10 }
37
+ };
38
+
29
39
static struct tst_fzsync_pair fzsync_pair ;
30
40
41
+ static void reinit_pool (int pool_size )
42
+ {
43
+ struct snd_seq_client_pool pconf = {
44
+ .output_pool = pool_size ,
45
+ .client = client_id
46
+ };
47
+
48
+ ioctl (fd , SNDRV_SEQ_IOCTL_SET_CLIENT_POOL , & pconf );
49
+ }
50
+
51
+ static void race_ioctl (void )
52
+ {
53
+ reinit_pool (512 );
54
+ }
55
+
56
+ static void race_write (void )
57
+ {
58
+ TEST (write (fd , & ssev , sizeof (ssev )));
59
+ }
60
+
61
+ void (* testfunc_list [])(void ) = {race_ioctl , race_write };
62
+
31
63
static void setup (void )
32
64
{
33
65
struct snd_seq_queue_info qconf = { .queue = 0 };
@@ -44,8 +76,9 @@ static void setup(void)
44
76
45
77
SAFE_IOCTL (fd , SNDRV_SEQ_IOCTL_CLIENT_ID , & client_id );
46
78
SAFE_IOCTL (fd , SNDRV_SEQ_IOCTL_CREATE_QUEUE , & qconf );
79
+ ssev .dest .client = client_id ;
47
80
48
- fzsync_pair .exec_loops = 100000 ;
81
+ fzsync_pair .exec_loops = 1000000 ;
49
82
tst_fzsync_pair_init (& fzsync_pair );
50
83
}
51
84
@@ -56,35 +89,26 @@ static void cleanup(void)
56
89
tst_fzsync_pair_cleanup (& fzsync_pair );
57
90
}
58
91
59
- static void reinit_pool (int pool_size )
60
- {
61
- struct snd_seq_client_pool pconf = {
62
- .output_pool = pool_size ,
63
- .client = client_id
64
- };
65
-
66
- SAFE_IOCTL (fd , SNDRV_SEQ_IOCTL_SET_CLIENT_POOL , & pconf );
67
- }
68
-
69
92
static void * thread_run (void * arg )
70
93
{
71
94
while (tst_fzsync_run_b (& fzsync_pair )) {
72
95
tst_fzsync_start_race_b (& fzsync_pair );
73
- reinit_pool (512 );
96
+ reinit_pool (10 );
74
97
tst_fzsync_end_race_b (& fzsync_pair );
75
98
}
76
99
77
100
return arg ;
78
101
}
79
102
80
- static void run (void )
103
+ static void run (unsigned int n )
81
104
{
82
105
tst_fzsync_pair_reset (& fzsync_pair , thread_run );
83
106
84
107
while (tst_fzsync_run_a (& fzsync_pair )) {
85
- reinit_pool (1 );
108
+ reinit_pool (5 );
109
+ SAFE_IOCTL (fd , SNDRV_SEQ_IOCTL_REMOVE_EVENTS , & rminfo );
86
110
tst_fzsync_start_race_a (& fzsync_pair );
87
- reinit_pool ( 2 );
111
+ testfunc_list [ n ]( );
88
112
tst_fzsync_end_race_a (& fzsync_pair );
89
113
90
114
if (tst_taint_check ()) {
@@ -97,9 +121,11 @@ static void run(void)
97
121
}
98
122
99
123
static struct tst_test test = {
100
- .test_all = run ,
124
+ .test = run ,
125
+ .tcnt = ARRAY_SIZE (testfunc_list ),
101
126
.setup = setup ,
102
127
.cleanup = cleanup ,
128
+ .timeout = 120 ,
103
129
.tags = (const struct tst_tag []) {
104
130
{"linux-git" , "d15d662e89fc" },
105
131
{"CVE" , "2018-7566" },
0 commit comments