diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-02-22 14:38:22 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-02-22 14:38:22 -0500 |
commit | e30aee9e10bb5168579e047f05c3d13d09e23356 (patch) | |
tree | 12371bdcd52d2427cad838201997479e31b6a9c9 /tools | |
parent | 8ff546b801e5cca0337c0f0a7234795d0a6309a1 (diff) | |
parent | 6cf18e6927c0b224f972e3042fb85770d63cb9f8 (diff) |
Merge tag 'char-misc-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver updates from Greg KH:
"Here is the big char/misc driver patchset for 4.11-rc1.
Lots of different driver subsystems updated here: rework for the
hyperv subsystem to handle new platforms better, mei and w1 and extcon
driver updates, as well as a number of other "minor" driver updates.
All of these have been in linux-next for a while with no reported
issues"
* tag 'char-misc-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (169 commits)
goldfish: Sanitize the broken interrupt handler
x86/platform/goldfish: Prevent unconditional loading
vmbus: replace modulus operation with subtraction
vmbus: constify parameters where possible
vmbus: expose hv_begin/end_read
vmbus: remove conditional locking of vmbus_write
vmbus: add direct isr callback mode
vmbus: change to per channel tasklet
vmbus: put related per-cpu variable together
vmbus: callback is in softirq not workqueue
binder: Add support for file-descriptor arrays
binder: Add support for scatter-gather
binder: Add extra size to allocator
binder: Refactor binder_transact()
binder: Support multiple /dev instances
binder: Deal with contexts in debugfs
binder: Support multiple context managers
binder: Split flat_binder_object
auxdisplay: ht16k33: remove private workqueue
auxdisplay: ht16k33: rework input device initialization
...
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/firmware/Makefile | 2 | ||||
-rwxr-xr-x | tools/testing/selftests/firmware/fw_fallback.sh | 224 | ||||
-rwxr-xr-x | tools/testing/selftests/firmware/fw_userhelper.sh | 99 |
3 files changed, 225 insertions, 100 deletions
diff --git a/tools/testing/selftests/firmware/Makefile b/tools/testing/selftests/firmware/Makefile index 9bf82234855b..1894d625af2d 100644 --- a/tools/testing/selftests/firmware/Makefile +++ b/tools/testing/selftests/firmware/Makefile | |||
@@ -3,7 +3,7 @@ | |||
3 | # No binaries, but make sure arg-less "make" doesn't trigger "run_tests" | 3 | # No binaries, but make sure arg-less "make" doesn't trigger "run_tests" |
4 | all: | 4 | all: |
5 | 5 | ||
6 | TEST_PROGS := fw_filesystem.sh fw_userhelper.sh | 6 | TEST_PROGS := fw_filesystem.sh fw_fallback.sh |
7 | 7 | ||
8 | include ../lib.mk | 8 | include ../lib.mk |
9 | 9 | ||
diff --git a/tools/testing/selftests/firmware/fw_fallback.sh b/tools/testing/selftests/firmware/fw_fallback.sh new file mode 100755 index 000000000000..2e4c22d5abf7 --- /dev/null +++ b/tools/testing/selftests/firmware/fw_fallback.sh | |||
@@ -0,0 +1,224 @@ | |||
1 | #!/bin/sh | ||
2 | # This validates that the kernel will fall back to using the fallback mechanism | ||
3 | # to load firmware it can't find on disk itself. We must request a firmware | ||
4 | # that the kernel won't find, and any installed helper (e.g. udev) also | ||
5 | # won't find so that we can do the load ourself manually. | ||
6 | set -e | ||
7 | |||
8 | modprobe test_firmware | ||
9 | |||
10 | DIR=/sys/devices/virtual/misc/test_firmware | ||
11 | |||
12 | # CONFIG_FW_LOADER_USER_HELPER has a sysfs class under /sys/class/firmware/ | ||
13 | # These days no one enables CONFIG_FW_LOADER_USER_HELPER so check for that | ||
14 | # as an indicator for CONFIG_FW_LOADER_USER_HELPER. | ||
15 | HAS_FW_LOADER_USER_HELPER=$(if [ -d /sys/class/firmware/ ]; then echo yes; else echo no; fi) | ||
16 | |||
17 | if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then | ||
18 | OLD_TIMEOUT=$(cat /sys/class/firmware/timeout) | ||
19 | else | ||
20 | echo "usermode helper disabled so ignoring test" | ||
21 | exit 0 | ||
22 | fi | ||
23 | |||
24 | FWPATH=$(mktemp -d) | ||
25 | FW="$FWPATH/test-firmware.bin" | ||
26 | |||
27 | test_finish() | ||
28 | { | ||
29 | echo "$OLD_TIMEOUT" >/sys/class/firmware/timeout | ||
30 | rm -f "$FW" | ||
31 | rmdir "$FWPATH" | ||
32 | } | ||
33 | |||
34 | load_fw() | ||
35 | { | ||
36 | local name="$1" | ||
37 | local file="$2" | ||
38 | |||
39 | # This will block until our load (below) has finished. | ||
40 | echo -n "$name" >"$DIR"/trigger_request & | ||
41 | |||
42 | # Give kernel a chance to react. | ||
43 | local timeout=10 | ||
44 | while [ ! -e "$DIR"/"$name"/loading ]; do | ||
45 | sleep 0.1 | ||
46 | timeout=$(( $timeout - 1 )) | ||
47 | if [ "$timeout" -eq 0 ]; then | ||
48 | echo "$0: firmware interface never appeared" >&2 | ||
49 | exit 1 | ||
50 | fi | ||
51 | done | ||
52 | |||
53 | echo 1 >"$DIR"/"$name"/loading | ||
54 | cat "$file" >"$DIR"/"$name"/data | ||
55 | echo 0 >"$DIR"/"$name"/loading | ||
56 | |||
57 | # Wait for request to finish. | ||
58 | wait | ||
59 | } | ||
60 | |||
61 | load_fw_cancel() | ||
62 | { | ||
63 | local name="$1" | ||
64 | local file="$2" | ||
65 | |||
66 | # This will block until our load (below) has finished. | ||
67 | echo -n "$name" >"$DIR"/trigger_request 2>/dev/null & | ||
68 | |||
69 | # Give kernel a chance to react. | ||
70 | local timeout=10 | ||
71 | while [ ! -e "$DIR"/"$name"/loading ]; do | ||
72 | sleep 0.1 | ||
73 | timeout=$(( $timeout - 1 )) | ||
74 | if [ "$timeout" -eq 0 ]; then | ||
75 | echo "$0: firmware interface never appeared" >&2 | ||
76 | exit 1 | ||
77 | fi | ||
78 | done | ||
79 | |||
80 | echo -1 >"$DIR"/"$name"/loading | ||
81 | |||
82 | # Wait for request to finish. | ||
83 | wait | ||
84 | } | ||
85 | |||
86 | load_fw_custom() | ||
87 | { | ||
88 | local name="$1" | ||
89 | local file="$2" | ||
90 | |||
91 | echo -n "$name" >"$DIR"/trigger_custom_fallback 2>/dev/null & | ||
92 | |||
93 | # Give kernel a chance to react. | ||
94 | local timeout=10 | ||
95 | while [ ! -e "$DIR"/"$name"/loading ]; do | ||
96 | sleep 0.1 | ||
97 | timeout=$(( $timeout - 1 )) | ||
98 | if [ "$timeout" -eq 0 ]; then | ||
99 | echo "$0: firmware interface never appeared" >&2 | ||
100 | exit 1 | ||
101 | fi | ||
102 | done | ||
103 | |||
104 | echo 1 >"$DIR"/"$name"/loading | ||
105 | cat "$file" >"$DIR"/"$name"/data | ||
106 | echo 0 >"$DIR"/"$name"/loading | ||
107 | |||
108 | # Wait for request to finish. | ||
109 | wait | ||
110 | } | ||
111 | |||
112 | |||
113 | load_fw_custom_cancel() | ||
114 | { | ||
115 | local name="$1" | ||
116 | local file="$2" | ||
117 | |||
118 | echo -n "$name" >"$DIR"/trigger_custom_fallback 2>/dev/null & | ||
119 | |||
120 | # Give kernel a chance to react. | ||
121 | local timeout=10 | ||
122 | while [ ! -e "$DIR"/"$name"/loading ]; do | ||
123 | sleep 0.1 | ||
124 | timeout=$(( $timeout - 1 )) | ||
125 | if [ "$timeout" -eq 0 ]; then | ||
126 | echo "$0: firmware interface never appeared" >&2 | ||
127 | exit 1 | ||
128 | fi | ||
129 | done | ||
130 | |||
131 | echo -1 >"$DIR"/"$name"/loading | ||
132 | |||
133 | # Wait for request to finish. | ||
134 | wait | ||
135 | } | ||
136 | |||
137 | |||
138 | trap "test_finish" EXIT | ||
139 | |||
140 | # This is an unlikely real-world firmware content. :) | ||
141 | echo "ABCD0123" >"$FW" | ||
142 | NAME=$(basename "$FW") | ||
143 | |||
144 | DEVPATH="$DIR"/"nope-$NAME"/loading | ||
145 | |||
146 | # Test failure when doing nothing (timeout works). | ||
147 | echo -n 2 >/sys/class/firmware/timeout | ||
148 | echo -n "nope-$NAME" >"$DIR"/trigger_request 2>/dev/null & | ||
149 | |||
150 | # Give the kernel some time to load the loading file, must be less | ||
151 | # than the timeout above. | ||
152 | sleep 1 | ||
153 | if [ ! -f $DEVPATH ]; then | ||
154 | echo "$0: fallback mechanism immediately cancelled" | ||
155 | echo "" | ||
156 | echo "The file never appeared: $DEVPATH" | ||
157 | echo "" | ||
158 | echo "This might be a distribution udev rule setup by your distribution" | ||
159 | echo "to immediately cancel all fallback requests, this must be" | ||
160 | echo "removed before running these tests. To confirm look for" | ||
161 | echo "a firmware rule like /lib/udev/rules.d/50-firmware.rules" | ||
162 | echo "and see if you have something like this:" | ||
163 | echo "" | ||
164 | echo "SUBSYSTEM==\"firmware\", ACTION==\"add\", ATTR{loading}=\"-1\"" | ||
165 | echo "" | ||
166 | echo "If you do remove this file or comment out this line before" | ||
167 | echo "proceeding with these tests." | ||
168 | exit 1 | ||
169 | fi | ||
170 | |||
171 | if diff -q "$FW" /dev/test_firmware >/dev/null ; then | ||
172 | echo "$0: firmware was not expected to match" >&2 | ||
173 | exit 1 | ||
174 | else | ||
175 | echo "$0: timeout works" | ||
176 | fi | ||
177 | |||
178 | # Put timeout high enough for us to do work but not so long that failures | ||
179 | # slow down this test too much. | ||
180 | echo 4 >/sys/class/firmware/timeout | ||
181 | |||
182 | # Load this script instead of the desired firmware. | ||
183 | load_fw "$NAME" "$0" | ||
184 | if diff -q "$FW" /dev/test_firmware >/dev/null ; then | ||
185 | echo "$0: firmware was not expected to match" >&2 | ||
186 | exit 1 | ||
187 | else | ||
188 | echo "$0: firmware comparison works" | ||
189 | fi | ||
190 | |||
191 | # Do a proper load, which should work correctly. | ||
192 | load_fw "$NAME" "$FW" | ||
193 | if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then | ||
194 | echo "$0: firmware was not loaded" >&2 | ||
195 | exit 1 | ||
196 | else | ||
197 | echo "$0: fallback mechanism works" | ||
198 | fi | ||
199 | |||
200 | load_fw_cancel "nope-$NAME" "$FW" | ||
201 | if diff -q "$FW" /dev/test_firmware >/dev/null ; then | ||
202 | echo "$0: firmware was expected to be cancelled" >&2 | ||
203 | exit 1 | ||
204 | else | ||
205 | echo "$0: cancelling fallback mechanism works" | ||
206 | fi | ||
207 | |||
208 | load_fw_custom "$NAME" "$FW" | ||
209 | if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then | ||
210 | echo "$0: firmware was not loaded" >&2 | ||
211 | exit 1 | ||
212 | else | ||
213 | echo "$0: custom fallback loading mechanism works" | ||
214 | fi | ||
215 | |||
216 | load_fw_custom_cancel "nope-$NAME" "$FW" | ||
217 | if diff -q "$FW" /dev/test_firmware >/dev/null ; then | ||
218 | echo "$0: firmware was expected to be cancelled" >&2 | ||
219 | exit 1 | ||
220 | else | ||
221 | echo "$0: cancelling custom fallback mechanism works" | ||
222 | fi | ||
223 | |||
224 | exit 0 | ||
diff --git a/tools/testing/selftests/firmware/fw_userhelper.sh b/tools/testing/selftests/firmware/fw_userhelper.sh deleted file mode 100755 index b9983f8e09f6..000000000000 --- a/tools/testing/selftests/firmware/fw_userhelper.sh +++ /dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | # This validates that the kernel will fall back to using the user helper | ||
3 | # to load firmware it can't find on disk itself. We must request a firmware | ||
4 | # that the kernel won't find, and any installed helper (e.g. udev) also | ||
5 | # won't find so that we can do the load ourself manually. | ||
6 | set -e | ||
7 | |||
8 | modprobe test_firmware | ||
9 | |||
10 | DIR=/sys/devices/virtual/misc/test_firmware | ||
11 | |||
12 | # CONFIG_FW_LOADER_USER_HELPER has a sysfs class under /sys/class/firmware/ | ||
13 | # These days no one enables CONFIG_FW_LOADER_USER_HELPER so check for that | ||
14 | # as an indicator for CONFIG_FW_LOADER_USER_HELPER. | ||
15 | HAS_FW_LOADER_USER_HELPER=$(if [ -d /sys/class/firmware/ ]; then echo yes; else echo no; fi) | ||
16 | |||
17 | if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then | ||
18 | OLD_TIMEOUT=$(cat /sys/class/firmware/timeout) | ||
19 | else | ||
20 | echo "usermode helper disabled so ignoring test" | ||
21 | exit 0 | ||
22 | fi | ||
23 | |||
24 | FWPATH=$(mktemp -d) | ||
25 | FW="$FWPATH/test-firmware.bin" | ||
26 | |||
27 | test_finish() | ||
28 | { | ||
29 | echo "$OLD_TIMEOUT" >/sys/class/firmware/timeout | ||
30 | rm -f "$FW" | ||
31 | rmdir "$FWPATH" | ||
32 | } | ||
33 | |||
34 | load_fw() | ||
35 | { | ||
36 | local name="$1" | ||
37 | local file="$2" | ||
38 | |||
39 | # This will block until our load (below) has finished. | ||
40 | echo -n "$name" >"$DIR"/trigger_request & | ||
41 | |||
42 | # Give kernel a chance to react. | ||
43 | local timeout=10 | ||
44 | while [ ! -e "$DIR"/"$name"/loading ]; do | ||
45 | sleep 0.1 | ||
46 | timeout=$(( $timeout - 1 )) | ||
47 | if [ "$timeout" -eq 0 ]; then | ||
48 | echo "$0: firmware interface never appeared" >&2 | ||
49 | exit 1 | ||
50 | fi | ||
51 | done | ||
52 | |||
53 | echo 1 >"$DIR"/"$name"/loading | ||
54 | cat "$file" >"$DIR"/"$name"/data | ||
55 | echo 0 >"$DIR"/"$name"/loading | ||
56 | |||
57 | # Wait for request to finish. | ||
58 | wait | ||
59 | } | ||
60 | |||
61 | trap "test_finish" EXIT | ||
62 | |||
63 | # This is an unlikely real-world firmware content. :) | ||
64 | echo "ABCD0123" >"$FW" | ||
65 | NAME=$(basename "$FW") | ||
66 | |||
67 | # Test failure when doing nothing (timeout works). | ||
68 | echo 1 >/sys/class/firmware/timeout | ||
69 | echo -n "$NAME" >"$DIR"/trigger_request | ||
70 | if diff -q "$FW" /dev/test_firmware >/dev/null ; then | ||
71 | echo "$0: firmware was not expected to match" >&2 | ||
72 | exit 1 | ||
73 | else | ||
74 | echo "$0: timeout works" | ||
75 | fi | ||
76 | |||
77 | # Put timeout high enough for us to do work but not so long that failures | ||
78 | # slow down this test too much. | ||
79 | echo 4 >/sys/class/firmware/timeout | ||
80 | |||
81 | # Load this script instead of the desired firmware. | ||
82 | load_fw "$NAME" "$0" | ||
83 | if diff -q "$FW" /dev/test_firmware >/dev/null ; then | ||
84 | echo "$0: firmware was not expected to match" >&2 | ||
85 | exit 1 | ||
86 | else | ||
87 | echo "$0: firmware comparison works" | ||
88 | fi | ||
89 | |||
90 | # Do a proper load, which should work correctly. | ||
91 | load_fw "$NAME" "$FW" | ||
92 | if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then | ||
93 | echo "$0: firmware was not loaded" >&2 | ||
94 | exit 1 | ||
95 | else | ||
96 | echo "$0: user helper firmware loading works" | ||
97 | fi | ||
98 | |||
99 | exit 0 | ||