aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/message')
-rw-r--r--drivers/message/fusion/Kconfig2
-rw-r--r--drivers/message/fusion/Makefile6
-rw-r--r--drivers/message/fusion/lsi/fc_log.h89
-rw-r--r--drivers/message/fusion/lsi/mpi.h5
-rw-r--r--drivers/message/fusion/lsi/mpi_cnfg.h158
-rw-r--r--drivers/message/fusion/lsi/mpi_history.txt76
-rw-r--r--drivers/message/fusion/lsi/mpi_init.h4
-rw-r--r--drivers/message/fusion/lsi/mpi_ioc.h154
-rw-r--r--drivers/message/fusion/lsi/mpi_log_sas.h82
-rw-r--r--drivers/message/fusion/lsi/mpi_sas.h13
-rw-r--r--drivers/message/fusion/lsi/mpi_targ.h5
-rw-r--r--drivers/message/fusion/mptbase.c179
-rw-r--r--drivers/message/fusion/mptbase.h24
-rw-r--r--drivers/message/fusion/mptctl.c4
-rw-r--r--drivers/message/fusion/mptctl.h5
-rw-r--r--drivers/message/fusion/mptfc.c228
-rw-r--r--drivers/message/fusion/mptsas.c1063
-rw-r--r--drivers/message/fusion/mptscsih.c118
-rw-r--r--drivers/message/fusion/mptspi.c14
-rw-r--r--drivers/message/i2o/core.h3
-rw-r--r--drivers/message/i2o/debug.c1
-rw-r--r--drivers/message/i2o/i2o_block.c1
-rw-r--r--drivers/message/i2o/i2o_config.c4
-rw-r--r--drivers/message/i2o/iop.c15
-rw-r--r--drivers/message/i2o/pci.c2
25 files changed, 1544 insertions, 711 deletions
diff --git a/drivers/message/fusion/Kconfig b/drivers/message/fusion/Kconfig
index bbc229852881..ea31d8470510 100644
--- a/drivers/message/fusion/Kconfig
+++ b/drivers/message/fusion/Kconfig
@@ -48,10 +48,8 @@ config FUSION_SAS
48 List of supported controllers: 48 List of supported controllers:
49 49
50 LSISAS1064 50 LSISAS1064
51 LSISAS1066
52 LSISAS1068 51 LSISAS1068
53 LSISAS1064E 52 LSISAS1064E
54 LSISAS1066E
55 LSISAS1068E 53 LSISAS1068E
56 54
57config FUSION_MAX_SGE 55config FUSION_MAX_SGE
diff --git a/drivers/message/fusion/Makefile b/drivers/message/fusion/Makefile
index 51740b346224..341691390e86 100644
--- a/drivers/message/fusion/Makefile
+++ b/drivers/message/fusion/Makefile
@@ -9,7 +9,6 @@
9#EXTRA_CFLAGS += -DMPT_DEBUG_EXIT 9#EXTRA_CFLAGS += -DMPT_DEBUG_EXIT
10#EXTRA_CFLAGS += -DMPT_DEBUG_FAIL 10#EXTRA_CFLAGS += -DMPT_DEBUG_FAIL
11 11
12
13# 12#
14# driver/module specifics... 13# driver/module specifics...
15# 14#
@@ -33,6 +32,11 @@
33# For mptfc: 32# For mptfc:
34#CFLAGS_mptfc.o += -DMPT_DEBUG_FC 33#CFLAGS_mptfc.o += -DMPT_DEBUG_FC
35 34
35# For mptsas:
36#CFLAGS_mptsas.o += -DMPT_DEBUG_SAS
37#CFLAGS_mptsas.o += -DMPT_DEBUG_SAS_WIDE
38
39
36#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-} LSI_LOGIC 40#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-} LSI_LOGIC
37 41
38obj-$(CONFIG_FUSION_SPI) += mptbase.o mptscsih.o mptspi.o 42obj-$(CONFIG_FUSION_SPI) += mptbase.o mptscsih.o mptspi.o
diff --git a/drivers/message/fusion/lsi/fc_log.h b/drivers/message/fusion/lsi/fc_log.h
deleted file mode 100644
index dc98d46f9071..000000000000
--- a/drivers/message/fusion/lsi/fc_log.h
+++ /dev/null
@@ -1,89 +0,0 @@
1/*
2 * Copyright (c) 2000-2001 LSI Logic Corporation. All rights reserved.
3 *
4 * NAME: fc_log.h
5 * SUMMARY: MPI IocLogInfo definitions for the SYMFC9xx chips
6 * DESCRIPTION: Contains the enumerated list of values that may be returned
7 * in the IOCLogInfo field of a MPI Default Reply Message.
8 *
9 * CREATION DATE: 6/02/2000
10 * ID: $Id: fc_log.h,v 4.6 2001/07/26 14:41:33 sschremm Exp $
11 */
12
13
14/*
15 * MpiIocLogInfo_t enum
16 *
17 * These 32 bit values are used in the IOCLogInfo field of the MPI reply
18 * messages.
19 * The value is 0xabcccccc where
20 * a = The type of log info as per the MPI spec. Since these codes are
21 * all for Fibre Channel this value will always be 2.
22 * b = Specifies a subclass of the firmware where
23 * 0 = FCP Initiator
24 * 1 = FCP Target
25 * 2 = LAN
26 * 3 = MPI Message Layer
27 * 4 = FC Link
28 * 5 = Context Manager
29 * 6 = Invalid Field Offset
30 * 7 = State Change Info
31 * all others are reserved for future use
32 * c = A specific value within the subclass.
33 *
34 * NOTE: Any new values should be added to the end of each subclass so that the
35 * codes remain consistent across firmware releases.
36 */
37typedef enum _MpiIocLogInfoFc
38{
39 MPI_IOCLOGINFO_FC_INIT_BASE = 0x20000000,
40 MPI_IOCLOGINFO_FC_INIT_ERROR_OUT_OF_ORDER_FRAME = 0x20000001, /* received an out of order frame - unsupported */
41 MPI_IOCLOGINFO_FC_INIT_ERROR_BAD_START_OF_FRAME = 0x20000002, /* Bad Rx Frame, bad start of frame primative */
42 MPI_IOCLOGINFO_FC_INIT_ERROR_BAD_END_OF_FRAME = 0x20000003, /* Bad Rx Frame, bad end of frame primative */
43 MPI_IOCLOGINFO_FC_INIT_ERROR_OVER_RUN = 0x20000004, /* Bad Rx Frame, overrun */
44 MPI_IOCLOGINFO_FC_INIT_ERROR_RX_OTHER = 0x20000005, /* Other errors caught by IOC which require retries */
45 MPI_IOCLOGINFO_FC_INIT_ERROR_SUBPROC_DEAD = 0x20000006, /* Main processor could not initialize sub-processor */
46 MPI_IOCLOGINFO_FC_INIT_ERROR_RX_OVERRUN = 0x20000007, /* Scatter Gather overrun */
47 MPI_IOCLOGINFO_FC_INIT_ERROR_RX_BAD_STATUS = 0x20000008, /* Receiver detected context mismatch via invalid header */
48 MPI_IOCLOGINFO_FC_INIT_ERROR_RX_UNEXPECTED_FRAME= 0x20000009, /* CtxMgr detected unsupported frame type */
49 MPI_IOCLOGINFO_FC_INIT_ERROR_LINK_FAILURE = 0x2000000A, /* Link failure occurred */
50 MPI_IOCLOGINFO_FC_INIT_ERROR_TX_TIMEOUT = 0x2000000B, /* Transmitter timeout error */
51
52 MPI_IOCLOGINFO_FC_TARGET_BASE = 0x21000000,
53 MPI_IOCLOGINFO_FC_TARGET_NO_PDISC = 0x21000001, /* not sent because we are waiting for a PDISC from the initiator */
54 MPI_IOCLOGINFO_FC_TARGET_NO_LOGIN = 0x21000002, /* not sent because we are not logged in to the remote node */
55 MPI_IOCLOGINFO_FC_TARGET_DOAR_KILLED_BY_LIP = 0x21000003, /* Data Out, Auto Response, not sent due to a LIP */
56 MPI_IOCLOGINFO_FC_TARGET_DIAR_KILLED_BY_LIP = 0x21000004, /* Data In, Auto Response, not sent due to a LIP */
57 MPI_IOCLOGINFO_FC_TARGET_DIAR_MISSING_DATA = 0x21000005, /* Data In, Auto Response, missing data frames */
58 MPI_IOCLOGINFO_FC_TARGET_DONR_KILLED_BY_LIP = 0x21000006, /* Data Out, No Response, not sent due to a LIP */
59 MPI_IOCLOGINFO_FC_TARGET_WRSP_KILLED_BY_LIP = 0x21000007, /* Auto-response after a write not sent due to a LIP */
60 MPI_IOCLOGINFO_FC_TARGET_DINR_KILLED_BY_LIP = 0x21000008, /* Data In, No Response, not completed due to a LIP */
61 MPI_IOCLOGINFO_FC_TARGET_DINR_MISSING_DATA = 0x21000009, /* Data In, No Response, missing data frames */
62 MPI_IOCLOGINFO_FC_TARGET_MRSP_KILLED_BY_LIP = 0x2100000a, /* Manual Response not sent due to a LIP */
63 MPI_IOCLOGINFO_FC_TARGET_NO_CLASS_3 = 0x2100000b, /* not sent because remote node does not support Class 3 */
64 MPI_IOCLOGINFO_FC_TARGET_LOGIN_NOT_VALID = 0x2100000c, /* not sent because login to remote node not validated */
65 MPI_IOCLOGINFO_FC_TARGET_FROM_OUTBOUND = 0x2100000e, /* cleared from the outbound queue after a logout */
66 MPI_IOCLOGINFO_FC_TARGET_WAITING_FOR_DATA_IN = 0x2100000f, /* cleared waiting for data after a logout */
67
68 MPI_IOCLOGINFO_FC_LAN_BASE = 0x22000000,
69 MPI_IOCLOGINFO_FC_LAN_TRANS_SGL_MISSING = 0x22000001, /* Transaction Context Sgl Missing */
70 MPI_IOCLOGINFO_FC_LAN_TRANS_WRONG_PLACE = 0x22000002, /* Transaction Context found before an EOB */
71 MPI_IOCLOGINFO_FC_LAN_TRANS_RES_BITS_SET = 0x22000003, /* Transaction Context value has reserved bits set */
72 MPI_IOCLOGINFO_FC_LAN_WRONG_SGL_FLAG = 0x22000004, /* Invalid SGL Flags */
73
74 MPI_IOCLOGINFO_FC_MSG_BASE = 0x23000000,
75
76 MPI_IOCLOGINFO_FC_LINK_BASE = 0x24000000,
77 MPI_IOCLOGINFO_FC_LINK_LOOP_INIT_TIMEOUT = 0x24000001, /* Loop initialization timed out */
78 MPI_IOCLOGINFO_FC_LINK_ALREADY_INITIALIZED = 0x24000002, /* Another system controller already initialized the loop */
79 MPI_IOCLOGINFO_FC_LINK_LINK_NOT_ESTABLISHED = 0x24000003, /* Not synchronized to signal or still negotiating (possible cable problem) */
80 MPI_IOCLOGINFO_FC_LINK_CRC_ERROR = 0x24000004, /* CRC check detected error on received frame */
81
82 MPI_IOCLOGINFO_FC_CTX_BASE = 0x25000000,
83
84 MPI_IOCLOGINFO_FC_INVALID_FIELD_BYTE_OFFSET = 0x26000000, /* The lower 24 bits give the byte offset of the field in the request message that is invalid */
85 MPI_IOCLOGINFO_FC_INVALID_FIELD_MAX_OFFSET = 0x26ffffff,
86
87 MPI_IOCLOGINFO_FC_STATE_CHANGE = 0x27000000 /* The lower 24 bits give additional information concerning state change */
88
89} MpiIocLogInfoFc_t;
diff --git a/drivers/message/fusion/lsi/mpi.h b/drivers/message/fusion/lsi/mpi.h
index 02cdc840a06b..81ad77622dac 100644
--- a/drivers/message/fusion/lsi/mpi.h
+++ b/drivers/message/fusion/lsi/mpi.h
@@ -6,7 +6,7 @@
6 * Title: MPI Message independent structures and definitions 6 * Title: MPI Message independent structures and definitions
7 * Creation Date: July 27, 2000 7 * Creation Date: July 27, 2000
8 * 8 *
9 * mpi.h Version: 01.05.10 9 * mpi.h Version: 01.05.11
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -76,6 +76,7 @@
76 * Added EEDP IOCStatus codes. 76 * Added EEDP IOCStatus codes.
77 * 08-03-05 01.05.09 Bumped MPI_HEADER_VERSION_UNIT. 77 * 08-03-05 01.05.09 Bumped MPI_HEADER_VERSION_UNIT.
78 * 08-30-05 01.05.10 Added 2 new IOCStatus codes for Target. 78 * 08-30-05 01.05.10 Added 2 new IOCStatus codes for Target.
79 * 03-27-06 01.05.11 Bumped MPI_HEADER_VERSION_UNIT.
79 * -------------------------------------------------------------------------- 80 * --------------------------------------------------------------------------
80 */ 81 */
81 82
@@ -106,7 +107,7 @@
106/* Note: The major versions of 0xe0 through 0xff are reserved */ 107/* Note: The major versions of 0xe0 through 0xff are reserved */
107 108
108/* versioning for this MPI header set */ 109/* versioning for this MPI header set */
109#define MPI_HEADER_VERSION_UNIT (0x0C) 110#define MPI_HEADER_VERSION_UNIT (0x0D)
110#define MPI_HEADER_VERSION_DEV (0x00) 111#define MPI_HEADER_VERSION_DEV (0x00)
111#define MPI_HEADER_VERSION_UNIT_MASK (0xFF00) 112#define MPI_HEADER_VERSION_UNIT_MASK (0xFF00)
112#define MPI_HEADER_VERSION_UNIT_SHIFT (8) 113#define MPI_HEADER_VERSION_UNIT_SHIFT (8)
diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h
index b1becec27e1b..47e13e360c10 100644
--- a/drivers/message/fusion/lsi/mpi_cnfg.h
+++ b/drivers/message/fusion/lsi/mpi_cnfg.h
@@ -6,7 +6,7 @@
6 * Title: MPI Config message, structures, and Pages 6 * Title: MPI Config message, structures, and Pages
7 * Creation Date: July 27, 2000 7 * Creation Date: July 27, 2000
8 * 8 *
9 * mpi_cnfg.h Version: 01.05.11 9 * mpi_cnfg.h Version: 01.05.12
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -266,6 +266,16 @@
266 * Added postpone SATA Init bit to SAS IO Unit Page 1 266 * Added postpone SATA Init bit to SAS IO Unit Page 1
267 * ControlFlags. 267 * ControlFlags.
268 * Changed LogEntry format for Log Page 0. 268 * Changed LogEntry format for Log Page 0.
269 * 03-27-06 01.05.12 Added two new Flags defines for Manufacturing Page 4.
270 * Added Manufacturing Page 7.
271 * Added MPI_IOCPAGE2_CAP_FLAGS_RAID_64_BIT_ADDRESSING.
272 * Added IOC Page 6.
273 * Added PrevBootDeviceForm field to CONFIG_PAGE_BIOS_2.
274 * Added MaxLBAHigh field to RAID Volume Page 0.
275 * Added Nvdata version fields to SAS IO Unit Page 0.
276 * Added AdditionalControlFlags, MaxTargetPortConnectTime,
277 * ReportDeviceMissingDelay, and IODeviceMissingDelay
278 * fields to SAS IO Unit Page 1.
269 * -------------------------------------------------------------------------- 279 * --------------------------------------------------------------------------
270 */ 280 */
271 281
@@ -631,9 +641,11 @@ typedef struct _CONFIG_PAGE_MANUFACTURING_4
631} CONFIG_PAGE_MANUFACTURING_4, MPI_POINTER PTR_CONFIG_PAGE_MANUFACTURING_4, 641} CONFIG_PAGE_MANUFACTURING_4, MPI_POINTER PTR_CONFIG_PAGE_MANUFACTURING_4,
632 ManufacturingPage4_t, MPI_POINTER pManufacturingPage4_t; 642 ManufacturingPage4_t, MPI_POINTER pManufacturingPage4_t;
633 643
634#define MPI_MANUFACTURING4_PAGEVERSION (0x03) 644#define MPI_MANUFACTURING4_PAGEVERSION (0x04)
635 645
636/* defines for the Flags field */ 646/* defines for the Flags field */
647#define MPI_MANPAGE4_FORCE_BAD_BLOCK_TABLE (0x80)
648#define MPI_MANPAGE4_FORCE_OFFLINE_FAILOVER (0x40)
637#define MPI_MANPAGE4_IME_DISABLE (0x20) 649#define MPI_MANPAGE4_IME_DISABLE (0x20)
638#define MPI_MANPAGE4_IM_DISABLE (0x10) 650#define MPI_MANPAGE4_IM_DISABLE (0x10)
639#define MPI_MANPAGE4_IS_DISABLE (0x08) 651#define MPI_MANPAGE4_IS_DISABLE (0x08)
@@ -668,6 +680,66 @@ typedef struct _CONFIG_PAGE_MANUFACTURING_6
668#define MPI_MANUFACTURING6_PAGEVERSION (0x00) 680#define MPI_MANUFACTURING6_PAGEVERSION (0x00)
669 681
670 682
683typedef struct _MPI_MANPAGE7_CONNECTOR_INFO
684{
685 U32 Pinout; /* 00h */
686 U8 Connector[16]; /* 04h */
687 U8 Location; /* 14h */
688 U8 Reserved1; /* 15h */
689 U16 Slot; /* 16h */
690 U32 Reserved2; /* 18h */
691} MPI_MANPAGE7_CONNECTOR_INFO, MPI_POINTER PTR_MPI_MANPAGE7_CONNECTOR_INFO,
692 MpiManPage7ConnectorInfo_t, MPI_POINTER pMpiManPage7ConnectorInfo_t;
693
694/* defines for the Pinout field */
695#define MPI_MANPAGE7_PINOUT_SFF_8484_L4 (0x00080000)
696#define MPI_MANPAGE7_PINOUT_SFF_8484_L3 (0x00040000)
697#define MPI_MANPAGE7_PINOUT_SFF_8484_L2 (0x00020000)
698#define MPI_MANPAGE7_PINOUT_SFF_8484_L1 (0x00010000)
699#define MPI_MANPAGE7_PINOUT_SFF_8470_L4 (0x00000800)
700#define MPI_MANPAGE7_PINOUT_SFF_8470_L3 (0x00000400)
701#define MPI_MANPAGE7_PINOUT_SFF_8470_L2 (0x00000200)
702#define MPI_MANPAGE7_PINOUT_SFF_8470_L1 (0x00000100)
703#define MPI_MANPAGE7_PINOUT_SFF_8482 (0x00000002)
704#define MPI_MANPAGE7_PINOUT_CONNECTION_UNKNOWN (0x00000001)
705
706/* defines for the Location field */
707#define MPI_MANPAGE7_LOCATION_UNKNOWN (0x01)
708#define MPI_MANPAGE7_LOCATION_INTERNAL (0x02)
709#define MPI_MANPAGE7_LOCATION_EXTERNAL (0x04)
710#define MPI_MANPAGE7_LOCATION_SWITCHABLE (0x08)
711#define MPI_MANPAGE7_LOCATION_AUTO (0x10)
712#define MPI_MANPAGE7_LOCATION_NOT_PRESENT (0x20)
713#define MPI_MANPAGE7_LOCATION_NOT_CONNECTED (0x80)
714
715/*
716 * Host code (drivers, BIOS, utilities, etc.) should leave this define set to
717 * one and check NumPhys at runtime.
718 */
719#ifndef MPI_MANPAGE7_CONNECTOR_INFO_MAX
720#define MPI_MANPAGE7_CONNECTOR_INFO_MAX (1)
721#endif
722
723typedef struct _CONFIG_PAGE_MANUFACTURING_7
724{
725 CONFIG_PAGE_HEADER Header; /* 00h */
726 U32 Reserved1; /* 04h */
727 U32 Reserved2; /* 08h */
728 U32 Flags; /* 0Ch */
729 U8 EnclosureName[16]; /* 10h */
730 U8 NumPhys; /* 20h */
731 U8 Reserved3; /* 21h */
732 U16 Reserved4; /* 22h */
733 MPI_MANPAGE7_CONNECTOR_INFO ConnectorInfo[MPI_MANPAGE7_CONNECTOR_INFO_MAX]; /* 24h */
734} CONFIG_PAGE_MANUFACTURING_7, MPI_POINTER PTR_CONFIG_PAGE_MANUFACTURING_7,
735 ManufacturingPage7_t, MPI_POINTER pManufacturingPage7_t;
736
737#define MPI_MANUFACTURING7_PAGEVERSION (0x00)
738
739/* defines for the Flags field */
740#define MPI_MANPAGE7_FLAG_USE_SLOT_INFO (0x00000001)
741
742
671/**************************************************************************** 743/****************************************************************************
672* IO Unit Config Pages 744* IO Unit Config Pages
673****************************************************************************/ 745****************************************************************************/
@@ -867,7 +939,7 @@ typedef struct _CONFIG_PAGE_IOC_2
867} CONFIG_PAGE_IOC_2, MPI_POINTER PTR_CONFIG_PAGE_IOC_2, 939} CONFIG_PAGE_IOC_2, MPI_POINTER PTR_CONFIG_PAGE_IOC_2,
868 IOCPage2_t, MPI_POINTER pIOCPage2_t; 940 IOCPage2_t, MPI_POINTER pIOCPage2_t;
869 941
870#define MPI_IOCPAGE2_PAGEVERSION (0x03) 942#define MPI_IOCPAGE2_PAGEVERSION (0x04)
871 943
872/* IOC Page 2 Capabilities flags */ 944/* IOC Page 2 Capabilities flags */
873 945
@@ -878,6 +950,7 @@ typedef struct _CONFIG_PAGE_IOC_2
878#define MPI_IOCPAGE2_CAP_FLAGS_RAID_6_SUPPORT (0x00000010) 950#define MPI_IOCPAGE2_CAP_FLAGS_RAID_6_SUPPORT (0x00000010)
879#define MPI_IOCPAGE2_CAP_FLAGS_RAID_10_SUPPORT (0x00000020) 951#define MPI_IOCPAGE2_CAP_FLAGS_RAID_10_SUPPORT (0x00000020)
880#define MPI_IOCPAGE2_CAP_FLAGS_RAID_50_SUPPORT (0x00000040) 952#define MPI_IOCPAGE2_CAP_FLAGS_RAID_50_SUPPORT (0x00000040)
953#define MPI_IOCPAGE2_CAP_FLAGS_RAID_64_BIT_ADDRESSING (0x10000000)
881#define MPI_IOCPAGE2_CAP_FLAGS_SES_SUPPORT (0x20000000) 954#define MPI_IOCPAGE2_CAP_FLAGS_SES_SUPPORT (0x20000000)
882#define MPI_IOCPAGE2_CAP_FLAGS_SAFTE_SUPPORT (0x40000000) 955#define MPI_IOCPAGE2_CAP_FLAGS_SAFTE_SUPPORT (0x40000000)
883#define MPI_IOCPAGE2_CAP_FLAGS_CROSS_CHANNEL_SUPPORT (0x80000000) 956#define MPI_IOCPAGE2_CAP_FLAGS_CROSS_CHANNEL_SUPPORT (0x80000000)
@@ -975,6 +1048,44 @@ typedef struct _CONFIG_PAGE_IOC_5
975 1048
976#define MPI_IOCPAGE5_PAGEVERSION (0x00) 1049#define MPI_IOCPAGE5_PAGEVERSION (0x00)
977 1050
1051typedef struct _CONFIG_PAGE_IOC_6
1052{
1053 CONFIG_PAGE_HEADER Header; /* 00h */
1054 U32 CapabilitiesFlags; /* 04h */
1055 U8 MaxDrivesIS; /* 08h */
1056 U8 MaxDrivesIM; /* 09h */
1057 U8 MaxDrivesIME; /* 0Ah */
1058 U8 Reserved1; /* 0Bh */
1059 U8 MinDrivesIS; /* 0Ch */
1060 U8 MinDrivesIM; /* 0Dh */
1061 U8 MinDrivesIME; /* 0Eh */
1062 U8 Reserved2; /* 0Fh */
1063 U8 MaxGlobalHotSpares; /* 10h */
1064 U8 Reserved3; /* 11h */
1065 U16 Reserved4; /* 12h */
1066 U32 Reserved5; /* 14h */
1067 U32 SupportedStripeSizeMapIS; /* 18h */
1068 U32 SupportedStripeSizeMapIME; /* 1Ch */
1069 U32 Reserved6; /* 20h */
1070 U8 MetadataSize; /* 24h */
1071 U8 Reserved7; /* 25h */
1072 U16 Reserved8; /* 26h */
1073 U16 MaxBadBlockTableEntries; /* 28h */
1074 U16 Reserved9; /* 2Ah */
1075 U16 IRNvsramUsage; /* 2Ch */
1076 U16 Reserved10; /* 2Eh */
1077 U32 IRNvsramVersion; /* 30h */
1078 U32 Reserved11; /* 34h */
1079 U32 Reserved12; /* 38h */
1080} CONFIG_PAGE_IOC_6, MPI_POINTER PTR_CONFIG_PAGE_IOC_6,
1081 IOCPage6_t, MPI_POINTER pIOCPage6_t;
1082
1083#define MPI_IOCPAGE6_PAGEVERSION (0x00)
1084
1085/* IOC Page 6 Capabilities Flags */
1086
1087#define MPI_IOCPAGE6_CAP_FLAGS_GLOBAL_HOT_SPARE (0x00000001)
1088
978 1089
979/**************************************************************************** 1090/****************************************************************************
980* BIOS Config Pages 1091* BIOS Config Pages
@@ -1218,13 +1329,13 @@ typedef struct _CONFIG_PAGE_BIOS_2
1218 U32 Reserved5; /* 14h */ 1329 U32 Reserved5; /* 14h */
1219 U32 Reserved6; /* 18h */ 1330 U32 Reserved6; /* 18h */
1220 U8 BootDeviceForm; /* 1Ch */ 1331 U8 BootDeviceForm; /* 1Ch */
1221 U8 Reserved7; /* 1Dh */ 1332 U8 PrevBootDeviceForm; /* 1Ch */
1222 U16 Reserved8; /* 1Eh */ 1333 U16 Reserved8; /* 1Eh */
1223 MPI_BIOSPAGE2_BOOT_DEVICE BootDevice; /* 20h */ 1334 MPI_BIOSPAGE2_BOOT_DEVICE BootDevice; /* 20h */
1224} CONFIG_PAGE_BIOS_2, MPI_POINTER PTR_CONFIG_PAGE_BIOS_2, 1335} CONFIG_PAGE_BIOS_2, MPI_POINTER PTR_CONFIG_PAGE_BIOS_2,
1225 BIOSPage2_t, MPI_POINTER pBIOSPage2_t; 1336 BIOSPage2_t, MPI_POINTER pBIOSPage2_t;
1226 1337
1227#define MPI_BIOSPAGE2_PAGEVERSION (0x01) 1338#define MPI_BIOSPAGE2_PAGEVERSION (0x02)
1228 1339
1229#define MPI_BIOSPAGE2_FORM_MASK (0x0F) 1340#define MPI_BIOSPAGE2_FORM_MASK (0x0F)
1230#define MPI_BIOSPAGE2_FORM_ADAPTER_ORDER (0x00) 1341#define MPI_BIOSPAGE2_FORM_ADAPTER_ORDER (0x00)
@@ -2080,7 +2191,7 @@ typedef struct _CONFIG_PAGE_RAID_VOL_0
2080 RAID_VOL0_STATUS VolumeStatus; /* 08h */ 2191 RAID_VOL0_STATUS VolumeStatus; /* 08h */
2081 RAID_VOL0_SETTINGS VolumeSettings; /* 0Ch */ 2192 RAID_VOL0_SETTINGS VolumeSettings; /* 0Ch */
2082 U32 MaxLBA; /* 10h */ 2193 U32 MaxLBA; /* 10h */
2083 U32 Reserved1; /* 14h */ 2194 U32 MaxLBAHigh; /* 14h */
2084 U32 StripeSize; /* 18h */ 2195 U32 StripeSize; /* 18h */
2085 U32 Reserved2; /* 1Ch */ 2196 U32 Reserved2; /* 1Ch */
2086 U32 Reserved3; /* 20h */ 2197 U32 Reserved3; /* 20h */
@@ -2092,7 +2203,7 @@ typedef struct _CONFIG_PAGE_RAID_VOL_0
2092} CONFIG_PAGE_RAID_VOL_0, MPI_POINTER PTR_CONFIG_PAGE_RAID_VOL_0, 2203} CONFIG_PAGE_RAID_VOL_0, MPI_POINTER PTR_CONFIG_PAGE_RAID_VOL_0,
2093 RaidVolumePage0_t, MPI_POINTER pRaidVolumePage0_t; 2204 RaidVolumePage0_t, MPI_POINTER pRaidVolumePage0_t;
2094 2205
2095#define MPI_RAIDVOLPAGE0_PAGEVERSION (0x05) 2206#define MPI_RAIDVOLPAGE0_PAGEVERSION (0x06)
2096 2207
2097/* values for RAID Volume Page 0 InactiveStatus field */ 2208/* values for RAID Volume Page 0 InactiveStatus field */
2098#define MPI_RAIDVOLPAGE0_UNKNOWN_INACTIVE (0x00) 2209#define MPI_RAIDVOLPAGE0_UNKNOWN_INACTIVE (0x00)
@@ -2324,7 +2435,8 @@ typedef struct _MPI_SAS_IO_UNIT0_PHY_DATA
2324typedef struct _CONFIG_PAGE_SAS_IO_UNIT_0 2435typedef struct _CONFIG_PAGE_SAS_IO_UNIT_0
2325{ 2436{
2326 CONFIG_EXTENDED_PAGE_HEADER Header; /* 00h */ 2437 CONFIG_EXTENDED_PAGE_HEADER Header; /* 00h */
2327 U32 Reserved1; /* 08h */ 2438 U16 NvdataVersionDefault; /* 08h */
2439 U16 NvdataVersionPersistent; /* 0Ah */
2328 U8 NumPhys; /* 0Ch */ 2440 U8 NumPhys; /* 0Ch */
2329 U8 Reserved2; /* 0Dh */ 2441 U8 Reserved2; /* 0Dh */
2330 U16 Reserved3; /* 0Eh */ 2442 U16 Reserved3; /* 0Eh */
@@ -2332,7 +2444,7 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_0
2332} CONFIG_PAGE_SAS_IO_UNIT_0, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_0, 2444} CONFIG_PAGE_SAS_IO_UNIT_0, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_0,
2333 SasIOUnitPage0_t, MPI_POINTER pSasIOUnitPage0_t; 2445 SasIOUnitPage0_t, MPI_POINTER pSasIOUnitPage0_t;
2334 2446
2335#define MPI_SASIOUNITPAGE0_PAGEVERSION (0x03) 2447#define MPI_SASIOUNITPAGE0_PAGEVERSION (0x04)
2336 2448
2337/* values for SAS IO Unit Page 0 PortFlags */ 2449/* values for SAS IO Unit Page 0 PortFlags */
2338#define MPI_SAS_IOUNIT0_PORT_FLAGS_DISCOVERY_IN_PROGRESS (0x08) 2450#define MPI_SAS_IOUNIT0_PORT_FLAGS_DISCOVERY_IN_PROGRESS (0x08)
@@ -2373,12 +2485,13 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_0
2373 2485
2374typedef struct _MPI_SAS_IO_UNIT1_PHY_DATA 2486typedef struct _MPI_SAS_IO_UNIT1_PHY_DATA
2375{ 2487{
2376 U8 Port; /* 00h */ 2488 U8 Port; /* 00h */
2377 U8 PortFlags; /* 01h */ 2489 U8 PortFlags; /* 01h */
2378 U8 PhyFlags; /* 02h */ 2490 U8 PhyFlags; /* 02h */
2379 U8 MaxMinLinkRate; /* 03h */ 2491 U8 MaxMinLinkRate; /* 03h */
2380 U32 ControllerPhyDeviceInfo;/* 04h */ 2492 U32 ControllerPhyDeviceInfo; /* 04h */
2381 U32 Reserved1; /* 08h */ 2493 U16 MaxTargetPortConnectTime; /* 08h */
2494 U16 Reserved1; /* 0Ah */
2382} MPI_SAS_IO_UNIT1_PHY_DATA, MPI_POINTER PTR_MPI_SAS_IO_UNIT1_PHY_DATA, 2495} MPI_SAS_IO_UNIT1_PHY_DATA, MPI_POINTER PTR_MPI_SAS_IO_UNIT1_PHY_DATA,
2383 SasIOUnit1PhyData, MPI_POINTER pSasIOUnit1PhyData; 2496 SasIOUnit1PhyData, MPI_POINTER pSasIOUnit1PhyData;
2384 2497
@@ -2395,15 +2508,17 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_1
2395 CONFIG_EXTENDED_PAGE_HEADER Header; /* 00h */ 2508 CONFIG_EXTENDED_PAGE_HEADER Header; /* 00h */
2396 U16 ControlFlags; /* 08h */ 2509 U16 ControlFlags; /* 08h */
2397 U16 MaxNumSATATargets; /* 0Ah */ 2510 U16 MaxNumSATATargets; /* 0Ah */
2398 U32 Reserved1; /* 0Ch */ 2511 U16 AdditionalControlFlags; /* 0Ch */
2512 U16 Reserved1; /* 0Eh */
2399 U8 NumPhys; /* 10h */ 2513 U8 NumPhys; /* 10h */
2400 U8 SATAMaxQDepth; /* 11h */ 2514 U8 SATAMaxQDepth; /* 11h */
2401 U16 Reserved2; /* 12h */ 2515 U8 ReportDeviceMissingDelay; /* 12h */
2516 U8 IODeviceMissingDelay; /* 13h */
2402 MPI_SAS_IO_UNIT1_PHY_DATA PhyData[MPI_SAS_IOUNIT1_PHY_MAX]; /* 14h */ 2517 MPI_SAS_IO_UNIT1_PHY_DATA PhyData[MPI_SAS_IOUNIT1_PHY_MAX]; /* 14h */
2403} CONFIG_PAGE_SAS_IO_UNIT_1, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_1, 2518} CONFIG_PAGE_SAS_IO_UNIT_1, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_1,
2404 SasIOUnitPage1_t, MPI_POINTER pSasIOUnitPage1_t; 2519 SasIOUnitPage1_t, MPI_POINTER pSasIOUnitPage1_t;
2405 2520
2406#define MPI_SASIOUNITPAGE1_PAGEVERSION (0x05) 2521#define MPI_SASIOUNITPAGE1_PAGEVERSION (0x06)
2407 2522
2408/* values for SAS IO Unit Page 1 ControlFlags */ 2523/* values for SAS IO Unit Page 1 ControlFlags */
2409#define MPI_SAS_IOUNIT1_CONTROL_DEVICE_SELF_TEST (0x8000) 2524#define MPI_SAS_IOUNIT1_CONTROL_DEVICE_SELF_TEST (0x8000)
@@ -2428,6 +2543,13 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_1
2428#define MPI_SAS_IOUNIT1_CONTROL_FIRST_LVL_DISC_ONLY (0x0002) 2543#define MPI_SAS_IOUNIT1_CONTROL_FIRST_LVL_DISC_ONLY (0x0002)
2429#define MPI_SAS_IOUNIT1_CONTROL_CLEAR_AFFILIATION (0x0001) 2544#define MPI_SAS_IOUNIT1_CONTROL_CLEAR_AFFILIATION (0x0001)
2430 2545
2546/* values for SAS IO Unit Page 1 AdditionalControlFlags */
2547#define MPI_SAS_IOUNIT1_ACONTROL_ALLOW_TABLE_TO_TABLE (0x0001)
2548
2549/* defines for SAS IO Unit Page 1 ReportDeviceMissingDelay */
2550#define MPI_SAS_IOUNIT1_REPORT_MISSING_TIMEOUT_MASK (0x7F)
2551#define MPI_SAS_IOUNIT1_REPORT_MISSING_UNIT_16 (0x80)
2552
2431/* values for SAS IO Unit Page 1 PortFlags */ 2553/* values for SAS IO Unit Page 1 PortFlags */
2432#define MPI_SAS_IOUNIT1_PORT_FLAGS_0_TARGET_IOC_NUM (0x00) 2554#define MPI_SAS_IOUNIT1_PORT_FLAGS_0_TARGET_IOC_NUM (0x00)
2433#define MPI_SAS_IOUNIT1_PORT_FLAGS_1_TARGET_IOC_NUM (0x04) 2555#define MPI_SAS_IOUNIT1_PORT_FLAGS_1_TARGET_IOC_NUM (0x04)
diff --git a/drivers/message/fusion/lsi/mpi_history.txt b/drivers/message/fusion/lsi/mpi_history.txt
index 4a5f8dd1d766..582cfe7c2aa1 100644
--- a/drivers/message/fusion/lsi/mpi_history.txt
+++ b/drivers/message/fusion/lsi/mpi_history.txt
@@ -6,25 +6,25 @@
6 Copyright (c) 2000-2005 LSI Logic Corporation. 6 Copyright (c) 2000-2005 LSI Logic Corporation.
7 7
8 --------------------------------------- 8 ---------------------------------------
9 Header Set Release Version: 01.05.12 9 Header Set Release Version: 01.05.13
10 Header Set Release Date: 08-30-05 10 Header Set Release Date: 03-27-06
11 --------------------------------------- 11 ---------------------------------------
12 12
13 Filename Current version Prior version 13 Filename Current version Prior version
14 ---------- --------------- ------------- 14 ---------- --------------- -------------
15 mpi.h 01.05.10 01.05.09 15 mpi.h 01.05.11 01.05.10
16 mpi_ioc.h 01.05.10 01.05.09 16 mpi_ioc.h 01.05.11 01.05.10
17 mpi_cnfg.h 01.05.11 01.05.10 17 mpi_cnfg.h 01.05.12 01.05.11
18 mpi_init.h 01.05.06 01.05.06 18 mpi_init.h 01.05.07 01.05.06
19 mpi_targ.h 01.05.05 01.05.05 19 mpi_targ.h 01.05.06 01.05.05
20 mpi_fc.h 01.05.01 01.05.01 20 mpi_fc.h 01.05.01 01.05.01
21 mpi_lan.h 01.05.01 01.05.01 21 mpi_lan.h 01.05.01 01.05.01
22 mpi_raid.h 01.05.02 01.05.02 22 mpi_raid.h 01.05.02 01.05.02
23 mpi_tool.h 01.05.03 01.05.03 23 mpi_tool.h 01.05.03 01.05.03
24 mpi_inb.h 01.05.01 01.05.01 24 mpi_inb.h 01.05.01 01.05.01
25 mpi_sas.h 01.05.02 01.05.01 25 mpi_sas.h 01.05.03 01.05.02
26 mpi_type.h 01.05.02 01.05.01 26 mpi_type.h 01.05.02 01.05.02
27 mpi_history.txt 01.05.12 01.05.11 27 mpi_history.txt 01.05.13 01.05.12
28 28
29 29
30 * Date Version Description 30 * Date Version Description
@@ -93,6 +93,7 @@ mpi.h
93 * Added EEDP IOCStatus codes. 93 * Added EEDP IOCStatus codes.
94 * 08-03-05 01.05.09 Bumped MPI_HEADER_VERSION_UNIT. 94 * 08-03-05 01.05.09 Bumped MPI_HEADER_VERSION_UNIT.
95 * 08-30-05 01.05.10 Added 2 new IOCStatus codes for Target. 95 * 08-30-05 01.05.10 Added 2 new IOCStatus codes for Target.
96 * 03-27-06 01.05.11 Bumped MPI_HEADER_VERSION_UNIT.
96 * -------------------------------------------------------------------------- 97 * --------------------------------------------------------------------------
97 98
98mpi_ioc.h 99mpi_ioc.h
@@ -170,6 +171,17 @@ mpi_ioc.h
170 * Added new ReasonCode value for SAS Device Status Change 171 * Added new ReasonCode value for SAS Device Status Change
171 * event. 172 * event.
172 * Added new family code for FC949E. 173 * Added new family code for FC949E.
174 * 03-27-06 01.05.11 Added MPI_IOCFACTS_CAPABILITY_TLR.
175 * Added additional Reason Codes and more event data fields
176 * to EVENT_DATA_SAS_DEVICE_STATUS_CHANGE.
177 * Added EVENT_DATA_SAS_BROADCAST_PRIMITIVE structure and
178 * new event.
179 * Added MPI_EVENT_SAS_SMP_ERROR and event data structure.
180 * Added MPI_EVENT_SAS_INIT_DEVICE_STATUS_CHANGE and event
181 * data structure.
182 * Added MPI_EVENT_SAS_INIT_TABLE_OVERFLOW and event
183 * data structure.
184 * Added MPI_EXT_IMAGE_TYPE_INITIALIZATION.
173 * -------------------------------------------------------------------------- 185 * --------------------------------------------------------------------------
174 186
175mpi_cnfg.h 187mpi_cnfg.h
@@ -425,6 +437,16 @@ mpi_cnfg.h
425 * Added postpone SATA Init bit to SAS IO Unit Page 1 437 * Added postpone SATA Init bit to SAS IO Unit Page 1
426 * ControlFlags. 438 * ControlFlags.
427 * Changed LogEntry format for Log Page 0. 439 * Changed LogEntry format for Log Page 0.
440 * 03-27-06 01.05.12 Added two new Flags defines for Manufacturing Page 4.
441 * Added Manufacturing Page 7.
442 * Added MPI_IOCPAGE2_CAP_FLAGS_RAID_64_BIT_ADDRESSING.
443 * Added IOC Page 6.
444 * Added PrevBootDeviceForm field to CONFIG_PAGE_BIOS_2.
445 * Added MaxLBAHigh field to RAID Volume Page 0.
446 * Added Nvdata version fields to SAS IO Unit Page 0.
447 * Added AdditionalControlFlags, MaxTargetPortConnectTime,
448 * ReportDeviceMissingDelay, and IODeviceMissingDelay
449 * fields to SAS IO Unit Page 1.
428 * -------------------------------------------------------------------------- 450 * --------------------------------------------------------------------------
429 451
430mpi_init.h 452mpi_init.h
@@ -467,6 +489,7 @@ mpi_init.h
467 * Added four new defines for SEP SlotStatus. 489 * Added four new defines for SEP SlotStatus.
468 * 08-03-05 01.05.06 Fixed some MPI_SCSIIO32_MSGFLGS_ defines to make them 490 * 08-03-05 01.05.06 Fixed some MPI_SCSIIO32_MSGFLGS_ defines to make them
469 * unique in the first 32 characters. 491 * unique in the first 32 characters.
492 * 03-27-06 01.05.07 Added Task Management type of Clear ACA.
470 * -------------------------------------------------------------------------- 493 * --------------------------------------------------------------------------
471 494
472mpi_targ.h 495mpi_targ.h
@@ -511,6 +534,7 @@ mpi_targ.h
511 * 02-22-05 01.05.03 Changed a comment. 534 * 02-22-05 01.05.03 Changed a comment.
512 * 03-11-05 01.05.04 Removed TargetAssistExtended Request. 535 * 03-11-05 01.05.04 Removed TargetAssistExtended Request.
513 * 06-24-05 01.05.05 Added TargetAssistExtended structures and defines. 536 * 06-24-05 01.05.05 Added TargetAssistExtended structures and defines.
537 * 03-27-06 01.05.06 Added a comment.
514 * -------------------------------------------------------------------------- 538 * --------------------------------------------------------------------------
515 539
516mpi_fc.h 540mpi_fc.h
@@ -610,6 +634,10 @@ mpi_sas.h
610 * 08-30-05 01.05.02 Added DeviceInfo bit for SEP. 634 * 08-30-05 01.05.02 Added DeviceInfo bit for SEP.
611 * Added PrimFlags and Primitive field to SAS IO Unit 635 * Added PrimFlags and Primitive field to SAS IO Unit
612 * Control request, and added a new operation code. 636 * Control request, and added a new operation code.
637 * 03-27-06 01.05.03 Added Force Full Discovery, Transmit Port Select Signal,
638 * and Remove Device operations to SAS IO Unit Control.
639 * Added DevHandle field to SAS IO Unit Control request and
640 * reply.
613 * -------------------------------------------------------------------------- 641 * --------------------------------------------------------------------------
614 642
615mpi_type.h 643mpi_type.h
@@ -625,20 +653,20 @@ mpi_type.h
625 653
626mpi_history.txt Parts list history 654mpi_history.txt Parts list history
627 655
628Filename 01.05.12 01.05.11 01.05.10 01.05.09 656Filename 01.05.13 01.05.12 01.05.11 01.05.10 01.05.09
629---------- -------- -------- -------- -------- 657---------- -------- -------- -------- -------- --------
630mpi.h 01.05.10 01.05.09 01.05.08 01.05.07 658mpi.h 01.05.11 01.05.10 01.05.09 01.05.08 01.05.07
631mpi_ioc.h 01.05.10 01.05.09 01.05.09 01.05.08 659mpi_ioc.h 01.05.11 01.05.10 01.05.09 01.05.09 01.05.08
632mpi_cnfg.h 01.05.11 01.05.10 01.05.09 01.05.08 660mpi_cnfg.h 01.05.12 01.05.11 01.05.10 01.05.09 01.05.08
633mpi_init.h 01.05.06 01.05.06 01.05.05 01.05.04 661mpi_init.h 01.05.07 01.05.06 01.05.06 01.05.05 01.05.04
634mpi_targ.h 01.05.05 01.05.05 01.05.05 01.05.04 662mpi_targ.h 01.05.06 01.05.05 01.05.05 01.05.05 01.05.04
635mpi_fc.h 01.05.01 01.05.01 01.05.01 01.05.01 663mpi_fc.h 01.05.01 01.05.01 01.05.01 01.05.01 01.05.01
636mpi_lan.h 01.05.01 01.05.01 01.05.01 01.05.01 664mpi_lan.h 01.05.01 01.05.01 01.05.01 01.05.01 01.05.01
637mpi_raid.h 01.05.02 01.05.02 01.05.02 01.05.02 665mpi_raid.h 01.05.02 01.05.02 01.05.02 01.05.02 01.05.02
638mpi_tool.h 01.05.03 01.05.03 01.05.03 01.05.03 666mpi_tool.h 01.05.03 01.05.03 01.05.03 01.05.03 01.05.03
639mpi_inb.h 01.05.01 01.05.01 01.05.01 01.05.01 667mpi_inb.h 01.05.01 01.05.01 01.05.01 01.05.01 01.05.01
640mpi_sas.h 01.05.02 01.05.01 01.05.01 01.05.01 668mpi_sas.h 01.05.03 01.05.02 01.05.01 01.05.01 01.05.01
641mpi_type.h 01.05.02 01.05.01 01.05.01 01.05.01 669mpi_type.h 01.05.02 01.05.02 01.05.01 01.05.01 01.05.01
642 670
643Filename 01.05.08 01.05.07 01.05.06 01.05.05 01.05.04 01.05.03 671Filename 01.05.08 01.05.07 01.05.06 01.05.05 01.05.04 01.05.03
644---------- -------- -------- -------- -------- -------- -------- 672---------- -------- -------- -------- -------- -------- --------
diff --git a/drivers/message/fusion/lsi/mpi_init.h b/drivers/message/fusion/lsi/mpi_init.h
index 68941f459ca3..c1c678989a23 100644
--- a/drivers/message/fusion/lsi/mpi_init.h
+++ b/drivers/message/fusion/lsi/mpi_init.h
@@ -6,7 +6,7 @@
6 * Title: MPI initiator mode messages and structures 6 * Title: MPI initiator mode messages and structures
7 * Creation Date: June 8, 2000 7 * Creation Date: June 8, 2000
8 * 8 *
9 * mpi_init.h Version: 01.05.06 9 * mpi_init.h Version: 01.05.07
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -52,6 +52,7 @@
52 * Added four new defines for SEP SlotStatus. 52 * Added four new defines for SEP SlotStatus.
53 * 08-03-05 01.05.06 Fixed some MPI_SCSIIO32_MSGFLGS_ defines to make them 53 * 08-03-05 01.05.06 Fixed some MPI_SCSIIO32_MSGFLGS_ defines to make them
54 * unique in the first 32 characters. 54 * unique in the first 32 characters.
55 * 03-27-06 01.05.07 Added Task Management type of Clear ACA.
55 * -------------------------------------------------------------------------- 56 * --------------------------------------------------------------------------
56 */ 57 */
57 58
@@ -427,6 +428,7 @@ typedef struct _MSG_SCSI_TASK_MGMT
427#define MPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET (0x05) 428#define MPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET (0x05)
428#define MPI_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET (0x06) 429#define MPI_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET (0x06)
429#define MPI_SCSITASKMGMT_TASKTYPE_QUERY_TASK (0x07) 430#define MPI_SCSITASKMGMT_TASKTYPE_QUERY_TASK (0x07)
431#define MPI_SCSITASKMGMT_TASKTYPE_CLEAR_ACA (0x08)
430 432
431/* MsgFlags bits */ 433/* MsgFlags bits */
432#define MPI_SCSITASKMGMT_MSGFLAGS_TARGET_RESET_OPTION (0x00) 434#define MPI_SCSITASKMGMT_MSGFLAGS_TARGET_RESET_OPTION (0x00)
diff --git a/drivers/message/fusion/lsi/mpi_ioc.h b/drivers/message/fusion/lsi/mpi_ioc.h
index 2c5f43fa7c73..18ba407fd399 100644
--- a/drivers/message/fusion/lsi/mpi_ioc.h
+++ b/drivers/message/fusion/lsi/mpi_ioc.h
@@ -6,7 +6,7 @@
6 * Title: MPI IOC, Port, Event, FW Download, and FW Upload messages 6 * Title: MPI IOC, Port, Event, FW Download, and FW Upload messages
7 * Creation Date: August 11, 2000 7 * Creation Date: August 11, 2000
8 * 8 *
9 * mpi_ioc.h Version: 01.05.10 9 * mpi_ioc.h Version: 01.05.11
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -87,6 +87,17 @@
87 * Added new ReasonCode value for SAS Device Status Change 87 * Added new ReasonCode value for SAS Device Status Change
88 * event. 88 * event.
89 * Added new family code for FC949E. 89 * Added new family code for FC949E.
90 * 03-27-06 01.05.11 Added MPI_IOCFACTS_CAPABILITY_TLR.
91 * Added additional Reason Codes and more event data fields
92 * to EVENT_DATA_SAS_DEVICE_STATUS_CHANGE.
93 * Added EVENT_DATA_SAS_BROADCAST_PRIMITIVE structure and
94 * new event.
95 * Added MPI_EVENT_SAS_SMP_ERROR and event data structure.
96 * Added MPI_EVENT_SAS_INIT_DEVICE_STATUS_CHANGE and event
97 * data structure.
98 * Added MPI_EVENT_SAS_INIT_TABLE_OVERFLOW and event
99 * data structure.
100 * Added MPI_EXT_IMAGE_TYPE_INITIALIZATION.
90 * -------------------------------------------------------------------------- 101 * --------------------------------------------------------------------------
91 */ 102 */
92 103
@@ -272,6 +283,7 @@ typedef struct _MSG_IOC_FACTS_REPLY
272#define MPI_IOCFACTS_CAPABILITY_MULTICAST (0x00000100) 283#define MPI_IOCFACTS_CAPABILITY_MULTICAST (0x00000100)
273#define MPI_IOCFACTS_CAPABILITY_SCSIIO32 (0x00000200) 284#define MPI_IOCFACTS_CAPABILITY_SCSIIO32 (0x00000200)
274#define MPI_IOCFACTS_CAPABILITY_NO_SCSIIO16 (0x00000400) 285#define MPI_IOCFACTS_CAPABILITY_NO_SCSIIO16 (0x00000400)
286#define MPI_IOCFACTS_CAPABILITY_TLR (0x00000800)
275 287
276 288
277/***************************************************************************** 289/*****************************************************************************
@@ -448,30 +460,34 @@ typedef struct _MSG_EVENT_ACK_REPLY
448 460
449/* Event */ 461/* Event */
450 462
451#define MPI_EVENT_NONE (0x00000000) 463#define MPI_EVENT_NONE (0x00000000)
452#define MPI_EVENT_LOG_DATA (0x00000001) 464#define MPI_EVENT_LOG_DATA (0x00000001)
453#define MPI_EVENT_STATE_CHANGE (0x00000002) 465#define MPI_EVENT_STATE_CHANGE (0x00000002)
454#define MPI_EVENT_UNIT_ATTENTION (0x00000003) 466#define MPI_EVENT_UNIT_ATTENTION (0x00000003)
455#define MPI_EVENT_IOC_BUS_RESET (0x00000004) 467#define MPI_EVENT_IOC_BUS_RESET (0x00000004)
456#define MPI_EVENT_EXT_BUS_RESET (0x00000005) 468#define MPI_EVENT_EXT_BUS_RESET (0x00000005)
457#define MPI_EVENT_RESCAN (0x00000006) 469#define MPI_EVENT_RESCAN (0x00000006)
458#define MPI_EVENT_LINK_STATUS_CHANGE (0x00000007) 470#define MPI_EVENT_LINK_STATUS_CHANGE (0x00000007)
459#define MPI_EVENT_LOOP_STATE_CHANGE (0x00000008) 471#define MPI_EVENT_LOOP_STATE_CHANGE (0x00000008)
460#define MPI_EVENT_LOGOUT (0x00000009) 472#define MPI_EVENT_LOGOUT (0x00000009)
461#define MPI_EVENT_EVENT_CHANGE (0x0000000A) 473#define MPI_EVENT_EVENT_CHANGE (0x0000000A)
462#define MPI_EVENT_INTEGRATED_RAID (0x0000000B) 474#define MPI_EVENT_INTEGRATED_RAID (0x0000000B)
463#define MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE (0x0000000C) 475#define MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE (0x0000000C)
464#define MPI_EVENT_ON_BUS_TIMER_EXPIRED (0x0000000D) 476#define MPI_EVENT_ON_BUS_TIMER_EXPIRED (0x0000000D)
465#define MPI_EVENT_QUEUE_FULL (0x0000000E) 477#define MPI_EVENT_QUEUE_FULL (0x0000000E)
466#define MPI_EVENT_SAS_DEVICE_STATUS_CHANGE (0x0000000F) 478#define MPI_EVENT_SAS_DEVICE_STATUS_CHANGE (0x0000000F)
467#define MPI_EVENT_SAS_SES (0x00000010) 479#define MPI_EVENT_SAS_SES (0x00000010)
468#define MPI_EVENT_PERSISTENT_TABLE_FULL (0x00000011) 480#define MPI_EVENT_PERSISTENT_TABLE_FULL (0x00000011)
469#define MPI_EVENT_SAS_PHY_LINK_STATUS (0x00000012) 481#define MPI_EVENT_SAS_PHY_LINK_STATUS (0x00000012)
470#define MPI_EVENT_SAS_DISCOVERY_ERROR (0x00000013) 482#define MPI_EVENT_SAS_DISCOVERY_ERROR (0x00000013)
471#define MPI_EVENT_IR_RESYNC_UPDATE (0x00000014) 483#define MPI_EVENT_IR_RESYNC_UPDATE (0x00000014)
472#define MPI_EVENT_IR2 (0x00000015) 484#define MPI_EVENT_IR2 (0x00000015)
473#define MPI_EVENT_SAS_DISCOVERY (0x00000016) 485#define MPI_EVENT_SAS_DISCOVERY (0x00000016)
474#define MPI_EVENT_LOG_ENTRY_ADDED (0x00000021) 486#define MPI_EVENT_SAS_BROADCAST_PRIMITIVE (0x00000017)
487#define MPI_EVENT_SAS_INIT_DEVICE_STATUS_CHANGE (0x00000018)
488#define MPI_EVENT_SAS_INIT_TABLE_OVERFLOW (0x00000019)
489#define MPI_EVENT_SAS_SMP_ERROR (0x0000001A)
490#define MPI_EVENT_LOG_ENTRY_ADDED (0x00000021)
475 491
476/* AckRequired field values */ 492/* AckRequired field values */
477 493
@@ -558,18 +574,25 @@ typedef struct _EVENT_DATA_SAS_DEVICE_STATUS_CHANGE
558 U8 PhyNum; /* 0Eh */ 574 U8 PhyNum; /* 0Eh */
559 U8 Reserved1; /* 0Fh */ 575 U8 Reserved1; /* 0Fh */
560 U64 SASAddress; /* 10h */ 576 U64 SASAddress; /* 10h */
577 U8 LUN[8]; /* 18h */
578 U16 TaskTag; /* 20h */
579 U16 Reserved2; /* 22h */
561} EVENT_DATA_SAS_DEVICE_STATUS_CHANGE, 580} EVENT_DATA_SAS_DEVICE_STATUS_CHANGE,
562 MPI_POINTER PTR_EVENT_DATA_SAS_DEVICE_STATUS_CHANGE, 581 MPI_POINTER PTR_EVENT_DATA_SAS_DEVICE_STATUS_CHANGE,
563 MpiEventDataSasDeviceStatusChange_t, 582 MpiEventDataSasDeviceStatusChange_t,
564 MPI_POINTER pMpiEventDataSasDeviceStatusChange_t; 583 MPI_POINTER pMpiEventDataSasDeviceStatusChange_t;
565 584
566/* MPI SAS Device Status Change Event data ReasonCode values */ 585/* MPI SAS Device Status Change Event data ReasonCode values */
567#define MPI_EVENT_SAS_DEV_STAT_RC_ADDED (0x03) 586#define MPI_EVENT_SAS_DEV_STAT_RC_ADDED (0x03)
568#define MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING (0x04) 587#define MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING (0x04)
569#define MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA (0x05) 588#define MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA (0x05)
570#define MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED (0x06) 589#define MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED (0x06)
571#define MPI_EVENT_SAS_DEV_STAT_RC_UNSUPPORTED (0x07) 590#define MPI_EVENT_SAS_DEV_STAT_RC_UNSUPPORTED (0x07)
572#define MPI_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET (0x08) 591#define MPI_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET (0x08)
592#define MPI_EVENT_SAS_DEV_STAT_RC_TASK_ABORT_INTERNAL (0x09)
593#define MPI_EVENT_SAS_DEV_STAT_RC_ABORT_TASK_SET_INTERNAL (0x0A)
594#define MPI_EVENT_SAS_DEV_STAT_RC_CLEAR_TASK_SET_INTERNAL (0x0B)
595#define MPI_EVENT_SAS_DEV_STAT_RC_QUERY_TASK_INTERNAL (0x0C)
573 596
574 597
575/* SCSI Event data for Queue Full event */ 598/* SCSI Event data for Queue Full event */
@@ -742,6 +765,27 @@ typedef struct _EVENT_DATA_SAS_SES
742} EVENT_DATA_SAS_SES, MPI_POINTER PTR_EVENT_DATA_SAS_SES, 765} EVENT_DATA_SAS_SES, MPI_POINTER PTR_EVENT_DATA_SAS_SES,
743 MpiEventDataSasSes_t, MPI_POINTER pMpiEventDataSasSes_t; 766 MpiEventDataSasSes_t, MPI_POINTER pMpiEventDataSasSes_t;
744 767
768/* SAS Broadcast Primitive Event data */
769
770typedef struct _EVENT_DATA_SAS_BROADCAST_PRIMITIVE
771{
772 U8 PhyNum; /* 00h */
773 U8 Port; /* 01h */
774 U8 PortWidth; /* 02h */
775 U8 Primitive; /* 04h */
776} EVENT_DATA_SAS_BROADCAST_PRIMITIVE,
777 MPI_POINTER PTR_EVENT_DATA_SAS_BROADCAST_PRIMITIVE,
778 MpiEventDataSasBroadcastPrimitive_t,
779 MPI_POINTER pMpiEventDataSasBroadcastPrimitive_t;
780
781#define MPI_EVENT_PRIMITIVE_CHANGE (0x01)
782#define MPI_EVENT_PRIMITIVE_EXPANDER (0x03)
783#define MPI_EVENT_PRIMITIVE_RESERVED2 (0x04)
784#define MPI_EVENT_PRIMITIVE_RESERVED3 (0x05)
785#define MPI_EVENT_PRIMITIVE_RESERVED4 (0x06)
786#define MPI_EVENT_PRIMITIVE_CHANGE0_RESERVED (0x07)
787#define MPI_EVENT_PRIMITIVE_CHANGE1_RESERVED (0x08)
788
745/* SAS Phy Link Status Event data */ 789/* SAS Phy Link Status Event data */
746 790
747typedef struct _EVENT_DATA_SAS_PHY_LINK_STATUS 791typedef struct _EVENT_DATA_SAS_PHY_LINK_STATUS
@@ -804,6 +848,53 @@ typedef struct _EVENT_DATA_DISCOVERY_ERROR
804#define MPI_EVENT_DSCVRY_ERR_DS_MULTPL_PATHS (0x00000800) 848#define MPI_EVENT_DSCVRY_ERR_DS_MULTPL_PATHS (0x00000800)
805#define MPI_EVENT_DSCVRY_ERR_DS_MAX_SATA_TARGETS (0x00001000) 849#define MPI_EVENT_DSCVRY_ERR_DS_MAX_SATA_TARGETS (0x00001000)
806 850
851/* SAS SMP Error Event data */
852
853typedef struct _EVENT_DATA_SAS_SMP_ERROR
854{
855 U8 Status; /* 00h */
856 U8 Port; /* 01h */
857 U8 SMPFunctionResult; /* 02h */
858 U8 Reserved1; /* 03h */
859 U64 SASAddress; /* 04h */
860} EVENT_DATA_SAS_SMP_ERROR, MPI_POINTER PTR_EVENT_DATA_SAS_SMP_ERROR,
861 MpiEventDataSasSmpError_t, MPI_POINTER pMpiEventDataSasSmpError_t;
862
863/* defines for the Status field of the SAS SMP Error event */
864#define MPI_EVENT_SAS_SMP_FUNCTION_RESULT_VALID (0x00)
865#define MPI_EVENT_SAS_SMP_CRC_ERROR (0x01)
866#define MPI_EVENT_SAS_SMP_TIMEOUT (0x02)
867#define MPI_EVENT_SAS_SMP_NO_DESTINATION (0x03)
868#define MPI_EVENT_SAS_SMP_BAD_DESTINATION (0x04)
869
870/* SAS Initiator Device Status Change Event data */
871
872typedef struct _EVENT_DATA_SAS_INIT_DEV_STATUS_CHANGE
873{
874 U8 ReasonCode; /* 00h */
875 U8 Port; /* 01h */
876 U16 DevHandle; /* 02h */
877 U64 SASAddress; /* 04h */
878} EVENT_DATA_SAS_INIT_DEV_STATUS_CHANGE,
879 MPI_POINTER PTR_EVENT_DATA_SAS_INIT_DEV_STATUS_CHANGE,
880 MpiEventDataSasInitDevStatusChange_t,
881 MPI_POINTER pMpiEventDataSasInitDevStatusChange_t;
882
883/* defines for the ReasonCode field of the SAS Initiator Device Status Change event */
884#define MPI_EVENT_SAS_INIT_RC_ADDED (0x01)
885
886/* SAS Initiator Device Table Overflow Event data */
887
888typedef struct _EVENT_DATA_SAS_INIT_TABLE_OVERFLOW
889{
890 U8 MaxInit; /* 00h */
891 U8 CurrentInit; /* 01h */
892 U16 Reserved1; /* 02h */
893} EVENT_DATA_SAS_INIT_TABLE_OVERFLOW,
894 MPI_POINTER PTR_EVENT_DATA_SAS_INIT_TABLE_OVERFLOW,
895 MpiEventDataSasInitTableOverflow_t,
896 MPI_POINTER pMpiEventDataSasInitTableOverflow_t;
897
807 898
808/***************************************************************************** 899/*****************************************************************************
809* 900*
@@ -1013,5 +1104,6 @@ typedef struct _MPI_EXT_IMAGE_HEADER
1013#define MPI_EXT_IMAGE_TYPE_FW (0x01) 1104#define MPI_EXT_IMAGE_TYPE_FW (0x01)
1014#define MPI_EXT_IMAGE_TYPE_NVDATA (0x03) 1105#define MPI_EXT_IMAGE_TYPE_NVDATA (0x03)
1015#define MPI_EXT_IMAGE_TYPE_BOOTLOADER (0x04) 1106#define MPI_EXT_IMAGE_TYPE_BOOTLOADER (0x04)
1107#define MPI_EXT_IMAGE_TYPE_INITIALIZATION (0x05)
1016 1108
1017#endif 1109#endif
diff --git a/drivers/message/fusion/lsi/mpi_log_sas.h b/drivers/message/fusion/lsi/mpi_log_sas.h
index a9c14ad132ce..871ebc08b706 100644
--- a/drivers/message/fusion/lsi/mpi_log_sas.h
+++ b/drivers/message/fusion/lsi/mpi_log_sas.h
@@ -13,6 +13,8 @@
13#ifndef IOPI_IOCLOGINFO_H_INCLUDED 13#ifndef IOPI_IOCLOGINFO_H_INCLUDED
14#define IOPI_IOCLOGINFO_H_INCLUDED 14#define IOPI_IOCLOGINFO_H_INCLUDED
15 15
16#define SAS_LOGINFO_NEXUS_LOSS 0x31170000
17#define SAS_LOGINFO_MASK 0xFFFF0000
16 18
17/****************************************************************************/ 19/****************************************************************************/
18/* IOC LOGINFO defines, 0x00000000 - 0x0FFFFFFF */ 20/* IOC LOGINFO defines, 0x00000000 - 0x0FFFFFFF */
@@ -51,6 +53,9 @@
51#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_DNM (0x00030500) /* Device Not Mapped */ 53#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_DNM (0x00030500) /* Device Not Mapped */
52#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_PERSIST (0x00030600) /* Persistent Page not found */ 54#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_PERSIST (0x00030600) /* Persistent Page not found */
53#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_DEFAULT (0x00030700) /* Default Page not found */ 55#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_DEFAULT (0x00030700) /* Default Page not found */
56
57#define IOP_LOGINFO_CODE_DIAG_MSG_ERROR (0x00040000) /* Error handling diag msg - or'd with diag status */
58
54#define IOP_LOGINFO_CODE_TASK_TERMINATED (0x00050000) 59#define IOP_LOGINFO_CODE_TASK_TERMINATED (0x00050000)
55 60
56#define IOP_LOGINFO_CODE_ENCL_MGMT_READ_ACTION_ERR0R (0x00060001) /* Read Action not supported for SEP msg */ 61#define IOP_LOGINFO_CODE_ENCL_MGMT_READ_ACTION_ERR0R (0x00060001) /* Read Action not supported for SEP msg */
@@ -103,6 +108,7 @@
103#define PL_LOGINFO_CODE_IO_EXECUTED (0x00140000) 108#define PL_LOGINFO_CODE_IO_EXECUTED (0x00140000)
104#define PL_LOGINFO_CODE_PERS_RESV_OUT_NOT_AFFIL_OWNER (0x00150000) 109#define PL_LOGINFO_CODE_PERS_RESV_OUT_NOT_AFFIL_OWNER (0x00150000)
105#define PL_LOGINFO_CODE_OPEN_TXDMA_ABORT (0x00160000) 110#define PL_LOGINFO_CODE_OPEN_TXDMA_ABORT (0x00160000)
111#define PL_LOGINFO_CODE_IO_DEVICE_MISSING_DELAY_RETRY (0x00170000)
106#define PL_LOGINFO_SUB_CODE_OPEN_FAILURE (0x00000100) 112#define PL_LOGINFO_SUB_CODE_OPEN_FAILURE (0x00000100)
107#define PL_LOGINFO_SUB_CODE_OPEN_FAILURE_NO_DEST_TIMEOUT (0x00000101) 113#define PL_LOGINFO_SUB_CODE_OPEN_FAILURE_NO_DEST_TIMEOUT (0x00000101)
108#define PL_LOGINFO_SUB_CODE_OPEN_FAILURE_ORR_TIMEOUT (0x0000011A) /* Open Reject (Retry) Timeout */ 114#define PL_LOGINFO_SUB_CODE_OPEN_FAILURE_ORR_TIMEOUT (0x0000011A) /* Open Reject (Retry) Timeout */
@@ -165,11 +171,81 @@
165/****************************************************************************/ 171/****************************************************************************/
166/* IR LOGINFO_CODE defines, valid if IOC_LOGINFO_ORIGINATOR = IR */ 172/* IR LOGINFO_CODE defines, valid if IOC_LOGINFO_ORIGINATOR = IR */
167/****************************************************************************/ 173/****************************************************************************/
168#define IR_LOGINFO_CODE_UNUSED1 (0x00010000) 174#define IR_LOGINFO_RAID_ACTION_ERROR (0x00010000)
169#define IR_LOGINFO_CODE_UNUSED2 (0x00020000) 175#define IR_LOGINFO_CODE_UNUSED2 (0x00020000)
176
177/* Amount of information passed down for Create Volume is too large */
178#define IR_LOGINFO_VOLUME_CREATE_INVALID_LENGTH (0x00010001)
179/* Creation of duplicate volume attempted (Bus/Target ID checked) */
180#define IR_LOGINFO_VOLUME_CREATE_DUPLICATE (0x00010002)
181/* Creation failed due to maximum number of supported volumes exceeded */
182#define IR_LOGINFO_VOLUME_CREATE_NO_SLOTS (0x00010003)
183/* Creation failed due to DMA error in trying to read from host */
184#define IR_LOGINFO_VOLUME_CREATE_DMA_ERROR (0x00010004)
185/* Creation failed due to invalid volume type passed down */
186#define IR_LOGINFO_VOLUME_CREATE_INVALID_VOLUME_TYPE (0x00010005)
187/* Creation failed due to error reading MFG Page 4 */
188#define IR_LOGINFO_VOLUME_MFG_PAGE4_ERROR (0x00010006)
189/* Creation failed when trying to create internal structures */
190#define IR_LOGINFO_VOLUME_INTERNAL_CONFIG_STRUCTURE_ERROR (0x00010007)
191
192/* Activation failed due to trying to activate an already active volume */
193#define IR_LOGINFO_VOLUME_ACTIVATING_AN_ACTIVE_VOLUME (0x00010010)
194/* Activation failed due to trying to active unsupported volume type */
195#define IR_LOGINFO_VOLUME_ACTIVATING_INVALID_VOLUME_TYPE (0x00010011)
196/* Activation failed due to trying to active too many volumes */
197#define IR_LOGINFO_VOLUME_ACTIVATING_TOO_MANY_VOLUMES (0x00010012)
198/* Activation failed due to Volume ID in use already */
199#define IR_LOGINFO_VOLUME_ACTIVATING_VOLUME_ID_IN_USE (0x00010013)
200/* Activation failed call to activateVolume returned failure */
201#define IR_LOGINFO_VOLUME_ACTIVATE_VOLUME_FAILED (0x00010014)
202/* Activation failed trying to import the volume */
203#define IR_LOGINFO_VOLUME_ACTIVATING_IMPORT_VOLUME_FAILED (0x00010015)
204
205/* Phys Disk failed, too many phys disks */
206#define IR_LOGINFO_PHYSDISK_CREATE_TOO_MANY_DISKS (0x00010020)
207/* Amount of information passed down for Create Pnysdisk is too large */
208#define IR_LOGINFO_PHYSDISK_CREATE_INVALID_LENGTH (0x00010021)
209/* Creation failed due to DMA error in trying to read from host */
210#define IR_LOGINFO_PHYSDISK_CREATE_DMA_ERROR (0x00010022)
211/* Creation failed due to invalid Bus TargetID passed down */
212#define IR_LOGINFO_PHYSDISK_CREATE_BUS_TID_INVALID (0x00010023)
213/* Creation failed due to error in creating RAID Phys Disk Config Page */
214#define IR_LOGINFO_PHYSDISK_CREATE_CONFIG_PAGE_ERROR (0x00010024)
215
216
217/* Compatibility Error : IR Disabled */
218#define IR_LOGINFO_COMPAT_ERROR_RAID_DISABLED (0x00010030)
219/* Compatibility Error : Inquiry Comand failed */
220#define IR_LOGINFO_COMPAT_ERROR_INQUIRY_FAILED (0x00010031)
221/* Compatibility Error : Device not direct access device */
222#define IR_LOGINFO_COMPAT_ERROR_NOT_DIRECT_ACCESS (0x00010032)
223/* Compatibility Error : Removable device found */
224#define IR_LOGINFO_COMPAT_ERROR_REMOVABLE_FOUND (0x00010033)
225/* Compatibility Error : Device SCSI Version not 2 or higher */
226#define IR_LOGINFO_COMPAT_ERROR_NEED_SCSI_2_OR_HIGHER (0x00010034)
227/* Compatibility Error : SATA device, 48 BIT LBA not supported */
228#define IR_LOGINFO_COMPAT_ERROR_SATA_48BIT_LBA_NOT_SUPPORTED (0x00010035)
229/* Compatibility Error : Device does not have 512 byte block sizes */
230#define IR_LOGINFO_COMPAT_ERROR_DEVICE_NOT_512_BYTE_BLOCK (0x00010036)
231/* Compatibility Error : Volume Type check failed */
232#define IR_LOGINFO_COMPAT_ERROR_VOLUME_TYPE_CHECK_FAILED (0x00010037)
233/* Compatibility Error : Volume Type is unsupported by FW */
234#define IR_LOGINFO_COMPAT_ERROR_UNSUPPORTED_VOLUME_TYPE (0x00010038)
235/* Compatibility Error : Disk drive too small for use in volume */
236#define IR_LOGINFO_COMPAT_ERROR_DISK_TOO_SMALL (0x00010039)
237/* Compatibility Error : Phys disk for Create Volume not found */
238#define IR_LOGINFO_COMPAT_ERROR_PHYS_DISK_NOT_FOUND (0x0001003A)
239/* Compatibility Error : membership count error, too many or too few disks for volume type */
240#define IR_LOGINFO_COMPAT_ERROR_MEMBERSHIP_COUNT (0x0001003B)
241/* Compatibility Error : Disk stripe sizes must be 64KB */
242#define IR_LOGINFO_COMPAT_ERROR_NON_64K_STRIPE_SIZE (0x0001003C)
243/* Compatibility Error : IME size limited to < 2TB */
244#define IR_LOGINFO_COMPAT_ERROR_IME_VOL_NOT_CURRENTLY_SUPPORTED (0x0001003D)
245
170 246
171/****************************************************************************/ 247/****************************************************************************/
172/* Defines for convienence */ 248/* Defines for convenience */
173/****************************************************************************/ 249/****************************************************************************/
174#define IOC_LOGINFO_PREFIX_IOP ((MPI_IOCLOGINFO_TYPE_SAS << MPI_IOCLOGINFO_TYPE_SHIFT) | IOC_LOGINFO_ORIGINATOR_IOP) 250#define IOC_LOGINFO_PREFIX_IOP ((MPI_IOCLOGINFO_TYPE_SAS << MPI_IOCLOGINFO_TYPE_SHIFT) | IOC_LOGINFO_ORIGINATOR_IOP)
175#define IOC_LOGINFO_PREFIX_PL ((MPI_IOCLOGINFO_TYPE_SAS << MPI_IOCLOGINFO_TYPE_SHIFT) | IOC_LOGINFO_ORIGINATOR_PL) 251#define IOC_LOGINFO_PREFIX_PL ((MPI_IOCLOGINFO_TYPE_SAS << MPI_IOCLOGINFO_TYPE_SHIFT) | IOC_LOGINFO_ORIGINATOR_PL)
diff --git a/drivers/message/fusion/lsi/mpi_sas.h b/drivers/message/fusion/lsi/mpi_sas.h
index 70514867bddf..50b8f0a8f456 100644
--- a/drivers/message/fusion/lsi/mpi_sas.h
+++ b/drivers/message/fusion/lsi/mpi_sas.h
@@ -6,7 +6,7 @@
6 * Title: MPI Serial Attached SCSI structures and definitions 6 * Title: MPI Serial Attached SCSI structures and definitions
7 * Creation Date: August 19, 2004 7 * Creation Date: August 19, 2004
8 * 8 *
9 * mpi_sas.h Version: 01.05.02 9 * mpi_sas.h Version: 01.05.03
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -17,6 +17,10 @@
17 * 08-30-05 01.05.02 Added DeviceInfo bit for SEP. 17 * 08-30-05 01.05.02 Added DeviceInfo bit for SEP.
18 * Added PrimFlags and Primitive field to SAS IO Unit 18 * Added PrimFlags and Primitive field to SAS IO Unit
19 * Control request, and added a new operation code. 19 * Control request, and added a new operation code.
20 * 03-27-06 01.05.03 Added Force Full Discovery, Transmit Port Select Signal,
21 * and Remove Device operations to SAS IO Unit Control.
22 * Added DevHandle field to SAS IO Unit Control request and
23 * reply.
20 * -------------------------------------------------------------------------- 24 * --------------------------------------------------------------------------
21 */ 25 */
22 26
@@ -209,7 +213,7 @@ typedef struct _MSG_SAS_IOUNIT_CONTROL_REQUEST
209 U8 Reserved1; /* 01h */ 213 U8 Reserved1; /* 01h */
210 U8 ChainOffset; /* 02h */ 214 U8 ChainOffset; /* 02h */
211 U8 Function; /* 03h */ 215 U8 Function; /* 03h */
212 U16 Reserved2; /* 04h */ 216 U16 DevHandle; /* 04h */
213 U8 Reserved3; /* 06h */ 217 U8 Reserved3; /* 06h */
214 U8 MsgFlags; /* 07h */ 218 U8 MsgFlags; /* 07h */
215 U32 MsgContext; /* 08h */ 219 U32 MsgContext; /* 08h */
@@ -231,6 +235,9 @@ typedef struct _MSG_SAS_IOUNIT_CONTROL_REQUEST
231#define MPI_SAS_OP_PHY_CLEAR_ERROR_LOG (0x08) 235#define MPI_SAS_OP_PHY_CLEAR_ERROR_LOG (0x08)
232#define MPI_SAS_OP_MAP_CURRENT (0x09) 236#define MPI_SAS_OP_MAP_CURRENT (0x09)
233#define MPI_SAS_OP_SEND_PRIMITIVE (0x0A) 237#define MPI_SAS_OP_SEND_PRIMITIVE (0x0A)
238#define MPI_SAS_OP_FORCE_FULL_DISCOVERY (0x0B)
239#define MPI_SAS_OP_TRANSMIT_PORT_SELECT_SIGNAL (0x0C)
240#define MPI_SAS_OP_TRANSMIT_REMOVE_DEVICE (0x0D)
234 241
235/* values for the PrimFlags field */ 242/* values for the PrimFlags field */
236#define MPI_SAS_PRIMFLAGS_SINGLE (0x08) 243#define MPI_SAS_PRIMFLAGS_SINGLE (0x08)
@@ -245,7 +252,7 @@ typedef struct _MSG_SAS_IOUNIT_CONTROL_REPLY
245 U8 Reserved1; /* 01h */ 252 U8 Reserved1; /* 01h */
246 U8 MsgLength; /* 02h */ 253 U8 MsgLength; /* 02h */
247 U8 Function; /* 03h */ 254 U8 Function; /* 03h */
248 U16 Reserved2; /* 04h */ 255 U16 DevHandle; /* 04h */
249 U8 Reserved3; /* 06h */ 256 U8 Reserved3; /* 06h */
250 U8 MsgFlags; /* 07h */ 257 U8 MsgFlags; /* 07h */
251 U32 MsgContext; /* 08h */ 258 U32 MsgContext; /* 08h */
diff --git a/drivers/message/fusion/lsi/mpi_targ.h b/drivers/message/fusion/lsi/mpi_targ.h
index 3f462859ceea..20b667315773 100644
--- a/drivers/message/fusion/lsi/mpi_targ.h
+++ b/drivers/message/fusion/lsi/mpi_targ.h
@@ -6,7 +6,7 @@
6 * Title: MPI Target mode messages and structures 6 * Title: MPI Target mode messages and structures
7 * Creation Date: June 22, 2000 7 * Creation Date: June 22, 2000
8 * 8 *
9 * mpi_targ.h Version: 01.05.05 9 * mpi_targ.h Version: 01.05.06
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -54,6 +54,7 @@
54 * 02-22-05 01.05.03 Changed a comment. 54 * 02-22-05 01.05.03 Changed a comment.
55 * 03-11-05 01.05.04 Removed TargetAssistExtended Request. 55 * 03-11-05 01.05.04 Removed TargetAssistExtended Request.
56 * 06-24-05 01.05.05 Added TargetAssistExtended structures and defines. 56 * 06-24-05 01.05.05 Added TargetAssistExtended structures and defines.
57 * 03-27-06 01.05.06 Added a comment.
57 * -------------------------------------------------------------------------- 58 * --------------------------------------------------------------------------
58 */ 59 */
59 60
@@ -351,7 +352,7 @@ typedef struct _MSG_TARGET_ASSIST_REQUEST
351#define TARGET_ASSIST_FLAGS_CONFIRMED (0x08) 352#define TARGET_ASSIST_FLAGS_CONFIRMED (0x08)
352#define TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER (0x80) 353#define TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER (0x80)
353 354
354 355/* Standard Target Mode Reply message */
355typedef struct _MSG_TARGET_ERROR_REPLY 356typedef struct _MSG_TARGET_ERROR_REPLY
356{ 357{
357 U16 Reserved; /* 00h */ 358 U16 Reserved; /* 00h */
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 12dd8d493ee2..29d0635cce1d 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -46,7 +46,6 @@
46*/ 46*/
47/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 47/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
48 48
49#include <linux/config.h>
50#include <linux/kernel.h> 49#include <linux/kernel.h>
51#include <linux/module.h> 50#include <linux/module.h>
52#include <linux/errno.h> 51#include <linux/errno.h>
@@ -369,20 +368,21 @@ static irqreturn_t
369mpt_interrupt(int irq, void *bus_id, struct pt_regs *r) 368mpt_interrupt(int irq, void *bus_id, struct pt_regs *r)
370{ 369{
371 MPT_ADAPTER *ioc = bus_id; 370 MPT_ADAPTER *ioc = bus_id;
372 u32 pa; 371 u32 pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo);
372
373 if (pa == 0xFFFFFFFF)
374 return IRQ_NONE;
373 375
374 /* 376 /*
375 * Drain the reply FIFO! 377 * Drain the reply FIFO!
376 */ 378 */
377 while (1) { 379 do {
378 pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo); 380 if (pa & MPI_ADDRESS_REPLY_A_BIT)
379 if (pa == 0xFFFFFFFF)
380 return IRQ_HANDLED;
381 else if (pa & MPI_ADDRESS_REPLY_A_BIT)
382 mpt_reply(ioc, pa); 381 mpt_reply(ioc, pa);
383 else 382 else
384 mpt_turbo_reply(ioc, pa); 383 mpt_turbo_reply(ioc, pa);
385 } 384 pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo);
385 } while (pa != 0xFFFFFFFF);
386 386
387 return IRQ_HANDLED; 387 return IRQ_HANDLED;
388} 388}
@@ -436,8 +436,6 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
436 */ 436 */
437 if (pEvReply->MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY) { 437 if (pEvReply->MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY) {
438 freereq = 0; 438 freereq = 0;
439 devtverboseprintk((MYIOC_s_WARN_FMT "EVENT_NOTIFICATION reply %p does not return Request frame\n",
440 ioc->name, pEvReply));
441 } else { 439 } else {
442 devtverboseprintk((MYIOC_s_WARN_FMT "EVENT_NOTIFICATION reply %p returns Request frame\n", 440 devtverboseprintk((MYIOC_s_WARN_FMT "EVENT_NOTIFICATION reply %p returns Request frame\n",
443 ioc->name, pEvReply)); 441 ioc->name, pEvReply));
@@ -678,19 +676,19 @@ int
678mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx) 676mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx)
679{ 677{
680 MPT_ADAPTER *ioc; 678 MPT_ADAPTER *ioc;
679 const struct pci_device_id *id;
681 680
682 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) { 681 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
683 return -EINVAL; 682 return -EINVAL;
684 }
685 683
686 MptDeviceDriverHandlers[cb_idx] = dd_cbfunc; 684 MptDeviceDriverHandlers[cb_idx] = dd_cbfunc;
687 685
688 /* call per pci device probe entry point */ 686 /* call per pci device probe entry point */
689 list_for_each_entry(ioc, &ioc_list, list) { 687 list_for_each_entry(ioc, &ioc_list, list) {
690 if(dd_cbfunc->probe) { 688 id = ioc->pcidev->driver ?
691 dd_cbfunc->probe(ioc->pcidev, 689 ioc->pcidev->driver->id_table : NULL;
692 ioc->pcidev->driver->id_table); 690 if (dd_cbfunc->probe)
693 } 691 dd_cbfunc->probe(ioc->pcidev, id);
694 } 692 }
695 693
696 return 0; 694 return 0;
@@ -1056,9 +1054,8 @@ mpt_host_page_alloc(MPT_ADAPTER *ioc, pIOCInit_t ioc_init)
1056 1054
1057 dinitprintk((MYIOC_s_INFO_FMT 1055 dinitprintk((MYIOC_s_INFO_FMT
1058 "host_page_buffer @ %p, dma @ %x, sz=%d bytes\n", 1056 "host_page_buffer @ %p, dma @ %x, sz=%d bytes\n",
1059 ioc->name, 1057 ioc->name, ioc->HostPageBuffer,
1060 ioc->HostPageBuffer, 1058 (u32)ioc->HostPageBuffer_dma,
1061 ioc->HostPageBuffer_dma,
1062 host_page_buffer_sz)); 1059 host_page_buffer_sz));
1063 ioc->alloc_total += host_page_buffer_sz; 1060 ioc->alloc_total += host_page_buffer_sz;
1064 ioc->HostPageBuffer_sz = host_page_buffer_sz; 1061 ioc->HostPageBuffer_sz = host_page_buffer_sz;
@@ -1220,31 +1217,25 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1220 port = psize = 0; 1217 port = psize = 0;
1221 for (ii=0; ii < DEVICE_COUNT_RESOURCE; ii++) { 1218 for (ii=0; ii < DEVICE_COUNT_RESOURCE; ii++) {
1222 if (pci_resource_flags(pdev, ii) & PCI_BASE_ADDRESS_SPACE_IO) { 1219 if (pci_resource_flags(pdev, ii) & PCI_BASE_ADDRESS_SPACE_IO) {
1220 if (psize)
1221 continue;
1223 /* Get I/O space! */ 1222 /* Get I/O space! */
1224 port = pci_resource_start(pdev, ii); 1223 port = pci_resource_start(pdev, ii);
1225 psize = pci_resource_len(pdev,ii); 1224 psize = pci_resource_len(pdev,ii);
1226 } else { 1225 } else {
1226 if (msize)
1227 continue;
1227 /* Get memmap */ 1228 /* Get memmap */
1228 mem_phys = pci_resource_start(pdev, ii); 1229 mem_phys = pci_resource_start(pdev, ii);
1229 msize = pci_resource_len(pdev,ii); 1230 msize = pci_resource_len(pdev,ii);
1230 break;
1231 } 1231 }
1232 } 1232 }
1233 ioc->mem_size = msize; 1233 ioc->mem_size = msize;
1234 1234
1235 if (ii == DEVICE_COUNT_RESOURCE) {
1236 printk(KERN_ERR MYNAM ": ERROR - MPT adapter has no memory regions defined!\n");
1237 kfree(ioc);
1238 return -EINVAL;
1239 }
1240
1241 dinitprintk((KERN_INFO MYNAM ": MPT adapter @ %lx, msize=%dd bytes\n", mem_phys, msize));
1242 dinitprintk((KERN_INFO MYNAM ": (port i/o @ %lx, psize=%dd bytes)\n", port, psize));
1243
1244 mem = NULL; 1235 mem = NULL;
1245 /* Get logical ptr for PciMem0 space */ 1236 /* Get logical ptr for PciMem0 space */
1246 /*mem = ioremap(mem_phys, msize);*/ 1237 /*mem = ioremap(mem_phys, msize);*/
1247 mem = ioremap(mem_phys, 0x100); 1238 mem = ioremap(mem_phys, msize);
1248 if (mem == NULL) { 1239 if (mem == NULL) {
1249 printk(KERN_ERR MYNAM ": ERROR - Unable to map adapter memory!\n"); 1240 printk(KERN_ERR MYNAM ": ERROR - Unable to map adapter memory!\n");
1250 kfree(ioc); 1241 kfree(ioc);
@@ -1344,11 +1335,6 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1344 ioc->bus_type = SAS; 1335 ioc->bus_type = SAS;
1345 ioc->errata_flag_1064 = 1; 1336 ioc->errata_flag_1064 = 1;
1346 } 1337 }
1347 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1066) {
1348 ioc->prod_name = "LSISAS1066";
1349 ioc->bus_type = SAS;
1350 ioc->errata_flag_1064 = 1;
1351 }
1352 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1068) { 1338 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1068) {
1353 ioc->prod_name = "LSISAS1068"; 1339 ioc->prod_name = "LSISAS1068";
1354 ioc->bus_type = SAS; 1340 ioc->bus_type = SAS;
@@ -1358,14 +1344,14 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1358 ioc->prod_name = "LSISAS1064E"; 1344 ioc->prod_name = "LSISAS1064E";
1359 ioc->bus_type = SAS; 1345 ioc->bus_type = SAS;
1360 } 1346 }
1361 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1066E) {
1362 ioc->prod_name = "LSISAS1066E";
1363 ioc->bus_type = SAS;
1364 }
1365 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1068E) { 1347 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1068E) {
1366 ioc->prod_name = "LSISAS1068E"; 1348 ioc->prod_name = "LSISAS1068E";
1367 ioc->bus_type = SAS; 1349 ioc->bus_type = SAS;
1368 } 1350 }
1351 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) {
1352 ioc->prod_name = "LSISAS1078";
1353 ioc->bus_type = SAS;
1354 }
1369 1355
1370 if (ioc->errata_flag_1064) 1356 if (ioc->errata_flag_1064)
1371 pci_disable_io_access(pdev); 1357 pci_disable_io_access(pdev);
@@ -1391,6 +1377,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1391 printk(KERN_WARNING MYNAM 1377 printk(KERN_WARNING MYNAM
1392 ": WARNING - %s did not initialize properly! (%d)\n", 1378 ": WARNING - %s did not initialize properly! (%d)\n",
1393 ioc->name, r); 1379 ioc->name, r);
1380
1394 list_del(&ioc->list); 1381 list_del(&ioc->list);
1395 if (ioc->alt_ioc) 1382 if (ioc->alt_ioc)
1396 ioc->alt_ioc->alt_ioc = NULL; 1383 ioc->alt_ioc->alt_ioc = NULL;
@@ -1706,7 +1693,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1706 printk(MYIOC_s_INFO_FMT "PCI-MSI enabled\n", 1693 printk(MYIOC_s_INFO_FMT "PCI-MSI enabled\n",
1707 ioc->name); 1694 ioc->name);
1708 rc = request_irq(ioc->pcidev->irq, mpt_interrupt, 1695 rc = request_irq(ioc->pcidev->irq, mpt_interrupt,
1709 SA_SHIRQ, ioc->name, ioc); 1696 IRQF_SHARED, ioc->name, ioc);
1710 if (rc < 0) { 1697 if (rc < 0) {
1711 printk(MYIOC_s_ERR_FMT "Unable to allocate " 1698 printk(MYIOC_s_ERR_FMT "Unable to allocate "
1712 "interrupt %d!\n", ioc->name, 1699 "interrupt %d!\n", ioc->name,
@@ -1773,9 +1760,9 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1773 * chips (mpt_adapter_disable, 1760 * chips (mpt_adapter_disable,
1774 * mpt_diag_reset) 1761 * mpt_diag_reset)
1775 */ 1762 */
1776 ioc->cached_fw = NULL;
1777 ddlprintk((MYIOC_s_INFO_FMT ": mpt_upload: alt_%s has cached_fw=%p \n", 1763 ddlprintk((MYIOC_s_INFO_FMT ": mpt_upload: alt_%s has cached_fw=%p \n",
1778 ioc->name, ioc->alt_ioc->name, ioc->alt_ioc->cached_fw)); 1764 ioc->name, ioc->alt_ioc->name, ioc->alt_ioc->cached_fw));
1765 ioc->alt_ioc->cached_fw = NULL;
1779 } 1766 }
1780 } else { 1767 } else {
1781 printk(KERN_WARNING MYNAM ": firmware upload failure!\n"); 1768 printk(KERN_WARNING MYNAM ": firmware upload failure!\n");
@@ -1896,7 +1883,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1896 /* FIXME? Examine results here? */ 1883 /* FIXME? Examine results here? */
1897 } 1884 }
1898 1885
1899out: 1886 out:
1900 if ((ret != 0) && irq_allocated) { 1887 if ((ret != 0) && irq_allocated) {
1901 free_irq(ioc->pci_irq, ioc); 1888 free_irq(ioc->pci_irq, ioc);
1902 if (mpt_msi_enable) 1889 if (mpt_msi_enable)
@@ -2681,6 +2668,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
2681 dinitprintk((MYIOC_s_INFO_FMT "INFO - Wait IOC_OPERATIONAL state (cnt=%d)\n", 2668 dinitprintk((MYIOC_s_INFO_FMT "INFO - Wait IOC_OPERATIONAL state (cnt=%d)\n",
2682 ioc->name, count)); 2669 ioc->name, count));
2683 2670
2671 ioc->aen_event_read_flag=0;
2684 return r; 2672 return r;
2685} 2673}
2686 2674
@@ -2748,6 +2736,8 @@ mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size)
2748 if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) { 2736 if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) {
2749 ioc->cached_fw = ioc->alt_ioc->cached_fw; /* use alt_ioc's memory */ 2737 ioc->cached_fw = ioc->alt_ioc->cached_fw; /* use alt_ioc's memory */
2750 ioc->cached_fw_dma = ioc->alt_ioc->cached_fw_dma; 2738 ioc->cached_fw_dma = ioc->alt_ioc->cached_fw_dma;
2739 ioc->alloc_total += size;
2740 ioc->alt_ioc->alloc_total -= size;
2751 } else { 2741 } else {
2752 if ( (ioc->cached_fw = pci_alloc_consistent(ioc->pcidev, size, &ioc->cached_fw_dma) ) ) 2742 if ( (ioc->cached_fw = pci_alloc_consistent(ioc->pcidev, size, &ioc->cached_fw_dma) ) )
2753 ioc->alloc_total += size; 2743 ioc->alloc_total += size;
@@ -3177,6 +3167,7 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag)
3177static int 3167static int
3178mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag) 3168mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3179{ 3169{
3170 MPT_ADAPTER *iocp=NULL;
3180 u32 diag0val; 3171 u32 diag0val;
3181 u32 doorbell; 3172 u32 doorbell;
3182 int hard_reset_done = 0; 3173 int hard_reset_done = 0;
@@ -3185,6 +3176,37 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3185 u32 diag1val = 0; 3176 u32 diag1val = 0;
3186#endif 3177#endif
3187 3178
3179 if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) {
3180 drsprintk((MYIOC_s_WARN_FMT "%s: Doorbell=%p; 1078 reset "
3181 "address=%p\n", ioc->name, __FUNCTION__,
3182 &ioc->chip->Doorbell, &ioc->chip->Reset_1078));
3183 CHIPREG_WRITE32(&ioc->chip->Reset_1078, 0x07);
3184 if (sleepFlag == CAN_SLEEP)
3185 msleep(1);
3186 else
3187 mdelay(1);
3188
3189 for (count = 0; count < 60; count ++) {
3190 doorbell = CHIPREG_READ32(&ioc->chip->Doorbell);
3191 doorbell &= MPI_IOC_STATE_MASK;
3192
3193 drsprintk((MYIOC_s_INFO_FMT
3194 "looking for READY STATE: doorbell=%x"
3195 " count=%d\n",
3196 ioc->name, doorbell, count));
3197 if (doorbell == MPI_IOC_STATE_READY) {
3198 return 0;
3199 }
3200
3201 /* wait 1 sec */
3202 if (sleepFlag == CAN_SLEEP)
3203 msleep(1000);
3204 else
3205 mdelay(1000);
3206 }
3207 return -1;
3208 }
3209
3188 /* Clear any existing interrupts */ 3210 /* Clear any existing interrupts */
3189 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); 3211 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
3190 3212
@@ -3281,17 +3303,23 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3281 /* FIXME? Examine results here? */ 3303 /* FIXME? Examine results here? */
3282 } 3304 }
3283 3305
3284 if (ioc->cached_fw) { 3306 if (ioc->cached_fw)
3307 iocp = ioc;
3308 else if (ioc->alt_ioc && ioc->alt_ioc->cached_fw)
3309 iocp = ioc->alt_ioc;
3310 if (iocp) {
3285 /* If the DownloadBoot operation fails, the 3311 /* If the DownloadBoot operation fails, the
3286 * IOC will be left unusable. This is a fatal error 3312 * IOC will be left unusable. This is a fatal error
3287 * case. _diag_reset will return < 0 3313 * case. _diag_reset will return < 0
3288 */ 3314 */
3289 for (count = 0; count < 30; count ++) { 3315 for (count = 0; count < 30; count ++) {
3290 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); 3316 diag0val = CHIPREG_READ32(&iocp->chip->Diagnostic);
3291 if (!(diag0val & MPI_DIAG_RESET_ADAPTER)) { 3317 if (!(diag0val & MPI_DIAG_RESET_ADAPTER)) {
3292 break; 3318 break;
3293 } 3319 }
3294 3320
3321 dprintk((MYIOC_s_INFO_FMT "cached_fw: diag0val=%x count=%d\n",
3322 iocp->name, diag0val, count));
3295 /* wait 1 sec */ 3323 /* wait 1 sec */
3296 if (sleepFlag == CAN_SLEEP) { 3324 if (sleepFlag == CAN_SLEEP) {
3297 msleep (1000); 3325 msleep (1000);
@@ -3300,7 +3328,7 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3300 } 3328 }
3301 } 3329 }
3302 if ((count = mpt_downloadboot(ioc, 3330 if ((count = mpt_downloadboot(ioc,
3303 (MpiFwHeader_t *)ioc->cached_fw, sleepFlag)) < 0) { 3331 (MpiFwHeader_t *)iocp->cached_fw, sleepFlag)) < 0) {
3304 printk(KERN_WARNING MYNAM 3332 printk(KERN_WARNING MYNAM
3305 ": firmware downloadboot failure (%d)!\n", count); 3333 ": firmware downloadboot failure (%d)!\n", count);
3306 } 3334 }
@@ -3887,18 +3915,18 @@ WaitForDoorbellAck(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
3887 3915
3888 if (sleepFlag == CAN_SLEEP) { 3916 if (sleepFlag == CAN_SLEEP) {
3889 while (--cntdn) { 3917 while (--cntdn) {
3918 msleep (1);
3890 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); 3919 intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
3891 if (! (intstat & MPI_HIS_IOP_DOORBELL_STATUS)) 3920 if (! (intstat & MPI_HIS_IOP_DOORBELL_STATUS))
3892 break; 3921 break;
3893 msleep (1);
3894 count++; 3922 count++;
3895 } 3923 }
3896 } else { 3924 } else {
3897 while (--cntdn) { 3925 while (--cntdn) {
3926 mdelay (1);
3898 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); 3927 intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
3899 if (! (intstat & MPI_HIS_IOP_DOORBELL_STATUS)) 3928 if (! (intstat & MPI_HIS_IOP_DOORBELL_STATUS))
3900 break; 3929 break;
3901 mdelay (1);
3902 count++; 3930 count++;
3903 } 3931 }
3904 } 3932 }
@@ -4863,6 +4891,7 @@ mpt_read_ioc_pg_4(MPT_ADAPTER *ioc)
4863 pIoc4 = pci_alloc_consistent(ioc->pcidev, iocpage4sz, &ioc4_dma); 4891 pIoc4 = pci_alloc_consistent(ioc->pcidev, iocpage4sz, &ioc4_dma);
4864 if (!pIoc4) 4892 if (!pIoc4)
4865 return; 4893 return;
4894 ioc->alloc_total += iocpage4sz;
4866 } else { 4895 } else {
4867 ioc4_dma = ioc->spi_data.IocPg4_dma; 4896 ioc4_dma = ioc->spi_data.IocPg4_dma;
4868 iocpage4sz = ioc->spi_data.IocPg4Sz; 4897 iocpage4sz = ioc->spi_data.IocPg4Sz;
@@ -4879,6 +4908,7 @@ mpt_read_ioc_pg_4(MPT_ADAPTER *ioc)
4879 } else { 4908 } else {
4880 pci_free_consistent(ioc->pcidev, iocpage4sz, pIoc4, ioc4_dma); 4909 pci_free_consistent(ioc->pcidev, iocpage4sz, pIoc4, ioc4_dma);
4881 ioc->spi_data.pIocPg4 = NULL; 4910 ioc->spi_data.pIocPg4 = NULL;
4911 ioc->alloc_total -= iocpage4sz;
4882 } 4912 }
4883} 4913}
4884 4914
@@ -5010,19 +5040,18 @@ SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp)
5010 EventAck_t *pAck; 5040 EventAck_t *pAck;
5011 5041
5012 if ((pAck = (EventAck_t *) mpt_get_msg_frame(mpt_base_index, ioc)) == NULL) { 5042 if ((pAck = (EventAck_t *) mpt_get_msg_frame(mpt_base_index, ioc)) == NULL) {
5013 printk(MYIOC_s_WARN_FMT "Unable to allocate event ACK " 5043 dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
5014 "request frame for Event=%x EventContext=%x EventData=%x!\n", 5044 ioc->name,__FUNCTION__));
5015 ioc->name, evnp->Event, le32_to_cpu(evnp->EventContext),
5016 le32_to_cpu(evnp->Data[0]));
5017 return -1; 5045 return -1;
5018 } 5046 }
5019 memset(pAck, 0, sizeof(*pAck));
5020 5047
5021 dprintk((MYIOC_s_INFO_FMT "Sending EventAck\n", ioc->name)); 5048 devtverboseprintk((MYIOC_s_INFO_FMT "Sending EventAck\n", ioc->name));
5022 5049
5023 pAck->Function = MPI_FUNCTION_EVENT_ACK; 5050 pAck->Function = MPI_FUNCTION_EVENT_ACK;
5024 pAck->ChainOffset = 0; 5051 pAck->ChainOffset = 0;
5052 pAck->Reserved[0] = pAck->Reserved[1] = 0;
5025 pAck->MsgFlags = 0; 5053 pAck->MsgFlags = 0;
5054 pAck->Reserved1[0] = pAck->Reserved1[1] = pAck->Reserved1[2] = 0;
5026 pAck->Event = evnp->Event; 5055 pAck->Event = evnp->Event;
5027 pAck->EventContext = evnp->EventContext; 5056 pAck->EventContext = evnp->EventContext;
5028 5057
@@ -5592,7 +5621,7 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag)
5592 5621
5593 /* The SCSI driver needs to adjust timeouts on all current 5622 /* The SCSI driver needs to adjust timeouts on all current
5594 * commands prior to the diagnostic reset being issued. 5623 * commands prior to the diagnostic reset being issued.
5595 * Prevents timeouts occuring during a diagnostic reset...very bad. 5624 * Prevents timeouts occurring during a diagnostic reset...very bad.
5596 * For all other protocol drivers, this is a no-op. 5625 * For all other protocol drivers, this is a no-op.
5597 */ 5626 */
5598 { 5627 {
@@ -5684,9 +5713,9 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
5684 break; 5713 break;
5685 case MPI_EVENT_EVENT_CHANGE: 5714 case MPI_EVENT_EVENT_CHANGE:
5686 if (evData0) 5715 if (evData0)
5687 ds = "Events(ON) Change"; 5716 ds = "Events ON";
5688 else 5717 else
5689 ds = "Events(OFF) Change"; 5718 ds = "Events OFF";
5690 break; 5719 break;
5691 case MPI_EVENT_INTEGRATED_RAID: 5720 case MPI_EVENT_INTEGRATED_RAID:
5692 { 5721 {
@@ -5757,8 +5786,27 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
5757 break; 5786 break;
5758 case MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED: 5787 case MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED:
5759 snprintf(evStr, EVENT_DESCR_STR_SZ, 5788 snprintf(evStr, EVENT_DESCR_STR_SZ,
5760 "SAS Device Status Change: No Persistancy " 5789 "SAS Device Status Change: No Persistancy: id=%d", id);
5761 "Added: id=%d", id); 5790 break;
5791 case MPI_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET:
5792 snprintf(evStr, EVENT_DESCR_STR_SZ,
5793 "SAS Device Status Change: Internal Device Reset : id=%d", id);
5794 break;
5795 case MPI_EVENT_SAS_DEV_STAT_RC_TASK_ABORT_INTERNAL:
5796 snprintf(evStr, EVENT_DESCR_STR_SZ,
5797 "SAS Device Status Change: Internal Task Abort : id=%d", id);
5798 break;
5799 case MPI_EVENT_SAS_DEV_STAT_RC_ABORT_TASK_SET_INTERNAL:
5800 snprintf(evStr, EVENT_DESCR_STR_SZ,
5801 "SAS Device Status Change: Internal Abort Task Set : id=%d", id);
5802 break;
5803 case MPI_EVENT_SAS_DEV_STAT_RC_CLEAR_TASK_SET_INTERNAL:
5804 snprintf(evStr, EVENT_DESCR_STR_SZ,
5805 "SAS Device Status Change: Internal Clear Task Set : id=%d", id);
5806 break;
5807 case MPI_EVENT_SAS_DEV_STAT_RC_QUERY_TASK_INTERNAL:
5808 snprintf(evStr, EVENT_DESCR_STR_SZ,
5809 "SAS Device Status Change: Internal Query Task : id=%d", id);
5762 break; 5810 break;
5763 default: 5811 default:
5764 snprintf(evStr, EVENT_DESCR_STR_SZ, 5812 snprintf(evStr, EVENT_DESCR_STR_SZ,
@@ -6014,7 +6062,7 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
6014 * @ioc: Pointer to MPT_ADAPTER structure 6062 * @ioc: Pointer to MPT_ADAPTER structure
6015 * @log_info: U32 LogInfo reply word from the IOC 6063 * @log_info: U32 LogInfo reply word from the IOC
6016 * 6064 *
6017 * Refer to lsi/fc_log.h. 6065 * Refer to lsi/mpi_log_fc.h.
6018 */ 6066 */
6019static void 6067static void
6020mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info) 6068mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info)
@@ -6111,8 +6159,10 @@ mpt_spi_log_info(MPT_ADAPTER *ioc, u32 log_info)
6111 "Invalid SAS Address", /* 01h */ 6159 "Invalid SAS Address", /* 01h */
6112 NULL, /* 02h */ 6160 NULL, /* 02h */
6113 "Invalid Page", /* 03h */ 6161 "Invalid Page", /* 03h */
6114 NULL, /* 04h */ 6162 "Diag Message Error", /* 04h */
6115 "Task Terminated" /* 05h */ 6163 "Task Terminated", /* 05h */
6164 "Enclosure Management", /* 06h */
6165 "Target Mode" /* 07h */
6116 }; 6166 };
6117 static char *pl_code_str[] = { 6167 static char *pl_code_str[] = {
6118 NULL, /* 00h */ 6168 NULL, /* 00h */
@@ -6138,7 +6188,7 @@ mpt_spi_log_info(MPT_ADAPTER *ioc, u32 log_info)
6138 "IO Executed", /* 14h */ 6188 "IO Executed", /* 14h */
6139 "Persistant Reservation Out Not Affiliation Owner", /* 15h */ 6189 "Persistant Reservation Out Not Affiliation Owner", /* 15h */
6140 "Open Transmit DMA Abort", /* 16h */ 6190 "Open Transmit DMA Abort", /* 16h */
6141 NULL, /* 17h */ 6191 "IO Device Missing Delay Retry", /* 17h */
6142 NULL, /* 18h */ 6192 NULL, /* 18h */
6143 NULL, /* 19h */ 6193 NULL, /* 19h */
6144 NULL, /* 1Ah */ 6194 NULL, /* 1Ah */
@@ -6218,7 +6268,7 @@ static void
6218mpt_sp_ioc_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf) 6268mpt_sp_ioc_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf)
6219{ 6269{
6220 u32 status = ioc_status & MPI_IOCSTATUS_MASK; 6270 u32 status = ioc_status & MPI_IOCSTATUS_MASK;
6221 char *desc = ""; 6271 char *desc = NULL;
6222 6272
6223 switch (status) { 6273 switch (status) {
6224 case MPI_IOCSTATUS_INVALID_FUNCTION: /* 0x0001 */ 6274 case MPI_IOCSTATUS_INVALID_FUNCTION: /* 0x0001 */
@@ -6328,7 +6378,7 @@ mpt_sp_ioc_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf)
6328 desc = "Others"; 6378 desc = "Others";
6329 break; 6379 break;
6330 } 6380 }
6331 if (desc != "") 6381 if (desc != NULL)
6332 printk(MYIOC_s_INFO_FMT "IOCStatus(0x%04x): %s\n", ioc->name, status, desc); 6382 printk(MYIOC_s_INFO_FMT "IOCStatus(0x%04x): %s\n", ioc->name, status, desc);
6333} 6383}
6334 6384
@@ -6366,7 +6416,6 @@ EXPORT_SYMBOL(mpt_alloc_fw_memory);
6366EXPORT_SYMBOL(mpt_free_fw_memory); 6416EXPORT_SYMBOL(mpt_free_fw_memory);
6367EXPORT_SYMBOL(mptbase_sas_persist_operation); 6417EXPORT_SYMBOL(mptbase_sas_persist_operation);
6368 6418
6369
6370/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6419/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6371/* 6420/*
6372 * fusion_init - Fusion MPT base driver initialization routine. 6421 * fusion_init - Fusion MPT base driver initialization routine.
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index 4720f9ae86aa..c537d71c18e4 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -49,7 +49,6 @@
49#define MPTBASE_H_INCLUDED 49#define MPTBASE_H_INCLUDED
50/*{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 50/*{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
51 51
52#include <linux/config.h>
53#include <linux/kernel.h> 52#include <linux/kernel.h>
54#include <linux/pci.h> 53#include <linux/pci.h>
55 54
@@ -76,8 +75,8 @@
76#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR 75#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR
77#endif 76#endif
78 77
79#define MPT_LINUX_VERSION_COMMON "3.03.10" 78#define MPT_LINUX_VERSION_COMMON "3.04.01"
80#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.10" 79#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.04.01"
81#define WHAT_MAGIC_STRING "@" "(" "#" ")" 80#define WHAT_MAGIC_STRING "@" "(" "#" ")"
82 81
83#define show_mptmod_ver(s,ver) \ 82#define show_mptmod_ver(s,ver) \
@@ -308,7 +307,8 @@ typedef struct _SYSIF_REGS
308 u32 HostIndex; /* 50 Host Index register */ 307 u32 HostIndex; /* 50 Host Index register */
309 u32 Reserved4[15]; /* 54-8F */ 308 u32 Reserved4[15]; /* 54-8F */
310 u32 Fubar; /* 90 For Fubar usage */ 309 u32 Fubar; /* 90 For Fubar usage */
311 u32 Reserved5[27]; /* 94-FF */ 310 u32 Reserved5[1050];/* 94-10F8 */
311 u32 Reset_1078; /* 10FC Reset 1078 */
312} SYSIF_REGS; 312} SYSIF_REGS;
313 313
314/* 314/*
@@ -342,6 +342,7 @@ typedef struct _VirtTarget {
342 u8 negoFlags; /* bit field, see above */ 342 u8 negoFlags; /* bit field, see above */
343 u8 raidVolume; /* set, if RAID Volume */ 343 u8 raidVolume; /* set, if RAID Volume */
344 u8 type; /* byte 0 of Inquiry data */ 344 u8 type; /* byte 0 of Inquiry data */
345 u8 deleted; /* target in process of being removed */
345 u32 num_luns; 346 u32 num_luns;
346 u32 luns[8]; /* Max LUNs is 256 */ 347 u32 luns[8]; /* Max LUNs is 256 */
347} VirtTarget; 348} VirtTarget;
@@ -362,6 +363,7 @@ typedef struct _VirtDevice {
362#define MPT_TARGET_FLAGS_VALID_56 0x10 363#define MPT_TARGET_FLAGS_VALID_56 0x10
363#define MPT_TARGET_FLAGS_SAF_TE_ISSUED 0x20 364#define MPT_TARGET_FLAGS_SAF_TE_ISSUED 0x20
364#define MPT_TARGET_FLAGS_RAID_COMPONENT 0x40 365#define MPT_TARGET_FLAGS_RAID_COMPONENT 0x40
366#define MPT_TARGET_FLAGS_LED_ON 0x80
365 367
366/* 368/*
367 * /proc/mpt interface 369 * /proc/mpt interface
@@ -630,15 +632,14 @@ typedef struct _MPT_ADAPTER
630 struct mutex sas_discovery_mutex; 632 struct mutex sas_discovery_mutex;
631 u8 sas_discovery_runtime; 633 u8 sas_discovery_runtime;
632 u8 sas_discovery_ignore_events; 634 u8 sas_discovery_ignore_events;
635 u16 handle;
633 int sas_index; /* index refrencing */ 636 int sas_index; /* index refrencing */
634 MPT_SAS_MGMT sas_mgmt; 637 MPT_SAS_MGMT sas_mgmt;
635 int num_ports; 638 struct work_struct sas_persist_task;
636 struct work_struct mptscsih_persistTask;
637 639
638 struct work_struct fc_setup_reset_work; 640 struct work_struct fc_setup_reset_work;
639 struct list_head fc_rports; 641 struct list_head fc_rports;
640 spinlock_t fc_rescan_work_lock; 642 spinlock_t fc_rescan_work_lock;
641 int fc_rescan_work_count;
642 struct work_struct fc_rescan_work; 643 struct work_struct fc_rescan_work;
643 char fc_rescan_work_q_name[KOBJ_NAME_LEN]; 644 char fc_rescan_work_q_name[KOBJ_NAME_LEN];
644 struct workqueue_struct *fc_rescan_work_q; 645 struct workqueue_struct *fc_rescan_work_q;
@@ -893,6 +894,13 @@ typedef struct _mpt_sge {
893#define DBG_DUMP_REQUEST_FRAME_HDR(mfp) 894#define DBG_DUMP_REQUEST_FRAME_HDR(mfp)
894#endif 895#endif
895 896
897// debug sas wide ports
898#ifdef MPT_DEBUG_SAS_WIDE
899#define dsaswideprintk(x) printk x
900#else
901#define dsaswideprintk(x)
902#endif
903
896 904
897/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 905/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
898 906
@@ -972,7 +980,7 @@ typedef struct _MPT_SCSI_HOST {
972 wait_queue_head_t scandv_waitq; 980 wait_queue_head_t scandv_waitq;
973 int scandv_wait_done; 981 int scandv_wait_done;
974 long last_queue_full; 982 long last_queue_full;
975 u8 mpt_pq_filter; 983 u16 tm_iocstatus;
976} MPT_SCSI_HOST; 984} MPT_SCSI_HOST;
977 985
978/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 986/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index b4967bb8a7d6..30975ccd9947 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -2332,7 +2332,7 @@ done_free_mem:
2332} 2332}
2333 2333
2334/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2334/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2335/* Prototype Routine for the HP HOST INFO command. 2335/* Prototype Routine for the HOST INFO command.
2336 * 2336 *
2337 * Outputs: None. 2337 * Outputs: None.
2338 * Return: 0 if successful 2338 * Return: 0 if successful
@@ -2568,7 +2568,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size)
2568} 2568}
2569 2569
2570/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2570/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2571/* Prototype Routine for the HP TARGET INFO command. 2571/* Prototype Routine for the TARGET INFO command.
2572 * 2572 *
2573 * Outputs: None. 2573 * Outputs: None.
2574 * Return: 0 if successful 2574 * Return: 0 if successful
diff --git a/drivers/message/fusion/mptctl.h b/drivers/message/fusion/mptctl.h
index a2f8a97992e6..043941882c6e 100644
--- a/drivers/message/fusion/mptctl.h
+++ b/drivers/message/fusion/mptctl.h
@@ -354,9 +354,6 @@ struct mpt_ioctl_command32 {
354 354
355 355
356/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 356/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
357/*
358 * HP Specific IOCTL Defines and Structures
359 */
360 357
361#define CPQFCTS_IOC_MAGIC 'Z' 358#define CPQFCTS_IOC_MAGIC 'Z'
362#define HP_IOC_MAGIC 'Z' 359#define HP_IOC_MAGIC 'Z'
@@ -364,8 +361,6 @@ struct mpt_ioctl_command32 {
364#define HP_GETHOSTINFO1 _IOR(HP_IOC_MAGIC, 20, hp_host_info_rev0_t) 361#define HP_GETHOSTINFO1 _IOR(HP_IOC_MAGIC, 20, hp_host_info_rev0_t)
365#define HP_GETTARGETINFO _IOR(HP_IOC_MAGIC, 21, hp_target_info_t) 362#define HP_GETTARGETINFO _IOR(HP_IOC_MAGIC, 21, hp_target_info_t)
366 363
367/* All HP IOCTLs must include this header
368 */
369typedef struct _hp_header { 364typedef struct _hp_header {
370 unsigned int iocnum; 365 unsigned int iocnum;
371 unsigned int host; 366 unsigned int host;
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index 74714e5bcf03..e57bb035a021 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -77,10 +77,6 @@ MODULE_DESCRIPTION(my_NAME);
77MODULE_LICENSE("GPL"); 77MODULE_LICENSE("GPL");
78 78
79/* Command line args */ 79/* Command line args */
80static int mpt_pq_filter = 0;
81module_param(mpt_pq_filter, int, 0);
82MODULE_PARM_DESC(mpt_pq_filter, " Enable peripheral qualifier filter: enable=1 (default=0)");
83
84#define MPTFC_DEV_LOSS_TMO (60) 80#define MPTFC_DEV_LOSS_TMO (60)
85static int mptfc_dev_loss_tmo = MPTFC_DEV_LOSS_TMO; /* reasonable default */ 81static int mptfc_dev_loss_tmo = MPTFC_DEV_LOSS_TMO; /* reasonable default */
86module_param(mptfc_dev_loss_tmo, int, 0); 82module_param(mptfc_dev_loss_tmo, int, 0);
@@ -132,21 +128,21 @@ static struct scsi_host_template mptfc_driver_template = {
132 */ 128 */
133 129
134static struct pci_device_id mptfc_pci_table[] = { 130static struct pci_device_id mptfc_pci_table[] = {
135 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC909, 131 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC909,
136 PCI_ANY_ID, PCI_ANY_ID }, 132 PCI_ANY_ID, PCI_ANY_ID },
137 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC919, 133 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC919,
138 PCI_ANY_ID, PCI_ANY_ID }, 134 PCI_ANY_ID, PCI_ANY_ID },
139 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC929, 135 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC929,
140 PCI_ANY_ID, PCI_ANY_ID }, 136 PCI_ANY_ID, PCI_ANY_ID },
141 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC919X, 137 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC919X,
142 PCI_ANY_ID, PCI_ANY_ID }, 138 PCI_ANY_ID, PCI_ANY_ID },
143 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC929X, 139 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC929X,
144 PCI_ANY_ID, PCI_ANY_ID }, 140 PCI_ANY_ID, PCI_ANY_ID },
145 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC939X, 141 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC939X,
146 PCI_ANY_ID, PCI_ANY_ID }, 142 PCI_ANY_ID, PCI_ANY_ID },
147 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC949X, 143 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC949X,
148 PCI_ANY_ID, PCI_ANY_ID }, 144 PCI_ANY_ID, PCI_ANY_ID },
149 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC949ES, 145 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC949E,
150 PCI_ANY_ID, PCI_ANY_ID }, 146 PCI_ANY_ID, PCI_ANY_ID },
151 {0} /* Terminating entry */ 147 {0} /* Terminating entry */
152}; 148};
@@ -166,7 +162,13 @@ static struct fc_function_template mptfc_transport_functions = {
166 .show_starget_port_id = 1, 162 .show_starget_port_id = 1,
167 .set_rport_dev_loss_tmo = mptfc_set_rport_loss_tmo, 163 .set_rport_dev_loss_tmo = mptfc_set_rport_loss_tmo,
168 .show_rport_dev_loss_tmo = 1, 164 .show_rport_dev_loss_tmo = 1,
169 165 .show_host_supported_speeds = 1,
166 .show_host_maxframe_size = 1,
167 .show_host_speed = 1,
168 .show_host_fabric_name = 1,
169 .show_host_port_type = 1,
170 .show_host_port_state = 1,
171 .show_host_symbolic_name = 1,
170}; 172};
171 173
172static void 174static void
@@ -305,10 +307,8 @@ mptfc_GetFcDevPage0(MPT_ADAPTER *ioc, int ioc_port,
305 } 307 }
306 308
307 out: 309 out:
308 if (pp0_array) 310 kfree(pp0_array);
309 kfree(pp0_array); 311 kfree(p0_array);
310 if (p0_array)
311 kfree(p0_array);
312 return rc; 312 return rc;
313} 313}
314 314
@@ -515,8 +515,7 @@ mptfc_slave_alloc(struct scsi_device *sdev)
515 515
516 if (vtarget->num_luns == 0) { 516 if (vtarget->num_luns == 0) {
517 vtarget->ioc_id = hd->ioc->id; 517 vtarget->ioc_id = hd->ioc->id;
518 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES | 518 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES;
519 MPT_TARGET_FLAGS_VALID_INQUIRY;
520 hd->Targets[sdev->id] = vtarget; 519 hd->Targets[sdev->id] = vtarget;
521 } 520 }
522 521
@@ -676,7 +675,10 @@ mptfc_GetFcPortPage0(MPT_ADAPTER *ioc, int portnum)
676 * if still doing discovery, 675 * if still doing discovery,
677 * hang loose a while until finished 676 * hang loose a while until finished
678 */ 677 */
679 if (pp0dest->PortState == MPI_FCPORTPAGE0_PORTSTATE_UNKNOWN) { 678 if ((pp0dest->PortState == MPI_FCPORTPAGE0_PORTSTATE_UNKNOWN) ||
679 (pp0dest->PortState == MPI_FCPORTPAGE0_PORTSTATE_ONLINE &&
680 (pp0dest->Flags & MPI_FCPORTPAGE0_FLAGS_ATTACH_TYPE_MASK)
681 == MPI_FCPORTPAGE0_FLAGS_ATTACH_NO_INIT)) {
680 if (count-- > 0) { 682 if (count-- > 0) {
681 msleep(100); 683 msleep(100);
682 goto try_again; 684 goto try_again;
@@ -843,33 +845,95 @@ mptfc_SetFcPortPage1_defaults(MPT_ADAPTER *ioc)
843static void 845static void
844mptfc_init_host_attr(MPT_ADAPTER *ioc,int portnum) 846mptfc_init_host_attr(MPT_ADAPTER *ioc,int portnum)
845{ 847{
846 unsigned class = 0, cos = 0; 848 unsigned class = 0;
849 unsigned cos = 0;
850 unsigned speed;
851 unsigned port_type;
852 unsigned port_state;
853 FCPortPage0_t *pp0;
854 struct Scsi_Host *sh;
855 char *sn;
847 856
848 /* don't know what to do as only one scsi (fc) host was allocated */ 857 /* don't know what to do as only one scsi (fc) host was allocated */
849 if (portnum != 0) 858 if (portnum != 0)
850 return; 859 return;
851 860
852 class = ioc->fc_port_page0[portnum].SupportedServiceClass; 861 pp0 = &ioc->fc_port_page0[portnum];
862 sh = ioc->sh;
863
864 sn = fc_host_symbolic_name(sh);
865 snprintf(sn, FC_SYMBOLIC_NAME_SIZE, "%s %s%08xh",
866 ioc->prod_name,
867 MPT_FW_REV_MAGIC_ID_STRING,
868 ioc->facts.FWVersion.Word);
869
870 fc_host_tgtid_bind_type(sh) = FC_TGTID_BIND_BY_WWPN;
871
872 fc_host_maxframe_size(sh) = pp0->MaxFrameSize;
873
874 fc_host_node_name(sh) =
875 (u64)pp0->WWNN.High << 32 | (u64)pp0->WWNN.Low;
876
877 fc_host_port_name(sh) =
878 (u64)pp0->WWPN.High << 32 | (u64)pp0->WWPN.Low;
879
880 fc_host_port_id(sh) = pp0->PortIdentifier;
881
882 class = pp0->SupportedServiceClass;
853 if (class & MPI_FCPORTPAGE0_SUPPORT_CLASS_1) 883 if (class & MPI_FCPORTPAGE0_SUPPORT_CLASS_1)
854 cos |= FC_COS_CLASS1; 884 cos |= FC_COS_CLASS1;
855 if (class & MPI_FCPORTPAGE0_SUPPORT_CLASS_2) 885 if (class & MPI_FCPORTPAGE0_SUPPORT_CLASS_2)
856 cos |= FC_COS_CLASS2; 886 cos |= FC_COS_CLASS2;
857 if (class & MPI_FCPORTPAGE0_SUPPORT_CLASS_3) 887 if (class & MPI_FCPORTPAGE0_SUPPORT_CLASS_3)
858 cos |= FC_COS_CLASS3; 888 cos |= FC_COS_CLASS3;
889 fc_host_supported_classes(sh) = cos;
890
891 if (pp0->CurrentSpeed == MPI_FCPORTPAGE0_CURRENT_SPEED_1GBIT)
892 speed = FC_PORTSPEED_1GBIT;
893 else if (pp0->CurrentSpeed == MPI_FCPORTPAGE0_CURRENT_SPEED_2GBIT)
894 speed = FC_PORTSPEED_2GBIT;
895 else if (pp0->CurrentSpeed == MPI_FCPORTPAGE0_CURRENT_SPEED_4GBIT)
896 speed = FC_PORTSPEED_4GBIT;
897 else if (pp0->CurrentSpeed == MPI_FCPORTPAGE0_CURRENT_SPEED_10GBIT)
898 speed = FC_PORTSPEED_10GBIT;
899 else
900 speed = FC_PORTSPEED_UNKNOWN;
901 fc_host_speed(sh) = speed;
902
903 speed = 0;
904 if (pp0->SupportedSpeeds & MPI_FCPORTPAGE0_SUPPORT_1GBIT_SPEED)
905 speed |= FC_PORTSPEED_1GBIT;
906 if (pp0->SupportedSpeeds & MPI_FCPORTPAGE0_SUPPORT_2GBIT_SPEED)
907 speed |= FC_PORTSPEED_2GBIT;
908 if (pp0->SupportedSpeeds & MPI_FCPORTPAGE0_SUPPORT_4GBIT_SPEED)
909 speed |= FC_PORTSPEED_4GBIT;
910 if (pp0->SupportedSpeeds & MPI_FCPORTPAGE0_SUPPORT_10GBIT_SPEED)
911 speed |= FC_PORTSPEED_10GBIT;
912 fc_host_supported_speeds(sh) = speed;
913
914 port_state = FC_PORTSTATE_UNKNOWN;
915 if (pp0->PortState == MPI_FCPORTPAGE0_PORTSTATE_ONLINE)
916 port_state = FC_PORTSTATE_ONLINE;
917 else if (pp0->PortState == MPI_FCPORTPAGE0_PORTSTATE_OFFLINE)
918 port_state = FC_PORTSTATE_LINKDOWN;
919 fc_host_port_state(sh) = port_state;
920
921 port_type = FC_PORTTYPE_UNKNOWN;
922 if (pp0->Flags & MPI_FCPORTPAGE0_FLAGS_ATTACH_POINT_TO_POINT)
923 port_type = FC_PORTTYPE_PTP;
924 else if (pp0->Flags & MPI_FCPORTPAGE0_FLAGS_ATTACH_PRIVATE_LOOP)
925 port_type = FC_PORTTYPE_LPORT;
926 else if (pp0->Flags & MPI_FCPORTPAGE0_FLAGS_ATTACH_PUBLIC_LOOP)
927 port_type = FC_PORTTYPE_NLPORT;
928 else if (pp0->Flags & MPI_FCPORTPAGE0_FLAGS_ATTACH_FABRIC_DIRECT)
929 port_type = FC_PORTTYPE_NPORT;
930 fc_host_port_type(sh) = port_type;
931
932 fc_host_fabric_name(sh) =
933 (pp0->Flags & MPI_FCPORTPAGE0_FLAGS_FABRIC_WWN_VALID) ?
934 (u64) pp0->FabricWWNN.High << 32 | (u64) pp0->FabricWWPN.Low :
935 (u64)pp0->WWNN.High << 32 | (u64)pp0->WWNN.Low;
859 936
860 fc_host_node_name(ioc->sh) =
861 (u64)ioc->fc_port_page0[portnum].WWNN.High << 32
862 | (u64)ioc->fc_port_page0[portnum].WWNN.Low;
863
864 fc_host_port_name(ioc->sh) =
865 (u64)ioc->fc_port_page0[portnum].WWPN.High << 32
866 | (u64)ioc->fc_port_page0[portnum].WWPN.Low;
867
868 fc_host_port_id(ioc->sh) = ioc->fc_port_page0[portnum].PortIdentifier;
869
870 fc_host_supported_classes(ioc->sh) = cos;
871
872 fc_host_tgtid_bind_type(ioc->sh) = FC_TGTID_BIND_BY_WWPN;
873} 937}
874 938
875static void 939static void
@@ -902,59 +966,45 @@ mptfc_rescan_devices(void *arg)
902{ 966{
903 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; 967 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg;
904 int ii; 968 int ii;
905 int work_to_do;
906 u64 pn; 969 u64 pn;
907 unsigned long flags;
908 struct mptfc_rport_info *ri; 970 struct mptfc_rport_info *ri;
909 971
910 do { 972 /* start by tagging all ports as missing */
911 /* start by tagging all ports as missing */ 973 list_for_each_entry(ri, &ioc->fc_rports, list) {
912 list_for_each_entry(ri, &ioc->fc_rports, list) { 974 if (ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED) {
913 if (ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED) { 975 ri->flags |= MPT_RPORT_INFO_FLAGS_MISSING;
914 ri->flags |= MPT_RPORT_INFO_FLAGS_MISSING;
915 }
916 } 976 }
977 }
917 978
918 /* 979 /*
919 * now rescan devices known to adapter, 980 * now rescan devices known to adapter,
920 * will reregister existing rports 981 * will reregister existing rports
921 */ 982 */
922 for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) { 983 for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) {
923 (void) mptfc_GetFcPortPage0(ioc, ii); 984 (void) mptfc_GetFcPortPage0(ioc, ii);
924 mptfc_init_host_attr(ioc,ii); /* refresh */ 985 mptfc_init_host_attr(ioc, ii); /* refresh */
925 mptfc_GetFcDevPage0(ioc,ii,mptfc_register_dev); 986 mptfc_GetFcDevPage0(ioc, ii, mptfc_register_dev);
926 } 987 }
927 988
928 /* delete devices still missing */ 989 /* delete devices still missing */
929 list_for_each_entry(ri, &ioc->fc_rports, list) { 990 list_for_each_entry(ri, &ioc->fc_rports, list) {
930 /* if newly missing, delete it */ 991 /* if newly missing, delete it */
931 if (ri->flags & MPT_RPORT_INFO_FLAGS_MISSING) { 992 if (ri->flags & MPT_RPORT_INFO_FLAGS_MISSING) {
932 993
933 ri->flags &= ~(MPT_RPORT_INFO_FLAGS_REGISTERED| 994 ri->flags &= ~(MPT_RPORT_INFO_FLAGS_REGISTERED|
934 MPT_RPORT_INFO_FLAGS_MISSING); 995 MPT_RPORT_INFO_FLAGS_MISSING);
935 fc_remote_port_delete(ri->rport); /* won't sleep */ 996 fc_remote_port_delete(ri->rport); /* won't sleep */
936 ri->rport = NULL; 997 ri->rport = NULL;
937 998
938 pn = (u64)ri->pg0.WWPN.High << 32 | 999 pn = (u64)ri->pg0.WWPN.High << 32 |
939 (u64)ri->pg0.WWPN.Low; 1000 (u64)ri->pg0.WWPN.Low;
940 dfcprintk ((MYIOC_s_INFO_FMT 1001 dfcprintk ((MYIOC_s_INFO_FMT
941 "mptfc_rescan.%d: %llx deleted\n", 1002 "mptfc_rescan.%d: %llx deleted\n",
942 ioc->name, 1003 ioc->name,
943 ioc->sh->host_no, 1004 ioc->sh->host_no,
944 (unsigned long long)pn)); 1005 (unsigned long long)pn));
945 }
946 } 1006 }
947 1007 }
948 /*
949 * allow multiple passes as target state
950 * might have changed during scan
951 */
952 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);
953 if (ioc->fc_rescan_work_count > 2) /* only need one more */
954 ioc->fc_rescan_work_count = 2;
955 work_to_do = --ioc->fc_rescan_work_count;
956 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);
957 } while (work_to_do);
958} 1008}
959 1009
960static int 1010static int
@@ -1131,13 +1181,6 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1131 hd->timer.data = (unsigned long) hd; 1181 hd->timer.data = (unsigned long) hd;
1132 hd->timer.function = mptscsih_timer_expired; 1182 hd->timer.function = mptscsih_timer_expired;
1133 1183
1134 hd->mpt_pq_filter = mpt_pq_filter;
1135
1136 ddvprintk((MYIOC_s_INFO_FMT
1137 "mpt_pq_filter %x\n",
1138 ioc->name,
1139 mpt_pq_filter));
1140
1141 init_waitqueue_head(&hd->scandv_waitq); 1184 init_waitqueue_head(&hd->scandv_waitq);
1142 hd->scandv_wait_done = 0; 1185 hd->scandv_wait_done = 0;
1143 hd->last_queue_full = 0; 1186 hd->last_queue_full = 0;
@@ -1173,7 +1216,6 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1173 * by doing it via the workqueue, some locking is eliminated 1216 * by doing it via the workqueue, some locking is eliminated
1174 */ 1217 */
1175 1218
1176 ioc->fc_rescan_work_count = 1;
1177 queue_work(ioc->fc_rescan_work_q, &ioc->fc_rescan_work); 1219 queue_work(ioc->fc_rescan_work_q, &ioc->fc_rescan_work);
1178 flush_workqueue(ioc->fc_rescan_work_q); 1220 flush_workqueue(ioc->fc_rescan_work_q);
1179 1221
@@ -1216,10 +1258,8 @@ mptfc_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
1216 case MPI_EVENT_RESCAN: 1258 case MPI_EVENT_RESCAN:
1217 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags); 1259 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);
1218 if (ioc->fc_rescan_work_q) { 1260 if (ioc->fc_rescan_work_q) {
1219 if (ioc->fc_rescan_work_count++ == 0) { 1261 queue_work(ioc->fc_rescan_work_q,
1220 queue_work(ioc->fc_rescan_work_q, 1262 &ioc->fc_rescan_work);
1221 &ioc->fc_rescan_work);
1222 }
1223 } 1263 }
1224 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); 1264 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);
1225 break; 1265 break;
@@ -1262,10 +1302,8 @@ mptfc_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
1262 mptfc_SetFcPortPage1_defaults(ioc); 1302 mptfc_SetFcPortPage1_defaults(ioc);
1263 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags); 1303 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);
1264 if (ioc->fc_rescan_work_q) { 1304 if (ioc->fc_rescan_work_q) {
1265 if (ioc->fc_rescan_work_count++ == 0) { 1305 queue_work(ioc->fc_rescan_work_q,
1266 queue_work(ioc->fc_rescan_work_q, 1306 &ioc->fc_rescan_work);
1267 &ioc->fc_rescan_work);
1268 }
1269 } 1307 }
1270 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); 1308 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);
1271 } 1309 }
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index af6ec553ff7c..b752a479f6db 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -50,11 +50,14 @@
50#include <linux/errno.h> 50#include <linux/errno.h>
51#include <linux/sched.h> 51#include <linux/sched.h>
52#include <linux/workqueue.h> 52#include <linux/workqueue.h>
53#include <linux/delay.h> /* for mdelay */
53 54
55#include <scsi/scsi.h>
54#include <scsi/scsi_cmnd.h> 56#include <scsi/scsi_cmnd.h>
55#include <scsi/scsi_device.h> 57#include <scsi/scsi_device.h>
56#include <scsi/scsi_host.h> 58#include <scsi/scsi_host.h>
57#include <scsi/scsi_transport_sas.h> 59#include <scsi/scsi_transport_sas.h>
60#include <scsi/scsi_dbg.h>
58 61
59#include "mptbase.h" 62#include "mptbase.h"
60#include "mptscsih.h" 63#include "mptscsih.h"
@@ -64,20 +67,19 @@
64#define my_VERSION MPT_LINUX_VERSION_COMMON 67#define my_VERSION MPT_LINUX_VERSION_COMMON
65#define MYNAM "mptsas" 68#define MYNAM "mptsas"
66 69
70/*
71 * Reserved channel for integrated raid
72 */
73#define MPTSAS_RAID_CHANNEL 1
74
67MODULE_AUTHOR(MODULEAUTHOR); 75MODULE_AUTHOR(MODULEAUTHOR);
68MODULE_DESCRIPTION(my_NAME); 76MODULE_DESCRIPTION(my_NAME);
69MODULE_LICENSE("GPL"); 77MODULE_LICENSE("GPL");
70 78
71static int mpt_pq_filter;
72module_param(mpt_pq_filter, int, 0);
73MODULE_PARM_DESC(mpt_pq_filter,
74 "Enable peripheral qualifier filter: enable=1 "
75 "(default=0)");
76
77static int mpt_pt_clear; 79static int mpt_pt_clear;
78module_param(mpt_pt_clear, int, 0); 80module_param(mpt_pt_clear, int, 0);
79MODULE_PARM_DESC(mpt_pt_clear, 81MODULE_PARM_DESC(mpt_pt_clear,
80 "Clear persistency table: enable=1 " 82 " Clear persistency table: enable=1 "
81 "(default=MPTSCSIH_PT_CLEAR=0)"); 83 "(default=MPTSCSIH_PT_CLEAR=0)");
82 84
83static int mptsasDoneCtx = -1; 85static int mptsasDoneCtx = -1;
@@ -137,23 +139,36 @@ struct mptsas_devinfo {
137 u32 device_info; /* bitfield detailed info about this device */ 139 u32 device_info; /* bitfield detailed info about this device */
138}; 140};
139 141
142/*
143 * Specific details on ports, wide/narrow
144 */
145struct mptsas_portinfo_details{
146 u16 num_phys; /* number of phys belong to this port */
147 u64 phy_bitmask; /* TODO, extend support for 255 phys */
148 struct sas_rphy *rphy; /* transport layer rphy object */
149 struct sas_port *port; /* transport layer port object */
150 struct scsi_target *starget;
151 struct mptsas_portinfo *port_info;
152};
153
140struct mptsas_phyinfo { 154struct mptsas_phyinfo {
141 u8 phy_id; /* phy index */ 155 u8 phy_id; /* phy index */
142 u8 port_id; /* port number this phy is part of */ 156 u8 port_id; /* firmware port identifier */
143 u8 negotiated_link_rate; /* nego'd link rate for this phy */ 157 u8 negotiated_link_rate; /* nego'd link rate for this phy */
144 u8 hw_link_rate; /* hardware max/min phys link rate */ 158 u8 hw_link_rate; /* hardware max/min phys link rate */
145 u8 programmed_link_rate; /* programmed max/min phy link rate */ 159 u8 programmed_link_rate; /* programmed max/min phy link rate */
160 u8 sas_port_add_phy; /* flag to request sas_port_add_phy*/
146 struct mptsas_devinfo identify; /* point to phy device info */ 161 struct mptsas_devinfo identify; /* point to phy device info */
147 struct mptsas_devinfo attached; /* point to attached device info */ 162 struct mptsas_devinfo attached; /* point to attached device info */
148 struct sas_phy *phy; 163 struct sas_phy *phy; /* transport layer phy object */
149 struct sas_rphy *rphy; 164 struct mptsas_portinfo *portinfo;
150 struct scsi_target *starget; 165 struct mptsas_portinfo_details * port_details;
151}; 166};
152 167
153struct mptsas_portinfo { 168struct mptsas_portinfo {
154 struct list_head list; 169 struct list_head list;
155 u16 handle; /* unique id to address this */ 170 u16 handle; /* unique id to address this */
156 u8 num_phys; /* number of phys */ 171 u16 num_phys; /* number of phys */
157 struct mptsas_phyinfo *phy_info; 172 struct mptsas_phyinfo *phy_info;
158}; 173};
159 174
@@ -169,7 +184,7 @@ struct mptsas_enclosure {
169 u8 sep_channel; /* SEP channel logical channel id */ 184 u8 sep_channel; /* SEP channel logical channel id */
170}; 185};
171 186
172#ifdef SASDEBUG 187#ifdef MPT_DEBUG_SAS
173static void mptsas_print_phy_data(MPI_SAS_IO_UNIT0_PHY_DATA *phy_data) 188static void mptsas_print_phy_data(MPI_SAS_IO_UNIT0_PHY_DATA *phy_data)
174{ 189{
175 printk("---- IO UNIT PAGE 0 ------------\n"); 190 printk("---- IO UNIT PAGE 0 ------------\n");
@@ -305,7 +320,7 @@ mptsas_find_portinfo_by_handle(MPT_ADAPTER *ioc, u16 handle)
305static inline int 320static inline int
306mptsas_is_end_device(struct mptsas_devinfo * attached) 321mptsas_is_end_device(struct mptsas_devinfo * attached)
307{ 322{
308 if ((attached->handle) && 323 if ((attached->sas_address) &&
309 (attached->device_info & 324 (attached->device_info &
310 MPI_SAS_DEVICE_INFO_END_DEVICE) && 325 MPI_SAS_DEVICE_INFO_END_DEVICE) &&
311 ((attached->device_info & 326 ((attached->device_info &
@@ -319,6 +334,247 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
319 return 0; 334 return 0;
320} 335}
321 336
337/* no mutex */
338static void
339mptsas_port_delete(struct mptsas_portinfo_details * port_details)
340{
341 struct mptsas_portinfo *port_info;
342 struct mptsas_phyinfo *phy_info;
343 u8 i;
344
345 if (!port_details)
346 return;
347
348 port_info = port_details->port_info;
349 phy_info = port_info->phy_info;
350
351 dsaswideprintk((KERN_DEBUG "%s: [%p]: num_phys=%02d "
352 "bitmask=0x%016llX\n",
353 __FUNCTION__, port_details, port_details->num_phys,
354 port_details->phy_bitmask));
355
356 for (i = 0; i < port_info->num_phys; i++, phy_info++) {
357 if(phy_info->port_details != port_details)
358 continue;
359 memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo));
360 phy_info->port_details = NULL;
361 }
362 kfree(port_details);
363}
364
365static inline struct sas_rphy *
366mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
367{
368 if (phy_info->port_details)
369 return phy_info->port_details->rphy;
370 else
371 return NULL;
372}
373
374static inline void
375mptsas_set_rphy(struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
376{
377 if (phy_info->port_details) {
378 phy_info->port_details->rphy = rphy;
379 dsaswideprintk((KERN_DEBUG "sas_rphy_add: rphy=%p\n", rphy));
380 }
381
382#ifdef MPT_DEBUG_SAS_WIDE
383 if (rphy) {
384 dev_printk(KERN_DEBUG, &rphy->dev, "add:");
385 printk("rphy=%p release=%p\n",
386 rphy, rphy->dev.release);
387 }
388#endif
389}
390
391static inline struct sas_port *
392mptsas_get_port(struct mptsas_phyinfo *phy_info)
393{
394 if (phy_info->port_details)
395 return phy_info->port_details->port;
396 else
397 return NULL;
398}
399
400static inline void
401mptsas_set_port(struct mptsas_phyinfo *phy_info, struct sas_port *port)
402{
403 if (phy_info->port_details)
404 phy_info->port_details->port = port;
405
406#ifdef MPT_DEBUG_SAS_WIDE
407 if (port) {
408 dev_printk(KERN_DEBUG, &port->dev, "add: ");
409 printk("port=%p release=%p\n",
410 port, port->dev.release);
411 }
412#endif
413}
414
415static inline struct scsi_target *
416mptsas_get_starget(struct mptsas_phyinfo *phy_info)
417{
418 if (phy_info->port_details)
419 return phy_info->port_details->starget;
420 else
421 return NULL;
422}
423
424static inline void
425mptsas_set_starget(struct mptsas_phyinfo *phy_info, struct scsi_target *
426starget)
427{
428 if (phy_info->port_details)
429 phy_info->port_details->starget = starget;
430}
431
432
433/*
434 * mptsas_setup_wide_ports
435 *
436 * Updates for new and existing narrow/wide port configuration
437 * in the sas_topology
438 */
439static void
440mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
441{
442 struct mptsas_portinfo_details * port_details;
443 struct mptsas_phyinfo *phy_info, *phy_info_cmp;
444 u64 sas_address;
445 int i, j;
446
447 mutex_lock(&ioc->sas_topology_mutex);
448
449 phy_info = port_info->phy_info;
450 for (i = 0 ; i < port_info->num_phys ; i++, phy_info++) {
451 if (phy_info->attached.handle)
452 continue;
453 port_details = phy_info->port_details;
454 if (!port_details)
455 continue;
456 if (port_details->num_phys < 2)
457 continue;
458 /*
459 * Removing a phy from a port, letting the last
460 * phy be removed by firmware events.
461 */
462 dsaswideprintk((KERN_DEBUG
463 "%s: [%p]: deleting phy = %d\n",
464 __FUNCTION__, port_details, i));
465 port_details->num_phys--;
466 port_details->phy_bitmask &= ~ (1 << phy_info->phy_id);
467 memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo));
468 sas_port_delete_phy(port_details->port, phy_info->phy);
469 phy_info->port_details = NULL;
470 }
471
472 /*
473 * Populate and refresh the tree
474 */
475 phy_info = port_info->phy_info;
476 for (i = 0 ; i < port_info->num_phys ; i++, phy_info++) {
477 sas_address = phy_info->attached.sas_address;
478 dsaswideprintk((KERN_DEBUG "phy_id=%d sas_address=0x%018llX\n",
479 i, sas_address));
480 if (!sas_address)
481 continue;
482 port_details = phy_info->port_details;
483 /*
484 * Forming a port
485 */
486 if (!port_details) {
487 port_details = kzalloc(sizeof(*port_details),
488 GFP_KERNEL);
489 if (!port_details)
490 goto out;
491 port_details->num_phys = 1;
492 port_details->port_info = port_info;
493 if (phy_info->phy_id < 64 )
494 port_details->phy_bitmask |=
495 (1 << phy_info->phy_id);
496 phy_info->sas_port_add_phy=1;
497 dsaswideprintk((KERN_DEBUG "\t\tForming port\n\t\t"
498 "phy_id=%d sas_address=0x%018llX\n",
499 i, sas_address));
500 phy_info->port_details = port_details;
501 }
502
503 if (i == port_info->num_phys - 1)
504 continue;
505 phy_info_cmp = &port_info->phy_info[i + 1];
506 for (j = i + 1 ; j < port_info->num_phys ; j++,
507 phy_info_cmp++) {
508 if (!phy_info_cmp->attached.sas_address)
509 continue;
510 if (sas_address != phy_info_cmp->attached.sas_address)
511 continue;
512 if (phy_info_cmp->port_details == port_details )
513 continue;
514 dsaswideprintk((KERN_DEBUG
515 "\t\tphy_id=%d sas_address=0x%018llX\n",
516 j, phy_info_cmp->attached.sas_address));
517 if (phy_info_cmp->port_details) {
518 port_details->rphy =
519 mptsas_get_rphy(phy_info_cmp);
520 port_details->port =
521 mptsas_get_port(phy_info_cmp);
522 port_details->starget =
523 mptsas_get_starget(phy_info_cmp);
524 port_details->num_phys =
525 phy_info_cmp->port_details->num_phys;
526 if (!phy_info_cmp->port_details->num_phys)
527 kfree(phy_info_cmp->port_details);
528 } else
529 phy_info_cmp->sas_port_add_phy=1;
530 /*
531 * Adding a phy to a port
532 */
533 phy_info_cmp->port_details = port_details;
534 if (phy_info_cmp->phy_id < 64 )
535 port_details->phy_bitmask |=
536 (1 << phy_info_cmp->phy_id);
537 port_details->num_phys++;
538 }
539 }
540
541 out:
542
543#ifdef MPT_DEBUG_SAS_WIDE
544 for (i = 0; i < port_info->num_phys; i++) {
545 port_details = port_info->phy_info[i].port_details;
546 if (!port_details)
547 continue;
548 dsaswideprintk((KERN_DEBUG
549 "%s: [%p]: phy_id=%02d num_phys=%02d "
550 "bitmask=0x%016llX\n",
551 __FUNCTION__,
552 port_details, i, port_details->num_phys,
553 port_details->phy_bitmask));
554 dsaswideprintk((KERN_DEBUG"\t\tport = %p rphy=%p\n",
555 port_details->port, port_details->rphy));
556 }
557 dsaswideprintk((KERN_DEBUG"\n"));
558#endif
559 mutex_unlock(&ioc->sas_topology_mutex);
560}
561
562static void
563mptsas_target_reset(MPT_ADAPTER *ioc, VirtTarget * vtarget)
564{
565 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)ioc->sh->hostdata;
566
567 if (mptscsih_TMHandler(hd,
568 MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
569 vtarget->bus_id, vtarget->target_id, 0, 0, 5) < 0) {
570 hd->tmPending = 0;
571 hd->tmState = TM_STATE_NONE;
572 printk(MYIOC_s_WARN_FMT
573 "Error processing TaskMgmt id=%d TARGET_RESET\n",
574 ioc->name, vtarget->target_id);
575 }
576}
577
322static int 578static int
323mptsas_sas_enclosure_pg0(MPT_ADAPTER *ioc, struct mptsas_enclosure *enclosure, 579mptsas_sas_enclosure_pg0(MPT_ADAPTER *ioc, struct mptsas_enclosure *enclosure,
324 u32 form, u32 form_specific) 580 u32 form, u32 form_specific)
@@ -387,24 +643,112 @@ mptsas_sas_enclosure_pg0(MPT_ADAPTER *ioc, struct mptsas_enclosure *enclosure,
387static int 643static int
388mptsas_slave_configure(struct scsi_device *sdev) 644mptsas_slave_configure(struct scsi_device *sdev)
389{ 645{
390 struct Scsi_Host *host = sdev->host;
391 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
392 646
393 /* 647 if (sdev->channel == MPTSAS_RAID_CHANNEL)
394 * RAID volumes placed beyond the last expected port. 648 goto out;
395 * Ignore sending sas mode pages in that case..
396 */
397 if (sdev->channel < hd->ioc->num_ports)
398 sas_read_port_mode_page(sdev);
399 649
650 sas_read_port_mode_page(sdev);
651
652 out:
400 return mptscsih_slave_configure(sdev); 653 return mptscsih_slave_configure(sdev);
401} 654}
402 655
403/* 656static int
404 * This is pretty ugly. We will be able to seriously clean it up 657mptsas_target_alloc(struct scsi_target *starget)
405 * once the DV code in mptscsih goes away and we can properly 658{
406 * implement ->target_alloc. 659 struct Scsi_Host *host = dev_to_shost(&starget->dev);
407 */ 660 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
661 VirtTarget *vtarget;
662 u32 target_id;
663 u32 channel;
664 struct sas_rphy *rphy;
665 struct mptsas_portinfo *p;
666 int i;
667
668 vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL);
669 if (!vtarget)
670 return -ENOMEM;
671
672 vtarget->starget = starget;
673 vtarget->ioc_id = hd->ioc->id;
674 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES|MPT_TARGET_FLAGS_VALID_INQUIRY;
675
676 target_id = starget->id;
677 channel = 0;
678
679 hd->Targets[target_id] = vtarget;
680
681 if (starget->channel == MPTSAS_RAID_CHANNEL)
682 goto out;
683
684 rphy = dev_to_rphy(starget->dev.parent);
685 mutex_lock(&hd->ioc->sas_topology_mutex);
686 list_for_each_entry(p, &hd->ioc->sas_topology, list) {
687 for (i = 0; i < p->num_phys; i++) {
688 if (p->phy_info[i].attached.sas_address !=
689 rphy->identify.sas_address)
690 continue;
691 target_id = p->phy_info[i].attached.id;
692 channel = p->phy_info[i].attached.channel;
693 mptsas_set_starget(&p->phy_info[i], starget);
694
695 /*
696 * Exposing hidden raid components
697 */
698 if (mptscsih_is_phys_disk(hd->ioc, target_id)) {
699 target_id = mptscsih_raid_id_to_num(hd,
700 target_id);
701 vtarget->tflags |=
702 MPT_TARGET_FLAGS_RAID_COMPONENT;
703 }
704 mutex_unlock(&hd->ioc->sas_topology_mutex);
705 goto out;
706 }
707 }
708 mutex_unlock(&hd->ioc->sas_topology_mutex);
709
710 kfree(vtarget);
711 return -ENXIO;
712
713 out:
714 vtarget->target_id = target_id;
715 vtarget->bus_id = channel;
716 starget->hostdata = vtarget;
717 return 0;
718}
719
720static void
721mptsas_target_destroy(struct scsi_target *starget)
722{
723 struct Scsi_Host *host = dev_to_shost(&starget->dev);
724 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
725 struct sas_rphy *rphy;
726 struct mptsas_portinfo *p;
727 int i;
728
729 if (!starget->hostdata)
730 return;
731
732 if (starget->channel == MPTSAS_RAID_CHANNEL)
733 goto out;
734
735 rphy = dev_to_rphy(starget->dev.parent);
736 list_for_each_entry(p, &hd->ioc->sas_topology, list) {
737 for (i = 0; i < p->num_phys; i++) {
738 if (p->phy_info[i].attached.sas_address !=
739 rphy->identify.sas_address)
740 continue;
741 mptsas_set_starget(&p->phy_info[i], NULL);
742 goto out;
743 }
744 }
745
746 out:
747 kfree(starget->hostdata);
748 starget->hostdata = NULL;
749}
750
751
408static int 752static int
409mptsas_slave_alloc(struct scsi_device *sdev) 753mptsas_slave_alloc(struct scsi_device *sdev)
410{ 754{
@@ -412,61 +756,38 @@ mptsas_slave_alloc(struct scsi_device *sdev)
412 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 756 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
413 struct sas_rphy *rphy; 757 struct sas_rphy *rphy;
414 struct mptsas_portinfo *p; 758 struct mptsas_portinfo *p;
415 VirtTarget *vtarget;
416 VirtDevice *vdev; 759 VirtDevice *vdev;
417 struct scsi_target *starget; 760 struct scsi_target *starget;
418 u32 target_id; 761 int i;
419 int i;
420 762
421 vdev = kzalloc(sizeof(VirtDevice), GFP_KERNEL); 763 vdev = kzalloc(sizeof(VirtDevice), GFP_KERNEL);
422 if (!vdev) { 764 if (!vdev) {
423 printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", 765 printk(MYIOC_s_ERR_FMT "slave_alloc kzalloc(%zd) FAILED!\n",
424 hd->ioc->name, sizeof(VirtDevice)); 766 hd->ioc->name, sizeof(VirtDevice));
425 return -ENOMEM; 767 return -ENOMEM;
426 } 768 }
427 sdev->hostdata = vdev;
428 starget = scsi_target(sdev); 769 starget = scsi_target(sdev);
429 vtarget = starget->hostdata; 770 vdev->vtarget = starget->hostdata;
430 vtarget->ioc_id = hd->ioc->id;
431 vdev->vtarget = vtarget;
432 if (vtarget->num_luns == 0) {
433 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES|MPT_TARGET_FLAGS_VALID_INQUIRY;
434 hd->Targets[sdev->id] = vtarget;
435 }
436 771
437 /* 772 if (sdev->channel == MPTSAS_RAID_CHANNEL)
438 RAID volumes placed beyond the last expected port.
439 */
440 if (sdev->channel == hd->ioc->num_ports) {
441 target_id = sdev->id;
442 vtarget->bus_id = 0;
443 vdev->lun = 0;
444 goto out; 773 goto out;
445 }
446 774
447 rphy = dev_to_rphy(sdev->sdev_target->dev.parent); 775 rphy = dev_to_rphy(sdev->sdev_target->dev.parent);
448 mutex_lock(&hd->ioc->sas_topology_mutex); 776 mutex_lock(&hd->ioc->sas_topology_mutex);
449 list_for_each_entry(p, &hd->ioc->sas_topology, list) { 777 list_for_each_entry(p, &hd->ioc->sas_topology, list) {
450 for (i = 0; i < p->num_phys; i++) { 778 for (i = 0; i < p->num_phys; i++) {
451 if (p->phy_info[i].attached.sas_address == 779 if (p->phy_info[i].attached.sas_address !=
452 rphy->identify.sas_address) { 780 rphy->identify.sas_address)
453 target_id = p->phy_info[i].attached.id; 781 continue;
454 vtarget->bus_id = p->phy_info[i].attached.channel; 782 vdev->lun = sdev->lun;
455 vdev->lun = sdev->lun; 783 /*
456 p->phy_info[i].starget = sdev->sdev_target; 784 * Exposing hidden raid components
457 /* 785 */
458 * Exposing hidden disk (RAID) 786 if (mptscsih_is_phys_disk(hd->ioc,
459 */ 787 p->phy_info[i].attached.id))
460 if (mptscsih_is_phys_disk(hd->ioc, target_id)) { 788 sdev->no_uld_attach = 1;
461 target_id = mptscsih_raid_id_to_num(hd, 789 mutex_unlock(&hd->ioc->sas_topology_mutex);
462 target_id); 790 goto out;
463 vdev->vtarget->tflags |=
464 MPT_TARGET_FLAGS_RAID_COMPONENT;
465 sdev->no_uld_attach = 1;
466 }
467 mutex_unlock(&hd->ioc->sas_topology_mutex);
468 goto out;
469 }
470 } 791 }
471 } 792 }
472 mutex_unlock(&hd->ioc->sas_topology_mutex); 793 mutex_unlock(&hd->ioc->sas_topology_mutex);
@@ -475,57 +796,39 @@ mptsas_slave_alloc(struct scsi_device *sdev)
475 return -ENXIO; 796 return -ENXIO;
476 797
477 out: 798 out:
478 vtarget->target_id = target_id; 799 vdev->vtarget->num_luns++;
479 vtarget->num_luns++; 800 sdev->hostdata = vdev;
480 return 0; 801 return 0;
481} 802}
482 803
483static void 804static int
484mptsas_slave_destroy(struct scsi_device *sdev) 805mptsas_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
485{ 806{
486 struct Scsi_Host *host = sdev->host; 807 VirtDevice *vdev = SCpnt->device->hostdata;
487 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
488 VirtDevice *vdev;
489 808
490 /* 809// scsi_print_command(SCpnt);
491 * Issue target reset to flush firmware outstanding commands. 810 if (vdev->vtarget->deleted) {
492 */ 811 SCpnt->result = DID_NO_CONNECT << 16;
493 vdev = sdev->hostdata; 812 done(SCpnt);
494 if (vdev->configured_lun){ 813 return 0;
495 if (mptscsih_TMHandler(hd,
496 MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
497 vdev->vtarget->bus_id,
498 vdev->vtarget->target_id,
499 0, 0, 5 /* 5 second timeout */)
500 < 0){
501
502 /* The TM request failed!
503 * Fatal error case.
504 */
505 printk(MYIOC_s_WARN_FMT
506 "Error processing TaskMgmt id=%d TARGET_RESET\n",
507 hd->ioc->name,
508 vdev->vtarget->target_id);
509
510 hd->tmPending = 0;
511 hd->tmState = TM_STATE_NONE;
512 }
513 } 814 }
514 mptscsih_slave_destroy(sdev); 815
816 return mptscsih_qcmd(SCpnt,done);
515} 817}
516 818
819
517static struct scsi_host_template mptsas_driver_template = { 820static struct scsi_host_template mptsas_driver_template = {
518 .module = THIS_MODULE, 821 .module = THIS_MODULE,
519 .proc_name = "mptsas", 822 .proc_name = "mptsas",
520 .proc_info = mptscsih_proc_info, 823 .proc_info = mptscsih_proc_info,
521 .name = "MPT SPI Host", 824 .name = "MPT SPI Host",
522 .info = mptscsih_info, 825 .info = mptscsih_info,
523 .queuecommand = mptscsih_qcmd, 826 .queuecommand = mptsas_qcmd,
524 .target_alloc = mptscsih_target_alloc, 827 .target_alloc = mptsas_target_alloc,
525 .slave_alloc = mptsas_slave_alloc, 828 .slave_alloc = mptsas_slave_alloc,
526 .slave_configure = mptsas_slave_configure, 829 .slave_configure = mptsas_slave_configure,
527 .target_destroy = mptscsih_target_destroy, 830 .target_destroy = mptsas_target_destroy,
528 .slave_destroy = mptsas_slave_destroy, 831 .slave_destroy = mptscsih_slave_destroy,
529 .change_queue_depth = mptscsih_change_queue_depth, 832 .change_queue_depth = mptscsih_change_queue_depth,
530 .eh_abort_handler = mptscsih_abort, 833 .eh_abort_handler = mptscsih_abort,
531 .eh_device_reset_handler = mptscsih_dev_reset, 834 .eh_device_reset_handler = mptscsih_dev_reset,
@@ -549,6 +852,10 @@ static int mptsas_get_linkerrors(struct sas_phy *phy)
549 dma_addr_t dma_handle; 852 dma_addr_t dma_handle;
550 int error; 853 int error;
551 854
855 /* FIXME: only have link errors on local phys */
856 if (!scsi_is_sas_phy_local(phy))
857 return -EINVAL;
858
552 hdr.PageVersion = MPI_SASPHY1_PAGEVERSION; 859 hdr.PageVersion = MPI_SASPHY1_PAGEVERSION;
553 hdr.ExtPageLength = 0; 860 hdr.ExtPageLength = 0;
554 hdr.PageNumber = 1 /* page number 1*/; 861 hdr.PageNumber = 1 /* page number 1*/;
@@ -621,6 +928,10 @@ static int mptsas_phy_reset(struct sas_phy *phy, int hard_reset)
621 unsigned long timeleft; 928 unsigned long timeleft;
622 int error = -ERESTARTSYS; 929 int error = -ERESTARTSYS;
623 930
931 /* FIXME: fusion doesn't allow non-local phy reset */
932 if (!scsi_is_sas_phy_local(phy))
933 return -EINVAL;
934
624 /* not implemented for expanders */ 935 /* not implemented for expanders */
625 if (phy->identify.target_port_protocols & SAS_PROTOCOL_SMP) 936 if (phy->identify.target_port_protocols & SAS_PROTOCOL_SMP)
626 return -ENXIO; 937 return -ENXIO;
@@ -795,7 +1106,7 @@ mptsas_sas_io_unit_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
795 1106
796 port_info->num_phys = buffer->NumPhys; 1107 port_info->num_phys = buffer->NumPhys;
797 port_info->phy_info = kcalloc(port_info->num_phys, 1108 port_info->phy_info = kcalloc(port_info->num_phys,
798 sizeof(struct mptsas_phyinfo),GFP_KERNEL); 1109 sizeof(*port_info->phy_info),GFP_KERNEL);
799 if (!port_info->phy_info) { 1110 if (!port_info->phy_info) {
800 error = -ENOMEM; 1111 error = -ENOMEM;
801 goto out_free_consistent; 1112 goto out_free_consistent;
@@ -811,6 +1122,7 @@ mptsas_sas_io_unit_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
811 buffer->PhyData[i].Port; 1122 buffer->PhyData[i].Port;
812 port_info->phy_info[i].negotiated_link_rate = 1123 port_info->phy_info[i].negotiated_link_rate =
813 buffer->PhyData[i].NegotiatedLinkRate; 1124 buffer->PhyData[i].NegotiatedLinkRate;
1125 port_info->phy_info[i].portinfo = port_info;
814 } 1126 }
815 1127
816 out_free_consistent: 1128 out_free_consistent:
@@ -968,7 +1280,7 @@ mptsas_sas_expander_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info,
968 CONFIGPARMS cfg; 1280 CONFIGPARMS cfg;
969 SasExpanderPage0_t *buffer; 1281 SasExpanderPage0_t *buffer;
970 dma_addr_t dma_handle; 1282 dma_addr_t dma_handle;
971 int error; 1283 int i, error;
972 1284
973 hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION; 1285 hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION;
974 hdr.ExtPageLength = 0; 1286 hdr.ExtPageLength = 0;
@@ -1013,12 +1325,15 @@ mptsas_sas_expander_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info,
1013 port_info->num_phys = buffer->NumPhys; 1325 port_info->num_phys = buffer->NumPhys;
1014 port_info->handle = le16_to_cpu(buffer->DevHandle); 1326 port_info->handle = le16_to_cpu(buffer->DevHandle);
1015 port_info->phy_info = kcalloc(port_info->num_phys, 1327 port_info->phy_info = kcalloc(port_info->num_phys,
1016 sizeof(struct mptsas_phyinfo),GFP_KERNEL); 1328 sizeof(*port_info->phy_info),GFP_KERNEL);
1017 if (!port_info->phy_info) { 1329 if (!port_info->phy_info) {
1018 error = -ENOMEM; 1330 error = -ENOMEM;
1019 goto out_free_consistent; 1331 goto out_free_consistent;
1020 } 1332 }
1021 1333
1334 for (i = 0; i < port_info->num_phys; i++)
1335 port_info->phy_info[i].portinfo = port_info;
1336
1022 out_free_consistent: 1337 out_free_consistent:
1023 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4, 1338 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
1024 buffer, dma_handle); 1339 buffer, dma_handle);
@@ -1161,19 +1476,23 @@ static int mptsas_probe_one_phy(struct device *dev,
1161{ 1476{
1162 MPT_ADAPTER *ioc; 1477 MPT_ADAPTER *ioc;
1163 struct sas_phy *phy; 1478 struct sas_phy *phy;
1164 int error; 1479 struct sas_port *port;
1480 int error = 0;
1165 1481
1166 if (!dev) 1482 if (!dev) {
1167 return -ENODEV; 1483 error = -ENODEV;
1484 goto out;
1485 }
1168 1486
1169 if (!phy_info->phy) { 1487 if (!phy_info->phy) {
1170 phy = sas_phy_alloc(dev, index); 1488 phy = sas_phy_alloc(dev, index);
1171 if (!phy) 1489 if (!phy) {
1172 return -ENOMEM; 1490 error = -ENOMEM;
1491 goto out;
1492 }
1173 } else 1493 } else
1174 phy = phy_info->phy; 1494 phy = phy_info->phy;
1175 1495
1176 phy->port_identifier = phy_info->port_id;
1177 mptsas_parse_device_info(&phy->identify, &phy_info->identify); 1496 mptsas_parse_device_info(&phy->identify, &phy_info->identify);
1178 1497
1179 /* 1498 /*
@@ -1259,25 +1578,54 @@ static int mptsas_probe_one_phy(struct device *dev,
1259 1578
1260 if (!phy_info->phy) { 1579 if (!phy_info->phy) {
1261 1580
1262 if (local)
1263 phy->local_attached = 1;
1264
1265 error = sas_phy_add(phy); 1581 error = sas_phy_add(phy);
1266 if (error) { 1582 if (error) {
1267 sas_phy_free(phy); 1583 sas_phy_free(phy);
1268 return error; 1584 goto out;
1269 } 1585 }
1270 phy_info->phy = phy; 1586 phy_info->phy = phy;
1271 } 1587 }
1272 1588
1273 if ((phy_info->attached.handle) && 1589 if (!phy_info->attached.handle ||
1274 (!phy_info->rphy)) { 1590 !phy_info->port_details)
1591 goto out;
1592
1593 port = mptsas_get_port(phy_info);
1594 ioc = phy_to_ioc(phy_info->phy);
1595
1596 if (phy_info->sas_port_add_phy) {
1597
1598 if (!port) {
1599 port = sas_port_alloc_num(dev);
1600 if (!port) {
1601 error = -ENOMEM;
1602 goto out;
1603 }
1604 error = sas_port_add(port);
1605 if (error) {
1606 dfailprintk((MYIOC_s_ERR_FMT
1607 "%s: exit at line=%d\n", ioc->name,
1608 __FUNCTION__, __LINE__));
1609 goto out;
1610 }
1611 mptsas_set_port(phy_info, port);
1612 dsaswideprintk((KERN_DEBUG
1613 "sas_port_alloc: port=%p dev=%p port_id=%d\n",
1614 port, dev, port->port_identifier));
1615 }
1616 dsaswideprintk((KERN_DEBUG "sas_port_add_phy: phy_id=%d\n",
1617 phy_info->phy_id));
1618 sas_port_add_phy(port, phy_info->phy);
1619 phy_info->sas_port_add_phy = 0;
1620 }
1621
1622 if (!mptsas_get_rphy(phy_info) && port && !port->rphy) {
1275 1623
1276 struct sas_rphy *rphy; 1624 struct sas_rphy *rphy;
1625 struct device *parent;
1277 struct sas_identify identify; 1626 struct sas_identify identify;
1278 1627
1279 ioc = phy_to_ioc(phy_info->phy); 1628 parent = dev->parent->parent;
1280
1281 /* 1629 /*
1282 * Let the hotplug_work thread handle processing 1630 * Let the hotplug_work thread handle processing
1283 * the adding/removing of devices that occur 1631 * the adding/removing of devices that occur
@@ -1285,36 +1633,67 @@ static int mptsas_probe_one_phy(struct device *dev,
1285 */ 1633 */
1286 if (ioc->sas_discovery_runtime && 1634 if (ioc->sas_discovery_runtime &&
1287 mptsas_is_end_device(&phy_info->attached)) 1635 mptsas_is_end_device(&phy_info->attached))
1288 return 0; 1636 goto out;
1289 1637
1290 mptsas_parse_device_info(&identify, &phy_info->attached); 1638 mptsas_parse_device_info(&identify, &phy_info->attached);
1639 if (scsi_is_host_device(parent)) {
1640 struct mptsas_portinfo *port_info;
1641 int i;
1642
1643 mutex_lock(&ioc->sas_topology_mutex);
1644 port_info = mptsas_find_portinfo_by_handle(ioc,
1645 ioc->handle);
1646 mutex_unlock(&ioc->sas_topology_mutex);
1647
1648 for (i = 0; i < port_info->num_phys; i++)
1649 if (port_info->phy_info[i].identify.sas_address ==
1650 identify.sas_address) {
1651 sas_port_mark_backlink(port);
1652 goto out;
1653 }
1654
1655 } else if (scsi_is_sas_rphy(parent)) {
1656 struct sas_rphy *parent_rphy = dev_to_rphy(parent);
1657 if (identify.sas_address ==
1658 parent_rphy->identify.sas_address) {
1659 sas_port_mark_backlink(port);
1660 goto out;
1661 }
1662 }
1663
1291 switch (identify.device_type) { 1664 switch (identify.device_type) {
1292 case SAS_END_DEVICE: 1665 case SAS_END_DEVICE:
1293 rphy = sas_end_device_alloc(phy); 1666 rphy = sas_end_device_alloc(port);
1294 break; 1667 break;
1295 case SAS_EDGE_EXPANDER_DEVICE: 1668 case SAS_EDGE_EXPANDER_DEVICE:
1296 case SAS_FANOUT_EXPANDER_DEVICE: 1669 case SAS_FANOUT_EXPANDER_DEVICE:
1297 rphy = sas_expander_alloc(phy, identify.device_type); 1670 rphy = sas_expander_alloc(port, identify.device_type);
1298 break; 1671 break;
1299 default: 1672 default:
1300 rphy = NULL; 1673 rphy = NULL;
1301 break; 1674 break;
1302 } 1675 }
1303 if (!rphy) 1676 if (!rphy) {
1304 return 0; /* non-fatal: an rphy can be added later */ 1677 dfailprintk((MYIOC_s_ERR_FMT
1678 "%s: exit at line=%d\n", ioc->name,
1679 __FUNCTION__, __LINE__));
1680 goto out;
1681 }
1305 1682
1306 rphy->identify = identify; 1683 rphy->identify = identify;
1307
1308 error = sas_rphy_add(rphy); 1684 error = sas_rphy_add(rphy);
1309 if (error) { 1685 if (error) {
1686 dfailprintk((MYIOC_s_ERR_FMT
1687 "%s: exit at line=%d\n", ioc->name,
1688 __FUNCTION__, __LINE__));
1310 sas_rphy_free(rphy); 1689 sas_rphy_free(rphy);
1311 return error; 1690 goto out;
1312 } 1691 }
1313 1692 mptsas_set_rphy(phy_info, rphy);
1314 phy_info->rphy = rphy;
1315 } 1693 }
1316 1694
1317 return 0; 1695 out:
1696 return error;
1318} 1697}
1319 1698
1320static int 1699static int
@@ -1333,6 +1712,7 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc)
1333 goto out_free_port_info; 1712 goto out_free_port_info;
1334 1713
1335 mutex_lock(&ioc->sas_topology_mutex); 1714 mutex_lock(&ioc->sas_topology_mutex);
1715 ioc->handle = hba->handle;
1336 port_info = mptsas_find_portinfo_by_handle(ioc, hba->handle); 1716 port_info = mptsas_find_portinfo_by_handle(ioc, hba->handle);
1337 if (!port_info) { 1717 if (!port_info) {
1338 port_info = hba; 1718 port_info = hba;
@@ -1342,13 +1722,11 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc)
1342 for (i = 0; i < hba->num_phys; i++) 1722 for (i = 0; i < hba->num_phys; i++)
1343 port_info->phy_info[i].negotiated_link_rate = 1723 port_info->phy_info[i].negotiated_link_rate =
1344 hba->phy_info[i].negotiated_link_rate; 1724 hba->phy_info[i].negotiated_link_rate;
1345 if (hba->phy_info) 1725 kfree(hba->phy_info);
1346 kfree(hba->phy_info);
1347 kfree(hba); 1726 kfree(hba);
1348 hba = NULL; 1727 hba = NULL;
1349 } 1728 }
1350 mutex_unlock(&ioc->sas_topology_mutex); 1729 mutex_unlock(&ioc->sas_topology_mutex);
1351 ioc->num_ports = port_info->num_phys;
1352 1730
1353 for (i = 0; i < port_info->num_phys; i++) { 1731 for (i = 0; i < port_info->num_phys; i++) {
1354 mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i], 1732 mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i],
@@ -1362,24 +1740,24 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc)
1362 port_info->phy_info[i].phy_id; 1740 port_info->phy_info[i].phy_id;
1363 handle = port_info->phy_info[i].identify.handle; 1741 handle = port_info->phy_info[i].identify.handle;
1364 1742
1365 if (port_info->phy_info[i].attached.handle) { 1743 if (port_info->phy_info[i].attached.handle)
1366 mptsas_sas_device_pg0(ioc, 1744 mptsas_sas_device_pg0(ioc,
1367 &port_info->phy_info[i].attached, 1745 &port_info->phy_info[i].attached,
1368 (MPI_SAS_DEVICE_PGAD_FORM_HANDLE << 1746 (MPI_SAS_DEVICE_PGAD_FORM_HANDLE <<
1369 MPI_SAS_DEVICE_PGAD_FORM_SHIFT), 1747 MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
1370 port_info->phy_info[i].attached.handle); 1748 port_info->phy_info[i].attached.handle);
1371 } 1749 }
1372 1750
1751 mptsas_setup_wide_ports(ioc, port_info);
1752
1753 for (i = 0; i < port_info->num_phys; i++, ioc->sas_index++)
1373 mptsas_probe_one_phy(&ioc->sh->shost_gendev, 1754 mptsas_probe_one_phy(&ioc->sh->shost_gendev,
1374 &port_info->phy_info[i], ioc->sas_index, 1); 1755 &port_info->phy_info[i], ioc->sas_index, 1);
1375 ioc->sas_index++;
1376 }
1377 1756
1378 return 0; 1757 return 0;
1379 1758
1380 out_free_port_info: 1759 out_free_port_info:
1381 if (hba) 1760 kfree(hba);
1382 kfree(hba);
1383 out: 1761 out:
1384 return error; 1762 return error;
1385} 1763}
@@ -1388,6 +1766,8 @@ static int
1388mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle) 1766mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle)
1389{ 1767{
1390 struct mptsas_portinfo *port_info, *p, *ex; 1768 struct mptsas_portinfo *port_info, *p, *ex;
1769 struct device *parent;
1770 struct sas_rphy *rphy;
1391 int error = -ENOMEM, i, j; 1771 int error = -ENOMEM, i, j;
1392 1772
1393 ex = kzalloc(sizeof(*port_info), GFP_KERNEL); 1773 ex = kzalloc(sizeof(*port_info), GFP_KERNEL);
@@ -1409,16 +1789,13 @@ mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle)
1409 list_add_tail(&port_info->list, &ioc->sas_topology); 1789 list_add_tail(&port_info->list, &ioc->sas_topology);
1410 } else { 1790 } else {
1411 port_info->handle = ex->handle; 1791 port_info->handle = ex->handle;
1412 if (ex->phy_info) 1792 kfree(ex->phy_info);
1413 kfree(ex->phy_info);
1414 kfree(ex); 1793 kfree(ex);
1415 ex = NULL; 1794 ex = NULL;
1416 } 1795 }
1417 mutex_unlock(&ioc->sas_topology_mutex); 1796 mutex_unlock(&ioc->sas_topology_mutex);
1418 1797
1419 for (i = 0; i < port_info->num_phys; i++) { 1798 for (i = 0; i < port_info->num_phys; i++) {
1420 struct device *parent;
1421
1422 mptsas_sas_expander_pg1(ioc, &port_info->phy_info[i], 1799 mptsas_sas_expander_pg1(ioc, &port_info->phy_info[i],
1423 (MPI_SAS_EXPAND_PGAD_FORM_HANDLE_PHY_NUM << 1800 (MPI_SAS_EXPAND_PGAD_FORM_HANDLE_PHY_NUM <<
1424 MPI_SAS_EXPAND_PGAD_FORM_SHIFT), (i << 16) + *handle); 1801 MPI_SAS_EXPAND_PGAD_FORM_SHIFT), (i << 16) + *handle);
@@ -1442,34 +1819,34 @@ mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle)
1442 port_info->phy_info[i].attached.phy_id = 1819 port_info->phy_info[i].attached.phy_id =
1443 port_info->phy_info[i].phy_id; 1820 port_info->phy_info[i].phy_id;
1444 } 1821 }
1822 }
1445 1823
1446 /* 1824 parent = &ioc->sh->shost_gendev;
1447 * If we find a parent port handle this expander is 1825 for (i = 0; i < port_info->num_phys; i++) {
1448 * attached to another expander, else it hangs of the
1449 * HBA phys.
1450 */
1451 parent = &ioc->sh->shost_gendev;
1452 mutex_lock(&ioc->sas_topology_mutex); 1826 mutex_lock(&ioc->sas_topology_mutex);
1453 list_for_each_entry(p, &ioc->sas_topology, list) { 1827 list_for_each_entry(p, &ioc->sas_topology, list) {
1454 for (j = 0; j < p->num_phys; j++) { 1828 for (j = 0; j < p->num_phys; j++) {
1455 if (port_info->phy_info[i].identify.handle == 1829 if (port_info->phy_info[i].identify.handle !=
1456 p->phy_info[j].attached.handle) 1830 p->phy_info[j].attached.handle)
1457 parent = &p->phy_info[j].rphy->dev; 1831 continue;
1832 rphy = mptsas_get_rphy(&p->phy_info[j]);
1833 parent = &rphy->dev;
1458 } 1834 }
1459 } 1835 }
1460 mutex_unlock(&ioc->sas_topology_mutex); 1836 mutex_unlock(&ioc->sas_topology_mutex);
1837 }
1838
1839 mptsas_setup_wide_ports(ioc, port_info);
1461 1840
1841 for (i = 0; i < port_info->num_phys; i++, ioc->sas_index++)
1462 mptsas_probe_one_phy(parent, &port_info->phy_info[i], 1842 mptsas_probe_one_phy(parent, &port_info->phy_info[i],
1463 ioc->sas_index, 0); 1843 ioc->sas_index, 0);
1464 ioc->sas_index++;
1465 }
1466 1844
1467 return 0; 1845 return 0;
1468 1846
1469 out_free_port_info: 1847 out_free_port_info:
1470 if (ex) { 1848 if (ex) {
1471 if (ex->phy_info) 1849 kfree(ex->phy_info);
1472 kfree(ex->phy_info);
1473 kfree(ex); 1850 kfree(ex);
1474 } 1851 }
1475 out: 1852 out:
@@ -1488,7 +1865,12 @@ mptsas_delete_expander_phys(MPT_ADAPTER *ioc)
1488{ 1865{
1489 struct mptsas_portinfo buffer; 1866 struct mptsas_portinfo buffer;
1490 struct mptsas_portinfo *port_info, *n, *parent; 1867 struct mptsas_portinfo *port_info, *n, *parent;
1868 struct mptsas_phyinfo *phy_info;
1869 struct scsi_target * starget;
1870 VirtTarget * vtarget;
1871 struct sas_port * port;
1491 int i; 1872 int i;
1873 u64 expander_sas_address;
1492 1874
1493 mutex_lock(&ioc->sas_topology_mutex); 1875 mutex_lock(&ioc->sas_topology_mutex);
1494 list_for_each_entry_safe(port_info, n, &ioc->sas_topology, list) { 1876 list_for_each_entry_safe(port_info, n, &ioc->sas_topology, list) {
@@ -1503,6 +1885,25 @@ mptsas_delete_expander_phys(MPT_ADAPTER *ioc)
1503 MPI_SAS_EXPAND_PGAD_FORM_SHIFT), port_info->handle)) { 1885 MPI_SAS_EXPAND_PGAD_FORM_SHIFT), port_info->handle)) {
1504 1886
1505 /* 1887 /*
1888 * Issue target reset to all child end devices
1889 * then mark them deleted to prevent further
1890 * IO going to them.
1891 */
1892 phy_info = port_info->phy_info;
1893 for (i = 0; i < port_info->num_phys; i++, phy_info++) {
1894 starget = mptsas_get_starget(phy_info);
1895 if (!starget)
1896 continue;
1897 vtarget = starget->hostdata;
1898 if(vtarget->deleted)
1899 continue;
1900 vtarget->deleted = 1;
1901 mptsas_target_reset(ioc, vtarget);
1902 sas_port_delete(mptsas_get_port(phy_info));
1903 mptsas_port_delete(phy_info->port_details);
1904 }
1905
1906 /*
1506 * Obtain the port_info instance to the parent port 1907 * Obtain the port_info instance to the parent port
1507 */ 1908 */
1508 parent = mptsas_find_portinfo_by_handle(ioc, 1909 parent = mptsas_find_portinfo_by_handle(ioc,
@@ -1511,34 +1912,44 @@ mptsas_delete_expander_phys(MPT_ADAPTER *ioc)
1511 if (!parent) 1912 if (!parent)
1512 goto next_port; 1913 goto next_port;
1513 1914
1915 expander_sas_address =
1916 port_info->phy_info[0].identify.sas_address;
1917
1514 /* 1918 /*
1515 * Delete rphys in the parent that point 1919 * Delete rphys in the parent that point
1516 * to this expander. The transport layer will 1920 * to this expander. The transport layer will
1517 * cleanup all the children. 1921 * cleanup all the children.
1518 */ 1922 */
1519 for (i = 0; i < parent->num_phys; i++) { 1923 phy_info = parent->phy_info;
1520 if ((!parent->phy_info[i].rphy) || 1924 for (i = 0; i < parent->num_phys; i++, phy_info++) {
1521 (parent->phy_info[i].attached.sas_address != 1925 port = mptsas_get_port(phy_info);
1522 port_info->phy_info[i].identify.sas_address)) 1926 if (!port)
1927 continue;
1928 if (phy_info->attached.sas_address !=
1929 expander_sas_address)
1523 continue; 1930 continue;
1524 sas_rphy_delete(parent->phy_info[i].rphy); 1931#ifdef MPT_DEBUG_SAS_WIDE
1525 memset(&parent->phy_info[i].attached, 0, 1932 dev_printk(KERN_DEBUG, &port->dev,
1526 sizeof(struct mptsas_devinfo)); 1933 "delete port (%d)\n", port->port_identifier);
1527 parent->phy_info[i].rphy = NULL; 1934#endif
1528 parent->phy_info[i].starget = NULL; 1935 sas_port_delete(port);
1936 mptsas_port_delete(phy_info->port_details);
1529 } 1937 }
1530 next_port: 1938 next_port:
1939
1940 phy_info = port_info->phy_info;
1941 for (i = 0; i < port_info->num_phys; i++, phy_info++)
1942 mptsas_port_delete(phy_info->port_details);
1943
1531 list_del(&port_info->list); 1944 list_del(&port_info->list);
1532 if (port_info->phy_info) 1945 kfree(port_info->phy_info);
1533 kfree(port_info->phy_info);
1534 kfree(port_info); 1946 kfree(port_info);
1535 } 1947 }
1536 /* 1948 /*
1537 * Free this memory allocated from inside 1949 * Free this memory allocated from inside
1538 * mptsas_sas_expander_pg0 1950 * mptsas_sas_expander_pg0
1539 */ 1951 */
1540 if (buffer.phy_info) 1952 kfree(buffer.phy_info);
1541 kfree(buffer.phy_info);
1542 } 1953 }
1543 mutex_unlock(&ioc->sas_topology_mutex); 1954 mutex_unlock(&ioc->sas_topology_mutex);
1544} 1955}
@@ -1564,7 +1975,7 @@ mptsas_scan_sas_topology(MPT_ADAPTER *ioc)
1564 if (!ioc->raid_data.pIocPg2->NumActiveVolumes) 1975 if (!ioc->raid_data.pIocPg2->NumActiveVolumes)
1565 goto out; 1976 goto out;
1566 for (i=0; i<ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { 1977 for (i=0; i<ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
1567 scsi_add_device(ioc->sh, ioc->num_ports, 1978 scsi_add_device(ioc->sh, MPTSAS_RAID_CHANNEL,
1568 ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0); 1979 ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0);
1569 } 1980 }
1570 out: 1981 out:
@@ -1574,60 +1985,59 @@ mptsas_scan_sas_topology(MPT_ADAPTER *ioc)
1574/* 1985/*
1575 * Work queue thread to handle Runtime discovery 1986 * Work queue thread to handle Runtime discovery
1576 * Mere purpose is the hot add/delete of expanders 1987 * Mere purpose is the hot add/delete of expanders
1988 *(Mutex UNLOCKED)
1577 */ 1989 */
1578static void 1990static void
1579mptscsih_discovery_work(void * arg) 1991__mptsas_discovery_work(MPT_ADAPTER *ioc)
1580{ 1992{
1581 struct mptsas_discovery_event *ev = arg;
1582 MPT_ADAPTER *ioc = ev->ioc;
1583 u32 handle = 0xFFFF; 1993 u32 handle = 0xFFFF;
1584 1994
1585 mutex_lock(&ioc->sas_discovery_mutex);
1586 ioc->sas_discovery_runtime=1; 1995 ioc->sas_discovery_runtime=1;
1587 mptsas_delete_expander_phys(ioc); 1996 mptsas_delete_expander_phys(ioc);
1588 mptsas_probe_hba_phys(ioc); 1997 mptsas_probe_hba_phys(ioc);
1589 while (!mptsas_probe_expander_phys(ioc, &handle)) 1998 while (!mptsas_probe_expander_phys(ioc, &handle))
1590 ; 1999 ;
1591 kfree(ev);
1592 ioc->sas_discovery_runtime=0; 2000 ioc->sas_discovery_runtime=0;
2001}
2002
2003/*
2004 * Work queue thread to handle Runtime discovery
2005 * Mere purpose is the hot add/delete of expanders
2006 *(Mutex LOCKED)
2007 */
2008static void
2009mptsas_discovery_work(void * arg)
2010{
2011 struct mptsas_discovery_event *ev = arg;
2012 MPT_ADAPTER *ioc = ev->ioc;
2013
2014 mutex_lock(&ioc->sas_discovery_mutex);
2015 __mptsas_discovery_work(ioc);
1593 mutex_unlock(&ioc->sas_discovery_mutex); 2016 mutex_unlock(&ioc->sas_discovery_mutex);
2017 kfree(ev);
1594} 2018}
1595 2019
1596static struct mptsas_phyinfo * 2020static struct mptsas_phyinfo *
1597mptsas_find_phyinfo_by_parent(MPT_ADAPTER *ioc, u16 parent_handle, u8 phy_id) 2021mptsas_find_phyinfo_by_sas_address(MPT_ADAPTER *ioc, u64 sas_address)
1598{ 2022{
1599 struct mptsas_portinfo *port_info; 2023 struct mptsas_portinfo *port_info;
1600 struct mptsas_devinfo device_info;
1601 struct mptsas_phyinfo *phy_info = NULL; 2024 struct mptsas_phyinfo *phy_info = NULL;
1602 int i, error; 2025 int i;
1603
1604 /*
1605 * Retrieve the parent sas_address
1606 */
1607 error = mptsas_sas_device_pg0(ioc, &device_info,
1608 (MPI_SAS_DEVICE_PGAD_FORM_HANDLE <<
1609 MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
1610 parent_handle);
1611 if (error)
1612 return NULL;
1613 2026
1614 /*
1615 * The phy_info structures are never deallocated during lifetime of
1616 * a host, so the code below is safe without additional refcounting.
1617 */
1618 mutex_lock(&ioc->sas_topology_mutex); 2027 mutex_lock(&ioc->sas_topology_mutex);
1619 list_for_each_entry(port_info, &ioc->sas_topology, list) { 2028 list_for_each_entry(port_info, &ioc->sas_topology, list) {
1620 for (i = 0; i < port_info->num_phys; i++) { 2029 for (i = 0; i < port_info->num_phys; i++) {
1621 if (port_info->phy_info[i].identify.sas_address == 2030 if (port_info->phy_info[i].attached.sas_address
1622 device_info.sas_address && 2031 != sas_address)
1623 port_info->phy_info[i].phy_id == phy_id) { 2032 continue;
1624 phy_info = &port_info->phy_info[i]; 2033 if (!mptsas_is_end_device(
1625 break; 2034 &port_info->phy_info[i].attached))
1626 } 2035 continue;
2036 phy_info = &port_info->phy_info[i];
2037 break;
1627 } 2038 }
1628 } 2039 }
1629 mutex_unlock(&ioc->sas_topology_mutex); 2040 mutex_unlock(&ioc->sas_topology_mutex);
1630
1631 return phy_info; 2041 return phy_info;
1632} 2042}
1633 2043
@@ -1638,21 +2048,19 @@ mptsas_find_phyinfo_by_target(MPT_ADAPTER *ioc, u32 id)
1638 struct mptsas_phyinfo *phy_info = NULL; 2048 struct mptsas_phyinfo *phy_info = NULL;
1639 int i; 2049 int i;
1640 2050
1641 /*
1642 * The phy_info structures are never deallocated during lifetime of
1643 * a host, so the code below is safe without additional refcounting.
1644 */
1645 mutex_lock(&ioc->sas_topology_mutex); 2051 mutex_lock(&ioc->sas_topology_mutex);
1646 list_for_each_entry(port_info, &ioc->sas_topology, list) { 2052 list_for_each_entry(port_info, &ioc->sas_topology, list) {
1647 for (i = 0; i < port_info->num_phys; i++) 2053 for (i = 0; i < port_info->num_phys; i++) {
1648 if (mptsas_is_end_device(&port_info->phy_info[i].attached)) 2054 if (port_info->phy_info[i].attached.id != id)
1649 if (port_info->phy_info[i].attached.id == id) { 2055 continue;
1650 phy_info = &port_info->phy_info[i]; 2056 if (!mptsas_is_end_device(
1651 break; 2057 &port_info->phy_info[i].attached))
1652 } 2058 continue;
2059 phy_info = &port_info->phy_info[i];
2060 break;
2061 }
1653 } 2062 }
1654 mutex_unlock(&ioc->sas_topology_mutex); 2063 mutex_unlock(&ioc->sas_topology_mutex);
1655
1656 return phy_info; 2064 return phy_info;
1657} 2065}
1658 2066
@@ -1660,7 +2068,7 @@ mptsas_find_phyinfo_by_target(MPT_ADAPTER *ioc, u32 id)
1660 * Work queue thread to clear the persitency table 2068 * Work queue thread to clear the persitency table
1661 */ 2069 */
1662static void 2070static void
1663mptscsih_sas_persist_clear_table(void * arg) 2071mptsas_persist_clear_table(void * arg)
1664{ 2072{
1665 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; 2073 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg;
1666 2074
@@ -1681,7 +2089,6 @@ mptsas_reprobe_target(struct scsi_target *starget, int uld_attach)
1681 mptsas_reprobe_lun); 2089 mptsas_reprobe_lun);
1682} 2090}
1683 2091
1684
1685/* 2092/*
1686 * Work queue thread to handle SAS hotplug events 2093 * Work queue thread to handle SAS hotplug events
1687 */ 2094 */
@@ -1692,14 +2099,17 @@ mptsas_hotplug_work(void *arg)
1692 MPT_ADAPTER *ioc = ev->ioc; 2099 MPT_ADAPTER *ioc = ev->ioc;
1693 struct mptsas_phyinfo *phy_info; 2100 struct mptsas_phyinfo *phy_info;
1694 struct sas_rphy *rphy; 2101 struct sas_rphy *rphy;
2102 struct sas_port *port;
1695 struct scsi_device *sdev; 2103 struct scsi_device *sdev;
2104 struct scsi_target * starget;
1696 struct sas_identify identify; 2105 struct sas_identify identify;
1697 char *ds = NULL; 2106 char *ds = NULL;
1698 struct mptsas_devinfo sas_device; 2107 struct mptsas_devinfo sas_device;
1699 VirtTarget *vtarget; 2108 VirtTarget *vtarget;
2109 VirtDevice *vdevice;
1700 2110
1701 mutex_lock(&ioc->sas_discovery_mutex);
1702 2111
2112 mutex_lock(&ioc->sas_discovery_mutex);
1703 switch (ev->event_type) { 2113 switch (ev->event_type) {
1704 case MPTSAS_DEL_DEVICE: 2114 case MPTSAS_DEL_DEVICE:
1705 2115
@@ -1708,24 +2118,50 @@ mptsas_hotplug_work(void *arg)
1708 /* 2118 /*
1709 * Sanity checks, for non-existing phys and remote rphys. 2119 * Sanity checks, for non-existing phys and remote rphys.
1710 */ 2120 */
1711 if (!phy_info) 2121 if (!phy_info || !phy_info->port_details) {
2122 dfailprintk((MYIOC_s_ERR_FMT
2123 "%s: exit at line=%d\n", ioc->name,
2124 __FUNCTION__, __LINE__));
1712 break; 2125 break;
1713 if (!phy_info->rphy) 2126 }
2127 rphy = mptsas_get_rphy(phy_info);
2128 if (!rphy) {
2129 dfailprintk((MYIOC_s_ERR_FMT
2130 "%s: exit at line=%d\n", ioc->name,
2131 __FUNCTION__, __LINE__));
2132 break;
2133 }
2134 port = mptsas_get_port(phy_info);
2135 if (!port) {
2136 dfailprintk((MYIOC_s_ERR_FMT
2137 "%s: exit at line=%d\n", ioc->name,
2138 __FUNCTION__, __LINE__));
1714 break; 2139 break;
1715 if (phy_info->starget) { 2140 }
1716 vtarget = phy_info->starget->hostdata; 2141
2142 starget = mptsas_get_starget(phy_info);
2143 if (starget) {
2144 vtarget = starget->hostdata;
1717 2145
1718 if (!vtarget) 2146 if (!vtarget) {
2147 dfailprintk((MYIOC_s_ERR_FMT
2148 "%s: exit at line=%d\n", ioc->name,
2149 __FUNCTION__, __LINE__));
1719 break; 2150 break;
2151 }
2152
1720 /* 2153 /*
1721 * Handling RAID components 2154 * Handling RAID components
1722 */ 2155 */
1723 if (ev->phys_disk_num_valid) { 2156 if (ev->phys_disk_num_valid) {
1724 vtarget->target_id = ev->phys_disk_num; 2157 vtarget->target_id = ev->phys_disk_num;
1725 vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT; 2158 vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT;
1726 mptsas_reprobe_target(vtarget->starget, 1); 2159 mptsas_reprobe_target(starget, 1);
1727 break; 2160 break;
1728 } 2161 }
2162
2163 vtarget->deleted = 1;
2164 mptsas_target_reset(ioc, vtarget);
1729 } 2165 }
1730 2166
1731 if (phy_info->attached.device_info & MPI_SAS_DEVICE_INFO_SSP_TARGET) 2167 if (phy_info->attached.device_info & MPI_SAS_DEVICE_INFO_SSP_TARGET)
@@ -1739,10 +2175,12 @@ mptsas_hotplug_work(void *arg)
1739 "removing %s device, channel %d, id %d, phy %d\n", 2175 "removing %s device, channel %d, id %d, phy %d\n",
1740 ioc->name, ds, ev->channel, ev->id, phy_info->phy_id); 2176 ioc->name, ds, ev->channel, ev->id, phy_info->phy_id);
1741 2177
1742 sas_rphy_delete(phy_info->rphy); 2178#ifdef MPT_DEBUG_SAS_WIDE
1743 memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo)); 2179 dev_printk(KERN_DEBUG, &port->dev,
1744 phy_info->rphy = NULL; 2180 "delete port (%d)\n", port->port_identifier);
1745 phy_info->starget = NULL; 2181#endif
2182 sas_port_delete(port);
2183 mptsas_port_delete(phy_info->port_details);
1746 break; 2184 break;
1747 case MPTSAS_ADD_DEVICE: 2185 case MPTSAS_ADD_DEVICE:
1748 2186
@@ -1754,59 +2192,60 @@ mptsas_hotplug_work(void *arg)
1754 */ 2192 */
1755 if (mptsas_sas_device_pg0(ioc, &sas_device, 2193 if (mptsas_sas_device_pg0(ioc, &sas_device,
1756 (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID << 2194 (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID <<
1757 MPI_SAS_DEVICE_PGAD_FORM_SHIFT), ev->id)) 2195 MPI_SAS_DEVICE_PGAD_FORM_SHIFT), ev->id)) {
2196 dfailprintk((MYIOC_s_ERR_FMT
2197 "%s: exit at line=%d\n", ioc->name,
2198 __FUNCTION__, __LINE__));
1758 break; 2199 break;
2200 }
1759 2201
1760 phy_info = mptsas_find_phyinfo_by_parent(ioc, 2202 ssleep(2);
1761 sas_device.handle_parent, sas_device.phy_id); 2203 __mptsas_discovery_work(ioc);
1762 2204
1763 if (!phy_info) { 2205 phy_info = mptsas_find_phyinfo_by_sas_address(ioc,
1764 u32 handle = 0xFFFF; 2206 sas_device.sas_address);
1765 2207
1766 /* 2208 if (!phy_info || !phy_info->port_details) {
1767 * Its possible when an expander has been hot added 2209 dfailprintk((MYIOC_s_ERR_FMT
1768 * containing attached devices, the sas firmware 2210 "%s: exit at line=%d\n", ioc->name,
1769 * may send a RC_ADDED event prior to the 2211 __FUNCTION__, __LINE__));
1770 * DISCOVERY STOP event. If that occurs, our 2212 break;
1771 * view of the topology in the driver in respect to this
1772 * expander might of not been setup, and we hit this
1773 * condition.
1774 * Therefore, this code kicks off discovery to
1775 * refresh the data.
1776 * Then again, we check whether the parent phy has
1777 * been created.
1778 */
1779 ioc->sas_discovery_runtime=1;
1780 mptsas_delete_expander_phys(ioc);
1781 mptsas_probe_hba_phys(ioc);
1782 while (!mptsas_probe_expander_phys(ioc, &handle))
1783 ;
1784 ioc->sas_discovery_runtime=0;
1785
1786 phy_info = mptsas_find_phyinfo_by_parent(ioc,
1787 sas_device.handle_parent, sas_device.phy_id);
1788 if (!phy_info)
1789 break;
1790 } 2213 }
1791 2214
1792 if (phy_info->starget) { 2215 starget = mptsas_get_starget(phy_info);
1793 vtarget = phy_info->starget->hostdata; 2216 if (starget) {
2217 vtarget = starget->hostdata;
1794 2218
1795 if (!vtarget) 2219 if (!vtarget) {
2220 dfailprintk((MYIOC_s_ERR_FMT
2221 "%s: exit at line=%d\n", ioc->name,
2222 __FUNCTION__, __LINE__));
1796 break; 2223 break;
2224 }
1797 /* 2225 /*
1798 * Handling RAID components 2226 * Handling RAID components
1799 */ 2227 */
1800 if (vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) { 2228 if (vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) {
1801 vtarget->tflags &= ~MPT_TARGET_FLAGS_RAID_COMPONENT; 2229 vtarget->tflags &= ~MPT_TARGET_FLAGS_RAID_COMPONENT;
1802 vtarget->target_id = ev->id; 2230 vtarget->target_id = ev->id;
1803 mptsas_reprobe_target(phy_info->starget, 0); 2231 mptsas_reprobe_target(starget, 0);
1804 } 2232 }
1805 break; 2233 break;
1806 } 2234 }
1807 2235
1808 if (phy_info->rphy) 2236 if (mptsas_get_rphy(phy_info)) {
2237 dfailprintk((MYIOC_s_ERR_FMT
2238 "%s: exit at line=%d\n", ioc->name,
2239 __FUNCTION__, __LINE__));
1809 break; 2240 break;
2241 }
2242 port = mptsas_get_port(phy_info);
2243 if (!port) {
2244 dfailprintk((MYIOC_s_ERR_FMT
2245 "%s: exit at line=%d\n", ioc->name,
2246 __FUNCTION__, __LINE__));
2247 break;
2248 }
1810 2249
1811 memcpy(&phy_info->attached, &sas_device, 2250 memcpy(&phy_info->attached, &sas_device,
1812 sizeof(struct mptsas_devinfo)); 2251 sizeof(struct mptsas_devinfo));
@@ -1823,59 +2262,48 @@ mptsas_hotplug_work(void *arg)
1823 ioc->name, ds, ev->channel, ev->id, ev->phy_id); 2262 ioc->name, ds, ev->channel, ev->id, ev->phy_id);
1824 2263
1825 mptsas_parse_device_info(&identify, &phy_info->attached); 2264 mptsas_parse_device_info(&identify, &phy_info->attached);
1826 switch (identify.device_type) { 2265 rphy = sas_end_device_alloc(port);
1827 case SAS_END_DEVICE: 2266 if (!rphy) {
1828 rphy = sas_end_device_alloc(phy_info->phy); 2267 dfailprintk((MYIOC_s_ERR_FMT
1829 break; 2268 "%s: exit at line=%d\n", ioc->name,
1830 case SAS_EDGE_EXPANDER_DEVICE: 2269 __FUNCTION__, __LINE__));
1831 case SAS_FANOUT_EXPANDER_DEVICE:
1832 rphy = sas_expander_alloc(phy_info->phy, identify.device_type);
1833 break;
1834 default:
1835 rphy = NULL;
1836 break;
1837 }
1838 if (!rphy)
1839 break; /* non-fatal: an rphy can be added later */ 2270 break; /* non-fatal: an rphy can be added later */
2271 }
1840 2272
1841 rphy->identify = identify; 2273 rphy->identify = identify;
1842 if (sas_rphy_add(rphy)) { 2274 if (sas_rphy_add(rphy)) {
2275 dfailprintk((MYIOC_s_ERR_FMT
2276 "%s: exit at line=%d\n", ioc->name,
2277 __FUNCTION__, __LINE__));
1843 sas_rphy_free(rphy); 2278 sas_rphy_free(rphy);
1844 break; 2279 break;
1845 } 2280 }
1846 2281 mptsas_set_rphy(phy_info, rphy);
1847 phy_info->rphy = rphy;
1848 break; 2282 break;
1849 case MPTSAS_ADD_RAID: 2283 case MPTSAS_ADD_RAID:
1850 sdev = scsi_device_lookup( 2284 sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL,
1851 ioc->sh, 2285 ev->id, 0);
1852 ioc->num_ports,
1853 ev->id,
1854 0);
1855 if (sdev) { 2286 if (sdev) {
1856 scsi_device_put(sdev); 2287 scsi_device_put(sdev);
1857 break; 2288 break;
1858 } 2289 }
1859 printk(MYIOC_s_INFO_FMT 2290 printk(MYIOC_s_INFO_FMT
1860 "attaching raid volume, channel %d, id %d\n", 2291 "attaching raid volume, channel %d, id %d\n",
1861 ioc->name, ioc->num_ports, ev->id); 2292 ioc->name, MPTSAS_RAID_CHANNEL, ev->id);
1862 scsi_add_device(ioc->sh, 2293 scsi_add_device(ioc->sh, MPTSAS_RAID_CHANNEL, ev->id, 0);
1863 ioc->num_ports,
1864 ev->id,
1865 0);
1866 mpt_findImVolumes(ioc); 2294 mpt_findImVolumes(ioc);
1867 break; 2295 break;
1868 case MPTSAS_DEL_RAID: 2296 case MPTSAS_DEL_RAID:
1869 sdev = scsi_device_lookup( 2297 sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL,
1870 ioc->sh, 2298 ev->id, 0);
1871 ioc->num_ports,
1872 ev->id,
1873 0);
1874 if (!sdev) 2299 if (!sdev)
1875 break; 2300 break;
1876 printk(MYIOC_s_INFO_FMT 2301 printk(MYIOC_s_INFO_FMT
1877 "removing raid volume, channel %d, id %d\n", 2302 "removing raid volume, channel %d, id %d\n",
1878 ioc->name, ioc->num_ports, ev->id); 2303 ioc->name, MPTSAS_RAID_CHANNEL, ev->id);
2304 vdevice = sdev->hostdata;
2305 vdevice->vtarget->deleted = 1;
2306 mptsas_target_reset(ioc, vdevice->vtarget);
1879 scsi_remove_device(sdev); 2307 scsi_remove_device(sdev);
1880 scsi_device_put(sdev); 2308 scsi_device_put(sdev);
1881 mpt_findImVolumes(ioc); 2309 mpt_findImVolumes(ioc);
@@ -1885,12 +2313,13 @@ mptsas_hotplug_work(void *arg)
1885 break; 2313 break;
1886 } 2314 }
1887 2315
1888 kfree(ev);
1889 mutex_unlock(&ioc->sas_discovery_mutex); 2316 mutex_unlock(&ioc->sas_discovery_mutex);
2317 kfree(ev);
2318
1890} 2319}
1891 2320
1892static void 2321static void
1893mptscsih_send_sas_event(MPT_ADAPTER *ioc, 2322mptsas_send_sas_event(MPT_ADAPTER *ioc,
1894 EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *sas_event_data) 2323 EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *sas_event_data)
1895{ 2324{
1896 struct mptsas_hotplug_event *ev; 2325 struct mptsas_hotplug_event *ev;
@@ -1906,7 +2335,7 @@ mptscsih_send_sas_event(MPT_ADAPTER *ioc,
1906 switch (sas_event_data->ReasonCode) { 2335 switch (sas_event_data->ReasonCode) {
1907 case MPI_EVENT_SAS_DEV_STAT_RC_ADDED: 2336 case MPI_EVENT_SAS_DEV_STAT_RC_ADDED:
1908 case MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING: 2337 case MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING:
1909 ev = kmalloc(sizeof(*ev), GFP_ATOMIC); 2338 ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
1910 if (!ev) { 2339 if (!ev) {
1911 printk(KERN_WARNING "mptsas: lost hotplug event\n"); 2340 printk(KERN_WARNING "mptsas: lost hotplug event\n");
1912 break; 2341 break;
@@ -1936,10 +2365,9 @@ mptscsih_send_sas_event(MPT_ADAPTER *ioc,
1936 /* 2365 /*
1937 * Persistent table is full. 2366 * Persistent table is full.
1938 */ 2367 */
1939 INIT_WORK(&ioc->mptscsih_persistTask, 2368 INIT_WORK(&ioc->sas_persist_task,
1940 mptscsih_sas_persist_clear_table, 2369 mptsas_persist_clear_table, (void *)ioc);
1941 (void *)ioc); 2370 schedule_work(&ioc->sas_persist_task);
1942 schedule_work(&ioc->mptscsih_persistTask);
1943 break; 2371 break;
1944 case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA: 2372 case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA:
1945 /* TODO */ 2373 /* TODO */
@@ -1951,7 +2379,7 @@ mptscsih_send_sas_event(MPT_ADAPTER *ioc,
1951} 2379}
1952 2380
1953static void 2381static void
1954mptscsih_send_raid_event(MPT_ADAPTER *ioc, 2382mptsas_send_raid_event(MPT_ADAPTER *ioc,
1955 EVENT_DATA_RAID *raid_event_data) 2383 EVENT_DATA_RAID *raid_event_data)
1956{ 2384{
1957 struct mptsas_hotplug_event *ev; 2385 struct mptsas_hotplug_event *ev;
@@ -1961,13 +2389,12 @@ mptscsih_send_raid_event(MPT_ADAPTER *ioc,
1961 if (ioc->bus_type != SAS) 2389 if (ioc->bus_type != SAS)
1962 return; 2390 return;
1963 2391
1964 ev = kmalloc(sizeof(*ev), GFP_ATOMIC); 2392 ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
1965 if (!ev) { 2393 if (!ev) {
1966 printk(KERN_WARNING "mptsas: lost hotplug event\n"); 2394 printk(KERN_WARNING "mptsas: lost hotplug event\n");
1967 return; 2395 return;
1968 } 2396 }
1969 2397
1970 memset(ev,0,sizeof(struct mptsas_hotplug_event));
1971 INIT_WORK(&ev->work, mptsas_hotplug_work, ev); 2398 INIT_WORK(&ev->work, mptsas_hotplug_work, ev);
1972 ev->ioc = ioc; 2399 ev->ioc = ioc;
1973 ev->id = raid_event_data->VolumeID; 2400 ev->id = raid_event_data->VolumeID;
@@ -2029,7 +2456,7 @@ mptscsih_send_raid_event(MPT_ADAPTER *ioc,
2029} 2456}
2030 2457
2031static void 2458static void
2032mptscsih_send_discovery(MPT_ADAPTER *ioc, 2459mptsas_send_discovery_event(MPT_ADAPTER *ioc,
2033 EVENT_DATA_SAS_DISCOVERY *discovery_data) 2460 EVENT_DATA_SAS_DISCOVERY *discovery_data)
2034{ 2461{
2035 struct mptsas_discovery_event *ev; 2462 struct mptsas_discovery_event *ev;
@@ -2044,11 +2471,10 @@ mptscsih_send_discovery(MPT_ADAPTER *ioc,
2044 if (discovery_data->DiscoveryStatus) 2471 if (discovery_data->DiscoveryStatus)
2045 return; 2472 return;
2046 2473
2047 ev = kmalloc(sizeof(*ev), GFP_ATOMIC); 2474 ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
2048 if (!ev) 2475 if (!ev)
2049 return; 2476 return;
2050 memset(ev,0,sizeof(struct mptsas_discovery_event)); 2477 INIT_WORK(&ev->work, mptsas_discovery_work, ev);
2051 INIT_WORK(&ev->work, mptscsih_discovery_work, ev);
2052 ev->ioc = ioc; 2478 ev->ioc = ioc;
2053 schedule_work(&ev->work); 2479 schedule_work(&ev->work);
2054}; 2480};
@@ -2076,21 +2502,21 @@ mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply)
2076 2502
2077 switch (event) { 2503 switch (event) {
2078 case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE: 2504 case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE:
2079 mptscsih_send_sas_event(ioc, 2505 mptsas_send_sas_event(ioc,
2080 (EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *)reply->Data); 2506 (EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *)reply->Data);
2081 break; 2507 break;
2082 case MPI_EVENT_INTEGRATED_RAID: 2508 case MPI_EVENT_INTEGRATED_RAID:
2083 mptscsih_send_raid_event(ioc, 2509 mptsas_send_raid_event(ioc,
2084 (EVENT_DATA_RAID *)reply->Data); 2510 (EVENT_DATA_RAID *)reply->Data);
2085 break; 2511 break;
2086 case MPI_EVENT_PERSISTENT_TABLE_FULL: 2512 case MPI_EVENT_PERSISTENT_TABLE_FULL:
2087 INIT_WORK(&ioc->mptscsih_persistTask, 2513 INIT_WORK(&ioc->sas_persist_task,
2088 mptscsih_sas_persist_clear_table, 2514 mptsas_persist_clear_table,
2089 (void *)ioc); 2515 (void *)ioc);
2090 schedule_work(&ioc->mptscsih_persistTask); 2516 schedule_work(&ioc->sas_persist_task);
2091 break; 2517 break;
2092 case MPI_EVENT_SAS_DISCOVERY: 2518 case MPI_EVENT_SAS_DISCOVERY:
2093 mptscsih_send_discovery(ioc, 2519 mptsas_send_discovery_event(ioc,
2094 (EVENT_DATA_SAS_DISCOVERY *)reply->Data); 2520 (EVENT_DATA_SAS_DISCOVERY *)reply->Data);
2095 break; 2521 break;
2096 default: 2522 default:
@@ -2280,7 +2706,6 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2280 hd->timer.data = (unsigned long) hd; 2706 hd->timer.data = (unsigned long) hd;
2281 hd->timer.function = mptscsih_timer_expired; 2707 hd->timer.function = mptscsih_timer_expired;
2282 2708
2283 hd->mpt_pq_filter = mpt_pq_filter;
2284 ioc->sas_data.ptClear = mpt_pt_clear; 2709 ioc->sas_data.ptClear = mpt_pt_clear;
2285 2710
2286 if (ioc->sas_data.ptClear==1) { 2711 if (ioc->sas_data.ptClear==1) {
@@ -2288,12 +2713,6 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2288 ioc, MPI_SAS_OP_CLEAR_ALL_PERSISTENT); 2713 ioc, MPI_SAS_OP_CLEAR_ALL_PERSISTENT);
2289 } 2714 }
2290 2715
2291 ddvprintk((MYIOC_s_INFO_FMT
2292 "mpt_pq_filter %x mpt_pq_filter %x\n",
2293 ioc->name,
2294 mpt_pq_filter,
2295 mpt_pq_filter));
2296
2297 init_waitqueue_head(&hd->scandv_waitq); 2716 init_waitqueue_head(&hd->scandv_waitq);
2298 hd->scandv_wait_done = 0; 2717 hd->scandv_wait_done = 0;
2299 hd->last_queue_full = 0; 2718 hd->last_queue_full = 0;
@@ -2309,7 +2728,7 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2309 2728
2310 return 0; 2729 return 0;
2311 2730
2312out_mptsas_probe: 2731 out_mptsas_probe:
2313 2732
2314 mptscsih_remove(pdev); 2733 mptscsih_remove(pdev);
2315 return error; 2734 return error;
@@ -2319,6 +2738,7 @@ static void __devexit mptsas_remove(struct pci_dev *pdev)
2319{ 2738{
2320 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 2739 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
2321 struct mptsas_portinfo *p, *n; 2740 struct mptsas_portinfo *p, *n;
2741 int i;
2322 2742
2323 ioc->sas_discovery_ignore_events=1; 2743 ioc->sas_discovery_ignore_events=1;
2324 sas_remove_host(ioc->sh); 2744 sas_remove_host(ioc->sh);
@@ -2326,8 +2746,9 @@ static void __devexit mptsas_remove(struct pci_dev *pdev)
2326 mutex_lock(&ioc->sas_topology_mutex); 2746 mutex_lock(&ioc->sas_topology_mutex);
2327 list_for_each_entry_safe(p, n, &ioc->sas_topology, list) { 2747 list_for_each_entry_safe(p, n, &ioc->sas_topology, list) {
2328 list_del(&p->list); 2748 list_del(&p->list);
2329 if (p->phy_info) 2749 for (i = 0 ; i < p->num_phys ; i++)
2330 kfree(p->phy_info); 2750 mptsas_port_delete(p->phy_info[i].port_details);
2751 kfree(p->phy_info);
2331 kfree(p); 2752 kfree(p);
2332 } 2753 }
2333 mutex_unlock(&ioc->sas_topology_mutex); 2754 mutex_unlock(&ioc->sas_topology_mutex);
@@ -2336,17 +2757,15 @@ static void __devexit mptsas_remove(struct pci_dev *pdev)
2336} 2757}
2337 2758
2338static struct pci_device_id mptsas_pci_table[] = { 2759static struct pci_device_id mptsas_pci_table[] = {
2339 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1064, 2760 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1064,
2340 PCI_ANY_ID, PCI_ANY_ID },
2341 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1066,
2342 PCI_ANY_ID, PCI_ANY_ID }, 2761 PCI_ANY_ID, PCI_ANY_ID },
2343 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1068, 2762 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1068,
2344 PCI_ANY_ID, PCI_ANY_ID }, 2763 PCI_ANY_ID, PCI_ANY_ID },
2345 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1064E, 2764 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1064E,
2346 PCI_ANY_ID, PCI_ANY_ID }, 2765 PCI_ANY_ID, PCI_ANY_ID },
2347 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1066E, 2766 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1068E,
2348 PCI_ANY_ID, PCI_ANY_ID }, 2767 PCI_ANY_ID, PCI_ANY_ID },
2349 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1068E, 2768 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1078,
2350 PCI_ANY_ID, PCI_ANY_ID }, 2769 PCI_ANY_ID, PCI_ANY_ID },
2351 {0} /* Terminating entry */ 2770 {0} /* Terminating entry */
2352}; 2771};
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 8242b16e3168..30524dc54b16 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -66,6 +66,7 @@
66 66
67#include "mptbase.h" 67#include "mptbase.h"
68#include "mptscsih.h" 68#include "mptscsih.h"
69#include "lsi/mpi_log_sas.h"
69 70
70/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 71/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
71#define my_NAME "Fusion MPT SCSI Host driver" 72#define my_NAME "Fusion MPT SCSI Host driver"
@@ -127,7 +128,7 @@ static void mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx);
127static void mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply); 128static void mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply);
128static int mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd); 129static int mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd);
129static int mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout ); 130static int mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout );
130static u32 SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc); 131static int SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc);
131 132
132static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout); 133static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout);
133 134
@@ -497,6 +498,34 @@ nextSGEset:
497 return SUCCESS; 498 return SUCCESS;
498} /* mptscsih_AddSGE() */ 499} /* mptscsih_AddSGE() */
499 500
501static void
502mptscsih_issue_sep_command(MPT_ADAPTER *ioc, VirtTarget *vtarget,
503 U32 SlotStatus)
504{
505 MPT_FRAME_HDR *mf;
506 SEPRequest_t *SEPMsg;
507
508 if (ioc->bus_type == FC)
509 return;
510
511 if ((mf = mpt_get_msg_frame(ioc->InternalCtx, ioc)) == NULL) {
512 dfailprintk((MYIOC_s_WARN_FMT "%s: no msg frames!!\n",
513 ioc->name,__FUNCTION__));
514 return;
515 }
516
517 SEPMsg = (SEPRequest_t *)mf;
518 SEPMsg->Function = MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR;
519 SEPMsg->Bus = vtarget->bus_id;
520 SEPMsg->TargetID = vtarget->target_id;
521 SEPMsg->Action = MPI_SEP_REQ_ACTION_WRITE_STATUS;
522 SEPMsg->SlotStatus = SlotStatus;
523 devtverboseprintk((MYIOC_s_WARN_FMT
524 "Sending SEP cmd=%x id=%d bus=%d\n",
525 ioc->name, SlotStatus, SEPMsg->TargetID, SEPMsg->Bus));
526 mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
527}
528
500/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 529/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
501/* 530/*
502 * mptscsih_io_done - Main SCSI IO callback routine registered to 531 * mptscsih_io_done - Main SCSI IO callback routine registered to
@@ -520,6 +549,8 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
520 SCSIIORequest_t *pScsiReq; 549 SCSIIORequest_t *pScsiReq;
521 SCSIIOReply_t *pScsiReply; 550 SCSIIOReply_t *pScsiReply;
522 u16 req_idx, req_idx_MR; 551 u16 req_idx, req_idx_MR;
552 VirtDevice *vdev;
553 VirtTarget *vtarget;
523 554
524 hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; 555 hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
525 556
@@ -538,6 +569,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
538 } 569 }
539 570
540 sc = hd->ScsiLookup[req_idx]; 571 sc = hd->ScsiLookup[req_idx];
572 hd->ScsiLookup[req_idx] = NULL;
541 if (sc == NULL) { 573 if (sc == NULL) {
542 MPIHeader_t *hdr = (MPIHeader_t *)mf; 574 MPIHeader_t *hdr = (MPIHeader_t *)mf;
543 575
@@ -553,6 +585,12 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
553 return 1; 585 return 1;
554 } 586 }
555 587
588 if ((unsigned char *)mf != sc->host_scribble) {
589 mptscsih_freeChainBuffers(ioc, req_idx);
590 return 1;
591 }
592
593 sc->host_scribble = NULL;
556 sc->result = DID_OK << 16; /* Set default reply as OK */ 594 sc->result = DID_OK << 16; /* Set default reply as OK */
557 pScsiReq = (SCSIIORequest_t *) mf; 595 pScsiReq = (SCSIIORequest_t *) mf;
558 pScsiReply = (SCSIIOReply_t *) mr; 596 pScsiReply = (SCSIIOReply_t *) mr;
@@ -640,10 +678,36 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
640 678
641 if (hd->sel_timeout[pScsiReq->TargetID] < 0xFFFF) 679 if (hd->sel_timeout[pScsiReq->TargetID] < 0xFFFF)
642 hd->sel_timeout[pScsiReq->TargetID]++; 680 hd->sel_timeout[pScsiReq->TargetID]++;
681
682 vdev = sc->device->hostdata;
683 if (!vdev)
684 break;
685 vtarget = vdev->vtarget;
686 if (vtarget->tflags & MPT_TARGET_FLAGS_LED_ON) {
687 mptscsih_issue_sep_command(ioc, vtarget,
688 MPI_SEP_REQ_SLOTSTATUS_UNCONFIGURED);
689 vtarget->tflags &= ~MPT_TARGET_FLAGS_LED_ON;
690 }
643 break; 691 break;
644 692
645 case MPI_IOCSTATUS_SCSI_TASK_TERMINATED: /* 0x0048 */
646 case MPI_IOCSTATUS_SCSI_IOC_TERMINATED: /* 0x004B */ 693 case MPI_IOCSTATUS_SCSI_IOC_TERMINATED: /* 0x004B */
694 if ( ioc->bus_type == SAS ) {
695 u16 ioc_status = le16_to_cpu(pScsiReply->IOCStatus);
696 if (ioc_status & MPI_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE) {
697 u32 log_info = le32_to_cpu(mr->u.reply.IOCLogInfo);
698 log_info &=SAS_LOGINFO_MASK;
699 if (log_info == SAS_LOGINFO_NEXUS_LOSS) {
700 sc->result = (DID_BUS_BUSY << 16);
701 break;
702 }
703 }
704 }
705
706 /*
707 * Allow non-SAS & non-NEXUS_LOSS to drop into below code
708 */
709
710 case MPI_IOCSTATUS_SCSI_TASK_TERMINATED: /* 0x0048 */
647 case MPI_IOCSTATUS_SCSI_EXT_TERMINATED: /* 0x004C */ 711 case MPI_IOCSTATUS_SCSI_EXT_TERMINATED: /* 0x004C */
648 /* Linux handles an unsolicited DID_RESET better 712 /* Linux handles an unsolicited DID_RESET better
649 * than an unsolicited DID_ABORT. 713 * than an unsolicited DID_ABORT.
@@ -658,7 +722,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
658 sc->result=DID_SOFT_ERROR << 16; 722 sc->result=DID_SOFT_ERROR << 16;
659 else /* Sufficient data transfer occurred */ 723 else /* Sufficient data transfer occurred */
660 sc->result = (DID_OK << 16) | scsi_status; 724 sc->result = (DID_OK << 16) | scsi_status;
661 dreplyprintk((KERN_NOTICE 725 dreplyprintk((KERN_NOTICE
662 "RESIDUAL_MISMATCH: result=%x on id=%d\n", sc->result, sc->device->id)); 726 "RESIDUAL_MISMATCH: result=%x on id=%d\n", sc->result, sc->device->id));
663 break; 727 break;
664 728
@@ -784,8 +848,6 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
784 sc->request_bufflen, sc->sc_data_direction); 848 sc->request_bufflen, sc->sc_data_direction);
785 } 849 }
786 850
787 hd->ScsiLookup[req_idx] = NULL;
788
789 sc->scsi_done(sc); /* Issue the command callback */ 851 sc->scsi_done(sc); /* Issue the command callback */
790 852
791 /* Free Chain buffers */ 853 /* Free Chain buffers */
@@ -827,9 +889,17 @@ mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd)
827 dmfprintk(( "flush: ScsiDone (mf=%p,sc=%p)\n", 889 dmfprintk(( "flush: ScsiDone (mf=%p,sc=%p)\n",
828 mf, SCpnt)); 890 mf, SCpnt));
829 891
892 /* Free Chain buffers */
893 mptscsih_freeChainBuffers(ioc, ii);
894
895 /* Free Message frames */
896 mpt_free_msg_frame(ioc, mf);
897
898 if ((unsigned char *)mf != SCpnt->host_scribble)
899 continue;
900
830 /* Set status, free OS resources (SG DMA buffers) 901 /* Set status, free OS resources (SG DMA buffers)
831 * Do OS callback 902 * Do OS callback
832 * Free driver resources (chain, msg buffers)
833 */ 903 */
834 if (SCpnt->use_sg) { 904 if (SCpnt->use_sg) {
835 pci_unmap_sg(ioc->pcidev, 905 pci_unmap_sg(ioc->pcidev,
@@ -845,12 +915,6 @@ mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd)
845 SCpnt->result = DID_RESET << 16; 915 SCpnt->result = DID_RESET << 16;
846 SCpnt->host_scribble = NULL; 916 SCpnt->host_scribble = NULL;
847 917
848 /* Free Chain buffers */
849 mptscsih_freeChainBuffers(ioc, ii);
850
851 /* Free Message frames */
852 mpt_free_msg_frame(ioc, mf);
853
854 SCpnt->scsi_done(SCpnt); /* Issue the command callback */ 918 SCpnt->scsi_done(SCpnt); /* Issue the command callback */
855 } 919 }
856 } 920 }
@@ -887,10 +951,10 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
887 if ((sc = hd->ScsiLookup[ii]) != NULL) { 951 if ((sc = hd->ScsiLookup[ii]) != NULL) {
888 952
889 mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(hd->ioc, ii); 953 mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(hd->ioc, ii);
890 954 if (mf == NULL)
955 continue;
891 dsprintk(( "search_running: found (sc=%p, mf = %p) target %d, lun %d \n", 956 dsprintk(( "search_running: found (sc=%p, mf = %p) target %d, lun %d \n",
892 hd->ScsiLookup[ii], mf, mf->TargetID, mf->LUN[1])); 957 hd->ScsiLookup[ii], mf, mf->TargetID, mf->LUN[1]));
893
894 if ((mf->TargetID != ((u8)vdevice->vtarget->target_id)) || (mf->LUN[1] != ((u8) vdevice->lun))) 958 if ((mf->TargetID != ((u8)vdevice->vtarget->target_id)) || (mf->LUN[1] != ((u8) vdevice->lun)))
895 continue; 959 continue;
896 960
@@ -899,6 +963,8 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
899 hd->ScsiLookup[ii] = NULL; 963 hd->ScsiLookup[ii] = NULL;
900 mptscsih_freeChainBuffers(hd->ioc, ii); 964 mptscsih_freeChainBuffers(hd->ioc, ii);
901 mpt_free_msg_frame(hd->ioc, (MPT_FRAME_HDR *)mf); 965 mpt_free_msg_frame(hd->ioc, (MPT_FRAME_HDR *)mf);
966 if ((unsigned char *)mf != sc->host_scribble)
967 continue;
902 if (sc->use_sg) { 968 if (sc->use_sg) {
903 pci_unmap_sg(hd->ioc->pcidev, 969 pci_unmap_sg(hd->ioc->pcidev,
904 (struct scatterlist *) sc->request_buffer, 970 (struct scatterlist *) sc->request_buffer,
@@ -1341,8 +1407,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1341 goto fail; 1407 goto fail;
1342 } 1408 }
1343 1409
1410 SCpnt->host_scribble = (unsigned char *)mf;
1344 hd->ScsiLookup[my_idx] = SCpnt; 1411 hd->ScsiLookup[my_idx] = SCpnt;
1345 SCpnt->host_scribble = NULL;
1346 1412
1347 mpt_put_msg_frame(hd->ioc->DoneCtx, hd->ioc, mf); 1413 mpt_put_msg_frame(hd->ioc->DoneCtx, hd->ioc, mf);
1348 dmfprintk((MYIOC_s_INFO_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n", 1414 dmfprintk((MYIOC_s_INFO_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n",
@@ -1529,6 +1595,12 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, in
1529 rc = mpt_HardResetHandler(hd->ioc, CAN_SLEEP); 1595 rc = mpt_HardResetHandler(hd->ioc, CAN_SLEEP);
1530 } 1596 }
1531 1597
1598 /*
1599 * Check IOCStatus from TM reply message
1600 */
1601 if (hd->tm_iocstatus != MPI_IOCSTATUS_SUCCESS)
1602 rc = FAILED;
1603
1532 dtmprintk((MYIOC_s_INFO_FMT "TMHandler rc = %d!\n", hd->ioc->name, rc)); 1604 dtmprintk((MYIOC_s_INFO_FMT "TMHandler rc = %d!\n", hd->ioc->name, rc));
1533 1605
1534 return rc; 1606 return rc;
@@ -1654,6 +1726,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1654 int scpnt_idx; 1726 int scpnt_idx;
1655 int retval; 1727 int retval;
1656 VirtDevice *vdev; 1728 VirtDevice *vdev;
1729 ulong sn = SCpnt->serial_number;
1657 1730
1658 /* If we can't locate our host adapter structure, return FAILED status. 1731 /* If we can't locate our host adapter structure, return FAILED status.
1659 */ 1732 */
@@ -1707,6 +1780,11 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1707 vdev->vtarget->bus_id, vdev->vtarget->target_id, vdev->lun, 1780 vdev->vtarget->bus_id, vdev->vtarget->target_id, vdev->lun,
1708 ctx2abort, mptscsih_get_tm_timeout(hd->ioc)); 1781 ctx2abort, mptscsih_get_tm_timeout(hd->ioc));
1709 1782
1783 if (SCPNT_TO_LOOKUP_IDX(SCpnt) == scpnt_idx &&
1784 SCpnt->serial_number == sn) {
1785 retval = FAILED;
1786 }
1787
1710 printk (KERN_WARNING MYNAM ": %s: task abort: %s (sc=%p)\n", 1788 printk (KERN_WARNING MYNAM ": %s: task abort: %s (sc=%p)\n",
1711 hd->ioc->name, 1789 hd->ioc->name,
1712 ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt); 1790 ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
@@ -2023,6 +2101,7 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *m
2023 DBG_DUMP_TM_REPLY_FRAME((u32 *)pScsiTmReply); 2101 DBG_DUMP_TM_REPLY_FRAME((u32 *)pScsiTmReply);
2024 2102
2025 iocstatus = le16_to_cpu(pScsiTmReply->IOCStatus) & MPI_IOCSTATUS_MASK; 2103 iocstatus = le16_to_cpu(pScsiTmReply->IOCStatus) & MPI_IOCSTATUS_MASK;
2104 hd->tm_iocstatus = iocstatus;
2026 dtmprintk((MYIOC_s_WARN_FMT " SCSI TaskMgmt (%d) IOCStatus=%04x IOCLogInfo=%08x\n", 2105 dtmprintk((MYIOC_s_WARN_FMT " SCSI TaskMgmt (%d) IOCStatus=%04x IOCLogInfo=%08x\n",
2027 ioc->name, tmType, iocstatus, le32_to_cpu(pScsiTmReply->IOCLogInfo))); 2106 ioc->name, tmType, iocstatus, le32_to_cpu(pScsiTmReply->IOCLogInfo)));
2028 /* Error? (anything non-zero?) */ 2107 /* Error? (anything non-zero?) */
@@ -2401,6 +2480,13 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
2401 ioc->events[idx].data[1] = (sense_data[13] << 8) || sense_data[12]; 2480 ioc->events[idx].data[1] = (sense_data[13] << 8) || sense_data[12];
2402 2481
2403 ioc->eventContext++; 2482 ioc->eventContext++;
2483 if (hd->ioc->pcidev->vendor ==
2484 PCI_VENDOR_ID_IBM) {
2485 mptscsih_issue_sep_command(hd->ioc,
2486 vdev->vtarget, MPI_SEP_REQ_SLOTSTATUS_PREDICTED_FAULT);
2487 vdev->vtarget->tflags |=
2488 MPT_TARGET_FLAGS_LED_ON;
2489 }
2404 } 2490 }
2405 } 2491 }
2406 } else { 2492 } else {
@@ -2409,7 +2495,7 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
2409 } 2495 }
2410} 2496}
2411 2497
2412static u32 2498static int
2413SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc) 2499SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc)
2414{ 2500{
2415 MPT_SCSI_HOST *hd; 2501 MPT_SCSI_HOST *hd;
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index 3201de053943..e4cc3dd5fc9f 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -83,10 +83,6 @@ static int mpt_saf_te = MPTSCSIH_SAF_TE;
83module_param(mpt_saf_te, int, 0); 83module_param(mpt_saf_te, int, 0);
84MODULE_PARM_DESC(mpt_saf_te, " Force enabling SEP Processor: enable=1 (default=MPTSCSIH_SAF_TE=0)"); 84MODULE_PARM_DESC(mpt_saf_te, " Force enabling SEP Processor: enable=1 (default=MPTSCSIH_SAF_TE=0)");
85 85
86static int mpt_pq_filter = 0;
87module_param(mpt_pq_filter, int, 0);
88MODULE_PARM_DESC(mpt_pq_filter, " Enable peripheral qualifier filter: enable=1 (default=0)");
89
90static void mptspi_write_offset(struct scsi_target *, int); 86static void mptspi_write_offset(struct scsi_target *, int);
91static void mptspi_write_width(struct scsi_target *, int); 87static void mptspi_write_width(struct scsi_target *, int);
92static int mptspi_write_spi_device_pg1(struct scsi_target *, 88static int mptspi_write_spi_device_pg1(struct scsi_target *,
@@ -775,9 +771,9 @@ static struct spi_function_template mptspi_transport_functions = {
775 */ 771 */
776 772
777static struct pci_device_id mptspi_pci_table[] = { 773static struct pci_device_id mptspi_pci_table[] = {
778 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_53C1030, 774 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_53C1030,
779 PCI_ANY_ID, PCI_ANY_ID }, 775 PCI_ANY_ID, PCI_ANY_ID },
780 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_1030_53C1035, 776 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_53C1035,
781 PCI_ANY_ID, PCI_ANY_ID }, 777 PCI_ANY_ID, PCI_ANY_ID },
782 {0} /* Terminating entry */ 778 {0} /* Terminating entry */
783}; 779};
@@ -1047,14 +1043,12 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1047 hd->timer.function = mptscsih_timer_expired; 1043 hd->timer.function = mptscsih_timer_expired;
1048 1044
1049 ioc->spi_data.Saf_Te = mpt_saf_te; 1045 ioc->spi_data.Saf_Te = mpt_saf_te;
1050 hd->mpt_pq_filter = mpt_pq_filter;
1051 1046
1052 hd->negoNvram = MPT_SCSICFG_USE_NVRAM; 1047 hd->negoNvram = MPT_SCSICFG_USE_NVRAM;
1053 ddvprintk((MYIOC_s_INFO_FMT 1048 ddvprintk((MYIOC_s_INFO_FMT
1054 "saf_te %x mpt_pq_filter %x\n", 1049 "saf_te %x\n",
1055 ioc->name, 1050 ioc->name,
1056 mpt_saf_te, 1051 mpt_saf_te));
1057 mpt_pq_filter));
1058 ioc->spi_data.noQas = 0; 1052 ioc->spi_data.noQas = 0;
1059 1053
1060 init_waitqueue_head(&hd->scandv_waitq); 1054 init_waitqueue_head(&hd->scandv_waitq);
diff --git a/drivers/message/i2o/core.h b/drivers/message/i2o/core.h
index 184974cc734d..dc388a3ff5e0 100644
--- a/drivers/message/i2o/core.h
+++ b/drivers/message/i2o/core.h
@@ -38,6 +38,9 @@ extern struct device_attribute i2o_device_attrs[];
38extern void i2o_device_remove(struct i2o_device *); 38extern void i2o_device_remove(struct i2o_device *);
39extern int i2o_device_parse_lct(struct i2o_controller *); 39extern int i2o_device_parse_lct(struct i2o_controller *);
40 40
41int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
42 int oplen, void *reslist, int reslen);
43
41/* IOP */ 44/* IOP */
42extern struct i2o_controller *i2o_iop_alloc(void); 45extern struct i2o_controller *i2o_iop_alloc(void);
43 46
diff --git a/drivers/message/i2o/debug.c b/drivers/message/i2o/debug.c
index 5a6cca8e8c45..8abe45e49ad7 100644
--- a/drivers/message/i2o/debug.c
+++ b/drivers/message/i2o/debug.c
@@ -1,4 +1,3 @@
1#include <linux/config.h>
2#include <linux/module.h> 1#include <linux/module.h>
3#include <linux/kernel.h> 2#include <linux/kernel.h>
4#include <linux/pci.h> 3#include <linux/pci.h>
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index 7d4c5497785b..1ddc2fb429d5 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -1089,7 +1089,6 @@ static int i2o_block_probe(struct device *dev)
1089 gd = i2o_blk_dev->gd; 1089 gd = i2o_blk_dev->gd;
1090 gd->first_minor = unit << 4; 1090 gd->first_minor = unit << 4;
1091 sprintf(gd->disk_name, "i2o/hd%c", 'a' + unit); 1091 sprintf(gd->disk_name, "i2o/hd%c", 'a' + unit);
1092 sprintf(gd->devfs_name, "i2o/hd%c", 'a' + unit);
1093 gd->driverfs_dev = &i2o_dev->device; 1092 gd->driverfs_dev = &i2o_dev->device;
1094 1093
1095 /* setup request queue */ 1094 /* setup request queue */
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index 89daf67b764d..7d23e082bf26 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -36,9 +36,9 @@
36 36
37#include <asm/uaccess.h> 37#include <asm/uaccess.h>
38 38
39#define SG_TABLESIZE 30 39#include "core.h"
40 40
41extern int i2o_parm_issue(struct i2o_device *, int, void *, int, void *, int); 41#define SG_TABLESIZE 30
42 42
43static int i2o_cfg_ioctl(struct inode *, struct file *, unsigned int, 43static int i2o_cfg_ioctl(struct inode *, struct file *, unsigned int,
44 unsigned long); 44 unsigned long);
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index febbdd4e0605..3305c12372a2 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -683,9 +683,10 @@ static int i2o_iop_systab_set(struct i2o_controller *c)
683 c->mem_alloc = 1; 683 c->mem_alloc = 1;
684 sb->current_mem_size = 1 + res->end - res->start; 684 sb->current_mem_size = 1 + res->end - res->start;
685 sb->current_mem_base = res->start; 685 sb->current_mem_base = res->start;
686 osm_info("%s: allocated %ld bytes of PCI memory at " 686 osm_info("%s: allocated %llu bytes of PCI memory at "
687 "0x%08lX.\n", c->name, 687 "0x%016llX.\n", c->name,
688 1 + res->end - res->start, res->start); 688 (unsigned long long)(1 + res->end - res->start),
689 (unsigned long long)res->start);
689 } 690 }
690 } 691 }
691 692
@@ -704,9 +705,10 @@ static int i2o_iop_systab_set(struct i2o_controller *c)
704 c->io_alloc = 1; 705 c->io_alloc = 1;
705 sb->current_io_size = 1 + res->end - res->start; 706 sb->current_io_size = 1 + res->end - res->start;
706 sb->current_mem_base = res->start; 707 sb->current_mem_base = res->start;
707 osm_info("%s: allocated %ld bytes of PCI I/O at 0x%08lX" 708 osm_info("%s: allocated %llu bytes of PCI I/O at "
708 ".\n", c->name, 1 + res->end - res->start, 709 "0x%016llX.\n", c->name,
709 res->start); 710 (unsigned long long)(1 + res->end - res->start),
711 (unsigned long long)res->start);
710 } 712 }
711 } 713 }
712 714
@@ -1239,7 +1241,6 @@ EXPORT_SYMBOL(i2o_cntxt_list_remove);
1239EXPORT_SYMBOL(i2o_cntxt_list_get_ptr); 1241EXPORT_SYMBOL(i2o_cntxt_list_get_ptr);
1240#endif 1242#endif
1241EXPORT_SYMBOL(i2o_msg_get_wait); 1243EXPORT_SYMBOL(i2o_msg_get_wait);
1242EXPORT_SYMBOL(i2o_msg_nop);
1243EXPORT_SYMBOL(i2o_find_iop); 1244EXPORT_SYMBOL(i2o_find_iop);
1244EXPORT_SYMBOL(i2o_iop_find_device); 1245EXPORT_SYMBOL(i2o_iop_find_device);
1245EXPORT_SYMBOL(i2o_event_register); 1246EXPORT_SYMBOL(i2o_event_register);
diff --git a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c
index 4f1515cae5dc..1b58444d5aaf 100644
--- a/drivers/message/i2o/pci.c
+++ b/drivers/message/i2o/pci.c
@@ -274,7 +274,7 @@ static int i2o_pci_irq_enable(struct i2o_controller *c)
274 writel(0xffffffff, c->irq_mask); 274 writel(0xffffffff, c->irq_mask);
275 275
276 if (pdev->irq) { 276 if (pdev->irq) {
277 rc = request_irq(pdev->irq, i2o_pci_interrupt, SA_SHIRQ, 277 rc = request_irq(pdev->irq, i2o_pci_interrupt, IRQF_SHARED,
278 c->name, c); 278 c->name, c);
279 if (rc < 0) { 279 if (rc < 0) {
280 printk(KERN_ERR "%s: unable to allocate interrupt %d." 280 printk(KERN_ERR "%s: unable to allocate interrupt %d."