diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-04 21:34:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-04 21:34:04 -0400 |
commit | 29b88e23a9212136d39b0161a39afe587d0170a5 (patch) | |
tree | 48d9f857b137222e35f853004973e12a515314f5 /tools | |
parent | 2521129a6d2fd8a81f99cf95055eddea3df914ff (diff) | |
parent | 4e3a25b0274b8474f5ad46215a270785dd18265e (diff) |
Merge tag 'driver-core-3.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core updates from Greg KH:
"Here's the big driver-core pull request for 3.17-rc1.
Largest thing in here is the dma-buf rework and fence code, that
touched many different subsystems so it was agreed it should go
through this tree to handle merge issues. There's also some firmware
loading updates, as well as tests added, and a few other tiny changes,
the changelog has the details.
All have been in linux-next for a long time"
* tag 'driver-core-3.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (32 commits)
ARM: imx: Remove references to platform_bus in mxc code
firmware loader: Fix _request_firmware_load() return val for fw load abort
platform: Remove most references to platform_bus device
test: add firmware_class loader test
doc: fix minor typos in firmware_class README
staging: android: Cleanup style issues
Documentation: devres: Sort managed interfaces
Documentation: devres: Add devm_kmalloc() et al
fs: debugfs: remove trailing whitespace
kernfs: kernel-doc warning fix
debugfs: Fix corrupted loop in debugfs_remove_recursive
stable_kernel_rules: Add pointer to netdev-FAQ for network patches
driver core: platform: add device binding path 'driver_override'
driver core/platform: remove unused implicit padding in platform_object
firmware loader: inform direct failure when udev loader is disabled
firmware: replace ALIGN(PAGE_SIZE) by PAGE_ALIGN
firmware: read firmware size using i_size_read()
firmware loader: allow disabling of udev as firmware loader
reservation: add suppport for read-only access using rcu
reservation: update api and add some helpers
...
Conflicts:
drivers/base/platform.c
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/Makefile | 1 | ||||
-rw-r--r-- | tools/testing/selftests/firmware/Makefile | 27 | ||||
-rw-r--r-- | tools/testing/selftests/firmware/fw_filesystem.sh | 62 | ||||
-rw-r--r-- | tools/testing/selftests/firmware/fw_userhelper.sh | 89 |
4 files changed, 179 insertions, 0 deletions
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 4c2aa357e12f..d10f95ce2ea4 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile | |||
@@ -11,6 +11,7 @@ TARGETS += vm | |||
11 | TARGETS += powerpc | 11 | TARGETS += powerpc |
12 | TARGETS += user | 12 | TARGETS += user |
13 | TARGETS += sysctl | 13 | TARGETS += sysctl |
14 | TARGETS += firmware | ||
14 | 15 | ||
15 | TARGETS_HOTPLUG = cpu-hotplug | 16 | TARGETS_HOTPLUG = cpu-hotplug |
16 | TARGETS_HOTPLUG += memory-hotplug | 17 | TARGETS_HOTPLUG += memory-hotplug |
diff --git a/tools/testing/selftests/firmware/Makefile b/tools/testing/selftests/firmware/Makefile new file mode 100644 index 000000000000..e23cce0bbc3a --- /dev/null +++ b/tools/testing/selftests/firmware/Makefile | |||
@@ -0,0 +1,27 @@ | |||
1 | # Makefile for firmware loading selftests | ||
2 | |||
3 | # No binaries, but make sure arg-less "make" doesn't trigger "run_tests" | ||
4 | all: | ||
5 | |||
6 | fw_filesystem: | ||
7 | @if /bin/sh ./fw_filesystem.sh ; then \ | ||
8 | echo "fw_filesystem: ok"; \ | ||
9 | else \ | ||
10 | echo "fw_filesystem: [FAIL]"; \ | ||
11 | exit 1; \ | ||
12 | fi | ||
13 | |||
14 | fw_userhelper: | ||
15 | @if /bin/sh ./fw_userhelper.sh ; then \ | ||
16 | echo "fw_userhelper: ok"; \ | ||
17 | else \ | ||
18 | echo "fw_userhelper: [FAIL]"; \ | ||
19 | exit 1; \ | ||
20 | fi | ||
21 | |||
22 | run_tests: all fw_filesystem fw_userhelper | ||
23 | |||
24 | # Nothing to clean up. | ||
25 | clean: | ||
26 | |||
27 | .PHONY: all clean run_tests fw_filesystem fw_userhelper | ||
diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh new file mode 100644 index 000000000000..3fc6c10c2479 --- /dev/null +++ b/tools/testing/selftests/firmware/fw_filesystem.sh | |||
@@ -0,0 +1,62 @@ | |||
1 | #!/bin/sh | ||
2 | # This validates that the kernel will load firmware out of its list of | ||
3 | # firmware locations on disk. Since the user helper does similar work, | ||
4 | # we reset the custom load directory to a location the user helper doesn't | ||
5 | # know so we can be sure we're not accidentally testing the user helper. | ||
6 | set -e | ||
7 | |||
8 | modprobe test_firmware | ||
9 | |||
10 | DIR=/sys/devices/virtual/misc/test_firmware | ||
11 | |||
12 | OLD_TIMEOUT=$(cat /sys/class/firmware/timeout) | ||
13 | OLD_FWPATH=$(cat /sys/module/firmware_class/parameters/path) | ||
14 | |||
15 | FWPATH=$(mktemp -d) | ||
16 | FW="$FWPATH/test-firmware.bin" | ||
17 | |||
18 | test_finish() | ||
19 | { | ||
20 | echo "$OLD_TIMEOUT" >/sys/class/firmware/timeout | ||
21 | echo -n "$OLD_PATH" >/sys/module/firmware_class/parameters/path | ||
22 | rm -f "$FW" | ||
23 | rmdir "$FWPATH" | ||
24 | } | ||
25 | |||
26 | trap "test_finish" EXIT | ||
27 | |||
28 | # Turn down the timeout so failures don't take so long. | ||
29 | echo 1 >/sys/class/firmware/timeout | ||
30 | # Set the kernel search path. | ||
31 | echo -n "$FWPATH" >/sys/module/firmware_class/parameters/path | ||
32 | |||
33 | # This is an unlikely real-world firmware content. :) | ||
34 | echo "ABCD0123" >"$FW" | ||
35 | |||
36 | NAME=$(basename "$FW") | ||
37 | |||
38 | # Request a firmware that doesn't exist, it should fail. | ||
39 | echo -n "nope-$NAME" >"$DIR"/trigger_request | ||
40 | if diff -q "$FW" /dev/test_firmware >/dev/null ; then | ||
41 | echo "$0: firmware was not expected to match" >&2 | ||
42 | exit 1 | ||
43 | else | ||
44 | echo "$0: timeout works" | ||
45 | fi | ||
46 | |||
47 | # This should succeed via kernel load or will fail after 1 second after | ||
48 | # being handed over to the user helper, which won't find the fw either. | ||
49 | if ! echo -n "$NAME" >"$DIR"/trigger_request ; then | ||
50 | echo "$0: could not trigger request" >&2 | ||
51 | exit 1 | ||
52 | fi | ||
53 | |||
54 | # Verify the contents are what we expect. | ||
55 | if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then | ||
56 | echo "$0: firmware was not loaded" >&2 | ||
57 | exit 1 | ||
58 | else | ||
59 | echo "$0: filesystem loading works" | ||
60 | fi | ||
61 | |||
62 | exit 0 | ||
diff --git a/tools/testing/selftests/firmware/fw_userhelper.sh b/tools/testing/selftests/firmware/fw_userhelper.sh new file mode 100644 index 000000000000..6efbade12139 --- /dev/null +++ b/tools/testing/selftests/firmware/fw_userhelper.sh | |||
@@ -0,0 +1,89 @@ | |||
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 | OLD_TIMEOUT=$(cat /sys/class/firmware/timeout) | ||
13 | |||
14 | FWPATH=$(mktemp -d) | ||
15 | FW="$FWPATH/test-firmware.bin" | ||
16 | |||
17 | test_finish() | ||
18 | { | ||
19 | echo "$OLD_TIMEOUT" >/sys/class/firmware/timeout | ||
20 | rm -f "$FW" | ||
21 | rmdir "$FWPATH" | ||
22 | } | ||
23 | |||
24 | load_fw() | ||
25 | { | ||
26 | local name="$1" | ||
27 | local file="$2" | ||
28 | |||
29 | # This will block until our load (below) has finished. | ||
30 | echo -n "$name" >"$DIR"/trigger_request & | ||
31 | |||
32 | # Give kernel a chance to react. | ||
33 | local timeout=10 | ||
34 | while [ ! -e "$DIR"/"$name"/loading ]; do | ||
35 | sleep 0.1 | ||
36 | timeout=$(( $timeout - 1 )) | ||
37 | if [ "$timeout" -eq 0 ]; then | ||
38 | echo "$0: firmware interface never appeared" >&2 | ||
39 | exit 1 | ||
40 | fi | ||
41 | done | ||
42 | |||
43 | echo 1 >"$DIR"/"$name"/loading | ||
44 | cat "$file" >"$DIR"/"$name"/data | ||
45 | echo 0 >"$DIR"/"$name"/loading | ||
46 | |||
47 | # Wait for request to finish. | ||
48 | wait | ||
49 | } | ||
50 | |||
51 | trap "test_finish" EXIT | ||
52 | |||
53 | # This is an unlikely real-world firmware content. :) | ||
54 | echo "ABCD0123" >"$FW" | ||
55 | NAME=$(basename "$FW") | ||
56 | |||
57 | # Test failure when doing nothing (timeout works). | ||
58 | echo 1 >/sys/class/firmware/timeout | ||
59 | echo -n "$NAME" >"$DIR"/trigger_request | ||
60 | if diff -q "$FW" /dev/test_firmware >/dev/null ; then | ||
61 | echo "$0: firmware was not expected to match" >&2 | ||
62 | exit 1 | ||
63 | else | ||
64 | echo "$0: timeout works" | ||
65 | fi | ||
66 | |||
67 | # Put timeout high enough for us to do work but not so long that failures | ||
68 | # slow down this test too much. | ||
69 | echo 4 >/sys/class/firmware/timeout | ||
70 | |||
71 | # Load this script instead of the desired firmware. | ||
72 | load_fw "$NAME" "$0" | ||
73 | if diff -q "$FW" /dev/test_firmware >/dev/null ; then | ||
74 | echo "$0: firmware was not expected to match" >&2 | ||
75 | exit 1 | ||
76 | else | ||
77 | echo "$0: firmware comparison works" | ||
78 | fi | ||
79 | |||
80 | # Do a proper load, which should work correctly. | ||
81 | load_fw "$NAME" "$FW" | ||
82 | if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then | ||
83 | echo "$0: firmware was not loaded" >&2 | ||
84 | exit 1 | ||
85 | else | ||
86 | echo "$0: user helper firmware loading works" | ||
87 | fi | ||
88 | |||
89 | exit 0 | ||