Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 101004
b: refs/heads/master
c: 5a86102
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed Jul 14, 2008
1 parent c7255b4 commit f29da77
Show file tree
Hide file tree
Showing 796 changed files with 57,697 additions and 10,589 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 751851af7aae9b8bd5a60b3897209081fbc18b2b
refs/heads/master: 5a86102248592e178a9023359ccf7f0e489d8e35
5 changes: 5 additions & 0 deletions trunk/Documentation/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,11 @@ and is between 256 and 4096 characters. It is defined in the file
mtdparts= [MTD]
See drivers/mtd/cmdlinepart.c.

mtdset= [ARM]
ARM/S3C2412 JIVE boot control

See arch/arm/mach-s3c2412/mach-jive.c

mtouchusb.raw_coordinates=
[HW] Make the MicroTouch USB driver use raw coordinates
('y', default) or cooked coordinates ('n')
Expand Down
164 changes: 164 additions & 0 deletions trunk/Documentation/tracers/mmiotrace.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
In-kernel memory-mapped I/O tracing


Home page and links to optional user space tools:

http://nouveau.freedesktop.org/wiki/MmioTrace

MMIO tracing was originally developed by Intel around 2003 for their Fault
Injection Test Harness. In Dec 2006 - Jan 2007, using the code from Intel,
Jeff Muizelaar created a tool for tracing MMIO accesses with the Nouveau
project in mind. Since then many people have contributed.

Mmiotrace was built for reverse engineering any memory-mapped IO device with
the Nouveau project as the first real user. Only x86 and x86_64 architectures
are supported.

Out-of-tree mmiotrace was originally modified for mainline inclusion and
ftrace framework by Pekka Paalanen <pq@iki.fi>.


Preparation
-----------

Mmiotrace feature is compiled in by the CONFIG_MMIOTRACE option. Tracing is
disabled by default, so it is safe to have this set to yes. SMP systems are
supported, but tracing is unreliable and may miss events if more than one CPU
is on-line, therefore mmiotrace takes all but one CPU off-line during run-time
activation. You can re-enable CPUs by hand, but you have been warned, there
is no way to automatically detect if you are losing events due to CPUs racing.


Usage Quick Reference
---------------------

$ mount -t debugfs debugfs /debug
$ echo mmiotrace > /debug/tracing/current_tracer
$ cat /debug/tracing/trace_pipe > mydump.txt &
Start X or whatever.
$ echo "X is up" > /debug/tracing/marker
$ echo none > /debug/tracing/current_tracer
Check for lost events.


Usage
-----

Make sure debugfs is mounted to /debug. If not, (requires root privileges)
$ mount -t debugfs debugfs /debug

Check that the driver you are about to trace is not loaded.

Activate mmiotrace (requires root privileges):
$ echo mmiotrace > /debug/tracing/current_tracer

Start storing the trace:
$ cat /debug/tracing/trace_pipe > mydump.txt &
The 'cat' process should stay running (sleeping) in the background.

Load the driver you want to trace and use it. Mmiotrace will only catch MMIO
accesses to areas that are ioremapped while mmiotrace is active.

[Unimplemented feature:]
During tracing you can place comments (markers) into the trace by
$ echo "X is up" > /debug/tracing/marker
This makes it easier to see which part of the (huge) trace corresponds to
which action. It is recommended to place descriptive markers about what you
do.

Shut down mmiotrace (requires root privileges):
$ echo none > /debug/tracing/current_tracer
The 'cat' process exits. If it does not, kill it by issuing 'fg' command and
pressing ctrl+c.

Check that mmiotrace did not lose events due to a buffer filling up. Either
$ grep -i lost mydump.txt
which tells you exactly how many events were lost, or use
$ dmesg
to view your kernel log and look for "mmiotrace has lost events" warning. If
events were lost, the trace is incomplete. You should enlarge the buffers and
try again. Buffers are enlarged by first seeing how large the current buffers
are:
$ cat /debug/tracing/trace_entries
gives you a number. Approximately double this number and write it back, for
instance:
$ echo 128000 > /debug/tracing/trace_entries
Then start again from the top.

If you are doing a trace for a driver project, e.g. Nouveau, you should also
do the following before sending your results:
$ lspci -vvv > lspci.txt
$ dmesg > dmesg.txt
$ tar zcf pciid-nick-mmiotrace.tar.gz mydump.txt lspci.txt dmesg.txt
and then send the .tar.gz file. The trace compresses considerably. Replace
"pciid" and "nick" with the PCI ID or model name of your piece of hardware
under investigation and your nick name.


How Mmiotrace Works
-------------------

Access to hardware IO-memory is gained by mapping addresses from PCI bus by
calling one of the ioremap_*() functions. Mmiotrace is hooked into the
__ioremap() function and gets called whenever a mapping is created. Mapping is
an event that is recorded into the trace log. Note, that ISA range mappings
are not caught, since the mapping always exists and is returned directly.

