aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ftrace.txt171
-rw-r--r--Documentation/io-mapping.txt82
-rw-r--r--arch/x86/Kconfig5
-rw-r--r--arch/x86/include/asm/fixmap.h4
-rw-r--r--arch/x86/include/asm/fixmap_32.h4
-rw-r--r--arch/x86/include/asm/highmem.h5
-rw-r--r--arch/x86/kernel/entry_32.S6
-rw-r--r--arch/x86/kernel/entry_64.S5
-rw-r--r--arch/x86/mm/Makefile2
-rw-r--r--arch/x86/mm/init_32.c3
-rw-r--r--arch/x86/mm/iomap_32.c59
-rw-r--r--drivers/char/sysrq.c18
-rw-r--r--drivers/gpu/drm/i915/Makefile3
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c1
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h12
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c196
-rw-r--r--drivers/gpu/drm/radeon/radeon_cp.c15
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.h12
-rw-r--r--fs/proc/uptime.c38
-rw-r--r--include/asm-x86/iomap.h30
-rw-r--r--include/drm/i915_drm.h13
-rw-r--r--include/linux/ftrace.h59
-rw-r--r--include/linux/io-mapping.h125
-rw-r--r--init/main.c4
-rw-r--r--kernel/sysctl.c2
-rw-r--r--kernel/trace/Kconfig7
-rw-r--r--kernel/trace/ftrace.c47
-rw-r--r--kernel/trace/ring_buffer.c114
-rw-r--r--kernel/trace/trace.c236
-rw-r--r--kernel/trace/trace.h55
-rw-r--r--kernel/trace/trace_boot.c36
-rw-r--r--kernel/trace/trace_functions.c6
-rw-r--r--kernel/trace/trace_irqsoff.c41
-rw-r--r--kernel/trace/trace_sched_switch.c50
-rw-r--r--kernel/trace/trace_sched_wakeup.c52
-rw-r--r--kernel/trace/trace_stack.c8
-rw-r--r--sound/aoa/soundbus/core.c2
-rw-r--r--sound/core/rawmidi.c8
-rw-r--r--sound/drivers/ml403-ac97cr.c4
-rw-r--r--sound/drivers/pcsp/pcsp_input.c4
-rw-r--r--sound/isa/ad1848/ad1848.c6
-rw-r--r--sound/isa/adlib.c12
-rw-r--r--sound/isa/cs423x/cs4231.c8
-rw-r--r--sound/isa/cs423x/cs4236.c8
-rw-r--r--sound/isa/es1688/es1688.c9
-rw-r--r--sound/isa/gus/gusclassic.c13
-rw-r--r--sound/isa/gus/gusextreme.c19
-rw-r--r--sound/isa/sb/sb8.c4
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c3
-rw-r--r--sound/pci/hda/patch_realtek.c29
-rw-r--r--sound/pci/hda/patch_sigmatel.c16
-rw-r--r--sound/soc/soc-core.c4
52 files changed, 1208 insertions, 467 deletions
diff --git a/Documentation/ftrace.txt b/Documentation/ftrace.txt
index ea5a827395dd..9cc4d685dde5 100644
--- a/Documentation/ftrace.txt
+++ b/Documentation/ftrace.txt
@@ -8,7 +8,7 @@ Copyright 2008 Red Hat Inc.
8Reviewers: Elias Oltmanns, Randy Dunlap, Andrew Morton, 8Reviewers: Elias Oltmanns, Randy Dunlap, Andrew Morton,
9 John Kacur, and David Teigland. 9 John Kacur, and David Teigland.
10 10
11Written for: 2.6.27-rc1 11Written for: 2.6.28-rc2
12 12
13Introduction 13Introduction
14------------ 14------------
@@ -50,26 +50,26 @@ of ftrace. Here is a list of some of the key files:
50 50
51 Note: all time values are in microseconds. 51 Note: all time values are in microseconds.
52 52
53 current_tracer : This is used to set or display the current tracer 53 current_tracer: This is used to set or display the current tracer
54 that is configured. 54 that is configured.
55 55
56 available_tracers : This holds the different types of tracers that 56 available_tracers: This holds the different types of tracers that
57 have been compiled into the kernel. The tracers 57 have been compiled into the kernel. The tracers
58 listed here can be configured by echoing their name 58 listed here can be configured by echoing their name
59 into current_tracer. 59 into current_tracer.
60 60
61 tracing_enabled : This sets or displays whether the current_tracer 61 tracing_enabled: This sets or displays whether the current_tracer
62 is activated and tracing or not. Echo 0 into this 62 is activated and tracing or not. Echo 0 into this
63 file to disable the tracer or 1 to enable it. 63 file to disable the tracer or 1 to enable it.
64 64
65 trace : This file holds the output of the trace in a human readable 65 trace: This file holds the output of the trace in a human readable
66 format (described below). 66 format (described below).
67 67
68 latency_trace : This file shows the same trace but the information 68 latency_trace: This file shows the same trace but the information
69 is organized more to display possible latencies 69 is organized more to display possible latencies
70 in the system (described below). 70 in the system (described below).
71 71
72 trace_pipe : The output is the same as the "trace" file but this 72 trace_pipe: The output is the same as the "trace" file but this
73 file is meant to be streamed with live tracing. 73 file is meant to be streamed with live tracing.
74 Reads from this file will block until new data 74 Reads from this file will block until new data
75 is retrieved. Unlike the "trace" and "latency_trace" 75 is retrieved. Unlike the "trace" and "latency_trace"
@@ -82,11 +82,11 @@ of ftrace. Here is a list of some of the key files:
82 tracer is not adding more data, they will display 82 tracer is not adding more data, they will display
83 the same information every time they are read. 83 the same information every time they are read.
84 84
85 iter_ctrl : This file lets the user control the amount of data 85 iter_ctrl: This file lets the user control the amount of data
86 that is displayed in one of the above output 86 that is displayed in one of the above output
87 files. 87 files.
88 88
89 trace_max_latency : Some of the tracers record the max latency. 89 trace_max_latency: Some of the tracers record the max latency.
90 For example, the time interrupts are disabled. 90 For example, the time interrupts are disabled.
91 This time is saved in this file. The max trace 91 This time is saved in this file. The max trace
92 will also be stored, and displayed by either 92 will also be stored, and displayed by either
@@ -94,29 +94,26 @@ of ftrace. Here is a list of some of the key files:
94 only be recorded if the latency is greater than 94 only be recorded if the latency is greater than
95 the value in this file. (in microseconds) 95 the value in this file. (in microseconds)
96 96
97 trace_entries : This sets or displays the number of trace 97 trace_entries: This sets or displays the number of bytes each CPU
98 entries each CPU buffer can hold. The tracer buffers 98 buffer can hold. The tracer buffers are the same size
99 are the same size for each CPU. The displayed number 99 for each CPU. The displayed number is the size of the
100 is the size of the CPU buffer and not total size. The 100 CPU buffer and not total size of all buffers. The
101 trace buffers are allocated in pages (blocks of memory 101 trace buffers are allocated in pages (blocks of memory
102 that the kernel uses for allocation, usually 4 KB in size). 102 that the kernel uses for allocation, usually 4 KB in size).
103 Since each entry is smaller than a page, if the last 103 If the last page allocated has room for more bytes
104 allocated page has room for more entries than were 104 than requested, the rest of the page will be used,
105 requested, the rest of the page is used to allocate 105 making the actual allocation bigger than requested.
106 entries. 106 (Note, the size may not be a multiple of the page size due
107 to buffer managment overhead.)
107 108
108 This can only be updated when the current_tracer 109 This can only be updated when the current_tracer
109 is set to "none". 110 is set to "nop".
110 111
111 NOTE: It is planned on changing the allocated buffers 112 tracing_cpumask: This is a mask that lets the user only trace
112 from being the number of possible CPUS to
113 the number of online CPUS.
114
115 tracing_cpumask : This is a mask that lets the user only trace
116 on specified CPUS. The format is a hex string 113 on specified CPUS. The format is a hex string
117 representing the CPUS. 114 representing the CPUS.
118 115
119 set_ftrace_filter : When dynamic ftrace is configured in (see the 116 set_ftrace_filter: When dynamic ftrace is configured in (see the
120 section below "dynamic ftrace"), the code is dynamically 117 section below "dynamic ftrace"), the code is dynamically
121 modified (code text rewrite) to disable calling of the 118 modified (code text rewrite) to disable calling of the
122 function profiler (mcount). This lets tracing be configured 119 function profiler (mcount). This lets tracing be configured
@@ -130,14 +127,11 @@ of ftrace. Here is a list of some of the key files:
130 be traced. If a function exists in both set_ftrace_filter 127 be traced. If a function exists in both set_ftrace_filter
131 and set_ftrace_notrace, the function will _not_ be traced. 128 and set_ftrace_notrace, the function will _not_ be traced.
132 129
133 available_filter_functions : When a function is encountered the first 130 available_filter_functions: This lists the functions that ftrace
134 time by the dynamic tracer, it is recorded and 131 has processed and can trace. These are the function
135 later the call is converted into a nop. This file 132 names that you can pass to "set_ftrace_filter" or
136 lists the functions that have been recorded 133 "set_ftrace_notrace". (See the section "dynamic ftrace"
137 by the dynamic tracer and these functions can 134 below for more details.)
138 be used to set the ftrace filter by the above
139 "set_ftrace_filter" file. (See the section "dynamic ftrace"
140 below for more details).
141 135
142 136
143The Tracers 137The Tracers
@@ -145,7 +139,7 @@ The Tracers
145 139
146Here is the list of current tracers that may be configured. 140Here is the list of current tracers that may be configured.
147 141
148 ftrace - function tracer that uses mcount to trace all functions. 142 function - function tracer that uses mcount to trace all functions.
149 143
150 sched_switch - traces the context switches between tasks. 144 sched_switch - traces the context switches between tasks.
151 145
@@ -166,8 +160,8 @@ Here is the list of current tracers that may be configured.
166 the highest priority task to get scheduled after 160 the highest priority task to get scheduled after
167 it has been woken up. 161 it has been woken up.
168 162
169 none - This is not a tracer. To remove all tracers from tracing 163 nop - This is not a tracer. To remove all tracers from tracing
170 simply echo "none" into current_tracer. 164 simply echo "nop" into current_tracer.
171 165
172 166
173Examples of using the tracer 167Examples of using the tracer
@@ -182,7 +176,7 @@ Output format:
182Here is an example of the output format of the file "trace" 176Here is an example of the output format of the file "trace"
183 177
184 -------- 178 --------
185# tracer: ftrace 179# tracer: function
186# 180#
187# TASK-PID CPU# TIMESTAMP FUNCTION 181# TASK-PID CPU# TIMESTAMP FUNCTION
188# | | | | | 182# | | | | |
@@ -192,7 +186,7 @@ Here is an example of the output format of the file "trace"
192 -------- 186 --------
193 187
194A header is printed with the tracer name that is represented by the trace. 188A header is printed with the tracer name that is represented by the trace.
195In this case the tracer is "ftrace". Then a header showing the format. Task 189In this case the tracer is "function". Then a header showing the format. Task
196name "bash", the task PID "4251", the CPU that it was running on 190name "bash", the task PID "4251", the CPU that it was running on
197"01", the timestamp in <secs>.<usecs> format, the function name that was 191"01", the timestamp in <secs>.<usecs> format, the function name that was
198traced "path_put" and the parent function that called this function 192traced "path_put" and the parent function that called this function
@@ -1003,22 +997,20 @@ is the stack for the hard interrupt. This hides the fact that NEED_RESCHED
1003has been set. We do not see the 'N' until we switch back to the task's 997has been set. We do not see the 'N' until we switch back to the task's
1004assigned stack. 998assigned stack.
1005 999
1006ftrace 1000function
1007------ 1001--------
1008 1002
1009ftrace is not only the name of the tracing infrastructure, but it 1003This tracer is the function tracer. Enabling the function tracer
1010is also a name of one of the tracers. The tracer is the function 1004can be done from the debug file system. Make sure the ftrace_enabled is
1011tracer. Enabling the function tracer can be done from the 1005set; otherwise this tracer is a nop.
1012debug file system. Make sure the ftrace_enabled is set otherwise
1013this tracer is a nop.
1014 1006
1015 # sysctl kernel.ftrace_enabled=1 1007 # sysctl kernel.ftrace_enabled=1
1016 # echo ftrace > /debug/tracing/current_tracer 1008 # echo function > /debug/tracing/current_tracer
1017 # echo 1 > /debug/tracing/tracing_enabled 1009 # echo 1 > /debug/tracing/tracing_enabled
1018 # usleep 1 1010 # usleep 1
1019 # echo 0 > /debug/tracing/tracing_enabled 1011 # echo 0 > /debug/tracing/tracing_enabled
1020 # cat /debug/tracing/trace 1012 # cat /debug/tracing/trace
1021# tracer: ftrace 1013# tracer: function
1022# 1014#
1023# TASK-PID CPU# TIMESTAMP FUNCTION 1015# TASK-PID CPU# TIMESTAMP FUNCTION
1024# | | | | | 1016# | | | | |
@@ -1040,10 +1032,10 @@ this tracer is a nop.
1040[...] 1032[...]
1041 1033
1042 1034
1043Note: ftrace uses ring buffers to store the above entries. The newest data 1035Note: function tracer uses ring buffers to store the above entries.
1044may overwrite the oldest data. Sometimes using echo to stop the trace 1036The newest data may overwrite the oldest data. Sometimes using echo to
1045is not sufficient because the tracing could have overwritten the data 1037stop the trace is not sufficient because the tracing could have overwritten
1046that you wanted to record. For this reason, it is sometimes better to 1038the data that you wanted to record. For this reason, it is sometimes better to
1047disable tracing directly from a program. This allows you to stop the 1039disable tracing directly from a program. This allows you to stop the
1048tracing at the point that you hit the part that you are interested in. 1040tracing at the point that you hit the part that you are interested in.
1049To disable the tracing directly from a C program, something like following 1041To disable the tracing directly from a C program, something like following
@@ -1077,18 +1069,31 @@ every kernel function, produced by the -pg switch in gcc), starts
1077of pointing to a simple return. (Enabling FTRACE will include the 1069of pointing to a simple return. (Enabling FTRACE will include the
1078-pg switch in the compiling of the kernel.) 1070-pg switch in the compiling of the kernel.)
1079 1071
1080When dynamic ftrace is initialized, it calls kstop_machine to make 1072At compile time every C file object is run through the
1081the machine act like a uniprocessor so that it can freely modify code 1073recordmcount.pl script (located in the scripts directory). This
1082without worrying about other processors executing that same code. At 1074script will process the C object using objdump to find all the
1083initialization, the mcount calls are changed to call a "record_ip" 1075locations in the .text section that call mcount. (Note, only
1084function. After this, the first time a kernel function is called, 1076the .text section is processed, since processing other sections
1085it has the calling address saved in a hash table. 1077like .init.text may cause races due to those sections being freed).
1086 1078
1087Later on the ftraced kernel thread is awoken and will again call 1079A new section called "__mcount_loc" is created that holds references
1088kstop_machine if new functions have been recorded. The ftraced thread 1080to all the mcount call sites in the .text section. This section is
1089will change all calls to mcount to "nop". Just calling mcount 1081compiled back into the original object. The final linker will add
1090and having mcount return has shown a 10% overhead. By converting 1082all these references into a single table.
1091it to a nop, there is no measurable overhead to the system. 1083
1084On boot up, before SMP is initialized, the dynamic ftrace code
1085scans this table and updates all the locations into nops. It also
1086records the locations, which are added to the available_filter_functions
1087list. Modules are processed as they are loaded and before they are
1088executed. When a module is unloaded, it also removes its functions from
1089the ftrace function list. This is automatic in the module unload
1090code, and the module author does not need to worry about it.
1091
1092When tracing is enabled, kstop_machine is called to prevent races
1093with the CPUS executing code being modified (which can cause the
1094CPU to do undesireable things), and the nops are patched back
1095to calls. But this time, they do not call mcount (which is just
1096a function stub). They now call into the ftrace infrastructure.
1092 1097
1093One special side-effect to the recording of the functions being 1098One special side-effect to the recording of the functions being
1094traced is that we can now selectively choose which functions we 1099traced is that we can now selectively choose which functions we
@@ -1251,36 +1256,6 @@ Produces:
1251 1256
1252We can see that there's no more lock or preempt tracing. 1257We can see that there's no more lock or preempt tracing.
1253 1258
1254ftraced
1255-------
1256
1257As mentioned above, when dynamic ftrace is configured in, a kernel
1258thread wakes up once a second and checks to see if there are mcount
1259calls that need to be converted into nops. If there are not any, then
1260it simply goes back to sleep. But if there are some, it will call
1261kstop_machine to convert the calls to nops.
1262
1263There may be a case in which you do not want this added latency.
1264Perhaps you are doing some audio recording and this activity might
1265cause skips in the playback. There is an interface to disable
1266and enable the "ftraced" kernel thread.
1267
1268 # echo 0 > /debug/tracing/ftraced_enabled
1269
1270This will disable the calling of kstop_machine to update the
1271mcount calls to nops. Remember that there is a large overhead
1272to calling mcount. Without this kernel thread, that overhead will
1273exist.
1274
1275If there are recorded calls to mcount, any write to the ftraced_enabled
1276file will cause the kstop_machine to run. This means that a
1277user can manually perform the updates when they want to by simply
1278echoing a '0' into the ftraced_enabled file.
1279
1280The updates are also done at the beginning of enabling a tracer
1281that uses ftrace function recording.
1282
1283
1284trace_pipe 1259trace_pipe
1285---------- 1260----------
1286 1261
@@ -1289,14 +1264,14 @@ on the tracing is different. Every read from trace_pipe is consumed.
1289This means that subsequent reads will be different. The trace 1264This means that subsequent reads will be different. The trace
1290is live. 1265is live.
1291 1266
1292 # echo ftrace > /debug/tracing/current_tracer 1267 # echo function > /debug/tracing/current_tracer
1293 # cat /debug/tracing/trace_pipe > /tmp/trace.out & 1268 # cat /debug/tracing/trace_pipe > /tmp/trace.out &
1294[1] 4153 1269[1] 4153
1295 # echo 1 > /debug/tracing/tracing_enabled 1270 # echo 1 > /debug/tracing/tracing_enabled
1296 # usleep 1 1271 # usleep 1
1297 # echo 0 > /debug/tracing/tracing_enabled 1272 # echo 0 > /debug/tracing/tracing_enabled
1298 # cat /debug/tracing/trace 1273 # cat /debug/tracing/trace
1299# tracer: ftrace 1274# tracer: function
1300# 1275#
1301# TASK-PID CPU# TIMESTAMP FUNCTION 1276# TASK-PID CPU# TIMESTAMP FUNCTION
1302# | | | | | 1277# | | | | |
@@ -1317,7 +1292,7 @@ is live.
1317 1292
1318Note, reading the trace_pipe file will block until more input is added. 1293Note, reading the trace_pipe file will block until more input is added.
1319By changing the tracer, trace_pipe will issue an EOF. We needed 1294By changing the tracer, trace_pipe will issue an EOF. We needed
1320to set the ftrace tracer _before_ cating the trace_pipe file. 1295to set the function tracer _before_ we "cat" the trace_pipe file.
1321 1296
1322 1297
1323trace entries 1298trace entries
@@ -1334,10 +1309,10 @@ number of entries.
133465620 130965620
1335 1310
1336Note, to modify this, you must have tracing completely disabled. To do that, 1311Note, to modify this, you must have tracing completely disabled. To do that,
1337echo "none" into the current_tracer. If the current_tracer is not set 1312echo "nop" into the current_tracer. If the current_tracer is not set
1338to "none", an EINVAL error will be returned. 1313to "nop", an EINVAL error will be returned.
1339 1314
1340 # echo none > /debug/tracing/current_tracer 1315 # echo nop > /debug/tracing/current_tracer
1341 # echo 100000 > /debug/tracing/trace_entries 1316 # echo 100000 > /debug/tracing/trace_entries
1342 # cat /debug/tracing/trace_entries 1317 # cat /debug/tracing/trace_entries
1343100045 1318100045
diff --git a/Documentation/io-mapping.txt b/Documentation/io-mapping.txt
new file mode 100644
index 000000000000..473e43b2d588
--- /dev/null
+++ b/Documentation/io-mapping.txt
@@ -0,0 +1,82 @@
1The io_mapping functions in linux/io-mapping.h provide an abstraction for
2efficiently mapping small regions of an I/O device to the CPU. The initial
3usage is to support the large graphics aperture on 32-bit processors where
4ioremap_wc cannot be used to statically map the entire aperture to the CPU
5as it would consume too much of the kernel address space.
6
7A mapping object is created during driver initialization using
8
9 struct io_mapping *io_mapping_create_wc(unsigned long base,
10 unsigned long size)
11
12 'base' is the bus address of the region to be made
13 mappable, while 'size' indicates how large a mapping region to
14 enable. Both are in bytes.
15
16 This _wc variant provides a mapping which may only be used
17 with the io_mapping_map_atomic_wc or io_mapping_map_wc.
18
19With this mapping object, individual pages can be mapped either atomically
20or not, depending on the necessary scheduling environment. Of course, atomic
21maps are more efficient:
22
23 void *io_mapping_map_atomic_wc(struct io_mapping *mapping,
24 unsigned long offset)
25
26 'offset' is the offset within the defined mapping region.
27 Accessing addresses beyond the region specified in the
28 creation function yields undefined results. Using an offset
29 which is not page aligned yields an undefined result. The
30 return value points to a single page in CPU address space.
31
32 This _wc variant returns a write-combining map to the
33 page and may only be used with mappings created by
34 io_mapping_create_wc
35
36 Note that the task may not sleep while holding this page
37 mapped.
38
39 void io_mapping_unmap_atomic(void *vaddr)
40
41 'vaddr' must be the the value returned by the last
42 io_mapping_map_atomic_wc call. This unmaps the specified
43 page and allows the task to sleep once again.
44
45If you need to sleep while holding the lock, you can use the non-atomic
46variant, although they may be significantly slower.
47
48 void *io_mapping_map_wc(struct io_mapping *mapping,
49 unsigned long offset)
50
51 This works like io_mapping_map_atomic_wc except it allows
52 the task to sleep while holding the page mapped.
53
54 void io_mapping_unmap(void *vaddr)
55
56 This works like io_mapping_unmap_atomic, except it is used
57 for pages mapped with io_mapping_map_wc.
58
59At driver close time, the io_mapping object must be freed:
60
61 void io_mapping_free(struct io_mapping *mapping)
62
63Current Implementation:
64
65The initial implementation of these functions uses existing mapping
66mechanisms and so provides only an abstraction layer and no new
67functionality.
68
69On 64-bit processors, io_mapping_create_wc calls ioremap_wc for the whole
70range, creating a permanent kernel-visible mapping to the resource. The
71map_atomic and map functions add the requested offset to the base of the
72virtual address returned by ioremap_wc.
73
74On 32-bit processors with HIGHMEM defined, io_mapping_map_atomic_wc uses
75kmap_atomic_pfn to map the specified page in an atomic fashion;
76kmap_atomic_pfn isn't really supposed to be used with device pages, but it
77provides an efficient mapping for this usage.
78
79On 32-bit processors without HIGHMEM defined, io_mapping_map_atomic_wc and
80io_mapping_map_wc both use ioremap_wc, a terribly inefficient function which
81performs an IPI to inform all processors about the new mapping. This results
82in a significant performance penalty.
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 6f20718d3156..d03e91762f61 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -29,6 +29,7 @@ config X86
29 select HAVE_FTRACE_MCOUNT_RECORD 29 select HAVE_FTRACE_MCOUNT_RECORD
30 select HAVE_DYNAMIC_FTRACE 30 select HAVE_DYNAMIC_FTRACE
31 select HAVE_FUNCTION_TRACER 31 select HAVE_FUNCTION_TRACER
32 select HAVE_FUNCTION_TRACE_MCOUNT_TEST
32 select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64) 33 select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64)
33 select HAVE_ARCH_KGDB if !X86_VOYAGER 34 select HAVE_ARCH_KGDB if !X86_VOYAGER
34 select HAVE_ARCH_TRACEHOOK 35 select HAVE_ARCH_TRACEHOOK
@@ -1894,6 +1895,10 @@ config SYSVIPC_COMPAT
1894endmenu 1895endmenu
1895 1896
1896 1897
1898config HAVE_ATOMIC_IOMAP
1899 def_bool y
1900 depends on X86_32
1901
1897source "net/Kconfig" 1902source "net/Kconfig"
1898 1903
1899source "drivers/Kconfig" 1904source "drivers/Kconfig"
diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
index 8668a94f850e..23696d44a0af 100644
--- a/arch/x86/include/asm/fixmap.h
+++ b/arch/x86/include/asm/fixmap.h
@@ -9,6 +9,10 @@
9 9
10extern int fixmaps_set; 10extern int fixmaps_set;
11 11
12extern pte_t *kmap_pte;
13extern pgprot_t kmap_prot;
14extern pte_t *pkmap_page_table;
15
12void __native_set_fixmap(enum fixed_addresses idx, pte_t pte); 16void __native_set_fixmap(enum fixed_addresses idx, pte_t pte);
13void native_set_fixmap(enum fixed_addresses idx, 17void native_set_fixmap(enum fixed_addresses idx,
14 unsigned long phys, pgprot_t flags); 18 unsigned long phys, pgprot_t flags);
diff --git a/arch/x86/include/asm/fixmap_32.h b/arch/x86/include/asm/fixmap_32.h
index 09f29ab5c139..c7115c1d7217 100644
--- a/arch/x86/include/asm/fixmap_32.h
+++ b/arch/x86/include/asm/fixmap_32.h
@@ -28,10 +28,8 @@ extern unsigned long __FIXADDR_TOP;
28#include <asm/acpi.h> 28#include <asm/acpi.h>
29#include <asm/apicdef.h> 29#include <asm/apicdef.h>
30#include <asm/page.h> 30#include <asm/page.h>
31#ifdef CONFIG_HIGHMEM
32#include <linux/threads.h> 31#include <linux/threads.h>
33#include <asm/kmap_types.h> 32#include <asm/kmap_types.h>
34#endif
35 33
36/* 34/*
37 * Here we define all the compile-time 'special' virtual 35 * Here we define all the compile-time 'special' virtual
@@ -75,10 +73,8 @@ enum fixed_addresses {
75#ifdef CONFIG_X86_CYCLONE_TIMER 73#ifdef CONFIG_X86_CYCLONE_TIMER
76 FIX_CYCLONE_TIMER, /*cyclone timer register*/ 74 FIX_CYCLONE_TIMER, /*cyclone timer register*/
77#endif 75#endif
78#ifdef CONFIG_HIGHMEM
79 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ 76 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
80 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1, 77 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
81#endif
82#ifdef CONFIG_PCI_MMCONFIG 78#ifdef CONFIG_PCI_MMCONFIG
83 FIX_PCIE_MCFG, 79 FIX_PCIE_MCFG,
84#endif 80#endif
diff --git a/arch/x86/include/asm/highmem.h b/arch/x86/include/asm/highmem.h
index a3b3b7c3027b..bf9276bea660 100644
--- a/arch/x86/include/asm/highmem.h
+++ b/arch/x86/include/asm/highmem.h
@@ -25,14 +25,11 @@
25#include <asm/kmap_types.h> 25#include <asm/kmap_types.h>
26#include <asm/tlbflush.h> 26#include <asm/tlbflush.h>
27#include <asm/paravirt.h> 27#include <asm/paravirt.h>
28#include <asm/fixmap.h>
28 29
29/* declarations for highmem.c */ 30/* declarations for highmem.c */
30extern unsigned long highstart_pfn, highend_pfn; 31extern unsigned long highstart_pfn, highend_pfn;
31 32
32extern pte_t *kmap_pte;
33extern pgprot_t kmap_prot;
34extern pte_t *pkmap_page_table;
35
36/* 33/*
37 * Right now we initialize only a single pte table. It can be extended 34 * Right now we initialize only a single pte table. It can be extended
38 * easily, subsequent pte tables have to be allocated in one physical 35 * easily, subsequent pte tables have to be allocated in one physical
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 28b597ef9ca1..9134de814c97 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -1157,6 +1157,9 @@ ENTRY(mcount)
1157END(mcount) 1157END(mcount)
1158 1158
1159ENTRY(ftrace_caller) 1159ENTRY(ftrace_caller)
1160 cmpl $0, function_trace_stop
1161 jne ftrace_stub
1162
1160 pushl %eax 1163 pushl %eax
1161 pushl %ecx 1164 pushl %ecx
1162 pushl %edx 1165 pushl %edx
@@ -1180,6 +1183,9 @@ END(ftrace_caller)
1180#else /* ! CONFIG_DYNAMIC_FTRACE */ 1183#else /* ! CONFIG_DYNAMIC_FTRACE */
1181 1184
1182ENTRY(mcount) 1185ENTRY(mcount)
1186 cmpl $0, function_trace_stop
1187 jne ftrace_stub
1188
1183 cmpl $ftrace_stub, ftrace_trace_function 1189 cmpl $ftrace_stub, ftrace_trace_function
1184 jnz trace 1190 jnz trace
1185.globl ftrace_stub 1191.globl ftrace_stub
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index b86f332c96a6..08aa6b10933c 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -68,6 +68,8 @@ ENTRY(mcount)
68END(mcount) 68END(mcount)
69 69
70ENTRY(ftrace_caller) 70ENTRY(ftrace_caller)
71 cmpl $0, function_trace_stop
72 jne ftrace_stub
71 73
72 /* taken from glibc */ 74 /* taken from glibc */
73 subq $0x38, %rsp 75 subq $0x38, %rsp
@@ -103,6 +105,9 @@ END(ftrace_caller)
103 105
104#else /* ! CONFIG_DYNAMIC_FTRACE */ 106#else /* ! CONFIG_DYNAMIC_FTRACE */
105ENTRY(mcount) 107ENTRY(mcount)
108 cmpl $0, function_trace_stop
109 jne ftrace_stub
110
106 cmpq $ftrace_stub, ftrace_trace_function 111 cmpq $ftrace_stub, ftrace_trace_function
107 jnz trace 112 jnz trace
108.globl ftrace_stub 113.globl ftrace_stub
diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
index 0a21b7aab9dc..d8cc96a2738f 100644
--- a/arch/x86/mm/Makefile
+++ b/arch/x86/mm/Makefile
@@ -1,7 +1,7 @@
1obj-y := init_$(BITS).o fault.o ioremap.o extable.o pageattr.o mmap.o \ 1obj-y := init_$(BITS).o fault.o ioremap.o extable.o pageattr.o mmap.o \
2 pat.o pgtable.o gup.o 2 pat.o pgtable.o gup.o
3 3
4obj-$(CONFIG_X86_32) += pgtable_32.o 4obj-$(CONFIG_X86_32) += pgtable_32.o iomap_32.o
5 5
6obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 6obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
7obj-$(CONFIG_X86_PTDUMP) += dump_pagetables.o 7obj-$(CONFIG_X86_PTDUMP) += dump_pagetables.o
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 8396868e82c5..c483f4242079 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -334,7 +334,6 @@ int devmem_is_allowed(unsigned long pagenr)
334 return 0; 334 return 0;
335} 335}
336 336
337#ifdef CONFIG_HIGHMEM
338pte_t *kmap_pte; 337pte_t *kmap_pte;
339pgprot_t kmap_prot; 338pgprot_t kmap_prot;
340 339
@@ -357,6 +356,7 @@ static void __init kmap_init(void)
357 kmap_prot = PAGE_KERNEL; 356 kmap_prot = PAGE_KERNEL;
358} 357}
359 358
359#ifdef CONFIG_HIGHMEM
360static void __init permanent_kmaps_init(pgd_t *pgd_base) 360static void __init permanent_kmaps_init(pgd_t *pgd_base)
361{ 361{
362 unsigned long vaddr; 362 unsigned long vaddr;
@@ -436,7 +436,6 @@ static void __init set_highmem_pages_init(void)
436#endif /* !CONFIG_NUMA */ 436#endif /* !CONFIG_NUMA */
437 437
438#else 438#else
439# define kmap_init() do { } while (0)
440# define permanent_kmaps_init(pgd_base) do { } while (0) 439# define permanent_kmaps_init(pgd_base) do { } while (0)
441# define set_highmem_pages_init() do { } while (0) 440# define set_highmem_pages_init() do { } while (0)
442#endif /* CONFIG_HIGHMEM */ 441#endif /* CONFIG_HIGHMEM */
diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
new file mode 100644
index 000000000000..d0151d8ce452
--- /dev/null
+++ b/arch/x86/mm/iomap_32.c
@@ -0,0 +1,59 @@
1/*
2 * Copyright © 2008 Ingo Molnar
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 */
18
19#include <asm/iomap.h>
20#include <linux/module.h>
21
22/* Map 'pfn' using fixed map 'type' and protections 'prot'
23 */
24void *
25iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot)
26{
27 enum fixed_addresses idx;
28 unsigned long vaddr;
29
30 pagefault_disable();
31
32 idx = type + KM_TYPE_NR*smp_processor_id();
33 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
34 set_pte(kmap_pte-idx, pfn_pte(pfn, prot));
35 arch_flush_lazy_mmu_mode();
36
37 return (void*) vaddr;
38}
39EXPORT_SYMBOL_GPL(iomap_atomic_prot_pfn);
40
41void
42iounmap_atomic(void *kvaddr, enum km_type type)
43{
44 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
45 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
46
47 /*
48 * Force other mappings to Oops if they'll try to access this pte
49 * without first remap it. Keeping stale mappings around is a bad idea
50 * also, in case the page changes cacheability attributes or becomes
51 * a protected page in a hypervisor.
52 */
53 if (vaddr == __fix_to_virt(FIX_KMAP_BEGIN+idx))
54 kpte_clear_flush(kmap_pte-idx, vaddr);
55
56 arch_flush_lazy_mmu_mode();
57 pagefault_enable();
58}
59EXPORT_SYMBOL_GPL(iounmap_atomic);
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index ce0d9da52a8a..94966edfb44d 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -274,6 +274,22 @@ static struct sysrq_key_op sysrq_showstate_blocked_op = {
274 .enable_mask = SYSRQ_ENABLE_DUMP, 274 .enable_mask = SYSRQ_ENABLE_DUMP,
275}; 275};
276 276
277#ifdef CONFIG_TRACING
278#include <linux/ftrace.h>
279
280static void sysrq_ftrace_dump(int key, struct tty_struct *tty)
281{
282 ftrace_dump();
283}
284static struct sysrq_key_op sysrq_ftrace_dump_op = {
285 .handler = sysrq_ftrace_dump,
286 .help_msg = "dumpZ-ftrace-buffer",
287 .action_msg = "Dump ftrace buffer",
288 .enable_mask = SYSRQ_ENABLE_DUMP,
289};
290#else
291#define sysrq_ftrace_dump_op (*(struct sysrq_key_op *)0)
292#endif
277 293
278static void sysrq_handle_showmem(int key, struct tty_struct *tty) 294static void sysrq_handle_showmem(int key, struct tty_struct *tty)
279{ 295{
@@ -406,7 +422,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = {
406 NULL, /* x */ 422 NULL, /* x */
407 /* y: May be registered on sparc64 for global register dump */ 423 /* y: May be registered on sparc64 for global register dump */
408 NULL, /* y */ 424 NULL, /* y */
409 NULL /* z */ 425 &sysrq_ftrace_dump_op, /* z */
410}; 426};
411 427
412/* key2index calculation, -1 on invalid index */ 428/* key2index calculation, -1 on invalid index */
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 5ba78e4fd2b5..d8fb5d8ee7ea 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -3,13 +3,14 @@
3# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. 3# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
4 4
5ccflags-y := -Iinclude/drm 5ccflags-y := -Iinclude/drm
6i915-y := i915_drv.o i915_dma.o i915_irq.o i915_mem.o i915_opregion.o \ 6i915-y := i915_drv.o i915_dma.o i915_irq.o i915_mem.o \
7 i915_suspend.o \ 7 i915_suspend.o \
8 i915_gem.o \ 8 i915_gem.o \
9 i915_gem_debug.o \ 9 i915_gem_debug.o \
10 i915_gem_proc.o \ 10 i915_gem_proc.o \
11 i915_gem_tiling.o 11 i915_gem_tiling.o
12 12
13i915-$(CONFIG_ACPI) += i915_opregion.o
13i915-$(CONFIG_COMPAT) += i915_ioc32.o 14i915-$(CONFIG_COMPAT) += i915_ioc32.o
14 15
15obj-$(CONFIG_DRM_I915) += i915.o 16obj-$(CONFIG_DRM_I915) += i915.o
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 01de536e0211..256e22963ae4 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -960,6 +960,7 @@ struct drm_ioctl_desc i915_ioctls[] = {
960 DRM_IOCTL_DEF(DRM_I915_GEM_SW_FINISH, i915_gem_sw_finish_ioctl, 0), 960 DRM_IOCTL_DEF(DRM_I915_GEM_SW_FINISH, i915_gem_sw_finish_ioctl, 0),
961 DRM_IOCTL_DEF(DRM_I915_GEM_SET_TILING, i915_gem_set_tiling, 0), 961 DRM_IOCTL_DEF(DRM_I915_GEM_SET_TILING, i915_gem_set_tiling, 0),
962 DRM_IOCTL_DEF(DRM_I915_GEM_GET_TILING, i915_gem_get_tiling, 0), 962 DRM_IOCTL_DEF(DRM_I915_GEM_GET_TILING, i915_gem_get_tiling, 0),
963 DRM_IOCTL_DEF(DRM_I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, 0),
963}; 964};
964 965
965int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); 966int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index f20ffe17df71..572dcd0e3e0d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -31,6 +31,7 @@
31#define _I915_DRV_H_ 31#define _I915_DRV_H_
32 32
33#include "i915_reg.h" 33#include "i915_reg.h"
34#include <linux/io-mapping.h>
34 35
35/* General customization: 36/* General customization:
36 */ 37 */
@@ -246,6 +247,8 @@ typedef struct drm_i915_private {
246 struct { 247 struct {
247 struct drm_mm gtt_space; 248 struct drm_mm gtt_space;
248 249
250 struct io_mapping *gtt_mapping;
251
249 /** 252 /**
250 * List of objects currently involved in rendering from the 253 * List of objects currently involved in rendering from the
251 * ringbuffer. 254 * ringbuffer.
@@ -502,6 +505,8 @@ int i915_gem_set_tiling(struct drm_device *dev, void *data,
502 struct drm_file *file_priv); 505 struct drm_file *file_priv);
503int i915_gem_get_tiling(struct drm_device *dev, void *data, 506int i915_gem_get_tiling(struct drm_device *dev, void *data,
504 struct drm_file *file_priv); 507 struct drm_file *file_priv);
508int i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
509 struct drm_file *file_priv);
505void i915_gem_load(struct drm_device *dev); 510void i915_gem_load(struct drm_device *dev);
506int i915_gem_proc_init(struct drm_minor *minor); 511int i915_gem_proc_init(struct drm_minor *minor);
507void i915_gem_proc_cleanup(struct drm_minor *minor); 512void i915_gem_proc_cleanup(struct drm_minor *minor);
@@ -539,11 +544,18 @@ extern int i915_restore_state(struct drm_device *dev);
539extern int i915_save_state(struct drm_device *dev); 544extern int i915_save_state(struct drm_device *dev);
540extern int i915_restore_state(struct drm_device *dev); 545extern int i915_restore_state(struct drm_device *dev);
541 546
547#ifdef CONFIG_ACPI
542/* i915_opregion.c */ 548/* i915_opregion.c */
543extern int intel_opregion_init(struct drm_device *dev); 549extern int intel_opregion_init(struct drm_device *dev);
544extern void intel_opregion_free(struct drm_device *dev); 550extern void intel_opregion_free(struct drm_device *dev);
545extern void opregion_asle_intr(struct drm_device *dev); 551extern void opregion_asle_intr(struct drm_device *dev);
546extern void opregion_enable_asle(struct drm_device *dev); 552extern void opregion_enable_asle(struct drm_device *dev);
553#else
554static inline int intel_opregion_init(struct drm_device *dev) { return 0; }
555static inline void intel_opregion_free(struct drm_device *dev) { return; }
556static inline void opregion_asle_intr(struct drm_device *dev) { return; }
557static inline void opregion_enable_asle(struct drm_device *dev) { return; }
558#endif
547 559
548/** 560/**
549 * Lock test for when it's just for synchronization of ring access. 561 * Lock test for when it's just for synchronization of ring access.
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 17ae330ff269..b0ec73fa6a93 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -79,6 +79,28 @@ i915_gem_init_ioctl(struct drm_device *dev, void *data,
79 return 0; 79 return 0;
80} 80}
81 81
82int
83i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
84 struct drm_file *file_priv)
85{
86 drm_i915_private_t *dev_priv = dev->dev_private;
87 struct drm_i915_gem_get_aperture *args = data;
88 struct drm_i915_gem_object *obj_priv;
89
90 if (!(dev->driver->driver_features & DRIVER_GEM))
91 return -ENODEV;
92
93 args->aper_size = dev->gtt_total;
94 args->aper_available_size = args->aper_size;
95
96 list_for_each_entry(obj_priv, &dev_priv->mm.active_list, list) {
97 if (obj_priv->pin_count > 0)
98 args->aper_available_size -= obj_priv->obj->size;
99 }
100
101 return 0;
102}
103
82 104
83/** 105/**
84 * Creates a new mm object and returns a handle to it. 106 * Creates a new mm object and returns a handle to it.
@@ -171,35 +193,50 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
171 return 0; 193 return 0;
172} 194}
173 195
174/* 196/* This is the fast write path which cannot handle
175 * Try to write quickly with an atomic kmap. Return true on success. 197 * page faults in the source data
176 *
177 * If this fails (which includes a partial write), we'll redo the whole
178 * thing with the slow version.
179 *
180 * This is a workaround for the low performance of iounmap (approximate
181 * 10% cpu cost on normal 3D workloads). kmap_atomic on HIGHMEM kernels
182 * happens to let us map card memory without taking IPIs. When the vmap
183 * rework lands we should be able to dump this hack.
184 */ 198 */
185static inline int fast_user_write(unsigned long pfn, char __user *user_data, 199
186 int l, int o) 200static inline int
201fast_user_write(struct io_mapping *mapping,
202 loff_t page_base, int page_offset,
203 char __user *user_data,
204 int length)
187{ 205{
188#ifdef CONFIG_HIGHMEM
189 unsigned long unwritten;
190 char *vaddr_atomic; 206 char *vaddr_atomic;
207 unsigned long unwritten;
191 208
192 vaddr_atomic = kmap_atomic_pfn(pfn, KM_USER0); 209 vaddr_atomic = io_mapping_map_atomic_wc(mapping, page_base);
193#if WATCH_PWRITE 210 unwritten = __copy_from_user_inatomic_nocache(vaddr_atomic + page_offset,
194 DRM_INFO("pwrite i %d o %d l %d pfn %ld vaddr %p\n", 211 user_data, length);
195 i, o, l, pfn, vaddr_atomic); 212 io_mapping_unmap_atomic(vaddr_atomic);
196#endif 213 if (unwritten)
197 unwritten = __copy_from_user_inatomic_nocache(vaddr_atomic + o, user_data, l); 214 return -EFAULT;
198 kunmap_atomic(vaddr_atomic, KM_USER0); 215 return 0;
199 return !unwritten; 216}
200#else 217
218/* Here's the write path which can sleep for
219 * page faults
220 */
221
222static inline int
223slow_user_write(struct io_mapping *mapping,
224 loff_t page_base, int page_offset,
225 char __user *user_data,
226 int length)
227{
228 char __iomem *vaddr;
229 unsigned long unwritten;
230
231 vaddr = io_mapping_map_wc(mapping, page_base);
232 if (vaddr == NULL)
233 return -EFAULT;
234 unwritten = __copy_from_user(vaddr + page_offset,
235 user_data, length);
236 io_mapping_unmap(vaddr);
237 if (unwritten)
238 return -EFAULT;
201 return 0; 239 return 0;
202#endif
203} 240}
204 241
205static int 242static int
@@ -208,10 +245,12 @@ i915_gem_gtt_pwrite(struct drm_device *dev, struct drm_gem_object *obj,
208 struct drm_file *file_priv) 245 struct drm_file *file_priv)
209{ 246{
210 struct drm_i915_gem_object *obj_priv = obj->driver_private; 247 struct drm_i915_gem_object *obj_priv = obj->driver_private;
248 drm_i915_private_t *dev_priv = dev->dev_private;
211 ssize_t remain; 249 ssize_t remain;
212 loff_t offset; 250 loff_t offset, page_base;
213 char __user *user_data; 251 char __user *user_data;
214 int ret = 0; 252 int page_offset, page_length;
253 int ret;
215 254
216 user_data = (char __user *) (uintptr_t) args->data_ptr; 255 user_data = (char __user *) (uintptr_t) args->data_ptr;
217 remain = args->size; 256 remain = args->size;
@@ -235,57 +274,37 @@ i915_gem_gtt_pwrite(struct drm_device *dev, struct drm_gem_object *obj,
235 obj_priv->dirty = 1; 274 obj_priv->dirty = 1;
236 275
237 while (remain > 0) { 276 while (remain > 0) {
238 unsigned long pfn;
239 int i, o, l;
240
241 /* Operation in this page 277 /* Operation in this page
242 * 278 *
243 * i = page number 279 * page_base = page offset within aperture
244 * o = offset within page 280 * page_offset = offset within page
245 * l = bytes to copy 281 * page_length = bytes to copy for this page
246 */ 282 */
247 i = offset >> PAGE_SHIFT; 283 page_base = (offset & ~(PAGE_SIZE-1));
248 o = offset & (PAGE_SIZE-1); 284 page_offset = offset & (PAGE_SIZE-1);
249 l = remain; 285 page_length = remain;
250 if ((o + l) > PAGE_SIZE) 286 if ((page_offset + remain) > PAGE_SIZE)
251 l = PAGE_SIZE - o; 287 page_length = PAGE_SIZE - page_offset;
252 288
253 pfn = (dev->agp->base >> PAGE_SHIFT) + i; 289 ret = fast_user_write (dev_priv->mm.gtt_mapping, page_base,
254 290 page_offset, user_data, page_length);
255 if (!fast_user_write(pfn, user_data, l, o)) { 291
256 unsigned long unwritten; 292 /* If we get a fault while copying data, then (presumably) our
257 char __iomem *vaddr; 293 * source page isn't available. In this case, use the
258 294 * non-atomic function
259 vaddr = ioremap_wc(pfn << PAGE_SHIFT, PAGE_SIZE); 295 */
260#if WATCH_PWRITE 296 if (ret) {
261 DRM_INFO("pwrite slow i %d o %d l %d " 297 ret = slow_user_write (dev_priv->mm.gtt_mapping,
262 "pfn %ld vaddr %p\n", 298 page_base, page_offset,
263 i, o, l, pfn, vaddr); 299 user_data, page_length);
264#endif 300 if (ret)
265 if (vaddr == NULL) {
266 ret = -EFAULT;
267 goto fail;
268 }
269 unwritten = __copy_from_user(vaddr + o, user_data, l);
270#if WATCH_PWRITE
271 DRM_INFO("unwritten %ld\n", unwritten);
272#endif
273 iounmap(vaddr);
274 if (unwritten) {
275 ret = -EFAULT;
276 goto fail; 301 goto fail;
277 }
278 } 302 }
279 303
280 remain -= l; 304 remain -= page_length;
281 user_data += l; 305 user_data += page_length;
282 offset += l; 306 offset += page_length;
283 } 307 }
284#if WATCH_PWRITE && 1
285 i915_gem_clflush_object(obj);
286 i915_gem_dump_object(obj, args->offset + args->size, __func__, ~0);
287 i915_gem_clflush_object(obj);
288#endif
289 308
290fail: 309fail:
291 i915_gem_object_unpin(obj); 310 i915_gem_object_unpin(obj);
@@ -1503,12 +1522,12 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj,
1503 struct drm_i915_gem_exec_object *entry) 1522 struct drm_i915_gem_exec_object *entry)
1504{ 1523{
1505 struct drm_device *dev = obj->dev; 1524 struct drm_device *dev = obj->dev;
1525 drm_i915_private_t *dev_priv = dev->dev_private;
1506 struct drm_i915_gem_relocation_entry reloc; 1526 struct drm_i915_gem_relocation_entry reloc;
1507 struct drm_i915_gem_relocation_entry __user *relocs; 1527 struct drm_i915_gem_relocation_entry __user *relocs;
1508 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1528 struct drm_i915_gem_object *obj_priv = obj->driver_private;
1509 int i, ret; 1529 int i, ret;
1510 uint32_t last_reloc_offset = -1; 1530 void __iomem *reloc_page;
1511 void __iomem *reloc_page = NULL;
1512 1531
1513 /* Choose the GTT offset for our buffer and put it there. */ 1532 /* Choose the GTT offset for our buffer and put it there. */
1514 ret = i915_gem_object_pin(obj, (uint32_t) entry->alignment); 1533 ret = i915_gem_object_pin(obj, (uint32_t) entry->alignment);
@@ -1631,26 +1650,11 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj,
1631 * perform. 1650 * perform.
1632 */ 1651 */
1633 reloc_offset = obj_priv->gtt_offset + reloc.offset; 1652 reloc_offset = obj_priv->gtt_offset + reloc.offset;
1634 if (reloc_page == NULL || 1653 reloc_page = io_mapping_map_atomic_wc(dev_priv->mm.gtt_mapping,
1635 (last_reloc_offset & ~(PAGE_SIZE - 1)) != 1654 (reloc_offset &
1636 (reloc_offset & ~(PAGE_SIZE - 1))) { 1655 ~(PAGE_SIZE - 1)));
1637 if (reloc_page != NULL)
1638 iounmap(reloc_page);
1639
1640 reloc_page = ioremap_wc(dev->agp->base +
1641 (reloc_offset &
1642 ~(PAGE_SIZE - 1)),
1643 PAGE_SIZE);
1644 last_reloc_offset = reloc_offset;
1645 if (reloc_page == NULL) {
1646 drm_gem_object_unreference(target_obj);
1647 i915_gem_object_unpin(obj);
1648 return -ENOMEM;
1649 }
1650 }
1651
1652 reloc_entry = (uint32_t __iomem *)(reloc_page + 1656 reloc_entry = (uint32_t __iomem *)(reloc_page +
1653 (reloc_offset & (PAGE_SIZE - 1))); 1657 (reloc_offset & (PAGE_SIZE - 1)));
1654 reloc_val = target_obj_priv->gtt_offset + reloc.delta; 1658 reloc_val = target_obj_priv->gtt_offset + reloc.delta;
1655 1659
1656#if WATCH_BUF 1660#if WATCH_BUF
@@ -1659,6 +1663,7 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj,
1659 readl(reloc_entry), reloc_val); 1663 readl(reloc_entry), reloc_val);
1660#endif 1664#endif
1661 writel(reloc_val, reloc_entry); 1665 writel(reloc_val, reloc_entry);
1666 io_mapping_unmap_atomic(reloc_page);
1662 1667
1663 /* Write the updated presumed offset for this entry back out 1668 /* Write the updated presumed offset for this entry back out
1664 * to the user. 1669 * to the user.
@@ -1674,9 +1679,6 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj,
1674 drm_gem_object_unreference(target_obj); 1679 drm_gem_object_unreference(target_obj);
1675 } 1680 }
1676 1681
1677 if (reloc_page != NULL)
1678 iounmap(reloc_page);
1679
1680#if WATCH_BUF 1682#if WATCH_BUF
1681 if (0) 1683 if (0)
1682 i915_gem_dump_object(obj, 128, __func__, ~0); 1684 i915_gem_dump_object(obj, 128, __func__, ~0);
@@ -2518,6 +2520,10 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
2518 if (ret != 0) 2520 if (ret != 0)
2519 return ret; 2521 return ret;
2520 2522
2523 dev_priv->mm.gtt_mapping = io_mapping_create_wc(dev->agp->base,
2524 dev->agp->agp_info.aper_size
2525 * 1024 * 1024);
2526
2521 mutex_lock(&dev->struct_mutex); 2527 mutex_lock(&dev->struct_mutex);
2522 BUG_ON(!list_empty(&dev_priv->mm.active_list)); 2528 BUG_ON(!list_empty(&dev_priv->mm.active_list));
2523 BUG_ON(!list_empty(&dev_priv->mm.flushing_list)); 2529 BUG_ON(!list_empty(&dev_priv->mm.flushing_list));
@@ -2535,11 +2541,13 @@ int
2535i915_gem_leavevt_ioctl(struct drm_device *dev, void *data, 2541i915_gem_leavevt_ioctl(struct drm_device *dev, void *data,
2536 struct drm_file *file_priv) 2542 struct drm_file *file_priv)
2537{ 2543{
2544 drm_i915_private_t *dev_priv = dev->dev_private;
2538 int ret; 2545 int ret;
2539 2546
2540 ret = i915_gem_idle(dev); 2547 ret = i915_gem_idle(dev);
2541 drm_irq_uninstall(dev); 2548 drm_irq_uninstall(dev);
2542 2549
2550 io_mapping_free(dev_priv->mm.gtt_mapping);
2543 return ret; 2551 return ret;
2544} 2552}
2545 2553
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
index 59a2132a8f57..073894824e6b 100644
--- a/drivers/gpu/drm/radeon/radeon_cp.c
+++ b/drivers/gpu/drm/radeon/radeon_cp.c
@@ -653,15 +653,16 @@ static void radeon_cp_init_ring_buffer(struct drm_device * dev,
653 RADEON_WRITE(RADEON_SCRATCH_UMSK, 0x7); 653 RADEON_WRITE(RADEON_SCRATCH_UMSK, 0x7);
654 654
655 /* Turn on bus mastering */ 655 /* Turn on bus mastering */
656 if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS400) || 656 if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) ||
657 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) ||
658 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740)) { 657 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740)) {
659 /* rs400, rs690/rs740 */ 658 /* rs600/rs690/rs740 */
660 tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RS400_BUS_MASTER_DIS; 659 tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RS600_BUS_MASTER_DIS;
661 RADEON_WRITE(RADEON_BUS_CNTL, tmp); 660 RADEON_WRITE(RADEON_BUS_CNTL, tmp);
662 } else if (!(((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV380) || 661 } else if (((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV350) ||
663 ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R423))) { 662 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R420) ||
664 /* r1xx, r2xx, r300, r(v)350, r420/r481, rs480 */ 663 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS400) ||
664 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS480)) {
665 /* r1xx, r2xx, r300, r(v)350, r420/r481, rs400/rs480 */
665 tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RADEON_BUS_MASTER_DIS; 666 tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RADEON_BUS_MASTER_DIS;
666 RADEON_WRITE(RADEON_BUS_CNTL, tmp); 667 RADEON_WRITE(RADEON_BUS_CNTL, tmp);
667 } /* PCIE cards appears to not need this */ 668 } /* PCIE cards appears to not need this */
diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
index 4dbb813910c3..02f5575ba395 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.h
+++ b/drivers/gpu/drm/radeon/radeon_drv.h
@@ -447,12 +447,12 @@ extern int r300_do_cp_cmdbuf(struct drm_device *dev,
447 * handling, not bus mastering itself. 447 * handling, not bus mastering itself.
448 */ 448 */
449#define RADEON_BUS_CNTL 0x0030 449#define RADEON_BUS_CNTL 0x0030
450/* r1xx, r2xx, r300, r(v)350, r420/r481, rs480 */ 450/* r1xx, r2xx, r300, r(v)350, r420/r481, rs400/rs480 */
451# define RADEON_BUS_MASTER_DIS (1 << 6) 451# define RADEON_BUS_MASTER_DIS (1 << 6)
452/* rs400, rs690/rs740 */ 452/* rs600/rs690/rs740 */
453# define RS400_BUS_MASTER_DIS (1 << 14) 453# define RS600_BUS_MASTER_DIS (1 << 14)
454# define RS400_MSI_REARM (1 << 20) 454# define RS600_MSI_REARM (1 << 20)
455/* see RS480_MSI_REARM in AIC_CNTL for rs480 */ 455/* see RS400_MSI_REARM in AIC_CNTL for rs480 */
456 456
457#define RADEON_BUS_CNTL1 0x0034 457#define RADEON_BUS_CNTL1 0x0034
458# define RADEON_PMI_BM_DIS (1 << 2) 458# define RADEON_PMI_BM_DIS (1 << 2)
@@ -937,7 +937,7 @@ extern int r300_do_cp_cmdbuf(struct drm_device *dev,
937 937
938#define RADEON_AIC_CNTL 0x01d0 938#define RADEON_AIC_CNTL 0x01d0
939# define RADEON_PCIGART_TRANSLATE_EN (1 << 0) 939# define RADEON_PCIGART_TRANSLATE_EN (1 << 0)
940# define RS480_MSI_REARM (1 << 3) 940# define RS400_MSI_REARM (1 << 3)
941#define RADEON_AIC_STAT 0x01d4 941#define RADEON_AIC_STAT 0x01d4
942#define RADEON_AIC_PT_BASE 0x01d8 942#define RADEON_AIC_PT_BASE 0x01d8
943#define RADEON_AIC_LO_ADDR 0x01dc 943#define RADEON_AIC_LO_ADDR 0x01dc
diff --git a/fs/proc/uptime.c b/fs/proc/uptime.c
index 0c10a0b3f146..df26aa88fa47 100644
--- a/fs/proc/uptime.c
+++ b/fs/proc/uptime.c
@@ -1,43 +1,45 @@
1#include <linux/fs.h>
2#include <linux/init.h> 1#include <linux/init.h>
3#include <linux/proc_fs.h> 2#include <linux/proc_fs.h>
4#include <linux/sched.h> 3#include <linux/sched.h>
5#include <linux/seq_file.h>
6#include <linux/time.h> 4#include <linux/time.h>
7#include <asm/cputime.h> 5#include <asm/cputime.h>
8 6
9static int uptime_proc_show(struct seq_file *m, void *v) 7static int proc_calc_metrics(char *page, char **start, off_t off,
8 int count, int *eof, int len)
9{
10 if (len <= off + count)
11 *eof = 1;
12 *start = page + off;
13 len -= off;
14 if (len > count)
15 len = count;
16 if (len < 0)
17 len = 0;
18 return len;
19}
20
21static int uptime_read_proc(char *page, char **start, off_t off, int count,
22 int *eof, void *data)
10{ 23{
11 struct timespec uptime; 24 struct timespec uptime;
12 struct timespec idle; 25 struct timespec idle;
26 int len;
13 cputime_t idletime = cputime_add(init_task.utime, init_task.stime); 27 cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
14 28
15 do_posix_clock_monotonic_gettime(&uptime); 29 do_posix_clock_monotonic_gettime(&uptime);
16 monotonic_to_bootbased(&uptime); 30 monotonic_to_bootbased(&uptime);
17 cputime_to_timespec(idletime, &idle); 31 cputime_to_timespec(idletime, &idle);
18 seq_printf(m, "%lu.%02lu %lu.%02lu\n", 32 len = sprintf(page, "%lu.%02lu %lu.%02lu\n",
19 (unsigned long) uptime.tv_sec, 33 (unsigned long) uptime.tv_sec,
20 (uptime.tv_nsec / (NSEC_PER_SEC / 100)), 34 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
21 (unsigned long) idle.tv_sec, 35 (unsigned long) idle.tv_sec,
22 (idle.tv_nsec / (NSEC_PER_SEC / 100))); 36 (idle.tv_nsec / (NSEC_PER_SEC / 100)));
23 return 0; 37 return proc_calc_metrics(page, start, off, count, eof, len);
24} 38}
25 39
26static int uptime_proc_open(struct inode *inode, struct file *file)
27{
28 return single_open(file, uptime_proc_show, NULL);
29}
30
31static const struct file_operations uptime_proc_fops = {
32 .open = uptime_proc_open,
33 .read = seq_read,
34 .llseek = seq_lseek,
35 .release = single_release,
36};
37
38static int __init proc_uptime_init(void) 40static int __init proc_uptime_init(void)
39{ 41{
40 proc_create("uptime", 0, NULL, &uptime_proc_fops); 42 create_proc_read_entry("uptime", 0, NULL, uptime_read_proc, NULL);
41 return 0; 43 return 0;
42} 44}
43module_init(proc_uptime_init); 45module_init(proc_uptime_init);
diff --git a/include/asm-x86/iomap.h b/include/asm-x86/iomap.h
new file mode 100644
index 000000000000..c1f06289b14b
--- /dev/null
+++ b/include/asm-x86/iomap.h
@@ -0,0 +1,30 @@
1/*
2 * Copyright © 2008 Ingo Molnar
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 */
18
19#include <linux/fs.h>
20#include <linux/mm.h>
21#include <linux/uaccess.h>
22#include <asm/cacheflush.h>
23#include <asm/pgtable.h>
24#include <asm/tlbflush.h>
25
26void *
27iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot);
28
29void
30iounmap_atomic(void *kvaddr, enum km_type type);
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index eb4b35031a55..152b34da927c 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -159,6 +159,7 @@ typedef struct _drm_i915_sarea {
159#define DRM_I915_GEM_SW_FINISH 0x20 159#define DRM_I915_GEM_SW_FINISH 0x20
160#define DRM_I915_GEM_SET_TILING 0x21 160#define DRM_I915_GEM_SET_TILING 0x21
161#define DRM_I915_GEM_GET_TILING 0x22 161#define DRM_I915_GEM_GET_TILING 0x22
162#define DRM_I915_GEM_GET_APERTURE 0x23
162 163
163#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) 164#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
164#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) 165#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
@@ -190,6 +191,7 @@ typedef struct _drm_i915_sarea {
190#define DRM_IOCTL_I915_GEM_SW_FINISH DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SW_FINISH, struct drm_i915_gem_sw_finish) 191#define DRM_IOCTL_I915_GEM_SW_FINISH DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SW_FINISH, struct drm_i915_gem_sw_finish)
191#define DRM_IOCTL_I915_GEM_SET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling) 192#define DRM_IOCTL_I915_GEM_SET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling)
192#define DRM_IOCTL_I915_GEM_GET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_TILING, struct drm_i915_gem_get_tiling) 193#define DRM_IOCTL_I915_GEM_GET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_TILING, struct drm_i915_gem_get_tiling)
194#define DRM_IOCTL_I915_GEM_GET_APERTURE DRM_IOR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct drm_i915_gem_get_aperture)
193 195
194/* Allow drivers to submit batchbuffers directly to hardware, relying 196/* Allow drivers to submit batchbuffers directly to hardware, relying
195 * on the security mechanisms provided by hardware. 197 * on the security mechanisms provided by hardware.
@@ -600,4 +602,15 @@ struct drm_i915_gem_get_tiling {
600 uint32_t swizzle_mode; 602 uint32_t swizzle_mode;
601}; 603};
602 604
605struct drm_i915_gem_get_aperture {
606 /** Total size of the aperture used by i915_gem_execbuffer, in bytes */
607 uint64_t aper_size;
608
609 /**
610 * Available space in the aperture used by i915_gem_execbuffer, in
611 * bytes
612 */
613 uint64_t aper_available_size;
614};
615
603#endif /* _I915_DRM_H_ */ 616#endif /* _I915_DRM_H_ */
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 1b340e3fa249..1f5608c11023 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -23,6 +23,34 @@ struct ftrace_ops {
23 struct ftrace_ops *next; 23 struct ftrace_ops *next;
24}; 24};
25 25
26extern int function_trace_stop;
27
28/**
29 * ftrace_stop - stop function tracer.
30 *
31 * A quick way to stop the function tracer. Note this an on off switch,
32 * it is not something that is recursive like preempt_disable.
33 * This does not disable the calling of mcount, it only stops the
34 * calling of functions from mcount.
35 */
36static inline void ftrace_stop(void)
37{
38 function_trace_stop = 1;
39}
40
41/**
42 * ftrace_start - start the function tracer.
43 *
44 * This function is the inverse of ftrace_stop. This does not enable
45 * the function tracing if the function tracer is disabled. This only
46 * sets the function tracer flag to continue calling the functions
47 * from mcount.
48 */
49static inline void ftrace_start(void)
50{
51 function_trace_stop = 0;
52}
53
26/* 54/*
27 * The ftrace_ops must be a static and should also 55 * The ftrace_ops must be a static and should also
28 * be read_mostly. These functions do modify read_mostly variables 56 * be read_mostly. These functions do modify read_mostly variables
@@ -41,6 +69,8 @@ extern void ftrace_stub(unsigned long a0, unsigned long a1);
41# define unregister_ftrace_function(ops) do { } while (0) 69# define unregister_ftrace_function(ops) do { } while (0)
42# define clear_ftrace_function(ops) do { } while (0) 70# define clear_ftrace_function(ops) do { } while (0)
43static inline void ftrace_kill(void) { } 71static inline void ftrace_kill(void) { }
72static inline void ftrace_stop(void) { }
73static inline void ftrace_start(void) { }
44#endif /* CONFIG_FUNCTION_TRACER */ 74#endif /* CONFIG_FUNCTION_TRACER */
45 75
46#ifdef CONFIG_DYNAMIC_FTRACE 76#ifdef CONFIG_DYNAMIC_FTRACE
@@ -184,6 +214,9 @@ static inline void __ftrace_enabled_restore(int enabled)
184#ifdef CONFIG_TRACING 214#ifdef CONFIG_TRACING
185extern int ftrace_dump_on_oops; 215extern int ftrace_dump_on_oops;
186 216
217extern void tracing_start(void);
218extern void tracing_stop(void);
219
187extern void 220extern void
188ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); 221ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
189 222
@@ -214,6 +247,8 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
214static inline int 247static inline int
215ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0))); 248ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0)));
216 249
250static inline void tracing_start(void) { }
251static inline void tracing_stop(void) { }
217static inline int 252static inline int
218ftrace_printk(const char *fmt, ...) 253ftrace_printk(const char *fmt, ...)
219{ 254{
@@ -232,6 +267,11 @@ ftrace_init_module(unsigned long *start, unsigned long *end) { }
232#endif 267#endif
233 268
234 269
270/*
271 * Structure which defines the trace of an initcall.
272 * You don't have to fill the func field since it is
273 * only used internally by the tracer.
274 */
235struct boot_trace { 275struct boot_trace {
236 pid_t caller; 276 pid_t caller;
237 char func[KSYM_NAME_LEN]; 277 char func[KSYM_NAME_LEN];
@@ -242,13 +282,28 @@ struct boot_trace {
242}; 282};
243 283
244#ifdef CONFIG_BOOT_TRACER 284#ifdef CONFIG_BOOT_TRACER
285/* Append the trace on the ring-buffer */
245extern void trace_boot(struct boot_trace *it, initcall_t fn); 286extern void trace_boot(struct boot_trace *it, initcall_t fn);
287
288/* Tells the tracer that smp_pre_initcall is finished.
289 * So we can start the tracing
290 */
246extern void start_boot_trace(void); 291extern void start_boot_trace(void);
247extern void stop_boot_trace(void); 292
293/* Resume the tracing of other necessary events
294 * such as sched switches
295 */
296extern void enable_boot_trace(void);
297
298/* Suspend this tracing. Actually, only sched_switches tracing have
299 * to be suspended. Initcalls doesn't need it.)
300 */
301extern void disable_boot_trace(void);
248#else 302#else
249static inline void trace_boot(struct boot_trace *it, initcall_t fn) { } 303static inline void trace_boot(struct boot_trace *it, initcall_t fn) { }
250static inline void start_boot_trace(void) { } 304static inline void start_boot_trace(void) { }
251static inline void stop_boot_trace(void) { } 305static inline void enable_boot_trace(void) { }
306static inline void disable_boot_trace(void) { }
252#endif 307#endif
253 308
254 309
diff --git a/include/linux/io-mapping.h b/include/linux/io-mapping.h
new file mode 100644
index 000000000000..82df31726a54
--- /dev/null
+++ b/include/linux/io-mapping.h
@@ -0,0 +1,125 @@
1/*
2 * Copyright © 2008 Keith Packard <keithp@keithp.com>
3 *
4 * This file is free software; you can redistribute it and/or modify
5 * it under the terms of version 2 of the GNU General Public License
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
16 */
17
18#ifndef _LINUX_IO_MAPPING_H
19#define _LINUX_IO_MAPPING_H
20
21#include <linux/types.h>
22#include <asm/io.h>
23#include <asm/page.h>
24#include <asm/iomap.h>
25
26/*
27 * The io_mapping mechanism provides an abstraction for mapping
28 * individual pages from an io device to the CPU in an efficient fashion.
29 *
30 * See Documentation/io_mapping.txt
31 */
32
33/* this struct isn't actually defined anywhere */
34struct io_mapping;
35
36#ifdef CONFIG_HAVE_ATOMIC_IOMAP
37
38/*
39 * For small address space machines, mapping large objects
40 * into the kernel virtual space isn't practical. Where
41 * available, use fixmap support to dynamically map pages
42 * of the object at run time.
43 */
44
45static inline struct io_mapping *
46io_mapping_create_wc(unsigned long base, unsigned long size)
47{
48 return (struct io_mapping *) base;
49}
50
51static inline void
52io_mapping_free(struct io_mapping *mapping)
53{
54}
55
56/* Atomic map/unmap */
57static inline void *
58io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset)
59{
60 offset += (unsigned long) mapping;
61 return iomap_atomic_prot_pfn(offset >> PAGE_SHIFT, KM_USER0,
62 __pgprot(__PAGE_KERNEL_WC));
63}
64
65static inline void
66io_mapping_unmap_atomic(void *vaddr)
67{
68 iounmap_atomic(vaddr, KM_USER0);
69}
70
71static inline void *
72io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset)
73{
74 offset += (unsigned long) mapping;
75 return ioremap_wc(offset, PAGE_SIZE);
76}
77
78static inline void
79io_mapping_unmap(void *vaddr)
80{
81 iounmap(vaddr);
82}
83
84#else
85
86/* Create the io_mapping object*/
87static inline struct io_mapping *
88io_mapping_create_wc(unsigned long base, unsigned long size)
89{
90 return (struct io_mapping *) ioremap_wc(base, size);
91}
92
93static inline void
94io_mapping_free(struct io_mapping *mapping)
95{
96 iounmap(mapping);
97}
98
99/* Atomic map/unmap */
100static inline void *
101io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset)
102{
103 return ((char *) mapping) + offset;
104}
105
106static inline void
107io_mapping_unmap_atomic(void *vaddr)
108{
109}
110
111/* Non-atomic map/unmap */
112static inline void *
113io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset)
114{
115 return ((char *) mapping) + offset;
116}
117
118static inline void
119io_mapping_unmap(void *vaddr)
120{
121}
122
123#endif /* HAVE_ATOMIC_IOMAP */
124
125#endif /* _LINUX_IO_MAPPING_H */
diff --git a/init/main.c b/init/main.c
index 7e117a231af1..4b03cd5656ca 100644
--- a/init/main.c
+++ b/init/main.c
@@ -711,6 +711,7 @@ int do_one_initcall(initcall_t fn)
711 it.caller = task_pid_nr(current); 711 it.caller = task_pid_nr(current);
712 printk("calling %pF @ %i\n", fn, it.caller); 712 printk("calling %pF @ %i\n", fn, it.caller);
713 it.calltime = ktime_get(); 713 it.calltime = ktime_get();
714 enable_boot_trace();
714 } 715 }
715 716
716 it.result = fn(); 717 it.result = fn();
@@ -722,6 +723,7 @@ int do_one_initcall(initcall_t fn)
722 printk("initcall %pF returned %d after %Ld usecs\n", fn, 723 printk("initcall %pF returned %d after %Ld usecs\n", fn,
723 it.result, it.duration); 724 it.result, it.duration);
724 trace_boot(&it, fn); 725 trace_boot(&it, fn);
726 disable_boot_trace();
725 } 727 }
726 728
727 msgbuf[0] = 0; 729 msgbuf[0] = 0;
@@ -882,7 +884,7 @@ static int __init kernel_init(void * unused)
882 * we're essentially up and running. Get rid of the 884 * we're essentially up and running. Get rid of the
883 * initmem segments and start the user-mode stuff.. 885 * initmem segments and start the user-mode stuff..
884 */ 886 */
885 stop_boot_trace(); 887
886 init_post(); 888 init_post();
887 return 0; 889 return 0;
888} 890}
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 6b6b727258b5..65d4a9ba79e4 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -487,7 +487,7 @@ static struct ctl_table kern_table[] = {
487#ifdef CONFIG_TRACING 487#ifdef CONFIG_TRACING
488 { 488 {
489 .ctl_name = CTL_UNNUMBERED, 489 .ctl_name = CTL_UNNUMBERED,
490 .procname = "ftrace_dump_on_opps", 490 .procname = "ftrace_dump_on_oops",
491 .data = &ftrace_dump_on_oops, 491 .data = &ftrace_dump_on_oops,
492 .maxlen = sizeof(int), 492 .maxlen = sizeof(int),
493 .mode = 0644, 493 .mode = 0644,
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 33dbefd471e8..fc4febc3334a 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -9,6 +9,13 @@ config NOP_TRACER
9config HAVE_FUNCTION_TRACER 9config HAVE_FUNCTION_TRACER
10 bool 10 bool
11 11
12config HAVE_FUNCTION_TRACE_MCOUNT_TEST
13 bool
14 help
15 This gets selected when the arch tests the function_trace_stop
16 variable at the mcount call site. Otherwise, this variable
17 is tested by the called function.
18
12config HAVE_DYNAMIC_FTRACE 19config HAVE_DYNAMIC_FTRACE
13 bool 20 bool
14 21
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 4a39d24568c8..896c71f0f4c4 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -47,6 +47,9 @@
47int ftrace_enabled __read_mostly; 47int ftrace_enabled __read_mostly;
48static int last_ftrace_enabled; 48static int last_ftrace_enabled;
49 49
50/* Quick disabling of function tracer. */
51int function_trace_stop;
52
50/* 53/*
51 * ftrace_disabled is set when an anomaly is discovered. 54 * ftrace_disabled is set when an anomaly is discovered.
52 * ftrace_disabled is much stronger than ftrace_enabled. 55 * ftrace_disabled is much stronger than ftrace_enabled.
@@ -63,6 +66,7 @@ static struct ftrace_ops ftrace_list_end __read_mostly =
63 66
64static struct ftrace_ops *ftrace_list __read_mostly = &ftrace_list_end; 67static struct ftrace_ops *ftrace_list __read_mostly = &ftrace_list_end;
65ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub; 68ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub;
69ftrace_func_t __ftrace_trace_function __read_mostly = ftrace_stub;
66 70
67static void ftrace_list_func(unsigned long ip, unsigned long parent_ip) 71static void ftrace_list_func(unsigned long ip, unsigned long parent_ip)
68{ 72{
@@ -88,8 +92,23 @@ static void ftrace_list_func(unsigned long ip, unsigned long parent_ip)
88void clear_ftrace_function(void) 92void clear_ftrace_function(void)
89{ 93{
90 ftrace_trace_function = ftrace_stub; 94 ftrace_trace_function = ftrace_stub;
95 __ftrace_trace_function = ftrace_stub;
91} 96}
92 97
98#ifndef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST
99/*
100 * For those archs that do not test ftrace_trace_stop in their
101 * mcount call site, we need to do it from C.
102 */
103static void ftrace_test_stop_func(unsigned long ip, unsigned long parent_ip)
104{
105 if (function_trace_stop)
106 return;
107
108 __ftrace_trace_function(ip, parent_ip);
109}
110#endif
111
93static int __register_ftrace_function(struct ftrace_ops *ops) 112static int __register_ftrace_function(struct ftrace_ops *ops)
94{ 113{
95 /* should not be called from interrupt context */ 114 /* should not be called from interrupt context */
@@ -110,10 +129,18 @@ static int __register_ftrace_function(struct ftrace_ops *ops)
110 * For one func, simply call it directly. 129 * For one func, simply call it directly.
111 * For more than one func, call the chain. 130 * For more than one func, call the chain.
112 */ 131 */
132#ifdef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST
113 if (ops->next == &ftrace_list_end) 133 if (ops->next == &ftrace_list_end)
114 ftrace_trace_function = ops->func; 134 ftrace_trace_function = ops->func;
115 else 135 else
116 ftrace_trace_function = ftrace_list_func; 136 ftrace_trace_function = ftrace_list_func;
137#else
138 if (ops->next == &ftrace_list_end)
139 __ftrace_trace_function = ops->func;
140 else
141 __ftrace_trace_function = ftrace_list_func;
142 ftrace_trace_function = ftrace_test_stop_func;
143#endif
117 } 144 }
118 145
119 spin_unlock(&ftrace_lock); 146 spin_unlock(&ftrace_lock);
@@ -526,7 +553,7 @@ static void ftrace_run_update_code(int command)
526} 553}
527 554
528static ftrace_func_t saved_ftrace_func; 555static ftrace_func_t saved_ftrace_func;
529static int ftrace_start; 556static int ftrace_start_up;
530static DEFINE_MUTEX(ftrace_start_lock); 557static DEFINE_MUTEX(ftrace_start_lock);
531 558
532static void ftrace_startup(void) 559static void ftrace_startup(void)
@@ -537,8 +564,8 @@ static void ftrace_startup(void)
537 return; 564 return;
538 565
539 mutex_lock(&ftrace_start_lock); 566 mutex_lock(&ftrace_start_lock);
540 ftrace_start++; 567 ftrace_start_up++;
541 if (ftrace_start == 1) 568 if (ftrace_start_up == 1)
542 command |= FTRACE_ENABLE_CALLS; 569 command |= FTRACE_ENABLE_CALLS;
543 570
544 if (saved_ftrace_func != ftrace_trace_function) { 571 if (saved_ftrace_func != ftrace_trace_function) {
@@ -562,8 +589,8 @@ static void ftrace_shutdown(void)
562 return; 589 return;
563 590
564 mutex_lock(&ftrace_start_lock); 591 mutex_lock(&ftrace_start_lock);
565 ftrace_start--; 592 ftrace_start_up--;
566 if (!ftrace_start) 593 if (!ftrace_start_up)
567 command |= FTRACE_DISABLE_CALLS; 594 command |= FTRACE_DISABLE_CALLS;
568 595
569 if (saved_ftrace_func != ftrace_trace_function) { 596 if (saved_ftrace_func != ftrace_trace_function) {
@@ -589,8 +616,8 @@ static void ftrace_startup_sysctl(void)
589 mutex_lock(&ftrace_start_lock); 616 mutex_lock(&ftrace_start_lock);
590 /* Force update next time */ 617 /* Force update next time */
591 saved_ftrace_func = NULL; 618 saved_ftrace_func = NULL;
592 /* ftrace_start is true if we want ftrace running */ 619 /* ftrace_start_up is true if we want ftrace running */
593 if (ftrace_start) 620 if (ftrace_start_up)
594 command |= FTRACE_ENABLE_CALLS; 621 command |= FTRACE_ENABLE_CALLS;
595 622
596 ftrace_run_update_code(command); 623 ftrace_run_update_code(command);
@@ -605,8 +632,8 @@ static void ftrace_shutdown_sysctl(void)
605 return; 632 return;
606 633
607 mutex_lock(&ftrace_start_lock); 634 mutex_lock(&ftrace_start_lock);
608 /* ftrace_start is true if ftrace is running */ 635 /* ftrace_start_up is true if ftrace is running */
609 if (ftrace_start) 636 if (ftrace_start_up)
610 command |= FTRACE_DISABLE_CALLS; 637 command |= FTRACE_DISABLE_CALLS;
611 638
612 ftrace_run_update_code(command); 639 ftrace_run_update_code(command);
@@ -1186,7 +1213,7 @@ ftrace_regex_release(struct inode *inode, struct file *file, int enable)
1186 1213
1187 mutex_lock(&ftrace_sysctl_lock); 1214 mutex_lock(&ftrace_sysctl_lock);
1188 mutex_lock(&ftrace_start_lock); 1215 mutex_lock(&ftrace_start_lock);
1189 if (iter->filtered && ftrace_start && ftrace_enabled) 1216 if (iter->filtered && ftrace_start_up && ftrace_enabled)
1190 ftrace_run_update_code(FTRACE_ENABLE_CALLS); 1217 ftrace_run_update_code(FTRACE_ENABLE_CALLS);
1191 mutex_unlock(&ftrace_start_lock); 1218 mutex_unlock(&ftrace_start_lock);
1192 mutex_unlock(&ftrace_sysctl_lock); 1219 mutex_unlock(&ftrace_sysctl_lock);
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index cedf4e268285..6781e9aab2c0 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -16,6 +16,8 @@
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/fs.h> 17#include <linux/fs.h>
18 18
19#include "trace.h"
20
19/* Up this if you want to test the TIME_EXTENTS and normalization */ 21/* Up this if you want to test the TIME_EXTENTS and normalization */
20#define DEBUG_SHIFT 0 22#define DEBUG_SHIFT 0
21 23
@@ -152,7 +154,7 @@ static inline int test_time_stamp(u64 delta)
152struct ring_buffer_per_cpu { 154struct ring_buffer_per_cpu {
153 int cpu; 155 int cpu;
154 struct ring_buffer *buffer; 156 struct ring_buffer *buffer;
155 spinlock_t lock; 157 raw_spinlock_t lock;
156 struct lock_class_key lock_key; 158 struct lock_class_key lock_key;
157 struct list_head pages; 159 struct list_head pages;
158 struct buffer_page *head_page; /* read from head */ 160 struct buffer_page *head_page; /* read from head */
@@ -289,7 +291,7 @@ rb_allocate_cpu_buffer(struct ring_buffer *buffer, int cpu)
289 291
290 cpu_buffer->cpu = cpu; 292 cpu_buffer->cpu = cpu;
291 cpu_buffer->buffer = buffer; 293 cpu_buffer->buffer = buffer;
292 spin_lock_init(&cpu_buffer->lock); 294 cpu_buffer->lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
293 INIT_LIST_HEAD(&cpu_buffer->pages); 295 INIT_LIST_HEAD(&cpu_buffer->pages);
294 296
295 page = kzalloc_node(ALIGN(sizeof(*page), cache_line_size()), 297 page = kzalloc_node(ALIGN(sizeof(*page), cache_line_size()),
@@ -852,7 +854,8 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
852 if (write > BUF_PAGE_SIZE) { 854 if (write > BUF_PAGE_SIZE) {
853 struct buffer_page *next_page = tail_page; 855 struct buffer_page *next_page = tail_page;
854 856
855 spin_lock_irqsave(&cpu_buffer->lock, flags); 857 local_irq_save(flags);
858 __raw_spin_lock(&cpu_buffer->lock);
856 859
857 rb_inc_page(cpu_buffer, &next_page); 860 rb_inc_page(cpu_buffer, &next_page);
858 861
@@ -928,7 +931,8 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
928 rb_set_commit_to_write(cpu_buffer); 931 rb_set_commit_to_write(cpu_buffer);
929 } 932 }
930 933
931 spin_unlock_irqrestore(&cpu_buffer->lock, flags); 934 __raw_spin_unlock(&cpu_buffer->lock);
935 local_irq_restore(flags);
932 936
933 /* fail and let the caller try again */ 937 /* fail and let the caller try again */
934 return ERR_PTR(-EAGAIN); 938 return ERR_PTR(-EAGAIN);
@@ -951,7 +955,8 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
951 return event; 955 return event;
952 956
953 out_unlock: 957 out_unlock:
954 spin_unlock_irqrestore(&cpu_buffer->lock, flags); 958 __raw_spin_unlock(&cpu_buffer->lock);
959 local_irq_restore(flags);
955 return NULL; 960 return NULL;
956} 961}
957 962
@@ -1022,8 +1027,23 @@ rb_reserve_next_event(struct ring_buffer_per_cpu *cpu_buffer,
1022 struct ring_buffer_event *event; 1027 struct ring_buffer_event *event;
1023 u64 ts, delta; 1028 u64 ts, delta;
1024 int commit = 0; 1029 int commit = 0;
1030 int nr_loops = 0;
1025 1031
1026 again: 1032 again:
1033 /*
1034 * We allow for interrupts to reenter here and do a trace.
1035 * If one does, it will cause this original code to loop
1036 * back here. Even with heavy interrupts happening, this
1037 * should only happen a few times in a row. If this happens
1038 * 1000 times in a row, there must be either an interrupt
1039 * storm or we have something buggy.
1040 * Bail!
1041 */
1042 if (unlikely(++nr_loops > 1000)) {
1043 RB_WARN_ON(cpu_buffer, 1);
1044 return NULL;
1045 }
1046
1027 ts = ring_buffer_time_stamp(cpu_buffer->cpu); 1047 ts = ring_buffer_time_stamp(cpu_buffer->cpu);
1028 1048
1029 /* 1049 /*
@@ -1122,8 +1142,7 @@ ring_buffer_lock_reserve(struct ring_buffer *buffer,
1122 return NULL; 1142 return NULL;
1123 1143
1124 /* If we are tracing schedule, we don't want to recurse */ 1144 /* If we are tracing schedule, we don't want to recurse */
1125 resched = need_resched(); 1145 resched = ftrace_preempt_disable();
1126 preempt_disable_notrace();
1127 1146
1128 cpu = raw_smp_processor_id(); 1147 cpu = raw_smp_processor_id();
1129 1148
@@ -1154,10 +1173,7 @@ ring_buffer_lock_reserve(struct ring_buffer *buffer,
1154 return event; 1173 return event;
1155 1174
1156 out: 1175 out:
1157 if (resched) 1176 ftrace_preempt_enable(resched);
1158 preempt_enable_notrace();
1159 else
1160 preempt_enable_notrace();
1161 return NULL; 1177 return NULL;
1162} 1178}
1163 1179
@@ -1199,12 +1215,9 @@ int ring_buffer_unlock_commit(struct ring_buffer *buffer,
1199 /* 1215 /*
1200 * Only the last preempt count needs to restore preemption. 1216 * Only the last preempt count needs to restore preemption.
1201 */ 1217 */
1202 if (preempt_count() == 1) { 1218 if (preempt_count() == 1)
1203 if (per_cpu(rb_need_resched, cpu)) 1219 ftrace_preempt_enable(per_cpu(rb_need_resched, cpu));
1204 preempt_enable_no_resched_notrace(); 1220 else
1205 else
1206 preempt_enable_notrace();
1207 } else
1208 preempt_enable_no_resched_notrace(); 1221 preempt_enable_no_resched_notrace();
1209 1222
1210 return 0; 1223 return 0;
@@ -1237,8 +1250,7 @@ int ring_buffer_write(struct ring_buffer *buffer,
1237 if (atomic_read(&buffer->record_disabled)) 1250 if (atomic_read(&buffer->record_disabled))
1238 return -EBUSY; 1251 return -EBUSY;
1239 1252
1240 resched = need_resched(); 1253 resched = ftrace_preempt_disable();
1241 preempt_disable_notrace();
1242 1254
1243 cpu = raw_smp_processor_id(); 1255 cpu = raw_smp_processor_id();
1244 1256
@@ -1264,10 +1276,7 @@ int ring_buffer_write(struct ring_buffer *buffer,
1264 1276
1265 ret = 0; 1277 ret = 0;
1266 out: 1278 out:
1267 if (resched) 1279 ftrace_preempt_enable(resched);
1268 preempt_enable_no_resched_notrace();
1269 else
1270 preempt_enable_notrace();
1271 1280
1272 return ret; 1281 return ret;
1273} 1282}
@@ -1532,10 +1541,24 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
1532{ 1541{
1533 struct buffer_page *reader = NULL; 1542 struct buffer_page *reader = NULL;
1534 unsigned long flags; 1543 unsigned long flags;
1544 int nr_loops = 0;
1535 1545
1536 spin_lock_irqsave(&cpu_buffer->lock, flags); 1546 local_irq_save(flags);
1547 __raw_spin_lock(&cpu_buffer->lock);
1537 1548
1538 again: 1549 again:
1550 /*
1551 * This should normally only loop twice. But because the
1552 * start of the reader inserts an empty page, it causes
1553 * a case where we will loop three times. There should be no
1554 * reason to loop four times (that I know of).
1555 */
1556 if (unlikely(++nr_loops > 3)) {
1557 RB_WARN_ON(cpu_buffer, 1);
1558 reader = NULL;
1559 goto out;
1560 }
1561
1539 reader = cpu_buffer->reader_page; 1562 reader = cpu_buffer->reader_page;
1540 1563
1541 /* If there's more to read, return this page */ 1564 /* If there's more to read, return this page */
@@ -1583,7 +1606,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
1583 goto again; 1606 goto again;
1584 1607
1585 out: 1608 out:
1586 spin_unlock_irqrestore(&cpu_buffer->lock, flags); 1609 __raw_spin_unlock(&cpu_buffer->lock);
1610 local_irq_restore(flags);
1587 1611
1588 return reader; 1612 return reader;
1589} 1613}
@@ -1665,6 +1689,7 @@ ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts)
1665 struct ring_buffer_per_cpu *cpu_buffer; 1689 struct ring_buffer_per_cpu *cpu_buffer;
1666 struct ring_buffer_event *event; 1690 struct ring_buffer_event *event;
1667 struct buffer_page *reader; 1691 struct buffer_page *reader;
1692 int nr_loops = 0;
1668 1693
1669 if (!cpu_isset(cpu, buffer->cpumask)) 1694 if (!cpu_isset(cpu, buffer->cpumask))
1670 return NULL; 1695 return NULL;
@@ -1672,6 +1697,19 @@ ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts)
1672 cpu_buffer = buffer->buffers[cpu]; 1697 cpu_buffer = buffer->buffers[cpu];
1673 1698
1674 again: 1699 again:
1700 /*
1701 * We repeat when a timestamp is encountered. It is possible
1702 * to get multiple timestamps from an interrupt entering just
1703 * as one timestamp is about to be written. The max times
1704 * that this can happen is the number of nested interrupts we
1705 * can have. Nesting 10 deep of interrupts is clearly
1706 * an anomaly.
1707 */
1708 if (unlikely(++nr_loops > 10)) {
1709 RB_WARN_ON(cpu_buffer, 1);
1710 return NULL;
1711 }
1712
1675 reader = rb_get_reader_page(cpu_buffer); 1713 reader = rb_get_reader_page(cpu_buffer);
1676 if (!reader) 1714 if (!reader)
1677 return NULL; 1715 return NULL;
@@ -1722,6 +1760,7 @@ ring_buffer_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
1722 struct ring_buffer *buffer; 1760 struct ring_buffer *buffer;
1723 struct ring_buffer_per_cpu *cpu_buffer; 1761 struct ring_buffer_per_cpu *cpu_buffer;
1724 struct ring_buffer_event *event; 1762 struct ring_buffer_event *event;
1763 int nr_loops = 0;
1725 1764
1726 if (ring_buffer_iter_empty(iter)) 1765 if (ring_buffer_iter_empty(iter))
1727 return NULL; 1766 return NULL;
@@ -1730,6 +1769,19 @@ ring_buffer_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
1730 buffer = cpu_buffer->buffer; 1769 buffer = cpu_buffer->buffer;
1731 1770
1732 again: 1771 again:
1772 /*
1773 * We repeat when a timestamp is encountered. It is possible
1774 * to get multiple timestamps from an interrupt entering just
1775 * as one timestamp is about to be written. The max times
1776 * that this can happen is the number of nested interrupts we
1777 * can have. Nesting 10 deep of interrupts is clearly
1778 * an anomaly.
1779 */
1780 if (unlikely(++nr_loops > 10)) {
1781 RB_WARN_ON(cpu_buffer, 1);
1782 return NULL;
1783 }
1784
1733 if (rb_per_cpu_empty(cpu_buffer)) 1785 if (rb_per_cpu_empty(cpu_buffer))
1734 return NULL; 1786 return NULL;
1735 1787
@@ -1824,9 +1876,11 @@ ring_buffer_read_start(struct ring_buffer *buffer, int cpu)
1824 atomic_inc(&cpu_buffer->record_disabled); 1876 atomic_inc(&cpu_buffer->record_disabled);
1825 synchronize_sched(); 1877 synchronize_sched();
1826 1878
1827 spin_lock_irqsave(&cpu_buffer->lock, flags); 1879 local_irq_save(flags);
1880 __raw_spin_lock(&cpu_buffer->lock);
1828 ring_buffer_iter_reset(iter); 1881 ring_buffer_iter_reset(iter);
1829 spin_unlock_irqrestore(&cpu_buffer->lock, flags); 1882 __raw_spin_unlock(&cpu_buffer->lock);
1883 local_irq_restore(flags);
1830 1884
1831 return iter; 1885 return iter;
1832} 1886}
@@ -1912,11 +1966,13 @@ void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu)
1912 if (!cpu_isset(cpu, buffer->cpumask)) 1966 if (!cpu_isset(cpu, buffer->cpumask))
1913 return; 1967 return;
1914 1968
1915 spin_lock_irqsave(&cpu_buffer->lock, flags); 1969 local_irq_save(flags);
1970 __raw_spin_lock(&cpu_buffer->lock);
1916 1971
1917 rb_reset_cpu(cpu_buffer); 1972 rb_reset_cpu(cpu_buffer);
1918 1973
1919 spin_unlock_irqrestore(&cpu_buffer->lock, flags); 1974 __raw_spin_unlock(&cpu_buffer->lock);
1975 local_irq_restore(flags);
1920} 1976}
1921 1977
1922/** 1978/**
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index e4c40c868d67..d55ccfc8d674 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -43,6 +43,15 @@
43unsigned long __read_mostly tracing_max_latency = (cycle_t)ULONG_MAX; 43unsigned long __read_mostly tracing_max_latency = (cycle_t)ULONG_MAX;
44unsigned long __read_mostly tracing_thresh; 44unsigned long __read_mostly tracing_thresh;
45 45
46
47/*
48 * Kill all tracing for good (never come back).
49 * It is initialized to 1 but will turn to zero if the initialization
50 * of the tracer is successful. But that is the only place that sets
51 * this back to zero.
52 */
53int tracing_disabled = 1;
54
46static DEFINE_PER_CPU(local_t, ftrace_cpu_disabled); 55static DEFINE_PER_CPU(local_t, ftrace_cpu_disabled);
47 56
48static inline void ftrace_disable_cpu(void) 57static inline void ftrace_disable_cpu(void)
@@ -62,8 +71,6 @@ static cpumask_t __read_mostly tracing_buffer_mask;
62#define for_each_tracing_cpu(cpu) \ 71#define for_each_tracing_cpu(cpu) \
63 for_each_cpu_mask(cpu, tracing_buffer_mask) 72 for_each_cpu_mask(cpu, tracing_buffer_mask)
64 73
65static int tracing_disabled = 1;
66
67/* 74/*
68 * ftrace_dump_on_oops - variable to dump ftrace buffer on oops 75 * ftrace_dump_on_oops - variable to dump ftrace buffer on oops
69 * 76 *
@@ -143,6 +150,19 @@ static DEFINE_PER_CPU(struct trace_array_cpu, max_data);
143/* tracer_enabled is used to toggle activation of a tracer */ 150/* tracer_enabled is used to toggle activation of a tracer */
144static int tracer_enabled = 1; 151static int tracer_enabled = 1;
145 152
153/**
154 * tracing_is_enabled - return tracer_enabled status
155 *
156 * This function is used by other tracers to know the status
157 * of the tracer_enabled flag. Tracers may use this function
158 * to know if it should enable their features when starting
159 * up. See irqsoff tracer for an example (start_irqsoff_tracer).
160 */
161int tracing_is_enabled(void)
162{
163 return tracer_enabled;
164}
165
146/* function tracing enabled */ 166/* function tracing enabled */
147int ftrace_function_enabled; 167int ftrace_function_enabled;
148 168
@@ -244,6 +264,7 @@ static const char *trace_options[] = {
244 "stacktrace", 264 "stacktrace",
245 "sched-tree", 265 "sched-tree",
246 "ftrace_printk", 266 "ftrace_printk",
267 "ftrace_preempt",
247 NULL 268 NULL
248}; 269};
249 270
@@ -612,6 +633,76 @@ static void trace_init_cmdlines(void)
612 cmdline_idx = 0; 633 cmdline_idx = 0;
613} 634}
614 635
636static int trace_stop_count;
637static DEFINE_SPINLOCK(tracing_start_lock);
638
639/**
640 * tracing_start - quick start of the tracer
641 *
642 * If tracing is enabled but was stopped by tracing_stop,
643 * this will start the tracer back up.
644 */
645void tracing_start(void)
646{
647 struct ring_buffer *buffer;
648 unsigned long flags;
649
650 if (tracing_disabled)
651 return;
652
653 spin_lock_irqsave(&tracing_start_lock, flags);
654 if (--trace_stop_count)
655 goto out;
656
657 if (trace_stop_count < 0) {
658 /* Someone screwed up their debugging */
659 WARN_ON_ONCE(1);
660 trace_stop_count = 0;
661 goto out;
662 }
663
664
665 buffer = global_trace.buffer;
666 if (buffer)
667 ring_buffer_record_enable(buffer);
668
669 buffer = max_tr.buffer;
670 if (buffer)
671 ring_buffer_record_enable(buffer);
672
673 ftrace_start();
674 out:
675 spin_unlock_irqrestore(&tracing_start_lock, flags);
676}
677
678/**
679 * tracing_stop - quick stop of the tracer
680 *
681 * Light weight way to stop tracing. Use in conjunction with
682 * tracing_start.
683 */
684void tracing_stop(void)
685{
686 struct ring_buffer *buffer;
687 unsigned long flags;
688
689 ftrace_stop();
690 spin_lock_irqsave(&tracing_start_lock, flags);
691 if (trace_stop_count++)
692 goto out;
693
694 buffer = global_trace.buffer;
695 if (buffer)
696 ring_buffer_record_disable(buffer);
697
698 buffer = max_tr.buffer;
699 if (buffer)
700 ring_buffer_record_disable(buffer);
701
702 out:
703 spin_unlock_irqrestore(&tracing_start_lock, flags);
704}
705
615void trace_stop_cmdline_recording(void); 706void trace_stop_cmdline_recording(void);
616 707
617static void trace_save_cmdline(struct task_struct *tsk) 708static void trace_save_cmdline(struct task_struct *tsk)
@@ -891,7 +982,7 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3)
891 982
892#ifdef CONFIG_FUNCTION_TRACER 983#ifdef CONFIG_FUNCTION_TRACER
893static void 984static void
894function_trace_call(unsigned long ip, unsigned long parent_ip) 985function_trace_call_preempt_only(unsigned long ip, unsigned long parent_ip)
895{ 986{
896 struct trace_array *tr = &global_trace; 987 struct trace_array *tr = &global_trace;
897 struct trace_array_cpu *data; 988 struct trace_array_cpu *data;
@@ -904,8 +995,7 @@ function_trace_call(unsigned long ip, unsigned long parent_ip)
904 return; 995 return;
905 996
906 pc = preempt_count(); 997 pc = preempt_count();
907 resched = need_resched(); 998 resched = ftrace_preempt_disable();
908 preempt_disable_notrace();
909 local_save_flags(flags); 999 local_save_flags(flags);
910 cpu = raw_smp_processor_id(); 1000 cpu = raw_smp_processor_id();
911 data = tr->data[cpu]; 1001 data = tr->data[cpu];
@@ -915,10 +1005,38 @@ function_trace_call(unsigned long ip, unsigned long parent_ip)
915 trace_function(tr, data, ip, parent_ip, flags, pc); 1005 trace_function(tr, data, ip, parent_ip, flags, pc);
916 1006
917 atomic_dec(&data->disabled); 1007 atomic_dec(&data->disabled);
918 if (resched) 1008 ftrace_preempt_enable(resched);
919 preempt_enable_no_resched_notrace(); 1009}
920 else 1010
921 preempt_enable_notrace(); 1011static void
1012function_trace_call(unsigned long ip, unsigned long parent_ip)
1013{
1014 struct trace_array *tr = &global_trace;
1015 struct trace_array_cpu *data;
1016 unsigned long flags;
1017 long disabled;
1018 int cpu;
1019 int pc;
1020
1021 if (unlikely(!ftrace_function_enabled))
1022 return;
1023
1024 /*
1025 * Need to use raw, since this must be called before the
1026 * recursive protection is performed.
1027 */
1028 raw_local_irq_save(flags);
1029 cpu = raw_smp_processor_id();
1030 data = tr->data[cpu];
1031 disabled = atomic_inc_return(&data->disabled);
1032
1033 if (likely(disabled == 1)) {
1034 pc = preempt_count();
1035 trace_function(tr, data, ip, parent_ip, flags, pc);
1036 }
1037
1038 atomic_dec(&data->disabled);
1039 raw_local_irq_restore(flags);
922} 1040}
923 1041
924static struct ftrace_ops trace_ops __read_mostly = 1042static struct ftrace_ops trace_ops __read_mostly =
@@ -929,9 +1047,14 @@ static struct ftrace_ops trace_ops __read_mostly =
929void tracing_start_function_trace(void) 1047void tracing_start_function_trace(void)
930{ 1048{
931 ftrace_function_enabled = 0; 1049 ftrace_function_enabled = 0;
1050
1051 if (trace_flags & TRACE_ITER_PREEMPTONLY)
1052 trace_ops.func = function_trace_call_preempt_only;
1053 else
1054 trace_ops.func = function_trace_call;
1055
932 register_ftrace_function(&trace_ops); 1056 register_ftrace_function(&trace_ops);
933 if (tracer_enabled) 1057 ftrace_function_enabled = 1;
934 ftrace_function_enabled = 1;
935} 1058}
936 1059
937void tracing_stop_function_trace(void) 1060void tracing_stop_function_trace(void)
@@ -1078,10 +1201,6 @@ static void *s_start(struct seq_file *m, loff_t *pos)
1078 1201
1079 atomic_inc(&trace_record_cmdline_disabled); 1202 atomic_inc(&trace_record_cmdline_disabled);
1080 1203
1081 /* let the tracer grab locks here if needed */
1082 if (current_trace->start)
1083 current_trace->start(iter);
1084
1085 if (*pos != iter->pos) { 1204 if (*pos != iter->pos) {
1086 iter->ent = NULL; 1205 iter->ent = NULL;
1087 iter->cpu = 0; 1206 iter->cpu = 0;
@@ -1108,28 +1227,24 @@ static void *s_start(struct seq_file *m, loff_t *pos)
1108 1227
1109static void s_stop(struct seq_file *m, void *p) 1228static void s_stop(struct seq_file *m, void *p)
1110{ 1229{
1111 struct trace_iterator *iter = m->private;
1112
1113 atomic_dec(&trace_record_cmdline_disabled); 1230 atomic_dec(&trace_record_cmdline_disabled);
1114
1115 /* let the tracer release locks here if needed */
1116 if (current_trace && current_trace == iter->trace && iter->trace->stop)
1117 iter->trace->stop(iter);
1118
1119 mutex_unlock(&trace_types_lock); 1231 mutex_unlock(&trace_types_lock);
1120} 1232}
1121 1233
1122#define KRETPROBE_MSG "[unknown/kretprobe'd]"
1123
1124#ifdef CONFIG_KRETPROBES 1234#ifdef CONFIG_KRETPROBES
1125static inline int kretprobed(unsigned long addr) 1235static inline const char *kretprobed(const char *name)
1126{ 1236{
1127 return addr == (unsigned long)kretprobe_trampoline; 1237 static const char tramp_name[] = "kretprobe_trampoline";
1238 int size = sizeof(tramp_name);
1239
1240 if (strncmp(tramp_name, name, size) == 0)
1241 return "[unknown/kretprobe'd]";
1242 return name;
1128} 1243}
1129#else 1244#else
1130static inline int kretprobed(unsigned long addr) 1245static inline const char *kretprobed(const char *name)
1131{ 1246{
1132 return 0; 1247 return name;
1133} 1248}
1134#endif /* CONFIG_KRETPROBES */ 1249#endif /* CONFIG_KRETPROBES */
1135 1250
@@ -1138,10 +1253,13 @@ seq_print_sym_short(struct trace_seq *s, const char *fmt, unsigned long address)
1138{ 1253{
1139#ifdef CONFIG_KALLSYMS 1254#ifdef CONFIG_KALLSYMS
1140 char str[KSYM_SYMBOL_LEN]; 1255 char str[KSYM_SYMBOL_LEN];
1256 const char *name;
1141 1257
1142 kallsyms_lookup(address, NULL, NULL, NULL, str); 1258 kallsyms_lookup(address, NULL, NULL, NULL, str);
1143 1259
1144 return trace_seq_printf(s, fmt, str); 1260 name = kretprobed(str);
1261
1262 return trace_seq_printf(s, fmt, name);
1145#endif 1263#endif
1146 return 1; 1264 return 1;
1147} 1265}
@@ -1152,9 +1270,12 @@ seq_print_sym_offset(struct trace_seq *s, const char *fmt,
1152{ 1270{
1153#ifdef CONFIG_KALLSYMS 1271#ifdef CONFIG_KALLSYMS
1154 char str[KSYM_SYMBOL_LEN]; 1272 char str[KSYM_SYMBOL_LEN];
1273 const char *name;
1155 1274
1156 sprint_symbol(str, address); 1275 sprint_symbol(str, address);
1157 return trace_seq_printf(s, fmt, str); 1276 name = kretprobed(str);
1277
1278 return trace_seq_printf(s, fmt, name);
1158#endif 1279#endif
1159 return 1; 1280 return 1;
1160} 1281}
@@ -1408,10 +1529,7 @@ print_lat_fmt(struct trace_iterator *iter, unsigned int trace_idx, int cpu)
1408 1529
1409 seq_print_ip_sym(s, field->ip, sym_flags); 1530 seq_print_ip_sym(s, field->ip, sym_flags);
1410 trace_seq_puts(s, " ("); 1531 trace_seq_puts(s, " (");
1411 if (kretprobed(field->parent_ip)) 1532 seq_print_ip_sym(s, field->parent_ip, sym_flags);
1412 trace_seq_puts(s, KRETPROBE_MSG);
1413 else
1414 seq_print_ip_sym(s, field->parent_ip, sym_flags);
1415 trace_seq_puts(s, ")\n"); 1533 trace_seq_puts(s, ")\n");
1416 break; 1534 break;
1417 } 1535 }
@@ -1527,12 +1645,9 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
1527 ret = trace_seq_printf(s, " <-"); 1645 ret = trace_seq_printf(s, " <-");
1528 if (!ret) 1646 if (!ret)
1529 return TRACE_TYPE_PARTIAL_LINE; 1647 return TRACE_TYPE_PARTIAL_LINE;
1530 if (kretprobed(field->parent_ip)) 1648 ret = seq_print_ip_sym(s,
1531 ret = trace_seq_puts(s, KRETPROBE_MSG); 1649 field->parent_ip,
1532 else 1650 sym_flags);
1533 ret = seq_print_ip_sym(s,
1534 field->parent_ip,
1535 sym_flags);
1536 if (!ret) 1651 if (!ret)
1537 return TRACE_TYPE_PARTIAL_LINE; 1652 return TRACE_TYPE_PARTIAL_LINE;
1538 } 1653 }
@@ -1783,7 +1898,7 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
1783 return TRACE_TYPE_HANDLED; 1898 return TRACE_TYPE_HANDLED;
1784 1899
1785 SEQ_PUT_FIELD_RET(s, entry->pid); 1900 SEQ_PUT_FIELD_RET(s, entry->pid);
1786 SEQ_PUT_FIELD_RET(s, iter->cpu); 1901 SEQ_PUT_FIELD_RET(s, entry->cpu);
1787 SEQ_PUT_FIELD_RET(s, iter->ts); 1902 SEQ_PUT_FIELD_RET(s, iter->ts);
1788 1903
1789 switch (entry->type) { 1904 switch (entry->type) {
@@ -1945,10 +2060,7 @@ __tracing_open(struct inode *inode, struct file *file, int *ret)
1945 m->private = iter; 2060 m->private = iter;
1946 2061
1947 /* stop the trace while dumping */ 2062 /* stop the trace while dumping */
1948 if (iter->tr->ctrl) { 2063 tracing_stop();
1949 tracer_enabled = 0;
1950 ftrace_function_enabled = 0;
1951 }
1952 2064
1953 if (iter->trace && iter->trace->open) 2065 if (iter->trace && iter->trace->open)
1954 iter->trace->open(iter); 2066 iter->trace->open(iter);
@@ -1993,14 +2105,7 @@ int tracing_release(struct inode *inode, struct file *file)
1993 iter->trace->close(iter); 2105 iter->trace->close(iter);
1994 2106
1995 /* reenable tracing if it was previously enabled */ 2107 /* reenable tracing if it was previously enabled */
1996 if (iter->tr->ctrl) { 2108 tracing_start();
1997 tracer_enabled = 1;
1998 /*
1999 * It is safe to enable function tracing even if it
2000 * isn't used
2001 */
2002 ftrace_function_enabled = 1;
2003 }
2004 mutex_unlock(&trace_types_lock); 2109 mutex_unlock(&trace_types_lock);
2005 2110
2006 seq_release(inode, file); 2111 seq_release(inode, file);
@@ -2338,11 +2443,10 @@ static ssize_t
2338tracing_ctrl_read(struct file *filp, char __user *ubuf, 2443tracing_ctrl_read(struct file *filp, char __user *ubuf,
2339 size_t cnt, loff_t *ppos) 2444 size_t cnt, loff_t *ppos)
2340{ 2445{
2341 struct trace_array *tr = filp->private_data;
2342 char buf[64]; 2446 char buf[64];
2343 int r; 2447 int r;
2344 2448
2345 r = sprintf(buf, "%ld\n", tr->ctrl); 2449 r = sprintf(buf, "%u\n", tracer_enabled);
2346 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); 2450 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
2347} 2451}
2348 2452
@@ -2370,16 +2474,18 @@ tracing_ctrl_write(struct file *filp, const char __user *ubuf,
2370 val = !!val; 2474 val = !!val;
2371 2475
2372 mutex_lock(&trace_types_lock); 2476 mutex_lock(&trace_types_lock);
2373 if (tr->ctrl ^ val) { 2477 if (tracer_enabled ^ val) {
2374 if (val) 2478 if (val) {
2375 tracer_enabled = 1; 2479 tracer_enabled = 1;
2376 else 2480 if (current_trace->start)
2481 current_trace->start(tr);
2482 tracing_start();
2483 } else {
2377 tracer_enabled = 0; 2484 tracer_enabled = 0;
2378 2485 tracing_stop();
2379 tr->ctrl = val; 2486 if (current_trace->stop)
2380 2487 current_trace->stop(tr);
2381 if (current_trace && current_trace->ctrl_update) 2488 }
2382 current_trace->ctrl_update(tr);
2383 } 2489 }
2384 mutex_unlock(&trace_types_lock); 2490 mutex_unlock(&trace_types_lock);
2385 2491
@@ -3251,6 +3357,8 @@ __init static int tracer_alloc_buffers(void)
3251 3357
3252 register_tracer(&nop_trace); 3358 register_tracer(&nop_trace);
3253#ifdef CONFIG_BOOT_TRACER 3359#ifdef CONFIG_BOOT_TRACER
3360 /* We don't want to launch sched_switch tracer yet */
3361 global_trace.ctrl = 0;
3254 register_tracer(&boot_tracer); 3362 register_tracer(&boot_tracer);
3255 current_trace = &boot_tracer; 3363 current_trace = &boot_tracer;
3256 current_trace->init(&global_trace); 3364 current_trace->init(&global_trace);
@@ -3259,7 +3367,7 @@ __init static int tracer_alloc_buffers(void)
3259#endif 3367#endif
3260 3368
3261 /* All seems OK, enable tracing */ 3369 /* All seems OK, enable tracing */
3262 global_trace.ctrl = tracer_enabled; 3370 global_trace.ctrl = 1;
3263 tracing_disabled = 0; 3371 tracing_disabled = 0;
3264 3372
3265 atomic_notifier_chain_register(&panic_notifier_list, 3373 atomic_notifier_chain_register(&panic_notifier_list,
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 8465ad052707..3422489fad5e 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -49,6 +49,7 @@ struct ftrace_entry {
49 unsigned long parent_ip; 49 unsigned long parent_ip;
50}; 50};
51extern struct tracer boot_tracer; 51extern struct tracer boot_tracer;
52extern struct tracer sched_switch_trace; /* Used by the boot tracer */
52 53
53/* 54/*
54 * Context switch trace entry - which task (and prio) we switched from/to: 55 * Context switch trace entry - which task (and prio) we switched from/to:
@@ -236,11 +237,11 @@ struct tracer {
236 const char *name; 237 const char *name;
237 void (*init)(struct trace_array *tr); 238 void (*init)(struct trace_array *tr);
238 void (*reset)(struct trace_array *tr); 239 void (*reset)(struct trace_array *tr);
240 void (*start)(struct trace_array *tr);
241 void (*stop)(struct trace_array *tr);
239 void (*open)(struct trace_iterator *iter); 242 void (*open)(struct trace_iterator *iter);
240 void (*pipe_open)(struct trace_iterator *iter); 243 void (*pipe_open)(struct trace_iterator *iter);
241 void (*close)(struct trace_iterator *iter); 244 void (*close)(struct trace_iterator *iter);
242 void (*start)(struct trace_iterator *iter);
243 void (*stop)(struct trace_iterator *iter);
244 ssize_t (*read)(struct trace_iterator *iter, 245 ssize_t (*read)(struct trace_iterator *iter,
245 struct file *filp, char __user *ubuf, 246 struct file *filp, char __user *ubuf,
246 size_t cnt, loff_t *ppos); 247 size_t cnt, loff_t *ppos);
@@ -281,6 +282,7 @@ struct trace_iterator {
281 long idx; 282 long idx;
282}; 283};
283 284
285int tracing_is_enabled(void);
284void trace_wake_up(void); 286void trace_wake_up(void);
285void tracing_reset(struct trace_array *tr, int cpu); 287void tracing_reset(struct trace_array *tr, int cpu);
286int tracing_open_generic(struct inode *inode, struct file *filp); 288int tracing_open_generic(struct inode *inode, struct file *filp);
@@ -415,8 +417,57 @@ enum trace_iterator_flags {
415 TRACE_ITER_STACKTRACE = 0x100, 417 TRACE_ITER_STACKTRACE = 0x100,
416 TRACE_ITER_SCHED_TREE = 0x200, 418 TRACE_ITER_SCHED_TREE = 0x200,
417 TRACE_ITER_PRINTK = 0x400, 419 TRACE_ITER_PRINTK = 0x400,
420 TRACE_ITER_PREEMPTONLY = 0x800,
418}; 421};
419 422
420extern struct tracer nop_trace; 423extern struct tracer nop_trace;
421 424
425/**
426 * ftrace_preempt_disable - disable preemption scheduler safe
427 *
428 * When tracing can happen inside the scheduler, there exists
429 * cases that the tracing might happen before the need_resched
430 * flag is checked. If this happens and the tracer calls
431 * preempt_enable (after a disable), a schedule might take place
432 * causing an infinite recursion.
433 *
434 * To prevent this, we read the need_recshed flag before
435 * disabling preemption. When we want to enable preemption we
436 * check the flag, if it is set, then we call preempt_enable_no_resched.
437 * Otherwise, we call preempt_enable.
438 *
439 * The rational for doing the above is that if need resched is set
440 * and we have yet to reschedule, we are either in an atomic location
441 * (where we do not need to check for scheduling) or we are inside
442 * the scheduler and do not want to resched.
443 */
444static inline int ftrace_preempt_disable(void)
445{
446 int resched;
447
448 resched = need_resched();
449 preempt_disable_notrace();
450
451 return resched;
452}
453
454/**
455 * ftrace_preempt_enable - enable preemption scheduler safe
456 * @resched: the return value from ftrace_preempt_disable
457 *
458 * This is a scheduler safe way to enable preemption and not miss
459 * any preemption checks. The disabled saved the state of preemption.
460 * If resched is set, then we were either inside an atomic or
461 * are inside the scheduler (we would have already scheduled
462 * otherwise). In this case, we do not want to call normal
463 * preempt_enable, but preempt_enable_no_resched instead.
464 */
465static inline void ftrace_preempt_enable(int resched)
466{
467 if (resched)
468 preempt_enable_no_resched_notrace();
469 else
470 preempt_enable_notrace();
471}
472
422#endif /* _LINUX_KERNEL_TRACE_H */ 473#endif /* _LINUX_KERNEL_TRACE_H */
diff --git a/kernel/trace/trace_boot.c b/kernel/trace/trace_boot.c
index d0a5e50eeff2..bd5046c9deb7 100644
--- a/kernel/trace/trace_boot.c
+++ b/kernel/trace/trace_boot.c
@@ -13,23 +13,33 @@
13#include "trace.h" 13#include "trace.h"
14 14
15static struct trace_array *boot_trace; 15static struct trace_array *boot_trace;
16static int trace_boot_enabled; 16static bool pre_initcalls_finished;
17 17
18 18/* Tells the boot tracer that the pre_smp_initcalls are finished.
19/* Should be started after do_pre_smp_initcalls() in init/main.c */ 19 * So we are ready .
20 * It doesn't enable sched events tracing however.
21 * You have to call enable_boot_trace to do so.
22 */
20void start_boot_trace(void) 23void start_boot_trace(void)
21{ 24{
22 trace_boot_enabled = 1; 25 pre_initcalls_finished = true;
23} 26}
24 27
25void stop_boot_trace(void) 28void enable_boot_trace(void)
26{ 29{
27 trace_boot_enabled = 0; 30 if (pre_initcalls_finished)
31 tracing_start_cmdline_record();
28} 32}
29 33
30void reset_boot_trace(struct trace_array *tr) 34void disable_boot_trace(void)
31{ 35{
32 stop_boot_trace(); 36 if (pre_initcalls_finished)
37 tracing_stop_cmdline_record();
38}
39
40static void reset_boot_trace(struct trace_array *tr)
41{
42 sched_switch_trace.reset(tr);
33} 43}
34 44
35static void boot_trace_init(struct trace_array *tr) 45static void boot_trace_init(struct trace_array *tr)
@@ -37,18 +47,18 @@ static void boot_trace_init(struct trace_array *tr)
37 int cpu; 47 int cpu;
38 boot_trace = tr; 48 boot_trace = tr;
39 49
40 trace_boot_enabled = 0;
41
42 for_each_cpu_mask(cpu, cpu_possible_map) 50 for_each_cpu_mask(cpu, cpu_possible_map)
43 tracing_reset(tr, cpu); 51 tracing_reset(tr, cpu);
52
53 sched_switch_trace.init(tr);
44} 54}
45 55
46static void boot_trace_ctrl_update(struct trace_array *tr) 56static void boot_trace_ctrl_update(struct trace_array *tr)
47{ 57{
48 if (tr->ctrl) 58 if (tr->ctrl)
49 start_boot_trace(); 59 enable_boot_trace();
50 else 60 else
51 stop_boot_trace(); 61 disable_boot_trace();
52} 62}
53 63
54static enum print_line_t initcall_print_line(struct trace_iterator *iter) 64static enum print_line_t initcall_print_line(struct trace_iterator *iter)
@@ -99,7 +109,7 @@ void trace_boot(struct boot_trace *it, initcall_t fn)
99 unsigned long irq_flags; 109 unsigned long irq_flags;
100 struct trace_array *tr = boot_trace; 110 struct trace_array *tr = boot_trace;
101 111
102 if (!trace_boot_enabled) 112 if (!pre_initcalls_finished)
103 return; 113 return;
104 114
105 /* Get its name now since this function could 115 /* Get its name now since this function could
diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index 0f85a64003d3..9f1b0de71284 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -62,11 +62,17 @@ static void function_trace_ctrl_update(struct trace_array *tr)
62 stop_function_trace(tr); 62 stop_function_trace(tr);
63} 63}
64 64
65static void function_trace_start(struct trace_array *tr)
66{
67 function_reset(tr);
68}
69
65static struct tracer function_trace __read_mostly = 70static struct tracer function_trace __read_mostly =
66{ 71{
67 .name = "function", 72 .name = "function",
68 .init = function_trace_init, 73 .init = function_trace_init,
69 .reset = function_trace_reset, 74 .reset = function_trace_reset,
75 .start = function_trace_start,
70 .ctrl_update = function_trace_ctrl_update, 76 .ctrl_update = function_trace_ctrl_update,
71#ifdef CONFIG_FTRACE_SELFTEST 77#ifdef CONFIG_FTRACE_SELFTEST
72 .selftest = trace_selftest_startup_function, 78 .selftest = trace_selftest_startup_function,
diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index 9c74071c10e0..a87a20fa3fc6 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -353,15 +353,28 @@ void trace_preempt_off(unsigned long a0, unsigned long a1)
353} 353}
354#endif /* CONFIG_PREEMPT_TRACER */ 354#endif /* CONFIG_PREEMPT_TRACER */
355 355
356/*
357 * save_tracer_enabled is used to save the state of the tracer_enabled
358 * variable when we disable it when we open a trace output file.
359 */
360static int save_tracer_enabled;
361
356static void start_irqsoff_tracer(struct trace_array *tr) 362static void start_irqsoff_tracer(struct trace_array *tr)
357{ 363{
358 register_ftrace_function(&trace_ops); 364 register_ftrace_function(&trace_ops);
359 tracer_enabled = 1; 365 if (tracing_is_enabled()) {
366 tracer_enabled = 1;
367 save_tracer_enabled = 1;
368 } else {
369 tracer_enabled = 0;
370 save_tracer_enabled = 0;
371 }
360} 372}
361 373
362static void stop_irqsoff_tracer(struct trace_array *tr) 374static void stop_irqsoff_tracer(struct trace_array *tr)
363{ 375{
364 tracer_enabled = 0; 376 tracer_enabled = 0;
377 save_tracer_enabled = 0;
365 unregister_ftrace_function(&trace_ops); 378 unregister_ftrace_function(&trace_ops);
366} 379}
367 380
@@ -389,17 +402,29 @@ static void irqsoff_tracer_ctrl_update(struct trace_array *tr)
389 stop_irqsoff_tracer(tr); 402 stop_irqsoff_tracer(tr);
390} 403}
391 404
405static void irqsoff_tracer_start(struct trace_array *tr)
406{
407 irqsoff_tracer_reset(tr);
408 tracer_enabled = 1;
409 save_tracer_enabled = 1;
410}
411
412static void irqsoff_tracer_stop(struct trace_array *tr)
413{
414 tracer_enabled = 0;
415 save_tracer_enabled = 0;
416}
417
392static void irqsoff_tracer_open(struct trace_iterator *iter) 418static void irqsoff_tracer_open(struct trace_iterator *iter)
393{ 419{
394 /* stop the trace while dumping */ 420 /* stop the trace while dumping */
395 if (iter->tr->ctrl) 421 tracer_enabled = 0;
396 stop_irqsoff_tracer(iter->tr);
397} 422}
398 423
399static void irqsoff_tracer_close(struct trace_iterator *iter) 424static void irqsoff_tracer_close(struct trace_iterator *iter)
400{ 425{
401 if (iter->tr->ctrl) 426 /* restart tracing */
402 start_irqsoff_tracer(iter->tr); 427 tracer_enabled = save_tracer_enabled;
403} 428}
404 429
405#ifdef CONFIG_IRQSOFF_TRACER 430#ifdef CONFIG_IRQSOFF_TRACER
@@ -414,6 +439,8 @@ static struct tracer irqsoff_tracer __read_mostly =
414 .name = "irqsoff", 439 .name = "irqsoff",
415 .init = irqsoff_tracer_init, 440 .init = irqsoff_tracer_init,
416 .reset = irqsoff_tracer_reset, 441 .reset = irqsoff_tracer_reset,
442 .start = irqsoff_tracer_start,
443 .stop = irqsoff_tracer_stop,
417 .open = irqsoff_tracer_open, 444 .open = irqsoff_tracer_open,
418 .close = irqsoff_tracer_close, 445 .close = irqsoff_tracer_close,
419 .ctrl_update = irqsoff_tracer_ctrl_update, 446 .ctrl_update = irqsoff_tracer_ctrl_update,
@@ -440,6 +467,8 @@ static struct tracer preemptoff_tracer __read_mostly =
440 .name = "preemptoff", 467 .name = "preemptoff",
441 .init = preemptoff_tracer_init, 468 .init = preemptoff_tracer_init,
442 .reset = irqsoff_tracer_reset, 469 .reset = irqsoff_tracer_reset,
470 .start = irqsoff_tracer_start,
471 .stop = irqsoff_tracer_stop,
443 .open = irqsoff_tracer_open, 472 .open = irqsoff_tracer_open,
444 .close = irqsoff_tracer_close, 473 .close = irqsoff_tracer_close,
445 .ctrl_update = irqsoff_tracer_ctrl_update, 474 .ctrl_update = irqsoff_tracer_ctrl_update,
@@ -468,6 +497,8 @@ static struct tracer preemptirqsoff_tracer __read_mostly =
468 .name = "preemptirqsoff", 497 .name = "preemptirqsoff",
469 .init = preemptirqsoff_tracer_init, 498 .init = preemptirqsoff_tracer_init,
470 .reset = irqsoff_tracer_reset, 499 .reset = irqsoff_tracer_reset,
500 .start = irqsoff_tracer_start,
501 .stop = irqsoff_tracer_stop,
471 .open = irqsoff_tracer_open, 502 .open = irqsoff_tracer_open,
472 .close = irqsoff_tracer_close, 503 .close = irqsoff_tracer_close,
473 .ctrl_update = irqsoff_tracer_ctrl_update, 504 .ctrl_update = irqsoff_tracer_ctrl_update,
diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c
index b8f56beb1a62..91c699be8c87 100644
--- a/kernel/trace/trace_sched_switch.c
+++ b/kernel/trace/trace_sched_switch.c
@@ -16,7 +16,8 @@
16 16
17static struct trace_array *ctx_trace; 17static struct trace_array *ctx_trace;
18static int __read_mostly tracer_enabled; 18static int __read_mostly tracer_enabled;
19static atomic_t sched_ref; 19static int sched_ref;
20static DEFINE_MUTEX(sched_register_mutex);
20 21
21static void 22static void
22probe_sched_switch(struct rq *__rq, struct task_struct *prev, 23probe_sched_switch(struct rq *__rq, struct task_struct *prev,
@@ -27,7 +28,7 @@ probe_sched_switch(struct rq *__rq, struct task_struct *prev,
27 int cpu; 28 int cpu;
28 int pc; 29 int pc;
29 30
30 if (!atomic_read(&sched_ref)) 31 if (!sched_ref)
31 return; 32 return;
32 33
33 tracing_record_cmdline(prev); 34 tracing_record_cmdline(prev);
@@ -123,20 +124,22 @@ static void tracing_sched_unregister(void)
123 124
124static void tracing_start_sched_switch(void) 125static void tracing_start_sched_switch(void)
125{ 126{
126 long ref; 127 mutex_lock(&sched_register_mutex);
127 128 if (!(sched_ref++)) {
128 ref = atomic_inc_return(&sched_ref); 129 tracer_enabled = 1;
129 if (ref == 1)
130 tracing_sched_register(); 130 tracing_sched_register();
131 }
132 mutex_unlock(&sched_register_mutex);
131} 133}
132 134
133static void tracing_stop_sched_switch(void) 135static void tracing_stop_sched_switch(void)
134{ 136{
135 long ref; 137 mutex_lock(&sched_register_mutex);
136 138 if (!(--sched_ref)) {
137 ref = atomic_dec_and_test(&sched_ref);
138 if (ref)
139 tracing_sched_unregister(); 139 tracing_sched_unregister();
140 tracer_enabled = 0;
141 }
142 mutex_unlock(&sched_register_mutex);
140} 143}
141 144
142void tracing_start_cmdline_record(void) 145void tracing_start_cmdline_record(void)
@@ -153,12 +156,10 @@ static void start_sched_trace(struct trace_array *tr)
153{ 156{
154 sched_switch_reset(tr); 157 sched_switch_reset(tr);
155 tracing_start_cmdline_record(); 158 tracing_start_cmdline_record();
156 tracer_enabled = 1;
157} 159}
158 160
159static void stop_sched_trace(struct trace_array *tr) 161static void stop_sched_trace(struct trace_array *tr)
160{ 162{
161 tracer_enabled = 0;
162 tracing_stop_cmdline_record(); 163 tracing_stop_cmdline_record();
163} 164}
164 165
@@ -172,7 +173,7 @@ static void sched_switch_trace_init(struct trace_array *tr)
172 173
173static void sched_switch_trace_reset(struct trace_array *tr) 174static void sched_switch_trace_reset(struct trace_array *tr)
174{ 175{
175 if (tr->ctrl) 176 if (tr->ctrl && sched_ref)
176 stop_sched_trace(tr); 177 stop_sched_trace(tr);
177} 178}
178 179
@@ -185,11 +186,24 @@ static void sched_switch_trace_ctrl_update(struct trace_array *tr)
185 stop_sched_trace(tr); 186 stop_sched_trace(tr);
186} 187}
187 188
188static struct tracer sched_switch_trace __read_mostly = 189static void sched_switch_trace_start(struct trace_array *tr)
190{
191 sched_switch_reset(tr);
192 tracing_start_sched_switch();
193}
194
195static void sched_switch_trace_stop(struct trace_array *tr)
196{
197 tracing_stop_sched_switch();
198}
199
200struct tracer sched_switch_trace __read_mostly =
189{ 201{
190 .name = "sched_switch", 202 .name = "sched_switch",
191 .init = sched_switch_trace_init, 203 .init = sched_switch_trace_init,
192 .reset = sched_switch_trace_reset, 204 .reset = sched_switch_trace_reset,
205 .start = sched_switch_trace_start,
206 .stop = sched_switch_trace_stop,
193 .ctrl_update = sched_switch_trace_ctrl_update, 207 .ctrl_update = sched_switch_trace_ctrl_update,
194#ifdef CONFIG_FTRACE_SELFTEST 208#ifdef CONFIG_FTRACE_SELFTEST
195 .selftest = trace_selftest_startup_sched_switch, 209 .selftest = trace_selftest_startup_sched_switch,
@@ -198,14 +212,6 @@ static struct tracer sched_switch_trace __read_mostly =
198 212
199__init static int init_sched_switch_trace(void) 213__init static int init_sched_switch_trace(void)
200{ 214{
201 int ret = 0;
202
203 if (atomic_read(&sched_ref))
204 ret = tracing_sched_register();
205 if (ret) {
206 pr_info("error registering scheduler trace\n");
207 return ret;
208 }
209 return register_tracer(&sched_switch_trace); 215 return register_tracer(&sched_switch_trace);
210} 216}
211device_initcall(init_sched_switch_trace); 217device_initcall(init_sched_switch_trace);
diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c
index 3ae93f16b565..240577bc8ba5 100644
--- a/kernel/trace/trace_sched_wakeup.c
+++ b/kernel/trace/trace_sched_wakeup.c
@@ -50,8 +50,7 @@ wakeup_tracer_call(unsigned long ip, unsigned long parent_ip)
50 return; 50 return;
51 51
52 pc = preempt_count(); 52 pc = preempt_count();
53 resched = need_resched(); 53 resched = ftrace_preempt_disable();
54 preempt_disable_notrace();
55 54
56 cpu = raw_smp_processor_id(); 55 cpu = raw_smp_processor_id();
57 data = tr->data[cpu]; 56 data = tr->data[cpu];
@@ -81,15 +80,7 @@ wakeup_tracer_call(unsigned long ip, unsigned long parent_ip)
81 out: 80 out:
82 atomic_dec(&data->disabled); 81 atomic_dec(&data->disabled);
83 82
84 /* 83 ftrace_preempt_enable(resched);
85 * To prevent recursion from the scheduler, if the
86 * resched flag was set before we entered, then
87 * don't reschedule.
88 */
89 if (resched)
90 preempt_enable_no_resched_notrace();
91 else
92 preempt_enable_notrace();
93} 84}
94 85
95static struct ftrace_ops trace_ops __read_mostly = 86static struct ftrace_ops trace_ops __read_mostly =
@@ -271,6 +262,12 @@ out:
271 atomic_dec(&wakeup_trace->data[cpu]->disabled); 262 atomic_dec(&wakeup_trace->data[cpu]->disabled);
272} 263}
273 264
265/*
266 * save_tracer_enabled is used to save the state of the tracer_enabled
267 * variable when we disable it when we open a trace output file.
268 */
269static int save_tracer_enabled;
270
274static void start_wakeup_tracer(struct trace_array *tr) 271static void start_wakeup_tracer(struct trace_array *tr)
275{ 272{
276 int ret; 273 int ret;
@@ -309,7 +306,13 @@ static void start_wakeup_tracer(struct trace_array *tr)
309 306
310 register_ftrace_function(&trace_ops); 307 register_ftrace_function(&trace_ops);
311 308
312 tracer_enabled = 1; 309 if (tracing_is_enabled()) {
310 tracer_enabled = 1;
311 save_tracer_enabled = 1;
312 } else {
313 tracer_enabled = 0;
314 save_tracer_enabled = 0;
315 }
313 316
314 return; 317 return;
315fail_deprobe_wake_new: 318fail_deprobe_wake_new:
@@ -321,6 +324,7 @@ fail_deprobe:
321static void stop_wakeup_tracer(struct trace_array *tr) 324static void stop_wakeup_tracer(struct trace_array *tr)
322{ 325{
323 tracer_enabled = 0; 326 tracer_enabled = 0;
327 save_tracer_enabled = 0;
324 unregister_ftrace_function(&trace_ops); 328 unregister_ftrace_function(&trace_ops);
325 unregister_trace_sched_switch(probe_wakeup_sched_switch); 329 unregister_trace_sched_switch(probe_wakeup_sched_switch);
326 unregister_trace_sched_wakeup_new(probe_wakeup); 330 unregister_trace_sched_wakeup_new(probe_wakeup);
@@ -352,18 +356,32 @@ static void wakeup_tracer_ctrl_update(struct trace_array *tr)
352 stop_wakeup_tracer(tr); 356 stop_wakeup_tracer(tr);
353} 357}
354 358
359static void wakeup_tracer_start(struct trace_array *tr)
360{
361 wakeup_reset(tr);
362 tracer_enabled = 1;
363 save_tracer_enabled = 1;
364}
365
366static void wakeup_tracer_stop(struct trace_array *tr)
367{
368 tracer_enabled = 0;
369 save_tracer_enabled = 0;
370}
371
355static void wakeup_tracer_open(struct trace_iterator *iter) 372static void wakeup_tracer_open(struct trace_iterator *iter)
356{ 373{
357 /* stop the trace while dumping */ 374 /* stop the trace while dumping */
358 if (iter->tr->ctrl) 375 tracer_enabled = 0;
359 stop_wakeup_tracer(iter->tr);
360} 376}
361 377
362static void wakeup_tracer_close(struct trace_iterator *iter) 378static void wakeup_tracer_close(struct trace_iterator *iter)
363{ 379{
364 /* forget about any processes we were recording */ 380 /* forget about any processes we were recording */
365 if (iter->tr->ctrl) 381 if (save_tracer_enabled) {
366 start_wakeup_tracer(iter->tr); 382 wakeup_reset(iter->tr);
383 tracer_enabled = 1;
384 }
367} 385}
368 386
369static struct tracer wakeup_tracer __read_mostly = 387static struct tracer wakeup_tracer __read_mostly =
@@ -371,6 +389,8 @@ static struct tracer wakeup_tracer __read_mostly =
371 .name = "wakeup", 389 .name = "wakeup",
372 .init = wakeup_tracer_init, 390 .init = wakeup_tracer_init,
373 .reset = wakeup_tracer_reset, 391 .reset = wakeup_tracer_reset,
392 .start = wakeup_tracer_start,
393 .stop = wakeup_tracer_stop,
374 .open = wakeup_tracer_open, 394 .open = wakeup_tracer_open,
375 .close = wakeup_tracer_close, 395 .close = wakeup_tracer_close,
376 .ctrl_update = wakeup_tracer_ctrl_update, 396 .ctrl_update = wakeup_tracer_ctrl_update,
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index be682b62fe58..d39e8b7de6a2 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -107,8 +107,7 @@ stack_trace_call(unsigned long ip, unsigned long parent_ip)
107 if (unlikely(!ftrace_enabled || stack_trace_disabled)) 107 if (unlikely(!ftrace_enabled || stack_trace_disabled))
108 return; 108 return;
109 109
110 resched = need_resched(); 110 resched = ftrace_preempt_disable();
111 preempt_disable_notrace();
112 111
113 cpu = raw_smp_processor_id(); 112 cpu = raw_smp_processor_id();
114 /* no atomic needed, we only modify this variable by this cpu */ 113 /* no atomic needed, we only modify this variable by this cpu */
@@ -120,10 +119,7 @@ stack_trace_call(unsigned long ip, unsigned long parent_ip)
120 out: 119 out:
121 per_cpu(trace_active, cpu)--; 120 per_cpu(trace_active, cpu)--;
122 /* prevent recursion in schedule */ 121 /* prevent recursion in schedule */
123 if (resched) 122 ftrace_preempt_enable(resched);
124 preempt_enable_no_resched_notrace();
125 else
126 preempt_enable_notrace();
127} 123}
128 124
129static struct ftrace_ops trace_ops __read_mostly = 125static struct ftrace_ops trace_ops __read_mostly =
diff --git a/sound/aoa/soundbus/core.c b/sound/aoa/soundbus/core.c
index f84f3e505788..fa8ab2815a98 100644
--- a/sound/aoa/soundbus/core.c
+++ b/sound/aoa/soundbus/core.c
@@ -176,7 +176,7 @@ int soundbus_add_one(struct soundbus_dev *dev)
176 return -EINVAL; 176 return -EINVAL;
177 } 177 }
178 178
179 snprintf(dev->ofdev.dev.bus_id, BUS_ID_SIZE, "soundbus:%x", ++devcount); 179 dev_set_name(&dev->ofdev.dev, "soundbus:%x", ++devcount);
180 dev->ofdev.dev.bus = &soundbus_bus_type; 180 dev->ofdev.dev.bus = &soundbus_bus_type;
181 return of_device_register(&dev->ofdev); 181 return of_device_register(&dev->ofdev);
182} 182}
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index c4995c9f5730..39672f68ce5d 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -148,6 +148,8 @@ static int snd_rawmidi_runtime_free(struct snd_rawmidi_substream *substream)
148 148
149static inline void snd_rawmidi_output_trigger(struct snd_rawmidi_substream *substream,int up) 149static inline void snd_rawmidi_output_trigger(struct snd_rawmidi_substream *substream,int up)
150{ 150{
151 if (!substream->opened)
152 return;
151 if (up) { 153 if (up) {
152 tasklet_hi_schedule(&substream->runtime->tasklet); 154 tasklet_hi_schedule(&substream->runtime->tasklet);
153 } else { 155 } else {
@@ -158,6 +160,8 @@ static inline void snd_rawmidi_output_trigger(struct snd_rawmidi_substream *subs
158 160
159static void snd_rawmidi_input_trigger(struct snd_rawmidi_substream *substream, int up) 161static void snd_rawmidi_input_trigger(struct snd_rawmidi_substream *substream, int up)
160{ 162{
163 if (!substream->opened)
164 return;
161 substream->ops->trigger(substream, up); 165 substream->ops->trigger(substream, up);
162 if (!up && substream->runtime->event) 166 if (!up && substream->runtime->event)
163 tasklet_kill(&substream->runtime->tasklet); 167 tasklet_kill(&substream->runtime->tasklet);
@@ -857,6 +861,8 @@ int snd_rawmidi_receive(struct snd_rawmidi_substream *substream,
857 int result = 0, count1; 861 int result = 0, count1;
858 struct snd_rawmidi_runtime *runtime = substream->runtime; 862 struct snd_rawmidi_runtime *runtime = substream->runtime;
859 863
864 if (!substream->opened)
865 return -EBADFD;
860 if (runtime->buffer == NULL) { 866 if (runtime->buffer == NULL) {
861 snd_printd("snd_rawmidi_receive: input is not active!!!\n"); 867 snd_printd("snd_rawmidi_receive: input is not active!!!\n");
862 return -EINVAL; 868 return -EINVAL;
@@ -1126,6 +1132,8 @@ int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count)
1126int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream, 1132int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream,
1127 unsigned char *buffer, int count) 1133 unsigned char *buffer, int count)
1128{ 1134{
1135 if (!substream->opened)
1136 return -EBADFD;
1129 count = snd_rawmidi_transmit_peek(substream, buffer, count); 1137 count = snd_rawmidi_transmit_peek(substream, buffer, count);
1130 if (count < 0) 1138 if (count < 0)
1131 return count; 1139 return count;
diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c
index ecdbeb6d3603..7783843ca9ae 100644
--- a/sound/drivers/ml403-ac97cr.c
+++ b/sound/drivers/ml403-ac97cr.c
@@ -1153,7 +1153,7 @@ snd_ml403_ac97cr_create(struct snd_card *card, struct platform_device *pfdev,
1153 /* get irq */ 1153 /* get irq */
1154 irq = platform_get_irq(pfdev, 0); 1154 irq = platform_get_irq(pfdev, 0);
1155 if (request_irq(irq, snd_ml403_ac97cr_irq, IRQF_DISABLED, 1155 if (request_irq(irq, snd_ml403_ac97cr_irq, IRQF_DISABLED,
1156 pfdev->dev.bus_id, (void *)ml403_ac97cr)) { 1156 dev_name(&pfdev->dev), (void *)ml403_ac97cr)) {
1157 snd_printk(KERN_ERR SND_ML403_AC97CR_DRIVER ": " 1157 snd_printk(KERN_ERR SND_ML403_AC97CR_DRIVER ": "
1158 "unable to grab IRQ %d\n", 1158 "unable to grab IRQ %d\n",
1159 irq); 1159 irq);
@@ -1166,7 +1166,7 @@ snd_ml403_ac97cr_create(struct snd_card *card, struct platform_device *pfdev,
1166 ml403_ac97cr->irq); 1166 ml403_ac97cr->irq);
1167 irq = platform_get_irq(pfdev, 1); 1167 irq = platform_get_irq(pfdev, 1);
1168 if (request_irq(irq, snd_ml403_ac97cr_irq, IRQF_DISABLED, 1168 if (request_irq(irq, snd_ml403_ac97cr_irq, IRQF_DISABLED,
1169 pfdev->dev.bus_id, (void *)ml403_ac97cr)) { 1169 dev_name(&pfdev->dev), (void *)ml403_ac97cr)) {
1170 snd_printk(KERN_ERR SND_ML403_AC97CR_DRIVER ": " 1170 snd_printk(KERN_ERR SND_ML403_AC97CR_DRIVER ": "
1171 "unable to grab IRQ %d\n", 1171 "unable to grab IRQ %d\n",
1172 irq); 1172 irq);
diff --git a/sound/drivers/pcsp/pcsp_input.c b/sound/drivers/pcsp/pcsp_input.c
index cd9b83e7f7d1..0444cdeb4bec 100644
--- a/sound/drivers/pcsp/pcsp_input.c
+++ b/sound/drivers/pcsp/pcsp_input.c
@@ -24,13 +24,13 @@ static void pcspkr_do_sound(unsigned int count)
24 spin_lock_irqsave(&i8253_lock, flags); 24 spin_lock_irqsave(&i8253_lock, flags);
25 25
26 if (count) { 26 if (count) {
27 /* enable counter 2 */
28 outb_p(inb_p(0x61) | 3, 0x61);
29 /* set command for counter 2, 2 byte write */ 27 /* set command for counter 2, 2 byte write */
30 outb_p(0xB6, 0x43); 28 outb_p(0xB6, 0x43);
31 /* select desired HZ */ 29 /* select desired HZ */
32 outb_p(count & 0xff, 0x42); 30 outb_p(count & 0xff, 0x42);
33 outb((count >> 8) & 0xff, 0x42); 31 outb((count >> 8) & 0xff, 0x42);
32 /* enable counter 2 */
33 outb_p(inb_p(0x61) | 3, 0x61);
34 } else { 34 } else {
35 /* disable counter 2 */ 35 /* disable counter 2 */
36 outb(inb_p(0x61) & 0xFC, 0x61); 36 outb(inb_p(0x61) & 0xFC, 0x61);
diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c
index b68d20edc20f..223a6c038819 100644
--- a/sound/isa/ad1848/ad1848.c
+++ b/sound/isa/ad1848/ad1848.c
@@ -70,15 +70,15 @@ static int __devinit snd_ad1848_match(struct device *dev, unsigned int n)
70 return 0; 70 return 0;
71 71
72 if (port[n] == SNDRV_AUTO_PORT) { 72 if (port[n] == SNDRV_AUTO_PORT) {
73 snd_printk(KERN_ERR "%s: please specify port\n", dev->bus_id); 73 dev_err(dev, "please specify port\n");
74 return 0; 74 return 0;
75 } 75 }
76 if (irq[n] == SNDRV_AUTO_IRQ) { 76 if (irq[n] == SNDRV_AUTO_IRQ) {
77 snd_printk(KERN_ERR "%s: please specify irq\n", dev->bus_id); 77 dev_err(dev, "please specify irq\n");
78 return 0; 78 return 0;
79 } 79 }
80 if (dma1[n] == SNDRV_AUTO_DMA) { 80 if (dma1[n] == SNDRV_AUTO_DMA) {
81 snd_printk(KERN_ERR "%s: please specify dma1\n", dev->bus_id); 81 dev_err(dev, "please specify dma1\n");
82 return 0; 82 return 0;
83 } 83 }
84 return 1; 84 return 1;
diff --git a/sound/isa/adlib.c b/sound/isa/adlib.c
index efa8c80d05b6..374b7177e111 100644
--- a/sound/isa/adlib.c
+++ b/sound/isa/adlib.c
@@ -36,7 +36,7 @@ static int __devinit snd_adlib_match(struct device *dev, unsigned int n)
36 return 0; 36 return 0;
37 37
38 if (port[n] == SNDRV_AUTO_PORT) { 38 if (port[n] == SNDRV_AUTO_PORT) {
39 snd_printk(KERN_ERR "%s: please specify port\n", dev->bus_id); 39 dev_err(dev, "please specify port\n");
40 return 0; 40 return 0;
41 } 41 }
42 return 1; 42 return 1;
@@ -55,13 +55,13 @@ static int __devinit snd_adlib_probe(struct device *dev, unsigned int n)
55 55
56 card = snd_card_new(index[n], id[n], THIS_MODULE, 0); 56 card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
57 if (!card) { 57 if (!card) {
58 snd_printk(KERN_ERR "%s: could not create card\n", dev->bus_id); 58 dev_err(dev, "could not create card\n");
59 return -EINVAL; 59 return -EINVAL;
60 } 60 }
61 61
62 card->private_data = request_region(port[n], 4, CRD_NAME); 62 card->private_data = request_region(port[n], 4, CRD_NAME);
63 if (!card->private_data) { 63 if (!card->private_data) {
64 snd_printk(KERN_ERR "%s: could not grab ports\n", dev->bus_id); 64 dev_err(dev, "could not grab ports\n");
65 error = -EBUSY; 65 error = -EBUSY;
66 goto out; 66 goto out;
67 } 67 }
@@ -73,13 +73,13 @@ static int __devinit snd_adlib_probe(struct device *dev, unsigned int n)
73 73
74 error = snd_opl3_create(card, port[n], port[n] + 2, OPL3_HW_AUTO, 1, &opl3); 74 error = snd_opl3_create(card, port[n], port[n] + 2, OPL3_HW_AUTO, 1, &opl3);
75 if (error < 0) { 75 if (error < 0) {
76 snd_printk(KERN_ERR "%s: could not create OPL\n", dev->bus_id); 76 dev_err(dev, "could not create OPL\n");
77 goto out; 77 goto out;
78 } 78 }
79 79
80 error = snd_opl3_hwdep_new(opl3, 0, 0, NULL); 80 error = snd_opl3_hwdep_new(opl3, 0, 0, NULL);
81 if (error < 0) { 81 if (error < 0) {
82 snd_printk(KERN_ERR "%s: could not create FM\n", dev->bus_id); 82 dev_err(dev, "could not create FM\n");
83 goto out; 83 goto out;
84 } 84 }
85 85
@@ -87,7 +87,7 @@ static int __devinit snd_adlib_probe(struct device *dev, unsigned int n)
87 87
88 error = snd_card_register(card); 88 error = snd_card_register(card);
89 if (error < 0) { 89 if (error < 0) {
90 snd_printk(KERN_ERR "%s: could not register card\n", dev->bus_id); 90 dev_err(dev, "could not register card\n");
91 goto out; 91 goto out;
92 } 92 }
93 93
diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c
index ddd289120aa8..f019d449e2d6 100644
--- a/sound/isa/cs423x/cs4231.c
+++ b/sound/isa/cs423x/cs4231.c
@@ -74,15 +74,15 @@ static int __devinit snd_cs4231_match(struct device *dev, unsigned int n)
74 return 0; 74 return 0;
75 75
76 if (port[n] == SNDRV_AUTO_PORT) { 76 if (port[n] == SNDRV_AUTO_PORT) {
77 snd_printk(KERN_ERR "%s: please specify port\n", dev->bus_id); 77 dev_err(dev, "please specify port\n");
78 return 0; 78 return 0;
79 } 79 }
80 if (irq[n] == SNDRV_AUTO_IRQ) { 80 if (irq[n] == SNDRV_AUTO_IRQ) {
81 snd_printk(KERN_ERR "%s: please specify irq\n", dev->bus_id); 81 dev_err(dev, "please specify irq\n");
82 return 0; 82 return 0;
83 } 83 }
84 if (dma1[n] == SNDRV_AUTO_DMA) { 84 if (dma1[n] == SNDRV_AUTO_DMA) {
85 snd_printk(KERN_ERR "%s: please specify dma1\n", dev->bus_id); 85 dev_err(dev, "please specify dma1\n");
86 return 0; 86 return 0;
87 } 87 }
88 return 1; 88 return 1;
@@ -133,7 +133,7 @@ static int __devinit snd_cs4231_probe(struct device *dev, unsigned int n)
133 mpu_port[n], 0, mpu_irq[n], 133 mpu_port[n], 0, mpu_irq[n],
134 mpu_irq[n] >= 0 ? IRQF_DISABLED : 0, 134 mpu_irq[n] >= 0 ? IRQF_DISABLED : 0,
135 NULL) < 0) 135 NULL) < 0)
136 printk(KERN_WARNING "%s: MPU401 not detected\n", dev->bus_id); 136 dev_warn(dev, "MPU401 not detected\n");
137 } 137 }
138 138
139 snd_card_set_dev(card, dev); 139 snd_card_set_dev(card, dev);
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
index 91f9c15d3e30..019c9401663e 100644
--- a/sound/isa/cs423x/cs4236.c
+++ b/sound/isa/cs423x/cs4236.c
@@ -488,19 +488,19 @@ static int __devinit snd_cs423x_isa_match(struct device *pdev,
488 return 0; 488 return 0;
489 489
490 if (port[dev] == SNDRV_AUTO_PORT) { 490 if (port[dev] == SNDRV_AUTO_PORT) {
491 snd_printk(KERN_ERR "%s: please specify port\n", pdev->bus_id); 491 dev_err(pdev, "please specify port\n");
492 return 0; 492 return 0;
493 } 493 }
494 if (cport[dev] == SNDRV_AUTO_PORT) { 494 if (cport[dev] == SNDRV_AUTO_PORT) {
495 snd_printk(KERN_ERR "%s: please specify cport\n", pdev->bus_id); 495 dev_err(pdev, "please specify cport\n");
496 return 0; 496 return 0;
497 } 497 }
498 if (irq[dev] == SNDRV_AUTO_IRQ) { 498 if (irq[dev] == SNDRV_AUTO_IRQ) {
499 snd_printk(KERN_ERR "%s: please specify irq\n", pdev->bus_id); 499 dev_err(pdev, "please specify irq\n");
500 return 0; 500 return 0;
501 } 501 }
502 if (dma1[dev] == SNDRV_AUTO_DMA) { 502 if (dma1[dev] == SNDRV_AUTO_DMA) {
503 snd_printk(KERN_ERR "%s: please specify dma1\n", pdev->bus_id); 503 dev_err(pdev, "please specify dma1\n");
504 return 0; 504 return 0;
505 } 505 }
506 return 1; 506 return 1;
diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c
index f88639ea64b2..b46377139cf8 100644
--- a/sound/isa/es1688/es1688.c
+++ b/sound/isa/es1688/es1688.c
@@ -88,16 +88,14 @@ static int __devinit snd_es1688_legacy_create(struct snd_card *card,
88 if (irq[n] == SNDRV_AUTO_IRQ) { 88 if (irq[n] == SNDRV_AUTO_IRQ) {
89 irq[n] = snd_legacy_find_free_irq(possible_irqs); 89 irq[n] = snd_legacy_find_free_irq(possible_irqs);
90 if (irq[n] < 0) { 90 if (irq[n] < 0) {
91 snd_printk(KERN_ERR "%s: unable to find a free IRQ\n", 91 dev_err(dev, "unable to find a free IRQ\n");
92 dev->bus_id);
93 return -EBUSY; 92 return -EBUSY;
94 } 93 }
95 } 94 }
96 if (dma8[n] == SNDRV_AUTO_DMA) { 95 if (dma8[n] == SNDRV_AUTO_DMA) {
97 dma8[n] = snd_legacy_find_free_dma(possible_dmas); 96 dma8[n] = snd_legacy_find_free_dma(possible_dmas);
98 if (dma8[n] < 0) { 97 if (dma8[n] < 0) {
99 snd_printk(KERN_ERR "%s: unable to find a free DMA\n", 98 dev_err(dev, "unable to find a free DMA\n");
100 dev->bus_id);
101 return -EBUSY; 99 return -EBUSY;
102 } 100 }
103 } 101 }
@@ -147,8 +145,7 @@ static int __devinit snd_es1688_probe(struct device *dev, unsigned int n)
147 145
148 if (snd_opl3_create(card, chip->port, chip->port + 2, 146 if (snd_opl3_create(card, chip->port, chip->port + 2,
149 OPL3_HW_OPL3, 0, &opl3) < 0) 147 OPL3_HW_OPL3, 0, &opl3) < 0)
150 printk(KERN_WARNING "%s: opl3 not detected at 0x%lx\n", 148 dev_warn(dev, "opl3 not detected at 0x%lx\n", chip->port);
151 dev->bus_id, chip->port);
152 else { 149 else {
153 error = snd_opl3_hwdep_new(opl3, 0, 1, NULL); 150 error = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
154 if (error < 0) 151 if (error < 0)
diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c
index 8f914b37bf89..426532a4d730 100644
--- a/sound/isa/gus/gusclassic.c
+++ b/sound/isa/gus/gusclassic.c
@@ -90,24 +90,21 @@ static int __devinit snd_gusclassic_create(struct snd_card *card,
90 if (irq[n] == SNDRV_AUTO_IRQ) { 90 if (irq[n] == SNDRV_AUTO_IRQ) {
91 irq[n] = snd_legacy_find_free_irq(possible_irqs); 91 irq[n] = snd_legacy_find_free_irq(possible_irqs);
92 if (irq[n] < 0) { 92 if (irq[n] < 0) {
93 snd_printk(KERN_ERR "%s: unable to find a free IRQ\n", 93 dev_err(dev, "unable to find a free IRQ\n");
94 dev->bus_id);
95 return -EBUSY; 94 return -EBUSY;
96 } 95 }
97 } 96 }
98 if (dma1[n] == SNDRV_AUTO_DMA) { 97 if (dma1[n] == SNDRV_AUTO_DMA) {
99 dma1[n] = snd_legacy_find_free_dma(possible_dmas); 98 dma1[n] = snd_legacy_find_free_dma(possible_dmas);
100 if (dma1[n] < 0) { 99 if (dma1[n] < 0) {
101 snd_printk(KERN_ERR "%s: unable to find a free DMA1\n", 100 dev_err(dev, "unable to find a free DMA1\n");
102 dev->bus_id);
103 return -EBUSY; 101 return -EBUSY;
104 } 102 }
105 } 103 }
106 if (dma2[n] == SNDRV_AUTO_DMA) { 104 if (dma2[n] == SNDRV_AUTO_DMA) {
107 dma2[n] = snd_legacy_find_free_dma(possible_dmas); 105 dma2[n] = snd_legacy_find_free_dma(possible_dmas);
108 if (dma2[n] < 0) { 106 if (dma2[n] < 0) {
109 snd_printk(KERN_ERR "%s: unable to find a free DMA2\n", 107 dev_err(dev, "unable to find a free DMA2\n");
110 dev->bus_id);
111 return -EBUSY; 108 return -EBUSY;
112 } 109 }
113 } 110 }
@@ -174,8 +171,8 @@ static int __devinit snd_gusclassic_probe(struct device *dev, unsigned int n)
174 171
175 error = -ENODEV; 172 error = -ENODEV;
176 if (gus->max_flag || gus->ess_flag) { 173 if (gus->max_flag || gus->ess_flag) {
177 snd_printk(KERN_ERR "%s: GUS Classic or ACE soundcard was " 174 dev_err(dev, "GUS Classic or ACE soundcard was "
178 "not detected at 0x%lx\n", dev->bus_id, gus->gf1.port); 175 "not detected at 0x%lx\n", gus->gf1.port);
179 goto out; 176 goto out;
180 } 177 }
181 178
diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c
index da13185eb0a0..7ad4c3b41a84 100644
--- a/sound/isa/gus/gusextreme.c
+++ b/sound/isa/gus/gusextreme.c
@@ -106,16 +106,14 @@ static int __devinit snd_gusextreme_es1688_create(struct snd_card *card,
106 if (irq[n] == SNDRV_AUTO_IRQ) { 106 if (irq[n] == SNDRV_AUTO_IRQ) {
107 irq[n] = snd_legacy_find_free_irq(possible_irqs); 107 irq[n] = snd_legacy_find_free_irq(possible_irqs);
108 if (irq[n] < 0) { 108 if (irq[n] < 0) {
109 snd_printk(KERN_ERR "%s: unable to find a free IRQ " 109 dev_err(dev, "unable to find a free IRQ for ES1688\n");
110 "for ES1688\n", dev->bus_id);
111 return -EBUSY; 110 return -EBUSY;
112 } 111 }
113 } 112 }
114 if (dma8[n] == SNDRV_AUTO_DMA) { 113 if (dma8[n] == SNDRV_AUTO_DMA) {
115 dma8[n] = snd_legacy_find_free_dma(possible_dmas); 114 dma8[n] = snd_legacy_find_free_dma(possible_dmas);
116 if (dma8[n] < 0) { 115 if (dma8[n] < 0) {
117 snd_printk(KERN_ERR "%s: unable to find a free DMA " 116 dev_err(dev, "unable to find a free DMA for ES1688\n");
118 "for ES1688\n", dev->bus_id);
119 return -EBUSY; 117 return -EBUSY;
120 } 118 }
121 } 119 }
@@ -143,16 +141,14 @@ static int __devinit snd_gusextreme_gus_card_create(struct snd_card *card,
143 if (gf1_irq[n] == SNDRV_AUTO_IRQ) { 141 if (gf1_irq[n] == SNDRV_AUTO_IRQ) {
144 gf1_irq[n] = snd_legacy_find_free_irq(possible_irqs); 142 gf1_irq[n] = snd_legacy_find_free_irq(possible_irqs);
145 if (gf1_irq[n] < 0) { 143 if (gf1_irq[n] < 0) {
146 snd_printk(KERN_ERR "%s: unable to find a free IRQ " 144 dev_err(dev, "unable to find a free IRQ for GF1\n");
147 "for GF1\n", dev->bus_id);
148 return -EBUSY; 145 return -EBUSY;
149 } 146 }
150 } 147 }
151 if (dma1[n] == SNDRV_AUTO_DMA) { 148 if (dma1[n] == SNDRV_AUTO_DMA) {
152 dma1[n] = snd_legacy_find_free_dma(possible_dmas); 149 dma1[n] = snd_legacy_find_free_dma(possible_dmas);
153 if (dma1[n] < 0) { 150 if (dma1[n] < 0) {
154 snd_printk(KERN_ERR "%s: unable to find a free DMA " 151 dev_err(dev, "unable to find a free DMA for GF1\n");
155 "for GF1\n", dev->bus_id);
156 return -EBUSY; 152 return -EBUSY;
157 } 153 }
158 } 154 }
@@ -278,8 +274,8 @@ static int __devinit snd_gusextreme_probe(struct device *dev, unsigned int n)
278 274
279 error = -ENODEV; 275 error = -ENODEV;
280 if (!gus->ess_flag) { 276 if (!gus->ess_flag) {
281 snd_printk(KERN_ERR "%s: GUS Extreme soundcard was not " 277 dev_err(dev, "GUS Extreme soundcard was not "
282 "detected at 0x%lx\n", dev->bus_id, gus->gf1.port); 278 "detected at 0x%lx\n", gus->gf1.port);
283 goto out; 279 goto out;
284 } 280 }
285 gus->codec_flag = 1; 281 gus->codec_flag = 1;
@@ -310,8 +306,7 @@ static int __devinit snd_gusextreme_probe(struct device *dev, unsigned int n)
310 306
311 if (snd_opl3_create(card, es1688->port, es1688->port + 2, 307 if (snd_opl3_create(card, es1688->port, es1688->port + 2,
312 OPL3_HW_OPL3, 0, &opl3) < 0) 308 OPL3_HW_OPL3, 0, &opl3) < 0)
313 printk(KERN_ERR "%s: opl3 not detected at 0x%lx\n", 309 dev_warn(dev, "opl3 not detected at 0x%lx\n", es1688->port);
314 dev->bus_id, es1688->port);
315 else { 310 else {
316 error = snd_opl3_hwdep_new(opl3, 0, 2, NULL); 311 error = snd_opl3_hwdep_new(opl3, 0, 2, NULL);
317 if (error < 0) 312 if (error < 0)
diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c
index 336a34277907..667eccc676a4 100644
--- a/sound/isa/sb/sb8.c
+++ b/sound/isa/sb/sb8.c
@@ -85,11 +85,11 @@ static int __devinit snd_sb8_match(struct device *pdev, unsigned int dev)
85 if (!enable[dev]) 85 if (!enable[dev])
86 return 0; 86 return 0;
87 if (irq[dev] == SNDRV_AUTO_IRQ) { 87 if (irq[dev] == SNDRV_AUTO_IRQ) {
88 snd_printk(KERN_ERR "%s: please specify irq\n", pdev->bus_id); 88 dev_err(pdev, "please specify irq\n");
89 return 0; 89 return 0;
90 } 90 }
91 if (dma8[dev] == SNDRV_AUTO_DMA) { 91 if (dma8[dev] == SNDRV_AUTO_DMA) {
92 snd_printk(KERN_ERR "%s: please specify dma8\n", pdev->bus_id); 92 dev_err(pdev, "please specify dma8\n");
93 return 0; 93 return 0;
94 } 94 }
95 return 1; 95 return 1;
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 2f283ea6ad9a..de5ee8f097f6 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1464,6 +1464,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1464 .ca0151_chip = 1, 1464 .ca0151_chip = 1,
1465 .spk71 = 1, 1465 .spk71 = 1,
1466 .spdif_bug = 1, 1466 .spdif_bug = 1,
1467 .invert_shared_spdif = 1, /* digital/analog switch swapped */
1467 .ac97_chip = 1} , 1468 .ac97_chip = 1} ,
1468 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, 1469 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102,
1469 .driver = "Audigy2", .name = "Audigy 2 ZS [SB0350]", 1470 .driver = "Audigy2", .name = "Audigy 2 ZS [SB0350]",
@@ -1473,6 +1474,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1473 .ca0151_chip = 1, 1474 .ca0151_chip = 1,
1474 .spk71 = 1, 1475 .spk71 = 1,
1475 .spdif_bug = 1, 1476 .spdif_bug = 1,
1477 .invert_shared_spdif = 1, /* digital/analog switch swapped */
1476 .ac97_chip = 1} , 1478 .ac97_chip = 1} ,
1477 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102, 1479 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102,
1478 .driver = "Audigy2", .name = "Audigy 2 ZS [2001]", 1480 .driver = "Audigy2", .name = "Audigy 2 ZS [2001]",
@@ -1482,6 +1484,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1482 .ca0151_chip = 1, 1484 .ca0151_chip = 1,
1483 .spk71 = 1, 1485 .spk71 = 1,
1484 .spdif_bug = 1, 1486 .spdif_bug = 1,
1487 .invert_shared_spdif = 1, /* digital/analog switch swapped */
1485 .ac97_chip = 1} , 1488 .ac97_chip = 1} ,
1486 /* Audigy 2 */ 1489 /* Audigy 2 */
1487 /* Tested by James@superbug.co.uk 3rd July 2005 */ 1490 /* Tested by James@superbug.co.uk 3rd July 2005 */
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 4eceab9bd109..a4666c96a44f 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -829,6 +829,7 @@ static void alc_sku_automute(struct hda_codec *codec)
829 spec->jack_present ? 0 : PIN_OUT); 829 spec->jack_present ? 0 : PIN_OUT);
830} 830}
831 831
832#if 0 /* it's broken in some acses -- temporarily disabled */
832static void alc_mic_automute(struct hda_codec *codec) 833static void alc_mic_automute(struct hda_codec *codec)
833{ 834{
834 struct alc_spec *spec = codec->spec; 835 struct alc_spec *spec = codec->spec;
@@ -849,6 +850,9 @@ static void alc_mic_automute(struct hda_codec *codec)
849 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic, 850 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
850 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 851 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
851} 852}
853#else
854#define alc_mic_automute(codec) /* NOP */
855#endif /* disabled */
852 856
853/* unsolicited event for HP jack sensing */ 857/* unsolicited event for HP jack sensing */
854static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) 858static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -1058,12 +1062,14 @@ do_sku:
1058 AC_VERB_SET_UNSOLICITED_ENABLE, 1062 AC_VERB_SET_UNSOLICITED_ENABLE,
1059 AC_USRSP_EN | ALC880_HP_EVENT); 1063 AC_USRSP_EN | ALC880_HP_EVENT);
1060 1064
1065#if 0 /* it's broken in some acses -- temporarily disabled */
1061 if (spec->autocfg.input_pins[AUTO_PIN_MIC] && 1066 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1062 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]) 1067 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1063 snd_hda_codec_write(codec, 1068 snd_hda_codec_write(codec,
1064 spec->autocfg.input_pins[AUTO_PIN_MIC], 0, 1069 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1065 AC_VERB_SET_UNSOLICITED_ENABLE, 1070 AC_VERB_SET_UNSOLICITED_ENABLE,
1066 AC_USRSP_EN | ALC880_MIC_EVENT); 1071 AC_USRSP_EN | ALC880_MIC_EVENT);
1072#endif /* disabled */
1067 1073
1068 spec->unsol_event = alc_sku_unsol_event; 1074 spec->unsol_event = alc_sku_unsol_event;
1069} 1075}
@@ -8408,6 +8414,7 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
8408static struct snd_pci_quirk alc883_cfg_tbl[] = { 8414static struct snd_pci_quirk alc883_cfg_tbl[] = {
8409 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), 8415 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
8410 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), 8416 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8417 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
8411 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE), 8418 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8412 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE), 8419 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
8413 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE), 8420 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
@@ -12238,8 +12245,26 @@ static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12238 return 0; 12245 return 0;
12239} 12246}
12240 12247
12241#define alc269_auto_create_analog_input_ctls \ 12248static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12242 alc880_auto_create_analog_input_ctls 12249 const struct auto_pin_cfg *cfg)
12250{
12251 int err;
12252
12253 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12254 if (err < 0)
12255 return err;
12256 /* digital-mic input pin is excluded in alc880_auto_create..()
12257 * because it's under 0x18
12258 */
12259 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12260 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
12261 struct hda_input_mux *imux = &spec->private_imux;
12262 imux->items[imux->num_items].label = "Int Mic";
12263 imux->items[imux->num_items].index = 0x05;
12264 imux->num_items++;
12265 }
12266 return 0;
12267}
12243 12268
12244#ifdef CONFIG_SND_HDA_POWER_SAVE 12269#ifdef CONFIG_SND_HDA_POWER_SAVE
12245#define alc269_loopbacks alc880_loopbacks 12270#define alc269_loopbacks alc880_loopbacks
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index df9b0bc7f878..e6085915d86d 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -69,6 +69,7 @@ enum {
69enum { 69enum {
70 STAC_92HD73XX_REF, 70 STAC_92HD73XX_REF,
71 STAC_DELL_M6, 71 STAC_DELL_M6,
72 STAC_DELL_EQ,
72 STAC_92HD73XX_MODELS 73 STAC_92HD73XX_MODELS
73}; 74};
74 75
@@ -773,9 +774,7 @@ static struct hda_verb dell_eq_core_init[] = {
773}; 774};
774 775
775static struct hda_verb dell_m6_core_init[] = { 776static struct hda_verb dell_m6_core_init[] = {
776 /* set master volume to max value without distortion 777 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
777 * and direct control */
778 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
779 /* setup audio connections */ 778 /* setup audio connections */
780 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, 779 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
781 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01}, 780 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
@@ -1600,11 +1599,13 @@ static unsigned int dell_m6_pin_configs[13] = {
1600static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { 1599static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1601 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, 1600 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1602 [STAC_DELL_M6] = dell_m6_pin_configs, 1601 [STAC_DELL_M6] = dell_m6_pin_configs,
1602 [STAC_DELL_EQ] = dell_m6_pin_configs,
1603}; 1603};
1604 1604
1605static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { 1605static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1606 [STAC_92HD73XX_REF] = "ref", 1606 [STAC_92HD73XX_REF] = "ref",
1607 [STAC_DELL_M6] = "dell-m6", 1607 [STAC_DELL_M6] = "dell-m6",
1608 [STAC_DELL_EQ] = "dell-eq",
1608}; 1609};
1609 1610
1610static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { 1611static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
@@ -4131,12 +4132,17 @@ again:
4131 sizeof(stac92hd73xx_dmux)); 4132 sizeof(stac92hd73xx_dmux));
4132 4133
4133 switch (spec->board_config) { 4134 switch (spec->board_config) {
4134 case STAC_DELL_M6: 4135 case STAC_DELL_EQ:
4135 spec->init = dell_eq_core_init; 4136 spec->init = dell_eq_core_init;
4137 /* fallthru */
4138 case STAC_DELL_M6:
4136 spec->num_smuxes = 0; 4139 spec->num_smuxes = 0;
4137 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER]; 4140 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4138 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; 4141 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4139 spec->num_amps = 1; 4142 spec->num_amps = 1;
4143
4144 if (!spec->init)
4145 spec->init = dell_m6_core_init;
4140 switch (codec->subsystem_id) { 4146 switch (codec->subsystem_id) {
4141 case 0x1028025e: /* Analog Mics */ 4147 case 0x1028025e: /* Analog Mics */
4142 case 0x1028025f: 4148 case 0x1028025f:
@@ -4146,8 +4152,6 @@ again:
4146 break; 4152 break;
4147 case 0x10280271: /* Digital Mics */ 4153 case 0x10280271: /* Digital Mics */
4148 case 0x10280272: 4154 case 0x10280272:
4149 spec->init = dell_m6_core_init;
4150 /* fall-through */
4151 case 0x10280254: 4155 case 0x10280254:
4152 case 0x10280255: 4156 case 0x10280255:
4153 stac92xx_set_config_reg(codec, 0x13, 0x90A60160); 4157 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index a3adbf06b1e5..16c7453f4946 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -95,8 +95,8 @@ static int soc_ac97_dev_register(struct snd_soc_codec *codec)
95 codec->ac97->dev.parent = NULL; 95 codec->ac97->dev.parent = NULL;
96 codec->ac97->dev.release = soc_ac97_device_release; 96 codec->ac97->dev.release = soc_ac97_device_release;
97 97
98 snprintf(codec->ac97->dev.bus_id, BUS_ID_SIZE, "%d-%d:%s", 98 dev_set_name(&codec->ac97->dev, "%d-%d:%s",
99 codec->card->number, 0, codec->name); 99 codec->card->number, 0, codec->name);
100 err = device_register(&codec->ac97->dev); 100 err = device_register(&codec->ac97->dev);
101 if (err < 0) { 101 if (err < 0) {
102 snd_printk(KERN_ERR "Can't register ac97 bus\n"); 102 snd_printk(KERN_ERR "Can't register ac97 bus\n");