diff options
117 files changed, 4680 insertions, 658 deletions
diff --git a/Documentation/00-INDEX b/Documentation/00-INDEX index 6e9c4050a41b..8d556707bb68 100644 --- a/Documentation/00-INDEX +++ b/Documentation/00-INDEX | |||
@@ -227,6 +227,8 @@ kref.txt | |||
227 | - docs on adding reference counters (krefs) to kernel objects. | 227 | - docs on adding reference counters (krefs) to kernel objects. |
228 | laptop-mode.txt | 228 | laptop-mode.txt |
229 | - how to conserve battery power using laptop-mode. | 229 | - how to conserve battery power using laptop-mode. |
230 | laptops/ | ||
231 | - directory with laptop related info and laptop driver documentation. | ||
230 | ldm.txt | 232 | ldm.txt |
231 | - a brief description of LDM (Windows Dynamic Disks). | 233 | - a brief description of LDM (Windows Dynamic Disks). |
232 | leds-class.txt | 234 | leds-class.txt |
@@ -351,10 +353,6 @@ sh/ | |||
351 | - directory with info on porting Linux to a new architecture. | 353 | - directory with info on porting Linux to a new architecture. |
352 | smart-config.txt | 354 | smart-config.txt |
353 | - description of the Smart Config makefile feature. | 355 | - description of the Smart Config makefile feature. |
354 | sony-laptop.txt | ||
355 | - Sony Notebook Control Driver (SNC) Readme. | ||
356 | sonypi.txt | ||
357 | - info on Linux Sony Programmable I/O Device support. | ||
358 | sound/ | 356 | sound/ |
359 | - directory with info on sound card support. | 357 | - directory with info on sound card support. |
360 | sparc/ | 358 | sparc/ |
@@ -385,8 +383,6 @@ sysrq.txt | |||
385 | - info on the magic SysRq key. | 383 | - info on the magic SysRq key. |
386 | telephony/ | 384 | telephony/ |
387 | - directory with info on telephony (e.g. voice over IP) support. | 385 | - directory with info on telephony (e.g. voice over IP) support. |
388 | thinkpad-acpi.txt | ||
389 | - information on the (IBM and Lenovo) ThinkPad ACPI Extras driver. | ||
390 | time_interpolators.txt | 386 | time_interpolators.txt |
391 | - info on time interpolators. | 387 | - info on time interpolators. |
392 | tipar.txt | 388 | tipar.txt |
diff --git a/Documentation/laptops/00-INDEX b/Documentation/laptops/00-INDEX new file mode 100644 index 000000000000..729c2c062e10 --- /dev/null +++ b/Documentation/laptops/00-INDEX | |||
@@ -0,0 +1,10 @@ | |||
1 | 00-INDEX | ||
2 | - This file | ||
3 | acer-wmi.txt | ||
4 | - information on the Acer Laptop WMI Extras driver. | ||
5 | sony-laptop.txt | ||
6 | - Sony Notebook Control Driver (SNC) Readme. | ||
7 | sonypi.txt | ||
8 | - info on Linux Sony Programmable I/O Device support. | ||
9 | thinkpad-acpi.txt | ||
10 | - information on the (IBM and Lenovo) ThinkPad ACPI Extras driver. | ||
diff --git a/Documentation/laptops/acer-wmi.txt b/Documentation/laptops/acer-wmi.txt new file mode 100644 index 000000000000..b06696329cff --- /dev/null +++ b/Documentation/laptops/acer-wmi.txt | |||
@@ -0,0 +1,202 @@ | |||
1 | Acer Laptop WMI Extras Driver | ||
2 | http://code.google.com/p/aceracpi | ||
3 | Version 0.1 | ||
4 | 9th February 2008 | ||
5 | |||
6 | Copyright 2007-2008 Carlos Corbacho <carlos@strangeworlds.co.uk> | ||
7 | |||
8 | acer-wmi is a driver to allow you to control various parts of your Acer laptop | ||
9 | hardware under Linux which are exposed via ACPI-WMI. | ||
10 | |||
11 | This driver completely replaces the old out-of-tree acer_acpi, which I am | ||
12 | currently maintaining for bug fixes only on pre-2.6.25 kernels. All development | ||
13 | work is now focused solely on acer-wmi. | ||
14 | |||
15 | Disclaimer | ||
16 | ********** | ||
17 | |||
18 | Acer and Wistron have provided nothing towards the development acer_acpi or | ||
19 | acer-wmi. All information we have has been through the efforts of the developers | ||
20 | and the users to discover as much as possible about the hardware. | ||
21 | |||
22 | As such, I do warn that this could break your hardware - this is extremely | ||
23 | unlikely of course, but please bear this in mind. | ||
24 | |||
25 | Background | ||
26 | ********** | ||
27 | |||
28 | acer-wmi is derived from acer_acpi, originally developed by Mark | ||
29 | Smith in 2005, then taken over by Carlos Corbacho in 2007, in order to activate | ||
30 | the wireless LAN card under a 64-bit version of Linux, as acerhk[1] (the | ||
31 | previous solution to the problem) relied on making 32 bit BIOS calls which are | ||
32 | not possible in kernel space from a 64 bit OS. | ||
33 | |||
34 | [1] acerhk: http://www.cakey.de/acerhk/ | ||
35 | |||
36 | Supported Hardware | ||
37 | ****************** | ||
38 | |||
39 | Please see the website for the current list of known working hardare: | ||
40 | |||
41 | http://code.google.com/p/aceracpi/wiki/SupportedHardware | ||
42 | |||
43 | If your laptop is not listed, or listed as unknown, and works with acer-wmi, | ||
44 | please contact me with a copy of the DSDT. | ||
45 | |||
46 | If your Acer laptop doesn't work with acer-wmi, I would also like to see the | ||
47 | DSDT. | ||
48 | |||
49 | To send me the DSDT, as root/sudo: | ||
50 | |||
51 | cat /sys/firmware/acpi/DSDT > dsdt | ||
52 | |||
53 | And send me the resulting 'dsdt' file. | ||
54 | |||
55 | Usage | ||
56 | ***** | ||
57 | |||
58 | On Acer laptops, acer-wmi should already be autoloaded based on DMI matching. | ||
59 | For non-Acer laptops, until WMI based autoloading support is added, you will | ||
60 | need to manually load acer-wmi. | ||
61 | |||
62 | acer-wmi creates /sys/devices/platform/acer-wmi, and fills it with various | ||
63 | files whose usage is detailed below, which enables you to control some of the | ||
64 | following (varies between models): | ||
65 | |||
66 | * the wireless LAN card radio | ||
67 | * inbuilt Bluetooth adapter | ||
68 | * inbuilt 3G card | ||
69 | * mail LED of your laptop | ||
70 | * brightness of the LCD panel | ||
71 | |||
72 | Wireless | ||
73 | ******** | ||
74 | |||
75 | With regards to wireless, all acer-wmi does is enable the radio on the card. It | ||
76 | is not responsible for the wireless LED - once the radio is enabled, this is | ||
77 | down to the wireless driver for your card. So the behaviour of the wireless LED, | ||
78 | once you enable the radio, will depend on your hardware and driver combination. | ||
79 | |||
80 | e.g. With the BCM4318 on the Acer Aspire 5020 series: | ||
81 | |||
82 | ndiswrapper: Light blinks on when transmitting | ||
83 | bcm43xx/b43: Solid light, blinks off when transmitting | ||
84 | |||
85 | Wireless radio control is unconditionally enabled - all Acer laptops that support | ||
86 | acer-wmi come with built-in wireless. However, should you feel so inclined to | ||
87 | ever wish to remove the card, or swap it out at some point, please get in touch | ||
88 | with me, as we may well be able to gain some data on wireless card detection. | ||
89 | |||
90 | To read the status of the wireless radio (0=off, 1=on): | ||
91 | cat /sys/devices/platform/acer-wmi/wireless | ||
92 | |||
93 | To enable the wireless radio: | ||
94 | echo 1 > /sys/devices/platform/acer-wmi/wireless | ||
95 | |||
96 | To disable the wireless radio: | ||
97 | echo 0 > /sys/devices/platform/acer-wmi/wireless | ||
98 | |||
99 | To set the state of the wireless radio when loading acer-wmi, pass: | ||
100 | wireless=X (where X is 0 or 1) | ||
101 | |||
102 | Bluetooth | ||
103 | ********* | ||
104 | |||
105 | For bluetooth, this is an internal USB dongle, so once enabled, you will get | ||
106 | a USB device connection event, and a new USB device appears. When you disable | ||
107 | bluetooth, you get the reverse - a USB device disconnect event, followed by the | ||
108 | device disappearing again. | ||
109 | |||
110 | Bluetooth is autodetected by acer-wmi, so if you do not have a bluetooth module | ||
111 | installed in your laptop, this file won't exist (please be aware that it is | ||
112 | quite common for Acer not to fit bluetooth to their laptops - so just because | ||
113 | you have a bluetooth button on the laptop, doesn't mean that bluetooth is | ||
114 | installed). | ||
115 | |||
116 | For the adventurously minded - if you want to buy an internal bluetooth | ||
117 | module off the internet that is compatible with your laptop and fit it, then | ||
118 | it will work just fine with acer-wmi. | ||
119 | |||
120 | To read the status of the bluetooth module (0=off, 1=on): | ||
121 | cat /sys/devices/platform/acer-wmi/wireless | ||
122 | |||
123 | To enable the bluetooth module: | ||
124 | echo 1 > /sys/devices/platform/acer-wmi/bluetooth | ||
125 | |||
126 | To disable the bluetooth module: | ||
127 | echo 0 > /sys/devices/platform/acer-wmi/bluetooth | ||
128 | |||
129 | To set the state of the bluetooth module when loading acer-wmi, pass: | ||
130 | bluetooth=X (where X is 0 or 1) | ||
131 | |||
132 | 3G | ||
133 | ** | ||
134 | |||
135 | 3G is currently not autodetected, so the 'threeg' file is always created under | ||
136 | sysfs. So far, no-one in possession of an Acer laptop with 3G built-in appears to | ||
137 | have tried Linux, or reported back, so we don't have any information on this. | ||
138 | |||
139 | If you have an Acer laptop that does have a 3G card in, please contact me so we | ||
140 | can properly detect these, and find out a bit more about them. | ||
141 | |||
142 | To read the status of the 3G card (0=off, 1=on): | ||
143 | cat /sys/devices/platform/acer-wmi/threeg | ||
144 | |||
145 | To enable the 3G card: | ||
146 | echo 1 > /sys/devices/platform/acer-wmi/threeg | ||
147 | |||
148 | To disable the 3G card: | ||
149 | echo 0 > /sys/devices/platform/acer-wmi/threeg | ||
150 | |||
151 | To set the state of the 3G card when loading acer-wmi, pass: | ||
152 | threeg=X (where X is 0 or 1) | ||
153 | |||
154 | Mail LED | ||
155 | ******** | ||
156 | |||
157 | This can be found in most older Acer laptops supported by acer-wmi, and many | ||
158 | newer ones - it is built into the 'mail' button, and blinks when active. | ||
159 | |||
160 | On newer (WMID) laptops though, we have no way of detecting the mail LED. If | ||
161 | your laptop identifies itself in dmesg as a WMID model, then please try loading | ||
162 | acer_acpi with: | ||
163 | |||
164 | force_series=2490 | ||
165 | |||
166 | This will use a known alternative method of reading/ writing the mail LED. If | ||
167 | it works, please report back to me with the DMI data from your laptop so this | ||
168 | can be added to acer-wmi. | ||
169 | |||
170 | The LED is exposed through the LED subsystem, and can be found in: | ||
171 | |||
172 | /sys/devices/platform/acer-wmi/leds/acer-mail:green/ | ||
173 | |||
174 | The mail LED is autodetected, so if you don't have one, the LED device won't | ||
175 | be registered. | ||
176 | |||
177 | If you have a mail LED that is not green, please report this to me. | ||
178 | |||
179 | Backlight | ||
180 | ********* | ||
181 | |||
182 | The backlight brightness control is available on all acer-wmi supported | ||
183 | hardware. The maximum brightness level is usually 15, but on some newer laptops | ||
184 | it's 10 (this is again autodetected). | ||
185 | |||
186 | The backlight is exposed through the backlight subsystem, and can be found in: | ||
187 | |||
188 | /sys/devices/platform/acer-wmi/backlight/acer-wmi/ | ||
189 | |||
190 | Credits | ||
191 | ******* | ||
192 | |||
193 | Olaf Tauber, who did the real hard work when he developed acerhk | ||
194 | http://www.informatik.hu-berlin.de/~tauber/acerhk | ||
195 | All the authors of laptop ACPI modules in the kernel, whose work | ||
196 | was an inspiration in the early days of acer_acpi | ||
197 | Mathieu Segaud, who solved the problem with having to modprobe the driver | ||
198 | twice in acer_acpi 0.2. | ||
199 | Jim Ramsay, who added support for the WMID interface | ||
200 | Mark Smith, who started the original acer_acpi | ||
201 | |||
202 | And the many people who have used both acer_acpi and acer-wmi. | ||
diff --git a/Documentation/sony-laptop.txt b/Documentation/laptops/sony-laptop.txt index 7a5c1a81905c..8b2bc1572d98 100644 --- a/Documentation/sony-laptop.txt +++ b/Documentation/laptops/sony-laptop.txt | |||
@@ -114,4 +114,3 @@ Bugs/Limitations: | |||
114 | sonypi driver (through /dev/sonypi) does not try to use the | 114 | sonypi driver (through /dev/sonypi) does not try to use the |
115 | sony-laptop driver. In the future, spicctrl could try sonypi first, | 115 | sony-laptop driver. In the future, spicctrl could try sonypi first, |
116 | and if it isn't present, try sony-laptop instead. | 116 | and if it isn't present, try sony-laptop instead. |
117 | |||
diff --git a/Documentation/sonypi.txt b/Documentation/laptops/sonypi.txt index 4857acfc50f1..4857acfc50f1 100644 --- a/Documentation/sonypi.txt +++ b/Documentation/laptops/sonypi.txt | |||
diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt index 6c2477754a2a..6c2477754a2a 100644 --- a/Documentation/thinkpad-acpi.txt +++ b/Documentation/laptops/thinkpad-acpi.txt | |||
diff --git a/MAINTAINERS b/MAINTAINERS index 0d6f5119a6da..c40f0ae96552 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -2682,7 +2682,6 @@ MOTOROLA IMX MMC/SD HOST CONTROLLER INTERFACE DRIVER | |||
2682 | P: Pavel Pisa | 2682 | P: Pavel Pisa |
2683 | M: ppisa@pikron.com | 2683 | M: ppisa@pikron.com |
2684 | L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only) | 2684 | L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only) |
2685 | W: http://mmc.drzeus.cx/wiki/Controllers/Freescale/SDHC | ||
2686 | S: Maintained | 2685 | S: Maintained |
2687 | 2686 | ||
2688 | MOUSE AND MISC DEVICES [GENERAL] | 2687 | MOUSE AND MISC DEVICES [GENERAL] |
@@ -3627,6 +3626,13 @@ L: linux-acpi@vger.kernel.org | |||
3627 | W: http://www.linux.it/~malattia/wiki/index.php/Sony_drivers | 3626 | W: http://www.linux.it/~malattia/wiki/index.php/Sony_drivers |
3628 | S: Maintained | 3627 | S: Maintained |
3629 | 3628 | ||
3629 | SONY MEMORYSTICK CARD SUPPORT | ||
3630 | P: Alex Dubov | ||
3631 | M: oakad@yahoo.com | ||
3632 | L: linux-kernel@vger.kernel.org | ||
3633 | W: http://tifmxx.berlios.de/ | ||
3634 | S: Maintained | ||
3635 | |||
3630 | SOUND | 3636 | SOUND |
3631 | P: Jaroslav Kysela | 3637 | P: Jaroslav Kysela |
3632 | M: perex@perex.cz | 3638 | M: perex@perex.cz |
@@ -3709,7 +3715,6 @@ SECURE DIGITAL HOST CONTROLLER INTERFACE DRIVER | |||
3709 | P: Pierre Ossman | 3715 | P: Pierre Ossman |
3710 | M: drzeus-sdhci@drzeus.cx | 3716 | M: drzeus-sdhci@drzeus.cx |
3711 | L: sdhci-devel@list.drzeus.cx | 3717 | L: sdhci-devel@list.drzeus.cx |
3712 | W: http://mmc.drzeus.cx/wiki/Linux/Drivers/sdhci | ||
3713 | S: Maintained | 3718 | S: Maintained |
3714 | 3719 | ||
3715 | SKGE, SKY2 10/100/1000 GIGABIT ETHERNET DRIVERS | 3720 | SKGE, SKY2 10/100/1000 GIGABIT ETHERNET DRIVERS |
@@ -4279,7 +4284,6 @@ W83L51xD SD/MMC CARD INTERFACE DRIVER | |||
4279 | P: Pierre Ossman | 4284 | P: Pierre Ossman |
4280 | M: drzeus-wbsd@drzeus.cx | 4285 | M: drzeus-wbsd@drzeus.cx |
4281 | L: linux-kernel@vger.kernel.org | 4286 | L: linux-kernel@vger.kernel.org |
4282 | W: http://projects.drzeus.cx/wbsd | ||
4283 | S: Maintained | 4287 | S: Maintained |
4284 | 4288 | ||
4285 | WATCHDOG DEVICE DRIVERS | 4289 | WATCHDOG DEVICE DRIVERS |
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index 5b7dcd5a0e75..002703b8c0b0 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig | |||
@@ -5,6 +5,7 @@ | |||
5 | config ALPHA | 5 | config ALPHA |
6 | bool | 6 | bool |
7 | default y | 7 | default y |
8 | select HAVE_IDE | ||
8 | select HAVE_OPROFILE | 9 | select HAVE_OPROFILE |
9 | help | 10 | help |
10 | The Alpha is a 64-bit general-purpose processor designed and | 11 | The Alpha is a 64-bit general-purpose processor designed and |
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 4127af93c5f3..9619c43783ff 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -222,6 +222,7 @@ config ARCH_CLPS7500 | |||
222 | select TIMER_ACORN | 222 | select TIMER_ACORN |
223 | select ISA | 223 | select ISA |
224 | select NO_IOPORT | 224 | select NO_IOPORT |
225 | select HAVE_IDE | ||
225 | help | 226 | help |
226 | Support for the Cirrus Logic PS7500FE system-on-a-chip. | 227 | Support for the Cirrus Logic PS7500FE system-on-a-chip. |
227 | 228 | ||
@@ -234,6 +235,7 @@ config ARCH_CO285 | |||
234 | bool "Co-EBSA285" | 235 | bool "Co-EBSA285" |
235 | select FOOTBRIDGE | 236 | select FOOTBRIDGE |
236 | select FOOTBRIDGE_ADDIN | 237 | select FOOTBRIDGE_ADDIN |
238 | select HAVE_IDE | ||
237 | help | 239 | help |
238 | Support for Intel's EBSA285 companion chip. | 240 | Support for Intel's EBSA285 companion chip. |
239 | 241 | ||
@@ -258,6 +260,7 @@ config ARCH_EP93XX | |||
258 | config ARCH_FOOTBRIDGE | 260 | config ARCH_FOOTBRIDGE |
259 | bool "FootBridge" | 261 | bool "FootBridge" |
260 | select FOOTBRIDGE | 262 | select FOOTBRIDGE |
263 | select HAVE_IDE | ||
261 | help | 264 | help |
262 | Support for systems based on the DC21285 companion chip | 265 | Support for systems based on the DC21285 companion chip |
263 | ("FootBridge"), such as the Simtec CATS and the Rebel NetWinder. | 266 | ("FootBridge"), such as the Simtec CATS and the Rebel NetWinder. |
@@ -296,6 +299,7 @@ config ARCH_IOP32X | |||
296 | depends on MMU | 299 | depends on MMU |
297 | select PLAT_IOP | 300 | select PLAT_IOP |
298 | select PCI | 301 | select PCI |
302 | select HAVE_IDE | ||
299 | help | 303 | help |
300 | Support for Intel's 80219 and IOP32X (XScale) family of | 304 | Support for Intel's 80219 and IOP32X (XScale) family of |
301 | processors. | 305 | processors. |
@@ -305,12 +309,14 @@ config ARCH_IOP33X | |||
305 | depends on MMU | 309 | depends on MMU |
306 | select PLAT_IOP | 310 | select PLAT_IOP |
307 | select PCI | 311 | select PCI |
312 | select HAVE_IDE | ||
308 | help | 313 | help |
309 | Support for Intel's IOP33X (XScale) family of processors. | 314 | Support for Intel's IOP33X (XScale) family of processors. |
310 | 315 | ||
311 | config ARCH_IXP23XX | 316 | config ARCH_IXP23XX |
312 | bool "IXP23XX-based" | 317 | bool "IXP23XX-based" |
313 | depends on MMU | 318 | depends on MMU |
319 | select HAVE_IDE | ||
314 | select PCI | 320 | select PCI |
315 | help | 321 | help |
316 | Support for Intel's IXP23xx (XScale) family of processors. | 322 | Support for Intel's IXP23xx (XScale) family of processors. |
@@ -328,12 +334,14 @@ config ARCH_IXP4XX | |||
328 | select GENERIC_GPIO | 334 | select GENERIC_GPIO |
329 | select GENERIC_TIME | 335 | select GENERIC_TIME |
330 | select GENERIC_CLOCKEVENTS | 336 | select GENERIC_CLOCKEVENTS |
337 | select HAVE_IDE | ||
331 | help | 338 | help |
332 | Support for Intel's IXP4XX (XScale) family of processors. | 339 | Support for Intel's IXP4XX (XScale) family of processors. |
333 | 340 | ||
334 | config ARCH_L7200 | 341 | config ARCH_L7200 |
335 | bool "LinkUp-L7200" | 342 | bool "LinkUp-L7200" |
336 | select FIQ | 343 | select FIQ |
344 | select HAVE_IDE | ||
337 | help | 345 | help |
338 | Say Y here if you intend to run this kernel on a LinkUp Systems | 346 | Say Y here if you intend to run this kernel on a LinkUp Systems |
339 | L7200 Software Development Board which uses an ARM720T processor. | 347 | L7200 Software Development Board which uses an ARM720T processor. |
@@ -388,6 +396,7 @@ config ARCH_PXA | |||
388 | depends on MMU | 396 | depends on MMU |
389 | select ARCH_MTD_XIP | 397 | select ARCH_MTD_XIP |
390 | select GENERIC_GPIO | 398 | select GENERIC_GPIO |
399 | select HAVE_IDE | ||
391 | select HAVE_GPIO_LIB | 400 | select HAVE_GPIO_LIB |
392 | select GENERIC_TIME | 401 | select GENERIC_TIME |
393 | select GENERIC_CLOCKEVENTS | 402 | select GENERIC_CLOCKEVENTS |
@@ -403,6 +412,7 @@ config ARCH_RPC | |||
403 | select ARCH_MAY_HAVE_PC_FDC | 412 | select ARCH_MAY_HAVE_PC_FDC |
404 | select ISA_DMA_API | 413 | select ISA_DMA_API |
405 | select NO_IOPORT | 414 | select NO_IOPORT |
415 | select HAVE_IDE | ||
406 | help | 416 | help |
407 | On the Acorn Risc-PC, Linux can support the internal IDE disk and | 417 | On the Acorn Risc-PC, Linux can support the internal IDE disk and |
408 | CD-ROM interface, serial and parallel port, and the floppy drive. | 418 | CD-ROM interface, serial and parallel port, and the floppy drive. |
@@ -414,12 +424,14 @@ config ARCH_SA1100 | |||
414 | select ARCH_MTD_XIP | 424 | select ARCH_MTD_XIP |
415 | select GENERIC_GPIO | 425 | select GENERIC_GPIO |
416 | select GENERIC_TIME | 426 | select GENERIC_TIME |
427 | select HAVE_IDE | ||
417 | help | 428 | help |
418 | Support for StrongARM 11x0 based boards. | 429 | Support for StrongARM 11x0 based boards. |
419 | 430 | ||
420 | config ARCH_S3C2410 | 431 | config ARCH_S3C2410 |
421 | bool "Samsung S3C2410, S3C2412, S3C2413, S3C2440, S3C2442, S3C2443" | 432 | bool "Samsung S3C2410, S3C2412, S3C2413, S3C2440, S3C2442, S3C2443" |
422 | select GENERIC_GPIO | 433 | select GENERIC_GPIO |
434 | select HAVE_IDE | ||
423 | help | 435 | help |
424 | Samsung S3C2410X CPU based systems, such as the Simtec Electronics | 436 | Samsung S3C2410X CPU based systems, such as the Simtec Electronics |
425 | BAST (<http://www.simtec.co.uk/products/EB110ITX/>), the IPAQ 1940 or | 437 | BAST (<http://www.simtec.co.uk/products/EB110ITX/>), the IPAQ 1940 or |
@@ -427,6 +439,7 @@ config ARCH_S3C2410 | |||
427 | 439 | ||
428 | config ARCH_SHARK | 440 | config ARCH_SHARK |
429 | bool "Shark" | 441 | bool "Shark" |
442 | select HAVE_IDE | ||
430 | select ISA | 443 | select ISA |
431 | select ISA_DMA | 444 | select ISA_DMA |
432 | select PCI | 445 | select PCI |
@@ -436,6 +449,7 @@ config ARCH_SHARK | |||
436 | 449 | ||
437 | config ARCH_LH7A40X | 450 | config ARCH_LH7A40X |
438 | bool "Sharp LH7A40X" | 451 | bool "Sharp LH7A40X" |
452 | select HAVE_IDE | ||
439 | help | 453 | help |
440 | Say Y here for systems based on one of the Sharp LH7A40X | 454 | Say Y here for systems based on one of the Sharp LH7A40X |
441 | System on a Chip processors. These CPUs include an ARM922T | 455 | System on a Chip processors. These CPUs include an ARM922T |
@@ -1093,12 +1107,7 @@ source "drivers/block/Kconfig" | |||
1093 | 1107 | ||
1094 | source "drivers/misc/Kconfig" | 1108 | source "drivers/misc/Kconfig" |
1095 | 1109 | ||
1096 | if PCMCIA || ARCH_CLPS7500 || ARCH_IOP32X || ARCH_IOP33X || ARCH_IXP4XX \ | ||
1097 | || ARCH_L7200 || ARCH_LH7A40X || ARCH_PXA || ARCH_RPC \ | ||
1098 | || ARCH_S3C2410 || ARCH_SA1100 || ARCH_SHARK || FOOTBRIDGE \ | ||
1099 | || ARCH_IXP23XX | ||
1100 | source "drivers/ide/Kconfig" | 1110 | source "drivers/ide/Kconfig" |
1101 | endif | ||
1102 | 1111 | ||
1103 | source "drivers/scsi/Kconfig" | 1112 | source "drivers/scsi/Kconfig" |
1104 | 1113 | ||
diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig index 28e0caf4156c..c75d7089f982 100644 --- a/arch/avr32/Kconfig +++ b/arch/avr32/Kconfig | |||
@@ -10,6 +10,7 @@ config AVR32 | |||
10 | # With EMBEDDED=n, we get lots of stuff automatically selected | 10 | # With EMBEDDED=n, we get lots of stuff automatically selected |
11 | # that we usually don't need on AVR32. | 11 | # that we usually don't need on AVR32. |
12 | select EMBEDDED | 12 | select EMBEDDED |
13 | select HAVE_IDE | ||
13 | select HAVE_OPROFILE | 14 | select HAVE_OPROFILE |
14 | select HAVE_KPROBES | 15 | select HAVE_KPROBES |
15 | help | 16 | help |
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig index 368bc7fe167e..589c6aca4803 100644 --- a/arch/blackfin/Kconfig +++ b/arch/blackfin/Kconfig | |||
@@ -24,6 +24,7 @@ config RWSEM_XCHGADD_ALGORITHM | |||
24 | config BLACKFIN | 24 | config BLACKFIN |
25 | bool | 25 | bool |
26 | default y | 26 | default y |
27 | select HAVE_IDE | ||
27 | select HAVE_OPROFILE | 28 | select HAVE_OPROFILE |
28 | 29 | ||
29 | config ZONE_DMA | 30 | config ZONE_DMA |
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig index 8456bc8efb7c..9389d38f222f 100644 --- a/arch/cris/Kconfig +++ b/arch/cris/Kconfig | |||
@@ -54,6 +54,7 @@ config FORCE_MAX_ZONEORDER | |||
54 | config CRIS | 54 | config CRIS |
55 | bool | 55 | bool |
56 | default y | 56 | default y |
57 | select HAVE_IDE | ||
57 | 58 | ||
58 | config HZ | 59 | config HZ |
59 | int | 60 | int |
diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig index 9e561ede0925..a5aac1b07562 100644 --- a/arch/frv/Kconfig +++ b/arch/frv/Kconfig | |||
@@ -5,6 +5,7 @@ | |||
5 | config FRV | 5 | config FRV |
6 | bool | 6 | bool |
7 | default y | 7 | default y |
8 | select HAVE_IDE | ||
8 | 9 | ||
9 | config ZONE_DMA | 10 | config ZONE_DMA |
10 | bool | 11 | bool |
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig index f69e5ea38558..085dc6ec152b 100644 --- a/arch/h8300/Kconfig +++ b/arch/h8300/Kconfig | |||
@@ -8,6 +8,7 @@ mainmenu "uClinux/h8300 (w/o MMU) Kernel Configuration" | |||
8 | config H8300 | 8 | config H8300 |
9 | bool | 9 | bool |
10 | default y | 10 | default y |
11 | select HAVE_IDE | ||
11 | 12 | ||
12 | config MMU | 13 | config MMU |
13 | bool | 14 | bool |
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index b0de1132dfc0..2d4fcd01bc91 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig | |||
@@ -15,6 +15,7 @@ config IA64 | |||
15 | select ACPI if (!IA64_HP_SIM) | 15 | select ACPI if (!IA64_HP_SIM) |
16 | select PM if (!IA64_HP_SIM) | 16 | select PM if (!IA64_HP_SIM) |
17 | select ARCH_SUPPORTS_MSI | 17 | select ARCH_SUPPORTS_MSI |
18 | select HAVE_IDE | ||
18 | select HAVE_OPROFILE | 19 | select HAVE_OPROFILE |
19 | select HAVE_KPROBES | 20 | select HAVE_KPROBES |
20 | default y | 21 | default y |
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index d4679ab55b96..de153de2ea9f 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig | |||
@@ -8,6 +8,7 @@ mainmenu "Linux/M32R Kernel Configuration" | |||
8 | config M32R | 8 | config M32R |
9 | bool | 9 | bool |
10 | default y | 10 | default y |
11 | select HAVE_IDE | ||
11 | select HAVE_OPROFILE | 12 | select HAVE_OPROFILE |
12 | 13 | ||
13 | config SBUS | 14 | config SBUS |
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index 2b0ed89cd173..65db2261b9ea 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig | |||
@@ -5,6 +5,7 @@ | |||
5 | config M68K | 5 | config M68K |
6 | bool | 6 | bool |
7 | default y | 7 | default y |
8 | select HAVE_IDE | ||
8 | 9 | ||
9 | config MMU | 10 | config MMU |
10 | bool | 11 | bool |
diff --git a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig index 548a7b321633..07eb4c4bab82 100644 --- a/arch/m68knommu/Kconfig +++ b/arch/m68knommu/Kconfig | |||
@@ -8,6 +8,7 @@ mainmenu "uClinux/68k (w/o MMU) Kernel Configuration" | |||
8 | config M68K | 8 | config M68K |
9 | bool | 9 | bool |
10 | default y | 10 | default y |
11 | select HAVE_IDE | ||
11 | 12 | ||
12 | config MMU | 13 | config MMU |
13 | bool | 14 | bool |
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index ec78a5762e9e..ade230d445d9 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
@@ -1,6 +1,7 @@ | |||
1 | config MIPS | 1 | config MIPS |
2 | bool | 2 | bool |
3 | default y | 3 | default y |
4 | select HAVE_IDE | ||
4 | select HAVE_OPROFILE | 5 | select HAVE_OPROFILE |
5 | # Horrible source of confusion. Die, die, die ... | 6 | # Horrible source of confusion. Die, die, die ... |
6 | select EMBEDDED | 7 | select EMBEDDED |
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index d929ac84f25a..bc7a19da6245 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig | |||
@@ -7,6 +7,7 @@ mainmenu "Linux/PA-RISC Kernel Configuration" | |||
7 | 7 | ||
8 | config PARISC | 8 | config PARISC |
9 | def_bool y | 9 | def_bool y |
10 | select HAVE_IDE | ||
10 | select HAVE_OPROFILE | 11 | select HAVE_OPROFILE |
11 | help | 12 | help |
12 | The PA-RISC microprocessor is designed by Hewlett-Packard and used | 13 | The PA-RISC microprocessor is designed by Hewlett-Packard and used |
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 26b963c33c88..485513c9f1af 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
@@ -87,6 +87,7 @@ config ARCH_NO_VIRT_TO_BUS | |||
87 | config PPC | 87 | config PPC |
88 | bool | 88 | bool |
89 | default y | 89 | default y |
90 | select HAVE_IDE | ||
90 | select HAVE_OPROFILE | 91 | select HAVE_OPROFILE |
91 | select HAVE_KPROBES | 92 | select HAVE_KPROBES |
92 | 93 | ||
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig index 531156f8919c..abc877faf123 100644 --- a/arch/ppc/Kconfig +++ b/arch/ppc/Kconfig | |||
@@ -42,6 +42,7 @@ config GENERIC_CALIBRATE_DELAY | |||
42 | config PPC | 42 | config PPC |
43 | bool | 43 | bool |
44 | default y | 44 | default y |
45 | select HAVE_IDE | ||
45 | select HAVE_OPROFILE | 46 | select HAVE_OPROFILE |
46 | select HAVE_KPROBES | 47 | select HAVE_KPROBES |
47 | 48 | ||
diff --git a/arch/s390/defconfig b/arch/s390/defconfig index ece7b99da895..39921f3a9685 100644 --- a/arch/s390/defconfig +++ b/arch/s390/defconfig | |||
@@ -1,12 +1,13 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Linux kernel version: 2.6.23 | 3 | # Linux kernel version: 2.6.24 |
4 | # Mon Oct 22 12:10:44 2007 | 4 | # Sat Feb 9 12:13:01 2008 |
5 | # | 5 | # |
6 | CONFIG_MMU=y | 6 | CONFIG_MMU=y |
7 | CONFIG_ZONE_DMA=y | 7 | CONFIG_ZONE_DMA=y |
8 | CONFIG_LOCKDEP_SUPPORT=y | 8 | CONFIG_LOCKDEP_SUPPORT=y |
9 | CONFIG_STACKTRACE_SUPPORT=y | 9 | CONFIG_STACKTRACE_SUPPORT=y |
10 | CONFIG_HAVE_LATENCYTOP_SUPPORT=y | ||
10 | CONFIG_RWSEM_XCHGADD_ALGORITHM=y | 11 | CONFIG_RWSEM_XCHGADD_ALGORITHM=y |
11 | # CONFIG_ARCH_HAS_ILOG2_U32 is not set | 12 | # CONFIG_ARCH_HAS_ILOG2_U32 is not set |
12 | # CONFIG_ARCH_HAS_ILOG2_U64 is not set | 13 | # CONFIG_ARCH_HAS_ILOG2_U64 is not set |
@@ -15,6 +16,7 @@ CONFIG_GENERIC_TIME=y | |||
15 | CONFIG_GENERIC_BUG=y | 16 | CONFIG_GENERIC_BUG=y |
16 | CONFIG_NO_IOMEM=y | 17 | CONFIG_NO_IOMEM=y |
17 | CONFIG_NO_DMA=y | 18 | CONFIG_NO_DMA=y |
19 | CONFIG_GENERIC_LOCKBREAK=y | ||
18 | CONFIG_S390=y | 20 | CONFIG_S390=y |
19 | CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" | 21 | CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" |
20 | 22 | ||
@@ -32,7 +34,6 @@ CONFIG_SYSVIPC_SYSCTL=y | |||
32 | CONFIG_POSIX_MQUEUE=y | 34 | CONFIG_POSIX_MQUEUE=y |
33 | # CONFIG_BSD_PROCESS_ACCT is not set | 35 | # CONFIG_BSD_PROCESS_ACCT is not set |
34 | # CONFIG_TASKSTATS is not set | 36 | # CONFIG_TASKSTATS is not set |
35 | # CONFIG_USER_NS is not set | ||
36 | CONFIG_AUDIT=y | 37 | CONFIG_AUDIT=y |
37 | # CONFIG_AUDITSYSCALL is not set | 38 | # CONFIG_AUDITSYSCALL is not set |
38 | CONFIG_IKCONFIG=y | 39 | CONFIG_IKCONFIG=y |
@@ -41,13 +42,19 @@ CONFIG_LOG_BUF_SHIFT=17 | |||
41 | CONFIG_CGROUPS=y | 42 | CONFIG_CGROUPS=y |
42 | # CONFIG_CGROUP_DEBUG is not set | 43 | # CONFIG_CGROUP_DEBUG is not set |
43 | CONFIG_CGROUP_NS=y | 44 | CONFIG_CGROUP_NS=y |
44 | CONFIG_CGROUP_CPUACCT=y | ||
45 | # CONFIG_CPUSETS is not set | 45 | # CONFIG_CPUSETS is not set |
46 | CONFIG_FAIR_GROUP_SCHED=y | 46 | CONFIG_FAIR_GROUP_SCHED=y |
47 | CONFIG_FAIR_USER_SCHED=y | 47 | CONFIG_FAIR_USER_SCHED=y |
48 | # CONFIG_FAIR_CGROUP_SCHED is not set | 48 | # CONFIG_FAIR_CGROUP_SCHED is not set |
49 | # CONFIG_CGROUP_CPUACCT is not set | ||
50 | # CONFIG_RESOURCE_COUNTERS is not set | ||
49 | CONFIG_SYSFS_DEPRECATED=y | 51 | CONFIG_SYSFS_DEPRECATED=y |
50 | # CONFIG_RELAY is not set | 52 | # CONFIG_RELAY is not set |
53 | CONFIG_NAMESPACES=y | ||
54 | CONFIG_UTS_NS=y | ||
55 | CONFIG_IPC_NS=y | ||
56 | # CONFIG_USER_NS is not set | ||
57 | # CONFIG_PID_NS is not set | ||
51 | CONFIG_BLK_DEV_INITRD=y | 58 | CONFIG_BLK_DEV_INITRD=y |
52 | CONFIG_INITRAMFS_SOURCE="" | 59 | CONFIG_INITRAMFS_SOURCE="" |
53 | # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set | 60 | # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set |
@@ -61,17 +68,26 @@ CONFIG_HOTPLUG=y | |||
61 | CONFIG_PRINTK=y | 68 | CONFIG_PRINTK=y |
62 | CONFIG_BUG=y | 69 | CONFIG_BUG=y |
63 | CONFIG_ELF_CORE=y | 70 | CONFIG_ELF_CORE=y |
71 | # CONFIG_COMPAT_BRK is not set | ||
64 | CONFIG_BASE_FULL=y | 72 | CONFIG_BASE_FULL=y |
65 | CONFIG_FUTEX=y | 73 | CONFIG_FUTEX=y |
66 | CONFIG_ANON_INODES=y | 74 | CONFIG_ANON_INODES=y |
67 | CONFIG_EPOLL=y | 75 | CONFIG_EPOLL=y |
68 | CONFIG_SIGNALFD=y | 76 | CONFIG_SIGNALFD=y |
77 | CONFIG_TIMERFD=y | ||
69 | CONFIG_EVENTFD=y | 78 | CONFIG_EVENTFD=y |
70 | CONFIG_SHMEM=y | 79 | CONFIG_SHMEM=y |
71 | CONFIG_VM_EVENT_COUNTERS=y | 80 | CONFIG_VM_EVENT_COUNTERS=y |
72 | CONFIG_SLAB=y | 81 | CONFIG_SLAB=y |
73 | # CONFIG_SLUB is not set | 82 | # CONFIG_SLUB is not set |
74 | # CONFIG_SLOB is not set | 83 | # CONFIG_SLOB is not set |
84 | # CONFIG_PROFILING is not set | ||
85 | # CONFIG_MARKERS is not set | ||
86 | CONFIG_HAVE_OPROFILE=y | ||
87 | CONFIG_KPROBES=y | ||
88 | CONFIG_HAVE_KPROBES=y | ||
89 | CONFIG_PROC_PAGE_MONITOR=y | ||
90 | CONFIG_SLABINFO=y | ||
75 | CONFIG_RT_MUTEXES=y | 91 | CONFIG_RT_MUTEXES=y |
76 | # CONFIG_TINY_SHMEM is not set | 92 | # CONFIG_TINY_SHMEM is not set |
77 | CONFIG_BASE_SMALL=0 | 93 | CONFIG_BASE_SMALL=0 |
@@ -99,6 +115,8 @@ CONFIG_DEFAULT_DEADLINE=y | |||
99 | # CONFIG_DEFAULT_CFQ is not set | 115 | # CONFIG_DEFAULT_CFQ is not set |
100 | # CONFIG_DEFAULT_NOOP is not set | 116 | # CONFIG_DEFAULT_NOOP is not set |
101 | CONFIG_DEFAULT_IOSCHED="deadline" | 117 | CONFIG_DEFAULT_IOSCHED="deadline" |
118 | CONFIG_CLASSIC_RCU=y | ||
119 | # CONFIG_PREEMPT_RCU is not set | ||
102 | 120 | ||
103 | # | 121 | # |
104 | # Base setup | 122 | # Base setup |
@@ -137,7 +155,7 @@ CONFIG_ARCH_POPULATES_NODE_MAP=y | |||
137 | # CONFIG_PREEMPT_NONE is not set | 155 | # CONFIG_PREEMPT_NONE is not set |
138 | # CONFIG_PREEMPT_VOLUNTARY is not set | 156 | # CONFIG_PREEMPT_VOLUNTARY is not set |
139 | CONFIG_PREEMPT=y | 157 | CONFIG_PREEMPT=y |
140 | CONFIG_PREEMPT_BKL=y | 158 | # CONFIG_RCU_TRACE is not set |
141 | CONFIG_SELECT_MEMORY_MODEL=y | 159 | CONFIG_SELECT_MEMORY_MODEL=y |
142 | CONFIG_FLATMEM_MANUAL=y | 160 | CONFIG_FLATMEM_MANUAL=y |
143 | # CONFIG_DISCONTIGMEM_MANUAL is not set | 161 | # CONFIG_DISCONTIGMEM_MANUAL is not set |
@@ -151,7 +169,6 @@ CONFIG_RESOURCES_64BIT=y | |||
151 | CONFIG_ZONE_DMA_FLAG=1 | 169 | CONFIG_ZONE_DMA_FLAG=1 |
152 | CONFIG_BOUNCE=y | 170 | CONFIG_BOUNCE=y |
153 | CONFIG_VIRT_TO_BUS=y | 171 | CONFIG_VIRT_TO_BUS=y |
154 | CONFIG_HOLES_IN_ZONE=y | ||
155 | 172 | ||
156 | # | 173 | # |
157 | # I/O subsystem configuration | 174 | # I/O subsystem configuration |
@@ -180,6 +197,7 @@ CONFIG_HZ_100=y | |||
180 | # CONFIG_HZ_300 is not set | 197 | # CONFIG_HZ_300 is not set |
181 | # CONFIG_HZ_1000 is not set | 198 | # CONFIG_HZ_1000 is not set |
182 | CONFIG_HZ=100 | 199 | CONFIG_HZ=100 |
200 | # CONFIG_SCHED_HRTICK is not set | ||
183 | CONFIG_NO_IDLE_HZ=y | 201 | CONFIG_NO_IDLE_HZ=y |
184 | CONFIG_NO_IDLE_HZ_INIT=y | 202 | CONFIG_NO_IDLE_HZ_INIT=y |
185 | CONFIG_S390_HYPFS_FS=y | 203 | CONFIG_S390_HYPFS_FS=y |
@@ -201,6 +219,7 @@ CONFIG_XFRM=y | |||
201 | # CONFIG_XFRM_USER is not set | 219 | # CONFIG_XFRM_USER is not set |
202 | # CONFIG_XFRM_SUB_POLICY is not set | 220 | # CONFIG_XFRM_SUB_POLICY is not set |
203 | # CONFIG_XFRM_MIGRATE is not set | 221 | # CONFIG_XFRM_MIGRATE is not set |
222 | # CONFIG_XFRM_STATISTICS is not set | ||
204 | CONFIG_NET_KEY=y | 223 | CONFIG_NET_KEY=y |
205 | # CONFIG_NET_KEY_MIGRATE is not set | 224 | # CONFIG_NET_KEY_MIGRATE is not set |
206 | CONFIG_IUCV=m | 225 | CONFIG_IUCV=m |
@@ -251,6 +270,7 @@ CONFIG_IPV6_SIT=y | |||
251 | # CONFIG_NETWORK_SECMARK is not set | 270 | # CONFIG_NETWORK_SECMARK is not set |
252 | CONFIG_NETFILTER=y | 271 | CONFIG_NETFILTER=y |
253 | # CONFIG_NETFILTER_DEBUG is not set | 272 | # CONFIG_NETFILTER_DEBUG is not set |
273 | CONFIG_NETFILTER_ADVANCED=y | ||
254 | 274 | ||
255 | # | 275 | # |
256 | # Core Netfilter Configuration | 276 | # Core Netfilter Configuration |
@@ -258,7 +278,6 @@ CONFIG_NETFILTER=y | |||
258 | CONFIG_NETFILTER_NETLINK=m | 278 | CONFIG_NETFILTER_NETLINK=m |
259 | CONFIG_NETFILTER_NETLINK_QUEUE=m | 279 | CONFIG_NETFILTER_NETLINK_QUEUE=m |
260 | CONFIG_NETFILTER_NETLINK_LOG=m | 280 | CONFIG_NETFILTER_NETLINK_LOG=m |
261 | CONFIG_NF_CONNTRACK_ENABLED=m | ||
262 | CONFIG_NF_CONNTRACK=m | 281 | CONFIG_NF_CONNTRACK=m |
263 | # CONFIG_NF_CT_ACCT is not set | 282 | # CONFIG_NF_CT_ACCT is not set |
264 | # CONFIG_NF_CONNTRACK_MARK is not set | 283 | # CONFIG_NF_CONNTRACK_MARK is not set |
@@ -286,7 +305,7 @@ CONFIG_NF_CONNTRACK=m | |||
286 | # CONFIG_IP_NF_ARPTABLES is not set | 305 | # CONFIG_IP_NF_ARPTABLES is not set |
287 | 306 | ||
288 | # | 307 | # |
289 | # IPv6: Netfilter Configuration (EXPERIMENTAL) | 308 | # IPv6: Netfilter Configuration |
290 | # | 309 | # |
291 | # CONFIG_NF_CONNTRACK_IPV6 is not set | 310 | # CONFIG_NF_CONNTRACK_IPV6 is not set |
292 | # CONFIG_IP6_NF_QUEUE is not set | 311 | # CONFIG_IP6_NF_QUEUE is not set |
@@ -343,6 +362,7 @@ CONFIG_NET_CLS_U32=m | |||
343 | CONFIG_CLS_U32_MARK=y | 362 | CONFIG_CLS_U32_MARK=y |
344 | CONFIG_NET_CLS_RSVP=m | 363 | CONFIG_NET_CLS_RSVP=m |
345 | CONFIG_NET_CLS_RSVP6=m | 364 | CONFIG_NET_CLS_RSVP6=m |
365 | CONFIG_NET_CLS_FLOW=m | ||
346 | # CONFIG_NET_EMATCH is not set | 366 | # CONFIG_NET_EMATCH is not set |
347 | CONFIG_NET_CLS_ACT=y | 367 | CONFIG_NET_CLS_ACT=y |
348 | CONFIG_NET_ACT_POLICE=y | 368 | CONFIG_NET_ACT_POLICE=y |
@@ -351,7 +371,6 @@ CONFIG_NET_ACT_POLICE=y | |||
351 | CONFIG_NET_ACT_NAT=m | 371 | CONFIG_NET_ACT_NAT=m |
352 | # CONFIG_NET_ACT_PEDIT is not set | 372 | # CONFIG_NET_ACT_PEDIT is not set |
353 | # CONFIG_NET_ACT_SIMP is not set | 373 | # CONFIG_NET_ACT_SIMP is not set |
354 | CONFIG_NET_CLS_POLICE=y | ||
355 | # CONFIG_NET_CLS_IND is not set | 374 | # CONFIG_NET_CLS_IND is not set |
356 | CONFIG_NET_SCH_FIFO=y | 375 | CONFIG_NET_SCH_FIFO=y |
357 | 376 | ||
@@ -360,6 +379,15 @@ CONFIG_NET_SCH_FIFO=y | |||
360 | # | 379 | # |
361 | # CONFIG_NET_PKTGEN is not set | 380 | # CONFIG_NET_PKTGEN is not set |
362 | # CONFIG_NET_TCPPROBE is not set | 381 | # CONFIG_NET_TCPPROBE is not set |
382 | CONFIG_CAN=m | ||
383 | CONFIG_CAN_RAW=m | ||
384 | CONFIG_CAN_BCM=m | ||
385 | |||
386 | # | ||
387 | # CAN Device Drivers | ||
388 | # | ||
389 | CONFIG_CAN_VCAN=m | ||
390 | # CONFIG_CAN_DEBUG_DEVICES is not set | ||
363 | # CONFIG_AF_RXRPC is not set | 391 | # CONFIG_AF_RXRPC is not set |
364 | # CONFIG_RFKILL is not set | 392 | # CONFIG_RFKILL is not set |
365 | # CONFIG_NET_9P is not set | 393 | # CONFIG_NET_9P is not set |
@@ -389,7 +417,7 @@ CONFIG_BLK_DEV_NBD=m | |||
389 | CONFIG_BLK_DEV_RAM=y | 417 | CONFIG_BLK_DEV_RAM=y |
390 | CONFIG_BLK_DEV_RAM_COUNT=16 | 418 | CONFIG_BLK_DEV_RAM_COUNT=16 |
391 | CONFIG_BLK_DEV_RAM_SIZE=4096 | 419 | CONFIG_BLK_DEV_RAM_SIZE=4096 |
392 | CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 | 420 | CONFIG_BLK_DEV_XIP=y |
393 | # CONFIG_CDROM_PKTCDVD is not set | 421 | # CONFIG_CDROM_PKTCDVD is not set |
394 | # CONFIG_ATA_OVER_ETH is not set | 422 | # CONFIG_ATA_OVER_ETH is not set |
395 | 423 | ||
@@ -406,6 +434,7 @@ CONFIG_DASD_DIAG=y | |||
406 | CONFIG_DASD_EER=y | 434 | CONFIG_DASD_EER=y |
407 | CONFIG_MISC_DEVICES=y | 435 | CONFIG_MISC_DEVICES=y |
408 | # CONFIG_EEPROM_93CX6 is not set | 436 | # CONFIG_EEPROM_93CX6 is not set |
437 | # CONFIG_ENCLOSURE_SERVICES is not set | ||
409 | 438 | ||
410 | # | 439 | # |
411 | # SCSI device support | 440 | # SCSI device support |
@@ -487,6 +516,7 @@ CONFIG_NET_ETHERNET=y | |||
487 | # CONFIG_IBM_NEW_EMAC_TAH is not set | 516 | # CONFIG_IBM_NEW_EMAC_TAH is not set |
488 | # CONFIG_IBM_NEW_EMAC_EMAC4 is not set | 517 | # CONFIG_IBM_NEW_EMAC_EMAC4 is not set |
489 | CONFIG_NETDEV_1000=y | 518 | CONFIG_NETDEV_1000=y |
519 | # CONFIG_E1000E_ENABLED is not set | ||
490 | CONFIG_NETDEV_10000=y | 520 | CONFIG_NETDEV_10000=y |
491 | # CONFIG_TR is not set | 521 | # CONFIG_TR is not set |
492 | # CONFIG_WAN is not set | 522 | # CONFIG_WAN is not set |
@@ -508,7 +538,6 @@ CONFIG_QETH=y | |||
508 | CONFIG_CCWGROUP=y | 538 | CONFIG_CCWGROUP=y |
509 | # CONFIG_PPP is not set | 539 | # CONFIG_PPP is not set |
510 | # CONFIG_SLIP is not set | 540 | # CONFIG_SLIP is not set |
511 | # CONFIG_SHAPER is not set | ||
512 | # CONFIG_NETCONSOLE is not set | 541 | # CONFIG_NETCONSOLE is not set |
513 | # CONFIG_NETPOLL is not set | 542 | # CONFIG_NETPOLL is not set |
514 | # CONFIG_NET_POLL_CONTROLLER is not set | 543 | # CONFIG_NET_POLL_CONTROLLER is not set |
@@ -558,6 +587,7 @@ CONFIG_S390_TAPE_34XX=m | |||
558 | CONFIG_MONWRITER=m | 587 | CONFIG_MONWRITER=m |
559 | CONFIG_S390_VMUR=m | 588 | CONFIG_S390_VMUR=m |
560 | # CONFIG_POWER_SUPPLY is not set | 589 | # CONFIG_POWER_SUPPLY is not set |
590 | # CONFIG_THERMAL is not set | ||
561 | # CONFIG_WATCHDOG is not set | 591 | # CONFIG_WATCHDOG is not set |
562 | 592 | ||
563 | # | 593 | # |
@@ -584,12 +614,10 @@ CONFIG_FS_POSIX_ACL=y | |||
584 | # CONFIG_XFS_FS is not set | 614 | # CONFIG_XFS_FS is not set |
585 | # CONFIG_GFS2_FS is not set | 615 | # CONFIG_GFS2_FS is not set |
586 | # CONFIG_OCFS2_FS is not set | 616 | # CONFIG_OCFS2_FS is not set |
587 | # CONFIG_MINIX_FS is not set | 617 | CONFIG_DNOTIFY=y |
588 | # CONFIG_ROMFS_FS is not set | ||
589 | CONFIG_INOTIFY=y | 618 | CONFIG_INOTIFY=y |
590 | CONFIG_INOTIFY_USER=y | 619 | CONFIG_INOTIFY_USER=y |
591 | # CONFIG_QUOTA is not set | 620 | # CONFIG_QUOTA is not set |
592 | CONFIG_DNOTIFY=y | ||
593 | # CONFIG_AUTOFS_FS is not set | 621 | # CONFIG_AUTOFS_FS is not set |
594 | # CONFIG_AUTOFS4_FS is not set | 622 | # CONFIG_AUTOFS4_FS is not set |
595 | # CONFIG_FUSE_FS is not set | 623 | # CONFIG_FUSE_FS is not set |
@@ -632,8 +660,10 @@ CONFIG_CONFIGFS_FS=m | |||
632 | # CONFIG_EFS_FS is not set | 660 | # CONFIG_EFS_FS is not set |
633 | # CONFIG_CRAMFS is not set | 661 | # CONFIG_CRAMFS is not set |
634 | # CONFIG_VXFS_FS is not set | 662 | # CONFIG_VXFS_FS is not set |
663 | # CONFIG_MINIX_FS is not set | ||
635 | # CONFIG_HPFS_FS is not set | 664 | # CONFIG_HPFS_FS is not set |
636 | # CONFIG_QNX4FS_FS is not set | 665 | # CONFIG_QNX4FS_FS is not set |
666 | # CONFIG_ROMFS_FS is not set | ||
637 | # CONFIG_SYSV_FS is not set | 667 | # CONFIG_SYSV_FS is not set |
638 | # CONFIG_UFS_FS is not set | 668 | # CONFIG_UFS_FS is not set |
639 | CONFIG_NETWORK_FILESYSTEMS=y | 669 | CONFIG_NETWORK_FILESYSTEMS=y |
@@ -686,16 +716,13 @@ CONFIG_MSDOS_PARTITION=y | |||
686 | # CONFIG_NLS is not set | 716 | # CONFIG_NLS is not set |
687 | CONFIG_DLM=m | 717 | CONFIG_DLM=m |
688 | # CONFIG_DLM_DEBUG is not set | 718 | # CONFIG_DLM_DEBUG is not set |
689 | CONFIG_INSTRUMENTATION=y | ||
690 | # CONFIG_PROFILING is not set | ||
691 | CONFIG_KPROBES=y | ||
692 | # CONFIG_MARKERS is not set | ||
693 | 719 | ||
694 | # | 720 | # |
695 | # Kernel hacking | 721 | # Kernel hacking |
696 | # | 722 | # |
697 | CONFIG_TRACE_IRQFLAGS_SUPPORT=y | 723 | CONFIG_TRACE_IRQFLAGS_SUPPORT=y |
698 | # CONFIG_PRINTK_TIME is not set | 724 | # CONFIG_PRINTK_TIME is not set |
725 | CONFIG_ENABLE_WARN_DEPRECATED=y | ||
699 | CONFIG_ENABLE_MUST_CHECK=y | 726 | CONFIG_ENABLE_MUST_CHECK=y |
700 | CONFIG_MAGIC_SYSRQ=y | 727 | CONFIG_MAGIC_SYSRQ=y |
701 | # CONFIG_UNUSED_SYMBOLS is not set | 728 | # CONFIG_UNUSED_SYMBOLS is not set |
@@ -721,12 +748,18 @@ CONFIG_DEBUG_BUGVERBOSE=y | |||
721 | # CONFIG_DEBUG_INFO is not set | 748 | # CONFIG_DEBUG_INFO is not set |
722 | # CONFIG_DEBUG_VM is not set | 749 | # CONFIG_DEBUG_VM is not set |
723 | # CONFIG_DEBUG_LIST is not set | 750 | # CONFIG_DEBUG_LIST is not set |
751 | # CONFIG_DEBUG_SG is not set | ||
724 | # CONFIG_FRAME_POINTER is not set | 752 | # CONFIG_FRAME_POINTER is not set |
725 | CONFIG_FORCED_INLINING=y | 753 | CONFIG_FORCED_INLINING=y |
726 | # CONFIG_RCU_TORTURE_TEST is not set | 754 | # CONFIG_RCU_TORTURE_TEST is not set |
755 | # CONFIG_KPROBES_SANITY_TEST is not set | ||
756 | # CONFIG_BACKTRACE_SELF_TEST is not set | ||
727 | # CONFIG_LKDTM is not set | 757 | # CONFIG_LKDTM is not set |
728 | # CONFIG_FAULT_INJECTION is not set | 758 | # CONFIG_FAULT_INJECTION is not set |
759 | # CONFIG_LATENCYTOP is not set | ||
729 | CONFIG_SAMPLES=y | 760 | CONFIG_SAMPLES=y |
761 | # CONFIG_SAMPLE_KOBJECT is not set | ||
762 | # CONFIG_DEBUG_PAGEALLOC is not set | ||
730 | 763 | ||
731 | # | 764 | # |
732 | # Security options | 765 | # Security options |
@@ -738,6 +771,7 @@ CONFIG_CRYPTO=y | |||
738 | CONFIG_CRYPTO_ALGAPI=y | 771 | CONFIG_CRYPTO_ALGAPI=y |
739 | CONFIG_CRYPTO_AEAD=m | 772 | CONFIG_CRYPTO_AEAD=m |
740 | CONFIG_CRYPTO_BLKCIPHER=y | 773 | CONFIG_CRYPTO_BLKCIPHER=y |
774 | CONFIG_CRYPTO_SEQIV=m | ||
741 | CONFIG_CRYPTO_HASH=m | 775 | CONFIG_CRYPTO_HASH=m |
742 | CONFIG_CRYPTO_MANAGER=y | 776 | CONFIG_CRYPTO_MANAGER=y |
743 | CONFIG_CRYPTO_HMAC=m | 777 | CONFIG_CRYPTO_HMAC=m |
@@ -745,17 +779,20 @@ CONFIG_CRYPTO_HMAC=m | |||
745 | # CONFIG_CRYPTO_NULL is not set | 779 | # CONFIG_CRYPTO_NULL is not set |
746 | # CONFIG_CRYPTO_MD4 is not set | 780 | # CONFIG_CRYPTO_MD4 is not set |
747 | CONFIG_CRYPTO_MD5=m | 781 | CONFIG_CRYPTO_MD5=m |
748 | # CONFIG_CRYPTO_SHA1 is not set | 782 | CONFIG_CRYPTO_SHA1=m |
749 | # CONFIG_CRYPTO_SHA256 is not set | 783 | # CONFIG_CRYPTO_SHA256 is not set |
750 | # CONFIG_CRYPTO_SHA512 is not set | 784 | # CONFIG_CRYPTO_SHA512 is not set |
751 | # CONFIG_CRYPTO_WP512 is not set | 785 | # CONFIG_CRYPTO_WP512 is not set |
752 | # CONFIG_CRYPTO_TGR192 is not set | 786 | # CONFIG_CRYPTO_TGR192 is not set |
753 | # CONFIG_CRYPTO_GF128MUL is not set | 787 | CONFIG_CRYPTO_GF128MUL=m |
754 | CONFIG_CRYPTO_ECB=m | 788 | CONFIG_CRYPTO_ECB=m |
755 | CONFIG_CRYPTO_CBC=y | 789 | CONFIG_CRYPTO_CBC=y |
756 | CONFIG_CRYPTO_PCBC=m | 790 | CONFIG_CRYPTO_PCBC=m |
757 | # CONFIG_CRYPTO_LRW is not set | 791 | # CONFIG_CRYPTO_LRW is not set |
758 | # CONFIG_CRYPTO_XTS is not set | 792 | # CONFIG_CRYPTO_XTS is not set |
793 | CONFIG_CRYPTO_CTR=m | ||
794 | CONFIG_CRYPTO_GCM=m | ||
795 | CONFIG_CRYPTO_CCM=m | ||
759 | # CONFIG_CRYPTO_CRYPTD is not set | 796 | # CONFIG_CRYPTO_CRYPTD is not set |
760 | # CONFIG_CRYPTO_DES is not set | 797 | # CONFIG_CRYPTO_DES is not set |
761 | CONFIG_CRYPTO_FCRYPT=m | 798 | CONFIG_CRYPTO_FCRYPT=m |
@@ -770,20 +807,22 @@ CONFIG_CRYPTO_FCRYPT=m | |||
770 | # CONFIG_CRYPTO_KHAZAD is not set | 807 | # CONFIG_CRYPTO_KHAZAD is not set |
771 | # CONFIG_CRYPTO_ANUBIS is not set | 808 | # CONFIG_CRYPTO_ANUBIS is not set |
772 | CONFIG_CRYPTO_SEED=m | 809 | CONFIG_CRYPTO_SEED=m |
810 | CONFIG_CRYPTO_SALSA20=m | ||
773 | # CONFIG_CRYPTO_DEFLATE is not set | 811 | # CONFIG_CRYPTO_DEFLATE is not set |
774 | # CONFIG_CRYPTO_MICHAEL_MIC is not set | 812 | # CONFIG_CRYPTO_MICHAEL_MIC is not set |
775 | # CONFIG_CRYPTO_CRC32C is not set | 813 | # CONFIG_CRYPTO_CRC32C is not set |
776 | CONFIG_CRYPTO_CAMELLIA=m | 814 | CONFIG_CRYPTO_CAMELLIA=m |
777 | # CONFIG_CRYPTO_TEST is not set | 815 | # CONFIG_CRYPTO_TEST is not set |
778 | CONFIG_CRYPTO_AUTHENC=m | 816 | CONFIG_CRYPTO_AUTHENC=m |
817 | CONFIG_CRYPTO_LZO=m | ||
779 | CONFIG_CRYPTO_HW=y | 818 | CONFIG_CRYPTO_HW=y |
819 | CONFIG_ZCRYPT=m | ||
820 | # CONFIG_ZCRYPT_MONOLITHIC is not set | ||
780 | # CONFIG_CRYPTO_SHA1_S390 is not set | 821 | # CONFIG_CRYPTO_SHA1_S390 is not set |
781 | # CONFIG_CRYPTO_SHA256_S390 is not set | 822 | # CONFIG_CRYPTO_SHA256_S390 is not set |
782 | # CONFIG_CRYPTO_DES_S390 is not set | 823 | # CONFIG_CRYPTO_DES_S390 is not set |
783 | # CONFIG_CRYPTO_AES_S390 is not set | 824 | # CONFIG_CRYPTO_AES_S390 is not set |
784 | CONFIG_S390_PRNG=m | 825 | CONFIG_S390_PRNG=m |
785 | CONFIG_ZCRYPT=m | ||
786 | # CONFIG_ZCRYPT_MONOLITHIC is not set | ||
787 | 826 | ||
788 | # | 827 | # |
789 | # Library routines | 828 | # Library routines |
@@ -794,5 +833,7 @@ CONFIG_BITREVERSE=m | |||
794 | # CONFIG_CRC_ITU_T is not set | 833 | # CONFIG_CRC_ITU_T is not set |
795 | CONFIG_CRC32=m | 834 | CONFIG_CRC32=m |
796 | CONFIG_CRC7=m | 835 | CONFIG_CRC7=m |
797 | # CONFIG_LIBCRC32C is not set | 836 | CONFIG_LIBCRC32C=m |
837 | CONFIG_LZO_COMPRESS=m | ||
838 | CONFIG_LZO_DECOMPRESS=m | ||
798 | CONFIG_PLIST=y | 839 | CONFIG_PLIST=y |
diff --git a/arch/s390/kernel/binfmt_elf32.c b/arch/s390/kernel/binfmt_elf32.c index f1e40ca00d8d..3e1c315b736d 100644 --- a/arch/s390/kernel/binfmt_elf32.c +++ b/arch/s390/kernel/binfmt_elf32.c | |||
@@ -134,6 +134,7 @@ static inline int dump_task_fpu(struct task_struct *tsk, elf_fpregset_t *fpregs) | |||
134 | } | 134 | } |
135 | 135 | ||
136 | #include <asm/processor.h> | 136 | #include <asm/processor.h> |
137 | #include <asm/pgalloc.h> | ||
137 | #include <linux/module.h> | 138 | #include <linux/module.h> |
138 | #include <linux/elfcore.h> | 139 | #include <linux/elfcore.h> |
139 | #include <linux/binfmts.h> | 140 | #include <linux/binfmts.h> |
@@ -183,6 +184,16 @@ struct elf_prpsinfo32 | |||
183 | #undef start_thread | 184 | #undef start_thread |
184 | #define start_thread start_thread31 | 185 | #define start_thread start_thread31 |
185 | 186 | ||
187 | static inline void start_thread31(struct pt_regs *regs, unsigned long new_psw, | ||
188 | unsigned long new_stackp) | ||
189 | { | ||
190 | set_fs(USER_DS); | ||
191 | regs->psw.mask = psw_user32_bits; | ||
192 | regs->psw.addr = new_psw; | ||
193 | regs->gprs[15] = new_stackp; | ||
194 | crst_table_downgrade(current->mm, 1UL << 31); | ||
195 | } | ||
196 | |||
186 | MODULE_DESCRIPTION("Binary format loader for compatibility with 32bit Linux for S390 binaries," | 197 | MODULE_DESCRIPTION("Binary format loader for compatibility with 32bit Linux for S390 binaries," |
187 | " Copyright 2000 IBM Corporation"); | 198 | " Copyright 2000 IBM Corporation"); |
188 | MODULE_AUTHOR("Gerhard Tonn <ton@de.ibm.com>"); | 199 | MODULE_AUTHOR("Gerhard Tonn <ton@de.ibm.com>"); |
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S index 062c3d4c0394..743d54f0b8db 100644 --- a/arch/s390/kernel/compat_wrapper.S +++ b/arch/s390/kernel/compat_wrapper.S | |||
@@ -1712,3 +1712,23 @@ sys_fallocate_wrapper: | |||
1712 | sllg %r5,%r6,32 # get high word of 64bit loff_t | 1712 | sllg %r5,%r6,32 # get high word of 64bit loff_t |
1713 | l %r5,164(%r15) # get low word of 64bit loff_t | 1713 | l %r5,164(%r15) # get low word of 64bit loff_t |
1714 | jg sys_fallocate | 1714 | jg sys_fallocate |
1715 | |||
1716 | .globl sys_timerfd_create_wrapper | ||
1717 | sys_timerfd_create_wrapper: | ||
1718 | lgfr %r2,%r2 # int | ||
1719 | lgfr %r3,%r3 # int | ||
1720 | jg sys_timerfd_create | ||
1721 | |||
1722 | .globl compat_sys_timerfd_settime_wrapper | ||
1723 | compat_sys_timerfd_settime_wrapper: | ||
1724 | lgfr %r2,%r2 # int | ||
1725 | lgfr %r3,%r3 # int | ||
1726 | llgtr %r4,%r4 # struct compat_itimerspec * | ||
1727 | llgtr %r5,%r5 # struct compat_itimerspec * | ||
1728 | jg compat_sys_timerfd_settime | ||
1729 | |||
1730 | .globl compat_sys_timerfd_gettime_wrapper | ||
1731 | compat_sys_timerfd_gettime_wrapper: | ||
1732 | lgfr %r2,%r2 # int | ||
1733 | llgtr %r3,%r3 # struct compat_itimerspec * | ||
1734 | jg compat_sys_timerfd_gettime | ||
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c index 0e7aca039307..a6a4729e0e94 100644 --- a/arch/s390/kernel/process.c +++ b/arch/s390/kernel/process.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/vmalloc.h> | 30 | #include <linux/vmalloc.h> |
31 | #include <linux/user.h> | 31 | #include <linux/user.h> |
32 | #include <linux/a.out.h> | ||
33 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
34 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
35 | #include <linux/reboot.h> | 34 | #include <linux/reboot.h> |
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index f9f8779022a0..290e504061a3 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/ptrace.h> | 24 | #include <linux/ptrace.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/user.h> | 26 | #include <linux/user.h> |
27 | #include <linux/a.out.h> | ||
28 | #include <linux/tty.h> | 27 | #include <linux/tty.h> |
29 | #include <linux/ioport.h> | 28 | #include <linux/ioport.h> |
30 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
diff --git a/arch/s390/kernel/syscalls.S b/arch/s390/kernel/syscalls.S index 25eac7802fc4..c87ec687d4c6 100644 --- a/arch/s390/kernel/syscalls.S +++ b/arch/s390/kernel/syscalls.S | |||
@@ -327,3 +327,6 @@ SYSCALL(sys_utimensat,sys_utimensat,compat_sys_utimensat_wrapper) /* 315 */ | |||
327 | SYSCALL(sys_signalfd,sys_signalfd,compat_sys_signalfd_wrapper) | 327 | SYSCALL(sys_signalfd,sys_signalfd,compat_sys_signalfd_wrapper) |
328 | NI_SYSCALL /* 317 old sys_timer_fd */ | 328 | NI_SYSCALL /* 317 old sys_timer_fd */ |
329 | SYSCALL(sys_eventfd,sys_eventfd,sys_eventfd_wrapper) | 329 | SYSCALL(sys_eventfd,sys_eventfd,sys_eventfd_wrapper) |
330 | SYSCALL(sys_timerfd_create,sys_timerfd_create,sys_timerfd_create_wrapper) | ||
331 | SYSCALL(sys_timerfd_settime,sys_timerfd_settime,compat_sys_timerfd_settime_wrapper) /* 320 */ | ||
332 | SYSCALL(sys_timerfd_gettime,sys_timerfd_gettime,compat_sys_timerfd_gettime_wrapper) | ||
diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c index a4d29025ddbd..60f728aeaf12 100644 --- a/arch/s390/kernel/traps.c +++ b/arch/s390/kernel/traps.c | |||
@@ -60,6 +60,7 @@ int sysctl_userprocess_debug = 0; | |||
60 | extern pgm_check_handler_t do_protection_exception; | 60 | extern pgm_check_handler_t do_protection_exception; |
61 | extern pgm_check_handler_t do_dat_exception; | 61 | extern pgm_check_handler_t do_dat_exception; |
62 | extern pgm_check_handler_t do_monitor_call; | 62 | extern pgm_check_handler_t do_monitor_call; |
63 | extern pgm_check_handler_t do_asce_exception; | ||
63 | 64 | ||
64 | #define stack_pointer ({ void **sp; asm("la %0,0(15)" : "=&d" (sp)); sp; }) | 65 | #define stack_pointer ({ void **sp; asm("la %0,0(15)" : "=&d" (sp)); sp; }) |
65 | 66 | ||
@@ -730,7 +731,7 @@ void __init trap_init(void) | |||
730 | pgm_check_table[0x12] = &translation_exception; | 731 | pgm_check_table[0x12] = &translation_exception; |
731 | pgm_check_table[0x13] = &special_op_exception; | 732 | pgm_check_table[0x13] = &special_op_exception; |
732 | #ifdef CONFIG_64BIT | 733 | #ifdef CONFIG_64BIT |
733 | pgm_check_table[0x38] = &do_dat_exception; | 734 | pgm_check_table[0x38] = &do_asce_exception; |
734 | pgm_check_table[0x39] = &do_dat_exception; | 735 | pgm_check_table[0x39] = &do_dat_exception; |
735 | pgm_check_table[0x3A] = &do_dat_exception; | 736 | pgm_check_table[0x3A] = &do_dat_exception; |
736 | pgm_check_table[0x3B] = &do_dat_exception; | 737 | pgm_check_table[0x3B] = &do_dat_exception; |
diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index 2456b52ed068..ed13d429a487 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <asm/system.h> | 32 | #include <asm/system.h> |
33 | #include <asm/pgtable.h> | 33 | #include <asm/pgtable.h> |
34 | #include <asm/s390_ext.h> | 34 | #include <asm/s390_ext.h> |
35 | #include <asm/mmu_context.h> | ||
35 | 36 | ||
36 | #ifndef CONFIG_64BIT | 37 | #ifndef CONFIG_64BIT |
37 | #define __FAIL_ADDR_MASK 0x7ffff000 | 38 | #define __FAIL_ADDR_MASK 0x7ffff000 |
@@ -444,6 +445,45 @@ void __kprobes do_dat_exception(struct pt_regs *regs, unsigned long error_code) | |||
444 | do_exception(regs, error_code & 0xff, 0); | 445 | do_exception(regs, error_code & 0xff, 0); |
445 | } | 446 | } |
446 | 447 | ||
448 | #ifdef CONFIG_64BIT | ||
449 | void __kprobes do_asce_exception(struct pt_regs *regs, unsigned long error_code) | ||
450 | { | ||
451 | struct mm_struct *mm; | ||
452 | struct vm_area_struct *vma; | ||
453 | unsigned long address; | ||
454 | int space; | ||
455 | |||
456 | mm = current->mm; | ||
457 | address = S390_lowcore.trans_exc_code & __FAIL_ADDR_MASK; | ||
458 | space = check_space(current); | ||
459 | |||
460 | if (unlikely(space == 0 || in_atomic() || !mm)) | ||
461 | goto no_context; | ||
462 | |||
463 | local_irq_enable(); | ||
464 | |||
465 | down_read(&mm->mmap_sem); | ||
466 | vma = find_vma(mm, address); | ||
467 | up_read(&mm->mmap_sem); | ||
468 | |||
469 | if (vma) { | ||
470 | update_mm(mm, current); | ||
471 | return; | ||
472 | } | ||
473 | |||
474 | /* User mode accesses just cause a SIGSEGV */ | ||
475 | if (regs->psw.mask & PSW_MASK_PSTATE) { | ||
476 | current->thread.prot_addr = address; | ||
477 | current->thread.trap_no = error_code; | ||
478 | do_sigsegv(regs, error_code, SEGV_MAPERR, address); | ||
479 | return; | ||
480 | } | ||
481 | |||
482 | no_context: | ||
483 | do_no_context(regs, error_code, address); | ||
484 | } | ||
485 | #endif | ||
486 | |||
447 | #ifdef CONFIG_PFAULT | 487 | #ifdef CONFIG_PFAULT |
448 | /* | 488 | /* |
449 | * 'pfault' pseudo page faults routines. | 489 | * 'pfault' pseudo page faults routines. |
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index 983ec6ec0e7c..8053245fe259 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c | |||
@@ -112,6 +112,7 @@ void __init paging_init(void) | |||
112 | init_mm.pgd = swapper_pg_dir; | 112 | init_mm.pgd = swapper_pg_dir; |
113 | S390_lowcore.kernel_asce = __pa(init_mm.pgd) & PAGE_MASK; | 113 | S390_lowcore.kernel_asce = __pa(init_mm.pgd) & PAGE_MASK; |
114 | #ifdef CONFIG_64BIT | 114 | #ifdef CONFIG_64BIT |
115 | /* A three level page table (4TB) is enough for the kernel space. */ | ||
115 | S390_lowcore.kernel_asce |= _ASCE_TYPE_REGION3 | _ASCE_TABLE_LENGTH; | 116 | S390_lowcore.kernel_asce |= _ASCE_TYPE_REGION3 | _ASCE_TABLE_LENGTH; |
116 | pgd_type = _REGION3_ENTRY_EMPTY; | 117 | pgd_type = _REGION3_ENTRY_EMPTY; |
117 | #else | 118 | #else |
@@ -184,7 +185,7 @@ void kernel_map_pages(struct page *page, int numpages, int enable) | |||
184 | pmd = pmd_offset(pud, address); | 185 | pmd = pmd_offset(pud, address); |
185 | pte = pte_offset_kernel(pmd, address); | 186 | pte = pte_offset_kernel(pmd, address); |
186 | if (!enable) { | 187 | if (!enable) { |
187 | ptep_invalidate(address, pte); | 188 | ptep_invalidate(&init_mm, address, pte); |
188 | continue; | 189 | continue; |
189 | } | 190 | } |
190 | *pte = mk_pte_phys(address, __pgprot(_PAGE_TYPE_RW)); | 191 | *pte = mk_pte_phys(address, __pgprot(_PAGE_TYPE_RW)); |
diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c index 356257c171de..5932a824547a 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/personality.h> | 27 | #include <linux/personality.h> |
28 | #include <linux/mm.h> | 28 | #include <linux/mm.h> |
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | #include <asm/pgalloc.h> | ||
30 | 31 | ||
31 | /* | 32 | /* |
32 | * Top of mmap area (just below the process stack). | 33 | * Top of mmap area (just below the process stack). |
@@ -62,6 +63,8 @@ static inline int mmap_is_legacy(void) | |||
62 | current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY; | 63 | current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY; |
63 | } | 64 | } |
64 | 65 | ||
66 | #ifndef CONFIG_64BIT | ||
67 | |||
65 | /* | 68 | /* |
66 | * This function, called very early during the creation of a new | 69 | * This function, called very early during the creation of a new |
67 | * process VM image, sets up which VM layout function to use: | 70 | * process VM image, sets up which VM layout function to use: |
@@ -84,3 +87,65 @@ void arch_pick_mmap_layout(struct mm_struct *mm) | |||
84 | } | 87 | } |
85 | EXPORT_SYMBOL_GPL(arch_pick_mmap_layout); | 88 | EXPORT_SYMBOL_GPL(arch_pick_mmap_layout); |
86 | 89 | ||
90 | #else | ||
91 | |||
92 | static unsigned long | ||
93 | s390_get_unmapped_area(struct file *filp, unsigned long addr, | ||
94 | unsigned long len, unsigned long pgoff, unsigned long flags) | ||
95 | { | ||
96 | struct mm_struct *mm = current->mm; | ||
97 | int rc; | ||
98 | |||
99 | addr = arch_get_unmapped_area(filp, addr, len, pgoff, flags); | ||
100 | if (addr & ~PAGE_MASK) | ||
101 | return addr; | ||
102 | if (unlikely(mm->context.asce_limit < addr + len)) { | ||
103 | rc = crst_table_upgrade(mm, addr + len); | ||
104 | if (rc) | ||
105 | return (unsigned long) rc; | ||
106 | } | ||
107 | return addr; | ||
108 | } | ||
109 | |||
110 | static unsigned long | ||
111 | s390_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, | ||
112 | const unsigned long len, const unsigned long pgoff, | ||
113 | const unsigned long flags) | ||
114 | { | ||
115 | struct mm_struct *mm = current->mm; | ||
116 | unsigned long addr = addr0; | ||
117 | int rc; | ||
118 | |||
119 | addr = arch_get_unmapped_area_topdown(filp, addr, len, pgoff, flags); | ||
120 | if (addr & ~PAGE_MASK) | ||
121 | return addr; | ||
122 | if (unlikely(mm->context.asce_limit < addr + len)) { | ||
123 | rc = crst_table_upgrade(mm, addr + len); | ||
124 | if (rc) | ||
125 | return (unsigned long) rc; | ||
126 | } | ||
127 | return addr; | ||
128 | } | ||
129 | /* | ||
130 | * This function, called very early during the creation of a new | ||
131 | * process VM image, sets up which VM layout function to use: | ||
132 | */ | ||
133 | void arch_pick_mmap_layout(struct mm_struct *mm) | ||
134 | { | ||
135 | /* | ||
136 | * Fall back to the standard layout if the personality | ||
137 | * bit is set, or if the expected stack growth is unlimited: | ||
138 | */ | ||
139 | if (mmap_is_legacy()) { | ||
140 | mm->mmap_base = TASK_UNMAPPED_BASE; | ||
141 | mm->get_unmapped_area = s390_get_unmapped_area; | ||
142 | mm->unmap_area = arch_unmap_area; | ||
143 | } else { | ||
144 | mm->mmap_base = mmap_base(); | ||
145 | mm->get_unmapped_area = s390_get_unmapped_area_topdown; | ||
146 | mm->unmap_area = arch_unmap_area_topdown; | ||
147 | } | ||
148 | } | ||
149 | EXPORT_SYMBOL_GPL(arch_pick_mmap_layout); | ||
150 | |||
151 | #endif | ||
diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c index 019f518cd5a0..fd072013f88c 100644 --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c | |||
@@ -23,11 +23,18 @@ | |||
23 | #include <asm/pgalloc.h> | 23 | #include <asm/pgalloc.h> |
24 | #include <asm/tlb.h> | 24 | #include <asm/tlb.h> |
25 | #include <asm/tlbflush.h> | 25 | #include <asm/tlbflush.h> |
26 | #include <asm/mmu_context.h> | ||
26 | 27 | ||
27 | #ifndef CONFIG_64BIT | 28 | #ifndef CONFIG_64BIT |
28 | #define ALLOC_ORDER 1 | 29 | #define ALLOC_ORDER 1 |
30 | #define TABLES_PER_PAGE 4 | ||
31 | #define FRAG_MASK 15UL | ||
32 | #define SECOND_HALVES 10UL | ||
29 | #else | 33 | #else |
30 | #define ALLOC_ORDER 2 | 34 | #define ALLOC_ORDER 2 |
35 | #define TABLES_PER_PAGE 2 | ||
36 | #define FRAG_MASK 3UL | ||
37 | #define SECOND_HALVES 2UL | ||
31 | #endif | 38 | #endif |
32 | 39 | ||
33 | unsigned long *crst_table_alloc(struct mm_struct *mm, int noexec) | 40 | unsigned long *crst_table_alloc(struct mm_struct *mm, int noexec) |
@@ -45,52 +52,179 @@ unsigned long *crst_table_alloc(struct mm_struct *mm, int noexec) | |||
45 | } | 52 | } |
46 | page->index = page_to_phys(shadow); | 53 | page->index = page_to_phys(shadow); |
47 | } | 54 | } |
55 | spin_lock(&mm->page_table_lock); | ||
56 | list_add(&page->lru, &mm->context.crst_list); | ||
57 | spin_unlock(&mm->page_table_lock); | ||
48 | return (unsigned long *) page_to_phys(page); | 58 | return (unsigned long *) page_to_phys(page); |
49 | } | 59 | } |
50 | 60 | ||
51 | void crst_table_free(unsigned long *table) | 61 | void crst_table_free(struct mm_struct *mm, unsigned long *table) |
52 | { | 62 | { |
53 | unsigned long *shadow = get_shadow_table(table); | 63 | unsigned long *shadow = get_shadow_table(table); |
64 | struct page *page = virt_to_page(table); | ||
54 | 65 | ||
66 | spin_lock(&mm->page_table_lock); | ||
67 | list_del(&page->lru); | ||
68 | spin_unlock(&mm->page_table_lock); | ||
55 | if (shadow) | 69 | if (shadow) |
56 | free_pages((unsigned long) shadow, ALLOC_ORDER); | 70 | free_pages((unsigned long) shadow, ALLOC_ORDER); |
57 | free_pages((unsigned long) table, ALLOC_ORDER); | 71 | free_pages((unsigned long) table, ALLOC_ORDER); |
58 | } | 72 | } |
59 | 73 | ||
74 | #ifdef CONFIG_64BIT | ||
75 | int crst_table_upgrade(struct mm_struct *mm, unsigned long limit) | ||
76 | { | ||
77 | unsigned long *table, *pgd; | ||
78 | unsigned long entry; | ||
79 | |||
80 | BUG_ON(limit > (1UL << 53)); | ||
81 | repeat: | ||
82 | table = crst_table_alloc(mm, mm->context.noexec); | ||
83 | if (!table) | ||
84 | return -ENOMEM; | ||
85 | spin_lock(&mm->page_table_lock); | ||
86 | if (mm->context.asce_limit < limit) { | ||
87 | pgd = (unsigned long *) mm->pgd; | ||
88 | if (mm->context.asce_limit <= (1UL << 31)) { | ||
89 | entry = _REGION3_ENTRY_EMPTY; | ||
90 | mm->context.asce_limit = 1UL << 42; | ||
91 | mm->context.asce_bits = _ASCE_TABLE_LENGTH | | ||
92 | _ASCE_USER_BITS | | ||
93 | _ASCE_TYPE_REGION3; | ||
94 | } else { | ||
95 | entry = _REGION2_ENTRY_EMPTY; | ||
96 | mm->context.asce_limit = 1UL << 53; | ||
97 | mm->context.asce_bits = _ASCE_TABLE_LENGTH | | ||
98 | _ASCE_USER_BITS | | ||
99 | _ASCE_TYPE_REGION2; | ||
100 | } | ||
101 | crst_table_init(table, entry); | ||
102 | pgd_populate(mm, (pgd_t *) table, (pud_t *) pgd); | ||
103 | mm->pgd = (pgd_t *) table; | ||
104 | table = NULL; | ||
105 | } | ||
106 | spin_unlock(&mm->page_table_lock); | ||
107 | if (table) | ||
108 | crst_table_free(mm, table); | ||
109 | if (mm->context.asce_limit < limit) | ||
110 | goto repeat; | ||
111 | update_mm(mm, current); | ||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | void crst_table_downgrade(struct mm_struct *mm, unsigned long limit) | ||
116 | { | ||
117 | pgd_t *pgd; | ||
118 | |||
119 | if (mm->context.asce_limit <= limit) | ||
120 | return; | ||
121 | __tlb_flush_mm(mm); | ||
122 | while (mm->context.asce_limit > limit) { | ||
123 | pgd = mm->pgd; | ||
124 | switch (pgd_val(*pgd) & _REGION_ENTRY_TYPE_MASK) { | ||
125 | case _REGION_ENTRY_TYPE_R2: | ||
126 | mm->context.asce_limit = 1UL << 42; | ||
127 | mm->context.asce_bits = _ASCE_TABLE_LENGTH | | ||
128 | _ASCE_USER_BITS | | ||
129 | _ASCE_TYPE_REGION3; | ||
130 | break; | ||
131 | case _REGION_ENTRY_TYPE_R3: | ||
132 | mm->context.asce_limit = 1UL << 31; | ||
133 | mm->context.asce_bits = _ASCE_TABLE_LENGTH | | ||
134 | _ASCE_USER_BITS | | ||
135 | _ASCE_TYPE_SEGMENT; | ||
136 | break; | ||
137 | default: | ||
138 | BUG(); | ||
139 | } | ||
140 | mm->pgd = (pgd_t *) (pgd_val(*pgd) & _REGION_ENTRY_ORIGIN); | ||
141 | crst_table_free(mm, (unsigned long *) pgd); | ||
142 | } | ||
143 | update_mm(mm, current); | ||
144 | } | ||
145 | #endif | ||
146 | |||
60 | /* | 147 | /* |
61 | * page table entry allocation/free routines. | 148 | * page table entry allocation/free routines. |
62 | */ | 149 | */ |
63 | unsigned long *page_table_alloc(int noexec) | 150 | unsigned long *page_table_alloc(struct mm_struct *mm) |
64 | { | 151 | { |
65 | struct page *page = alloc_page(GFP_KERNEL); | 152 | struct page *page; |
66 | unsigned long *table; | 153 | unsigned long *table; |
154 | unsigned long bits; | ||
67 | 155 | ||
68 | if (!page) | 156 | bits = mm->context.noexec ? 3UL : 1UL; |
69 | return NULL; | 157 | spin_lock(&mm->page_table_lock); |
70 | page->index = 0; | 158 | page = NULL; |
71 | if (noexec) { | 159 | if (!list_empty(&mm->context.pgtable_list)) { |
72 | struct page *shadow = alloc_page(GFP_KERNEL); | 160 | page = list_first_entry(&mm->context.pgtable_list, |
73 | if (!shadow) { | 161 | struct page, lru); |
74 | __free_page(page); | 162 | if ((page->flags & FRAG_MASK) == ((1UL << TABLES_PER_PAGE) - 1)) |
163 | page = NULL; | ||
164 | } | ||
165 | if (!page) { | ||
166 | spin_unlock(&mm->page_table_lock); | ||
167 | page = alloc_page(GFP_KERNEL|__GFP_REPEAT); | ||
168 | if (!page) | ||
75 | return NULL; | 169 | return NULL; |
76 | } | 170 | pgtable_page_ctor(page); |
77 | table = (unsigned long *) page_to_phys(shadow); | 171 | page->flags &= ~FRAG_MASK; |
172 | table = (unsigned long *) page_to_phys(page); | ||
78 | clear_table(table, _PAGE_TYPE_EMPTY, PAGE_SIZE); | 173 | clear_table(table, _PAGE_TYPE_EMPTY, PAGE_SIZE); |
79 | page->index = (addr_t) table; | 174 | spin_lock(&mm->page_table_lock); |
175 | list_add(&page->lru, &mm->context.pgtable_list); | ||
80 | } | 176 | } |
81 | pgtable_page_ctor(page); | ||
82 | table = (unsigned long *) page_to_phys(page); | 177 | table = (unsigned long *) page_to_phys(page); |
83 | clear_table(table, _PAGE_TYPE_EMPTY, PAGE_SIZE); | 178 | while (page->flags & bits) { |
179 | table += 256; | ||
180 | bits <<= 1; | ||
181 | } | ||
182 | page->flags |= bits; | ||
183 | if ((page->flags & FRAG_MASK) == ((1UL << TABLES_PER_PAGE) - 1)) | ||
184 | list_move_tail(&page->lru, &mm->context.pgtable_list); | ||
185 | spin_unlock(&mm->page_table_lock); | ||
84 | return table; | 186 | return table; |
85 | } | 187 | } |
86 | 188 | ||
87 | void page_table_free(unsigned long *table) | 189 | void page_table_free(struct mm_struct *mm, unsigned long *table) |
88 | { | 190 | { |
89 | unsigned long *shadow = get_shadow_pte(table); | 191 | struct page *page; |
192 | unsigned long bits; | ||
90 | 193 | ||
91 | pgtable_page_dtor(virt_to_page(table)); | 194 | bits = mm->context.noexec ? 3UL : 1UL; |
92 | if (shadow) | 195 | bits <<= (__pa(table) & (PAGE_SIZE - 1)) / 256 / sizeof(unsigned long); |
93 | free_page((unsigned long) shadow); | 196 | page = pfn_to_page(__pa(table) >> PAGE_SHIFT); |
94 | free_page((unsigned long) table); | 197 | spin_lock(&mm->page_table_lock); |
198 | page->flags ^= bits; | ||
199 | if (page->flags & FRAG_MASK) { | ||
200 | /* Page now has some free pgtable fragments. */ | ||
201 | list_move(&page->lru, &mm->context.pgtable_list); | ||
202 | page = NULL; | ||
203 | } else | ||
204 | /* All fragments of the 4K page have been freed. */ | ||
205 | list_del(&page->lru); | ||
206 | spin_unlock(&mm->page_table_lock); | ||
207 | if (page) { | ||
208 | pgtable_page_dtor(page); | ||
209 | __free_page(page); | ||
210 | } | ||
211 | } | ||
95 | 212 | ||
213 | void disable_noexec(struct mm_struct *mm, struct task_struct *tsk) | ||
214 | { | ||
215 | struct page *page; | ||
216 | |||
217 | spin_lock(&mm->page_table_lock); | ||
218 | /* Free shadow region and segment tables. */ | ||
219 | list_for_each_entry(page, &mm->context.crst_list, lru) | ||
220 | if (page->index) { | ||
221 | free_pages((unsigned long) page->index, ALLOC_ORDER); | ||
222 | page->index = 0; | ||
223 | } | ||
224 | /* "Free" second halves of page tables. */ | ||
225 | list_for_each_entry(page, &mm->context.pgtable_list, lru) | ||
226 | page->flags &= ~SECOND_HALVES; | ||
227 | spin_unlock(&mm->page_table_lock); | ||
228 | mm->context.noexec = 0; | ||
229 | update_mm(mm, tsk); | ||
96 | } | 230 | } |
diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c index 7c1287ccf788..35d90a4720fd 100644 --- a/arch/s390/mm/vmem.c +++ b/arch/s390/mm/vmem.c | |||
@@ -69,7 +69,19 @@ static void __ref *vmem_alloc_pages(unsigned int order) | |||
69 | return alloc_bootmem_pages((1 << order) * PAGE_SIZE); | 69 | return alloc_bootmem_pages((1 << order) * PAGE_SIZE); |
70 | } | 70 | } |
71 | 71 | ||
72 | #define vmem_pud_alloc() ({ BUG(); ((pud_t *) NULL); }) | 72 | static inline pud_t *vmem_pud_alloc(void) |
73 | { | ||
74 | pud_t *pud = NULL; | ||
75 | |||
76 | #ifdef CONFIG_64BIT | ||
77 | pud = vmem_alloc_pages(2); | ||
78 | if (!pud) | ||
79 | return NULL; | ||
80 | pud_val(*pud) = _REGION3_ENTRY_EMPTY; | ||
81 | memcpy(pud + 1, pud, (PTRS_PER_PUD - 1)*sizeof(pud_t)); | ||
82 | #endif | ||
83 | return pud; | ||
84 | } | ||
73 | 85 | ||
74 | static inline pmd_t *vmem_pmd_alloc(void) | 86 | static inline pmd_t *vmem_pmd_alloc(void) |
75 | { | 87 | { |
@@ -84,13 +96,18 @@ static inline pmd_t *vmem_pmd_alloc(void) | |||
84 | return pmd; | 96 | return pmd; |
85 | } | 97 | } |
86 | 98 | ||
87 | static inline pte_t *vmem_pte_alloc(void) | 99 | static pte_t __init_refok *vmem_pte_alloc(void) |
88 | { | 100 | { |
89 | pte_t *pte = vmem_alloc_pages(0); | 101 | pte_t *pte; |
90 | 102 | ||
103 | if (slab_is_available()) | ||
104 | pte = (pte_t *) page_table_alloc(&init_mm); | ||
105 | else | ||
106 | pte = alloc_bootmem(PTRS_PER_PTE * sizeof(pte_t)); | ||
91 | if (!pte) | 107 | if (!pte) |
92 | return NULL; | 108 | return NULL; |
93 | clear_table((unsigned long *) pte, _PAGE_TYPE_EMPTY, PAGE_SIZE); | 109 | clear_table((unsigned long *) pte, _PAGE_TYPE_EMPTY, |
110 | PTRS_PER_PTE * sizeof(pte_t)); | ||
94 | return pte; | 111 | return pte; |
95 | } | 112 | } |
96 | 113 | ||
@@ -360,6 +377,9 @@ void __init vmem_map_init(void) | |||
360 | { | 377 | { |
361 | int i; | 378 | int i; |
362 | 379 | ||
380 | INIT_LIST_HEAD(&init_mm.context.crst_list); | ||
381 | INIT_LIST_HEAD(&init_mm.context.pgtable_list); | ||
382 | init_mm.context.noexec = 0; | ||
363 | NODE_DATA(0)->node_mem_map = VMEM_MAP; | 383 | NODE_DATA(0)->node_mem_map = VMEM_MAP; |
364 | for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) | 384 | for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) |
365 | vmem_add_mem(memory_chunk[i].addr, memory_chunk[i].size); | 385 | vmem_add_mem(memory_chunk[i].addr, memory_chunk[i].size); |
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 6e035d1cf789..d87d4bf88803 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig | |||
@@ -8,6 +8,7 @@ mainmenu "Linux/SuperH Kernel Configuration" | |||
8 | config SUPERH | 8 | config SUPERH |
9 | def_bool y | 9 | def_bool y |
10 | select EMBEDDED | 10 | select EMBEDDED |
11 | select HAVE_IDE | ||
11 | select HAVE_OPROFILE | 12 | select HAVE_OPROFILE |
12 | help | 13 | help |
13 | The SuperH is a RISC processor targeted for use in embedded systems | 14 | The SuperH is a RISC processor targeted for use in embedded systems |
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 7c674a3503b6..c40343c54920 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig | |||
@@ -69,6 +69,7 @@ config NR_CPUS | |||
69 | config SPARC | 69 | config SPARC |
70 | bool | 70 | bool |
71 | default y | 71 | default y |
72 | select HAVE_IDE | ||
72 | select HAVE_OPROFILE | 73 | select HAVE_OPROFILE |
73 | 74 | ||
74 | # Identify this as a Sparc32 build | 75 | # Identify this as a Sparc32 build |
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig index 4ac22f4f9798..3af378ddb6ae 100644 --- a/arch/sparc64/Kconfig +++ b/arch/sparc64/Kconfig | |||
@@ -14,6 +14,7 @@ config SPARC | |||
14 | config SPARC64 | 14 | config SPARC64 |
15 | bool | 15 | bool |
16 | default y | 16 | default y |
17 | select HAVE_IDE | ||
17 | help | 18 | help |
18 | SPARC is a family of RISC microprocessors designed and marketed by | 19 | SPARC is a family of RISC microprocessors designed and marketed by |
19 | Sun Microsystems, incorporated. This port covers the newer 64-bit | 20 | Sun Microsystems, incorporated. This port covers the newer 64-bit |
diff --git a/arch/v850/Kconfig b/arch/v850/Kconfig index 7b6d3716efca..4379f43505ef 100644 --- a/arch/v850/Kconfig +++ b/arch/v850/Kconfig | |||
@@ -78,6 +78,7 @@ config MCA | |||
78 | config V850 | 78 | config V850 |
79 | bool | 79 | bool |
80 | default y | 80 | default y |
81 | select HAVE_IDE | ||
81 | 82 | ||
82 | menu "Processor type and features" | 83 | menu "Processor type and features" |
83 | 84 | ||
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 65a70b777c12..aaed1a3b92d6 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -18,6 +18,7 @@ config X86_64 | |||
18 | ### Arch settings | 18 | ### Arch settings |
19 | config X86 | 19 | config X86 |
20 | def_bool y | 20 | def_bool y |
21 | select HAVE_IDE | ||
21 | select HAVE_OPROFILE | 22 | select HAVE_OPROFILE |
22 | select HAVE_KPROBES | 23 | select HAVE_KPROBES |
23 | 24 | ||
@@ -102,6 +103,9 @@ config ARCH_HAS_ILOG2_U32 | |||
102 | config ARCH_HAS_ILOG2_U64 | 103 | config ARCH_HAS_ILOG2_U64 |
103 | def_bool n | 104 | def_bool n |
104 | 105 | ||
106 | config ARCH_HAS_CPU_IDLE_WAIT | ||
107 | def_bool y | ||
108 | |||
105 | config GENERIC_CALIBRATE_DELAY | 109 | config GENERIC_CALIBRATE_DELAY |
106 | def_bool y | 110 | def_bool y |
107 | 111 | ||
diff --git a/arch/x86/boot/.gitignore b/arch/x86/boot/.gitignore index 18465143cfa2..b1bdc4c6f9f2 100644 --- a/arch/x86/boot/.gitignore +++ b/arch/x86/boot/.gitignore | |||
@@ -3,3 +3,5 @@ bzImage | |||
3 | setup | 3 | setup |
4 | setup.bin | 4 | setup.bin |
5 | setup.elf | 5 | setup.elf |
6 | cpustr.h | ||
7 | mkcpustr | ||
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index fd36764d7fb7..9fc8551a1cf6 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig | |||
@@ -14,6 +14,7 @@ config ZONE_DMA | |||
14 | config XTENSA | 14 | config XTENSA |
15 | bool | 15 | bool |
16 | default y | 16 | default y |
17 | select HAVE_IDE | ||
17 | help | 18 | help |
18 | Xtensa processors are 32-bit RISC machines designed by Tensilica | 19 | Xtensa processors are 32-bit RISC machines designed by Tensilica |
19 | primarily for embedded systems. These processors are both | 20 | primarily for embedded systems. These processors are both |
diff --git a/drivers/Kconfig b/drivers/Kconfig index b86877bdc7ac..3a0e3549739f 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig | |||
@@ -80,6 +80,8 @@ source "drivers/usb/Kconfig" | |||
80 | 80 | ||
81 | source "drivers/mmc/Kconfig" | 81 | source "drivers/mmc/Kconfig" |
82 | 82 | ||
83 | source "drivers/memstick/Kconfig" | ||
84 | |||
83 | source "drivers/leds/Kconfig" | 85 | source "drivers/leds/Kconfig" |
84 | 86 | ||
85 | source "drivers/infiniband/Kconfig" | 87 | source "drivers/infiniband/Kconfig" |
diff --git a/drivers/Makefile b/drivers/Makefile index 30ba97ec5eb5..e5e394a7e6c0 100644 --- a/drivers/Makefile +++ b/drivers/Makefile | |||
@@ -78,6 +78,7 @@ obj-y += lguest/ | |||
78 | obj-$(CONFIG_CPU_FREQ) += cpufreq/ | 78 | obj-$(CONFIG_CPU_FREQ) += cpufreq/ |
79 | obj-$(CONFIG_CPU_IDLE) += cpuidle/ | 79 | obj-$(CONFIG_CPU_IDLE) += cpuidle/ |
80 | obj-$(CONFIG_MMC) += mmc/ | 80 | obj-$(CONFIG_MMC) += mmc/ |
81 | obj-$(CONFIG_MEMSTICK) += memstick/ | ||
81 | obj-$(CONFIG_NEW_LEDS) += leds/ | 82 | obj-$(CONFIG_NEW_LEDS) += leds/ |
82 | obj-$(CONFIG_INFINIBAND) += infiniband/ | 83 | obj-$(CONFIG_INFINIBAND) += infiniband/ |
83 | obj-$(CONFIG_SGI_SN) += sn/ | 84 | obj-$(CONFIG_SGI_SN) += sn/ |
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index f29812a86533..40b0fcae4c78 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -60,5 +60,5 @@ obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o | |||
60 | obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o | 60 | obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o |
61 | obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o | 61 | obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o |
62 | obj-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o | 62 | obj-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o |
63 | obj-$(CONFIG_ACPI_SBS) += sbs.o | ||
64 | obj-$(CONFIG_ACPI_SBS) += sbshc.o | 63 | obj-$(CONFIG_ACPI_SBS) += sbshc.o |
64 | obj-$(CONFIG_ACPI_SBS) += sbs.o | ||
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index 1194105cc3ca..585ae3c9c8ea 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c | |||
@@ -827,7 +827,7 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) | |||
827 | #endif | 827 | #endif |
828 | printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n", | 828 | printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n", |
829 | ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), | 829 | ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), |
830 | battery->name, sbs->battery->present ? "present" : "absent"); | 830 | battery->name, battery->present ? "present" : "absent"); |
831 | return result; | 831 | return result; |
832 | } | 832 | } |
833 | 833 | ||
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c index ae9a90438e2f..a2cf3008ce6c 100644 --- a/drivers/acpi/sbshc.c +++ b/drivers/acpi/sbshc.c | |||
@@ -117,6 +117,11 @@ static int acpi_smbus_transaction(struct acpi_smb_hc *hc, u8 protocol, | |||
117 | int ret = -EFAULT, i; | 117 | int ret = -EFAULT, i; |
118 | u8 temp, sz = 0; | 118 | u8 temp, sz = 0; |
119 | 119 | ||
120 | if (!hc) { | ||
121 | printk(KERN_ERR PREFIX "host controller is not configured\n"); | ||
122 | return ret; | ||
123 | } | ||
124 | |||
120 | mutex_lock(&hc->lock); | 125 | mutex_lock(&hc->lock); |
121 | if (smb_hc_read(hc, ACPI_SMB_PROTOCOL, &temp)) | 126 | if (smb_hc_read(hc, ACPI_SMB_PROTOCOL, &temp)) |
122 | goto end; | 127 | goto end; |
@@ -292,6 +297,7 @@ static int acpi_smbus_hc_remove(struct acpi_device *device, int type) | |||
292 | hc = acpi_driver_data(device); | 297 | hc = acpi_driver_data(device); |
293 | acpi_ec_remove_query_handler(hc->ec, hc->query_bit); | 298 | acpi_ec_remove_query_handler(hc->ec, hc->query_bit); |
294 | kfree(hc); | 299 | kfree(hc); |
300 | acpi_driver_data(device) = NULL; | ||
295 | return 0; | 301 | return 0; |
296 | } | 302 | } |
297 | 303 | ||
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index a70c1c29a7aa..c452e2d355ee 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
@@ -657,7 +657,6 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq) | |||
657 | if ((cmd = ub_get_cmd(lun)) == NULL) | 657 | if ((cmd = ub_get_cmd(lun)) == NULL) |
658 | return -1; | 658 | return -1; |
659 | memset(cmd, 0, sizeof(struct ub_scsi_cmd)); | 659 | memset(cmd, 0, sizeof(struct ub_scsi_cmd)); |
660 | sg_init_table(cmd->sgv, UB_MAX_REQ_SG); | ||
661 | 660 | ||
662 | blkdev_dequeue_request(rq); | 661 | blkdev_dequeue_request(rq); |
663 | 662 | ||
@@ -668,6 +667,7 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq) | |||
668 | /* | 667 | /* |
669 | * get scatterlist from block layer | 668 | * get scatterlist from block layer |
670 | */ | 669 | */ |
670 | sg_init_table(&urq->sgv[0], UB_MAX_REQ_SG); | ||
671 | n_elem = blk_rq_map_sg(lun->disk->queue, rq, &urq->sgv[0]); | 671 | n_elem = blk_rq_map_sg(lun->disk->queue, rq, &urq->sgv[0]); |
672 | if (n_elem < 0) { | 672 | if (n_elem < 0) { |
673 | /* Impossible, because blk_rq_map_sg should not hit ENOMEM. */ | 673 | /* Impossible, because blk_rq_map_sg should not hit ENOMEM. */ |
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index f01ac9a07bf5..47c6be84fc84 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -875,7 +875,7 @@ config SONYPI | |||
875 | Device which can be found in many (all ?) Sony Vaio laptops. | 875 | Device which can be found in many (all ?) Sony Vaio laptops. |
876 | 876 | ||
877 | If you have one of those laptops, read | 877 | If you have one of those laptops, read |
878 | <file:Documentation/sonypi.txt>, and say Y or M here. | 878 | <file:Documentation/laptops/sonypi.txt>, and say Y or M here. |
879 | 879 | ||
880 | To compile this driver as a module, choose M here: the | 880 | To compile this driver as a module, choose M here: the |
881 | module will be called sonypi. | 881 | module will be called sonypi. |
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 2c4b2d47973e..60f71e6345e3 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
@@ -27,6 +27,17 @@ static void (*pm_idle_old)(void); | |||
27 | 27 | ||
28 | static int enabled_devices; | 28 | static int enabled_devices; |
29 | 29 | ||
30 | #if defined(CONFIG_ARCH_HAS_CPU_IDLE_WAIT) | ||
31 | static void cpuidle_kick_cpus(void) | ||
32 | { | ||
33 | cpu_idle_wait(); | ||
34 | } | ||
35 | #elif defined(CONFIG_SMP) | ||
36 | # error "Arch needs cpu_idle_wait() equivalent here" | ||
37 | #else /* !CONFIG_ARCH_HAS_CPU_IDLE_WAIT && !CONFIG_SMP */ | ||
38 | static void cpuidle_kick_cpus(void) {} | ||
39 | #endif | ||
40 | |||
30 | /** | 41 | /** |
31 | * cpuidle_idle_call - the main idle loop | 42 | * cpuidle_idle_call - the main idle loop |
32 | * | 43 | * |
@@ -83,7 +94,7 @@ void cpuidle_uninstall_idle_handler(void) | |||
83 | { | 94 | { |
84 | if (enabled_devices && (pm_idle != pm_idle_old)) { | 95 | if (enabled_devices && (pm_idle != pm_idle_old)) { |
85 | pm_idle = pm_idle_old; | 96 | pm_idle = pm_idle_old; |
86 | cpu_idle_wait(); | 97 | cpuidle_kick_cpus(); |
87 | } | 98 | } |
88 | } | 99 | } |
89 | 100 | ||
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index ab8fb257528e..043c34ad0a05 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -4,10 +4,14 @@ | |||
4 | # Andre Hedrick <andre@linux-ide.org> | 4 | # Andre Hedrick <andre@linux-ide.org> |
5 | # | 5 | # |
6 | 6 | ||
7 | # Select HAVE_IDE if IDE is supported | ||
8 | config HAVE_IDE | ||
9 | def_bool n | ||
10 | |||
7 | menuconfig IDE | 11 | menuconfig IDE |
8 | tristate "ATA/ATAPI/MFM/RLL support" | 12 | tristate "ATA/ATAPI/MFM/RLL support" |
13 | depends on HAVE_IDE | ||
9 | depends on BLOCK | 14 | depends on BLOCK |
10 | depends on HAS_IOMEM | ||
11 | ---help--- | 15 | ---help--- |
12 | If you say Y here, your kernel will be able to manage low cost mass | 16 | If you say Y here, your kernel will be able to manage low cost mass |
13 | storage units such as ATA/(E)IDE and ATAPI units. The most common | 17 | storage units such as ATA/(E)IDE and ATAPI units. The most common |
diff --git a/drivers/media/video/em28xx/Kconfig b/drivers/media/video/em28xx/Kconfig index abbd38c1ebba..0f7a0bd86ff4 100644 --- a/drivers/media/video/em28xx/Kconfig +++ b/drivers/media/video/em28xx/Kconfig | |||
@@ -13,7 +13,8 @@ config VIDEO_EM28XX | |||
13 | module will be called em28xx | 13 | module will be called em28xx |
14 | 14 | ||
15 | config VIDEO_EM28XX_ALSA | 15 | config VIDEO_EM28XX_ALSA |
16 | depends on VIDEO_EM28XX | 16 | depends on VIDEO_EM28XX && SND |
17 | select SND_PCM | ||
17 | tristate "Empia EM28xx ALSA audio module" | 18 | tristate "Empia EM28xx ALSA audio module" |
18 | ---help--- | 19 | ---help--- |
19 | This is an ALSA driver for some Empia 28xx based TV cards. | 20 | This is an ALSA driver for some Empia 28xx based TV cards. |
diff --git a/drivers/memstick/Kconfig b/drivers/memstick/Kconfig new file mode 100644 index 000000000000..1093fdb07297 --- /dev/null +++ b/drivers/memstick/Kconfig | |||
@@ -0,0 +1,26 @@ | |||
1 | # | ||
2 | # MemoryStick subsystem configuration | ||
3 | # | ||
4 | |||
5 | menuconfig MEMSTICK | ||
6 | tristate "Sony MemoryStick card support (EXPERIMENTAL)" | ||
7 | help | ||
8 | Sony MemoryStick is a proprietary storage/extension card protocol. | ||
9 | |||
10 | If you want MemoryStick support, you should say Y here and also | ||
11 | to the specific driver for your MMC interface. | ||
12 | |||
13 | if MEMSTICK | ||
14 | |||
15 | config MEMSTICK_DEBUG | ||
16 | bool "MemoryStick debugging" | ||
17 | help | ||
18 | This is an option for use by developers; most people should | ||
19 | say N here. This enables MemoryStick core and driver debugging. | ||
20 | |||
21 | |||
22 | source "drivers/memstick/core/Kconfig" | ||
23 | |||
24 | source "drivers/memstick/host/Kconfig" | ||
25 | |||
26 | endif # MEMSTICK | ||
diff --git a/drivers/memstick/Makefile b/drivers/memstick/Makefile new file mode 100644 index 000000000000..dc160fb43515 --- /dev/null +++ b/drivers/memstick/Makefile | |||
@@ -0,0 +1,11 @@ | |||
1 | # | ||
2 | # Makefile for the kernel MemoryStick device drivers. | ||
3 | # | ||
4 | |||
5 | ifeq ($(CONFIG_MEMSTICK_DEBUG),y) | ||
6 | EXTRA_CFLAGS += -DDEBUG | ||
7 | endif | ||
8 | |||
9 | obj-$(CONFIG_MEMSTICK) += core/ | ||
10 | obj-$(CONFIG_MEMSTICK) += host/ | ||
11 | |||
diff --git a/drivers/memstick/core/Kconfig b/drivers/memstick/core/Kconfig new file mode 100644 index 000000000000..95f1814b5368 --- /dev/null +++ b/drivers/memstick/core/Kconfig | |||
@@ -0,0 +1,26 @@ | |||
1 | # | ||
2 | # MemoryStick core configuration | ||
3 | # | ||
4 | |||
5 | comment "MemoryStick drivers" | ||
6 | |||
7 | config MEMSTICK_UNSAFE_RESUME | ||
8 | bool "Allow unsafe resume (DANGEROUS)" | ||
9 | help | ||
10 | If you say Y here, the MemoryStick layer will assume that all | ||
11 | cards stayed in their respective slots during the suspend. The | ||
12 | normal behaviour is to remove them at suspend and | ||
13 | redetecting them at resume. Breaking this assumption will | ||
14 | in most cases result in data corruption. | ||
15 | |||
16 | This option is usually just for embedded systems which use | ||
17 | a MemoryStick card for rootfs. Most people should say N here. | ||
18 | |||
19 | config MSPRO_BLOCK | ||
20 | tristate "MemoryStick Pro block device driver" | ||
21 | depends on BLOCK | ||
22 | help | ||
23 | Say Y here to enable the MemoryStick Pro block device driver | ||
24 | support. This provides a block device driver, which you can use | ||
25 | to mount the filesystem. Almost everyone wishing MemoryStick | ||
26 | support should say Y or M here. | ||
diff --git a/drivers/memstick/core/Makefile b/drivers/memstick/core/Makefile new file mode 100644 index 000000000000..8b2b5293877e --- /dev/null +++ b/drivers/memstick/core/Makefile | |||
@@ -0,0 +1,11 @@ | |||
1 | # | ||
2 | # Makefile for the kernel MemoryStick core. | ||
3 | # | ||
4 | |||
5 | ifeq ($(CONFIG_MEMSTICK_DEBUG),y) | ||
6 | EXTRA_CFLAGS += -DDEBUG | ||
7 | endif | ||
8 | |||
9 | obj-$(CONFIG_MEMSTICK) += memstick.o | ||
10 | |||
11 | obj-$(CONFIG_MSPRO_BLOCK) += mspro_block.o | ||
diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c new file mode 100644 index 000000000000..bba467fe4bce --- /dev/null +++ b/drivers/memstick/core/memstick.c | |||
@@ -0,0 +1,614 @@ | |||
1 | /* | ||
2 | * Sony MemoryStick support | ||
3 | * | ||
4 | * Copyright (C) 2007 Alex Dubov <oakad@yahoo.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * Special thanks to Carlos Corbacho for providing various MemoryStick cards | ||
11 | * that made this driver possible. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/memstick.h> | ||
16 | #include <linux/idr.h> | ||
17 | #include <linux/fs.h> | ||
18 | #include <linux/delay.h> | ||
19 | |||
20 | #define DRIVER_NAME "memstick" | ||
21 | #define DRIVER_VERSION "0.2" | ||
22 | |||
23 | static unsigned int cmd_retries = 3; | ||
24 | module_param(cmd_retries, uint, 0644); | ||
25 | |||
26 | static struct workqueue_struct *workqueue; | ||
27 | static DEFINE_IDR(memstick_host_idr); | ||
28 | static DEFINE_SPINLOCK(memstick_host_lock); | ||
29 | |||
30 | static int memstick_dev_match(struct memstick_dev *card, | ||
31 | struct memstick_device_id *id) | ||
32 | { | ||
33 | if (id->match_flags & MEMSTICK_MATCH_ALL) { | ||
34 | if ((id->type == card->id.type) | ||
35 | && (id->category == card->id.category) | ||
36 | && (id->class == card->id.class)) | ||
37 | return 1; | ||
38 | } | ||
39 | |||
40 | return 0; | ||
41 | } | ||
42 | |||
43 | static int memstick_bus_match(struct device *dev, struct device_driver *drv) | ||
44 | { | ||
45 | struct memstick_dev *card = container_of(dev, struct memstick_dev, | ||
46 | dev); | ||
47 | struct memstick_driver *ms_drv = container_of(drv, | ||
48 | struct memstick_driver, | ||
49 | driver); | ||
50 | struct memstick_device_id *ids = ms_drv->id_table; | ||
51 | |||
52 | if (ids) { | ||
53 | while (ids->match_flags) { | ||
54 | if (memstick_dev_match(card, ids)) | ||
55 | return 1; | ||
56 | ++ids; | ||
57 | } | ||
58 | } | ||
59 | return 0; | ||
60 | } | ||
61 | |||
62 | static int memstick_uevent(struct device *dev, struct kobj_uevent_env *env) | ||
63 | { | ||
64 | struct memstick_dev *card = container_of(dev, struct memstick_dev, | ||
65 | dev); | ||
66 | |||
67 | if (add_uevent_var(env, "MEMSTICK_TYPE=%02X", card->id.type)) | ||
68 | return -ENOMEM; | ||
69 | |||
70 | if (add_uevent_var(env, "MEMSTICK_CATEGORY=%02X", card->id.category)) | ||
71 | return -ENOMEM; | ||
72 | |||
73 | if (add_uevent_var(env, "MEMSTICK_CLASS=%02X", card->id.class)) | ||
74 | return -ENOMEM; | ||
75 | |||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | static int memstick_device_probe(struct device *dev) | ||
80 | { | ||
81 | struct memstick_dev *card = container_of(dev, struct memstick_dev, | ||
82 | dev); | ||
83 | struct memstick_driver *drv = container_of(dev->driver, | ||
84 | struct memstick_driver, | ||
85 | driver); | ||
86 | int rc = -ENODEV; | ||
87 | |||
88 | if (dev->driver && drv->probe) { | ||
89 | rc = drv->probe(card); | ||
90 | if (!rc) | ||
91 | get_device(dev); | ||
92 | } | ||
93 | return rc; | ||
94 | } | ||
95 | |||
96 | static int memstick_device_remove(struct device *dev) | ||
97 | { | ||
98 | struct memstick_dev *card = container_of(dev, struct memstick_dev, | ||
99 | dev); | ||
100 | struct memstick_driver *drv = container_of(dev->driver, | ||
101 | struct memstick_driver, | ||
102 | driver); | ||
103 | |||
104 | if (dev->driver && drv->remove) { | ||
105 | drv->remove(card); | ||
106 | card->dev.driver = NULL; | ||
107 | } | ||
108 | |||
109 | put_device(dev); | ||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | #ifdef CONFIG_PM | ||
114 | |||
115 | static int memstick_device_suspend(struct device *dev, pm_message_t state) | ||
116 | { | ||
117 | struct memstick_dev *card = container_of(dev, struct memstick_dev, | ||
118 | dev); | ||
119 | struct memstick_driver *drv = container_of(dev->driver, | ||
120 | struct memstick_driver, | ||
121 | driver); | ||
122 | |||
123 | if (dev->driver && drv->suspend) | ||
124 | return drv->suspend(card, state); | ||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | static int memstick_device_resume(struct device *dev) | ||
129 | { | ||
130 | struct memstick_dev *card = container_of(dev, struct memstick_dev, | ||
131 | dev); | ||
132 | struct memstick_driver *drv = container_of(dev->driver, | ||
133 | struct memstick_driver, | ||
134 | driver); | ||
135 | |||
136 | if (dev->driver && drv->resume) | ||
137 | return drv->resume(card); | ||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | #else | ||
142 | |||
143 | #define memstick_device_suspend NULL | ||
144 | #define memstick_device_resume NULL | ||
145 | |||
146 | #endif /* CONFIG_PM */ | ||
147 | |||
148 | #define MEMSTICK_ATTR(name, format) \ | ||
149 | static ssize_t name##_show(struct device *dev, struct device_attribute *attr, \ | ||
150 | char *buf) \ | ||
151 | { \ | ||
152 | struct memstick_dev *card = container_of(dev, struct memstick_dev, \ | ||
153 | dev); \ | ||
154 | return sprintf(buf, format, card->id.name); \ | ||
155 | } | ||
156 | |||
157 | MEMSTICK_ATTR(type, "%02X"); | ||
158 | MEMSTICK_ATTR(category, "%02X"); | ||
159 | MEMSTICK_ATTR(class, "%02X"); | ||
160 | |||
161 | #define MEMSTICK_ATTR_RO(name) __ATTR(name, S_IRUGO, name##_show, NULL) | ||
162 | |||
163 | static struct device_attribute memstick_dev_attrs[] = { | ||
164 | MEMSTICK_ATTR_RO(type), | ||
165 | MEMSTICK_ATTR_RO(category), | ||
166 | MEMSTICK_ATTR_RO(class), | ||
167 | __ATTR_NULL | ||
168 | }; | ||
169 | |||
170 | static struct bus_type memstick_bus_type = { | ||
171 | .name = "memstick", | ||
172 | .dev_attrs = memstick_dev_attrs, | ||
173 | .match = memstick_bus_match, | ||
174 | .uevent = memstick_uevent, | ||
175 | .probe = memstick_device_probe, | ||
176 | .remove = memstick_device_remove, | ||
177 | .suspend = memstick_device_suspend, | ||
178 | .resume = memstick_device_resume | ||
179 | }; | ||
180 | |||
181 | static void memstick_free(struct class_device *cdev) | ||
182 | { | ||
183 | struct memstick_host *host = container_of(cdev, struct memstick_host, | ||
184 | cdev); | ||
185 | kfree(host); | ||
186 | } | ||
187 | |||
188 | static struct class memstick_host_class = { | ||
189 | .name = "memstick_host", | ||
190 | .release = memstick_free | ||
191 | }; | ||
192 | |||
193 | static void memstick_free_card(struct device *dev) | ||
194 | { | ||
195 | struct memstick_dev *card = container_of(dev, struct memstick_dev, | ||
196 | dev); | ||
197 | kfree(card); | ||
198 | } | ||
199 | |||
200 | static int memstick_dummy_check(struct memstick_dev *card) | ||
201 | { | ||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | /** | ||
206 | * memstick_detect_change - schedule media detection on memstick host | ||
207 | * @host - host to use | ||
208 | */ | ||
209 | void memstick_detect_change(struct memstick_host *host) | ||
210 | { | ||
211 | queue_work(workqueue, &host->media_checker); | ||
212 | } | ||
213 | EXPORT_SYMBOL(memstick_detect_change); | ||
214 | |||
215 | /** | ||
216 | * memstick_next_req - called by host driver to obtain next request to process | ||
217 | * @host - host to use | ||
218 | * @mrq - pointer to stick the request to | ||
219 | * | ||
220 | * Host calls this function from idle state (*mrq == NULL) or after finishing | ||
221 | * previous request (*mrq should point to it). If previous request was | ||
222 | * unsuccessful, it is retried for predetermined number of times. Return value | ||
223 | * of 0 means that new request was assigned to the host. | ||
224 | */ | ||
225 | int memstick_next_req(struct memstick_host *host, struct memstick_request **mrq) | ||
226 | { | ||
227 | int rc = -ENXIO; | ||
228 | |||
229 | if ((*mrq) && (*mrq)->error && host->retries) { | ||
230 | (*mrq)->error = rc; | ||
231 | host->retries--; | ||
232 | return 0; | ||
233 | } | ||
234 | |||
235 | if (host->card && host->card->next_request) | ||
236 | rc = host->card->next_request(host->card, mrq); | ||
237 | |||
238 | if (!rc) | ||
239 | host->retries = cmd_retries; | ||
240 | else | ||
241 | *mrq = NULL; | ||
242 | |||
243 | return rc; | ||
244 | } | ||
245 | EXPORT_SYMBOL(memstick_next_req); | ||
246 | |||
247 | /** | ||
248 | * memstick_new_req - notify the host that some requests are pending | ||
249 | * @host - host to use | ||
250 | */ | ||
251 | void memstick_new_req(struct memstick_host *host) | ||
252 | { | ||
253 | host->retries = cmd_retries; | ||
254 | host->request(host); | ||
255 | } | ||
256 | EXPORT_SYMBOL(memstick_new_req); | ||
257 | |||
258 | /** | ||
259 | * memstick_init_req_sg - set request fields needed for bulk data transfer | ||
260 | * @mrq - request to use | ||
261 | * @tpc - memstick Transport Protocol Command | ||
262 | * @sg - TPC argument | ||
263 | */ | ||
264 | void memstick_init_req_sg(struct memstick_request *mrq, unsigned char tpc, | ||
265 | struct scatterlist *sg) | ||
266 | { | ||
267 | mrq->tpc = tpc; | ||
268 | if (tpc & 8) | ||
269 | mrq->data_dir = WRITE; | ||
270 | else | ||
271 | mrq->data_dir = READ; | ||
272 | |||
273 | mrq->sg = *sg; | ||
274 | mrq->io_type = MEMSTICK_IO_SG; | ||
275 | |||
276 | if (tpc == MS_TPC_SET_CMD || tpc == MS_TPC_EX_SET_CMD) | ||
277 | mrq->need_card_int = 1; | ||
278 | else | ||
279 | mrq->need_card_int = 0; | ||
280 | |||
281 | mrq->get_int_reg = 0; | ||
282 | } | ||
283 | EXPORT_SYMBOL(memstick_init_req_sg); | ||
284 | |||
285 | /** | ||
286 | * memstick_init_req - set request fields needed for short data transfer | ||
287 | * @mrq - request to use | ||
288 | * @tpc - memstick Transport Protocol Command | ||
289 | * @buf - TPC argument buffer | ||
290 | * @length - TPC argument size | ||
291 | * | ||
292 | * The intended use of this function (transfer of data items several bytes | ||
293 | * in size) allows us to just copy the value between request structure and | ||
294 | * user supplied buffer. | ||
295 | */ | ||
296 | void memstick_init_req(struct memstick_request *mrq, unsigned char tpc, | ||
297 | void *buf, size_t length) | ||
298 | { | ||
299 | mrq->tpc = tpc; | ||
300 | if (tpc & 8) | ||
301 | mrq->data_dir = WRITE; | ||
302 | else | ||
303 | mrq->data_dir = READ; | ||
304 | |||
305 | mrq->data_len = length > sizeof(mrq->data) ? sizeof(mrq->data) : length; | ||
306 | if (mrq->data_dir == WRITE) | ||
307 | memcpy(mrq->data, buf, mrq->data_len); | ||
308 | |||
309 | mrq->io_type = MEMSTICK_IO_VAL; | ||
310 | |||
311 | if (tpc == MS_TPC_SET_CMD || tpc == MS_TPC_EX_SET_CMD) | ||
312 | mrq->need_card_int = 1; | ||
313 | else | ||
314 | mrq->need_card_int = 0; | ||
315 | |||
316 | mrq->get_int_reg = 0; | ||
317 | } | ||
318 | EXPORT_SYMBOL(memstick_init_req); | ||
319 | |||
320 | /* | ||
321 | * Functions prefixed with "h_" are protocol callbacks. They can be called from | ||
322 | * interrupt context. Return value of 0 means that request processing is still | ||
323 | * ongoing, while special error value of -EAGAIN means that current request is | ||
324 | * finished (and request processor should come back some time later). | ||
325 | */ | ||
326 | |||
327 | static int h_memstick_read_dev_id(struct memstick_dev *card, | ||
328 | struct memstick_request **mrq) | ||
329 | { | ||
330 | struct ms_id_register id_reg; | ||
331 | |||
332 | if (!(*mrq)) { | ||
333 | memstick_init_req(&card->current_mrq, MS_TPC_READ_REG, NULL, | ||
334 | sizeof(struct ms_id_register)); | ||
335 | *mrq = &card->current_mrq; | ||
336 | return 0; | ||
337 | } else { | ||
338 | if (!(*mrq)->error) { | ||
339 | memcpy(&id_reg, (*mrq)->data, sizeof(id_reg)); | ||
340 | card->id.match_flags = MEMSTICK_MATCH_ALL; | ||
341 | card->id.type = id_reg.type; | ||
342 | card->id.category = id_reg.category; | ||
343 | card->id.class = id_reg.class; | ||
344 | } | ||
345 | complete(&card->mrq_complete); | ||
346 | return -EAGAIN; | ||
347 | } | ||
348 | } | ||
349 | |||
350 | static int h_memstick_set_rw_addr(struct memstick_dev *card, | ||
351 | struct memstick_request **mrq) | ||
352 | { | ||
353 | if (!(*mrq)) { | ||
354 | memstick_init_req(&card->current_mrq, MS_TPC_SET_RW_REG_ADRS, | ||
355 | (char *)&card->reg_addr, | ||
356 | sizeof(card->reg_addr)); | ||
357 | *mrq = &card->current_mrq; | ||
358 | return 0; | ||
359 | } else { | ||
360 | complete(&card->mrq_complete); | ||
361 | return -EAGAIN; | ||
362 | } | ||
363 | } | ||
364 | |||
365 | /** | ||
366 | * memstick_set_rw_addr - issue SET_RW_REG_ADDR request and wait for it to | ||
367 | * complete | ||
368 | * @card - media device to use | ||
369 | */ | ||
370 | int memstick_set_rw_addr(struct memstick_dev *card) | ||
371 | { | ||
372 | card->next_request = h_memstick_set_rw_addr; | ||
373 | memstick_new_req(card->host); | ||
374 | wait_for_completion(&card->mrq_complete); | ||
375 | |||
376 | return card->current_mrq.error; | ||
377 | } | ||
378 | EXPORT_SYMBOL(memstick_set_rw_addr); | ||
379 | |||
380 | static struct memstick_dev *memstick_alloc_card(struct memstick_host *host) | ||
381 | { | ||
382 | struct memstick_dev *card = kzalloc(sizeof(struct memstick_dev), | ||
383 | GFP_KERNEL); | ||
384 | struct memstick_dev *old_card = host->card; | ||
385 | struct ms_id_register id_reg; | ||
386 | |||
387 | if (card) { | ||
388 | card->host = host; | ||
389 | snprintf(card->dev.bus_id, sizeof(card->dev.bus_id), | ||
390 | "%s", host->cdev.class_id); | ||
391 | card->dev.parent = host->cdev.dev; | ||
392 | card->dev.bus = &memstick_bus_type; | ||
393 | card->dev.release = memstick_free_card; | ||
394 | card->check = memstick_dummy_check; | ||
395 | |||
396 | card->reg_addr.r_offset = offsetof(struct ms_register, id); | ||
397 | card->reg_addr.r_length = sizeof(id_reg); | ||
398 | card->reg_addr.w_offset = offsetof(struct ms_register, id); | ||
399 | card->reg_addr.w_length = sizeof(id_reg); | ||
400 | |||
401 | init_completion(&card->mrq_complete); | ||
402 | |||
403 | host->card = card; | ||
404 | if (memstick_set_rw_addr(card)) | ||
405 | goto err_out; | ||
406 | |||
407 | card->next_request = h_memstick_read_dev_id; | ||
408 | memstick_new_req(host); | ||
409 | wait_for_completion(&card->mrq_complete); | ||
410 | |||
411 | if (card->current_mrq.error) | ||
412 | goto err_out; | ||
413 | } | ||
414 | host->card = old_card; | ||
415 | return card; | ||
416 | err_out: | ||
417 | host->card = old_card; | ||
418 | kfree(card); | ||
419 | return NULL; | ||
420 | } | ||
421 | |||
422 | static void memstick_power_on(struct memstick_host *host) | ||
423 | { | ||
424 | host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_ON); | ||
425 | host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_SERIAL); | ||
426 | msleep(1); | ||
427 | } | ||
428 | |||
429 | static void memstick_check(struct work_struct *work) | ||
430 | { | ||
431 | struct memstick_host *host = container_of(work, struct memstick_host, | ||
432 | media_checker); | ||
433 | struct memstick_dev *card; | ||
434 | |||
435 | dev_dbg(host->cdev.dev, "memstick_check started\n"); | ||
436 | mutex_lock(&host->lock); | ||
437 | if (!host->card) | ||
438 | memstick_power_on(host); | ||
439 | |||
440 | card = memstick_alloc_card(host); | ||
441 | |||
442 | if (!card) { | ||
443 | if (host->card) { | ||
444 | device_unregister(&host->card->dev); | ||
445 | host->card = NULL; | ||
446 | } | ||
447 | } else { | ||
448 | dev_dbg(host->cdev.dev, "new card %02x, %02x, %02x\n", | ||
449 | card->id.type, card->id.category, card->id.class); | ||
450 | if (host->card) { | ||
451 | if (memstick_set_rw_addr(host->card) | ||
452 | || !memstick_dev_match(host->card, &card->id) | ||
453 | || !(host->card->check(host->card))) { | ||
454 | device_unregister(&host->card->dev); | ||
455 | host->card = NULL; | ||
456 | } | ||
457 | } | ||
458 | |||
459 | if (!host->card) { | ||
460 | host->card = card; | ||
461 | if (device_register(&card->dev)) { | ||
462 | kfree(host->card); | ||
463 | host->card = NULL; | ||
464 | } | ||
465 | } else | ||
466 | kfree(card); | ||
467 | } | ||
468 | |||
469 | if (!host->card) | ||
470 | host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); | ||
471 | |||
472 | mutex_unlock(&host->lock); | ||
473 | dev_dbg(host->cdev.dev, "memstick_check finished\n"); | ||
474 | } | ||
475 | |||
476 | /** | ||
477 | * memstick_alloc_host - allocate a memstick_host structure | ||
478 | * @extra: size of the user private data to allocate | ||
479 | * @dev: parent device of the host | ||
480 | */ | ||
481 | struct memstick_host *memstick_alloc_host(unsigned int extra, | ||
482 | struct device *dev) | ||
483 | { | ||
484 | struct memstick_host *host; | ||
485 | |||
486 | host = kzalloc(sizeof(struct memstick_host) + extra, GFP_KERNEL); | ||
487 | if (host) { | ||
488 | mutex_init(&host->lock); | ||
489 | INIT_WORK(&host->media_checker, memstick_check); | ||
490 | host->cdev.class = &memstick_host_class; | ||
491 | host->cdev.dev = dev; | ||
492 | class_device_initialize(&host->cdev); | ||
493 | } | ||
494 | return host; | ||
495 | } | ||
496 | EXPORT_SYMBOL(memstick_alloc_host); | ||
497 | |||
498 | /** | ||
499 | * memstick_add_host - start request processing on memstick host | ||
500 | * @host - host to use | ||
501 | */ | ||
502 | int memstick_add_host(struct memstick_host *host) | ||
503 | { | ||
504 | int rc; | ||
505 | |||
506 | if (!idr_pre_get(&memstick_host_idr, GFP_KERNEL)) | ||
507 | return -ENOMEM; | ||
508 | |||
509 | spin_lock(&memstick_host_lock); | ||
510 | rc = idr_get_new(&memstick_host_idr, host, &host->id); | ||
511 | spin_unlock(&memstick_host_lock); | ||
512 | if (rc) | ||
513 | return rc; | ||
514 | |||
515 | snprintf(host->cdev.class_id, BUS_ID_SIZE, | ||
516 | "memstick%u", host->id); | ||
517 | |||
518 | rc = class_device_add(&host->cdev); | ||
519 | if (rc) { | ||
520 | spin_lock(&memstick_host_lock); | ||
521 | idr_remove(&memstick_host_idr, host->id); | ||
522 | spin_unlock(&memstick_host_lock); | ||
523 | return rc; | ||
524 | } | ||
525 | |||
526 | host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); | ||
527 | memstick_detect_change(host); | ||
528 | return 0; | ||
529 | } | ||
530 | EXPORT_SYMBOL(memstick_add_host); | ||
531 | |||
532 | /** | ||
533 | * memstick_remove_host - stop request processing on memstick host | ||
534 | * @host - host to use | ||
535 | */ | ||
536 | void memstick_remove_host(struct memstick_host *host) | ||
537 | { | ||
538 | flush_workqueue(workqueue); | ||
539 | mutex_lock(&host->lock); | ||
540 | if (host->card) | ||
541 | device_unregister(&host->card->dev); | ||
542 | host->card = NULL; | ||
543 | host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); | ||
544 | mutex_unlock(&host->lock); | ||
545 | |||
546 | spin_lock(&memstick_host_lock); | ||
547 | idr_remove(&memstick_host_idr, host->id); | ||
548 | spin_unlock(&memstick_host_lock); | ||
549 | class_device_del(&host->cdev); | ||
550 | } | ||
551 | EXPORT_SYMBOL(memstick_remove_host); | ||
552 | |||
553 | /** | ||
554 | * memstick_free_host - free memstick host | ||
555 | * @host - host to use | ||
556 | */ | ||
557 | void memstick_free_host(struct memstick_host *host) | ||
558 | { | ||
559 | mutex_destroy(&host->lock); | ||
560 | class_device_put(&host->cdev); | ||
561 | } | ||
562 | EXPORT_SYMBOL(memstick_free_host); | ||
563 | |||
564 | int memstick_register_driver(struct memstick_driver *drv) | ||
565 | { | ||
566 | drv->driver.bus = &memstick_bus_type; | ||
567 | |||
568 | return driver_register(&drv->driver); | ||
569 | } | ||
570 | EXPORT_SYMBOL(memstick_register_driver); | ||
571 | |||
572 | void memstick_unregister_driver(struct memstick_driver *drv) | ||
573 | { | ||
574 | driver_unregister(&drv->driver); | ||
575 | } | ||
576 | EXPORT_SYMBOL(memstick_unregister_driver); | ||
577 | |||
578 | |||
579 | static int __init memstick_init(void) | ||
580 | { | ||
581 | int rc; | ||
582 | |||
583 | workqueue = create_freezeable_workqueue("kmemstick"); | ||
584 | if (!workqueue) | ||
585 | return -ENOMEM; | ||
586 | |||
587 | rc = bus_register(&memstick_bus_type); | ||
588 | if (!rc) | ||
589 | rc = class_register(&memstick_host_class); | ||
590 | |||
591 | if (!rc) | ||
592 | return 0; | ||
593 | |||
594 | bus_unregister(&memstick_bus_type); | ||
595 | destroy_workqueue(workqueue); | ||
596 | |||
597 | return rc; | ||
598 | } | ||
599 | |||
600 | static void __exit memstick_exit(void) | ||
601 | { | ||
602 | class_unregister(&memstick_host_class); | ||
603 | bus_unregister(&memstick_bus_type); | ||
604 | destroy_workqueue(workqueue); | ||
605 | idr_destroy(&memstick_host_idr); | ||
606 | } | ||
607 | |||
608 | module_init(memstick_init); | ||
609 | module_exit(memstick_exit); | ||
610 | |||
611 | MODULE_AUTHOR("Alex Dubov"); | ||
612 | MODULE_LICENSE("GPL"); | ||
613 | MODULE_DESCRIPTION("Sony MemoryStick core driver"); | ||
614 | MODULE_VERSION(DRIVER_VERSION); | ||
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c new file mode 100644 index 000000000000..423ad8cf4bb9 --- /dev/null +++ b/drivers/memstick/core/mspro_block.c | |||
@@ -0,0 +1,1351 @@ | |||
1 | /* | ||
2 | * Sony MemoryStick Pro storage support | ||
3 | * | ||
4 | * Copyright (C) 2007 Alex Dubov <oakad@yahoo.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * Special thanks to Carlos Corbacho for providing various MemoryStick cards | ||
11 | * that made this driver possible. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/blkdev.h> | ||
16 | #include <linux/idr.h> | ||
17 | #include <linux/hdreg.h> | ||
18 | #include <linux/kthread.h> | ||
19 | #include <linux/memstick.h> | ||
20 | |||
21 | #define DRIVER_NAME "mspro_block" | ||
22 | #define DRIVER_VERSION "0.2" | ||
23 | |||
24 | static int major; | ||
25 | module_param(major, int, 0644); | ||
26 | |||
27 | #define MSPRO_BLOCK_MAX_SEGS 32 | ||
28 | #define MSPRO_BLOCK_MAX_PAGES ((2 << 16) - 1) | ||
29 | |||
30 | #define MSPRO_BLOCK_SIGNATURE 0xa5c3 | ||
31 | #define MSPRO_BLOCK_MAX_ATTRIBUTES 41 | ||
32 | |||
33 | enum { | ||
34 | MSPRO_BLOCK_ID_SYSINFO = 0x10, | ||
35 | MSPRO_BLOCK_ID_MODELNAME = 0x15, | ||
36 | MSPRO_BLOCK_ID_MBR = 0x20, | ||
37 | MSPRO_BLOCK_ID_PBR16 = 0x21, | ||
38 | MSPRO_BLOCK_ID_PBR32 = 0x22, | ||
39 | MSPRO_BLOCK_ID_SPECFILEVALUES1 = 0x25, | ||
40 | MSPRO_BLOCK_ID_SPECFILEVALUES2 = 0x26, | ||
41 | MSPRO_BLOCK_ID_DEVINFO = 0x30 | ||
42 | }; | ||
43 | |||
44 | struct mspro_sys_attr { | ||
45 | size_t size; | ||
46 | void *data; | ||
47 | unsigned char id; | ||
48 | char name[32]; | ||
49 | struct device_attribute dev_attr; | ||
50 | }; | ||
51 | |||
52 | struct mspro_attr_entry { | ||
53 | unsigned int address; | ||
54 | unsigned int size; | ||
55 | unsigned char id; | ||
56 | unsigned char reserved[3]; | ||
57 | } __attribute__((packed)); | ||
58 | |||
59 | struct mspro_attribute { | ||
60 | unsigned short signature; | ||
61 | unsigned short version; | ||
62 | unsigned char count; | ||
63 | unsigned char reserved[11]; | ||
64 | struct mspro_attr_entry entries[]; | ||
65 | } __attribute__((packed)); | ||
66 | |||
67 | struct mspro_sys_info { | ||
68 | unsigned char class; | ||
69 | unsigned char reserved0; | ||
70 | unsigned short block_size; | ||
71 | unsigned short block_count; | ||
72 | unsigned short user_block_count; | ||
73 | unsigned short page_size; | ||
74 | unsigned char reserved1[2]; | ||
75 | unsigned char assembly_date[8]; | ||
76 | unsigned int serial_number; | ||
77 | unsigned char assembly_maker_code; | ||
78 | unsigned char assembly_model_code[3]; | ||
79 | unsigned short memory_maker_code; | ||
80 | unsigned short memory_model_code; | ||
81 | unsigned char reserved2[4]; | ||
82 | unsigned char vcc; | ||
83 | unsigned char vpp; | ||
84 | unsigned short controller_number; | ||
85 | unsigned short controller_function; | ||
86 | unsigned short start_sector; | ||
87 | unsigned short unit_size; | ||
88 | unsigned char ms_sub_class; | ||
89 | unsigned char reserved3[4]; | ||
90 | unsigned char interface_type; | ||
91 | unsigned short controller_code; | ||
92 | unsigned char format_type; | ||
93 | unsigned char reserved4; | ||
94 | unsigned char device_type; | ||
95 | unsigned char reserved5[7]; | ||
96 | unsigned char mspro_id[16]; | ||
97 | unsigned char reserved6[16]; | ||
98 | } __attribute__((packed)); | ||
99 | |||
100 | struct mspro_mbr { | ||
101 | unsigned char boot_partition; | ||
102 | unsigned char start_head; | ||
103 | unsigned char start_sector; | ||
104 | unsigned char start_cylinder; | ||
105 | unsigned char partition_type; | ||
106 | unsigned char end_head; | ||
107 | unsigned char end_sector; | ||
108 | unsigned char end_cylinder; | ||
109 | unsigned int start_sectors; | ||
110 | unsigned int sectors_per_partition; | ||
111 | } __attribute__((packed)); | ||
112 | |||
113 | struct mspro_devinfo { | ||
114 | unsigned short cylinders; | ||
115 | unsigned short heads; | ||
116 | unsigned short bytes_per_track; | ||
117 | unsigned short bytes_per_sector; | ||
118 | unsigned short sectors_per_track; | ||
119 | unsigned char reserved[6]; | ||
120 | } __attribute__((packed)); | ||
121 | |||
122 | struct mspro_block_data { | ||
123 | struct memstick_dev *card; | ||
124 | unsigned int usage_count; | ||
125 | struct gendisk *disk; | ||
126 | struct request_queue *queue; | ||
127 | spinlock_t q_lock; | ||
128 | wait_queue_head_t q_wait; | ||
129 | struct task_struct *q_thread; | ||
130 | |||
131 | unsigned short page_size; | ||
132 | unsigned short cylinders; | ||
133 | unsigned short heads; | ||
134 | unsigned short sectors_per_track; | ||
135 | |||
136 | unsigned char system; | ||
137 | unsigned char read_only:1, | ||
138 | active:1, | ||
139 | has_request:1, | ||
140 | data_dir:1; | ||
141 | unsigned char transfer_cmd; | ||
142 | |||
143 | int (*mrq_handler)(struct memstick_dev *card, | ||
144 | struct memstick_request **mrq); | ||
145 | |||
146 | struct attribute_group attr_group; | ||
147 | |||
148 | struct scatterlist req_sg[MSPRO_BLOCK_MAX_SEGS]; | ||
149 | unsigned int seg_count; | ||
150 | unsigned int current_seg; | ||
151 | unsigned short current_page; | ||
152 | }; | ||
153 | |||
154 | static DEFINE_IDR(mspro_block_disk_idr); | ||
155 | static DEFINE_MUTEX(mspro_block_disk_lock); | ||
156 | |||
157 | /*** Block device ***/ | ||
158 | |||
159 | static int mspro_block_bd_open(struct inode *inode, struct file *filp) | ||
160 | { | ||
161 | struct gendisk *disk = inode->i_bdev->bd_disk; | ||
162 | struct mspro_block_data *msb = disk->private_data; | ||
163 | int rc = -ENXIO; | ||
164 | |||
165 | mutex_lock(&mspro_block_disk_lock); | ||
166 | |||
167 | if (msb && msb->card) { | ||
168 | msb->usage_count++; | ||
169 | if ((filp->f_mode & FMODE_WRITE) && msb->read_only) | ||
170 | rc = -EROFS; | ||
171 | else | ||
172 | rc = 0; | ||
173 | } | ||
174 | |||
175 | mutex_unlock(&mspro_block_disk_lock); | ||
176 | |||
177 | return rc; | ||
178 | } | ||
179 | |||
180 | |||
181 | static int mspro_block_disk_release(struct gendisk *disk) | ||
182 | { | ||
183 | struct mspro_block_data *msb = disk->private_data; | ||
184 | int disk_id = disk->first_minor >> MEMSTICK_PART_SHIFT; | ||
185 | |||
186 | mutex_lock(&mspro_block_disk_lock); | ||
187 | |||
188 | if (msb->usage_count) { | ||
189 | msb->usage_count--; | ||
190 | if (!msb->usage_count) { | ||
191 | kfree(msb); | ||
192 | disk->private_data = NULL; | ||
193 | idr_remove(&mspro_block_disk_idr, disk_id); | ||
194 | put_disk(disk); | ||
195 | } | ||
196 | } | ||
197 | |||
198 | mutex_unlock(&mspro_block_disk_lock); | ||
199 | |||
200 | return 0; | ||
201 | } | ||
202 | |||
203 | static int mspro_block_bd_release(struct inode *inode, struct file *filp) | ||
204 | { | ||
205 | struct gendisk *disk = inode->i_bdev->bd_disk; | ||
206 | return mspro_block_disk_release(disk); | ||
207 | } | ||
208 | |||
209 | static int mspro_block_bd_getgeo(struct block_device *bdev, | ||
210 | struct hd_geometry *geo) | ||
211 | { | ||
212 | struct mspro_block_data *msb = bdev->bd_disk->private_data; | ||
213 | |||
214 | geo->heads = msb->heads; | ||
215 | geo->sectors = msb->sectors_per_track; | ||
216 | geo->cylinders = msb->cylinders; | ||
217 | |||
218 | return 0; | ||
219 | } | ||
220 | |||
221 | static struct block_device_operations ms_block_bdops = { | ||
222 | .open = mspro_block_bd_open, | ||
223 | .release = mspro_block_bd_release, | ||
224 | .getgeo = mspro_block_bd_getgeo, | ||
225 | .owner = THIS_MODULE | ||
226 | }; | ||
227 | |||
228 | /*** Information ***/ | ||
229 | |||
230 | static struct mspro_sys_attr *mspro_from_sysfs_attr(struct attribute *attr) | ||
231 | { | ||
232 | struct device_attribute *dev_attr | ||
233 | = container_of(attr, struct device_attribute, attr); | ||
234 | return container_of(dev_attr, struct mspro_sys_attr, dev_attr); | ||
235 | } | ||
236 | |||
237 | static const char *mspro_block_attr_name(unsigned char tag) | ||
238 | { | ||
239 | switch (tag) { | ||
240 | case MSPRO_BLOCK_ID_SYSINFO: | ||
241 | return "attr_sysinfo"; | ||
242 | case MSPRO_BLOCK_ID_MODELNAME: | ||
243 | return "attr_modelname"; | ||
244 | case MSPRO_BLOCK_ID_MBR: | ||
245 | return "attr_mbr"; | ||
246 | case MSPRO_BLOCK_ID_PBR16: | ||
247 | return "attr_pbr16"; | ||
248 | case MSPRO_BLOCK_ID_PBR32: | ||
249 | return "attr_pbr32"; | ||
250 | case MSPRO_BLOCK_ID_SPECFILEVALUES1: | ||
251 | return "attr_specfilevalues1"; | ||
252 | case MSPRO_BLOCK_ID_SPECFILEVALUES2: | ||
253 | return "attr_specfilevalues2"; | ||
254 | case MSPRO_BLOCK_ID_DEVINFO: | ||
255 | return "attr_devinfo"; | ||
256 | default: | ||
257 | return NULL; | ||
258 | }; | ||
259 | } | ||
260 | |||
261 | typedef ssize_t (*sysfs_show_t)(struct device *dev, | ||
262 | struct device_attribute *attr, | ||
263 | char *buffer); | ||
264 | |||
265 | static ssize_t mspro_block_attr_show_default(struct device *dev, | ||
266 | struct device_attribute *attr, | ||
267 | char *buffer) | ||
268 | { | ||
269 | struct mspro_sys_attr *s_attr = container_of(attr, | ||
270 | struct mspro_sys_attr, | ||
271 | dev_attr); | ||
272 | |||
273 | ssize_t cnt, rc = 0; | ||
274 | |||
275 | for (cnt = 0; cnt < s_attr->size; cnt++) { | ||
276 | if (cnt && !(cnt % 16)) { | ||
277 | if (PAGE_SIZE - rc) | ||
278 | buffer[rc++] = '\n'; | ||
279 | } | ||
280 | |||
281 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "%02x ", | ||
282 | ((unsigned char *)s_attr->data)[cnt]); | ||
283 | } | ||
284 | return rc; | ||
285 | } | ||
286 | |||
287 | static ssize_t mspro_block_attr_show_sysinfo(struct device *dev, | ||
288 | struct device_attribute *attr, | ||
289 | char *buffer) | ||
290 | { | ||
291 | struct mspro_sys_attr *x_attr = container_of(attr, | ||
292 | struct mspro_sys_attr, | ||
293 | dev_attr); | ||
294 | struct mspro_sys_info *x_sys = x_attr->data; | ||
295 | ssize_t rc = 0; | ||
296 | |||
297 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "class: %x\n", | ||
298 | x_sys->class); | ||
299 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "block size: %x\n", | ||
300 | be16_to_cpu(x_sys->block_size)); | ||
301 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "block count: %x\n", | ||
302 | be16_to_cpu(x_sys->block_count)); | ||
303 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "user block count: %x\n", | ||
304 | be16_to_cpu(x_sys->user_block_count)); | ||
305 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "page size: %x\n", | ||
306 | be16_to_cpu(x_sys->page_size)); | ||
307 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "assembly date: " | ||
308 | "%d %04u-%02u-%02u %02u:%02u:%02u\n", | ||
309 | x_sys->assembly_date[0], | ||
310 | be16_to_cpu(*(unsigned short *) | ||
311 | &x_sys->assembly_date[1]), | ||
312 | x_sys->assembly_date[3], x_sys->assembly_date[4], | ||
313 | x_sys->assembly_date[5], x_sys->assembly_date[6], | ||
314 | x_sys->assembly_date[7]); | ||
315 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "serial number: %x\n", | ||
316 | be32_to_cpu(x_sys->serial_number)); | ||
317 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, | ||
318 | "assembly maker code: %x\n", | ||
319 | x_sys->assembly_maker_code); | ||
320 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "assembly model code: " | ||
321 | "%02x%02x%02x\n", x_sys->assembly_model_code[0], | ||
322 | x_sys->assembly_model_code[1], | ||
323 | x_sys->assembly_model_code[2]); | ||
324 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "memory maker code: %x\n", | ||
325 | be16_to_cpu(x_sys->memory_maker_code)); | ||
326 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "memory model code: %x\n", | ||
327 | be16_to_cpu(x_sys->memory_model_code)); | ||
328 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "vcc: %x\n", | ||
329 | x_sys->vcc); | ||
330 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "vpp: %x\n", | ||
331 | x_sys->vpp); | ||
332 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "controller number: %x\n", | ||
333 | be16_to_cpu(x_sys->controller_number)); | ||
334 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, | ||
335 | "controller function: %x\n", | ||
336 | be16_to_cpu(x_sys->controller_function)); | ||
337 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "start sector: %x\n", | ||
338 | be16_to_cpu(x_sys->start_sector)); | ||
339 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "unit size: %x\n", | ||
340 | be16_to_cpu(x_sys->unit_size)); | ||
341 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "sub class: %x\n", | ||
342 | x_sys->ms_sub_class); | ||
343 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "interface type: %x\n", | ||
344 | x_sys->interface_type); | ||
345 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "controller code: %x\n", | ||
346 | be16_to_cpu(x_sys->controller_code)); | ||
347 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "format type: %x\n", | ||
348 | x_sys->format_type); | ||
349 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "device type: %x\n", | ||
350 | x_sys->device_type); | ||
351 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "mspro id: %s\n", | ||
352 | x_sys->mspro_id); | ||
353 | return rc; | ||
354 | } | ||
355 | |||
356 | static ssize_t mspro_block_attr_show_modelname(struct device *dev, | ||
357 | struct device_attribute *attr, | ||
358 | char *buffer) | ||
359 | { | ||
360 | struct mspro_sys_attr *s_attr = container_of(attr, | ||
361 | struct mspro_sys_attr, | ||
362 | dev_attr); | ||
363 | |||
364 | return scnprintf(buffer, PAGE_SIZE, "%s", (char *)s_attr->data); | ||
365 | } | ||
366 | |||
367 | static ssize_t mspro_block_attr_show_mbr(struct device *dev, | ||
368 | struct device_attribute *attr, | ||
369 | char *buffer) | ||
370 | { | ||
371 | struct mspro_sys_attr *x_attr = container_of(attr, | ||
372 | struct mspro_sys_attr, | ||
373 | dev_attr); | ||
374 | struct mspro_mbr *x_mbr = x_attr->data; | ||
375 | ssize_t rc = 0; | ||
376 | |||
377 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "boot partition: %x\n", | ||
378 | x_mbr->boot_partition); | ||
379 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "start head: %x\n", | ||
380 | x_mbr->start_head); | ||
381 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "start sector: %x\n", | ||
382 | x_mbr->start_sector); | ||
383 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "start cylinder: %x\n", | ||
384 | x_mbr->start_cylinder); | ||
385 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "partition type: %x\n", | ||
386 | x_mbr->partition_type); | ||
387 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "end head: %x\n", | ||
388 | x_mbr->end_head); | ||
389 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "end sector: %x\n", | ||
390 | x_mbr->end_sector); | ||
391 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "end cylinder: %x\n", | ||
392 | x_mbr->end_cylinder); | ||
393 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "start sectors: %x\n", | ||
394 | x_mbr->start_sectors); | ||
395 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, | ||
396 | "sectors per partition: %x\n", | ||
397 | x_mbr->sectors_per_partition); | ||
398 | return rc; | ||
399 | } | ||
400 | |||
401 | static ssize_t mspro_block_attr_show_devinfo(struct device *dev, | ||
402 | struct device_attribute *attr, | ||
403 | char *buffer) | ||
404 | { | ||
405 | struct mspro_sys_attr *x_attr = container_of(attr, | ||
406 | struct mspro_sys_attr, | ||
407 | dev_attr); | ||
408 | struct mspro_devinfo *x_devinfo = x_attr->data; | ||
409 | ssize_t rc = 0; | ||
410 | |||
411 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "cylinders: %x\n", | ||
412 | be16_to_cpu(x_devinfo->cylinders)); | ||
413 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "heads: %x\n", | ||
414 | be16_to_cpu(x_devinfo->heads)); | ||
415 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "bytes per track: %x\n", | ||
416 | be16_to_cpu(x_devinfo->bytes_per_track)); | ||
417 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "bytes per sector: %x\n", | ||
418 | be16_to_cpu(x_devinfo->bytes_per_sector)); | ||
419 | rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "sectors per track: %x\n", | ||
420 | be16_to_cpu(x_devinfo->sectors_per_track)); | ||
421 | return rc; | ||
422 | } | ||
423 | |||
424 | static sysfs_show_t mspro_block_attr_show(unsigned char tag) | ||
425 | { | ||
426 | switch (tag) { | ||
427 | case MSPRO_BLOCK_ID_SYSINFO: | ||
428 | return mspro_block_attr_show_sysinfo; | ||
429 | case MSPRO_BLOCK_ID_MODELNAME: | ||
430 | return mspro_block_attr_show_modelname; | ||
431 | case MSPRO_BLOCK_ID_MBR: | ||
432 | return mspro_block_attr_show_mbr; | ||
433 | case MSPRO_BLOCK_ID_DEVINFO: | ||
434 | return mspro_block_attr_show_devinfo; | ||
435 | default: | ||
436 | return mspro_block_attr_show_default; | ||
437 | } | ||
438 | } | ||
439 | |||
440 | /*** Protocol handlers ***/ | ||
441 | |||
442 | /* | ||
443 | * Functions prefixed with "h_" are protocol callbacks. They can be called from | ||
444 | * interrupt context. Return value of 0 means that request processing is still | ||
445 | * ongoing, while special error value of -EAGAIN means that current request is | ||
446 | * finished (and request processor should come back some time later). | ||
447 | */ | ||
448 | |||
449 | static int h_mspro_block_req_init(struct memstick_dev *card, | ||
450 | struct memstick_request **mrq) | ||
451 | { | ||
452 | struct mspro_block_data *msb = memstick_get_drvdata(card); | ||
453 | |||
454 | *mrq = &card->current_mrq; | ||
455 | card->next_request = msb->mrq_handler; | ||
456 | return 0; | ||
457 | } | ||
458 | |||
459 | static int h_mspro_block_default(struct memstick_dev *card, | ||
460 | struct memstick_request **mrq) | ||
461 | { | ||
462 | complete(&card->mrq_complete); | ||
463 | if (!(*mrq)->error) | ||
464 | return -EAGAIN; | ||
465 | else | ||
466 | return (*mrq)->error; | ||
467 | } | ||
468 | |||
469 | static int h_mspro_block_get_ro(struct memstick_dev *card, | ||
470 | struct memstick_request **mrq) | ||
471 | { | ||
472 | struct mspro_block_data *msb = memstick_get_drvdata(card); | ||
473 | |||
474 | if ((*mrq)->error) { | ||
475 | complete(&card->mrq_complete); | ||
476 | return (*mrq)->error; | ||
477 | } | ||
478 | |||
479 | if ((*mrq)->data[offsetof(struct ms_status_register, status0)] | ||
480 | & MEMSTICK_STATUS0_WP) | ||
481 | msb->read_only = 1; | ||
482 | else | ||
483 | msb->read_only = 0; | ||
484 | |||
485 | complete(&card->mrq_complete); | ||
486 | return -EAGAIN; | ||
487 | } | ||
488 | |||
489 | static int h_mspro_block_wait_for_ced(struct memstick_dev *card, | ||
490 | struct memstick_request **mrq) | ||
491 | { | ||
492 | if ((*mrq)->error) { | ||
493 | complete(&card->mrq_complete); | ||
494 | return (*mrq)->error; | ||
495 | } | ||
496 | |||
497 | dev_dbg(&card->dev, "wait for ced: value %x\n", (*mrq)->data[0]); | ||
498 | |||
499 | if ((*mrq)->data[0] & (MEMSTICK_INT_CMDNAK | MEMSTICK_INT_ERR)) { | ||
500 | card->current_mrq.error = -EFAULT; | ||
501 | complete(&card->mrq_complete); | ||
502 | return card->current_mrq.error; | ||
503 | } | ||
504 | |||
505 | if (!((*mrq)->data[0] & MEMSTICK_INT_CED)) | ||
506 | return 0; | ||
507 | else { | ||
508 | card->current_mrq.error = 0; | ||
509 | complete(&card->mrq_complete); | ||
510 | return -EAGAIN; | ||
511 | } | ||
512 | } | ||
513 | |||
514 | static int h_mspro_block_transfer_data(struct memstick_dev *card, | ||
515 | struct memstick_request **mrq) | ||
516 | { | ||
517 | struct memstick_host *host = card->host; | ||
518 | struct mspro_block_data *msb = memstick_get_drvdata(card); | ||
519 | unsigned char t_val = 0; | ||
520 | struct scatterlist t_sg = { 0 }; | ||
521 | size_t t_offset; | ||
522 | |||
523 | if ((*mrq)->error) { | ||
524 | complete(&card->mrq_complete); | ||
525 | return (*mrq)->error; | ||
526 | } | ||
527 | |||
528 | switch ((*mrq)->tpc) { | ||
529 | case MS_TPC_WRITE_REG: | ||
530 | memstick_init_req(*mrq, MS_TPC_SET_CMD, &msb->transfer_cmd, 1); | ||
531 | (*mrq)->get_int_reg = 1; | ||
532 | return 0; | ||
533 | case MS_TPC_SET_CMD: | ||
534 | t_val = (*mrq)->int_reg; | ||
535 | memstick_init_req(*mrq, MS_TPC_GET_INT, NULL, 1); | ||
536 | if (host->caps & MEMSTICK_CAP_AUTO_GET_INT) | ||
537 | goto has_int_reg; | ||
538 | return 0; | ||
539 | case MS_TPC_GET_INT: | ||
540 | t_val = (*mrq)->data[0]; | ||
541 | has_int_reg: | ||
542 | if (t_val & (MEMSTICK_INT_CMDNAK | MEMSTICK_INT_ERR)) { | ||
543 | t_val = MSPRO_CMD_STOP; | ||
544 | memstick_init_req(*mrq, MS_TPC_SET_CMD, &t_val, 1); | ||
545 | card->next_request = h_mspro_block_default; | ||
546 | return 0; | ||
547 | } | ||
548 | |||
549 | if (msb->current_page | ||
550 | == (msb->req_sg[msb->current_seg].length | ||
551 | / msb->page_size)) { | ||
552 | msb->current_page = 0; | ||
553 | msb->current_seg++; | ||
554 | |||
555 | if (msb->current_seg == msb->seg_count) { | ||
556 | if (t_val & MEMSTICK_INT_CED) { | ||
557 | complete(&card->mrq_complete); | ||
558 | return -EAGAIN; | ||
559 | } else { | ||
560 | card->next_request | ||
561 | = h_mspro_block_wait_for_ced; | ||
562 | memstick_init_req(*mrq, MS_TPC_GET_INT, | ||
563 | NULL, 1); | ||
564 | return 0; | ||
565 | } | ||
566 | } | ||
567 | } | ||
568 | |||
569 | if (!(t_val & MEMSTICK_INT_BREQ)) { | ||
570 | memstick_init_req(*mrq, MS_TPC_GET_INT, NULL, 1); | ||
571 | return 0; | ||
572 | } | ||
573 | |||
574 | t_offset = msb->req_sg[msb->current_seg].offset; | ||
575 | t_offset += msb->current_page * msb->page_size; | ||
576 | |||
577 | sg_set_page(&t_sg, | ||
578 | nth_page(sg_page(&(msb->req_sg[msb->current_seg])), | ||
579 | t_offset >> PAGE_SHIFT), | ||
580 | msb->page_size, offset_in_page(t_offset)); | ||
581 | |||
582 | memstick_init_req_sg(*mrq, msb->data_dir == READ | ||
583 | ? MS_TPC_READ_LONG_DATA | ||
584 | : MS_TPC_WRITE_LONG_DATA, | ||
585 | &t_sg); | ||
586 | (*mrq)->get_int_reg = 1; | ||
587 | return 0; | ||
588 | case MS_TPC_READ_LONG_DATA: | ||
589 | case MS_TPC_WRITE_LONG_DATA: | ||
590 | msb->current_page++; | ||
591 | if (host->caps & MEMSTICK_CAP_AUTO_GET_INT) { | ||
592 | t_val = (*mrq)->int_reg; | ||
593 | goto has_int_reg; | ||
594 | } else { | ||
595 | memstick_init_req(*mrq, MS_TPC_GET_INT, NULL, 1); | ||
596 | return 0; | ||
597 | } | ||
598 | |||
599 | default: | ||
600 | BUG(); | ||
601 | } | ||
602 | } | ||
603 | |||
604 | /*** Data transfer ***/ | ||
605 | |||
606 | static void mspro_block_process_request(struct memstick_dev *card, | ||
607 | struct request *req) | ||
608 | { | ||
609 | struct mspro_block_data *msb = memstick_get_drvdata(card); | ||
610 | struct mspro_param_register param; | ||
611 | int rc, chunk, cnt; | ||
612 | unsigned short page_count; | ||
613 | sector_t t_sec; | ||
614 | unsigned long flags; | ||
615 | |||
616 | do { | ||
617 | page_count = 0; | ||
618 | msb->current_seg = 0; | ||
619 | msb->seg_count = blk_rq_map_sg(req->q, req, msb->req_sg); | ||
620 | |||
621 | if (msb->seg_count) { | ||
622 | msb->current_page = 0; | ||
623 | for (rc = 0; rc < msb->seg_count; rc++) | ||
624 | page_count += msb->req_sg[rc].length | ||
625 | / msb->page_size; | ||
626 | |||
627 | t_sec = req->sector; | ||
628 | sector_div(t_sec, msb->page_size >> 9); | ||
629 | param.system = msb->system; | ||
630 | param.data_count = cpu_to_be16(page_count); | ||
631 | param.data_address = cpu_to_be32((uint32_t)t_sec); | ||
632 | param.cmd_param = 0; | ||
633 | |||
634 | msb->data_dir = rq_data_dir(req); | ||
635 | msb->transfer_cmd = msb->data_dir == READ | ||
636 | ? MSPRO_CMD_READ_DATA | ||
637 | : MSPRO_CMD_WRITE_DATA; | ||
638 | |||
639 | dev_dbg(&card->dev, "data transfer: cmd %x, " | ||
640 | "lba %x, count %x\n", msb->transfer_cmd, | ||
641 | be32_to_cpu(param.data_address), | ||
642 | page_count); | ||
643 | |||
644 | card->next_request = h_mspro_block_req_init; | ||
645 | msb->mrq_handler = h_mspro_block_transfer_data; | ||
646 | memstick_init_req(&card->current_mrq, MS_TPC_WRITE_REG, | ||
647 | ¶m, sizeof(param)); | ||
648 | memstick_new_req(card->host); | ||
649 | wait_for_completion(&card->mrq_complete); | ||
650 | rc = card->current_mrq.error; | ||
651 | |||
652 | if (rc || (card->current_mrq.tpc == MSPRO_CMD_STOP)) { | ||
653 | for (cnt = 0; cnt < msb->current_seg; cnt++) | ||
654 | page_count += msb->req_sg[cnt].length | ||
655 | / msb->page_size; | ||
656 | |||
657 | if (msb->current_page) | ||
658 | page_count += msb->current_page - 1; | ||
659 | |||
660 | if (page_count && (msb->data_dir == READ)) | ||
661 | rc = msb->page_size * page_count; | ||
662 | else | ||
663 | rc = -EIO; | ||
664 | } else | ||
665 | rc = msb->page_size * page_count; | ||
666 | } else | ||
667 | rc = -EFAULT; | ||
668 | |||
669 | spin_lock_irqsave(&msb->q_lock, flags); | ||
670 | if (rc >= 0) | ||
671 | chunk = __blk_end_request(req, 0, rc); | ||
672 | else | ||
673 | chunk = __blk_end_request(req, rc, 0); | ||
674 | |||
675 | dev_dbg(&card->dev, "end chunk %d, %d\n", rc, chunk); | ||
676 | spin_unlock_irqrestore(&msb->q_lock, flags); | ||
677 | } while (chunk); | ||
678 | } | ||
679 | |||
680 | static int mspro_block_has_request(struct mspro_block_data *msb) | ||
681 | { | ||
682 | int rc = 0; | ||
683 | unsigned long flags; | ||
684 | |||
685 | spin_lock_irqsave(&msb->q_lock, flags); | ||
686 | if (kthread_should_stop() || msb->has_request) | ||
687 | rc = 1; | ||
688 | spin_unlock_irqrestore(&msb->q_lock, flags); | ||
689 | return rc; | ||
690 | } | ||
691 | |||
692 | static int mspro_block_queue_thread(void *data) | ||
693 | { | ||
694 | struct memstick_dev *card = data; | ||
695 | struct memstick_host *host = card->host; | ||
696 | struct mspro_block_data *msb = memstick_get_drvdata(card); | ||
697 | struct request *req; | ||
698 | unsigned long flags; | ||
699 | |||
700 | while (1) { | ||
701 | wait_event(msb->q_wait, mspro_block_has_request(msb)); | ||
702 | dev_dbg(&card->dev, "thread iter\n"); | ||
703 | |||
704 | spin_lock_irqsave(&msb->q_lock, flags); | ||
705 | req = elv_next_request(msb->queue); | ||
706 | dev_dbg(&card->dev, "next req %p\n", req); | ||
707 | if (!req) { | ||
708 | msb->has_request = 0; | ||
709 | if (kthread_should_stop()) { | ||
710 | spin_unlock_irqrestore(&msb->q_lock, flags); | ||
711 | break; | ||
712 | } | ||
713 | } else | ||
714 | msb->has_request = 1; | ||
715 | spin_unlock_irqrestore(&msb->q_lock, flags); | ||
716 | |||
717 | if (req) { | ||
718 | mutex_lock(&host->lock); | ||
719 | mspro_block_process_request(card, req); | ||
720 | mutex_unlock(&host->lock); | ||
721 | } | ||
722 | } | ||
723 | dev_dbg(&card->dev, "thread finished\n"); | ||
724 | return 0; | ||
725 | } | ||
726 | |||
727 | static void mspro_block_request(struct request_queue *q) | ||
728 | { | ||
729 | struct memstick_dev *card = q->queuedata; | ||
730 | struct mspro_block_data *msb = memstick_get_drvdata(card); | ||
731 | struct request *req = NULL; | ||
732 | |||
733 | if (msb->q_thread) { | ||
734 | msb->has_request = 1; | ||
735 | wake_up_all(&msb->q_wait); | ||
736 | } else { | ||
737 | while ((req = elv_next_request(q)) != NULL) | ||
738 | end_queued_request(req, -ENODEV); | ||
739 | } | ||
740 | } | ||
741 | |||
742 | /*** Initialization ***/ | ||
743 | |||
744 | static int mspro_block_wait_for_ced(struct memstick_dev *card) | ||
745 | { | ||
746 | struct mspro_block_data *msb = memstick_get_drvdata(card); | ||
747 | |||
748 | card->next_request = h_mspro_block_req_init; | ||
749 | msb->mrq_handler = h_mspro_block_wait_for_ced; | ||
750 | memstick_init_req(&card->current_mrq, MS_TPC_GET_INT, NULL, 1); | ||
751 | memstick_new_req(card->host); | ||
752 | wait_for_completion(&card->mrq_complete); | ||
753 | return card->current_mrq.error; | ||
754 | } | ||
755 | |||
756 | static int mspro_block_switch_to_parallel(struct memstick_dev *card) | ||
757 | { | ||
758 | struct memstick_host *host = card->host; | ||
759 | struct mspro_block_data *msb = memstick_get_drvdata(card); | ||
760 | struct mspro_param_register param = { | ||
761 | .system = 0, | ||
762 | .data_count = 0, | ||
763 | .data_address = 0, | ||
764 | .cmd_param = 0 | ||
765 | }; | ||
766 | |||
767 | card->next_request = h_mspro_block_req_init; | ||
768 | msb->mrq_handler = h_mspro_block_default; | ||
769 | memstick_init_req(&card->current_mrq, MS_TPC_WRITE_REG, ¶m, | ||
770 | sizeof(param)); | ||
771 | memstick_new_req(host); | ||
772 | wait_for_completion(&card->mrq_complete); | ||
773 | if (card->current_mrq.error) | ||
774 | return card->current_mrq.error; | ||
775 | |||
776 | msb->system = 0; | ||
777 | host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_PARALLEL); | ||
778 | |||
779 | card->next_request = h_mspro_block_req_init; | ||
780 | msb->mrq_handler = h_mspro_block_default; | ||
781 | memstick_init_req(&card->current_mrq, MS_TPC_GET_INT, NULL, 1); | ||
782 | memstick_new_req(card->host); | ||
783 | wait_for_completion(&card->mrq_complete); | ||
784 | |||
785 | if (card->current_mrq.error) { | ||
786 | msb->system = 0x80; | ||
787 | host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_SERIAL); | ||
788 | return -EFAULT; | ||
789 | } | ||
790 | |||
791 | return 0; | ||
792 | } | ||
793 | |||
794 | /* Memory allocated for attributes by this function should be freed by | ||
795 | * mspro_block_data_clear, no matter if the initialization process succeded | ||
796 | * or failed. | ||
797 | */ | ||
798 | static int mspro_block_read_attributes(struct memstick_dev *card) | ||
799 | { | ||
800 | struct mspro_block_data *msb = memstick_get_drvdata(card); | ||
801 | struct mspro_param_register param = { | ||
802 | .system = msb->system, | ||
803 | .data_count = cpu_to_be16(1), | ||
804 | .data_address = 0, | ||
805 | .cmd_param = 0 | ||
806 | }; | ||
807 | struct mspro_attribute *attr = NULL; | ||
808 | struct mspro_sys_attr *s_attr = NULL; | ||
809 | unsigned char *buffer = NULL; | ||
810 | int cnt, rc, attr_count; | ||
811 | unsigned int addr; | ||
812 | unsigned short page_count; | ||
813 | |||
814 | attr = kmalloc(msb->page_size, GFP_KERNEL); | ||
815 | if (!attr) | ||
816 | return -ENOMEM; | ||
817 | |||
818 | sg_init_one(&msb->req_sg[0], attr, msb->page_size); | ||
819 | msb->seg_count = 1; | ||
820 | msb->current_seg = 0; | ||
821 | msb->current_page = 0; | ||
822 | msb->data_dir = READ; | ||
823 | msb->transfer_cmd = MSPRO_CMD_READ_ATRB; | ||
824 | |||
825 | card->next_request = h_mspro_block_req_init; | ||
826 | msb->mrq_handler = h_mspro_block_transfer_data; | ||
827 | memstick_init_req(&card->current_mrq, MS_TPC_WRITE_REG, ¶m, | ||
828 | sizeof(param)); | ||
829 | memstick_new_req(card->host); | ||
830 | wait_for_completion(&card->mrq_complete); | ||
831 | if (card->current_mrq.error) { | ||
832 | rc = card->current_mrq.error; | ||
833 | goto out_free_attr; | ||
834 | } | ||
835 | |||
836 | if (be16_to_cpu(attr->signature) != MSPRO_BLOCK_SIGNATURE) { | ||
837 | printk(KERN_ERR "%s: unrecognized device signature %x\n", | ||
838 | card->dev.bus_id, be16_to_cpu(attr->signature)); | ||
839 | rc = -ENODEV; | ||
840 | goto out_free_attr; | ||
841 | } | ||
842 | |||
843 | if (attr->count > MSPRO_BLOCK_MAX_ATTRIBUTES) { | ||
844 | printk(KERN_WARNING "%s: way too many attribute entries\n", | ||
845 | card->dev.bus_id); | ||
846 | attr_count = MSPRO_BLOCK_MAX_ATTRIBUTES; | ||
847 | } else | ||
848 | attr_count = attr->count; | ||
849 | |||
850 | msb->attr_group.attrs = kzalloc((attr_count + 1) | ||
851 | * sizeof(struct attribute), | ||
852 | GFP_KERNEL); | ||
853 | if (!msb->attr_group.attrs) { | ||
854 | rc = -ENOMEM; | ||
855 | goto out_free_attr; | ||
856 | } | ||
857 | msb->attr_group.name = "media_attributes"; | ||
858 | |||
859 | buffer = kmalloc(msb->page_size, GFP_KERNEL); | ||
860 | if (!buffer) { | ||
861 | rc = -ENOMEM; | ||
862 | goto out_free_attr; | ||
863 | } | ||
864 | memcpy(buffer, (char *)attr, msb->page_size); | ||
865 | page_count = 1; | ||
866 | |||
867 | for (cnt = 0; cnt < attr_count; ++cnt) { | ||
868 | s_attr = kzalloc(sizeof(struct mspro_sys_attr), GFP_KERNEL); | ||
869 | if (!s_attr) { | ||
870 | rc = -ENOMEM; | ||
871 | goto out_free_buffer; | ||
872 | } | ||
873 | |||
874 | msb->attr_group.attrs[cnt] = &s_attr->dev_attr.attr; | ||
875 | addr = be32_to_cpu(attr->entries[cnt].address); | ||
876 | rc = be32_to_cpu(attr->entries[cnt].size); | ||
877 | dev_dbg(&card->dev, "adding attribute %d: id %x, address %x, " | ||
878 | "size %x\n", cnt, attr->entries[cnt].id, addr, rc); | ||
879 | s_attr->id = attr->entries[cnt].id; | ||
880 | if (mspro_block_attr_name(s_attr->id)) | ||
881 | snprintf(s_attr->name, sizeof(s_attr->name), "%s", | ||
882 | mspro_block_attr_name(attr->entries[cnt].id)); | ||
883 | else | ||
884 | snprintf(s_attr->name, sizeof(s_attr->name), | ||
885 | "attr_x%02x", attr->entries[cnt].id); | ||
886 | |||
887 | s_attr->dev_attr.attr.name = s_attr->name; | ||
888 | s_attr->dev_attr.attr.mode = S_IRUGO; | ||
889 | s_attr->dev_attr.attr.owner = THIS_MODULE; | ||
890 | s_attr->dev_attr.show = mspro_block_attr_show(s_attr->id); | ||
891 | |||
892 | if (!rc) | ||
893 | continue; | ||
894 | |||
895 | s_attr->size = rc; | ||
896 | s_attr->data = kmalloc(rc, GFP_KERNEL); | ||
897 | if (!s_attr->data) { | ||
898 | rc = -ENOMEM; | ||
899 | goto out_free_buffer; | ||
900 | } | ||
901 | |||
902 | if (((addr / msb->page_size) | ||
903 | == be32_to_cpu(param.data_address)) | ||
904 | && (((addr + rc - 1) / msb->page_size) | ||
905 | == be32_to_cpu(param.data_address))) { | ||
906 | memcpy(s_attr->data, buffer + addr % msb->page_size, | ||
907 | rc); | ||
908 | continue; | ||
909 | } | ||
910 | |||
911 | if (page_count <= (rc / msb->page_size)) { | ||
912 | kfree(buffer); | ||
913 | page_count = (rc / msb->page_size) + 1; | ||
914 | buffer = kmalloc(page_count * msb->page_size, | ||
915 | GFP_KERNEL); | ||
916 | if (!buffer) { | ||
917 | rc = -ENOMEM; | ||
918 | goto out_free_attr; | ||
919 | } | ||
920 | } | ||
921 | |||
922 | param.system = msb->system; | ||
923 | param.data_count = cpu_to_be16((rc / msb->page_size) + 1); | ||
924 | param.data_address = cpu_to_be32(addr / msb->page_size); | ||
925 | param.cmd_param = 0; | ||
926 | |||
927 | sg_init_one(&msb->req_sg[0], buffer, | ||
928 | be16_to_cpu(param.data_count) * msb->page_size); | ||
929 | msb->seg_count = 1; | ||
930 | msb->current_seg = 0; | ||
931 | msb->current_page = 0; | ||
932 | msb->data_dir = READ; | ||
933 | msb->transfer_cmd = MSPRO_CMD_READ_ATRB; | ||
934 | |||
935 | dev_dbg(&card->dev, "reading attribute pages %x, %x\n", | ||
936 | be32_to_cpu(param.data_address), | ||
937 | be16_to_cpu(param.data_count)); | ||
938 | |||
939 | card->next_request = h_mspro_block_req_init; | ||
940 | msb->mrq_handler = h_mspro_block_transfer_data; | ||
941 | memstick_init_req(&card->current_mrq, MS_TPC_WRITE_REG, | ||
942 | (char *)¶m, sizeof(param)); | ||
943 | memstick_new_req(card->host); | ||
944 | wait_for_completion(&card->mrq_complete); | ||
945 | if (card->current_mrq.error) { | ||
946 | rc = card->current_mrq.error; | ||
947 | goto out_free_buffer; | ||
948 | } | ||
949 | |||
950 | memcpy(s_attr->data, buffer + addr % msb->page_size, rc); | ||
951 | } | ||
952 | |||
953 | rc = 0; | ||
954 | out_free_buffer: | ||
955 | kfree(buffer); | ||
956 | out_free_attr: | ||
957 | kfree(attr); | ||
958 | return rc; | ||
959 | } | ||
960 | |||
961 | static int mspro_block_init_card(struct memstick_dev *card) | ||
962 | { | ||
963 | struct mspro_block_data *msb = memstick_get_drvdata(card); | ||
964 | struct memstick_host *host = card->host; | ||
965 | int rc = 0; | ||
966 | |||
967 | msb->system = 0x80; | ||
968 | card->reg_addr.r_offset = offsetof(struct mspro_register, status); | ||
969 | card->reg_addr.r_length = sizeof(struct ms_status_register); | ||
970 | card->reg_addr.w_offset = offsetof(struct mspro_register, param); | ||
971 | card->reg_addr.w_length = sizeof(struct mspro_param_register); | ||
972 | |||
973 | if (memstick_set_rw_addr(card)) | ||
974 | return -EIO; | ||
975 | |||
976 | if (host->caps & MEMSTICK_CAP_PARALLEL) { | ||
977 | if (mspro_block_switch_to_parallel(card)) | ||
978 | printk(KERN_WARNING "%s: could not switch to " | ||
979 | "parallel interface\n", card->dev.bus_id); | ||
980 | } | ||
981 | |||
982 | rc = mspro_block_wait_for_ced(card); | ||
983 | if (rc) | ||
984 | return rc; | ||
985 | dev_dbg(&card->dev, "card activated\n"); | ||
986 | |||
987 | card->next_request = h_mspro_block_req_init; | ||
988 | msb->mrq_handler = h_mspro_block_get_ro; | ||
989 | memstick_init_req(&card->current_mrq, MS_TPC_READ_REG, NULL, | ||
990 | sizeof(struct ms_status_register)); | ||
991 | memstick_new_req(card->host); | ||
992 | wait_for_completion(&card->mrq_complete); | ||
993 | if (card->current_mrq.error) | ||
994 | return card->current_mrq.error; | ||
995 | |||
996 | dev_dbg(&card->dev, "card r/w status %d\n", msb->read_only ? 0 : 1); | ||
997 | |||
998 | msb->page_size = 512; | ||
999 | rc = mspro_block_read_attributes(card); | ||
1000 | if (rc) | ||
1001 | return rc; | ||
1002 | |||
1003 | dev_dbg(&card->dev, "attributes loaded\n"); | ||
1004 | return 0; | ||
1005 | |||
1006 | } | ||
1007 | |||
1008 | static int mspro_block_init_disk(struct memstick_dev *card) | ||
1009 | { | ||
1010 | struct mspro_block_data *msb = memstick_get_drvdata(card); | ||
1011 | struct memstick_host *host = card->host; | ||
1012 | struct mspro_devinfo *dev_info = NULL; | ||
1013 | struct mspro_sys_info *sys_info = NULL; | ||
1014 | struct mspro_sys_attr *s_attr = NULL; | ||
1015 | int rc, disk_id; | ||
1016 | u64 limit = BLK_BOUNCE_HIGH; | ||
1017 | unsigned long capacity; | ||
1018 | |||
1019 | if (host->cdev.dev->dma_mask && *(host->cdev.dev->dma_mask)) | ||
1020 | limit = *(host->cdev.dev->dma_mask); | ||
1021 | |||
1022 | for (rc = 0; msb->attr_group.attrs[rc]; ++rc) { | ||
1023 | s_attr = mspro_from_sysfs_attr(msb->attr_group.attrs[rc]); | ||
1024 | |||
1025 | if (s_attr->id == MSPRO_BLOCK_ID_DEVINFO) | ||
1026 | dev_info = s_attr->data; | ||
1027 | else if (s_attr->id == MSPRO_BLOCK_ID_SYSINFO) | ||
1028 | sys_info = s_attr->data; | ||
1029 | } | ||
1030 | |||
1031 | if (!dev_info || !sys_info) | ||
1032 | return -ENODEV; | ||
1033 | |||
1034 | msb->cylinders = be16_to_cpu(dev_info->cylinders); | ||
1035 | msb->heads = be16_to_cpu(dev_info->heads); | ||
1036 | msb->sectors_per_track = be16_to_cpu(dev_info->sectors_per_track); | ||
1037 | |||
1038 | msb->page_size = be16_to_cpu(sys_info->unit_size); | ||
1039 | |||
1040 | if (!idr_pre_get(&mspro_block_disk_idr, GFP_KERNEL)) | ||
1041 | return -ENOMEM; | ||
1042 | |||
1043 | mutex_lock(&mspro_block_disk_lock); | ||
1044 | rc = idr_get_new(&mspro_block_disk_idr, card, &disk_id); | ||
1045 | mutex_unlock(&mspro_block_disk_lock); | ||
1046 | |||
1047 | if (rc) | ||
1048 | return rc; | ||
1049 | |||
1050 | if ((disk_id << MEMSTICK_PART_SHIFT) > 255) { | ||
1051 | rc = -ENOSPC; | ||
1052 | goto out_release_id; | ||
1053 | } | ||
1054 | |||
1055 | msb->disk = alloc_disk(1 << MEMSTICK_PART_SHIFT); | ||
1056 | if (!msb->disk) { | ||
1057 | rc = -ENOMEM; | ||
1058 | goto out_release_id; | ||
1059 | } | ||
1060 | |||
1061 | spin_lock_init(&msb->q_lock); | ||
1062 | init_waitqueue_head(&msb->q_wait); | ||
1063 | |||
1064 | msb->queue = blk_init_queue(mspro_block_request, &msb->q_lock); | ||
1065 | if (!msb->queue) { | ||
1066 | rc = -ENOMEM; | ||
1067 | goto out_put_disk; | ||
1068 | } | ||
1069 | |||
1070 | msb->queue->queuedata = card; | ||
1071 | |||
1072 | blk_queue_bounce_limit(msb->queue, limit); | ||
1073 | blk_queue_max_sectors(msb->queue, MSPRO_BLOCK_MAX_PAGES); | ||
1074 | blk_queue_max_phys_segments(msb->queue, MSPRO_BLOCK_MAX_SEGS); | ||
1075 | blk_queue_max_hw_segments(msb->queue, MSPRO_BLOCK_MAX_SEGS); | ||
1076 | blk_queue_max_segment_size(msb->queue, | ||
1077 | MSPRO_BLOCK_MAX_PAGES * msb->page_size); | ||
1078 | |||
1079 | msb->disk->major = major; | ||
1080 | msb->disk->first_minor = disk_id << MEMSTICK_PART_SHIFT; | ||
1081 | msb->disk->fops = &ms_block_bdops; | ||
1082 | msb->usage_count = 1; | ||
1083 | msb->disk->private_data = msb; | ||
1084 | msb->disk->queue = msb->queue; | ||
1085 | msb->disk->driverfs_dev = &card->dev; | ||
1086 | |||
1087 | sprintf(msb->disk->disk_name, "mspblk%d", disk_id); | ||
1088 | |||
1089 | blk_queue_hardsect_size(msb->queue, msb->page_size); | ||
1090 | |||
1091 | capacity = be16_to_cpu(sys_info->user_block_count); | ||
1092 | capacity *= be16_to_cpu(sys_info->block_size); | ||
1093 | capacity *= msb->page_size >> 9; | ||
1094 | set_capacity(msb->disk, capacity); | ||
1095 | dev_dbg(&card->dev, "capacity set %ld\n", capacity); | ||
1096 | msb->q_thread = kthread_run(mspro_block_queue_thread, card, | ||
1097 | DRIVER_NAME"d"); | ||
1098 | if (IS_ERR(msb->q_thread)) | ||
1099 | goto out_put_disk; | ||
1100 | |||
1101 | mutex_unlock(&host->lock); | ||
1102 | add_disk(msb->disk); | ||
1103 | mutex_lock(&host->lock); | ||
1104 | msb->active = 1; | ||
1105 | return 0; | ||
1106 | |||
1107 | out_put_disk: | ||
1108 | put_disk(msb->disk); | ||
1109 | out_release_id: | ||
1110 | mutex_lock(&mspro_block_disk_lock); | ||
1111 | idr_remove(&mspro_block_disk_idr, disk_id); | ||
1112 | mutex_unlock(&mspro_block_disk_lock); | ||
1113 | return rc; | ||
1114 | } | ||
1115 | |||
1116 | static void mspro_block_data_clear(struct mspro_block_data *msb) | ||
1117 | { | ||
1118 | int cnt; | ||
1119 | struct mspro_sys_attr *s_attr; | ||
1120 | |||
1121 | if (msb->attr_group.attrs) { | ||
1122 | for (cnt = 0; msb->attr_group.attrs[cnt]; ++cnt) { | ||
1123 | s_attr = mspro_from_sysfs_attr(msb->attr_group | ||
1124 | .attrs[cnt]); | ||
1125 | kfree(s_attr->data); | ||
1126 | kfree(s_attr); | ||
1127 | } | ||
1128 | kfree(msb->attr_group.attrs); | ||
1129 | } | ||
1130 | |||
1131 | msb->card = NULL; | ||
1132 | } | ||
1133 | |||
1134 | static int mspro_block_check_card(struct memstick_dev *card) | ||
1135 | { | ||
1136 | struct mspro_block_data *msb = memstick_get_drvdata(card); | ||
1137 | |||
1138 | return (msb->active == 1); | ||
1139 | } | ||
1140 | |||
1141 | static int mspro_block_probe(struct memstick_dev *card) | ||
1142 | { | ||
1143 | struct mspro_block_data *msb; | ||
1144 | int rc = 0; | ||
1145 | |||
1146 | msb = kzalloc(sizeof(struct mspro_block_data), GFP_KERNEL); | ||
1147 | if (!msb) | ||
1148 | return -ENOMEM; | ||
1149 | memstick_set_drvdata(card, msb); | ||
1150 | msb->card = card; | ||
1151 | |||
1152 | rc = mspro_block_init_card(card); | ||
1153 | |||
1154 | if (rc) | ||
1155 | goto out_free; | ||
1156 | |||
1157 | rc = sysfs_create_group(&card->dev.kobj, &msb->attr_group); | ||
1158 | if (rc) | ||
1159 | goto out_free; | ||
1160 | |||
1161 | rc = mspro_block_init_disk(card); | ||
1162 | if (!rc) { | ||
1163 | card->check = mspro_block_check_card; | ||
1164 | return 0; | ||
1165 | } | ||
1166 | |||
1167 | sysfs_remove_group(&card->dev.kobj, &msb->attr_group); | ||
1168 | out_free: | ||
1169 | memstick_set_drvdata(card, NULL); | ||
1170 | mspro_block_data_clear(msb); | ||
1171 | kfree(msb); | ||
1172 | return rc; | ||
1173 | } | ||
1174 | |||
1175 | static void mspro_block_remove(struct memstick_dev *card) | ||
1176 | { | ||
1177 | struct mspro_block_data *msb = memstick_get_drvdata(card); | ||
1178 | struct task_struct *q_thread = NULL; | ||
1179 | unsigned long flags; | ||
1180 | |||
1181 | del_gendisk(msb->disk); | ||
1182 | dev_dbg(&card->dev, "mspro block remove\n"); | ||
1183 | spin_lock_irqsave(&msb->q_lock, flags); | ||
1184 | q_thread = msb->q_thread; | ||
1185 | msb->q_thread = NULL; | ||
1186 | msb->active = 0; | ||
1187 | spin_unlock_irqrestore(&msb->q_lock, flags); | ||
1188 | |||
1189 | if (q_thread) { | ||
1190 | mutex_unlock(&card->host->lock); | ||
1191 | kthread_stop(q_thread); | ||
1192 | mutex_lock(&card->host->lock); | ||
1193 | } | ||
1194 | |||
1195 | dev_dbg(&card->dev, "queue thread stopped\n"); | ||
1196 | |||
1197 | blk_cleanup_queue(msb->queue); | ||
1198 | |||
1199 | sysfs_remove_group(&card->dev.kobj, &msb->attr_group); | ||
1200 | |||
1201 | mutex_lock(&mspro_block_disk_lock); | ||
1202 | mspro_block_data_clear(msb); | ||
1203 | mutex_unlock(&mspro_block_disk_lock); | ||
1204 | |||
1205 | mspro_block_disk_release(msb->disk); | ||
1206 | memstick_set_drvdata(card, NULL); | ||
1207 | } | ||
1208 | |||
1209 | #ifdef CONFIG_PM | ||
1210 | |||
1211 | static int mspro_block_suspend(struct memstick_dev *card, pm_message_t state) | ||
1212 | { | ||
1213 | struct mspro_block_data *msb = memstick_get_drvdata(card); | ||
1214 | struct task_struct *q_thread = NULL; | ||
1215 | unsigned long flags; | ||
1216 | |||
1217 | spin_lock_irqsave(&msb->q_lock, flags); | ||
1218 | q_thread = msb->q_thread; | ||
1219 | msb->q_thread = NULL; | ||
1220 | msb->active = 0; | ||
1221 | blk_stop_queue(msb->queue); | ||
1222 | spin_unlock_irqrestore(&msb->q_lock, flags); | ||
1223 | |||
1224 | if (q_thread) | ||
1225 | kthread_stop(q_thread); | ||
1226 | |||
1227 | return 0; | ||
1228 | } | ||
1229 | |||
1230 | static int mspro_block_resume(struct memstick_dev *card) | ||
1231 | { | ||
1232 | struct mspro_block_data *msb = memstick_get_drvdata(card); | ||
1233 | unsigned long flags; | ||
1234 | int rc = 0; | ||
1235 | |||
1236 | #ifdef CONFIG_MEMSTICK_UNSAFE_RESUME | ||
1237 | |||
1238 | struct mspro_block_data *new_msb; | ||
1239 | struct memstick_host *host = card->host; | ||
1240 | struct mspro_sys_attr *s_attr, *r_attr; | ||
1241 | unsigned char cnt; | ||
1242 | |||
1243 | mutex_lock(&host->lock); | ||
1244 | new_msb = kzalloc(sizeof(struct mspro_block_data), GFP_KERNEL); | ||
1245 | if (!new_msb) { | ||
1246 | rc = -ENOMEM; | ||
1247 | goto out_unlock; | ||
1248 | } | ||
1249 | |||
1250 | new_msb->card = card; | ||
1251 | memstick_set_drvdata(card, new_msb); | ||
1252 | if (mspro_block_init_card(card)) | ||
1253 | goto out_free; | ||
1254 | |||
1255 | for (cnt = 0; new_msb->attr_group.attrs[cnt] | ||
1256 | && msb->attr_group.attrs[cnt]; ++cnt) { | ||
1257 | s_attr = mspro_from_sysfs_attr(new_msb->attr_group.attrs[cnt]); | ||
1258 | r_attr = mspro_from_sysfs_attr(msb->attr_group.attrs[cnt]); | ||
1259 | |||
1260 | if (s_attr->id == MSPRO_BLOCK_ID_SYSINFO | ||
1261 | && r_attr->id == s_attr->id) { | ||
1262 | if (memcmp(s_attr->data, r_attr->data, s_attr->size)) | ||
1263 | break; | ||
1264 | |||
1265 | memstick_set_drvdata(card, msb); | ||
1266 | msb->q_thread = kthread_run(mspro_block_queue_thread, | ||
1267 | card, DRIVER_NAME"d"); | ||
1268 | if (IS_ERR(msb->q_thread)) | ||
1269 | msb->q_thread = NULL; | ||
1270 | else | ||
1271 | msb->active = 1; | ||
1272 | |||
1273 | break; | ||
1274 | } | ||
1275 | } | ||
1276 | |||
1277 | out_free: | ||
1278 | memstick_set_drvdata(card, msb); | ||
1279 | mspro_block_data_clear(new_msb); | ||
1280 | kfree(new_msb); | ||
1281 | out_unlock: | ||
1282 | mutex_unlock(&host->lock); | ||
1283 | |||
1284 | #endif /* CONFIG_MEMSTICK_UNSAFE_RESUME */ | ||
1285 | |||
1286 | spin_lock_irqsave(&msb->q_lock, flags); | ||
1287 | blk_start_queue(msb->queue); | ||
1288 | spin_unlock_irqrestore(&msb->q_lock, flags); | ||
1289 | return rc; | ||
1290 | } | ||
1291 | |||
1292 | #else | ||
1293 | |||
1294 | #define mspro_block_suspend NULL | ||
1295 | #define mspro_block_resume NULL | ||
1296 | |||
1297 | #endif /* CONFIG_PM */ | ||
1298 | |||
1299 | static struct memstick_device_id mspro_block_id_tbl[] = { | ||
1300 | {MEMSTICK_MATCH_ALL, MEMSTICK_TYPE_PRO, MEMSTICK_CATEGORY_STORAGE_DUO, | ||
1301 | MEMSTICK_CLASS_GENERIC_DUO}, | ||
1302 | {} | ||
1303 | }; | ||
1304 | |||
1305 | |||
1306 | static struct memstick_driver mspro_block_driver = { | ||
1307 | .driver = { | ||
1308 | .name = DRIVER_NAME, | ||
1309 | .owner = THIS_MODULE | ||
1310 | }, | ||
1311 | .id_table = mspro_block_id_tbl, | ||
1312 | .probe = mspro_block_probe, | ||
1313 | .remove = mspro_block_remove, | ||
1314 | .suspend = mspro_block_suspend, | ||
1315 | .resume = mspro_block_resume | ||
1316 | }; | ||
1317 | |||
1318 | static int __init mspro_block_init(void) | ||
1319 | { | ||
1320 | int rc = -ENOMEM; | ||
1321 | |||
1322 | rc = register_blkdev(major, DRIVER_NAME); | ||
1323 | if (rc < 0) { | ||
1324 | printk(KERN_ERR DRIVER_NAME ": failed to register " | ||
1325 | "major %d, error %d\n", major, rc); | ||
1326 | return rc; | ||
1327 | } | ||
1328 | if (!major) | ||
1329 | major = rc; | ||
1330 | |||
1331 | rc = memstick_register_driver(&mspro_block_driver); | ||
1332 | if (rc) | ||
1333 | unregister_blkdev(major, DRIVER_NAME); | ||
1334 | return rc; | ||
1335 | } | ||
1336 | |||
1337 | static void __exit mspro_block_exit(void) | ||
1338 | { | ||
1339 | memstick_unregister_driver(&mspro_block_driver); | ||
1340 | unregister_blkdev(major, DRIVER_NAME); | ||
1341 | idr_destroy(&mspro_block_disk_idr); | ||
1342 | } | ||
1343 | |||
1344 | module_init(mspro_block_init); | ||
1345 | module_exit(mspro_block_exit); | ||
1346 | |||
1347 | MODULE_LICENSE("GPL"); | ||
1348 | MODULE_AUTHOR("Alex Dubov"); | ||
1349 | MODULE_DESCRIPTION("Sony MemoryStickPro block device driver"); | ||
1350 | MODULE_DEVICE_TABLE(memstick, mspro_block_id_tbl); | ||
1351 | MODULE_VERSION(DRIVER_VERSION); | ||
diff --git a/drivers/memstick/host/Kconfig b/drivers/memstick/host/Kconfig new file mode 100644 index 000000000000..c002fcc3c879 --- /dev/null +++ b/drivers/memstick/host/Kconfig | |||
@@ -0,0 +1,22 @@ | |||
1 | # | ||
2 | # MemoryStick host controller drivers | ||
3 | # | ||
4 | |||
5 | comment "MemoryStick Host Controller Drivers" | ||
6 | |||
7 | config MEMSTICK_TIFM_MS | ||
8 | tristate "TI Flash Media MemoryStick Interface support (EXPERIMENTAL)" | ||
9 | depends on EXPERIMENTAL && PCI | ||
10 | select TIFM_CORE | ||
11 | help | ||
12 | Say Y here if you want to be able to access MemoryStick cards with | ||
13 | the Texas Instruments(R) Flash Media card reader, found in many | ||
14 | laptops. | ||
15 | This option 'selects' (turns on, enables) 'TIFM_CORE', but you | ||
16 | probably also need appropriate card reader host adapter, such as | ||
17 | 'Misc devices: TI Flash Media PCI74xx/PCI76xx host adapter support | ||
18 | (TIFM_7XX1)'. | ||
19 | |||
20 | To compile this driver as a module, choose M here: the | ||
21 | module will be called tifm_ms. | ||
22 | |||
diff --git a/drivers/memstick/host/Makefile b/drivers/memstick/host/Makefile new file mode 100644 index 000000000000..ee666380efa1 --- /dev/null +++ b/drivers/memstick/host/Makefile | |||
@@ -0,0 +1,10 @@ | |||
1 | # | ||
2 | # Makefile for MemoryStick host controller drivers | ||
3 | # | ||
4 | |||
5 | ifeq ($(CONFIG_MEMSTICK_DEBUG),y) | ||
6 | EXTRA_CFLAGS += -DDEBUG | ||
7 | endif | ||
8 | |||
9 | obj-$(CONFIG_MEMSTICK_TIFM_MS) += tifm_ms.o | ||
10 | |||
diff --git a/drivers/memstick/host/tifm_ms.c b/drivers/memstick/host/tifm_ms.c new file mode 100644 index 000000000000..f55b71a4337d --- /dev/null +++ b/drivers/memstick/host/tifm_ms.c | |||
@@ -0,0 +1,685 @@ | |||
1 | /* | ||
2 | * TI FlashMedia driver | ||
3 | * | ||
4 | * Copyright (C) 2007 Alex Dubov <oakad@yahoo.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * Special thanks to Carlos Corbacho for providing various MemoryStick cards | ||
11 | * that made this driver possible. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/tifm.h> | ||
16 | #include <linux/memstick.h> | ||
17 | #include <linux/highmem.h> | ||
18 | #include <linux/scatterlist.h> | ||
19 | #include <linux/log2.h> | ||
20 | #include <asm/io.h> | ||
21 | |||
22 | #define DRIVER_NAME "tifm_ms" | ||
23 | #define DRIVER_VERSION "0.1" | ||
24 | |||
25 | static int no_dma; | ||
26 | module_param(no_dma, bool, 0644); | ||
27 | |||
28 | #define TIFM_MS_TIMEOUT 0x00100 | ||
29 | #define TIFM_MS_BADCRC 0x00200 | ||
30 | #define TIFM_MS_EOTPC 0x01000 | ||
31 | #define TIFM_MS_INT 0x02000 | ||
32 | |||
33 | /* The meaning of the bit majority in this constant is unknown. */ | ||
34 | #define TIFM_MS_SERIAL 0x04010 | ||
35 | |||
36 | #define TIFM_MS_SYS_LATCH 0x00100 | ||
37 | #define TIFM_MS_SYS_NOT_RDY 0x00800 | ||
38 | #define TIFM_MS_SYS_DATA 0x10000 | ||
39 | |||
40 | /* Hardware flags */ | ||
41 | enum { | ||
42 | CMD_READY = 0x0001, | ||
43 | FIFO_READY = 0x0002, | ||
44 | CARD_READY = 0x0004, | ||
45 | DATA_CARRY = 0x0008 | ||
46 | }; | ||
47 | |||
48 | struct tifm_ms { | ||
49 | struct tifm_dev *dev; | ||
50 | unsigned short eject:1, | ||
51 | no_dma:1; | ||
52 | unsigned short cmd_flags; | ||
53 | unsigned int mode_mask; | ||
54 | unsigned int block_pos; | ||
55 | unsigned long timeout_jiffies; | ||
56 | |||
57 | struct timer_list timer; | ||
58 | struct memstick_request *req; | ||
59 | unsigned int io_word; | ||
60 | }; | ||
61 | |||
62 | static void tifm_ms_read_fifo(struct tifm_ms *host, unsigned int fifo_offset, | ||
63 | struct page *pg, unsigned int page_off, | ||
64 | unsigned int length) | ||
65 | { | ||
66 | struct tifm_dev *sock = host->dev; | ||
67 | unsigned int cnt = 0, off = 0; | ||
68 | unsigned char *buf = kmap_atomic(pg, KM_BIO_DST_IRQ) + page_off; | ||
69 | |||
70 | if (host->cmd_flags & DATA_CARRY) { | ||
71 | while ((fifo_offset & 3) && length) { | ||
72 | buf[off++] = host->io_word & 0xff; | ||
73 | host->io_word >>= 8; | ||
74 | length--; | ||
75 | fifo_offset++; | ||
76 | } | ||
77 | if (!(fifo_offset & 3)) | ||
78 | host->cmd_flags &= ~DATA_CARRY; | ||
79 | if (!length) | ||
80 | return; | ||
81 | } | ||
82 | |||
83 | do { | ||
84 | host->io_word = readl(sock->addr + SOCK_FIFO_ACCESS | ||
85 | + fifo_offset); | ||
86 | cnt = 4; | ||
87 | while (length && cnt) { | ||
88 | buf[off++] = (host->io_word >> 8) & 0xff; | ||
89 | cnt--; | ||
90 | length--; | ||
91 | } | ||
92 | fifo_offset += 4 - cnt; | ||
93 | } while (length); | ||
94 | |||
95 | if (cnt) | ||
96 | host->cmd_flags |= DATA_CARRY; | ||
97 | |||
98 | kunmap_atomic(buf - page_off, KM_BIO_DST_IRQ); | ||
99 | } | ||
100 | |||
101 | static void tifm_ms_write_fifo(struct tifm_ms *host, unsigned int fifo_offset, | ||
102 | struct page *pg, unsigned int page_off, | ||
103 | unsigned int length) | ||
104 | { | ||
105 | struct tifm_dev *sock = host->dev; | ||
106 | unsigned int cnt = 0, off = 0; | ||
107 | unsigned char *buf = kmap_atomic(pg, KM_BIO_SRC_IRQ) + page_off; | ||
108 | |||
109 | if (host->cmd_flags & DATA_CARRY) { | ||
110 | while (fifo_offset & 3) { | ||
111 | host->io_word |= buf[off++] << (8 * (fifo_offset & 3)); | ||
112 | length--; | ||
113 | fifo_offset++; | ||
114 | } | ||
115 | if (!(fifo_offset & 3)) { | ||
116 | writel(host->io_word, sock->addr + SOCK_FIFO_ACCESS | ||
117 | + fifo_offset - 4); | ||
118 | |||
119 | host->cmd_flags &= ~DATA_CARRY; | ||
120 | } | ||
121 | if (!length) | ||
122 | return; | ||
123 | } | ||
124 | |||
125 | do { | ||
126 | cnt = 4; | ||
127 | host->io_word = 0; | ||
128 | while (length && cnt) { | ||
129 | host->io_word |= buf[off++] << (4 - cnt); | ||
130 | cnt--; | ||
131 | length--; | ||
132 | } | ||
133 | fifo_offset += 4 - cnt; | ||
134 | if (!cnt) | ||
135 | writel(host->io_word, sock->addr + SOCK_FIFO_ACCESS | ||
136 | + fifo_offset - 4); | ||
137 | |||
138 | } while (length); | ||
139 | |||
140 | if (cnt) | ||
141 | host->cmd_flags |= DATA_CARRY; | ||
142 | |||
143 | kunmap_atomic(buf - page_off, KM_BIO_SRC_IRQ); | ||
144 | } | ||
145 | |||
146 | static void tifm_ms_move_block(struct tifm_ms *host, unsigned int length) | ||
147 | { | ||
148 | unsigned int t_size; | ||
149 | unsigned int off = host->req->sg.offset + host->block_pos; | ||
150 | unsigned int p_off, p_cnt; | ||
151 | struct page *pg; | ||
152 | unsigned long flags; | ||
153 | |||
154 | dev_dbg(&host->dev->dev, "moving block\n"); | ||
155 | local_irq_save(flags); | ||
156 | t_size = length; | ||
157 | while (t_size) { | ||
158 | pg = nth_page(sg_page(&host->req->sg), off >> PAGE_SHIFT); | ||
159 | p_off = offset_in_page(off); | ||
160 | p_cnt = PAGE_SIZE - p_off; | ||
161 | p_cnt = min(p_cnt, t_size); | ||
162 | |||
163 | if (host->req->data_dir == WRITE) | ||
164 | tifm_ms_write_fifo(host, length - t_size, | ||
165 | pg, p_off, p_cnt); | ||
166 | else | ||
167 | tifm_ms_read_fifo(host, length - t_size, | ||
168 | pg, p_off, p_cnt); | ||
169 | |||
170 | t_size -= p_cnt; | ||
171 | } | ||
172 | local_irq_restore(flags); | ||
173 | } | ||
174 | |||
175 | static int tifm_ms_transfer_data(struct tifm_ms *host, int skip) | ||
176 | { | ||
177 | struct tifm_dev *sock = host->dev; | ||
178 | unsigned int length = host->req->sg.length - host->block_pos; | ||
179 | |||
180 | if (!length) | ||
181 | return 1; | ||
182 | |||
183 | if (length > TIFM_FIFO_SIZE) | ||
184 | length = TIFM_FIFO_SIZE; | ||
185 | |||
186 | if (!skip) { | ||
187 | tifm_ms_move_block(host, length); | ||
188 | host->block_pos += length; | ||
189 | } | ||
190 | |||
191 | if ((host->req->data_dir == READ) | ||
192 | && (host->block_pos == host->req->sg.length)) | ||
193 | return 1; | ||
194 | |||
195 | writel(ilog2(length) - 2, sock->addr + SOCK_FIFO_PAGE_SIZE); | ||
196 | if (host->req->data_dir == WRITE) | ||
197 | writel((1 << 8) | TIFM_DMA_TX, sock->addr + SOCK_DMA_CONTROL); | ||
198 | else | ||
199 | writel((1 << 8), sock->addr + SOCK_DMA_CONTROL); | ||
200 | |||
201 | return 0; | ||
202 | } | ||
203 | |||
204 | static int tifm_ms_issue_cmd(struct tifm_ms *host) | ||
205 | { | ||
206 | struct tifm_dev *sock = host->dev; | ||
207 | unsigned char *data; | ||
208 | unsigned int data_len = 0, cmd = 0, cmd_mask = 0, cnt, tval = 0; | ||
209 | |||
210 | host->cmd_flags = 0; | ||
211 | |||
212 | if (host->req->io_type == MEMSTICK_IO_SG) { | ||
213 | if (!host->no_dma) { | ||
214 | if (1 != tifm_map_sg(sock, &host->req->sg, 1, | ||
215 | host->req->data_dir == READ | ||
216 | ? PCI_DMA_FROMDEVICE | ||
217 | : PCI_DMA_TODEVICE)) { | ||
218 | host->req->error = -ENOMEM; | ||
219 | return host->req->error; | ||
220 | } | ||
221 | data_len = sg_dma_len(&host->req->sg); | ||
222 | } else | ||
223 | data_len = host->req->sg.length; | ||
224 | |||
225 | writel(TIFM_FIFO_INT_SETALL, | ||
226 | sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR); | ||
227 | writel(TIFM_FIFO_ENABLE, | ||
228 | sock->addr + SOCK_FIFO_CONTROL); | ||
229 | writel(TIFM_FIFO_INTMASK, | ||
230 | sock->addr + SOCK_DMA_FIFO_INT_ENABLE_SET); | ||
231 | |||
232 | if (!host->no_dma) { | ||
233 | writel(ilog2(data_len) - 2, | ||
234 | sock->addr + SOCK_FIFO_PAGE_SIZE); | ||
235 | writel(sg_dma_address(&host->req->sg), | ||
236 | sock->addr + SOCK_DMA_ADDRESS); | ||
237 | if (host->req->data_dir == WRITE) | ||
238 | writel((1 << 8) | TIFM_DMA_TX | TIFM_DMA_EN, | ||
239 | sock->addr + SOCK_DMA_CONTROL); | ||
240 | else | ||
241 | writel((1 << 8) | TIFM_DMA_EN, | ||
242 | sock->addr + SOCK_DMA_CONTROL); | ||
243 | } else { | ||
244 | tifm_ms_transfer_data(host, | ||
245 | host->req->data_dir == READ); | ||
246 | } | ||
247 | |||
248 | cmd_mask = readl(sock->addr + SOCK_MS_SYSTEM); | ||
249 | cmd_mask |= TIFM_MS_SYS_DATA | TIFM_MS_SYS_NOT_RDY; | ||
250 | writel(cmd_mask, sock->addr + SOCK_MS_SYSTEM); | ||
251 | } else if (host->req->io_type == MEMSTICK_IO_VAL) { | ||
252 | data = host->req->data; | ||
253 | data_len = host->req->data_len; | ||
254 | |||
255 | cmd_mask = host->mode_mask | 0x2607; /* unknown constant */ | ||
256 | |||
257 | if (host->req->data_dir == WRITE) { | ||
258 | cmd_mask |= TIFM_MS_SYS_LATCH; | ||
259 | writel(cmd_mask, sock->addr + SOCK_MS_SYSTEM); | ||
260 | for (cnt = 0; (data_len - cnt) >= 4; cnt += 4) { | ||
261 | writel(TIFM_MS_SYS_LATCH | ||
262 | | readl(sock->addr + SOCK_MS_SYSTEM), | ||
263 | sock->addr + SOCK_MS_SYSTEM); | ||
264 | __raw_writel(*(unsigned int *)(data + cnt), | ||
265 | sock->addr + SOCK_MS_DATA); | ||
266 | dev_dbg(&sock->dev, "writing %x\n", | ||
267 | *(int *)(data + cnt)); | ||
268 | } | ||
269 | switch (data_len - cnt) { | ||
270 | case 3: | ||
271 | tval |= data[cnt + 2] << 16; | ||
272 | case 2: | ||
273 | tval |= data[cnt + 1] << 8; | ||
274 | case 1: | ||
275 | tval |= data[cnt]; | ||
276 | writel(TIFM_MS_SYS_LATCH | ||
277 | | readl(sock->addr + SOCK_MS_SYSTEM), | ||
278 | sock->addr + SOCK_MS_SYSTEM); | ||
279 | writel(tval, sock->addr + SOCK_MS_DATA); | ||
280 | dev_dbg(&sock->dev, "writing %x\n", tval); | ||
281 | } | ||
282 | |||
283 | writel(TIFM_MS_SYS_LATCH | ||
284 | | readl(sock->addr + SOCK_MS_SYSTEM), | ||
285 | sock + SOCK_MS_SYSTEM); | ||
286 | writel(0, sock->addr + SOCK_MS_DATA); | ||
287 | dev_dbg(&sock->dev, "writing %x\n", 0); | ||
288 | |||
289 | } else | ||
290 | writel(cmd_mask, sock->addr + SOCK_MS_SYSTEM); | ||
291 | |||
292 | cmd_mask = readl(sock->addr + SOCK_MS_SYSTEM); | ||
293 | cmd_mask &= ~TIFM_MS_SYS_DATA; | ||
294 | cmd_mask |= TIFM_MS_SYS_NOT_RDY; | ||
295 | dev_dbg(&sock->dev, "mask %x\n", cmd_mask); | ||
296 | writel(cmd_mask, sock->addr + SOCK_MS_SYSTEM); | ||
297 | } else | ||
298 | BUG(); | ||
299 | |||
300 | mod_timer(&host->timer, jiffies + host->timeout_jiffies); | ||
301 | writel(TIFM_CTRL_LED | readl(sock->addr + SOCK_CONTROL), | ||
302 | sock->addr + SOCK_CONTROL); | ||
303 | host->req->error = 0; | ||
304 | |||
305 | cmd = (host->req->tpc & 0xf) << 12; | ||
306 | cmd |= data_len; | ||
307 | writel(cmd, sock->addr + SOCK_MS_COMMAND); | ||
308 | |||
309 | dev_dbg(&sock->dev, "executing TPC %x, %x\n", cmd, cmd_mask); | ||
310 | return 0; | ||
311 | } | ||
312 | |||
313 | static void tifm_ms_complete_cmd(struct tifm_ms *host) | ||
314 | { | ||
315 | struct tifm_dev *sock = host->dev; | ||
316 | struct memstick_host *msh = tifm_get_drvdata(sock); | ||
317 | unsigned int tval = 0, data_len; | ||
318 | unsigned char *data; | ||
319 | int rc; | ||
320 | |||
321 | del_timer(&host->timer); | ||
322 | if (host->req->io_type == MEMSTICK_IO_SG) { | ||
323 | if (!host->no_dma) | ||
324 | tifm_unmap_sg(sock, &host->req->sg, 1, | ||
325 | host->req->data_dir == READ | ||
326 | ? PCI_DMA_FROMDEVICE | ||
327 | : PCI_DMA_TODEVICE); | ||
328 | } else if (host->req->io_type == MEMSTICK_IO_VAL) { | ||
329 | writel(~TIFM_MS_SYS_DATA & readl(sock->addr + SOCK_MS_SYSTEM), | ||
330 | sock->addr + SOCK_MS_SYSTEM); | ||
331 | |||
332 | data = host->req->data; | ||
333 | data_len = host->req->data_len; | ||
334 | |||
335 | if (host->req->data_dir == READ) { | ||
336 | for (rc = 0; (data_len - rc) >= 4; rc += 4) | ||
337 | *(int *)(data + rc) | ||
338 | = __raw_readl(sock->addr | ||
339 | + SOCK_MS_DATA); | ||
340 | |||
341 | if (data_len - rc) | ||
342 | tval = readl(sock->addr + SOCK_MS_DATA); | ||
343 | switch (data_len - rc) { | ||
344 | case 3: | ||
345 | data[rc + 2] = (tval >> 16) & 0xff; | ||
346 | case 2: | ||
347 | data[rc + 1] = (tval >> 8) & 0xff; | ||
348 | case 1: | ||
349 | data[rc] = tval & 0xff; | ||
350 | } | ||
351 | readl(sock->addr + SOCK_MS_DATA); | ||
352 | } | ||
353 | } | ||
354 | |||
355 | writel((~TIFM_CTRL_LED) & readl(sock->addr + SOCK_CONTROL), | ||
356 | sock->addr + SOCK_CONTROL); | ||
357 | |||
358 | do { | ||
359 | rc = memstick_next_req(msh, &host->req); | ||
360 | } while (!rc && tifm_ms_issue_cmd(host)); | ||
361 | } | ||
362 | |||
363 | static int tifm_ms_check_status(struct tifm_ms *host) | ||
364 | { | ||
365 | if (!host->req->error) { | ||
366 | if (!(host->cmd_flags & CMD_READY)) | ||
367 | return 1; | ||
368 | if ((host->req->io_type == MEMSTICK_IO_SG) | ||
369 | && !(host->cmd_flags & FIFO_READY)) | ||
370 | return 1; | ||
371 | if (host->req->need_card_int | ||
372 | && !(host->cmd_flags & CARD_READY)) | ||
373 | return 1; | ||
374 | } | ||
375 | return 0; | ||
376 | } | ||
377 | |||
378 | /* Called from interrupt handler */ | ||
379 | static void tifm_ms_data_event(struct tifm_dev *sock) | ||
380 | { | ||
381 | struct tifm_ms *host; | ||
382 | unsigned int fifo_status = 0; | ||
383 | int rc = 1; | ||
384 | |||
385 | spin_lock(&sock->lock); | ||
386 | host = memstick_priv((struct memstick_host *)tifm_get_drvdata(sock)); | ||
387 | fifo_status = readl(sock->addr + SOCK_DMA_FIFO_STATUS); | ||
388 | dev_dbg(&sock->dev, "data event: fifo_status %x, flags %x\n", | ||
389 | fifo_status, host->cmd_flags); | ||
390 | |||
391 | if (host->req) { | ||
392 | if (fifo_status & TIFM_FIFO_READY) { | ||
393 | if (!host->no_dma || tifm_ms_transfer_data(host, 0)) { | ||
394 | host->cmd_flags |= FIFO_READY; | ||
395 | rc = tifm_ms_check_status(host); | ||
396 | } | ||
397 | } | ||
398 | } | ||
399 | |||
400 | writel(fifo_status, sock->addr + SOCK_DMA_FIFO_STATUS); | ||
401 | if (!rc) | ||
402 | tifm_ms_complete_cmd(host); | ||
403 | |||
404 | spin_unlock(&sock->lock); | ||
405 | } | ||
406 | |||
407 | |||
408 | /* Called from interrupt handler */ | ||
409 | static void tifm_ms_card_event(struct tifm_dev *sock) | ||
410 | { | ||
411 | struct tifm_ms *host; | ||
412 | unsigned int host_status = 0; | ||
413 | int rc = 1; | ||
414 | |||
415 | spin_lock(&sock->lock); | ||
416 | host = memstick_priv((struct memstick_host *)tifm_get_drvdata(sock)); | ||
417 | host_status = readl(sock->addr + SOCK_MS_STATUS); | ||
418 | dev_dbg(&sock->dev, "host event: host_status %x, flags %x\n", | ||
419 | host_status, host->cmd_flags); | ||
420 | |||
421 | if (host->req) { | ||
422 | if (host_status & TIFM_MS_TIMEOUT) | ||
423 | host->req->error = -ETIME; | ||
424 | else if (host_status & TIFM_MS_BADCRC) | ||
425 | host->req->error = -EILSEQ; | ||
426 | |||
427 | if (host->req->error) { | ||
428 | writel(TIFM_FIFO_INT_SETALL, | ||
429 | sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR); | ||
430 | writel(TIFM_DMA_RESET, sock->addr + SOCK_DMA_CONTROL); | ||
431 | } | ||
432 | |||
433 | if (host_status & TIFM_MS_EOTPC) | ||
434 | host->cmd_flags |= CMD_READY; | ||
435 | if (host_status & TIFM_MS_INT) | ||
436 | host->cmd_flags |= CARD_READY; | ||
437 | |||
438 | rc = tifm_ms_check_status(host); | ||
439 | |||
440 | } | ||
441 | |||
442 | writel(TIFM_MS_SYS_NOT_RDY | readl(sock->addr + SOCK_MS_SYSTEM), | ||
443 | sock->addr + SOCK_MS_SYSTEM); | ||
444 | writel((~TIFM_MS_SYS_DATA) & readl(sock->addr + SOCK_MS_SYSTEM), | ||
445 | sock->addr + SOCK_MS_SYSTEM); | ||
446 | |||
447 | if (!rc) | ||
448 | tifm_ms_complete_cmd(host); | ||
449 | |||
450 | spin_unlock(&sock->lock); | ||
451 | return; | ||
452 | } | ||
453 | |||
454 | static void tifm_ms_request(struct memstick_host *msh) | ||
455 | { | ||
456 | struct tifm_ms *host = memstick_priv(msh); | ||
457 | struct tifm_dev *sock = host->dev; | ||
458 | unsigned long flags; | ||
459 | int rc; | ||
460 | |||
461 | spin_lock_irqsave(&sock->lock, flags); | ||
462 | if (host->req) { | ||
463 | printk(KERN_ERR "%s : unfinished request detected\n", | ||
464 | sock->dev.bus_id); | ||
465 | spin_unlock_irqrestore(&sock->lock, flags); | ||
466 | tifm_eject(host->dev); | ||
467 | return; | ||
468 | } | ||
469 | |||
470 | if (host->eject) { | ||
471 | do { | ||
472 | rc = memstick_next_req(msh, &host->req); | ||
473 | if (!rc) | ||
474 | host->req->error = -ETIME; | ||
475 | } while (!rc); | ||
476 | spin_unlock_irqrestore(&sock->lock, flags); | ||
477 | return; | ||
478 | } | ||
479 | |||
480 | do { | ||
481 | rc = memstick_next_req(msh, &host->req); | ||
482 | } while (!rc && tifm_ms_issue_cmd(host)); | ||
483 | |||
484 | spin_unlock_irqrestore(&sock->lock, flags); | ||
485 | return; | ||
486 | } | ||
487 | |||
488 | static void tifm_ms_set_param(struct memstick_host *msh, | ||
489 | enum memstick_param param, | ||
490 | int value) | ||
491 | { | ||
492 | struct tifm_ms *host = memstick_priv(msh); | ||
493 | struct tifm_dev *sock = host->dev; | ||
494 | unsigned long flags; | ||
495 | |||
496 | spin_lock_irqsave(&sock->lock, flags); | ||
497 | |||
498 | switch (param) { | ||
499 | case MEMSTICK_POWER: | ||
500 | /* this is set by card detection mechanism */ | ||
501 | break; | ||
502 | case MEMSTICK_INTERFACE: | ||
503 | if (value == MEMSTICK_SERIAL) { | ||
504 | host->mode_mask = TIFM_MS_SERIAL; | ||
505 | writel((~TIFM_CTRL_FAST_CLK) | ||
506 | & readl(sock->addr + SOCK_CONTROL), | ||
507 | sock->addr + SOCK_CONTROL); | ||
508 | } else if (value == MEMSTICK_PARALLEL) { | ||
509 | host->mode_mask = 0; | ||
510 | writel(TIFM_CTRL_FAST_CLK | ||
511 | | readl(sock->addr + SOCK_CONTROL), | ||
512 | sock->addr + SOCK_CONTROL); | ||
513 | } | ||
514 | break; | ||
515 | }; | ||
516 | |||
517 | spin_unlock_irqrestore(&sock->lock, flags); | ||
518 | } | ||
519 | |||
520 | static void tifm_ms_abort(unsigned long data) | ||
521 | { | ||
522 | struct tifm_ms *host = (struct tifm_ms *)data; | ||
523 | |||
524 | dev_dbg(&host->dev->dev, "status %x\n", | ||
525 | readl(host->dev->addr + SOCK_MS_STATUS)); | ||
526 | printk(KERN_ERR | ||
527 | "%s : card failed to respond for a long period of time " | ||
528 | "(%x, %x)\n", | ||
529 | host->dev->dev.bus_id, host->req ? host->req->tpc : 0, | ||
530 | host->cmd_flags); | ||
531 | |||
532 | tifm_eject(host->dev); | ||
533 | } | ||
534 | |||
535 | static int tifm_ms_initialize_host(struct tifm_ms *host) | ||
536 | { | ||
537 | struct tifm_dev *sock = host->dev; | ||
538 | struct memstick_host *msh = tifm_get_drvdata(sock); | ||
539 | |||
540 | host->mode_mask = TIFM_MS_SERIAL; | ||
541 | writel(0x8000, sock->addr + SOCK_MS_SYSTEM); | ||
542 | writel(0x0200 | TIFM_MS_SYS_NOT_RDY, sock->addr + SOCK_MS_SYSTEM); | ||
543 | writel(0xffffffff, sock->addr + SOCK_MS_STATUS); | ||
544 | if (tifm_has_ms_pif(sock)) | ||
545 | msh->caps |= MEMSTICK_CAP_PARALLEL; | ||
546 | |||
547 | return 0; | ||
548 | } | ||
549 | |||
550 | static int tifm_ms_probe(struct tifm_dev *sock) | ||
551 | { | ||
552 | struct memstick_host *msh; | ||
553 | struct tifm_ms *host; | ||
554 | int rc = -EIO; | ||
555 | |||
556 | if (!(TIFM_SOCK_STATE_OCCUPIED | ||
557 | & readl(sock->addr + SOCK_PRESENT_STATE))) { | ||
558 | printk(KERN_WARNING "%s : card gone, unexpectedly\n", | ||
559 | sock->dev.bus_id); | ||
560 | return rc; | ||
561 | } | ||
562 | |||
563 | msh = memstick_alloc_host(sizeof(struct tifm_ms), &sock->dev); | ||
564 | if (!msh) | ||
565 | return -ENOMEM; | ||
566 | |||
567 | host = memstick_priv(msh); | ||
568 | tifm_set_drvdata(sock, msh); | ||
569 | host->dev = sock; | ||
570 | host->timeout_jiffies = msecs_to_jiffies(1000); | ||
571 | host->no_dma = no_dma; | ||
572 | |||
573 | setup_timer(&host->timer, tifm_ms_abort, (unsigned long)host); | ||
574 | |||
575 | msh->request = tifm_ms_request; | ||
576 | msh->set_param = tifm_ms_set_param; | ||
577 | sock->card_event = tifm_ms_card_event; | ||
578 | sock->data_event = tifm_ms_data_event; | ||
579 | rc = tifm_ms_initialize_host(host); | ||
580 | |||
581 | if (!rc) | ||
582 | rc = memstick_add_host(msh); | ||
583 | if (!rc) | ||
584 | return 0; | ||
585 | |||
586 | memstick_free_host(msh); | ||
587 | return rc; | ||
588 | } | ||
589 | |||
590 | static void tifm_ms_remove(struct tifm_dev *sock) | ||
591 | { | ||
592 | struct memstick_host *msh = tifm_get_drvdata(sock); | ||
593 | struct tifm_ms *host = memstick_priv(msh); | ||
594 | int rc = 0; | ||
595 | unsigned long flags; | ||
596 | |||
597 | spin_lock_irqsave(&sock->lock, flags); | ||
598 | host->eject = 1; | ||
599 | if (host->req) { | ||
600 | del_timer(&host->timer); | ||
601 | writel(TIFM_FIFO_INT_SETALL, | ||
602 | sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR); | ||
603 | writel(TIFM_DMA_RESET, sock->addr + SOCK_DMA_CONTROL); | ||
604 | if ((host->req->io_type == MEMSTICK_IO_SG) && !host->no_dma) | ||
605 | tifm_unmap_sg(sock, &host->req->sg, 1, | ||
606 | host->req->data_dir == READ | ||
607 | ? PCI_DMA_TODEVICE | ||
608 | : PCI_DMA_FROMDEVICE); | ||
609 | host->req->error = -ETIME; | ||
610 | |||
611 | do { | ||
612 | rc = memstick_next_req(msh, &host->req); | ||
613 | if (!rc) | ||
614 | host->req->error = -ETIME; | ||
615 | } while (!rc); | ||
616 | } | ||
617 | spin_unlock_irqrestore(&sock->lock, flags); | ||
618 | |||
619 | memstick_remove_host(msh); | ||
620 | |||
621 | writel(0x0200 | TIFM_MS_SYS_NOT_RDY, sock->addr + SOCK_MS_SYSTEM); | ||
622 | writel(0xffffffff, sock->addr + SOCK_MS_STATUS); | ||
623 | |||
624 | memstick_free_host(msh); | ||
625 | } | ||
626 | |||
627 | #ifdef CONFIG_PM | ||
628 | |||
629 | static int tifm_ms_suspend(struct tifm_dev *sock, pm_message_t state) | ||
630 | { | ||
631 | return 0; | ||
632 | } | ||
633 | |||
634 | static int tifm_ms_resume(struct tifm_dev *sock) | ||
635 | { | ||
636 | struct memstick_host *msh = tifm_get_drvdata(sock); | ||
637 | struct tifm_ms *host = memstick_priv(msh); | ||
638 | |||
639 | tifm_ms_initialize_host(host); | ||
640 | memstick_detect_change(msh); | ||
641 | |||
642 | return 0; | ||
643 | } | ||
644 | |||
645 | #else | ||
646 | |||
647 | #define tifm_ms_suspend NULL | ||
648 | #define tifm_ms_resume NULL | ||
649 | |||
650 | #endif /* CONFIG_PM */ | ||
651 | |||
652 | static struct tifm_device_id tifm_ms_id_tbl[] = { | ||
653 | { TIFM_TYPE_MS }, { 0 } | ||
654 | }; | ||
655 | |||
656 | static struct tifm_driver tifm_ms_driver = { | ||
657 | .driver = { | ||
658 | .name = DRIVER_NAME, | ||
659 | .owner = THIS_MODULE | ||
660 | }, | ||
661 | .id_table = tifm_ms_id_tbl, | ||
662 | .probe = tifm_ms_probe, | ||
663 | .remove = tifm_ms_remove, | ||
664 | .suspend = tifm_ms_suspend, | ||
665 | .resume = tifm_ms_resume | ||
666 | }; | ||
667 | |||
668 | static int __init tifm_ms_init(void) | ||
669 | { | ||
670 | return tifm_register_driver(&tifm_ms_driver); | ||
671 | } | ||
672 | |||
673 | static void __exit tifm_ms_exit(void) | ||
674 | { | ||
675 | tifm_unregister_driver(&tifm_ms_driver); | ||
676 | } | ||
677 | |||
678 | MODULE_AUTHOR("Alex Dubov"); | ||
679 | MODULE_DESCRIPTION("TI FlashMedia MemoryStick driver"); | ||
680 | MODULE_LICENSE("GPL"); | ||
681 | MODULE_DEVICE_TABLE(tifm, tifm_ms_id_tbl); | ||
682 | MODULE_VERSION(DRIVER_VERSION); | ||
683 | |||
684 | module_init(tifm_ms_init); | ||
685 | module_exit(tifm_ms_exit); | ||
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index c143a86c2ea6..1abc95ca9dfa 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -114,6 +114,9 @@ config ACER_WMI | |||
114 | wireless radio and bluetooth control, and on some laptops, | 114 | wireless radio and bluetooth control, and on some laptops, |
115 | exposes the mail LED and LCD backlight. | 115 | exposes the mail LED and LCD backlight. |
116 | 116 | ||
117 | For more information about this driver see | ||
118 | <file:Documentation/laptops/acer-wmi.txt> | ||
119 | |||
117 | If you have an ACPI-WMI compatible Acer/ Wistron laptop, say Y or M | 120 | If you have an ACPI-WMI compatible Acer/ Wistron laptop, say Y or M |
118 | here. | 121 | here. |
119 | 122 | ||
@@ -152,8 +155,9 @@ config FUJITSU_LAPTOP | |||
152 | If you have a Fujitsu laptop, say Y or M here. | 155 | If you have a Fujitsu laptop, say Y or M here. |
153 | 156 | ||
154 | config TC1100_WMI | 157 | config TC1100_WMI |
155 | tristate "HP Compaq TC1100 Tablet WMI Extras" | 158 | tristate "HP Compaq TC1100 Tablet WMI Extras (EXPERIMENTAL)" |
156 | depends on X86 && !X86_64 | 159 | depends on X86 && !X86_64 |
160 | depends on EXPERIMENTAL | ||
157 | depends on ACPI | 161 | depends on ACPI |
158 | select ACPI_WMI | 162 | select ACPI_WMI |
159 | ---help--- | 163 | ---help--- |
@@ -192,7 +196,7 @@ config SONY_LAPTOP | |||
192 | screen brightness control, Fn keys and allows powering on/off some | 196 | screen brightness control, Fn keys and allows powering on/off some |
193 | devices. | 197 | devices. |
194 | 198 | ||
195 | Read <file:Documentation/sony-laptop.txt> for more information. | 199 | Read <file:Documentation/laptops/sony-laptop.txt> for more information. |
196 | 200 | ||
197 | config SONYPI_COMPAT | 201 | config SONYPI_COMPAT |
198 | bool "Sonypi compatibility" | 202 | bool "Sonypi compatibility" |
@@ -211,8 +215,9 @@ config THINKPAD_ACPI | |||
211 | This is a driver for the IBM and Lenovo ThinkPad laptops. It adds | 215 | This is a driver for the IBM and Lenovo ThinkPad laptops. It adds |
212 | support for Fn-Fx key combinations, Bluetooth control, video | 216 | support for Fn-Fx key combinations, Bluetooth control, video |
213 | output switching, ThinkLight control, UltraBay eject and more. | 217 | output switching, ThinkLight control, UltraBay eject and more. |
214 | For more information about this driver see | 218 | For more information about this driver see |
215 | <file:Documentation/thinkpad-acpi.txt> and <http://ibm-acpi.sf.net/> . | 219 | <file:Documentation/laptops/thinkpad-acpi.txt> and |
220 | <http://ibm-acpi.sf.net/> . | ||
216 | 221 | ||
217 | This driver was formerly known as ibm-acpi. | 222 | This driver was formerly known as ibm-acpi. |
218 | 223 | ||
diff --git a/drivers/misc/acer-wmi.c b/drivers/misc/acer-wmi.c index a4d677504250..d7aea93081f2 100644 --- a/drivers/misc/acer-wmi.c +++ b/drivers/misc/acer-wmi.c | |||
@@ -428,11 +428,9 @@ static acpi_status AMW0_set_u32(u32 value, u32 cap, struct wmi_interface *iface) | |||
428 | if (value > max_brightness) | 428 | if (value > max_brightness) |
429 | return AE_BAD_PARAMETER; | 429 | return AE_BAD_PARAMETER; |
430 | switch (quirks->brightness) { | 430 | switch (quirks->brightness) { |
431 | case 1: | ||
432 | return ec_write(0x83, value); | ||
433 | default: | 431 | default: |
434 | return AE_BAD_ADDRESS; | 432 | return ec_write(0x83, value); |
435 | break; | 433 | break; |
436 | } | 434 | } |
437 | default: | 435 | default: |
438 | return AE_BAD_ADDRESS; | 436 | return AE_BAD_ADDRESS; |
diff --git a/drivers/misc/tifm_7xx1.c b/drivers/misc/tifm_7xx1.c index 54380da343a5..63a089b29545 100644 --- a/drivers/misc/tifm_7xx1.c +++ b/drivers/misc/tifm_7xx1.c | |||
@@ -302,6 +302,21 @@ static int tifm_7xx1_resume(struct pci_dev *dev) | |||
302 | 302 | ||
303 | #endif /* CONFIG_PM */ | 303 | #endif /* CONFIG_PM */ |
304 | 304 | ||
305 | static int tifm_7xx1_dummy_has_ms_pif(struct tifm_adapter *fm, | ||
306 | struct tifm_dev *sock) | ||
307 | { | ||
308 | return 0; | ||
309 | } | ||
310 | |||
311 | static int tifm_7xx1_has_ms_pif(struct tifm_adapter *fm, struct tifm_dev *sock) | ||
312 | { | ||
313 | if (((fm->num_sockets == 4) && (sock->socket_id == 2)) | ||
314 | || ((fm->num_sockets == 2) && (sock->socket_id == 0))) | ||
315 | return 1; | ||
316 | |||
317 | return 0; | ||
318 | } | ||
319 | |||
305 | static int tifm_7xx1_probe(struct pci_dev *dev, | 320 | static int tifm_7xx1_probe(struct pci_dev *dev, |
306 | const struct pci_device_id *dev_id) | 321 | const struct pci_device_id *dev_id) |
307 | { | 322 | { |
@@ -336,6 +351,7 @@ static int tifm_7xx1_probe(struct pci_dev *dev, | |||
336 | 351 | ||
337 | INIT_WORK(&fm->media_switcher, tifm_7xx1_switch_media); | 352 | INIT_WORK(&fm->media_switcher, tifm_7xx1_switch_media); |
338 | fm->eject = tifm_7xx1_eject; | 353 | fm->eject = tifm_7xx1_eject; |
354 | fm->has_ms_pif = tifm_7xx1_has_ms_pif; | ||
339 | pci_set_drvdata(dev, fm); | 355 | pci_set_drvdata(dev, fm); |
340 | 356 | ||
341 | fm->addr = ioremap(pci_resource_start(dev, 0), | 357 | fm->addr = ioremap(pci_resource_start(dev, 0), |
@@ -377,6 +393,7 @@ static void tifm_7xx1_remove(struct pci_dev *dev) | |||
377 | int cnt; | 393 | int cnt; |
378 | 394 | ||
379 | fm->eject = tifm_7xx1_dummy_eject; | 395 | fm->eject = tifm_7xx1_dummy_eject; |
396 | fm->has_ms_pif = tifm_7xx1_dummy_has_ms_pif; | ||
380 | writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE); | 397 | writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE); |
381 | mmiowb(); | 398 | mmiowb(); |
382 | free_irq(dev->irq, fm); | 399 | free_irq(dev->irq, fm); |
diff --git a/drivers/misc/tifm_core.c b/drivers/misc/tifm_core.c index 97544052e768..82dc72a1484f 100644 --- a/drivers/misc/tifm_core.c +++ b/drivers/misc/tifm_core.c | |||
@@ -284,6 +284,13 @@ void tifm_eject(struct tifm_dev *sock) | |||
284 | } | 284 | } |
285 | EXPORT_SYMBOL(tifm_eject); | 285 | EXPORT_SYMBOL(tifm_eject); |
286 | 286 | ||
287 | int tifm_has_ms_pif(struct tifm_dev *sock) | ||
288 | { | ||
289 | struct tifm_adapter *fm = dev_get_drvdata(sock->dev.parent); | ||
290 | return fm->has_ms_pif(fm, sock); | ||
291 | } | ||
292 | EXPORT_SYMBOL(tifm_has_ms_pif); | ||
293 | |||
287 | int tifm_map_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents, | 294 | int tifm_map_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents, |
288 | int direction) | 295 | int direction) |
289 | { | 296 | { |
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 5fef6783c716..3b3cd0e74715 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig | |||
@@ -25,8 +25,8 @@ config MMC_PXA | |||
25 | If unsure, say N. | 25 | If unsure, say N. |
26 | 26 | ||
27 | config MMC_SDHCI | 27 | config MMC_SDHCI |
28 | tristate "Secure Digital Host Controller Interface support (EXPERIMENTAL)" | 28 | tristate "Secure Digital Host Controller Interface support" |
29 | depends on PCI && EXPERIMENTAL | 29 | depends on PCI |
30 | help | 30 | help |
31 | This select the generic Secure Digital Host Controller Interface. | 31 | This select the generic Secure Digital Host Controller Interface. |
32 | It is used by manufacturers such as Texas Instruments(R), Ricoh(R) | 32 | It is used by manufacturers such as Texas Instruments(R), Ricoh(R) |
@@ -118,8 +118,8 @@ config MMC_TIFM_SD | |||
118 | module will be called tifm_sd. | 118 | module will be called tifm_sd. |
119 | 119 | ||
120 | config MMC_SPI | 120 | config MMC_SPI |
121 | tristate "MMC/SD over SPI (EXPERIMENTAL)" | 121 | tristate "MMC/SD over SPI" |
122 | depends on MMC && SPI_MASTER && !HIGHMEM && EXPERIMENTAL | 122 | depends on MMC && SPI_MASTER && !HIGHMEM |
123 | select CRC7 | 123 | select CRC7 |
124 | select CRC_ITU_T | 124 | select CRC_ITU_T |
125 | help | 125 | help |
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c index b1edcefdd4f9..21acecc9fe3a 100644 --- a/drivers/mmc/host/at91_mci.c +++ b/drivers/mmc/host/at91_mci.c | |||
@@ -70,10 +70,11 @@ | |||
70 | 70 | ||
71 | #include <asm/io.h> | 71 | #include <asm/io.h> |
72 | #include <asm/irq.h> | 72 | #include <asm/irq.h> |
73 | #include <asm/gpio.h> | ||
74 | |||
73 | #include <asm/mach/mmc.h> | 75 | #include <asm/mach/mmc.h> |
74 | #include <asm/arch/board.h> | 76 | #include <asm/arch/board.h> |
75 | #include <asm/arch/cpu.h> | 77 | #include <asm/arch/cpu.h> |
76 | #include <asm/arch/gpio.h> | ||
77 | #include <asm/arch/at91_mci.h> | 78 | #include <asm/arch/at91_mci.h> |
78 | 79 | ||
79 | #define DRIVER_NAME "at91_mci" | 80 | #define DRIVER_NAME "at91_mci" |
@@ -659,11 +660,11 @@ static void at91_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
659 | if (host->board->vcc_pin) { | 660 | if (host->board->vcc_pin) { |
660 | switch (ios->power_mode) { | 661 | switch (ios->power_mode) { |
661 | case MMC_POWER_OFF: | 662 | case MMC_POWER_OFF: |
662 | at91_set_gpio_value(host->board->vcc_pin, 0); | 663 | gpio_set_value(host->board->vcc_pin, 0); |
663 | break; | 664 | break; |
664 | case MMC_POWER_UP: | 665 | case MMC_POWER_UP: |
665 | case MMC_POWER_ON: | 666 | case MMC_POWER_ON: |
666 | at91_set_gpio_value(host->board->vcc_pin, 1); | 667 | gpio_set_value(host->board->vcc_pin, 1); |
667 | break; | 668 | break; |
668 | } | 669 | } |
669 | } | 670 | } |
@@ -768,7 +769,7 @@ static irqreturn_t at91_mci_irq(int irq, void *devid) | |||
768 | static irqreturn_t at91_mmc_det_irq(int irq, void *_host) | 769 | static irqreturn_t at91_mmc_det_irq(int irq, void *_host) |
769 | { | 770 | { |
770 | struct at91mci_host *host = _host; | 771 | struct at91mci_host *host = _host; |
771 | int present = !at91_get_gpio_value(irq); | 772 | int present = !gpio_get_value(irq_to_gpio(irq)); |
772 | 773 | ||
773 | /* | 774 | /* |
774 | * we expect this irq on both insert and remove, | 775 | * we expect this irq on both insert and remove, |
@@ -793,7 +794,7 @@ static int at91_mci_get_ro(struct mmc_host *mmc) | |||
793 | struct at91mci_host *host = mmc_priv(mmc); | 794 | struct at91mci_host *host = mmc_priv(mmc); |
794 | 795 | ||
795 | if (host->board->wp_pin) { | 796 | if (host->board->wp_pin) { |
796 | read_only = at91_get_gpio_value(host->board->wp_pin); | 797 | read_only = gpio_get_value(host->board->wp_pin); |
797 | printk(KERN_WARNING "%s: card is %s\n", mmc_hostname(mmc), | 798 | printk(KERN_WARNING "%s: card is %s\n", mmc_hostname(mmc), |
798 | (read_only ? "read-only" : "read-write") ); | 799 | (read_only ? "read-only" : "read-write") ); |
799 | } | 800 | } |
@@ -820,8 +821,6 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
820 | struct resource *res; | 821 | struct resource *res; |
821 | int ret; | 822 | int ret; |
822 | 823 | ||
823 | pr_debug("Probe MCI devices\n"); | ||
824 | |||
825 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 824 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
826 | if (!res) | 825 | if (!res) |
827 | return -ENXIO; | 826 | return -ENXIO; |
@@ -831,9 +830,9 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
831 | 830 | ||
832 | mmc = mmc_alloc_host(sizeof(struct at91mci_host), &pdev->dev); | 831 | mmc = mmc_alloc_host(sizeof(struct at91mci_host), &pdev->dev); |
833 | if (!mmc) { | 832 | if (!mmc) { |
834 | pr_debug("Failed to allocate mmc host\n"); | 833 | ret = -ENOMEM; |
835 | release_mem_region(res->start, res->end - res->start + 1); | 834 | dev_dbg(&pdev->dev, "couldn't allocate mmc host\n"); |
836 | return -ENOMEM; | 835 | goto fail6; |
837 | } | 836 | } |
838 | 837 | ||
839 | mmc->ops = &at91_mci_ops; | 838 | mmc->ops = &at91_mci_ops; |
@@ -853,19 +852,44 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
853 | if (cpu_is_at91sam9260() || cpu_is_at91sam9263()) | 852 | if (cpu_is_at91sam9260() || cpu_is_at91sam9263()) |
854 | mmc->caps |= MMC_CAP_4_BIT_DATA; | 853 | mmc->caps |= MMC_CAP_4_BIT_DATA; |
855 | else | 854 | else |
856 | printk("AT91 MMC: 4 wire bus mode not supported" | 855 | dev_warn(&pdev->dev, "4 wire bus mode not supported" |
857 | " - using 1 wire\n"); | 856 | " - using 1 wire\n"); |
858 | } | 857 | } |
859 | 858 | ||
860 | /* | 859 | /* |
860 | * Reserve GPIOs ... board init code makes sure these pins are set | ||
861 | * up as GPIOs with the right direction (input, except for vcc) | ||
862 | */ | ||
863 | if (host->board->det_pin) { | ||
864 | ret = gpio_request(host->board->det_pin, "mmc_detect"); | ||
865 | if (ret < 0) { | ||
866 | dev_dbg(&pdev->dev, "couldn't claim card detect pin\n"); | ||
867 | goto fail5; | ||
868 | } | ||
869 | } | ||
870 | if (host->board->wp_pin) { | ||
871 | ret = gpio_request(host->board->wp_pin, "mmc_wp"); | ||
872 | if (ret < 0) { | ||
873 | dev_dbg(&pdev->dev, "couldn't claim wp sense pin\n"); | ||
874 | goto fail4; | ||
875 | } | ||
876 | } | ||
877 | if (host->board->vcc_pin) { | ||
878 | ret = gpio_request(host->board->vcc_pin, "mmc_vcc"); | ||
879 | if (ret < 0) { | ||
880 | dev_dbg(&pdev->dev, "couldn't claim vcc switch pin\n"); | ||
881 | goto fail3; | ||
882 | } | ||
883 | } | ||
884 | |||
885 | /* | ||
861 | * Get Clock | 886 | * Get Clock |
862 | */ | 887 | */ |
863 | host->mci_clk = clk_get(&pdev->dev, "mci_clk"); | 888 | host->mci_clk = clk_get(&pdev->dev, "mci_clk"); |
864 | if (IS_ERR(host->mci_clk)) { | 889 | if (IS_ERR(host->mci_clk)) { |
865 | printk(KERN_ERR "AT91 MMC: no clock defined.\n"); | 890 | ret = -ENODEV; |
866 | mmc_free_host(mmc); | 891 | dev_dbg(&pdev->dev, "no mci_clk?\n"); |
867 | release_mem_region(res->start, res->end - res->start + 1); | 892 | goto fail2; |
868 | return -ENODEV; | ||
869 | } | 893 | } |
870 | 894 | ||
871 | /* | 895 | /* |
@@ -873,10 +897,8 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
873 | */ | 897 | */ |
874 | host->baseaddr = ioremap(res->start, res->end - res->start + 1); | 898 | host->baseaddr = ioremap(res->start, res->end - res->start + 1); |
875 | if (!host->baseaddr) { | 899 | if (!host->baseaddr) { |
876 | clk_put(host->mci_clk); | 900 | ret = -ENOMEM; |
877 | mmc_free_host(mmc); | 901 | goto fail1; |
878 | release_mem_region(res->start, res->end - res->start + 1); | ||
879 | return -ENOMEM; | ||
880 | } | 902 | } |
881 | 903 | ||
882 | /* | 904 | /* |
@@ -890,15 +912,11 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
890 | * Allocate the MCI interrupt | 912 | * Allocate the MCI interrupt |
891 | */ | 913 | */ |
892 | host->irq = platform_get_irq(pdev, 0); | 914 | host->irq = platform_get_irq(pdev, 0); |
893 | ret = request_irq(host->irq, at91_mci_irq, IRQF_SHARED, DRIVER_NAME, host); | 915 | ret = request_irq(host->irq, at91_mci_irq, IRQF_SHARED, |
916 | mmc_hostname(mmc), host); | ||
894 | if (ret) { | 917 | if (ret) { |
895 | printk(KERN_ERR "AT91 MMC: Failed to request MCI interrupt\n"); | 918 | dev_dbg(&pdev->dev, "request MCI interrupt failed\n"); |
896 | clk_disable(host->mci_clk); | 919 | goto fail0; |
897 | clk_put(host->mci_clk); | ||
898 | mmc_free_host(mmc); | ||
899 | iounmap(host->baseaddr); | ||
900 | release_mem_region(res->start, res->end - res->start + 1); | ||
901 | return ret; | ||
902 | } | 920 | } |
903 | 921 | ||
904 | platform_set_drvdata(pdev, mmc); | 922 | platform_set_drvdata(pdev, mmc); |
@@ -907,8 +925,7 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
907 | * Add host to MMC layer | 925 | * Add host to MMC layer |
908 | */ | 926 | */ |
909 | if (host->board->det_pin) { | 927 | if (host->board->det_pin) { |
910 | host->present = !at91_get_gpio_value(host->board->det_pin); | 928 | host->present = !gpio_get_value(host->board->det_pin); |
911 | device_init_wakeup(&pdev->dev, 1); | ||
912 | } | 929 | } |
913 | else | 930 | else |
914 | host->present = -1; | 931 | host->present = -1; |
@@ -919,15 +936,38 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
919 | * monitor card insertion/removal if we can | 936 | * monitor card insertion/removal if we can |
920 | */ | 937 | */ |
921 | if (host->board->det_pin) { | 938 | if (host->board->det_pin) { |
922 | ret = request_irq(host->board->det_pin, at91_mmc_det_irq, | 939 | ret = request_irq(gpio_to_irq(host->board->det_pin), |
923 | 0, DRIVER_NAME, host); | 940 | at91_mmc_det_irq, 0, mmc_hostname(mmc), host); |
924 | if (ret) | 941 | if (ret) |
925 | printk(KERN_ERR "AT91 MMC: Couldn't allocate MMC detect irq\n"); | 942 | dev_warn(&pdev->dev, "request MMC detect irq failed\n"); |
943 | else | ||
944 | device_init_wakeup(&pdev->dev, 1); | ||
926 | } | 945 | } |
927 | 946 | ||
928 | pr_debug("Added MCI driver\n"); | 947 | pr_debug("Added MCI driver\n"); |
929 | 948 | ||
930 | return 0; | 949 | return 0; |
950 | |||
951 | fail0: | ||
952 | clk_disable(host->mci_clk); | ||
953 | iounmap(host->baseaddr); | ||
954 | fail1: | ||
955 | clk_put(host->mci_clk); | ||
956 | fail2: | ||
957 | if (host->board->vcc_pin) | ||
958 | gpio_free(host->board->vcc_pin); | ||
959 | fail3: | ||
960 | if (host->board->wp_pin) | ||
961 | gpio_free(host->board->wp_pin); | ||
962 | fail4: | ||
963 | if (host->board->det_pin) | ||
964 | gpio_free(host->board->det_pin); | ||
965 | fail5: | ||
966 | mmc_free_host(mmc); | ||
967 | fail6: | ||
968 | release_mem_region(res->start, res->end - res->start + 1); | ||
969 | dev_err(&pdev->dev, "probe failed, err %d\n", ret); | ||
970 | return ret; | ||
931 | } | 971 | } |
932 | 972 | ||
933 | /* | 973 | /* |
@@ -945,9 +985,10 @@ static int __exit at91_mci_remove(struct platform_device *pdev) | |||
945 | host = mmc_priv(mmc); | 985 | host = mmc_priv(mmc); |
946 | 986 | ||
947 | if (host->board->det_pin) { | 987 | if (host->board->det_pin) { |
988 | if (device_can_wakeup(&pdev->dev)) | ||
989 | free_irq(gpio_to_irq(host->board->det_pin), host); | ||
948 | device_init_wakeup(&pdev->dev, 0); | 990 | device_init_wakeup(&pdev->dev, 0); |
949 | free_irq(host->board->det_pin, host); | 991 | gpio_free(host->board->det_pin); |
950 | cancel_delayed_work(&host->mmc->detect); | ||
951 | } | 992 | } |
952 | 993 | ||
953 | at91_mci_disable(host); | 994 | at91_mci_disable(host); |
@@ -957,6 +998,11 @@ static int __exit at91_mci_remove(struct platform_device *pdev) | |||
957 | clk_disable(host->mci_clk); /* Disable the peripheral clock */ | 998 | clk_disable(host->mci_clk); /* Disable the peripheral clock */ |
958 | clk_put(host->mci_clk); | 999 | clk_put(host->mci_clk); |
959 | 1000 | ||
1001 | if (host->board->vcc_pin) | ||
1002 | gpio_free(host->board->vcc_pin); | ||
1003 | if (host->board->wp_pin) | ||
1004 | gpio_free(host->board->wp_pin); | ||
1005 | |||
960 | iounmap(host->baseaddr); | 1006 | iounmap(host->baseaddr); |
961 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1007 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
962 | release_mem_region(res->start, res->end - res->start + 1); | 1008 | release_mem_region(res->start, res->end - res->start + 1); |
diff --git a/drivers/mmc/host/ricoh_mmc.c b/drivers/mmc/host/ricoh_mmc.c index 1e8704533bc5..a16d7609e4ee 100644 --- a/drivers/mmc/host/ricoh_mmc.c +++ b/drivers/mmc/host/ricoh_mmc.c | |||
@@ -41,10 +41,91 @@ static const struct pci_device_id pci_ids[] __devinitdata = { | |||
41 | 41 | ||
42 | MODULE_DEVICE_TABLE(pci, pci_ids); | 42 | MODULE_DEVICE_TABLE(pci, pci_ids); |
43 | 43 | ||
44 | static int ricoh_mmc_disable(struct pci_dev *fw_dev) | ||
45 | { | ||
46 | u8 write_enable; | ||
47 | u8 write_target; | ||
48 | u8 disable; | ||
49 | |||
50 | if (fw_dev->device == PCI_DEVICE_ID_RICOH_RL5C476) { | ||
51 | /* via RL5C476 */ | ||
52 | |||
53 | pci_read_config_byte(fw_dev, 0xB7, &disable); | ||
54 | if (disable & 0x02) { | ||
55 | printk(KERN_INFO DRIVER_NAME | ||
56 | ": Controller already disabled. " \ | ||
57 | "Nothing to do.\n"); | ||
58 | return -ENODEV; | ||
59 | } | ||
60 | |||
61 | pci_read_config_byte(fw_dev, 0x8E, &write_enable); | ||
62 | pci_write_config_byte(fw_dev, 0x8E, 0xAA); | ||
63 | pci_read_config_byte(fw_dev, 0x8D, &write_target); | ||
64 | pci_write_config_byte(fw_dev, 0x8D, 0xB7); | ||
65 | pci_write_config_byte(fw_dev, 0xB7, disable | 0x02); | ||
66 | pci_write_config_byte(fw_dev, 0x8E, write_enable); | ||
67 | pci_write_config_byte(fw_dev, 0x8D, write_target); | ||
68 | } else { | ||
69 | /* via R5C832 */ | ||
70 | |||
71 | pci_read_config_byte(fw_dev, 0xCB, &disable); | ||
72 | if (disable & 0x02) { | ||
73 | printk(KERN_INFO DRIVER_NAME | ||
74 | ": Controller already disabled. " \ | ||
75 | "Nothing to do.\n"); | ||
76 | return -ENODEV; | ||
77 | } | ||
78 | |||
79 | pci_read_config_byte(fw_dev, 0xCA, &write_enable); | ||
80 | pci_write_config_byte(fw_dev, 0xCA, 0x57); | ||
81 | pci_write_config_byte(fw_dev, 0xCB, disable | 0x02); | ||
82 | pci_write_config_byte(fw_dev, 0xCA, write_enable); | ||
83 | } | ||
84 | |||
85 | printk(KERN_INFO DRIVER_NAME | ||
86 | ": Controller is now disabled.\n"); | ||
87 | |||
88 | return 0; | ||
89 | } | ||
90 | |||
91 | static int ricoh_mmc_enable(struct pci_dev *fw_dev) | ||
92 | { | ||
93 | u8 write_enable; | ||
94 | u8 write_target; | ||
95 | u8 disable; | ||
96 | |||
97 | if (fw_dev->device == PCI_DEVICE_ID_RICOH_RL5C476) { | ||
98 | /* via RL5C476 */ | ||
99 | |||
100 | pci_read_config_byte(fw_dev, 0x8E, &write_enable); | ||
101 | pci_write_config_byte(fw_dev, 0x8E, 0xAA); | ||
102 | pci_read_config_byte(fw_dev, 0x8D, &write_target); | ||
103 | pci_write_config_byte(fw_dev, 0x8D, 0xB7); | ||
104 | pci_read_config_byte(fw_dev, 0xB7, &disable); | ||
105 | pci_write_config_byte(fw_dev, 0xB7, disable & ~0x02); | ||
106 | pci_write_config_byte(fw_dev, 0x8E, write_enable); | ||
107 | pci_write_config_byte(fw_dev, 0x8D, write_target); | ||
108 | } else { | ||
109 | /* via R5C832 */ | ||
110 | |||
111 | pci_read_config_byte(fw_dev, 0xCA, &write_enable); | ||
112 | pci_read_config_byte(fw_dev, 0xCB, &disable); | ||
113 | pci_write_config_byte(fw_dev, 0xCA, 0x57); | ||
114 | pci_write_config_byte(fw_dev, 0xCB, disable & ~0x02); | ||
115 | pci_write_config_byte(fw_dev, 0xCA, write_enable); | ||
116 | } | ||
117 | |||
118 | printk(KERN_INFO DRIVER_NAME | ||
119 | ": Controller is now re-enabled.\n"); | ||
120 | |||
121 | return 0; | ||
122 | } | ||
123 | |||
44 | static int __devinit ricoh_mmc_probe(struct pci_dev *pdev, | 124 | static int __devinit ricoh_mmc_probe(struct pci_dev *pdev, |
45 | const struct pci_device_id *ent) | 125 | const struct pci_device_id *ent) |
46 | { | 126 | { |
47 | u8 rev; | 127 | u8 rev; |
128 | u8 ctrlfound = 0; | ||
48 | 129 | ||
49 | struct pci_dev *fw_dev = NULL; | 130 | struct pci_dev *fw_dev = NULL; |
50 | 131 | ||
@@ -58,34 +139,38 @@ static int __devinit ricoh_mmc_probe(struct pci_dev *pdev, | |||
58 | pci_name(pdev), (int)pdev->vendor, (int)pdev->device, | 139 | pci_name(pdev), (int)pdev->vendor, (int)pdev->device, |
59 | (int)rev); | 140 | (int)rev); |
60 | 141 | ||
61 | while ((fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) { | 142 | while ((fw_dev = |
143 | pci_get_device(PCI_VENDOR_ID_RICOH, | ||
144 | PCI_DEVICE_ID_RICOH_RL5C476, fw_dev))) { | ||
62 | if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && | 145 | if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && |
63 | pdev->bus == fw_dev->bus) { | 146 | pdev->bus == fw_dev->bus) { |
64 | u8 write_enable; | 147 | if (ricoh_mmc_disable(fw_dev) != 0) |
65 | u8 disable; | ||
66 | |||
67 | pci_read_config_byte(fw_dev, 0xCB, &disable); | ||
68 | if (disable & 0x02) { | ||
69 | printk(KERN_INFO DRIVER_NAME | ||
70 | ": Controller already disabled. Nothing to do.\n"); | ||
71 | return -ENODEV; | 148 | return -ENODEV; |
72 | } | ||
73 | |||
74 | pci_read_config_byte(fw_dev, 0xCA, &write_enable); | ||
75 | pci_write_config_byte(fw_dev, 0xCA, 0x57); | ||
76 | pci_write_config_byte(fw_dev, 0xCB, disable | 0x02); | ||
77 | pci_write_config_byte(fw_dev, 0xCA, write_enable); | ||
78 | 149 | ||
79 | pci_set_drvdata(pdev, fw_dev); | 150 | pci_set_drvdata(pdev, fw_dev); |
80 | 151 | ||
81 | printk(KERN_INFO DRIVER_NAME | 152 | ++ctrlfound; |
82 | ": Controller is now disabled.\n"); | ||
83 | |||
84 | break; | 153 | break; |
85 | } | 154 | } |
86 | } | 155 | } |
87 | 156 | ||
88 | if (pci_get_drvdata(pdev) == NULL) { | 157 | fw_dev = NULL; |
158 | |||
159 | while (!ctrlfound && | ||
160 | (fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, | ||
161 | PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) { | ||
162 | if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && | ||
163 | pdev->bus == fw_dev->bus) { | ||
164 | if (ricoh_mmc_disable(fw_dev) != 0) | ||
165 | return -ENODEV; | ||
166 | |||
167 | pci_set_drvdata(pdev, fw_dev); | ||
168 | |||
169 | ++ctrlfound; | ||
170 | } | ||
171 | } | ||
172 | |||
173 | if (!ctrlfound) { | ||
89 | printk(KERN_WARNING DRIVER_NAME | 174 | printk(KERN_WARNING DRIVER_NAME |
90 | ": Main firewire function not found. Cannot disable controller.\n"); | 175 | ": Main firewire function not found. Cannot disable controller.\n"); |
91 | return -ENODEV; | 176 | return -ENODEV; |
@@ -96,30 +181,51 @@ static int __devinit ricoh_mmc_probe(struct pci_dev *pdev, | |||
96 | 181 | ||
97 | static void __devexit ricoh_mmc_remove(struct pci_dev *pdev) | 182 | static void __devexit ricoh_mmc_remove(struct pci_dev *pdev) |
98 | { | 183 | { |
99 | u8 write_enable; | ||
100 | u8 disable; | ||
101 | struct pci_dev *fw_dev = NULL; | 184 | struct pci_dev *fw_dev = NULL; |
102 | 185 | ||
103 | fw_dev = pci_get_drvdata(pdev); | 186 | fw_dev = pci_get_drvdata(pdev); |
104 | BUG_ON(fw_dev == NULL); | 187 | BUG_ON(fw_dev == NULL); |
105 | 188 | ||
106 | pci_read_config_byte(fw_dev, 0xCA, &write_enable); | 189 | ricoh_mmc_enable(fw_dev); |
107 | pci_read_config_byte(fw_dev, 0xCB, &disable); | ||
108 | pci_write_config_byte(fw_dev, 0xCA, 0x57); | ||
109 | pci_write_config_byte(fw_dev, 0xCB, disable & ~0x02); | ||
110 | pci_write_config_byte(fw_dev, 0xCA, write_enable); | ||
111 | |||
112 | printk(KERN_INFO DRIVER_NAME | ||
113 | ": Controller is now re-enabled.\n"); | ||
114 | 190 | ||
115 | pci_set_drvdata(pdev, NULL); | 191 | pci_set_drvdata(pdev, NULL); |
116 | } | 192 | } |
117 | 193 | ||
194 | static int ricoh_mmc_suspend(struct pci_dev *pdev, pm_message_t state) | ||
195 | { | ||
196 | struct pci_dev *fw_dev = NULL; | ||
197 | |||
198 | fw_dev = pci_get_drvdata(pdev); | ||
199 | BUG_ON(fw_dev == NULL); | ||
200 | |||
201 | printk(KERN_INFO DRIVER_NAME ": Suspending.\n"); | ||
202 | |||
203 | ricoh_mmc_enable(fw_dev); | ||
204 | |||
205 | return 0; | ||
206 | } | ||
207 | |||
208 | static int ricoh_mmc_resume(struct pci_dev *pdev) | ||
209 | { | ||
210 | struct pci_dev *fw_dev = NULL; | ||
211 | |||
212 | fw_dev = pci_get_drvdata(pdev); | ||
213 | BUG_ON(fw_dev == NULL); | ||
214 | |||
215 | printk(KERN_INFO DRIVER_NAME ": Resuming.\n"); | ||
216 | |||
217 | ricoh_mmc_disable(fw_dev); | ||
218 | |||
219 | return 0; | ||
220 | } | ||
221 | |||
118 | static struct pci_driver ricoh_mmc_driver = { | 222 | static struct pci_driver ricoh_mmc_driver = { |
119 | .name = DRIVER_NAME, | 223 | .name = DRIVER_NAME, |
120 | .id_table = pci_ids, | 224 | .id_table = pci_ids, |
121 | .probe = ricoh_mmc_probe, | 225 | .probe = ricoh_mmc_probe, |
122 | .remove = __devexit_p(ricoh_mmc_remove), | 226 | .remove = __devexit_p(ricoh_mmc_remove), |
227 | .suspend = ricoh_mmc_suspend, | ||
228 | .resume = ricoh_mmc_resume, | ||
123 | }; | 229 | }; |
124 | 230 | ||
125 | /*****************************************************************************\ | 231 | /*****************************************************************************\ |
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 785bbdcf4a58..4b673aa2dc3c 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -30,6 +30,10 @@ | |||
30 | 30 | ||
31 | static unsigned int debug_quirks = 0; | 31 | static unsigned int debug_quirks = 0; |
32 | 32 | ||
33 | /* For multi controllers in one platform case */ | ||
34 | static u16 chip_index = 0; | ||
35 | static spinlock_t index_lock; | ||
36 | |||
33 | /* | 37 | /* |
34 | * Different quirks to handle when the hardware deviates from a strict | 38 | * Different quirks to handle when the hardware deviates from a strict |
35 | * interpretation of the SDHCI specification. | 39 | * interpretation of the SDHCI specification. |
@@ -1320,7 +1324,7 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot) | |||
1320 | 1324 | ||
1321 | DBG("slot %d at 0x%08lx, irq %d\n", slot, host->addr, host->irq); | 1325 | DBG("slot %d at 0x%08lx, irq %d\n", slot, host->addr, host->irq); |
1322 | 1326 | ||
1323 | snprintf(host->slot_descr, 20, "sdhci:slot%d", slot); | 1327 | snprintf(host->slot_descr, 20, "sdhc%d:slot%d", chip->index, slot); |
1324 | 1328 | ||
1325 | ret = pci_request_region(pdev, host->bar, host->slot_descr); | 1329 | ret = pci_request_region(pdev, host->bar, host->slot_descr); |
1326 | if (ret) | 1330 | if (ret) |
@@ -1585,6 +1589,11 @@ static int __devinit sdhci_probe(struct pci_dev *pdev, | |||
1585 | chip->num_slots = slots; | 1589 | chip->num_slots = slots; |
1586 | pci_set_drvdata(pdev, chip); | 1590 | pci_set_drvdata(pdev, chip); |
1587 | 1591 | ||
1592 | /* Add for multi controller case */ | ||
1593 | spin_lock(&index_lock); | ||
1594 | chip->index = chip_index++; | ||
1595 | spin_unlock(&index_lock); | ||
1596 | |||
1588 | for (i = 0;i < slots;i++) { | 1597 | for (i = 0;i < slots;i++) { |
1589 | ret = sdhci_probe_slot(pdev, i); | 1598 | ret = sdhci_probe_slot(pdev, i); |
1590 | if (ret) { | 1599 | if (ret) { |
@@ -1645,6 +1654,8 @@ static int __init sdhci_drv_init(void) | |||
1645 | ": Secure Digital Host Controller Interface driver\n"); | 1654 | ": Secure Digital Host Controller Interface driver\n"); |
1646 | printk(KERN_INFO DRIVER_NAME ": Copyright(c) Pierre Ossman\n"); | 1655 | printk(KERN_INFO DRIVER_NAME ": Copyright(c) Pierre Ossman\n"); |
1647 | 1656 | ||
1657 | spin_lock_init(&index_lock); | ||
1658 | |||
1648 | return pci_register_driver(&sdhci_driver); | 1659 | return pci_register_driver(&sdhci_driver); |
1649 | } | 1660 | } |
1650 | 1661 | ||
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index e4d77b038bfa..d5a38f1b755a 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h | |||
@@ -208,6 +208,7 @@ struct sdhci_chip { | |||
208 | 208 | ||
209 | unsigned long quirks; | 209 | unsigned long quirks; |
210 | 210 | ||
211 | int index; /* Index for chip0, chip1 ...*/ | ||
211 | int num_slots; /* Slots on controller */ | 212 | int num_slots; /* Slots on controller */ |
212 | struct sdhci_host *hosts[0]; /* Pointers to hosts */ | 213 | struct sdhci_host *hosts[0]; /* Pointers to hosts */ |
213 | }; | 214 | }; |
diff --git a/drivers/mtd/nand/cs553x_nand.c b/drivers/mtd/nand/cs553x_nand.c index 19e1594421a4..8dab69657b19 100644 --- a/drivers/mtd/nand/cs553x_nand.c +++ b/drivers/mtd/nand/cs553x_nand.c | |||
@@ -13,9 +13,12 @@ | |||
13 | * Overview: | 13 | * Overview: |
14 | * This is a device driver for the NAND flash controller found on | 14 | * This is a device driver for the NAND flash controller found on |
15 | * the AMD CS5535/CS5536 companion chipsets for the Geode processor. | 15 | * the AMD CS5535/CS5536 companion chipsets for the Geode processor. |
16 | * mtd-id for command line partitioning is cs553x_nand_cs[0-3] | ||
17 | * where 0-3 reflects the chip select for NAND. | ||
16 | * | 18 | * |
17 | */ | 19 | */ |
18 | 20 | ||
21 | #include <linux/kernel.h> | ||
19 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
20 | #include <linux/init.h> | 23 | #include <linux/init.h> |
21 | #include <linux/module.h> | 24 | #include <linux/module.h> |
@@ -244,6 +247,8 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr) | |||
244 | goto out_ior; | 247 | goto out_ior; |
245 | } | 248 | } |
246 | 249 | ||
250 | new_mtd->name = kasprintf(GFP_KERNEL, "cs553x_nand_cs%d", cs); | ||
251 | |||
247 | cs553x_mtd[cs] = new_mtd; | 252 | cs553x_mtd[cs] = new_mtd; |
248 | goto out; | 253 | goto out; |
249 | 254 | ||
@@ -272,12 +277,21 @@ static int is_geode(void) | |||
272 | return 0; | 277 | return 0; |
273 | } | 278 | } |
274 | 279 | ||
280 | |||
281 | #ifdef CONFIG_MTD_PARTITIONS | ||
282 | const char *part_probes[] = { "cmdlinepart", NULL }; | ||
283 | #endif | ||
284 | |||
285 | |||
275 | static int __init cs553x_init(void) | 286 | static int __init cs553x_init(void) |
276 | { | 287 | { |
277 | int err = -ENXIO; | 288 | int err = -ENXIO; |
278 | int i; | 289 | int i; |
279 | uint64_t val; | 290 | uint64_t val; |
280 | 291 | ||
292 | int mtd_parts_nb = 0; | ||
293 | struct mtd_partition *mtd_parts = NULL; | ||
294 | |||
281 | /* If the CPU isn't a Geode GX or LX, abort */ | 295 | /* If the CPU isn't a Geode GX or LX, abort */ |
282 | if (!is_geode()) | 296 | if (!is_geode()) |
283 | return -ENXIO; | 297 | return -ENXIO; |
@@ -290,7 +304,7 @@ static int __init cs553x_init(void) | |||
290 | 304 | ||
291 | /* If it doesn't have the NAND controller enabled, abort */ | 305 | /* If it doesn't have the NAND controller enabled, abort */ |
292 | rdmsrl(MSR_DIVIL_BALL_OPTS, val); | 306 | rdmsrl(MSR_DIVIL_BALL_OPTS, val); |
293 | if (val & 1) { | 307 | if (val & PIN_OPT_IDE) { |
294 | printk(KERN_INFO "CS553x NAND controller: Flash I/O not enabled in MSR_DIVIL_BALL_OPTS.\n"); | 308 | printk(KERN_INFO "CS553x NAND controller: Flash I/O not enabled in MSR_DIVIL_BALL_OPTS.\n"); |
295 | return -ENXIO; | 309 | return -ENXIO; |
296 | } | 310 | } |
@@ -306,9 +320,19 @@ static int __init cs553x_init(void) | |||
306 | do mtdconcat etc. if we want to. */ | 320 | do mtdconcat etc. if we want to. */ |
307 | for (i = 0; i < NR_CS553X_CONTROLLERS; i++) { | 321 | for (i = 0; i < NR_CS553X_CONTROLLERS; i++) { |
308 | if (cs553x_mtd[i]) { | 322 | if (cs553x_mtd[i]) { |
309 | add_mtd_device(cs553x_mtd[i]); | ||
310 | 323 | ||
311 | /* If any devices registered, return success. Else the last error. */ | 324 | /* If any devices registered, return success. Else the last error. */ |
325 | #ifdef CONFIG_MTD_PARTITIONS | ||
326 | mtd_parts_nb = parse_mtd_partitions(cs553x_mtd[i], part_probes, &mtd_parts, 0); | ||
327 | if (mtd_parts_nb > 0) { | ||
328 | printk(KERN_NOTICE "Using command line partition definition\n"); | ||
329 | add_mtd_partitions(cs553x_mtd[i], mtd_parts, mtd_parts_nb); | ||
330 | } else { | ||
331 | add_mtd_device(cs553x_mtd[i]); | ||
332 | } | ||
333 | #else | ||
334 | add_mtd_device(cs553x_mtd[i]); | ||
335 | #endif | ||
312 | err = 0; | 336 | err = 0; |
313 | } | 337 | } |
314 | } | 338 | } |
@@ -328,13 +352,14 @@ static void __exit cs553x_cleanup(void) | |||
328 | void __iomem *mmio_base; | 352 | void __iomem *mmio_base; |
329 | 353 | ||
330 | if (!mtd) | 354 | if (!mtd) |
331 | break; | 355 | continue; |
332 | 356 | ||
333 | this = cs553x_mtd[i]->priv; | 357 | this = cs553x_mtd[i]->priv; |
334 | mmio_base = this->IO_ADDR_R; | 358 | mmio_base = this->IO_ADDR_R; |
335 | 359 | ||
336 | /* Release resources, unregister device */ | 360 | /* Release resources, unregister device */ |
337 | nand_release(cs553x_mtd[i]); | 361 | nand_release(cs553x_mtd[i]); |
362 | kfree(cs553x_mtd[i]->name); | ||
338 | cs553x_mtd[i] = NULL; | 363 | cs553x_mtd[i] = NULL; |
339 | 364 | ||
340 | /* unmap physical address */ | 365 | /* unmap physical address */ |
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c index 5e2d763c6b5f..0f8aca8a4d43 100644 --- a/drivers/net/wan/x25_asy.c +++ b/drivers/net/wan/x25_asy.c | |||
@@ -554,7 +554,6 @@ static void x25_asy_receive_buf(struct tty_struct *tty, const unsigned char *cp, | |||
554 | static int x25_asy_open_tty(struct tty_struct *tty) | 554 | static int x25_asy_open_tty(struct tty_struct *tty) |
555 | { | 555 | { |
556 | struct x25_asy *sl = (struct x25_asy *) tty->disc_data; | 556 | struct x25_asy *sl = (struct x25_asy *) tty->disc_data; |
557 | struct tty_ldisc *ld; | ||
558 | int err; | 557 | int err; |
559 | 558 | ||
560 | /* First make sure we're not already connected. */ | 559 | /* First make sure we're not already connected. */ |
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index 519b4ff79f7f..8b22281b087f 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig | |||
@@ -38,6 +38,7 @@ config PCMCIA_DEBUG | |||
38 | config PCMCIA | 38 | config PCMCIA |
39 | tristate "16-bit PCMCIA support" | 39 | tristate "16-bit PCMCIA support" |
40 | select CRC32 | 40 | select CRC32 |
41 | select HAVE_IDE | ||
41 | default y | 42 | default y |
42 | ---help--- | 43 | ---help--- |
43 | This option enables support for 16-bit PCMCIA cards. Most older | 44 | This option enables support for 16-bit PCMCIA cards. Most older |
diff --git a/drivers/rtc/rtc-r9701.c b/drivers/rtc/rtc-r9701.c index a64626a82d0b..b35f9bfa2af4 100644 --- a/drivers/rtc/rtc-r9701.c +++ b/drivers/rtc/rtc-r9701.c | |||
@@ -71,7 +71,6 @@ static int read_regs(struct device *dev, unsigned char *regs, int no_regs) | |||
71 | 71 | ||
72 | static int r9701_get_datetime(struct device *dev, struct rtc_time *dt) | 72 | static int r9701_get_datetime(struct device *dev, struct rtc_time *dt) |
73 | { | 73 | { |
74 | unsigned long time; | ||
75 | int ret; | 74 | int ret; |
76 | unsigned char buf[] = { RSECCNT, RMINCNT, RHRCNT, | 75 | unsigned char buf[] = { RSECCNT, RMINCNT, RHRCNT, |
77 | RDAYCNT, RMONCNT, RYRCNT }; | 76 | RDAYCNT, RMONCNT, RYRCNT }; |
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c index 68071622d4bb..f47f4a768be5 100644 --- a/drivers/s390/char/sclp_vt220.c +++ b/drivers/s390/char/sclp_vt220.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * SCLP VT220 terminal driver. | 3 | * SCLP VT220 terminal driver. |
4 | * | 4 | * |
5 | * S390 version | 5 | * S390 version |
6 | * Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation | 6 | * Copyright IBM Corp. 2003,2008 |
7 | * Author(s): Peter Oberparleiter <Peter.Oberparleiter@de.ibm.com> | 7 | * Author(s): Peter Oberparleiter <Peter.Oberparleiter@de.ibm.com> |
8 | */ | 8 | */ |
9 | 9 | ||
@@ -632,6 +632,9 @@ static void __init __sclp_vt220_cleanup(void) | |||
632 | else | 632 | else |
633 | free_bootmem((unsigned long) page, PAGE_SIZE); | 633 | free_bootmem((unsigned long) page, PAGE_SIZE); |
634 | } | 634 | } |
635 | if (!list_empty(&sclp_vt220_register.list)) | ||
636 | sclp_unregister(&sclp_vt220_register); | ||
637 | sclp_vt220_initialized = 0; | ||
635 | } | 638 | } |
636 | 639 | ||
637 | static int __init __sclp_vt220_init(void) | 640 | static int __init __sclp_vt220_init(void) |
@@ -639,6 +642,7 @@ static int __init __sclp_vt220_init(void) | |||
639 | void *page; | 642 | void *page; |
640 | int i; | 643 | int i; |
641 | int num_pages; | 644 | int num_pages; |
645 | int rc; | ||
642 | 646 | ||
643 | if (sclp_vt220_initialized) | 647 | if (sclp_vt220_initialized) |
644 | return 0; | 648 | return 0; |
@@ -667,7 +671,14 @@ static int __init __sclp_vt220_init(void) | |||
667 | } | 671 | } |
668 | list_add_tail((struct list_head *) page, &sclp_vt220_empty); | 672 | list_add_tail((struct list_head *) page, &sclp_vt220_empty); |
669 | } | 673 | } |
670 | return 0; | 674 | rc = sclp_register(&sclp_vt220_register); |
675 | if (rc) { | ||
676 | printk(KERN_ERR SCLP_VT220_PRINT_HEADER | ||
677 | "could not register vt220 - " | ||
678 | "sclp_register returned %d\n", rc); | ||
679 | __sclp_vt220_cleanup(); | ||
680 | } | ||
681 | return rc; | ||
671 | } | 682 | } |
672 | 683 | ||
673 | static const struct tty_operations sclp_vt220_ops = { | 684 | static const struct tty_operations sclp_vt220_ops = { |
@@ -688,22 +699,17 @@ static int __init sclp_vt220_tty_init(void) | |||
688 | { | 699 | { |
689 | struct tty_driver *driver; | 700 | struct tty_driver *driver; |
690 | int rc; | 701 | int rc; |
702 | int cleanup; | ||
691 | 703 | ||
692 | /* Note: we're not testing for CONSOLE_IS_SCLP here to preserve | 704 | /* Note: we're not testing for CONSOLE_IS_SCLP here to preserve |
693 | * symmetry between VM and LPAR systems regarding ttyS1. */ | 705 | * symmetry between VM and LPAR systems regarding ttyS1. */ |
694 | driver = alloc_tty_driver(1); | 706 | driver = alloc_tty_driver(1); |
695 | if (!driver) | 707 | if (!driver) |
696 | return -ENOMEM; | 708 | return -ENOMEM; |
709 | cleanup = !sclp_vt220_initialized; | ||
697 | rc = __sclp_vt220_init(); | 710 | rc = __sclp_vt220_init(); |
698 | if (rc) | 711 | if (rc) |
699 | goto out_driver; | 712 | goto out_driver; |
700 | rc = sclp_register(&sclp_vt220_register); | ||
701 | if (rc) { | ||
702 | printk(KERN_ERR SCLP_VT220_PRINT_HEADER | ||
703 | "could not register tty - " | ||
704 | "sclp_register returned %d\n", rc); | ||
705 | goto out_init; | ||
706 | } | ||
707 | 713 | ||
708 | driver->owner = THIS_MODULE; | 714 | driver->owner = THIS_MODULE; |
709 | driver->driver_name = SCLP_VT220_DRIVER_NAME; | 715 | driver->driver_name = SCLP_VT220_DRIVER_NAME; |
@@ -721,15 +727,14 @@ static int __init sclp_vt220_tty_init(void) | |||
721 | printk(KERN_ERR SCLP_VT220_PRINT_HEADER | 727 | printk(KERN_ERR SCLP_VT220_PRINT_HEADER |
722 | "could not register tty - " | 728 | "could not register tty - " |
723 | "tty_register_driver returned %d\n", rc); | 729 | "tty_register_driver returned %d\n", rc); |
724 | goto out_sclp; | 730 | goto out_init; |
725 | } | 731 | } |
726 | sclp_vt220_driver = driver; | 732 | sclp_vt220_driver = driver; |
727 | return 0; | 733 | return 0; |
728 | 734 | ||
729 | out_sclp: | ||
730 | sclp_unregister(&sclp_vt220_register); | ||
731 | out_init: | 735 | out_init: |
732 | __sclp_vt220_cleanup(); | 736 | if (cleanup) |
737 | __sclp_vt220_cleanup(); | ||
733 | out_driver: | 738 | out_driver: |
734 | put_tty_driver(driver); | 739 | put_tty_driver(driver); |
735 | return rc; | 740 | return rc; |
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c index e2a781b6b21d..097fc0967e9d 100644 --- a/drivers/s390/cio/qdio.c +++ b/drivers/s390/cio/qdio.c | |||
@@ -3189,13 +3189,11 @@ qdio_establish(struct qdio_initialize *init_data) | |||
3189 | spin_lock_irqsave(get_ccwdev_lock(cdev),saveflags); | 3189 | spin_lock_irqsave(get_ccwdev_lock(cdev),saveflags); |
3190 | 3190 | ||
3191 | ccw_device_set_options_mask(cdev, 0); | 3191 | ccw_device_set_options_mask(cdev, 0); |
3192 | result=ccw_device_start_timeout(cdev,&irq_ptr->ccw, | 3192 | result = ccw_device_start(cdev, &irq_ptr->ccw, |
3193 | QDIO_DOING_ESTABLISH,0, 0, | 3193 | QDIO_DOING_ESTABLISH, 0, 0); |
3194 | QDIO_ESTABLISH_TIMEOUT); | ||
3195 | if (result) { | 3194 | if (result) { |
3196 | result2=ccw_device_start_timeout(cdev,&irq_ptr->ccw, | 3195 | result2 = ccw_device_start(cdev, &irq_ptr->ccw, |
3197 | QDIO_DOING_ESTABLISH,0,0, | 3196 | QDIO_DOING_ESTABLISH, 0, 0); |
3198 | QDIO_ESTABLISH_TIMEOUT); | ||
3199 | sprintf(dbf_text,"eq:io%4x",result); | 3197 | sprintf(dbf_text,"eq:io%4x",result); |
3200 | QDIO_DBF_TEXT2(1,setup,dbf_text); | 3198 | QDIO_DBF_TEXT2(1,setup,dbf_text); |
3201 | if (result2) { | 3199 | if (result2) { |
@@ -3219,10 +3217,10 @@ qdio_establish(struct qdio_initialize *init_data) | |||
3219 | return result; | 3217 | return result; |
3220 | } | 3218 | } |
3221 | 3219 | ||
3222 | /* Timeout is cared for already by using ccw_device_start_timeout(). */ | 3220 | wait_event_interruptible_timeout(cdev->private->wait_q, |
3223 | wait_event_interruptible(cdev->private->wait_q, | 3221 | irq_ptr->state == QDIO_IRQ_STATE_ESTABLISHED || |
3224 | irq_ptr->state == QDIO_IRQ_STATE_ESTABLISHED || | 3222 | irq_ptr->state == QDIO_IRQ_STATE_ERR, |
3225 | irq_ptr->state == QDIO_IRQ_STATE_ERR); | 3223 | QDIO_ESTABLISH_TIMEOUT); |
3226 | 3224 | ||
3227 | if (irq_ptr->state == QDIO_IRQ_STATE_ESTABLISHED) | 3225 | if (irq_ptr->state == QDIO_IRQ_STATE_ESTABLISHED) |
3228 | result = 0; | 3226 | result = 0; |
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index 67aaff3e668d..d0c6fd3b1c19 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c | |||
@@ -61,9 +61,9 @@ module_param_named(domain, ap_domain_index, int, 0000); | |||
61 | MODULE_PARM_DESC(domain, "domain index for ap devices"); | 61 | MODULE_PARM_DESC(domain, "domain index for ap devices"); |
62 | EXPORT_SYMBOL(ap_domain_index); | 62 | EXPORT_SYMBOL(ap_domain_index); |
63 | 63 | ||
64 | static int ap_thread_flag = 1; | 64 | static int ap_thread_flag = 0; |
65 | module_param_named(poll_thread, ap_thread_flag, int, 0000); | 65 | module_param_named(poll_thread, ap_thread_flag, int, 0000); |
66 | MODULE_PARM_DESC(poll_thread, "Turn on/off poll thread, default is 1 (on)."); | 66 | MODULE_PARM_DESC(poll_thread, "Turn on/off poll thread, default is 0 (off)."); |
67 | 67 | ||
68 | static struct device *ap_root_device = NULL; | 68 | static struct device *ap_root_device = NULL; |
69 | static DEFINE_SPINLOCK(ap_device_lock); | 69 | static DEFINE_SPINLOCK(ap_device_lock); |
diff --git a/drivers/scsi/aic7xxx/Makefile b/drivers/scsi/aic7xxx/Makefile index 4c549540a35d..741d81861d17 100644 --- a/drivers/scsi/aic7xxx/Makefile +++ b/drivers/scsi/aic7xxx/Makefile | |||
@@ -44,8 +44,8 @@ clean-files += aic79xx_seq.h aic79xx_reg.h aic79xx_reg_print.c | |||
44 | 44 | ||
45 | # Dependencies for generated files need to be listed explicitly | 45 | # Dependencies for generated files need to be listed explicitly |
46 | 46 | ||
47 | $(addprefix $(src)/,$(aic7xxx-y:.o=.c)): $(obj)/aic7xxx_seq.h $(obj)/aic7xxx_reg.h | 47 | $(addprefix $(obj)/,$(aic7xxx-y)): $(obj)/aic7xxx_seq.h $(obj)/aic7xxx_reg.h |
48 | $(addprefix $(src)/,$(aic79xx-y:.o=.c)): $(obj)/aic79xx_seq.h $(obj)/aic79xx_reg.h | 48 | $(addprefix $(obj)/,$(aic79xx-y)): $(obj)/aic79xx_seq.h $(obj)/aic79xx_reg.h |
49 | 49 | ||
50 | aic7xxx-gen-$(CONFIG_AIC7XXX_BUILD_FIRMWARE) := $(obj)/aic7xxx_reg.h | 50 | aic7xxx-gen-$(CONFIG_AIC7XXX_BUILD_FIRMWARE) := $(obj)/aic7xxx_reg.h |
51 | aic7xxx-gen-$(CONFIG_AIC7XXX_REG_PRETTY_PRINT) += $(obj)/aic7xxx_reg_print.c | 51 | aic7xxx-gen-$(CONFIG_AIC7XXX_REG_PRETTY_PRINT) += $(obj)/aic7xxx_reg_print.c |
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index f4e387452246..7dd9b50d5ebc 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -892,7 +892,16 @@ out: | |||
892 | return err; | 892 | return err; |
893 | } | 893 | } |
894 | 894 | ||
895 | #define DIO_CREDITS (EXT4_RESERVE_TRANS_BLOCKS + 32) | 895 | /* Maximum number of blocks we map for direct IO at once. */ |
896 | #define DIO_MAX_BLOCKS 4096 | ||
897 | /* | ||
898 | * Number of credits we need for writing DIO_MAX_BLOCKS: | ||
899 | * We need sb + group descriptor + bitmap + inode -> 4 | ||
900 | * For B blocks with A block pointers per block we need: | ||
901 | * 1 (triple ind.) + (B/A/A + 2) (doubly ind.) + (B/A + 2) (indirect). | ||
902 | * If we plug in 4096 for B and 256 for A (for 1KB block size), we get 25. | ||
903 | */ | ||
904 | #define DIO_CREDITS 25 | ||
896 | 905 | ||
897 | int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block, | 906 | int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block, |
898 | unsigned long max_blocks, struct buffer_head *bh, | 907 | unsigned long max_blocks, struct buffer_head *bh, |
@@ -939,49 +948,31 @@ static int ext4_get_block(struct inode *inode, sector_t iblock, | |||
939 | struct buffer_head *bh_result, int create) | 948 | struct buffer_head *bh_result, int create) |
940 | { | 949 | { |
941 | handle_t *handle = ext4_journal_current_handle(); | 950 | handle_t *handle = ext4_journal_current_handle(); |
942 | int ret = 0; | 951 | int ret = 0, started = 0; |
943 | unsigned max_blocks = bh_result->b_size >> inode->i_blkbits; | 952 | unsigned max_blocks = bh_result->b_size >> inode->i_blkbits; |
944 | 953 | ||
945 | if (!create) | 954 | if (create && !handle) { |
946 | goto get_block; /* A read */ | 955 | /* Direct IO write... */ |
947 | 956 | if (max_blocks > DIO_MAX_BLOCKS) | |
948 | if (max_blocks == 1) | 957 | max_blocks = DIO_MAX_BLOCKS; |
949 | goto get_block; /* A single block get */ | 958 | handle = ext4_journal_start(inode, DIO_CREDITS + |
950 | 959 | 2 * EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb)); | |
951 | if (handle->h_transaction->t_state == T_LOCKED) { | 960 | if (IS_ERR(handle)) { |
952 | /* | ||
953 | * Huge direct-io writes can hold off commits for long | ||
954 | * periods of time. Let this commit run. | ||
955 | */ | ||
956 | ext4_journal_stop(handle); | ||
957 | handle = ext4_journal_start(inode, DIO_CREDITS); | ||
958 | if (IS_ERR(handle)) | ||
959 | ret = PTR_ERR(handle); | 961 | ret = PTR_ERR(handle); |
960 | goto get_block; | 962 | goto out; |
961 | } | ||
962 | |||
963 | if (handle->h_buffer_credits <= EXT4_RESERVE_TRANS_BLOCKS) { | ||
964 | /* | ||
965 | * Getting low on buffer credits... | ||
966 | */ | ||
967 | ret = ext4_journal_extend(handle, DIO_CREDITS); | ||
968 | if (ret > 0) { | ||
969 | /* | ||
970 | * Couldn't extend the transaction. Start a new one. | ||
971 | */ | ||
972 | ret = ext4_journal_restart(handle, DIO_CREDITS); | ||
973 | } | 963 | } |
964 | started = 1; | ||
974 | } | 965 | } |
975 | 966 | ||
976 | get_block: | 967 | ret = ext4_get_blocks_wrap(handle, inode, iblock, |
977 | if (ret == 0) { | ||
978 | ret = ext4_get_blocks_wrap(handle, inode, iblock, | ||
979 | max_blocks, bh_result, create, 0); | 968 | max_blocks, bh_result, create, 0); |
980 | if (ret > 0) { | 969 | if (ret > 0) { |
981 | bh_result->b_size = (ret << inode->i_blkbits); | 970 | bh_result->b_size = (ret << inode->i_blkbits); |
982 | ret = 0; | 971 | ret = 0; |
983 | } | ||
984 | } | 972 | } |
973 | if (started) | ||
974 | ext4_journal_stop(handle); | ||
975 | out: | ||
985 | return ret; | 976 | return ret; |
986 | } | 977 | } |
987 | 978 | ||
@@ -1671,7 +1662,8 @@ static int ext4_releasepage(struct page *page, gfp_t wait) | |||
1671 | * if the machine crashes during the write. | 1662 | * if the machine crashes during the write. |
1672 | * | 1663 | * |
1673 | * If the O_DIRECT write is intantiating holes inside i_size and the machine | 1664 | * If the O_DIRECT write is intantiating holes inside i_size and the machine |
1674 | * crashes then stale disk data _may_ be exposed inside the file. | 1665 | * crashes then stale disk data _may_ be exposed inside the file. But current |
1666 | * VFS code falls back into buffered path in that case so we are safe. | ||
1675 | */ | 1667 | */ |
1676 | static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb, | 1668 | static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb, |
1677 | const struct iovec *iov, loff_t offset, | 1669 | const struct iovec *iov, loff_t offset, |
@@ -1680,7 +1672,7 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb, | |||
1680 | struct file *file = iocb->ki_filp; | 1672 | struct file *file = iocb->ki_filp; |
1681 | struct inode *inode = file->f_mapping->host; | 1673 | struct inode *inode = file->f_mapping->host; |
1682 | struct ext4_inode_info *ei = EXT4_I(inode); | 1674 | struct ext4_inode_info *ei = EXT4_I(inode); |
1683 | handle_t *handle = NULL; | 1675 | handle_t *handle; |
1684 | ssize_t ret; | 1676 | ssize_t ret; |
1685 | int orphan = 0; | 1677 | int orphan = 0; |
1686 | size_t count = iov_length(iov, nr_segs); | 1678 | size_t count = iov_length(iov, nr_segs); |
@@ -1688,17 +1680,21 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb, | |||
1688 | if (rw == WRITE) { | 1680 | if (rw == WRITE) { |
1689 | loff_t final_size = offset + count; | 1681 | loff_t final_size = offset + count; |
1690 | 1682 | ||
1691 | handle = ext4_journal_start(inode, DIO_CREDITS); | ||
1692 | if (IS_ERR(handle)) { | ||
1693 | ret = PTR_ERR(handle); | ||
1694 | goto out; | ||
1695 | } | ||
1696 | if (final_size > inode->i_size) { | 1683 | if (final_size > inode->i_size) { |
1684 | /* Credits for sb + inode write */ | ||
1685 | handle = ext4_journal_start(inode, 2); | ||
1686 | if (IS_ERR(handle)) { | ||
1687 | ret = PTR_ERR(handle); | ||
1688 | goto out; | ||
1689 | } | ||
1697 | ret = ext4_orphan_add(handle, inode); | 1690 | ret = ext4_orphan_add(handle, inode); |
1698 | if (ret) | 1691 | if (ret) { |
1699 | goto out_stop; | 1692 | ext4_journal_stop(handle); |
1693 | goto out; | ||
1694 | } | ||
1700 | orphan = 1; | 1695 | orphan = 1; |
1701 | ei->i_disksize = inode->i_size; | 1696 | ei->i_disksize = inode->i_size; |
1697 | ext4_journal_stop(handle); | ||
1702 | } | 1698 | } |
1703 | } | 1699 | } |
1704 | 1700 | ||
@@ -1706,18 +1702,21 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb, | |||
1706 | offset, nr_segs, | 1702 | offset, nr_segs, |
1707 | ext4_get_block, NULL); | 1703 | ext4_get_block, NULL); |
1708 | 1704 | ||
1709 | /* | 1705 | if (orphan) { |
1710 | * Reacquire the handle: ext4_get_block() can restart the transaction | ||
1711 | */ | ||
1712 | handle = ext4_journal_current_handle(); | ||
1713 | |||
1714 | out_stop: | ||
1715 | if (handle) { | ||
1716 | int err; | 1706 | int err; |
1717 | 1707 | ||
1718 | if (orphan && inode->i_nlink) | 1708 | /* Credits for sb + inode write */ |
1709 | handle = ext4_journal_start(inode, 2); | ||
1710 | if (IS_ERR(handle)) { | ||
1711 | /* This is really bad luck. We've written the data | ||
1712 | * but cannot extend i_size. Bail out and pretend | ||
1713 | * the write failed... */ | ||
1714 | ret = PTR_ERR(handle); | ||
1715 | goto out; | ||
1716 | } | ||
1717 | if (inode->i_nlink) | ||
1719 | ext4_orphan_del(handle, inode); | 1718 | ext4_orphan_del(handle, inode); |
1720 | if (orphan && ret > 0) { | 1719 | if (ret > 0) { |
1721 | loff_t end = offset + ret; | 1720 | loff_t end = offset + ret; |
1722 | if (end > inode->i_size) { | 1721 | if (end > inode->i_size) { |
1723 | ei->i_disksize = end; | 1722 | ei->i_disksize = end; |
@@ -2758,13 +2757,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) | |||
2758 | ei->i_data[block] = raw_inode->i_block[block]; | 2757 | ei->i_data[block] = raw_inode->i_block[block]; |
2759 | INIT_LIST_HEAD(&ei->i_orphan); | 2758 | INIT_LIST_HEAD(&ei->i_orphan); |
2760 | 2759 | ||
2761 | if (inode->i_ino >= EXT4_FIRST_INO(inode->i_sb) + 1 && | 2760 | if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) { |
2762 | EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) { | ||
2763 | /* | ||
2764 | * When mke2fs creates big inodes it does not zero out | ||
2765 | * the unused bytes above EXT4_GOOD_OLD_INODE_SIZE, | ||
2766 | * so ignore those first few inodes. | ||
2767 | */ | ||
2768 | ei->i_extra_isize = le16_to_cpu(raw_inode->i_extra_isize); | 2761 | ei->i_extra_isize = le16_to_cpu(raw_inode->i_extra_isize); |
2769 | if (EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize > | 2762 | if (EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize > |
2770 | EXT4_INODE_SIZE(inode->i_sb)) { | 2763 | EXT4_INODE_SIZE(inode->i_sb)) { |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 76e5fedc0a0b..dd0fcfcb35ce 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -420,6 +420,7 @@ | |||
420 | #define MB_DEFAULT_GROUP_PREALLOC 512 | 420 | #define MB_DEFAULT_GROUP_PREALLOC 512 |
421 | 421 | ||
422 | static struct kmem_cache *ext4_pspace_cachep; | 422 | static struct kmem_cache *ext4_pspace_cachep; |
423 | static struct kmem_cache *ext4_ac_cachep; | ||
423 | 424 | ||
424 | #ifdef EXT4_BB_MAX_BLOCKS | 425 | #ifdef EXT4_BB_MAX_BLOCKS |
425 | #undef EXT4_BB_MAX_BLOCKS | 426 | #undef EXT4_BB_MAX_BLOCKS |
@@ -680,7 +681,6 @@ static void *mb_find_buddy(struct ext4_buddy *e4b, int order, int *max) | |||
680 | { | 681 | { |
681 | char *bb; | 682 | char *bb; |
682 | 683 | ||
683 | /* FIXME!! is this needed */ | ||
684 | BUG_ON(EXT4_MB_BITMAP(e4b) == EXT4_MB_BUDDY(e4b)); | 684 | BUG_ON(EXT4_MB_BITMAP(e4b) == EXT4_MB_BUDDY(e4b)); |
685 | BUG_ON(max == NULL); | 685 | BUG_ON(max == NULL); |
686 | 686 | ||
@@ -964,7 +964,7 @@ static void ext4_mb_generate_buddy(struct super_block *sb, | |||
964 | grp->bb_fragments = fragments; | 964 | grp->bb_fragments = fragments; |
965 | 965 | ||
966 | if (free != grp->bb_free) { | 966 | if (free != grp->bb_free) { |
967 | printk(KERN_DEBUG | 967 | ext4_error(sb, __FUNCTION__, |
968 | "EXT4-fs: group %lu: %u blocks in bitmap, %u in gd\n", | 968 | "EXT4-fs: group %lu: %u blocks in bitmap, %u in gd\n", |
969 | group, free, grp->bb_free); | 969 | group, free, grp->bb_free); |
970 | grp->bb_free = free; | 970 | grp->bb_free = free; |
@@ -1821,13 +1821,24 @@ static void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac, | |||
1821 | i = ext4_find_next_zero_bit(bitmap, | 1821 | i = ext4_find_next_zero_bit(bitmap, |
1822 | EXT4_BLOCKS_PER_GROUP(sb), i); | 1822 | EXT4_BLOCKS_PER_GROUP(sb), i); |
1823 | if (i >= EXT4_BLOCKS_PER_GROUP(sb)) { | 1823 | if (i >= EXT4_BLOCKS_PER_GROUP(sb)) { |
1824 | BUG_ON(free != 0); | 1824 | /* |
1825 | * IF we corrupt the bitmap we won't find any | ||
1826 | * free blocks even though group info says we | ||
1827 | * we have free blocks | ||
1828 | */ | ||
1829 | ext4_error(sb, __FUNCTION__, "%d free blocks as per " | ||
1830 | "group info. But bitmap says 0\n", | ||
1831 | free); | ||
1825 | break; | 1832 | break; |
1826 | } | 1833 | } |
1827 | 1834 | ||
1828 | mb_find_extent(e4b, 0, i, ac->ac_g_ex.fe_len, &ex); | 1835 | mb_find_extent(e4b, 0, i, ac->ac_g_ex.fe_len, &ex); |
1829 | BUG_ON(ex.fe_len <= 0); | 1836 | BUG_ON(ex.fe_len <= 0); |
1830 | BUG_ON(free < ex.fe_len); | 1837 | if (free < ex.fe_len) { |
1838 | ext4_error(sb, __FUNCTION__, "%d free blocks as per " | ||
1839 | "group info. But got %d blocks\n", | ||
1840 | free, ex.fe_len); | ||
1841 | } | ||
1831 | 1842 | ||
1832 | ext4_mb_measure_extent(ac, &ex, e4b); | 1843 | ext4_mb_measure_extent(ac, &ex, e4b); |
1833 | 1844 | ||
@@ -2959,12 +2970,19 @@ int __init init_ext4_mballoc(void) | |||
2959 | if (ext4_pspace_cachep == NULL) | 2970 | if (ext4_pspace_cachep == NULL) |
2960 | return -ENOMEM; | 2971 | return -ENOMEM; |
2961 | 2972 | ||
2973 | ext4_ac_cachep = | ||
2974 | kmem_cache_create("ext4_alloc_context", | ||
2975 | sizeof(struct ext4_allocation_context), | ||
2976 | 0, SLAB_RECLAIM_ACCOUNT, NULL); | ||
2977 | if (ext4_ac_cachep == NULL) { | ||
2978 | kmem_cache_destroy(ext4_pspace_cachep); | ||
2979 | return -ENOMEM; | ||
2980 | } | ||
2962 | #ifdef CONFIG_PROC_FS | 2981 | #ifdef CONFIG_PROC_FS |
2963 | proc_root_ext4 = proc_mkdir(EXT4_ROOT, proc_root_fs); | 2982 | proc_root_ext4 = proc_mkdir(EXT4_ROOT, proc_root_fs); |
2964 | if (proc_root_ext4 == NULL) | 2983 | if (proc_root_ext4 == NULL) |
2965 | printk(KERN_ERR "EXT4-fs: Unable to create %s\n", EXT4_ROOT); | 2984 | printk(KERN_ERR "EXT4-fs: Unable to create %s\n", EXT4_ROOT); |
2966 | #endif | 2985 | #endif |
2967 | |||
2968 | return 0; | 2986 | return 0; |
2969 | } | 2987 | } |
2970 | 2988 | ||
@@ -2972,6 +2990,7 @@ void exit_ext4_mballoc(void) | |||
2972 | { | 2990 | { |
2973 | /* XXX: synchronize_rcu(); */ | 2991 | /* XXX: synchronize_rcu(); */ |
2974 | kmem_cache_destroy(ext4_pspace_cachep); | 2992 | kmem_cache_destroy(ext4_pspace_cachep); |
2993 | kmem_cache_destroy(ext4_ac_cachep); | ||
2975 | #ifdef CONFIG_PROC_FS | 2994 | #ifdef CONFIG_PROC_FS |
2976 | remove_proc_entry(EXT4_ROOT, proc_root_fs); | 2995 | remove_proc_entry(EXT4_ROOT, proc_root_fs); |
2977 | #endif | 2996 | #endif |
@@ -3069,7 +3088,7 @@ static int ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac, | |||
3069 | 3088 | ||
3070 | out_err: | 3089 | out_err: |
3071 | sb->s_dirt = 1; | 3090 | sb->s_dirt = 1; |
3072 | put_bh(bitmap_bh); | 3091 | brelse(bitmap_bh); |
3073 | return err; | 3092 | return err; |
3074 | } | 3093 | } |
3075 | 3094 | ||
@@ -3354,13 +3373,10 @@ static void ext4_mb_use_group_pa(struct ext4_allocation_context *ac, | |||
3354 | ac->ac_pa = pa; | 3373 | ac->ac_pa = pa; |
3355 | 3374 | ||
3356 | /* we don't correct pa_pstart or pa_plen here to avoid | 3375 | /* we don't correct pa_pstart or pa_plen here to avoid |
3357 | * possible race when tte group is being loaded concurrently | 3376 | * possible race when the group is being loaded concurrently |
3358 | * instead we correct pa later, after blocks are marked | 3377 | * instead we correct pa later, after blocks are marked |
3359 | * in on-disk bitmap -- see ext4_mb_release_context() */ | 3378 | * in on-disk bitmap -- see ext4_mb_release_context() |
3360 | /* | 3379 | * Other CPUs are prevented from allocating from this pa by lg_mutex |
3361 | * FIXME!! but the other CPUs can look at this particular | ||
3362 | * pa and think that it have enought free blocks if we | ||
3363 | * don't update pa_free here right ? | ||
3364 | */ | 3380 | */ |
3365 | mb_debug("use %u/%u from group pa %p\n", pa->pa_lstart-len, len, pa); | 3381 | mb_debug("use %u/%u from group pa %p\n", pa->pa_lstart-len, len, pa); |
3366 | } | 3382 | } |
@@ -3699,7 +3715,7 @@ static int ext4_mb_release_inode_pa(struct ext4_buddy *e4b, | |||
3699 | struct buffer_head *bitmap_bh, | 3715 | struct buffer_head *bitmap_bh, |
3700 | struct ext4_prealloc_space *pa) | 3716 | struct ext4_prealloc_space *pa) |
3701 | { | 3717 | { |
3702 | struct ext4_allocation_context ac; | 3718 | struct ext4_allocation_context *ac; |
3703 | struct super_block *sb = e4b->bd_sb; | 3719 | struct super_block *sb = e4b->bd_sb; |
3704 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 3720 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
3705 | unsigned long end; | 3721 | unsigned long end; |
@@ -3715,9 +3731,13 @@ static int ext4_mb_release_inode_pa(struct ext4_buddy *e4b, | |||
3715 | BUG_ON(group != e4b->bd_group && pa->pa_len != 0); | 3731 | BUG_ON(group != e4b->bd_group && pa->pa_len != 0); |
3716 | end = bit + pa->pa_len; | 3732 | end = bit + pa->pa_len; |
3717 | 3733 | ||
3718 | ac.ac_sb = sb; | 3734 | ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); |
3719 | ac.ac_inode = pa->pa_inode; | 3735 | |
3720 | ac.ac_op = EXT4_MB_HISTORY_DISCARD; | 3736 | if (ac) { |
3737 | ac->ac_sb = sb; | ||
3738 | ac->ac_inode = pa->pa_inode; | ||
3739 | ac->ac_op = EXT4_MB_HISTORY_DISCARD; | ||
3740 | } | ||
3721 | 3741 | ||
3722 | while (bit < end) { | 3742 | while (bit < end) { |
3723 | bit = ext4_find_next_zero_bit(bitmap_bh->b_data, end, bit); | 3743 | bit = ext4_find_next_zero_bit(bitmap_bh->b_data, end, bit); |
@@ -3733,24 +3753,28 @@ static int ext4_mb_release_inode_pa(struct ext4_buddy *e4b, | |||
3733 | (unsigned) group); | 3753 | (unsigned) group); |
3734 | free += next - bit; | 3754 | free += next - bit; |
3735 | 3755 | ||
3736 | ac.ac_b_ex.fe_group = group; | 3756 | if (ac) { |
3737 | ac.ac_b_ex.fe_start = bit; | 3757 | ac->ac_b_ex.fe_group = group; |
3738 | ac.ac_b_ex.fe_len = next - bit; | 3758 | ac->ac_b_ex.fe_start = bit; |
3739 | ac.ac_b_ex.fe_logical = 0; | 3759 | ac->ac_b_ex.fe_len = next - bit; |
3740 | ext4_mb_store_history(&ac); | 3760 | ac->ac_b_ex.fe_logical = 0; |
3761 | ext4_mb_store_history(ac); | ||
3762 | } | ||
3741 | 3763 | ||
3742 | mb_free_blocks(pa->pa_inode, e4b, bit, next - bit); | 3764 | mb_free_blocks(pa->pa_inode, e4b, bit, next - bit); |
3743 | bit = next + 1; | 3765 | bit = next + 1; |
3744 | } | 3766 | } |
3745 | if (free != pa->pa_free) { | 3767 | if (free != pa->pa_free) { |
3746 | printk(KERN_ERR "pa %p: logic %lu, phys. %lu, len %lu\n", | 3768 | printk(KERN_CRIT "pa %p: logic %lu, phys. %lu, len %lu\n", |
3747 | pa, (unsigned long) pa->pa_lstart, | 3769 | pa, (unsigned long) pa->pa_lstart, |
3748 | (unsigned long) pa->pa_pstart, | 3770 | (unsigned long) pa->pa_pstart, |
3749 | (unsigned long) pa->pa_len); | 3771 | (unsigned long) pa->pa_len); |
3750 | printk(KERN_ERR "free %u, pa_free %u\n", free, pa->pa_free); | 3772 | ext4_error(sb, __FUNCTION__, "free %u, pa_free %u\n", |
3773 | free, pa->pa_free); | ||
3751 | } | 3774 | } |
3752 | BUG_ON(free != pa->pa_free); | ||
3753 | atomic_add(free, &sbi->s_mb_discarded); | 3775 | atomic_add(free, &sbi->s_mb_discarded); |
3776 | if (ac) | ||
3777 | kmem_cache_free(ext4_ac_cachep, ac); | ||
3754 | 3778 | ||
3755 | return err; | 3779 | return err; |
3756 | } | 3780 | } |
@@ -3758,12 +3782,15 @@ static int ext4_mb_release_inode_pa(struct ext4_buddy *e4b, | |||
3758 | static int ext4_mb_release_group_pa(struct ext4_buddy *e4b, | 3782 | static int ext4_mb_release_group_pa(struct ext4_buddy *e4b, |
3759 | struct ext4_prealloc_space *pa) | 3783 | struct ext4_prealloc_space *pa) |
3760 | { | 3784 | { |
3761 | struct ext4_allocation_context ac; | 3785 | struct ext4_allocation_context *ac; |
3762 | struct super_block *sb = e4b->bd_sb; | 3786 | struct super_block *sb = e4b->bd_sb; |
3763 | ext4_group_t group; | 3787 | ext4_group_t group; |
3764 | ext4_grpblk_t bit; | 3788 | ext4_grpblk_t bit; |
3765 | 3789 | ||
3766 | ac.ac_op = EXT4_MB_HISTORY_DISCARD; | 3790 | ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); |
3791 | |||
3792 | if (ac) | ||
3793 | ac->ac_op = EXT4_MB_HISTORY_DISCARD; | ||
3767 | 3794 | ||
3768 | BUG_ON(pa->pa_deleted == 0); | 3795 | BUG_ON(pa->pa_deleted == 0); |
3769 | ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit); | 3796 | ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit); |
@@ -3771,13 +3798,16 @@ static int ext4_mb_release_group_pa(struct ext4_buddy *e4b, | |||
3771 | mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len); | 3798 | mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len); |
3772 | atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded); | 3799 | atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded); |
3773 | 3800 | ||
3774 | ac.ac_sb = sb; | 3801 | if (ac) { |
3775 | ac.ac_inode = NULL; | 3802 | ac->ac_sb = sb; |
3776 | ac.ac_b_ex.fe_group = group; | 3803 | ac->ac_inode = NULL; |
3777 | ac.ac_b_ex.fe_start = bit; | 3804 | ac->ac_b_ex.fe_group = group; |
3778 | ac.ac_b_ex.fe_len = pa->pa_len; | 3805 | ac->ac_b_ex.fe_start = bit; |
3779 | ac.ac_b_ex.fe_logical = 0; | 3806 | ac->ac_b_ex.fe_len = pa->pa_len; |
3780 | ext4_mb_store_history(&ac); | 3807 | ac->ac_b_ex.fe_logical = 0; |
3808 | ext4_mb_store_history(ac); | ||
3809 | kmem_cache_free(ext4_ac_cachep, ac); | ||
3810 | } | ||
3781 | 3811 | ||
3782 | return 0; | 3812 | return 0; |
3783 | } | 3813 | } |
@@ -4231,7 +4261,7 @@ static int ext4_mb_discard_preallocations(struct super_block *sb, int needed) | |||
4231 | ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, | 4261 | ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, |
4232 | struct ext4_allocation_request *ar, int *errp) | 4262 | struct ext4_allocation_request *ar, int *errp) |
4233 | { | 4263 | { |
4234 | struct ext4_allocation_context ac; | 4264 | struct ext4_allocation_context *ac = NULL; |
4235 | struct ext4_sb_info *sbi; | 4265 | struct ext4_sb_info *sbi; |
4236 | struct super_block *sb; | 4266 | struct super_block *sb; |
4237 | ext4_fsblk_t block = 0; | 4267 | ext4_fsblk_t block = 0; |
@@ -4257,53 +4287,60 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, | |||
4257 | } | 4287 | } |
4258 | inquota = ar->len; | 4288 | inquota = ar->len; |
4259 | 4289 | ||
4290 | ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); | ||
4291 | if (!ac) { | ||
4292 | *errp = -ENOMEM; | ||
4293 | return 0; | ||
4294 | } | ||
4295 | |||
4260 | ext4_mb_poll_new_transaction(sb, handle); | 4296 | ext4_mb_poll_new_transaction(sb, handle); |
4261 | 4297 | ||
4262 | *errp = ext4_mb_initialize_context(&ac, ar); | 4298 | *errp = ext4_mb_initialize_context(ac, ar); |
4263 | if (*errp) { | 4299 | if (*errp) { |
4264 | ar->len = 0; | 4300 | ar->len = 0; |
4265 | goto out; | 4301 | goto out; |
4266 | } | 4302 | } |
4267 | 4303 | ||
4268 | ac.ac_op = EXT4_MB_HISTORY_PREALLOC; | 4304 | ac->ac_op = EXT4_MB_HISTORY_PREALLOC; |
4269 | if (!ext4_mb_use_preallocated(&ac)) { | 4305 | if (!ext4_mb_use_preallocated(ac)) { |
4270 | 4306 | ||
4271 | ac.ac_op = EXT4_MB_HISTORY_ALLOC; | 4307 | ac->ac_op = EXT4_MB_HISTORY_ALLOC; |
4272 | ext4_mb_normalize_request(&ac, ar); | 4308 | ext4_mb_normalize_request(ac, ar); |
4273 | 4309 | ||
4274 | repeat: | 4310 | repeat: |
4275 | /* allocate space in core */ | 4311 | /* allocate space in core */ |
4276 | ext4_mb_regular_allocator(&ac); | 4312 | ext4_mb_regular_allocator(ac); |
4277 | 4313 | ||
4278 | /* as we've just preallocated more space than | 4314 | /* as we've just preallocated more space than |
4279 | * user requested orinally, we store allocated | 4315 | * user requested orinally, we store allocated |
4280 | * space in a special descriptor */ | 4316 | * space in a special descriptor */ |
4281 | if (ac.ac_status == AC_STATUS_FOUND && | 4317 | if (ac->ac_status == AC_STATUS_FOUND && |
4282 | ac.ac_o_ex.fe_len < ac.ac_b_ex.fe_len) | 4318 | ac->ac_o_ex.fe_len < ac->ac_b_ex.fe_len) |
4283 | ext4_mb_new_preallocation(&ac); | 4319 | ext4_mb_new_preallocation(ac); |
4284 | } | 4320 | } |
4285 | 4321 | ||
4286 | if (likely(ac.ac_status == AC_STATUS_FOUND)) { | 4322 | if (likely(ac->ac_status == AC_STATUS_FOUND)) { |
4287 | ext4_mb_mark_diskspace_used(&ac, handle); | 4323 | ext4_mb_mark_diskspace_used(ac, handle); |
4288 | *errp = 0; | 4324 | *errp = 0; |
4289 | block = ext4_grp_offs_to_block(sb, &ac.ac_b_ex); | 4325 | block = ext4_grp_offs_to_block(sb, &ac->ac_b_ex); |
4290 | ar->len = ac.ac_b_ex.fe_len; | 4326 | ar->len = ac->ac_b_ex.fe_len; |
4291 | } else { | 4327 | } else { |
4292 | freed = ext4_mb_discard_preallocations(sb, ac.ac_o_ex.fe_len); | 4328 | freed = ext4_mb_discard_preallocations(sb, ac->ac_o_ex.fe_len); |
4293 | if (freed) | 4329 | if (freed) |
4294 | goto repeat; | 4330 | goto repeat; |
4295 | *errp = -ENOSPC; | 4331 | *errp = -ENOSPC; |
4296 | ac.ac_b_ex.fe_len = 0; | 4332 | ac->ac_b_ex.fe_len = 0; |
4297 | ar->len = 0; | 4333 | ar->len = 0; |
4298 | ext4_mb_show_ac(&ac); | 4334 | ext4_mb_show_ac(ac); |
4299 | } | 4335 | } |
4300 | 4336 | ||
4301 | ext4_mb_release_context(&ac); | 4337 | ext4_mb_release_context(ac); |
4302 | 4338 | ||
4303 | out: | 4339 | out: |
4304 | if (ar->len < inquota) | 4340 | if (ar->len < inquota) |
4305 | DQUOT_FREE_BLOCK(ar->inode, inquota - ar->len); | 4341 | DQUOT_FREE_BLOCK(ar->inode, inquota - ar->len); |
4306 | 4342 | ||
4343 | kmem_cache_free(ext4_ac_cachep, ac); | ||
4307 | return block; | 4344 | return block; |
4308 | } | 4345 | } |
4309 | static void ext4_mb_poll_new_transaction(struct super_block *sb, | 4346 | static void ext4_mb_poll_new_transaction(struct super_block *sb, |
@@ -4405,9 +4442,9 @@ void ext4_mb_free_blocks(handle_t *handle, struct inode *inode, | |||
4405 | unsigned long block, unsigned long count, | 4442 | unsigned long block, unsigned long count, |
4406 | int metadata, unsigned long *freed) | 4443 | int metadata, unsigned long *freed) |
4407 | { | 4444 | { |
4408 | struct buffer_head *bitmap_bh = 0; | 4445 | struct buffer_head *bitmap_bh = NULL; |
4409 | struct super_block *sb = inode->i_sb; | 4446 | struct super_block *sb = inode->i_sb; |
4410 | struct ext4_allocation_context ac; | 4447 | struct ext4_allocation_context *ac = NULL; |
4411 | struct ext4_group_desc *gdp; | 4448 | struct ext4_group_desc *gdp; |
4412 | struct ext4_super_block *es; | 4449 | struct ext4_super_block *es; |
4413 | unsigned long overflow; | 4450 | unsigned long overflow; |
@@ -4436,9 +4473,12 @@ void ext4_mb_free_blocks(handle_t *handle, struct inode *inode, | |||
4436 | 4473 | ||
4437 | ext4_debug("freeing block %lu\n", block); | 4474 | ext4_debug("freeing block %lu\n", block); |
4438 | 4475 | ||
4439 | ac.ac_op = EXT4_MB_HISTORY_FREE; | 4476 | ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); |
4440 | ac.ac_inode = inode; | 4477 | if (ac) { |
4441 | ac.ac_sb = sb; | 4478 | ac->ac_op = EXT4_MB_HISTORY_FREE; |
4479 | ac->ac_inode = inode; | ||
4480 | ac->ac_sb = sb; | ||
4481 | } | ||
4442 | 4482 | ||
4443 | do_more: | 4483 | do_more: |
4444 | overflow = 0; | 4484 | overflow = 0; |
@@ -4504,10 +4544,12 @@ do_more: | |||
4504 | BUFFER_TRACE(bitmap_bh, "dirtied bitmap block"); | 4544 | BUFFER_TRACE(bitmap_bh, "dirtied bitmap block"); |
4505 | err = ext4_journal_dirty_metadata(handle, bitmap_bh); | 4545 | err = ext4_journal_dirty_metadata(handle, bitmap_bh); |
4506 | 4546 | ||
4507 | ac.ac_b_ex.fe_group = block_group; | 4547 | if (ac) { |
4508 | ac.ac_b_ex.fe_start = bit; | 4548 | ac->ac_b_ex.fe_group = block_group; |
4509 | ac.ac_b_ex.fe_len = count; | 4549 | ac->ac_b_ex.fe_start = bit; |
4510 | ext4_mb_store_history(&ac); | 4550 | ac->ac_b_ex.fe_len = count; |
4551 | ext4_mb_store_history(ac); | ||
4552 | } | ||
4511 | 4553 | ||
4512 | if (metadata) { | 4554 | if (metadata) { |
4513 | /* blocks being freed are metadata. these blocks shouldn't | 4555 | /* blocks being freed are metadata. these blocks shouldn't |
@@ -4548,5 +4590,7 @@ do_more: | |||
4548 | error_return: | 4590 | error_return: |
4549 | brelse(bitmap_bh); | 4591 | brelse(bitmap_bh); |
4550 | ext4_std_error(sb, err); | 4592 | ext4_std_error(sb, err); |
4593 | if (ac) | ||
4594 | kmem_cache_free(ext4_ac_cachep, ac); | ||
4551 | return; | 4595 | return; |
4552 | } | 4596 | } |
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c index 3ebc2332f52e..8c6c685b9d22 100644 --- a/fs/ext4/migrate.c +++ b/fs/ext4/migrate.c | |||
@@ -61,10 +61,9 @@ static int finish_range(handle_t *handle, struct inode *inode, | |||
61 | retval = ext4_journal_restart(handle, needed); | 61 | retval = ext4_journal_restart(handle, needed); |
62 | if (retval) | 62 | if (retval) |
63 | goto err_out; | 63 | goto err_out; |
64 | } | 64 | } else if (needed) { |
65 | if (needed) { | ||
66 | retval = ext4_journal_extend(handle, needed); | 65 | retval = ext4_journal_extend(handle, needed); |
67 | if (retval != 0) { | 66 | if (retval) { |
68 | /* | 67 | /* |
69 | * IF not able to extend the journal restart the journal | 68 | * IF not able to extend the journal restart the journal |
70 | */ | 69 | */ |
@@ -220,6 +219,26 @@ static int update_tind_extent_range(handle_t *handle, struct inode *inode, | |||
220 | 219 | ||
221 | } | 220 | } |
222 | 221 | ||
222 | static int extend_credit_for_blkdel(handle_t *handle, struct inode *inode) | ||
223 | { | ||
224 | int retval = 0, needed; | ||
225 | |||
226 | if (handle->h_buffer_credits > EXT4_RESERVE_TRANS_BLOCKS) | ||
227 | return 0; | ||
228 | /* | ||
229 | * We are freeing a blocks. During this we touch | ||
230 | * superblock, group descriptor and block bitmap. | ||
231 | * So allocate a credit of 3. We may update | ||
232 | * quota (user and group). | ||
233 | */ | ||
234 | needed = 3 + 2*EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb); | ||
235 | |||
236 | if (ext4_journal_extend(handle, needed) != 0) | ||
237 | retval = ext4_journal_restart(handle, needed); | ||
238 | |||
239 | return retval; | ||
240 | } | ||
241 | |||
223 | static int free_dind_blocks(handle_t *handle, | 242 | static int free_dind_blocks(handle_t *handle, |
224 | struct inode *inode, __le32 i_data) | 243 | struct inode *inode, __le32 i_data) |
225 | { | 244 | { |
@@ -234,11 +253,14 @@ static int free_dind_blocks(handle_t *handle, | |||
234 | 253 | ||
235 | tmp_idata = (__le32 *)bh->b_data; | 254 | tmp_idata = (__le32 *)bh->b_data; |
236 | for (i = 0; i < max_entries; i++) { | 255 | for (i = 0; i < max_entries; i++) { |
237 | if (tmp_idata[i]) | 256 | if (tmp_idata[i]) { |
257 | extend_credit_for_blkdel(handle, inode); | ||
238 | ext4_free_blocks(handle, inode, | 258 | ext4_free_blocks(handle, inode, |
239 | le32_to_cpu(tmp_idata[i]), 1, 1); | 259 | le32_to_cpu(tmp_idata[i]), 1, 1); |
260 | } | ||
240 | } | 261 | } |
241 | put_bh(bh); | 262 | put_bh(bh); |
263 | extend_credit_for_blkdel(handle, inode); | ||
242 | ext4_free_blocks(handle, inode, le32_to_cpu(i_data), 1, 1); | 264 | ext4_free_blocks(handle, inode, le32_to_cpu(i_data), 1, 1); |
243 | return 0; | 265 | return 0; |
244 | } | 266 | } |
@@ -267,29 +289,32 @@ static int free_tind_blocks(handle_t *handle, | |||
267 | } | 289 | } |
268 | } | 290 | } |
269 | put_bh(bh); | 291 | put_bh(bh); |
292 | extend_credit_for_blkdel(handle, inode); | ||
270 | ext4_free_blocks(handle, inode, le32_to_cpu(i_data), 1, 1); | 293 | ext4_free_blocks(handle, inode, le32_to_cpu(i_data), 1, 1); |
271 | return 0; | 294 | return 0; |
272 | } | 295 | } |
273 | 296 | ||
274 | static int free_ind_block(handle_t *handle, struct inode *inode) | 297 | static int free_ind_block(handle_t *handle, struct inode *inode, __le32 *i_data) |
275 | { | 298 | { |
276 | int retval; | 299 | int retval; |
277 | struct ext4_inode_info *ei = EXT4_I(inode); | ||
278 | 300 | ||
279 | if (ei->i_data[EXT4_IND_BLOCK]) | 301 | /* ei->i_data[EXT4_IND_BLOCK] */ |
302 | if (i_data[0]) { | ||
303 | extend_credit_for_blkdel(handle, inode); | ||
280 | ext4_free_blocks(handle, inode, | 304 | ext4_free_blocks(handle, inode, |
281 | le32_to_cpu(ei->i_data[EXT4_IND_BLOCK]), 1, 1); | 305 | le32_to_cpu(i_data[0]), 1, 1); |
306 | } | ||
282 | 307 | ||
283 | if (ei->i_data[EXT4_DIND_BLOCK]) { | 308 | /* ei->i_data[EXT4_DIND_BLOCK] */ |
284 | retval = free_dind_blocks(handle, inode, | 309 | if (i_data[1]) { |
285 | ei->i_data[EXT4_DIND_BLOCK]); | 310 | retval = free_dind_blocks(handle, inode, i_data[1]); |
286 | if (retval) | 311 | if (retval) |
287 | return retval; | 312 | return retval; |
288 | } | 313 | } |
289 | 314 | ||
290 | if (ei->i_data[EXT4_TIND_BLOCK]) { | 315 | /* ei->i_data[EXT4_TIND_BLOCK] */ |
291 | retval = free_tind_blocks(handle, inode, | 316 | if (i_data[2]) { |
292 | ei->i_data[EXT4_TIND_BLOCK]); | 317 | retval = free_tind_blocks(handle, inode, i_data[2]); |
293 | if (retval) | 318 | if (retval) |
294 | return retval; | 319 | return retval; |
295 | } | 320 | } |
@@ -297,15 +322,13 @@ static int free_ind_block(handle_t *handle, struct inode *inode) | |||
297 | } | 322 | } |
298 | 323 | ||
299 | static int ext4_ext_swap_inode_data(handle_t *handle, struct inode *inode, | 324 | static int ext4_ext_swap_inode_data(handle_t *handle, struct inode *inode, |
300 | struct inode *tmp_inode, int retval) | 325 | struct inode *tmp_inode) |
301 | { | 326 | { |
327 | int retval; | ||
328 | __le32 i_data[3]; | ||
302 | struct ext4_inode_info *ei = EXT4_I(inode); | 329 | struct ext4_inode_info *ei = EXT4_I(inode); |
303 | struct ext4_inode_info *tmp_ei = EXT4_I(tmp_inode); | 330 | struct ext4_inode_info *tmp_ei = EXT4_I(tmp_inode); |
304 | 331 | ||
305 | retval = free_ind_block(handle, inode); | ||
306 | if (retval) | ||
307 | goto err_out; | ||
308 | |||
309 | /* | 332 | /* |
310 | * One credit accounted for writing the | 333 | * One credit accounted for writing the |
311 | * i_data field of the original inode | 334 | * i_data field of the original inode |
@@ -317,6 +340,11 @@ static int ext4_ext_swap_inode_data(handle_t *handle, struct inode *inode, | |||
317 | goto err_out; | 340 | goto err_out; |
318 | } | 341 | } |
319 | 342 | ||
343 | i_data[0] = ei->i_data[EXT4_IND_BLOCK]; | ||
344 | i_data[1] = ei->i_data[EXT4_DIND_BLOCK]; | ||
345 | i_data[2] = ei->i_data[EXT4_TIND_BLOCK]; | ||
346 | |||
347 | down_write(&EXT4_I(inode)->i_data_sem); | ||
320 | /* | 348 | /* |
321 | * We have the extent map build with the tmp inode. | 349 | * We have the extent map build with the tmp inode. |
322 | * Now copy the i_data across | 350 | * Now copy the i_data across |
@@ -336,8 +364,15 @@ static int ext4_ext_swap_inode_data(handle_t *handle, struct inode *inode, | |||
336 | spin_lock(&inode->i_lock); | 364 | spin_lock(&inode->i_lock); |
337 | inode->i_blocks += tmp_inode->i_blocks; | 365 | inode->i_blocks += tmp_inode->i_blocks; |
338 | spin_unlock(&inode->i_lock); | 366 | spin_unlock(&inode->i_lock); |
367 | up_write(&EXT4_I(inode)->i_data_sem); | ||
339 | 368 | ||
369 | /* | ||
370 | * We mark the inode dirty after, because we decrement the | ||
371 | * i_blocks when freeing the indirect meta-data blocks | ||
372 | */ | ||
373 | retval = free_ind_block(handle, inode, i_data); | ||
340 | ext4_mark_inode_dirty(handle, inode); | 374 | ext4_mark_inode_dirty(handle, inode); |
375 | |||
341 | err_out: | 376 | err_out: |
342 | return retval; | 377 | return retval; |
343 | } | 378 | } |
@@ -365,6 +400,7 @@ static int free_ext_idx(handle_t *handle, struct inode *inode, | |||
365 | } | 400 | } |
366 | } | 401 | } |
367 | put_bh(bh); | 402 | put_bh(bh); |
403 | extend_credit_for_blkdel(handle, inode); | ||
368 | ext4_free_blocks(handle, inode, block, 1, 1); | 404 | ext4_free_blocks(handle, inode, block, 1, 1); |
369 | return retval; | 405 | return retval; |
370 | } | 406 | } |
@@ -414,7 +450,12 @@ int ext4_ext_migrate(struct inode *inode, struct file *filp, | |||
414 | if ((EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)) | 450 | if ((EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)) |
415 | return -EINVAL; | 451 | return -EINVAL; |
416 | 452 | ||
417 | down_write(&EXT4_I(inode)->i_data_sem); | 453 | if (S_ISLNK(inode->i_mode) && inode->i_blocks == 0) |
454 | /* | ||
455 | * don't migrate fast symlink | ||
456 | */ | ||
457 | return retval; | ||
458 | |||
418 | handle = ext4_journal_start(inode, | 459 | handle = ext4_journal_start(inode, |
419 | EXT4_DATA_TRANS_BLOCKS(inode->i_sb) + | 460 | EXT4_DATA_TRANS_BLOCKS(inode->i_sb) + |
420 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + | 461 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + |
@@ -448,13 +489,6 @@ int ext4_ext_migrate(struct inode *inode, struct file *filp, | |||
448 | ext4_orphan_add(handle, tmp_inode); | 489 | ext4_orphan_add(handle, tmp_inode); |
449 | ext4_journal_stop(handle); | 490 | ext4_journal_stop(handle); |
450 | 491 | ||
451 | ei = EXT4_I(inode); | ||
452 | i_data = ei->i_data; | ||
453 | memset(&lb, 0, sizeof(lb)); | ||
454 | |||
455 | /* 32 bit block address 4 bytes */ | ||
456 | max_entries = inode->i_sb->s_blocksize >> 2; | ||
457 | |||
458 | /* | 492 | /* |
459 | * start with one credit accounted for | 493 | * start with one credit accounted for |
460 | * superblock modification. | 494 | * superblock modification. |
@@ -463,7 +497,20 @@ int ext4_ext_migrate(struct inode *inode, struct file *filp, | |||
463 | * trascation that created the inode. Later as and | 497 | * trascation that created the inode. Later as and |
464 | * when we add extents we extent the journal | 498 | * when we add extents we extent the journal |
465 | */ | 499 | */ |
500 | /* | ||
501 | * inode_mutex prevent write and truncate on the file. Read still goes | ||
502 | * through. We take i_data_sem in ext4_ext_swap_inode_data before we | ||
503 | * switch the inode format to prevent read. | ||
504 | */ | ||
505 | mutex_lock(&(inode->i_mutex)); | ||
466 | handle = ext4_journal_start(inode, 1); | 506 | handle = ext4_journal_start(inode, 1); |
507 | |||
508 | ei = EXT4_I(inode); | ||
509 | i_data = ei->i_data; | ||
510 | memset(&lb, 0, sizeof(lb)); | ||
511 | |||
512 | /* 32 bit block address 4 bytes */ | ||
513 | max_entries = inode->i_sb->s_blocksize >> 2; | ||
467 | for (i = 0; i < EXT4_NDIR_BLOCKS; i++, blk_count++) { | 514 | for (i = 0; i < EXT4_NDIR_BLOCKS; i++, blk_count++) { |
468 | if (i_data[i]) { | 515 | if (i_data[i]) { |
469 | retval = update_extent_range(handle, tmp_inode, | 516 | retval = update_extent_range(handle, tmp_inode, |
@@ -501,19 +548,6 @@ int ext4_ext_migrate(struct inode *inode, struct file *filp, | |||
501 | */ | 548 | */ |
502 | retval = finish_range(handle, tmp_inode, &lb); | 549 | retval = finish_range(handle, tmp_inode, &lb); |
503 | err_out: | 550 | err_out: |
504 | /* | ||
505 | * We are either freeing extent information or indirect | ||
506 | * blocks. During this we touch superblock, group descriptor | ||
507 | * and block bitmap. Later we mark the tmp_inode dirty | ||
508 | * via ext4_ext_tree_init. So allocate a credit of 4 | ||
509 | * We may update quota (user and group). | ||
510 | * | ||
511 | * FIXME!! we may be touching bitmaps in different block groups. | ||
512 | */ | ||
513 | if (ext4_journal_extend(handle, | ||
514 | 4 + 2*EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb)) != 0) | ||
515 | ext4_journal_restart(handle, | ||
516 | 4 + 2*EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb)); | ||
517 | if (retval) | 551 | if (retval) |
518 | /* | 552 | /* |
519 | * Failure case delete the extent information with the | 553 | * Failure case delete the extent information with the |
@@ -522,7 +556,11 @@ err_out: | |||
522 | free_ext_block(handle, tmp_inode); | 556 | free_ext_block(handle, tmp_inode); |
523 | else | 557 | else |
524 | retval = ext4_ext_swap_inode_data(handle, inode, | 558 | retval = ext4_ext_swap_inode_data(handle, inode, |
525 | tmp_inode, retval); | 559 | tmp_inode); |
560 | |||
561 | /* We mark the tmp_inode dirty via ext4_ext_tree_init. */ | ||
562 | if (ext4_journal_extend(handle, 1) != 0) | ||
563 | ext4_journal_restart(handle, 1); | ||
526 | 564 | ||
527 | /* | 565 | /* |
528 | * Mark the tmp_inode as of size zero | 566 | * Mark the tmp_inode as of size zero |
@@ -550,8 +588,7 @@ err_out: | |||
550 | tmp_inode->i_nlink = 0; | 588 | tmp_inode->i_nlink = 0; |
551 | 589 | ||
552 | ext4_journal_stop(handle); | 590 | ext4_journal_stop(handle); |
553 | 591 | mutex_unlock(&(inode->i_mutex)); | |
554 | up_write(&EXT4_I(inode)->i_data_sem); | ||
555 | 592 | ||
556 | if (tmp_inode) | 593 | if (tmp_inode) |
557 | iput(tmp_inode); | 594 | iput(tmp_inode); |
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index d153bb5922fc..a9347fb43bcc 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -2223,6 +2223,7 @@ retry: | |||
2223 | inode->i_op = &ext4_fast_symlink_inode_operations; | 2223 | inode->i_op = &ext4_fast_symlink_inode_operations; |
2224 | memcpy((char*)&EXT4_I(inode)->i_data,symname,l); | 2224 | memcpy((char*)&EXT4_I(inode)->i_data,symname,l); |
2225 | inode->i_size = l-1; | 2225 | inode->i_size = l-1; |
2226 | EXT4_I(inode)->i_flags &= ~EXT4_EXTENTS_FL; | ||
2226 | } | 2227 | } |
2227 | EXT4_I(inode)->i_disksize = inode->i_size; | 2228 | EXT4_I(inode)->i_disksize = inode->i_size; |
2228 | err = ext4_add_nondir(handle, dentry, inode); | 2229 | err = ext4_add_nondir(handle, dentry, inode); |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 93beb865c20d..0072da75221f 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -1919,6 +1919,17 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent) | |||
1919 | printk(KERN_WARNING | 1919 | printk(KERN_WARNING |
1920 | "EXT4-fs warning: feature flags set on rev 0 fs, " | 1920 | "EXT4-fs warning: feature flags set on rev 0 fs, " |
1921 | "running e2fsck is recommended\n"); | 1921 | "running e2fsck is recommended\n"); |
1922 | |||
1923 | /* | ||
1924 | * Since ext4 is still considered development code, we require | ||
1925 | * that the TEST_FILESYS flag in s->flags be set. | ||
1926 | */ | ||
1927 | if (!(le32_to_cpu(es->s_flags) & EXT2_FLAGS_TEST_FILESYS)) { | ||
1928 | printk(KERN_WARNING "EXT4-fs: %s: not marked " | ||
1929 | "OK to use with test code.\n", sb->s_id); | ||
1930 | goto failed_mount; | ||
1931 | } | ||
1932 | |||
1922 | /* | 1933 | /* |
1923 | * Check feature flags regardless of the revision level, since we | 1934 | * Check feature flags regardless of the revision level, since we |
1924 | * previously didn't change the revision level when setting the flags, | 1935 | * previously didn't change the revision level when setting the flags, |
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index d0549cb4fb23..5222345ddccf 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/pagemap.h> | 12 | #include <linux/pagemap.h> |
13 | #include <linux/statfs.h> | 13 | #include <linux/statfs.h> |
14 | #include <linux/seq_file.h> | 14 | #include <linux/seq_file.h> |
15 | #include <linux/mount.h> | ||
15 | #include "hostfs.h" | 16 | #include "hostfs.h" |
16 | #include "init.h" | 17 | #include "init.h" |
17 | #include "kern.h" | 18 | #include "kern.h" |
diff --git a/fs/ioctl.c b/fs/ioctl.c index 683002fefa55..f32fbde2175e 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c | |||
@@ -18,12 +18,12 @@ | |||
18 | 18 | ||
19 | /** | 19 | /** |
20 | * vfs_ioctl - call filesystem specific ioctl methods | 20 | * vfs_ioctl - call filesystem specific ioctl methods |
21 | * @filp: [in] open file to invoke ioctl method on | 21 | * @filp: open file to invoke ioctl method on |
22 | * @cmd: [in] ioctl command to execute | 22 | * @cmd: ioctl command to execute |
23 | * @arg: [in/out] command-specific argument for ioctl | 23 | * @arg: command-specific argument for ioctl |
24 | * | 24 | * |
25 | * Invokes filesystem specific ->unlocked_ioctl, if one exists; otherwise | 25 | * Invokes filesystem specific ->unlocked_ioctl, if one exists; otherwise |
26 | * invokes * filesystem specific ->ioctl method. If neither method exists, | 26 | * invokes filesystem specific ->ioctl method. If neither method exists, |
27 | * returns -ENOTTY. | 27 | * returns -ENOTTY. |
28 | * | 28 | * |
29 | * Returns 0 on success, -errno on error. | 29 | * Returns 0 on success, -errno on error. |
diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c index 8e08efcaede2..a38c7186c570 100644 --- a/fs/jbd/commit.c +++ b/fs/jbd/commit.c | |||
@@ -104,7 +104,8 @@ static int journal_write_commit_record(journal_t *journal, | |||
104 | { | 104 | { |
105 | struct journal_head *descriptor; | 105 | struct journal_head *descriptor; |
106 | struct buffer_head *bh; | 106 | struct buffer_head *bh; |
107 | int i, ret; | 107 | journal_header_t *header; |
108 | int ret; | ||
108 | int barrier_done = 0; | 109 | int barrier_done = 0; |
109 | 110 | ||
110 | if (is_journal_aborted(journal)) | 111 | if (is_journal_aborted(journal)) |
@@ -116,13 +117,10 @@ static int journal_write_commit_record(journal_t *journal, | |||
116 | 117 | ||
117 | bh = jh2bh(descriptor); | 118 | bh = jh2bh(descriptor); |
118 | 119 | ||
119 | /* AKPM: buglet - add `i' to tmp! */ | 120 | header = (journal_header_t *)(bh->b_data); |
120 | for (i = 0; i < bh->b_size; i += 512) { | 121 | header->h_magic = cpu_to_be32(JFS_MAGIC_NUMBER); |
121 | journal_header_t *tmp = (journal_header_t*)bh->b_data; | 122 | header->h_blocktype = cpu_to_be32(JFS_COMMIT_BLOCK); |
122 | tmp->h_magic = cpu_to_be32(JFS_MAGIC_NUMBER); | 123 | header->h_sequence = cpu_to_be32(commit_transaction->t_tid); |
123 | tmp->h_blocktype = cpu_to_be32(JFS_COMMIT_BLOCK); | ||
124 | tmp->h_sequence = cpu_to_be32(commit_transaction->t_tid); | ||
125 | } | ||
126 | 124 | ||
127 | JBUFFER_TRACE(descriptor, "write commit block"); | 125 | JBUFFER_TRACE(descriptor, "write commit block"); |
128 | set_buffer_dirty(bh); | 126 | set_buffer_dirty(bh); |
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 4f302d279279..a8173081f831 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c | |||
@@ -136,18 +136,20 @@ static int journal_submit_commit_record(journal_t *journal, | |||
136 | 136 | ||
137 | JBUFFER_TRACE(descriptor, "submit commit block"); | 137 | JBUFFER_TRACE(descriptor, "submit commit block"); |
138 | lock_buffer(bh); | 138 | lock_buffer(bh); |
139 | 139 | get_bh(bh); | |
140 | set_buffer_dirty(bh); | 140 | set_buffer_dirty(bh); |
141 | set_buffer_uptodate(bh); | 141 | set_buffer_uptodate(bh); |
142 | bh->b_end_io = journal_end_buffer_io_sync; | 142 | bh->b_end_io = journal_end_buffer_io_sync; |
143 | 143 | ||
144 | if (journal->j_flags & JBD2_BARRIER && | 144 | if (journal->j_flags & JBD2_BARRIER && |
145 | !JBD2_HAS_COMPAT_FEATURE(journal, | 145 | !JBD2_HAS_INCOMPAT_FEATURE(journal, |
146 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) { | 146 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) { |
147 | set_buffer_ordered(bh); | 147 | set_buffer_ordered(bh); |
148 | barrier_done = 1; | 148 | barrier_done = 1; |
149 | } | 149 | } |
150 | ret = submit_bh(WRITE, bh); | 150 | ret = submit_bh(WRITE, bh); |
151 | if (barrier_done) | ||
152 | clear_buffer_ordered(bh); | ||
151 | 153 | ||
152 | /* is it possible for another commit to fail at roughly | 154 | /* is it possible for another commit to fail at roughly |
153 | * the same time as this one? If so, we don't want to | 155 | * the same time as this one? If so, we don't want to |
@@ -166,7 +168,6 @@ static int journal_submit_commit_record(journal_t *journal, | |||
166 | spin_unlock(&journal->j_state_lock); | 168 | spin_unlock(&journal->j_state_lock); |
167 | 169 | ||
168 | /* And try again, without the barrier */ | 170 | /* And try again, without the barrier */ |
169 | clear_buffer_ordered(bh); | ||
170 | set_buffer_uptodate(bh); | 171 | set_buffer_uptodate(bh); |
171 | set_buffer_dirty(bh); | 172 | set_buffer_dirty(bh); |
172 | ret = submit_bh(WRITE, bh); | 173 | ret = submit_bh(WRITE, bh); |
@@ -872,7 +873,8 @@ wait_for_iobuf: | |||
872 | if (err) | 873 | if (err) |
873 | __jbd2_journal_abort_hard(journal); | 874 | __jbd2_journal_abort_hard(journal); |
874 | } | 875 | } |
875 | err = journal_wait_on_commit_record(cbh); | 876 | if (!err && !is_journal_aborted(journal)) |
877 | err = journal_wait_on_commit_record(cbh); | ||
876 | 878 | ||
877 | if (err) | 879 | if (err) |
878 | jbd2_journal_abort(journal, err); | 880 | jbd2_journal_abort(journal, err); |
diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c index d36356f7d222..146411387ada 100644 --- a/fs/jbd2/recovery.c +++ b/fs/jbd2/recovery.c | |||
@@ -641,7 +641,7 @@ static int do_one_pass(journal_t *journal, | |||
641 | if (chksum_err) { | 641 | if (chksum_err) { |
642 | info->end_transaction = next_commit_ID; | 642 | info->end_transaction = next_commit_ID; |
643 | 643 | ||
644 | if (!JBD2_HAS_COMPAT_FEATURE(journal, | 644 | if (!JBD2_HAS_INCOMPAT_FEATURE(journal, |
645 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)){ | 645 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)){ |
646 | printk(KERN_ERR | 646 | printk(KERN_ERR |
647 | "JBD: Transaction %u " | 647 | "JBD: Transaction %u " |
diff --git a/include/asm-blackfin/page.h b/include/asm-blackfin/page.h index d5c9d1433781..c7db0220fbd6 100644 --- a/include/asm-blackfin/page.h +++ b/include/asm-blackfin/page.h | |||
@@ -39,6 +39,7 @@ typedef struct { | |||
39 | typedef struct { | 39 | typedef struct { |
40 | unsigned long pgprot; | 40 | unsigned long pgprot; |
41 | } pgprot_t; | 41 | } pgprot_t; |
42 | typedef struct page *pgtable_t; | ||
42 | 43 | ||
43 | #define pte_val(x) ((x).pte) | 44 | #define pte_val(x) ((x).pte) |
44 | #define pmd_val(x) ((&x)->pmd[0]) | 45 | #define pmd_val(x) ((&x)->pmd[0]) |
diff --git a/include/asm-h8300/page.h b/include/asm-h8300/page.h index a83492449130..d6a3eaf3b27e 100644 --- a/include/asm-h8300/page.h +++ b/include/asm-h8300/page.h | |||
@@ -31,6 +31,7 @@ typedef struct { unsigned long pte; } pte_t; | |||
31 | typedef struct { unsigned long pmd[16]; } pmd_t; | 31 | typedef struct { unsigned long pmd[16]; } pmd_t; |
32 | typedef struct { unsigned long pgd; } pgd_t; | 32 | typedef struct { unsigned long pgd; } pgd_t; |
33 | typedef struct { unsigned long pgprot; } pgprot_t; | 33 | typedef struct { unsigned long pgprot; } pgprot_t; |
34 | typedef struct page *pgtable_t; | ||
34 | 35 | ||
35 | #define pte_val(x) ((x).pte) | 36 | #define pte_val(x) ((x).pte) |
36 | #define pmd_val(x) ((&x)->pmd[0]) | 37 | #define pmd_val(x) ((&x)->pmd[0]) |
diff --git a/include/asm-m68knommu/page.h b/include/asm-m68knommu/page.h index 6af480c7f291..1e82ebb7d644 100644 --- a/include/asm-m68knommu/page.h +++ b/include/asm-m68knommu/page.h | |||
@@ -31,6 +31,7 @@ typedef struct { unsigned long pte; } pte_t; | |||
31 | typedef struct { unsigned long pmd[16]; } pmd_t; | 31 | typedef struct { unsigned long pmd[16]; } pmd_t; |
32 | typedef struct { unsigned long pgd; } pgd_t; | 32 | typedef struct { unsigned long pgd; } pgd_t; |
33 | typedef struct { unsigned long pgprot; } pgprot_t; | 33 | typedef struct { unsigned long pgprot; } pgprot_t; |
34 | typedef struct page *pgtable_t; | ||
34 | 35 | ||
35 | #define pte_val(x) ((x).pte) | 36 | #define pte_val(x) ((x).pte) |
36 | #define pmd_val(x) ((&x)->pmd[0]) | 37 | #define pmd_val(x) ((&x)->pmd[0]) |
diff --git a/include/asm-s390/a.out.h b/include/asm-s390/a.out.h deleted file mode 100644 index 8d6bd9c2952e..000000000000 --- a/include/asm-s390/a.out.h +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | /* | ||
2 | * include/asm-s390/a.out.h | ||
3 | * | ||
4 | * S390 version | ||
5 | * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation | ||
6 | * | ||
7 | * Derived from "include/asm-i386/a.out.h" | ||
8 | * Copyright (C) 1992, Linus Torvalds | ||
9 | * | ||
10 | * I don't think we'll ever need a.out ... | ||
11 | */ | ||
12 | |||
13 | #ifndef __S390_A_OUT_H__ | ||
14 | #define __S390_A_OUT_H__ | ||
15 | |||
16 | struct exec | ||
17 | { | ||
18 | unsigned long a_info; /* Use macros N_MAGIC, etc for access */ | ||
19 | unsigned a_text; /* length of text, in bytes */ | ||
20 | unsigned a_data; /* length of data, in bytes */ | ||
21 | unsigned a_bss; /* length of uninitialized data area for file, in bytes */ | ||
22 | unsigned a_syms; /* length of symbol table data in file, in bytes */ | ||
23 | unsigned a_entry; /* start address */ | ||
24 | unsigned a_trsize; /* length of relocation info for text, in bytes */ | ||
25 | unsigned a_drsize; /* length of relocation info for data, in bytes */ | ||
26 | }; | ||
27 | |||
28 | #define N_TRSIZE(a) ((a).a_trsize) | ||
29 | #define N_DRSIZE(a) ((a).a_drsize) | ||
30 | #define N_SYMSIZE(a) ((a).a_syms) | ||
31 | |||
32 | #endif /* __A_OUT_GNU_H__ */ | ||
diff --git a/include/asm-s390/bitops.h b/include/asm-s390/bitops.h index 882db054110c..ab83c844d04c 100644 --- a/include/asm-s390/bitops.h +++ b/include/asm-s390/bitops.h | |||
@@ -472,7 +472,7 @@ static inline unsigned long __ffz_word_loop(const unsigned long *addr, | |||
472 | " brct %1,0b\n" | 472 | " brct %1,0b\n" |
473 | "1:\n" | 473 | "1:\n" |
474 | #endif | 474 | #endif |
475 | : "+a" (bytes), "+d" (size) | 475 | : "+&a" (bytes), "+&d" (size) |
476 | : "d" (-1UL), "a" (addr), "m" (*(addrtype *) addr) | 476 | : "d" (-1UL), "a" (addr), "m" (*(addrtype *) addr) |
477 | : "cc" ); | 477 | : "cc" ); |
478 | return bytes; | 478 | return bytes; |
@@ -507,7 +507,7 @@ static inline unsigned long __ffs_word_loop(const unsigned long *addr, | |||
507 | " brct %1,0b\n" | 507 | " brct %1,0b\n" |
508 | "1:\n" | 508 | "1:\n" |
509 | #endif | 509 | #endif |
510 | : "+a" (bytes), "+a" (size) | 510 | : "+&a" (bytes), "+&a" (size) |
511 | : "d" (0UL), "a" (addr), "m" (*(addrtype *) addr) | 511 | : "d" (0UL), "a" (addr), "m" (*(addrtype *) addr) |
512 | : "cc" ); | 512 | : "cc" ); |
513 | return bytes; | 513 | return bytes; |
diff --git a/include/asm-s390/elf.h b/include/asm-s390/elf.h index b73a424d0f97..b3ac262c4582 100644 --- a/include/asm-s390/elf.h +++ b/include/asm-s390/elf.h | |||
@@ -115,6 +115,7 @@ typedef s390_regs elf_gregset_t; | |||
115 | 115 | ||
116 | #include <linux/sched.h> /* for task_struct */ | 116 | #include <linux/sched.h> /* for task_struct */ |
117 | #include <asm/system.h> /* for save_access_regs */ | 117 | #include <asm/system.h> /* for save_access_regs */ |
118 | #include <asm/mmu_context.h> | ||
118 | 119 | ||
119 | /* | 120 | /* |
120 | * This is used to ensure we don't load something for the wrong architecture. | 121 | * This is used to ensure we don't load something for the wrong architecture. |
@@ -137,14 +138,7 @@ typedef s390_regs elf_gregset_t; | |||
137 | use of this is to invoke "./ld.so someprog" to test out a new version of | 138 | use of this is to invoke "./ld.so someprog" to test out a new version of |
138 | the loader. We need to make sure that it is out of the way of the program | 139 | the loader. We need to make sure that it is out of the way of the program |
139 | that it will "exec", and that there is sufficient room for the brk. */ | 140 | that it will "exec", and that there is sufficient room for the brk. */ |
140 | 141 | #define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2) | |
141 | #ifndef __s390x__ | ||
142 | #define ELF_ET_DYN_BASE ((TASK_SIZE & 0x80000000) \ | ||
143 | ? TASK_SIZE / 3 * 2 \ | ||
144 | : 2 * TASK_SIZE / 3) | ||
145 | #else /* __s390x__ */ | ||
146 | #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2) | ||
147 | #endif /* __s390x__ */ | ||
148 | 142 | ||
149 | /* Wow, the "main" arch needs arch dependent functions too.. :) */ | 143 | /* Wow, the "main" arch needs arch dependent functions too.. :) */ |
150 | 144 | ||
@@ -214,4 +208,16 @@ do { \ | |||
214 | } while (0) | 208 | } while (0) |
215 | #endif /* __s390x__ */ | 209 | #endif /* __s390x__ */ |
216 | 210 | ||
211 | /* | ||
212 | * An executable for which elf_read_implies_exec() returns TRUE will | ||
213 | * have the READ_IMPLIES_EXEC personality flag set automatically. | ||
214 | */ | ||
215 | #define elf_read_implies_exec(ex, executable_stack) \ | ||
216 | ({ \ | ||
217 | if (current->mm->context.noexec && \ | ||
218 | executable_stack != EXSTACK_DISABLE_X) \ | ||
219 | disable_noexec(current->mm, current); \ | ||
220 | current->mm->context.noexec == 0; \ | ||
221 | }) | ||
222 | |||
217 | #endif | 223 | #endif |
diff --git a/include/asm-s390/mmu.h b/include/asm-s390/mmu.h index ccd36d26615a..1698e29c5b20 100644 --- a/include/asm-s390/mmu.h +++ b/include/asm-s390/mmu.h | |||
@@ -1,7 +1,12 @@ | |||
1 | #ifndef __MMU_H | 1 | #ifndef __MMU_H |
2 | #define __MMU_H | 2 | #define __MMU_H |
3 | 3 | ||
4 | /* Default "unsigned long" context */ | 4 | typedef struct { |
5 | typedef unsigned long mm_context_t; | 5 | struct list_head crst_list; |
6 | struct list_head pgtable_list; | ||
7 | unsigned long asce_bits; | ||
8 | unsigned long asce_limit; | ||
9 | int noexec; | ||
10 | } mm_context_t; | ||
6 | 11 | ||
7 | #endif | 12 | #endif |
diff --git a/include/asm-s390/mmu_context.h b/include/asm-s390/mmu_context.h index a77d4ba3c8eb..b5a34c6f91a9 100644 --- a/include/asm-s390/mmu_context.h +++ b/include/asm-s390/mmu_context.h | |||
@@ -10,15 +10,19 @@ | |||
10 | #define __S390_MMU_CONTEXT_H | 10 | #define __S390_MMU_CONTEXT_H |
11 | 11 | ||
12 | #include <asm/pgalloc.h> | 12 | #include <asm/pgalloc.h> |
13 | #include <asm/uaccess.h> | ||
13 | #include <asm-generic/mm_hooks.h> | 14 | #include <asm-generic/mm_hooks.h> |
14 | 15 | ||
15 | static inline int init_new_context(struct task_struct *tsk, | 16 | static inline int init_new_context(struct task_struct *tsk, |
16 | struct mm_struct *mm) | 17 | struct mm_struct *mm) |
17 | { | 18 | { |
18 | mm->context = _ASCE_TABLE_LENGTH | _ASCE_USER_BITS; | 19 | mm->context.asce_bits = _ASCE_TABLE_LENGTH | _ASCE_USER_BITS; |
19 | #ifdef CONFIG_64BIT | 20 | #ifdef CONFIG_64BIT |
20 | mm->context |= _ASCE_TYPE_REGION3; | 21 | mm->context.asce_bits |= _ASCE_TYPE_REGION3; |
21 | #endif | 22 | #endif |
23 | mm->context.noexec = s390_noexec; | ||
24 | mm->context.asce_limit = STACK_TOP_MAX; | ||
25 | crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm)); | ||
22 | return 0; | 26 | return 0; |
23 | } | 27 | } |
24 | 28 | ||
@@ -32,24 +36,25 @@ static inline int init_new_context(struct task_struct *tsk, | |||
32 | 36 | ||
33 | static inline void update_mm(struct mm_struct *mm, struct task_struct *tsk) | 37 | static inline void update_mm(struct mm_struct *mm, struct task_struct *tsk) |
34 | { | 38 | { |
35 | S390_lowcore.user_asce = mm->context | __pa(mm->pgd); | 39 | pgd_t *pgd = mm->pgd; |
40 | |||
41 | S390_lowcore.user_asce = mm->context.asce_bits | __pa(pgd); | ||
36 | if (switch_amode) { | 42 | if (switch_amode) { |
37 | /* Load primary space page table origin. */ | 43 | /* Load primary space page table origin. */ |
38 | pgd_t *shadow_pgd = get_shadow_table(mm->pgd) ? : mm->pgd; | 44 | pgd = mm->context.noexec ? get_shadow_table(pgd) : pgd; |
39 | S390_lowcore.user_exec_asce = mm->context | __pa(shadow_pgd); | 45 | S390_lowcore.user_exec_asce = mm->context.asce_bits | __pa(pgd); |
40 | asm volatile(LCTL_OPCODE" 1,1,%0\n" | 46 | asm volatile(LCTL_OPCODE" 1,1,%0\n" |
41 | : : "m" (S390_lowcore.user_exec_asce) ); | 47 | : : "m" (S390_lowcore.user_exec_asce) ); |
42 | } else | 48 | } else |
43 | /* Load home space page table origin. */ | 49 | /* Load home space page table origin. */ |
44 | asm volatile(LCTL_OPCODE" 13,13,%0" | 50 | asm volatile(LCTL_OPCODE" 13,13,%0" |
45 | : : "m" (S390_lowcore.user_asce) ); | 51 | : : "m" (S390_lowcore.user_asce) ); |
52 | set_fs(current->thread.mm_segment); | ||
46 | } | 53 | } |
47 | 54 | ||
48 | static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, | 55 | static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, |
49 | struct task_struct *tsk) | 56 | struct task_struct *tsk) |
50 | { | 57 | { |
51 | if (unlikely(prev == next)) | ||
52 | return; | ||
53 | cpu_set(smp_processor_id(), next->cpu_vm_mask); | 58 | cpu_set(smp_processor_id(), next->cpu_vm_mask); |
54 | update_mm(next, tsk); | 59 | update_mm(next, tsk); |
55 | } | 60 | } |
@@ -61,7 +66,6 @@ static inline void activate_mm(struct mm_struct *prev, | |||
61 | struct mm_struct *next) | 66 | struct mm_struct *next) |
62 | { | 67 | { |
63 | switch_mm(prev, next, current); | 68 | switch_mm(prev, next, current); |
64 | set_fs(current->thread.mm_segment); | ||
65 | } | 69 | } |
66 | 70 | ||
67 | #endif /* __S390_MMU_CONTEXT_H */ | 71 | #endif /* __S390_MMU_CONTEXT_H */ |
diff --git a/include/asm-s390/page.h b/include/asm-s390/page.h index 7f29a981f48c..fe7f92b6ae6d 100644 --- a/include/asm-s390/page.h +++ b/include/asm-s390/page.h | |||
@@ -74,43 +74,17 @@ static inline void copy_page(void *to, void *from) | |||
74 | 74 | ||
75 | typedef struct { unsigned long pgprot; } pgprot_t; | 75 | typedef struct { unsigned long pgprot; } pgprot_t; |
76 | typedef struct { unsigned long pte; } pte_t; | 76 | typedef struct { unsigned long pte; } pte_t; |
77 | |||
78 | #define pte_val(x) ((x).pte) | ||
79 | #define pgprot_val(x) ((x).pgprot) | ||
80 | |||
81 | #ifndef __s390x__ | ||
82 | |||
83 | typedef struct { unsigned long pmd; } pmd_t; | 77 | typedef struct { unsigned long pmd; } pmd_t; |
84 | typedef struct { unsigned long pud; } pud_t; | 78 | typedef struct { unsigned long pud; } pud_t; |
85 | typedef struct { | ||
86 | unsigned long pgd0; | ||
87 | unsigned long pgd1; | ||
88 | unsigned long pgd2; | ||
89 | unsigned long pgd3; | ||
90 | } pgd_t; | ||
91 | |||
92 | #define pmd_val(x) ((x).pmd) | ||
93 | #define pud_val(x) ((x).pud) | ||
94 | #define pgd_val(x) ((x).pgd0) | ||
95 | |||
96 | #else /* __s390x__ */ | ||
97 | |||
98 | typedef struct { | ||
99 | unsigned long pmd0; | ||
100 | unsigned long pmd1; | ||
101 | } pmd_t; | ||
102 | typedef struct { unsigned long pud; } pud_t; | ||
103 | typedef struct { unsigned long pgd; } pgd_t; | 79 | typedef struct { unsigned long pgd; } pgd_t; |
80 | typedef pte_t *pgtable_t; | ||
104 | 81 | ||
105 | #define pmd_val(x) ((x).pmd0) | 82 | #define pgprot_val(x) ((x).pgprot) |
106 | #define pmd_val1(x) ((x).pmd1) | 83 | #define pte_val(x) ((x).pte) |
84 | #define pmd_val(x) ((x).pmd) | ||
107 | #define pud_val(x) ((x).pud) | 85 | #define pud_val(x) ((x).pud) |
108 | #define pgd_val(x) ((x).pgd) | 86 | #define pgd_val(x) ((x).pgd) |
109 | 87 | ||
110 | #endif /* __s390x__ */ | ||
111 | |||
112 | typedef struct page *pgtable_t; | ||
113 | |||
114 | #define __pte(x) ((pte_t) { (x) } ) | 88 | #define __pte(x) ((pte_t) { (x) } ) |
115 | #define __pmd(x) ((pmd_t) { (x) } ) | 89 | #define __pmd(x) ((pmd_t) { (x) } ) |
116 | #define __pgd(x) ((pgd_t) { (x) } ) | 90 | #define __pgd(x) ((pgd_t) { (x) } ) |
@@ -167,7 +141,7 @@ static inline int pfn_valid(unsigned long pfn) | |||
167 | #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) | 141 | #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) |
168 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) | 142 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) |
169 | 143 | ||
170 | #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ | 144 | #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \ |
171 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) | 145 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) |
172 | 146 | ||
173 | #include <asm-generic/memory_model.h> | 147 | #include <asm-generic/memory_model.h> |
diff --git a/include/asm-s390/pgalloc.h b/include/asm-s390/pgalloc.h index 900d44807e10..f5b2bf3d7c1d 100644 --- a/include/asm-s390/pgalloc.h +++ b/include/asm-s390/pgalloc.h | |||
@@ -20,10 +20,11 @@ | |||
20 | #define check_pgt_cache() do {} while (0) | 20 | #define check_pgt_cache() do {} while (0) |
21 | 21 | ||
22 | unsigned long *crst_table_alloc(struct mm_struct *, int); | 22 | unsigned long *crst_table_alloc(struct mm_struct *, int); |
23 | void crst_table_free(unsigned long *); | 23 | void crst_table_free(struct mm_struct *, unsigned long *); |
24 | 24 | ||
25 | unsigned long *page_table_alloc(int); | 25 | unsigned long *page_table_alloc(struct mm_struct *); |
26 | void page_table_free(unsigned long *); | 26 | void page_table_free(struct mm_struct *, unsigned long *); |
27 | void disable_noexec(struct mm_struct *, struct task_struct *); | ||
27 | 28 | ||
28 | static inline void clear_table(unsigned long *s, unsigned long val, size_t n) | 29 | static inline void clear_table(unsigned long *s, unsigned long val, size_t n) |
29 | { | 30 | { |
@@ -72,23 +73,49 @@ static inline unsigned long pgd_entry_type(struct mm_struct *mm) | |||
72 | 73 | ||
73 | static inline unsigned long pgd_entry_type(struct mm_struct *mm) | 74 | static inline unsigned long pgd_entry_type(struct mm_struct *mm) |
74 | { | 75 | { |
75 | return _REGION3_ENTRY_EMPTY; | 76 | if (mm->context.asce_limit <= (1UL << 31)) |
77 | return _SEGMENT_ENTRY_EMPTY; | ||
78 | if (mm->context.asce_limit <= (1UL << 42)) | ||
79 | return _REGION3_ENTRY_EMPTY; | ||
80 | return _REGION2_ENTRY_EMPTY; | ||
76 | } | 81 | } |
77 | 82 | ||
78 | #define pud_alloc_one(mm,address) ({ BUG(); ((pud_t *)2); }) | 83 | int crst_table_upgrade(struct mm_struct *, unsigned long limit); |
79 | #define pud_free(mm, x) do { } while (0) | 84 | void crst_table_downgrade(struct mm_struct *, unsigned long limit); |
85 | |||
86 | static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address) | ||
87 | { | ||
88 | unsigned long *table = crst_table_alloc(mm, mm->context.noexec); | ||
89 | if (table) | ||
90 | crst_table_init(table, _REGION3_ENTRY_EMPTY); | ||
91 | return (pud_t *) table; | ||
92 | } | ||
93 | #define pud_free(mm, pud) crst_table_free(mm, (unsigned long *) pud) | ||
80 | 94 | ||
81 | static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long vmaddr) | 95 | static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long vmaddr) |
82 | { | 96 | { |
83 | unsigned long *crst = crst_table_alloc(mm, s390_noexec); | 97 | unsigned long *table = crst_table_alloc(mm, mm->context.noexec); |
84 | if (crst) | 98 | if (table) |
85 | crst_table_init(crst, _SEGMENT_ENTRY_EMPTY); | 99 | crst_table_init(table, _SEGMENT_ENTRY_EMPTY); |
86 | return (pmd_t *) crst; | 100 | return (pmd_t *) table; |
87 | } | 101 | } |
88 | #define pmd_free(mm, pmd) crst_table_free((unsigned long *)pmd) | 102 | #define pmd_free(mm, pmd) crst_table_free(mm, (unsigned long *) pmd) |
89 | 103 | ||
90 | #define pgd_populate(mm, pgd, pud) BUG() | 104 | static inline void pgd_populate_kernel(struct mm_struct *mm, |
91 | #define pgd_populate_kernel(mm, pgd, pud) BUG() | 105 | pgd_t *pgd, pud_t *pud) |
106 | { | ||
107 | pgd_val(*pgd) = _REGION2_ENTRY | __pa(pud); | ||
108 | } | ||
109 | |||
110 | static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud) | ||
111 | { | ||
112 | pgd_populate_kernel(mm, pgd, pud); | ||
113 | if (mm->context.noexec) { | ||
114 | pgd = get_shadow_table(pgd); | ||
115 | pud = get_shadow_table(pud); | ||
116 | pgd_populate_kernel(mm, pgd, pud); | ||
117 | } | ||
118 | } | ||
92 | 119 | ||
93 | static inline void pud_populate_kernel(struct mm_struct *mm, | 120 | static inline void pud_populate_kernel(struct mm_struct *mm, |
94 | pud_t *pud, pmd_t *pmd) | 121 | pud_t *pud, pmd_t *pmd) |
@@ -98,63 +125,50 @@ static inline void pud_populate_kernel(struct mm_struct *mm, | |||
98 | 125 | ||
99 | static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) | 126 | static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) |
100 | { | 127 | { |
101 | pud_t *shadow_pud = get_shadow_table(pud); | ||
102 | pmd_t *shadow_pmd = get_shadow_table(pmd); | ||
103 | |||
104 | if (shadow_pud && shadow_pmd) | ||
105 | pud_populate_kernel(mm, shadow_pud, shadow_pmd); | ||
106 | pud_populate_kernel(mm, pud, pmd); | 128 | pud_populate_kernel(mm, pud, pmd); |
129 | if (mm->context.noexec) { | ||
130 | pud = get_shadow_table(pud); | ||
131 | pmd = get_shadow_table(pmd); | ||
132 | pud_populate_kernel(mm, pud, pmd); | ||
133 | } | ||
107 | } | 134 | } |
108 | 135 | ||
109 | #endif /* __s390x__ */ | 136 | #endif /* __s390x__ */ |
110 | 137 | ||
111 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) | 138 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) |
112 | { | 139 | { |
113 | unsigned long *crst = crst_table_alloc(mm, s390_noexec); | 140 | INIT_LIST_HEAD(&mm->context.crst_list); |
114 | if (crst) | 141 | INIT_LIST_HEAD(&mm->context.pgtable_list); |
115 | crst_table_init(crst, pgd_entry_type(mm)); | 142 | return (pgd_t *) crst_table_alloc(mm, s390_noexec); |
116 | return (pgd_t *) crst; | ||
117 | } | 143 | } |
118 | #define pgd_free(mm, pgd) crst_table_free((unsigned long *) pgd) | 144 | #define pgd_free(mm, pgd) crst_table_free(mm, (unsigned long *) pgd) |
119 | 145 | ||
120 | static inline void | 146 | static inline void pmd_populate_kernel(struct mm_struct *mm, |
121 | pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte) | 147 | pmd_t *pmd, pte_t *pte) |
122 | { | 148 | { |
123 | #ifndef __s390x__ | ||
124 | pmd_val(pmd[0]) = _SEGMENT_ENTRY + __pa(pte); | ||
125 | pmd_val(pmd[1]) = _SEGMENT_ENTRY + __pa(pte+256); | ||
126 | pmd_val(pmd[2]) = _SEGMENT_ENTRY + __pa(pte+512); | ||
127 | pmd_val(pmd[3]) = _SEGMENT_ENTRY + __pa(pte+768); | ||
128 | #else /* __s390x__ */ | ||
129 | pmd_val(*pmd) = _SEGMENT_ENTRY + __pa(pte); | 149 | pmd_val(*pmd) = _SEGMENT_ENTRY + __pa(pte); |
130 | pmd_val1(*pmd) = _SEGMENT_ENTRY + __pa(pte+256); | ||
131 | #endif /* __s390x__ */ | ||
132 | } | 150 | } |
133 | 151 | ||
134 | static inline void | 152 | static inline void pmd_populate(struct mm_struct *mm, |
135 | pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t page) | 153 | pmd_t *pmd, pgtable_t pte) |
136 | { | 154 | { |
137 | pte_t *pte = (pte_t *)page_to_phys(page); | ||
138 | pmd_t *shadow_pmd = get_shadow_table(pmd); | ||
139 | pte_t *shadow_pte = get_shadow_pte(pte); | ||
140 | |||
141 | pmd_populate_kernel(mm, pmd, pte); | 155 | pmd_populate_kernel(mm, pmd, pte); |
142 | if (shadow_pmd && shadow_pte) | 156 | if (mm->context.noexec) { |
143 | pmd_populate_kernel(mm, shadow_pmd, shadow_pte); | 157 | pmd = get_shadow_table(pmd); |
158 | pmd_populate_kernel(mm, pmd, pte + PTRS_PER_PTE); | ||
159 | } | ||
144 | } | 160 | } |
145 | #define pmd_pgtable(pmd) pmd_page(pmd) | 161 | |
162 | #define pmd_pgtable(pmd) \ | ||
163 | (pgtable_t)(pmd_val(pmd) & -sizeof(pte_t)*PTRS_PER_PTE) | ||
146 | 164 | ||
147 | /* | 165 | /* |
148 | * page table entry allocation/free routines. | 166 | * page table entry allocation/free routines. |
149 | */ | 167 | */ |
150 | #define pte_alloc_one_kernel(mm, vmaddr) \ | 168 | #define pte_alloc_one_kernel(mm, vmaddr) ((pte_t *) page_table_alloc(mm)) |
151 | ((pte_t *) page_table_alloc(s390_noexec)) | 169 | #define pte_alloc_one(mm, vmaddr) ((pte_t *) page_table_alloc(mm)) |
152 | #define pte_alloc_one(mm, vmaddr) \ | 170 | |
153 | virt_to_page(page_table_alloc(s390_noexec)) | 171 | #define pte_free_kernel(mm, pte) page_table_free(mm, (unsigned long *) pte) |
154 | 172 | #define pte_free(mm, pte) page_table_free(mm, (unsigned long *) pte) | |
155 | #define pte_free_kernel(mm, pte) \ | ||
156 | page_table_free((unsigned long *) pte) | ||
157 | #define pte_free(mm, pte) \ | ||
158 | page_table_free((unsigned long *) page_to_phys((struct page *) pte)) | ||
159 | 173 | ||
160 | #endif /* _S390_PGALLOC_H */ | 174 | #endif /* _S390_PGALLOC_H */ |
diff --git a/include/asm-s390/pgtable.h b/include/asm-s390/pgtable.h index 3f520754e71c..65154dc9a9e5 100644 --- a/include/asm-s390/pgtable.h +++ b/include/asm-s390/pgtable.h | |||
@@ -57,21 +57,21 @@ extern char empty_zero_page[PAGE_SIZE]; | |||
57 | * PGDIR_SHIFT determines what a third-level page table entry can map | 57 | * PGDIR_SHIFT determines what a third-level page table entry can map |
58 | */ | 58 | */ |
59 | #ifndef __s390x__ | 59 | #ifndef __s390x__ |
60 | # define PMD_SHIFT 22 | 60 | # define PMD_SHIFT 20 |
61 | # define PUD_SHIFT 22 | 61 | # define PUD_SHIFT 20 |
62 | # define PGDIR_SHIFT 22 | 62 | # define PGDIR_SHIFT 20 |
63 | #else /* __s390x__ */ | 63 | #else /* __s390x__ */ |
64 | # define PMD_SHIFT 21 | 64 | # define PMD_SHIFT 20 |
65 | # define PUD_SHIFT 31 | 65 | # define PUD_SHIFT 31 |
66 | # define PGDIR_SHIFT 31 | 66 | # define PGDIR_SHIFT 42 |
67 | #endif /* __s390x__ */ | 67 | #endif /* __s390x__ */ |
68 | 68 | ||
69 | #define PMD_SIZE (1UL << PMD_SHIFT) | 69 | #define PMD_SIZE (1UL << PMD_SHIFT) |
70 | #define PMD_MASK (~(PMD_SIZE-1)) | 70 | #define PMD_MASK (~(PMD_SIZE-1)) |
71 | #define PUD_SIZE (1UL << PUD_SHIFT) | 71 | #define PUD_SIZE (1UL << PUD_SHIFT) |
72 | #define PUD_MASK (~(PUD_SIZE-1)) | 72 | #define PUD_MASK (~(PUD_SIZE-1)) |
73 | #define PGDIR_SIZE (1UL << PGDIR_SHIFT) | 73 | #define PGDIR_SIZE (1UL << PGDIR_SHIFT) |
74 | #define PGDIR_MASK (~(PGDIR_SIZE-1)) | 74 | #define PGDIR_MASK (~(PGDIR_SIZE-1)) |
75 | 75 | ||
76 | /* | 76 | /* |
77 | * entries per page directory level: the S390 is two-level, so | 77 | * entries per page directory level: the S390 is two-level, so |
@@ -79,17 +79,15 @@ extern char empty_zero_page[PAGE_SIZE]; | |||
79 | * for S390 segment-table entries are combined to one PGD | 79 | * for S390 segment-table entries are combined to one PGD |
80 | * that leads to 1024 pte per pgd | 80 | * that leads to 1024 pte per pgd |
81 | */ | 81 | */ |
82 | #define PTRS_PER_PTE 256 | ||
82 | #ifndef __s390x__ | 83 | #ifndef __s390x__ |
83 | # define PTRS_PER_PTE 1024 | 84 | #define PTRS_PER_PMD 1 |
84 | # define PTRS_PER_PMD 1 | 85 | #define PTRS_PER_PUD 1 |
85 | # define PTRS_PER_PUD 1 | ||
86 | # define PTRS_PER_PGD 512 | ||
87 | #else /* __s390x__ */ | 86 | #else /* __s390x__ */ |
88 | # define PTRS_PER_PTE 512 | 87 | #define PTRS_PER_PMD 2048 |
89 | # define PTRS_PER_PMD 1024 | 88 | #define PTRS_PER_PUD 2048 |
90 | # define PTRS_PER_PUD 1 | ||
91 | # define PTRS_PER_PGD 2048 | ||
92 | #endif /* __s390x__ */ | 89 | #endif /* __s390x__ */ |
90 | #define PTRS_PER_PGD 2048 | ||
93 | 91 | ||
94 | #define FIRST_USER_ADDRESS 0 | 92 | #define FIRST_USER_ADDRESS 0 |
95 | 93 | ||
@@ -127,8 +125,9 @@ extern char empty_zero_page[PAGE_SIZE]; | |||
127 | * mapping. This needs to be calculated at compile time since the size of the | 125 | * mapping. This needs to be calculated at compile time since the size of the |
128 | * VMEM_MAP is static but the size of struct page can change. | 126 | * VMEM_MAP is static but the size of struct page can change. |
129 | */ | 127 | */ |
130 | #define VMEM_MAX_PHYS min(VMALLOC_START, ((VMEM_MAP_END - VMALLOC_END) / \ | 128 | #define VMEM_MAX_PAGES ((VMEM_MAP_END - VMALLOC_END) / sizeof(struct page)) |
131 | sizeof(struct page) * PAGE_SIZE) & ~((16 << 20) - 1)) | 129 | #define VMEM_MAX_PFN min(VMALLOC_START >> PAGE_SHIFT, VMEM_MAX_PAGES) |
130 | #define VMEM_MAX_PHYS ((VMEM_MAX_PFN << PAGE_SHIFT) & ~((16 << 20) - 1)) | ||
132 | #define VMEM_MAP ((struct page *) VMALLOC_END) | 131 | #define VMEM_MAP ((struct page *) VMALLOC_END) |
133 | 132 | ||
134 | /* | 133 | /* |
@@ -375,24 +374,6 @@ extern char empty_zero_page[PAGE_SIZE]; | |||
375 | # define PxD_SHADOW_SHIFT 2 | 374 | # define PxD_SHADOW_SHIFT 2 |
376 | #endif /* __s390x__ */ | 375 | #endif /* __s390x__ */ |
377 | 376 | ||
378 | static inline struct page *get_shadow_page(struct page *page) | ||
379 | { | ||
380 | if (s390_noexec && page->index) | ||
381 | return virt_to_page((void *)(addr_t) page->index); | ||
382 | return NULL; | ||
383 | } | ||
384 | |||
385 | static inline void *get_shadow_pte(void *table) | ||
386 | { | ||
387 | unsigned long addr, offset; | ||
388 | struct page *page; | ||
389 | |||
390 | addr = (unsigned long) table; | ||
391 | offset = addr & (PAGE_SIZE - 1); | ||
392 | page = virt_to_page((void *)(addr ^ offset)); | ||
393 | return (void *)(addr_t)(page->index ? (page->index | offset) : 0UL); | ||
394 | } | ||
395 | |||
396 | static inline void *get_shadow_table(void *table) | 377 | static inline void *get_shadow_table(void *table) |
397 | { | 378 | { |
398 | unsigned long addr, offset; | 379 | unsigned long addr, offset; |
@@ -410,17 +391,16 @@ static inline void *get_shadow_table(void *table) | |||
410 | * hook is made available. | 391 | * hook is made available. |
411 | */ | 392 | */ |
412 | static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, | 393 | static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, |
413 | pte_t *pteptr, pte_t pteval) | 394 | pte_t *ptep, pte_t entry) |
414 | { | 395 | { |
415 | pte_t *shadow_pte = get_shadow_pte(pteptr); | 396 | *ptep = entry; |
416 | 397 | if (mm->context.noexec) { | |
417 | *pteptr = pteval; | 398 | if (!(pte_val(entry) & _PAGE_INVALID) && |
418 | if (shadow_pte) { | 399 | (pte_val(entry) & _PAGE_SWX)) |
419 | if (!(pte_val(pteval) & _PAGE_INVALID) && | 400 | pte_val(entry) |= _PAGE_RO; |
420 | (pte_val(pteval) & _PAGE_SWX)) | ||
421 | pte_val(*shadow_pte) = pte_val(pteval) | _PAGE_RO; | ||
422 | else | 401 | else |
423 | pte_val(*shadow_pte) = _PAGE_TYPE_EMPTY; | 402 | pte_val(entry) = _PAGE_TYPE_EMPTY; |
403 | ptep[PTRS_PER_PTE] = entry; | ||
424 | } | 404 | } |
425 | } | 405 | } |
426 | 406 | ||
@@ -439,24 +419,58 @@ static inline int pud_bad(pud_t pud) { return 0; } | |||
439 | 419 | ||
440 | #else /* __s390x__ */ | 420 | #else /* __s390x__ */ |
441 | 421 | ||
442 | static inline int pgd_present(pgd_t pgd) { return 1; } | 422 | static inline int pgd_present(pgd_t pgd) |
443 | static inline int pgd_none(pgd_t pgd) { return 0; } | 423 | { |
444 | static inline int pgd_bad(pgd_t pgd) { return 0; } | 424 | if ((pgd_val(pgd) & _REGION_ENTRY_TYPE_MASK) < _REGION_ENTRY_TYPE_R2) |
425 | return 1; | ||
426 | return (pgd_val(pgd) & _REGION_ENTRY_ORIGIN) != 0UL; | ||
427 | } | ||
428 | |||
429 | static inline int pgd_none(pgd_t pgd) | ||
430 | { | ||
431 | if ((pgd_val(pgd) & _REGION_ENTRY_TYPE_MASK) < _REGION_ENTRY_TYPE_R2) | ||
432 | return 0; | ||
433 | return (pgd_val(pgd) & _REGION_ENTRY_INV) != 0UL; | ||
434 | } | ||
435 | |||
436 | static inline int pgd_bad(pgd_t pgd) | ||
437 | { | ||
438 | /* | ||
439 | * With dynamic page table levels the pgd can be a region table | ||
440 | * entry or a segment table entry. Check for the bit that are | ||
441 | * invalid for either table entry. | ||
442 | */ | ||
443 | unsigned long mask = | ||
444 | ~_SEGMENT_ENTRY_ORIGIN & ~_REGION_ENTRY_INV & | ||
445 | ~_REGION_ENTRY_TYPE_MASK & ~_REGION_ENTRY_LENGTH; | ||
446 | return (pgd_val(pgd) & mask) != 0; | ||
447 | } | ||
445 | 448 | ||
446 | static inline int pud_present(pud_t pud) | 449 | static inline int pud_present(pud_t pud) |
447 | { | 450 | { |
451 | if ((pud_val(pud) & _REGION_ENTRY_TYPE_MASK) < _REGION_ENTRY_TYPE_R3) | ||
452 | return 1; | ||
448 | return (pud_val(pud) & _REGION_ENTRY_ORIGIN) != 0UL; | 453 | return (pud_val(pud) & _REGION_ENTRY_ORIGIN) != 0UL; |
449 | } | 454 | } |
450 | 455 | ||
451 | static inline int pud_none(pud_t pud) | 456 | static inline int pud_none(pud_t pud) |
452 | { | 457 | { |
458 | if ((pud_val(pud) & _REGION_ENTRY_TYPE_MASK) < _REGION_ENTRY_TYPE_R3) | ||
459 | return 0; | ||
453 | return (pud_val(pud) & _REGION_ENTRY_INV) != 0UL; | 460 | return (pud_val(pud) & _REGION_ENTRY_INV) != 0UL; |
454 | } | 461 | } |
455 | 462 | ||
456 | static inline int pud_bad(pud_t pud) | 463 | static inline int pud_bad(pud_t pud) |
457 | { | 464 | { |
458 | unsigned long mask = ~_REGION_ENTRY_ORIGIN & ~_REGION_ENTRY_INV; | 465 | /* |
459 | return (pud_val(pud) & mask) != _REGION3_ENTRY; | 466 | * With dynamic page table levels the pud can be a region table |
467 | * entry or a segment table entry. Check for the bit that are | ||
468 | * invalid for either table entry. | ||
469 | */ | ||
470 | unsigned long mask = | ||
471 | ~_SEGMENT_ENTRY_ORIGIN & ~_REGION_ENTRY_INV & | ||
472 | ~_REGION_ENTRY_TYPE_MASK & ~_REGION_ENTRY_LENGTH; | ||
473 | return (pud_val(pud) & mask) != 0; | ||
460 | } | 474 | } |
461 | 475 | ||
462 | #endif /* __s390x__ */ | 476 | #endif /* __s390x__ */ |
@@ -535,24 +549,30 @@ static inline int pte_young(pte_t pte) | |||
535 | #define pgd_clear(pgd) do { } while (0) | 549 | #define pgd_clear(pgd) do { } while (0) |
536 | #define pud_clear(pud) do { } while (0) | 550 | #define pud_clear(pud) do { } while (0) |
537 | 551 | ||
538 | static inline void pmd_clear_kernel(pmd_t * pmdp) | 552 | #else /* __s390x__ */ |
553 | |||
554 | static inline void pgd_clear_kernel(pgd_t * pgd) | ||
539 | { | 555 | { |
540 | pmd_val(pmdp[0]) = _SEGMENT_ENTRY_EMPTY; | 556 | if ((pgd_val(*pgd) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R2) |
541 | pmd_val(pmdp[1]) = _SEGMENT_ENTRY_EMPTY; | 557 | pgd_val(*pgd) = _REGION2_ENTRY_EMPTY; |
542 | pmd_val(pmdp[2]) = _SEGMENT_ENTRY_EMPTY; | ||
543 | pmd_val(pmdp[3]) = _SEGMENT_ENTRY_EMPTY; | ||
544 | } | 558 | } |
545 | 559 | ||
546 | #else /* __s390x__ */ | 560 | static inline void pgd_clear(pgd_t * pgd) |
561 | { | ||
562 | pgd_t *shadow = get_shadow_table(pgd); | ||
547 | 563 | ||
548 | #define pgd_clear(pgd) do { } while (0) | 564 | pgd_clear_kernel(pgd); |
565 | if (shadow) | ||
566 | pgd_clear_kernel(shadow); | ||
567 | } | ||
549 | 568 | ||
550 | static inline void pud_clear_kernel(pud_t *pud) | 569 | static inline void pud_clear_kernel(pud_t *pud) |
551 | { | 570 | { |
552 | pud_val(*pud) = _REGION3_ENTRY_EMPTY; | 571 | if ((pud_val(*pud) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3) |
572 | pud_val(*pud) = _REGION3_ENTRY_EMPTY; | ||
553 | } | 573 | } |
554 | 574 | ||
555 | static inline void pud_clear(pud_t * pud) | 575 | static inline void pud_clear(pud_t *pud) |
556 | { | 576 | { |
557 | pud_t *shadow = get_shadow_table(pud); | 577 | pud_t *shadow = get_shadow_table(pud); |
558 | 578 | ||
@@ -561,30 +581,27 @@ static inline void pud_clear(pud_t * pud) | |||
561 | pud_clear_kernel(shadow); | 581 | pud_clear_kernel(shadow); |
562 | } | 582 | } |
563 | 583 | ||
584 | #endif /* __s390x__ */ | ||
585 | |||
564 | static inline void pmd_clear_kernel(pmd_t * pmdp) | 586 | static inline void pmd_clear_kernel(pmd_t * pmdp) |
565 | { | 587 | { |
566 | pmd_val(*pmdp) = _SEGMENT_ENTRY_EMPTY; | 588 | pmd_val(*pmdp) = _SEGMENT_ENTRY_EMPTY; |
567 | pmd_val1(*pmdp) = _SEGMENT_ENTRY_EMPTY; | ||
568 | } | 589 | } |
569 | 590 | ||
570 | #endif /* __s390x__ */ | 591 | static inline void pmd_clear(pmd_t *pmd) |
571 | |||
572 | static inline void pmd_clear(pmd_t * pmdp) | ||
573 | { | 592 | { |
574 | pmd_t *shadow_pmd = get_shadow_table(pmdp); | 593 | pmd_t *shadow = get_shadow_table(pmd); |
575 | 594 | ||
576 | pmd_clear_kernel(pmdp); | 595 | pmd_clear_kernel(pmd); |
577 | if (shadow_pmd) | 596 | if (shadow) |
578 | pmd_clear_kernel(shadow_pmd); | 597 | pmd_clear_kernel(shadow); |
579 | } | 598 | } |
580 | 599 | ||
581 | static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) | 600 | static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) |
582 | { | 601 | { |
583 | pte_t *shadow_pte = get_shadow_pte(ptep); | ||
584 | |||
585 | pte_val(*ptep) = _PAGE_TYPE_EMPTY; | 602 | pte_val(*ptep) = _PAGE_TYPE_EMPTY; |
586 | if (shadow_pte) | 603 | if (mm->context.noexec) |
587 | pte_val(*shadow_pte) = _PAGE_TYPE_EMPTY; | 604 | pte_val(ptep[PTRS_PER_PTE]) = _PAGE_TYPE_EMPTY; |
588 | } | 605 | } |
589 | 606 | ||
590 | /* | 607 | /* |
@@ -665,7 +682,7 @@ static inline void __ptep_ipte(unsigned long address, pte_t *ptep) | |||
665 | { | 682 | { |
666 | if (!(pte_val(*ptep) & _PAGE_INVALID)) { | 683 | if (!(pte_val(*ptep) & _PAGE_INVALID)) { |
667 | #ifndef __s390x__ | 684 | #ifndef __s390x__ |
668 | /* S390 has 1mb segments, we are emulating 4MB segments */ | 685 | /* pto must point to the start of the segment table */ |
669 | pte_t *pto = (pte_t *) (((unsigned long) ptep) & 0x7ffffc00); | 686 | pte_t *pto = (pte_t *) (((unsigned long) ptep) & 0x7ffffc00); |
670 | #else | 687 | #else |
671 | /* ipte in zarch mode can do the math */ | 688 | /* ipte in zarch mode can do the math */ |
@@ -679,12 +696,12 @@ static inline void __ptep_ipte(unsigned long address, pte_t *ptep) | |||
679 | pte_val(*ptep) = _PAGE_TYPE_EMPTY; | 696 | pte_val(*ptep) = _PAGE_TYPE_EMPTY; |
680 | } | 697 | } |
681 | 698 | ||
682 | static inline void ptep_invalidate(unsigned long address, pte_t *ptep) | 699 | static inline void ptep_invalidate(struct mm_struct *mm, |
700 | unsigned long address, pte_t *ptep) | ||
683 | { | 701 | { |
684 | __ptep_ipte(address, ptep); | 702 | __ptep_ipte(address, ptep); |
685 | ptep = get_shadow_pte(ptep); | 703 | if (mm->context.noexec) |
686 | if (ptep) | 704 | __ptep_ipte(address, ptep + PTRS_PER_PTE); |
687 | __ptep_ipte(address, ptep); | ||
688 | } | 705 | } |
689 | 706 | ||
690 | /* | 707 | /* |
@@ -706,7 +723,7 @@ static inline void ptep_invalidate(unsigned long address, pte_t *ptep) | |||
706 | pte_t __pte = *(__ptep); \ | 723 | pte_t __pte = *(__ptep); \ |
707 | if (atomic_read(&(__mm)->mm_users) > 1 || \ | 724 | if (atomic_read(&(__mm)->mm_users) > 1 || \ |
708 | (__mm) != current->active_mm) \ | 725 | (__mm) != current->active_mm) \ |
709 | ptep_invalidate(__address, __ptep); \ | 726 | ptep_invalidate(__mm, __address, __ptep); \ |
710 | else \ | 727 | else \ |
711 | pte_clear((__mm), (__address), (__ptep)); \ | 728 | pte_clear((__mm), (__address), (__ptep)); \ |
712 | __pte; \ | 729 | __pte; \ |
@@ -717,7 +734,7 @@ static inline pte_t ptep_clear_flush(struct vm_area_struct *vma, | |||
717 | unsigned long address, pte_t *ptep) | 734 | unsigned long address, pte_t *ptep) |
718 | { | 735 | { |
719 | pte_t pte = *ptep; | 736 | pte_t pte = *ptep; |
720 | ptep_invalidate(address, ptep); | 737 | ptep_invalidate(vma->vm_mm, address, ptep); |
721 | return pte; | 738 | return pte; |
722 | } | 739 | } |
723 | 740 | ||
@@ -738,7 +755,7 @@ static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, | |||
738 | if (full) | 755 | if (full) |
739 | pte_clear(mm, addr, ptep); | 756 | pte_clear(mm, addr, ptep); |
740 | else | 757 | else |
741 | ptep_invalidate(addr, ptep); | 758 | ptep_invalidate(mm, addr, ptep); |
742 | return pte; | 759 | return pte; |
743 | } | 760 | } |
744 | 761 | ||
@@ -749,7 +766,7 @@ static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, | |||
749 | if (pte_write(__pte)) { \ | 766 | if (pte_write(__pte)) { \ |
750 | if (atomic_read(&(__mm)->mm_users) > 1 || \ | 767 | if (atomic_read(&(__mm)->mm_users) > 1 || \ |
751 | (__mm) != current->active_mm) \ | 768 | (__mm) != current->active_mm) \ |
752 | ptep_invalidate(__addr, __ptep); \ | 769 | ptep_invalidate(__mm, __addr, __ptep); \ |
753 | set_pte_at(__mm, __addr, __ptep, pte_wrprotect(__pte)); \ | 770 | set_pte_at(__mm, __addr, __ptep, pte_wrprotect(__pte)); \ |
754 | } \ | 771 | } \ |
755 | }) | 772 | }) |
@@ -759,7 +776,7 @@ static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, | |||
759 | ({ \ | 776 | ({ \ |
760 | int __changed = !pte_same(*(__ptep), __entry); \ | 777 | int __changed = !pte_same(*(__ptep), __entry); \ |
761 | if (__changed) { \ | 778 | if (__changed) { \ |
762 | ptep_invalidate(__addr, __ptep); \ | 779 | ptep_invalidate((__vma)->vm_mm, __addr, __ptep); \ |
763 | set_pte_at((__vma)->vm_mm, __addr, __ptep, __entry); \ | 780 | set_pte_at((__vma)->vm_mm, __addr, __ptep, __entry); \ |
764 | } \ | 781 | } \ |
765 | __changed; \ | 782 | __changed; \ |
@@ -840,13 +857,21 @@ static inline pte_t mk_pte(struct page *page, pgprot_t pgprot) | |||
840 | 857 | ||
841 | #define pmd_deref(pmd) (pmd_val(pmd) & _SEGMENT_ENTRY_ORIGIN) | 858 | #define pmd_deref(pmd) (pmd_val(pmd) & _SEGMENT_ENTRY_ORIGIN) |
842 | #define pud_deref(pud) (pud_val(pud) & _REGION_ENTRY_ORIGIN) | 859 | #define pud_deref(pud) (pud_val(pud) & _REGION_ENTRY_ORIGIN) |
843 | #define pgd_deref(pgd) ({ BUG(); 0UL; }) | 860 | #define pgd_deref(pgd) (pgd_val(pgd) & _REGION_ENTRY_ORIGIN) |
844 | 861 | ||
845 | #define pud_offset(pgd, address) ((pud_t *) pgd) | 862 | static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address) |
863 | { | ||
864 | pud_t *pud = (pud_t *) pgd; | ||
865 | if ((pgd_val(*pgd) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R2) | ||
866 | pud = (pud_t *) pgd_deref(*pgd); | ||
867 | return pud + pud_index(address); | ||
868 | } | ||
846 | 869 | ||
847 | static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address) | 870 | static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address) |
848 | { | 871 | { |
849 | pmd_t *pmd = (pmd_t *) pud_deref(*pud); | 872 | pmd_t *pmd = (pmd_t *) pud; |
873 | if ((pud_val(*pud) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3) | ||
874 | pmd = (pmd_t *) pud_deref(*pud); | ||
850 | return pmd + pmd_index(address); | 875 | return pmd + pmd_index(address); |
851 | } | 876 | } |
852 | 877 | ||
diff --git a/include/asm-s390/processor.h b/include/asm-s390/processor.h index e8785634cbdb..51d88912aa20 100644 --- a/include/asm-s390/processor.h +++ b/include/asm-s390/processor.h | |||
@@ -64,24 +64,29 @@ extern int get_cpu_capability(unsigned int *); | |||
64 | */ | 64 | */ |
65 | #ifndef __s390x__ | 65 | #ifndef __s390x__ |
66 | 66 | ||
67 | # define TASK_SIZE (0x80000000UL) | 67 | #define TASK_SIZE (1UL << 31) |
68 | # define TASK_UNMAPPED_BASE (TASK_SIZE / 2) | 68 | #define TASK_UNMAPPED_BASE (1UL << 30) |
69 | # define DEFAULT_TASK_SIZE (0x80000000UL) | ||
70 | 69 | ||
71 | #else /* __s390x__ */ | 70 | #else /* __s390x__ */ |
72 | 71 | ||
73 | # define TASK_SIZE_OF(tsk) (test_tsk_thread_flag(tsk, TIF_31BIT) ? \ | 72 | #define TASK_SIZE_OF(tsk) (test_tsk_thread_flag(tsk,TIF_31BIT) ? \ |
74 | (0x80000000UL) : (0x40000000000UL)) | 73 | (1UL << 31) : (1UL << 53)) |
75 | # define TASK_SIZE TASK_SIZE_OF(current) | 74 | #define TASK_UNMAPPED_BASE (test_thread_flag(TIF_31BIT) ? \ |
76 | # define TASK_UNMAPPED_BASE (TASK_SIZE / 2) | 75 | (1UL << 30) : (1UL << 41)) |
77 | # define DEFAULT_TASK_SIZE (0x40000000000UL) | 76 | #define TASK_SIZE TASK_SIZE_OF(current) |
78 | 77 | ||
79 | #endif /* __s390x__ */ | 78 | #endif /* __s390x__ */ |
80 | 79 | ||
81 | #ifdef __KERNEL__ | 80 | #ifdef __KERNEL__ |
82 | 81 | ||
83 | #define STACK_TOP TASK_SIZE | 82 | #ifndef __s390x__ |
84 | #define STACK_TOP_MAX DEFAULT_TASK_SIZE | 83 | #define STACK_TOP (1UL << 31) |
84 | #define STACK_TOP_MAX (1UL << 31) | ||
85 | #else /* __s390x__ */ | ||
86 | #define STACK_TOP (1UL << (test_thread_flag(TIF_31BIT) ? 31:42)) | ||
87 | #define STACK_TOP_MAX (1UL << 42) | ||
88 | #endif /* __s390x__ */ | ||
89 | |||
85 | 90 | ||
86 | #endif | 91 | #endif |
87 | 92 | ||
@@ -138,8 +143,6 @@ struct stack_frame { | |||
138 | /* | 143 | /* |
139 | * Do necessary setup to start up a new thread. | 144 | * Do necessary setup to start up a new thread. |
140 | */ | 145 | */ |
141 | #ifndef __s390x__ | ||
142 | |||
143 | #define start_thread(regs, new_psw, new_stackp) do { \ | 146 | #define start_thread(regs, new_psw, new_stackp) do { \ |
144 | set_fs(USER_DS); \ | 147 | set_fs(USER_DS); \ |
145 | regs->psw.mask = psw_user_bits; \ | 148 | regs->psw.mask = psw_user_bits; \ |
@@ -147,24 +150,6 @@ struct stack_frame { | |||
147 | regs->gprs[15] = new_stackp ; \ | 150 | regs->gprs[15] = new_stackp ; \ |
148 | } while (0) | 151 | } while (0) |
149 | 152 | ||
150 | #else /* __s390x__ */ | ||
151 | |||
152 | #define start_thread(regs, new_psw, new_stackp) do { \ | ||
153 | set_fs(USER_DS); \ | ||
154 | regs->psw.mask = psw_user_bits; \ | ||
155 | regs->psw.addr = new_psw; \ | ||
156 | regs->gprs[15] = new_stackp; \ | ||
157 | } while (0) | ||
158 | |||
159 | #define start_thread31(regs, new_psw, new_stackp) do { \ | ||
160 | set_fs(USER_DS); \ | ||
161 | regs->psw.mask = psw_user32_bits; \ | ||
162 | regs->psw.addr = new_psw; \ | ||
163 | regs->gprs[15] = new_stackp; \ | ||
164 | } while (0) | ||
165 | |||
166 | #endif /* __s390x__ */ | ||
167 | |||
168 | /* Forward declaration, a strange C thing */ | 153 | /* Forward declaration, a strange C thing */ |
169 | struct task_struct; | 154 | struct task_struct; |
170 | struct mm_struct; | 155 | struct mm_struct; |
diff --git a/include/asm-s390/tlb.h b/include/asm-s390/tlb.h index 3c8177fa9e06..3d8a96d39d9d 100644 --- a/include/asm-s390/tlb.h +++ b/include/asm-s390/tlb.h | |||
@@ -38,7 +38,7 @@ struct mmu_gather { | |||
38 | struct mm_struct *mm; | 38 | struct mm_struct *mm; |
39 | unsigned int fullmm; | 39 | unsigned int fullmm; |
40 | unsigned int nr_ptes; | 40 | unsigned int nr_ptes; |
41 | unsigned int nr_pmds; | 41 | unsigned int nr_pxds; |
42 | void *array[TLB_NR_PTRS]; | 42 | void *array[TLB_NR_PTRS]; |
43 | }; | 43 | }; |
44 | 44 | ||
@@ -53,7 +53,7 @@ static inline struct mmu_gather *tlb_gather_mmu(struct mm_struct *mm, | |||
53 | tlb->fullmm = full_mm_flush || (num_online_cpus() == 1) || | 53 | tlb->fullmm = full_mm_flush || (num_online_cpus() == 1) || |
54 | (atomic_read(&mm->mm_users) <= 1 && mm == current->active_mm); | 54 | (atomic_read(&mm->mm_users) <= 1 && mm == current->active_mm); |
55 | tlb->nr_ptes = 0; | 55 | tlb->nr_ptes = 0; |
56 | tlb->nr_pmds = TLB_NR_PTRS; | 56 | tlb->nr_pxds = TLB_NR_PTRS; |
57 | if (tlb->fullmm) | 57 | if (tlb->fullmm) |
58 | __tlb_flush_mm(mm); | 58 | __tlb_flush_mm(mm); |
59 | return tlb; | 59 | return tlb; |
@@ -62,12 +62,13 @@ static inline struct mmu_gather *tlb_gather_mmu(struct mm_struct *mm, | |||
62 | static inline void tlb_flush_mmu(struct mmu_gather *tlb, | 62 | static inline void tlb_flush_mmu(struct mmu_gather *tlb, |
63 | unsigned long start, unsigned long end) | 63 | unsigned long start, unsigned long end) |
64 | { | 64 | { |
65 | if (!tlb->fullmm && (tlb->nr_ptes > 0 || tlb->nr_pmds < TLB_NR_PTRS)) | 65 | if (!tlb->fullmm && (tlb->nr_ptes > 0 || tlb->nr_pxds < TLB_NR_PTRS)) |
66 | __tlb_flush_mm(tlb->mm); | 66 | __tlb_flush_mm(tlb->mm); |
67 | while (tlb->nr_ptes > 0) | 67 | while (tlb->nr_ptes > 0) |
68 | pte_free(tlb->mm, tlb->array[--tlb->nr_ptes]); | 68 | pte_free(tlb->mm, tlb->array[--tlb->nr_ptes]); |
69 | while (tlb->nr_pmds < TLB_NR_PTRS) | 69 | while (tlb->nr_pxds < TLB_NR_PTRS) |
70 | pmd_free(tlb->mm, (pmd_t *) tlb->array[tlb->nr_pmds++]); | 70 | /* pgd_free frees the pointer as region or segment table */ |
71 | pgd_free(tlb->mm, tlb->array[tlb->nr_pxds++]); | ||
71 | } | 72 | } |
72 | 73 | ||
73 | static inline void tlb_finish_mmu(struct mmu_gather *tlb, | 74 | static inline void tlb_finish_mmu(struct mmu_gather *tlb, |
@@ -95,33 +96,57 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page) | |||
95 | * pte_free_tlb frees a pte table and clears the CRSTE for the | 96 | * pte_free_tlb frees a pte table and clears the CRSTE for the |
96 | * page table from the tlb. | 97 | * page table from the tlb. |
97 | */ | 98 | */ |
98 | static inline void pte_free_tlb(struct mmu_gather *tlb, pgtable_t page) | 99 | static inline void pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte) |
99 | { | 100 | { |
100 | if (!tlb->fullmm) { | 101 | if (!tlb->fullmm) { |
101 | tlb->array[tlb->nr_ptes++] = page; | 102 | tlb->array[tlb->nr_ptes++] = pte; |
102 | if (tlb->nr_ptes >= tlb->nr_pmds) | 103 | if (tlb->nr_ptes >= tlb->nr_pxds) |
103 | tlb_flush_mmu(tlb, 0, 0); | 104 | tlb_flush_mmu(tlb, 0, 0); |
104 | } else | 105 | } else |
105 | pte_free(tlb->mm, page); | 106 | pte_free(tlb->mm, pte); |
106 | } | 107 | } |
107 | 108 | ||
108 | /* | 109 | /* |
109 | * pmd_free_tlb frees a pmd table and clears the CRSTE for the | 110 | * pmd_free_tlb frees a pmd table and clears the CRSTE for the |
110 | * segment table entry from the tlb. | 111 | * segment table entry from the tlb. |
112 | * If the mm uses a two level page table the single pmd is freed | ||
113 | * as the pgd. pmd_free_tlb checks the asce_limit against 2GB | ||
114 | * to avoid the double free of the pmd in this case. | ||
111 | */ | 115 | */ |
112 | static inline void pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd) | 116 | static inline void pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd) |
113 | { | 117 | { |
114 | #ifdef __s390x__ | 118 | #ifdef __s390x__ |
119 | if (tlb->mm->context.asce_limit <= (1UL << 31)) | ||
120 | return; | ||
115 | if (!tlb->fullmm) { | 121 | if (!tlb->fullmm) { |
116 | tlb->array[--tlb->nr_pmds] = (struct page *) pmd; | 122 | tlb->array[--tlb->nr_pxds] = pmd; |
117 | if (tlb->nr_ptes >= tlb->nr_pmds) | 123 | if (tlb->nr_ptes >= tlb->nr_pxds) |
118 | tlb_flush_mmu(tlb, 0, 0); | 124 | tlb_flush_mmu(tlb, 0, 0); |
119 | } else | 125 | } else |
120 | pmd_free(tlb->mm, pmd); | 126 | pmd_free(tlb->mm, pmd); |
121 | #endif | 127 | #endif |
122 | } | 128 | } |
123 | 129 | ||
124 | #define pud_free_tlb(tlb, pud) do { } while (0) | 130 | /* |
131 | * pud_free_tlb frees a pud table and clears the CRSTE for the | ||
132 | * region third table entry from the tlb. | ||
133 | * If the mm uses a three level page table the single pud is freed | ||
134 | * as the pgd. pud_free_tlb checks the asce_limit against 4TB | ||
135 | * to avoid the double free of the pud in this case. | ||
136 | */ | ||
137 | static inline void pud_free_tlb(struct mmu_gather *tlb, pud_t *pud) | ||
138 | { | ||
139 | #ifdef __s390x__ | ||
140 | if (tlb->mm->context.asce_limit <= (1UL << 42)) | ||
141 | return; | ||
142 | if (!tlb->fullmm) { | ||
143 | tlb->array[--tlb->nr_pxds] = pud; | ||
144 | if (tlb->nr_ptes >= tlb->nr_pxds) | ||
145 | tlb_flush_mmu(tlb, 0, 0); | ||
146 | } else | ||
147 | pud_free(tlb->mm, pud); | ||
148 | #endif | ||
149 | } | ||
125 | 150 | ||
126 | #define tlb_start_vma(tlb, vma) do { } while (0) | 151 | #define tlb_start_vma(tlb, vma) do { } while (0) |
127 | #define tlb_end_vma(tlb, vma) do { } while (0) | 152 | #define tlb_end_vma(tlb, vma) do { } while (0) |
diff --git a/include/asm-s390/tlbflush.h b/include/asm-s390/tlbflush.h index 70fa5ae58180..35fb4f9127b2 100644 --- a/include/asm-s390/tlbflush.h +++ b/include/asm-s390/tlbflush.h | |||
@@ -61,11 +61,12 @@ static inline void __tlb_flush_mm(struct mm_struct * mm) | |||
61 | * only ran on the local cpu. | 61 | * only ran on the local cpu. |
62 | */ | 62 | */ |
63 | if (MACHINE_HAS_IDTE) { | 63 | if (MACHINE_HAS_IDTE) { |
64 | pgd_t *shadow = get_shadow_table(mm->pgd); | 64 | if (mm->context.noexec) |
65 | 65 | __tlb_flush_idte((unsigned long) | |
66 | if (shadow) | 66 | get_shadow_table(mm->pgd) | |
67 | __tlb_flush_idte((unsigned long) shadow | mm->context); | 67 | mm->context.asce_bits); |
68 | __tlb_flush_idte((unsigned long) mm->pgd | mm->context); | 68 | __tlb_flush_idte((unsigned long) mm->pgd | |
69 | mm->context.asce_bits); | ||
69 | return; | 70 | return; |
70 | } | 71 | } |
71 | preempt_disable(); | 72 | preempt_disable(); |
diff --git a/include/asm-s390/unistd.h b/include/asm-s390/unistd.h index f04acb2670a8..583da807ea97 100644 --- a/include/asm-s390/unistd.h +++ b/include/asm-s390/unistd.h | |||
@@ -256,7 +256,10 @@ | |||
256 | #define __NR_signalfd 316 | 256 | #define __NR_signalfd 316 |
257 | #define __NR_timerfd 317 | 257 | #define __NR_timerfd 317 |
258 | #define __NR_eventfd 318 | 258 | #define __NR_eventfd 318 |
259 | #define NR_syscalls 319 | 259 | #define __NR_timerfd_create 319 |
260 | #define __NR_timerfd_settime 320 | ||
261 | #define __NR_timerfd_gettime 321 | ||
262 | #define NR_syscalls 322 | ||
260 | 263 | ||
261 | /* | 264 | /* |
262 | * There are some system calls that are not present on 64 bit, some | 265 | * There are some system calls that are not present on 64 bit, some |
diff --git a/include/asm-v850/page.h b/include/asm-v850/page.h index 661d8cd08839..74a539a9bd59 100644 --- a/include/asm-v850/page.h +++ b/include/asm-v850/page.h | |||
@@ -57,6 +57,7 @@ typedef struct { unsigned long pte; } pte_t; | |||
57 | typedef struct { unsigned long pmd; } pmd_t; | 57 | typedef struct { unsigned long pmd; } pmd_t; |
58 | typedef struct { unsigned long pgd; } pgd_t; | 58 | typedef struct { unsigned long pgd; } pgd_t; |
59 | typedef struct { unsigned long pgprot; } pgprot_t; | 59 | typedef struct { unsigned long pgprot; } pgprot_t; |
60 | typedef struct page *pgtable_t; | ||
60 | 61 | ||
61 | #define pte_val(x) ((x).pte) | 62 | #define pte_val(x) ((x).pte) |
62 | #define pmd_val(x) ((x).pmd) | 63 | #define pmd_val(x) ((x).pmd) |
diff --git a/include/linux/ext4_fs.h b/include/linux/ext4_fs.h index c4f635a4dd25..250032548597 100644 --- a/include/linux/ext4_fs.h +++ b/include/linux/ext4_fs.h | |||
@@ -490,6 +490,13 @@ do { \ | |||
490 | #define EXT4_ORPHAN_FS 0x0004 /* Orphans being recovered */ | 490 | #define EXT4_ORPHAN_FS 0x0004 /* Orphans being recovered */ |
491 | 491 | ||
492 | /* | 492 | /* |
493 | * Misc. filesystem flags | ||
494 | */ | ||
495 | #define EXT2_FLAGS_SIGNED_HASH 0x0001 /* Signed dirhash in use */ | ||
496 | #define EXT2_FLAGS_UNSIGNED_HASH 0x0002 /* Unsigned dirhash in use */ | ||
497 | #define EXT2_FLAGS_TEST_FILESYS 0x0004 /* to test development code */ | ||
498 | |||
499 | /* | ||
493 | * Mount flags | 500 | * Mount flags |
494 | */ | 501 | */ |
495 | #define EXT4_MOUNT_CHECK 0x00001 /* Do mount-time checks */ | 502 | #define EXT4_MOUNT_CHECK 0x00001 /* Do mount-time checks */ |
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 9815951ec995..925d57b236aa 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -51,10 +51,8 @@ extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm, | |||
51 | gfp_t gfp_mask); | 51 | gfp_t gfp_mask); |
52 | int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem); | 52 | int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem); |
53 | 53 | ||
54 | static inline struct mem_cgroup *mm_cgroup(const struct mm_struct *mm) | 54 | #define vm_match_cgroup(mm, cgroup) \ |
55 | { | 55 | ((cgroup) == rcu_dereference((mm)->mem_cgroup)) |
56 | return rcu_dereference(mm->mem_cgroup); | ||
57 | } | ||
58 | 56 | ||
59 | extern int mem_cgroup_prepare_migration(struct page *page); | 57 | extern int mem_cgroup_prepare_migration(struct page *page); |
60 | extern void mem_cgroup_end_migration(struct page *page); | 58 | extern void mem_cgroup_end_migration(struct page *page); |
@@ -123,9 +121,9 @@ static inline int mem_cgroup_cache_charge(struct page *page, | |||
123 | return 0; | 121 | return 0; |
124 | } | 122 | } |
125 | 123 | ||
126 | static inline struct mem_cgroup *mm_cgroup(const struct mm_struct *mm) | 124 | static inline int vm_match_cgroup(struct mm_struct *mm, struct mem_cgroup *mem) |
127 | { | 125 | { |
128 | return NULL; | 126 | return 1; |
129 | } | 127 | } |
130 | 128 | ||
131 | static inline int task_in_mem_cgroup(struct task_struct *task, | 129 | static inline int task_in_mem_cgroup(struct task_struct *task, |
diff --git a/include/linux/memstick.h b/include/linux/memstick.h new file mode 100644 index 000000000000..334d059d6794 --- /dev/null +++ b/include/linux/memstick.h | |||
@@ -0,0 +1,299 @@ | |||
1 | /* | ||
2 | * Sony MemoryStick support | ||
3 | * | ||
4 | * Copyright (C) 2007 Alex Dubov <oakad@yahoo.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | #ifndef _MEMSTICK_H | ||
13 | #define _MEMSTICK_H | ||
14 | |||
15 | #include <linux/workqueue.h> | ||
16 | #include <linux/scatterlist.h> | ||
17 | #include <linux/device.h> | ||
18 | |||
19 | /*** Hardware based structures ***/ | ||
20 | |||
21 | struct ms_status_register { | ||
22 | unsigned char reserved; | ||
23 | unsigned char interrupt; | ||
24 | #define MEMSTICK_INT_CMDNAK 0x0001 | ||
25 | #define MEMSTICK_INT_BREQ 0x0020 | ||
26 | #define MEMSTICK_INT_ERR 0x0040 | ||
27 | #define MEMSTICK_INT_CED 0x0080 | ||
28 | |||
29 | unsigned char status0; | ||
30 | #define MEMSTICK_STATUS0_WP 0x0001 | ||
31 | #define MEMSTICK_STATUS0_SL 0x0002 | ||
32 | #define MEMSTICK_STATUS0_BF 0x0010 | ||
33 | #define MEMSTICK_STATUS0_BE 0x0020 | ||
34 | #define MEMSTICK_STATUS0_FB0 0x0040 | ||
35 | #define MEMSTICK_STATUS0_MB 0x0080 | ||
36 | |||
37 | unsigned char status1; | ||
38 | #define MEMSTICK_STATUS1_UCFG 0x0001 | ||
39 | #define MEMSTICK_STATUS1_FGER 0x0002 | ||
40 | #define MEMSTICK_STATUS1_UCEX 0x0004 | ||
41 | #define MEMSTICK_STATUS1_EXER 0x0008 | ||
42 | #define MEMSTICK_STATUS1_UCDT 0x0010 | ||
43 | #define MEMSTICK_STATUS1_DTER 0x0020 | ||
44 | #define MEMSTICK_STATUS1_FBI 0x0040 | ||
45 | #define MEMSTICK_STATUS1_MB 0x0080 | ||
46 | } __attribute__((packed)); | ||
47 | |||
48 | struct ms_id_register { | ||
49 | unsigned char type; | ||
50 | unsigned char reserved; | ||
51 | unsigned char category; | ||
52 | unsigned char class; | ||
53 | } __attribute__((packed)); | ||
54 | |||
55 | struct ms_param_register { | ||
56 | unsigned char system; | ||
57 | unsigned char block_address_msb; | ||
58 | unsigned short block_address; | ||
59 | unsigned char cp; | ||
60 | #define MEMSTICK_CP_BLOCK 0x0000 | ||
61 | #define MEMSTICK_CP_PAGE 0x0020 | ||
62 | #define MEMSTICK_CP_EXTRA 0x0040 | ||
63 | #define MEMSTICK_CP_OVERWRITE 0x0080 | ||
64 | |||
65 | unsigned char page_address; | ||
66 | } __attribute__((packed)); | ||
67 | |||
68 | struct ms_extra_data_register { | ||
69 | unsigned char overwrite_flag; | ||
70 | #define MEMSTICK_OVERWRITE_UPDATA 0x0010 | ||
71 | #define MEMSTICK_OVERWRITE_PAGE 0x0060 | ||
72 | #define MEMSTICK_OVERWRITE_BLOCK 0x0080 | ||
73 | |||
74 | unsigned char management_flag; | ||
75 | #define MEMSTICK_MANAGEMENT_SYSTEM 0x0004 | ||
76 | #define MEMSTICK_MANAGEMENT_TRANS_TABLE 0x0008 | ||
77 | #define MEMSTICK_MANAGEMENT_COPY 0x0010 | ||
78 | #define MEMSTICK_MANAGEMENT_ACCESS 0x0020 | ||
79 | |||
80 | unsigned short logical_address; | ||
81 | } __attribute__((packed)); | ||
82 | |||
83 | struct ms_register { | ||
84 | struct ms_status_register status; | ||
85 | struct ms_id_register id; | ||
86 | unsigned char reserved[8]; | ||
87 | struct ms_param_register param; | ||
88 | struct ms_extra_data_register extra_data; | ||
89 | } __attribute__((packed)); | ||
90 | |||
91 | struct mspro_param_register { | ||
92 | unsigned char system; | ||
93 | unsigned short data_count; | ||
94 | unsigned int data_address; | ||
95 | unsigned char cmd_param; | ||
96 | } __attribute__((packed)); | ||
97 | |||
98 | struct mspro_register { | ||
99 | struct ms_status_register status; | ||
100 | struct ms_id_register id; | ||
101 | unsigned char reserved[8]; | ||
102 | struct mspro_param_register param; | ||
103 | } __attribute__((packed)); | ||
104 | |||
105 | struct ms_register_addr { | ||
106 | unsigned char r_offset; | ||
107 | unsigned char r_length; | ||
108 | unsigned char w_offset; | ||
109 | unsigned char w_length; | ||
110 | } __attribute__((packed)); | ||
111 | |||
112 | enum { | ||
113 | MS_TPC_READ_LONG_DATA = 0x02, | ||
114 | MS_TPC_READ_SHORT_DATA = 0x03, | ||
115 | MS_TPC_READ_REG = 0x04, | ||
116 | MS_TPC_READ_IO_DATA = 0x05, /* unverified */ | ||
117 | MS_TPC_GET_INT = 0x07, | ||
118 | MS_TPC_SET_RW_REG_ADRS = 0x08, | ||
119 | MS_TPC_EX_SET_CMD = 0x09, | ||
120 | MS_TPC_WRITE_IO_DATA = 0x0a, /* unverified */ | ||
121 | MS_TPC_WRITE_REG = 0x0b, | ||
122 | MS_TPC_WRITE_SHORT_DATA = 0x0c, | ||
123 | MS_TPC_WRITE_LONG_DATA = 0x0d, | ||
124 | MS_TPC_SET_CMD = 0x0e | ||
125 | }; | ||
126 | |||
127 | enum { | ||
128 | MS_CMD_BLOCK_END = 0x33, | ||
129 | MS_CMD_RESET = 0x3c, | ||
130 | MS_CMD_BLOCK_WRITE = 0x55, | ||
131 | MS_CMD_SLEEP = 0x5a, | ||
132 | MS_CMD_BLOCK_ERASE = 0x99, | ||
133 | MS_CMD_BLOCK_READ = 0xaa, | ||
134 | MS_CMD_CLEAR_BUF = 0xc3, | ||
135 | MS_CMD_FLASH_STOP = 0xcc, | ||
136 | MSPRO_CMD_FORMAT = 0x10, | ||
137 | MSPRO_CMD_SLEEP = 0x11, | ||
138 | MSPRO_CMD_READ_DATA = 0x20, | ||
139 | MSPRO_CMD_WRITE_DATA = 0x21, | ||
140 | MSPRO_CMD_READ_ATRB = 0x24, | ||
141 | MSPRO_CMD_STOP = 0x25, | ||
142 | MSPRO_CMD_ERASE = 0x26, | ||
143 | MSPRO_CMD_SET_IBA = 0x46, | ||
144 | MSPRO_CMD_SET_IBD = 0x47 | ||
145 | /* | ||
146 | MSPRO_CMD_RESET | ||
147 | MSPRO_CMD_WAKEUP | ||
148 | MSPRO_CMD_IN_IO_DATA | ||
149 | MSPRO_CMD_OUT_IO_DATA | ||
150 | MSPRO_CMD_READ_IO_ATRB | ||
151 | MSPRO_CMD_IN_IO_FIFO | ||
152 | MSPRO_CMD_OUT_IO_FIFO | ||
153 | MSPRO_CMD_IN_IOM | ||
154 | MSPRO_CMD_OUT_IOM | ||
155 | */ | ||
156 | }; | ||
157 | |||
158 | /*** Driver structures and functions ***/ | ||
159 | |||
160 | #define MEMSTICK_PART_SHIFT 3 | ||
161 | |||
162 | enum memstick_param { MEMSTICK_POWER = 1, MEMSTICK_INTERFACE }; | ||
163 | |||
164 | #define MEMSTICK_POWER_OFF 0 | ||
165 | #define MEMSTICK_POWER_ON 1 | ||
166 | |||
167 | #define MEMSTICK_SERIAL 0 | ||
168 | #define MEMSTICK_PARALLEL 1 | ||
169 | |||
170 | struct memstick_host; | ||
171 | struct memstick_driver; | ||
172 | |||
173 | #define MEMSTICK_MATCH_ALL 0x01 | ||
174 | |||
175 | #define MEMSTICK_TYPE_LEGACY 0xff | ||
176 | #define MEMSTICK_TYPE_DUO 0x00 | ||
177 | #define MEMSTICK_TYPE_PRO 0x01 | ||
178 | |||
179 | #define MEMSTICK_CATEGORY_STORAGE 0xff | ||
180 | #define MEMSTICK_CATEGORY_STORAGE_DUO 0x00 | ||
181 | |||
182 | #define MEMSTICK_CLASS_GENERIC 0xff | ||
183 | #define MEMSTICK_CLASS_GENERIC_DUO 0x00 | ||
184 | |||
185 | |||
186 | struct memstick_device_id { | ||
187 | unsigned char match_flags; | ||
188 | unsigned char type; | ||
189 | unsigned char category; | ||
190 | unsigned char class; | ||
191 | }; | ||
192 | |||
193 | struct memstick_request { | ||
194 | unsigned char tpc; | ||
195 | unsigned char data_dir:1, | ||
196 | need_card_int:1, | ||
197 | get_int_reg:1, | ||
198 | io_type:2; | ||
199 | #define MEMSTICK_IO_NONE 0 | ||
200 | #define MEMSTICK_IO_VAL 1 | ||
201 | #define MEMSTICK_IO_SG 2 | ||
202 | |||
203 | unsigned char int_reg; | ||
204 | int error; | ||
205 | union { | ||
206 | struct scatterlist sg; | ||
207 | struct { | ||
208 | unsigned char data_len; | ||
209 | unsigned char data[15]; | ||
210 | }; | ||
211 | }; | ||
212 | }; | ||
213 | |||
214 | struct memstick_dev { | ||
215 | struct memstick_device_id id; | ||
216 | struct memstick_host *host; | ||
217 | struct ms_register_addr reg_addr; | ||
218 | struct completion mrq_complete; | ||
219 | struct memstick_request current_mrq; | ||
220 | |||
221 | /* Check that media driver is still willing to operate the device. */ | ||
222 | int (*check)(struct memstick_dev *card); | ||
223 | /* Get next request from the media driver. */ | ||
224 | int (*next_request)(struct memstick_dev *card, | ||
225 | struct memstick_request **mrq); | ||
226 | |||
227 | struct device dev; | ||
228 | }; | ||
229 | |||
230 | struct memstick_host { | ||
231 | struct mutex lock; | ||
232 | unsigned int id; | ||
233 | unsigned int caps; | ||
234 | #define MEMSTICK_CAP_PARALLEL 1 | ||
235 | #define MEMSTICK_CAP_AUTO_GET_INT 2 | ||
236 | |||
237 | struct work_struct media_checker; | ||
238 | struct class_device cdev; | ||
239 | |||
240 | struct memstick_dev *card; | ||
241 | unsigned int retries; | ||
242 | |||
243 | /* Notify the host that some requests are pending. */ | ||
244 | void (*request)(struct memstick_host *host); | ||
245 | /* Set host IO parameters (power, clock, etc). */ | ||
246 | void (*set_param)(struct memstick_host *host, | ||
247 | enum memstick_param param, | ||
248 | int value); | ||
249 | unsigned long private[0] ____cacheline_aligned; | ||
250 | }; | ||
251 | |||
252 | struct memstick_driver { | ||
253 | struct memstick_device_id *id_table; | ||
254 | int (*probe)(struct memstick_dev *card); | ||
255 | void (*remove)(struct memstick_dev *card); | ||
256 | int (*suspend)(struct memstick_dev *card, | ||
257 | pm_message_t state); | ||
258 | int (*resume)(struct memstick_dev *card); | ||
259 | |||
260 | struct device_driver driver; | ||
261 | }; | ||
262 | |||
263 | int memstick_register_driver(struct memstick_driver *drv); | ||
264 | void memstick_unregister_driver(struct memstick_driver *drv); | ||
265 | |||
266 | struct memstick_host *memstick_alloc_host(unsigned int extra, | ||
267 | struct device *dev); | ||
268 | |||
269 | int memstick_add_host(struct memstick_host *host); | ||
270 | void memstick_remove_host(struct memstick_host *host); | ||
271 | void memstick_free_host(struct memstick_host *host); | ||
272 | void memstick_detect_change(struct memstick_host *host); | ||
273 | |||
274 | void memstick_init_req_sg(struct memstick_request *mrq, unsigned char tpc, | ||
275 | struct scatterlist *sg); | ||
276 | void memstick_init_req(struct memstick_request *mrq, unsigned char tpc, | ||
277 | void *buf, size_t length); | ||
278 | int memstick_next_req(struct memstick_host *host, | ||
279 | struct memstick_request **mrq); | ||
280 | void memstick_new_req(struct memstick_host *host); | ||
281 | |||
282 | int memstick_set_rw_addr(struct memstick_dev *card); | ||
283 | |||
284 | static inline void *memstick_priv(struct memstick_host *host) | ||
285 | { | ||
286 | return (void *)host->private; | ||
287 | } | ||
288 | |||
289 | static inline void *memstick_get_drvdata(struct memstick_dev *card) | ||
290 | { | ||
291 | return dev_get_drvdata(&card->dev); | ||
292 | } | ||
293 | |||
294 | static inline void memstick_set_drvdata(struct memstick_dev *card, void *data) | ||
295 | { | ||
296 | dev_set_drvdata(&card->dev, data); | ||
297 | } | ||
298 | |||
299 | #endif | ||
diff --git a/include/linux/swapops.h b/include/linux/swapops.h index 7bf2d149d209..6ec39ab27b4b 100644 --- a/include/linux/swapops.h +++ b/include/linux/swapops.h | |||
@@ -42,11 +42,13 @@ static inline pgoff_t swp_offset(swp_entry_t entry) | |||
42 | return entry.val & SWP_OFFSET_MASK(entry); | 42 | return entry.val & SWP_OFFSET_MASK(entry); |
43 | } | 43 | } |
44 | 44 | ||
45 | #ifdef CONFIG_MMU | ||
45 | /* check whether a pte points to a swap entry */ | 46 | /* check whether a pte points to a swap entry */ |
46 | static inline int is_swap_pte(pte_t pte) | 47 | static inline int is_swap_pte(pte_t pte) |
47 | { | 48 | { |
48 | return !pte_none(pte) && !pte_present(pte) && !pte_file(pte); | 49 | return !pte_none(pte) && !pte_present(pte) && !pte_file(pte); |
49 | } | 50 | } |
51 | #endif | ||
50 | 52 | ||
51 | /* | 53 | /* |
52 | * Convert the arch-dependent pte representation of a swp_entry_t into an | 54 | * Convert the arch-dependent pte representation of a swp_entry_t into an |
diff --git a/include/linux/thermal.h b/include/linux/thermal.h index bba7712cadc7..818ca1cf0b6d 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h | |||
@@ -79,7 +79,9 @@ struct thermal_zone_device { | |||
79 | }; | 79 | }; |
80 | 80 | ||
81 | struct thermal_zone_device *thermal_zone_device_register(char *, int, void *, | 81 | struct thermal_zone_device *thermal_zone_device_register(char *, int, void *, |
82 | struct thermal_zone_device_ops *); | 82 | struct |
83 | thermal_zone_device_ops | ||
84 | *); | ||
83 | void thermal_zone_device_unregister(struct thermal_zone_device *); | 85 | void thermal_zone_device_unregister(struct thermal_zone_device *); |
84 | 86 | ||
85 | int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int, | 87 | int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int, |
@@ -87,8 +89,23 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int, | |||
87 | int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int, | 89 | int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int, |
88 | struct thermal_cooling_device *); | 90 | struct thermal_cooling_device *); |
89 | 91 | ||
92 | #ifdef CONFIG_THERMAL | ||
90 | struct thermal_cooling_device *thermal_cooling_device_register(char *, void *, | 93 | struct thermal_cooling_device *thermal_cooling_device_register(char *, void *, |
91 | struct thermal_cooling_device_ops *); | 94 | struct |
95 | thermal_cooling_device_ops | ||
96 | *); | ||
92 | void thermal_cooling_device_unregister(struct thermal_cooling_device *); | 97 | void thermal_cooling_device_unregister(struct thermal_cooling_device *); |
98 | #else | ||
99 | static inline struct thermal_cooling_device | ||
100 | *thermal_cooling_device_register(char *c, void *v, | ||
101 | struct thermal_cooling_device_ops *t) | ||
102 | { | ||
103 | return NULL; | ||
104 | } | ||
105 | static inline | ||
106 | void thermal_cooling_device_unregister(struct thermal_cooling_device *t) | ||
107 | { | ||
108 | }; | ||
109 | #endif | ||
93 | 110 | ||
94 | #endif /* __THERMAL_H__ */ | 111 | #endif /* __THERMAL_H__ */ |
diff --git a/include/linux/tifm.h b/include/linux/tifm.h index 2096b76d0cee..da76ed85f595 100644 --- a/include/linux/tifm.h +++ b/include/linux/tifm.h | |||
@@ -72,6 +72,7 @@ enum { | |||
72 | #define TIFM_FIFO_READY 0x00000001 | 72 | #define TIFM_FIFO_READY 0x00000001 |
73 | #define TIFM_FIFO_INT_SETALL 0x0000ffff | 73 | #define TIFM_FIFO_INT_SETALL 0x0000ffff |
74 | #define TIFM_FIFO_INTMASK 0x00000005 | 74 | #define TIFM_FIFO_INTMASK 0x00000005 |
75 | #define TIFM_FIFO_SIZE 0x00000200 | ||
75 | 76 | ||
76 | #define TIFM_DMA_RESET 0x00000002 | 77 | #define TIFM_DMA_RESET 0x00000002 |
77 | #define TIFM_DMA_TX 0x00008000 | 78 | #define TIFM_DMA_TX 0x00008000 |
@@ -124,6 +125,8 @@ struct tifm_adapter { | |||
124 | 125 | ||
125 | void (*eject)(struct tifm_adapter *fm, | 126 | void (*eject)(struct tifm_adapter *fm, |
126 | struct tifm_dev *sock); | 127 | struct tifm_dev *sock); |
128 | int (*has_ms_pif)(struct tifm_adapter *fm, | ||
129 | struct tifm_dev *sock); | ||
127 | 130 | ||
128 | struct tifm_dev *sockets[0]; | 131 | struct tifm_dev *sockets[0]; |
129 | }; | 132 | }; |
@@ -141,6 +144,7 @@ struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm, unsigned int id, | |||
141 | int tifm_register_driver(struct tifm_driver *drv); | 144 | int tifm_register_driver(struct tifm_driver *drv); |
142 | void tifm_unregister_driver(struct tifm_driver *drv); | 145 | void tifm_unregister_driver(struct tifm_driver *drv); |
143 | void tifm_eject(struct tifm_dev *sock); | 146 | void tifm_eject(struct tifm_dev *sock); |
147 | int tifm_has_ms_pif(struct tifm_dev *sock); | ||
144 | int tifm_map_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents, | 148 | int tifm_map_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents, |
145 | int direction); | 149 | int direction); |
146 | void tifm_unmap_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents, | 150 | void tifm_unmap_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents, |
diff --git a/init/Makefile b/init/Makefile index 633392f5cdee..c5f157ce293e 100644 --- a/init/Makefile +++ b/init/Makefile | |||
@@ -27,7 +27,9 @@ $(obj)/version.o: include/linux/compile.h | |||
27 | # mkcompile_h will make sure to only update the | 27 | # mkcompile_h will make sure to only update the |
28 | # actual file if its content has changed. | 28 | # actual file if its content has changed. |
29 | 29 | ||
30 | quiet_chk_compile.h = echo ' CHK $@' | ||
31 | silent_chk_compile.h = : | ||
30 | include/linux/compile.h: FORCE | 32 | include/linux/compile.h: FORCE |
31 | @echo ' CHK $@' | 33 | @$($(quiet)chk_compile.h) |
32 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \ | 34 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \ |
33 | "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" "$(CC) $(KBUILD_CFLAGS)" | 35 | "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" "$(CC) $(KBUILD_CFLAGS)" |
diff --git a/kernel/.gitignore b/kernel/.gitignore index f2ab70073bd4..ab4f1090f437 100644 --- a/kernel/.gitignore +++ b/kernel/.gitignore | |||
@@ -3,3 +3,4 @@ | |||
3 | # | 3 | # |
4 | config_data.h | 4 | config_data.h |
5 | config_data.gz | 5 | config_data.gz |
6 | timeconst.h | ||
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 5c2c702af617..6bded84c20c8 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -399,7 +399,7 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem) | |||
399 | int ret; | 399 | int ret; |
400 | 400 | ||
401 | task_lock(task); | 401 | task_lock(task); |
402 | ret = task->mm && mm_cgroup(task->mm) == mem; | 402 | ret = task->mm && vm_match_cgroup(task->mm, mem); |
403 | task_unlock(task); | 403 | task_unlock(task); |
404 | return ret; | 404 | return ret; |
405 | } | 405 | } |
@@ -321,7 +321,7 @@ static int page_referenced_anon(struct page *page, | |||
321 | * counting on behalf of references from different | 321 | * counting on behalf of references from different |
322 | * cgroups | 322 | * cgroups |
323 | */ | 323 | */ |
324 | if (mem_cont && (mm_cgroup(vma->vm_mm) != mem_cont)) | 324 | if (mem_cont && !vm_match_cgroup(vma->vm_mm, mem_cont)) |
325 | continue; | 325 | continue; |
326 | referenced += page_referenced_one(page, vma, &mapcount); | 326 | referenced += page_referenced_one(page, vma, &mapcount); |
327 | if (!mapcount) | 327 | if (!mapcount) |
@@ -382,7 +382,7 @@ static int page_referenced_file(struct page *page, | |||
382 | * counting on behalf of references from different | 382 | * counting on behalf of references from different |
383 | * cgroups | 383 | * cgroups |
384 | */ | 384 | */ |
385 | if (mem_cont && (mm_cgroup(vma->vm_mm) != mem_cont)) | 385 | if (mem_cont && !vm_match_cgroup(vma->vm_mm, mem_cont)) |
386 | continue; | 386 | continue; |
387 | if ((vma->vm_flags & (VM_LOCKED|VM_MAYSHARE)) | 387 | if ((vma->vm_flags & (VM_LOCKED|VM_MAYSHARE)) |
388 | == (VM_LOCKED|VM_MAYSHARE)) { | 388 | == (VM_LOCKED|VM_MAYSHARE)) { |
diff --git a/scripts/.gitignore b/scripts/.gitignore index a1f52cb47200..b939fbd01195 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore | |||
@@ -6,3 +6,4 @@ kallsyms | |||
6 | pnmtologo | 6 | pnmtologo |
7 | bin2c | 7 | bin2c |
8 | unifdef | 8 | unifdef |
9 | binoffset | ||
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index b96ea8d6a5ed..da3559ea92e0 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
@@ -39,15 +39,19 @@ escsq = $(subst $(squote),'\$(squote)',$1) | |||
39 | # - If they are equal no change, and no timestamp update | 39 | # - If they are equal no change, and no timestamp update |
40 | # - stdin is piped in from the first prerequisite ($<) so one has | 40 | # - stdin is piped in from the first prerequisite ($<) so one has |
41 | # to specify a valid file as first prerequisite (often the kbuild file) | 41 | # to specify a valid file as first prerequisite (often the kbuild file) |
42 | quiet_chk_filechk = echo ' CHK $@' | ||
43 | silent_chk_filechk = : | ||
44 | quiet_upd_filechk = echo ' UPD $@' | ||
45 | silent_upd_filechk = : | ||
42 | define filechk | 46 | define filechk |
43 | $(Q)set -e; \ | 47 | $(Q)set -e; \ |
44 | echo ' CHK $@'; \ | 48 | $($(quiet)chk_filechk); \ |
45 | mkdir -p $(dir $@); \ | 49 | mkdir -p $(dir $@); \ |
46 | $(filechk_$(1)) < $< > $@.tmp; \ | 50 | $(filechk_$(1)) < $< > $@.tmp; \ |
47 | if [ -r $@ ] && cmp -s $@ $@.tmp; then \ | 51 | if [ -r $@ ] && cmp -s $@ $@.tmp; then \ |
48 | rm -f $@.tmp; \ | 52 | rm -f $@.tmp; \ |
49 | else \ | 53 | else \ |
50 | echo ' UPD $@'; \ | 54 | $($(quiet)upd_filechk); \ |
51 | mv -f $@.tmp $@; \ | 55 | mv -f $@.tmp $@; \ |
52 | fi | 56 | fi |
53 | endef | 57 | endef |
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 5d546466e6b1..dbe1fb5e8cc0 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -613,7 +613,7 @@ static const char *sym_name(struct elf_info *elf, Elf_Sym *sym) | |||
613 | if (sym) | 613 | if (sym) |
614 | return elf->strtab + sym->st_name; | 614 | return elf->strtab + sym->st_name; |
615 | else | 615 | else |
616 | return ""; | 616 | return "(unknown)"; |
617 | } | 617 | } |
618 | 618 | ||
619 | static const char *sec_name(struct elf_info *elf, int shndx) | 619 | static const char *sec_name(struct elf_info *elf, int shndx) |
@@ -1102,7 +1102,7 @@ static int is_function(Elf_Sym *sym) | |||
1102 | if (sym) | 1102 | if (sym) |
1103 | return ELF_ST_TYPE(sym->st_info) == STT_FUNC; | 1103 | return ELF_ST_TYPE(sym->st_info) == STT_FUNC; |
1104 | else | 1104 | else |
1105 | return 0; | 1105 | return -1; |
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | /* | 1108 | /* |
@@ -1120,24 +1120,31 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch, | |||
1120 | { | 1120 | { |
1121 | const char *from, *from_p; | 1121 | const char *from, *from_p; |
1122 | const char *to, *to_p; | 1122 | const char *to, *to_p; |
1123 | from = from_is_func ? "function" : "variable"; | 1123 | |
1124 | from_p = from_is_func ? "()" : ""; | 1124 | switch (from_is_func) { |
1125 | to = to_is_func ? "function" : "variable"; | 1125 | case 0: from = "variable"; from_p = ""; break; |
1126 | to_p = to_is_func ? "()" : ""; | 1126 | case 1: from = "function"; from_p = "()"; break; |
1127 | default: from = "(unknown reference)"; from_p = ""; break; | ||
1128 | } | ||
1129 | switch (to_is_func) { | ||
1130 | case 0: to = "variable"; to_p = ""; break; | ||
1131 | case 1: to = "function"; to_p = "()"; break; | ||
1132 | default: to = "(unknown reference)"; to_p = ""; break; | ||
1133 | } | ||
1127 | 1134 | ||
1128 | sec_mismatch_count++; | 1135 | sec_mismatch_count++; |
1129 | if (!sec_mismatch_verbose) | 1136 | if (!sec_mismatch_verbose) |
1130 | return; | 1137 | return; |
1131 | 1138 | ||
1132 | fprintf(stderr, "WARNING: %s(%s+0x%llx): Section mismatch in" | 1139 | warn("%s(%s+0x%llx): Section mismatch in reference from the %s %s%s " |
1133 | " reference from the %s %s%s to the %s %s:%s%s\n", | 1140 | "to the %s %s:%s%s\n", |
1134 | modname, fromsec, fromaddr, from, fromsym, from_p, | 1141 | modname, fromsec, fromaddr, from, fromsym, from_p, to, tosec, |
1135 | to, tosec, tosym, to_p); | 1142 | tosym, to_p); |
1136 | 1143 | ||
1137 | switch (mismatch) { | 1144 | switch (mismatch) { |
1138 | case TEXT_TO_INIT: | 1145 | case TEXT_TO_INIT: |
1139 | fprintf(stderr, | 1146 | fprintf(stderr, |
1140 | "The function %s %s() references\n" | 1147 | "The function %s%s() references\n" |
1141 | "the %s %s%s%s.\n" | 1148 | "the %s %s%s%s.\n" |
1142 | "This is often because %s lacks a %s\n" | 1149 | "This is often because %s lacks a %s\n" |
1143 | "annotation or the annotation of %s is wrong.\n", | 1150 | "annotation or the annotation of %s is wrong.\n", |
@@ -1938,10 +1945,10 @@ int main(int argc, char **argv) | |||
1938 | if (dump_write) | 1945 | if (dump_write) |
1939 | write_dump(dump_write); | 1946 | write_dump(dump_write); |
1940 | if (sec_mismatch_count && !sec_mismatch_verbose) | 1947 | if (sec_mismatch_count && !sec_mismatch_verbose) |
1941 | fprintf(stderr, "modpost: Found %d section mismatch(es).\n" | 1948 | warn("modpost: Found %d section mismatch(es).\n" |
1942 | "To see full details build your kernel with:\n" | 1949 | "To see full details build your kernel with:\n" |
1943 | "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n", | 1950 | "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n", |
1944 | sec_mismatch_count); | 1951 | sec_mismatch_count); |
1945 | 1952 | ||
1946 | return err; | 1953 | return err; |
1947 | } | 1954 | } |
diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 0f657b5f3bc8..ba6bf5d5abf9 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb | |||
@@ -13,6 +13,7 @@ set -e | |||
13 | 13 | ||
14 | # Some variables and settings used throughout the script | 14 | # Some variables and settings used throughout the script |
15 | version=$KERNELRELEASE | 15 | version=$KERNELRELEASE |
16 | revision=`cat .version` | ||
16 | tmpdir="$objtree/debian/tmp" | 17 | tmpdir="$objtree/debian/tmp" |
17 | packagename=linux-$version | 18 | packagename=linux-$version |
18 | 19 | ||
@@ -65,7 +66,7 @@ done | |||
65 | name="Kernel Compiler <$(id -nu)@$(hostname -f)>" | 66 | name="Kernel Compiler <$(id -nu)@$(hostname -f)>" |
66 | # Generate a simple changelog template | 67 | # Generate a simple changelog template |
67 | cat <<EOF > debian/changelog | 68 | cat <<EOF > debian/changelog |
68 | linux ($version) unstable; urgency=low | 69 | linux ($version-$revision) unstable; urgency=low |
69 | 70 | ||
70 | * A standard release | 71 | * A standard release |
71 | 72 | ||