MMIO accesses are recorded via page faults. Just before __ioremap() returns,
the mapped pages are marked as not present. Any access to the pages causes a
fault. The page fault handler calls mmiotrace to handle the fault. Mmiotrace
marks the page present, sets TF flag to achieve single stepping and exits the
fault handler. The instruction that faulted is executed and debug trap is
entered. Here mmiotrace again marks the page as not present. The instruction
is decoded to get the type of operation (read/write), data width and the value
read or written. These are stored to the trace log.

Setting the page present in the page fault handler has a race condition on SMP
machines. During the single stepping other CPUs may run freely on that page
and events can be missed without a notice. Re-enabling other CPUs during
tracing is discouraged.


Trace Log Format
----------------

The raw log is text and easily filtered with e.g. grep and awk. One record is
one line in the log. A record starts with a keyword, followed by keyword
dependant arguments. Arguments are separated by a space, or continue until the
end of line. The format for version 20070824 is as follows:

Explanation Keyword Space separated arguments
---------------------------------------------------------------------------

read event R width, timestamp, map id, physical, value, PC, PID
write event W width, timestamp, map id, physical, value, PC, PID
ioremap event MAP timestamp, map id, physical, virtual, length, PC, PID
iounmap event UNMAP timestamp, map id, PC, PID
marker MARK timestamp, text
version VERSION the string "20070824"
info for reader LSPCI one line from lspci -v
PCI address map PCIDEV space separated /proc/bus/pci/devices data
unk. opcode UNKNOWN timestamp, map id, physical, data, PC, PID

Timestamp is in seconds with decimals. Physical is a PCI bus address, virtual
is a kernel virtual address. Width is the data width in bytes and value is the
data value. Map id is an arbitrary id number identifying the mapping that was
used in an operation. PC is the program counter and PID is process id. PC is
zero if it is not recorded. PID is always zero as tracing MMIO accesses
originating in user space memory is not yet supported.

For instance, the following awk filter will pass all 32-bit writes that target
physical addresses in the range [0xfb73ce40, 0xfb800000[

$ awk '/W 4 / { adr=strtonum($5); if (adr >= 0xfb73ce40 &&
adr < 0xfb800000) print; }'


Tools for Developers
--------------------

The user space tools include utilities for:
- replacing numeric addresses and values with hardware register names
- replaying MMIO logs, i.e., re-executing the recorded writes


4 changes: 4 additions & 0 deletions trunk/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,10 @@ KBUILD_CFLAGS += -g
KBUILD_AFLAGS += -gdwarf-2
endif

ifdef CONFIG_FTRACE
KBUILD_CFLAGS += -pg
endif

# We trigger additional mismatches with less inlining
ifdef CONFIG_DEBUG_SECTION_MISMATCH
KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
Expand Down
90 changes: 60 additions & 30 deletions trunk/arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ config ARM
select HAVE_OPROFILE
select HAVE_KPROBES if (!XIP_KERNEL)
select HAVE_KRETPROBES if (HAVE_KPROBES)
select HAVE_FTRACE if (!XIP_KERNEL)
select HAVE_DYNAMIC_FTRACE if (HAVE_FTRACE)
help
The ARM series is a line of low-power-consumption RISC chip designs
licensed by ARM Ltd and targeted at embedded applications and
Expand All @@ -22,6 +24,9 @@ config ARM
Europe. There is an ARM Linux project with a web page at
<http://www.arm.linux.org.uk/>.

config HAVE_PWM
bool

config SYS_SUPPORTS_APM_EMULATION
bool

Expand Down Expand Up @@ -84,6 +89,11 @@ config STACKTRACE_SUPPORT
bool
default y

config HAVE_LATENCYTOP_SUPPORT
bool
depends on !SMP
default y

config LOCKDEP_SUPPORT
bool
default y
Expand Down Expand Up @@ -147,6 +157,10 @@ config FIQ
config ARCH_MTD_XIP
bool

config GENERIC_HARDIRQS_NO__DO_IRQ
bool
def_bool y

if OPROFILE

config OPROFILE_ARMV6
Expand Down Expand Up @@ -232,13 +246,6 @@ config ARCH_CLPS711X
help
Support for Cirrus Logic 711x/721x based boards.

config ARCH_CO285
bool "Co-EBSA285"
select FOOTBRIDGE
select FOOTBRIDGE_ADDIN
help
Support for Intel's EBSA285 companion chip.

config ARCH_EBSA110
bool "EBSA-110"
select ISA
Expand Down Expand Up @@ -299,6 +306,8 @@ config ARCH_IOP32X
depends on MMU
select PLAT_IOP
select PCI
select GENERIC_GPIO
select HAVE_GPIO_LIB
help
Support for Intel's 80219 and IOP32X (XScale) family of
processors.
Expand All @@ -308,6 +317,8 @@ config ARCH_IOP33X
depends on MMU
select PLAT_IOP
select PCI
select GENERIC_GPIO
select HAVE_GPIO_LIB
help
Support for Intel's IOP33X (XScale) family of processors.

