Commit 43c9c59185eec7caaff6e9dd8d4c93a4d9836a86

Authored by Tejun Heo
Committed by Jeff Garzik
1 parent e7ecd43569

libata: implement dump_id force param

Add dump_id libata.force parameter.  If specified, libata dumps full
IDENTIFY data during device configuration.  This is to aid debugging.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Larry Baker <baker@usgs.gov>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>

Showing 3 changed files with 12 additions and 0 deletions Inline Diff

Documentation/kernel-parameters.txt
1 Kernel Parameters 1 Kernel Parameters
2 ~~~~~~~~~~~~~~~~~ 2 ~~~~~~~~~~~~~~~~~
3 3
4 The following is a consolidated list of the kernel parameters as implemented 4 The following is a consolidated list of the kernel parameters as implemented
5 (mostly) by the __setup() macro and sorted into English Dictionary order 5 (mostly) by the __setup() macro and sorted into English Dictionary order
6 (defined as ignoring all punctuation and sorting digits before letters in a 6 (defined as ignoring all punctuation and sorting digits before letters in a
7 case insensitive manner), and with descriptions where known. 7 case insensitive manner), and with descriptions where known.
8 8
9 Module parameters for loadable modules are specified only as the 9 Module parameters for loadable modules are specified only as the
10 parameter name with optional '=' and value as appropriate, such as: 10 parameter name with optional '=' and value as appropriate, such as:
11 11
12 modprobe usbcore blinkenlights=1 12 modprobe usbcore blinkenlights=1
13 13
14 Module parameters for modules that are built into the kernel image 14 Module parameters for modules that are built into the kernel image
15 are specified on the kernel command line with the module name plus 15 are specified on the kernel command line with the module name plus
16 '.' plus parameter name, with '=' and value if appropriate, such as: 16 '.' plus parameter name, with '=' and value if appropriate, such as:
17 17
18 usbcore.blinkenlights=1 18 usbcore.blinkenlights=1
19 19
20 Hyphens (dashes) and underscores are equivalent in parameter names, so 20 Hyphens (dashes) and underscores are equivalent in parameter names, so
21 log_buf_len=1M print-fatal-signals=1 21 log_buf_len=1M print-fatal-signals=1
22 can also be entered as 22 can also be entered as
23 log-buf-len=1M print_fatal_signals=1 23 log-buf-len=1M print_fatal_signals=1
24 24
25 25
26 This document may not be entirely up to date and comprehensive. The command 26 This document may not be entirely up to date and comprehensive. The command
27 "modinfo -p ${modulename}" shows a current list of all parameters of a loadable 27 "modinfo -p ${modulename}" shows a current list of all parameters of a loadable
28 module. Loadable modules, after being loaded into the running kernel, also 28 module. Loadable modules, after being loaded into the running kernel, also
29 reveal their parameters in /sys/module/${modulename}/parameters/. Some of these 29 reveal their parameters in /sys/module/${modulename}/parameters/. Some of these
30 parameters may be changed at runtime by the command 30 parameters may be changed at runtime by the command
31 "echo -n ${value} > /sys/module/${modulename}/parameters/${parm}". 31 "echo -n ${value} > /sys/module/${modulename}/parameters/${parm}".
32 32
33 The parameters listed below are only valid if certain kernel build options were 33 The parameters listed below are only valid if certain kernel build options were
34 enabled and if respective hardware is present. The text in square brackets at 34 enabled and if respective hardware is present. The text in square brackets at
35 the beginning of each description states the restrictions within which a 35 the beginning of each description states the restrictions within which a
36 parameter is applicable: 36 parameter is applicable:
37 37
38 ACPI ACPI support is enabled. 38 ACPI ACPI support is enabled.
39 AGP AGP (Accelerated Graphics Port) is enabled. 39 AGP AGP (Accelerated Graphics Port) is enabled.
40 ALSA ALSA sound support is enabled. 40 ALSA ALSA sound support is enabled.
41 APIC APIC support is enabled. 41 APIC APIC support is enabled.
42 APM Advanced Power Management support is enabled. 42 APM Advanced Power Management support is enabled.
43 AVR32 AVR32 architecture is enabled. 43 AVR32 AVR32 architecture is enabled.
44 AX25 Appropriate AX.25 support is enabled. 44 AX25 Appropriate AX.25 support is enabled.
45 BLACKFIN Blackfin architecture is enabled. 45 BLACKFIN Blackfin architecture is enabled.
46 DRM Direct Rendering Management support is enabled. 46 DRM Direct Rendering Management support is enabled.
47 EDD BIOS Enhanced Disk Drive Services (EDD) is enabled 47 EDD BIOS Enhanced Disk Drive Services (EDD) is enabled
48 EFI EFI Partitioning (GPT) is enabled 48 EFI EFI Partitioning (GPT) is enabled
49 EIDE EIDE/ATAPI support is enabled. 49 EIDE EIDE/ATAPI support is enabled.
50 FB The frame buffer device is enabled. 50 FB The frame buffer device is enabled.
51 GCOV GCOV profiling is enabled. 51 GCOV GCOV profiling is enabled.
52 HW Appropriate hardware is enabled. 52 HW Appropriate hardware is enabled.
53 IA-64 IA-64 architecture is enabled. 53 IA-64 IA-64 architecture is enabled.
54 IMA Integrity measurement architecture is enabled. 54 IMA Integrity measurement architecture is enabled.
55 IOSCHED More than one I/O scheduler is enabled. 55 IOSCHED More than one I/O scheduler is enabled.
56 IP_PNP IP DHCP, BOOTP, or RARP is enabled. 56 IP_PNP IP DHCP, BOOTP, or RARP is enabled.
57 IPV6 IPv6 support is enabled. 57 IPV6 IPv6 support is enabled.
58 ISAPNP ISA PnP code is enabled. 58 ISAPNP ISA PnP code is enabled.
59 ISDN Appropriate ISDN support is enabled. 59 ISDN Appropriate ISDN support is enabled.
60 JOY Appropriate joystick support is enabled. 60 JOY Appropriate joystick support is enabled.
61 KGDB Kernel debugger support is enabled. 61 KGDB Kernel debugger support is enabled.
62 KVM Kernel Virtual Machine support is enabled. 62 KVM Kernel Virtual Machine support is enabled.
63 LIBATA Libata driver is enabled 63 LIBATA Libata driver is enabled
64 LP Printer support is enabled. 64 LP Printer support is enabled.
65 LOOP Loopback device support is enabled. 65 LOOP Loopback device support is enabled.
66 M68k M68k architecture is enabled. 66 M68k M68k architecture is enabled.
67 These options have more detailed description inside of 67 These options have more detailed description inside of
68 Documentation/m68k/kernel-options.txt. 68 Documentation/m68k/kernel-options.txt.
69 MCA MCA bus support is enabled. 69 MCA MCA bus support is enabled.
70 MDA MDA console support is enabled. 70 MDA MDA console support is enabled.
71 MOUSE Appropriate mouse support is enabled. 71 MOUSE Appropriate mouse support is enabled.
72 MSI Message Signaled Interrupts (PCI). 72 MSI Message Signaled Interrupts (PCI).
73 MTD MTD (Memory Technology Device) support is enabled. 73 MTD MTD (Memory Technology Device) support is enabled.
74 NET Appropriate network support is enabled. 74 NET Appropriate network support is enabled.
75 NUMA NUMA support is enabled. 75 NUMA NUMA support is enabled.
76 GENERIC_TIME The generic timeofday code is enabled. 76 GENERIC_TIME The generic timeofday code is enabled.
77 NFS Appropriate NFS support is enabled. 77 NFS Appropriate NFS support is enabled.
78 OSS OSS sound support is enabled. 78 OSS OSS sound support is enabled.
79 PV_OPS A paravirtualized kernel is enabled. 79 PV_OPS A paravirtualized kernel is enabled.
80 PARIDE The ParIDE (parallel port IDE) subsystem is enabled. 80 PARIDE The ParIDE (parallel port IDE) subsystem is enabled.
81 PARISC The PA-RISC architecture is enabled. 81 PARISC The PA-RISC architecture is enabled.
82 PCI PCI bus support is enabled. 82 PCI PCI bus support is enabled.
83 PCIE PCI Express support is enabled. 83 PCIE PCI Express support is enabled.
84 PCMCIA The PCMCIA subsystem is enabled. 84 PCMCIA The PCMCIA subsystem is enabled.
85 PNP Plug & Play support is enabled. 85 PNP Plug & Play support is enabled.
86 PPC PowerPC architecture is enabled. 86 PPC PowerPC architecture is enabled.
87 PPT Parallel port support is enabled. 87 PPT Parallel port support is enabled.
88 PS2 Appropriate PS/2 support is enabled. 88 PS2 Appropriate PS/2 support is enabled.
89 RAM RAM disk support is enabled. 89 RAM RAM disk support is enabled.
90 S390 S390 architecture is enabled. 90 S390 S390 architecture is enabled.
91 SCSI Appropriate SCSI support is enabled. 91 SCSI Appropriate SCSI support is enabled.
92 A lot of drivers has their options described inside of 92 A lot of drivers has their options described inside of
93 Documentation/scsi/. 93 Documentation/scsi/.
94 SECURITY Different security models are enabled. 94 SECURITY Different security models are enabled.
95 SELINUX SELinux support is enabled. 95 SELINUX SELinux support is enabled.
96 SERIAL Serial support is enabled. 96 SERIAL Serial support is enabled.
97 SH SuperH architecture is enabled. 97 SH SuperH architecture is enabled.
98 SMP The kernel is an SMP kernel. 98 SMP The kernel is an SMP kernel.
99 SPARC Sparc architecture is enabled. 99 SPARC Sparc architecture is enabled.
100 SWSUSP Software suspend (hibernation) is enabled. 100 SWSUSP Software suspend (hibernation) is enabled.
101 SUSPEND System suspend states are enabled. 101 SUSPEND System suspend states are enabled.
102 FTRACE Function tracing enabled. 102 FTRACE Function tracing enabled.
103 TPM TPM drivers are enabled. 103 TPM TPM drivers are enabled.
104 TS Appropriate touchscreen support is enabled. 104 TS Appropriate touchscreen support is enabled.
105 UMS USB Mass Storage support is enabled. 105 UMS USB Mass Storage support is enabled.
106 USB USB support is enabled. 106 USB USB support is enabled.
107 USBHID USB Human Interface Device support is enabled. 107 USBHID USB Human Interface Device support is enabled.
108 V4L Video For Linux support is enabled. 108 V4L Video For Linux support is enabled.
109 VGA The VGA console has been enabled. 109 VGA The VGA console has been enabled.
110 VT Virtual terminal support is enabled. 110 VT Virtual terminal support is enabled.
111 WDT Watchdog support is enabled. 111 WDT Watchdog support is enabled.
112 XT IBM PC/XT MFM hard disk support is enabled. 112 XT IBM PC/XT MFM hard disk support is enabled.
113 X86-32 X86-32, aka i386 architecture is enabled. 113 X86-32 X86-32, aka i386 architecture is enabled.
114 X86-64 X86-64 architecture is enabled. 114 X86-64 X86-64 architecture is enabled.
115 More X86-64 boot options can be found in 115 More X86-64 boot options can be found in
116 Documentation/x86/x86_64/boot-options.txt . 116 Documentation/x86/x86_64/boot-options.txt .
117 X86 Either 32bit or 64bit x86 (same as X86-32+X86-64) 117 X86 Either 32bit or 64bit x86 (same as X86-32+X86-64)
118 118
119 In addition, the following text indicates that the option: 119 In addition, the following text indicates that the option:
120 120
121 BUGS= Relates to possible processor bugs on the said processor. 121 BUGS= Relates to possible processor bugs on the said processor.
122 KNL Is a kernel start-up parameter. 122 KNL Is a kernel start-up parameter.
123 BOOT Is a boot loader parameter. 123 BOOT Is a boot loader parameter.
124 124
125 Parameters denoted with BOOT are actually interpreted by the boot 125 Parameters denoted with BOOT are actually interpreted by the boot
126 loader, and have no meaning to the kernel directly. 126 loader, and have no meaning to the kernel directly.
127 Do not modify the syntax of boot loader parameters without extreme 127 Do not modify the syntax of boot loader parameters without extreme
128 need or coordination with <Documentation/x86/boot.txt>. 128 need or coordination with <Documentation/x86/boot.txt>.
129 129
130 There are also arch-specific kernel-parameters not documented here. 130 There are also arch-specific kernel-parameters not documented here.
131 See for example <Documentation/x86/x86_64/boot-options.txt>. 131 See for example <Documentation/x86/x86_64/boot-options.txt>.
132 132
133 Note that ALL kernel parameters listed below are CASE SENSITIVE, and that 133 Note that ALL kernel parameters listed below are CASE SENSITIVE, and that
134 a trailing = on the name of any parameter states that that parameter will 134 a trailing = on the name of any parameter states that that parameter will
135 be entered as an environment variable, whereas its absence indicates that 135 be entered as an environment variable, whereas its absence indicates that
136 it will appear as a kernel argument readable via /proc/cmdline by programs 136 it will appear as a kernel argument readable via /proc/cmdline by programs
137 running once the system is up. 137 running once the system is up.
138 138
139 The number of kernel parameters is not limited, but the length of the 139 The number of kernel parameters is not limited, but the length of the
140 complete command line (parameters including spaces etc.) is limited to 140 complete command line (parameters including spaces etc.) is limited to
141 a fixed number of characters. This limit depends on the architecture 141 a fixed number of characters. This limit depends on the architecture
142 and is between 256 and 4096 characters. It is defined in the file 142 and is between 256 and 4096 characters. It is defined in the file
143 ./include/asm/setup.h as COMMAND_LINE_SIZE. 143 ./include/asm/setup.h as COMMAND_LINE_SIZE.
144 144
145 145
146 acpi= [HW,ACPI,X86] 146 acpi= [HW,ACPI,X86]
147 Advanced Configuration and Power Interface 147 Advanced Configuration and Power Interface
148 Format: { force | off | ht | strict | noirq | rsdt } 148 Format: { force | off | ht | strict | noirq | rsdt }
149 force -- enable ACPI if default was off 149 force -- enable ACPI if default was off
150 off -- disable ACPI if default was on 150 off -- disable ACPI if default was on
151 noirq -- do not use ACPI for IRQ routing 151 noirq -- do not use ACPI for IRQ routing
152 ht -- run only enough ACPI to enable Hyper Threading 152 ht -- run only enough ACPI to enable Hyper Threading
153 strict -- Be less tolerant of platforms that are not 153 strict -- Be less tolerant of platforms that are not
154 strictly ACPI specification compliant. 154 strictly ACPI specification compliant.
155 rsdt -- prefer RSDT over (default) XSDT 155 rsdt -- prefer RSDT over (default) XSDT
156 copy_dsdt -- copy DSDT to memory 156 copy_dsdt -- copy DSDT to memory
157 157
158 See also Documentation/power/pm.txt, pci=noacpi 158 See also Documentation/power/pm.txt, pci=noacpi
159 159
160 acpi_apic_instance= [ACPI, IOAPIC] 160 acpi_apic_instance= [ACPI, IOAPIC]
161 Format: <int> 161 Format: <int>
162 2: use 2nd APIC table, if available 162 2: use 2nd APIC table, if available
163 1,0: use 1st APIC table 163 1,0: use 1st APIC table
164 default: 0 164 default: 0
165 165
166 acpi_backlight= [HW,ACPI] 166 acpi_backlight= [HW,ACPI]
167 acpi_backlight=vendor 167 acpi_backlight=vendor
168 acpi_backlight=video 168 acpi_backlight=video
169 If set to vendor, prefer vendor specific driver 169 If set to vendor, prefer vendor specific driver
170 (e.g. thinkpad_acpi, sony_acpi, etc.) instead 170 (e.g. thinkpad_acpi, sony_acpi, etc.) instead
171 of the ACPI video.ko driver. 171 of the ACPI video.ko driver.
172 172
173 acpi.debug_layer= [HW,ACPI,ACPI_DEBUG] 173 acpi.debug_layer= [HW,ACPI,ACPI_DEBUG]
174 acpi.debug_level= [HW,ACPI,ACPI_DEBUG] 174 acpi.debug_level= [HW,ACPI,ACPI_DEBUG]
175 Format: <int> 175 Format: <int>
176 CONFIG_ACPI_DEBUG must be enabled to produce any ACPI 176 CONFIG_ACPI_DEBUG must be enabled to produce any ACPI
177 debug output. Bits in debug_layer correspond to a 177 debug output. Bits in debug_layer correspond to a
178 _COMPONENT in an ACPI source file, e.g., 178 _COMPONENT in an ACPI source file, e.g.,
179 #define _COMPONENT ACPI_PCI_COMPONENT 179 #define _COMPONENT ACPI_PCI_COMPONENT
180 Bits in debug_level correspond to a level in 180 Bits in debug_level correspond to a level in
181 ACPI_DEBUG_PRINT statements, e.g., 181 ACPI_DEBUG_PRINT statements, e.g.,
182 ACPI_DEBUG_PRINT((ACPI_DB_INFO, ... 182 ACPI_DEBUG_PRINT((ACPI_DB_INFO, ...
183 The debug_level mask defaults to "info". See 183 The debug_level mask defaults to "info". See
184 Documentation/acpi/debug.txt for more information about 184 Documentation/acpi/debug.txt for more information about
185 debug layers and levels. 185 debug layers and levels.
186 186
187 Enable processor driver info messages: 187 Enable processor driver info messages:
188 acpi.debug_layer=0x20000000 188 acpi.debug_layer=0x20000000
189 Enable PCI/PCI interrupt routing info messages: 189 Enable PCI/PCI interrupt routing info messages:
190 acpi.debug_layer=0x400000 190 acpi.debug_layer=0x400000
191 Enable AML "Debug" output, i.e., stores to the Debug 191 Enable AML "Debug" output, i.e., stores to the Debug
192 object while interpreting AML: 192 object while interpreting AML:
193 acpi.debug_layer=0xffffffff acpi.debug_level=0x2 193 acpi.debug_layer=0xffffffff acpi.debug_level=0x2
194 Enable all messages related to ACPI hardware: 194 Enable all messages related to ACPI hardware:
195 acpi.debug_layer=0x2 acpi.debug_level=0xffffffff 195 acpi.debug_layer=0x2 acpi.debug_level=0xffffffff
196 196
197 Some values produce so much output that the system is 197 Some values produce so much output that the system is
198 unusable. The "log_buf_len" parameter may be useful 198 unusable. The "log_buf_len" parameter may be useful
199 if you need to capture more output. 199 if you need to capture more output.
200 200
201 acpi_display_output= [HW,ACPI] 201 acpi_display_output= [HW,ACPI]
202 acpi_display_output=vendor 202 acpi_display_output=vendor
203 acpi_display_output=video 203 acpi_display_output=video
204 See above. 204 See above.
205 205
206 acpi_irq_balance [HW,ACPI] 206 acpi_irq_balance [HW,ACPI]
207 ACPI will balance active IRQs 207 ACPI will balance active IRQs
208 default in APIC mode 208 default in APIC mode
209 209
210 acpi_irq_nobalance [HW,ACPI] 210 acpi_irq_nobalance [HW,ACPI]
211 ACPI will not move active IRQs (default) 211 ACPI will not move active IRQs (default)
212 default in PIC mode 212 default in PIC mode
213 213
214 acpi_irq_isa= [HW,ACPI] If irq_balance, mark listed IRQs used by ISA 214 acpi_irq_isa= [HW,ACPI] If irq_balance, mark listed IRQs used by ISA
215 Format: <irq>,<irq>... 215 Format: <irq>,<irq>...
216 216
217 acpi_irq_pci= [HW,ACPI] If irq_balance, clear listed IRQs for 217 acpi_irq_pci= [HW,ACPI] If irq_balance, clear listed IRQs for
218 use by PCI 218 use by PCI
219 Format: <irq>,<irq>... 219 Format: <irq>,<irq>...
220 220
221 acpi_no_auto_ssdt [HW,ACPI] Disable automatic loading of SSDT 221 acpi_no_auto_ssdt [HW,ACPI] Disable automatic loading of SSDT
222 222
223 acpi_os_name= [HW,ACPI] Tell ACPI BIOS the name of the OS 223 acpi_os_name= [HW,ACPI] Tell ACPI BIOS the name of the OS
224 Format: To spoof as Windows 98: ="Microsoft Windows" 224 Format: To spoof as Windows 98: ="Microsoft Windows"
225 225
226 acpi_osi= [HW,ACPI] Modify list of supported OS interface strings 226 acpi_osi= [HW,ACPI] Modify list of supported OS interface strings
227 acpi_osi="string1" # add string1 -- only one string 227 acpi_osi="string1" # add string1 -- only one string
228 acpi_osi="!string2" # remove built-in string2 228 acpi_osi="!string2" # remove built-in string2
229 acpi_osi= # disable all strings 229 acpi_osi= # disable all strings
230 230
231 acpi_pm_good [X86] 231 acpi_pm_good [X86]
232 Override the pmtimer bug detection: force the kernel 232 Override the pmtimer bug detection: force the kernel
233 to assume that this machine's pmtimer latches its value 233 to assume that this machine's pmtimer latches its value
234 and always returns good values. 234 and always returns good values.
235 235
236 acpi_sci= [HW,ACPI] ACPI System Control Interrupt trigger mode 236 acpi_sci= [HW,ACPI] ACPI System Control Interrupt trigger mode
237 Format: { level | edge | high | low } 237 Format: { level | edge | high | low }
238 238
239 acpi_serialize [HW,ACPI] force serialization of AML methods 239 acpi_serialize [HW,ACPI] force serialization of AML methods
240 240
241 acpi_skip_timer_override [HW,ACPI] 241 acpi_skip_timer_override [HW,ACPI]
242 Recognize and ignore IRQ0/pin2 Interrupt Override. 242 Recognize and ignore IRQ0/pin2 Interrupt Override.
243 For broken nForce2 BIOS resulting in XT-PIC timer. 243 For broken nForce2 BIOS resulting in XT-PIC timer.
244 244
245 acpi_sleep= [HW,ACPI] Sleep options 245 acpi_sleep= [HW,ACPI] Sleep options
246 Format: { s3_bios, s3_mode, s3_beep, s4_nohwsig, 246 Format: { s3_bios, s3_mode, s3_beep, s4_nohwsig,
247 old_ordering, s4_nonvs, sci_force_enable } 247 old_ordering, s4_nonvs, sci_force_enable }
248 See Documentation/power/video.txt for information on 248 See Documentation/power/video.txt for information on
249 s3_bios and s3_mode. 249 s3_bios and s3_mode.
250 s3_beep is for debugging; it makes the PC's speaker beep 250 s3_beep is for debugging; it makes the PC's speaker beep
251 as soon as the kernel's real-mode entry point is called. 251 as soon as the kernel's real-mode entry point is called.
252 s4_nohwsig prevents ACPI hardware signature from being 252 s4_nohwsig prevents ACPI hardware signature from being
253 used during resume from hibernation. 253 used during resume from hibernation.
254 old_ordering causes the ACPI 1.0 ordering of the _PTS 254 old_ordering causes the ACPI 1.0 ordering of the _PTS
255 control method, with respect to putting devices into 255 control method, with respect to putting devices into
256 low power states, to be enforced (the ACPI 2.0 ordering 256 low power states, to be enforced (the ACPI 2.0 ordering
257 of _PTS is used by default). 257 of _PTS is used by default).
258 s4_nonvs prevents the kernel from saving/restoring the 258 s4_nonvs prevents the kernel from saving/restoring the
259 ACPI NVS memory during hibernation. 259 ACPI NVS memory during hibernation.
260 sci_force_enable causes the kernel to set SCI_EN directly 260 sci_force_enable causes the kernel to set SCI_EN directly
261 on resume from S1/S3 (which is against the ACPI spec, 261 on resume from S1/S3 (which is against the ACPI spec,
262 but some broken systems don't work without it). 262 but some broken systems don't work without it).
263 263
264 acpi_use_timer_override [HW,ACPI] 264 acpi_use_timer_override [HW,ACPI]
265 Use timer override. For some broken Nvidia NF5 boards 265 Use timer override. For some broken Nvidia NF5 boards
266 that require a timer override, but don't have HPET 266 that require a timer override, but don't have HPET
267 267
268 acpi_enforce_resources= [ACPI] 268 acpi_enforce_resources= [ACPI]
269 { strict | lax | no } 269 { strict | lax | no }
270 Check for resource conflicts between native drivers 270 Check for resource conflicts between native drivers
271 and ACPI OperationRegions (SystemIO and SystemMemory 271 and ACPI OperationRegions (SystemIO and SystemMemory
272 only). IO ports and memory declared in ACPI might be 272 only). IO ports and memory declared in ACPI might be
273 used by the ACPI subsystem in arbitrary AML code and 273 used by the ACPI subsystem in arbitrary AML code and
274 can interfere with legacy drivers. 274 can interfere with legacy drivers.
275 strict (default): access to resources claimed by ACPI 275 strict (default): access to resources claimed by ACPI
276 is denied; legacy drivers trying to access reserved 276 is denied; legacy drivers trying to access reserved
277 resources will fail to bind to device using them. 277 resources will fail to bind to device using them.
278 lax: access to resources claimed by ACPI is allowed; 278 lax: access to resources claimed by ACPI is allowed;
279 legacy drivers trying to access reserved resources 279 legacy drivers trying to access reserved resources
280 will bind successfully but a warning message is logged. 280 will bind successfully but a warning message is logged.
281 no: ACPI OperationRegions are not marked as reserved, 281 no: ACPI OperationRegions are not marked as reserved,
282 no further checks are performed. 282 no further checks are performed.
283 283
284 ad1848= [HW,OSS] 284 ad1848= [HW,OSS]
285 Format: <io>,<irq>,<dma>,<dma2>,<type> 285 Format: <io>,<irq>,<dma>,<dma2>,<type>
286 286
287 add_efi_memmap [EFI; X86] Include EFI memory map in 287 add_efi_memmap [EFI; X86] Include EFI memory map in
288 kernel's map of available physical RAM. 288 kernel's map of available physical RAM.
289 289
290 advansys= [HW,SCSI] 290 advansys= [HW,SCSI]
291 See header of drivers/scsi/advansys.c. 291 See header of drivers/scsi/advansys.c.
292 292
293 aedsp16= [HW,OSS] Audio Excel DSP 16 293 aedsp16= [HW,OSS] Audio Excel DSP 16
294 Format: <io>,<irq>,<dma>,<mss_io>,<mpu_io>,<mpu_irq> 294 Format: <io>,<irq>,<dma>,<mss_io>,<mpu_io>,<mpu_irq>
295 See also header of sound/oss/aedsp16.c. 295 See also header of sound/oss/aedsp16.c.
296 296
297 agp= [AGP] 297 agp= [AGP]
298 { off | try_unsupported } 298 { off | try_unsupported }
299 off: disable AGP support 299 off: disable AGP support
300 try_unsupported: try to drive unsupported chipsets 300 try_unsupported: try to drive unsupported chipsets
301 (may crash computer or cause data corruption) 301 (may crash computer or cause data corruption)
302 302
303 aha152x= [HW,SCSI] 303 aha152x= [HW,SCSI]
304 See Documentation/scsi/aha152x.txt. 304 See Documentation/scsi/aha152x.txt.
305 305
306 aha1542= [HW,SCSI] 306 aha1542= [HW,SCSI]
307 Format: <portbase>[,<buson>,<busoff>[,<dmaspeed>]] 307 Format: <portbase>[,<buson>,<busoff>[,<dmaspeed>]]
308 308
309 aic7xxx= [HW,SCSI] 309 aic7xxx= [HW,SCSI]
310 See Documentation/scsi/aic7xxx.txt. 310 See Documentation/scsi/aic7xxx.txt.
311 311
312 aic79xx= [HW,SCSI] 312 aic79xx= [HW,SCSI]
313 See Documentation/scsi/aic79xx.txt. 313 See Documentation/scsi/aic79xx.txt.
314 314
315 alignment= [KNL,ARM] 315 alignment= [KNL,ARM]
316 Allow the default userspace alignment fault handler 316 Allow the default userspace alignment fault handler
317 behaviour to be specified. Bit 0 enables warnings, 317 behaviour to be specified. Bit 0 enables warnings,
318 bit 1 enables fixups, and bit 2 sends a segfault. 318 bit 1 enables fixups, and bit 2 sends a segfault.
319 319
320 amd_iommu= [HW,X86-84] 320 amd_iommu= [HW,X86-84]
321 Pass parameters to the AMD IOMMU driver in the system. 321 Pass parameters to the AMD IOMMU driver in the system.
322 Possible values are: 322 Possible values are:
323 fullflush - enable flushing of IO/TLB entries when 323 fullflush - enable flushing of IO/TLB entries when
324 they are unmapped. Otherwise they are 324 they are unmapped. Otherwise they are
325 flushed before they will be reused, which 325 flushed before they will be reused, which
326 is a lot of faster 326 is a lot of faster
327 off - do not initialize any AMD IOMMU found in 327 off - do not initialize any AMD IOMMU found in
328 the system 328 the system
329 329
330 amijoy.map= [HW,JOY] Amiga joystick support 330 amijoy.map= [HW,JOY] Amiga joystick support
331 Map of devices attached to JOY0DAT and JOY1DAT 331 Map of devices attached to JOY0DAT and JOY1DAT
332 Format: <a>,<b> 332 Format: <a>,<b>
333 See also Documentation/kernel/input/joystick.txt 333 See also Documentation/kernel/input/joystick.txt
334 334
335 analog.map= [HW,JOY] Analog joystick and gamepad support 335 analog.map= [HW,JOY] Analog joystick and gamepad support
336 Specifies type or capabilities of an analog joystick 336 Specifies type or capabilities of an analog joystick
337 connected to one of 16 gameports 337 connected to one of 16 gameports
338 Format: <type1>,<type2>,..<type16> 338 Format: <type1>,<type2>,..<type16>
339 339
340 apc= [HW,SPARC] 340 apc= [HW,SPARC]
341 Power management functions (SPARCstation-4/5 + deriv.) 341 Power management functions (SPARCstation-4/5 + deriv.)
342 Format: noidle 342 Format: noidle
343 Disable APC CPU standby support. SPARCstation-Fox does 343 Disable APC CPU standby support. SPARCstation-Fox does
344 not play well with APC CPU idle - disable it if you have 344 not play well with APC CPU idle - disable it if you have
345 APC and your system crashes randomly. 345 APC and your system crashes randomly.
346 346
347 apic= [APIC,X86-32] Advanced Programmable Interrupt Controller 347 apic= [APIC,X86-32] Advanced Programmable Interrupt Controller
348 Change the output verbosity whilst booting 348 Change the output verbosity whilst booting
349 Format: { quiet (default) | verbose | debug } 349 Format: { quiet (default) | verbose | debug }
350 Change the amount of debugging information output 350 Change the amount of debugging information output
351 when initialising the APIC and IO-APIC components. 351 when initialising the APIC and IO-APIC components.
352 352
353 autoconf= [IPV6] 353 autoconf= [IPV6]
354 See Documentation/networking/ipv6.txt. 354 See Documentation/networking/ipv6.txt.
355 355
356 show_lapic= [APIC,X86] Advanced Programmable Interrupt Controller 356 show_lapic= [APIC,X86] Advanced Programmable Interrupt Controller
357 Limit apic dumping. The parameter defines the maximal 357 Limit apic dumping. The parameter defines the maximal
358 number of local apics being dumped. Also it is possible 358 number of local apics being dumped. Also it is possible
359 to set it to "all" by meaning -- no limit here. 359 to set it to "all" by meaning -- no limit here.
360 Format: { 1 (default) | 2 | ... | all }. 360 Format: { 1 (default) | 2 | ... | all }.
361 The parameter valid if only apic=debug or 361 The parameter valid if only apic=debug or
362 apic=verbose is specified. 362 apic=verbose is specified.
363 Example: apic=debug show_lapic=all 363 Example: apic=debug show_lapic=all
364 364
365 apm= [APM] Advanced Power Management 365 apm= [APM] Advanced Power Management
366 See header of arch/x86/kernel/apm_32.c. 366 See header of arch/x86/kernel/apm_32.c.
367 367
368 arcrimi= [HW,NET] ARCnet - "RIM I" (entirely mem-mapped) cards 368 arcrimi= [HW,NET] ARCnet - "RIM I" (entirely mem-mapped) cards
369 Format: <io>,<irq>,<nodeID> 369 Format: <io>,<irq>,<nodeID>
370 370
371 ataflop= [HW,M68k] 371 ataflop= [HW,M68k]
372 372
373 atarimouse= [HW,MOUSE] Atari Mouse 373 atarimouse= [HW,MOUSE] Atari Mouse
374 374
375 atascsi= [HW,SCSI] Atari SCSI 375 atascsi= [HW,SCSI] Atari SCSI
376 376
377 atkbd.extra= [HW] Enable extra LEDs and keys on IBM RapidAccess, 377 atkbd.extra= [HW] Enable extra LEDs and keys on IBM RapidAccess,
378 EzKey and similar keyboards 378 EzKey and similar keyboards
379 379
380 atkbd.reset= [HW] Reset keyboard during initialization 380 atkbd.reset= [HW] Reset keyboard during initialization
381 381
382 atkbd.set= [HW] Select keyboard code set 382 atkbd.set= [HW] Select keyboard code set
383 Format: <int> (2 = AT (default), 3 = PS/2) 383 Format: <int> (2 = AT (default), 3 = PS/2)
384 384
385 atkbd.scroll= [HW] Enable scroll wheel on MS Office and similar 385 atkbd.scroll= [HW] Enable scroll wheel on MS Office and similar
386 keyboards 386 keyboards
387 387
388 atkbd.softraw= [HW] Choose between synthetic and real raw mode 388 atkbd.softraw= [HW] Choose between synthetic and real raw mode
389 Format: <bool> (0 = real, 1 = synthetic (default)) 389 Format: <bool> (0 = real, 1 = synthetic (default))
390 390
391 atkbd.softrepeat= [HW] 391 atkbd.softrepeat= [HW]
392 Use software keyboard repeat 392 Use software keyboard repeat
393 393
394 autotest [IA64] 394 autotest [IA64]
395 395
396 baycom_epp= [HW,AX25] 396 baycom_epp= [HW,AX25]
397 Format: <io>,<mode> 397 Format: <io>,<mode>
398 398
399 baycom_par= [HW,AX25] BayCom Parallel Port AX.25 Modem 399 baycom_par= [HW,AX25] BayCom Parallel Port AX.25 Modem
400 Format: <io>,<mode> 400 Format: <io>,<mode>
401 See header of drivers/net/hamradio/baycom_par.c. 401 See header of drivers/net/hamradio/baycom_par.c.
402 402
403 baycom_ser_fdx= [HW,AX25] 403 baycom_ser_fdx= [HW,AX25]
404 BayCom Serial Port AX.25 Modem (Full Duplex Mode) 404 BayCom Serial Port AX.25 Modem (Full Duplex Mode)
405 Format: <io>,<irq>,<mode>[,<baud>] 405 Format: <io>,<irq>,<mode>[,<baud>]
406 See header of drivers/net/hamradio/baycom_ser_fdx.c. 406 See header of drivers/net/hamradio/baycom_ser_fdx.c.
407 407
408 baycom_ser_hdx= [HW,AX25] 408 baycom_ser_hdx= [HW,AX25]
409 BayCom Serial Port AX.25 Modem (Half Duplex Mode) 409 BayCom Serial Port AX.25 Modem (Half Duplex Mode)
410 Format: <io>,<irq>,<mode> 410 Format: <io>,<irq>,<mode>
411 See header of drivers/net/hamradio/baycom_ser_hdx.c. 411 See header of drivers/net/hamradio/baycom_ser_hdx.c.
412 412
413 boot_delay= Milliseconds to delay each printk during boot. 413 boot_delay= Milliseconds to delay each printk during boot.
414 Values larger than 10 seconds (10000) are changed to 414 Values larger than 10 seconds (10000) are changed to
415 no delay (0). 415 no delay (0).
416 Format: integer 416 Format: integer
417 417
418 bootmem_debug [KNL] Enable bootmem allocator debug messages. 418 bootmem_debug [KNL] Enable bootmem allocator debug messages.
419 419
420 bttv.card= [HW,V4L] bttv (bt848 + bt878 based grabber cards) 420 bttv.card= [HW,V4L] bttv (bt848 + bt878 based grabber cards)
421 bttv.radio= Most important insmod options are available as 421 bttv.radio= Most important insmod options are available as
422 kernel args too. 422 kernel args too.
423 bttv.pll= See Documentation/video4linux/bttv/Insmod-options 423 bttv.pll= See Documentation/video4linux/bttv/Insmod-options
424 bttv.tuner= and Documentation/video4linux/bttv/CARDLIST 424 bttv.tuner= and Documentation/video4linux/bttv/CARDLIST
425 425
426 BusLogic= [HW,SCSI] 426 BusLogic= [HW,SCSI]
427 See drivers/scsi/BusLogic.c, comment before function 427 See drivers/scsi/BusLogic.c, comment before function
428 BusLogic_ParseDriverOptions(). 428 BusLogic_ParseDriverOptions().
429 429
430 c101= [NET] Moxa C101 synchronous serial card 430 c101= [NET] Moxa C101 synchronous serial card
431 431
432 cachesize= [BUGS=X86-32] Override level 2 CPU cache size detection. 432 cachesize= [BUGS=X86-32] Override level 2 CPU cache size detection.
433 Sometimes CPU hardware bugs make them report the cache 433 Sometimes CPU hardware bugs make them report the cache
434 size incorrectly. The kernel will attempt work arounds 434 size incorrectly. The kernel will attempt work arounds
435 to fix known problems, but for some CPUs it is not 435 to fix known problems, but for some CPUs it is not
436 possible to determine what the correct size should be. 436 possible to determine what the correct size should be.
437 This option provides an override for these situations. 437 This option provides an override for these situations.
438 438
439 capability.disable= 439 capability.disable=
440 [SECURITY] Disable capabilities. This would normally 440 [SECURITY] Disable capabilities. This would normally
441 be used only if an alternative security model is to be 441 be used only if an alternative security model is to be
442 configured. Potentially dangerous and should only be 442 configured. Potentially dangerous and should only be
443 used if you are entirely sure of the consequences. 443 used if you are entirely sure of the consequences.
444 444
445 ccw_timeout_log [S390] 445 ccw_timeout_log [S390]
446 See Documentation/s390/CommonIO for details. 446 See Documentation/s390/CommonIO for details.
447 447
448 cgroup_disable= [KNL] Disable a particular controller 448 cgroup_disable= [KNL] Disable a particular controller
449 Format: {name of the controller(s) to disable} 449 Format: {name of the controller(s) to disable}
450 {Currently supported controllers - "memory"} 450 {Currently supported controllers - "memory"}
451 451
452 checkreqprot [SELINUX] Set initial checkreqprot flag value. 452 checkreqprot [SELINUX] Set initial checkreqprot flag value.
453 Format: { "0" | "1" } 453 Format: { "0" | "1" }
454 See security/selinux/Kconfig help text. 454 See security/selinux/Kconfig help text.
455 0 -- check protection applied by kernel (includes 455 0 -- check protection applied by kernel (includes
456 any implied execute protection). 456 any implied execute protection).
457 1 -- check protection requested by application. 457 1 -- check protection requested by application.
458 Default value is set via a kernel config option. 458 Default value is set via a kernel config option.
459 Value can be changed at runtime via 459 Value can be changed at runtime via
460 /selinux/checkreqprot. 460 /selinux/checkreqprot.
461 461
462 cio_ignore= [S390] 462 cio_ignore= [S390]
463 See Documentation/s390/CommonIO for details. 463 See Documentation/s390/CommonIO for details.
464 464
465 clock= [BUGS=X86-32, HW] gettimeofday clocksource override. 465 clock= [BUGS=X86-32, HW] gettimeofday clocksource override.
466 [Deprecated] 466 [Deprecated]
467 Forces specified clocksource (if available) to be used 467 Forces specified clocksource (if available) to be used
468 when calculating gettimeofday(). If specified 468 when calculating gettimeofday(). If specified
469 clocksource is not available, it defaults to PIT. 469 clocksource is not available, it defaults to PIT.
470 Format: { pit | tsc | cyclone | pmtmr } 470 Format: { pit | tsc | cyclone | pmtmr }
471 471
472 clocksource= [GENERIC_TIME] Override the default clocksource 472 clocksource= [GENERIC_TIME] Override the default clocksource
473 Format: <string> 473 Format: <string>
474 Override the default clocksource and use the clocksource 474 Override the default clocksource and use the clocksource
475 with the name specified. 475 with the name specified.
476 Some clocksource names to choose from, depending on 476 Some clocksource names to choose from, depending on
477 the platform: 477 the platform:
478 [all] jiffies (this is the base, fallback clocksource) 478 [all] jiffies (this is the base, fallback clocksource)
479 [ACPI] acpi_pm 479 [ACPI] acpi_pm
480 [ARM] imx_timer1,OSTS,netx_timer,mpu_timer2, 480 [ARM] imx_timer1,OSTS,netx_timer,mpu_timer2,
481 pxa_timer,timer3,32k_counter,timer0_1 481 pxa_timer,timer3,32k_counter,timer0_1
482 [AVR32] avr32 482 [AVR32] avr32
483 [X86-32] pit,hpet,tsc,vmi-timer; 483 [X86-32] pit,hpet,tsc,vmi-timer;
484 scx200_hrt on Geode; cyclone on IBM x440 484 scx200_hrt on Geode; cyclone on IBM x440
485 [MIPS] MIPS 485 [MIPS] MIPS
486 [PARISC] cr16 486 [PARISC] cr16
487 [S390] tod 487 [S390] tod
488 [SH] SuperH 488 [SH] SuperH
489 [SPARC64] tick 489 [SPARC64] tick
490 [X86-64] hpet,tsc 490 [X86-64] hpet,tsc
491 491
492 clearcpuid=BITNUM [X86] 492 clearcpuid=BITNUM [X86]
493 Disable CPUID feature X for the kernel. See 493 Disable CPUID feature X for the kernel. See
494 arch/x86/include/asm/cpufeature.h for the valid bit 494 arch/x86/include/asm/cpufeature.h for the valid bit
495 numbers. Note the Linux specific bits are not necessarily 495 numbers. Note the Linux specific bits are not necessarily
496 stable over kernel options, but the vendor specific 496 stable over kernel options, but the vendor specific
497 ones should be. 497 ones should be.
498 Also note that user programs calling CPUID directly 498 Also note that user programs calling CPUID directly
499 or using the feature without checking anything 499 or using the feature without checking anything
500 will still see it. This just prevents it from 500 will still see it. This just prevents it from
501 being used by the kernel or shown in /proc/cpuinfo. 501 being used by the kernel or shown in /proc/cpuinfo.
502 Also note the kernel might malfunction if you disable 502 Also note the kernel might malfunction if you disable
503 some critical bits. 503 some critical bits.
504 504
505 cmo_free_hint= [PPC] Format: { yes | no } 505 cmo_free_hint= [PPC] Format: { yes | no }
506 Specify whether pages are marked as being inactive 506 Specify whether pages are marked as being inactive
507 when they are freed. This is used in CMO environments 507 when they are freed. This is used in CMO environments
508 to determine OS memory pressure for page stealing by 508 to determine OS memory pressure for page stealing by
509 a hypervisor. 509 a hypervisor.
510 Default: yes 510 Default: yes
511 511
512 code_bytes [X86] How many bytes of object code to print 512 code_bytes [X86] How many bytes of object code to print
513 in an oops report. 513 in an oops report.
514 Range: 0 - 8192 514 Range: 0 - 8192
515 Default: 64 515 Default: 64
516 516
517 com20020= [HW,NET] ARCnet - COM20020 chipset 517 com20020= [HW,NET] ARCnet - COM20020 chipset
518 Format: 518 Format:
519 <io>[,<irq>[,<nodeID>[,<backplane>[,<ckp>[,<timeout>]]]]] 519 <io>[,<irq>[,<nodeID>[,<backplane>[,<ckp>[,<timeout>]]]]]
520 520
521 com90io= [HW,NET] ARCnet - COM90xx chipset (IO-mapped buffers) 521 com90io= [HW,NET] ARCnet - COM90xx chipset (IO-mapped buffers)
522 Format: <io>[,<irq>] 522 Format: <io>[,<irq>]
523 523
524 com90xx= [HW,NET] 524 com90xx= [HW,NET]
525 ARCnet - COM90xx chipset (memory-mapped buffers) 525 ARCnet - COM90xx chipset (memory-mapped buffers)
526 Format: <io>[,<irq>[,<memstart>]] 526 Format: <io>[,<irq>[,<memstart>]]
527 527
528 condev= [HW,S390] console device 528 condev= [HW,S390] console device
529 conmode= 529 conmode=
530 530
531 console= [KNL] Output console device and options. 531 console= [KNL] Output console device and options.
532 532
533 tty<n> Use the virtual console device <n>. 533 tty<n> Use the virtual console device <n>.
534 534
535 ttyS<n>[,options] 535 ttyS<n>[,options]
536 ttyUSB0[,options] 536 ttyUSB0[,options]
537 Use the specified serial port. The options are of 537 Use the specified serial port. The options are of
538 the form "bbbbpnf", where "bbbb" is the baud rate, 538 the form "bbbbpnf", where "bbbb" is the baud rate,
539 "p" is parity ("n", "o", or "e"), "n" is number of 539 "p" is parity ("n", "o", or "e"), "n" is number of
540 bits, and "f" is flow control ("r" for RTS or 540 bits, and "f" is flow control ("r" for RTS or
541 omit it). Default is "9600n8". 541 omit it). Default is "9600n8".
542 542
543 See Documentation/serial-console.txt for more 543 See Documentation/serial-console.txt for more
544 information. See 544 information. See
545 Documentation/networking/netconsole.txt for an 545 Documentation/networking/netconsole.txt for an
546 alternative. 546 alternative.
547 547
548 uart[8250],io,<addr>[,options] 548 uart[8250],io,<addr>[,options]
549 uart[8250],mmio,<addr>[,options] 549 uart[8250],mmio,<addr>[,options]
550 Start an early, polled-mode console on the 8250/16550 550 Start an early, polled-mode console on the 8250/16550
551 UART at the specified I/O port or MMIO address, 551 UART at the specified I/O port or MMIO address,
552 switching to the matching ttyS device later. The 552 switching to the matching ttyS device later. The
553 options are the same as for ttyS, above. 553 options are the same as for ttyS, above.
554 554
555 If the device connected to the port is not a TTY but a braille 555 If the device connected to the port is not a TTY but a braille
556 device, prepend "brl," before the device type, for instance 556 device, prepend "brl," before the device type, for instance
557 console=brl,ttyS0 557 console=brl,ttyS0
558 For now, only VisioBraille is supported. 558 For now, only VisioBraille is supported.
559 559
560 consoleblank= [KNL] The console blank (screen saver) timeout in 560 consoleblank= [KNL] The console blank (screen saver) timeout in
561 seconds. Defaults to 10*60 = 10mins. A value of 0 561 seconds. Defaults to 10*60 = 10mins. A value of 0
562 disables the blank timer. 562 disables the blank timer.
563 563
564 coredump_filter= 564 coredump_filter=
565 [KNL] Change the default value for 565 [KNL] Change the default value for
566 /proc/<pid>/coredump_filter. 566 /proc/<pid>/coredump_filter.
567 See also Documentation/filesystems/proc.txt. 567 See also Documentation/filesystems/proc.txt.
568 568
569 cpcihp_generic= [HW,PCI] Generic port I/O CompactPCI driver 569 cpcihp_generic= [HW,PCI] Generic port I/O CompactPCI driver
570 Format: 570 Format:
571 <first_slot>,<last_slot>,<port>,<enum_bit>[,<debug>] 571 <first_slot>,<last_slot>,<port>,<enum_bit>[,<debug>]
572 572
573 crashkernel=nn[KMG]@ss[KMG] 573 crashkernel=nn[KMG]@ss[KMG]
574 [KNL] Reserve a chunk of physical memory to 574 [KNL] Reserve a chunk of physical memory to
575 hold a kernel to switch to with kexec on panic. 575 hold a kernel to switch to with kexec on panic.
576 576
577 crashkernel=range1:size1[,range2:size2,...][@offset] 577 crashkernel=range1:size1[,range2:size2,...][@offset]
578 [KNL] Same as above, but depends on the memory 578 [KNL] Same as above, but depends on the memory
579 in the running system. The syntax of range is 579 in the running system. The syntax of range is
580 start-[end] where start and end are both 580 start-[end] where start and end are both
581 a memory unit (amount[KMG]). See also 581 a memory unit (amount[KMG]). See also
582 Documentation/kdump/kdump.txt for a example. 582 Documentation/kdump/kdump.txt for a example.
583 583
584 cs89x0_dma= [HW,NET] 584 cs89x0_dma= [HW,NET]
585 Format: <dma> 585 Format: <dma>
586 586
587 cs89x0_media= [HW,NET] 587 cs89x0_media= [HW,NET]
588 Format: { rj45 | aui | bnc } 588 Format: { rj45 | aui | bnc }
589 589
590 dasd= [HW,NET] 590 dasd= [HW,NET]
591 See header of drivers/s390/block/dasd_devmap.c. 591 See header of drivers/s390/block/dasd_devmap.c.
592 592
593 db9.dev[2|3]= [HW,JOY] Multisystem joystick support via parallel port 593 db9.dev[2|3]= [HW,JOY] Multisystem joystick support via parallel port
594 (one device per port) 594 (one device per port)
595 Format: <port#>,<type> 595 Format: <port#>,<type>
596 See also Documentation/input/joystick-parport.txt 596 See also Documentation/input/joystick-parport.txt
597 597
598 debug [KNL] Enable kernel debugging (events log level). 598 debug [KNL] Enable kernel debugging (events log level).
599 599
600 debug_locks_verbose= 600 debug_locks_verbose=
601 [KNL] verbose self-tests 601 [KNL] verbose self-tests
602 Format=<0|1> 602 Format=<0|1>
603 Print debugging info while doing the locking API 603 Print debugging info while doing the locking API
604 self-tests. 604 self-tests.
605 We default to 0 (no extra messages), setting it to 605 We default to 0 (no extra messages), setting it to
606 1 will print _a lot_ more information - normally 606 1 will print _a lot_ more information - normally
607 only useful to kernel developers. 607 only useful to kernel developers.
608 608
609 debug_objects [KNL] Enable object debugging 609 debug_objects [KNL] Enable object debugging
610 610
611 no_debug_objects 611 no_debug_objects
612 [KNL] Disable object debugging 612 [KNL] Disable object debugging
613 613
614 debugpat [X86] Enable PAT debugging 614 debugpat [X86] Enable PAT debugging
615 615
616 decnet.addr= [HW,NET] 616 decnet.addr= [HW,NET]
617 Format: <area>[,<node>] 617 Format: <area>[,<node>]
618 See also Documentation/networking/decnet.txt. 618 See also Documentation/networking/decnet.txt.
619 619
620 default_hugepagesz= 620 default_hugepagesz=
621 [same as hugepagesz=] The size of the default 621 [same as hugepagesz=] The size of the default
622 HugeTLB page size. This is the size represented by 622 HugeTLB page size. This is the size represented by
623 the legacy /proc/ hugepages APIs, used for SHM, and 623 the legacy /proc/ hugepages APIs, used for SHM, and
624 default size when mounting hugetlbfs filesystems. 624 default size when mounting hugetlbfs filesystems.
625 Defaults to the default architecture's huge page size 625 Defaults to the default architecture's huge page size
626 if not specified. 626 if not specified.
627 627
628 dhash_entries= [KNL] 628 dhash_entries= [KNL]
629 Set number of hash buckets for dentry cache. 629 Set number of hash buckets for dentry cache.
630 630
631 digi= [HW,SERIAL] 631 digi= [HW,SERIAL]
632 IO parameters + enable/disable command. 632 IO parameters + enable/disable command.
633 633
634 digiepca= [HW,SERIAL] 634 digiepca= [HW,SERIAL]
635 See drivers/char/README.epca and 635 See drivers/char/README.epca and
636 Documentation/serial/digiepca.txt. 636 Documentation/serial/digiepca.txt.
637 637
638 disable= [IPV6] 638 disable= [IPV6]
639 See Documentation/networking/ipv6.txt. 639 See Documentation/networking/ipv6.txt.
640 640
641 disable_ipv6= [IPV6] 641 disable_ipv6= [IPV6]
642 See Documentation/networking/ipv6.txt. 642 See Documentation/networking/ipv6.txt.
643 643
644 disable_mtrr_cleanup [X86] 644 disable_mtrr_cleanup [X86]
645 The kernel tries to adjust MTRR layout from continuous 645 The kernel tries to adjust MTRR layout from continuous
646 to discrete, to make X server driver able to add WB 646 to discrete, to make X server driver able to add WB
647 entry later. This parameter disables that. 647 entry later. This parameter disables that.
648 648
649 disable_mtrr_trim [X86, Intel and AMD only] 649 disable_mtrr_trim [X86, Intel and AMD only]
650 By default the kernel will trim any uncacheable 650 By default the kernel will trim any uncacheable
651 memory out of your available memory pool based on 651 memory out of your available memory pool based on
652 MTRR settings. This parameter disables that behavior, 652 MTRR settings. This parameter disables that behavior,
653 possibly causing your machine to run very slowly. 653 possibly causing your machine to run very slowly.
654 654
655 disable_timer_pin_1 [X86] 655 disable_timer_pin_1 [X86]
656 Disable PIN 1 of APIC timer 656 Disable PIN 1 of APIC timer
657 Can be useful to work around chipset bugs. 657 Can be useful to work around chipset bugs.
658 658
659 dmasound= [HW,OSS] Sound subsystem buffers 659 dmasound= [HW,OSS] Sound subsystem buffers
660 660
661 dma_debug=off If the kernel is compiled with DMA_API_DEBUG support, 661 dma_debug=off If the kernel is compiled with DMA_API_DEBUG support,
662 this option disables the debugging code at boot. 662 this option disables the debugging code at boot.
663 663
664 dma_debug_entries=<number> 664 dma_debug_entries=<number>
665 This option allows to tune the number of preallocated 665 This option allows to tune the number of preallocated
666 entries for DMA-API debugging code. One entry is 666 entries for DMA-API debugging code. One entry is
667 required per DMA-API allocation. Use this if the 667 required per DMA-API allocation. Use this if the
668 DMA-API debugging code disables itself because the 668 DMA-API debugging code disables itself because the
669 architectural default is too low. 669 architectural default is too low.
670 670
671 dma_debug_driver=<driver_name> 671 dma_debug_driver=<driver_name>
672 With this option the DMA-API debugging driver 672 With this option the DMA-API debugging driver
673 filter feature can be enabled at boot time. Just 673 filter feature can be enabled at boot time. Just
674 pass the driver to filter for as the parameter. 674 pass the driver to filter for as the parameter.
675 The filter can be disabled or changed to another 675 The filter can be disabled or changed to another
676 driver later using sysfs. 676 driver later using sysfs.
677 677
678 dscc4.setup= [NET] 678 dscc4.setup= [NET]
679 679
680 dtc3181e= [HW,SCSI] 680 dtc3181e= [HW,SCSI]
681 681
682 dynamic_printk Enables pr_debug()/dev_dbg() calls if 682 dynamic_printk Enables pr_debug()/dev_dbg() calls if
683 CONFIG_DYNAMIC_PRINTK_DEBUG has been enabled. 683 CONFIG_DYNAMIC_PRINTK_DEBUG has been enabled.
684 These can also be switched on/off via 684 These can also be switched on/off via
685 <debugfs>/dynamic_printk/modules 685 <debugfs>/dynamic_printk/modules
686 686
687 earlycon= [KNL] Output early console device and options. 687 earlycon= [KNL] Output early console device and options.
688 uart[8250],io,<addr>[,options] 688 uart[8250],io,<addr>[,options]
689 uart[8250],mmio,<addr>[,options] 689 uart[8250],mmio,<addr>[,options]
690 Start an early, polled-mode console on the 8250/16550 690 Start an early, polled-mode console on the 8250/16550
691 UART at the specified I/O port or MMIO address. 691 UART at the specified I/O port or MMIO address.
692 The options are the same as for ttyS, above. 692 The options are the same as for ttyS, above.
693 693
694 earlyprintk= [X86,SH,BLACKFIN] 694 earlyprintk= [X86,SH,BLACKFIN]
695 earlyprintk=vga 695 earlyprintk=vga
696 earlyprintk=serial[,ttySn[,baudrate]] 696 earlyprintk=serial[,ttySn[,baudrate]]
697 earlyprintk=ttySn[,baudrate] 697 earlyprintk=ttySn[,baudrate]
698 earlyprintk=dbgp[debugController#] 698 earlyprintk=dbgp[debugController#]
699 699
700 Append ",keep" to not disable it when the real console 700 Append ",keep" to not disable it when the real console
701 takes over. 701 takes over.
702 702
703 Only vga or serial or usb debug port at a time. 703 Only vga or serial or usb debug port at a time.
704 704
705 Currently only ttyS0 and ttyS1 are supported. 705 Currently only ttyS0 and ttyS1 are supported.
706 706
707 Interaction with the standard serial driver is not 707 Interaction with the standard serial driver is not
708 very good. 708 very good.
709 709
710 The VGA output is eventually overwritten by the real 710 The VGA output is eventually overwritten by the real
711 console. 711 console.
712 712
713 ekgdboc= [X86,KGDB] Allow early kernel console debugging 713 ekgdboc= [X86,KGDB] Allow early kernel console debugging
714 ekgdboc=kbd 714 ekgdboc=kbd
715 715
716 This is desgined to be used in conjunction with 716 This is desgined to be used in conjunction with
717 the boot argument: earlyprintk=vga 717 the boot argument: earlyprintk=vga
718 718
719 eata= [HW,SCSI] 719 eata= [HW,SCSI]
720 720
721 edd= [EDD] 721 edd= [EDD]
722 Format: {"off" | "on" | "skip[mbr]"} 722 Format: {"off" | "on" | "skip[mbr]"}
723 723
724 eisa_irq_edge= [PARISC,HW] 724 eisa_irq_edge= [PARISC,HW]
725 See header of drivers/parisc/eisa.c. 725 See header of drivers/parisc/eisa.c.
726 726
727 elanfreq= [X86-32] 727 elanfreq= [X86-32]
728 See comment before function elanfreq_setup() in 728 See comment before function elanfreq_setup() in
729 arch/x86/kernel/cpu/cpufreq/elanfreq.c. 729 arch/x86/kernel/cpu/cpufreq/elanfreq.c.
730 730
731 elevator= [IOSCHED] 731 elevator= [IOSCHED]
732 Format: {"anticipatory" | "cfq" | "deadline" | "noop"} 732 Format: {"anticipatory" | "cfq" | "deadline" | "noop"}
733 See Documentation/block/as-iosched.txt and 733 See Documentation/block/as-iosched.txt and
734 Documentation/block/deadline-iosched.txt for details. 734 Documentation/block/deadline-iosched.txt for details.
735 735
736 elfcorehdr= [IA64,PPC,SH,X86] 736 elfcorehdr= [IA64,PPC,SH,X86]
737 Specifies physical address of start of kernel core 737 Specifies physical address of start of kernel core
738 image elf header. Generally kexec loader will 738 image elf header. Generally kexec loader will
739 pass this option to capture kernel. 739 pass this option to capture kernel.
740 See Documentation/kdump/kdump.txt for details. 740 See Documentation/kdump/kdump.txt for details.
741 741
742 enable_mtrr_cleanup [X86] 742 enable_mtrr_cleanup [X86]
743 The kernel tries to adjust MTRR layout from continuous 743 The kernel tries to adjust MTRR layout from continuous
744 to discrete, to make X server driver able to add WB 744 to discrete, to make X server driver able to add WB
745 entry later. This parameter enables that. 745 entry later. This parameter enables that.
746 746
747 enable_timer_pin_1 [X86] 747 enable_timer_pin_1 [X86]
748 Enable PIN 1 of APIC timer 748 Enable PIN 1 of APIC timer
749 Can be useful to work around chipset bugs 749 Can be useful to work around chipset bugs
750 (in particular on some ATI chipsets). 750 (in particular on some ATI chipsets).
751 The kernel tries to set a reasonable default. 751 The kernel tries to set a reasonable default.
752 752
753 enforcing [SELINUX] Set initial enforcing status. 753 enforcing [SELINUX] Set initial enforcing status.
754 Format: {"0" | "1"} 754 Format: {"0" | "1"}
755 See security/selinux/Kconfig help text. 755 See security/selinux/Kconfig help text.
756 0 -- permissive (log only, no denials). 756 0 -- permissive (log only, no denials).
757 1 -- enforcing (deny and log). 757 1 -- enforcing (deny and log).
758 Default value is 0. 758 Default value is 0.
759 Value can be changed at runtime via /selinux/enforce. 759 Value can be changed at runtime via /selinux/enforce.
760 760
761 ether= [HW,NET] Ethernet cards parameters 761 ether= [HW,NET] Ethernet cards parameters
762 This option is obsoleted by the "netdev=" option, which 762 This option is obsoleted by the "netdev=" option, which
763 has equivalent usage. See its documentation for details. 763 has equivalent usage. See its documentation for details.
764 764
765 failslab= 765 failslab=
766 fail_page_alloc= 766 fail_page_alloc=
767 fail_make_request=[KNL] 767 fail_make_request=[KNL]
768 General fault injection mechanism. 768 General fault injection mechanism.
769 Format: <interval>,<probability>,<space>,<times> 769 Format: <interval>,<probability>,<space>,<times>
770 See also /Documentation/fault-injection/. 770 See also /Documentation/fault-injection/.
771 771
772 fd_mcs= [HW,SCSI] 772 fd_mcs= [HW,SCSI]
773 See header of drivers/scsi/fd_mcs.c. 773 See header of drivers/scsi/fd_mcs.c.
774 774
775 fdomain= [HW,SCSI] 775 fdomain= [HW,SCSI]
776 See header of drivers/scsi/fdomain.c. 776 See header of drivers/scsi/fdomain.c.
777 777
778 floppy= [HW] 778 floppy= [HW]
779 See Documentation/blockdev/floppy.txt. 779 See Documentation/blockdev/floppy.txt.
780 780
781 force_pal_cache_flush 781 force_pal_cache_flush
782 [IA-64] Avoid check_sal_cache_flush which may hang on 782 [IA-64] Avoid check_sal_cache_flush which may hang on
783 buggy SAL_CACHE_FLUSH implementations. Using this 783 buggy SAL_CACHE_FLUSH implementations. Using this
784 parameter will force ia64_sal_cache_flush to call 784 parameter will force ia64_sal_cache_flush to call
785 ia64_pal_cache_flush instead of SAL_CACHE_FLUSH. 785 ia64_pal_cache_flush instead of SAL_CACHE_FLUSH.
786 786
787 ftrace=[tracer] 787 ftrace=[tracer]
788 [FTRACE] will set and start the specified tracer 788 [FTRACE] will set and start the specified tracer
789 as early as possible in order to facilitate early 789 as early as possible in order to facilitate early
790 boot debugging. 790 boot debugging.
791 791
792 ftrace_dump_on_oops[=orig_cpu] 792 ftrace_dump_on_oops[=orig_cpu]
793 [FTRACE] will dump the trace buffers on oops. 793 [FTRACE] will dump the trace buffers on oops.
794 If no parameter is passed, ftrace will dump 794 If no parameter is passed, ftrace will dump
795 buffers of all CPUs, but if you pass orig_cpu, it will 795 buffers of all CPUs, but if you pass orig_cpu, it will
796 dump only the buffer of the CPU that triggered the 796 dump only the buffer of the CPU that triggered the
797 oops. 797 oops.
798 798
799 ftrace_filter=[function-list] 799 ftrace_filter=[function-list]
800 [FTRACE] Limit the functions traced by the function 800 [FTRACE] Limit the functions traced by the function
801 tracer at boot up. function-list is a comma separated 801 tracer at boot up. function-list is a comma separated
802 list of functions. This list can be changed at run 802 list of functions. This list can be changed at run
803 time by the set_ftrace_filter file in the debugfs 803 time by the set_ftrace_filter file in the debugfs
804 tracing directory. 804 tracing directory.
805 805
806 ftrace_notrace=[function-list] 806 ftrace_notrace=[function-list]
807 [FTRACE] Do not trace the functions specified in 807 [FTRACE] Do not trace the functions specified in
808 function-list. This list can be changed at run time 808 function-list. This list can be changed at run time
809 by the set_ftrace_notrace file in the debugfs 809 by the set_ftrace_notrace file in the debugfs
810 tracing directory. 810 tracing directory.
811 811
812 ftrace_graph_filter=[function-list] 812 ftrace_graph_filter=[function-list]
813 [FTRACE] Limit the top level callers functions traced 813 [FTRACE] Limit the top level callers functions traced
814 by the function graph tracer at boot up. 814 by the function graph tracer at boot up.
815 function-list is a comma separated list of functions 815 function-list is a comma separated list of functions
816 that can be changed at run time by the 816 that can be changed at run time by the
817 set_graph_function file in the debugfs tracing directory. 817 set_graph_function file in the debugfs tracing directory.
818 818
819 gamecon.map[2|3]= 819 gamecon.map[2|3]=
820 [HW,JOY] Multisystem joystick and NES/SNES/PSX pad 820 [HW,JOY] Multisystem joystick and NES/SNES/PSX pad
821 support via parallel port (up to 5 devices per port) 821 support via parallel port (up to 5 devices per port)
822 Format: <port#>,<pad1>,<pad2>,<pad3>,<pad4>,<pad5> 822 Format: <port#>,<pad1>,<pad2>,<pad3>,<pad4>,<pad5>
823 See also Documentation/input/joystick-parport.txt 823 See also Documentation/input/joystick-parport.txt
824 824
825 gamma= [HW,DRM] 825 gamma= [HW,DRM]
826 826
827 gart_fix_e820= [X86_64] disable the fix e820 for K8 GART 827 gart_fix_e820= [X86_64] disable the fix e820 for K8 GART
828 Format: off | on 828 Format: off | on
829 default: on 829 default: on
830 830
831 gcov_persist= [GCOV] When non-zero (default), profiling data for 831 gcov_persist= [GCOV] When non-zero (default), profiling data for
832 kernel modules is saved and remains accessible via 832 kernel modules is saved and remains accessible via
833 debugfs, even when the module is unloaded/reloaded. 833 debugfs, even when the module is unloaded/reloaded.
834 When zero, profiling data is discarded and associated 834 When zero, profiling data is discarded and associated
835 debugfs files are removed at module unload time. 835 debugfs files are removed at module unload time.
836 836
837 gdth= [HW,SCSI] 837 gdth= [HW,SCSI]
838 See header of drivers/scsi/gdth.c. 838 See header of drivers/scsi/gdth.c.
839 839
840 gpt [EFI] Forces disk with valid GPT signature but 840 gpt [EFI] Forces disk with valid GPT signature but
841 invalid Protective MBR to be treated as GPT. 841 invalid Protective MBR to be treated as GPT.
842 842
843 gvp11= [HW,SCSI] 843 gvp11= [HW,SCSI]
844 844
845 hashdist= [KNL,NUMA] Large hashes allocated during boot 845 hashdist= [KNL,NUMA] Large hashes allocated during boot
846 are distributed across NUMA nodes. Defaults on 846 are distributed across NUMA nodes. Defaults on
847 for 64bit NUMA, off otherwise. 847 for 64bit NUMA, off otherwise.
848 Format: 0 | 1 (for off | on) 848 Format: 0 | 1 (for off | on)
849 849
850 hcl= [IA-64] SGI's Hardware Graph compatibility layer 850 hcl= [IA-64] SGI's Hardware Graph compatibility layer
851 851
852 hd= [EIDE] (E)IDE hard drive subsystem geometry 852 hd= [EIDE] (E)IDE hard drive subsystem geometry
853 Format: <cyl>,<head>,<sect> 853 Format: <cyl>,<head>,<sect>
854 854
855 highmem=nn[KMG] [KNL,BOOT] forces the highmem zone to have an exact 855 highmem=nn[KMG] [KNL,BOOT] forces the highmem zone to have an exact
856 size of <nn>. This works even on boxes that have no 856 size of <nn>. This works even on boxes that have no
857 highmem otherwise. This also works to reduce highmem 857 highmem otherwise. This also works to reduce highmem
858 size on bigger boxes. 858 size on bigger boxes.
859 859
860 highres= [KNL] Enable/disable high resolution timer mode. 860 highres= [KNL] Enable/disable high resolution timer mode.
861 Valid parameters: "on", "off" 861 Valid parameters: "on", "off"
862 Default: "on" 862 Default: "on"
863 863
864 hisax= [HW,ISDN] 864 hisax= [HW,ISDN]
865 See Documentation/isdn/README.HiSax. 865 See Documentation/isdn/README.HiSax.
866 866
867 hlt [BUGS=ARM,SH] 867 hlt [BUGS=ARM,SH]
868 868
869 hpet= [X86-32,HPET] option to control HPET usage 869 hpet= [X86-32,HPET] option to control HPET usage
870 Format: { enable (default) | disable | force | 870 Format: { enable (default) | disable | force |
871 verbose } 871 verbose }
872 disable: disable HPET and use PIT instead 872 disable: disable HPET and use PIT instead
873 force: allow force enabled of undocumented chips (ICH4, 873 force: allow force enabled of undocumented chips (ICH4,
874 VIA, nVidia) 874 VIA, nVidia)
875 verbose: show contents of HPET registers during setup 875 verbose: show contents of HPET registers during setup
876 876
877 hugepages= [HW,X86-32,IA-64] HugeTLB pages to allocate at boot. 877 hugepages= [HW,X86-32,IA-64] HugeTLB pages to allocate at boot.
878 hugepagesz= [HW,IA-64,PPC,X86-64] The size of the HugeTLB pages. 878 hugepagesz= [HW,IA-64,PPC,X86-64] The size of the HugeTLB pages.
879 On x86-64 and powerpc, this option can be specified 879 On x86-64 and powerpc, this option can be specified
880 multiple times interleaved with hugepages= to reserve 880 multiple times interleaved with hugepages= to reserve
881 huge pages of different sizes. Valid pages sizes on 881 huge pages of different sizes. Valid pages sizes on
882 x86-64 are 2M (when the CPU supports "pse") and 1G 882 x86-64 are 2M (when the CPU supports "pse") and 1G
883 (when the CPU supports the "pdpe1gb" cpuinfo flag) 883 (when the CPU supports the "pdpe1gb" cpuinfo flag)
884 Note that 1GB pages can only be allocated at boot time 884 Note that 1GB pages can only be allocated at boot time
885 using hugepages= and not freed afterwards. 885 using hugepages= and not freed afterwards.
886 886
887 hvc_iucv= [S390] Number of z/VM IUCV hypervisor console (HVC) 887 hvc_iucv= [S390] Number of z/VM IUCV hypervisor console (HVC)
888 terminal devices. Valid values: 0..8 888 terminal devices. Valid values: 0..8
889 hvc_iucv_allow= [S390] Comma-separated list of z/VM user IDs. 889 hvc_iucv_allow= [S390] Comma-separated list of z/VM user IDs.
890 If specified, z/VM IUCV HVC accepts connections 890 If specified, z/VM IUCV HVC accepts connections
891 from listed z/VM user IDs only. 891 from listed z/VM user IDs only.
892 892
893 i2c_bus= [HW] Override the default board specific I2C bus speed 893 i2c_bus= [HW] Override the default board specific I2C bus speed
894 or register an additional I2C bus that is not 894 or register an additional I2C bus that is not
895 registered from board initialization code. 895 registered from board initialization code.
896 Format: 896 Format:
897 <bus_id>,<clkrate> 897 <bus_id>,<clkrate>
898 898
899 i8042.debug [HW] Toggle i8042 debug mode 899 i8042.debug [HW] Toggle i8042 debug mode
900 i8042.direct [HW] Put keyboard port into non-translated mode 900 i8042.direct [HW] Put keyboard port into non-translated mode
901 i8042.dumbkbd [HW] Pretend that controller can only read data from 901 i8042.dumbkbd [HW] Pretend that controller can only read data from
902 keyboard and cannot control its state 902 keyboard and cannot control its state
903 (Don't attempt to blink the leds) 903 (Don't attempt to blink the leds)
904 i8042.noaux [HW] Don't check for auxiliary (== mouse) port 904 i8042.noaux [HW] Don't check for auxiliary (== mouse) port
905 i8042.nokbd [HW] Don't check/create keyboard port 905 i8042.nokbd [HW] Don't check/create keyboard port
906 i8042.noloop [HW] Disable the AUX Loopback command while probing 906 i8042.noloop [HW] Disable the AUX Loopback command while probing
907 for the AUX port 907 for the AUX port
908 i8042.nomux [HW] Don't check presence of an active multiplexing 908 i8042.nomux [HW] Don't check presence of an active multiplexing
909 controller 909 controller
910 i8042.nopnp [HW] Don't use ACPIPnP / PnPBIOS to discover KBD/AUX 910 i8042.nopnp [HW] Don't use ACPIPnP / PnPBIOS to discover KBD/AUX
911 controllers 911 controllers
912 i8042.panicblink= 912 i8042.panicblink=
913 [HW] Frequency with which keyboard LEDs should blink 913 [HW] Frequency with which keyboard LEDs should blink
914 when kernel panics (default is 0.5 sec) 914 when kernel panics (default is 0.5 sec)
915 i8042.reset [HW] Reset the controller during init and cleanup 915 i8042.reset [HW] Reset the controller during init and cleanup
916 i8042.unlock [HW] Unlock (ignore) the keylock 916 i8042.unlock [HW] Unlock (ignore) the keylock
917 917
918 i810= [HW,DRM] 918 i810= [HW,DRM]
919 919
920 i8k.ignore_dmi [HW] Continue probing hardware even if DMI data 920 i8k.ignore_dmi [HW] Continue probing hardware even if DMI data
921 indicates that the driver is running on unsupported 921 indicates that the driver is running on unsupported
922 hardware. 922 hardware.
923 i8k.force [HW] Activate i8k driver even if SMM BIOS signature 923 i8k.force [HW] Activate i8k driver even if SMM BIOS signature
924 does not match list of supported models. 924 does not match list of supported models.
925 i8k.power_status 925 i8k.power_status
926 [HW] Report power status in /proc/i8k 926 [HW] Report power status in /proc/i8k
927 (disabled by default) 927 (disabled by default)
928 i8k.restricted [HW] Allow controlling fans only if SYS_ADMIN 928 i8k.restricted [HW] Allow controlling fans only if SYS_ADMIN
929 capability is set. 929 capability is set.
930 930
931 ibmmcascsi= [HW,MCA,SCSI] IBM MicroChannel SCSI adapter 931 ibmmcascsi= [HW,MCA,SCSI] IBM MicroChannel SCSI adapter
932 See Documentation/mca.txt. 932 See Documentation/mca.txt.
933 933
934 icn= [HW,ISDN] 934 icn= [HW,ISDN]
935 Format: <io>[,<membase>[,<icn_id>[,<icn_id2>]]] 935 Format: <io>[,<membase>[,<icn_id>[,<icn_id2>]]]
936 936
937 ide-core.nodma= [HW] (E)IDE subsystem 937 ide-core.nodma= [HW] (E)IDE subsystem
938 Format: =0.0 to prevent dma on hda, =0.1 hdb =1.0 hdc 938 Format: =0.0 to prevent dma on hda, =0.1 hdb =1.0 hdc
939 .vlb_clock .pci_clock .noflush .nohpa .noprobe .nowerr 939 .vlb_clock .pci_clock .noflush .nohpa .noprobe .nowerr
940 .cdrom .chs .ignore_cable are additional options 940 .cdrom .chs .ignore_cable are additional options
941 See Documentation/ide/ide.txt. 941 See Documentation/ide/ide.txt.
942 942
943 ide-pci-generic.all-generic-ide [HW] (E)IDE subsystem 943 ide-pci-generic.all-generic-ide [HW] (E)IDE subsystem
944 Claim all unknown PCI IDE storage controllers. 944 Claim all unknown PCI IDE storage controllers.
945 945
946 idle= [X86] 946 idle= [X86]
947 Format: idle=poll, idle=mwait, idle=halt, idle=nomwait 947 Format: idle=poll, idle=mwait, idle=halt, idle=nomwait
948 Poll forces a polling idle loop that can slightly 948 Poll forces a polling idle loop that can slightly
949 improve the performance of waking up a idle CPU, but 949 improve the performance of waking up a idle CPU, but
950 will use a lot of power and make the system run hot. 950 will use a lot of power and make the system run hot.
951 Not recommended. 951 Not recommended.
952 idle=mwait: On systems which support MONITOR/MWAIT but 952 idle=mwait: On systems which support MONITOR/MWAIT but
953 the kernel chose to not use it because it doesn't save 953 the kernel chose to not use it because it doesn't save
954 as much power as a normal idle loop, use the 954 as much power as a normal idle loop, use the
955 MONITOR/MWAIT idle loop anyways. Performance should be 955 MONITOR/MWAIT idle loop anyways. Performance should be
956 the same as idle=poll. 956 the same as idle=poll.
957 idle=halt: Halt is forced to be used for CPU idle. 957 idle=halt: Halt is forced to be used for CPU idle.
958 In such case C2/C3 won't be used again. 958 In such case C2/C3 won't be used again.
959 idle=nomwait: Disable mwait for CPU C-states 959 idle=nomwait: Disable mwait for CPU C-states
960 960
961 ignore_loglevel [KNL] 961 ignore_loglevel [KNL]
962 Ignore loglevel setting - this will print /all/ 962 Ignore loglevel setting - this will print /all/
963 kernel messages to the console. Useful for debugging. 963 kernel messages to the console. Useful for debugging.
964 964
965 ihash_entries= [KNL] 965 ihash_entries= [KNL]
966 Set number of hash buckets for inode cache. 966 Set number of hash buckets for inode cache.
967 967
968 ima_audit= [IMA] 968 ima_audit= [IMA]
969 Format: { "0" | "1" } 969 Format: { "0" | "1" }
970 0 -- integrity auditing messages. (Default) 970 0 -- integrity auditing messages. (Default)
971 1 -- enable informational integrity auditing messages. 971 1 -- enable informational integrity auditing messages.
972 972
973 ima_hash= [IMA] 973 ima_hash= [IMA]
974 Format: { "sha1" | "md5" } 974 Format: { "sha1" | "md5" }
975 default: "sha1" 975 default: "sha1"
976 976
977 ima_tcb [IMA] 977 ima_tcb [IMA]
978 Load a policy which meets the needs of the Trusted 978 Load a policy which meets the needs of the Trusted
979 Computing Base. This means IMA will measure all 979 Computing Base. This means IMA will measure all
980 programs exec'd, files mmap'd for exec, and all files 980 programs exec'd, files mmap'd for exec, and all files
981 opened for read by uid=0. 981 opened for read by uid=0.
982 982
983 in2000= [HW,SCSI] 983 in2000= [HW,SCSI]
984 See header of drivers/scsi/in2000.c. 984 See header of drivers/scsi/in2000.c.
985 985
986 init= [KNL] 986 init= [KNL]
987 Format: <full_path> 987 Format: <full_path>
988 Run specified binary instead of /sbin/init as init 988 Run specified binary instead of /sbin/init as init
989 process. 989 process.
990 990
991 initcall_debug [KNL] Trace initcalls as they are executed. Useful 991 initcall_debug [KNL] Trace initcalls as they are executed. Useful
992 for working out where the kernel is dying during 992 for working out where the kernel is dying during
993 startup. 993 startup.
994 994
995 initrd= [BOOT] Specify the location of the initial ramdisk 995 initrd= [BOOT] Specify the location of the initial ramdisk
996 996
997 inport.irq= [HW] Inport (ATI XL and Microsoft) busmouse driver 997 inport.irq= [HW] Inport (ATI XL and Microsoft) busmouse driver
998 Format: <irq> 998 Format: <irq>
999 999
1000 intel_iommu= [DMAR] Intel IOMMU driver (DMAR) option 1000 intel_iommu= [DMAR] Intel IOMMU driver (DMAR) option
1001 on 1001 on
1002 Enable intel iommu driver. 1002 Enable intel iommu driver.
1003 off 1003 off
1004 Disable intel iommu driver. 1004 Disable intel iommu driver.
1005 igfx_off [Default Off] 1005 igfx_off [Default Off]
1006 By default, gfx is mapped as normal device. If a gfx 1006 By default, gfx is mapped as normal device. If a gfx
1007 device has a dedicated DMAR unit, the DMAR unit is 1007 device has a dedicated DMAR unit, the DMAR unit is
1008 bypassed by not enabling DMAR with this option. In 1008 bypassed by not enabling DMAR with this option. In
1009 this case, gfx device will use physical address for 1009 this case, gfx device will use physical address for
1010 DMA. 1010 DMA.
1011 forcedac [x86_64] 1011 forcedac [x86_64]
1012 With this option iommu will not optimize to look 1012 With this option iommu will not optimize to look
1013 for io virtual address below 32 bit forcing dual 1013 for io virtual address below 32 bit forcing dual
1014 address cycle on pci bus for cards supporting greater 1014 address cycle on pci bus for cards supporting greater
1015 than 32 bit addressing. The default is to look 1015 than 32 bit addressing. The default is to look
1016 for translation below 32 bit and if not available 1016 for translation below 32 bit and if not available
1017 then look in the higher range. 1017 then look in the higher range.
1018 strict [Default Off] 1018 strict [Default Off]
1019 With this option on every unmap_single operation will 1019 With this option on every unmap_single operation will
1020 result in a hardware IOTLB flush operation as opposed 1020 result in a hardware IOTLB flush operation as opposed
1021 to batching them for performance. 1021 to batching them for performance.
1022 1022
1023 inttest= [IA64] 1023 inttest= [IA64]
1024 1024
1025 iomem= Disable strict checking of access to MMIO memory 1025 iomem= Disable strict checking of access to MMIO memory
1026 strict regions from userspace. 1026 strict regions from userspace.
1027 relaxed 1027 relaxed
1028 1028
1029 iommu= [x86] 1029 iommu= [x86]
1030 off 1030 off
1031 force 1031 force
1032 noforce 1032 noforce
1033 biomerge 1033 biomerge
1034 panic 1034 panic
1035 nopanic 1035 nopanic
1036 merge 1036 merge
1037 nomerge 1037 nomerge
1038 forcesac 1038 forcesac
1039 soft 1039 soft
1040 pt [x86, IA64] 1040 pt [x86, IA64]
1041 1041
1042 io7= [HW] IO7 for Marvel based alpha systems 1042 io7= [HW] IO7 for Marvel based alpha systems
1043 See comment before marvel_specify_io7 in 1043 See comment before marvel_specify_io7 in
1044 arch/alpha/kernel/core_marvel.c. 1044 arch/alpha/kernel/core_marvel.c.
1045 1045
1046 io_delay= [X86] I/O delay method 1046 io_delay= [X86] I/O delay method
1047 0x80 1047 0x80
1048 Standard port 0x80 based delay 1048 Standard port 0x80 based delay
1049 0xed 1049 0xed
1050 Alternate port 0xed based delay (needed on some systems) 1050 Alternate port 0xed based delay (needed on some systems)
1051 udelay 1051 udelay
1052 Simple two microseconds delay 1052 Simple two microseconds delay
1053 none 1053 none
1054 No delay 1054 No delay
1055 1055
1056 ip= [IP_PNP] 1056 ip= [IP_PNP]
1057 See Documentation/filesystems/nfs/nfsroot.txt. 1057 See Documentation/filesystems/nfs/nfsroot.txt.
1058 1058
1059 ip2= [HW] Set IO/IRQ pairs for up to 4 IntelliPort boards 1059 ip2= [HW] Set IO/IRQ pairs for up to 4 IntelliPort boards
1060 See comment before ip2_setup() in 1060 See comment before ip2_setup() in
1061 drivers/char/ip2/ip2base.c. 1061 drivers/char/ip2/ip2base.c.
1062 1062
1063 ips= [HW,SCSI] Adaptec / IBM ServeRAID controller 1063 ips= [HW,SCSI] Adaptec / IBM ServeRAID controller
1064 See header of drivers/scsi/ips.c. 1064 See header of drivers/scsi/ips.c.
1065 1065
1066 irqfixup [HW] 1066 irqfixup [HW]
1067 When an interrupt is not handled search all handlers 1067 When an interrupt is not handled search all handlers
1068 for it. Intended to get systems with badly broken 1068 for it. Intended to get systems with badly broken
1069 firmware running. 1069 firmware running.
1070 1070
1071 irqpoll [HW] 1071 irqpoll [HW]
1072 When an interrupt is not handled search all handlers 1072 When an interrupt is not handled search all handlers
1073 for it. Also check all handlers each timer 1073 for it. Also check all handlers each timer
1074 interrupt. Intended to get systems with badly broken 1074 interrupt. Intended to get systems with badly broken
1075 firmware running. 1075 firmware running.
1076 1076
1077 isapnp= [ISAPNP] 1077 isapnp= [ISAPNP]
1078 Format: <RDP>,<reset>,<pci_scan>,<verbosity> 1078 Format: <RDP>,<reset>,<pci_scan>,<verbosity>
1079 1079
1080 isolcpus= [KNL,SMP] Isolate CPUs from the general scheduler. 1080 isolcpus= [KNL,SMP] Isolate CPUs from the general scheduler.
1081 Format: 1081 Format:
1082 <cpu number>,...,<cpu number> 1082 <cpu number>,...,<cpu number>
1083 or 1083 or
1084 <cpu number>-<cpu number> 1084 <cpu number>-<cpu number>
1085 (must be a positive range in ascending order) 1085 (must be a positive range in ascending order)
1086 or a mixture 1086 or a mixture
1087 <cpu number>,...,<cpu number>-<cpu number> 1087 <cpu number>,...,<cpu number>-<cpu number>
1088 1088
1089 This option can be used to specify one or more CPUs 1089 This option can be used to specify one or more CPUs
1090 to isolate from the general SMP balancing and scheduling 1090 to isolate from the general SMP balancing and scheduling
1091 algorithms. You can move a process onto or off an 1091 algorithms. You can move a process onto or off an
1092 "isolated" CPU via the CPU affinity syscalls or cpuset. 1092 "isolated" CPU via the CPU affinity syscalls or cpuset.
1093 <cpu number> begins at 0 and the maximum value is 1093 <cpu number> begins at 0 and the maximum value is
1094 "number of CPUs in system - 1". 1094 "number of CPUs in system - 1".
1095 1095
1096 This option is the preferred way to isolate CPUs. The 1096 This option is the preferred way to isolate CPUs. The
1097 alternative -- manually setting the CPU mask of all 1097 alternative -- manually setting the CPU mask of all
1098 tasks in the system -- can cause problems and 1098 tasks in the system -- can cause problems and
1099 suboptimal load balancer performance. 1099 suboptimal load balancer performance.
1100 1100
1101 iucv= [HW,NET] 1101 iucv= [HW,NET]
1102 1102
1103 js= [HW,JOY] Analog joystick 1103 js= [HW,JOY] Analog joystick
1104 See Documentation/input/joystick.txt. 1104 See Documentation/input/joystick.txt.
1105 1105
1106 keepinitrd [HW,ARM] 1106 keepinitrd [HW,ARM]
1107 1107
1108 kernelcore=nn[KMG] [KNL,X86,IA-64,PPC] This parameter 1108 kernelcore=nn[KMG] [KNL,X86,IA-64,PPC] This parameter
1109 specifies the amount of memory usable by the kernel 1109 specifies the amount of memory usable by the kernel
1110 for non-movable allocations. The requested amount is 1110 for non-movable allocations. The requested amount is
1111 spread evenly throughout all nodes in the system. The 1111 spread evenly throughout all nodes in the system. The
1112 remaining memory in each node is used for Movable 1112 remaining memory in each node is used for Movable
1113 pages. In the event, a node is too small to have both 1113 pages. In the event, a node is too small to have both
1114 kernelcore and Movable pages, kernelcore pages will 1114 kernelcore and Movable pages, kernelcore pages will
1115 take priority and other nodes will have a larger number 1115 take priority and other nodes will have a larger number
1116 of kernelcore pages. The Movable zone is used for the 1116 of kernelcore pages. The Movable zone is used for the
1117 allocation of pages that may be reclaimed or moved 1117 allocation of pages that may be reclaimed or moved
1118 by the page migration subsystem. This means that 1118 by the page migration subsystem. This means that
1119 HugeTLB pages may not be allocated from this zone. 1119 HugeTLB pages may not be allocated from this zone.
1120 Note that allocations like PTEs-from-HighMem still 1120 Note that allocations like PTEs-from-HighMem still
1121 use the HighMem zone if it exists, and the Normal 1121 use the HighMem zone if it exists, and the Normal
1122 zone if it does not. 1122 zone if it does not.
1123 1123
1124 kgdbdbgp= [KGDB,HW] kgdb over EHCI usb debug port. 1124 kgdbdbgp= [KGDB,HW] kgdb over EHCI usb debug port.
1125 Format: <Controller#>[,poll interval] 1125 Format: <Controller#>[,poll interval]
1126 The controller # is the number of the ehci usb debug 1126 The controller # is the number of the ehci usb debug
1127 port as it is probed via PCI. The poll interval is 1127 port as it is probed via PCI. The poll interval is
1128 optional and is the number seconds in between 1128 optional and is the number seconds in between
1129 each poll cycle to the debug port in case you need 1129 each poll cycle to the debug port in case you need
1130 the functionality for interrupting the kernel with 1130 the functionality for interrupting the kernel with
1131 gdb or control-c on the dbgp connection. When 1131 gdb or control-c on the dbgp connection. When
1132 not using this parameter you use sysrq-g to break into 1132 not using this parameter you use sysrq-g to break into
1133 the kernel debugger. 1133 the kernel debugger.
1134 1134
1135 kgdboc= [KGDB,HW] kgdb over consoles. 1135 kgdboc= [KGDB,HW] kgdb over consoles.
1136 Requires a tty driver that supports console polling, 1136 Requires a tty driver that supports console polling,
1137 or a supported polling keyboard driver (non-usb). 1137 or a supported polling keyboard driver (non-usb).
1138 Serial only format: <serial_device>[,baud] 1138 Serial only format: <serial_device>[,baud]
1139 keyboard only format: kbd 1139 keyboard only format: kbd
1140 keyboard and serial format: kbd,<serial_device>[,baud] 1140 keyboard and serial format: kbd,<serial_device>[,baud]
1141 1141
1142 kgdbwait [KGDB] Stop kernel execution and enter the 1142 kgdbwait [KGDB] Stop kernel execution and enter the
1143 kernel debugger at the earliest opportunity. 1143 kernel debugger at the earliest opportunity.
1144 1144
1145 kmac= [MIPS] korina ethernet MAC address. 1145 kmac= [MIPS] korina ethernet MAC address.
1146 Configure the RouterBoard 532 series on-chip 1146 Configure the RouterBoard 532 series on-chip
1147 Ethernet adapter MAC address. 1147 Ethernet adapter MAC address.
1148 1148
1149 kmemleak= [KNL] Boot-time kmemleak enable/disable 1149 kmemleak= [KNL] Boot-time kmemleak enable/disable
1150 Valid arguments: on, off 1150 Valid arguments: on, off
1151 Default: on 1151 Default: on
1152 1152
1153 kstack=N [X86] Print N words from the kernel stack 1153 kstack=N [X86] Print N words from the kernel stack
1154 in oops dumps. 1154 in oops dumps.
1155 1155
1156 kvm.ignore_msrs=[KVM] Ignore guest accesses to unhandled MSRs. 1156 kvm.ignore_msrs=[KVM] Ignore guest accesses to unhandled MSRs.
1157 Default is 0 (don't ignore, but inject #GP) 1157 Default is 0 (don't ignore, but inject #GP)
1158 1158
1159 kvm.oos_shadow= [KVM] Disable out-of-sync shadow paging. 1159 kvm.oos_shadow= [KVM] Disable out-of-sync shadow paging.
1160 Default is 1 (enabled) 1160 Default is 1 (enabled)
1161 1161
1162 kvm-amd.nested= [KVM,AMD] Allow nested virtualization in KVM/SVM. 1162 kvm-amd.nested= [KVM,AMD] Allow nested virtualization in KVM/SVM.
1163 Default is 0 (off) 1163 Default is 0 (off)
1164 1164
1165 kvm-amd.npt= [KVM,AMD] Disable nested paging (virtualized MMU) 1165 kvm-amd.npt= [KVM,AMD] Disable nested paging (virtualized MMU)
1166 for all guests. 1166 for all guests.
1167 Default is 1 (enabled) if in 64bit or 32bit-PAE mode 1167 Default is 1 (enabled) if in 64bit or 32bit-PAE mode
1168 1168
1169 kvm-intel.bypass_guest_pf= 1169 kvm-intel.bypass_guest_pf=
1170 [KVM,Intel] Disables bypassing of guest page faults 1170 [KVM,Intel] Disables bypassing of guest page faults
1171 on Intel chips. Default is 1 (enabled) 1171 on Intel chips. Default is 1 (enabled)
1172 1172
1173 kvm-intel.ept= [KVM,Intel] Disable extended page tables 1173 kvm-intel.ept= [KVM,Intel] Disable extended page tables
1174 (virtualized MMU) support on capable Intel chips. 1174 (virtualized MMU) support on capable Intel chips.
1175 Default is 1 (enabled) 1175 Default is 1 (enabled)
1176 1176
1177 kvm-intel.emulate_invalid_guest_state= 1177 kvm-intel.emulate_invalid_guest_state=
1178 [KVM,Intel] Enable emulation of invalid guest states 1178 [KVM,Intel] Enable emulation of invalid guest states
1179 Default is 0 (disabled) 1179 Default is 0 (disabled)
1180 1180
1181 kvm-intel.flexpriority= 1181 kvm-intel.flexpriority=
1182 [KVM,Intel] Disable FlexPriority feature (TPR shadow). 1182 [KVM,Intel] Disable FlexPriority feature (TPR shadow).
1183 Default is 1 (enabled) 1183 Default is 1 (enabled)
1184 1184
1185 kvm-intel.unrestricted_guest= 1185 kvm-intel.unrestricted_guest=
1186 [KVM,Intel] Disable unrestricted guest feature 1186 [KVM,Intel] Disable unrestricted guest feature
1187 (virtualized real and unpaged mode) on capable 1187 (virtualized real and unpaged mode) on capable
1188 Intel chips. Default is 1 (enabled) 1188 Intel chips. Default is 1 (enabled)
1189 1189
1190 kvm-intel.vpid= [KVM,Intel] Disable Virtual Processor Identification 1190 kvm-intel.vpid= [KVM,Intel] Disable Virtual Processor Identification
1191 feature (tagged TLBs) on capable Intel chips. 1191 feature (tagged TLBs) on capable Intel chips.
1192 Default is 1 (enabled) 1192 Default is 1 (enabled)
1193 1193
1194 l2cr= [PPC] 1194 l2cr= [PPC]
1195 1195
1196 l3cr= [PPC] 1196 l3cr= [PPC]
1197 1197
1198 lapic [X86-32,APIC] Enable the local APIC even if BIOS 1198 lapic [X86-32,APIC] Enable the local APIC even if BIOS
1199 disabled it. 1199 disabled it.
1200 1200
1201 lapic_timer_c2_ok [X86,APIC] trust the local apic timer 1201 lapic_timer_c2_ok [X86,APIC] trust the local apic timer
1202 in C2 power state. 1202 in C2 power state.
1203 1203
1204 libata.dma= [LIBATA] DMA control 1204 libata.dma= [LIBATA] DMA control
1205 libata.dma=0 Disable all PATA and SATA DMA 1205 libata.dma=0 Disable all PATA and SATA DMA
1206 libata.dma=1 PATA and SATA Disk DMA only 1206 libata.dma=1 PATA and SATA Disk DMA only
1207 libata.dma=2 ATAPI (CDROM) DMA only 1207 libata.dma=2 ATAPI (CDROM) DMA only
1208 libata.dma=4 Compact Flash DMA only 1208 libata.dma=4 Compact Flash DMA only
1209 Combinations also work, so libata.dma=3 enables DMA 1209 Combinations also work, so libata.dma=3 enables DMA
1210 for disks and CDROMs, but not CFs. 1210 for disks and CDROMs, but not CFs.
1211 1211
1212 libata.ignore_hpa= [LIBATA] Ignore HPA limit 1212 libata.ignore_hpa= [LIBATA] Ignore HPA limit
1213 libata.ignore_hpa=0 keep BIOS limits (default) 1213 libata.ignore_hpa=0 keep BIOS limits (default)
1214 libata.ignore_hpa=1 ignore limits, using full disk 1214 libata.ignore_hpa=1 ignore limits, using full disk
1215 1215
1216 libata.noacpi [LIBATA] Disables use of ACPI in libata suspend/resume 1216 libata.noacpi [LIBATA] Disables use of ACPI in libata suspend/resume
1217 when set. 1217 when set.
1218 Format: <int> 1218 Format: <int>
1219 1219
1220 libata.force= [LIBATA] Force configurations. The format is comma 1220 libata.force= [LIBATA] Force configurations. The format is comma
1221 separated list of "[ID:]VAL" where ID is 1221 separated list of "[ID:]VAL" where ID is
1222 PORT[.DEVICE]. PORT and DEVICE are decimal numbers 1222 PORT[.DEVICE]. PORT and DEVICE are decimal numbers
1223 matching port, link or device. Basically, it matches 1223 matching port, link or device. Basically, it matches
1224 the ATA ID string printed on console by libata. If 1224 the ATA ID string printed on console by libata. If
1225 the whole ID part is omitted, the last PORT and DEVICE 1225 the whole ID part is omitted, the last PORT and DEVICE
1226 values are used. If ID hasn't been specified yet, the 1226 values are used. If ID hasn't been specified yet, the
1227 configuration applies to all ports, links and devices. 1227 configuration applies to all ports, links and devices.
1228 1228
1229 If only DEVICE is omitted, the parameter applies to 1229 If only DEVICE is omitted, the parameter applies to
1230 the port and all links and devices behind it. DEVICE 1230 the port and all links and devices behind it. DEVICE
1231 number of 0 either selects the first device or the 1231 number of 0 either selects the first device or the
1232 first fan-out link behind PMP device. It does not 1232 first fan-out link behind PMP device. It does not
1233 select the host link. DEVICE number of 15 selects the 1233 select the host link. DEVICE number of 15 selects the
1234 host link and device attached to it. 1234 host link and device attached to it.
1235 1235
1236 The VAL specifies the configuration to force. As long 1236 The VAL specifies the configuration to force. As long
1237 as there's no ambiguity shortcut notation is allowed. 1237 as there's no ambiguity shortcut notation is allowed.
1238 For example, both 1.5 and 1.5G would work for 1.5Gbps. 1238 For example, both 1.5 and 1.5G would work for 1.5Gbps.
1239 The following configurations can be forced. 1239 The following configurations can be forced.
1240 1240
1241 * Cable type: 40c, 80c, short40c, unk, ign or sata. 1241 * Cable type: 40c, 80c, short40c, unk, ign or sata.
1242 Any ID with matching PORT is used. 1242 Any ID with matching PORT is used.
1243 1243
1244 * SATA link speed limit: 1.5Gbps or 3.0Gbps. 1244 * SATA link speed limit: 1.5Gbps or 3.0Gbps.
1245 1245
1246 * Transfer mode: pio[0-7], mwdma[0-4] and udma[0-7]. 1246 * Transfer mode: pio[0-7], mwdma[0-4] and udma[0-7].
1247 udma[/][16,25,33,44,66,100,133] notation is also 1247 udma[/][16,25,33,44,66,100,133] notation is also
1248 allowed. 1248 allowed.
1249 1249
1250 * [no]ncq: Turn on or off NCQ. 1250 * [no]ncq: Turn on or off NCQ.
1251 1251
1252 * nohrst, nosrst, norst: suppress hard, soft 1252 * nohrst, nosrst, norst: suppress hard, soft
1253 and both resets. 1253 and both resets.
1254 1254
1255 * dump_id: dump IDENTIFY data.
1256
1255 If there are multiple matching configurations changing 1257 If there are multiple matching configurations changing
1256 the same attribute, the last one is used. 1258 the same attribute, the last one is used.
1257 1259
1258 lmb=debug [KNL] Enable lmb debug messages. 1260 lmb=debug [KNL] Enable lmb debug messages.
1259 1261
1260 load_ramdisk= [RAM] List of ramdisks to load from floppy 1262 load_ramdisk= [RAM] List of ramdisks to load from floppy
1261 See Documentation/blockdev/ramdisk.txt. 1263 See Documentation/blockdev/ramdisk.txt.
1262 1264
1263 lockd.nlm_grace_period=P [NFS] Assign grace period. 1265 lockd.nlm_grace_period=P [NFS] Assign grace period.
1264 Format: <integer> 1266 Format: <integer>
1265 1267
1266 lockd.nlm_tcpport=N [NFS] Assign TCP port. 1268 lockd.nlm_tcpport=N [NFS] Assign TCP port.
1267 Format: <integer> 1269 Format: <integer>
1268 1270
1269 lockd.nlm_timeout=T [NFS] Assign timeout value. 1271 lockd.nlm_timeout=T [NFS] Assign timeout value.
1270 Format: <integer> 1272 Format: <integer>
1271 1273
1272 lockd.nlm_udpport=M [NFS] Assign UDP port. 1274 lockd.nlm_udpport=M [NFS] Assign UDP port.
1273 Format: <integer> 1275 Format: <integer>
1274 1276
1275 logibm.irq= [HW,MOUSE] Logitech Bus Mouse Driver 1277 logibm.irq= [HW,MOUSE] Logitech Bus Mouse Driver
1276 Format: <irq> 1278 Format: <irq>
1277 1279
1278 loglevel= All Kernel Messages with a loglevel smaller than the 1280 loglevel= All Kernel Messages with a loglevel smaller than the
1279 console loglevel will be printed to the console. It can 1281 console loglevel will be printed to the console. It can
1280 also be changed with klogd or other programs. The 1282 also be changed with klogd or other programs. The
1281 loglevels are defined as follows: 1283 loglevels are defined as follows:
1282 1284
1283 0 (KERN_EMERG) system is unusable 1285 0 (KERN_EMERG) system is unusable
1284 1 (KERN_ALERT) action must be taken immediately 1286 1 (KERN_ALERT) action must be taken immediately
1285 2 (KERN_CRIT) critical conditions 1287 2 (KERN_CRIT) critical conditions
1286 3 (KERN_ERR) error conditions 1288 3 (KERN_ERR) error conditions
1287 4 (KERN_WARNING) warning conditions 1289 4 (KERN_WARNING) warning conditions
1288 5 (KERN_NOTICE) normal but significant condition 1290 5 (KERN_NOTICE) normal but significant condition
1289 6 (KERN_INFO) informational 1291 6 (KERN_INFO) informational
1290 7 (KERN_DEBUG) debug-level messages 1292 7 (KERN_DEBUG) debug-level messages
1291 1293
1292 log_buf_len=n Sets the size of the printk ring buffer, in bytes. 1294 log_buf_len=n Sets the size of the printk ring buffer, in bytes.
1293 Format: { n | nk | nM } 1295 Format: { n | nk | nM }
1294 n must be a power of two. The default size 1296 n must be a power of two. The default size
1295 is set in the kernel config file. 1297 is set in the kernel config file.
1296 1298
1297 logo.nologo [FB] Disables display of the built-in Linux logo. 1299 logo.nologo [FB] Disables display of the built-in Linux logo.
1298 This may be used to provide more screen space for 1300 This may be used to provide more screen space for
1299 kernel log messages and is useful when debugging 1301 kernel log messages and is useful when debugging
1300 kernel boot problems. 1302 kernel boot problems.
1301 1303
1302 lp=0 [LP] Specify parallel ports to use, e.g, 1304 lp=0 [LP] Specify parallel ports to use, e.g,
1303 lp=port[,port...] lp=none,parport0 (lp0 not configured, lp1 uses 1305 lp=port[,port...] lp=none,parport0 (lp0 not configured, lp1 uses
1304 lp=reset first parallel port). 'lp=0' disables the 1306 lp=reset first parallel port). 'lp=0' disables the
1305 lp=auto printer driver. 'lp=reset' (which can be 1307 lp=auto printer driver. 'lp=reset' (which can be
1306 specified in addition to the ports) causes 1308 specified in addition to the ports) causes
1307 attached printers to be reset. Using 1309 attached printers to be reset. Using
1308 lp=port1,port2,... specifies the parallel ports 1310 lp=port1,port2,... specifies the parallel ports
1309 to associate lp devices with, starting with 1311 to associate lp devices with, starting with
1310 lp0. A port specification may be 'none' to skip 1312 lp0. A port specification may be 'none' to skip
1311 that lp device, or a parport name such as 1313 that lp device, or a parport name such as
1312 'parport0'. Specifying 'lp=auto' instead of a 1314 'parport0'. Specifying 'lp=auto' instead of a
1313 port specification list means that device IDs 1315 port specification list means that device IDs
1314 from each port should be examined, to see if 1316 from each port should be examined, to see if
1315 an IEEE 1284-compliant printer is attached; if 1317 an IEEE 1284-compliant printer is attached; if
1316 so, the driver will manage that printer. 1318 so, the driver will manage that printer.
1317 See also header of drivers/char/lp.c. 1319 See also header of drivers/char/lp.c.
1318 1320
1319 lpj=n [KNL] 1321 lpj=n [KNL]
1320 Sets loops_per_jiffy to given constant, thus avoiding 1322 Sets loops_per_jiffy to given constant, thus avoiding
1321 time-consuming boot-time autodetection (up to 250 ms per 1323 time-consuming boot-time autodetection (up to 250 ms per
1322 CPU). 0 enables autodetection (default). To determine 1324 CPU). 0 enables autodetection (default). To determine
1323 the correct value for your kernel, boot with normal 1325 the correct value for your kernel, boot with normal
1324 autodetection and see what value is printed. Note that 1326 autodetection and see what value is printed. Note that
1325 on SMP systems the preset will be applied to all CPUs, 1327 on SMP systems the preset will be applied to all CPUs,
1326 which is likely to cause problems if your CPUs need 1328 which is likely to cause problems if your CPUs need
1327 significantly divergent settings. An incorrect value 1329 significantly divergent settings. An incorrect value
1328 will cause delays in the kernel to be wrong, leading to 1330 will cause delays in the kernel to be wrong, leading to
1329 unpredictable I/O errors and other breakage. Although 1331 unpredictable I/O errors and other breakage. Although
1330 unlikely, in the extreme case this might damage your 1332 unlikely, in the extreme case this might damage your
1331 hardware. 1333 hardware.
1332 1334
1333 ltpc= [NET] 1335 ltpc= [NET]
1334 Format: <io>,<irq>,<dma> 1336 Format: <io>,<irq>,<dma>
1335 1337
1336 mac5380= [HW,SCSI] Format: 1338 mac5380= [HW,SCSI] Format:
1337 <can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags> 1339 <can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags>
1338 1340
1339 machvec= [IA64] Force the use of a particular machine-vector 1341 machvec= [IA64] Force the use of a particular machine-vector
1340 (machvec) in a generic kernel. 1342 (machvec) in a generic kernel.
1341 Example: machvec=hpzx1_swiotlb 1343 Example: machvec=hpzx1_swiotlb
1342 1344
1343 machtype= [Loongson] Share the same kernel image file between different 1345 machtype= [Loongson] Share the same kernel image file between different
1344 yeeloong laptop. 1346 yeeloong laptop.
1345 Example: machtype=lemote-yeeloong-2f-7inch 1347 Example: machtype=lemote-yeeloong-2f-7inch
1346 1348
1347 max_addr=nn[KMG] [KNL,BOOT,ia64] All physical memory greater 1349 max_addr=nn[KMG] [KNL,BOOT,ia64] All physical memory greater
1348 than or equal to this physical address is ignored. 1350 than or equal to this physical address is ignored.
1349 1351
1350 maxcpus= [SMP] Maximum number of processors that an SMP kernel 1352 maxcpus= [SMP] Maximum number of processors that an SMP kernel
1351 should make use of. maxcpus=n : n >= 0 limits the 1353 should make use of. maxcpus=n : n >= 0 limits the
1352 kernel to using 'n' processors. n=0 is a special case, 1354 kernel to using 'n' processors. n=0 is a special case,
1353 it is equivalent to "nosmp", which also disables 1355 it is equivalent to "nosmp", which also disables
1354 the IO APIC. 1356 the IO APIC.
1355 1357
1356 max_loop= [LOOP] Maximum number of loopback devices that can 1358 max_loop= [LOOP] Maximum number of loopback devices that can
1357 be mounted 1359 be mounted
1358 Format: <1-256> 1360 Format: <1-256>
1359 1361
1360 max_luns= [SCSI] Maximum number of LUNs to probe. 1362 max_luns= [SCSI] Maximum number of LUNs to probe.
1361 Should be between 1 and 2^32-1. 1363 Should be between 1 and 2^32-1.
1362 1364
1363 max_report_luns= 1365 max_report_luns=
1364 [SCSI] Maximum number of LUNs received. 1366 [SCSI] Maximum number of LUNs received.
1365 Should be between 1 and 16384. 1367 Should be between 1 and 16384.
1366 1368
1367 mcatest= [IA-64] 1369 mcatest= [IA-64]
1368 1370
1369 mce [X86-32] Machine Check Exception 1371 mce [X86-32] Machine Check Exception
1370 1372
1371 mce=option [X86-64] See Documentation/x86/x86_64/boot-options.txt 1373 mce=option [X86-64] See Documentation/x86/x86_64/boot-options.txt
1372 1374
1373 md= [HW] RAID subsystems devices and level 1375 md= [HW] RAID subsystems devices and level
1374 See Documentation/md.txt. 1376 See Documentation/md.txt.
1375 1377
1376 mdacon= [MDA] 1378 mdacon= [MDA]
1377 Format: <first>,<last> 1379 Format: <first>,<last>
1378 Specifies range of consoles to be captured by the MDA. 1380 Specifies range of consoles to be captured by the MDA.
1379 1381
1380 mem=nn[KMG] [KNL,BOOT] Force usage of a specific amount of memory 1382 mem=nn[KMG] [KNL,BOOT] Force usage of a specific amount of memory
1381 Amount of memory to be used when the kernel is not able 1383 Amount of memory to be used when the kernel is not able
1382 to see the whole system memory or for test. 1384 to see the whole system memory or for test.
1383 [X86-32] Use together with memmap= to avoid physical 1385 [X86-32] Use together with memmap= to avoid physical
1384 address space collisions. Without memmap= PCI devices 1386 address space collisions. Without memmap= PCI devices
1385 could be placed at addresses belonging to unused RAM. 1387 could be placed at addresses belonging to unused RAM.
1386 1388
1387 mem=nopentium [BUGS=X86-32] Disable usage of 4MB pages for kernel 1389 mem=nopentium [BUGS=X86-32] Disable usage of 4MB pages for kernel
1388 memory. 1390 memory.
1389 1391
1390 memchunk=nn[KMG] 1392 memchunk=nn[KMG]
1391 [KNL,SH] Allow user to override the default size for 1393 [KNL,SH] Allow user to override the default size for
1392 per-device physically contiguous DMA buffers. 1394 per-device physically contiguous DMA buffers.
1393 1395
1394 memmap=exactmap [KNL,X86] Enable setting of an exact 1396 memmap=exactmap [KNL,X86] Enable setting of an exact
1395 E820 memory map, as specified by the user. 1397 E820 memory map, as specified by the user.
1396 Such memmap=exactmap lines can be constructed based on 1398 Such memmap=exactmap lines can be constructed based on
1397 BIOS output or other requirements. See the memmap=nn@ss 1399 BIOS output or other requirements. See the memmap=nn@ss
1398 option description. 1400 option description.
1399 1401
1400 memmap=nn[KMG]@ss[KMG] 1402 memmap=nn[KMG]@ss[KMG]
1401 [KNL] Force usage of a specific region of memory 1403 [KNL] Force usage of a specific region of memory
1402 Region of memory to be used, from ss to ss+nn. 1404 Region of memory to be used, from ss to ss+nn.
1403 1405
1404 memmap=nn[KMG]#ss[KMG] 1406 memmap=nn[KMG]#ss[KMG]
1405 [KNL,ACPI] Mark specific memory as ACPI data. 1407 [KNL,ACPI] Mark specific memory as ACPI data.
1406 Region of memory to be used, from ss to ss+nn. 1408 Region of memory to be used, from ss to ss+nn.
1407 1409
1408 memmap=nn[KMG]$ss[KMG] 1410 memmap=nn[KMG]$ss[KMG]
1409 [KNL,ACPI] Mark specific memory as reserved. 1411 [KNL,ACPI] Mark specific memory as reserved.
1410 Region of memory to be used, from ss to ss+nn. 1412 Region of memory to be used, from ss to ss+nn.
1411 Example: Exclude memory from 0x18690000-0x1869ffff 1413 Example: Exclude memory from 0x18690000-0x1869ffff
1412 memmap=64K$0x18690000 1414 memmap=64K$0x18690000
1413 or 1415 or
1414 memmap=0x10000$0x18690000 1416 memmap=0x10000$0x18690000
1415 1417
1416 memory_corruption_check=0/1 [X86] 1418 memory_corruption_check=0/1 [X86]
1417 Some BIOSes seem to corrupt the first 64k of 1419 Some BIOSes seem to corrupt the first 64k of
1418 memory when doing things like suspend/resume. 1420 memory when doing things like suspend/resume.
1419 Setting this option will scan the memory 1421 Setting this option will scan the memory
1420 looking for corruption. Enabling this will 1422 looking for corruption. Enabling this will
1421 both detect corruption and prevent the kernel 1423 both detect corruption and prevent the kernel
1422 from using the memory being corrupted. 1424 from using the memory being corrupted.
1423 However, its intended as a diagnostic tool; if 1425 However, its intended as a diagnostic tool; if
1424 repeatable BIOS-originated corruption always 1426 repeatable BIOS-originated corruption always
1425 affects the same memory, you can use memmap= 1427 affects the same memory, you can use memmap=
1426 to prevent the kernel from using that memory. 1428 to prevent the kernel from using that memory.
1427 1429
1428 memory_corruption_check_size=size [X86] 1430 memory_corruption_check_size=size [X86]
1429 By default it checks for corruption in the low 1431 By default it checks for corruption in the low
1430 64k, making this memory unavailable for normal 1432 64k, making this memory unavailable for normal
1431 use. Use this parameter to scan for 1433 use. Use this parameter to scan for
1432 corruption in more or less memory. 1434 corruption in more or less memory.
1433 1435
1434 memory_corruption_check_period=seconds [X86] 1436 memory_corruption_check_period=seconds [X86]
1435 By default it checks for corruption every 60 1437 By default it checks for corruption every 60
1436 seconds. Use this parameter to check at some 1438 seconds. Use this parameter to check at some
1437 other rate. 0 disables periodic checking. 1439 other rate. 0 disables periodic checking.
1438 1440
1439 memtest= [KNL,X86] Enable memtest 1441 memtest= [KNL,X86] Enable memtest
1440 Format: <integer> 1442 Format: <integer>
1441 default : 0 <disable> 1443 default : 0 <disable>
1442 Specifies the number of memtest passes to be 1444 Specifies the number of memtest passes to be
1443 performed. Each pass selects another test 1445 performed. Each pass selects another test
1444 pattern from a given set of patterns. Memtest 1446 pattern from a given set of patterns. Memtest
1445 fills the memory with this pattern, validates 1447 fills the memory with this pattern, validates
1446 memory contents and reserves bad memory 1448 memory contents and reserves bad memory
1447 regions that are detected. 1449 regions that are detected.
1448 1450
1449 meye.*= [HW] Set MotionEye Camera parameters 1451 meye.*= [HW] Set MotionEye Camera parameters
1450 See Documentation/video4linux/meye.txt. 1452 See Documentation/video4linux/meye.txt.
1451 1453
1452 mfgpt_irq= [IA-32] Specify the IRQ to use for the 1454 mfgpt_irq= [IA-32] Specify the IRQ to use for the
1453 Multi-Function General Purpose Timers on AMD Geode 1455 Multi-Function General Purpose Timers on AMD Geode
1454 platforms. 1456 platforms.
1455 1457
1456 mfgptfix [X86-32] Fix MFGPT timers on AMD Geode platforms when 1458 mfgptfix [X86-32] Fix MFGPT timers on AMD Geode platforms when
1457 the BIOS has incorrectly applied a workaround. TinyBIOS 1459 the BIOS has incorrectly applied a workaround. TinyBIOS
1458 version 0.98 is known to be affected, 0.99 fixes the 1460 version 0.98 is known to be affected, 0.99 fixes the
1459 problem by letting the user disable the workaround. 1461 problem by letting the user disable the workaround.
1460 1462
1461 mga= [HW,DRM] 1463 mga= [HW,DRM]
1462 1464
1463 min_addr=nn[KMG] [KNL,BOOT,ia64] All physical memory below this 1465 min_addr=nn[KMG] [KNL,BOOT,ia64] All physical memory below this
1464 physical address is ignored. 1466 physical address is ignored.
1465 1467
1466 mini2440= [ARM,HW,KNL] 1468 mini2440= [ARM,HW,KNL]
1467 Format:[0..2][b][c][t] 1469 Format:[0..2][b][c][t]
1468 Default: "0tb" 1470 Default: "0tb"
1469 MINI2440 configuration specification: 1471 MINI2440 configuration specification:
1470 0 - The attached screen is the 3.5" TFT 1472 0 - The attached screen is the 3.5" TFT
1471 1 - The attached screen is the 7" TFT 1473 1 - The attached screen is the 7" TFT
1472 2 - The VGA Shield is attached (1024x768) 1474 2 - The VGA Shield is attached (1024x768)
1473 Leaving out the screen size parameter will not load 1475 Leaving out the screen size parameter will not load
1474 the TFT driver, and the framebuffer will be left 1476 the TFT driver, and the framebuffer will be left
1475 unconfigured. 1477 unconfigured.
1476 b - Enable backlight. The TFT backlight pin will be 1478 b - Enable backlight. The TFT backlight pin will be
1477 linked to the kernel VESA blanking code and a GPIO 1479 linked to the kernel VESA blanking code and a GPIO
1478 LED. This parameter is not necessary when using the 1480 LED. This parameter is not necessary when using the
1479 VGA shield. 1481 VGA shield.
1480 c - Enable the s3c camera interface. 1482 c - Enable the s3c camera interface.
1481 t - Reserved for enabling touchscreen support. The 1483 t - Reserved for enabling touchscreen support. The
1482 touchscreen support is not enabled in the mainstream 1484 touchscreen support is not enabled in the mainstream
1483 kernel as of 2.6.30, a preliminary port can be found 1485 kernel as of 2.6.30, a preliminary port can be found
1484 in the "bleeding edge" mini2440 support kernel at 1486 in the "bleeding edge" mini2440 support kernel at
1485 http://repo.or.cz/w/linux-2.6/mini2440.git 1487 http://repo.or.cz/w/linux-2.6/mini2440.git
1486 1488
1487 mminit_loglevel= 1489 mminit_loglevel=
1488 [KNL] When CONFIG_DEBUG_MEMORY_INIT is set, this 1490 [KNL] When CONFIG_DEBUG_MEMORY_INIT is set, this
1489 parameter allows control of the logging verbosity for 1491 parameter allows control of the logging verbosity for
1490 the additional memory initialisation checks. A value 1492 the additional memory initialisation checks. A value
1491 of 0 disables mminit logging and a level of 4 will 1493 of 0 disables mminit logging and a level of 4 will
1492 log everything. Information is printed at KERN_DEBUG 1494 log everything. Information is printed at KERN_DEBUG
1493 so loglevel=8 may also need to be specified. 1495 so loglevel=8 may also need to be specified.
1494 1496
1495 mousedev.tap_time= 1497 mousedev.tap_time=
1496 [MOUSE] Maximum time between finger touching and 1498 [MOUSE] Maximum time between finger touching and
1497 leaving touchpad surface for touch to be considered 1499 leaving touchpad surface for touch to be considered
1498 a tap and be reported as a left button click (for 1500 a tap and be reported as a left button click (for
1499 touchpads working in absolute mode only). 1501 touchpads working in absolute mode only).
1500 Format: <msecs> 1502 Format: <msecs>
1501 mousedev.xres= [MOUSE] Horizontal screen resolution, used for devices 1503 mousedev.xres= [MOUSE] Horizontal screen resolution, used for devices
1502 reporting absolute coordinates, such as tablets 1504 reporting absolute coordinates, such as tablets
1503 mousedev.yres= [MOUSE] Vertical screen resolution, used for devices 1505 mousedev.yres= [MOUSE] Vertical screen resolution, used for devices
1504 reporting absolute coordinates, such as tablets 1506 reporting absolute coordinates, such as tablets
1505 1507
1506 movablecore=nn[KMG] [KNL,X86,IA-64,PPC] This parameter 1508 movablecore=nn[KMG] [KNL,X86,IA-64,PPC] This parameter
1507 is similar to kernelcore except it specifies the 1509 is similar to kernelcore except it specifies the
1508 amount of memory used for migratable allocations. 1510 amount of memory used for migratable allocations.
1509 If both kernelcore and movablecore is specified, 1511 If both kernelcore and movablecore is specified,
1510 then kernelcore will be at *least* the specified 1512 then kernelcore will be at *least* the specified
1511 value but may be more. If movablecore on its own 1513 value but may be more. If movablecore on its own
1512 is specified, the administrator must be careful 1514 is specified, the administrator must be careful
1513 that the amount of memory usable for all allocations 1515 that the amount of memory usable for all allocations
1514 is not too small. 1516 is not too small.
1515 1517
1516 mpu401= [HW,OSS] 1518 mpu401= [HW,OSS]
1517 Format: <io>,<irq> 1519 Format: <io>,<irq>
1518 1520
1519 MTD_Partition= [MTD] 1521 MTD_Partition= [MTD]
1520 Format: <name>,<region-number>,<size>,<offset> 1522 Format: <name>,<region-number>,<size>,<offset>
1521 1523
1522 MTD_Region= [MTD] Format: 1524 MTD_Region= [MTD] Format:
1523 <name>,<region-number>[,<base>,<size>,<buswidth>,<altbuswidth>] 1525 <name>,<region-number>[,<base>,<size>,<buswidth>,<altbuswidth>]
1524 1526
1525 mtdparts= [MTD] 1527 mtdparts= [MTD]
1526 See drivers/mtd/cmdlinepart.c. 1528 See drivers/mtd/cmdlinepart.c.
1527 1529
1528 onenand.bdry= [HW,MTD] Flex-OneNAND Boundary Configuration 1530 onenand.bdry= [HW,MTD] Flex-OneNAND Boundary Configuration
1529 1531
1530 Format: [die0_boundary][,die0_lock][,die1_boundary][,die1_lock] 1532 Format: [die0_boundary][,die0_lock][,die1_boundary][,die1_lock]
1531 1533
1532 boundary - index of last SLC block on Flex-OneNAND. 1534 boundary - index of last SLC block on Flex-OneNAND.
1533 The remaining blocks are configured as MLC blocks. 1535 The remaining blocks are configured as MLC blocks.
1534 lock - Configure if Flex-OneNAND boundary should be locked. 1536 lock - Configure if Flex-OneNAND boundary should be locked.
1535 Once locked, the boundary cannot be changed. 1537 Once locked, the boundary cannot be changed.
1536 1 indicates lock status, 0 indicates unlock status. 1538 1 indicates lock status, 0 indicates unlock status.
1537 1539
1538 mtdset= [ARM] 1540 mtdset= [ARM]
1539 ARM/S3C2412 JIVE boot control 1541 ARM/S3C2412 JIVE boot control
1540 1542
1541 See arch/arm/mach-s3c2412/mach-jive.c 1543 See arch/arm/mach-s3c2412/mach-jive.c
1542 1544
1543 mtouchusb.raw_coordinates= 1545 mtouchusb.raw_coordinates=
1544 [HW] Make the MicroTouch USB driver use raw coordinates 1546 [HW] Make the MicroTouch USB driver use raw coordinates
1545 ('y', default) or cooked coordinates ('n') 1547 ('y', default) or cooked coordinates ('n')
1546 1548
1547 mtrr_chunk_size=nn[KMG] [X86] 1549 mtrr_chunk_size=nn[KMG] [X86]
1548 used for mtrr cleanup. It is largest continuous chunk 1550 used for mtrr cleanup. It is largest continuous chunk
1549 that could hold holes aka. UC entries. 1551 that could hold holes aka. UC entries.
1550 1552
1551 mtrr_gran_size=nn[KMG] [X86] 1553 mtrr_gran_size=nn[KMG] [X86]
1552 Used for mtrr cleanup. It is granularity of mtrr block. 1554 Used for mtrr cleanup. It is granularity of mtrr block.
1553 Default is 1. 1555 Default is 1.
1554 Large value could prevent small alignment from 1556 Large value could prevent small alignment from
1555 using up MTRRs. 1557 using up MTRRs.
1556 1558
1557 mtrr_spare_reg_nr=n [X86] 1559 mtrr_spare_reg_nr=n [X86]
1558 Format: <integer> 1560 Format: <integer>
1559 Range: 0,7 : spare reg number 1561 Range: 0,7 : spare reg number
1560 Default : 1 1562 Default : 1
1561 Used for mtrr cleanup. It is spare mtrr entries number. 1563 Used for mtrr cleanup. It is spare mtrr entries number.
1562 Set to 2 or more if your graphical card needs more. 1564 Set to 2 or more if your graphical card needs more.
1563 1565
1564 n2= [NET] SDL Inc. RISCom/N2 synchronous serial card 1566 n2= [NET] SDL Inc. RISCom/N2 synchronous serial card
1565 1567
1566 NCR_D700= [HW,SCSI] 1568 NCR_D700= [HW,SCSI]
1567 See header of drivers/scsi/NCR_D700.c. 1569 See header of drivers/scsi/NCR_D700.c.
1568 1570
1569 ncr5380= [HW,SCSI] 1571 ncr5380= [HW,SCSI]
1570 1572
1571 ncr53c400= [HW,SCSI] 1573 ncr53c400= [HW,SCSI]
1572 1574
1573 ncr53c400a= [HW,SCSI] 1575 ncr53c400a= [HW,SCSI]
1574 1576
1575 ncr53c406a= [HW,SCSI] 1577 ncr53c406a= [HW,SCSI]
1576 1578
1577 ncr53c8xx= [HW,SCSI] 1579 ncr53c8xx= [HW,SCSI]
1578 1580
1579 netdev= [NET] Network devices parameters 1581 netdev= [NET] Network devices parameters
1580 Format: <irq>,<io>,<mem_start>,<mem_end>,<name> 1582 Format: <irq>,<io>,<mem_start>,<mem_end>,<name>
1581 Note that mem_start is often overloaded to mean 1583 Note that mem_start is often overloaded to mean
1582 something different and driver-specific. 1584 something different and driver-specific.
1583 This usage is only documented in each driver source 1585 This usage is only documented in each driver source
1584 file if at all. 1586 file if at all.
1585 1587
1586 nf_conntrack.acct= 1588 nf_conntrack.acct=
1587 [NETFILTER] Enable connection tracking flow accounting 1589 [NETFILTER] Enable connection tracking flow accounting
1588 0 to disable accounting 1590 0 to disable accounting
1589 1 to enable accounting 1591 1 to enable accounting
1590 Default value depends on CONFIG_NF_CT_ACCT that is 1592 Default value depends on CONFIG_NF_CT_ACCT that is
1591 going to be removed in 2.6.29. 1593 going to be removed in 2.6.29.
1592 1594
1593 nfsaddrs= [NFS] 1595 nfsaddrs= [NFS]
1594 See Documentation/filesystems/nfs/nfsroot.txt. 1596 See Documentation/filesystems/nfs/nfsroot.txt.
1595 1597
1596 nfsroot= [NFS] nfs root filesystem for disk-less boxes. 1598 nfsroot= [NFS] nfs root filesystem for disk-less boxes.
1597 See Documentation/filesystems/nfs/nfsroot.txt. 1599 See Documentation/filesystems/nfs/nfsroot.txt.
1598 1600
1599 nfs.callback_tcpport= 1601 nfs.callback_tcpport=
1600 [NFS] set the TCP port on which the NFSv4 callback 1602 [NFS] set the TCP port on which the NFSv4 callback
1601 channel should listen. 1603 channel should listen.
1602 1604
1603 nfs.cache_getent= 1605 nfs.cache_getent=
1604 [NFS] sets the pathname to the program which is used 1606 [NFS] sets the pathname to the program which is used
1605 to update the NFS client cache entries. 1607 to update the NFS client cache entries.
1606 1608
1607 nfs.cache_getent_timeout= 1609 nfs.cache_getent_timeout=
1608 [NFS] sets the timeout after which an attempt to 1610 [NFS] sets the timeout after which an attempt to
1609 update a cache entry is deemed to have failed. 1611 update a cache entry is deemed to have failed.
1610 1612
1611 nfs.idmap_cache_timeout= 1613 nfs.idmap_cache_timeout=
1612 [NFS] set the maximum lifetime for idmapper cache 1614 [NFS] set the maximum lifetime for idmapper cache
1613 entries. 1615 entries.
1614 1616
1615 nfs.enable_ino64= 1617 nfs.enable_ino64=
1616 [NFS] enable 64-bit inode numbers. 1618 [NFS] enable 64-bit inode numbers.
1617 If zero, the NFS client will fake up a 32-bit inode 1619 If zero, the NFS client will fake up a 32-bit inode
1618 number for the readdir() and stat() syscalls instead 1620 number for the readdir() and stat() syscalls instead
1619 of returning the full 64-bit number. 1621 of returning the full 64-bit number.
1620 The default is to return 64-bit inode numbers. 1622 The default is to return 64-bit inode numbers.
1621 1623
1622 nmi_debug= [KNL,AVR32,SH] Specify one or more actions to take 1624 nmi_debug= [KNL,AVR32,SH] Specify one or more actions to take
1623 when a NMI is triggered. 1625 when a NMI is triggered.
1624 Format: [state][,regs][,debounce][,die] 1626 Format: [state][,regs][,debounce][,die]
1625 1627
1626 nmi_watchdog= [KNL,BUGS=X86] Debugging features for SMP kernels 1628 nmi_watchdog= [KNL,BUGS=X86] Debugging features for SMP kernels
1627 Format: [panic,][num] 1629 Format: [panic,][num]
1628 Valid num: 0,1,2 1630 Valid num: 0,1,2
1629 0 - turn nmi_watchdog off 1631 0 - turn nmi_watchdog off
1630 1 - use the IO-APIC timer for the NMI watchdog 1632 1 - use the IO-APIC timer for the NMI watchdog
1631 2 - use the local APIC for the NMI watchdog using 1633 2 - use the local APIC for the NMI watchdog using
1632 a performance counter. Note: This will use one 1634 a performance counter. Note: This will use one
1633 performance counter and the local APIC's performance 1635 performance counter and the local APIC's performance
1634 vector. 1636 vector.
1635 When panic is specified, panic when an NMI watchdog 1637 When panic is specified, panic when an NMI watchdog
1636 timeout occurs. 1638 timeout occurs.
1637 This is useful when you use a panic=... timeout and 1639 This is useful when you use a panic=... timeout and
1638 need the box quickly up again. 1640 need the box quickly up again.
1639 Instead of 1 and 2 it is possible to use the following 1641 Instead of 1 and 2 it is possible to use the following
1640 symbolic names: lapic and ioapic 1642 symbolic names: lapic and ioapic
1641 Example: nmi_watchdog=2 or nmi_watchdog=panic,lapic 1643 Example: nmi_watchdog=2 or nmi_watchdog=panic,lapic
1642 1644
1643 netpoll.carrier_timeout= 1645 netpoll.carrier_timeout=
1644 [NET] Specifies amount of time (in seconds) that 1646 [NET] Specifies amount of time (in seconds) that
1645 netpoll should wait for a carrier. By default netpoll 1647 netpoll should wait for a carrier. By default netpoll
1646 waits 4 seconds. 1648 waits 4 seconds.
1647 1649
1648 no387 [BUGS=X86-32] Tells the kernel to use the 387 maths 1650 no387 [BUGS=X86-32] Tells the kernel to use the 387 maths
1649 emulation library even if a 387 maths coprocessor 1651 emulation library even if a 387 maths coprocessor
1650 is present. 1652 is present.
1651 1653
1652 no_console_suspend 1654 no_console_suspend
1653 [HW] Never suspend the console 1655 [HW] Never suspend the console
1654 Disable suspending of consoles during suspend and 1656 Disable suspending of consoles during suspend and
1655 hibernate operations. Once disabled, debugging 1657 hibernate operations. Once disabled, debugging
1656 messages can reach various consoles while the rest 1658 messages can reach various consoles while the rest
1657 of the system is being put to sleep (ie, while 1659 of the system is being put to sleep (ie, while
1658 debugging driver suspend/resume hooks). This may 1660 debugging driver suspend/resume hooks). This may
1659 not work reliably with all consoles, but is known 1661 not work reliably with all consoles, but is known
1660 to work with serial and VGA consoles. 1662 to work with serial and VGA consoles.
1661 1663
1662 noaliencache [MM, NUMA, SLAB] Disables the allocation of alien 1664 noaliencache [MM, NUMA, SLAB] Disables the allocation of alien
1663 caches in the slab allocator. Saves per-node memory, 1665 caches in the slab allocator. Saves per-node memory,
1664 but will impact performance. 1666 but will impact performance.
1665 1667
1666 noalign [KNL,ARM] 1668 noalign [KNL,ARM]
1667 1669
1668 noapic [SMP,APIC] Tells the kernel to not make use of any 1670 noapic [SMP,APIC] Tells the kernel to not make use of any
1669 IOAPICs that may be present in the system. 1671 IOAPICs that may be present in the system.
1670 1672
1671 nobats [PPC] Do not use BATs for mapping kernel lowmem 1673 nobats [PPC] Do not use BATs for mapping kernel lowmem
1672 on "Classic" PPC cores. 1674 on "Classic" PPC cores.
1673 1675
1674 nocache [ARM] 1676 nocache [ARM]
1675 1677
1676 noclflush [BUGS=X86] Don't use the CLFLUSH instruction 1678 noclflush [BUGS=X86] Don't use the CLFLUSH instruction
1677 1679
1678 nodelayacct [KNL] Disable per-task delay accounting 1680 nodelayacct [KNL] Disable per-task delay accounting
1679 1681
1680 nodisconnect [HW,SCSI,M68K] Disables SCSI disconnects. 1682 nodisconnect [HW,SCSI,M68K] Disables SCSI disconnects.
1681 1683
1682 nodsp [SH] Disable hardware DSP at boot time. 1684 nodsp [SH] Disable hardware DSP at boot time.
1683 1685
1684 noefi [X86] Disable EFI runtime services support. 1686 noefi [X86] Disable EFI runtime services support.
1685 1687
1686 noexec [IA-64] 1688 noexec [IA-64]
1687 1689
1688 noexec [X86] 1690 noexec [X86]
1689 On X86-32 available only on PAE configured kernels. 1691 On X86-32 available only on PAE configured kernels.
1690 noexec=on: enable non-executable mappings (default) 1692 noexec=on: enable non-executable mappings (default)
1691 noexec=off: disable non-executable mappings 1693 noexec=off: disable non-executable mappings
1692 1694
1693 noexec32 [X86-64] 1695 noexec32 [X86-64]
1694 This affects only 32-bit executables. 1696 This affects only 32-bit executables.
1695 noexec32=on: enable non-executable mappings (default) 1697 noexec32=on: enable non-executable mappings (default)
1696 read doesn't imply executable mappings 1698 read doesn't imply executable mappings
1697 noexec32=off: disable non-executable mappings 1699 noexec32=off: disable non-executable mappings
1698 read implies executable mappings 1700 read implies executable mappings
1699 1701
1700 nofpu [SH] Disable hardware FPU at boot time. 1702 nofpu [SH] Disable hardware FPU at boot time.
1701 1703
1702 nofxsr [BUGS=X86-32] Disables x86 floating point extended 1704 nofxsr [BUGS=X86-32] Disables x86 floating point extended
1703 register save and restore. The kernel will only save 1705 register save and restore. The kernel will only save
1704 legacy floating-point registers on task switch. 1706 legacy floating-point registers on task switch.
1705 1707
1706 noxsave [BUGS=X86] Disables x86 extended register state save 1708 noxsave [BUGS=X86] Disables x86 extended register state save
1707 and restore using xsave. The kernel will fallback to 1709 and restore using xsave. The kernel will fallback to
1708 enabling legacy floating-point and sse state. 1710 enabling legacy floating-point and sse state.
1709 1711
1710 nohlt [BUGS=ARM,SH] Tells the kernel that the sleep(SH) or 1712 nohlt [BUGS=ARM,SH] Tells the kernel that the sleep(SH) or
1711 wfi(ARM) instruction doesn't work correctly and not to 1713 wfi(ARM) instruction doesn't work correctly and not to
1712 use it. This is also useful when using JTAG debugger. 1714 use it. This is also useful when using JTAG debugger.
1713 1715
1714 no-hlt [BUGS=X86-32] Tells the kernel that the hlt 1716 no-hlt [BUGS=X86-32] Tells the kernel that the hlt
1715 instruction doesn't work correctly and not to 1717 instruction doesn't work correctly and not to
1716 use it. 1718 use it.
1717 1719
1718 no_file_caps Tells the kernel not to honor file capabilities. The 1720 no_file_caps Tells the kernel not to honor file capabilities. The
1719 only way then for a file to be executed with privilege 1721 only way then for a file to be executed with privilege
1720 is to be setuid root or executed by root. 1722 is to be setuid root or executed by root.
1721 1723
1722 nohalt [IA-64] Tells the kernel not to use the power saving 1724 nohalt [IA-64] Tells the kernel not to use the power saving
1723 function PAL_HALT_LIGHT when idle. This increases 1725 function PAL_HALT_LIGHT when idle. This increases
1724 power-consumption. On the positive side, it reduces 1726 power-consumption. On the positive side, it reduces
1725 interrupt wake-up latency, which may improve performance 1727 interrupt wake-up latency, which may improve performance
1726 in certain environments such as networked servers or 1728 in certain environments such as networked servers or
1727 real-time systems. 1729 real-time systems.
1728 1730
1729 nohz= [KNL] Boottime enable/disable dynamic ticks 1731 nohz= [KNL] Boottime enable/disable dynamic ticks
1730 Valid arguments: on, off 1732 Valid arguments: on, off
1731 Default: on 1733 Default: on
1732 1734
1733 noiotrap [SH] Disables trapped I/O port accesses. 1735 noiotrap [SH] Disables trapped I/O port accesses.
1734 1736
1735 noirqdebug [X86-32] Disables the code which attempts to detect and 1737 noirqdebug [X86-32] Disables the code which attempts to detect and
1736 disable unhandled interrupt sources. 1738 disable unhandled interrupt sources.
1737 1739
1738 no_timer_check [X86,APIC] Disables the code which tests for 1740 no_timer_check [X86,APIC] Disables the code which tests for
1739 broken timer IRQ sources. 1741 broken timer IRQ sources.
1740 1742
1741 noisapnp [ISAPNP] Disables ISA PnP code. 1743 noisapnp [ISAPNP] Disables ISA PnP code.
1742 1744
1743 noinitrd [RAM] Tells the kernel not to load any configured 1745 noinitrd [RAM] Tells the kernel not to load any configured
1744 initial RAM disk. 1746 initial RAM disk.
1745 1747
1746 nointremap [X86-64, Intel-IOMMU] Do not enable interrupt 1748 nointremap [X86-64, Intel-IOMMU] Do not enable interrupt
1747 remapping. 1749 remapping.
1748 1750
1749 nointroute [IA-64] 1751 nointroute [IA-64]
1750 1752
1751 nojitter [IA64] Disables jitter checking for ITC timers. 1753 nojitter [IA64] Disables jitter checking for ITC timers.
1752 1754
1753 nolapic [X86-32,APIC] Do not enable or use the local APIC. 1755 nolapic [X86-32,APIC] Do not enable or use the local APIC.
1754 1756
1755 nolapic_timer [X86-32,APIC] Do not use the local APIC timer. 1757 nolapic_timer [X86-32,APIC] Do not use the local APIC timer.
1756 1758
1757 noltlbs [PPC] Do not use large page/tlb entries for kernel 1759 noltlbs [PPC] Do not use large page/tlb entries for kernel
1758 lowmem mapping on PPC40x. 1760 lowmem mapping on PPC40x.
1759 1761
1760 nomca [IA-64] Disable machine check abort handling 1762 nomca [IA-64] Disable machine check abort handling
1761 1763
1762 nomce [X86-32] Machine Check Exception 1764 nomce [X86-32] Machine Check Exception
1763 1765
1764 nomfgpt [X86-32] Disable Multi-Function General Purpose 1766 nomfgpt [X86-32] Disable Multi-Function General Purpose
1765 Timer usage (for AMD Geode machines). 1767 Timer usage (for AMD Geode machines).
1766 1768
1767 nopat [X86] Disable PAT (page attribute table extension of 1769 nopat [X86] Disable PAT (page attribute table extension of
1768 pagetables) support. 1770 pagetables) support.
1769 1771
1770 norandmaps Don't use address space randomization. Equivalent to 1772 norandmaps Don't use address space randomization. Equivalent to
1771 echo 0 > /proc/sys/kernel/randomize_va_space 1773 echo 0 > /proc/sys/kernel/randomize_va_space
1772 1774
1773 noreplace-paravirt [X86-32,PV_OPS] Don't patch paravirt_ops 1775 noreplace-paravirt [X86-32,PV_OPS] Don't patch paravirt_ops
1774 1776
1775 noreplace-smp [X86-32,SMP] Don't replace SMP instructions 1777 noreplace-smp [X86-32,SMP] Don't replace SMP instructions
1776 with UP alternatives 1778 with UP alternatives
1777 1779
1778 noresidual [PPC] Don't use residual data on PReP machines. 1780 noresidual [PPC] Don't use residual data on PReP machines.
1779 1781
1780 noresume [SWSUSP] Disables resume and restores original swap 1782 noresume [SWSUSP] Disables resume and restores original swap
1781 space. 1783 space.
1782 1784
1783 no-scroll [VGA] Disables scrollback. 1785 no-scroll [VGA] Disables scrollback.
1784 This is required for the Braillex ib80-piezo Braille 1786 This is required for the Braillex ib80-piezo Braille
1785 reader made by F.H. Papenmeier (Germany). 1787 reader made by F.H. Papenmeier (Germany).
1786 1788
1787 nosbagart [IA-64] 1789 nosbagart [IA-64]
1788 1790
1789 nosep [BUGS=X86-32] Disables x86 SYSENTER/SYSEXIT support. 1791 nosep [BUGS=X86-32] Disables x86 SYSENTER/SYSEXIT support.
1790 1792
1791 nosmp [SMP] Tells an SMP kernel to act as a UP kernel, 1793 nosmp [SMP] Tells an SMP kernel to act as a UP kernel,
1792 and disable the IO APIC. legacy for "maxcpus=0". 1794 and disable the IO APIC. legacy for "maxcpus=0".
1793 1795
1794 nosoftlockup [KNL] Disable the soft-lockup detector. 1796 nosoftlockup [KNL] Disable the soft-lockup detector.
1795 1797
1796 noswapaccount [KNL] Disable accounting of swap in memory resource 1798 noswapaccount [KNL] Disable accounting of swap in memory resource
1797 controller. (See Documentation/cgroups/memory.txt) 1799 controller. (See Documentation/cgroups/memory.txt)
1798 1800
1799 nosync [HW,M68K] Disables sync negotiation for all devices. 1801 nosync [HW,M68K] Disables sync negotiation for all devices.
1800 1802
1801 notsc [BUGS=X86-32] Disable Time Stamp Counter 1803 notsc [BUGS=X86-32] Disable Time Stamp Counter
1802 1804
1803 nousb [USB] Disable the USB subsystem 1805 nousb [USB] Disable the USB subsystem
1804 1806
1805 nowb [ARM] 1807 nowb [ARM]
1806 1808
1807 nox2apic [X86-64,APIC] Do not enable x2APIC mode. 1809 nox2apic [X86-64,APIC] Do not enable x2APIC mode.
1808 1810
1809 nptcg= [IA64] Override max number of concurrent global TLB 1811 nptcg= [IA64] Override max number of concurrent global TLB
1810 purges which is reported from either PAL_VM_SUMMARY or 1812 purges which is reported from either PAL_VM_SUMMARY or
1811 SAL PALO. 1813 SAL PALO.
1812 1814
1813 nr_cpus= [SMP] Maximum number of processors that an SMP kernel 1815 nr_cpus= [SMP] Maximum number of processors that an SMP kernel
1814 could support. nr_cpus=n : n >= 1 limits the kernel to 1816 could support. nr_cpus=n : n >= 1 limits the kernel to
1815 supporting 'n' processors. Later in runtime you can not 1817 supporting 'n' processors. Later in runtime you can not
1816 use hotplug cpu feature to put more cpu back to online. 1818 use hotplug cpu feature to put more cpu back to online.
1817 just like you compile the kernel NR_CPUS=n 1819 just like you compile the kernel NR_CPUS=n
1818 1820
1819 nr_uarts= [SERIAL] maximum number of UARTs to be registered. 1821 nr_uarts= [SERIAL] maximum number of UARTs to be registered.
1820 1822
1821 numa_zonelist_order= [KNL, BOOT] Select zonelist order for NUMA. 1823 numa_zonelist_order= [KNL, BOOT] Select zonelist order for NUMA.
1822 one of ['zone', 'node', 'default'] can be specified 1824 one of ['zone', 'node', 'default'] can be specified
1823 This can be set from sysctl after boot. 1825 This can be set from sysctl after boot.
1824 See Documentation/sysctl/vm.txt for details. 1826 See Documentation/sysctl/vm.txt for details.
1825 1827
1826 ohci1394_dma=early [HW] enable debugging via the ohci1394 driver. 1828 ohci1394_dma=early [HW] enable debugging via the ohci1394 driver.
1827 See Documentation/debugging-via-ohci1394.txt for more 1829 See Documentation/debugging-via-ohci1394.txt for more
1828 info. 1830 info.
1829 1831
1830 olpc_ec_timeout= [OLPC] ms delay when issuing EC commands 1832 olpc_ec_timeout= [OLPC] ms delay when issuing EC commands
1831 Rather than timing out after 20 ms if an EC 1833 Rather than timing out after 20 ms if an EC
1832 command is not properly ACKed, override the length 1834 command is not properly ACKed, override the length
1833 of the timeout. We have interrupts disabled while 1835 of the timeout. We have interrupts disabled while
1834 waiting for the ACK, so if this is set too high 1836 waiting for the ACK, so if this is set too high
1835 interrupts *may* be lost! 1837 interrupts *may* be lost!
1836 1838
1837 omap_mux= [OMAP] Override bootloader pin multiplexing. 1839 omap_mux= [OMAP] Override bootloader pin multiplexing.
1838 Format: <mux_mode0.mode_name=value>... 1840 Format: <mux_mode0.mode_name=value>...
1839 For example, to override I2C bus2: 1841 For example, to override I2C bus2:
1840 omap_mux=i2c2_scl.i2c2_scl=0x100,i2c2_sda.i2c2_sda=0x100 1842 omap_mux=i2c2_scl.i2c2_scl=0x100,i2c2_sda.i2c2_sda=0x100
1841 1843
1842 opl3= [HW,OSS] 1844 opl3= [HW,OSS]
1843 Format: <io> 1845 Format: <io>
1844 1846
1845 oprofile.timer= [HW] 1847 oprofile.timer= [HW]
1846 Use timer interrupt instead of performance counters 1848 Use timer interrupt instead of performance counters
1847 1849
1848 oprofile.cpu_type= Force an oprofile cpu type 1850 oprofile.cpu_type= Force an oprofile cpu type
1849 This might be useful if you have an older oprofile 1851 This might be useful if you have an older oprofile
1850 userland or if you want common events. 1852 userland or if you want common events.
1851 Format: { arch_perfmon } 1853 Format: { arch_perfmon }
1852 arch_perfmon: [X86] Force use of architectural 1854 arch_perfmon: [X86] Force use of architectural
1853 perfmon on Intel CPUs instead of the 1855 perfmon on Intel CPUs instead of the
1854 CPU specific event set. 1856 CPU specific event set.
1855 1857
1856 osst= [HW,SCSI] SCSI Tape Driver 1858 osst= [HW,SCSI] SCSI Tape Driver
1857 Format: <buffer_size>,<write_threshold> 1859 Format: <buffer_size>,<write_threshold>
1858 See also Documentation/scsi/st.txt. 1860 See also Documentation/scsi/st.txt.
1859 1861
1860 panic= [KNL] Kernel behaviour on panic 1862 panic= [KNL] Kernel behaviour on panic
1861 Format: <timeout> 1863 Format: <timeout>
1862 1864
1863 parkbd.port= [HW] Parallel port number the keyboard adapter is 1865 parkbd.port= [HW] Parallel port number the keyboard adapter is
1864 connected to, default is 0. 1866 connected to, default is 0.
1865 Format: <parport#> 1867 Format: <parport#>
1866 parkbd.mode= [HW] Parallel port keyboard adapter mode of operation, 1868 parkbd.mode= [HW] Parallel port keyboard adapter mode of operation,
1867 0 for XT, 1 for AT (default is AT). 1869 0 for XT, 1 for AT (default is AT).
1868 Format: <mode> 1870 Format: <mode>
1869 1871
1870 parport= [HW,PPT] Specify parallel ports. 0 disables. 1872 parport= [HW,PPT] Specify parallel ports. 0 disables.
1871 Format: { 0 | auto | 0xBBB[,IRQ[,DMA]] } 1873 Format: { 0 | auto | 0xBBB[,IRQ[,DMA]] }
1872 Use 'auto' to force the driver to use any 1874 Use 'auto' to force the driver to use any
1873 IRQ/DMA settings detected (the default is to 1875 IRQ/DMA settings detected (the default is to
1874 ignore detected IRQ/DMA settings because of 1876 ignore detected IRQ/DMA settings because of
1875 possible conflicts). You can specify the base 1877 possible conflicts). You can specify the base
1876 address, IRQ, and DMA settings; IRQ and DMA 1878 address, IRQ, and DMA settings; IRQ and DMA
1877 should be numbers, or 'auto' (for using detected 1879 should be numbers, or 'auto' (for using detected
1878 settings on that particular port), or 'nofifo' 1880 settings on that particular port), or 'nofifo'
1879 (to avoid using a FIFO even if it is detected). 1881 (to avoid using a FIFO even if it is detected).
1880 Parallel ports are assigned in the order they 1882 Parallel ports are assigned in the order they
1881 are specified on the command line, starting 1883 are specified on the command line, starting
1882 with parport0. 1884 with parport0.
1883 1885
1884 parport_init_mode= [HW,PPT] 1886 parport_init_mode= [HW,PPT]
1885 Configure VIA parallel port to operate in 1887 Configure VIA parallel port to operate in
1886 a specific mode. This is necessary on Pegasos 1888 a specific mode. This is necessary on Pegasos
1887 computer where firmware has no options for setting 1889 computer where firmware has no options for setting
1888 up parallel port mode and sets it to spp. 1890 up parallel port mode and sets it to spp.
1889 Currently this function knows 686a and 8231 chips. 1891 Currently this function knows 686a and 8231 chips.
1890 Format: [spp|ps2|epp|ecp|ecpepp] 1892 Format: [spp|ps2|epp|ecp|ecpepp]
1891 1893
1892 pas2= [HW,OSS] Format: 1894 pas2= [HW,OSS] Format:
1893 <io>,<irq>,<dma>,<dma16>,<sb_io>,<sb_irq>,<sb_dma>,<sb_dma16> 1895 <io>,<irq>,<dma>,<dma16>,<sb_io>,<sb_irq>,<sb_dma>,<sb_dma16>
1894 1896
1895 pas16= [HW,SCSI] 1897 pas16= [HW,SCSI]
1896 See header of drivers/scsi/pas16.c. 1898 See header of drivers/scsi/pas16.c.
1897 1899
1898 pause_on_oops= 1900 pause_on_oops=
1899 Halt all CPUs after the first oops has been printed for 1901 Halt all CPUs after the first oops has been printed for
1900 the specified number of seconds. This is to be used if 1902 the specified number of seconds. This is to be used if
1901 your oopses keep scrolling off the screen. 1903 your oopses keep scrolling off the screen.
1902 1904
1903 pcbit= [HW,ISDN] 1905 pcbit= [HW,ISDN]
1904 1906
1905 pcd. [PARIDE] 1907 pcd. [PARIDE]
1906 See header of drivers/block/paride/pcd.c. 1908 See header of drivers/block/paride/pcd.c.
1907 See also Documentation/blockdev/paride.txt. 1909 See also Documentation/blockdev/paride.txt.
1908 1910
1909 pci=option[,option...] [PCI] various PCI subsystem options: 1911 pci=option[,option...] [PCI] various PCI subsystem options:
1910 earlydump [X86] dump PCI config space before the kernel 1912 earlydump [X86] dump PCI config space before the kernel
1911 changes anything 1913 changes anything
1912 off [X86] don't probe for the PCI bus 1914 off [X86] don't probe for the PCI bus
1913 bios [X86-32] force use of PCI BIOS, don't access 1915 bios [X86-32] force use of PCI BIOS, don't access
1914 the hardware directly. Use this if your machine 1916 the hardware directly. Use this if your machine
1915 has a non-standard PCI host bridge. 1917 has a non-standard PCI host bridge.
1916 nobios [X86-32] disallow use of PCI BIOS, only direct 1918 nobios [X86-32] disallow use of PCI BIOS, only direct
1917 hardware access methods are allowed. Use this 1919 hardware access methods are allowed. Use this
1918 if you experience crashes upon bootup and you 1920 if you experience crashes upon bootup and you
1919 suspect they are caused by the BIOS. 1921 suspect they are caused by the BIOS.
1920 conf1 [X86] Force use of PCI Configuration 1922 conf1 [X86] Force use of PCI Configuration
1921 Mechanism 1. 1923 Mechanism 1.
1922 conf2 [X86] Force use of PCI Configuration 1924 conf2 [X86] Force use of PCI Configuration
1923 Mechanism 2. 1925 Mechanism 2.
1924 noaer [PCIE] If the PCIEAER kernel config parameter is 1926 noaer [PCIE] If the PCIEAER kernel config parameter is
1925 enabled, this kernel boot option can be used to 1927 enabled, this kernel boot option can be used to
1926 disable the use of PCIE advanced error reporting. 1928 disable the use of PCIE advanced error reporting.
1927 nodomains [PCI] Disable support for multiple PCI 1929 nodomains [PCI] Disable support for multiple PCI
1928 root domains (aka PCI segments, in ACPI-speak). 1930 root domains (aka PCI segments, in ACPI-speak).
1929 nommconf [X86] Disable use of MMCONFIG for PCI 1931 nommconf [X86] Disable use of MMCONFIG for PCI
1930 Configuration 1932 Configuration
1931 check_enable_amd_mmconf [X86] check for and enable 1933 check_enable_amd_mmconf [X86] check for and enable
1932 properly configured MMIO access to PCI 1934 properly configured MMIO access to PCI
1933 config space on AMD family 10h CPU 1935 config space on AMD family 10h CPU
1934 nomsi [MSI] If the PCI_MSI kernel config parameter is 1936 nomsi [MSI] If the PCI_MSI kernel config parameter is
1935 enabled, this kernel boot option can be used to 1937 enabled, this kernel boot option can be used to
1936 disable the use of MSI interrupts system-wide. 1938 disable the use of MSI interrupts system-wide.
1937 noioapicquirk [APIC] Disable all boot interrupt quirks. 1939 noioapicquirk [APIC] Disable all boot interrupt quirks.
1938 Safety option to keep boot IRQs enabled. This 1940 Safety option to keep boot IRQs enabled. This
1939 should never be necessary. 1941 should never be necessary.
1940 ioapicreroute [APIC] Enable rerouting of boot IRQs to the 1942 ioapicreroute [APIC] Enable rerouting of boot IRQs to the
1941 primary IO-APIC for bridges that cannot disable 1943 primary IO-APIC for bridges that cannot disable
1942 boot IRQs. This fixes a source of spurious IRQs 1944 boot IRQs. This fixes a source of spurious IRQs
1943 when the system masks IRQs. 1945 when the system masks IRQs.
1944 noioapicreroute [APIC] Disable workaround that uses the 1946 noioapicreroute [APIC] Disable workaround that uses the
1945 boot IRQ equivalent of an IRQ that connects to 1947 boot IRQ equivalent of an IRQ that connects to
1946 a chipset where boot IRQs cannot be disabled. 1948 a chipset where boot IRQs cannot be disabled.
1947 The opposite of ioapicreroute. 1949 The opposite of ioapicreroute.
1948 biosirq [X86-32] Use PCI BIOS calls to get the interrupt 1950 biosirq [X86-32] Use PCI BIOS calls to get the interrupt
1949 routing table. These calls are known to be buggy 1951 routing table. These calls are known to be buggy
1950 on several machines and they hang the machine 1952 on several machines and they hang the machine
1951 when used, but on other computers it's the only 1953 when used, but on other computers it's the only
1952 way to get the interrupt routing table. Try 1954 way to get the interrupt routing table. Try
1953 this option if the kernel is unable to allocate 1955 this option if the kernel is unable to allocate
1954 IRQs or discover secondary PCI buses on your 1956 IRQs or discover secondary PCI buses on your
1955 motherboard. 1957 motherboard.
1956 rom [X86] Assign address space to expansion ROMs. 1958 rom [X86] Assign address space to expansion ROMs.
1957 Use with caution as certain devices share 1959 Use with caution as certain devices share
1958 address decoders between ROMs and other 1960 address decoders between ROMs and other
1959 resources. 1961 resources.
1960 norom [X86] Do not assign address space to 1962 norom [X86] Do not assign address space to
1961 expansion ROMs that do not already have 1963 expansion ROMs that do not already have
1962 BIOS assigned address ranges. 1964 BIOS assigned address ranges.
1963 irqmask=0xMMMM [X86] Set a bit mask of IRQs allowed to be 1965 irqmask=0xMMMM [X86] Set a bit mask of IRQs allowed to be
1964 assigned automatically to PCI devices. You can 1966 assigned automatically to PCI devices. You can
1965 make the kernel exclude IRQs of your ISA cards 1967 make the kernel exclude IRQs of your ISA cards
1966 this way. 1968 this way.
1967 pirqaddr=0xAAAAA [X86] Specify the physical address 1969 pirqaddr=0xAAAAA [X86] Specify the physical address
1968 of the PIRQ table (normally generated 1970 of the PIRQ table (normally generated
1969 by the BIOS) if it is outside the 1971 by the BIOS) if it is outside the
1970 F0000h-100000h range. 1972 F0000h-100000h range.
1971 lastbus=N [X86] Scan all buses thru bus #N. Can be 1973 lastbus=N [X86] Scan all buses thru bus #N. Can be
1972 useful if the kernel is unable to find your 1974 useful if the kernel is unable to find your
1973 secondary buses and you want to tell it 1975 secondary buses and you want to tell it
1974 explicitly which ones they are. 1976 explicitly which ones they are.
1975 assign-busses [X86] Always assign all PCI bus 1977 assign-busses [X86] Always assign all PCI bus
1976 numbers ourselves, overriding 1978 numbers ourselves, overriding
1977 whatever the firmware may have done. 1979 whatever the firmware may have done.
1978 usepirqmask [X86] Honor the possible IRQ mask stored 1980 usepirqmask [X86] Honor the possible IRQ mask stored
1979 in the BIOS $PIR table. This is needed on 1981 in the BIOS $PIR table. This is needed on
1980 some systems with broken BIOSes, notably 1982 some systems with broken BIOSes, notably
1981 some HP Pavilion N5400 and Omnibook XE3 1983 some HP Pavilion N5400 and Omnibook XE3
1982 notebooks. This will have no effect if ACPI 1984 notebooks. This will have no effect if ACPI
1983 IRQ routing is enabled. 1985 IRQ routing is enabled.
1984 noacpi [X86] Do not use ACPI for IRQ routing 1986 noacpi [X86] Do not use ACPI for IRQ routing
1985 or for PCI scanning. 1987 or for PCI scanning.
1986 use_crs [X86] Use PCI host bridge window information 1988 use_crs [X86] Use PCI host bridge window information
1987 from ACPI. On BIOSes from 2008 or later, this 1989 from ACPI. On BIOSes from 2008 or later, this
1988 is enabled by default. If you need to use this, 1990 is enabled by default. If you need to use this,
1989 please report a bug. 1991 please report a bug.
1990 nocrs [X86] Ignore PCI host bridge windows from ACPI. 1992 nocrs [X86] Ignore PCI host bridge windows from ACPI.
1991 If you need to use this, please report a bug. 1993 If you need to use this, please report a bug.
1992 routeirq Do IRQ routing for all PCI devices. 1994 routeirq Do IRQ routing for all PCI devices.
1993 This is normally done in pci_enable_device(), 1995 This is normally done in pci_enable_device(),
1994 so this option is a temporary workaround 1996 so this option is a temporary workaround
1995 for broken drivers that don't call it. 1997 for broken drivers that don't call it.
1996 skip_isa_align [X86] do not align io start addr, so can 1998 skip_isa_align [X86] do not align io start addr, so can
1997 handle more pci cards 1999 handle more pci cards
1998 firmware [ARM] Do not re-enumerate the bus but instead 2000 firmware [ARM] Do not re-enumerate the bus but instead
1999 just use the configuration from the 2001 just use the configuration from the
2000 bootloader. This is currently used on 2002 bootloader. This is currently used on
2001 IXP2000 systems where the bus has to be 2003 IXP2000 systems where the bus has to be
2002 configured a certain way for adjunct CPUs. 2004 configured a certain way for adjunct CPUs.
2003 noearly [X86] Don't do any early type 1 scanning. 2005 noearly [X86] Don't do any early type 1 scanning.
2004 This might help on some broken boards which 2006 This might help on some broken boards which
2005 machine check when some devices' config space 2007 machine check when some devices' config space
2006 is read. But various workarounds are disabled 2008 is read. But various workarounds are disabled
2007 and some IOMMU drivers will not work. 2009 and some IOMMU drivers will not work.
2008 bfsort Sort PCI devices into breadth-first order. 2010 bfsort Sort PCI devices into breadth-first order.
2009 This sorting is done to get a device 2011 This sorting is done to get a device
2010 order compatible with older (<= 2.4) kernels. 2012 order compatible with older (<= 2.4) kernels.
2011 nobfsort Don't sort PCI devices into breadth-first order. 2013 nobfsort Don't sort PCI devices into breadth-first order.
2012 cbiosize=nn[KMG] The fixed amount of bus space which is 2014 cbiosize=nn[KMG] The fixed amount of bus space which is
2013 reserved for the CardBus bridge's IO window. 2015 reserved for the CardBus bridge's IO window.
2014 The default value is 256 bytes. 2016 The default value is 256 bytes.
2015 cbmemsize=nn[KMG] The fixed amount of bus space which is 2017 cbmemsize=nn[KMG] The fixed amount of bus space which is
2016 reserved for the CardBus bridge's memory 2018 reserved for the CardBus bridge's memory
2017 window. The default value is 64 megabytes. 2019 window. The default value is 64 megabytes.
2018 resource_alignment= 2020 resource_alignment=
2019 Format: 2021 Format:
2020 [<order of align>@][<domain>:]<bus>:<slot>.<func>[; ...] 2022 [<order of align>@][<domain>:]<bus>:<slot>.<func>[; ...]
2021 Specifies alignment and device to reassign 2023 Specifies alignment and device to reassign
2022 aligned memory resources. 2024 aligned memory resources.
2023 If <order of align> is not specified, 2025 If <order of align> is not specified,
2024 PAGE_SIZE is used as alignment. 2026 PAGE_SIZE is used as alignment.
2025 PCI-PCI bridge can be specified, if resource 2027 PCI-PCI bridge can be specified, if resource
2026 windows need to be expanded. 2028 windows need to be expanded.
2027 ecrc= Enable/disable PCIe ECRC (transaction layer 2029 ecrc= Enable/disable PCIe ECRC (transaction layer
2028 end-to-end CRC checking). 2030 end-to-end CRC checking).
2029 bios: Use BIOS/firmware settings. This is the 2031 bios: Use BIOS/firmware settings. This is the
2030 the default. 2032 the default.
2031 off: Turn ECRC off 2033 off: Turn ECRC off
2032 on: Turn ECRC on. 2034 on: Turn ECRC on.
2033 2035
2034 pcie_aspm= [PCIE] Forcibly enable or disable PCIe Active State Power 2036 pcie_aspm= [PCIE] Forcibly enable or disable PCIe Active State Power
2035 Management. 2037 Management.
2036 off Disable ASPM. 2038 off Disable ASPM.
2037 force Enable ASPM even on devices that claim not to support it. 2039 force Enable ASPM even on devices that claim not to support it.
2038 WARNING: Forcing ASPM on may cause system lockups. 2040 WARNING: Forcing ASPM on may cause system lockups.
2039 2041
2040 pcie_pme= [PCIE,PM] Native PCIe PME signaling options: 2042 pcie_pme= [PCIE,PM] Native PCIe PME signaling options:
2041 off Do not use native PCIe PME signaling. 2043 off Do not use native PCIe PME signaling.
2042 force Use native PCIe PME signaling even if the BIOS refuses 2044 force Use native PCIe PME signaling even if the BIOS refuses
2043 to allow the kernel to control the relevant PCIe config 2045 to allow the kernel to control the relevant PCIe config
2044 registers. 2046 registers.
2045 nomsi Do not use MSI for native PCIe PME signaling (this makes 2047 nomsi Do not use MSI for native PCIe PME signaling (this makes
2046 all PCIe root ports use INTx for everything). 2048 all PCIe root ports use INTx for everything).
2047 2049
2048 pcmv= [HW,PCMCIA] BadgePAD 4 2050 pcmv= [HW,PCMCIA] BadgePAD 4
2049 2051
2050 pd. [PARIDE] 2052 pd. [PARIDE]
2051 See Documentation/blockdev/paride.txt. 2053 See Documentation/blockdev/paride.txt.
2052 2054
2053 pdcchassis= [PARISC,HW] Disable/Enable PDC Chassis Status codes at 2055 pdcchassis= [PARISC,HW] Disable/Enable PDC Chassis Status codes at
2054 boot time. 2056 boot time.
2055 Format: { 0 | 1 } 2057 Format: { 0 | 1 }
2056 See arch/parisc/kernel/pdc_chassis.c 2058 See arch/parisc/kernel/pdc_chassis.c
2057 2059
2058 percpu_alloc= Select which percpu first chunk allocator to use. 2060 percpu_alloc= Select which percpu first chunk allocator to use.
2059 Currently supported values are "embed" and "page". 2061 Currently supported values are "embed" and "page".
2060 Archs may support subset or none of the selections. 2062 Archs may support subset or none of the selections.
2061 See comments in mm/percpu.c for details on each 2063 See comments in mm/percpu.c for details on each
2062 allocator. This parameter is primarily for debugging 2064 allocator. This parameter is primarily for debugging
2063 and performance comparison. 2065 and performance comparison.
2064 2066
2065 pf. [PARIDE] 2067 pf. [PARIDE]
2066 See Documentation/blockdev/paride.txt. 2068 See Documentation/blockdev/paride.txt.
2067 2069
2068 pg. [PARIDE] 2070 pg. [PARIDE]
2069 See Documentation/blockdev/paride.txt. 2071 See Documentation/blockdev/paride.txt.
2070 2072
2071 pirq= [SMP,APIC] Manual mp-table setup 2073 pirq= [SMP,APIC] Manual mp-table setup
2072 See Documentation/x86/i386/IO-APIC.txt. 2074 See Documentation/x86/i386/IO-APIC.txt.
2073 2075
2074 plip= [PPT,NET] Parallel port network link 2076 plip= [PPT,NET] Parallel port network link
2075 Format: { parport<nr> | timid | 0 } 2077 Format: { parport<nr> | timid | 0 }
2076 See also Documentation/parport.txt. 2078 See also Documentation/parport.txt.
2077 2079
2078 pmtmr= [X86] Manual setup of pmtmr I/O Port. 2080 pmtmr= [X86] Manual setup of pmtmr I/O Port.
2079 Override pmtimer IOPort with a hex value. 2081 Override pmtimer IOPort with a hex value.
2080 e.g. pmtmr=0x508 2082 e.g. pmtmr=0x508
2081 2083
2082 pnp.debug [PNP] 2084 pnp.debug [PNP]
2083 Enable PNP debug messages. This depends on the 2085 Enable PNP debug messages. This depends on the
2084 CONFIG_PNP_DEBUG_MESSAGES option. 2086 CONFIG_PNP_DEBUG_MESSAGES option.
2085 2087
2086 pnpacpi= [ACPI] 2088 pnpacpi= [ACPI]
2087 { off } 2089 { off }
2088 2090
2089 pnpbios= [ISAPNP] 2091 pnpbios= [ISAPNP]
2090 { on | off | curr | res | no-curr | no-res } 2092 { on | off | curr | res | no-curr | no-res }
2091 2093
2092 pnp_reserve_irq= 2094 pnp_reserve_irq=
2093 [ISAPNP] Exclude IRQs for the autoconfiguration 2095 [ISAPNP] Exclude IRQs for the autoconfiguration
2094 2096
2095 pnp_reserve_dma= 2097 pnp_reserve_dma=
2096 [ISAPNP] Exclude DMAs for the autoconfiguration 2098 [ISAPNP] Exclude DMAs for the autoconfiguration
2097 2099
2098 pnp_reserve_io= [ISAPNP] Exclude I/O ports for the autoconfiguration 2100 pnp_reserve_io= [ISAPNP] Exclude I/O ports for the autoconfiguration
2099 Ranges are in pairs (I/O port base and size). 2101 Ranges are in pairs (I/O port base and size).
2100 2102
2101 pnp_reserve_mem= 2103 pnp_reserve_mem=
2102 [ISAPNP] Exclude memory regions for the 2104 [ISAPNP] Exclude memory regions for the
2103 autoconfiguration. 2105 autoconfiguration.
2104 Ranges are in pairs (memory base and size). 2106 Ranges are in pairs (memory base and size).
2105 2107
2106 ports= [IP_VS_FTP] IPVS ftp helper module 2108 ports= [IP_VS_FTP] IPVS ftp helper module
2107 Default is 21. 2109 Default is 21.
2108 Up to 8 (IP_VS_APP_MAX_PORTS) ports 2110 Up to 8 (IP_VS_APP_MAX_PORTS) ports
2109 may be specified. 2111 may be specified.
2110 Format: <port>,<port>.... 2112 Format: <port>,<port>....
2111 2113
2112 print-fatal-signals= 2114 print-fatal-signals=
2113 [KNL] debug: print fatal signals 2115 [KNL] debug: print fatal signals
2114 2116
2115 If enabled, warn about various signal handling 2117 If enabled, warn about various signal handling
2116 related application anomalies: too many signals, 2118 related application anomalies: too many signals,
2117 too many POSIX.1 timers, fatal signals causing a 2119 too many POSIX.1 timers, fatal signals causing a
2118 coredump - etc. 2120 coredump - etc.
2119 2121
2120 If you hit the warning due to signal overflow, 2122 If you hit the warning due to signal overflow,
2121 you might want to try "ulimit -i unlimited". 2123 you might want to try "ulimit -i unlimited".
2122 2124
2123 default: off. 2125 default: off.
2124 2126
2125 printk.time= Show timing data prefixed to each printk message line 2127 printk.time= Show timing data prefixed to each printk message line
2126 Format: <bool> (1/Y/y=enable, 0/N/n=disable) 2128 Format: <bool> (1/Y/y=enable, 0/N/n=disable)
2127 2129
2128 processor.max_cstate= [HW,ACPI] 2130 processor.max_cstate= [HW,ACPI]
2129 Limit processor to maximum C-state 2131 Limit processor to maximum C-state
2130 max_cstate=9 overrides any DMI blacklist limit. 2132 max_cstate=9 overrides any DMI blacklist limit.
2131 2133
2132 processor.nocst [HW,ACPI] 2134 processor.nocst [HW,ACPI]
2133 Ignore the _CST method to determine C-states, 2135 Ignore the _CST method to determine C-states,
2134 instead using the legacy FADT method 2136 instead using the legacy FADT method
2135 2137
2136 profile= [KNL] Enable kernel profiling via /proc/profile 2138 profile= [KNL] Enable kernel profiling via /proc/profile
2137 Format: [schedule,]<number> 2139 Format: [schedule,]<number>
2138 Param: "schedule" - profile schedule points. 2140 Param: "schedule" - profile schedule points.
2139 Param: <number> - step/bucket size as a power of 2 for 2141 Param: <number> - step/bucket size as a power of 2 for
2140 statistical time based profiling. 2142 statistical time based profiling.
2141 Param: "sleep" - profile D-state sleeping (millisecs). 2143 Param: "sleep" - profile D-state sleeping (millisecs).
2142 Requires CONFIG_SCHEDSTATS 2144 Requires CONFIG_SCHEDSTATS
2143 Param: "kvm" - profile VM exits. 2145 Param: "kvm" - profile VM exits.
2144 2146
2145 prompt_ramdisk= [RAM] List of RAM disks to prompt for floppy disk 2147 prompt_ramdisk= [RAM] List of RAM disks to prompt for floppy disk
2146 before loading. 2148 before loading.
2147 See Documentation/blockdev/ramdisk.txt. 2149 See Documentation/blockdev/ramdisk.txt.
2148 2150
2149 psmouse.proto= [HW,MOUSE] Highest PS2 mouse protocol extension to 2151 psmouse.proto= [HW,MOUSE] Highest PS2 mouse protocol extension to
2150 probe for; one of (bare|imps|exps|lifebook|any). 2152 probe for; one of (bare|imps|exps|lifebook|any).
2151 psmouse.rate= [HW,MOUSE] Set desired mouse report rate, in reports 2153 psmouse.rate= [HW,MOUSE] Set desired mouse report rate, in reports
2152 per second. 2154 per second.
2153 psmouse.resetafter= [HW,MOUSE] 2155 psmouse.resetafter= [HW,MOUSE]
2154 Try to reset the device after so many bad packets 2156 Try to reset the device after so many bad packets
2155 (0 = never). 2157 (0 = never).
2156 psmouse.resolution= 2158 psmouse.resolution=
2157 [HW,MOUSE] Set desired mouse resolution, in dpi. 2159 [HW,MOUSE] Set desired mouse resolution, in dpi.
2158 psmouse.smartscroll= 2160 psmouse.smartscroll=
2159 [HW,MOUSE] Controls Logitech smartscroll autorepeat. 2161 [HW,MOUSE] Controls Logitech smartscroll autorepeat.
2160 0 = disabled, 1 = enabled (default). 2162 0 = disabled, 1 = enabled (default).
2161 2163
2162 pss= [HW,OSS] Personal Sound System (ECHO ESC614) 2164 pss= [HW,OSS] Personal Sound System (ECHO ESC614)
2163 Format: 2165 Format:
2164 <io>,<mss_io>,<mss_irq>,<mss_dma>,<mpu_io>,<mpu_irq> 2166 <io>,<mss_io>,<mss_irq>,<mss_dma>,<mpu_io>,<mpu_irq>
2165 2167
2166 pt. [PARIDE] 2168 pt. [PARIDE]
2167 See Documentation/blockdev/paride.txt. 2169 See Documentation/blockdev/paride.txt.
2168 2170
2169 pty.legacy_count= 2171 pty.legacy_count=
2170 [KNL] Number of legacy pty's. Overwrites compiled-in 2172 [KNL] Number of legacy pty's. Overwrites compiled-in
2171 default number. 2173 default number.
2172 2174
2173 quiet [KNL] Disable most log messages 2175 quiet [KNL] Disable most log messages
2174 2176
2175 r128= [HW,DRM] 2177 r128= [HW,DRM]
2176 2178
2177 raid= [HW,RAID] 2179 raid= [HW,RAID]
2178 See Documentation/md.txt. 2180 See Documentation/md.txt.
2179 2181
2180 ramdisk_blocksize= [RAM] 2182 ramdisk_blocksize= [RAM]
2181 See Documentation/blockdev/ramdisk.txt. 2183 See Documentation/blockdev/ramdisk.txt.
2182 2184
2183 ramdisk_size= [RAM] Sizes of RAM disks in kilobytes 2185 ramdisk_size= [RAM] Sizes of RAM disks in kilobytes
2184 See Documentation/blockdev/ramdisk.txt. 2186 See Documentation/blockdev/ramdisk.txt.
2185 2187
2186 rcupdate.blimit= [KNL,BOOT] 2188 rcupdate.blimit= [KNL,BOOT]
2187 Set maximum number of finished RCU callbacks to process 2189 Set maximum number of finished RCU callbacks to process
2188 in one batch. 2190 in one batch.
2189 2191
2190 rcupdate.qhimark= [KNL,BOOT] 2192 rcupdate.qhimark= [KNL,BOOT]
2191 Set threshold of queued 2193 Set threshold of queued
2192 RCU callbacks over which batch limiting is disabled. 2194 RCU callbacks over which batch limiting is disabled.
2193 2195
2194 rcupdate.qlowmark= [KNL,BOOT] 2196 rcupdate.qlowmark= [KNL,BOOT]
2195 Set threshold of queued RCU callbacks below which 2197 Set threshold of queued RCU callbacks below which
2196 batch limiting is re-enabled. 2198 batch limiting is re-enabled.
2197 2199
2198 rdinit= [KNL] 2200 rdinit= [KNL]
2199 Format: <full_path> 2201 Format: <full_path>
2200 Run specified binary instead of /init from the ramdisk, 2202 Run specified binary instead of /init from the ramdisk,
2201 used for early userspace startup. See initrd. 2203 used for early userspace startup. See initrd.
2202 2204
2203 reboot= [BUGS=X86-32,BUGS=ARM,BUGS=IA-64] Rebooting mode 2205 reboot= [BUGS=X86-32,BUGS=ARM,BUGS=IA-64] Rebooting mode
2204 Format: <reboot_mode>[,<reboot_mode2>[,...]] 2206 Format: <reboot_mode>[,<reboot_mode2>[,...]]
2205 See arch/*/kernel/reboot.c or arch/*/kernel/process.c 2207 See arch/*/kernel/reboot.c or arch/*/kernel/process.c
2206 2208
2207 relax_domain_level= 2209 relax_domain_level=
2208 [KNL, SMP] Set scheduler's default relax_domain_level. 2210 [KNL, SMP] Set scheduler's default relax_domain_level.
2209 See Documentation/cgroups/cpusets.txt. 2211 See Documentation/cgroups/cpusets.txt.
2210 2212
2211 reserve= [KNL,BUGS] Force the kernel to ignore some iomem area 2213 reserve= [KNL,BUGS] Force the kernel to ignore some iomem area
2212 2214
2213 reservetop= [X86-32] 2215 reservetop= [X86-32]
2214 Format: nn[KMG] 2216 Format: nn[KMG]
2215 Reserves a hole at the top of the kernel virtual 2217 Reserves a hole at the top of the kernel virtual
2216 address space. 2218 address space.
2217 2219
2218 reset_devices [KNL] Force drivers to reset the underlying device 2220 reset_devices [KNL] Force drivers to reset the underlying device
2219 during initialization. 2221 during initialization.
2220 2222
2221 resume= [SWSUSP] 2223 resume= [SWSUSP]
2222 Specify the partition device for software suspend 2224 Specify the partition device for software suspend
2223 2225
2224 resume_offset= [SWSUSP] 2226 resume_offset= [SWSUSP]
2225 Specify the offset from the beginning of the partition 2227 Specify the offset from the beginning of the partition
2226 given by "resume=" at which the swap header is located, 2228 given by "resume=" at which the swap header is located,
2227 in <PAGE_SIZE> units (needed only for swap files). 2229 in <PAGE_SIZE> units (needed only for swap files).
2228 See Documentation/power/swsusp-and-swap-files.txt 2230 See Documentation/power/swsusp-and-swap-files.txt
2229 2231
2230 retain_initrd [RAM] Keep initrd memory after extraction 2232 retain_initrd [RAM] Keep initrd memory after extraction
2231 2233
2232 rhash_entries= [KNL,NET] 2234 rhash_entries= [KNL,NET]
2233 Set number of hash buckets for route cache 2235 Set number of hash buckets for route cache
2234 2236
2235 riscom8= [HW,SERIAL] 2237 riscom8= [HW,SERIAL]
2236 Format: <io_board1>[,<io_board2>[,...<io_boardN>]] 2238 Format: <io_board1>[,<io_board2>[,...<io_boardN>]]
2237 2239
2238 ro [KNL] Mount root device read-only on boot 2240 ro [KNL] Mount root device read-only on boot
2239 2241
2240 root= [KNL] Root filesystem 2242 root= [KNL] Root filesystem
2241 2243
2242 rootdelay= [KNL] Delay (in seconds) to pause before attempting to 2244 rootdelay= [KNL] Delay (in seconds) to pause before attempting to
2243 mount the root filesystem 2245 mount the root filesystem
2244 2246
2245 rootflags= [KNL] Set root filesystem mount option string 2247 rootflags= [KNL] Set root filesystem mount option string
2246 2248
2247 rootfstype= [KNL] Set root filesystem type 2249 rootfstype= [KNL] Set root filesystem type
2248 2250
2249 rootwait [KNL] Wait (indefinitely) for root device to show up. 2251 rootwait [KNL] Wait (indefinitely) for root device to show up.
2250 Useful for devices that are detected asynchronously 2252 Useful for devices that are detected asynchronously
2251 (e.g. USB and MMC devices). 2253 (e.g. USB and MMC devices).
2252 2254
2253 rw [KNL] Mount root device read-write on boot 2255 rw [KNL] Mount root device read-write on boot
2254 2256
2255 S [KNL] Run init in single mode 2257 S [KNL] Run init in single mode
2256 2258
2257 sa1100ir [NET] 2259 sa1100ir [NET]
2258 See drivers/net/irda/sa1100_ir.c. 2260 See drivers/net/irda/sa1100_ir.c.
2259 2261
2260 sbni= [NET] Granch SBNI12 leased line adapter 2262 sbni= [NET] Granch SBNI12 leased line adapter
2261 2263
2262 sched_debug [KNL] Enables verbose scheduler debug messages. 2264 sched_debug [KNL] Enables verbose scheduler debug messages.
2263 2265
2264 scsi_debug_*= [SCSI] 2266 scsi_debug_*= [SCSI]
2265 See drivers/scsi/scsi_debug.c. 2267 See drivers/scsi/scsi_debug.c.
2266 2268
2267 scsi_default_dev_flags= 2269 scsi_default_dev_flags=
2268 [SCSI] SCSI default device flags 2270 [SCSI] SCSI default device flags
2269 Format: <integer> 2271 Format: <integer>
2270 2272
2271 scsi_dev_flags= [SCSI] Black/white list entry for vendor and model 2273 scsi_dev_flags= [SCSI] Black/white list entry for vendor and model
2272 Format: <vendor>:<model>:<flags> 2274 Format: <vendor>:<model>:<flags>
2273 (flags are integer value) 2275 (flags are integer value)
2274 2276
2275 scsi_logging_level= [SCSI] a bit mask of logging levels 2277 scsi_logging_level= [SCSI] a bit mask of logging levels
2276 See drivers/scsi/scsi_logging.h for bits. Also 2278 See drivers/scsi/scsi_logging.h for bits. Also
2277 settable via sysctl at dev.scsi.logging_level 2279 settable via sysctl at dev.scsi.logging_level
2278 (/proc/sys/dev/scsi/logging_level). 2280 (/proc/sys/dev/scsi/logging_level).
2279 There is also a nice 'scsi_logging_level' script in the 2281 There is also a nice 'scsi_logging_level' script in the
2280 S390-tools package, available for download at 2282 S390-tools package, available for download at
2281 http://www-128.ibm.com/developerworks/linux/linux390/s390-tools-1.5.4.html 2283 http://www-128.ibm.com/developerworks/linux/linux390/s390-tools-1.5.4.html
2282 2284
2283 scsi_mod.scan= [SCSI] sync (default) scans SCSI busses as they are 2285 scsi_mod.scan= [SCSI] sync (default) scans SCSI busses as they are
2284 discovered. async scans them in kernel threads, 2286 discovered. async scans them in kernel threads,
2285 allowing boot to proceed. none ignores them, expecting 2287 allowing boot to proceed. none ignores them, expecting
2286 user space to do the scan. 2288 user space to do the scan.
2287 2289
2288 security= [SECURITY] Choose a security module to enable at boot. 2290 security= [SECURITY] Choose a security module to enable at boot.
2289 If this boot parameter is not specified, only the first 2291 If this boot parameter is not specified, only the first
2290 security module asking for security registration will be 2292 security module asking for security registration will be
2291 loaded. An invalid security module name will be treated 2293 loaded. An invalid security module name will be treated
2292 as if no module has been chosen. 2294 as if no module has been chosen.
2293 2295
2294 selinux= [SELINUX] Disable or enable SELinux at boot time. 2296 selinux= [SELINUX] Disable or enable SELinux at boot time.
2295 Format: { "0" | "1" } 2297 Format: { "0" | "1" }
2296 See security/selinux/Kconfig help text. 2298 See security/selinux/Kconfig help text.
2297 0 -- disable. 2299 0 -- disable.
2298 1 -- enable. 2300 1 -- enable.
2299 Default value is set via kernel config option. 2301 Default value is set via kernel config option.
2300 If enabled at boot time, /selinux/disable can be used 2302 If enabled at boot time, /selinux/disable can be used
2301 later to disable prior to initial policy load. 2303 later to disable prior to initial policy load.
2302 2304
2303 serialnumber [BUGS=X86-32] 2305 serialnumber [BUGS=X86-32]
2304 2306
2305 shapers= [NET] 2307 shapers= [NET]
2306 Maximal number of shapers. 2308 Maximal number of shapers.
2307 2309
2308 show_msr= [x86] show boot-time MSR settings 2310 show_msr= [x86] show boot-time MSR settings
2309 Format: { <integer> } 2311 Format: { <integer> }
2310 Show boot-time (BIOS-initialized) MSR settings. 2312 Show boot-time (BIOS-initialized) MSR settings.
2311 The parameter means the number of CPUs to show, 2313 The parameter means the number of CPUs to show,
2312 for example 1 means boot CPU only. 2314 for example 1 means boot CPU only.
2313 2315
2314 sim710= [SCSI,HW] 2316 sim710= [SCSI,HW]
2315 See header of drivers/scsi/sim710.c. 2317 See header of drivers/scsi/sim710.c.
2316 2318
2317 simeth= [IA-64] 2319 simeth= [IA-64]
2318 simscsi= 2320 simscsi=
2319 2321
2320 slram= [HW,MTD] 2322 slram= [HW,MTD]
2321 2323
2322 slub_debug[=options[,slabs]] [MM, SLUB] 2324 slub_debug[=options[,slabs]] [MM, SLUB]
2323 Enabling slub_debug allows one to determine the 2325 Enabling slub_debug allows one to determine the
2324 culprit if slab objects become corrupted. Enabling 2326 culprit if slab objects become corrupted. Enabling
2325 slub_debug can create guard zones around objects and 2327 slub_debug can create guard zones around objects and
2326 may poison objects when not in use. Also tracks the 2328 may poison objects when not in use. Also tracks the
2327 last alloc / free. For more information see 2329 last alloc / free. For more information see
2328 Documentation/vm/slub.txt. 2330 Documentation/vm/slub.txt.
2329 2331
2330 slub_max_order= [MM, SLUB] 2332 slub_max_order= [MM, SLUB]
2331 Determines the maximum allowed order for slabs. 2333 Determines the maximum allowed order for slabs.
2332 A high setting may cause OOMs due to memory 2334 A high setting may cause OOMs due to memory
2333 fragmentation. For more information see 2335 fragmentation. For more information see
2334 Documentation/vm/slub.txt. 2336 Documentation/vm/slub.txt.
2335 2337
2336 slub_min_objects= [MM, SLUB] 2338 slub_min_objects= [MM, SLUB]
2337 The minimum number of objects per slab. SLUB will 2339 The minimum number of objects per slab. SLUB will
2338 increase the slab order up to slub_max_order to 2340 increase the slab order up to slub_max_order to
2339 generate a sufficiently large slab able to contain 2341 generate a sufficiently large slab able to contain
2340 the number of objects indicated. The higher the number 2342 the number of objects indicated. The higher the number
2341 of objects the smaller the overhead of tracking slabs 2343 of objects the smaller the overhead of tracking slabs
2342 and the less frequently locks need to be acquired. 2344 and the less frequently locks need to be acquired.
2343 For more information see Documentation/vm/slub.txt. 2345 For more information see Documentation/vm/slub.txt.
2344 2346
2345 slub_min_order= [MM, SLUB] 2347 slub_min_order= [MM, SLUB]
2346 Determines the mininum page order for slabs. Must be 2348 Determines the mininum page order for slabs. Must be
2347 lower than slub_max_order. 2349 lower than slub_max_order.
2348 For more information see Documentation/vm/slub.txt. 2350 For more information see Documentation/vm/slub.txt.
2349 2351
2350 slub_nomerge [MM, SLUB] 2352 slub_nomerge [MM, SLUB]
2351 Disable merging of slabs with similar size. May be 2353 Disable merging of slabs with similar size. May be
2352 necessary if there is some reason to distinguish 2354 necessary if there is some reason to distinguish
2353 allocs to different slabs. Debug options disable 2355 allocs to different slabs. Debug options disable
2354 merging on their own. 2356 merging on their own.
2355 For more information see Documentation/vm/slub.txt. 2357 For more information see Documentation/vm/slub.txt.
2356 2358
2357 smart2= [HW] 2359 smart2= [HW]
2358 Format: <io1>[,<io2>[,...,<io8>]] 2360 Format: <io1>[,<io2>[,...,<io8>]]
2359 2361
2360 smp-alt-once [X86-32,SMP] On a hotplug CPU system, only 2362 smp-alt-once [X86-32,SMP] On a hotplug CPU system, only
2361 attempt to substitute SMP alternatives once at boot. 2363 attempt to substitute SMP alternatives once at boot.
2362 2364
2363 smsc-ircc2.nopnp [HW] Don't use PNP to discover SMC devices 2365 smsc-ircc2.nopnp [HW] Don't use PNP to discover SMC devices
2364 smsc-ircc2.ircc_cfg= [HW] Device configuration I/O port 2366 smsc-ircc2.ircc_cfg= [HW] Device configuration I/O port
2365 smsc-ircc2.ircc_sir= [HW] SIR base I/O port 2367 smsc-ircc2.ircc_sir= [HW] SIR base I/O port
2366 smsc-ircc2.ircc_fir= [HW] FIR base I/O port 2368 smsc-ircc2.ircc_fir= [HW] FIR base I/O port
2367 smsc-ircc2.ircc_irq= [HW] IRQ line 2369 smsc-ircc2.ircc_irq= [HW] IRQ line
2368 smsc-ircc2.ircc_dma= [HW] DMA channel 2370 smsc-ircc2.ircc_dma= [HW] DMA channel
2369 smsc-ircc2.ircc_transceiver= [HW] Transceiver type: 2371 smsc-ircc2.ircc_transceiver= [HW] Transceiver type:
2370 0: Toshiba Satellite 1800 (GP data pin select) 2372 0: Toshiba Satellite 1800 (GP data pin select)
2371 1: Fast pin select (default) 2373 1: Fast pin select (default)
2372 2: ATC IRMode 2374 2: ATC IRMode
2373 2375
2374 snd-ad1816a= [HW,ALSA] 2376 snd-ad1816a= [HW,ALSA]
2375 2377
2376 snd-ad1848= [HW,ALSA] 2378 snd-ad1848= [HW,ALSA]
2377 2379
2378 snd-ali5451= [HW,ALSA] 2380 snd-ali5451= [HW,ALSA]
2379 2381
2380 snd-als100= [HW,ALSA] 2382 snd-als100= [HW,ALSA]
2381 2383
2382 snd-als4000= [HW,ALSA] 2384 snd-als4000= [HW,ALSA]
2383 2385
2384 snd-azt2320= [HW,ALSA] 2386 snd-azt2320= [HW,ALSA]
2385 2387
2386 snd-cmi8330= [HW,ALSA] 2388 snd-cmi8330= [HW,ALSA]
2387 2389
2388 snd-cmipci= [HW,ALSA] 2390 snd-cmipci= [HW,ALSA]
2389 2391
2390 snd-cs4231= [HW,ALSA] 2392 snd-cs4231= [HW,ALSA]
2391 2393
2392 snd-cs4232= [HW,ALSA] 2394 snd-cs4232= [HW,ALSA]
2393 2395
2394 snd-cs4236= [HW,ALSA] 2396 snd-cs4236= [HW,ALSA]
2395 2397
2396 snd-cs4281= [HW,ALSA] 2398 snd-cs4281= [HW,ALSA]
2397 2399
2398 snd-cs46xx= [HW,ALSA] 2400 snd-cs46xx= [HW,ALSA]
2399 2401
2400 snd-dt019x= [HW,ALSA] 2402 snd-dt019x= [HW,ALSA]
2401 2403
2402 snd-dummy= [HW,ALSA] 2404 snd-dummy= [HW,ALSA]
2403 2405
2404 snd-emu10k1= [HW,ALSA] 2406 snd-emu10k1= [HW,ALSA]
2405 2407
2406 snd-ens1370= [HW,ALSA] 2408 snd-ens1370= [HW,ALSA]
2407 2409
2408 snd-ens1371= [HW,ALSA] 2410 snd-ens1371= [HW,ALSA]
2409 2411
2410 snd-es968= [HW,ALSA] 2412 snd-es968= [HW,ALSA]
2411 2413
2412 snd-es1688= [HW,ALSA] 2414 snd-es1688= [HW,ALSA]
2413 2415
2414 snd-es18xx= [HW,ALSA] 2416 snd-es18xx= [HW,ALSA]
2415 2417
2416 snd-es1938= [HW,ALSA] 2418 snd-es1938= [HW,ALSA]
2417 2419
2418 snd-es1968= [HW,ALSA] 2420 snd-es1968= [HW,ALSA]
2419 2421
2420 snd-fm801= [HW,ALSA] 2422 snd-fm801= [HW,ALSA]
2421 2423
2422 snd-gusclassic= [HW,ALSA] 2424 snd-gusclassic= [HW,ALSA]
2423 2425
2424 snd-gusextreme= [HW,ALSA] 2426 snd-gusextreme= [HW,ALSA]
2425 2427
2426 snd-gusmax= [HW,ALSA] 2428 snd-gusmax= [HW,ALSA]
2427 2429
2428 snd-hdsp= [HW,ALSA] 2430 snd-hdsp= [HW,ALSA]
2429 2431
2430 snd-ice1712= [HW,ALSA] 2432 snd-ice1712= [HW,ALSA]
2431 2433
2432 snd-intel8x0= [HW,ALSA] 2434 snd-intel8x0= [HW,ALSA]
2433 2435
2434 snd-interwave= [HW,ALSA] 2436 snd-interwave= [HW,ALSA]
2435 2437
2436 snd-interwave-stb= 2438 snd-interwave-stb=
2437 [HW,ALSA] 2439 [HW,ALSA]
2438 2440
2439 snd-korg1212= [HW,ALSA] 2441 snd-korg1212= [HW,ALSA]
2440 2442
2441 snd-maestro3= [HW,ALSA] 2443 snd-maestro3= [HW,ALSA]
2442 2444
2443 snd-mpu401= [HW,ALSA] 2445 snd-mpu401= [HW,ALSA]
2444 2446
2445 snd-mtpav= [HW,ALSA] 2447 snd-mtpav= [HW,ALSA]
2446 2448
2447 snd-nm256= [HW,ALSA] 2449 snd-nm256= [HW,ALSA]
2448 2450
2449 snd-opl3sa2= [HW,ALSA] 2451 snd-opl3sa2= [HW,ALSA]
2450 2452
2451 snd-opti92x-ad1848= 2453 snd-opti92x-ad1848=
2452 [HW,ALSA] 2454 [HW,ALSA]
2453 2455
2454 snd-opti92x-cs4231= 2456 snd-opti92x-cs4231=
2455 [HW,ALSA] 2457 [HW,ALSA]
2456 2458
2457 snd-opti93x= [HW,ALSA] 2459 snd-opti93x= [HW,ALSA]
2458 2460
2459 snd-pmac= [HW,ALSA] 2461 snd-pmac= [HW,ALSA]
2460 2462
2461 snd-rme32= [HW,ALSA] 2463 snd-rme32= [HW,ALSA]
2462 2464
2463 snd-rme96= [HW,ALSA] 2465 snd-rme96= [HW,ALSA]
2464 2466
2465 snd-rme9652= [HW,ALSA] 2467 snd-rme9652= [HW,ALSA]
2466 2468
2467 snd-sb8= [HW,ALSA] 2469 snd-sb8= [HW,ALSA]
2468 2470
2469 snd-sb16= [HW,ALSA] 2471 snd-sb16= [HW,ALSA]
2470 2472
2471 snd-sbawe= [HW,ALSA] 2473 snd-sbawe= [HW,ALSA]
2472 2474
2473 snd-serial= [HW,ALSA] 2475 snd-serial= [HW,ALSA]
2474 2476
2475 snd-sgalaxy= [HW,ALSA] 2477 snd-sgalaxy= [HW,ALSA]
2476 2478
2477 snd-sonicvibes= [HW,ALSA] 2479 snd-sonicvibes= [HW,ALSA]
2478 2480
2479 snd-sun-amd7930= 2481 snd-sun-amd7930=
2480 [HW,ALSA] 2482 [HW,ALSA]
2481 2483
2482 snd-sun-cs4231= [HW,ALSA] 2484 snd-sun-cs4231= [HW,ALSA]
2483 2485
2484 snd-trident= [HW,ALSA] 2486 snd-trident= [HW,ALSA]
2485 2487
2486 snd-usb-audio= [HW,ALSA,USB] 2488 snd-usb-audio= [HW,ALSA,USB]
2487 2489
2488 snd-via82xx= [HW,ALSA] 2490 snd-via82xx= [HW,ALSA]
2489 2491
2490 snd-virmidi= [HW,ALSA] 2492 snd-virmidi= [HW,ALSA]
2491 2493
2492 snd-wavefront= [HW,ALSA] 2494 snd-wavefront= [HW,ALSA]
2493 2495
2494 snd-ymfpci= [HW,ALSA] 2496 snd-ymfpci= [HW,ALSA]
2495 2497
2496 softlockup_panic= 2498 softlockup_panic=
2497 [KNL] Should the soft-lockup detector generate panics. 2499 [KNL] Should the soft-lockup detector generate panics.
2498 2500
2499 sonypi.*= [HW] Sony Programmable I/O Control Device driver 2501 sonypi.*= [HW] Sony Programmable I/O Control Device driver
2500 See Documentation/sonypi.txt 2502 See Documentation/sonypi.txt
2501 2503
2502 specialix= [HW,SERIAL] Specialix multi-serial port adapter 2504 specialix= [HW,SERIAL] Specialix multi-serial port adapter
2503 See Documentation/serial/specialix.txt. 2505 See Documentation/serial/specialix.txt.
2504 2506
2505 spia_io_base= [HW,MTD] 2507 spia_io_base= [HW,MTD]
2506 spia_fio_base= 2508 spia_fio_base=
2507 spia_pedr= 2509 spia_pedr=
2508 spia_peddr= 2510 spia_peddr=
2509 2511
2510 sscape= [HW,OSS] 2512 sscape= [HW,OSS]
2511 Format: <io>,<irq>,<dma>,<mpu_io>,<mpu_irq> 2513 Format: <io>,<irq>,<dma>,<mpu_io>,<mpu_irq>
2512 2514
2513 st= [HW,SCSI] SCSI tape parameters (buffers, etc.) 2515 st= [HW,SCSI] SCSI tape parameters (buffers, etc.)
2514 See Documentation/scsi/st.txt. 2516 See Documentation/scsi/st.txt.
2515 2517
2516 stacktrace [FTRACE] 2518 stacktrace [FTRACE]
2517 Enabled the stack tracer on boot up. 2519 Enabled the stack tracer on boot up.
2518 2520
2519 sti= [PARISC,HW] 2521 sti= [PARISC,HW]
2520 Format: <num> 2522 Format: <num>
2521 Set the STI (builtin display/keyboard on the HP-PARISC 2523 Set the STI (builtin display/keyboard on the HP-PARISC
2522 machines) console (graphic card) which should be used 2524 machines) console (graphic card) which should be used
2523 as the initial boot-console. 2525 as the initial boot-console.
2524 See also comment in drivers/video/console/sticore.c. 2526 See also comment in drivers/video/console/sticore.c.
2525 2527
2526 sti_font= [HW] 2528 sti_font= [HW]
2527 See comment in drivers/video/console/sticore.c. 2529 See comment in drivers/video/console/sticore.c.
2528 2530
2529 stifb= [HW] 2531 stifb= [HW]
2530 Format: bpp:<bpp1>[:<bpp2>[:<bpp3>...]] 2532 Format: bpp:<bpp1>[:<bpp2>[:<bpp3>...]]
2531 2533
2532 sunrpc.min_resvport= 2534 sunrpc.min_resvport=
2533 sunrpc.max_resvport= 2535 sunrpc.max_resvport=
2534 [NFS,SUNRPC] 2536 [NFS,SUNRPC]
2535 SunRPC servers often require that client requests 2537 SunRPC servers often require that client requests
2536 originate from a privileged port (i.e. a port in the 2538 originate from a privileged port (i.e. a port in the
2537 range 0 < portnr < 1024). 2539 range 0 < portnr < 1024).
2538 An administrator who wishes to reserve some of these 2540 An administrator who wishes to reserve some of these
2539 ports for other uses may adjust the range that the 2541 ports for other uses may adjust the range that the
2540 kernel's sunrpc client considers to be privileged 2542 kernel's sunrpc client considers to be privileged
2541 using these two parameters to set the minimum and 2543 using these two parameters to set the minimum and
2542 maximum port values. 2544 maximum port values.
2543 2545
2544 sunrpc.pool_mode= 2546 sunrpc.pool_mode=
2545 [NFS] 2547 [NFS]
2546 Control how the NFS server code allocates CPUs to 2548 Control how the NFS server code allocates CPUs to
2547 service thread pools. Depending on how many NICs 2549 service thread pools. Depending on how many NICs
2548 you have and where their interrupts are bound, this 2550 you have and where their interrupts are bound, this
2549 option will affect which CPUs will do NFS serving. 2551 option will affect which CPUs will do NFS serving.
2550 Note: this parameter cannot be changed while the 2552 Note: this parameter cannot be changed while the
2551 NFS server is running. 2553 NFS server is running.
2552 2554
2553 auto the server chooses an appropriate mode 2555 auto the server chooses an appropriate mode
2554 automatically using heuristics 2556 automatically using heuristics
2555 global a single global pool contains all CPUs 2557 global a single global pool contains all CPUs
2556 percpu one pool for each CPU 2558 percpu one pool for each CPU
2557 pernode one pool for each NUMA node (equivalent 2559 pernode one pool for each NUMA node (equivalent
2558 to global on non-NUMA machines) 2560 to global on non-NUMA machines)
2559 2561
2560 sunrpc.tcp_slot_table_entries= 2562 sunrpc.tcp_slot_table_entries=
2561 sunrpc.udp_slot_table_entries= 2563 sunrpc.udp_slot_table_entries=
2562 [NFS,SUNRPC] 2564 [NFS,SUNRPC]
2563 Sets the upper limit on the number of simultaneous 2565 Sets the upper limit on the number of simultaneous
2564 RPC calls that can be sent from the client to a 2566 RPC calls that can be sent from the client to a
2565 server. Increasing these values may allow you to 2567 server. Increasing these values may allow you to
2566 improve throughput, but will also increase the 2568 improve throughput, but will also increase the
2567 amount of memory reserved for use by the client. 2569 amount of memory reserved for use by the client.
2568 2570
2569 swiotlb= [IA-64] Number of I/O TLB slabs 2571 swiotlb= [IA-64] Number of I/O TLB slabs
2570 2572
2571 switches= [HW,M68k] 2573 switches= [HW,M68k]
2572 2574
2573 sym53c416= [HW,SCSI] 2575 sym53c416= [HW,SCSI]
2574 See header of drivers/scsi/sym53c416.c. 2576 See header of drivers/scsi/sym53c416.c.
2575 2577
2576 sysrq_always_enabled 2578 sysrq_always_enabled
2577 [KNL] 2579 [KNL]
2578 Ignore sysrq setting - this boot parameter will 2580 Ignore sysrq setting - this boot parameter will
2579 neutralize any effect of /proc/sys/kernel/sysrq. 2581 neutralize any effect of /proc/sys/kernel/sysrq.
2580 Useful for debugging. 2582 Useful for debugging.
2581 2583
2582 t128= [HW,SCSI] 2584 t128= [HW,SCSI]
2583 See header of drivers/scsi/t128.c. 2585 See header of drivers/scsi/t128.c.
2584 2586
2585 tdfx= [HW,DRM] 2587 tdfx= [HW,DRM]
2586 2588
2587 test_suspend= [SUSPEND] 2589 test_suspend= [SUSPEND]
2588 Specify "mem" (for Suspend-to-RAM) or "standby" (for 2590 Specify "mem" (for Suspend-to-RAM) or "standby" (for
2589 standby suspend) as the system sleep state to briefly 2591 standby suspend) as the system sleep state to briefly
2590 enter during system startup. The system is woken from 2592 enter during system startup. The system is woken from
2591 this state using a wakeup-capable RTC alarm. 2593 this state using a wakeup-capable RTC alarm.
2592 2594
2593 thash_entries= [KNL,NET] 2595 thash_entries= [KNL,NET]
2594 Set number of hash buckets for TCP connection 2596 Set number of hash buckets for TCP connection
2595 2597
2596 thermal.act= [HW,ACPI] 2598 thermal.act= [HW,ACPI]
2597 -1: disable all active trip points in all thermal zones 2599 -1: disable all active trip points in all thermal zones
2598 <degrees C>: override all lowest active trip points 2600 <degrees C>: override all lowest active trip points
2599 2601
2600 thermal.crt= [HW,ACPI] 2602 thermal.crt= [HW,ACPI]
2601 -1: disable all critical trip points in all thermal zones 2603 -1: disable all critical trip points in all thermal zones
2602 <degrees C>: override all critical trip points 2604 <degrees C>: override all critical trip points
2603 2605
2604 thermal.nocrt= [HW,ACPI] 2606 thermal.nocrt= [HW,ACPI]
2605 Set to disable actions on ACPI thermal zone 2607 Set to disable actions on ACPI thermal zone
2606 critical and hot trip points. 2608 critical and hot trip points.
2607 2609
2608 thermal.off= [HW,ACPI] 2610 thermal.off= [HW,ACPI]
2609 1: disable ACPI thermal control 2611 1: disable ACPI thermal control
2610 2612
2611 thermal.psv= [HW,ACPI] 2613 thermal.psv= [HW,ACPI]
2612 -1: disable all passive trip points 2614 -1: disable all passive trip points
2613 <degrees C>: override all passive trip points to this 2615 <degrees C>: override all passive trip points to this
2614 value 2616 value
2615 2617
2616 thermal.tzp= [HW,ACPI] 2618 thermal.tzp= [HW,ACPI]
2617 Specify global default ACPI thermal zone polling rate 2619 Specify global default ACPI thermal zone polling rate
2618 <deci-seconds>: poll all this frequency 2620 <deci-seconds>: poll all this frequency
2619 0: no polling (default) 2621 0: no polling (default)
2620 2622
2621 tmscsim= [HW,SCSI] 2623 tmscsim= [HW,SCSI]
2622 See comment before function dc390_setup() in 2624 See comment before function dc390_setup() in
2623 drivers/scsi/tmscsim.c. 2625 drivers/scsi/tmscsim.c.
2624 2626
2625 topology= [S390] 2627 topology= [S390]
2626 Format: {off | on} 2628 Format: {off | on}
2627 Specify if the kernel should make use of the cpu 2629 Specify if the kernel should make use of the cpu
2628 topology informations if the hardware supports these. 2630 topology informations if the hardware supports these.
2629 The scheduler will make use of these informations and 2631 The scheduler will make use of these informations and
2630 e.g. base its process migration decisions on it. 2632 e.g. base its process migration decisions on it.
2631 Default is off. 2633 Default is off.
2632 2634
2633 tp720= [HW,PS2] 2635 tp720= [HW,PS2]
2634 2636
2635 tpm_suspend_pcr=[HW,TPM] 2637 tpm_suspend_pcr=[HW,TPM]
2636 Format: integer pcr id 2638 Format: integer pcr id
2637 Specify that at suspend time, the tpm driver 2639 Specify that at suspend time, the tpm driver
2638 should extend the specified pcr with zeros, 2640 should extend the specified pcr with zeros,
2639 as a workaround for some chips which fail to 2641 as a workaround for some chips which fail to
2640 flush the last written pcr on TPM_SaveState. 2642 flush the last written pcr on TPM_SaveState.
2641 This will guarantee that all the other pcrs 2643 This will guarantee that all the other pcrs
2642 are saved. 2644 are saved.
2643 2645
2644 trace_buf_size=nn[KMG] 2646 trace_buf_size=nn[KMG]
2645 [FTRACE] will set tracing buffer size. 2647 [FTRACE] will set tracing buffer size.
2646 2648
2647 trace_event=[event-list] 2649 trace_event=[event-list]
2648 [FTRACE] Set and start specified trace events in order 2650 [FTRACE] Set and start specified trace events in order
2649 to facilitate early boot debugging. 2651 to facilitate early boot debugging.
2650 See also Documentation/trace/events.txt 2652 See also Documentation/trace/events.txt
2651 2653
2652 trix= [HW,OSS] MediaTrix AudioTrix Pro 2654 trix= [HW,OSS] MediaTrix AudioTrix Pro
2653 Format: 2655 Format:
2654 <io>,<irq>,<dma>,<dma2>,<sb_io>,<sb_irq>,<sb_dma>,<mpu_io>,<mpu_irq> 2656 <io>,<irq>,<dma>,<dma2>,<sb_io>,<sb_irq>,<sb_dma>,<mpu_io>,<mpu_irq>
2655 2657
2656 tsc= Disable clocksource-must-verify flag for TSC. 2658 tsc= Disable clocksource-must-verify flag for TSC.
2657 Format: <string> 2659 Format: <string>
2658 [x86] reliable: mark tsc clocksource as reliable, this 2660 [x86] reliable: mark tsc clocksource as reliable, this
2659 disables clocksource verification at runtime. 2661 disables clocksource verification at runtime.
2660 Used to enable high-resolution timer mode on older 2662 Used to enable high-resolution timer mode on older
2661 hardware, and in virtualized environment. 2663 hardware, and in virtualized environment.
2662 2664
2663 turbografx.map[2|3]= [HW,JOY] 2665 turbografx.map[2|3]= [HW,JOY]
2664 TurboGraFX parallel port interface 2666 TurboGraFX parallel port interface
2665 Format: 2667 Format:
2666 <port#>,<js1>,<js2>,<js3>,<js4>,<js5>,<js6>,<js7> 2668 <port#>,<js1>,<js2>,<js3>,<js4>,<js5>,<js6>,<js7>
2667 See also Documentation/input/joystick-parport.txt 2669 See also Documentation/input/joystick-parport.txt
2668 2670
2669 u14-34f= [HW,SCSI] UltraStor 14F/34F SCSI host adapter 2671 u14-34f= [HW,SCSI] UltraStor 14F/34F SCSI host adapter
2670 See header of drivers/scsi/u14-34f.c. 2672 See header of drivers/scsi/u14-34f.c.
2671 2673
2672 uart401= [HW,OSS] 2674 uart401= [HW,OSS]
2673 Format: <io>,<irq> 2675 Format: <io>,<irq>
2674 2676
2675 uart6850= [HW,OSS] 2677 uart6850= [HW,OSS]
2676 Format: <io>,<irq> 2678 Format: <io>,<irq>
2677 2679
2678 uhash_entries= [KNL,NET] 2680 uhash_entries= [KNL,NET]
2679 Set number of hash buckets for UDP/UDP-Lite connections 2681 Set number of hash buckets for UDP/UDP-Lite connections
2680 2682
2681 uhci-hcd.ignore_oc= 2683 uhci-hcd.ignore_oc=
2682 [USB] Ignore overcurrent events (default N). 2684 [USB] Ignore overcurrent events (default N).
2683 Some badly-designed motherboards generate lots of 2685 Some badly-designed motherboards generate lots of
2684 bogus events, for ports that aren't wired to 2686 bogus events, for ports that aren't wired to
2685 anything. Set this parameter to avoid log spamming. 2687 anything. Set this parameter to avoid log spamming.
2686 Note that genuine overcurrent events won't be 2688 Note that genuine overcurrent events won't be
2687 reported either. 2689 reported either.
2688 2690
2689 unknown_nmi_panic 2691 unknown_nmi_panic
2690 [X86] 2692 [X86]
2691 Set unknown_nmi_panic=1 early on boot. 2693 Set unknown_nmi_panic=1 early on boot.
2692 2694
2693 usbcore.autosuspend= 2695 usbcore.autosuspend=
2694 [USB] The autosuspend time delay (in seconds) used 2696 [USB] The autosuspend time delay (in seconds) used
2695 for newly-detected USB devices (default 2). This 2697 for newly-detected USB devices (default 2). This
2696 is the time required before an idle device will be 2698 is the time required before an idle device will be
2697 autosuspended. Devices for which the delay is set 2699 autosuspended. Devices for which the delay is set
2698 to a negative value won't be autosuspended at all. 2700 to a negative value won't be autosuspended at all.
2699 2701
2700 usbcore.usbfs_snoop= 2702 usbcore.usbfs_snoop=
2701 [USB] Set to log all usbfs traffic (default 0 = off). 2703 [USB] Set to log all usbfs traffic (default 0 = off).
2702 2704
2703 usbcore.blinkenlights= 2705 usbcore.blinkenlights=
2704 [USB] Set to cycle leds on hubs (default 0 = off). 2706 [USB] Set to cycle leds on hubs (default 0 = off).
2705 2707
2706 usbcore.old_scheme_first= 2708 usbcore.old_scheme_first=
2707 [USB] Start with the old device initialization 2709 [USB] Start with the old device initialization
2708 scheme (default 0 = off). 2710 scheme (default 0 = off).
2709 2711
2710 usbcore.use_both_schemes= 2712 usbcore.use_both_schemes=
2711 [USB] Try the other device initialization scheme 2713 [USB] Try the other device initialization scheme
2712 if the first one fails (default 1 = enabled). 2714 if the first one fails (default 1 = enabled).
2713 2715
2714 usbcore.initial_descriptor_timeout= 2716 usbcore.initial_descriptor_timeout=
2715 [USB] Specifies timeout for the initial 64-byte 2717 [USB] Specifies timeout for the initial 64-byte
2716 USB_REQ_GET_DESCRIPTOR request in milliseconds 2718 USB_REQ_GET_DESCRIPTOR request in milliseconds
2717 (default 5000 = 5.0 seconds). 2719 (default 5000 = 5.0 seconds).
2718 2720
2719 usbhid.mousepoll= 2721 usbhid.mousepoll=
2720 [USBHID] The interval which mice are to be polled at. 2722 [USBHID] The interval which mice are to be polled at.
2721 2723
2722 usb-storage.delay_use= 2724 usb-storage.delay_use=
2723 [UMS] The delay in seconds before a new device is 2725 [UMS] The delay in seconds before a new device is
2724 scanned for Logical Units (default 5). 2726 scanned for Logical Units (default 5).
2725 2727
2726 usb-storage.quirks= 2728 usb-storage.quirks=
2727 [UMS] A list of quirks entries to supplement or 2729 [UMS] A list of quirks entries to supplement or
2728 override the built-in unusual_devs list. List 2730 override the built-in unusual_devs list. List
2729 entries are separated by commas. Each entry has 2731 entries are separated by commas. Each entry has
2730 the form VID:PID:Flags where VID and PID are Vendor 2732 the form VID:PID:Flags where VID and PID are Vendor
2731 and Product ID values (4-digit hex numbers) and 2733 and Product ID values (4-digit hex numbers) and
2732 Flags is a set of characters, each corresponding 2734 Flags is a set of characters, each corresponding
2733 to a common usb-storage quirk flag as follows: 2735 to a common usb-storage quirk flag as follows:
2734 a = SANE_SENSE (collect more than 18 bytes 2736 a = SANE_SENSE (collect more than 18 bytes
2735 of sense data); 2737 of sense data);
2736 b = BAD_SENSE (don't collect more than 18 2738 b = BAD_SENSE (don't collect more than 18
2737 bytes of sense data); 2739 bytes of sense data);
2738 c = FIX_CAPACITY (decrease the reported 2740 c = FIX_CAPACITY (decrease the reported
2739 device capacity by one sector); 2741 device capacity by one sector);
2740 h = CAPACITY_HEURISTICS (decrease the 2742 h = CAPACITY_HEURISTICS (decrease the
2741 reported device capacity by one 2743 reported device capacity by one
2742 sector if the number is odd); 2744 sector if the number is odd);
2743 i = IGNORE_DEVICE (don't bind to this 2745 i = IGNORE_DEVICE (don't bind to this
2744 device); 2746 device);
2745 l = NOT_LOCKABLE (don't try to lock and 2747 l = NOT_LOCKABLE (don't try to lock and
2746 unlock ejectable media); 2748 unlock ejectable media);
2747 m = MAX_SECTORS_64 (don't transfer more 2749 m = MAX_SECTORS_64 (don't transfer more
2748 than 64 sectors = 32 KB at a time); 2750 than 64 sectors = 32 KB at a time);
2749 o = CAPACITY_OK (accept the capacity 2751 o = CAPACITY_OK (accept the capacity
2750 reported by the device); 2752 reported by the device);
2751 r = IGNORE_RESIDUE (the device reports 2753 r = IGNORE_RESIDUE (the device reports
2752 bogus residue values); 2754 bogus residue values);
2753 s = SINGLE_LUN (the device has only one 2755 s = SINGLE_LUN (the device has only one
2754 Logical Unit); 2756 Logical Unit);
2755 w = NO_WP_DETECT (don't test whether the 2757 w = NO_WP_DETECT (don't test whether the
2756 medium is write-protected). 2758 medium is write-protected).
2757 Example: quirks=0419:aaf5:rl,0421:0433:rc 2759 Example: quirks=0419:aaf5:rl,0421:0433:rc
2758 2760
2759 userpte= 2761 userpte=
2760 [X86] Flags controlling user PTE allocations. 2762 [X86] Flags controlling user PTE allocations.
2761 2763
2762 nohigh = do not allocate PTE pages in 2764 nohigh = do not allocate PTE pages in
2763 HIGHMEM regardless of setting 2765 HIGHMEM regardless of setting
2764 of CONFIG_HIGHPTE. 2766 of CONFIG_HIGHPTE.
2765 2767
2766 vdso= [X86,SH] 2768 vdso= [X86,SH]
2767 vdso=2: enable compat VDSO (default with COMPAT_VDSO) 2769 vdso=2: enable compat VDSO (default with COMPAT_VDSO)
2768 vdso=1: enable VDSO (default) 2770 vdso=1: enable VDSO (default)
2769 vdso=0: disable VDSO mapping 2771 vdso=0: disable VDSO mapping
2770 2772
2771 vdso32= [X86] 2773 vdso32= [X86]
2772 vdso32=2: enable compat VDSO (default with COMPAT_VDSO) 2774 vdso32=2: enable compat VDSO (default with COMPAT_VDSO)
2773 vdso32=1: enable 32-bit VDSO (default) 2775 vdso32=1: enable 32-bit VDSO (default)
2774 vdso32=0: disable 32-bit VDSO mapping 2776 vdso32=0: disable 32-bit VDSO mapping
2775 2777
2776 vector= [IA-64,SMP] 2778 vector= [IA-64,SMP]
2777 vector=percpu: enable percpu vector domain 2779 vector=percpu: enable percpu vector domain
2778 2780
2779 video= [FB] Frame buffer configuration 2781 video= [FB] Frame buffer configuration
2780 See Documentation/fb/modedb.txt. 2782 See Documentation/fb/modedb.txt.
2781 2783
2782 vga= [BOOT,X86-32] Select a particular video mode 2784 vga= [BOOT,X86-32] Select a particular video mode
2783 See Documentation/x86/boot.txt and 2785 See Documentation/x86/boot.txt and
2784 Documentation/svga.txt. 2786 Documentation/svga.txt.
2785 Use vga=ask for menu. 2787 Use vga=ask for menu.
2786 This is actually a boot loader parameter; the value is 2788 This is actually a boot loader parameter; the value is
2787 passed to the kernel using a special protocol. 2789 passed to the kernel using a special protocol.
2788 2790
2789 vmalloc=nn[KMG] [KNL,BOOT] Forces the vmalloc area to have an exact 2791 vmalloc=nn[KMG] [KNL,BOOT] Forces the vmalloc area to have an exact
2790 size of <nn>. This can be used to increase the 2792 size of <nn>. This can be used to increase the
2791 minimum size (128MB on x86). It can also be used to 2793 minimum size (128MB on x86). It can also be used to
2792 decrease the size and leave more room for directly 2794 decrease the size and leave more room for directly
2793 mapped kernel RAM. 2795 mapped kernel RAM.
2794 2796
2795 vmhalt= [KNL,S390] Perform z/VM CP command after system halt. 2797 vmhalt= [KNL,S390] Perform z/VM CP command after system halt.
2796 Format: <command> 2798 Format: <command>
2797 2799
2798 vmpanic= [KNL,S390] Perform z/VM CP command after kernel panic. 2800 vmpanic= [KNL,S390] Perform z/VM CP command after kernel panic.
2799 Format: <command> 2801 Format: <command>
2800 2802
2801 vmpoff= [KNL,S390] Perform z/VM CP command after power off. 2803 vmpoff= [KNL,S390] Perform z/VM CP command after power off.
2802 Format: <command> 2804 Format: <command>
2803 2805
2804 vt.cur_default= [VT] Default cursor shape. 2806 vt.cur_default= [VT] Default cursor shape.
2805 Format: 0xCCBBAA, where AA, BB, and CC are the same as 2807 Format: 0xCCBBAA, where AA, BB, and CC are the same as
2806 the parameters of the <Esc>[?A;B;Cc escape sequence; 2808 the parameters of the <Esc>[?A;B;Cc escape sequence;
2807 see VGA-softcursor.txt. Default: 2 = underline. 2809 see VGA-softcursor.txt. Default: 2 = underline.
2808 2810
2809 vt.default_blu= [VT] 2811 vt.default_blu= [VT]
2810 Format: <blue0>,<blue1>,<blue2>,...,<blue15> 2812 Format: <blue0>,<blue1>,<blue2>,...,<blue15>
2811 Change the default blue palette of the console. 2813 Change the default blue palette of the console.
2812 This is a 16-member array composed of values 2814 This is a 16-member array composed of values
2813 ranging from 0-255. 2815 ranging from 0-255.
2814 2816
2815 vt.default_grn= [VT] 2817 vt.default_grn= [VT]
2816 Format: <green0>,<green1>,<green2>,...,<green15> 2818 Format: <green0>,<green1>,<green2>,...,<green15>
2817 Change the default green palette of the console. 2819 Change the default green palette of the console.
2818 This is a 16-member array composed of values 2820 This is a 16-member array composed of values
2819 ranging from 0-255. 2821 ranging from 0-255.
2820 2822
2821 vt.default_red= [VT] 2823 vt.default_red= [VT]
2822 Format: <red0>,<red1>,<red2>,...,<red15> 2824 Format: <red0>,<red1>,<red2>,...,<red15>
2823 Change the default red palette of the console. 2825 Change the default red palette of the console.
2824 This is a 16-member array composed of values 2826 This is a 16-member array composed of values
2825 ranging from 0-255. 2827 ranging from 0-255.
2826 2828
2827 vt.default_utf8= 2829 vt.default_utf8=
2828 [VT] 2830 [VT]
2829 Format=<0|1> 2831 Format=<0|1>
2830 Set system-wide default UTF-8 mode for all tty's. 2832 Set system-wide default UTF-8 mode for all tty's.
2831 Default is 1, i.e. UTF-8 mode is enabled for all 2833 Default is 1, i.e. UTF-8 mode is enabled for all
2832 newly opened terminals. 2834 newly opened terminals.
2833 2835
2834 vt.global_cursor_default= 2836 vt.global_cursor_default=
2835 [VT] 2837 [VT]
2836 Format=<-1|0|1> 2838 Format=<-1|0|1>
2837 Set system-wide default for whether a cursor 2839 Set system-wide default for whether a cursor
2838 is shown on new VTs. Default is -1, 2840 is shown on new VTs. Default is -1,
2839 i.e. cursors will be created by default unless 2841 i.e. cursors will be created by default unless
2840 overridden by individual drivers. 0 will hide 2842 overridden by individual drivers. 0 will hide
2841 cursors, 1 will display them. 2843 cursors, 1 will display them.
2842 2844
2843 waveartist= [HW,OSS] 2845 waveartist= [HW,OSS]
2844 Format: <io>,<irq>,<dma>,<dma2> 2846 Format: <io>,<irq>,<dma>,<dma2>
2845 2847
2846 wd33c93= [HW,SCSI] 2848 wd33c93= [HW,SCSI]
2847 See header of drivers/scsi/wd33c93.c. 2849 See header of drivers/scsi/wd33c93.c.
2848 2850
2849 wd7000= [HW,SCSI] 2851 wd7000= [HW,SCSI]
2850 See header of drivers/scsi/wd7000.c. 2852 See header of drivers/scsi/wd7000.c.
2851 2853
2852 watchdog timers [HW,WDT] For information on watchdog timers, 2854 watchdog timers [HW,WDT] For information on watchdog timers,
2853 see Documentation/watchdog/watchdog-parameters.txt 2855 see Documentation/watchdog/watchdog-parameters.txt
2854 or other driver-specific files in the 2856 or other driver-specific files in the
2855 Documentation/watchdog/ directory. 2857 Documentation/watchdog/ directory.
2856 2858
2857 x2apic_phys [X86-64,APIC] Use x2apic physical mode instead of 2859 x2apic_phys [X86-64,APIC] Use x2apic physical mode instead of
2858 default x2apic cluster mode on platforms 2860 default x2apic cluster mode on platforms
2859 supporting x2apic. 2861 supporting x2apic.
2860 2862
2861 x86_mrst_timer= [X86-32,APBT] 2863 x86_mrst_timer= [X86-32,APBT]
2862 Choose timer option for x86 Moorestown MID platform. 2864 Choose timer option for x86 Moorestown MID platform.
2863 Two valid options are apbt timer only and lapic timer 2865 Two valid options are apbt timer only and lapic timer
2864 plus one apbt timer for broadcast timer. 2866 plus one apbt timer for broadcast timer.
2865 x86_mrst_timer=apbt_only | lapic_and_apbt 2867 x86_mrst_timer=apbt_only | lapic_and_apbt
2866 2868
2867 xd= [HW,XT] Original XT pre-IDE (RLL encoded) disks. 2869 xd= [HW,XT] Original XT pre-IDE (RLL encoded) disks.
2868 xd_geo= See header of drivers/block/xd.c. 2870 xd_geo= See header of drivers/block/xd.c.
2869 2871
2870 xirc2ps_cs= [NET,PCMCIA] 2872 xirc2ps_cs= [NET,PCMCIA]
2871 Format: 2873 Format:
2872 <irq>,<irq_mask>,<io>,<full_duplex>,<do_sound>,<lockup_hack>[,<irq2>[,<irq3>[,<irq4>]]] 2874 <irq>,<irq_mask>,<io>,<full_duplex>,<do_sound>,<lockup_hack>[,<irq2>[,<irq3>[,<irq4>]]]
2873 2875
2874 ______________________________________________________________________ 2876 ______________________________________________________________________
2875 2877
2876 TODO: 2878 TODO:
2877 2879
2878 Add documentation for ALSA options. 2880 Add documentation for ALSA options.
2879 Add more DRM drivers. 2881 Add more DRM drivers.
2880 2882
drivers/ata/libata-core.c
1 /* 1 /*
2 * libata-core.c - helper library for ATA 2 * libata-core.c - helper library for ATA
3 * 3 *
4 * Maintained by: Jeff Garzik <jgarzik@pobox.com> 4 * Maintained by: Jeff Garzik <jgarzik@pobox.com>
5 * Please ALWAYS copy linux-ide@vger.kernel.org 5 * Please ALWAYS copy linux-ide@vger.kernel.org
6 * on emails. 6 * on emails.
7 * 7 *
8 * Copyright 2003-2004 Red Hat, Inc. All rights reserved. 8 * Copyright 2003-2004 Red Hat, Inc. All rights reserved.
9 * Copyright 2003-2004 Jeff Garzik 9 * Copyright 2003-2004 Jeff Garzik
10 * 10 *
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by 13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2, or (at your option) 14 * the Free Software Foundation; either version 2, or (at your option)
15 * any later version. 15 * any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU General Public License 22 * You should have received a copy of the GNU General Public License
23 * along with this program; see the file COPYING. If not, write to 23 * along with this program; see the file COPYING. If not, write to
24 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 24 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25 * 25 *
26 * 26 *
27 * libata documentation is available via 'make {ps|pdf}docs', 27 * libata documentation is available via 'make {ps|pdf}docs',
28 * as Documentation/DocBook/libata.* 28 * as Documentation/DocBook/libata.*
29 * 29 *
30 * Hardware documentation available from http://www.t13.org/ and 30 * Hardware documentation available from http://www.t13.org/ and
31 * http://www.sata-io.org/ 31 * http://www.sata-io.org/
32 * 32 *
33 * Standards documents from: 33 * Standards documents from:
34 * http://www.t13.org (ATA standards, PCI DMA IDE spec) 34 * http://www.t13.org (ATA standards, PCI DMA IDE spec)
35 * http://www.t10.org (SCSI MMC - for ATAPI MMC) 35 * http://www.t10.org (SCSI MMC - for ATAPI MMC)
36 * http://www.sata-io.org (SATA) 36 * http://www.sata-io.org (SATA)
37 * http://www.compactflash.org (CF) 37 * http://www.compactflash.org (CF)
38 * http://www.qic.org (QIC157 - Tape and DSC) 38 * http://www.qic.org (QIC157 - Tape and DSC)
39 * http://www.ce-ata.org (CE-ATA: not supported) 39 * http://www.ce-ata.org (CE-ATA: not supported)
40 * 40 *
41 */ 41 */
42 42
43 #include <linux/kernel.h> 43 #include <linux/kernel.h>
44 #include <linux/module.h> 44 #include <linux/module.h>
45 #include <linux/pci.h> 45 #include <linux/pci.h>
46 #include <linux/init.h> 46 #include <linux/init.h>
47 #include <linux/list.h> 47 #include <linux/list.h>
48 #include <linux/mm.h> 48 #include <linux/mm.h>
49 #include <linux/spinlock.h> 49 #include <linux/spinlock.h>
50 #include <linux/blkdev.h> 50 #include <linux/blkdev.h>
51 #include <linux/delay.h> 51 #include <linux/delay.h>
52 #include <linux/timer.h> 52 #include <linux/timer.h>
53 #include <linux/interrupt.h> 53 #include <linux/interrupt.h>
54 #include <linux/completion.h> 54 #include <linux/completion.h>
55 #include <linux/suspend.h> 55 #include <linux/suspend.h>
56 #include <linux/workqueue.h> 56 #include <linux/workqueue.h>
57 #include <linux/scatterlist.h> 57 #include <linux/scatterlist.h>
58 #include <linux/io.h> 58 #include <linux/io.h>
59 #include <linux/async.h> 59 #include <linux/async.h>
60 #include <linux/log2.h> 60 #include <linux/log2.h>
61 #include <linux/slab.h> 61 #include <linux/slab.h>
62 #include <scsi/scsi.h> 62 #include <scsi/scsi.h>
63 #include <scsi/scsi_cmnd.h> 63 #include <scsi/scsi_cmnd.h>
64 #include <scsi/scsi_host.h> 64 #include <scsi/scsi_host.h>
65 #include <linux/libata.h> 65 #include <linux/libata.h>
66 #include <asm/byteorder.h> 66 #include <asm/byteorder.h>
67 #include <linux/cdrom.h> 67 #include <linux/cdrom.h>
68 #include <linux/ratelimit.h> 68 #include <linux/ratelimit.h>
69 69
70 #include "libata.h" 70 #include "libata.h"
71 71
72 72
73 /* debounce timing parameters in msecs { interval, duration, timeout } */ 73 /* debounce timing parameters in msecs { interval, duration, timeout } */
74 const unsigned long sata_deb_timing_normal[] = { 5, 100, 2000 }; 74 const unsigned long sata_deb_timing_normal[] = { 5, 100, 2000 };
75 const unsigned long sata_deb_timing_hotplug[] = { 25, 500, 2000 }; 75 const unsigned long sata_deb_timing_hotplug[] = { 25, 500, 2000 };
76 const unsigned long sata_deb_timing_long[] = { 100, 2000, 5000 }; 76 const unsigned long sata_deb_timing_long[] = { 100, 2000, 5000 };
77 77
78 const struct ata_port_operations ata_base_port_ops = { 78 const struct ata_port_operations ata_base_port_ops = {
79 .prereset = ata_std_prereset, 79 .prereset = ata_std_prereset,
80 .postreset = ata_std_postreset, 80 .postreset = ata_std_postreset,
81 .error_handler = ata_std_error_handler, 81 .error_handler = ata_std_error_handler,
82 }; 82 };
83 83
84 const struct ata_port_operations sata_port_ops = { 84 const struct ata_port_operations sata_port_ops = {
85 .inherits = &ata_base_port_ops, 85 .inherits = &ata_base_port_ops,
86 86
87 .qc_defer = ata_std_qc_defer, 87 .qc_defer = ata_std_qc_defer,
88 .hardreset = sata_std_hardreset, 88 .hardreset = sata_std_hardreset,
89 }; 89 };
90 90
91 static unsigned int ata_dev_init_params(struct ata_device *dev, 91 static unsigned int ata_dev_init_params(struct ata_device *dev,
92 u16 heads, u16 sectors); 92 u16 heads, u16 sectors);
93 static unsigned int ata_dev_set_xfermode(struct ata_device *dev); 93 static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
94 static unsigned int ata_dev_set_feature(struct ata_device *dev, 94 static unsigned int ata_dev_set_feature(struct ata_device *dev,
95 u8 enable, u8 feature); 95 u8 enable, u8 feature);
96 static void ata_dev_xfermask(struct ata_device *dev); 96 static void ata_dev_xfermask(struct ata_device *dev);
97 static unsigned long ata_dev_blacklisted(const struct ata_device *dev); 97 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
98 98
99 unsigned int ata_print_id = 1; 99 unsigned int ata_print_id = 1;
100 100
101 struct workqueue_struct *ata_aux_wq; 101 struct workqueue_struct *ata_aux_wq;
102 102
103 struct ata_force_param { 103 struct ata_force_param {
104 const char *name; 104 const char *name;
105 unsigned int cbl; 105 unsigned int cbl;
106 int spd_limit; 106 int spd_limit;
107 unsigned long xfer_mask; 107 unsigned long xfer_mask;
108 unsigned int horkage_on; 108 unsigned int horkage_on;
109 unsigned int horkage_off; 109 unsigned int horkage_off;
110 unsigned int lflags; 110 unsigned int lflags;
111 }; 111 };
112 112
113 struct ata_force_ent { 113 struct ata_force_ent {
114 int port; 114 int port;
115 int device; 115 int device;
116 struct ata_force_param param; 116 struct ata_force_param param;
117 }; 117 };
118 118
119 static struct ata_force_ent *ata_force_tbl; 119 static struct ata_force_ent *ata_force_tbl;
120 static int ata_force_tbl_size; 120 static int ata_force_tbl_size;
121 121
122 static char ata_force_param_buf[PAGE_SIZE] __initdata; 122 static char ata_force_param_buf[PAGE_SIZE] __initdata;
123 /* param_buf is thrown away after initialization, disallow read */ 123 /* param_buf is thrown away after initialization, disallow read */
124 module_param_string(force, ata_force_param_buf, sizeof(ata_force_param_buf), 0); 124 module_param_string(force, ata_force_param_buf, sizeof(ata_force_param_buf), 0);
125 MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link speed and transfer mode (see Documentation/kernel-parameters.txt for details)"); 125 MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link speed and transfer mode (see Documentation/kernel-parameters.txt for details)");
126 126
127 static int atapi_enabled = 1; 127 static int atapi_enabled = 1;
128 module_param(atapi_enabled, int, 0444); 128 module_param(atapi_enabled, int, 0444);
129 MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on [default])"); 129 MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on [default])");
130 130
131 static int atapi_dmadir = 0; 131 static int atapi_dmadir = 0;
132 module_param(atapi_dmadir, int, 0444); 132 module_param(atapi_dmadir, int, 0444);
133 MODULE_PARM_DESC(atapi_dmadir, "Enable ATAPI DMADIR bridge support (0=off [default], 1=on)"); 133 MODULE_PARM_DESC(atapi_dmadir, "Enable ATAPI DMADIR bridge support (0=off [default], 1=on)");
134 134
135 int atapi_passthru16 = 1; 135 int atapi_passthru16 = 1;
136 module_param(atapi_passthru16, int, 0444); 136 module_param(atapi_passthru16, int, 0444);
137 MODULE_PARM_DESC(atapi_passthru16, "Enable ATA_16 passthru for ATAPI devices (0=off, 1=on [default])"); 137 MODULE_PARM_DESC(atapi_passthru16, "Enable ATA_16 passthru for ATAPI devices (0=off, 1=on [default])");
138 138
139 int libata_fua = 0; 139 int libata_fua = 0;
140 module_param_named(fua, libata_fua, int, 0444); 140 module_param_named(fua, libata_fua, int, 0444);
141 MODULE_PARM_DESC(fua, "FUA support (0=off [default], 1=on)"); 141 MODULE_PARM_DESC(fua, "FUA support (0=off [default], 1=on)");
142 142
143 static int ata_ignore_hpa; 143 static int ata_ignore_hpa;
144 module_param_named(ignore_hpa, ata_ignore_hpa, int, 0644); 144 module_param_named(ignore_hpa, ata_ignore_hpa, int, 0644);
145 MODULE_PARM_DESC(ignore_hpa, "Ignore HPA limit (0=keep BIOS limits, 1=ignore limits, using full disk)"); 145 MODULE_PARM_DESC(ignore_hpa, "Ignore HPA limit (0=keep BIOS limits, 1=ignore limits, using full disk)");
146 146
147 static int libata_dma_mask = ATA_DMA_MASK_ATA|ATA_DMA_MASK_ATAPI|ATA_DMA_MASK_CFA; 147 static int libata_dma_mask = ATA_DMA_MASK_ATA|ATA_DMA_MASK_ATAPI|ATA_DMA_MASK_CFA;
148 module_param_named(dma, libata_dma_mask, int, 0444); 148 module_param_named(dma, libata_dma_mask, int, 0444);
149 MODULE_PARM_DESC(dma, "DMA enable/disable (0x1==ATA, 0x2==ATAPI, 0x4==CF)"); 149 MODULE_PARM_DESC(dma, "DMA enable/disable (0x1==ATA, 0x2==ATAPI, 0x4==CF)");
150 150
151 static int ata_probe_timeout; 151 static int ata_probe_timeout;
152 module_param(ata_probe_timeout, int, 0444); 152 module_param(ata_probe_timeout, int, 0444);
153 MODULE_PARM_DESC(ata_probe_timeout, "Set ATA probing timeout (seconds)"); 153 MODULE_PARM_DESC(ata_probe_timeout, "Set ATA probing timeout (seconds)");
154 154
155 int libata_noacpi = 0; 155 int libata_noacpi = 0;
156 module_param_named(noacpi, libata_noacpi, int, 0444); 156 module_param_named(noacpi, libata_noacpi, int, 0444);
157 MODULE_PARM_DESC(noacpi, "Disable the use of ACPI in probe/suspend/resume (0=off [default], 1=on)"); 157 MODULE_PARM_DESC(noacpi, "Disable the use of ACPI in probe/suspend/resume (0=off [default], 1=on)");
158 158
159 int libata_allow_tpm = 0; 159 int libata_allow_tpm = 0;
160 module_param_named(allow_tpm, libata_allow_tpm, int, 0444); 160 module_param_named(allow_tpm, libata_allow_tpm, int, 0444);
161 MODULE_PARM_DESC(allow_tpm, "Permit the use of TPM commands (0=off [default], 1=on)"); 161 MODULE_PARM_DESC(allow_tpm, "Permit the use of TPM commands (0=off [default], 1=on)");
162 162
163 static int atapi_an; 163 static int atapi_an;
164 module_param(atapi_an, int, 0444); 164 module_param(atapi_an, int, 0444);
165 MODULE_PARM_DESC(atapi_an, "Enable ATAPI AN media presence notification (0=0ff [default], 1=on)"); 165 MODULE_PARM_DESC(atapi_an, "Enable ATAPI AN media presence notification (0=0ff [default], 1=on)");
166 166
167 MODULE_AUTHOR("Jeff Garzik"); 167 MODULE_AUTHOR("Jeff Garzik");
168 MODULE_DESCRIPTION("Library module for ATA devices"); 168 MODULE_DESCRIPTION("Library module for ATA devices");
169 MODULE_LICENSE("GPL"); 169 MODULE_LICENSE("GPL");
170 MODULE_VERSION(DRV_VERSION); 170 MODULE_VERSION(DRV_VERSION);
171 171
172 172
173 static bool ata_sstatus_online(u32 sstatus) 173 static bool ata_sstatus_online(u32 sstatus)
174 { 174 {
175 return (sstatus & 0xf) == 0x3; 175 return (sstatus & 0xf) == 0x3;
176 } 176 }
177 177
178 /** 178 /**
179 * ata_link_next - link iteration helper 179 * ata_link_next - link iteration helper
180 * @link: the previous link, NULL to start 180 * @link: the previous link, NULL to start
181 * @ap: ATA port containing links to iterate 181 * @ap: ATA port containing links to iterate
182 * @mode: iteration mode, one of ATA_LITER_* 182 * @mode: iteration mode, one of ATA_LITER_*
183 * 183 *
184 * LOCKING: 184 * LOCKING:
185 * Host lock or EH context. 185 * Host lock or EH context.
186 * 186 *
187 * RETURNS: 187 * RETURNS:
188 * Pointer to the next link. 188 * Pointer to the next link.
189 */ 189 */
190 struct ata_link *ata_link_next(struct ata_link *link, struct ata_port *ap, 190 struct ata_link *ata_link_next(struct ata_link *link, struct ata_port *ap,
191 enum ata_link_iter_mode mode) 191 enum ata_link_iter_mode mode)
192 { 192 {
193 BUG_ON(mode != ATA_LITER_EDGE && 193 BUG_ON(mode != ATA_LITER_EDGE &&
194 mode != ATA_LITER_PMP_FIRST && mode != ATA_LITER_HOST_FIRST); 194 mode != ATA_LITER_PMP_FIRST && mode != ATA_LITER_HOST_FIRST);
195 195
196 /* NULL link indicates start of iteration */ 196 /* NULL link indicates start of iteration */
197 if (!link) 197 if (!link)
198 switch (mode) { 198 switch (mode) {
199 case ATA_LITER_EDGE: 199 case ATA_LITER_EDGE:
200 case ATA_LITER_PMP_FIRST: 200 case ATA_LITER_PMP_FIRST:
201 if (sata_pmp_attached(ap)) 201 if (sata_pmp_attached(ap))
202 return ap->pmp_link; 202 return ap->pmp_link;
203 /* fall through */ 203 /* fall through */
204 case ATA_LITER_HOST_FIRST: 204 case ATA_LITER_HOST_FIRST:
205 return &ap->link; 205 return &ap->link;
206 } 206 }
207 207
208 /* we just iterated over the host link, what's next? */ 208 /* we just iterated over the host link, what's next? */
209 if (link == &ap->link) 209 if (link == &ap->link)
210 switch (mode) { 210 switch (mode) {
211 case ATA_LITER_HOST_FIRST: 211 case ATA_LITER_HOST_FIRST:
212 if (sata_pmp_attached(ap)) 212 if (sata_pmp_attached(ap))
213 return ap->pmp_link; 213 return ap->pmp_link;
214 /* fall through */ 214 /* fall through */
215 case ATA_LITER_PMP_FIRST: 215 case ATA_LITER_PMP_FIRST:
216 if (unlikely(ap->slave_link)) 216 if (unlikely(ap->slave_link))
217 return ap->slave_link; 217 return ap->slave_link;
218 /* fall through */ 218 /* fall through */
219 case ATA_LITER_EDGE: 219 case ATA_LITER_EDGE:
220 return NULL; 220 return NULL;
221 } 221 }
222 222
223 /* slave_link excludes PMP */ 223 /* slave_link excludes PMP */
224 if (unlikely(link == ap->slave_link)) 224 if (unlikely(link == ap->slave_link))
225 return NULL; 225 return NULL;
226 226
227 /* we were over a PMP link */ 227 /* we were over a PMP link */
228 if (++link < ap->pmp_link + ap->nr_pmp_links) 228 if (++link < ap->pmp_link + ap->nr_pmp_links)
229 return link; 229 return link;
230 230
231 if (mode == ATA_LITER_PMP_FIRST) 231 if (mode == ATA_LITER_PMP_FIRST)
232 return &ap->link; 232 return &ap->link;
233 233
234 return NULL; 234 return NULL;
235 } 235 }
236 236
237 /** 237 /**
238 * ata_dev_next - device iteration helper 238 * ata_dev_next - device iteration helper
239 * @dev: the previous device, NULL to start 239 * @dev: the previous device, NULL to start
240 * @link: ATA link containing devices to iterate 240 * @link: ATA link containing devices to iterate
241 * @mode: iteration mode, one of ATA_DITER_* 241 * @mode: iteration mode, one of ATA_DITER_*
242 * 242 *
243 * LOCKING: 243 * LOCKING:
244 * Host lock or EH context. 244 * Host lock or EH context.
245 * 245 *
246 * RETURNS: 246 * RETURNS:
247 * Pointer to the next device. 247 * Pointer to the next device.
248 */ 248 */
249 struct ata_device *ata_dev_next(struct ata_device *dev, struct ata_link *link, 249 struct ata_device *ata_dev_next(struct ata_device *dev, struct ata_link *link,
250 enum ata_dev_iter_mode mode) 250 enum ata_dev_iter_mode mode)
251 { 251 {
252 BUG_ON(mode != ATA_DITER_ENABLED && mode != ATA_DITER_ENABLED_REVERSE && 252 BUG_ON(mode != ATA_DITER_ENABLED && mode != ATA_DITER_ENABLED_REVERSE &&
253 mode != ATA_DITER_ALL && mode != ATA_DITER_ALL_REVERSE); 253 mode != ATA_DITER_ALL && mode != ATA_DITER_ALL_REVERSE);
254 254
255 /* NULL dev indicates start of iteration */ 255 /* NULL dev indicates start of iteration */
256 if (!dev) 256 if (!dev)
257 switch (mode) { 257 switch (mode) {
258 case ATA_DITER_ENABLED: 258 case ATA_DITER_ENABLED:
259 case ATA_DITER_ALL: 259 case ATA_DITER_ALL:
260 dev = link->device; 260 dev = link->device;
261 goto check; 261 goto check;
262 case ATA_DITER_ENABLED_REVERSE: 262 case ATA_DITER_ENABLED_REVERSE:
263 case ATA_DITER_ALL_REVERSE: 263 case ATA_DITER_ALL_REVERSE:
264 dev = link->device + ata_link_max_devices(link) - 1; 264 dev = link->device + ata_link_max_devices(link) - 1;
265 goto check; 265 goto check;
266 } 266 }
267 267
268 next: 268 next:
269 /* move to the next one */ 269 /* move to the next one */
270 switch (mode) { 270 switch (mode) {
271 case ATA_DITER_ENABLED: 271 case ATA_DITER_ENABLED:
272 case ATA_DITER_ALL: 272 case ATA_DITER_ALL:
273 if (++dev < link->device + ata_link_max_devices(link)) 273 if (++dev < link->device + ata_link_max_devices(link))
274 goto check; 274 goto check;
275 return NULL; 275 return NULL;
276 case ATA_DITER_ENABLED_REVERSE: 276 case ATA_DITER_ENABLED_REVERSE:
277 case ATA_DITER_ALL_REVERSE: 277 case ATA_DITER_ALL_REVERSE:
278 if (--dev >= link->device) 278 if (--dev >= link->device)
279 goto check; 279 goto check;
280 return NULL; 280 return NULL;
281 } 281 }
282 282
283 check: 283 check:
284 if ((mode == ATA_DITER_ENABLED || mode == ATA_DITER_ENABLED_REVERSE) && 284 if ((mode == ATA_DITER_ENABLED || mode == ATA_DITER_ENABLED_REVERSE) &&
285 !ata_dev_enabled(dev)) 285 !ata_dev_enabled(dev))
286 goto next; 286 goto next;
287 return dev; 287 return dev;
288 } 288 }
289 289
290 /** 290 /**
291 * ata_dev_phys_link - find physical link for a device 291 * ata_dev_phys_link - find physical link for a device
292 * @dev: ATA device to look up physical link for 292 * @dev: ATA device to look up physical link for
293 * 293 *
294 * Look up physical link which @dev is attached to. Note that 294 * Look up physical link which @dev is attached to. Note that
295 * this is different from @dev->link only when @dev is on slave 295 * this is different from @dev->link only when @dev is on slave
296 * link. For all other cases, it's the same as @dev->link. 296 * link. For all other cases, it's the same as @dev->link.
297 * 297 *
298 * LOCKING: 298 * LOCKING:
299 * Don't care. 299 * Don't care.
300 * 300 *
301 * RETURNS: 301 * RETURNS:
302 * Pointer to the found physical link. 302 * Pointer to the found physical link.
303 */ 303 */
304 struct ata_link *ata_dev_phys_link(struct ata_device *dev) 304 struct ata_link *ata_dev_phys_link(struct ata_device *dev)
305 { 305 {
306 struct ata_port *ap = dev->link->ap; 306 struct ata_port *ap = dev->link->ap;
307 307
308 if (!ap->slave_link) 308 if (!ap->slave_link)
309 return dev->link; 309 return dev->link;
310 if (!dev->devno) 310 if (!dev->devno)
311 return &ap->link; 311 return &ap->link;
312 return ap->slave_link; 312 return ap->slave_link;
313 } 313 }
314 314
315 /** 315 /**
316 * ata_force_cbl - force cable type according to libata.force 316 * ata_force_cbl - force cable type according to libata.force
317 * @ap: ATA port of interest 317 * @ap: ATA port of interest
318 * 318 *
319 * Force cable type according to libata.force and whine about it. 319 * Force cable type according to libata.force and whine about it.
320 * The last entry which has matching port number is used, so it 320 * The last entry which has matching port number is used, so it
321 * can be specified as part of device force parameters. For 321 * can be specified as part of device force parameters. For
322 * example, both "a:40c,1.00:udma4" and "1.00:40c,udma4" have the 322 * example, both "a:40c,1.00:udma4" and "1.00:40c,udma4" have the
323 * same effect. 323 * same effect.
324 * 324 *
325 * LOCKING: 325 * LOCKING:
326 * EH context. 326 * EH context.
327 */ 327 */
328 void ata_force_cbl(struct ata_port *ap) 328 void ata_force_cbl(struct ata_port *ap)
329 { 329 {
330 int i; 330 int i;
331 331
332 for (i = ata_force_tbl_size - 1; i >= 0; i--) { 332 for (i = ata_force_tbl_size - 1; i >= 0; i--) {
333 const struct ata_force_ent *fe = &ata_force_tbl[i]; 333 const struct ata_force_ent *fe = &ata_force_tbl[i];
334 334
335 if (fe->port != -1 && fe->port != ap->print_id) 335 if (fe->port != -1 && fe->port != ap->print_id)
336 continue; 336 continue;
337 337
338 if (fe->param.cbl == ATA_CBL_NONE) 338 if (fe->param.cbl == ATA_CBL_NONE)
339 continue; 339 continue;
340 340
341 ap->cbl = fe->param.cbl; 341 ap->cbl = fe->param.cbl;
342 ata_port_printk(ap, KERN_NOTICE, 342 ata_port_printk(ap, KERN_NOTICE,
343 "FORCE: cable set to %s\n", fe->param.name); 343 "FORCE: cable set to %s\n", fe->param.name);
344 return; 344 return;
345 } 345 }
346 } 346 }
347 347
348 /** 348 /**
349 * ata_force_link_limits - force link limits according to libata.force 349 * ata_force_link_limits - force link limits according to libata.force
350 * @link: ATA link of interest 350 * @link: ATA link of interest
351 * 351 *
352 * Force link flags and SATA spd limit according to libata.force 352 * Force link flags and SATA spd limit according to libata.force
353 * and whine about it. When only the port part is specified 353 * and whine about it. When only the port part is specified
354 * (e.g. 1:), the limit applies to all links connected to both 354 * (e.g. 1:), the limit applies to all links connected to both
355 * the host link and all fan-out ports connected via PMP. If the 355 * the host link and all fan-out ports connected via PMP. If the
356 * device part is specified as 0 (e.g. 1.00:), it specifies the 356 * device part is specified as 0 (e.g. 1.00:), it specifies the
357 * first fan-out link not the host link. Device number 15 always 357 * first fan-out link not the host link. Device number 15 always
358 * points to the host link whether PMP is attached or not. If the 358 * points to the host link whether PMP is attached or not. If the
359 * controller has slave link, device number 16 points to it. 359 * controller has slave link, device number 16 points to it.
360 * 360 *
361 * LOCKING: 361 * LOCKING:
362 * EH context. 362 * EH context.
363 */ 363 */
364 static void ata_force_link_limits(struct ata_link *link) 364 static void ata_force_link_limits(struct ata_link *link)
365 { 365 {
366 bool did_spd = false; 366 bool did_spd = false;
367 int linkno = link->pmp; 367 int linkno = link->pmp;
368 int i; 368 int i;
369 369
370 if (ata_is_host_link(link)) 370 if (ata_is_host_link(link))
371 linkno += 15; 371 linkno += 15;
372 372
373 for (i = ata_force_tbl_size - 1; i >= 0; i--) { 373 for (i = ata_force_tbl_size - 1; i >= 0; i--) {
374 const struct ata_force_ent *fe = &ata_force_tbl[i]; 374 const struct ata_force_ent *fe = &ata_force_tbl[i];
375 375
376 if (fe->port != -1 && fe->port != link->ap->print_id) 376 if (fe->port != -1 && fe->port != link->ap->print_id)
377 continue; 377 continue;
378 378
379 if (fe->device != -1 && fe->device != linkno) 379 if (fe->device != -1 && fe->device != linkno)
380 continue; 380 continue;
381 381
382 /* only honor the first spd limit */ 382 /* only honor the first spd limit */
383 if (!did_spd && fe->param.spd_limit) { 383 if (!did_spd && fe->param.spd_limit) {
384 link->hw_sata_spd_limit = (1 << fe->param.spd_limit) - 1; 384 link->hw_sata_spd_limit = (1 << fe->param.spd_limit) - 1;
385 ata_link_printk(link, KERN_NOTICE, 385 ata_link_printk(link, KERN_NOTICE,
386 "FORCE: PHY spd limit set to %s\n", 386 "FORCE: PHY spd limit set to %s\n",
387 fe->param.name); 387 fe->param.name);
388 did_spd = true; 388 did_spd = true;
389 } 389 }
390 390
391 /* let lflags stack */ 391 /* let lflags stack */
392 if (fe->param.lflags) { 392 if (fe->param.lflags) {
393 link->flags |= fe->param.lflags; 393 link->flags |= fe->param.lflags;
394 ata_link_printk(link, KERN_NOTICE, 394 ata_link_printk(link, KERN_NOTICE,
395 "FORCE: link flag 0x%x forced -> 0x%x\n", 395 "FORCE: link flag 0x%x forced -> 0x%x\n",
396 fe->param.lflags, link->flags); 396 fe->param.lflags, link->flags);
397 } 397 }
398 } 398 }
399 } 399 }
400 400
401 /** 401 /**
402 * ata_force_xfermask - force xfermask according to libata.force 402 * ata_force_xfermask - force xfermask according to libata.force
403 * @dev: ATA device of interest 403 * @dev: ATA device of interest
404 * 404 *
405 * Force xfer_mask according to libata.force and whine about it. 405 * Force xfer_mask according to libata.force and whine about it.
406 * For consistency with link selection, device number 15 selects 406 * For consistency with link selection, device number 15 selects
407 * the first device connected to the host link. 407 * the first device connected to the host link.
408 * 408 *
409 * LOCKING: 409 * LOCKING:
410 * EH context. 410 * EH context.
411 */ 411 */
412 static void ata_force_xfermask(struct ata_device *dev) 412 static void ata_force_xfermask(struct ata_device *dev)
413 { 413 {
414 int devno = dev->link->pmp + dev->devno; 414 int devno = dev->link->pmp + dev->devno;
415 int alt_devno = devno; 415 int alt_devno = devno;
416 int i; 416 int i;
417 417
418 /* allow n.15/16 for devices attached to host port */ 418 /* allow n.15/16 for devices attached to host port */
419 if (ata_is_host_link(dev->link)) 419 if (ata_is_host_link(dev->link))
420 alt_devno += 15; 420 alt_devno += 15;
421 421
422 for (i = ata_force_tbl_size - 1; i >= 0; i--) { 422 for (i = ata_force_tbl_size - 1; i >= 0; i--) {
423 const struct ata_force_ent *fe = &ata_force_tbl[i]; 423 const struct ata_force_ent *fe = &ata_force_tbl[i];
424 unsigned long pio_mask, mwdma_mask, udma_mask; 424 unsigned long pio_mask, mwdma_mask, udma_mask;
425 425
426 if (fe->port != -1 && fe->port != dev->link->ap->print_id) 426 if (fe->port != -1 && fe->port != dev->link->ap->print_id)
427 continue; 427 continue;
428 428
429 if (fe->device != -1 && fe->device != devno && 429 if (fe->device != -1 && fe->device != devno &&
430 fe->device != alt_devno) 430 fe->device != alt_devno)
431 continue; 431 continue;
432 432
433 if (!fe->param.xfer_mask) 433 if (!fe->param.xfer_mask)
434 continue; 434 continue;
435 435
436 ata_unpack_xfermask(fe->param.xfer_mask, 436 ata_unpack_xfermask(fe->param.xfer_mask,
437 &pio_mask, &mwdma_mask, &udma_mask); 437 &pio_mask, &mwdma_mask, &udma_mask);
438 if (udma_mask) 438 if (udma_mask)
439 dev->udma_mask = udma_mask; 439 dev->udma_mask = udma_mask;
440 else if (mwdma_mask) { 440 else if (mwdma_mask) {
441 dev->udma_mask = 0; 441 dev->udma_mask = 0;
442 dev->mwdma_mask = mwdma_mask; 442 dev->mwdma_mask = mwdma_mask;
443 } else { 443 } else {
444 dev->udma_mask = 0; 444 dev->udma_mask = 0;
445 dev->mwdma_mask = 0; 445 dev->mwdma_mask = 0;
446 dev->pio_mask = pio_mask; 446 dev->pio_mask = pio_mask;
447 } 447 }
448 448
449 ata_dev_printk(dev, KERN_NOTICE, 449 ata_dev_printk(dev, KERN_NOTICE,
450 "FORCE: xfer_mask set to %s\n", fe->param.name); 450 "FORCE: xfer_mask set to %s\n", fe->param.name);
451 return; 451 return;
452 } 452 }
453 } 453 }
454 454
455 /** 455 /**
456 * ata_force_horkage - force horkage according to libata.force 456 * ata_force_horkage - force horkage according to libata.force
457 * @dev: ATA device of interest 457 * @dev: ATA device of interest
458 * 458 *
459 * Force horkage according to libata.force and whine about it. 459 * Force horkage according to libata.force and whine about it.
460 * For consistency with link selection, device number 15 selects 460 * For consistency with link selection, device number 15 selects
461 * the first device connected to the host link. 461 * the first device connected to the host link.
462 * 462 *
463 * LOCKING: 463 * LOCKING:
464 * EH context. 464 * EH context.
465 */ 465 */
466 static void ata_force_horkage(struct ata_device *dev) 466 static void ata_force_horkage(struct ata_device *dev)
467 { 467 {
468 int devno = dev->link->pmp + dev->devno; 468 int devno = dev->link->pmp + dev->devno;
469 int alt_devno = devno; 469 int alt_devno = devno;
470 int i; 470 int i;
471 471
472 /* allow n.15/16 for devices attached to host port */ 472 /* allow n.15/16 for devices attached to host port */
473 if (ata_is_host_link(dev->link)) 473 if (ata_is_host_link(dev->link))
474 alt_devno += 15; 474 alt_devno += 15;
475 475
476 for (i = 0; i < ata_force_tbl_size; i++) { 476 for (i = 0; i < ata_force_tbl_size; i++) {
477 const struct ata_force_ent *fe = &ata_force_tbl[i]; 477 const struct ata_force_ent *fe = &ata_force_tbl[i];
478 478
479 if (fe->port != -1 && fe->port != dev->link->ap->print_id) 479 if (fe->port != -1 && fe->port != dev->link->ap->print_id)
480 continue; 480 continue;
481 481
482 if (fe->device != -1 && fe->device != devno && 482 if (fe->device != -1 && fe->device != devno &&
483 fe->device != alt_devno) 483 fe->device != alt_devno)
484 continue; 484 continue;
485 485
486 if (!(~dev->horkage & fe->param.horkage_on) && 486 if (!(~dev->horkage & fe->param.horkage_on) &&
487 !(dev->horkage & fe->param.horkage_off)) 487 !(dev->horkage & fe->param.horkage_off))
488 continue; 488 continue;
489 489
490 dev->horkage |= fe->param.horkage_on; 490 dev->horkage |= fe->param.horkage_on;
491 dev->horkage &= ~fe->param.horkage_off; 491 dev->horkage &= ~fe->param.horkage_off;
492 492
493 ata_dev_printk(dev, KERN_NOTICE, 493 ata_dev_printk(dev, KERN_NOTICE,
494 "FORCE: horkage modified (%s)\n", fe->param.name); 494 "FORCE: horkage modified (%s)\n", fe->param.name);
495 } 495 }
496 } 496 }
497 497
498 /** 498 /**
499 * atapi_cmd_type - Determine ATAPI command type from SCSI opcode 499 * atapi_cmd_type - Determine ATAPI command type from SCSI opcode
500 * @opcode: SCSI opcode 500 * @opcode: SCSI opcode
501 * 501 *
502 * Determine ATAPI command type from @opcode. 502 * Determine ATAPI command type from @opcode.
503 * 503 *
504 * LOCKING: 504 * LOCKING:
505 * None. 505 * None.
506 * 506 *
507 * RETURNS: 507 * RETURNS:
508 * ATAPI_{READ|WRITE|READ_CD|PASS_THRU|MISC} 508 * ATAPI_{READ|WRITE|READ_CD|PASS_THRU|MISC}
509 */ 509 */
510 int atapi_cmd_type(u8 opcode) 510 int atapi_cmd_type(u8 opcode)
511 { 511 {
512 switch (opcode) { 512 switch (opcode) {
513 case GPCMD_READ_10: 513 case GPCMD_READ_10:
514 case GPCMD_READ_12: 514 case GPCMD_READ_12:
515 return ATAPI_READ; 515 return ATAPI_READ;
516 516
517 case GPCMD_WRITE_10: 517 case GPCMD_WRITE_10:
518 case GPCMD_WRITE_12: 518 case GPCMD_WRITE_12:
519 case GPCMD_WRITE_AND_VERIFY_10: 519 case GPCMD_WRITE_AND_VERIFY_10:
520 return ATAPI_WRITE; 520 return ATAPI_WRITE;
521 521
522 case GPCMD_READ_CD: 522 case GPCMD_READ_CD:
523 case GPCMD_READ_CD_MSF: 523 case GPCMD_READ_CD_MSF:
524 return ATAPI_READ_CD; 524 return ATAPI_READ_CD;
525 525
526 case ATA_16: 526 case ATA_16:
527 case ATA_12: 527 case ATA_12:
528 if (atapi_passthru16) 528 if (atapi_passthru16)
529 return ATAPI_PASS_THRU; 529 return ATAPI_PASS_THRU;
530 /* fall thru */ 530 /* fall thru */
531 default: 531 default:
532 return ATAPI_MISC; 532 return ATAPI_MISC;
533 } 533 }
534 } 534 }
535 535
536 /** 536 /**
537 * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure 537 * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure
538 * @tf: Taskfile to convert 538 * @tf: Taskfile to convert
539 * @pmp: Port multiplier port 539 * @pmp: Port multiplier port
540 * @is_cmd: This FIS is for command 540 * @is_cmd: This FIS is for command
541 * @fis: Buffer into which data will output 541 * @fis: Buffer into which data will output
542 * 542 *
543 * Converts a standard ATA taskfile to a Serial ATA 543 * Converts a standard ATA taskfile to a Serial ATA
544 * FIS structure (Register - Host to Device). 544 * FIS structure (Register - Host to Device).
545 * 545 *
546 * LOCKING: 546 * LOCKING:
547 * Inherited from caller. 547 * Inherited from caller.
548 */ 548 */
549 void ata_tf_to_fis(const struct ata_taskfile *tf, u8 pmp, int is_cmd, u8 *fis) 549 void ata_tf_to_fis(const struct ata_taskfile *tf, u8 pmp, int is_cmd, u8 *fis)
550 { 550 {
551 fis[0] = 0x27; /* Register - Host to Device FIS */ 551 fis[0] = 0x27; /* Register - Host to Device FIS */
552 fis[1] = pmp & 0xf; /* Port multiplier number*/ 552 fis[1] = pmp & 0xf; /* Port multiplier number*/
553 if (is_cmd) 553 if (is_cmd)
554 fis[1] |= (1 << 7); /* bit 7 indicates Command FIS */ 554 fis[1] |= (1 << 7); /* bit 7 indicates Command FIS */
555 555
556 fis[2] = tf->command; 556 fis[2] = tf->command;
557 fis[3] = tf->feature; 557 fis[3] = tf->feature;
558 558
559 fis[4] = tf->lbal; 559 fis[4] = tf->lbal;
560 fis[5] = tf->lbam; 560 fis[5] = tf->lbam;
561 fis[6] = tf->lbah; 561 fis[6] = tf->lbah;
562 fis[7] = tf->device; 562 fis[7] = tf->device;
563 563
564 fis[8] = tf->hob_lbal; 564 fis[8] = tf->hob_lbal;
565 fis[9] = tf->hob_lbam; 565 fis[9] = tf->hob_lbam;
566 fis[10] = tf->hob_lbah; 566 fis[10] = tf->hob_lbah;
567 fis[11] = tf->hob_feature; 567 fis[11] = tf->hob_feature;
568 568
569 fis[12] = tf->nsect; 569 fis[12] = tf->nsect;
570 fis[13] = tf->hob_nsect; 570 fis[13] = tf->hob_nsect;
571 fis[14] = 0; 571 fis[14] = 0;
572 fis[15] = tf->ctl; 572 fis[15] = tf->ctl;
573 573
574 fis[16] = 0; 574 fis[16] = 0;
575 fis[17] = 0; 575 fis[17] = 0;
576 fis[18] = 0; 576 fis[18] = 0;
577 fis[19] = 0; 577 fis[19] = 0;
578 } 578 }
579 579
580 /** 580 /**
581 * ata_tf_from_fis - Convert SATA FIS to ATA taskfile 581 * ata_tf_from_fis - Convert SATA FIS to ATA taskfile
582 * @fis: Buffer from which data will be input 582 * @fis: Buffer from which data will be input
583 * @tf: Taskfile to output 583 * @tf: Taskfile to output
584 * 584 *
585 * Converts a serial ATA FIS structure to a standard ATA taskfile. 585 * Converts a serial ATA FIS structure to a standard ATA taskfile.
586 * 586 *
587 * LOCKING: 587 * LOCKING:
588 * Inherited from caller. 588 * Inherited from caller.
589 */ 589 */
590 590
591 void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf) 591 void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf)
592 { 592 {
593 tf->command = fis[2]; /* status */ 593 tf->command = fis[2]; /* status */
594 tf->feature = fis[3]; /* error */ 594 tf->feature = fis[3]; /* error */
595 595
596 tf->lbal = fis[4]; 596 tf->lbal = fis[4];
597 tf->lbam = fis[5]; 597 tf->lbam = fis[5];
598 tf->lbah = fis[6]; 598 tf->lbah = fis[6];
599 tf->device = fis[7]; 599 tf->device = fis[7];
600 600
601 tf->hob_lbal = fis[8]; 601 tf->hob_lbal = fis[8];
602 tf->hob_lbam = fis[9]; 602 tf->hob_lbam = fis[9];
603 tf->hob_lbah = fis[10]; 603 tf->hob_lbah = fis[10];
604 604
605 tf->nsect = fis[12]; 605 tf->nsect = fis[12];
606 tf->hob_nsect = fis[13]; 606 tf->hob_nsect = fis[13];
607 } 607 }
608 608
609 static const u8 ata_rw_cmds[] = { 609 static const u8 ata_rw_cmds[] = {
610 /* pio multi */ 610 /* pio multi */
611 ATA_CMD_READ_MULTI, 611 ATA_CMD_READ_MULTI,
612 ATA_CMD_WRITE_MULTI, 612 ATA_CMD_WRITE_MULTI,
613 ATA_CMD_READ_MULTI_EXT, 613 ATA_CMD_READ_MULTI_EXT,
614 ATA_CMD_WRITE_MULTI_EXT, 614 ATA_CMD_WRITE_MULTI_EXT,
615 0, 615 0,
616 0, 616 0,
617 0, 617 0,
618 ATA_CMD_WRITE_MULTI_FUA_EXT, 618 ATA_CMD_WRITE_MULTI_FUA_EXT,
619 /* pio */ 619 /* pio */
620 ATA_CMD_PIO_READ, 620 ATA_CMD_PIO_READ,
621 ATA_CMD_PIO_WRITE, 621 ATA_CMD_PIO_WRITE,
622 ATA_CMD_PIO_READ_EXT, 622 ATA_CMD_PIO_READ_EXT,
623 ATA_CMD_PIO_WRITE_EXT, 623 ATA_CMD_PIO_WRITE_EXT,
624 0, 624 0,
625 0, 625 0,
626 0, 626 0,
627 0, 627 0,
628 /* dma */ 628 /* dma */
629 ATA_CMD_READ, 629 ATA_CMD_READ,
630 ATA_CMD_WRITE, 630 ATA_CMD_WRITE,
631 ATA_CMD_READ_EXT, 631 ATA_CMD_READ_EXT,
632 ATA_CMD_WRITE_EXT, 632 ATA_CMD_WRITE_EXT,
633 0, 633 0,
634 0, 634 0,
635 0, 635 0,
636 ATA_CMD_WRITE_FUA_EXT 636 ATA_CMD_WRITE_FUA_EXT
637 }; 637 };
638 638
639 /** 639 /**
640 * ata_rwcmd_protocol - set taskfile r/w commands and protocol 640 * ata_rwcmd_protocol - set taskfile r/w commands and protocol
641 * @tf: command to examine and configure 641 * @tf: command to examine and configure
642 * @dev: device tf belongs to 642 * @dev: device tf belongs to
643 * 643 *
644 * Examine the device configuration and tf->flags to calculate 644 * Examine the device configuration and tf->flags to calculate
645 * the proper read/write commands and protocol to use. 645 * the proper read/write commands and protocol to use.
646 * 646 *
647 * LOCKING: 647 * LOCKING:
648 * caller. 648 * caller.
649 */ 649 */
650 static int ata_rwcmd_protocol(struct ata_taskfile *tf, struct ata_device *dev) 650 static int ata_rwcmd_protocol(struct ata_taskfile *tf, struct ata_device *dev)
651 { 651 {
652 u8 cmd; 652 u8 cmd;
653 653
654 int index, fua, lba48, write; 654 int index, fua, lba48, write;
655 655
656 fua = (tf->flags & ATA_TFLAG_FUA) ? 4 : 0; 656 fua = (tf->flags & ATA_TFLAG_FUA) ? 4 : 0;
657 lba48 = (tf->flags & ATA_TFLAG_LBA48) ? 2 : 0; 657 lba48 = (tf->flags & ATA_TFLAG_LBA48) ? 2 : 0;
658 write = (tf->flags & ATA_TFLAG_WRITE) ? 1 : 0; 658 write = (tf->flags & ATA_TFLAG_WRITE) ? 1 : 0;
659 659
660 if (dev->flags & ATA_DFLAG_PIO) { 660 if (dev->flags & ATA_DFLAG_PIO) {
661 tf->protocol = ATA_PROT_PIO; 661 tf->protocol = ATA_PROT_PIO;
662 index = dev->multi_count ? 0 : 8; 662 index = dev->multi_count ? 0 : 8;
663 } else if (lba48 && (dev->link->ap->flags & ATA_FLAG_PIO_LBA48)) { 663 } else if (lba48 && (dev->link->ap->flags & ATA_FLAG_PIO_LBA48)) {
664 /* Unable to use DMA due to host limitation */ 664 /* Unable to use DMA due to host limitation */
665 tf->protocol = ATA_PROT_PIO; 665 tf->protocol = ATA_PROT_PIO;
666 index = dev->multi_count ? 0 : 8; 666 index = dev->multi_count ? 0 : 8;
667 } else { 667 } else {
668 tf->protocol = ATA_PROT_DMA; 668 tf->protocol = ATA_PROT_DMA;
669 index = 16; 669 index = 16;
670 } 670 }
671 671
672 cmd = ata_rw_cmds[index + fua + lba48 + write]; 672 cmd = ata_rw_cmds[index + fua + lba48 + write];
673 if (cmd) { 673 if (cmd) {
674 tf->command = cmd; 674 tf->command = cmd;
675 return 0; 675 return 0;
676 } 676 }
677 return -1; 677 return -1;
678 } 678 }
679 679
680 /** 680 /**
681 * ata_tf_read_block - Read block address from ATA taskfile 681 * ata_tf_read_block - Read block address from ATA taskfile
682 * @tf: ATA taskfile of interest 682 * @tf: ATA taskfile of interest
683 * @dev: ATA device @tf belongs to 683 * @dev: ATA device @tf belongs to
684 * 684 *
685 * LOCKING: 685 * LOCKING:
686 * None. 686 * None.
687 * 687 *
688 * Read block address from @tf. This function can handle all 688 * Read block address from @tf. This function can handle all
689 * three address formats - LBA, LBA48 and CHS. tf->protocol and 689 * three address formats - LBA, LBA48 and CHS. tf->protocol and
690 * flags select the address format to use. 690 * flags select the address format to use.
691 * 691 *
692 * RETURNS: 692 * RETURNS:
693 * Block address read from @tf. 693 * Block address read from @tf.
694 */ 694 */
695 u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev) 695 u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev)
696 { 696 {
697 u64 block = 0; 697 u64 block = 0;
698 698
699 if (tf->flags & ATA_TFLAG_LBA) { 699 if (tf->flags & ATA_TFLAG_LBA) {
700 if (tf->flags & ATA_TFLAG_LBA48) { 700 if (tf->flags & ATA_TFLAG_LBA48) {
701 block |= (u64)tf->hob_lbah << 40; 701 block |= (u64)tf->hob_lbah << 40;
702 block |= (u64)tf->hob_lbam << 32; 702 block |= (u64)tf->hob_lbam << 32;
703 block |= (u64)tf->hob_lbal << 24; 703 block |= (u64)tf->hob_lbal << 24;
704 } else 704 } else
705 block |= (tf->device & 0xf) << 24; 705 block |= (tf->device & 0xf) << 24;
706 706
707 block |= tf->lbah << 16; 707 block |= tf->lbah << 16;
708 block |= tf->lbam << 8; 708 block |= tf->lbam << 8;
709 block |= tf->lbal; 709 block |= tf->lbal;
710 } else { 710 } else {
711 u32 cyl, head, sect; 711 u32 cyl, head, sect;
712 712
713 cyl = tf->lbam | (tf->lbah << 8); 713 cyl = tf->lbam | (tf->lbah << 8);
714 head = tf->device & 0xf; 714 head = tf->device & 0xf;
715 sect = tf->lbal; 715 sect = tf->lbal;
716 716
717 if (!sect) { 717 if (!sect) {
718 ata_dev_printk(dev, KERN_WARNING, "device reported " 718 ata_dev_printk(dev, KERN_WARNING, "device reported "
719 "invalid CHS sector 0\n"); 719 "invalid CHS sector 0\n");
720 sect = 1; /* oh well */ 720 sect = 1; /* oh well */
721 } 721 }
722 722
723 block = (cyl * dev->heads + head) * dev->sectors + sect - 1; 723 block = (cyl * dev->heads + head) * dev->sectors + sect - 1;
724 } 724 }
725 725
726 return block; 726 return block;
727 } 727 }
728 728
729 /** 729 /**
730 * ata_build_rw_tf - Build ATA taskfile for given read/write request 730 * ata_build_rw_tf - Build ATA taskfile for given read/write request
731 * @tf: Target ATA taskfile 731 * @tf: Target ATA taskfile
732 * @dev: ATA device @tf belongs to 732 * @dev: ATA device @tf belongs to
733 * @block: Block address 733 * @block: Block address
734 * @n_block: Number of blocks 734 * @n_block: Number of blocks
735 * @tf_flags: RW/FUA etc... 735 * @tf_flags: RW/FUA etc...
736 * @tag: tag 736 * @tag: tag
737 * 737 *
738 * LOCKING: 738 * LOCKING:
739 * None. 739 * None.
740 * 740 *
741 * Build ATA taskfile @tf for read/write request described by 741 * Build ATA taskfile @tf for read/write request described by
742 * @block, @n_block, @tf_flags and @tag on @dev. 742 * @block, @n_block, @tf_flags and @tag on @dev.
743 * 743 *
744 * RETURNS: 744 * RETURNS:
745 * 745 *
746 * 0 on success, -ERANGE if the request is too large for @dev, 746 * 0 on success, -ERANGE if the request is too large for @dev,
747 * -EINVAL if the request is invalid. 747 * -EINVAL if the request is invalid.
748 */ 748 */
749 int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, 749 int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
750 u64 block, u32 n_block, unsigned int tf_flags, 750 u64 block, u32 n_block, unsigned int tf_flags,
751 unsigned int tag) 751 unsigned int tag)
752 { 752 {
753 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 753 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
754 tf->flags |= tf_flags; 754 tf->flags |= tf_flags;
755 755
756 if (ata_ncq_enabled(dev) && likely(tag != ATA_TAG_INTERNAL)) { 756 if (ata_ncq_enabled(dev) && likely(tag != ATA_TAG_INTERNAL)) {
757 /* yay, NCQ */ 757 /* yay, NCQ */
758 if (!lba_48_ok(block, n_block)) 758 if (!lba_48_ok(block, n_block))
759 return -ERANGE; 759 return -ERANGE;
760 760
761 tf->protocol = ATA_PROT_NCQ; 761 tf->protocol = ATA_PROT_NCQ;
762 tf->flags |= ATA_TFLAG_LBA | ATA_TFLAG_LBA48; 762 tf->flags |= ATA_TFLAG_LBA | ATA_TFLAG_LBA48;
763 763
764 if (tf->flags & ATA_TFLAG_WRITE) 764 if (tf->flags & ATA_TFLAG_WRITE)
765 tf->command = ATA_CMD_FPDMA_WRITE; 765 tf->command = ATA_CMD_FPDMA_WRITE;
766 else 766 else
767 tf->command = ATA_CMD_FPDMA_READ; 767 tf->command = ATA_CMD_FPDMA_READ;
768 768
769 tf->nsect = tag << 3; 769 tf->nsect = tag << 3;
770 tf->hob_feature = (n_block >> 8) & 0xff; 770 tf->hob_feature = (n_block >> 8) & 0xff;
771 tf->feature = n_block & 0xff; 771 tf->feature = n_block & 0xff;
772 772
773 tf->hob_lbah = (block >> 40) & 0xff; 773 tf->hob_lbah = (block >> 40) & 0xff;
774 tf->hob_lbam = (block >> 32) & 0xff; 774 tf->hob_lbam = (block >> 32) & 0xff;
775 tf->hob_lbal = (block >> 24) & 0xff; 775 tf->hob_lbal = (block >> 24) & 0xff;
776 tf->lbah = (block >> 16) & 0xff; 776 tf->lbah = (block >> 16) & 0xff;
777 tf->lbam = (block >> 8) & 0xff; 777 tf->lbam = (block >> 8) & 0xff;
778 tf->lbal = block & 0xff; 778 tf->lbal = block & 0xff;
779 779
780 tf->device = 1 << 6; 780 tf->device = 1 << 6;
781 if (tf->flags & ATA_TFLAG_FUA) 781 if (tf->flags & ATA_TFLAG_FUA)
782 tf->device |= 1 << 7; 782 tf->device |= 1 << 7;
783 } else if (dev->flags & ATA_DFLAG_LBA) { 783 } else if (dev->flags & ATA_DFLAG_LBA) {
784 tf->flags |= ATA_TFLAG_LBA; 784 tf->flags |= ATA_TFLAG_LBA;
785 785
786 if (lba_28_ok(block, n_block)) { 786 if (lba_28_ok(block, n_block)) {
787 /* use LBA28 */ 787 /* use LBA28 */
788 tf->device |= (block >> 24) & 0xf; 788 tf->device |= (block >> 24) & 0xf;
789 } else if (lba_48_ok(block, n_block)) { 789 } else if (lba_48_ok(block, n_block)) {
790 if (!(dev->flags & ATA_DFLAG_LBA48)) 790 if (!(dev->flags & ATA_DFLAG_LBA48))
791 return -ERANGE; 791 return -ERANGE;
792 792
793 /* use LBA48 */ 793 /* use LBA48 */
794 tf->flags |= ATA_TFLAG_LBA48; 794 tf->flags |= ATA_TFLAG_LBA48;
795 795
796 tf->hob_nsect = (n_block >> 8) & 0xff; 796 tf->hob_nsect = (n_block >> 8) & 0xff;
797 797
798 tf->hob_lbah = (block >> 40) & 0xff; 798 tf->hob_lbah = (block >> 40) & 0xff;
799 tf->hob_lbam = (block >> 32) & 0xff; 799 tf->hob_lbam = (block >> 32) & 0xff;
800 tf->hob_lbal = (block >> 24) & 0xff; 800 tf->hob_lbal = (block >> 24) & 0xff;
801 } else 801 } else
802 /* request too large even for LBA48 */ 802 /* request too large even for LBA48 */
803 return -ERANGE; 803 return -ERANGE;
804 804
805 if (unlikely(ata_rwcmd_protocol(tf, dev) < 0)) 805 if (unlikely(ata_rwcmd_protocol(tf, dev) < 0))
806 return -EINVAL; 806 return -EINVAL;
807 807
808 tf->nsect = n_block & 0xff; 808 tf->nsect = n_block & 0xff;
809 809
810 tf->lbah = (block >> 16) & 0xff; 810 tf->lbah = (block >> 16) & 0xff;
811 tf->lbam = (block >> 8) & 0xff; 811 tf->lbam = (block >> 8) & 0xff;
812 tf->lbal = block & 0xff; 812 tf->lbal = block & 0xff;
813 813
814 tf->device |= ATA_LBA; 814 tf->device |= ATA_LBA;
815 } else { 815 } else {
816 /* CHS */ 816 /* CHS */
817 u32 sect, head, cyl, track; 817 u32 sect, head, cyl, track;
818 818
819 /* The request -may- be too large for CHS addressing. */ 819 /* The request -may- be too large for CHS addressing. */
820 if (!lba_28_ok(block, n_block)) 820 if (!lba_28_ok(block, n_block))
821 return -ERANGE; 821 return -ERANGE;
822 822
823 if (unlikely(ata_rwcmd_protocol(tf, dev) < 0)) 823 if (unlikely(ata_rwcmd_protocol(tf, dev) < 0))
824 return -EINVAL; 824 return -EINVAL;
825 825
826 /* Convert LBA to CHS */ 826 /* Convert LBA to CHS */
827 track = (u32)block / dev->sectors; 827 track = (u32)block / dev->sectors;
828 cyl = track / dev->heads; 828 cyl = track / dev->heads;
829 head = track % dev->heads; 829 head = track % dev->heads;
830 sect = (u32)block % dev->sectors + 1; 830 sect = (u32)block % dev->sectors + 1;
831 831
832 DPRINTK("block %u track %u cyl %u head %u sect %u\n", 832 DPRINTK("block %u track %u cyl %u head %u sect %u\n",
833 (u32)block, track, cyl, head, sect); 833 (u32)block, track, cyl, head, sect);
834 834
835 /* Check whether the converted CHS can fit. 835 /* Check whether the converted CHS can fit.
836 Cylinder: 0-65535 836 Cylinder: 0-65535
837 Head: 0-15 837 Head: 0-15
838 Sector: 1-255*/ 838 Sector: 1-255*/
839 if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect)) 839 if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect))
840 return -ERANGE; 840 return -ERANGE;
841 841
842 tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */ 842 tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */
843 tf->lbal = sect; 843 tf->lbal = sect;
844 tf->lbam = cyl; 844 tf->lbam = cyl;
845 tf->lbah = cyl >> 8; 845 tf->lbah = cyl >> 8;
846 tf->device |= head; 846 tf->device |= head;
847 } 847 }
848 848
849 return 0; 849 return 0;
850 } 850 }
851 851
852 /** 852 /**
853 * ata_pack_xfermask - Pack pio, mwdma and udma masks into xfer_mask 853 * ata_pack_xfermask - Pack pio, mwdma and udma masks into xfer_mask
854 * @pio_mask: pio_mask 854 * @pio_mask: pio_mask
855 * @mwdma_mask: mwdma_mask 855 * @mwdma_mask: mwdma_mask
856 * @udma_mask: udma_mask 856 * @udma_mask: udma_mask
857 * 857 *
858 * Pack @pio_mask, @mwdma_mask and @udma_mask into a single 858 * Pack @pio_mask, @mwdma_mask and @udma_mask into a single
859 * unsigned int xfer_mask. 859 * unsigned int xfer_mask.
860 * 860 *
861 * LOCKING: 861 * LOCKING:
862 * None. 862 * None.
863 * 863 *
864 * RETURNS: 864 * RETURNS:
865 * Packed xfer_mask. 865 * Packed xfer_mask.
866 */ 866 */
867 unsigned long ata_pack_xfermask(unsigned long pio_mask, 867 unsigned long ata_pack_xfermask(unsigned long pio_mask,
868 unsigned long mwdma_mask, 868 unsigned long mwdma_mask,
869 unsigned long udma_mask) 869 unsigned long udma_mask)
870 { 870 {
871 return ((pio_mask << ATA_SHIFT_PIO) & ATA_MASK_PIO) | 871 return ((pio_mask << ATA_SHIFT_PIO) & ATA_MASK_PIO) |
872 ((mwdma_mask << ATA_SHIFT_MWDMA) & ATA_MASK_MWDMA) | 872 ((mwdma_mask << ATA_SHIFT_MWDMA) & ATA_MASK_MWDMA) |
873 ((udma_mask << ATA_SHIFT_UDMA) & ATA_MASK_UDMA); 873 ((udma_mask << ATA_SHIFT_UDMA) & ATA_MASK_UDMA);
874 } 874 }
875 875
876 /** 876 /**
877 * ata_unpack_xfermask - Unpack xfer_mask into pio, mwdma and udma masks 877 * ata_unpack_xfermask - Unpack xfer_mask into pio, mwdma and udma masks
878 * @xfer_mask: xfer_mask to unpack 878 * @xfer_mask: xfer_mask to unpack
879 * @pio_mask: resulting pio_mask 879 * @pio_mask: resulting pio_mask
880 * @mwdma_mask: resulting mwdma_mask 880 * @mwdma_mask: resulting mwdma_mask
881 * @udma_mask: resulting udma_mask 881 * @udma_mask: resulting udma_mask
882 * 882 *
883 * Unpack @xfer_mask into @pio_mask, @mwdma_mask and @udma_mask. 883 * Unpack @xfer_mask into @pio_mask, @mwdma_mask and @udma_mask.
884 * Any NULL distination masks will be ignored. 884 * Any NULL distination masks will be ignored.
885 */ 885 */
886 void ata_unpack_xfermask(unsigned long xfer_mask, unsigned long *pio_mask, 886 void ata_unpack_xfermask(unsigned long xfer_mask, unsigned long *pio_mask,
887 unsigned long *mwdma_mask, unsigned long *udma_mask) 887 unsigned long *mwdma_mask, unsigned long *udma_mask)
888 { 888 {
889 if (pio_mask) 889 if (pio_mask)
890 *pio_mask = (xfer_mask & ATA_MASK_PIO) >> ATA_SHIFT_PIO; 890 *pio_mask = (xfer_mask & ATA_MASK_PIO) >> ATA_SHIFT_PIO;
891 if (mwdma_mask) 891 if (mwdma_mask)
892 *mwdma_mask = (xfer_mask & ATA_MASK_MWDMA) >> ATA_SHIFT_MWDMA; 892 *mwdma_mask = (xfer_mask & ATA_MASK_MWDMA) >> ATA_SHIFT_MWDMA;
893 if (udma_mask) 893 if (udma_mask)
894 *udma_mask = (xfer_mask & ATA_MASK_UDMA) >> ATA_SHIFT_UDMA; 894 *udma_mask = (xfer_mask & ATA_MASK_UDMA) >> ATA_SHIFT_UDMA;
895 } 895 }
896 896
897 static const struct ata_xfer_ent { 897 static const struct ata_xfer_ent {
898 int shift, bits; 898 int shift, bits;
899 u8 base; 899 u8 base;
900 } ata_xfer_tbl[] = { 900 } ata_xfer_tbl[] = {
901 { ATA_SHIFT_PIO, ATA_NR_PIO_MODES, XFER_PIO_0 }, 901 { ATA_SHIFT_PIO, ATA_NR_PIO_MODES, XFER_PIO_0 },
902 { ATA_SHIFT_MWDMA, ATA_NR_MWDMA_MODES, XFER_MW_DMA_0 }, 902 { ATA_SHIFT_MWDMA, ATA_NR_MWDMA_MODES, XFER_MW_DMA_0 },
903 { ATA_SHIFT_UDMA, ATA_NR_UDMA_MODES, XFER_UDMA_0 }, 903 { ATA_SHIFT_UDMA, ATA_NR_UDMA_MODES, XFER_UDMA_0 },
904 { -1, }, 904 { -1, },
905 }; 905 };
906 906
907 /** 907 /**
908 * ata_xfer_mask2mode - Find matching XFER_* for the given xfer_mask 908 * ata_xfer_mask2mode - Find matching XFER_* for the given xfer_mask
909 * @xfer_mask: xfer_mask of interest 909 * @xfer_mask: xfer_mask of interest
910 * 910 *
911 * Return matching XFER_* value for @xfer_mask. Only the highest 911 * Return matching XFER_* value for @xfer_mask. Only the highest
912 * bit of @xfer_mask is considered. 912 * bit of @xfer_mask is considered.
913 * 913 *
914 * LOCKING: 914 * LOCKING:
915 * None. 915 * None.
916 * 916 *
917 * RETURNS: 917 * RETURNS:
918 * Matching XFER_* value, 0xff if no match found. 918 * Matching XFER_* value, 0xff if no match found.
919 */ 919 */
920 u8 ata_xfer_mask2mode(unsigned long xfer_mask) 920 u8 ata_xfer_mask2mode(unsigned long xfer_mask)
921 { 921 {
922 int highbit = fls(xfer_mask) - 1; 922 int highbit = fls(xfer_mask) - 1;
923 const struct ata_xfer_ent *ent; 923 const struct ata_xfer_ent *ent;
924 924
925 for (ent = ata_xfer_tbl; ent->shift >= 0; ent++) 925 for (ent = ata_xfer_tbl; ent->shift >= 0; ent++)
926 if (highbit >= ent->shift && highbit < ent->shift + ent->bits) 926 if (highbit >= ent->shift && highbit < ent->shift + ent->bits)
927 return ent->base + highbit - ent->shift; 927 return ent->base + highbit - ent->shift;
928 return 0xff; 928 return 0xff;
929 } 929 }
930 930
931 /** 931 /**
932 * ata_xfer_mode2mask - Find matching xfer_mask for XFER_* 932 * ata_xfer_mode2mask - Find matching xfer_mask for XFER_*
933 * @xfer_mode: XFER_* of interest 933 * @xfer_mode: XFER_* of interest
934 * 934 *
935 * Return matching xfer_mask for @xfer_mode. 935 * Return matching xfer_mask for @xfer_mode.
936 * 936 *
937 * LOCKING: 937 * LOCKING:
938 * None. 938 * None.
939 * 939 *
940 * RETURNS: 940 * RETURNS:
941 * Matching xfer_mask, 0 if no match found. 941 * Matching xfer_mask, 0 if no match found.
942 */ 942 */
943 unsigned long ata_xfer_mode2mask(u8 xfer_mode) 943 unsigned long ata_xfer_mode2mask(u8 xfer_mode)
944 { 944 {
945 const struct ata_xfer_ent *ent; 945 const struct ata_xfer_ent *ent;
946 946
947 for (ent = ata_xfer_tbl; ent->shift >= 0; ent++) 947 for (ent = ata_xfer_tbl; ent->shift >= 0; ent++)
948 if (xfer_mode >= ent->base && xfer_mode < ent->base + ent->bits) 948 if (xfer_mode >= ent->base && xfer_mode < ent->base + ent->bits)
949 return ((2 << (ent->shift + xfer_mode - ent->base)) - 1) 949 return ((2 << (ent->shift + xfer_mode - ent->base)) - 1)
950 & ~((1 << ent->shift) - 1); 950 & ~((1 << ent->shift) - 1);
951 return 0; 951 return 0;
952 } 952 }
953 953
954 /** 954 /**
955 * ata_xfer_mode2shift - Find matching xfer_shift for XFER_* 955 * ata_xfer_mode2shift - Find matching xfer_shift for XFER_*
956 * @xfer_mode: XFER_* of interest 956 * @xfer_mode: XFER_* of interest
957 * 957 *
958 * Return matching xfer_shift for @xfer_mode. 958 * Return matching xfer_shift for @xfer_mode.
959 * 959 *
960 * LOCKING: 960 * LOCKING:
961 * None. 961 * None.
962 * 962 *
963 * RETURNS: 963 * RETURNS:
964 * Matching xfer_shift, -1 if no match found. 964 * Matching xfer_shift, -1 if no match found.
965 */ 965 */
966 int ata_xfer_mode2shift(unsigned long xfer_mode) 966 int ata_xfer_mode2shift(unsigned long xfer_mode)
967 { 967 {
968 const struct ata_xfer_ent *ent; 968 const struct ata_xfer_ent *ent;
969 969
970 for (ent = ata_xfer_tbl; ent->shift >= 0; ent++) 970 for (ent = ata_xfer_tbl; ent->shift >= 0; ent++)
971 if (xfer_mode >= ent->base && xfer_mode < ent->base + ent->bits) 971 if (xfer_mode >= ent->base && xfer_mode < ent->base + ent->bits)
972 return ent->shift; 972 return ent->shift;
973 return -1; 973 return -1;
974 } 974 }
975 975
976 /** 976 /**
977 * ata_mode_string - convert xfer_mask to string 977 * ata_mode_string - convert xfer_mask to string
978 * @xfer_mask: mask of bits supported; only highest bit counts. 978 * @xfer_mask: mask of bits supported; only highest bit counts.
979 * 979 *
980 * Determine string which represents the highest speed 980 * Determine string which represents the highest speed
981 * (highest bit in @modemask). 981 * (highest bit in @modemask).
982 * 982 *
983 * LOCKING: 983 * LOCKING:
984 * None. 984 * None.
985 * 985 *
986 * RETURNS: 986 * RETURNS:
987 * Constant C string representing highest speed listed in 987 * Constant C string representing highest speed listed in
988 * @mode_mask, or the constant C string "<n/a>". 988 * @mode_mask, or the constant C string "<n/a>".
989 */ 989 */
990 const char *ata_mode_string(unsigned long xfer_mask) 990 const char *ata_mode_string(unsigned long xfer_mask)
991 { 991 {
992 static const char * const xfer_mode_str[] = { 992 static const char * const xfer_mode_str[] = {
993 "PIO0", 993 "PIO0",
994 "PIO1", 994 "PIO1",
995 "PIO2", 995 "PIO2",
996 "PIO3", 996 "PIO3",
997 "PIO4", 997 "PIO4",
998 "PIO5", 998 "PIO5",
999 "PIO6", 999 "PIO6",
1000 "MWDMA0", 1000 "MWDMA0",
1001 "MWDMA1", 1001 "MWDMA1",
1002 "MWDMA2", 1002 "MWDMA2",
1003 "MWDMA3", 1003 "MWDMA3",
1004 "MWDMA4", 1004 "MWDMA4",
1005 "UDMA/16", 1005 "UDMA/16",
1006 "UDMA/25", 1006 "UDMA/25",
1007 "UDMA/33", 1007 "UDMA/33",
1008 "UDMA/44", 1008 "UDMA/44",
1009 "UDMA/66", 1009 "UDMA/66",
1010 "UDMA/100", 1010 "UDMA/100",
1011 "UDMA/133", 1011 "UDMA/133",
1012 "UDMA7", 1012 "UDMA7",
1013 }; 1013 };
1014 int highbit; 1014 int highbit;
1015 1015
1016 highbit = fls(xfer_mask) - 1; 1016 highbit = fls(xfer_mask) - 1;
1017 if (highbit >= 0 && highbit < ARRAY_SIZE(xfer_mode_str)) 1017 if (highbit >= 0 && highbit < ARRAY_SIZE(xfer_mode_str))
1018 return xfer_mode_str[highbit]; 1018 return xfer_mode_str[highbit];
1019 return "<n/a>"; 1019 return "<n/a>";
1020 } 1020 }
1021 1021
1022 static const char *sata_spd_string(unsigned int spd) 1022 static const char *sata_spd_string(unsigned int spd)
1023 { 1023 {
1024 static const char * const spd_str[] = { 1024 static const char * const spd_str[] = {
1025 "1.5 Gbps", 1025 "1.5 Gbps",
1026 "3.0 Gbps", 1026 "3.0 Gbps",
1027 "6.0 Gbps", 1027 "6.0 Gbps",
1028 }; 1028 };
1029 1029
1030 if (spd == 0 || (spd - 1) >= ARRAY_SIZE(spd_str)) 1030 if (spd == 0 || (spd - 1) >= ARRAY_SIZE(spd_str))
1031 return "<unknown>"; 1031 return "<unknown>";
1032 return spd_str[spd - 1]; 1032 return spd_str[spd - 1];
1033 } 1033 }
1034 1034
1035 static int ata_dev_set_dipm(struct ata_device *dev, enum link_pm policy) 1035 static int ata_dev_set_dipm(struct ata_device *dev, enum link_pm policy)
1036 { 1036 {
1037 struct ata_link *link = dev->link; 1037 struct ata_link *link = dev->link;
1038 struct ata_port *ap = link->ap; 1038 struct ata_port *ap = link->ap;
1039 u32 scontrol; 1039 u32 scontrol;
1040 unsigned int err_mask; 1040 unsigned int err_mask;
1041 int rc; 1041 int rc;
1042 1042
1043 /* 1043 /*
1044 * disallow DIPM for drivers which haven't set 1044 * disallow DIPM for drivers which haven't set
1045 * ATA_FLAG_IPM. This is because when DIPM is enabled, 1045 * ATA_FLAG_IPM. This is because when DIPM is enabled,
1046 * phy ready will be set in the interrupt status on 1046 * phy ready will be set in the interrupt status on
1047 * state changes, which will cause some drivers to 1047 * state changes, which will cause some drivers to
1048 * think there are errors - additionally drivers will 1048 * think there are errors - additionally drivers will
1049 * need to disable hot plug. 1049 * need to disable hot plug.
1050 */ 1050 */
1051 if (!(ap->flags & ATA_FLAG_IPM) || !ata_dev_enabled(dev)) { 1051 if (!(ap->flags & ATA_FLAG_IPM) || !ata_dev_enabled(dev)) {
1052 ap->pm_policy = NOT_AVAILABLE; 1052 ap->pm_policy = NOT_AVAILABLE;
1053 return -EINVAL; 1053 return -EINVAL;
1054 } 1054 }
1055 1055
1056 /* 1056 /*
1057 * For DIPM, we will only enable it for the 1057 * For DIPM, we will only enable it for the
1058 * min_power setting. 1058 * min_power setting.
1059 * 1059 *
1060 * Why? Because Disks are too stupid to know that 1060 * Why? Because Disks are too stupid to know that
1061 * If the host rejects a request to go to SLUMBER 1061 * If the host rejects a request to go to SLUMBER
1062 * they should retry at PARTIAL, and instead it 1062 * they should retry at PARTIAL, and instead it
1063 * just would give up. So, for medium_power to 1063 * just would give up. So, for medium_power to
1064 * work at all, we need to only allow HIPM. 1064 * work at all, we need to only allow HIPM.
1065 */ 1065 */
1066 rc = sata_scr_read(link, SCR_CONTROL, &scontrol); 1066 rc = sata_scr_read(link, SCR_CONTROL, &scontrol);
1067 if (rc) 1067 if (rc)
1068 return rc; 1068 return rc;
1069 1069
1070 switch (policy) { 1070 switch (policy) {
1071 case MIN_POWER: 1071 case MIN_POWER:
1072 /* no restrictions on IPM transitions */ 1072 /* no restrictions on IPM transitions */
1073 scontrol &= ~(0x3 << 8); 1073 scontrol &= ~(0x3 << 8);
1074 rc = sata_scr_write(link, SCR_CONTROL, scontrol); 1074 rc = sata_scr_write(link, SCR_CONTROL, scontrol);
1075 if (rc) 1075 if (rc)
1076 return rc; 1076 return rc;
1077 1077
1078 /* enable DIPM */ 1078 /* enable DIPM */
1079 if (dev->flags & ATA_DFLAG_DIPM) 1079 if (dev->flags & ATA_DFLAG_DIPM)
1080 err_mask = ata_dev_set_feature(dev, 1080 err_mask = ata_dev_set_feature(dev,
1081 SETFEATURES_SATA_ENABLE, SATA_DIPM); 1081 SETFEATURES_SATA_ENABLE, SATA_DIPM);
1082 break; 1082 break;
1083 case MEDIUM_POWER: 1083 case MEDIUM_POWER:
1084 /* allow IPM to PARTIAL */ 1084 /* allow IPM to PARTIAL */
1085 scontrol &= ~(0x1 << 8); 1085 scontrol &= ~(0x1 << 8);
1086 scontrol |= (0x2 << 8); 1086 scontrol |= (0x2 << 8);
1087 rc = sata_scr_write(link, SCR_CONTROL, scontrol); 1087 rc = sata_scr_write(link, SCR_CONTROL, scontrol);
1088 if (rc) 1088 if (rc)
1089 return rc; 1089 return rc;
1090 1090
1091 /* 1091 /*
1092 * we don't have to disable DIPM since IPM flags 1092 * we don't have to disable DIPM since IPM flags
1093 * disallow transitions to SLUMBER, which effectively 1093 * disallow transitions to SLUMBER, which effectively
1094 * disable DIPM if it does not support PARTIAL 1094 * disable DIPM if it does not support PARTIAL
1095 */ 1095 */
1096 break; 1096 break;
1097 case NOT_AVAILABLE: 1097 case NOT_AVAILABLE:
1098 case MAX_PERFORMANCE: 1098 case MAX_PERFORMANCE:
1099 /* disable all IPM transitions */ 1099 /* disable all IPM transitions */
1100 scontrol |= (0x3 << 8); 1100 scontrol |= (0x3 << 8);
1101 rc = sata_scr_write(link, SCR_CONTROL, scontrol); 1101 rc = sata_scr_write(link, SCR_CONTROL, scontrol);
1102 if (rc) 1102 if (rc)
1103 return rc; 1103 return rc;
1104 1104
1105 /* 1105 /*
1106 * we don't have to disable DIPM since IPM flags 1106 * we don't have to disable DIPM since IPM flags
1107 * disallow all transitions which effectively 1107 * disallow all transitions which effectively
1108 * disable DIPM anyway. 1108 * disable DIPM anyway.
1109 */ 1109 */
1110 break; 1110 break;
1111 } 1111 }
1112 1112
1113 /* FIXME: handle SET FEATURES failure */ 1113 /* FIXME: handle SET FEATURES failure */
1114 (void) err_mask; 1114 (void) err_mask;
1115 1115
1116 return 0; 1116 return 0;
1117 } 1117 }
1118 1118
1119 /** 1119 /**
1120 * ata_dev_enable_pm - enable SATA interface power management 1120 * ata_dev_enable_pm - enable SATA interface power management
1121 * @dev: device to enable power management 1121 * @dev: device to enable power management
1122 * @policy: the link power management policy 1122 * @policy: the link power management policy
1123 * 1123 *
1124 * Enable SATA Interface power management. This will enable 1124 * Enable SATA Interface power management. This will enable
1125 * Device Interface Power Management (DIPM) for min_power 1125 * Device Interface Power Management (DIPM) for min_power
1126 * policy, and then call driver specific callbacks for 1126 * policy, and then call driver specific callbacks for
1127 * enabling Host Initiated Power management. 1127 * enabling Host Initiated Power management.
1128 * 1128 *
1129 * Locking: Caller. 1129 * Locking: Caller.
1130 * Returns: -EINVAL if IPM is not supported, 0 otherwise. 1130 * Returns: -EINVAL if IPM is not supported, 0 otherwise.
1131 */ 1131 */
1132 void ata_dev_enable_pm(struct ata_device *dev, enum link_pm policy) 1132 void ata_dev_enable_pm(struct ata_device *dev, enum link_pm policy)
1133 { 1133 {
1134 int rc = 0; 1134 int rc = 0;
1135 struct ata_port *ap = dev->link->ap; 1135 struct ata_port *ap = dev->link->ap;
1136 1136
1137 /* set HIPM first, then DIPM */ 1137 /* set HIPM first, then DIPM */
1138 if (ap->ops->enable_pm) 1138 if (ap->ops->enable_pm)
1139 rc = ap->ops->enable_pm(ap, policy); 1139 rc = ap->ops->enable_pm(ap, policy);
1140 if (rc) 1140 if (rc)
1141 goto enable_pm_out; 1141 goto enable_pm_out;
1142 rc = ata_dev_set_dipm(dev, policy); 1142 rc = ata_dev_set_dipm(dev, policy);
1143 1143
1144 enable_pm_out: 1144 enable_pm_out:
1145 if (rc) 1145 if (rc)
1146 ap->pm_policy = MAX_PERFORMANCE; 1146 ap->pm_policy = MAX_PERFORMANCE;
1147 else 1147 else
1148 ap->pm_policy = policy; 1148 ap->pm_policy = policy;
1149 return /* rc */; /* hopefully we can use 'rc' eventually */ 1149 return /* rc */; /* hopefully we can use 'rc' eventually */
1150 } 1150 }
1151 1151
1152 #ifdef CONFIG_PM 1152 #ifdef CONFIG_PM
1153 /** 1153 /**
1154 * ata_dev_disable_pm - disable SATA interface power management 1154 * ata_dev_disable_pm - disable SATA interface power management
1155 * @dev: device to disable power management 1155 * @dev: device to disable power management
1156 * 1156 *
1157 * Disable SATA Interface power management. This will disable 1157 * Disable SATA Interface power management. This will disable
1158 * Device Interface Power Management (DIPM) without changing 1158 * Device Interface Power Management (DIPM) without changing
1159 * policy, call driver specific callbacks for disabling Host 1159 * policy, call driver specific callbacks for disabling Host
1160 * Initiated Power management. 1160 * Initiated Power management.
1161 * 1161 *
1162 * Locking: Caller. 1162 * Locking: Caller.
1163 * Returns: void 1163 * Returns: void
1164 */ 1164 */
1165 static void ata_dev_disable_pm(struct ata_device *dev) 1165 static void ata_dev_disable_pm(struct ata_device *dev)
1166 { 1166 {
1167 struct ata_port *ap = dev->link->ap; 1167 struct ata_port *ap = dev->link->ap;
1168 1168
1169 ata_dev_set_dipm(dev, MAX_PERFORMANCE); 1169 ata_dev_set_dipm(dev, MAX_PERFORMANCE);
1170 if (ap->ops->disable_pm) 1170 if (ap->ops->disable_pm)
1171 ap->ops->disable_pm(ap); 1171 ap->ops->disable_pm(ap);
1172 } 1172 }
1173 #endif /* CONFIG_PM */ 1173 #endif /* CONFIG_PM */
1174 1174
1175 void ata_lpm_schedule(struct ata_port *ap, enum link_pm policy) 1175 void ata_lpm_schedule(struct ata_port *ap, enum link_pm policy)
1176 { 1176 {
1177 ap->pm_policy = policy; 1177 ap->pm_policy = policy;
1178 ap->link.eh_info.action |= ATA_EH_LPM; 1178 ap->link.eh_info.action |= ATA_EH_LPM;
1179 ap->link.eh_info.flags |= ATA_EHI_NO_AUTOPSY; 1179 ap->link.eh_info.flags |= ATA_EHI_NO_AUTOPSY;
1180 ata_port_schedule_eh(ap); 1180 ata_port_schedule_eh(ap);
1181 } 1181 }
1182 1182
1183 #ifdef CONFIG_PM 1183 #ifdef CONFIG_PM
1184 static void ata_lpm_enable(struct ata_host *host) 1184 static void ata_lpm_enable(struct ata_host *host)
1185 { 1185 {
1186 struct ata_link *link; 1186 struct ata_link *link;
1187 struct ata_port *ap; 1187 struct ata_port *ap;
1188 struct ata_device *dev; 1188 struct ata_device *dev;
1189 int i; 1189 int i;
1190 1190
1191 for (i = 0; i < host->n_ports; i++) { 1191 for (i = 0; i < host->n_ports; i++) {
1192 ap = host->ports[i]; 1192 ap = host->ports[i];
1193 ata_for_each_link(link, ap, EDGE) { 1193 ata_for_each_link(link, ap, EDGE) {
1194 ata_for_each_dev(dev, link, ALL) 1194 ata_for_each_dev(dev, link, ALL)
1195 ata_dev_disable_pm(dev); 1195 ata_dev_disable_pm(dev);
1196 } 1196 }
1197 } 1197 }
1198 } 1198 }
1199 1199
1200 static void ata_lpm_disable(struct ata_host *host) 1200 static void ata_lpm_disable(struct ata_host *host)
1201 { 1201 {
1202 int i; 1202 int i;
1203 1203
1204 for (i = 0; i < host->n_ports; i++) { 1204 for (i = 0; i < host->n_ports; i++) {
1205 struct ata_port *ap = host->ports[i]; 1205 struct ata_port *ap = host->ports[i];
1206 ata_lpm_schedule(ap, ap->pm_policy); 1206 ata_lpm_schedule(ap, ap->pm_policy);
1207 } 1207 }
1208 } 1208 }
1209 #endif /* CONFIG_PM */ 1209 #endif /* CONFIG_PM */
1210 1210
1211 /** 1211 /**
1212 * ata_dev_classify - determine device type based on ATA-spec signature 1212 * ata_dev_classify - determine device type based on ATA-spec signature
1213 * @tf: ATA taskfile register set for device to be identified 1213 * @tf: ATA taskfile register set for device to be identified
1214 * 1214 *
1215 * Determine from taskfile register contents whether a device is 1215 * Determine from taskfile register contents whether a device is
1216 * ATA or ATAPI, as per "Signature and persistence" section 1216 * ATA or ATAPI, as per "Signature and persistence" section
1217 * of ATA/PI spec (volume 1, sect 5.14). 1217 * of ATA/PI spec (volume 1, sect 5.14).
1218 * 1218 *
1219 * LOCKING: 1219 * LOCKING:
1220 * None. 1220 * None.
1221 * 1221 *
1222 * RETURNS: 1222 * RETURNS:
1223 * Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP or 1223 * Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP or
1224 * %ATA_DEV_UNKNOWN the event of failure. 1224 * %ATA_DEV_UNKNOWN the event of failure.
1225 */ 1225 */
1226 unsigned int ata_dev_classify(const struct ata_taskfile *tf) 1226 unsigned int ata_dev_classify(const struct ata_taskfile *tf)
1227 { 1227 {
1228 /* Apple's open source Darwin code hints that some devices only 1228 /* Apple's open source Darwin code hints that some devices only
1229 * put a proper signature into the LBA mid/high registers, 1229 * put a proper signature into the LBA mid/high registers,
1230 * So, we only check those. It's sufficient for uniqueness. 1230 * So, we only check those. It's sufficient for uniqueness.
1231 * 1231 *
1232 * ATA/ATAPI-7 (d1532v1r1: Feb. 19, 2003) specified separate 1232 * ATA/ATAPI-7 (d1532v1r1: Feb. 19, 2003) specified separate
1233 * signatures for ATA and ATAPI devices attached on SerialATA, 1233 * signatures for ATA and ATAPI devices attached on SerialATA,
1234 * 0x3c/0xc3 and 0x69/0x96 respectively. However, SerialATA 1234 * 0x3c/0xc3 and 0x69/0x96 respectively. However, SerialATA
1235 * spec has never mentioned about using different signatures 1235 * spec has never mentioned about using different signatures
1236 * for ATA/ATAPI devices. Then, Serial ATA II: Port 1236 * for ATA/ATAPI devices. Then, Serial ATA II: Port
1237 * Multiplier specification began to use 0x69/0x96 to identify 1237 * Multiplier specification began to use 0x69/0x96 to identify
1238 * port multpliers and 0x3c/0xc3 to identify SEMB device. 1238 * port multpliers and 0x3c/0xc3 to identify SEMB device.
1239 * ATA/ATAPI-7 dropped descriptions about 0x3c/0xc3 and 1239 * ATA/ATAPI-7 dropped descriptions about 0x3c/0xc3 and
1240 * 0x69/0x96 shortly and described them as reserved for 1240 * 0x69/0x96 shortly and described them as reserved for
1241 * SerialATA. 1241 * SerialATA.
1242 * 1242 *
1243 * We follow the current spec and consider that 0x69/0x96 1243 * We follow the current spec and consider that 0x69/0x96
1244 * identifies a port multiplier and 0x3c/0xc3 a SEMB device. 1244 * identifies a port multiplier and 0x3c/0xc3 a SEMB device.
1245 * Unfortunately, WDC WD1600JS-62MHB5 (a hard drive) reports 1245 * Unfortunately, WDC WD1600JS-62MHB5 (a hard drive) reports
1246 * SEMB signature. This is worked around in 1246 * SEMB signature. This is worked around in
1247 * ata_dev_read_id(). 1247 * ata_dev_read_id().
1248 */ 1248 */
1249 if ((tf->lbam == 0) && (tf->lbah == 0)) { 1249 if ((tf->lbam == 0) && (tf->lbah == 0)) {
1250 DPRINTK("found ATA device by sig\n"); 1250 DPRINTK("found ATA device by sig\n");
1251 return ATA_DEV_ATA; 1251 return ATA_DEV_ATA;
1252 } 1252 }
1253 1253
1254 if ((tf->lbam == 0x14) && (tf->lbah == 0xeb)) { 1254 if ((tf->lbam == 0x14) && (tf->lbah == 0xeb)) {
1255 DPRINTK("found ATAPI device by sig\n"); 1255 DPRINTK("found ATAPI device by sig\n");
1256 return ATA_DEV_ATAPI; 1256 return ATA_DEV_ATAPI;
1257 } 1257 }
1258 1258
1259 if ((tf->lbam == 0x69) && (tf->lbah == 0x96)) { 1259 if ((tf->lbam == 0x69) && (tf->lbah == 0x96)) {
1260 DPRINTK("found PMP device by sig\n"); 1260 DPRINTK("found PMP device by sig\n");
1261 return ATA_DEV_PMP; 1261 return ATA_DEV_PMP;
1262 } 1262 }
1263 1263
1264 if ((tf->lbam == 0x3c) && (tf->lbah == 0xc3)) { 1264 if ((tf->lbam == 0x3c) && (tf->lbah == 0xc3)) {
1265 DPRINTK("found SEMB device by sig (could be ATA device)\n"); 1265 DPRINTK("found SEMB device by sig (could be ATA device)\n");
1266 return ATA_DEV_SEMB; 1266 return ATA_DEV_SEMB;
1267 } 1267 }
1268 1268
1269 DPRINTK("unknown device\n"); 1269 DPRINTK("unknown device\n");
1270 return ATA_DEV_UNKNOWN; 1270 return ATA_DEV_UNKNOWN;
1271 } 1271 }
1272 1272
1273 /** 1273 /**
1274 * ata_id_string - Convert IDENTIFY DEVICE page into string 1274 * ata_id_string - Convert IDENTIFY DEVICE page into string
1275 * @id: IDENTIFY DEVICE results we will examine 1275 * @id: IDENTIFY DEVICE results we will examine
1276 * @s: string into which data is output 1276 * @s: string into which data is output
1277 * @ofs: offset into identify device page 1277 * @ofs: offset into identify device page
1278 * @len: length of string to return. must be an even number. 1278 * @len: length of string to return. must be an even number.
1279 * 1279 *
1280 * The strings in the IDENTIFY DEVICE page are broken up into 1280 * The strings in the IDENTIFY DEVICE page are broken up into
1281 * 16-bit chunks. Run through the string, and output each 1281 * 16-bit chunks. Run through the string, and output each
1282 * 8-bit chunk linearly, regardless of platform. 1282 * 8-bit chunk linearly, regardless of platform.
1283 * 1283 *
1284 * LOCKING: 1284 * LOCKING:
1285 * caller. 1285 * caller.
1286 */ 1286 */
1287 1287
1288 void ata_id_string(const u16 *id, unsigned char *s, 1288 void ata_id_string(const u16 *id, unsigned char *s,
1289 unsigned int ofs, unsigned int len) 1289 unsigned int ofs, unsigned int len)
1290 { 1290 {
1291 unsigned int c; 1291 unsigned int c;
1292 1292
1293 BUG_ON(len & 1); 1293 BUG_ON(len & 1);
1294 1294
1295 while (len > 0) { 1295 while (len > 0) {
1296 c = id[ofs] >> 8; 1296 c = id[ofs] >> 8;
1297 *s = c; 1297 *s = c;
1298 s++; 1298 s++;
1299 1299
1300 c = id[ofs] & 0xff; 1300 c = id[ofs] & 0xff;
1301 *s = c; 1301 *s = c;
1302 s++; 1302 s++;
1303 1303
1304 ofs++; 1304 ofs++;
1305 len -= 2; 1305 len -= 2;
1306 } 1306 }
1307 } 1307 }
1308 1308
1309 /** 1309 /**
1310 * ata_id_c_string - Convert IDENTIFY DEVICE page into C string 1310 * ata_id_c_string - Convert IDENTIFY DEVICE page into C string
1311 * @id: IDENTIFY DEVICE results we will examine 1311 * @id: IDENTIFY DEVICE results we will examine
1312 * @s: string into which data is output 1312 * @s: string into which data is output
1313 * @ofs: offset into identify device page 1313 * @ofs: offset into identify device page
1314 * @len: length of string to return. must be an odd number. 1314 * @len: length of string to return. must be an odd number.
1315 * 1315 *
1316 * This function is identical to ata_id_string except that it 1316 * This function is identical to ata_id_string except that it
1317 * trims trailing spaces and terminates the resulting string with 1317 * trims trailing spaces and terminates the resulting string with
1318 * null. @len must be actual maximum length (even number) + 1. 1318 * null. @len must be actual maximum length (even number) + 1.
1319 * 1319 *
1320 * LOCKING: 1320 * LOCKING:
1321 * caller. 1321 * caller.
1322 */ 1322 */
1323 void ata_id_c_string(const u16 *id, unsigned char *s, 1323 void ata_id_c_string(const u16 *id, unsigned char *s,
1324 unsigned int ofs, unsigned int len) 1324 unsigned int ofs, unsigned int len)
1325 { 1325 {
1326 unsigned char *p; 1326 unsigned char *p;
1327 1327
1328 ata_id_string(id, s, ofs, len - 1); 1328 ata_id_string(id, s, ofs, len - 1);
1329 1329
1330 p = s + strnlen(s, len - 1); 1330 p = s + strnlen(s, len - 1);
1331 while (p > s && p[-1] == ' ') 1331 while (p > s && p[-1] == ' ')
1332 p--; 1332 p--;
1333 *p = '\0'; 1333 *p = '\0';
1334 } 1334 }
1335 1335
1336 static u64 ata_id_n_sectors(const u16 *id) 1336 static u64 ata_id_n_sectors(const u16 *id)
1337 { 1337 {
1338 if (ata_id_has_lba(id)) { 1338 if (ata_id_has_lba(id)) {
1339 if (ata_id_has_lba48(id)) 1339 if (ata_id_has_lba48(id))
1340 return ata_id_u64(id, ATA_ID_LBA_CAPACITY_2); 1340 return ata_id_u64(id, ATA_ID_LBA_CAPACITY_2);
1341 else 1341 else
1342 return ata_id_u32(id, ATA_ID_LBA_CAPACITY); 1342 return ata_id_u32(id, ATA_ID_LBA_CAPACITY);
1343 } else { 1343 } else {
1344 if (ata_id_current_chs_valid(id)) 1344 if (ata_id_current_chs_valid(id))
1345 return id[ATA_ID_CUR_CYLS] * id[ATA_ID_CUR_HEADS] * 1345 return id[ATA_ID_CUR_CYLS] * id[ATA_ID_CUR_HEADS] *
1346 id[ATA_ID_CUR_SECTORS]; 1346 id[ATA_ID_CUR_SECTORS];
1347 else 1347 else
1348 return id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * 1348 return id[ATA_ID_CYLS] * id[ATA_ID_HEADS] *
1349 id[ATA_ID_SECTORS]; 1349 id[ATA_ID_SECTORS];
1350 } 1350 }
1351 } 1351 }
1352 1352
1353 u64 ata_tf_to_lba48(const struct ata_taskfile *tf) 1353 u64 ata_tf_to_lba48(const struct ata_taskfile *tf)
1354 { 1354 {
1355 u64 sectors = 0; 1355 u64 sectors = 0;
1356 1356
1357 sectors |= ((u64)(tf->hob_lbah & 0xff)) << 40; 1357 sectors |= ((u64)(tf->hob_lbah & 0xff)) << 40;
1358 sectors |= ((u64)(tf->hob_lbam & 0xff)) << 32; 1358 sectors |= ((u64)(tf->hob_lbam & 0xff)) << 32;
1359 sectors |= ((u64)(tf->hob_lbal & 0xff)) << 24; 1359 sectors |= ((u64)(tf->hob_lbal & 0xff)) << 24;
1360 sectors |= (tf->lbah & 0xff) << 16; 1360 sectors |= (tf->lbah & 0xff) << 16;
1361 sectors |= (tf->lbam & 0xff) << 8; 1361 sectors |= (tf->lbam & 0xff) << 8;
1362 sectors |= (tf->lbal & 0xff); 1362 sectors |= (tf->lbal & 0xff);
1363 1363
1364 return sectors; 1364 return sectors;
1365 } 1365 }
1366 1366
1367 u64 ata_tf_to_lba(const struct ata_taskfile *tf) 1367 u64 ata_tf_to_lba(const struct ata_taskfile *tf)
1368 { 1368 {
1369 u64 sectors = 0; 1369 u64 sectors = 0;
1370 1370
1371 sectors |= (tf->device & 0x0f) << 24; 1371 sectors |= (tf->device & 0x0f) << 24;
1372 sectors |= (tf->lbah & 0xff) << 16; 1372 sectors |= (tf->lbah & 0xff) << 16;
1373 sectors |= (tf->lbam & 0xff) << 8; 1373 sectors |= (tf->lbam & 0xff) << 8;
1374 sectors |= (tf->lbal & 0xff); 1374 sectors |= (tf->lbal & 0xff);
1375 1375
1376 return sectors; 1376 return sectors;
1377 } 1377 }
1378 1378
1379 /** 1379 /**
1380 * ata_read_native_max_address - Read native max address 1380 * ata_read_native_max_address - Read native max address
1381 * @dev: target device 1381 * @dev: target device
1382 * @max_sectors: out parameter for the result native max address 1382 * @max_sectors: out parameter for the result native max address
1383 * 1383 *
1384 * Perform an LBA48 or LBA28 native size query upon the device in 1384 * Perform an LBA48 or LBA28 native size query upon the device in
1385 * question. 1385 * question.
1386 * 1386 *
1387 * RETURNS: 1387 * RETURNS:
1388 * 0 on success, -EACCES if command is aborted by the drive. 1388 * 0 on success, -EACCES if command is aborted by the drive.
1389 * -EIO on other errors. 1389 * -EIO on other errors.
1390 */ 1390 */
1391 static int ata_read_native_max_address(struct ata_device *dev, u64 *max_sectors) 1391 static int ata_read_native_max_address(struct ata_device *dev, u64 *max_sectors)
1392 { 1392 {
1393 unsigned int err_mask; 1393 unsigned int err_mask;
1394 struct ata_taskfile tf; 1394 struct ata_taskfile tf;
1395 int lba48 = ata_id_has_lba48(dev->id); 1395 int lba48 = ata_id_has_lba48(dev->id);
1396 1396
1397 ata_tf_init(dev, &tf); 1397 ata_tf_init(dev, &tf);
1398 1398
1399 /* always clear all address registers */ 1399 /* always clear all address registers */
1400 tf.flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR; 1400 tf.flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR;
1401 1401
1402 if (lba48) { 1402 if (lba48) {
1403 tf.command = ATA_CMD_READ_NATIVE_MAX_EXT; 1403 tf.command = ATA_CMD_READ_NATIVE_MAX_EXT;
1404 tf.flags |= ATA_TFLAG_LBA48; 1404 tf.flags |= ATA_TFLAG_LBA48;
1405 } else 1405 } else
1406 tf.command = ATA_CMD_READ_NATIVE_MAX; 1406 tf.command = ATA_CMD_READ_NATIVE_MAX;
1407 1407
1408 tf.protocol |= ATA_PROT_NODATA; 1408 tf.protocol |= ATA_PROT_NODATA;
1409 tf.device |= ATA_LBA; 1409 tf.device |= ATA_LBA;
1410 1410
1411 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); 1411 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
1412 if (err_mask) { 1412 if (err_mask) {
1413 ata_dev_printk(dev, KERN_WARNING, "failed to read native " 1413 ata_dev_printk(dev, KERN_WARNING, "failed to read native "
1414 "max address (err_mask=0x%x)\n", err_mask); 1414 "max address (err_mask=0x%x)\n", err_mask);
1415 if (err_mask == AC_ERR_DEV && (tf.feature & ATA_ABORTED)) 1415 if (err_mask == AC_ERR_DEV && (tf.feature & ATA_ABORTED))
1416 return -EACCES; 1416 return -EACCES;
1417 return -EIO; 1417 return -EIO;
1418 } 1418 }
1419 1419
1420 if (lba48) 1420 if (lba48)
1421 *max_sectors = ata_tf_to_lba48(&tf) + 1; 1421 *max_sectors = ata_tf_to_lba48(&tf) + 1;
1422 else 1422 else
1423 *max_sectors = ata_tf_to_lba(&tf) + 1; 1423 *max_sectors = ata_tf_to_lba(&tf) + 1;
1424 if (dev->horkage & ATA_HORKAGE_HPA_SIZE) 1424 if (dev->horkage & ATA_HORKAGE_HPA_SIZE)
1425 (*max_sectors)--; 1425 (*max_sectors)--;
1426 return 0; 1426 return 0;
1427 } 1427 }
1428 1428
1429 /** 1429 /**
1430 * ata_set_max_sectors - Set max sectors 1430 * ata_set_max_sectors - Set max sectors
1431 * @dev: target device 1431 * @dev: target device
1432 * @new_sectors: new max sectors value to set for the device 1432 * @new_sectors: new max sectors value to set for the device
1433 * 1433 *
1434 * Set max sectors of @dev to @new_sectors. 1434 * Set max sectors of @dev to @new_sectors.
1435 * 1435 *
1436 * RETURNS: 1436 * RETURNS:
1437 * 0 on success, -EACCES if command is aborted or denied (due to 1437 * 0 on success, -EACCES if command is aborted or denied (due to
1438 * previous non-volatile SET_MAX) by the drive. -EIO on other 1438 * previous non-volatile SET_MAX) by the drive. -EIO on other
1439 * errors. 1439 * errors.
1440 */ 1440 */
1441 static int ata_set_max_sectors(struct ata_device *dev, u64 new_sectors) 1441 static int ata_set_max_sectors(struct ata_device *dev, u64 new_sectors)
1442 { 1442 {
1443 unsigned int err_mask; 1443 unsigned int err_mask;
1444 struct ata_taskfile tf; 1444 struct ata_taskfile tf;
1445 int lba48 = ata_id_has_lba48(dev->id); 1445 int lba48 = ata_id_has_lba48(dev->id);
1446 1446
1447 new_sectors--; 1447 new_sectors--;
1448 1448
1449 ata_tf_init(dev, &tf); 1449 ata_tf_init(dev, &tf);
1450 1450
1451 tf.flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR; 1451 tf.flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR;
1452 1452
1453 if (lba48) { 1453 if (lba48) {
1454 tf.command = ATA_CMD_SET_MAX_EXT; 1454 tf.command = ATA_CMD_SET_MAX_EXT;
1455 tf.flags |= ATA_TFLAG_LBA48; 1455 tf.flags |= ATA_TFLAG_LBA48;
1456 1456
1457 tf.hob_lbal = (new_sectors >> 24) & 0xff; 1457 tf.hob_lbal = (new_sectors >> 24) & 0xff;
1458 tf.hob_lbam = (new_sectors >> 32) & 0xff; 1458 tf.hob_lbam = (new_sectors >> 32) & 0xff;
1459 tf.hob_lbah = (new_sectors >> 40) & 0xff; 1459 tf.hob_lbah = (new_sectors >> 40) & 0xff;
1460 } else { 1460 } else {
1461 tf.command = ATA_CMD_SET_MAX; 1461 tf.command = ATA_CMD_SET_MAX;
1462 1462
1463 tf.device |= (new_sectors >> 24) & 0xf; 1463 tf.device |= (new_sectors >> 24) & 0xf;
1464 } 1464 }
1465 1465
1466 tf.protocol |= ATA_PROT_NODATA; 1466 tf.protocol |= ATA_PROT_NODATA;
1467 tf.device |= ATA_LBA; 1467 tf.device |= ATA_LBA;
1468 1468
1469 tf.lbal = (new_sectors >> 0) & 0xff; 1469 tf.lbal = (new_sectors >> 0) & 0xff;
1470 tf.lbam = (new_sectors >> 8) & 0xff; 1470 tf.lbam = (new_sectors >> 8) & 0xff;
1471 tf.lbah = (new_sectors >> 16) & 0xff; 1471 tf.lbah = (new_sectors >> 16) & 0xff;
1472 1472
1473 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); 1473 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
1474 if (err_mask) { 1474 if (err_mask) {
1475 ata_dev_printk(dev, KERN_WARNING, "failed to set " 1475 ata_dev_printk(dev, KERN_WARNING, "failed to set "
1476 "max address (err_mask=0x%x)\n", err_mask); 1476 "max address (err_mask=0x%x)\n", err_mask);
1477 if (err_mask == AC_ERR_DEV && 1477 if (err_mask == AC_ERR_DEV &&
1478 (tf.feature & (ATA_ABORTED | ATA_IDNF))) 1478 (tf.feature & (ATA_ABORTED | ATA_IDNF)))
1479 return -EACCES; 1479 return -EACCES;
1480 return -EIO; 1480 return -EIO;
1481 } 1481 }
1482 1482
1483 return 0; 1483 return 0;
1484 } 1484 }
1485 1485
1486 /** 1486 /**
1487 * ata_hpa_resize - Resize a device with an HPA set 1487 * ata_hpa_resize - Resize a device with an HPA set
1488 * @dev: Device to resize 1488 * @dev: Device to resize
1489 * 1489 *
1490 * Read the size of an LBA28 or LBA48 disk with HPA features and resize 1490 * Read the size of an LBA28 or LBA48 disk with HPA features and resize
1491 * it if required to the full size of the media. The caller must check 1491 * it if required to the full size of the media. The caller must check
1492 * the drive has the HPA feature set enabled. 1492 * the drive has the HPA feature set enabled.
1493 * 1493 *
1494 * RETURNS: 1494 * RETURNS:
1495 * 0 on success, -errno on failure. 1495 * 0 on success, -errno on failure.
1496 */ 1496 */
1497 static int ata_hpa_resize(struct ata_device *dev) 1497 static int ata_hpa_resize(struct ata_device *dev)
1498 { 1498 {
1499 struct ata_eh_context *ehc = &dev->link->eh_context; 1499 struct ata_eh_context *ehc = &dev->link->eh_context;
1500 int print_info = ehc->i.flags & ATA_EHI_PRINTINFO; 1500 int print_info = ehc->i.flags & ATA_EHI_PRINTINFO;
1501 bool unlock_hpa = ata_ignore_hpa || dev->flags & ATA_DFLAG_UNLOCK_HPA; 1501 bool unlock_hpa = ata_ignore_hpa || dev->flags & ATA_DFLAG_UNLOCK_HPA;
1502 u64 sectors = ata_id_n_sectors(dev->id); 1502 u64 sectors = ata_id_n_sectors(dev->id);
1503 u64 native_sectors; 1503 u64 native_sectors;
1504 int rc; 1504 int rc;
1505 1505
1506 /* do we need to do it? */ 1506 /* do we need to do it? */
1507 if (dev->class != ATA_DEV_ATA || 1507 if (dev->class != ATA_DEV_ATA ||
1508 !ata_id_has_lba(dev->id) || !ata_id_hpa_enabled(dev->id) || 1508 !ata_id_has_lba(dev->id) || !ata_id_hpa_enabled(dev->id) ||
1509 (dev->horkage & ATA_HORKAGE_BROKEN_HPA)) 1509 (dev->horkage & ATA_HORKAGE_BROKEN_HPA))
1510 return 0; 1510 return 0;
1511 1511
1512 /* read native max address */ 1512 /* read native max address */
1513 rc = ata_read_native_max_address(dev, &native_sectors); 1513 rc = ata_read_native_max_address(dev, &native_sectors);
1514 if (rc) { 1514 if (rc) {
1515 /* If device aborted the command or HPA isn't going to 1515 /* If device aborted the command or HPA isn't going to
1516 * be unlocked, skip HPA resizing. 1516 * be unlocked, skip HPA resizing.
1517 */ 1517 */
1518 if (rc == -EACCES || !unlock_hpa) { 1518 if (rc == -EACCES || !unlock_hpa) {
1519 ata_dev_printk(dev, KERN_WARNING, "HPA support seems " 1519 ata_dev_printk(dev, KERN_WARNING, "HPA support seems "
1520 "broken, skipping HPA handling\n"); 1520 "broken, skipping HPA handling\n");
1521 dev->horkage |= ATA_HORKAGE_BROKEN_HPA; 1521 dev->horkage |= ATA_HORKAGE_BROKEN_HPA;
1522 1522
1523 /* we can continue if device aborted the command */ 1523 /* we can continue if device aborted the command */
1524 if (rc == -EACCES) 1524 if (rc == -EACCES)
1525 rc = 0; 1525 rc = 0;
1526 } 1526 }
1527 1527
1528 return rc; 1528 return rc;
1529 } 1529 }
1530 dev->n_native_sectors = native_sectors; 1530 dev->n_native_sectors = native_sectors;
1531 1531
1532 /* nothing to do? */ 1532 /* nothing to do? */
1533 if (native_sectors <= sectors || !unlock_hpa) { 1533 if (native_sectors <= sectors || !unlock_hpa) {
1534 if (!print_info || native_sectors == sectors) 1534 if (!print_info || native_sectors == sectors)
1535 return 0; 1535 return 0;
1536 1536
1537 if (native_sectors > sectors) 1537 if (native_sectors > sectors)
1538 ata_dev_printk(dev, KERN_INFO, 1538 ata_dev_printk(dev, KERN_INFO,
1539 "HPA detected: current %llu, native %llu\n", 1539 "HPA detected: current %llu, native %llu\n",
1540 (unsigned long long)sectors, 1540 (unsigned long long)sectors,
1541 (unsigned long long)native_sectors); 1541 (unsigned long long)native_sectors);
1542 else if (native_sectors < sectors) 1542 else if (native_sectors < sectors)
1543 ata_dev_printk(dev, KERN_WARNING, 1543 ata_dev_printk(dev, KERN_WARNING,
1544 "native sectors (%llu) is smaller than " 1544 "native sectors (%llu) is smaller than "
1545 "sectors (%llu)\n", 1545 "sectors (%llu)\n",
1546 (unsigned long long)native_sectors, 1546 (unsigned long long)native_sectors,
1547 (unsigned long long)sectors); 1547 (unsigned long long)sectors);
1548 return 0; 1548 return 0;
1549 } 1549 }
1550 1550
1551 /* let's unlock HPA */ 1551 /* let's unlock HPA */
1552 rc = ata_set_max_sectors(dev, native_sectors); 1552 rc = ata_set_max_sectors(dev, native_sectors);
1553 if (rc == -EACCES) { 1553 if (rc == -EACCES) {
1554 /* if device aborted the command, skip HPA resizing */ 1554 /* if device aborted the command, skip HPA resizing */
1555 ata_dev_printk(dev, KERN_WARNING, "device aborted resize " 1555 ata_dev_printk(dev, KERN_WARNING, "device aborted resize "
1556 "(%llu -> %llu), skipping HPA handling\n", 1556 "(%llu -> %llu), skipping HPA handling\n",
1557 (unsigned long long)sectors, 1557 (unsigned long long)sectors,
1558 (unsigned long long)native_sectors); 1558 (unsigned long long)native_sectors);
1559 dev->horkage |= ATA_HORKAGE_BROKEN_HPA; 1559 dev->horkage |= ATA_HORKAGE_BROKEN_HPA;
1560 return 0; 1560 return 0;
1561 } else if (rc) 1561 } else if (rc)
1562 return rc; 1562 return rc;
1563 1563
1564 /* re-read IDENTIFY data */ 1564 /* re-read IDENTIFY data */
1565 rc = ata_dev_reread_id(dev, 0); 1565 rc = ata_dev_reread_id(dev, 0);
1566 if (rc) { 1566 if (rc) {
1567 ata_dev_printk(dev, KERN_ERR, "failed to re-read IDENTIFY " 1567 ata_dev_printk(dev, KERN_ERR, "failed to re-read IDENTIFY "
1568 "data after HPA resizing\n"); 1568 "data after HPA resizing\n");
1569 return rc; 1569 return rc;
1570 } 1570 }
1571 1571
1572 if (print_info) { 1572 if (print_info) {
1573 u64 new_sectors = ata_id_n_sectors(dev->id); 1573 u64 new_sectors = ata_id_n_sectors(dev->id);
1574 ata_dev_printk(dev, KERN_INFO, 1574 ata_dev_printk(dev, KERN_INFO,
1575 "HPA unlocked: %llu -> %llu, native %llu\n", 1575 "HPA unlocked: %llu -> %llu, native %llu\n",
1576 (unsigned long long)sectors, 1576 (unsigned long long)sectors,
1577 (unsigned long long)new_sectors, 1577 (unsigned long long)new_sectors,
1578 (unsigned long long)native_sectors); 1578 (unsigned long long)native_sectors);
1579 } 1579 }
1580 1580
1581 return 0; 1581 return 0;
1582 } 1582 }
1583 1583
1584 /** 1584 /**
1585 * ata_dump_id - IDENTIFY DEVICE info debugging output 1585 * ata_dump_id - IDENTIFY DEVICE info debugging output
1586 * @id: IDENTIFY DEVICE page to dump 1586 * @id: IDENTIFY DEVICE page to dump
1587 * 1587 *
1588 * Dump selected 16-bit words from the given IDENTIFY DEVICE 1588 * Dump selected 16-bit words from the given IDENTIFY DEVICE
1589 * page. 1589 * page.
1590 * 1590 *
1591 * LOCKING: 1591 * LOCKING:
1592 * caller. 1592 * caller.
1593 */ 1593 */
1594 1594
1595 static inline void ata_dump_id(const u16 *id) 1595 static inline void ata_dump_id(const u16 *id)
1596 { 1596 {
1597 DPRINTK("49==0x%04x " 1597 DPRINTK("49==0x%04x "
1598 "53==0x%04x " 1598 "53==0x%04x "
1599 "63==0x%04x " 1599 "63==0x%04x "
1600 "64==0x%04x " 1600 "64==0x%04x "
1601 "75==0x%04x \n", 1601 "75==0x%04x \n",
1602 id[49], 1602 id[49],
1603 id[53], 1603 id[53],
1604 id[63], 1604 id[63],
1605 id[64], 1605 id[64],
1606 id[75]); 1606 id[75]);
1607 DPRINTK("80==0x%04x " 1607 DPRINTK("80==0x%04x "
1608 "81==0x%04x " 1608 "81==0x%04x "
1609 "82==0x%04x " 1609 "82==0x%04x "
1610 "83==0x%04x " 1610 "83==0x%04x "
1611 "84==0x%04x \n", 1611 "84==0x%04x \n",
1612 id[80], 1612 id[80],
1613 id[81], 1613 id[81],
1614 id[82], 1614 id[82],
1615 id[83], 1615 id[83],
1616 id[84]); 1616 id[84]);
1617 DPRINTK("88==0x%04x " 1617 DPRINTK("88==0x%04x "
1618 "93==0x%04x\n", 1618 "93==0x%04x\n",
1619 id[88], 1619 id[88],
1620 id[93]); 1620 id[93]);
1621 } 1621 }
1622 1622
1623 /** 1623 /**
1624 * ata_id_xfermask - Compute xfermask from the given IDENTIFY data 1624 * ata_id_xfermask - Compute xfermask from the given IDENTIFY data
1625 * @id: IDENTIFY data to compute xfer mask from 1625 * @id: IDENTIFY data to compute xfer mask from
1626 * 1626 *
1627 * Compute the xfermask for this device. This is not as trivial 1627 * Compute the xfermask for this device. This is not as trivial
1628 * as it seems if we must consider early devices correctly. 1628 * as it seems if we must consider early devices correctly.
1629 * 1629 *
1630 * FIXME: pre IDE drive timing (do we care ?). 1630 * FIXME: pre IDE drive timing (do we care ?).
1631 * 1631 *
1632 * LOCKING: 1632 * LOCKING:
1633 * None. 1633 * None.
1634 * 1634 *
1635 * RETURNS: 1635 * RETURNS:
1636 * Computed xfermask 1636 * Computed xfermask
1637 */ 1637 */
1638 unsigned long ata_id_xfermask(const u16 *id) 1638 unsigned long ata_id_xfermask(const u16 *id)
1639 { 1639 {
1640 unsigned long pio_mask, mwdma_mask, udma_mask; 1640 unsigned long pio_mask, mwdma_mask, udma_mask;
1641 1641
1642 /* Usual case. Word 53 indicates word 64 is valid */ 1642 /* Usual case. Word 53 indicates word 64 is valid */
1643 if (id[ATA_ID_FIELD_VALID] & (1 << 1)) { 1643 if (id[ATA_ID_FIELD_VALID] & (1 << 1)) {
1644 pio_mask = id[ATA_ID_PIO_MODES] & 0x03; 1644 pio_mask = id[ATA_ID_PIO_MODES] & 0x03;
1645 pio_mask <<= 3; 1645 pio_mask <<= 3;
1646 pio_mask |= 0x7; 1646 pio_mask |= 0x7;
1647 } else { 1647 } else {
1648 /* If word 64 isn't valid then Word 51 high byte holds 1648 /* If word 64 isn't valid then Word 51 high byte holds
1649 * the PIO timing number for the maximum. Turn it into 1649 * the PIO timing number for the maximum. Turn it into
1650 * a mask. 1650 * a mask.
1651 */ 1651 */
1652 u8 mode = (id[ATA_ID_OLD_PIO_MODES] >> 8) & 0xFF; 1652 u8 mode = (id[ATA_ID_OLD_PIO_MODES] >> 8) & 0xFF;
1653 if (mode < 5) /* Valid PIO range */ 1653 if (mode < 5) /* Valid PIO range */
1654 pio_mask = (2 << mode) - 1; 1654 pio_mask = (2 << mode) - 1;
1655 else 1655 else
1656 pio_mask = 1; 1656 pio_mask = 1;
1657 1657
1658 /* But wait.. there's more. Design your standards by 1658 /* But wait.. there's more. Design your standards by
1659 * committee and you too can get a free iordy field to 1659 * committee and you too can get a free iordy field to
1660 * process. However its the speeds not the modes that 1660 * process. However its the speeds not the modes that
1661 * are supported... Note drivers using the timing API 1661 * are supported... Note drivers using the timing API
1662 * will get this right anyway 1662 * will get this right anyway
1663 */ 1663 */
1664 } 1664 }
1665 1665
1666 mwdma_mask = id[ATA_ID_MWDMA_MODES] & 0x07; 1666 mwdma_mask = id[ATA_ID_MWDMA_MODES] & 0x07;
1667 1667
1668 if (ata_id_is_cfa(id)) { 1668 if (ata_id_is_cfa(id)) {
1669 /* 1669 /*
1670 * Process compact flash extended modes 1670 * Process compact flash extended modes
1671 */ 1671 */
1672 int pio = (id[ATA_ID_CFA_MODES] >> 0) & 0x7; 1672 int pio = (id[ATA_ID_CFA_MODES] >> 0) & 0x7;
1673 int dma = (id[ATA_ID_CFA_MODES] >> 3) & 0x7; 1673 int dma = (id[ATA_ID_CFA_MODES] >> 3) & 0x7;
1674 1674
1675 if (pio) 1675 if (pio)
1676 pio_mask |= (1 << 5); 1676 pio_mask |= (1 << 5);
1677 if (pio > 1) 1677 if (pio > 1)
1678 pio_mask |= (1 << 6); 1678 pio_mask |= (1 << 6);
1679 if (dma) 1679 if (dma)
1680 mwdma_mask |= (1 << 3); 1680 mwdma_mask |= (1 << 3);
1681 if (dma > 1) 1681 if (dma > 1)
1682 mwdma_mask |= (1 << 4); 1682 mwdma_mask |= (1 << 4);
1683 } 1683 }
1684 1684
1685 udma_mask = 0; 1685 udma_mask = 0;
1686 if (id[ATA_ID_FIELD_VALID] & (1 << 2)) 1686 if (id[ATA_ID_FIELD_VALID] & (1 << 2))
1687 udma_mask = id[ATA_ID_UDMA_MODES] & 0xff; 1687 udma_mask = id[ATA_ID_UDMA_MODES] & 0xff;
1688 1688
1689 return ata_pack_xfermask(pio_mask, mwdma_mask, udma_mask); 1689 return ata_pack_xfermask(pio_mask, mwdma_mask, udma_mask);
1690 } 1690 }
1691 1691
1692 static void ata_qc_complete_internal(struct ata_queued_cmd *qc) 1692 static void ata_qc_complete_internal(struct ata_queued_cmd *qc)
1693 { 1693 {
1694 struct completion *waiting = qc->private_data; 1694 struct completion *waiting = qc->private_data;
1695 1695
1696 complete(waiting); 1696 complete(waiting);
1697 } 1697 }
1698 1698
1699 /** 1699 /**
1700 * ata_exec_internal_sg - execute libata internal command 1700 * ata_exec_internal_sg - execute libata internal command
1701 * @dev: Device to which the command is sent 1701 * @dev: Device to which the command is sent
1702 * @tf: Taskfile registers for the command and the result 1702 * @tf: Taskfile registers for the command and the result
1703 * @cdb: CDB for packet command 1703 * @cdb: CDB for packet command
1704 * @dma_dir: Data tranfer direction of the command 1704 * @dma_dir: Data tranfer direction of the command
1705 * @sgl: sg list for the data buffer of the command 1705 * @sgl: sg list for the data buffer of the command
1706 * @n_elem: Number of sg entries 1706 * @n_elem: Number of sg entries
1707 * @timeout: Timeout in msecs (0 for default) 1707 * @timeout: Timeout in msecs (0 for default)
1708 * 1708 *
1709 * Executes libata internal command with timeout. @tf contains 1709 * Executes libata internal command with timeout. @tf contains
1710 * command on entry and result on return. Timeout and error 1710 * command on entry and result on return. Timeout and error
1711 * conditions are reported via return value. No recovery action 1711 * conditions are reported via return value. No recovery action
1712 * is taken after a command times out. It's caller's duty to 1712 * is taken after a command times out. It's caller's duty to
1713 * clean up after timeout. 1713 * clean up after timeout.
1714 * 1714 *
1715 * LOCKING: 1715 * LOCKING:
1716 * None. Should be called with kernel context, might sleep. 1716 * None. Should be called with kernel context, might sleep.
1717 * 1717 *
1718 * RETURNS: 1718 * RETURNS:
1719 * Zero on success, AC_ERR_* mask on failure 1719 * Zero on success, AC_ERR_* mask on failure
1720 */ 1720 */
1721 unsigned ata_exec_internal_sg(struct ata_device *dev, 1721 unsigned ata_exec_internal_sg(struct ata_device *dev,
1722 struct ata_taskfile *tf, const u8 *cdb, 1722 struct ata_taskfile *tf, const u8 *cdb,
1723 int dma_dir, struct scatterlist *sgl, 1723 int dma_dir, struct scatterlist *sgl,
1724 unsigned int n_elem, unsigned long timeout) 1724 unsigned int n_elem, unsigned long timeout)
1725 { 1725 {
1726 struct ata_link *link = dev->link; 1726 struct ata_link *link = dev->link;
1727 struct ata_port *ap = link->ap; 1727 struct ata_port *ap = link->ap;
1728 u8 command = tf->command; 1728 u8 command = tf->command;
1729 int auto_timeout = 0; 1729 int auto_timeout = 0;
1730 struct ata_queued_cmd *qc; 1730 struct ata_queued_cmd *qc;
1731 unsigned int tag, preempted_tag; 1731 unsigned int tag, preempted_tag;
1732 u32 preempted_sactive, preempted_qc_active; 1732 u32 preempted_sactive, preempted_qc_active;
1733 int preempted_nr_active_links; 1733 int preempted_nr_active_links;
1734 DECLARE_COMPLETION_ONSTACK(wait); 1734 DECLARE_COMPLETION_ONSTACK(wait);
1735 unsigned long flags; 1735 unsigned long flags;
1736 unsigned int err_mask; 1736 unsigned int err_mask;
1737 int rc; 1737 int rc;
1738 1738
1739 spin_lock_irqsave(ap->lock, flags); 1739 spin_lock_irqsave(ap->lock, flags);
1740 1740
1741 /* no internal command while frozen */ 1741 /* no internal command while frozen */
1742 if (ap->pflags & ATA_PFLAG_FROZEN) { 1742 if (ap->pflags & ATA_PFLAG_FROZEN) {
1743 spin_unlock_irqrestore(ap->lock, flags); 1743 spin_unlock_irqrestore(ap->lock, flags);
1744 return AC_ERR_SYSTEM; 1744 return AC_ERR_SYSTEM;
1745 } 1745 }
1746 1746
1747 /* initialize internal qc */ 1747 /* initialize internal qc */
1748 1748
1749 /* XXX: Tag 0 is used for drivers with legacy EH as some 1749 /* XXX: Tag 0 is used for drivers with legacy EH as some
1750 * drivers choke if any other tag is given. This breaks 1750 * drivers choke if any other tag is given. This breaks
1751 * ata_tag_internal() test for those drivers. Don't use new 1751 * ata_tag_internal() test for those drivers. Don't use new
1752 * EH stuff without converting to it. 1752 * EH stuff without converting to it.
1753 */ 1753 */
1754 if (ap->ops->error_handler) 1754 if (ap->ops->error_handler)
1755 tag = ATA_TAG_INTERNAL; 1755 tag = ATA_TAG_INTERNAL;
1756 else 1756 else
1757 tag = 0; 1757 tag = 0;
1758 1758
1759 if (test_and_set_bit(tag, &ap->qc_allocated)) 1759 if (test_and_set_bit(tag, &ap->qc_allocated))
1760 BUG(); 1760 BUG();
1761 qc = __ata_qc_from_tag(ap, tag); 1761 qc = __ata_qc_from_tag(ap, tag);
1762 1762
1763 qc->tag = tag; 1763 qc->tag = tag;
1764 qc->scsicmd = NULL; 1764 qc->scsicmd = NULL;
1765 qc->ap = ap; 1765 qc->ap = ap;
1766 qc->dev = dev; 1766 qc->dev = dev;
1767 ata_qc_reinit(qc); 1767 ata_qc_reinit(qc);
1768 1768
1769 preempted_tag = link->active_tag; 1769 preempted_tag = link->active_tag;
1770 preempted_sactive = link->sactive; 1770 preempted_sactive = link->sactive;
1771 preempted_qc_active = ap->qc_active; 1771 preempted_qc_active = ap->qc_active;
1772 preempted_nr_active_links = ap->nr_active_links; 1772 preempted_nr_active_links = ap->nr_active_links;
1773 link->active_tag = ATA_TAG_POISON; 1773 link->active_tag = ATA_TAG_POISON;
1774 link->sactive = 0; 1774 link->sactive = 0;
1775 ap->qc_active = 0; 1775 ap->qc_active = 0;
1776 ap->nr_active_links = 0; 1776 ap->nr_active_links = 0;
1777 1777
1778 /* prepare & issue qc */ 1778 /* prepare & issue qc */
1779 qc->tf = *tf; 1779 qc->tf = *tf;
1780 if (cdb) 1780 if (cdb)
1781 memcpy(qc->cdb, cdb, ATAPI_CDB_LEN); 1781 memcpy(qc->cdb, cdb, ATAPI_CDB_LEN);
1782 qc->flags |= ATA_QCFLAG_RESULT_TF; 1782 qc->flags |= ATA_QCFLAG_RESULT_TF;
1783 qc->dma_dir = dma_dir; 1783 qc->dma_dir = dma_dir;
1784 if (dma_dir != DMA_NONE) { 1784 if (dma_dir != DMA_NONE) {
1785 unsigned int i, buflen = 0; 1785 unsigned int i, buflen = 0;
1786 struct scatterlist *sg; 1786 struct scatterlist *sg;
1787 1787
1788 for_each_sg(sgl, sg, n_elem, i) 1788 for_each_sg(sgl, sg, n_elem, i)
1789 buflen += sg->length; 1789 buflen += sg->length;
1790 1790
1791 ata_sg_init(qc, sgl, n_elem); 1791 ata_sg_init(qc, sgl, n_elem);
1792 qc->nbytes = buflen; 1792 qc->nbytes = buflen;
1793 } 1793 }
1794 1794
1795 qc->private_data = &wait; 1795 qc->private_data = &wait;
1796 qc->complete_fn = ata_qc_complete_internal; 1796 qc->complete_fn = ata_qc_complete_internal;
1797 1797
1798 ata_qc_issue(qc); 1798 ata_qc_issue(qc);
1799 1799
1800 spin_unlock_irqrestore(ap->lock, flags); 1800 spin_unlock_irqrestore(ap->lock, flags);
1801 1801
1802 if (!timeout) { 1802 if (!timeout) {
1803 if (ata_probe_timeout) 1803 if (ata_probe_timeout)
1804 timeout = ata_probe_timeout * 1000; 1804 timeout = ata_probe_timeout * 1000;
1805 else { 1805 else {
1806 timeout = ata_internal_cmd_timeout(dev, command); 1806 timeout = ata_internal_cmd_timeout(dev, command);
1807 auto_timeout = 1; 1807 auto_timeout = 1;
1808 } 1808 }
1809 } 1809 }
1810 1810
1811 rc = wait_for_completion_timeout(&wait, msecs_to_jiffies(timeout)); 1811 rc = wait_for_completion_timeout(&wait, msecs_to_jiffies(timeout));
1812 1812
1813 ata_sff_flush_pio_task(ap); 1813 ata_sff_flush_pio_task(ap);
1814 1814
1815 if (!rc) { 1815 if (!rc) {
1816 spin_lock_irqsave(ap->lock, flags); 1816 spin_lock_irqsave(ap->lock, flags);
1817 1817
1818 /* We're racing with irq here. If we lose, the 1818 /* We're racing with irq here. If we lose, the
1819 * following test prevents us from completing the qc 1819 * following test prevents us from completing the qc
1820 * twice. If we win, the port is frozen and will be 1820 * twice. If we win, the port is frozen and will be
1821 * cleaned up by ->post_internal_cmd(). 1821 * cleaned up by ->post_internal_cmd().
1822 */ 1822 */
1823 if (qc->flags & ATA_QCFLAG_ACTIVE) { 1823 if (qc->flags & ATA_QCFLAG_ACTIVE) {
1824 qc->err_mask |= AC_ERR_TIMEOUT; 1824 qc->err_mask |= AC_ERR_TIMEOUT;
1825 1825
1826 if (ap->ops->error_handler) 1826 if (ap->ops->error_handler)
1827 ata_port_freeze(ap); 1827 ata_port_freeze(ap);
1828 else 1828 else
1829 ata_qc_complete(qc); 1829 ata_qc_complete(qc);
1830 1830
1831 if (ata_msg_warn(ap)) 1831 if (ata_msg_warn(ap))
1832 ata_dev_printk(dev, KERN_WARNING, 1832 ata_dev_printk(dev, KERN_WARNING,
1833 "qc timeout (cmd 0x%x)\n", command); 1833 "qc timeout (cmd 0x%x)\n", command);
1834 } 1834 }
1835 1835
1836 spin_unlock_irqrestore(ap->lock, flags); 1836 spin_unlock_irqrestore(ap->lock, flags);
1837 } 1837 }
1838 1838
1839 /* do post_internal_cmd */ 1839 /* do post_internal_cmd */
1840 if (ap->ops->post_internal_cmd) 1840 if (ap->ops->post_internal_cmd)
1841 ap->ops->post_internal_cmd(qc); 1841 ap->ops->post_internal_cmd(qc);
1842 1842
1843 /* perform minimal error analysis */ 1843 /* perform minimal error analysis */
1844 if (qc->flags & ATA_QCFLAG_FAILED) { 1844 if (qc->flags & ATA_QCFLAG_FAILED) {
1845 if (qc->result_tf.command & (ATA_ERR | ATA_DF)) 1845 if (qc->result_tf.command & (ATA_ERR | ATA_DF))
1846 qc->err_mask |= AC_ERR_DEV; 1846 qc->err_mask |= AC_ERR_DEV;
1847 1847
1848 if (!qc->err_mask) 1848 if (!qc->err_mask)
1849 qc->err_mask |= AC_ERR_OTHER; 1849 qc->err_mask |= AC_ERR_OTHER;
1850 1850
1851 if (qc->err_mask & ~AC_ERR_OTHER) 1851 if (qc->err_mask & ~AC_ERR_OTHER)
1852 qc->err_mask &= ~AC_ERR_OTHER; 1852 qc->err_mask &= ~AC_ERR_OTHER;
1853 } 1853 }
1854 1854
1855 /* finish up */ 1855 /* finish up */
1856 spin_lock_irqsave(ap->lock, flags); 1856 spin_lock_irqsave(ap->lock, flags);
1857 1857
1858 *tf = qc->result_tf; 1858 *tf = qc->result_tf;
1859 err_mask = qc->err_mask; 1859 err_mask = qc->err_mask;
1860 1860
1861 ata_qc_free(qc); 1861 ata_qc_free(qc);
1862 link->active_tag = preempted_tag; 1862 link->active_tag = preempted_tag;
1863 link->sactive = preempted_sactive; 1863 link->sactive = preempted_sactive;
1864 ap->qc_active = preempted_qc_active; 1864 ap->qc_active = preempted_qc_active;
1865 ap->nr_active_links = preempted_nr_active_links; 1865 ap->nr_active_links = preempted_nr_active_links;
1866 1866
1867 spin_unlock_irqrestore(ap->lock, flags); 1867 spin_unlock_irqrestore(ap->lock, flags);
1868 1868
1869 if ((err_mask & AC_ERR_TIMEOUT) && auto_timeout) 1869 if ((err_mask & AC_ERR_TIMEOUT) && auto_timeout)
1870 ata_internal_cmd_timed_out(dev, command); 1870 ata_internal_cmd_timed_out(dev, command);
1871 1871
1872 return err_mask; 1872 return err_mask;
1873 } 1873 }
1874 1874
1875 /** 1875 /**
1876 * ata_exec_internal - execute libata internal command 1876 * ata_exec_internal - execute libata internal command
1877 * @dev: Device to which the command is sent 1877 * @dev: Device to which the command is sent
1878 * @tf: Taskfile registers for the command and the result 1878 * @tf: Taskfile registers for the command and the result
1879 * @cdb: CDB for packet command 1879 * @cdb: CDB for packet command
1880 * @dma_dir: Data tranfer direction of the command 1880 * @dma_dir: Data tranfer direction of the command
1881 * @buf: Data buffer of the command 1881 * @buf: Data buffer of the command
1882 * @buflen: Length of data buffer 1882 * @buflen: Length of data buffer
1883 * @timeout: Timeout in msecs (0 for default) 1883 * @timeout: Timeout in msecs (0 for default)
1884 * 1884 *
1885 * Wrapper around ata_exec_internal_sg() which takes simple 1885 * Wrapper around ata_exec_internal_sg() which takes simple
1886 * buffer instead of sg list. 1886 * buffer instead of sg list.
1887 * 1887 *
1888 * LOCKING: 1888 * LOCKING:
1889 * None. Should be called with kernel context, might sleep. 1889 * None. Should be called with kernel context, might sleep.
1890 * 1890 *
1891 * RETURNS: 1891 * RETURNS:
1892 * Zero on success, AC_ERR_* mask on failure 1892 * Zero on success, AC_ERR_* mask on failure
1893 */ 1893 */
1894 unsigned ata_exec_internal(struct ata_device *dev, 1894 unsigned ata_exec_internal(struct ata_device *dev,
1895 struct ata_taskfile *tf, const u8 *cdb, 1895 struct ata_taskfile *tf, const u8 *cdb,
1896 int dma_dir, void *buf, unsigned int buflen, 1896 int dma_dir, void *buf, unsigned int buflen,
1897 unsigned long timeout) 1897 unsigned long timeout)
1898 { 1898 {
1899 struct scatterlist *psg = NULL, sg; 1899 struct scatterlist *psg = NULL, sg;
1900 unsigned int n_elem = 0; 1900 unsigned int n_elem = 0;
1901 1901
1902 if (dma_dir != DMA_NONE) { 1902 if (dma_dir != DMA_NONE) {
1903 WARN_ON(!buf); 1903 WARN_ON(!buf);
1904 sg_init_one(&sg, buf, buflen); 1904 sg_init_one(&sg, buf, buflen);
1905 psg = &sg; 1905 psg = &sg;
1906 n_elem++; 1906 n_elem++;
1907 } 1907 }
1908 1908
1909 return ata_exec_internal_sg(dev, tf, cdb, dma_dir, psg, n_elem, 1909 return ata_exec_internal_sg(dev, tf, cdb, dma_dir, psg, n_elem,
1910 timeout); 1910 timeout);
1911 } 1911 }
1912 1912
1913 /** 1913 /**
1914 * ata_do_simple_cmd - execute simple internal command 1914 * ata_do_simple_cmd - execute simple internal command
1915 * @dev: Device to which the command is sent 1915 * @dev: Device to which the command is sent
1916 * @cmd: Opcode to execute 1916 * @cmd: Opcode to execute
1917 * 1917 *
1918 * Execute a 'simple' command, that only consists of the opcode 1918 * Execute a 'simple' command, that only consists of the opcode
1919 * 'cmd' itself, without filling any other registers 1919 * 'cmd' itself, without filling any other registers
1920 * 1920 *
1921 * LOCKING: 1921 * LOCKING:
1922 * Kernel thread context (may sleep). 1922 * Kernel thread context (may sleep).
1923 * 1923 *
1924 * RETURNS: 1924 * RETURNS:
1925 * Zero on success, AC_ERR_* mask on failure 1925 * Zero on success, AC_ERR_* mask on failure
1926 */ 1926 */
1927 unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd) 1927 unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd)
1928 { 1928 {
1929 struct ata_taskfile tf; 1929 struct ata_taskfile tf;
1930 1930
1931 ata_tf_init(dev, &tf); 1931 ata_tf_init(dev, &tf);
1932 1932
1933 tf.command = cmd; 1933 tf.command = cmd;
1934 tf.flags |= ATA_TFLAG_DEVICE; 1934 tf.flags |= ATA_TFLAG_DEVICE;
1935 tf.protocol = ATA_PROT_NODATA; 1935 tf.protocol = ATA_PROT_NODATA;
1936 1936
1937 return ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); 1937 return ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
1938 } 1938 }
1939 1939
1940 /** 1940 /**
1941 * ata_pio_need_iordy - check if iordy needed 1941 * ata_pio_need_iordy - check if iordy needed
1942 * @adev: ATA device 1942 * @adev: ATA device
1943 * 1943 *
1944 * Check if the current speed of the device requires IORDY. Used 1944 * Check if the current speed of the device requires IORDY. Used
1945 * by various controllers for chip configuration. 1945 * by various controllers for chip configuration.
1946 */ 1946 */
1947 unsigned int ata_pio_need_iordy(const struct ata_device *adev) 1947 unsigned int ata_pio_need_iordy(const struct ata_device *adev)
1948 { 1948 {
1949 /* Don't set IORDY if we're preparing for reset. IORDY may 1949 /* Don't set IORDY if we're preparing for reset. IORDY may
1950 * lead to controller lock up on certain controllers if the 1950 * lead to controller lock up on certain controllers if the
1951 * port is not occupied. See bko#11703 for details. 1951 * port is not occupied. See bko#11703 for details.
1952 */ 1952 */
1953 if (adev->link->ap->pflags & ATA_PFLAG_RESETTING) 1953 if (adev->link->ap->pflags & ATA_PFLAG_RESETTING)
1954 return 0; 1954 return 0;
1955 /* Controller doesn't support IORDY. Probably a pointless 1955 /* Controller doesn't support IORDY. Probably a pointless
1956 * check as the caller should know this. 1956 * check as the caller should know this.
1957 */ 1957 */
1958 if (adev->link->ap->flags & ATA_FLAG_NO_IORDY) 1958 if (adev->link->ap->flags & ATA_FLAG_NO_IORDY)
1959 return 0; 1959 return 0;
1960 /* CF spec. r4.1 Table 22 says no iordy on PIO5 and PIO6. */ 1960 /* CF spec. r4.1 Table 22 says no iordy on PIO5 and PIO6. */
1961 if (ata_id_is_cfa(adev->id) 1961 if (ata_id_is_cfa(adev->id)
1962 && (adev->pio_mode == XFER_PIO_5 || adev->pio_mode == XFER_PIO_6)) 1962 && (adev->pio_mode == XFER_PIO_5 || adev->pio_mode == XFER_PIO_6))
1963 return 0; 1963 return 0;
1964 /* PIO3 and higher it is mandatory */ 1964 /* PIO3 and higher it is mandatory */
1965 if (adev->pio_mode > XFER_PIO_2) 1965 if (adev->pio_mode > XFER_PIO_2)
1966 return 1; 1966 return 1;
1967 /* We turn it on when possible */ 1967 /* We turn it on when possible */
1968 if (ata_id_has_iordy(adev->id)) 1968 if (ata_id_has_iordy(adev->id))
1969 return 1; 1969 return 1;
1970 return 0; 1970 return 0;
1971 } 1971 }
1972 1972
1973 /** 1973 /**
1974 * ata_pio_mask_no_iordy - Return the non IORDY mask 1974 * ata_pio_mask_no_iordy - Return the non IORDY mask
1975 * @adev: ATA device 1975 * @adev: ATA device
1976 * 1976 *
1977 * Compute the highest mode possible if we are not using iordy. Return 1977 * Compute the highest mode possible if we are not using iordy. Return
1978 * -1 if no iordy mode is available. 1978 * -1 if no iordy mode is available.
1979 */ 1979 */
1980 static u32 ata_pio_mask_no_iordy(const struct ata_device *adev) 1980 static u32 ata_pio_mask_no_iordy(const struct ata_device *adev)
1981 { 1981 {
1982 /* If we have no drive specific rule, then PIO 2 is non IORDY */ 1982 /* If we have no drive specific rule, then PIO 2 is non IORDY */
1983 if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE */ 1983 if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE */
1984 u16 pio = adev->id[ATA_ID_EIDE_PIO]; 1984 u16 pio = adev->id[ATA_ID_EIDE_PIO];
1985 /* Is the speed faster than the drive allows non IORDY ? */ 1985 /* Is the speed faster than the drive allows non IORDY ? */
1986 if (pio) { 1986 if (pio) {
1987 /* This is cycle times not frequency - watch the logic! */ 1987 /* This is cycle times not frequency - watch the logic! */
1988 if (pio > 240) /* PIO2 is 240nS per cycle */ 1988 if (pio > 240) /* PIO2 is 240nS per cycle */
1989 return 3 << ATA_SHIFT_PIO; 1989 return 3 << ATA_SHIFT_PIO;
1990 return 7 << ATA_SHIFT_PIO; 1990 return 7 << ATA_SHIFT_PIO;
1991 } 1991 }
1992 } 1992 }
1993 return 3 << ATA_SHIFT_PIO; 1993 return 3 << ATA_SHIFT_PIO;
1994 } 1994 }
1995 1995
1996 /** 1996 /**
1997 * ata_do_dev_read_id - default ID read method 1997 * ata_do_dev_read_id - default ID read method
1998 * @dev: device 1998 * @dev: device
1999 * @tf: proposed taskfile 1999 * @tf: proposed taskfile
2000 * @id: data buffer 2000 * @id: data buffer
2001 * 2001 *
2002 * Issue the identify taskfile and hand back the buffer containing 2002 * Issue the identify taskfile and hand back the buffer containing
2003 * identify data. For some RAID controllers and for pre ATA devices 2003 * identify data. For some RAID controllers and for pre ATA devices
2004 * this function is wrapped or replaced by the driver 2004 * this function is wrapped or replaced by the driver
2005 */ 2005 */
2006 unsigned int ata_do_dev_read_id(struct ata_device *dev, 2006 unsigned int ata_do_dev_read_id(struct ata_device *dev,
2007 struct ata_taskfile *tf, u16 *id) 2007 struct ata_taskfile *tf, u16 *id)
2008 { 2008 {
2009 return ata_exec_internal(dev, tf, NULL, DMA_FROM_DEVICE, 2009 return ata_exec_internal(dev, tf, NULL, DMA_FROM_DEVICE,
2010 id, sizeof(id[0]) * ATA_ID_WORDS, 0); 2010 id, sizeof(id[0]) * ATA_ID_WORDS, 0);
2011 } 2011 }
2012 2012
2013 /** 2013 /**
2014 * ata_dev_read_id - Read ID data from the specified device 2014 * ata_dev_read_id - Read ID data from the specified device
2015 * @dev: target device 2015 * @dev: target device
2016 * @p_class: pointer to class of the target device (may be changed) 2016 * @p_class: pointer to class of the target device (may be changed)
2017 * @flags: ATA_READID_* flags 2017 * @flags: ATA_READID_* flags
2018 * @id: buffer to read IDENTIFY data into 2018 * @id: buffer to read IDENTIFY data into
2019 * 2019 *
2020 * Read ID data from the specified device. ATA_CMD_ID_ATA is 2020 * Read ID data from the specified device. ATA_CMD_ID_ATA is
2021 * performed on ATA devices and ATA_CMD_ID_ATAPI on ATAPI 2021 * performed on ATA devices and ATA_CMD_ID_ATAPI on ATAPI
2022 * devices. This function also issues ATA_CMD_INIT_DEV_PARAMS 2022 * devices. This function also issues ATA_CMD_INIT_DEV_PARAMS
2023 * for pre-ATA4 drives. 2023 * for pre-ATA4 drives.
2024 * 2024 *
2025 * FIXME: ATA_CMD_ID_ATA is optional for early drives and right 2025 * FIXME: ATA_CMD_ID_ATA is optional for early drives and right
2026 * now we abort if we hit that case. 2026 * now we abort if we hit that case.
2027 * 2027 *
2028 * LOCKING: 2028 * LOCKING:
2029 * Kernel thread context (may sleep) 2029 * Kernel thread context (may sleep)
2030 * 2030 *
2031 * RETURNS: 2031 * RETURNS:
2032 * 0 on success, -errno otherwise. 2032 * 0 on success, -errno otherwise.
2033 */ 2033 */
2034 int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, 2034 int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
2035 unsigned int flags, u16 *id) 2035 unsigned int flags, u16 *id)
2036 { 2036 {
2037 struct ata_port *ap = dev->link->ap; 2037 struct ata_port *ap = dev->link->ap;
2038 unsigned int class = *p_class; 2038 unsigned int class = *p_class;
2039 struct ata_taskfile tf; 2039 struct ata_taskfile tf;
2040 unsigned int err_mask = 0; 2040 unsigned int err_mask = 0;
2041 const char *reason; 2041 const char *reason;
2042 bool is_semb = class == ATA_DEV_SEMB; 2042 bool is_semb = class == ATA_DEV_SEMB;
2043 int may_fallback = 1, tried_spinup = 0; 2043 int may_fallback = 1, tried_spinup = 0;
2044 int rc; 2044 int rc;
2045 2045
2046 if (ata_msg_ctl(ap)) 2046 if (ata_msg_ctl(ap))
2047 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __func__); 2047 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __func__);
2048 2048
2049 retry: 2049 retry:
2050 ata_tf_init(dev, &tf); 2050 ata_tf_init(dev, &tf);
2051 2051
2052 switch (class) { 2052 switch (class) {
2053 case ATA_DEV_SEMB: 2053 case ATA_DEV_SEMB:
2054 class = ATA_DEV_ATA; /* some hard drives report SEMB sig */ 2054 class = ATA_DEV_ATA; /* some hard drives report SEMB sig */
2055 case ATA_DEV_ATA: 2055 case ATA_DEV_ATA:
2056 tf.command = ATA_CMD_ID_ATA; 2056 tf.command = ATA_CMD_ID_ATA;
2057 break; 2057 break;
2058 case ATA_DEV_ATAPI: 2058 case ATA_DEV_ATAPI:
2059 tf.command = ATA_CMD_ID_ATAPI; 2059 tf.command = ATA_CMD_ID_ATAPI;
2060 break; 2060 break;
2061 default: 2061 default:
2062 rc = -ENODEV; 2062 rc = -ENODEV;
2063 reason = "unsupported class"; 2063 reason = "unsupported class";
2064 goto err_out; 2064 goto err_out;
2065 } 2065 }
2066 2066
2067 tf.protocol = ATA_PROT_PIO; 2067 tf.protocol = ATA_PROT_PIO;
2068 2068
2069 /* Some devices choke if TF registers contain garbage. Make 2069 /* Some devices choke if TF registers contain garbage. Make
2070 * sure those are properly initialized. 2070 * sure those are properly initialized.
2071 */ 2071 */
2072 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 2072 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
2073 2073
2074 /* Device presence detection is unreliable on some 2074 /* Device presence detection is unreliable on some
2075 * controllers. Always poll IDENTIFY if available. 2075 * controllers. Always poll IDENTIFY if available.
2076 */ 2076 */
2077 tf.flags |= ATA_TFLAG_POLLING; 2077 tf.flags |= ATA_TFLAG_POLLING;
2078 2078
2079 if (ap->ops->read_id) 2079 if (ap->ops->read_id)
2080 err_mask = ap->ops->read_id(dev, &tf, id); 2080 err_mask = ap->ops->read_id(dev, &tf, id);
2081 else 2081 else
2082 err_mask = ata_do_dev_read_id(dev, &tf, id); 2082 err_mask = ata_do_dev_read_id(dev, &tf, id);
2083 2083
2084 if (err_mask) { 2084 if (err_mask) {
2085 if (err_mask & AC_ERR_NODEV_HINT) { 2085 if (err_mask & AC_ERR_NODEV_HINT) {
2086 ata_dev_printk(dev, KERN_DEBUG, 2086 ata_dev_printk(dev, KERN_DEBUG,
2087 "NODEV after polling detection\n"); 2087 "NODEV after polling detection\n");
2088 return -ENOENT; 2088 return -ENOENT;
2089 } 2089 }
2090 2090
2091 if (is_semb) { 2091 if (is_semb) {
2092 ata_dev_printk(dev, KERN_INFO, "IDENTIFY failed on " 2092 ata_dev_printk(dev, KERN_INFO, "IDENTIFY failed on "
2093 "device w/ SEMB sig, disabled\n"); 2093 "device w/ SEMB sig, disabled\n");
2094 /* SEMB is not supported yet */ 2094 /* SEMB is not supported yet */
2095 *p_class = ATA_DEV_SEMB_UNSUP; 2095 *p_class = ATA_DEV_SEMB_UNSUP;
2096 return 0; 2096 return 0;
2097 } 2097 }
2098 2098
2099 if ((err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) { 2099 if ((err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) {
2100 /* Device or controller might have reported 2100 /* Device or controller might have reported
2101 * the wrong device class. Give a shot at the 2101 * the wrong device class. Give a shot at the
2102 * other IDENTIFY if the current one is 2102 * other IDENTIFY if the current one is
2103 * aborted by the device. 2103 * aborted by the device.
2104 */ 2104 */
2105 if (may_fallback) { 2105 if (may_fallback) {
2106 may_fallback = 0; 2106 may_fallback = 0;
2107 2107
2108 if (class == ATA_DEV_ATA) 2108 if (class == ATA_DEV_ATA)
2109 class = ATA_DEV_ATAPI; 2109 class = ATA_DEV_ATAPI;
2110 else 2110 else
2111 class = ATA_DEV_ATA; 2111 class = ATA_DEV_ATA;
2112 goto retry; 2112 goto retry;
2113 } 2113 }
2114 2114
2115 /* Control reaches here iff the device aborted 2115 /* Control reaches here iff the device aborted
2116 * both flavors of IDENTIFYs which happens 2116 * both flavors of IDENTIFYs which happens
2117 * sometimes with phantom devices. 2117 * sometimes with phantom devices.
2118 */ 2118 */
2119 ata_dev_printk(dev, KERN_DEBUG, 2119 ata_dev_printk(dev, KERN_DEBUG,
2120 "both IDENTIFYs aborted, assuming NODEV\n"); 2120 "both IDENTIFYs aborted, assuming NODEV\n");
2121 return -ENOENT; 2121 return -ENOENT;
2122 } 2122 }
2123 2123
2124 rc = -EIO; 2124 rc = -EIO;
2125 reason = "I/O error"; 2125 reason = "I/O error";
2126 goto err_out; 2126 goto err_out;
2127 } 2127 }
2128 2128
2129 if (dev->horkage & ATA_HORKAGE_DUMP_ID) {
2130 ata_dev_printk(dev, KERN_DEBUG, "dumping IDENTIFY data, "
2131 "class=%d may_fallback=%d tried_spinup=%d\n",
2132 class, may_fallback, tried_spinup);
2133 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET,
2134 16, 2, id, ATA_ID_WORDS * sizeof(*id), true);
2135 }
2136
2129 /* Falling back doesn't make sense if ID data was read 2137 /* Falling back doesn't make sense if ID data was read
2130 * successfully at least once. 2138 * successfully at least once.
2131 */ 2139 */
2132 may_fallback = 0; 2140 may_fallback = 0;
2133 2141
2134 swap_buf_le16(id, ATA_ID_WORDS); 2142 swap_buf_le16(id, ATA_ID_WORDS);
2135 2143
2136 /* sanity check */ 2144 /* sanity check */
2137 rc = -EINVAL; 2145 rc = -EINVAL;
2138 reason = "device reports invalid type"; 2146 reason = "device reports invalid type";
2139 2147
2140 if (class == ATA_DEV_ATA) { 2148 if (class == ATA_DEV_ATA) {
2141 if (!ata_id_is_ata(id) && !ata_id_is_cfa(id)) 2149 if (!ata_id_is_ata(id) && !ata_id_is_cfa(id))
2142 goto err_out; 2150 goto err_out;
2143 } else { 2151 } else {
2144 if (ata_id_is_ata(id)) 2152 if (ata_id_is_ata(id))
2145 goto err_out; 2153 goto err_out;
2146 } 2154 }
2147 2155
2148 if (!tried_spinup && (id[2] == 0x37c8 || id[2] == 0x738c)) { 2156 if (!tried_spinup && (id[2] == 0x37c8 || id[2] == 0x738c)) {
2149 tried_spinup = 1; 2157 tried_spinup = 1;
2150 /* 2158 /*
2151 * Drive powered-up in standby mode, and requires a specific 2159 * Drive powered-up in standby mode, and requires a specific
2152 * SET_FEATURES spin-up subcommand before it will accept 2160 * SET_FEATURES spin-up subcommand before it will accept
2153 * anything other than the original IDENTIFY command. 2161 * anything other than the original IDENTIFY command.
2154 */ 2162 */
2155 err_mask = ata_dev_set_feature(dev, SETFEATURES_SPINUP, 0); 2163 err_mask = ata_dev_set_feature(dev, SETFEATURES_SPINUP, 0);
2156 if (err_mask && id[2] != 0x738c) { 2164 if (err_mask && id[2] != 0x738c) {
2157 rc = -EIO; 2165 rc = -EIO;
2158 reason = "SPINUP failed"; 2166 reason = "SPINUP failed";
2159 goto err_out; 2167 goto err_out;
2160 } 2168 }
2161 /* 2169 /*
2162 * If the drive initially returned incomplete IDENTIFY info, 2170 * If the drive initially returned incomplete IDENTIFY info,
2163 * we now must reissue the IDENTIFY command. 2171 * we now must reissue the IDENTIFY command.
2164 */ 2172 */
2165 if (id[2] == 0x37c8) 2173 if (id[2] == 0x37c8)
2166 goto retry; 2174 goto retry;
2167 } 2175 }
2168 2176
2169 if ((flags & ATA_READID_POSTRESET) && class == ATA_DEV_ATA) { 2177 if ((flags & ATA_READID_POSTRESET) && class == ATA_DEV_ATA) {
2170 /* 2178 /*
2171 * The exact sequence expected by certain pre-ATA4 drives is: 2179 * The exact sequence expected by certain pre-ATA4 drives is:
2172 * SRST RESET 2180 * SRST RESET
2173 * IDENTIFY (optional in early ATA) 2181 * IDENTIFY (optional in early ATA)
2174 * INITIALIZE DEVICE PARAMETERS (later IDE and ATA) 2182 * INITIALIZE DEVICE PARAMETERS (later IDE and ATA)
2175 * anything else.. 2183 * anything else..
2176 * Some drives were very specific about that exact sequence. 2184 * Some drives were very specific about that exact sequence.
2177 * 2185 *
2178 * Note that ATA4 says lba is mandatory so the second check 2186 * Note that ATA4 says lba is mandatory so the second check
2179 * should never trigger. 2187 * should never trigger.
2180 */ 2188 */
2181 if (ata_id_major_version(id) < 4 || !ata_id_has_lba(id)) { 2189 if (ata_id_major_version(id) < 4 || !ata_id_has_lba(id)) {
2182 err_mask = ata_dev_init_params(dev, id[3], id[6]); 2190 err_mask = ata_dev_init_params(dev, id[3], id[6]);
2183 if (err_mask) { 2191 if (err_mask) {
2184 rc = -EIO; 2192 rc = -EIO;
2185 reason = "INIT_DEV_PARAMS failed"; 2193 reason = "INIT_DEV_PARAMS failed";
2186 goto err_out; 2194 goto err_out;
2187 } 2195 }
2188 2196
2189 /* current CHS translation info (id[53-58]) might be 2197 /* current CHS translation info (id[53-58]) might be
2190 * changed. reread the identify device info. 2198 * changed. reread the identify device info.
2191 */ 2199 */
2192 flags &= ~ATA_READID_POSTRESET; 2200 flags &= ~ATA_READID_POSTRESET;
2193 goto retry; 2201 goto retry;
2194 } 2202 }
2195 } 2203 }
2196 2204
2197 *p_class = class; 2205 *p_class = class;
2198 2206
2199 return 0; 2207 return 0;
2200 2208
2201 err_out: 2209 err_out:
2202 if (ata_msg_warn(ap)) 2210 if (ata_msg_warn(ap))
2203 ata_dev_printk(dev, KERN_WARNING, "failed to IDENTIFY " 2211 ata_dev_printk(dev, KERN_WARNING, "failed to IDENTIFY "
2204 "(%s, err_mask=0x%x)\n", reason, err_mask); 2212 "(%s, err_mask=0x%x)\n", reason, err_mask);
2205 return rc; 2213 return rc;
2206 } 2214 }
2207 2215
2208 static int ata_do_link_spd_horkage(struct ata_device *dev) 2216 static int ata_do_link_spd_horkage(struct ata_device *dev)
2209 { 2217 {
2210 struct ata_link *plink = ata_dev_phys_link(dev); 2218 struct ata_link *plink = ata_dev_phys_link(dev);
2211 u32 target, target_limit; 2219 u32 target, target_limit;
2212 2220
2213 if (!sata_scr_valid(plink)) 2221 if (!sata_scr_valid(plink))
2214 return 0; 2222 return 0;
2215 2223
2216 if (dev->horkage & ATA_HORKAGE_1_5_GBPS) 2224 if (dev->horkage & ATA_HORKAGE_1_5_GBPS)
2217 target = 1; 2225 target = 1;
2218 else 2226 else
2219 return 0; 2227 return 0;
2220 2228
2221 target_limit = (1 << target) - 1; 2229 target_limit = (1 << target) - 1;
2222 2230
2223 /* if already on stricter limit, no need to push further */ 2231 /* if already on stricter limit, no need to push further */
2224 if (plink->sata_spd_limit <= target_limit) 2232 if (plink->sata_spd_limit <= target_limit)
2225 return 0; 2233 return 0;
2226 2234
2227 plink->sata_spd_limit = target_limit; 2235 plink->sata_spd_limit = target_limit;
2228 2236
2229 /* Request another EH round by returning -EAGAIN if link is 2237 /* Request another EH round by returning -EAGAIN if link is
2230 * going faster than the target speed. Forward progress is 2238 * going faster than the target speed. Forward progress is
2231 * guaranteed by setting sata_spd_limit to target_limit above. 2239 * guaranteed by setting sata_spd_limit to target_limit above.
2232 */ 2240 */
2233 if (plink->sata_spd > target) { 2241 if (plink->sata_spd > target) {
2234 ata_dev_printk(dev, KERN_INFO, 2242 ata_dev_printk(dev, KERN_INFO,
2235 "applying link speed limit horkage to %s\n", 2243 "applying link speed limit horkage to %s\n",
2236 sata_spd_string(target)); 2244 sata_spd_string(target));
2237 return -EAGAIN; 2245 return -EAGAIN;
2238 } 2246 }
2239 return 0; 2247 return 0;
2240 } 2248 }
2241 2249
2242 static inline u8 ata_dev_knobble(struct ata_device *dev) 2250 static inline u8 ata_dev_knobble(struct ata_device *dev)
2243 { 2251 {
2244 struct ata_port *ap = dev->link->ap; 2252 struct ata_port *ap = dev->link->ap;
2245 2253
2246 if (ata_dev_blacklisted(dev) & ATA_HORKAGE_BRIDGE_OK) 2254 if (ata_dev_blacklisted(dev) & ATA_HORKAGE_BRIDGE_OK)
2247 return 0; 2255 return 0;
2248 2256
2249 return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(dev->id))); 2257 return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(dev->id)));
2250 } 2258 }
2251 2259
2252 static int ata_dev_config_ncq(struct ata_device *dev, 2260 static int ata_dev_config_ncq(struct ata_device *dev,
2253 char *desc, size_t desc_sz) 2261 char *desc, size_t desc_sz)
2254 { 2262 {
2255 struct ata_port *ap = dev->link->ap; 2263 struct ata_port *ap = dev->link->ap;
2256 int hdepth = 0, ddepth = ata_id_queue_depth(dev->id); 2264 int hdepth = 0, ddepth = ata_id_queue_depth(dev->id);
2257 unsigned int err_mask; 2265 unsigned int err_mask;
2258 char *aa_desc = ""; 2266 char *aa_desc = "";
2259 2267
2260 if (!ata_id_has_ncq(dev->id)) { 2268 if (!ata_id_has_ncq(dev->id)) {
2261 desc[0] = '\0'; 2269 desc[0] = '\0';
2262 return 0; 2270 return 0;
2263 } 2271 }
2264 if (dev->horkage & ATA_HORKAGE_NONCQ) { 2272 if (dev->horkage & ATA_HORKAGE_NONCQ) {
2265 snprintf(desc, desc_sz, "NCQ (not used)"); 2273 snprintf(desc, desc_sz, "NCQ (not used)");
2266 return 0; 2274 return 0;
2267 } 2275 }
2268 if (ap->flags & ATA_FLAG_NCQ) { 2276 if (ap->flags & ATA_FLAG_NCQ) {
2269 hdepth = min(ap->scsi_host->can_queue, ATA_MAX_QUEUE - 1); 2277 hdepth = min(ap->scsi_host->can_queue, ATA_MAX_QUEUE - 1);
2270 dev->flags |= ATA_DFLAG_NCQ; 2278 dev->flags |= ATA_DFLAG_NCQ;
2271 } 2279 }
2272 2280
2273 if (!(dev->horkage & ATA_HORKAGE_BROKEN_FPDMA_AA) && 2281 if (!(dev->horkage & ATA_HORKAGE_BROKEN_FPDMA_AA) &&
2274 (ap->flags & ATA_FLAG_FPDMA_AA) && 2282 (ap->flags & ATA_FLAG_FPDMA_AA) &&
2275 ata_id_has_fpdma_aa(dev->id)) { 2283 ata_id_has_fpdma_aa(dev->id)) {
2276 err_mask = ata_dev_set_feature(dev, SETFEATURES_SATA_ENABLE, 2284 err_mask = ata_dev_set_feature(dev, SETFEATURES_SATA_ENABLE,
2277 SATA_FPDMA_AA); 2285 SATA_FPDMA_AA);
2278 if (err_mask) { 2286 if (err_mask) {
2279 ata_dev_printk(dev, KERN_ERR, "failed to enable AA" 2287 ata_dev_printk(dev, KERN_ERR, "failed to enable AA"
2280 "(error_mask=0x%x)\n", err_mask); 2288 "(error_mask=0x%x)\n", err_mask);
2281 if (err_mask != AC_ERR_DEV) { 2289 if (err_mask != AC_ERR_DEV) {
2282 dev->horkage |= ATA_HORKAGE_BROKEN_FPDMA_AA; 2290 dev->horkage |= ATA_HORKAGE_BROKEN_FPDMA_AA;
2283 return -EIO; 2291 return -EIO;
2284 } 2292 }
2285 } else 2293 } else
2286 aa_desc = ", AA"; 2294 aa_desc = ", AA";
2287 } 2295 }
2288 2296
2289 if (hdepth >= ddepth) 2297 if (hdepth >= ddepth)
2290 snprintf(desc, desc_sz, "NCQ (depth %d)%s", ddepth, aa_desc); 2298 snprintf(desc, desc_sz, "NCQ (depth %d)%s", ddepth, aa_desc);
2291 else 2299 else
2292 snprintf(desc, desc_sz, "NCQ (depth %d/%d)%s", hdepth, 2300 snprintf(desc, desc_sz, "NCQ (depth %d/%d)%s", hdepth,
2293 ddepth, aa_desc); 2301 ddepth, aa_desc);
2294 return 0; 2302 return 0;
2295 } 2303 }
2296 2304
2297 /** 2305 /**
2298 * ata_dev_configure - Configure the specified ATA/ATAPI device 2306 * ata_dev_configure - Configure the specified ATA/ATAPI device
2299 * @dev: Target device to configure 2307 * @dev: Target device to configure
2300 * 2308 *
2301 * Configure @dev according to @dev->id. Generic and low-level 2309 * Configure @dev according to @dev->id. Generic and low-level
2302 * driver specific fixups are also applied. 2310 * driver specific fixups are also applied.
2303 * 2311 *
2304 * LOCKING: 2312 * LOCKING:
2305 * Kernel thread context (may sleep) 2313 * Kernel thread context (may sleep)
2306 * 2314 *
2307 * RETURNS: 2315 * RETURNS:
2308 * 0 on success, -errno otherwise 2316 * 0 on success, -errno otherwise
2309 */ 2317 */
2310 int ata_dev_configure(struct ata_device *dev) 2318 int ata_dev_configure(struct ata_device *dev)
2311 { 2319 {
2312 struct ata_port *ap = dev->link->ap; 2320 struct ata_port *ap = dev->link->ap;
2313 struct ata_eh_context *ehc = &dev->link->eh_context; 2321 struct ata_eh_context *ehc = &dev->link->eh_context;
2314 int print_info = ehc->i.flags & ATA_EHI_PRINTINFO; 2322 int print_info = ehc->i.flags & ATA_EHI_PRINTINFO;
2315 const u16 *id = dev->id; 2323 const u16 *id = dev->id;
2316 unsigned long xfer_mask; 2324 unsigned long xfer_mask;
2317 char revbuf[7]; /* XYZ-99\0 */ 2325 char revbuf[7]; /* XYZ-99\0 */
2318 char fwrevbuf[ATA_ID_FW_REV_LEN+1]; 2326 char fwrevbuf[ATA_ID_FW_REV_LEN+1];
2319 char modelbuf[ATA_ID_PROD_LEN+1]; 2327 char modelbuf[ATA_ID_PROD_LEN+1];
2320 int rc; 2328 int rc;
2321 2329
2322 if (!ata_dev_enabled(dev) && ata_msg_info(ap)) { 2330 if (!ata_dev_enabled(dev) && ata_msg_info(ap)) {
2323 ata_dev_printk(dev, KERN_INFO, "%s: ENTER/EXIT -- nodev\n", 2331 ata_dev_printk(dev, KERN_INFO, "%s: ENTER/EXIT -- nodev\n",
2324 __func__); 2332 __func__);
2325 return 0; 2333 return 0;
2326 } 2334 }
2327 2335
2328 if (ata_msg_probe(ap)) 2336 if (ata_msg_probe(ap))
2329 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __func__); 2337 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __func__);
2330 2338
2331 /* set horkage */ 2339 /* set horkage */
2332 dev->horkage |= ata_dev_blacklisted(dev); 2340 dev->horkage |= ata_dev_blacklisted(dev);
2333 ata_force_horkage(dev); 2341 ata_force_horkage(dev);
2334 2342
2335 if (dev->horkage & ATA_HORKAGE_DISABLE) { 2343 if (dev->horkage & ATA_HORKAGE_DISABLE) {
2336 ata_dev_printk(dev, KERN_INFO, 2344 ata_dev_printk(dev, KERN_INFO,
2337 "unsupported device, disabling\n"); 2345 "unsupported device, disabling\n");
2338 ata_dev_disable(dev); 2346 ata_dev_disable(dev);
2339 return 0; 2347 return 0;
2340 } 2348 }
2341 2349
2342 if ((!atapi_enabled || (ap->flags & ATA_FLAG_NO_ATAPI)) && 2350 if ((!atapi_enabled || (ap->flags & ATA_FLAG_NO_ATAPI)) &&
2343 dev->class == ATA_DEV_ATAPI) { 2351 dev->class == ATA_DEV_ATAPI) {
2344 ata_dev_printk(dev, KERN_WARNING, 2352 ata_dev_printk(dev, KERN_WARNING,
2345 "WARNING: ATAPI is %s, device ignored.\n", 2353 "WARNING: ATAPI is %s, device ignored.\n",
2346 atapi_enabled ? "not supported with this driver" 2354 atapi_enabled ? "not supported with this driver"
2347 : "disabled"); 2355 : "disabled");
2348 ata_dev_disable(dev); 2356 ata_dev_disable(dev);
2349 return 0; 2357 return 0;
2350 } 2358 }
2351 2359
2352 rc = ata_do_link_spd_horkage(dev); 2360 rc = ata_do_link_spd_horkage(dev);
2353 if (rc) 2361 if (rc)
2354 return rc; 2362 return rc;
2355 2363
2356 /* let ACPI work its magic */ 2364 /* let ACPI work its magic */
2357 rc = ata_acpi_on_devcfg(dev); 2365 rc = ata_acpi_on_devcfg(dev);
2358 if (rc) 2366 if (rc)
2359 return rc; 2367 return rc;
2360 2368
2361 /* massage HPA, do it early as it might change IDENTIFY data */ 2369 /* massage HPA, do it early as it might change IDENTIFY data */
2362 rc = ata_hpa_resize(dev); 2370 rc = ata_hpa_resize(dev);
2363 if (rc) 2371 if (rc)
2364 return rc; 2372 return rc;
2365 2373
2366 /* print device capabilities */ 2374 /* print device capabilities */
2367 if (ata_msg_probe(ap)) 2375 if (ata_msg_probe(ap))
2368 ata_dev_printk(dev, KERN_DEBUG, 2376 ata_dev_printk(dev, KERN_DEBUG,
2369 "%s: cfg 49:%04x 82:%04x 83:%04x 84:%04x " 2377 "%s: cfg 49:%04x 82:%04x 83:%04x 84:%04x "
2370 "85:%04x 86:%04x 87:%04x 88:%04x\n", 2378 "85:%04x 86:%04x 87:%04x 88:%04x\n",
2371 __func__, 2379 __func__,
2372 id[49], id[82], id[83], id[84], 2380 id[49], id[82], id[83], id[84],
2373 id[85], id[86], id[87], id[88]); 2381 id[85], id[86], id[87], id[88]);
2374 2382
2375 /* initialize to-be-configured parameters */ 2383 /* initialize to-be-configured parameters */
2376 dev->flags &= ~ATA_DFLAG_CFG_MASK; 2384 dev->flags &= ~ATA_DFLAG_CFG_MASK;
2377 dev->max_sectors = 0; 2385 dev->max_sectors = 0;
2378 dev->cdb_len = 0; 2386 dev->cdb_len = 0;
2379 dev->n_sectors = 0; 2387 dev->n_sectors = 0;
2380 dev->cylinders = 0; 2388 dev->cylinders = 0;
2381 dev->heads = 0; 2389 dev->heads = 0;
2382 dev->sectors = 0; 2390 dev->sectors = 0;
2383 dev->multi_count = 0; 2391 dev->multi_count = 0;
2384 2392
2385 /* 2393 /*
2386 * common ATA, ATAPI feature tests 2394 * common ATA, ATAPI feature tests
2387 */ 2395 */
2388 2396
2389 /* find max transfer mode; for printk only */ 2397 /* find max transfer mode; for printk only */
2390 xfer_mask = ata_id_xfermask(id); 2398 xfer_mask = ata_id_xfermask(id);
2391 2399
2392 if (ata_msg_probe(ap)) 2400 if (ata_msg_probe(ap))
2393 ata_dump_id(id); 2401 ata_dump_id(id);
2394 2402
2395 /* SCSI only uses 4-char revisions, dump full 8 chars from ATA */ 2403 /* SCSI only uses 4-char revisions, dump full 8 chars from ATA */
2396 ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV, 2404 ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV,
2397 sizeof(fwrevbuf)); 2405 sizeof(fwrevbuf));
2398 2406
2399 ata_id_c_string(dev->id, modelbuf, ATA_ID_PROD, 2407 ata_id_c_string(dev->id, modelbuf, ATA_ID_PROD,
2400 sizeof(modelbuf)); 2408 sizeof(modelbuf));
2401 2409
2402 /* ATA-specific feature tests */ 2410 /* ATA-specific feature tests */
2403 if (dev->class == ATA_DEV_ATA) { 2411 if (dev->class == ATA_DEV_ATA) {
2404 if (ata_id_is_cfa(id)) { 2412 if (ata_id_is_cfa(id)) {
2405 /* CPRM may make this media unusable */ 2413 /* CPRM may make this media unusable */
2406 if (id[ATA_ID_CFA_KEY_MGMT] & 1) 2414 if (id[ATA_ID_CFA_KEY_MGMT] & 1)
2407 ata_dev_printk(dev, KERN_WARNING, 2415 ata_dev_printk(dev, KERN_WARNING,
2408 "supports DRM functions and may " 2416 "supports DRM functions and may "
2409 "not be fully accessable.\n"); 2417 "not be fully accessable.\n");
2410 snprintf(revbuf, 7, "CFA"); 2418 snprintf(revbuf, 7, "CFA");
2411 } else { 2419 } else {
2412 snprintf(revbuf, 7, "ATA-%d", ata_id_major_version(id)); 2420 snprintf(revbuf, 7, "ATA-%d", ata_id_major_version(id));
2413 /* Warn the user if the device has TPM extensions */ 2421 /* Warn the user if the device has TPM extensions */
2414 if (ata_id_has_tpm(id)) 2422 if (ata_id_has_tpm(id))
2415 ata_dev_printk(dev, KERN_WARNING, 2423 ata_dev_printk(dev, KERN_WARNING,
2416 "supports DRM functions and may " 2424 "supports DRM functions and may "
2417 "not be fully accessable.\n"); 2425 "not be fully accessable.\n");
2418 } 2426 }
2419 2427
2420 dev->n_sectors = ata_id_n_sectors(id); 2428 dev->n_sectors = ata_id_n_sectors(id);
2421 2429
2422 /* get current R/W Multiple count setting */ 2430 /* get current R/W Multiple count setting */
2423 if ((dev->id[47] >> 8) == 0x80 && (dev->id[59] & 0x100)) { 2431 if ((dev->id[47] >> 8) == 0x80 && (dev->id[59] & 0x100)) {
2424 unsigned int max = dev->id[47] & 0xff; 2432 unsigned int max = dev->id[47] & 0xff;
2425 unsigned int cnt = dev->id[59] & 0xff; 2433 unsigned int cnt = dev->id[59] & 0xff;
2426 /* only recognize/allow powers of two here */ 2434 /* only recognize/allow powers of two here */
2427 if (is_power_of_2(max) && is_power_of_2(cnt)) 2435 if (is_power_of_2(max) && is_power_of_2(cnt))
2428 if (cnt <= max) 2436 if (cnt <= max)
2429 dev->multi_count = cnt; 2437 dev->multi_count = cnt;
2430 } 2438 }
2431 2439
2432 if (ata_id_has_lba(id)) { 2440 if (ata_id_has_lba(id)) {
2433 const char *lba_desc; 2441 const char *lba_desc;
2434 char ncq_desc[24]; 2442 char ncq_desc[24];
2435 2443
2436 lba_desc = "LBA"; 2444 lba_desc = "LBA";
2437 dev->flags |= ATA_DFLAG_LBA; 2445 dev->flags |= ATA_DFLAG_LBA;
2438 if (ata_id_has_lba48(id)) { 2446 if (ata_id_has_lba48(id)) {
2439 dev->flags |= ATA_DFLAG_LBA48; 2447 dev->flags |= ATA_DFLAG_LBA48;
2440 lba_desc = "LBA48"; 2448 lba_desc = "LBA48";
2441 2449
2442 if (dev->n_sectors >= (1UL << 28) && 2450 if (dev->n_sectors >= (1UL << 28) &&
2443 ata_id_has_flush_ext(id)) 2451 ata_id_has_flush_ext(id))
2444 dev->flags |= ATA_DFLAG_FLUSH_EXT; 2452 dev->flags |= ATA_DFLAG_FLUSH_EXT;
2445 } 2453 }
2446 2454
2447 /* config NCQ */ 2455 /* config NCQ */
2448 rc = ata_dev_config_ncq(dev, ncq_desc, sizeof(ncq_desc)); 2456 rc = ata_dev_config_ncq(dev, ncq_desc, sizeof(ncq_desc));
2449 if (rc) 2457 if (rc)
2450 return rc; 2458 return rc;
2451 2459
2452 /* print device info to dmesg */ 2460 /* print device info to dmesg */
2453 if (ata_msg_drv(ap) && print_info) { 2461 if (ata_msg_drv(ap) && print_info) {
2454 ata_dev_printk(dev, KERN_INFO, 2462 ata_dev_printk(dev, KERN_INFO,
2455 "%s: %s, %s, max %s\n", 2463 "%s: %s, %s, max %s\n",
2456 revbuf, modelbuf, fwrevbuf, 2464 revbuf, modelbuf, fwrevbuf,
2457 ata_mode_string(xfer_mask)); 2465 ata_mode_string(xfer_mask));
2458 ata_dev_printk(dev, KERN_INFO, 2466 ata_dev_printk(dev, KERN_INFO,
2459 "%Lu sectors, multi %u: %s %s\n", 2467 "%Lu sectors, multi %u: %s %s\n",
2460 (unsigned long long)dev->n_sectors, 2468 (unsigned long long)dev->n_sectors,
2461 dev->multi_count, lba_desc, ncq_desc); 2469 dev->multi_count, lba_desc, ncq_desc);
2462 } 2470 }
2463 } else { 2471 } else {
2464 /* CHS */ 2472 /* CHS */
2465 2473
2466 /* Default translation */ 2474 /* Default translation */
2467 dev->cylinders = id[1]; 2475 dev->cylinders = id[1];
2468 dev->heads = id[3]; 2476 dev->heads = id[3];
2469 dev->sectors = id[6]; 2477 dev->sectors = id[6];
2470 2478
2471 if (ata_id_current_chs_valid(id)) { 2479 if (ata_id_current_chs_valid(id)) {
2472 /* Current CHS translation is valid. */ 2480 /* Current CHS translation is valid. */
2473 dev->cylinders = id[54]; 2481 dev->cylinders = id[54];
2474 dev->heads = id[55]; 2482 dev->heads = id[55];
2475 dev->sectors = id[56]; 2483 dev->sectors = id[56];
2476 } 2484 }
2477 2485
2478 /* print device info to dmesg */ 2486 /* print device info to dmesg */
2479 if (ata_msg_drv(ap) && print_info) { 2487 if (ata_msg_drv(ap) && print_info) {
2480 ata_dev_printk(dev, KERN_INFO, 2488 ata_dev_printk(dev, KERN_INFO,
2481 "%s: %s, %s, max %s\n", 2489 "%s: %s, %s, max %s\n",
2482 revbuf, modelbuf, fwrevbuf, 2490 revbuf, modelbuf, fwrevbuf,
2483 ata_mode_string(xfer_mask)); 2491 ata_mode_string(xfer_mask));
2484 ata_dev_printk(dev, KERN_INFO, 2492 ata_dev_printk(dev, KERN_INFO,
2485 "%Lu sectors, multi %u, CHS %u/%u/%u\n", 2493 "%Lu sectors, multi %u, CHS %u/%u/%u\n",
2486 (unsigned long long)dev->n_sectors, 2494 (unsigned long long)dev->n_sectors,
2487 dev->multi_count, dev->cylinders, 2495 dev->multi_count, dev->cylinders,
2488 dev->heads, dev->sectors); 2496 dev->heads, dev->sectors);
2489 } 2497 }
2490 } 2498 }
2491 2499
2492 dev->cdb_len = 16; 2500 dev->cdb_len = 16;
2493 } 2501 }
2494 2502
2495 /* ATAPI-specific feature tests */ 2503 /* ATAPI-specific feature tests */
2496 else if (dev->class == ATA_DEV_ATAPI) { 2504 else if (dev->class == ATA_DEV_ATAPI) {
2497 const char *cdb_intr_string = ""; 2505 const char *cdb_intr_string = "";
2498 const char *atapi_an_string = ""; 2506 const char *atapi_an_string = "";
2499 const char *dma_dir_string = ""; 2507 const char *dma_dir_string = "";
2500 u32 sntf; 2508 u32 sntf;
2501 2509
2502 rc = atapi_cdb_len(id); 2510 rc = atapi_cdb_len(id);
2503 if ((rc < 12) || (rc > ATAPI_CDB_LEN)) { 2511 if ((rc < 12) || (rc > ATAPI_CDB_LEN)) {
2504 if (ata_msg_warn(ap)) 2512 if (ata_msg_warn(ap))
2505 ata_dev_printk(dev, KERN_WARNING, 2513 ata_dev_printk(dev, KERN_WARNING,
2506 "unsupported CDB len\n"); 2514 "unsupported CDB len\n");
2507 rc = -EINVAL; 2515 rc = -EINVAL;
2508 goto err_out_nosup; 2516 goto err_out_nosup;
2509 } 2517 }
2510 dev->cdb_len = (unsigned int) rc; 2518 dev->cdb_len = (unsigned int) rc;
2511 2519
2512 /* Enable ATAPI AN if both the host and device have 2520 /* Enable ATAPI AN if both the host and device have
2513 * the support. If PMP is attached, SNTF is required 2521 * the support. If PMP is attached, SNTF is required
2514 * to enable ATAPI AN to discern between PHY status 2522 * to enable ATAPI AN to discern between PHY status
2515 * changed notifications and ATAPI ANs. 2523 * changed notifications and ATAPI ANs.
2516 */ 2524 */
2517 if (atapi_an && 2525 if (atapi_an &&
2518 (ap->flags & ATA_FLAG_AN) && ata_id_has_atapi_AN(id) && 2526 (ap->flags & ATA_FLAG_AN) && ata_id_has_atapi_AN(id) &&
2519 (!sata_pmp_attached(ap) || 2527 (!sata_pmp_attached(ap) ||
2520 sata_scr_read(&ap->link, SCR_NOTIFICATION, &sntf) == 0)) { 2528 sata_scr_read(&ap->link, SCR_NOTIFICATION, &sntf) == 0)) {
2521 unsigned int err_mask; 2529 unsigned int err_mask;
2522 2530
2523 /* issue SET feature command to turn this on */ 2531 /* issue SET feature command to turn this on */
2524 err_mask = ata_dev_set_feature(dev, 2532 err_mask = ata_dev_set_feature(dev,
2525 SETFEATURES_SATA_ENABLE, SATA_AN); 2533 SETFEATURES_SATA_ENABLE, SATA_AN);
2526 if (err_mask) 2534 if (err_mask)
2527 ata_dev_printk(dev, KERN_ERR, 2535 ata_dev_printk(dev, KERN_ERR,
2528 "failed to enable ATAPI AN " 2536 "failed to enable ATAPI AN "
2529 "(err_mask=0x%x)\n", err_mask); 2537 "(err_mask=0x%x)\n", err_mask);
2530 else { 2538 else {
2531 dev->flags |= ATA_DFLAG_AN; 2539 dev->flags |= ATA_DFLAG_AN;
2532 atapi_an_string = ", ATAPI AN"; 2540 atapi_an_string = ", ATAPI AN";
2533 } 2541 }
2534 } 2542 }
2535 2543
2536 if (ata_id_cdb_intr(dev->id)) { 2544 if (ata_id_cdb_intr(dev->id)) {
2537 dev->flags |= ATA_DFLAG_CDB_INTR; 2545 dev->flags |= ATA_DFLAG_CDB_INTR;
2538 cdb_intr_string = ", CDB intr"; 2546 cdb_intr_string = ", CDB intr";
2539 } 2547 }
2540 2548
2541 if (atapi_dmadir || atapi_id_dmadir(dev->id)) { 2549 if (atapi_dmadir || atapi_id_dmadir(dev->id)) {
2542 dev->flags |= ATA_DFLAG_DMADIR; 2550 dev->flags |= ATA_DFLAG_DMADIR;
2543 dma_dir_string = ", DMADIR"; 2551 dma_dir_string = ", DMADIR";
2544 } 2552 }
2545 2553
2546 /* print device info to dmesg */ 2554 /* print device info to dmesg */
2547 if (ata_msg_drv(ap) && print_info) 2555 if (ata_msg_drv(ap) && print_info)
2548 ata_dev_printk(dev, KERN_INFO, 2556 ata_dev_printk(dev, KERN_INFO,
2549 "ATAPI: %s, %s, max %s%s%s%s\n", 2557 "ATAPI: %s, %s, max %s%s%s%s\n",
2550 modelbuf, fwrevbuf, 2558 modelbuf, fwrevbuf,
2551 ata_mode_string(xfer_mask), 2559 ata_mode_string(xfer_mask),
2552 cdb_intr_string, atapi_an_string, 2560 cdb_intr_string, atapi_an_string,
2553 dma_dir_string); 2561 dma_dir_string);
2554 } 2562 }
2555 2563
2556 /* determine max_sectors */ 2564 /* determine max_sectors */
2557 dev->max_sectors = ATA_MAX_SECTORS; 2565 dev->max_sectors = ATA_MAX_SECTORS;
2558 if (dev->flags & ATA_DFLAG_LBA48) 2566 if (dev->flags & ATA_DFLAG_LBA48)
2559 dev->max_sectors = ATA_MAX_SECTORS_LBA48; 2567 dev->max_sectors = ATA_MAX_SECTORS_LBA48;
2560 2568
2561 if (!(dev->horkage & ATA_HORKAGE_IPM)) { 2569 if (!(dev->horkage & ATA_HORKAGE_IPM)) {
2562 if (ata_id_has_hipm(dev->id)) 2570 if (ata_id_has_hipm(dev->id))
2563 dev->flags |= ATA_DFLAG_HIPM; 2571 dev->flags |= ATA_DFLAG_HIPM;
2564 if (ata_id_has_dipm(dev->id)) 2572 if (ata_id_has_dipm(dev->id))
2565 dev->flags |= ATA_DFLAG_DIPM; 2573 dev->flags |= ATA_DFLAG_DIPM;
2566 } 2574 }
2567 2575
2568 /* Limit PATA drive on SATA cable bridge transfers to udma5, 2576 /* Limit PATA drive on SATA cable bridge transfers to udma5,
2569 200 sectors */ 2577 200 sectors */
2570 if (ata_dev_knobble(dev)) { 2578 if (ata_dev_knobble(dev)) {
2571 if (ata_msg_drv(ap) && print_info) 2579 if (ata_msg_drv(ap) && print_info)
2572 ata_dev_printk(dev, KERN_INFO, 2580 ata_dev_printk(dev, KERN_INFO,
2573 "applying bridge limits\n"); 2581 "applying bridge limits\n");
2574 dev->udma_mask &= ATA_UDMA5; 2582 dev->udma_mask &= ATA_UDMA5;
2575 dev->max_sectors = ATA_MAX_SECTORS; 2583 dev->max_sectors = ATA_MAX_SECTORS;
2576 } 2584 }
2577 2585
2578 if ((dev->class == ATA_DEV_ATAPI) && 2586 if ((dev->class == ATA_DEV_ATAPI) &&
2579 (atapi_command_packet_set(id) == TYPE_TAPE)) { 2587 (atapi_command_packet_set(id) == TYPE_TAPE)) {
2580 dev->max_sectors = ATA_MAX_SECTORS_TAPE; 2588 dev->max_sectors = ATA_MAX_SECTORS_TAPE;
2581 dev->horkage |= ATA_HORKAGE_STUCK_ERR; 2589 dev->horkage |= ATA_HORKAGE_STUCK_ERR;
2582 } 2590 }
2583 2591
2584 if (dev->horkage & ATA_HORKAGE_MAX_SEC_128) 2592 if (dev->horkage & ATA_HORKAGE_MAX_SEC_128)
2585 dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128, 2593 dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128,
2586 dev->max_sectors); 2594 dev->max_sectors);
2587 2595
2588 if (ata_dev_blacklisted(dev) & ATA_HORKAGE_IPM) { 2596 if (ata_dev_blacklisted(dev) & ATA_HORKAGE_IPM) {
2589 dev->horkage |= ATA_HORKAGE_IPM; 2597 dev->horkage |= ATA_HORKAGE_IPM;
2590 2598
2591 /* reset link pm_policy for this port to no pm */ 2599 /* reset link pm_policy for this port to no pm */
2592 ap->pm_policy = MAX_PERFORMANCE; 2600 ap->pm_policy = MAX_PERFORMANCE;
2593 } 2601 }
2594 2602
2595 if (ap->ops->dev_config) 2603 if (ap->ops->dev_config)
2596 ap->ops->dev_config(dev); 2604 ap->ops->dev_config(dev);
2597 2605
2598 if (dev->horkage & ATA_HORKAGE_DIAGNOSTIC) { 2606 if (dev->horkage & ATA_HORKAGE_DIAGNOSTIC) {
2599 /* Let the user know. We don't want to disallow opens for 2607 /* Let the user know. We don't want to disallow opens for
2600 rescue purposes, or in case the vendor is just a blithering 2608 rescue purposes, or in case the vendor is just a blithering
2601 idiot. Do this after the dev_config call as some controllers 2609 idiot. Do this after the dev_config call as some controllers
2602 with buggy firmware may want to avoid reporting false device 2610 with buggy firmware may want to avoid reporting false device
2603 bugs */ 2611 bugs */
2604 2612
2605 if (print_info) { 2613 if (print_info) {
2606 ata_dev_printk(dev, KERN_WARNING, 2614 ata_dev_printk(dev, KERN_WARNING,
2607 "Drive reports diagnostics failure. This may indicate a drive\n"); 2615 "Drive reports diagnostics failure. This may indicate a drive\n");
2608 ata_dev_printk(dev, KERN_WARNING, 2616 ata_dev_printk(dev, KERN_WARNING,
2609 "fault or invalid emulation. Contact drive vendor for information.\n"); 2617 "fault or invalid emulation. Contact drive vendor for information.\n");
2610 } 2618 }
2611 } 2619 }
2612 2620
2613 if ((dev->horkage & ATA_HORKAGE_FIRMWARE_WARN) && print_info) { 2621 if ((dev->horkage & ATA_HORKAGE_FIRMWARE_WARN) && print_info) {
2614 ata_dev_printk(dev, KERN_WARNING, "WARNING: device requires " 2622 ata_dev_printk(dev, KERN_WARNING, "WARNING: device requires "
2615 "firmware update to be fully functional.\n"); 2623 "firmware update to be fully functional.\n");
2616 ata_dev_printk(dev, KERN_WARNING, " contact the vendor " 2624 ata_dev_printk(dev, KERN_WARNING, " contact the vendor "
2617 "or visit http://ata.wiki.kernel.org.\n"); 2625 "or visit http://ata.wiki.kernel.org.\n");
2618 } 2626 }
2619 2627
2620 return 0; 2628 return 0;
2621 2629
2622 err_out_nosup: 2630 err_out_nosup:
2623 if (ata_msg_probe(ap)) 2631 if (ata_msg_probe(ap))
2624 ata_dev_printk(dev, KERN_DEBUG, 2632 ata_dev_printk(dev, KERN_DEBUG,
2625 "%s: EXIT, err\n", __func__); 2633 "%s: EXIT, err\n", __func__);
2626 return rc; 2634 return rc;
2627 } 2635 }
2628 2636
2629 /** 2637 /**
2630 * ata_cable_40wire - return 40 wire cable type 2638 * ata_cable_40wire - return 40 wire cable type
2631 * @ap: port 2639 * @ap: port
2632 * 2640 *
2633 * Helper method for drivers which want to hardwire 40 wire cable 2641 * Helper method for drivers which want to hardwire 40 wire cable
2634 * detection. 2642 * detection.
2635 */ 2643 */
2636 2644
2637 int ata_cable_40wire(struct ata_port *ap) 2645 int ata_cable_40wire(struct ata_port *ap)
2638 { 2646 {
2639 return ATA_CBL_PATA40; 2647 return ATA_CBL_PATA40;
2640 } 2648 }
2641 2649
2642 /** 2650 /**
2643 * ata_cable_80wire - return 80 wire cable type 2651 * ata_cable_80wire - return 80 wire cable type
2644 * @ap: port 2652 * @ap: port
2645 * 2653 *
2646 * Helper method for drivers which want to hardwire 80 wire cable 2654 * Helper method for drivers which want to hardwire 80 wire cable
2647 * detection. 2655 * detection.
2648 */ 2656 */
2649 2657
2650 int ata_cable_80wire(struct ata_port *ap) 2658 int ata_cable_80wire(struct ata_port *ap)
2651 { 2659 {
2652 return ATA_CBL_PATA80; 2660 return ATA_CBL_PATA80;
2653 } 2661 }
2654 2662
2655 /** 2663 /**
2656 * ata_cable_unknown - return unknown PATA cable. 2664 * ata_cable_unknown - return unknown PATA cable.
2657 * @ap: port 2665 * @ap: port
2658 * 2666 *
2659 * Helper method for drivers which have no PATA cable detection. 2667 * Helper method for drivers which have no PATA cable detection.
2660 */ 2668 */
2661 2669
2662 int ata_cable_unknown(struct ata_port *ap) 2670 int ata_cable_unknown(struct ata_port *ap)
2663 { 2671 {
2664 return ATA_CBL_PATA_UNK; 2672 return ATA_CBL_PATA_UNK;
2665 } 2673 }
2666 2674
2667 /** 2675 /**
2668 * ata_cable_ignore - return ignored PATA cable. 2676 * ata_cable_ignore - return ignored PATA cable.
2669 * @ap: port 2677 * @ap: port
2670 * 2678 *
2671 * Helper method for drivers which don't use cable type to limit 2679 * Helper method for drivers which don't use cable type to limit
2672 * transfer mode. 2680 * transfer mode.
2673 */ 2681 */
2674 int ata_cable_ignore(struct ata_port *ap) 2682 int ata_cable_ignore(struct ata_port *ap)
2675 { 2683 {
2676 return ATA_CBL_PATA_IGN; 2684 return ATA_CBL_PATA_IGN;
2677 } 2685 }
2678 2686
2679 /** 2687 /**
2680 * ata_cable_sata - return SATA cable type 2688 * ata_cable_sata - return SATA cable type
2681 * @ap: port 2689 * @ap: port
2682 * 2690 *
2683 * Helper method for drivers which have SATA cables 2691 * Helper method for drivers which have SATA cables
2684 */ 2692 */
2685 2693
2686 int ata_cable_sata(struct ata_port *ap) 2694 int ata_cable_sata(struct ata_port *ap)
2687 { 2695 {
2688 return ATA_CBL_SATA; 2696 return ATA_CBL_SATA;
2689 } 2697 }
2690 2698
2691 /** 2699 /**
2692 * ata_bus_probe - Reset and probe ATA bus 2700 * ata_bus_probe - Reset and probe ATA bus
2693 * @ap: Bus to probe 2701 * @ap: Bus to probe
2694 * 2702 *
2695 * Master ATA bus probing function. Initiates a hardware-dependent 2703 * Master ATA bus probing function. Initiates a hardware-dependent
2696 * bus reset, then attempts to identify any devices found on 2704 * bus reset, then attempts to identify any devices found on
2697 * the bus. 2705 * the bus.
2698 * 2706 *
2699 * LOCKING: 2707 * LOCKING:
2700 * PCI/etc. bus probe sem. 2708 * PCI/etc. bus probe sem.
2701 * 2709 *
2702 * RETURNS: 2710 * RETURNS:
2703 * Zero on success, negative errno otherwise. 2711 * Zero on success, negative errno otherwise.
2704 */ 2712 */
2705 2713
2706 int ata_bus_probe(struct ata_port *ap) 2714 int ata_bus_probe(struct ata_port *ap)
2707 { 2715 {
2708 unsigned int classes[ATA_MAX_DEVICES]; 2716 unsigned int classes[ATA_MAX_DEVICES];
2709 int tries[ATA_MAX_DEVICES]; 2717 int tries[ATA_MAX_DEVICES];
2710 int rc; 2718 int rc;
2711 struct ata_device *dev; 2719 struct ata_device *dev;
2712 2720
2713 ata_for_each_dev(dev, &ap->link, ALL) 2721 ata_for_each_dev(dev, &ap->link, ALL)
2714 tries[dev->devno] = ATA_PROBE_MAX_TRIES; 2722 tries[dev->devno] = ATA_PROBE_MAX_TRIES;
2715 2723
2716 retry: 2724 retry:
2717 ata_for_each_dev(dev, &ap->link, ALL) { 2725 ata_for_each_dev(dev, &ap->link, ALL) {
2718 /* If we issue an SRST then an ATA drive (not ATAPI) 2726 /* If we issue an SRST then an ATA drive (not ATAPI)
2719 * may change configuration and be in PIO0 timing. If 2727 * may change configuration and be in PIO0 timing. If
2720 * we do a hard reset (or are coming from power on) 2728 * we do a hard reset (or are coming from power on)
2721 * this is true for ATA or ATAPI. Until we've set a 2729 * this is true for ATA or ATAPI. Until we've set a
2722 * suitable controller mode we should not touch the 2730 * suitable controller mode we should not touch the
2723 * bus as we may be talking too fast. 2731 * bus as we may be talking too fast.
2724 */ 2732 */
2725 dev->pio_mode = XFER_PIO_0; 2733 dev->pio_mode = XFER_PIO_0;
2726 2734
2727 /* If the controller has a pio mode setup function 2735 /* If the controller has a pio mode setup function
2728 * then use it to set the chipset to rights. Don't 2736 * then use it to set the chipset to rights. Don't
2729 * touch the DMA setup as that will be dealt with when 2737 * touch the DMA setup as that will be dealt with when
2730 * configuring devices. 2738 * configuring devices.
2731 */ 2739 */
2732 if (ap->ops->set_piomode) 2740 if (ap->ops->set_piomode)
2733 ap->ops->set_piomode(ap, dev); 2741 ap->ops->set_piomode(ap, dev);
2734 } 2742 }
2735 2743
2736 /* reset and determine device classes */ 2744 /* reset and determine device classes */
2737 ap->ops->phy_reset(ap); 2745 ap->ops->phy_reset(ap);
2738 2746
2739 ata_for_each_dev(dev, &ap->link, ALL) { 2747 ata_for_each_dev(dev, &ap->link, ALL) {
2740 if (dev->class != ATA_DEV_UNKNOWN) 2748 if (dev->class != ATA_DEV_UNKNOWN)
2741 classes[dev->devno] = dev->class; 2749 classes[dev->devno] = dev->class;
2742 else 2750 else
2743 classes[dev->devno] = ATA_DEV_NONE; 2751 classes[dev->devno] = ATA_DEV_NONE;
2744 2752
2745 dev->class = ATA_DEV_UNKNOWN; 2753 dev->class = ATA_DEV_UNKNOWN;
2746 } 2754 }
2747 2755
2748 /* read IDENTIFY page and configure devices. We have to do the identify 2756 /* read IDENTIFY page and configure devices. We have to do the identify
2749 specific sequence bass-ackwards so that PDIAG- is released by 2757 specific sequence bass-ackwards so that PDIAG- is released by
2750 the slave device */ 2758 the slave device */
2751 2759
2752 ata_for_each_dev(dev, &ap->link, ALL_REVERSE) { 2760 ata_for_each_dev(dev, &ap->link, ALL_REVERSE) {
2753 if (tries[dev->devno]) 2761 if (tries[dev->devno])
2754 dev->class = classes[dev->devno]; 2762 dev->class = classes[dev->devno];
2755 2763
2756 if (!ata_dev_enabled(dev)) 2764 if (!ata_dev_enabled(dev))
2757 continue; 2765 continue;
2758 2766
2759 rc = ata_dev_read_id(dev, &dev->class, ATA_READID_POSTRESET, 2767 rc = ata_dev_read_id(dev, &dev->class, ATA_READID_POSTRESET,
2760 dev->id); 2768 dev->id);
2761 if (rc) 2769 if (rc)
2762 goto fail; 2770 goto fail;
2763 } 2771 }
2764 2772
2765 /* Now ask for the cable type as PDIAG- should have been released */ 2773 /* Now ask for the cable type as PDIAG- should have been released */
2766 if (ap->ops->cable_detect) 2774 if (ap->ops->cable_detect)
2767 ap->cbl = ap->ops->cable_detect(ap); 2775 ap->cbl = ap->ops->cable_detect(ap);
2768 2776
2769 /* We may have SATA bridge glue hiding here irrespective of 2777 /* We may have SATA bridge glue hiding here irrespective of
2770 * the reported cable types and sensed types. When SATA 2778 * the reported cable types and sensed types. When SATA
2771 * drives indicate we have a bridge, we don't know which end 2779 * drives indicate we have a bridge, we don't know which end
2772 * of the link the bridge is which is a problem. 2780 * of the link the bridge is which is a problem.
2773 */ 2781 */
2774 ata_for_each_dev(dev, &ap->link, ENABLED) 2782 ata_for_each_dev(dev, &ap->link, ENABLED)
2775 if (ata_id_is_sata(dev->id)) 2783 if (ata_id_is_sata(dev->id))
2776 ap->cbl = ATA_CBL_SATA; 2784 ap->cbl = ATA_CBL_SATA;
2777 2785
2778 /* After the identify sequence we can now set up the devices. We do 2786 /* After the identify sequence we can now set up the devices. We do
2779 this in the normal order so that the user doesn't get confused */ 2787 this in the normal order so that the user doesn't get confused */
2780 2788
2781 ata_for_each_dev(dev, &ap->link, ENABLED) { 2789 ata_for_each_dev(dev, &ap->link, ENABLED) {
2782 ap->link.eh_context.i.flags |= ATA_EHI_PRINTINFO; 2790 ap->link.eh_context.i.flags |= ATA_EHI_PRINTINFO;
2783 rc = ata_dev_configure(dev); 2791 rc = ata_dev_configure(dev);
2784 ap->link.eh_context.i.flags &= ~ATA_EHI_PRINTINFO; 2792 ap->link.eh_context.i.flags &= ~ATA_EHI_PRINTINFO;
2785 if (rc) 2793 if (rc)
2786 goto fail; 2794 goto fail;
2787 } 2795 }
2788 2796
2789 /* configure transfer mode */ 2797 /* configure transfer mode */
2790 rc = ata_set_mode(&ap->link, &dev); 2798 rc = ata_set_mode(&ap->link, &dev);
2791 if (rc) 2799 if (rc)
2792 goto fail; 2800 goto fail;
2793 2801
2794 ata_for_each_dev(dev, &ap->link, ENABLED) 2802 ata_for_each_dev(dev, &ap->link, ENABLED)
2795 return 0; 2803 return 0;
2796 2804
2797 return -ENODEV; 2805 return -ENODEV;
2798 2806
2799 fail: 2807 fail:
2800 tries[dev->devno]--; 2808 tries[dev->devno]--;
2801 2809
2802 switch (rc) { 2810 switch (rc) {
2803 case -EINVAL: 2811 case -EINVAL:
2804 /* eeek, something went very wrong, give up */ 2812 /* eeek, something went very wrong, give up */
2805 tries[dev->devno] = 0; 2813 tries[dev->devno] = 0;
2806 break; 2814 break;
2807 2815
2808 case -ENODEV: 2816 case -ENODEV:
2809 /* give it just one more chance */ 2817 /* give it just one more chance */
2810 tries[dev->devno] = min(tries[dev->devno], 1); 2818 tries[dev->devno] = min(tries[dev->devno], 1);
2811 case -EIO: 2819 case -EIO:
2812 if (tries[dev->devno] == 1) { 2820 if (tries[dev->devno] == 1) {
2813 /* This is the last chance, better to slow 2821 /* This is the last chance, better to slow
2814 * down than lose it. 2822 * down than lose it.
2815 */ 2823 */
2816 sata_down_spd_limit(&ap->link, 0); 2824 sata_down_spd_limit(&ap->link, 0);
2817 ata_down_xfermask_limit(dev, ATA_DNXFER_PIO); 2825 ata_down_xfermask_limit(dev, ATA_DNXFER_PIO);
2818 } 2826 }
2819 } 2827 }
2820 2828
2821 if (!tries[dev->devno]) 2829 if (!tries[dev->devno])
2822 ata_dev_disable(dev); 2830 ata_dev_disable(dev);
2823 2831
2824 goto retry; 2832 goto retry;
2825 } 2833 }
2826 2834
2827 /** 2835 /**
2828 * sata_print_link_status - Print SATA link status 2836 * sata_print_link_status - Print SATA link status
2829 * @link: SATA link to printk link status about 2837 * @link: SATA link to printk link status about
2830 * 2838 *
2831 * This function prints link speed and status of a SATA link. 2839 * This function prints link speed and status of a SATA link.
2832 * 2840 *
2833 * LOCKING: 2841 * LOCKING:
2834 * None. 2842 * None.
2835 */ 2843 */
2836 static void sata_print_link_status(struct ata_link *link) 2844 static void sata_print_link_status(struct ata_link *link)
2837 { 2845 {
2838 u32 sstatus, scontrol, tmp; 2846 u32 sstatus, scontrol, tmp;
2839 2847
2840 if (sata_scr_read(link, SCR_STATUS, &sstatus)) 2848 if (sata_scr_read(link, SCR_STATUS, &sstatus))
2841 return; 2849 return;
2842 sata_scr_read(link, SCR_CONTROL, &scontrol); 2850 sata_scr_read(link, SCR_CONTROL, &scontrol);
2843 2851
2844 if (ata_phys_link_online(link)) { 2852 if (ata_phys_link_online(link)) {
2845 tmp = (sstatus >> 4) & 0xf; 2853 tmp = (sstatus >> 4) & 0xf;
2846 ata_link_printk(link, KERN_INFO, 2854 ata_link_printk(link, KERN_INFO,
2847 "SATA link up %s (SStatus %X SControl %X)\n", 2855 "SATA link up %s (SStatus %X SControl %X)\n",
2848 sata_spd_string(tmp), sstatus, scontrol); 2856 sata_spd_string(tmp), sstatus, scontrol);
2849 } else { 2857 } else {
2850 ata_link_printk(link, KERN_INFO, 2858 ata_link_printk(link, KERN_INFO,
2851 "SATA link down (SStatus %X SControl %X)\n", 2859 "SATA link down (SStatus %X SControl %X)\n",
2852 sstatus, scontrol); 2860 sstatus, scontrol);
2853 } 2861 }
2854 } 2862 }
2855 2863
2856 /** 2864 /**
2857 * ata_dev_pair - return other device on cable 2865 * ata_dev_pair - return other device on cable
2858 * @adev: device 2866 * @adev: device
2859 * 2867 *
2860 * Obtain the other device on the same cable, or if none is 2868 * Obtain the other device on the same cable, or if none is
2861 * present NULL is returned 2869 * present NULL is returned
2862 */ 2870 */
2863 2871
2864 struct ata_device *ata_dev_pair(struct ata_device *adev) 2872 struct ata_device *ata_dev_pair(struct ata_device *adev)
2865 { 2873 {
2866 struct ata_link *link = adev->link; 2874 struct ata_link *link = adev->link;
2867 struct ata_device *pair = &link->device[1 - adev->devno]; 2875 struct ata_device *pair = &link->device[1 - adev->devno];
2868 if (!ata_dev_enabled(pair)) 2876 if (!ata_dev_enabled(pair))
2869 return NULL; 2877 return NULL;
2870 return pair; 2878 return pair;
2871 } 2879 }
2872 2880
2873 /** 2881 /**
2874 * sata_down_spd_limit - adjust SATA spd limit downward 2882 * sata_down_spd_limit - adjust SATA spd limit downward
2875 * @link: Link to adjust SATA spd limit for 2883 * @link: Link to adjust SATA spd limit for
2876 * @spd_limit: Additional limit 2884 * @spd_limit: Additional limit
2877 * 2885 *
2878 * Adjust SATA spd limit of @link downward. Note that this 2886 * Adjust SATA spd limit of @link downward. Note that this
2879 * function only adjusts the limit. The change must be applied 2887 * function only adjusts the limit. The change must be applied
2880 * using sata_set_spd(). 2888 * using sata_set_spd().
2881 * 2889 *
2882 * If @spd_limit is non-zero, the speed is limited to equal to or 2890 * If @spd_limit is non-zero, the speed is limited to equal to or
2883 * lower than @spd_limit if such speed is supported. If 2891 * lower than @spd_limit if such speed is supported. If
2884 * @spd_limit is slower than any supported speed, only the lowest 2892 * @spd_limit is slower than any supported speed, only the lowest
2885 * supported speed is allowed. 2893 * supported speed is allowed.
2886 * 2894 *
2887 * LOCKING: 2895 * LOCKING:
2888 * Inherited from caller. 2896 * Inherited from caller.
2889 * 2897 *
2890 * RETURNS: 2898 * RETURNS:
2891 * 0 on success, negative errno on failure 2899 * 0 on success, negative errno on failure
2892 */ 2900 */
2893 int sata_down_spd_limit(struct ata_link *link, u32 spd_limit) 2901 int sata_down_spd_limit(struct ata_link *link, u32 spd_limit)
2894 { 2902 {
2895 u32 sstatus, spd, mask; 2903 u32 sstatus, spd, mask;
2896 int rc, bit; 2904 int rc, bit;
2897 2905
2898 if (!sata_scr_valid(link)) 2906 if (!sata_scr_valid(link))
2899 return -EOPNOTSUPP; 2907 return -EOPNOTSUPP;
2900 2908
2901 /* If SCR can be read, use it to determine the current SPD. 2909 /* If SCR can be read, use it to determine the current SPD.
2902 * If not, use cached value in link->sata_spd. 2910 * If not, use cached value in link->sata_spd.
2903 */ 2911 */
2904 rc = sata_scr_read(link, SCR_STATUS, &sstatus); 2912 rc = sata_scr_read(link, SCR_STATUS, &sstatus);
2905 if (rc == 0 && ata_sstatus_online(sstatus)) 2913 if (rc == 0 && ata_sstatus_online(sstatus))
2906 spd = (sstatus >> 4) & 0xf; 2914 spd = (sstatus >> 4) & 0xf;
2907 else 2915 else
2908 spd = link->sata_spd; 2916 spd = link->sata_spd;
2909 2917
2910 mask = link->sata_spd_limit; 2918 mask = link->sata_spd_limit;
2911 if (mask <= 1) 2919 if (mask <= 1)
2912 return -EINVAL; 2920 return -EINVAL;
2913 2921
2914 /* unconditionally mask off the highest bit */ 2922 /* unconditionally mask off the highest bit */
2915 bit = fls(mask) - 1; 2923 bit = fls(mask) - 1;
2916 mask &= ~(1 << bit); 2924 mask &= ~(1 << bit);
2917 2925
2918 /* Mask off all speeds higher than or equal to the current 2926 /* Mask off all speeds higher than or equal to the current
2919 * one. Force 1.5Gbps if current SPD is not available. 2927 * one. Force 1.5Gbps if current SPD is not available.
2920 */ 2928 */
2921 if (spd > 1) 2929 if (spd > 1)
2922 mask &= (1 << (spd - 1)) - 1; 2930 mask &= (1 << (spd - 1)) - 1;
2923 else 2931 else
2924 mask &= 1; 2932 mask &= 1;
2925 2933
2926 /* were we already at the bottom? */ 2934 /* were we already at the bottom? */
2927 if (!mask) 2935 if (!mask)
2928 return -EINVAL; 2936 return -EINVAL;
2929 2937
2930 if (spd_limit) { 2938 if (spd_limit) {
2931 if (mask & ((1 << spd_limit) - 1)) 2939 if (mask & ((1 << spd_limit) - 1))
2932 mask &= (1 << spd_limit) - 1; 2940 mask &= (1 << spd_limit) - 1;
2933 else { 2941 else {
2934 bit = ffs(mask) - 1; 2942 bit = ffs(mask) - 1;
2935 mask = 1 << bit; 2943 mask = 1 << bit;
2936 } 2944 }
2937 } 2945 }
2938 2946
2939 link->sata_spd_limit = mask; 2947 link->sata_spd_limit = mask;
2940 2948
2941 ata_link_printk(link, KERN_WARNING, "limiting SATA link speed to %s\n", 2949 ata_link_printk(link, KERN_WARNING, "limiting SATA link speed to %s\n",
2942 sata_spd_string(fls(mask))); 2950 sata_spd_string(fls(mask)));
2943 2951
2944 return 0; 2952 return 0;
2945 } 2953 }
2946 2954
2947 static int __sata_set_spd_needed(struct ata_link *link, u32 *scontrol) 2955 static int __sata_set_spd_needed(struct ata_link *link, u32 *scontrol)
2948 { 2956 {
2949 struct ata_link *host_link = &link->ap->link; 2957 struct ata_link *host_link = &link->ap->link;
2950 u32 limit, target, spd; 2958 u32 limit, target, spd;
2951 2959
2952 limit = link->sata_spd_limit; 2960 limit = link->sata_spd_limit;
2953 2961
2954 /* Don't configure downstream link faster than upstream link. 2962 /* Don't configure downstream link faster than upstream link.
2955 * It doesn't speed up anything and some PMPs choke on such 2963 * It doesn't speed up anything and some PMPs choke on such
2956 * configuration. 2964 * configuration.
2957 */ 2965 */
2958 if (!ata_is_host_link(link) && host_link->sata_spd) 2966 if (!ata_is_host_link(link) && host_link->sata_spd)
2959 limit &= (1 << host_link->sata_spd) - 1; 2967 limit &= (1 << host_link->sata_spd) - 1;
2960 2968
2961 if (limit == UINT_MAX) 2969 if (limit == UINT_MAX)
2962 target = 0; 2970 target = 0;
2963 else 2971 else
2964 target = fls(limit); 2972 target = fls(limit);
2965 2973
2966 spd = (*scontrol >> 4) & 0xf; 2974 spd = (*scontrol >> 4) & 0xf;
2967 *scontrol = (*scontrol & ~0xf0) | ((target & 0xf) << 4); 2975 *scontrol = (*scontrol & ~0xf0) | ((target & 0xf) << 4);
2968 2976
2969 return spd != target; 2977 return spd != target;
2970 } 2978 }
2971 2979
2972 /** 2980 /**
2973 * sata_set_spd_needed - is SATA spd configuration needed 2981 * sata_set_spd_needed - is SATA spd configuration needed
2974 * @link: Link in question 2982 * @link: Link in question
2975 * 2983 *
2976 * Test whether the spd limit in SControl matches 2984 * Test whether the spd limit in SControl matches
2977 * @link->sata_spd_limit. This function is used to determine 2985 * @link->sata_spd_limit. This function is used to determine
2978 * whether hardreset is necessary to apply SATA spd 2986 * whether hardreset is necessary to apply SATA spd
2979 * configuration. 2987 * configuration.
2980 * 2988 *
2981 * LOCKING: 2989 * LOCKING:
2982 * Inherited from caller. 2990 * Inherited from caller.
2983 * 2991 *
2984 * RETURNS: 2992 * RETURNS:
2985 * 1 if SATA spd configuration is needed, 0 otherwise. 2993 * 1 if SATA spd configuration is needed, 0 otherwise.
2986 */ 2994 */
2987 static int sata_set_spd_needed(struct ata_link *link) 2995 static int sata_set_spd_needed(struct ata_link *link)
2988 { 2996 {
2989 u32 scontrol; 2997 u32 scontrol;
2990 2998
2991 if (sata_scr_read(link, SCR_CONTROL, &scontrol)) 2999 if (sata_scr_read(link, SCR_CONTROL, &scontrol))
2992 return 1; 3000 return 1;
2993 3001
2994 return __sata_set_spd_needed(link, &scontrol); 3002 return __sata_set_spd_needed(link, &scontrol);
2995 } 3003 }
2996 3004
2997 /** 3005 /**
2998 * sata_set_spd - set SATA spd according to spd limit 3006 * sata_set_spd - set SATA spd according to spd limit
2999 * @link: Link to set SATA spd for 3007 * @link: Link to set SATA spd for
3000 * 3008 *
3001 * Set SATA spd of @link according to sata_spd_limit. 3009 * Set SATA spd of @link according to sata_spd_limit.
3002 * 3010 *
3003 * LOCKING: 3011 * LOCKING:
3004 * Inherited from caller. 3012 * Inherited from caller.
3005 * 3013 *
3006 * RETURNS: 3014 * RETURNS:
3007 * 0 if spd doesn't need to be changed, 1 if spd has been 3015 * 0 if spd doesn't need to be changed, 1 if spd has been
3008 * changed. Negative errno if SCR registers are inaccessible. 3016 * changed. Negative errno if SCR registers are inaccessible.
3009 */ 3017 */
3010 int sata_set_spd(struct ata_link *link) 3018 int sata_set_spd(struct ata_link *link)
3011 { 3019 {
3012 u32 scontrol; 3020 u32 scontrol;
3013 int rc; 3021 int rc;
3014 3022
3015 if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol))) 3023 if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol)))
3016 return rc; 3024 return rc;
3017 3025
3018 if (!__sata_set_spd_needed(link, &scontrol)) 3026 if (!__sata_set_spd_needed(link, &scontrol))
3019 return 0; 3027 return 0;
3020 3028
3021 if ((rc = sata_scr_write(link, SCR_CONTROL, scontrol))) 3029 if ((rc = sata_scr_write(link, SCR_CONTROL, scontrol)))
3022 return rc; 3030 return rc;
3023 3031
3024 return 1; 3032 return 1;
3025 } 3033 }
3026 3034
3027 /* 3035 /*
3028 * This mode timing computation functionality is ported over from 3036 * This mode timing computation functionality is ported over from
3029 * drivers/ide/ide-timing.h and was originally written by Vojtech Pavlik 3037 * drivers/ide/ide-timing.h and was originally written by Vojtech Pavlik
3030 */ 3038 */
3031 /* 3039 /*
3032 * PIO 0-4, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds). 3040 * PIO 0-4, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
3033 * These were taken from ATA/ATAPI-6 standard, rev 0a, except 3041 * These were taken from ATA/ATAPI-6 standard, rev 0a, except
3034 * for UDMA6, which is currently supported only by Maxtor drives. 3042 * for UDMA6, which is currently supported only by Maxtor drives.
3035 * 3043 *
3036 * For PIO 5/6 MWDMA 3/4 see the CFA specification 3.0. 3044 * For PIO 5/6 MWDMA 3/4 see the CFA specification 3.0.
3037 */ 3045 */
3038 3046
3039 static const struct ata_timing ata_timing[] = { 3047 static const struct ata_timing ata_timing[] = {
3040 /* { XFER_PIO_SLOW, 120, 290, 240, 960, 290, 240, 0, 960, 0 }, */ 3048 /* { XFER_PIO_SLOW, 120, 290, 240, 960, 290, 240, 0, 960, 0 }, */
3041 { XFER_PIO_0, 70, 290, 240, 600, 165, 150, 0, 600, 0 }, 3049 { XFER_PIO_0, 70, 290, 240, 600, 165, 150, 0, 600, 0 },
3042 { XFER_PIO_1, 50, 290, 93, 383, 125, 100, 0, 383, 0 }, 3050 { XFER_PIO_1, 50, 290, 93, 383, 125, 100, 0, 383, 0 },
3043 { XFER_PIO_2, 30, 290, 40, 330, 100, 90, 0, 240, 0 }, 3051 { XFER_PIO_2, 30, 290, 40, 330, 100, 90, 0, 240, 0 },
3044 { XFER_PIO_3, 30, 80, 70, 180, 80, 70, 0, 180, 0 }, 3052 { XFER_PIO_3, 30, 80, 70, 180, 80, 70, 0, 180, 0 },
3045 { XFER_PIO_4, 25, 70, 25, 120, 70, 25, 0, 120, 0 }, 3053 { XFER_PIO_4, 25, 70, 25, 120, 70, 25, 0, 120, 0 },
3046 { XFER_PIO_5, 15, 65, 25, 100, 65, 25, 0, 100, 0 }, 3054 { XFER_PIO_5, 15, 65, 25, 100, 65, 25, 0, 100, 0 },
3047 { XFER_PIO_6, 10, 55, 20, 80, 55, 20, 0, 80, 0 }, 3055 { XFER_PIO_6, 10, 55, 20, 80, 55, 20, 0, 80, 0 },
3048 3056
3049 { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 50, 960, 0 }, 3057 { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 50, 960, 0 },
3050 { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 30, 480, 0 }, 3058 { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 30, 480, 0 },
3051 { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 20, 240, 0 }, 3059 { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 20, 240, 0 },
3052 3060
3053 { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 20, 480, 0 }, 3061 { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 20, 480, 0 },
3054 { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 5, 150, 0 }, 3062 { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 5, 150, 0 },
3055 { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 5, 120, 0 }, 3063 { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 5, 120, 0 },
3056 { XFER_MW_DMA_3, 25, 0, 0, 0, 65, 25, 5, 100, 0 }, 3064 { XFER_MW_DMA_3, 25, 0, 0, 0, 65, 25, 5, 100, 0 },
3057 { XFER_MW_DMA_4, 25, 0, 0, 0, 55, 20, 5, 80, 0 }, 3065 { XFER_MW_DMA_4, 25, 0, 0, 0, 55, 20, 5, 80, 0 },
3058 3066
3059 /* { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 0, 150 }, */ 3067 /* { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 0, 150 }, */
3060 { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 0, 120 }, 3068 { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 0, 120 },
3061 { XFER_UDMA_1, 0, 0, 0, 0, 0, 0, 0, 0, 80 }, 3069 { XFER_UDMA_1, 0, 0, 0, 0, 0, 0, 0, 0, 80 },
3062 { XFER_UDMA_2, 0, 0, 0, 0, 0, 0, 0, 0, 60 }, 3070 { XFER_UDMA_2, 0, 0, 0, 0, 0, 0, 0, 0, 60 },
3063 { XFER_UDMA_3, 0, 0, 0, 0, 0, 0, 0, 0, 45 }, 3071 { XFER_UDMA_3, 0, 0, 0, 0, 0, 0, 0, 0, 45 },
3064 { XFER_UDMA_4, 0, 0, 0, 0, 0, 0, 0, 0, 30 }, 3072 { XFER_UDMA_4, 0, 0, 0, 0, 0, 0, 0, 0, 30 },
3065 { XFER_UDMA_5, 0, 0, 0, 0, 0, 0, 0, 0, 20 }, 3073 { XFER_UDMA_5, 0, 0, 0, 0, 0, 0, 0, 0, 20 },
3066 { XFER_UDMA_6, 0, 0, 0, 0, 0, 0, 0, 0, 15 }, 3074 { XFER_UDMA_6, 0, 0, 0, 0, 0, 0, 0, 0, 15 },
3067 3075
3068 { 0xFF } 3076 { 0xFF }
3069 }; 3077 };
3070 3078
3071 #define ENOUGH(v, unit) (((v)-1)/(unit)+1) 3079 #define ENOUGH(v, unit) (((v)-1)/(unit)+1)
3072 #define EZ(v, unit) ((v)?ENOUGH(v, unit):0) 3080 #define EZ(v, unit) ((v)?ENOUGH(v, unit):0)
3073 3081
3074 static void ata_timing_quantize(const struct ata_timing *t, struct ata_timing *q, int T, int UT) 3082 static void ata_timing_quantize(const struct ata_timing *t, struct ata_timing *q, int T, int UT)
3075 { 3083 {
3076 q->setup = EZ(t->setup * 1000, T); 3084 q->setup = EZ(t->setup * 1000, T);
3077 q->act8b = EZ(t->act8b * 1000, T); 3085 q->act8b = EZ(t->act8b * 1000, T);
3078 q->rec8b = EZ(t->rec8b * 1000, T); 3086 q->rec8b = EZ(t->rec8b * 1000, T);
3079 q->cyc8b = EZ(t->cyc8b * 1000, T); 3087 q->cyc8b = EZ(t->cyc8b * 1000, T);
3080 q->active = EZ(t->active * 1000, T); 3088 q->active = EZ(t->active * 1000, T);
3081 q->recover = EZ(t->recover * 1000, T); 3089 q->recover = EZ(t->recover * 1000, T);
3082 q->dmack_hold = EZ(t->dmack_hold * 1000, T); 3090 q->dmack_hold = EZ(t->dmack_hold * 1000, T);
3083 q->cycle = EZ(t->cycle * 1000, T); 3091 q->cycle = EZ(t->cycle * 1000, T);
3084 q->udma = EZ(t->udma * 1000, UT); 3092 q->udma = EZ(t->udma * 1000, UT);
3085 } 3093 }
3086 3094
3087 void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b, 3095 void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b,
3088 struct ata_timing *m, unsigned int what) 3096 struct ata_timing *m, unsigned int what)
3089 { 3097 {
3090 if (what & ATA_TIMING_SETUP ) m->setup = max(a->setup, b->setup); 3098 if (what & ATA_TIMING_SETUP ) m->setup = max(a->setup, b->setup);
3091 if (what & ATA_TIMING_ACT8B ) m->act8b = max(a->act8b, b->act8b); 3099 if (what & ATA_TIMING_ACT8B ) m->act8b = max(a->act8b, b->act8b);
3092 if (what & ATA_TIMING_REC8B ) m->rec8b = max(a->rec8b, b->rec8b); 3100 if (what & ATA_TIMING_REC8B ) m->rec8b = max(a->rec8b, b->rec8b);
3093 if (what & ATA_TIMING_CYC8B ) m->cyc8b = max(a->cyc8b, b->cyc8b); 3101 if (what & ATA_TIMING_CYC8B ) m->cyc8b = max(a->cyc8b, b->cyc8b);
3094 if (what & ATA_TIMING_ACTIVE ) m->active = max(a->active, b->active); 3102 if (what & ATA_TIMING_ACTIVE ) m->active = max(a->active, b->active);
3095 if (what & ATA_TIMING_RECOVER) m->recover = max(a->recover, b->recover); 3103 if (what & ATA_TIMING_RECOVER) m->recover = max(a->recover, b->recover);
3096 if (what & ATA_TIMING_DMACK_HOLD) m->dmack_hold = max(a->dmack_hold, b->dmack_hold); 3104 if (what & ATA_TIMING_DMACK_HOLD) m->dmack_hold = max(a->dmack_hold, b->dmack_hold);
3097 if (what & ATA_TIMING_CYCLE ) m->cycle = max(a->cycle, b->cycle); 3105 if (what & ATA_TIMING_CYCLE ) m->cycle = max(a->cycle, b->cycle);
3098 if (what & ATA_TIMING_UDMA ) m->udma = max(a->udma, b->udma); 3106 if (what & ATA_TIMING_UDMA ) m->udma = max(a->udma, b->udma);
3099 } 3107 }
3100 3108
3101 const struct ata_timing *ata_timing_find_mode(u8 xfer_mode) 3109 const struct ata_timing *ata_timing_find_mode(u8 xfer_mode)
3102 { 3110 {
3103 const struct ata_timing *t = ata_timing; 3111 const struct ata_timing *t = ata_timing;
3104 3112
3105 while (xfer_mode > t->mode) 3113 while (xfer_mode > t->mode)
3106 t++; 3114 t++;
3107 3115
3108 if (xfer_mode == t->mode) 3116 if (xfer_mode == t->mode)
3109 return t; 3117 return t;
3110 return NULL; 3118 return NULL;
3111 } 3119 }
3112 3120
3113 int ata_timing_compute(struct ata_device *adev, unsigned short speed, 3121 int ata_timing_compute(struct ata_device *adev, unsigned short speed,
3114 struct ata_timing *t, int T, int UT) 3122 struct ata_timing *t, int T, int UT)
3115 { 3123 {
3116 const u16 *id = adev->id; 3124 const u16 *id = adev->id;
3117 const struct ata_timing *s; 3125 const struct ata_timing *s;
3118 struct ata_timing p; 3126 struct ata_timing p;
3119 3127
3120 /* 3128 /*
3121 * Find the mode. 3129 * Find the mode.
3122 */ 3130 */
3123 3131
3124 if (!(s = ata_timing_find_mode(speed))) 3132 if (!(s = ata_timing_find_mode(speed)))
3125 return -EINVAL; 3133 return -EINVAL;
3126 3134
3127 memcpy(t, s, sizeof(*s)); 3135 memcpy(t, s, sizeof(*s));
3128 3136
3129 /* 3137 /*
3130 * If the drive is an EIDE drive, it can tell us it needs extended 3138 * If the drive is an EIDE drive, it can tell us it needs extended
3131 * PIO/MW_DMA cycle timing. 3139 * PIO/MW_DMA cycle timing.
3132 */ 3140 */
3133 3141
3134 if (id[ATA_ID_FIELD_VALID] & 2) { /* EIDE drive */ 3142 if (id[ATA_ID_FIELD_VALID] & 2) { /* EIDE drive */
3135 memset(&p, 0, sizeof(p)); 3143 memset(&p, 0, sizeof(p));
3136 3144
3137 if (speed >= XFER_PIO_0 && speed <= XFER_SW_DMA_0) { 3145 if (speed >= XFER_PIO_0 && speed <= XFER_SW_DMA_0) {
3138 if (speed <= XFER_PIO_2) 3146 if (speed <= XFER_PIO_2)
3139 p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO]; 3147 p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO];
3140 else if ((speed <= XFER_PIO_4) || 3148 else if ((speed <= XFER_PIO_4) ||
3141 (speed == XFER_PIO_5 && !ata_id_is_cfa(id))) 3149 (speed == XFER_PIO_5 && !ata_id_is_cfa(id)))
3142 p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO_IORDY]; 3150 p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO_IORDY];
3143 } else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2) 3151 } else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2)
3144 p.cycle = id[ATA_ID_EIDE_DMA_MIN]; 3152 p.cycle = id[ATA_ID_EIDE_DMA_MIN];
3145 3153
3146 ata_timing_merge(&p, t, t, ATA_TIMING_CYCLE | ATA_TIMING_CYC8B); 3154 ata_timing_merge(&p, t, t, ATA_TIMING_CYCLE | ATA_TIMING_CYC8B);
3147 } 3155 }
3148 3156
3149 /* 3157 /*
3150 * Convert the timing to bus clock counts. 3158 * Convert the timing to bus clock counts.
3151 */ 3159 */
3152 3160
3153 ata_timing_quantize(t, t, T, UT); 3161 ata_timing_quantize(t, t, T, UT);
3154 3162
3155 /* 3163 /*
3156 * Even in DMA/UDMA modes we still use PIO access for IDENTIFY, 3164 * Even in DMA/UDMA modes we still use PIO access for IDENTIFY,
3157 * S.M.A.R.T * and some other commands. We have to ensure that the 3165 * S.M.A.R.T * and some other commands. We have to ensure that the
3158 * DMA cycle timing is slower/equal than the fastest PIO timing. 3166 * DMA cycle timing is slower/equal than the fastest PIO timing.
3159 */ 3167 */
3160 3168
3161 if (speed > XFER_PIO_6) { 3169 if (speed > XFER_PIO_6) {
3162 ata_timing_compute(adev, adev->pio_mode, &p, T, UT); 3170 ata_timing_compute(adev, adev->pio_mode, &p, T, UT);
3163 ata_timing_merge(&p, t, t, ATA_TIMING_ALL); 3171 ata_timing_merge(&p, t, t, ATA_TIMING_ALL);
3164 } 3172 }
3165 3173
3166 /* 3174 /*
3167 * Lengthen active & recovery time so that cycle time is correct. 3175 * Lengthen active & recovery time so that cycle time is correct.
3168 */ 3176 */
3169 3177
3170 if (t->act8b + t->rec8b < t->cyc8b) { 3178 if (t->act8b + t->rec8b < t->cyc8b) {
3171 t->act8b += (t->cyc8b - (t->act8b + t->rec8b)) / 2; 3179 t->act8b += (t->cyc8b - (t->act8b + t->rec8b)) / 2;
3172 t->rec8b = t->cyc8b - t->act8b; 3180 t->rec8b = t->cyc8b - t->act8b;
3173 } 3181 }
3174 3182
3175 if (t->active + t->recover < t->cycle) { 3183 if (t->active + t->recover < t->cycle) {
3176 t->active += (t->cycle - (t->active + t->recover)) / 2; 3184 t->active += (t->cycle - (t->active + t->recover)) / 2;
3177 t->recover = t->cycle - t->active; 3185 t->recover = t->cycle - t->active;
3178 } 3186 }
3179 3187
3180 /* In a few cases quantisation may produce enough errors to 3188 /* In a few cases quantisation may produce enough errors to
3181 leave t->cycle too low for the sum of active and recovery 3189 leave t->cycle too low for the sum of active and recovery
3182 if so we must correct this */ 3190 if so we must correct this */
3183 if (t->active + t->recover > t->cycle) 3191 if (t->active + t->recover > t->cycle)
3184 t->cycle = t->active + t->recover; 3192 t->cycle = t->active + t->recover;
3185 3193
3186 return 0; 3194 return 0;
3187 } 3195 }
3188 3196
3189 /** 3197 /**
3190 * ata_timing_cycle2mode - find xfer mode for the specified cycle duration 3198 * ata_timing_cycle2mode - find xfer mode for the specified cycle duration
3191 * @xfer_shift: ATA_SHIFT_* value for transfer type to examine. 3199 * @xfer_shift: ATA_SHIFT_* value for transfer type to examine.
3192 * @cycle: cycle duration in ns 3200 * @cycle: cycle duration in ns
3193 * 3201 *
3194 * Return matching xfer mode for @cycle. The returned mode is of 3202 * Return matching xfer mode for @cycle. The returned mode is of
3195 * the transfer type specified by @xfer_shift. If @cycle is too 3203 * the transfer type specified by @xfer_shift. If @cycle is too
3196 * slow for @xfer_shift, 0xff is returned. If @cycle is faster 3204 * slow for @xfer_shift, 0xff is returned. If @cycle is faster
3197 * than the fastest known mode, the fasted mode is returned. 3205 * than the fastest known mode, the fasted mode is returned.
3198 * 3206 *
3199 * LOCKING: 3207 * LOCKING:
3200 * None. 3208 * None.
3201 * 3209 *
3202 * RETURNS: 3210 * RETURNS:
3203 * Matching xfer_mode, 0xff if no match found. 3211 * Matching xfer_mode, 0xff if no match found.
3204 */ 3212 */
3205 u8 ata_timing_cycle2mode(unsigned int xfer_shift, int cycle) 3213 u8 ata_timing_cycle2mode(unsigned int xfer_shift, int cycle)
3206 { 3214 {
3207 u8 base_mode = 0xff, last_mode = 0xff; 3215 u8 base_mode = 0xff, last_mode = 0xff;
3208 const struct ata_xfer_ent *ent; 3216 const struct ata_xfer_ent *ent;
3209 const struct ata_timing *t; 3217 const struct ata_timing *t;
3210 3218
3211 for (ent = ata_xfer_tbl; ent->shift >= 0; ent++) 3219 for (ent = ata_xfer_tbl; ent->shift >= 0; ent++)
3212 if (ent->shift == xfer_shift) 3220 if (ent->shift == xfer_shift)
3213 base_mode = ent->base; 3221 base_mode = ent->base;
3214 3222
3215 for (t = ata_timing_find_mode(base_mode); 3223 for (t = ata_timing_find_mode(base_mode);
3216 t && ata_xfer_mode2shift(t->mode) == xfer_shift; t++) { 3224 t && ata_xfer_mode2shift(t->mode) == xfer_shift; t++) {
3217 unsigned short this_cycle; 3225 unsigned short this_cycle;
3218 3226
3219 switch (xfer_shift) { 3227 switch (xfer_shift) {
3220 case ATA_SHIFT_PIO: 3228 case ATA_SHIFT_PIO:
3221 case ATA_SHIFT_MWDMA: 3229 case ATA_SHIFT_MWDMA:
3222 this_cycle = t->cycle; 3230 this_cycle = t->cycle;
3223 break; 3231 break;
3224 case ATA_SHIFT_UDMA: 3232 case ATA_SHIFT_UDMA:
3225 this_cycle = t->udma; 3233 this_cycle = t->udma;
3226 break; 3234 break;
3227 default: 3235 default:
3228 return 0xff; 3236 return 0xff;
3229 } 3237 }
3230 3238
3231 if (cycle > this_cycle) 3239 if (cycle > this_cycle)
3232 break; 3240 break;
3233 3241
3234 last_mode = t->mode; 3242 last_mode = t->mode;
3235 } 3243 }
3236 3244
3237 return last_mode; 3245 return last_mode;
3238 } 3246 }
3239 3247
3240 /** 3248 /**
3241 * ata_down_xfermask_limit - adjust dev xfer masks downward 3249 * ata_down_xfermask_limit - adjust dev xfer masks downward
3242 * @dev: Device to adjust xfer masks 3250 * @dev: Device to adjust xfer masks
3243 * @sel: ATA_DNXFER_* selector 3251 * @sel: ATA_DNXFER_* selector
3244 * 3252 *
3245 * Adjust xfer masks of @dev downward. Note that this function 3253 * Adjust xfer masks of @dev downward. Note that this function
3246 * does not apply the change. Invoking ata_set_mode() afterwards 3254 * does not apply the change. Invoking ata_set_mode() afterwards
3247 * will apply the limit. 3255 * will apply the limit.
3248 * 3256 *
3249 * LOCKING: 3257 * LOCKING:
3250 * Inherited from caller. 3258 * Inherited from caller.
3251 * 3259 *
3252 * RETURNS: 3260 * RETURNS:
3253 * 0 on success, negative errno on failure 3261 * 0 on success, negative errno on failure
3254 */ 3262 */
3255 int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel) 3263 int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel)
3256 { 3264 {
3257 char buf[32]; 3265 char buf[32];
3258 unsigned long orig_mask, xfer_mask; 3266 unsigned long orig_mask, xfer_mask;
3259 unsigned long pio_mask, mwdma_mask, udma_mask; 3267 unsigned long pio_mask, mwdma_mask, udma_mask;
3260 int quiet, highbit; 3268 int quiet, highbit;
3261 3269
3262 quiet = !!(sel & ATA_DNXFER_QUIET); 3270 quiet = !!(sel & ATA_DNXFER_QUIET);
3263 sel &= ~ATA_DNXFER_QUIET; 3271 sel &= ~ATA_DNXFER_QUIET;
3264 3272
3265 xfer_mask = orig_mask = ata_pack_xfermask(dev->pio_mask, 3273 xfer_mask = orig_mask = ata_pack_xfermask(dev->pio_mask,
3266 dev->mwdma_mask, 3274 dev->mwdma_mask,
3267 dev->udma_mask); 3275 dev->udma_mask);
3268 ata_unpack_xfermask(xfer_mask, &pio_mask, &mwdma_mask, &udma_mask); 3276 ata_unpack_xfermask(xfer_mask, &pio_mask, &mwdma_mask, &udma_mask);
3269 3277
3270 switch (sel) { 3278 switch (sel) {
3271 case ATA_DNXFER_PIO: 3279 case ATA_DNXFER_PIO:
3272 highbit = fls(pio_mask) - 1; 3280 highbit = fls(pio_mask) - 1;
3273 pio_mask &= ~(1 << highbit); 3281 pio_mask &= ~(1 << highbit);
3274 break; 3282 break;
3275 3283
3276 case ATA_DNXFER_DMA: 3284 case ATA_DNXFER_DMA:
3277 if (udma_mask) { 3285 if (udma_mask) {
3278 highbit = fls(udma_mask) - 1; 3286 highbit = fls(udma_mask) - 1;
3279 udma_mask &= ~(1 << highbit); 3287 udma_mask &= ~(1 << highbit);
3280 if (!udma_mask) 3288 if (!udma_mask)
3281 return -ENOENT; 3289 return -ENOENT;
3282 } else if (mwdma_mask) { 3290 } else if (mwdma_mask) {
3283 highbit = fls(mwdma_mask) - 1; 3291 highbit = fls(mwdma_mask) - 1;
3284 mwdma_mask &= ~(1 << highbit); 3292 mwdma_mask &= ~(1 << highbit);
3285 if (!mwdma_mask) 3293 if (!mwdma_mask)
3286 return -ENOENT; 3294 return -ENOENT;
3287 } 3295 }
3288 break; 3296 break;
3289 3297
3290 case ATA_DNXFER_40C: 3298 case ATA_DNXFER_40C:
3291 udma_mask &= ATA_UDMA_MASK_40C; 3299 udma_mask &= ATA_UDMA_MASK_40C;
3292 break; 3300 break;
3293 3301
3294 case ATA_DNXFER_FORCE_PIO0: 3302 case ATA_DNXFER_FORCE_PIO0:
3295 pio_mask &= 1; 3303 pio_mask &= 1;
3296 case ATA_DNXFER_FORCE_PIO: 3304 case ATA_DNXFER_FORCE_PIO:
3297 mwdma_mask = 0; 3305 mwdma_mask = 0;
3298 udma_mask = 0; 3306 udma_mask = 0;
3299 break; 3307 break;
3300 3308
3301 default: 3309 default:
3302 BUG(); 3310 BUG();
3303 } 3311 }
3304 3312
3305 xfer_mask &= ata_pack_xfermask(pio_mask, mwdma_mask, udma_mask); 3313 xfer_mask &= ata_pack_xfermask(pio_mask, mwdma_mask, udma_mask);
3306 3314
3307 if (!(xfer_mask & ATA_MASK_PIO) || xfer_mask == orig_mask) 3315 if (!(xfer_mask & ATA_MASK_PIO) || xfer_mask == orig_mask)
3308 return -ENOENT; 3316 return -ENOENT;
3309 3317
3310 if (!quiet) { 3318 if (!quiet) {
3311 if (xfer_mask & (ATA_MASK_MWDMA | ATA_MASK_UDMA)) 3319 if (xfer_mask & (ATA_MASK_MWDMA | ATA_MASK_UDMA))
3312 snprintf(buf, sizeof(buf), "%s:%s", 3320 snprintf(buf, sizeof(buf), "%s:%s",
3313 ata_mode_string(xfer_mask), 3321 ata_mode_string(xfer_mask),
3314 ata_mode_string(xfer_mask & ATA_MASK_PIO)); 3322 ata_mode_string(xfer_mask & ATA_MASK_PIO));
3315 else 3323 else
3316 snprintf(buf, sizeof(buf), "%s", 3324 snprintf(buf, sizeof(buf), "%s",
3317 ata_mode_string(xfer_mask)); 3325 ata_mode_string(xfer_mask));
3318 3326
3319 ata_dev_printk(dev, KERN_WARNING, 3327 ata_dev_printk(dev, KERN_WARNING,
3320 "limiting speed to %s\n", buf); 3328 "limiting speed to %s\n", buf);
3321 } 3329 }
3322 3330
3323 ata_unpack_xfermask(xfer_mask, &dev->pio_mask, &dev->mwdma_mask, 3331 ata_unpack_xfermask(xfer_mask, &dev->pio_mask, &dev->mwdma_mask,
3324 &dev->udma_mask); 3332 &dev->udma_mask);
3325 3333
3326 return 0; 3334 return 0;
3327 } 3335 }
3328 3336
3329 static int ata_dev_set_mode(struct ata_device *dev) 3337 static int ata_dev_set_mode(struct ata_device *dev)
3330 { 3338 {
3331 struct ata_port *ap = dev->link->ap; 3339 struct ata_port *ap = dev->link->ap;
3332 struct ata_eh_context *ehc = &dev->link->eh_context; 3340 struct ata_eh_context *ehc = &dev->link->eh_context;
3333 const bool nosetxfer = dev->horkage & ATA_HORKAGE_NOSETXFER; 3341 const bool nosetxfer = dev->horkage & ATA_HORKAGE_NOSETXFER;
3334 const char *dev_err_whine = ""; 3342 const char *dev_err_whine = "";
3335 int ign_dev_err = 0; 3343 int ign_dev_err = 0;
3336 unsigned int err_mask = 0; 3344 unsigned int err_mask = 0;
3337 int rc; 3345 int rc;
3338 3346
3339 dev->flags &= ~ATA_DFLAG_PIO; 3347 dev->flags &= ~ATA_DFLAG_PIO;
3340 if (dev->xfer_shift == ATA_SHIFT_PIO) 3348 if (dev->xfer_shift == ATA_SHIFT_PIO)
3341 dev->flags |= ATA_DFLAG_PIO; 3349 dev->flags |= ATA_DFLAG_PIO;
3342 3350
3343 if (nosetxfer && ap->flags & ATA_FLAG_SATA && ata_id_is_sata(dev->id)) 3351 if (nosetxfer && ap->flags & ATA_FLAG_SATA && ata_id_is_sata(dev->id))
3344 dev_err_whine = " (SET_XFERMODE skipped)"; 3352 dev_err_whine = " (SET_XFERMODE skipped)";
3345 else { 3353 else {
3346 if (nosetxfer) 3354 if (nosetxfer)
3347 ata_dev_printk(dev, KERN_WARNING, 3355 ata_dev_printk(dev, KERN_WARNING,
3348 "NOSETXFER but PATA detected - can't " 3356 "NOSETXFER but PATA detected - can't "
3349 "skip SETXFER, might malfunction\n"); 3357 "skip SETXFER, might malfunction\n");
3350 err_mask = ata_dev_set_xfermode(dev); 3358 err_mask = ata_dev_set_xfermode(dev);
3351 } 3359 }
3352 3360
3353 if (err_mask & ~AC_ERR_DEV) 3361 if (err_mask & ~AC_ERR_DEV)
3354 goto fail; 3362 goto fail;
3355 3363
3356 /* revalidate */ 3364 /* revalidate */
3357 ehc->i.flags |= ATA_EHI_POST_SETMODE; 3365 ehc->i.flags |= ATA_EHI_POST_SETMODE;
3358 rc = ata_dev_revalidate(dev, ATA_DEV_UNKNOWN, 0); 3366 rc = ata_dev_revalidate(dev, ATA_DEV_UNKNOWN, 0);
3359 ehc->i.flags &= ~ATA_EHI_POST_SETMODE; 3367 ehc->i.flags &= ~ATA_EHI_POST_SETMODE;
3360 if (rc) 3368 if (rc)
3361 return rc; 3369 return rc;
3362 3370
3363 if (dev->xfer_shift == ATA_SHIFT_PIO) { 3371 if (dev->xfer_shift == ATA_SHIFT_PIO) {
3364 /* Old CFA may refuse this command, which is just fine */ 3372 /* Old CFA may refuse this command, which is just fine */
3365 if (ata_id_is_cfa(dev->id)) 3373 if (ata_id_is_cfa(dev->id))
3366 ign_dev_err = 1; 3374 ign_dev_err = 1;
3367 /* Catch several broken garbage emulations plus some pre 3375 /* Catch several broken garbage emulations plus some pre
3368 ATA devices */ 3376 ATA devices */
3369 if (ata_id_major_version(dev->id) == 0 && 3377 if (ata_id_major_version(dev->id) == 0 &&
3370 dev->pio_mode <= XFER_PIO_2) 3378 dev->pio_mode <= XFER_PIO_2)
3371 ign_dev_err = 1; 3379 ign_dev_err = 1;
3372 /* Some very old devices and some bad newer ones fail 3380 /* Some very old devices and some bad newer ones fail
3373 any kind of SET_XFERMODE request but support PIO0-2 3381 any kind of SET_XFERMODE request but support PIO0-2
3374 timings and no IORDY */ 3382 timings and no IORDY */
3375 if (!ata_id_has_iordy(dev->id) && dev->pio_mode <= XFER_PIO_2) 3383 if (!ata_id_has_iordy(dev->id) && dev->pio_mode <= XFER_PIO_2)
3376 ign_dev_err = 1; 3384 ign_dev_err = 1;
3377 } 3385 }
3378 /* Early MWDMA devices do DMA but don't allow DMA mode setting. 3386 /* Early MWDMA devices do DMA but don't allow DMA mode setting.
3379 Don't fail an MWDMA0 set IFF the device indicates it is in MWDMA0 */ 3387 Don't fail an MWDMA0 set IFF the device indicates it is in MWDMA0 */
3380 if (dev->xfer_shift == ATA_SHIFT_MWDMA && 3388 if (dev->xfer_shift == ATA_SHIFT_MWDMA &&
3381 dev->dma_mode == XFER_MW_DMA_0 && 3389 dev->dma_mode == XFER_MW_DMA_0 &&
3382 (dev->id[63] >> 8) & 1) 3390 (dev->id[63] >> 8) & 1)
3383 ign_dev_err = 1; 3391 ign_dev_err = 1;
3384 3392
3385 /* if the device is actually configured correctly, ignore dev err */ 3393 /* if the device is actually configured correctly, ignore dev err */
3386 if (dev->xfer_mode == ata_xfer_mask2mode(ata_id_xfermask(dev->id))) 3394 if (dev->xfer_mode == ata_xfer_mask2mode(ata_id_xfermask(dev->id)))
3387 ign_dev_err = 1; 3395 ign_dev_err = 1;
3388 3396
3389 if (err_mask & AC_ERR_DEV) { 3397 if (err_mask & AC_ERR_DEV) {
3390 if (!ign_dev_err) 3398 if (!ign_dev_err)
3391 goto fail; 3399 goto fail;
3392 else 3400 else
3393 dev_err_whine = " (device error ignored)"; 3401 dev_err_whine = " (device error ignored)";
3394 } 3402 }
3395 3403
3396 DPRINTK("xfer_shift=%u, xfer_mode=0x%x\n", 3404 DPRINTK("xfer_shift=%u, xfer_mode=0x%x\n",
3397 dev->xfer_shift, (int)dev->xfer_mode); 3405 dev->xfer_shift, (int)dev->xfer_mode);
3398 3406
3399 ata_dev_printk(dev, KERN_INFO, "configured for %s%s\n", 3407 ata_dev_printk(dev, KERN_INFO, "configured for %s%s\n",
3400 ata_mode_string(ata_xfer_mode2mask(dev->xfer_mode)), 3408 ata_mode_string(ata_xfer_mode2mask(dev->xfer_mode)),
3401 dev_err_whine); 3409 dev_err_whine);
3402 3410
3403 return 0; 3411 return 0;
3404 3412
3405 fail: 3413 fail:
3406 ata_dev_printk(dev, KERN_ERR, "failed to set xfermode " 3414 ata_dev_printk(dev, KERN_ERR, "failed to set xfermode "
3407 "(err_mask=0x%x)\n", err_mask); 3415 "(err_mask=0x%x)\n", err_mask);
3408 return -EIO; 3416 return -EIO;
3409 } 3417 }
3410 3418
3411 /** 3419 /**
3412 * ata_do_set_mode - Program timings and issue SET FEATURES - XFER 3420 * ata_do_set_mode - Program timings and issue SET FEATURES - XFER
3413 * @link: link on which timings will be programmed 3421 * @link: link on which timings will be programmed
3414 * @r_failed_dev: out parameter for failed device 3422 * @r_failed_dev: out parameter for failed device
3415 * 3423 *
3416 * Standard implementation of the function used to tune and set 3424 * Standard implementation of the function used to tune and set
3417 * ATA device disk transfer mode (PIO3, UDMA6, etc.). If 3425 * ATA device disk transfer mode (PIO3, UDMA6, etc.). If
3418 * ata_dev_set_mode() fails, pointer to the failing device is 3426 * ata_dev_set_mode() fails, pointer to the failing device is
3419 * returned in @r_failed_dev. 3427 * returned in @r_failed_dev.
3420 * 3428 *
3421 * LOCKING: 3429 * LOCKING:
3422 * PCI/etc. bus probe sem. 3430 * PCI/etc. bus probe sem.
3423 * 3431 *
3424 * RETURNS: 3432 * RETURNS:
3425 * 0 on success, negative errno otherwise 3433 * 0 on success, negative errno otherwise
3426 */ 3434 */
3427 3435
3428 int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev) 3436 int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
3429 { 3437 {
3430 struct ata_port *ap = link->ap; 3438 struct ata_port *ap = link->ap;
3431 struct ata_device *dev; 3439 struct ata_device *dev;
3432 int rc = 0, used_dma = 0, found = 0; 3440 int rc = 0, used_dma = 0, found = 0;
3433 3441
3434 /* step 1: calculate xfer_mask */ 3442 /* step 1: calculate xfer_mask */
3435 ata_for_each_dev(dev, link, ENABLED) { 3443 ata_for_each_dev(dev, link, ENABLED) {
3436 unsigned long pio_mask, dma_mask; 3444 unsigned long pio_mask, dma_mask;
3437 unsigned int mode_mask; 3445 unsigned int mode_mask;
3438 3446
3439 mode_mask = ATA_DMA_MASK_ATA; 3447 mode_mask = ATA_DMA_MASK_ATA;
3440 if (dev->class == ATA_DEV_ATAPI) 3448 if (dev->class == ATA_DEV_ATAPI)
3441 mode_mask = ATA_DMA_MASK_ATAPI; 3449 mode_mask = ATA_DMA_MASK_ATAPI;
3442 else if (ata_id_is_cfa(dev->id)) 3450 else if (ata_id_is_cfa(dev->id))
3443 mode_mask = ATA_DMA_MASK_CFA; 3451 mode_mask = ATA_DMA_MASK_CFA;
3444 3452
3445 ata_dev_xfermask(dev); 3453 ata_dev_xfermask(dev);
3446 ata_force_xfermask(dev); 3454 ata_force_xfermask(dev);
3447 3455
3448 pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0); 3456 pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0);
3449 dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask); 3457 dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask);
3450 3458
3451 if (libata_dma_mask & mode_mask) 3459 if (libata_dma_mask & mode_mask)
3452 dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask); 3460 dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask);
3453 else 3461 else
3454 dma_mask = 0; 3462 dma_mask = 0;
3455 3463
3456 dev->pio_mode = ata_xfer_mask2mode(pio_mask); 3464 dev->pio_mode = ata_xfer_mask2mode(pio_mask);
3457 dev->dma_mode = ata_xfer_mask2mode(dma_mask); 3465 dev->dma_mode = ata_xfer_mask2mode(dma_mask);
3458 3466
3459 found = 1; 3467 found = 1;
3460 if (ata_dma_enabled(dev)) 3468 if (ata_dma_enabled(dev))
3461 used_dma = 1; 3469 used_dma = 1;
3462 } 3470 }
3463 if (!found) 3471 if (!found)
3464 goto out; 3472 goto out;
3465 3473
3466 /* step 2: always set host PIO timings */ 3474 /* step 2: always set host PIO timings */
3467 ata_for_each_dev(dev, link, ENABLED) { 3475 ata_for_each_dev(dev, link, ENABLED) {
3468 if (dev->pio_mode == 0xff) { 3476 if (dev->pio_mode == 0xff) {
3469 ata_dev_printk(dev, KERN_WARNING, "no PIO support\n"); 3477 ata_dev_printk(dev, KERN_WARNING, "no PIO support\n");
3470 rc = -EINVAL; 3478 rc = -EINVAL;
3471 goto out; 3479 goto out;
3472 } 3480 }
3473 3481
3474 dev->xfer_mode = dev->pio_mode; 3482 dev->xfer_mode = dev->pio_mode;
3475 dev->xfer_shift = ATA_SHIFT_PIO; 3483 dev->xfer_shift = ATA_SHIFT_PIO;
3476 if (ap->ops->set_piomode) 3484 if (ap->ops->set_piomode)
3477 ap->ops->set_piomode(ap, dev); 3485 ap->ops->set_piomode(ap, dev);
3478 } 3486 }
3479 3487
3480 /* step 3: set host DMA timings */ 3488 /* step 3: set host DMA timings */
3481 ata_for_each_dev(dev, link, ENABLED) { 3489 ata_for_each_dev(dev, link, ENABLED) {
3482 if (!ata_dma_enabled(dev)) 3490 if (!ata_dma_enabled(dev))
3483 continue; 3491 continue;
3484 3492
3485 dev->xfer_mode = dev->dma_mode; 3493 dev->xfer_mode = dev->dma_mode;
3486 dev->xfer_shift = ata_xfer_mode2shift(dev->dma_mode); 3494 dev->xfer_shift = ata_xfer_mode2shift(dev->dma_mode);
3487 if (ap->ops->set_dmamode) 3495 if (ap->ops->set_dmamode)
3488 ap->ops->set_dmamode(ap, dev); 3496 ap->ops->set_dmamode(ap, dev);
3489 } 3497 }
3490 3498
3491 /* step 4: update devices' xfer mode */ 3499 /* step 4: update devices' xfer mode */
3492 ata_for_each_dev(dev, link, ENABLED) { 3500 ata_for_each_dev(dev, link, ENABLED) {
3493 rc = ata_dev_set_mode(dev); 3501 rc = ata_dev_set_mode(dev);
3494 if (rc) 3502 if (rc)
3495 goto out; 3503 goto out;
3496 } 3504 }
3497 3505
3498 /* Record simplex status. If we selected DMA then the other 3506 /* Record simplex status. If we selected DMA then the other
3499 * host channels are not permitted to do so. 3507 * host channels are not permitted to do so.
3500 */ 3508 */
3501 if (used_dma && (ap->host->flags & ATA_HOST_SIMPLEX)) 3509 if (used_dma && (ap->host->flags & ATA_HOST_SIMPLEX))
3502 ap->host->simplex_claimed = ap; 3510 ap->host->simplex_claimed = ap;
3503 3511
3504 out: 3512 out:
3505 if (rc) 3513 if (rc)
3506 *r_failed_dev = dev; 3514 *r_failed_dev = dev;
3507 return rc; 3515 return rc;
3508 } 3516 }
3509 3517
3510 /** 3518 /**
3511 * ata_wait_ready - wait for link to become ready 3519 * ata_wait_ready - wait for link to become ready
3512 * @link: link to be waited on 3520 * @link: link to be waited on
3513 * @deadline: deadline jiffies for the operation 3521 * @deadline: deadline jiffies for the operation
3514 * @check_ready: callback to check link readiness 3522 * @check_ready: callback to check link readiness
3515 * 3523 *
3516 * Wait for @link to become ready. @check_ready should return 3524 * Wait for @link to become ready. @check_ready should return
3517 * positive number if @link is ready, 0 if it isn't, -ENODEV if 3525 * positive number if @link is ready, 0 if it isn't, -ENODEV if
3518 * link doesn't seem to be occupied, other errno for other error 3526 * link doesn't seem to be occupied, other errno for other error
3519 * conditions. 3527 * conditions.
3520 * 3528 *
3521 * Transient -ENODEV conditions are allowed for 3529 * Transient -ENODEV conditions are allowed for
3522 * ATA_TMOUT_FF_WAIT. 3530 * ATA_TMOUT_FF_WAIT.
3523 * 3531 *
3524 * LOCKING: 3532 * LOCKING:
3525 * EH context. 3533 * EH context.
3526 * 3534 *
3527 * RETURNS: 3535 * RETURNS:
3528 * 0 if @linke is ready before @deadline; otherwise, -errno. 3536 * 0 if @linke is ready before @deadline; otherwise, -errno.
3529 */ 3537 */
3530 int ata_wait_ready(struct ata_link *link, unsigned long deadline, 3538 int ata_wait_ready(struct ata_link *link, unsigned long deadline,
3531 int (*check_ready)(struct ata_link *link)) 3539 int (*check_ready)(struct ata_link *link))
3532 { 3540 {
3533 unsigned long start = jiffies; 3541 unsigned long start = jiffies;
3534 unsigned long nodev_deadline; 3542 unsigned long nodev_deadline;
3535 int warned = 0; 3543 int warned = 0;
3536 3544
3537 /* choose which 0xff timeout to use, read comment in libata.h */ 3545 /* choose which 0xff timeout to use, read comment in libata.h */
3538 if (link->ap->host->flags & ATA_HOST_PARALLEL_SCAN) 3546 if (link->ap->host->flags & ATA_HOST_PARALLEL_SCAN)
3539 nodev_deadline = ata_deadline(start, ATA_TMOUT_FF_WAIT_LONG); 3547 nodev_deadline = ata_deadline(start, ATA_TMOUT_FF_WAIT_LONG);
3540 else 3548 else
3541 nodev_deadline = ata_deadline(start, ATA_TMOUT_FF_WAIT); 3549 nodev_deadline = ata_deadline(start, ATA_TMOUT_FF_WAIT);
3542 3550
3543 /* Slave readiness can't be tested separately from master. On 3551 /* Slave readiness can't be tested separately from master. On
3544 * M/S emulation configuration, this function should be called 3552 * M/S emulation configuration, this function should be called
3545 * only on the master and it will handle both master and slave. 3553 * only on the master and it will handle both master and slave.
3546 */ 3554 */
3547 WARN_ON(link == link->ap->slave_link); 3555 WARN_ON(link == link->ap->slave_link);
3548 3556
3549 if (time_after(nodev_deadline, deadline)) 3557 if (time_after(nodev_deadline, deadline))
3550 nodev_deadline = deadline; 3558 nodev_deadline = deadline;
3551 3559
3552 while (1) { 3560 while (1) {
3553 unsigned long now = jiffies; 3561 unsigned long now = jiffies;
3554 int ready, tmp; 3562 int ready, tmp;
3555 3563
3556 ready = tmp = check_ready(link); 3564 ready = tmp = check_ready(link);
3557 if (ready > 0) 3565 if (ready > 0)
3558 return 0; 3566 return 0;
3559 3567
3560 /* 3568 /*
3561 * -ENODEV could be transient. Ignore -ENODEV if link 3569 * -ENODEV could be transient. Ignore -ENODEV if link
3562 * is online. Also, some SATA devices take a long 3570 * is online. Also, some SATA devices take a long
3563 * time to clear 0xff after reset. Wait for 3571 * time to clear 0xff after reset. Wait for
3564 * ATA_TMOUT_FF_WAIT[_LONG] on -ENODEV if link isn't 3572 * ATA_TMOUT_FF_WAIT[_LONG] on -ENODEV if link isn't
3565 * offline. 3573 * offline.
3566 * 3574 *
3567 * Note that some PATA controllers (pata_ali) explode 3575 * Note that some PATA controllers (pata_ali) explode
3568 * if status register is read more than once when 3576 * if status register is read more than once when
3569 * there's no device attached. 3577 * there's no device attached.
3570 */ 3578 */
3571 if (ready == -ENODEV) { 3579 if (ready == -ENODEV) {
3572 if (ata_link_online(link)) 3580 if (ata_link_online(link))
3573 ready = 0; 3581 ready = 0;
3574 else if ((link->ap->flags & ATA_FLAG_SATA) && 3582 else if ((link->ap->flags & ATA_FLAG_SATA) &&
3575 !ata_link_offline(link) && 3583 !ata_link_offline(link) &&
3576 time_before(now, nodev_deadline)) 3584 time_before(now, nodev_deadline))
3577 ready = 0; 3585 ready = 0;
3578 } 3586 }
3579 3587
3580 if (ready) 3588 if (ready)
3581 return ready; 3589 return ready;
3582 if (time_after(now, deadline)) 3590 if (time_after(now, deadline))
3583 return -EBUSY; 3591 return -EBUSY;
3584 3592
3585 if (!warned && time_after(now, start + 5 * HZ) && 3593 if (!warned && time_after(now, start + 5 * HZ) &&
3586 (deadline - now > 3 * HZ)) { 3594 (deadline - now > 3 * HZ)) {
3587 ata_link_printk(link, KERN_WARNING, 3595 ata_link_printk(link, KERN_WARNING,
3588 "link is slow to respond, please be patient " 3596 "link is slow to respond, please be patient "
3589 "(ready=%d)\n", tmp); 3597 "(ready=%d)\n", tmp);
3590 warned = 1; 3598 warned = 1;
3591 } 3599 }
3592 3600
3593 msleep(50); 3601 msleep(50);
3594 } 3602 }
3595 } 3603 }
3596 3604
3597 /** 3605 /**
3598 * ata_wait_after_reset - wait for link to become ready after reset 3606 * ata_wait_after_reset - wait for link to become ready after reset
3599 * @link: link to be waited on 3607 * @link: link to be waited on
3600 * @deadline: deadline jiffies for the operation 3608 * @deadline: deadline jiffies for the operation
3601 * @check_ready: callback to check link readiness 3609 * @check_ready: callback to check link readiness
3602 * 3610 *
3603 * Wait for @link to become ready after reset. 3611 * Wait for @link to become ready after reset.
3604 * 3612 *
3605 * LOCKING: 3613 * LOCKING:
3606 * EH context. 3614 * EH context.
3607 * 3615 *
3608 * RETURNS: 3616 * RETURNS:
3609 * 0 if @linke is ready before @deadline; otherwise, -errno. 3617 * 0 if @linke is ready before @deadline; otherwise, -errno.
3610 */ 3618 */
3611 int ata_wait_after_reset(struct ata_link *link, unsigned long deadline, 3619 int ata_wait_after_reset(struct ata_link *link, unsigned long deadline,
3612 int (*check_ready)(struct ata_link *link)) 3620 int (*check_ready)(struct ata_link *link))
3613 { 3621 {
3614 msleep(ATA_WAIT_AFTER_RESET); 3622 msleep(ATA_WAIT_AFTER_RESET);
3615 3623
3616 return ata_wait_ready(link, deadline, check_ready); 3624 return ata_wait_ready(link, deadline, check_ready);
3617 } 3625 }
3618 3626
3619 /** 3627 /**
3620 * sata_link_debounce - debounce SATA phy status 3628 * sata_link_debounce - debounce SATA phy status
3621 * @link: ATA link to debounce SATA phy status for 3629 * @link: ATA link to debounce SATA phy status for
3622 * @params: timing parameters { interval, duratinon, timeout } in msec 3630 * @params: timing parameters { interval, duratinon, timeout } in msec
3623 * @deadline: deadline jiffies for the operation 3631 * @deadline: deadline jiffies for the operation
3624 * 3632 *
3625 * Make sure SStatus of @link reaches stable state, determined by 3633 * Make sure SStatus of @link reaches stable state, determined by
3626 * holding the same value where DET is not 1 for @duration polled 3634 * holding the same value where DET is not 1 for @duration polled
3627 * every @interval, before @timeout. Timeout constraints the 3635 * every @interval, before @timeout. Timeout constraints the
3628 * beginning of the stable state. Because DET gets stuck at 1 on 3636 * beginning of the stable state. Because DET gets stuck at 1 on
3629 * some controllers after hot unplugging, this functions waits 3637 * some controllers after hot unplugging, this functions waits
3630 * until timeout then returns 0 if DET is stable at 1. 3638 * until timeout then returns 0 if DET is stable at 1.
3631 * 3639 *
3632 * @timeout is further limited by @deadline. The sooner of the 3640 * @timeout is further limited by @deadline. The sooner of the
3633 * two is used. 3641 * two is used.
3634 * 3642 *
3635 * LOCKING: 3643 * LOCKING:
3636 * Kernel thread context (may sleep) 3644 * Kernel thread context (may sleep)
3637 * 3645 *
3638 * RETURNS: 3646 * RETURNS:
3639 * 0 on success, -errno on failure. 3647 * 0 on success, -errno on failure.
3640 */ 3648 */
3641 int sata_link_debounce(struct ata_link *link, const unsigned long *params, 3649 int sata_link_debounce(struct ata_link *link, const unsigned long *params,
3642 unsigned long deadline) 3650 unsigned long deadline)
3643 { 3651 {
3644 unsigned long interval = params[0]; 3652 unsigned long interval = params[0];
3645 unsigned long duration = params[1]; 3653 unsigned long duration = params[1];
3646 unsigned long last_jiffies, t; 3654 unsigned long last_jiffies, t;
3647 u32 last, cur; 3655 u32 last, cur;
3648 int rc; 3656 int rc;
3649 3657
3650 t = ata_deadline(jiffies, params[2]); 3658 t = ata_deadline(jiffies, params[2]);
3651 if (time_before(t, deadline)) 3659 if (time_before(t, deadline))
3652 deadline = t; 3660 deadline = t;
3653 3661
3654 if ((rc = sata_scr_read(link, SCR_STATUS, &cur))) 3662 if ((rc = sata_scr_read(link, SCR_STATUS, &cur)))
3655 return rc; 3663 return rc;
3656 cur &= 0xf; 3664 cur &= 0xf;
3657 3665
3658 last = cur; 3666 last = cur;
3659 last_jiffies = jiffies; 3667 last_jiffies = jiffies;
3660 3668
3661 while (1) { 3669 while (1) {
3662 msleep(interval); 3670 msleep(interval);
3663 if ((rc = sata_scr_read(link, SCR_STATUS, &cur))) 3671 if ((rc = sata_scr_read(link, SCR_STATUS, &cur)))
3664 return rc; 3672 return rc;
3665 cur &= 0xf; 3673 cur &= 0xf;
3666 3674
3667 /* DET stable? */ 3675 /* DET stable? */
3668 if (cur == last) { 3676 if (cur == last) {
3669 if (cur == 1 && time_before(jiffies, deadline)) 3677 if (cur == 1 && time_before(jiffies, deadline))
3670 continue; 3678 continue;
3671 if (time_after(jiffies, 3679 if (time_after(jiffies,
3672 ata_deadline(last_jiffies, duration))) 3680 ata_deadline(last_jiffies, duration)))
3673 return 0; 3681 return 0;
3674 continue; 3682 continue;
3675 } 3683 }
3676 3684
3677 /* unstable, start over */ 3685 /* unstable, start over */
3678 last = cur; 3686 last = cur;
3679 last_jiffies = jiffies; 3687 last_jiffies = jiffies;
3680 3688
3681 /* Check deadline. If debouncing failed, return 3689 /* Check deadline. If debouncing failed, return
3682 * -EPIPE to tell upper layer to lower link speed. 3690 * -EPIPE to tell upper layer to lower link speed.
3683 */ 3691 */
3684 if (time_after(jiffies, deadline)) 3692 if (time_after(jiffies, deadline))
3685 return -EPIPE; 3693 return -EPIPE;
3686 } 3694 }
3687 } 3695 }
3688 3696
3689 /** 3697 /**
3690 * sata_link_resume - resume SATA link 3698 * sata_link_resume - resume SATA link
3691 * @link: ATA link to resume SATA 3699 * @link: ATA link to resume SATA
3692 * @params: timing parameters { interval, duratinon, timeout } in msec 3700 * @params: timing parameters { interval, duratinon, timeout } in msec
3693 * @deadline: deadline jiffies for the operation 3701 * @deadline: deadline jiffies for the operation
3694 * 3702 *
3695 * Resume SATA phy @link and debounce it. 3703 * Resume SATA phy @link and debounce it.
3696 * 3704 *
3697 * LOCKING: 3705 * LOCKING:
3698 * Kernel thread context (may sleep) 3706 * Kernel thread context (may sleep)
3699 * 3707 *
3700 * RETURNS: 3708 * RETURNS:
3701 * 0 on success, -errno on failure. 3709 * 0 on success, -errno on failure.
3702 */ 3710 */
3703 int sata_link_resume(struct ata_link *link, const unsigned long *params, 3711 int sata_link_resume(struct ata_link *link, const unsigned long *params,
3704 unsigned long deadline) 3712 unsigned long deadline)
3705 { 3713 {
3706 int tries = ATA_LINK_RESUME_TRIES; 3714 int tries = ATA_LINK_RESUME_TRIES;
3707 u32 scontrol, serror; 3715 u32 scontrol, serror;
3708 int rc; 3716 int rc;
3709 3717
3710 if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol))) 3718 if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol)))
3711 return rc; 3719 return rc;
3712 3720
3713 /* 3721 /*
3714 * Writes to SControl sometimes get ignored under certain 3722 * Writes to SControl sometimes get ignored under certain
3715 * controllers (ata_piix SIDPR). Make sure DET actually is 3723 * controllers (ata_piix SIDPR). Make sure DET actually is
3716 * cleared. 3724 * cleared.
3717 */ 3725 */
3718 do { 3726 do {
3719 scontrol = (scontrol & 0x0f0) | 0x300; 3727 scontrol = (scontrol & 0x0f0) | 0x300;
3720 if ((rc = sata_scr_write(link, SCR_CONTROL, scontrol))) 3728 if ((rc = sata_scr_write(link, SCR_CONTROL, scontrol)))
3721 return rc; 3729 return rc;
3722 /* 3730 /*
3723 * Some PHYs react badly if SStatus is pounded 3731 * Some PHYs react badly if SStatus is pounded
3724 * immediately after resuming. Delay 200ms before 3732 * immediately after resuming. Delay 200ms before
3725 * debouncing. 3733 * debouncing.
3726 */ 3734 */
3727 msleep(200); 3735 msleep(200);
3728 3736
3729 /* is SControl restored correctly? */ 3737 /* is SControl restored correctly? */
3730 if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol))) 3738 if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol)))
3731 return rc; 3739 return rc;
3732 } while ((scontrol & 0xf0f) != 0x300 && --tries); 3740 } while ((scontrol & 0xf0f) != 0x300 && --tries);
3733 3741
3734 if ((scontrol & 0xf0f) != 0x300) { 3742 if ((scontrol & 0xf0f) != 0x300) {
3735 ata_link_printk(link, KERN_ERR, 3743 ata_link_printk(link, KERN_ERR,
3736 "failed to resume link (SControl %X)\n", 3744 "failed to resume link (SControl %X)\n",
3737 scontrol); 3745 scontrol);
3738 return 0; 3746 return 0;
3739 } 3747 }
3740 3748
3741 if (tries < ATA_LINK_RESUME_TRIES) 3749 if (tries < ATA_LINK_RESUME_TRIES)
3742 ata_link_printk(link, KERN_WARNING, 3750 ata_link_printk(link, KERN_WARNING,
3743 "link resume succeeded after %d retries\n", 3751 "link resume succeeded after %d retries\n",
3744 ATA_LINK_RESUME_TRIES - tries); 3752 ATA_LINK_RESUME_TRIES - tries);
3745 3753
3746 if ((rc = sata_link_debounce(link, params, deadline))) 3754 if ((rc = sata_link_debounce(link, params, deadline)))
3747 return rc; 3755 return rc;
3748 3756
3749 /* clear SError, some PHYs require this even for SRST to work */ 3757 /* clear SError, some PHYs require this even for SRST to work */
3750 if (!(rc = sata_scr_read(link, SCR_ERROR, &serror))) 3758 if (!(rc = sata_scr_read(link, SCR_ERROR, &serror)))
3751 rc = sata_scr_write(link, SCR_ERROR, serror); 3759 rc = sata_scr_write(link, SCR_ERROR, serror);
3752 3760
3753 return rc != -EINVAL ? rc : 0; 3761 return rc != -EINVAL ? rc : 0;
3754 } 3762 }
3755 3763
3756 /** 3764 /**
3757 * ata_std_prereset - prepare for reset 3765 * ata_std_prereset - prepare for reset
3758 * @link: ATA link to be reset 3766 * @link: ATA link to be reset
3759 * @deadline: deadline jiffies for the operation 3767 * @deadline: deadline jiffies for the operation
3760 * 3768 *
3761 * @link is about to be reset. Initialize it. Failure from 3769 * @link is about to be reset. Initialize it. Failure from
3762 * prereset makes libata abort whole reset sequence and give up 3770 * prereset makes libata abort whole reset sequence and give up
3763 * that port, so prereset should be best-effort. It does its 3771 * that port, so prereset should be best-effort. It does its
3764 * best to prepare for reset sequence but if things go wrong, it 3772 * best to prepare for reset sequence but if things go wrong, it
3765 * should just whine, not fail. 3773 * should just whine, not fail.
3766 * 3774 *
3767 * LOCKING: 3775 * LOCKING:
3768 * Kernel thread context (may sleep) 3776 * Kernel thread context (may sleep)
3769 * 3777 *
3770 * RETURNS: 3778 * RETURNS:
3771 * 0 on success, -errno otherwise. 3779 * 0 on success, -errno otherwise.
3772 */ 3780 */
3773 int ata_std_prereset(struct ata_link *link, unsigned long deadline) 3781 int ata_std_prereset(struct ata_link *link, unsigned long deadline)
3774 { 3782 {
3775 struct ata_port *ap = link->ap; 3783 struct ata_port *ap = link->ap;
3776 struct ata_eh_context *ehc = &link->eh_context; 3784 struct ata_eh_context *ehc = &link->eh_context;
3777 const unsigned long *timing = sata_ehc_deb_timing(ehc); 3785 const unsigned long *timing = sata_ehc_deb_timing(ehc);
3778 int rc; 3786 int rc;
3779 3787
3780 /* if we're about to do hardreset, nothing more to do */ 3788 /* if we're about to do hardreset, nothing more to do */
3781 if (ehc->i.action & ATA_EH_HARDRESET) 3789 if (ehc->i.action & ATA_EH_HARDRESET)
3782 return 0; 3790 return 0;
3783 3791
3784 /* if SATA, resume link */ 3792 /* if SATA, resume link */
3785 if (ap->flags & ATA_FLAG_SATA) { 3793 if (ap->flags & ATA_FLAG_SATA) {
3786 rc = sata_link_resume(link, timing, deadline); 3794 rc = sata_link_resume(link, timing, deadline);
3787 /* whine about phy resume failure but proceed */ 3795 /* whine about phy resume failure but proceed */
3788 if (rc && rc != -EOPNOTSUPP) 3796 if (rc && rc != -EOPNOTSUPP)
3789 ata_link_printk(link, KERN_WARNING, "failed to resume " 3797 ata_link_printk(link, KERN_WARNING, "failed to resume "
3790 "link for reset (errno=%d)\n", rc); 3798 "link for reset (errno=%d)\n", rc);
3791 } 3799 }
3792 3800
3793 /* no point in trying softreset on offline link */ 3801 /* no point in trying softreset on offline link */
3794 if (ata_phys_link_offline(link)) 3802 if (ata_phys_link_offline(link))
3795 ehc->i.action &= ~ATA_EH_SOFTRESET; 3803 ehc->i.action &= ~ATA_EH_SOFTRESET;
3796 3804
3797 return 0; 3805 return 0;
3798 } 3806 }
3799 3807
3800 /** 3808 /**
3801 * sata_link_hardreset - reset link via SATA phy reset 3809 * sata_link_hardreset - reset link via SATA phy reset
3802 * @link: link to reset 3810 * @link: link to reset
3803 * @timing: timing parameters { interval, duratinon, timeout } in msec 3811 * @timing: timing parameters { interval, duratinon, timeout } in msec
3804 * @deadline: deadline jiffies for the operation 3812 * @deadline: deadline jiffies for the operation
3805 * @online: optional out parameter indicating link onlineness 3813 * @online: optional out parameter indicating link onlineness
3806 * @check_ready: optional callback to check link readiness 3814 * @check_ready: optional callback to check link readiness
3807 * 3815 *
3808 * SATA phy-reset @link using DET bits of SControl register. 3816 * SATA phy-reset @link using DET bits of SControl register.
3809 * After hardreset, link readiness is waited upon using 3817 * After hardreset, link readiness is waited upon using
3810 * ata_wait_ready() if @check_ready is specified. LLDs are 3818 * ata_wait_ready() if @check_ready is specified. LLDs are
3811 * allowed to not specify @check_ready and wait itself after this 3819 * allowed to not specify @check_ready and wait itself after this
3812 * function returns. Device classification is LLD's 3820 * function returns. Device classification is LLD's
3813 * responsibility. 3821 * responsibility.
3814 * 3822 *
3815 * *@online is set to one iff reset succeeded and @link is online 3823 * *@online is set to one iff reset succeeded and @link is online
3816 * after reset. 3824 * after reset.
3817 * 3825 *
3818 * LOCKING: 3826 * LOCKING:
3819 * Kernel thread context (may sleep) 3827 * Kernel thread context (may sleep)
3820 * 3828 *
3821 * RETURNS: 3829 * RETURNS:
3822 * 0 on success, -errno otherwise. 3830 * 0 on success, -errno otherwise.
3823 */ 3831 */
3824 int sata_link_hardreset(struct ata_link *link, const unsigned long *timing, 3832 int sata_link_hardreset(struct ata_link *link, const unsigned long *timing,
3825 unsigned long deadline, 3833 unsigned long deadline,
3826 bool *online, int (*check_ready)(struct ata_link *)) 3834 bool *online, int (*check_ready)(struct ata_link *))
3827 { 3835 {
3828 u32 scontrol; 3836 u32 scontrol;
3829 int rc; 3837 int rc;
3830 3838
3831 DPRINTK("ENTER\n"); 3839 DPRINTK("ENTER\n");
3832 3840
3833 if (online) 3841 if (online)
3834 *online = false; 3842 *online = false;
3835 3843
3836 if (sata_set_spd_needed(link)) { 3844 if (sata_set_spd_needed(link)) {
3837 /* SATA spec says nothing about how to reconfigure 3845 /* SATA spec says nothing about how to reconfigure
3838 * spd. To be on the safe side, turn off phy during 3846 * spd. To be on the safe side, turn off phy during
3839 * reconfiguration. This works for at least ICH7 AHCI 3847 * reconfiguration. This works for at least ICH7 AHCI
3840 * and Sil3124. 3848 * and Sil3124.
3841 */ 3849 */
3842 if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol))) 3850 if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol)))
3843 goto out; 3851 goto out;
3844 3852
3845 scontrol = (scontrol & 0x0f0) | 0x304; 3853 scontrol = (scontrol & 0x0f0) | 0x304;
3846 3854
3847 if ((rc = sata_scr_write(link, SCR_CONTROL, scontrol))) 3855 if ((rc = sata_scr_write(link, SCR_CONTROL, scontrol)))
3848 goto out; 3856 goto out;
3849 3857
3850 sata_set_spd(link); 3858 sata_set_spd(link);
3851 } 3859 }
3852 3860
3853 /* issue phy wake/reset */ 3861 /* issue phy wake/reset */
3854 if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol))) 3862 if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol)))
3855 goto out; 3863 goto out;
3856 3864
3857 scontrol = (scontrol & 0x0f0) | 0x301; 3865 scontrol = (scontrol & 0x0f0) | 0x301;
3858 3866
3859 if ((rc = sata_scr_write_flush(link, SCR_CONTROL, scontrol))) 3867 if ((rc = sata_scr_write_flush(link, SCR_CONTROL, scontrol)))
3860 goto out; 3868 goto out;
3861 3869
3862 /* Couldn't find anything in SATA I/II specs, but AHCI-1.1 3870 /* Couldn't find anything in SATA I/II specs, but AHCI-1.1
3863 * 10.4.2 says at least 1 ms. 3871 * 10.4.2 says at least 1 ms.
3864 */ 3872 */
3865 msleep(1); 3873 msleep(1);
3866 3874
3867 /* bring link back */ 3875 /* bring link back */
3868 rc = sata_link_resume(link, timing, deadline); 3876 rc = sata_link_resume(link, timing, deadline);
3869 if (rc) 3877 if (rc)
3870 goto out; 3878 goto out;
3871 /* if link is offline nothing more to do */ 3879 /* if link is offline nothing more to do */
3872 if (ata_phys_link_offline(link)) 3880 if (ata_phys_link_offline(link))
3873 goto out; 3881 goto out;
3874 3882
3875 /* Link is online. From this point, -ENODEV too is an error. */ 3883 /* Link is online. From this point, -ENODEV too is an error. */
3876 if (online) 3884 if (online)
3877 *online = true; 3885 *online = true;
3878 3886
3879 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) { 3887 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) {
3880 /* If PMP is supported, we have to do follow-up SRST. 3888 /* If PMP is supported, we have to do follow-up SRST.
3881 * Some PMPs don't send D2H Reg FIS after hardreset if 3889 * Some PMPs don't send D2H Reg FIS after hardreset if
3882 * the first port is empty. Wait only for 3890 * the first port is empty. Wait only for
3883 * ATA_TMOUT_PMP_SRST_WAIT. 3891 * ATA_TMOUT_PMP_SRST_WAIT.
3884 */ 3892 */
3885 if (check_ready) { 3893 if (check_ready) {
3886 unsigned long pmp_deadline; 3894 unsigned long pmp_deadline;
3887 3895
3888 pmp_deadline = ata_deadline(jiffies, 3896 pmp_deadline = ata_deadline(jiffies,
3889 ATA_TMOUT_PMP_SRST_WAIT); 3897 ATA_TMOUT_PMP_SRST_WAIT);
3890 if (time_after(pmp_deadline, deadline)) 3898 if (time_after(pmp_deadline, deadline))
3891 pmp_deadline = deadline; 3899 pmp_deadline = deadline;
3892 ata_wait_ready(link, pmp_deadline, check_ready); 3900 ata_wait_ready(link, pmp_deadline, check_ready);
3893 } 3901 }
3894 rc = -EAGAIN; 3902 rc = -EAGAIN;
3895 goto out; 3903 goto out;
3896 } 3904 }
3897 3905
3898 rc = 0; 3906 rc = 0;
3899 if (check_ready) 3907 if (check_ready)
3900 rc = ata_wait_ready(link, deadline, check_ready); 3908 rc = ata_wait_ready(link, deadline, check_ready);
3901 out: 3909 out:
3902 if (rc && rc != -EAGAIN) { 3910 if (rc && rc != -EAGAIN) {
3903 /* online is set iff link is online && reset succeeded */ 3911 /* online is set iff link is online && reset succeeded */
3904 if (online) 3912 if (online)
3905 *online = false; 3913 *online = false;
3906 ata_link_printk(link, KERN_ERR, 3914 ata_link_printk(link, KERN_ERR,
3907 "COMRESET failed (errno=%d)\n", rc); 3915 "COMRESET failed (errno=%d)\n", rc);
3908 } 3916 }
3909 DPRINTK("EXIT, rc=%d\n", rc); 3917 DPRINTK("EXIT, rc=%d\n", rc);
3910 return rc; 3918 return rc;
3911 } 3919 }
3912 3920
3913 /** 3921 /**
3914 * sata_std_hardreset - COMRESET w/o waiting or classification 3922 * sata_std_hardreset - COMRESET w/o waiting or classification
3915 * @link: link to reset 3923 * @link: link to reset
3916 * @class: resulting class of attached device 3924 * @class: resulting class of attached device
3917 * @deadline: deadline jiffies for the operation 3925 * @deadline: deadline jiffies for the operation
3918 * 3926 *
3919 * Standard SATA COMRESET w/o waiting or classification. 3927 * Standard SATA COMRESET w/o waiting or classification.
3920 * 3928 *
3921 * LOCKING: 3929 * LOCKING:
3922 * Kernel thread context (may sleep) 3930 * Kernel thread context (may sleep)
3923 * 3931 *
3924 * RETURNS: 3932 * RETURNS:
3925 * 0 if link offline, -EAGAIN if link online, -errno on errors. 3933 * 0 if link offline, -EAGAIN if link online, -errno on errors.
3926 */ 3934 */
3927 int sata_std_hardreset(struct ata_link *link, unsigned int *class, 3935 int sata_std_hardreset(struct ata_link *link, unsigned int *class,
3928 unsigned long deadline) 3936 unsigned long deadline)
3929 { 3937 {
3930 const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context); 3938 const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context);
3931 bool online; 3939 bool online;
3932 int rc; 3940 int rc;
3933 3941
3934 /* do hardreset */ 3942 /* do hardreset */
3935 rc = sata_link_hardreset(link, timing, deadline, &online, NULL); 3943 rc = sata_link_hardreset(link, timing, deadline, &online, NULL);
3936 return online ? -EAGAIN : rc; 3944 return online ? -EAGAIN : rc;
3937 } 3945 }
3938 3946
3939 /** 3947 /**
3940 * ata_std_postreset - standard postreset callback 3948 * ata_std_postreset - standard postreset callback
3941 * @link: the target ata_link 3949 * @link: the target ata_link
3942 * @classes: classes of attached devices 3950 * @classes: classes of attached devices
3943 * 3951 *
3944 * This function is invoked after a successful reset. Note that 3952 * This function is invoked after a successful reset. Note that
3945 * the device might have been reset more than once using 3953 * the device might have been reset more than once using
3946 * different reset methods before postreset is invoked. 3954 * different reset methods before postreset is invoked.
3947 * 3955 *
3948 * LOCKING: 3956 * LOCKING:
3949 * Kernel thread context (may sleep) 3957 * Kernel thread context (may sleep)
3950 */ 3958 */
3951 void ata_std_postreset(struct ata_link *link, unsigned int *classes) 3959 void ata_std_postreset(struct ata_link *link, unsigned int *classes)
3952 { 3960 {
3953 u32 serror; 3961 u32 serror;
3954 3962
3955 DPRINTK("ENTER\n"); 3963 DPRINTK("ENTER\n");
3956 3964
3957 /* reset complete, clear SError */ 3965 /* reset complete, clear SError */
3958 if (!sata_scr_read(link, SCR_ERROR, &serror)) 3966 if (!sata_scr_read(link, SCR_ERROR, &serror))
3959 sata_scr_write(link, SCR_ERROR, serror); 3967 sata_scr_write(link, SCR_ERROR, serror);
3960 3968
3961 /* print link status */ 3969 /* print link status */
3962 sata_print_link_status(link); 3970 sata_print_link_status(link);
3963 3971
3964 DPRINTK("EXIT\n"); 3972 DPRINTK("EXIT\n");
3965 } 3973 }
3966 3974
3967 /** 3975 /**
3968 * ata_dev_same_device - Determine whether new ID matches configured device 3976 * ata_dev_same_device - Determine whether new ID matches configured device
3969 * @dev: device to compare against 3977 * @dev: device to compare against
3970 * @new_class: class of the new device 3978 * @new_class: class of the new device
3971 * @new_id: IDENTIFY page of the new device 3979 * @new_id: IDENTIFY page of the new device
3972 * 3980 *
3973 * Compare @new_class and @new_id against @dev and determine 3981 * Compare @new_class and @new_id against @dev and determine
3974 * whether @dev is the device indicated by @new_class and 3982 * whether @dev is the device indicated by @new_class and
3975 * @new_id. 3983 * @new_id.
3976 * 3984 *
3977 * LOCKING: 3985 * LOCKING:
3978 * None. 3986 * None.
3979 * 3987 *
3980 * RETURNS: 3988 * RETURNS:
3981 * 1 if @dev matches @new_class and @new_id, 0 otherwise. 3989 * 1 if @dev matches @new_class and @new_id, 0 otherwise.
3982 */ 3990 */
3983 static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class, 3991 static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
3984 const u16 *new_id) 3992 const u16 *new_id)
3985 { 3993 {
3986 const u16 *old_id = dev->id; 3994 const u16 *old_id = dev->id;
3987 unsigned char model[2][ATA_ID_PROD_LEN + 1]; 3995 unsigned char model[2][ATA_ID_PROD_LEN + 1];
3988 unsigned char serial[2][ATA_ID_SERNO_LEN + 1]; 3996 unsigned char serial[2][ATA_ID_SERNO_LEN + 1];
3989 3997
3990 if (dev->class != new_class) { 3998 if (dev->class != new_class) {
3991 ata_dev_printk(dev, KERN_INFO, "class mismatch %d != %d\n", 3999 ata_dev_printk(dev, KERN_INFO, "class mismatch %d != %d\n",
3992 dev->class, new_class); 4000 dev->class, new_class);
3993 return 0; 4001 return 0;
3994 } 4002 }
3995 4003
3996 ata_id_c_string(old_id, model[0], ATA_ID_PROD, sizeof(model[0])); 4004 ata_id_c_string(old_id, model[0], ATA_ID_PROD, sizeof(model[0]));
3997 ata_id_c_string(new_id, model[1], ATA_ID_PROD, sizeof(model[1])); 4005 ata_id_c_string(new_id, model[1], ATA_ID_PROD, sizeof(model[1]));
3998 ata_id_c_string(old_id, serial[0], ATA_ID_SERNO, sizeof(serial[0])); 4006 ata_id_c_string(old_id, serial[0], ATA_ID_SERNO, sizeof(serial[0]));
3999 ata_id_c_string(new_id, serial[1], ATA_ID_SERNO, sizeof(serial[1])); 4007 ata_id_c_string(new_id, serial[1], ATA_ID_SERNO, sizeof(serial[1]));
4000 4008
4001 if (strcmp(model[0], model[1])) { 4009 if (strcmp(model[0], model[1])) {
4002 ata_dev_printk(dev, KERN_INFO, "model number mismatch " 4010 ata_dev_printk(dev, KERN_INFO, "model number mismatch "
4003 "'%s' != '%s'\n", model[0], model[1]); 4011 "'%s' != '%s'\n", model[0], model[1]);
4004 return 0; 4012 return 0;
4005 } 4013 }
4006 4014
4007 if (strcmp(serial[0], serial[1])) { 4015 if (strcmp(serial[0], serial[1])) {
4008 ata_dev_printk(dev, KERN_INFO, "serial number mismatch " 4016 ata_dev_printk(dev, KERN_INFO, "serial number mismatch "
4009 "'%s' != '%s'\n", serial[0], serial[1]); 4017 "'%s' != '%s'\n", serial[0], serial[1]);
4010 return 0; 4018 return 0;
4011 } 4019 }
4012 4020
4013 return 1; 4021 return 1;
4014 } 4022 }
4015 4023
4016 /** 4024 /**
4017 * ata_dev_reread_id - Re-read IDENTIFY data 4025 * ata_dev_reread_id - Re-read IDENTIFY data
4018 * @dev: target ATA device 4026 * @dev: target ATA device
4019 * @readid_flags: read ID flags 4027 * @readid_flags: read ID flags
4020 * 4028 *
4021 * Re-read IDENTIFY page and make sure @dev is still attached to 4029 * Re-read IDENTIFY page and make sure @dev is still attached to
4022 * the port. 4030 * the port.
4023 * 4031 *
4024 * LOCKING: 4032 * LOCKING:
4025 * Kernel thread context (may sleep) 4033 * Kernel thread context (may sleep)
4026 * 4034 *
4027 * RETURNS: 4035 * RETURNS:
4028 * 0 on success, negative errno otherwise 4036 * 0 on success, negative errno otherwise
4029 */ 4037 */
4030 int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags) 4038 int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags)
4031 { 4039 {
4032 unsigned int class = dev->class; 4040 unsigned int class = dev->class;
4033 u16 *id = (void *)dev->link->ap->sector_buf; 4041 u16 *id = (void *)dev->link->ap->sector_buf;
4034 int rc; 4042 int rc;
4035 4043
4036 /* read ID data */ 4044 /* read ID data */
4037 rc = ata_dev_read_id(dev, &class, readid_flags, id); 4045 rc = ata_dev_read_id(dev, &class, readid_flags, id);
4038 if (rc) 4046 if (rc)
4039 return rc; 4047 return rc;
4040 4048
4041 /* is the device still there? */ 4049 /* is the device still there? */
4042 if (!ata_dev_same_device(dev, class, id)) 4050 if (!ata_dev_same_device(dev, class, id))
4043 return -ENODEV; 4051 return -ENODEV;
4044 4052
4045 memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS); 4053 memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS);
4046 return 0; 4054 return 0;
4047 } 4055 }
4048 4056
4049 /** 4057 /**
4050 * ata_dev_revalidate - Revalidate ATA device 4058 * ata_dev_revalidate - Revalidate ATA device
4051 * @dev: device to revalidate 4059 * @dev: device to revalidate
4052 * @new_class: new class code 4060 * @new_class: new class code
4053 * @readid_flags: read ID flags 4061 * @readid_flags: read ID flags
4054 * 4062 *
4055 * Re-read IDENTIFY page, make sure @dev is still attached to the 4063 * Re-read IDENTIFY page, make sure @dev is still attached to the
4056 * port and reconfigure it according to the new IDENTIFY page. 4064 * port and reconfigure it according to the new IDENTIFY page.
4057 * 4065 *
4058 * LOCKING: 4066 * LOCKING:
4059 * Kernel thread context (may sleep) 4067 * Kernel thread context (may sleep)
4060 * 4068 *
4061 * RETURNS: 4069 * RETURNS:
4062 * 0 on success, negative errno otherwise 4070 * 0 on success, negative errno otherwise
4063 */ 4071 */
4064 int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class, 4072 int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
4065 unsigned int readid_flags) 4073 unsigned int readid_flags)
4066 { 4074 {
4067 u64 n_sectors = dev->n_sectors; 4075 u64 n_sectors = dev->n_sectors;
4068 u64 n_native_sectors = dev->n_native_sectors; 4076 u64 n_native_sectors = dev->n_native_sectors;
4069 int rc; 4077 int rc;
4070 4078
4071 if (!ata_dev_enabled(dev)) 4079 if (!ata_dev_enabled(dev))
4072 return -ENODEV; 4080 return -ENODEV;
4073 4081
4074 /* fail early if !ATA && !ATAPI to avoid issuing [P]IDENTIFY to PMP */ 4082 /* fail early if !ATA && !ATAPI to avoid issuing [P]IDENTIFY to PMP */
4075 if (ata_class_enabled(new_class) && 4083 if (ata_class_enabled(new_class) &&
4076 new_class != ATA_DEV_ATA && 4084 new_class != ATA_DEV_ATA &&
4077 new_class != ATA_DEV_ATAPI && 4085 new_class != ATA_DEV_ATAPI &&
4078 new_class != ATA_DEV_SEMB) { 4086 new_class != ATA_DEV_SEMB) {
4079 ata_dev_printk(dev, KERN_INFO, "class mismatch %u != %u\n", 4087 ata_dev_printk(dev, KERN_INFO, "class mismatch %u != %u\n",
4080 dev->class, new_class); 4088 dev->class, new_class);
4081 rc = -ENODEV; 4089 rc = -ENODEV;
4082 goto fail; 4090 goto fail;
4083 } 4091 }
4084 4092
4085 /* re-read ID */ 4093 /* re-read ID */
4086 rc = ata_dev_reread_id(dev, readid_flags); 4094 rc = ata_dev_reread_id(dev, readid_flags);
4087 if (rc) 4095 if (rc)
4088 goto fail; 4096 goto fail;
4089 4097
4090 /* configure device according to the new ID */ 4098 /* configure device according to the new ID */
4091 rc = ata_dev_configure(dev); 4099 rc = ata_dev_configure(dev);
4092 if (rc) 4100 if (rc)
4093 goto fail; 4101 goto fail;
4094 4102
4095 /* verify n_sectors hasn't changed */ 4103 /* verify n_sectors hasn't changed */
4096 if (dev->class != ATA_DEV_ATA || !n_sectors || 4104 if (dev->class != ATA_DEV_ATA || !n_sectors ||
4097 dev->n_sectors == n_sectors) 4105 dev->n_sectors == n_sectors)
4098 return 0; 4106 return 0;
4099 4107
4100 /* n_sectors has changed */ 4108 /* n_sectors has changed */
4101 ata_dev_printk(dev, KERN_WARNING, "n_sectors mismatch %llu != %llu\n", 4109 ata_dev_printk(dev, KERN_WARNING, "n_sectors mismatch %llu != %llu\n",
4102 (unsigned long long)n_sectors, 4110 (unsigned long long)n_sectors,
4103 (unsigned long long)dev->n_sectors); 4111 (unsigned long long)dev->n_sectors);
4104 4112
4105 /* 4113 /*
4106 * Something could have caused HPA to be unlocked 4114 * Something could have caused HPA to be unlocked
4107 * involuntarily. If n_native_sectors hasn't changed and the 4115 * involuntarily. If n_native_sectors hasn't changed and the
4108 * new size matches it, keep the device. 4116 * new size matches it, keep the device.
4109 */ 4117 */
4110 if (dev->n_native_sectors == n_native_sectors && 4118 if (dev->n_native_sectors == n_native_sectors &&
4111 dev->n_sectors > n_sectors && dev->n_sectors == n_native_sectors) { 4119 dev->n_sectors > n_sectors && dev->n_sectors == n_native_sectors) {
4112 ata_dev_printk(dev, KERN_WARNING, 4120 ata_dev_printk(dev, KERN_WARNING,
4113 "new n_sectors matches native, probably " 4121 "new n_sectors matches native, probably "
4114 "late HPA unlock, continuing\n"); 4122 "late HPA unlock, continuing\n");
4115 /* keep using the old n_sectors */ 4123 /* keep using the old n_sectors */
4116 dev->n_sectors = n_sectors; 4124 dev->n_sectors = n_sectors;
4117 return 0; 4125 return 0;
4118 } 4126 }
4119 4127
4120 /* 4128 /*
4121 * Some BIOSes boot w/o HPA but resume w/ HPA locked. Try 4129 * Some BIOSes boot w/o HPA but resume w/ HPA locked. Try
4122 * unlocking HPA in those cases. 4130 * unlocking HPA in those cases.
4123 * 4131 *
4124 * https://bugzilla.kernel.org/show_bug.cgi?id=15396 4132 * https://bugzilla.kernel.org/show_bug.cgi?id=15396
4125 */ 4133 */
4126 if (dev->n_native_sectors == n_native_sectors && 4134 if (dev->n_native_sectors == n_native_sectors &&
4127 dev->n_sectors < n_sectors && n_sectors == n_native_sectors && 4135 dev->n_sectors < n_sectors && n_sectors == n_native_sectors &&
4128 !(dev->horkage & ATA_HORKAGE_BROKEN_HPA)) { 4136 !(dev->horkage & ATA_HORKAGE_BROKEN_HPA)) {
4129 ata_dev_printk(dev, KERN_WARNING, 4137 ata_dev_printk(dev, KERN_WARNING,
4130 "old n_sectors matches native, probably " 4138 "old n_sectors matches native, probably "
4131 "late HPA lock, will try to unlock HPA\n"); 4139 "late HPA lock, will try to unlock HPA\n");
4132 /* try unlocking HPA */ 4140 /* try unlocking HPA */
4133 dev->flags |= ATA_DFLAG_UNLOCK_HPA; 4141 dev->flags |= ATA_DFLAG_UNLOCK_HPA;
4134 rc = -EIO; 4142 rc = -EIO;
4135 } else 4143 } else
4136 rc = -ENODEV; 4144 rc = -ENODEV;
4137 4145
4138 /* restore original n_[native_]sectors and fail */ 4146 /* restore original n_[native_]sectors and fail */
4139 dev->n_native_sectors = n_native_sectors; 4147 dev->n_native_sectors = n_native_sectors;
4140 dev->n_sectors = n_sectors; 4148 dev->n_sectors = n_sectors;
4141 fail: 4149 fail:
4142 ata_dev_printk(dev, KERN_ERR, "revalidation failed (errno=%d)\n", rc); 4150 ata_dev_printk(dev, KERN_ERR, "revalidation failed (errno=%d)\n", rc);
4143 return rc; 4151 return rc;
4144 } 4152 }
4145 4153
4146 struct ata_blacklist_entry { 4154 struct ata_blacklist_entry {
4147 const char *model_num; 4155 const char *model_num;
4148 const char *model_rev; 4156 const char *model_rev;
4149 unsigned long horkage; 4157 unsigned long horkage;
4150 }; 4158 };
4151 4159
4152 static const struct ata_blacklist_entry ata_device_blacklist [] = { 4160 static const struct ata_blacklist_entry ata_device_blacklist [] = {
4153 /* Devices with DMA related problems under Linux */ 4161 /* Devices with DMA related problems under Linux */
4154 { "WDC AC11000H", NULL, ATA_HORKAGE_NODMA }, 4162 { "WDC AC11000H", NULL, ATA_HORKAGE_NODMA },
4155 { "WDC AC22100H", NULL, ATA_HORKAGE_NODMA }, 4163 { "WDC AC22100H", NULL, ATA_HORKAGE_NODMA },
4156 { "WDC AC32500H", NULL, ATA_HORKAGE_NODMA }, 4164 { "WDC AC32500H", NULL, ATA_HORKAGE_NODMA },
4157 { "WDC AC33100H", NULL, ATA_HORKAGE_NODMA }, 4165 { "WDC AC33100H", NULL, ATA_HORKAGE_NODMA },
4158 { "WDC AC31600H", NULL, ATA_HORKAGE_NODMA }, 4166 { "WDC AC31600H", NULL, ATA_HORKAGE_NODMA },
4159 { "WDC AC32100H", "24.09P07", ATA_HORKAGE_NODMA }, 4167 { "WDC AC32100H", "24.09P07", ATA_HORKAGE_NODMA },
4160 { "WDC AC23200L", "21.10N21", ATA_HORKAGE_NODMA }, 4168 { "WDC AC23200L", "21.10N21", ATA_HORKAGE_NODMA },
4161 { "Compaq CRD-8241B", NULL, ATA_HORKAGE_NODMA }, 4169 { "Compaq CRD-8241B", NULL, ATA_HORKAGE_NODMA },
4162 { "CRD-8400B", NULL, ATA_HORKAGE_NODMA }, 4170 { "CRD-8400B", NULL, ATA_HORKAGE_NODMA },
4163 { "CRD-8480B", NULL, ATA_HORKAGE_NODMA }, 4171 { "CRD-8480B", NULL, ATA_HORKAGE_NODMA },
4164 { "CRD-8482B", NULL, ATA_HORKAGE_NODMA }, 4172 { "CRD-8482B", NULL, ATA_HORKAGE_NODMA },
4165 { "CRD-84", NULL, ATA_HORKAGE_NODMA }, 4173 { "CRD-84", NULL, ATA_HORKAGE_NODMA },
4166 { "SanDisk SDP3B", NULL, ATA_HORKAGE_NODMA }, 4174 { "SanDisk SDP3B", NULL, ATA_HORKAGE_NODMA },
4167 { "SanDisk SDP3B-64", NULL, ATA_HORKAGE_NODMA }, 4175 { "SanDisk SDP3B-64", NULL, ATA_HORKAGE_NODMA },
4168 { "SANYO CD-ROM CRD", NULL, ATA_HORKAGE_NODMA }, 4176 { "SANYO CD-ROM CRD", NULL, ATA_HORKAGE_NODMA },
4169 { "HITACHI CDR-8", NULL, ATA_HORKAGE_NODMA }, 4177 { "HITACHI CDR-8", NULL, ATA_HORKAGE_NODMA },
4170 { "HITACHI CDR-8335", NULL, ATA_HORKAGE_NODMA }, 4178 { "HITACHI CDR-8335", NULL, ATA_HORKAGE_NODMA },
4171 { "HITACHI CDR-8435", NULL, ATA_HORKAGE_NODMA }, 4179 { "HITACHI CDR-8435", NULL, ATA_HORKAGE_NODMA },
4172 { "Toshiba CD-ROM XM-6202B", NULL, ATA_HORKAGE_NODMA }, 4180 { "Toshiba CD-ROM XM-6202B", NULL, ATA_HORKAGE_NODMA },
4173 { "TOSHIBA CD-ROM XM-1702BC", NULL, ATA_HORKAGE_NODMA }, 4181 { "TOSHIBA CD-ROM XM-1702BC", NULL, ATA_HORKAGE_NODMA },
4174 { "CD-532E-A", NULL, ATA_HORKAGE_NODMA }, 4182 { "CD-532E-A", NULL, ATA_HORKAGE_NODMA },
4175 { "E-IDE CD-ROM CR-840",NULL, ATA_HORKAGE_NODMA }, 4183 { "E-IDE CD-ROM CR-840",NULL, ATA_HORKAGE_NODMA },
4176 { "CD-ROM Drive/F5A", NULL, ATA_HORKAGE_NODMA }, 4184 { "CD-ROM Drive/F5A", NULL, ATA_HORKAGE_NODMA },
4177 { "WPI CDD-820", NULL, ATA_HORKAGE_NODMA }, 4185 { "WPI CDD-820", NULL, ATA_HORKAGE_NODMA },
4178 { "SAMSUNG CD-ROM SC-148C", NULL, ATA_HORKAGE_NODMA }, 4186 { "SAMSUNG CD-ROM SC-148C", NULL, ATA_HORKAGE_NODMA },
4179 { "SAMSUNG CD-ROM SC", NULL, ATA_HORKAGE_NODMA }, 4187 { "SAMSUNG CD-ROM SC", NULL, ATA_HORKAGE_NODMA },
4180 { "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL,ATA_HORKAGE_NODMA }, 4188 { "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL,ATA_HORKAGE_NODMA },
4181 { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA }, 4189 { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA },
4182 { "SAMSUNG CD-ROM SN-124", "N001", ATA_HORKAGE_NODMA }, 4190 { "SAMSUNG CD-ROM SN-124", "N001", ATA_HORKAGE_NODMA },
4183 { "Seagate STT20000A", NULL, ATA_HORKAGE_NODMA }, 4191 { "Seagate STT20000A", NULL, ATA_HORKAGE_NODMA },
4184 /* Odd clown on sil3726/4726 PMPs */ 4192 /* Odd clown on sil3726/4726 PMPs */
4185 { "Config Disk", NULL, ATA_HORKAGE_DISABLE }, 4193 { "Config Disk", NULL, ATA_HORKAGE_DISABLE },
4186 4194
4187 /* Weird ATAPI devices */ 4195 /* Weird ATAPI devices */
4188 { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_HORKAGE_MAX_SEC_128 }, 4196 { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_HORKAGE_MAX_SEC_128 },
4189 { "QUANTUM DAT DAT72-000", NULL, ATA_HORKAGE_ATAPI_MOD16_DMA }, 4197 { "QUANTUM DAT DAT72-000", NULL, ATA_HORKAGE_ATAPI_MOD16_DMA },
4190 4198
4191 /* Devices we expect to fail diagnostics */ 4199 /* Devices we expect to fail diagnostics */
4192 4200
4193 /* Devices where NCQ should be avoided */ 4201 /* Devices where NCQ should be avoided */
4194 /* NCQ is slow */ 4202 /* NCQ is slow */
4195 { "WDC WD740ADFD-00", NULL, ATA_HORKAGE_NONCQ }, 4203 { "WDC WD740ADFD-00", NULL, ATA_HORKAGE_NONCQ },
4196 { "WDC WD740ADFD-00NLR1", NULL, ATA_HORKAGE_NONCQ, }, 4204 { "WDC WD740ADFD-00NLR1", NULL, ATA_HORKAGE_NONCQ, },
4197 /* http://thread.gmane.org/gmane.linux.ide/14907 */ 4205 /* http://thread.gmane.org/gmane.linux.ide/14907 */
4198 { "FUJITSU MHT2060BH", NULL, ATA_HORKAGE_NONCQ }, 4206 { "FUJITSU MHT2060BH", NULL, ATA_HORKAGE_NONCQ },
4199 /* NCQ is broken */ 4207 /* NCQ is broken */
4200 { "Maxtor *", "BANC*", ATA_HORKAGE_NONCQ }, 4208 { "Maxtor *", "BANC*", ATA_HORKAGE_NONCQ },
4201 { "Maxtor 7V300F0", "VA111630", ATA_HORKAGE_NONCQ }, 4209 { "Maxtor 7V300F0", "VA111630", ATA_HORKAGE_NONCQ },
4202 { "ST380817AS", "3.42", ATA_HORKAGE_NONCQ }, 4210 { "ST380817AS", "3.42", ATA_HORKAGE_NONCQ },
4203 { "ST3160023AS", "3.42", ATA_HORKAGE_NONCQ }, 4211 { "ST3160023AS", "3.42", ATA_HORKAGE_NONCQ },
4204 { "OCZ CORE_SSD", "02.10104", ATA_HORKAGE_NONCQ }, 4212 { "OCZ CORE_SSD", "02.10104", ATA_HORKAGE_NONCQ },
4205 4213
4206 /* Seagate NCQ + FLUSH CACHE firmware bug */ 4214 /* Seagate NCQ + FLUSH CACHE firmware bug */
4207 { "ST31500341AS", "SD15", ATA_HORKAGE_NONCQ | 4215 { "ST31500341AS", "SD15", ATA_HORKAGE_NONCQ |
4208 ATA_HORKAGE_FIRMWARE_WARN }, 4216 ATA_HORKAGE_FIRMWARE_WARN },
4209 { "ST31500341AS", "SD16", ATA_HORKAGE_NONCQ | 4217 { "ST31500341AS", "SD16", ATA_HORKAGE_NONCQ |
4210 ATA_HORKAGE_FIRMWARE_WARN }, 4218 ATA_HORKAGE_FIRMWARE_WARN },
4211 { "ST31500341AS", "SD17", ATA_HORKAGE_NONCQ | 4219 { "ST31500341AS", "SD17", ATA_HORKAGE_NONCQ |
4212 ATA_HORKAGE_FIRMWARE_WARN }, 4220 ATA_HORKAGE_FIRMWARE_WARN },
4213 { "ST31500341AS", "SD18", ATA_HORKAGE_NONCQ | 4221 { "ST31500341AS", "SD18", ATA_HORKAGE_NONCQ |
4214 ATA_HORKAGE_FIRMWARE_WARN }, 4222 ATA_HORKAGE_FIRMWARE_WARN },
4215 { "ST31500341AS", "SD19", ATA_HORKAGE_NONCQ | 4223 { "ST31500341AS", "SD19", ATA_HORKAGE_NONCQ |
4216 ATA_HORKAGE_FIRMWARE_WARN }, 4224 ATA_HORKAGE_FIRMWARE_WARN },
4217 4225
4218 { "ST31000333AS", "SD15", ATA_HORKAGE_NONCQ | 4226 { "ST31000333AS", "SD15", ATA_HORKAGE_NONCQ |
4219 ATA_HORKAGE_FIRMWARE_WARN }, 4227 ATA_HORKAGE_FIRMWARE_WARN },
4220 { "ST31000333AS", "SD16", ATA_HORKAGE_NONCQ | 4228 { "ST31000333AS", "SD16", ATA_HORKAGE_NONCQ |
4221 ATA_HORKAGE_FIRMWARE_WARN }, 4229 ATA_HORKAGE_FIRMWARE_WARN },
4222 { "ST31000333AS", "SD17", ATA_HORKAGE_NONCQ | 4230 { "ST31000333AS", "SD17", ATA_HORKAGE_NONCQ |
4223 ATA_HORKAGE_FIRMWARE_WARN }, 4231 ATA_HORKAGE_FIRMWARE_WARN },
4224 { "ST31000333AS", "SD18", ATA_HORKAGE_NONCQ | 4232 { "ST31000333AS", "SD18", ATA_HORKAGE_NONCQ |
4225 ATA_HORKAGE_FIRMWARE_WARN }, 4233 ATA_HORKAGE_FIRMWARE_WARN },
4226 { "ST31000333AS", "SD19", ATA_HORKAGE_NONCQ | 4234 { "ST31000333AS", "SD19", ATA_HORKAGE_NONCQ |
4227 ATA_HORKAGE_FIRMWARE_WARN }, 4235 ATA_HORKAGE_FIRMWARE_WARN },
4228 4236
4229 { "ST3640623AS", "SD15", ATA_HORKAGE_NONCQ | 4237 { "ST3640623AS", "SD15", ATA_HORKAGE_NONCQ |
4230 ATA_HORKAGE_FIRMWARE_WARN }, 4238 ATA_HORKAGE_FIRMWARE_WARN },
4231 { "ST3640623AS", "SD16", ATA_HORKAGE_NONCQ | 4239 { "ST3640623AS", "SD16", ATA_HORKAGE_NONCQ |
4232 ATA_HORKAGE_FIRMWARE_WARN }, 4240 ATA_HORKAGE_FIRMWARE_WARN },
4233 { "ST3640623AS", "SD17", ATA_HORKAGE_NONCQ | 4241 { "ST3640623AS", "SD17", ATA_HORKAGE_NONCQ |
4234 ATA_HORKAGE_FIRMWARE_WARN }, 4242 ATA_HORKAGE_FIRMWARE_WARN },
4235 { "ST3640623AS", "SD18", ATA_HORKAGE_NONCQ | 4243 { "ST3640623AS", "SD18", ATA_HORKAGE_NONCQ |
4236 ATA_HORKAGE_FIRMWARE_WARN }, 4244 ATA_HORKAGE_FIRMWARE_WARN },
4237 { "ST3640623AS", "SD19", ATA_HORKAGE_NONCQ | 4245 { "ST3640623AS", "SD19", ATA_HORKAGE_NONCQ |
4238 ATA_HORKAGE_FIRMWARE_WARN }, 4246 ATA_HORKAGE_FIRMWARE_WARN },
4239 4247
4240 { "ST3640323AS", "SD15", ATA_HORKAGE_NONCQ | 4248 { "ST3640323AS", "SD15", ATA_HORKAGE_NONCQ |
4241 ATA_HORKAGE_FIRMWARE_WARN }, 4249 ATA_HORKAGE_FIRMWARE_WARN },
4242 { "ST3640323AS", "SD16", ATA_HORKAGE_NONCQ | 4250 { "ST3640323AS", "SD16", ATA_HORKAGE_NONCQ |
4243 ATA_HORKAGE_FIRMWARE_WARN }, 4251 ATA_HORKAGE_FIRMWARE_WARN },
4244 { "ST3640323AS", "SD17", ATA_HORKAGE_NONCQ | 4252 { "ST3640323AS", "SD17", ATA_HORKAGE_NONCQ |
4245 ATA_HORKAGE_FIRMWARE_WARN }, 4253 ATA_HORKAGE_FIRMWARE_WARN },
4246 { "ST3640323AS", "SD18", ATA_HORKAGE_NONCQ | 4254 { "ST3640323AS", "SD18", ATA_HORKAGE_NONCQ |
4247 ATA_HORKAGE_FIRMWARE_WARN }, 4255 ATA_HORKAGE_FIRMWARE_WARN },
4248 { "ST3640323AS", "SD19", ATA_HORKAGE_NONCQ | 4256 { "ST3640323AS", "SD19", ATA_HORKAGE_NONCQ |
4249 ATA_HORKAGE_FIRMWARE_WARN }, 4257 ATA_HORKAGE_FIRMWARE_WARN },
4250 4258
4251 { "ST3320813AS", "SD15", ATA_HORKAGE_NONCQ | 4259 { "ST3320813AS", "SD15", ATA_HORKAGE_NONCQ |
4252 ATA_HORKAGE_FIRMWARE_WARN }, 4260 ATA_HORKAGE_FIRMWARE_WARN },
4253 { "ST3320813AS", "SD16", ATA_HORKAGE_NONCQ | 4261 { "ST3320813AS", "SD16", ATA_HORKAGE_NONCQ |
4254 ATA_HORKAGE_FIRMWARE_WARN }, 4262 ATA_HORKAGE_FIRMWARE_WARN },
4255 { "ST3320813AS", "SD17", ATA_HORKAGE_NONCQ | 4263 { "ST3320813AS", "SD17", ATA_HORKAGE_NONCQ |
4256 ATA_HORKAGE_FIRMWARE_WARN }, 4264 ATA_HORKAGE_FIRMWARE_WARN },
4257 { "ST3320813AS", "SD18", ATA_HORKAGE_NONCQ | 4265 { "ST3320813AS", "SD18", ATA_HORKAGE_NONCQ |
4258 ATA_HORKAGE_FIRMWARE_WARN }, 4266 ATA_HORKAGE_FIRMWARE_WARN },
4259 { "ST3320813AS", "SD19", ATA_HORKAGE_NONCQ | 4267 { "ST3320813AS", "SD19", ATA_HORKAGE_NONCQ |
4260 ATA_HORKAGE_FIRMWARE_WARN }, 4268 ATA_HORKAGE_FIRMWARE_WARN },
4261 4269
4262 { "ST3320613AS", "SD15", ATA_HORKAGE_NONCQ | 4270 { "ST3320613AS", "SD15", ATA_HORKAGE_NONCQ |
4263 ATA_HORKAGE_FIRMWARE_WARN }, 4271 ATA_HORKAGE_FIRMWARE_WARN },
4264 { "ST3320613AS", "SD16", ATA_HORKAGE_NONCQ | 4272 { "ST3320613AS", "SD16", ATA_HORKAGE_NONCQ |
4265 ATA_HORKAGE_FIRMWARE_WARN }, 4273 ATA_HORKAGE_FIRMWARE_WARN },
4266 { "ST3320613AS", "SD17", ATA_HORKAGE_NONCQ | 4274 { "ST3320613AS", "SD17", ATA_HORKAGE_NONCQ |
4267 ATA_HORKAGE_FIRMWARE_WARN }, 4275 ATA_HORKAGE_FIRMWARE_WARN },
4268 { "ST3320613AS", "SD18", ATA_HORKAGE_NONCQ | 4276 { "ST3320613AS", "SD18", ATA_HORKAGE_NONCQ |
4269 ATA_HORKAGE_FIRMWARE_WARN }, 4277 ATA_HORKAGE_FIRMWARE_WARN },
4270 { "ST3320613AS", "SD19", ATA_HORKAGE_NONCQ | 4278 { "ST3320613AS", "SD19", ATA_HORKAGE_NONCQ |
4271 ATA_HORKAGE_FIRMWARE_WARN }, 4279 ATA_HORKAGE_FIRMWARE_WARN },
4272 4280
4273 /* Blacklist entries taken from Silicon Image 3124/3132 4281 /* Blacklist entries taken from Silicon Image 3124/3132
4274 Windows driver .inf file - also several Linux problem reports */ 4282 Windows driver .inf file - also several Linux problem reports */
4275 { "HTS541060G9SA00", "MB3OC60D", ATA_HORKAGE_NONCQ, }, 4283 { "HTS541060G9SA00", "MB3OC60D", ATA_HORKAGE_NONCQ, },
4276 { "HTS541080G9SA00", "MB4OC60D", ATA_HORKAGE_NONCQ, }, 4284 { "HTS541080G9SA00", "MB4OC60D", ATA_HORKAGE_NONCQ, },
4277 { "HTS541010G9SA00", "MBZOC60D", ATA_HORKAGE_NONCQ, }, 4285 { "HTS541010G9SA00", "MBZOC60D", ATA_HORKAGE_NONCQ, },
4278 4286
4279 /* https://bugzilla.kernel.org/show_bug.cgi?id=15573 */ 4287 /* https://bugzilla.kernel.org/show_bug.cgi?id=15573 */
4280 { "C300-CTFDDAC128MAG", "0001", ATA_HORKAGE_NONCQ, }, 4288 { "C300-CTFDDAC128MAG", "0001", ATA_HORKAGE_NONCQ, },
4281 4289
4282 /* devices which puke on READ_NATIVE_MAX */ 4290 /* devices which puke on READ_NATIVE_MAX */
4283 { "HDS724040KLSA80", "KFAOA20N", ATA_HORKAGE_BROKEN_HPA, }, 4291 { "HDS724040KLSA80", "KFAOA20N", ATA_HORKAGE_BROKEN_HPA, },
4284 { "WDC WD3200JD-00KLB0", "WD-WCAMR1130137", ATA_HORKAGE_BROKEN_HPA }, 4292 { "WDC WD3200JD-00KLB0", "WD-WCAMR1130137", ATA_HORKAGE_BROKEN_HPA },
4285 { "WDC WD2500JD-00HBB0", "WD-WMAL71490727", ATA_HORKAGE_BROKEN_HPA }, 4293 { "WDC WD2500JD-00HBB0", "WD-WMAL71490727", ATA_HORKAGE_BROKEN_HPA },
4286 { "MAXTOR 6L080L4", "A93.0500", ATA_HORKAGE_BROKEN_HPA }, 4294 { "MAXTOR 6L080L4", "A93.0500", ATA_HORKAGE_BROKEN_HPA },
4287 4295
4288 /* this one allows HPA unlocking but fails IOs on the area */ 4296 /* this one allows HPA unlocking but fails IOs on the area */
4289 { "OCZ-VERTEX", "1.30", ATA_HORKAGE_BROKEN_HPA }, 4297 { "OCZ-VERTEX", "1.30", ATA_HORKAGE_BROKEN_HPA },
4290 4298
4291 /* Devices which report 1 sector over size HPA */ 4299 /* Devices which report 1 sector over size HPA */
4292 { "ST340823A", NULL, ATA_HORKAGE_HPA_SIZE, }, 4300 { "ST340823A", NULL, ATA_HORKAGE_HPA_SIZE, },
4293 { "ST320413A", NULL, ATA_HORKAGE_HPA_SIZE, }, 4301 { "ST320413A", NULL, ATA_HORKAGE_HPA_SIZE, },
4294 { "ST310211A", NULL, ATA_HORKAGE_HPA_SIZE, }, 4302 { "ST310211A", NULL, ATA_HORKAGE_HPA_SIZE, },
4295 4303
4296 /* Devices which get the IVB wrong */ 4304 /* Devices which get the IVB wrong */
4297 { "QUANTUM FIREBALLlct10 05", "A03.0900", ATA_HORKAGE_IVB, }, 4305 { "QUANTUM FIREBALLlct10 05", "A03.0900", ATA_HORKAGE_IVB, },
4298 /* Maybe we should just blacklist TSSTcorp... */ 4306 /* Maybe we should just blacklist TSSTcorp... */
4299 { "TSSTcorp CDDVDW SH-S202H", "SB00", ATA_HORKAGE_IVB, }, 4307 { "TSSTcorp CDDVDW SH-S202H", "SB00", ATA_HORKAGE_IVB, },
4300 { "TSSTcorp CDDVDW SH-S202H", "SB01", ATA_HORKAGE_IVB, }, 4308 { "TSSTcorp CDDVDW SH-S202H", "SB01", ATA_HORKAGE_IVB, },
4301 { "TSSTcorp CDDVDW SH-S202J", "SB00", ATA_HORKAGE_IVB, }, 4309 { "TSSTcorp CDDVDW SH-S202J", "SB00", ATA_HORKAGE_IVB, },
4302 { "TSSTcorp CDDVDW SH-S202J", "SB01", ATA_HORKAGE_IVB, }, 4310 { "TSSTcorp CDDVDW SH-S202J", "SB01", ATA_HORKAGE_IVB, },
4303 { "TSSTcorp CDDVDW SH-S202N", "SB00", ATA_HORKAGE_IVB, }, 4311 { "TSSTcorp CDDVDW SH-S202N", "SB00", ATA_HORKAGE_IVB, },
4304 { "TSSTcorp CDDVDW SH-S202N", "SB01", ATA_HORKAGE_IVB, }, 4312 { "TSSTcorp CDDVDW SH-S202N", "SB01", ATA_HORKAGE_IVB, },
4305 4313
4306 /* Devices that do not need bridging limits applied */ 4314 /* Devices that do not need bridging limits applied */
4307 { "MTRON MSP-SATA*", NULL, ATA_HORKAGE_BRIDGE_OK, }, 4315 { "MTRON MSP-SATA*", NULL, ATA_HORKAGE_BRIDGE_OK, },
4308 4316
4309 /* Devices which aren't very happy with higher link speeds */ 4317 /* Devices which aren't very happy with higher link speeds */
4310 { "WD My Book", NULL, ATA_HORKAGE_1_5_GBPS, }, 4318 { "WD My Book", NULL, ATA_HORKAGE_1_5_GBPS, },
4311 4319
4312 /* 4320 /*
4313 * Devices which choke on SETXFER. Applies only if both the 4321 * Devices which choke on SETXFER. Applies only if both the
4314 * device and controller are SATA. 4322 * device and controller are SATA.
4315 */ 4323 */
4316 { "PIONEER DVD-RW DVRTD08", "1.00", ATA_HORKAGE_NOSETXFER }, 4324 { "PIONEER DVD-RW DVRTD08", "1.00", ATA_HORKAGE_NOSETXFER },
4317 4325
4318 /* End Marker */ 4326 /* End Marker */
4319 { } 4327 { }
4320 }; 4328 };
4321 4329
4322 static int strn_pattern_cmp(const char *patt, const char *name, int wildchar) 4330 static int strn_pattern_cmp(const char *patt, const char *name, int wildchar)
4323 { 4331 {
4324 const char *p; 4332 const char *p;
4325 int len; 4333 int len;
4326 4334
4327 /* 4335 /*
4328 * check for trailing wildcard: *\0 4336 * check for trailing wildcard: *\0
4329 */ 4337 */
4330 p = strchr(patt, wildchar); 4338 p = strchr(patt, wildchar);
4331 if (p && ((*(p + 1)) == 0)) 4339 if (p && ((*(p + 1)) == 0))
4332 len = p - patt; 4340 len = p - patt;
4333 else { 4341 else {
4334 len = strlen(name); 4342 len = strlen(name);
4335 if (!len) { 4343 if (!len) {
4336 if (!*patt) 4344 if (!*patt)
4337 return 0; 4345 return 0;
4338 return -1; 4346 return -1;
4339 } 4347 }
4340 } 4348 }
4341 4349
4342 return strncmp(patt, name, len); 4350 return strncmp(patt, name, len);
4343 } 4351 }
4344 4352
4345 static unsigned long ata_dev_blacklisted(const struct ata_device *dev) 4353 static unsigned long ata_dev_blacklisted(const struct ata_device *dev)
4346 { 4354 {
4347 unsigned char model_num[ATA_ID_PROD_LEN + 1]; 4355 unsigned char model_num[ATA_ID_PROD_LEN + 1];
4348 unsigned char model_rev[ATA_ID_FW_REV_LEN + 1]; 4356 unsigned char model_rev[ATA_ID_FW_REV_LEN + 1];
4349 const struct ata_blacklist_entry *ad = ata_device_blacklist; 4357 const struct ata_blacklist_entry *ad = ata_device_blacklist;
4350 4358
4351 ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num)); 4359 ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num));
4352 ata_id_c_string(dev->id, model_rev, ATA_ID_FW_REV, sizeof(model_rev)); 4360 ata_id_c_string(dev->id, model_rev, ATA_ID_FW_REV, sizeof(model_rev));
4353 4361
4354 while (ad->model_num) { 4362 while (ad->model_num) {
4355 if (!strn_pattern_cmp(ad->model_num, model_num, '*')) { 4363 if (!strn_pattern_cmp(ad->model_num, model_num, '*')) {
4356 if (ad->model_rev == NULL) 4364 if (ad->model_rev == NULL)
4357 return ad->horkage; 4365 return ad->horkage;
4358 if (!strn_pattern_cmp(ad->model_rev, model_rev, '*')) 4366 if (!strn_pattern_cmp(ad->model_rev, model_rev, '*'))
4359 return ad->horkage; 4367 return ad->horkage;
4360 } 4368 }
4361 ad++; 4369 ad++;
4362 } 4370 }
4363 return 0; 4371 return 0;
4364 } 4372 }
4365 4373
4366 static int ata_dma_blacklisted(const struct ata_device *dev) 4374 static int ata_dma_blacklisted(const struct ata_device *dev)
4367 { 4375 {
4368 /* We don't support polling DMA. 4376 /* We don't support polling DMA.
4369 * DMA blacklist those ATAPI devices with CDB-intr (and use PIO) 4377 * DMA blacklist those ATAPI devices with CDB-intr (and use PIO)
4370 * if the LLDD handles only interrupts in the HSM_ST_LAST state. 4378 * if the LLDD handles only interrupts in the HSM_ST_LAST state.
4371 */ 4379 */
4372 if ((dev->link->ap->flags & ATA_FLAG_PIO_POLLING) && 4380 if ((dev->link->ap->flags & ATA_FLAG_PIO_POLLING) &&
4373 (dev->flags & ATA_DFLAG_CDB_INTR)) 4381 (dev->flags & ATA_DFLAG_CDB_INTR))
4374 return 1; 4382 return 1;
4375 return (dev->horkage & ATA_HORKAGE_NODMA) ? 1 : 0; 4383 return (dev->horkage & ATA_HORKAGE_NODMA) ? 1 : 0;
4376 } 4384 }
4377 4385
4378 /** 4386 /**
4379 * ata_is_40wire - check drive side detection 4387 * ata_is_40wire - check drive side detection
4380 * @dev: device 4388 * @dev: device
4381 * 4389 *
4382 * Perform drive side detection decoding, allowing for device vendors 4390 * Perform drive side detection decoding, allowing for device vendors
4383 * who can't follow the documentation. 4391 * who can't follow the documentation.
4384 */ 4392 */
4385 4393
4386 static int ata_is_40wire(struct ata_device *dev) 4394 static int ata_is_40wire(struct ata_device *dev)
4387 { 4395 {
4388 if (dev->horkage & ATA_HORKAGE_IVB) 4396 if (dev->horkage & ATA_HORKAGE_IVB)
4389 return ata_drive_40wire_relaxed(dev->id); 4397 return ata_drive_40wire_relaxed(dev->id);
4390 return ata_drive_40wire(dev->id); 4398 return ata_drive_40wire(dev->id);
4391 } 4399 }
4392 4400
4393 /** 4401 /**
4394 * cable_is_40wire - 40/80/SATA decider 4402 * cable_is_40wire - 40/80/SATA decider
4395 * @ap: port to consider 4403 * @ap: port to consider
4396 * 4404 *
4397 * This function encapsulates the policy for speed management 4405 * This function encapsulates the policy for speed management
4398 * in one place. At the moment we don't cache the result but 4406 * in one place. At the moment we don't cache the result but
4399 * there is a good case for setting ap->cbl to the result when 4407 * there is a good case for setting ap->cbl to the result when
4400 * we are called with unknown cables (and figuring out if it 4408 * we are called with unknown cables (and figuring out if it
4401 * impacts hotplug at all). 4409 * impacts hotplug at all).
4402 * 4410 *
4403 * Return 1 if the cable appears to be 40 wire. 4411 * Return 1 if the cable appears to be 40 wire.
4404 */ 4412 */
4405 4413
4406 static int cable_is_40wire(struct ata_port *ap) 4414 static int cable_is_40wire(struct ata_port *ap)
4407 { 4415 {
4408 struct ata_link *link; 4416 struct ata_link *link;
4409 struct ata_device *dev; 4417 struct ata_device *dev;
4410 4418
4411 /* If the controller thinks we are 40 wire, we are. */ 4419 /* If the controller thinks we are 40 wire, we are. */
4412 if (ap->cbl == ATA_CBL_PATA40) 4420 if (ap->cbl == ATA_CBL_PATA40)
4413 return 1; 4421 return 1;
4414 4422
4415 /* If the controller thinks we are 80 wire, we are. */ 4423 /* If the controller thinks we are 80 wire, we are. */
4416 if (ap->cbl == ATA_CBL_PATA80 || ap->cbl == ATA_CBL_SATA) 4424 if (ap->cbl == ATA_CBL_PATA80 || ap->cbl == ATA_CBL_SATA)
4417 return 0; 4425 return 0;
4418 4426
4419 /* If the system is known to be 40 wire short cable (eg 4427 /* If the system is known to be 40 wire short cable (eg
4420 * laptop), then we allow 80 wire modes even if the drive 4428 * laptop), then we allow 80 wire modes even if the drive
4421 * isn't sure. 4429 * isn't sure.
4422 */ 4430 */
4423 if (ap->cbl == ATA_CBL_PATA40_SHORT) 4431 if (ap->cbl == ATA_CBL_PATA40_SHORT)
4424 return 0; 4432 return 0;
4425 4433
4426 /* If the controller doesn't know, we scan. 4434 /* If the controller doesn't know, we scan.
4427 * 4435 *
4428 * Note: We look for all 40 wire detects at this point. Any 4436 * Note: We look for all 40 wire detects at this point. Any
4429 * 80 wire detect is taken to be 80 wire cable because 4437 * 80 wire detect is taken to be 80 wire cable because
4430 * - in many setups only the one drive (slave if present) will 4438 * - in many setups only the one drive (slave if present) will
4431 * give a valid detect 4439 * give a valid detect
4432 * - if you have a non detect capable drive you don't want it 4440 * - if you have a non detect capable drive you don't want it
4433 * to colour the choice 4441 * to colour the choice
4434 */ 4442 */
4435 ata_for_each_link(link, ap, EDGE) { 4443 ata_for_each_link(link, ap, EDGE) {
4436 ata_for_each_dev(dev, link, ENABLED) { 4444 ata_for_each_dev(dev, link, ENABLED) {
4437 if (!ata_is_40wire(dev)) 4445 if (!ata_is_40wire(dev))
4438 return 0; 4446 return 0;
4439 } 4447 }
4440 } 4448 }
4441 return 1; 4449 return 1;
4442 } 4450 }
4443 4451
4444 /** 4452 /**
4445 * ata_dev_xfermask - Compute supported xfermask of the given device 4453 * ata_dev_xfermask - Compute supported xfermask of the given device
4446 * @dev: Device to compute xfermask for 4454 * @dev: Device to compute xfermask for
4447 * 4455 *
4448 * Compute supported xfermask of @dev and store it in 4456 * Compute supported xfermask of @dev and store it in
4449 * dev->*_mask. This function is responsible for applying all 4457 * dev->*_mask. This function is responsible for applying all
4450 * known limits including host controller limits, device 4458 * known limits including host controller limits, device
4451 * blacklist, etc... 4459 * blacklist, etc...
4452 * 4460 *
4453 * LOCKING: 4461 * LOCKING:
4454 * None. 4462 * None.
4455 */ 4463 */
4456 static void ata_dev_xfermask(struct ata_device *dev) 4464 static void ata_dev_xfermask(struct ata_device *dev)
4457 { 4465 {
4458 struct ata_link *link = dev->link; 4466 struct ata_link *link = dev->link;
4459 struct ata_port *ap = link->ap; 4467 struct ata_port *ap = link->ap;
4460 struct ata_host *host = ap->host; 4468 struct ata_host *host = ap->host;
4461 unsigned long xfer_mask; 4469 unsigned long xfer_mask;
4462 4470
4463 /* controller modes available */ 4471 /* controller modes available */
4464 xfer_mask = ata_pack_xfermask(ap->pio_mask, 4472 xfer_mask = ata_pack_xfermask(ap->pio_mask,
4465 ap->mwdma_mask, ap->udma_mask); 4473 ap->mwdma_mask, ap->udma_mask);
4466 4474
4467 /* drive modes available */ 4475 /* drive modes available */
4468 xfer_mask &= ata_pack_xfermask(dev->pio_mask, 4476 xfer_mask &= ata_pack_xfermask(dev->pio_mask,
4469 dev->mwdma_mask, dev->udma_mask); 4477 dev->mwdma_mask, dev->udma_mask);
4470 xfer_mask &= ata_id_xfermask(dev->id); 4478 xfer_mask &= ata_id_xfermask(dev->id);
4471 4479
4472 /* 4480 /*
4473 * CFA Advanced TrueIDE timings are not allowed on a shared 4481 * CFA Advanced TrueIDE timings are not allowed on a shared
4474 * cable 4482 * cable
4475 */ 4483 */
4476 if (ata_dev_pair(dev)) { 4484 if (ata_dev_pair(dev)) {
4477 /* No PIO5 or PIO6 */ 4485 /* No PIO5 or PIO6 */
4478 xfer_mask &= ~(0x03 << (ATA_SHIFT_PIO + 5)); 4486 xfer_mask &= ~(0x03 << (ATA_SHIFT_PIO + 5));
4479 /* No MWDMA3 or MWDMA 4 */ 4487 /* No MWDMA3 or MWDMA 4 */
4480 xfer_mask &= ~(0x03 << (ATA_SHIFT_MWDMA + 3)); 4488 xfer_mask &= ~(0x03 << (ATA_SHIFT_MWDMA + 3));
4481 } 4489 }
4482 4490
4483 if (ata_dma_blacklisted(dev)) { 4491 if (ata_dma_blacklisted(dev)) {
4484 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); 4492 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
4485 ata_dev_printk(dev, KERN_WARNING, 4493 ata_dev_printk(dev, KERN_WARNING,
4486 "device is on DMA blacklist, disabling DMA\n"); 4494 "device is on DMA blacklist, disabling DMA\n");
4487 } 4495 }
4488 4496
4489 if ((host->flags & ATA_HOST_SIMPLEX) && 4497 if ((host->flags & ATA_HOST_SIMPLEX) &&
4490 host->simplex_claimed && host->simplex_claimed != ap) { 4498 host->simplex_claimed && host->simplex_claimed != ap) {
4491 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); 4499 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
4492 ata_dev_printk(dev, KERN_WARNING, "simplex DMA is claimed by " 4500 ata_dev_printk(dev, KERN_WARNING, "simplex DMA is claimed by "
4493 "other device, disabling DMA\n"); 4501 "other device, disabling DMA\n");
4494 } 4502 }
4495 4503
4496 if (ap->flags & ATA_FLAG_NO_IORDY) 4504 if (ap->flags & ATA_FLAG_NO_IORDY)
4497 xfer_mask &= ata_pio_mask_no_iordy(dev); 4505 xfer_mask &= ata_pio_mask_no_iordy(dev);
4498 4506
4499 if (ap->ops->mode_filter) 4507 if (ap->ops->mode_filter)
4500 xfer_mask = ap->ops->mode_filter(dev, xfer_mask); 4508 xfer_mask = ap->ops->mode_filter(dev, xfer_mask);
4501 4509
4502 /* Apply cable rule here. Don't apply it early because when 4510 /* Apply cable rule here. Don't apply it early because when
4503 * we handle hot plug the cable type can itself change. 4511 * we handle hot plug the cable type can itself change.
4504 * Check this last so that we know if the transfer rate was 4512 * Check this last so that we know if the transfer rate was
4505 * solely limited by the cable. 4513 * solely limited by the cable.
4506 * Unknown or 80 wire cables reported host side are checked 4514 * Unknown or 80 wire cables reported host side are checked
4507 * drive side as well. Cases where we know a 40wire cable 4515 * drive side as well. Cases where we know a 40wire cable
4508 * is used safely for 80 are not checked here. 4516 * is used safely for 80 are not checked here.
4509 */ 4517 */
4510 if (xfer_mask & (0xF8 << ATA_SHIFT_UDMA)) 4518 if (xfer_mask & (0xF8 << ATA_SHIFT_UDMA))
4511 /* UDMA/44 or higher would be available */ 4519 /* UDMA/44 or higher would be available */
4512 if (cable_is_40wire(ap)) { 4520 if (cable_is_40wire(ap)) {
4513 ata_dev_printk(dev, KERN_WARNING, 4521 ata_dev_printk(dev, KERN_WARNING,
4514 "limited to UDMA/33 due to 40-wire cable\n"); 4522 "limited to UDMA/33 due to 40-wire cable\n");
4515 xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA); 4523 xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA);
4516 } 4524 }
4517 4525
4518 ata_unpack_xfermask(xfer_mask, &dev->pio_mask, 4526 ata_unpack_xfermask(xfer_mask, &dev->pio_mask,
4519 &dev->mwdma_mask, &dev->udma_mask); 4527 &dev->mwdma_mask, &dev->udma_mask);
4520 } 4528 }
4521 4529
4522 /** 4530 /**
4523 * ata_dev_set_xfermode - Issue SET FEATURES - XFER MODE command 4531 * ata_dev_set_xfermode - Issue SET FEATURES - XFER MODE command
4524 * @dev: Device to which command will be sent 4532 * @dev: Device to which command will be sent
4525 * 4533 *
4526 * Issue SET FEATURES - XFER MODE command to device @dev 4534 * Issue SET FEATURES - XFER MODE command to device @dev
4527 * on port @ap. 4535 * on port @ap.
4528 * 4536 *
4529 * LOCKING: 4537 * LOCKING:
4530 * PCI/etc. bus probe sem. 4538 * PCI/etc. bus probe sem.
4531 * 4539 *
4532 * RETURNS: 4540 * RETURNS:
4533 * 0 on success, AC_ERR_* mask otherwise. 4541 * 0 on success, AC_ERR_* mask otherwise.
4534 */ 4542 */
4535 4543
4536 static unsigned int ata_dev_set_xfermode(struct ata_device *dev) 4544 static unsigned int ata_dev_set_xfermode(struct ata_device *dev)
4537 { 4545 {
4538 struct ata_taskfile tf; 4546 struct ata_taskfile tf;
4539 unsigned int err_mask; 4547 unsigned int err_mask;
4540 4548
4541 /* set up set-features taskfile */ 4549 /* set up set-features taskfile */
4542 DPRINTK("set features - xfer mode\n"); 4550 DPRINTK("set features - xfer mode\n");
4543 4551
4544 /* Some controllers and ATAPI devices show flaky interrupt 4552 /* Some controllers and ATAPI devices show flaky interrupt
4545 * behavior after setting xfer mode. Use polling instead. 4553 * behavior after setting xfer mode. Use polling instead.
4546 */ 4554 */
4547 ata_tf_init(dev, &tf); 4555 ata_tf_init(dev, &tf);
4548 tf.command = ATA_CMD_SET_FEATURES; 4556 tf.command = ATA_CMD_SET_FEATURES;
4549 tf.feature = SETFEATURES_XFER; 4557 tf.feature = SETFEATURES_XFER;
4550 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_POLLING; 4558 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_POLLING;
4551 tf.protocol = ATA_PROT_NODATA; 4559 tf.protocol = ATA_PROT_NODATA;
4552 /* If we are using IORDY we must send the mode setting command */ 4560 /* If we are using IORDY we must send the mode setting command */
4553 if (ata_pio_need_iordy(dev)) 4561 if (ata_pio_need_iordy(dev))
4554 tf.nsect = dev->xfer_mode; 4562 tf.nsect = dev->xfer_mode;
4555 /* If the device has IORDY and the controller does not - turn it off */ 4563 /* If the device has IORDY and the controller does not - turn it off */
4556 else if (ata_id_has_iordy(dev->id)) 4564 else if (ata_id_has_iordy(dev->id))
4557 tf.nsect = 0x01; 4565 tf.nsect = 0x01;
4558 else /* In the ancient relic department - skip all of this */ 4566 else /* In the ancient relic department - skip all of this */
4559 return 0; 4567 return 0;
4560 4568
4561 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); 4569 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
4562 4570
4563 DPRINTK("EXIT, err_mask=%x\n", err_mask); 4571 DPRINTK("EXIT, err_mask=%x\n", err_mask);
4564 return err_mask; 4572 return err_mask;
4565 } 4573 }
4566 /** 4574 /**
4567 * ata_dev_set_feature - Issue SET FEATURES - SATA FEATURES 4575 * ata_dev_set_feature - Issue SET FEATURES - SATA FEATURES
4568 * @dev: Device to which command will be sent 4576 * @dev: Device to which command will be sent
4569 * @enable: Whether to enable or disable the feature 4577 * @enable: Whether to enable or disable the feature
4570 * @feature: The sector count represents the feature to set 4578 * @feature: The sector count represents the feature to set
4571 * 4579 *
4572 * Issue SET FEATURES - SATA FEATURES command to device @dev 4580 * Issue SET FEATURES - SATA FEATURES command to device @dev
4573 * on port @ap with sector count 4581 * on port @ap with sector count
4574 * 4582 *
4575 * LOCKING: 4583 * LOCKING:
4576 * PCI/etc. bus probe sem. 4584 * PCI/etc. bus probe sem.
4577 * 4585 *
4578 * RETURNS: 4586 * RETURNS:
4579 * 0 on success, AC_ERR_* mask otherwise. 4587 * 0 on success, AC_ERR_* mask otherwise.
4580 */ 4588 */
4581 static unsigned int ata_dev_set_feature(struct ata_device *dev, u8 enable, 4589 static unsigned int ata_dev_set_feature(struct ata_device *dev, u8 enable,
4582 u8 feature) 4590 u8 feature)
4583 { 4591 {
4584 struct ata_taskfile tf; 4592 struct ata_taskfile tf;
4585 unsigned int err_mask; 4593 unsigned int err_mask;
4586 4594
4587 /* set up set-features taskfile */ 4595 /* set up set-features taskfile */
4588 DPRINTK("set features - SATA features\n"); 4596 DPRINTK("set features - SATA features\n");
4589 4597
4590 ata_tf_init(dev, &tf); 4598 ata_tf_init(dev, &tf);
4591 tf.command = ATA_CMD_SET_FEATURES; 4599 tf.command = ATA_CMD_SET_FEATURES;
4592 tf.feature = enable; 4600 tf.feature = enable;
4593 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 4601 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
4594 tf.protocol = ATA_PROT_NODATA; 4602 tf.protocol = ATA_PROT_NODATA;
4595 tf.nsect = feature; 4603 tf.nsect = feature;
4596 4604
4597 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); 4605 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
4598 4606
4599 DPRINTK("EXIT, err_mask=%x\n", err_mask); 4607 DPRINTK("EXIT, err_mask=%x\n", err_mask);
4600 return err_mask; 4608 return err_mask;
4601 } 4609 }
4602 4610
4603 /** 4611 /**
4604 * ata_dev_init_params - Issue INIT DEV PARAMS command 4612 * ata_dev_init_params - Issue INIT DEV PARAMS command
4605 * @dev: Device to which command will be sent 4613 * @dev: Device to which command will be sent
4606 * @heads: Number of heads (taskfile parameter) 4614 * @heads: Number of heads (taskfile parameter)
4607 * @sectors: Number of sectors (taskfile parameter) 4615 * @sectors: Number of sectors (taskfile parameter)
4608 * 4616 *
4609 * LOCKING: 4617 * LOCKING:
4610 * Kernel thread context (may sleep) 4618 * Kernel thread context (may sleep)
4611 * 4619 *
4612 * RETURNS: 4620 * RETURNS:
4613 * 0 on success, AC_ERR_* mask otherwise. 4621 * 0 on success, AC_ERR_* mask otherwise.
4614 */ 4622 */
4615 static unsigned int ata_dev_init_params(struct ata_device *dev, 4623 static unsigned int ata_dev_init_params(struct ata_device *dev,
4616 u16 heads, u16 sectors) 4624 u16 heads, u16 sectors)
4617 { 4625 {
4618 struct ata_taskfile tf; 4626 struct ata_taskfile tf;
4619 unsigned int err_mask; 4627 unsigned int err_mask;
4620 4628
4621 /* Number of sectors per track 1-255. Number of heads 1-16 */ 4629 /* Number of sectors per track 1-255. Number of heads 1-16 */
4622 if (sectors < 1 || sectors > 255 || heads < 1 || heads > 16) 4630 if (sectors < 1 || sectors > 255 || heads < 1 || heads > 16)
4623 return AC_ERR_INVALID; 4631 return AC_ERR_INVALID;
4624 4632
4625 /* set up init dev params taskfile */ 4633 /* set up init dev params taskfile */
4626 DPRINTK("init dev params \n"); 4634 DPRINTK("init dev params \n");
4627 4635
4628 ata_tf_init(dev, &tf); 4636 ata_tf_init(dev, &tf);
4629 tf.command = ATA_CMD_INIT_DEV_PARAMS; 4637 tf.command = ATA_CMD_INIT_DEV_PARAMS;
4630 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 4638 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
4631 tf.protocol = ATA_PROT_NODATA; 4639 tf.protocol = ATA_PROT_NODATA;
4632 tf.nsect = sectors; 4640 tf.nsect = sectors;
4633 tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ 4641 tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */
4634 4642
4635 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); 4643 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
4636 /* A clean abort indicates an original or just out of spec drive 4644 /* A clean abort indicates an original or just out of spec drive
4637 and we should continue as we issue the setup based on the 4645 and we should continue as we issue the setup based on the
4638 drive reported working geometry */ 4646 drive reported working geometry */
4639 if (err_mask == AC_ERR_DEV && (tf.feature & ATA_ABORTED)) 4647 if (err_mask == AC_ERR_DEV && (tf.feature & ATA_ABORTED))
4640 err_mask = 0; 4648 err_mask = 0;
4641 4649
4642 DPRINTK("EXIT, err_mask=%x\n", err_mask); 4650 DPRINTK("EXIT, err_mask=%x\n", err_mask);
4643 return err_mask; 4651 return err_mask;
4644 } 4652 }
4645 4653
4646 /** 4654 /**
4647 * ata_sg_clean - Unmap DMA memory associated with command 4655 * ata_sg_clean - Unmap DMA memory associated with command
4648 * @qc: Command containing DMA memory to be released 4656 * @qc: Command containing DMA memory to be released
4649 * 4657 *
4650 * Unmap all mapped DMA memory associated with this command. 4658 * Unmap all mapped DMA memory associated with this command.
4651 * 4659 *
4652 * LOCKING: 4660 * LOCKING:
4653 * spin_lock_irqsave(host lock) 4661 * spin_lock_irqsave(host lock)
4654 */ 4662 */
4655 void ata_sg_clean(struct ata_queued_cmd *qc) 4663 void ata_sg_clean(struct ata_queued_cmd *qc)
4656 { 4664 {
4657 struct ata_port *ap = qc->ap; 4665 struct ata_port *ap = qc->ap;
4658 struct scatterlist *sg = qc->sg; 4666 struct scatterlist *sg = qc->sg;
4659 int dir = qc->dma_dir; 4667 int dir = qc->dma_dir;
4660 4668
4661 WARN_ON_ONCE(sg == NULL); 4669 WARN_ON_ONCE(sg == NULL);
4662 4670
4663 VPRINTK("unmapping %u sg elements\n", qc->n_elem); 4671 VPRINTK("unmapping %u sg elements\n", qc->n_elem);
4664 4672
4665 if (qc->n_elem) 4673 if (qc->n_elem)
4666 dma_unmap_sg(ap->dev, sg, qc->orig_n_elem, dir); 4674 dma_unmap_sg(ap->dev, sg, qc->orig_n_elem, dir);
4667 4675
4668 qc->flags &= ~ATA_QCFLAG_DMAMAP; 4676 qc->flags &= ~ATA_QCFLAG_DMAMAP;
4669 qc->sg = NULL; 4677 qc->sg = NULL;
4670 } 4678 }
4671 4679
4672 /** 4680 /**
4673 * atapi_check_dma - Check whether ATAPI DMA can be supported 4681 * atapi_check_dma - Check whether ATAPI DMA can be supported
4674 * @qc: Metadata associated with taskfile to check 4682 * @qc: Metadata associated with taskfile to check
4675 * 4683 *
4676 * Allow low-level driver to filter ATA PACKET commands, returning 4684 * Allow low-level driver to filter ATA PACKET commands, returning
4677 * a status indicating whether or not it is OK to use DMA for the 4685 * a status indicating whether or not it is OK to use DMA for the
4678 * supplied PACKET command. 4686 * supplied PACKET command.
4679 * 4687 *
4680 * LOCKING: 4688 * LOCKING:
4681 * spin_lock_irqsave(host lock) 4689 * spin_lock_irqsave(host lock)
4682 * 4690 *
4683 * RETURNS: 0 when ATAPI DMA can be used 4691 * RETURNS: 0 when ATAPI DMA can be used
4684 * nonzero otherwise 4692 * nonzero otherwise
4685 */ 4693 */
4686 int atapi_check_dma(struct ata_queued_cmd *qc) 4694 int atapi_check_dma(struct ata_queued_cmd *qc)
4687 { 4695 {
4688 struct ata_port *ap = qc->ap; 4696 struct ata_port *ap = qc->ap;
4689 4697
4690 /* Don't allow DMA if it isn't multiple of 16 bytes. Quite a 4698 /* Don't allow DMA if it isn't multiple of 16 bytes. Quite a
4691 * few ATAPI devices choke on such DMA requests. 4699 * few ATAPI devices choke on such DMA requests.
4692 */ 4700 */
4693 if (!(qc->dev->horkage & ATA_HORKAGE_ATAPI_MOD16_DMA) && 4701 if (!(qc->dev->horkage & ATA_HORKAGE_ATAPI_MOD16_DMA) &&
4694 unlikely(qc->nbytes & 15)) 4702 unlikely(qc->nbytes & 15))
4695 return 1; 4703 return 1;
4696 4704
4697 if (ap->ops->check_atapi_dma) 4705 if (ap->ops->check_atapi_dma)
4698 return ap->ops->check_atapi_dma(qc); 4706 return ap->ops->check_atapi_dma(qc);
4699 4707
4700 return 0; 4708 return 0;
4701 } 4709 }
4702 4710
4703 /** 4711 /**
4704 * ata_std_qc_defer - Check whether a qc needs to be deferred 4712 * ata_std_qc_defer - Check whether a qc needs to be deferred
4705 * @qc: ATA command in question 4713 * @qc: ATA command in question
4706 * 4714 *
4707 * Non-NCQ commands cannot run with any other command, NCQ or 4715 * Non-NCQ commands cannot run with any other command, NCQ or
4708 * not. As upper layer only knows the queue depth, we are 4716 * not. As upper layer only knows the queue depth, we are
4709 * responsible for maintaining exclusion. This function checks 4717 * responsible for maintaining exclusion. This function checks
4710 * whether a new command @qc can be issued. 4718 * whether a new command @qc can be issued.
4711 * 4719 *
4712 * LOCKING: 4720 * LOCKING:
4713 * spin_lock_irqsave(host lock) 4721 * spin_lock_irqsave(host lock)
4714 * 4722 *
4715 * RETURNS: 4723 * RETURNS:
4716 * ATA_DEFER_* if deferring is needed, 0 otherwise. 4724 * ATA_DEFER_* if deferring is needed, 0 otherwise.
4717 */ 4725 */
4718 int ata_std_qc_defer(struct ata_queued_cmd *qc) 4726 int ata_std_qc_defer(struct ata_queued_cmd *qc)
4719 { 4727 {
4720 struct ata_link *link = qc->dev->link; 4728 struct ata_link *link = qc->dev->link;
4721 4729
4722 if (qc->tf.protocol == ATA_PROT_NCQ) { 4730 if (qc->tf.protocol == ATA_PROT_NCQ) {
4723 if (!ata_tag_valid(link->active_tag)) 4731 if (!ata_tag_valid(link->active_tag))
4724 return 0; 4732 return 0;
4725 } else { 4733 } else {
4726 if (!ata_tag_valid(link->active_tag) && !link->sactive) 4734 if (!ata_tag_valid(link->active_tag) && !link->sactive)
4727 return 0; 4735 return 0;
4728 } 4736 }
4729 4737
4730 return ATA_DEFER_LINK; 4738 return ATA_DEFER_LINK;
4731 } 4739 }
4732 4740
4733 void ata_noop_qc_prep(struct ata_queued_cmd *qc) { } 4741 void ata_noop_qc_prep(struct ata_queued_cmd *qc) { }
4734 4742
4735 /** 4743 /**
4736 * ata_sg_init - Associate command with scatter-gather table. 4744 * ata_sg_init - Associate command with scatter-gather table.
4737 * @qc: Command to be associated 4745 * @qc: Command to be associated
4738 * @sg: Scatter-gather table. 4746 * @sg: Scatter-gather table.
4739 * @n_elem: Number of elements in s/g table. 4747 * @n_elem: Number of elements in s/g table.
4740 * 4748 *
4741 * Initialize the data-related elements of queued_cmd @qc 4749 * Initialize the data-related elements of queued_cmd @qc
4742 * to point to a scatter-gather table @sg, containing @n_elem 4750 * to point to a scatter-gather table @sg, containing @n_elem
4743 * elements. 4751 * elements.
4744 * 4752 *
4745 * LOCKING: 4753 * LOCKING:
4746 * spin_lock_irqsave(host lock) 4754 * spin_lock_irqsave(host lock)
4747 */ 4755 */
4748 void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, 4756 void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
4749 unsigned int n_elem) 4757 unsigned int n_elem)
4750 { 4758 {
4751 qc->sg = sg; 4759 qc->sg = sg;
4752 qc->n_elem = n_elem; 4760 qc->n_elem = n_elem;
4753 qc->cursg = qc->sg; 4761 qc->cursg = qc->sg;
4754 } 4762 }
4755 4763
4756 /** 4764 /**
4757 * ata_sg_setup - DMA-map the scatter-gather table associated with a command. 4765 * ata_sg_setup - DMA-map the scatter-gather table associated with a command.
4758 * @qc: Command with scatter-gather table to be mapped. 4766 * @qc: Command with scatter-gather table to be mapped.
4759 * 4767 *
4760 * DMA-map the scatter-gather table associated with queued_cmd @qc. 4768 * DMA-map the scatter-gather table associated with queued_cmd @qc.
4761 * 4769 *
4762 * LOCKING: 4770 * LOCKING:
4763 * spin_lock_irqsave(host lock) 4771 * spin_lock_irqsave(host lock)
4764 * 4772 *
4765 * RETURNS: 4773 * RETURNS:
4766 * Zero on success, negative on error. 4774 * Zero on success, negative on error.
4767 * 4775 *
4768 */ 4776 */
4769 static int ata_sg_setup(struct ata_queued_cmd *qc) 4777 static int ata_sg_setup(struct ata_queued_cmd *qc)
4770 { 4778 {
4771 struct ata_port *ap = qc->ap; 4779 struct ata_port *ap = qc->ap;
4772 unsigned int n_elem; 4780 unsigned int n_elem;
4773 4781
4774 VPRINTK("ENTER, ata%u\n", ap->print_id); 4782 VPRINTK("ENTER, ata%u\n", ap->print_id);
4775 4783
4776 n_elem = dma_map_sg(ap->dev, qc->sg, qc->n_elem, qc->dma_dir); 4784 n_elem = dma_map_sg(ap->dev, qc->sg, qc->n_elem, qc->dma_dir);
4777 if (n_elem < 1) 4785 if (n_elem < 1)
4778 return -1; 4786 return -1;
4779 4787
4780 DPRINTK("%d sg elements mapped\n", n_elem); 4788 DPRINTK("%d sg elements mapped\n", n_elem);
4781 qc->orig_n_elem = qc->n_elem; 4789 qc->orig_n_elem = qc->n_elem;
4782 qc->n_elem = n_elem; 4790 qc->n_elem = n_elem;
4783 qc->flags |= ATA_QCFLAG_DMAMAP; 4791 qc->flags |= ATA_QCFLAG_DMAMAP;
4784 4792
4785 return 0; 4793 return 0;
4786 } 4794 }
4787 4795
4788 /** 4796 /**
4789 * swap_buf_le16 - swap halves of 16-bit words in place 4797 * swap_buf_le16 - swap halves of 16-bit words in place
4790 * @buf: Buffer to swap 4798 * @buf: Buffer to swap
4791 * @buf_words: Number of 16-bit words in buffer. 4799 * @buf_words: Number of 16-bit words in buffer.
4792 * 4800 *
4793 * Swap halves of 16-bit words if needed to convert from 4801 * Swap halves of 16-bit words if needed to convert from
4794 * little-endian byte order to native cpu byte order, or 4802 * little-endian byte order to native cpu byte order, or
4795 * vice-versa. 4803 * vice-versa.
4796 * 4804 *
4797 * LOCKING: 4805 * LOCKING:
4798 * Inherited from caller. 4806 * Inherited from caller.
4799 */ 4807 */
4800 void swap_buf_le16(u16 *buf, unsigned int buf_words) 4808 void swap_buf_le16(u16 *buf, unsigned int buf_words)
4801 { 4809 {
4802 #ifdef __BIG_ENDIAN 4810 #ifdef __BIG_ENDIAN
4803 unsigned int i; 4811 unsigned int i;
4804 4812
4805 for (i = 0; i < buf_words; i++) 4813 for (i = 0; i < buf_words; i++)
4806 buf[i] = le16_to_cpu(buf[i]); 4814 buf[i] = le16_to_cpu(buf[i]);
4807 #endif /* __BIG_ENDIAN */ 4815 #endif /* __BIG_ENDIAN */
4808 } 4816 }
4809 4817
4810 /** 4818 /**
4811 * ata_qc_new - Request an available ATA command, for queueing 4819 * ata_qc_new - Request an available ATA command, for queueing
4812 * @ap: target port 4820 * @ap: target port
4813 * 4821 *
4814 * LOCKING: 4822 * LOCKING:
4815 * None. 4823 * None.
4816 */ 4824 */
4817 4825
4818 static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) 4826 static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap)
4819 { 4827 {
4820 struct ata_queued_cmd *qc = NULL; 4828 struct ata_queued_cmd *qc = NULL;
4821 unsigned int i; 4829 unsigned int i;
4822 4830
4823 /* no command while frozen */ 4831 /* no command while frozen */
4824 if (unlikely(ap->pflags & ATA_PFLAG_FROZEN)) 4832 if (unlikely(ap->pflags & ATA_PFLAG_FROZEN))
4825 return NULL; 4833 return NULL;
4826 4834
4827 /* the last tag is reserved for internal command. */ 4835 /* the last tag is reserved for internal command. */
4828 for (i = 0; i < ATA_MAX_QUEUE - 1; i++) 4836 for (i = 0; i < ATA_MAX_QUEUE - 1; i++)
4829 if (!test_and_set_bit(i, &ap->qc_allocated)) { 4837 if (!test_and_set_bit(i, &ap->qc_allocated)) {
4830 qc = __ata_qc_from_tag(ap, i); 4838 qc = __ata_qc_from_tag(ap, i);
4831 break; 4839 break;
4832 } 4840 }
4833 4841
4834 if (qc) 4842 if (qc)
4835 qc->tag = i; 4843 qc->tag = i;
4836 4844
4837 return qc; 4845 return qc;
4838 } 4846 }
4839 4847
4840 /** 4848 /**
4841 * ata_qc_new_init - Request an available ATA command, and initialize it 4849 * ata_qc_new_init - Request an available ATA command, and initialize it
4842 * @dev: Device from whom we request an available command structure 4850 * @dev: Device from whom we request an available command structure
4843 * 4851 *
4844 * LOCKING: 4852 * LOCKING:
4845 * None. 4853 * None.
4846 */ 4854 */
4847 4855
4848 struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev) 4856 struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev)
4849 { 4857 {
4850 struct ata_port *ap = dev->link->ap; 4858 struct ata_port *ap = dev->link->ap;
4851 struct ata_queued_cmd *qc; 4859 struct ata_queued_cmd *qc;
4852 4860
4853 qc = ata_qc_new(ap); 4861 qc = ata_qc_new(ap);
4854 if (qc) { 4862 if (qc) {
4855 qc->scsicmd = NULL; 4863 qc->scsicmd = NULL;
4856 qc->ap = ap; 4864 qc->ap = ap;
4857 qc->dev = dev; 4865 qc->dev = dev;
4858 4866
4859 ata_qc_reinit(qc); 4867 ata_qc_reinit(qc);
4860 } 4868 }
4861 4869
4862 return qc; 4870 return qc;
4863 } 4871 }
4864 4872
4865 /** 4873 /**
4866 * ata_qc_free - free unused ata_queued_cmd 4874 * ata_qc_free - free unused ata_queued_cmd
4867 * @qc: Command to complete 4875 * @qc: Command to complete
4868 * 4876 *
4869 * Designed to free unused ata_queued_cmd object 4877 * Designed to free unused ata_queued_cmd object
4870 * in case something prevents using it. 4878 * in case something prevents using it.
4871 * 4879 *
4872 * LOCKING: 4880 * LOCKING:
4873 * spin_lock_irqsave(host lock) 4881 * spin_lock_irqsave(host lock)
4874 */ 4882 */
4875 void ata_qc_free(struct ata_queued_cmd *qc) 4883 void ata_qc_free(struct ata_queued_cmd *qc)
4876 { 4884 {
4877 struct ata_port *ap; 4885 struct ata_port *ap;
4878 unsigned int tag; 4886 unsigned int tag;
4879 4887
4880 WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */ 4888 WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
4881 ap = qc->ap; 4889 ap = qc->ap;
4882 4890
4883 qc->flags = 0; 4891 qc->flags = 0;
4884 tag = qc->tag; 4892 tag = qc->tag;
4885 if (likely(ata_tag_valid(tag))) { 4893 if (likely(ata_tag_valid(tag))) {
4886 qc->tag = ATA_TAG_POISON; 4894 qc->tag = ATA_TAG_POISON;
4887 clear_bit(tag, &ap->qc_allocated); 4895 clear_bit(tag, &ap->qc_allocated);
4888 } 4896 }
4889 } 4897 }
4890 4898
4891 void __ata_qc_complete(struct ata_queued_cmd *qc) 4899 void __ata_qc_complete(struct ata_queued_cmd *qc)
4892 { 4900 {
4893 struct ata_port *ap; 4901 struct ata_port *ap;
4894 struct ata_link *link; 4902 struct ata_link *link;
4895 4903
4896 WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */ 4904 WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
4897 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE)); 4905 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
4898 ap = qc->ap; 4906 ap = qc->ap;
4899 link = qc->dev->link; 4907 link = qc->dev->link;
4900 4908
4901 if (likely(qc->flags & ATA_QCFLAG_DMAMAP)) 4909 if (likely(qc->flags & ATA_QCFLAG_DMAMAP))
4902 ata_sg_clean(qc); 4910 ata_sg_clean(qc);
4903 4911
4904 /* command should be marked inactive atomically with qc completion */ 4912 /* command should be marked inactive atomically with qc completion */
4905 if (qc->tf.protocol == ATA_PROT_NCQ) { 4913 if (qc->tf.protocol == ATA_PROT_NCQ) {
4906 link->sactive &= ~(1 << qc->tag); 4914 link->sactive &= ~(1 << qc->tag);
4907 if (!link->sactive) 4915 if (!link->sactive)
4908 ap->nr_active_links--; 4916 ap->nr_active_links--;
4909 } else { 4917 } else {
4910 link->active_tag = ATA_TAG_POISON; 4918 link->active_tag = ATA_TAG_POISON;
4911 ap->nr_active_links--; 4919 ap->nr_active_links--;
4912 } 4920 }
4913 4921
4914 /* clear exclusive status */ 4922 /* clear exclusive status */
4915 if (unlikely(qc->flags & ATA_QCFLAG_CLEAR_EXCL && 4923 if (unlikely(qc->flags & ATA_QCFLAG_CLEAR_EXCL &&
4916 ap->excl_link == link)) 4924 ap->excl_link == link))
4917 ap->excl_link = NULL; 4925 ap->excl_link = NULL;
4918 4926
4919 /* atapi: mark qc as inactive to prevent the interrupt handler 4927 /* atapi: mark qc as inactive to prevent the interrupt handler
4920 * from completing the command twice later, before the error handler 4928 * from completing the command twice later, before the error handler
4921 * is called. (when rc != 0 and atapi request sense is needed) 4929 * is called. (when rc != 0 and atapi request sense is needed)
4922 */ 4930 */
4923 qc->flags &= ~ATA_QCFLAG_ACTIVE; 4931 qc->flags &= ~ATA_QCFLAG_ACTIVE;
4924 ap->qc_active &= ~(1 << qc->tag); 4932 ap->qc_active &= ~(1 << qc->tag);
4925 4933
4926 /* call completion callback */ 4934 /* call completion callback */
4927 qc->complete_fn(qc); 4935 qc->complete_fn(qc);
4928 } 4936 }
4929 4937
4930 static void fill_result_tf(struct ata_queued_cmd *qc) 4938 static void fill_result_tf(struct ata_queued_cmd *qc)
4931 { 4939 {
4932 struct ata_port *ap = qc->ap; 4940 struct ata_port *ap = qc->ap;
4933 4941
4934 qc->result_tf.flags = qc->tf.flags; 4942 qc->result_tf.flags = qc->tf.flags;
4935 ap->ops->qc_fill_rtf(qc); 4943 ap->ops->qc_fill_rtf(qc);
4936 } 4944 }
4937 4945
4938 static void ata_verify_xfer(struct ata_queued_cmd *qc) 4946 static void ata_verify_xfer(struct ata_queued_cmd *qc)
4939 { 4947 {
4940 struct ata_device *dev = qc->dev; 4948 struct ata_device *dev = qc->dev;
4941 4949
4942 if (ata_tag_internal(qc->tag)) 4950 if (ata_tag_internal(qc->tag))
4943 return; 4951 return;
4944 4952
4945 if (ata_is_nodata(qc->tf.protocol)) 4953 if (ata_is_nodata(qc->tf.protocol))
4946 return; 4954 return;
4947 4955
4948 if ((dev->mwdma_mask || dev->udma_mask) && ata_is_pio(qc->tf.protocol)) 4956 if ((dev->mwdma_mask || dev->udma_mask) && ata_is_pio(qc->tf.protocol))
4949 return; 4957 return;
4950 4958
4951 dev->flags &= ~ATA_DFLAG_DUBIOUS_XFER; 4959 dev->flags &= ~ATA_DFLAG_DUBIOUS_XFER;
4952 } 4960 }
4953 4961
4954 /** 4962 /**
4955 * ata_qc_complete - Complete an active ATA command 4963 * ata_qc_complete - Complete an active ATA command
4956 * @qc: Command to complete 4964 * @qc: Command to complete
4957 * 4965 *
4958 * Indicate to the mid and upper layers that an ATA 4966 * Indicate to the mid and upper layers that an ATA
4959 * command has completed, with either an ok or not-ok status. 4967 * command has completed, with either an ok or not-ok status.
4960 * 4968 *
4961 * LOCKING: 4969 * LOCKING:
4962 * spin_lock_irqsave(host lock) 4970 * spin_lock_irqsave(host lock)
4963 */ 4971 */
4964 void ata_qc_complete(struct ata_queued_cmd *qc) 4972 void ata_qc_complete(struct ata_queued_cmd *qc)
4965 { 4973 {
4966 struct ata_port *ap = qc->ap; 4974 struct ata_port *ap = qc->ap;
4967 4975
4968 /* XXX: New EH and old EH use different mechanisms to 4976 /* XXX: New EH and old EH use different mechanisms to
4969 * synchronize EH with regular execution path. 4977 * synchronize EH with regular execution path.
4970 * 4978 *
4971 * In new EH, a failed qc is marked with ATA_QCFLAG_FAILED. 4979 * In new EH, a failed qc is marked with ATA_QCFLAG_FAILED.
4972 * Normal execution path is responsible for not accessing a 4980 * Normal execution path is responsible for not accessing a
4973 * failed qc. libata core enforces the rule by returning NULL 4981 * failed qc. libata core enforces the rule by returning NULL
4974 * from ata_qc_from_tag() for failed qcs. 4982 * from ata_qc_from_tag() for failed qcs.
4975 * 4983 *
4976 * Old EH depends on ata_qc_complete() nullifying completion 4984 * Old EH depends on ata_qc_complete() nullifying completion
4977 * requests if ATA_QCFLAG_EH_SCHEDULED is set. Old EH does 4985 * requests if ATA_QCFLAG_EH_SCHEDULED is set. Old EH does
4978 * not synchronize with interrupt handler. Only PIO task is 4986 * not synchronize with interrupt handler. Only PIO task is
4979 * taken care of. 4987 * taken care of.
4980 */ 4988 */
4981 if (ap->ops->error_handler) { 4989 if (ap->ops->error_handler) {
4982 struct ata_device *dev = qc->dev; 4990 struct ata_device *dev = qc->dev;
4983 struct ata_eh_info *ehi = &dev->link->eh_info; 4991 struct ata_eh_info *ehi = &dev->link->eh_info;
4984 4992
4985 if (unlikely(qc->err_mask)) 4993 if (unlikely(qc->err_mask))
4986 qc->flags |= ATA_QCFLAG_FAILED; 4994 qc->flags |= ATA_QCFLAG_FAILED;
4987 4995
4988 if (unlikely(qc->flags & ATA_QCFLAG_FAILED)) { 4996 if (unlikely(qc->flags & ATA_QCFLAG_FAILED)) {
4989 /* always fill result TF for failed qc */ 4997 /* always fill result TF for failed qc */
4990 fill_result_tf(qc); 4998 fill_result_tf(qc);
4991 4999
4992 if (!ata_tag_internal(qc->tag)) 5000 if (!ata_tag_internal(qc->tag))
4993 ata_qc_schedule_eh(qc); 5001 ata_qc_schedule_eh(qc);
4994 else 5002 else
4995 __ata_qc_complete(qc); 5003 __ata_qc_complete(qc);
4996 return; 5004 return;
4997 } 5005 }
4998 5006
4999 WARN_ON_ONCE(ap->pflags & ATA_PFLAG_FROZEN); 5007 WARN_ON_ONCE(ap->pflags & ATA_PFLAG_FROZEN);
5000 5008
5001 /* read result TF if requested */ 5009 /* read result TF if requested */
5002 if (qc->flags & ATA_QCFLAG_RESULT_TF) 5010 if (qc->flags & ATA_QCFLAG_RESULT_TF)
5003 fill_result_tf(qc); 5011 fill_result_tf(qc);
5004 5012
5005 /* Some commands need post-processing after successful 5013 /* Some commands need post-processing after successful
5006 * completion. 5014 * completion.
5007 */ 5015 */
5008 switch (qc->tf.command) { 5016 switch (qc->tf.command) {
5009 case ATA_CMD_SET_FEATURES: 5017 case ATA_CMD_SET_FEATURES:
5010 if (qc->tf.feature != SETFEATURES_WC_ON && 5018 if (qc->tf.feature != SETFEATURES_WC_ON &&
5011 qc->tf.feature != SETFEATURES_WC_OFF) 5019 qc->tf.feature != SETFEATURES_WC_OFF)
5012 break; 5020 break;
5013 /* fall through */ 5021 /* fall through */
5014 case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */ 5022 case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */
5015 case ATA_CMD_SET_MULTI: /* multi_count changed */ 5023 case ATA_CMD_SET_MULTI: /* multi_count changed */
5016 /* revalidate device */ 5024 /* revalidate device */
5017 ehi->dev_action[dev->devno] |= ATA_EH_REVALIDATE; 5025 ehi->dev_action[dev->devno] |= ATA_EH_REVALIDATE;
5018 ata_port_schedule_eh(ap); 5026 ata_port_schedule_eh(ap);
5019 break; 5027 break;
5020 5028
5021 case ATA_CMD_SLEEP: 5029 case ATA_CMD_SLEEP:
5022 dev->flags |= ATA_DFLAG_SLEEPING; 5030 dev->flags |= ATA_DFLAG_SLEEPING;
5023 break; 5031 break;
5024 } 5032 }
5025 5033
5026 if (unlikely(dev->flags & ATA_DFLAG_DUBIOUS_XFER)) 5034 if (unlikely(dev->flags & ATA_DFLAG_DUBIOUS_XFER))
5027 ata_verify_xfer(qc); 5035 ata_verify_xfer(qc);
5028 5036
5029 __ata_qc_complete(qc); 5037 __ata_qc_complete(qc);
5030 } else { 5038 } else {
5031 if (qc->flags & ATA_QCFLAG_EH_SCHEDULED) 5039 if (qc->flags & ATA_QCFLAG_EH_SCHEDULED)
5032 return; 5040 return;
5033 5041
5034 /* read result TF if failed or requested */ 5042 /* read result TF if failed or requested */
5035 if (qc->err_mask || qc->flags & ATA_QCFLAG_RESULT_TF) 5043 if (qc->err_mask || qc->flags & ATA_QCFLAG_RESULT_TF)
5036 fill_result_tf(qc); 5044 fill_result_tf(qc);
5037 5045
5038 __ata_qc_complete(qc); 5046 __ata_qc_complete(qc);
5039 } 5047 }
5040 } 5048 }
5041 5049
5042 /** 5050 /**
5043 * ata_qc_complete_multiple - Complete multiple qcs successfully 5051 * ata_qc_complete_multiple - Complete multiple qcs successfully
5044 * @ap: port in question 5052 * @ap: port in question
5045 * @qc_active: new qc_active mask 5053 * @qc_active: new qc_active mask
5046 * 5054 *
5047 * Complete in-flight commands. This functions is meant to be 5055 * Complete in-flight commands. This functions is meant to be
5048 * called from low-level driver's interrupt routine to complete 5056 * called from low-level driver's interrupt routine to complete
5049 * requests normally. ap->qc_active and @qc_active is compared 5057 * requests normally. ap->qc_active and @qc_active is compared
5050 * and commands are completed accordingly. 5058 * and commands are completed accordingly.
5051 * 5059 *
5052 * LOCKING: 5060 * LOCKING:
5053 * spin_lock_irqsave(host lock) 5061 * spin_lock_irqsave(host lock)
5054 * 5062 *
5055 * RETURNS: 5063 * RETURNS:
5056 * Number of completed commands on success, -errno otherwise. 5064 * Number of completed commands on success, -errno otherwise.
5057 */ 5065 */
5058 int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active) 5066 int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active)
5059 { 5067 {
5060 int nr_done = 0; 5068 int nr_done = 0;
5061 u32 done_mask; 5069 u32 done_mask;
5062 5070
5063 done_mask = ap->qc_active ^ qc_active; 5071 done_mask = ap->qc_active ^ qc_active;
5064 5072
5065 if (unlikely(done_mask & qc_active)) { 5073 if (unlikely(done_mask & qc_active)) {
5066 ata_port_printk(ap, KERN_ERR, "illegal qc_active transition " 5074 ata_port_printk(ap, KERN_ERR, "illegal qc_active transition "
5067 "(%08x->%08x)\n", ap->qc_active, qc_active); 5075 "(%08x->%08x)\n", ap->qc_active, qc_active);
5068 return -EINVAL; 5076 return -EINVAL;
5069 } 5077 }
5070 5078
5071 while (done_mask) { 5079 while (done_mask) {
5072 struct ata_queued_cmd *qc; 5080 struct ata_queued_cmd *qc;
5073 unsigned int tag = __ffs(done_mask); 5081 unsigned int tag = __ffs(done_mask);
5074 5082
5075 qc = ata_qc_from_tag(ap, tag); 5083 qc = ata_qc_from_tag(ap, tag);
5076 if (qc) { 5084 if (qc) {
5077 ata_qc_complete(qc); 5085 ata_qc_complete(qc);
5078 nr_done++; 5086 nr_done++;
5079 } 5087 }
5080 done_mask &= ~(1 << tag); 5088 done_mask &= ~(1 << tag);
5081 } 5089 }
5082 5090
5083 return nr_done; 5091 return nr_done;
5084 } 5092 }
5085 5093
5086 /** 5094 /**
5087 * ata_qc_issue - issue taskfile to device 5095 * ata_qc_issue - issue taskfile to device
5088 * @qc: command to issue to device 5096 * @qc: command to issue to device
5089 * 5097 *
5090 * Prepare an ATA command to submission to device. 5098 * Prepare an ATA command to submission to device.
5091 * This includes mapping the data into a DMA-able 5099 * This includes mapping the data into a DMA-able
5092 * area, filling in the S/G table, and finally 5100 * area, filling in the S/G table, and finally
5093 * writing the taskfile to hardware, starting the command. 5101 * writing the taskfile to hardware, starting the command.
5094 * 5102 *
5095 * LOCKING: 5103 * LOCKING:
5096 * spin_lock_irqsave(host lock) 5104 * spin_lock_irqsave(host lock)
5097 */ 5105 */
5098 void ata_qc_issue(struct ata_queued_cmd *qc) 5106 void ata_qc_issue(struct ata_queued_cmd *qc)
5099 { 5107 {
5100 struct ata_port *ap = qc->ap; 5108 struct ata_port *ap = qc->ap;
5101 struct ata_link *link = qc->dev->link; 5109 struct ata_link *link = qc->dev->link;
5102 u8 prot = qc->tf.protocol; 5110 u8 prot = qc->tf.protocol;
5103 5111
5104 /* Make sure only one non-NCQ command is outstanding. The 5112 /* Make sure only one non-NCQ command is outstanding. The
5105 * check is skipped for old EH because it reuses active qc to 5113 * check is skipped for old EH because it reuses active qc to
5106 * request ATAPI sense. 5114 * request ATAPI sense.
5107 */ 5115 */
5108 WARN_ON_ONCE(ap->ops->error_handler && ata_tag_valid(link->active_tag)); 5116 WARN_ON_ONCE(ap->ops->error_handler && ata_tag_valid(link->active_tag));
5109 5117
5110 if (ata_is_ncq(prot)) { 5118 if (ata_is_ncq(prot)) {
5111 WARN_ON_ONCE(link->sactive & (1 << qc->tag)); 5119 WARN_ON_ONCE(link->sactive & (1 << qc->tag));
5112 5120
5113 if (!link->sactive) 5121 if (!link->sactive)
5114 ap->nr_active_links++; 5122 ap->nr_active_links++;
5115 link->sactive |= 1 << qc->tag; 5123 link->sactive |= 1 << qc->tag;
5116 } else { 5124 } else {
5117 WARN_ON_ONCE(link->sactive); 5125 WARN_ON_ONCE(link->sactive);
5118 5126
5119 ap->nr_active_links++; 5127 ap->nr_active_links++;
5120 link->active_tag = qc->tag; 5128 link->active_tag = qc->tag;
5121 } 5129 }
5122 5130
5123 qc->flags |= ATA_QCFLAG_ACTIVE; 5131 qc->flags |= ATA_QCFLAG_ACTIVE;
5124 ap->qc_active |= 1 << qc->tag; 5132 ap->qc_active |= 1 << qc->tag;
5125 5133
5126 /* We guarantee to LLDs that they will have at least one 5134 /* We guarantee to LLDs that they will have at least one
5127 * non-zero sg if the command is a data command. 5135 * non-zero sg if the command is a data command.
5128 */ 5136 */
5129 BUG_ON(ata_is_data(prot) && (!qc->sg || !qc->n_elem || !qc->nbytes)); 5137 BUG_ON(ata_is_data(prot) && (!qc->sg || !qc->n_elem || !qc->nbytes));
5130 5138
5131 if (ata_is_dma(prot) || (ata_is_pio(prot) && 5139 if (ata_is_dma(prot) || (ata_is_pio(prot) &&
5132 (ap->flags & ATA_FLAG_PIO_DMA))) 5140 (ap->flags & ATA_FLAG_PIO_DMA)))
5133 if (ata_sg_setup(qc)) 5141 if (ata_sg_setup(qc))
5134 goto sg_err; 5142 goto sg_err;
5135 5143
5136 /* if device is sleeping, schedule reset and abort the link */ 5144 /* if device is sleeping, schedule reset and abort the link */
5137 if (unlikely(qc->dev->flags & ATA_DFLAG_SLEEPING)) { 5145 if (unlikely(qc->dev->flags & ATA_DFLAG_SLEEPING)) {
5138 link->eh_info.action |= ATA_EH_RESET; 5146 link->eh_info.action |= ATA_EH_RESET;
5139 ata_ehi_push_desc(&link->eh_info, "waking up from sleep"); 5147 ata_ehi_push_desc(&link->eh_info, "waking up from sleep");
5140 ata_link_abort(link); 5148 ata_link_abort(link);
5141 return; 5149 return;
5142 } 5150 }
5143 5151
5144 ap->ops->qc_prep(qc); 5152 ap->ops->qc_prep(qc);
5145 5153
5146 qc->err_mask |= ap->ops->qc_issue(qc); 5154 qc->err_mask |= ap->ops->qc_issue(qc);
5147 if (unlikely(qc->err_mask)) 5155 if (unlikely(qc->err_mask))
5148 goto err; 5156 goto err;
5149 return; 5157 return;
5150 5158
5151 sg_err: 5159 sg_err:
5152 qc->err_mask |= AC_ERR_SYSTEM; 5160 qc->err_mask |= AC_ERR_SYSTEM;
5153 err: 5161 err:
5154 ata_qc_complete(qc); 5162 ata_qc_complete(qc);
5155 } 5163 }
5156 5164
5157 /** 5165 /**
5158 * sata_scr_valid - test whether SCRs are accessible 5166 * sata_scr_valid - test whether SCRs are accessible
5159 * @link: ATA link to test SCR accessibility for 5167 * @link: ATA link to test SCR accessibility for
5160 * 5168 *
5161 * Test whether SCRs are accessible for @link. 5169 * Test whether SCRs are accessible for @link.
5162 * 5170 *
5163 * LOCKING: 5171 * LOCKING:
5164 * None. 5172 * None.
5165 * 5173 *
5166 * RETURNS: 5174 * RETURNS:
5167 * 1 if SCRs are accessible, 0 otherwise. 5175 * 1 if SCRs are accessible, 0 otherwise.
5168 */ 5176 */
5169 int sata_scr_valid(struct ata_link *link) 5177 int sata_scr_valid(struct ata_link *link)
5170 { 5178 {
5171 struct ata_port *ap = link->ap; 5179 struct ata_port *ap = link->ap;
5172 5180
5173 return (ap->flags & ATA_FLAG_SATA) && ap->ops->scr_read; 5181 return (ap->flags & ATA_FLAG_SATA) && ap->ops->scr_read;
5174 } 5182 }
5175 5183
5176 /** 5184 /**
5177 * sata_scr_read - read SCR register of the specified port 5185 * sata_scr_read - read SCR register of the specified port
5178 * @link: ATA link to read SCR for 5186 * @link: ATA link to read SCR for
5179 * @reg: SCR to read 5187 * @reg: SCR to read
5180 * @val: Place to store read value 5188 * @val: Place to store read value
5181 * 5189 *
5182 * Read SCR register @reg of @link into *@val. This function is 5190 * Read SCR register @reg of @link into *@val. This function is
5183 * guaranteed to succeed if @link is ap->link, the cable type of 5191 * guaranteed to succeed if @link is ap->link, the cable type of
5184 * the port is SATA and the port implements ->scr_read. 5192 * the port is SATA and the port implements ->scr_read.
5185 * 5193 *
5186 * LOCKING: 5194 * LOCKING:
5187 * None if @link is ap->link. Kernel thread context otherwise. 5195 * None if @link is ap->link. Kernel thread context otherwise.
5188 * 5196 *
5189 * RETURNS: 5197 * RETURNS:
5190 * 0 on success, negative errno on failure. 5198 * 0 on success, negative errno on failure.
5191 */ 5199 */
5192 int sata_scr_read(struct ata_link *link, int reg, u32 *val) 5200 int sata_scr_read(struct ata_link *link, int reg, u32 *val)
5193 { 5201 {
5194 if (ata_is_host_link(link)) { 5202 if (ata_is_host_link(link)) {
5195 if (sata_scr_valid(link)) 5203 if (sata_scr_valid(link))
5196 return link->ap->ops->scr_read(link, reg, val); 5204 return link->ap->ops->scr_read(link, reg, val);
5197 return -EOPNOTSUPP; 5205 return -EOPNOTSUPP;
5198 } 5206 }
5199 5207
5200 return sata_pmp_scr_read(link, reg, val); 5208 return sata_pmp_scr_read(link, reg, val);
5201 } 5209 }
5202 5210
5203 /** 5211 /**
5204 * sata_scr_write - write SCR register of the specified port 5212 * sata_scr_write - write SCR register of the specified port
5205 * @link: ATA link to write SCR for 5213 * @link: ATA link to write SCR for
5206 * @reg: SCR to write 5214 * @reg: SCR to write
5207 * @val: value to write 5215 * @val: value to write
5208 * 5216 *
5209 * Write @val to SCR register @reg of @link. This function is 5217 * Write @val to SCR register @reg of @link. This function is
5210 * guaranteed to succeed if @link is ap->link, the cable type of 5218 * guaranteed to succeed if @link is ap->link, the cable type of
5211 * the port is SATA and the port implements ->scr_read. 5219 * the port is SATA and the port implements ->scr_read.
5212 * 5220 *
5213 * LOCKING: 5221 * LOCKING:
5214 * None if @link is ap->link. Kernel thread context otherwise. 5222 * None if @link is ap->link. Kernel thread context otherwise.
5215 * 5223 *
5216 * RETURNS: 5224 * RETURNS:
5217 * 0 on success, negative errno on failure. 5225 * 0 on success, negative errno on failure.
5218 */ 5226 */
5219 int sata_scr_write(struct ata_link *link, int reg, u32 val) 5227 int sata_scr_write(struct ata_link *link, int reg, u32 val)
5220 { 5228 {
5221 if (ata_is_host_link(link)) { 5229 if (ata_is_host_link(link)) {
5222 if (sata_scr_valid(link)) 5230 if (sata_scr_valid(link))
5223 return link->ap->ops->scr_write(link, reg, val); 5231 return link->ap->ops->scr_write(link, reg, val);
5224 return -EOPNOTSUPP; 5232 return -EOPNOTSUPP;
5225 } 5233 }
5226 5234
5227 return sata_pmp_scr_write(link, reg, val); 5235 return sata_pmp_scr_write(link, reg, val);
5228 } 5236 }
5229 5237
5230 /** 5238 /**
5231 * sata_scr_write_flush - write SCR register of the specified port and flush 5239 * sata_scr_write_flush - write SCR register of the specified port and flush
5232 * @link: ATA link to write SCR for 5240 * @link: ATA link to write SCR for
5233 * @reg: SCR to write 5241 * @reg: SCR to write
5234 * @val: value to write 5242 * @val: value to write
5235 * 5243 *
5236 * This function is identical to sata_scr_write() except that this 5244 * This function is identical to sata_scr_write() except that this
5237 * function performs flush after writing to the register. 5245 * function performs flush after writing to the register.
5238 * 5246 *
5239 * LOCKING: 5247 * LOCKING:
5240 * None if @link is ap->link. Kernel thread context otherwise. 5248 * None if @link is ap->link. Kernel thread context otherwise.
5241 * 5249 *
5242 * RETURNS: 5250 * RETURNS:
5243 * 0 on success, negative errno on failure. 5251 * 0 on success, negative errno on failure.
5244 */ 5252 */
5245 int sata_scr_write_flush(struct ata_link *link, int reg, u32 val) 5253 int sata_scr_write_flush(struct ata_link *link, int reg, u32 val)
5246 { 5254 {
5247 if (ata_is_host_link(link)) { 5255 if (ata_is_host_link(link)) {
5248 int rc; 5256 int rc;
5249 5257
5250 if (sata_scr_valid(link)) { 5258 if (sata_scr_valid(link)) {
5251 rc = link->ap->ops->scr_write(link, reg, val); 5259 rc = link->ap->ops->scr_write(link, reg, val);
5252 if (rc == 0) 5260 if (rc == 0)
5253 rc = link->ap->ops->scr_read(link, reg, &val); 5261 rc = link->ap->ops->scr_read(link, reg, &val);
5254 return rc; 5262 return rc;
5255 } 5263 }
5256 return -EOPNOTSUPP; 5264 return -EOPNOTSUPP;
5257 } 5265 }
5258 5266
5259 return sata_pmp_scr_write(link, reg, val); 5267 return sata_pmp_scr_write(link, reg, val);
5260 } 5268 }
5261 5269
5262 /** 5270 /**
5263 * ata_phys_link_online - test whether the given link is online 5271 * ata_phys_link_online - test whether the given link is online
5264 * @link: ATA link to test 5272 * @link: ATA link to test
5265 * 5273 *
5266 * Test whether @link is online. Note that this function returns 5274 * Test whether @link is online. Note that this function returns
5267 * 0 if online status of @link cannot be obtained, so 5275 * 0 if online status of @link cannot be obtained, so
5268 * ata_link_online(link) != !ata_link_offline(link). 5276 * ata_link_online(link) != !ata_link_offline(link).
5269 * 5277 *
5270 * LOCKING: 5278 * LOCKING:
5271 * None. 5279 * None.
5272 * 5280 *
5273 * RETURNS: 5281 * RETURNS:
5274 * True if the port online status is available and online. 5282 * True if the port online status is available and online.
5275 */ 5283 */
5276 bool ata_phys_link_online(struct ata_link *link) 5284 bool ata_phys_link_online(struct ata_link *link)
5277 { 5285 {
5278 u32 sstatus; 5286 u32 sstatus;
5279 5287
5280 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && 5288 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 &&
5281 ata_sstatus_online(sstatus)) 5289 ata_sstatus_online(sstatus))
5282 return true; 5290 return true;
5283 return false; 5291 return false;
5284 } 5292 }
5285 5293
5286 /** 5294 /**
5287 * ata_phys_link_offline - test whether the given link is offline 5295 * ata_phys_link_offline - test whether the given link is offline
5288 * @link: ATA link to test 5296 * @link: ATA link to test
5289 * 5297 *
5290 * Test whether @link is offline. Note that this function 5298 * Test whether @link is offline. Note that this function
5291 * returns 0 if offline status of @link cannot be obtained, so 5299 * returns 0 if offline status of @link cannot be obtained, so
5292 * ata_link_online(link) != !ata_link_offline(link). 5300 * ata_link_online(link) != !ata_link_offline(link).
5293 * 5301 *
5294 * LOCKING: 5302 * LOCKING:
5295 * None. 5303 * None.
5296 * 5304 *
5297 * RETURNS: 5305 * RETURNS:
5298 * True if the port offline status is available and offline. 5306 * True if the port offline status is available and offline.
5299 */ 5307 */
5300 bool ata_phys_link_offline(struct ata_link *link) 5308 bool ata_phys_link_offline(struct ata_link *link)
5301 { 5309 {
5302 u32 sstatus; 5310 u32 sstatus;
5303 5311
5304 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && 5312 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 &&
5305 !ata_sstatus_online(sstatus)) 5313 !ata_sstatus_online(sstatus))
5306 return true; 5314 return true;
5307 return false; 5315 return false;
5308 } 5316 }
5309 5317
5310 /** 5318 /**
5311 * ata_link_online - test whether the given link is online 5319 * ata_link_online - test whether the given link is online
5312 * @link: ATA link to test 5320 * @link: ATA link to test
5313 * 5321 *
5314 * Test whether @link is online. This is identical to 5322 * Test whether @link is online. This is identical to
5315 * ata_phys_link_online() when there's no slave link. When 5323 * ata_phys_link_online() when there's no slave link. When
5316 * there's a slave link, this function should only be called on 5324 * there's a slave link, this function should only be called on
5317 * the master link and will return true if any of M/S links is 5325 * the master link and will return true if any of M/S links is
5318 * online. 5326 * online.
5319 * 5327 *
5320 * LOCKING: 5328 * LOCKING:
5321 * None. 5329 * None.
5322 * 5330 *
5323 * RETURNS: 5331 * RETURNS:
5324 * True if the port online status is available and online. 5332 * True if the port online status is available and online.
5325 */ 5333 */
5326 bool ata_link_online(struct ata_link *link) 5334 bool ata_link_online(struct ata_link *link)
5327 { 5335 {
5328 struct ata_link *slave = link->ap->slave_link; 5336 struct ata_link *slave = link->ap->slave_link;
5329 5337
5330 WARN_ON(link == slave); /* shouldn't be called on slave link */ 5338 WARN_ON(link == slave); /* shouldn't be called on slave link */
5331 5339
5332 return ata_phys_link_online(link) || 5340 return ata_phys_link_online(link) ||
5333 (slave && ata_phys_link_online(slave)); 5341 (slave && ata_phys_link_online(slave));
5334 } 5342 }
5335 5343
5336 /** 5344 /**
5337 * ata_link_offline - test whether the given link is offline 5345 * ata_link_offline - test whether the given link is offline
5338 * @link: ATA link to test 5346 * @link: ATA link to test
5339 * 5347 *
5340 * Test whether @link is offline. This is identical to 5348 * Test whether @link is offline. This is identical to
5341 * ata_phys_link_offline() when there's no slave link. When 5349 * ata_phys_link_offline() when there's no slave link. When
5342 * there's a slave link, this function should only be called on 5350 * there's a slave link, this function should only be called on
5343 * the master link and will return true if both M/S links are 5351 * the master link and will return true if both M/S links are
5344 * offline. 5352 * offline.
5345 * 5353 *
5346 * LOCKING: 5354 * LOCKING:
5347 * None. 5355 * None.
5348 * 5356 *
5349 * RETURNS: 5357 * RETURNS:
5350 * True if the port offline status is available and offline. 5358 * True if the port offline status is available and offline.
5351 */ 5359 */
5352 bool ata_link_offline(struct ata_link *link) 5360 bool ata_link_offline(struct ata_link *link)
5353 { 5361 {
5354 struct ata_link *slave = link->ap->slave_link; 5362 struct ata_link *slave = link->ap->slave_link;
5355 5363
5356 WARN_ON(link == slave); /* shouldn't be called on slave link */ 5364 WARN_ON(link == slave); /* shouldn't be called on slave link */
5357 5365
5358 return ata_phys_link_offline(link) && 5366 return ata_phys_link_offline(link) &&
5359 (!slave || ata_phys_link_offline(slave)); 5367 (!slave || ata_phys_link_offline(slave));
5360 } 5368 }
5361 5369
5362 #ifdef CONFIG_PM 5370 #ifdef CONFIG_PM
5363 static int ata_host_request_pm(struct ata_host *host, pm_message_t mesg, 5371 static int ata_host_request_pm(struct ata_host *host, pm_message_t mesg,
5364 unsigned int action, unsigned int ehi_flags, 5372 unsigned int action, unsigned int ehi_flags,
5365 int wait) 5373 int wait)
5366 { 5374 {
5367 unsigned long flags; 5375 unsigned long flags;
5368 int i, rc; 5376 int i, rc;
5369 5377
5370 for (i = 0; i < host->n_ports; i++) { 5378 for (i = 0; i < host->n_ports; i++) {
5371 struct ata_port *ap = host->ports[i]; 5379 struct ata_port *ap = host->ports[i];
5372 struct ata_link *link; 5380 struct ata_link *link;
5373 5381
5374 /* Previous resume operation might still be in 5382 /* Previous resume operation might still be in
5375 * progress. Wait for PM_PENDING to clear. 5383 * progress. Wait for PM_PENDING to clear.
5376 */ 5384 */
5377 if (ap->pflags & ATA_PFLAG_PM_PENDING) { 5385 if (ap->pflags & ATA_PFLAG_PM_PENDING) {
5378 ata_port_wait_eh(ap); 5386 ata_port_wait_eh(ap);
5379 WARN_ON(ap->pflags & ATA_PFLAG_PM_PENDING); 5387 WARN_ON(ap->pflags & ATA_PFLAG_PM_PENDING);
5380 } 5388 }
5381 5389
5382 /* request PM ops to EH */ 5390 /* request PM ops to EH */
5383 spin_lock_irqsave(ap->lock, flags); 5391 spin_lock_irqsave(ap->lock, flags);
5384 5392
5385 ap->pm_mesg = mesg; 5393 ap->pm_mesg = mesg;
5386 if (wait) { 5394 if (wait) {
5387 rc = 0; 5395 rc = 0;
5388 ap->pm_result = &rc; 5396 ap->pm_result = &rc;
5389 } 5397 }
5390 5398
5391 ap->pflags |= ATA_PFLAG_PM_PENDING; 5399 ap->pflags |= ATA_PFLAG_PM_PENDING;
5392 ata_for_each_link(link, ap, HOST_FIRST) { 5400 ata_for_each_link(link, ap, HOST_FIRST) {
5393 link->eh_info.action |= action; 5401 link->eh_info.action |= action;
5394 link->eh_info.flags |= ehi_flags; 5402 link->eh_info.flags |= ehi_flags;
5395 } 5403 }
5396 5404
5397 ata_port_schedule_eh(ap); 5405 ata_port_schedule_eh(ap);
5398 5406
5399 spin_unlock_irqrestore(ap->lock, flags); 5407 spin_unlock_irqrestore(ap->lock, flags);
5400 5408
5401 /* wait and check result */ 5409 /* wait and check result */
5402 if (wait) { 5410 if (wait) {
5403 ata_port_wait_eh(ap); 5411 ata_port_wait_eh(ap);
5404 WARN_ON(ap->pflags & ATA_PFLAG_PM_PENDING); 5412 WARN_ON(ap->pflags & ATA_PFLAG_PM_PENDING);
5405 if (rc) 5413 if (rc)
5406 return rc; 5414 return rc;
5407 } 5415 }
5408 } 5416 }
5409 5417
5410 return 0; 5418 return 0;
5411 } 5419 }
5412 5420
5413 /** 5421 /**
5414 * ata_host_suspend - suspend host 5422 * ata_host_suspend - suspend host
5415 * @host: host to suspend 5423 * @host: host to suspend
5416 * @mesg: PM message 5424 * @mesg: PM message
5417 * 5425 *
5418 * Suspend @host. Actual operation is performed by EH. This 5426 * Suspend @host. Actual operation is performed by EH. This
5419 * function requests EH to perform PM operations and waits for EH 5427 * function requests EH to perform PM operations and waits for EH
5420 * to finish. 5428 * to finish.
5421 * 5429 *
5422 * LOCKING: 5430 * LOCKING:
5423 * Kernel thread context (may sleep). 5431 * Kernel thread context (may sleep).
5424 * 5432 *
5425 * RETURNS: 5433 * RETURNS:
5426 * 0 on success, -errno on failure. 5434 * 0 on success, -errno on failure.
5427 */ 5435 */
5428 int ata_host_suspend(struct ata_host *host, pm_message_t mesg) 5436 int ata_host_suspend(struct ata_host *host, pm_message_t mesg)
5429 { 5437 {
5430 int rc; 5438 int rc;
5431 5439
5432 /* 5440 /*
5433 * disable link pm on all ports before requesting 5441 * disable link pm on all ports before requesting
5434 * any pm activity 5442 * any pm activity
5435 */ 5443 */
5436 ata_lpm_enable(host); 5444 ata_lpm_enable(host);
5437 5445
5438 rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1); 5446 rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1);
5439 if (rc == 0) 5447 if (rc == 0)
5440 host->dev->power.power_state = mesg; 5448 host->dev->power.power_state = mesg;
5441 return rc; 5449 return rc;
5442 } 5450 }
5443 5451
5444 /** 5452 /**
5445 * ata_host_resume - resume host 5453 * ata_host_resume - resume host
5446 * @host: host to resume 5454 * @host: host to resume
5447 * 5455 *
5448 * Resume @host. Actual operation is performed by EH. This 5456 * Resume @host. Actual operation is performed by EH. This
5449 * function requests EH to perform PM operations and returns. 5457 * function requests EH to perform PM operations and returns.
5450 * Note that all resume operations are performed parallely. 5458 * Note that all resume operations are performed parallely.
5451 * 5459 *
5452 * LOCKING: 5460 * LOCKING:
5453 * Kernel thread context (may sleep). 5461 * Kernel thread context (may sleep).
5454 */ 5462 */
5455 void ata_host_resume(struct ata_host *host) 5463 void ata_host_resume(struct ata_host *host)
5456 { 5464 {
5457 ata_host_request_pm(host, PMSG_ON, ATA_EH_RESET, 5465 ata_host_request_pm(host, PMSG_ON, ATA_EH_RESET,
5458 ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET, 0); 5466 ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET, 0);
5459 host->dev->power.power_state = PMSG_ON; 5467 host->dev->power.power_state = PMSG_ON;
5460 5468
5461 /* reenable link pm */ 5469 /* reenable link pm */
5462 ata_lpm_disable(host); 5470 ata_lpm_disable(host);
5463 } 5471 }
5464 #endif 5472 #endif
5465 5473
5466 /** 5474 /**
5467 * ata_dev_init - Initialize an ata_device structure 5475 * ata_dev_init - Initialize an ata_device structure
5468 * @dev: Device structure to initialize 5476 * @dev: Device structure to initialize
5469 * 5477 *
5470 * Initialize @dev in preparation for probing. 5478 * Initialize @dev in preparation for probing.
5471 * 5479 *
5472 * LOCKING: 5480 * LOCKING:
5473 * Inherited from caller. 5481 * Inherited from caller.
5474 */ 5482 */
5475 void ata_dev_init(struct ata_device *dev) 5483 void ata_dev_init(struct ata_device *dev)
5476 { 5484 {
5477 struct ata_link *link = ata_dev_phys_link(dev); 5485 struct ata_link *link = ata_dev_phys_link(dev);
5478 struct ata_port *ap = link->ap; 5486 struct ata_port *ap = link->ap;
5479 unsigned long flags; 5487 unsigned long flags;
5480 5488
5481 /* SATA spd limit is bound to the attached device, reset together */ 5489 /* SATA spd limit is bound to the attached device, reset together */
5482 link->sata_spd_limit = link->hw_sata_spd_limit; 5490 link->sata_spd_limit = link->hw_sata_spd_limit;
5483 link->sata_spd = 0; 5491 link->sata_spd = 0;
5484 5492
5485 /* High bits of dev->flags are used to record warm plug 5493 /* High bits of dev->flags are used to record warm plug
5486 * requests which occur asynchronously. Synchronize using 5494 * requests which occur asynchronously. Synchronize using
5487 * host lock. 5495 * host lock.
5488 */ 5496 */
5489 spin_lock_irqsave(ap->lock, flags); 5497 spin_lock_irqsave(ap->lock, flags);
5490 dev->flags &= ~ATA_DFLAG_INIT_MASK; 5498 dev->flags &= ~ATA_DFLAG_INIT_MASK;
5491 dev->horkage = 0; 5499 dev->horkage = 0;
5492 spin_unlock_irqrestore(ap->lock, flags); 5500 spin_unlock_irqrestore(ap->lock, flags);
5493 5501
5494 memset((void *)dev + ATA_DEVICE_CLEAR_BEGIN, 0, 5502 memset((void *)dev + ATA_DEVICE_CLEAR_BEGIN, 0,
5495 ATA_DEVICE_CLEAR_END - ATA_DEVICE_CLEAR_BEGIN); 5503 ATA_DEVICE_CLEAR_END - ATA_DEVICE_CLEAR_BEGIN);
5496 dev->pio_mask = UINT_MAX; 5504 dev->pio_mask = UINT_MAX;
5497 dev->mwdma_mask = UINT_MAX; 5505 dev->mwdma_mask = UINT_MAX;
5498 dev->udma_mask = UINT_MAX; 5506 dev->udma_mask = UINT_MAX;
5499 } 5507 }
5500 5508
5501 /** 5509 /**
5502 * ata_link_init - Initialize an ata_link structure 5510 * ata_link_init - Initialize an ata_link structure
5503 * @ap: ATA port link is attached to 5511 * @ap: ATA port link is attached to
5504 * @link: Link structure to initialize 5512 * @link: Link structure to initialize
5505 * @pmp: Port multiplier port number 5513 * @pmp: Port multiplier port number
5506 * 5514 *
5507 * Initialize @link. 5515 * Initialize @link.
5508 * 5516 *
5509 * LOCKING: 5517 * LOCKING:
5510 * Kernel thread context (may sleep) 5518 * Kernel thread context (may sleep)
5511 */ 5519 */
5512 void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp) 5520 void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp)
5513 { 5521 {
5514 int i; 5522 int i;
5515 5523
5516 /* clear everything except for devices */ 5524 /* clear everything except for devices */
5517 memset(link, 0, offsetof(struct ata_link, device[0])); 5525 memset(link, 0, offsetof(struct ata_link, device[0]));
5518 5526
5519 link->ap = ap; 5527 link->ap = ap;
5520 link->pmp = pmp; 5528 link->pmp = pmp;
5521 link->active_tag = ATA_TAG_POISON; 5529 link->active_tag = ATA_TAG_POISON;
5522 link->hw_sata_spd_limit = UINT_MAX; 5530 link->hw_sata_spd_limit = UINT_MAX;
5523 5531
5524 /* can't use iterator, ap isn't initialized yet */ 5532 /* can't use iterator, ap isn't initialized yet */
5525 for (i = 0; i < ATA_MAX_DEVICES; i++) { 5533 for (i = 0; i < ATA_MAX_DEVICES; i++) {
5526 struct ata_device *dev = &link->device[i]; 5534 struct ata_device *dev = &link->device[i];
5527 5535
5528 dev->link = link; 5536 dev->link = link;
5529 dev->devno = dev - link->device; 5537 dev->devno = dev - link->device;
5530 #ifdef CONFIG_ATA_ACPI 5538 #ifdef CONFIG_ATA_ACPI
5531 dev->gtf_filter = ata_acpi_gtf_filter; 5539 dev->gtf_filter = ata_acpi_gtf_filter;
5532 #endif 5540 #endif
5533 ata_dev_init(dev); 5541 ata_dev_init(dev);
5534 } 5542 }
5535 } 5543 }
5536 5544
5537 /** 5545 /**
5538 * sata_link_init_spd - Initialize link->sata_spd_limit 5546 * sata_link_init_spd - Initialize link->sata_spd_limit
5539 * @link: Link to configure sata_spd_limit for 5547 * @link: Link to configure sata_spd_limit for
5540 * 5548 *
5541 * Initialize @link->[hw_]sata_spd_limit to the currently 5549 * Initialize @link->[hw_]sata_spd_limit to the currently
5542 * configured value. 5550 * configured value.
5543 * 5551 *
5544 * LOCKING: 5552 * LOCKING:
5545 * Kernel thread context (may sleep). 5553 * Kernel thread context (may sleep).
5546 * 5554 *
5547 * RETURNS: 5555 * RETURNS:
5548 * 0 on success, -errno on failure. 5556 * 0 on success, -errno on failure.
5549 */ 5557 */
5550 int sata_link_init_spd(struct ata_link *link) 5558 int sata_link_init_spd(struct ata_link *link)
5551 { 5559 {
5552 u8 spd; 5560 u8 spd;
5553 int rc; 5561 int rc;
5554 5562
5555 rc = sata_scr_read(link, SCR_CONTROL, &link->saved_scontrol); 5563 rc = sata_scr_read(link, SCR_CONTROL, &link->saved_scontrol);
5556 if (rc) 5564 if (rc)
5557 return rc; 5565 return rc;
5558 5566
5559 spd = (link->saved_scontrol >> 4) & 0xf; 5567 spd = (link->saved_scontrol >> 4) & 0xf;
5560 if (spd) 5568 if (spd)
5561 link->hw_sata_spd_limit &= (1 << spd) - 1; 5569 link->hw_sata_spd_limit &= (1 << spd) - 1;
5562 5570
5563 ata_force_link_limits(link); 5571 ata_force_link_limits(link);
5564 5572
5565 link->sata_spd_limit = link->hw_sata_spd_limit; 5573 link->sata_spd_limit = link->hw_sata_spd_limit;
5566 5574
5567 return 0; 5575 return 0;
5568 } 5576 }
5569 5577
5570 /** 5578 /**
5571 * ata_port_alloc - allocate and initialize basic ATA port resources 5579 * ata_port_alloc - allocate and initialize basic ATA port resources
5572 * @host: ATA host this allocated port belongs to 5580 * @host: ATA host this allocated port belongs to
5573 * 5581 *
5574 * Allocate and initialize basic ATA port resources. 5582 * Allocate and initialize basic ATA port resources.
5575 * 5583 *
5576 * RETURNS: 5584 * RETURNS:
5577 * Allocate ATA port on success, NULL on failure. 5585 * Allocate ATA port on success, NULL on failure.
5578 * 5586 *
5579 * LOCKING: 5587 * LOCKING:
5580 * Inherited from calling layer (may sleep). 5588 * Inherited from calling layer (may sleep).
5581 */ 5589 */
5582 struct ata_port *ata_port_alloc(struct ata_host *host) 5590 struct ata_port *ata_port_alloc(struct ata_host *host)
5583 { 5591 {
5584 struct ata_port *ap; 5592 struct ata_port *ap;
5585 5593
5586 DPRINTK("ENTER\n"); 5594 DPRINTK("ENTER\n");
5587 5595
5588 ap = kzalloc(sizeof(*ap), GFP_KERNEL); 5596 ap = kzalloc(sizeof(*ap), GFP_KERNEL);
5589 if (!ap) 5597 if (!ap)
5590 return NULL; 5598 return NULL;
5591 5599
5592 ap->pflags |= ATA_PFLAG_INITIALIZING; 5600 ap->pflags |= ATA_PFLAG_INITIALIZING;
5593 ap->lock = &host->lock; 5601 ap->lock = &host->lock;
5594 ap->print_id = -1; 5602 ap->print_id = -1;
5595 ap->host = host; 5603 ap->host = host;
5596 ap->dev = host->dev; 5604 ap->dev = host->dev;
5597 5605
5598 #if defined(ATA_VERBOSE_DEBUG) 5606 #if defined(ATA_VERBOSE_DEBUG)
5599 /* turn on all debugging levels */ 5607 /* turn on all debugging levels */
5600 ap->msg_enable = 0x00FF; 5608 ap->msg_enable = 0x00FF;
5601 #elif defined(ATA_DEBUG) 5609 #elif defined(ATA_DEBUG)
5602 ap->msg_enable = ATA_MSG_DRV | ATA_MSG_INFO | ATA_MSG_CTL | ATA_MSG_WARN | ATA_MSG_ERR; 5610 ap->msg_enable = ATA_MSG_DRV | ATA_MSG_INFO | ATA_MSG_CTL | ATA_MSG_WARN | ATA_MSG_ERR;
5603 #else 5611 #else
5604 ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN; 5612 ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN;
5605 #endif 5613 #endif
5606 5614
5607 INIT_DELAYED_WORK(&ap->hotplug_task, ata_scsi_hotplug); 5615 INIT_DELAYED_WORK(&ap->hotplug_task, ata_scsi_hotplug);
5608 INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan); 5616 INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan);
5609 INIT_LIST_HEAD(&ap->eh_done_q); 5617 INIT_LIST_HEAD(&ap->eh_done_q);
5610 init_waitqueue_head(&ap->eh_wait_q); 5618 init_waitqueue_head(&ap->eh_wait_q);
5611 init_completion(&ap->park_req_pending); 5619 init_completion(&ap->park_req_pending);
5612 init_timer_deferrable(&ap->fastdrain_timer); 5620 init_timer_deferrable(&ap->fastdrain_timer);
5613 ap->fastdrain_timer.function = ata_eh_fastdrain_timerfn; 5621 ap->fastdrain_timer.function = ata_eh_fastdrain_timerfn;
5614 ap->fastdrain_timer.data = (unsigned long)ap; 5622 ap->fastdrain_timer.data = (unsigned long)ap;
5615 5623
5616 ap->cbl = ATA_CBL_NONE; 5624 ap->cbl = ATA_CBL_NONE;
5617 5625
5618 ata_link_init(ap, &ap->link, 0); 5626 ata_link_init(ap, &ap->link, 0);
5619 5627
5620 #ifdef ATA_IRQ_TRAP 5628 #ifdef ATA_IRQ_TRAP
5621 ap->stats.unhandled_irq = 1; 5629 ap->stats.unhandled_irq = 1;
5622 ap->stats.idle_irq = 1; 5630 ap->stats.idle_irq = 1;
5623 #endif 5631 #endif
5624 ata_sff_port_init(ap); 5632 ata_sff_port_init(ap);
5625 5633
5626 return ap; 5634 return ap;
5627 } 5635 }
5628 5636
5629 static void ata_host_release(struct device *gendev, void *res) 5637 static void ata_host_release(struct device *gendev, void *res)
5630 { 5638 {
5631 struct ata_host *host = dev_get_drvdata(gendev); 5639 struct ata_host *host = dev_get_drvdata(gendev);
5632 int i; 5640 int i;
5633 5641
5634 for (i = 0; i < host->n_ports; i++) { 5642 for (i = 0; i < host->n_ports; i++) {
5635 struct ata_port *ap = host->ports[i]; 5643 struct ata_port *ap = host->ports[i];
5636 5644
5637 if (!ap) 5645 if (!ap)
5638 continue; 5646 continue;
5639 5647
5640 if (ap->scsi_host) 5648 if (ap->scsi_host)
5641 scsi_host_put(ap->scsi_host); 5649 scsi_host_put(ap->scsi_host);
5642 5650
5643 kfree(ap->pmp_link); 5651 kfree(ap->pmp_link);
5644 kfree(ap->slave_link); 5652 kfree(ap->slave_link);
5645 kfree(ap); 5653 kfree(ap);
5646 host->ports[i] = NULL; 5654 host->ports[i] = NULL;
5647 } 5655 }
5648 5656
5649 dev_set_drvdata(gendev, NULL); 5657 dev_set_drvdata(gendev, NULL);
5650 } 5658 }
5651 5659
5652 /** 5660 /**
5653 * ata_host_alloc - allocate and init basic ATA host resources 5661 * ata_host_alloc - allocate and init basic ATA host resources
5654 * @dev: generic device this host is associated with 5662 * @dev: generic device this host is associated with
5655 * @max_ports: maximum number of ATA ports associated with this host 5663 * @max_ports: maximum number of ATA ports associated with this host
5656 * 5664 *
5657 * Allocate and initialize basic ATA host resources. LLD calls 5665 * Allocate and initialize basic ATA host resources. LLD calls
5658 * this function to allocate a host, initializes it fully and 5666 * this function to allocate a host, initializes it fully and
5659 * attaches it using ata_host_register(). 5667 * attaches it using ata_host_register().
5660 * 5668 *
5661 * @max_ports ports are allocated and host->n_ports is 5669 * @max_ports ports are allocated and host->n_ports is
5662 * initialized to @max_ports. The caller is allowed to decrease 5670 * initialized to @max_ports. The caller is allowed to decrease
5663 * host->n_ports before calling ata_host_register(). The unused 5671 * host->n_ports before calling ata_host_register(). The unused
5664 * ports will be automatically freed on registration. 5672 * ports will be automatically freed on registration.
5665 * 5673 *
5666 * RETURNS: 5674 * RETURNS:
5667 * Allocate ATA host on success, NULL on failure. 5675 * Allocate ATA host on success, NULL on failure.
5668 * 5676 *
5669 * LOCKING: 5677 * LOCKING:
5670 * Inherited from calling layer (may sleep). 5678 * Inherited from calling layer (may sleep).
5671 */ 5679 */
5672 struct ata_host *ata_host_alloc(struct device *dev, int max_ports) 5680 struct ata_host *ata_host_alloc(struct device *dev, int max_ports)
5673 { 5681 {
5674 struct ata_host *host; 5682 struct ata_host *host;
5675 size_t sz; 5683 size_t sz;
5676 int i; 5684 int i;
5677 5685
5678 DPRINTK("ENTER\n"); 5686 DPRINTK("ENTER\n");
5679 5687
5680 if (!devres_open_group(dev, NULL, GFP_KERNEL)) 5688 if (!devres_open_group(dev, NULL, GFP_KERNEL))
5681 return NULL; 5689 return NULL;
5682 5690
5683 /* alloc a container for our list of ATA ports (buses) */ 5691 /* alloc a container for our list of ATA ports (buses) */
5684 sz = sizeof(struct ata_host) + (max_ports + 1) * sizeof(void *); 5692 sz = sizeof(struct ata_host) + (max_ports + 1) * sizeof(void *);
5685 /* alloc a container for our list of ATA ports (buses) */ 5693 /* alloc a container for our list of ATA ports (buses) */
5686 host = devres_alloc(ata_host_release, sz, GFP_KERNEL); 5694 host = devres_alloc(ata_host_release, sz, GFP_KERNEL);
5687 if (!host) 5695 if (!host)
5688 goto err_out; 5696 goto err_out;
5689 5697
5690 devres_add(dev, host); 5698 devres_add(dev, host);
5691 dev_set_drvdata(dev, host); 5699 dev_set_drvdata(dev, host);
5692 5700
5693 spin_lock_init(&host->lock); 5701 spin_lock_init(&host->lock);
5694 host->dev = dev; 5702 host->dev = dev;
5695 host->n_ports = max_ports; 5703 host->n_ports = max_ports;
5696 5704
5697 /* allocate ports bound to this host */ 5705 /* allocate ports bound to this host */
5698 for (i = 0; i < max_ports; i++) { 5706 for (i = 0; i < max_ports; i++) {
5699 struct ata_port *ap; 5707 struct ata_port *ap;
5700 5708
5701 ap = ata_port_alloc(host); 5709 ap = ata_port_alloc(host);
5702 if (!ap) 5710 if (!ap)
5703 goto err_out; 5711 goto err_out;
5704 5712
5705 ap->port_no = i; 5713 ap->port_no = i;
5706 host->ports[i] = ap; 5714 host->ports[i] = ap;
5707 } 5715 }
5708 5716
5709 devres_remove_group(dev, NULL); 5717 devres_remove_group(dev, NULL);
5710 return host; 5718 return host;
5711 5719
5712 err_out: 5720 err_out:
5713 devres_release_group(dev, NULL); 5721 devres_release_group(dev, NULL);
5714 return NULL; 5722 return NULL;
5715 } 5723 }
5716 5724
5717 /** 5725 /**
5718 * ata_host_alloc_pinfo - alloc host and init with port_info array 5726 * ata_host_alloc_pinfo - alloc host and init with port_info array
5719 * @dev: generic device this host is associated with 5727 * @dev: generic device this host is associated with
5720 * @ppi: array of ATA port_info to initialize host with 5728 * @ppi: array of ATA port_info to initialize host with
5721 * @n_ports: number of ATA ports attached to this host 5729 * @n_ports: number of ATA ports attached to this host
5722 * 5730 *
5723 * Allocate ATA host and initialize with info from @ppi. If NULL 5731 * Allocate ATA host and initialize with info from @ppi. If NULL
5724 * terminated, @ppi may contain fewer entries than @n_ports. The 5732 * terminated, @ppi may contain fewer entries than @n_ports. The
5725 * last entry will be used for the remaining ports. 5733 * last entry will be used for the remaining ports.
5726 * 5734 *
5727 * RETURNS: 5735 * RETURNS:
5728 * Allocate ATA host on success, NULL on failure. 5736 * Allocate ATA host on success, NULL on failure.
5729 * 5737 *
5730 * LOCKING: 5738 * LOCKING:
5731 * Inherited from calling layer (may sleep). 5739 * Inherited from calling layer (may sleep).
5732 */ 5740 */
5733 struct ata_host *ata_host_alloc_pinfo(struct device *dev, 5741 struct ata_host *ata_host_alloc_pinfo(struct device *dev,
5734 const struct ata_port_info * const * ppi, 5742 const struct ata_port_info * const * ppi,
5735 int n_ports) 5743 int n_ports)
5736 { 5744 {
5737 const struct ata_port_info *pi; 5745 const struct ata_port_info *pi;
5738 struct ata_host *host; 5746 struct ata_host *host;
5739 int i, j; 5747 int i, j;
5740 5748
5741 host = ata_host_alloc(dev, n_ports); 5749 host = ata_host_alloc(dev, n_ports);
5742 if (!host) 5750 if (!host)
5743 return NULL; 5751 return NULL;
5744 5752
5745 for (i = 0, j = 0, pi = NULL; i < host->n_ports; i++) { 5753 for (i = 0, j = 0, pi = NULL; i < host->n_ports; i++) {
5746 struct ata_port *ap = host->ports[i]; 5754 struct ata_port *ap = host->ports[i];
5747 5755
5748 if (ppi[j]) 5756 if (ppi[j])
5749 pi = ppi[j++]; 5757 pi = ppi[j++];
5750 5758
5751 ap->pio_mask = pi->pio_mask; 5759 ap->pio_mask = pi->pio_mask;
5752 ap->mwdma_mask = pi->mwdma_mask; 5760 ap->mwdma_mask = pi->mwdma_mask;
5753 ap->udma_mask = pi->udma_mask; 5761 ap->udma_mask = pi->udma_mask;
5754 ap->flags |= pi->flags; 5762 ap->flags |= pi->flags;
5755 ap->link.flags |= pi->link_flags; 5763 ap->link.flags |= pi->link_flags;
5756 ap->ops = pi->port_ops; 5764 ap->ops = pi->port_ops;
5757 5765
5758 if (!host->ops && (pi->port_ops != &ata_dummy_port_ops)) 5766 if (!host->ops && (pi->port_ops != &ata_dummy_port_ops))
5759 host->ops = pi->port_ops; 5767 host->ops = pi->port_ops;
5760 } 5768 }
5761 5769
5762 return host; 5770 return host;
5763 } 5771 }
5764 5772
5765 /** 5773 /**
5766 * ata_slave_link_init - initialize slave link 5774 * ata_slave_link_init - initialize slave link
5767 * @ap: port to initialize slave link for 5775 * @ap: port to initialize slave link for
5768 * 5776 *
5769 * Create and initialize slave link for @ap. This enables slave 5777 * Create and initialize slave link for @ap. This enables slave
5770 * link handling on the port. 5778 * link handling on the port.
5771 * 5779 *
5772 * In libata, a port contains links and a link contains devices. 5780 * In libata, a port contains links and a link contains devices.
5773 * There is single host link but if a PMP is attached to it, 5781 * There is single host link but if a PMP is attached to it,
5774 * there can be multiple fan-out links. On SATA, there's usually 5782 * there can be multiple fan-out links. On SATA, there's usually
5775 * a single device connected to a link but PATA and SATA 5783 * a single device connected to a link but PATA and SATA
5776 * controllers emulating TF based interface can have two - master 5784 * controllers emulating TF based interface can have two - master
5777 * and slave. 5785 * and slave.
5778 * 5786 *
5779 * However, there are a few controllers which don't fit into this 5787 * However, there are a few controllers which don't fit into this
5780 * abstraction too well - SATA controllers which emulate TF 5788 * abstraction too well - SATA controllers which emulate TF
5781 * interface with both master and slave devices but also have 5789 * interface with both master and slave devices but also have
5782 * separate SCR register sets for each device. These controllers 5790 * separate SCR register sets for each device. These controllers
5783 * need separate links for physical link handling 5791 * need separate links for physical link handling
5784 * (e.g. onlineness, link speed) but should be treated like a 5792 * (e.g. onlineness, link speed) but should be treated like a
5785 * traditional M/S controller for everything else (e.g. command 5793 * traditional M/S controller for everything else (e.g. command
5786 * issue, softreset). 5794 * issue, softreset).
5787 * 5795 *
5788 * slave_link is libata's way of handling this class of 5796 * slave_link is libata's way of handling this class of
5789 * controllers without impacting core layer too much. For 5797 * controllers without impacting core layer too much. For
5790 * anything other than physical link handling, the default host 5798 * anything other than physical link handling, the default host
5791 * link is used for both master and slave. For physical link 5799 * link is used for both master and slave. For physical link
5792 * handling, separate @ap->slave_link is used. All dirty details 5800 * handling, separate @ap->slave_link is used. All dirty details
5793 * are implemented inside libata core layer. From LLD's POV, the 5801 * are implemented inside libata core layer. From LLD's POV, the
5794 * only difference is that prereset, hardreset and postreset are 5802 * only difference is that prereset, hardreset and postreset are
5795 * called once more for the slave link, so the reset sequence 5803 * called once more for the slave link, so the reset sequence
5796 * looks like the following. 5804 * looks like the following.
5797 * 5805 *
5798 * prereset(M) -> prereset(S) -> hardreset(M) -> hardreset(S) -> 5806 * prereset(M) -> prereset(S) -> hardreset(M) -> hardreset(S) ->
5799 * softreset(M) -> postreset(M) -> postreset(S) 5807 * softreset(M) -> postreset(M) -> postreset(S)
5800 * 5808 *
5801 * Note that softreset is called only for the master. Softreset 5809 * Note that softreset is called only for the master. Softreset
5802 * resets both M/S by definition, so SRST on master should handle 5810 * resets both M/S by definition, so SRST on master should handle
5803 * both (the standard method will work just fine). 5811 * both (the standard method will work just fine).
5804 * 5812 *
5805 * LOCKING: 5813 * LOCKING:
5806 * Should be called before host is registered. 5814 * Should be called before host is registered.
5807 * 5815 *
5808 * RETURNS: 5816 * RETURNS:
5809 * 0 on success, -errno on failure. 5817 * 0 on success, -errno on failure.
5810 */ 5818 */
5811 int ata_slave_link_init(struct ata_port *ap) 5819 int ata_slave_link_init(struct ata_port *ap)
5812 { 5820 {
5813 struct ata_link *link; 5821 struct ata_link *link;
5814 5822
5815 WARN_ON(ap->slave_link); 5823 WARN_ON(ap->slave_link);
5816 WARN_ON(ap->flags & ATA_FLAG_PMP); 5824 WARN_ON(ap->flags & ATA_FLAG_PMP);
5817 5825
5818 link = kzalloc(sizeof(*link), GFP_KERNEL); 5826 link = kzalloc(sizeof(*link), GFP_KERNEL);
5819 if (!link) 5827 if (!link)
5820 return -ENOMEM; 5828 return -ENOMEM;
5821 5829
5822 ata_link_init(ap, link, 1); 5830 ata_link_init(ap, link, 1);
5823 ap->slave_link = link; 5831 ap->slave_link = link;
5824 return 0; 5832 return 0;
5825 } 5833 }
5826 5834
5827 static void ata_host_stop(struct device *gendev, void *res) 5835 static void ata_host_stop(struct device *gendev, void *res)
5828 { 5836 {
5829 struct ata_host *host = dev_get_drvdata(gendev); 5837 struct ata_host *host = dev_get_drvdata(gendev);
5830 int i; 5838 int i;
5831 5839
5832 WARN_ON(!(host->flags & ATA_HOST_STARTED)); 5840 WARN_ON(!(host->flags & ATA_HOST_STARTED));
5833 5841
5834 for (i = 0; i < host->n_ports; i++) { 5842 for (i = 0; i < host->n_ports; i++) {
5835 struct ata_port *ap = host->ports[i]; 5843 struct ata_port *ap = host->ports[i];
5836 5844
5837 if (ap->ops->port_stop) 5845 if (ap->ops->port_stop)
5838 ap->ops->port_stop(ap); 5846 ap->ops->port_stop(ap);
5839 } 5847 }
5840 5848
5841 if (host->ops->host_stop) 5849 if (host->ops->host_stop)
5842 host->ops->host_stop(host); 5850 host->ops->host_stop(host);
5843 } 5851 }
5844 5852
5845 /** 5853 /**
5846 * ata_finalize_port_ops - finalize ata_port_operations 5854 * ata_finalize_port_ops - finalize ata_port_operations
5847 * @ops: ata_port_operations to finalize 5855 * @ops: ata_port_operations to finalize
5848 * 5856 *
5849 * An ata_port_operations can inherit from another ops and that 5857 * An ata_port_operations can inherit from another ops and that
5850 * ops can again inherit from another. This can go on as many 5858 * ops can again inherit from another. This can go on as many
5851 * times as necessary as long as there is no loop in the 5859 * times as necessary as long as there is no loop in the
5852 * inheritance chain. 5860 * inheritance chain.
5853 * 5861 *
5854 * Ops tables are finalized when the host is started. NULL or 5862 * Ops tables are finalized when the host is started. NULL or
5855 * unspecified entries are inherited from the closet ancestor 5863 * unspecified entries are inherited from the closet ancestor
5856 * which has the method and the entry is populated with it. 5864 * which has the method and the entry is populated with it.
5857 * After finalization, the ops table directly points to all the 5865 * After finalization, the ops table directly points to all the
5858 * methods and ->inherits is no longer necessary and cleared. 5866 * methods and ->inherits is no longer necessary and cleared.
5859 * 5867 *
5860 * Using ATA_OP_NULL, inheriting ops can force a method to NULL. 5868 * Using ATA_OP_NULL, inheriting ops can force a method to NULL.
5861 * 5869 *
5862 * LOCKING: 5870 * LOCKING:
5863 * None. 5871 * None.
5864 */ 5872 */
5865 static void ata_finalize_port_ops(struct ata_port_operations *ops) 5873 static void ata_finalize_port_ops(struct ata_port_operations *ops)
5866 { 5874 {
5867 static DEFINE_SPINLOCK(lock); 5875 static DEFINE_SPINLOCK(lock);
5868 const struct ata_port_operations *cur; 5876 const struct ata_port_operations *cur;
5869 void **begin = (void **)ops; 5877 void **begin = (void **)ops;
5870 void **end = (void **)&ops->inherits; 5878 void **end = (void **)&ops->inherits;
5871 void **pp; 5879 void **pp;
5872 5880
5873 if (!ops || !ops->inherits) 5881 if (!ops || !ops->inherits)
5874 return; 5882 return;
5875 5883
5876 spin_lock(&lock); 5884 spin_lock(&lock);
5877 5885
5878 for (cur = ops->inherits; cur; cur = cur->inherits) { 5886 for (cur = ops->inherits; cur; cur = cur->inherits) {
5879 void **inherit = (void **)cur; 5887 void **inherit = (void **)cur;
5880 5888
5881 for (pp = begin; pp < end; pp++, inherit++) 5889 for (pp = begin; pp < end; pp++, inherit++)
5882 if (!*pp) 5890 if (!*pp)
5883 *pp = *inherit; 5891 *pp = *inherit;
5884 } 5892 }
5885 5893
5886 for (pp = begin; pp < end; pp++) 5894 for (pp = begin; pp < end; pp++)
5887 if (IS_ERR(*pp)) 5895 if (IS_ERR(*pp))
5888 *pp = NULL; 5896 *pp = NULL;
5889 5897
5890 ops->inherits = NULL; 5898 ops->inherits = NULL;
5891 5899
5892 spin_unlock(&lock); 5900 spin_unlock(&lock);
5893 } 5901 }
5894 5902
5895 /** 5903 /**
5896 * ata_host_start - start and freeze ports of an ATA host 5904 * ata_host_start - start and freeze ports of an ATA host
5897 * @host: ATA host to start ports for 5905 * @host: ATA host to start ports for
5898 * 5906 *
5899 * Start and then freeze ports of @host. Started status is 5907 * Start and then freeze ports of @host. Started status is
5900 * recorded in host->flags, so this function can be called 5908 * recorded in host->flags, so this function can be called
5901 * multiple times. Ports are guaranteed to get started only 5909 * multiple times. Ports are guaranteed to get started only
5902 * once. If host->ops isn't initialized yet, its set to the 5910 * once. If host->ops isn't initialized yet, its set to the
5903 * first non-dummy port ops. 5911 * first non-dummy port ops.
5904 * 5912 *
5905 * LOCKING: 5913 * LOCKING:
5906 * Inherited from calling layer (may sleep). 5914 * Inherited from calling layer (may sleep).
5907 * 5915 *
5908 * RETURNS: 5916 * RETURNS:
5909 * 0 if all ports are started successfully, -errno otherwise. 5917 * 0 if all ports are started successfully, -errno otherwise.
5910 */ 5918 */
5911 int ata_host_start(struct ata_host *host) 5919 int ata_host_start(struct ata_host *host)
5912 { 5920 {
5913 int have_stop = 0; 5921 int have_stop = 0;
5914 void *start_dr = NULL; 5922 void *start_dr = NULL;
5915 int i, rc; 5923 int i, rc;
5916 5924
5917 if (host->flags & ATA_HOST_STARTED) 5925 if (host->flags & ATA_HOST_STARTED)
5918 return 0; 5926 return 0;
5919 5927
5920 ata_finalize_port_ops(host->ops); 5928 ata_finalize_port_ops(host->ops);
5921 5929
5922 for (i = 0; i < host->n_ports; i++) { 5930 for (i = 0; i < host->n_ports; i++) {
5923 struct ata_port *ap = host->ports[i]; 5931 struct ata_port *ap = host->ports[i];
5924 5932
5925 ata_finalize_port_ops(ap->ops); 5933 ata_finalize_port_ops(ap->ops);
5926 5934
5927 if (!host->ops && !ata_port_is_dummy(ap)) 5935 if (!host->ops && !ata_port_is_dummy(ap))
5928 host->ops = ap->ops; 5936 host->ops = ap->ops;
5929 5937
5930 if (ap->ops->port_stop) 5938 if (ap->ops->port_stop)
5931 have_stop = 1; 5939 have_stop = 1;
5932 } 5940 }
5933 5941
5934 if (host->ops->host_stop) 5942 if (host->ops->host_stop)
5935 have_stop = 1; 5943 have_stop = 1;
5936 5944
5937 if (have_stop) { 5945 if (have_stop) {
5938 start_dr = devres_alloc(ata_host_stop, 0, GFP_KERNEL); 5946 start_dr = devres_alloc(ata_host_stop, 0, GFP_KERNEL);
5939 if (!start_dr) 5947 if (!start_dr)
5940 return -ENOMEM; 5948 return -ENOMEM;
5941 } 5949 }
5942 5950
5943 for (i = 0; i < host->n_ports; i++) { 5951 for (i = 0; i < host->n_ports; i++) {
5944 struct ata_port *ap = host->ports[i]; 5952 struct ata_port *ap = host->ports[i];
5945 5953
5946 if (ap->ops->port_start) { 5954 if (ap->ops->port_start) {
5947 rc = ap->ops->port_start(ap); 5955 rc = ap->ops->port_start(ap);
5948 if (rc) { 5956 if (rc) {
5949 if (rc != -ENODEV) 5957 if (rc != -ENODEV)
5950 dev_printk(KERN_ERR, host->dev, 5958 dev_printk(KERN_ERR, host->dev,
5951 "failed to start port %d " 5959 "failed to start port %d "
5952 "(errno=%d)\n", i, rc); 5960 "(errno=%d)\n", i, rc);
5953 goto err_out; 5961 goto err_out;
5954 } 5962 }
5955 } 5963 }
5956 ata_eh_freeze_port(ap); 5964 ata_eh_freeze_port(ap);
5957 } 5965 }
5958 5966
5959 if (start_dr) 5967 if (start_dr)
5960 devres_add(host->dev, start_dr); 5968 devres_add(host->dev, start_dr);
5961 host->flags |= ATA_HOST_STARTED; 5969 host->flags |= ATA_HOST_STARTED;
5962 return 0; 5970 return 0;
5963 5971
5964 err_out: 5972 err_out:
5965 while (--i >= 0) { 5973 while (--i >= 0) {
5966 struct ata_port *ap = host->ports[i]; 5974 struct ata_port *ap = host->ports[i];
5967 5975
5968 if (ap->ops->port_stop) 5976 if (ap->ops->port_stop)
5969 ap->ops->port_stop(ap); 5977 ap->ops->port_stop(ap);
5970 } 5978 }
5971 devres_free(start_dr); 5979 devres_free(start_dr);
5972 return rc; 5980 return rc;
5973 } 5981 }
5974 5982
5975 /** 5983 /**
5976 * ata_sas_host_init - Initialize a host struct 5984 * ata_sas_host_init - Initialize a host struct
5977 * @host: host to initialize 5985 * @host: host to initialize
5978 * @dev: device host is attached to 5986 * @dev: device host is attached to
5979 * @flags: host flags 5987 * @flags: host flags
5980 * @ops: port_ops 5988 * @ops: port_ops
5981 * 5989 *
5982 * LOCKING: 5990 * LOCKING:
5983 * PCI/etc. bus probe sem. 5991 * PCI/etc. bus probe sem.
5984 * 5992 *
5985 */ 5993 */
5986 /* KILLME - the only user left is ipr */ 5994 /* KILLME - the only user left is ipr */
5987 void ata_host_init(struct ata_host *host, struct device *dev, 5995 void ata_host_init(struct ata_host *host, struct device *dev,
5988 unsigned long flags, struct ata_port_operations *ops) 5996 unsigned long flags, struct ata_port_operations *ops)
5989 { 5997 {
5990 spin_lock_init(&host->lock); 5998 spin_lock_init(&host->lock);
5991 host->dev = dev; 5999 host->dev = dev;
5992 host->flags = flags; 6000 host->flags = flags;
5993 host->ops = ops; 6001 host->ops = ops;
5994 } 6002 }
5995 6003
5996 6004
5997 static void async_port_probe(void *data, async_cookie_t cookie) 6005 static void async_port_probe(void *data, async_cookie_t cookie)
5998 { 6006 {
5999 int rc; 6007 int rc;
6000 struct ata_port *ap = data; 6008 struct ata_port *ap = data;
6001 6009
6002 /* 6010 /*
6003 * If we're not allowed to scan this host in parallel, 6011 * If we're not allowed to scan this host in parallel,
6004 * we need to wait until all previous scans have completed 6012 * we need to wait until all previous scans have completed
6005 * before going further. 6013 * before going further.
6006 * Jeff Garzik says this is only within a controller, so we 6014 * Jeff Garzik says this is only within a controller, so we
6007 * don't need to wait for port 0, only for later ports. 6015 * don't need to wait for port 0, only for later ports.
6008 */ 6016 */
6009 if (!(ap->host->flags & ATA_HOST_PARALLEL_SCAN) && ap->port_no != 0) 6017 if (!(ap->host->flags & ATA_HOST_PARALLEL_SCAN) && ap->port_no != 0)
6010 async_synchronize_cookie(cookie); 6018 async_synchronize_cookie(cookie);
6011 6019
6012 /* probe */ 6020 /* probe */
6013 if (ap->ops->error_handler) { 6021 if (ap->ops->error_handler) {
6014 struct ata_eh_info *ehi = &ap->link.eh_info; 6022 struct ata_eh_info *ehi = &ap->link.eh_info;
6015 unsigned long flags; 6023 unsigned long flags;
6016 6024
6017 /* kick EH for boot probing */ 6025 /* kick EH for boot probing */
6018 spin_lock_irqsave(ap->lock, flags); 6026 spin_lock_irqsave(ap->lock, flags);
6019 6027
6020 ehi->probe_mask |= ATA_ALL_DEVICES; 6028 ehi->probe_mask |= ATA_ALL_DEVICES;
6021 ehi->action |= ATA_EH_RESET | ATA_EH_LPM; 6029 ehi->action |= ATA_EH_RESET | ATA_EH_LPM;
6022 ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; 6030 ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET;
6023 6031
6024 ap->pflags &= ~ATA_PFLAG_INITIALIZING; 6032 ap->pflags &= ~ATA_PFLAG_INITIALIZING;
6025 ap->pflags |= ATA_PFLAG_LOADING; 6033 ap->pflags |= ATA_PFLAG_LOADING;
6026 ata_port_schedule_eh(ap); 6034 ata_port_schedule_eh(ap);
6027 6035
6028 spin_unlock_irqrestore(ap->lock, flags); 6036 spin_unlock_irqrestore(ap->lock, flags);
6029 6037
6030 /* wait for EH to finish */ 6038 /* wait for EH to finish */
6031 ata_port_wait_eh(ap); 6039 ata_port_wait_eh(ap);
6032 } else { 6040 } else {
6033 DPRINTK("ata%u: bus probe begin\n", ap->print_id); 6041 DPRINTK("ata%u: bus probe begin\n", ap->print_id);
6034 rc = ata_bus_probe(ap); 6042 rc = ata_bus_probe(ap);
6035 DPRINTK("ata%u: bus probe end\n", ap->print_id); 6043 DPRINTK("ata%u: bus probe end\n", ap->print_id);
6036 6044
6037 if (rc) { 6045 if (rc) {
6038 /* FIXME: do something useful here? 6046 /* FIXME: do something useful here?
6039 * Current libata behavior will 6047 * Current libata behavior will
6040 * tear down everything when 6048 * tear down everything when
6041 * the module is removed 6049 * the module is removed
6042 * or the h/w is unplugged. 6050 * or the h/w is unplugged.
6043 */ 6051 */
6044 } 6052 }
6045 } 6053 }
6046 6054
6047 /* in order to keep device order, we need to synchronize at this point */ 6055 /* in order to keep device order, we need to synchronize at this point */
6048 async_synchronize_cookie(cookie); 6056 async_synchronize_cookie(cookie);
6049 6057
6050 ata_scsi_scan_host(ap, 1); 6058 ata_scsi_scan_host(ap, 1);
6051 6059
6052 } 6060 }
6053 /** 6061 /**
6054 * ata_host_register - register initialized ATA host 6062 * ata_host_register - register initialized ATA host
6055 * @host: ATA host to register 6063 * @host: ATA host to register
6056 * @sht: template for SCSI host 6064 * @sht: template for SCSI host
6057 * 6065 *
6058 * Register initialized ATA host. @host is allocated using 6066 * Register initialized ATA host. @host is allocated using
6059 * ata_host_alloc() and fully initialized by LLD. This function 6067 * ata_host_alloc() and fully initialized by LLD. This function
6060 * starts ports, registers @host with ATA and SCSI layers and 6068 * starts ports, registers @host with ATA and SCSI layers and
6061 * probe registered devices. 6069 * probe registered devices.
6062 * 6070 *
6063 * LOCKING: 6071 * LOCKING:
6064 * Inherited from calling layer (may sleep). 6072 * Inherited from calling layer (may sleep).
6065 * 6073 *
6066 * RETURNS: 6074 * RETURNS:
6067 * 0 on success, -errno otherwise. 6075 * 0 on success, -errno otherwise.
6068 */ 6076 */
6069 int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) 6077 int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
6070 { 6078 {
6071 int i, rc; 6079 int i, rc;
6072 6080
6073 /* host must have been started */ 6081 /* host must have been started */
6074 if (!(host->flags & ATA_HOST_STARTED)) { 6082 if (!(host->flags & ATA_HOST_STARTED)) {
6075 dev_printk(KERN_ERR, host->dev, 6083 dev_printk(KERN_ERR, host->dev,
6076 "BUG: trying to register unstarted host\n"); 6084 "BUG: trying to register unstarted host\n");
6077 WARN_ON(1); 6085 WARN_ON(1);
6078 return -EINVAL; 6086 return -EINVAL;
6079 } 6087 }
6080 6088
6081 /* Blow away unused ports. This happens when LLD can't 6089 /* Blow away unused ports. This happens when LLD can't
6082 * determine the exact number of ports to allocate at 6090 * determine the exact number of ports to allocate at
6083 * allocation time. 6091 * allocation time.
6084 */ 6092 */
6085 for (i = host->n_ports; host->ports[i]; i++) 6093 for (i = host->n_ports; host->ports[i]; i++)
6086 kfree(host->ports[i]); 6094 kfree(host->ports[i]);
6087 6095
6088 /* give ports names and add SCSI hosts */ 6096 /* give ports names and add SCSI hosts */
6089 for (i = 0; i < host->n_ports; i++) 6097 for (i = 0; i < host->n_ports; i++)
6090 host->ports[i]->print_id = ata_print_id++; 6098 host->ports[i]->print_id = ata_print_id++;
6091 6099
6092 rc = ata_scsi_add_hosts(host, sht); 6100 rc = ata_scsi_add_hosts(host, sht);
6093 if (rc) 6101 if (rc)
6094 return rc; 6102 return rc;
6095 6103
6096 /* associate with ACPI nodes */ 6104 /* associate with ACPI nodes */
6097 ata_acpi_associate(host); 6105 ata_acpi_associate(host);
6098 6106
6099 /* set cable, sata_spd_limit and report */ 6107 /* set cable, sata_spd_limit and report */
6100 for (i = 0; i < host->n_ports; i++) { 6108 for (i = 0; i < host->n_ports; i++) {
6101 struct ata_port *ap = host->ports[i]; 6109 struct ata_port *ap = host->ports[i];
6102 unsigned long xfer_mask; 6110 unsigned long xfer_mask;
6103 6111
6104 /* set SATA cable type if still unset */ 6112 /* set SATA cable type if still unset */
6105 if (ap->cbl == ATA_CBL_NONE && (ap->flags & ATA_FLAG_SATA)) 6113 if (ap->cbl == ATA_CBL_NONE && (ap->flags & ATA_FLAG_SATA))
6106 ap->cbl = ATA_CBL_SATA; 6114 ap->cbl = ATA_CBL_SATA;
6107 6115
6108 /* init sata_spd_limit to the current value */ 6116 /* init sata_spd_limit to the current value */
6109 sata_link_init_spd(&ap->link); 6117 sata_link_init_spd(&ap->link);
6110 if (ap->slave_link) 6118 if (ap->slave_link)
6111 sata_link_init_spd(ap->slave_link); 6119 sata_link_init_spd(ap->slave_link);
6112 6120
6113 /* print per-port info to dmesg */ 6121 /* print per-port info to dmesg */
6114 xfer_mask = ata_pack_xfermask(ap->pio_mask, ap->mwdma_mask, 6122 xfer_mask = ata_pack_xfermask(ap->pio_mask, ap->mwdma_mask,
6115 ap->udma_mask); 6123 ap->udma_mask);
6116 6124
6117 if (!ata_port_is_dummy(ap)) { 6125 if (!ata_port_is_dummy(ap)) {
6118 ata_port_printk(ap, KERN_INFO, 6126 ata_port_printk(ap, KERN_INFO,
6119 "%cATA max %s %s\n", 6127 "%cATA max %s %s\n",
6120 (ap->flags & ATA_FLAG_SATA) ? 'S' : 'P', 6128 (ap->flags & ATA_FLAG_SATA) ? 'S' : 'P',
6121 ata_mode_string(xfer_mask), 6129 ata_mode_string(xfer_mask),
6122 ap->link.eh_info.desc); 6130 ap->link.eh_info.desc);
6123 ata_ehi_clear_desc(&ap->link.eh_info); 6131 ata_ehi_clear_desc(&ap->link.eh_info);
6124 } else 6132 } else
6125 ata_port_printk(ap, KERN_INFO, "DUMMY\n"); 6133 ata_port_printk(ap, KERN_INFO, "DUMMY\n");
6126 } 6134 }
6127 6135
6128 /* perform each probe asynchronously */ 6136 /* perform each probe asynchronously */
6129 for (i = 0; i < host->n_ports; i++) { 6137 for (i = 0; i < host->n_ports; i++) {
6130 struct ata_port *ap = host->ports[i]; 6138 struct ata_port *ap = host->ports[i];
6131 async_schedule(async_port_probe, ap); 6139 async_schedule(async_port_probe, ap);
6132 } 6140 }
6133 6141
6134 return 0; 6142 return 0;
6135 } 6143 }
6136 6144
6137 /** 6145 /**
6138 * ata_host_activate - start host, request IRQ and register it 6146 * ata_host_activate - start host, request IRQ and register it
6139 * @host: target ATA host 6147 * @host: target ATA host
6140 * @irq: IRQ to request 6148 * @irq: IRQ to request
6141 * @irq_handler: irq_handler used when requesting IRQ 6149 * @irq_handler: irq_handler used when requesting IRQ
6142 * @irq_flags: irq_flags used when requesting IRQ 6150 * @irq_flags: irq_flags used when requesting IRQ
6143 * @sht: scsi_host_template to use when registering the host 6151 * @sht: scsi_host_template to use when registering the host
6144 * 6152 *
6145 * After allocating an ATA host and initializing it, most libata 6153 * After allocating an ATA host and initializing it, most libata
6146 * LLDs perform three steps to activate the host - start host, 6154 * LLDs perform three steps to activate the host - start host,
6147 * request IRQ and register it. This helper takes necessasry 6155 * request IRQ and register it. This helper takes necessasry
6148 * arguments and performs the three steps in one go. 6156 * arguments and performs the three steps in one go.
6149 * 6157 *
6150 * An invalid IRQ skips the IRQ registration and expects the host to 6158 * An invalid IRQ skips the IRQ registration and expects the host to
6151 * have set polling mode on the port. In this case, @irq_handler 6159 * have set polling mode on the port. In this case, @irq_handler
6152 * should be NULL. 6160 * should be NULL.
6153 * 6161 *
6154 * LOCKING: 6162 * LOCKING:
6155 * Inherited from calling layer (may sleep). 6163 * Inherited from calling layer (may sleep).
6156 * 6164 *
6157 * RETURNS: 6165 * RETURNS:
6158 * 0 on success, -errno otherwise. 6166 * 0 on success, -errno otherwise.
6159 */ 6167 */
6160 int ata_host_activate(struct ata_host *host, int irq, 6168 int ata_host_activate(struct ata_host *host, int irq,
6161 irq_handler_t irq_handler, unsigned long irq_flags, 6169 irq_handler_t irq_handler, unsigned long irq_flags,
6162 struct scsi_host_template *sht) 6170 struct scsi_host_template *sht)
6163 { 6171 {
6164 int i, rc; 6172 int i, rc;
6165 6173
6166 rc = ata_host_start(host); 6174 rc = ata_host_start(host);
6167 if (rc) 6175 if (rc)
6168 return rc; 6176 return rc;
6169 6177
6170 /* Special case for polling mode */ 6178 /* Special case for polling mode */
6171 if (!irq) { 6179 if (!irq) {
6172 WARN_ON(irq_handler); 6180 WARN_ON(irq_handler);
6173 return ata_host_register(host, sht); 6181 return ata_host_register(host, sht);
6174 } 6182 }
6175 6183
6176 rc = devm_request_irq(host->dev, irq, irq_handler, irq_flags, 6184 rc = devm_request_irq(host->dev, irq, irq_handler, irq_flags,
6177 dev_driver_string(host->dev), host); 6185 dev_driver_string(host->dev), host);
6178 if (rc) 6186 if (rc)
6179 return rc; 6187 return rc;
6180 6188
6181 for (i = 0; i < host->n_ports; i++) 6189 for (i = 0; i < host->n_ports; i++)
6182 ata_port_desc(host->ports[i], "irq %d", irq); 6190 ata_port_desc(host->ports[i], "irq %d", irq);
6183 6191
6184 rc = ata_host_register(host, sht); 6192 rc = ata_host_register(host, sht);
6185 /* if failed, just free the IRQ and leave ports alone */ 6193 /* if failed, just free the IRQ and leave ports alone */
6186 if (rc) 6194 if (rc)
6187 devm_free_irq(host->dev, irq, host); 6195 devm_free_irq(host->dev, irq, host);
6188 6196
6189 return rc; 6197 return rc;
6190 } 6198 }
6191 6199
6192 /** 6200 /**
6193 * ata_port_detach - Detach ATA port in prepration of device removal 6201 * ata_port_detach - Detach ATA port in prepration of device removal
6194 * @ap: ATA port to be detached 6202 * @ap: ATA port to be detached
6195 * 6203 *
6196 * Detach all ATA devices and the associated SCSI devices of @ap; 6204 * Detach all ATA devices and the associated SCSI devices of @ap;
6197 * then, remove the associated SCSI host. @ap is guaranteed to 6205 * then, remove the associated SCSI host. @ap is guaranteed to
6198 * be quiescent on return from this function. 6206 * be quiescent on return from this function.
6199 * 6207 *
6200 * LOCKING: 6208 * LOCKING:
6201 * Kernel thread context (may sleep). 6209 * Kernel thread context (may sleep).
6202 */ 6210 */
6203 static void ata_port_detach(struct ata_port *ap) 6211 static void ata_port_detach(struct ata_port *ap)
6204 { 6212 {
6205 unsigned long flags; 6213 unsigned long flags;
6206 6214
6207 if (!ap->ops->error_handler) 6215 if (!ap->ops->error_handler)
6208 goto skip_eh; 6216 goto skip_eh;
6209 6217
6210 /* tell EH we're leaving & flush EH */ 6218 /* tell EH we're leaving & flush EH */
6211 spin_lock_irqsave(ap->lock, flags); 6219 spin_lock_irqsave(ap->lock, flags);
6212 ap->pflags |= ATA_PFLAG_UNLOADING; 6220 ap->pflags |= ATA_PFLAG_UNLOADING;
6213 ata_port_schedule_eh(ap); 6221 ata_port_schedule_eh(ap);
6214 spin_unlock_irqrestore(ap->lock, flags); 6222 spin_unlock_irqrestore(ap->lock, flags);
6215 6223
6216 /* wait till EH commits suicide */ 6224 /* wait till EH commits suicide */
6217 ata_port_wait_eh(ap); 6225 ata_port_wait_eh(ap);
6218 6226
6219 /* it better be dead now */ 6227 /* it better be dead now */
6220 WARN_ON(!(ap->pflags & ATA_PFLAG_UNLOADED)); 6228 WARN_ON(!(ap->pflags & ATA_PFLAG_UNLOADED));
6221 6229
6222 cancel_rearming_delayed_work(&ap->hotplug_task); 6230 cancel_rearming_delayed_work(&ap->hotplug_task);
6223 6231
6224 skip_eh: 6232 skip_eh:
6225 /* remove the associated SCSI host */ 6233 /* remove the associated SCSI host */
6226 scsi_remove_host(ap->scsi_host); 6234 scsi_remove_host(ap->scsi_host);
6227 } 6235 }
6228 6236
6229 /** 6237 /**
6230 * ata_host_detach - Detach all ports of an ATA host 6238 * ata_host_detach - Detach all ports of an ATA host
6231 * @host: Host to detach 6239 * @host: Host to detach
6232 * 6240 *
6233 * Detach all ports of @host. 6241 * Detach all ports of @host.
6234 * 6242 *
6235 * LOCKING: 6243 * LOCKING:
6236 * Kernel thread context (may sleep). 6244 * Kernel thread context (may sleep).
6237 */ 6245 */
6238 void ata_host_detach(struct ata_host *host) 6246 void ata_host_detach(struct ata_host *host)
6239 { 6247 {
6240 int i; 6248 int i;
6241 6249
6242 for (i = 0; i < host->n_ports; i++) 6250 for (i = 0; i < host->n_ports; i++)
6243 ata_port_detach(host->ports[i]); 6251 ata_port_detach(host->ports[i]);
6244 6252
6245 /* the host is dead now, dissociate ACPI */ 6253 /* the host is dead now, dissociate ACPI */
6246 ata_acpi_dissociate(host); 6254 ata_acpi_dissociate(host);
6247 } 6255 }
6248 6256
6249 #ifdef CONFIG_PCI 6257 #ifdef CONFIG_PCI
6250 6258
6251 /** 6259 /**
6252 * ata_pci_remove_one - PCI layer callback for device removal 6260 * ata_pci_remove_one - PCI layer callback for device removal
6253 * @pdev: PCI device that was removed 6261 * @pdev: PCI device that was removed
6254 * 6262 *
6255 * PCI layer indicates to libata via this hook that hot-unplug or 6263 * PCI layer indicates to libata via this hook that hot-unplug or
6256 * module unload event has occurred. Detach all ports. Resource 6264 * module unload event has occurred. Detach all ports. Resource
6257 * release is handled via devres. 6265 * release is handled via devres.
6258 * 6266 *
6259 * LOCKING: 6267 * LOCKING:
6260 * Inherited from PCI layer (may sleep). 6268 * Inherited from PCI layer (may sleep).
6261 */ 6269 */
6262 void ata_pci_remove_one(struct pci_dev *pdev) 6270 void ata_pci_remove_one(struct pci_dev *pdev)
6263 { 6271 {
6264 struct device *dev = &pdev->dev; 6272 struct device *dev = &pdev->dev;
6265 struct ata_host *host = dev_get_drvdata(dev); 6273 struct ata_host *host = dev_get_drvdata(dev);
6266 6274
6267 ata_host_detach(host); 6275 ata_host_detach(host);
6268 } 6276 }
6269 6277
6270 /* move to PCI subsystem */ 6278 /* move to PCI subsystem */
6271 int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits) 6279 int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits)
6272 { 6280 {
6273 unsigned long tmp = 0; 6281 unsigned long tmp = 0;
6274 6282
6275 switch (bits->width) { 6283 switch (bits->width) {
6276 case 1: { 6284 case 1: {
6277 u8 tmp8 = 0; 6285 u8 tmp8 = 0;
6278 pci_read_config_byte(pdev, bits->reg, &tmp8); 6286 pci_read_config_byte(pdev, bits->reg, &tmp8);
6279 tmp = tmp8; 6287 tmp = tmp8;
6280 break; 6288 break;
6281 } 6289 }
6282 case 2: { 6290 case 2: {
6283 u16 tmp16 = 0; 6291 u16 tmp16 = 0;
6284 pci_read_config_word(pdev, bits->reg, &tmp16); 6292 pci_read_config_word(pdev, bits->reg, &tmp16);
6285 tmp = tmp16; 6293 tmp = tmp16;
6286 break; 6294 break;
6287 } 6295 }
6288 case 4: { 6296 case 4: {
6289 u32 tmp32 = 0; 6297 u32 tmp32 = 0;
6290 pci_read_config_dword(pdev, bits->reg, &tmp32); 6298 pci_read_config_dword(pdev, bits->reg, &tmp32);
6291 tmp = tmp32; 6299 tmp = tmp32;
6292 break; 6300 break;
6293 } 6301 }
6294 6302
6295 default: 6303 default:
6296 return -EINVAL; 6304 return -EINVAL;
6297 } 6305 }
6298 6306
6299 tmp &= bits->mask; 6307 tmp &= bits->mask;
6300 6308
6301 return (tmp == bits->val) ? 1 : 0; 6309 return (tmp == bits->val) ? 1 : 0;
6302 } 6310 }
6303 6311
6304 #ifdef CONFIG_PM 6312 #ifdef CONFIG_PM
6305 void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg) 6313 void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg)
6306 { 6314 {
6307 pci_save_state(pdev); 6315 pci_save_state(pdev);
6308 pci_disable_device(pdev); 6316 pci_disable_device(pdev);
6309 6317
6310 if (mesg.event & PM_EVENT_SLEEP) 6318 if (mesg.event & PM_EVENT_SLEEP)
6311 pci_set_power_state(pdev, PCI_D3hot); 6319 pci_set_power_state(pdev, PCI_D3hot);
6312 } 6320 }
6313 6321
6314 int ata_pci_device_do_resume(struct pci_dev *pdev) 6322 int ata_pci_device_do_resume(struct pci_dev *pdev)
6315 { 6323 {
6316 int rc; 6324 int rc;
6317 6325
6318 pci_set_power_state(pdev, PCI_D0); 6326 pci_set_power_state(pdev, PCI_D0);
6319 pci_restore_state(pdev); 6327 pci_restore_state(pdev);
6320 6328
6321 rc = pcim_enable_device(pdev); 6329 rc = pcim_enable_device(pdev);
6322 if (rc) { 6330 if (rc) {
6323 dev_printk(KERN_ERR, &pdev->dev, 6331 dev_printk(KERN_ERR, &pdev->dev,
6324 "failed to enable device after resume (%d)\n", rc); 6332 "failed to enable device after resume (%d)\n", rc);
6325 return rc; 6333 return rc;
6326 } 6334 }
6327 6335
6328 pci_set_master(pdev); 6336 pci_set_master(pdev);
6329 return 0; 6337 return 0;
6330 } 6338 }
6331 6339
6332 int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg) 6340 int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
6333 { 6341 {
6334 struct ata_host *host = dev_get_drvdata(&pdev->dev); 6342 struct ata_host *host = dev_get_drvdata(&pdev->dev);
6335 int rc = 0; 6343 int rc = 0;
6336 6344
6337 rc = ata_host_suspend(host, mesg); 6345 rc = ata_host_suspend(host, mesg);
6338 if (rc) 6346 if (rc)
6339 return rc; 6347 return rc;
6340 6348
6341 ata_pci_device_do_suspend(pdev, mesg); 6349 ata_pci_device_do_suspend(pdev, mesg);
6342 6350
6343 return 0; 6351 return 0;
6344 } 6352 }
6345 6353
6346 int ata_pci_device_resume(struct pci_dev *pdev) 6354 int ata_pci_device_resume(struct pci_dev *pdev)
6347 { 6355 {
6348 struct ata_host *host = dev_get_drvdata(&pdev->dev); 6356 struct ata_host *host = dev_get_drvdata(&pdev->dev);
6349 int rc; 6357 int rc;
6350 6358
6351 rc = ata_pci_device_do_resume(pdev); 6359 rc = ata_pci_device_do_resume(pdev);
6352 if (rc == 0) 6360 if (rc == 0)
6353 ata_host_resume(host); 6361 ata_host_resume(host);
6354 return rc; 6362 return rc;
6355 } 6363 }
6356 #endif /* CONFIG_PM */ 6364 #endif /* CONFIG_PM */
6357 6365
6358 #endif /* CONFIG_PCI */ 6366 #endif /* CONFIG_PCI */
6359 6367
6360 static int __init ata_parse_force_one(char **cur, 6368 static int __init ata_parse_force_one(char **cur,
6361 struct ata_force_ent *force_ent, 6369 struct ata_force_ent *force_ent,
6362 const char **reason) 6370 const char **reason)
6363 { 6371 {
6364 /* FIXME: Currently, there's no way to tag init const data and 6372 /* FIXME: Currently, there's no way to tag init const data and
6365 * using __initdata causes build failure on some versions of 6373 * using __initdata causes build failure on some versions of
6366 * gcc. Once __initdataconst is implemented, add const to the 6374 * gcc. Once __initdataconst is implemented, add const to the
6367 * following structure. 6375 * following structure.
6368 */ 6376 */
6369 static struct ata_force_param force_tbl[] __initdata = { 6377 static struct ata_force_param force_tbl[] __initdata = {
6370 { "40c", .cbl = ATA_CBL_PATA40 }, 6378 { "40c", .cbl = ATA_CBL_PATA40 },
6371 { "80c", .cbl = ATA_CBL_PATA80 }, 6379 { "80c", .cbl = ATA_CBL_PATA80 },
6372 { "short40c", .cbl = ATA_CBL_PATA40_SHORT }, 6380 { "short40c", .cbl = ATA_CBL_PATA40_SHORT },
6373 { "unk", .cbl = ATA_CBL_PATA_UNK }, 6381 { "unk", .cbl = ATA_CBL_PATA_UNK },
6374 { "ign", .cbl = ATA_CBL_PATA_IGN }, 6382 { "ign", .cbl = ATA_CBL_PATA_IGN },
6375 { "sata", .cbl = ATA_CBL_SATA }, 6383 { "sata", .cbl = ATA_CBL_SATA },
6376 { "1.5Gbps", .spd_limit = 1 }, 6384 { "1.5Gbps", .spd_limit = 1 },
6377 { "3.0Gbps", .spd_limit = 2 }, 6385 { "3.0Gbps", .spd_limit = 2 },
6378 { "noncq", .horkage_on = ATA_HORKAGE_NONCQ }, 6386 { "noncq", .horkage_on = ATA_HORKAGE_NONCQ },
6379 { "ncq", .horkage_off = ATA_HORKAGE_NONCQ }, 6387 { "ncq", .horkage_off = ATA_HORKAGE_NONCQ },
6388 { "dump_id", .horkage_on = ATA_HORKAGE_DUMP_ID },
6380 { "pio0", .xfer_mask = 1 << (ATA_SHIFT_PIO + 0) }, 6389 { "pio0", .xfer_mask = 1 << (ATA_SHIFT_PIO + 0) },
6381 { "pio1", .xfer_mask = 1 << (ATA_SHIFT_PIO + 1) }, 6390 { "pio1", .xfer_mask = 1 << (ATA_SHIFT_PIO + 1) },
6382 { "pio2", .xfer_mask = 1 << (ATA_SHIFT_PIO + 2) }, 6391 { "pio2", .xfer_mask = 1 << (ATA_SHIFT_PIO + 2) },
6383 { "pio3", .xfer_mask = 1 << (ATA_SHIFT_PIO + 3) }, 6392 { "pio3", .xfer_mask = 1 << (ATA_SHIFT_PIO + 3) },
6384 { "pio4", .xfer_mask = 1 << (ATA_SHIFT_PIO + 4) }, 6393 { "pio4", .xfer_mask = 1 << (ATA_SHIFT_PIO + 4) },
6385 { "pio5", .xfer_mask = 1 << (ATA_SHIFT_PIO + 5) }, 6394 { "pio5", .xfer_mask = 1 << (ATA_SHIFT_PIO + 5) },
6386 { "pio6", .xfer_mask = 1 << (ATA_SHIFT_PIO + 6) }, 6395 { "pio6", .xfer_mask = 1 << (ATA_SHIFT_PIO + 6) },
6387 { "mwdma0", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 0) }, 6396 { "mwdma0", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 0) },
6388 { "mwdma1", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 1) }, 6397 { "mwdma1", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 1) },
6389 { "mwdma2", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 2) }, 6398 { "mwdma2", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 2) },
6390 { "mwdma3", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 3) }, 6399 { "mwdma3", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 3) },
6391 { "mwdma4", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 4) }, 6400 { "mwdma4", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 4) },
6392 { "udma0", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 0) }, 6401 { "udma0", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 0) },
6393 { "udma16", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 0) }, 6402 { "udma16", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 0) },
6394 { "udma/16", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 0) }, 6403 { "udma/16", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 0) },
6395 { "udma1", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 1) }, 6404 { "udma1", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 1) },
6396 { "udma25", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 1) }, 6405 { "udma25", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 1) },
6397 { "udma/25", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 1) }, 6406 { "udma/25", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 1) },
6398 { "udma2", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 2) }, 6407 { "udma2", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 2) },
6399 { "udma33", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 2) }, 6408 { "udma33", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 2) },
6400 { "udma/33", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 2) }, 6409 { "udma/33", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 2) },
6401 { "udma3", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 3) }, 6410 { "udma3", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 3) },
6402 { "udma44", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 3) }, 6411 { "udma44", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 3) },
6403 { "udma/44", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 3) }, 6412 { "udma/44", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 3) },
6404 { "udma4", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 4) }, 6413 { "udma4", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 4) },
6405 { "udma66", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 4) }, 6414 { "udma66", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 4) },
6406 { "udma/66", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 4) }, 6415 { "udma/66", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 4) },
6407 { "udma5", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 5) }, 6416 { "udma5", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 5) },
6408 { "udma100", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 5) }, 6417 { "udma100", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 5) },
6409 { "udma/100", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 5) }, 6418 { "udma/100", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 5) },
6410 { "udma6", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 6) }, 6419 { "udma6", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 6) },
6411 { "udma133", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 6) }, 6420 { "udma133", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 6) },
6412 { "udma/133", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 6) }, 6421 { "udma/133", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 6) },
6413 { "udma7", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 7) }, 6422 { "udma7", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 7) },
6414 { "nohrst", .lflags = ATA_LFLAG_NO_HRST }, 6423 { "nohrst", .lflags = ATA_LFLAG_NO_HRST },
6415 { "nosrst", .lflags = ATA_LFLAG_NO_SRST }, 6424 { "nosrst", .lflags = ATA_LFLAG_NO_SRST },
6416 { "norst", .lflags = ATA_LFLAG_NO_HRST | ATA_LFLAG_NO_SRST }, 6425 { "norst", .lflags = ATA_LFLAG_NO_HRST | ATA_LFLAG_NO_SRST },
6417 }; 6426 };
6418 char *start = *cur, *p = *cur; 6427 char *start = *cur, *p = *cur;
6419 char *id, *val, *endp; 6428 char *id, *val, *endp;
6420 const struct ata_force_param *match_fp = NULL; 6429 const struct ata_force_param *match_fp = NULL;
6421 int nr_matches = 0, i; 6430 int nr_matches = 0, i;
6422 6431
6423 /* find where this param ends and update *cur */ 6432 /* find where this param ends and update *cur */
6424 while (*p != '\0' && *p != ',') 6433 while (*p != '\0' && *p != ',')
6425 p++; 6434 p++;
6426 6435
6427 if (*p == '\0') 6436 if (*p == '\0')
6428 *cur = p; 6437 *cur = p;
6429 else 6438 else
6430 *cur = p + 1; 6439 *cur = p + 1;
6431 6440
6432 *p = '\0'; 6441 *p = '\0';
6433 6442
6434 /* parse */ 6443 /* parse */
6435 p = strchr(start, ':'); 6444 p = strchr(start, ':');
6436 if (!p) { 6445 if (!p) {
6437 val = strstrip(start); 6446 val = strstrip(start);
6438 goto parse_val; 6447 goto parse_val;
6439 } 6448 }
6440 *p = '\0'; 6449 *p = '\0';
6441 6450
6442 id = strstrip(start); 6451 id = strstrip(start);
6443 val = strstrip(p + 1); 6452 val = strstrip(p + 1);
6444 6453
6445 /* parse id */ 6454 /* parse id */
6446 p = strchr(id, '.'); 6455 p = strchr(id, '.');
6447 if (p) { 6456 if (p) {
6448 *p++ = '\0'; 6457 *p++ = '\0';
6449 force_ent->device = simple_strtoul(p, &endp, 10); 6458 force_ent->device = simple_strtoul(p, &endp, 10);
6450 if (p == endp || *endp != '\0') { 6459 if (p == endp || *endp != '\0') {
6451 *reason = "invalid device"; 6460 *reason = "invalid device";
6452 return -EINVAL; 6461 return -EINVAL;
6453 } 6462 }
6454 } 6463 }
6455 6464
6456 force_ent->port = simple_strtoul(id, &endp, 10); 6465 force_ent->port = simple_strtoul(id, &endp, 10);
6457 if (p == endp || *endp != '\0') { 6466 if (p == endp || *endp != '\0') {
6458 *reason = "invalid port/link"; 6467 *reason = "invalid port/link";
6459 return -EINVAL; 6468 return -EINVAL;
6460 } 6469 }
6461 6470
6462 parse_val: 6471 parse_val:
6463 /* parse val, allow shortcuts so that both 1.5 and 1.5Gbps work */ 6472 /* parse val, allow shortcuts so that both 1.5 and 1.5Gbps work */
6464 for (i = 0; i < ARRAY_SIZE(force_tbl); i++) { 6473 for (i = 0; i < ARRAY_SIZE(force_tbl); i++) {
6465 const struct ata_force_param *fp = &force_tbl[i]; 6474 const struct ata_force_param *fp = &force_tbl[i];
6466 6475
6467 if (strncasecmp(val, fp->name, strlen(val))) 6476 if (strncasecmp(val, fp->name, strlen(val)))
6468 continue; 6477 continue;
6469 6478
6470 nr_matches++; 6479 nr_matches++;
6471 match_fp = fp; 6480 match_fp = fp;
6472 6481
6473 if (strcasecmp(val, fp->name) == 0) { 6482 if (strcasecmp(val, fp->name) == 0) {
6474 nr_matches = 1; 6483 nr_matches = 1;
6475 break; 6484 break;
6476 } 6485 }
6477 } 6486 }
6478 6487
6479 if (!nr_matches) { 6488 if (!nr_matches) {
6480 *reason = "unknown value"; 6489 *reason = "unknown value";
6481 return -EINVAL; 6490 return -EINVAL;
6482 } 6491 }
6483 if (nr_matches > 1) { 6492 if (nr_matches > 1) {
6484 *reason = "ambigious value"; 6493 *reason = "ambigious value";
6485 return -EINVAL; 6494 return -EINVAL;
6486 } 6495 }
6487 6496
6488 force_ent->param = *match_fp; 6497 force_ent->param = *match_fp;
6489 6498
6490 return 0; 6499 return 0;
6491 } 6500 }
6492 6501
6493 static void __init ata_parse_force_param(void) 6502 static void __init ata_parse_force_param(void)
6494 { 6503 {
6495 int idx = 0, size = 1; 6504 int idx = 0, size = 1;
6496 int last_port = -1, last_device = -1; 6505 int last_port = -1, last_device = -1;
6497 char *p, *cur, *next; 6506 char *p, *cur, *next;
6498 6507
6499 /* calculate maximum number of params and allocate force_tbl */ 6508 /* calculate maximum number of params and allocate force_tbl */
6500 for (p = ata_force_param_buf; *p; p++) 6509 for (p = ata_force_param_buf; *p; p++)
6501 if (*p == ',') 6510 if (*p == ',')
6502 size++; 6511 size++;
6503 6512
6504 ata_force_tbl = kzalloc(sizeof(ata_force_tbl[0]) * size, GFP_KERNEL); 6513 ata_force_tbl = kzalloc(sizeof(ata_force_tbl[0]) * size, GFP_KERNEL);
6505 if (!ata_force_tbl) { 6514 if (!ata_force_tbl) {
6506 printk(KERN_WARNING "ata: failed to extend force table, " 6515 printk(KERN_WARNING "ata: failed to extend force table, "
6507 "libata.force ignored\n"); 6516 "libata.force ignored\n");
6508 return; 6517 return;
6509 } 6518 }
6510 6519
6511 /* parse and populate the table */ 6520 /* parse and populate the table */
6512 for (cur = ata_force_param_buf; *cur != '\0'; cur = next) { 6521 for (cur = ata_force_param_buf; *cur != '\0'; cur = next) {
6513 const char *reason = ""; 6522 const char *reason = "";
6514 struct ata_force_ent te = { .port = -1, .device = -1 }; 6523 struct ata_force_ent te = { .port = -1, .device = -1 };
6515 6524
6516 next = cur; 6525 next = cur;
6517 if (ata_parse_force_one(&next, &te, &reason)) { 6526 if (ata_parse_force_one(&next, &te, &reason)) {
6518 printk(KERN_WARNING "ata: failed to parse force " 6527 printk(KERN_WARNING "ata: failed to parse force "
6519 "parameter \"%s\" (%s)\n", 6528 "parameter \"%s\" (%s)\n",
6520 cur, reason); 6529 cur, reason);
6521 continue; 6530 continue;
6522 } 6531 }
6523 6532
6524 if (te.port == -1) { 6533 if (te.port == -1) {
6525 te.port = last_port; 6534 te.port = last_port;
6526 te.device = last_device; 6535 te.device = last_device;
6527 } 6536 }
6528 6537
6529 ata_force_tbl[idx++] = te; 6538 ata_force_tbl[idx++] = te;
6530 6539
6531 last_port = te.port; 6540 last_port = te.port;
6532 last_device = te.device; 6541 last_device = te.device;
6533 } 6542 }
6534 6543
6535 ata_force_tbl_size = idx; 6544 ata_force_tbl_size = idx;
6536 } 6545 }
6537 6546
6538 static int __init ata_init(void) 6547 static int __init ata_init(void)
6539 { 6548 {
6540 int rc = -ENOMEM; 6549 int rc = -ENOMEM;
6541 6550
6542 ata_parse_force_param(); 6551 ata_parse_force_param();
6543 6552
6544 ata_aux_wq = create_singlethread_workqueue("ata_aux"); 6553 ata_aux_wq = create_singlethread_workqueue("ata_aux");
6545 if (!ata_aux_wq) 6554 if (!ata_aux_wq)
6546 goto fail; 6555 goto fail;
6547 6556
6548 rc = ata_sff_init(); 6557 rc = ata_sff_init();
6549 if (rc) 6558 if (rc)
6550 goto fail; 6559 goto fail;
6551 6560
6552 printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n"); 6561 printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n");
6553 return 0; 6562 return 0;
6554 6563
6555 fail: 6564 fail:
6556 kfree(ata_force_tbl); 6565 kfree(ata_force_tbl);
6557 if (ata_aux_wq) 6566 if (ata_aux_wq)
6558 destroy_workqueue(ata_aux_wq); 6567 destroy_workqueue(ata_aux_wq);
6559 return rc; 6568 return rc;
6560 } 6569 }
6561 6570
6562 static void __exit ata_exit(void) 6571 static void __exit ata_exit(void)
6563 { 6572 {
6564 ata_sff_exit(); 6573 ata_sff_exit();
6565 kfree(ata_force_tbl); 6574 kfree(ata_force_tbl);
6566 destroy_workqueue(ata_aux_wq); 6575 destroy_workqueue(ata_aux_wq);
6567 } 6576 }
6568 6577
6569 subsys_initcall(ata_init); 6578 subsys_initcall(ata_init);
6570 module_exit(ata_exit); 6579 module_exit(ata_exit);
6571 6580
6572 static DEFINE_RATELIMIT_STATE(ratelimit, HZ / 5, 1); 6581 static DEFINE_RATELIMIT_STATE(ratelimit, HZ / 5, 1);
6573 6582
6574 int ata_ratelimit(void) 6583 int ata_ratelimit(void)
6575 { 6584 {
6576 return __ratelimit(&ratelimit); 6585 return __ratelimit(&ratelimit);
6577 } 6586 }
6578 6587
6579 /** 6588 /**
6580 * ata_wait_register - wait until register value changes 6589 * ata_wait_register - wait until register value changes
6581 * @reg: IO-mapped register 6590 * @reg: IO-mapped register
6582 * @mask: Mask to apply to read register value 6591 * @mask: Mask to apply to read register value
6583 * @val: Wait condition 6592 * @val: Wait condition
6584 * @interval: polling interval in milliseconds 6593 * @interval: polling interval in milliseconds
6585 * @timeout: timeout in milliseconds 6594 * @timeout: timeout in milliseconds
6586 * 6595 *
6587 * Waiting for some bits of register to change is a common 6596 * Waiting for some bits of register to change is a common
6588 * operation for ATA controllers. This function reads 32bit LE 6597 * operation for ATA controllers. This function reads 32bit LE
6589 * IO-mapped register @reg and tests for the following condition. 6598 * IO-mapped register @reg and tests for the following condition.
6590 * 6599 *
6591 * (*@reg & mask) != val 6600 * (*@reg & mask) != val
6592 * 6601 *
6593 * If the condition is met, it returns; otherwise, the process is 6602 * If the condition is met, it returns; otherwise, the process is
6594 * repeated after @interval_msec until timeout. 6603 * repeated after @interval_msec until timeout.
6595 * 6604 *
6596 * LOCKING: 6605 * LOCKING:
6597 * Kernel thread context (may sleep) 6606 * Kernel thread context (may sleep)
6598 * 6607 *
6599 * RETURNS: 6608 * RETURNS:
6600 * The final register value. 6609 * The final register value.
6601 */ 6610 */
6602 u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, 6611 u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
6603 unsigned long interval, unsigned long timeout) 6612 unsigned long interval, unsigned long timeout)
6604 { 6613 {
6605 unsigned long deadline; 6614 unsigned long deadline;
6606 u32 tmp; 6615 u32 tmp;
6607 6616
6608 tmp = ioread32(reg); 6617 tmp = ioread32(reg);
6609 6618
6610 /* Calculate timeout _after_ the first read to make sure 6619 /* Calculate timeout _after_ the first read to make sure
6611 * preceding writes reach the controller before starting to 6620 * preceding writes reach the controller before starting to
6612 * eat away the timeout. 6621 * eat away the timeout.
6613 */ 6622 */
6614 deadline = ata_deadline(jiffies, timeout); 6623 deadline = ata_deadline(jiffies, timeout);
6615 6624
6616 while ((tmp & mask) == val && time_before(jiffies, deadline)) { 6625 while ((tmp & mask) == val && time_before(jiffies, deadline)) {
6617 msleep(interval); 6626 msleep(interval);
6618 tmp = ioread32(reg); 6627 tmp = ioread32(reg);
6619 } 6628 }
6620 6629
6621 return tmp; 6630 return tmp;
6622 } 6631 }
6623 6632
6624 /* 6633 /*
6625 * Dummy port_ops 6634 * Dummy port_ops
6626 */ 6635 */
6627 static unsigned int ata_dummy_qc_issue(struct ata_queued_cmd *qc) 6636 static unsigned int ata_dummy_qc_issue(struct ata_queued_cmd *qc)
6628 { 6637 {
6629 return AC_ERR_SYSTEM; 6638 return AC_ERR_SYSTEM;
6630 } 6639 }
6631 6640
6632 static void ata_dummy_error_handler(struct ata_port *ap) 6641 static void ata_dummy_error_handler(struct ata_port *ap)
6633 { 6642 {
6634 /* truly dummy */ 6643 /* truly dummy */
6635 } 6644 }
6636 6645
6637 struct ata_port_operations ata_dummy_port_ops = { 6646 struct ata_port_operations ata_dummy_port_ops = {
6638 .qc_prep = ata_noop_qc_prep, 6647 .qc_prep = ata_noop_qc_prep,
6639 .qc_issue = ata_dummy_qc_issue, 6648 .qc_issue = ata_dummy_qc_issue,
6640 .error_handler = ata_dummy_error_handler, 6649 .error_handler = ata_dummy_error_handler,
6641 }; 6650 };
6642 6651
6643 const struct ata_port_info ata_dummy_port_info = { 6652 const struct ata_port_info ata_dummy_port_info = {
6644 .port_ops = &ata_dummy_port_ops, 6653 .port_ops = &ata_dummy_port_ops,
6645 }; 6654 };
6646 6655
6647 /* 6656 /*
6648 * libata is essentially a library of internal helper functions for 6657 * libata is essentially a library of internal helper functions for
6649 * low-level ATA host controller drivers. As such, the API/ABI is 6658 * low-level ATA host controller drivers. As such, the API/ABI is
6650 * likely to change as new drivers are added and updated. 6659 * likely to change as new drivers are added and updated.
6651 * Do not depend on ABI/API stability. 6660 * Do not depend on ABI/API stability.
6652 */ 6661 */
6653 EXPORT_SYMBOL_GPL(sata_deb_timing_normal); 6662 EXPORT_SYMBOL_GPL(sata_deb_timing_normal);
6654 EXPORT_SYMBOL_GPL(sata_deb_timing_hotplug); 6663 EXPORT_SYMBOL_GPL(sata_deb_timing_hotplug);
6655 EXPORT_SYMBOL_GPL(sata_deb_timing_long); 6664 EXPORT_SYMBOL_GPL(sata_deb_timing_long);
6656 EXPORT_SYMBOL_GPL(ata_base_port_ops); 6665 EXPORT_SYMBOL_GPL(ata_base_port_ops);
6657 EXPORT_SYMBOL_GPL(sata_port_ops); 6666 EXPORT_SYMBOL_GPL(sata_port_ops);
6658 EXPORT_SYMBOL_GPL(ata_dummy_port_ops); 6667 EXPORT_SYMBOL_GPL(ata_dummy_port_ops);
6659 EXPORT_SYMBOL_GPL(ata_dummy_port_info); 6668 EXPORT_SYMBOL_GPL(ata_dummy_port_info);
6660 EXPORT_SYMBOL_GPL(ata_link_next); 6669 EXPORT_SYMBOL_GPL(ata_link_next);
6661 EXPORT_SYMBOL_GPL(ata_dev_next); 6670 EXPORT_SYMBOL_GPL(ata_dev_next);
6662 EXPORT_SYMBOL_GPL(ata_std_bios_param); 6671 EXPORT_SYMBOL_GPL(ata_std_bios_param);
6663 EXPORT_SYMBOL_GPL(ata_host_init); 6672 EXPORT_SYMBOL_GPL(ata_host_init);
6664 EXPORT_SYMBOL_GPL(ata_host_alloc); 6673 EXPORT_SYMBOL_GPL(ata_host_alloc);
6665 EXPORT_SYMBOL_GPL(ata_host_alloc_pinfo); 6674 EXPORT_SYMBOL_GPL(ata_host_alloc_pinfo);
6666 EXPORT_SYMBOL_GPL(ata_slave_link_init); 6675 EXPORT_SYMBOL_GPL(ata_slave_link_init);
6667 EXPORT_SYMBOL_GPL(ata_host_start); 6676 EXPORT_SYMBOL_GPL(ata_host_start);
6668 EXPORT_SYMBOL_GPL(ata_host_register); 6677 EXPORT_SYMBOL_GPL(ata_host_register);
6669 EXPORT_SYMBOL_GPL(ata_host_activate); 6678 EXPORT_SYMBOL_GPL(ata_host_activate);
6670 EXPORT_SYMBOL_GPL(ata_host_detach); 6679 EXPORT_SYMBOL_GPL(ata_host_detach);
6671 EXPORT_SYMBOL_GPL(ata_sg_init); 6680 EXPORT_SYMBOL_GPL(ata_sg_init);
6672 EXPORT_SYMBOL_GPL(ata_qc_complete); 6681 EXPORT_SYMBOL_GPL(ata_qc_complete);
6673 EXPORT_SYMBOL_GPL(ata_qc_complete_multiple); 6682 EXPORT_SYMBOL_GPL(ata_qc_complete_multiple);
6674 EXPORT_SYMBOL_GPL(atapi_cmd_type); 6683 EXPORT_SYMBOL_GPL(atapi_cmd_type);
6675 EXPORT_SYMBOL_GPL(ata_tf_to_fis); 6684 EXPORT_SYMBOL_GPL(ata_tf_to_fis);
6676 EXPORT_SYMBOL_GPL(ata_tf_from_fis); 6685 EXPORT_SYMBOL_GPL(ata_tf_from_fis);
6677 EXPORT_SYMBOL_GPL(ata_pack_xfermask); 6686 EXPORT_SYMBOL_GPL(ata_pack_xfermask);
6678 EXPORT_SYMBOL_GPL(ata_unpack_xfermask); 6687 EXPORT_SYMBOL_GPL(ata_unpack_xfermask);
6679 EXPORT_SYMBOL_GPL(ata_xfer_mask2mode); 6688 EXPORT_SYMBOL_GPL(ata_xfer_mask2mode);
6680 EXPORT_SYMBOL_GPL(ata_xfer_mode2mask); 6689 EXPORT_SYMBOL_GPL(ata_xfer_mode2mask);
6681 EXPORT_SYMBOL_GPL(ata_xfer_mode2shift); 6690 EXPORT_SYMBOL_GPL(ata_xfer_mode2shift);
6682 EXPORT_SYMBOL_GPL(ata_mode_string); 6691 EXPORT_SYMBOL_GPL(ata_mode_string);
6683 EXPORT_SYMBOL_GPL(ata_id_xfermask); 6692 EXPORT_SYMBOL_GPL(ata_id_xfermask);
6684 EXPORT_SYMBOL_GPL(ata_do_set_mode); 6693 EXPORT_SYMBOL_GPL(ata_do_set_mode);
6685 EXPORT_SYMBOL_GPL(ata_std_qc_defer); 6694 EXPORT_SYMBOL_GPL(ata_std_qc_defer);
6686 EXPORT_SYMBOL_GPL(ata_noop_qc_prep); 6695 EXPORT_SYMBOL_GPL(ata_noop_qc_prep);
6687 EXPORT_SYMBOL_GPL(ata_dev_disable); 6696 EXPORT_SYMBOL_GPL(ata_dev_disable);
6688 EXPORT_SYMBOL_GPL(sata_set_spd); 6697 EXPORT_SYMBOL_GPL(sata_set_spd);
6689 EXPORT_SYMBOL_GPL(ata_wait_after_reset); 6698 EXPORT_SYMBOL_GPL(ata_wait_after_reset);
6690 EXPORT_SYMBOL_GPL(sata_link_debounce); 6699 EXPORT_SYMBOL_GPL(sata_link_debounce);
6691 EXPORT_SYMBOL_GPL(sata_link_resume); 6700 EXPORT_SYMBOL_GPL(sata_link_resume);
6692 EXPORT_SYMBOL_GPL(ata_std_prereset); 6701 EXPORT_SYMBOL_GPL(ata_std_prereset);
6693 EXPORT_SYMBOL_GPL(sata_link_hardreset); 6702 EXPORT_SYMBOL_GPL(sata_link_hardreset);
6694 EXPORT_SYMBOL_GPL(sata_std_hardreset); 6703 EXPORT_SYMBOL_GPL(sata_std_hardreset);
6695 EXPORT_SYMBOL_GPL(ata_std_postreset); 6704 EXPORT_SYMBOL_GPL(ata_std_postreset);
6696 EXPORT_SYMBOL_GPL(ata_dev_classify); 6705 EXPORT_SYMBOL_GPL(ata_dev_classify);
6697 EXPORT_SYMBOL_GPL(ata_dev_pair); 6706 EXPORT_SYMBOL_GPL(ata_dev_pair);
6698 EXPORT_SYMBOL_GPL(ata_ratelimit); 6707 EXPORT_SYMBOL_GPL(ata_ratelimit);
6699 EXPORT_SYMBOL_GPL(ata_wait_register); 6708 EXPORT_SYMBOL_GPL(ata_wait_register);
6700 EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); 6709 EXPORT_SYMBOL_GPL(ata_scsi_queuecmd);
6701 EXPORT_SYMBOL_GPL(ata_scsi_slave_config); 6710 EXPORT_SYMBOL_GPL(ata_scsi_slave_config);
6702 EXPORT_SYMBOL_GPL(ata_scsi_slave_destroy); 6711 EXPORT_SYMBOL_GPL(ata_scsi_slave_destroy);
6703 EXPORT_SYMBOL_GPL(ata_scsi_change_queue_depth); 6712 EXPORT_SYMBOL_GPL(ata_scsi_change_queue_depth);
6704 EXPORT_SYMBOL_GPL(sata_scr_valid); 6713 EXPORT_SYMBOL_GPL(sata_scr_valid);
6705 EXPORT_SYMBOL_GPL(sata_scr_read); 6714 EXPORT_SYMBOL_GPL(sata_scr_read);
6706 EXPORT_SYMBOL_GPL(sata_scr_write); 6715 EXPORT_SYMBOL_GPL(sata_scr_write);
6707 EXPORT_SYMBOL_GPL(sata_scr_write_flush); 6716 EXPORT_SYMBOL_GPL(sata_scr_write_flush);
6708 EXPORT_SYMBOL_GPL(ata_link_online); 6717 EXPORT_SYMBOL_GPL(ata_link_online);
6709 EXPORT_SYMBOL_GPL(ata_link_offline); 6718 EXPORT_SYMBOL_GPL(ata_link_offline);
6710 #ifdef CONFIG_PM 6719 #ifdef CONFIG_PM
6711 EXPORT_SYMBOL_GPL(ata_host_suspend); 6720 EXPORT_SYMBOL_GPL(ata_host_suspend);
6712 EXPORT_SYMBOL_GPL(ata_host_resume); 6721 EXPORT_SYMBOL_GPL(ata_host_resume);
6713 #endif /* CONFIG_PM */ 6722 #endif /* CONFIG_PM */
6714 EXPORT_SYMBOL_GPL(ata_id_string); 6723 EXPORT_SYMBOL_GPL(ata_id_string);
6715 EXPORT_SYMBOL_GPL(ata_id_c_string); 6724 EXPORT_SYMBOL_GPL(ata_id_c_string);
6716 EXPORT_SYMBOL_GPL(ata_do_dev_read_id); 6725 EXPORT_SYMBOL_GPL(ata_do_dev_read_id);
6717 EXPORT_SYMBOL_GPL(ata_scsi_simulate); 6726 EXPORT_SYMBOL_GPL(ata_scsi_simulate);
6718 6727
6719 EXPORT_SYMBOL_GPL(ata_pio_need_iordy); 6728 EXPORT_SYMBOL_GPL(ata_pio_need_iordy);
6720 EXPORT_SYMBOL_GPL(ata_timing_find_mode); 6729 EXPORT_SYMBOL_GPL(ata_timing_find_mode);
6721 EXPORT_SYMBOL_GPL(ata_timing_compute); 6730 EXPORT_SYMBOL_GPL(ata_timing_compute);
6722 EXPORT_SYMBOL_GPL(ata_timing_merge); 6731 EXPORT_SYMBOL_GPL(ata_timing_merge);
6723 EXPORT_SYMBOL_GPL(ata_timing_cycle2mode); 6732 EXPORT_SYMBOL_GPL(ata_timing_cycle2mode);
6724 6733
6725 #ifdef CONFIG_PCI 6734 #ifdef CONFIG_PCI
6726 EXPORT_SYMBOL_GPL(pci_test_config_bits); 6735 EXPORT_SYMBOL_GPL(pci_test_config_bits);
6727 EXPORT_SYMBOL_GPL(ata_pci_remove_one); 6736 EXPORT_SYMBOL_GPL(ata_pci_remove_one);
6728 #ifdef CONFIG_PM 6737 #ifdef CONFIG_PM
6729 EXPORT_SYMBOL_GPL(ata_pci_device_do_suspend); 6738 EXPORT_SYMBOL_GPL(ata_pci_device_do_suspend);
6730 EXPORT_SYMBOL_GPL(ata_pci_device_do_resume); 6739 EXPORT_SYMBOL_GPL(ata_pci_device_do_resume);
6731 EXPORT_SYMBOL_GPL(ata_pci_device_suspend); 6740 EXPORT_SYMBOL_GPL(ata_pci_device_suspend);
6732 EXPORT_SYMBOL_GPL(ata_pci_device_resume); 6741 EXPORT_SYMBOL_GPL(ata_pci_device_resume);
6733 #endif /* CONFIG_PM */ 6742 #endif /* CONFIG_PM */
6734 #endif /* CONFIG_PCI */ 6743 #endif /* CONFIG_PCI */
6735 6744
6736 EXPORT_SYMBOL_GPL(__ata_ehi_push_desc); 6745 EXPORT_SYMBOL_GPL(__ata_ehi_push_desc);
6737 EXPORT_SYMBOL_GPL(ata_ehi_push_desc); 6746 EXPORT_SYMBOL_GPL(ata_ehi_push_desc);
6738 EXPORT_SYMBOL_GPL(ata_ehi_clear_desc); 6747 EXPORT_SYMBOL_GPL(ata_ehi_clear_desc);
6739 EXPORT_SYMBOL_GPL(ata_port_desc); 6748 EXPORT_SYMBOL_GPL(ata_port_desc);
6740 #ifdef CONFIG_PCI 6749 #ifdef CONFIG_PCI
6741 EXPORT_SYMBOL_GPL(ata_port_pbar_desc); 6750 EXPORT_SYMBOL_GPL(ata_port_pbar_desc);
6742 #endif /* CONFIG_PCI */ 6751 #endif /* CONFIG_PCI */
6743 EXPORT_SYMBOL_GPL(ata_port_schedule_eh); 6752 EXPORT_SYMBOL_GPL(ata_port_schedule_eh);
6744 EXPORT_SYMBOL_GPL(ata_link_abort); 6753 EXPORT_SYMBOL_GPL(ata_link_abort);
6745 EXPORT_SYMBOL_GPL(ata_port_abort); 6754 EXPORT_SYMBOL_GPL(ata_port_abort);
6746 EXPORT_SYMBOL_GPL(ata_port_freeze); 6755 EXPORT_SYMBOL_GPL(ata_port_freeze);
6747 EXPORT_SYMBOL_GPL(sata_async_notification); 6756 EXPORT_SYMBOL_GPL(sata_async_notification);
6748 EXPORT_SYMBOL_GPL(ata_eh_freeze_port); 6757 EXPORT_SYMBOL_GPL(ata_eh_freeze_port);
6749 EXPORT_SYMBOL_GPL(ata_eh_thaw_port); 6758 EXPORT_SYMBOL_GPL(ata_eh_thaw_port);
6750 EXPORT_SYMBOL_GPL(ata_eh_qc_complete); 6759 EXPORT_SYMBOL_GPL(ata_eh_qc_complete);
6751 EXPORT_SYMBOL_GPL(ata_eh_qc_retry); 6760 EXPORT_SYMBOL_GPL(ata_eh_qc_retry);
6752 EXPORT_SYMBOL_GPL(ata_eh_analyze_ncq_error); 6761 EXPORT_SYMBOL_GPL(ata_eh_analyze_ncq_error);
6753 EXPORT_SYMBOL_GPL(ata_do_eh); 6762 EXPORT_SYMBOL_GPL(ata_do_eh);
6754 EXPORT_SYMBOL_GPL(ata_std_error_handler); 6763 EXPORT_SYMBOL_GPL(ata_std_error_handler);
6755 6764
6756 EXPORT_SYMBOL_GPL(ata_cable_40wire); 6765 EXPORT_SYMBOL_GPL(ata_cable_40wire);
6757 EXPORT_SYMBOL_GPL(ata_cable_80wire); 6766 EXPORT_SYMBOL_GPL(ata_cable_80wire);
6758 EXPORT_SYMBOL_GPL(ata_cable_unknown); 6767 EXPORT_SYMBOL_GPL(ata_cable_unknown);
6759 EXPORT_SYMBOL_GPL(ata_cable_ignore); 6768 EXPORT_SYMBOL_GPL(ata_cable_ignore);
6760 EXPORT_SYMBOL_GPL(ata_cable_sata); 6769 EXPORT_SYMBOL_GPL(ata_cable_sata);
6761 6770
include/linux/libata.h
1 /* 1 /*
2 * Copyright 2003-2005 Red Hat, Inc. All rights reserved. 2 * Copyright 2003-2005 Red Hat, Inc. All rights reserved.
3 * Copyright 2003-2005 Jeff Garzik 3 * Copyright 2003-2005 Jeff Garzik
4 * 4 *
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option) 8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version. 9 * any later version.
10 * 10 *
11 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING. If not, write to 17 * along with this program; see the file COPYING. If not, write to
18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19 * 19 *
20 * 20 *
21 * libata documentation is available via 'make {ps|pdf}docs', 21 * libata documentation is available via 'make {ps|pdf}docs',
22 * as Documentation/DocBook/libata.* 22 * as Documentation/DocBook/libata.*
23 * 23 *
24 */ 24 */
25 25
26 #ifndef __LINUX_LIBATA_H__ 26 #ifndef __LINUX_LIBATA_H__
27 #define __LINUX_LIBATA_H__ 27 #define __LINUX_LIBATA_H__
28 28
29 #include <linux/delay.h> 29 #include <linux/delay.h>
30 #include <linux/jiffies.h> 30 #include <linux/jiffies.h>
31 #include <linux/interrupt.h> 31 #include <linux/interrupt.h>
32 #include <linux/dma-mapping.h> 32 #include <linux/dma-mapping.h>
33 #include <linux/scatterlist.h> 33 #include <linux/scatterlist.h>
34 #include <linux/io.h> 34 #include <linux/io.h>
35 #include <linux/ata.h> 35 #include <linux/ata.h>
36 #include <linux/workqueue.h> 36 #include <linux/workqueue.h>
37 #include <scsi/scsi_host.h> 37 #include <scsi/scsi_host.h>
38 #include <linux/acpi.h> 38 #include <linux/acpi.h>
39 #include <linux/cdrom.h> 39 #include <linux/cdrom.h>
40 40
41 /* 41 /*
42 * Define if arch has non-standard setup. This is a _PCI_ standard 42 * Define if arch has non-standard setup. This is a _PCI_ standard
43 * not a legacy or ISA standard. 43 * not a legacy or ISA standard.
44 */ 44 */
45 #ifdef CONFIG_ATA_NONSTANDARD 45 #ifdef CONFIG_ATA_NONSTANDARD
46 #include <asm/libata-portmap.h> 46 #include <asm/libata-portmap.h>
47 #else 47 #else
48 #include <asm-generic/libata-portmap.h> 48 #include <asm-generic/libata-portmap.h>
49 #endif 49 #endif
50 50
51 /* 51 /*
52 * compile-time options: to be removed as soon as all the drivers are 52 * compile-time options: to be removed as soon as all the drivers are
53 * converted to the new debugging mechanism 53 * converted to the new debugging mechanism
54 */ 54 */
55 #undef ATA_DEBUG /* debugging output */ 55 #undef ATA_DEBUG /* debugging output */
56 #undef ATA_VERBOSE_DEBUG /* yet more debugging output */ 56 #undef ATA_VERBOSE_DEBUG /* yet more debugging output */
57 #undef ATA_IRQ_TRAP /* define to ack screaming irqs */ 57 #undef ATA_IRQ_TRAP /* define to ack screaming irqs */
58 #undef ATA_NDEBUG /* define to disable quick runtime checks */ 58 #undef ATA_NDEBUG /* define to disable quick runtime checks */
59 59
60 60
61 /* note: prints function name for you */ 61 /* note: prints function name for you */
62 #ifdef ATA_DEBUG 62 #ifdef ATA_DEBUG
63 #define DPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args) 63 #define DPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
64 #ifdef ATA_VERBOSE_DEBUG 64 #ifdef ATA_VERBOSE_DEBUG
65 #define VPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args) 65 #define VPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
66 #else 66 #else
67 #define VPRINTK(fmt, args...) 67 #define VPRINTK(fmt, args...)
68 #endif /* ATA_VERBOSE_DEBUG */ 68 #endif /* ATA_VERBOSE_DEBUG */
69 #else 69 #else
70 #define DPRINTK(fmt, args...) 70 #define DPRINTK(fmt, args...)
71 #define VPRINTK(fmt, args...) 71 #define VPRINTK(fmt, args...)
72 #endif /* ATA_DEBUG */ 72 #endif /* ATA_DEBUG */
73 73
74 #define BPRINTK(fmt, args...) if (ap->flags & ATA_FLAG_DEBUGMSG) printk(KERN_ERR "%s: " fmt, __func__, ## args) 74 #define BPRINTK(fmt, args...) if (ap->flags & ATA_FLAG_DEBUGMSG) printk(KERN_ERR "%s: " fmt, __func__, ## args)
75 75
76 /* NEW: debug levels */ 76 /* NEW: debug levels */
77 #define HAVE_LIBATA_MSG 1 77 #define HAVE_LIBATA_MSG 1
78 78
79 enum { 79 enum {
80 ATA_MSG_DRV = 0x0001, 80 ATA_MSG_DRV = 0x0001,
81 ATA_MSG_INFO = 0x0002, 81 ATA_MSG_INFO = 0x0002,
82 ATA_MSG_PROBE = 0x0004, 82 ATA_MSG_PROBE = 0x0004,
83 ATA_MSG_WARN = 0x0008, 83 ATA_MSG_WARN = 0x0008,
84 ATA_MSG_MALLOC = 0x0010, 84 ATA_MSG_MALLOC = 0x0010,
85 ATA_MSG_CTL = 0x0020, 85 ATA_MSG_CTL = 0x0020,
86 ATA_MSG_INTR = 0x0040, 86 ATA_MSG_INTR = 0x0040,
87 ATA_MSG_ERR = 0x0080, 87 ATA_MSG_ERR = 0x0080,
88 }; 88 };
89 89
90 #define ata_msg_drv(p) ((p)->msg_enable & ATA_MSG_DRV) 90 #define ata_msg_drv(p) ((p)->msg_enable & ATA_MSG_DRV)
91 #define ata_msg_info(p) ((p)->msg_enable & ATA_MSG_INFO) 91 #define ata_msg_info(p) ((p)->msg_enable & ATA_MSG_INFO)
92 #define ata_msg_probe(p) ((p)->msg_enable & ATA_MSG_PROBE) 92 #define ata_msg_probe(p) ((p)->msg_enable & ATA_MSG_PROBE)
93 #define ata_msg_warn(p) ((p)->msg_enable & ATA_MSG_WARN) 93 #define ata_msg_warn(p) ((p)->msg_enable & ATA_MSG_WARN)
94 #define ata_msg_malloc(p) ((p)->msg_enable & ATA_MSG_MALLOC) 94 #define ata_msg_malloc(p) ((p)->msg_enable & ATA_MSG_MALLOC)
95 #define ata_msg_ctl(p) ((p)->msg_enable & ATA_MSG_CTL) 95 #define ata_msg_ctl(p) ((p)->msg_enable & ATA_MSG_CTL)
96 #define ata_msg_intr(p) ((p)->msg_enable & ATA_MSG_INTR) 96 #define ata_msg_intr(p) ((p)->msg_enable & ATA_MSG_INTR)
97 #define ata_msg_err(p) ((p)->msg_enable & ATA_MSG_ERR) 97 #define ata_msg_err(p) ((p)->msg_enable & ATA_MSG_ERR)
98 98
99 static inline u32 ata_msg_init(int dval, int default_msg_enable_bits) 99 static inline u32 ata_msg_init(int dval, int default_msg_enable_bits)
100 { 100 {
101 if (dval < 0 || dval >= (sizeof(u32) * 8)) 101 if (dval < 0 || dval >= (sizeof(u32) * 8))
102 return default_msg_enable_bits; /* should be 0x1 - only driver info msgs */ 102 return default_msg_enable_bits; /* should be 0x1 - only driver info msgs */
103 if (!dval) 103 if (!dval)
104 return 0; 104 return 0;
105 return (1 << dval) - 1; 105 return (1 << dval) - 1;
106 } 106 }
107 107
108 /* defines only for the constants which don't work well as enums */ 108 /* defines only for the constants which don't work well as enums */
109 #define ATA_TAG_POISON 0xfafbfcfdU 109 #define ATA_TAG_POISON 0xfafbfcfdU
110 110
111 enum { 111 enum {
112 /* various global constants */ 112 /* various global constants */
113 LIBATA_MAX_PRD = ATA_MAX_PRD / 2, 113 LIBATA_MAX_PRD = ATA_MAX_PRD / 2,
114 LIBATA_DUMB_MAX_PRD = ATA_MAX_PRD / 4, /* Worst case */ 114 LIBATA_DUMB_MAX_PRD = ATA_MAX_PRD / 4, /* Worst case */
115 ATA_DEF_QUEUE = 1, 115 ATA_DEF_QUEUE = 1,
116 /* tag ATA_MAX_QUEUE - 1 is reserved for internal commands */ 116 /* tag ATA_MAX_QUEUE - 1 is reserved for internal commands */
117 ATA_MAX_QUEUE = 32, 117 ATA_MAX_QUEUE = 32,
118 ATA_TAG_INTERNAL = ATA_MAX_QUEUE - 1, 118 ATA_TAG_INTERNAL = ATA_MAX_QUEUE - 1,
119 ATA_SHORT_PAUSE = 16, 119 ATA_SHORT_PAUSE = 16,
120 120
121 ATAPI_MAX_DRAIN = 16 << 10, 121 ATAPI_MAX_DRAIN = 16 << 10,
122 122
123 ATA_ALL_DEVICES = (1 << ATA_MAX_DEVICES) - 1, 123 ATA_ALL_DEVICES = (1 << ATA_MAX_DEVICES) - 1,
124 124
125 ATA_SHT_EMULATED = 1, 125 ATA_SHT_EMULATED = 1,
126 ATA_SHT_CMD_PER_LUN = 1, 126 ATA_SHT_CMD_PER_LUN = 1,
127 ATA_SHT_THIS_ID = -1, 127 ATA_SHT_THIS_ID = -1,
128 ATA_SHT_USE_CLUSTERING = 1, 128 ATA_SHT_USE_CLUSTERING = 1,
129 129
130 /* struct ata_device stuff */ 130 /* struct ata_device stuff */
131 ATA_DFLAG_LBA = (1 << 0), /* device supports LBA */ 131 ATA_DFLAG_LBA = (1 << 0), /* device supports LBA */
132 ATA_DFLAG_LBA48 = (1 << 1), /* device supports LBA48 */ 132 ATA_DFLAG_LBA48 = (1 << 1), /* device supports LBA48 */
133 ATA_DFLAG_CDB_INTR = (1 << 2), /* device asserts INTRQ when ready for CDB */ 133 ATA_DFLAG_CDB_INTR = (1 << 2), /* device asserts INTRQ when ready for CDB */
134 ATA_DFLAG_NCQ = (1 << 3), /* device supports NCQ */ 134 ATA_DFLAG_NCQ = (1 << 3), /* device supports NCQ */
135 ATA_DFLAG_FLUSH_EXT = (1 << 4), /* do FLUSH_EXT instead of FLUSH */ 135 ATA_DFLAG_FLUSH_EXT = (1 << 4), /* do FLUSH_EXT instead of FLUSH */
136 ATA_DFLAG_ACPI_PENDING = (1 << 5), /* ACPI resume action pending */ 136 ATA_DFLAG_ACPI_PENDING = (1 << 5), /* ACPI resume action pending */
137 ATA_DFLAG_ACPI_FAILED = (1 << 6), /* ACPI on devcfg has failed */ 137 ATA_DFLAG_ACPI_FAILED = (1 << 6), /* ACPI on devcfg has failed */
138 ATA_DFLAG_AN = (1 << 7), /* AN configured */ 138 ATA_DFLAG_AN = (1 << 7), /* AN configured */
139 ATA_DFLAG_HIPM = (1 << 8), /* device supports HIPM */ 139 ATA_DFLAG_HIPM = (1 << 8), /* device supports HIPM */
140 ATA_DFLAG_DIPM = (1 << 9), /* device supports DIPM */ 140 ATA_DFLAG_DIPM = (1 << 9), /* device supports DIPM */
141 ATA_DFLAG_DMADIR = (1 << 10), /* device requires DMADIR */ 141 ATA_DFLAG_DMADIR = (1 << 10), /* device requires DMADIR */
142 ATA_DFLAG_CFG_MASK = (1 << 12) - 1, 142 ATA_DFLAG_CFG_MASK = (1 << 12) - 1,
143 143
144 ATA_DFLAG_PIO = (1 << 12), /* device limited to PIO mode */ 144 ATA_DFLAG_PIO = (1 << 12), /* device limited to PIO mode */
145 ATA_DFLAG_NCQ_OFF = (1 << 13), /* device limited to non-NCQ mode */ 145 ATA_DFLAG_NCQ_OFF = (1 << 13), /* device limited to non-NCQ mode */
146 ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */ 146 ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */
147 ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */ 147 ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */
148 ATA_DFLAG_NO_UNLOAD = (1 << 17), /* device doesn't support unload */ 148 ATA_DFLAG_NO_UNLOAD = (1 << 17), /* device doesn't support unload */
149 ATA_DFLAG_UNLOCK_HPA = (1 << 18), /* unlock HPA */ 149 ATA_DFLAG_UNLOCK_HPA = (1 << 18), /* unlock HPA */
150 ATA_DFLAG_INIT_MASK = (1 << 24) - 1, 150 ATA_DFLAG_INIT_MASK = (1 << 24) - 1,
151 151
152 ATA_DFLAG_DETACH = (1 << 24), 152 ATA_DFLAG_DETACH = (1 << 24),
153 ATA_DFLAG_DETACHED = (1 << 25), 153 ATA_DFLAG_DETACHED = (1 << 25),
154 154
155 ATA_DEV_UNKNOWN = 0, /* unknown device */ 155 ATA_DEV_UNKNOWN = 0, /* unknown device */
156 ATA_DEV_ATA = 1, /* ATA device */ 156 ATA_DEV_ATA = 1, /* ATA device */
157 ATA_DEV_ATA_UNSUP = 2, /* ATA device (unsupported) */ 157 ATA_DEV_ATA_UNSUP = 2, /* ATA device (unsupported) */
158 ATA_DEV_ATAPI = 3, /* ATAPI device */ 158 ATA_DEV_ATAPI = 3, /* ATAPI device */
159 ATA_DEV_ATAPI_UNSUP = 4, /* ATAPI device (unsupported) */ 159 ATA_DEV_ATAPI_UNSUP = 4, /* ATAPI device (unsupported) */
160 ATA_DEV_PMP = 5, /* SATA port multiplier */ 160 ATA_DEV_PMP = 5, /* SATA port multiplier */
161 ATA_DEV_PMP_UNSUP = 6, /* SATA port multiplier (unsupported) */ 161 ATA_DEV_PMP_UNSUP = 6, /* SATA port multiplier (unsupported) */
162 ATA_DEV_SEMB = 7, /* SEMB */ 162 ATA_DEV_SEMB = 7, /* SEMB */
163 ATA_DEV_SEMB_UNSUP = 8, /* SEMB (unsupported) */ 163 ATA_DEV_SEMB_UNSUP = 8, /* SEMB (unsupported) */
164 ATA_DEV_NONE = 9, /* no device */ 164 ATA_DEV_NONE = 9, /* no device */
165 165
166 /* struct ata_link flags */ 166 /* struct ata_link flags */
167 ATA_LFLAG_NO_HRST = (1 << 1), /* avoid hardreset */ 167 ATA_LFLAG_NO_HRST = (1 << 1), /* avoid hardreset */
168 ATA_LFLAG_NO_SRST = (1 << 2), /* avoid softreset */ 168 ATA_LFLAG_NO_SRST = (1 << 2), /* avoid softreset */
169 ATA_LFLAG_ASSUME_ATA = (1 << 3), /* assume ATA class */ 169 ATA_LFLAG_ASSUME_ATA = (1 << 3), /* assume ATA class */
170 ATA_LFLAG_ASSUME_SEMB = (1 << 4), /* assume SEMB class */ 170 ATA_LFLAG_ASSUME_SEMB = (1 << 4), /* assume SEMB class */
171 ATA_LFLAG_ASSUME_CLASS = ATA_LFLAG_ASSUME_ATA | ATA_LFLAG_ASSUME_SEMB, 171 ATA_LFLAG_ASSUME_CLASS = ATA_LFLAG_ASSUME_ATA | ATA_LFLAG_ASSUME_SEMB,
172 ATA_LFLAG_NO_RETRY = (1 << 5), /* don't retry this link */ 172 ATA_LFLAG_NO_RETRY = (1 << 5), /* don't retry this link */
173 ATA_LFLAG_DISABLED = (1 << 6), /* link is disabled */ 173 ATA_LFLAG_DISABLED = (1 << 6), /* link is disabled */
174 ATA_LFLAG_SW_ACTIVITY = (1 << 7), /* keep activity stats */ 174 ATA_LFLAG_SW_ACTIVITY = (1 << 7), /* keep activity stats */
175 175
176 /* struct ata_port flags */ 176 /* struct ata_port flags */
177 ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */ 177 ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */
178 /* (doesn't imply presence) */ 178 /* (doesn't imply presence) */
179 ATA_FLAG_SATA = (1 << 1), 179 ATA_FLAG_SATA = (1 << 1),
180 ATA_FLAG_NO_LEGACY = (1 << 2), /* no legacy mode check */ 180 ATA_FLAG_NO_LEGACY = (1 << 2), /* no legacy mode check */
181 ATA_FLAG_MMIO = (1 << 3), /* use MMIO, not PIO */ 181 ATA_FLAG_MMIO = (1 << 3), /* use MMIO, not PIO */
182 ATA_FLAG_SRST = (1 << 4), /* (obsolete) use ATA SRST, not E.D.D. */ 182 ATA_FLAG_SRST = (1 << 4), /* (obsolete) use ATA SRST, not E.D.D. */
183 ATA_FLAG_SATA_RESET = (1 << 5), /* (obsolete) use COMRESET */ 183 ATA_FLAG_SATA_RESET = (1 << 5), /* (obsolete) use COMRESET */
184 ATA_FLAG_NO_ATAPI = (1 << 6), /* No ATAPI support */ 184 ATA_FLAG_NO_ATAPI = (1 << 6), /* No ATAPI support */
185 ATA_FLAG_PIO_DMA = (1 << 7), /* PIO cmds via DMA */ 185 ATA_FLAG_PIO_DMA = (1 << 7), /* PIO cmds via DMA */
186 ATA_FLAG_PIO_LBA48 = (1 << 8), /* Host DMA engine is LBA28 only */ 186 ATA_FLAG_PIO_LBA48 = (1 << 8), /* Host DMA engine is LBA28 only */
187 ATA_FLAG_PIO_POLLING = (1 << 9), /* use polling PIO if LLD 187 ATA_FLAG_PIO_POLLING = (1 << 9), /* use polling PIO if LLD
188 * doesn't handle PIO interrupts */ 188 * doesn't handle PIO interrupts */
189 ATA_FLAG_NCQ = (1 << 10), /* host supports NCQ */ 189 ATA_FLAG_NCQ = (1 << 10), /* host supports NCQ */
190 ATA_FLAG_NO_POWEROFF_SPINDOWN = (1 << 11), /* don't spindown before poweroff */ 190 ATA_FLAG_NO_POWEROFF_SPINDOWN = (1 << 11), /* don't spindown before poweroff */
191 ATA_FLAG_NO_HIBERNATE_SPINDOWN = (1 << 12), /* don't spindown before hibernation */ 191 ATA_FLAG_NO_HIBERNATE_SPINDOWN = (1 << 12), /* don't spindown before hibernation */
192 ATA_FLAG_DEBUGMSG = (1 << 13), 192 ATA_FLAG_DEBUGMSG = (1 << 13),
193 ATA_FLAG_FPDMA_AA = (1 << 14), /* driver supports Auto-Activate */ 193 ATA_FLAG_FPDMA_AA = (1 << 14), /* driver supports Auto-Activate */
194 ATA_FLAG_IGN_SIMPLEX = (1 << 15), /* ignore SIMPLEX */ 194 ATA_FLAG_IGN_SIMPLEX = (1 << 15), /* ignore SIMPLEX */
195 ATA_FLAG_NO_IORDY = (1 << 16), /* controller lacks iordy */ 195 ATA_FLAG_NO_IORDY = (1 << 16), /* controller lacks iordy */
196 ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */ 196 ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */
197 ATA_FLAG_AN = (1 << 18), /* controller supports AN */ 197 ATA_FLAG_AN = (1 << 18), /* controller supports AN */
198 ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */ 198 ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */
199 ATA_FLAG_IPM = (1 << 20), /* driver can handle IPM */ 199 ATA_FLAG_IPM = (1 << 20), /* driver can handle IPM */
200 ATA_FLAG_EM = (1 << 21), /* driver supports enclosure 200 ATA_FLAG_EM = (1 << 21), /* driver supports enclosure
201 * management */ 201 * management */
202 ATA_FLAG_SW_ACTIVITY = (1 << 22), /* driver supports sw activity 202 ATA_FLAG_SW_ACTIVITY = (1 << 22), /* driver supports sw activity
203 * led */ 203 * led */
204 204
205 /* bits 24:31 of ap->flags are reserved for LLD specific flags */ 205 /* bits 24:31 of ap->flags are reserved for LLD specific flags */
206 206
207 207
208 /* struct ata_port pflags */ 208 /* struct ata_port pflags */
209 ATA_PFLAG_EH_PENDING = (1 << 0), /* EH pending */ 209 ATA_PFLAG_EH_PENDING = (1 << 0), /* EH pending */
210 ATA_PFLAG_EH_IN_PROGRESS = (1 << 1), /* EH in progress */ 210 ATA_PFLAG_EH_IN_PROGRESS = (1 << 1), /* EH in progress */
211 ATA_PFLAG_FROZEN = (1 << 2), /* port is frozen */ 211 ATA_PFLAG_FROZEN = (1 << 2), /* port is frozen */
212 ATA_PFLAG_RECOVERED = (1 << 3), /* recovery action performed */ 212 ATA_PFLAG_RECOVERED = (1 << 3), /* recovery action performed */
213 ATA_PFLAG_LOADING = (1 << 4), /* boot/loading probe */ 213 ATA_PFLAG_LOADING = (1 << 4), /* boot/loading probe */
214 ATA_PFLAG_SCSI_HOTPLUG = (1 << 6), /* SCSI hotplug scheduled */ 214 ATA_PFLAG_SCSI_HOTPLUG = (1 << 6), /* SCSI hotplug scheduled */
215 ATA_PFLAG_INITIALIZING = (1 << 7), /* being initialized, don't touch */ 215 ATA_PFLAG_INITIALIZING = (1 << 7), /* being initialized, don't touch */
216 ATA_PFLAG_RESETTING = (1 << 8), /* reset in progress */ 216 ATA_PFLAG_RESETTING = (1 << 8), /* reset in progress */
217 ATA_PFLAG_UNLOADING = (1 << 9), /* driver is being unloaded */ 217 ATA_PFLAG_UNLOADING = (1 << 9), /* driver is being unloaded */
218 ATA_PFLAG_UNLOADED = (1 << 10), /* driver is unloaded */ 218 ATA_PFLAG_UNLOADED = (1 << 10), /* driver is unloaded */
219 219
220 ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */ 220 ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */
221 ATA_PFLAG_PM_PENDING = (1 << 18), /* PM operation pending */ 221 ATA_PFLAG_PM_PENDING = (1 << 18), /* PM operation pending */
222 ATA_PFLAG_INIT_GTM_VALID = (1 << 19), /* initial gtm data valid */ 222 ATA_PFLAG_INIT_GTM_VALID = (1 << 19), /* initial gtm data valid */
223 223
224 ATA_PFLAG_PIO32 = (1 << 20), /* 32bit PIO */ 224 ATA_PFLAG_PIO32 = (1 << 20), /* 32bit PIO */
225 ATA_PFLAG_PIO32CHANGE = (1 << 21), /* 32bit PIO can be turned on/off */ 225 ATA_PFLAG_PIO32CHANGE = (1 << 21), /* 32bit PIO can be turned on/off */
226 226
227 /* struct ata_queued_cmd flags */ 227 /* struct ata_queued_cmd flags */
228 ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */ 228 ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */
229 ATA_QCFLAG_DMAMAP = (1 << 1), /* SG table is DMA mapped */ 229 ATA_QCFLAG_DMAMAP = (1 << 1), /* SG table is DMA mapped */
230 ATA_QCFLAG_IO = (1 << 3), /* standard IO command */ 230 ATA_QCFLAG_IO = (1 << 3), /* standard IO command */
231 ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */ 231 ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */
232 ATA_QCFLAG_CLEAR_EXCL = (1 << 5), /* clear excl_link on completion */ 232 ATA_QCFLAG_CLEAR_EXCL = (1 << 5), /* clear excl_link on completion */
233 ATA_QCFLAG_QUIET = (1 << 6), /* don't report device error */ 233 ATA_QCFLAG_QUIET = (1 << 6), /* don't report device error */
234 ATA_QCFLAG_RETRY = (1 << 7), /* retry after failure */ 234 ATA_QCFLAG_RETRY = (1 << 7), /* retry after failure */
235 235
236 ATA_QCFLAG_FAILED = (1 << 16), /* cmd failed and is owned by EH */ 236 ATA_QCFLAG_FAILED = (1 << 16), /* cmd failed and is owned by EH */
237 ATA_QCFLAG_SENSE_VALID = (1 << 17), /* sense data valid */ 237 ATA_QCFLAG_SENSE_VALID = (1 << 17), /* sense data valid */
238 ATA_QCFLAG_EH_SCHEDULED = (1 << 18), /* EH scheduled (obsolete) */ 238 ATA_QCFLAG_EH_SCHEDULED = (1 << 18), /* EH scheduled (obsolete) */
239 239
240 /* host set flags */ 240 /* host set flags */
241 ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host only */ 241 ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host only */
242 ATA_HOST_STARTED = (1 << 1), /* Host started */ 242 ATA_HOST_STARTED = (1 << 1), /* Host started */
243 ATA_HOST_PARALLEL_SCAN = (1 << 2), /* Ports on this host can be scanned in parallel */ 243 ATA_HOST_PARALLEL_SCAN = (1 << 2), /* Ports on this host can be scanned in parallel */
244 244
245 /* bits 24:31 of host->flags are reserved for LLD specific flags */ 245 /* bits 24:31 of host->flags are reserved for LLD specific flags */
246 246
247 /* various lengths of time */ 247 /* various lengths of time */
248 ATA_TMOUT_BOOT = 30000, /* heuristic */ 248 ATA_TMOUT_BOOT = 30000, /* heuristic */
249 ATA_TMOUT_BOOT_QUICK = 7000, /* heuristic */ 249 ATA_TMOUT_BOOT_QUICK = 7000, /* heuristic */
250 ATA_TMOUT_INTERNAL_QUICK = 5000, 250 ATA_TMOUT_INTERNAL_QUICK = 5000,
251 ATA_TMOUT_MAX_PARK = 30000, 251 ATA_TMOUT_MAX_PARK = 30000,
252 252
253 /* 253 /*
254 * GoVault needs 2s and iVDR disk HHD424020F7SV00 800ms. 2s 254 * GoVault needs 2s and iVDR disk HHD424020F7SV00 800ms. 2s
255 * is too much without parallel probing. Use 2s if parallel 255 * is too much without parallel probing. Use 2s if parallel
256 * probing is available, 800ms otherwise. 256 * probing is available, 800ms otherwise.
257 */ 257 */
258 ATA_TMOUT_FF_WAIT_LONG = 2000, 258 ATA_TMOUT_FF_WAIT_LONG = 2000,
259 ATA_TMOUT_FF_WAIT = 800, 259 ATA_TMOUT_FF_WAIT = 800,
260 260
261 /* Spec mandates to wait for ">= 2ms" before checking status 261 /* Spec mandates to wait for ">= 2ms" before checking status
262 * after reset. We wait 150ms, because that was the magic 262 * after reset. We wait 150ms, because that was the magic
263 * delay used for ATAPI devices in Hale Landis's ATADRVR, for 263 * delay used for ATAPI devices in Hale Landis's ATADRVR, for
264 * the period of time between when the ATA command register is 264 * the period of time between when the ATA command register is
265 * written, and then status is checked. Because waiting for 265 * written, and then status is checked. Because waiting for
266 * "a while" before checking status is fine, post SRST, we 266 * "a while" before checking status is fine, post SRST, we
267 * perform this magic delay here as well. 267 * perform this magic delay here as well.
268 * 268 *
269 * Old drivers/ide uses the 2mS rule and then waits for ready. 269 * Old drivers/ide uses the 2mS rule and then waits for ready.
270 */ 270 */
271 ATA_WAIT_AFTER_RESET = 150, 271 ATA_WAIT_AFTER_RESET = 150,
272 272
273 /* If PMP is supported, we have to do follow-up SRST. As some 273 /* If PMP is supported, we have to do follow-up SRST. As some
274 * PMPs don't send D2H Reg FIS after hardreset, LLDs are 274 * PMPs don't send D2H Reg FIS after hardreset, LLDs are
275 * advised to wait only for the following duration before 275 * advised to wait only for the following duration before
276 * doing SRST. 276 * doing SRST.
277 */ 277 */
278 ATA_TMOUT_PMP_SRST_WAIT = 5000, 278 ATA_TMOUT_PMP_SRST_WAIT = 5000,
279 279
280 /* ATA bus states */ 280 /* ATA bus states */
281 BUS_UNKNOWN = 0, 281 BUS_UNKNOWN = 0,
282 BUS_DMA = 1, 282 BUS_DMA = 1,
283 BUS_IDLE = 2, 283 BUS_IDLE = 2,
284 BUS_NOINTR = 3, 284 BUS_NOINTR = 3,
285 BUS_NODATA = 4, 285 BUS_NODATA = 4,
286 BUS_TIMER = 5, 286 BUS_TIMER = 5,
287 BUS_PIO = 6, 287 BUS_PIO = 6,
288 BUS_EDD = 7, 288 BUS_EDD = 7,
289 BUS_IDENTIFY = 8, 289 BUS_IDENTIFY = 8,
290 BUS_PACKET = 9, 290 BUS_PACKET = 9,
291 291
292 /* SATA port states */ 292 /* SATA port states */
293 PORT_UNKNOWN = 0, 293 PORT_UNKNOWN = 0,
294 PORT_ENABLED = 1, 294 PORT_ENABLED = 1,
295 PORT_DISABLED = 2, 295 PORT_DISABLED = 2,
296 296
297 /* encoding various smaller bitmaps into a single 297 /* encoding various smaller bitmaps into a single
298 * unsigned long bitmap 298 * unsigned long bitmap
299 */ 299 */
300 ATA_NR_PIO_MODES = 7, 300 ATA_NR_PIO_MODES = 7,
301 ATA_NR_MWDMA_MODES = 5, 301 ATA_NR_MWDMA_MODES = 5,
302 ATA_NR_UDMA_MODES = 8, 302 ATA_NR_UDMA_MODES = 8,
303 303
304 ATA_SHIFT_PIO = 0, 304 ATA_SHIFT_PIO = 0,
305 ATA_SHIFT_MWDMA = ATA_SHIFT_PIO + ATA_NR_PIO_MODES, 305 ATA_SHIFT_MWDMA = ATA_SHIFT_PIO + ATA_NR_PIO_MODES,
306 ATA_SHIFT_UDMA = ATA_SHIFT_MWDMA + ATA_NR_MWDMA_MODES, 306 ATA_SHIFT_UDMA = ATA_SHIFT_MWDMA + ATA_NR_MWDMA_MODES,
307 307
308 /* size of buffer to pad xfers ending on unaligned boundaries */ 308 /* size of buffer to pad xfers ending on unaligned boundaries */
309 ATA_DMA_PAD_SZ = 4, 309 ATA_DMA_PAD_SZ = 4,
310 310
311 /* ering size */ 311 /* ering size */
312 ATA_ERING_SIZE = 32, 312 ATA_ERING_SIZE = 32,
313 313
314 /* return values for ->qc_defer */ 314 /* return values for ->qc_defer */
315 ATA_DEFER_LINK = 1, 315 ATA_DEFER_LINK = 1,
316 ATA_DEFER_PORT = 2, 316 ATA_DEFER_PORT = 2,
317 317
318 /* desc_len for ata_eh_info and context */ 318 /* desc_len for ata_eh_info and context */
319 ATA_EH_DESC_LEN = 80, 319 ATA_EH_DESC_LEN = 80,
320 320
321 /* reset / recovery action types */ 321 /* reset / recovery action types */
322 ATA_EH_REVALIDATE = (1 << 0), 322 ATA_EH_REVALIDATE = (1 << 0),
323 ATA_EH_SOFTRESET = (1 << 1), /* meaningful only in ->prereset */ 323 ATA_EH_SOFTRESET = (1 << 1), /* meaningful only in ->prereset */
324 ATA_EH_HARDRESET = (1 << 2), /* meaningful only in ->prereset */ 324 ATA_EH_HARDRESET = (1 << 2), /* meaningful only in ->prereset */
325 ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, 325 ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
326 ATA_EH_ENABLE_LINK = (1 << 3), 326 ATA_EH_ENABLE_LINK = (1 << 3),
327 ATA_EH_LPM = (1 << 4), /* link power management action */ 327 ATA_EH_LPM = (1 << 4), /* link power management action */
328 ATA_EH_PARK = (1 << 5), /* unload heads and stop I/O */ 328 ATA_EH_PARK = (1 << 5), /* unload heads and stop I/O */
329 329
330 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE | ATA_EH_PARK, 330 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE | ATA_EH_PARK,
331 ATA_EH_ALL_ACTIONS = ATA_EH_REVALIDATE | ATA_EH_RESET | 331 ATA_EH_ALL_ACTIONS = ATA_EH_REVALIDATE | ATA_EH_RESET |
332 ATA_EH_ENABLE_LINK | ATA_EH_LPM, 332 ATA_EH_ENABLE_LINK | ATA_EH_LPM,
333 333
334 /* ata_eh_info->flags */ 334 /* ata_eh_info->flags */
335 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ 335 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */
336 ATA_EHI_NO_AUTOPSY = (1 << 2), /* no autopsy */ 336 ATA_EHI_NO_AUTOPSY = (1 << 2), /* no autopsy */
337 ATA_EHI_QUIET = (1 << 3), /* be quiet */ 337 ATA_EHI_QUIET = (1 << 3), /* be quiet */
338 338
339 ATA_EHI_DID_SOFTRESET = (1 << 16), /* already soft-reset this port */ 339 ATA_EHI_DID_SOFTRESET = (1 << 16), /* already soft-reset this port */
340 ATA_EHI_DID_HARDRESET = (1 << 17), /* already soft-reset this port */ 340 ATA_EHI_DID_HARDRESET = (1 << 17), /* already soft-reset this port */
341 ATA_EHI_PRINTINFO = (1 << 18), /* print configuration info */ 341 ATA_EHI_PRINTINFO = (1 << 18), /* print configuration info */
342 ATA_EHI_SETMODE = (1 << 19), /* configure transfer mode */ 342 ATA_EHI_SETMODE = (1 << 19), /* configure transfer mode */
343 ATA_EHI_POST_SETMODE = (1 << 20), /* revaildating after setmode */ 343 ATA_EHI_POST_SETMODE = (1 << 20), /* revaildating after setmode */
344 344
345 ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET, 345 ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET,
346 346
347 /* mask of flags to transfer *to* the slave link */ 347 /* mask of flags to transfer *to* the slave link */
348 ATA_EHI_TO_SLAVE_MASK = ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET, 348 ATA_EHI_TO_SLAVE_MASK = ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET,
349 349
350 /* max tries if error condition is still set after ->error_handler */ 350 /* max tries if error condition is still set after ->error_handler */
351 ATA_EH_MAX_TRIES = 5, 351 ATA_EH_MAX_TRIES = 5,
352 352
353 /* sometimes resuming a link requires several retries */ 353 /* sometimes resuming a link requires several retries */
354 ATA_LINK_RESUME_TRIES = 5, 354 ATA_LINK_RESUME_TRIES = 5,
355 355
356 /* how hard are we gonna try to probe/recover devices */ 356 /* how hard are we gonna try to probe/recover devices */
357 ATA_PROBE_MAX_TRIES = 3, 357 ATA_PROBE_MAX_TRIES = 3,
358 ATA_EH_DEV_TRIES = 3, 358 ATA_EH_DEV_TRIES = 3,
359 ATA_EH_PMP_TRIES = 5, 359 ATA_EH_PMP_TRIES = 5,
360 ATA_EH_PMP_LINK_TRIES = 3, 360 ATA_EH_PMP_LINK_TRIES = 3,
361 361
362 SATA_PMP_RW_TIMEOUT = 3000, /* PMP read/write timeout */ 362 SATA_PMP_RW_TIMEOUT = 3000, /* PMP read/write timeout */
363 363
364 /* This should match the actual table size of 364 /* This should match the actual table size of
365 * ata_eh_cmd_timeout_table in libata-eh.c. 365 * ata_eh_cmd_timeout_table in libata-eh.c.
366 */ 366 */
367 ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 6, 367 ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 6,
368 368
369 /* Horkage types. May be set by libata or controller on drives 369 /* Horkage types. May be set by libata or controller on drives
370 (some horkage may be drive/controller pair dependant */ 370 (some horkage may be drive/controller pair dependant */
371 371
372 ATA_HORKAGE_DIAGNOSTIC = (1 << 0), /* Failed boot diag */ 372 ATA_HORKAGE_DIAGNOSTIC = (1 << 0), /* Failed boot diag */
373 ATA_HORKAGE_NODMA = (1 << 1), /* DMA problems */ 373 ATA_HORKAGE_NODMA = (1 << 1), /* DMA problems */
374 ATA_HORKAGE_NONCQ = (1 << 2), /* Don't use NCQ */ 374 ATA_HORKAGE_NONCQ = (1 << 2), /* Don't use NCQ */
375 ATA_HORKAGE_MAX_SEC_128 = (1 << 3), /* Limit max sects to 128 */ 375 ATA_HORKAGE_MAX_SEC_128 = (1 << 3), /* Limit max sects to 128 */
376 ATA_HORKAGE_BROKEN_HPA = (1 << 4), /* Broken HPA */ 376 ATA_HORKAGE_BROKEN_HPA = (1 << 4), /* Broken HPA */
377 ATA_HORKAGE_DISABLE = (1 << 5), /* Disable it */ 377 ATA_HORKAGE_DISABLE = (1 << 5), /* Disable it */
378 ATA_HORKAGE_HPA_SIZE = (1 << 6), /* native size off by one */ 378 ATA_HORKAGE_HPA_SIZE = (1 << 6), /* native size off by one */
379 ATA_HORKAGE_IPM = (1 << 7), /* Link PM problems */ 379 ATA_HORKAGE_IPM = (1 << 7), /* Link PM problems */
380 ATA_HORKAGE_IVB = (1 << 8), /* cbl det validity bit bugs */ 380 ATA_HORKAGE_IVB = (1 << 8), /* cbl det validity bit bugs */
381 ATA_HORKAGE_STUCK_ERR = (1 << 9), /* stuck ERR on next PACKET */ 381 ATA_HORKAGE_STUCK_ERR = (1 << 9), /* stuck ERR on next PACKET */
382 ATA_HORKAGE_BRIDGE_OK = (1 << 10), /* no bridge limits */ 382 ATA_HORKAGE_BRIDGE_OK = (1 << 10), /* no bridge limits */
383 ATA_HORKAGE_ATAPI_MOD16_DMA = (1 << 11), /* use ATAPI DMA for commands 383 ATA_HORKAGE_ATAPI_MOD16_DMA = (1 << 11), /* use ATAPI DMA for commands
384 not multiple of 16 bytes */ 384 not multiple of 16 bytes */
385 ATA_HORKAGE_FIRMWARE_WARN = (1 << 12), /* firmware update warning */ 385 ATA_HORKAGE_FIRMWARE_WARN = (1 << 12), /* firmware update warning */
386 ATA_HORKAGE_1_5_GBPS = (1 << 13), /* force 1.5 Gbps */ 386 ATA_HORKAGE_1_5_GBPS = (1 << 13), /* force 1.5 Gbps */
387 ATA_HORKAGE_NOSETXFER = (1 << 14), /* skip SETXFER, SATA only */ 387 ATA_HORKAGE_NOSETXFER = (1 << 14), /* skip SETXFER, SATA only */
388 ATA_HORKAGE_BROKEN_FPDMA_AA = (1 << 15), /* skip AA */ 388 ATA_HORKAGE_BROKEN_FPDMA_AA = (1 << 15), /* skip AA */
389 ATA_HORKAGE_DUMP_ID = (1 << 16), /* dump IDENTIFY data */
389 390
390 /* DMA mask for user DMA control: User visible values; DO NOT 391 /* DMA mask for user DMA control: User visible values; DO NOT
391 renumber */ 392 renumber */
392 ATA_DMA_MASK_ATA = (1 << 0), /* DMA on ATA Disk */ 393 ATA_DMA_MASK_ATA = (1 << 0), /* DMA on ATA Disk */
393 ATA_DMA_MASK_ATAPI = (1 << 1), /* DMA on ATAPI */ 394 ATA_DMA_MASK_ATAPI = (1 << 1), /* DMA on ATAPI */
394 ATA_DMA_MASK_CFA = (1 << 2), /* DMA on CF Card */ 395 ATA_DMA_MASK_CFA = (1 << 2), /* DMA on CF Card */
395 396
396 /* ATAPI command types */ 397 /* ATAPI command types */
397 ATAPI_READ = 0, /* READs */ 398 ATAPI_READ = 0, /* READs */
398 ATAPI_WRITE = 1, /* WRITEs */ 399 ATAPI_WRITE = 1, /* WRITEs */
399 ATAPI_READ_CD = 2, /* READ CD [MSF] */ 400 ATAPI_READ_CD = 2, /* READ CD [MSF] */
400 ATAPI_PASS_THRU = 3, /* SAT pass-thru */ 401 ATAPI_PASS_THRU = 3, /* SAT pass-thru */
401 ATAPI_MISC = 4, /* the rest */ 402 ATAPI_MISC = 4, /* the rest */
402 403
403 /* Timing constants */ 404 /* Timing constants */
404 ATA_TIMING_SETUP = (1 << 0), 405 ATA_TIMING_SETUP = (1 << 0),
405 ATA_TIMING_ACT8B = (1 << 1), 406 ATA_TIMING_ACT8B = (1 << 1),
406 ATA_TIMING_REC8B = (1 << 2), 407 ATA_TIMING_REC8B = (1 << 2),
407 ATA_TIMING_CYC8B = (1 << 3), 408 ATA_TIMING_CYC8B = (1 << 3),
408 ATA_TIMING_8BIT = ATA_TIMING_ACT8B | ATA_TIMING_REC8B | 409 ATA_TIMING_8BIT = ATA_TIMING_ACT8B | ATA_TIMING_REC8B |
409 ATA_TIMING_CYC8B, 410 ATA_TIMING_CYC8B,
410 ATA_TIMING_ACTIVE = (1 << 4), 411 ATA_TIMING_ACTIVE = (1 << 4),
411 ATA_TIMING_RECOVER = (1 << 5), 412 ATA_TIMING_RECOVER = (1 << 5),
412 ATA_TIMING_DMACK_HOLD = (1 << 6), 413 ATA_TIMING_DMACK_HOLD = (1 << 6),
413 ATA_TIMING_CYCLE = (1 << 7), 414 ATA_TIMING_CYCLE = (1 << 7),
414 ATA_TIMING_UDMA = (1 << 8), 415 ATA_TIMING_UDMA = (1 << 8),
415 ATA_TIMING_ALL = ATA_TIMING_SETUP | ATA_TIMING_ACT8B | 416 ATA_TIMING_ALL = ATA_TIMING_SETUP | ATA_TIMING_ACT8B |
416 ATA_TIMING_REC8B | ATA_TIMING_CYC8B | 417 ATA_TIMING_REC8B | ATA_TIMING_CYC8B |
417 ATA_TIMING_ACTIVE | ATA_TIMING_RECOVER | 418 ATA_TIMING_ACTIVE | ATA_TIMING_RECOVER |
418 ATA_TIMING_DMACK_HOLD | ATA_TIMING_CYCLE | 419 ATA_TIMING_DMACK_HOLD | ATA_TIMING_CYCLE |
419 ATA_TIMING_UDMA, 420 ATA_TIMING_UDMA,
420 421
421 /* ACPI constants */ 422 /* ACPI constants */
422 ATA_ACPI_FILTER_SETXFER = 1 << 0, 423 ATA_ACPI_FILTER_SETXFER = 1 << 0,
423 ATA_ACPI_FILTER_LOCK = 1 << 1, 424 ATA_ACPI_FILTER_LOCK = 1 << 1,
424 ATA_ACPI_FILTER_DIPM = 1 << 2, 425 ATA_ACPI_FILTER_DIPM = 1 << 2,
425 ATA_ACPI_FILTER_FPDMA_OFFSET = 1 << 3, /* FPDMA non-zero offset */ 426 ATA_ACPI_FILTER_FPDMA_OFFSET = 1 << 3, /* FPDMA non-zero offset */
426 ATA_ACPI_FILTER_FPDMA_AA = 1 << 4, /* FPDMA auto activate */ 427 ATA_ACPI_FILTER_FPDMA_AA = 1 << 4, /* FPDMA auto activate */
427 428
428 ATA_ACPI_FILTER_DEFAULT = ATA_ACPI_FILTER_SETXFER | 429 ATA_ACPI_FILTER_DEFAULT = ATA_ACPI_FILTER_SETXFER |
429 ATA_ACPI_FILTER_LOCK | 430 ATA_ACPI_FILTER_LOCK |
430 ATA_ACPI_FILTER_DIPM, 431 ATA_ACPI_FILTER_DIPM,
431 }; 432 };
432 433
433 enum ata_xfer_mask { 434 enum ata_xfer_mask {
434 ATA_MASK_PIO = ((1LU << ATA_NR_PIO_MODES) - 1) 435 ATA_MASK_PIO = ((1LU << ATA_NR_PIO_MODES) - 1)
435 << ATA_SHIFT_PIO, 436 << ATA_SHIFT_PIO,
436 ATA_MASK_MWDMA = ((1LU << ATA_NR_MWDMA_MODES) - 1) 437 ATA_MASK_MWDMA = ((1LU << ATA_NR_MWDMA_MODES) - 1)
437 << ATA_SHIFT_MWDMA, 438 << ATA_SHIFT_MWDMA,
438 ATA_MASK_UDMA = ((1LU << ATA_NR_UDMA_MODES) - 1) 439 ATA_MASK_UDMA = ((1LU << ATA_NR_UDMA_MODES) - 1)
439 << ATA_SHIFT_UDMA, 440 << ATA_SHIFT_UDMA,
440 }; 441 };
441 442
442 enum hsm_task_states { 443 enum hsm_task_states {
443 HSM_ST_IDLE, /* no command on going */ 444 HSM_ST_IDLE, /* no command on going */
444 HSM_ST_FIRST, /* (waiting the device to) 445 HSM_ST_FIRST, /* (waiting the device to)
445 write CDB or first data block */ 446 write CDB or first data block */
446 HSM_ST, /* (waiting the device to) transfer data */ 447 HSM_ST, /* (waiting the device to) transfer data */
447 HSM_ST_LAST, /* (waiting the device to) complete command */ 448 HSM_ST_LAST, /* (waiting the device to) complete command */
448 HSM_ST_ERR, /* error */ 449 HSM_ST_ERR, /* error */
449 }; 450 };
450 451
451 enum ata_completion_errors { 452 enum ata_completion_errors {
452 AC_ERR_DEV = (1 << 0), /* device reported error */ 453 AC_ERR_DEV = (1 << 0), /* device reported error */
453 AC_ERR_HSM = (1 << 1), /* host state machine violation */ 454 AC_ERR_HSM = (1 << 1), /* host state machine violation */
454 AC_ERR_TIMEOUT = (1 << 2), /* timeout */ 455 AC_ERR_TIMEOUT = (1 << 2), /* timeout */
455 AC_ERR_MEDIA = (1 << 3), /* media error */ 456 AC_ERR_MEDIA = (1 << 3), /* media error */
456 AC_ERR_ATA_BUS = (1 << 4), /* ATA bus error */ 457 AC_ERR_ATA_BUS = (1 << 4), /* ATA bus error */
457 AC_ERR_HOST_BUS = (1 << 5), /* host bus error */ 458 AC_ERR_HOST_BUS = (1 << 5), /* host bus error */
458 AC_ERR_SYSTEM = (1 << 6), /* system error */ 459 AC_ERR_SYSTEM = (1 << 6), /* system error */
459 AC_ERR_INVALID = (1 << 7), /* invalid argument */ 460 AC_ERR_INVALID = (1 << 7), /* invalid argument */
460 AC_ERR_OTHER = (1 << 8), /* unknown */ 461 AC_ERR_OTHER = (1 << 8), /* unknown */
461 AC_ERR_NODEV_HINT = (1 << 9), /* polling device detection hint */ 462 AC_ERR_NODEV_HINT = (1 << 9), /* polling device detection hint */
462 AC_ERR_NCQ = (1 << 10), /* marker for offending NCQ qc */ 463 AC_ERR_NCQ = (1 << 10), /* marker for offending NCQ qc */
463 }; 464 };
464 465
465 /* forward declarations */ 466 /* forward declarations */
466 struct scsi_device; 467 struct scsi_device;
467 struct ata_port_operations; 468 struct ata_port_operations;
468 struct ata_port; 469 struct ata_port;
469 struct ata_link; 470 struct ata_link;
470 struct ata_queued_cmd; 471 struct ata_queued_cmd;
471 472
472 /* typedefs */ 473 /* typedefs */
473 typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc); 474 typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc);
474 typedef int (*ata_prereset_fn_t)(struct ata_link *link, unsigned long deadline); 475 typedef int (*ata_prereset_fn_t)(struct ata_link *link, unsigned long deadline);
475 typedef int (*ata_reset_fn_t)(struct ata_link *link, unsigned int *classes, 476 typedef int (*ata_reset_fn_t)(struct ata_link *link, unsigned int *classes,
476 unsigned long deadline); 477 unsigned long deadline);
477 typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes); 478 typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes);
478 479
479 /* 480 /*
480 * host pm policy: If you alter this, you also need to alter libata-scsi.c 481 * host pm policy: If you alter this, you also need to alter libata-scsi.c
481 * (for the ascii descriptions) 482 * (for the ascii descriptions)
482 */ 483 */
483 enum link_pm { 484 enum link_pm {
484 NOT_AVAILABLE, 485 NOT_AVAILABLE,
485 MIN_POWER, 486 MIN_POWER,
486 MAX_PERFORMANCE, 487 MAX_PERFORMANCE,
487 MEDIUM_POWER, 488 MEDIUM_POWER,
488 }; 489 };
489 extern struct device_attribute dev_attr_link_power_management_policy; 490 extern struct device_attribute dev_attr_link_power_management_policy;
490 extern struct device_attribute dev_attr_unload_heads; 491 extern struct device_attribute dev_attr_unload_heads;
491 extern struct device_attribute dev_attr_em_message_type; 492 extern struct device_attribute dev_attr_em_message_type;
492 extern struct device_attribute dev_attr_em_message; 493 extern struct device_attribute dev_attr_em_message;
493 extern struct device_attribute dev_attr_sw_activity; 494 extern struct device_attribute dev_attr_sw_activity;
494 495
495 enum sw_activity { 496 enum sw_activity {
496 OFF, 497 OFF,
497 BLINK_ON, 498 BLINK_ON,
498 BLINK_OFF, 499 BLINK_OFF,
499 }; 500 };
500 501
501 #ifdef CONFIG_ATA_SFF 502 #ifdef CONFIG_ATA_SFF
502 struct ata_ioports { 503 struct ata_ioports {
503 void __iomem *cmd_addr; 504 void __iomem *cmd_addr;
504 void __iomem *data_addr; 505 void __iomem *data_addr;
505 void __iomem *error_addr; 506 void __iomem *error_addr;
506 void __iomem *feature_addr; 507 void __iomem *feature_addr;
507 void __iomem *nsect_addr; 508 void __iomem *nsect_addr;
508 void __iomem *lbal_addr; 509 void __iomem *lbal_addr;
509 void __iomem *lbam_addr; 510 void __iomem *lbam_addr;
510 void __iomem *lbah_addr; 511 void __iomem *lbah_addr;
511 void __iomem *device_addr; 512 void __iomem *device_addr;
512 void __iomem *status_addr; 513 void __iomem *status_addr;
513 void __iomem *command_addr; 514 void __iomem *command_addr;
514 void __iomem *altstatus_addr; 515 void __iomem *altstatus_addr;
515 void __iomem *ctl_addr; 516 void __iomem *ctl_addr;
516 #ifdef CONFIG_ATA_BMDMA 517 #ifdef CONFIG_ATA_BMDMA
517 void __iomem *bmdma_addr; 518 void __iomem *bmdma_addr;
518 #endif /* CONFIG_ATA_BMDMA */ 519 #endif /* CONFIG_ATA_BMDMA */
519 void __iomem *scr_addr; 520 void __iomem *scr_addr;
520 }; 521 };
521 #endif /* CONFIG_ATA_SFF */ 522 #endif /* CONFIG_ATA_SFF */
522 523
523 struct ata_host { 524 struct ata_host {
524 spinlock_t lock; 525 spinlock_t lock;
525 struct device *dev; 526 struct device *dev;
526 void __iomem * const *iomap; 527 void __iomem * const *iomap;
527 unsigned int n_ports; 528 unsigned int n_ports;
528 void *private_data; 529 void *private_data;
529 struct ata_port_operations *ops; 530 struct ata_port_operations *ops;
530 unsigned long flags; 531 unsigned long flags;
531 #ifdef CONFIG_ATA_ACPI 532 #ifdef CONFIG_ATA_ACPI
532 acpi_handle acpi_handle; 533 acpi_handle acpi_handle;
533 #endif 534 #endif
534 struct ata_port *simplex_claimed; /* channel owning the DMA */ 535 struct ata_port *simplex_claimed; /* channel owning the DMA */
535 struct ata_port *ports[0]; 536 struct ata_port *ports[0];
536 }; 537 };
537 538
538 struct ata_queued_cmd { 539 struct ata_queued_cmd {
539 struct ata_port *ap; 540 struct ata_port *ap;
540 struct ata_device *dev; 541 struct ata_device *dev;
541 542
542 struct scsi_cmnd *scsicmd; 543 struct scsi_cmnd *scsicmd;
543 void (*scsidone)(struct scsi_cmnd *); 544 void (*scsidone)(struct scsi_cmnd *);
544 545
545 struct ata_taskfile tf; 546 struct ata_taskfile tf;
546 u8 cdb[ATAPI_CDB_LEN]; 547 u8 cdb[ATAPI_CDB_LEN];
547 548
548 unsigned long flags; /* ATA_QCFLAG_xxx */ 549 unsigned long flags; /* ATA_QCFLAG_xxx */
549 unsigned int tag; 550 unsigned int tag;
550 unsigned int n_elem; 551 unsigned int n_elem;
551 unsigned int orig_n_elem; 552 unsigned int orig_n_elem;
552 553
553 int dma_dir; 554 int dma_dir;
554 555
555 unsigned int sect_size; 556 unsigned int sect_size;
556 557
557 unsigned int nbytes; 558 unsigned int nbytes;
558 unsigned int extrabytes; 559 unsigned int extrabytes;
559 unsigned int curbytes; 560 unsigned int curbytes;
560 561
561 struct scatterlist *cursg; 562 struct scatterlist *cursg;
562 unsigned int cursg_ofs; 563 unsigned int cursg_ofs;
563 564
564 struct scatterlist sgent; 565 struct scatterlist sgent;
565 566
566 struct scatterlist *sg; 567 struct scatterlist *sg;
567 568
568 unsigned int err_mask; 569 unsigned int err_mask;
569 struct ata_taskfile result_tf; 570 struct ata_taskfile result_tf;
570 ata_qc_cb_t complete_fn; 571 ata_qc_cb_t complete_fn;
571 572
572 void *private_data; 573 void *private_data;
573 void *lldd_task; 574 void *lldd_task;
574 }; 575 };
575 576
576 struct ata_port_stats { 577 struct ata_port_stats {
577 unsigned long unhandled_irq; 578 unsigned long unhandled_irq;
578 unsigned long idle_irq; 579 unsigned long idle_irq;
579 unsigned long rw_reqbuf; 580 unsigned long rw_reqbuf;
580 }; 581 };
581 582
582 struct ata_ering_entry { 583 struct ata_ering_entry {
583 unsigned int eflags; 584 unsigned int eflags;
584 unsigned int err_mask; 585 unsigned int err_mask;
585 u64 timestamp; 586 u64 timestamp;
586 }; 587 };
587 588
588 struct ata_ering { 589 struct ata_ering {
589 int cursor; 590 int cursor;
590 struct ata_ering_entry ring[ATA_ERING_SIZE]; 591 struct ata_ering_entry ring[ATA_ERING_SIZE];
591 }; 592 };
592 593
593 struct ata_device { 594 struct ata_device {
594 struct ata_link *link; 595 struct ata_link *link;
595 unsigned int devno; /* 0 or 1 */ 596 unsigned int devno; /* 0 or 1 */
596 unsigned int horkage; /* List of broken features */ 597 unsigned int horkage; /* List of broken features */
597 unsigned long flags; /* ATA_DFLAG_xxx */ 598 unsigned long flags; /* ATA_DFLAG_xxx */
598 struct scsi_device *sdev; /* attached SCSI device */ 599 struct scsi_device *sdev; /* attached SCSI device */
599 void *private_data; 600 void *private_data;
600 #ifdef CONFIG_ATA_ACPI 601 #ifdef CONFIG_ATA_ACPI
601 acpi_handle acpi_handle; 602 acpi_handle acpi_handle;
602 union acpi_object *gtf_cache; 603 union acpi_object *gtf_cache;
603 unsigned int gtf_filter; 604 unsigned int gtf_filter;
604 #endif 605 #endif
605 /* n_sector is CLEAR_BEGIN, read comment above CLEAR_BEGIN */ 606 /* n_sector is CLEAR_BEGIN, read comment above CLEAR_BEGIN */
606 u64 n_sectors; /* size of device, if ATA */ 607 u64 n_sectors; /* size of device, if ATA */
607 u64 n_native_sectors; /* native size, if ATA */ 608 u64 n_native_sectors; /* native size, if ATA */
608 unsigned int class; /* ATA_DEV_xxx */ 609 unsigned int class; /* ATA_DEV_xxx */
609 unsigned long unpark_deadline; 610 unsigned long unpark_deadline;
610 611
611 u8 pio_mode; 612 u8 pio_mode;
612 u8 dma_mode; 613 u8 dma_mode;
613 u8 xfer_mode; 614 u8 xfer_mode;
614 unsigned int xfer_shift; /* ATA_SHIFT_xxx */ 615 unsigned int xfer_shift; /* ATA_SHIFT_xxx */
615 616
616 unsigned int multi_count; /* sectors count for 617 unsigned int multi_count; /* sectors count for
617 READ/WRITE MULTIPLE */ 618 READ/WRITE MULTIPLE */
618 unsigned int max_sectors; /* per-device max sectors */ 619 unsigned int max_sectors; /* per-device max sectors */
619 unsigned int cdb_len; 620 unsigned int cdb_len;
620 621
621 /* per-dev xfer mask */ 622 /* per-dev xfer mask */
622 unsigned long pio_mask; 623 unsigned long pio_mask;
623 unsigned long mwdma_mask; 624 unsigned long mwdma_mask;
624 unsigned long udma_mask; 625 unsigned long udma_mask;
625 626
626 /* for CHS addressing */ 627 /* for CHS addressing */
627 u16 cylinders; /* Number of cylinders */ 628 u16 cylinders; /* Number of cylinders */
628 u16 heads; /* Number of heads */ 629 u16 heads; /* Number of heads */
629 u16 sectors; /* Number of sectors per track */ 630 u16 sectors; /* Number of sectors per track */
630 631
631 union { 632 union {
632 u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */ 633 u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */
633 u32 gscr[SATA_PMP_GSCR_DWORDS]; /* PMP GSCR block */ 634 u32 gscr[SATA_PMP_GSCR_DWORDS]; /* PMP GSCR block */
634 }; 635 };
635 636
636 /* error history */ 637 /* error history */
637 int spdn_cnt; 638 int spdn_cnt;
638 /* ering is CLEAR_END, read comment above CLEAR_END */ 639 /* ering is CLEAR_END, read comment above CLEAR_END */
639 struct ata_ering ering; 640 struct ata_ering ering;
640 }; 641 };
641 642
642 /* Fields between ATA_DEVICE_CLEAR_BEGIN and ATA_DEVICE_CLEAR_END are 643 /* Fields between ATA_DEVICE_CLEAR_BEGIN and ATA_DEVICE_CLEAR_END are
643 * cleared to zero on ata_dev_init(). 644 * cleared to zero on ata_dev_init().
644 */ 645 */
645 #define ATA_DEVICE_CLEAR_BEGIN offsetof(struct ata_device, n_sectors) 646 #define ATA_DEVICE_CLEAR_BEGIN offsetof(struct ata_device, n_sectors)
646 #define ATA_DEVICE_CLEAR_END offsetof(struct ata_device, ering) 647 #define ATA_DEVICE_CLEAR_END offsetof(struct ata_device, ering)
647 648
648 struct ata_eh_info { 649 struct ata_eh_info {
649 struct ata_device *dev; /* offending device */ 650 struct ata_device *dev; /* offending device */
650 u32 serror; /* SError from LLDD */ 651 u32 serror; /* SError from LLDD */
651 unsigned int err_mask; /* port-wide err_mask */ 652 unsigned int err_mask; /* port-wide err_mask */
652 unsigned int action; /* ATA_EH_* action mask */ 653 unsigned int action; /* ATA_EH_* action mask */
653 unsigned int dev_action[ATA_MAX_DEVICES]; /* dev EH action */ 654 unsigned int dev_action[ATA_MAX_DEVICES]; /* dev EH action */
654 unsigned int flags; /* ATA_EHI_* flags */ 655 unsigned int flags; /* ATA_EHI_* flags */
655 656
656 unsigned int probe_mask; 657 unsigned int probe_mask;
657 658
658 char desc[ATA_EH_DESC_LEN]; 659 char desc[ATA_EH_DESC_LEN];
659 int desc_len; 660 int desc_len;
660 }; 661 };
661 662
662 struct ata_eh_context { 663 struct ata_eh_context {
663 struct ata_eh_info i; 664 struct ata_eh_info i;
664 int tries[ATA_MAX_DEVICES]; 665 int tries[ATA_MAX_DEVICES];
665 int cmd_timeout_idx[ATA_MAX_DEVICES] 666 int cmd_timeout_idx[ATA_MAX_DEVICES]
666 [ATA_EH_CMD_TIMEOUT_TABLE_SIZE]; 667 [ATA_EH_CMD_TIMEOUT_TABLE_SIZE];
667 unsigned int classes[ATA_MAX_DEVICES]; 668 unsigned int classes[ATA_MAX_DEVICES];
668 unsigned int did_probe_mask; 669 unsigned int did_probe_mask;
669 unsigned int unloaded_mask; 670 unsigned int unloaded_mask;
670 unsigned int saved_ncq_enabled; 671 unsigned int saved_ncq_enabled;
671 u8 saved_xfer_mode[ATA_MAX_DEVICES]; 672 u8 saved_xfer_mode[ATA_MAX_DEVICES];
672 /* timestamp for the last reset attempt or success */ 673 /* timestamp for the last reset attempt or success */
673 unsigned long last_reset; 674 unsigned long last_reset;
674 }; 675 };
675 676
676 struct ata_acpi_drive 677 struct ata_acpi_drive
677 { 678 {
678 u32 pio; 679 u32 pio;
679 u32 dma; 680 u32 dma;
680 } __packed; 681 } __packed;
681 682
682 struct ata_acpi_gtm { 683 struct ata_acpi_gtm {
683 struct ata_acpi_drive drive[2]; 684 struct ata_acpi_drive drive[2];
684 u32 flags; 685 u32 flags;
685 } __packed; 686 } __packed;
686 687
687 struct ata_link { 688 struct ata_link {
688 struct ata_port *ap; 689 struct ata_port *ap;
689 int pmp; /* port multiplier port # */ 690 int pmp; /* port multiplier port # */
690 691
691 unsigned int active_tag; /* active tag on this link */ 692 unsigned int active_tag; /* active tag on this link */
692 u32 sactive; /* active NCQ commands */ 693 u32 sactive; /* active NCQ commands */
693 694
694 unsigned int flags; /* ATA_LFLAG_xxx */ 695 unsigned int flags; /* ATA_LFLAG_xxx */
695 696
696 u32 saved_scontrol; /* SControl on probe */ 697 u32 saved_scontrol; /* SControl on probe */
697 unsigned int hw_sata_spd_limit; 698 unsigned int hw_sata_spd_limit;
698 unsigned int sata_spd_limit; 699 unsigned int sata_spd_limit;
699 unsigned int sata_spd; /* current SATA PHY speed */ 700 unsigned int sata_spd; /* current SATA PHY speed */
700 701
701 /* record runtime error info, protected by host_set lock */ 702 /* record runtime error info, protected by host_set lock */
702 struct ata_eh_info eh_info; 703 struct ata_eh_info eh_info;
703 /* EH context */ 704 /* EH context */
704 struct ata_eh_context eh_context; 705 struct ata_eh_context eh_context;
705 706
706 struct ata_device device[ATA_MAX_DEVICES]; 707 struct ata_device device[ATA_MAX_DEVICES];
707 }; 708 };
708 709
709 struct ata_port { 710 struct ata_port {
710 struct Scsi_Host *scsi_host; /* our co-allocated scsi host */ 711 struct Scsi_Host *scsi_host; /* our co-allocated scsi host */
711 struct ata_port_operations *ops; 712 struct ata_port_operations *ops;
712 spinlock_t *lock; 713 spinlock_t *lock;
713 /* Flags owned by the EH context. Only EH should touch these once the 714 /* Flags owned by the EH context. Only EH should touch these once the
714 port is active */ 715 port is active */
715 unsigned long flags; /* ATA_FLAG_xxx */ 716 unsigned long flags; /* ATA_FLAG_xxx */
716 /* Flags that change dynamically, protected by ap->lock */ 717 /* Flags that change dynamically, protected by ap->lock */
717 unsigned int pflags; /* ATA_PFLAG_xxx */ 718 unsigned int pflags; /* ATA_PFLAG_xxx */
718 unsigned int print_id; /* user visible unique port ID */ 719 unsigned int print_id; /* user visible unique port ID */
719 unsigned int port_no; /* 0 based port no. inside the host */ 720 unsigned int port_no; /* 0 based port no. inside the host */
720 721
721 #ifdef CONFIG_ATA_SFF 722 #ifdef CONFIG_ATA_SFF
722 struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */ 723 struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */
723 u8 ctl; /* cache of ATA control register */ 724 u8 ctl; /* cache of ATA control register */
724 u8 last_ctl; /* Cache last written value */ 725 u8 last_ctl; /* Cache last written value */
725 struct delayed_work sff_pio_task; 726 struct delayed_work sff_pio_task;
726 #ifdef CONFIG_ATA_BMDMA 727 #ifdef CONFIG_ATA_BMDMA
727 struct ata_bmdma_prd *bmdma_prd; /* BMDMA SG list */ 728 struct ata_bmdma_prd *bmdma_prd; /* BMDMA SG list */
728 dma_addr_t bmdma_prd_dma; /* and its DMA mapping */ 729 dma_addr_t bmdma_prd_dma; /* and its DMA mapping */
729 #endif /* CONFIG_ATA_BMDMA */ 730 #endif /* CONFIG_ATA_BMDMA */
730 #endif /* CONFIG_ATA_SFF */ 731 #endif /* CONFIG_ATA_SFF */
731 732
732 unsigned int pio_mask; 733 unsigned int pio_mask;
733 unsigned int mwdma_mask; 734 unsigned int mwdma_mask;
734 unsigned int udma_mask; 735 unsigned int udma_mask;
735 unsigned int cbl; /* cable type; ATA_CBL_xxx */ 736 unsigned int cbl; /* cable type; ATA_CBL_xxx */
736 737
737 struct ata_queued_cmd qcmd[ATA_MAX_QUEUE]; 738 struct ata_queued_cmd qcmd[ATA_MAX_QUEUE];
738 unsigned long qc_allocated; 739 unsigned long qc_allocated;
739 unsigned int qc_active; 740 unsigned int qc_active;
740 int nr_active_links; /* #links with active qcs */ 741 int nr_active_links; /* #links with active qcs */
741 742
742 struct ata_link link; /* host default link */ 743 struct ata_link link; /* host default link */
743 struct ata_link *slave_link; /* see ata_slave_link_init() */ 744 struct ata_link *slave_link; /* see ata_slave_link_init() */
744 745
745 int nr_pmp_links; /* nr of available PMP links */ 746 int nr_pmp_links; /* nr of available PMP links */
746 struct ata_link *pmp_link; /* array of PMP links */ 747 struct ata_link *pmp_link; /* array of PMP links */
747 struct ata_link *excl_link; /* for PMP qc exclusion */ 748 struct ata_link *excl_link; /* for PMP qc exclusion */
748 749
749 struct ata_port_stats stats; 750 struct ata_port_stats stats;
750 struct ata_host *host; 751 struct ata_host *host;
751 struct device *dev; 752 struct device *dev;
752 753
753 struct delayed_work hotplug_task; 754 struct delayed_work hotplug_task;
754 struct work_struct scsi_rescan_task; 755 struct work_struct scsi_rescan_task;
755 756
756 unsigned int hsm_task_state; 757 unsigned int hsm_task_state;
757 758
758 u32 msg_enable; 759 u32 msg_enable;
759 struct list_head eh_done_q; 760 struct list_head eh_done_q;
760 wait_queue_head_t eh_wait_q; 761 wait_queue_head_t eh_wait_q;
761 int eh_tries; 762 int eh_tries;
762 struct completion park_req_pending; 763 struct completion park_req_pending;
763 764
764 pm_message_t pm_mesg; 765 pm_message_t pm_mesg;
765 int *pm_result; 766 int *pm_result;
766 enum link_pm pm_policy; 767 enum link_pm pm_policy;
767 768
768 struct timer_list fastdrain_timer; 769 struct timer_list fastdrain_timer;
769 unsigned long fastdrain_cnt; 770 unsigned long fastdrain_cnt;
770 771
771 int em_message_type; 772 int em_message_type;
772 void *private_data; 773 void *private_data;
773 774
774 #ifdef CONFIG_ATA_ACPI 775 #ifdef CONFIG_ATA_ACPI
775 acpi_handle acpi_handle; 776 acpi_handle acpi_handle;
776 struct ata_acpi_gtm __acpi_init_gtm; /* use ata_acpi_init_gtm() */ 777 struct ata_acpi_gtm __acpi_init_gtm; /* use ata_acpi_init_gtm() */
777 #endif 778 #endif
778 /* owned by EH */ 779 /* owned by EH */
779 u8 sector_buf[ATA_SECT_SIZE] ____cacheline_aligned; 780 u8 sector_buf[ATA_SECT_SIZE] ____cacheline_aligned;
780 }; 781 };
781 782
782 /* The following initializer overrides a method to NULL whether one of 783 /* The following initializer overrides a method to NULL whether one of
783 * its parent has the method defined or not. This is equivalent to 784 * its parent has the method defined or not. This is equivalent to
784 * ERR_PTR(-ENOENT). Unfortunately, ERR_PTR doesn't render a constant 785 * ERR_PTR(-ENOENT). Unfortunately, ERR_PTR doesn't render a constant
785 * expression and thus can't be used as an initializer. 786 * expression and thus can't be used as an initializer.
786 */ 787 */
787 #define ATA_OP_NULL (void *)(unsigned long)(-ENOENT) 788 #define ATA_OP_NULL (void *)(unsigned long)(-ENOENT)
788 789
789 struct ata_port_operations { 790 struct ata_port_operations {
790 /* 791 /*
791 * Command execution 792 * Command execution
792 */ 793 */
793 int (*qc_defer)(struct ata_queued_cmd *qc); 794 int (*qc_defer)(struct ata_queued_cmd *qc);
794 int (*check_atapi_dma)(struct ata_queued_cmd *qc); 795 int (*check_atapi_dma)(struct ata_queued_cmd *qc);
795 void (*qc_prep)(struct ata_queued_cmd *qc); 796 void (*qc_prep)(struct ata_queued_cmd *qc);
796 unsigned int (*qc_issue)(struct ata_queued_cmd *qc); 797 unsigned int (*qc_issue)(struct ata_queued_cmd *qc);
797 bool (*qc_fill_rtf)(struct ata_queued_cmd *qc); 798 bool (*qc_fill_rtf)(struct ata_queued_cmd *qc);
798 799
799 /* 800 /*
800 * Configuration and exception handling 801 * Configuration and exception handling
801 */ 802 */
802 int (*cable_detect)(struct ata_port *ap); 803 int (*cable_detect)(struct ata_port *ap);
803 unsigned long (*mode_filter)(struct ata_device *dev, unsigned long xfer_mask); 804 unsigned long (*mode_filter)(struct ata_device *dev, unsigned long xfer_mask);
804 void (*set_piomode)(struct ata_port *ap, struct ata_device *dev); 805 void (*set_piomode)(struct ata_port *ap, struct ata_device *dev);
805 void (*set_dmamode)(struct ata_port *ap, struct ata_device *dev); 806 void (*set_dmamode)(struct ata_port *ap, struct ata_device *dev);
806 int (*set_mode)(struct ata_link *link, struct ata_device **r_failed_dev); 807 int (*set_mode)(struct ata_link *link, struct ata_device **r_failed_dev);
807 unsigned int (*read_id)(struct ata_device *dev, struct ata_taskfile *tf, u16 *id); 808 unsigned int (*read_id)(struct ata_device *dev, struct ata_taskfile *tf, u16 *id);
808 809
809 void (*dev_config)(struct ata_device *dev); 810 void (*dev_config)(struct ata_device *dev);
810 811
811 void (*freeze)(struct ata_port *ap); 812 void (*freeze)(struct ata_port *ap);
812 void (*thaw)(struct ata_port *ap); 813 void (*thaw)(struct ata_port *ap);
813 ata_prereset_fn_t prereset; 814 ata_prereset_fn_t prereset;
814 ata_reset_fn_t softreset; 815 ata_reset_fn_t softreset;
815 ata_reset_fn_t hardreset; 816 ata_reset_fn_t hardreset;
816 ata_postreset_fn_t postreset; 817 ata_postreset_fn_t postreset;
817 ata_prereset_fn_t pmp_prereset; 818 ata_prereset_fn_t pmp_prereset;
818 ata_reset_fn_t pmp_softreset; 819 ata_reset_fn_t pmp_softreset;
819 ata_reset_fn_t pmp_hardreset; 820 ata_reset_fn_t pmp_hardreset;
820 ata_postreset_fn_t pmp_postreset; 821 ata_postreset_fn_t pmp_postreset;
821 void (*error_handler)(struct ata_port *ap); 822 void (*error_handler)(struct ata_port *ap);
822 void (*lost_interrupt)(struct ata_port *ap); 823 void (*lost_interrupt)(struct ata_port *ap);
823 void (*post_internal_cmd)(struct ata_queued_cmd *qc); 824 void (*post_internal_cmd)(struct ata_queued_cmd *qc);
824 825
825 /* 826 /*
826 * Optional features 827 * Optional features
827 */ 828 */
828 int (*scr_read)(struct ata_link *link, unsigned int sc_reg, u32 *val); 829 int (*scr_read)(struct ata_link *link, unsigned int sc_reg, u32 *val);
829 int (*scr_write)(struct ata_link *link, unsigned int sc_reg, u32 val); 830 int (*scr_write)(struct ata_link *link, unsigned int sc_reg, u32 val);
830 void (*pmp_attach)(struct ata_port *ap); 831 void (*pmp_attach)(struct ata_port *ap);
831 void (*pmp_detach)(struct ata_port *ap); 832 void (*pmp_detach)(struct ata_port *ap);
832 int (*enable_pm)(struct ata_port *ap, enum link_pm policy); 833 int (*enable_pm)(struct ata_port *ap, enum link_pm policy);
833 void (*disable_pm)(struct ata_port *ap); 834 void (*disable_pm)(struct ata_port *ap);
834 835
835 /* 836 /*
836 * Start, stop, suspend and resume 837 * Start, stop, suspend and resume
837 */ 838 */
838 int (*port_suspend)(struct ata_port *ap, pm_message_t mesg); 839 int (*port_suspend)(struct ata_port *ap, pm_message_t mesg);
839 int (*port_resume)(struct ata_port *ap); 840 int (*port_resume)(struct ata_port *ap);
840 int (*port_start)(struct ata_port *ap); 841 int (*port_start)(struct ata_port *ap);
841 void (*port_stop)(struct ata_port *ap); 842 void (*port_stop)(struct ata_port *ap);
842 void (*host_stop)(struct ata_host *host); 843 void (*host_stop)(struct ata_host *host);
843 844
844 #ifdef CONFIG_ATA_SFF 845 #ifdef CONFIG_ATA_SFF
845 /* 846 /*
846 * SFF / taskfile oriented ops 847 * SFF / taskfile oriented ops
847 */ 848 */
848 void (*sff_dev_select)(struct ata_port *ap, unsigned int device); 849 void (*sff_dev_select)(struct ata_port *ap, unsigned int device);
849 void (*sff_set_devctl)(struct ata_port *ap, u8 ctl); 850 void (*sff_set_devctl)(struct ata_port *ap, u8 ctl);
850 u8 (*sff_check_status)(struct ata_port *ap); 851 u8 (*sff_check_status)(struct ata_port *ap);
851 u8 (*sff_check_altstatus)(struct ata_port *ap); 852 u8 (*sff_check_altstatus)(struct ata_port *ap);
852 void (*sff_tf_load)(struct ata_port *ap, const struct ata_taskfile *tf); 853 void (*sff_tf_load)(struct ata_port *ap, const struct ata_taskfile *tf);
853 void (*sff_tf_read)(struct ata_port *ap, struct ata_taskfile *tf); 854 void (*sff_tf_read)(struct ata_port *ap, struct ata_taskfile *tf);
854 void (*sff_exec_command)(struct ata_port *ap, 855 void (*sff_exec_command)(struct ata_port *ap,
855 const struct ata_taskfile *tf); 856 const struct ata_taskfile *tf);
856 unsigned int (*sff_data_xfer)(struct ata_device *dev, 857 unsigned int (*sff_data_xfer)(struct ata_device *dev,
857 unsigned char *buf, unsigned int buflen, int rw); 858 unsigned char *buf, unsigned int buflen, int rw);
858 void (*sff_irq_on)(struct ata_port *); 859 void (*sff_irq_on)(struct ata_port *);
859 bool (*sff_irq_check)(struct ata_port *); 860 bool (*sff_irq_check)(struct ata_port *);
860 void (*sff_irq_clear)(struct ata_port *); 861 void (*sff_irq_clear)(struct ata_port *);
861 void (*sff_drain_fifo)(struct ata_queued_cmd *qc); 862 void (*sff_drain_fifo)(struct ata_queued_cmd *qc);
862 863
863 #ifdef CONFIG_ATA_BMDMA 864 #ifdef CONFIG_ATA_BMDMA
864 void (*bmdma_setup)(struct ata_queued_cmd *qc); 865 void (*bmdma_setup)(struct ata_queued_cmd *qc);
865 void (*bmdma_start)(struct ata_queued_cmd *qc); 866 void (*bmdma_start)(struct ata_queued_cmd *qc);
866 void (*bmdma_stop)(struct ata_queued_cmd *qc); 867 void (*bmdma_stop)(struct ata_queued_cmd *qc);
867 u8 (*bmdma_status)(struct ata_port *ap); 868 u8 (*bmdma_status)(struct ata_port *ap);
868 #endif /* CONFIG_ATA_BMDMA */ 869 #endif /* CONFIG_ATA_BMDMA */
869 #endif /* CONFIG_ATA_SFF */ 870 #endif /* CONFIG_ATA_SFF */
870 871
871 ssize_t (*em_show)(struct ata_port *ap, char *buf); 872 ssize_t (*em_show)(struct ata_port *ap, char *buf);
872 ssize_t (*em_store)(struct ata_port *ap, const char *message, 873 ssize_t (*em_store)(struct ata_port *ap, const char *message,
873 size_t size); 874 size_t size);
874 ssize_t (*sw_activity_show)(struct ata_device *dev, char *buf); 875 ssize_t (*sw_activity_show)(struct ata_device *dev, char *buf);
875 ssize_t (*sw_activity_store)(struct ata_device *dev, 876 ssize_t (*sw_activity_store)(struct ata_device *dev,
876 enum sw_activity val); 877 enum sw_activity val);
877 /* 878 /*
878 * Obsolete 879 * Obsolete
879 */ 880 */
880 void (*phy_reset)(struct ata_port *ap); 881 void (*phy_reset)(struct ata_port *ap);
881 void (*eng_timeout)(struct ata_port *ap); 882 void (*eng_timeout)(struct ata_port *ap);
882 883
883 /* 884 /*
884 * ->inherits must be the last field and all the preceding 885 * ->inherits must be the last field and all the preceding
885 * fields must be pointers. 886 * fields must be pointers.
886 */ 887 */
887 const struct ata_port_operations *inherits; 888 const struct ata_port_operations *inherits;
888 }; 889 };
889 890
890 struct ata_port_info { 891 struct ata_port_info {
891 unsigned long flags; 892 unsigned long flags;
892 unsigned long link_flags; 893 unsigned long link_flags;
893 unsigned long pio_mask; 894 unsigned long pio_mask;
894 unsigned long mwdma_mask; 895 unsigned long mwdma_mask;
895 unsigned long udma_mask; 896 unsigned long udma_mask;
896 struct ata_port_operations *port_ops; 897 struct ata_port_operations *port_ops;
897 void *private_data; 898 void *private_data;
898 }; 899 };
899 900
900 struct ata_timing { 901 struct ata_timing {
901 unsigned short mode; /* ATA mode */ 902 unsigned short mode; /* ATA mode */
902 unsigned short setup; /* t1 */ 903 unsigned short setup; /* t1 */
903 unsigned short act8b; /* t2 for 8-bit I/O */ 904 unsigned short act8b; /* t2 for 8-bit I/O */
904 unsigned short rec8b; /* t2i for 8-bit I/O */ 905 unsigned short rec8b; /* t2i for 8-bit I/O */
905 unsigned short cyc8b; /* t0 for 8-bit I/O */ 906 unsigned short cyc8b; /* t0 for 8-bit I/O */
906 unsigned short active; /* t2 or tD */ 907 unsigned short active; /* t2 or tD */
907 unsigned short recover; /* t2i or tK */ 908 unsigned short recover; /* t2i or tK */
908 unsigned short dmack_hold; /* tj */ 909 unsigned short dmack_hold; /* tj */
909 unsigned short cycle; /* t0 */ 910 unsigned short cycle; /* t0 */
910 unsigned short udma; /* t2CYCTYP/2 */ 911 unsigned short udma; /* t2CYCTYP/2 */
911 }; 912 };
912 913
913 /* 914 /*
914 * Core layer - drivers/ata/libata-core.c 915 * Core layer - drivers/ata/libata-core.c
915 */ 916 */
916 extern const unsigned long sata_deb_timing_normal[]; 917 extern const unsigned long sata_deb_timing_normal[];
917 extern const unsigned long sata_deb_timing_hotplug[]; 918 extern const unsigned long sata_deb_timing_hotplug[];
918 extern const unsigned long sata_deb_timing_long[]; 919 extern const unsigned long sata_deb_timing_long[];
919 920
920 extern struct ata_port_operations ata_dummy_port_ops; 921 extern struct ata_port_operations ata_dummy_port_ops;
921 extern const struct ata_port_info ata_dummy_port_info; 922 extern const struct ata_port_info ata_dummy_port_info;
922 923
923 static inline const unsigned long * 924 static inline const unsigned long *
924 sata_ehc_deb_timing(struct ata_eh_context *ehc) 925 sata_ehc_deb_timing(struct ata_eh_context *ehc)
925 { 926 {
926 if (ehc->i.flags & ATA_EHI_HOTPLUGGED) 927 if (ehc->i.flags & ATA_EHI_HOTPLUGGED)
927 return sata_deb_timing_hotplug; 928 return sata_deb_timing_hotplug;
928 else 929 else
929 return sata_deb_timing_normal; 930 return sata_deb_timing_normal;
930 } 931 }
931 932
932 static inline int ata_port_is_dummy(struct ata_port *ap) 933 static inline int ata_port_is_dummy(struct ata_port *ap)
933 { 934 {
934 return ap->ops == &ata_dummy_port_ops; 935 return ap->ops == &ata_dummy_port_ops;
935 } 936 }
936 937
937 extern int sata_set_spd(struct ata_link *link); 938 extern int sata_set_spd(struct ata_link *link);
938 extern int ata_std_prereset(struct ata_link *link, unsigned long deadline); 939 extern int ata_std_prereset(struct ata_link *link, unsigned long deadline);
939 extern int ata_wait_after_reset(struct ata_link *link, unsigned long deadline, 940 extern int ata_wait_after_reset(struct ata_link *link, unsigned long deadline,
940 int (*check_ready)(struct ata_link *link)); 941 int (*check_ready)(struct ata_link *link));
941 extern int sata_link_debounce(struct ata_link *link, 942 extern int sata_link_debounce(struct ata_link *link,
942 const unsigned long *params, unsigned long deadline); 943 const unsigned long *params, unsigned long deadline);
943 extern int sata_link_resume(struct ata_link *link, const unsigned long *params, 944 extern int sata_link_resume(struct ata_link *link, const unsigned long *params,
944 unsigned long deadline); 945 unsigned long deadline);
945 extern int sata_link_hardreset(struct ata_link *link, 946 extern int sata_link_hardreset(struct ata_link *link,
946 const unsigned long *timing, unsigned long deadline, 947 const unsigned long *timing, unsigned long deadline,
947 bool *online, int (*check_ready)(struct ata_link *)); 948 bool *online, int (*check_ready)(struct ata_link *));
948 extern int sata_std_hardreset(struct ata_link *link, unsigned int *class, 949 extern int sata_std_hardreset(struct ata_link *link, unsigned int *class,
949 unsigned long deadline); 950 unsigned long deadline);
950 extern void ata_std_postreset(struct ata_link *link, unsigned int *classes); 951 extern void ata_std_postreset(struct ata_link *link, unsigned int *classes);
951 952
952 extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports); 953 extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports);
953 extern struct ata_host *ata_host_alloc_pinfo(struct device *dev, 954 extern struct ata_host *ata_host_alloc_pinfo(struct device *dev,
954 const struct ata_port_info * const * ppi, int n_ports); 955 const struct ata_port_info * const * ppi, int n_ports);
955 extern int ata_slave_link_init(struct ata_port *ap); 956 extern int ata_slave_link_init(struct ata_port *ap);
956 extern int ata_host_start(struct ata_host *host); 957 extern int ata_host_start(struct ata_host *host);
957 extern int ata_host_register(struct ata_host *host, 958 extern int ata_host_register(struct ata_host *host,
958 struct scsi_host_template *sht); 959 struct scsi_host_template *sht);
959 extern int ata_host_activate(struct ata_host *host, int irq, 960 extern int ata_host_activate(struct ata_host *host, int irq,
960 irq_handler_t irq_handler, unsigned long irq_flags, 961 irq_handler_t irq_handler, unsigned long irq_flags,
961 struct scsi_host_template *sht); 962 struct scsi_host_template *sht);
962 extern void ata_host_detach(struct ata_host *host); 963 extern void ata_host_detach(struct ata_host *host);
963 extern void ata_host_init(struct ata_host *, struct device *, 964 extern void ata_host_init(struct ata_host *, struct device *,
964 unsigned long, struct ata_port_operations *); 965 unsigned long, struct ata_port_operations *);
965 extern int ata_scsi_detect(struct scsi_host_template *sht); 966 extern int ata_scsi_detect(struct scsi_host_template *sht);
966 extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); 967 extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
967 extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); 968 extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *));
968 extern int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *dev, 969 extern int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *dev,
969 int cmd, void __user *arg); 970 int cmd, void __user *arg);
970 extern void ata_sas_port_destroy(struct ata_port *); 971 extern void ata_sas_port_destroy(struct ata_port *);
971 extern struct ata_port *ata_sas_port_alloc(struct ata_host *, 972 extern struct ata_port *ata_sas_port_alloc(struct ata_host *,
972 struct ata_port_info *, struct Scsi_Host *); 973 struct ata_port_info *, struct Scsi_Host *);
973 extern int ata_sas_port_init(struct ata_port *); 974 extern int ata_sas_port_init(struct ata_port *);
974 extern int ata_sas_port_start(struct ata_port *ap); 975 extern int ata_sas_port_start(struct ata_port *ap);
975 extern void ata_sas_port_stop(struct ata_port *ap); 976 extern void ata_sas_port_stop(struct ata_port *ap);
976 extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *); 977 extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *);
977 extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), 978 extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
978 struct ata_port *ap); 979 struct ata_port *ap);
979 extern int sata_scr_valid(struct ata_link *link); 980 extern int sata_scr_valid(struct ata_link *link);
980 extern int sata_scr_read(struct ata_link *link, int reg, u32 *val); 981 extern int sata_scr_read(struct ata_link *link, int reg, u32 *val);
981 extern int sata_scr_write(struct ata_link *link, int reg, u32 val); 982 extern int sata_scr_write(struct ata_link *link, int reg, u32 val);
982 extern int sata_scr_write_flush(struct ata_link *link, int reg, u32 val); 983 extern int sata_scr_write_flush(struct ata_link *link, int reg, u32 val);
983 extern bool ata_link_online(struct ata_link *link); 984 extern bool ata_link_online(struct ata_link *link);
984 extern bool ata_link_offline(struct ata_link *link); 985 extern bool ata_link_offline(struct ata_link *link);
985 #ifdef CONFIG_PM 986 #ifdef CONFIG_PM
986 extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg); 987 extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
987 extern void ata_host_resume(struct ata_host *host); 988 extern void ata_host_resume(struct ata_host *host);
988 #endif 989 #endif
989 extern int ata_ratelimit(void); 990 extern int ata_ratelimit(void);
990 extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, 991 extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
991 unsigned long interval, unsigned long timeout); 992 unsigned long interval, unsigned long timeout);
992 extern int atapi_cmd_type(u8 opcode); 993 extern int atapi_cmd_type(u8 opcode);
993 extern void ata_tf_to_fis(const struct ata_taskfile *tf, 994 extern void ata_tf_to_fis(const struct ata_taskfile *tf,
994 u8 pmp, int is_cmd, u8 *fis); 995 u8 pmp, int is_cmd, u8 *fis);
995 extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf); 996 extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf);
996 extern unsigned long ata_pack_xfermask(unsigned long pio_mask, 997 extern unsigned long ata_pack_xfermask(unsigned long pio_mask,
997 unsigned long mwdma_mask, unsigned long udma_mask); 998 unsigned long mwdma_mask, unsigned long udma_mask);
998 extern void ata_unpack_xfermask(unsigned long xfer_mask, 999 extern void ata_unpack_xfermask(unsigned long xfer_mask,
999 unsigned long *pio_mask, unsigned long *mwdma_mask, 1000 unsigned long *pio_mask, unsigned long *mwdma_mask,
1000 unsigned long *udma_mask); 1001 unsigned long *udma_mask);
1001 extern u8 ata_xfer_mask2mode(unsigned long xfer_mask); 1002 extern u8 ata_xfer_mask2mode(unsigned long xfer_mask);
1002 extern unsigned long ata_xfer_mode2mask(u8 xfer_mode); 1003 extern unsigned long ata_xfer_mode2mask(u8 xfer_mode);
1003 extern int ata_xfer_mode2shift(unsigned long xfer_mode); 1004 extern int ata_xfer_mode2shift(unsigned long xfer_mode);
1004 extern const char *ata_mode_string(unsigned long xfer_mask); 1005 extern const char *ata_mode_string(unsigned long xfer_mask);
1005 extern unsigned long ata_id_xfermask(const u16 *id); 1006 extern unsigned long ata_id_xfermask(const u16 *id);
1006 extern int ata_std_qc_defer(struct ata_queued_cmd *qc); 1007 extern int ata_std_qc_defer(struct ata_queued_cmd *qc);
1007 extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); 1008 extern void ata_noop_qc_prep(struct ata_queued_cmd *qc);
1008 extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, 1009 extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
1009 unsigned int n_elem); 1010 unsigned int n_elem);
1010 extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); 1011 extern unsigned int ata_dev_classify(const struct ata_taskfile *tf);
1011 extern void ata_dev_disable(struct ata_device *adev); 1012 extern void ata_dev_disable(struct ata_device *adev);
1012 extern void ata_id_string(const u16 *id, unsigned char *s, 1013 extern void ata_id_string(const u16 *id, unsigned char *s,
1013 unsigned int ofs, unsigned int len); 1014 unsigned int ofs, unsigned int len);
1014 extern void ata_id_c_string(const u16 *id, unsigned char *s, 1015 extern void ata_id_c_string(const u16 *id, unsigned char *s,
1015 unsigned int ofs, unsigned int len); 1016 unsigned int ofs, unsigned int len);
1016 extern unsigned int ata_do_dev_read_id(struct ata_device *dev, 1017 extern unsigned int ata_do_dev_read_id(struct ata_device *dev,
1017 struct ata_taskfile *tf, u16 *id); 1018 struct ata_taskfile *tf, u16 *id);
1018 extern void ata_qc_complete(struct ata_queued_cmd *qc); 1019 extern void ata_qc_complete(struct ata_queued_cmd *qc);
1019 extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active); 1020 extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active);
1020 extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, 1021 extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
1021 void (*done)(struct scsi_cmnd *)); 1022 void (*done)(struct scsi_cmnd *));
1022 extern int ata_std_bios_param(struct scsi_device *sdev, 1023 extern int ata_std_bios_param(struct scsi_device *sdev,
1023 struct block_device *bdev, 1024 struct block_device *bdev,
1024 sector_t capacity, int geom[]); 1025 sector_t capacity, int geom[]);
1025 extern int ata_scsi_slave_config(struct scsi_device *sdev); 1026 extern int ata_scsi_slave_config(struct scsi_device *sdev);
1026 extern void ata_scsi_slave_destroy(struct scsi_device *sdev); 1027 extern void ata_scsi_slave_destroy(struct scsi_device *sdev);
1027 extern int ata_scsi_change_queue_depth(struct scsi_device *sdev, 1028 extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
1028 int queue_depth, int reason); 1029 int queue_depth, int reason);
1029 extern struct ata_device *ata_dev_pair(struct ata_device *adev); 1030 extern struct ata_device *ata_dev_pair(struct ata_device *adev);
1030 extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev); 1031 extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev);
1031 1032
1032 extern int ata_cable_40wire(struct ata_port *ap); 1033 extern int ata_cable_40wire(struct ata_port *ap);
1033 extern int ata_cable_80wire(struct ata_port *ap); 1034 extern int ata_cable_80wire(struct ata_port *ap);
1034 extern int ata_cable_sata(struct ata_port *ap); 1035 extern int ata_cable_sata(struct ata_port *ap);
1035 extern int ata_cable_ignore(struct ata_port *ap); 1036 extern int ata_cable_ignore(struct ata_port *ap);
1036 extern int ata_cable_unknown(struct ata_port *ap); 1037 extern int ata_cable_unknown(struct ata_port *ap);
1037 1038
1038 /* Timing helpers */ 1039 /* Timing helpers */
1039 extern unsigned int ata_pio_need_iordy(const struct ata_device *); 1040 extern unsigned int ata_pio_need_iordy(const struct ata_device *);
1040 extern const struct ata_timing *ata_timing_find_mode(u8 xfer_mode); 1041 extern const struct ata_timing *ata_timing_find_mode(u8 xfer_mode);
1041 extern int ata_timing_compute(struct ata_device *, unsigned short, 1042 extern int ata_timing_compute(struct ata_device *, unsigned short,
1042 struct ata_timing *, int, int); 1043 struct ata_timing *, int, int);
1043 extern void ata_timing_merge(const struct ata_timing *, 1044 extern void ata_timing_merge(const struct ata_timing *,
1044 const struct ata_timing *, struct ata_timing *, 1045 const struct ata_timing *, struct ata_timing *,
1045 unsigned int); 1046 unsigned int);
1046 extern u8 ata_timing_cycle2mode(unsigned int xfer_shift, int cycle); 1047 extern u8 ata_timing_cycle2mode(unsigned int xfer_shift, int cycle);
1047 1048
1048 /* PCI */ 1049 /* PCI */
1049 #ifdef CONFIG_PCI 1050 #ifdef CONFIG_PCI
1050 struct pci_dev; 1051 struct pci_dev;
1051 1052
1052 struct pci_bits { 1053 struct pci_bits {
1053 unsigned int reg; /* PCI config register to read */ 1054 unsigned int reg; /* PCI config register to read */
1054 unsigned int width; /* 1 (8 bit), 2 (16 bit), 4 (32 bit) */ 1055 unsigned int width; /* 1 (8 bit), 2 (16 bit), 4 (32 bit) */
1055 unsigned long mask; 1056 unsigned long mask;
1056 unsigned long val; 1057 unsigned long val;
1057 }; 1058 };
1058 1059
1059 extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); 1060 extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
1060 extern void ata_pci_remove_one(struct pci_dev *pdev); 1061 extern void ata_pci_remove_one(struct pci_dev *pdev);
1061 1062
1062 #ifdef CONFIG_PM 1063 #ifdef CONFIG_PM
1063 extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg); 1064 extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg);
1064 extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev); 1065 extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev);
1065 extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); 1066 extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
1066 extern int ata_pci_device_resume(struct pci_dev *pdev); 1067 extern int ata_pci_device_resume(struct pci_dev *pdev);
1067 #endif /* CONFIG_PM */ 1068 #endif /* CONFIG_PM */
1068 #endif /* CONFIG_PCI */ 1069 #endif /* CONFIG_PCI */
1069 1070
1070 /* 1071 /*
1071 * ACPI - drivers/ata/libata-acpi.c 1072 * ACPI - drivers/ata/libata-acpi.c
1072 */ 1073 */
1073 #ifdef CONFIG_ATA_ACPI 1074 #ifdef CONFIG_ATA_ACPI
1074 static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) 1075 static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap)
1075 { 1076 {
1076 if (ap->pflags & ATA_PFLAG_INIT_GTM_VALID) 1077 if (ap->pflags & ATA_PFLAG_INIT_GTM_VALID)
1077 return &ap->__acpi_init_gtm; 1078 return &ap->__acpi_init_gtm;
1078 return NULL; 1079 return NULL;
1079 } 1080 }
1080 int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm); 1081 int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm);
1081 int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *stm); 1082 int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *stm);
1082 unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev, 1083 unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev,
1083 const struct ata_acpi_gtm *gtm); 1084 const struct ata_acpi_gtm *gtm);
1084 int ata_acpi_cbl_80wire(struct ata_port *ap, const struct ata_acpi_gtm *gtm); 1085 int ata_acpi_cbl_80wire(struct ata_port *ap, const struct ata_acpi_gtm *gtm);
1085 #else 1086 #else
1086 static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) 1087 static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap)
1087 { 1088 {
1088 return NULL; 1089 return NULL;
1089 } 1090 }
1090 1091
1091 static inline int ata_acpi_stm(const struct ata_port *ap, 1092 static inline int ata_acpi_stm(const struct ata_port *ap,
1092 struct ata_acpi_gtm *stm) 1093 struct ata_acpi_gtm *stm)
1093 { 1094 {
1094 return -ENOSYS; 1095 return -ENOSYS;
1095 } 1096 }
1096 1097
1097 static inline int ata_acpi_gtm(const struct ata_port *ap, 1098 static inline int ata_acpi_gtm(const struct ata_port *ap,
1098 struct ata_acpi_gtm *stm) 1099 struct ata_acpi_gtm *stm)
1099 { 1100 {
1100 return -ENOSYS; 1101 return -ENOSYS;
1101 } 1102 }
1102 1103
1103 static inline unsigned int ata_acpi_gtm_xfermask(struct ata_device *dev, 1104 static inline unsigned int ata_acpi_gtm_xfermask(struct ata_device *dev,
1104 const struct ata_acpi_gtm *gtm) 1105 const struct ata_acpi_gtm *gtm)
1105 { 1106 {
1106 return 0; 1107 return 0;
1107 } 1108 }
1108 1109
1109 static inline int ata_acpi_cbl_80wire(struct ata_port *ap, 1110 static inline int ata_acpi_cbl_80wire(struct ata_port *ap,
1110 const struct ata_acpi_gtm *gtm) 1111 const struct ata_acpi_gtm *gtm)
1111 { 1112 {
1112 return 0; 1113 return 0;
1113 } 1114 }
1114 #endif 1115 #endif
1115 1116
1116 /* 1117 /*
1117 * EH - drivers/ata/libata-eh.c 1118 * EH - drivers/ata/libata-eh.c
1118 */ 1119 */
1119 extern void ata_port_schedule_eh(struct ata_port *ap); 1120 extern void ata_port_schedule_eh(struct ata_port *ap);
1120 extern int ata_link_abort(struct ata_link *link); 1121 extern int ata_link_abort(struct ata_link *link);
1121 extern int ata_port_abort(struct ata_port *ap); 1122 extern int ata_port_abort(struct ata_port *ap);
1122 extern int ata_port_freeze(struct ata_port *ap); 1123 extern int ata_port_freeze(struct ata_port *ap);
1123 extern int sata_async_notification(struct ata_port *ap); 1124 extern int sata_async_notification(struct ata_port *ap);
1124 1125
1125 extern void ata_eh_freeze_port(struct ata_port *ap); 1126 extern void ata_eh_freeze_port(struct ata_port *ap);
1126 extern void ata_eh_thaw_port(struct ata_port *ap); 1127 extern void ata_eh_thaw_port(struct ata_port *ap);
1127 1128
1128 extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); 1129 extern void ata_eh_qc_complete(struct ata_queued_cmd *qc);
1129 extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); 1130 extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
1130 extern void ata_eh_analyze_ncq_error(struct ata_link *link); 1131 extern void ata_eh_analyze_ncq_error(struct ata_link *link);
1131 1132
1132 extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, 1133 extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
1133 ata_reset_fn_t softreset, ata_reset_fn_t hardreset, 1134 ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
1134 ata_postreset_fn_t postreset); 1135 ata_postreset_fn_t postreset);
1135 extern void ata_std_error_handler(struct ata_port *ap); 1136 extern void ata_std_error_handler(struct ata_port *ap);
1136 1137
1137 /* 1138 /*
1138 * Base operations to inherit from and initializers for sht 1139 * Base operations to inherit from and initializers for sht
1139 * 1140 *
1140 * Operations 1141 * Operations
1141 * 1142 *
1142 * base : Common to all libata drivers. 1143 * base : Common to all libata drivers.
1143 * sata : SATA controllers w/ native interface. 1144 * sata : SATA controllers w/ native interface.
1144 * pmp : SATA controllers w/ PMP support. 1145 * pmp : SATA controllers w/ PMP support.
1145 * sff : SFF ATA controllers w/o BMDMA support. 1146 * sff : SFF ATA controllers w/o BMDMA support.
1146 * bmdma : SFF ATA controllers w/ BMDMA support. 1147 * bmdma : SFF ATA controllers w/ BMDMA support.
1147 * 1148 *
1148 * sht initializers 1149 * sht initializers
1149 * 1150 *
1150 * BASE : Common to all libata drivers. The user must set 1151 * BASE : Common to all libata drivers. The user must set
1151 * sg_tablesize and dma_boundary. 1152 * sg_tablesize and dma_boundary.
1152 * PIO : SFF ATA controllers w/ only PIO support. 1153 * PIO : SFF ATA controllers w/ only PIO support.
1153 * BMDMA : SFF ATA controllers w/ BMDMA support. sg_tablesize and 1154 * BMDMA : SFF ATA controllers w/ BMDMA support. sg_tablesize and
1154 * dma_boundary are set to BMDMA limits. 1155 * dma_boundary are set to BMDMA limits.
1155 * NCQ : SATA controllers supporting NCQ. The user must set 1156 * NCQ : SATA controllers supporting NCQ. The user must set
1156 * sg_tablesize, dma_boundary and can_queue. 1157 * sg_tablesize, dma_boundary and can_queue.
1157 */ 1158 */
1158 extern const struct ata_port_operations ata_base_port_ops; 1159 extern const struct ata_port_operations ata_base_port_ops;
1159 extern const struct ata_port_operations sata_port_ops; 1160 extern const struct ata_port_operations sata_port_ops;
1160 extern struct device_attribute *ata_common_sdev_attrs[]; 1161 extern struct device_attribute *ata_common_sdev_attrs[];
1161 1162
1162 #define ATA_BASE_SHT(drv_name) \ 1163 #define ATA_BASE_SHT(drv_name) \
1163 .module = THIS_MODULE, \ 1164 .module = THIS_MODULE, \
1164 .name = drv_name, \ 1165 .name = drv_name, \
1165 .ioctl = ata_scsi_ioctl, \ 1166 .ioctl = ata_scsi_ioctl, \
1166 .queuecommand = ata_scsi_queuecmd, \ 1167 .queuecommand = ata_scsi_queuecmd, \
1167 .can_queue = ATA_DEF_QUEUE, \ 1168 .can_queue = ATA_DEF_QUEUE, \
1168 .this_id = ATA_SHT_THIS_ID, \ 1169 .this_id = ATA_SHT_THIS_ID, \
1169 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, \ 1170 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, \
1170 .emulated = ATA_SHT_EMULATED, \ 1171 .emulated = ATA_SHT_EMULATED, \
1171 .use_clustering = ATA_SHT_USE_CLUSTERING, \ 1172 .use_clustering = ATA_SHT_USE_CLUSTERING, \
1172 .proc_name = drv_name, \ 1173 .proc_name = drv_name, \
1173 .slave_configure = ata_scsi_slave_config, \ 1174 .slave_configure = ata_scsi_slave_config, \
1174 .slave_destroy = ata_scsi_slave_destroy, \ 1175 .slave_destroy = ata_scsi_slave_destroy, \
1175 .bios_param = ata_std_bios_param, \ 1176 .bios_param = ata_std_bios_param, \
1176 .sdev_attrs = ata_common_sdev_attrs 1177 .sdev_attrs = ata_common_sdev_attrs
1177 1178
1178 #define ATA_NCQ_SHT(drv_name) \ 1179 #define ATA_NCQ_SHT(drv_name) \
1179 ATA_BASE_SHT(drv_name), \ 1180 ATA_BASE_SHT(drv_name), \
1180 .change_queue_depth = ata_scsi_change_queue_depth 1181 .change_queue_depth = ata_scsi_change_queue_depth
1181 1182
1182 /* 1183 /*
1183 * PMP helpers 1184 * PMP helpers
1184 */ 1185 */
1185 #ifdef CONFIG_SATA_PMP 1186 #ifdef CONFIG_SATA_PMP
1186 static inline bool sata_pmp_supported(struct ata_port *ap) 1187 static inline bool sata_pmp_supported(struct ata_port *ap)
1187 { 1188 {
1188 return ap->flags & ATA_FLAG_PMP; 1189 return ap->flags & ATA_FLAG_PMP;
1189 } 1190 }
1190 1191
1191 static inline bool sata_pmp_attached(struct ata_port *ap) 1192 static inline bool sata_pmp_attached(struct ata_port *ap)
1192 { 1193 {
1193 return ap->nr_pmp_links != 0; 1194 return ap->nr_pmp_links != 0;
1194 } 1195 }
1195 1196
1196 static inline int ata_is_host_link(const struct ata_link *link) 1197 static inline int ata_is_host_link(const struct ata_link *link)
1197 { 1198 {
1198 return link == &link->ap->link || link == link->ap->slave_link; 1199 return link == &link->ap->link || link == link->ap->slave_link;
1199 } 1200 }
1200 #else /* CONFIG_SATA_PMP */ 1201 #else /* CONFIG_SATA_PMP */
1201 static inline bool sata_pmp_supported(struct ata_port *ap) 1202 static inline bool sata_pmp_supported(struct ata_port *ap)
1202 { 1203 {
1203 return false; 1204 return false;
1204 } 1205 }
1205 1206
1206 static inline bool sata_pmp_attached(struct ata_port *ap) 1207 static inline bool sata_pmp_attached(struct ata_port *ap)
1207 { 1208 {
1208 return false; 1209 return false;
1209 } 1210 }
1210 1211
1211 static inline int ata_is_host_link(const struct ata_link *link) 1212 static inline int ata_is_host_link(const struct ata_link *link)
1212 { 1213 {
1213 return 1; 1214 return 1;
1214 } 1215 }
1215 #endif /* CONFIG_SATA_PMP */ 1216 #endif /* CONFIG_SATA_PMP */
1216 1217
1217 static inline int sata_srst_pmp(struct ata_link *link) 1218 static inline int sata_srst_pmp(struct ata_link *link)
1218 { 1219 {
1219 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) 1220 if (sata_pmp_supported(link->ap) && ata_is_host_link(link))
1220 return SATA_PMP_CTRL_PORT; 1221 return SATA_PMP_CTRL_PORT;
1221 return link->pmp; 1222 return link->pmp;
1222 } 1223 }
1223 1224
1224 /* 1225 /*
1225 * printk helpers 1226 * printk helpers
1226 */ 1227 */
1227 #define ata_port_printk(ap, lv, fmt, args...) \ 1228 #define ata_port_printk(ap, lv, fmt, args...) \
1228 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args) 1229 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args)
1229 1230
1230 #define ata_link_printk(link, lv, fmt, args...) do { \ 1231 #define ata_link_printk(link, lv, fmt, args...) do { \
1231 if (sata_pmp_attached((link)->ap) || (link)->ap->slave_link) \ 1232 if (sata_pmp_attached((link)->ap) || (link)->ap->slave_link) \
1232 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \ 1233 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \
1233 (link)->pmp , ##args); \ 1234 (link)->pmp , ##args); \
1234 else \ 1235 else \
1235 printk("%sata%u: "fmt, lv, (link)->ap->print_id , ##args); \ 1236 printk("%sata%u: "fmt, lv, (link)->ap->print_id , ##args); \
1236 } while(0) 1237 } while(0)
1237 1238
1238 #define ata_dev_printk(dev, lv, fmt, args...) \ 1239 #define ata_dev_printk(dev, lv, fmt, args...) \
1239 printk("%sata%u.%02u: "fmt, lv, (dev)->link->ap->print_id, \ 1240 printk("%sata%u.%02u: "fmt, lv, (dev)->link->ap->print_id, \
1240 (dev)->link->pmp + (dev)->devno , ##args) 1241 (dev)->link->pmp + (dev)->devno , ##args)
1241 1242
1242 /* 1243 /*
1243 * ata_eh_info helpers 1244 * ata_eh_info helpers
1244 */ 1245 */
1245 extern void __ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...) 1246 extern void __ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...)
1246 __attribute__ ((format (printf, 2, 3))); 1247 __attribute__ ((format (printf, 2, 3)));
1247 extern void ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...) 1248 extern void ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...)
1248 __attribute__ ((format (printf, 2, 3))); 1249 __attribute__ ((format (printf, 2, 3)));
1249 extern void ata_ehi_clear_desc(struct ata_eh_info *ehi); 1250 extern void ata_ehi_clear_desc(struct ata_eh_info *ehi);
1250 1251
1251 static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi) 1252 static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi)
1252 { 1253 {
1253 ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1; 1254 ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1;
1254 ehi->flags |= ATA_EHI_HOTPLUGGED; 1255 ehi->flags |= ATA_EHI_HOTPLUGGED;
1255 ehi->action |= ATA_EH_RESET | ATA_EH_ENABLE_LINK; 1256 ehi->action |= ATA_EH_RESET | ATA_EH_ENABLE_LINK;
1256 ehi->err_mask |= AC_ERR_ATA_BUS; 1257 ehi->err_mask |= AC_ERR_ATA_BUS;
1257 } 1258 }
1258 1259
1259 /* 1260 /*
1260 * port description helpers 1261 * port description helpers
1261 */ 1262 */
1262 extern void ata_port_desc(struct ata_port *ap, const char *fmt, ...) 1263 extern void ata_port_desc(struct ata_port *ap, const char *fmt, ...)
1263 __attribute__ ((format (printf, 2, 3))); 1264 __attribute__ ((format (printf, 2, 3)));
1264 #ifdef CONFIG_PCI 1265 #ifdef CONFIG_PCI
1265 extern void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset, 1266 extern void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset,
1266 const char *name); 1267 const char *name);
1267 #endif 1268 #endif
1268 1269
1269 static inline unsigned int ata_tag_valid(unsigned int tag) 1270 static inline unsigned int ata_tag_valid(unsigned int tag)
1270 { 1271 {
1271 return (tag < ATA_MAX_QUEUE) ? 1 : 0; 1272 return (tag < ATA_MAX_QUEUE) ? 1 : 0;
1272 } 1273 }
1273 1274
1274 static inline unsigned int ata_tag_internal(unsigned int tag) 1275 static inline unsigned int ata_tag_internal(unsigned int tag)
1275 { 1276 {
1276 return tag == ATA_TAG_INTERNAL; 1277 return tag == ATA_TAG_INTERNAL;
1277 } 1278 }
1278 1279
1279 /* 1280 /*
1280 * device helpers 1281 * device helpers
1281 */ 1282 */
1282 static inline unsigned int ata_class_enabled(unsigned int class) 1283 static inline unsigned int ata_class_enabled(unsigned int class)
1283 { 1284 {
1284 return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI || 1285 return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI ||
1285 class == ATA_DEV_PMP || class == ATA_DEV_SEMB; 1286 class == ATA_DEV_PMP || class == ATA_DEV_SEMB;
1286 } 1287 }
1287 1288
1288 static inline unsigned int ata_class_disabled(unsigned int class) 1289 static inline unsigned int ata_class_disabled(unsigned int class)
1289 { 1290 {
1290 return class == ATA_DEV_ATA_UNSUP || class == ATA_DEV_ATAPI_UNSUP || 1291 return class == ATA_DEV_ATA_UNSUP || class == ATA_DEV_ATAPI_UNSUP ||
1291 class == ATA_DEV_PMP_UNSUP || class == ATA_DEV_SEMB_UNSUP; 1292 class == ATA_DEV_PMP_UNSUP || class == ATA_DEV_SEMB_UNSUP;
1292 } 1293 }
1293 1294
1294 static inline unsigned int ata_class_absent(unsigned int class) 1295 static inline unsigned int ata_class_absent(unsigned int class)
1295 { 1296 {
1296 return !ata_class_enabled(class) && !ata_class_disabled(class); 1297 return !ata_class_enabled(class) && !ata_class_disabled(class);
1297 } 1298 }
1298 1299
1299 static inline unsigned int ata_dev_enabled(const struct ata_device *dev) 1300 static inline unsigned int ata_dev_enabled(const struct ata_device *dev)
1300 { 1301 {
1301 return ata_class_enabled(dev->class); 1302 return ata_class_enabled(dev->class);
1302 } 1303 }
1303 1304
1304 static inline unsigned int ata_dev_disabled(const struct ata_device *dev) 1305 static inline unsigned int ata_dev_disabled(const struct ata_device *dev)
1305 { 1306 {
1306 return ata_class_disabled(dev->class); 1307 return ata_class_disabled(dev->class);
1307 } 1308 }
1308 1309
1309 static inline unsigned int ata_dev_absent(const struct ata_device *dev) 1310 static inline unsigned int ata_dev_absent(const struct ata_device *dev)
1310 { 1311 {
1311 return ata_class_absent(dev->class); 1312 return ata_class_absent(dev->class);
1312 } 1313 }
1313 1314
1314 /* 1315 /*
1315 * link helpers 1316 * link helpers
1316 */ 1317 */
1317 static inline int ata_link_max_devices(const struct ata_link *link) 1318 static inline int ata_link_max_devices(const struct ata_link *link)
1318 { 1319 {
1319 if (ata_is_host_link(link) && link->ap->flags & ATA_FLAG_SLAVE_POSS) 1320 if (ata_is_host_link(link) && link->ap->flags & ATA_FLAG_SLAVE_POSS)
1320 return 2; 1321 return 2;
1321 return 1; 1322 return 1;
1322 } 1323 }
1323 1324
1324 static inline int ata_link_active(struct ata_link *link) 1325 static inline int ata_link_active(struct ata_link *link)
1325 { 1326 {
1326 return ata_tag_valid(link->active_tag) || link->sactive; 1327 return ata_tag_valid(link->active_tag) || link->sactive;
1327 } 1328 }
1328 1329
1329 /* 1330 /*
1330 * Iterators 1331 * Iterators
1331 * 1332 *
1332 * ATA_LITER_* constants are used to select link iteration mode and 1333 * ATA_LITER_* constants are used to select link iteration mode and
1333 * ATA_DITER_* device iteration mode. 1334 * ATA_DITER_* device iteration mode.
1334 * 1335 *
1335 * For a custom iteration directly using ata_{link|dev}_next(), if 1336 * For a custom iteration directly using ata_{link|dev}_next(), if
1336 * @link or @dev, respectively, is NULL, the first element is 1337 * @link or @dev, respectively, is NULL, the first element is
1337 * returned. @dev and @link can be any valid device or link and the 1338 * returned. @dev and @link can be any valid device or link and the
1338 * next element according to the iteration mode will be returned. 1339 * next element according to the iteration mode will be returned.
1339 * After the last element, NULL is returned. 1340 * After the last element, NULL is returned.
1340 */ 1341 */
1341 enum ata_link_iter_mode { 1342 enum ata_link_iter_mode {
1342 ATA_LITER_EDGE, /* if present, PMP links only; otherwise, 1343 ATA_LITER_EDGE, /* if present, PMP links only; otherwise,
1343 * host link. no slave link */ 1344 * host link. no slave link */
1344 ATA_LITER_HOST_FIRST, /* host link followed by PMP or slave links */ 1345 ATA_LITER_HOST_FIRST, /* host link followed by PMP or slave links */
1345 ATA_LITER_PMP_FIRST, /* PMP links followed by host link, 1346 ATA_LITER_PMP_FIRST, /* PMP links followed by host link,
1346 * slave link still comes after host link */ 1347 * slave link still comes after host link */
1347 }; 1348 };
1348 1349
1349 enum ata_dev_iter_mode { 1350 enum ata_dev_iter_mode {
1350 ATA_DITER_ENABLED, 1351 ATA_DITER_ENABLED,
1351 ATA_DITER_ENABLED_REVERSE, 1352 ATA_DITER_ENABLED_REVERSE,
1352 ATA_DITER_ALL, 1353 ATA_DITER_ALL,
1353 ATA_DITER_ALL_REVERSE, 1354 ATA_DITER_ALL_REVERSE,
1354 }; 1355 };
1355 1356
1356 extern struct ata_link *ata_link_next(struct ata_link *link, 1357 extern struct ata_link *ata_link_next(struct ata_link *link,
1357 struct ata_port *ap, 1358 struct ata_port *ap,
1358 enum ata_link_iter_mode mode); 1359 enum ata_link_iter_mode mode);
1359 1360
1360 extern struct ata_device *ata_dev_next(struct ata_device *dev, 1361 extern struct ata_device *ata_dev_next(struct ata_device *dev,
1361 struct ata_link *link, 1362 struct ata_link *link,
1362 enum ata_dev_iter_mode mode); 1363 enum ata_dev_iter_mode mode);
1363 1364
1364 /* 1365 /*
1365 * Shortcut notation for iterations 1366 * Shortcut notation for iterations
1366 * 1367 *
1367 * ata_for_each_link() iterates over each link of @ap according to 1368 * ata_for_each_link() iterates over each link of @ap according to
1368 * @mode. @link points to the current link in the loop. @link is 1369 * @mode. @link points to the current link in the loop. @link is
1369 * NULL after loop termination. ata_for_each_dev() works the same way 1370 * NULL after loop termination. ata_for_each_dev() works the same way
1370 * except that it iterates over each device of @link. 1371 * except that it iterates over each device of @link.
1371 * 1372 *
1372 * Note that the mode prefixes ATA_{L|D}ITER_ shouldn't need to be 1373 * Note that the mode prefixes ATA_{L|D}ITER_ shouldn't need to be
1373 * specified when using the following shorthand notations. Only the 1374 * specified when using the following shorthand notations. Only the
1374 * mode itself (EDGE, HOST_FIRST, ENABLED, etc...) should be 1375 * mode itself (EDGE, HOST_FIRST, ENABLED, etc...) should be
1375 * specified. This not only increases brevity but also makes it 1376 * specified. This not only increases brevity but also makes it
1376 * impossible to use ATA_LITER_* for device iteration or vice-versa. 1377 * impossible to use ATA_LITER_* for device iteration or vice-versa.
1377 */ 1378 */
1378 #define ata_for_each_link(link, ap, mode) \ 1379 #define ata_for_each_link(link, ap, mode) \
1379 for ((link) = ata_link_next(NULL, (ap), ATA_LITER_##mode); (link); \ 1380 for ((link) = ata_link_next(NULL, (ap), ATA_LITER_##mode); (link); \
1380 (link) = ata_link_next((link), (ap), ATA_LITER_##mode)) 1381 (link) = ata_link_next((link), (ap), ATA_LITER_##mode))
1381 1382
1382 #define ata_for_each_dev(dev, link, mode) \ 1383 #define ata_for_each_dev(dev, link, mode) \
1383 for ((dev) = ata_dev_next(NULL, (link), ATA_DITER_##mode); (dev); \ 1384 for ((dev) = ata_dev_next(NULL, (link), ATA_DITER_##mode); (dev); \
1384 (dev) = ata_dev_next((dev), (link), ATA_DITER_##mode)) 1385 (dev) = ata_dev_next((dev), (link), ATA_DITER_##mode))
1385 1386
1386 /** 1387 /**
1387 * ata_ncq_enabled - Test whether NCQ is enabled 1388 * ata_ncq_enabled - Test whether NCQ is enabled
1388 * @dev: ATA device to test for 1389 * @dev: ATA device to test for
1389 * 1390 *
1390 * LOCKING: 1391 * LOCKING:
1391 * spin_lock_irqsave(host lock) 1392 * spin_lock_irqsave(host lock)
1392 * 1393 *
1393 * RETURNS: 1394 * RETURNS:
1394 * 1 if NCQ is enabled for @dev, 0 otherwise. 1395 * 1 if NCQ is enabled for @dev, 0 otherwise.
1395 */ 1396 */
1396 static inline int ata_ncq_enabled(struct ata_device *dev) 1397 static inline int ata_ncq_enabled(struct ata_device *dev)
1397 { 1398 {
1398 return (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF | 1399 return (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF |
1399 ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ; 1400 ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ;
1400 } 1401 }
1401 1402
1402 static inline void ata_qc_set_polling(struct ata_queued_cmd *qc) 1403 static inline void ata_qc_set_polling(struct ata_queued_cmd *qc)
1403 { 1404 {
1404 qc->tf.ctl |= ATA_NIEN; 1405 qc->tf.ctl |= ATA_NIEN;
1405 } 1406 }
1406 1407
1407 static inline struct ata_queued_cmd *__ata_qc_from_tag(struct ata_port *ap, 1408 static inline struct ata_queued_cmd *__ata_qc_from_tag(struct ata_port *ap,
1408 unsigned int tag) 1409 unsigned int tag)
1409 { 1410 {
1410 if (likely(ata_tag_valid(tag))) 1411 if (likely(ata_tag_valid(tag)))
1411 return &ap->qcmd[tag]; 1412 return &ap->qcmd[tag];
1412 return NULL; 1413 return NULL;
1413 } 1414 }
1414 1415
1415 static inline struct ata_queued_cmd *ata_qc_from_tag(struct ata_port *ap, 1416 static inline struct ata_queued_cmd *ata_qc_from_tag(struct ata_port *ap,
1416 unsigned int tag) 1417 unsigned int tag)
1417 { 1418 {
1418 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); 1419 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
1419 1420
1420 if (unlikely(!qc) || !ap->ops->error_handler) 1421 if (unlikely(!qc) || !ap->ops->error_handler)
1421 return qc; 1422 return qc;
1422 1423
1423 if ((qc->flags & (ATA_QCFLAG_ACTIVE | 1424 if ((qc->flags & (ATA_QCFLAG_ACTIVE |
1424 ATA_QCFLAG_FAILED)) == ATA_QCFLAG_ACTIVE) 1425 ATA_QCFLAG_FAILED)) == ATA_QCFLAG_ACTIVE)
1425 return qc; 1426 return qc;
1426 1427
1427 return NULL; 1428 return NULL;
1428 } 1429 }
1429 1430
1430 static inline unsigned int ata_qc_raw_nbytes(struct ata_queued_cmd *qc) 1431 static inline unsigned int ata_qc_raw_nbytes(struct ata_queued_cmd *qc)
1431 { 1432 {
1432 return qc->nbytes - min(qc->extrabytes, qc->nbytes); 1433 return qc->nbytes - min(qc->extrabytes, qc->nbytes);
1433 } 1434 }
1434 1435
1435 static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf) 1436 static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf)
1436 { 1437 {
1437 memset(tf, 0, sizeof(*tf)); 1438 memset(tf, 0, sizeof(*tf));
1438 1439
1439 #ifdef CONFIG_ATA_SFF 1440 #ifdef CONFIG_ATA_SFF
1440 tf->ctl = dev->link->ap->ctl; 1441 tf->ctl = dev->link->ap->ctl;
1441 #else 1442 #else
1442 tf->ctl = ATA_DEVCTL_OBS; 1443 tf->ctl = ATA_DEVCTL_OBS;
1443 #endif 1444 #endif
1444 if (dev->devno == 0) 1445 if (dev->devno == 0)
1445 tf->device = ATA_DEVICE_OBS; 1446 tf->device = ATA_DEVICE_OBS;
1446 else 1447 else
1447 tf->device = ATA_DEVICE_OBS | ATA_DEV1; 1448 tf->device = ATA_DEVICE_OBS | ATA_DEV1;
1448 } 1449 }
1449 1450
1450 static inline void ata_qc_reinit(struct ata_queued_cmd *qc) 1451 static inline void ata_qc_reinit(struct ata_queued_cmd *qc)
1451 { 1452 {
1452 qc->dma_dir = DMA_NONE; 1453 qc->dma_dir = DMA_NONE;
1453 qc->sg = NULL; 1454 qc->sg = NULL;
1454 qc->flags = 0; 1455 qc->flags = 0;
1455 qc->cursg = NULL; 1456 qc->cursg = NULL;
1456 qc->cursg_ofs = 0; 1457 qc->cursg_ofs = 0;
1457 qc->nbytes = qc->extrabytes = qc->curbytes = 0; 1458 qc->nbytes = qc->extrabytes = qc->curbytes = 0;
1458 qc->n_elem = 0; 1459 qc->n_elem = 0;
1459 qc->err_mask = 0; 1460 qc->err_mask = 0;
1460 qc->sect_size = ATA_SECT_SIZE; 1461 qc->sect_size = ATA_SECT_SIZE;
1461 1462
1462 ata_tf_init(qc->dev, &qc->tf); 1463 ata_tf_init(qc->dev, &qc->tf);
1463 1464
1464 /* init result_tf such that it indicates normal completion */ 1465 /* init result_tf such that it indicates normal completion */
1465 qc->result_tf.command = ATA_DRDY; 1466 qc->result_tf.command = ATA_DRDY;
1466 qc->result_tf.feature = 0; 1467 qc->result_tf.feature = 0;
1467 } 1468 }
1468 1469
1469 static inline int ata_try_flush_cache(const struct ata_device *dev) 1470 static inline int ata_try_flush_cache(const struct ata_device *dev)
1470 { 1471 {
1471 return ata_id_wcache_enabled(dev->id) || 1472 return ata_id_wcache_enabled(dev->id) ||
1472 ata_id_has_flush(dev->id) || 1473 ata_id_has_flush(dev->id) ||
1473 ata_id_has_flush_ext(dev->id); 1474 ata_id_has_flush_ext(dev->id);
1474 } 1475 }
1475 1476
1476 static inline unsigned int ac_err_mask(u8 status) 1477 static inline unsigned int ac_err_mask(u8 status)
1477 { 1478 {
1478 if (status & (ATA_BUSY | ATA_DRQ)) 1479 if (status & (ATA_BUSY | ATA_DRQ))
1479 return AC_ERR_HSM; 1480 return AC_ERR_HSM;
1480 if (status & (ATA_ERR | ATA_DF)) 1481 if (status & (ATA_ERR | ATA_DF))
1481 return AC_ERR_DEV; 1482 return AC_ERR_DEV;
1482 return 0; 1483 return 0;
1483 } 1484 }
1484 1485
1485 static inline unsigned int __ac_err_mask(u8 status) 1486 static inline unsigned int __ac_err_mask(u8 status)
1486 { 1487 {
1487 unsigned int mask = ac_err_mask(status); 1488 unsigned int mask = ac_err_mask(status);
1488 if (mask == 0) 1489 if (mask == 0)
1489 return AC_ERR_OTHER; 1490 return AC_ERR_OTHER;
1490 return mask; 1491 return mask;
1491 } 1492 }
1492 1493
1493 static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host) 1494 static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)
1494 { 1495 {
1495 return *(struct ata_port **)&host->hostdata[0]; 1496 return *(struct ata_port **)&host->hostdata[0];
1496 } 1497 }
1497 1498
1498 static inline int ata_check_ready(u8 status) 1499 static inline int ata_check_ready(u8 status)
1499 { 1500 {
1500 if (!(status & ATA_BUSY)) 1501 if (!(status & ATA_BUSY))
1501 return 1; 1502 return 1;
1502 1503
1503 /* 0xff indicates either no device or device not ready */ 1504 /* 0xff indicates either no device or device not ready */
1504 if (status == 0xff) 1505 if (status == 0xff)
1505 return -ENODEV; 1506 return -ENODEV;
1506 1507
1507 return 0; 1508 return 0;
1508 } 1509 }
1509 1510
1510 static inline unsigned long ata_deadline(unsigned long from_jiffies, 1511 static inline unsigned long ata_deadline(unsigned long from_jiffies,
1511 unsigned long timeout_msecs) 1512 unsigned long timeout_msecs)
1512 { 1513 {
1513 return from_jiffies + msecs_to_jiffies(timeout_msecs); 1514 return from_jiffies + msecs_to_jiffies(timeout_msecs);
1514 } 1515 }
1515 1516
1516 /* Don't open code these in drivers as there are traps. Firstly the range may 1517 /* Don't open code these in drivers as there are traps. Firstly the range may
1517 change in future hardware and specs, secondly 0xFF means 'no DMA' but is 1518 change in future hardware and specs, secondly 0xFF means 'no DMA' but is
1518 > UDMA_0. Dyma ddreigiau */ 1519 > UDMA_0. Dyma ddreigiau */
1519 1520
1520 static inline int ata_using_mwdma(struct ata_device *adev) 1521 static inline int ata_using_mwdma(struct ata_device *adev)
1521 { 1522 {
1522 if (adev->dma_mode >= XFER_MW_DMA_0 && adev->dma_mode <= XFER_MW_DMA_4) 1523 if (adev->dma_mode >= XFER_MW_DMA_0 && adev->dma_mode <= XFER_MW_DMA_4)
1523 return 1; 1524 return 1;
1524 return 0; 1525 return 0;
1525 } 1526 }
1526 1527
1527 static inline int ata_using_udma(struct ata_device *adev) 1528 static inline int ata_using_udma(struct ata_device *adev)
1528 { 1529 {
1529 if (adev->dma_mode >= XFER_UDMA_0 && adev->dma_mode <= XFER_UDMA_7) 1530 if (adev->dma_mode >= XFER_UDMA_0 && adev->dma_mode <= XFER_UDMA_7)
1530 return 1; 1531 return 1;
1531 return 0; 1532 return 0;
1532 } 1533 }
1533 1534
1534 static inline int ata_dma_enabled(struct ata_device *adev) 1535 static inline int ata_dma_enabled(struct ata_device *adev)
1535 { 1536 {
1536 return (adev->dma_mode == 0xFF ? 0 : 1); 1537 return (adev->dma_mode == 0xFF ? 0 : 1);
1537 } 1538 }
1538 1539
1539 /************************************************************************** 1540 /**************************************************************************
1540 * PMP - drivers/ata/libata-pmp.c 1541 * PMP - drivers/ata/libata-pmp.c
1541 */ 1542 */
1542 #ifdef CONFIG_SATA_PMP 1543 #ifdef CONFIG_SATA_PMP
1543 1544
1544 extern const struct ata_port_operations sata_pmp_port_ops; 1545 extern const struct ata_port_operations sata_pmp_port_ops;
1545 1546
1546 extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc); 1547 extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc);
1547 extern void sata_pmp_error_handler(struct ata_port *ap); 1548 extern void sata_pmp_error_handler(struct ata_port *ap);
1548 1549
1549 #else /* CONFIG_SATA_PMP */ 1550 #else /* CONFIG_SATA_PMP */
1550 1551
1551 #define sata_pmp_port_ops sata_port_ops 1552 #define sata_pmp_port_ops sata_port_ops
1552 #define sata_pmp_qc_defer_cmd_switch ata_std_qc_defer 1553 #define sata_pmp_qc_defer_cmd_switch ata_std_qc_defer
1553 #define sata_pmp_error_handler ata_std_error_handler 1554 #define sata_pmp_error_handler ata_std_error_handler
1554 1555
1555 #endif /* CONFIG_SATA_PMP */ 1556 #endif /* CONFIG_SATA_PMP */
1556 1557
1557 1558
1558 /************************************************************************** 1559 /**************************************************************************
1559 * SFF - drivers/ata/libata-sff.c 1560 * SFF - drivers/ata/libata-sff.c
1560 */ 1561 */
1561 #ifdef CONFIG_ATA_SFF 1562 #ifdef CONFIG_ATA_SFF
1562 1563
1563 extern const struct ata_port_operations ata_sff_port_ops; 1564 extern const struct ata_port_operations ata_sff_port_ops;
1564 extern const struct ata_port_operations ata_bmdma32_port_ops; 1565 extern const struct ata_port_operations ata_bmdma32_port_ops;
1565 1566
1566 /* PIO only, sg_tablesize and dma_boundary limits can be removed */ 1567 /* PIO only, sg_tablesize and dma_boundary limits can be removed */
1567 #define ATA_PIO_SHT(drv_name) \ 1568 #define ATA_PIO_SHT(drv_name) \
1568 ATA_BASE_SHT(drv_name), \ 1569 ATA_BASE_SHT(drv_name), \
1569 .sg_tablesize = LIBATA_MAX_PRD, \ 1570 .sg_tablesize = LIBATA_MAX_PRD, \
1570 .dma_boundary = ATA_DMA_BOUNDARY 1571 .dma_boundary = ATA_DMA_BOUNDARY
1571 1572
1572 extern void ata_sff_dev_select(struct ata_port *ap, unsigned int device); 1573 extern void ata_sff_dev_select(struct ata_port *ap, unsigned int device);
1573 extern u8 ata_sff_check_status(struct ata_port *ap); 1574 extern u8 ata_sff_check_status(struct ata_port *ap);
1574 extern void ata_sff_pause(struct ata_port *ap); 1575 extern void ata_sff_pause(struct ata_port *ap);
1575 extern void ata_sff_dma_pause(struct ata_port *ap); 1576 extern void ata_sff_dma_pause(struct ata_port *ap);
1576 extern int ata_sff_busy_sleep(struct ata_port *ap, 1577 extern int ata_sff_busy_sleep(struct ata_port *ap,
1577 unsigned long timeout_pat, unsigned long timeout); 1578 unsigned long timeout_pat, unsigned long timeout);
1578 extern int ata_sff_wait_ready(struct ata_link *link, unsigned long deadline); 1579 extern int ata_sff_wait_ready(struct ata_link *link, unsigned long deadline);
1579 extern void ata_sff_tf_load(struct ata_port *ap, const struct ata_taskfile *tf); 1580 extern void ata_sff_tf_load(struct ata_port *ap, const struct ata_taskfile *tf);
1580 extern void ata_sff_tf_read(struct ata_port *ap, struct ata_taskfile *tf); 1581 extern void ata_sff_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
1581 extern void ata_sff_exec_command(struct ata_port *ap, 1582 extern void ata_sff_exec_command(struct ata_port *ap,
1582 const struct ata_taskfile *tf); 1583 const struct ata_taskfile *tf);
1583 extern unsigned int ata_sff_data_xfer(struct ata_device *dev, 1584 extern unsigned int ata_sff_data_xfer(struct ata_device *dev,
1584 unsigned char *buf, unsigned int buflen, int rw); 1585 unsigned char *buf, unsigned int buflen, int rw);
1585 extern unsigned int ata_sff_data_xfer32(struct ata_device *dev, 1586 extern unsigned int ata_sff_data_xfer32(struct ata_device *dev,
1586 unsigned char *buf, unsigned int buflen, int rw); 1587 unsigned char *buf, unsigned int buflen, int rw);
1587 extern unsigned int ata_sff_data_xfer_noirq(struct ata_device *dev, 1588 extern unsigned int ata_sff_data_xfer_noirq(struct ata_device *dev,
1588 unsigned char *buf, unsigned int buflen, int rw); 1589 unsigned char *buf, unsigned int buflen, int rw);
1589 extern void ata_sff_irq_on(struct ata_port *ap); 1590 extern void ata_sff_irq_on(struct ata_port *ap);
1590 extern void ata_sff_irq_clear(struct ata_port *ap); 1591 extern void ata_sff_irq_clear(struct ata_port *ap);
1591 extern int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, 1592 extern int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
1592 u8 status, int in_wq); 1593 u8 status, int in_wq);
1593 extern void ata_sff_queue_pio_task(struct ata_port *ap, unsigned long delay); 1594 extern void ata_sff_queue_pio_task(struct ata_port *ap, unsigned long delay);
1594 extern unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc); 1595 extern unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc);
1595 extern bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc); 1596 extern bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc);
1596 extern unsigned int ata_sff_port_intr(struct ata_port *ap, 1597 extern unsigned int ata_sff_port_intr(struct ata_port *ap,
1597 struct ata_queued_cmd *qc); 1598 struct ata_queued_cmd *qc);
1598 extern irqreturn_t ata_sff_interrupt(int irq, void *dev_instance); 1599 extern irqreturn_t ata_sff_interrupt(int irq, void *dev_instance);
1599 extern void ata_sff_lost_interrupt(struct ata_port *ap); 1600 extern void ata_sff_lost_interrupt(struct ata_port *ap);
1600 extern void ata_sff_freeze(struct ata_port *ap); 1601 extern void ata_sff_freeze(struct ata_port *ap);
1601 extern void ata_sff_thaw(struct ata_port *ap); 1602 extern void ata_sff_thaw(struct ata_port *ap);
1602 extern int ata_sff_prereset(struct ata_link *link, unsigned long deadline); 1603 extern int ata_sff_prereset(struct ata_link *link, unsigned long deadline);
1603 extern unsigned int ata_sff_dev_classify(struct ata_device *dev, int present, 1604 extern unsigned int ata_sff_dev_classify(struct ata_device *dev, int present,
1604 u8 *r_err); 1605 u8 *r_err);
1605 extern int ata_sff_wait_after_reset(struct ata_link *link, unsigned int devmask, 1606 extern int ata_sff_wait_after_reset(struct ata_link *link, unsigned int devmask,
1606 unsigned long deadline); 1607 unsigned long deadline);
1607 extern int ata_sff_softreset(struct ata_link *link, unsigned int *classes, 1608 extern int ata_sff_softreset(struct ata_link *link, unsigned int *classes,
1608 unsigned long deadline); 1609 unsigned long deadline);
1609 extern int sata_sff_hardreset(struct ata_link *link, unsigned int *class, 1610 extern int sata_sff_hardreset(struct ata_link *link, unsigned int *class,
1610 unsigned long deadline); 1611 unsigned long deadline);
1611 extern void ata_sff_postreset(struct ata_link *link, unsigned int *classes); 1612 extern void ata_sff_postreset(struct ata_link *link, unsigned int *classes);
1612 extern void ata_sff_drain_fifo(struct ata_queued_cmd *qc); 1613 extern void ata_sff_drain_fifo(struct ata_queued_cmd *qc);
1613 extern void ata_sff_error_handler(struct ata_port *ap); 1614 extern void ata_sff_error_handler(struct ata_port *ap);
1614 extern void ata_sff_std_ports(struct ata_ioports *ioaddr); 1615 extern void ata_sff_std_ports(struct ata_ioports *ioaddr);
1615 #ifdef CONFIG_PCI 1616 #ifdef CONFIG_PCI
1616 extern int ata_pci_sff_init_host(struct ata_host *host); 1617 extern int ata_pci_sff_init_host(struct ata_host *host);
1617 extern int ata_pci_sff_prepare_host(struct pci_dev *pdev, 1618 extern int ata_pci_sff_prepare_host(struct pci_dev *pdev,
1618 const struct ata_port_info * const * ppi, 1619 const struct ata_port_info * const * ppi,
1619 struct ata_host **r_host); 1620 struct ata_host **r_host);
1620 extern int ata_pci_sff_activate_host(struct ata_host *host, 1621 extern int ata_pci_sff_activate_host(struct ata_host *host,
1621 irq_handler_t irq_handler, 1622 irq_handler_t irq_handler,
1622 struct scsi_host_template *sht); 1623 struct scsi_host_template *sht);
1623 extern int ata_pci_sff_init_one(struct pci_dev *pdev, 1624 extern int ata_pci_sff_init_one(struct pci_dev *pdev,
1624 const struct ata_port_info * const * ppi, 1625 const struct ata_port_info * const * ppi,
1625 struct scsi_host_template *sht, void *host_priv, int hflags); 1626 struct scsi_host_template *sht, void *host_priv, int hflags);
1626 #endif /* CONFIG_PCI */ 1627 #endif /* CONFIG_PCI */
1627 1628
1628 #ifdef CONFIG_ATA_BMDMA 1629 #ifdef CONFIG_ATA_BMDMA
1629 1630
1630 extern const struct ata_port_operations ata_bmdma_port_ops; 1631 extern const struct ata_port_operations ata_bmdma_port_ops;
1631 1632
1632 #define ATA_BMDMA_SHT(drv_name) \ 1633 #define ATA_BMDMA_SHT(drv_name) \
1633 ATA_BASE_SHT(drv_name), \ 1634 ATA_BASE_SHT(drv_name), \
1634 .sg_tablesize = LIBATA_MAX_PRD, \ 1635 .sg_tablesize = LIBATA_MAX_PRD, \
1635 .dma_boundary = ATA_DMA_BOUNDARY 1636 .dma_boundary = ATA_DMA_BOUNDARY
1636 1637
1637 extern void ata_bmdma_qc_prep(struct ata_queued_cmd *qc); 1638 extern void ata_bmdma_qc_prep(struct ata_queued_cmd *qc);
1638 extern unsigned int ata_bmdma_qc_issue(struct ata_queued_cmd *qc); 1639 extern unsigned int ata_bmdma_qc_issue(struct ata_queued_cmd *qc);
1639 extern void ata_bmdma_dumb_qc_prep(struct ata_queued_cmd *qc); 1640 extern void ata_bmdma_dumb_qc_prep(struct ata_queued_cmd *qc);
1640 extern unsigned int ata_bmdma_port_intr(struct ata_port *ap, 1641 extern unsigned int ata_bmdma_port_intr(struct ata_port *ap,
1641 struct ata_queued_cmd *qc); 1642 struct ata_queued_cmd *qc);
1642 extern irqreturn_t ata_bmdma_interrupt(int irq, void *dev_instance); 1643 extern irqreturn_t ata_bmdma_interrupt(int irq, void *dev_instance);
1643 extern void ata_bmdma_error_handler(struct ata_port *ap); 1644 extern void ata_bmdma_error_handler(struct ata_port *ap);
1644 extern void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc); 1645 extern void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc);
1645 extern void ata_bmdma_irq_clear(struct ata_port *ap); 1646 extern void ata_bmdma_irq_clear(struct ata_port *ap);
1646 extern void ata_bmdma_setup(struct ata_queued_cmd *qc); 1647 extern void ata_bmdma_setup(struct ata_queued_cmd *qc);
1647 extern void ata_bmdma_start(struct ata_queued_cmd *qc); 1648 extern void ata_bmdma_start(struct ata_queued_cmd *qc);
1648 extern void ata_bmdma_stop(struct ata_queued_cmd *qc); 1649 extern void ata_bmdma_stop(struct ata_queued_cmd *qc);
1649 extern u8 ata_bmdma_status(struct ata_port *ap); 1650 extern u8 ata_bmdma_status(struct ata_port *ap);
1650 extern int ata_bmdma_port_start(struct ata_port *ap); 1651 extern int ata_bmdma_port_start(struct ata_port *ap);
1651 extern int ata_bmdma_port_start32(struct ata_port *ap); 1652 extern int ata_bmdma_port_start32(struct ata_port *ap);
1652 1653
1653 #ifdef CONFIG_PCI 1654 #ifdef CONFIG_PCI
1654 extern int ata_pci_bmdma_clear_simplex(struct pci_dev *pdev); 1655 extern int ata_pci_bmdma_clear_simplex(struct pci_dev *pdev);
1655 extern void ata_pci_bmdma_init(struct ata_host *host); 1656 extern void ata_pci_bmdma_init(struct ata_host *host);
1656 extern int ata_pci_bmdma_prepare_host(struct pci_dev *pdev, 1657 extern int ata_pci_bmdma_prepare_host(struct pci_dev *pdev,
1657 const struct ata_port_info * const * ppi, 1658 const struct ata_port_info * const * ppi,
1658 struct ata_host **r_host); 1659 struct ata_host **r_host);
1659 extern int ata_pci_bmdma_init_one(struct pci_dev *pdev, 1660 extern int ata_pci_bmdma_init_one(struct pci_dev *pdev,
1660 const struct ata_port_info * const * ppi, 1661 const struct ata_port_info * const * ppi,
1661 struct scsi_host_template *sht, 1662 struct scsi_host_template *sht,
1662 void *host_priv, int hflags); 1663 void *host_priv, int hflags);
1663 #endif /* CONFIG_PCI */ 1664 #endif /* CONFIG_PCI */
1664 #endif /* CONFIG_ATA_BMDMA */ 1665 #endif /* CONFIG_ATA_BMDMA */
1665 1666
1666 /** 1667 /**
1667 * ata_sff_busy_wait - Wait for a port status register 1668 * ata_sff_busy_wait - Wait for a port status register
1668 * @ap: Port to wait for. 1669 * @ap: Port to wait for.
1669 * @bits: bits that must be clear 1670 * @bits: bits that must be clear
1670 * @max: number of 10uS waits to perform 1671 * @max: number of 10uS waits to perform
1671 * 1672 *
1672 * Waits up to max*10 microseconds for the selected bits in the port's 1673 * Waits up to max*10 microseconds for the selected bits in the port's
1673 * status register to be cleared. 1674 * status register to be cleared.
1674 * Returns final value of status register. 1675 * Returns final value of status register.
1675 * 1676 *
1676 * LOCKING: 1677 * LOCKING:
1677 * Inherited from caller. 1678 * Inherited from caller.
1678 */ 1679 */
1679 static inline u8 ata_sff_busy_wait(struct ata_port *ap, unsigned int bits, 1680 static inline u8 ata_sff_busy_wait(struct ata_port *ap, unsigned int bits,
1680 unsigned int max) 1681 unsigned int max)
1681 { 1682 {
1682 u8 status; 1683 u8 status;
1683 1684
1684 do { 1685 do {
1685 udelay(10); 1686 udelay(10);
1686 status = ap->ops->sff_check_status(ap); 1687 status = ap->ops->sff_check_status(ap);
1687 max--; 1688 max--;
1688 } while (status != 0xff && (status & bits) && (max > 0)); 1689 } while (status != 0xff && (status & bits) && (max > 0));
1689 1690
1690 return status; 1691 return status;
1691 } 1692 }
1692 1693
1693 /** 1694 /**
1694 * ata_wait_idle - Wait for a port to be idle. 1695 * ata_wait_idle - Wait for a port to be idle.
1695 * @ap: Port to wait for. 1696 * @ap: Port to wait for.
1696 * 1697 *
1697 * Waits up to 10ms for port's BUSY and DRQ signals to clear. 1698 * Waits up to 10ms for port's BUSY and DRQ signals to clear.
1698 * Returns final value of status register. 1699 * Returns final value of status register.
1699 * 1700 *
1700 * LOCKING: 1701 * LOCKING:
1701 * Inherited from caller. 1702 * Inherited from caller.
1702 */ 1703 */
1703 static inline u8 ata_wait_idle(struct ata_port *ap) 1704 static inline u8 ata_wait_idle(struct ata_port *ap)
1704 { 1705 {
1705 u8 status = ata_sff_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); 1706 u8 status = ata_sff_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
1706 1707
1707 #ifdef ATA_DEBUG 1708 #ifdef ATA_DEBUG
1708 if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ))) 1709 if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ)))
1709 ata_port_printk(ap, KERN_DEBUG, "abnormal Status 0x%X\n", 1710 ata_port_printk(ap, KERN_DEBUG, "abnormal Status 0x%X\n",
1710 status); 1711 status);
1711 #endif 1712 #endif
1712 1713
1713 return status; 1714 return status;
1714 } 1715 }
1715 #endif /* CONFIG_ATA_SFF */ 1716 #endif /* CONFIG_ATA_SFF */
1716 1717
1717 #endif /* __LINUX_LIBATA_H__ */ 1718 #endif /* __LINUX_LIBATA_H__ */
1718 1719