diff options
Diffstat (limited to 'Documentation')
49 files changed, 3759 insertions, 147 deletions
diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle index 9069189e78ef..afc286775891 100644 --- a/Documentation/CodingStyle +++ b/Documentation/CodingStyle | |||
@@ -160,6 +160,21 @@ supply of new-lines on your screen is not a renewable resource (think | |||
160 | 25-line terminal screens here), you have more empty lines to put | 160 | 25-line terminal screens here), you have more empty lines to put |
161 | comments on. | 161 | comments on. |
162 | 162 | ||
163 | Do not unnecessarily use braces where a single statement will do. | ||
164 | |||
165 | if (condition) | ||
166 | action(); | ||
167 | |||
168 | This does not apply if one branch of a conditional statement is a single | ||
169 | statement. Use braces in both branches. | ||
170 | |||
171 | if (condition) { | ||
172 | do_this(); | ||
173 | do_that(); | ||
174 | } else { | ||
175 | otherwise(); | ||
176 | } | ||
177 | |||
163 | 3.1: Spaces | 178 | 3.1: Spaces |
164 | 179 | ||
165 | Linux kernel style for use of spaces depends (mostly) on | 180 | Linux kernel style for use of spaces depends (mostly) on |
@@ -625,7 +640,7 @@ language. | |||
625 | 640 | ||
626 | There appears to be a common misperception that gcc has a magic "make me | 641 | There appears to be a common misperception that gcc has a magic "make me |
627 | faster" speedup option called "inline". While the use of inlines can be | 642 | faster" speedup option called "inline". While the use of inlines can be |
628 | appropriate (for example as a means of replacing macros, see Chapter 11), it | 643 | appropriate (for example as a means of replacing macros, see Chapter 12), it |
629 | very often is not. Abundant use of the inline keyword leads to a much bigger | 644 | very often is not. Abundant use of the inline keyword leads to a much bigger |
630 | kernel, which in turn slows the system as a whole down, due to a bigger | 645 | kernel, which in turn slows the system as a whole down, due to a bigger |
631 | icache footprint for the CPU and simply because there is less memory | 646 | icache footprint for the CPU and simply because there is less memory |
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile index 867608ab3ca0..6fd1646d3204 100644 --- a/Documentation/DocBook/Makefile +++ b/Documentation/DocBook/Makefile | |||
@@ -41,8 +41,9 @@ psdocs: $(PS) | |||
41 | PDF := $(patsubst %.xml, %.pdf, $(BOOKS)) | 41 | PDF := $(patsubst %.xml, %.pdf, $(BOOKS)) |
42 | pdfdocs: $(PDF) | 42 | pdfdocs: $(PDF) |
43 | 43 | ||
44 | HTML := $(patsubst %.xml, %.html, $(BOOKS)) | 44 | HTML := $(sort $(patsubst %.xml, %.html, $(BOOKS))) |
45 | htmldocs: $(HTML) | 45 | htmldocs: $(HTML) |
46 | $(call build_main_index) | ||
46 | 47 | ||
47 | MAN := $(patsubst %.xml, %.9, $(BOOKS)) | 48 | MAN := $(patsubst %.xml, %.9, $(BOOKS)) |
48 | mandocs: $(MAN) | 49 | mandocs: $(MAN) |
@@ -132,10 +133,17 @@ quiet_cmd_db2pdf = PDF $@ | |||
132 | %.pdf : %.xml | 133 | %.pdf : %.xml |
133 | $(call cmd,db2pdf) | 134 | $(call cmd,db2pdf) |
134 | 135 | ||
136 | |||
137 | main_idx = Documentation/DocBook/index.html | ||
138 | build_main_index = rm -rf $(main_idx) && \ | ||
139 | echo '<h1>Linux Kernel HTML Documentation</h1>' >> $(main_idx) && \ | ||
140 | echo '<h2>Kernel Version: $(KERNELVERSION)</h2>' >> $(main_idx) && \ | ||
141 | cat $(HTML) >> $(main_idx) | ||
142 | |||
135 | quiet_cmd_db2html = HTML $@ | 143 | quiet_cmd_db2html = HTML $@ |
136 | cmd_db2html = xmlto xhtml $(XMLTOFLAGS) -o $(patsubst %.html,%,$@) $< && \ | 144 | cmd_db2html = xmlto xhtml $(XMLTOFLAGS) -o $(patsubst %.html,%,$@) $< && \ |
137 | echo '<a HREF="$(patsubst %.html,%,$(notdir $@))/index.html"> \ | 145 | echo '<a HREF="$(patsubst %.html,%,$(notdir $@))/index.html"> \ |
138 | Goto $(patsubst %.html,%,$(notdir $@))</a><p>' > $@ | 146 | $(patsubst %.html,%,$(notdir $@))</a><p>' > $@ |
139 | 147 | ||
140 | %.html: %.xml | 148 | %.html: %.xml |
141 | @(which xmlto > /dev/null 2>&1) || \ | 149 | @(which xmlto > /dev/null 2>&1) || \ |
@@ -152,6 +160,7 @@ quiet_cmd_db2man = MAN $@ | |||
152 | @(which xmlto > /dev/null 2>&1) || \ | 160 | @(which xmlto > /dev/null 2>&1) || \ |
153 | (echo "*** You need to install xmlto ***"; \ | 161 | (echo "*** You need to install xmlto ***"; \ |
154 | exit 1) | 162 | exit 1) |
163 | $(Q)mkdir -p $(obj)/man | ||
155 | $(call cmd,db2man) | 164 | $(call cmd,db2man) |
156 | @touch $@ | 165 | @touch $@ |
157 | 166 | ||
@@ -212,11 +221,7 @@ clean-files := $(DOCBOOKS) \ | |||
212 | $(patsubst %.xml, %.9, $(DOCBOOKS)) \ | 221 | $(patsubst %.xml, %.9, $(DOCBOOKS)) \ |
213 | $(C-procfs-example) | 222 | $(C-procfs-example) |
214 | 223 | ||
215 | clean-dirs := $(patsubst %.xml,%,$(DOCBOOKS)) | 224 | clean-dirs := $(patsubst %.xml,%,$(DOCBOOKS)) man |
216 | |||
217 | #man put files in man subdir - traverse down | ||
218 | subdir- := man/ | ||
219 | |||
220 | 225 | ||
221 | # Declare the contents of the .PHONY variable as phony. We keep that | 226 | # Declare the contents of the .PHONY variable as phony. We keep that |
222 | # information in a variable se we can use it in if_changed and friends. | 227 | # information in a variable se we can use it in if_changed and friends. |
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl index b61dfc79e1b8..a2b2b4d187c5 100644 --- a/Documentation/DocBook/kernel-api.tmpl +++ b/Documentation/DocBook/kernel-api.tmpl | |||
@@ -576,4 +576,67 @@ X!Idrivers/video/console/fonts.c | |||
576 | !Edrivers/input/ff-core.c | 576 | !Edrivers/input/ff-core.c |
577 | !Edrivers/input/ff-memless.c | 577 | !Edrivers/input/ff-memless.c |
578 | </chapter> | 578 | </chapter> |
579 | |||
580 | <chapter id="spi"> | ||
581 | <title>Serial Peripheral Interface (SPI)</title> | ||
582 | <para> | ||
583 | SPI is the "Serial Peripheral Interface", widely used with | ||
584 | embedded systems because it is a simple and efficient | ||
585 | interface: basically a multiplexed shift register. | ||
586 | Its three signal wires hold a clock (SCK, often in the range | ||
587 | of 1-20 MHz), a "Master Out, Slave In" (MOSI) data line, and | ||
588 | a "Master In, Slave Out" (MISO) data line. | ||
589 | SPI is a full duplex protocol; for each bit shifted out the | ||
590 | MOSI line (one per clock) another is shifted in on the MISO line. | ||
591 | Those bits are assembled into words of various sizes on the | ||
592 | way to and from system memory. | ||
593 | An additional chipselect line is usually active-low (nCS); | ||
594 | four signals are normally used for each peripheral, plus | ||
595 | sometimes an interrupt. | ||
596 | </para> | ||
597 | <para> | ||
598 | The SPI bus facilities listed here provide a generalized | ||
599 | interface to declare SPI busses and devices, manage them | ||
600 | according to the standard Linux driver model, and perform | ||
601 | input/output operations. | ||
602 | At this time, only "master" side interfaces are supported, | ||
603 | where Linux talks to SPI peripherals and does not implement | ||
604 | such a peripheral itself. | ||
605 | (Interfaces to support implementing SPI slaves would | ||
606 | necessarily look different.) | ||
607 | </para> | ||
608 | <para> | ||
609 | The programming interface is structured around two kinds of driver, | ||
610 | and two kinds of device. | ||
611 | A "Controller Driver" abstracts the controller hardware, which may | ||
612 | be as simple as a set of GPIO pins or as complex as a pair of FIFOs | ||
613 | connected to dual DMA engines on the other side of the SPI shift | ||
614 | register (maximizing throughput). Such drivers bridge between | ||
615 | whatever bus they sit on (often the platform bus) and SPI, and | ||
616 | expose the SPI side of their device as a | ||
617 | <structname>struct spi_master</structname>. | ||
618 | SPI devices are children of that master, represented as a | ||
619 | <structname>struct spi_device</structname> and manufactured from | ||
620 | <structname>struct spi_board_info</structname> descriptors which | ||
621 | are usually provided by board-specific initialization code. | ||
622 | A <structname>struct spi_driver</structname> is called a | ||
623 | "Protocol Driver", and is bound to a spi_device using normal | ||
624 | driver model calls. | ||
625 | </para> | ||
626 | <para> | ||
627 | The I/O model is a set of queued messages. Protocol drivers | ||
628 | submit one or more <structname>struct spi_message</structname> | ||
629 | objects, which are processed and completed asynchronously. | ||
630 | (There are synchronous wrappers, however.) Messages are | ||
631 | built from one or more <structname>struct spi_transfer</structname> | ||
632 | objects, each of which wraps a full duplex SPI transfer. | ||
633 | A variety of protocol tweaking options are needed, because | ||
634 | different chips adopt very different policies for how they | ||
635 | use the bits transferred with SPI. | ||
636 | </para> | ||
637 | !Iinclude/linux/spi/spi.h | ||
638 | !Fdrivers/spi/spi.c spi_register_board_info | ||
639 | !Edrivers/spi/spi.c | ||
640 | </chapter> | ||
641 | |||
579 | </book> | 642 | </book> |
diff --git a/Documentation/DocBook/librs.tmpl b/Documentation/DocBook/librs.tmpl index 3ff39bafc00e..94f21361e0ed 100644 --- a/Documentation/DocBook/librs.tmpl +++ b/Documentation/DocBook/librs.tmpl | |||
@@ -79,12 +79,12 @@ | |||
79 | <chapter id="usage"> | 79 | <chapter id="usage"> |
80 | <title>Usage</title> | 80 | <title>Usage</title> |
81 | <para> | 81 | <para> |
82 | This chapter provides examples how to use the library. | 82 | This chapter provides examples of how to use the library. |
83 | </para> | 83 | </para> |
84 | <sect1> | 84 | <sect1> |
85 | <title>Initializing</title> | 85 | <title>Initializing</title> |
86 | <para> | 86 | <para> |
87 | The init function init_rs returns a pointer to a | 87 | The init function init_rs returns a pointer to an |
88 | rs decoder structure, which holds the necessary | 88 | rs decoder structure, which holds the necessary |
89 | information for encoding, decoding and error correction | 89 | information for encoding, decoding and error correction |
90 | with the given polynomial. It either uses an existing | 90 | with the given polynomial. It either uses an existing |
@@ -98,10 +98,10 @@ | |||
98 | static struct rs_control *rs_decoder; | 98 | static struct rs_control *rs_decoder; |
99 | 99 | ||
100 | /* Symbolsize is 10 (bits) | 100 | /* Symbolsize is 10 (bits) |
101 | * Primitve polynomial is x^10+x^3+1 | 101 | * Primitive polynomial is x^10+x^3+1 |
102 | * first consecutive root is 0 | 102 | * first consecutive root is 0 |
103 | * primitve element to generate roots = 1 | 103 | * primitive element to generate roots = 1 |
104 | * generator polinomial degree (number of roots) = 6 | 104 | * generator polynomial degree (number of roots) = 6 |
105 | */ | 105 | */ |
106 | rs_decoder = init_rs (10, 0x409, 0, 1, 6); | 106 | rs_decoder = init_rs (10, 0x409, 0, 1, 6); |
107 | </programlisting> | 107 | </programlisting> |
@@ -116,12 +116,12 @@ rs_decoder = init_rs (10, 0x409, 0, 1, 6); | |||
116 | </para> | 116 | </para> |
117 | <para> | 117 | <para> |
118 | The expanded data can be inverted on the fly by | 118 | The expanded data can be inverted on the fly by |
119 | providing a non zero inversion mask. The expanded data is | 119 | providing a non-zero inversion mask. The expanded data is |
120 | XOR'ed with the mask. This is used e.g. for FLASH | 120 | XOR'ed with the mask. This is used e.g. for FLASH |
121 | ECC, where the all 0xFF is inverted to an all 0x00. | 121 | ECC, where the all 0xFF is inverted to an all 0x00. |
122 | The Reed-Solomon code for all 0x00 is all 0x00. The | 122 | The Reed-Solomon code for all 0x00 is all 0x00. The |
123 | code is inverted before storing to FLASH so it is 0xFF | 123 | code is inverted before storing to FLASH so it is 0xFF |
124 | too. This prevent's that reading from an erased FLASH | 124 | too. This prevents that reading from an erased FLASH |
125 | results in ECC errors. | 125 | results in ECC errors. |
126 | </para> | 126 | </para> |
127 | <para> | 127 | <para> |
@@ -273,7 +273,7 @@ free_rs(rs_decoder); | |||
273 | May be used under the terms of the GNU General Public License (GPL) | 273 | May be used under the terms of the GNU General Public License (GPL) |
274 | </programlisting> | 274 | </programlisting> |
275 | <para> | 275 | <para> |
276 | The wrapper functions and interfaces are written by Thomas Gleixner | 276 | The wrapper functions and interfaces are written by Thomas Gleixner. |
277 | </para> | 277 | </para> |
278 | <para> | 278 | <para> |
279 | Many users have provided bugfixes, improvements and helping hands for testing. | 279 | Many users have provided bugfixes, improvements and helping hands for testing. |
diff --git a/Documentation/DocBook/man/Makefile b/Documentation/DocBook/man/Makefile deleted file mode 100644 index 4fb7ea0f7ac8..000000000000 --- a/Documentation/DocBook/man/Makefile +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | # Rules are put in Documentation/DocBook | ||
2 | |||
3 | clean-files := *.9.gz *.sgml manpage.links manpage.refs | ||
diff --git a/Documentation/SubmittingDrivers b/Documentation/SubmittingDrivers index 58bead05eabb..d7e26427e426 100644 --- a/Documentation/SubmittingDrivers +++ b/Documentation/SubmittingDrivers | |||
@@ -87,6 +87,21 @@ Clarity: It helps if anyone can see how to fix the driver. It helps | |||
87 | driver that intentionally obfuscates how the hardware works | 87 | driver that intentionally obfuscates how the hardware works |
88 | it will go in the bitbucket. | 88 | it will go in the bitbucket. |
89 | 89 | ||
90 | PM support: Since Linux is used on many portable and desktop systems, your | ||
91 | driver is likely to be used on such a system and therefore it | ||
92 | should support basic power management by implementing, if | ||
93 | necessary, the .suspend and .resume methods used during the | ||
94 | system-wide suspend and resume transitions. You should verify | ||
95 | that your driver correctly handles the suspend and resume, but | ||
96 | if you are unable to ensure that, please at least define the | ||
97 | .suspend method returning the -ENOSYS ("Function not | ||
98 | implemented") error. You should also try to make sure that your | ||
99 | driver uses as little power as possible when it's not doing | ||
100 | anything. For the driver testing instructions see | ||
101 | Documentation/power/drivers-testing.txt and for a relatively | ||
102 | complete overview of the power management issues related to | ||
103 | drivers see Documentation/power/devices.txt . | ||
104 | |||
90 | Control: In general if there is active maintainance of a driver by | 105 | Control: In general if there is active maintainance of a driver by |
91 | the author then patches will be redirected to them unless | 106 | the author then patches will be redirected to them unless |
92 | they are totally obvious and without need of checking. | 107 | they are totally obvious and without need of checking. |
diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c index e9126e794ed7..71acc28ed0d1 100644 --- a/Documentation/accounting/getdelays.c +++ b/Documentation/accounting/getdelays.c | |||
@@ -61,8 +61,6 @@ __u64 stime, utime; | |||
61 | #define MAX_MSG_SIZE 1024 | 61 | #define MAX_MSG_SIZE 1024 |
62 | /* Maximum number of cpus expected to be specified in a cpumask */ | 62 | /* Maximum number of cpus expected to be specified in a cpumask */ |
63 | #define MAX_CPUS 32 | 63 | #define MAX_CPUS 32 |
64 | /* Maximum length of pathname to log file */ | ||
65 | #define MAX_FILENAME 256 | ||
66 | 64 | ||
67 | struct msgtemplate { | 65 | struct msgtemplate { |
68 | struct nlmsghdr n; | 66 | struct nlmsghdr n; |
@@ -72,6 +70,16 @@ struct msgtemplate { | |||
72 | 70 | ||
73 | char cpumask[100+6*MAX_CPUS]; | 71 | char cpumask[100+6*MAX_CPUS]; |
74 | 72 | ||
73 | static void usage(void) | ||
74 | { | ||
75 | fprintf(stderr, "getdelays [-dilv] [-w logfile] [-r bufsize] " | ||
76 | "[-m cpumask] [-t tgid] [-p pid]\n"); | ||
77 | fprintf(stderr, " -d: print delayacct stats\n"); | ||
78 | fprintf(stderr, " -i: print IO accounting (works only with -p)\n"); | ||
79 | fprintf(stderr, " -l: listen forever\n"); | ||
80 | fprintf(stderr, " -v: debug on\n"); | ||
81 | } | ||
82 | |||
75 | /* | 83 | /* |
76 | * Create a raw netlink socket and bind | 84 | * Create a raw netlink socket and bind |
77 | */ | 85 | */ |
@@ -221,13 +229,13 @@ int main(int argc, char *argv[]) | |||
221 | int count = 0; | 229 | int count = 0; |
222 | int write_file = 0; | 230 | int write_file = 0; |
223 | int maskset = 0; | 231 | int maskset = 0; |
224 | char logfile[128]; | 232 | char *logfile = NULL; |
225 | int loop = 0; | 233 | int loop = 0; |
226 | 234 | ||
227 | struct msgtemplate msg; | 235 | struct msgtemplate msg; |
228 | 236 | ||
229 | while (1) { | 237 | while (1) { |
230 | c = getopt(argc, argv, "diw:r:m:t:p:v:l"); | 238 | c = getopt(argc, argv, "diw:r:m:t:p:vl"); |
231 | if (c < 0) | 239 | if (c < 0) |
232 | break; | 240 | break; |
233 | 241 | ||
@@ -241,7 +249,7 @@ int main(int argc, char *argv[]) | |||
241 | print_io_accounting = 1; | 249 | print_io_accounting = 1; |
242 | break; | 250 | break; |
243 | case 'w': | 251 | case 'w': |
244 | strncpy(logfile, optarg, MAX_FILENAME); | 252 | logfile = strdup(optarg); |
245 | printf("write to file %s\n", logfile); | 253 | printf("write to file %s\n", logfile); |
246 | write_file = 1; | 254 | write_file = 1; |
247 | break; | 255 | break; |
@@ -277,7 +285,7 @@ int main(int argc, char *argv[]) | |||
277 | loop = 1; | 285 | loop = 1; |
278 | break; | 286 | break; |
279 | default: | 287 | default: |
280 | printf("Unknown option %d\n", c); | 288 | usage(); |
281 | exit(-1); | 289 | exit(-1); |
282 | } | 290 | } |
283 | } | 291 | } |
diff --git a/Documentation/blackfin/00-INDEX b/Documentation/blackfin/00-INDEX new file mode 100644 index 000000000000..7cb3b356b249 --- /dev/null +++ b/Documentation/blackfin/00-INDEX | |||
@@ -0,0 +1,11 @@ | |||
1 | 00-INDEX | ||
2 | - This file | ||
3 | |||
4 | cache-lock.txt | ||
5 | - HOWTO for blackfin cache locking. | ||
6 | |||
7 | cachefeatures.txt | ||
8 | - Supported cache features. | ||
9 | |||
10 | Filesystems | ||
11 | - Requirements for mounting the root file system. | ||
diff --git a/Documentation/blackfin/Filesystems b/Documentation/blackfin/Filesystems new file mode 100644 index 000000000000..51260a1b8032 --- /dev/null +++ b/Documentation/blackfin/Filesystems | |||
@@ -0,0 +1,169 @@ | |||
1 | /* | ||
2 | * File: Documentation/blackfin/Filesystems | ||
3 | * Based on: | ||
4 | * Author: | ||
5 | * | ||
6 | * Created: | ||
7 | * Description: This file contains the simple DMA Implementation for Blackfin | ||
8 | * | ||
9 | * Rev: $Id: Filesystems 2384 2006-11-01 04:12:43Z magicyang $ | ||
10 | * | ||
11 | * Modified: | ||
12 | * Copyright 2004-2006 Analog Devices Inc. | ||
13 | * | ||
14 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | How to mount the root file system in uClinux/Blackfin | ||
19 | ----------------------------------------------------- | ||
20 | |||
21 | 1 Mounting EXT3 File system. | ||
22 | ------------------------ | ||
23 | |||
24 | Creating an EXT3 File system for uClinux/Blackfin: | ||
25 | |||
26 | |||
27 | Please follow the steps to form the EXT3 File system and mount the same as root | ||
28 | file system. | ||
29 | |||
30 | a Make an ext3 file system as large as you want the final root file | ||
31 | system. | ||
32 | |||
33 | mkfs.ext3 /dev/ram0 <your-rootfs-size-in-1k-blocks> | ||
34 | |||
35 | b Mount this Empty file system on a free directory as: | ||
36 | |||
37 | mount -t ext3 /dev/ram0 ./test | ||
38 | where ./test is the empty directory. | ||
39 | |||
40 | c Copy your root fs directory that you have so carefully made over. | ||
41 | |||
42 | cp -af /tmp/my_final_rootfs_files/* ./test | ||
43 | |||
44 | (For ex: cp -af uClinux-dist/romfs/* ./test) | ||
45 | |||
46 | d If you have done everything right till now you should be able to see | ||
47 | the required "root" dir's (that's etc, root, bin, lib, sbin...) | ||
48 | |||
49 | e Now unmount the file system | ||
50 | |||
51 | umount ./test | ||
52 | |||
53 | f Create the root file system image. | ||
54 | |||
55 | dd if=/dev/ram0 bs=1k count=<your-rootfs-size-in-1k-blocks> \ | ||
56 | > ext3fs.img | ||
57 | |||
58 | |||
59 | Now you have to tell the kernel that will be mounting this file system as | ||
60 | rootfs. | ||
61 | So do a make menuconfig under kernel and select the Ext3 journaling file system | ||
62 | support under File system --> submenu. | ||
63 | |||
64 | |||
65 | 2. Mounting EXT2 File system. | ||
66 | ------------------------- | ||
67 | |||
68 | By default the ext2 file system image will be created if you invoke make from | ||
69 | the top uClinux-dist directory. | ||
70 | |||
71 | |||
72 | 3. Mounting CRAMFS File System | ||
73 | ---------------------------- | ||
74 | |||
75 | To create a CRAMFS file system image execute the command | ||
76 | |||
77 | mkfs.cramfs ./test cramfs.img | ||
78 | |||
79 | where ./test is the target directory. | ||
80 | |||
81 | |||
82 | 4. Mounting ROMFS File System | ||
83 | -------------------------- | ||
84 | |||
85 | To create a ROMFS file system image execute the command | ||
86 | |||
87 | genromfs -v -V "ROMdisk" -f romfs.img -d ./test | ||
88 | |||
89 | where ./test is the target directory | ||
90 | |||
91 | |||
92 | 5. Mounting the JFFS2 Filesystem | ||
93 | ----------------------------- | ||
94 | |||
95 | To create a compressed JFFS filesystem (JFFS2), please execute the command | ||
96 | |||
97 | mkfs.jffs2 -d ./test -o jffs2.img | ||
98 | |||
99 | where ./test is the target directory. | ||
100 | |||
101 | However, please make sure the following is in your kernel config. | ||
102 | |||
103 | /* | ||
104 | * RAM/ROM/Flash chip drivers | ||
105 | */ | ||
106 | #define CONFIG_MTD_CFI 1 | ||
107 | #define CONFIG_MTD_ROM 1 | ||
108 | /* | ||
109 | * Mapping drivers for chip access | ||
110 | */ | ||
111 | #define CONFIG_MTD_COMPLEX_MAPPINGS 1 | ||
112 | #define CONFIG_MTD_BF533 1 | ||
113 | #undef CONFIG_MTD_UCLINUX | ||
114 | |||
115 | Through the u-boot boot loader, use the jffs2.img in the corresponding | ||
116 | partition made in linux-2.6.x/drivers/mtd/maps/bf533_flash.c. | ||
117 | |||
118 | NOTE - Currently the Flash driver is available only for EZKIT. Watch out for a | ||
119 | STAMP driver soon. | ||
120 | |||
121 | |||
122 | 6. Mounting the NFS File system | ||
123 | ----------------------------- | ||
124 | |||
125 | For mounting the NFS please do the following in the kernel config. | ||
126 | |||
127 | In Networking Support --> Networking options --> TCP/IP networking --> | ||
128 | IP: kernel level autoconfiguration | ||
129 | |||
130 | Enable BOOTP Support. | ||
131 | |||
132 | In Kernel hacking --> Compiled-in kernel boot parameter add the following | ||
133 | |||
134 | root=/dev/nfs rw ip=bootp | ||
135 | |||
136 | In File system --> Network File system, Enable | ||
137 | |||
138 | NFS file system support --> NFSv3 client support | ||
139 | Root File system on NFS | ||
140 | |||
141 | in uClibc menuconfig, do the following | ||
142 | In Networking Support | ||
143 | enable Remote Procedure Call (RPC) support | ||
144 | Full RPC Support | ||
145 | |||
146 | On the Host side, ensure that /etc/dhcpd.conf looks something like this | ||
147 | |||
148 | ddns-update-style ad-hoc; | ||
149 | allow bootp; | ||
150 | subnet 10.100.4.0 netmask 255.255.255.0 { | ||
151 | default-lease-time 122209600; | ||
152 | max-lease-time 31557600; | ||
153 | group { | ||
154 | host bf533 { | ||
155 | hardware ethernet 00:CF:52:49:C3:01; | ||
156 | fixed-address 10.100.4.50; | ||
157 | option root-path "/home/nfsmount"; | ||
158 | } | ||
159 | } | ||
160 | |||
161 | ensure that /etc/exports looks something like this | ||
162 | /home/nfsmount *(rw,no_root_squash,no_all_squash) | ||
163 | |||
164 | run the following commands as root (may differ depending on your | ||
165 | distribution) : | ||
166 | - service nfs start | ||
167 | - service portmap start | ||
168 | - service dhcpd start | ||
169 | - /usr/sbin/exportfs | ||
diff --git a/Documentation/blackfin/cache-lock.txt b/Documentation/blackfin/cache-lock.txt new file mode 100644 index 000000000000..88ba1e6c31c3 --- /dev/null +++ b/Documentation/blackfin/cache-lock.txt | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * File: Documentation/blackfin/cache-lock.txt | ||
3 | * Based on: | ||
4 | * Author: | ||
5 | * | ||
6 | * Created: | ||
7 | * Description: This file contains the simple DMA Implementation for Blackfin | ||
8 | * | ||
9 | * Rev: $Id: cache-lock.txt 2384 2006-11-01 04:12:43Z magicyang $ | ||
10 | * | ||
11 | * Modified: | ||
12 | * Copyright 2004-2006 Analog Devices Inc. | ||
13 | * | ||
14 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | How to lock your code in cache in uClinux/blackfin | ||
19 | -------------------------------------------------- | ||
20 | |||
21 | There are only a few steps required to lock your code into the cache. | ||
22 | Currently you can lock the code by Way. | ||
23 | |||
24 | Below are the interface provided for locking the cache. | ||
25 | |||
26 | |||
27 | 1. cache_grab_lock(int Ways); | ||
28 | |||
29 | This function grab the lock for locking your code into the cache specified | ||
30 | by Ways. | ||
31 | |||
32 | |||
33 | 2. cache_lock(int Ways); | ||
34 | |||
35 | This function should be called after your critical code has been executed. | ||
36 | Once the critical code exits, the code is now loaded into the cache. This | ||
37 | function locks the code into the cache. | ||
38 | |||
39 | |||
40 | So, the example sequence will be: | ||
41 | |||
42 | cache_grab_lock(WAY0_L); /* Grab the lock */ | ||
43 | |||
44 | critical_code(); /* Execute the code of interest */ | ||
45 | |||
46 | cache_lock(WAY0_L); /* Lock the cache */ | ||
47 | |||
48 | Where WAY0_L signifies WAY0 locking. | ||
diff --git a/Documentation/blackfin/cachefeatures.txt b/Documentation/blackfin/cachefeatures.txt new file mode 100644 index 000000000000..0fbec23becb5 --- /dev/null +++ b/Documentation/blackfin/cachefeatures.txt | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * File: Documentation/blackfin/cachefeatures.txt | ||
3 | * Based on: | ||
4 | * Author: | ||
5 | * | ||
6 | * Created: | ||
7 | * Description: This file contains the simple DMA Implementation for Blackfin | ||
8 | * | ||
9 | * Rev: $Id: cachefeatures.txt 2384 2006-11-01 04:12:43Z magicyang $ | ||
10 | * | ||
11 | * Modified: | ||
12 | * Copyright 2004-2006 Analog Devices Inc. | ||
13 | * | ||
14 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | - Instruction and Data cache initialization. | ||
19 | icache_init(); | ||
20 | dcache_init(); | ||
21 | |||
22 | - Instruction and Data cache Invalidation Routines, when flushing the | ||
23 | same is not required. | ||
24 | _icache_invalidate(); | ||
25 | _dcache_invalidate(); | ||
26 | |||
27 | Also, for invalidating the entire instruction and data cache, the below | ||
28 | routines are provided (another method for invalidation, refer page no 267 and 287 of | ||
29 | ADSP-BF533 Hardware Reference manual) | ||
30 | |||
31 | invalidate_entire_dcache(); | ||
32 | invalidate_entire_icache(); | ||
33 | |||
34 | -External Flushing of Instruction and data cache routines. | ||
35 | |||
36 | flush_instruction_cache(); | ||
37 | flush_data_cache(); | ||
38 | |||
39 | - Internal Flushing of Instruction and Data Cache. | ||
40 | |||
41 | icplb_flush(); | ||
42 | dcplb_flush(); | ||
43 | |||
44 | - Locking the cache. | ||
45 | |||
46 | cache_grab_lock(); | ||
47 | cache_lock(); | ||
48 | |||
49 | Please refer linux-2.6.x/Documentation/blackfin/cache-lock.txt for how to | ||
50 | lock the cache. | ||
51 | |||
52 | Locking the cache is optional feature. | ||
53 | |||
54 | - Miscellaneous cache functions. | ||
55 | |||
56 | flush_cache_all(); | ||
57 | flush_cache_mm(); | ||
58 | invalidate_dcache_range(); | ||
59 | flush_dcache_range(); | ||
60 | flush_dcache_page(); | ||
61 | flush_cache_range(); | ||
62 | flush_cache_page(); | ||
63 | invalidate_dcache_range(); | ||
64 | flush_page_to_ram(); | ||
65 | |||
diff --git a/Documentation/cciss.txt b/Documentation/cciss.txt index f74affe5c829..e65736c6b8bc 100644 --- a/Documentation/cciss.txt +++ b/Documentation/cciss.txt | |||
@@ -22,14 +22,21 @@ This driver is known to work with the following cards: | |||
22 | * SA E200i | 22 | * SA E200i |
23 | * SA E500 | 23 | * SA E500 |
24 | 24 | ||
25 | If nodes are not already created in the /dev/cciss directory, run as root: | 25 | Detecting drive failures: |
26 | ------------------------- | ||
26 | 27 | ||
27 | # cd /dev | 28 | To get the status of logical volumes and to detect physical drive |
28 | # ./MAKEDEV cciss | 29 | failures, you can use the cciss_vol_status program found here: |
30 | http://cciss.sourceforge.net/#cciss_utils | ||
29 | 31 | ||
30 | Device Naming: | 32 | Device Naming: |
31 | -------------- | 33 | -------------- |
32 | 34 | ||
35 | If nodes are not already created in the /dev/cciss directory, run as root: | ||
36 | |||
37 | # cd /dev | ||
38 | # ./MAKEDEV cciss | ||
39 | |||
33 | You need some entries in /dev for the cciss device. The MAKEDEV script | 40 | You need some entries in /dev for the cciss device. The MAKEDEV script |
34 | can make device nodes for you automatically. Currently the device setup | 41 | can make device nodes for you automatically. Currently the device setup |
35 | is as follows: | 42 | is as follows: |
diff --git a/Documentation/fb/deferred_io.txt b/Documentation/fb/deferred_io.txt new file mode 100644 index 000000000000..73cf9fb7cf60 --- /dev/null +++ b/Documentation/fb/deferred_io.txt | |||
@@ -0,0 +1,75 @@ | |||
1 | Deferred IO | ||
2 | ----------- | ||
3 | |||
4 | Deferred IO is a way to delay and repurpose IO. It uses host memory as a | ||
5 | buffer and the MMU pagefault as a pretrigger for when to perform the device | ||
6 | IO. The following example may be a useful explaination of how one such setup | ||
7 | works: | ||
8 | |||
9 | - userspace app like Xfbdev mmaps framebuffer | ||
10 | - deferred IO and driver sets up nopage and page_mkwrite handlers | ||
11 | - userspace app tries to write to mmaped vaddress | ||
12 | - we get pagefault and reach nopage handler | ||
13 | - nopage handler finds and returns physical page | ||
14 | - we get page_mkwrite where we add this page to a list | ||
15 | - schedule a workqueue task to be run after a delay | ||
16 | - app continues writing to that page with no additional cost. this is | ||
17 | the key benefit. | ||
18 | - the workqueue task comes in and mkcleans the pages on the list, then | ||
19 | completes the work associated with updating the framebuffer. this is | ||
20 | the real work talking to the device. | ||
21 | - app tries to write to the address (that has now been mkcleaned) | ||
22 | - get pagefault and the above sequence occurs again | ||
23 | |||
24 | As can be seen from above, one benefit is roughly to allow bursty framebuffer | ||
25 | writes to occur at minimum cost. Then after some time when hopefully things | ||
26 | have gone quiet, we go and really update the framebuffer which would be | ||
27 | a relatively more expensive operation. | ||
28 | |||
29 | For some types of nonvolatile high latency displays, the desired image is | ||
30 | the final image rather than the intermediate stages which is why it's okay | ||
31 | to not update for each write that is occuring. | ||
32 | |||
33 | It may be the case that this is useful in other scenarios as well. Paul Mundt | ||
34 | has mentioned a case where it is beneficial to use the page count to decide | ||
35 | whether to coalesce and issue SG DMA or to do memory bursts. | ||
36 | |||
37 | Another one may be if one has a device framebuffer that is in an usual format, | ||
38 | say diagonally shifting RGB, this may then be a mechanism for you to allow | ||
39 | apps to pretend to have a normal framebuffer but reswizzle for the device | ||
40 | framebuffer at vsync time based on the touched pagelist. | ||
41 | |||
42 | How to use it: (for applications) | ||
43 | --------------------------------- | ||
44 | No changes needed. mmap the framebuffer like normal and just use it. | ||
45 | |||
46 | How to use it: (for fbdev drivers) | ||
47 | ---------------------------------- | ||
48 | The following example may be helpful. | ||
49 | |||
50 | 1. Setup your structure. Eg: | ||
51 | |||
52 | static struct fb_deferred_io hecubafb_defio = { | ||
53 | .delay = HZ, | ||
54 | .deferred_io = hecubafb_dpy_deferred_io, | ||
55 | }; | ||
56 | |||
57 | The delay is the minimum delay between when the page_mkwrite trigger occurs | ||
58 | and when the deferred_io callback is called. The deferred_io callback is | ||
59 | explained below. | ||
60 | |||
61 | 2. Setup your deferred IO callback. Eg: | ||
62 | static void hecubafb_dpy_deferred_io(struct fb_info *info, | ||
63 | struct list_head *pagelist) | ||
64 | |||
65 | The deferred_io callback is where you would perform all your IO to the display | ||
66 | device. You receive the pagelist which is the list of pages that were written | ||
67 | to during the delay. You must not modify this list. This callback is called | ||
68 | from a workqueue. | ||
69 | |||
70 | 3. Call init | ||
71 | info->fbdefio = &hecubafb_defio; | ||
72 | fb_deferred_io_init(info); | ||
73 | |||
74 | 4. Call cleanup | ||
75 | fb_deferred_io_cleanup(info); | ||
diff --git a/Documentation/fb/s3fb.txt b/Documentation/fb/s3fb.txt index 8a04c0da0c91..2c97770bdbaa 100644 --- a/Documentation/fb/s3fb.txt +++ b/Documentation/fb/s3fb.txt | |||
@@ -35,10 +35,12 @@ Supported Features | |||
35 | * suspend/resume support | 35 | * suspend/resume support |
36 | * DPMS support | 36 | * DPMS support |
37 | 37 | ||
38 | Text mode is supported even in higher resolutions, but there is limitation | 38 | Text mode is supported even in higher resolutions, but there is limitation to |
39 | to lower pixclocks (maximum between 50-60 MHz, depending on specific hardware). | 39 | lower pixclocks (maximum usually between 50-60 MHz, depending on specific |
40 | This limitation is not enforced by driver. Text mode supports 8bit wide fonts | 40 | hardware, i get best results from plain S3 Trio32 card - about 75 MHz). This |
41 | only (hardware limitation) and 16bit tall fonts (driver limitation). | 41 | limitation is not enforced by driver. Text mode supports 8bit wide fonts only |
42 | (hardware limitation) and 16bit tall fonts (driver limitation). Text mode | ||
43 | support is broken on S3 Trio64 V2/DX. | ||
42 | 44 | ||
43 | There are two 4 bpp modes. First mode (selected if nonstd == 0) is mode with | 45 | There are two 4 bpp modes. First mode (selected if nonstd == 0) is mode with |
44 | packed pixels, high nibble first. Second mode (selected if nonstd == 1) is mode | 46 | packed pixels, high nibble first. Second mode (selected if nonstd == 1) is mode |
@@ -73,6 +75,8 @@ Known bugs | |||
73 | ========== | 75 | ========== |
74 | 76 | ||
75 | * cursor disable in text mode doesn't work | 77 | * cursor disable in text mode doesn't work |
78 | * text mode broken on S3 Trio64 V2/DX | ||
79 | |||
76 | 80 | ||
77 | -- | 81 | -- |
78 | Ondrej Zajicek <santiago@crfreenet.org> | 82 | Ondrej Zajicek <santiago@crfreenet.org> |
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index 94fd03f25235..676b7981adb7 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt | |||
@@ -6,6 +6,14 @@ be removed from this file. | |||
6 | 6 | ||
7 | --------------------------- | 7 | --------------------------- |
8 | 8 | ||
9 | What: MXSER | ||
10 | When: December 2007 | ||
11 | Why: Old mxser driver is obsoleted by the mxser_new. Give it some time yet | ||
12 | and remove it. | ||
13 | Who: Jiri Slaby <jirislaby@gmail.com> | ||
14 | |||
15 | --------------------------- | ||
16 | |||
9 | What: V4L2 VIDIOC_G_MPEGCOMP and VIDIOC_S_MPEGCOMP | 17 | What: V4L2 VIDIOC_G_MPEGCOMP and VIDIOC_S_MPEGCOMP |
10 | When: October 2007 | 18 | When: October 2007 |
11 | Why: Broken attempt to set MPEG compression parameters. These ioctls are | 19 | Why: Broken attempt to set MPEG compression parameters. These ioctls are |
@@ -126,18 +134,6 @@ Who: Adrian Bunk <bunk@stusta.de> | |||
126 | 134 | ||
127 | --------------------------- | 135 | --------------------------- |
128 | 136 | ||
129 | What: Usage of invalid timevals in setitimer | ||
130 | When: March 2007 | ||
131 | Why: POSIX requires to validate timevals in the setitimer call. This | ||
132 | was never done by Linux. The invalid (e.g. negative timevals) were | ||
133 | silently converted to more or less random timeouts and intervals. | ||
134 | Until the removal a per boot limited number of warnings is printed | ||
135 | and the timevals are sanitized. | ||
136 | |||
137 | Who: Thomas Gleixner <tglx@linutronix.de> | ||
138 | |||
139 | --------------------------- | ||
140 | |||
141 | What: Unused EXPORT_SYMBOL/EXPORT_SYMBOL_GPL exports | 137 | What: Unused EXPORT_SYMBOL/EXPORT_SYMBOL_GPL exports |
142 | (temporary transition config option provided until then) | 138 | (temporary transition config option provided until then) |
143 | The transition config option will also be removed at the same time. | 139 | The transition config option will also be removed at the same time. |
@@ -165,7 +161,7 @@ Who: Greg Kroah-Hartman <gregkh@suse.de> | |||
165 | --------------------------- | 161 | --------------------------- |
166 | 162 | ||
167 | What: Interrupt only SA_* flags | 163 | What: Interrupt only SA_* flags |
168 | When: Januar 2007 | 164 | When: September 2007 |
169 | Why: The interrupt related SA_* flags are replaced by IRQF_* to move them | 165 | Why: The interrupt related SA_* flags are replaced by IRQF_* to move them |
170 | out of the signal namespace. | 166 | out of the signal namespace. |
171 | 167 | ||
@@ -332,3 +328,11 @@ Why: Obsolete. The new i2c-gpio driver replaces all hardware-specific | |||
332 | Who: Jean Delvare <khali@linux-fr.org> | 328 | Who: Jean Delvare <khali@linux-fr.org> |
333 | 329 | ||
334 | --------------------------- | 330 | --------------------------- |
331 | |||
332 | What: drivers depending on OSS_OBSOLETE | ||
333 | When: options in 2.6.23, code in 2.6.25 | ||
334 | Why: obsolete OSS drivers | ||
335 | Who: Adrian Bunk <bunk@stusta.de> | ||
336 | |||
337 | --------------------------- | ||
338 | |||
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking index 28bfea75bcf2..59c14159cc47 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking | |||
@@ -15,6 +15,7 @@ prototypes: | |||
15 | int (*d_delete)(struct dentry *); | 15 | int (*d_delete)(struct dentry *); |
16 | void (*d_release)(struct dentry *); | 16 | void (*d_release)(struct dentry *); |
17 | void (*d_iput)(struct dentry *, struct inode *); | 17 | void (*d_iput)(struct dentry *, struct inode *); |
18 | char *(*d_dname)((struct dentry *dentry, char *buffer, int buflen); | ||
18 | 19 | ||
19 | locking rules: | 20 | locking rules: |
20 | none have BKL | 21 | none have BKL |
@@ -25,6 +26,7 @@ d_compare: no yes no no | |||
25 | d_delete: yes no yes no | 26 | d_delete: yes no yes no |
26 | d_release: no no no yes | 27 | d_release: no no no yes |
27 | d_iput: no no no yes | 28 | d_iput: no no no yes |
29 | d_dname: no no no no | ||
28 | 30 | ||
29 | --------------------------- inode_operations --------------------------- | 31 | --------------------------- inode_operations --------------------------- |
30 | prototypes: | 32 | prototypes: |
diff --git a/Documentation/filesystems/jfs.txt b/Documentation/filesystems/jfs.txt index bae128663748..26ebde77e821 100644 --- a/Documentation/filesystems/jfs.txt +++ b/Documentation/filesystems/jfs.txt | |||
@@ -29,7 +29,13 @@ errors=continue Keep going on a filesystem error. | |||
29 | errors=remount-ro Default. Remount the filesystem read-only on an error. | 29 | errors=remount-ro Default. Remount the filesystem read-only on an error. |
30 | errors=panic Panic and halt the machine if an error occurs. | 30 | errors=panic Panic and halt the machine if an error occurs. |
31 | 31 | ||
32 | Please send bugs, comments, cards and letters to shaggy@austin.ibm.com. | 32 | uid=value Override on-disk uid with specified value |
33 | gid=value Override on-disk gid with specified value | ||
34 | umask=value Override on-disk umask with specified octal value. For | ||
35 | directories, the execute bit will be set if the corresponding | ||
36 | read bit is set. | ||
37 | |||
38 | Please send bugs, comments, cards and letters to shaggy@linux.vnet.ibm.com. | ||
33 | 39 | ||
34 | The JFS mailing list can be subscribed to by using the link labeled | 40 | The JFS mailing list can be subscribed to by using the link labeled |
35 | "Mail list Subscribe" at our web page http://jfs.sourceforge.net/ | 41 | "Mail list Subscribe" at our web page http://jfs.sourceforge.net/ |
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt index 7aaf09b86a55..4f3e84c520a5 100644 --- a/Documentation/filesystems/proc.txt +++ b/Documentation/filesystems/proc.txt | |||
@@ -122,21 +122,22 @@ subdirectory has the entries listed in Table 1-1. | |||
122 | 122 | ||
123 | Table 1-1: Process specific entries in /proc | 123 | Table 1-1: Process specific entries in /proc |
124 | .............................................................................. | 124 | .............................................................................. |
125 | File Content | 125 | File Content |
126 | cmdline Command line arguments | 126 | clear_refs Clears page referenced bits shown in smaps output |
127 | cpu Current and last cpu in which it was executed (2.4)(smp) | 127 | cmdline Command line arguments |
128 | cwd Link to the current working directory | 128 | cpu Current and last cpu in which it was executed (2.4)(smp) |
129 | environ Values of environment variables | 129 | cwd Link to the current working directory |
130 | exe Link to the executable of this process | 130 | environ Values of environment variables |
131 | fd Directory, which contains all file descriptors | 131 | exe Link to the executable of this process |
132 | maps Memory maps to executables and library files (2.4) | 132 | fd Directory, which contains all file descriptors |
133 | mem Memory held by this process | 133 | maps Memory maps to executables and library files (2.4) |
134 | root Link to the root directory of this process | 134 | mem Memory held by this process |
135 | stat Process status | 135 | root Link to the root directory of this process |
136 | statm Process memory status information | 136 | stat Process status |
137 | status Process status in human readable form | 137 | statm Process memory status information |
138 | wchan If CONFIG_KALLSYMS is set, a pre-decoded wchan | 138 | status Process status in human readable form |
139 | smaps Extension based on maps, presenting the rss size for each mapped file | 139 | wchan If CONFIG_KALLSYMS is set, a pre-decoded wchan |
140 | smaps Extension based on maps, the rss size for each mapped file | ||
140 | .............................................................................. | 141 | .............................................................................. |
141 | 142 | ||
142 | For example, to get the status information of a process, all you have to do is | 143 | For example, to get the status information of a process, all you have to do is |
@@ -1137,6 +1138,13 @@ determine whether or not they are still functioning properly. | |||
1137 | Because the NMI watchdog shares registers with oprofile, by disabling the NMI | 1138 | Because the NMI watchdog shares registers with oprofile, by disabling the NMI |
1138 | watchdog, oprofile may have more registers to utilize. | 1139 | watchdog, oprofile may have more registers to utilize. |
1139 | 1140 | ||
1141 | maps_protect | ||
1142 | ------------ | ||
1143 | |||
1144 | Enables/Disables the protection of the per-process proc entries "maps" and | ||
1145 | "smaps". When enabled, the contents of these files are visible only to | ||
1146 | readers that are allowed to ptrace() the given process. | ||
1147 | |||
1140 | 1148 | ||
1141 | 2.4 /proc/sys/vm - The virtual memory subsystem | 1149 | 2.4 /proc/sys/vm - The virtual memory subsystem |
1142 | ----------------------------------------------- | 1150 | ----------------------------------------------- |
diff --git a/Documentation/filesystems/vfat.txt b/Documentation/filesystems/vfat.txt index 069cb1094300..fcc123ffa252 100644 --- a/Documentation/filesystems/vfat.txt +++ b/Documentation/filesystems/vfat.txt | |||
@@ -57,6 +57,13 @@ nonumtail=<bool> -- When creating 8.3 aliases, normally the alias will | |||
57 | currently exist in the directory, 'longfile.txt' will | 57 | currently exist in the directory, 'longfile.txt' will |
58 | be the short alias instead of 'longfi~1.txt'. | 58 | be the short alias instead of 'longfi~1.txt'. |
59 | 59 | ||
60 | usefree -- Use the "free clusters" value stored on FSINFO. It'll | ||
61 | be used to determine number of free clusters without | ||
62 | scanning disk. But it's not used by default, because | ||
63 | recent Windows don't update it correctly in some | ||
64 | case. If you are sure the "free clusters" on FSINFO is | ||
65 | correct, by this option you can avoid scanning disk. | ||
66 | |||
60 | quiet -- Stops printing certain warning messages. | 67 | quiet -- Stops printing certain warning messages. |
61 | 68 | ||
62 | check=s|r|n -- Case sensitivity checking setting. | 69 | check=s|r|n -- Case sensitivity checking setting. |
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index ea271f2d3954..a47cc819f37b 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt | |||
@@ -827,7 +827,7 @@ This describes how a filesystem can overload the standard dentry | |||
827 | operations. Dentries and the dcache are the domain of the VFS and the | 827 | operations. Dentries and the dcache are the domain of the VFS and the |
828 | individual filesystem implementations. Device drivers have no business | 828 | individual filesystem implementations. Device drivers have no business |
829 | here. These methods may be set to NULL, as they are either optional or | 829 | here. These methods may be set to NULL, as they are either optional or |
830 | the VFS uses a default. As of kernel 2.6.13, the following members are | 830 | the VFS uses a default. As of kernel 2.6.22, the following members are |
831 | defined: | 831 | defined: |
832 | 832 | ||
833 | struct dentry_operations { | 833 | struct dentry_operations { |
@@ -837,6 +837,7 @@ struct dentry_operations { | |||
837 | int (*d_delete)(struct dentry *); | 837 | int (*d_delete)(struct dentry *); |
838 | void (*d_release)(struct dentry *); | 838 | void (*d_release)(struct dentry *); |
839 | void (*d_iput)(struct dentry *, struct inode *); | 839 | void (*d_iput)(struct dentry *, struct inode *); |
840 | char *(*d_dname)(struct dentry *, char *, int); | ||
840 | }; | 841 | }; |
841 | 842 | ||
842 | d_revalidate: called when the VFS needs to revalidate a dentry. This | 843 | d_revalidate: called when the VFS needs to revalidate a dentry. This |
@@ -859,6 +860,26 @@ struct dentry_operations { | |||
859 | VFS calls iput(). If you define this method, you must call | 860 | VFS calls iput(). If you define this method, you must call |
860 | iput() yourself | 861 | iput() yourself |
861 | 862 | ||
863 | d_dname: called when the pathname of a dentry should be generated. | ||
864 | Usefull for some pseudo filesystems (sockfs, pipefs, ...) to delay | ||
865 | pathname generation. (Instead of doing it when dentry is created, | ||
866 | its done only when the path is needed.). Real filesystems probably | ||
867 | dont want to use it, because their dentries are present in global | ||
868 | dcache hash, so their hash should be an invariant. As no lock is | ||
869 | held, d_dname() should not try to modify the dentry itself, unless | ||
870 | appropriate SMP safety is used. CAUTION : d_path() logic is quite | ||
871 | tricky. The correct way to return for example "Hello" is to put it | ||
872 | at the end of the buffer, and returns a pointer to the first char. | ||
873 | dynamic_dname() helper function is provided to take care of this. | ||
874 | |||
875 | Example : | ||
876 | |||
877 | static char *pipefs_dname(struct dentry *dent, char *buffer, int buflen) | ||
878 | { | ||
879 | return dynamic_dname(dentry, buffer, buflen, "pipe:[%lu]", | ||
880 | dentry->d_inode->i_ino); | ||
881 | } | ||
882 | |||
862 | Each dentry has a pointer to its parent dentry, as well as a hash list | 883 | Each dentry has a pointer to its parent dentry, as well as a hash list |
863 | of child dentries. Child dentries are basically like files in a | 884 | of child dentries. Child dentries are basically like files in a |
864 | directory. | 885 | directory. |
diff --git a/Documentation/hwmon/coretemp b/Documentation/hwmon/coretemp new file mode 100644 index 000000000000..870cda9416e9 --- /dev/null +++ b/Documentation/hwmon/coretemp | |||
@@ -0,0 +1,36 @@ | |||
1 | Kernel driver coretemp | ||
2 | ====================== | ||
3 | |||
4 | Supported chips: | ||
5 | * All Intel Core family | ||
6 | Prefix: 'coretemp' | ||
7 | CPUID: family 0x6, models 0xe, 0xf | ||
8 | Datasheet: Intel 64 and IA-32 Architectures Software Developer's Manual | ||
9 | Volume 3A: System Programming Guide | ||
10 | |||
11 | Author: Rudolf Marek | ||
12 | |||
13 | Description | ||
14 | ----------- | ||
15 | |||
16 | This driver permits reading temperature sensor embedded inside Intel Core CPU. | ||
17 | Temperature is measured in degrees Celsius and measurement resolution is | ||
18 | 1 degree C. Valid temperatures are from 0 to TjMax degrees C, because | ||
19 | the actual value of temperature register is in fact a delta from TjMax. | ||
20 | |||
21 | Temperature known as TjMax is the maximum junction temperature of processor. | ||
22 | Intel defines this temperature as 85C or 100C. At this temperature, protection | ||
23 | mechanism will perform actions to forcibly cool down the processor. Alarm | ||
24 | may be raised, if the temperature grows enough (more than TjMax) to trigger | ||
25 | the Out-Of-Spec bit. Following table summarizes the exported sysfs files: | ||
26 | |||
27 | temp1_input - Core temperature (in millidegrees Celsius). | ||
28 | temp1_crit - Maximum junction temperature (in millidegrees Celsius). | ||
29 | temp1_crit_alarm - Set when Out-of-spec bit is set, never clears. | ||
30 | Correct CPU operation is no longer guaranteed. | ||
31 | temp1_label - Contains string "Core X", where X is processor | ||
32 | number. | ||
33 | |||
34 | The TjMax temperature is set to 85 degrees C if undocumented model specific | ||
35 | register (UMSR) 0xee has bit 30 set. If not the TjMax is 100 degrees C as | ||
36 | (sometimes) documented in processor datasheet. | ||
diff --git a/Documentation/hwmon/max6650 b/Documentation/hwmon/max6650 new file mode 100644 index 000000000000..8be7beb9e3e8 --- /dev/null +++ b/Documentation/hwmon/max6650 | |||
@@ -0,0 +1,53 @@ | |||
1 | Kernel driver max6650 | ||
2 | ===================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Maxim 6650 / 6651 | ||
6 | Prefix: 'max6650' | ||
7 | Addresses scanned: I2C 0x1b, 0x1f, 0x48, 0x4b | ||
8 | Datasheet: http://pdfserv.maxim-ic.com/en/ds/MAX6650-MAX6651.pdf | ||
9 | |||
10 | Authors: | ||
11 | Hans J. Koch <hjk@linutronix.de> | ||
12 | John Morris <john.morris@spirentcom.com> | ||
13 | Claus Gindhart <claus.gindhart@kontron.com> | ||
14 | |||
15 | Description | ||
16 | ----------- | ||
17 | |||
18 | This driver implements support for the Maxim 6650/6651 | ||
19 | |||
20 | The 2 devices are very similar, but the Maxim 6550 has a reduced feature | ||
21 | set, e.g. only one fan-input, instead of 4 for the 6651. | ||
22 | |||
23 | The driver is not able to distinguish between the 2 devices. | ||
24 | |||
25 | The driver provides the following sensor accesses in sysfs: | ||
26 | |||
27 | fan1_input ro fan tachometer speed in RPM | ||
28 | fan2_input ro " | ||
29 | fan3_input ro " | ||
30 | fan4_input ro " | ||
31 | fan1_target rw desired fan speed in RPM (closed loop mode only) | ||
32 | pwm1_enable rw regulator mode, 0=full on, 1=open loop, 2=closed loop | ||
33 | pwm1 rw relative speed (0-255), 255=max. speed. | ||
34 | Used in open loop mode only. | ||
35 | fan1_div rw sets the speed range the inputs can handle. Legal | ||
36 | values are 1, 2, 4, and 8. Use lower values for | ||
37 | faster fans. | ||
38 | |||
39 | Module parameters | ||
40 | ----------------- | ||
41 | |||
42 | If your board has a BIOS that initializes the MAX6650/6651 correctly, you can | ||
43 | simply load your module without parameters. It won't touch the configuration | ||
44 | registers then. If your board BIOS doesn't initialize the chip, or you want | ||
45 | different settings, you can set the following parameters: | ||
46 | |||
47 | voltage_12V: 5=5V fan, 12=12V fan, 0=don't change | ||
48 | prescaler: Possible values are 1,2,4,8,16, or 0 for don't change | ||
49 | clock: The clock frequency in Hz of the chip the driver should assume [254000] | ||
50 | |||
51 | Please have a look at the MAX6650/6651 data sheet and make sure that you fully | ||
52 | understand the meaning of these parameters before you attempt to change them. | ||
53 | |||
diff --git a/Documentation/hwmon/smsc47m1 b/Documentation/hwmon/smsc47m1 index 04a11124f667..42c8431b3c9d 100644 --- a/Documentation/hwmon/smsc47m1 +++ b/Documentation/hwmon/smsc47m1 | |||
@@ -14,6 +14,10 @@ Supported chips: | |||
14 | http://www.smsc.com/main/datasheets/47m14x.pdf | 14 | http://www.smsc.com/main/datasheets/47m14x.pdf |
15 | http://www.smsc.com/main/tools/discontinued/47m15x.pdf | 15 | http://www.smsc.com/main/tools/discontinued/47m15x.pdf |
16 | http://www.smsc.com/main/datasheets/47m192.pdf | 16 | http://www.smsc.com/main/datasheets/47m192.pdf |
17 | * SMSC LPC47M292 | ||
18 | Addresses scanned: none, address read from Super I/O config space | ||
19 | Prefix: 'smsc47m2' | ||
20 | Datasheet: Not public | ||
17 | * SMSC LPC47M997 | 21 | * SMSC LPC47M997 |
18 | Addresses scanned: none, address read from Super I/O config space | 22 | Addresses scanned: none, address read from Super I/O config space |
19 | Prefix: 'smsc47m1' | 23 | Prefix: 'smsc47m1' |
@@ -32,9 +36,10 @@ Description | |||
32 | The Standard Microsystems Corporation (SMSC) 47M1xx Super I/O chips | 36 | The Standard Microsystems Corporation (SMSC) 47M1xx Super I/O chips |
33 | contain monitoring and PWM control circuitry for two fans. | 37 | contain monitoring and PWM control circuitry for two fans. |
34 | 38 | ||
35 | The 47M15x and 47M192 chips contain a full 'hardware monitoring block' | 39 | The LPC47M15x, LPC47M192 and LPC47M292 chips contain a full 'hardware |
36 | in addition to the fan monitoring and control. The hardware monitoring | 40 | monitoring block' in addition to the fan monitoring and control. The |
37 | block is not supported by the driver. | 41 | hardware monitoring block is not supported by this driver, use the |
42 | smsc47m192 driver for that. | ||
38 | 43 | ||
39 | No documentation is available for the 47M997, but it has the same device | 44 | No documentation is available for the 47M997, but it has the same device |
40 | ID as the 47M15x and 47M192 chips and seems to be compatible. | 45 | ID as the 47M15x and 47M192 chips and seems to be compatible. |
diff --git a/Documentation/hwmon/smsc47m192 b/Documentation/hwmon/smsc47m192 index 45d6453cd435..6d54ecb7b3f8 100644 --- a/Documentation/hwmon/smsc47m192 +++ b/Documentation/hwmon/smsc47m192 | |||
@@ -2,12 +2,13 @@ Kernel driver smsc47m192 | |||
2 | ======================== | 2 | ======================== |
3 | 3 | ||
4 | Supported chips: | 4 | Supported chips: |
5 | * SMSC LPC47M192 and LPC47M997 | 5 | * SMSC LPC47M192, LPC47M15x, LPC47M292 and LPC47M997 |
6 | Prefix: 'smsc47m192' | 6 | Prefix: 'smsc47m192' |
7 | Addresses scanned: I2C 0x2c - 0x2d | 7 | Addresses scanned: I2C 0x2c - 0x2d |
8 | Datasheet: The datasheet for LPC47M192 is publicly available from | 8 | Datasheet: The datasheet for LPC47M192 is publicly available from |
9 | http://www.smsc.com/ | 9 | http://www.smsc.com/ |
10 | The LPC47M997 is compatible for hardware monitoring. | 10 | The LPC47M15x, LPC47M292 and LPC47M997 are compatible for |
11 | hardware monitoring. | ||
11 | 12 | ||
12 | Author: Hartmut Rick <linux@rick.claranet.de> | 13 | Author: Hartmut Rick <linux@rick.claranet.de> |
13 | Special thanks to Jean Delvare for careful checking | 14 | Special thanks to Jean Delvare for careful checking |
@@ -18,7 +19,7 @@ Description | |||
18 | ----------- | 19 | ----------- |
19 | 20 | ||
20 | This driver implements support for the hardware sensor capabilities | 21 | This driver implements support for the hardware sensor capabilities |
21 | of the SMSC LPC47M192 and LPC47M997 Super-I/O chips. | 22 | of the SMSC LPC47M192 and compatible Super-I/O chips. |
22 | 23 | ||
23 | These chips support 3 temperature channels and 8 voltage inputs | 24 | These chips support 3 temperature channels and 8 voltage inputs |
24 | as well as CPU voltage VID input. | 25 | as well as CPU voltage VID input. |
diff --git a/Documentation/hwmon/sysfs-interface b/Documentation/hwmon/sysfs-interface index d73d2e8c7534..a9a18ad0d17a 100644 --- a/Documentation/hwmon/sysfs-interface +++ b/Documentation/hwmon/sysfs-interface | |||
@@ -152,6 +152,13 @@ fan[1-*]_div Fan divisor. | |||
152 | Note that this is actually an internal clock divisor, which | 152 | Note that this is actually an internal clock divisor, which |
153 | affects the measurable speed range, not the read value. | 153 | affects the measurable speed range, not the read value. |
154 | 154 | ||
155 | fan[1-*]_target | ||
156 | Desired fan speed | ||
157 | Unit: revolution/min (RPM) | ||
158 | RW | ||
159 | Only makes sense if the chip supports closed-loop fan speed | ||
160 | control based on the measured fan speed. | ||
161 | |||
155 | Also see the Alarms section for status flags associated with fans. | 162 | Also see the Alarms section for status flags associated with fans. |
156 | 163 | ||
157 | 164 | ||
diff --git a/Documentation/ia64/aliasing-test.c b/Documentation/ia64/aliasing-test.c new file mode 100644 index 000000000000..3153167b41c3 --- /dev/null +++ b/Documentation/ia64/aliasing-test.c | |||
@@ -0,0 +1,247 @@ | |||
1 | /* | ||
2 | * Exercise /dev/mem mmap cases that have been troublesome in the past | ||
3 | * | ||
4 | * (c) Copyright 2007 Hewlett-Packard Development Company, L.P. | ||
5 | * Bjorn Helgaas <bjorn.helgaas@hp.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <stdlib.h> | ||
13 | #include <stdio.h> | ||
14 | #include <sys/types.h> | ||
15 | #include <dirent.h> | ||
16 | #include <fcntl.h> | ||
17 | #include <fnmatch.h> | ||
18 | #include <string.h> | ||
19 | #include <sys/mman.h> | ||
20 | #include <sys/stat.h> | ||
21 | #include <unistd.h> | ||
22 | |||
23 | int sum; | ||
24 | |||
25 | int map_mem(char *path, off_t offset, size_t length, int touch) | ||
26 | { | ||
27 | int fd, rc; | ||
28 | void *addr; | ||
29 | int *c; | ||
30 | |||
31 | fd = open(path, O_RDWR); | ||
32 | if (fd == -1) { | ||
33 | perror(path); | ||
34 | return -1; | ||
35 | } | ||
36 | |||
37 | addr = mmap(NULL, length, PROT_READ|PROT_WRITE, MAP_SHARED, fd, offset); | ||
38 | if (addr == MAP_FAILED) | ||
39 | return 1; | ||
40 | |||
41 | if (touch) { | ||
42 | c = (int *) addr; | ||
43 | while (c < (int *) (offset + length)) | ||
44 | sum += *c++; | ||
45 | } | ||
46 | |||
47 | rc = munmap(addr, length); | ||
48 | if (rc == -1) { | ||
49 | perror("munmap"); | ||
50 | return -1; | ||
51 | } | ||
52 | |||
53 | close(fd); | ||
54 | return 0; | ||
55 | } | ||
56 | |||
57 | int scan_sysfs(char *path, char *file, off_t offset, size_t length, int touch) | ||
58 | { | ||
59 | struct dirent **namelist; | ||
60 | char *name, *path2; | ||
61 | int i, n, r, rc, result = 0; | ||
62 | struct stat buf; | ||
63 | |||
64 | n = scandir(path, &namelist, 0, alphasort); | ||
65 | if (n < 0) { | ||
66 | perror("scandir"); | ||
67 | return -1; | ||
68 | } | ||
69 | |||
70 | for (i = 0; i < n; i++) { | ||
71 | name = namelist[i]->d_name; | ||
72 | |||
73 | if (fnmatch(".", name, 0) == 0) | ||
74 | goto skip; | ||
75 | if (fnmatch("..", name, 0) == 0) | ||
76 | goto skip; | ||
77 | |||
78 | path2 = malloc(strlen(path) + strlen(name) + 3); | ||
79 | strcpy(path2, path); | ||
80 | strcat(path2, "/"); | ||
81 | strcat(path2, name); | ||
82 | |||
83 | if (fnmatch(file, name, 0) == 0) { | ||
84 | rc = map_mem(path2, offset, length, touch); | ||
85 | if (rc == 0) | ||
86 | fprintf(stderr, "PASS: %s 0x%lx-0x%lx is %s\n", path2, offset, offset + length, touch ? "readable" : "mappable"); | ||
87 | else if (rc > 0) | ||
88 | fprintf(stderr, "PASS: %s 0x%lx-0x%lx not mappable\n", path2, offset, offset + length); | ||
89 | else { | ||
90 | fprintf(stderr, "FAIL: %s 0x%lx-0x%lx not accessible\n", path2, offset, offset + length); | ||
91 | return rc; | ||
92 | } | ||
93 | } else { | ||
94 | r = lstat(path2, &buf); | ||
95 | if (r == 0 && S_ISDIR(buf.st_mode)) { | ||
96 | rc = scan_sysfs(path2, file, offset, length, touch); | ||
97 | if (rc < 0) | ||
98 | return rc; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | result |= rc; | ||
103 | free(path2); | ||
104 | |||
105 | skip: | ||
106 | free(namelist[i]); | ||
107 | } | ||
108 | free(namelist); | ||
109 | return rc; | ||
110 | } | ||
111 | |||
112 | char buf[1024]; | ||
113 | |||
114 | int read_rom(char *path) | ||
115 | { | ||
116 | int fd, rc; | ||
117 | size_t size = 0; | ||
118 | |||
119 | fd = open(path, O_RDWR); | ||
120 | if (fd == -1) { | ||
121 | perror(path); | ||
122 | return -1; | ||
123 | } | ||
124 | |||
125 | rc = write(fd, "1", 2); | ||
126 | if (rc <= 0) { | ||
127 | perror("write"); | ||
128 | return -1; | ||
129 | } | ||
130 | |||
131 | do { | ||
132 | rc = read(fd, buf, sizeof(buf)); | ||
133 | if (rc > 0) | ||
134 | size += rc; | ||
135 | } while (rc > 0); | ||
136 | |||
137 | close(fd); | ||
138 | return size; | ||
139 | } | ||
140 | |||
141 | int scan_rom(char *path, char *file) | ||
142 | { | ||
143 | struct dirent **namelist; | ||
144 | char *name, *path2; | ||
145 | int i, n, r, rc, result = 0; | ||
146 | struct stat buf; | ||
147 | |||
148 | n = scandir(path, &namelist, 0, alphasort); | ||
149 | if (n < 0) { | ||
150 | perror("scandir"); | ||
151 | return -1; | ||
152 | } | ||
153 | |||
154 | for (i = 0; i < n; i++) { | ||
155 | name = namelist[i]->d_name; | ||
156 | |||
157 | if (fnmatch(".", name, 0) == 0) | ||
158 | goto skip; | ||
159 | if (fnmatch("..", name, 0) == 0) | ||
160 | goto skip; | ||
161 | |||
162 | path2 = malloc(strlen(path) + strlen(name) + 3); | ||
163 | strcpy(path2, path); | ||
164 | strcat(path2, "/"); | ||
165 | strcat(path2, name); | ||
166 | |||
167 | if (fnmatch(file, name, 0) == 0) { | ||
168 | rc = read_rom(path2); | ||
169 | |||
170 | /* | ||
171 | * It's OK if the ROM is unreadable. Maybe there | ||
172 | * is no ROM, or some other error ocurred. The | ||
173 | * important thing is that no MCA happened. | ||
174 | */ | ||
175 | if (rc > 0) | ||
176 | fprintf(stderr, "PASS: %s read %ld bytes\n", path2, rc); | ||
177 | else { | ||
178 | fprintf(stderr, "PASS: %s not readable\n", path2); | ||
179 | return rc; | ||
180 | } | ||
181 | } else { | ||
182 | r = lstat(path2, &buf); | ||
183 | if (r == 0 && S_ISDIR(buf.st_mode)) { | ||
184 | rc = scan_rom(path2, file); | ||
185 | if (rc < 0) | ||
186 | return rc; | ||
187 | } | ||
188 | } | ||
189 | |||
190 | result |= rc; | ||
191 | free(path2); | ||
192 | |||
193 | skip: | ||
194 | free(namelist[i]); | ||
195 | } | ||
196 | free(namelist); | ||
197 | return rc; | ||
198 | } | ||
199 | |||
200 | main() | ||
201 | { | ||
202 | int rc; | ||
203 | |||
204 | if (map_mem("/dev/mem", 0, 0xA0000, 1) == 0) | ||
205 | fprintf(stderr, "PASS: /dev/mem 0x0-0xa0000 is readable\n"); | ||
206 | else | ||
207 | fprintf(stderr, "FAIL: /dev/mem 0x0-0xa0000 not accessible\n"); | ||
208 | |||
209 | /* | ||
210 | * It's not safe to blindly read the VGA frame buffer. If you know | ||
211 | * how to poke the card the right way, it should respond, but it's | ||
212 | * not safe in general. Many machines, e.g., Intel chipsets, cover | ||
213 | * up a non-responding card by just returning -1, but others will | ||
214 | * report the failure as a machine check. | ||
215 | */ | ||
216 | if (map_mem("/dev/mem", 0xA0000, 0x20000, 0) == 0) | ||
217 | fprintf(stderr, "PASS: /dev/mem 0xa0000-0xc0000 is mappable\n"); | ||
218 | else | ||
219 | fprintf(stderr, "FAIL: /dev/mem 0xa0000-0xc0000 not accessible\n"); | ||
220 | |||
221 | if (map_mem("/dev/mem", 0xC0000, 0x40000, 1) == 0) | ||
222 | fprintf(stderr, "PASS: /dev/mem 0xc0000-0x100000 is readable\n"); | ||
223 | else | ||
224 | fprintf(stderr, "FAIL: /dev/mem 0xc0000-0x100000 not accessible\n"); | ||
225 | |||
226 | /* | ||
227 | * Often you can map all the individual pieces above (0-0xA0000, | ||
228 | * 0xA0000-0xC0000, and 0xC0000-0x100000), but can't map the whole | ||
229 | * thing at once. This is because the individual pieces use different | ||
230 | * attributes, and there's no single attribute supported over the | ||
231 | * whole region. | ||
232 | */ | ||
233 | rc = map_mem("/dev/mem", 0, 1024*1024, 0); | ||
234 | if (rc == 0) | ||
235 | fprintf(stderr, "PASS: /dev/mem 0x0-0x100000 is mappable\n"); | ||
236 | else if (rc > 0) | ||
237 | fprintf(stderr, "PASS: /dev/mem 0x0-0x100000 not mappable\n"); | ||
238 | else | ||
239 | fprintf(stderr, "FAIL: /dev/mem 0x0-0x100000 not accessible\n"); | ||
240 | |||
241 | scan_sysfs("/sys/class/pci_bus", "legacy_mem", 0, 0xA0000, 1); | ||
242 | scan_sysfs("/sys/class/pci_bus", "legacy_mem", 0xA0000, 0x20000, 0); | ||
243 | scan_sysfs("/sys/class/pci_bus", "legacy_mem", 0xC0000, 0x40000, 1); | ||
244 | scan_sysfs("/sys/class/pci_bus", "legacy_mem", 0, 1024*1024, 0); | ||
245 | |||
246 | scan_rom("/sys/devices", "rom"); | ||
247 | } | ||
diff --git a/Documentation/ia64/aliasing.txt b/Documentation/ia64/aliasing.txt index 38f9a52d1820..9a431a7d0f5d 100644 --- a/Documentation/ia64/aliasing.txt +++ b/Documentation/ia64/aliasing.txt | |||
@@ -112,16 +112,6 @@ POTENTIAL ATTRIBUTE ALIASING CASES | |||
112 | 112 | ||
113 | The /dev/mem mmap constraints apply. | 113 | The /dev/mem mmap constraints apply. |
114 | 114 | ||
115 | However, since this is for mapping legacy MMIO space, WB access | ||
116 | does not make sense. This matters on machines without legacy | ||
117 | VGA support: these machines may have WB memory for the entire | ||
118 | first megabyte (or even the entire first granule). | ||
119 | |||
120 | On these machines, we could mmap legacy_mem as WB, which would | ||
121 | be safe in terms of attribute aliasing, but X has no way of | ||
122 | knowing that it is accessing regular memory, not a frame buffer, | ||
123 | so the kernel should fail the mmap rather than doing it with WB. | ||
124 | |||
125 | read/write of /dev/mem | 115 | read/write of /dev/mem |
126 | 116 | ||
127 | This uses copy_from_user(), which implicitly uses a kernel | 117 | This uses copy_from_user(), which implicitly uses a kernel |
@@ -138,14 +128,20 @@ POTENTIAL ATTRIBUTE ALIASING CASES | |||
138 | 128 | ||
139 | ioremap() | 129 | ioremap() |
140 | 130 | ||
141 | This returns a kernel identity mapping for use inside the | 131 | This returns a mapping for use inside the kernel. |
142 | kernel. | ||
143 | 132 | ||
144 | If the region is in kern_memmap, we should use the attribute | 133 | If the region is in kern_memmap, we should use the attribute |
145 | specified there. Otherwise, if the EFI memory map reports that | 134 | specified there. |
146 | the entire granule supports WB, we should use that (granules | 135 | |
147 | that are partially reserved or occupied by firmware do not appear | 136 | If the EFI memory map reports that the entire granule supports |
148 | in kern_memmap). Otherwise, we should use a UC mapping. | 137 | WB, we should use that (granules that are partially reserved |
138 | or occupied by firmware do not appear in kern_memmap). | ||
139 | |||
140 | If the granule contains non-WB memory, but we can cover the | ||
141 | region safely with kernel page table mappings, we can use | ||
142 | ioremap_page_range() as most other architectures do. | ||
143 | |||
144 | Failing all of the above, we have to fall back to a UC mapping. | ||
149 | 145 | ||
150 | PAST PROBLEM CASES | 146 | PAST PROBLEM CASES |
151 | 147 | ||
@@ -158,7 +154,7 @@ PAST PROBLEM CASES | |||
158 | succeed. It may create either WB or UC user mappings, depending | 154 | succeed. It may create either WB or UC user mappings, depending |
159 | on whether the region is in kern_memmap or the EFI memory map. | 155 | on whether the region is in kern_memmap or the EFI memory map. |
160 | 156 | ||
161 | mmap of 0x0-0xA0000 /dev/mem by "hwinfo" on HP sx1000 with VGA enabled | 157 | mmap of 0x0-0x9FFFF /dev/mem by "hwinfo" on HP sx1000 with VGA enabled |
162 | 158 | ||
163 | See https://bugzilla.novell.com/show_bug.cgi?id=140858. | 159 | See https://bugzilla.novell.com/show_bug.cgi?id=140858. |
164 | 160 | ||
@@ -171,28 +167,25 @@ PAST PROBLEM CASES | |||
171 | so it is safe to use WB mappings. | 167 | so it is safe to use WB mappings. |
172 | 168 | ||
173 | The kernel VGA driver may ioremap the VGA frame buffer at 0xA0000, | 169 | The kernel VGA driver may ioremap the VGA frame buffer at 0xA0000, |
174 | which will use a granule-sized UC mapping covering 0-0xFFFFF. This | 170 | which uses a granule-sized UC mapping. This granule will cover some |
175 | granule covers some WB-only memory, but since UC is non-speculative, | 171 | WB-only memory, but since UC is non-speculative, the processor will |
176 | the processor will never generate an uncacheable reference to the | 172 | never generate an uncacheable reference to the WB-only areas unless |
177 | WB-only areas unless the driver explicitly touches them. | 173 | the driver explicitly touches them. |
178 | 174 | ||
179 | mmap of 0x0-0xFFFFF legacy_mem by "X" | 175 | mmap of 0x0-0xFFFFF legacy_mem by "X" |
180 | 176 | ||
181 | If the EFI memory map reports this entire range as WB, there | 177 | If the EFI memory map reports that the entire range supports the |
182 | is no VGA MMIO hole, and the mmap should fail or be done with | 178 | same attributes, we can allow the mmap (and we will prefer WB if |
183 | a WB mapping. | 179 | supported, as is the case with HP sx[12]000 machines with VGA |
180 | disabled). | ||
184 | 181 | ||
185 | There's no easy way for X to determine whether the 0xA0000-0xBFFFF | 182 | If EFI reports the range as partly WB and partly UC (as on sx[12]000 |
186 | region is a frame buffer or just memory, so I think it's best to | 183 | machines with VGA enabled), we must fail the mmap because there's no |
187 | just fail this mmap request rather than using a WB mapping. As | 184 | safe attribute to use. |
188 | far as I know, there's no need to map legacy_mem with WB | ||
189 | mappings. | ||
190 | 185 | ||
191 | Otherwise, a UC mapping of the entire region is probably safe. | 186 | If EFI reports some of the range but not all (as on Intel firmware |
192 | The VGA hole means the region will not be in kern_memmap. The | 187 | that doesn't report the VGA frame buffer at all), we should fail the |
193 | HP sx1000 chipset doesn't support UC access to the memory surrounding | 188 | mmap and force the user to map just the specific region of interest. |
194 | the VGA hole, but X doesn't need that area anyway and should not | ||
195 | reference it. | ||
196 | 189 | ||
197 | mmap of 0xA0000-0xBFFFF legacy_mem by "X" on HP sx1000 with VGA disabled | 190 | mmap of 0xA0000-0xBFFFF legacy_mem by "X" on HP sx1000 with VGA disabled |
198 | 191 | ||
@@ -202,6 +195,16 @@ PAST PROBLEM CASES | |||
202 | This is a special case of the previous case, and the mmap should | 195 | This is a special case of the previous case, and the mmap should |
203 | fail for the same reason as above. | 196 | fail for the same reason as above. |
204 | 197 | ||
198 | read of /sys/devices/.../rom | ||
199 | |||
200 | For VGA devices, this may cause an ioremap() of 0xC0000. This | ||
201 | used to be done with a UC mapping, because the VGA frame buffer | ||
202 | at 0xA0000 prevents use of a WB granule. The UC mapping causes | ||
203 | an MCA on HP sx[12]000 chipsets. | ||
204 | |||
205 | We should use WB page table mappings to avoid covering the VGA | ||
206 | frame buffer. | ||
207 | |||
205 | NOTES | 208 | NOTES |
206 | 209 | ||
207 | [1] SDM rev 2.2, vol 2, sec 4.4.1. | 210 | [1] SDM rev 2.2, vol 2, sec 4.4.1. |
diff --git a/Documentation/ia64/err_inject.txt b/Documentation/ia64/err_inject.txt new file mode 100644 index 000000000000..6449a7090dbb --- /dev/null +++ b/Documentation/ia64/err_inject.txt | |||
@@ -0,0 +1,1068 @@ | |||
1 | |||
2 | IPF Machine Check (MC) error inject tool | ||
3 | ======================================== | ||
4 | |||
5 | IPF Machine Check (MC) error inject tool is used to inject MC | ||
6 | errors from Linux. The tool is a test bed for IPF MC work flow including | ||
7 | hardware correctable error handling, OS recoverable error handling, MC | ||
8 | event logging, etc. | ||
9 | |||
10 | The tool includes two parts: a kernel driver and a user application | ||
11 | sample. The driver provides interface to PAL to inject error | ||
12 | and query error injection capabilities. The driver code is in | ||
13 | arch/ia64/kernel/err_inject.c. The application sample (shown below) | ||
14 | provides a combination of various errors and calls the driver's interface | ||
15 | (sysfs interface) to inject errors or query error injection capabilities. | ||
16 | |||
17 | The tool can be used to test Intel IPF machine MC handling capabilities. | ||
18 | It's especially useful for people who can not access hardware MC injection | ||
19 | tool to inject error. It's also very useful to integrate with other | ||
20 | software test suits to do stressful testing on IPF. | ||
21 | |||
22 | Below is a sample application as part of the whole tool. The sample | ||
23 | can be used as a working test tool. Or it can be expanded to include | ||
24 | more features. It also can be a integrated into a libary or other user | ||
25 | application to have more thorough test. | ||
26 | |||
27 | The sample application takes err.conf as error configuation input. Gcc | ||
28 | compiles the code. After you install err_inject driver, you can run | ||
29 | this sample application to inject errors. | ||
30 | |||
31 | Errata: Itanium 2 Processors Specification Update lists some errata against | ||
32 | the pal_mc_error_inject PAL procedure. The following err.conf has been tested | ||
33 | on latest Montecito PAL. | ||
34 | |||
35 | err.conf: | ||
36 | |||
37 | #This is configuration file for err_inject_tool. | ||
38 | #The format of the each line is: | ||
39 | #cpu, loop, interval, err_type_info, err_struct_info, err_data_buffer | ||
40 | #where | ||
41 | # cpu: logical cpu number the error will be inject in. | ||
42 | # loop: times the error will be injected. | ||
43 | # interval: In second. every so often one error is injected. | ||
44 | # err_type_info, err_struct_info: PAL parameters. | ||
45 | # | ||
46 | #Note: All values are hex w/o or w/ 0x prefix. | ||
47 | |||
48 | |||
49 | #On cpu2, inject only total 0x10 errors, interval 5 seconds | ||
50 | #corrected, data cache, hier-2, physical addr(assigned by tool code). | ||
51 | #working on Montecito latest PAL. | ||
52 | 2, 10, 5, 4101, 95 | ||
53 | |||
54 | #On cpu4, inject and consume total 0x10 errors, interval 5 seconds | ||
55 | #corrected, data cache, hier-2, physical addr(assigned by tool code). | ||
56 | #working on Montecito latest PAL. | ||
57 | 4, 10, 5, 4109, 95 | ||
58 | |||
59 | #On cpu15, inject and consume total 0x10 errors, interval 5 seconds | ||
60 | #recoverable, DTR0, hier-2. | ||
61 | #working on Montecito latest PAL. | ||
62 | 0xf, 0x10, 5, 4249, 15 | ||
63 | |||
64 | The sample application source code: | ||
65 | |||
66 | err_injection_tool.c: | ||
67 | |||
68 | /* | ||
69 | * This program is free software; you can redistribute it and/or modify | ||
70 | * it under the terms of the GNU General Public License as published by | ||
71 | * the Free Software Foundation; either version 2 of the License, or | ||
72 | * (at your option) any later version. | ||
73 | * | ||
74 | * This program is distributed in the hope that it will be useful, but | ||
75 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
76 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
77 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
78 | * details. | ||
79 | * | ||
80 | * You should have received a copy of the GNU General Public License | ||
81 | * along with this program; if not, write to the Free Software | ||
82 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
83 | * | ||
84 | * Copyright (C) 2006 Intel Co | ||
85 | * Fenghua Yu <fenghua.yu@intel.com> | ||
86 | * | ||
87 | */ | ||
88 | #include <sys/types.h> | ||
89 | #include <sys/stat.h> | ||
90 | #include <fcntl.h> | ||
91 | #include <stdio.h> | ||
92 | #include <sched.h> | ||
93 | #include <unistd.h> | ||
94 | #include <stdlib.h> | ||
95 | #include <stdarg.h> | ||
96 | #include <string.h> | ||
97 | #include <errno.h> | ||
98 | #include <time.h> | ||
99 | #include <sys/ipc.h> | ||
100 | #include <sys/sem.h> | ||
101 | #include <sys/wait.h> | ||
102 | #include <sys/mman.h> | ||
103 | #include <sys/shm.h> | ||
104 | |||
105 | #define MAX_FN_SIZE 256 | ||
106 | #define MAX_BUF_SIZE 256 | ||
107 | #define DATA_BUF_SIZE 256 | ||
108 | #define NR_CPUS 512 | ||
109 | #define MAX_TASK_NUM 2048 | ||
110 | #define MIN_INTERVAL 5 // seconds | ||
111 | #define ERR_DATA_BUFFER_SIZE 3 // Three 8-byte. | ||
112 | #define PARA_FIELD_NUM 5 | ||
113 | #define MASK_SIZE (NR_CPUS/64) | ||
114 | #define PATH_FORMAT "/sys/devices/system/cpu/cpu%d/err_inject/" | ||
115 | |||
116 | int sched_setaffinity(pid_t pid, unsigned int len, unsigned long *mask); | ||
117 | |||
118 | int verbose; | ||
119 | #define vbprintf if (verbose) printf | ||
120 | |||
121 | int log_info(int cpu, const char *fmt, ...) | ||
122 | { | ||
123 | FILE *log; | ||
124 | char fn[MAX_FN_SIZE]; | ||
125 | char buf[MAX_BUF_SIZE]; | ||
126 | va_list args; | ||
127 | |||
128 | sprintf(fn, "%d.log", cpu); | ||
129 | log=fopen(fn, "a+"); | ||
130 | if (log==NULL) { | ||
131 | perror("Error open:"); | ||
132 | return -1; | ||
133 | } | ||
134 | |||
135 | va_start(args, fmt); | ||
136 | vprintf(fmt, args); | ||
137 | memset(buf, 0, MAX_BUF_SIZE); | ||
138 | vsprintf(buf, fmt, args); | ||
139 | va_end(args); | ||
140 | |||
141 | fwrite(buf, sizeof(buf), 1, log); | ||
142 | fclose(log); | ||
143 | |||
144 | return 0; | ||
145 | } | ||
146 | |||
147 | typedef unsigned long u64; | ||
148 | typedef unsigned int u32; | ||
149 | |||
150 | typedef union err_type_info_u { | ||
151 | struct { | ||
152 | u64 mode : 3, /* 0-2 */ | ||
153 | err_inj : 3, /* 3-5 */ | ||
154 | err_sev : 2, /* 6-7 */ | ||
155 | err_struct : 5, /* 8-12 */ | ||
156 | struct_hier : 3, /* 13-15 */ | ||
157 | reserved : 48; /* 16-63 */ | ||
158 | } err_type_info_u; | ||
159 | u64 err_type_info; | ||
160 | } err_type_info_t; | ||
161 | |||
162 | typedef union err_struct_info_u { | ||
163 | struct { | ||
164 | u64 siv : 1, /* 0 */ | ||
165 | c_t : 2, /* 1-2 */ | ||
166 | cl_p : 3, /* 3-5 */ | ||
167 | cl_id : 3, /* 6-8 */ | ||
168 | cl_dp : 1, /* 9 */ | ||
169 | reserved1 : 22, /* 10-31 */ | ||
170 | tiv : 1, /* 32 */ | ||
171 | trigger : 4, /* 33-36 */ | ||
172 | trigger_pl : 3, /* 37-39 */ | ||
173 | reserved2 : 24; /* 40-63 */ | ||
174 | } err_struct_info_cache; | ||
175 | struct { | ||
176 | u64 siv : 1, /* 0 */ | ||
177 | tt : 2, /* 1-2 */ | ||
178 | tc_tr : 2, /* 3-4 */ | ||
179 | tr_slot : 8, /* 5-12 */ | ||
180 | reserved1 : 19, /* 13-31 */ | ||
181 | tiv : 1, /* 32 */ | ||
182 | trigger : 4, /* 33-36 */ | ||
183 | trigger_pl : 3, /* 37-39 */ | ||
184 | reserved2 : 24; /* 40-63 */ | ||
185 | } err_struct_info_tlb; | ||
186 | struct { | ||
187 | u64 siv : 1, /* 0 */ | ||
188 | regfile_id : 4, /* 1-4 */ | ||
189 | reg_num : 7, /* 5-11 */ | ||
190 | reserved1 : 20, /* 12-31 */ | ||
191 | tiv : 1, /* 32 */ | ||
192 | trigger : 4, /* 33-36 */ | ||
193 | trigger_pl : 3, /* 37-39 */ | ||
194 | reserved2 : 24; /* 40-63 */ | ||
195 | } err_struct_info_register; | ||
196 | struct { | ||
197 | u64 reserved; | ||
198 | } err_struct_info_bus_processor_interconnect; | ||
199 | u64 err_struct_info; | ||
200 | } err_struct_info_t; | ||
201 | |||
202 | typedef union err_data_buffer_u { | ||
203 | struct { | ||
204 | u64 trigger_addr; /* 0-63 */ | ||
205 | u64 inj_addr; /* 64-127 */ | ||
206 | u64 way : 5, /* 128-132 */ | ||
207 | index : 20, /* 133-152 */ | ||
208 | : 39; /* 153-191 */ | ||
209 | } err_data_buffer_cache; | ||
210 | struct { | ||
211 | u64 trigger_addr; /* 0-63 */ | ||
212 | u64 inj_addr; /* 64-127 */ | ||
213 | u64 way : 5, /* 128-132 */ | ||
214 | index : 20, /* 133-152 */ | ||
215 | reserved : 39; /* 153-191 */ | ||
216 | } err_data_buffer_tlb; | ||
217 | struct { | ||
218 | u64 trigger_addr; /* 0-63 */ | ||
219 | } err_data_buffer_register; | ||
220 | struct { | ||
221 | u64 reserved; /* 0-63 */ | ||
222 | } err_data_buffer_bus_processor_interconnect; | ||
223 | u64 err_data_buffer[ERR_DATA_BUFFER_SIZE]; | ||
224 | } err_data_buffer_t; | ||
225 | |||
226 | typedef union capabilities_u { | ||
227 | struct { | ||
228 | u64 i : 1, | ||
229 | d : 1, | ||
230 | rv : 1, | ||
231 | tag : 1, | ||
232 | data : 1, | ||
233 | mesi : 1, | ||
234 | dp : 1, | ||
235 | reserved1 : 3, | ||
236 | pa : 1, | ||
237 | va : 1, | ||
238 | wi : 1, | ||
239 | reserved2 : 20, | ||
240 | trigger : 1, | ||
241 | trigger_pl : 1, | ||
242 | reserved3 : 30; | ||
243 | } capabilities_cache; | ||
244 | struct { | ||
245 | u64 d : 1, | ||
246 | i : 1, | ||
247 | rv : 1, | ||
248 | tc : 1, | ||
249 | tr : 1, | ||
250 | reserved1 : 27, | ||
251 | trigger : 1, | ||
252 | trigger_pl : 1, | ||
253 | reserved2 : 30; | ||
254 | } capabilities_tlb; | ||
255 | struct { | ||
256 | u64 gr_b0 : 1, | ||
257 | gr_b1 : 1, | ||
258 | fr : 1, | ||
259 | br : 1, | ||
260 | pr : 1, | ||
261 | ar : 1, | ||
262 | cr : 1, | ||
263 | rr : 1, | ||
264 | pkr : 1, | ||
265 | dbr : 1, | ||
266 | ibr : 1, | ||
267 | pmc : 1, | ||
268 | pmd : 1, | ||
269 | reserved1 : 3, | ||
270 | regnum : 1, | ||
271 | reserved2 : 15, | ||
272 | trigger : 1, | ||
273 | trigger_pl : 1, | ||
274 | reserved3 : 30; | ||
275 | } capabilities_register; | ||
276 | struct { | ||
277 | u64 reserved; | ||
278 | } capabilities_bus_processor_interconnect; | ||
279 | } capabilities_t; | ||
280 | |||
281 | typedef struct resources_s { | ||
282 | u64 ibr0 : 1, | ||
283 | ibr2 : 1, | ||
284 | ibr4 : 1, | ||
285 | ibr6 : 1, | ||
286 | dbr0 : 1, | ||
287 | dbr2 : 1, | ||
288 | dbr4 : 1, | ||
289 | dbr6 : 1, | ||
290 | reserved : 48; | ||
291 | } resources_t; | ||
292 | |||
293 | |||
294 | long get_page_size(void) | ||
295 | { | ||
296 | long page_size=sysconf(_SC_PAGESIZE); | ||
297 | return page_size; | ||
298 | } | ||
299 | |||
300 | #define PAGE_SIZE (get_page_size()==-1?0x4000:get_page_size()) | ||
301 | #define SHM_SIZE (2*PAGE_SIZE*NR_CPUS) | ||
302 | #define SHM_VA 0x2000000100000000 | ||
303 | |||
304 | int shmid; | ||
305 | void *shmaddr; | ||
306 | |||
307 | int create_shm(void) | ||
308 | { | ||
309 | key_t key; | ||
310 | char fn[MAX_FN_SIZE]; | ||
311 | |||
312 | /* cpu0 is always existing */ | ||
313 | sprintf(fn, PATH_FORMAT, 0); | ||
314 | if ((key = ftok(fn, 's')) == -1) { | ||
315 | perror("ftok"); | ||
316 | return -1; | ||
317 | } | ||
318 | |||
319 | shmid = shmget(key, SHM_SIZE, 0644 | IPC_CREAT); | ||
320 | if (shmid == -1) { | ||
321 | if (errno==EEXIST) { | ||
322 | shmid = shmget(key, SHM_SIZE, 0); | ||
323 | if (shmid == -1) { | ||
324 | perror("shmget"); | ||
325 | return -1; | ||
326 | } | ||
327 | } | ||
328 | else { | ||
329 | perror("shmget"); | ||
330 | return -1; | ||
331 | } | ||
332 | } | ||
333 | vbprintf("shmid=%d", shmid); | ||
334 | |||
335 | /* connect to the segment: */ | ||
336 | shmaddr = shmat(shmid, (void *)SHM_VA, 0); | ||
337 | if (shmaddr == (void*)-1) { | ||
338 | perror("shmat"); | ||
339 | return -1; | ||
340 | } | ||
341 | |||
342 | memset(shmaddr, 0, SHM_SIZE); | ||
343 | mlock(shmaddr, SHM_SIZE); | ||
344 | |||
345 | return 0; | ||
346 | } | ||
347 | |||
348 | int free_shm() | ||
349 | { | ||
350 | munlock(shmaddr, SHM_SIZE); | ||
351 | shmdt(shmaddr); | ||
352 | semctl(shmid, 0, IPC_RMID); | ||
353 | |||
354 | return 0; | ||
355 | } | ||
356 | |||
357 | #ifdef _SEM_SEMUN_UNDEFINED | ||
358 | union semun | ||
359 | { | ||
360 | int val; | ||
361 | struct semid_ds *buf; | ||
362 | unsigned short int *array; | ||
363 | struct seminfo *__buf; | ||
364 | }; | ||
365 | #endif | ||
366 | |||
367 | u32 mode=1; /* 1: physical mode; 2: virtual mode. */ | ||
368 | int one_lock=1; | ||
369 | key_t key[NR_CPUS]; | ||
370 | int semid[NR_CPUS]; | ||
371 | |||
372 | int create_sem(int cpu) | ||
373 | { | ||
374 | union semun arg; | ||
375 | char fn[MAX_FN_SIZE]; | ||
376 | int sid; | ||
377 | |||
378 | sprintf(fn, PATH_FORMAT, cpu); | ||
379 | sprintf(fn, "%s/%s", fn, "err_type_info"); | ||
380 | if ((key[cpu] = ftok(fn, 'e')) == -1) { | ||
381 | perror("ftok"); | ||
382 | return -1; | ||
383 | } | ||
384 | |||
385 | if (semid[cpu]!=0) | ||
386 | return 0; | ||
387 | |||
388 | /* clear old semaphore */ | ||
389 | if ((sid = semget(key[cpu], 1, 0)) != -1) | ||
390 | semctl(sid, 0, IPC_RMID); | ||
391 | |||
392 | /* get one semaphore */ | ||
393 | if ((semid[cpu] = semget(key[cpu], 1, IPC_CREAT | IPC_EXCL)) == -1) { | ||
394 | perror("semget"); | ||
395 | printf("Please remove semaphore with key=0x%lx, then run the tool.\n", | ||
396 | (u64)key[cpu]); | ||
397 | return -1; | ||
398 | } | ||
399 | |||
400 | vbprintf("semid[%d]=0x%lx, key[%d]=%lx\n",cpu,(u64)semid[cpu],cpu, | ||
401 | (u64)key[cpu]); | ||
402 | /* initialize the semaphore to 1: */ | ||
403 | arg.val = 1; | ||
404 | if (semctl(semid[cpu], 0, SETVAL, arg) == -1) { | ||
405 | perror("semctl"); | ||
406 | return -1; | ||
407 | } | ||
408 | |||
409 | return 0; | ||
410 | } | ||
411 | |||
412 | static int lock(int cpu) | ||
413 | { | ||
414 | struct sembuf lock; | ||
415 | |||
416 | lock.sem_num = cpu; | ||
417 | lock.sem_op = 1; | ||
418 | semop(semid[cpu], &lock, 1); | ||
419 | |||
420 | return 0; | ||
421 | } | ||
422 | |||
423 | static int unlock(int cpu) | ||
424 | { | ||
425 | struct sembuf unlock; | ||
426 | |||
427 | unlock.sem_num = cpu; | ||
428 | unlock.sem_op = -1; | ||
429 | semop(semid[cpu], &unlock, 1); | ||
430 | |||
431 | return 0; | ||
432 | } | ||
433 | |||
434 | void free_sem(int cpu) | ||
435 | { | ||
436 | semctl(semid[cpu], 0, IPC_RMID); | ||
437 | } | ||
438 | |||
439 | int wr_multi(char *fn, unsigned long *data, int size) | ||
440 | { | ||
441 | int fd; | ||
442 | char buf[MAX_BUF_SIZE]; | ||
443 | int ret; | ||
444 | |||
445 | if (size==1) | ||
446 | sprintf(buf, "%lx", *data); | ||
447 | else if (size==3) | ||
448 | sprintf(buf, "%lx,%lx,%lx", data[0], data[1], data[2]); | ||
449 | else { | ||
450 | fprintf(stderr,"write to file with wrong size!\n"); | ||
451 | return -1; | ||
452 | } | ||
453 | |||
454 | fd=open(fn, O_RDWR); | ||
455 | if (!fd) { | ||
456 | perror("Error:"); | ||
457 | return -1; | ||
458 | } | ||
459 | ret=write(fd, buf, sizeof(buf)); | ||
460 | close(fd); | ||
461 | return ret; | ||
462 | } | ||
463 | |||
464 | int wr(char *fn, unsigned long data) | ||
465 | { | ||
466 | return wr_multi(fn, &data, 1); | ||
467 | } | ||
468 | |||
469 | int rd(char *fn, unsigned long *data) | ||
470 | { | ||
471 | int fd; | ||
472 | char buf[MAX_BUF_SIZE]; | ||
473 | |||
474 | fd=open(fn, O_RDONLY); | ||
475 | if (fd<0) { | ||
476 | perror("Error:"); | ||
477 | return -1; | ||
478 | } | ||
479 | read(fd, buf, MAX_BUF_SIZE); | ||
480 | *data=strtoul(buf, NULL, 16); | ||
481 | close(fd); | ||
482 | return 0; | ||
483 | } | ||
484 | |||
485 | int rd_status(char *path, int *status) | ||
486 | { | ||
487 | char fn[MAX_FN_SIZE]; | ||
488 | sprintf(fn, "%s/status", path); | ||
489 | if (rd(fn, (u64*)status)<0) { | ||
490 | perror("status reading error.\n"); | ||
491 | return -1; | ||
492 | } | ||
493 | |||
494 | return 0; | ||
495 | } | ||
496 | |||
497 | int rd_capabilities(char *path, u64 *capabilities) | ||
498 | { | ||
499 | char fn[MAX_FN_SIZE]; | ||
500 | sprintf(fn, "%s/capabilities", path); | ||
501 | if (rd(fn, capabilities)<0) { | ||
502 | perror("capabilities reading error.\n"); | ||
503 | return -1; | ||
504 | } | ||
505 | |||
506 | return 0; | ||
507 | } | ||
508 | |||
509 | int rd_all(char *path) | ||
510 | { | ||
511 | unsigned long err_type_info, err_struct_info, err_data_buffer; | ||
512 | int status; | ||
513 | unsigned long capabilities, resources; | ||
514 | char fn[MAX_FN_SIZE]; | ||
515 | |||
516 | sprintf(fn, "%s/err_type_info", path); | ||
517 | if (rd(fn, &err_type_info)<0) { | ||
518 | perror("err_type_info reading error.\n"); | ||
519 | return -1; | ||
520 | } | ||
521 | printf("err_type_info=%lx\n", err_type_info); | ||
522 | |||
523 | sprintf(fn, "%s/err_struct_info", path); | ||
524 | if (rd(fn, &err_struct_info)<0) { | ||
525 | perror("err_struct_info reading error.\n"); | ||
526 | return -1; | ||
527 | } | ||
528 | printf("err_struct_info=%lx\n", err_struct_info); | ||
529 | |||
530 | sprintf(fn, "%s/err_data_buffer", path); | ||
531 | if (rd(fn, &err_data_buffer)<0) { | ||
532 | perror("err_data_buffer reading error.\n"); | ||
533 | return -1; | ||
534 | } | ||
535 | printf("err_data_buffer=%lx\n", err_data_buffer); | ||
536 | |||
537 | sprintf(fn, "%s/status", path); | ||
538 | if (rd("status", (u64*)&status)<0) { | ||
539 | perror("status reading error.\n"); | ||
540 | return -1; | ||
541 | } | ||
542 | printf("status=%d\n", status); | ||
543 | |||
544 | sprintf(fn, "%s/capabilities", path); | ||
545 | if (rd(fn,&capabilities)<0) { | ||
546 | perror("capabilities reading error.\n"); | ||
547 | return -1; | ||
548 | } | ||
549 | printf("capabilities=%lx\n", capabilities); | ||
550 | |||
551 | sprintf(fn, "%s/resources", path); | ||
552 | if (rd(fn, &resources)<0) { | ||
553 | perror("resources reading error.\n"); | ||
554 | return -1; | ||
555 | } | ||
556 | printf("resources=%lx\n", resources); | ||
557 | |||
558 | return 0; | ||
559 | } | ||
560 | |||
561 | int query_capabilities(char *path, err_type_info_t err_type_info, | ||
562 | u64 *capabilities) | ||
563 | { | ||
564 | char fn[MAX_FN_SIZE]; | ||
565 | err_struct_info_t err_struct_info; | ||
566 | err_data_buffer_t err_data_buffer; | ||
567 | |||
568 | err_struct_info.err_struct_info=0; | ||
569 | memset(err_data_buffer.err_data_buffer, -1, ERR_DATA_BUFFER_SIZE*8); | ||
570 | |||
571 | sprintf(fn, "%s/err_type_info", path); | ||
572 | wr(fn, err_type_info.err_type_info); | ||
573 | sprintf(fn, "%s/err_struct_info", path); | ||
574 | wr(fn, 0x0); | ||
575 | sprintf(fn, "%s/err_data_buffer", path); | ||
576 | wr_multi(fn, err_data_buffer.err_data_buffer, ERR_DATA_BUFFER_SIZE); | ||
577 | |||
578 | // Fire pal_mc_error_inject procedure. | ||
579 | sprintf(fn, "%s/call_start", path); | ||
580 | wr(fn, mode); | ||
581 | |||
582 | if (rd_capabilities(path, capabilities)<0) | ||
583 | return -1; | ||
584 | |||
585 | return 0; | ||
586 | } | ||
587 | |||
588 | int query_all_capabilities() | ||
589 | { | ||
590 | int status; | ||
591 | err_type_info_t err_type_info; | ||
592 | int err_sev, err_struct, struct_hier; | ||
593 | int cap=0; | ||
594 | u64 capabilities; | ||
595 | char path[MAX_FN_SIZE]; | ||
596 | |||
597 | err_type_info.err_type_info=0; // Initial | ||
598 | err_type_info.err_type_info_u.mode=0; // Query mode; | ||
599 | err_type_info.err_type_info_u.err_inj=0; | ||
600 | |||
601 | printf("All capabilities implemented in pal_mc_error_inject:\n"); | ||
602 | sprintf(path, PATH_FORMAT ,0); | ||
603 | for (err_sev=0;err_sev<3;err_sev++) | ||
604 | for (err_struct=0;err_struct<5;err_struct++) | ||
605 | for (struct_hier=0;struct_hier<5;struct_hier++) | ||
606 | { | ||
607 | status=-1; | ||
608 | capabilities=0; | ||
609 | err_type_info.err_type_info_u.err_sev=err_sev; | ||
610 | err_type_info.err_type_info_u.err_struct=err_struct; | ||
611 | err_type_info.err_type_info_u.struct_hier=struct_hier; | ||
612 | |||
613 | if (query_capabilities(path, err_type_info, &capabilities)<0) | ||
614 | continue; | ||
615 | |||
616 | if (rd_status(path, &status)<0) | ||
617 | continue; | ||
618 | |||
619 | if (status==0) { | ||
620 | cap=1; | ||
621 | printf("For err_sev=%d, err_struct=%d, struct_hier=%d: ", | ||
622 | err_sev, err_struct, struct_hier); | ||
623 | printf("capabilities 0x%lx\n", capabilities); | ||
624 | } | ||
625 | } | ||
626 | if (!cap) { | ||
627 | printf("No capabilities supported.\n"); | ||
628 | return 0; | ||
629 | } | ||
630 | |||
631 | return 0; | ||
632 | } | ||
633 | |||
634 | int err_inject(int cpu, char *path, err_type_info_t err_type_info, | ||
635 | err_struct_info_t err_struct_info, | ||
636 | err_data_buffer_t err_data_buffer) | ||
637 | { | ||
638 | int status; | ||
639 | char fn[MAX_FN_SIZE]; | ||
640 | |||
641 | log_info(cpu, "err_type_info=%lx, err_struct_info=%lx, ", | ||
642 | err_type_info.err_type_info, | ||
643 | err_struct_info.err_struct_info); | ||
644 | log_info(cpu,"err_data_buffer=[%lx,%lx,%lx]\n", | ||
645 | err_data_buffer.err_data_buffer[0], | ||
646 | err_data_buffer.err_data_buffer[1], | ||
647 | err_data_buffer.err_data_buffer[2]); | ||
648 | sprintf(fn, "%s/err_type_info", path); | ||
649 | wr(fn, err_type_info.err_type_info); | ||
650 | sprintf(fn, "%s/err_struct_info", path); | ||
651 | wr(fn, err_struct_info.err_struct_info); | ||
652 | sprintf(fn, "%s/err_data_buffer", path); | ||
653 | wr_multi(fn, err_data_buffer.err_data_buffer, ERR_DATA_BUFFER_SIZE); | ||
654 | |||
655 | // Fire pal_mc_error_inject procedure. | ||
656 | sprintf(fn, "%s/call_start", path); | ||
657 | wr(fn,mode); | ||
658 | |||
659 | if (rd_status(path, &status)<0) { | ||
660 | vbprintf("fail: read status\n"); | ||
661 | return -100; | ||
662 | } | ||
663 | |||
664 | if (status!=0) { | ||
665 | log_info(cpu, "fail: status=%d\n", status); | ||
666 | return status; | ||
667 | } | ||
668 | |||
669 | return status; | ||
670 | } | ||
671 | |||
672 | static int construct_data_buf(char *path, err_type_info_t err_type_info, | ||
673 | err_struct_info_t err_struct_info, | ||
674 | err_data_buffer_t *err_data_buffer, | ||
675 | void *va1) | ||
676 | { | ||
677 | char fn[MAX_FN_SIZE]; | ||
678 | u64 virt_addr=0, phys_addr=0; | ||
679 | |||
680 | vbprintf("va1=%lx\n", (u64)va1); | ||
681 | memset(&err_data_buffer->err_data_buffer_cache, 0, ERR_DATA_BUFFER_SIZE*8); | ||
682 | |||
683 | switch (err_type_info.err_type_info_u.err_struct) { | ||
684 | case 1: // Cache | ||
685 | switch (err_struct_info.err_struct_info_cache.cl_id) { | ||
686 | case 1: //Virtual addr | ||
687 | err_data_buffer->err_data_buffer_cache.inj_addr=(u64)va1; | ||
688 | break; | ||
689 | case 2: //Phys addr | ||
690 | sprintf(fn, "%s/virtual_to_phys", path); | ||
691 | virt_addr=(u64)va1; | ||
692 | if (wr(fn,virt_addr)<0) | ||
693 | return -1; | ||
694 | rd(fn, &phys_addr); | ||
695 | err_data_buffer->err_data_buffer_cache.inj_addr=phys_addr; | ||
696 | break; | ||
697 | default: | ||
698 | printf("Not supported cl_id\n"); | ||
699 | break; | ||
700 | } | ||
701 | break; | ||
702 | case 2: // TLB | ||
703 | break; | ||
704 | case 3: // Register file | ||
705 | break; | ||
706 | case 4: // Bus/system interconnect | ||
707 | default: | ||
708 | printf("Not supported err_struct\n"); | ||
709 | break; | ||
710 | } | ||
711 | |||
712 | return 0; | ||
713 | } | ||
714 | |||
715 | typedef struct { | ||
716 | u64 cpu; | ||
717 | u64 loop; | ||
718 | u64 interval; | ||
719 | u64 err_type_info; | ||
720 | u64 err_struct_info; | ||
721 | u64 err_data_buffer[ERR_DATA_BUFFER_SIZE]; | ||
722 | } parameters_t; | ||
723 | |||
724 | parameters_t line_para; | ||
725 | int para; | ||
726 | |||
727 | static int empty_data_buffer(u64 *err_data_buffer) | ||
728 | { | ||
729 | int empty=1; | ||
730 | int i; | ||
731 | |||
732 | for (i=0;i<ERR_DATA_BUFFER_SIZE; i++) | ||
733 | if (err_data_buffer[i]!=-1) | ||
734 | empty=0; | ||
735 | |||
736 | return empty; | ||
737 | } | ||
738 | |||
739 | int err_inj() | ||
740 | { | ||
741 | err_type_info_t err_type_info; | ||
742 | err_struct_info_t err_struct_info; | ||
743 | err_data_buffer_t err_data_buffer; | ||
744 | int count; | ||
745 | FILE *fp; | ||
746 | unsigned long cpu, loop, interval, err_type_info_conf, err_struct_info_conf; | ||
747 | u64 err_data_buffer_conf[ERR_DATA_BUFFER_SIZE]; | ||
748 | int num; | ||
749 | int i; | ||
750 | char path[MAX_FN_SIZE]; | ||
751 | parameters_t parameters[MAX_TASK_NUM]={}; | ||
752 | pid_t child_pid[MAX_TASK_NUM]; | ||
753 | time_t current_time; | ||
754 | int status; | ||
755 | |||
756 | if (!para) { | ||
757 | fp=fopen("err.conf", "r"); | ||
758 | if (fp==NULL) { | ||
759 | perror("Error open err.conf"); | ||
760 | return -1; | ||
761 | } | ||
762 | |||
763 | num=0; | ||
764 | while (!feof(fp)) { | ||
765 | char buf[256]; | ||
766 | memset(buf,0,256); | ||
767 | fgets(buf, 256, fp); | ||
768 | count=sscanf(buf, "%lx, %lx, %lx, %lx, %lx, %lx, %lx, %lx\n", | ||
769 | &cpu, &loop, &interval,&err_type_info_conf, | ||
770 | &err_struct_info_conf, | ||
771 | &err_data_buffer_conf[0], | ||
772 | &err_data_buffer_conf[1], | ||
773 | &err_data_buffer_conf[2]); | ||
774 | if (count!=PARA_FIELD_NUM+3) { | ||
775 | err_data_buffer_conf[0]=-1; | ||
776 | err_data_buffer_conf[1]=-1; | ||
777 | err_data_buffer_conf[2]=-1; | ||
778 | count=sscanf(buf, "%lx, %lx, %lx, %lx, %lx\n", | ||
779 | &cpu, &loop, &interval,&err_type_info_conf, | ||
780 | &err_struct_info_conf); | ||
781 | if (count!=PARA_FIELD_NUM) | ||
782 | continue; | ||
783 | } | ||
784 | |||
785 | parameters[num].cpu=cpu; | ||
786 | parameters[num].loop=loop; | ||
787 | parameters[num].interval= interval>MIN_INTERVAL | ||
788 | ?interval:MIN_INTERVAL; | ||
789 | parameters[num].err_type_info=err_type_info_conf; | ||
790 | parameters[num].err_struct_info=err_struct_info_conf; | ||
791 | memcpy(parameters[num++].err_data_buffer, | ||
792 | err_data_buffer_conf,ERR_DATA_BUFFER_SIZE*8) ; | ||
793 | |||
794 | if (num>=MAX_TASK_NUM) | ||
795 | break; | ||
796 | } | ||
797 | } | ||
798 | else { | ||
799 | parameters[0].cpu=line_para.cpu; | ||
800 | parameters[0].loop=line_para.loop; | ||
801 | parameters[0].interval= line_para.interval>MIN_INTERVAL | ||
802 | ?line_para.interval:MIN_INTERVAL; | ||
803 | parameters[0].err_type_info=line_para.err_type_info; | ||
804 | parameters[0].err_struct_info=line_para.err_struct_info; | ||
805 | memcpy(parameters[0].err_data_buffer, | ||
806 | line_para.err_data_buffer,ERR_DATA_BUFFER_SIZE*8) ; | ||
807 | |||
808 | num=1; | ||
809 | } | ||
810 | |||
811 | /* Create semaphore: If one_lock, one semaphore for all processors. | ||
812 | Otherwise, one sempaphore for each processor. */ | ||
813 | if (one_lock) { | ||
814 | if (create_sem(0)) { | ||
815 | printf("Can not create semaphore...exit\n"); | ||
816 | free_sem(0); | ||
817 | return -1; | ||
818 | } | ||
819 | } | ||
820 | else { | ||
821 | for (i=0;i<num;i++) { | ||
822 | if (create_sem(parameters[i].cpu)) { | ||
823 | printf("Can not create semaphore for cpu%d...exit\n",i); | ||
824 | free_sem(parameters[num].cpu); | ||
825 | return -1; | ||
826 | } | ||
827 | } | ||
828 | } | ||
829 | |||
830 | /* Create a shm segment which will be used to inject/consume errors on.*/ | ||
831 | if (create_shm()==-1) { | ||
832 | printf("Error to create shm...exit\n"); | ||
833 | return -1; | ||
834 | } | ||
835 | |||
836 | for (i=0;i<num;i++) { | ||
837 | pid_t pid; | ||
838 | |||
839 | current_time=time(NULL); | ||
840 | log_info(parameters[i].cpu, "\nBegine at %s", ctime(¤t_time)); | ||
841 | log_info(parameters[i].cpu, "Configurations:\n"); | ||
842 | log_info(parameters[i].cpu,"On cpu%ld: loop=%lx, interval=%lx(s)", | ||
843 | parameters[i].cpu, | ||
844 | parameters[i].loop, | ||
845 | parameters[i].interval); | ||
846 | log_info(parameters[i].cpu," err_type_info=%lx,err_struct_info=%lx\n", | ||
847 | parameters[i].err_type_info, | ||
848 | parameters[i].err_struct_info); | ||
849 | |||
850 | sprintf(path, PATH_FORMAT, (int)parameters[i].cpu); | ||
851 | err_type_info.err_type_info=parameters[i].err_type_info; | ||
852 | err_struct_info.err_struct_info=parameters[i].err_struct_info; | ||
853 | memcpy(err_data_buffer.err_data_buffer, | ||
854 | parameters[i].err_data_buffer, | ||
855 | ERR_DATA_BUFFER_SIZE*8); | ||
856 | |||
857 | pid=fork(); | ||
858 | if (pid==0) { | ||
859 | unsigned long mask[MASK_SIZE]; | ||
860 | int j, k; | ||
861 | |||
862 | void *va1, *va2; | ||
863 | |||
864 | /* Allocate two memory areas va1 and va2 in shm */ | ||
865 | va1=shmaddr+parameters[i].cpu*PAGE_SIZE; | ||
866 | va2=shmaddr+parameters[i].cpu*PAGE_SIZE+PAGE_SIZE; | ||
867 | |||
868 | vbprintf("va1=%lx, va2=%lx\n", (u64)va1, (u64)va2); | ||
869 | memset(va1, 0x1, PAGE_SIZE); | ||
870 | memset(va2, 0x2, PAGE_SIZE); | ||
871 | |||
872 | if (empty_data_buffer(err_data_buffer.err_data_buffer)) | ||
873 | /* If not specified yet, construct data buffer | ||
874 | * with va1 | ||
875 | */ | ||
876 | construct_data_buf(path, err_type_info, | ||
877 | err_struct_info, &err_data_buffer,va1); | ||
878 | |||
879 | for (j=0;j<MASK_SIZE;j++) | ||
880 | mask[j]=0; | ||
881 | |||
882 | cpu=parameters[i].cpu; | ||
883 | k = cpu%64; | ||
884 | j = cpu/64; | ||
885 | mask[j]=1<<k; | ||
886 | |||
887 | if (sched_setaffinity(0, MASK_SIZE*8, mask)==-1) { | ||
888 | perror("Error sched_setaffinity:"); | ||
889 | return -1; | ||
890 | } | ||
891 | |||
892 | for (j=0; j<parameters[i].loop; j++) { | ||
893 | log_info(parameters[i].cpu,"Injection "); | ||
894 | log_info(parameters[i].cpu,"on cpu%ld: #%d/%ld ", | ||
895 | |||
896 | parameters[i].cpu,j+1, parameters[i].loop); | ||
897 | |||
898 | /* Hold the lock */ | ||
899 | if (one_lock) | ||
900 | lock(0); | ||
901 | else | ||
902 | /* Hold lock on this cpu */ | ||
903 | lock(parameters[i].cpu); | ||
904 | |||
905 | if ((status=err_inject(parameters[i].cpu, | ||
906 | path, err_type_info, | ||
907 | err_struct_info, err_data_buffer)) | ||
908 | ==0) { | ||
909 | /* consume the error for "inject only"*/ | ||
910 | memcpy(va2, va1, PAGE_SIZE); | ||
911 | memcpy(va1, va2, PAGE_SIZE); | ||
912 | log_info(parameters[i].cpu, | ||
913 | "successful\n"); | ||
914 | } | ||
915 | else { | ||
916 | log_info(parameters[i].cpu,"fail:"); | ||
917 | log_info(parameters[i].cpu, | ||
918 | "status=%d\n", status); | ||
919 | unlock(parameters[i].cpu); | ||
920 | break; | ||
921 | } | ||
922 | if (one_lock) | ||
923 | /* Release the lock */ | ||
924 | unlock(0); | ||
925 | /* Release lock on this cpu */ | ||
926 | else | ||
927 | unlock(parameters[i].cpu); | ||
928 | |||
929 | if (j < parameters[i].loop-1) | ||
930 | sleep(parameters[i].interval); | ||
931 | } | ||
932 | current_time=time(NULL); | ||
933 | log_info(parameters[i].cpu, "Done at %s", ctime(¤t_time)); | ||
934 | return 0; | ||
935 | } | ||
936 | else if (pid<0) { | ||
937 | perror("Error fork:"); | ||
938 | continue; | ||
939 | } | ||
940 | child_pid[i]=pid; | ||
941 | } | ||
942 | for (i=0;i<num;i++) | ||
943 | waitpid(child_pid[i], NULL, 0); | ||
944 | |||
945 | if (one_lock) | ||
946 | free_sem(0); | ||
947 | else | ||
948 | for (i=0;i<num;i++) | ||
949 | free_sem(parameters[i].cpu); | ||
950 | |||
951 | printf("All done.\n"); | ||
952 | |||
953 | return 0; | ||
954 | } | ||
955 | |||
956 | void help() | ||
957 | { | ||
958 | printf("err_inject_tool:\n"); | ||
959 | printf("\t-q: query all capabilities. default: off\n"); | ||
960 | printf("\t-m: procedure mode. 1: physical 2: virtual. default: 1\n"); | ||
961 | printf("\t-i: inject errors. default: off\n"); | ||
962 | printf("\t-l: one lock per cpu. default: one lock for all\n"); | ||
963 | printf("\t-e: error parameters:\n"); | ||
964 | printf("\t\tcpu,loop,interval,err_type_info,err_struct_info[,err_data_buffer[0],err_data_buffer[1],err_data_buffer[2]]\n"); | ||
965 | printf("\t\t cpu: logical cpu number the error will be inject in.\n"); | ||
966 | printf("\t\t loop: times the error will be injected.\n"); | ||
967 | printf("\t\t interval: In second. every so often one error is injected.\n"); | ||
968 | printf("\t\t err_type_info, err_struct_info: PAL parameters.\n"); | ||
969 | printf("\t\t err_data_buffer: PAL parameter. Optional. If not present,\n"); | ||
970 | printf("\t\t it's constructed by tool automatically. Be\n"); | ||
971 | printf("\t\t careful to provide err_data_buffer and make\n"); | ||
972 | printf("\t\t sure it's working with the environment.\n"); | ||
973 | printf("\t Note:no space between error parameters.\n"); | ||
974 | printf("\t default: Take error parameters from err.conf instead of command line.\n"); | ||
975 | printf("\t-v: verbose. default: off\n"); | ||
976 | printf("\t-h: help\n\n"); | ||
977 | printf("The tool will take err.conf file as "); | ||
978 | printf("input to inject single or multiple errors "); | ||
979 | printf("on one or multiple cpus in parallel.\n"); | ||
980 | } | ||
981 | |||
982 | int main(int argc, char **argv) | ||
983 | { | ||
984 | char c; | ||
985 | int do_err_inj=0; | ||
986 | int do_query_all=0; | ||
987 | int count; | ||
988 | u32 m; | ||
989 | |||
990 | /* Default one lock for all cpu's */ | ||
991 | one_lock=1; | ||
992 | while ((c = getopt(argc, argv, "m:iqvhle:")) != EOF) | ||
993 | switch (c) { | ||
994 | case 'm': /* Procedure mode. 1: phys 2: virt */ | ||
995 | count=sscanf(optarg, "%x", &m); | ||
996 | if (count!=1 || (m!=1 && m!=2)) { | ||
997 | printf("Wrong mode number.\n"); | ||
998 | help(); | ||
999 | return -1; | ||
1000 | } | ||
1001 | mode=m; | ||
1002 | break; | ||
1003 | case 'i': /* Inject errors */ | ||
1004 | do_err_inj=1; | ||
1005 | break; | ||
1006 | case 'q': /* Query */ | ||
1007 | do_query_all=1; | ||
1008 | break; | ||
1009 | case 'v': /* Verbose */ | ||
1010 | verbose=1; | ||
1011 | break; | ||
1012 | case 'l': /* One lock per cpu */ | ||
1013 | one_lock=0; | ||
1014 | break; | ||
1015 | case 'e': /* error arguments */ | ||
1016 | /* Take parameters: | ||
1017 | * #cpu, loop, interval, err_type_info, err_struct_info[, err_data_buffer] | ||
1018 | * err_data_buffer is optional. Recommend not to specify | ||
1019 | * err_data_buffer. Better to use tool to generate it. | ||
1020 | */ | ||
1021 | count=sscanf(optarg, | ||
1022 | "%lx, %lx, %lx, %lx, %lx, %lx, %lx, %lx\n", | ||
1023 | &line_para.cpu, | ||
1024 | &line_para.loop, | ||
1025 | &line_para.interval, | ||
1026 | &line_para.err_type_info, | ||
1027 | &line_para.err_struct_info, | ||
1028 | &line_para.err_data_buffer[0], | ||
1029 | &line_para.err_data_buffer[1], | ||
1030 | &line_para.err_data_buffer[2]); | ||
1031 | if (count!=PARA_FIELD_NUM+3) { | ||
1032 | line_para.err_data_buffer[0]=-1, | ||
1033 | line_para.err_data_buffer[1]=-1, | ||
1034 | line_para.err_data_buffer[2]=-1; | ||
1035 | count=sscanf(optarg, "%lx, %lx, %lx, %lx, %lx\n", | ||
1036 | &line_para.cpu, | ||
1037 | &line_para.loop, | ||
1038 | &line_para.interval, | ||
1039 | &line_para.err_type_info, | ||
1040 | &line_para.err_struct_info); | ||
1041 | if (count!=PARA_FIELD_NUM) { | ||
1042 | printf("Wrong error arguments.\n"); | ||
1043 | help(); | ||
1044 | return -1; | ||
1045 | } | ||
1046 | } | ||
1047 | para=1; | ||
1048 | break; | ||
1049 | continue; | ||
1050 | break; | ||
1051 | case 'h': | ||
1052 | help(); | ||
1053 | return 0; | ||
1054 | default: | ||
1055 | break; | ||
1056 | } | ||
1057 | |||
1058 | if (do_query_all) | ||
1059 | query_all_capabilities(); | ||
1060 | if (do_err_inj) | ||
1061 | err_inj(); | ||
1062 | |||
1063 | if (!do_query_all && !do_err_inj) | ||
1064 | help(); | ||
1065 | |||
1066 | return 0; | ||
1067 | } | ||
1068 | |||
diff --git a/Documentation/ioctl-number.txt b/Documentation/ioctl-number.txt index 8f750c0efed5..3de7d379cf07 100644 --- a/Documentation/ioctl-number.txt +++ b/Documentation/ioctl-number.txt | |||
@@ -138,7 +138,8 @@ Code Seq# Include File Comments | |||
138 | 'm' 00-1F net/irda/irmod.h conflict! | 138 | 'm' 00-1F net/irda/irmod.h conflict! |
139 | 'n' 00-7F linux/ncp_fs.h | 139 | 'n' 00-7F linux/ncp_fs.h |
140 | 'n' E0-FF video/matrox.h matroxfb | 140 | 'n' E0-FF video/matrox.h matroxfb |
141 | 'p' 00-3F linux/mc146818rtc.h | 141 | 'p' 00-0F linux/phantom.h conflict! (OpenHaptics needs this) |
142 | 'p' 00-3F linux/mc146818rtc.h conflict! | ||
142 | 'p' 40-7F linux/nvram.h | 143 | 'p' 40-7F linux/nvram.h |
143 | 'p' 80-9F user-space parport | 144 | 'p' 80-9F user-space parport |
144 | <mailto:tim@cyberelk.net> | 145 | <mailto:tim@cyberelk.net> |
diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt index 769ee05ee4d1..1d247d59ad56 100644 --- a/Documentation/kbuild/modules.txt +++ b/Documentation/kbuild/modules.txt | |||
@@ -249,7 +249,7 @@ following files: | |||
249 | --> filename: Makefile | 249 | --> filename: Makefile |
250 | KERNELDIR := /lib/modules/`uname -r`/build | 250 | KERNELDIR := /lib/modules/`uname -r`/build |
251 | all:: | 251 | all:: |
252 | $(MAKE) -C $KERNELDIR M=`pwd` $@ | 252 | $(MAKE) -C $(KERNELDIR) M=`pwd` $@ |
253 | 253 | ||
254 | # Module specific targets | 254 | # Module specific targets |
255 | genbin: | 255 | genbin: |
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 38d7db3262c7..6b8ad06846c4 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -496,6 +496,30 @@ and is between 256 and 4096 characters. It is defined in the file | |||
496 | Format: <area>[,<node>] | 496 | Format: <area>[,<node>] |
497 | See also Documentation/networking/decnet.txt. | 497 | See also Documentation/networking/decnet.txt. |
498 | 498 | ||
499 | default_blu= [VT] | ||
500 | Format: <blue0>,<blue1>,<blue2>,...,<blue15> | ||
501 | Change the default blue palette of the console. | ||
502 | This is a 16-member array composed of values | ||
503 | ranging from 0-255. | ||
504 | |||
505 | default_grn= [VT] | ||
506 | Format: <green0>,<green1>,<green2>,...,<green15> | ||
507 | Change the default green palette of the console. | ||
508 | This is a 16-member array composed of values | ||
509 | ranging from 0-255. | ||
510 | |||
511 | default_red= [VT] | ||
512 | Format: <red0>,<red1>,<red2>,...,<red15> | ||
513 | Change the default red palette of the console. | ||
514 | This is a 16-member array composed of values | ||
515 | ranging from 0-255. | ||
516 | |||
517 | default_utf8= [VT] | ||
518 | Format=<0|1> | ||
519 | Set system-wide default UTF-8 mode for all tty's. | ||
520 | Default is 0 and by setting to 1, it enables UTF-8 | ||
521 | mode for all newly opened or allocated terminals. | ||
522 | |||
499 | dhash_entries= [KNL] | 523 | dhash_entries= [KNL] |
500 | Set number of hash buckets for dentry cache. | 524 | Set number of hash buckets for dentry cache. |
501 | 525 | ||
@@ -816,6 +840,11 @@ and is between 256 and 4096 characters. It is defined in the file | |||
816 | lasi= [HW,SCSI] PARISC LASI driver for the 53c700 chip | 840 | lasi= [HW,SCSI] PARISC LASI driver for the 53c700 chip |
817 | Format: addr:<io>,irq:<irq> | 841 | Format: addr:<io>,irq:<irq> |
818 | 842 | ||
843 | legacy_serial.force [HW,IA-32,X86-64] | ||
844 | Probe for COM ports at legacy addresses even | ||
845 | if PNPBIOS or ACPI should describe them. This | ||
846 | is for working around firmware defects. | ||
847 | |||
819 | llsc*= [IA64] See function print_params() in | 848 | llsc*= [IA64] See function print_params() in |
820 | arch/ia64/sn/kernel/llsc4.c. | 849 | arch/ia64/sn/kernel/llsc4.c. |
821 | 850 | ||
@@ -1578,6 +1607,17 @@ and is between 256 and 4096 characters. It is defined in the file | |||
1578 | smp-alt-once [IA-32,SMP] On a hotplug CPU system, only | 1607 | smp-alt-once [IA-32,SMP] On a hotplug CPU system, only |
1579 | attempt to substitute SMP alternatives once at boot. | 1608 | attempt to substitute SMP alternatives once at boot. |
1580 | 1609 | ||
1610 | smsc-ircc2.nopnp [HW] Don't use PNP to discover SMC devices | ||
1611 | smsc-ircc2.ircc_cfg= [HW] Device configuration I/O port | ||
1612 | smsc-ircc2.ircc_sir= [HW] SIR base I/O port | ||
1613 | smsc-ircc2.ircc_fir= [HW] FIR base I/O port | ||
1614 | smsc-ircc2.ircc_irq= [HW] IRQ line | ||
1615 | smsc-ircc2.ircc_dma= [HW] DMA channel | ||
1616 | smsc-ircc2.ircc_transceiver= [HW] Transceiver type: | ||
1617 | 0: Toshiba Satellite 1800 (GP data pin select) | ||
1618 | 1: Fast pin select (default) | ||
1619 | 2: ATC IRMode | ||
1620 | |||
1581 | snd-ad1816a= [HW,ALSA] | 1621 | snd-ad1816a= [HW,ALSA] |
1582 | 1622 | ||
1583 | snd-ad1848= [HW,ALSA] | 1623 | snd-ad1848= [HW,ALSA] |
diff --git a/Documentation/kprobes.txt b/Documentation/kprobes.txt index d71fafffce90..da5404ab7569 100644 --- a/Documentation/kprobes.txt +++ b/Documentation/kprobes.txt | |||
@@ -14,6 +14,7 @@ CONTENTS | |||
14 | 8. Kprobes Example | 14 | 8. Kprobes Example |
15 | 9. Jprobes Example | 15 | 9. Jprobes Example |
16 | 10. Kretprobes Example | 16 | 10. Kretprobes Example |
17 | Appendix A: The kprobes debugfs interface | ||
17 | 18 | ||
18 | 1. Concepts: Kprobes, Jprobes, Return Probes | 19 | 1. Concepts: Kprobes, Jprobes, Return Probes |
19 | 20 | ||
@@ -349,9 +350,12 @@ for instrumentation and error reporting.) | |||
349 | 350 | ||
350 | If the number of times a function is called does not match the number | 351 | If the number of times a function is called does not match the number |
351 | of times it returns, registering a return probe on that function may | 352 | of times it returns, registering a return probe on that function may |
352 | produce undesirable results. We have the do_exit() case covered. | 353 | produce undesirable results. In such a case, a line: |
353 | do_execve() and do_fork() are not an issue. We're unaware of other | 354 | kretprobe BUG!: Processing kretprobe d000000000041aa8 @ c00000000004f48c |
354 | specific cases where this could be a problem. | 355 | gets printed. With this information, one will be able to correlate the |
356 | exact instance of the kretprobe that caused the problem. We have the | ||
357 | do_exit() case covered. do_execve() and do_fork() are not an issue. | ||
358 | We're unaware of other specific cases where this could be a problem. | ||
355 | 359 | ||
356 | If, upon entry to or exit from a function, the CPU is running on | 360 | If, upon entry to or exit from a function, the CPU is running on |
357 | a stack other than that of the current task, registering a return | 361 | a stack other than that of the current task, registering a return |
@@ -614,3 +618,27 @@ http://www-106.ibm.com/developerworks/library/l-kprobes.html?ca=dgr-lnxw42Kprobe | |||
614 | http://www.redhat.com/magazine/005mar05/features/kprobes/ | 618 | http://www.redhat.com/magazine/005mar05/features/kprobes/ |
615 | http://www-users.cs.umn.edu/~boutcher/kprobes/ | 619 | http://www-users.cs.umn.edu/~boutcher/kprobes/ |
616 | http://www.linuxsymposium.org/2006/linuxsymposium_procv2.pdf (pages 101-115) | 620 | http://www.linuxsymposium.org/2006/linuxsymposium_procv2.pdf (pages 101-115) |
621 | |||
622 | |||
623 | Appendix A: The kprobes debugfs interface | ||
624 | |||
625 | With recent kernels (> 2.6.20) the list of registered kprobes is visible | ||
626 | under the /debug/kprobes/ directory (assuming debugfs is mounted at /debug). | ||
627 | |||
628 | /debug/kprobes/list: Lists all registered probes on the system | ||
629 | |||
630 | c015d71a k vfs_read+0x0 | ||
631 | c011a316 j do_fork+0x0 | ||
632 | c03dedc5 r tcp_v4_rcv+0x0 | ||
633 | |||
634 | The first column provides the kernel address where the probe is inserted. | ||
635 | The second column identifies the type of probe (k - kprobe, r - kretprobe | ||
636 | and j - jprobe), while the third column specifies the symbol+offset of | ||
637 | the probe. If the probed function belongs to a module, the module name | ||
638 | is also specified. | ||
639 | |||
640 | /debug/kprobes/enabled: Turn kprobes ON/OFF | ||
641 | |||
642 | Provides a knob to globally turn registered kprobes ON or OFF. By default, | ||
643 | all kprobes are enabled. By echoing "0" to this file, all registered probes | ||
644 | will be disarmed, till such time a "1" is echoed to this file. | ||
diff --git a/Documentation/laptop-mode.txt b/Documentation/laptop-mode.txt index 6f639e3473af..eeedee11c8c2 100644 --- a/Documentation/laptop-mode.txt +++ b/Documentation/laptop-mode.txt | |||
@@ -33,7 +33,7 @@ or anything. Simply install all the files included in this document, and | |||
33 | laptop mode will automatically be started when you're on battery. For | 33 | laptop mode will automatically be started when you're on battery. For |
34 | your convenience, a tarball containing an installer can be downloaded at: | 34 | your convenience, a tarball containing an installer can be downloaded at: |
35 | 35 | ||
36 | http://www.xs4all.nl/~bsamwel/laptop_mode/tools/ | 36 | http://www.samwel.tk/laptop_mode/laptop_mode/ |
37 | 37 | ||
38 | To configure laptop mode, you need to edit the configuration file, which is | 38 | To configure laptop mode, you need to edit the configuration file, which is |
39 | located in /etc/default/laptop-mode on Debian-based systems, or in | 39 | located in /etc/default/laptop-mode on Debian-based systems, or in |
diff --git a/Documentation/oops-tracing.txt b/Documentation/oops-tracing.txt index ea55ea8bc8ef..7d5b60dea551 100644 --- a/Documentation/oops-tracing.txt +++ b/Documentation/oops-tracing.txt | |||
@@ -234,9 +234,6 @@ characters, each representing a particular tainted value. | |||
234 | 6: 'B' if a page-release function has found a bad page reference or | 234 | 6: 'B' if a page-release function has found a bad page reference or |
235 | some unexpected page flags. | 235 | some unexpected page flags. |
236 | 236 | ||
237 | 7: 'U' if a user specifically requested that the Tainted flag be set, | ||
238 | ' ' otherwise. | ||
239 | |||
240 | 7: 'U' if a user or user application specifically requested that the | 237 | 7: 'U' if a user or user application specifically requested that the |
241 | Tainted flag be set, ' ' otherwise. | 238 | Tainted flag be set, ' ' otherwise. |
242 | 239 | ||
diff --git a/Documentation/pcmcia/driver.txt b/Documentation/pcmcia/driver.txt new file mode 100644 index 000000000000..0ac167920778 --- /dev/null +++ b/Documentation/pcmcia/driver.txt | |||
@@ -0,0 +1,30 @@ | |||
1 | PCMCIA Driver | ||
2 | ------------- | ||
3 | |||
4 | |||
5 | sysfs | ||
6 | ----- | ||
7 | |||
8 | New PCMCIA IDs may be added to a device driver pcmcia_device_id table at | ||
9 | runtime as shown below: | ||
10 | |||
11 | echo "match_flags manf_id card_id func_id function device_no \ | ||
12 | prod_id_hash[0] prod_id_hash[1] prod_id_hash[2] prod_id_hash[3]" > \ | ||
13 | /sys/bus/pcmcia/drivers/{driver}/new_id | ||
14 | |||
15 | All fields are passed in as hexadecimal values (no leading 0x). | ||
16 | The meaning is described in the PCMCIA specification, the match_flags is | ||
17 | a bitwise or-ed combination from PCMCIA_DEV_ID_MATCH_* constants | ||
18 | defined in include/linux/mod_devicetable.h. | ||
19 | |||
20 | Once added, the driver probe routine will be invoked for any unclaimed | ||
21 | PCMCIA device listed in its (newly updated) pcmcia_device_id list. | ||
22 | |||
23 | A common use-case is to add a new device according to the manufacturer ID | ||
24 | and the card ID (form the manf_id and card_id file in the device tree). | ||
25 | For this, just use: | ||
26 | |||
27 | echo "0x3 manf_id card_id 0 0 0 0 0 0 0" > \ | ||
28 | /sys/bus/pcmcia/drivers/{driver}/new_id | ||
29 | |||
30 | after loading the driver. | ||
diff --git a/Documentation/power/basic-pm-debugging.txt b/Documentation/power/basic-pm-debugging.txt new file mode 100644 index 000000000000..1a85e2b964dc --- /dev/null +++ b/Documentation/power/basic-pm-debugging.txt | |||
@@ -0,0 +1,106 @@ | |||
1 | Debugging suspend and resume | ||
2 | (C) 2007 Rafael J. Wysocki <rjw@sisk.pl>, GPL | ||
3 | |||
4 | 1. Testing suspend to disk (STD) | ||
5 | |||
6 | To verify that the STD works, you can try to suspend in the "reboot" mode: | ||
7 | |||
8 | # echo reboot > /sys/power/disk | ||
9 | # echo disk > /sys/power/state | ||
10 | |||
11 | and the system should suspend, reboot, resume and get back to the command prompt | ||
12 | where you have started the transition. If that happens, the STD is most likely | ||
13 | to work correctly, but you need to repeat the test at least a couple of times in | ||
14 | a row for confidence. This is necessary, because some problems only show up on | ||
15 | a second attempt at suspending and resuming the system. You should also test | ||
16 | the "platform" and "shutdown" modes of suspend: | ||
17 | |||
18 | # echo platform > /sys/power/disk | ||
19 | # echo disk > /sys/power/state | ||
20 | |||
21 | or | ||
22 | |||
23 | # echo shutdown > /sys/power/disk | ||
24 | # echo disk > /sys/power/state | ||
25 | |||
26 | in which cases you will have to press the power button to make the system | ||
27 | resume. If that does not work, you will need to identify what goes wrong. | ||
28 | |||
29 | a) Test mode of STD | ||
30 | |||
31 | To verify if there are any drivers that cause problems you can run the STD | ||
32 | in the test mode: | ||
33 | |||
34 | # echo test > /sys/power/disk | ||
35 | # echo disk > /sys/power/state | ||
36 | |||
37 | in which case the system should freeze tasks, suspend devices, disable nonboot | ||
38 | CPUs (if any), wait for 5 seconds, enable nonboot CPUs, resume devices, thaw | ||
39 | tasks and return to your command prompt. If that fails, most likely there is | ||
40 | a driver that fails to either suspend or resume (in the latter case the system | ||
41 | may hang or be unstable after the test, so please take that into consideration). | ||
42 | To find this driver, you can carry out a binary search according to the rules: | ||
43 | - if the test fails, unload a half of the drivers currently loaded and repeat | ||
44 | (that would probably involve rebooting the system, so always note what drivers | ||
45 | have been loaded before the test), | ||
46 | - if the test succeeds, load a half of the drivers you have unloaded most | ||
47 | recently and repeat. | ||
48 | |||
49 | Once you have found the failing driver (there can be more than just one of | ||
50 | them), you have to unload it every time before the STD transition. In that case | ||
51 | please make sure to report the problem with the driver. | ||
52 | |||
53 | It is also possible that a cycle can still fail after you have unloaded | ||
54 | all modules. In that case, you would want to look in your kernel configuration | ||
55 | for the drivers that can be compiled as modules (testing again with them as | ||
56 | modules), and possibly also try boot time options such as "noapic" or "noacpi". | ||
57 | |||
58 | b) Testing minimal configuration | ||
59 | |||
60 | If the test mode of STD works, you can boot the system with "init=/bin/bash" | ||
61 | and attempt to suspend in the "reboot", "shutdown" and "platform" modes. If | ||
62 | that does not work, there probably is a problem with a driver statically | ||
63 | compiled into the kernel and you can try to compile more drivers as modules, | ||
64 | so that they can be tested individually. Otherwise, there is a problem with a | ||
65 | modular driver and you can find it by loading a half of the modules you normally | ||
66 | use and binary searching in accordance with the algorithm: | ||
67 | - if there are n modules loaded and the attempt to suspend and resume fails, | ||
68 | unload n/2 of the modules and try again (that would probably involve rebooting | ||
69 | the system), | ||
70 | - if there are n modules loaded and the attempt to suspend and resume succeeds, | ||
71 | load n/2 modules more and try again. | ||
72 | |||
73 | Again, if you find the offending module(s), it(they) must be unloaded every time | ||
74 | before the STD transition, and please report the problem with it(them). | ||
75 | |||
76 | c) Advanced debugging | ||
77 | |||
78 | In case the STD does not work on your system even in the minimal configuration | ||
79 | and compiling more drivers as modules is not practical or some modules cannot | ||
80 | be unloaded, you can use one of the more advanced debugging techniques to find | ||
81 | the problem. First, if there is a serial port in your box, you can set the | ||
82 | CONFIG_DISABLE_CONSOLE_SUSPEND kernel configuration option and try to log kernel | ||
83 | messages using the serial console. This may provide you with some information | ||
84 | about the reasons of the suspend (resume) failure. Alternatively, it may be | ||
85 | possible to use a FireWire port for debugging with firescope | ||
86 | (ftp://ftp.firstfloor.org/pub/ak/firescope/). On i386 it is also possible to | ||
87 | use the PM_TRACE mechanism documented in Documentation/s2ram.txt . | ||
88 | |||
89 | 2. Testing suspend to RAM (STR) | ||
90 | |||
91 | To verify that the STR works, it is generally more convenient to use the s2ram | ||
92 | tool available from http://suspend.sf.net and documented at | ||
93 | http://en.opensuse.org/s2ram . However, before doing that it is recommended to | ||
94 | carry out the procedure described in section 1. | ||
95 | |||
96 | Assume you have resolved the problems with the STD and you have found some | ||
97 | failing drivers. These drivers are also likely to fail during the STR or | ||
98 | during the resume, so it is better to unload them every time before the STR | ||
99 | transition. Now, you can follow the instructions at | ||
100 | http://en.opensuse.org/s2ram to test the system, but if it does not work | ||
101 | "out of the box", you may need to boot it with "init=/bin/bash" and test | ||
102 | s2ram in the minimal configuration. In that case, you may be able to search | ||
103 | for failing drivers by following the procedure analogous to the one described in | ||
104 | 1b). If you find some failing drivers, you will have to unload them every time | ||
105 | before the STR transition (ie. before you run s2ram), and please report the | ||
106 | problems with them. | ||
diff --git a/Documentation/power/drivers-testing.txt b/Documentation/power/drivers-testing.txt new file mode 100644 index 000000000000..33016c2f18dd --- /dev/null +++ b/Documentation/power/drivers-testing.txt | |||
@@ -0,0 +1,42 @@ | |||
1 | Testing suspend and resume support in device drivers | ||
2 | (C) 2007 Rafael J. Wysocki <rjw@sisk.pl>, GPL | ||
3 | |||
4 | 1. Preparing the test system | ||
5 | |||
6 | Unfortunately, to effectively test the support for the system-wide suspend and | ||
7 | resume transitions in a driver, it is necessary to suspend and resume a fully | ||
8 | functional system with this driver loaded. Moreover, that should be done | ||
9 | several times, preferably several times in a row, and separately for the suspend | ||
10 | to disk (STD) and the suspend to RAM (STR) transitions, because each of these | ||
11 | cases involves different ordering of operations and different interactions with | ||
12 | the machine's BIOS. | ||
13 | |||
14 | Of course, for this purpose the test system has to be known to suspend and | ||
15 | resume without the driver being tested. Thus, if possible, you should first | ||
16 | resolve all suspend/resume-related problems in the test system before you start | ||
17 | testing the new driver. Please see Documents/power/basic-pm-debugging.txt for | ||
18 | more information about the debugging of suspend/resume functionality. | ||
19 | |||
20 | 2. Testing the driver | ||
21 | |||
22 | Once you have resolved the suspend/resume-related problems with your test system | ||
23 | without the new driver, you are ready to test it: | ||
24 | |||
25 | a) Build the driver as a module, load it and try the STD in the test mode (see: | ||
26 | Documents/power/basic-pm-debugging.txt, 1a)). | ||
27 | |||
28 | b) Load the driver and attempt to suspend to disk in the "reboot", "shutdown" | ||
29 | and "platform" modes (see: Documents/power/basic-pm-debugging.txt, 1). | ||
30 | |||
31 | c) Compile the driver directly into the kernel and try the STD in the test mode. | ||
32 | |||
33 | d) Attempt to suspend to disk with the driver compiled directly into the kernel | ||
34 | in the "reboot", "shutdown" and "platform" modes. | ||
35 | |||
36 | e) Attempt to suspend to RAM using the s2ram tool with the driver loaded (see: | ||
37 | Documents/power/basic-pm-debugging.txt, 2). As far as the STR tests are | ||
38 | concerned, it should not matter whether or not the driver is built as a module. | ||
39 | |||
40 | Each of the above tests should be repeated several times and the STD tests | ||
41 | should be mixed with the STR tests. If any of them fails, the driver cannot be | ||
42 | regarded as suspend/resume-safe. | ||
diff --git a/Documentation/power/interface.txt b/Documentation/power/interface.txt index 8c5b41bf3f36..fd5192a8fa8a 100644 --- a/Documentation/power/interface.txt +++ b/Documentation/power/interface.txt | |||
@@ -34,8 +34,12 @@ for 5 seconds, resume devices, unfreeze tasks and enable nonboot CPUs. Then, | |||
34 | we are able to look in the log messages and work out, for example, which code | 34 | we are able to look in the log messages and work out, for example, which code |
35 | is being slow and which device drivers are misbehaving. | 35 | is being slow and which device drivers are misbehaving. |
36 | 36 | ||
37 | Reading from this file will display what the mode is currently set | 37 | Reading from this file will display all supported modes and the currently |
38 | to. Writing to this file will accept one of | 38 | selected one in brackets, for example |
39 | |||
40 | [shutdown] reboot test testproc | ||
41 | |||
42 | Writing to this file will accept one of | ||
39 | 43 | ||
40 | 'platform' (only if the platform supports it) | 44 | 'platform' (only if the platform supports it) |
41 | 'shutdown' | 45 | 'shutdown' |
diff --git a/Documentation/powerpc/booting-without-of.txt b/Documentation/powerpc/booting-without-of.txt index 033a3f3b3ab7..d4bfae75c946 100644 --- a/Documentation/powerpc/booting-without-of.txt +++ b/Documentation/powerpc/booting-without-of.txt | |||
@@ -1560,6 +1560,9 @@ platforms are moved over to use the flattened-device-tree model. | |||
1560 | network device. This is used by the bootwrapper to interpret | 1560 | network device. This is used by the bootwrapper to interpret |
1561 | MAC addresses passed by the firmware when no information other | 1561 | MAC addresses passed by the firmware when no information other |
1562 | than indices is available to associate an address with a device. | 1562 | than indices is available to associate an address with a device. |
1563 | - phy-connection-type : a string naming the controller/PHY interface type, | ||
1564 | i.e., "mii" (default), "rmii", "gmii", "rgmii", "rgmii-id", "tbi", | ||
1565 | or "rtbi". | ||
1563 | 1566 | ||
1564 | Example: | 1567 | Example: |
1565 | ucc@2000 { | 1568 | ucc@2000 { |
@@ -1574,6 +1577,7 @@ platforms are moved over to use the flattened-device-tree model. | |||
1574 | rx-clock = "none"; | 1577 | rx-clock = "none"; |
1575 | tx-clock = "clk9"; | 1578 | tx-clock = "clk9"; |
1576 | phy-handle = <212000>; | 1579 | phy-handle = <212000>; |
1580 | phy-connection-type = "gmii"; | ||
1577 | pio-handle = <140001>; | 1581 | pio-handle = <140001>; |
1578 | }; | 1582 | }; |
1579 | 1583 | ||
diff --git a/Documentation/rtc.txt b/Documentation/rtc.txt index 1ef6bb88cd00..7c701b88d6d5 100644 --- a/Documentation/rtc.txt +++ b/Documentation/rtc.txt | |||
@@ -147,7 +147,7 @@ RTC class framework, but can't be supported by the older driver. | |||
147 | 147 | ||
148 | * RTC_AIE_ON, RTC_AIE_OFF, RTC_ALM_SET, RTC_ALM_READ ... when the RTC | 148 | * RTC_AIE_ON, RTC_AIE_OFF, RTC_ALM_SET, RTC_ALM_READ ... when the RTC |
149 | is connected to an IRQ line, it can often issue an alarm IRQ up to | 149 | is connected to an IRQ line, it can often issue an alarm IRQ up to |
150 | 24 hours in the future. | 150 | 24 hours in the future. (Use RTC_WKALM_* by preference.) |
151 | 151 | ||
152 | * RTC_WKALM_SET, RTC_WKALM_RD ... RTCs that can issue alarms beyond | 152 | * RTC_WKALM_SET, RTC_WKALM_RD ... RTCs that can issue alarms beyond |
153 | the next 24 hours use a slightly more powerful API, which supports | 153 | the next 24 hours use a slightly more powerful API, which supports |
@@ -175,10 +175,7 @@ driver returns ENOIOCTLCMD. Some common examples: | |||
175 | called with appropriate values. | 175 | called with appropriate values. |
176 | 176 | ||
177 | * RTC_ALM_SET, RTC_ALM_READ, RTC_WKALM_SET, RTC_WKALM_RD: the | 177 | * RTC_ALM_SET, RTC_ALM_READ, RTC_WKALM_SET, RTC_WKALM_RD: the |
178 | set_alarm/read_alarm functions will be called. To differentiate | 178 | set_alarm/read_alarm functions will be called. |
179 | between the ALM and WKALM, check the larger fields of the rtc_wkalrm | ||
180 | struct (like tm_year). These will be set to -1 when using ALM and | ||
181 | will be set to proper values when using WKALM. | ||
182 | 179 | ||
183 | * RTC_IRQP_SET, RTC_IRQP_READ: the irq_set_freq function will be called | 180 | * RTC_IRQP_SET, RTC_IRQP_READ: the irq_set_freq function will be called |
184 | to set the frequency while the framework will handle the read for you | 181 | to set the frequency while the framework will handle the read for you |
diff --git a/Documentation/sh/clk.txt b/Documentation/sh/clk.txt new file mode 100644 index 000000000000..9aef710e9a4b --- /dev/null +++ b/Documentation/sh/clk.txt | |||
@@ -0,0 +1,32 @@ | |||
1 | Clock framework on SuperH architecture | ||
2 | |||
3 | The framework on SH extends existing API by the function clk_set_rate_ex, | ||
4 | which prototype is as follows: | ||
5 | |||
6 | clk_set_rate_ex (struct clk *clk, unsigned long rate, int algo_id) | ||
7 | |||
8 | The algo_id parameter is used to specify algorithm used to recalculate clocks, | ||
9 | adjanced to clock, specified as first argument. It is assumed that algo_id==0 | ||
10 | means no changes to adjanced clock | ||
11 | |||
12 | Internally, the clk_set_rate_ex forwards request to clk->ops->set_rate method, | ||
13 | if it is present in ops structure. The method should set the clock rate and adjust | ||
14 | all needed clocks according to the passed algo_id. | ||
15 | Exact values for algo_id are machine-dependend. For the sh7722, the following | ||
16 | values are defined: | ||
17 | |||
18 | NO_CHANGE = 0, | ||
19 | IUS_N1_N1, /* I:U = N:1, U:Sh = N:1 */ | ||
20 | IUS_322, /* I:U:Sh = 3:2:2 */ | ||
21 | IUS_522, /* I:U:Sh = 5:2:2 */ | ||
22 | IUS_N11, /* I:U:Sh = N:1:1 */ | ||
23 | SB_N1, /* Sh:B = N:1 */ | ||
24 | SB3_N1, /* Sh:B3 = N:1 */ | ||
25 | SB3_32, /* Sh:B3 = 3:2 */ | ||
26 | SB3_43, /* Sh:B3 = 4:3 */ | ||
27 | SB3_54, /* Sh:B3 = 5:4 */ | ||
28 | BP_N1, /* B:P = N:1 */ | ||
29 | IP_N1 /* I:P = N:1 */ | ||
30 | |||
31 | Each of these constants means relation between clocks that can be set via the FRQCR | ||
32 | register | ||
diff --git a/Documentation/spi/pxa2xx b/Documentation/spi/pxa2xx index f9717fe9bd85..215e3b8e7266 100644 --- a/Documentation/spi/pxa2xx +++ b/Documentation/spi/pxa2xx | |||
@@ -62,7 +62,7 @@ static struct resource pxa_spi_nssp_resources[] = { | |||
62 | 62 | ||
63 | static struct pxa2xx_spi_master pxa_nssp_master_info = { | 63 | static struct pxa2xx_spi_master pxa_nssp_master_info = { |
64 | .ssp_type = PXA25x_NSSP, /* Type of SSP */ | 64 | .ssp_type = PXA25x_NSSP, /* Type of SSP */ |
65 | .clock_enable = CKEN9_NSSP, /* NSSP Peripheral clock */ | 65 | .clock_enable = CKEN_NSSP, /* NSSP Peripheral clock */ |
66 | .num_chipselect = 1, /* Matches the number of chips attached to NSSP */ | 66 | .num_chipselect = 1, /* Matches the number of chips attached to NSSP */ |
67 | .enable_dma = 1, /* Enables NSSP DMA */ | 67 | .enable_dma = 1, /* Enables NSSP DMA */ |
68 | }; | 68 | }; |
diff --git a/Documentation/spi/spi-summary b/Documentation/spi/spi-summary index ecc7c9eb9f29..795fbb48ffa7 100644 --- a/Documentation/spi/spi-summary +++ b/Documentation/spi/spi-summary | |||
@@ -8,7 +8,7 @@ What is SPI? | |||
8 | The "Serial Peripheral Interface" (SPI) is a synchronous four wire serial | 8 | The "Serial Peripheral Interface" (SPI) is a synchronous four wire serial |
9 | link used to connect microcontrollers to sensors, memory, and peripherals. | 9 | link used to connect microcontrollers to sensors, memory, and peripherals. |
10 | 10 | ||
11 | The three signal wires hold a clock (SCLK, often on the order of 10 MHz), | 11 | The three signal wires hold a clock (SCK, often on the order of 10 MHz), |
12 | and parallel data lines with "Master Out, Slave In" (MOSI) or "Master In, | 12 | and parallel data lines with "Master Out, Slave In" (MOSI) or "Master In, |
13 | Slave Out" (MISO) signals. (Other names are also used.) There are four | 13 | Slave Out" (MISO) signals. (Other names are also used.) There are four |
14 | clocking modes through which data is exchanged; mode-0 and mode-3 are most | 14 | clocking modes through which data is exchanged; mode-0 and mode-3 are most |
@@ -22,7 +22,7 @@ other signals, often including an interrupt to the master. | |||
22 | 22 | ||
23 | Unlike serial busses like USB or SMBUS, even low level protocols for | 23 | Unlike serial busses like USB or SMBUS, even low level protocols for |
24 | SPI slave functions are usually not interoperable between vendors | 24 | SPI slave functions are usually not interoperable between vendors |
25 | (except for cases like SPI memory chips). | 25 | (except for commodities like SPI memory chips). |
26 | 26 | ||
27 | - SPI may be used for request/response style device protocols, as with | 27 | - SPI may be used for request/response style device protocols, as with |
28 | touchscreen sensors and memory chips. | 28 | touchscreen sensors and memory chips. |
@@ -77,8 +77,9 @@ cards without needing a special purpose MMC/SD/SDIO controller. | |||
77 | How do these driver programming interfaces work? | 77 | How do these driver programming interfaces work? |
78 | ------------------------------------------------ | 78 | ------------------------------------------------ |
79 | The <linux/spi/spi.h> header file includes kerneldoc, as does the | 79 | The <linux/spi/spi.h> header file includes kerneldoc, as does the |
80 | main source code, and you should certainly read that. This is just | 80 | main source code, and you should certainly read that chapter of the |
81 | an overview, so you get the big picture before the details. | 81 | kernel API document. This is just an overview, so you get the big |
82 | picture before those details. | ||
82 | 83 | ||
83 | SPI requests always go into I/O queues. Requests for a given SPI device | 84 | SPI requests always go into I/O queues. Requests for a given SPI device |
84 | are always executed in FIFO order, and complete asynchronously through | 85 | are always executed in FIFO order, and complete asynchronously through |
@@ -88,7 +89,7 @@ a command and then reading its response. | |||
88 | 89 | ||
89 | There are two types of SPI driver, here called: | 90 | There are two types of SPI driver, here called: |
90 | 91 | ||
91 | Controller drivers ... these are often built in to System-On-Chip | 92 | Controller drivers ... controllers may be built in to System-On-Chip |
92 | processors, and often support both Master and Slave roles. | 93 | processors, and often support both Master and Slave roles. |
93 | These drivers touch hardware registers and may use DMA. | 94 | These drivers touch hardware registers and may use DMA. |
94 | Or they can be PIO bitbangers, needing just GPIO pins. | 95 | Or they can be PIO bitbangers, needing just GPIO pins. |
@@ -108,18 +109,18 @@ those two types of driver. At this writing, Linux has no slave side | |||
108 | programming interface. | 109 | programming interface. |
109 | 110 | ||
110 | There is a minimal core of SPI programming interfaces, focussing on | 111 | There is a minimal core of SPI programming interfaces, focussing on |
111 | using driver model to connect controller and protocol drivers using | 112 | using the driver model to connect controller and protocol drivers using |
112 | device tables provided by board specific initialization code. SPI | 113 | device tables provided by board specific initialization code. SPI |
113 | shows up in sysfs in several locations: | 114 | shows up in sysfs in several locations: |
114 | 115 | ||
115 | /sys/devices/.../CTLR/spiB.C ... spi_device for on bus "B", | 116 | /sys/devices/.../CTLR/spiB.C ... spi_device on bus "B", |
116 | chipselect C, accessed through CTLR. | 117 | chipselect C, accessed through CTLR. |
117 | 118 | ||
118 | /sys/devices/.../CTLR/spiB.C/modalias ... identifies the driver | 119 | /sys/devices/.../CTLR/spiB.C/modalias ... identifies the driver |
119 | that should be used with this device (for hotplug/coldplug) | 120 | that should be used with this device (for hotplug/coldplug) |
120 | 121 | ||
121 | /sys/bus/spi/devices/spiB.C ... symlink to the physical | 122 | /sys/bus/spi/devices/spiB.C ... symlink to the physical |
122 | spiB-C device | 123 | spiB.C device |
123 | 124 | ||
124 | /sys/bus/spi/drivers/D ... driver for one or more spi*.* devices | 125 | /sys/bus/spi/drivers/D ... driver for one or more spi*.* devices |
125 | 126 | ||
@@ -240,7 +241,7 @@ The board_info should provide enough information to let the system work | |||
240 | without the chip's driver being loaded. The most troublesome aspect of | 241 | without the chip's driver being loaded. The most troublesome aspect of |
241 | that is likely the SPI_CS_HIGH bit in the spi_device.mode field, since | 242 | that is likely the SPI_CS_HIGH bit in the spi_device.mode field, since |
242 | sharing a bus with a device that interprets chipselect "backwards" is | 243 | sharing a bus with a device that interprets chipselect "backwards" is |
243 | not possible. | 244 | not possible until the infrastructure knows how to deselect it. |
244 | 245 | ||
245 | Then your board initialization code would register that table with the SPI | 246 | Then your board initialization code would register that table with the SPI |
246 | infrastructure, so that it's available later when the SPI master controller | 247 | infrastructure, so that it's available later when the SPI master controller |
@@ -268,16 +269,14 @@ board info based on the board that was hotplugged. Of course, you'd later | |||
268 | call at least spi_unregister_device() when that board is removed. | 269 | call at least spi_unregister_device() when that board is removed. |
269 | 270 | ||
270 | When Linux includes support for MMC/SD/SDIO/DataFlash cards through SPI, those | 271 | When Linux includes support for MMC/SD/SDIO/DataFlash cards through SPI, those |
271 | configurations will also be dynamic. Fortunately, those devices all support | 272 | configurations will also be dynamic. Fortunately, such devices all support |
272 | basic device identification probes, so that support should hotplug normally. | 273 | basic device identification probes, so they should hotplug normally. |
273 | 274 | ||
274 | 275 | ||
275 | How do I write an "SPI Protocol Driver"? | 276 | How do I write an "SPI Protocol Driver"? |
276 | ---------------------------------------- | 277 | ---------------------------------------- |
277 | All SPI drivers are currently kernel drivers. A userspace driver API | 278 | Most SPI drivers are currently kernel drivers, but there's also support |
278 | would just be another kernel driver, probably offering some lowlevel | 279 | for userspace drivers. Here we talk only about kernel drivers. |
279 | access through aio_read(), aio_write(), and ioctl() calls and using the | ||
280 | standard userspace sysfs mechanisms to bind to a given SPI device. | ||
281 | 280 | ||
282 | SPI protocol drivers somewhat resemble platform device drivers: | 281 | SPI protocol drivers somewhat resemble platform device drivers: |
283 | 282 | ||
@@ -319,7 +318,8 @@ might look like this unless you're creating a class_device: | |||
319 | 318 | ||
320 | As soon as it enters probe(), the driver may issue I/O requests to | 319 | As soon as it enters probe(), the driver may issue I/O requests to |
321 | the SPI device using "struct spi_message". When remove() returns, | 320 | the SPI device using "struct spi_message". When remove() returns, |
322 | the driver guarantees that it won't submit any more such messages. | 321 | or after probe() fails, the driver guarantees that it won't submit |
322 | any more such messages. | ||
323 | 323 | ||
324 | - An spi_message is a sequence of protocol operations, executed | 324 | - An spi_message is a sequence of protocol operations, executed |
325 | as one atomic sequence. SPI driver controls include: | 325 | as one atomic sequence. SPI driver controls include: |
@@ -368,7 +368,8 @@ the driver guarantees that it won't submit any more such messages. | |||
368 | Some drivers may need to modify spi_device characteristics like the | 368 | Some drivers may need to modify spi_device characteristics like the |
369 | transfer mode, wordsize, or clock rate. This is done with spi_setup(), | 369 | transfer mode, wordsize, or clock rate. This is done with spi_setup(), |
370 | which would normally be called from probe() before the first I/O is | 370 | which would normally be called from probe() before the first I/O is |
371 | done to the device. | 371 | done to the device. However, that can also be called at any time |
372 | that no message is pending for that device. | ||
372 | 373 | ||
373 | While "spi_device" would be the bottom boundary of the driver, the | 374 | While "spi_device" would be the bottom boundary of the driver, the |
374 | upper boundaries might include sysfs (especially for sensor readings), | 375 | upper boundaries might include sysfs (especially for sensor readings), |
@@ -445,11 +446,15 @@ SPI MASTER METHODS | |||
445 | This sets up the device clock rate, SPI mode, and word sizes. | 446 | This sets up the device clock rate, SPI mode, and word sizes. |
446 | Drivers may change the defaults provided by board_info, and then | 447 | Drivers may change the defaults provided by board_info, and then |
447 | call spi_setup(spi) to invoke this routine. It may sleep. | 448 | call spi_setup(spi) to invoke this routine. It may sleep. |
449 | Unless each SPI slave has its own configuration registers, don't | ||
450 | change them right away ... otherwise drivers could corrupt I/O | ||
451 | that's in progress for other SPI devices. | ||
448 | 452 | ||
449 | master->transfer(struct spi_device *spi, struct spi_message *message) | 453 | master->transfer(struct spi_device *spi, struct spi_message *message) |
450 | This must not sleep. Its responsibility is arrange that the | 454 | This must not sleep. Its responsibility is arrange that the |
451 | transfer happens and its complete() callback is issued; the two | 455 | transfer happens and its complete() callback is issued. The two |
452 | will normally happen later, after other transfers complete. | 456 | will normally happen later, after other transfers complete, and |
457 | if the controller is idle it will need to be kickstarted. | ||
453 | 458 | ||
454 | master->cleanup(struct spi_device *spi) | 459 | master->cleanup(struct spi_device *spi) |
455 | Your controller driver may use spi_device.controller_state to hold | 460 | Your controller driver may use spi_device.controller_state to hold |
diff --git a/Documentation/spi/spidev b/Documentation/spi/spidev new file mode 100644 index 000000000000..5c8e1b988a08 --- /dev/null +++ b/Documentation/spi/spidev | |||
@@ -0,0 +1,307 @@ | |||
1 | SPI devices have a limited userspace API, supporting basic half-duplex | ||
2 | read() and write() access to SPI slave devices. Using ioctl() requests, | ||
3 | full duplex transfers and device I/O configuration are also available. | ||
4 | |||
5 | #include <fcntl.h> | ||
6 | #include <unistd.h> | ||
7 | #include <sys/ioctl.h> | ||
8 | #include <linux/types.h> | ||
9 | #include <linux/spi/spidev.h> | ||
10 | |||
11 | Some reasons you might want to use this programming interface include: | ||
12 | |||
13 | * Prototyping in an environment that's not crash-prone; stray pointers | ||
14 | in userspace won't normally bring down any Linux system. | ||
15 | |||
16 | * Developing simple protocols used to talk to microcontrollers acting | ||
17 | as SPI slaves, which you may need to change quite often. | ||
18 | |||
19 | Of course there are drivers that can never be written in userspace, because | ||
20 | they need to access kernel interfaces (such as IRQ handlers or other layers | ||
21 | of the driver stack) that are not accessible to userspace. | ||
22 | |||
23 | |||
24 | DEVICE CREATION, DRIVER BINDING | ||
25 | =============================== | ||
26 | The simplest way to arrange to use this driver is to just list it in the | ||
27 | spi_board_info for a device as the driver it should use: the "modalias" | ||
28 | entry is "spidev", matching the name of the driver exposing this API. | ||
29 | Set up the other device characteristics (bits per word, SPI clocking, | ||
30 | chipselect polarity, etc) as usual, so you won't always need to override | ||
31 | them later. | ||
32 | |||
33 | (Sysfs also supports userspace driven binding/unbinding of drivers to | ||
34 | devices. That mechanism might be supported here in the future.) | ||
35 | |||
36 | When you do that, the sysfs node for the SPI device will include a child | ||
37 | device node with a "dev" attribute that will be understood by udev or mdev. | ||
38 | (Larger systems will have "udev". Smaller ones may configure "mdev" into | ||
39 | busybox; it's less featureful, but often enough.) For a SPI device with | ||
40 | chipselect C on bus B, you should see: | ||
41 | |||
42 | /dev/spidevB.C ... character special device, major number 153 with | ||
43 | a dynamically chosen minor device number. This is the node | ||
44 | that userspace programs will open, created by "udev" or "mdev". | ||
45 | |||
46 | /sys/devices/.../spiB.C ... as usual, the SPI device node will | ||
47 | be a child of its SPI master controller. | ||
48 | |||
49 | /sys/class/spidev/spidevB.C ... created when the "spidev" driver | ||
50 | binds to that device. (Directory or symlink, based on whether | ||
51 | or not you enabled the "deprecated sysfs files" Kconfig option.) | ||
52 | |||
53 | Do not try to manage the /dev character device special file nodes by hand. | ||
54 | That's error prone, and you'd need to pay careful attention to system | ||
55 | security issues; udev/mdev should already be configured securely. | ||
56 | |||
57 | If you unbind the "spidev" driver from that device, those two "spidev" nodes | ||
58 | (in sysfs and in /dev) should automatically be removed (respectively by the | ||
59 | kernel and by udev/mdev). You can unbind by removing the "spidev" driver | ||
60 | module, which will affect all devices using this driver. You can also unbind | ||
61 | by having kernel code remove the SPI device, probably by removing the driver | ||
62 | for its SPI controller (so its spi_master vanishes). | ||
63 | |||
64 | Since this is a standard Linux device driver -- even though it just happens | ||
65 | to expose a low level API to userspace -- it can be associated with any number | ||
66 | of devices at a time. Just provide one spi_board_info record for each such | ||
67 | SPI device, and you'll get a /dev device node for each device. | ||
68 | |||
69 | |||
70 | BASIC CHARACTER DEVICE API | ||
71 | ========================== | ||
72 | Normal open() and close() operations on /dev/spidevB.D files work as you | ||
73 | would expect. | ||
74 | |||
75 | Standard read() and write() operations are obviously only half-duplex, and | ||
76 | the chipselect is deactivated between those operations. Full-duplex access, | ||
77 | and composite operation without chipselect de-activation, is available using | ||
78 | the SPI_IOC_MESSAGE(N) request. | ||
79 | |||
80 | Several ioctl() requests let your driver read or override the device's current | ||
81 | settings for data transfer parameters: | ||
82 | |||
83 | SPI_IOC_RD_MODE, SPI_IOC_WR_MODE ... pass a pointer to a byte which will | ||
84 | return (RD) or assign (WR) the SPI transfer mode. Use the constants | ||
85 | SPI_MODE_0..SPI_MODE_3; or if you prefer you can combine SPI_CPOL | ||
86 | (clock polarity, idle high iff this is set) or SPI_CPHA (clock phase, | ||
87 | sample on trailing edge iff this is set) flags. | ||
88 | |||
89 | SPI_IOC_RD_LSB_FIRST, SPI_IOC_WR_LSB_FIRST ... pass a pointer to a byte | ||
90 | which will return (RD) or assign (WR) the bit justification used to | ||
91 | transfer SPI words. Zero indicates MSB-first; other values indicate | ||
92 | the less common LSB-first encoding. In both cases the specified value | ||
93 | is right-justified in each word, so that unused (TX) or undefined (RX) | ||
94 | bits are in the MSBs. | ||
95 | |||
96 | SPI_IOC_RD_BITS_PER_WORD, SPI_IOC_WR_BITS_PER_WORD ... pass a pointer to | ||
97 | a byte which will return (RD) or assign (WR) the number of bits in | ||
98 | each SPI transfer word. The value zero signifies eight bits. | ||
99 | |||
100 | SPI_IOC_RD_MAX_SPEED_HZ, SPI_IOC_WR_MAX_SPEED_HZ ... pass a pointer to a | ||
101 | u32 which will return (RD) or assign (WR) the maximum SPI transfer | ||
102 | speed, in Hz. The controller can't necessarily assign that specific | ||
103 | clock speed. | ||
104 | |||
105 | NOTES: | ||
106 | |||
107 | - At this time there is no async I/O support; everything is purely | ||
108 | synchronous. | ||
109 | |||
110 | - There's currently no way to report the actual bit rate used to | ||
111 | shift data to/from a given device. | ||
112 | |||
113 | - From userspace, you can't currently change the chip select polarity; | ||
114 | that could corrupt transfers to other devices sharing the SPI bus. | ||
115 | Each SPI device is deselected when it's not in active use, allowing | ||
116 | other drivers to talk to other devices. | ||
117 | |||
118 | - There's a limit on the number of bytes each I/O request can transfer | ||
119 | to the SPI device. It defaults to one page, but that can be changed | ||
120 | using a module parameter. | ||
121 | |||
122 | - Because SPI has no low-level transfer acknowledgement, you usually | ||
123 | won't see any I/O errors when talking to a non-existent device. | ||
124 | |||
125 | |||
126 | FULL DUPLEX CHARACTER DEVICE API | ||
127 | ================================ | ||
128 | |||
129 | See the sample program below for one example showing the use of the full | ||
130 | duplex programming interface. (Although it doesn't perform a full duplex | ||
131 | transfer.) The model is the same as that used in the kernel spi_sync() | ||
132 | request; the individual transfers offer the same capabilities as are | ||
133 | available to kernel drivers (except that it's not asynchronous). | ||
134 | |||
135 | The example shows one half-duplex RPC-style request and response message. | ||
136 | These requests commonly require that the chip not be deselected between | ||
137 | the request and response. Several such requests could be chained into | ||
138 | a single kernel request, even allowing the chip to be deselected after | ||
139 | each response. (Other protocol options include changing the word size | ||
140 | and bitrate for each transfer segment.) | ||
141 | |||
142 | To make a full duplex request, provide both rx_buf and tx_buf for the | ||
143 | same transfer. It's even OK if those are the same buffer. | ||
144 | |||
145 | |||
146 | SAMPLE PROGRAM | ||
147 | ============== | ||
148 | |||
149 | -------------------------------- CUT HERE | ||
150 | #include <stdio.h> | ||
151 | #include <unistd.h> | ||
152 | #include <stdlib.h> | ||
153 | #include <fcntl.h> | ||
154 | #include <string.h> | ||
155 | |||
156 | #include <sys/ioctl.h> | ||
157 | #include <sys/types.h> | ||
158 | #include <sys/stat.h> | ||
159 | |||
160 | #include <linux/types.h> | ||
161 | #include <linux/spi/spidev.h> | ||
162 | |||
163 | |||
164 | static int verbose; | ||
165 | |||
166 | static void do_read(int fd, int len) | ||
167 | { | ||
168 | unsigned char buf[32], *bp; | ||
169 | int status; | ||
170 | |||
171 | /* read at least 2 bytes, no more than 32 */ | ||
172 | if (len < 2) | ||
173 | len = 2; | ||
174 | else if (len > sizeof(buf)) | ||
175 | len = sizeof(buf); | ||
176 | memset(buf, 0, sizeof buf); | ||
177 | |||
178 | status = read(fd, buf, len); | ||
179 | if (status < 0) { | ||
180 | perror("read"); | ||
181 | return; | ||
182 | } | ||
183 | if (status != len) { | ||
184 | fprintf(stderr, "short read\n"); | ||
185 | return; | ||
186 | } | ||
187 | |||
188 | printf("read(%2d, %2d): %02x %02x,", len, status, | ||
189 | buf[0], buf[1]); | ||
190 | status -= 2; | ||
191 | bp = buf + 2; | ||
192 | while (status-- > 0) | ||
193 | printf(" %02x", *bp++); | ||
194 | printf("\n"); | ||
195 | } | ||
196 | |||
197 | static void do_msg(int fd, int len) | ||
198 | { | ||
199 | struct spi_ioc_transfer xfer[2]; | ||
200 | unsigned char buf[32], *bp; | ||
201 | int status; | ||
202 | |||
203 | memset(xfer, 0, sizeof xfer); | ||
204 | memset(buf, 0, sizeof buf); | ||
205 | |||
206 | if (len > sizeof buf) | ||
207 | len = sizeof buf; | ||
208 | |||
209 | buf[0] = 0xaa; | ||
210 | xfer[0].tx_buf = (__u64) buf; | ||
211 | xfer[0].len = 1; | ||
212 | |||
213 | xfer[1].rx_buf = (__u64) buf; | ||
214 | xfer[1].len = len; | ||
215 | |||
216 | status = ioctl(fd, SPI_IOC_MESSAGE(2), xfer); | ||
217 | if (status < 0) { | ||
218 | perror("SPI_IOC_MESSAGE"); | ||
219 | return; | ||
220 | } | ||
221 | |||
222 | printf("response(%2d, %2d): ", len, status); | ||
223 | for (bp = buf; len; len--) | ||
224 | printf(" %02x", *bp++); | ||
225 | printf("\n"); | ||
226 | } | ||
227 | |||
228 | static void dumpstat(const char *name, int fd) | ||
229 | { | ||
230 | __u8 mode, lsb, bits; | ||
231 | __u32 speed; | ||
232 | |||
233 | if (ioctl(fd, SPI_IOC_RD_MODE, &mode) < 0) { | ||
234 | perror("SPI rd_mode"); | ||
235 | return; | ||
236 | } | ||
237 | if (ioctl(fd, SPI_IOC_RD_LSB_FIRST, &lsb) < 0) { | ||
238 | perror("SPI rd_lsb_fist"); | ||
239 | return; | ||
240 | } | ||
241 | if (ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits) < 0) { | ||
242 | perror("SPI bits_per_word"); | ||
243 | return; | ||
244 | } | ||
245 | if (ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed) < 0) { | ||
246 | perror("SPI max_speed_hz"); | ||
247 | return; | ||
248 | } | ||
249 | |||
250 | printf("%s: spi mode %d, %d bits %sper word, %d Hz max\n", | ||
251 | name, mode, bits, lsb ? "(lsb first) " : "", speed); | ||
252 | } | ||
253 | |||
254 | int main(int argc, char **argv) | ||
255 | { | ||
256 | int c; | ||
257 | int readcount = 0; | ||
258 | int msglen = 0; | ||
259 | int fd; | ||
260 | const char *name; | ||
261 | |||
262 | while ((c = getopt(argc, argv, "hm:r:v")) != EOF) { | ||
263 | switch (c) { | ||
264 | case 'm': | ||
265 | msglen = atoi(optarg); | ||
266 | if (msglen < 0) | ||
267 | goto usage; | ||
268 | continue; | ||
269 | case 'r': | ||
270 | readcount = atoi(optarg); | ||
271 | if (readcount < 0) | ||
272 | goto usage; | ||
273 | continue; | ||
274 | case 'v': | ||
275 | verbose++; | ||
276 | continue; | ||
277 | case 'h': | ||
278 | case '?': | ||
279 | usage: | ||
280 | fprintf(stderr, | ||
281 | "usage: %s [-h] [-m N] [-r N] /dev/spidevB.D\n", | ||
282 | argv[0]); | ||
283 | return 1; | ||
284 | } | ||
285 | } | ||
286 | |||
287 | if ((optind + 1) != argc) | ||
288 | goto usage; | ||
289 | name = argv[optind]; | ||
290 | |||
291 | fd = open(name, O_RDWR); | ||
292 | if (fd < 0) { | ||
293 | perror("open"); | ||
294 | return 1; | ||
295 | } | ||
296 | |||
297 | dumpstat(name, fd); | ||
298 | |||
299 | if (msglen) | ||
300 | do_msg(fd, msglen); | ||
301 | |||
302 | if (readcount) | ||
303 | do_read(fd, readcount); | ||
304 | |||
305 | close(fd); | ||
306 | return 0; | ||
307 | } | ||
diff --git a/Documentation/sysctl/vm.txt b/Documentation/sysctl/vm.txt index e96a341eb7e4..1d192565e182 100644 --- a/Documentation/sysctl/vm.txt +++ b/Documentation/sysctl/vm.txt | |||
@@ -197,11 +197,22 @@ and may not be fast. | |||
197 | 197 | ||
198 | panic_on_oom | 198 | panic_on_oom |
199 | 199 | ||
200 | This enables or disables panic on out-of-memory feature. If this is set to 1, | 200 | This enables or disables panic on out-of-memory feature. |
201 | the kernel panics when out-of-memory happens. If this is set to 0, the kernel | ||
202 | will kill some rogue process, called oom_killer. Usually, oom_killer can kill | ||
203 | rogue processes and system will survive. If you want to panic the system | ||
204 | rather than killing rogue processes, set this to 1. | ||
205 | 201 | ||
206 | The default value is 0. | 202 | If this is set to 0, the kernel will kill some rogue process, |
203 | called oom_killer. Usually, oom_killer can kill rogue processes and | ||
204 | system will survive. | ||
205 | |||
206 | If this is set to 1, the kernel panics when out-of-memory happens. | ||
207 | However, if a process limits using nodes by mempolicy/cpusets, | ||
208 | and those nodes become memory exhaustion status, one process | ||
209 | may be killed by oom-killer. No panic occurs in this case. | ||
210 | Because other nodes' memory may be free. This means system total status | ||
211 | may be not fatal yet. | ||
207 | 212 | ||
213 | If this is set to 2, the kernel panics compulsorily even on the | ||
214 | above-mentioned. | ||
215 | |||
216 | The default value is 0. | ||
217 | 1 and 2 are for failover of clustering. Please select either | ||
218 | according to your policy of failover. | ||
diff --git a/Documentation/sysrq.txt b/Documentation/sysrq.txt index d43aa9d3c105..ba328f255417 100644 --- a/Documentation/sysrq.txt +++ b/Documentation/sysrq.txt | |||
@@ -1,6 +1,6 @@ | |||
1 | Linux Magic System Request Key Hacks | 1 | Linux Magic System Request Key Hacks |
2 | Documentation for sysrq.c | 2 | Documentation for sysrq.c |
3 | Last update: 2007-JAN-06 | 3 | Last update: 2007-MAR-14 |
4 | 4 | ||
5 | * What is the magic SysRq key? | 5 | * What is the magic SysRq key? |
6 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 6 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
@@ -75,7 +75,7 @@ On all - write a character to /proc/sysrq-trigger. e.g.: | |||
75 | 75 | ||
76 | 'f' - Will call oom_kill to kill a memory hog process. | 76 | 'f' - Will call oom_kill to kill a memory hog process. |
77 | 77 | ||
78 | 'g' - Used by kgdb on ppc platforms. | 78 | 'g' - Used by kgdb on ppc and sh platforms. |
79 | 79 | ||
80 | 'h' - Will display help (actually any other key than those listed | 80 | 'h' - Will display help (actually any other key than those listed |
81 | above will display help. but 'h' is easy to remember :-) | 81 | above will display help. but 'h' is easy to remember :-) |
diff --git a/Documentation/tty.txt b/Documentation/tty.txt index 5f799e612e03..048a8762cfb5 100644 --- a/Documentation/tty.txt +++ b/Documentation/tty.txt | |||
@@ -108,7 +108,9 @@ hardware driver through the function pointers within the tty->driver | |||
108 | structure: | 108 | structure: |
109 | 109 | ||
110 | write() Write a block of characters to the tty device. | 110 | write() Write a block of characters to the tty device. |
111 | Returns the number of characters accepted. | 111 | Returns the number of characters accepted. The |
112 | character buffer passed to this method is already | ||
113 | in kernel space. | ||
112 | 114 | ||
113 | put_char() Queues a character for writing to the tty device. | 115 | put_char() Queues a character for writing to the tty device. |
114 | If there is no room in the queue, the character is | 116 | If there is no room in the queue, the character is |
diff --git a/Documentation/vm/slabinfo.c b/Documentation/vm/slabinfo.c new file mode 100644 index 000000000000..41710ccf3a29 --- /dev/null +++ b/Documentation/vm/slabinfo.c | |||
@@ -0,0 +1,943 @@ | |||
1 | /* | ||
2 | * Slabinfo: Tool to get reports about slabs | ||
3 | * | ||
4 | * (C) 2007 sgi, Christoph Lameter <clameter@sgi.com> | ||
5 | * | ||
6 | * Compile by: | ||
7 | * | ||
8 | * gcc -o slabinfo slabinfo.c | ||
9 | */ | ||
10 | #include <stdio.h> | ||
11 | #include <stdlib.h> | ||
12 | #include <sys/types.h> | ||
13 | #include <dirent.h> | ||
14 | #include <string.h> | ||
15 | #include <unistd.h> | ||
16 | #include <stdarg.h> | ||
17 | #include <getopt.h> | ||
18 | #include <regex.h> | ||
19 | |||
20 | #define MAX_SLABS 500 | ||
21 | #define MAX_ALIASES 500 | ||
22 | #define MAX_NODES 1024 | ||
23 | |||
24 | struct slabinfo { | ||
25 | char *name; | ||
26 | int alias; | ||
27 | int refs; | ||
28 | int aliases, align, cache_dma, cpu_slabs, destroy_by_rcu; | ||
29 | int hwcache_align, object_size, objs_per_slab; | ||
30 | int sanity_checks, slab_size, store_user, trace; | ||
31 | int order, poison, reclaim_account, red_zone; | ||
32 | unsigned long partial, objects, slabs; | ||
33 | int numa[MAX_NODES]; | ||
34 | int numa_partial[MAX_NODES]; | ||
35 | } slabinfo[MAX_SLABS]; | ||
36 | |||
37 | struct aliasinfo { | ||
38 | char *name; | ||
39 | char *ref; | ||
40 | struct slabinfo *slab; | ||
41 | } aliasinfo[MAX_ALIASES]; | ||
42 | |||
43 | int slabs = 0; | ||
44 | int aliases = 0; | ||
45 | int alias_targets = 0; | ||
46 | int highest_node = 0; | ||
47 | |||
48 | char buffer[4096]; | ||
49 | |||
50 | int show_alias = 0; | ||
51 | int show_slab = 0; | ||
52 | int skip_zero = 1; | ||
53 | int show_numa = 0; | ||
54 | int show_track = 0; | ||
55 | int show_first_alias = 0; | ||
56 | int validate = 0; | ||
57 | int shrink = 0; | ||
58 | int show_inverted = 0; | ||
59 | int show_single_ref = 0; | ||
60 | int show_totals = 0; | ||
61 | int sort_size = 0; | ||
62 | |||
63 | int page_size; | ||
64 | |||
65 | regex_t pattern; | ||
66 | |||
67 | void fatal(const char *x, ...) | ||
68 | { | ||
69 | va_list ap; | ||
70 | |||
71 | va_start(ap, x); | ||
72 | vfprintf(stderr, x, ap); | ||
73 | va_end(ap); | ||
74 | exit(1); | ||
75 | } | ||
76 | |||
77 | void usage(void) | ||
78 | { | ||
79 | printf("slabinfo [-ahnpvtsz] [slab-regexp]\n" | ||
80 | "-a|--aliases Show aliases\n" | ||
81 | "-h|--help Show usage information\n" | ||
82 | "-n|--numa Show NUMA information\n" | ||
83 | "-s|--shrink Shrink slabs\n" | ||
84 | "-v|--validate Validate slabs\n" | ||
85 | "-t|--tracking Show alloc/free information\n" | ||
86 | "-T|--Totals Show summary information\n" | ||
87 | "-l|--slabs Show slabs\n" | ||
88 | "-S|--Size Sort by size\n" | ||
89 | "-z|--zero Include empty slabs\n" | ||
90 | "-f|--first-alias Show first alias\n" | ||
91 | "-i|--inverted Inverted list\n" | ||
92 | "-1|--1ref Single reference\n" | ||
93 | ); | ||
94 | } | ||
95 | |||
96 | unsigned long read_obj(char *name) | ||
97 | { | ||
98 | FILE *f = fopen(name, "r"); | ||
99 | |||
100 | if (!f) | ||
101 | buffer[0] = 0; | ||
102 | else { | ||
103 | if (!fgets(buffer,sizeof(buffer), f)) | ||
104 | buffer[0] = 0; | ||
105 | fclose(f); | ||
106 | if (buffer[strlen(buffer)] == '\n') | ||
107 | buffer[strlen(buffer)] = 0; | ||
108 | } | ||
109 | return strlen(buffer); | ||
110 | } | ||
111 | |||
112 | |||
113 | /* | ||
114 | * Get the contents of an attribute | ||
115 | */ | ||
116 | unsigned long get_obj(char *name) | ||
117 | { | ||
118 | if (!read_obj(name)) | ||
119 | return 0; | ||
120 | |||
121 | return atol(buffer); | ||
122 | } | ||
123 | |||
124 | unsigned long get_obj_and_str(char *name, char **x) | ||
125 | { | ||
126 | unsigned long result = 0; | ||
127 | char *p; | ||
128 | |||
129 | *x = NULL; | ||
130 | |||
131 | if (!read_obj(name)) { | ||
132 | x = NULL; | ||
133 | return 0; | ||
134 | } | ||
135 | result = strtoul(buffer, &p, 10); | ||
136 | while (*p == ' ') | ||
137 | p++; | ||
138 | if (*p) | ||
139 | *x = strdup(p); | ||
140 | return result; | ||
141 | } | ||
142 | |||
143 | void set_obj(struct slabinfo *s, char *name, int n) | ||
144 | { | ||
145 | char x[100]; | ||
146 | |||
147 | sprintf(x, "%s/%s", s->name, name); | ||
148 | |||
149 | FILE *f = fopen(x, "w"); | ||
150 | |||
151 | if (!f) | ||
152 | fatal("Cannot write to %s\n", x); | ||
153 | |||
154 | fprintf(f, "%d\n", n); | ||
155 | fclose(f); | ||
156 | } | ||
157 | |||
158 | /* | ||
159 | * Put a size string together | ||
160 | */ | ||
161 | int store_size(char *buffer, unsigned long value) | ||
162 | { | ||
163 | unsigned long divisor = 1; | ||
164 | char trailer = 0; | ||
165 | int n; | ||
166 | |||
167 | if (value > 1000000000UL) { | ||
168 | divisor = 100000000UL; | ||
169 | trailer = 'G'; | ||
170 | } else if (value > 1000000UL) { | ||
171 | divisor = 100000UL; | ||
172 | trailer = 'M'; | ||
173 | } else if (value > 1000UL) { | ||
174 | divisor = 100; | ||
175 | trailer = 'K'; | ||
176 | } | ||
177 | |||
178 | value /= divisor; | ||
179 | n = sprintf(buffer, "%ld",value); | ||
180 | if (trailer) { | ||
181 | buffer[n] = trailer; | ||
182 | n++; | ||
183 | buffer[n] = 0; | ||
184 | } | ||
185 | if (divisor != 1) { | ||
186 | memmove(buffer + n - 2, buffer + n - 3, 4); | ||
187 | buffer[n-2] = '.'; | ||
188 | n++; | ||
189 | } | ||
190 | return n; | ||
191 | } | ||
192 | |||
193 | void decode_numa_list(int *numa, char *t) | ||
194 | { | ||
195 | int node; | ||
196 | int nr; | ||
197 | |||
198 | memset(numa, 0, MAX_NODES * sizeof(int)); | ||
199 | |||
200 | while (*t == 'N') { | ||
201 | t++; | ||
202 | node = strtoul(t, &t, 10); | ||
203 | if (*t == '=') { | ||
204 | t++; | ||
205 | nr = strtoul(t, &t, 10); | ||
206 | numa[node] = nr; | ||
207 | if (node > highest_node) | ||
208 | highest_node = node; | ||
209 | } | ||
210 | while (*t == ' ') | ||
211 | t++; | ||
212 | } | ||
213 | } | ||
214 | |||
215 | void slab_validate(struct slabinfo *s) | ||
216 | { | ||
217 | set_obj(s, "validate", 1); | ||
218 | } | ||
219 | |||
220 | void slab_shrink(struct slabinfo *s) | ||
221 | { | ||
222 | set_obj(s, "shrink", 1); | ||
223 | } | ||
224 | |||
225 | int line = 0; | ||
226 | |||
227 | void first_line(void) | ||
228 | { | ||
229 | printf("Name Objects Objsize Space " | ||
230 | "Slabs/Part/Cpu O/S O %%Fr %%Ef Flg\n"); | ||
231 | } | ||
232 | |||
233 | /* | ||
234 | * Find the shortest alias of a slab | ||
235 | */ | ||
236 | struct aliasinfo *find_one_alias(struct slabinfo *find) | ||
237 | { | ||
238 | struct aliasinfo *a; | ||
239 | struct aliasinfo *best = NULL; | ||
240 | |||
241 | for(a = aliasinfo;a < aliasinfo + aliases; a++) { | ||
242 | if (a->slab == find && | ||
243 | (!best || strlen(best->name) < strlen(a->name))) { | ||
244 | best = a; | ||
245 | if (strncmp(a->name,"kmall", 5) == 0) | ||
246 | return best; | ||
247 | } | ||
248 | } | ||
249 | if (best) | ||
250 | return best; | ||
251 | fatal("Cannot find alias for %s\n", find->name); | ||
252 | return NULL; | ||
253 | } | ||
254 | |||
255 | unsigned long slab_size(struct slabinfo *s) | ||
256 | { | ||
257 | return s->slabs * (page_size << s->order); | ||
258 | } | ||
259 | |||
260 | |||
261 | void slabcache(struct slabinfo *s) | ||
262 | { | ||
263 | char size_str[20]; | ||
264 | char dist_str[40]; | ||
265 | char flags[20]; | ||
266 | char *p = flags; | ||
267 | |||
268 | if (skip_zero && !s->slabs) | ||
269 | return; | ||
270 | |||
271 | store_size(size_str, slab_size(s)); | ||
272 | sprintf(dist_str,"%lu/%lu/%d", s->slabs, s->partial, s->cpu_slabs); | ||
273 | |||
274 | if (!line++) | ||
275 | first_line(); | ||
276 | |||
277 | if (s->aliases) | ||
278 | *p++ = '*'; | ||
279 | if (s->cache_dma) | ||
280 | *p++ = 'd'; | ||
281 | if (s->hwcache_align) | ||
282 | *p++ = 'A'; | ||
283 | if (s->poison) | ||
284 | *p++ = 'P'; | ||
285 | if (s->reclaim_account) | ||
286 | *p++ = 'a'; | ||
287 | if (s->red_zone) | ||
288 | *p++ = 'Z'; | ||
289 | if (s->sanity_checks) | ||
290 | *p++ = 'F'; | ||
291 | if (s->store_user) | ||
292 | *p++ = 'U'; | ||
293 | if (s->trace) | ||
294 | *p++ = 'T'; | ||
295 | |||
296 | *p = 0; | ||
297 | printf("%-21s %8ld %7d %8s %14s %4d %1d %3ld %3ld %s\n", | ||
298 | s->name, s->objects, s->object_size, size_str, dist_str, | ||
299 | s->objs_per_slab, s->order, | ||
300 | s->slabs ? (s->partial * 100) / s->slabs : 100, | ||
301 | s->slabs ? (s->objects * s->object_size * 100) / | ||
302 | (s->slabs * (page_size << s->order)) : 100, | ||
303 | flags); | ||
304 | } | ||
305 | |||
306 | void slab_numa(struct slabinfo *s) | ||
307 | { | ||
308 | int node; | ||
309 | |||
310 | if (!highest_node) | ||
311 | fatal("No NUMA information available.\n"); | ||
312 | |||
313 | if (skip_zero && !s->slabs) | ||
314 | return; | ||
315 | |||
316 | if (!line) { | ||
317 | printf("\nSlab Node "); | ||
318 | for(node = 0; node <= highest_node; node++) | ||
319 | printf(" %4d", node); | ||
320 | printf("\n----------------------"); | ||
321 | for(node = 0; node <= highest_node; node++) | ||
322 | printf("-----"); | ||
323 | printf("\n"); | ||
324 | } | ||
325 | printf("%-21s ", s->name); | ||
326 | for(node = 0; node <= highest_node; node++) { | ||
327 | char b[20]; | ||
328 | |||
329 | store_size(b, s->numa[node]); | ||
330 | printf(" %4s", b); | ||
331 | } | ||
332 | printf("\n"); | ||
333 | line++; | ||
334 | } | ||
335 | |||
336 | void show_tracking(struct slabinfo *s) | ||
337 | { | ||
338 | printf("\n%s: Calls to allocate a slab object\n", s->name); | ||
339 | printf("---------------------------------------------------\n"); | ||
340 | if (read_obj("alloc_calls")) | ||
341 | printf(buffer); | ||
342 | |||
343 | printf("%s: Calls to free a slab object\n", s->name); | ||
344 | printf("-----------------------------------------------\n"); | ||
345 | if (read_obj("free_calls")) | ||
346 | printf(buffer); | ||
347 | |||
348 | } | ||
349 | |||
350 | void totals(void) | ||
351 | { | ||
352 | struct slabinfo *s; | ||
353 | |||
354 | int used_slabs = 0; | ||
355 | char b1[20], b2[20], b3[20], b4[20]; | ||
356 | unsigned long long max = 1ULL << 63; | ||
357 | |||
358 | /* Object size */ | ||
359 | unsigned long long min_objsize = max, max_objsize = 0, avg_objsize; | ||
360 | |||
361 | /* Number of partial slabs in a slabcache */ | ||
362 | unsigned long long min_partial = max, max_partial = 0, | ||
363 | avg_partial, total_partial = 0; | ||
364 | |||
365 | /* Number of slabs in a slab cache */ | ||
366 | unsigned long long min_slabs = max, max_slabs = 0, | ||
367 | avg_slabs, total_slabs = 0; | ||
368 | |||
369 | /* Size of the whole slab */ | ||
370 | unsigned long long min_size = max, max_size = 0, | ||
371 | avg_size, total_size = 0; | ||
372 | |||
373 | /* Bytes used for object storage in a slab */ | ||
374 | unsigned long long min_used = max, max_used = 0, | ||
375 | avg_used, total_used = 0; | ||
376 | |||
377 | /* Waste: Bytes used for alignment and padding */ | ||
378 | unsigned long long min_waste = max, max_waste = 0, | ||
379 | avg_waste, total_waste = 0; | ||
380 | /* Number of objects in a slab */ | ||
381 | unsigned long long min_objects = max, max_objects = 0, | ||
382 | avg_objects, total_objects = 0; | ||
383 | /* Waste per object */ | ||
384 | unsigned long long min_objwaste = max, | ||
385 | max_objwaste = 0, avg_objwaste, | ||
386 | total_objwaste = 0; | ||
387 | |||
388 | /* Memory per object */ | ||
389 | unsigned long long min_memobj = max, | ||
390 | max_memobj = 0, avg_memobj, | ||
391 | total_objsize = 0; | ||
392 | |||
393 | /* Percentage of partial slabs per slab */ | ||
394 | unsigned long min_ppart = 100, max_ppart = 0, | ||
395 | avg_ppart, total_ppart = 0; | ||
396 | |||
397 | /* Number of objects in partial slabs */ | ||
398 | unsigned long min_partobj = max, max_partobj = 0, | ||
399 | avg_partobj, total_partobj = 0; | ||
400 | |||
401 | /* Percentage of partial objects of all objects in a slab */ | ||
402 | unsigned long min_ppartobj = 100, max_ppartobj = 0, | ||
403 | avg_ppartobj, total_ppartobj = 0; | ||
404 | |||
405 | |||
406 | for (s = slabinfo; s < slabinfo + slabs; s++) { | ||
407 | unsigned long long size; | ||
408 | unsigned long used; | ||
409 | unsigned long long wasted; | ||
410 | unsigned long long objwaste; | ||
411 | long long objects_in_partial_slabs; | ||
412 | unsigned long percentage_partial_slabs; | ||
413 | unsigned long percentage_partial_objs; | ||
414 | |||
415 | if (!s->slabs || !s->objects) | ||
416 | continue; | ||
417 | |||
418 | used_slabs++; | ||
419 | |||
420 | size = slab_size(s); | ||
421 | used = s->objects * s->object_size; | ||
422 | wasted = size - used; | ||
423 | objwaste = s->slab_size - s->object_size; | ||
424 | |||
425 | objects_in_partial_slabs = s->objects - | ||
426 | (s->slabs - s->partial - s ->cpu_slabs) * | ||
427 | s->objs_per_slab; | ||
428 | |||
429 | if (objects_in_partial_slabs < 0) | ||
430 | objects_in_partial_slabs = 0; | ||
431 | |||
432 | percentage_partial_slabs = s->partial * 100 / s->slabs; | ||
433 | if (percentage_partial_slabs > 100) | ||
434 | percentage_partial_slabs = 100; | ||
435 | |||
436 | percentage_partial_objs = objects_in_partial_slabs * 100 | ||
437 | / s->objects; | ||
438 | |||
439 | if (percentage_partial_objs > 100) | ||
440 | percentage_partial_objs = 100; | ||
441 | |||
442 | if (s->object_size < min_objsize) | ||
443 | min_objsize = s->object_size; | ||
444 | if (s->partial < min_partial) | ||
445 | min_partial = s->partial; | ||
446 | if (s->slabs < min_slabs) | ||
447 | min_slabs = s->slabs; | ||
448 | if (size < min_size) | ||
449 | min_size = size; | ||
450 | if (wasted < min_waste) | ||
451 | min_waste = wasted; | ||
452 | if (objwaste < min_objwaste) | ||
453 | min_objwaste = objwaste; | ||
454 | if (s->objects < min_objects) | ||
455 | min_objects = s->objects; | ||
456 | if (used < min_used) | ||
457 | min_used = used; | ||
458 | if (objects_in_partial_slabs < min_partobj) | ||
459 | min_partobj = objects_in_partial_slabs; | ||
460 | if (percentage_partial_slabs < min_ppart) | ||
461 | min_ppart = percentage_partial_slabs; | ||
462 | if (percentage_partial_objs < min_ppartobj) | ||
463 | min_ppartobj = percentage_partial_objs; | ||
464 | if (s->slab_size < min_memobj) | ||
465 | min_memobj = s->slab_size; | ||
466 | |||
467 | if (s->object_size > max_objsize) | ||
468 | max_objsize = s->object_size; | ||
469 | if (s->partial > max_partial) | ||
470 | max_partial = s->partial; | ||
471 | if (s->slabs > max_slabs) | ||
472 | max_slabs = s->slabs; | ||
473 | if (size > max_size) | ||
474 | max_size = size; | ||
475 | if (wasted > max_waste) | ||
476 | max_waste = wasted; | ||
477 | if (objwaste > max_objwaste) | ||
478 | max_objwaste = objwaste; | ||
479 | if (s->objects > max_objects) | ||
480 | max_objects = s->objects; | ||
481 | if (used > max_used) | ||
482 | max_used = used; | ||
483 | if (objects_in_partial_slabs > max_partobj) | ||
484 | max_partobj = objects_in_partial_slabs; | ||
485 | if (percentage_partial_slabs > max_ppart) | ||
486 | max_ppart = percentage_partial_slabs; | ||
487 | if (percentage_partial_objs > max_ppartobj) | ||
488 | max_ppartobj = percentage_partial_objs; | ||
489 | if (s->slab_size > max_memobj) | ||
490 | max_memobj = s->slab_size; | ||
491 | |||
492 | total_partial += s->partial; | ||
493 | total_slabs += s->slabs; | ||
494 | total_size += size; | ||
495 | total_waste += wasted; | ||
496 | |||
497 | total_objects += s->objects; | ||
498 | total_used += used; | ||
499 | total_partobj += objects_in_partial_slabs; | ||
500 | total_ppart += percentage_partial_slabs; | ||
501 | total_ppartobj += percentage_partial_objs; | ||
502 | |||
503 | total_objwaste += s->objects * objwaste; | ||
504 | total_objsize += s->objects * s->slab_size; | ||
505 | } | ||
506 | |||
507 | if (!total_objects) { | ||
508 | printf("No objects\n"); | ||
509 | return; | ||
510 | } | ||
511 | if (!used_slabs) { | ||
512 | printf("No slabs\n"); | ||
513 | return; | ||
514 | } | ||
515 | |||
516 | /* Per slab averages */ | ||
517 | avg_partial = total_partial / used_slabs; | ||
518 | avg_slabs = total_slabs / used_slabs; | ||
519 | avg_size = total_size / used_slabs; | ||
520 | avg_waste = total_waste / used_slabs; | ||
521 | |||
522 | avg_objects = total_objects / used_slabs; | ||
523 | avg_used = total_used / used_slabs; | ||
524 | avg_partobj = total_partobj / used_slabs; | ||
525 | avg_ppart = total_ppart / used_slabs; | ||
526 | avg_ppartobj = total_ppartobj / used_slabs; | ||
527 | |||
528 | /* Per object object sizes */ | ||
529 | avg_objsize = total_used / total_objects; | ||
530 | avg_objwaste = total_objwaste / total_objects; | ||
531 | avg_partobj = total_partobj * 100 / total_objects; | ||
532 | avg_memobj = total_objsize / total_objects; | ||
533 | |||
534 | printf("Slabcache Totals\n"); | ||
535 | printf("----------------\n"); | ||
536 | printf("Slabcaches : %3d Aliases : %3d->%-3d Active: %3d\n", | ||
537 | slabs, aliases, alias_targets, used_slabs); | ||
538 | |||
539 | store_size(b1, total_size);store_size(b2, total_waste); | ||
540 | store_size(b3, total_waste * 100 / total_used); | ||
541 | printf("Memory used: %6s # Loss : %6s MRatio: %6s%%\n", b1, b2, b3); | ||
542 | |||
543 | store_size(b1, total_objects);store_size(b2, total_partobj); | ||
544 | store_size(b3, total_partobj * 100 / total_objects); | ||
545 | printf("# Objects : %6s # PartObj: %6s ORatio: %6s%%\n", b1, b2, b3); | ||
546 | |||
547 | printf("\n"); | ||
548 | printf("Per Cache Average Min Max Total\n"); | ||
549 | printf("---------------------------------------------------------\n"); | ||
550 | |||
551 | store_size(b1, avg_objects);store_size(b2, min_objects); | ||
552 | store_size(b3, max_objects);store_size(b4, total_objects); | ||
553 | printf("#Objects %10s %10s %10s %10s\n", | ||
554 | b1, b2, b3, b4); | ||
555 | |||
556 | store_size(b1, avg_slabs);store_size(b2, min_slabs); | ||
557 | store_size(b3, max_slabs);store_size(b4, total_slabs); | ||
558 | printf("#Slabs %10s %10s %10s %10s\n", | ||
559 | b1, b2, b3, b4); | ||
560 | |||
561 | store_size(b1, avg_partial);store_size(b2, min_partial); | ||
562 | store_size(b3, max_partial);store_size(b4, total_partial); | ||
563 | printf("#PartSlab %10s %10s %10s %10s\n", | ||
564 | b1, b2, b3, b4); | ||
565 | store_size(b1, avg_ppart);store_size(b2, min_ppart); | ||
566 | store_size(b3, max_ppart); | ||
567 | store_size(b4, total_partial * 100 / total_slabs); | ||
568 | printf("%%PartSlab %10s%% %10s%% %10s%% %10s%%\n", | ||
569 | b1, b2, b3, b4); | ||
570 | |||
571 | store_size(b1, avg_partobj);store_size(b2, min_partobj); | ||
572 | store_size(b3, max_partobj); | ||
573 | store_size(b4, total_partobj); | ||
574 | printf("PartObjs %10s %10s %10s %10s\n", | ||
575 | b1, b2, b3, b4); | ||
576 | |||
577 | store_size(b1, avg_ppartobj);store_size(b2, min_ppartobj); | ||
578 | store_size(b3, max_ppartobj); | ||
579 | store_size(b4, total_partobj * 100 / total_objects); | ||
580 | printf("%% PartObj %10s%% %10s%% %10s%% %10s%%\n", | ||
581 | b1, b2, b3, b4); | ||
582 | |||
583 | store_size(b1, avg_size);store_size(b2, min_size); | ||
584 | store_size(b3, max_size);store_size(b4, total_size); | ||
585 | printf("Memory %10s %10s %10s %10s\n", | ||
586 | b1, b2, b3, b4); | ||
587 | |||
588 | store_size(b1, avg_used);store_size(b2, min_used); | ||
589 | store_size(b3, max_used);store_size(b4, total_used); | ||
590 | printf("Used %10s %10s %10s %10s\n", | ||
591 | b1, b2, b3, b4); | ||
592 | |||
593 | store_size(b1, avg_waste);store_size(b2, min_waste); | ||
594 | store_size(b3, max_waste);store_size(b4, total_waste); | ||
595 | printf("Loss %10s %10s %10s %10s\n", | ||
596 | b1, b2, b3, b4); | ||
597 | |||
598 | printf("\n"); | ||
599 | printf("Per Object Average Min Max\n"); | ||
600 | printf("---------------------------------------------\n"); | ||
601 | |||
602 | store_size(b1, avg_memobj);store_size(b2, min_memobj); | ||
603 | store_size(b3, max_memobj); | ||
604 | printf("Memory %10s %10s %10s\n", | ||
605 | b1, b2, b3); | ||
606 | store_size(b1, avg_objsize);store_size(b2, min_objsize); | ||
607 | store_size(b3, max_objsize); | ||
608 | printf("User %10s %10s %10s\n", | ||
609 | b1, b2, b3); | ||
610 | |||
611 | store_size(b1, avg_objwaste);store_size(b2, min_objwaste); | ||
612 | store_size(b3, max_objwaste); | ||
613 | printf("Loss %10s %10s %10s\n", | ||
614 | b1, b2, b3); | ||
615 | } | ||
616 | |||
617 | void sort_slabs(void) | ||
618 | { | ||
619 | struct slabinfo *s1,*s2; | ||
620 | |||
621 | for (s1 = slabinfo; s1 < slabinfo + slabs; s1++) { | ||
622 | for (s2 = s1 + 1; s2 < slabinfo + slabs; s2++) { | ||
623 | int result; | ||
624 | |||
625 | if (sort_size) | ||
626 | result = slab_size(s1) < slab_size(s2); | ||
627 | else | ||
628 | result = strcasecmp(s1->name, s2->name); | ||
629 | |||
630 | if (show_inverted) | ||
631 | result = -result; | ||
632 | |||
633 | if (result > 0) { | ||
634 | struct slabinfo t; | ||
635 | |||
636 | memcpy(&t, s1, sizeof(struct slabinfo)); | ||
637 | memcpy(s1, s2, sizeof(struct slabinfo)); | ||
638 | memcpy(s2, &t, sizeof(struct slabinfo)); | ||
639 | } | ||
640 | } | ||
641 | } | ||
642 | } | ||
643 | |||
644 | void sort_aliases(void) | ||
645 | { | ||
646 | struct aliasinfo *a1,*a2; | ||
647 | |||
648 | for (a1 = aliasinfo; a1 < aliasinfo + aliases; a1++) { | ||
649 | for (a2 = a1 + 1; a2 < aliasinfo + aliases; a2++) { | ||
650 | char *n1, *n2; | ||
651 | |||
652 | n1 = a1->name; | ||
653 | n2 = a2->name; | ||
654 | if (show_alias && !show_inverted) { | ||
655 | n1 = a1->ref; | ||
656 | n2 = a2->ref; | ||
657 | } | ||
658 | if (strcasecmp(n1, n2) > 0) { | ||
659 | struct aliasinfo t; | ||
660 | |||
661 | memcpy(&t, a1, sizeof(struct aliasinfo)); | ||
662 | memcpy(a1, a2, sizeof(struct aliasinfo)); | ||
663 | memcpy(a2, &t, sizeof(struct aliasinfo)); | ||
664 | } | ||
665 | } | ||
666 | } | ||
667 | } | ||
668 | |||
669 | void link_slabs(void) | ||
670 | { | ||
671 | struct aliasinfo *a; | ||
672 | struct slabinfo *s; | ||
673 | |||
674 | for (a = aliasinfo; a < aliasinfo + aliases; a++) { | ||
675 | |||
676 | for(s = slabinfo; s < slabinfo + slabs; s++) | ||
677 | if (strcmp(a->ref, s->name) == 0) { | ||
678 | a->slab = s; | ||
679 | s->refs++; | ||
680 | break; | ||
681 | } | ||
682 | if (s == slabinfo + slabs) | ||
683 | fatal("Unresolved alias %s\n", a->ref); | ||
684 | } | ||
685 | } | ||
686 | |||
687 | void alias(void) | ||
688 | { | ||
689 | struct aliasinfo *a; | ||
690 | char *active = NULL; | ||
691 | |||
692 | sort_aliases(); | ||
693 | link_slabs(); | ||
694 | |||
695 | for(a = aliasinfo; a < aliasinfo + aliases; a++) { | ||
696 | |||
697 | if (!show_single_ref && a->slab->refs == 1) | ||
698 | continue; | ||
699 | |||
700 | if (!show_inverted) { | ||
701 | if (active) { | ||
702 | if (strcmp(a->slab->name, active) == 0) { | ||
703 | printf(" %s", a->name); | ||
704 | continue; | ||
705 | } | ||
706 | } | ||
707 | printf("\n%-20s <- %s", a->slab->name, a->name); | ||
708 | active = a->slab->name; | ||
709 | } | ||
710 | else | ||
711 | printf("%-20s -> %s\n", a->name, a->slab->name); | ||
712 | } | ||
713 | if (active) | ||
714 | printf("\n"); | ||
715 | } | ||
716 | |||
717 | |||
718 | void rename_slabs(void) | ||
719 | { | ||
720 | struct slabinfo *s; | ||
721 | struct aliasinfo *a; | ||
722 | |||
723 | for (s = slabinfo; s < slabinfo + slabs; s++) { | ||
724 | if (*s->name != ':') | ||
725 | continue; | ||
726 | |||
727 | if (s->refs > 1 && !show_first_alias) | ||
728 | continue; | ||
729 | |||
730 | a = find_one_alias(s); | ||
731 | |||
732 | s->name = a->name; | ||
733 | } | ||
734 | } | ||
735 | |||
736 | int slab_mismatch(char *slab) | ||
737 | { | ||
738 | return regexec(&pattern, slab, 0, NULL, 0); | ||
739 | } | ||
740 | |||
741 | void read_slab_dir(void) | ||
742 | { | ||
743 | DIR *dir; | ||
744 | struct dirent *de; | ||
745 | struct slabinfo *slab = slabinfo; | ||
746 | struct aliasinfo *alias = aliasinfo; | ||
747 | char *p; | ||
748 | char *t; | ||
749 | int count; | ||
750 | |||
751 | dir = opendir("."); | ||
752 | while ((de = readdir(dir))) { | ||
753 | if (de->d_name[0] == '.' || | ||
754 | slab_mismatch(de->d_name)) | ||
755 | continue; | ||
756 | switch (de->d_type) { | ||
757 | case DT_LNK: | ||
758 | alias->name = strdup(de->d_name); | ||
759 | count = readlink(de->d_name, buffer, sizeof(buffer)); | ||
760 | |||
761 | if (count < 0) | ||
762 | fatal("Cannot read symlink %s\n", de->d_name); | ||
763 | |||
764 | buffer[count] = 0; | ||
765 | p = buffer + count; | ||
766 | while (p > buffer && p[-1] != '/') | ||
767 | p--; | ||
768 | alias->ref = strdup(p); | ||
769 | alias++; | ||
770 | break; | ||
771 | case DT_DIR: | ||
772 | if (chdir(de->d_name)) | ||
773 | fatal("Unable to access slab %s\n", slab->name); | ||
774 | slab->name = strdup(de->d_name); | ||
775 | slab->alias = 0; | ||
776 | slab->refs = 0; | ||
777 | slab->aliases = get_obj("aliases"); | ||
778 | slab->align = get_obj("align"); | ||
779 | slab->cache_dma = get_obj("cache_dma"); | ||
780 | slab->cpu_slabs = get_obj("cpu_slabs"); | ||
781 | slab->destroy_by_rcu = get_obj("destroy_by_rcu"); | ||
782 | slab->hwcache_align = get_obj("hwcache_align"); | ||
783 | slab->object_size = get_obj("object_size"); | ||
784 | slab->objects = get_obj("objects"); | ||
785 | slab->objs_per_slab = get_obj("objs_per_slab"); | ||
786 | slab->order = get_obj("order"); | ||
787 | slab->partial = get_obj("partial"); | ||
788 | slab->partial = get_obj_and_str("partial", &t); | ||
789 | decode_numa_list(slab->numa_partial, t); | ||
790 | slab->poison = get_obj("poison"); | ||
791 | slab->reclaim_account = get_obj("reclaim_account"); | ||
792 | slab->red_zone = get_obj("red_zone"); | ||
793 | slab->sanity_checks = get_obj("sanity_checks"); | ||
794 | slab->slab_size = get_obj("slab_size"); | ||
795 | slab->slabs = get_obj_and_str("slabs", &t); | ||
796 | decode_numa_list(slab->numa, t); | ||
797 | slab->store_user = get_obj("store_user"); | ||
798 | slab->trace = get_obj("trace"); | ||
799 | chdir(".."); | ||
800 | if (slab->name[0] == ':') | ||
801 | alias_targets++; | ||
802 | slab++; | ||
803 | break; | ||
804 | default : | ||
805 | fatal("Unknown file type %lx\n", de->d_type); | ||
806 | } | ||
807 | } | ||
808 | closedir(dir); | ||
809 | slabs = slab - slabinfo; | ||
810 | aliases = alias - aliasinfo; | ||
811 | if (slabs > MAX_SLABS) | ||
812 | fatal("Too many slabs\n"); | ||
813 | if (aliases > MAX_ALIASES) | ||
814 | fatal("Too many aliases\n"); | ||
815 | } | ||
816 | |||
817 | void output_slabs(void) | ||
818 | { | ||
819 | struct slabinfo *slab; | ||
820 | |||
821 | for (slab = slabinfo; slab < slabinfo + slabs; slab++) { | ||
822 | |||
823 | if (slab->alias) | ||
824 | continue; | ||
825 | |||
826 | |||
827 | if (show_numa) | ||
828 | slab_numa(slab); | ||
829 | else | ||
830 | if (show_track) | ||
831 | show_tracking(slab); | ||
832 | else | ||
833 | if (validate) | ||
834 | slab_validate(slab); | ||
835 | else | ||
836 | if (shrink) | ||
837 | slab_shrink(slab); | ||
838 | else { | ||
839 | if (show_slab) | ||
840 | slabcache(slab); | ||
841 | } | ||
842 | } | ||
843 | } | ||
844 | |||
845 | struct option opts[] = { | ||
846 | { "aliases", 0, NULL, 'a' }, | ||
847 | { "slabs", 0, NULL, 'l' }, | ||
848 | { "numa", 0, NULL, 'n' }, | ||
849 | { "zero", 0, NULL, 'z' }, | ||
850 | { "help", 0, NULL, 'h' }, | ||
851 | { "validate", 0, NULL, 'v' }, | ||
852 | { "first-alias", 0, NULL, 'f' }, | ||
853 | { "shrink", 0, NULL, 's' }, | ||
854 | { "track", 0, NULL, 't'}, | ||
855 | { "inverted", 0, NULL, 'i'}, | ||
856 | { "1ref", 0, NULL, '1'}, | ||
857 | { NULL, 0, NULL, 0 } | ||
858 | }; | ||
859 | |||
860 | int main(int argc, char *argv[]) | ||
861 | { | ||
862 | int c; | ||
863 | int err; | ||
864 | char *pattern_source; | ||
865 | |||
866 | page_size = getpagesize(); | ||
867 | if (chdir("/sys/slab")) | ||
868 | fatal("This kernel does not have SLUB support.\n"); | ||
869 | |||
870 | while ((c = getopt_long(argc, argv, "afhil1npstvzTS", opts, NULL)) != -1) | ||
871 | switch(c) { | ||
872 | case '1': | ||
873 | show_single_ref = 1; | ||
874 | break; | ||
875 | case 'a': | ||
876 | show_alias = 1; | ||
877 | break; | ||
878 | case 'f': | ||
879 | show_first_alias = 1; | ||
880 | break; | ||
881 | case 'h': | ||
882 | usage(); | ||
883 | return 0; | ||
884 | case 'i': | ||
885 | show_inverted = 1; | ||
886 | break; | ||
887 | case 'n': | ||
888 | show_numa = 1; | ||
889 | break; | ||
890 | case 's': | ||
891 | shrink = 1; | ||
892 | break; | ||
893 | case 'l': | ||
894 | show_slab = 1; | ||
895 | break; | ||
896 | case 't': | ||
897 | show_track = 1; | ||
898 | break; | ||
899 | case 'v': | ||
900 | validate = 1; | ||
901 | break; | ||
902 | case 'z': | ||
903 | skip_zero = 0; | ||
904 | break; | ||
905 | case 'T': | ||
906 | show_totals = 1; | ||
907 | break; | ||
908 | case 'S': | ||
909 | sort_size = 1; | ||
910 | break; | ||
911 | |||
912 | default: | ||
913 | fatal("%s: Invalid option '%c'\n", argv[0], optopt); | ||
914 | |||
915 | } | ||
916 | |||
917 | if (!show_slab && !show_alias && !show_track | ||
918 | && !validate && !shrink) | ||
919 | show_slab = 1; | ||
920 | |||
921 | if (argc > optind) | ||
922 | pattern_source = argv[optind]; | ||
923 | else | ||
924 | pattern_source = ".*"; | ||
925 | |||
926 | err = regcomp(&pattern, pattern_source, REG_ICASE|REG_NOSUB); | ||
927 | if (err) | ||
928 | fatal("%s: Invalid pattern '%s' code %d\n", | ||
929 | argv[0], pattern_source, err); | ||
930 | read_slab_dir(); | ||
931 | if (show_alias) | ||
932 | alias(); | ||
933 | else | ||
934 | if (show_totals) | ||
935 | totals(); | ||
936 | else { | ||
937 | link_slabs(); | ||
938 | rename_slabs(); | ||
939 | sort_slabs(); | ||
940 | output_slabs(); | ||
941 | } | ||
942 | return 0; | ||
943 | } | ||
diff --git a/Documentation/vm/slub.txt b/Documentation/vm/slub.txt new file mode 100644 index 000000000000..727c8d81aeaf --- /dev/null +++ b/Documentation/vm/slub.txt | |||
@@ -0,0 +1,113 @@ | |||
1 | Short users guide for SLUB | ||
2 | -------------------------- | ||
3 | |||
4 | First of all slub should transparently replace SLAB. If you enable | ||
5 | SLUB then everything should work the same (Note the word "should". | ||
6 | There is likely not much value in that word at this point). | ||
7 | |||
8 | The basic philosophy of SLUB is very different from SLAB. SLAB | ||
9 | requires rebuilding the kernel to activate debug options for all | ||
10 | SLABS. SLUB always includes full debugging but its off by default. | ||
11 | SLUB can enable debugging only for selected slabs in order to avoid | ||
12 | an impact on overall system performance which may make a bug more | ||
13 | difficult to find. | ||
14 | |||
15 | In order to switch debugging on one can add a option "slub_debug" | ||
16 | to the kernel command line. That will enable full debugging for | ||
17 | all slabs. | ||
18 | |||
19 | Typically one would then use the "slabinfo" command to get statistical | ||
20 | data and perform operation on the slabs. By default slabinfo only lists | ||
21 | slabs that have data in them. See "slabinfo -h" for more options when | ||
22 | running the command. slabinfo can be compiled with | ||
23 | |||
24 | gcc -o slabinfo Documentation/vm/slabinfo.c | ||
25 | |||
26 | Some of the modes of operation of slabinfo require that slub debugging | ||
27 | be enabled on the command line. F.e. no tracking information will be | ||
28 | available without debugging on and validation can only partially | ||
29 | be performed if debugging was not switched on. | ||
30 | |||
31 | Some more sophisticated uses of slub_debug: | ||
32 | ------------------------------------------- | ||
33 | |||
34 | Parameters may be given to slub_debug. If none is specified then full | ||
35 | debugging is enabled. Format: | ||
36 | |||
37 | slub_debug=<Debug-Options> Enable options for all slabs | ||
38 | slub_debug=<Debug-Options>,<slab name> | ||
39 | Enable options only for select slabs | ||
40 | |||
41 | Possible debug options are | ||
42 | F Sanity checks on (enables SLAB_DEBUG_FREE. Sorry | ||
43 | SLAB legacy issues) | ||
44 | Z Red zoning | ||
45 | P Poisoning (object and padding) | ||
46 | U User tracking (free and alloc) | ||
47 | T Trace (please only use on single slabs) | ||
48 | |||
49 | F.e. in order to boot just with sanity checks and red zoning one would specify: | ||
50 | |||
51 | slub_debug=FZ | ||
52 | |||
53 | Trying to find an issue in the dentry cache? Try | ||
54 | |||
55 | slub_debug=,dentry_cache | ||
56 | |||
57 | to only enable debugging on the dentry cache. | ||
58 | |||
59 | Red zoning and tracking may realign the slab. We can just apply sanity checks | ||
60 | to the dentry cache with | ||
61 | |||
62 | slub_debug=F,dentry_cache | ||
63 | |||
64 | In case you forgot to enable debugging on the kernel command line: It is | ||
65 | possible to enable debugging manually when the kernel is up. Look at the | ||
66 | contents of: | ||
67 | |||
68 | /sys/slab/<slab name>/ | ||
69 | |||
70 | Look at the writable files. Writing 1 to them will enable the | ||
71 | corresponding debug option. All options can be set on a slab that does | ||
72 | not contain objects. If the slab already contains objects then sanity checks | ||
73 | and tracing may only be enabled. The other options may cause the realignment | ||
74 | of objects. | ||
75 | |||
76 | Careful with tracing: It may spew out lots of information and never stop if | ||
77 | used on the wrong slab. | ||
78 | |||
79 | SLAB Merging | ||
80 | ------------ | ||
81 | |||
82 | If no debugging is specified then SLUB may merge similar slabs together | ||
83 | in order to reduce overhead and increase cache hotness of objects. | ||
84 | slabinfo -a displays which slabs were merged together. | ||
85 | |||
86 | Getting more performance | ||
87 | ------------------------ | ||
88 | |||
89 | To some degree SLUB's performance is limited by the need to take the | ||
90 | list_lock once in a while to deal with partial slabs. That overhead is | ||
91 | governed by the order of the allocation for each slab. The allocations | ||
92 | can be influenced by kernel parameters: | ||
93 | |||
94 | slub_min_objects=x (default 8) | ||
95 | slub_min_order=x (default 0) | ||
96 | slub_max_order=x (default 4) | ||
97 | |||
98 | slub_min_objects allows to specify how many objects must at least fit | ||
99 | into one slab in order for the allocation order to be acceptable. | ||
100 | In general slub will be able to perform this number of allocations | ||
101 | on a slab without consulting centralized resources (list_lock) where | ||
102 | contention may occur. | ||
103 | |||
104 | slub_min_order specifies a minim order of slabs. A similar effect like | ||
105 | slub_min_objects. | ||
106 | |||
107 | slub_max_order specified the order at which slub_min_objects should no | ||
108 | longer be checked. This is useful to avoid SLUB trying to generate | ||
109 | super large order pages to fit slub_min_objects of a slab cache with | ||
110 | large object sizes into one high order page. | ||
111 | |||
112 | |||
113 | Christoph Lameter, <clameter@sgi.com>, April 10, 2007 | ||