Expand Down Expand Up @@ -347,6 +358,16 @@ config ARCH_L7200
If you have any questions or comments about the Linux kernel port
to this board, send e-mail to <sjhill@cotw.com>.

config ARCH_KIRKWOOD
bool "Marvell Kirkwood"
select PCI
select GENERIC_TIME
select GENERIC_CLOCKEVENTS
select PLAT_ORION
help
Support for the following Marvell Kirkwood series SoCs:
88F6180, 88F6192 and 88F6281.

config ARCH_KS8695
bool "Micrel/Kendin KS8695"
select GENERIC_GPIO
Expand All @@ -365,9 +386,31 @@ config ARCH_NS9XXX

<http://www.digi.com/products/microprocessors/index.jsp>

config ARCH_LOKI
bool "Marvell Loki (88RC8480)"
select GENERIC_TIME
select GENERIC_CLOCKEVENTS
select PLAT_ORION
help
Support for the Marvell Loki (88RC8480) SoC.

config ARCH_MV78XX0
bool "Marvell MV78xx0"
select PCI
select GENERIC_TIME
select GENERIC_CLOCKEVENTS
select PLAT_ORION
help
Support for the following Marvell MV78xx0 series SoCs:
MV781x0, MV782x0.

config ARCH_MXC
bool "Freescale MXC/iMX-based"
select GENERIC_TIME
select GENERIC_CLOCKEVENTS
select ARCH_MTD_XIP
select GENERIC_GPIO
select HAVE_GPIO_LIB
help
Support for Freescale MXC/iMX-based family of processors

Expand All @@ -381,7 +424,8 @@ config ARCH_ORION5X
select PLAT_ORION
help
Support for the following Marvell Orion 5x series SoCs:
Orion-1 (5181), Orion-NAS (5182), Orion-2 (5281.)
Orion-1 (5181), Orion-VoIP (5181L), Orion-NAS (5182),
Orion-2 (5281).

config ARCH_PNX4008
bool "Philips Nexperia PNX4008 Mobile"
Expand All @@ -406,6 +450,7 @@ config ARCH_RPC
select FIQ
select TIMER_ACORN
select ARCH_MAY_HAVE_PC_FDC
select HAVE_PATA_PLATFORM
select ISA_DMA_API
select NO_IOPORT
help
Expand Down Expand Up @@ -502,6 +547,10 @@ source "arch/arm/mach-ixp2000/Kconfig"

source "arch/arm/mach-ixp23xx/Kconfig"

source "arch/arm/mach-loki/Kconfig"

source "arch/arm/mach-mv78xx0/Kconfig"

source "arch/arm/mach-pxa/Kconfig"

source "arch/arm/mach-sa1100/Kconfig"
Expand All @@ -514,6 +563,8 @@ source "arch/arm/mach-omap2/Kconfig"

source "arch/arm/mach-orion5x/Kconfig"

source "arch/arm/mach-kirkwood/Kconfig"

source "arch/arm/plat-s3c24xx/Kconfig"
source "arch/arm/plat-s3c/Kconfig"

Expand Down Expand Up @@ -703,27 +754,6 @@ config PREEMPT
Say Y here if you are building a kernel for a desktop, embedded
or real-time system. Say N if you are unsure.

config NO_IDLE_HZ
bool "Dynamic tick timer"
depends on !GENERIC_CLOCKEVENTS
help
Select this option if you want to disable continuous timer ticks
and have them programmed to occur as required. This option saves
power as the system can remain in idle state for longer.

By default dynamic tick is disabled during the boot, and can be
manually enabled with:

echo 1 > /sys/devices/system/timer/timer0/dyn_tick

Alternatively, if you want dynamic tick automatically enabled
during boot, pass "dyntick=enable" via the kernel command string.

Please note that dynamic tick may affect the accuracy of
timekeeping on some platforms depending on the implementation.
Currently at least OMAP, PXA2xx and SA11x0 platforms are known
to have accurate timekeeping with dynamic tick.

config HZ
int
default 128 if ARCH_L7200
Expand Down Expand Up @@ -789,7 +819,7 @@ source "mm/Kconfig"

config LEDS
bool "Timer and CPU usage LEDs"
depends on ARCH_CDB89712 || ARCH_CO285 || ARCH_EBSA110 || \
depends on ARCH_CDB89712 || ARCH_EBSA110 || \
ARCH_EBSA285 || ARCH_IMX || ARCH_INTEGRATOR || \
ARCH_LUBBOCK || MACH_MAINSTONE || ARCH_NETWINDER || \
ARCH_OMAP || ARCH_P720T || ARCH_PXA_IDP || \
Expand Down
Loading

0 comments on commit f29da77

Please sign in to comment.