diff options
143 files changed, 6041 insertions, 633 deletions
diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml index 85164016ed26..23fdf79f8cf3 100644 --- a/Documentation/DocBook/media/v4l/controls.xml +++ b/Documentation/DocBook/media/v4l/controls.xml | |||
@@ -1455,7 +1455,7 @@ Applicable to the H264 encoder.</entry> | |||
1455 | </row> | 1455 | </row> |
1456 | 1456 | ||
1457 | <row><entry></entry></row> | 1457 | <row><entry></entry></row> |
1458 | <row> | 1458 | <row id="v4l2-mpeg-video-h264-vui-sar-idc"> |
1459 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC</constant> </entry> | 1459 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC</constant> </entry> |
1460 | <entry>enum v4l2_mpeg_video_h264_vui_sar_idc</entry> | 1460 | <entry>enum v4l2_mpeg_video_h264_vui_sar_idc</entry> |
1461 | </row> | 1461 | </row> |
@@ -1561,7 +1561,7 @@ Applicable to the H264 encoder.</entry> | |||
1561 | </row> | 1561 | </row> |
1562 | 1562 | ||
1563 | <row><entry></entry></row> | 1563 | <row><entry></entry></row> |
1564 | <row> | 1564 | <row id="v4l2-mpeg-video-h264-level"> |
1565 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_H264_LEVEL</constant> </entry> | 1565 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_H264_LEVEL</constant> </entry> |
1566 | <entry>enum v4l2_mpeg_video_h264_level</entry> | 1566 | <entry>enum v4l2_mpeg_video_h264_level</entry> |
1567 | </row> | 1567 | </row> |
@@ -1641,7 +1641,7 @@ Possible values are:</entry> | |||
1641 | </row> | 1641 | </row> |
1642 | 1642 | ||
1643 | <row><entry></entry></row> | 1643 | <row><entry></entry></row> |
1644 | <row> | 1644 | <row id="v4l2-mpeg-video-mpeg4-level"> |
1645 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL</constant> </entry> | 1645 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL</constant> </entry> |
1646 | <entry>enum v4l2_mpeg_video_mpeg4_level</entry> | 1646 | <entry>enum v4l2_mpeg_video_mpeg4_level</entry> |
1647 | </row> | 1647 | </row> |
@@ -1689,9 +1689,9 @@ Possible values are:</entry> | |||
1689 | </row> | 1689 | </row> |
1690 | 1690 | ||
1691 | <row><entry></entry></row> | 1691 | <row><entry></entry></row> |
1692 | <row> | 1692 | <row id="v4l2-mpeg-video-h264-profile"> |
1693 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_H264_PROFILE</constant> </entry> | 1693 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_H264_PROFILE</constant> </entry> |
1694 | <entry>enum v4l2_mpeg_h264_profile</entry> | 1694 | <entry>enum v4l2_mpeg_video_h264_profile</entry> |
1695 | </row> | 1695 | </row> |
1696 | <row><entry spanname="descr">The profile information for H264. | 1696 | <row><entry spanname="descr">The profile information for H264. |
1697 | Applicable to the H264 encoder. | 1697 | Applicable to the H264 encoder. |
@@ -1774,9 +1774,9 @@ Possible values are:</entry> | |||
1774 | </row> | 1774 | </row> |
1775 | 1775 | ||
1776 | <row><entry></entry></row> | 1776 | <row><entry></entry></row> |
1777 | <row> | 1777 | <row id="v4l2-mpeg-video-mpeg4-profile"> |
1778 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE</constant> </entry> | 1778 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE</constant> </entry> |
1779 | <entry>enum v4l2_mpeg_mpeg4_profile</entry> | 1779 | <entry>enum v4l2_mpeg_video_mpeg4_profile</entry> |
1780 | </row> | 1780 | </row> |
1781 | <row><entry spanname="descr">The profile information for MPEG4. | 1781 | <row><entry spanname="descr">The profile information for MPEG4. |
1782 | Applicable to the MPEG4 encoder. | 1782 | Applicable to the MPEG4 encoder. |
@@ -1820,9 +1820,9 @@ Applicable to the encoder. | |||
1820 | </row> | 1820 | </row> |
1821 | 1821 | ||
1822 | <row><entry></entry></row> | 1822 | <row><entry></entry></row> |
1823 | <row> | 1823 | <row id="v4l2-mpeg-video-multi-slice-mode"> |
1824 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE</constant> </entry> | 1824 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE</constant> </entry> |
1825 | <entry>enum v4l2_mpeg_multi_slice_mode</entry> | 1825 | <entry>enum v4l2_mpeg_video_multi_slice_mode</entry> |
1826 | </row> | 1826 | </row> |
1827 | <row><entry spanname="descr">Determines how the encoder should handle division of frame into slices. | 1827 | <row><entry spanname="descr">Determines how the encoder should handle division of frame into slices. |
1828 | Applicable to the encoder. | 1828 | Applicable to the encoder. |
@@ -1868,9 +1868,9 @@ Applicable to the encoder.</entry> | |||
1868 | </row> | 1868 | </row> |
1869 | 1869 | ||
1870 | <row><entry></entry></row> | 1870 | <row><entry></entry></row> |
1871 | <row> | 1871 | <row id="v4l2-mpeg-video-h264-loop-filter-mode"> |
1872 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE</constant> </entry> | 1872 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE</constant> </entry> |
1873 | <entry>enum v4l2_mpeg_h264_loop_filter_mode</entry> | 1873 | <entry>enum v4l2_mpeg_video_h264_loop_filter_mode</entry> |
1874 | </row> | 1874 | </row> |
1875 | <row><entry spanname="descr">Loop filter mode for H264 encoder. | 1875 | <row><entry spanname="descr">Loop filter mode for H264 encoder. |
1876 | Possible values are:</entry> | 1876 | Possible values are:</entry> |
@@ -1913,9 +1913,9 @@ Applicable to the H264 encoder.</entry> | |||
1913 | </row> | 1913 | </row> |
1914 | 1914 | ||
1915 | <row><entry></entry></row> | 1915 | <row><entry></entry></row> |
1916 | <row> | 1916 | <row id="v4l2-mpeg-video-h264-entropy-mode"> |
1917 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE</constant> </entry> | 1917 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE</constant> </entry> |
1918 | <entry>enum v4l2_mpeg_h264_symbol_mode</entry> | 1918 | <entry>enum v4l2_mpeg_video_h264_entropy_mode</entry> |
1919 | </row> | 1919 | </row> |
1920 | <row><entry spanname="descr">Entropy coding mode for H264 - CABAC/CAVALC. | 1920 | <row><entry spanname="descr">Entropy coding mode for H264 - CABAC/CAVALC. |
1921 | Applicable to the H264 encoder. | 1921 | Applicable to the H264 encoder. |
@@ -2140,9 +2140,9 @@ previous frames. Applicable to the H264 encoder.</entry> | |||
2140 | </row> | 2140 | </row> |
2141 | 2141 | ||
2142 | <row><entry></entry></row> | 2142 | <row><entry></entry></row> |
2143 | <row> | 2143 | <row id="v4l2-mpeg-video-header-mode"> |
2144 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_HEADER_MODE</constant> </entry> | 2144 | <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_HEADER_MODE</constant> </entry> |
2145 | <entry>enum v4l2_mpeg_header_mode</entry> | 2145 | <entry>enum v4l2_mpeg_video_header_mode</entry> |
2146 | </row> | 2146 | </row> |
2147 | <row><entry spanname="descr">Determines whether the header is returned as the first buffer or is | 2147 | <row><entry spanname="descr">Determines whether the header is returned as the first buffer or is |
2148 | it returned together with the first frame. Applicable to encoders. | 2148 | it returned together with the first frame. Applicable to encoders. |
@@ -2320,9 +2320,9 @@ Valid only when H.264 and macroblock level RC is enabled (<constant>V4L2_CID_MPE | |||
2320 | Applicable to the H264 encoder.</entry> | 2320 | Applicable to the H264 encoder.</entry> |
2321 | </row> | 2321 | </row> |
2322 | <row><entry></entry></row> | 2322 | <row><entry></entry></row> |
2323 | <row> | 2323 | <row id="v4l2-mpeg-mfc51-video-frame-skip-mode"> |
2324 | <entry spanname="id"><constant>V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE</constant> </entry> | 2324 | <entry spanname="id"><constant>V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE</constant> </entry> |
2325 | <entry>enum v4l2_mpeg_mfc51_frame_skip_mode</entry> | 2325 | <entry>enum v4l2_mpeg_mfc51_video_frame_skip_mode</entry> |
2326 | </row> | 2326 | </row> |
2327 | <row><entry spanname="descr"> | 2327 | <row><entry spanname="descr"> |
2328 | Indicates in what conditions the encoder should skip frames. If encoding a frame would cause the encoded stream to be larger then | 2328 | Indicates in what conditions the encoder should skip frames. If encoding a frame would cause the encoded stream to be larger then |
@@ -2361,9 +2361,9 @@ the stream will meet tight bandwidth contraints. Applicable to encoders. | |||
2361 | </entry> | 2361 | </entry> |
2362 | </row> | 2362 | </row> |
2363 | <row><entry></entry></row> | 2363 | <row><entry></entry></row> |
2364 | <row> | 2364 | <row id="v4l2-mpeg-mfc51-video-force-frame-type"> |
2365 | <entry spanname="id"><constant>V4L2_CID_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE</constant> </entry> | 2365 | <entry spanname="id"><constant>V4L2_CID_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE</constant> </entry> |
2366 | <entry>enum v4l2_mpeg_mfc51_force_frame_type</entry> | 2366 | <entry>enum v4l2_mpeg_mfc51_video_force_frame_type</entry> |
2367 | </row> | 2367 | </row> |
2368 | <row><entry spanname="descr">Force a frame type for the next queued buffer. Applicable to encoders. | 2368 | <row><entry spanname="descr">Force a frame type for the next queued buffer. Applicable to encoders. |
2369 | Possible values are:</entry> | 2369 | Possible values are:</entry> |
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index c4a6e148732a..4dc465477665 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt | |||
@@ -592,3 +592,11 @@ Why: In 3.0, we can now autodetect internal 3G device and already have | |||
592 | interface that was used by acer-wmi driver. It will replaced by | 592 | interface that was used by acer-wmi driver. It will replaced by |
593 | information log when acer-wmi initial. | 593 | information log when acer-wmi initial. |
594 | Who: Lee, Chun-Yi <jlee@novell.com> | 594 | Who: Lee, Chun-Yi <jlee@novell.com> |
595 | |||
596 | ---------------------------- | ||
597 | What: The XFS nodelaylog mount option | ||
598 | When: 3.3 | ||
599 | Why: The delaylog mode that has been the default since 2.6.39 has proven | ||
600 | stable, and the old code is in the way of additional improvements in | ||
601 | the log code. | ||
602 | Who: Christoph Hellwig <hch@lst.de> | ||
diff --git a/Documentation/hwmon/max16065 b/Documentation/hwmon/max16065 index 44b4f61e04f9..c11f64a1f2ad 100644 --- a/Documentation/hwmon/max16065 +++ b/Documentation/hwmon/max16065 | |||
@@ -62,6 +62,13 @@ can be safely used to identify the chip. You will have to instantiate | |||
62 | the devices explicitly. Please see Documentation/i2c/instantiating-devices for | 62 | the devices explicitly. Please see Documentation/i2c/instantiating-devices for |
63 | details. | 63 | details. |
64 | 64 | ||
65 | WARNING: Do not access chip registers using the i2cdump command, and do not use | ||
66 | any of the i2ctools commands on a command register (0xa5 to 0xac). The chips | ||
67 | supported by this driver interpret any access to a command register (including | ||
68 | read commands) as request to execute the command in question. This may result in | ||
69 | power loss, board resets, and/or Flash corruption. Worst case, your board may | ||
70 | turn into a brick. | ||
71 | |||
65 | 72 | ||
66 | Sysfs entries | 73 | Sysfs entries |
67 | ------------- | 74 | ------------- |
diff --git a/Documentation/ioctl/ioctl-number.txt b/Documentation/ioctl/ioctl-number.txt index 845a191004b1..54078ed96b37 100644 --- a/Documentation/ioctl/ioctl-number.txt +++ b/Documentation/ioctl/ioctl-number.txt | |||
@@ -319,4 +319,6 @@ Code Seq#(hex) Include File Comments | |||
319 | <mailto:thomas@winischhofer.net> | 319 | <mailto:thomas@winischhofer.net> |
320 | 0xF4 00-1F video/mbxfb.h mbxfb | 320 | 0xF4 00-1F video/mbxfb.h mbxfb |
321 | <mailto:raph@8d.com> | 321 | <mailto:raph@8d.com> |
322 | 0xF6 all LTTng Linux Trace Toolkit Next Generation | ||
323 | <mailto:mathieu.desnoyers@efficios.com> | ||
322 | 0xFD all linux/dm-ioctl.h | 324 | 0xFD all linux/dm-ioctl.h |
@@ -1,7 +1,7 @@ | |||
1 | VERSION = 3 | 1 | VERSION = 3 |
2 | PATCHLEVEL = 1 | 2 | PATCHLEVEL = 1 |
3 | SUBLEVEL = 0 | 3 | SUBLEVEL = 0 |
4 | EXTRAVERSION = -rc4 | 4 | EXTRAVERSION = -rc6 |
5 | NAME = "Divemaster Edition" | 5 | NAME = "Divemaster Edition" |
6 | 6 | ||
7 | # *DOCUMENTATION* | 7 | # *DOCUMENTATION* |
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug index 81cbe40c159c..be3a0f78d915 100644 --- a/arch/arm/Kconfig.debug +++ b/arch/arm/Kconfig.debug | |||
@@ -129,4 +129,10 @@ config DEBUG_S3C_UART | |||
129 | The uncompressor code port configuration is now handled | 129 | The uncompressor code port configuration is now handled |
130 | by CONFIG_S3C_LOWLEVEL_UART_PORT. | 130 | by CONFIG_S3C_LOWLEVEL_UART_PORT. |
131 | 131 | ||
132 | config ARM_KPROBES_TEST | ||
133 | tristate "Kprobes test module" | ||
134 | depends on KPROBES && MODULES | ||
135 | help | ||
136 | Perform tests of kprobes API and instruction set simulation. | ||
137 | |||
132 | endmenu | 138 | endmenu |
diff --git a/arch/arm/include/asm/hardware/cache-l2x0.h b/arch/arm/include/asm/hardware/cache-l2x0.h index bfa706ffd968..99a6ed7e1bfd 100644 --- a/arch/arm/include/asm/hardware/cache-l2x0.h +++ b/arch/arm/include/asm/hardware/cache-l2x0.h | |||
@@ -45,8 +45,13 @@ | |||
45 | #define L2X0_CLEAN_INV_LINE_PA 0x7F0 | 45 | #define L2X0_CLEAN_INV_LINE_PA 0x7F0 |
46 | #define L2X0_CLEAN_INV_LINE_IDX 0x7F8 | 46 | #define L2X0_CLEAN_INV_LINE_IDX 0x7F8 |
47 | #define L2X0_CLEAN_INV_WAY 0x7FC | 47 | #define L2X0_CLEAN_INV_WAY 0x7FC |
48 | #define L2X0_LOCKDOWN_WAY_D 0x900 | 48 | /* |
49 | #define L2X0_LOCKDOWN_WAY_I 0x904 | 49 | * The lockdown registers repeat 8 times for L310, the L210 has only one |
50 | * D and one I lockdown register at 0x0900 and 0x0904. | ||
51 | */ | ||
52 | #define L2X0_LOCKDOWN_WAY_D_BASE 0x900 | ||
53 | #define L2X0_LOCKDOWN_WAY_I_BASE 0x904 | ||
54 | #define L2X0_LOCKDOWN_STRIDE 0x08 | ||
50 | #define L2X0_TEST_OPERATION 0xF00 | 55 | #define L2X0_TEST_OPERATION 0xF00 |
51 | #define L2X0_LINE_DATA 0xF10 | 56 | #define L2X0_LINE_DATA 0xF10 |
52 | #define L2X0_LINE_TAG 0xF30 | 57 | #define L2X0_LINE_TAG 0xF30 |
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index f7887dc53c1f..af32e466e1c1 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile | |||
@@ -43,6 +43,13 @@ obj-$(CONFIG_KPROBES) += kprobes-thumb.o | |||
43 | else | 43 | else |
44 | obj-$(CONFIG_KPROBES) += kprobes-arm.o | 44 | obj-$(CONFIG_KPROBES) += kprobes-arm.o |
45 | endif | 45 | endif |
46 | obj-$(CONFIG_ARM_KPROBES_TEST) += test-kprobes.o | ||
47 | test-kprobes-objs := kprobes-test.o | ||
48 | ifdef CONFIG_THUMB2_KERNEL | ||
49 | test-kprobes-objs += kprobes-test-thumb.o | ||
50 | else | ||
51 | test-kprobes-objs += kprobes-test-arm.o | ||
52 | endif | ||
46 | obj-$(CONFIG_ATAGS_PROC) += atags.o | 53 | obj-$(CONFIG_ATAGS_PROC) += atags.o |
47 | obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o | 54 | obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o |
48 | obj-$(CONFIG_ARM_THUMBEE) += thumbee.o | 55 | obj-$(CONFIG_ARM_THUMBEE) += thumbee.o |
diff --git a/arch/arm/kernel/kprobes-arm.c b/arch/arm/kernel/kprobes-arm.c index 79203ee1d039..9fe8910308af 100644 --- a/arch/arm/kernel/kprobes-arm.c +++ b/arch/arm/kernel/kprobes-arm.c | |||
@@ -60,6 +60,7 @@ | |||
60 | 60 | ||
61 | #include <linux/kernel.h> | 61 | #include <linux/kernel.h> |
62 | #include <linux/kprobes.h> | 62 | #include <linux/kprobes.h> |
63 | #include <linux/module.h> | ||
63 | 64 | ||
64 | #include "kprobes.h" | 65 | #include "kprobes.h" |
65 | 66 | ||
@@ -971,6 +972,9 @@ const union decode_item kprobe_decode_arm_table[] = { | |||
971 | 972 | ||
972 | DECODE_END | 973 | DECODE_END |
973 | }; | 974 | }; |
975 | #ifdef CONFIG_ARM_KPROBES_TEST_MODULE | ||
976 | EXPORT_SYMBOL_GPL(kprobe_decode_arm_table); | ||
977 | #endif | ||
974 | 978 | ||
975 | static void __kprobes arm_singlestep(struct kprobe *p, struct pt_regs *regs) | 979 | static void __kprobes arm_singlestep(struct kprobe *p, struct pt_regs *regs) |
976 | { | 980 | { |
diff --git a/arch/arm/kernel/kprobes-test-arm.c b/arch/arm/kernel/kprobes-test-arm.c new file mode 100644 index 000000000000..fc82de8bdcce --- /dev/null +++ b/arch/arm/kernel/kprobes-test-arm.c | |||
@@ -0,0 +1,1323 @@ | |||
1 | /* | ||
2 | * arch/arm/kernel/kprobes-test-arm.c | ||
3 | * | ||
4 | * Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/module.h> | ||
13 | |||
14 | #include "kprobes-test.h" | ||
15 | |||
16 | |||
17 | #define TEST_ISA "32" | ||
18 | |||
19 | #define TEST_ARM_TO_THUMB_INTERWORK_R(code1, reg, val, code2) \ | ||
20 | TESTCASE_START(code1 #reg code2) \ | ||
21 | TEST_ARG_REG(reg, val) \ | ||
22 | TEST_ARG_REG(14, 99f) \ | ||
23 | TEST_ARG_END("") \ | ||
24 | "50: nop \n\t" \ | ||
25 | "1: "code1 #reg code2" \n\t" \ | ||
26 | " bx lr \n\t" \ | ||
27 | ".thumb \n\t" \ | ||
28 | "3: adr lr, 2f \n\t" \ | ||
29 | " bx lr \n\t" \ | ||
30 | ".arm \n\t" \ | ||
31 | "2: nop \n\t" \ | ||
32 | TESTCASE_END | ||
33 | |||
34 | #define TEST_ARM_TO_THUMB_INTERWORK_P(code1, reg, val, code2) \ | ||
35 | TESTCASE_START(code1 #reg code2) \ | ||
36 | TEST_ARG_PTR(reg, val) \ | ||
37 | TEST_ARG_REG(14, 99f) \ | ||
38 | TEST_ARG_MEM(15, 3f+1) \ | ||
39 | TEST_ARG_END("") \ | ||
40 | "50: nop \n\t" \ | ||
41 | "1: "code1 #reg code2" \n\t" \ | ||
42 | " bx lr \n\t" \ | ||
43 | ".thumb \n\t" \ | ||
44 | "3: adr lr, 2f \n\t" \ | ||
45 | " bx lr \n\t" \ | ||
46 | ".arm \n\t" \ | ||
47 | "2: nop \n\t" \ | ||
48 | TESTCASE_END | ||
49 | |||
50 | |||
51 | void kprobe_arm_test_cases(void) | ||
52 | { | ||
53 | kprobe_test_flags = 0; | ||
54 | |||
55 | TEST_GROUP("Data-processing (register), (register-shifted register), (immediate)") | ||
56 | |||
57 | #define _DATA_PROCESSING_DNM(op,s,val) \ | ||
58 | TEST_RR( op "eq" s " r0, r",1, VAL1,", r",2, val, "") \ | ||
59 | TEST_RR( op "ne" s " r1, r",1, VAL1,", r",2, val, ", lsl #3") \ | ||
60 | TEST_RR( op "cs" s " r2, r",3, VAL1,", r",2, val, ", lsr #4") \ | ||
61 | TEST_RR( op "cc" s " r3, r",3, VAL1,", r",2, val, ", asr #5") \ | ||
62 | TEST_RR( op "mi" s " r4, r",5, VAL1,", r",2, N(val),", asr #6") \ | ||
63 | TEST_RR( op "pl" s " r5, r",5, VAL1,", r",2, val, ", ror #7") \ | ||
64 | TEST_RR( op "vs" s " r6, r",7, VAL1,", r",2, val, ", rrx") \ | ||
65 | TEST_R( op "vc" s " r6, r",7, VAL1,", pc, lsl #3") \ | ||
66 | TEST_R( op "vc" s " r6, r",7, VAL1,", sp, lsr #4") \ | ||
67 | TEST_R( op "vc" s " r6, pc, r",7, VAL1,", asr #5") \ | ||
68 | TEST_R( op "vc" s " r6, sp, r",7, VAL1,", ror #6") \ | ||
69 | TEST_RRR( op "hi" s " r8, r",9, VAL1,", r",14,val, ", lsl r",0, 3,"")\ | ||
70 | TEST_RRR( op "ls" s " r9, r",9, VAL1,", r",14,val, ", lsr r",7, 4,"")\ | ||
71 | TEST_RRR( op "ge" s " r10, r",11,VAL1,", r",14,val, ", asr r",7, 5,"")\ | ||
72 | TEST_RRR( op "lt" s " r11, r",11,VAL1,", r",14,N(val),", asr r",7, 6,"")\ | ||
73 | TEST_RR( op "gt" s " r12, r13" ", r",14,val, ", ror r",14,7,"")\ | ||
74 | TEST_RR( op "le" s " r14, r",0, val, ", r13" ", lsl r",14,8,"")\ | ||
75 | TEST_RR( op s " r12, pc" ", r",14,val, ", ror r",14,7,"")\ | ||
76 | TEST_RR( op s " r14, r",0, val, ", pc" ", lsl r",14,8,"")\ | ||
77 | TEST_R( op "eq" s " r0, r",11,VAL1,", #0xf5") \ | ||
78 | TEST_R( op "ne" s " r11, r",0, VAL1,", #0xf5000000") \ | ||
79 | TEST_R( op s " r7, r",8, VAL2,", #0x000af000") \ | ||
80 | TEST( op s " r4, pc" ", #0x00005a00") | ||
81 | |||
82 | #define DATA_PROCESSING_DNM(op,val) \ | ||
83 | _DATA_PROCESSING_DNM(op,"",val) \ | ||
84 | _DATA_PROCESSING_DNM(op,"s",val) | ||
85 | |||
86 | #define DATA_PROCESSING_NM(op,val) \ | ||
87 | TEST_RR( op "ne r",1, VAL1,", r",2, val, "") \ | ||
88 | TEST_RR( op "eq r",1, VAL1,", r",2, val, ", lsl #3") \ | ||
89 | TEST_RR( op "cc r",3, VAL1,", r",2, val, ", lsr #4") \ | ||
90 | TEST_RR( op "cs r",3, VAL1,", r",2, val, ", asr #5") \ | ||
91 | TEST_RR( op "pl r",5, VAL1,", r",2, N(val),", asr #6") \ | ||
92 | TEST_RR( op "mi r",5, VAL1,", r",2, val, ", ror #7") \ | ||
93 | TEST_RR( op "vc r",7, VAL1,", r",2, val, ", rrx") \ | ||
94 | TEST_R ( op "vs r",7, VAL1,", pc, lsl #3") \ | ||
95 | TEST_R ( op "vs r",7, VAL1,", sp, lsr #4") \ | ||
96 | TEST_R( op "vs pc, r",7, VAL1,", asr #5") \ | ||
97 | TEST_R( op "vs sp, r",7, VAL1,", ror #6") \ | ||
98 | TEST_RRR( op "ls r",9, VAL1,", r",14,val, ", lsl r",0, 3,"") \ | ||
99 | TEST_RRR( op "hi r",9, VAL1,", r",14,val, ", lsr r",7, 4,"") \ | ||
100 | TEST_RRR( op "lt r",11,VAL1,", r",14,val, ", asr r",7, 5,"") \ | ||
101 | TEST_RRR( op "ge r",11,VAL1,", r",14,N(val),", asr r",7, 6,"") \ | ||
102 | TEST_RR( op "le r13" ", r",14,val, ", ror r",14,7,"") \ | ||
103 | TEST_RR( op "gt r",0, val, ", r13" ", lsl r",14,8,"") \ | ||
104 | TEST_RR( op " pc" ", r",14,val, ", ror r",14,7,"") \ | ||
105 | TEST_RR( op " r",0, val, ", pc" ", lsl r",14,8,"") \ | ||
106 | TEST_R( op "eq r",11,VAL1,", #0xf5") \ | ||
107 | TEST_R( op "ne r",0, VAL1,", #0xf5000000") \ | ||
108 | TEST_R( op " r",8, VAL2,", #0x000af000") | ||
109 | |||
110 | #define _DATA_PROCESSING_DM(op,s,val) \ | ||
111 | TEST_R( op "eq" s " r0, r",1, val, "") \ | ||
112 | TEST_R( op "ne" s " r1, r",1, val, ", lsl #3") \ | ||
113 | TEST_R( op "cs" s " r2, r",3, val, ", lsr #4") \ | ||
114 | TEST_R( op "cc" s " r3, r",3, val, ", asr #5") \ | ||
115 | TEST_R( op "mi" s " r4, r",5, N(val),", asr #6") \ | ||
116 | TEST_R( op "pl" s " r5, r",5, val, ", ror #7") \ | ||
117 | TEST_R( op "vs" s " r6, r",10,val, ", rrx") \ | ||
118 | TEST( op "vs" s " r7, pc, lsl #3") \ | ||
119 | TEST( op "vs" s " r7, sp, lsr #4") \ | ||
120 | TEST_RR( op "vc" s " r8, r",7, val, ", lsl r",0, 3,"") \ | ||
121 | TEST_RR( op "hi" s " r9, r",9, val, ", lsr r",7, 4,"") \ | ||
122 | TEST_RR( op "ls" s " r10, r",9, val, ", asr r",7, 5,"") \ | ||
123 | TEST_RR( op "ge" s " r11, r",11,N(val),", asr r",7, 6,"") \ | ||
124 | TEST_RR( op "lt" s " r12, r",11,val, ", ror r",14,7,"") \ | ||
125 | TEST_R( op "gt" s " r14, r13" ", lsl r",14,8,"") \ | ||
126 | TEST_R( op "le" s " r14, pc" ", lsl r",14,8,"") \ | ||
127 | TEST( op "eq" s " r0, #0xf5") \ | ||
128 | TEST( op "ne" s " r11, #0xf5000000") \ | ||
129 | TEST( op s " r7, #0x000af000") \ | ||
130 | TEST( op s " r4, #0x00005a00") | ||
131 | |||
132 | #define DATA_PROCESSING_DM(op,val) \ | ||
133 | _DATA_PROCESSING_DM(op,"",val) \ | ||
134 | _DATA_PROCESSING_DM(op,"s",val) | ||
135 | |||
136 | DATA_PROCESSING_DNM("and",0xf00f00ff) | ||
137 | DATA_PROCESSING_DNM("eor",0xf00f00ff) | ||
138 | DATA_PROCESSING_DNM("sub",VAL2) | ||
139 | DATA_PROCESSING_DNM("rsb",VAL2) | ||
140 | DATA_PROCESSING_DNM("add",VAL2) | ||
141 | DATA_PROCESSING_DNM("adc",VAL2) | ||
142 | DATA_PROCESSING_DNM("sbc",VAL2) | ||
143 | DATA_PROCESSING_DNM("rsc",VAL2) | ||
144 | DATA_PROCESSING_NM("tst",0xf00f00ff) | ||
145 | DATA_PROCESSING_NM("teq",0xf00f00ff) | ||
146 | DATA_PROCESSING_NM("cmp",VAL2) | ||
147 | DATA_PROCESSING_NM("cmn",VAL2) | ||
148 | DATA_PROCESSING_DNM("orr",0xf00f00ff) | ||
149 | DATA_PROCESSING_DM("mov",VAL2) | ||
150 | DATA_PROCESSING_DNM("bic",0xf00f00ff) | ||
151 | DATA_PROCESSING_DM("mvn",VAL2) | ||
152 | |||
153 | TEST("mov ip, sp") /* This has special case emulation code */ | ||
154 | |||
155 | TEST_SUPPORTED("mov pc, #0x1000"); | ||
156 | TEST_SUPPORTED("mov sp, #0x1000"); | ||
157 | TEST_SUPPORTED("cmp pc, #0x1000"); | ||
158 | TEST_SUPPORTED("cmp sp, #0x1000"); | ||
159 | |||
160 | /* Data-processing with PC as shift*/ | ||
161 | TEST_UNSUPPORTED(".word 0xe15c0f1e @ cmp r12, r14, asl pc") | ||
162 | TEST_UNSUPPORTED(".word 0xe1a0cf1e @ mov r12, r14, asl pc") | ||
163 | TEST_UNSUPPORTED(".word 0xe08caf1e @ add r10, r12, r14, asl pc") | ||
164 | |||
165 | /* Data-processing with PC as shift*/ | ||
166 | TEST_UNSUPPORTED("movs pc, r1") | ||
167 | TEST_UNSUPPORTED("movs pc, r1, lsl r2") | ||
168 | TEST_UNSUPPORTED("movs pc, #0x10000") | ||
169 | TEST_UNSUPPORTED("adds pc, lr, r1") | ||
170 | TEST_UNSUPPORTED("adds pc, lr, r1, lsl r2") | ||
171 | TEST_UNSUPPORTED("adds pc, lr, #4") | ||
172 | |||
173 | /* Data-processing with SP as target */ | ||
174 | TEST("add sp, sp, #16") | ||
175 | TEST("sub sp, sp, #8") | ||
176 | TEST("bic sp, sp, #0x20") | ||
177 | TEST("orr sp, sp, #0x20") | ||
178 | TEST_PR( "add sp, r",10,0,", r",11,4,"") | ||
179 | TEST_PRR("add sp, r",10,0,", r",11,4,", asl r",12,1,"") | ||
180 | TEST_P( "mov sp, r",10,0,"") | ||
181 | TEST_PR( "mov sp, r",10,0,", asl r",12,0,"") | ||
182 | |||
183 | /* Data-processing with PC as target */ | ||
184 | TEST_BF( "add pc, pc, #2f-1b-8") | ||
185 | TEST_BF_R ("add pc, pc, r",14,2f-1f-8,"") | ||
186 | TEST_BF_R ("add pc, r",14,2f-1f-8,", pc") | ||
187 | TEST_BF_R ("mov pc, r",0,2f,"") | ||
188 | TEST_BF_RR("mov pc, r",0,2f,", asl r",1,0,"") | ||
189 | TEST_BB( "sub pc, pc, #1b-2b+8") | ||
190 | #if __LINUX_ARM_ARCH__ >= 6 | ||
191 | TEST_BB( "sub pc, pc, #1b-2b+8-2") /* UNPREDICTABLE before ARMv6 */ | ||
192 | #endif | ||
193 | TEST_BB_R( "sub pc, pc, r",14, 1f-2f+8,"") | ||
194 | TEST_BB_R( "rsb pc, r",14,1f-2f+8,", pc") | ||
195 | TEST_RR( "add pc, pc, r",10,-2,", asl r",11,1,"") | ||
196 | #ifdef CONFIG_THUMB2_KERNEL | ||
197 | TEST_ARM_TO_THUMB_INTERWORK_R("add pc, pc, r",0,3f-1f-8+1,"") | ||
198 | TEST_ARM_TO_THUMB_INTERWORK_R("sub pc, r",0,3f+8+1,", #8") | ||
199 | #endif | ||
200 | TEST_GROUP("Miscellaneous instructions") | ||
201 | |||
202 | TEST("mrs r0, cpsr") | ||
203 | TEST("mrspl r7, cpsr") | ||
204 | TEST("mrs r14, cpsr") | ||
205 | TEST_UNSUPPORTED(".word 0xe10ff000 @ mrs r15, cpsr") | ||
206 | TEST_UNSUPPORTED("mrs r0, spsr") | ||
207 | TEST_UNSUPPORTED("mrs lr, spsr") | ||
208 | |||
209 | TEST_UNSUPPORTED("msr cpsr, r0") | ||
210 | TEST_UNSUPPORTED("msr cpsr_f, lr") | ||
211 | TEST_UNSUPPORTED("msr spsr, r0") | ||
212 | |||
213 | TEST_BF_R("bx r",0,2f,"") | ||
214 | TEST_BB_R("bx r",7,2f,"") | ||
215 | TEST_BF_R("bxeq r",14,2f,"") | ||
216 | |||
217 | TEST_R("clz r0, r",0, 0x0,"") | ||
218 | TEST_R("clzeq r7, r",14,0x1,"") | ||
219 | TEST_R("clz lr, r",7, 0xffffffff,"") | ||
220 | TEST( "clz r4, sp") | ||
221 | TEST_UNSUPPORTED(".word 0x016fff10 @ clz pc, r0") | ||
222 | TEST_UNSUPPORTED(".word 0x016f0f1f @ clz r0, pc") | ||
223 | |||
224 | #if __LINUX_ARM_ARCH__ >= 6 | ||
225 | TEST_UNSUPPORTED("bxj r0") | ||
226 | #endif | ||
227 | |||
228 | TEST_BF_R("blx r",0,2f,"") | ||
229 | TEST_BB_R("blx r",7,2f,"") | ||
230 | TEST_BF_R("blxeq r",14,2f,"") | ||
231 | TEST_UNSUPPORTED(".word 0x0120003f @ blx pc") | ||
232 | |||
233 | TEST_RR( "qadd r0, r",1, VAL1,", r",2, VAL2,"") | ||
234 | TEST_RR( "qaddvs lr, r",9, VAL2,", r",8, VAL1,"") | ||
235 | TEST_R( "qadd lr, r",9, VAL2,", r13") | ||
236 | TEST_RR( "qsub r0, r",1, VAL1,", r",2, VAL2,"") | ||
237 | TEST_RR( "qsubvs lr, r",9, VAL2,", r",8, VAL1,"") | ||
238 | TEST_R( "qsub lr, r",9, VAL2,", r13") | ||
239 | TEST_RR( "qdadd r0, r",1, VAL1,", r",2, VAL2,"") | ||
240 | TEST_RR( "qdaddvs lr, r",9, VAL2,", r",8, VAL1,"") | ||
241 | TEST_R( "qdadd lr, r",9, VAL2,", r13") | ||
242 | TEST_RR( "qdsub r0, r",1, VAL1,", r",2, VAL2,"") | ||
243 | TEST_RR( "qdsubvs lr, r",9, VAL2,", r",8, VAL1,"") | ||
244 | TEST_R( "qdsub lr, r",9, VAL2,", r13") | ||
245 | TEST_UNSUPPORTED(".word 0xe101f050 @ qadd pc, r0, r1") | ||
246 | TEST_UNSUPPORTED(".word 0xe121f050 @ qsub pc, r0, r1") | ||
247 | TEST_UNSUPPORTED(".word 0xe141f050 @ qdadd pc, r0, r1") | ||
248 | TEST_UNSUPPORTED(".word 0xe161f050 @ qdsub pc, r0, r1") | ||
249 | TEST_UNSUPPORTED(".word 0xe16f2050 @ qdsub r2, r0, pc") | ||
250 | TEST_UNSUPPORTED(".word 0xe161205f @ qdsub r2, pc, r1") | ||
251 | |||
252 | TEST_UNSUPPORTED("bkpt 0xffff") | ||
253 | TEST_UNSUPPORTED("bkpt 0x0000") | ||
254 | |||
255 | TEST_UNSUPPORTED(".word 0xe1600070 @ smc #0") | ||
256 | |||
257 | TEST_GROUP("Halfword multiply and multiply-accumulate") | ||
258 | |||
259 | TEST_RRR( "smlabb r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
260 | TEST_RRR( "smlabbge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
261 | TEST_RR( "smlabb lr, r",1, VAL2,", r",2, VAL3,", r13") | ||
262 | TEST_UNSUPPORTED(".word 0xe10f3281 @ smlabb pc, r1, r2, r3") | ||
263 | TEST_RRR( "smlatb r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
264 | TEST_RRR( "smlatbge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
265 | TEST_RR( "smlatb lr, r",1, VAL2,", r",2, VAL3,", r13") | ||
266 | TEST_UNSUPPORTED(".word 0xe10f32a1 @ smlatb pc, r1, r2, r3") | ||
267 | TEST_RRR( "smlabt r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
268 | TEST_RRR( "smlabtge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
269 | TEST_RR( "smlabt lr, r",1, VAL2,", r",2, VAL3,", r13") | ||
270 | TEST_UNSUPPORTED(".word 0xe10f32c1 @ smlabt pc, r1, r2, r3") | ||
271 | TEST_RRR( "smlatt r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
272 | TEST_RRR( "smlattge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
273 | TEST_RR( "smlatt lr, r",1, VAL2,", r",2, VAL3,", r13") | ||
274 | TEST_UNSUPPORTED(".word 0xe10f32e1 @ smlatt pc, r1, r2, r3") | ||
275 | |||
276 | TEST_RRR( "smlawb r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
277 | TEST_RRR( "smlawbge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
278 | TEST_RR( "smlawb lr, r",1, VAL2,", r",2, VAL3,", r13") | ||
279 | TEST_UNSUPPORTED(".word 0xe12f3281 @ smlawb pc, r1, r2, r3") | ||
280 | TEST_RRR( "smlawt r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
281 | TEST_RRR( "smlawtge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
282 | TEST_RR( "smlawt lr, r",1, VAL2,", r",2, VAL3,", r13") | ||
283 | TEST_UNSUPPORTED(".word 0xe12f32c1 @ smlawt pc, r1, r2, r3") | ||
284 | TEST_UNSUPPORTED(".word 0xe12032cf @ smlawt r0, pc, r2, r3") | ||
285 | TEST_UNSUPPORTED(".word 0xe1203fc1 @ smlawt r0, r1, pc, r3") | ||
286 | TEST_UNSUPPORTED(".word 0xe120f2c1 @ smlawt r0, r1, r2, pc") | ||
287 | |||
288 | TEST_RR( "smulwb r0, r",1, VAL1,", r",2, VAL2,"") | ||
289 | TEST_RR( "smulwbge r7, r",8, VAL3,", r",9, VAL1,"") | ||
290 | TEST_R( "smulwb lr, r",1, VAL2,", r13") | ||
291 | TEST_UNSUPPORTED(".word 0xe12f02a1 @ smulwb pc, r1, r2") | ||
292 | TEST_RR( "smulwt r0, r",1, VAL1,", r",2, VAL2,"") | ||
293 | TEST_RR( "smulwtge r7, r",8, VAL3,", r",9, VAL1,"") | ||
294 | TEST_R( "smulwt lr, r",1, VAL2,", r13") | ||
295 | TEST_UNSUPPORTED(".word 0xe12f02e1 @ smulwt pc, r1, r2") | ||
296 | |||
297 | TEST_RRRR( "smlalbb r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) | ||
298 | TEST_RRRR( "smlalbble r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) | ||
299 | TEST_RRR( "smlalbb r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13") | ||
300 | TEST_UNSUPPORTED(".word 0xe14f1382 @ smlalbb pc, r1, r2, r3") | ||
301 | TEST_UNSUPPORTED(".word 0xe141f382 @ smlalbb r1, pc, r2, r3") | ||
302 | TEST_RRRR( "smlaltb r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) | ||
303 | TEST_RRRR( "smlaltble r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) | ||
304 | TEST_RRR( "smlaltb r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13") | ||
305 | TEST_UNSUPPORTED(".word 0xe14f13a2 @ smlaltb pc, r1, r2, r3") | ||
306 | TEST_UNSUPPORTED(".word 0xe141f3a2 @ smlaltb r1, pc, r2, r3") | ||
307 | TEST_RRRR( "smlalbt r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) | ||
308 | TEST_RRRR( "smlalbtle r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) | ||
309 | TEST_RRR( "smlalbt r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13") | ||
310 | TEST_UNSUPPORTED(".word 0xe14f13c2 @ smlalbt pc, r1, r2, r3") | ||
311 | TEST_UNSUPPORTED(".word 0xe141f3c2 @ smlalbt r1, pc, r2, r3") | ||
312 | TEST_RRRR( "smlaltt r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) | ||
313 | TEST_RRRR( "smlalttle r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) | ||
314 | TEST_RRR( "smlaltt r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13") | ||
315 | TEST_UNSUPPORTED(".word 0xe14f13e2 @ smlalbb pc, r1, r2, r3") | ||
316 | TEST_UNSUPPORTED(".word 0xe140f3e2 @ smlalbb r0, pc, r2, r3") | ||
317 | TEST_UNSUPPORTED(".word 0xe14013ef @ smlalbb r0, r1, pc, r3") | ||
318 | TEST_UNSUPPORTED(".word 0xe1401fe2 @ smlalbb r0, r1, r2, pc") | ||
319 | |||
320 | TEST_RR( "smulbb r0, r",1, VAL1,", r",2, VAL2,"") | ||
321 | TEST_RR( "smulbbge r7, r",8, VAL3,", r",9, VAL1,"") | ||
322 | TEST_R( "smulbb lr, r",1, VAL2,", r13") | ||
323 | TEST_UNSUPPORTED(".word 0xe16f0281 @ smulbb pc, r1, r2") | ||
324 | TEST_RR( "smultb r0, r",1, VAL1,", r",2, VAL2,"") | ||
325 | TEST_RR( "smultbge r7, r",8, VAL3,", r",9, VAL1,"") | ||
326 | TEST_R( "smultb lr, r",1, VAL2,", r13") | ||
327 | TEST_UNSUPPORTED(".word 0xe16f02a1 @ smultb pc, r1, r2") | ||
328 | TEST_RR( "smulbt r0, r",1, VAL1,", r",2, VAL2,"") | ||
329 | TEST_RR( "smulbtge r7, r",8, VAL3,", r",9, VAL1,"") | ||
330 | TEST_R( "smulbt lr, r",1, VAL2,", r13") | ||
331 | TEST_UNSUPPORTED(".word 0xe16f02c1 @ smultb pc, r1, r2") | ||
332 | TEST_RR( "smultt r0, r",1, VAL1,", r",2, VAL2,"") | ||
333 | TEST_RR( "smulttge r7, r",8, VAL3,", r",9, VAL1,"") | ||
334 | TEST_R( "smultt lr, r",1, VAL2,", r13") | ||
335 | TEST_UNSUPPORTED(".word 0xe16f02e1 @ smultt pc, r1, r2") | ||
336 | TEST_UNSUPPORTED(".word 0xe16002ef @ smultt r0, pc, r2") | ||
337 | TEST_UNSUPPORTED(".word 0xe1600fe1 @ smultt r0, r1, pc") | ||
338 | |||
339 | TEST_GROUP("Multiply and multiply-accumulate") | ||
340 | |||
341 | TEST_RR( "mul r0, r",1, VAL1,", r",2, VAL2,"") | ||
342 | TEST_RR( "mulls r7, r",8, VAL2,", r",9, VAL2,"") | ||
343 | TEST_R( "mul lr, r",4, VAL3,", r13") | ||
344 | TEST_UNSUPPORTED(".word 0xe00f0291 @ mul pc, r1, r2") | ||
345 | TEST_UNSUPPORTED(".word 0xe000029f @ mul r0, pc, r2") | ||
346 | TEST_UNSUPPORTED(".word 0xe0000f91 @ mul r0, r1, pc") | ||
347 | TEST_RR( "muls r0, r",1, VAL1,", r",2, VAL2,"") | ||
348 | TEST_RR( "mullss r7, r",8, VAL2,", r",9, VAL2,"") | ||
349 | TEST_R( "muls lr, r",4, VAL3,", r13") | ||
350 | TEST_UNSUPPORTED(".word 0xe01f0291 @ muls pc, r1, r2") | ||
351 | |||
352 | TEST_RRR( "mla r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
353 | TEST_RRR( "mlahi r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
354 | TEST_RR( "mla lr, r",1, VAL2,", r",2, VAL3,", r13") | ||
355 | TEST_UNSUPPORTED(".word 0xe02f3291 @ mla pc, r1, r2, r3") | ||
356 | TEST_RRR( "mlas r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
357 | TEST_RRR( "mlahis r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
358 | TEST_RR( "mlas lr, r",1, VAL2,", r",2, VAL3,", r13") | ||
359 | TEST_UNSUPPORTED(".word 0xe03f3291 @ mlas pc, r1, r2, r3") | ||
360 | |||
361 | #if __LINUX_ARM_ARCH__ >= 6 | ||
362 | TEST_RR( "umaal r0, r1, r",2, VAL1,", r",3, VAL2,"") | ||
363 | TEST_RR( "umaalls r7, r8, r",9, VAL2,", r",10, VAL1,"") | ||
364 | TEST_R( "umaal lr, r12, r",11,VAL3,", r13") | ||
365 | TEST_UNSUPPORTED(".word 0xe041f392 @ umaal pc, r1, r2, r3") | ||
366 | TEST_UNSUPPORTED(".word 0xe04f0392 @ umaal r0, pc, r2, r3") | ||
367 | TEST_UNSUPPORTED(".word 0xe0500090 @ undef") | ||
368 | TEST_UNSUPPORTED(".word 0xe05fff9f @ undef") | ||
369 | |||
370 | TEST_RRR( "mls r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
371 | TEST_RRR( "mlshi r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
372 | TEST_RR( "mls lr, r",1, VAL2,", r",2, VAL3,", r13") | ||
373 | TEST_UNSUPPORTED(".word 0xe06f3291 @ mls pc, r1, r2, r3") | ||
374 | TEST_UNSUPPORTED(".word 0xe060329f @ mls r0, pc, r2, r3") | ||
375 | TEST_UNSUPPORTED(".word 0xe0603f91 @ mls r0, r1, pc, r3") | ||
376 | TEST_UNSUPPORTED(".word 0xe060f291 @ mls r0, r1, r2, pc") | ||
377 | #endif | ||
378 | |||
379 | TEST_UNSUPPORTED(".word 0xe0700090 @ undef") | ||
380 | TEST_UNSUPPORTED(".word 0xe07fff9f @ undef") | ||
381 | |||
382 | TEST_RR( "umull r0, r1, r",2, VAL1,", r",3, VAL2,"") | ||
383 | TEST_RR( "umullls r7, r8, r",9, VAL2,", r",10, VAL1,"") | ||
384 | TEST_R( "umull lr, r12, r",11,VAL3,", r13") | ||
385 | TEST_UNSUPPORTED(".word 0xe081f392 @ umull pc, r1, r2, r3") | ||
386 | TEST_UNSUPPORTED(".word 0xe08f1392 @ umull r1, pc, r2, r3") | ||
387 | TEST_RR( "umulls r0, r1, r",2, VAL1,", r",3, VAL2,"") | ||
388 | TEST_RR( "umulllss r7, r8, r",9, VAL2,", r",10, VAL1,"") | ||
389 | TEST_R( "umulls lr, r12, r",11,VAL3,", r13") | ||
390 | TEST_UNSUPPORTED(".word 0xe091f392 @ umulls pc, r1, r2, r3") | ||
391 | TEST_UNSUPPORTED(".word 0xe09f1392 @ umulls r1, pc, r2, r3") | ||
392 | |||
393 | TEST_RRRR( "umlal r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) | ||
394 | TEST_RRRR( "umlalle r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) | ||
395 | TEST_RRR( "umlal r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13") | ||
396 | TEST_UNSUPPORTED(".word 0xe0af1392 @ umlal pc, r1, r2, r3") | ||
397 | TEST_UNSUPPORTED(".word 0xe0a1f392 @ umlal r1, pc, r2, r3") | ||
398 | TEST_RRRR( "umlals r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) | ||
399 | TEST_RRRR( "umlalles r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) | ||
400 | TEST_RRR( "umlals r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13") | ||
401 | TEST_UNSUPPORTED(".word 0xe0bf1392 @ umlals pc, r1, r2, r3") | ||
402 | TEST_UNSUPPORTED(".word 0xe0b1f392 @ umlals r1, pc, r2, r3") | ||
403 | |||
404 | TEST_RR( "smull r0, r1, r",2, VAL1,", r",3, VAL2,"") | ||
405 | TEST_RR( "smullls r7, r8, r",9, VAL2,", r",10, VAL1,"") | ||
406 | TEST_R( "smull lr, r12, r",11,VAL3,", r13") | ||
407 | TEST_UNSUPPORTED(".word 0xe0c1f392 @ smull pc, r1, r2, r3") | ||
408 | TEST_UNSUPPORTED(".word 0xe0cf1392 @ smull r1, pc, r2, r3") | ||
409 | TEST_RR( "smulls r0, r1, r",2, VAL1,", r",3, VAL2,"") | ||
410 | TEST_RR( "smulllss r7, r8, r",9, VAL2,", r",10, VAL1,"") | ||
411 | TEST_R( "smulls lr, r12, r",11,VAL3,", r13") | ||
412 | TEST_UNSUPPORTED(".word 0xe0d1f392 @ smulls pc, r1, r2, r3") | ||
413 | TEST_UNSUPPORTED(".word 0xe0df1392 @ smulls r1, pc, r2, r3") | ||
414 | |||
415 | TEST_RRRR( "smlal r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) | ||
416 | TEST_RRRR( "smlalle r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) | ||
417 | TEST_RRR( "smlal r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13") | ||
418 | TEST_UNSUPPORTED(".word 0xe0ef1392 @ smlal pc, r1, r2, r3") | ||
419 | TEST_UNSUPPORTED(".word 0xe0e1f392 @ smlal r1, pc, r2, r3") | ||
420 | TEST_RRRR( "smlals r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) | ||
421 | TEST_RRRR( "smlalles r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) | ||
422 | TEST_RRR( "smlals r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13") | ||
423 | TEST_UNSUPPORTED(".word 0xe0ff1392 @ smlals pc, r1, r2, r3") | ||
424 | TEST_UNSUPPORTED(".word 0xe0f0f392 @ smlals r0, pc, r2, r3") | ||
425 | TEST_UNSUPPORTED(".word 0xe0f0139f @ smlals r0, r1, pc, r3") | ||
426 | TEST_UNSUPPORTED(".word 0xe0f01f92 @ smlals r0, r1, r2, pc") | ||
427 | |||
428 | TEST_GROUP("Synchronization primitives") | ||
429 | |||
430 | /* | ||
431 | * Use hard coded constants for SWP instructions to avoid warnings | ||
432 | * about deprecated instructions. | ||
433 | */ | ||
434 | TEST_RP( ".word 0xe108e097 @ swp lr, r",7,VAL2,", [r",8,0,"]") | ||
435 | TEST_R( ".word 0x610d0091 @ swpvs r0, r",1,VAL1,", [sp]") | ||
436 | TEST_RP( ".word 0xe10cd09e @ swp sp, r",14,VAL2,", [r",12,13*4,"]") | ||
437 | TEST_UNSUPPORTED(".word 0xe102f091 @ swp pc, r1, [r2]") | ||
438 | TEST_UNSUPPORTED(".word 0xe102009f @ swp r0, pc, [r2]") | ||
439 | TEST_UNSUPPORTED(".word 0xe10f0091 @ swp r0, r1, [pc]") | ||
440 | TEST_RP( ".word 0xe148e097 @ swpb lr, r",7,VAL2,", [r",8,0,"]") | ||
441 | TEST_R( ".word 0x614d0091 @ swpvsb r0, r",1,VAL1,", [sp]") | ||
442 | TEST_UNSUPPORTED(".word 0xe142f091 @ swpb pc, r1, [r2]") | ||
443 | |||
444 | TEST_UNSUPPORTED(".word 0xe1100090") /* Unallocated space */ | ||
445 | TEST_UNSUPPORTED(".word 0xe1200090") /* Unallocated space */ | ||
446 | TEST_UNSUPPORTED(".word 0xe1300090") /* Unallocated space */ | ||
447 | TEST_UNSUPPORTED(".word 0xe1500090") /* Unallocated space */ | ||
448 | TEST_UNSUPPORTED(".word 0xe1600090") /* Unallocated space */ | ||
449 | TEST_UNSUPPORTED(".word 0xe1700090") /* Unallocated space */ | ||
450 | #if __LINUX_ARM_ARCH__ >= 6 | ||
451 | TEST_UNSUPPORTED("ldrex r2, [sp]") | ||
452 | TEST_UNSUPPORTED("strexd r0, r2, r3, [sp]") | ||
453 | TEST_UNSUPPORTED("ldrexd r2, r3, [sp]") | ||
454 | TEST_UNSUPPORTED("strexb r0, r2, [sp]") | ||
455 | TEST_UNSUPPORTED("ldrexb r2, [sp]") | ||
456 | TEST_UNSUPPORTED("strexh r0, r2, [sp]") | ||
457 | TEST_UNSUPPORTED("ldrexh r2, [sp]") | ||
458 | #endif | ||
459 | TEST_GROUP("Extra load/store instructions") | ||
460 | |||
461 | TEST_RPR( "strh r",0, VAL1,", [r",1, 48,", -r",2, 24,"]") | ||
462 | TEST_RPR( "streqh r",14,VAL2,", [r",13,0, ", r",12, 48,"]") | ||
463 | TEST_RPR( "strh r",1, VAL1,", [r",2, 24,", r",3, 48,"]!") | ||
464 | TEST_RPR( "strneh r",12,VAL2,", [r",11,48,", -r",10,24,"]!") | ||
465 | TEST_RPR( "strh r",2, VAL1,", [r",3, 24,"], r",4, 48,"") | ||
466 | TEST_RPR( "strh r",10,VAL2,", [r",9, 48,"], -r",11,24,"") | ||
467 | TEST_UNSUPPORTED(".word 0xe1afc0ba @ strh r12, [pc, r10]!") | ||
468 | TEST_UNSUPPORTED(".word 0xe089f0bb @ strh pc, [r9], r11") | ||
469 | TEST_UNSUPPORTED(".word 0xe089a0bf @ strh r10, [r9], pc") | ||
470 | |||
471 | TEST_PR( "ldrh r0, [r",0, 48,", -r",2, 24,"]") | ||
472 | TEST_PR( "ldrcsh r14, [r",13,0, ", r",12, 48,"]") | ||
473 | TEST_PR( "ldrh r1, [r",2, 24,", r",3, 48,"]!") | ||
474 | TEST_PR( "ldrcch r12, [r",11,48,", -r",10,24,"]!") | ||
475 | TEST_PR( "ldrh r2, [r",3, 24,"], r",4, 48,"") | ||
476 | TEST_PR( "ldrh r10, [r",9, 48,"], -r",11,24,"") | ||
477 | TEST_UNSUPPORTED(".word 0xe1bfc0ba @ ldrh r12, [pc, r10]!") | ||
478 | TEST_UNSUPPORTED(".word 0xe099f0bb @ ldrh pc, [r9], r11") | ||
479 | TEST_UNSUPPORTED(".word 0xe099a0bf @ ldrh r10, [r9], pc") | ||
480 | |||
481 | TEST_RP( "strh r",0, VAL1,", [r",1, 24,", #-2]") | ||
482 | TEST_RP( "strmih r",14,VAL2,", [r",13,0, ", #2]") | ||
483 | TEST_RP( "strh r",1, VAL1,", [r",2, 24,", #4]!") | ||
484 | TEST_RP( "strplh r",12,VAL2,", [r",11,24,", #-4]!") | ||
485 | TEST_RP( "strh r",2, VAL1,", [r",3, 24,"], #48") | ||
486 | TEST_RP( "strh r",10,VAL2,", [r",9, 64,"], #-48") | ||
487 | TEST_UNSUPPORTED(".word 0xe1efc3b0 @ strh r12, [pc, #48]!") | ||
488 | TEST_UNSUPPORTED(".word 0xe0c9f3b0 @ strh pc, [r9], #48") | ||
489 | |||
490 | TEST_P( "ldrh r0, [r",0, 24,", #-2]") | ||
491 | TEST_P( "ldrvsh r14, [r",13,0, ", #2]") | ||
492 | TEST_P( "ldrh r1, [r",2, 24,", #4]!") | ||
493 | TEST_P( "ldrvch r12, [r",11,24,", #-4]!") | ||
494 | TEST_P( "ldrh r2, [r",3, 24,"], #48") | ||
495 | TEST_P( "ldrh r10, [r",9, 64,"], #-48") | ||
496 | TEST( "ldrh r0, [pc, #0]") | ||
497 | TEST_UNSUPPORTED(".word 0xe1ffc3b0 @ ldrh r12, [pc, #48]!") | ||
498 | TEST_UNSUPPORTED(".word 0xe0d9f3b0 @ ldrh pc, [r9], #48") | ||
499 | |||
500 | TEST_PR( "ldrsb r0, [r",0, 48,", -r",2, 24,"]") | ||
501 | TEST_PR( "ldrhisb r14, [r",13,0,", r",12, 48,"]") | ||
502 | TEST_PR( "ldrsb r1, [r",2, 24,", r",3, 48,"]!") | ||
503 | TEST_PR( "ldrlssb r12, [r",11,48,", -r",10,24,"]!") | ||
504 | TEST_PR( "ldrsb r2, [r",3, 24,"], r",4, 48,"") | ||
505 | TEST_PR( "ldrsb r10, [r",9, 48,"], -r",11,24,"") | ||
506 | TEST_UNSUPPORTED(".word 0xe1bfc0da @ ldrsb r12, [pc, r10]!") | ||
507 | TEST_UNSUPPORTED(".word 0xe099f0db @ ldrsb pc, [r9], r11") | ||
508 | |||
509 | TEST_P( "ldrsb r0, [r",0, 24,", #-1]") | ||
510 | TEST_P( "ldrgesb r14, [r",13,0, ", #1]") | ||
511 | TEST_P( "ldrsb r1, [r",2, 24,", #4]!") | ||
512 | TEST_P( "ldrltsb r12, [r",11,24,", #-4]!") | ||
513 | TEST_P( "ldrsb r2, [r",3, 24,"], #48") | ||
514 | TEST_P( "ldrsb r10, [r",9, 64,"], #-48") | ||
515 | TEST( "ldrsb r0, [pc, #0]") | ||
516 | TEST_UNSUPPORTED(".word 0xe1ffc3d0 @ ldrsb r12, [pc, #48]!") | ||
517 | TEST_UNSUPPORTED(".word 0xe0d9f3d0 @ ldrsb pc, [r9], #48") | ||
518 | |||
519 | TEST_PR( "ldrsh r0, [r",0, 48,", -r",2, 24,"]") | ||
520 | TEST_PR( "ldrgtsh r14, [r",13,0, ", r",12, 48,"]") | ||
521 | TEST_PR( "ldrsh r1, [r",2, 24,", r",3, 48,"]!") | ||
522 | TEST_PR( "ldrlesh r12, [r",11,48,", -r",10,24,"]!") | ||
523 | TEST_PR( "ldrsh r2, [r",3, 24,"], r",4, 48,"") | ||
524 | TEST_PR( "ldrsh r10, [r",9, 48,"], -r",11,24,"") | ||
525 | TEST_UNSUPPORTED(".word 0xe1bfc0fa @ ldrsh r12, [pc, r10]!") | ||
526 | TEST_UNSUPPORTED(".word 0xe099f0fb @ ldrsh pc, [r9], r11") | ||
527 | |||
528 | TEST_P( "ldrsh r0, [r",0, 24,", #-1]") | ||
529 | TEST_P( "ldreqsh r14, [r",13,0 ,", #1]") | ||
530 | TEST_P( "ldrsh r1, [r",2, 24,", #4]!") | ||
531 | TEST_P( "ldrnesh r12, [r",11,24,", #-4]!") | ||
532 | TEST_P( "ldrsh r2, [r",3, 24,"], #48") | ||
533 | TEST_P( "ldrsh r10, [r",9, 64,"], #-48") | ||
534 | TEST( "ldrsh r0, [pc, #0]") | ||
535 | TEST_UNSUPPORTED(".word 0xe1ffc3f0 @ ldrsh r12, [pc, #48]!") | ||
536 | TEST_UNSUPPORTED(".word 0xe0d9f3f0 @ ldrsh pc, [r9], #48") | ||
537 | |||
538 | #if __LINUX_ARM_ARCH__ >= 7 | ||
539 | TEST_UNSUPPORTED("strht r1, [r2], r3") | ||
540 | TEST_UNSUPPORTED("ldrht r1, [r2], r3") | ||
541 | TEST_UNSUPPORTED("strht r1, [r2], #48") | ||
542 | TEST_UNSUPPORTED("ldrht r1, [r2], #48") | ||
543 | TEST_UNSUPPORTED("ldrsbt r1, [r2], r3") | ||
544 | TEST_UNSUPPORTED("ldrsbt r1, [r2], #48") | ||
545 | TEST_UNSUPPORTED("ldrsht r1, [r2], r3") | ||
546 | TEST_UNSUPPORTED("ldrsht r1, [r2], #48") | ||
547 | #endif | ||
548 | |||
549 | TEST_RPR( "strd r",0, VAL1,", [r",1, 48,", -r",2,24,"]") | ||
550 | TEST_RPR( "strccd r",8, VAL2,", [r",13,0, ", r",12,48,"]") | ||
551 | TEST_RPR( "strd r",4, VAL1,", [r",2, 24,", r",3, 48,"]!") | ||
552 | TEST_RPR( "strcsd r",12,VAL2,", [r",11,48,", -r",10,24,"]!") | ||
553 | TEST_RPR( "strd r",2, VAL1,", [r",3, 24,"], r",4,48,"") | ||
554 | TEST_RPR( "strd r",10,VAL2,", [r",9, 48,"], -r",7,24,"") | ||
555 | TEST_UNSUPPORTED(".word 0xe1afc0fa @ strd r12, [pc, r10]!") | ||
556 | |||
557 | TEST_PR( "ldrd r0, [r",0, 48,", -r",2,24,"]") | ||
558 | TEST_PR( "ldrmid r8, [r",13,0, ", r",12,48,"]") | ||
559 | TEST_PR( "ldrd r4, [r",2, 24,", r",3, 48,"]!") | ||
560 | TEST_PR( "ldrpld r6, [r",11,48,", -r",10,24,"]!") | ||
561 | TEST_PR( "ldrd r2, [r",5, 24,"], r",4,48,"") | ||
562 | TEST_PR( "ldrd r10, [r",9,48,"], -r",7,24,"") | ||
563 | TEST_UNSUPPORTED(".word 0xe1afc0da @ ldrd r12, [pc, r10]!") | ||
564 | TEST_UNSUPPORTED(".word 0xe089f0db @ ldrd pc, [r9], r11") | ||
565 | TEST_UNSUPPORTED(".word 0xe089e0db @ ldrd lr, [r9], r11") | ||
566 | TEST_UNSUPPORTED(".word 0xe089c0df @ ldrd r12, [r9], pc") | ||
567 | |||
568 | TEST_RP( "strd r",0, VAL1,", [r",1, 24,", #-8]") | ||
569 | TEST_RP( "strvsd r",8, VAL2,", [r",13,0, ", #8]") | ||
570 | TEST_RP( "strd r",4, VAL1,", [r",2, 24,", #16]!") | ||
571 | TEST_RP( "strvcd r",12,VAL2,", [r",11,24,", #-16]!") | ||
572 | TEST_RP( "strd r",2, VAL1,", [r",4, 24,"], #48") | ||
573 | TEST_RP( "strd r",10,VAL2,", [r",9, 64,"], #-48") | ||
574 | TEST_UNSUPPORTED(".word 0xe1efc3f0 @ strd r12, [pc, #48]!") | ||
575 | |||
576 | TEST_P( "ldrd r0, [r",0, 24,", #-8]") | ||
577 | TEST_P( "ldrhid r8, [r",13,0, ", #8]") | ||
578 | TEST_P( "ldrd r4, [r",2, 24,", #16]!") | ||
579 | TEST_P( "ldrlsd r6, [r",11,24,", #-16]!") | ||
580 | TEST_P( "ldrd r2, [r",5, 24,"], #48") | ||
581 | TEST_P( "ldrd r10, [r",9,6,"], #-48") | ||
582 | TEST_UNSUPPORTED(".word 0xe1efc3d0 @ ldrd r12, [pc, #48]!") | ||
583 | TEST_UNSUPPORTED(".word 0xe0c9f3d0 @ ldrd pc, [r9], #48") | ||
584 | TEST_UNSUPPORTED(".word 0xe0c9e3d0 @ ldrd lr, [r9], #48") | ||
585 | |||
586 | TEST_GROUP("Miscellaneous") | ||
587 | |||
588 | #if __LINUX_ARM_ARCH__ >= 7 | ||
589 | TEST("movw r0, #0") | ||
590 | TEST("movw r0, #0xffff") | ||
591 | TEST("movw lr, #0xffff") | ||
592 | TEST_UNSUPPORTED(".word 0xe300f000 @ movw pc, #0") | ||
593 | TEST_R("movt r",0, VAL1,", #0") | ||
594 | TEST_R("movt r",0, VAL2,", #0xffff") | ||
595 | TEST_R("movt r",14,VAL1,", #0xffff") | ||
596 | TEST_UNSUPPORTED(".word 0xe340f000 @ movt pc, #0") | ||
597 | #endif | ||
598 | |||
599 | TEST_UNSUPPORTED("msr cpsr, 0x13") | ||
600 | TEST_UNSUPPORTED("msr cpsr_f, 0xf0000000") | ||
601 | TEST_UNSUPPORTED("msr spsr, 0x13") | ||
602 | |||
603 | #if __LINUX_ARM_ARCH__ >= 7 | ||
604 | TEST_SUPPORTED("yield") | ||
605 | TEST("sev") | ||
606 | TEST("nop") | ||
607 | TEST("wfi") | ||
608 | TEST_SUPPORTED("wfe") | ||
609 | TEST_UNSUPPORTED("dbg #0") | ||
610 | #endif | ||
611 | |||
612 | TEST_GROUP("Load/store word and unsigned byte") | ||
613 | |||
614 | #define LOAD_STORE(byte) \ | ||
615 | TEST_RP( "str"byte" r",0, VAL1,", [r",1, 24,", #-2]") \ | ||
616 | TEST_RP( "str"byte" r",14,VAL2,", [r",13,0, ", #2]") \ | ||
617 | TEST_RP( "str"byte" r",1, VAL1,", [r",2, 24,", #4]!") \ | ||
618 | TEST_RP( "str"byte" r",12,VAL2,", [r",11,24,", #-4]!") \ | ||
619 | TEST_RP( "str"byte" r",2, VAL1,", [r",3, 24,"], #48") \ | ||
620 | TEST_RP( "str"byte" r",10,VAL2,", [r",9, 64,"], #-48") \ | ||
621 | TEST_RPR("str"byte" r",0, VAL1,", [r",1, 48,", -r",2, 24,"]") \ | ||
622 | TEST_RPR("str"byte" r",14,VAL2,", [r",13,0, ", r",12, 48,"]") \ | ||
623 | TEST_RPR("str"byte" r",1, VAL1,", [r",2, 24,", r",3, 48,"]!") \ | ||
624 | TEST_RPR("str"byte" r",12,VAL2,", [r",11,48,", -r",10,24,"]!") \ | ||
625 | TEST_RPR("str"byte" r",2, VAL1,", [r",3, 24,"], r",4, 48,"") \ | ||
626 | TEST_RPR("str"byte" r",10,VAL2,", [r",9, 48,"], -r",11,24,"") \ | ||
627 | TEST_RPR("str"byte" r",0, VAL1,", [r",1, 24,", r",2, 32,", asl #1]")\ | ||
628 | TEST_RPR("str"byte" r",14,VAL2,", [r",13,0, ", r",12, 32,", lsr #2]")\ | ||
629 | TEST_RPR("str"byte" r",1, VAL1,", [r",2, 24,", r",3, 32,", asr #3]!")\ | ||
630 | TEST_RPR("str"byte" r",12,VAL2,", [r",11,24,", r",10, 4,", ror #31]!")\ | ||
631 | TEST_P( "ldr"byte" r0, [r",0, 24,", #-2]") \ | ||
632 | TEST_P( "ldr"byte" r14, [r",13,0, ", #2]") \ | ||
633 | TEST_P( "ldr"byte" r1, [r",2, 24,", #4]!") \ | ||
634 | TEST_P( "ldr"byte" r12, [r",11,24,", #-4]!") \ | ||
635 | TEST_P( "ldr"byte" r2, [r",3, 24,"], #48") \ | ||
636 | TEST_P( "ldr"byte" r10, [r",9, 64,"], #-48") \ | ||
637 | TEST_PR( "ldr"byte" r0, [r",0, 48,", -r",2, 24,"]") \ | ||
638 | TEST_PR( "ldr"byte" r14, [r",13,0, ", r",12, 48,"]") \ | ||
639 | TEST_PR( "ldr"byte" r1, [r",2, 24,", r",3, 48,"]!") \ | ||
640 | TEST_PR( "ldr"byte" r12, [r",11,48,", -r",10,24,"]!") \ | ||
641 | TEST_PR( "ldr"byte" r2, [r",3, 24,"], r",4, 48,"") \ | ||
642 | TEST_PR( "ldr"byte" r10, [r",9, 48,"], -r",11,24,"") \ | ||
643 | TEST_PR( "ldr"byte" r0, [r",0, 24,", r",2, 32,", asl #1]") \ | ||
644 | TEST_PR( "ldr"byte" r14, [r",13,0, ", r",12, 32,", lsr #2]") \ | ||
645 | TEST_PR( "ldr"byte" r1, [r",2, 24,", r",3, 32,", asr #3]!") \ | ||
646 | TEST_PR( "ldr"byte" r12, [r",11,24,", r",10, 4,", ror #31]!") \ | ||
647 | TEST( "ldr"byte" r0, [pc, #0]") \ | ||
648 | TEST_R( "ldr"byte" r12, [pc, r",14,0,"]") | ||
649 | |||
650 | LOAD_STORE("") | ||
651 | TEST_P( "str pc, [r",0,0,", #15*4]") | ||
652 | TEST_R( "str pc, [sp, r",2,15*4,"]") | ||
653 | TEST_BF( "ldr pc, [sp, #15*4]") | ||
654 | TEST_BF_R("ldr pc, [sp, r",2,15*4,"]") | ||
655 | |||
656 | TEST_P( "str sp, [r",0,0,", #13*4]") | ||
657 | TEST_R( "str sp, [sp, r",2,13*4,"]") | ||
658 | TEST_BF( "ldr sp, [sp, #13*4]") | ||
659 | TEST_BF_R("ldr sp, [sp, r",2,13*4,"]") | ||
660 | |||
661 | #ifdef CONFIG_THUMB2_KERNEL | ||
662 | TEST_ARM_TO_THUMB_INTERWORK_P("ldr pc, [r",0,0,", #15*4]") | ||
663 | #endif | ||
664 | TEST_UNSUPPORTED(".word 0xe5af6008 @ str r6, [pc, #8]!") | ||
665 | TEST_UNSUPPORTED(".word 0xe7af6008 @ str r6, [pc, r8]!") | ||
666 | TEST_UNSUPPORTED(".word 0xe5bf6008 @ ldr r6, [pc, #8]!") | ||
667 | TEST_UNSUPPORTED(".word 0xe7bf6008 @ ldr r6, [pc, r8]!") | ||
668 | TEST_UNSUPPORTED(".word 0xe788600f @ str r6, [r8, pc]") | ||
669 | TEST_UNSUPPORTED(".word 0xe798600f @ ldr r6, [r8, pc]") | ||
670 | |||
671 | LOAD_STORE("b") | ||
672 | TEST_UNSUPPORTED(".word 0xe5f7f008 @ ldrb pc, [r7, #8]!") | ||
673 | TEST_UNSUPPORTED(".word 0xe7f7f008 @ ldrb pc, [r7, r8]!") | ||
674 | TEST_UNSUPPORTED(".word 0xe5ef6008 @ strb r6, [pc, #8]!") | ||
675 | TEST_UNSUPPORTED(".word 0xe7ef6008 @ strb r6, [pc, r3]!") | ||
676 | TEST_UNSUPPORTED(".word 0xe5ff6008 @ ldrb r6, [pc, #8]!") | ||
677 | TEST_UNSUPPORTED(".word 0xe7ff6008 @ ldrb r6, [pc, r3]!") | ||
678 | |||
679 | TEST_UNSUPPORTED("ldrt r0, [r1], #4") | ||
680 | TEST_UNSUPPORTED("ldrt r1, [r2], r3") | ||
681 | TEST_UNSUPPORTED("strt r2, [r3], #4") | ||
682 | TEST_UNSUPPORTED("strt r3, [r4], r5") | ||
683 | TEST_UNSUPPORTED("ldrbt r4, [r5], #4") | ||
684 | TEST_UNSUPPORTED("ldrbt r5, [r6], r7") | ||
685 | TEST_UNSUPPORTED("strbt r6, [r7], #4") | ||
686 | TEST_UNSUPPORTED("strbt r7, [r8], r9") | ||
687 | |||
688 | #if __LINUX_ARM_ARCH__ >= 7 | ||
689 | TEST_GROUP("Parallel addition and subtraction, signed") | ||
690 | |||
691 | TEST_UNSUPPORTED(".word 0xe6000010") /* Unallocated space */ | ||
692 | TEST_UNSUPPORTED(".word 0xe60fffff") /* Unallocated space */ | ||
693 | |||
694 | TEST_RR( "sadd16 r0, r",0, HH1,", r",1, HH2,"") | ||
695 | TEST_RR( "sadd16 r14, r",12,HH2,", r",10,HH1,"") | ||
696 | TEST_UNSUPPORTED(".word 0xe61cff1a @ sadd16 pc, r12, r10") | ||
697 | TEST_RR( "sasx r0, r",0, HH1,", r",1, HH2,"") | ||
698 | TEST_RR( "sasx r14, r",12,HH2,", r",10,HH1,"") | ||
699 | TEST_UNSUPPORTED(".word 0xe61cff3a @ sasx pc, r12, r10") | ||
700 | TEST_RR( "ssax r0, r",0, HH1,", r",1, HH2,"") | ||
701 | TEST_RR( "ssax r14, r",12,HH2,", r",10,HH1,"") | ||
702 | TEST_UNSUPPORTED(".word 0xe61cff5a @ ssax pc, r12, r10") | ||
703 | TEST_RR( "ssub16 r0, r",0, HH1,", r",1, HH2,"") | ||
704 | TEST_RR( "ssub16 r14, r",12,HH2,", r",10,HH1,"") | ||
705 | TEST_UNSUPPORTED(".word 0xe61cff7a @ ssub16 pc, r12, r10") | ||
706 | TEST_RR( "sadd8 r0, r",0, HH1,", r",1, HH2,"") | ||
707 | TEST_RR( "sadd8 r14, r",12,HH2,", r",10,HH1,"") | ||
708 | TEST_UNSUPPORTED(".word 0xe61cff9a @ sadd8 pc, r12, r10") | ||
709 | TEST_UNSUPPORTED(".word 0xe61000b0") /* Unallocated space */ | ||
710 | TEST_UNSUPPORTED(".word 0xe61fffbf") /* Unallocated space */ | ||
711 | TEST_UNSUPPORTED(".word 0xe61000d0") /* Unallocated space */ | ||
712 | TEST_UNSUPPORTED(".word 0xe61fffdf") /* Unallocated space */ | ||
713 | TEST_RR( "ssub8 r0, r",0, HH1,", r",1, HH2,"") | ||
714 | TEST_RR( "ssub8 r14, r",12,HH2,", r",10,HH1,"") | ||
715 | TEST_UNSUPPORTED(".word 0xe61cfffa @ ssub8 pc, r12, r10") | ||
716 | |||
717 | TEST_RR( "qadd16 r0, r",0, HH1,", r",1, HH2,"") | ||
718 | TEST_RR( "qadd16 r14, r",12,HH2,", r",10,HH1,"") | ||
719 | TEST_UNSUPPORTED(".word 0xe62cff1a @ qadd16 pc, r12, r10") | ||
720 | TEST_RR( "qasx r0, r",0, HH1,", r",1, HH2,"") | ||
721 | TEST_RR( "qasx r14, r",12,HH2,", r",10,HH1,"") | ||
722 | TEST_UNSUPPORTED(".word 0xe62cff3a @ qasx pc, r12, r10") | ||
723 | TEST_RR( "qsax r0, r",0, HH1,", r",1, HH2,"") | ||
724 | TEST_RR( "qsax r14, r",12,HH2,", r",10,HH1,"") | ||
725 | TEST_UNSUPPORTED(".word 0xe62cff5a @ qsax pc, r12, r10") | ||
726 | TEST_RR( "qsub16 r0, r",0, HH1,", r",1, HH2,"") | ||
727 | TEST_RR( "qsub16 r14, r",12,HH2,", r",10,HH1,"") | ||
728 | TEST_UNSUPPORTED(".word 0xe62cff7a @ qsub16 pc, r12, r10") | ||
729 | TEST_RR( "qadd8 r0, r",0, HH1,", r",1, HH2,"") | ||
730 | TEST_RR( "qadd8 r14, r",12,HH2,", r",10,HH1,"") | ||
731 | TEST_UNSUPPORTED(".word 0xe62cff9a @ qadd8 pc, r12, r10") | ||
732 | TEST_UNSUPPORTED(".word 0xe62000b0") /* Unallocated space */ | ||
733 | TEST_UNSUPPORTED(".word 0xe62fffbf") /* Unallocated space */ | ||
734 | TEST_UNSUPPORTED(".word 0xe62000d0") /* Unallocated space */ | ||
735 | TEST_UNSUPPORTED(".word 0xe62fffdf") /* Unallocated space */ | ||
736 | TEST_RR( "qsub8 r0, r",0, HH1,", r",1, HH2,"") | ||
737 | TEST_RR( "qsub8 r14, r",12,HH2,", r",10,HH1,"") | ||
738 | TEST_UNSUPPORTED(".word 0xe62cfffa @ qsub8 pc, r12, r10") | ||
739 | |||
740 | TEST_RR( "shadd16 r0, r",0, HH1,", r",1, HH2,"") | ||
741 | TEST_RR( "shadd16 r14, r",12,HH2,", r",10,HH1,"") | ||
742 | TEST_UNSUPPORTED(".word 0xe63cff1a @ shadd16 pc, r12, r10") | ||
743 | TEST_RR( "shasx r0, r",0, HH1,", r",1, HH2,"") | ||
744 | TEST_RR( "shasx r14, r",12,HH2,", r",10,HH1,"") | ||
745 | TEST_UNSUPPORTED(".word 0xe63cff3a @ shasx pc, r12, r10") | ||
746 | TEST_RR( "shsax r0, r",0, HH1,", r",1, HH2,"") | ||
747 | TEST_RR( "shsax r14, r",12,HH2,", r",10,HH1,"") | ||
748 | TEST_UNSUPPORTED(".word 0xe63cff5a @ shsax pc, r12, r10") | ||
749 | TEST_RR( "shsub16 r0, r",0, HH1,", r",1, HH2,"") | ||
750 | TEST_RR( "shsub16 r14, r",12,HH2,", r",10,HH1,"") | ||
751 | TEST_UNSUPPORTED(".word 0xe63cff7a @ shsub16 pc, r12, r10") | ||
752 | TEST_RR( "shadd8 r0, r",0, HH1,", r",1, HH2,"") | ||
753 | TEST_RR( "shadd8 r14, r",12,HH2,", r",10,HH1,"") | ||
754 | TEST_UNSUPPORTED(".word 0xe63cff9a @ shadd8 pc, r12, r10") | ||
755 | TEST_UNSUPPORTED(".word 0xe63000b0") /* Unallocated space */ | ||
756 | TEST_UNSUPPORTED(".word 0xe63fffbf") /* Unallocated space */ | ||
757 | TEST_UNSUPPORTED(".word 0xe63000d0") /* Unallocated space */ | ||
758 | TEST_UNSUPPORTED(".word 0xe63fffdf") /* Unallocated space */ | ||
759 | TEST_RR( "shsub8 r0, r",0, HH1,", r",1, HH2,"") | ||
760 | TEST_RR( "shsub8 r14, r",12,HH2,", r",10,HH1,"") | ||
761 | TEST_UNSUPPORTED(".word 0xe63cfffa @ shsub8 pc, r12, r10") | ||
762 | |||
763 | TEST_GROUP("Parallel addition and subtraction, unsigned") | ||
764 | |||
765 | TEST_UNSUPPORTED(".word 0xe6400010") /* Unallocated space */ | ||
766 | TEST_UNSUPPORTED(".word 0xe64fffff") /* Unallocated space */ | ||
767 | |||
768 | TEST_RR( "uadd16 r0, r",0, HH1,", r",1, HH2,"") | ||
769 | TEST_RR( "uadd16 r14, r",12,HH2,", r",10,HH1,"") | ||
770 | TEST_UNSUPPORTED(".word 0xe65cff1a @ uadd16 pc, r12, r10") | ||
771 | TEST_RR( "uasx r0, r",0, HH1,", r",1, HH2,"") | ||
772 | TEST_RR( "uasx r14, r",12,HH2,", r",10,HH1,"") | ||
773 | TEST_UNSUPPORTED(".word 0xe65cff3a @ uasx pc, r12, r10") | ||
774 | TEST_RR( "usax r0, r",0, HH1,", r",1, HH2,"") | ||
775 | TEST_RR( "usax r14, r",12,HH2,", r",10,HH1,"") | ||
776 | TEST_UNSUPPORTED(".word 0xe65cff5a @ usax pc, r12, r10") | ||
777 | TEST_RR( "usub16 r0, r",0, HH1,", r",1, HH2,"") | ||
778 | TEST_RR( "usub16 r14, r",12,HH2,", r",10,HH1,"") | ||
779 | TEST_UNSUPPORTED(".word 0xe65cff7a @ usub16 pc, r12, r10") | ||
780 | TEST_RR( "uadd8 r0, r",0, HH1,", r",1, HH2,"") | ||
781 | TEST_RR( "uadd8 r14, r",12,HH2,", r",10,HH1,"") | ||
782 | TEST_UNSUPPORTED(".word 0xe65cff9a @ uadd8 pc, r12, r10") | ||
783 | TEST_UNSUPPORTED(".word 0xe65000b0") /* Unallocated space */ | ||
784 | TEST_UNSUPPORTED(".word 0xe65fffbf") /* Unallocated space */ | ||
785 | TEST_UNSUPPORTED(".word 0xe65000d0") /* Unallocated space */ | ||
786 | TEST_UNSUPPORTED(".word 0xe65fffdf") /* Unallocated space */ | ||
787 | TEST_RR( "usub8 r0, r",0, HH1,", r",1, HH2,"") | ||
788 | TEST_RR( "usub8 r14, r",12,HH2,", r",10,HH1,"") | ||
789 | TEST_UNSUPPORTED(".word 0xe65cfffa @ usub8 pc, r12, r10") | ||
790 | |||
791 | TEST_RR( "uqadd16 r0, r",0, HH1,", r",1, HH2,"") | ||
792 | TEST_RR( "uqadd16 r14, r",12,HH2,", r",10,HH1,"") | ||
793 | TEST_UNSUPPORTED(".word 0xe66cff1a @ uqadd16 pc, r12, r10") | ||
794 | TEST_RR( "uqasx r0, r",0, HH1,", r",1, HH2,"") | ||
795 | TEST_RR( "uqasx r14, r",12,HH2,", r",10,HH1,"") | ||
796 | TEST_UNSUPPORTED(".word 0xe66cff3a @ uqasx pc, r12, r10") | ||
797 | TEST_RR( "uqsax r0, r",0, HH1,", r",1, HH2,"") | ||
798 | TEST_RR( "uqsax r14, r",12,HH2,", r",10,HH1,"") | ||
799 | TEST_UNSUPPORTED(".word 0xe66cff5a @ uqsax pc, r12, r10") | ||
800 | TEST_RR( "uqsub16 r0, r",0, HH1,", r",1, HH2,"") | ||
801 | TEST_RR( "uqsub16 r14, r",12,HH2,", r",10,HH1,"") | ||
802 | TEST_UNSUPPORTED(".word 0xe66cff7a @ uqsub16 pc, r12, r10") | ||
803 | TEST_RR( "uqadd8 r0, r",0, HH1,", r",1, HH2,"") | ||
804 | TEST_RR( "uqadd8 r14, r",12,HH2,", r",10,HH1,"") | ||
805 | TEST_UNSUPPORTED(".word 0xe66cff9a @ uqadd8 pc, r12, r10") | ||
806 | TEST_UNSUPPORTED(".word 0xe66000b0") /* Unallocated space */ | ||
807 | TEST_UNSUPPORTED(".word 0xe66fffbf") /* Unallocated space */ | ||
808 | TEST_UNSUPPORTED(".word 0xe66000d0") /* Unallocated space */ | ||
809 | TEST_UNSUPPORTED(".word 0xe66fffdf") /* Unallocated space */ | ||
810 | TEST_RR( "uqsub8 r0, r",0, HH1,", r",1, HH2,"") | ||
811 | TEST_RR( "uqsub8 r14, r",12,HH2,", r",10,HH1,"") | ||
812 | TEST_UNSUPPORTED(".word 0xe66cfffa @ uqsub8 pc, r12, r10") | ||
813 | |||
814 | TEST_RR( "uhadd16 r0, r",0, HH1,", r",1, HH2,"") | ||
815 | TEST_RR( "uhadd16 r14, r",12,HH2,", r",10,HH1,"") | ||
816 | TEST_UNSUPPORTED(".word 0xe67cff1a @ uhadd16 pc, r12, r10") | ||
817 | TEST_RR( "uhasx r0, r",0, HH1,", r",1, HH2,"") | ||
818 | TEST_RR( "uhasx r14, r",12,HH2,", r",10,HH1,"") | ||
819 | TEST_UNSUPPORTED(".word 0xe67cff3a @ uhasx pc, r12, r10") | ||
820 | TEST_RR( "uhsax r0, r",0, HH1,", r",1, HH2,"") | ||
821 | TEST_RR( "uhsax r14, r",12,HH2,", r",10,HH1,"") | ||
822 | TEST_UNSUPPORTED(".word 0xe67cff5a @ uhsax pc, r12, r10") | ||
823 | TEST_RR( "uhsub16 r0, r",0, HH1,", r",1, HH2,"") | ||
824 | TEST_RR( "uhsub16 r14, r",12,HH2,", r",10,HH1,"") | ||
825 | TEST_UNSUPPORTED(".word 0xe67cff7a @ uhsub16 pc, r12, r10") | ||
826 | TEST_RR( "uhadd8 r0, r",0, HH1,", r",1, HH2,"") | ||
827 | TEST_RR( "uhadd8 r14, r",12,HH2,", r",10,HH1,"") | ||
828 | TEST_UNSUPPORTED(".word 0xe67cff9a @ uhadd8 pc, r12, r10") | ||
829 | TEST_UNSUPPORTED(".word 0xe67000b0") /* Unallocated space */ | ||
830 | TEST_UNSUPPORTED(".word 0xe67fffbf") /* Unallocated space */ | ||
831 | TEST_UNSUPPORTED(".word 0xe67000d0") /* Unallocated space */ | ||
832 | TEST_UNSUPPORTED(".word 0xe67fffdf") /* Unallocated space */ | ||
833 | TEST_RR( "uhsub8 r0, r",0, HH1,", r",1, HH2,"") | ||
834 | TEST_RR( "uhsub8 r14, r",12,HH2,", r",10,HH1,"") | ||
835 | TEST_UNSUPPORTED(".word 0xe67cfffa @ uhsub8 pc, r12, r10") | ||
836 | TEST_UNSUPPORTED(".word 0xe67feffa @ uhsub8 r14, pc, r10") | ||
837 | TEST_UNSUPPORTED(".word 0xe67cefff @ uhsub8 r14, r12, pc") | ||
838 | #endif /* __LINUX_ARM_ARCH__ >= 7 */ | ||
839 | |||
840 | #if __LINUX_ARM_ARCH__ >= 6 | ||
841 | TEST_GROUP("Packing, unpacking, saturation, and reversal") | ||
842 | |||
843 | TEST_RR( "pkhbt r0, r",0, HH1,", r",1, HH2,"") | ||
844 | TEST_RR( "pkhbt r14,r",12, HH1,", r",10,HH2,", lsl #2") | ||
845 | TEST_UNSUPPORTED(".word 0xe68cf11a @ pkhbt pc, r12, r10, lsl #2") | ||
846 | TEST_RR( "pkhtb r0, r",0, HH1,", r",1, HH2,"") | ||
847 | TEST_RR( "pkhtb r14,r",12, HH1,", r",10,HH2,", asr #2") | ||
848 | TEST_UNSUPPORTED(".word 0xe68cf15a @ pkhtb pc, r12, r10, asr #2") | ||
849 | TEST_UNSUPPORTED(".word 0xe68fe15a @ pkhtb r14, pc, r10, asr #2") | ||
850 | TEST_UNSUPPORTED(".word 0xe68ce15f @ pkhtb r14, r12, pc, asr #2") | ||
851 | TEST_UNSUPPORTED(".word 0xe6900010") /* Unallocated space */ | ||
852 | TEST_UNSUPPORTED(".word 0xe69fffdf") /* Unallocated space */ | ||
853 | |||
854 | TEST_R( "ssat r0, #24, r",0, VAL1,"") | ||
855 | TEST_R( "ssat r14, #24, r",12, VAL2,"") | ||
856 | TEST_R( "ssat r0, #24, r",0, VAL1,", lsl #8") | ||
857 | TEST_R( "ssat r14, #24, r",12, VAL2,", asr #8") | ||
858 | TEST_UNSUPPORTED(".word 0xe6b7f01c @ ssat pc, #24, r12") | ||
859 | |||
860 | TEST_R( "usat r0, #24, r",0, VAL1,"") | ||
861 | TEST_R( "usat r14, #24, r",12, VAL2,"") | ||
862 | TEST_R( "usat r0, #24, r",0, VAL1,", lsl #8") | ||
863 | TEST_R( "usat r14, #24, r",12, VAL2,", asr #8") | ||
864 | TEST_UNSUPPORTED(".word 0xe6f7f01c @ usat pc, #24, r12") | ||
865 | |||
866 | TEST_RR( "sxtab16 r0, r",0, HH1,", r",1, HH2,"") | ||
867 | TEST_RR( "sxtab16 r14,r",12, HH2,", r",10,HH1,", ror #8") | ||
868 | TEST_R( "sxtb16 r8, r",7, HH1,"") | ||
869 | TEST_UNSUPPORTED(".word 0xe68cf47a @ sxtab16 pc,r12, r10, ror #8") | ||
870 | |||
871 | TEST_RR( "sel r0, r",0, VAL1,", r",1, VAL2,"") | ||
872 | TEST_RR( "sel r14, r",12,VAL1,", r",10, VAL2,"") | ||
873 | TEST_UNSUPPORTED(".word 0xe68cffba @ sel pc, r12, r10") | ||
874 | TEST_UNSUPPORTED(".word 0xe68fefba @ sel r14, pc, r10") | ||
875 | TEST_UNSUPPORTED(".word 0xe68cefbf @ sel r14, r12, pc") | ||
876 | |||
877 | TEST_R( "ssat16 r0, #12, r",0, HH1,"") | ||
878 | TEST_R( "ssat16 r14, #12, r",12, HH2,"") | ||
879 | TEST_UNSUPPORTED(".word 0xe6abff3c @ ssat16 pc, #12, r12") | ||
880 | |||
881 | TEST_RR( "sxtab r0, r",0, HH1,", r",1, HH2,"") | ||
882 | TEST_RR( "sxtab r14,r",12, HH2,", r",10,HH1,", ror #8") | ||
883 | TEST_R( "sxtb r8, r",7, HH1,"") | ||
884 | TEST_UNSUPPORTED(".word 0xe6acf47a @ sxtab pc,r12, r10, ror #8") | ||
885 | |||
886 | TEST_R( "rev r0, r",0, VAL1,"") | ||
887 | TEST_R( "rev r14, r",12, VAL2,"") | ||
888 | TEST_UNSUPPORTED(".word 0xe6bfff3c @ rev pc, r12") | ||
889 | |||
890 | TEST_RR( "sxtah r0, r",0, HH1,", r",1, HH2,"") | ||
891 | TEST_RR( "sxtah r14,r",12, HH2,", r",10,HH1,", ror #8") | ||
892 | TEST_R( "sxth r8, r",7, HH1,"") | ||
893 | TEST_UNSUPPORTED(".word 0xe6bcf47a @ sxtah pc,r12, r10, ror #8") | ||
894 | |||
895 | TEST_R( "rev16 r0, r",0, VAL1,"") | ||
896 | TEST_R( "rev16 r14, r",12, VAL2,"") | ||
897 | TEST_UNSUPPORTED(".word 0xe6bfffbc @ rev16 pc, r12") | ||
898 | |||
899 | TEST_RR( "uxtab16 r0, r",0, HH1,", r",1, HH2,"") | ||
900 | TEST_RR( "uxtab16 r14,r",12, HH2,", r",10,HH1,", ror #8") | ||
901 | TEST_R( "uxtb16 r8, r",7, HH1,"") | ||
902 | TEST_UNSUPPORTED(".word 0xe6ccf47a @ uxtab16 pc,r12, r10, ror #8") | ||
903 | |||
904 | TEST_R( "usat16 r0, #12, r",0, HH1,"") | ||
905 | TEST_R( "usat16 r14, #12, r",12, HH2,"") | ||
906 | TEST_UNSUPPORTED(".word 0xe6ecff3c @ usat16 pc, #12, r12") | ||
907 | TEST_UNSUPPORTED(".word 0xe6ecef3f @ usat16 r14, #12, pc") | ||
908 | |||
909 | TEST_RR( "uxtab r0, r",0, HH1,", r",1, HH2,"") | ||
910 | TEST_RR( "uxtab r14,r",12, HH2,", r",10,HH1,", ror #8") | ||
911 | TEST_R( "uxtb r8, r",7, HH1,"") | ||
912 | TEST_UNSUPPORTED(".word 0xe6ecf47a @ uxtab pc,r12, r10, ror #8") | ||
913 | |||
914 | #if __LINUX_ARM_ARCH__ >= 7 | ||
915 | TEST_R( "rbit r0, r",0, VAL1,"") | ||
916 | TEST_R( "rbit r14, r",12, VAL2,"") | ||
917 | TEST_UNSUPPORTED(".word 0xe6ffff3c @ rbit pc, r12") | ||
918 | #endif | ||
919 | |||
920 | TEST_RR( "uxtah r0, r",0, HH1,", r",1, HH2,"") | ||
921 | TEST_RR( "uxtah r14,r",12, HH2,", r",10,HH1,", ror #8") | ||
922 | TEST_R( "uxth r8, r",7, HH1,"") | ||
923 | TEST_UNSUPPORTED(".word 0xe6fff077 @ uxth pc, r7") | ||
924 | TEST_UNSUPPORTED(".word 0xe6ff807f @ uxth r8, pc") | ||
925 | TEST_UNSUPPORTED(".word 0xe6fcf47a @ uxtah pc, r12, r10, ror #8") | ||
926 | TEST_UNSUPPORTED(".word 0xe6fce47f @ uxtah r14, r12, pc, ror #8") | ||
927 | |||
928 | TEST_R( "revsh r0, r",0, VAL1,"") | ||
929 | TEST_R( "revsh r14, r",12, VAL2,"") | ||
930 | TEST_UNSUPPORTED(".word 0xe6ffff3c @ revsh pc, r12") | ||
931 | TEST_UNSUPPORTED(".word 0xe6ffef3f @ revsh r14, pc") | ||
932 | |||
933 | TEST_UNSUPPORTED(".word 0xe6900070") /* Unallocated space */ | ||
934 | TEST_UNSUPPORTED(".word 0xe69fff7f") /* Unallocated space */ | ||
935 | |||
936 | TEST_UNSUPPORTED(".word 0xe6d00070") /* Unallocated space */ | ||
937 | TEST_UNSUPPORTED(".word 0xe6dfff7f") /* Unallocated space */ | ||
938 | #endif /* __LINUX_ARM_ARCH__ >= 6 */ | ||
939 | |||
940 | #if __LINUX_ARM_ARCH__ >= 6 | ||
941 | TEST_GROUP("Signed multiplies") | ||
942 | |||
943 | TEST_RRR( "smlad r0, r",0, HH1,", r",1, HH2,", r",2, VAL1,"") | ||
944 | TEST_RRR( "smlad r14, r",12,HH2,", r",10,HH1,", r",8, VAL2,"") | ||
945 | TEST_UNSUPPORTED(".word 0xe70f8a1c @ smlad pc, r12, r10, r8") | ||
946 | TEST_RRR( "smladx r0, r",0, HH1,", r",1, HH2,", r",2, VAL1,"") | ||
947 | TEST_RRR( "smladx r14, r",12,HH2,", r",10,HH1,", r",8, VAL2,"") | ||
948 | TEST_UNSUPPORTED(".word 0xe70f8a3c @ smladx pc, r12, r10, r8") | ||
949 | |||
950 | TEST_RR( "smuad r0, r",0, HH1,", r",1, HH2,"") | ||
951 | TEST_RR( "smuad r14, r",12,HH2,", r",10,HH1,"") | ||
952 | TEST_UNSUPPORTED(".word 0xe70ffa1c @ smuad pc, r12, r10") | ||
953 | TEST_RR( "smuadx r0, r",0, HH1,", r",1, HH2,"") | ||
954 | TEST_RR( "smuadx r14, r",12,HH2,", r",10,HH1,"") | ||
955 | TEST_UNSUPPORTED(".word 0xe70ffa3c @ smuadx pc, r12, r10") | ||
956 | |||
957 | TEST_RRR( "smlsd r0, r",0, HH1,", r",1, HH2,", r",2, VAL1,"") | ||
958 | TEST_RRR( "smlsd r14, r",12,HH2,", r",10,HH1,", r",8, VAL2,"") | ||
959 | TEST_UNSUPPORTED(".word 0xe70f8a5c @ smlsd pc, r12, r10, r8") | ||
960 | TEST_RRR( "smlsdx r0, r",0, HH1,", r",1, HH2,", r",2, VAL1,"") | ||
961 | TEST_RRR( "smlsdx r14, r",12,HH2,", r",10,HH1,", r",8, VAL2,"") | ||
962 | TEST_UNSUPPORTED(".word 0xe70f8a7c @ smlsdx pc, r12, r10, r8") | ||
963 | |||
964 | TEST_RR( "smusd r0, r",0, HH1,", r",1, HH2,"") | ||
965 | TEST_RR( "smusd r14, r",12,HH2,", r",10,HH1,"") | ||
966 | TEST_UNSUPPORTED(".word 0xe70ffa5c @ smusd pc, r12, r10") | ||
967 | TEST_RR( "smusdx r0, r",0, HH1,", r",1, HH2,"") | ||
968 | TEST_RR( "smusdx r14, r",12,HH2,", r",10,HH1,"") | ||
969 | TEST_UNSUPPORTED(".word 0xe70ffa7c @ smusdx pc, r12, r10") | ||
970 | |||
971 | TEST_RRRR( "smlald r",0, VAL1,", r",1, VAL2, ", r",0, HH1,", r",1, HH2) | ||
972 | TEST_RRRR( "smlald r",11,VAL2,", r",10,VAL1, ", r",9, HH2,", r",8, HH1) | ||
973 | TEST_UNSUPPORTED(".word 0xe74af819 @ smlald pc, r10, r9, r8") | ||
974 | TEST_UNSUPPORTED(".word 0xe74fb819 @ smlald r11, pc, r9, r8") | ||
975 | TEST_UNSUPPORTED(".word 0xe74ab81f @ smlald r11, r10, pc, r8") | ||
976 | TEST_UNSUPPORTED(".word 0xe74abf19 @ smlald r11, r10, r9, pc") | ||
977 | |||
978 | TEST_RRRR( "smlaldx r",0, VAL1,", r",1, VAL2, ", r",0, HH1,", r",1, HH2) | ||
979 | TEST_RRRR( "smlaldx r",11,VAL2,", r",10,VAL1, ", r",9, HH2,", r",8, HH1) | ||
980 | TEST_UNSUPPORTED(".word 0xe74af839 @ smlaldx pc, r10, r9, r8") | ||
981 | TEST_UNSUPPORTED(".word 0xe74fb839 @ smlaldx r11, pc, r9, r8") | ||
982 | |||
983 | TEST_RRR( "smmla r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL1,"") | ||
984 | TEST_RRR( "smmla r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL2,"") | ||
985 | TEST_UNSUPPORTED(".word 0xe75f8a1c @ smmla pc, r12, r10, r8") | ||
986 | TEST_RRR( "smmlar r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL1,"") | ||
987 | TEST_RRR( "smmlar r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL2,"") | ||
988 | TEST_UNSUPPORTED(".word 0xe75f8a3c @ smmlar pc, r12, r10, r8") | ||
989 | |||
990 | TEST_RR( "smmul r0, r",0, VAL1,", r",1, VAL2,"") | ||
991 | TEST_RR( "smmul r14, r",12,VAL2,", r",10,VAL1,"") | ||
992 | TEST_UNSUPPORTED(".word 0xe75ffa1c @ smmul pc, r12, r10") | ||
993 | TEST_RR( "smmulr r0, r",0, VAL1,", r",1, VAL2,"") | ||
994 | TEST_RR( "smmulr r14, r",12,VAL2,", r",10,VAL1,"") | ||
995 | TEST_UNSUPPORTED(".word 0xe75ffa3c @ smmulr pc, r12, r10") | ||
996 | |||
997 | TEST_RRR( "smmls r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL1,"") | ||
998 | TEST_RRR( "smmls r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL2,"") | ||
999 | TEST_UNSUPPORTED(".word 0xe75f8adc @ smmls pc, r12, r10, r8") | ||
1000 | TEST_RRR( "smmlsr r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL1,"") | ||
1001 | TEST_RRR( "smmlsr r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL2,"") | ||
1002 | TEST_UNSUPPORTED(".word 0xe75f8afc @ smmlsr pc, r12, r10, r8") | ||
1003 | TEST_UNSUPPORTED(".word 0xe75e8aff @ smmlsr r14, pc, r10, r8") | ||
1004 | TEST_UNSUPPORTED(".word 0xe75e8ffc @ smmlsr r14, r12, pc, r8") | ||
1005 | TEST_UNSUPPORTED(".word 0xe75efafc @ smmlsr r14, r12, r10, pc") | ||
1006 | |||
1007 | TEST_RR( "usad8 r0, r",0, VAL1,", r",1, VAL2,"") | ||
1008 | TEST_RR( "usad8 r14, r",12,VAL2,", r",10,VAL1,"") | ||
1009 | TEST_UNSUPPORTED(".word 0xe75ffa1c @ usad8 pc, r12, r10") | ||
1010 | TEST_UNSUPPORTED(".word 0xe75efa1f @ usad8 r14, pc, r10") | ||
1011 | TEST_UNSUPPORTED(".word 0xe75eff1c @ usad8 r14, r12, pc") | ||
1012 | |||
1013 | TEST_RRR( "usada8 r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL3,"") | ||
1014 | TEST_RRR( "usada8 r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL3,"") | ||
1015 | TEST_UNSUPPORTED(".word 0xe78f8a1c @ usada8 pc, r12, r10, r8") | ||
1016 | TEST_UNSUPPORTED(".word 0xe78e8a1f @ usada8 r14, pc, r10, r8") | ||
1017 | TEST_UNSUPPORTED(".word 0xe78e8f1c @ usada8 r14, r12, pc, r8") | ||
1018 | #endif /* __LINUX_ARM_ARCH__ >= 6 */ | ||
1019 | |||
1020 | #if __LINUX_ARM_ARCH__ >= 7 | ||
1021 | TEST_GROUP("Bit Field") | ||
1022 | |||
1023 | TEST_R( "sbfx r0, r",0 , VAL1,", #0, #31") | ||
1024 | TEST_R( "sbfxeq r14, r",12, VAL2,", #8, #16") | ||
1025 | TEST_R( "sbfx r4, r",10, VAL1,", #16, #15") | ||
1026 | TEST_UNSUPPORTED(".word 0xe7aff45c @ sbfx pc, r12, #8, #16") | ||
1027 | |||
1028 | TEST_R( "ubfx r0, r",0 , VAL1,", #0, #31") | ||
1029 | TEST_R( "ubfxcs r14, r",12, VAL2,", #8, #16") | ||
1030 | TEST_R( "ubfx r4, r",10, VAL1,", #16, #15") | ||
1031 | TEST_UNSUPPORTED(".word 0xe7eff45c @ ubfx pc, r12, #8, #16") | ||
1032 | TEST_UNSUPPORTED(".word 0xe7efc45f @ ubfx r12, pc, #8, #16") | ||
1033 | |||
1034 | TEST_R( "bfc r",0, VAL1,", #4, #20") | ||
1035 | TEST_R( "bfcvs r",14,VAL2,", #4, #20") | ||
1036 | TEST_R( "bfc r",7, VAL1,", #0, #31") | ||
1037 | TEST_R( "bfc r",8, VAL2,", #0, #31") | ||
1038 | TEST_UNSUPPORTED(".word 0xe7def01f @ bfc pc, #0, #31"); | ||
1039 | |||
1040 | TEST_RR( "bfi r",0, VAL1,", r",0 , VAL2,", #0, #31") | ||
1041 | TEST_RR( "bfipl r",12,VAL1,", r",14 , VAL2,", #4, #20") | ||
1042 | TEST_UNSUPPORTED(".word 0xe7d7f21e @ bfi pc, r14, #4, #20") | ||
1043 | |||
1044 | TEST_UNSUPPORTED(".word 0x07f000f0") /* Permanently UNDEFINED */ | ||
1045 | TEST_UNSUPPORTED(".word 0x07ffffff") /* Permanently UNDEFINED */ | ||
1046 | #endif /* __LINUX_ARM_ARCH__ >= 6 */ | ||
1047 | |||
1048 | TEST_GROUP("Branch, branch with link, and block data transfer") | ||
1049 | |||
1050 | TEST_P( "stmda r",0, 16*4,", {r0}") | ||
1051 | TEST_P( "stmeqda r",4, 16*4,", {r0-r15}") | ||
1052 | TEST_P( "stmneda r",8, 16*4,"!, {r8-r15}") | ||
1053 | TEST_P( "stmda r",12,16*4,"!, {r1,r3,r5,r7,r8-r11,r14}") | ||
1054 | TEST_P( "stmda r",13,0, "!, {pc}") | ||
1055 | |||
1056 | TEST_P( "ldmda r",0, 16*4,", {r0}") | ||
1057 | TEST_BF_P("ldmcsda r",4, 15*4,", {r0-r15}") | ||
1058 | TEST_BF_P("ldmccda r",7, 15*4,"!, {r8-r15}") | ||
1059 | TEST_P( "ldmda r",12,16*4,"!, {r1,r3,r5,r7,r8-r11,r14}") | ||
1060 | TEST_BF_P("ldmda r",14,15*4,"!, {pc}") | ||
1061 | |||
1062 | TEST_P( "stmia r",0, 16*4,", {r0}") | ||
1063 | TEST_P( "stmmiia r",4, 16*4,", {r0-r15}") | ||
1064 | TEST_P( "stmplia r",8, 16*4,"!, {r8-r15}") | ||
1065 | TEST_P( "stmia r",12,16*4,"!, {r1,r3,r5,r7,r8-r11,r14}") | ||
1066 | TEST_P( "stmia r",14,0, "!, {pc}") | ||
1067 | |||
1068 | TEST_P( "ldmia r",0, 16*4,", {r0}") | ||
1069 | TEST_BF_P("ldmvsia r",4, 0, ", {r0-r15}") | ||
1070 | TEST_BF_P("ldmvcia r",7, 8*4, "!, {r8-r15}") | ||
1071 | TEST_P( "ldmia r",12,16*4,"!, {r1,r3,r5,r7,r8-r11,r14}") | ||
1072 | TEST_BF_P("ldmia r",14,15*4,"!, {pc}") | ||
1073 | |||
1074 | TEST_P( "stmdb r",0, 16*4,", {r0}") | ||
1075 | TEST_P( "stmhidb r",4, 16*4,", {r0-r15}") | ||
1076 | TEST_P( "stmlsdb r",8, 16*4,"!, {r8-r15}") | ||
1077 | TEST_P( "stmdb r",12,16*4,"!, {r1,r3,r5,r7,r8-r11,r14}") | ||
1078 | TEST_P( "stmdb r",13,4, "!, {pc}") | ||
1079 | |||
1080 | TEST_P( "ldmdb r",0, 16*4,", {r0}") | ||
1081 | TEST_BF_P("ldmgedb r",4, 16*4,", {r0-r15}") | ||
1082 | TEST_BF_P("ldmltdb r",7, 16*4,"!, {r8-r15}") | ||
1083 | TEST_P( "ldmdb r",12,16*4,"!, {r1,r3,r5,r7,r8-r11,r14}") | ||
1084 | TEST_BF_P("ldmdb r",14,16*4,"!, {pc}") | ||
1085 | |||
1086 | TEST_P( "stmib r",0, 16*4,", {r0}") | ||
1087 | TEST_P( "stmgtib r",4, 16*4,", {r0-r15}") | ||
1088 | TEST_P( "stmleib r",8, 16*4,"!, {r8-r15}") | ||
1089 | TEST_P( "stmib r",12,16*4,"!, {r1,r3,r5,r7,r8-r11,r14}") | ||
1090 | TEST_P( "stmib r",13,-4, "!, {pc}") | ||
1091 | |||
1092 | TEST_P( "ldmib r",0, 16*4,", {r0}") | ||
1093 | TEST_BF_P("ldmeqib r",4, -4,", {r0-r15}") | ||
1094 | TEST_BF_P("ldmneib r",7, 7*4,"!, {r8-r15}") | ||
1095 | TEST_P( "ldmib r",12,16*4,"!, {r1,r3,r5,r7,r8-r11,r14}") | ||
1096 | TEST_BF_P("ldmib r",14,14*4,"!, {pc}") | ||
1097 | |||
1098 | TEST_P( "stmdb r",13,16*4,"!, {r3-r12,lr}") | ||
1099 | TEST_P( "stmeqdb r",13,16*4,"!, {r3-r12}") | ||
1100 | TEST_P( "stmnedb r",2, 16*4,", {r3-r12,lr}") | ||
1101 | TEST_P( "stmdb r",13,16*4,"!, {r2-r12,lr}") | ||
1102 | TEST_P( "stmdb r",0, 16*4,", {r0-r12}") | ||
1103 | TEST_P( "stmdb r",0, 16*4,", {r0-r12,lr}") | ||
1104 | |||
1105 | TEST_BF_P("ldmia r",13,5*4, "!, {r3-r12,pc}") | ||
1106 | TEST_P( "ldmccia r",13,5*4, "!, {r3-r12}") | ||
1107 | TEST_BF_P("ldmcsia r",2, 5*4, "!, {r3-r12,pc}") | ||
1108 | TEST_BF_P("ldmia r",13,4*4, "!, {r2-r12,pc}") | ||
1109 | TEST_P( "ldmia r",0, 16*4,", {r0-r12}") | ||
1110 | TEST_P( "ldmia r",0, 16*4,", {r0-r12,lr}") | ||
1111 | |||
1112 | #ifdef CONFIG_THUMB2_KERNEL | ||
1113 | TEST_ARM_TO_THUMB_INTERWORK_P("ldmplia r",0,15*4,", {pc}") | ||
1114 | TEST_ARM_TO_THUMB_INTERWORK_P("ldmmiia r",13,0,", {r0-r15}") | ||
1115 | #endif | ||
1116 | TEST_BF("b 2f") | ||
1117 | TEST_BF("bl 2f") | ||
1118 | TEST_BB("b 2b") | ||
1119 | TEST_BB("bl 2b") | ||
1120 | |||
1121 | TEST_BF("beq 2f") | ||
1122 | TEST_BF("bleq 2f") | ||
1123 | TEST_BB("bne 2b") | ||
1124 | TEST_BB("blne 2b") | ||
1125 | |||
1126 | TEST_BF("bgt 2f") | ||
1127 | TEST_BF("blgt 2f") | ||
1128 | TEST_BB("blt 2b") | ||
1129 | TEST_BB("bllt 2b") | ||
1130 | |||
1131 | TEST_GROUP("Supervisor Call, and coprocessor instructions") | ||
1132 | |||
1133 | /* | ||
1134 | * We can't really test these by executing them, so all | ||
1135 | * we can do is check that probes are, or are not allowed. | ||
1136 | * At the moment none are allowed... | ||
1137 | */ | ||
1138 | #define TEST_COPROCESSOR(code) TEST_UNSUPPORTED(code) | ||
1139 | |||
1140 | #define COPROCESSOR_INSTRUCTIONS_ST_LD(two,cc) \ | ||
1141 | TEST_COPROCESSOR("stc"two" 0, cr0, [r13, #4]") \ | ||
1142 | TEST_COPROCESSOR("stc"two" 0, cr0, [r13, #-4]") \ | ||
1143 | TEST_COPROCESSOR("stc"two" 0, cr0, [r13, #4]!") \ | ||
1144 | TEST_COPROCESSOR("stc"two" 0, cr0, [r13, #-4]!") \ | ||
1145 | TEST_COPROCESSOR("stc"two" 0, cr0, [r13], #4") \ | ||
1146 | TEST_COPROCESSOR("stc"two" 0, cr0, [r13], #-4") \ | ||
1147 | TEST_COPROCESSOR("stc"two" 0, cr0, [r13], {1}") \ | ||
1148 | TEST_COPROCESSOR("stc"two"l 0, cr0, [r13, #4]") \ | ||
1149 | TEST_COPROCESSOR("stc"two"l 0, cr0, [r13, #-4]") \ | ||
1150 | TEST_COPROCESSOR("stc"two"l 0, cr0, [r13, #4]!") \ | ||
1151 | TEST_COPROCESSOR("stc"two"l 0, cr0, [r13, #-4]!") \ | ||
1152 | TEST_COPROCESSOR("stc"two"l 0, cr0, [r13], #4") \ | ||
1153 | TEST_COPROCESSOR("stc"two"l 0, cr0, [r13], #-4") \ | ||
1154 | TEST_COPROCESSOR("stc"two"l 0, cr0, [r13], {1}") \ | ||
1155 | TEST_COPROCESSOR("ldc"two" 0, cr0, [r13, #4]") \ | ||
1156 | TEST_COPROCESSOR("ldc"two" 0, cr0, [r13, #-4]") \ | ||
1157 | TEST_COPROCESSOR("ldc"two" 0, cr0, [r13, #4]!") \ | ||
1158 | TEST_COPROCESSOR("ldc"two" 0, cr0, [r13, #-4]!") \ | ||
1159 | TEST_COPROCESSOR("ldc"two" 0, cr0, [r13], #4") \ | ||
1160 | TEST_COPROCESSOR("ldc"two" 0, cr0, [r13], #-4") \ | ||
1161 | TEST_COPROCESSOR("ldc"two" 0, cr0, [r13], {1}") \ | ||
1162 | TEST_COPROCESSOR("ldc"two"l 0, cr0, [r13, #4]") \ | ||
1163 | TEST_COPROCESSOR("ldc"two"l 0, cr0, [r13, #-4]") \ | ||
1164 | TEST_COPROCESSOR("ldc"two"l 0, cr0, [r13, #4]!") \ | ||
1165 | TEST_COPROCESSOR("ldc"two"l 0, cr0, [r13, #-4]!") \ | ||
1166 | TEST_COPROCESSOR("ldc"two"l 0, cr0, [r13], #4") \ | ||
1167 | TEST_COPROCESSOR("ldc"two"l 0, cr0, [r13], #-4") \ | ||
1168 | TEST_COPROCESSOR("ldc"two"l 0, cr0, [r13], {1}") \ | ||
1169 | \ | ||
1170 | TEST_COPROCESSOR( "stc"two" 0, cr0, [r15, #4]") \ | ||
1171 | TEST_COPROCESSOR( "stc"two" 0, cr0, [r15, #-4]") \ | ||
1172 | TEST_UNSUPPORTED(".word 0x"cc"daf0001 @ stc"two" 0, cr0, [r15, #4]!") \ | ||
1173 | TEST_UNSUPPORTED(".word 0x"cc"d2f0001 @ stc"two" 0, cr0, [r15, #-4]!") \ | ||
1174 | TEST_UNSUPPORTED(".word 0x"cc"caf0001 @ stc"two" 0, cr0, [r15], #4") \ | ||
1175 | TEST_UNSUPPORTED(".word 0x"cc"c2f0001 @ stc"two" 0, cr0, [r15], #-4") \ | ||
1176 | TEST_COPROCESSOR( "stc"two" 0, cr0, [r15], {1}") \ | ||
1177 | TEST_COPROCESSOR( "stc"two"l 0, cr0, [r15, #4]") \ | ||
1178 | TEST_COPROCESSOR( "stc"two"l 0, cr0, [r15, #-4]") \ | ||
1179 | TEST_UNSUPPORTED(".word 0x"cc"def0001 @ stc"two"l 0, cr0, [r15, #4]!") \ | ||
1180 | TEST_UNSUPPORTED(".word 0x"cc"d6f0001 @ stc"two"l 0, cr0, [r15, #-4]!") \ | ||
1181 | TEST_UNSUPPORTED(".word 0x"cc"cef0001 @ stc"two"l 0, cr0, [r15], #4") \ | ||
1182 | TEST_UNSUPPORTED(".word 0x"cc"c6f0001 @ stc"two"l 0, cr0, [r15], #-4") \ | ||
1183 | TEST_COPROCESSOR( "stc"two"l 0, cr0, [r15], {1}") \ | ||
1184 | TEST_COPROCESSOR( "ldc"two" 0, cr0, [r15, #4]") \ | ||
1185 | TEST_COPROCESSOR( "ldc"two" 0, cr0, [r15, #-4]") \ | ||
1186 | TEST_UNSUPPORTED(".word 0x"cc"dbf0001 @ ldc"two" 0, cr0, [r15, #4]!") \ | ||
1187 | TEST_UNSUPPORTED(".word 0x"cc"d3f0001 @ ldc"two" 0, cr0, [r15, #-4]!") \ | ||
1188 | TEST_UNSUPPORTED(".word 0x"cc"cbf0001 @ ldc"two" 0, cr0, [r15], #4") \ | ||
1189 | TEST_UNSUPPORTED(".word 0x"cc"c3f0001 @ ldc"two" 0, cr0, [r15], #-4") \ | ||
1190 | TEST_COPROCESSOR( "ldc"two" 0, cr0, [r15], {1}") \ | ||
1191 | TEST_COPROCESSOR( "ldc"two"l 0, cr0, [r15, #4]") \ | ||
1192 | TEST_COPROCESSOR( "ldc"two"l 0, cr0, [r15, #-4]") \ | ||
1193 | TEST_UNSUPPORTED(".word 0x"cc"dff0001 @ ldc"two"l 0, cr0, [r15, #4]!") \ | ||
1194 | TEST_UNSUPPORTED(".word 0x"cc"d7f0001 @ ldc"two"l 0, cr0, [r15, #-4]!") \ | ||
1195 | TEST_UNSUPPORTED(".word 0x"cc"cff0001 @ ldc"two"l 0, cr0, [r15], #4") \ | ||
1196 | TEST_UNSUPPORTED(".word 0x"cc"c7f0001 @ ldc"two"l 0, cr0, [r15], #-4") \ | ||
1197 | TEST_COPROCESSOR( "ldc"two"l 0, cr0, [r15], {1}") | ||
1198 | |||
1199 | #define COPROCESSOR_INSTRUCTIONS_MC_MR(two,cc) \ | ||
1200 | \ | ||
1201 | TEST_COPROCESSOR( "mcrr"two" 0, 15, r0, r14, cr0") \ | ||
1202 | TEST_COPROCESSOR( "mcrr"two" 15, 0, r14, r0, cr15") \ | ||
1203 | TEST_UNSUPPORTED(".word 0x"cc"c4f00f0 @ mcrr"two" 0, 15, r0, r15, cr0") \ | ||
1204 | TEST_UNSUPPORTED(".word 0x"cc"c40ff0f @ mcrr"two" 15, 0, r15, r0, cr15") \ | ||
1205 | TEST_COPROCESSOR( "mrrc"two" 0, 15, r0, r14, cr0") \ | ||
1206 | TEST_COPROCESSOR( "mrrc"two" 15, 0, r14, r0, cr15") \ | ||
1207 | TEST_UNSUPPORTED(".word 0x"cc"c5f00f0 @ mrrc"two" 0, 15, r0, r15, cr0") \ | ||
1208 | TEST_UNSUPPORTED(".word 0x"cc"c50ff0f @ mrrc"two" 15, 0, r15, r0, cr15") \ | ||
1209 | TEST_COPROCESSOR( "cdp"two" 15, 15, cr15, cr15, cr15, 7") \ | ||
1210 | TEST_COPROCESSOR( "cdp"two" 0, 0, cr0, cr0, cr0, 0") \ | ||
1211 | TEST_COPROCESSOR( "mcr"two" 15, 7, r15, cr15, cr15, 7") \ | ||
1212 | TEST_COPROCESSOR( "mcr"two" 0, 0, r0, cr0, cr0, 0") \ | ||
1213 | TEST_COPROCESSOR( "mrc"two" 15, 7, r15, cr15, cr15, 7") \ | ||
1214 | TEST_COPROCESSOR( "mrc"two" 0, 0, r0, cr0, cr0, 0") | ||
1215 | |||
1216 | COPROCESSOR_INSTRUCTIONS_ST_LD("","e") | ||
1217 | COPROCESSOR_INSTRUCTIONS_MC_MR("","e") | ||
1218 | TEST_UNSUPPORTED("svc 0") | ||
1219 | TEST_UNSUPPORTED("svc 0xffffff") | ||
1220 | |||
1221 | TEST_UNSUPPORTED("svc 0") | ||
1222 | |||
1223 | TEST_GROUP("Unconditional instruction") | ||
1224 | |||
1225 | #if __LINUX_ARM_ARCH__ >= 6 | ||
1226 | TEST_UNSUPPORTED("srsda sp, 0x13") | ||
1227 | TEST_UNSUPPORTED("srsdb sp, 0x13") | ||
1228 | TEST_UNSUPPORTED("srsia sp, 0x13") | ||
1229 | TEST_UNSUPPORTED("srsib sp, 0x13") | ||
1230 | TEST_UNSUPPORTED("srsda sp!, 0x13") | ||
1231 | TEST_UNSUPPORTED("srsdb sp!, 0x13") | ||
1232 | TEST_UNSUPPORTED("srsia sp!, 0x13") | ||
1233 | TEST_UNSUPPORTED("srsib sp!, 0x13") | ||
1234 | |||
1235 | TEST_UNSUPPORTED("rfeda sp") | ||
1236 | TEST_UNSUPPORTED("rfedb sp") | ||
1237 | TEST_UNSUPPORTED("rfeia sp") | ||
1238 | TEST_UNSUPPORTED("rfeib sp") | ||
1239 | TEST_UNSUPPORTED("rfeda sp!") | ||
1240 | TEST_UNSUPPORTED("rfedb sp!") | ||
1241 | TEST_UNSUPPORTED("rfeia sp!") | ||
1242 | TEST_UNSUPPORTED("rfeib sp!") | ||
1243 | TEST_UNSUPPORTED(".word 0xf81d0a00 @ rfeda pc") | ||
1244 | TEST_UNSUPPORTED(".word 0xf91d0a00 @ rfedb pc") | ||
1245 | TEST_UNSUPPORTED(".word 0xf89d0a00 @ rfeia pc") | ||
1246 | TEST_UNSUPPORTED(".word 0xf99d0a00 @ rfeib pc") | ||
1247 | TEST_UNSUPPORTED(".word 0xf83d0a00 @ rfeda pc!") | ||
1248 | TEST_UNSUPPORTED(".word 0xf93d0a00 @ rfedb pc!") | ||
1249 | TEST_UNSUPPORTED(".word 0xf8bd0a00 @ rfeia pc!") | ||
1250 | TEST_UNSUPPORTED(".word 0xf9bd0a00 @ rfeib pc!") | ||
1251 | #endif /* __LINUX_ARM_ARCH__ >= 6 */ | ||
1252 | |||
1253 | #if __LINUX_ARM_ARCH__ >= 6 | ||
1254 | TEST_X( "blx __dummy_thumb_subroutine_even", | ||
1255 | ".thumb \n\t" | ||
1256 | ".space 4 \n\t" | ||
1257 | ".type __dummy_thumb_subroutine_even, %%function \n\t" | ||
1258 | "__dummy_thumb_subroutine_even: \n\t" | ||
1259 | "mov r0, pc \n\t" | ||
1260 | "bx lr \n\t" | ||
1261 | ".arm \n\t" | ||
1262 | ) | ||
1263 | TEST( "blx __dummy_thumb_subroutine_even") | ||
1264 | |||
1265 | TEST_X( "blx __dummy_thumb_subroutine_odd", | ||
1266 | ".thumb \n\t" | ||
1267 | ".space 2 \n\t" | ||
1268 | ".type __dummy_thumb_subroutine_odd, %%function \n\t" | ||
1269 | "__dummy_thumb_subroutine_odd: \n\t" | ||
1270 | "mov r0, pc \n\t" | ||
1271 | "bx lr \n\t" | ||
1272 | ".arm \n\t" | ||
1273 | ) | ||
1274 | TEST( "blx __dummy_thumb_subroutine_odd") | ||
1275 | #endif /* __LINUX_ARM_ARCH__ >= 6 */ | ||
1276 | |||
1277 | COPROCESSOR_INSTRUCTIONS_ST_LD("2","f") | ||
1278 | #if __LINUX_ARM_ARCH__ >= 6 | ||
1279 | COPROCESSOR_INSTRUCTIONS_MC_MR("2","f") | ||
1280 | #endif | ||
1281 | |||
1282 | TEST_GROUP("Miscellaneous instructions, memory hints, and Advanced SIMD instructions") | ||
1283 | |||
1284 | #if __LINUX_ARM_ARCH__ >= 6 | ||
1285 | TEST_UNSUPPORTED("cps 0x13") | ||
1286 | TEST_UNSUPPORTED("cpsie i") | ||
1287 | TEST_UNSUPPORTED("cpsid i") | ||
1288 | TEST_UNSUPPORTED("cpsie i,0x13") | ||
1289 | TEST_UNSUPPORTED("cpsid i,0x13") | ||
1290 | TEST_UNSUPPORTED("setend le") | ||
1291 | TEST_UNSUPPORTED("setend be") | ||
1292 | #endif | ||
1293 | |||
1294 | #if __LINUX_ARM_ARCH__ >= 7 | ||
1295 | TEST_P("pli [r",0,0b,", #16]") | ||
1296 | TEST( "pli [pc, #0]") | ||
1297 | TEST_RR("pli [r",12,0b,", r",0, 16,"]") | ||
1298 | TEST_RR("pli [r",0, 0b,", -r",12,16,", lsl #4]") | ||
1299 | #endif | ||
1300 | |||
1301 | #if __LINUX_ARM_ARCH__ >= 5 | ||
1302 | TEST_P("pld [r",0,32,", #-16]") | ||
1303 | TEST( "pld [pc, #0]") | ||
1304 | TEST_PR("pld [r",7, 24, ", r",0, 16,"]") | ||
1305 | TEST_PR("pld [r",8, 24, ", -r",12,16,", lsl #4]") | ||
1306 | #endif | ||
1307 | |||
1308 | #if __LINUX_ARM_ARCH__ >= 7 | ||
1309 | TEST_SUPPORTED( ".word 0xf590f000 @ pldw [r0, #0]") | ||
1310 | TEST_SUPPORTED( ".word 0xf797f000 @ pldw [r7, r0]") | ||
1311 | TEST_SUPPORTED( ".word 0xf798f18c @ pldw [r8, r12, lsl #3]"); | ||
1312 | #endif | ||
1313 | |||
1314 | #if __LINUX_ARM_ARCH__ >= 7 | ||
1315 | TEST_UNSUPPORTED("clrex") | ||
1316 | TEST_UNSUPPORTED("dsb") | ||
1317 | TEST_UNSUPPORTED("dmb") | ||
1318 | TEST_UNSUPPORTED("isb") | ||
1319 | #endif | ||
1320 | |||
1321 | verbose("\n"); | ||
1322 | } | ||
1323 | |||
diff --git a/arch/arm/kernel/kprobes-test-thumb.c b/arch/arm/kernel/kprobes-test-thumb.c new file mode 100644 index 000000000000..5e726c31c45a --- /dev/null +++ b/arch/arm/kernel/kprobes-test-thumb.c | |||
@@ -0,0 +1,1187 @@ | |||
1 | /* | ||
2 | * arch/arm/kernel/kprobes-test-thumb.c | ||
3 | * | ||
4 | * Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/module.h> | ||
13 | |||
14 | #include "kprobes-test.h" | ||
15 | |||
16 | |||
17 | #define TEST_ISA "16" | ||
18 | |||
19 | #define DONT_TEST_IN_ITBLOCK(tests) \ | ||
20 | kprobe_test_flags |= TEST_FLAG_NO_ITBLOCK; \ | ||
21 | tests \ | ||
22 | kprobe_test_flags &= ~TEST_FLAG_NO_ITBLOCK; | ||
23 | |||
24 | #define CONDITION_INSTRUCTIONS(cc_pos, tests) \ | ||
25 | kprobe_test_cc_position = cc_pos; \ | ||
26 | DONT_TEST_IN_ITBLOCK(tests) \ | ||
27 | kprobe_test_cc_position = 0; | ||
28 | |||
29 | #define TEST_ITBLOCK(code) \ | ||
30 | kprobe_test_flags |= TEST_FLAG_FULL_ITBLOCK; \ | ||
31 | TESTCASE_START(code) \ | ||
32 | TEST_ARG_END("") \ | ||
33 | "50: nop \n\t" \ | ||
34 | "1: "code" \n\t" \ | ||
35 | " mov r1, #0x11 \n\t" \ | ||
36 | " mov r2, #0x22 \n\t" \ | ||
37 | " mov r3, #0x33 \n\t" \ | ||
38 | "2: nop \n\t" \ | ||
39 | TESTCASE_END \ | ||
40 | kprobe_test_flags &= ~TEST_FLAG_FULL_ITBLOCK; | ||
41 | |||
42 | #define TEST_THUMB_TO_ARM_INTERWORK_P(code1, reg, val, code2) \ | ||
43 | TESTCASE_START(code1 #reg code2) \ | ||
44 | TEST_ARG_PTR(reg, val) \ | ||
45 | TEST_ARG_REG(14, 99f+1) \ | ||
46 | TEST_ARG_MEM(15, 3f) \ | ||
47 | TEST_ARG_END("") \ | ||
48 | " nop \n\t" /* To align 1f */ \ | ||
49 | "50: nop \n\t" \ | ||
50 | "1: "code1 #reg code2" \n\t" \ | ||
51 | " bx lr \n\t" \ | ||
52 | ".arm \n\t" \ | ||
53 | "3: adr lr, 2f+1 \n\t" \ | ||
54 | " bx lr \n\t" \ | ||
55 | ".thumb \n\t" \ | ||
56 | "2: nop \n\t" \ | ||
57 | TESTCASE_END | ||
58 | |||
59 | |||
60 | void kprobe_thumb16_test_cases(void) | ||
61 | { | ||
62 | kprobe_test_flags = TEST_FLAG_NARROW_INSTR; | ||
63 | |||
64 | TEST_GROUP("Shift (immediate), add, subtract, move, and compare") | ||
65 | |||
66 | TEST_R( "lsls r7, r",0,VAL1,", #5") | ||
67 | TEST_R( "lsls r0, r",7,VAL2,", #11") | ||
68 | TEST_R( "lsrs r7, r",0,VAL1,", #5") | ||
69 | TEST_R( "lsrs r0, r",7,VAL2,", #11") | ||
70 | TEST_R( "asrs r7, r",0,VAL1,", #5") | ||
71 | TEST_R( "asrs r0, r",7,VAL2,", #11") | ||
72 | TEST_RR( "adds r2, r",0,VAL1,", r",7,VAL2,"") | ||
73 | TEST_RR( "adds r5, r",7,VAL2,", r",0,VAL2,"") | ||
74 | TEST_RR( "subs r2, r",0,VAL1,", r",7,VAL2,"") | ||
75 | TEST_RR( "subs r5, r",7,VAL2,", r",0,VAL2,"") | ||
76 | TEST_R( "adds r7, r",0,VAL1,", #5") | ||
77 | TEST_R( "adds r0, r",7,VAL2,", #2") | ||
78 | TEST_R( "subs r7, r",0,VAL1,", #5") | ||
79 | TEST_R( "subs r0, r",7,VAL2,", #2") | ||
80 | TEST( "movs.n r0, #0x5f") | ||
81 | TEST( "movs.n r7, #0xa0") | ||
82 | TEST_R( "cmp.n r",0,0x5e, ", #0x5f") | ||
83 | TEST_R( "cmp.n r",5,0x15f,", #0x5f") | ||
84 | TEST_R( "cmp.n r",7,0xa0, ", #0xa0") | ||
85 | TEST_R( "adds.n r",0,VAL1,", #0x5f") | ||
86 | TEST_R( "adds.n r",7,VAL2,", #0xa0") | ||
87 | TEST_R( "subs.n r",0,VAL1,", #0x5f") | ||
88 | TEST_R( "subs.n r",7,VAL2,", #0xa0") | ||
89 | |||
90 | TEST_GROUP("16-bit Thumb data-processing instructions") | ||
91 | |||
92 | #define DATA_PROCESSING16(op,val) \ | ||
93 | TEST_RR( op" r",0,VAL1,", r",7,val,"") \ | ||
94 | TEST_RR( op" r",7,VAL2,", r",0,val,"") | ||
95 | |||
96 | DATA_PROCESSING16("ands",0xf00f00ff) | ||
97 | DATA_PROCESSING16("eors",0xf00f00ff) | ||
98 | DATA_PROCESSING16("lsls",11) | ||
99 | DATA_PROCESSING16("lsrs",11) | ||
100 | DATA_PROCESSING16("asrs",11) | ||
101 | DATA_PROCESSING16("adcs",VAL2) | ||
102 | DATA_PROCESSING16("sbcs",VAL2) | ||
103 | DATA_PROCESSING16("rors",11) | ||
104 | DATA_PROCESSING16("tst",0xf00f00ff) | ||
105 | TEST_R("rsbs r",0,VAL1,", #0") | ||
106 | TEST_R("rsbs r",7,VAL2,", #0") | ||
107 | DATA_PROCESSING16("cmp",0xf00f00ff) | ||
108 | DATA_PROCESSING16("cmn",0xf00f00ff) | ||
109 | DATA_PROCESSING16("orrs",0xf00f00ff) | ||
110 | DATA_PROCESSING16("muls",VAL2) | ||
111 | DATA_PROCESSING16("bics",0xf00f00ff) | ||
112 | DATA_PROCESSING16("mvns",VAL2) | ||
113 | |||
114 | TEST_GROUP("Special data instructions and branch and exchange") | ||
115 | |||
116 | TEST_RR( "add r",0, VAL1,", r",7,VAL2,"") | ||
117 | TEST_RR( "add r",3, VAL2,", r",8,VAL3,"") | ||
118 | TEST_RR( "add r",8, VAL3,", r",0,VAL1,"") | ||
119 | TEST_R( "add sp" ", r",8,-8, "") | ||
120 | TEST_R( "add r",14,VAL1,", pc") | ||
121 | TEST_BF_R("add pc" ", r",0,2f-1f-8,"") | ||
122 | TEST_UNSUPPORTED(".short 0x44ff @ add pc, pc") | ||
123 | |||
124 | TEST_RR( "cmp r",3,VAL1,", r",8,VAL2,"") | ||
125 | TEST_RR( "cmp r",8,VAL2,", r",0,VAL1,"") | ||
126 | TEST_R( "cmp sp" ", r",8,-8, "") | ||
127 | |||
128 | TEST_R( "mov r0, r",7,VAL2,"") | ||
129 | TEST_R( "mov r3, r",8,VAL3,"") | ||
130 | TEST_R( "mov r8, r",0,VAL1,"") | ||
131 | TEST_P( "mov sp, r",8,-8, "") | ||
132 | TEST( "mov lr, pc") | ||
133 | TEST_BF_R("mov pc, r",0,2f, "") | ||
134 | |||
135 | TEST_BF_R("bx r",0, 2f+1,"") | ||
136 | TEST_BF_R("bx r",14,2f+1,"") | ||
137 | TESTCASE_START("bx pc") | ||
138 | TEST_ARG_REG(14, 99f+1) | ||
139 | TEST_ARG_END("") | ||
140 | " nop \n\t" /* To align the bx pc*/ | ||
141 | "50: nop \n\t" | ||
142 | "1: bx pc \n\t" | ||
143 | " bx lr \n\t" | ||
144 | ".arm \n\t" | ||
145 | " adr lr, 2f+1 \n\t" | ||
146 | " bx lr \n\t" | ||
147 | ".thumb \n\t" | ||
148 | "2: nop \n\t" | ||
149 | TESTCASE_END | ||
150 | |||
151 | TEST_BF_R("blx r",0, 2f+1,"") | ||
152 | TEST_BB_R("blx r",14,2f+1,"") | ||
153 | TEST_UNSUPPORTED(".short 0x47f8 @ blx pc") | ||
154 | |||
155 | TEST_GROUP("Load from Literal Pool") | ||
156 | |||
157 | TEST_X( "ldr r0, 3f", | ||
158 | ".align \n\t" | ||
159 | "3: .word "__stringify(VAL1)) | ||
160 | TEST_X( "ldr r7, 3f", | ||
161 | ".space 128 \n\t" | ||
162 | ".align \n\t" | ||
163 | "3: .word "__stringify(VAL2)) | ||
164 | |||
165 | TEST_GROUP("16-bit Thumb Load/store instructions") | ||
166 | |||
167 | TEST_RPR("str r",0, VAL1,", [r",1, 24,", r",2, 48,"]") | ||
168 | TEST_RPR("str r",7, VAL2,", [r",6, 24,", r",5, 48,"]") | ||
169 | TEST_RPR("strh r",0, VAL1,", [r",1, 24,", r",2, 48,"]") | ||
170 | TEST_RPR("strh r",7, VAL2,", [r",6, 24,", r",5, 48,"]") | ||
171 | TEST_RPR("strb r",0, VAL1,", [r",1, 24,", r",2, 48,"]") | ||
172 | TEST_RPR("strb r",7, VAL2,", [r",6, 24,", r",5, 48,"]") | ||
173 | TEST_PR( "ldrsb r0, [r",1, 24,", r",2, 48,"]") | ||
174 | TEST_PR( "ldrsb r7, [r",6, 24,", r",5, 50,"]") | ||
175 | TEST_PR( "ldr r0, [r",1, 24,", r",2, 48,"]") | ||
176 | TEST_PR( "ldr r7, [r",6, 24,", r",5, 48,"]") | ||
177 | TEST_PR( "ldrh r0, [r",1, 24,", r",2, 48,"]") | ||
178 | TEST_PR( "ldrh r7, [r",6, 24,", r",5, 50,"]") | ||
179 | TEST_PR( "ldrb r0, [r",1, 24,", r",2, 48,"]") | ||
180 | TEST_PR( "ldrb r7, [r",6, 24,", r",5, 50,"]") | ||
181 | TEST_PR( "ldrsh r0, [r",1, 24,", r",2, 48,"]") | ||
182 | TEST_PR( "ldrsh r7, [r",6, 24,", r",5, 50,"]") | ||
183 | |||
184 | TEST_RP("str r",0, VAL1,", [r",1, 24,", #120]") | ||
185 | TEST_RP("str r",7, VAL2,", [r",6, 24,", #120]") | ||
186 | TEST_P( "ldr r0, [r",1, 24,", #120]") | ||
187 | TEST_P( "ldr r7, [r",6, 24,", #120]") | ||
188 | TEST_RP("strb r",0, VAL1,", [r",1, 24,", #30]") | ||
189 | TEST_RP("strb r",7, VAL2,", [r",6, 24,", #30]") | ||
190 | TEST_P( "ldrb r0, [r",1, 24,", #30]") | ||
191 | TEST_P( "ldrb r7, [r",6, 24,", #30]") | ||
192 | TEST_RP("strh r",0, VAL1,", [r",1, 24,", #60]") | ||
193 | TEST_RP("strh r",7, VAL2,", [r",6, 24,", #60]") | ||
194 | TEST_P( "ldrh r0, [r",1, 24,", #60]") | ||
195 | TEST_P( "ldrh r7, [r",6, 24,", #60]") | ||
196 | |||
197 | TEST_R( "str r",0, VAL1,", [sp, #0]") | ||
198 | TEST_R( "str r",7, VAL2,", [sp, #160]") | ||
199 | TEST( "ldr r0, [sp, #0]") | ||
200 | TEST( "ldr r7, [sp, #160]") | ||
201 | |||
202 | TEST_RP("str r",0, VAL1,", [r",0, 24,"]") | ||
203 | TEST_P( "ldr r0, [r",0, 24,"]") | ||
204 | |||
205 | TEST_GROUP("Generate PC-/SP-relative address") | ||
206 | |||
207 | TEST("add r0, pc, #4") | ||
208 | TEST("add r7, pc, #1020") | ||
209 | TEST("add r0, sp, #4") | ||
210 | TEST("add r7, sp, #1020") | ||
211 | |||
212 | TEST_GROUP("Miscellaneous 16-bit instructions") | ||
213 | |||
214 | TEST_UNSUPPORTED( "cpsie i") | ||
215 | TEST_UNSUPPORTED( "cpsid i") | ||
216 | TEST_UNSUPPORTED( "setend le") | ||
217 | TEST_UNSUPPORTED( "setend be") | ||
218 | |||
219 | TEST("add sp, #"__stringify(TEST_MEMORY_SIZE)) /* Assumes TEST_MEMORY_SIZE < 0x400 */ | ||
220 | TEST("sub sp, #0x7f*4") | ||
221 | |||
222 | DONT_TEST_IN_ITBLOCK( | ||
223 | TEST_BF_R( "cbnz r",0,0, ", 2f") | ||
224 | TEST_BF_R( "cbz r",2,-1,", 2f") | ||
225 | TEST_BF_RX( "cbnz r",4,1, ", 2f",0x20) | ||
226 | TEST_BF_RX( "cbz r",7,0, ", 2f",0x40) | ||
227 | ) | ||
228 | TEST_R("sxth r0, r",7, HH1,"") | ||
229 | TEST_R("sxth r7, r",0, HH2,"") | ||
230 | TEST_R("sxtb r0, r",7, HH1,"") | ||
231 | TEST_R("sxtb r7, r",0, HH2,"") | ||
232 | TEST_R("uxth r0, r",7, HH1,"") | ||
233 | TEST_R("uxth r7, r",0, HH2,"") | ||
234 | TEST_R("uxtb r0, r",7, HH1,"") | ||
235 | TEST_R("uxtb r7, r",0, HH2,"") | ||
236 | TEST_R("rev r0, r",7, VAL1,"") | ||
237 | TEST_R("rev r7, r",0, VAL2,"") | ||
238 | TEST_R("rev16 r0, r",7, VAL1,"") | ||
239 | TEST_R("rev16 r7, r",0, VAL2,"") | ||
240 | TEST_UNSUPPORTED(".short 0xba80") | ||
241 | TEST_UNSUPPORTED(".short 0xbabf") | ||
242 | TEST_R("revsh r0, r",7, VAL1,"") | ||
243 | TEST_R("revsh r7, r",0, VAL2,"") | ||
244 | |||
245 | #define TEST_POPPC(code, offset) \ | ||
246 | TESTCASE_START(code) \ | ||
247 | TEST_ARG_PTR(13, offset) \ | ||
248 | TEST_ARG_END("") \ | ||
249 | TEST_BRANCH_F(code,0) \ | ||
250 | TESTCASE_END | ||
251 | |||
252 | TEST("push {r0}") | ||
253 | TEST("push {r7}") | ||
254 | TEST("push {r14}") | ||
255 | TEST("push {r0-r7,r14}") | ||
256 | TEST("push {r0,r2,r4,r6,r14}") | ||
257 | TEST("push {r1,r3,r5,r7}") | ||
258 | TEST("pop {r0}") | ||
259 | TEST("pop {r7}") | ||
260 | TEST("pop {r0,r2,r4,r6}") | ||
261 | TEST_POPPC("pop {pc}",15*4) | ||
262 | TEST_POPPC("pop {r0-r7,pc}",7*4) | ||
263 | TEST_POPPC("pop {r1,r3,r5,r7,pc}",11*4) | ||
264 | TEST_THUMB_TO_ARM_INTERWORK_P("pop {pc} @ ",13,15*4,"") | ||
265 | TEST_THUMB_TO_ARM_INTERWORK_P("pop {r0-r7,pc} @ ",13,7*4,"") | ||
266 | |||
267 | TEST_UNSUPPORTED("bkpt.n 0") | ||
268 | TEST_UNSUPPORTED("bkpt.n 255") | ||
269 | |||
270 | TEST_SUPPORTED("yield") | ||
271 | TEST("sev") | ||
272 | TEST("nop") | ||
273 | TEST("wfi") | ||
274 | TEST_SUPPORTED("wfe") | ||
275 | TEST_UNSUPPORTED(".short 0xbf50") /* Unassigned hints */ | ||
276 | TEST_UNSUPPORTED(".short 0xbff0") /* Unassigned hints */ | ||
277 | |||
278 | #define TEST_IT(code, code2) \ | ||
279 | TESTCASE_START(code) \ | ||
280 | TEST_ARG_END("") \ | ||
281 | "50: nop \n\t" \ | ||
282 | "1: "code" \n\t" \ | ||
283 | " "code2" \n\t" \ | ||
284 | "2: nop \n\t" \ | ||
285 | TESTCASE_END | ||
286 | |||
287 | DONT_TEST_IN_ITBLOCK( | ||
288 | TEST_IT("it eq","moveq r0,#0") | ||
289 | TEST_IT("it vc","movvc r0,#0") | ||
290 | TEST_IT("it le","movle r0,#0") | ||
291 | TEST_IT("ite eq","moveq r0,#0\n\t movne r1,#1") | ||
292 | TEST_IT("itet vc","movvc r0,#0\n\t movvs r1,#1\n\t movvc r2,#2") | ||
293 | TEST_IT("itete le","movle r0,#0\n\t movgt r1,#1\n\t movle r2,#2\n\t movgt r3,#3") | ||
294 | TEST_IT("itttt le","movle r0,#0\n\t movle r1,#1\n\t movle r2,#2\n\t movle r3,#3") | ||
295 | TEST_IT("iteee le","movle r0,#0\n\t movgt r1,#1\n\t movgt r2,#2\n\t movgt r3,#3") | ||
296 | ) | ||
297 | |||
298 | TEST_GROUP("Load and store multiple") | ||
299 | |||
300 | TEST_P("ldmia r",4, 16*4,"!, {r0,r7}") | ||
301 | TEST_P("ldmia r",7, 16*4,"!, {r0-r6}") | ||
302 | TEST_P("stmia r",4, 16*4,"!, {r0,r7}") | ||
303 | TEST_P("stmia r",0, 16*4,"!, {r0-r7}") | ||
304 | |||
305 | TEST_GROUP("Conditional branch and Supervisor Call instructions") | ||
306 | |||
307 | CONDITION_INSTRUCTIONS(8, | ||
308 | TEST_BF("beq 2f") | ||
309 | TEST_BB("bne 2b") | ||
310 | TEST_BF("bgt 2f") | ||
311 | TEST_BB("blt 2b") | ||
312 | ) | ||
313 | TEST_UNSUPPORTED(".short 0xde00") | ||
314 | TEST_UNSUPPORTED(".short 0xdeff") | ||
315 | TEST_UNSUPPORTED("svc #0x00") | ||
316 | TEST_UNSUPPORTED("svc #0xff") | ||
317 | |||
318 | TEST_GROUP("Unconditional branch") | ||
319 | |||
320 | TEST_BF( "b 2f") | ||
321 | TEST_BB( "b 2b") | ||
322 | TEST_BF_X("b 2f", 0x400) | ||
323 | TEST_BB_X("b 2b", 0x400) | ||
324 | |||
325 | TEST_GROUP("Testing instructions in IT blocks") | ||
326 | |||
327 | TEST_ITBLOCK("subs.n r0, r0") | ||
328 | |||
329 | verbose("\n"); | ||
330 | } | ||
331 | |||
332 | |||
333 | void kprobe_thumb32_test_cases(void) | ||
334 | { | ||
335 | kprobe_test_flags = 0; | ||
336 | |||
337 | TEST_GROUP("Load/store multiple") | ||
338 | |||
339 | TEST_UNSUPPORTED("rfedb sp") | ||
340 | TEST_UNSUPPORTED("rfeia sp") | ||
341 | TEST_UNSUPPORTED("rfedb sp!") | ||
342 | TEST_UNSUPPORTED("rfeia sp!") | ||
343 | |||
344 | TEST_P( "stmia r",0, 16*4,", {r0,r8}") | ||
345 | TEST_P( "stmia r",4, 16*4,", {r0-r12,r14}") | ||
346 | TEST_P( "stmia r",7, 16*4,"!, {r8-r12,r14}") | ||
347 | TEST_P( "stmia r",12,16*4,"!, {r1,r3,r5,r7,r8-r11,r14}") | ||
348 | |||
349 | TEST_P( "ldmia r",0, 16*4,", {r0,r8}") | ||
350 | TEST_P( "ldmia r",4, 0, ", {r0-r12,r14}") | ||
351 | TEST_BF_P("ldmia r",5, 8*4, "!, {r6-r12,r15}") | ||
352 | TEST_P( "ldmia r",12,16*4,"!, {r1,r3,r5,r7,r8-r11,r14}") | ||
353 | TEST_BF_P("ldmia r",14,14*4,"!, {r4,pc}") | ||
354 | |||
355 | TEST_P( "stmdb r",0, 16*4,", {r0,r8}") | ||
356 | TEST_P( "stmdb r",4, 16*4,", {r0-r12,r14}") | ||
357 | TEST_P( "stmdb r",5, 16*4,"!, {r8-r12,r14}") | ||
358 | TEST_P( "stmdb r",12,16*4,"!, {r1,r3,r5,r7,r8-r11,r14}") | ||
359 | |||
360 | TEST_P( "ldmdb r",0, 16*4,", {r0,r8}") | ||
361 | TEST_P( "ldmdb r",4, 16*4,", {r0-r12,r14}") | ||
362 | TEST_BF_P("ldmdb r",5, 16*4,"!, {r6-r12,r15}") | ||
363 | TEST_P( "ldmdb r",12,16*4,"!, {r1,r3,r5,r7,r8-r11,r14}") | ||
364 | TEST_BF_P("ldmdb r",14,16*4,"!, {r4,pc}") | ||
365 | |||
366 | TEST_P( "stmdb r",13,16*4,"!, {r3-r12,lr}") | ||
367 | TEST_P( "stmdb r",13,16*4,"!, {r3-r12}") | ||
368 | TEST_P( "stmdb r",2, 16*4,", {r3-r12,lr}") | ||
369 | TEST_P( "stmdb r",13,16*4,"!, {r2-r12,lr}") | ||
370 | TEST_P( "stmdb r",0, 16*4,", {r0-r12}") | ||
371 | TEST_P( "stmdb r",0, 16*4,", {r0-r12,lr}") | ||
372 | |||
373 | TEST_BF_P("ldmia r",13,5*4, "!, {r3-r12,pc}") | ||
374 | TEST_P( "ldmia r",13,5*4, "!, {r3-r12}") | ||
375 | TEST_BF_P("ldmia r",2, 5*4, "!, {r3-r12,pc}") | ||
376 | TEST_BF_P("ldmia r",13,4*4, "!, {r2-r12,pc}") | ||
377 | TEST_P( "ldmia r",0, 16*4,", {r0-r12}") | ||
378 | TEST_P( "ldmia r",0, 16*4,", {r0-r12,lr}") | ||
379 | |||
380 | TEST_THUMB_TO_ARM_INTERWORK_P("ldmia r",0,14*4,", {r12,pc}") | ||
381 | TEST_THUMB_TO_ARM_INTERWORK_P("ldmia r",13,2*4,", {r0-r12,pc}") | ||
382 | |||
383 | TEST_UNSUPPORTED(".short 0xe88f,0x0101 @ stmia pc, {r0,r8}") | ||
384 | TEST_UNSUPPORTED(".short 0xe92f,0x5f00 @ stmdb pc!, {r8-r12,r14}") | ||
385 | TEST_UNSUPPORTED(".short 0xe8bd,0xc000 @ ldmia r13!, {r14,pc}") | ||
386 | TEST_UNSUPPORTED(".short 0xe93e,0xc000 @ ldmdb r14!, {r14,pc}") | ||
387 | TEST_UNSUPPORTED(".short 0xe8a7,0x3f00 @ stmia r7!, {r8-r12,sp}") | ||
388 | TEST_UNSUPPORTED(".short 0xe8a7,0x9f00 @ stmia r7!, {r8-r12,pc}") | ||
389 | TEST_UNSUPPORTED(".short 0xe93e,0x2010 @ ldmdb r14!, {r4,sp}") | ||
390 | |||
391 | TEST_GROUP("Load/store double or exclusive, table branch") | ||
392 | |||
393 | TEST_P( "ldrd r0, r1, [r",1, 24,", #-16]") | ||
394 | TEST( "ldrd r12, r14, [sp, #16]") | ||
395 | TEST_P( "ldrd r1, r0, [r",7, 24,", #-16]!") | ||
396 | TEST( "ldrd r14, r12, [sp, #16]!") | ||
397 | TEST_P( "ldrd r1, r0, [r",7, 24,"], #16") | ||
398 | TEST( "ldrd r7, r8, [sp], #-16") | ||
399 | |||
400 | TEST_X( "ldrd r12, r14, 3f", | ||
401 | ".align 3 \n\t" | ||
402 | "3: .word "__stringify(VAL1)" \n\t" | ||
403 | " .word "__stringify(VAL2)) | ||
404 | |||
405 | TEST_UNSUPPORTED(".short 0xe9ff,0xec04 @ ldrd r14, r12, [pc, #16]!") | ||
406 | TEST_UNSUPPORTED(".short 0xe8ff,0xec04 @ ldrd r14, r12, [pc], #16") | ||
407 | TEST_UNSUPPORTED(".short 0xe9d4,0xd800 @ ldrd sp, r8, [r4]") | ||
408 | TEST_UNSUPPORTED(".short 0xe9d4,0xf800 @ ldrd pc, r8, [r4]") | ||
409 | TEST_UNSUPPORTED(".short 0xe9d4,0x7d00 @ ldrd r7, sp, [r4]") | ||
410 | TEST_UNSUPPORTED(".short 0xe9d4,0x7f00 @ ldrd r7, pc, [r4]") | ||
411 | |||
412 | TEST_RRP("strd r",0, VAL1,", r",1, VAL2,", [r",1, 24,", #-16]") | ||
413 | TEST_RR( "strd r",12,VAL2,", r",14,VAL1,", [sp, #16]") | ||
414 | TEST_RRP("strd r",1, VAL1,", r",0, VAL2,", [r",7, 24,", #-16]!") | ||
415 | TEST_RR( "strd r",14,VAL2,", r",12,VAL1,", [sp, #16]!") | ||
416 | TEST_RRP("strd r",1, VAL1,", r",0, VAL2,", [r",7, 24,"], #16") | ||
417 | TEST_RR( "strd r",7, VAL2,", r",8, VAL1,", [sp], #-16") | ||
418 | TEST_UNSUPPORTED(".short 0xe9ef,0xec04 @ strd r14, r12, [pc, #16]!") | ||
419 | TEST_UNSUPPORTED(".short 0xe8ef,0xec04 @ strd r14, r12, [pc], #16") | ||
420 | |||
421 | TEST_RX("tbb [pc, r",0, (9f-(1f+4)),"]", | ||
422 | "9: \n\t" | ||
423 | ".byte (2f-1b-4)>>1 \n\t" | ||
424 | ".byte (3f-1b-4)>>1 \n\t" | ||
425 | "3: mvn r0, r0 \n\t" | ||
426 | "2: nop \n\t") | ||
427 | |||
428 | TEST_RX("tbb [pc, r",4, (9f-(1f+4)+1),"]", | ||
429 | "9: \n\t" | ||
430 | ".byte (2f-1b-4)>>1 \n\t" | ||
431 | ".byte (3f-1b-4)>>1 \n\t" | ||
432 | "3: mvn r0, r0 \n\t" | ||
433 | "2: nop \n\t") | ||
434 | |||
435 | TEST_RRX("tbb [r",1,9f,", r",2,0,"]", | ||
436 | "9: \n\t" | ||
437 | ".byte (2f-1b-4)>>1 \n\t" | ||
438 | ".byte (3f-1b-4)>>1 \n\t" | ||
439 | "3: mvn r0, r0 \n\t" | ||
440 | "2: nop \n\t") | ||
441 | |||
442 | TEST_RX("tbh [pc, r",7, (9f-(1f+4))>>1,"]", | ||
443 | "9: \n\t" | ||
444 | ".short (2f-1b-4)>>1 \n\t" | ||
445 | ".short (3f-1b-4)>>1 \n\t" | ||
446 | "3: mvn r0, r0 \n\t" | ||
447 | "2: nop \n\t") | ||
448 | |||
449 | TEST_RX("tbh [pc, r",12, ((9f-(1f+4))>>1)+1,"]", | ||
450 | "9: \n\t" | ||
451 | ".short (2f-1b-4)>>1 \n\t" | ||
452 | ".short (3f-1b-4)>>1 \n\t" | ||
453 | "3: mvn r0, r0 \n\t" | ||
454 | "2: nop \n\t") | ||
455 | |||
456 | TEST_RRX("tbh [r",1,9f, ", r",14,1,"]", | ||
457 | "9: \n\t" | ||
458 | ".short (2f-1b-4)>>1 \n\t" | ||
459 | ".short (3f-1b-4)>>1 \n\t" | ||
460 | "3: mvn r0, r0 \n\t" | ||
461 | "2: nop \n\t") | ||
462 | |||
463 | TEST_UNSUPPORTED(".short 0xe8d1,0xf01f @ tbh [r1, pc]") | ||
464 | TEST_UNSUPPORTED(".short 0xe8d1,0xf01d @ tbh [r1, sp]") | ||
465 | TEST_UNSUPPORTED(".short 0xe8dd,0xf012 @ tbh [sp, r2]") | ||
466 | |||
467 | TEST_UNSUPPORTED("strexb r0, r1, [r2]") | ||
468 | TEST_UNSUPPORTED("strexh r0, r1, [r2]") | ||
469 | TEST_UNSUPPORTED("strexd r0, r1, [r2]") | ||
470 | TEST_UNSUPPORTED("ldrexb r0, [r1]") | ||
471 | TEST_UNSUPPORTED("ldrexh r0, [r1]") | ||
472 | TEST_UNSUPPORTED("ldrexd r0, [r1]") | ||
473 | |||
474 | TEST_GROUP("Data-processing (shifted register) and (modified immediate)") | ||
475 | |||
476 | #define _DATA_PROCESSING32_DNM(op,s,val) \ | ||
477 | TEST_RR(op s".w r0, r",1, VAL1,", r",2, val, "") \ | ||
478 | TEST_RR(op s" r1, r",1, VAL1,", r",2, val, ", lsl #3") \ | ||
479 | TEST_RR(op s" r2, r",3, VAL1,", r",2, val, ", lsr #4") \ | ||
480 | TEST_RR(op s" r3, r",3, VAL1,", r",2, val, ", asr #5") \ | ||
481 | TEST_RR(op s" r4, r",5, VAL1,", r",2, N(val),", asr #6") \ | ||
482 | TEST_RR(op s" r5, r",5, VAL1,", r",2, val, ", ror #7") \ | ||
483 | TEST_RR(op s" r8, r",9, VAL1,", r",10,val, ", rrx") \ | ||
484 | TEST_R( op s" r0, r",11,VAL1,", #0x00010001") \ | ||
485 | TEST_R( op s" r11, r",0, VAL1,", #0xf5000000") \ | ||
486 | TEST_R( op s" r7, r",8, VAL2,", #0x000af000") | ||
487 | |||
488 | #define DATA_PROCESSING32_DNM(op,val) \ | ||
489 | _DATA_PROCESSING32_DNM(op,"",val) \ | ||
490 | _DATA_PROCESSING32_DNM(op,"s",val) | ||
491 | |||
492 | #define DATA_PROCESSING32_NM(op,val) \ | ||
493 | TEST_RR(op".w r",1, VAL1,", r",2, val, "") \ | ||
494 | TEST_RR(op" r",1, VAL1,", r",2, val, ", lsl #3") \ | ||
495 | TEST_RR(op" r",3, VAL1,", r",2, val, ", lsr #4") \ | ||
496 | TEST_RR(op" r",3, VAL1,", r",2, val, ", asr #5") \ | ||
497 | TEST_RR(op" r",5, VAL1,", r",2, N(val),", asr #6") \ | ||
498 | TEST_RR(op" r",5, VAL1,", r",2, val, ", ror #7") \ | ||
499 | TEST_RR(op" r",9, VAL1,", r",10,val, ", rrx") \ | ||
500 | TEST_R( op" r",11,VAL1,", #0x00010001") \ | ||
501 | TEST_R( op" r",0, VAL1,", #0xf5000000") \ | ||
502 | TEST_R( op" r",8, VAL2,", #0x000af000") | ||
503 | |||
504 | #define _DATA_PROCESSING32_DM(op,s,val) \ | ||
505 | TEST_R( op s".w r0, r",14, val, "") \ | ||
506 | TEST_R( op s" r1, r",12, val, ", lsl #3") \ | ||
507 | TEST_R( op s" r2, r",11, val, ", lsr #4") \ | ||
508 | TEST_R( op s" r3, r",10, val, ", asr #5") \ | ||
509 | TEST_R( op s" r4, r",9, N(val),", asr #6") \ | ||
510 | TEST_R( op s" r5, r",8, val, ", ror #7") \ | ||
511 | TEST_R( op s" r8, r",7,val, ", rrx") \ | ||
512 | TEST( op s" r0, #0x00010001") \ | ||
513 | TEST( op s" r11, #0xf5000000") \ | ||
514 | TEST( op s" r7, #0x000af000") \ | ||
515 | TEST( op s" r4, #0x00005a00") | ||
516 | |||
517 | #define DATA_PROCESSING32_DM(op,val) \ | ||
518 | _DATA_PROCESSING32_DM(op,"",val) \ | ||
519 | _DATA_PROCESSING32_DM(op,"s",val) | ||
520 | |||
521 | DATA_PROCESSING32_DNM("and",0xf00f00ff) | ||
522 | DATA_PROCESSING32_NM("tst",0xf00f00ff) | ||
523 | DATA_PROCESSING32_DNM("bic",0xf00f00ff) | ||
524 | DATA_PROCESSING32_DNM("orr",0xf00f00ff) | ||
525 | DATA_PROCESSING32_DM("mov",VAL2) | ||
526 | DATA_PROCESSING32_DNM("orn",0xf00f00ff) | ||
527 | DATA_PROCESSING32_DM("mvn",VAL2) | ||
528 | DATA_PROCESSING32_DNM("eor",0xf00f00ff) | ||
529 | DATA_PROCESSING32_NM("teq",0xf00f00ff) | ||
530 | DATA_PROCESSING32_DNM("add",VAL2) | ||
531 | DATA_PROCESSING32_NM("cmn",VAL2) | ||
532 | DATA_PROCESSING32_DNM("adc",VAL2) | ||
533 | DATA_PROCESSING32_DNM("sbc",VAL2) | ||
534 | DATA_PROCESSING32_DNM("sub",VAL2) | ||
535 | DATA_PROCESSING32_NM("cmp",VAL2) | ||
536 | DATA_PROCESSING32_DNM("rsb",VAL2) | ||
537 | |||
538 | TEST_RR("pkhbt r0, r",0, HH1,", r",1, HH2,"") | ||
539 | TEST_RR("pkhbt r14,r",12, HH1,", r",10,HH2,", lsl #2") | ||
540 | TEST_RR("pkhtb r0, r",0, HH1,", r",1, HH2,"") | ||
541 | TEST_RR("pkhtb r14,r",12, HH1,", r",10,HH2,", asr #2") | ||
542 | |||
543 | TEST_UNSUPPORTED(".short 0xea17,0x0f0d @ tst.w r7, sp") | ||
544 | TEST_UNSUPPORTED(".short 0xea17,0x0f0f @ tst.w r7, pc") | ||
545 | TEST_UNSUPPORTED(".short 0xea1d,0x0f07 @ tst.w sp, r7") | ||
546 | TEST_UNSUPPORTED(".short 0xea1f,0x0f07 @ tst.w pc, r7") | ||
547 | TEST_UNSUPPORTED(".short 0xf01d,0x1f08 @ tst sp, #0x00080008") | ||
548 | TEST_UNSUPPORTED(".short 0xf01f,0x1f08 @ tst pc, #0x00080008") | ||
549 | |||
550 | TEST_UNSUPPORTED(".short 0xea97,0x0f0d @ teq.w r7, sp") | ||
551 | TEST_UNSUPPORTED(".short 0xea97,0x0f0f @ teq.w r7, pc") | ||
552 | TEST_UNSUPPORTED(".short 0xea9d,0x0f07 @ teq.w sp, r7") | ||
553 | TEST_UNSUPPORTED(".short 0xea9f,0x0f07 @ teq.w pc, r7") | ||
554 | TEST_UNSUPPORTED(".short 0xf09d,0x1f08 @ tst sp, #0x00080008") | ||
555 | TEST_UNSUPPORTED(".short 0xf09f,0x1f08 @ tst pc, #0x00080008") | ||
556 | |||
557 | TEST_UNSUPPORTED(".short 0xeb17,0x0f0d @ cmn.w r7, sp") | ||
558 | TEST_UNSUPPORTED(".short 0xeb17,0x0f0f @ cmn.w r7, pc") | ||
559 | TEST_P("cmn.w sp, r",7,0,"") | ||
560 | TEST_UNSUPPORTED(".short 0xeb1f,0x0f07 @ cmn.w pc, r7") | ||
561 | TEST( "cmn sp, #0x00080008") | ||
562 | TEST_UNSUPPORTED(".short 0xf11f,0x1f08 @ cmn pc, #0x00080008") | ||
563 | |||
564 | TEST_UNSUPPORTED(".short 0xebb7,0x0f0d @ cmp.w r7, sp") | ||
565 | TEST_UNSUPPORTED(".short 0xebb7,0x0f0f @ cmp.w r7, pc") | ||
566 | TEST_P("cmp.w sp, r",7,0,"") | ||
567 | TEST_UNSUPPORTED(".short 0xebbf,0x0f07 @ cmp.w pc, r7") | ||
568 | TEST( "cmp sp, #0x00080008") | ||
569 | TEST_UNSUPPORTED(".short 0xf1bf,0x1f08 @ cmp pc, #0x00080008") | ||
570 | |||
571 | TEST_UNSUPPORTED(".short 0xea5f,0x070d @ movs.w r7, sp") | ||
572 | TEST_UNSUPPORTED(".short 0xea5f,0x070f @ movs.w r7, pc") | ||
573 | TEST_UNSUPPORTED(".short 0xea5f,0x0d07 @ movs.w sp, r7") | ||
574 | TEST_UNSUPPORTED(".short 0xea4f,0x0f07 @ mov.w pc, r7") | ||
575 | TEST_UNSUPPORTED(".short 0xf04f,0x1d08 @ mov sp, #0x00080008") | ||
576 | TEST_UNSUPPORTED(".short 0xf04f,0x1f08 @ mov pc, #0x00080008") | ||
577 | |||
578 | TEST_R("add.w r0, sp, r",1, 4,"") | ||
579 | TEST_R("adds r0, sp, r",1, 4,", asl #3") | ||
580 | TEST_R("add r0, sp, r",1, 4,", asl #4") | ||
581 | TEST_R("add r0, sp, r",1, 16,", ror #1") | ||
582 | TEST_R("add.w sp, sp, r",1, 4,"") | ||
583 | TEST_R("add sp, sp, r",1, 4,", asl #3") | ||
584 | TEST_UNSUPPORTED(".short 0xeb0d,0x1d01 @ add sp, sp, r1, asl #4") | ||
585 | TEST_UNSUPPORTED(".short 0xeb0d,0x0d71 @ add sp, sp, r1, ror #1") | ||
586 | TEST( "add.w r0, sp, #24") | ||
587 | TEST( "add.w sp, sp, #24") | ||
588 | TEST_UNSUPPORTED(".short 0xeb0d,0x0f01 @ add pc, sp, r1") | ||
589 | TEST_UNSUPPORTED(".short 0xeb0d,0x000f @ add r0, sp, pc") | ||
590 | TEST_UNSUPPORTED(".short 0xeb0d,0x000d @ add r0, sp, sp") | ||
591 | TEST_UNSUPPORTED(".short 0xeb0d,0x0d0f @ add sp, sp, pc") | ||
592 | TEST_UNSUPPORTED(".short 0xeb0d,0x0d0d @ add sp, sp, sp") | ||
593 | |||
594 | TEST_R("sub.w r0, sp, r",1, 4,"") | ||
595 | TEST_R("subs r0, sp, r",1, 4,", asl #3") | ||
596 | TEST_R("sub r0, sp, r",1, 4,", asl #4") | ||
597 | TEST_R("sub r0, sp, r",1, 16,", ror #1") | ||
598 | TEST_R("sub.w sp, sp, r",1, 4,"") | ||
599 | TEST_R("sub sp, sp, r",1, 4,", asl #3") | ||
600 | TEST_UNSUPPORTED(".short 0xebad,0x1d01 @ sub sp, sp, r1, asl #4") | ||
601 | TEST_UNSUPPORTED(".short 0xebad,0x0d71 @ sub sp, sp, r1, ror #1") | ||
602 | TEST_UNSUPPORTED(".short 0xebad,0x0f01 @ sub pc, sp, r1") | ||
603 | TEST( "sub.w r0, sp, #24") | ||
604 | TEST( "sub.w sp, sp, #24") | ||
605 | |||
606 | TEST_UNSUPPORTED(".short 0xea02,0x010f @ and r1, r2, pc") | ||
607 | TEST_UNSUPPORTED(".short 0xea0f,0x0103 @ and r1, pc, r3") | ||
608 | TEST_UNSUPPORTED(".short 0xea02,0x0f03 @ and pc, r2, r3") | ||
609 | TEST_UNSUPPORTED(".short 0xea02,0x010d @ and r1, r2, sp") | ||
610 | TEST_UNSUPPORTED(".short 0xea0d,0x0103 @ and r1, sp, r3") | ||
611 | TEST_UNSUPPORTED(".short 0xea02,0x0d03 @ and sp, r2, r3") | ||
612 | TEST_UNSUPPORTED(".short 0xf00d,0x1108 @ and r1, sp, #0x00080008") | ||
613 | TEST_UNSUPPORTED(".short 0xf00f,0x1108 @ and r1, pc, #0x00080008") | ||
614 | TEST_UNSUPPORTED(".short 0xf002,0x1d08 @ and sp, r8, #0x00080008") | ||
615 | TEST_UNSUPPORTED(".short 0xf002,0x1f08 @ and pc, r8, #0x00080008") | ||
616 | |||
617 | TEST_UNSUPPORTED(".short 0xeb02,0x010f @ add r1, r2, pc") | ||
618 | TEST_UNSUPPORTED(".short 0xeb0f,0x0103 @ add r1, pc, r3") | ||
619 | TEST_UNSUPPORTED(".short 0xeb02,0x0f03 @ add pc, r2, r3") | ||
620 | TEST_UNSUPPORTED(".short 0xeb02,0x010d @ add r1, r2, sp") | ||
621 | TEST_SUPPORTED( ".short 0xeb0d,0x0103 @ add r1, sp, r3") | ||
622 | TEST_UNSUPPORTED(".short 0xeb02,0x0d03 @ add sp, r2, r3") | ||
623 | TEST_SUPPORTED( ".short 0xf10d,0x1108 @ add r1, sp, #0x00080008") | ||
624 | TEST_UNSUPPORTED(".short 0xf10d,0x1f08 @ add pc, sp, #0x00080008") | ||
625 | TEST_UNSUPPORTED(".short 0xf10f,0x1108 @ add r1, pc, #0x00080008") | ||
626 | TEST_UNSUPPORTED(".short 0xf102,0x1d08 @ add sp, r8, #0x00080008") | ||
627 | TEST_UNSUPPORTED(".short 0xf102,0x1f08 @ add pc, r8, #0x00080008") | ||
628 | |||
629 | TEST_UNSUPPORTED(".short 0xeaa0,0x0000") | ||
630 | TEST_UNSUPPORTED(".short 0xeaf0,0x0000") | ||
631 | TEST_UNSUPPORTED(".short 0xeb20,0x0000") | ||
632 | TEST_UNSUPPORTED(".short 0xeb80,0x0000") | ||
633 | TEST_UNSUPPORTED(".short 0xebe0,0x0000") | ||
634 | |||
635 | TEST_UNSUPPORTED(".short 0xf0a0,0x0000") | ||
636 | TEST_UNSUPPORTED(".short 0xf0c0,0x0000") | ||
637 | TEST_UNSUPPORTED(".short 0xf0f0,0x0000") | ||
638 | TEST_UNSUPPORTED(".short 0xf120,0x0000") | ||
639 | TEST_UNSUPPORTED(".short 0xf180,0x0000") | ||
640 | TEST_UNSUPPORTED(".short 0xf1e0,0x0000") | ||
641 | |||
642 | TEST_GROUP("Coprocessor instructions") | ||
643 | |||
644 | TEST_UNSUPPORTED(".short 0xec00,0x0000") | ||
645 | TEST_UNSUPPORTED(".short 0xeff0,0x0000") | ||
646 | TEST_UNSUPPORTED(".short 0xfc00,0x0000") | ||
647 | TEST_UNSUPPORTED(".short 0xfff0,0x0000") | ||
648 | |||
649 | TEST_GROUP("Data-processing (plain binary immediate)") | ||
650 | |||
651 | TEST_R("addw r0, r",1, VAL1,", #0x123") | ||
652 | TEST( "addw r14, sp, #0xf5a") | ||
653 | TEST( "addw sp, sp, #0x20") | ||
654 | TEST( "addw r7, pc, #0x888") | ||
655 | TEST_UNSUPPORTED(".short 0xf20f,0x1f20 @ addw pc, pc, #0x120") | ||
656 | TEST_UNSUPPORTED(".short 0xf20d,0x1f20 @ addw pc, sp, #0x120") | ||
657 | TEST_UNSUPPORTED(".short 0xf20f,0x1d20 @ addw sp, pc, #0x120") | ||
658 | TEST_UNSUPPORTED(".short 0xf200,0x1d20 @ addw sp, r0, #0x120") | ||
659 | |||
660 | TEST_R("subw r0, r",1, VAL1,", #0x123") | ||
661 | TEST( "subw r14, sp, #0xf5a") | ||
662 | TEST( "subw sp, sp, #0x20") | ||
663 | TEST( "subw r7, pc, #0x888") | ||
664 | TEST_UNSUPPORTED(".short 0xf2af,0x1f20 @ subw pc, pc, #0x120") | ||
665 | TEST_UNSUPPORTED(".short 0xf2ad,0x1f20 @ subw pc, sp, #0x120") | ||
666 | TEST_UNSUPPORTED(".short 0xf2af,0x1d20 @ subw sp, pc, #0x120") | ||
667 | TEST_UNSUPPORTED(".short 0xf2a0,0x1d20 @ subw sp, r0, #0x120") | ||
668 | |||
669 | TEST("movw r0, #0") | ||
670 | TEST("movw r0, #0xffff") | ||
671 | TEST("movw lr, #0xffff") | ||
672 | TEST_UNSUPPORTED(".short 0xf240,0x0d00 @ movw sp, #0") | ||
673 | TEST_UNSUPPORTED(".short 0xf240,0x0f00 @ movw pc, #0") | ||
674 | |||
675 | TEST_R("movt r",0, VAL1,", #0") | ||
676 | TEST_R("movt r",0, VAL2,", #0xffff") | ||
677 | TEST_R("movt r",14,VAL1,", #0xffff") | ||
678 | TEST_UNSUPPORTED(".short 0xf2c0,0x0d00 @ movt sp, #0") | ||
679 | TEST_UNSUPPORTED(".short 0xf2c0,0x0f00 @ movt pc, #0") | ||
680 | |||
681 | TEST_R( "ssat r0, #24, r",0, VAL1,"") | ||
682 | TEST_R( "ssat r14, #24, r",12, VAL2,"") | ||
683 | TEST_R( "ssat r0, #24, r",0, VAL1,", lsl #8") | ||
684 | TEST_R( "ssat r14, #24, r",12, VAL2,", asr #8") | ||
685 | TEST_UNSUPPORTED(".short 0xf30c,0x0d17 @ ssat sp, #24, r12") | ||
686 | TEST_UNSUPPORTED(".short 0xf30c,0x0f17 @ ssat pc, #24, r12") | ||
687 | TEST_UNSUPPORTED(".short 0xf30d,0x0c17 @ ssat r12, #24, sp") | ||
688 | TEST_UNSUPPORTED(".short 0xf30f,0x0c17 @ ssat r12, #24, pc") | ||
689 | |||
690 | TEST_R( "usat r0, #24, r",0, VAL1,"") | ||
691 | TEST_R( "usat r14, #24, r",12, VAL2,"") | ||
692 | TEST_R( "usat r0, #24, r",0, VAL1,", lsl #8") | ||
693 | TEST_R( "usat r14, #24, r",12, VAL2,", asr #8") | ||
694 | TEST_UNSUPPORTED(".short 0xf38c,0x0d17 @ usat sp, #24, r12") | ||
695 | TEST_UNSUPPORTED(".short 0xf38c,0x0f17 @ usat pc, #24, r12") | ||
696 | TEST_UNSUPPORTED(".short 0xf38d,0x0c17 @ usat r12, #24, sp") | ||
697 | TEST_UNSUPPORTED(".short 0xf38f,0x0c17 @ usat r12, #24, pc") | ||
698 | |||
699 | TEST_R( "ssat16 r0, #12, r",0, HH1,"") | ||
700 | TEST_R( "ssat16 r14, #12, r",12, HH2,"") | ||
701 | TEST_UNSUPPORTED(".short 0xf32c,0x0d0b @ ssat16 sp, #12, r12") | ||
702 | TEST_UNSUPPORTED(".short 0xf32c,0x0f0b @ ssat16 pc, #12, r12") | ||
703 | TEST_UNSUPPORTED(".short 0xf32d,0x0c0b @ ssat16 r12, #12, sp") | ||
704 | TEST_UNSUPPORTED(".short 0xf32f,0x0c0b @ ssat16 r12, #12, pc") | ||
705 | |||
706 | TEST_R( "usat16 r0, #12, r",0, HH1,"") | ||
707 | TEST_R( "usat16 r14, #12, r",12, HH2,"") | ||
708 | TEST_UNSUPPORTED(".short 0xf3ac,0x0d0b @ usat16 sp, #12, r12") | ||
709 | TEST_UNSUPPORTED(".short 0xf3ac,0x0f0b @ usat16 pc, #12, r12") | ||
710 | TEST_UNSUPPORTED(".short 0xf3ad,0x0c0b @ usat16 r12, #12, sp") | ||
711 | TEST_UNSUPPORTED(".short 0xf3af,0x0c0b @ usat16 r12, #12, pc") | ||
712 | |||
713 | TEST_R( "sbfx r0, r",0 , VAL1,", #0, #31") | ||
714 | TEST_R( "sbfx r14, r",12, VAL2,", #8, #16") | ||
715 | TEST_R( "sbfx r4, r",10, VAL1,", #16, #15") | ||
716 | TEST_UNSUPPORTED(".short 0xf34c,0x2d0f @ sbfx sp, r12, #8, #16") | ||
717 | TEST_UNSUPPORTED(".short 0xf34c,0x2f0f @ sbfx pc, r12, #8, #16") | ||
718 | TEST_UNSUPPORTED(".short 0xf34d,0x2c0f @ sbfx r12, sp, #8, #16") | ||
719 | TEST_UNSUPPORTED(".short 0xf34f,0x2c0f @ sbfx r12, pc, #8, #16") | ||
720 | |||
721 | TEST_R( "ubfx r0, r",0 , VAL1,", #0, #31") | ||
722 | TEST_R( "ubfx r14, r",12, VAL2,", #8, #16") | ||
723 | TEST_R( "ubfx r4, r",10, VAL1,", #16, #15") | ||
724 | TEST_UNSUPPORTED(".short 0xf3cc,0x2d0f @ ubfx sp, r12, #8, #16") | ||
725 | TEST_UNSUPPORTED(".short 0xf3cc,0x2f0f @ ubfx pc, r12, #8, #16") | ||
726 | TEST_UNSUPPORTED(".short 0xf3cd,0x2c0f @ ubfx r12, sp, #8, #16") | ||
727 | TEST_UNSUPPORTED(".short 0xf3cf,0x2c0f @ ubfx r12, pc, #8, #16") | ||
728 | |||
729 | TEST_R( "bfc r",0, VAL1,", #4, #20") | ||
730 | TEST_R( "bfc r",14,VAL2,", #4, #20") | ||
731 | TEST_R( "bfc r",7, VAL1,", #0, #31") | ||
732 | TEST_R( "bfc r",8, VAL2,", #0, #31") | ||
733 | TEST_UNSUPPORTED(".short 0xf36f,0x0d1e @ bfc sp, #0, #31") | ||
734 | TEST_UNSUPPORTED(".short 0xf36f,0x0f1e @ bfc pc, #0, #31") | ||
735 | |||
736 | TEST_RR( "bfi r",0, VAL1,", r",0 , VAL2,", #0, #31") | ||
737 | TEST_RR( "bfi r",12,VAL1,", r",14 , VAL2,", #4, #20") | ||
738 | TEST_UNSUPPORTED(".short 0xf36e,0x1d17 @ bfi sp, r14, #4, #20") | ||
739 | TEST_UNSUPPORTED(".short 0xf36e,0x1f17 @ bfi pc, r14, #4, #20") | ||
740 | TEST_UNSUPPORTED(".short 0xf36d,0x1e17 @ bfi r14, sp, #4, #20") | ||
741 | |||
742 | TEST_GROUP("Branches and miscellaneous control") | ||
743 | |||
744 | CONDITION_INSTRUCTIONS(22, | ||
745 | TEST_BF("beq.w 2f") | ||
746 | TEST_BB("bne.w 2b") | ||
747 | TEST_BF("bgt.w 2f") | ||
748 | TEST_BB("blt.w 2b") | ||
749 | TEST_BF_X("bpl.w 2f",0x1000) | ||
750 | ) | ||
751 | |||
752 | TEST_UNSUPPORTED("msr cpsr, r0") | ||
753 | TEST_UNSUPPORTED("msr cpsr_f, r1") | ||
754 | TEST_UNSUPPORTED("msr spsr, r2") | ||
755 | |||
756 | TEST_UNSUPPORTED("cpsie.w i") | ||
757 | TEST_UNSUPPORTED("cpsid.w i") | ||
758 | TEST_UNSUPPORTED("cps 0x13") | ||
759 | |||
760 | TEST_SUPPORTED("yield.w") | ||
761 | TEST("sev.w") | ||
762 | TEST("nop.w") | ||
763 | TEST("wfi.w") | ||
764 | TEST_SUPPORTED("wfe.w") | ||
765 | TEST_UNSUPPORTED("dbg.w #0") | ||
766 | |||
767 | TEST_UNSUPPORTED("clrex") | ||
768 | TEST_UNSUPPORTED("dsb") | ||
769 | TEST_UNSUPPORTED("dmb") | ||
770 | TEST_UNSUPPORTED("isb") | ||
771 | |||
772 | TEST_UNSUPPORTED("bxj r0") | ||
773 | |||
774 | TEST_UNSUPPORTED("subs pc, lr, #4") | ||
775 | |||
776 | TEST("mrs r0, cpsr") | ||
777 | TEST("mrs r14, cpsr") | ||
778 | TEST_UNSUPPORTED(".short 0xf3ef,0x8d00 @ mrs sp, spsr") | ||
779 | TEST_UNSUPPORTED(".short 0xf3ef,0x8f00 @ mrs pc, spsr") | ||
780 | TEST_UNSUPPORTED("mrs r0, spsr") | ||
781 | TEST_UNSUPPORTED("mrs lr, spsr") | ||
782 | |||
783 | TEST_UNSUPPORTED(".short 0xf7f0,0x8000 @ smc #0") | ||
784 | |||
785 | TEST_UNSUPPORTED(".short 0xf7f0,0xa000 @ undefeined") | ||
786 | |||
787 | TEST_BF( "b.w 2f") | ||
788 | TEST_BB( "b.w 2b") | ||
789 | TEST_BF_X("b.w 2f", 0x1000) | ||
790 | |||
791 | TEST_BF( "bl.w 2f") | ||
792 | TEST_BB( "bl.w 2b") | ||
793 | TEST_BB_X("bl.w 2b", 0x1000) | ||
794 | |||
795 | TEST_X( "blx __dummy_arm_subroutine", | ||
796 | ".arm \n\t" | ||
797 | ".align \n\t" | ||
798 | ".type __dummy_arm_subroutine, %%function \n\t" | ||
799 | "__dummy_arm_subroutine: \n\t" | ||
800 | "mov r0, pc \n\t" | ||
801 | "bx lr \n\t" | ||
802 | ".thumb \n\t" | ||
803 | ) | ||
804 | TEST( "blx __dummy_arm_subroutine") | ||
805 | |||
806 | TEST_GROUP("Store single data item") | ||
807 | |||
808 | #define SINGLE_STORE(size) \ | ||
809 | TEST_RP( "str"size" r",0, VAL1,", [r",11,-1024,", #1024]") \ | ||
810 | TEST_RP( "str"size" r",14,VAL2,", [r",1, -1024,", #1080]") \ | ||
811 | TEST_RP( "str"size" r",0, VAL1,", [r",11,256, ", #-120]") \ | ||
812 | TEST_RP( "str"size" r",14,VAL2,", [r",1, 256, ", #-128]") \ | ||
813 | TEST_RP( "str"size" r",0, VAL1,", [r",11,24, "], #120") \ | ||
814 | TEST_RP( "str"size" r",14,VAL2,", [r",1, 24, "], #128") \ | ||
815 | TEST_RP( "str"size" r",0, VAL1,", [r",11,24, "], #-120") \ | ||
816 | TEST_RP( "str"size" r",14,VAL2,", [r",1, 24, "], #-128") \ | ||
817 | TEST_RP( "str"size" r",0, VAL1,", [r",11,24, ", #120]!") \ | ||
818 | TEST_RP( "str"size" r",14,VAL2,", [r",1, 24, ", #128]!") \ | ||
819 | TEST_RP( "str"size" r",0, VAL1,", [r",11,256, ", #-120]!") \ | ||
820 | TEST_RP( "str"size" r",14,VAL2,", [r",1, 256, ", #-128]!") \ | ||
821 | TEST_RPR("str"size".w r",0, VAL1,", [r",1, 0,", r",2, 4,"]") \ | ||
822 | TEST_RPR("str"size" r",14,VAL2,", [r",10,0,", r",11,4,", lsl #1]") \ | ||
823 | TEST_R( "str"size".w r",7, VAL1,", [sp, #24]") \ | ||
824 | TEST_RP( "str"size".w r",0, VAL2,", [r",0,0, "]") \ | ||
825 | TEST_UNSUPPORTED("str"size"t r0, [r1, #4]") | ||
826 | |||
827 | SINGLE_STORE("b") | ||
828 | SINGLE_STORE("h") | ||
829 | SINGLE_STORE("") | ||
830 | |||
831 | TEST("str sp, [sp]") | ||
832 | TEST_UNSUPPORTED(".short 0xf8cf,0xe000 @ str r14, [pc]") | ||
833 | TEST_UNSUPPORTED(".short 0xf8ce,0xf000 @ str pc, [r14]") | ||
834 | |||
835 | TEST_GROUP("Advanced SIMD element or structure load/store instructions") | ||
836 | |||
837 | TEST_UNSUPPORTED(".short 0xf900,0x0000") | ||
838 | TEST_UNSUPPORTED(".short 0xf92f,0xffff") | ||
839 | TEST_UNSUPPORTED(".short 0xf980,0x0000") | ||
840 | TEST_UNSUPPORTED(".short 0xf9ef,0xffff") | ||
841 | |||
842 | TEST_GROUP("Load single data item and memory hints") | ||
843 | |||
844 | #define SINGLE_LOAD(size) \ | ||
845 | TEST_P( "ldr"size" r0, [r",11,-1024, ", #1024]") \ | ||
846 | TEST_P( "ldr"size" r14, [r",1, -1024,", #1080]") \ | ||
847 | TEST_P( "ldr"size" r0, [r",11,256, ", #-120]") \ | ||
848 | TEST_P( "ldr"size" r14, [r",1, 256, ", #-128]") \ | ||
849 | TEST_P( "ldr"size" r0, [r",11,24, "], #120") \ | ||
850 | TEST_P( "ldr"size" r14, [r",1, 24, "], #128") \ | ||
851 | TEST_P( "ldr"size" r0, [r",11,24, "], #-120") \ | ||
852 | TEST_P( "ldr"size" r14, [r",1,24, "], #-128") \ | ||
853 | TEST_P( "ldr"size" r0, [r",11,24, ", #120]!") \ | ||
854 | TEST_P( "ldr"size" r14, [r",1, 24, ", #128]!") \ | ||
855 | TEST_P( "ldr"size" r0, [r",11,256, ", #-120]!") \ | ||
856 | TEST_P( "ldr"size" r14, [r",1, 256, ", #-128]!") \ | ||
857 | TEST_PR("ldr"size".w r0, [r",1, 0,", r",2, 4,"]") \ | ||
858 | TEST_PR("ldr"size" r14, [r",10,0,", r",11,4,", lsl #1]") \ | ||
859 | TEST_X( "ldr"size".w r0, 3f", \ | ||
860 | ".align 3 \n\t" \ | ||
861 | "3: .word "__stringify(VAL1)) \ | ||
862 | TEST_X( "ldr"size".w r14, 3f", \ | ||
863 | ".align 3 \n\t" \ | ||
864 | "3: .word "__stringify(VAL2)) \ | ||
865 | TEST( "ldr"size".w r7, 3b") \ | ||
866 | TEST( "ldr"size".w r7, [sp, #24]") \ | ||
867 | TEST_P( "ldr"size".w r0, [r",0,0, "]") \ | ||
868 | TEST_UNSUPPORTED("ldr"size"t r0, [r1, #4]") | ||
869 | |||
870 | SINGLE_LOAD("b") | ||
871 | SINGLE_LOAD("sb") | ||
872 | SINGLE_LOAD("h") | ||
873 | SINGLE_LOAD("sh") | ||
874 | SINGLE_LOAD("") | ||
875 | |||
876 | TEST_BF_P("ldr pc, [r",14, 15*4,"]") | ||
877 | TEST_P( "ldr sp, [r",14, 13*4,"]") | ||
878 | TEST_BF_R("ldr pc, [sp, r",14, 15*4,"]") | ||
879 | TEST_R( "ldr sp, [sp, r",14, 13*4,"]") | ||
880 | TEST_THUMB_TO_ARM_INTERWORK_P("ldr pc, [r",0,0,", #15*4]") | ||
881 | TEST_SUPPORTED("ldr sp, 99f") | ||
882 | TEST_SUPPORTED("ldr pc, 99f") | ||
883 | |||
884 | TEST_UNSUPPORTED(".short 0xf854,0x700d @ ldr r7, [r4, sp]") | ||
885 | TEST_UNSUPPORTED(".short 0xf854,0x700f @ ldr r7, [r4, pc]") | ||
886 | TEST_UNSUPPORTED(".short 0xf814,0x700d @ ldrb r7, [r4, sp]") | ||
887 | TEST_UNSUPPORTED(".short 0xf814,0x700f @ ldrb r7, [r4, pc]") | ||
888 | TEST_UNSUPPORTED(".short 0xf89f,0xd004 @ ldrb sp, 99f") | ||
889 | TEST_UNSUPPORTED(".short 0xf814,0xd008 @ ldrb sp, [r4, r8]") | ||
890 | TEST_UNSUPPORTED(".short 0xf894,0xd000 @ ldrb sp, [r4]") | ||
891 | |||
892 | TEST_UNSUPPORTED(".short 0xf860,0x0000") /* Unallocated space */ | ||
893 | TEST_UNSUPPORTED(".short 0xf9ff,0xffff") /* Unallocated space */ | ||
894 | TEST_UNSUPPORTED(".short 0xf950,0x0000") /* Unallocated space */ | ||
895 | TEST_UNSUPPORTED(".short 0xf95f,0xffff") /* Unallocated space */ | ||
896 | TEST_UNSUPPORTED(".short 0xf800,0x0800") /* Unallocated space */ | ||
897 | TEST_UNSUPPORTED(".short 0xf97f,0xfaff") /* Unallocated space */ | ||
898 | |||
899 | TEST( "pli [pc, #4]") | ||
900 | TEST( "pli [pc, #-4]") | ||
901 | TEST( "pld [pc, #4]") | ||
902 | TEST( "pld [pc, #-4]") | ||
903 | |||
904 | TEST_P( "pld [r",0,-1024,", #1024]") | ||
905 | TEST( ".short 0xf8b0,0xf400 @ pldw [r0, #1024]") | ||
906 | TEST_P( "pli [r",4, 0b,", #1024]") | ||
907 | TEST_P( "pld [r",7, 120,", #-120]") | ||
908 | TEST( ".short 0xf837,0xfc78 @ pldw [r7, #-120]") | ||
909 | TEST_P( "pli [r",11,120,", #-120]") | ||
910 | TEST( "pld [sp, #0]") | ||
911 | |||
912 | TEST_PR("pld [r",7, 24, ", r",0, 16,"]") | ||
913 | TEST_PR("pld [r",8, 24, ", r",12,16,", lsl #3]") | ||
914 | TEST_SUPPORTED(".short 0xf837,0xf000 @ pldw [r7, r0]") | ||
915 | TEST_SUPPORTED(".short 0xf838,0xf03c @ pldw [r8, r12, lsl #3]"); | ||
916 | TEST_RR("pli [r",12,0b,", r",0, 16,"]") | ||
917 | TEST_RR("pli [r",0, 0b,", r",12,16,", lsl #3]") | ||
918 | TEST_R( "pld [sp, r",1, 16,"]") | ||
919 | TEST_UNSUPPORTED(".short 0xf817,0xf00d @pld [r7, sp]") | ||
920 | TEST_UNSUPPORTED(".short 0xf817,0xf00f @pld [r7, pc]") | ||
921 | |||
922 | TEST_GROUP("Data-processing (register)") | ||
923 | |||
924 | #define SHIFTS32(op) \ | ||
925 | TEST_RR(op" r0, r",1, VAL1,", r",2, 3, "") \ | ||
926 | TEST_RR(op" r14, r",12,VAL2,", r",11,10,"") | ||
927 | |||
928 | SHIFTS32("lsl") | ||
929 | SHIFTS32("lsls") | ||
930 | SHIFTS32("lsr") | ||
931 | SHIFTS32("lsrs") | ||
932 | SHIFTS32("asr") | ||
933 | SHIFTS32("asrs") | ||
934 | SHIFTS32("ror") | ||
935 | SHIFTS32("rors") | ||
936 | |||
937 | TEST_UNSUPPORTED(".short 0xfa01,0xff02 @ lsl pc, r1, r2") | ||
938 | TEST_UNSUPPORTED(".short 0xfa01,0xfd02 @ lsl sp, r1, r2") | ||
939 | TEST_UNSUPPORTED(".short 0xfa0f,0xf002 @ lsl r0, pc, r2") | ||
940 | TEST_UNSUPPORTED(".short 0xfa0d,0xf002 @ lsl r0, sp, r2") | ||
941 | TEST_UNSUPPORTED(".short 0xfa01,0xf00f @ lsl r0, r1, pc") | ||
942 | TEST_UNSUPPORTED(".short 0xfa01,0xf00d @ lsl r0, r1, sp") | ||
943 | |||
944 | TEST_RR( "sxtah r0, r",0, HH1,", r",1, HH2,"") | ||
945 | TEST_RR( "sxtah r14,r",12, HH2,", r",10,HH1,", ror #8") | ||
946 | TEST_R( "sxth r8, r",7, HH1,"") | ||
947 | |||
948 | TEST_UNSUPPORTED(".short 0xfa0f,0xff87 @ sxth pc, r7"); | ||
949 | TEST_UNSUPPORTED(".short 0xfa0f,0xfd87 @ sxth sp, r7"); | ||
950 | TEST_UNSUPPORTED(".short 0xfa0f,0xf88f @ sxth r8, pc"); | ||
951 | TEST_UNSUPPORTED(".short 0xfa0f,0xf88d @ sxth r8, sp"); | ||
952 | |||
953 | TEST_RR( "uxtah r0, r",0, HH1,", r",1, HH2,"") | ||
954 | TEST_RR( "uxtah r14,r",12, HH2,", r",10,HH1,", ror #8") | ||
955 | TEST_R( "uxth r8, r",7, HH1,"") | ||
956 | |||
957 | TEST_RR( "sxtab16 r0, r",0, HH1,", r",1, HH2,"") | ||
958 | TEST_RR( "sxtab16 r14,r",12, HH2,", r",10,HH1,", ror #8") | ||
959 | TEST_R( "sxtb16 r8, r",7, HH1,"") | ||
960 | |||
961 | TEST_RR( "uxtab16 r0, r",0, HH1,", r",1, HH2,"") | ||
962 | TEST_RR( "uxtab16 r14,r",12, HH2,", r",10,HH1,", ror #8") | ||
963 | TEST_R( "uxtb16 r8, r",7, HH1,"") | ||
964 | |||
965 | TEST_RR( "sxtab r0, r",0, HH1,", r",1, HH2,"") | ||
966 | TEST_RR( "sxtab r14,r",12, HH2,", r",10,HH1,", ror #8") | ||
967 | TEST_R( "sxtb r8, r",7, HH1,"") | ||
968 | |||
969 | TEST_RR( "uxtab r0, r",0, HH1,", r",1, HH2,"") | ||
970 | TEST_RR( "uxtab r14,r",12, HH2,", r",10,HH1,", ror #8") | ||
971 | TEST_R( "uxtb r8, r",7, HH1,"") | ||
972 | |||
973 | TEST_UNSUPPORTED(".short 0xfa60,0x00f0") | ||
974 | TEST_UNSUPPORTED(".short 0xfa7f,0xffff") | ||
975 | |||
976 | #define PARALLEL_ADD_SUB(op) \ | ||
977 | TEST_RR( op"add16 r0, r",0, HH1,", r",1, HH2,"") \ | ||
978 | TEST_RR( op"add16 r14, r",12,HH2,", r",10,HH1,"") \ | ||
979 | TEST_RR( op"asx r0, r",0, HH1,", r",1, HH2,"") \ | ||
980 | TEST_RR( op"asx r14, r",12,HH2,", r",10,HH1,"") \ | ||
981 | TEST_RR( op"sax r0, r",0, HH1,", r",1, HH2,"") \ | ||
982 | TEST_RR( op"sax r14, r",12,HH2,", r",10,HH1,"") \ | ||
983 | TEST_RR( op"sub16 r0, r",0, HH1,", r",1, HH2,"") \ | ||
984 | TEST_RR( op"sub16 r14, r",12,HH2,", r",10,HH1,"") \ | ||
985 | TEST_RR( op"add8 r0, r",0, HH1,", r",1, HH2,"") \ | ||
986 | TEST_RR( op"add8 r14, r",12,HH2,", r",10,HH1,"") \ | ||
987 | TEST_RR( op"sub8 r0, r",0, HH1,", r",1, HH2,"") \ | ||
988 | TEST_RR( op"sub8 r14, r",12,HH2,", r",10,HH1,"") | ||
989 | |||
990 | TEST_GROUP("Parallel addition and subtraction, signed") | ||
991 | |||
992 | PARALLEL_ADD_SUB("s") | ||
993 | PARALLEL_ADD_SUB("q") | ||
994 | PARALLEL_ADD_SUB("sh") | ||
995 | |||
996 | TEST_GROUP("Parallel addition and subtraction, unsigned") | ||
997 | |||
998 | PARALLEL_ADD_SUB("u") | ||
999 | PARALLEL_ADD_SUB("uq") | ||
1000 | PARALLEL_ADD_SUB("uh") | ||
1001 | |||
1002 | TEST_GROUP("Miscellaneous operations") | ||
1003 | |||
1004 | TEST_RR("qadd r0, r",1, VAL1,", r",2, VAL2,"") | ||
1005 | TEST_RR("qadd lr, r",9, VAL2,", r",8, VAL1,"") | ||
1006 | TEST_RR("qsub r0, r",1, VAL1,", r",2, VAL2,"") | ||
1007 | TEST_RR("qsub lr, r",9, VAL2,", r",8, VAL1,"") | ||
1008 | TEST_RR("qdadd r0, r",1, VAL1,", r",2, VAL2,"") | ||
1009 | TEST_RR("qdadd lr, r",9, VAL2,", r",8, VAL1,"") | ||
1010 | TEST_RR("qdsub r0, r",1, VAL1,", r",2, VAL2,"") | ||
1011 | TEST_RR("qdsub lr, r",9, VAL2,", r",8, VAL1,"") | ||
1012 | |||
1013 | TEST_R("rev.w r0, r",0, VAL1,"") | ||
1014 | TEST_R("rev r14, r",12, VAL2,"") | ||
1015 | TEST_R("rev16.w r0, r",0, VAL1,"") | ||
1016 | TEST_R("rev16 r14, r",12, VAL2,"") | ||
1017 | TEST_R("rbit r0, r",0, VAL1,"") | ||
1018 | TEST_R("rbit r14, r",12, VAL2,"") | ||
1019 | TEST_R("revsh.w r0, r",0, VAL1,"") | ||
1020 | TEST_R("revsh r14, r",12, VAL2,"") | ||
1021 | |||
1022 | TEST_UNSUPPORTED(".short 0xfa9c,0xff8c @ rev pc, r12"); | ||
1023 | TEST_UNSUPPORTED(".short 0xfa9c,0xfd8c @ rev sp, r12"); | ||
1024 | TEST_UNSUPPORTED(".short 0xfa9f,0xfe8f @ rev r14, pc"); | ||
1025 | TEST_UNSUPPORTED(".short 0xfa9d,0xfe8d @ rev r14, sp"); | ||
1026 | |||
1027 | TEST_RR("sel r0, r",0, VAL1,", r",1, VAL2,"") | ||
1028 | TEST_RR("sel r14, r",12,VAL1,", r",10, VAL2,"") | ||
1029 | |||
1030 | TEST_R("clz r0, r",0, 0x0,"") | ||
1031 | TEST_R("clz r7, r",14,0x1,"") | ||
1032 | TEST_R("clz lr, r",7, 0xffffffff,"") | ||
1033 | |||
1034 | TEST_UNSUPPORTED(".short 0xfa80,0xf030") /* Unallocated space */ | ||
1035 | TEST_UNSUPPORTED(".short 0xfaff,0xff7f") /* Unallocated space */ | ||
1036 | TEST_UNSUPPORTED(".short 0xfab0,0xf000") /* Unallocated space */ | ||
1037 | TEST_UNSUPPORTED(".short 0xfaff,0xff7f") /* Unallocated space */ | ||
1038 | |||
1039 | TEST_GROUP("Multiply, multiply accumulate, and absolute difference operations") | ||
1040 | |||
1041 | TEST_RR( "mul r0, r",1, VAL1,", r",2, VAL2,"") | ||
1042 | TEST_RR( "mul r7, r",8, VAL2,", r",9, VAL2,"") | ||
1043 | TEST_UNSUPPORTED(".short 0xfb08,0xff09 @ mul pc, r8, r9") | ||
1044 | TEST_UNSUPPORTED(".short 0xfb08,0xfd09 @ mul sp, r8, r9") | ||
1045 | TEST_UNSUPPORTED(".short 0xfb0f,0xf709 @ mul r7, pc, r9") | ||
1046 | TEST_UNSUPPORTED(".short 0xfb0d,0xf709 @ mul r7, sp, r9") | ||
1047 | TEST_UNSUPPORTED(".short 0xfb08,0xf70f @ mul r7, r8, pc") | ||
1048 | TEST_UNSUPPORTED(".short 0xfb08,0xf70d @ mul r7, r8, sp") | ||
1049 | |||
1050 | TEST_RRR( "mla r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
1051 | TEST_RRR( "mla r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
1052 | TEST_UNSUPPORTED(".short 0xfb08,0xaf09 @ mla pc, r8, r9, r10"); | ||
1053 | TEST_UNSUPPORTED(".short 0xfb08,0xad09 @ mla sp, r8, r9, r10"); | ||
1054 | TEST_UNSUPPORTED(".short 0xfb0f,0xa709 @ mla r7, pc, r9, r10"); | ||
1055 | TEST_UNSUPPORTED(".short 0xfb0d,0xa709 @ mla r7, sp, r9, r10"); | ||
1056 | TEST_UNSUPPORTED(".short 0xfb08,0xa70f @ mla r7, r8, pc, r10"); | ||
1057 | TEST_UNSUPPORTED(".short 0xfb08,0xa70d @ mla r7, r8, sp, r10"); | ||
1058 | TEST_UNSUPPORTED(".short 0xfb08,0xd709 @ mla r7, r8, r9, sp"); | ||
1059 | |||
1060 | TEST_RRR( "mls r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
1061 | TEST_RRR( "mls r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
1062 | |||
1063 | TEST_RRR( "smlabb r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
1064 | TEST_RRR( "smlabb r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
1065 | TEST_RRR( "smlatb r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
1066 | TEST_RRR( "smlatb r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
1067 | TEST_RRR( "smlabt r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
1068 | TEST_RRR( "smlabt r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
1069 | TEST_RRR( "smlatt r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
1070 | TEST_RRR( "smlatt r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
1071 | TEST_RR( "smulbb r0, r",1, VAL1,", r",2, VAL2,"") | ||
1072 | TEST_RR( "smulbb r7, r",8, VAL3,", r",9, VAL1,"") | ||
1073 | TEST_RR( "smultb r0, r",1, VAL1,", r",2, VAL2,"") | ||
1074 | TEST_RR( "smultb r7, r",8, VAL3,", r",9, VAL1,"") | ||
1075 | TEST_RR( "smulbt r0, r",1, VAL1,", r",2, VAL2,"") | ||
1076 | TEST_RR( "smulbt r7, r",8, VAL3,", r",9, VAL1,"") | ||
1077 | TEST_RR( "smultt r0, r",1, VAL1,", r",2, VAL2,"") | ||
1078 | TEST_RR( "smultt r7, r",8, VAL3,", r",9, VAL1,"") | ||
1079 | |||
1080 | TEST_RRR( "smlad r0, r",0, HH1,", r",1, HH2,", r",2, VAL1,"") | ||
1081 | TEST_RRR( "smlad r14, r",12,HH2,", r",10,HH1,", r",8, VAL2,"") | ||
1082 | TEST_RRR( "smladx r0, r",0, HH1,", r",1, HH2,", r",2, VAL1,"") | ||
1083 | TEST_RRR( "smladx r14, r",12,HH2,", r",10,HH1,", r",8, VAL2,"") | ||
1084 | TEST_RR( "smuad r0, r",0, HH1,", r",1, HH2,"") | ||
1085 | TEST_RR( "smuad r14, r",12,HH2,", r",10,HH1,"") | ||
1086 | TEST_RR( "smuadx r0, r",0, HH1,", r",1, HH2,"") | ||
1087 | TEST_RR( "smuadx r14, r",12,HH2,", r",10,HH1,"") | ||
1088 | |||
1089 | TEST_RRR( "smlawb r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
1090 | TEST_RRR( "smlawb r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
1091 | TEST_RRR( "smlawt r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") | ||
1092 | TEST_RRR( "smlawt r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") | ||
1093 | TEST_RR( "smulwb r0, r",1, VAL1,", r",2, VAL2,"") | ||
1094 | TEST_RR( "smulwb r7, r",8, VAL3,", r",9, VAL1,"") | ||
1095 | TEST_RR( "smulwt r0, r",1, VAL1,", r",2, VAL2,"") | ||
1096 | TEST_RR( "smulwt r7, r",8, VAL3,", r",9, VAL1,"") | ||
1097 | |||
1098 | TEST_RRR( "smlsd r0, r",0, HH1,", r",1, HH2,", r",2, VAL1,"") | ||
1099 | TEST_RRR( "smlsd r14, r",12,HH2,", r",10,HH1,", r",8, VAL2,"") | ||
1100 | TEST_RRR( "smlsdx r0, r",0, HH1,", r",1, HH2,", r",2, VAL1,"") | ||
1101 | TEST_RRR( "smlsdx r14, r",12,HH2,", r",10,HH1,", r",8, VAL2,"") | ||
1102 | TEST_RR( "smusd r0, r",0, HH1,", r",1, HH2,"") | ||
1103 | TEST_RR( "smusd r14, r",12,HH2,", r",10,HH1,"") | ||
1104 | TEST_RR( "smusdx r0, r",0, HH1,", r",1, HH2,"") | ||
1105 | TEST_RR( "smusdx r14, r",12,HH2,", r",10,HH1,"") | ||
1106 | |||
1107 | TEST_RRR( "smmla r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL1,"") | ||
1108 | TEST_RRR( "smmla r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL2,"") | ||
1109 | TEST_RRR( "smmlar r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL1,"") | ||
1110 | TEST_RRR( "smmlar r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL2,"") | ||
1111 | TEST_RR( "smmul r0, r",0, VAL1,", r",1, VAL2,"") | ||
1112 | TEST_RR( "smmul r14, r",12,VAL2,", r",10,VAL1,"") | ||
1113 | TEST_RR( "smmulr r0, r",0, VAL1,", r",1, VAL2,"") | ||
1114 | TEST_RR( "smmulr r14, r",12,VAL2,", r",10,VAL1,"") | ||
1115 | |||
1116 | TEST_RRR( "smmls r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL1,"") | ||
1117 | TEST_RRR( "smmls r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL2,"") | ||
1118 | TEST_RRR( "smmlsr r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL1,"") | ||
1119 | TEST_RRR( "smmlsr r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL2,"") | ||
1120 | |||
1121 | TEST_RRR( "usada8 r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL3,"") | ||
1122 | TEST_RRR( "usada8 r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL3,"") | ||
1123 | TEST_RR( "usad8 r0, r",0, VAL1,", r",1, VAL2,"") | ||
1124 | TEST_RR( "usad8 r14, r",12,VAL2,", r",10,VAL1,"") | ||
1125 | |||
1126 | TEST_UNSUPPORTED(".short 0xfb00,0xf010") /* Unallocated space */ | ||
1127 | TEST_UNSUPPORTED(".short 0xfb0f,0xff1f") /* Unallocated space */ | ||
1128 | TEST_UNSUPPORTED(".short 0xfb70,0xf010") /* Unallocated space */ | ||
1129 | TEST_UNSUPPORTED(".short 0xfb7f,0xff1f") /* Unallocated space */ | ||
1130 | TEST_UNSUPPORTED(".short 0xfb70,0x0010") /* Unallocated space */ | ||
1131 | TEST_UNSUPPORTED(".short 0xfb7f,0xff1f") /* Unallocated space */ | ||
1132 | |||
1133 | TEST_GROUP("Long multiply, long multiply accumulate, and divide") | ||
1134 | |||
1135 | TEST_RR( "smull r0, r1, r",2, VAL1,", r",3, VAL2,"") | ||
1136 | TEST_RR( "smull r7, r8, r",9, VAL2,", r",10, VAL1,"") | ||
1137 | TEST_UNSUPPORTED(".short 0xfb89,0xf80a @ smull pc, r8, r9, r10"); | ||
1138 | TEST_UNSUPPORTED(".short 0xfb89,0xd80a @ smull sp, r8, r9, r10"); | ||
1139 | TEST_UNSUPPORTED(".short 0xfb89,0x7f0a @ smull r7, pc, r9, r10"); | ||
1140 | TEST_UNSUPPORTED(".short 0xfb89,0x7d0a @ smull r7, sp, r9, r10"); | ||
1141 | TEST_UNSUPPORTED(".short 0xfb8f,0x780a @ smull r7, r8, pc, r10"); | ||
1142 | TEST_UNSUPPORTED(".short 0xfb8d,0x780a @ smull r7, r8, sp, r10"); | ||
1143 | TEST_UNSUPPORTED(".short 0xfb89,0x780f @ smull r7, r8, r9, pc"); | ||
1144 | TEST_UNSUPPORTED(".short 0xfb89,0x780d @ smull r7, r8, r9, sp"); | ||
1145 | |||
1146 | TEST_RR( "umull r0, r1, r",2, VAL1,", r",3, VAL2,"") | ||
1147 | TEST_RR( "umull r7, r8, r",9, VAL2,", r",10, VAL1,"") | ||
1148 | |||
1149 | TEST_RRRR( "smlal r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) | ||
1150 | TEST_RRRR( "smlal r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) | ||
1151 | |||
1152 | TEST_RRRR( "smlalbb r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) | ||
1153 | TEST_RRRR( "smlalbb r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) | ||
1154 | TEST_RRRR( "smlalbt r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) | ||
1155 | TEST_RRRR( "smlalbt r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) | ||
1156 | TEST_RRRR( "smlaltb r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) | ||
1157 | TEST_RRRR( "smlaltb r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) | ||
1158 | TEST_RRRR( "smlaltt r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) | ||
1159 | TEST_RRRR( "smlaltt r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) | ||
1160 | |||
1161 | TEST_RRRR( "smlald r",0, VAL1,", r",1, VAL2, ", r",0, HH1,", r",1, HH2) | ||
1162 | TEST_RRRR( "smlald r",11,VAL2,", r",10,VAL1, ", r",9, HH2,", r",8, HH1) | ||
1163 | TEST_RRRR( "smlaldx r",0, VAL1,", r",1, VAL2, ", r",0, HH1,", r",1, HH2) | ||
1164 | TEST_RRRR( "smlaldx r",11,VAL2,", r",10,VAL1, ", r",9, HH2,", r",8, HH1) | ||
1165 | |||
1166 | TEST_RRRR( "smlsld r",0, VAL1,", r",1, VAL2, ", r",0, HH1,", r",1, HH2) | ||
1167 | TEST_RRRR( "smlsld r",11,VAL2,", r",10,VAL1, ", r",9, HH2,", r",8, HH1) | ||
1168 | TEST_RRRR( "smlsldx r",0, VAL1,", r",1, VAL2, ", r",0, HH1,", r",1, HH2) | ||
1169 | TEST_RRRR( "smlsldx r",11,VAL2,", r",10,VAL1, ", r",9, HH2,", r",8, HH1) | ||
1170 | |||
1171 | TEST_RRRR( "umlal r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) | ||
1172 | TEST_RRRR( "umlal r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) | ||
1173 | TEST_RRRR( "umaal r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) | ||
1174 | TEST_RRRR( "umaal r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) | ||
1175 | |||
1176 | TEST_GROUP("Coprocessor instructions") | ||
1177 | |||
1178 | TEST_UNSUPPORTED(".short 0xfc00,0x0000") | ||
1179 | TEST_UNSUPPORTED(".short 0xffff,0xffff") | ||
1180 | |||
1181 | TEST_GROUP("Testing instructions in IT blocks") | ||
1182 | |||
1183 | TEST_ITBLOCK("sub.w r0, r0") | ||
1184 | |||
1185 | verbose("\n"); | ||
1186 | } | ||
1187 | |||
diff --git a/arch/arm/kernel/kprobes-test.c b/arch/arm/kernel/kprobes-test.c new file mode 100644 index 000000000000..e17cdd6d90d8 --- /dev/null +++ b/arch/arm/kernel/kprobes-test.c | |||
@@ -0,0 +1,1748 @@ | |||
1 | /* | ||
2 | * arch/arm/kernel/kprobes-test.c | ||
3 | * | ||
4 | * Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | /* | ||
12 | * This file contains test code for ARM kprobes. | ||
13 | * | ||
14 | * The top level function run_all_tests() executes tests for all of the | ||
15 | * supported instruction sets: ARM, 16-bit Thumb, and 32-bit Thumb. These tests | ||
16 | * fall into two categories; run_api_tests() checks basic functionality of the | ||
17 | * kprobes API, and run_test_cases() is a comprehensive test for kprobes | ||
18 | * instruction decoding and simulation. | ||
19 | * | ||
20 | * run_test_cases() first checks the kprobes decoding table for self consistency | ||
21 | * (using table_test()) then executes a series of test cases for each of the CPU | ||
22 | * instruction forms. coverage_start() and coverage_end() are used to verify | ||
23 | * that these test cases cover all of the possible combinations of instructions | ||
24 | * described by the kprobes decoding tables. | ||
25 | * | ||
26 | * The individual test cases are in kprobes-test-arm.c and kprobes-test-thumb.c | ||
27 | * which use the macros defined in kprobes-test.h. The rest of this | ||
28 | * documentation will describe the operation of the framework used by these | ||
29 | * test cases. | ||
30 | */ | ||
31 | |||
32 | /* | ||
33 | * TESTING METHODOLOGY | ||
34 | * ------------------- | ||
35 | * | ||
36 | * The methodology used to test an ARM instruction 'test_insn' is to use | ||
37 | * inline assembler like: | ||
38 | * | ||
39 | * test_before: nop | ||
40 | * test_case: test_insn | ||
41 | * test_after: nop | ||
42 | * | ||
43 | * When the test case is run a kprobe is placed of each nop. The | ||
44 | * post-handler of the test_before probe is used to modify the saved CPU | ||
45 | * register context to that which we require for the test case. The | ||
46 | * pre-handler of the of the test_after probe saves a copy of the CPU | ||
47 | * register context. In this way we can execute test_insn with a specific | ||
48 | * register context and see the results afterwards. | ||
49 | * | ||
50 | * To actually test the kprobes instruction emulation we perform the above | ||
51 | * step a second time but with an additional kprobe on the test_case | ||
52 | * instruction itself. If the emulation is accurate then the results seen | ||
53 | * by the test_after probe will be identical to the first run which didn't | ||
54 | * have a probe on test_case. | ||
55 | * | ||
56 | * Each test case is run several times with a variety of variations in the | ||
57 | * flags value of stored in CPSR, and for Thumb code, different ITState. | ||
58 | * | ||
59 | * For instructions which can modify PC, a second test_after probe is used | ||
60 | * like this: | ||
61 | * | ||
62 | * test_before: nop | ||
63 | * test_case: test_insn | ||
64 | * test_after: nop | ||
65 | * b test_done | ||
66 | * test_after2: nop | ||
67 | * test_done: | ||
68 | * | ||
69 | * The test case is constructed such that test_insn branches to | ||
70 | * test_after2, or, if testing a conditional instruction, it may just | ||
71 | * continue to test_after. The probes inserted at both locations let us | ||
72 | * determine which happened. A similar approach is used for testing | ||
73 | * backwards branches... | ||
74 | * | ||
75 | * b test_before | ||
76 | * b test_done @ helps to cope with off by 1 branches | ||
77 | * test_after2: nop | ||
78 | * b test_done | ||
79 | * test_before: nop | ||
80 | * test_case: test_insn | ||
81 | * test_after: nop | ||
82 | * test_done: | ||
83 | * | ||
84 | * The macros used to generate the assembler instructions describe above | ||
85 | * are TEST_INSTRUCTION, TEST_BRANCH_F (branch forwards) and TEST_BRANCH_B | ||
86 | * (branch backwards). In these, the local variables numbered 1, 50, 2 and | ||
87 | * 99 represent: test_before, test_case, test_after2 and test_done. | ||
88 | * | ||
89 | * FRAMEWORK | ||
90 | * --------- | ||
91 | * | ||
92 | * Each test case is wrapped between the pair of macros TESTCASE_START and | ||
93 | * TESTCASE_END. As well as performing the inline assembler boilerplate, | ||
94 | * these call out to the kprobes_test_case_start() and | ||
95 | * kprobes_test_case_end() functions which drive the execution of the test | ||
96 | * case. The specific arguments to use for each test case are stored as | ||
97 | * inline data constructed using the various TEST_ARG_* macros. Putting | ||
98 | * this all together, a simple test case may look like: | ||
99 | * | ||
100 | * TESTCASE_START("Testing mov r0, r7") | ||
101 | * TEST_ARG_REG(7, 0x12345678) // Set r7=0x12345678 | ||
102 | * TEST_ARG_END("") | ||
103 | * TEST_INSTRUCTION("mov r0, r7") | ||
104 | * TESTCASE_END | ||
105 | * | ||
106 | * Note, in practice the single convenience macro TEST_R would be used for this | ||
107 | * instead. | ||
108 | * | ||
109 | * The above would expand to assembler looking something like: | ||
110 | * | ||
111 | * @ TESTCASE_START | ||
112 | * bl __kprobes_test_case_start | ||
113 | * @ start of inline data... | ||
114 | * .ascii "mov r0, r7" @ text title for test case | ||
115 | * .byte 0 | ||
116 | * .align 2 | ||
117 | * | ||
118 | * @ TEST_ARG_REG | ||
119 | * .byte ARG_TYPE_REG | ||
120 | * .byte 7 | ||
121 | * .short 0 | ||
122 | * .word 0x1234567 | ||
123 | * | ||
124 | * @ TEST_ARG_END | ||
125 | * .byte ARG_TYPE_END | ||
126 | * .byte TEST_ISA @ flags, including ISA being tested | ||
127 | * .short 50f-0f @ offset of 'test_before' | ||
128 | * .short 2f-0f @ offset of 'test_after2' (if relevent) | ||
129 | * .short 99f-0f @ offset of 'test_done' | ||
130 | * @ start of test case code... | ||
131 | * 0: | ||
132 | * .code TEST_ISA @ switch to ISA being tested | ||
133 | * | ||
134 | * @ TEST_INSTRUCTION | ||
135 | * 50: nop @ location for 'test_before' probe | ||
136 | * 1: mov r0, r7 @ the test case instruction 'test_insn' | ||
137 | * nop @ location for 'test_after' probe | ||
138 | * | ||
139 | * // TESTCASE_END | ||
140 | * 2: | ||
141 | * 99: bl __kprobes_test_case_end_##TEST_ISA | ||
142 | * .code NONMAL_ISA | ||
143 | * | ||
144 | * When the above is execute the following happens... | ||
145 | * | ||
146 | * __kprobes_test_case_start() is an assembler wrapper which sets up space | ||
147 | * for a stack buffer and calls the C function kprobes_test_case_start(). | ||
148 | * This C function will do some initial processing of the inline data and | ||
149 | * setup some global state. It then inserts the test_before and test_after | ||
150 | * kprobes and returns a value which causes the assembler wrapper to jump | ||
151 | * to the start of the test case code, (local label '0'). | ||
152 | * | ||
153 | * When the test case code executes, the test_before probe will be hit and | ||
154 | * test_before_post_handler will call setup_test_context(). This fills the | ||
155 | * stack buffer and CPU registers with a test pattern and then processes | ||
156 | * the test case arguments. In our example there is one TEST_ARG_REG which | ||
157 | * indicates that R7 should be loaded with the value 0x12345678. | ||
158 | * | ||
159 | * When the test_before probe ends, the test case continues and executes | ||
160 | * the "mov r0, r7" instruction. It then hits the test_after probe and the | ||
161 | * pre-handler for this (test_after_pre_handler) will save a copy of the | ||
162 | * CPU register context. This should now have R0 holding the same value as | ||
163 | * R7. | ||
164 | * | ||
165 | * Finally we get to the call to __kprobes_test_case_end_{32,16}. This is | ||
166 | * an assembler wrapper which switches back to the ISA used by the test | ||
167 | * code and calls the C function kprobes_test_case_end(). | ||
168 | * | ||
169 | * For each run through the test case, test_case_run_count is incremented | ||
170 | * by one. For even runs, kprobes_test_case_end() saves a copy of the | ||
171 | * register and stack buffer contents from the test case just run. It then | ||
172 | * inserts a kprobe on the test case instruction 'test_insn' and returns a | ||
173 | * value to cause the test case code to be re-run. | ||
174 | * | ||
175 | * For odd numbered runs, kprobes_test_case_end() compares the register and | ||
176 | * stack buffer contents to those that were saved on the previous even | ||
177 | * numbered run (the one without the kprobe on test_insn). These should be | ||
178 | * the same if the kprobe instruction simulation routine is correct. | ||
179 | * | ||
180 | * The pair of test case runs is repeated with different combinations of | ||
181 | * flag values in CPSR and, for Thumb, different ITState. This is | ||
182 | * controlled by test_context_cpsr(). | ||
183 | * | ||
184 | * BUILDING TEST CASES | ||
185 | * ------------------- | ||
186 | * | ||
187 | * | ||
188 | * As an aid to building test cases, the stack buffer is initialised with | ||
189 | * some special values: | ||
190 | * | ||
191 | * [SP+13*4] Contains SP+120. This can be used to test instructions | ||
192 | * which load a value into SP. | ||
193 | * | ||
194 | * [SP+15*4] When testing branching instructions using TEST_BRANCH_{F,B}, | ||
195 | * this holds the target address of the branch, 'test_after2'. | ||
196 | * This can be used to test instructions which load a PC value | ||
197 | * from memory. | ||
198 | */ | ||
199 | |||
200 | #include <linux/kernel.h> | ||
201 | #include <linux/module.h> | ||
202 | #include <linux/slab.h> | ||
203 | #include <linux/kprobes.h> | ||
204 | |||
205 | #include "kprobes.h" | ||
206 | #include "kprobes-test.h" | ||
207 | |||
208 | |||
209 | #define BENCHMARKING 1 | ||
210 | |||
211 | |||
212 | /* | ||
213 | * Test basic API | ||
214 | */ | ||
215 | |||
216 | static bool test_regs_ok; | ||
217 | static int test_func_instance; | ||
218 | static int pre_handler_called; | ||
219 | static int post_handler_called; | ||
220 | static int jprobe_func_called; | ||
221 | static int kretprobe_handler_called; | ||
222 | |||
223 | #define FUNC_ARG1 0x12345678 | ||
224 | #define FUNC_ARG2 0xabcdef | ||
225 | |||
226 | |||
227 | #ifndef CONFIG_THUMB2_KERNEL | ||
228 | |||
229 | long arm_func(long r0, long r1); | ||
230 | |||
231 | static void __used __naked __arm_kprobes_test_func(void) | ||
232 | { | ||
233 | __asm__ __volatile__ ( | ||
234 | ".arm \n\t" | ||
235 | ".type arm_func, %%function \n\t" | ||
236 | "arm_func: \n\t" | ||
237 | "adds r0, r0, r1 \n\t" | ||
238 | "bx lr \n\t" | ||
239 | ".code "NORMAL_ISA /* Back to Thumb if necessary */ | ||
240 | : : : "r0", "r1", "cc" | ||
241 | ); | ||
242 | } | ||
243 | |||
244 | #else /* CONFIG_THUMB2_KERNEL */ | ||
245 | |||
246 | long thumb16_func(long r0, long r1); | ||
247 | long thumb32even_func(long r0, long r1); | ||
248 | long thumb32odd_func(long r0, long r1); | ||
249 | |||
250 | static void __used __naked __thumb_kprobes_test_funcs(void) | ||
251 | { | ||
252 | __asm__ __volatile__ ( | ||
253 | ".type thumb16_func, %%function \n\t" | ||
254 | "thumb16_func: \n\t" | ||
255 | "adds.n r0, r0, r1 \n\t" | ||
256 | "bx lr \n\t" | ||
257 | |||
258 | ".align \n\t" | ||
259 | ".type thumb32even_func, %%function \n\t" | ||
260 | "thumb32even_func: \n\t" | ||
261 | "adds.w r0, r0, r1 \n\t" | ||
262 | "bx lr \n\t" | ||
263 | |||
264 | ".align \n\t" | ||
265 | "nop.n \n\t" | ||
266 | ".type thumb32odd_func, %%function \n\t" | ||
267 | "thumb32odd_func: \n\t" | ||
268 | "adds.w r0, r0, r1 \n\t" | ||
269 | "bx lr \n\t" | ||
270 | |||
271 | : : : "r0", "r1", "cc" | ||
272 | ); | ||
273 | } | ||
274 | |||
275 | #endif /* CONFIG_THUMB2_KERNEL */ | ||
276 | |||
277 | |||
278 | static int call_test_func(long (*func)(long, long), bool check_test_regs) | ||
279 | { | ||
280 | long ret; | ||
281 | |||
282 | ++test_func_instance; | ||
283 | test_regs_ok = false; | ||
284 | |||
285 | ret = (*func)(FUNC_ARG1, FUNC_ARG2); | ||
286 | if (ret != FUNC_ARG1 + FUNC_ARG2) { | ||
287 | pr_err("FAIL: call_test_func: func returned %lx\n", ret); | ||
288 | return false; | ||
289 | } | ||
290 | |||
291 | if (check_test_regs && !test_regs_ok) { | ||
292 | pr_err("FAIL: test regs not OK\n"); | ||
293 | return false; | ||
294 | } | ||
295 | |||
296 | return true; | ||
297 | } | ||
298 | |||
299 | static int __kprobes pre_handler(struct kprobe *p, struct pt_regs *regs) | ||
300 | { | ||
301 | pre_handler_called = test_func_instance; | ||
302 | if (regs->ARM_r0 == FUNC_ARG1 && regs->ARM_r1 == FUNC_ARG2) | ||
303 | test_regs_ok = true; | ||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | static void __kprobes post_handler(struct kprobe *p, struct pt_regs *regs, | ||
308 | unsigned long flags) | ||
309 | { | ||
310 | post_handler_called = test_func_instance; | ||
311 | if (regs->ARM_r0 != FUNC_ARG1 + FUNC_ARG2 || regs->ARM_r1 != FUNC_ARG2) | ||
312 | test_regs_ok = false; | ||
313 | } | ||
314 | |||
315 | static struct kprobe the_kprobe = { | ||
316 | .addr = 0, | ||
317 | .pre_handler = pre_handler, | ||
318 | .post_handler = post_handler | ||
319 | }; | ||
320 | |||
321 | static int test_kprobe(long (*func)(long, long)) | ||
322 | { | ||
323 | int ret; | ||
324 | |||
325 | the_kprobe.addr = (kprobe_opcode_t *)func; | ||
326 | ret = register_kprobe(&the_kprobe); | ||
327 | if (ret < 0) { | ||
328 | pr_err("FAIL: register_kprobe failed with %d\n", ret); | ||
329 | return ret; | ||
330 | } | ||
331 | |||
332 | ret = call_test_func(func, true); | ||
333 | |||
334 | unregister_kprobe(&the_kprobe); | ||
335 | the_kprobe.flags = 0; /* Clear disable flag to allow reuse */ | ||
336 | |||
337 | if (!ret) | ||
338 | return -EINVAL; | ||
339 | if (pre_handler_called != test_func_instance) { | ||
340 | pr_err("FAIL: kprobe pre_handler not called\n"); | ||
341 | return -EINVAL; | ||
342 | } | ||
343 | if (post_handler_called != test_func_instance) { | ||
344 | pr_err("FAIL: kprobe post_handler not called\n"); | ||
345 | return -EINVAL; | ||
346 | } | ||
347 | if (!call_test_func(func, false)) | ||
348 | return -EINVAL; | ||
349 | if (pre_handler_called == test_func_instance || | ||
350 | post_handler_called == test_func_instance) { | ||
351 | pr_err("FAIL: probe called after unregistering\n"); | ||
352 | return -EINVAL; | ||
353 | } | ||
354 | |||
355 | return 0; | ||
356 | } | ||
357 | |||
358 | static void __kprobes jprobe_func(long r0, long r1) | ||
359 | { | ||
360 | jprobe_func_called = test_func_instance; | ||
361 | if (r0 == FUNC_ARG1 && r1 == FUNC_ARG2) | ||
362 | test_regs_ok = true; | ||
363 | jprobe_return(); | ||
364 | } | ||
365 | |||
366 | static struct jprobe the_jprobe = { | ||
367 | .entry = jprobe_func, | ||
368 | }; | ||
369 | |||
370 | static int test_jprobe(long (*func)(long, long)) | ||
371 | { | ||
372 | int ret; | ||
373 | |||
374 | the_jprobe.kp.addr = (kprobe_opcode_t *)func; | ||
375 | ret = register_jprobe(&the_jprobe); | ||
376 | if (ret < 0) { | ||
377 | pr_err("FAIL: register_jprobe failed with %d\n", ret); | ||
378 | return ret; | ||
379 | } | ||
380 | |||
381 | ret = call_test_func(func, true); | ||
382 | |||
383 | unregister_jprobe(&the_jprobe); | ||
384 | the_jprobe.kp.flags = 0; /* Clear disable flag to allow reuse */ | ||
385 | |||
386 | if (!ret) | ||
387 | return -EINVAL; | ||
388 | if (jprobe_func_called != test_func_instance) { | ||
389 | pr_err("FAIL: jprobe handler function not called\n"); | ||
390 | return -EINVAL; | ||
391 | } | ||
392 | if (!call_test_func(func, false)) | ||
393 | return -EINVAL; | ||
394 | if (jprobe_func_called == test_func_instance) { | ||
395 | pr_err("FAIL: probe called after unregistering\n"); | ||
396 | return -EINVAL; | ||
397 | } | ||
398 | |||
399 | return 0; | ||
400 | } | ||
401 | |||
402 | static int __kprobes | ||
403 | kretprobe_handler(struct kretprobe_instance *ri, struct pt_regs *regs) | ||
404 | { | ||
405 | kretprobe_handler_called = test_func_instance; | ||
406 | if (regs_return_value(regs) == FUNC_ARG1 + FUNC_ARG2) | ||
407 | test_regs_ok = true; | ||
408 | return 0; | ||
409 | } | ||
410 | |||
411 | static struct kretprobe the_kretprobe = { | ||
412 | .handler = kretprobe_handler, | ||
413 | }; | ||
414 | |||
415 | static int test_kretprobe(long (*func)(long, long)) | ||
416 | { | ||
417 | int ret; | ||
418 | |||
419 | the_kretprobe.kp.addr = (kprobe_opcode_t *)func; | ||
420 | ret = register_kretprobe(&the_kretprobe); | ||
421 | if (ret < 0) { | ||
422 | pr_err("FAIL: register_kretprobe failed with %d\n", ret); | ||
423 | return ret; | ||
424 | } | ||
425 | |||
426 | ret = call_test_func(func, true); | ||
427 | |||
428 | unregister_kretprobe(&the_kretprobe); | ||
429 | the_kretprobe.kp.flags = 0; /* Clear disable flag to allow reuse */ | ||
430 | |||
431 | if (!ret) | ||
432 | return -EINVAL; | ||
433 | if (kretprobe_handler_called != test_func_instance) { | ||
434 | pr_err("FAIL: kretprobe handler not called\n"); | ||
435 | return -EINVAL; | ||
436 | } | ||
437 | if (!call_test_func(func, false)) | ||
438 | return -EINVAL; | ||
439 | if (jprobe_func_called == test_func_instance) { | ||
440 | pr_err("FAIL: kretprobe called after unregistering\n"); | ||
441 | return -EINVAL; | ||
442 | } | ||
443 | |||
444 | return 0; | ||
445 | } | ||
446 | |||
447 | static int run_api_tests(long (*func)(long, long)) | ||
448 | { | ||
449 | int ret; | ||
450 | |||
451 | pr_info(" kprobe\n"); | ||
452 | ret = test_kprobe(func); | ||
453 | if (ret < 0) | ||
454 | return ret; | ||
455 | |||
456 | pr_info(" jprobe\n"); | ||
457 | ret = test_jprobe(func); | ||
458 | if (ret < 0) | ||
459 | return ret; | ||
460 | |||
461 | pr_info(" kretprobe\n"); | ||
462 | ret = test_kretprobe(func); | ||
463 | if (ret < 0) | ||
464 | return ret; | ||
465 | |||
466 | return 0; | ||
467 | } | ||
468 | |||
469 | |||
470 | /* | ||
471 | * Benchmarking | ||
472 | */ | ||
473 | |||
474 | #if BENCHMARKING | ||
475 | |||
476 | static void __naked benchmark_nop(void) | ||
477 | { | ||
478 | __asm__ __volatile__ ( | ||
479 | "nop \n\t" | ||
480 | "bx lr" | ||
481 | ); | ||
482 | } | ||
483 | |||
484 | #ifdef CONFIG_THUMB2_KERNEL | ||
485 | #define wide ".w" | ||
486 | #else | ||
487 | #define wide | ||
488 | #endif | ||
489 | |||
490 | static void __naked benchmark_pushpop1(void) | ||
491 | { | ||
492 | __asm__ __volatile__ ( | ||
493 | "stmdb"wide" sp!, {r3-r11,lr} \n\t" | ||
494 | "ldmia"wide" sp!, {r3-r11,pc}" | ||
495 | ); | ||
496 | } | ||
497 | |||
498 | static void __naked benchmark_pushpop2(void) | ||
499 | { | ||
500 | __asm__ __volatile__ ( | ||
501 | "stmdb"wide" sp!, {r0-r8,lr} \n\t" | ||
502 | "ldmia"wide" sp!, {r0-r8,pc}" | ||
503 | ); | ||
504 | } | ||
505 | |||
506 | static void __naked benchmark_pushpop3(void) | ||
507 | { | ||
508 | __asm__ __volatile__ ( | ||
509 | "stmdb"wide" sp!, {r4,lr} \n\t" | ||
510 | "ldmia"wide" sp!, {r4,pc}" | ||
511 | ); | ||
512 | } | ||
513 | |||
514 | static void __naked benchmark_pushpop4(void) | ||
515 | { | ||
516 | __asm__ __volatile__ ( | ||
517 | "stmdb"wide" sp!, {r0,lr} \n\t" | ||
518 | "ldmia"wide" sp!, {r0,pc}" | ||
519 | ); | ||
520 | } | ||
521 | |||
522 | |||
523 | #ifdef CONFIG_THUMB2_KERNEL | ||
524 | |||
525 | static void __naked benchmark_pushpop_thumb(void) | ||
526 | { | ||
527 | __asm__ __volatile__ ( | ||
528 | "push.n {r0-r7,lr} \n\t" | ||
529 | "pop.n {r0-r7,pc}" | ||
530 | ); | ||
531 | } | ||
532 | |||
533 | #endif | ||
534 | |||
535 | static int __kprobes | ||
536 | benchmark_pre_handler(struct kprobe *p, struct pt_regs *regs) | ||
537 | { | ||
538 | return 0; | ||
539 | } | ||
540 | |||
541 | static int benchmark(void(*fn)(void)) | ||
542 | { | ||
543 | unsigned n, i, t, t0; | ||
544 | |||
545 | for (n = 1000; ; n *= 2) { | ||
546 | t0 = sched_clock(); | ||
547 | for (i = n; i > 0; --i) | ||
548 | fn(); | ||
549 | t = sched_clock() - t0; | ||
550 | if (t >= 250000000) | ||
551 | break; /* Stop once we took more than 0.25 seconds */ | ||
552 | } | ||
553 | return t / n; /* Time for one iteration in nanoseconds */ | ||
554 | }; | ||
555 | |||
556 | static int kprobe_benchmark(void(*fn)(void), unsigned offset) | ||
557 | { | ||
558 | struct kprobe k = { | ||
559 | .addr = (kprobe_opcode_t *)((uintptr_t)fn + offset), | ||
560 | .pre_handler = benchmark_pre_handler, | ||
561 | }; | ||
562 | |||
563 | int ret = register_kprobe(&k); | ||
564 | if (ret < 0) { | ||
565 | pr_err("FAIL: register_kprobe failed with %d\n", ret); | ||
566 | return ret; | ||
567 | } | ||
568 | |||
569 | ret = benchmark(fn); | ||
570 | |||
571 | unregister_kprobe(&k); | ||
572 | return ret; | ||
573 | }; | ||
574 | |||
575 | struct benchmarks { | ||
576 | void (*fn)(void); | ||
577 | unsigned offset; | ||
578 | const char *title; | ||
579 | }; | ||
580 | |||
581 | static int run_benchmarks(void) | ||
582 | { | ||
583 | int ret; | ||
584 | struct benchmarks list[] = { | ||
585 | {&benchmark_nop, 0, "nop"}, | ||
586 | /* | ||
587 | * benchmark_pushpop{1,3} will have the optimised | ||
588 | * instruction emulation, whilst benchmark_pushpop{2,4} will | ||
589 | * be the equivalent unoptimised instructions. | ||
590 | */ | ||
591 | {&benchmark_pushpop1, 0, "stmdb sp!, {r3-r11,lr}"}, | ||
592 | {&benchmark_pushpop1, 4, "ldmia sp!, {r3-r11,pc}"}, | ||
593 | {&benchmark_pushpop2, 0, "stmdb sp!, {r0-r8,lr}"}, | ||
594 | {&benchmark_pushpop2, 4, "ldmia sp!, {r0-r8,pc}"}, | ||
595 | {&benchmark_pushpop3, 0, "stmdb sp!, {r4,lr}"}, | ||
596 | {&benchmark_pushpop3, 4, "ldmia sp!, {r4,pc}"}, | ||
597 | {&benchmark_pushpop4, 0, "stmdb sp!, {r0,lr}"}, | ||
598 | {&benchmark_pushpop4, 4, "ldmia sp!, {r0,pc}"}, | ||
599 | #ifdef CONFIG_THUMB2_KERNEL | ||
600 | {&benchmark_pushpop_thumb, 0, "push.n {r0-r7,lr}"}, | ||
601 | {&benchmark_pushpop_thumb, 2, "pop.n {r0-r7,pc}"}, | ||
602 | #endif | ||
603 | {0} | ||
604 | }; | ||
605 | |||
606 | struct benchmarks *b; | ||
607 | for (b = list; b->fn; ++b) { | ||
608 | ret = kprobe_benchmark(b->fn, b->offset); | ||
609 | if (ret < 0) | ||
610 | return ret; | ||
611 | pr_info(" %dns for kprobe %s\n", ret, b->title); | ||
612 | } | ||
613 | |||
614 | pr_info("\n"); | ||
615 | return 0; | ||
616 | } | ||
617 | |||
618 | #endif /* BENCHMARKING */ | ||
619 | |||
620 | |||
621 | /* | ||
622 | * Decoding table self-consistency tests | ||
623 | */ | ||
624 | |||
625 | static const int decode_struct_sizes[NUM_DECODE_TYPES] = { | ||
626 | [DECODE_TYPE_TABLE] = sizeof(struct decode_table), | ||
627 | [DECODE_TYPE_CUSTOM] = sizeof(struct decode_custom), | ||
628 | [DECODE_TYPE_SIMULATE] = sizeof(struct decode_simulate), | ||
629 | [DECODE_TYPE_EMULATE] = sizeof(struct decode_emulate), | ||
630 | [DECODE_TYPE_OR] = sizeof(struct decode_or), | ||
631 | [DECODE_TYPE_REJECT] = sizeof(struct decode_reject) | ||
632 | }; | ||
633 | |||
634 | static int table_iter(const union decode_item *table, | ||
635 | int (*fn)(const struct decode_header *, void *), | ||
636 | void *args) | ||
637 | { | ||
638 | const struct decode_header *h = (struct decode_header *)table; | ||
639 | int result; | ||
640 | |||
641 | for (;;) { | ||
642 | enum decode_type type = h->type_regs.bits & DECODE_TYPE_MASK; | ||
643 | |||
644 | if (type == DECODE_TYPE_END) | ||
645 | return 0; | ||
646 | |||
647 | result = fn(h, args); | ||
648 | if (result) | ||
649 | return result; | ||
650 | |||
651 | h = (struct decode_header *) | ||
652 | ((uintptr_t)h + decode_struct_sizes[type]); | ||
653 | |||
654 | } | ||
655 | } | ||
656 | |||
657 | static int table_test_fail(const struct decode_header *h, const char* message) | ||
658 | { | ||
659 | |||
660 | pr_err("FAIL: kprobes test failure \"%s\" (mask %08x, value %08x)\n", | ||
661 | message, h->mask.bits, h->value.bits); | ||
662 | return -EINVAL; | ||
663 | } | ||
664 | |||
665 | struct table_test_args { | ||
666 | const union decode_item *root_table; | ||
667 | u32 parent_mask; | ||
668 | u32 parent_value; | ||
669 | }; | ||
670 | |||
671 | static int table_test_fn(const struct decode_header *h, void *args) | ||
672 | { | ||
673 | struct table_test_args *a = (struct table_test_args *)args; | ||
674 | enum decode_type type = h->type_regs.bits & DECODE_TYPE_MASK; | ||
675 | |||
676 | if (h->value.bits & ~h->mask.bits) | ||
677 | return table_test_fail(h, "Match value has bits not in mask"); | ||
678 | |||
679 | if ((h->mask.bits & a->parent_mask) != a->parent_mask) | ||
680 | return table_test_fail(h, "Mask has bits not in parent mask"); | ||
681 | |||
682 | if ((h->value.bits ^ a->parent_value) & a->parent_mask) | ||
683 | return table_test_fail(h, "Value is inconsistent with parent"); | ||
684 | |||
685 | if (type == DECODE_TYPE_TABLE) { | ||
686 | struct decode_table *d = (struct decode_table *)h; | ||
687 | struct table_test_args args2 = *a; | ||
688 | args2.parent_mask = h->mask.bits; | ||
689 | args2.parent_value = h->value.bits; | ||
690 | return table_iter(d->table.table, table_test_fn, &args2); | ||
691 | } | ||
692 | |||
693 | return 0; | ||
694 | } | ||
695 | |||
696 | static int table_test(const union decode_item *table) | ||
697 | { | ||
698 | struct table_test_args args = { | ||
699 | .root_table = table, | ||
700 | .parent_mask = 0, | ||
701 | .parent_value = 0 | ||
702 | }; | ||
703 | return table_iter(args.root_table, table_test_fn, &args); | ||
704 | } | ||
705 | |||
706 | |||
707 | /* | ||
708 | * Decoding table test coverage analysis | ||
709 | * | ||
710 | * coverage_start() builds a coverage_table which contains a list of | ||
711 | * coverage_entry's to match each entry in the specified kprobes instruction | ||
712 | * decoding table. | ||
713 | * | ||
714 | * When test cases are run, coverage_add() is called to process each case. | ||
715 | * This looks up the corresponding entry in the coverage_table and sets it as | ||
716 | * being matched, as well as clearing the regs flag appropriate for the test. | ||
717 | * | ||
718 | * After all test cases have been run, coverage_end() is called to check that | ||
719 | * all entries in coverage_table have been matched and that all regs flags are | ||
720 | * cleared. I.e. that all possible combinations of instructions described by | ||
721 | * the kprobes decoding tables have had a test case executed for them. | ||
722 | */ | ||
723 | |||
724 | bool coverage_fail; | ||
725 | |||
726 | #define MAX_COVERAGE_ENTRIES 256 | ||
727 | |||
728 | struct coverage_entry { | ||
729 | const struct decode_header *header; | ||
730 | unsigned regs; | ||
731 | unsigned nesting; | ||
732 | char matched; | ||
733 | }; | ||
734 | |||
735 | struct coverage_table { | ||
736 | struct coverage_entry *base; | ||
737 | unsigned num_entries; | ||
738 | unsigned nesting; | ||
739 | }; | ||
740 | |||
741 | struct coverage_table coverage; | ||
742 | |||
743 | #define COVERAGE_ANY_REG (1<<0) | ||
744 | #define COVERAGE_SP (1<<1) | ||
745 | #define COVERAGE_PC (1<<2) | ||
746 | #define COVERAGE_PCWB (1<<3) | ||
747 | |||
748 | static const char coverage_register_lookup[16] = { | ||
749 | [REG_TYPE_ANY] = COVERAGE_ANY_REG | COVERAGE_SP | COVERAGE_PC, | ||
750 | [REG_TYPE_SAMEAS16] = COVERAGE_ANY_REG, | ||
751 | [REG_TYPE_SP] = COVERAGE_SP, | ||
752 | [REG_TYPE_PC] = COVERAGE_PC, | ||
753 | [REG_TYPE_NOSP] = COVERAGE_ANY_REG | COVERAGE_SP, | ||
754 | [REG_TYPE_NOSPPC] = COVERAGE_ANY_REG | COVERAGE_SP | COVERAGE_PC, | ||
755 | [REG_TYPE_NOPC] = COVERAGE_ANY_REG | COVERAGE_PC, | ||
756 | [REG_TYPE_NOPCWB] = COVERAGE_ANY_REG | COVERAGE_PC | COVERAGE_PCWB, | ||
757 | [REG_TYPE_NOPCX] = COVERAGE_ANY_REG, | ||
758 | [REG_TYPE_NOSPPCX] = COVERAGE_ANY_REG | COVERAGE_SP, | ||
759 | }; | ||
760 | |||
761 | unsigned coverage_start_registers(const struct decode_header *h) | ||
762 | { | ||
763 | unsigned regs = 0; | ||
764 | int i; | ||
765 | for (i = 0; i < 20; i += 4) { | ||
766 | int r = (h->type_regs.bits >> (DECODE_TYPE_BITS + i)) & 0xf; | ||
767 | regs |= coverage_register_lookup[r] << i; | ||
768 | } | ||
769 | return regs; | ||
770 | } | ||
771 | |||
772 | static int coverage_start_fn(const struct decode_header *h, void *args) | ||
773 | { | ||
774 | struct coverage_table *coverage = (struct coverage_table *)args; | ||
775 | enum decode_type type = h->type_regs.bits & DECODE_TYPE_MASK; | ||
776 | struct coverage_entry *entry = coverage->base + coverage->num_entries; | ||
777 | |||
778 | if (coverage->num_entries == MAX_COVERAGE_ENTRIES - 1) { | ||
779 | pr_err("FAIL: Out of space for test coverage data"); | ||
780 | return -ENOMEM; | ||
781 | } | ||
782 | |||
783 | ++coverage->num_entries; | ||
784 | |||
785 | entry->header = h; | ||
786 | entry->regs = coverage_start_registers(h); | ||
787 | entry->nesting = coverage->nesting; | ||
788 | entry->matched = false; | ||
789 | |||
790 | if (type == DECODE_TYPE_TABLE) { | ||
791 | struct decode_table *d = (struct decode_table *)h; | ||
792 | int ret; | ||
793 | ++coverage->nesting; | ||
794 | ret = table_iter(d->table.table, coverage_start_fn, coverage); | ||
795 | --coverage->nesting; | ||
796 | return ret; | ||
797 | } | ||
798 | |||
799 | return 0; | ||
800 | } | ||
801 | |||
802 | static int coverage_start(const union decode_item *table) | ||
803 | { | ||
804 | coverage.base = kmalloc(MAX_COVERAGE_ENTRIES * | ||
805 | sizeof(struct coverage_entry), GFP_KERNEL); | ||
806 | coverage.num_entries = 0; | ||
807 | coverage.nesting = 0; | ||
808 | return table_iter(table, coverage_start_fn, &coverage); | ||
809 | } | ||
810 | |||
811 | static void | ||
812 | coverage_add_registers(struct coverage_entry *entry, kprobe_opcode_t insn) | ||
813 | { | ||
814 | int regs = entry->header->type_regs.bits >> DECODE_TYPE_BITS; | ||
815 | int i; | ||
816 | for (i = 0; i < 20; i += 4) { | ||
817 | enum decode_reg_type reg_type = (regs >> i) & 0xf; | ||
818 | int reg = (insn >> i) & 0xf; | ||
819 | int flag; | ||
820 | |||
821 | if (!reg_type) | ||
822 | continue; | ||
823 | |||
824 | if (reg == 13) | ||
825 | flag = COVERAGE_SP; | ||
826 | else if (reg == 15) | ||
827 | flag = COVERAGE_PC; | ||
828 | else | ||
829 | flag = COVERAGE_ANY_REG; | ||
830 | entry->regs &= ~(flag << i); | ||
831 | |||
832 | switch (reg_type) { | ||
833 | |||
834 | case REG_TYPE_NONE: | ||
835 | case REG_TYPE_ANY: | ||
836 | case REG_TYPE_SAMEAS16: | ||
837 | break; | ||
838 | |||
839 | case REG_TYPE_SP: | ||
840 | if (reg != 13) | ||
841 | return; | ||
842 | break; | ||
843 | |||
844 | case REG_TYPE_PC: | ||
845 | if (reg != 15) | ||
846 | return; | ||
847 | break; | ||
848 | |||
849 | case REG_TYPE_NOSP: | ||
850 | if (reg == 13) | ||
851 | return; | ||
852 | break; | ||
853 | |||
854 | case REG_TYPE_NOSPPC: | ||
855 | case REG_TYPE_NOSPPCX: | ||
856 | if (reg == 13 || reg == 15) | ||
857 | return; | ||
858 | break; | ||
859 | |||
860 | case REG_TYPE_NOPCWB: | ||
861 | if (!is_writeback(insn)) | ||
862 | break; | ||
863 | if (reg == 15) { | ||
864 | entry->regs &= ~(COVERAGE_PCWB << i); | ||
865 | return; | ||
866 | } | ||
867 | break; | ||
868 | |||
869 | case REG_TYPE_NOPC: | ||
870 | case REG_TYPE_NOPCX: | ||
871 | if (reg == 15) | ||
872 | return; | ||
873 | break; | ||
874 | } | ||
875 | |||
876 | } | ||
877 | } | ||
878 | |||
879 | static void coverage_add(kprobe_opcode_t insn) | ||
880 | { | ||
881 | struct coverage_entry *entry = coverage.base; | ||
882 | struct coverage_entry *end = coverage.base + coverage.num_entries; | ||
883 | bool matched = false; | ||
884 | unsigned nesting = 0; | ||
885 | |||
886 | for (; entry < end; ++entry) { | ||
887 | const struct decode_header *h = entry->header; | ||
888 | enum decode_type type = h->type_regs.bits & DECODE_TYPE_MASK; | ||
889 | |||
890 | if (entry->nesting > nesting) | ||
891 | continue; /* Skip sub-table we didn't match */ | ||
892 | |||
893 | if (entry->nesting < nesting) | ||
894 | break; /* End of sub-table we were scanning */ | ||
895 | |||
896 | if (!matched) { | ||
897 | if ((insn & h->mask.bits) != h->value.bits) | ||
898 | continue; | ||
899 | entry->matched = true; | ||
900 | } | ||
901 | |||
902 | switch (type) { | ||
903 | |||
904 | case DECODE_TYPE_TABLE: | ||
905 | ++nesting; | ||
906 | break; | ||
907 | |||
908 | case DECODE_TYPE_CUSTOM: | ||
909 | case DECODE_TYPE_SIMULATE: | ||
910 | case DECODE_TYPE_EMULATE: | ||
911 | coverage_add_registers(entry, insn); | ||
912 | return; | ||
913 | |||
914 | case DECODE_TYPE_OR: | ||
915 | matched = true; | ||
916 | break; | ||
917 | |||
918 | case DECODE_TYPE_REJECT: | ||
919 | default: | ||
920 | return; | ||
921 | } | ||
922 | |||
923 | } | ||
924 | } | ||
925 | |||
926 | static void coverage_end(void) | ||
927 | { | ||
928 | struct coverage_entry *entry = coverage.base; | ||
929 | struct coverage_entry *end = coverage.base + coverage.num_entries; | ||
930 | |||
931 | for (; entry < end; ++entry) { | ||
932 | u32 mask = entry->header->mask.bits; | ||
933 | u32 value = entry->header->value.bits; | ||
934 | |||
935 | if (entry->regs) { | ||
936 | pr_err("FAIL: Register test coverage missing for %08x %08x (%05x)\n", | ||
937 | mask, value, entry->regs); | ||
938 | coverage_fail = true; | ||
939 | } | ||
940 | if (!entry->matched) { | ||
941 | pr_err("FAIL: Test coverage entry missing for %08x %08x\n", | ||
942 | mask, value); | ||
943 | coverage_fail = true; | ||
944 | } | ||
945 | } | ||
946 | |||
947 | kfree(coverage.base); | ||
948 | } | ||
949 | |||
950 | |||
951 | /* | ||
952 | * Framework for instruction set test cases | ||
953 | */ | ||
954 | |||
955 | void __naked __kprobes_test_case_start(void) | ||
956 | { | ||
957 | __asm__ __volatile__ ( | ||
958 | "stmdb sp!, {r4-r11} \n\t" | ||
959 | "sub sp, sp, #"__stringify(TEST_MEMORY_SIZE)"\n\t" | ||
960 | "bic r0, lr, #1 @ r0 = inline title string \n\t" | ||
961 | "mov r1, sp \n\t" | ||
962 | "bl kprobes_test_case_start \n\t" | ||
963 | "bx r0 \n\t" | ||
964 | ); | ||
965 | } | ||
966 | |||
967 | #ifndef CONFIG_THUMB2_KERNEL | ||
968 | |||
969 | void __naked __kprobes_test_case_end_32(void) | ||
970 | { | ||
971 | __asm__ __volatile__ ( | ||
972 | "mov r4, lr \n\t" | ||
973 | "bl kprobes_test_case_end \n\t" | ||
974 | "cmp r0, #0 \n\t" | ||
975 | "movne pc, r0 \n\t" | ||
976 | "mov r0, r4 \n\t" | ||
977 | "add sp, sp, #"__stringify(TEST_MEMORY_SIZE)"\n\t" | ||
978 | "ldmia sp!, {r4-r11} \n\t" | ||
979 | "mov pc, r0 \n\t" | ||
980 | ); | ||
981 | } | ||
982 | |||
983 | #else /* CONFIG_THUMB2_KERNEL */ | ||
984 | |||
985 | void __naked __kprobes_test_case_end_16(void) | ||
986 | { | ||
987 | __asm__ __volatile__ ( | ||
988 | "mov r4, lr \n\t" | ||
989 | "bl kprobes_test_case_end \n\t" | ||
990 | "cmp r0, #0 \n\t" | ||
991 | "bxne r0 \n\t" | ||
992 | "mov r0, r4 \n\t" | ||
993 | "add sp, sp, #"__stringify(TEST_MEMORY_SIZE)"\n\t" | ||
994 | "ldmia sp!, {r4-r11} \n\t" | ||
995 | "bx r0 \n\t" | ||
996 | ); | ||
997 | } | ||
998 | |||
999 | void __naked __kprobes_test_case_end_32(void) | ||
1000 | { | ||
1001 | __asm__ __volatile__ ( | ||
1002 | ".arm \n\t" | ||
1003 | "orr lr, lr, #1 @ will return to Thumb code \n\t" | ||
1004 | "ldr pc, 1f \n\t" | ||
1005 | "1: \n\t" | ||
1006 | ".word __kprobes_test_case_end_16 \n\t" | ||
1007 | ); | ||
1008 | } | ||
1009 | |||
1010 | #endif | ||
1011 | |||
1012 | |||
1013 | int kprobe_test_flags; | ||
1014 | int kprobe_test_cc_position; | ||
1015 | |||
1016 | static int test_try_count; | ||
1017 | static int test_pass_count; | ||
1018 | static int test_fail_count; | ||
1019 | |||
1020 | static struct pt_regs initial_regs; | ||
1021 | static struct pt_regs expected_regs; | ||
1022 | static struct pt_regs result_regs; | ||
1023 | |||
1024 | static u32 expected_memory[TEST_MEMORY_SIZE/sizeof(u32)]; | ||
1025 | |||
1026 | static const char *current_title; | ||
1027 | static struct test_arg *current_args; | ||
1028 | static u32 *current_stack; | ||
1029 | static uintptr_t current_branch_target; | ||
1030 | |||
1031 | static uintptr_t current_code_start; | ||
1032 | static kprobe_opcode_t current_instruction; | ||
1033 | |||
1034 | |||
1035 | #define TEST_CASE_PASSED -1 | ||
1036 | #define TEST_CASE_FAILED -2 | ||
1037 | |||
1038 | static int test_case_run_count; | ||
1039 | static bool test_case_is_thumb; | ||
1040 | static int test_instance; | ||
1041 | |||
1042 | /* | ||
1043 | * We ignore the state of the imprecise abort disable flag (CPSR.A) because this | ||
1044 | * can change randomly as the kernel doesn't take care to preserve or initialise | ||
1045 | * this across context switches. Also, with Security Extentions, the flag may | ||
1046 | * not be under control of the kernel; for this reason we ignore the state of | ||
1047 | * the FIQ disable flag CPSR.F as well. | ||
1048 | */ | ||
1049 | #define PSR_IGNORE_BITS (PSR_A_BIT | PSR_F_BIT) | ||
1050 | |||
1051 | static unsigned long test_check_cc(int cc, unsigned long cpsr) | ||
1052 | { | ||
1053 | unsigned long temp; | ||
1054 | |||
1055 | switch (cc) { | ||
1056 | case 0x0: /* eq */ | ||
1057 | return cpsr & PSR_Z_BIT; | ||
1058 | |||
1059 | case 0x1: /* ne */ | ||
1060 | return (~cpsr) & PSR_Z_BIT; | ||
1061 | |||
1062 | case 0x2: /* cs */ | ||
1063 | return cpsr & PSR_C_BIT; | ||
1064 | |||
1065 | case 0x3: /* cc */ | ||
1066 | return (~cpsr) & PSR_C_BIT; | ||
1067 | |||
1068 | case 0x4: /* mi */ | ||
1069 | return cpsr & PSR_N_BIT; | ||
1070 | |||
1071 | case 0x5: /* pl */ | ||
1072 | return (~cpsr) & PSR_N_BIT; | ||
1073 | |||
1074 | case 0x6: /* vs */ | ||
1075 | return cpsr & PSR_V_BIT; | ||
1076 | |||
1077 | case 0x7: /* vc */ | ||
1078 | return (~cpsr) & PSR_V_BIT; | ||
1079 | |||
1080 | case 0x8: /* hi */ | ||
1081 | cpsr &= ~(cpsr >> 1); /* PSR_C_BIT &= ~PSR_Z_BIT */ | ||
1082 | return cpsr & PSR_C_BIT; | ||
1083 | |||
1084 | case 0x9: /* ls */ | ||
1085 | cpsr &= ~(cpsr >> 1); /* PSR_C_BIT &= ~PSR_Z_BIT */ | ||
1086 | return (~cpsr) & PSR_C_BIT; | ||
1087 | |||
1088 | case 0xa: /* ge */ | ||
1089 | cpsr ^= (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */ | ||
1090 | return (~cpsr) & PSR_N_BIT; | ||
1091 | |||
1092 | case 0xb: /* lt */ | ||
1093 | cpsr ^= (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */ | ||
1094 | return cpsr & PSR_N_BIT; | ||
1095 | |||
1096 | case 0xc: /* gt */ | ||
1097 | temp = cpsr ^ (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */ | ||
1098 | temp |= (cpsr << 1); /* PSR_N_BIT |= PSR_Z_BIT */ | ||
1099 | return (~temp) & PSR_N_BIT; | ||
1100 | |||
1101 | case 0xd: /* le */ | ||
1102 | temp = cpsr ^ (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */ | ||
1103 | temp |= (cpsr << 1); /* PSR_N_BIT |= PSR_Z_BIT */ | ||
1104 | return temp & PSR_N_BIT; | ||
1105 | |||
1106 | case 0xe: /* al */ | ||
1107 | case 0xf: /* unconditional */ | ||
1108 | return true; | ||
1109 | } | ||
1110 | BUG(); | ||
1111 | return false; | ||
1112 | } | ||
1113 | |||
1114 | static int is_last_scenario; | ||
1115 | static int probe_should_run; /* 0 = no, 1 = yes, -1 = unknown */ | ||
1116 | static int memory_needs_checking; | ||
1117 | |||
1118 | static unsigned long test_context_cpsr(int scenario) | ||
1119 | { | ||
1120 | unsigned long cpsr; | ||
1121 | |||
1122 | probe_should_run = 1; | ||
1123 | |||
1124 | /* Default case is that we cycle through 16 combinations of flags */ | ||
1125 | cpsr = (scenario & 0xf) << 28; /* N,Z,C,V flags */ | ||
1126 | cpsr |= (scenario & 0xf) << 16; /* GE flags */ | ||
1127 | cpsr |= (scenario & 0x1) << 27; /* Toggle Q flag */ | ||
1128 | |||
1129 | if (!test_case_is_thumb) { | ||
1130 | /* Testing ARM code */ | ||
1131 | probe_should_run = test_check_cc(current_instruction >> 28, cpsr) != 0; | ||
1132 | if (scenario == 15) | ||
1133 | is_last_scenario = true; | ||
1134 | |||
1135 | } else if (kprobe_test_flags & TEST_FLAG_NO_ITBLOCK) { | ||
1136 | /* Testing Thumb code without setting ITSTATE */ | ||
1137 | if (kprobe_test_cc_position) { | ||
1138 | int cc = (current_instruction >> kprobe_test_cc_position) & 0xf; | ||
1139 | probe_should_run = test_check_cc(cc, cpsr) != 0; | ||
1140 | } | ||
1141 | |||
1142 | if (scenario == 15) | ||
1143 | is_last_scenario = true; | ||
1144 | |||
1145 | } else if (kprobe_test_flags & TEST_FLAG_FULL_ITBLOCK) { | ||
1146 | /* Testing Thumb code with all combinations of ITSTATE */ | ||
1147 | unsigned x = (scenario >> 4); | ||
1148 | unsigned cond_base = x % 7; /* ITSTATE<7:5> */ | ||
1149 | unsigned mask = x / 7 + 2; /* ITSTATE<4:0>, bits reversed */ | ||
1150 | |||
1151 | if (mask > 0x1f) { | ||
1152 | /* Finish by testing state from instruction 'itt al' */ | ||
1153 | cond_base = 7; | ||
1154 | mask = 0x4; | ||
1155 | if ((scenario & 0xf) == 0xf) | ||
1156 | is_last_scenario = true; | ||
1157 | } | ||
1158 | |||
1159 | cpsr |= cond_base << 13; /* ITSTATE<7:5> */ | ||
1160 | cpsr |= (mask & 0x1) << 12; /* ITSTATE<4> */ | ||
1161 | cpsr |= (mask & 0x2) << 10; /* ITSTATE<3> */ | ||
1162 | cpsr |= (mask & 0x4) << 8; /* ITSTATE<2> */ | ||
1163 | cpsr |= (mask & 0x8) << 23; /* ITSTATE<1> */ | ||
1164 | cpsr |= (mask & 0x10) << 21; /* ITSTATE<0> */ | ||
1165 | |||
1166 | probe_should_run = test_check_cc((cpsr >> 12) & 0xf, cpsr) != 0; | ||
1167 | |||
1168 | } else { | ||
1169 | /* Testing Thumb code with several combinations of ITSTATE */ | ||
1170 | switch (scenario) { | ||
1171 | case 16: /* Clear NZCV flags and 'it eq' state (false as Z=0) */ | ||
1172 | cpsr = 0x00000800; | ||
1173 | probe_should_run = 0; | ||
1174 | break; | ||
1175 | case 17: /* Set NZCV flags and 'it vc' state (false as V=1) */ | ||
1176 | cpsr = 0xf0007800; | ||
1177 | probe_should_run = 0; | ||
1178 | break; | ||
1179 | case 18: /* Clear NZCV flags and 'it ls' state (true as C=0) */ | ||
1180 | cpsr = 0x00009800; | ||
1181 | break; | ||
1182 | case 19: /* Set NZCV flags and 'it cs' state (true as C=1) */ | ||
1183 | cpsr = 0xf0002800; | ||
1184 | is_last_scenario = true; | ||
1185 | break; | ||
1186 | } | ||
1187 | } | ||
1188 | |||
1189 | return cpsr; | ||
1190 | } | ||
1191 | |||
1192 | static void setup_test_context(struct pt_regs *regs) | ||
1193 | { | ||
1194 | int scenario = test_case_run_count>>1; | ||
1195 | unsigned long val; | ||
1196 | struct test_arg *args; | ||
1197 | int i; | ||
1198 | |||
1199 | is_last_scenario = false; | ||
1200 | memory_needs_checking = false; | ||
1201 | |||
1202 | /* Initialise test memory on stack */ | ||
1203 | val = (scenario & 1) ? VALM : ~VALM; | ||
1204 | for (i = 0; i < TEST_MEMORY_SIZE / sizeof(current_stack[0]); ++i) | ||
1205 | current_stack[i] = val + (i << 8); | ||
1206 | /* Put target of branch on stack for tests which load PC from memory */ | ||
1207 | if (current_branch_target) | ||
1208 | current_stack[15] = current_branch_target; | ||
1209 | /* Put a value for SP on stack for tests which load SP from memory */ | ||
1210 | current_stack[13] = (u32)current_stack + 120; | ||
1211 | |||
1212 | /* Initialise register values to their default state */ | ||
1213 | val = (scenario & 2) ? VALR : ~VALR; | ||
1214 | for (i = 0; i < 13; ++i) | ||
1215 | regs->uregs[i] = val ^ (i << 8); | ||
1216 | regs->ARM_lr = val ^ (14 << 8); | ||
1217 | regs->ARM_cpsr &= ~(APSR_MASK | PSR_IT_MASK); | ||
1218 | regs->ARM_cpsr |= test_context_cpsr(scenario); | ||
1219 | |||
1220 | /* Perform testcase specific register setup */ | ||
1221 | args = current_args; | ||
1222 | for (; args[0].type != ARG_TYPE_END; ++args) | ||
1223 | switch (args[0].type) { | ||
1224 | case ARG_TYPE_REG: { | ||
1225 | struct test_arg_regptr *arg = | ||
1226 | (struct test_arg_regptr *)args; | ||
1227 | regs->uregs[arg->reg] = arg->val; | ||
1228 | break; | ||
1229 | } | ||
1230 | case ARG_TYPE_PTR: { | ||
1231 | struct test_arg_regptr *arg = | ||
1232 | (struct test_arg_regptr *)args; | ||
1233 | regs->uregs[arg->reg] = | ||
1234 | (unsigned long)current_stack + arg->val; | ||
1235 | memory_needs_checking = true; | ||
1236 | break; | ||
1237 | } | ||
1238 | case ARG_TYPE_MEM: { | ||
1239 | struct test_arg_mem *arg = (struct test_arg_mem *)args; | ||
1240 | current_stack[arg->index] = arg->val; | ||
1241 | break; | ||
1242 | } | ||
1243 | default: | ||
1244 | break; | ||
1245 | } | ||
1246 | } | ||
1247 | |||
1248 | struct test_probe { | ||
1249 | struct kprobe kprobe; | ||
1250 | bool registered; | ||
1251 | int hit; | ||
1252 | }; | ||
1253 | |||
1254 | static void unregister_test_probe(struct test_probe *probe) | ||
1255 | { | ||
1256 | if (probe->registered) { | ||
1257 | unregister_kprobe(&probe->kprobe); | ||
1258 | probe->kprobe.flags = 0; /* Clear disable flag to allow reuse */ | ||
1259 | } | ||
1260 | probe->registered = false; | ||
1261 | } | ||
1262 | |||
1263 | static int register_test_probe(struct test_probe *probe) | ||
1264 | { | ||
1265 | int ret; | ||
1266 | |||
1267 | if (probe->registered) | ||
1268 | BUG(); | ||
1269 | |||
1270 | ret = register_kprobe(&probe->kprobe); | ||
1271 | if (ret >= 0) { | ||
1272 | probe->registered = true; | ||
1273 | probe->hit = -1; | ||
1274 | } | ||
1275 | return ret; | ||
1276 | } | ||
1277 | |||
1278 | static int __kprobes | ||
1279 | test_before_pre_handler(struct kprobe *p, struct pt_regs *regs) | ||
1280 | { | ||
1281 | container_of(p, struct test_probe, kprobe)->hit = test_instance; | ||
1282 | return 0; | ||
1283 | } | ||
1284 | |||
1285 | static void __kprobes | ||
1286 | test_before_post_handler(struct kprobe *p, struct pt_regs *regs, | ||
1287 | unsigned long flags) | ||
1288 | { | ||
1289 | setup_test_context(regs); | ||
1290 | initial_regs = *regs; | ||
1291 | initial_regs.ARM_cpsr &= ~PSR_IGNORE_BITS; | ||
1292 | } | ||
1293 | |||
1294 | static int __kprobes | ||
1295 | test_case_pre_handler(struct kprobe *p, struct pt_regs *regs) | ||
1296 | { | ||
1297 | container_of(p, struct test_probe, kprobe)->hit = test_instance; | ||
1298 | return 0; | ||
1299 | } | ||
1300 | |||
1301 | static int __kprobes | ||
1302 | test_after_pre_handler(struct kprobe *p, struct pt_regs *regs) | ||
1303 | { | ||
1304 | if (container_of(p, struct test_probe, kprobe)->hit == test_instance) | ||
1305 | return 0; /* Already run for this test instance */ | ||
1306 | |||
1307 | result_regs = *regs; | ||
1308 | result_regs.ARM_cpsr &= ~PSR_IGNORE_BITS; | ||
1309 | |||
1310 | /* Undo any changes done to SP by the test case */ | ||
1311 | regs->ARM_sp = (unsigned long)current_stack; | ||
1312 | |||
1313 | container_of(p, struct test_probe, kprobe)->hit = test_instance; | ||
1314 | return 0; | ||
1315 | } | ||
1316 | |||
1317 | static struct test_probe test_before_probe = { | ||
1318 | .kprobe.pre_handler = test_before_pre_handler, | ||
1319 | .kprobe.post_handler = test_before_post_handler, | ||
1320 | }; | ||
1321 | |||
1322 | static struct test_probe test_case_probe = { | ||
1323 | .kprobe.pre_handler = test_case_pre_handler, | ||
1324 | }; | ||
1325 | |||
1326 | static struct test_probe test_after_probe = { | ||
1327 | .kprobe.pre_handler = test_after_pre_handler, | ||
1328 | }; | ||
1329 | |||
1330 | static struct test_probe test_after2_probe = { | ||
1331 | .kprobe.pre_handler = test_after_pre_handler, | ||
1332 | }; | ||
1333 | |||
1334 | static void test_case_cleanup(void) | ||
1335 | { | ||
1336 | unregister_test_probe(&test_before_probe); | ||
1337 | unregister_test_probe(&test_case_probe); | ||
1338 | unregister_test_probe(&test_after_probe); | ||
1339 | unregister_test_probe(&test_after2_probe); | ||
1340 | } | ||
1341 | |||
1342 | static void print_registers(struct pt_regs *regs) | ||
1343 | { | ||
1344 | pr_err("r0 %08lx | r1 %08lx | r2 %08lx | r3 %08lx\n", | ||
1345 | regs->ARM_r0, regs->ARM_r1, regs->ARM_r2, regs->ARM_r3); | ||
1346 | pr_err("r4 %08lx | r5 %08lx | r6 %08lx | r7 %08lx\n", | ||
1347 | regs->ARM_r4, regs->ARM_r5, regs->ARM_r6, regs->ARM_r7); | ||
1348 | pr_err("r8 %08lx | r9 %08lx | r10 %08lx | r11 %08lx\n", | ||
1349 | regs->ARM_r8, regs->ARM_r9, regs->ARM_r10, regs->ARM_fp); | ||
1350 | pr_err("r12 %08lx | sp %08lx | lr %08lx | pc %08lx\n", | ||
1351 | regs->ARM_ip, regs->ARM_sp, regs->ARM_lr, regs->ARM_pc); | ||
1352 | pr_err("cpsr %08lx\n", regs->ARM_cpsr); | ||
1353 | } | ||
1354 | |||
1355 | static void print_memory(u32 *mem, size_t size) | ||
1356 | { | ||
1357 | int i; | ||
1358 | for (i = 0; i < size / sizeof(u32); i += 4) | ||
1359 | pr_err("%08x %08x %08x %08x\n", mem[i], mem[i+1], | ||
1360 | mem[i+2], mem[i+3]); | ||
1361 | } | ||
1362 | |||
1363 | static size_t expected_memory_size(u32 *sp) | ||
1364 | { | ||
1365 | size_t size = sizeof(expected_memory); | ||
1366 | int offset = (uintptr_t)sp - (uintptr_t)current_stack; | ||
1367 | if (offset > 0) | ||
1368 | size -= offset; | ||
1369 | return size; | ||
1370 | } | ||
1371 | |||
1372 | static void test_case_failed(const char *message) | ||
1373 | { | ||
1374 | test_case_cleanup(); | ||
1375 | |||
1376 | pr_err("FAIL: %s\n", message); | ||
1377 | pr_err("FAIL: Test %s\n", current_title); | ||
1378 | pr_err("FAIL: Scenario %d\n", test_case_run_count >> 1); | ||
1379 | } | ||
1380 | |||
1381 | static unsigned long next_instruction(unsigned long pc) | ||
1382 | { | ||
1383 | #ifdef CONFIG_THUMB2_KERNEL | ||
1384 | if ((pc & 1) && !is_wide_instruction(*(u16 *)(pc - 1))) | ||
1385 | return pc + 2; | ||
1386 | else | ||
1387 | #endif | ||
1388 | return pc + 4; | ||
1389 | } | ||
1390 | |||
1391 | static uintptr_t __used kprobes_test_case_start(const char *title, void *stack) | ||
1392 | { | ||
1393 | struct test_arg *args; | ||
1394 | struct test_arg_end *end_arg; | ||
1395 | unsigned long test_code; | ||
1396 | |||
1397 | args = (struct test_arg *)PTR_ALIGN(title + strlen(title) + 1, 4); | ||
1398 | |||
1399 | current_title = title; | ||
1400 | current_args = args; | ||
1401 | current_stack = stack; | ||
1402 | |||
1403 | ++test_try_count; | ||
1404 | |||
1405 | while (args->type != ARG_TYPE_END) | ||
1406 | ++args; | ||
1407 | end_arg = (struct test_arg_end *)args; | ||
1408 | |||
1409 | test_code = (unsigned long)(args + 1); /* Code starts after args */ | ||
1410 | |||
1411 | test_case_is_thumb = end_arg->flags & ARG_FLAG_THUMB; | ||
1412 | if (test_case_is_thumb) | ||
1413 | test_code |= 1; | ||
1414 | |||
1415 | current_code_start = test_code; | ||
1416 | |||
1417 | current_branch_target = 0; | ||
1418 | if (end_arg->branch_offset != end_arg->end_offset) | ||
1419 | current_branch_target = test_code + end_arg->branch_offset; | ||
1420 | |||
1421 | test_code += end_arg->code_offset; | ||
1422 | test_before_probe.kprobe.addr = (kprobe_opcode_t *)test_code; | ||
1423 | |||
1424 | test_code = next_instruction(test_code); | ||
1425 | test_case_probe.kprobe.addr = (kprobe_opcode_t *)test_code; | ||
1426 | |||
1427 | if (test_case_is_thumb) { | ||
1428 | u16 *p = (u16 *)(test_code & ~1); | ||
1429 | current_instruction = p[0]; | ||
1430 | if (is_wide_instruction(current_instruction)) { | ||
1431 | current_instruction <<= 16; | ||
1432 | current_instruction |= p[1]; | ||
1433 | } | ||
1434 | } else { | ||
1435 | current_instruction = *(u32 *)test_code; | ||
1436 | } | ||
1437 | |||
1438 | if (current_title[0] == '.') | ||
1439 | verbose("%s\n", current_title); | ||
1440 | else | ||
1441 | verbose("%s\t@ %0*x\n", current_title, | ||
1442 | test_case_is_thumb ? 4 : 8, | ||
1443 | current_instruction); | ||
1444 | |||
1445 | test_code = next_instruction(test_code); | ||
1446 | test_after_probe.kprobe.addr = (kprobe_opcode_t *)test_code; | ||
1447 | |||
1448 | if (kprobe_test_flags & TEST_FLAG_NARROW_INSTR) { | ||
1449 | if (!test_case_is_thumb || | ||
1450 | is_wide_instruction(current_instruction)) { | ||
1451 | test_case_failed("expected 16-bit instruction"); | ||
1452 | goto fail; | ||
1453 | } | ||
1454 | } else { | ||
1455 | if (test_case_is_thumb && | ||
1456 | !is_wide_instruction(current_instruction)) { | ||
1457 | test_case_failed("expected 32-bit instruction"); | ||
1458 | goto fail; | ||
1459 | } | ||
1460 | } | ||
1461 | |||
1462 | coverage_add(current_instruction); | ||
1463 | |||
1464 | if (end_arg->flags & ARG_FLAG_UNSUPPORTED) { | ||
1465 | if (register_test_probe(&test_case_probe) < 0) | ||
1466 | goto pass; | ||
1467 | test_case_failed("registered probe for unsupported instruction"); | ||
1468 | goto fail; | ||
1469 | } | ||
1470 | |||
1471 | if (end_arg->flags & ARG_FLAG_SUPPORTED) { | ||
1472 | if (register_test_probe(&test_case_probe) >= 0) | ||
1473 | goto pass; | ||
1474 | test_case_failed("couldn't register probe for supported instruction"); | ||
1475 | goto fail; | ||
1476 | } | ||
1477 | |||
1478 | if (register_test_probe(&test_before_probe) < 0) { | ||
1479 | test_case_failed("register test_before_probe failed"); | ||
1480 | goto fail; | ||
1481 | } | ||
1482 | if (register_test_probe(&test_after_probe) < 0) { | ||
1483 | test_case_failed("register test_after_probe failed"); | ||
1484 | goto fail; | ||
1485 | } | ||
1486 | if (current_branch_target) { | ||
1487 | test_after2_probe.kprobe.addr = | ||
1488 | (kprobe_opcode_t *)current_branch_target; | ||
1489 | if (register_test_probe(&test_after2_probe) < 0) { | ||
1490 | test_case_failed("register test_after2_probe failed"); | ||
1491 | goto fail; | ||
1492 | } | ||
1493 | } | ||
1494 | |||
1495 | /* Start first run of test case */ | ||
1496 | test_case_run_count = 0; | ||
1497 | ++test_instance; | ||
1498 | return current_code_start; | ||
1499 | pass: | ||
1500 | test_case_run_count = TEST_CASE_PASSED; | ||
1501 | return (uintptr_t)test_after_probe.kprobe.addr; | ||
1502 | fail: | ||
1503 | test_case_run_count = TEST_CASE_FAILED; | ||
1504 | return (uintptr_t)test_after_probe.kprobe.addr; | ||
1505 | } | ||
1506 | |||
1507 | static bool check_test_results(void) | ||
1508 | { | ||
1509 | size_t mem_size = 0; | ||
1510 | u32 *mem = 0; | ||
1511 | |||
1512 | if (memcmp(&expected_regs, &result_regs, sizeof(expected_regs))) { | ||
1513 | test_case_failed("registers differ"); | ||
1514 | goto fail; | ||
1515 | } | ||
1516 | |||
1517 | if (memory_needs_checking) { | ||
1518 | mem = (u32 *)result_regs.ARM_sp; | ||
1519 | mem_size = expected_memory_size(mem); | ||
1520 | if (memcmp(expected_memory, mem, mem_size)) { | ||
1521 | test_case_failed("test memory differs"); | ||
1522 | goto fail; | ||
1523 | } | ||
1524 | } | ||
1525 | |||
1526 | return true; | ||
1527 | |||
1528 | fail: | ||
1529 | pr_err("initial_regs:\n"); | ||
1530 | print_registers(&initial_regs); | ||
1531 | pr_err("expected_regs:\n"); | ||
1532 | print_registers(&expected_regs); | ||
1533 | pr_err("result_regs:\n"); | ||
1534 | print_registers(&result_regs); | ||
1535 | |||
1536 | if (mem) { | ||
1537 | pr_err("current_stack=%p\n", current_stack); | ||
1538 | pr_err("expected_memory:\n"); | ||
1539 | print_memory(expected_memory, mem_size); | ||
1540 | pr_err("result_memory:\n"); | ||
1541 | print_memory(mem, mem_size); | ||
1542 | } | ||
1543 | |||
1544 | return false; | ||
1545 | } | ||
1546 | |||
1547 | static uintptr_t __used kprobes_test_case_end(void) | ||
1548 | { | ||
1549 | if (test_case_run_count < 0) { | ||
1550 | if (test_case_run_count == TEST_CASE_PASSED) | ||
1551 | /* kprobes_test_case_start did all the needed testing */ | ||
1552 | goto pass; | ||
1553 | else | ||
1554 | /* kprobes_test_case_start failed */ | ||
1555 | goto fail; | ||
1556 | } | ||
1557 | |||
1558 | if (test_before_probe.hit != test_instance) { | ||
1559 | test_case_failed("test_before_handler not run"); | ||
1560 | goto fail; | ||
1561 | } | ||
1562 | |||
1563 | if (test_after_probe.hit != test_instance && | ||
1564 | test_after2_probe.hit != test_instance) { | ||
1565 | test_case_failed("test_after_handler not run"); | ||
1566 | goto fail; | ||
1567 | } | ||
1568 | |||
1569 | /* | ||
1570 | * Even numbered test runs ran without a probe on the test case so | ||
1571 | * we can gather reference results. The subsequent odd numbered run | ||
1572 | * will have the probe inserted. | ||
1573 | */ | ||
1574 | if ((test_case_run_count & 1) == 0) { | ||
1575 | /* Save results from run without probe */ | ||
1576 | u32 *mem = (u32 *)result_regs.ARM_sp; | ||
1577 | expected_regs = result_regs; | ||
1578 | memcpy(expected_memory, mem, expected_memory_size(mem)); | ||
1579 | |||
1580 | /* Insert probe onto test case instruction */ | ||
1581 | if (register_test_probe(&test_case_probe) < 0) { | ||
1582 | test_case_failed("register test_case_probe failed"); | ||
1583 | goto fail; | ||
1584 | } | ||
1585 | } else { | ||
1586 | /* Check probe ran as expected */ | ||
1587 | if (probe_should_run == 1) { | ||
1588 | if (test_case_probe.hit != test_instance) { | ||
1589 | test_case_failed("test_case_handler not run"); | ||
1590 | goto fail; | ||
1591 | } | ||
1592 | } else if (probe_should_run == 0) { | ||
1593 | if (test_case_probe.hit == test_instance) { | ||
1594 | test_case_failed("test_case_handler ran"); | ||
1595 | goto fail; | ||
1596 | } | ||
1597 | } | ||
1598 | |||
1599 | /* Remove probe for any subsequent reference run */ | ||
1600 | unregister_test_probe(&test_case_probe); | ||
1601 | |||
1602 | if (!check_test_results()) | ||
1603 | goto fail; | ||
1604 | |||
1605 | if (is_last_scenario) | ||
1606 | goto pass; | ||
1607 | } | ||
1608 | |||
1609 | /* Do next test run */ | ||
1610 | ++test_case_run_count; | ||
1611 | ++test_instance; | ||
1612 | return current_code_start; | ||
1613 | fail: | ||
1614 | ++test_fail_count; | ||
1615 | goto end; | ||
1616 | pass: | ||
1617 | ++test_pass_count; | ||
1618 | end: | ||
1619 | test_case_cleanup(); | ||
1620 | return 0; | ||
1621 | } | ||
1622 | |||
1623 | |||
1624 | /* | ||
1625 | * Top level test functions | ||
1626 | */ | ||
1627 | |||
1628 | static int run_test_cases(void (*tests)(void), const union decode_item *table) | ||
1629 | { | ||
1630 | int ret; | ||
1631 | |||
1632 | pr_info(" Check decoding tables\n"); | ||
1633 | ret = table_test(table); | ||
1634 | if (ret) | ||
1635 | return ret; | ||
1636 | |||
1637 | pr_info(" Run test cases\n"); | ||
1638 | ret = coverage_start(table); | ||
1639 | if (ret) | ||
1640 | return ret; | ||
1641 | |||
1642 | tests(); | ||
1643 | |||
1644 | coverage_end(); | ||
1645 | return 0; | ||
1646 | } | ||
1647 | |||
1648 | |||
1649 | static int __init run_all_tests(void) | ||
1650 | { | ||
1651 | int ret = 0; | ||
1652 | |||
1653 | pr_info("Begining kprobe tests...\n"); | ||
1654 | |||
1655 | #ifndef CONFIG_THUMB2_KERNEL | ||
1656 | |||
1657 | pr_info("Probe ARM code\n"); | ||
1658 | ret = run_api_tests(arm_func); | ||
1659 | if (ret) | ||
1660 | goto out; | ||
1661 | |||
1662 | pr_info("ARM instruction simulation\n"); | ||
1663 | ret = run_test_cases(kprobe_arm_test_cases, kprobe_decode_arm_table); | ||
1664 | if (ret) | ||
1665 | goto out; | ||
1666 | |||
1667 | #else /* CONFIG_THUMB2_KERNEL */ | ||
1668 | |||
1669 | pr_info("Probe 16-bit Thumb code\n"); | ||
1670 | ret = run_api_tests(thumb16_func); | ||
1671 | if (ret) | ||
1672 | goto out; | ||
1673 | |||
1674 | pr_info("Probe 32-bit Thumb code, even halfword\n"); | ||
1675 | ret = run_api_tests(thumb32even_func); | ||
1676 | if (ret) | ||
1677 | goto out; | ||
1678 | |||
1679 | pr_info("Probe 32-bit Thumb code, odd halfword\n"); | ||
1680 | ret = run_api_tests(thumb32odd_func); | ||
1681 | if (ret) | ||
1682 | goto out; | ||
1683 | |||
1684 | pr_info("16-bit Thumb instruction simulation\n"); | ||
1685 | ret = run_test_cases(kprobe_thumb16_test_cases, | ||
1686 | kprobe_decode_thumb16_table); | ||
1687 | if (ret) | ||
1688 | goto out; | ||
1689 | |||
1690 | pr_info("32-bit Thumb instruction simulation\n"); | ||
1691 | ret = run_test_cases(kprobe_thumb32_test_cases, | ||
1692 | kprobe_decode_thumb32_table); | ||
1693 | if (ret) | ||
1694 | goto out; | ||
1695 | #endif | ||
1696 | |||
1697 | pr_info("Total instruction simulation tests=%d, pass=%d fail=%d\n", | ||
1698 | test_try_count, test_pass_count, test_fail_count); | ||
1699 | if (test_fail_count) { | ||
1700 | ret = -EINVAL; | ||
1701 | goto out; | ||
1702 | } | ||
1703 | |||
1704 | #if BENCHMARKING | ||
1705 | pr_info("Benchmarks\n"); | ||
1706 | ret = run_benchmarks(); | ||
1707 | if (ret) | ||
1708 | goto out; | ||
1709 | #endif | ||
1710 | |||
1711 | #if __LINUX_ARM_ARCH__ >= 7 | ||
1712 | /* We are able to run all test cases so coverage should be complete */ | ||
1713 | if (coverage_fail) { | ||
1714 | pr_err("FAIL: Test coverage checks failed\n"); | ||
1715 | ret = -EINVAL; | ||
1716 | goto out; | ||
1717 | } | ||
1718 | #endif | ||
1719 | |||
1720 | out: | ||
1721 | if (ret == 0) | ||
1722 | pr_info("Finished kprobe tests OK\n"); | ||
1723 | else | ||
1724 | pr_err("kprobe tests failed\n"); | ||
1725 | |||
1726 | return ret; | ||
1727 | } | ||
1728 | |||
1729 | |||
1730 | /* | ||
1731 | * Module setup | ||
1732 | */ | ||
1733 | |||
1734 | #ifdef MODULE | ||
1735 | |||
1736 | static void __exit kprobe_test_exit(void) | ||
1737 | { | ||
1738 | } | ||
1739 | |||
1740 | module_init(run_all_tests) | ||
1741 | module_exit(kprobe_test_exit) | ||
1742 | MODULE_LICENSE("GPL"); | ||
1743 | |||
1744 | #else /* !MODULE */ | ||
1745 | |||
1746 | late_initcall(run_all_tests); | ||
1747 | |||
1748 | #endif | ||
diff --git a/arch/arm/kernel/kprobes-test.h b/arch/arm/kernel/kprobes-test.h new file mode 100644 index 000000000000..0dc5d77b9356 --- /dev/null +++ b/arch/arm/kernel/kprobes-test.h | |||
@@ -0,0 +1,392 @@ | |||
1 | /* | ||
2 | * arch/arm/kernel/kprobes-test.h | ||
3 | * | ||
4 | * Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #define VERBOSE 0 /* Set to '1' for more logging of test cases */ | ||
12 | |||
13 | #ifdef CONFIG_THUMB2_KERNEL | ||
14 | #define NORMAL_ISA "16" | ||
15 | #else | ||
16 | #define NORMAL_ISA "32" | ||
17 | #endif | ||
18 | |||
19 | |||
20 | /* Flags used in kprobe_test_flags */ | ||
21 | #define TEST_FLAG_NO_ITBLOCK (1<<0) | ||
22 | #define TEST_FLAG_FULL_ITBLOCK (1<<1) | ||
23 | #define TEST_FLAG_NARROW_INSTR (1<<2) | ||
24 | |||
25 | extern int kprobe_test_flags; | ||
26 | extern int kprobe_test_cc_position; | ||
27 | |||
28 | |||
29 | #define TEST_MEMORY_SIZE 256 | ||
30 | |||
31 | |||
32 | /* | ||
33 | * Test case structures. | ||
34 | * | ||
35 | * The arguments given to test cases can be one of three types. | ||
36 | * | ||
37 | * ARG_TYPE_REG | ||
38 | * Load a register with the given value. | ||
39 | * | ||
40 | * ARG_TYPE_PTR | ||
41 | * Load a register with a pointer into the stack buffer (SP + given value). | ||
42 | * | ||
43 | * ARG_TYPE_MEM | ||
44 | * Store the given value into the stack buffer at [SP+index]. | ||
45 | * | ||
46 | */ | ||
47 | |||
48 | #define ARG_TYPE_END 0 | ||
49 | #define ARG_TYPE_REG 1 | ||
50 | #define ARG_TYPE_PTR 2 | ||
51 | #define ARG_TYPE_MEM 3 | ||
52 | |||
53 | #define ARG_FLAG_UNSUPPORTED 0x01 | ||
54 | #define ARG_FLAG_SUPPORTED 0x02 | ||
55 | #define ARG_FLAG_THUMB 0x10 /* Must be 16 so TEST_ISA can be used */ | ||
56 | #define ARG_FLAG_ARM 0x20 /* Must be 32 so TEST_ISA can be used */ | ||
57 | |||
58 | struct test_arg { | ||
59 | u8 type; /* ARG_TYPE_x */ | ||
60 | u8 _padding[7]; | ||
61 | }; | ||
62 | |||
63 | struct test_arg_regptr { | ||
64 | u8 type; /* ARG_TYPE_REG or ARG_TYPE_PTR */ | ||
65 | u8 reg; | ||
66 | u8 _padding[2]; | ||
67 | u32 val; | ||
68 | }; | ||
69 | |||
70 | struct test_arg_mem { | ||
71 | u8 type; /* ARG_TYPE_MEM */ | ||
72 | u8 index; | ||
73 | u8 _padding[2]; | ||
74 | u32 val; | ||
75 | }; | ||
76 | |||
77 | struct test_arg_end { | ||
78 | u8 type; /* ARG_TYPE_END */ | ||
79 | u8 flags; /* ARG_FLAG_x */ | ||
80 | u16 code_offset; | ||
81 | u16 branch_offset; | ||
82 | u16 end_offset; | ||
83 | }; | ||
84 | |||
85 | |||
86 | /* | ||
87 | * Building blocks for test cases. | ||
88 | * | ||
89 | * Each test case is wrapped between TESTCASE_START and TESTCASE_END. | ||
90 | * | ||
91 | * To specify arguments for a test case the TEST_ARG_{REG,PTR,MEM} macros are | ||
92 | * used followed by a terminating TEST_ARG_END. | ||
93 | * | ||
94 | * After this, the instruction to be tested is defined with TEST_INSTRUCTION. | ||
95 | * Or for branches, TEST_BRANCH_B and TEST_BRANCH_F (branch forwards/backwards). | ||
96 | * | ||
97 | * Some specific test cases may make use of other custom constructs. | ||
98 | */ | ||
99 | |||
100 | #if VERBOSE | ||
101 | #define verbose(fmt, ...) pr_info(fmt, ##__VA_ARGS__) | ||
102 | #else | ||
103 | #define verbose(fmt, ...) | ||
104 | #endif | ||
105 | |||
106 | #define TEST_GROUP(title) \ | ||
107 | verbose("\n"); \ | ||
108 | verbose(title"\n"); \ | ||
109 | verbose("---------------------------------------------------------\n"); | ||
110 | |||
111 | #define TESTCASE_START(title) \ | ||
112 | __asm__ __volatile__ ( \ | ||
113 | "bl __kprobes_test_case_start \n\t" \ | ||
114 | /* don't use .asciz here as 'title' may be */ \ | ||
115 | /* multiple strings to be concatenated. */ \ | ||
116 | ".ascii "#title" \n\t" \ | ||
117 | ".byte 0 \n\t" \ | ||
118 | ".align 2 \n\t" | ||
119 | |||
120 | #define TEST_ARG_REG(reg, val) \ | ||
121 | ".byte "__stringify(ARG_TYPE_REG)" \n\t" \ | ||
122 | ".byte "#reg" \n\t" \ | ||
123 | ".short 0 \n\t" \ | ||
124 | ".word "#val" \n\t" | ||
125 | |||
126 | #define TEST_ARG_PTR(reg, val) \ | ||
127 | ".byte "__stringify(ARG_TYPE_PTR)" \n\t" \ | ||
128 | ".byte "#reg" \n\t" \ | ||
129 | ".short 0 \n\t" \ | ||
130 | ".word "#val" \n\t" | ||
131 | |||
132 | #define TEST_ARG_MEM(index, val) \ | ||
133 | ".byte "__stringify(ARG_TYPE_MEM)" \n\t" \ | ||
134 | ".byte "#index" \n\t" \ | ||
135 | ".short 0 \n\t" \ | ||
136 | ".word "#val" \n\t" | ||
137 | |||
138 | #define TEST_ARG_END(flags) \ | ||
139 | ".byte "__stringify(ARG_TYPE_END)" \n\t" \ | ||
140 | ".byte "TEST_ISA flags" \n\t" \ | ||
141 | ".short 50f-0f \n\t" \ | ||
142 | ".short 2f-0f \n\t" \ | ||
143 | ".short 99f-0f \n\t" \ | ||
144 | ".code "TEST_ISA" \n\t" \ | ||
145 | "0: \n\t" | ||
146 | |||
147 | #define TEST_INSTRUCTION(instruction) \ | ||
148 | "50: nop \n\t" \ | ||
149 | "1: "instruction" \n\t" \ | ||
150 | " nop \n\t" | ||
151 | |||
152 | #define TEST_BRANCH_F(instruction, xtra_dist) \ | ||
153 | TEST_INSTRUCTION(instruction) \ | ||
154 | ".if "#xtra_dist" \n\t" \ | ||
155 | " b 99f \n\t" \ | ||
156 | ".space "#xtra_dist" \n\t" \ | ||
157 | ".endif \n\t" \ | ||
158 | " b 99f \n\t" \ | ||
159 | "2: nop \n\t" | ||
160 | |||
161 | #define TEST_BRANCH_B(instruction, xtra_dist) \ | ||
162 | " b 50f \n\t" \ | ||
163 | " b 99f \n\t" \ | ||
164 | "2: nop \n\t" \ | ||
165 | " b 99f \n\t" \ | ||
166 | ".if "#xtra_dist" \n\t" \ | ||
167 | ".space "#xtra_dist" \n\t" \ | ||
168 | ".endif \n\t" \ | ||
169 | TEST_INSTRUCTION(instruction) | ||
170 | |||
171 | #define TESTCASE_END \ | ||
172 | "2: \n\t" \ | ||
173 | "99: \n\t" \ | ||
174 | " bl __kprobes_test_case_end_"TEST_ISA" \n\t" \ | ||
175 | ".code "NORMAL_ISA" \n\t" \ | ||
176 | : : \ | ||
177 | : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" \ | ||
178 | ); | ||
179 | |||
180 | |||
181 | /* | ||
182 | * Macros to define test cases. | ||
183 | * | ||
184 | * Those of the form TEST_{R,P,M}* can be used to define test cases | ||
185 | * which take combinations of the three basic types of arguments. E.g. | ||
186 | * | ||
187 | * TEST_R One register argument | ||
188 | * TEST_RR Two register arguments | ||
189 | * TEST_RPR A register, a pointer, then a register argument | ||
190 | * | ||
191 | * For testing instructions which may branch, there are macros TEST_BF_* | ||
192 | * and TEST_BB_* for branching forwards and backwards. | ||
193 | * | ||
194 | * TEST_SUPPORTED and TEST_UNSUPPORTED don't cause the code to be executed, | ||
195 | * the just verify that a kprobe is or is not allowed on the given instruction. | ||
196 | */ | ||
197 | |||
198 | #define TEST(code) \ | ||
199 | TESTCASE_START(code) \ | ||
200 | TEST_ARG_END("") \ | ||
201 | TEST_INSTRUCTION(code) \ | ||
202 | TESTCASE_END | ||
203 | |||
204 | #define TEST_UNSUPPORTED(code) \ | ||
205 | TESTCASE_START(code) \ | ||
206 | TEST_ARG_END("|"__stringify(ARG_FLAG_UNSUPPORTED)) \ | ||
207 | TEST_INSTRUCTION(code) \ | ||
208 | TESTCASE_END | ||
209 | |||
210 | #define TEST_SUPPORTED(code) \ | ||
211 | TESTCASE_START(code) \ | ||
212 | TEST_ARG_END("|"__stringify(ARG_FLAG_SUPPORTED)) \ | ||
213 | TEST_INSTRUCTION(code) \ | ||
214 | TESTCASE_END | ||
215 | |||
216 | #define TEST_R(code1, reg, val, code2) \ | ||
217 | TESTCASE_START(code1 #reg code2) \ | ||
218 | TEST_ARG_REG(reg, val) \ | ||
219 | TEST_ARG_END("") \ | ||
220 | TEST_INSTRUCTION(code1 #reg code2) \ | ||
221 | TESTCASE_END | ||
222 | |||
223 | #define TEST_RR(code1, reg1, val1, code2, reg2, val2, code3) \ | ||
224 | TESTCASE_START(code1 #reg1 code2 #reg2 code3) \ | ||
225 | TEST_ARG_REG(reg1, val1) \ | ||
226 | TEST_ARG_REG(reg2, val2) \ | ||
227 | TEST_ARG_END("") \ | ||
228 | TEST_INSTRUCTION(code1 #reg1 code2 #reg2 code3) \ | ||
229 | TESTCASE_END | ||
230 | |||
231 | #define TEST_RRR(code1, reg1, val1, code2, reg2, val2, code3, reg3, val3, code4)\ | ||
232 | TESTCASE_START(code1 #reg1 code2 #reg2 code3 #reg3 code4) \ | ||
233 | TEST_ARG_REG(reg1, val1) \ | ||
234 | TEST_ARG_REG(reg2, val2) \ | ||
235 | TEST_ARG_REG(reg3, val3) \ | ||
236 | TEST_ARG_END("") \ | ||
237 | TEST_INSTRUCTION(code1 #reg1 code2 #reg2 code3 #reg3 code4) \ | ||
238 | TESTCASE_END | ||
239 | |||
240 | #define TEST_RRRR(code1, reg1, val1, code2, reg2, val2, code3, reg3, val3, code4, reg4, val4) \ | ||
241 | TESTCASE_START(code1 #reg1 code2 #reg2 code3 #reg3 code4 #reg4) \ | ||
242 | TEST_ARG_REG(reg1, val1) \ | ||
243 | TEST_ARG_REG(reg2, val2) \ | ||
244 | TEST_ARG_REG(reg3, val3) \ | ||
245 | TEST_ARG_REG(reg4, val4) \ | ||
246 | TEST_ARG_END("") \ | ||
247 | TEST_INSTRUCTION(code1 #reg1 code2 #reg2 code3 #reg3 code4 #reg4) \ | ||
248 | TESTCASE_END | ||
249 | |||
250 | #define TEST_P(code1, reg1, val1, code2) \ | ||
251 | TESTCASE_START(code1 #reg1 code2) \ | ||
252 | TEST_ARG_PTR(reg1, val1) \ | ||
253 | TEST_ARG_END("") \ | ||
254 | TEST_INSTRUCTION(code1 #reg1 code2) \ | ||
255 | TESTCASE_END | ||
256 | |||
257 | #define TEST_PR(code1, reg1, val1, code2, reg2, val2, code3) \ | ||
258 | TESTCASE_START(code1 #reg1 code2 #reg2 code3) \ | ||
259 | TEST_ARG_PTR(reg1, val1) \ | ||
260 | TEST_ARG_REG(reg2, val2) \ | ||
261 | TEST_ARG_END("") \ | ||
262 | TEST_INSTRUCTION(code1 #reg1 code2 #reg2 code3) \ | ||
263 | TESTCASE_END | ||
264 | |||
265 | #define TEST_RP(code1, reg1, val1, code2, reg2, val2, code3) \ | ||
266 | TESTCASE_START(code1 #reg1 code2 #reg2 code3) \ | ||
267 | TEST_ARG_REG(reg1, val1) \ | ||
268 | TEST_ARG_PTR(reg2, val2) \ | ||
269 | TEST_ARG_END("") \ | ||
270 | TEST_INSTRUCTION(code1 #reg1 code2 #reg2 code3) \ | ||
271 | TESTCASE_END | ||
272 | |||
273 | #define TEST_PRR(code1, reg1, val1, code2, reg2, val2, code3, reg3, val3, code4)\ | ||
274 | TESTCASE_START(code1 #reg1 code2 #reg2 code3 #reg3 code4) \ | ||
275 | TEST_ARG_PTR(reg1, val1) \ | ||
276 | TEST_ARG_REG(reg2, val2) \ | ||
277 | TEST_ARG_REG(reg3, val3) \ | ||
278 | TEST_ARG_END("") \ | ||
279 | TEST_INSTRUCTION(code1 #reg1 code2 #reg2 code3 #reg3 code4) \ | ||
280 | TESTCASE_END | ||
281 | |||
282 | #define TEST_RPR(code1, reg1, val1, code2, reg2, val2, code3, reg3, val3, code4)\ | ||
283 | TESTCASE_START(code1 #reg1 code2 #reg2 code3 #reg3 code4) \ | ||
284 | TEST_ARG_REG(reg1, val1) \ | ||
285 | TEST_ARG_PTR(reg2, val2) \ | ||
286 | TEST_ARG_REG(reg3, val3) \ | ||
287 | TEST_ARG_END("") \ | ||
288 | TEST_INSTRUCTION(code1 #reg1 code2 #reg2 code3 #reg3 code4) \ | ||
289 | TESTCASE_END | ||
290 | |||
291 | #define TEST_RRP(code1, reg1, val1, code2, reg2, val2, code3, reg3, val3, code4)\ | ||
292 | TESTCASE_START(code1 #reg1 code2 #reg2 code3 #reg3 code4) \ | ||
293 | TEST_ARG_REG(reg1, val1) \ | ||
294 | TEST_ARG_REG(reg2, val2) \ | ||
295 | TEST_ARG_PTR(reg3, val3) \ | ||
296 | TEST_ARG_END("") \ | ||
297 | TEST_INSTRUCTION(code1 #reg1 code2 #reg2 code3 #reg3 code4) \ | ||
298 | TESTCASE_END | ||
299 | |||
300 | #define TEST_BF_P(code1, reg1, val1, code2) \ | ||
301 | TESTCASE_START(code1 #reg1 code2) \ | ||
302 | TEST_ARG_PTR(reg1, val1) \ | ||
303 | TEST_ARG_END("") \ | ||
304 | TEST_BRANCH_F(code1 #reg1 code2, 0) \ | ||
305 | TESTCASE_END | ||
306 | |||
307 | #define TEST_BF_X(code, xtra_dist) \ | ||
308 | TESTCASE_START(code) \ | ||
309 | TEST_ARG_END("") \ | ||
310 | TEST_BRANCH_F(code, xtra_dist) \ | ||
311 | TESTCASE_END | ||
312 | |||
313 | #define TEST_BB_X(code, xtra_dist) \ | ||
314 | TESTCASE_START(code) \ | ||
315 | TEST_ARG_END("") \ | ||
316 | TEST_BRANCH_B(code, xtra_dist) \ | ||
317 | TESTCASE_END | ||
318 | |||
319 | #define TEST_BF_RX(code1, reg, val, code2, xtra_dist) \ | ||
320 | TESTCASE_START(code1 #reg code2) \ | ||
321 | TEST_ARG_REG(reg, val) \ | ||
322 | TEST_ARG_END("") \ | ||
323 | TEST_BRANCH_F(code1 #reg code2, xtra_dist) \ | ||
324 | TESTCASE_END | ||
325 | |||
326 | #define TEST_BB_RX(code1, reg, val, code2, xtra_dist) \ | ||
327 | TESTCASE_START(code1 #reg code2) \ | ||
328 | TEST_ARG_REG(reg, val) \ | ||
329 | TEST_ARG_END("") \ | ||
330 | TEST_BRANCH_B(code1 #reg code2, xtra_dist) \ | ||
331 | TESTCASE_END | ||
332 | |||
333 | #define TEST_BF(code) TEST_BF_X(code, 0) | ||
334 | #define TEST_BB(code) TEST_BB_X(code, 0) | ||
335 | |||
336 | #define TEST_BF_R(code1, reg, val, code2) TEST_BF_RX(code1, reg, val, code2, 0) | ||
337 | #define TEST_BB_R(code1, reg, val, code2) TEST_BB_RX(code1, reg, val, code2, 0) | ||
338 | |||
339 | #define TEST_BF_RR(code1, reg1, val1, code2, reg2, val2, code3) \ | ||
340 | TESTCASE_START(code1 #reg1 code2 #reg2 code3) \ | ||
341 | TEST_ARG_REG(reg1, val1) \ | ||
342 | TEST_ARG_REG(reg2, val2) \ | ||
343 | TEST_ARG_END("") \ | ||
344 | TEST_BRANCH_F(code1 #reg1 code2 #reg2 code3, 0) \ | ||
345 | TESTCASE_END | ||
346 | |||
347 | #define TEST_X(code, codex) \ | ||
348 | TESTCASE_START(code) \ | ||
349 | TEST_ARG_END("") \ | ||
350 | TEST_INSTRUCTION(code) \ | ||
351 | " b 99f \n\t" \ | ||
352 | " "codex" \n\t" \ | ||
353 | TESTCASE_END | ||
354 | |||
355 | #define TEST_RX(code1, reg, val, code2, codex) \ | ||
356 | TESTCASE_START(code1 #reg code2) \ | ||
357 | TEST_ARG_REG(reg, val) \ | ||
358 | TEST_ARG_END("") \ | ||
359 | TEST_INSTRUCTION(code1 __stringify(reg) code2) \ | ||
360 | " b 99f \n\t" \ | ||
361 | " "codex" \n\t" \ | ||
362 | TESTCASE_END | ||
363 | |||
364 | #define TEST_RRX(code1, reg1, val1, code2, reg2, val2, code3, codex) \ | ||
365 | TESTCASE_START(code1 #reg1 code2 #reg2 code3) \ | ||
366 | TEST_ARG_REG(reg1, val1) \ | ||
367 | TEST_ARG_REG(reg2, val2) \ | ||
368 | TEST_ARG_END("") \ | ||
369 | TEST_INSTRUCTION(code1 __stringify(reg1) code2 __stringify(reg2) code3) \ | ||
370 | " b 99f \n\t" \ | ||
371 | " "codex" \n\t" \ | ||
372 | TESTCASE_END | ||
373 | |||
374 | |||
375 | /* Various values used in test cases... */ | ||
376 | #define N(val) (val ^ 0xffffffff) | ||
377 | #define VAL1 0x12345678 | ||
378 | #define VAL2 N(VAL1) | ||
379 | #define VAL3 0xa5f801 | ||
380 | #define VAL4 N(VAL3) | ||
381 | #define VALM 0x456789ab | ||
382 | #define VALR 0xdeaddead | ||
383 | #define HH1 0x0123fecb | ||
384 | #define HH2 0xa9874567 | ||
385 | |||
386 | |||
387 | #ifdef CONFIG_THUMB2_KERNEL | ||
388 | void kprobe_thumb16_test_cases(void); | ||
389 | void kprobe_thumb32_test_cases(void); | ||
390 | #else | ||
391 | void kprobe_arm_test_cases(void); | ||
392 | #endif | ||
diff --git a/arch/arm/kernel/kprobes-thumb.c b/arch/arm/kernel/kprobes-thumb.c index 902ca59e8b11..8f96ec778e8d 100644 --- a/arch/arm/kernel/kprobes-thumb.c +++ b/arch/arm/kernel/kprobes-thumb.c | |||
@@ -10,6 +10,7 @@ | |||
10 | 10 | ||
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/kprobes.h> | 12 | #include <linux/kprobes.h> |
13 | #include <linux/module.h> | ||
13 | 14 | ||
14 | #include "kprobes.h" | 15 | #include "kprobes.h" |
15 | 16 | ||
@@ -943,6 +944,9 @@ const union decode_item kprobe_decode_thumb32_table[] = { | |||
943 | */ | 944 | */ |
944 | DECODE_END | 945 | DECODE_END |
945 | }; | 946 | }; |
947 | #ifdef CONFIG_ARM_KPROBES_TEST_MODULE | ||
948 | EXPORT_SYMBOL_GPL(kprobe_decode_thumb32_table); | ||
949 | #endif | ||
946 | 950 | ||
947 | static void __kprobes | 951 | static void __kprobes |
948 | t16_simulate_bxblx(struct kprobe *p, struct pt_regs *regs) | 952 | t16_simulate_bxblx(struct kprobe *p, struct pt_regs *regs) |
@@ -1423,6 +1427,9 @@ const union decode_item kprobe_decode_thumb16_table[] = { | |||
1423 | 1427 | ||
1424 | DECODE_END | 1428 | DECODE_END |
1425 | }; | 1429 | }; |
1430 | #ifdef CONFIG_ARM_KPROBES_TEST_MODULE | ||
1431 | EXPORT_SYMBOL_GPL(kprobe_decode_thumb16_table); | ||
1432 | #endif | ||
1426 | 1433 | ||
1427 | static unsigned long __kprobes thumb_check_cc(unsigned long cpsr) | 1434 | static unsigned long __kprobes thumb_check_cc(unsigned long cpsr) |
1428 | { | 1435 | { |
diff --git a/arch/arm/kernel/kprobes.h b/arch/arm/kernel/kprobes.h index a6aeda0a6c7f..38945f78f9f1 100644 --- a/arch/arm/kernel/kprobes.h +++ b/arch/arm/kernel/kprobes.h | |||
@@ -413,6 +413,14 @@ struct decode_reject { | |||
413 | DECODE_HEADER(DECODE_TYPE_REJECT, _mask, _value, 0) | 413 | DECODE_HEADER(DECODE_TYPE_REJECT, _mask, _value, 0) |
414 | 414 | ||
415 | 415 | ||
416 | #ifdef CONFIG_THUMB2_KERNEL | ||
417 | extern const union decode_item kprobe_decode_thumb16_table[]; | ||
418 | extern const union decode_item kprobe_decode_thumb32_table[]; | ||
419 | #else | ||
420 | extern const union decode_item kprobe_decode_arm_table[]; | ||
421 | #endif | ||
422 | |||
423 | |||
416 | int kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi, | 424 | int kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi, |
417 | const union decode_item *table, bool thumb16); | 425 | const union decode_item *table, bool thumb16); |
418 | 426 | ||
diff --git a/arch/arm/mach-cns3xxx/include/mach/entry-macro.S b/arch/arm/mach-cns3xxx/include/mach/entry-macro.S index 6bd83ed90afe..d87bfc397d39 100644 --- a/arch/arm/mach-cns3xxx/include/mach/entry-macro.S +++ b/arch/arm/mach-cns3xxx/include/mach/entry-macro.S | |||
@@ -8,7 +8,6 @@ | |||
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <mach/hardware.h> | ||
12 | #include <asm/hardware/entry-macro-gic.S> | 11 | #include <asm/hardware/entry-macro-gic.S> |
13 | 12 | ||
14 | .macro disable_fiq | 13 | .macro disable_fiq |
diff --git a/arch/arm/mach-cns3xxx/include/mach/system.h b/arch/arm/mach-cns3xxx/include/mach/system.h index 58bb03ae3cf4..4f16c9b79f78 100644 --- a/arch/arm/mach-cns3xxx/include/mach/system.h +++ b/arch/arm/mach-cns3xxx/include/mach/system.h | |||
@@ -13,7 +13,6 @@ | |||
13 | 13 | ||
14 | #include <linux/io.h> | 14 | #include <linux/io.h> |
15 | #include <asm/proc-fns.h> | 15 | #include <asm/proc-fns.h> |
16 | #include <mach/hardware.h> | ||
17 | 16 | ||
18 | static inline void arch_idle(void) | 17 | static inline void arch_idle(void) |
19 | { | 18 | { |
diff --git a/arch/arm/mach-cns3xxx/include/mach/uncompress.h b/arch/arm/mach-cns3xxx/include/mach/uncompress.h index de8ead9b91f7..a91b6058ab4f 100644 --- a/arch/arm/mach-cns3xxx/include/mach/uncompress.h +++ b/arch/arm/mach-cns3xxx/include/mach/uncompress.h | |||
@@ -8,7 +8,6 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <asm/mach-types.h> | 10 | #include <asm/mach-types.h> |
11 | #include <mach/hardware.h> | ||
12 | #include <mach/cns3xxx.h> | 11 | #include <mach/cns3xxx.h> |
13 | 12 | ||
14 | #define AMBA_UART_DR(base) (*(volatile unsigned char *)((base) + 0x00)) | 13 | #define AMBA_UART_DR(base) (*(volatile unsigned char *)((base) + 0x00)) |
diff --git a/arch/arm/mach-cns3xxx/pcie.c b/arch/arm/mach-cns3xxx/pcie.c index 06fd25d70aec..0f8fca48a5ed 100644 --- a/arch/arm/mach-cns3xxx/pcie.c +++ b/arch/arm/mach-cns3xxx/pcie.c | |||
@@ -49,7 +49,7 @@ static struct cns3xxx_pcie *sysdata_to_cnspci(void *sysdata) | |||
49 | return &cns3xxx_pcie[root->domain]; | 49 | return &cns3xxx_pcie[root->domain]; |
50 | } | 50 | } |
51 | 51 | ||
52 | static struct cns3xxx_pcie *pdev_to_cnspci(struct pci_dev *dev) | 52 | static struct cns3xxx_pcie *pdev_to_cnspci(const struct pci_dev *dev) |
53 | { | 53 | { |
54 | return sysdata_to_cnspci(dev->sysdata); | 54 | return sysdata_to_cnspci(dev->sysdata); |
55 | } | 55 | } |
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c index 85a2c7e1e684..6e41cb5baeb4 100644 --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c | |||
@@ -115,6 +115,32 @@ static struct spi_board_info da850evm_spi_info[] = { | |||
115 | }, | 115 | }, |
116 | }; | 116 | }; |
117 | 117 | ||
118 | #ifdef CONFIG_MTD | ||
119 | static void da850_evm_m25p80_notify_add(struct mtd_info *mtd) | ||
120 | { | ||
121 | char *mac_addr = davinci_soc_info.emac_pdata->mac_addr; | ||
122 | size_t retlen; | ||
123 | |||
124 | if (!strcmp(mtd->name, "MAC-Address")) { | ||
125 | mtd->read(mtd, 0, ETH_ALEN, &retlen, mac_addr); | ||
126 | if (retlen == ETH_ALEN) | ||
127 | pr_info("Read MAC addr from SPI Flash: %pM\n", | ||
128 | mac_addr); | ||
129 | } | ||
130 | } | ||
131 | |||
132 | static struct mtd_notifier da850evm_spi_notifier = { | ||
133 | .add = da850_evm_m25p80_notify_add, | ||
134 | }; | ||
135 | |||
136 | static void da850_evm_setup_mac_addr(void) | ||
137 | { | ||
138 | register_mtd_user(&da850evm_spi_notifier); | ||
139 | } | ||
140 | #else | ||
141 | static void da850_evm_setup_mac_addr(void) { } | ||
142 | #endif | ||
143 | |||
118 | static struct mtd_partition da850_evm_norflash_partition[] = { | 144 | static struct mtd_partition da850_evm_norflash_partition[] = { |
119 | { | 145 | { |
120 | .name = "bootloaders + env", | 146 | .name = "bootloaders + env", |
@@ -1244,6 +1270,8 @@ static __init void da850_evm_init(void) | |||
1244 | if (ret) | 1270 | if (ret) |
1245 | pr_warning("da850_evm_init: sata registration failed: %d\n", | 1271 | pr_warning("da850_evm_init: sata registration failed: %d\n", |
1246 | ret); | 1272 | ret); |
1273 | |||
1274 | da850_evm_setup_mac_addr(); | ||
1247 | } | 1275 | } |
1248 | 1276 | ||
1249 | #ifdef CONFIG_SERIAL_8250_CONSOLE | 1277 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
diff --git a/arch/arm/mach-davinci/include/mach/psc.h b/arch/arm/mach-davinci/include/mach/psc.h index 47fd0bc3d3e7..fa59c097223d 100644 --- a/arch/arm/mach-davinci/include/mach/psc.h +++ b/arch/arm/mach-davinci/include/mach/psc.h | |||
@@ -243,7 +243,7 @@ | |||
243 | #define PSC_STATE_DISABLE 2 | 243 | #define PSC_STATE_DISABLE 2 |
244 | #define PSC_STATE_ENABLE 3 | 244 | #define PSC_STATE_ENABLE 3 |
245 | 245 | ||
246 | #define MDSTAT_STATE_MASK 0x1f | 246 | #define MDSTAT_STATE_MASK 0x3f |
247 | #define MDCTL_FORCE BIT(31) | 247 | #define MDCTL_FORCE BIT(31) |
248 | 248 | ||
249 | #ifndef __ASSEMBLER__ | 249 | #ifndef __ASSEMBLER__ |
diff --git a/arch/arm/mach-davinci/sleep.S b/arch/arm/mach-davinci/sleep.S index fb5e72b532b0..5f1e045a3ad1 100644 --- a/arch/arm/mach-davinci/sleep.S +++ b/arch/arm/mach-davinci/sleep.S | |||
@@ -217,7 +217,11 @@ ddr2clk_stop_done: | |||
217 | ENDPROC(davinci_ddr_psc_config) | 217 | ENDPROC(davinci_ddr_psc_config) |
218 | 218 | ||
219 | CACHE_FLUSH: | 219 | CACHE_FLUSH: |
220 | .word arm926_flush_kern_cache_all | 220 | #ifdef CONFIG_CPU_V6 |
221 | .word v6_flush_kern_cache_all | ||
222 | #else | ||
223 | .word arm926_flush_kern_cache_all | ||
224 | #endif | ||
221 | 225 | ||
222 | ENTRY(davinci_cpu_suspend_sz) | 226 | ENTRY(davinci_cpu_suspend_sz) |
223 | .word . - davinci_cpu_suspend | 227 | .word . - davinci_cpu_suspend |
diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c index eaa95bdadcac..b19ae1805569 100644 --- a/arch/arm/mach-integrator/integrator_ap.c +++ b/arch/arm/mach-integrator/integrator_ap.c | |||
@@ -337,15 +337,15 @@ static unsigned long timer_reload; | |||
337 | static void integrator_clocksource_init(u32 khz) | 337 | static void integrator_clocksource_init(u32 khz) |
338 | { | 338 | { |
339 | void __iomem *base = (void __iomem *)TIMER2_VA_BASE; | 339 | void __iomem *base = (void __iomem *)TIMER2_VA_BASE; |
340 | u32 ctrl = TIMER_CTRL_ENABLE; | 340 | u32 ctrl = TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC; |
341 | 341 | ||
342 | if (khz >= 1500) { | 342 | if (khz >= 1500) { |
343 | khz /= 16; | 343 | khz /= 16; |
344 | ctrl = TIMER_CTRL_DIV16; | 344 | ctrl |= TIMER_CTRL_DIV16; |
345 | } | 345 | } |
346 | 346 | ||
347 | writel(ctrl, base + TIMER_CTRL); | ||
348 | writel(0xffff, base + TIMER_LOAD); | 347 | writel(0xffff, base + TIMER_LOAD); |
348 | writel(ctrl, base + TIMER_CTRL); | ||
349 | 349 | ||
350 | clocksource_mmio_init(base + TIMER_VALUE, "timer2", | 350 | clocksource_mmio_init(base + TIMER_VALUE, "timer2", |
351 | khz * 1000, 200, 16, clocksource_mmio_readl_down); | 351 | khz * 1000, 200, 16, clocksource_mmio_readl_down); |
diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c index ffd55b1c4396..b9b844683147 100644 --- a/arch/arm/mach-omap2/clock3xxx_data.c +++ b/arch/arm/mach-omap2/clock3xxx_data.c | |||
@@ -3078,6 +3078,7 @@ static struct clk gpt12_fck = { | |||
3078 | .name = "gpt12_fck", | 3078 | .name = "gpt12_fck", |
3079 | .ops = &clkops_null, | 3079 | .ops = &clkops_null, |
3080 | .parent = &secure_32k_fck, | 3080 | .parent = &secure_32k_fck, |
3081 | .clkdm_name = "wkup_clkdm", | ||
3081 | .recalc = &followparent_recalc, | 3082 | .recalc = &followparent_recalc, |
3082 | }; | 3083 | }; |
3083 | 3084 | ||
@@ -3085,6 +3086,7 @@ static struct clk wdt1_fck = { | |||
3085 | .name = "wdt1_fck", | 3086 | .name = "wdt1_fck", |
3086 | .ops = &clkops_null, | 3087 | .ops = &clkops_null, |
3087 | .parent = &secure_32k_fck, | 3088 | .parent = &secure_32k_fck, |
3089 | .clkdm_name = "wkup_clkdm", | ||
3088 | .recalc = &followparent_recalc, | 3090 | .recalc = &followparent_recalc, |
3089 | }; | 3091 | }; |
3090 | 3092 | ||
diff --git a/arch/arm/mach-omap2/clock44xx_data.c b/arch/arm/mach-omap2/clock44xx_data.c index 2af0e3f00ce1..c0b6fbda3408 100644 --- a/arch/arm/mach-omap2/clock44xx_data.c +++ b/arch/arm/mach-omap2/clock44xx_data.c | |||
@@ -3376,10 +3376,18 @@ int __init omap4xxx_clk_init(void) | |||
3376 | } else if (cpu_is_omap446x()) { | 3376 | } else if (cpu_is_omap446x()) { |
3377 | cpu_mask = RATE_IN_4460; | 3377 | cpu_mask = RATE_IN_4460; |
3378 | cpu_clkflg = CK_446X; | 3378 | cpu_clkflg = CK_446X; |
3379 | } else { | ||
3380 | return 0; | ||
3379 | } | 3381 | } |
3380 | 3382 | ||
3381 | clk_init(&omap2_clk_functions); | 3383 | clk_init(&omap2_clk_functions); |
3382 | omap2_clk_disable_clkdm_control(); | 3384 | |
3385 | /* | ||
3386 | * Must stay commented until all OMAP SoC drivers are | ||
3387 | * converted to runtime PM, or drivers may start crashing | ||
3388 | * | ||
3389 | * omap2_clk_disable_clkdm_control(); | ||
3390 | */ | ||
3383 | 3391 | ||
3384 | for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks); | 3392 | for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks); |
3385 | c++) | 3393 | c++) |
diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c index ab7db083f97f..8f0890685d7b 100644 --- a/arch/arm/mach-omap2/clockdomain.c +++ b/arch/arm/mach-omap2/clockdomain.c | |||
@@ -747,6 +747,7 @@ int clkdm_wakeup(struct clockdomain *clkdm) | |||
747 | spin_lock_irqsave(&clkdm->lock, flags); | 747 | spin_lock_irqsave(&clkdm->lock, flags); |
748 | clkdm->_flags &= ~_CLKDM_FLAG_HWSUP_ENABLED; | 748 | clkdm->_flags &= ~_CLKDM_FLAG_HWSUP_ENABLED; |
749 | ret = arch_clkdm->clkdm_wakeup(clkdm); | 749 | ret = arch_clkdm->clkdm_wakeup(clkdm); |
750 | ret |= pwrdm_state_switch(clkdm->pwrdm.ptr); | ||
750 | spin_unlock_irqrestore(&clkdm->lock, flags); | 751 | spin_unlock_irqrestore(&clkdm->lock, flags); |
751 | return ret; | 752 | return ret; |
752 | } | 753 | } |
@@ -818,6 +819,7 @@ void clkdm_deny_idle(struct clockdomain *clkdm) | |||
818 | spin_lock_irqsave(&clkdm->lock, flags); | 819 | spin_lock_irqsave(&clkdm->lock, flags); |
819 | clkdm->_flags &= ~_CLKDM_FLAG_HWSUP_ENABLED; | 820 | clkdm->_flags &= ~_CLKDM_FLAG_HWSUP_ENABLED; |
820 | arch_clkdm->clkdm_deny_idle(clkdm); | 821 | arch_clkdm->clkdm_deny_idle(clkdm); |
822 | pwrdm_state_switch(clkdm->pwrdm.ptr); | ||
821 | spin_unlock_irqrestore(&clkdm->lock, flags); | 823 | spin_unlock_irqrestore(&clkdm->lock, flags); |
822 | } | 824 | } |
823 | 825 | ||
diff --git a/arch/arm/mach-omap2/omap_hwmod_2430_data.c b/arch/arm/mach-omap2/omap_hwmod_2430_data.c index 16743c7d6e8e..408193d8e044 100644 --- a/arch/arm/mach-omap2/omap_hwmod_2430_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_2430_data.c | |||
@@ -192,6 +192,7 @@ static struct omap_hwmod_addr_space omap2430_usbhsotg_addrs[] = { | |||
192 | .pa_end = OMAP243X_HS_BASE + SZ_4K - 1, | 192 | .pa_end = OMAP243X_HS_BASE + SZ_4K - 1, |
193 | .flags = ADDR_TYPE_RT | 193 | .flags = ADDR_TYPE_RT |
194 | }, | 194 | }, |
195 | { } | ||
195 | }; | 196 | }; |
196 | 197 | ||
197 | /* l4_core ->usbhsotg interface */ | 198 | /* l4_core ->usbhsotg interface */ |
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c index 3feb35911a32..472bf22d5e84 100644 --- a/arch/arm/mach-omap2/pm.c +++ b/arch/arm/mach-omap2/pm.c | |||
@@ -130,7 +130,6 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state) | |||
130 | } else { | 130 | } else { |
131 | hwsup = clkdm_in_hwsup(pwrdm->pwrdm_clkdms[0]); | 131 | hwsup = clkdm_in_hwsup(pwrdm->pwrdm_clkdms[0]); |
132 | clkdm_wakeup(pwrdm->pwrdm_clkdms[0]); | 132 | clkdm_wakeup(pwrdm->pwrdm_clkdms[0]); |
133 | pwrdm_wait_transition(pwrdm); | ||
134 | sleep_switch = FORCEWAKEUP_SWITCH; | 133 | sleep_switch = FORCEWAKEUP_SWITCH; |
135 | } | 134 | } |
136 | } | 135 | } |
@@ -156,7 +155,6 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state) | |||
156 | return ret; | 155 | return ret; |
157 | } | 156 | } |
158 | 157 | ||
159 | pwrdm_wait_transition(pwrdm); | ||
160 | pwrdm_state_switch(pwrdm); | 158 | pwrdm_state_switch(pwrdm); |
161 | err: | 159 | err: |
162 | return ret; | 160 | return ret; |
diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c index 9af08473bf10..ef71fdd40fc4 100644 --- a/arch/arm/mach-omap2/powerdomain.c +++ b/arch/arm/mach-omap2/powerdomain.c | |||
@@ -195,28 +195,35 @@ static int _pwrdm_post_transition_cb(struct powerdomain *pwrdm, void *unused) | |||
195 | 195 | ||
196 | /** | 196 | /** |
197 | * pwrdm_init - set up the powerdomain layer | 197 | * pwrdm_init - set up the powerdomain layer |
198 | * @pwrdm_list: array of struct powerdomain pointers to register | 198 | * @pwrdms: array of struct powerdomain pointers to register |
199 | * @custom_funcs: func pointers for arch specific implementations | 199 | * @custom_funcs: func pointers for arch specific implementations |
200 | * | 200 | * |
201 | * Loop through the array of powerdomains @pwrdm_list, registering all | 201 | * Loop through the array of powerdomains @pwrdms, registering all |
202 | * that are available on the current CPU. If pwrdm_list is supplied | 202 | * that are available on the current CPU. Also, program all |
203 | * and not null, all of the referenced powerdomains will be | 203 | * powerdomain target state as ON; this is to prevent domains from |
204 | * registered. No return value. XXX pwrdm_list is not really a | 204 | * hitting low power states (if bootloader has target states set to |
205 | * "list"; it is an array. Rename appropriately. | 205 | * something other than ON) and potentially even losing context while |
206 | * PM is not fully initialized. The PM late init code can then program | ||
207 | * the desired target state for all the power domains. No return | ||
208 | * value. | ||
206 | */ | 209 | */ |
207 | void pwrdm_init(struct powerdomain **pwrdm_list, struct pwrdm_ops *custom_funcs) | 210 | void pwrdm_init(struct powerdomain **pwrdms, struct pwrdm_ops *custom_funcs) |
208 | { | 211 | { |
209 | struct powerdomain **p = NULL; | 212 | struct powerdomain **p = NULL; |
213 | struct powerdomain *temp_p; | ||
210 | 214 | ||
211 | if (!custom_funcs) | 215 | if (!custom_funcs) |
212 | WARN(1, "powerdomain: No custom pwrdm functions registered\n"); | 216 | WARN(1, "powerdomain: No custom pwrdm functions registered\n"); |
213 | else | 217 | else |
214 | arch_pwrdm = custom_funcs; | 218 | arch_pwrdm = custom_funcs; |
215 | 219 | ||
216 | if (pwrdm_list) { | 220 | if (pwrdms) { |
217 | for (p = pwrdm_list; *p; p++) | 221 | for (p = pwrdms; *p; p++) |
218 | _pwrdm_register(*p); | 222 | _pwrdm_register(*p); |
219 | } | 223 | } |
224 | |||
225 | list_for_each_entry(temp_p, &pwrdm_list, node) | ||
226 | pwrdm_set_next_pwrst(temp_p, PWRDM_POWER_ON); | ||
220 | } | 227 | } |
221 | 228 | ||
222 | /** | 229 | /** |
diff --git a/arch/arm/mach-prima2/clock.c b/arch/arm/mach-prima2/clock.c index f9a2aaf63f71..615a4e75ceab 100644 --- a/arch/arm/mach-prima2/clock.c +++ b/arch/arm/mach-prima2/clock.c | |||
@@ -481,6 +481,7 @@ static void __init sirfsoc_clk_init(void) | |||
481 | 481 | ||
482 | static struct of_device_id clkc_ids[] = { | 482 | static struct of_device_id clkc_ids[] = { |
483 | { .compatible = "sirf,prima2-clkc" }, | 483 | { .compatible = "sirf,prima2-clkc" }, |
484 | {}, | ||
484 | }; | 485 | }; |
485 | 486 | ||
486 | void __init sirfsoc_of_clk_init(void) | 487 | void __init sirfsoc_of_clk_init(void) |
diff --git a/arch/arm/mach-prima2/irq.c b/arch/arm/mach-prima2/irq.c index c3404cbb6ff7..7af254d046ba 100644 --- a/arch/arm/mach-prima2/irq.c +++ b/arch/arm/mach-prima2/irq.c | |||
@@ -51,6 +51,7 @@ static __init void sirfsoc_irq_init(void) | |||
51 | 51 | ||
52 | static struct of_device_id intc_ids[] = { | 52 | static struct of_device_id intc_ids[] = { |
53 | { .compatible = "sirf,prima2-intc" }, | 53 | { .compatible = "sirf,prima2-intc" }, |
54 | {}, | ||
54 | }; | 55 | }; |
55 | 56 | ||
56 | void __init sirfsoc_of_irq_init(void) | 57 | void __init sirfsoc_of_irq_init(void) |
diff --git a/arch/arm/mach-prima2/rstc.c b/arch/arm/mach-prima2/rstc.c index d074786e83d4..492cfa8d2610 100644 --- a/arch/arm/mach-prima2/rstc.c +++ b/arch/arm/mach-prima2/rstc.c | |||
@@ -19,6 +19,7 @@ static DEFINE_MUTEX(rstc_lock); | |||
19 | 19 | ||
20 | static struct of_device_id rstc_ids[] = { | 20 | static struct of_device_id rstc_ids[] = { |
21 | { .compatible = "sirf,prima2-rstc" }, | 21 | { .compatible = "sirf,prima2-rstc" }, |
22 | {}, | ||
22 | }; | 23 | }; |
23 | 24 | ||
24 | static int __init sirfsoc_of_rstc_init(void) | 25 | static int __init sirfsoc_of_rstc_init(void) |
diff --git a/arch/arm/mach-prima2/timer.c b/arch/arm/mach-prima2/timer.c index 44027f34a88a..ed7ec48d11da 100644 --- a/arch/arm/mach-prima2/timer.c +++ b/arch/arm/mach-prima2/timer.c | |||
@@ -190,6 +190,7 @@ static void __init sirfsoc_timer_init(void) | |||
190 | 190 | ||
191 | static struct of_device_id timer_ids[] = { | 191 | static struct of_device_id timer_ids[] = { |
192 | { .compatible = "sirf,prima2-tick" }, | 192 | { .compatible = "sirf,prima2-tick" }, |
193 | {}, | ||
193 | }; | 194 | }; |
194 | 195 | ||
195 | static void __init sirfsoc_of_timer_map(void) | 196 | static void __init sirfsoc_of_timer_map(void) |
diff --git a/arch/arm/mm/abort-macro.S b/arch/arm/mm/abort-macro.S index 52162d59407a..2cbf68ef0e83 100644 --- a/arch/arm/mm/abort-macro.S +++ b/arch/arm/mm/abort-macro.S | |||
@@ -17,7 +17,7 @@ | |||
17 | cmp \tmp, # 0x5600 @ Is it ldrsb? | 17 | cmp \tmp, # 0x5600 @ Is it ldrsb? |
18 | orreq \tmp, \tmp, #1 << 11 @ Set L-bit if yes | 18 | orreq \tmp, \tmp, #1 << 11 @ Set L-bit if yes |
19 | tst \tmp, #1 << 11 @ L = 0 -> write | 19 | tst \tmp, #1 << 11 @ L = 0 -> write |
20 | orreq \psr, \psr, #1 << 11 @ yes. | 20 | orreq \fsr, \fsr, #1 << 11 @ yes. |
21 | b do_DataAbort | 21 | b do_DataAbort |
22 | not_thumb: | 22 | not_thumb: |
23 | .endm | 23 | .endm |
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c index 44c086710d2b..9ecfdb511951 100644 --- a/arch/arm/mm/cache-l2x0.c +++ b/arch/arm/mm/cache-l2x0.c | |||
@@ -277,6 +277,25 @@ static void l2x0_disable(void) | |||
277 | spin_unlock_irqrestore(&l2x0_lock, flags); | 277 | spin_unlock_irqrestore(&l2x0_lock, flags); |
278 | } | 278 | } |
279 | 279 | ||
280 | static void __init l2x0_unlock(__u32 cache_id) | ||
281 | { | ||
282 | int lockregs; | ||
283 | int i; | ||
284 | |||
285 | if (cache_id == L2X0_CACHE_ID_PART_L310) | ||
286 | lockregs = 8; | ||
287 | else | ||
288 | /* L210 and unknown types */ | ||
289 | lockregs = 1; | ||
290 | |||
291 | for (i = 0; i < lockregs; i++) { | ||
292 | writel_relaxed(0x0, l2x0_base + L2X0_LOCKDOWN_WAY_D_BASE + | ||
293 | i * L2X0_LOCKDOWN_STRIDE); | ||
294 | writel_relaxed(0x0, l2x0_base + L2X0_LOCKDOWN_WAY_I_BASE + | ||
295 | i * L2X0_LOCKDOWN_STRIDE); | ||
296 | } | ||
297 | } | ||
298 | |||
280 | void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask) | 299 | void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask) |
281 | { | 300 | { |
282 | __u32 aux; | 301 | __u32 aux; |
@@ -328,6 +347,8 @@ void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask) | |||
328 | * accessing the below registers will fault. | 347 | * accessing the below registers will fault. |
329 | */ | 348 | */ |
330 | if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & 1)) { | 349 | if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & 1)) { |
350 | /* Make sure that I&D is not locked down when starting */ | ||
351 | l2x0_unlock(cache_id); | ||
331 | 352 | ||
332 | /* l2x0 controller is disabled */ | 353 | /* l2x0 controller is disabled */ |
333 | writel_relaxed(aux, l2x0_base + L2X0_AUX_CTRL); | 354 | writel_relaxed(aux, l2x0_base + L2X0_AUX_CTRL); |
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 64ab41348f30..34409a08ba0d 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c | |||
@@ -298,7 +298,7 @@ static void __init arm_bootmem_free(unsigned long min, unsigned long max_low, | |||
298 | #ifdef CONFIG_HAVE_ARCH_PFN_VALID | 298 | #ifdef CONFIG_HAVE_ARCH_PFN_VALID |
299 | int pfn_valid(unsigned long pfn) | 299 | int pfn_valid(unsigned long pfn) |
300 | { | 300 | { |
301 | return memblock_is_memory(pfn << PAGE_SHIFT); | 301 | return memblock_is_memory(__pfn_to_phys(pfn)); |
302 | } | 302 | } |
303 | EXPORT_SYMBOL(pfn_valid); | 303 | EXPORT_SYMBOL(pfn_valid); |
304 | #endif | 304 | #endif |
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c index 9a6a53854911..02609eee0562 100644 --- a/arch/arm/plat-omap/omap_device.c +++ b/arch/arm/plat-omap/omap_device.c | |||
@@ -615,6 +615,9 @@ static int _od_resume_noirq(struct device *dev) | |||
615 | 615 | ||
616 | return pm_generic_resume_noirq(dev); | 616 | return pm_generic_resume_noirq(dev); |
617 | } | 617 | } |
618 | #else | ||
619 | #define _od_suspend_noirq NULL | ||
620 | #define _od_resume_noirq NULL | ||
618 | #endif | 621 | #endif |
619 | 622 | ||
620 | static struct dev_pm_domain omap_device_pm_domain = { | 623 | static struct dev_pm_domain omap_device_pm_domain = { |
diff --git a/arch/openrisc/include/asm/dma-mapping.h b/arch/openrisc/include/asm/dma-mapping.h index 052f877b52a5..60b472233900 100644 --- a/arch/openrisc/include/asm/dma-mapping.h +++ b/arch/openrisc/include/asm/dma-mapping.h | |||
@@ -31,7 +31,6 @@ | |||
31 | 31 | ||
32 | #define DMA_ERROR_CODE (~(dma_addr_t)0x0) | 32 | #define DMA_ERROR_CODE (~(dma_addr_t)0x0) |
33 | 33 | ||
34 | int dma_mapping_error(struct device *dev, dma_addr_t dma_addr); | ||
35 | 34 | ||
36 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) | 35 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) |
37 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) | 36 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) |
@@ -47,6 +46,12 @@ dma_addr_t or1k_map_page(struct device *dev, struct page *page, | |||
47 | void or1k_unmap_page(struct device *dev, dma_addr_t dma_handle, | 46 | void or1k_unmap_page(struct device *dev, dma_addr_t dma_handle, |
48 | size_t size, enum dma_data_direction dir, | 47 | size_t size, enum dma_data_direction dir, |
49 | struct dma_attrs *attrs); | 48 | struct dma_attrs *attrs); |
49 | int or1k_map_sg(struct device *dev, struct scatterlist *sg, | ||
50 | int nents, enum dma_data_direction dir, | ||
51 | struct dma_attrs *attrs); | ||
52 | void or1k_unmap_sg(struct device *dev, struct scatterlist *sg, | ||
53 | int nents, enum dma_data_direction dir, | ||
54 | struct dma_attrs *attrs); | ||
50 | void or1k_sync_single_for_cpu(struct device *dev, | 55 | void or1k_sync_single_for_cpu(struct device *dev, |
51 | dma_addr_t dma_handle, size_t size, | 56 | dma_addr_t dma_handle, size_t size, |
52 | enum dma_data_direction dir); | 57 | enum dma_data_direction dir); |
@@ -98,6 +103,51 @@ static inline void dma_unmap_single(struct device *dev, dma_addr_t addr, | |||
98 | debug_dma_unmap_page(dev, addr, size, dir, true); | 103 | debug_dma_unmap_page(dev, addr, size, dir, true); |
99 | } | 104 | } |
100 | 105 | ||
106 | static inline int dma_map_sg(struct device *dev, struct scatterlist *sg, | ||
107 | int nents, enum dma_data_direction dir) | ||
108 | { | ||
109 | int i, ents; | ||
110 | struct scatterlist *s; | ||
111 | |||
112 | for_each_sg(sg, s, nents, i) | ||
113 | kmemcheck_mark_initialized(sg_virt(s), s->length); | ||
114 | BUG_ON(!valid_dma_direction(dir)); | ||
115 | ents = or1k_map_sg(dev, sg, nents, dir, NULL); | ||
116 | debug_dma_map_sg(dev, sg, nents, ents, dir); | ||
117 | |||
118 | return ents; | ||
119 | } | ||
120 | |||
121 | static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg, | ||
122 | int nents, enum dma_data_direction dir) | ||
123 | { | ||
124 | BUG_ON(!valid_dma_direction(dir)); | ||
125 | debug_dma_unmap_sg(dev, sg, nents, dir); | ||
126 | or1k_unmap_sg(dev, sg, nents, dir, NULL); | ||
127 | } | ||
128 | |||
129 | static inline dma_addr_t dma_map_page(struct device *dev, struct page *page, | ||
130 | size_t offset, size_t size, | ||
131 | enum dma_data_direction dir) | ||
132 | { | ||
133 | dma_addr_t addr; | ||
134 | |||
135 | kmemcheck_mark_initialized(page_address(page) + offset, size); | ||
136 | BUG_ON(!valid_dma_direction(dir)); | ||
137 | addr = or1k_map_page(dev, page, offset, size, dir, NULL); | ||
138 | debug_dma_map_page(dev, page, offset, size, dir, addr, false); | ||
139 | |||
140 | return addr; | ||
141 | } | ||
142 | |||
143 | static inline void dma_unmap_page(struct device *dev, dma_addr_t addr, | ||
144 | size_t size, enum dma_data_direction dir) | ||
145 | { | ||
146 | BUG_ON(!valid_dma_direction(dir)); | ||
147 | or1k_unmap_page(dev, addr, size, dir, NULL); | ||
148 | debug_dma_unmap_page(dev, addr, size, dir, true); | ||
149 | } | ||
150 | |||
101 | static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr, | 151 | static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr, |
102 | size_t size, | 152 | size_t size, |
103 | enum dma_data_direction dir) | 153 | enum dma_data_direction dir) |
@@ -119,7 +169,12 @@ static inline void dma_sync_single_for_device(struct device *dev, | |||
119 | static inline int dma_supported(struct device *dev, u64 dma_mask) | 169 | static inline int dma_supported(struct device *dev, u64 dma_mask) |
120 | { | 170 | { |
121 | /* Support 32 bit DMA mask exclusively */ | 171 | /* Support 32 bit DMA mask exclusively */ |
122 | return dma_mask == 0xffffffffULL; | 172 | return dma_mask == DMA_BIT_MASK(32); |
173 | } | ||
174 | |||
175 | static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) | ||
176 | { | ||
177 | return 0; | ||
123 | } | 178 | } |
124 | 179 | ||
125 | static inline int dma_set_mask(struct device *dev, u64 dma_mask) | 180 | static inline int dma_set_mask(struct device *dev, u64 dma_mask) |
diff --git a/arch/openrisc/include/asm/sigcontext.h b/arch/openrisc/include/asm/sigcontext.h index 54a5c50132e3..b79c2b19afbe 100644 --- a/arch/openrisc/include/asm/sigcontext.h +++ b/arch/openrisc/include/asm/sigcontext.h | |||
@@ -23,16 +23,11 @@ | |||
23 | 23 | ||
24 | /* This struct is saved by setup_frame in signal.c, to keep the current | 24 | /* This struct is saved by setup_frame in signal.c, to keep the current |
25 | context while a signal handler is executed. It's restored by sys_sigreturn. | 25 | context while a signal handler is executed. It's restored by sys_sigreturn. |
26 | |||
27 | To keep things simple, we use pt_regs here even though normally you just | ||
28 | specify the list of regs to save. Then we can use copy_from_user on the | ||
29 | entire regs instead of a bunch of get_user's as well... | ||
30 | */ | 26 | */ |
31 | 27 | ||
32 | struct sigcontext { | 28 | struct sigcontext { |
33 | struct pt_regs regs; /* needs to be first */ | 29 | struct user_regs_struct regs; /* needs to be first */ |
34 | unsigned long oldmask; | 30 | unsigned long oldmask; |
35 | unsigned long usp; /* usp before stacking this gunk on it */ | ||
36 | }; | 31 | }; |
37 | 32 | ||
38 | #endif /* __ASM_OPENRISC_SIGCONTEXT_H */ | 33 | #endif /* __ASM_OPENRISC_SIGCONTEXT_H */ |
diff --git a/arch/openrisc/kernel/dma.c b/arch/openrisc/kernel/dma.c index 968d3ee477e3..f1c8ee2895d0 100644 --- a/arch/openrisc/kernel/dma.c +++ b/arch/openrisc/kernel/dma.c | |||
@@ -154,6 +154,33 @@ void or1k_unmap_page(struct device *dev, dma_addr_t dma_handle, | |||
154 | /* Nothing special to do here... */ | 154 | /* Nothing special to do here... */ |
155 | } | 155 | } |
156 | 156 | ||
157 | int or1k_map_sg(struct device *dev, struct scatterlist *sg, | ||
158 | int nents, enum dma_data_direction dir, | ||
159 | struct dma_attrs *attrs) | ||
160 | { | ||
161 | struct scatterlist *s; | ||
162 | int i; | ||
163 | |||
164 | for_each_sg(sg, s, nents, i) { | ||
165 | s->dma_address = or1k_map_page(dev, sg_page(s), s->offset, | ||
166 | s->length, dir, NULL); | ||
167 | } | ||
168 | |||
169 | return nents; | ||
170 | } | ||
171 | |||
172 | void or1k_unmap_sg(struct device *dev, struct scatterlist *sg, | ||
173 | int nents, enum dma_data_direction dir, | ||
174 | struct dma_attrs *attrs) | ||
175 | { | ||
176 | struct scatterlist *s; | ||
177 | int i; | ||
178 | |||
179 | for_each_sg(sg, s, nents, i) { | ||
180 | or1k_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir, NULL); | ||
181 | } | ||
182 | } | ||
183 | |||
157 | void or1k_sync_single_for_cpu(struct device *dev, | 184 | void or1k_sync_single_for_cpu(struct device *dev, |
158 | dma_addr_t dma_handle, size_t size, | 185 | dma_addr_t dma_handle, size_t size, |
159 | enum dma_data_direction dir) | 186 | enum dma_data_direction dir) |
@@ -187,5 +214,4 @@ static int __init dma_init(void) | |||
187 | 214 | ||
188 | return 0; | 215 | return 0; |
189 | } | 216 | } |
190 | |||
191 | fs_initcall(dma_init); | 217 | fs_initcall(dma_init); |
diff --git a/arch/openrisc/kernel/signal.c b/arch/openrisc/kernel/signal.c index 5f759c76834e..95207ab0c99e 100644 --- a/arch/openrisc/kernel/signal.c +++ b/arch/openrisc/kernel/signal.c | |||
@@ -52,31 +52,25 @@ struct rt_sigframe { | |||
52 | static int restore_sigcontext(struct pt_regs *regs, struct sigcontext *sc) | 52 | static int restore_sigcontext(struct pt_regs *regs, struct sigcontext *sc) |
53 | { | 53 | { |
54 | unsigned int err = 0; | 54 | unsigned int err = 0; |
55 | unsigned long old_usp; | ||
56 | 55 | ||
57 | /* Alwys make any pending restarted system call return -EINTR */ | 56 | /* Alwys make any pending restarted system call return -EINTR */ |
58 | current_thread_info()->restart_block.fn = do_no_restart_syscall; | 57 | current_thread_info()->restart_block.fn = do_no_restart_syscall; |
59 | 58 | ||
60 | /* restore the regs from &sc->regs (same as sc, since regs is first) | 59 | /* |
60 | * Restore the regs from &sc->regs. | ||
61 | * (sc is already checked for VERIFY_READ since the sigframe was | 61 | * (sc is already checked for VERIFY_READ since the sigframe was |
62 | * checked in sys_sigreturn previously) | 62 | * checked in sys_sigreturn previously) |
63 | */ | 63 | */ |
64 | 64 | if (__copy_from_user(regs, sc->regs.gpr, 32 * sizeof(unsigned long))) | |
65 | if (__copy_from_user(regs, sc, sizeof(struct pt_regs))) | 65 | goto badframe; |
66 | if (__copy_from_user(®s->pc, &sc->regs.pc, sizeof(unsigned long))) | ||
67 | goto badframe; | ||
68 | if (__copy_from_user(®s->sr, &sc->regs.sr, sizeof(unsigned long))) | ||
66 | goto badframe; | 69 | goto badframe; |
67 | 70 | ||
68 | /* make sure the SM-bit is cleared so user-mode cannot fool us */ | 71 | /* make sure the SM-bit is cleared so user-mode cannot fool us */ |
69 | regs->sr &= ~SPR_SR_SM; | 72 | regs->sr &= ~SPR_SR_SM; |
70 | 73 | ||
71 | /* restore the old USP as it was before we stacked the sc etc. | ||
72 | * (we cannot just pop the sigcontext since we aligned the sp and | ||
73 | * stuff after pushing it) | ||
74 | */ | ||
75 | |||
76 | err |= __get_user(old_usp, &sc->usp); | ||
77 | |||
78 | regs->sp = old_usp; | ||
79 | |||
80 | /* TODO: the other ports use regs->orig_XX to disable syscall checks | 74 | /* TODO: the other ports use regs->orig_XX to disable syscall checks |
81 | * after this completes, but we don't use that mechanism. maybe we can | 75 | * after this completes, but we don't use that mechanism. maybe we can |
82 | * use it now ? | 76 | * use it now ? |
@@ -137,18 +131,17 @@ static int setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs, | |||
137 | unsigned long mask) | 131 | unsigned long mask) |
138 | { | 132 | { |
139 | int err = 0; | 133 | int err = 0; |
140 | unsigned long usp = regs->sp; | ||
141 | 134 | ||
142 | /* copy the regs. they are first in sc so we can use sc directly */ | 135 | /* copy the regs */ |
143 | 136 | ||
144 | err |= __copy_to_user(sc, regs, sizeof(struct pt_regs)); | 137 | err |= __copy_to_user(sc->regs.gpr, regs, 32 * sizeof(unsigned long)); |
138 | err |= __copy_to_user(&sc->regs.pc, ®s->pc, sizeof(unsigned long)); | ||
139 | err |= __copy_to_user(&sc->regs.sr, ®s->sr, sizeof(unsigned long)); | ||
145 | 140 | ||
146 | /* then some other stuff */ | 141 | /* then some other stuff */ |
147 | 142 | ||
148 | err |= __put_user(mask, &sc->oldmask); | 143 | err |= __put_user(mask, &sc->oldmask); |
149 | 144 | ||
150 | err |= __put_user(usp, &sc->usp); | ||
151 | |||
152 | return err; | 145 | return err; |
153 | } | 146 | } |
154 | 147 | ||
diff --git a/arch/powerpc/boot/dts/p1023rds.dts b/arch/powerpc/boot/dts/p1023rds.dts index bfa96aa8f2ca..d9b776740a67 100644 --- a/arch/powerpc/boot/dts/p1023rds.dts +++ b/arch/powerpc/boot/dts/p1023rds.dts | |||
@@ -387,7 +387,7 @@ | |||
387 | #size-cells = <1>; | 387 | #size-cells = <1>; |
388 | compatible = "cfi-flash"; | 388 | compatible = "cfi-flash"; |
389 | reg = <0x0 0x0 0x02000000>; | 389 | reg = <0x0 0x0 0x02000000>; |
390 | bank-width = <1>; | 390 | bank-width = <2>; |
391 | device-width = <1>; | 391 | device-width = <1>; |
392 | partition@0 { | 392 | partition@0 { |
393 | label = "ramdisk"; | 393 | label = "ramdisk"; |
diff --git a/arch/powerpc/configs/85xx/p1023rds_defconfig b/arch/powerpc/configs/85xx/p1023rds_defconfig index 980ff8f61fd4..3ff5a81c709f 100644 --- a/arch/powerpc/configs/85xx/p1023rds_defconfig +++ b/arch/powerpc/configs/85xx/p1023rds_defconfig | |||
@@ -171,3 +171,4 @@ CONFIG_CRYPTO_SHA256=y | |||
171 | CONFIG_CRYPTO_SHA512=y | 171 | CONFIG_CRYPTO_SHA512=y |
172 | CONFIG_CRYPTO_AES=y | 172 | CONFIG_CRYPTO_AES=y |
173 | # CONFIG_CRYPTO_ANSI_CPRNG is not set | 173 | # CONFIG_CRYPTO_ANSI_CPRNG is not set |
174 | CONFIG_CRYPTO_DEV_FSL_CAAM=y | ||
diff --git a/arch/powerpc/configs/corenet32_smp_defconfig b/arch/powerpc/configs/corenet32_smp_defconfig index 10562a5c65b9..4311d02a3bfd 100644 --- a/arch/powerpc/configs/corenet32_smp_defconfig +++ b/arch/powerpc/configs/corenet32_smp_defconfig | |||
@@ -185,3 +185,4 @@ CONFIG_CRYPTO_SHA256=y | |||
185 | CONFIG_CRYPTO_SHA512=y | 185 | CONFIG_CRYPTO_SHA512=y |
186 | CONFIG_CRYPTO_AES=y | 186 | CONFIG_CRYPTO_AES=y |
187 | # CONFIG_CRYPTO_ANSI_CPRNG is not set | 187 | # CONFIG_CRYPTO_ANSI_CPRNG is not set |
188 | CONFIG_CRYPTO_DEV_FSL_CAAM=y | ||
diff --git a/arch/powerpc/configs/corenet64_smp_defconfig b/arch/powerpc/configs/corenet64_smp_defconfig index d32283555b53..c92c204a204b 100644 --- a/arch/powerpc/configs/corenet64_smp_defconfig +++ b/arch/powerpc/configs/corenet64_smp_defconfig | |||
@@ -100,5 +100,8 @@ CONFIG_DEBUG_INFO=y | |||
100 | CONFIG_SYSCTL_SYSCALL_CHECK=y | 100 | CONFIG_SYSCTL_SYSCALL_CHECK=y |
101 | CONFIG_VIRQ_DEBUG=y | 101 | CONFIG_VIRQ_DEBUG=y |
102 | CONFIG_CRYPTO_PCBC=m | 102 | CONFIG_CRYPTO_PCBC=m |
103 | CONFIG_CRYPTO_SHA256=y | ||
104 | CONFIG_CRYPTO_SHA512=y | ||
105 | CONFIG_CRYPTO_AES=y | ||
103 | # CONFIG_CRYPTO_ANSI_CPRNG is not set | 106 | # CONFIG_CRYPTO_ANSI_CPRNG is not set |
104 | CONFIG_CRYPTO_DEV_TALITOS=y | 107 | CONFIG_CRYPTO_DEV_FSL_CAAM=y |
diff --git a/arch/powerpc/configs/mpc85xx_defconfig b/arch/powerpc/configs/mpc85xx_defconfig index fcd85d2c72dc..a3467bfb7671 100644 --- a/arch/powerpc/configs/mpc85xx_defconfig +++ b/arch/powerpc/configs/mpc85xx_defconfig | |||
@@ -139,6 +139,7 @@ CONFIG_SND=y | |||
139 | CONFIG_SND_INTEL8X0=y | 139 | CONFIG_SND_INTEL8X0=y |
140 | # CONFIG_SND_PPC is not set | 140 | # CONFIG_SND_PPC is not set |
141 | # CONFIG_SND_USB is not set | 141 | # CONFIG_SND_USB is not set |
142 | CONFIG_SND_SOC=y | ||
142 | CONFIG_HID_A4TECH=y | 143 | CONFIG_HID_A4TECH=y |
143 | CONFIG_HID_APPLE=y | 144 | CONFIG_HID_APPLE=y |
144 | CONFIG_HID_BELKIN=y | 145 | CONFIG_HID_BELKIN=y |
diff --git a/arch/powerpc/configs/mpc85xx_smp_defconfig b/arch/powerpc/configs/mpc85xx_smp_defconfig index 908c941fc24c..9693f6ed3da0 100644 --- a/arch/powerpc/configs/mpc85xx_smp_defconfig +++ b/arch/powerpc/configs/mpc85xx_smp_defconfig | |||
@@ -140,6 +140,7 @@ CONFIG_SND=y | |||
140 | CONFIG_SND_INTEL8X0=y | 140 | CONFIG_SND_INTEL8X0=y |
141 | # CONFIG_SND_PPC is not set | 141 | # CONFIG_SND_PPC is not set |
142 | # CONFIG_SND_USB is not set | 142 | # CONFIG_SND_USB is not set |
143 | CONFIG_SND_SOC=y | ||
143 | CONFIG_HID_A4TECH=y | 144 | CONFIG_HID_A4TECH=y |
144 | CONFIG_HID_APPLE=y | 145 | CONFIG_HID_APPLE=y |
145 | CONFIG_HID_BELKIN=y | 146 | CONFIG_HID_BELKIN=y |
diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c index 3e9daea1653d..3c5bb784214f 100644 --- a/arch/sparc/kernel/setup_64.c +++ b/arch/sparc/kernel/setup_64.c | |||
@@ -440,8 +440,14 @@ static void __init init_sparc64_elf_hwcap(void) | |||
440 | cap |= AV_SPARC_VIS; | 440 | cap |= AV_SPARC_VIS; |
441 | if (tlb_type == cheetah || tlb_type == cheetah_plus) | 441 | if (tlb_type == cheetah || tlb_type == cheetah_plus) |
442 | cap |= AV_SPARC_VIS | AV_SPARC_VIS2; | 442 | cap |= AV_SPARC_VIS | AV_SPARC_VIS2; |
443 | if (tlb_type == cheetah_plus) | 443 | if (tlb_type == cheetah_plus) { |
444 | cap |= AV_SPARC_POPC; | 444 | unsigned long impl, ver; |
445 | |||
446 | __asm__ __volatile__("rdpr %%ver, %0" : "=r" (ver)); | ||
447 | impl = ((ver >> 32) & 0xffff); | ||
448 | if (impl == PANTHER_IMPL) | ||
449 | cap |= AV_SPARC_POPC; | ||
450 | } | ||
445 | if (tlb_type == hypervisor) { | 451 | if (tlb_type == hypervisor) { |
446 | if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1) | 452 | if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1) |
447 | cap |= AV_SPARC_ASI_BLK_INIT; | 453 | cap |= AV_SPARC_ASI_BLK_INIT; |
diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h index a518c0a45044..c59cc97fe6c1 100644 --- a/arch/x86/include/asm/pvclock.h +++ b/arch/x86/include/asm/pvclock.h | |||
@@ -44,7 +44,7 @@ static inline u64 pvclock_scale_delta(u64 delta, u32 mul_frac, int shift) | |||
44 | : "a" ((u32)delta), "1" ((u32)(delta >> 32)), "2" (mul_frac) ); | 44 | : "a" ((u32)delta), "1" ((u32)(delta >> 32)), "2" (mul_frac) ); |
45 | #elif defined(__x86_64__) | 45 | #elif defined(__x86_64__) |
46 | __asm__ ( | 46 | __asm__ ( |
47 | "mul %[mul_frac] ; shrd $32, %[hi], %[lo]" | 47 | "mulq %[mul_frac] ; shrd $32, %[hi], %[lo]" |
48 | : [lo]"=a"(product), | 48 | : [lo]"=a"(product), |
49 | [hi]"=d"(tmp) | 49 | [hi]"=d"(tmp) |
50 | : "0"(delta), | 50 | : "0"(delta), |
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index 4ee3abf20ed6..cfa62ec090ec 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c | |||
@@ -1900,6 +1900,9 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs) | |||
1900 | 1900 | ||
1901 | perf_callchain_store(entry, regs->ip); | 1901 | perf_callchain_store(entry, regs->ip); |
1902 | 1902 | ||
1903 | if (!current->mm) | ||
1904 | return; | ||
1905 | |||
1903 | if (perf_callchain_user32(regs, entry)) | 1906 | if (perf_callchain_user32(regs, entry)) |
1904 | return; | 1907 | return; |
1905 | 1908 | ||
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index c95330267f08..039d91315bc5 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c | |||
@@ -365,8 +365,13 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root) | |||
365 | */ | 365 | */ |
366 | if (bus) { | 366 | if (bus) { |
367 | struct pci_bus *child; | 367 | struct pci_bus *child; |
368 | list_for_each_entry(child, &bus->children, node) | 368 | list_for_each_entry(child, &bus->children, node) { |
369 | pcie_bus_configure_settings(child, child->self->pcie_mpss); | 369 | struct pci_dev *self = child->self; |
370 | if (!self) | ||
371 | continue; | ||
372 | |||
373 | pcie_bus_configure_settings(child, self->pcie_mpss); | ||
374 | } | ||
370 | } | 375 | } |
371 | 376 | ||
372 | if (!bus) | 377 | if (!bus) |
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c index df118a825f39..c3b8d440873c 100644 --- a/arch/x86/xen/setup.c +++ b/arch/x86/xen/setup.c | |||
@@ -184,6 +184,19 @@ static unsigned long __init xen_set_identity(const struct e820entry *list, | |||
184 | PFN_UP(start_pci), PFN_DOWN(last)); | 184 | PFN_UP(start_pci), PFN_DOWN(last)); |
185 | return identity; | 185 | return identity; |
186 | } | 186 | } |
187 | |||
188 | static unsigned long __init xen_get_max_pages(void) | ||
189 | { | ||
190 | unsigned long max_pages = MAX_DOMAIN_PAGES; | ||
191 | domid_t domid = DOMID_SELF; | ||
192 | int ret; | ||
193 | |||
194 | ret = HYPERVISOR_memory_op(XENMEM_maximum_reservation, &domid); | ||
195 | if (ret > 0) | ||
196 | max_pages = ret; | ||
197 | return min(max_pages, MAX_DOMAIN_PAGES); | ||
198 | } | ||
199 | |||
187 | /** | 200 | /** |
188 | * machine_specific_memory_setup - Hook for machine specific memory setup. | 201 | * machine_specific_memory_setup - Hook for machine specific memory setup. |
189 | **/ | 202 | **/ |
@@ -292,6 +305,12 @@ char * __init xen_memory_setup(void) | |||
292 | 305 | ||
293 | sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); | 306 | sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); |
294 | 307 | ||
308 | extra_limit = xen_get_max_pages(); | ||
309 | if (extra_limit >= max_pfn) | ||
310 | extra_pages = extra_limit - max_pfn; | ||
311 | else | ||
312 | extra_pages = 0; | ||
313 | |||
295 | extra_pages += xen_return_unused_memory(xen_start_info->nr_pages, &e820); | 314 | extra_pages += xen_return_unused_memory(xen_start_info->nr_pages, &e820); |
296 | 315 | ||
297 | /* | 316 | /* |
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c index e79dbb95482b..d4fc6d454f8d 100644 --- a/arch/x86/xen/smp.c +++ b/arch/x86/xen/smp.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <xen/page.h> | 32 | #include <xen/page.h> |
33 | #include <xen/events.h> | 33 | #include <xen/events.h> |
34 | 34 | ||
35 | #include <xen/hvc-console.h> | ||
35 | #include "xen-ops.h" | 36 | #include "xen-ops.h" |
36 | #include "mmu.h" | 37 | #include "mmu.h" |
37 | 38 | ||
@@ -207,6 +208,15 @@ static void __init xen_smp_prepare_cpus(unsigned int max_cpus) | |||
207 | unsigned cpu; | 208 | unsigned cpu; |
208 | unsigned int i; | 209 | unsigned int i; |
209 | 210 | ||
211 | if (skip_ioapic_setup) { | ||
212 | char *m = (max_cpus == 0) ? | ||
213 | "The nosmp parameter is incompatible with Xen; " \ | ||
214 | "use Xen dom0_max_vcpus=1 parameter" : | ||
215 | "The noapic parameter is incompatible with Xen"; | ||
216 | |||
217 | xen_raw_printk(m); | ||
218 | panic(m); | ||
219 | } | ||
210 | xen_init_lock_cpu(0); | 220 | xen_init_lock_cpu(0); |
211 | 221 | ||
212 | smp_store_cpu_info(0); | 222 | smp_store_cpu_info(0); |
diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S index 22a2093b5862..b040b0e518ca 100644 --- a/arch/x86/xen/xen-asm_32.S +++ b/arch/x86/xen/xen-asm_32.S | |||
@@ -113,11 +113,13 @@ xen_iret_start_crit: | |||
113 | 113 | ||
114 | /* | 114 | /* |
115 | * If there's something pending, mask events again so we can | 115 | * If there's something pending, mask events again so we can |
116 | * jump back into xen_hypervisor_callback | 116 | * jump back into xen_hypervisor_callback. Otherwise do not |
117 | * touch XEN_vcpu_info_mask. | ||
117 | */ | 118 | */ |
118 | sete XEN_vcpu_info_mask(%eax) | 119 | jne 1f |
120 | movb $1, XEN_vcpu_info_mask(%eax) | ||
119 | 121 | ||
120 | popl %eax | 122 | 1: popl %eax |
121 | 123 | ||
122 | /* | 124 | /* |
123 | * From this point on the registers are restored and the stack | 125 | * From this point on the registers are restored and the stack |
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 0eef4da1ac61..20663f8dae45 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c | |||
@@ -168,13 +168,11 @@ struct regmap *regmap_init(struct device *dev, | |||
168 | map->work_buf = kmalloc(map->format.buf_size, GFP_KERNEL); | 168 | map->work_buf = kmalloc(map->format.buf_size, GFP_KERNEL); |
169 | if (map->work_buf == NULL) { | 169 | if (map->work_buf == NULL) { |
170 | ret = -ENOMEM; | 170 | ret = -ENOMEM; |
171 | goto err_bus; | 171 | goto err_map; |
172 | } | 172 | } |
173 | 173 | ||
174 | return map; | 174 | return map; |
175 | 175 | ||
176 | err_bus: | ||
177 | module_put(map->bus->owner); | ||
178 | err_map: | 176 | err_map: |
179 | kfree(map); | 177 | kfree(map); |
180 | err: | 178 | err: |
@@ -188,7 +186,6 @@ EXPORT_SYMBOL_GPL(regmap_init); | |||
188 | void regmap_exit(struct regmap *map) | 186 | void regmap_exit(struct regmap *map) |
189 | { | 187 | { |
190 | kfree(map->work_buf); | 188 | kfree(map->work_buf); |
191 | module_put(map->bus->owner); | ||
192 | kfree(map); | 189 | kfree(map); |
193 | } | 190 | } |
194 | EXPORT_SYMBOL_GPL(regmap_exit); | 191 | EXPORT_SYMBOL_GPL(regmap_exit); |
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index cd3a7c726bf8..467e4dcb20a0 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c | |||
@@ -174,8 +174,10 @@ struct d40_base; | |||
174 | * @tasklet: Tasklet that gets scheduled from interrupt context to complete a | 174 | * @tasklet: Tasklet that gets scheduled from interrupt context to complete a |
175 | * transfer and call client callback. | 175 | * transfer and call client callback. |
176 | * @client: Cliented owned descriptor list. | 176 | * @client: Cliented owned descriptor list. |
177 | * @pending_queue: Submitted jobs, to be issued by issue_pending() | ||
177 | * @active: Active descriptor. | 178 | * @active: Active descriptor. |
178 | * @queue: Queued jobs. | 179 | * @queue: Queued jobs. |
180 | * @prepare_queue: Prepared jobs. | ||
179 | * @dma_cfg: The client configuration of this dma channel. | 181 | * @dma_cfg: The client configuration of this dma channel. |
180 | * @configured: whether the dma_cfg configuration is valid | 182 | * @configured: whether the dma_cfg configuration is valid |
181 | * @base: Pointer to the device instance struct. | 183 | * @base: Pointer to the device instance struct. |
@@ -203,6 +205,7 @@ struct d40_chan { | |||
203 | struct list_head pending_queue; | 205 | struct list_head pending_queue; |
204 | struct list_head active; | 206 | struct list_head active; |
205 | struct list_head queue; | 207 | struct list_head queue; |
208 | struct list_head prepare_queue; | ||
206 | struct stedma40_chan_cfg dma_cfg; | 209 | struct stedma40_chan_cfg dma_cfg; |
207 | bool configured; | 210 | bool configured; |
208 | struct d40_base *base; | 211 | struct d40_base *base; |
@@ -477,7 +480,6 @@ static struct d40_desc *d40_desc_get(struct d40_chan *d40c) | |||
477 | 480 | ||
478 | list_for_each_entry_safe(d, _d, &d40c->client, node) | 481 | list_for_each_entry_safe(d, _d, &d40c->client, node) |
479 | if (async_tx_test_ack(&d->txd)) { | 482 | if (async_tx_test_ack(&d->txd)) { |
480 | d40_pool_lli_free(d40c, d); | ||
481 | d40_desc_remove(d); | 483 | d40_desc_remove(d); |
482 | desc = d; | 484 | desc = d; |
483 | memset(desc, 0, sizeof(*desc)); | 485 | memset(desc, 0, sizeof(*desc)); |
@@ -644,8 +646,11 @@ static struct d40_desc *d40_first_active_get(struct d40_chan *d40c) | |||
644 | return d; | 646 | return d; |
645 | } | 647 | } |
646 | 648 | ||
649 | /* remove desc from current queue and add it to the pending_queue */ | ||
647 | static void d40_desc_queue(struct d40_chan *d40c, struct d40_desc *desc) | 650 | static void d40_desc_queue(struct d40_chan *d40c, struct d40_desc *desc) |
648 | { | 651 | { |
652 | d40_desc_remove(desc); | ||
653 | desc->is_in_client_list = false; | ||
649 | list_add_tail(&desc->node, &d40c->pending_queue); | 654 | list_add_tail(&desc->node, &d40c->pending_queue); |
650 | } | 655 | } |
651 | 656 | ||
@@ -803,6 +808,7 @@ done: | |||
803 | static void d40_term_all(struct d40_chan *d40c) | 808 | static void d40_term_all(struct d40_chan *d40c) |
804 | { | 809 | { |
805 | struct d40_desc *d40d; | 810 | struct d40_desc *d40d; |
811 | struct d40_desc *_d; | ||
806 | 812 | ||
807 | /* Release active descriptors */ | 813 | /* Release active descriptors */ |
808 | while ((d40d = d40_first_active_get(d40c))) { | 814 | while ((d40d = d40_first_active_get(d40c))) { |
@@ -822,6 +828,21 @@ static void d40_term_all(struct d40_chan *d40c) | |||
822 | d40_desc_free(d40c, d40d); | 828 | d40_desc_free(d40c, d40d); |
823 | } | 829 | } |
824 | 830 | ||
831 | /* Release client owned descriptors */ | ||
832 | if (!list_empty(&d40c->client)) | ||
833 | list_for_each_entry_safe(d40d, _d, &d40c->client, node) { | ||
834 | d40_desc_remove(d40d); | ||
835 | d40_desc_free(d40c, d40d); | ||
836 | } | ||
837 | |||
838 | /* Release descriptors in prepare queue */ | ||
839 | if (!list_empty(&d40c->prepare_queue)) | ||
840 | list_for_each_entry_safe(d40d, _d, | ||
841 | &d40c->prepare_queue, node) { | ||
842 | d40_desc_remove(d40d); | ||
843 | d40_desc_free(d40c, d40d); | ||
844 | } | ||
845 | |||
825 | d40c->pending_tx = 0; | 846 | d40c->pending_tx = 0; |
826 | d40c->busy = false; | 847 | d40c->busy = false; |
827 | } | 848 | } |
@@ -1208,7 +1229,6 @@ static void dma_tasklet(unsigned long data) | |||
1208 | 1229 | ||
1209 | if (!d40d->cyclic) { | 1230 | if (!d40d->cyclic) { |
1210 | if (async_tx_test_ack(&d40d->txd)) { | 1231 | if (async_tx_test_ack(&d40d->txd)) { |
1211 | d40_pool_lli_free(d40c, d40d); | ||
1212 | d40_desc_remove(d40d); | 1232 | d40_desc_remove(d40d); |
1213 | d40_desc_free(d40c, d40d); | 1233 | d40_desc_free(d40c, d40d); |
1214 | } else { | 1234 | } else { |
@@ -1595,21 +1615,10 @@ static int d40_free_dma(struct d40_chan *d40c) | |||
1595 | u32 event; | 1615 | u32 event; |
1596 | struct d40_phy_res *phy = d40c->phy_chan; | 1616 | struct d40_phy_res *phy = d40c->phy_chan; |
1597 | bool is_src; | 1617 | bool is_src; |
1598 | struct d40_desc *d; | ||
1599 | struct d40_desc *_d; | ||
1600 | |||
1601 | 1618 | ||
1602 | /* Terminate all queued and active transfers */ | 1619 | /* Terminate all queued and active transfers */ |
1603 | d40_term_all(d40c); | 1620 | d40_term_all(d40c); |
1604 | 1621 | ||
1605 | /* Release client owned descriptors */ | ||
1606 | if (!list_empty(&d40c->client)) | ||
1607 | list_for_each_entry_safe(d, _d, &d40c->client, node) { | ||
1608 | d40_pool_lli_free(d40c, d); | ||
1609 | d40_desc_remove(d); | ||
1610 | d40_desc_free(d40c, d); | ||
1611 | } | ||
1612 | |||
1613 | if (phy == NULL) { | 1622 | if (phy == NULL) { |
1614 | chan_err(d40c, "phy == null\n"); | 1623 | chan_err(d40c, "phy == null\n"); |
1615 | return -EINVAL; | 1624 | return -EINVAL; |
@@ -1911,6 +1920,12 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src, | |||
1911 | goto err; | 1920 | goto err; |
1912 | } | 1921 | } |
1913 | 1922 | ||
1923 | /* | ||
1924 | * add descriptor to the prepare queue in order to be able | ||
1925 | * to free them later in terminate_all | ||
1926 | */ | ||
1927 | list_add_tail(&desc->node, &chan->prepare_queue); | ||
1928 | |||
1914 | spin_unlock_irqrestore(&chan->lock, flags); | 1929 | spin_unlock_irqrestore(&chan->lock, flags); |
1915 | 1930 | ||
1916 | return &desc->txd; | 1931 | return &desc->txd; |
@@ -2400,6 +2415,7 @@ static void __init d40_chan_init(struct d40_base *base, struct dma_device *dma, | |||
2400 | INIT_LIST_HEAD(&d40c->queue); | 2415 | INIT_LIST_HEAD(&d40c->queue); |
2401 | INIT_LIST_HEAD(&d40c->pending_queue); | 2416 | INIT_LIST_HEAD(&d40c->pending_queue); |
2402 | INIT_LIST_HEAD(&d40c->client); | 2417 | INIT_LIST_HEAD(&d40c->client); |
2418 | INIT_LIST_HEAD(&d40c->prepare_queue); | ||
2403 | 2419 | ||
2404 | tasklet_init(&d40c->tasklet, dma_tasklet, | 2420 | tasklet_init(&d40c->tasklet, dma_tasklet, |
2405 | (unsigned long) d40c); | 2421 | (unsigned long) d40c); |
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 82db18506662..fe738f05309b 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
@@ -499,6 +499,7 @@ void drm_connector_cleanup(struct drm_connector *connector) | |||
499 | mutex_lock(&dev->mode_config.mutex); | 499 | mutex_lock(&dev->mode_config.mutex); |
500 | drm_mode_object_put(dev, &connector->base); | 500 | drm_mode_object_put(dev, &connector->base); |
501 | list_del(&connector->head); | 501 | list_del(&connector->head); |
502 | dev->mode_config.num_connector--; | ||
502 | mutex_unlock(&dev->mode_config.mutex); | 503 | mutex_unlock(&dev->mode_config.mutex); |
503 | } | 504 | } |
504 | EXPORT_SYMBOL(drm_connector_cleanup); | 505 | EXPORT_SYMBOL(drm_connector_cleanup); |
@@ -529,6 +530,7 @@ void drm_encoder_cleanup(struct drm_encoder *encoder) | |||
529 | mutex_lock(&dev->mode_config.mutex); | 530 | mutex_lock(&dev->mode_config.mutex); |
530 | drm_mode_object_put(dev, &encoder->base); | 531 | drm_mode_object_put(dev, &encoder->base); |
531 | list_del(&encoder->head); | 532 | list_del(&encoder->head); |
533 | dev->mode_config.num_encoder--; | ||
532 | mutex_unlock(&dev->mode_config.mutex); | 534 | mutex_unlock(&dev->mode_config.mutex); |
533 | } | 535 | } |
534 | EXPORT_SYMBOL(drm_encoder_cleanup); | 536 | EXPORT_SYMBOL(drm_encoder_cleanup); |
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 802b61ac3139..f7c6854eb4dd 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c | |||
@@ -256,7 +256,6 @@ int drm_fb_helper_panic(struct notifier_block *n, unsigned long ununsed, | |||
256 | { | 256 | { |
257 | printk(KERN_ERR "panic occurred, switching back to text console\n"); | 257 | printk(KERN_ERR "panic occurred, switching back to text console\n"); |
258 | return drm_fb_helper_force_kernel_mode(); | 258 | return drm_fb_helper_force_kernel_mode(); |
259 | return 0; | ||
260 | } | 259 | } |
261 | EXPORT_SYMBOL(drm_fb_helper_panic); | 260 | EXPORT_SYMBOL(drm_fb_helper_panic); |
262 | 261 | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c index 8d02d875376d..c919cfc8f2fd 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fence.c +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c | |||
@@ -530,7 +530,8 @@ nouveau_fence_channel_init(struct nouveau_channel *chan) | |||
530 | nouveau_gpuobj_ref(NULL, &obj); | 530 | nouveau_gpuobj_ref(NULL, &obj); |
531 | if (ret) | 531 | if (ret) |
532 | return ret; | 532 | return ret; |
533 | } else { | 533 | } else |
534 | if (USE_SEMA(dev)) { | ||
534 | /* map fence bo into channel's vm */ | 535 | /* map fence bo into channel's vm */ |
535 | ret = nouveau_bo_vma_add(dev_priv->fence.bo, chan->vm, | 536 | ret = nouveau_bo_vma_add(dev_priv->fence.bo, chan->vm, |
536 | &chan->fence.vma); | 537 | &chan->fence.vma); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c index c444cadbf849..2706cb3d871a 100644 --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c | |||
@@ -37,8 +37,11 @@ nouveau_sgdma_populate(struct ttm_backend *be, unsigned long num_pages, | |||
37 | return -ENOMEM; | 37 | return -ENOMEM; |
38 | 38 | ||
39 | nvbe->ttm_alloced = kmalloc(sizeof(bool) * num_pages, GFP_KERNEL); | 39 | nvbe->ttm_alloced = kmalloc(sizeof(bool) * num_pages, GFP_KERNEL); |
40 | if (!nvbe->ttm_alloced) | 40 | if (!nvbe->ttm_alloced) { |
41 | kfree(nvbe->pages); | ||
42 | nvbe->pages = NULL; | ||
41 | return -ENOMEM; | 43 | return -ENOMEM; |
44 | } | ||
42 | 45 | ||
43 | nvbe->nr_pages = 0; | 46 | nvbe->nr_pages = 0; |
44 | while (num_pages--) { | 47 | while (num_pages--) { |
@@ -126,7 +129,7 @@ nv04_sgdma_bind(struct ttm_backend *be, struct ttm_mem_reg *mem) | |||
126 | 129 | ||
127 | for (j = 0; j < PAGE_SIZE / NV_CTXDMA_PAGE_SIZE; j++, pte++) { | 130 | for (j = 0; j < PAGE_SIZE / NV_CTXDMA_PAGE_SIZE; j++, pte++) { |
128 | nv_wo32(gpuobj, (pte * 4) + 0, offset_l | 3); | 131 | nv_wo32(gpuobj, (pte * 4) + 0, offset_l | 3); |
129 | dma_offset += NV_CTXDMA_PAGE_SIZE; | 132 | offset_l += NV_CTXDMA_PAGE_SIZE; |
130 | } | 133 | } |
131 | } | 134 | } |
132 | 135 | ||
diff --git a/drivers/gpu/drm/nouveau/nv04_crtc.c b/drivers/gpu/drm/nouveau/nv04_crtc.c index 118261d4927a..5e45398a9e2d 100644 --- a/drivers/gpu/drm/nouveau/nv04_crtc.c +++ b/drivers/gpu/drm/nouveau/nv04_crtc.c | |||
@@ -781,11 +781,20 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc, | |||
781 | struct drm_device *dev = crtc->dev; | 781 | struct drm_device *dev = crtc->dev; |
782 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 782 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
783 | struct nv04_crtc_reg *regp = &dev_priv->mode_reg.crtc_reg[nv_crtc->index]; | 783 | struct nv04_crtc_reg *regp = &dev_priv->mode_reg.crtc_reg[nv_crtc->index]; |
784 | struct drm_framebuffer *drm_fb = nv_crtc->base.fb; | 784 | struct drm_framebuffer *drm_fb; |
785 | struct nouveau_framebuffer *fb = nouveau_framebuffer(drm_fb); | 785 | struct nouveau_framebuffer *fb; |
786 | int arb_burst, arb_lwm; | 786 | int arb_burst, arb_lwm; |
787 | int ret; | 787 | int ret; |
788 | 788 | ||
789 | NV_DEBUG_KMS(dev, "index %d\n", nv_crtc->index); | ||
790 | |||
791 | /* no fb bound */ | ||
792 | if (!atomic && !crtc->fb) { | ||
793 | NV_DEBUG_KMS(dev, "No FB bound\n"); | ||
794 | return 0; | ||
795 | } | ||
796 | |||
797 | |||
789 | /* If atomic, we want to switch to the fb we were passed, so | 798 | /* If atomic, we want to switch to the fb we were passed, so |
790 | * now we update pointers to do that. (We don't pin; just | 799 | * now we update pointers to do that. (We don't pin; just |
791 | * assume we're already pinned and update the base address.) | 800 | * assume we're already pinned and update the base address.) |
@@ -794,6 +803,8 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc, | |||
794 | drm_fb = passed_fb; | 803 | drm_fb = passed_fb; |
795 | fb = nouveau_framebuffer(passed_fb); | 804 | fb = nouveau_framebuffer(passed_fb); |
796 | } else { | 805 | } else { |
806 | drm_fb = crtc->fb; | ||
807 | fb = nouveau_framebuffer(crtc->fb); | ||
797 | /* If not atomic, we can go ahead and pin, and unpin the | 808 | /* If not atomic, we can go ahead and pin, and unpin the |
798 | * old fb we were passed. | 809 | * old fb we were passed. |
799 | */ | 810 | */ |
diff --git a/drivers/gpu/drm/nouveau/nv50_crtc.c b/drivers/gpu/drm/nouveau/nv50_crtc.c index 46ad59ea2185..5d989073ba6e 100644 --- a/drivers/gpu/drm/nouveau/nv50_crtc.c +++ b/drivers/gpu/drm/nouveau/nv50_crtc.c | |||
@@ -519,12 +519,18 @@ nv50_crtc_do_mode_set_base(struct drm_crtc *crtc, | |||
519 | struct drm_device *dev = nv_crtc->base.dev; | 519 | struct drm_device *dev = nv_crtc->base.dev; |
520 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 520 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
521 | struct nouveau_channel *evo = nv50_display(dev)->master; | 521 | struct nouveau_channel *evo = nv50_display(dev)->master; |
522 | struct drm_framebuffer *drm_fb = nv_crtc->base.fb; | 522 | struct drm_framebuffer *drm_fb; |
523 | struct nouveau_framebuffer *fb = nouveau_framebuffer(drm_fb); | 523 | struct nouveau_framebuffer *fb; |
524 | int ret; | 524 | int ret; |
525 | 525 | ||
526 | NV_DEBUG_KMS(dev, "index %d\n", nv_crtc->index); | 526 | NV_DEBUG_KMS(dev, "index %d\n", nv_crtc->index); |
527 | 527 | ||
528 | /* no fb bound */ | ||
529 | if (!atomic && !crtc->fb) { | ||
530 | NV_DEBUG_KMS(dev, "No FB bound\n"); | ||
531 | return 0; | ||
532 | } | ||
533 | |||
528 | /* If atomic, we want to switch to the fb we were passed, so | 534 | /* If atomic, we want to switch to the fb we were passed, so |
529 | * now we update pointers to do that. (We don't pin; just | 535 | * now we update pointers to do that. (We don't pin; just |
530 | * assume we're already pinned and update the base address.) | 536 | * assume we're already pinned and update the base address.) |
@@ -533,6 +539,8 @@ nv50_crtc_do_mode_set_base(struct drm_crtc *crtc, | |||
533 | drm_fb = passed_fb; | 539 | drm_fb = passed_fb; |
534 | fb = nouveau_framebuffer(passed_fb); | 540 | fb = nouveau_framebuffer(passed_fb); |
535 | } else { | 541 | } else { |
542 | drm_fb = crtc->fb; | ||
543 | fb = nouveau_framebuffer(crtc->fb); | ||
536 | /* If not atomic, we can go ahead and pin, and unpin the | 544 | /* If not atomic, we can go ahead and pin, and unpin the |
537 | * old fb we were passed. | 545 | * old fb we were passed. |
538 | */ | 546 | */ |
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c index fb5fa0898868..dc0a5b56c81a 100644 --- a/drivers/gpu/drm/radeon/evergreen.c +++ b/drivers/gpu/drm/radeon/evergreen.c | |||
@@ -41,6 +41,31 @@ static void evergreen_gpu_init(struct radeon_device *rdev); | |||
41 | void evergreen_fini(struct radeon_device *rdev); | 41 | void evergreen_fini(struct radeon_device *rdev); |
42 | static void evergreen_pcie_gen2_enable(struct radeon_device *rdev); | 42 | static void evergreen_pcie_gen2_enable(struct radeon_device *rdev); |
43 | 43 | ||
44 | void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev) | ||
45 | { | ||
46 | u16 ctl, v; | ||
47 | int cap, err; | ||
48 | |||
49 | cap = pci_pcie_cap(rdev->pdev); | ||
50 | if (!cap) | ||
51 | return; | ||
52 | |||
53 | err = pci_read_config_word(rdev->pdev, cap + PCI_EXP_DEVCTL, &ctl); | ||
54 | if (err) | ||
55 | return; | ||
56 | |||
57 | v = (ctl & PCI_EXP_DEVCTL_READRQ) >> 12; | ||
58 | |||
59 | /* if bios or OS sets MAX_READ_REQUEST_SIZE to an invalid value, fix it | ||
60 | * to avoid hangs or perfomance issues | ||
61 | */ | ||
62 | if ((v == 0) || (v == 6) || (v == 7)) { | ||
63 | ctl &= ~PCI_EXP_DEVCTL_READRQ; | ||
64 | ctl |= (2 << 12); | ||
65 | pci_write_config_word(rdev->pdev, cap + PCI_EXP_DEVCTL, ctl); | ||
66 | } | ||
67 | } | ||
68 | |||
44 | void evergreen_pre_page_flip(struct radeon_device *rdev, int crtc) | 69 | void evergreen_pre_page_flip(struct radeon_device *rdev, int crtc) |
45 | { | 70 | { |
46 | /* enable the pflip int */ | 71 | /* enable the pflip int */ |
@@ -1357,6 +1382,7 @@ int evergreen_cp_resume(struct radeon_device *rdev) | |||
1357 | SOFT_RESET_PA | | 1382 | SOFT_RESET_PA | |
1358 | SOFT_RESET_SH | | 1383 | SOFT_RESET_SH | |
1359 | SOFT_RESET_VGT | | 1384 | SOFT_RESET_VGT | |
1385 | SOFT_RESET_SPI | | ||
1360 | SOFT_RESET_SX)); | 1386 | SOFT_RESET_SX)); |
1361 | RREG32(GRBM_SOFT_RESET); | 1387 | RREG32(GRBM_SOFT_RESET); |
1362 | mdelay(15); | 1388 | mdelay(15); |
@@ -1862,6 +1888,8 @@ static void evergreen_gpu_init(struct radeon_device *rdev) | |||
1862 | 1888 | ||
1863 | WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff)); | 1889 | WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff)); |
1864 | 1890 | ||
1891 | evergreen_fix_pci_max_read_req_size(rdev); | ||
1892 | |||
1865 | cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG) & ~2; | 1893 | cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG) & ~2; |
1866 | 1894 | ||
1867 | cc_gc_shader_pipe_config |= | 1895 | cc_gc_shader_pipe_config |= |
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c index 44c4750f4518..cbf57d75d925 100644 --- a/drivers/gpu/drm/radeon/ni.c +++ b/drivers/gpu/drm/radeon/ni.c | |||
@@ -39,6 +39,7 @@ extern int evergreen_mc_wait_for_idle(struct radeon_device *rdev); | |||
39 | extern void evergreen_mc_program(struct radeon_device *rdev); | 39 | extern void evergreen_mc_program(struct radeon_device *rdev); |
40 | extern void evergreen_irq_suspend(struct radeon_device *rdev); | 40 | extern void evergreen_irq_suspend(struct radeon_device *rdev); |
41 | extern int evergreen_mc_init(struct radeon_device *rdev); | 41 | extern int evergreen_mc_init(struct radeon_device *rdev); |
42 | extern void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev); | ||
42 | 43 | ||
43 | #define EVERGREEN_PFP_UCODE_SIZE 1120 | 44 | #define EVERGREEN_PFP_UCODE_SIZE 1120 |
44 | #define EVERGREEN_PM4_UCODE_SIZE 1376 | 45 | #define EVERGREEN_PM4_UCODE_SIZE 1376 |
@@ -669,6 +670,8 @@ static void cayman_gpu_init(struct radeon_device *rdev) | |||
669 | 670 | ||
670 | WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff)); | 671 | WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff)); |
671 | 672 | ||
673 | evergreen_fix_pci_max_read_req_size(rdev); | ||
674 | |||
672 | mc_shared_chmap = RREG32(MC_SHARED_CHMAP); | 675 | mc_shared_chmap = RREG32(MC_SHARED_CHMAP); |
673 | mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG); | 676 | mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG); |
674 | 677 | ||
@@ -1159,6 +1162,7 @@ int cayman_cp_resume(struct radeon_device *rdev) | |||
1159 | SOFT_RESET_PA | | 1162 | SOFT_RESET_PA | |
1160 | SOFT_RESET_SH | | 1163 | SOFT_RESET_SH | |
1161 | SOFT_RESET_VGT | | 1164 | SOFT_RESET_VGT | |
1165 | SOFT_RESET_SPI | | ||
1162 | SOFT_RESET_SX)); | 1166 | SOFT_RESET_SX)); |
1163 | RREG32(GRBM_SOFT_RESET); | 1167 | RREG32(GRBM_SOFT_RESET); |
1164 | mdelay(15); | 1168 | mdelay(15); |
diff --git a/drivers/gpu/drm/radeon/radeon_clocks.c b/drivers/gpu/drm/radeon/radeon_clocks.c index dcd0863e31ae..b6e18c8db9f5 100644 --- a/drivers/gpu/drm/radeon/radeon_clocks.c +++ b/drivers/gpu/drm/radeon/radeon_clocks.c | |||
@@ -219,6 +219,9 @@ void radeon_get_clock_info(struct drm_device *dev) | |||
219 | } else { | 219 | } else { |
220 | DRM_INFO("Using generic clock info\n"); | 220 | DRM_INFO("Using generic clock info\n"); |
221 | 221 | ||
222 | /* may need to be per card */ | ||
223 | rdev->clock.max_pixel_clock = 35000; | ||
224 | |||
222 | if (rdev->flags & RADEON_IS_IGP) { | 225 | if (rdev->flags & RADEON_IS_IGP) { |
223 | p1pll->reference_freq = 1432; | 226 | p1pll->reference_freq = 1432; |
224 | p2pll->reference_freq = 1432; | 227 | p2pll->reference_freq = 1432; |
diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c index e0138b674aca..63675241c7ff 100644 --- a/drivers/gpu/drm/radeon/radeon_combios.c +++ b/drivers/gpu/drm/radeon/radeon_combios.c | |||
@@ -3298,6 +3298,14 @@ void radeon_combios_asic_init(struct drm_device *dev) | |||
3298 | rdev->pdev->subsystem_device == 0x30a4) | 3298 | rdev->pdev->subsystem_device == 0x30a4) |
3299 | return; | 3299 | return; |
3300 | 3300 | ||
3301 | /* quirk for rs4xx Compaq Presario V5245EU laptop to make it resume | ||
3302 | * - it hangs on resume inside the dynclk 1 table. | ||
3303 | */ | ||
3304 | if (rdev->family == CHIP_RS480 && | ||
3305 | rdev->pdev->subsystem_vendor == 0x103c && | ||
3306 | rdev->pdev->subsystem_device == 0x30ae) | ||
3307 | return; | ||
3308 | |||
3301 | /* DYN CLK 1 */ | 3309 | /* DYN CLK 1 */ |
3302 | table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); | 3310 | table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE); |
3303 | if (table) | 3311 | if (table) |
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c index 4f0c1ecac72e..c4b8741dbf58 100644 --- a/drivers/gpu/drm/radeon/radeon_connectors.c +++ b/drivers/gpu/drm/radeon/radeon_connectors.c | |||
@@ -1297,12 +1297,33 @@ radeon_dp_detect(struct drm_connector *connector, bool force) | |||
1297 | if (!radeon_dig_connector->edp_on) | 1297 | if (!radeon_dig_connector->edp_on) |
1298 | atombios_set_edp_panel_power(connector, | 1298 | atombios_set_edp_panel_power(connector, |
1299 | ATOM_TRANSMITTER_ACTION_POWER_OFF); | 1299 | ATOM_TRANSMITTER_ACTION_POWER_OFF); |
1300 | } else { | 1300 | } else if (radeon_connector_encoder_is_dp_bridge(connector)) { |
1301 | /* need to setup ddc on the bridge */ | 1301 | /* DP bridges are always DP */ |
1302 | if (radeon_connector_encoder_is_dp_bridge(connector)) { | 1302 | radeon_dig_connector->dp_sink_type = CONNECTOR_OBJECT_ID_DISPLAYPORT; |
1303 | /* get the DPCD from the bridge */ | ||
1304 | radeon_dp_getdpcd(radeon_connector); | ||
1305 | |||
1306 | if (radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) | ||
1307 | ret = connector_status_connected; | ||
1308 | else { | ||
1309 | /* need to setup ddc on the bridge */ | ||
1303 | if (encoder) | 1310 | if (encoder) |
1304 | radeon_atom_ext_encoder_setup_ddc(encoder); | 1311 | radeon_atom_ext_encoder_setup_ddc(encoder); |
1312 | if (radeon_ddc_probe(radeon_connector, | ||
1313 | radeon_connector->requires_extended_probe)) | ||
1314 | ret = connector_status_connected; | ||
1315 | } | ||
1316 | |||
1317 | if ((ret == connector_status_disconnected) && | ||
1318 | radeon_connector->dac_load_detect) { | ||
1319 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); | ||
1320 | struct drm_encoder_helper_funcs *encoder_funcs; | ||
1321 | if (encoder) { | ||
1322 | encoder_funcs = encoder->helper_private; | ||
1323 | ret = encoder_funcs->detect(encoder, connector); | ||
1324 | } | ||
1305 | } | 1325 | } |
1326 | } else { | ||
1306 | radeon_dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector); | 1327 | radeon_dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector); |
1307 | if (radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) { | 1328 | if (radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) { |
1308 | ret = connector_status_connected; | 1329 | ret = connector_status_connected; |
@@ -1318,16 +1339,6 @@ radeon_dp_detect(struct drm_connector *connector, bool force) | |||
1318 | ret = connector_status_connected; | 1339 | ret = connector_status_connected; |
1319 | } | 1340 | } |
1320 | } | 1341 | } |
1321 | |||
1322 | if ((ret == connector_status_disconnected) && | ||
1323 | radeon_connector->dac_load_detect) { | ||
1324 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); | ||
1325 | struct drm_encoder_helper_funcs *encoder_funcs; | ||
1326 | if (encoder) { | ||
1327 | encoder_funcs = encoder->helper_private; | ||
1328 | ret = encoder_funcs->detect(encoder, connector); | ||
1329 | } | ||
1330 | } | ||
1331 | } | 1342 | } |
1332 | 1343 | ||
1333 | radeon_connector_update_scratch_regs(connector, ret); | 1344 | radeon_connector_update_scratch_regs(connector, ret); |
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c index 1a858944e4f3..6cc17fb96a57 100644 --- a/drivers/gpu/drm/radeon/radeon_display.c +++ b/drivers/gpu/drm/radeon/radeon_display.c | |||
@@ -707,16 +707,21 @@ int radeon_ddc_get_modes(struct radeon_connector *radeon_connector) | |||
707 | radeon_router_select_ddc_port(radeon_connector); | 707 | radeon_router_select_ddc_port(radeon_connector); |
708 | 708 | ||
709 | if ((radeon_connector->base.connector_type == DRM_MODE_CONNECTOR_DisplayPort) || | 709 | if ((radeon_connector->base.connector_type == DRM_MODE_CONNECTOR_DisplayPort) || |
710 | (radeon_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP)) { | 710 | (radeon_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) || |
711 | radeon_connector_encoder_is_dp_bridge(&radeon_connector->base)) { | ||
711 | struct radeon_connector_atom_dig *dig = radeon_connector->con_priv; | 712 | struct radeon_connector_atom_dig *dig = radeon_connector->con_priv; |
713 | |||
712 | if ((dig->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT || | 714 | if ((dig->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT || |
713 | dig->dp_sink_type == CONNECTOR_OBJECT_ID_eDP) && dig->dp_i2c_bus) | 715 | dig->dp_sink_type == CONNECTOR_OBJECT_ID_eDP) && dig->dp_i2c_bus) |
714 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, &dig->dp_i2c_bus->adapter); | 716 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, |
715 | } | 717 | &dig->dp_i2c_bus->adapter); |
716 | if (!radeon_connector->ddc_bus) | 718 | else if (radeon_connector->ddc_bus && !radeon_connector->edid) |
717 | return -1; | 719 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, |
718 | if (!radeon_connector->edid) { | 720 | &radeon_connector->ddc_bus->adapter); |
719 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, &radeon_connector->ddc_bus->adapter); | 721 | } else { |
722 | if (radeon_connector->ddc_bus && !radeon_connector->edid) | ||
723 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, | ||
724 | &radeon_connector->ddc_bus->adapter); | ||
720 | } | 725 | } |
721 | 726 | ||
722 | if (!radeon_connector->edid) { | 727 | if (!radeon_connector->edid) { |
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 7d27d2b0445a..7484e1b67249 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
@@ -277,6 +277,7 @@ | |||
277 | #define USB_DEVICE_ID_PENPOWER 0x00f4 | 277 | #define USB_DEVICE_ID_PENPOWER 0x00f4 |
278 | 278 | ||
279 | #define USB_VENDOR_ID_GREENASIA 0x0e8f | 279 | #define USB_VENDOR_ID_GREENASIA 0x0e8f |
280 | #define USB_DEVICE_ID_GREENASIA_DUAL_USB_JOYPAD 0x3013 | ||
280 | 281 | ||
281 | #define USB_VENDOR_ID_GRETAGMACBETH 0x0971 | 282 | #define USB_VENDOR_ID_GRETAGMACBETH 0x0971 |
282 | #define USB_DEVICE_ID_GRETAGMACBETH_HUEY 0x2005 | 283 | #define USB_DEVICE_ID_GRETAGMACBETH_HUEY 0x2005 |
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index 0ec91c18a421..f0fbd7bd239e 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c | |||
@@ -81,6 +81,28 @@ MODULE_PARM_DESC(report_undeciphered, "Report undeciphered multi-touch state fie | |||
81 | #define NO_TOUCHES -1 | 81 | #define NO_TOUCHES -1 |
82 | #define SINGLE_TOUCH_UP -2 | 82 | #define SINGLE_TOUCH_UP -2 |
83 | 83 | ||
84 | /* Touch surface information. Dimension is in hundredths of a mm, min and max | ||
85 | * are in units. */ | ||
86 | #define MOUSE_DIMENSION_X (float)9056 | ||
87 | #define MOUSE_MIN_X -1100 | ||
88 | #define MOUSE_MAX_X 1258 | ||
89 | #define MOUSE_RES_X ((MOUSE_MAX_X - MOUSE_MIN_X) / (MOUSE_DIMENSION_X / 100)) | ||
90 | #define MOUSE_DIMENSION_Y (float)5152 | ||
91 | #define MOUSE_MIN_Y -1589 | ||
92 | #define MOUSE_MAX_Y 2047 | ||
93 | #define MOUSE_RES_Y ((MOUSE_MAX_Y - MOUSE_MIN_Y) / (MOUSE_DIMENSION_Y / 100)) | ||
94 | |||
95 | #define TRACKPAD_DIMENSION_X (float)13000 | ||
96 | #define TRACKPAD_MIN_X -2909 | ||
97 | #define TRACKPAD_MAX_X 3167 | ||
98 | #define TRACKPAD_RES_X \ | ||
99 | ((TRACKPAD_MAX_X - TRACKPAD_MIN_X) / (TRACKPAD_DIMENSION_X / 100)) | ||
100 | #define TRACKPAD_DIMENSION_Y (float)11000 | ||
101 | #define TRACKPAD_MIN_Y -2456 | ||
102 | #define TRACKPAD_MAX_Y 2565 | ||
103 | #define TRACKPAD_RES_Y \ | ||
104 | ((TRACKPAD_MAX_Y - TRACKPAD_MIN_Y) / (TRACKPAD_DIMENSION_Y / 100)) | ||
105 | |||
84 | /** | 106 | /** |
85 | * struct magicmouse_sc - Tracks Magic Mouse-specific data. | 107 | * struct magicmouse_sc - Tracks Magic Mouse-specific data. |
86 | * @input: Input device through which we report events. | 108 | * @input: Input device through which we report events. |
@@ -406,17 +428,31 @@ static void magicmouse_setup_input(struct input_dev *input, struct hid_device *h | |||
406 | * inverse of the reported Y. | 428 | * inverse of the reported Y. |
407 | */ | 429 | */ |
408 | if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE) { | 430 | if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE) { |
409 | input_set_abs_params(input, ABS_MT_POSITION_X, -1100, | 431 | input_set_abs_params(input, ABS_MT_POSITION_X, |
410 | 1358, 4, 0); | 432 | MOUSE_MIN_X, MOUSE_MAX_X, 4, 0); |
411 | input_set_abs_params(input, ABS_MT_POSITION_Y, -1589, | 433 | input_set_abs_params(input, ABS_MT_POSITION_Y, |
412 | 2047, 4, 0); | 434 | MOUSE_MIN_Y, MOUSE_MAX_Y, 4, 0); |
435 | |||
436 | input_abs_set_res(input, ABS_MT_POSITION_X, | ||
437 | MOUSE_RES_X); | ||
438 | input_abs_set_res(input, ABS_MT_POSITION_Y, | ||
439 | MOUSE_RES_Y); | ||
413 | } else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */ | 440 | } else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */ |
414 | input_set_abs_params(input, ABS_X, -2909, 3167, 4, 0); | 441 | input_set_abs_params(input, ABS_X, TRACKPAD_MIN_X, |
415 | input_set_abs_params(input, ABS_Y, -2456, 2565, 4, 0); | 442 | TRACKPAD_MAX_X, 4, 0); |
416 | input_set_abs_params(input, ABS_MT_POSITION_X, -2909, | 443 | input_set_abs_params(input, ABS_Y, TRACKPAD_MIN_Y, |
417 | 3167, 4, 0); | 444 | TRACKPAD_MAX_Y, 4, 0); |
418 | input_set_abs_params(input, ABS_MT_POSITION_Y, -2456, | 445 | input_set_abs_params(input, ABS_MT_POSITION_X, |
419 | 2565, 4, 0); | 446 | TRACKPAD_MIN_X, TRACKPAD_MAX_X, 4, 0); |
447 | input_set_abs_params(input, ABS_MT_POSITION_Y, | ||
448 | TRACKPAD_MIN_Y, TRACKPAD_MAX_Y, 4, 0); | ||
449 | |||
450 | input_abs_set_res(input, ABS_X, TRACKPAD_RES_X); | ||
451 | input_abs_set_res(input, ABS_Y, TRACKPAD_RES_Y); | ||
452 | input_abs_set_res(input, ABS_MT_POSITION_X, | ||
453 | TRACKPAD_RES_X); | ||
454 | input_abs_set_res(input, ABS_MT_POSITION_Y, | ||
455 | TRACKPAD_RES_Y); | ||
420 | } | 456 | } |
421 | 457 | ||
422 | input_set_events_per_packet(input, 60); | 458 | input_set_events_per_packet(input, 60); |
@@ -501,9 +537,17 @@ static int magicmouse_probe(struct hid_device *hdev, | |||
501 | } | 537 | } |
502 | report->size = 6; | 538 | report->size = 6; |
503 | 539 | ||
540 | /* | ||
541 | * Some devices repond with 'invalid report id' when feature | ||
542 | * report switching it into multitouch mode is sent to it. | ||
543 | * | ||
544 | * This results in -EIO from the _raw low-level transport callback, | ||
545 | * but there seems to be no other way of switching the mode. | ||
546 | * Thus the super-ugly hacky success check below. | ||
547 | */ | ||
504 | ret = hdev->hid_output_raw_report(hdev, feature, sizeof(feature), | 548 | ret = hdev->hid_output_raw_report(hdev, feature, sizeof(feature), |
505 | HID_FEATURE_REPORT); | 549 | HID_FEATURE_REPORT); |
506 | if (ret != sizeof(feature)) { | 550 | if (ret != -EIO && ret != sizeof(feature)) { |
507 | hid_err(hdev, "unable to request touch data (%d)\n", ret); | 551 | hid_err(hdev, "unable to request touch data (%d)\n", ret); |
508 | goto err_stop_hw; | 552 | goto err_stop_hw; |
509 | } | 553 | } |
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 06888323828c..a597039d0755 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c | |||
@@ -353,11 +353,7 @@ static int wacom_probe(struct hid_device *hdev, | |||
353 | if (ret) { | 353 | if (ret) { |
354 | hid_warn(hdev, "can't create sysfs battery attribute, err: %d\n", | 354 | hid_warn(hdev, "can't create sysfs battery attribute, err: %d\n", |
355 | ret); | 355 | ret); |
356 | /* | 356 | goto err_battery; |
357 | * battery attribute is not critical for the tablet, but if it | ||
358 | * failed then there is no need to create ac attribute | ||
359 | */ | ||
360 | goto move_on; | ||
361 | } | 357 | } |
362 | 358 | ||
363 | wdata->ac.properties = wacom_ac_props; | 359 | wdata->ac.properties = wacom_ac_props; |
@@ -371,14 +367,8 @@ static int wacom_probe(struct hid_device *hdev, | |||
371 | if (ret) { | 367 | if (ret) { |
372 | hid_warn(hdev, | 368 | hid_warn(hdev, |
373 | "can't create ac battery attribute, err: %d\n", ret); | 369 | "can't create ac battery attribute, err: %d\n", ret); |
374 | /* | 370 | goto err_ac; |
375 | * ac attribute is not critical for the tablet, but if it | ||
376 | * failed then we don't want to battery attribute to exist | ||
377 | */ | ||
378 | power_supply_unregister(&wdata->battery); | ||
379 | } | 371 | } |
380 | |||
381 | move_on: | ||
382 | #endif | 372 | #endif |
383 | hidinput = list_entry(hdev->inputs.next, struct hid_input, list); | 373 | hidinput = list_entry(hdev->inputs.next, struct hid_input, list); |
384 | input = hidinput->input; | 374 | input = hidinput->input; |
@@ -416,6 +406,13 @@ move_on: | |||
416 | 406 | ||
417 | return 0; | 407 | return 0; |
418 | 408 | ||
409 | #ifdef CONFIG_HID_WACOM_POWER_SUPPLY | ||
410 | err_ac: | ||
411 | power_supply_unregister(&wdata->battery); | ||
412 | err_battery: | ||
413 | device_remove_file(&hdev->dev, &dev_attr_speed); | ||
414 | hid_hw_stop(hdev); | ||
415 | #endif | ||
419 | err_free: | 416 | err_free: |
420 | kfree(wdata); | 417 | kfree(wdata); |
421 | return ret; | 418 | return ret; |
@@ -426,6 +423,7 @@ static void wacom_remove(struct hid_device *hdev) | |||
426 | #ifdef CONFIG_HID_WACOM_POWER_SUPPLY | 423 | #ifdef CONFIG_HID_WACOM_POWER_SUPPLY |
427 | struct wacom_data *wdata = hid_get_drvdata(hdev); | 424 | struct wacom_data *wdata = hid_get_drvdata(hdev); |
428 | #endif | 425 | #endif |
426 | device_remove_file(&hdev->dev, &dev_attr_speed); | ||
429 | hid_hw_stop(hdev); | 427 | hid_hw_stop(hdev); |
430 | 428 | ||
431 | #ifdef CONFIG_HID_WACOM_POWER_SUPPLY | 429 | #ifdef CONFIG_HID_WACOM_POWER_SUPPLY |
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c index 4bdb5d46c52c..3146fdcda272 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c | |||
@@ -47,6 +47,7 @@ static const struct hid_blacklist { | |||
47 | { USB_VENDOR_ID_AFATECH, USB_DEVICE_ID_AFATECH_AF9016, HID_QUIRK_FULLSPEED_INTERVAL }, | 47 | { USB_VENDOR_ID_AFATECH, USB_DEVICE_ID_AFATECH_AF9016, HID_QUIRK_FULLSPEED_INTERVAL }, |
48 | 48 | ||
49 | { USB_VENDOR_ID_ETURBOTOUCH, USB_DEVICE_ID_ETURBOTOUCH, HID_QUIRK_MULTI_INPUT }, | 49 | { USB_VENDOR_ID_ETURBOTOUCH, USB_DEVICE_ID_ETURBOTOUCH, HID_QUIRK_MULTI_INPUT }, |
50 | { USB_VENDOR_ID_GREENASIA, USB_DEVICE_ID_GREENASIA_DUAL_USB_JOYPAD, HID_QUIRK_MULTI_INPUT }, | ||
50 | { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, | 51 | { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, |
51 | { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT }, | 52 | { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT }, |
52 | { USB_VENDOR_ID_TOUCHPACK, USB_DEVICE_ID_TOUCHPACK_RTS, HID_QUIRK_MULTI_INPUT }, | 53 | { USB_VENDOR_ID_TOUCHPACK, USB_DEVICE_ID_TOUCHPACK_RTS, HID_QUIRK_MULTI_INPUT }, |
diff --git a/drivers/hwmon/max16065.c b/drivers/hwmon/max16065.c index d94a24fdf4ba..dd2d7b9620c2 100644 --- a/drivers/hwmon/max16065.c +++ b/drivers/hwmon/max16065.c | |||
@@ -124,7 +124,7 @@ static inline int MV_TO_LIMIT(int mv, int range) | |||
124 | 124 | ||
125 | static inline int ADC_TO_CURR(int adc, int gain) | 125 | static inline int ADC_TO_CURR(int adc, int gain) |
126 | { | 126 | { |
127 | return adc * 1400000 / gain * 255; | 127 | return adc * 1400000 / (gain * 255); |
128 | } | 128 | } |
129 | 129 | ||
130 | /* | 130 | /* |
diff --git a/drivers/hwmon/pmbus/ucd9000.c b/drivers/hwmon/pmbus/ucd9000.c index ace1c7319734..d0ddb60155c9 100644 --- a/drivers/hwmon/pmbus/ucd9000.c +++ b/drivers/hwmon/pmbus/ucd9000.c | |||
@@ -141,13 +141,11 @@ static int ucd9000_probe(struct i2c_client *client, | |||
141 | block_buffer[ret] = '\0'; | 141 | block_buffer[ret] = '\0'; |
142 | dev_info(&client->dev, "Device ID %s\n", block_buffer); | 142 | dev_info(&client->dev, "Device ID %s\n", block_buffer); |
143 | 143 | ||
144 | mid = NULL; | 144 | for (mid = ucd9000_id; mid->name[0]; mid++) { |
145 | for (i = 0; i < ARRAY_SIZE(ucd9000_id); i++) { | ||
146 | mid = &ucd9000_id[i]; | ||
147 | if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) | 145 | if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) |
148 | break; | 146 | break; |
149 | } | 147 | } |
150 | if (!mid || !strlen(mid->name)) { | 148 | if (!mid->name[0]) { |
151 | dev_err(&client->dev, "Unsupported device\n"); | 149 | dev_err(&client->dev, "Unsupported device\n"); |
152 | return -ENODEV; | 150 | return -ENODEV; |
153 | } | 151 | } |
diff --git a/drivers/hwmon/pmbus/ucd9200.c b/drivers/hwmon/pmbus/ucd9200.c index ffcc1cf3609d..c65e9da707cc 100644 --- a/drivers/hwmon/pmbus/ucd9200.c +++ b/drivers/hwmon/pmbus/ucd9200.c | |||
@@ -68,13 +68,11 @@ static int ucd9200_probe(struct i2c_client *client, | |||
68 | block_buffer[ret] = '\0'; | 68 | block_buffer[ret] = '\0'; |
69 | dev_info(&client->dev, "Device ID %s\n", block_buffer); | 69 | dev_info(&client->dev, "Device ID %s\n", block_buffer); |
70 | 70 | ||
71 | mid = NULL; | 71 | for (mid = ucd9200_id; mid->name[0]; mid++) { |
72 | for (i = 0; i < ARRAY_SIZE(ucd9200_id); i++) { | ||
73 | mid = &ucd9200_id[i]; | ||
74 | if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) | 72 | if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) |
75 | break; | 73 | break; |
76 | } | 74 | } |
77 | if (!mid || !strlen(mid->name)) { | 75 | if (!mid->name[0]) { |
78 | dev_err(&client->dev, "Unsupported device\n"); | 76 | dev_err(&client->dev, "Unsupported device\n"); |
79 | return -ENODEV; | 77 | return -ENODEV; |
80 | } | 78 | } |
diff --git a/drivers/i2c/busses/i2c-pxa-pci.c b/drivers/i2c/busses/i2c-pxa-pci.c index 6659d269b841..b73da6cd6f91 100644 --- a/drivers/i2c/busses/i2c-pxa-pci.c +++ b/drivers/i2c/busses/i2c-pxa-pci.c | |||
@@ -109,12 +109,15 @@ static int __devinit ce4100_i2c_probe(struct pci_dev *dev, | |||
109 | return -EINVAL; | 109 | return -EINVAL; |
110 | } | 110 | } |
111 | sds = kzalloc(sizeof(*sds), GFP_KERNEL); | 111 | sds = kzalloc(sizeof(*sds), GFP_KERNEL); |
112 | if (!sds) | 112 | if (!sds) { |
113 | ret = -ENOMEM; | ||
113 | goto err_mem; | 114 | goto err_mem; |
115 | } | ||
114 | 116 | ||
115 | for (i = 0; i < ARRAY_SIZE(sds->pdev); i++) { | 117 | for (i = 0; i < ARRAY_SIZE(sds->pdev); i++) { |
116 | sds->pdev[i] = add_i2c_device(dev, i); | 118 | sds->pdev[i] = add_i2c_device(dev, i); |
117 | if (IS_ERR(sds->pdev[i])) { | 119 | if (IS_ERR(sds->pdev[i])) { |
120 | ret = PTR_ERR(sds->pdev[i]); | ||
118 | while (--i >= 0) | 121 | while (--i >= 0) |
119 | platform_device_unregister(sds->pdev[i]); | 122 | platform_device_unregister(sds->pdev[i]); |
120 | goto err_dev_add; | 123 | goto err_dev_add; |
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 2440b7411978..3c94c4a81a55 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c | |||
@@ -270,14 +270,30 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev) | |||
270 | 270 | ||
271 | /* Rounds down to not include partial word at the end of buf */ | 271 | /* Rounds down to not include partial word at the end of buf */ |
272 | words_to_transfer = buf_remaining / BYTES_PER_FIFO_WORD; | 272 | words_to_transfer = buf_remaining / BYTES_PER_FIFO_WORD; |
273 | if (words_to_transfer > tx_fifo_avail) | ||
274 | words_to_transfer = tx_fifo_avail; | ||
275 | 273 | ||
276 | i2c_writesl(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer); | 274 | /* It's very common to have < 4 bytes, so optimize that case. */ |
277 | 275 | if (words_to_transfer) { | |
278 | buf += words_to_transfer * BYTES_PER_FIFO_WORD; | 276 | if (words_to_transfer > tx_fifo_avail) |
279 | buf_remaining -= words_to_transfer * BYTES_PER_FIFO_WORD; | 277 | words_to_transfer = tx_fifo_avail; |
280 | tx_fifo_avail -= words_to_transfer; | 278 | |
279 | /* | ||
280 | * Update state before writing to FIFO. If this casues us | ||
281 | * to finish writing all bytes (AKA buf_remaining goes to 0) we | ||
282 | * have a potential for an interrupt (PACKET_XFER_COMPLETE is | ||
283 | * not maskable). We need to make sure that the isr sees | ||
284 | * buf_remaining as 0 and doesn't call us back re-entrantly. | ||
285 | */ | ||
286 | buf_remaining -= words_to_transfer * BYTES_PER_FIFO_WORD; | ||
287 | tx_fifo_avail -= words_to_transfer; | ||
288 | i2c_dev->msg_buf_remaining = buf_remaining; | ||
289 | i2c_dev->msg_buf = buf + | ||
290 | words_to_transfer * BYTES_PER_FIFO_WORD; | ||
291 | barrier(); | ||
292 | |||
293 | i2c_writesl(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer); | ||
294 | |||
295 | buf += words_to_transfer * BYTES_PER_FIFO_WORD; | ||
296 | } | ||
281 | 297 | ||
282 | /* | 298 | /* |
283 | * If there is a partial word at the end of buf, handle it manually to | 299 | * If there is a partial word at the end of buf, handle it manually to |
@@ -287,14 +303,15 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev) | |||
287 | if (tx_fifo_avail > 0 && buf_remaining > 0) { | 303 | if (tx_fifo_avail > 0 && buf_remaining > 0) { |
288 | BUG_ON(buf_remaining > 3); | 304 | BUG_ON(buf_remaining > 3); |
289 | memcpy(&val, buf, buf_remaining); | 305 | memcpy(&val, buf, buf_remaining); |
306 | |||
307 | /* Again update before writing to FIFO to make sure isr sees. */ | ||
308 | i2c_dev->msg_buf_remaining = 0; | ||
309 | i2c_dev->msg_buf = NULL; | ||
310 | barrier(); | ||
311 | |||
290 | i2c_writel(i2c_dev, val, I2C_TX_FIFO); | 312 | i2c_writel(i2c_dev, val, I2C_TX_FIFO); |
291 | buf_remaining = 0; | ||
292 | tx_fifo_avail--; | ||
293 | } | 313 | } |
294 | 314 | ||
295 | BUG_ON(tx_fifo_avail > 0 && buf_remaining > 0); | ||
296 | i2c_dev->msg_buf_remaining = buf_remaining; | ||
297 | i2c_dev->msg_buf = buf; | ||
298 | return 0; | 315 | return 0; |
299 | } | 316 | } |
300 | 317 | ||
@@ -411,9 +428,10 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id) | |||
411 | tegra_i2c_mask_irq(i2c_dev, I2C_INT_TX_FIFO_DATA_REQ); | 428 | tegra_i2c_mask_irq(i2c_dev, I2C_INT_TX_FIFO_DATA_REQ); |
412 | } | 429 | } |
413 | 430 | ||
414 | if ((status & I2C_INT_PACKET_XFER_COMPLETE) && | 431 | if (status & I2C_INT_PACKET_XFER_COMPLETE) { |
415 | !i2c_dev->msg_buf_remaining) | 432 | BUG_ON(i2c_dev->msg_buf_remaining); |
416 | complete(&i2c_dev->msg_complete); | 433 | complete(&i2c_dev->msg_complete); |
434 | } | ||
417 | 435 | ||
418 | i2c_writel(i2c_dev, status, I2C_INT_STATUS); | 436 | i2c_writel(i2c_dev, status, I2C_INT_STATUS); |
419 | if (i2c_dev->is_dvc) | 437 | if (i2c_dev->is_dvc) |
@@ -531,7 +549,7 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], | |||
531 | 549 | ||
532 | static u32 tegra_i2c_func(struct i2c_adapter *adap) | 550 | static u32 tegra_i2c_func(struct i2c_adapter *adap) |
533 | { | 551 | { |
534 | return I2C_FUNC_I2C; | 552 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; |
535 | } | 553 | } |
536 | 554 | ||
537 | static const struct i2c_algorithm tegra_i2c_algo = { | 555 | static const struct i2c_algorithm tegra_i2c_algo = { |
@@ -719,6 +737,17 @@ static int tegra_i2c_resume(struct platform_device *pdev) | |||
719 | } | 737 | } |
720 | #endif | 738 | #endif |
721 | 739 | ||
740 | #if defined(CONFIG_OF) | ||
741 | /* Match table for of_platform binding */ | ||
742 | static const struct of_device_id tegra_i2c_of_match[] __devinitconst = { | ||
743 | { .compatible = "nvidia,tegra20-i2c", }, | ||
744 | {}, | ||
745 | }; | ||
746 | MODULE_DEVICE_TABLE(of, tegra_i2c_of_match); | ||
747 | #else | ||
748 | #define tegra_i2c_of_match NULL | ||
749 | #endif | ||
750 | |||
722 | static struct platform_driver tegra_i2c_driver = { | 751 | static struct platform_driver tegra_i2c_driver = { |
723 | .probe = tegra_i2c_probe, | 752 | .probe = tegra_i2c_probe, |
724 | .remove = tegra_i2c_remove, | 753 | .remove = tegra_i2c_remove, |
@@ -729,6 +758,7 @@ static struct platform_driver tegra_i2c_driver = { | |||
729 | .driver = { | 758 | .driver = { |
730 | .name = "tegra-i2c", | 759 | .name = "tegra-i2c", |
731 | .owner = THIS_MODULE, | 760 | .owner = THIS_MODULE, |
761 | .of_match_table = tegra_i2c_of_match, | ||
732 | }, | 762 | }, |
733 | }; | 763 | }; |
734 | 764 | ||
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index a14f8dc23462..0e4227f457af 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c | |||
@@ -605,7 +605,9 @@ static void build_inv_all(struct iommu_cmd *cmd) | |||
605 | * Writes the command to the IOMMUs command buffer and informs the | 605 | * Writes the command to the IOMMUs command buffer and informs the |
606 | * hardware about the new command. | 606 | * hardware about the new command. |
607 | */ | 607 | */ |
608 | static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd) | 608 | static int iommu_queue_command_sync(struct amd_iommu *iommu, |
609 | struct iommu_cmd *cmd, | ||
610 | bool sync) | ||
609 | { | 611 | { |
610 | u32 left, tail, head, next_tail; | 612 | u32 left, tail, head, next_tail; |
611 | unsigned long flags; | 613 | unsigned long flags; |
@@ -639,13 +641,18 @@ again: | |||
639 | copy_cmd_to_buffer(iommu, cmd, tail); | 641 | copy_cmd_to_buffer(iommu, cmd, tail); |
640 | 642 | ||
641 | /* We need to sync now to make sure all commands are processed */ | 643 | /* We need to sync now to make sure all commands are processed */ |
642 | iommu->need_sync = true; | 644 | iommu->need_sync = sync; |
643 | 645 | ||
644 | spin_unlock_irqrestore(&iommu->lock, flags); | 646 | spin_unlock_irqrestore(&iommu->lock, flags); |
645 | 647 | ||
646 | return 0; | 648 | return 0; |
647 | } | 649 | } |
648 | 650 | ||
651 | static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd) | ||
652 | { | ||
653 | return iommu_queue_command_sync(iommu, cmd, true); | ||
654 | } | ||
655 | |||
649 | /* | 656 | /* |
650 | * This function queues a completion wait command into the command | 657 | * This function queues a completion wait command into the command |
651 | * buffer of an IOMMU | 658 | * buffer of an IOMMU |
@@ -661,7 +668,7 @@ static int iommu_completion_wait(struct amd_iommu *iommu) | |||
661 | 668 | ||
662 | build_completion_wait(&cmd, (u64)&sem); | 669 | build_completion_wait(&cmd, (u64)&sem); |
663 | 670 | ||
664 | ret = iommu_queue_command(iommu, &cmd); | 671 | ret = iommu_queue_command_sync(iommu, &cmd, false); |
665 | if (ret) | 672 | if (ret) |
666 | return ret; | 673 | return ret; |
667 | 674 | ||
@@ -840,14 +847,9 @@ static void domain_flush_complete(struct protection_domain *domain) | |||
840 | static void domain_flush_devices(struct protection_domain *domain) | 847 | static void domain_flush_devices(struct protection_domain *domain) |
841 | { | 848 | { |
842 | struct iommu_dev_data *dev_data; | 849 | struct iommu_dev_data *dev_data; |
843 | unsigned long flags; | ||
844 | |||
845 | spin_lock_irqsave(&domain->lock, flags); | ||
846 | 850 | ||
847 | list_for_each_entry(dev_data, &domain->dev_list, list) | 851 | list_for_each_entry(dev_data, &domain->dev_list, list) |
848 | device_flush_dte(dev_data); | 852 | device_flush_dte(dev_data); |
849 | |||
850 | spin_unlock_irqrestore(&domain->lock, flags); | ||
851 | } | 853 | } |
852 | 854 | ||
853 | /**************************************************************************** | 855 | /**************************************************************************** |
diff --git a/drivers/md/linear.h b/drivers/md/linear.h index 0ce29b61605a..2f2da05b2ce9 100644 --- a/drivers/md/linear.h +++ b/drivers/md/linear.h | |||
@@ -10,9 +10,9 @@ typedef struct dev_info dev_info_t; | |||
10 | 10 | ||
11 | struct linear_private_data | 11 | struct linear_private_data |
12 | { | 12 | { |
13 | struct rcu_head rcu; | ||
13 | sector_t array_sectors; | 14 | sector_t array_sectors; |
14 | dev_info_t disks[0]; | 15 | dev_info_t disks[0]; |
15 | struct rcu_head rcu; | ||
16 | }; | 16 | }; |
17 | 17 | ||
18 | 18 | ||
diff --git a/drivers/md/md.c b/drivers/md/md.c index 8e221a20f5d9..5404b2295820 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -848,7 +848,7 @@ void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev, | |||
848 | bio->bi_end_io = super_written; | 848 | bio->bi_end_io = super_written; |
849 | 849 | ||
850 | atomic_inc(&mddev->pending_writes); | 850 | atomic_inc(&mddev->pending_writes); |
851 | submit_bio(REQ_WRITE | REQ_SYNC | REQ_FLUSH | REQ_FUA, bio); | 851 | submit_bio(WRITE_FLUSH_FUA, bio); |
852 | } | 852 | } |
853 | 853 | ||
854 | void md_super_wait(mddev_t *mddev) | 854 | void md_super_wait(mddev_t *mddev) |
@@ -1138,8 +1138,11 @@ static int super_90_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version | |||
1138 | ret = 0; | 1138 | ret = 0; |
1139 | } | 1139 | } |
1140 | rdev->sectors = rdev->sb_start; | 1140 | rdev->sectors = rdev->sb_start; |
1141 | /* Limit to 4TB as metadata cannot record more than that */ | ||
1142 | if (rdev->sectors >= (2ULL << 32)) | ||
1143 | rdev->sectors = (2ULL << 32) - 2; | ||
1141 | 1144 | ||
1142 | if (rdev->sectors < sb->size * 2 && sb->level > 1) | 1145 | if (rdev->sectors < ((sector_t)sb->size) * 2 && sb->level >= 1) |
1143 | /* "this cannot possibly happen" ... */ | 1146 | /* "this cannot possibly happen" ... */ |
1144 | ret = -EINVAL; | 1147 | ret = -EINVAL; |
1145 | 1148 | ||
@@ -1173,7 +1176,7 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev) | |||
1173 | mddev->clevel[0] = 0; | 1176 | mddev->clevel[0] = 0; |
1174 | mddev->layout = sb->layout; | 1177 | mddev->layout = sb->layout; |
1175 | mddev->raid_disks = sb->raid_disks; | 1178 | mddev->raid_disks = sb->raid_disks; |
1176 | mddev->dev_sectors = sb->size * 2; | 1179 | mddev->dev_sectors = ((sector_t)sb->size) * 2; |
1177 | mddev->events = ev1; | 1180 | mddev->events = ev1; |
1178 | mddev->bitmap_info.offset = 0; | 1181 | mddev->bitmap_info.offset = 0; |
1179 | mddev->bitmap_info.default_offset = MD_SB_BYTES >> 9; | 1182 | mddev->bitmap_info.default_offset = MD_SB_BYTES >> 9; |
@@ -1415,6 +1418,11 @@ super_90_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors) | |||
1415 | rdev->sb_start = calc_dev_sboffset(rdev); | 1418 | rdev->sb_start = calc_dev_sboffset(rdev); |
1416 | if (!num_sectors || num_sectors > rdev->sb_start) | 1419 | if (!num_sectors || num_sectors > rdev->sb_start) |
1417 | num_sectors = rdev->sb_start; | 1420 | num_sectors = rdev->sb_start; |
1421 | /* Limit to 4TB as metadata cannot record more than that. | ||
1422 | * 4TB == 2^32 KB, or 2*2^32 sectors. | ||
1423 | */ | ||
1424 | if (num_sectors >= (2ULL << 32)) | ||
1425 | num_sectors = (2ULL << 32) - 2; | ||
1418 | md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size, | 1426 | md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size, |
1419 | rdev->sb_page); | 1427 | rdev->sb_page); |
1420 | md_super_wait(rdev->mddev); | 1428 | md_super_wait(rdev->mddev); |
@@ -1738,6 +1746,11 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev) | |||
1738 | sb->level = cpu_to_le32(mddev->level); | 1746 | sb->level = cpu_to_le32(mddev->level); |
1739 | sb->layout = cpu_to_le32(mddev->layout); | 1747 | sb->layout = cpu_to_le32(mddev->layout); |
1740 | 1748 | ||
1749 | if (test_bit(WriteMostly, &rdev->flags)) | ||
1750 | sb->devflags |= WriteMostly1; | ||
1751 | else | ||
1752 | sb->devflags &= ~WriteMostly1; | ||
1753 | |||
1741 | if (mddev->bitmap && mddev->bitmap_info.file == NULL) { | 1754 | if (mddev->bitmap && mddev->bitmap_info.file == NULL) { |
1742 | sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_info.offset); | 1755 | sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_info.offset); |
1743 | sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET); | 1756 | sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET); |
@@ -2561,7 +2574,10 @@ state_store(mdk_rdev_t *rdev, const char *buf, size_t len) | |||
2561 | int err = -EINVAL; | 2574 | int err = -EINVAL; |
2562 | if (cmd_match(buf, "faulty") && rdev->mddev->pers) { | 2575 | if (cmd_match(buf, "faulty") && rdev->mddev->pers) { |
2563 | md_error(rdev->mddev, rdev); | 2576 | md_error(rdev->mddev, rdev); |
2564 | err = 0; | 2577 | if (test_bit(Faulty, &rdev->flags)) |
2578 | err = 0; | ||
2579 | else | ||
2580 | err = -EBUSY; | ||
2565 | } else if (cmd_match(buf, "remove")) { | 2581 | } else if (cmd_match(buf, "remove")) { |
2566 | if (rdev->raid_disk >= 0) | 2582 | if (rdev->raid_disk >= 0) |
2567 | err = -EBUSY; | 2583 | err = -EBUSY; |
@@ -2584,7 +2600,7 @@ state_store(mdk_rdev_t *rdev, const char *buf, size_t len) | |||
2584 | err = 0; | 2600 | err = 0; |
2585 | } else if (cmd_match(buf, "-blocked")) { | 2601 | } else if (cmd_match(buf, "-blocked")) { |
2586 | if (!test_bit(Faulty, &rdev->flags) && | 2602 | if (!test_bit(Faulty, &rdev->flags) && |
2587 | test_bit(BlockedBadBlocks, &rdev->flags)) { | 2603 | rdev->badblocks.unacked_exist) { |
2588 | /* metadata handler doesn't understand badblocks, | 2604 | /* metadata handler doesn't understand badblocks, |
2589 | * so we need to fail the device | 2605 | * so we need to fail the device |
2590 | */ | 2606 | */ |
@@ -5983,6 +5999,8 @@ static int set_disk_faulty(mddev_t *mddev, dev_t dev) | |||
5983 | return -ENODEV; | 5999 | return -ENODEV; |
5984 | 6000 | ||
5985 | md_error(mddev, rdev); | 6001 | md_error(mddev, rdev); |
6002 | if (!test_bit(Faulty, &rdev->flags)) | ||
6003 | return -EBUSY; | ||
5986 | return 0; | 6004 | return 0; |
5987 | } | 6005 | } |
5988 | 6006 | ||
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 32323f0afd89..f4622dd8fc59 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -1099,12 +1099,11 @@ read_again: | |||
1099 | bio_list_add(&conf->pending_bio_list, mbio); | 1099 | bio_list_add(&conf->pending_bio_list, mbio); |
1100 | spin_unlock_irqrestore(&conf->device_lock, flags); | 1100 | spin_unlock_irqrestore(&conf->device_lock, flags); |
1101 | } | 1101 | } |
1102 | r1_bio_write_done(r1_bio); | 1102 | /* Mustn't call r1_bio_write_done before this next test, |
1103 | 1103 | * as it could result in the bio being freed. | |
1104 | /* In case raid1d snuck in to freeze_array */ | 1104 | */ |
1105 | wake_up(&conf->wait_barrier); | ||
1106 | |||
1107 | if (sectors_handled < (bio->bi_size >> 9)) { | 1105 | if (sectors_handled < (bio->bi_size >> 9)) { |
1106 | r1_bio_write_done(r1_bio); | ||
1108 | /* We need another r1_bio. It has already been counted | 1107 | /* We need another r1_bio. It has already been counted |
1109 | * in bio->bi_phys_segments | 1108 | * in bio->bi_phys_segments |
1110 | */ | 1109 | */ |
@@ -1117,6 +1116,11 @@ read_again: | |||
1117 | goto retry_write; | 1116 | goto retry_write; |
1118 | } | 1117 | } |
1119 | 1118 | ||
1119 | r1_bio_write_done(r1_bio); | ||
1120 | |||
1121 | /* In case raid1d snuck in to freeze_array */ | ||
1122 | wake_up(&conf->wait_barrier); | ||
1123 | |||
1120 | if (do_sync || !bitmap || !plugged) | 1124 | if (do_sync || !bitmap || !plugged) |
1121 | md_wakeup_thread(mddev->thread); | 1125 | md_wakeup_thread(mddev->thread); |
1122 | 1126 | ||
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 8b29cd4f01c8..d7a8468ddeab 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -337,6 +337,21 @@ static void close_write(r10bio_t *r10_bio) | |||
337 | md_write_end(r10_bio->mddev); | 337 | md_write_end(r10_bio->mddev); |
338 | } | 338 | } |
339 | 339 | ||
340 | static void one_write_done(r10bio_t *r10_bio) | ||
341 | { | ||
342 | if (atomic_dec_and_test(&r10_bio->remaining)) { | ||
343 | if (test_bit(R10BIO_WriteError, &r10_bio->state)) | ||
344 | reschedule_retry(r10_bio); | ||
345 | else { | ||
346 | close_write(r10_bio); | ||
347 | if (test_bit(R10BIO_MadeGood, &r10_bio->state)) | ||
348 | reschedule_retry(r10_bio); | ||
349 | else | ||
350 | raid_end_bio_io(r10_bio); | ||
351 | } | ||
352 | } | ||
353 | } | ||
354 | |||
340 | static void raid10_end_write_request(struct bio *bio, int error) | 355 | static void raid10_end_write_request(struct bio *bio, int error) |
341 | { | 356 | { |
342 | int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); | 357 | int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); |
@@ -387,17 +402,7 @@ static void raid10_end_write_request(struct bio *bio, int error) | |||
387 | * Let's see if all mirrored write operations have finished | 402 | * Let's see if all mirrored write operations have finished |
388 | * already. | 403 | * already. |
389 | */ | 404 | */ |
390 | if (atomic_dec_and_test(&r10_bio->remaining)) { | 405 | one_write_done(r10_bio); |
391 | if (test_bit(R10BIO_WriteError, &r10_bio->state)) | ||
392 | reschedule_retry(r10_bio); | ||
393 | else { | ||
394 | close_write(r10_bio); | ||
395 | if (test_bit(R10BIO_MadeGood, &r10_bio->state)) | ||
396 | reschedule_retry(r10_bio); | ||
397 | else | ||
398 | raid_end_bio_io(r10_bio); | ||
399 | } | ||
400 | } | ||
401 | if (dec_rdev) | 406 | if (dec_rdev) |
402 | rdev_dec_pending(conf->mirrors[dev].rdev, conf->mddev); | 407 | rdev_dec_pending(conf->mirrors[dev].rdev, conf->mddev); |
403 | } | 408 | } |
@@ -1127,20 +1132,12 @@ retry_write: | |||
1127 | spin_unlock_irqrestore(&conf->device_lock, flags); | 1132 | spin_unlock_irqrestore(&conf->device_lock, flags); |
1128 | } | 1133 | } |
1129 | 1134 | ||
1130 | if (atomic_dec_and_test(&r10_bio->remaining)) { | 1135 | /* Don't remove the bias on 'remaining' (one_write_done) until |
1131 | /* This matches the end of raid10_end_write_request() */ | 1136 | * after checking if we need to go around again. |
1132 | bitmap_endwrite(r10_bio->mddev->bitmap, r10_bio->sector, | 1137 | */ |
1133 | r10_bio->sectors, | ||
1134 | !test_bit(R10BIO_Degraded, &r10_bio->state), | ||
1135 | 0); | ||
1136 | md_write_end(mddev); | ||
1137 | raid_end_bio_io(r10_bio); | ||
1138 | } | ||
1139 | |||
1140 | /* In case raid10d snuck in to freeze_array */ | ||
1141 | wake_up(&conf->wait_barrier); | ||
1142 | 1138 | ||
1143 | if (sectors_handled < (bio->bi_size >> 9)) { | 1139 | if (sectors_handled < (bio->bi_size >> 9)) { |
1140 | one_write_done(r10_bio); | ||
1144 | /* We need another r10_bio. It has already been counted | 1141 | /* We need another r10_bio. It has already been counted |
1145 | * in bio->bi_phys_segments. | 1142 | * in bio->bi_phys_segments. |
1146 | */ | 1143 | */ |
@@ -1154,6 +1151,10 @@ retry_write: | |||
1154 | r10_bio->state = 0; | 1151 | r10_bio->state = 0; |
1155 | goto retry_write; | 1152 | goto retry_write; |
1156 | } | 1153 | } |
1154 | one_write_done(r10_bio); | ||
1155 | |||
1156 | /* In case raid10d snuck in to freeze_array */ | ||
1157 | wake_up(&conf->wait_barrier); | ||
1157 | 1158 | ||
1158 | if (do_sync || !mddev->bitmap || !plugged) | 1159 | if (do_sync || !mddev->bitmap || !plugged) |
1159 | md_wakeup_thread(mddev->thread); | 1160 | md_wakeup_thread(mddev->thread); |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index dbae459fb02d..43709fa6b6df 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -3336,7 +3336,7 @@ static void handle_stripe(struct stripe_head *sh) | |||
3336 | 3336 | ||
3337 | finish: | 3337 | finish: |
3338 | /* wait for this device to become unblocked */ | 3338 | /* wait for this device to become unblocked */ |
3339 | if (unlikely(s.blocked_rdev)) | 3339 | if (conf->mddev->external && unlikely(s.blocked_rdev)) |
3340 | md_wait_for_blocked_rdev(s.blocked_rdev, conf->mddev); | 3340 | md_wait_for_blocked_rdev(s.blocked_rdev, conf->mddev); |
3341 | 3341 | ||
3342 | if (s.handle_bad_blocks) | 3342 | if (s.handle_bad_blocks) |
diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c index 3db89e3cb0bb..536c16c943bd 100644 --- a/drivers/media/dvb/dvb-usb/vp7045.c +++ b/drivers/media/dvb/dvb-usb/vp7045.c | |||
@@ -224,26 +224,8 @@ static struct dvb_usb_device_properties vp7045_properties; | |||
224 | static int vp7045_usb_probe(struct usb_interface *intf, | 224 | static int vp7045_usb_probe(struct usb_interface *intf, |
225 | const struct usb_device_id *id) | 225 | const struct usb_device_id *id) |
226 | { | 226 | { |
227 | struct dvb_usb_device *d; | 227 | return dvb_usb_device_init(intf, &vp7045_properties, |
228 | int ret = dvb_usb_device_init(intf, &vp7045_properties, | 228 | THIS_MODULE, NULL, adapter_nr); |
229 | THIS_MODULE, &d, adapter_nr); | ||
230 | if (ret) | ||
231 | return ret; | ||
232 | |||
233 | d->priv = kmalloc(20, GFP_KERNEL); | ||
234 | if (!d->priv) { | ||
235 | dvb_usb_device_exit(intf); | ||
236 | return -ENOMEM; | ||
237 | } | ||
238 | |||
239 | return ret; | ||
240 | } | ||
241 | |||
242 | static void vp7045_usb_disconnect(struct usb_interface *intf) | ||
243 | { | ||
244 | struct dvb_usb_device *d = usb_get_intfdata(intf); | ||
245 | kfree(d->priv); | ||
246 | dvb_usb_device_exit(intf); | ||
247 | } | 229 | } |
248 | 230 | ||
249 | static struct usb_device_id vp7045_usb_table [] = { | 231 | static struct usb_device_id vp7045_usb_table [] = { |
@@ -258,7 +240,7 @@ MODULE_DEVICE_TABLE(usb, vp7045_usb_table); | |||
258 | static struct dvb_usb_device_properties vp7045_properties = { | 240 | static struct dvb_usb_device_properties vp7045_properties = { |
259 | .usb_ctrl = CYPRESS_FX2, | 241 | .usb_ctrl = CYPRESS_FX2, |
260 | .firmware = "dvb-usb-vp7045-01.fw", | 242 | .firmware = "dvb-usb-vp7045-01.fw", |
261 | .size_of_priv = sizeof(u8 *), | 243 | .size_of_priv = 20, |
262 | 244 | ||
263 | .num_adapters = 1, | 245 | .num_adapters = 1, |
264 | .adapter = { | 246 | .adapter = { |
@@ -305,7 +287,7 @@ static struct dvb_usb_device_properties vp7045_properties = { | |||
305 | static struct usb_driver vp7045_usb_driver = { | 287 | static struct usb_driver vp7045_usb_driver = { |
306 | .name = "dvb_usb_vp7045", | 288 | .name = "dvb_usb_vp7045", |
307 | .probe = vp7045_usb_probe, | 289 | .probe = vp7045_usb_probe, |
308 | .disconnect = vp7045_usb_disconnect, | 290 | .disconnect = dvb_usb_device_exit, |
309 | .id_table = vp7045_usb_table, | 291 | .id_table = vp7045_usb_table, |
310 | }; | 292 | }; |
311 | 293 | ||
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c index eae05b500476..144f3f55d765 100644 --- a/drivers/media/rc/nuvoton-cir.c +++ b/drivers/media/rc/nuvoton-cir.c | |||
@@ -618,7 +618,6 @@ static void nvt_dump_rx_buf(struct nvt_dev *nvt) | |||
618 | static void nvt_process_rx_ir_data(struct nvt_dev *nvt) | 618 | static void nvt_process_rx_ir_data(struct nvt_dev *nvt) |
619 | { | 619 | { |
620 | DEFINE_IR_RAW_EVENT(rawir); | 620 | DEFINE_IR_RAW_EVENT(rawir); |
621 | unsigned int count; | ||
622 | u32 carrier; | 621 | u32 carrier; |
623 | u8 sample; | 622 | u8 sample; |
624 | int i; | 623 | int i; |
@@ -631,65 +630,38 @@ static void nvt_process_rx_ir_data(struct nvt_dev *nvt) | |||
631 | if (nvt->carrier_detect_enabled) | 630 | if (nvt->carrier_detect_enabled) |
632 | carrier = nvt_rx_carrier_detect(nvt); | 631 | carrier = nvt_rx_carrier_detect(nvt); |
633 | 632 | ||
634 | count = nvt->pkts; | 633 | nvt_dbg_verbose("Processing buffer of len %d", nvt->pkts); |
635 | nvt_dbg_verbose("Processing buffer of len %d", count); | ||
636 | 634 | ||
637 | init_ir_raw_event(&rawir); | 635 | init_ir_raw_event(&rawir); |
638 | 636 | ||
639 | for (i = 0; i < count; i++) { | 637 | for (i = 0; i < nvt->pkts; i++) { |
640 | nvt->pkts--; | ||
641 | sample = nvt->buf[i]; | 638 | sample = nvt->buf[i]; |
642 | 639 | ||
643 | rawir.pulse = ((sample & BUF_PULSE_BIT) != 0); | 640 | rawir.pulse = ((sample & BUF_PULSE_BIT) != 0); |
644 | rawir.duration = US_TO_NS((sample & BUF_LEN_MASK) | 641 | rawir.duration = US_TO_NS((sample & BUF_LEN_MASK) |
645 | * SAMPLE_PERIOD); | 642 | * SAMPLE_PERIOD); |
646 | 643 | ||
647 | if ((sample & BUF_LEN_MASK) == BUF_LEN_MASK) { | 644 | nvt_dbg("Storing %s with duration %d", |
648 | if (nvt->rawir.pulse == rawir.pulse) | 645 | rawir.pulse ? "pulse" : "space", rawir.duration); |
649 | nvt->rawir.duration += rawir.duration; | ||
650 | else { | ||
651 | nvt->rawir.duration = rawir.duration; | ||
652 | nvt->rawir.pulse = rawir.pulse; | ||
653 | } | ||
654 | continue; | ||
655 | } | ||
656 | |||
657 | rawir.duration += nvt->rawir.duration; | ||
658 | 646 | ||
659 | init_ir_raw_event(&nvt->rawir); | 647 | ir_raw_event_store_with_filter(nvt->rdev, &rawir); |
660 | nvt->rawir.duration = 0; | ||
661 | nvt->rawir.pulse = rawir.pulse; | ||
662 | |||
663 | if (sample == BUF_PULSE_BIT) | ||
664 | rawir.pulse = false; | ||
665 | |||
666 | if (rawir.duration) { | ||
667 | nvt_dbg("Storing %s with duration %d", | ||
668 | rawir.pulse ? "pulse" : "space", | ||
669 | rawir.duration); | ||
670 | |||
671 | ir_raw_event_store_with_filter(nvt->rdev, &rawir); | ||
672 | } | ||
673 | 648 | ||
674 | /* | 649 | /* |
675 | * BUF_PULSE_BIT indicates end of IR data, BUF_REPEAT_BYTE | 650 | * BUF_PULSE_BIT indicates end of IR data, BUF_REPEAT_BYTE |
676 | * indicates end of IR signal, but new data incoming. In both | 651 | * indicates end of IR signal, but new data incoming. In both |
677 | * cases, it means we're ready to call ir_raw_event_handle | 652 | * cases, it means we're ready to call ir_raw_event_handle |
678 | */ | 653 | */ |
679 | if ((sample == BUF_PULSE_BIT) && nvt->pkts) { | 654 | if ((sample == BUF_PULSE_BIT) && (i + 1 < nvt->pkts)) { |
680 | nvt_dbg("Calling ir_raw_event_handle (signal end)\n"); | 655 | nvt_dbg("Calling ir_raw_event_handle (signal end)\n"); |
681 | ir_raw_event_handle(nvt->rdev); | 656 | ir_raw_event_handle(nvt->rdev); |
682 | } | 657 | } |
683 | } | 658 | } |
684 | 659 | ||
660 | nvt->pkts = 0; | ||
661 | |||
685 | nvt_dbg("Calling ir_raw_event_handle (buffer empty)\n"); | 662 | nvt_dbg("Calling ir_raw_event_handle (buffer empty)\n"); |
686 | ir_raw_event_handle(nvt->rdev); | 663 | ir_raw_event_handle(nvt->rdev); |
687 | 664 | ||
688 | if (nvt->pkts) { | ||
689 | nvt_dbg("Odd, pkts should be 0 now... (its %u)", nvt->pkts); | ||
690 | nvt->pkts = 0; | ||
691 | } | ||
692 | |||
693 | nvt_dbg_verbose("%s done", __func__); | 665 | nvt_dbg_verbose("%s done", __func__); |
694 | } | 666 | } |
695 | 667 | ||
@@ -1048,7 +1020,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) | |||
1048 | 1020 | ||
1049 | spin_lock_init(&nvt->nvt_lock); | 1021 | spin_lock_init(&nvt->nvt_lock); |
1050 | spin_lock_init(&nvt->tx.lock); | 1022 | spin_lock_init(&nvt->tx.lock); |
1051 | init_ir_raw_event(&nvt->rawir); | ||
1052 | 1023 | ||
1053 | ret = -EBUSY; | 1024 | ret = -EBUSY; |
1054 | /* now claim resources */ | 1025 | /* now claim resources */ |
diff --git a/drivers/media/rc/nuvoton-cir.h b/drivers/media/rc/nuvoton-cir.h index 1241fc89a36c..0d5e0872a2ea 100644 --- a/drivers/media/rc/nuvoton-cir.h +++ b/drivers/media/rc/nuvoton-cir.h | |||
@@ -67,7 +67,6 @@ static int debug; | |||
67 | struct nvt_dev { | 67 | struct nvt_dev { |
68 | struct pnp_dev *pdev; | 68 | struct pnp_dev *pdev; |
69 | struct rc_dev *rdev; | 69 | struct rc_dev *rdev; |
70 | struct ir_raw_event rawir; | ||
71 | 70 | ||
72 | spinlock_t nvt_lock; | 71 | spinlock_t nvt_lock; |
73 | 72 | ||
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c index 0800433b2092..18305c89083c 100644 --- a/drivers/media/video/gspca/ov519.c +++ b/drivers/media/video/gspca/ov519.c | |||
@@ -2858,7 +2858,6 @@ static void ov7xx0_configure(struct sd *sd) | |||
2858 | case 0x60: | 2858 | case 0x60: |
2859 | PDEBUG(D_PROBE, "Sensor is a OV7660"); | 2859 | PDEBUG(D_PROBE, "Sensor is a OV7660"); |
2860 | sd->sensor = SEN_OV7660; | 2860 | sd->sensor = SEN_OV7660; |
2861 | sd->invert_led = 0; | ||
2862 | break; | 2861 | break; |
2863 | default: | 2862 | default: |
2864 | PDEBUG(D_PROBE, "Unknown sensor: 0x76%x", low); | 2863 | PDEBUG(D_PROBE, "Unknown sensor: 0x76%x", low); |
@@ -3337,7 +3336,6 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
3337 | case BRIDGE_OV519: | 3336 | case BRIDGE_OV519: |
3338 | cam->cam_mode = ov519_vga_mode; | 3337 | cam->cam_mode = ov519_vga_mode; |
3339 | cam->nmodes = ARRAY_SIZE(ov519_vga_mode); | 3338 | cam->nmodes = ARRAY_SIZE(ov519_vga_mode); |
3340 | sd->invert_led = !sd->invert_led; | ||
3341 | break; | 3339 | break; |
3342 | case BRIDGE_OVFX2: | 3340 | case BRIDGE_OVFX2: |
3343 | cam->cam_mode = ov519_vga_mode; | 3341 | cam->cam_mode = ov519_vga_mode; |
@@ -5005,24 +5003,24 @@ static const struct sd_desc sd_desc = { | |||
5005 | /* -- module initialisation -- */ | 5003 | /* -- module initialisation -- */ |
5006 | static const struct usb_device_id device_table[] = { | 5004 | static const struct usb_device_id device_table[] = { |
5007 | {USB_DEVICE(0x041e, 0x4003), .driver_info = BRIDGE_W9968CF }, | 5005 | {USB_DEVICE(0x041e, 0x4003), .driver_info = BRIDGE_W9968CF }, |
5008 | {USB_DEVICE(0x041e, 0x4052), .driver_info = BRIDGE_OV519 }, | 5006 | {USB_DEVICE(0x041e, 0x4052), |
5009 | {USB_DEVICE(0x041e, 0x405f), | ||
5010 | .driver_info = BRIDGE_OV519 | BRIDGE_INVERT_LED }, | 5007 | .driver_info = BRIDGE_OV519 | BRIDGE_INVERT_LED }, |
5008 | {USB_DEVICE(0x041e, 0x405f), .driver_info = BRIDGE_OV519 }, | ||
5011 | {USB_DEVICE(0x041e, 0x4060), .driver_info = BRIDGE_OV519 }, | 5009 | {USB_DEVICE(0x041e, 0x4060), .driver_info = BRIDGE_OV519 }, |
5012 | {USB_DEVICE(0x041e, 0x4061), .driver_info = BRIDGE_OV519 }, | 5010 | {USB_DEVICE(0x041e, 0x4061), .driver_info = BRIDGE_OV519 }, |
5013 | {USB_DEVICE(0x041e, 0x4064), | 5011 | {USB_DEVICE(0x041e, 0x4064), .driver_info = BRIDGE_OV519 }, |
5014 | .driver_info = BRIDGE_OV519 | BRIDGE_INVERT_LED }, | ||
5015 | {USB_DEVICE(0x041e, 0x4067), .driver_info = BRIDGE_OV519 }, | 5012 | {USB_DEVICE(0x041e, 0x4067), .driver_info = BRIDGE_OV519 }, |
5016 | {USB_DEVICE(0x041e, 0x4068), | 5013 | {USB_DEVICE(0x041e, 0x4068), .driver_info = BRIDGE_OV519 }, |
5014 | {USB_DEVICE(0x045e, 0x028c), | ||
5017 | .driver_info = BRIDGE_OV519 | BRIDGE_INVERT_LED }, | 5015 | .driver_info = BRIDGE_OV519 | BRIDGE_INVERT_LED }, |
5018 | {USB_DEVICE(0x045e, 0x028c), .driver_info = BRIDGE_OV519 }, | ||
5019 | {USB_DEVICE(0x054c, 0x0154), .driver_info = BRIDGE_OV519 }, | 5016 | {USB_DEVICE(0x054c, 0x0154), .driver_info = BRIDGE_OV519 }, |
5020 | {USB_DEVICE(0x054c, 0x0155), | 5017 | {USB_DEVICE(0x054c, 0x0155), .driver_info = BRIDGE_OV519 }, |
5021 | .driver_info = BRIDGE_OV519 | BRIDGE_INVERT_LED }, | ||
5022 | {USB_DEVICE(0x05a9, 0x0511), .driver_info = BRIDGE_OV511 }, | 5018 | {USB_DEVICE(0x05a9, 0x0511), .driver_info = BRIDGE_OV511 }, |
5023 | {USB_DEVICE(0x05a9, 0x0518), .driver_info = BRIDGE_OV518 }, | 5019 | {USB_DEVICE(0x05a9, 0x0518), .driver_info = BRIDGE_OV518 }, |
5024 | {USB_DEVICE(0x05a9, 0x0519), .driver_info = BRIDGE_OV519 }, | 5020 | {USB_DEVICE(0x05a9, 0x0519), |
5025 | {USB_DEVICE(0x05a9, 0x0530), .driver_info = BRIDGE_OV519 }, | 5021 | .driver_info = BRIDGE_OV519 | BRIDGE_INVERT_LED }, |
5022 | {USB_DEVICE(0x05a9, 0x0530), | ||
5023 | .driver_info = BRIDGE_OV519 | BRIDGE_INVERT_LED }, | ||
5026 | {USB_DEVICE(0x05a9, 0x2800), .driver_info = BRIDGE_OVFX2 }, | 5024 | {USB_DEVICE(0x05a9, 0x2800), .driver_info = BRIDGE_OVFX2 }, |
5027 | {USB_DEVICE(0x05a9, 0x4519), .driver_info = BRIDGE_OV519 }, | 5025 | {USB_DEVICE(0x05a9, 0x4519), .driver_info = BRIDGE_OV519 }, |
5028 | {USB_DEVICE(0x05a9, 0x8519), .driver_info = BRIDGE_OV519 }, | 5026 | {USB_DEVICE(0x05a9, 0x8519), .driver_info = BRIDGE_OV519 }, |
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c index 81b8a600783b..c477ad11f103 100644 --- a/drivers/media/video/gspca/sonixj.c +++ b/drivers/media/video/gspca/sonixj.c | |||
@@ -2386,7 +2386,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2386 | reg_w1(gspca_dev, 0x01, 0x22); | 2386 | reg_w1(gspca_dev, 0x01, 0x22); |
2387 | msleep(100); | 2387 | msleep(100); |
2388 | reg01 = SCL_SEL_OD | S_PDN_INV; | 2388 | reg01 = SCL_SEL_OD | S_PDN_INV; |
2389 | reg17 &= MCK_SIZE_MASK; | 2389 | reg17 &= ~MCK_SIZE_MASK; |
2390 | reg17 |= 0x04; /* clock / 4 */ | 2390 | reg17 |= 0x04; /* clock / 4 */ |
2391 | break; | 2391 | break; |
2392 | } | 2392 | } |
@@ -2532,6 +2532,10 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2532 | if (!mode) { /* if 640x480 */ | 2532 | if (!mode) { /* if 640x480 */ |
2533 | reg17 &= ~MCK_SIZE_MASK; | 2533 | reg17 &= ~MCK_SIZE_MASK; |
2534 | reg17 |= 0x04; /* clock / 4 */ | 2534 | reg17 |= 0x04; /* clock / 4 */ |
2535 | } else { | ||
2536 | reg01 &= ~SYS_SEL_48M; /* clk 24Mz */ | ||
2537 | reg17 &= ~MCK_SIZE_MASK; | ||
2538 | reg17 |= 0x02; /* clock / 2 */ | ||
2535 | } | 2539 | } |
2536 | break; | 2540 | break; |
2537 | case SENSOR_OV7630: | 2541 | case SENSOR_OV7630: |
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c index e9a0e94b9995..8c70e64444e7 100644 --- a/drivers/media/video/pwc/pwc-v4l.c +++ b/drivers/media/video/pwc/pwc-v4l.c | |||
@@ -338,7 +338,7 @@ int pwc_init_controls(struct pwc_device *pdev) | |||
338 | if (pdev->restore_factory) | 338 | if (pdev->restore_factory) |
339 | pdev->restore_factory->flags = V4L2_CTRL_FLAG_UPDATE; | 339 | pdev->restore_factory->flags = V4L2_CTRL_FLAG_UPDATE; |
340 | 340 | ||
341 | if (!pdev->features & FEATURE_MOTOR_PANTILT) | 341 | if (!(pdev->features & FEATURE_MOTOR_PANTILT)) |
342 | return hdl->error; | 342 | return hdl->error; |
343 | 343 | ||
344 | /* Motor pan / tilt / reset */ | 344 | /* Motor pan / tilt / reset */ |
diff --git a/drivers/media/video/via-camera.c b/drivers/media/video/via-camera.c index 85d3048c1d67..bb7f17f2a33c 100644 --- a/drivers/media/video/via-camera.c +++ b/drivers/media/video/via-camera.c | |||
@@ -1332,6 +1332,8 @@ static __devinit bool viacam_serial_is_enabled(void) | |||
1332 | struct pci_bus *pbus = pci_find_bus(0, 0); | 1332 | struct pci_bus *pbus = pci_find_bus(0, 0); |
1333 | u8 cbyte; | 1333 | u8 cbyte; |
1334 | 1334 | ||
1335 | if (!pbus) | ||
1336 | return false; | ||
1335 | pci_bus_read_config_byte(pbus, VIACAM_SERIAL_DEVFN, | 1337 | pci_bus_read_config_byte(pbus, VIACAM_SERIAL_DEVFN, |
1336 | VIACAM_SERIAL_CREG, &cbyte); | 1338 | VIACAM_SERIAL_CREG, &cbyte); |
1337 | if ((cbyte & VIACAM_SERIAL_BIT) == 0) | 1339 | if ((cbyte & VIACAM_SERIAL_BIT) == 0) |
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 91a0a7460ebb..b27b94078c21 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -133,7 +133,7 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) | |||
133 | if (mrq->done) | 133 | if (mrq->done) |
134 | mrq->done(mrq); | 134 | mrq->done(mrq); |
135 | 135 | ||
136 | mmc_host_clk_gate(host); | 136 | mmc_host_clk_release(host); |
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
@@ -192,7 +192,7 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) | |||
192 | mrq->stop->mrq = mrq; | 192 | mrq->stop->mrq = mrq; |
193 | } | 193 | } |
194 | } | 194 | } |
195 | mmc_host_clk_ungate(host); | 195 | mmc_host_clk_hold(host); |
196 | led_trigger_event(host->led, LED_FULL); | 196 | led_trigger_event(host->led, LED_FULL); |
197 | host->ops->request(host, mrq); | 197 | host->ops->request(host, mrq); |
198 | } | 198 | } |
@@ -728,15 +728,17 @@ static inline void mmc_set_ios(struct mmc_host *host) | |||
728 | */ | 728 | */ |
729 | void mmc_set_chip_select(struct mmc_host *host, int mode) | 729 | void mmc_set_chip_select(struct mmc_host *host, int mode) |
730 | { | 730 | { |
731 | mmc_host_clk_hold(host); | ||
731 | host->ios.chip_select = mode; | 732 | host->ios.chip_select = mode; |
732 | mmc_set_ios(host); | 733 | mmc_set_ios(host); |
734 | mmc_host_clk_release(host); | ||
733 | } | 735 | } |
734 | 736 | ||
735 | /* | 737 | /* |
736 | * Sets the host clock to the highest possible frequency that | 738 | * Sets the host clock to the highest possible frequency that |
737 | * is below "hz". | 739 | * is below "hz". |
738 | */ | 740 | */ |
739 | void mmc_set_clock(struct mmc_host *host, unsigned int hz) | 741 | static void __mmc_set_clock(struct mmc_host *host, unsigned int hz) |
740 | { | 742 | { |
741 | WARN_ON(hz < host->f_min); | 743 | WARN_ON(hz < host->f_min); |
742 | 744 | ||
@@ -747,6 +749,13 @@ void mmc_set_clock(struct mmc_host *host, unsigned int hz) | |||
747 | mmc_set_ios(host); | 749 | mmc_set_ios(host); |
748 | } | 750 | } |
749 | 751 | ||
752 | void mmc_set_clock(struct mmc_host *host, unsigned int hz) | ||
753 | { | ||
754 | mmc_host_clk_hold(host); | ||
755 | __mmc_set_clock(host, hz); | ||
756 | mmc_host_clk_release(host); | ||
757 | } | ||
758 | |||
750 | #ifdef CONFIG_MMC_CLKGATE | 759 | #ifdef CONFIG_MMC_CLKGATE |
751 | /* | 760 | /* |
752 | * This gates the clock by setting it to 0 Hz. | 761 | * This gates the clock by setting it to 0 Hz. |
@@ -779,7 +788,7 @@ void mmc_ungate_clock(struct mmc_host *host) | |||
779 | if (host->clk_old) { | 788 | if (host->clk_old) { |
780 | BUG_ON(host->ios.clock); | 789 | BUG_ON(host->ios.clock); |
781 | /* This call will also set host->clk_gated to false */ | 790 | /* This call will also set host->clk_gated to false */ |
782 | mmc_set_clock(host, host->clk_old); | 791 | __mmc_set_clock(host, host->clk_old); |
783 | } | 792 | } |
784 | } | 793 | } |
785 | 794 | ||
@@ -807,8 +816,10 @@ void mmc_set_ungated(struct mmc_host *host) | |||
807 | */ | 816 | */ |
808 | void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode) | 817 | void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode) |
809 | { | 818 | { |
819 | mmc_host_clk_hold(host); | ||
810 | host->ios.bus_mode = mode; | 820 | host->ios.bus_mode = mode; |
811 | mmc_set_ios(host); | 821 | mmc_set_ios(host); |
822 | mmc_host_clk_release(host); | ||
812 | } | 823 | } |
813 | 824 | ||
814 | /* | 825 | /* |
@@ -816,8 +827,10 @@ void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode) | |||
816 | */ | 827 | */ |
817 | void mmc_set_bus_width(struct mmc_host *host, unsigned int width) | 828 | void mmc_set_bus_width(struct mmc_host *host, unsigned int width) |
818 | { | 829 | { |
830 | mmc_host_clk_hold(host); | ||
819 | host->ios.bus_width = width; | 831 | host->ios.bus_width = width; |
820 | mmc_set_ios(host); | 832 | mmc_set_ios(host); |
833 | mmc_host_clk_release(host); | ||
821 | } | 834 | } |
822 | 835 | ||
823 | /** | 836 | /** |
@@ -1015,8 +1028,10 @@ u32 mmc_select_voltage(struct mmc_host *host, u32 ocr) | |||
1015 | 1028 | ||
1016 | ocr &= 3 << bit; | 1029 | ocr &= 3 << bit; |
1017 | 1030 | ||
1031 | mmc_host_clk_hold(host); | ||
1018 | host->ios.vdd = bit; | 1032 | host->ios.vdd = bit; |
1019 | mmc_set_ios(host); | 1033 | mmc_set_ios(host); |
1034 | mmc_host_clk_release(host); | ||
1020 | } else { | 1035 | } else { |
1021 | pr_warning("%s: host doesn't support card's voltages\n", | 1036 | pr_warning("%s: host doesn't support card's voltages\n", |
1022 | mmc_hostname(host)); | 1037 | mmc_hostname(host)); |
@@ -1063,8 +1078,10 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, bool cmd11 | |||
1063 | */ | 1078 | */ |
1064 | void mmc_set_timing(struct mmc_host *host, unsigned int timing) | 1079 | void mmc_set_timing(struct mmc_host *host, unsigned int timing) |
1065 | { | 1080 | { |
1081 | mmc_host_clk_hold(host); | ||
1066 | host->ios.timing = timing; | 1082 | host->ios.timing = timing; |
1067 | mmc_set_ios(host); | 1083 | mmc_set_ios(host); |
1084 | mmc_host_clk_release(host); | ||
1068 | } | 1085 | } |
1069 | 1086 | ||
1070 | /* | 1087 | /* |
@@ -1072,8 +1089,10 @@ void mmc_set_timing(struct mmc_host *host, unsigned int timing) | |||
1072 | */ | 1089 | */ |
1073 | void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type) | 1090 | void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type) |
1074 | { | 1091 | { |
1092 | mmc_host_clk_hold(host); | ||
1075 | host->ios.drv_type = drv_type; | 1093 | host->ios.drv_type = drv_type; |
1076 | mmc_set_ios(host); | 1094 | mmc_set_ios(host); |
1095 | mmc_host_clk_release(host); | ||
1077 | } | 1096 | } |
1078 | 1097 | ||
1079 | /* | 1098 | /* |
@@ -1091,6 +1110,8 @@ static void mmc_power_up(struct mmc_host *host) | |||
1091 | { | 1110 | { |
1092 | int bit; | 1111 | int bit; |
1093 | 1112 | ||
1113 | mmc_host_clk_hold(host); | ||
1114 | |||
1094 | /* If ocr is set, we use it */ | 1115 | /* If ocr is set, we use it */ |
1095 | if (host->ocr) | 1116 | if (host->ocr) |
1096 | bit = ffs(host->ocr) - 1; | 1117 | bit = ffs(host->ocr) - 1; |
@@ -1126,10 +1147,14 @@ static void mmc_power_up(struct mmc_host *host) | |||
1126 | * time required to reach a stable voltage. | 1147 | * time required to reach a stable voltage. |
1127 | */ | 1148 | */ |
1128 | mmc_delay(10); | 1149 | mmc_delay(10); |
1150 | |||
1151 | mmc_host_clk_release(host); | ||
1129 | } | 1152 | } |
1130 | 1153 | ||
1131 | static void mmc_power_off(struct mmc_host *host) | 1154 | static void mmc_power_off(struct mmc_host *host) |
1132 | { | 1155 | { |
1156 | mmc_host_clk_hold(host); | ||
1157 | |||
1133 | host->ios.clock = 0; | 1158 | host->ios.clock = 0; |
1134 | host->ios.vdd = 0; | 1159 | host->ios.vdd = 0; |
1135 | 1160 | ||
@@ -1147,6 +1172,8 @@ static void mmc_power_off(struct mmc_host *host) | |||
1147 | host->ios.bus_width = MMC_BUS_WIDTH_1; | 1172 | host->ios.bus_width = MMC_BUS_WIDTH_1; |
1148 | host->ios.timing = MMC_TIMING_LEGACY; | 1173 | host->ios.timing = MMC_TIMING_LEGACY; |
1149 | mmc_set_ios(host); | 1174 | mmc_set_ios(host); |
1175 | |||
1176 | mmc_host_clk_release(host); | ||
1150 | } | 1177 | } |
1151 | 1178 | ||
1152 | /* | 1179 | /* |
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index b29d3e8fd3a2..793d0a0dad8d 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c | |||
@@ -119,14 +119,14 @@ static void mmc_host_clk_gate_work(struct work_struct *work) | |||
119 | } | 119 | } |
120 | 120 | ||
121 | /** | 121 | /** |
122 | * mmc_host_clk_ungate - ungate hardware MCI clocks | 122 | * mmc_host_clk_hold - ungate hardware MCI clocks |
123 | * @host: host to ungate. | 123 | * @host: host to ungate. |
124 | * | 124 | * |
125 | * Makes sure the host ios.clock is restored to a non-zero value | 125 | * Makes sure the host ios.clock is restored to a non-zero value |
126 | * past this call. Increase clock reference count and ungate clock | 126 | * past this call. Increase clock reference count and ungate clock |
127 | * if we're the first user. | 127 | * if we're the first user. |
128 | */ | 128 | */ |
129 | void mmc_host_clk_ungate(struct mmc_host *host) | 129 | void mmc_host_clk_hold(struct mmc_host *host) |
130 | { | 130 | { |
131 | unsigned long flags; | 131 | unsigned long flags; |
132 | 132 | ||
@@ -164,14 +164,14 @@ static bool mmc_host_may_gate_card(struct mmc_card *card) | |||
164 | } | 164 | } |
165 | 165 | ||
166 | /** | 166 | /** |
167 | * mmc_host_clk_gate - gate off hardware MCI clocks | 167 | * mmc_host_clk_release - gate off hardware MCI clocks |
168 | * @host: host to gate. | 168 | * @host: host to gate. |
169 | * | 169 | * |
170 | * Calls the host driver with ios.clock set to zero as often as possible | 170 | * Calls the host driver with ios.clock set to zero as often as possible |
171 | * in order to gate off hardware MCI clocks. Decrease clock reference | 171 | * in order to gate off hardware MCI clocks. Decrease clock reference |
172 | * count and schedule disabling of clock. | 172 | * count and schedule disabling of clock. |
173 | */ | 173 | */ |
174 | void mmc_host_clk_gate(struct mmc_host *host) | 174 | void mmc_host_clk_release(struct mmc_host *host) |
175 | { | 175 | { |
176 | unsigned long flags; | 176 | unsigned long flags; |
177 | 177 | ||
@@ -179,7 +179,7 @@ void mmc_host_clk_gate(struct mmc_host *host) | |||
179 | host->clk_requests--; | 179 | host->clk_requests--; |
180 | if (mmc_host_may_gate_card(host->card) && | 180 | if (mmc_host_may_gate_card(host->card) && |
181 | !host->clk_requests) | 181 | !host->clk_requests) |
182 | schedule_work(&host->clk_gate_work); | 182 | queue_work(system_nrt_wq, &host->clk_gate_work); |
183 | spin_unlock_irqrestore(&host->clk_lock, flags); | 183 | spin_unlock_irqrestore(&host->clk_lock, flags); |
184 | } | 184 | } |
185 | 185 | ||
@@ -231,7 +231,7 @@ static inline void mmc_host_clk_exit(struct mmc_host *host) | |||
231 | if (cancel_work_sync(&host->clk_gate_work)) | 231 | if (cancel_work_sync(&host->clk_gate_work)) |
232 | mmc_host_clk_gate_delayed(host); | 232 | mmc_host_clk_gate_delayed(host); |
233 | if (host->clk_gated) | 233 | if (host->clk_gated) |
234 | mmc_host_clk_ungate(host); | 234 | mmc_host_clk_hold(host); |
235 | /* There should be only one user now */ | 235 | /* There should be only one user now */ |
236 | WARN_ON(host->clk_requests > 1); | 236 | WARN_ON(host->clk_requests > 1); |
237 | } | 237 | } |
diff --git a/drivers/mmc/core/host.h b/drivers/mmc/core/host.h index de199f911928..fb8a5cd2e4a1 100644 --- a/drivers/mmc/core/host.h +++ b/drivers/mmc/core/host.h | |||
@@ -16,16 +16,16 @@ int mmc_register_host_class(void); | |||
16 | void mmc_unregister_host_class(void); | 16 | void mmc_unregister_host_class(void); |
17 | 17 | ||
18 | #ifdef CONFIG_MMC_CLKGATE | 18 | #ifdef CONFIG_MMC_CLKGATE |
19 | void mmc_host_clk_ungate(struct mmc_host *host); | 19 | void mmc_host_clk_hold(struct mmc_host *host); |
20 | void mmc_host_clk_gate(struct mmc_host *host); | 20 | void mmc_host_clk_release(struct mmc_host *host); |
21 | unsigned int mmc_host_clk_rate(struct mmc_host *host); | 21 | unsigned int mmc_host_clk_rate(struct mmc_host *host); |
22 | 22 | ||
23 | #else | 23 | #else |
24 | static inline void mmc_host_clk_ungate(struct mmc_host *host) | 24 | static inline void mmc_host_clk_hold(struct mmc_host *host) |
25 | { | 25 | { |
26 | } | 26 | } |
27 | 27 | ||
28 | static inline void mmc_host_clk_gate(struct mmc_host *host) | 28 | static inline void mmc_host_clk_release(struct mmc_host *host) |
29 | { | 29 | { |
30 | } | 30 | } |
31 | 31 | ||
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 633975ff2bb3..0370e03e3142 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c | |||
@@ -469,56 +469,75 @@ static int sd_select_driver_type(struct mmc_card *card, u8 *status) | |||
469 | return 0; | 469 | return 0; |
470 | } | 470 | } |
471 | 471 | ||
472 | static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) | 472 | static void sd_update_bus_speed_mode(struct mmc_card *card) |
473 | { | 473 | { |
474 | unsigned int bus_speed = 0, timing = 0; | ||
475 | int err; | ||
476 | |||
477 | /* | 474 | /* |
478 | * If the host doesn't support any of the UHS-I modes, fallback on | 475 | * If the host doesn't support any of the UHS-I modes, fallback on |
479 | * default speed. | 476 | * default speed. |
480 | */ | 477 | */ |
481 | if (!(card->host->caps & (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | | 478 | if (!(card->host->caps & (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | |
482 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_DDR50))) | 479 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_DDR50))) { |
483 | return 0; | 480 | card->sd_bus_speed = 0; |
481 | return; | ||
482 | } | ||
484 | 483 | ||
485 | if ((card->host->caps & MMC_CAP_UHS_SDR104) && | 484 | if ((card->host->caps & MMC_CAP_UHS_SDR104) && |
486 | (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR104)) { | 485 | (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR104)) { |
487 | bus_speed = UHS_SDR104_BUS_SPEED; | 486 | card->sd_bus_speed = UHS_SDR104_BUS_SPEED; |
488 | timing = MMC_TIMING_UHS_SDR104; | ||
489 | card->sw_caps.uhs_max_dtr = UHS_SDR104_MAX_DTR; | ||
490 | } else if ((card->host->caps & MMC_CAP_UHS_DDR50) && | 487 | } else if ((card->host->caps & MMC_CAP_UHS_DDR50) && |
491 | (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_DDR50)) { | 488 | (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_DDR50)) { |
492 | bus_speed = UHS_DDR50_BUS_SPEED; | 489 | card->sd_bus_speed = UHS_DDR50_BUS_SPEED; |
493 | timing = MMC_TIMING_UHS_DDR50; | ||
494 | card->sw_caps.uhs_max_dtr = UHS_DDR50_MAX_DTR; | ||
495 | } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | | 490 | } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | |
496 | MMC_CAP_UHS_SDR50)) && (card->sw_caps.sd3_bus_mode & | 491 | MMC_CAP_UHS_SDR50)) && (card->sw_caps.sd3_bus_mode & |
497 | SD_MODE_UHS_SDR50)) { | 492 | SD_MODE_UHS_SDR50)) { |
498 | bus_speed = UHS_SDR50_BUS_SPEED; | 493 | card->sd_bus_speed = UHS_SDR50_BUS_SPEED; |
499 | timing = MMC_TIMING_UHS_SDR50; | ||
500 | card->sw_caps.uhs_max_dtr = UHS_SDR50_MAX_DTR; | ||
501 | } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | | 494 | } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | |
502 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR25)) && | 495 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR25)) && |
503 | (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR25)) { | 496 | (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR25)) { |
504 | bus_speed = UHS_SDR25_BUS_SPEED; | 497 | card->sd_bus_speed = UHS_SDR25_BUS_SPEED; |
505 | timing = MMC_TIMING_UHS_SDR25; | ||
506 | card->sw_caps.uhs_max_dtr = UHS_SDR25_MAX_DTR; | ||
507 | } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | | 498 | } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | |
508 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR25 | | 499 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR25 | |
509 | MMC_CAP_UHS_SDR12)) && (card->sw_caps.sd3_bus_mode & | 500 | MMC_CAP_UHS_SDR12)) && (card->sw_caps.sd3_bus_mode & |
510 | SD_MODE_UHS_SDR12)) { | 501 | SD_MODE_UHS_SDR12)) { |
511 | bus_speed = UHS_SDR12_BUS_SPEED; | 502 | card->sd_bus_speed = UHS_SDR12_BUS_SPEED; |
512 | timing = MMC_TIMING_UHS_SDR12; | 503 | } |
513 | card->sw_caps.uhs_max_dtr = UHS_SDR12_MAX_DTR; | 504 | } |
505 | |||
506 | static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) | ||
507 | { | ||
508 | int err; | ||
509 | unsigned int timing = 0; | ||
510 | |||
511 | switch (card->sd_bus_speed) { | ||
512 | case UHS_SDR104_BUS_SPEED: | ||
513 | timing = MMC_TIMING_UHS_SDR104; | ||
514 | card->sw_caps.uhs_max_dtr = UHS_SDR104_MAX_DTR; | ||
515 | break; | ||
516 | case UHS_DDR50_BUS_SPEED: | ||
517 | timing = MMC_TIMING_UHS_DDR50; | ||
518 | card->sw_caps.uhs_max_dtr = UHS_DDR50_MAX_DTR; | ||
519 | break; | ||
520 | case UHS_SDR50_BUS_SPEED: | ||
521 | timing = MMC_TIMING_UHS_SDR50; | ||
522 | card->sw_caps.uhs_max_dtr = UHS_SDR50_MAX_DTR; | ||
523 | break; | ||
524 | case UHS_SDR25_BUS_SPEED: | ||
525 | timing = MMC_TIMING_UHS_SDR25; | ||
526 | card->sw_caps.uhs_max_dtr = UHS_SDR25_MAX_DTR; | ||
527 | break; | ||
528 | case UHS_SDR12_BUS_SPEED: | ||
529 | timing = MMC_TIMING_UHS_SDR12; | ||
530 | card->sw_caps.uhs_max_dtr = UHS_SDR12_MAX_DTR; | ||
531 | break; | ||
532 | default: | ||
533 | return 0; | ||
514 | } | 534 | } |
515 | 535 | ||
516 | card->sd_bus_speed = bus_speed; | 536 | err = mmc_sd_switch(card, 1, 0, card->sd_bus_speed, status); |
517 | err = mmc_sd_switch(card, 1, 0, bus_speed, status); | ||
518 | if (err) | 537 | if (err) |
519 | return err; | 538 | return err; |
520 | 539 | ||
521 | if ((status[16] & 0xF) != bus_speed) | 540 | if ((status[16] & 0xF) != card->sd_bus_speed) |
522 | printk(KERN_WARNING "%s: Problem setting bus speed mode!\n", | 541 | printk(KERN_WARNING "%s: Problem setting bus speed mode!\n", |
523 | mmc_hostname(card->host)); | 542 | mmc_hostname(card->host)); |
524 | else { | 543 | else { |
@@ -618,18 +637,24 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card) | |||
618 | mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4); | 637 | mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4); |
619 | } | 638 | } |
620 | 639 | ||
640 | /* | ||
641 | * Select the bus speed mode depending on host | ||
642 | * and card capability. | ||
643 | */ | ||
644 | sd_update_bus_speed_mode(card); | ||
645 | |||
621 | /* Set the driver strength for the card */ | 646 | /* Set the driver strength for the card */ |
622 | err = sd_select_driver_type(card, status); | 647 | err = sd_select_driver_type(card, status); |
623 | if (err) | 648 | if (err) |
624 | goto out; | 649 | goto out; |
625 | 650 | ||
626 | /* Set bus speed mode of the card */ | 651 | /* Set current limit for the card */ |
627 | err = sd_set_bus_speed_mode(card, status); | 652 | err = sd_set_current_limit(card, status); |
628 | if (err) | 653 | if (err) |
629 | goto out; | 654 | goto out; |
630 | 655 | ||
631 | /* Set current limit for the card */ | 656 | /* Set bus speed mode of the card */ |
632 | err = sd_set_current_limit(card, status); | 657 | err = sd_set_bus_speed_mode(card, status); |
633 | if (err) | 658 | if (err) |
634 | goto out; | 659 | goto out; |
635 | 660 | ||
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 0e9780f5a4a9..4dc0028086a3 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/err.h> | 16 | #include <linux/err.h> |
17 | #include <linux/clk.h> | 17 | #include <linux/clk.h> |
18 | #include <linux/gpio.h> | 18 | #include <linux/gpio.h> |
19 | #include <linux/module.h> | ||
19 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
20 | #include <linux/mmc/host.h> | 21 | #include <linux/mmc/host.h> |
21 | #include <linux/mmc/mmc.h> | 22 | #include <linux/mmc/mmc.h> |
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c index 2bd7bf4fece7..fe886d6c474a 100644 --- a/drivers/mmc/host/sdhci-s3c.c +++ b/drivers/mmc/host/sdhci-s3c.c | |||
@@ -302,6 +302,8 @@ static int sdhci_s3c_platform_8bit_width(struct sdhci_host *host, int width) | |||
302 | ctrl &= ~SDHCI_CTRL_8BITBUS; | 302 | ctrl &= ~SDHCI_CTRL_8BITBUS; |
303 | break; | 303 | break; |
304 | default: | 304 | default: |
305 | ctrl &= ~SDHCI_CTRL_4BITBUS; | ||
306 | ctrl &= ~SDHCI_CTRL_8BITBUS; | ||
305 | break; | 307 | break; |
306 | } | 308 | } |
307 | 309 | ||
diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index 774f6439d7ce..0c4a672f5db6 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c | |||
@@ -120,11 +120,11 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) | |||
120 | mmc_data->hclk = clk_get_rate(priv->clk); | 120 | mmc_data->hclk = clk_get_rate(priv->clk); |
121 | mmc_data->set_pwr = sh_mobile_sdhi_set_pwr; | 121 | mmc_data->set_pwr = sh_mobile_sdhi_set_pwr; |
122 | mmc_data->get_cd = sh_mobile_sdhi_get_cd; | 122 | mmc_data->get_cd = sh_mobile_sdhi_get_cd; |
123 | if (mmc_data->flags & TMIO_MMC_HAS_IDLE_WAIT) | ||
124 | mmc_data->write16_hook = sh_mobile_sdhi_write16_hook; | ||
125 | mmc_data->capabilities = MMC_CAP_MMC_HIGHSPEED; | 123 | mmc_data->capabilities = MMC_CAP_MMC_HIGHSPEED; |
126 | if (p) { | 124 | if (p) { |
127 | mmc_data->flags = p->tmio_flags; | 125 | mmc_data->flags = p->tmio_flags; |
126 | if (mmc_data->flags & TMIO_MMC_HAS_IDLE_WAIT) | ||
127 | mmc_data->write16_hook = sh_mobile_sdhi_write16_hook; | ||
128 | mmc_data->ocr_mask = p->tmio_ocr_mask; | 128 | mmc_data->ocr_mask = p->tmio_ocr_mask; |
129 | mmc_data->capabilities |= p->tmio_caps; | 129 | mmc_data->capabilities |= p->tmio_caps; |
130 | 130 | ||
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index 65b5b76cc379..64fbb0021825 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h | |||
@@ -181,7 +181,7 @@ static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi) | |||
181 | 181 | ||
182 | #define ubi_dbg_msg(fmt, ...) do { \ | 182 | #define ubi_dbg_msg(fmt, ...) do { \ |
183 | if (0) \ | 183 | if (0) \ |
184 | pr_debug(fmt "\n", ##__VA_ARGS__); \ | 184 | printk(KERN_DEBUG fmt "\n", ##__VA_ARGS__); \ |
185 | } while (0) | 185 | } while (0) |
186 | 186 | ||
187 | #define dbg_msg(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__) | 187 | #define dbg_msg(fmt, ...) ubi_dbg_msg(fmt, ##__VA_ARGS__) |
diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c index 52fe21e1e2cd..3b1416e3d217 100644 --- a/drivers/net/arm/am79c961a.c +++ b/drivers/net/arm/am79c961a.c | |||
@@ -308,8 +308,11 @@ static void am79c961_timer(unsigned long data) | |||
308 | struct net_device *dev = (struct net_device *)data; | 308 | struct net_device *dev = (struct net_device *)data; |
309 | struct dev_priv *priv = netdev_priv(dev); | 309 | struct dev_priv *priv = netdev_priv(dev); |
310 | unsigned int lnkstat, carrier; | 310 | unsigned int lnkstat, carrier; |
311 | unsigned long flags; | ||
311 | 312 | ||
313 | spin_lock_irqsave(&priv->chip_lock, flags); | ||
312 | lnkstat = read_ireg(dev->base_addr, ISALED0) & ISALED0_LNKST; | 314 | lnkstat = read_ireg(dev->base_addr, ISALED0) & ISALED0_LNKST; |
315 | spin_unlock_irqrestore(&priv->chip_lock, flags); | ||
313 | carrier = netif_carrier_ok(dev); | 316 | carrier = netif_carrier_ok(dev); |
314 | 317 | ||
315 | if (lnkstat && !carrier) { | 318 | if (lnkstat && !carrier) { |
diff --git a/drivers/pci/hotplug/pcihp_slot.c b/drivers/pci/hotplug/pcihp_slot.c index 753b21aaea61..3ffd9c1acc0a 100644 --- a/drivers/pci/hotplug/pcihp_slot.c +++ b/drivers/pci/hotplug/pcihp_slot.c | |||
@@ -169,7 +169,9 @@ void pci_configure_slot(struct pci_dev *dev) | |||
169 | (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI))) | 169 | (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI))) |
170 | return; | 170 | return; |
171 | 171 | ||
172 | pcie_bus_configure_settings(dev->bus, dev->bus->self->pcie_mpss); | 172 | if (dev->bus && dev->bus->self) |
173 | pcie_bus_configure_settings(dev->bus, | ||
174 | dev->bus->self->pcie_mpss); | ||
173 | 175 | ||
174 | memset(&hpp, 0, sizeof(hpp)); | 176 | memset(&hpp, 0, sizeof(hpp)); |
175 | ret = pci_get_hp_params(dev, &hpp); | 177 | ret = pci_get_hp_params(dev, &hpp); |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 0ce67423a0a3..4e84fd4a4312 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -77,7 +77,7 @@ unsigned long pci_cardbus_mem_size = DEFAULT_CARDBUS_MEM_SIZE; | |||
77 | unsigned long pci_hotplug_io_size = DEFAULT_HOTPLUG_IO_SIZE; | 77 | unsigned long pci_hotplug_io_size = DEFAULT_HOTPLUG_IO_SIZE; |
78 | unsigned long pci_hotplug_mem_size = DEFAULT_HOTPLUG_MEM_SIZE; | 78 | unsigned long pci_hotplug_mem_size = DEFAULT_HOTPLUG_MEM_SIZE; |
79 | 79 | ||
80 | enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_PERFORMANCE; | 80 | enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_SAFE; |
81 | 81 | ||
82 | /* | 82 | /* |
83 | * The default CLS is used if arch didn't set CLS explicitly and not | 83 | * The default CLS is used if arch didn't set CLS explicitly and not |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 8473727b29fa..b1187ff31d89 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -1396,34 +1396,37 @@ static void pcie_write_mps(struct pci_dev *dev, int mps) | |||
1396 | 1396 | ||
1397 | static void pcie_write_mrrs(struct pci_dev *dev, int mps) | 1397 | static void pcie_write_mrrs(struct pci_dev *dev, int mps) |
1398 | { | 1398 | { |
1399 | int rc, mrrs; | 1399 | int rc, mrrs, dev_mpss; |
1400 | 1400 | ||
1401 | if (pcie_bus_config == PCIE_BUS_PERFORMANCE) { | 1401 | /* In the "safe" case, do not configure the MRRS. There appear to be |
1402 | int dev_mpss = 128 << dev->pcie_mpss; | 1402 | * issues with setting MRRS to 0 on a number of devices. |
1403 | */ | ||
1403 | 1404 | ||
1404 | /* For Max performance, the MRRS must be set to the largest | 1405 | if (pcie_bus_config != PCIE_BUS_PERFORMANCE) |
1405 | * supported value. However, it cannot be configured larger | 1406 | return; |
1406 | * than the MPS the device or the bus can support. This assumes | ||
1407 | * that the largest MRRS available on the device cannot be | ||
1408 | * smaller than the device MPSS. | ||
1409 | */ | ||
1410 | mrrs = mps < dev_mpss ? mps : dev_mpss; | ||
1411 | } else | ||
1412 | /* In the "safe" case, configure the MRRS for fairness on the | ||
1413 | * bus by making all devices have the same size | ||
1414 | */ | ||
1415 | mrrs = mps; | ||
1416 | 1407 | ||
1408 | dev_mpss = 128 << dev->pcie_mpss; | ||
1409 | |||
1410 | /* For Max performance, the MRRS must be set to the largest supported | ||
1411 | * value. However, it cannot be configured larger than the MPS the | ||
1412 | * device or the bus can support. This assumes that the largest MRRS | ||
1413 | * available on the device cannot be smaller than the device MPSS. | ||
1414 | */ | ||
1415 | mrrs = min(mps, dev_mpss); | ||
1417 | 1416 | ||
1418 | /* MRRS is a R/W register. Invalid values can be written, but a | 1417 | /* MRRS is a R/W register. Invalid values can be written, but a |
1419 | * subsiquent read will verify if the value is acceptable or not. | 1418 | * subsequent read will verify if the value is acceptable or not. |
1420 | * If the MRRS value provided is not acceptable (e.g., too large), | 1419 | * If the MRRS value provided is not acceptable (e.g., too large), |
1421 | * shrink the value until it is acceptable to the HW. | 1420 | * shrink the value until it is acceptable to the HW. |
1422 | */ | 1421 | */ |
1423 | while (mrrs != pcie_get_readrq(dev) && mrrs >= 128) { | 1422 | while (mrrs != pcie_get_readrq(dev) && mrrs >= 128) { |
1423 | dev_warn(&dev->dev, "Attempting to modify the PCI-E MRRS value" | ||
1424 | " to %d. If any issues are encountered, please try " | ||
1425 | "running with pci=pcie_bus_safe\n", mrrs); | ||
1424 | rc = pcie_set_readrq(dev, mrrs); | 1426 | rc = pcie_set_readrq(dev, mrrs); |
1425 | if (rc) | 1427 | if (rc) |
1426 | dev_err(&dev->dev, "Failed attempting to set the MRRS\n"); | 1428 | dev_err(&dev->dev, |
1429 | "Failed attempting to set the MRRS\n"); | ||
1427 | 1430 | ||
1428 | mrrs /= 2; | 1431 | mrrs /= 2; |
1429 | } | 1432 | } |
@@ -1436,13 +1439,13 @@ static int pcie_bus_configure_set(struct pci_dev *dev, void *data) | |||
1436 | if (!pci_is_pcie(dev)) | 1439 | if (!pci_is_pcie(dev)) |
1437 | return 0; | 1440 | return 0; |
1438 | 1441 | ||
1439 | dev_info(&dev->dev, "Dev MPS %d MPSS %d MRRS %d\n", | 1442 | dev_dbg(&dev->dev, "Dev MPS %d MPSS %d MRRS %d\n", |
1440 | pcie_get_mps(dev), 128<<dev->pcie_mpss, pcie_get_readrq(dev)); | 1443 | pcie_get_mps(dev), 128<<dev->pcie_mpss, pcie_get_readrq(dev)); |
1441 | 1444 | ||
1442 | pcie_write_mps(dev, mps); | 1445 | pcie_write_mps(dev, mps); |
1443 | pcie_write_mrrs(dev, mps); | 1446 | pcie_write_mrrs(dev, mps); |
1444 | 1447 | ||
1445 | dev_info(&dev->dev, "Dev MPS %d MPSS %d MRRS %d\n", | 1448 | dev_dbg(&dev->dev, "Dev MPS %d MPSS %d MRRS %d\n", |
1446 | pcie_get_mps(dev), 128<<dev->pcie_mpss, pcie_get_readrq(dev)); | 1449 | pcie_get_mps(dev), 128<<dev->pcie_mpss, pcie_get_readrq(dev)); |
1447 | 1450 | ||
1448 | return 0; | 1451 | return 0; |
@@ -1456,9 +1459,6 @@ void pcie_bus_configure_settings(struct pci_bus *bus, u8 mpss) | |||
1456 | { | 1459 | { |
1457 | u8 smpss = mpss; | 1460 | u8 smpss = mpss; |
1458 | 1461 | ||
1459 | if (!bus->self) | ||
1460 | return; | ||
1461 | |||
1462 | if (!pci_is_pcie(bus->self)) | 1462 | if (!pci_is_pcie(bus->self)) |
1463 | return; | 1463 | return; |
1464 | 1464 | ||
diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c index 335551d333b2..14a42a1edc66 100644 --- a/drivers/rtc/rtc-ep93xx.c +++ b/drivers/rtc/rtc-ep93xx.c | |||
@@ -36,6 +36,7 @@ | |||
36 | */ | 36 | */ |
37 | struct ep93xx_rtc { | 37 | struct ep93xx_rtc { |
38 | void __iomem *mmio_base; | 38 | void __iomem *mmio_base; |
39 | struct rtc_device *rtc; | ||
39 | }; | 40 | }; |
40 | 41 | ||
41 | static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload, | 42 | static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload, |
@@ -130,7 +131,6 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev) | |||
130 | { | 131 | { |
131 | struct ep93xx_rtc *ep93xx_rtc; | 132 | struct ep93xx_rtc *ep93xx_rtc; |
132 | struct resource *res; | 133 | struct resource *res; |
133 | struct rtc_device *rtc; | ||
134 | int err; | 134 | int err; |
135 | 135 | ||
136 | ep93xx_rtc = devm_kzalloc(&pdev->dev, sizeof(*ep93xx_rtc), GFP_KERNEL); | 136 | ep93xx_rtc = devm_kzalloc(&pdev->dev, sizeof(*ep93xx_rtc), GFP_KERNEL); |
@@ -151,12 +151,12 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev) | |||
151 | return -ENXIO; | 151 | return -ENXIO; |
152 | 152 | ||
153 | pdev->dev.platform_data = ep93xx_rtc; | 153 | pdev->dev.platform_data = ep93xx_rtc; |
154 | platform_set_drvdata(pdev, rtc); | 154 | platform_set_drvdata(pdev, ep93xx_rtc); |
155 | 155 | ||
156 | rtc = rtc_device_register(pdev->name, | 156 | ep93xx_rtc->rtc = rtc_device_register(pdev->name, |
157 | &pdev->dev, &ep93xx_rtc_ops, THIS_MODULE); | 157 | &pdev->dev, &ep93xx_rtc_ops, THIS_MODULE); |
158 | if (IS_ERR(rtc)) { | 158 | if (IS_ERR(ep93xx_rtc->rtc)) { |
159 | err = PTR_ERR(rtc); | 159 | err = PTR_ERR(ep93xx_rtc->rtc); |
160 | goto exit; | 160 | goto exit; |
161 | } | 161 | } |
162 | 162 | ||
@@ -167,7 +167,7 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev) | |||
167 | return 0; | 167 | return 0; |
168 | 168 | ||
169 | fail: | 169 | fail: |
170 | rtc_device_unregister(rtc); | 170 | rtc_device_unregister(ep93xx_rtc->rtc); |
171 | exit: | 171 | exit: |
172 | platform_set_drvdata(pdev, NULL); | 172 | platform_set_drvdata(pdev, NULL); |
173 | pdev->dev.platform_data = NULL; | 173 | pdev->dev.platform_data = NULL; |
@@ -176,11 +176,11 @@ exit: | |||
176 | 176 | ||
177 | static int __exit ep93xx_rtc_remove(struct platform_device *pdev) | 177 | static int __exit ep93xx_rtc_remove(struct platform_device *pdev) |
178 | { | 178 | { |
179 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 179 | struct ep93xx_rtc *ep93xx_rtc = platform_get_drvdata(pdev); |
180 | 180 | ||
181 | sysfs_remove_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); | 181 | sysfs_remove_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); |
182 | platform_set_drvdata(pdev, NULL); | 182 | platform_set_drvdata(pdev, NULL); |
183 | rtc_device_unregister(rtc); | 183 | rtc_device_unregister(ep93xx_rtc->rtc); |
184 | pdev->dev.platform_data = NULL; | 184 | pdev->dev.platform_data = NULL; |
185 | 185 | ||
186 | return 0; | 186 | return 0; |
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c index 075f1708deae..c4cf05731118 100644 --- a/drivers/rtc/rtc-lib.c +++ b/drivers/rtc/rtc-lib.c | |||
@@ -85,6 +85,8 @@ void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) | |||
85 | time -= tm->tm_hour * 3600; | 85 | time -= tm->tm_hour * 3600; |
86 | tm->tm_min = time / 60; | 86 | tm->tm_min = time / 60; |
87 | tm->tm_sec = time - tm->tm_min * 60; | 87 | tm->tm_sec = time - tm->tm_min * 60; |
88 | |||
89 | tm->tm_isdst = 0; | ||
88 | } | 90 | } |
89 | EXPORT_SYMBOL(rtc_time_to_tm); | 91 | EXPORT_SYMBOL(rtc_time_to_tm); |
90 | 92 | ||
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c index 9a81f778d6b2..20687d55e7a7 100644 --- a/drivers/rtc/rtc-twl.c +++ b/drivers/rtc/rtc-twl.c | |||
@@ -362,14 +362,6 @@ static irqreturn_t twl_rtc_interrupt(int irq, void *rtc) | |||
362 | int res; | 362 | int res; |
363 | u8 rd_reg; | 363 | u8 rd_reg; |
364 | 364 | ||
365 | #ifdef CONFIG_LOCKDEP | ||
366 | /* WORKAROUND for lockdep forcing IRQF_DISABLED on us, which | ||
367 | * we don't want and can't tolerate. Although it might be | ||
368 | * friendlier not to borrow this thread context... | ||
369 | */ | ||
370 | local_irq_enable(); | ||
371 | #endif | ||
372 | |||
373 | res = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); | 365 | res = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); |
374 | if (res) | 366 | if (res) |
375 | goto out; | 367 | goto out; |
@@ -428,24 +420,12 @@ static struct rtc_class_ops twl_rtc_ops = { | |||
428 | static int __devinit twl_rtc_probe(struct platform_device *pdev) | 420 | static int __devinit twl_rtc_probe(struct platform_device *pdev) |
429 | { | 421 | { |
430 | struct rtc_device *rtc; | 422 | struct rtc_device *rtc; |
431 | int ret = 0; | 423 | int ret = -EINVAL; |
432 | int irq = platform_get_irq(pdev, 0); | 424 | int irq = platform_get_irq(pdev, 0); |
433 | u8 rd_reg; | 425 | u8 rd_reg; |
434 | 426 | ||
435 | if (irq <= 0) | 427 | if (irq <= 0) |
436 | return -EINVAL; | 428 | goto out1; |
437 | |||
438 | rtc = rtc_device_register(pdev->name, | ||
439 | &pdev->dev, &twl_rtc_ops, THIS_MODULE); | ||
440 | if (IS_ERR(rtc)) { | ||
441 | ret = PTR_ERR(rtc); | ||
442 | dev_err(&pdev->dev, "can't register RTC device, err %ld\n", | ||
443 | PTR_ERR(rtc)); | ||
444 | goto out0; | ||
445 | |||
446 | } | ||
447 | |||
448 | platform_set_drvdata(pdev, rtc); | ||
449 | 429 | ||
450 | ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); | 430 | ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); |
451 | if (ret < 0) | 431 | if (ret < 0) |
@@ -462,14 +442,6 @@ static int __devinit twl_rtc_probe(struct platform_device *pdev) | |||
462 | if (ret < 0) | 442 | if (ret < 0) |
463 | goto out1; | 443 | goto out1; |
464 | 444 | ||
465 | ret = request_irq(irq, twl_rtc_interrupt, | ||
466 | IRQF_TRIGGER_RISING, | ||
467 | dev_name(&rtc->dev), rtc); | ||
468 | if (ret < 0) { | ||
469 | dev_err(&pdev->dev, "IRQ is not free.\n"); | ||
470 | goto out1; | ||
471 | } | ||
472 | |||
473 | if (twl_class_is_6030()) { | 445 | if (twl_class_is_6030()) { |
474 | twl6030_interrupt_unmask(TWL6030_RTC_INT_MASK, | 446 | twl6030_interrupt_unmask(TWL6030_RTC_INT_MASK, |
475 | REG_INT_MSK_LINE_A); | 447 | REG_INT_MSK_LINE_A); |
@@ -480,28 +452,44 @@ static int __devinit twl_rtc_probe(struct platform_device *pdev) | |||
480 | /* Check RTC module status, Enable if it is off */ | 452 | /* Check RTC module status, Enable if it is off */ |
481 | ret = twl_rtc_read_u8(&rd_reg, REG_RTC_CTRL_REG); | 453 | ret = twl_rtc_read_u8(&rd_reg, REG_RTC_CTRL_REG); |
482 | if (ret < 0) | 454 | if (ret < 0) |
483 | goto out2; | 455 | goto out1; |
484 | 456 | ||
485 | if (!(rd_reg & BIT_RTC_CTRL_REG_STOP_RTC_M)) { | 457 | if (!(rd_reg & BIT_RTC_CTRL_REG_STOP_RTC_M)) { |
486 | dev_info(&pdev->dev, "Enabling TWL-RTC.\n"); | 458 | dev_info(&pdev->dev, "Enabling TWL-RTC.\n"); |
487 | rd_reg = BIT_RTC_CTRL_REG_STOP_RTC_M; | 459 | rd_reg = BIT_RTC_CTRL_REG_STOP_RTC_M; |
488 | ret = twl_rtc_write_u8(rd_reg, REG_RTC_CTRL_REG); | 460 | ret = twl_rtc_write_u8(rd_reg, REG_RTC_CTRL_REG); |
489 | if (ret < 0) | 461 | if (ret < 0) |
490 | goto out2; | 462 | goto out1; |
491 | } | 463 | } |
492 | 464 | ||
493 | /* init cached IRQ enable bits */ | 465 | /* init cached IRQ enable bits */ |
494 | ret = twl_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG); | 466 | ret = twl_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG); |
495 | if (ret < 0) | 467 | if (ret < 0) |
468 | goto out1; | ||
469 | |||
470 | rtc = rtc_device_register(pdev->name, | ||
471 | &pdev->dev, &twl_rtc_ops, THIS_MODULE); | ||
472 | if (IS_ERR(rtc)) { | ||
473 | ret = PTR_ERR(rtc); | ||
474 | dev_err(&pdev->dev, "can't register RTC device, err %ld\n", | ||
475 | PTR_ERR(rtc)); | ||
476 | goto out1; | ||
477 | } | ||
478 | |||
479 | ret = request_threaded_irq(irq, NULL, twl_rtc_interrupt, | ||
480 | IRQF_TRIGGER_RISING, | ||
481 | dev_name(&rtc->dev), rtc); | ||
482 | if (ret < 0) { | ||
483 | dev_err(&pdev->dev, "IRQ is not free.\n"); | ||
496 | goto out2; | 484 | goto out2; |
485 | } | ||
497 | 486 | ||
498 | return ret; | 487 | platform_set_drvdata(pdev, rtc); |
488 | return 0; | ||
499 | 489 | ||
500 | out2: | 490 | out2: |
501 | free_irq(irq, rtc); | ||
502 | out1: | ||
503 | rtc_device_unregister(rtc); | 491 | rtc_device_unregister(rtc); |
504 | out0: | 492 | out1: |
505 | return ret; | 493 | return ret; |
506 | } | 494 | } |
507 | 495 | ||
diff --git a/drivers/scsi/qla4xxx/Kconfig b/drivers/scsi/qla4xxx/Kconfig index 2c33ce6eac1e..0f5599e0abf6 100644 --- a/drivers/scsi/qla4xxx/Kconfig +++ b/drivers/scsi/qla4xxx/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config SCSI_QLA_ISCSI | 1 | config SCSI_QLA_ISCSI |
2 | tristate "QLogic ISP4XXX and ISP82XX host adapter family support" | 2 | tristate "QLogic ISP4XXX and ISP82XX host adapter family support" |
3 | depends on PCI && SCSI | 3 | depends on PCI && SCSI && NET |
4 | select SCSI_ISCSI_ATTRS | 4 | select SCSI_ISCSI_ATTRS |
5 | ---help--- | 5 | ---help--- |
6 | This driver supports the QLogic 40xx (ISP4XXX) and 8022 (ISP82XX) | 6 | This driver supports the QLogic 40xx (ISP4XXX) and 8022 (ISP82XX) |
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 80d292fb92d8..7363c1b169e8 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <asm/backlight.h> | 19 | #include <asm/backlight.h> |
20 | #endif | 20 | #endif |
21 | 21 | ||
22 | static const char const *backlight_types[] = { | 22 | static const char *const backlight_types[] = { |
23 | [BACKLIGHT_RAW] = "raw", | 23 | [BACKLIGHT_RAW] = "raw", |
24 | [BACKLIGHT_PLATFORM] = "platform", | 24 | [BACKLIGHT_PLATFORM] = "platform", |
25 | [BACKLIGHT_FIRMWARE] = "firmware", | 25 | [BACKLIGHT_FIRMWARE] = "firmware", |
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index 46ce357ca1ab..410ffd6ceb5f 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h | |||
@@ -54,9 +54,9 @@ extern struct kmem_cache *v9fs_inode_cache; | |||
54 | 54 | ||
55 | struct inode *v9fs_alloc_inode(struct super_block *sb); | 55 | struct inode *v9fs_alloc_inode(struct super_block *sb); |
56 | void v9fs_destroy_inode(struct inode *inode); | 56 | void v9fs_destroy_inode(struct inode *inode); |
57 | struct inode *v9fs_get_inode(struct super_block *sb, int mode); | 57 | struct inode *v9fs_get_inode(struct super_block *sb, int mode, dev_t); |
58 | int v9fs_init_inode(struct v9fs_session_info *v9ses, | 58 | int v9fs_init_inode(struct v9fs_session_info *v9ses, |
59 | struct inode *inode, int mode); | 59 | struct inode *inode, int mode, dev_t); |
60 | void v9fs_evict_inode(struct inode *inode); | 60 | void v9fs_evict_inode(struct inode *inode); |
61 | ino_t v9fs_qid2ino(struct p9_qid *qid); | 61 | ino_t v9fs_qid2ino(struct p9_qid *qid); |
62 | void v9fs_stat2inode(struct p9_wstat *, struct inode *, struct super_block *); | 62 | void v9fs_stat2inode(struct p9_wstat *, struct inode *, struct super_block *); |
@@ -83,4 +83,6 @@ static inline void v9fs_invalidate_inode_attr(struct inode *inode) | |||
83 | v9inode->cache_validity |= V9FS_INO_INVALID_ATTR; | 83 | v9inode->cache_validity |= V9FS_INO_INVALID_ATTR; |
84 | return; | 84 | return; |
85 | } | 85 | } |
86 | |||
87 | int v9fs_open_to_dotl_flags(int flags); | ||
86 | #endif | 88 | #endif |
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 3c173fcc2c5a..62857a810a79 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c | |||
@@ -65,7 +65,7 @@ int v9fs_file_open(struct inode *inode, struct file *file) | |||
65 | v9inode = V9FS_I(inode); | 65 | v9inode = V9FS_I(inode); |
66 | v9ses = v9fs_inode2v9ses(inode); | 66 | v9ses = v9fs_inode2v9ses(inode); |
67 | if (v9fs_proto_dotl(v9ses)) | 67 | if (v9fs_proto_dotl(v9ses)) |
68 | omode = file->f_flags; | 68 | omode = v9fs_open_to_dotl_flags(file->f_flags); |
69 | else | 69 | else |
70 | omode = v9fs_uflags2omode(file->f_flags, | 70 | omode = v9fs_uflags2omode(file->f_flags, |
71 | v9fs_proto_dotu(v9ses)); | 71 | v9fs_proto_dotu(v9ses)); |
@@ -169,7 +169,18 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl) | |||
169 | 169 | ||
170 | /* convert posix lock to p9 tlock args */ | 170 | /* convert posix lock to p9 tlock args */ |
171 | memset(&flock, 0, sizeof(flock)); | 171 | memset(&flock, 0, sizeof(flock)); |
172 | flock.type = fl->fl_type; | 172 | /* map the lock type */ |
173 | switch (fl->fl_type) { | ||
174 | case F_RDLCK: | ||
175 | flock.type = P9_LOCK_TYPE_RDLCK; | ||
176 | break; | ||
177 | case F_WRLCK: | ||
178 | flock.type = P9_LOCK_TYPE_WRLCK; | ||
179 | break; | ||
180 | case F_UNLCK: | ||
181 | flock.type = P9_LOCK_TYPE_UNLCK; | ||
182 | break; | ||
183 | } | ||
173 | flock.start = fl->fl_start; | 184 | flock.start = fl->fl_start; |
174 | if (fl->fl_end == OFFSET_MAX) | 185 | if (fl->fl_end == OFFSET_MAX) |
175 | flock.length = 0; | 186 | flock.length = 0; |
@@ -245,7 +256,7 @@ static int v9fs_file_getlock(struct file *filp, struct file_lock *fl) | |||
245 | 256 | ||
246 | /* convert posix lock to p9 tgetlock args */ | 257 | /* convert posix lock to p9 tgetlock args */ |
247 | memset(&glock, 0, sizeof(glock)); | 258 | memset(&glock, 0, sizeof(glock)); |
248 | glock.type = fl->fl_type; | 259 | glock.type = P9_LOCK_TYPE_UNLCK; |
249 | glock.start = fl->fl_start; | 260 | glock.start = fl->fl_start; |
250 | if (fl->fl_end == OFFSET_MAX) | 261 | if (fl->fl_end == OFFSET_MAX) |
251 | glock.length = 0; | 262 | glock.length = 0; |
@@ -257,17 +268,26 @@ static int v9fs_file_getlock(struct file *filp, struct file_lock *fl) | |||
257 | res = p9_client_getlock_dotl(fid, &glock); | 268 | res = p9_client_getlock_dotl(fid, &glock); |
258 | if (res < 0) | 269 | if (res < 0) |
259 | return res; | 270 | return res; |
260 | if (glock.type != F_UNLCK) { | 271 | /* map 9p lock type to os lock type */ |
261 | fl->fl_type = glock.type; | 272 | switch (glock.type) { |
273 | case P9_LOCK_TYPE_RDLCK: | ||
274 | fl->fl_type = F_RDLCK; | ||
275 | break; | ||
276 | case P9_LOCK_TYPE_WRLCK: | ||
277 | fl->fl_type = F_WRLCK; | ||
278 | break; | ||
279 | case P9_LOCK_TYPE_UNLCK: | ||
280 | fl->fl_type = F_UNLCK; | ||
281 | break; | ||
282 | } | ||
283 | if (glock.type != P9_LOCK_TYPE_UNLCK) { | ||
262 | fl->fl_start = glock.start; | 284 | fl->fl_start = glock.start; |
263 | if (glock.length == 0) | 285 | if (glock.length == 0) |
264 | fl->fl_end = OFFSET_MAX; | 286 | fl->fl_end = OFFSET_MAX; |
265 | else | 287 | else |
266 | fl->fl_end = glock.start + glock.length - 1; | 288 | fl->fl_end = glock.start + glock.length - 1; |
267 | fl->fl_pid = glock.proc_id; | 289 | fl->fl_pid = glock.proc_id; |
268 | } else | 290 | } |
269 | fl->fl_type = F_UNLCK; | ||
270 | |||
271 | return res; | 291 | return res; |
272 | } | 292 | } |
273 | 293 | ||
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 8bb5507e822f..e3c03db3c788 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -95,15 +95,18 @@ static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) | |||
95 | /** | 95 | /** |
96 | * p9mode2unixmode- convert plan9 mode bits to unix mode bits | 96 | * p9mode2unixmode- convert plan9 mode bits to unix mode bits |
97 | * @v9ses: v9fs session information | 97 | * @v9ses: v9fs session information |
98 | * @mode: mode to convert | 98 | * @stat: p9_wstat from which mode need to be derived |
99 | * @rdev: major number, minor number in case of device files. | ||
99 | * | 100 | * |
100 | */ | 101 | */ |
101 | 102 | static int p9mode2unixmode(struct v9fs_session_info *v9ses, | |
102 | static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) | 103 | struct p9_wstat *stat, dev_t *rdev) |
103 | { | 104 | { |
104 | int res; | 105 | int res; |
106 | int mode = stat->mode; | ||
105 | 107 | ||
106 | res = mode & 0777; | 108 | res = mode & S_IALLUGO; |
109 | *rdev = 0; | ||
107 | 110 | ||
108 | if ((mode & P9_DMDIR) == P9_DMDIR) | 111 | if ((mode & P9_DMDIR) == P9_DMDIR) |
109 | res |= S_IFDIR; | 112 | res |= S_IFDIR; |
@@ -116,9 +119,26 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) | |||
116 | && (v9ses->nodev == 0)) | 119 | && (v9ses->nodev == 0)) |
117 | res |= S_IFIFO; | 120 | res |= S_IFIFO; |
118 | else if ((mode & P9_DMDEVICE) && (v9fs_proto_dotu(v9ses)) | 121 | else if ((mode & P9_DMDEVICE) && (v9fs_proto_dotu(v9ses)) |
119 | && (v9ses->nodev == 0)) | 122 | && (v9ses->nodev == 0)) { |
120 | res |= S_IFBLK; | 123 | char type = 0, ext[32]; |
121 | else | 124 | int major = -1, minor = -1; |
125 | |||
126 | strncpy(ext, stat->extension, sizeof(ext)); | ||
127 | sscanf(ext, "%c %u %u", &type, &major, &minor); | ||
128 | switch (type) { | ||
129 | case 'c': | ||
130 | res |= S_IFCHR; | ||
131 | break; | ||
132 | case 'b': | ||
133 | res |= S_IFBLK; | ||
134 | break; | ||
135 | default: | ||
136 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
137 | "Unknown special type %c %s\n", type, | ||
138 | stat->extension); | ||
139 | }; | ||
140 | *rdev = MKDEV(major, minor); | ||
141 | } else | ||
122 | res |= S_IFREG; | 142 | res |= S_IFREG; |
123 | 143 | ||
124 | if (v9fs_proto_dotu(v9ses)) { | 144 | if (v9fs_proto_dotu(v9ses)) { |
@@ -131,7 +151,6 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) | |||
131 | if ((mode & P9_DMSETVTX) == P9_DMSETVTX) | 151 | if ((mode & P9_DMSETVTX) == P9_DMSETVTX) |
132 | res |= S_ISVTX; | 152 | res |= S_ISVTX; |
133 | } | 153 | } |
134 | |||
135 | return res; | 154 | return res; |
136 | } | 155 | } |
137 | 156 | ||
@@ -242,13 +261,13 @@ void v9fs_destroy_inode(struct inode *inode) | |||
242 | } | 261 | } |
243 | 262 | ||
244 | int v9fs_init_inode(struct v9fs_session_info *v9ses, | 263 | int v9fs_init_inode(struct v9fs_session_info *v9ses, |
245 | struct inode *inode, int mode) | 264 | struct inode *inode, int mode, dev_t rdev) |
246 | { | 265 | { |
247 | int err = 0; | 266 | int err = 0; |
248 | 267 | ||
249 | inode_init_owner(inode, NULL, mode); | 268 | inode_init_owner(inode, NULL, mode); |
250 | inode->i_blocks = 0; | 269 | inode->i_blocks = 0; |
251 | inode->i_rdev = 0; | 270 | inode->i_rdev = rdev; |
252 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 271 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
253 | inode->i_mapping->a_ops = &v9fs_addr_operations; | 272 | inode->i_mapping->a_ops = &v9fs_addr_operations; |
254 | 273 | ||
@@ -335,7 +354,7 @@ error: | |||
335 | * | 354 | * |
336 | */ | 355 | */ |
337 | 356 | ||
338 | struct inode *v9fs_get_inode(struct super_block *sb, int mode) | 357 | struct inode *v9fs_get_inode(struct super_block *sb, int mode, dev_t rdev) |
339 | { | 358 | { |
340 | int err; | 359 | int err; |
341 | struct inode *inode; | 360 | struct inode *inode; |
@@ -348,7 +367,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) | |||
348 | P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n"); | 367 | P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n"); |
349 | return ERR_PTR(-ENOMEM); | 368 | return ERR_PTR(-ENOMEM); |
350 | } | 369 | } |
351 | err = v9fs_init_inode(v9ses, inode, mode); | 370 | err = v9fs_init_inode(v9ses, inode, mode, rdev); |
352 | if (err) { | 371 | if (err) { |
353 | iput(inode); | 372 | iput(inode); |
354 | return ERR_PTR(err); | 373 | return ERR_PTR(err); |
@@ -435,11 +454,12 @@ void v9fs_evict_inode(struct inode *inode) | |||
435 | static int v9fs_test_inode(struct inode *inode, void *data) | 454 | static int v9fs_test_inode(struct inode *inode, void *data) |
436 | { | 455 | { |
437 | int umode; | 456 | int umode; |
457 | dev_t rdev; | ||
438 | struct v9fs_inode *v9inode = V9FS_I(inode); | 458 | struct v9fs_inode *v9inode = V9FS_I(inode); |
439 | struct p9_wstat *st = (struct p9_wstat *)data; | 459 | struct p9_wstat *st = (struct p9_wstat *)data; |
440 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); | 460 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); |
441 | 461 | ||
442 | umode = p9mode2unixmode(v9ses, st->mode); | 462 | umode = p9mode2unixmode(v9ses, st, &rdev); |
443 | /* don't match inode of different type */ | 463 | /* don't match inode of different type */ |
444 | if ((inode->i_mode & S_IFMT) != (umode & S_IFMT)) | 464 | if ((inode->i_mode & S_IFMT) != (umode & S_IFMT)) |
445 | return 0; | 465 | return 0; |
@@ -473,6 +493,7 @@ static struct inode *v9fs_qid_iget(struct super_block *sb, | |||
473 | struct p9_wstat *st, | 493 | struct p9_wstat *st, |
474 | int new) | 494 | int new) |
475 | { | 495 | { |
496 | dev_t rdev; | ||
476 | int retval, umode; | 497 | int retval, umode; |
477 | unsigned long i_ino; | 498 | unsigned long i_ino; |
478 | struct inode *inode; | 499 | struct inode *inode; |
@@ -496,8 +517,8 @@ static struct inode *v9fs_qid_iget(struct super_block *sb, | |||
496 | * later. | 517 | * later. |
497 | */ | 518 | */ |
498 | inode->i_ino = i_ino; | 519 | inode->i_ino = i_ino; |
499 | umode = p9mode2unixmode(v9ses, st->mode); | 520 | umode = p9mode2unixmode(v9ses, st, &rdev); |
500 | retval = v9fs_init_inode(v9ses, inode, umode); | 521 | retval = v9fs_init_inode(v9ses, inode, umode, rdev); |
501 | if (retval) | 522 | if (retval) |
502 | goto error; | 523 | goto error; |
503 | 524 | ||
@@ -532,6 +553,19 @@ v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid, | |||
532 | } | 553 | } |
533 | 554 | ||
534 | /** | 555 | /** |
556 | * v9fs_at_to_dotl_flags- convert Linux specific AT flags to | ||
557 | * plan 9 AT flag. | ||
558 | * @flags: flags to convert | ||
559 | */ | ||
560 | static int v9fs_at_to_dotl_flags(int flags) | ||
561 | { | ||
562 | int rflags = 0; | ||
563 | if (flags & AT_REMOVEDIR) | ||
564 | rflags |= P9_DOTL_AT_REMOVEDIR; | ||
565 | return rflags; | ||
566 | } | ||
567 | |||
568 | /** | ||
535 | * v9fs_remove - helper function to remove files and directories | 569 | * v9fs_remove - helper function to remove files and directories |
536 | * @dir: directory inode that is being deleted | 570 | * @dir: directory inode that is being deleted |
537 | * @dentry: dentry that is being deleted | 571 | * @dentry: dentry that is being deleted |
@@ -558,7 +592,8 @@ static int v9fs_remove(struct inode *dir, struct dentry *dentry, int flags) | |||
558 | return retval; | 592 | return retval; |
559 | } | 593 | } |
560 | if (v9fs_proto_dotl(v9ses)) | 594 | if (v9fs_proto_dotl(v9ses)) |
561 | retval = p9_client_unlinkat(dfid, dentry->d_name.name, flags); | 595 | retval = p9_client_unlinkat(dfid, dentry->d_name.name, |
596 | v9fs_at_to_dotl_flags(flags)); | ||
562 | if (retval == -EOPNOTSUPP) { | 597 | if (retval == -EOPNOTSUPP) { |
563 | /* Try the one based on path */ | 598 | /* Try the one based on path */ |
564 | v9fid = v9fs_fid_clone(dentry); | 599 | v9fid = v9fs_fid_clone(dentry); |
@@ -645,13 +680,11 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir, | |||
645 | P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err); | 680 | P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err); |
646 | goto error; | 681 | goto error; |
647 | } | 682 | } |
648 | d_instantiate(dentry, inode); | ||
649 | err = v9fs_fid_add(dentry, fid); | 683 | err = v9fs_fid_add(dentry, fid); |
650 | if (err < 0) | 684 | if (err < 0) |
651 | goto error; | 685 | goto error; |
652 | 686 | d_instantiate(dentry, inode); | |
653 | return ofid; | 687 | return ofid; |
654 | |||
655 | error: | 688 | error: |
656 | if (ofid) | 689 | if (ofid) |
657 | p9_client_clunk(ofid); | 690 | p9_client_clunk(ofid); |
@@ -792,6 +825,7 @@ static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
792 | struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, | 825 | struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, |
793 | struct nameidata *nameidata) | 826 | struct nameidata *nameidata) |
794 | { | 827 | { |
828 | struct dentry *res; | ||
795 | struct super_block *sb; | 829 | struct super_block *sb; |
796 | struct v9fs_session_info *v9ses; | 830 | struct v9fs_session_info *v9ses; |
797 | struct p9_fid *dfid, *fid; | 831 | struct p9_fid *dfid, *fid; |
@@ -823,22 +857,35 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, | |||
823 | 857 | ||
824 | return ERR_PTR(result); | 858 | return ERR_PTR(result); |
825 | } | 859 | } |
826 | 860 | /* | |
827 | inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb); | 861 | * Make sure we don't use a wrong inode due to parallel |
862 | * unlink. For cached mode create calls request for new | ||
863 | * inode. But with cache disabled, lookup should do this. | ||
864 | */ | ||
865 | if (v9ses->cache) | ||
866 | inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb); | ||
867 | else | ||
868 | inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); | ||
828 | if (IS_ERR(inode)) { | 869 | if (IS_ERR(inode)) { |
829 | result = PTR_ERR(inode); | 870 | result = PTR_ERR(inode); |
830 | inode = NULL; | 871 | inode = NULL; |
831 | goto error; | 872 | goto error; |
832 | } | 873 | } |
833 | |||
834 | result = v9fs_fid_add(dentry, fid); | 874 | result = v9fs_fid_add(dentry, fid); |
835 | if (result < 0) | 875 | if (result < 0) |
836 | goto error_iput; | 876 | goto error_iput; |
837 | |||
838 | inst_out: | 877 | inst_out: |
839 | d_add(dentry, inode); | 878 | /* |
840 | return NULL; | 879 | * If we had a rename on the server and a parallel lookup |
841 | 880 | * for the new name, then make sure we instantiate with | |
881 | * the new name. ie look up for a/b, while on server somebody | ||
882 | * moved b under k and client parallely did a lookup for | ||
883 | * k/b. | ||
884 | */ | ||
885 | res = d_materialise_unique(dentry, inode); | ||
886 | if (!IS_ERR(res)) | ||
887 | return res; | ||
888 | result = PTR_ERR(res); | ||
842 | error_iput: | 889 | error_iput: |
843 | iput(inode); | 890 | iput(inode); |
844 | error: | 891 | error: |
@@ -1002,7 +1049,7 @@ v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
1002 | return PTR_ERR(st); | 1049 | return PTR_ERR(st); |
1003 | 1050 | ||
1004 | v9fs_stat2inode(st, dentry->d_inode, dentry->d_inode->i_sb); | 1051 | v9fs_stat2inode(st, dentry->d_inode, dentry->d_inode->i_sb); |
1005 | generic_fillattr(dentry->d_inode, stat); | 1052 | generic_fillattr(dentry->d_inode, stat); |
1006 | 1053 | ||
1007 | p9stat_free(st); | 1054 | p9stat_free(st); |
1008 | kfree(st); | 1055 | kfree(st); |
@@ -1086,6 +1133,7 @@ void | |||
1086 | v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, | 1133 | v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, |
1087 | struct super_block *sb) | 1134 | struct super_block *sb) |
1088 | { | 1135 | { |
1136 | mode_t mode; | ||
1089 | char ext[32]; | 1137 | char ext[32]; |
1090 | char tag_name[14]; | 1138 | char tag_name[14]; |
1091 | unsigned int i_nlink; | 1139 | unsigned int i_nlink; |
@@ -1121,31 +1169,9 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, | |||
1121 | inode->i_nlink = i_nlink; | 1169 | inode->i_nlink = i_nlink; |
1122 | } | 1170 | } |
1123 | } | 1171 | } |
1124 | inode->i_mode = p9mode2unixmode(v9ses, stat->mode); | 1172 | mode = stat->mode & S_IALLUGO; |
1125 | if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode))) { | 1173 | mode |= inode->i_mode & ~S_IALLUGO; |
1126 | char type = 0; | 1174 | inode->i_mode = mode; |
1127 | int major = -1; | ||
1128 | int minor = -1; | ||
1129 | |||
1130 | strncpy(ext, stat->extension, sizeof(ext)); | ||
1131 | sscanf(ext, "%c %u %u", &type, &major, &minor); | ||
1132 | switch (type) { | ||
1133 | case 'c': | ||
1134 | inode->i_mode &= ~S_IFBLK; | ||
1135 | inode->i_mode |= S_IFCHR; | ||
1136 | break; | ||
1137 | case 'b': | ||
1138 | break; | ||
1139 | default: | ||
1140 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
1141 | "Unknown special type %c %s\n", type, | ||
1142 | stat->extension); | ||
1143 | }; | ||
1144 | inode->i_rdev = MKDEV(major, minor); | ||
1145 | init_special_inode(inode, inode->i_mode, inode->i_rdev); | ||
1146 | } else | ||
1147 | inode->i_rdev = 0; | ||
1148 | |||
1149 | i_size_write(inode, stat->length); | 1175 | i_size_write(inode, stat->length); |
1150 | 1176 | ||
1151 | /* not real number of blocks, but 512 byte ones ... */ | 1177 | /* not real number of blocks, but 512 byte ones ... */ |
@@ -1411,6 +1437,8 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) | |||
1411 | 1437 | ||
1412 | int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode) | 1438 | int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode) |
1413 | { | 1439 | { |
1440 | int umode; | ||
1441 | dev_t rdev; | ||
1414 | loff_t i_size; | 1442 | loff_t i_size; |
1415 | struct p9_wstat *st; | 1443 | struct p9_wstat *st; |
1416 | struct v9fs_session_info *v9ses; | 1444 | struct v9fs_session_info *v9ses; |
@@ -1419,6 +1447,12 @@ int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode) | |||
1419 | st = p9_client_stat(fid); | 1447 | st = p9_client_stat(fid); |
1420 | if (IS_ERR(st)) | 1448 | if (IS_ERR(st)) |
1421 | return PTR_ERR(st); | 1449 | return PTR_ERR(st); |
1450 | /* | ||
1451 | * Don't update inode if the file type is different | ||
1452 | */ | ||
1453 | umode = p9mode2unixmode(v9ses, st, &rdev); | ||
1454 | if ((inode->i_mode & S_IFMT) != (umode & S_IFMT)) | ||
1455 | goto out; | ||
1422 | 1456 | ||
1423 | spin_lock(&inode->i_lock); | 1457 | spin_lock(&inode->i_lock); |
1424 | /* | 1458 | /* |
@@ -1430,6 +1464,7 @@ int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode) | |||
1430 | if (v9ses->cache) | 1464 | if (v9ses->cache) |
1431 | inode->i_size = i_size; | 1465 | inode->i_size = i_size; |
1432 | spin_unlock(&inode->i_lock); | 1466 | spin_unlock(&inode->i_lock); |
1467 | out: | ||
1433 | p9stat_free(st); | 1468 | p9stat_free(st); |
1434 | kfree(st); | 1469 | kfree(st); |
1435 | return 0; | 1470 | return 0; |
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index b6c8ed205192..aded79fcd5cf 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c | |||
@@ -153,7 +153,8 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb, | |||
153 | * later. | 153 | * later. |
154 | */ | 154 | */ |
155 | inode->i_ino = i_ino; | 155 | inode->i_ino = i_ino; |
156 | retval = v9fs_init_inode(v9ses, inode, st->st_mode); | 156 | retval = v9fs_init_inode(v9ses, inode, |
157 | st->st_mode, new_decode_dev(st->st_rdev)); | ||
157 | if (retval) | 158 | if (retval) |
158 | goto error; | 159 | goto error; |
159 | 160 | ||
@@ -190,6 +191,58 @@ v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses, struct p9_fid *fid, | |||
190 | return inode; | 191 | return inode; |
191 | } | 192 | } |
192 | 193 | ||
194 | struct dotl_openflag_map { | ||
195 | int open_flag; | ||
196 | int dotl_flag; | ||
197 | }; | ||
198 | |||
199 | static int v9fs_mapped_dotl_flags(int flags) | ||
200 | { | ||
201 | int i; | ||
202 | int rflags = 0; | ||
203 | struct dotl_openflag_map dotl_oflag_map[] = { | ||
204 | { O_CREAT, P9_DOTL_CREATE }, | ||
205 | { O_EXCL, P9_DOTL_EXCL }, | ||
206 | { O_NOCTTY, P9_DOTL_NOCTTY }, | ||
207 | { O_TRUNC, P9_DOTL_TRUNC }, | ||
208 | { O_APPEND, P9_DOTL_APPEND }, | ||
209 | { O_NONBLOCK, P9_DOTL_NONBLOCK }, | ||
210 | { O_DSYNC, P9_DOTL_DSYNC }, | ||
211 | { FASYNC, P9_DOTL_FASYNC }, | ||
212 | { O_DIRECT, P9_DOTL_DIRECT }, | ||
213 | { O_LARGEFILE, P9_DOTL_LARGEFILE }, | ||
214 | { O_DIRECTORY, P9_DOTL_DIRECTORY }, | ||
215 | { O_NOFOLLOW, P9_DOTL_NOFOLLOW }, | ||
216 | { O_NOATIME, P9_DOTL_NOATIME }, | ||
217 | { O_CLOEXEC, P9_DOTL_CLOEXEC }, | ||
218 | { O_SYNC, P9_DOTL_SYNC}, | ||
219 | }; | ||
220 | for (i = 0; i < ARRAY_SIZE(dotl_oflag_map); i++) { | ||
221 | if (flags & dotl_oflag_map[i].open_flag) | ||
222 | rflags |= dotl_oflag_map[i].dotl_flag; | ||
223 | } | ||
224 | return rflags; | ||
225 | } | ||
226 | |||
227 | /** | ||
228 | * v9fs_open_to_dotl_flags- convert Linux specific open flags to | ||
229 | * plan 9 open flag. | ||
230 | * @flags: flags to convert | ||
231 | */ | ||
232 | int v9fs_open_to_dotl_flags(int flags) | ||
233 | { | ||
234 | int rflags = 0; | ||
235 | |||
236 | /* | ||
237 | * We have same bits for P9_DOTL_READONLY, P9_DOTL_WRONLY | ||
238 | * and P9_DOTL_NOACCESS | ||
239 | */ | ||
240 | rflags |= flags & O_ACCMODE; | ||
241 | rflags |= v9fs_mapped_dotl_flags(flags); | ||
242 | |||
243 | return rflags; | ||
244 | } | ||
245 | |||
193 | /** | 246 | /** |
194 | * v9fs_vfs_create_dotl - VFS hook to create files for 9P2000.L protocol. | 247 | * v9fs_vfs_create_dotl - VFS hook to create files for 9P2000.L protocol. |
195 | * @dir: directory inode that is being created | 248 | * @dir: directory inode that is being created |
@@ -258,7 +311,8 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode, | |||
258 | "Failed to get acl values in creat %d\n", err); | 311 | "Failed to get acl values in creat %d\n", err); |
259 | goto error; | 312 | goto error; |
260 | } | 313 | } |
261 | err = p9_client_create_dotl(ofid, name, flags, mode, gid, &qid); | 314 | err = p9_client_create_dotl(ofid, name, v9fs_open_to_dotl_flags(flags), |
315 | mode, gid, &qid); | ||
262 | if (err < 0) { | 316 | if (err < 0) { |
263 | P9_DPRINTK(P9_DEBUG_VFS, | 317 | P9_DPRINTK(P9_DEBUG_VFS, |
264 | "p9_client_open_dotl failed in creat %d\n", | 318 | "p9_client_open_dotl failed in creat %d\n", |
@@ -281,10 +335,10 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode, | |||
281 | P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err); | 335 | P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err); |
282 | goto error; | 336 | goto error; |
283 | } | 337 | } |
284 | d_instantiate(dentry, inode); | ||
285 | err = v9fs_fid_add(dentry, fid); | 338 | err = v9fs_fid_add(dentry, fid); |
286 | if (err < 0) | 339 | if (err < 0) |
287 | goto error; | 340 | goto error; |
341 | d_instantiate(dentry, inode); | ||
288 | 342 | ||
289 | /* Now set the ACL based on the default value */ | 343 | /* Now set the ACL based on the default value */ |
290 | v9fs_set_create_acl(dentry, &dacl, &pacl); | 344 | v9fs_set_create_acl(dentry, &dacl, &pacl); |
@@ -403,10 +457,10 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir, | |||
403 | err); | 457 | err); |
404 | goto error; | 458 | goto error; |
405 | } | 459 | } |
406 | d_instantiate(dentry, inode); | ||
407 | err = v9fs_fid_add(dentry, fid); | 460 | err = v9fs_fid_add(dentry, fid); |
408 | if (err < 0) | 461 | if (err < 0) |
409 | goto error; | 462 | goto error; |
463 | d_instantiate(dentry, inode); | ||
410 | fid = NULL; | 464 | fid = NULL; |
411 | } else { | 465 | } else { |
412 | /* | 466 | /* |
@@ -414,7 +468,7 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir, | |||
414 | * inode with stat. We need to get an inode | 468 | * inode with stat. We need to get an inode |
415 | * so that we can set the acl with dentry | 469 | * so that we can set the acl with dentry |
416 | */ | 470 | */ |
417 | inode = v9fs_get_inode(dir->i_sb, mode); | 471 | inode = v9fs_get_inode(dir->i_sb, mode, 0); |
418 | if (IS_ERR(inode)) { | 472 | if (IS_ERR(inode)) { |
419 | err = PTR_ERR(inode); | 473 | err = PTR_ERR(inode); |
420 | goto error; | 474 | goto error; |
@@ -540,6 +594,7 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr) | |||
540 | void | 594 | void |
541 | v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode) | 595 | v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode) |
542 | { | 596 | { |
597 | mode_t mode; | ||
543 | struct v9fs_inode *v9inode = V9FS_I(inode); | 598 | struct v9fs_inode *v9inode = V9FS_I(inode); |
544 | 599 | ||
545 | if ((stat->st_result_mask & P9_STATS_BASIC) == P9_STATS_BASIC) { | 600 | if ((stat->st_result_mask & P9_STATS_BASIC) == P9_STATS_BASIC) { |
@@ -552,11 +607,10 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode) | |||
552 | inode->i_uid = stat->st_uid; | 607 | inode->i_uid = stat->st_uid; |
553 | inode->i_gid = stat->st_gid; | 608 | inode->i_gid = stat->st_gid; |
554 | inode->i_nlink = stat->st_nlink; | 609 | inode->i_nlink = stat->st_nlink; |
555 | inode->i_mode = stat->st_mode; | ||
556 | inode->i_rdev = new_decode_dev(stat->st_rdev); | ||
557 | 610 | ||
558 | if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode))) | 611 | mode = stat->st_mode & S_IALLUGO; |
559 | init_special_inode(inode, inode->i_mode, inode->i_rdev); | 612 | mode |= inode->i_mode & ~S_IALLUGO; |
613 | inode->i_mode = mode; | ||
560 | 614 | ||
561 | i_size_write(inode, stat->st_size); | 615 | i_size_write(inode, stat->st_size); |
562 | inode->i_blocks = stat->st_blocks; | 616 | inode->i_blocks = stat->st_blocks; |
@@ -657,14 +711,14 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry, | |||
657 | err); | 711 | err); |
658 | goto error; | 712 | goto error; |
659 | } | 713 | } |
660 | d_instantiate(dentry, inode); | ||
661 | err = v9fs_fid_add(dentry, fid); | 714 | err = v9fs_fid_add(dentry, fid); |
662 | if (err < 0) | 715 | if (err < 0) |
663 | goto error; | 716 | goto error; |
717 | d_instantiate(dentry, inode); | ||
664 | fid = NULL; | 718 | fid = NULL; |
665 | } else { | 719 | } else { |
666 | /* Not in cached mode. No need to populate inode with stat */ | 720 | /* Not in cached mode. No need to populate inode with stat */ |
667 | inode = v9fs_get_inode(dir->i_sb, S_IFLNK); | 721 | inode = v9fs_get_inode(dir->i_sb, S_IFLNK, 0); |
668 | if (IS_ERR(inode)) { | 722 | if (IS_ERR(inode)) { |
669 | err = PTR_ERR(inode); | 723 | err = PTR_ERR(inode); |
670 | goto error; | 724 | goto error; |
@@ -810,17 +864,17 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode, | |||
810 | err); | 864 | err); |
811 | goto error; | 865 | goto error; |
812 | } | 866 | } |
813 | d_instantiate(dentry, inode); | ||
814 | err = v9fs_fid_add(dentry, fid); | 867 | err = v9fs_fid_add(dentry, fid); |
815 | if (err < 0) | 868 | if (err < 0) |
816 | goto error; | 869 | goto error; |
870 | d_instantiate(dentry, inode); | ||
817 | fid = NULL; | 871 | fid = NULL; |
818 | } else { | 872 | } else { |
819 | /* | 873 | /* |
820 | * Not in cached mode. No need to populate inode with stat. | 874 | * Not in cached mode. No need to populate inode with stat. |
821 | * socket syscall returns a fd, so we need instantiate | 875 | * socket syscall returns a fd, so we need instantiate |
822 | */ | 876 | */ |
823 | inode = v9fs_get_inode(dir->i_sb, mode); | 877 | inode = v9fs_get_inode(dir->i_sb, mode, rdev); |
824 | if (IS_ERR(inode)) { | 878 | if (IS_ERR(inode)) { |
825 | err = PTR_ERR(inode); | 879 | err = PTR_ERR(inode); |
826 | goto error; | 880 | goto error; |
@@ -886,6 +940,11 @@ int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode) | |||
886 | st = p9_client_getattr_dotl(fid, P9_STATS_ALL); | 940 | st = p9_client_getattr_dotl(fid, P9_STATS_ALL); |
887 | if (IS_ERR(st)) | 941 | if (IS_ERR(st)) |
888 | return PTR_ERR(st); | 942 | return PTR_ERR(st); |
943 | /* | ||
944 | * Don't update inode if the file type is different | ||
945 | */ | ||
946 | if ((inode->i_mode & S_IFMT) != (st->st_mode & S_IFMT)) | ||
947 | goto out; | ||
889 | 948 | ||
890 | spin_lock(&inode->i_lock); | 949 | spin_lock(&inode->i_lock); |
891 | /* | 950 | /* |
@@ -897,6 +956,7 @@ int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode) | |||
897 | if (v9ses->cache) | 956 | if (v9ses->cache) |
898 | inode->i_size = i_size; | 957 | inode->i_size = i_size; |
899 | spin_unlock(&inode->i_lock); | 958 | spin_unlock(&inode->i_lock); |
959 | out: | ||
900 | kfree(st); | 960 | kfree(st); |
901 | return 0; | 961 | return 0; |
902 | } | 962 | } |
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index feef6cdc1fd2..c70251d47ed1 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c | |||
@@ -149,7 +149,7 @@ static struct dentry *v9fs_mount(struct file_system_type *fs_type, int flags, | |||
149 | else | 149 | else |
150 | sb->s_d_op = &v9fs_dentry_operations; | 150 | sb->s_d_op = &v9fs_dentry_operations; |
151 | 151 | ||
152 | inode = v9fs_get_inode(sb, S_IFDIR | mode); | 152 | inode = v9fs_get_inode(sb, S_IFDIR | mode, 0); |
153 | if (IS_ERR(inode)) { | 153 | if (IS_ERR(inode)) { |
154 | retval = PTR_ERR(inode); | 154 | retval = PTR_ERR(inode); |
155 | goto release_sb; | 155 | goto release_sb; |
diff --git a/fs/block_dev.c b/fs/block_dev.c index ff77262e887c..95f786ec7f08 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -1429,6 +1429,11 @@ static int __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) | |||
1429 | WARN_ON_ONCE(bdev->bd_holders); | 1429 | WARN_ON_ONCE(bdev->bd_holders); |
1430 | sync_blockdev(bdev); | 1430 | sync_blockdev(bdev); |
1431 | kill_bdev(bdev); | 1431 | kill_bdev(bdev); |
1432 | /* ->release can cause the old bdi to disappear, | ||
1433 | * so must switch it out first | ||
1434 | */ | ||
1435 | bdev_inode_switch_bdi(bdev->bd_inode, | ||
1436 | &default_backing_dev_info); | ||
1432 | } | 1437 | } |
1433 | if (bdev->bd_contains == bdev) { | 1438 | if (bdev->bd_contains == bdev) { |
1434 | if (disk->fops->release) | 1439 | if (disk->fops->release) |
@@ -1442,8 +1447,6 @@ static int __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) | |||
1442 | disk_put_part(bdev->bd_part); | 1447 | disk_put_part(bdev->bd_part); |
1443 | bdev->bd_part = NULL; | 1448 | bdev->bd_part = NULL; |
1444 | bdev->bd_disk = NULL; | 1449 | bdev->bd_disk = NULL; |
1445 | bdev_inode_switch_bdi(bdev->bd_inode, | ||
1446 | &default_backing_dev_info); | ||
1447 | if (bdev != bdev->bd_contains) | 1450 | if (bdev != bdev->bd_contains) |
1448 | victim = bdev->bd_contains; | 1451 | victim = bdev->bd_contains; |
1449 | bdev->bd_contains = NULL; | 1452 | bdev->bd_contains = NULL; |
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index 502b9e988679..d9f99a16edd6 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h | |||
@@ -176,7 +176,11 @@ static inline u64 btrfs_ino(struct inode *inode) | |||
176 | { | 176 | { |
177 | u64 ino = BTRFS_I(inode)->location.objectid; | 177 | u64 ino = BTRFS_I(inode)->location.objectid; |
178 | 178 | ||
179 | if (ino <= BTRFS_FIRST_FREE_OBJECTID) | 179 | /* |
180 | * !ino: btree_inode | ||
181 | * type == BTRFS_ROOT_ITEM_KEY: subvol dir | ||
182 | */ | ||
183 | if (!ino || BTRFS_I(inode)->location.type == BTRFS_ROOT_ITEM_KEY) | ||
180 | ino = inode->i_ino; | 184 | ino = inode->i_ino; |
181 | return ino; | 185 | return ino; |
182 | } | 186 | } |
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index b910694f61ed..a1cb7821becd 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c | |||
@@ -183,8 +183,10 @@ static int __btrfs_lookup_bio_sums(struct btrfs_root *root, | |||
183 | * read from the commit root and sidestep a nasty deadlock | 183 | * read from the commit root and sidestep a nasty deadlock |
184 | * between reading the free space cache and updating the csum tree. | 184 | * between reading the free space cache and updating the csum tree. |
185 | */ | 185 | */ |
186 | if (btrfs_is_free_space_inode(root, inode)) | 186 | if (btrfs_is_free_space_inode(root, inode)) { |
187 | path->search_commit_root = 1; | 187 | path->search_commit_root = 1; |
188 | path->skip_locking = 1; | ||
189 | } | ||
188 | 190 | ||
189 | disk_bytenr = (u64)bio->bi_sector << 9; | 191 | disk_bytenr = (u64)bio->bi_sector << 9; |
190 | if (dio) | 192 | if (dio) |
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index e7872e485f13..3c3abff731a7 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -1075,12 +1075,6 @@ static noinline int prepare_pages(struct btrfs_root *root, struct file *file, | |||
1075 | start_pos = pos & ~((u64)root->sectorsize - 1); | 1075 | start_pos = pos & ~((u64)root->sectorsize - 1); |
1076 | last_pos = ((u64)index + num_pages) << PAGE_CACHE_SHIFT; | 1076 | last_pos = ((u64)index + num_pages) << PAGE_CACHE_SHIFT; |
1077 | 1077 | ||
1078 | if (start_pos > inode->i_size) { | ||
1079 | err = btrfs_cont_expand(inode, i_size_read(inode), start_pos); | ||
1080 | if (err) | ||
1081 | return err; | ||
1082 | } | ||
1083 | |||
1084 | again: | 1078 | again: |
1085 | for (i = 0; i < num_pages; i++) { | 1079 | for (i = 0; i < num_pages; i++) { |
1086 | pages[i] = find_or_create_page(inode->i_mapping, index + i, | 1080 | pages[i] = find_or_create_page(inode->i_mapping, index + i, |
@@ -1338,6 +1332,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, | |||
1338 | struct inode *inode = fdentry(file)->d_inode; | 1332 | struct inode *inode = fdentry(file)->d_inode; |
1339 | struct btrfs_root *root = BTRFS_I(inode)->root; | 1333 | struct btrfs_root *root = BTRFS_I(inode)->root; |
1340 | loff_t *ppos = &iocb->ki_pos; | 1334 | loff_t *ppos = &iocb->ki_pos; |
1335 | u64 start_pos; | ||
1341 | ssize_t num_written = 0; | 1336 | ssize_t num_written = 0; |
1342 | ssize_t err = 0; | 1337 | ssize_t err = 0; |
1343 | size_t count, ocount; | 1338 | size_t count, ocount; |
@@ -1386,6 +1381,15 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, | |||
1386 | file_update_time(file); | 1381 | file_update_time(file); |
1387 | BTRFS_I(inode)->sequence++; | 1382 | BTRFS_I(inode)->sequence++; |
1388 | 1383 | ||
1384 | start_pos = round_down(pos, root->sectorsize); | ||
1385 | if (start_pos > i_size_read(inode)) { | ||
1386 | err = btrfs_cont_expand(inode, i_size_read(inode), start_pos); | ||
1387 | if (err) { | ||
1388 | mutex_unlock(&inode->i_mutex); | ||
1389 | goto out; | ||
1390 | } | ||
1391 | } | ||
1392 | |||
1389 | if (unlikely(file->f_flags & O_DIRECT)) { | 1393 | if (unlikely(file->f_flags & O_DIRECT)) { |
1390 | num_written = __btrfs_direct_write(iocb, iov, nr_segs, | 1394 | num_written = __btrfs_direct_write(iocb, iov, nr_segs, |
1391 | pos, ppos, count, ocount); | 1395 | pos, ppos, count, ocount); |
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 6a265b9f85f2..41ac927401d0 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c | |||
@@ -190,9 +190,11 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root, | |||
190 | struct btrfs_path *path, | 190 | struct btrfs_path *path, |
191 | struct inode *inode) | 191 | struct inode *inode) |
192 | { | 192 | { |
193 | struct btrfs_block_rsv *rsv; | ||
193 | loff_t oldsize; | 194 | loff_t oldsize; |
194 | int ret = 0; | 195 | int ret = 0; |
195 | 196 | ||
197 | rsv = trans->block_rsv; | ||
196 | trans->block_rsv = root->orphan_block_rsv; | 198 | trans->block_rsv = root->orphan_block_rsv; |
197 | ret = btrfs_block_rsv_check(trans, root, | 199 | ret = btrfs_block_rsv_check(trans, root, |
198 | root->orphan_block_rsv, | 200 | root->orphan_block_rsv, |
@@ -210,6 +212,8 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root, | |||
210 | */ | 212 | */ |
211 | ret = btrfs_truncate_inode_items(trans, root, inode, | 213 | ret = btrfs_truncate_inode_items(trans, root, inode, |
212 | 0, BTRFS_EXTENT_DATA_KEY); | 214 | 0, BTRFS_EXTENT_DATA_KEY); |
215 | |||
216 | trans->block_rsv = rsv; | ||
213 | if (ret) { | 217 | if (ret) { |
214 | WARN_ON(1); | 218 | WARN_ON(1); |
215 | return ret; | 219 | return ret; |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 0ccc7438ad34..4d14de6d121b 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -1786,7 +1786,7 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) | |||
1786 | &ordered_extent->list); | 1786 | &ordered_extent->list); |
1787 | 1787 | ||
1788 | ret = btrfs_ordered_update_i_size(inode, 0, ordered_extent); | 1788 | ret = btrfs_ordered_update_i_size(inode, 0, ordered_extent); |
1789 | if (!ret) { | 1789 | if (!ret || !test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) { |
1790 | ret = btrfs_update_inode(trans, root, inode); | 1790 | ret = btrfs_update_inode(trans, root, inode); |
1791 | BUG_ON(ret); | 1791 | BUG_ON(ret); |
1792 | } | 1792 | } |
@@ -3510,15 +3510,19 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size) | |||
3510 | err = btrfs_drop_extents(trans, inode, cur_offset, | 3510 | err = btrfs_drop_extents(trans, inode, cur_offset, |
3511 | cur_offset + hole_size, | 3511 | cur_offset + hole_size, |
3512 | &hint_byte, 1); | 3512 | &hint_byte, 1); |
3513 | if (err) | 3513 | if (err) { |
3514 | btrfs_end_transaction(trans, root); | ||
3514 | break; | 3515 | break; |
3516 | } | ||
3515 | 3517 | ||
3516 | err = btrfs_insert_file_extent(trans, root, | 3518 | err = btrfs_insert_file_extent(trans, root, |
3517 | btrfs_ino(inode), cur_offset, 0, | 3519 | btrfs_ino(inode), cur_offset, 0, |
3518 | 0, hole_size, 0, hole_size, | 3520 | 0, hole_size, 0, hole_size, |
3519 | 0, 0, 0); | 3521 | 0, 0, 0); |
3520 | if (err) | 3522 | if (err) { |
3523 | btrfs_end_transaction(trans, root); | ||
3521 | break; | 3524 | break; |
3525 | } | ||
3522 | 3526 | ||
3523 | btrfs_drop_extent_cache(inode, hole_start, | 3527 | btrfs_drop_extent_cache(inode, hole_start, |
3524 | last_byte - 1, 0); | 3528 | last_byte - 1, 0); |
@@ -3952,7 +3956,6 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, | |||
3952 | struct btrfs_root *root, int *new) | 3956 | struct btrfs_root *root, int *new) |
3953 | { | 3957 | { |
3954 | struct inode *inode; | 3958 | struct inode *inode; |
3955 | int bad_inode = 0; | ||
3956 | 3959 | ||
3957 | inode = btrfs_iget_locked(s, location->objectid, root); | 3960 | inode = btrfs_iget_locked(s, location->objectid, root); |
3958 | if (!inode) | 3961 | if (!inode) |
@@ -3968,15 +3971,12 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, | |||
3968 | if (new) | 3971 | if (new) |
3969 | *new = 1; | 3972 | *new = 1; |
3970 | } else { | 3973 | } else { |
3971 | bad_inode = 1; | 3974 | unlock_new_inode(inode); |
3975 | iput(inode); | ||
3976 | inode = ERR_PTR(-ESTALE); | ||
3972 | } | 3977 | } |
3973 | } | 3978 | } |
3974 | 3979 | ||
3975 | if (bad_inode) { | ||
3976 | iput(inode); | ||
3977 | inode = ERR_PTR(-ESTALE); | ||
3978 | } | ||
3979 | |||
3980 | return inode; | 3980 | return inode; |
3981 | } | 3981 | } |
3982 | 3982 | ||
@@ -5823,7 +5823,7 @@ again: | |||
5823 | 5823 | ||
5824 | add_pending_csums(trans, inode, ordered->file_offset, &ordered->list); | 5824 | add_pending_csums(trans, inode, ordered->file_offset, &ordered->list); |
5825 | ret = btrfs_ordered_update_i_size(inode, 0, ordered); | 5825 | ret = btrfs_ordered_update_i_size(inode, 0, ordered); |
5826 | if (!ret) | 5826 | if (!ret || !test_bit(BTRFS_ORDERED_PREALLOC, &ordered->flags)) |
5827 | btrfs_update_inode(trans, root, inode); | 5827 | btrfs_update_inode(trans, root, inode); |
5828 | ret = 0; | 5828 | ret = 0; |
5829 | out_unlock: | 5829 | out_unlock: |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 970977aab224..3351b1b24574 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -2220,6 +2220,12 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2220 | !IS_ALIGNED(destoff, bs)) | 2220 | !IS_ALIGNED(destoff, bs)) |
2221 | goto out_unlock; | 2221 | goto out_unlock; |
2222 | 2222 | ||
2223 | if (destoff > inode->i_size) { | ||
2224 | ret = btrfs_cont_expand(inode, inode->i_size, destoff); | ||
2225 | if (ret) | ||
2226 | goto out_unlock; | ||
2227 | } | ||
2228 | |||
2223 | /* do any pending delalloc/csum calc on src, one way or | 2229 | /* do any pending delalloc/csum calc on src, one way or |
2224 | another, and lock file content */ | 2230 | another, and lock file content */ |
2225 | while (1) { | 2231 | while (1) { |
@@ -2325,14 +2331,21 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2325 | 2331 | ||
2326 | if (type == BTRFS_FILE_EXTENT_REG || | 2332 | if (type == BTRFS_FILE_EXTENT_REG || |
2327 | type == BTRFS_FILE_EXTENT_PREALLOC) { | 2333 | type == BTRFS_FILE_EXTENT_PREALLOC) { |
2334 | /* | ||
2335 | * a | --- range to clone ---| b | ||
2336 | * | ------------- extent ------------- | | ||
2337 | */ | ||
2338 | |||
2339 | /* substract range b */ | ||
2340 | if (key.offset + datal > off + len) | ||
2341 | datal = off + len - key.offset; | ||
2342 | |||
2343 | /* substract range a */ | ||
2328 | if (off > key.offset) { | 2344 | if (off > key.offset) { |
2329 | datao += off - key.offset; | 2345 | datao += off - key.offset; |
2330 | datal -= off - key.offset; | 2346 | datal -= off - key.offset; |
2331 | } | 2347 | } |
2332 | 2348 | ||
2333 | if (key.offset + datal > off + len) | ||
2334 | datal = off + len - key.offset; | ||
2335 | |||
2336 | ret = btrfs_drop_extents(trans, inode, | 2349 | ret = btrfs_drop_extents(trans, inode, |
2337 | new_key.offset, | 2350 | new_key.offset, |
2338 | new_key.offset + datal, | 2351 | new_key.offset + datal, |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 7dc36fab4afc..e24b7964a155 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -884,6 +884,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, | |||
884 | struct btrfs_root *tree_root = fs_info->tree_root; | 884 | struct btrfs_root *tree_root = fs_info->tree_root; |
885 | struct btrfs_root *root = pending->root; | 885 | struct btrfs_root *root = pending->root; |
886 | struct btrfs_root *parent_root; | 886 | struct btrfs_root *parent_root; |
887 | struct btrfs_block_rsv *rsv; | ||
887 | struct inode *parent_inode; | 888 | struct inode *parent_inode; |
888 | struct dentry *parent; | 889 | struct dentry *parent; |
889 | struct dentry *dentry; | 890 | struct dentry *dentry; |
@@ -895,6 +896,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, | |||
895 | u64 objectid; | 896 | u64 objectid; |
896 | u64 root_flags; | 897 | u64 root_flags; |
897 | 898 | ||
899 | rsv = trans->block_rsv; | ||
900 | |||
898 | new_root_item = kmalloc(sizeof(*new_root_item), GFP_NOFS); | 901 | new_root_item = kmalloc(sizeof(*new_root_item), GFP_NOFS); |
899 | if (!new_root_item) { | 902 | if (!new_root_item) { |
900 | pending->error = -ENOMEM; | 903 | pending->error = -ENOMEM; |
@@ -1002,6 +1005,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, | |||
1002 | btrfs_orphan_post_snapshot(trans, pending); | 1005 | btrfs_orphan_post_snapshot(trans, pending); |
1003 | fail: | 1006 | fail: |
1004 | kfree(new_root_item); | 1007 | kfree(new_root_item); |
1008 | trans->block_rsv = rsv; | ||
1005 | btrfs_block_rsv_release(root, &pending->block_rsv, (u64)-1); | 1009 | btrfs_block_rsv_release(root, &pending->block_rsv, (u64)-1); |
1006 | return 0; | 1010 | return 0; |
1007 | } | 1011 | } |
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index d733b9cfea34..69565e5fc6a0 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c | |||
@@ -116,6 +116,12 @@ static int do_setxattr(struct btrfs_trans_handle *trans, | |||
116 | if (ret) | 116 | if (ret) |
117 | goto out; | 117 | goto out; |
118 | btrfs_release_path(path); | 118 | btrfs_release_path(path); |
119 | |||
120 | /* | ||
121 | * remove the attribute | ||
122 | */ | ||
123 | if (!value) | ||
124 | goto out; | ||
119 | } | 125 | } |
120 | 126 | ||
121 | again: | 127 | again: |
@@ -158,6 +164,9 @@ out: | |||
158 | return ret; | 164 | return ret; |
159 | } | 165 | } |
160 | 166 | ||
167 | /* | ||
168 | * @value: "" makes the attribute to empty, NULL removes it | ||
169 | */ | ||
161 | int __btrfs_setxattr(struct btrfs_trans_handle *trans, | 170 | int __btrfs_setxattr(struct btrfs_trans_handle *trans, |
162 | struct inode *inode, const char *name, | 171 | struct inode *inode, const char *name, |
163 | const void *value, size_t size, int flags) | 172 | const void *value, size_t size, int flags) |
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index fee028b5332e..86c59e16ba74 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -1595,7 +1595,7 @@ static int set_request_path_attr(struct inode *rinode, struct dentry *rdentry, | |||
1595 | r = build_dentry_path(rdentry, ppath, pathlen, ino, freepath); | 1595 | r = build_dentry_path(rdentry, ppath, pathlen, ino, freepath); |
1596 | dout(" dentry %p %llx/%.*s\n", rdentry, *ino, *pathlen, | 1596 | dout(" dentry %p %llx/%.*s\n", rdentry, *ino, *pathlen, |
1597 | *ppath); | 1597 | *ppath); |
1598 | } else if (rpath) { | 1598 | } else if (rpath || rino) { |
1599 | *ino = rino; | 1599 | *ino = rino; |
1600 | *ppath = rpath; | 1600 | *ppath = rpath; |
1601 | *pathlen = strlen(rpath); | 1601 | *pathlen = strlen(rpath); |
diff --git a/fs/ceph/super.c b/fs/ceph/super.c index d47c5ec7fb1f..88bacaf385d9 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c | |||
@@ -813,8 +813,8 @@ static struct dentry *ceph_mount(struct file_system_type *fs_type, | |||
813 | fsc = create_fs_client(fsopt, opt); | 813 | fsc = create_fs_client(fsopt, opt); |
814 | if (IS_ERR(fsc)) { | 814 | if (IS_ERR(fsc)) { |
815 | res = ERR_CAST(fsc); | 815 | res = ERR_CAST(fsc); |
816 | kfree(fsopt); | 816 | destroy_mount_options(fsopt); |
817 | kfree(opt); | 817 | ceph_destroy_options(opt); |
818 | goto out_final; | 818 | goto out_final; |
819 | } | 819 | } |
820 | 820 | ||
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index e717dfd2f2b4..b7d7bd0f066e 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -175,6 +175,7 @@ struct mpage_da_data { | |||
175 | */ | 175 | */ |
176 | #define EXT4_IO_END_UNWRITTEN 0x0001 | 176 | #define EXT4_IO_END_UNWRITTEN 0x0001 |
177 | #define EXT4_IO_END_ERROR 0x0002 | 177 | #define EXT4_IO_END_ERROR 0x0002 |
178 | #define EXT4_IO_END_QUEUED 0x0004 | ||
178 | 179 | ||
179 | struct ext4_io_page { | 180 | struct ext4_io_page { |
180 | struct page *p_page; | 181 | struct page *p_page; |
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index c4da98a959ae..18d2558b7624 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -121,9 +121,6 @@ void ext4_evict_inode(struct inode *inode) | |||
121 | 121 | ||
122 | trace_ext4_evict_inode(inode); | 122 | trace_ext4_evict_inode(inode); |
123 | 123 | ||
124 | mutex_lock(&inode->i_mutex); | ||
125 | ext4_flush_completed_IO(inode); | ||
126 | mutex_unlock(&inode->i_mutex); | ||
127 | ext4_ioend_wait(inode); | 124 | ext4_ioend_wait(inode); |
128 | 125 | ||
129 | if (inode->i_nlink) { | 126 | if (inode->i_nlink) { |
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index 78839af7ce29..92f38ee13f8a 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c | |||
@@ -142,7 +142,23 @@ static void ext4_end_io_work(struct work_struct *work) | |||
142 | unsigned long flags; | 142 | unsigned long flags; |
143 | int ret; | 143 | int ret; |
144 | 144 | ||
145 | mutex_lock(&inode->i_mutex); | 145 | if (!mutex_trylock(&inode->i_mutex)) { |
146 | /* | ||
147 | * Requeue the work instead of waiting so that the work | ||
148 | * items queued after this can be processed. | ||
149 | */ | ||
150 | queue_work(EXT4_SB(inode->i_sb)->dio_unwritten_wq, &io->work); | ||
151 | /* | ||
152 | * To prevent the ext4-dio-unwritten thread from keeping | ||
153 | * requeueing end_io requests and occupying cpu for too long, | ||
154 | * yield the cpu if it sees an end_io request that has already | ||
155 | * been requeued. | ||
156 | */ | ||
157 | if (io->flag & EXT4_IO_END_QUEUED) | ||
158 | yield(); | ||
159 | io->flag |= EXT4_IO_END_QUEUED; | ||
160 | return; | ||
161 | } | ||
146 | ret = ext4_end_io_nolock(io); | 162 | ret = ext4_end_io_nolock(io); |
147 | if (ret < 0) { | 163 | if (ret < 0) { |
148 | mutex_unlock(&inode->i_mutex); | 164 | mutex_unlock(&inode->i_mutex); |
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 168a80f7f12b..5cb8614508c3 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c | |||
@@ -258,10 +258,14 @@ void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget, | |||
258 | forget->forget_one.nlookup = nlookup; | 258 | forget->forget_one.nlookup = nlookup; |
259 | 259 | ||
260 | spin_lock(&fc->lock); | 260 | spin_lock(&fc->lock); |
261 | fc->forget_list_tail->next = forget; | 261 | if (fc->connected) { |
262 | fc->forget_list_tail = forget; | 262 | fc->forget_list_tail->next = forget; |
263 | wake_up(&fc->waitq); | 263 | fc->forget_list_tail = forget; |
264 | kill_fasync(&fc->fasync, SIGIO, POLL_IN); | 264 | wake_up(&fc->waitq); |
265 | kill_fasync(&fc->fasync, SIGIO, POLL_IN); | ||
266 | } else { | ||
267 | kfree(forget); | ||
268 | } | ||
265 | spin_unlock(&fc->lock); | 269 | spin_unlock(&fc->lock); |
266 | } | 270 | } |
267 | 271 | ||
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 12b502929da9..add96f6ffda5 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
@@ -812,6 +812,9 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) | |||
812 | if (arg->minor >= 17) { | 812 | if (arg->minor >= 17) { |
813 | if (!(arg->flags & FUSE_FLOCK_LOCKS)) | 813 | if (!(arg->flags & FUSE_FLOCK_LOCKS)) |
814 | fc->no_flock = 1; | 814 | fc->no_flock = 1; |
815 | } else { | ||
816 | if (!(arg->flags & FUSE_POSIX_LOCKS)) | ||
817 | fc->no_flock = 1; | ||
815 | } | 818 | } |
816 | if (arg->flags & FUSE_ATOMIC_O_TRUNC) | 819 | if (arg->flags & FUSE_ATOMIC_O_TRUNC) |
817 | fc->atomic_o_trunc = 1; | 820 | fc->atomic_o_trunc = 1; |
diff --git a/fs/namei.c b/fs/namei.c index 2826db35dc25..b52bc685465f 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -727,25 +727,22 @@ static int follow_automount(struct path *path, unsigned flags, | |||
727 | if ((flags & LOOKUP_NO_AUTOMOUNT) && !(flags & LOOKUP_PARENT)) | 727 | if ((flags & LOOKUP_NO_AUTOMOUNT) && !(flags & LOOKUP_PARENT)) |
728 | return -EISDIR; /* we actually want to stop here */ | 728 | return -EISDIR; /* we actually want to stop here */ |
729 | 729 | ||
730 | /* | 730 | /* We don't want to mount if someone's just doing a stat - |
731 | * We don't want to mount if someone's just doing a stat and they've | 731 | * unless they're stat'ing a directory and appended a '/' to |
732 | * set AT_SYMLINK_NOFOLLOW - unless they're stat'ing a directory and | 732 | * the name. |
733 | * appended a '/' to the name. | 733 | * |
734 | * We do, however, want to mount if someone wants to open or | ||
735 | * create a file of any type under the mountpoint, wants to | ||
736 | * traverse through the mountpoint or wants to open the | ||
737 | * mounted directory. Also, autofs may mark negative dentries | ||
738 | * as being automount points. These will need the attentions | ||
739 | * of the daemon to instantiate them before they can be used. | ||
734 | */ | 740 | */ |
735 | if (!(flags & LOOKUP_FOLLOW)) { | 741 | if (!(flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY | |
736 | /* We do, however, want to mount if someone wants to open or | 742 | LOOKUP_OPEN | LOOKUP_CREATE)) && |
737 | * create a file of any type under the mountpoint, wants to | 743 | path->dentry->d_inode) |
738 | * traverse through the mountpoint or wants to open the mounted | 744 | return -EISDIR; |
739 | * directory. | 745 | |
740 | * Also, autofs may mark negative dentries as being automount | ||
741 | * points. These will need the attentions of the daemon to | ||
742 | * instantiate them before they can be used. | ||
743 | */ | ||
744 | if (!(flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY | | ||
745 | LOOKUP_OPEN | LOOKUP_CREATE)) && | ||
746 | path->dentry->d_inode) | ||
747 | return -EISDIR; | ||
748 | } | ||
749 | current->total_link_count++; | 746 | current->total_link_count++; |
750 | if (current->total_link_count >= 40) | 747 | if (current->total_link_count >= 40) |
751 | return -ELOOP; | 748 | return -ELOOP; |
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h index 45174b534377..feb361e252ac 100644 --- a/fs/ubifs/debug.h +++ b/fs/ubifs/debug.h | |||
@@ -335,9 +335,9 @@ void dbg_debugfs_exit_fs(struct ubifs_info *c); | |||
335 | #define DBGKEY(key) ((char *)(key)) | 335 | #define DBGKEY(key) ((char *)(key)) |
336 | #define DBGKEY1(key) ((char *)(key)) | 336 | #define DBGKEY1(key) ((char *)(key)) |
337 | 337 | ||
338 | #define ubifs_dbg_msg(fmt, ...) do { \ | 338 | #define ubifs_dbg_msg(fmt, ...) do { \ |
339 | if (0) \ | 339 | if (0) \ |
340 | pr_debug(fmt "\n", ##__VA_ARGS__); \ | 340 | printk(KERN_DEBUG fmt "\n", ##__VA_ARGS__); \ |
341 | } while (0) | 341 | } while (0) |
342 | 342 | ||
343 | #define dbg_dump_stack() | 343 | #define dbg_dump_stack() |
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index b9c172b3fbbe..673704fab748 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c | |||
@@ -70,9 +70,8 @@ xfs_synchronize_times( | |||
70 | } | 70 | } |
71 | 71 | ||
72 | /* | 72 | /* |
73 | * If the linux inode is valid, mark it dirty. | 73 | * If the linux inode is valid, mark it dirty, else mark the dirty state |
74 | * Used when committing a dirty inode into a transaction so that | 74 | * in the XFS inode to make sure we pick it up when reclaiming the inode. |
75 | * the inode will get written back by the linux code | ||
76 | */ | 75 | */ |
77 | void | 76 | void |
78 | xfs_mark_inode_dirty_sync( | 77 | xfs_mark_inode_dirty_sync( |
@@ -82,6 +81,10 @@ xfs_mark_inode_dirty_sync( | |||
82 | 81 | ||
83 | if (!(inode->i_state & (I_WILL_FREE|I_FREEING))) | 82 | if (!(inode->i_state & (I_WILL_FREE|I_FREEING))) |
84 | mark_inode_dirty_sync(inode); | 83 | mark_inode_dirty_sync(inode); |
84 | else { | ||
85 | barrier(); | ||
86 | ip->i_update_core = 1; | ||
87 | } | ||
85 | } | 88 | } |
86 | 89 | ||
87 | void | 90 | void |
@@ -92,6 +95,11 @@ xfs_mark_inode_dirty( | |||
92 | 95 | ||
93 | if (!(inode->i_state & (I_WILL_FREE|I_FREEING))) | 96 | if (!(inode->i_state & (I_WILL_FREE|I_FREEING))) |
94 | mark_inode_dirty(inode); | 97 | mark_inode_dirty(inode); |
98 | else { | ||
99 | barrier(); | ||
100 | ip->i_update_core = 1; | ||
101 | } | ||
102 | |||
95 | } | 103 | } |
96 | 104 | ||
97 | /* | 105 | /* |
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 9a72dda58bd0..2366c54cc4fa 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c | |||
@@ -356,6 +356,8 @@ xfs_parseargs( | |||
356 | mp->m_flags |= XFS_MOUNT_DELAYLOG; | 356 | mp->m_flags |= XFS_MOUNT_DELAYLOG; |
357 | } else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) { | 357 | } else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) { |
358 | mp->m_flags &= ~XFS_MOUNT_DELAYLOG; | 358 | mp->m_flags &= ~XFS_MOUNT_DELAYLOG; |
359 | xfs_warn(mp, | ||
360 | "nodelaylog is deprecated and will be removed in Linux 3.3"); | ||
359 | } else if (!strcmp(this_char, MNTOPT_DISCARD)) { | 361 | } else if (!strcmp(this_char, MNTOPT_DISCARD)) { |
360 | mp->m_flags |= XFS_MOUNT_DISCARD; | 362 | mp->m_flags |= XFS_MOUNT_DISCARD; |
361 | } else if (!strcmp(this_char, MNTOPT_NODISCARD)) { | 363 | } else if (!strcmp(this_char, MNTOPT_NODISCARD)) { |
@@ -877,33 +879,17 @@ xfs_log_inode( | |||
877 | struct xfs_trans *tp; | 879 | struct xfs_trans *tp; |
878 | int error; | 880 | int error; |
879 | 881 | ||
880 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | ||
881 | tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS); | 882 | tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS); |
882 | error = xfs_trans_reserve(tp, 0, XFS_FSYNC_TS_LOG_RES(mp), 0, 0, 0); | 883 | error = xfs_trans_reserve(tp, 0, XFS_FSYNC_TS_LOG_RES(mp), 0, 0, 0); |
883 | |||
884 | if (error) { | 884 | if (error) { |
885 | xfs_trans_cancel(tp, 0); | 885 | xfs_trans_cancel(tp, 0); |
886 | /* we need to return with the lock hold shared */ | ||
887 | xfs_ilock(ip, XFS_ILOCK_SHARED); | ||
888 | return error; | 886 | return error; |
889 | } | 887 | } |
890 | 888 | ||
891 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 889 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
892 | 890 | xfs_trans_ijoin_ref(tp, ip, XFS_ILOCK_EXCL); | |
893 | /* | ||
894 | * Note - it's possible that we might have pushed ourselves out of the | ||
895 | * way during trans_reserve which would flush the inode. But there's | ||
896 | * no guarantee that the inode buffer has actually gone out yet (it's | ||
897 | * delwri). Plus the buffer could be pinned anyway if it's part of | ||
898 | * an inode in another recent transaction. So we play it safe and | ||
899 | * fire off the transaction anyway. | ||
900 | */ | ||
901 | xfs_trans_ijoin(tp, ip); | ||
902 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 891 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
903 | error = xfs_trans_commit(tp, 0); | 892 | return xfs_trans_commit(tp, 0); |
904 | xfs_ilock_demote(ip, XFS_ILOCK_EXCL); | ||
905 | |||
906 | return error; | ||
907 | } | 893 | } |
908 | 894 | ||
909 | STATIC int | 895 | STATIC int |
@@ -918,7 +904,9 @@ xfs_fs_write_inode( | |||
918 | trace_xfs_write_inode(ip); | 904 | trace_xfs_write_inode(ip); |
919 | 905 | ||
920 | if (XFS_FORCED_SHUTDOWN(mp)) | 906 | if (XFS_FORCED_SHUTDOWN(mp)) |
921 | return XFS_ERROR(EIO); | 907 | return -XFS_ERROR(EIO); |
908 | if (!ip->i_update_core) | ||
909 | return 0; | ||
922 | 910 | ||
923 | if (wbc->sync_mode == WB_SYNC_ALL) { | 911 | if (wbc->sync_mode == WB_SYNC_ALL) { |
924 | /* | 912 | /* |
@@ -929,12 +917,10 @@ xfs_fs_write_inode( | |||
929 | * of synchronous log foces dramatically. | 917 | * of synchronous log foces dramatically. |
930 | */ | 918 | */ |
931 | xfs_ioend_wait(ip); | 919 | xfs_ioend_wait(ip); |
932 | xfs_ilock(ip, XFS_ILOCK_SHARED); | 920 | error = xfs_log_inode(ip); |
933 | if (ip->i_update_core) { | 921 | if (error) |
934 | error = xfs_log_inode(ip); | 922 | goto out; |
935 | if (error) | 923 | return 0; |
936 | goto out_unlock; | ||
937 | } | ||
938 | } else { | 924 | } else { |
939 | /* | 925 | /* |
940 | * We make this non-blocking if the inode is contended, return | 926 | * We make this non-blocking if the inode is contended, return |
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 245bafdafd5e..c816075c01ce 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h | |||
@@ -944,8 +944,10 @@ extern void perf_pmu_unregister(struct pmu *pmu); | |||
944 | 944 | ||
945 | extern int perf_num_counters(void); | 945 | extern int perf_num_counters(void); |
946 | extern const char *perf_pmu_name(void); | 946 | extern const char *perf_pmu_name(void); |
947 | extern void __perf_event_task_sched_in(struct task_struct *task); | 947 | extern void __perf_event_task_sched_in(struct task_struct *prev, |
948 | extern void __perf_event_task_sched_out(struct task_struct *task, struct task_struct *next); | 948 | struct task_struct *task); |
949 | extern void __perf_event_task_sched_out(struct task_struct *prev, | ||
950 | struct task_struct *next); | ||
949 | extern int perf_event_init_task(struct task_struct *child); | 951 | extern int perf_event_init_task(struct task_struct *child); |
950 | extern void perf_event_exit_task(struct task_struct *child); | 952 | extern void perf_event_exit_task(struct task_struct *child); |
951 | extern void perf_event_free_task(struct task_struct *task); | 953 | extern void perf_event_free_task(struct task_struct *task); |
@@ -1059,17 +1061,20 @@ perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr) | |||
1059 | 1061 | ||
1060 | extern struct jump_label_key perf_sched_events; | 1062 | extern struct jump_label_key perf_sched_events; |
1061 | 1063 | ||
1062 | static inline void perf_event_task_sched_in(struct task_struct *task) | 1064 | static inline void perf_event_task_sched_in(struct task_struct *prev, |
1065 | struct task_struct *task) | ||
1063 | { | 1066 | { |
1064 | if (static_branch(&perf_sched_events)) | 1067 | if (static_branch(&perf_sched_events)) |
1065 | __perf_event_task_sched_in(task); | 1068 | __perf_event_task_sched_in(prev, task); |
1066 | } | 1069 | } |
1067 | 1070 | ||
1068 | static inline void perf_event_task_sched_out(struct task_struct *task, struct task_struct *next) | 1071 | static inline void perf_event_task_sched_out(struct task_struct *prev, |
1072 | struct task_struct *next) | ||
1069 | { | 1073 | { |
1070 | perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, NULL, 0); | 1074 | perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, NULL, 0); |
1071 | 1075 | ||
1072 | __perf_event_task_sched_out(task, next); | 1076 | if (static_branch(&perf_sched_events)) |
1077 | __perf_event_task_sched_out(prev, next); | ||
1073 | } | 1078 | } |
1074 | 1079 | ||
1075 | extern void perf_event_mmap(struct vm_area_struct *vma); | 1080 | extern void perf_event_mmap(struct vm_area_struct *vma); |
@@ -1139,10 +1144,11 @@ extern void perf_event_disable(struct perf_event *event); | |||
1139 | extern void perf_event_task_tick(void); | 1144 | extern void perf_event_task_tick(void); |
1140 | #else | 1145 | #else |
1141 | static inline void | 1146 | static inline void |
1142 | perf_event_task_sched_in(struct task_struct *task) { } | 1147 | perf_event_task_sched_in(struct task_struct *prev, |
1148 | struct task_struct *task) { } | ||
1143 | static inline void | 1149 | static inline void |
1144 | perf_event_task_sched_out(struct task_struct *task, | 1150 | perf_event_task_sched_out(struct task_struct *prev, |
1145 | struct task_struct *next) { } | 1151 | struct task_struct *next) { } |
1146 | static inline int perf_event_init_task(struct task_struct *child) { return 0; } | 1152 | static inline int perf_event_init_task(struct task_struct *child) { return 0; } |
1147 | static inline void perf_event_exit_task(struct task_struct *child) { } | 1153 | static inline void perf_event_exit_task(struct task_struct *child) { } |
1148 | static inline void perf_event_free_task(struct task_struct *task) { } | 1154 | static inline void perf_event_free_task(struct task_struct *task) { } |
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index 26f6ea4444e3..b47771aa5718 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h | |||
@@ -123,7 +123,7 @@ struct regulator_bulk_data { | |||
123 | const char *supply; | 123 | const char *supply; |
124 | struct regulator *consumer; | 124 | struct regulator *consumer; |
125 | 125 | ||
126 | /* Internal use */ | 126 | /* private: Internal use */ |
127 | int ret; | 127 | int ret; |
128 | }; | 128 | }; |
129 | 129 | ||
diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h index 342dcf13d039..a6326ef8ade6 100644 --- a/include/net/9p/9p.h +++ b/include/net/9p/9p.h | |||
@@ -288,6 +288,35 @@ enum p9_perm_t { | |||
288 | P9_DMSETVTX = 0x00010000, | 288 | P9_DMSETVTX = 0x00010000, |
289 | }; | 289 | }; |
290 | 290 | ||
291 | /* 9p2000.L open flags */ | ||
292 | #define P9_DOTL_RDONLY 00000000 | ||
293 | #define P9_DOTL_WRONLY 00000001 | ||
294 | #define P9_DOTL_RDWR 00000002 | ||
295 | #define P9_DOTL_NOACCESS 00000003 | ||
296 | #define P9_DOTL_CREATE 00000100 | ||
297 | #define P9_DOTL_EXCL 00000200 | ||
298 | #define P9_DOTL_NOCTTY 00000400 | ||
299 | #define P9_DOTL_TRUNC 00001000 | ||
300 | #define P9_DOTL_APPEND 00002000 | ||
301 | #define P9_DOTL_NONBLOCK 00004000 | ||
302 | #define P9_DOTL_DSYNC 00010000 | ||
303 | #define P9_DOTL_FASYNC 00020000 | ||
304 | #define P9_DOTL_DIRECT 00040000 | ||
305 | #define P9_DOTL_LARGEFILE 00100000 | ||
306 | #define P9_DOTL_DIRECTORY 00200000 | ||
307 | #define P9_DOTL_NOFOLLOW 00400000 | ||
308 | #define P9_DOTL_NOATIME 01000000 | ||
309 | #define P9_DOTL_CLOEXEC 02000000 | ||
310 | #define P9_DOTL_SYNC 04000000 | ||
311 | |||
312 | /* 9p2000.L at flags */ | ||
313 | #define P9_DOTL_AT_REMOVEDIR 0x200 | ||
314 | |||
315 | /* 9p2000.L lock type */ | ||
316 | #define P9_LOCK_TYPE_RDLCK 0 | ||
317 | #define P9_LOCK_TYPE_WRLCK 1 | ||
318 | #define P9_LOCK_TYPE_UNLCK 2 | ||
319 | |||
291 | /** | 320 | /** |
292 | * enum p9_qid_t - QID types | 321 | * enum p9_qid_t - QID types |
293 | * @P9_QTDIR: directory | 322 | * @P9_QTDIR: directory |
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 408ae4882d22..401d73bd151f 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h | |||
@@ -1744,6 +1744,8 @@ struct wiphy_wowlan_support { | |||
1744 | * by default for perm_addr. In this case, the mask should be set to | 1744 | * by default for perm_addr. In this case, the mask should be set to |
1745 | * all-zeroes. In this case it is assumed that the device can handle | 1745 | * all-zeroes. In this case it is assumed that the device can handle |
1746 | * the same number of arbitrary MAC addresses. | 1746 | * the same number of arbitrary MAC addresses. |
1747 | * @registered: protects ->resume and ->suspend sysfs callbacks against | ||
1748 | * unregister hardware | ||
1747 | * @debugfsdir: debugfs directory used for this wiphy, will be renamed | 1749 | * @debugfsdir: debugfs directory used for this wiphy, will be renamed |
1748 | * automatically on wiphy renames | 1750 | * automatically on wiphy renames |
1749 | * @dev: (virtual) struct device for this wiphy | 1751 | * @dev: (virtual) struct device for this wiphy |
diff --git a/kernel/events/core.c b/kernel/events/core.c index 68c8017de969..fbe38f2e8edb 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -399,14 +399,54 @@ void perf_cgroup_switch(struct task_struct *task, int mode) | |||
399 | local_irq_restore(flags); | 399 | local_irq_restore(flags); |
400 | } | 400 | } |
401 | 401 | ||
402 | static inline void perf_cgroup_sched_out(struct task_struct *task) | 402 | static inline void perf_cgroup_sched_out(struct task_struct *task, |
403 | struct task_struct *next) | ||
403 | { | 404 | { |
404 | perf_cgroup_switch(task, PERF_CGROUP_SWOUT); | 405 | struct perf_cgroup *cgrp1; |
406 | struct perf_cgroup *cgrp2 = NULL; | ||
407 | |||
408 | /* | ||
409 | * we come here when we know perf_cgroup_events > 0 | ||
410 | */ | ||
411 | cgrp1 = perf_cgroup_from_task(task); | ||
412 | |||
413 | /* | ||
414 | * next is NULL when called from perf_event_enable_on_exec() | ||
415 | * that will systematically cause a cgroup_switch() | ||
416 | */ | ||
417 | if (next) | ||
418 | cgrp2 = perf_cgroup_from_task(next); | ||
419 | |||
420 | /* | ||
421 | * only schedule out current cgroup events if we know | ||
422 | * that we are switching to a different cgroup. Otherwise, | ||
423 | * do no touch the cgroup events. | ||
424 | */ | ||
425 | if (cgrp1 != cgrp2) | ||
426 | perf_cgroup_switch(task, PERF_CGROUP_SWOUT); | ||
405 | } | 427 | } |
406 | 428 | ||
407 | static inline void perf_cgroup_sched_in(struct task_struct *task) | 429 | static inline void perf_cgroup_sched_in(struct task_struct *prev, |
430 | struct task_struct *task) | ||
408 | { | 431 | { |
409 | perf_cgroup_switch(task, PERF_CGROUP_SWIN); | 432 | struct perf_cgroup *cgrp1; |
433 | struct perf_cgroup *cgrp2 = NULL; | ||
434 | |||
435 | /* | ||
436 | * we come here when we know perf_cgroup_events > 0 | ||
437 | */ | ||
438 | cgrp1 = perf_cgroup_from_task(task); | ||
439 | |||
440 | /* prev can never be NULL */ | ||
441 | cgrp2 = perf_cgroup_from_task(prev); | ||
442 | |||
443 | /* | ||
444 | * only need to schedule in cgroup events if we are changing | ||
445 | * cgroup during ctxsw. Cgroup events were not scheduled | ||
446 | * out of ctxsw out if that was not the case. | ||
447 | */ | ||
448 | if (cgrp1 != cgrp2) | ||
449 | perf_cgroup_switch(task, PERF_CGROUP_SWIN); | ||
410 | } | 450 | } |
411 | 451 | ||
412 | static inline int perf_cgroup_connect(int fd, struct perf_event *event, | 452 | static inline int perf_cgroup_connect(int fd, struct perf_event *event, |
@@ -518,11 +558,13 @@ static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx) | |||
518 | { | 558 | { |
519 | } | 559 | } |
520 | 560 | ||
521 | static inline void perf_cgroup_sched_out(struct task_struct *task) | 561 | static inline void perf_cgroup_sched_out(struct task_struct *task, |
562 | struct task_struct *next) | ||
522 | { | 563 | { |
523 | } | 564 | } |
524 | 565 | ||
525 | static inline void perf_cgroup_sched_in(struct task_struct *task) | 566 | static inline void perf_cgroup_sched_in(struct task_struct *prev, |
567 | struct task_struct *task) | ||
526 | { | 568 | { |
527 | } | 569 | } |
528 | 570 | ||
@@ -1988,7 +2030,7 @@ void __perf_event_task_sched_out(struct task_struct *task, | |||
1988 | * cgroup event are system-wide mode only | 2030 | * cgroup event are system-wide mode only |
1989 | */ | 2031 | */ |
1990 | if (atomic_read(&__get_cpu_var(perf_cgroup_events))) | 2032 | if (atomic_read(&__get_cpu_var(perf_cgroup_events))) |
1991 | perf_cgroup_sched_out(task); | 2033 | perf_cgroup_sched_out(task, next); |
1992 | } | 2034 | } |
1993 | 2035 | ||
1994 | static void task_ctx_sched_out(struct perf_event_context *ctx) | 2036 | static void task_ctx_sched_out(struct perf_event_context *ctx) |
@@ -2153,7 +2195,8 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx, | |||
2153 | * accessing the event control register. If a NMI hits, then it will | 2195 | * accessing the event control register. If a NMI hits, then it will |
2154 | * keep the event running. | 2196 | * keep the event running. |
2155 | */ | 2197 | */ |
2156 | void __perf_event_task_sched_in(struct task_struct *task) | 2198 | void __perf_event_task_sched_in(struct task_struct *prev, |
2199 | struct task_struct *task) | ||
2157 | { | 2200 | { |
2158 | struct perf_event_context *ctx; | 2201 | struct perf_event_context *ctx; |
2159 | int ctxn; | 2202 | int ctxn; |
@@ -2171,7 +2214,7 @@ void __perf_event_task_sched_in(struct task_struct *task) | |||
2171 | * cgroup event are system-wide mode only | 2214 | * cgroup event are system-wide mode only |
2172 | */ | 2215 | */ |
2173 | if (atomic_read(&__get_cpu_var(perf_cgroup_events))) | 2216 | if (atomic_read(&__get_cpu_var(perf_cgroup_events))) |
2174 | perf_cgroup_sched_in(task); | 2217 | perf_cgroup_sched_in(prev, task); |
2175 | } | 2218 | } |
2176 | 2219 | ||
2177 | static u64 perf_calculate_period(struct perf_event *event, u64 nsec, u64 count) | 2220 | static u64 perf_calculate_period(struct perf_event *event, u64 nsec, u64 count) |
@@ -2427,7 +2470,7 @@ static void perf_event_enable_on_exec(struct perf_event_context *ctx) | |||
2427 | * ctxswin cgroup events which are already scheduled | 2470 | * ctxswin cgroup events which are already scheduled |
2428 | * in. | 2471 | * in. |
2429 | */ | 2472 | */ |
2430 | perf_cgroup_sched_out(current); | 2473 | perf_cgroup_sched_out(current, NULL); |
2431 | 2474 | ||
2432 | raw_spin_lock(&ctx->lock); | 2475 | raw_spin_lock(&ctx->lock); |
2433 | task_ctx_sched_out(ctx); | 2476 | task_ctx_sched_out(ctx); |
@@ -3353,8 +3396,8 @@ static int perf_event_index(struct perf_event *event) | |||
3353 | } | 3396 | } |
3354 | 3397 | ||
3355 | static void calc_timer_values(struct perf_event *event, | 3398 | static void calc_timer_values(struct perf_event *event, |
3356 | u64 *running, | 3399 | u64 *enabled, |
3357 | u64 *enabled) | 3400 | u64 *running) |
3358 | { | 3401 | { |
3359 | u64 now, ctx_time; | 3402 | u64 now, ctx_time; |
3360 | 3403 | ||
diff --git a/kernel/sched.c b/kernel/sched.c index ccacdbdecf45..ec5f472bc5b9 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -3065,7 +3065,7 @@ static void finish_task_switch(struct rq *rq, struct task_struct *prev) | |||
3065 | #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW | 3065 | #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW |
3066 | local_irq_disable(); | 3066 | local_irq_disable(); |
3067 | #endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */ | 3067 | #endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */ |
3068 | perf_event_task_sched_in(current); | 3068 | perf_event_task_sched_in(prev, current); |
3069 | #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW | 3069 | #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW |
3070 | local_irq_enable(); | 3070 | local_irq_enable(); |
3071 | #endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */ | 3071 | #endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */ |
@@ -4279,9 +4279,9 @@ pick_next_task(struct rq *rq) | |||
4279 | } | 4279 | } |
4280 | 4280 | ||
4281 | /* | 4281 | /* |
4282 | * schedule() is the main scheduler function. | 4282 | * __schedule() is the main scheduler function. |
4283 | */ | 4283 | */ |
4284 | asmlinkage void __sched schedule(void) | 4284 | static void __sched __schedule(void) |
4285 | { | 4285 | { |
4286 | struct task_struct *prev, *next; | 4286 | struct task_struct *prev, *next; |
4287 | unsigned long *switch_count; | 4287 | unsigned long *switch_count; |
@@ -4322,16 +4322,6 @@ need_resched: | |||
4322 | if (to_wakeup) | 4322 | if (to_wakeup) |
4323 | try_to_wake_up_local(to_wakeup); | 4323 | try_to_wake_up_local(to_wakeup); |
4324 | } | 4324 | } |
4325 | |||
4326 | /* | ||
4327 | * If we are going to sleep and we have plugged IO | ||
4328 | * queued, make sure to submit it to avoid deadlocks. | ||
4329 | */ | ||
4330 | if (blk_needs_flush_plug(prev)) { | ||
4331 | raw_spin_unlock(&rq->lock); | ||
4332 | blk_schedule_flush_plug(prev); | ||
4333 | raw_spin_lock(&rq->lock); | ||
4334 | } | ||
4335 | } | 4325 | } |
4336 | switch_count = &prev->nvcsw; | 4326 | switch_count = &prev->nvcsw; |
4337 | } | 4327 | } |
@@ -4369,6 +4359,26 @@ need_resched: | |||
4369 | if (need_resched()) | 4359 | if (need_resched()) |
4370 | goto need_resched; | 4360 | goto need_resched; |
4371 | } | 4361 | } |
4362 | |||
4363 | static inline void sched_submit_work(struct task_struct *tsk) | ||
4364 | { | ||
4365 | if (!tsk->state) | ||
4366 | return; | ||
4367 | /* | ||
4368 | * If we are going to sleep and we have plugged IO queued, | ||
4369 | * make sure to submit it to avoid deadlocks. | ||
4370 | */ | ||
4371 | if (blk_needs_flush_plug(tsk)) | ||
4372 | blk_schedule_flush_plug(tsk); | ||
4373 | } | ||
4374 | |||
4375 | asmlinkage void schedule(void) | ||
4376 | { | ||
4377 | struct task_struct *tsk = current; | ||
4378 | |||
4379 | sched_submit_work(tsk); | ||
4380 | __schedule(); | ||
4381 | } | ||
4372 | EXPORT_SYMBOL(schedule); | 4382 | EXPORT_SYMBOL(schedule); |
4373 | 4383 | ||
4374 | #ifdef CONFIG_MUTEX_SPIN_ON_OWNER | 4384 | #ifdef CONFIG_MUTEX_SPIN_ON_OWNER |
@@ -4435,7 +4445,7 @@ asmlinkage void __sched notrace preempt_schedule(void) | |||
4435 | 4445 | ||
4436 | do { | 4446 | do { |
4437 | add_preempt_count_notrace(PREEMPT_ACTIVE); | 4447 | add_preempt_count_notrace(PREEMPT_ACTIVE); |
4438 | schedule(); | 4448 | __schedule(); |
4439 | sub_preempt_count_notrace(PREEMPT_ACTIVE); | 4449 | sub_preempt_count_notrace(PREEMPT_ACTIVE); |
4440 | 4450 | ||
4441 | /* | 4451 | /* |
@@ -4463,7 +4473,7 @@ asmlinkage void __sched preempt_schedule_irq(void) | |||
4463 | do { | 4473 | do { |
4464 | add_preempt_count(PREEMPT_ACTIVE); | 4474 | add_preempt_count(PREEMPT_ACTIVE); |
4465 | local_irq_enable(); | 4475 | local_irq_enable(); |
4466 | schedule(); | 4476 | __schedule(); |
4467 | local_irq_disable(); | 4477 | local_irq_disable(); |
4468 | sub_preempt_count(PREEMPT_ACTIVE); | 4478 | sub_preempt_count(PREEMPT_ACTIVE); |
4469 | 4479 | ||
@@ -5588,7 +5598,7 @@ static inline int should_resched(void) | |||
5588 | static void __cond_resched(void) | 5598 | static void __cond_resched(void) |
5589 | { | 5599 | { |
5590 | add_preempt_count(PREEMPT_ACTIVE); | 5600 | add_preempt_count(PREEMPT_ACTIVE); |
5591 | schedule(); | 5601 | __schedule(); |
5592 | sub_preempt_count(PREEMPT_ACTIVE); | 5602 | sub_preempt_count(PREEMPT_ACTIVE); |
5593 | } | 5603 | } |
5594 | 5604 | ||
@@ -7443,6 +7453,7 @@ static void __sdt_free(const struct cpumask *cpu_map) | |||
7443 | struct sched_domain *sd = *per_cpu_ptr(sdd->sd, j); | 7453 | struct sched_domain *sd = *per_cpu_ptr(sdd->sd, j); |
7444 | if (sd && (sd->flags & SD_OVERLAP)) | 7454 | if (sd && (sd->flags & SD_OVERLAP)) |
7445 | free_sched_groups(sd->groups, 0); | 7455 | free_sched_groups(sd->groups, 0); |
7456 | kfree(*per_cpu_ptr(sdd->sd, j)); | ||
7446 | kfree(*per_cpu_ptr(sdd->sg, j)); | 7457 | kfree(*per_cpu_ptr(sdd->sg, j)); |
7447 | kfree(*per_cpu_ptr(sdd->sgp, j)); | 7458 | kfree(*per_cpu_ptr(sdd->sgp, j)); |
7448 | } | 7459 | } |
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 59f369f98a04..ea5e1a928d5b 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c | |||
@@ -441,6 +441,8 @@ static int alarm_timer_create(struct k_itimer *new_timer) | |||
441 | static void alarm_timer_get(struct k_itimer *timr, | 441 | static void alarm_timer_get(struct k_itimer *timr, |
442 | struct itimerspec *cur_setting) | 442 | struct itimerspec *cur_setting) |
443 | { | 443 | { |
444 | memset(cur_setting, 0, sizeof(struct itimerspec)); | ||
445 | |||
444 | cur_setting->it_interval = | 446 | cur_setting->it_interval = |
445 | ktime_to_timespec(timr->it.alarmtimer.period); | 447 | ktime_to_timespec(timr->it.alarmtimer.period); |
446 | cur_setting->it_value = | 448 | cur_setting->it_value = |
@@ -479,11 +481,17 @@ static int alarm_timer_set(struct k_itimer *timr, int flags, | |||
479 | if (!rtcdev) | 481 | if (!rtcdev) |
480 | return -ENOTSUPP; | 482 | return -ENOTSUPP; |
481 | 483 | ||
482 | /* Save old values */ | 484 | /* |
483 | old_setting->it_interval = | 485 | * XXX HACK! Currently we can DOS a system if the interval |
484 | ktime_to_timespec(timr->it.alarmtimer.period); | 486 | * period on alarmtimers is too small. Cap the interval here |
485 | old_setting->it_value = | 487 | * to 100us and solve this properly in a future patch! -jstultz |
486 | ktime_to_timespec(timr->it.alarmtimer.node.expires); | 488 | */ |
489 | if ((new_setting->it_interval.tv_sec == 0) && | ||
490 | (new_setting->it_interval.tv_nsec < 100000)) | ||
491 | new_setting->it_interval.tv_nsec = 100000; | ||
492 | |||
493 | if (old_setting) | ||
494 | alarm_timer_get(timr, old_setting); | ||
487 | 495 | ||
488 | /* If the timer was already set, cancel it */ | 496 | /* If the timer was already set, cancel it */ |
489 | alarm_cancel(&timr->it.alarmtimer); | 497 | alarm_cancel(&timr->it.alarmtimer); |
diff --git a/lib/Makefile b/lib/Makefile index d5d175c8a6ca..3f5bc6d903e0 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
@@ -12,7 +12,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \ | |||
12 | idr.o int_sqrt.o extable.o prio_tree.o \ | 12 | idr.o int_sqrt.o extable.o prio_tree.o \ |
13 | sha1.o md5.o irq_regs.o reciprocal_div.o argv_split.o \ | 13 | sha1.o md5.o irq_regs.o reciprocal_div.o argv_split.o \ |
14 | proportions.o prio_heap.o ratelimit.o show_mem.o \ | 14 | proportions.o prio_heap.o ratelimit.o show_mem.o \ |
15 | is_single_threaded.o plist.o decompress.o find_next_bit.o | 15 | is_single_threaded.o plist.o decompress.o |
16 | 16 | ||
17 | lib-$(CONFIG_MMU) += ioremap.o | 17 | lib-$(CONFIG_MMU) += ioremap.o |
18 | lib-$(CONFIG_SMP) += cpumask.o | 18 | lib-$(CONFIG_SMP) += cpumask.o |
@@ -22,7 +22,7 @@ lib-y += kobject.o kref.o klist.o | |||
22 | obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ | 22 | obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ |
23 | bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ | 23 | bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ |
24 | string_helpers.o gcd.o lcm.o list_sort.o uuid.o flex_array.o \ | 24 | string_helpers.o gcd.o lcm.o list_sort.o uuid.o flex_array.o \ |
25 | bsearch.o find_last_bit.o | 25 | bsearch.o find_last_bit.o find_next_bit.o |
26 | obj-y += kstrtox.o | 26 | obj-y += kstrtox.o |
27 | obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o | 27 | obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o |
28 | 28 | ||
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index 175b5135bdcf..e317583fcc73 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c | |||
@@ -263,7 +263,6 @@ p9_virtio_request(struct p9_client *client, struct p9_req_t *req) | |||
263 | { | 263 | { |
264 | int in, out, inp, outp; | 264 | int in, out, inp, outp; |
265 | struct virtio_chan *chan = client->trans; | 265 | struct virtio_chan *chan = client->trans; |
266 | char *rdata = (char *)req->rc+sizeof(struct p9_fcall); | ||
267 | unsigned long flags; | 266 | unsigned long flags; |
268 | size_t pdata_off = 0; | 267 | size_t pdata_off = 0; |
269 | struct trans_rpage_info *rpinfo = NULL; | 268 | struct trans_rpage_info *rpinfo = NULL; |
@@ -346,7 +345,8 @@ req_retry_pinned: | |||
346 | * Arrange in such a way that server places header in the | 345 | * Arrange in such a way that server places header in the |
347 | * alloced memory and payload onto the user buffer. | 346 | * alloced memory and payload onto the user buffer. |
348 | */ | 347 | */ |
349 | inp = pack_sg_list(chan->sg, out, VIRTQUEUE_NUM, rdata, 11); | 348 | inp = pack_sg_list(chan->sg, out, |
349 | VIRTQUEUE_NUM, req->rc->sdata, 11); | ||
350 | /* | 350 | /* |
351 | * Running executables in the filesystem may result in | 351 | * Running executables in the filesystem may result in |
352 | * a read request with kernel buffer as opposed to user buffer. | 352 | * a read request with kernel buffer as opposed to user buffer. |
@@ -366,8 +366,8 @@ req_retry_pinned: | |||
366 | } | 366 | } |
367 | in += inp; | 367 | in += inp; |
368 | } else { | 368 | } else { |
369 | in = pack_sg_list(chan->sg, out, VIRTQUEUE_NUM, rdata, | 369 | in = pack_sg_list(chan->sg, out, VIRTQUEUE_NUM, |
370 | req->rc->capacity); | 370 | req->rc->sdata, req->rc->capacity); |
371 | } | 371 | } |
372 | 372 | ||
373 | err = virtqueue_add_buf(chan->vq, chan->sg, out, in, req->tc); | 373 | err = virtqueue_add_buf(chan->vq, chan->sg, out, in, req->tc); |
@@ -592,7 +592,14 @@ static struct p9_trans_module p9_virtio_trans = { | |||
592 | .close = p9_virtio_close, | 592 | .close = p9_virtio_close, |
593 | .request = p9_virtio_request, | 593 | .request = p9_virtio_request, |
594 | .cancel = p9_virtio_cancel, | 594 | .cancel = p9_virtio_cancel, |
595 | .maxsize = PAGE_SIZE*VIRTQUEUE_NUM, | 595 | |
596 | /* | ||
597 | * We leave one entry for input and one entry for response | ||
598 | * headers. We also skip one more entry to accomodate, address | ||
599 | * that are not at page boundary, that can result in an extra | ||
600 | * page in zero copy. | ||
601 | */ | ||
602 | .maxsize = PAGE_SIZE * (VIRTQUEUE_NUM - 3), | ||
596 | .pref = P9_TRANS_PREF_PAYLOAD_SEP, | 603 | .pref = P9_TRANS_PREF_PAYLOAD_SEP, |
597 | .def = 0, | 604 | .def = 0, |
598 | .owner = THIS_MODULE, | 605 | .owner = THIS_MODULE, |
diff --git a/net/ceph/msgpool.c b/net/ceph/msgpool.c index d5f2d97ac05c..1f4cb30a42c5 100644 --- a/net/ceph/msgpool.c +++ b/net/ceph/msgpool.c | |||
@@ -7,27 +7,37 @@ | |||
7 | 7 | ||
8 | #include <linux/ceph/msgpool.h> | 8 | #include <linux/ceph/msgpool.h> |
9 | 9 | ||
10 | static void *alloc_fn(gfp_t gfp_mask, void *arg) | 10 | static void *msgpool_alloc(gfp_t gfp_mask, void *arg) |
11 | { | 11 | { |
12 | struct ceph_msgpool *pool = arg; | 12 | struct ceph_msgpool *pool = arg; |
13 | void *p; | 13 | struct ceph_msg *msg; |
14 | 14 | ||
15 | p = ceph_msg_new(0, pool->front_len, gfp_mask); | 15 | msg = ceph_msg_new(0, pool->front_len, gfp_mask); |
16 | if (!p) | 16 | if (!msg) { |
17 | pr_err("msgpool %s alloc failed\n", pool->name); | 17 | dout("msgpool_alloc %s failed\n", pool->name); |
18 | return p; | 18 | } else { |
19 | dout("msgpool_alloc %s %p\n", pool->name, msg); | ||
20 | msg->pool = pool; | ||
21 | } | ||
22 | return msg; | ||
19 | } | 23 | } |
20 | 24 | ||
21 | static void free_fn(void *element, void *arg) | 25 | static void msgpool_free(void *element, void *arg) |
22 | { | 26 | { |
23 | ceph_msg_put(element); | 27 | struct ceph_msgpool *pool = arg; |
28 | struct ceph_msg *msg = element; | ||
29 | |||
30 | dout("msgpool_release %s %p\n", pool->name, msg); | ||
31 | msg->pool = NULL; | ||
32 | ceph_msg_put(msg); | ||
24 | } | 33 | } |
25 | 34 | ||
26 | int ceph_msgpool_init(struct ceph_msgpool *pool, | 35 | int ceph_msgpool_init(struct ceph_msgpool *pool, |
27 | int front_len, int size, bool blocking, const char *name) | 36 | int front_len, int size, bool blocking, const char *name) |
28 | { | 37 | { |
38 | dout("msgpool %s init\n", name); | ||
29 | pool->front_len = front_len; | 39 | pool->front_len = front_len; |
30 | pool->pool = mempool_create(size, alloc_fn, free_fn, pool); | 40 | pool->pool = mempool_create(size, msgpool_alloc, msgpool_free, pool); |
31 | if (!pool->pool) | 41 | if (!pool->pool) |
32 | return -ENOMEM; | 42 | return -ENOMEM; |
33 | pool->name = name; | 43 | pool->name = name; |
@@ -36,14 +46,17 @@ int ceph_msgpool_init(struct ceph_msgpool *pool, | |||
36 | 46 | ||
37 | void ceph_msgpool_destroy(struct ceph_msgpool *pool) | 47 | void ceph_msgpool_destroy(struct ceph_msgpool *pool) |
38 | { | 48 | { |
49 | dout("msgpool %s destroy\n", pool->name); | ||
39 | mempool_destroy(pool->pool); | 50 | mempool_destroy(pool->pool); |
40 | } | 51 | } |
41 | 52 | ||
42 | struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool, | 53 | struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool, |
43 | int front_len) | 54 | int front_len) |
44 | { | 55 | { |
56 | struct ceph_msg *msg; | ||
57 | |||
45 | if (front_len > pool->front_len) { | 58 | if (front_len > pool->front_len) { |
46 | pr_err("msgpool_get pool %s need front %d, pool size is %d\n", | 59 | dout("msgpool_get %s need front %d, pool size is %d\n", |
47 | pool->name, front_len, pool->front_len); | 60 | pool->name, front_len, pool->front_len); |
48 | WARN_ON(1); | 61 | WARN_ON(1); |
49 | 62 | ||
@@ -51,14 +64,19 @@ struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool, | |||
51 | return ceph_msg_new(0, front_len, GFP_NOFS); | 64 | return ceph_msg_new(0, front_len, GFP_NOFS); |
52 | } | 65 | } |
53 | 66 | ||
54 | return mempool_alloc(pool->pool, GFP_NOFS); | 67 | msg = mempool_alloc(pool->pool, GFP_NOFS); |
68 | dout("msgpool_get %s %p\n", pool->name, msg); | ||
69 | return msg; | ||
55 | } | 70 | } |
56 | 71 | ||
57 | void ceph_msgpool_put(struct ceph_msgpool *pool, struct ceph_msg *msg) | 72 | void ceph_msgpool_put(struct ceph_msgpool *pool, struct ceph_msg *msg) |
58 | { | 73 | { |
74 | dout("msgpool_put %s %p\n", pool->name, msg); | ||
75 | |||
59 | /* reset msg front_len; user may have changed it */ | 76 | /* reset msg front_len; user may have changed it */ |
60 | msg->front.iov_len = pool->front_len; | 77 | msg->front.iov_len = pool->front_len; |
61 | msg->hdr.front_len = cpu_to_le32(pool->front_len); | 78 | msg->hdr.front_len = cpu_to_le32(pool->front_len); |
62 | 79 | ||
63 | kref_init(&msg->kref); /* retake single ref */ | 80 | kref_init(&msg->kref); /* retake single ref */ |
81 | mempool_free(msg, pool->pool); | ||
64 | } | 82 | } |
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index ce310eee708d..16836a7df7a6 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -685,6 +685,18 @@ static void __remove_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd) | |||
685 | put_osd(osd); | 685 | put_osd(osd); |
686 | } | 686 | } |
687 | 687 | ||
688 | static void remove_all_osds(struct ceph_osd_client *osdc) | ||
689 | { | ||
690 | dout("__remove_old_osds %p\n", osdc); | ||
691 | mutex_lock(&osdc->request_mutex); | ||
692 | while (!RB_EMPTY_ROOT(&osdc->osds)) { | ||
693 | struct ceph_osd *osd = rb_entry(rb_first(&osdc->osds), | ||
694 | struct ceph_osd, o_node); | ||
695 | __remove_osd(osdc, osd); | ||
696 | } | ||
697 | mutex_unlock(&osdc->request_mutex); | ||
698 | } | ||
699 | |||
688 | static void __move_osd_to_lru(struct ceph_osd_client *osdc, | 700 | static void __move_osd_to_lru(struct ceph_osd_client *osdc, |
689 | struct ceph_osd *osd) | 701 | struct ceph_osd *osd) |
690 | { | 702 | { |
@@ -701,14 +713,14 @@ static void __remove_osd_from_lru(struct ceph_osd *osd) | |||
701 | list_del_init(&osd->o_osd_lru); | 713 | list_del_init(&osd->o_osd_lru); |
702 | } | 714 | } |
703 | 715 | ||
704 | static void remove_old_osds(struct ceph_osd_client *osdc, int remove_all) | 716 | static void remove_old_osds(struct ceph_osd_client *osdc) |
705 | { | 717 | { |
706 | struct ceph_osd *osd, *nosd; | 718 | struct ceph_osd *osd, *nosd; |
707 | 719 | ||
708 | dout("__remove_old_osds %p\n", osdc); | 720 | dout("__remove_old_osds %p\n", osdc); |
709 | mutex_lock(&osdc->request_mutex); | 721 | mutex_lock(&osdc->request_mutex); |
710 | list_for_each_entry_safe(osd, nosd, &osdc->osd_lru, o_osd_lru) { | 722 | list_for_each_entry_safe(osd, nosd, &osdc->osd_lru, o_osd_lru) { |
711 | if (!remove_all && time_before(jiffies, osd->lru_ttl)) | 723 | if (time_before(jiffies, osd->lru_ttl)) |
712 | break; | 724 | break; |
713 | __remove_osd(osdc, osd); | 725 | __remove_osd(osdc, osd); |
714 | } | 726 | } |
@@ -751,6 +763,7 @@ static void __insert_osd(struct ceph_osd_client *osdc, struct ceph_osd *new) | |||
751 | struct rb_node *parent = NULL; | 763 | struct rb_node *parent = NULL; |
752 | struct ceph_osd *osd = NULL; | 764 | struct ceph_osd *osd = NULL; |
753 | 765 | ||
766 | dout("__insert_osd %p osd%d\n", new, new->o_osd); | ||
754 | while (*p) { | 767 | while (*p) { |
755 | parent = *p; | 768 | parent = *p; |
756 | osd = rb_entry(parent, struct ceph_osd, o_node); | 769 | osd = rb_entry(parent, struct ceph_osd, o_node); |
@@ -1144,7 +1157,7 @@ static void handle_osds_timeout(struct work_struct *work) | |||
1144 | 1157 | ||
1145 | dout("osds timeout\n"); | 1158 | dout("osds timeout\n"); |
1146 | down_read(&osdc->map_sem); | 1159 | down_read(&osdc->map_sem); |
1147 | remove_old_osds(osdc, 0); | 1160 | remove_old_osds(osdc); |
1148 | up_read(&osdc->map_sem); | 1161 | up_read(&osdc->map_sem); |
1149 | 1162 | ||
1150 | schedule_delayed_work(&osdc->osds_timeout_work, | 1163 | schedule_delayed_work(&osdc->osds_timeout_work, |
@@ -1862,8 +1875,7 @@ void ceph_osdc_stop(struct ceph_osd_client *osdc) | |||
1862 | ceph_osdmap_destroy(osdc->osdmap); | 1875 | ceph_osdmap_destroy(osdc->osdmap); |
1863 | osdc->osdmap = NULL; | 1876 | osdc->osdmap = NULL; |
1864 | } | 1877 | } |
1865 | remove_old_osds(osdc, 1); | 1878 | remove_all_osds(osdc); |
1866 | WARN_ON(!RB_EMPTY_ROOT(&osdc->osds)); | ||
1867 | mempool_destroy(osdc->req_mempool); | 1879 | mempool_destroy(osdc->req_mempool); |
1868 | ceph_msgpool_destroy(&osdc->msgpool_op); | 1880 | ceph_msgpool_destroy(&osdc->msgpool_op); |
1869 | ceph_msgpool_destroy(&osdc->msgpool_op_reply); | 1881 | ceph_msgpool_destroy(&osdc->msgpool_op_reply); |