/drivers/scsi/ipr.c

https://bitbucket.org/cyanogenmod/android_kernel_asus_tf300t · C · 9237 lines · 5898 code · 1206 blank · 2133 comment · 873 complexity · a3660cded51ae2342d2ce8c903ee1110 MD5 · raw file

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