/drivers/scsi/ipr.c
C | 9237 lines | 5898 code | 1206 blank | 2133 comment | 861 complexity | a3660cded51ae2342d2ce8c903ee1110 MD5 | raw file
Possible License(s): LGPL-2.0, AGPL-1.0, GPL-2.0
Large files files are truncated, but you can click here to view the full file
1/* 2 * ipr.c -- driver for IBM Power Linux RAID adapters 3 * 4 * Written By: Brian King <brking@us.ibm.com>, IBM Corporation 5 * 6 * Copyright (C) 2003, 2004 IBM Corporation 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * 22 */ 23 24/* 25 * Notes: 26 * 27 * This driver is used to control the following SCSI adapters: 28 * 29 * IBM iSeries: 5702, 5703, 2780, 5709, 570A, 570B 30 * 31 * IBM pSeries: PCI-X Dual Channel Ultra 320 SCSI RAID Adapter 32 * PCI-X Dual Channel Ultra 320 SCSI Adapter 33 * PCI-X Dual Channel Ultra 320 SCSI RAID Enablement Card 34 * Embedded SCSI adapter on p615 and p655 systems 35 * 36 * Supported Hardware Features: 37 * - Ultra 320 SCSI controller 38 * - PCI-X host interface 39 * - Embedded PowerPC RISC Processor and Hardware XOR DMA Engine 40 * - Non-Volatile Write Cache 41 * - Supports attachment of non-RAID disks, tape, and optical devices 42 * - RAID Levels 0, 5, 10 43 * - Hot spare 44 * - Background Parity Checking 45 * - Background Data Scrubbing 46 * - Ability to increase the capacity of an existing RAID 5 disk array 47 * by adding disks 48 * 49 * Driver Features: 50 * - Tagged command queuing 51 * - Adapter microcode download 52 * - PCI hot plug 53 * - SCSI device hot plug 54 * 55 */ 56 57#include <linux/fs.h> 58#include <linux/init.h> 59#include <linux/types.h> 60#include <linux/errno.h> 61#include <linux/kernel.h> 62#include <linux/slab.h> 63#include <linux/vmalloc.h> 64#include <linux/ioport.h> 65#include <linux/delay.h> 66#include <linux/pci.h> 67#include <linux/wait.h> 68#include <linux/spinlock.h> 69#include <linux/sched.h> 70#include <linux/interrupt.h> 71#include <linux/blkdev.h> 72#include <linux/firmware.h> 73#include <linux/module.h> 74#include <linux/moduleparam.h> 75#include <linux/libata.h> 76#include <linux/hdreg.h> 77#include <linux/reboot.h> 78#include <linux/stringify.h> 79#include <asm/io.h> 80#include <asm/irq.h> 81#include <asm/processor.h> 82#include <scsi/scsi.h> 83#include <scsi/scsi_host.h> 84#include <scsi/scsi_tcq.h> 85#include <scsi/scsi_eh.h> 86#include <scsi/scsi_cmnd.h> 87#include "ipr.h" 88 89/* 90 * Global Data 91 */ 92static LIST_HEAD(ipr_ioa_head); 93static unsigned int ipr_log_level = IPR_DEFAULT_LOG_LEVEL; 94static unsigned int ipr_max_speed = 1; 95static int ipr_testmode = 0; 96static unsigned int ipr_fastfail = 0; 97static unsigned int ipr_transop_timeout = 0; 98static unsigned int ipr_debug = 0; 99static unsigned int ipr_max_devs = IPR_DEFAULT_SIS64_DEVS; 100static unsigned int ipr_dual_ioa_raid = 1; 101static DEFINE_SPINLOCK(ipr_driver_lock); 102 103/* This table describes the differences between DMA controller chips */ 104static const struct ipr_chip_cfg_t ipr_chip_cfg[] = { 105 { /* Gemstone, Citrine, Obsidian, and Obsidian-E */ 106 .mailbox = 0x0042C, 107 .cache_line_size = 0x20, 108 { 109 .set_interrupt_mask_reg = 0x0022C, 110 .clr_interrupt_mask_reg = 0x00230, 111 .clr_interrupt_mask_reg32 = 0x00230, 112 .sense_interrupt_mask_reg = 0x0022C, 113 .sense_interrupt_mask_reg32 = 0x0022C, 114 .clr_interrupt_reg = 0x00228, 115 .clr_interrupt_reg32 = 0x00228, 116 .sense_interrupt_reg = 0x00224, 117 .sense_interrupt_reg32 = 0x00224, 118 .ioarrin_reg = 0x00404, 119 .sense_uproc_interrupt_reg = 0x00214, 120 .sense_uproc_interrupt_reg32 = 0x00214, 121 .set_uproc_interrupt_reg = 0x00214, 122 .set_uproc_interrupt_reg32 = 0x00214, 123 .clr_uproc_interrupt_reg = 0x00218, 124 .clr_uproc_interrupt_reg32 = 0x00218 125 } 126 }, 127 { /* Snipe and Scamp */ 128 .mailbox = 0x0052C, 129 .cache_line_size = 0x20, 130 { 131 .set_interrupt_mask_reg = 0x00288, 132 .clr_interrupt_mask_reg = 0x0028C, 133 .clr_interrupt_mask_reg32 = 0x0028C, 134 .sense_interrupt_mask_reg = 0x00288, 135 .sense_interrupt_mask_reg32 = 0x00288, 136 .clr_interrupt_reg = 0x00284, 137 .clr_interrupt_reg32 = 0x00284, 138 .sense_interrupt_reg = 0x00280, 139 .sense_interrupt_reg32 = 0x00280, 140 .ioarrin_reg = 0x00504, 141 .sense_uproc_interrupt_reg = 0x00290, 142 .sense_uproc_interrupt_reg32 = 0x00290, 143 .set_uproc_interrupt_reg = 0x00290, 144 .set_uproc_interrupt_reg32 = 0x00290, 145 .clr_uproc_interrupt_reg = 0x00294, 146 .clr_uproc_interrupt_reg32 = 0x00294 147 } 148 }, 149 { /* CRoC */ 150 .mailbox = 0x00044, 151 .cache_line_size = 0x20, 152 { 153 .set_interrupt_mask_reg = 0x00010, 154 .clr_interrupt_mask_reg = 0x00018, 155 .clr_interrupt_mask_reg32 = 0x0001C, 156 .sense_interrupt_mask_reg = 0x00010, 157 .sense_interrupt_mask_reg32 = 0x00014, 158 .clr_interrupt_reg = 0x00008, 159 .clr_interrupt_reg32 = 0x0000C, 160 .sense_interrupt_reg = 0x00000, 161 .sense_interrupt_reg32 = 0x00004, 162 .ioarrin_reg = 0x00070, 163 .sense_uproc_interrupt_reg = 0x00020, 164 .sense_uproc_interrupt_reg32 = 0x00024, 165 .set_uproc_interrupt_reg = 0x00020, 166 .set_uproc_interrupt_reg32 = 0x00024, 167 .clr_uproc_interrupt_reg = 0x00028, 168 .clr_uproc_interrupt_reg32 = 0x0002C, 169 .init_feedback_reg = 0x0005C, 170 .dump_addr_reg = 0x00064, 171 .dump_data_reg = 0x00068, 172 .endian_swap_reg = 0x00084 173 } 174 }, 175}; 176 177static const struct ipr_chip_t ipr_chip[] = { 178 { PCI_VENDOR_ID_MYLEX, PCI_DEVICE_ID_IBM_GEMSTONE, IPR_USE_LSI, IPR_SIS32, IPR_PCI_CFG, &ipr_chip_cfg[0] }, 179 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, IPR_USE_LSI, IPR_SIS32, IPR_PCI_CFG, &ipr_chip_cfg[0] }, 180 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, IPR_USE_LSI, IPR_SIS32, IPR_PCI_CFG, &ipr_chip_cfg[0] }, 181 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, IPR_USE_LSI, IPR_SIS32, IPR_PCI_CFG, &ipr_chip_cfg[0] }, 182 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, IPR_USE_MSI, IPR_SIS32, IPR_PCI_CFG, &ipr_chip_cfg[0] }, 183 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, IPR_USE_LSI, IPR_SIS32, IPR_PCI_CFG, &ipr_chip_cfg[1] }, 184 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, IPR_USE_LSI, IPR_SIS32, IPR_PCI_CFG, &ipr_chip_cfg[1] }, 185 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_FPGA_E2, IPR_USE_MSI, IPR_SIS64, IPR_MMIO, &ipr_chip_cfg[2] }, 186 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_ASIC_E2, IPR_USE_MSI, IPR_SIS64, IPR_MMIO, &ipr_chip_cfg[2] } 187}; 188 189static int ipr_max_bus_speeds [] = { 190 IPR_80MBs_SCSI_RATE, IPR_U160_SCSI_RATE, IPR_U320_SCSI_RATE 191}; 192 193MODULE_AUTHOR("Brian King <brking@us.ibm.com>"); 194MODULE_DESCRIPTION("IBM Power RAID SCSI Adapter Driver"); 195module_param_named(max_speed, ipr_max_speed, uint, 0); 196MODULE_PARM_DESC(max_speed, "Maximum bus speed (0-2). Default: 1=U160. Speeds: 0=80 MB/s, 1=U160, 2=U320"); 197module_param_named(log_level, ipr_log_level, uint, 0); 198MODULE_PARM_DESC(log_level, "Set to 0 - 4 for increasing verbosity of device driver"); 199module_param_named(testmode, ipr_testmode, int, 0); 200MODULE_PARM_DESC(testmode, "DANGEROUS!!! Allows unsupported configurations"); 201module_param_named(fastfail, ipr_fastfail, int, S_IRUGO | S_IWUSR); 202MODULE_PARM_DESC(fastfail, "Reduce timeouts and retries"); 203module_param_named(transop_timeout, ipr_transop_timeout, int, 0); 204MODULE_PARM_DESC(transop_timeout, "Time in seconds to wait for adapter to come operational (default: 300)"); 205module_param_named(debug, ipr_debug, int, S_IRUGO | S_IWUSR); 206MODULE_PARM_DESC(debug, "Enable device driver debugging logging. Set to 1 to enable. (default: 0)"); 207module_param_named(dual_ioa_raid, ipr_dual_ioa_raid, int, 0); 208MODULE_PARM_DESC(dual_ioa_raid, "Enable dual adapter RAID support. Set to 1 to enable. (default: 1)"); 209module_param_named(max_devs, ipr_max_devs, int, 0); 210MODULE_PARM_DESC(max_devs, "Specify the maximum number of physical devices. " 211 "[Default=" __stringify(IPR_DEFAULT_SIS64_DEVS) "]"); 212MODULE_LICENSE("GPL"); 213MODULE_VERSION(IPR_DRIVER_VERSION); 214 215/* A constant array of IOASCs/URCs/Error Messages */ 216static const 217struct ipr_error_table_t ipr_error_table[] = { 218 {0x00000000, 1, IPR_DEFAULT_LOG_LEVEL, 219 "8155: An unknown error was received"}, 220 {0x00330000, 0, 0, 221 "Soft underlength error"}, 222 {0x005A0000, 0, 0, 223 "Command to be cancelled not found"}, 224 {0x00808000, 0, 0, 225 "Qualified success"}, 226 {0x01080000, 1, IPR_DEFAULT_LOG_LEVEL, 227 "FFFE: Soft device bus error recovered by the IOA"}, 228 {0x01088100, 0, IPR_DEFAULT_LOG_LEVEL, 229 "4101: Soft device bus fabric error"}, 230 {0x01100100, 0, IPR_DEFAULT_LOG_LEVEL, 231 "FFFC: Logical block guard error recovered by the device"}, 232 {0x01100300, 0, IPR_DEFAULT_LOG_LEVEL, 233 "FFFC: Logical block reference tag error recovered by the device"}, 234 {0x01108300, 0, IPR_DEFAULT_LOG_LEVEL, 235 "4171: Recovered scatter list tag / sequence number error"}, 236 {0x01109000, 0, IPR_DEFAULT_LOG_LEVEL, 237 "FF3D: Recovered logical block CRC error on IOA to Host transfer"}, 238 {0x01109200, 0, IPR_DEFAULT_LOG_LEVEL, 239 "4171: Recovered logical block sequence number error on IOA to Host transfer"}, 240 {0x0110A000, 0, IPR_DEFAULT_LOG_LEVEL, 241 "FFFD: Recovered logical block reference tag error detected by the IOA"}, 242 {0x0110A100, 0, IPR_DEFAULT_LOG_LEVEL, 243 "FFFD: Logical block guard error recovered by the IOA"}, 244 {0x01170600, 0, IPR_DEFAULT_LOG_LEVEL, 245 "FFF9: Device sector reassign successful"}, 246 {0x01170900, 0, IPR_DEFAULT_LOG_LEVEL, 247 "FFF7: Media error recovered by device rewrite procedures"}, 248 {0x01180200, 0, IPR_DEFAULT_LOG_LEVEL, 249 "7001: IOA sector reassignment successful"}, 250 {0x01180500, 0, IPR_DEFAULT_LOG_LEVEL, 251 "FFF9: Soft media error. Sector reassignment recommended"}, 252 {0x01180600, 0, IPR_DEFAULT_LOG_LEVEL, 253 "FFF7: Media error recovered by IOA rewrite procedures"}, 254 {0x01418000, 0, IPR_DEFAULT_LOG_LEVEL, 255 "FF3D: Soft PCI bus error recovered by the IOA"}, 256 {0x01440000, 1, IPR_DEFAULT_LOG_LEVEL, 257 "FFF6: Device hardware error recovered by the IOA"}, 258 {0x01448100, 0, IPR_DEFAULT_LOG_LEVEL, 259 "FFF6: Device hardware error recovered by the device"}, 260 {0x01448200, 1, IPR_DEFAULT_LOG_LEVEL, 261 "FF3D: Soft IOA error recovered by the IOA"}, 262 {0x01448300, 0, IPR_DEFAULT_LOG_LEVEL, 263 "FFFA: Undefined device response recovered by the IOA"}, 264 {0x014A0000, 1, IPR_DEFAULT_LOG_LEVEL, 265 "FFF6: Device bus error, message or command phase"}, 266 {0x014A8000, 0, IPR_DEFAULT_LOG_LEVEL, 267 "FFFE: Task Management Function failed"}, 268 {0x015D0000, 0, IPR_DEFAULT_LOG_LEVEL, 269 "FFF6: Failure prediction threshold exceeded"}, 270 {0x015D9200, 0, IPR_DEFAULT_LOG_LEVEL, 271 "8009: Impending cache battery pack failure"}, 272 {0x02040400, 0, 0, 273 "34FF: Disk device format in progress"}, 274 {0x02048000, 0, IPR_DEFAULT_LOG_LEVEL, 275 "9070: IOA requested reset"}, 276 {0x023F0000, 0, 0, 277 "Synchronization required"}, 278 {0x024E0000, 0, 0, 279 "No ready, IOA shutdown"}, 280 {0x025A0000, 0, 0, 281 "Not ready, IOA has been shutdown"}, 282 {0x02670100, 0, IPR_DEFAULT_LOG_LEVEL, 283 "3020: Storage subsystem configuration error"}, 284 {0x03110B00, 0, 0, 285 "FFF5: Medium error, data unreadable, recommend reassign"}, 286 {0x03110C00, 0, 0, 287 "7000: Medium error, data unreadable, do not reassign"}, 288 {0x03310000, 0, IPR_DEFAULT_LOG_LEVEL, 289 "FFF3: Disk media format bad"}, 290 {0x04050000, 0, IPR_DEFAULT_LOG_LEVEL, 291 "3002: Addressed device failed to respond to selection"}, 292 {0x04080000, 1, IPR_DEFAULT_LOG_LEVEL, 293 "3100: Device bus error"}, 294 {0x04080100, 0, IPR_DEFAULT_LOG_LEVEL, 295 "3109: IOA timed out a device command"}, 296 {0x04088000, 0, 0, 297 "3120: SCSI bus is not operational"}, 298 {0x04088100, 0, IPR_DEFAULT_LOG_LEVEL, 299 "4100: Hard device bus fabric error"}, 300 {0x04100100, 0, IPR_DEFAULT_LOG_LEVEL, 301 "310C: Logical block guard error detected by the device"}, 302 {0x04100300, 0, IPR_DEFAULT_LOG_LEVEL, 303 "310C: Logical block reference tag error detected by the device"}, 304 {0x04108300, 1, IPR_DEFAULT_LOG_LEVEL, 305 "4170: Scatter list tag / sequence number error"}, 306 {0x04109000, 1, IPR_DEFAULT_LOG_LEVEL, 307 "8150: Logical block CRC error on IOA to Host transfer"}, 308 {0x04109200, 1, IPR_DEFAULT_LOG_LEVEL, 309 "4170: Logical block sequence number error on IOA to Host transfer"}, 310 {0x0410A000, 0, IPR_DEFAULT_LOG_LEVEL, 311 "310D: Logical block reference tag error detected by the IOA"}, 312 {0x0410A100, 0, IPR_DEFAULT_LOG_LEVEL, 313 "310D: Logical block guard error detected by the IOA"}, 314 {0x04118000, 0, IPR_DEFAULT_LOG_LEVEL, 315 "9000: IOA reserved area data check"}, 316 {0x04118100, 0, IPR_DEFAULT_LOG_LEVEL, 317 "9001: IOA reserved area invalid data pattern"}, 318 {0x04118200, 0, IPR_DEFAULT_LOG_LEVEL, 319 "9002: IOA reserved area LRC error"}, 320 {0x04118300, 1, IPR_DEFAULT_LOG_LEVEL, 321 "Hardware Error, IOA metadata access error"}, 322 {0x04320000, 0, IPR_DEFAULT_LOG_LEVEL, 323 "102E: Out of alternate sectors for disk storage"}, 324 {0x04330000, 1, IPR_DEFAULT_LOG_LEVEL, 325 "FFF4: Data transfer underlength error"}, 326 {0x04338000, 1, IPR_DEFAULT_LOG_LEVEL, 327 "FFF4: Data transfer overlength error"}, 328 {0x043E0100, 0, IPR_DEFAULT_LOG_LEVEL, 329 "3400: Logical unit failure"}, 330 {0x04408500, 0, IPR_DEFAULT_LOG_LEVEL, 331 "FFF4: Device microcode is corrupt"}, 332 {0x04418000, 1, IPR_DEFAULT_LOG_LEVEL, 333 "8150: PCI bus error"}, 334 {0x04430000, 1, 0, 335 "Unsupported device bus message received"}, 336 {0x04440000, 1, IPR_DEFAULT_LOG_LEVEL, 337 "FFF4: Disk device problem"}, 338 {0x04448200, 1, IPR_DEFAULT_LOG_LEVEL, 339 "8150: Permanent IOA failure"}, 340 {0x04448300, 0, IPR_DEFAULT_LOG_LEVEL, 341 "3010: Disk device returned wrong response to IOA"}, 342 {0x04448400, 0, IPR_DEFAULT_LOG_LEVEL, 343 "8151: IOA microcode error"}, 344 {0x04448500, 0, 0, 345 "Device bus status error"}, 346 {0x04448600, 0, IPR_DEFAULT_LOG_LEVEL, 347 "8157: IOA error requiring IOA reset to recover"}, 348 {0x04448700, 0, 0, 349 "ATA device status error"}, 350 {0x04490000, 0, 0, 351 "Message reject received from the device"}, 352 {0x04449200, 0, IPR_DEFAULT_LOG_LEVEL, 353 "8008: A permanent cache battery pack failure occurred"}, 354 {0x0444A000, 0, IPR_DEFAULT_LOG_LEVEL, 355 "9090: Disk unit has been modified after the last known status"}, 356 {0x0444A200, 0, IPR_DEFAULT_LOG_LEVEL, 357 "9081: IOA detected device error"}, 358 {0x0444A300, 0, IPR_DEFAULT_LOG_LEVEL, 359 "9082: IOA detected device error"}, 360 {0x044A0000, 1, IPR_DEFAULT_LOG_LEVEL, 361 "3110: Device bus error, message or command phase"}, 362 {0x044A8000, 1, IPR_DEFAULT_LOG_LEVEL, 363 "3110: SAS Command / Task Management Function failed"}, 364 {0x04670400, 0, IPR_DEFAULT_LOG_LEVEL, 365 "9091: Incorrect hardware configuration change has been detected"}, 366 {0x04678000, 0, IPR_DEFAULT_LOG_LEVEL, 367 "9073: Invalid multi-adapter configuration"}, 368 {0x04678100, 0, IPR_DEFAULT_LOG_LEVEL, 369 "4010: Incorrect connection between cascaded expanders"}, 370 {0x04678200, 0, IPR_DEFAULT_LOG_LEVEL, 371 "4020: Connections exceed IOA design limits"}, 372 {0x04678300, 0, IPR_DEFAULT_LOG_LEVEL, 373 "4030: Incorrect multipath connection"}, 374 {0x04679000, 0, IPR_DEFAULT_LOG_LEVEL, 375 "4110: Unsupported enclosure function"}, 376 {0x046E0000, 0, IPR_DEFAULT_LOG_LEVEL, 377 "FFF4: Command to logical unit failed"}, 378 {0x05240000, 1, 0, 379 "Illegal request, invalid request type or request packet"}, 380 {0x05250000, 0, 0, 381 "Illegal request, invalid resource handle"}, 382 {0x05258000, 0, 0, 383 "Illegal request, commands not allowed to this device"}, 384 {0x05258100, 0, 0, 385 "Illegal request, command not allowed to a secondary adapter"}, 386 {0x05258200, 0, 0, 387 "Illegal request, command not allowed to a non-optimized resource"}, 388 {0x05260000, 0, 0, 389 "Illegal request, invalid field in parameter list"}, 390 {0x05260100, 0, 0, 391 "Illegal request, parameter not supported"}, 392 {0x05260200, 0, 0, 393 "Illegal request, parameter value invalid"}, 394 {0x052C0000, 0, 0, 395 "Illegal request, command sequence error"}, 396 {0x052C8000, 1, 0, 397 "Illegal request, dual adapter support not enabled"}, 398 {0x06040500, 0, IPR_DEFAULT_LOG_LEVEL, 399 "9031: Array protection temporarily suspended, protection resuming"}, 400 {0x06040600, 0, IPR_DEFAULT_LOG_LEVEL, 401 "9040: Array protection temporarily suspended, protection resuming"}, 402 {0x06288000, 0, IPR_DEFAULT_LOG_LEVEL, 403 "3140: Device bus not ready to ready transition"}, 404 {0x06290000, 0, IPR_DEFAULT_LOG_LEVEL, 405 "FFFB: SCSI bus was reset"}, 406 {0x06290500, 0, 0, 407 "FFFE: SCSI bus transition to single ended"}, 408 {0x06290600, 0, 0, 409 "FFFE: SCSI bus transition to LVD"}, 410 {0x06298000, 0, IPR_DEFAULT_LOG_LEVEL, 411 "FFFB: SCSI bus was reset by another initiator"}, 412 {0x063F0300, 0, IPR_DEFAULT_LOG_LEVEL, 413 "3029: A device replacement has occurred"}, 414 {0x064C8000, 0, IPR_DEFAULT_LOG_LEVEL, 415 "9051: IOA cache data exists for a missing or failed device"}, 416 {0x064C8100, 0, IPR_DEFAULT_LOG_LEVEL, 417 "9055: Auxiliary cache IOA contains cache data needed by the primary IOA"}, 418 {0x06670100, 0, IPR_DEFAULT_LOG_LEVEL, 419 "9025: Disk unit is not supported at its physical location"}, 420 {0x06670600, 0, IPR_DEFAULT_LOG_LEVEL, 421 "3020: IOA detected a SCSI bus configuration error"}, 422 {0x06678000, 0, IPR_DEFAULT_LOG_LEVEL, 423 "3150: SCSI bus configuration error"}, 424 {0x06678100, 0, IPR_DEFAULT_LOG_LEVEL, 425 "9074: Asymmetric advanced function disk configuration"}, 426 {0x06678300, 0, IPR_DEFAULT_LOG_LEVEL, 427 "4040: Incomplete multipath connection between IOA and enclosure"}, 428 {0x06678400, 0, IPR_DEFAULT_LOG_LEVEL, 429 "4041: Incomplete multipath connection between enclosure and device"}, 430 {0x06678500, 0, IPR_DEFAULT_LOG_LEVEL, 431 "9075: Incomplete multipath connection between IOA and remote IOA"}, 432 {0x06678600, 0, IPR_DEFAULT_LOG_LEVEL, 433 "9076: Configuration error, missing remote IOA"}, 434 {0x06679100, 0, IPR_DEFAULT_LOG_LEVEL, 435 "4050: Enclosure does not support a required multipath function"}, 436 {0x06690000, 0, IPR_DEFAULT_LOG_LEVEL, 437 "4070: Logically bad block written on device"}, 438 {0x06690200, 0, IPR_DEFAULT_LOG_LEVEL, 439 "9041: Array protection temporarily suspended"}, 440 {0x06698200, 0, IPR_DEFAULT_LOG_LEVEL, 441 "9042: Corrupt array parity detected on specified device"}, 442 {0x066B0200, 0, IPR_DEFAULT_LOG_LEVEL, 443 "9030: Array no longer protected due to missing or failed disk unit"}, 444 {0x066B8000, 0, IPR_DEFAULT_LOG_LEVEL, 445 "9071: Link operational transition"}, 446 {0x066B8100, 0, IPR_DEFAULT_LOG_LEVEL, 447 "9072: Link not operational transition"}, 448 {0x066B8200, 0, IPR_DEFAULT_LOG_LEVEL, 449 "9032: Array exposed but still protected"}, 450 {0x066B8300, 0, IPR_DEFAULT_LOG_LEVEL + 1, 451 "70DD: Device forced failed by disrupt device command"}, 452 {0x066B9100, 0, IPR_DEFAULT_LOG_LEVEL, 453 "4061: Multipath redundancy level got better"}, 454 {0x066B9200, 0, IPR_DEFAULT_LOG_LEVEL, 455 "4060: Multipath redundancy level got worse"}, 456 {0x07270000, 0, 0, 457 "Failure due to other device"}, 458 {0x07278000, 0, IPR_DEFAULT_LOG_LEVEL, 459 "9008: IOA does not support functions expected by devices"}, 460 {0x07278100, 0, IPR_DEFAULT_LOG_LEVEL, 461 "9010: Cache data associated with attached devices cannot be found"}, 462 {0x07278200, 0, IPR_DEFAULT_LOG_LEVEL, 463 "9011: Cache data belongs to devices other than those attached"}, 464 {0x07278400, 0, IPR_DEFAULT_LOG_LEVEL, 465 "9020: Array missing 2 or more devices with only 1 device present"}, 466 {0x07278500, 0, IPR_DEFAULT_LOG_LEVEL, 467 "9021: Array missing 2 or more devices with 2 or more devices present"}, 468 {0x07278600, 0, IPR_DEFAULT_LOG_LEVEL, 469 "9022: Exposed array is missing a required device"}, 470 {0x07278700, 0, IPR_DEFAULT_LOG_LEVEL, 471 "9023: Array member(s) not at required physical locations"}, 472 {0x07278800, 0, IPR_DEFAULT_LOG_LEVEL, 473 "9024: Array not functional due to present hardware configuration"}, 474 {0x07278900, 0, IPR_DEFAULT_LOG_LEVEL, 475 "9026: Array not functional due to present hardware configuration"}, 476 {0x07278A00, 0, IPR_DEFAULT_LOG_LEVEL, 477 "9027: Array is missing a device and parity is out of sync"}, 478 {0x07278B00, 0, IPR_DEFAULT_LOG_LEVEL, 479 "9028: Maximum number of arrays already exist"}, 480 {0x07278C00, 0, IPR_DEFAULT_LOG_LEVEL, 481 "9050: Required cache data cannot be located for a disk unit"}, 482 {0x07278D00, 0, IPR_DEFAULT_LOG_LEVEL, 483 "9052: Cache data exists for a device that has been modified"}, 484 {0x07278F00, 0, IPR_DEFAULT_LOG_LEVEL, 485 "9054: IOA resources not available due to previous problems"}, 486 {0x07279100, 0, IPR_DEFAULT_LOG_LEVEL, 487 "9092: Disk unit requires initialization before use"}, 488 {0x07279200, 0, IPR_DEFAULT_LOG_LEVEL, 489 "9029: Incorrect hardware configuration change has been detected"}, 490 {0x07279600, 0, IPR_DEFAULT_LOG_LEVEL, 491 "9060: One or more disk pairs are missing from an array"}, 492 {0x07279700, 0, IPR_DEFAULT_LOG_LEVEL, 493 "9061: One or more disks are missing from an array"}, 494 {0x07279800, 0, IPR_DEFAULT_LOG_LEVEL, 495 "9062: One or more disks are missing from an array"}, 496 {0x07279900, 0, IPR_DEFAULT_LOG_LEVEL, 497 "9063: Maximum number of functional arrays has been exceeded"}, 498 {0x0B260000, 0, 0, 499 "Aborted command, invalid descriptor"}, 500 {0x0B5A0000, 0, 0, 501 "Command terminated by host"} 502}; 503 504static const struct ipr_ses_table_entry ipr_ses_table[] = { 505 { "2104-DL1 ", "XXXXXXXXXXXXXXXX", 80 }, 506 { "2104-TL1 ", "XXXXXXXXXXXXXXXX", 80 }, 507 { "HSBP07M P U2SCSI", "XXXXXXXXXXXXXXXX", 80 }, /* Hidive 7 slot */ 508 { "HSBP05M P U2SCSI", "XXXXXXXXXXXXXXXX", 80 }, /* Hidive 5 slot */ 509 { "HSBP05M S U2SCSI", "XXXXXXXXXXXXXXXX", 80 }, /* Bowtie */ 510 { "HSBP06E ASU2SCSI", "XXXXXXXXXXXXXXXX", 80 }, /* MartinFenning */ 511 { "2104-DU3 ", "XXXXXXXXXXXXXXXX", 160 }, 512 { "2104-TU3 ", "XXXXXXXXXXXXXXXX", 160 }, 513 { "HSBP04C RSU2SCSI", "XXXXXXX*XXXXXXXX", 160 }, 514 { "HSBP06E RSU2SCSI", "XXXXXXX*XXXXXXXX", 160 }, 515 { "St V1S2 ", "XXXXXXXXXXXXXXXX", 160 }, 516 { "HSBPD4M PU3SCSI", "XXXXXXX*XXXXXXXX", 160 }, 517 { "VSBPD1H U3SCSI", "XXXXXXX*XXXXXXXX", 160 } 518}; 519 520/* 521 * Function Prototypes 522 */ 523static int ipr_reset_alert(struct ipr_cmnd *); 524static void ipr_process_ccn(struct ipr_cmnd *); 525static void ipr_process_error(struct ipr_cmnd *); 526static void ipr_reset_ioa_job(struct ipr_cmnd *); 527static void ipr_initiate_ioa_reset(struct ipr_ioa_cfg *, 528 enum ipr_shutdown_type); 529 530#ifdef CONFIG_SCSI_IPR_TRACE 531/** 532 * ipr_trc_hook - Add a trace entry to the driver trace 533 * @ipr_cmd: ipr command struct 534 * @type: trace type 535 * @add_data: additional data 536 * 537 * Return value: 538 * none 539 **/ 540static void ipr_trc_hook(struct ipr_cmnd *ipr_cmd, 541 u8 type, u32 add_data) 542{ 543 struct ipr_trace_entry *trace_entry; 544 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; 545 546 trace_entry = &ioa_cfg->trace[ioa_cfg->trace_index++]; 547 trace_entry->time = jiffies; 548 trace_entry->op_code = ipr_cmd->ioarcb.cmd_pkt.cdb[0]; 549 trace_entry->type = type; 550 if (ipr_cmd->ioa_cfg->sis64) 551 trace_entry->ata_op_code = ipr_cmd->i.ata_ioadl.regs.command; 552 else 553 trace_entry->ata_op_code = ipr_cmd->ioarcb.u.add_data.u.regs.command; 554 trace_entry->cmd_index = ipr_cmd->cmd_index & 0xff; 555 trace_entry->res_handle = ipr_cmd->ioarcb.res_handle; 556 trace_entry->u.add_data = add_data; 557} 558#else 559#define ipr_trc_hook(ipr_cmd, type, add_data) do { } while(0) 560#endif 561 562/** 563 * ipr_reinit_ipr_cmnd - Re-initialize an IPR Cmnd block for reuse 564 * @ipr_cmd: ipr command struct 565 * 566 * Return value: 567 * none 568 **/ 569static void ipr_reinit_ipr_cmnd(struct ipr_cmnd *ipr_cmd) 570{ 571 struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; 572 struct ipr_ioasa *ioasa = &ipr_cmd->s.ioasa; 573 struct ipr_ioasa64 *ioasa64 = &ipr_cmd->s.ioasa64; 574 dma_addr_t dma_addr = ipr_cmd->dma_addr; 575 576 memset(&ioarcb->cmd_pkt, 0, sizeof(struct ipr_cmd_pkt)); 577 ioarcb->data_transfer_length = 0; 578 ioarcb->read_data_transfer_length = 0; 579 ioarcb->ioadl_len = 0; 580 ioarcb->read_ioadl_len = 0; 581 582 if (ipr_cmd->ioa_cfg->sis64) { 583 ioarcb->u.sis64_addr_data.data_ioadl_addr = 584 cpu_to_be64(dma_addr + offsetof(struct ipr_cmnd, i.ioadl64)); 585 ioasa64->u.gata.status = 0; 586 } else { 587 ioarcb->write_ioadl_addr = 588 cpu_to_be32(dma_addr + offsetof(struct ipr_cmnd, i.ioadl)); 589 ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr; 590 ioasa->u.gata.status = 0; 591 } 592 593 ioasa->hdr.ioasc = 0; 594 ioasa->hdr.residual_data_len = 0; 595 ipr_cmd->scsi_cmd = NULL; 596 ipr_cmd->qc = NULL; 597 ipr_cmd->sense_buffer[0] = 0; 598 ipr_cmd->dma_use_sg = 0; 599} 600 601/** 602 * ipr_init_ipr_cmnd - Initialize an IPR Cmnd block 603 * @ipr_cmd: ipr command struct 604 * 605 * Return value: 606 * none 607 **/ 608static void ipr_init_ipr_cmnd(struct ipr_cmnd *ipr_cmd) 609{ 610 ipr_reinit_ipr_cmnd(ipr_cmd); 611 ipr_cmd->u.scratch = 0; 612 ipr_cmd->sibling = NULL; 613 init_timer(&ipr_cmd->timer); 614} 615 616/** 617 * ipr_get_free_ipr_cmnd - Get a free IPR Cmnd block 618 * @ioa_cfg: ioa config struct 619 * 620 * Return value: 621 * pointer to ipr command struct 622 **/ 623static 624struct ipr_cmnd *ipr_get_free_ipr_cmnd(struct ipr_ioa_cfg *ioa_cfg) 625{ 626 struct ipr_cmnd *ipr_cmd; 627 628 ipr_cmd = list_entry(ioa_cfg->free_q.next, struct ipr_cmnd, queue); 629 list_del(&ipr_cmd->queue); 630 ipr_init_ipr_cmnd(ipr_cmd); 631 632 return ipr_cmd; 633} 634 635/** 636 * ipr_mask_and_clear_interrupts - Mask all and clear specified interrupts 637 * @ioa_cfg: ioa config struct 638 * @clr_ints: interrupts to clear 639 * 640 * This function masks all interrupts on the adapter, then clears the 641 * interrupts specified in the mask 642 * 643 * Return value: 644 * none 645 **/ 646static void ipr_mask_and_clear_interrupts(struct ipr_ioa_cfg *ioa_cfg, 647 u32 clr_ints) 648{ 649 volatile u32 int_reg; 650 651 /* Stop new interrupts */ 652 ioa_cfg->allow_interrupts = 0; 653 654 /* Set interrupt mask to stop all new interrupts */ 655 if (ioa_cfg->sis64) 656 writeq(~0, ioa_cfg->regs.set_interrupt_mask_reg); 657 else 658 writel(~0, ioa_cfg->regs.set_interrupt_mask_reg); 659 660 /* Clear any pending interrupts */ 661 if (ioa_cfg->sis64) 662 writel(~0, ioa_cfg->regs.clr_interrupt_reg); 663 writel(clr_ints, ioa_cfg->regs.clr_interrupt_reg32); 664 int_reg = readl(ioa_cfg->regs.sense_interrupt_reg); 665} 666 667/** 668 * ipr_save_pcix_cmd_reg - Save PCI-X command register 669 * @ioa_cfg: ioa config struct 670 * 671 * Return value: 672 * 0 on success / -EIO on failure 673 **/ 674static int ipr_save_pcix_cmd_reg(struct ipr_ioa_cfg *ioa_cfg) 675{ 676 int pcix_cmd_reg = pci_find_capability(ioa_cfg->pdev, PCI_CAP_ID_PCIX); 677 678 if (pcix_cmd_reg == 0) 679 return 0; 680 681 if (pci_read_config_word(ioa_cfg->pdev, pcix_cmd_reg + PCI_X_CMD, 682 &ioa_cfg->saved_pcix_cmd_reg) != PCIBIOS_SUCCESSFUL) { 683 dev_err(&ioa_cfg->pdev->dev, "Failed to save PCI-X command register\n"); 684 return -EIO; 685 } 686 687 ioa_cfg->saved_pcix_cmd_reg |= PCI_X_CMD_DPERR_E | PCI_X_CMD_ERO; 688 return 0; 689} 690 691/** 692 * ipr_set_pcix_cmd_reg - Setup PCI-X command register 693 * @ioa_cfg: ioa config struct 694 * 695 * Return value: 696 * 0 on success / -EIO on failure 697 **/ 698static int ipr_set_pcix_cmd_reg(struct ipr_ioa_cfg *ioa_cfg) 699{ 700 int pcix_cmd_reg = pci_find_capability(ioa_cfg->pdev, PCI_CAP_ID_PCIX); 701 702 if (pcix_cmd_reg) { 703 if (pci_write_config_word(ioa_cfg->pdev, pcix_cmd_reg + PCI_X_CMD, 704 ioa_cfg->saved_pcix_cmd_reg) != PCIBIOS_SUCCESSFUL) { 705 dev_err(&ioa_cfg->pdev->dev, "Failed to setup PCI-X command register\n"); 706 return -EIO; 707 } 708 } 709 710 return 0; 711} 712 713/** 714 * ipr_sata_eh_done - done function for aborted SATA commands 715 * @ipr_cmd: ipr command struct 716 * 717 * This function is invoked for ops generated to SATA 718 * devices which are being aborted. 719 * 720 * Return value: 721 * none 722 **/ 723static void ipr_sata_eh_done(struct ipr_cmnd *ipr_cmd) 724{ 725 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; 726 struct ata_queued_cmd *qc = ipr_cmd->qc; 727 struct ipr_sata_port *sata_port = qc->ap->private_data; 728 729 qc->err_mask |= AC_ERR_OTHER; 730 sata_port->ioasa.status |= ATA_BUSY; 731 list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q); 732 ata_qc_complete(qc); 733} 734 735/** 736 * ipr_scsi_eh_done - mid-layer done function for aborted ops 737 * @ipr_cmd: ipr command struct 738 * 739 * This function is invoked by the interrupt handler for 740 * ops generated by the SCSI mid-layer which are being aborted. 741 * 742 * Return value: 743 * none 744 **/ 745static void ipr_scsi_eh_done(struct ipr_cmnd *ipr_cmd) 746{ 747 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; 748 struct scsi_cmnd *scsi_cmd = ipr_cmd->scsi_cmd; 749 750 scsi_cmd->result |= (DID_ERROR << 16); 751 752 scsi_dma_unmap(ipr_cmd->scsi_cmd); 753 scsi_cmd->scsi_done(scsi_cmd); 754 list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q); 755} 756 757/** 758 * ipr_fail_all_ops - Fails all outstanding ops. 759 * @ioa_cfg: ioa config struct 760 * 761 * This function fails all outstanding ops. 762 * 763 * Return value: 764 * none 765 **/ 766static void ipr_fail_all_ops(struct ipr_ioa_cfg *ioa_cfg) 767{ 768 struct ipr_cmnd *ipr_cmd, *temp; 769 770 ENTER; 771 list_for_each_entry_safe(ipr_cmd, temp, &ioa_cfg->pending_q, queue) { 772 list_del(&ipr_cmd->queue); 773 774 ipr_cmd->s.ioasa.hdr.ioasc = cpu_to_be32(IPR_IOASC_IOA_WAS_RESET); 775 ipr_cmd->s.ioasa.hdr.ilid = cpu_to_be32(IPR_DRIVER_ILID); 776 777 if (ipr_cmd->scsi_cmd) 778 ipr_cmd->done = ipr_scsi_eh_done; 779 else if (ipr_cmd->qc) 780 ipr_cmd->done = ipr_sata_eh_done; 781 782 ipr_trc_hook(ipr_cmd, IPR_TRACE_FINISH, IPR_IOASC_IOA_WAS_RESET); 783 del_timer(&ipr_cmd->timer); 784 ipr_cmd->done(ipr_cmd); 785 } 786 787 LEAVE; 788} 789 790/** 791 * ipr_send_command - Send driver initiated requests. 792 * @ipr_cmd: ipr command struct 793 * 794 * This function sends a command to the adapter using the correct write call. 795 * In the case of sis64, calculate the ioarcb size required. Then or in the 796 * appropriate bits. 797 * 798 * Return value: 799 * none 800 **/ 801static void ipr_send_command(struct ipr_cmnd *ipr_cmd) 802{ 803 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; 804 dma_addr_t send_dma_addr = ipr_cmd->dma_addr; 805 806 if (ioa_cfg->sis64) { 807 /* The default size is 256 bytes */ 808 send_dma_addr |= 0x1; 809 810 /* If the number of ioadls * size of ioadl > 128 bytes, 811 then use a 512 byte ioarcb */ 812 if (ipr_cmd->dma_use_sg * sizeof(struct ipr_ioadl64_desc) > 128 ) 813 send_dma_addr |= 0x4; 814 writeq(send_dma_addr, ioa_cfg->regs.ioarrin_reg); 815 } else 816 writel(send_dma_addr, ioa_cfg->regs.ioarrin_reg); 817} 818 819/** 820 * ipr_do_req - Send driver initiated requests. 821 * @ipr_cmd: ipr command struct 822 * @done: done function 823 * @timeout_func: timeout function 824 * @timeout: timeout value 825 * 826 * This function sends the specified command to the adapter with the 827 * timeout given. The done function is invoked on command completion. 828 * 829 * Return value: 830 * none 831 **/ 832static void ipr_do_req(struct ipr_cmnd *ipr_cmd, 833 void (*done) (struct ipr_cmnd *), 834 void (*timeout_func) (struct ipr_cmnd *), u32 timeout) 835{ 836 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; 837 838 list_add_tail(&ipr_cmd->queue, &ioa_cfg->pending_q); 839 840 ipr_cmd->done = done; 841 842 ipr_cmd->timer.data = (unsigned long) ipr_cmd; 843 ipr_cmd->timer.expires = jiffies + timeout; 844 ipr_cmd->timer.function = (void (*)(unsigned long))timeout_func; 845 846 add_timer(&ipr_cmd->timer); 847 848 ipr_trc_hook(ipr_cmd, IPR_TRACE_START, 0); 849 850 mb(); 851 852 ipr_send_command(ipr_cmd); 853} 854 855/** 856 * ipr_internal_cmd_done - Op done function for an internally generated op. 857 * @ipr_cmd: ipr command struct 858 * 859 * This function is the op done function for an internally generated, 860 * blocking op. It simply wakes the sleeping thread. 861 * 862 * Return value: 863 * none 864 **/ 865static void ipr_internal_cmd_done(struct ipr_cmnd *ipr_cmd) 866{ 867 if (ipr_cmd->sibling) 868 ipr_cmd->sibling = NULL; 869 else 870 complete(&ipr_cmd->completion); 871} 872 873/** 874 * ipr_init_ioadl - initialize the ioadl for the correct SIS type 875 * @ipr_cmd: ipr command struct 876 * @dma_addr: dma address 877 * @len: transfer length 878 * @flags: ioadl flag value 879 * 880 * This function initializes an ioadl in the case where there is only a single 881 * descriptor. 882 * 883 * Return value: 884 * nothing 885 **/ 886static void ipr_init_ioadl(struct ipr_cmnd *ipr_cmd, dma_addr_t dma_addr, 887 u32 len, int flags) 888{ 889 struct ipr_ioadl_desc *ioadl = ipr_cmd->i.ioadl; 890 struct ipr_ioadl64_desc *ioadl64 = ipr_cmd->i.ioadl64; 891 892 ipr_cmd->dma_use_sg = 1; 893 894 if (ipr_cmd->ioa_cfg->sis64) { 895 ioadl64->flags = cpu_to_be32(flags); 896 ioadl64->data_len = cpu_to_be32(len); 897 ioadl64->address = cpu_to_be64(dma_addr); 898 899 ipr_cmd->ioarcb.ioadl_len = 900 cpu_to_be32(sizeof(struct ipr_ioadl64_desc)); 901 ipr_cmd->ioarcb.data_transfer_length = cpu_to_be32(len); 902 } else { 903 ioadl->flags_and_data_len = cpu_to_be32(flags | len); 904 ioadl->address = cpu_to_be32(dma_addr); 905 906 if (flags == IPR_IOADL_FLAGS_READ_LAST) { 907 ipr_cmd->ioarcb.read_ioadl_len = 908 cpu_to_be32(sizeof(struct ipr_ioadl_desc)); 909 ipr_cmd->ioarcb.read_data_transfer_length = cpu_to_be32(len); 910 } else { 911 ipr_cmd->ioarcb.ioadl_len = 912 cpu_to_be32(sizeof(struct ipr_ioadl_desc)); 913 ipr_cmd->ioarcb.data_transfer_length = cpu_to_be32(len); 914 } 915 } 916} 917 918/** 919 * ipr_send_blocking_cmd - Send command and sleep on its completion. 920 * @ipr_cmd: ipr command struct 921 * @timeout_func: function to invoke if command times out 922 * @timeout: timeout 923 * 924 * Return value: 925 * none 926 **/ 927static void ipr_send_blocking_cmd(struct ipr_cmnd *ipr_cmd, 928 void (*timeout_func) (struct ipr_cmnd *ipr_cmd), 929 u32 timeout) 930{ 931 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; 932 933 init_completion(&ipr_cmd->completion); 934 ipr_do_req(ipr_cmd, ipr_internal_cmd_done, timeout_func, timeout); 935 936 spin_unlock_irq(ioa_cfg->host->host_lock); 937 wait_for_completion(&ipr_cmd->completion); 938 spin_lock_irq(ioa_cfg->host->host_lock); 939} 940 941/** 942 * ipr_send_hcam - Send an HCAM to the adapter. 943 * @ioa_cfg: ioa config struct 944 * @type: HCAM type 945 * @hostrcb: hostrcb struct 946 * 947 * This function will send a Host Controlled Async command to the adapter. 948 * If HCAMs are currently not allowed to be issued to the adapter, it will 949 * place the hostrcb on the free queue. 950 * 951 * Return value: 952 * none 953 **/ 954static void ipr_send_hcam(struct ipr_ioa_cfg *ioa_cfg, u8 type, 955 struct ipr_hostrcb *hostrcb) 956{ 957 struct ipr_cmnd *ipr_cmd; 958 struct ipr_ioarcb *ioarcb; 959 960 if (ioa_cfg->allow_cmds) { 961 ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg); 962 list_add_tail(&ipr_cmd->queue, &ioa_cfg->pending_q); 963 list_add_tail(&hostrcb->queue, &ioa_cfg->hostrcb_pending_q); 964 965 ipr_cmd->u.hostrcb = hostrcb; 966 ioarcb = &ipr_cmd->ioarcb; 967 968 ioarcb->res_handle = cpu_to_be32(IPR_IOA_RES_HANDLE); 969 ioarcb->cmd_pkt.request_type = IPR_RQTYPE_HCAM; 970 ioarcb->cmd_pkt.cdb[0] = IPR_HOST_CONTROLLED_ASYNC; 971 ioarcb->cmd_pkt.cdb[1] = type; 972 ioarcb->cmd_pkt.cdb[7] = (sizeof(hostrcb->hcam) >> 8) & 0xff; 973 ioarcb->cmd_pkt.cdb[8] = sizeof(hostrcb->hcam) & 0xff; 974 975 ipr_init_ioadl(ipr_cmd, hostrcb->hostrcb_dma, 976 sizeof(hostrcb->hcam), IPR_IOADL_FLAGS_READ_LAST); 977 978 if (type == IPR_HCAM_CDB_OP_CODE_CONFIG_CHANGE) 979 ipr_cmd->done = ipr_process_ccn; 980 else 981 ipr_cmd->done = ipr_process_error; 982 983 ipr_trc_hook(ipr_cmd, IPR_TRACE_START, IPR_IOA_RES_ADDR); 984 985 mb(); 986 987 ipr_send_command(ipr_cmd); 988 } else { 989 list_add_tail(&hostrcb->queue, &ioa_cfg->hostrcb_free_q); 990 } 991} 992 993/** 994 * ipr_update_ata_class - Update the ata class in the resource entry 995 * @res: resource entry struct 996 * @proto: cfgte device bus protocol value 997 * 998 * Return value: 999 * none 1000 **/ 1001static void ipr_update_ata_class(struct ipr_resource_entry *res, unsigned int proto) 1002{ 1003 switch(proto) { 1004 case IPR_PROTO_SATA: 1005 case IPR_PROTO_SAS_STP: 1006 res->ata_class = ATA_DEV_ATA; 1007 break; 1008 case IPR_PROTO_SATA_ATAPI: 1009 case IPR_PROTO_SAS_STP_ATAPI: 1010 res->ata_class = ATA_DEV_ATAPI; 1011 break; 1012 default: 1013 res->ata_class = ATA_DEV_UNKNOWN; 1014 break; 1015 }; 1016} 1017 1018/** 1019 * ipr_init_res_entry - Initialize a resource entry struct. 1020 * @res: resource entry struct 1021 * @cfgtew: config table entry wrapper struct 1022 * 1023 * Return value: 1024 * none 1025 **/ 1026static void ipr_init_res_entry(struct ipr_resource_entry *res, 1027 struct ipr_config_table_entry_wrapper *cfgtew) 1028{ 1029 int found = 0; 1030 unsigned int proto; 1031 struct ipr_ioa_cfg *ioa_cfg = res->ioa_cfg; 1032 struct ipr_resource_entry *gscsi_res = NULL; 1033 1034 res->needs_sync_complete = 0; 1035 res->in_erp = 0; 1036 res->add_to_ml = 0; 1037 res->del_from_ml = 0; 1038 res->resetting_device = 0; 1039 res->sdev = NULL; 1040 res->sata_port = NULL; 1041 1042 if (ioa_cfg->sis64) { 1043 proto = cfgtew->u.cfgte64->proto; 1044 res->res_flags = cfgtew->u.cfgte64->res_flags; 1045 res->qmodel = IPR_QUEUEING_MODEL64(res); 1046 res->type = cfgtew->u.cfgte64->res_type; 1047 1048 memcpy(res->res_path, &cfgtew->u.cfgte64->res_path, 1049 sizeof(res->res_path)); 1050 1051 res->bus = 0; 1052 memcpy(&res->dev_lun.scsi_lun, &cfgtew->u.cfgte64->lun, 1053 sizeof(res->dev_lun.scsi_lun)); 1054 res->lun = scsilun_to_int(&res->dev_lun); 1055 1056 if (res->type == IPR_RES_TYPE_GENERIC_SCSI) { 1057 list_for_each_entry(gscsi_res, &ioa_cfg->used_res_q, queue) { 1058 if (gscsi_res->dev_id == cfgtew->u.cfgte64->dev_id) { 1059 found = 1; 1060 res->target = gscsi_res->target; 1061 break; 1062 } 1063 } 1064 if (!found) { 1065 res->target = find_first_zero_bit(ioa_cfg->target_ids, 1066 ioa_cfg->max_devs_supported); 1067 set_bit(res->target, ioa_cfg->target_ids); 1068 } 1069 } else if (res->type == IPR_RES_TYPE_IOAFP) { 1070 res->bus = IPR_IOAFP_VIRTUAL_BUS; 1071 res->target = 0; 1072 } else if (res->type == IPR_RES_TYPE_ARRAY) { 1073 res->bus = IPR_ARRAY_VIRTUAL_BUS; 1074 res->target = find_first_zero_bit(ioa_cfg->array_ids, 1075 ioa_cfg->max_devs_supported); 1076 set_bit(res->target, ioa_cfg->array_ids); 1077 } else if (res->type == IPR_RES_TYPE_VOLUME_SET) { 1078 res->bus = IPR_VSET_VIRTUAL_BUS; 1079 res->target = find_first_zero_bit(ioa_cfg->vset_ids, 1080 ioa_cfg->max_devs_supported); 1081 set_bit(res->target, ioa_cfg->vset_ids); 1082 } else { 1083 res->target = find_first_zero_bit(ioa_cfg->target_ids, 1084 ioa_cfg->max_devs_supported); 1085 set_bit(res->target, ioa_cfg->target_ids); 1086 } 1087 } else { 1088 proto = cfgtew->u.cfgte->proto; 1089 res->qmodel = IPR_QUEUEING_MODEL(res); 1090 res->flags = cfgtew->u.cfgte->flags; 1091 if (res->flags & IPR_IS_IOA_RESOURCE) 1092 res->type = IPR_RES_TYPE_IOAFP; 1093 else 1094 res->type = cfgtew->u.cfgte->rsvd_subtype & 0x0f; 1095 1096 res->bus = cfgtew->u.cfgte->res_addr.bus; 1097 res->target = cfgtew->u.cfgte->res_addr.target; 1098 res->lun = cfgtew->u.cfgte->res_addr.lun; 1099 res->lun_wwn = get_unaligned_be64(cfgtew->u.cfgte->lun_wwn); 1100 } 1101 1102 ipr_update_ata_class(res, proto); 1103} 1104 1105/** 1106 * ipr_is_same_device - Determine if two devices are the same. 1107 * @res: resource entry struct 1108 * @cfgtew: config table entry wrapper struct 1109 * 1110 * Return value: 1111 * 1 if the devices are the same / 0 otherwise 1112 **/ 1113static int ipr_is_same_device(struct ipr_resource_entry *res, 1114 struct ipr_config_table_entry_wrapper *cfgtew) 1115{ 1116 if (res->ioa_cfg->sis64) { 1117 if (!memcmp(&res->dev_id, &cfgtew->u.cfgte64->dev_id, 1118 sizeof(cfgtew->u.cfgte64->dev_id)) && 1119 !memcmp(&res->dev_lun.scsi_lun, &cfgtew->u.cfgte64->lun, 1120 sizeof(cfgtew->u.cfgte64->lun))) { 1121 return 1; 1122 } 1123 } else { 1124 if (res->bus == cfgtew->u.cfgte->res_addr.bus && 1125 res->target == cfgtew->u.cfgte->res_addr.target && 1126 res->lun == cfgtew->u.cfgte->res_addr.lun) 1127 return 1; 1128 } 1129 1130 return 0; 1131} 1132 1133/** 1134 * ipr_format_res_path - Format the resource path for printing. 1135 * @res_path: resource path 1136 * @buf: buffer 1137 * 1138 * Return value: 1139 * pointer to buffer 1140 **/ 1141static char *ipr_format_res_path(u8 *res_path, char *buffer, int len) 1142{ 1143 int i; 1144 char *p = buffer; 1145 1146 *p = '\0'; 1147 p += snprintf(p, buffer + len - p, "%02X", res_path[0]); 1148 for (i = 1; res_path[i] != 0xff && ((i * 3) < len); i++) 1149 p += snprintf(p, buffer + len - p, "-%02X", res_path[i]); 1150 1151 return buffer; 1152} 1153 1154/** 1155 * ipr_update_res_entry - Update the resource entry. 1156 * @res: resource entry struct 1157 * @cfgtew: config table entry wrapper struct 1158 * 1159 * Return value: 1160 * none 1161 **/ 1162static void ipr_update_res_entry(struct ipr_resource_entry *res, 1163 struct ipr_config_table_entry_wrapper *cfgtew) 1164{ 1165 char buffer[IPR_MAX_RES_PATH_LENGTH]; 1166 unsigned int proto; 1167 int new_path = 0; 1168 1169 if (res->ioa_cfg->sis64) { 1170 res->flags = cfgtew->u.cfgte64->flags; 1171 res->res_flags = cfgtew->u.cfgte64->res_flags; 1172 res->type = cfgtew->u.cfgte64->res_type; 1173 1174 memcpy(&res->std_inq_data, &cfgtew->u.cfgte64->std_inq_data, 1175 sizeof(struct ipr_std_inq_data)); 1176 1177 res->qmodel = IPR_QUEUEING_MODEL64(res); 1178 proto = cfgtew->u.cfgte64->proto; 1179 res->res_handle = cfgtew->u.cfgte64->res_handle; 1180 res->dev_id = cfgtew->u.cfgte64->dev_id; 1181 1182 memcpy(&res->dev_lun.scsi_lun, &cfgtew->u.cfgte64->lun, 1183 sizeof(res->dev_lun.scsi_lun)); 1184 1185 if (memcmp(res->res_path, &cfgtew->u.cfgte64->res_path, 1186 sizeof(res->res_path))) { 1187 memcpy(res->res_path, &cfgtew->u.cfgte64->res_path, 1188 sizeof(res->res_path)); 1189 new_path = 1; 1190 } 1191 1192 if (res->sdev && new_path) 1193 sdev_printk(KERN_INFO, res->sdev, "Resource path: %s\n", 1194 ipr_format_res_path(res->res_path, buffer, 1195 sizeof(buffer))); 1196 } else { 1197 res->flags = cfgtew->u.cfgte->flags; 1198 if (res->flags & IPR_IS_IOA_RESOURCE) 1199 res->type = IPR_RES_TYPE_IOAFP; 1200 else 1201 res->type = cfgtew->u.cfgte->rsvd_subtype & 0x0f; 1202 1203 memcpy(&res->std_inq_data, &cfgtew->u.cfgte->std_inq_data, 1204 sizeof(struct ipr_std_inq_data)); 1205 1206 res->qmodel = IPR_QUEUEING_MODEL(res); 1207 proto = cfgtew->u.cfgte->proto; 1208 res->res_handle = cfgtew->u.cfgte->res_handle; 1209 } 1210 1211 ipr_update_ata_class(res, proto); 1212} 1213 1214/** 1215 * ipr_clear_res_target - Clear the bit in the bit map representing the target 1216 * for the resource. 1217 * @res: resource entry struct 1218 * @cfgtew: config table entry wrapper struct 1219 * 1220 * Return value: 1221 * none 1222 **/ 1223static void ipr_clear_res_target(struct ipr_resource_entry *res) 1224{ 1225 struct ipr_resource_entry *gscsi_res = NULL; 1226 struct ipr_ioa_cfg *ioa_cfg = res->ioa_cfg; 1227 1228 if (!ioa_cfg->sis64) 1229 return; 1230 1231 if (res->bus == IPR_ARRAY_VIRTUAL_BUS) 1232 clear_bit(res->target, ioa_cfg->array_ids); 1233 else if (res->bus == IPR_VSET_VIRTUAL_BUS) 1234 clear_bit(res->target, ioa_cfg->vset_ids); 1235 else if (res->bus == 0 && res->type == IPR_RES_TYPE_GENERIC_SCSI) { 1236 list_for_each_entry(gscsi_res, &ioa_cfg->used_res_q, queue) 1237 if (gscsi_res->dev_id == res->dev_id && gscsi_res != res) 1238 return; 1239 clear_bit(res->target, ioa_cfg->target_ids); 1240 1241 } else if (res->bus == 0) 1242 clear_bit(res->target, ioa_cfg->target_ids); 1243} 1244 1245/** 1246 * ipr_handle_config_change - Handle a config change from the adapter 1247 * @ioa_cfg: ioa config struct 1248 * @hostrcb: hostrcb 1249 * 1250 * Return value: 1251 * none 1252 **/ 1253static void ipr_handle_config_change(struct ipr_ioa_cfg *ioa_cfg, 1254 struct ipr_hostrcb *hostrcb) 1255{ 1256 struct ipr_resource_entry *res = NULL; 1257 struct ipr_config_table_entry_wrapper cfgtew; 1258 __be32 cc_res_handle; 1259 1260 u32 is_ndn = 1; 1261 1262 if (ioa_cfg->sis64) { 1263 cfgtew.u.cfgte64 = &hostrcb->hcam.u.ccn.u.cfgte64; 1264 cc_res_handle = cfgtew.u.cfgte64->res_handle; 1265 } else { 1266 cfgtew.u.cfgte = &hostrcb->hcam.u.ccn.u.cfgte; 1267 cc_res_handle = cfgtew.u.cfgte->res_handle; 1268 } 1269 1270 list_for_each_entry(res, &ioa_cfg->used_res_q, queue) { 1271 if (res->res_handle == cc_res_handle) { 1272 is_ndn = 0; 1273 break; 1274 } 1275 } 1276 1277 if (is_ndn) { 1278 if (list_empty(&ioa_cfg->free_res_q)) { 1279 ipr_send_hcam(ioa_cfg, 1280 IPR_HCAM_CDB_OP_CODE_CONFIG_CHANGE, 1281 hostrcb); 1282 return; 1283 } 1284 1285 res = list_entry(ioa_cfg->free_res_q.next, 1286 struct ipr_resource_entry, queue); 1287 1288 list_del(&res->queue); 1289 ipr_init_res_entry(res, &cfgtew); 1290 list_add_tail(&res->queue, &ioa_cfg->used_res_q); 1291 } 1292 1293 ipr_update_res_entry(res, &cfgtew); 1294 1295 if (hostrcb->hcam.notify_type == IPR_HOST_RCB_NOTIF_TYPE_REM_ENTRY) { 1296 if (res->sdev) { 1297 res->del_from_ml = 1; 1298 res->res_handle = IPR_INVALID_RES_HANDLE; 1299 if (ioa_cfg->allow_ml_add_del) 1300 schedule_work(&ioa_cfg->work_q); 1301 } else { 1302 ipr_clear_res_target(res); 1303 list_move_tail(&res->queue, &ioa_cfg->free_res_q); 1304 } 1305 } else if (!res->sdev || res->del_from_ml) { 1306 res->add_to_ml = 1; 1307 if (ioa_cfg->allow_ml_add_del) 1308 schedule_work(&ioa_cfg->work_q); 1309 } 1310 1311 ipr_send_hcam(ioa_cfg, IPR_HCAM_CDB_OP_CODE_CONFIG_CHANGE, hostrcb); 1312} 1313 1314/** 1315 * ipr_process_ccn - Op done function for a CCN. 1316 * @ipr_cmd: ipr command struct 1317 * 1318 * This function is the op done function for a configuration 1319 * change notification host controlled async from the adapter. 1320 * 1321 * Return value: 1322 * none 1323 **/ 1324static void ipr_process_ccn(struct ipr_cmnd *ipr_cmd) 1325{ 1326 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; 1327 struct ipr_hostrcb *hostrcb = ipr_cmd->u.hostrcb; 1328 u32 ioasc = be32_to_cpu(ipr_cmd->s.ioasa.hdr.ioasc); 1329 1330 list_del(&hostrcb->queue); 1331 list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q); 1332 1333 if (ioasc) { 1334 if (ioasc != IPR_IOASC_IOA_WAS_RESET) 1335 dev_err(&ioa_cfg->pdev->dev, 1336 "Host RCB failed with IOASC: 0x%08X\n", ioasc); 1337 1338 ipr_send_hcam(ioa_cfg, IPR_HCAM_CDB_OP_CODE_CONFIG_CHANGE, hostrcb); 1339 } else { 1340 ipr_handle_config_change(ioa_cfg, hostrcb); 1341 } 1342} 1343 1344/** 1345 * strip_and_pad_whitespace - Strip and pad trailing whitespace. 1346 * @i: index into buffer 1347 * @buf: string to modify 1348 * 1349 * This function will strip all trailing whitespace, pad the end 1350 * of the string with a single space, and NULL terminate the string. 1351 * 1352 * Return value: 1353 * new length of string 1354 **/ 1355static int strip_and_pad_whitespace(int i, char *buf) 1356{ 1357 while (i && buf[i] == ' ') 1358 i--; 1359 buf[i+1] = ' '; 1360 buf[i+2] = '\0'; 1361 return i + 2; 1362} 1363 1364/** 1365 * ipr_log_vpd_compact - Log the passed extended VPD compactly. 1366 * @prefix: string to print at start of printk 1367 * @hostrcb: hostrcb pointer 1368 * @vpd: vendor/product id/sn struct 1369 * 1370 * Return value: 1371 * none 1372 **/ 1373static void ipr_log_vpd_compact(char *prefix, struct ipr_hostrcb *hostrcb, 1374 struct ipr_vpd *vpd) 1375{ 1376 char buffer[IPR_VENDOR_ID_LEN + IPR_PROD_ID_LEN + IPR_SERIAL_NUM_LEN + 3]; 1377 int i = 0; 1378 1379 memcpy(buffer, vpd->vpids.vendor_id, IPR_VENDOR_ID_LEN); 1380 i = strip_and_pad_whitespace(IPR_VENDOR_ID_LEN - 1, buffer); 1381 1382 memcpy(&buffer[i], vpd->vpids.product_id, IPR_PROD_ID_LEN); 1383 i = strip_and_pad_whitespace(i + IPR_PROD_ID_LEN - 1, buffer); 1384 1385 memcpy(&buffer[i], vpd->sn, IPR_SERIAL_NUM_LEN); 1386 buffer[IPR_SERIAL_NUM_LEN + i] = '\0'; 1387 1388 ipr_hcam_err(hostrcb, "%s VPID/SN: %s\n", prefix, buffer); 1389} 1390 1391/** 1392 * ipr_log_vpd - Log the passed VPD to the error log. 1393 * @vpd: vendor/product id/sn struct 1394 * 1395 * Return value: 1396 * none 1397 **/ 1398static void ipr_log_vpd(struct ipr_vpd *vpd) 1399{ 1400 char buffer[IPR_VENDOR_ID_LEN + IPR_PROD_ID_LEN 1401 + IPR_SERIAL_NUM_LEN]; 1402 1403 memcpy(buffer, vpd->vpids.vendor_id, IPR_VENDOR_ID_LEN); 1404 memcpy(buffer + IPR_VENDOR_ID_LEN, vpd->vpids.product_id, 1405 IPR_PROD_ID_LEN); 1406 buffer[IPR_VENDOR_ID_LEN + IPR_PROD_ID_LEN] = '\0'; 1407 ipr_err("Vendor/Product ID: %s\n", buffer); 1408 1409 memcpy(buffer, vpd->sn, IPR_SERIAL_NUM_LEN); 1410 buffer[IPR_SERIAL_NUM_LEN] = '\0'; 1411 ipr_err(" Serial Number: %s\n", buffer); 1412} 1413 1414/** 1415 * ipr_log_ext_vpd_compact - Log the passed extended VPD compactly. 1416 * @prefix: string to print at start of printk 1417 * @hostrcb: hostrcb pointer 1418 * @vpd: vendor/product id/sn/wwn struct 1419 * 1420 * Return value: 1421 * none 1422 **/ 1423static void ipr_log_ext_vpd_compact(char *prefix, struct ipr_hostrcb *hostrcb, 1424 struct ipr_ext_vpd *vpd) 1425{ 1426 ipr_log_vpd_compact(prefix, hostrcb, &vpd->vpd); 1427 ipr_hcam_err(hostrcb, "%s WWN: %08X%08X\n", prefix, 1428 be32_to_cpu(vpd->wwid[0]), be32_to_cpu(vpd->wwid[1])); 1429} 1430 1431/** 1432 * ipr_log_ext_vpd - Log the passed extended VPD to the error log. 1433 * @vpd: vendor/product id/sn/wwn struct 1434 * 1435 * Return value: 1436 * none 1437 **/ 1438static void ipr_log_ext_vpd(struct ipr_ext_vpd *vpd) 1439{ 1440 ipr_log_vpd(&vpd->vpd); 1441 ipr_err(" WWN: %08X%08X\n", be32_to_cpu(vpd->wwid[0]), 1442 be32_to_cpu(vpd->wwid[1])); 1443} 1444 1445/** 1446 * ipr_log_enhanced_cache_error - Log a cache error. 1447 * @ioa_cfg: ioa config struct 1448 * @hostrcb: hostrcb struct 1449 * 1450 * Return value: 1451 * none 1452 **/ 1453static void ipr_log_enhanced_cache_error(struct ipr_ioa_cfg *ioa_cfg, 1454 struct ipr_hostrcb *hostrcb) 1455{ 1456 struct ipr_hostrcb_type_12_error *error; 1457 1458 if (ioa_cfg->sis64) 1459 error = &hostrcb->hcam.u.error64.u.type_12_error; 1460 else 1461 error = &hostrcb->hcam.u.error.u.type_12_error; 1462 1463 ipr_err("-----Current Configuration-----\n"); 1464 ipr_err("Cache Directory Card Information:\n"); 1465 ipr_log_ext_vpd(&error->ioa_vpd); 1466 ipr_err("Adapter Card Information:\n"); 1467 ipr_log_ext_vpd(&error->cfc_vpd); 1468 1469 ipr_err("-----Expected Configuration-----\n"); 1470 ipr_err("Cache Directory Card Information:\n"); 1471 ipr_log_ext_vpd(&error->ioa_last_attached_to_cfc_vpd); 1472 ipr_err("Adapter Card Information:\n"); 1473 ipr_log_ext_vpd(&error->cfc_last_attached_to_ioa_vpd); 1474 1475 ipr_err("Additional IOA Data: %08X %08X %08X\n", 1476 be32_to_cpu(error->ioa_data[0]), 1477 be32_to_cpu(error->ioa_data[1]), 1478 be32_to_cpu(error->ioa_data[2])); 1479} 1480 1481/** 1482 * ipr_log_cache_error - Log a cache error. 1483 * @ioa_cfg: ioa config struct 1484 * @hostrcb: hostrcb struct 1485 * 1486 * Return value: 1487 * none 1488 **/ 1489static void ipr_log_cache_error(struct ipr_ioa_cfg *ioa_cfg, 1490 struct ipr_hostrcb *hostrcb) 1491{ 1492 struct ipr_hostrcb_type_02_error *error = 1493 &hostrcb->hcam.u.error.u.type_02_error; 1494 1495 ipr_err("-----Current Configuration-----\n"); 1496 ipr_err("Cache Directory Card Information:\n"); 1497 ipr_log_vpd(&error->ioa_vpd); 1498 ipr_err("Adapter Card Information:\n"); 1499 ipr_log_vpd(&error->cfc_vpd); 1500 1501 ipr_err("-----Expected Configuration-----\n"); 1502 ipr_err("Cache Directory Card Information:\n"); 1503 ipr_log_vpd(&error->ioa_last_attached_to_cfc_vpd); 1504 ipr_err("Adapter Card Information:\n"); 1505 ipr_log_vpd(&error->cfc_last_attached_to_ioa_vpd); 1506 1507 ipr_err("Additional IOA Data: %08X %08X %08X\n", 1508 be32_to_cpu(error->ioa_data[0]), 1509 be32_to_cpu(error->ioa_data[1]), 1510 be32_to_cpu(error->ioa_data[2])); 1511} 1512 1513/** 1514 * ipr_log_enhanced_config_error - Log a configuration error. 1515 * @ioa_cfg: ioa config struct 1516 * @hostrcb: hostrcb struct 1517 * 1518 * Return value: 1519 * none 1520 **/ 1521static void ipr_log_enhanced_config_error(struct ipr_ioa_cfg *ioa_cfg, 1522 struct ipr_hostrcb *hostrcb) 1523{ 1524 int errors_logged, i; 1525 struct ipr_hostrcb_device_data_entry_enhanced *dev_entry; 1526 struct ipr_hostrcb_type_13_error *error; 1527 1528 error = &hostrcb->hcam.u.error.u.type_13_error; 1529 errors_logged = be32_to_cpu(error->errors_logged); 1530 1531 ipr_err("Device Errors Detected/Logged: %d/%d\n", 1532 be32_to_cpu(error->errors_detected), errors_logged); 1533 1534 dev_entry = error->dev; 1535 1536 for (i = 0; i < errors_logged; i++, dev_entry++) { 1537 ipr_err_separator; 1538 1539 ipr_phys_res_err(ioa_cfg, dev_entry->dev_res_addr, "Device %d", i + 1); 1540 ipr_log_ext_vpd(&dev_entry->vpd); 1541 1542 ipr_err("-----New Device Information-----\n"); 1543 ipr_log_ext_vpd(&dev_entry->new_vpd); 1544 1545 ipr_err("Cache Directory Card Information:\n"); 1546 ipr_log_ext_vpd(&dev_entry->ioa_last_with_dev_vpd); 1547 1548 ipr_err("Adapter Card Information:\n"); 1549 ipr_log_ext_vpd(&dev_entry->cfc_last_with_dev_vpd); 1550 } 1551} 1552 1553/** 1554 * ipr_log_sis64_config_error - Log a device error. 1555 * @ioa_cfg: ioa config struct 1556 * @hostrcb: hostrcb struct 1557 * 1558 * Return value: 1559 * none 1560 **/ 1561static void ipr_log_sis64_config_error(struct ipr_ioa_cfg *ioa_cfg, 1562 struct ipr_hostrcb *hostrcb) 1563{ 1564 int errors_logged, i; 1565 struct ipr_hostrcb64_device_data_entry_enhanced *dev_entry; 1566 struct ipr_hostrcb_type_23_error *error; 1567 char buffer[IPR_MAX_RES_PATH_LENGTH]; 1568 1569 error = &hostrcb->hcam.u.error64.u.type_23_error; 1570 errors_logged = be32_to_cpu(error->errors_logg…
Large files files are truncated, but you can click here to view the full file