aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/fusion
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2006-09-17 12:17:19 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2006-09-17 12:19:31 -0400
commit9b4f2e9576658c4e52d95dc8d309f51b2e2db096 (patch)
tree7b1902b0f931783fccc6fee45c6f9c16b4fde5ce /drivers/message/fusion
parent3c6c65f5ed5a6d307bd607aecd06d658c0934d88 (diff)
parent803db244b9f71102e366fd689000c1417b9a7508 (diff)
ieee1394: merge from Linus
Conflicts: drivers/ieee1394/hosts.c Patch "lockdep: annotate ieee1394 skb-queue-head locking" was meddling with patch "ieee1394: fix kerneldoc of hpsb_alloc_host". Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/message/fusion')
-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.c174
-rw-r--r--drivers/message/fusion/mptbase.h23
-rw-r--r--drivers/message/fusion/mptctl.c4
-rw-r--r--drivers/message/fusion/mptctl.h5
-rw-r--r--drivers/message/fusion/mptfc.c122
-rw-r--r--drivers/message/fusion/mptsas.c1045
-rw-r--r--drivers/message/fusion/mptscsih.c118
-rw-r--r--drivers/message/fusion/mptspi.c14
19 files changed, 1429 insertions, 670 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 57543603d6c8..29d0635cce1d 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -368,20 +368,21 @@ static irqreturn_t
368mpt_interrupt(int irq, void *bus_id, struct pt_regs *r) 368mpt_interrupt(int irq, void *bus_id, struct pt_regs *r)
369{ 369{
370 MPT_ADAPTER *ioc = bus_id; 370 MPT_ADAPTER *ioc = bus_id;
371 u32 pa; 371 u32 pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo);
372
373 if (pa == 0xFFFFFFFF)
374 return IRQ_NONE;
372 375
373 /* 376 /*
374 * Drain the reply FIFO! 377 * Drain the reply FIFO!
375 */ 378 */
376 while (1) { 379 do {
377 pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo); 380 if (pa & MPI_ADDRESS_REPLY_A_BIT)
378 if (pa == 0xFFFFFFFF)
379 return IRQ_HANDLED;
380 else if (pa & MPI_ADDRESS_REPLY_A_BIT)
381 mpt_reply(ioc, pa); 381 mpt_reply(ioc, pa);
382 else 382 else
383 mpt_turbo_reply(ioc, pa); 383 mpt_turbo_reply(ioc, pa);
384 } 384 pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo);
385 } while (pa != 0xFFFFFFFF);
385 386
386 return IRQ_HANDLED; 387 return IRQ_HANDLED;
387} 388}
@@ -435,8 +436,6 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
435 */ 436 */
436 if (pEvReply->MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY) { 437 if (pEvReply->MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY) {
437 freereq = 0; 438 freereq = 0;
438 devtverboseprintk((MYIOC_s_WARN_FMT "EVENT_NOTIFICATION reply %p does not return Request frame\n",
439 ioc->name, pEvReply));
440 } else { 439 } else {
441 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",
442 ioc->name, pEvReply)); 441 ioc->name, pEvReply));
@@ -677,19 +676,19 @@ int
677mpt_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)
678{ 677{
679 MPT_ADAPTER *ioc; 678 MPT_ADAPTER *ioc;
679 const struct pci_device_id *id;
680 680
681 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) { 681 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
682 return -EINVAL; 682 return -EINVAL;
683 }
684 683
685 MptDeviceDriverHandlers[cb_idx] = dd_cbfunc; 684 MptDeviceDriverHandlers[cb_idx] = dd_cbfunc;
686 685
687 /* call per pci device probe entry point */ 686 /* call per pci device probe entry point */
688 list_for_each_entry(ioc, &ioc_list, list) { 687 list_for_each_entry(ioc, &ioc_list, list) {
689 if(dd_cbfunc->probe) { 688 id = ioc->pcidev->driver ?
690 dd_cbfunc->probe(ioc->pcidev, 689 ioc->pcidev->driver->id_table : NULL;
691 ioc->pcidev->driver->id_table); 690 if (dd_cbfunc->probe)
692 } 691 dd_cbfunc->probe(ioc->pcidev, id);
693 } 692 }
694 693
695 return 0; 694 return 0;
@@ -1055,9 +1054,8 @@ mpt_host_page_alloc(MPT_ADAPTER *ioc, pIOCInit_t ioc_init)
1055 1054
1056 dinitprintk((MYIOC_s_INFO_FMT 1055 dinitprintk((MYIOC_s_INFO_FMT
1057 "host_page_buffer @ %p, dma @ %x, sz=%d bytes\n", 1056 "host_page_buffer @ %p, dma @ %x, sz=%d bytes\n",
1058 ioc->name, 1057 ioc->name, ioc->HostPageBuffer,
1059 ioc->HostPageBuffer, 1058 (u32)ioc->HostPageBuffer_dma,
1060 ioc->HostPageBuffer_dma,
1061 host_page_buffer_sz)); 1059 host_page_buffer_sz));
1062 ioc->alloc_total += host_page_buffer_sz; 1060 ioc->alloc_total += host_page_buffer_sz;
1063 ioc->HostPageBuffer_sz = host_page_buffer_sz; 1061 ioc->HostPageBuffer_sz = host_page_buffer_sz;
@@ -1219,31 +1217,25 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1219 port = psize = 0; 1217 port = psize = 0;
1220 for (ii=0; ii < DEVICE_COUNT_RESOURCE; ii++) { 1218 for (ii=0; ii < DEVICE_COUNT_RESOURCE; ii++) {
1221 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;
1222 /* Get I/O space! */ 1222 /* Get I/O space! */
1223 port = pci_resource_start(pdev, ii); 1223 port = pci_resource_start(pdev, ii);
1224 psize = pci_resource_len(pdev,ii); 1224 psize = pci_resource_len(pdev,ii);
1225 } else { 1225 } else {
1226 if (msize)
1227 continue;
1226 /* Get memmap */ 1228 /* Get memmap */
1227 mem_phys = pci_resource_start(pdev, ii); 1229 mem_phys = pci_resource_start(pdev, ii);
1228 msize = pci_resource_len(pdev,ii); 1230 msize = pci_resource_len(pdev,ii);
1229 break;
1230 } 1231 }
1231 } 1232 }
1232 ioc->mem_size = msize; 1233 ioc->mem_size = msize;
1233 1234
1234 if (ii == DEVICE_COUNT_RESOURCE) {
1235 printk(KERN_ERR MYNAM ": ERROR - MPT adapter has no memory regions defined!\n");
1236 kfree(ioc);
1237 return -EINVAL;
1238 }
1239
1240 dinitprintk((KERN_INFO MYNAM ": MPT adapter @ %lx, msize=%dd bytes\n", mem_phys, msize));
1241 dinitprintk((KERN_INFO MYNAM ": (port i/o @ %lx, psize=%dd bytes)\n", port, psize));
1242
1243 mem = NULL; 1235 mem = NULL;
1244 /* Get logical ptr for PciMem0 space */ 1236 /* Get logical ptr for PciMem0 space */
1245 /*mem = ioremap(mem_phys, msize);*/ 1237 /*mem = ioremap(mem_phys, msize);*/
1246 mem = ioremap(mem_phys, 0x100); 1238 mem = ioremap(mem_phys, msize);
1247 if (mem == NULL) { 1239 if (mem == NULL) {
1248 printk(KERN_ERR MYNAM ": ERROR - Unable to map adapter memory!\n"); 1240 printk(KERN_ERR MYNAM ": ERROR - Unable to map adapter memory!\n");
1249 kfree(ioc); 1241 kfree(ioc);
@@ -1343,11 +1335,6 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1343 ioc->bus_type = SAS; 1335 ioc->bus_type = SAS;
1344 ioc->errata_flag_1064 = 1; 1336 ioc->errata_flag_1064 = 1;
1345 } 1337 }
1346 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1066) {
1347 ioc->prod_name = "LSISAS1066";
1348 ioc->bus_type = SAS;
1349 ioc->errata_flag_1064 = 1;
1350 }
1351 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1068) { 1338 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1068) {
1352 ioc->prod_name = "LSISAS1068"; 1339 ioc->prod_name = "LSISAS1068";
1353 ioc->bus_type = SAS; 1340 ioc->bus_type = SAS;
@@ -1357,14 +1344,14 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1357 ioc->prod_name = "LSISAS1064E"; 1344 ioc->prod_name = "LSISAS1064E";
1358 ioc->bus_type = SAS; 1345 ioc->bus_type = SAS;
1359 } 1346 }
1360 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1066E) {
1361 ioc->prod_name = "LSISAS1066E";
1362 ioc->bus_type = SAS;
1363 }
1364 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1068E) { 1347 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1068E) {
1365 ioc->prod_name = "LSISAS1068E"; 1348 ioc->prod_name = "LSISAS1068E";
1366 ioc->bus_type = SAS; 1349 ioc->bus_type = SAS;
1367 } 1350 }
1351 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) {
1352 ioc->prod_name = "LSISAS1078";
1353 ioc->bus_type = SAS;
1354 }
1368 1355
1369 if (ioc->errata_flag_1064) 1356 if (ioc->errata_flag_1064)
1370 pci_disable_io_access(pdev); 1357 pci_disable_io_access(pdev);
@@ -1390,6 +1377,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1390 printk(KERN_WARNING MYNAM 1377 printk(KERN_WARNING MYNAM
1391 ": WARNING - %s did not initialize properly! (%d)\n", 1378 ": WARNING - %s did not initialize properly! (%d)\n",
1392 ioc->name, r); 1379 ioc->name, r);
1380
1393 list_del(&ioc->list); 1381 list_del(&ioc->list);
1394 if (ioc->alt_ioc) 1382 if (ioc->alt_ioc)
1395 ioc->alt_ioc->alt_ioc = NULL; 1383 ioc->alt_ioc->alt_ioc = NULL;
@@ -1772,9 +1760,9 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1772 * chips (mpt_adapter_disable, 1760 * chips (mpt_adapter_disable,
1773 * mpt_diag_reset) 1761 * mpt_diag_reset)
1774 */ 1762 */
1775 ioc->cached_fw = NULL;
1776 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",
1777 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;
1778 } 1766 }
1779 } else { 1767 } else {
1780 printk(KERN_WARNING MYNAM ": firmware upload failure!\n"); 1768 printk(KERN_WARNING MYNAM ": firmware upload failure!\n");
@@ -1895,7 +1883,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1895 /* FIXME? Examine results here? */ 1883 /* FIXME? Examine results here? */
1896 } 1884 }
1897 1885
1898out: 1886 out:
1899 if ((ret != 0) && irq_allocated) { 1887 if ((ret != 0) && irq_allocated) {
1900 free_irq(ioc->pci_irq, ioc); 1888 free_irq(ioc->pci_irq, ioc);
1901 if (mpt_msi_enable) 1889 if (mpt_msi_enable)
@@ -2680,6 +2668,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
2680 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",
2681 ioc->name, count)); 2669 ioc->name, count));
2682 2670
2671 ioc->aen_event_read_flag=0;
2683 return r; 2672 return r;
2684} 2673}
2685 2674
@@ -2747,6 +2736,8 @@ mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size)
2747 if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) { 2736 if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) {
2748 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 */
2749 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;
2750 } else { 2741 } else {
2751 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) ) )
2752 ioc->alloc_total += size; 2743 ioc->alloc_total += size;
@@ -3176,6 +3167,7 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag)
3176static int 3167static int
3177mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag) 3168mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3178{ 3169{
3170 MPT_ADAPTER *iocp=NULL;
3179 u32 diag0val; 3171 u32 diag0val;
3180 u32 doorbell; 3172 u32 doorbell;
3181 int hard_reset_done = 0; 3173 int hard_reset_done = 0;
@@ -3184,6 +3176,37 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3184 u32 diag1val = 0; 3176 u32 diag1val = 0;
3185#endif 3177#endif
3186 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
3187 /* Clear any existing interrupts */ 3210 /* Clear any existing interrupts */
3188 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); 3211 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
3189 3212
@@ -3280,17 +3303,23 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3280 /* FIXME? Examine results here? */ 3303 /* FIXME? Examine results here? */
3281 } 3304 }
3282 3305
3283 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) {
3284 /* If the DownloadBoot operation fails, the 3311 /* If the DownloadBoot operation fails, the
3285 * IOC will be left unusable. This is a fatal error 3312 * IOC will be left unusable. This is a fatal error
3286 * case. _diag_reset will return < 0 3313 * case. _diag_reset will return < 0
3287 */ 3314 */
3288 for (count = 0; count < 30; count ++) { 3315 for (count = 0; count < 30; count ++) {
3289 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); 3316 diag0val = CHIPREG_READ32(&iocp->chip->Diagnostic);
3290 if (!(diag0val & MPI_DIAG_RESET_ADAPTER)) { 3317 if (!(diag0val & MPI_DIAG_RESET_ADAPTER)) {
3291 break; 3318 break;
3292 } 3319 }
3293 3320
3321 dprintk((MYIOC_s_INFO_FMT "cached_fw: diag0val=%x count=%d\n",
3322 iocp->name, diag0val, count));
3294 /* wait 1 sec */ 3323 /* wait 1 sec */
3295 if (sleepFlag == CAN_SLEEP) { 3324 if (sleepFlag == CAN_SLEEP) {
3296 msleep (1000); 3325 msleep (1000);
@@ -3299,7 +3328,7 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3299 } 3328 }
3300 } 3329 }
3301 if ((count = mpt_downloadboot(ioc, 3330 if ((count = mpt_downloadboot(ioc,
3302 (MpiFwHeader_t *)ioc->cached_fw, sleepFlag)) < 0) { 3331 (MpiFwHeader_t *)iocp->cached_fw, sleepFlag)) < 0) {
3303 printk(KERN_WARNING MYNAM 3332 printk(KERN_WARNING MYNAM
3304 ": firmware downloadboot failure (%d)!\n", count); 3333 ": firmware downloadboot failure (%d)!\n", count);
3305 } 3334 }
@@ -3886,18 +3915,18 @@ WaitForDoorbellAck(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
3886 3915
3887 if (sleepFlag == CAN_SLEEP) { 3916 if (sleepFlag == CAN_SLEEP) {
3888 while (--cntdn) { 3917 while (--cntdn) {
3918 msleep (1);
3889 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); 3919 intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
3890 if (! (intstat & MPI_HIS_IOP_DOORBELL_STATUS)) 3920 if (! (intstat & MPI_HIS_IOP_DOORBELL_STATUS))
3891 break; 3921 break;
3892 msleep (1);
3893 count++; 3922 count++;
3894 } 3923 }
3895 } else { 3924 } else {
3896 while (--cntdn) { 3925 while (--cntdn) {
3926 mdelay (1);
3897 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); 3927 intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
3898 if (! (intstat & MPI_HIS_IOP_DOORBELL_STATUS)) 3928 if (! (intstat & MPI_HIS_IOP_DOORBELL_STATUS))
3899 break; 3929 break;
3900 mdelay (1);
3901 count++; 3930 count++;
3902 } 3931 }
3903 } 3932 }
@@ -4862,6 +4891,7 @@ mpt_read_ioc_pg_4(MPT_ADAPTER *ioc)
4862 pIoc4 = pci_alloc_consistent(ioc->pcidev, iocpage4sz, &ioc4_dma); 4891 pIoc4 = pci_alloc_consistent(ioc->pcidev, iocpage4sz, &ioc4_dma);
4863 if (!pIoc4) 4892 if (!pIoc4)
4864 return; 4893 return;
4894 ioc->alloc_total += iocpage4sz;
4865 } else { 4895 } else {
4866 ioc4_dma = ioc->spi_data.IocPg4_dma; 4896 ioc4_dma = ioc->spi_data.IocPg4_dma;
4867 iocpage4sz = ioc->spi_data.IocPg4Sz; 4897 iocpage4sz = ioc->spi_data.IocPg4Sz;
@@ -4878,6 +4908,7 @@ mpt_read_ioc_pg_4(MPT_ADAPTER *ioc)
4878 } else { 4908 } else {
4879 pci_free_consistent(ioc->pcidev, iocpage4sz, pIoc4, ioc4_dma); 4909 pci_free_consistent(ioc->pcidev, iocpage4sz, pIoc4, ioc4_dma);
4880 ioc->spi_data.pIocPg4 = NULL; 4910 ioc->spi_data.pIocPg4 = NULL;
4911 ioc->alloc_total -= iocpage4sz;
4881 } 4912 }
4882} 4913}
4883 4914
@@ -5009,19 +5040,18 @@ SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp)
5009 EventAck_t *pAck; 5040 EventAck_t *pAck;
5010 5041
5011 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) {
5012 printk(MYIOC_s_WARN_FMT "Unable to allocate event ACK " 5043 dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
5013 "request frame for Event=%x EventContext=%x EventData=%x!\n", 5044 ioc->name,__FUNCTION__));
5014 ioc->name, evnp->Event, le32_to_cpu(evnp->EventContext),
5015 le32_to_cpu(evnp->Data[0]));
5016 return -1; 5045 return -1;
5017 } 5046 }
5018 memset(pAck, 0, sizeof(*pAck));
5019 5047
5020 dprintk((MYIOC_s_INFO_FMT "Sending EventAck\n", ioc->name)); 5048 devtverboseprintk((MYIOC_s_INFO_FMT "Sending EventAck\n", ioc->name));
5021 5049
5022 pAck->Function = MPI_FUNCTION_EVENT_ACK; 5050 pAck->Function = MPI_FUNCTION_EVENT_ACK;
5023 pAck->ChainOffset = 0; 5051 pAck->ChainOffset = 0;
5052 pAck->Reserved[0] = pAck->Reserved[1] = 0;
5024 pAck->MsgFlags = 0; 5053 pAck->MsgFlags = 0;
5054 pAck->Reserved1[0] = pAck->Reserved1[1] = pAck->Reserved1[2] = 0;
5025 pAck->Event = evnp->Event; 5055 pAck->Event = evnp->Event;
5026 pAck->EventContext = evnp->EventContext; 5056 pAck->EventContext = evnp->EventContext;
5027 5057
@@ -5683,9 +5713,9 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
5683 break; 5713 break;
5684 case MPI_EVENT_EVENT_CHANGE: 5714 case MPI_EVENT_EVENT_CHANGE:
5685 if (evData0) 5715 if (evData0)
5686 ds = "Events(ON) Change"; 5716 ds = "Events ON";
5687 else 5717 else
5688 ds = "Events(OFF) Change"; 5718 ds = "Events OFF";
5689 break; 5719 break;
5690 case MPI_EVENT_INTEGRATED_RAID: 5720 case MPI_EVENT_INTEGRATED_RAID:
5691 { 5721 {
@@ -5756,8 +5786,27 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
5756 break; 5786 break;
5757 case MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED: 5787 case MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED:
5758 snprintf(evStr, EVENT_DESCR_STR_SZ, 5788 snprintf(evStr, EVENT_DESCR_STR_SZ,
5759 "SAS Device Status Change: No Persistancy " 5789 "SAS Device Status Change: No Persistancy: id=%d", id);
5760 "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);
5761 break; 5810 break;
5762 default: 5811 default:
5763 snprintf(evStr, EVENT_DESCR_STR_SZ, 5812 snprintf(evStr, EVENT_DESCR_STR_SZ,
@@ -6013,7 +6062,7 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
6013 * @ioc: Pointer to MPT_ADAPTER structure 6062 * @ioc: Pointer to MPT_ADAPTER structure
6014 * @log_info: U32 LogInfo reply word from the IOC 6063 * @log_info: U32 LogInfo reply word from the IOC
6015 * 6064 *
6016 * Refer to lsi/fc_log.h. 6065 * Refer to lsi/mpi_log_fc.h.
6017 */ 6066 */
6018static void 6067static void
6019mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info) 6068mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info)
@@ -6110,8 +6159,10 @@ mpt_spi_log_info(MPT_ADAPTER *ioc, u32 log_info)
6110 "Invalid SAS Address", /* 01h */ 6159 "Invalid SAS Address", /* 01h */
6111 NULL, /* 02h */ 6160 NULL, /* 02h */
6112 "Invalid Page", /* 03h */ 6161 "Invalid Page", /* 03h */
6113 NULL, /* 04h */ 6162 "Diag Message Error", /* 04h */
6114 "Task Terminated" /* 05h */ 6163 "Task Terminated", /* 05h */
6164 "Enclosure Management", /* 06h */
6165 "Target Mode" /* 07h */
6115 }; 6166 };
6116 static char *pl_code_str[] = { 6167 static char *pl_code_str[] = {
6117 NULL, /* 00h */ 6168 NULL, /* 00h */
@@ -6137,7 +6188,7 @@ mpt_spi_log_info(MPT_ADAPTER *ioc, u32 log_info)
6137 "IO Executed", /* 14h */ 6188 "IO Executed", /* 14h */
6138 "Persistant Reservation Out Not Affiliation Owner", /* 15h */ 6189 "Persistant Reservation Out Not Affiliation Owner", /* 15h */
6139 "Open Transmit DMA Abort", /* 16h */ 6190 "Open Transmit DMA Abort", /* 16h */
6140 NULL, /* 17h */ 6191 "IO Device Missing Delay Retry", /* 17h */
6141 NULL, /* 18h */ 6192 NULL, /* 18h */
6142 NULL, /* 19h */ 6193 NULL, /* 19h */
6143 NULL, /* 1Ah */ 6194 NULL, /* 1Ah */
@@ -6217,7 +6268,7 @@ static void
6217mpt_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)
6218{ 6269{
6219 u32 status = ioc_status & MPI_IOCSTATUS_MASK; 6270 u32 status = ioc_status & MPI_IOCSTATUS_MASK;
6220 char *desc = ""; 6271 char *desc = NULL;
6221 6272
6222 switch (status) { 6273 switch (status) {
6223 case MPI_IOCSTATUS_INVALID_FUNCTION: /* 0x0001 */ 6274 case MPI_IOCSTATUS_INVALID_FUNCTION: /* 0x0001 */
@@ -6327,7 +6378,7 @@ mpt_sp_ioc_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf)
6327 desc = "Others"; 6378 desc = "Others";
6328 break; 6379 break;
6329 } 6380 }
6330 if (desc != "") 6381 if (desc != NULL)
6331 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);
6332} 6383}
6333 6384
@@ -6365,7 +6416,6 @@ EXPORT_SYMBOL(mpt_alloc_fw_memory);
6365EXPORT_SYMBOL(mpt_free_fw_memory); 6416EXPORT_SYMBOL(mpt_free_fw_memory);
6366EXPORT_SYMBOL(mptbase_sas_persist_operation); 6417EXPORT_SYMBOL(mptbase_sas_persist_operation);
6367 6418
6368
6369/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6419/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6370/* 6420/*
6371 * 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 32ae4d664545..c537d71c18e4 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -75,8 +75,8 @@
75#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR 75#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR
76#endif 76#endif
77 77
78#define MPT_LINUX_VERSION_COMMON "3.03.10" 78#define MPT_LINUX_VERSION_COMMON "3.04.01"
79#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.10" 79#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.04.01"
80#define WHAT_MAGIC_STRING "@" "(" "#" ")" 80#define WHAT_MAGIC_STRING "@" "(" "#" ")"
81 81
82#define show_mptmod_ver(s,ver) \ 82#define show_mptmod_ver(s,ver) \
@@ -307,7 +307,8 @@ typedef struct _SYSIF_REGS
307 u32 HostIndex; /* 50 Host Index register */ 307 u32 HostIndex; /* 50 Host Index register */
308 u32 Reserved4[15]; /* 54-8F */ 308 u32 Reserved4[15]; /* 54-8F */
309 u32 Fubar; /* 90 For Fubar usage */ 309 u32 Fubar; /* 90 For Fubar usage */
310 u32 Reserved5[27]; /* 94-FF */ 310 u32 Reserved5[1050];/* 94-10F8 */
311 u32 Reset_1078; /* 10FC Reset 1078 */
311} SYSIF_REGS; 312} SYSIF_REGS;
312 313
313/* 314/*
@@ -341,6 +342,7 @@ typedef struct _VirtTarget {
341 u8 negoFlags; /* bit field, see above */ 342 u8 negoFlags; /* bit field, see above */
342 u8 raidVolume; /* set, if RAID Volume */ 343 u8 raidVolume; /* set, if RAID Volume */
343 u8 type; /* byte 0 of Inquiry data */ 344 u8 type; /* byte 0 of Inquiry data */
345 u8 deleted; /* target in process of being removed */
344 u32 num_luns; 346 u32 num_luns;
345 u32 luns[8]; /* Max LUNs is 256 */ 347 u32 luns[8]; /* Max LUNs is 256 */
346} VirtTarget; 348} VirtTarget;
@@ -361,6 +363,7 @@ typedef struct _VirtDevice {
361#define MPT_TARGET_FLAGS_VALID_56 0x10 363#define MPT_TARGET_FLAGS_VALID_56 0x10
362#define MPT_TARGET_FLAGS_SAF_TE_ISSUED 0x20 364#define MPT_TARGET_FLAGS_SAF_TE_ISSUED 0x20
363#define MPT_TARGET_FLAGS_RAID_COMPONENT 0x40 365#define MPT_TARGET_FLAGS_RAID_COMPONENT 0x40
366#define MPT_TARGET_FLAGS_LED_ON 0x80
364 367
365/* 368/*
366 * /proc/mpt interface 369 * /proc/mpt interface
@@ -629,15 +632,14 @@ typedef struct _MPT_ADAPTER
629 struct mutex sas_discovery_mutex; 632 struct mutex sas_discovery_mutex;
630 u8 sas_discovery_runtime; 633 u8 sas_discovery_runtime;
631 u8 sas_discovery_ignore_events; 634 u8 sas_discovery_ignore_events;
635 u16 handle;
632 int sas_index; /* index refrencing */ 636 int sas_index; /* index refrencing */
633 MPT_SAS_MGMT sas_mgmt; 637 MPT_SAS_MGMT sas_mgmt;
634 int num_ports; 638 struct work_struct sas_persist_task;
635 struct work_struct mptscsih_persistTask;
636 639
637 struct work_struct fc_setup_reset_work; 640 struct work_struct fc_setup_reset_work;
638 struct list_head fc_rports; 641 struct list_head fc_rports;
639 spinlock_t fc_rescan_work_lock; 642 spinlock_t fc_rescan_work_lock;
640 int fc_rescan_work_count;
641 struct work_struct fc_rescan_work; 643 struct work_struct fc_rescan_work;
642 char fc_rescan_work_q_name[KOBJ_NAME_LEN]; 644 char fc_rescan_work_q_name[KOBJ_NAME_LEN];
643 struct workqueue_struct *fc_rescan_work_q; 645 struct workqueue_struct *fc_rescan_work_q;
@@ -892,6 +894,13 @@ typedef struct _mpt_sge {
892#define DBG_DUMP_REQUEST_FRAME_HDR(mfp) 894#define DBG_DUMP_REQUEST_FRAME_HDR(mfp)
893#endif 895#endif
894 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
895 904
896/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 905/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
897 906
@@ -971,7 +980,7 @@ typedef struct _MPT_SCSI_HOST {
971 wait_queue_head_t scandv_waitq; 980 wait_queue_head_t scandv_waitq;
972 int scandv_wait_done; 981 int scandv_wait_done;
973 long last_queue_full; 982 long last_queue_full;
974 u8 mpt_pq_filter; 983 u16 tm_iocstatus;
975} MPT_SCSI_HOST; 984} MPT_SCSI_HOST;
976 985
977/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 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 3ff8378ea660..85696f34c310 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};
@@ -513,8 +509,7 @@ mptfc_slave_alloc(struct scsi_device *sdev)
513 509
514 if (vtarget->num_luns == 0) { 510 if (vtarget->num_luns == 0) {
515 vtarget->ioc_id = hd->ioc->id; 511 vtarget->ioc_id = hd->ioc->id;
516 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES | 512 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES;
517 MPT_TARGET_FLAGS_VALID_INQUIRY;
518 hd->Targets[sdev->id] = vtarget; 513 hd->Targets[sdev->id] = vtarget;
519 } 514 }
520 515
@@ -674,7 +669,10 @@ mptfc_GetFcPortPage0(MPT_ADAPTER *ioc, int portnum)
674 * if still doing discovery, 669 * if still doing discovery,
675 * hang loose a while until finished 670 * hang loose a while until finished
676 */ 671 */
677 if (pp0dest->PortState == MPI_FCPORTPAGE0_PORTSTATE_UNKNOWN) { 672 if ((pp0dest->PortState == MPI_FCPORTPAGE0_PORTSTATE_UNKNOWN) ||
673 (pp0dest->PortState == MPI_FCPORTPAGE0_PORTSTATE_ONLINE &&
674 (pp0dest->Flags & MPI_FCPORTPAGE0_FLAGS_ATTACH_TYPE_MASK)
675 == MPI_FCPORTPAGE0_FLAGS_ATTACH_NO_INIT)) {
678 if (count-- > 0) { 676 if (count-- > 0) {
679 msleep(100); 677 msleep(100);
680 goto try_again; 678 goto try_again;
@@ -900,59 +898,45 @@ mptfc_rescan_devices(void *arg)
900{ 898{
901 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; 899 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg;
902 int ii; 900 int ii;
903 int work_to_do;
904 u64 pn; 901 u64 pn;
905 unsigned long flags;
906 struct mptfc_rport_info *ri; 902 struct mptfc_rport_info *ri;
907 903
908 do { 904 /* start by tagging all ports as missing */
909 /* start by tagging all ports as missing */ 905 list_for_each_entry(ri, &ioc->fc_rports, list) {
910 list_for_each_entry(ri, &ioc->fc_rports, list) { 906 if (ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED) {
911 if (ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED) { 907 ri->flags |= MPT_RPORT_INFO_FLAGS_MISSING;
912 ri->flags |= MPT_RPORT_INFO_FLAGS_MISSING;
913 }
914 } 908 }
909 }
915 910
916 /* 911 /*
917 * now rescan devices known to adapter, 912 * now rescan devices known to adapter,
918 * will reregister existing rports 913 * will reregister existing rports
919 */ 914 */
920 for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) { 915 for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) {
921 (void) mptfc_GetFcPortPage0(ioc, ii); 916 (void) mptfc_GetFcPortPage0(ioc, ii);
922 mptfc_init_host_attr(ioc,ii); /* refresh */ 917 mptfc_init_host_attr(ioc, ii); /* refresh */
923 mptfc_GetFcDevPage0(ioc,ii,mptfc_register_dev); 918 mptfc_GetFcDevPage0(ioc, ii, mptfc_register_dev);
924 } 919 }
925 920
926 /* delete devices still missing */ 921 /* delete devices still missing */
927 list_for_each_entry(ri, &ioc->fc_rports, list) { 922 list_for_each_entry(ri, &ioc->fc_rports, list) {
928 /* if newly missing, delete it */ 923 /* if newly missing, delete it */
929 if (ri->flags & MPT_RPORT_INFO_FLAGS_MISSING) { 924 if (ri->flags & MPT_RPORT_INFO_FLAGS_MISSING) {
930 925
931 ri->flags &= ~(MPT_RPORT_INFO_FLAGS_REGISTERED| 926 ri->flags &= ~(MPT_RPORT_INFO_FLAGS_REGISTERED|
932 MPT_RPORT_INFO_FLAGS_MISSING); 927 MPT_RPORT_INFO_FLAGS_MISSING);
933 fc_remote_port_delete(ri->rport); /* won't sleep */ 928 fc_remote_port_delete(ri->rport); /* won't sleep */
934 ri->rport = NULL; 929 ri->rport = NULL;
935 930
936 pn = (u64)ri->pg0.WWPN.High << 32 | 931 pn = (u64)ri->pg0.WWPN.High << 32 |
937 (u64)ri->pg0.WWPN.Low; 932 (u64)ri->pg0.WWPN.Low;
938 dfcprintk ((MYIOC_s_INFO_FMT 933 dfcprintk ((MYIOC_s_INFO_FMT
939 "mptfc_rescan.%d: %llx deleted\n", 934 "mptfc_rescan.%d: %llx deleted\n",
940 ioc->name, 935 ioc->name,
941 ioc->sh->host_no, 936 ioc->sh->host_no,
942 (unsigned long long)pn)); 937 (unsigned long long)pn));
943 }
944 } 938 }
945 939 }
946 /*
947 * allow multiple passes as target state
948 * might have changed during scan
949 */
950 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);
951 if (ioc->fc_rescan_work_count > 2) /* only need one more */
952 ioc->fc_rescan_work_count = 2;
953 work_to_do = --ioc->fc_rescan_work_count;
954 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);
955 } while (work_to_do);
956} 940}
957 941
958static int 942static int
@@ -1129,13 +1113,6 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1129 hd->timer.data = (unsigned long) hd; 1113 hd->timer.data = (unsigned long) hd;
1130 hd->timer.function = mptscsih_timer_expired; 1114 hd->timer.function = mptscsih_timer_expired;
1131 1115
1132 hd->mpt_pq_filter = mpt_pq_filter;
1133
1134 ddvprintk((MYIOC_s_INFO_FMT
1135 "mpt_pq_filter %x\n",
1136 ioc->name,
1137 mpt_pq_filter));
1138
1139 init_waitqueue_head(&hd->scandv_waitq); 1116 init_waitqueue_head(&hd->scandv_waitq);
1140 hd->scandv_wait_done = 0; 1117 hd->scandv_wait_done = 0;
1141 hd->last_queue_full = 0; 1118 hd->last_queue_full = 0;
@@ -1171,7 +1148,6 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1171 * by doing it via the workqueue, some locking is eliminated 1148 * by doing it via the workqueue, some locking is eliminated
1172 */ 1149 */
1173 1150
1174 ioc->fc_rescan_work_count = 1;
1175 queue_work(ioc->fc_rescan_work_q, &ioc->fc_rescan_work); 1151 queue_work(ioc->fc_rescan_work_q, &ioc->fc_rescan_work);
1176 flush_workqueue(ioc->fc_rescan_work_q); 1152 flush_workqueue(ioc->fc_rescan_work_q);
1177 1153
@@ -1214,10 +1190,8 @@ mptfc_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
1214 case MPI_EVENT_RESCAN: 1190 case MPI_EVENT_RESCAN:
1215 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags); 1191 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);
1216 if (ioc->fc_rescan_work_q) { 1192 if (ioc->fc_rescan_work_q) {
1217 if (ioc->fc_rescan_work_count++ == 0) { 1193 queue_work(ioc->fc_rescan_work_q,
1218 queue_work(ioc->fc_rescan_work_q, 1194 &ioc->fc_rescan_work);
1219 &ioc->fc_rescan_work);
1220 }
1221 } 1195 }
1222 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); 1196 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);
1223 break; 1197 break;
@@ -1260,10 +1234,8 @@ mptfc_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
1260 mptfc_SetFcPortPage1_defaults(ioc); 1234 mptfc_SetFcPortPage1_defaults(ioc);
1261 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags); 1235 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);
1262 if (ioc->fc_rescan_work_q) { 1236 if (ioc->fc_rescan_work_q) {
1263 if (ioc->fc_rescan_work_count++ == 0) { 1237 queue_work(ioc->fc_rescan_work_q,
1264 queue_work(ioc->fc_rescan_work_q, 1238 &ioc->fc_rescan_work);
1265 &ioc->fc_rescan_work);
1266 }
1267 } 1239 }
1268 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); 1240 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);
1269 } 1241 }
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 85689ab46cbc..f66f2203143a 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
490 /*
491 * Issue target reset to flush firmware outstanding commands.
492 */
493 vdev = sdev->hostdata;
494 if (vdev->configured_lun){
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 808
510 hd->tmPending = 0; 809// scsi_print_command(SCpnt);
511 hd->tmState = TM_STATE_NONE; 810 if (vdev->vtarget->deleted) {
512 } 811 SCpnt->result = DID_NO_CONNECT << 16;
812 done(SCpnt);
813 return 0;
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,
@@ -795,7 +1098,7 @@ mptsas_sas_io_unit_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
795 1098
796 port_info->num_phys = buffer->NumPhys; 1099 port_info->num_phys = buffer->NumPhys;
797 port_info->phy_info = kcalloc(port_info->num_phys, 1100 port_info->phy_info = kcalloc(port_info->num_phys,
798 sizeof(struct mptsas_phyinfo),GFP_KERNEL); 1101 sizeof(*port_info->phy_info),GFP_KERNEL);
799 if (!port_info->phy_info) { 1102 if (!port_info->phy_info) {
800 error = -ENOMEM; 1103 error = -ENOMEM;
801 goto out_free_consistent; 1104 goto out_free_consistent;
@@ -811,6 +1114,7 @@ mptsas_sas_io_unit_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
811 buffer->PhyData[i].Port; 1114 buffer->PhyData[i].Port;
812 port_info->phy_info[i].negotiated_link_rate = 1115 port_info->phy_info[i].negotiated_link_rate =
813 buffer->PhyData[i].NegotiatedLinkRate; 1116 buffer->PhyData[i].NegotiatedLinkRate;
1117 port_info->phy_info[i].portinfo = port_info;
814 } 1118 }
815 1119
816 out_free_consistent: 1120 out_free_consistent:
@@ -968,7 +1272,7 @@ mptsas_sas_expander_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info,
968 CONFIGPARMS cfg; 1272 CONFIGPARMS cfg;
969 SasExpanderPage0_t *buffer; 1273 SasExpanderPage0_t *buffer;
970 dma_addr_t dma_handle; 1274 dma_addr_t dma_handle;
971 int error; 1275 int i, error;
972 1276
973 hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION; 1277 hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION;
974 hdr.ExtPageLength = 0; 1278 hdr.ExtPageLength = 0;
@@ -1013,12 +1317,15 @@ mptsas_sas_expander_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info,
1013 port_info->num_phys = buffer->NumPhys; 1317 port_info->num_phys = buffer->NumPhys;
1014 port_info->handle = le16_to_cpu(buffer->DevHandle); 1318 port_info->handle = le16_to_cpu(buffer->DevHandle);
1015 port_info->phy_info = kcalloc(port_info->num_phys, 1319 port_info->phy_info = kcalloc(port_info->num_phys,
1016 sizeof(struct mptsas_phyinfo),GFP_KERNEL); 1320 sizeof(*port_info->phy_info),GFP_KERNEL);
1017 if (!port_info->phy_info) { 1321 if (!port_info->phy_info) {
1018 error = -ENOMEM; 1322 error = -ENOMEM;
1019 goto out_free_consistent; 1323 goto out_free_consistent;
1020 } 1324 }
1021 1325
1326 for (i = 0; i < port_info->num_phys; i++)
1327 port_info->phy_info[i].portinfo = port_info;
1328
1022 out_free_consistent: 1329 out_free_consistent:
1023 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4, 1330 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
1024 buffer, dma_handle); 1331 buffer, dma_handle);
@@ -1161,19 +1468,23 @@ static int mptsas_probe_one_phy(struct device *dev,
1161{ 1468{
1162 MPT_ADAPTER *ioc; 1469 MPT_ADAPTER *ioc;
1163 struct sas_phy *phy; 1470 struct sas_phy *phy;
1164 int error; 1471 struct sas_port *port;
1472 int error = 0;
1165 1473
1166 if (!dev) 1474 if (!dev) {
1167 return -ENODEV; 1475 error = -ENODEV;
1476 goto out;
1477 }
1168 1478
1169 if (!phy_info->phy) { 1479 if (!phy_info->phy) {
1170 phy = sas_phy_alloc(dev, index); 1480 phy = sas_phy_alloc(dev, index);
1171 if (!phy) 1481 if (!phy) {
1172 return -ENOMEM; 1482 error = -ENOMEM;
1483 goto out;
1484 }
1173 } else 1485 } else
1174 phy = phy_info->phy; 1486 phy = phy_info->phy;
1175 1487
1176 phy->port_identifier = phy_info->port_id;
1177 mptsas_parse_device_info(&phy->identify, &phy_info->identify); 1488 mptsas_parse_device_info(&phy->identify, &phy_info->identify);
1178 1489
1179 /* 1490 /*
@@ -1265,19 +1576,51 @@ static int mptsas_probe_one_phy(struct device *dev,
1265 error = sas_phy_add(phy); 1576 error = sas_phy_add(phy);
1266 if (error) { 1577 if (error) {
1267 sas_phy_free(phy); 1578 sas_phy_free(phy);
1268 return error; 1579 goto out;
1269 } 1580 }
1270 phy_info->phy = phy; 1581 phy_info->phy = phy;
1271 } 1582 }
1272 1583
1273 if ((phy_info->attached.handle) && 1584 if (!phy_info->attached.handle ||
1274 (!phy_info->rphy)) { 1585 !phy_info->port_details)
1586 goto out;
1587
1588 port = mptsas_get_port(phy_info);
1589 ioc = phy_to_ioc(phy_info->phy);
1590
1591 if (phy_info->sas_port_add_phy) {
1592
1593 if (!port) {
1594 port = sas_port_alloc_num(dev);
1595 if (!port) {
1596 error = -ENOMEM;
1597 goto out;
1598 }
1599 error = sas_port_add(port);
1600 if (error) {
1601 dfailprintk((MYIOC_s_ERR_FMT
1602 "%s: exit at line=%d\n", ioc->name,
1603 __FUNCTION__, __LINE__));
1604 goto out;
1605 }
1606 mptsas_set_port(phy_info, port);
1607 dsaswideprintk((KERN_DEBUG
1608 "sas_port_alloc: port=%p dev=%p port_id=%d\n",
1609 port, dev, port->port_identifier));
1610 }
1611 dsaswideprintk((KERN_DEBUG "sas_port_add_phy: phy_id=%d\n",
1612 phy_info->phy_id));
1613 sas_port_add_phy(port, phy_info->phy);
1614 phy_info->sas_port_add_phy = 0;
1615 }
1616
1617 if (!mptsas_get_rphy(phy_info) && port && !port->rphy) {
1275 1618
1276 struct sas_rphy *rphy; 1619 struct sas_rphy *rphy;
1620 struct device *parent;
1277 struct sas_identify identify; 1621 struct sas_identify identify;
1278 1622
1279 ioc = phy_to_ioc(phy_info->phy); 1623 parent = dev->parent->parent;
1280
1281 /* 1624 /*
1282 * Let the hotplug_work thread handle processing 1625 * Let the hotplug_work thread handle processing
1283 * the adding/removing of devices that occur 1626 * the adding/removing of devices that occur
@@ -1285,36 +1628,63 @@ static int mptsas_probe_one_phy(struct device *dev,
1285 */ 1628 */
1286 if (ioc->sas_discovery_runtime && 1629 if (ioc->sas_discovery_runtime &&
1287 mptsas_is_end_device(&phy_info->attached)) 1630 mptsas_is_end_device(&phy_info->attached))
1288 return 0; 1631 goto out;
1289 1632
1290 mptsas_parse_device_info(&identify, &phy_info->attached); 1633 mptsas_parse_device_info(&identify, &phy_info->attached);
1634 if (scsi_is_host_device(parent)) {
1635 struct mptsas_portinfo *port_info;
1636 int i;
1637
1638 mutex_lock(&ioc->sas_topology_mutex);
1639 port_info = mptsas_find_portinfo_by_handle(ioc,
1640 ioc->handle);
1641 mutex_unlock(&ioc->sas_topology_mutex);
1642
1643 for (i = 0; i < port_info->num_phys; i++)
1644 if (port_info->phy_info[i].identify.sas_address ==
1645 identify.sas_address)
1646 goto out;
1647
1648 } else if (scsi_is_sas_rphy(parent)) {
1649 struct sas_rphy *parent_rphy = dev_to_rphy(parent);
1650 if (identify.sas_address ==
1651 parent_rphy->identify.sas_address)
1652 goto out;
1653 }
1654
1291 switch (identify.device_type) { 1655 switch (identify.device_type) {
1292 case SAS_END_DEVICE: 1656 case SAS_END_DEVICE:
1293 rphy = sas_end_device_alloc(phy); 1657 rphy = sas_end_device_alloc(port);
1294 break; 1658 break;
1295 case SAS_EDGE_EXPANDER_DEVICE: 1659 case SAS_EDGE_EXPANDER_DEVICE:
1296 case SAS_FANOUT_EXPANDER_DEVICE: 1660 case SAS_FANOUT_EXPANDER_DEVICE:
1297 rphy = sas_expander_alloc(phy, identify.device_type); 1661 rphy = sas_expander_alloc(port, identify.device_type);
1298 break; 1662 break;
1299 default: 1663 default:
1300 rphy = NULL; 1664 rphy = NULL;
1301 break; 1665 break;
1302 } 1666 }
1303 if (!rphy) 1667 if (!rphy) {
1304 return 0; /* non-fatal: an rphy can be added later */ 1668 dfailprintk((MYIOC_s_ERR_FMT
1669 "%s: exit at line=%d\n", ioc->name,
1670 __FUNCTION__, __LINE__));
1671 goto out;
1672 }
1305 1673
1306 rphy->identify = identify; 1674 rphy->identify = identify;
1307
1308 error = sas_rphy_add(rphy); 1675 error = sas_rphy_add(rphy);
1309 if (error) { 1676 if (error) {
1677 dfailprintk((MYIOC_s_ERR_FMT
1678 "%s: exit at line=%d\n", ioc->name,
1679 __FUNCTION__, __LINE__));
1310 sas_rphy_free(rphy); 1680 sas_rphy_free(rphy);
1311 return error; 1681 goto out;
1312 } 1682 }
1313 1683 mptsas_set_rphy(phy_info, rphy);
1314 phy_info->rphy = rphy;
1315 } 1684 }
1316 1685
1317 return 0; 1686 out:
1687 return error;
1318} 1688}
1319 1689
1320static int 1690static int
@@ -1333,6 +1703,7 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc)
1333 goto out_free_port_info; 1703 goto out_free_port_info;
1334 1704
1335 mutex_lock(&ioc->sas_topology_mutex); 1705 mutex_lock(&ioc->sas_topology_mutex);
1706 ioc->handle = hba->handle;
1336 port_info = mptsas_find_portinfo_by_handle(ioc, hba->handle); 1707 port_info = mptsas_find_portinfo_by_handle(ioc, hba->handle);
1337 if (!port_info) { 1708 if (!port_info) {
1338 port_info = hba; 1709 port_info = hba;
@@ -1342,13 +1713,11 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc)
1342 for (i = 0; i < hba->num_phys; i++) 1713 for (i = 0; i < hba->num_phys; i++)
1343 port_info->phy_info[i].negotiated_link_rate = 1714 port_info->phy_info[i].negotiated_link_rate =
1344 hba->phy_info[i].negotiated_link_rate; 1715 hba->phy_info[i].negotiated_link_rate;
1345 if (hba->phy_info) 1716 kfree(hba->phy_info);
1346 kfree(hba->phy_info);
1347 kfree(hba); 1717 kfree(hba);
1348 hba = NULL; 1718 hba = NULL;
1349 } 1719 }
1350 mutex_unlock(&ioc->sas_topology_mutex); 1720 mutex_unlock(&ioc->sas_topology_mutex);
1351 ioc->num_ports = port_info->num_phys;
1352 1721
1353 for (i = 0; i < port_info->num_phys; i++) { 1722 for (i = 0; i < port_info->num_phys; i++) {
1354 mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i], 1723 mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i],
@@ -1362,18 +1731,19 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc)
1362 port_info->phy_info[i].phy_id; 1731 port_info->phy_info[i].phy_id;
1363 handle = port_info->phy_info[i].identify.handle; 1732 handle = port_info->phy_info[i].identify.handle;
1364 1733
1365 if (port_info->phy_info[i].attached.handle) { 1734 if (port_info->phy_info[i].attached.handle)
1366 mptsas_sas_device_pg0(ioc, 1735 mptsas_sas_device_pg0(ioc,
1367 &port_info->phy_info[i].attached, 1736 &port_info->phy_info[i].attached,
1368 (MPI_SAS_DEVICE_PGAD_FORM_HANDLE << 1737 (MPI_SAS_DEVICE_PGAD_FORM_HANDLE <<
1369 MPI_SAS_DEVICE_PGAD_FORM_SHIFT), 1738 MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
1370 port_info->phy_info[i].attached.handle); 1739 port_info->phy_info[i].attached.handle);
1371 } 1740 }
1372 1741
1742 mptsas_setup_wide_ports(ioc, port_info);
1743
1744 for (i = 0; i < port_info->num_phys; i++, ioc->sas_index++)
1373 mptsas_probe_one_phy(&ioc->sh->shost_gendev, 1745 mptsas_probe_one_phy(&ioc->sh->shost_gendev,
1374 &port_info->phy_info[i], ioc->sas_index, 1); 1746 &port_info->phy_info[i], ioc->sas_index, 1);
1375 ioc->sas_index++;
1376 }
1377 1747
1378 return 0; 1748 return 0;
1379 1749
@@ -1387,6 +1757,8 @@ static int
1387mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle) 1757mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle)
1388{ 1758{
1389 struct mptsas_portinfo *port_info, *p, *ex; 1759 struct mptsas_portinfo *port_info, *p, *ex;
1760 struct device *parent;
1761 struct sas_rphy *rphy;
1390 int error = -ENOMEM, i, j; 1762 int error = -ENOMEM, i, j;
1391 1763
1392 ex = kzalloc(sizeof(*port_info), GFP_KERNEL); 1764 ex = kzalloc(sizeof(*port_info), GFP_KERNEL);
@@ -1408,16 +1780,13 @@ mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle)
1408 list_add_tail(&port_info->list, &ioc->sas_topology); 1780 list_add_tail(&port_info->list, &ioc->sas_topology);
1409 } else { 1781 } else {
1410 port_info->handle = ex->handle; 1782 port_info->handle = ex->handle;
1411 if (ex->phy_info) 1783 kfree(ex->phy_info);
1412 kfree(ex->phy_info);
1413 kfree(ex); 1784 kfree(ex);
1414 ex = NULL; 1785 ex = NULL;
1415 } 1786 }
1416 mutex_unlock(&ioc->sas_topology_mutex); 1787 mutex_unlock(&ioc->sas_topology_mutex);
1417 1788
1418 for (i = 0; i < port_info->num_phys; i++) { 1789 for (i = 0; i < port_info->num_phys; i++) {
1419 struct device *parent;
1420
1421 mptsas_sas_expander_pg1(ioc, &port_info->phy_info[i], 1790 mptsas_sas_expander_pg1(ioc, &port_info->phy_info[i],
1422 (MPI_SAS_EXPAND_PGAD_FORM_HANDLE_PHY_NUM << 1791 (MPI_SAS_EXPAND_PGAD_FORM_HANDLE_PHY_NUM <<
1423 MPI_SAS_EXPAND_PGAD_FORM_SHIFT), (i << 16) + *handle); 1792 MPI_SAS_EXPAND_PGAD_FORM_SHIFT), (i << 16) + *handle);
@@ -1441,34 +1810,34 @@ mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle)
1441 port_info->phy_info[i].attached.phy_id = 1810 port_info->phy_info[i].attached.phy_id =
1442 port_info->phy_info[i].phy_id; 1811 port_info->phy_info[i].phy_id;
1443 } 1812 }
1813 }
1444 1814
1445 /* 1815 parent = &ioc->sh->shost_gendev;
1446 * If we find a parent port handle this expander is 1816 for (i = 0; i < port_info->num_phys; i++) {
1447 * attached to another expander, else it hangs of the
1448 * HBA phys.
1449 */
1450 parent = &ioc->sh->shost_gendev;
1451 mutex_lock(&ioc->sas_topology_mutex); 1817 mutex_lock(&ioc->sas_topology_mutex);
1452 list_for_each_entry(p, &ioc->sas_topology, list) { 1818 list_for_each_entry(p, &ioc->sas_topology, list) {
1453 for (j = 0; j < p->num_phys; j++) { 1819 for (j = 0; j < p->num_phys; j++) {
1454 if (port_info->phy_info[i].identify.handle == 1820 if (port_info->phy_info[i].identify.handle !=
1455 p->phy_info[j].attached.handle) 1821 p->phy_info[j].attached.handle)
1456 parent = &p->phy_info[j].rphy->dev; 1822 continue;
1823 rphy = mptsas_get_rphy(&p->phy_info[j]);
1824 parent = &rphy->dev;
1457 } 1825 }
1458 } 1826 }
1459 mutex_unlock(&ioc->sas_topology_mutex); 1827 mutex_unlock(&ioc->sas_topology_mutex);
1828 }
1460 1829
1830 mptsas_setup_wide_ports(ioc, port_info);
1831
1832 for (i = 0; i < port_info->num_phys; i++, ioc->sas_index++)
1461 mptsas_probe_one_phy(parent, &port_info->phy_info[i], 1833 mptsas_probe_one_phy(parent, &port_info->phy_info[i],
1462 ioc->sas_index, 0); 1834 ioc->sas_index, 0);
1463 ioc->sas_index++;
1464 }
1465 1835
1466 return 0; 1836 return 0;
1467 1837
1468 out_free_port_info: 1838 out_free_port_info:
1469 if (ex) { 1839 if (ex) {
1470 if (ex->phy_info) 1840 kfree(ex->phy_info);
1471 kfree(ex->phy_info);
1472 kfree(ex); 1841 kfree(ex);
1473 } 1842 }
1474 out: 1843 out:
@@ -1487,7 +1856,12 @@ mptsas_delete_expander_phys(MPT_ADAPTER *ioc)
1487{ 1856{
1488 struct mptsas_portinfo buffer; 1857 struct mptsas_portinfo buffer;
1489 struct mptsas_portinfo *port_info, *n, *parent; 1858 struct mptsas_portinfo *port_info, *n, *parent;
1859 struct mptsas_phyinfo *phy_info;
1860 struct scsi_target * starget;
1861 VirtTarget * vtarget;
1862 struct sas_port * port;
1490 int i; 1863 int i;
1864 u64 expander_sas_address;
1491 1865
1492 mutex_lock(&ioc->sas_topology_mutex); 1866 mutex_lock(&ioc->sas_topology_mutex);
1493 list_for_each_entry_safe(port_info, n, &ioc->sas_topology, list) { 1867 list_for_each_entry_safe(port_info, n, &ioc->sas_topology, list) {
@@ -1502,6 +1876,25 @@ mptsas_delete_expander_phys(MPT_ADAPTER *ioc)
1502 MPI_SAS_EXPAND_PGAD_FORM_SHIFT), port_info->handle)) { 1876 MPI_SAS_EXPAND_PGAD_FORM_SHIFT), port_info->handle)) {
1503 1877
1504 /* 1878 /*
1879 * Issue target reset to all child end devices
1880 * then mark them deleted to prevent further
1881 * IO going to them.
1882 */
1883 phy_info = port_info->phy_info;
1884 for (i = 0; i < port_info->num_phys; i++, phy_info++) {
1885 starget = mptsas_get_starget(phy_info);
1886 if (!starget)
1887 continue;
1888 vtarget = starget->hostdata;
1889 if(vtarget->deleted)
1890 continue;
1891 vtarget->deleted = 1;
1892 mptsas_target_reset(ioc, vtarget);
1893 sas_port_delete(mptsas_get_port(phy_info));
1894 mptsas_port_delete(phy_info->port_details);
1895 }
1896
1897 /*
1505 * Obtain the port_info instance to the parent port 1898 * Obtain the port_info instance to the parent port
1506 */ 1899 */
1507 parent = mptsas_find_portinfo_by_handle(ioc, 1900 parent = mptsas_find_portinfo_by_handle(ioc,
@@ -1510,34 +1903,44 @@ mptsas_delete_expander_phys(MPT_ADAPTER *ioc)
1510 if (!parent) 1903 if (!parent)
1511 goto next_port; 1904 goto next_port;
1512 1905
1906 expander_sas_address =
1907 port_info->phy_info[0].identify.sas_address;
1908
1513 /* 1909 /*
1514 * Delete rphys in the parent that point 1910 * Delete rphys in the parent that point
1515 * to this expander. The transport layer will 1911 * to this expander. The transport layer will
1516 * cleanup all the children. 1912 * cleanup all the children.
1517 */ 1913 */
1518 for (i = 0; i < parent->num_phys; i++) { 1914 phy_info = parent->phy_info;
1519 if ((!parent->phy_info[i].rphy) || 1915 for (i = 0; i < parent->num_phys; i++, phy_info++) {
1520 (parent->phy_info[i].attached.sas_address != 1916 port = mptsas_get_port(phy_info);
1521 port_info->phy_info[i].identify.sas_address)) 1917 if (!port)
1522 continue; 1918 continue;
1523 sas_rphy_delete(parent->phy_info[i].rphy); 1919 if (phy_info->attached.sas_address !=
1524 memset(&parent->phy_info[i].attached, 0, 1920 expander_sas_address)
1525 sizeof(struct mptsas_devinfo)); 1921 continue;
1526 parent->phy_info[i].rphy = NULL; 1922#ifdef MPT_DEBUG_SAS_WIDE
1527 parent->phy_info[i].starget = NULL; 1923 dev_printk(KERN_DEBUG, &port->dev,
1924 "delete port (%d)\n", port->port_identifier);
1925#endif
1926 sas_port_delete(port);
1927 mptsas_port_delete(phy_info->port_details);
1528 } 1928 }
1529 next_port: 1929 next_port:
1930
1931 phy_info = port_info->phy_info;
1932 for (i = 0; i < port_info->num_phys; i++, phy_info++)
1933 mptsas_port_delete(phy_info->port_details);
1934
1530 list_del(&port_info->list); 1935 list_del(&port_info->list);
1531 if (port_info->phy_info) 1936 kfree(port_info->phy_info);
1532 kfree(port_info->phy_info);
1533 kfree(port_info); 1937 kfree(port_info);
1534 } 1938 }
1535 /* 1939 /*
1536 * Free this memory allocated from inside 1940 * Free this memory allocated from inside
1537 * mptsas_sas_expander_pg0 1941 * mptsas_sas_expander_pg0
1538 */ 1942 */
1539 if (buffer.phy_info) 1943 kfree(buffer.phy_info);
1540 kfree(buffer.phy_info);
1541 } 1944 }
1542 mutex_unlock(&ioc->sas_topology_mutex); 1945 mutex_unlock(&ioc->sas_topology_mutex);
1543} 1946}
@@ -1563,7 +1966,7 @@ mptsas_scan_sas_topology(MPT_ADAPTER *ioc)
1563 if (!ioc->raid_data.pIocPg2->NumActiveVolumes) 1966 if (!ioc->raid_data.pIocPg2->NumActiveVolumes)
1564 goto out; 1967 goto out;
1565 for (i=0; i<ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { 1968 for (i=0; i<ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
1566 scsi_add_device(ioc->sh, ioc->num_ports, 1969 scsi_add_device(ioc->sh, MPTSAS_RAID_CHANNEL,
1567 ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0); 1970 ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0);
1568 } 1971 }
1569 out: 1972 out:
@@ -1573,60 +1976,59 @@ mptsas_scan_sas_topology(MPT_ADAPTER *ioc)
1573/* 1976/*
1574 * Work queue thread to handle Runtime discovery 1977 * Work queue thread to handle Runtime discovery
1575 * Mere purpose is the hot add/delete of expanders 1978 * Mere purpose is the hot add/delete of expanders
1979 *(Mutex UNLOCKED)
1576 */ 1980 */
1577static void 1981static void
1578mptscsih_discovery_work(void * arg) 1982__mptsas_discovery_work(MPT_ADAPTER *ioc)
1579{ 1983{
1580 struct mptsas_discovery_event *ev = arg;
1581 MPT_ADAPTER *ioc = ev->ioc;
1582 u32 handle = 0xFFFF; 1984 u32 handle = 0xFFFF;
1583 1985
1584 mutex_lock(&ioc->sas_discovery_mutex);
1585 ioc->sas_discovery_runtime=1; 1986 ioc->sas_discovery_runtime=1;
1586 mptsas_delete_expander_phys(ioc); 1987 mptsas_delete_expander_phys(ioc);
1587 mptsas_probe_hba_phys(ioc); 1988 mptsas_probe_hba_phys(ioc);
1588 while (!mptsas_probe_expander_phys(ioc, &handle)) 1989 while (!mptsas_probe_expander_phys(ioc, &handle))
1589 ; 1990 ;
1590 kfree(ev);
1591 ioc->sas_discovery_runtime=0; 1991 ioc->sas_discovery_runtime=0;
1992}
1993
1994/*
1995 * Work queue thread to handle Runtime discovery
1996 * Mere purpose is the hot add/delete of expanders
1997 *(Mutex LOCKED)
1998 */
1999static void
2000mptsas_discovery_work(void * arg)
2001{
2002 struct mptsas_discovery_event *ev = arg;
2003 MPT_ADAPTER *ioc = ev->ioc;
2004
2005 mutex_lock(&ioc->sas_discovery_mutex);
2006 __mptsas_discovery_work(ioc);
1592 mutex_unlock(&ioc->sas_discovery_mutex); 2007 mutex_unlock(&ioc->sas_discovery_mutex);
2008 kfree(ev);
1593} 2009}
1594 2010
1595static struct mptsas_phyinfo * 2011static struct mptsas_phyinfo *
1596mptsas_find_phyinfo_by_parent(MPT_ADAPTER *ioc, u16 parent_handle, u8 phy_id) 2012mptsas_find_phyinfo_by_sas_address(MPT_ADAPTER *ioc, u64 sas_address)
1597{ 2013{
1598 struct mptsas_portinfo *port_info; 2014 struct mptsas_portinfo *port_info;
1599 struct mptsas_devinfo device_info;
1600 struct mptsas_phyinfo *phy_info = NULL; 2015 struct mptsas_phyinfo *phy_info = NULL;
1601 int i, error; 2016 int i;
1602
1603 /*
1604 * Retrieve the parent sas_address
1605 */
1606 error = mptsas_sas_device_pg0(ioc, &device_info,
1607 (MPI_SAS_DEVICE_PGAD_FORM_HANDLE <<
1608 MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
1609 parent_handle);
1610 if (error)
1611 return NULL;
1612 2017
1613 /*
1614 * The phy_info structures are never deallocated during lifetime of
1615 * a host, so the code below is safe without additional refcounting.
1616 */
1617 mutex_lock(&ioc->sas_topology_mutex); 2018 mutex_lock(&ioc->sas_topology_mutex);
1618 list_for_each_entry(port_info, &ioc->sas_topology, list) { 2019 list_for_each_entry(port_info, &ioc->sas_topology, list) {
1619 for (i = 0; i < port_info->num_phys; i++) { 2020 for (i = 0; i < port_info->num_phys; i++) {
1620 if (port_info->phy_info[i].identify.sas_address == 2021 if (port_info->phy_info[i].attached.sas_address
1621 device_info.sas_address && 2022 != sas_address)
1622 port_info->phy_info[i].phy_id == phy_id) { 2023 continue;
1623 phy_info = &port_info->phy_info[i]; 2024 if (!mptsas_is_end_device(
1624 break; 2025 &port_info->phy_info[i].attached))
1625 } 2026 continue;
2027 phy_info = &port_info->phy_info[i];
2028 break;
1626 } 2029 }
1627 } 2030 }
1628 mutex_unlock(&ioc->sas_topology_mutex); 2031 mutex_unlock(&ioc->sas_topology_mutex);
1629
1630 return phy_info; 2032 return phy_info;
1631} 2033}
1632 2034
@@ -1637,21 +2039,19 @@ mptsas_find_phyinfo_by_target(MPT_ADAPTER *ioc, u32 id)
1637 struct mptsas_phyinfo *phy_info = NULL; 2039 struct mptsas_phyinfo *phy_info = NULL;
1638 int i; 2040 int i;
1639 2041
1640 /*
1641 * The phy_info structures are never deallocated during lifetime of
1642 * a host, so the code below is safe without additional refcounting.
1643 */
1644 mutex_lock(&ioc->sas_topology_mutex); 2042 mutex_lock(&ioc->sas_topology_mutex);
1645 list_for_each_entry(port_info, &ioc->sas_topology, list) { 2043 list_for_each_entry(port_info, &ioc->sas_topology, list) {
1646 for (i = 0; i < port_info->num_phys; i++) 2044 for (i = 0; i < port_info->num_phys; i++) {
1647 if (mptsas_is_end_device(&port_info->phy_info[i].attached)) 2045 if (port_info->phy_info[i].attached.id != id)
1648 if (port_info->phy_info[i].attached.id == id) { 2046 continue;
1649 phy_info = &port_info->phy_info[i]; 2047 if (!mptsas_is_end_device(
1650 break; 2048 &port_info->phy_info[i].attached))
1651 } 2049 continue;
2050 phy_info = &port_info->phy_info[i];
2051 break;
2052 }
1652 } 2053 }
1653 mutex_unlock(&ioc->sas_topology_mutex); 2054 mutex_unlock(&ioc->sas_topology_mutex);
1654
1655 return phy_info; 2055 return phy_info;
1656} 2056}
1657 2057
@@ -1659,7 +2059,7 @@ mptsas_find_phyinfo_by_target(MPT_ADAPTER *ioc, u32 id)
1659 * Work queue thread to clear the persitency table 2059 * Work queue thread to clear the persitency table
1660 */ 2060 */
1661static void 2061static void
1662mptscsih_sas_persist_clear_table(void * arg) 2062mptsas_persist_clear_table(void * arg)
1663{ 2063{
1664 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; 2064 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg;
1665 2065
@@ -1680,7 +2080,6 @@ mptsas_reprobe_target(struct scsi_target *starget, int uld_attach)
1680 mptsas_reprobe_lun); 2080 mptsas_reprobe_lun);
1681} 2081}
1682 2082
1683
1684/* 2083/*
1685 * Work queue thread to handle SAS hotplug events 2084 * Work queue thread to handle SAS hotplug events
1686 */ 2085 */
@@ -1691,14 +2090,17 @@ mptsas_hotplug_work(void *arg)
1691 MPT_ADAPTER *ioc = ev->ioc; 2090 MPT_ADAPTER *ioc = ev->ioc;
1692 struct mptsas_phyinfo *phy_info; 2091 struct mptsas_phyinfo *phy_info;
1693 struct sas_rphy *rphy; 2092 struct sas_rphy *rphy;
2093 struct sas_port *port;
1694 struct scsi_device *sdev; 2094 struct scsi_device *sdev;
2095 struct scsi_target * starget;
1695 struct sas_identify identify; 2096 struct sas_identify identify;
1696 char *ds = NULL; 2097 char *ds = NULL;
1697 struct mptsas_devinfo sas_device; 2098 struct mptsas_devinfo sas_device;
1698 VirtTarget *vtarget; 2099 VirtTarget *vtarget;
2100 VirtDevice *vdevice;
1699 2101
1700 mutex_lock(&ioc->sas_discovery_mutex);
1701 2102
2103 mutex_lock(&ioc->sas_discovery_mutex);
1702 switch (ev->event_type) { 2104 switch (ev->event_type) {
1703 case MPTSAS_DEL_DEVICE: 2105 case MPTSAS_DEL_DEVICE:
1704 2106
@@ -1707,24 +2109,50 @@ mptsas_hotplug_work(void *arg)
1707 /* 2109 /*
1708 * Sanity checks, for non-existing phys and remote rphys. 2110 * Sanity checks, for non-existing phys and remote rphys.
1709 */ 2111 */
1710 if (!phy_info) 2112 if (!phy_info || !phy_info->port_details) {
2113 dfailprintk((MYIOC_s_ERR_FMT
2114 "%s: exit at line=%d\n", ioc->name,
2115 __FUNCTION__, __LINE__));
1711 break; 2116 break;
1712 if (!phy_info->rphy) 2117 }
2118 rphy = mptsas_get_rphy(phy_info);
2119 if (!rphy) {
2120 dfailprintk((MYIOC_s_ERR_FMT
2121 "%s: exit at line=%d\n", ioc->name,
2122 __FUNCTION__, __LINE__));
1713 break; 2123 break;
1714 if (phy_info->starget) { 2124 }
1715 vtarget = phy_info->starget->hostdata; 2125 port = mptsas_get_port(phy_info);
2126 if (!port) {
2127 dfailprintk((MYIOC_s_ERR_FMT
2128 "%s: exit at line=%d\n", ioc->name,
2129 __FUNCTION__, __LINE__));
2130 break;
2131 }
1716 2132
1717 if (!vtarget) 2133 starget = mptsas_get_starget(phy_info);
2134 if (starget) {
2135 vtarget = starget->hostdata;
2136
2137 if (!vtarget) {
2138 dfailprintk((MYIOC_s_ERR_FMT
2139 "%s: exit at line=%d\n", ioc->name,
2140 __FUNCTION__, __LINE__));
1718 break; 2141 break;
2142 }
2143
1719 /* 2144 /*
1720 * Handling RAID components 2145 * Handling RAID components
1721 */ 2146 */
1722 if (ev->phys_disk_num_valid) { 2147 if (ev->phys_disk_num_valid) {
1723 vtarget->target_id = ev->phys_disk_num; 2148 vtarget->target_id = ev->phys_disk_num;
1724 vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT; 2149 vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT;
1725 mptsas_reprobe_target(vtarget->starget, 1); 2150 mptsas_reprobe_target(starget, 1);
1726 break; 2151 break;
1727 } 2152 }
2153
2154 vtarget->deleted = 1;
2155 mptsas_target_reset(ioc, vtarget);
1728 } 2156 }
1729 2157
1730 if (phy_info->attached.device_info & MPI_SAS_DEVICE_INFO_SSP_TARGET) 2158 if (phy_info->attached.device_info & MPI_SAS_DEVICE_INFO_SSP_TARGET)
@@ -1738,10 +2166,12 @@ mptsas_hotplug_work(void *arg)
1738 "removing %s device, channel %d, id %d, phy %d\n", 2166 "removing %s device, channel %d, id %d, phy %d\n",
1739 ioc->name, ds, ev->channel, ev->id, phy_info->phy_id); 2167 ioc->name, ds, ev->channel, ev->id, phy_info->phy_id);
1740 2168
1741 sas_rphy_delete(phy_info->rphy); 2169#ifdef MPT_DEBUG_SAS_WIDE
1742 memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo)); 2170 dev_printk(KERN_DEBUG, &port->dev,
1743 phy_info->rphy = NULL; 2171 "delete port (%d)\n", port->port_identifier);
1744 phy_info->starget = NULL; 2172#endif
2173 sas_port_delete(port);
2174 mptsas_port_delete(phy_info->port_details);
1745 break; 2175 break;
1746 case MPTSAS_ADD_DEVICE: 2176 case MPTSAS_ADD_DEVICE:
1747 2177
@@ -1753,59 +2183,60 @@ mptsas_hotplug_work(void *arg)
1753 */ 2183 */
1754 if (mptsas_sas_device_pg0(ioc, &sas_device, 2184 if (mptsas_sas_device_pg0(ioc, &sas_device,
1755 (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID << 2185 (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID <<
1756 MPI_SAS_DEVICE_PGAD_FORM_SHIFT), ev->id)) 2186 MPI_SAS_DEVICE_PGAD_FORM_SHIFT), ev->id)) {
2187 dfailprintk((MYIOC_s_ERR_FMT
2188 "%s: exit at line=%d\n", ioc->name,
2189 __FUNCTION__, __LINE__));
1757 break; 2190 break;
2191 }
1758 2192
1759 phy_info = mptsas_find_phyinfo_by_parent(ioc, 2193 ssleep(2);
1760 sas_device.handle_parent, sas_device.phy_id); 2194 __mptsas_discovery_work(ioc);
1761 2195
1762 if (!phy_info) { 2196 phy_info = mptsas_find_phyinfo_by_sas_address(ioc,
1763 u32 handle = 0xFFFF; 2197 sas_device.sas_address);
1764 2198
1765 /* 2199 if (!phy_info || !phy_info->port_details) {
1766 * Its possible when an expander has been hot added 2200 dfailprintk((MYIOC_s_ERR_FMT
1767 * containing attached devices, the sas firmware 2201 "%s: exit at line=%d\n", ioc->name,
1768 * may send a RC_ADDED event prior to the 2202 __FUNCTION__, __LINE__));
1769 * DISCOVERY STOP event. If that occurs, our 2203 break;
1770 * view of the topology in the driver in respect to this
1771 * expander might of not been setup, and we hit this
1772 * condition.
1773 * Therefore, this code kicks off discovery to
1774 * refresh the data.
1775 * Then again, we check whether the parent phy has
1776 * been created.
1777 */
1778 ioc->sas_discovery_runtime=1;
1779 mptsas_delete_expander_phys(ioc);
1780 mptsas_probe_hba_phys(ioc);
1781 while (!mptsas_probe_expander_phys(ioc, &handle))
1782 ;
1783 ioc->sas_discovery_runtime=0;
1784
1785 phy_info = mptsas_find_phyinfo_by_parent(ioc,
1786 sas_device.handle_parent, sas_device.phy_id);
1787 if (!phy_info)
1788 break;
1789 } 2204 }
1790 2205
1791 if (phy_info->starget) { 2206 starget = mptsas_get_starget(phy_info);
1792 vtarget = phy_info->starget->hostdata; 2207 if (starget) {
2208 vtarget = starget->hostdata;
1793 2209
1794 if (!vtarget) 2210 if (!vtarget) {
2211 dfailprintk((MYIOC_s_ERR_FMT
2212 "%s: exit at line=%d\n", ioc->name,
2213 __FUNCTION__, __LINE__));
1795 break; 2214 break;
2215 }
1796 /* 2216 /*
1797 * Handling RAID components 2217 * Handling RAID components
1798 */ 2218 */
1799 if (vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) { 2219 if (vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) {
1800 vtarget->tflags &= ~MPT_TARGET_FLAGS_RAID_COMPONENT; 2220 vtarget->tflags &= ~MPT_TARGET_FLAGS_RAID_COMPONENT;
1801 vtarget->target_id = ev->id; 2221 vtarget->target_id = ev->id;
1802 mptsas_reprobe_target(phy_info->starget, 0); 2222 mptsas_reprobe_target(starget, 0);
1803 } 2223 }
1804 break; 2224 break;
1805 } 2225 }
1806 2226
1807 if (phy_info->rphy) 2227 if (mptsas_get_rphy(phy_info)) {
2228 dfailprintk((MYIOC_s_ERR_FMT
2229 "%s: exit at line=%d\n", ioc->name,
2230 __FUNCTION__, __LINE__));
2231 break;
2232 }
2233 port = mptsas_get_port(phy_info);
2234 if (!port) {
2235 dfailprintk((MYIOC_s_ERR_FMT
2236 "%s: exit at line=%d\n", ioc->name,
2237 __FUNCTION__, __LINE__));
1808 break; 2238 break;
2239 }
1809 2240
1810 memcpy(&phy_info->attached, &sas_device, 2241 memcpy(&phy_info->attached, &sas_device,
1811 sizeof(struct mptsas_devinfo)); 2242 sizeof(struct mptsas_devinfo));
@@ -1822,59 +2253,48 @@ mptsas_hotplug_work(void *arg)
1822 ioc->name, ds, ev->channel, ev->id, ev->phy_id); 2253 ioc->name, ds, ev->channel, ev->id, ev->phy_id);
1823 2254
1824 mptsas_parse_device_info(&identify, &phy_info->attached); 2255 mptsas_parse_device_info(&identify, &phy_info->attached);
1825 switch (identify.device_type) { 2256 rphy = sas_end_device_alloc(port);
1826 case SAS_END_DEVICE: 2257 if (!rphy) {
1827 rphy = sas_end_device_alloc(phy_info->phy); 2258 dfailprintk((MYIOC_s_ERR_FMT
1828 break; 2259 "%s: exit at line=%d\n", ioc->name,
1829 case SAS_EDGE_EXPANDER_DEVICE: 2260 __FUNCTION__, __LINE__));
1830 case SAS_FANOUT_EXPANDER_DEVICE:
1831 rphy = sas_expander_alloc(phy_info->phy, identify.device_type);
1832 break;
1833 default:
1834 rphy = NULL;
1835 break;
1836 }
1837 if (!rphy)
1838 break; /* non-fatal: an rphy can be added later */ 2261 break; /* non-fatal: an rphy can be added later */
2262 }
1839 2263
1840 rphy->identify = identify; 2264 rphy->identify = identify;
1841 if (sas_rphy_add(rphy)) { 2265 if (sas_rphy_add(rphy)) {
2266 dfailprintk((MYIOC_s_ERR_FMT
2267 "%s: exit at line=%d\n", ioc->name,
2268 __FUNCTION__, __LINE__));
1842 sas_rphy_free(rphy); 2269 sas_rphy_free(rphy);
1843 break; 2270 break;
1844 } 2271 }
1845 2272 mptsas_set_rphy(phy_info, rphy);
1846 phy_info->rphy = rphy;
1847 break; 2273 break;
1848 case MPTSAS_ADD_RAID: 2274 case MPTSAS_ADD_RAID:
1849 sdev = scsi_device_lookup( 2275 sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL,
1850 ioc->sh, 2276 ev->id, 0);
1851 ioc->num_ports,
1852 ev->id,
1853 0);
1854 if (sdev) { 2277 if (sdev) {
1855 scsi_device_put(sdev); 2278 scsi_device_put(sdev);
1856 break; 2279 break;
1857 } 2280 }
1858 printk(MYIOC_s_INFO_FMT 2281 printk(MYIOC_s_INFO_FMT
1859 "attaching raid volume, channel %d, id %d\n", 2282 "attaching raid volume, channel %d, id %d\n",
1860 ioc->name, ioc->num_ports, ev->id); 2283 ioc->name, MPTSAS_RAID_CHANNEL, ev->id);
1861 scsi_add_device(ioc->sh, 2284 scsi_add_device(ioc->sh, MPTSAS_RAID_CHANNEL, ev->id, 0);
1862 ioc->num_ports,
1863 ev->id,
1864 0);
1865 mpt_findImVolumes(ioc); 2285 mpt_findImVolumes(ioc);
1866 break; 2286 break;
1867 case MPTSAS_DEL_RAID: 2287 case MPTSAS_DEL_RAID:
1868 sdev = scsi_device_lookup( 2288 sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL,
1869 ioc->sh, 2289 ev->id, 0);
1870 ioc->num_ports,
1871 ev->id,
1872 0);
1873 if (!sdev) 2290 if (!sdev)
1874 break; 2291 break;
1875 printk(MYIOC_s_INFO_FMT 2292 printk(MYIOC_s_INFO_FMT
1876 "removing raid volume, channel %d, id %d\n", 2293 "removing raid volume, channel %d, id %d\n",
1877 ioc->name, ioc->num_ports, ev->id); 2294 ioc->name, MPTSAS_RAID_CHANNEL, ev->id);
2295 vdevice = sdev->hostdata;
2296 vdevice->vtarget->deleted = 1;
2297 mptsas_target_reset(ioc, vdevice->vtarget);
1878 scsi_remove_device(sdev); 2298 scsi_remove_device(sdev);
1879 scsi_device_put(sdev); 2299 scsi_device_put(sdev);
1880 mpt_findImVolumes(ioc); 2300 mpt_findImVolumes(ioc);
@@ -1884,12 +2304,13 @@ mptsas_hotplug_work(void *arg)
1884 break; 2304 break;
1885 } 2305 }
1886 2306
1887 kfree(ev);
1888 mutex_unlock(&ioc->sas_discovery_mutex); 2307 mutex_unlock(&ioc->sas_discovery_mutex);
2308 kfree(ev);
2309
1889} 2310}
1890 2311
1891static void 2312static void
1892mptscsih_send_sas_event(MPT_ADAPTER *ioc, 2313mptsas_send_sas_event(MPT_ADAPTER *ioc,
1893 EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *sas_event_data) 2314 EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *sas_event_data)
1894{ 2315{
1895 struct mptsas_hotplug_event *ev; 2316 struct mptsas_hotplug_event *ev;
@@ -1905,7 +2326,7 @@ mptscsih_send_sas_event(MPT_ADAPTER *ioc,
1905 switch (sas_event_data->ReasonCode) { 2326 switch (sas_event_data->ReasonCode) {
1906 case MPI_EVENT_SAS_DEV_STAT_RC_ADDED: 2327 case MPI_EVENT_SAS_DEV_STAT_RC_ADDED:
1907 case MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING: 2328 case MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING:
1908 ev = kmalloc(sizeof(*ev), GFP_ATOMIC); 2329 ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
1909 if (!ev) { 2330 if (!ev) {
1910 printk(KERN_WARNING "mptsas: lost hotplug event\n"); 2331 printk(KERN_WARNING "mptsas: lost hotplug event\n");
1911 break; 2332 break;
@@ -1935,10 +2356,9 @@ mptscsih_send_sas_event(MPT_ADAPTER *ioc,
1935 /* 2356 /*
1936 * Persistent table is full. 2357 * Persistent table is full.
1937 */ 2358 */
1938 INIT_WORK(&ioc->mptscsih_persistTask, 2359 INIT_WORK(&ioc->sas_persist_task,
1939 mptscsih_sas_persist_clear_table, 2360 mptsas_persist_clear_table, (void *)ioc);
1940 (void *)ioc); 2361 schedule_work(&ioc->sas_persist_task);
1941 schedule_work(&ioc->mptscsih_persistTask);
1942 break; 2362 break;
1943 case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA: 2363 case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA:
1944 /* TODO */ 2364 /* TODO */
@@ -1950,7 +2370,7 @@ mptscsih_send_sas_event(MPT_ADAPTER *ioc,
1950} 2370}
1951 2371
1952static void 2372static void
1953mptscsih_send_raid_event(MPT_ADAPTER *ioc, 2373mptsas_send_raid_event(MPT_ADAPTER *ioc,
1954 EVENT_DATA_RAID *raid_event_data) 2374 EVENT_DATA_RAID *raid_event_data)
1955{ 2375{
1956 struct mptsas_hotplug_event *ev; 2376 struct mptsas_hotplug_event *ev;
@@ -1960,13 +2380,12 @@ mptscsih_send_raid_event(MPT_ADAPTER *ioc,
1960 if (ioc->bus_type != SAS) 2380 if (ioc->bus_type != SAS)
1961 return; 2381 return;
1962 2382
1963 ev = kmalloc(sizeof(*ev), GFP_ATOMIC); 2383 ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
1964 if (!ev) { 2384 if (!ev) {
1965 printk(KERN_WARNING "mptsas: lost hotplug event\n"); 2385 printk(KERN_WARNING "mptsas: lost hotplug event\n");
1966 return; 2386 return;
1967 } 2387 }
1968 2388
1969 memset(ev,0,sizeof(struct mptsas_hotplug_event));
1970 INIT_WORK(&ev->work, mptsas_hotplug_work, ev); 2389 INIT_WORK(&ev->work, mptsas_hotplug_work, ev);
1971 ev->ioc = ioc; 2390 ev->ioc = ioc;
1972 ev->id = raid_event_data->VolumeID; 2391 ev->id = raid_event_data->VolumeID;
@@ -2028,7 +2447,7 @@ mptscsih_send_raid_event(MPT_ADAPTER *ioc,
2028} 2447}
2029 2448
2030static void 2449static void
2031mptscsih_send_discovery(MPT_ADAPTER *ioc, 2450mptsas_send_discovery_event(MPT_ADAPTER *ioc,
2032 EVENT_DATA_SAS_DISCOVERY *discovery_data) 2451 EVENT_DATA_SAS_DISCOVERY *discovery_data)
2033{ 2452{
2034 struct mptsas_discovery_event *ev; 2453 struct mptsas_discovery_event *ev;
@@ -2043,11 +2462,10 @@ mptscsih_send_discovery(MPT_ADAPTER *ioc,
2043 if (discovery_data->DiscoveryStatus) 2462 if (discovery_data->DiscoveryStatus)
2044 return; 2463 return;
2045 2464
2046 ev = kmalloc(sizeof(*ev), GFP_ATOMIC); 2465 ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
2047 if (!ev) 2466 if (!ev)
2048 return; 2467 return;
2049 memset(ev,0,sizeof(struct mptsas_discovery_event)); 2468 INIT_WORK(&ev->work, mptsas_discovery_work, ev);
2050 INIT_WORK(&ev->work, mptscsih_discovery_work, ev);
2051 ev->ioc = ioc; 2469 ev->ioc = ioc;
2052 schedule_work(&ev->work); 2470 schedule_work(&ev->work);
2053}; 2471};
@@ -2075,21 +2493,21 @@ mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply)
2075 2493
2076 switch (event) { 2494 switch (event) {
2077 case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE: 2495 case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE:
2078 mptscsih_send_sas_event(ioc, 2496 mptsas_send_sas_event(ioc,
2079 (EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *)reply->Data); 2497 (EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *)reply->Data);
2080 break; 2498 break;
2081 case MPI_EVENT_INTEGRATED_RAID: 2499 case MPI_EVENT_INTEGRATED_RAID:
2082 mptscsih_send_raid_event(ioc, 2500 mptsas_send_raid_event(ioc,
2083 (EVENT_DATA_RAID *)reply->Data); 2501 (EVENT_DATA_RAID *)reply->Data);
2084 break; 2502 break;
2085 case MPI_EVENT_PERSISTENT_TABLE_FULL: 2503 case MPI_EVENT_PERSISTENT_TABLE_FULL:
2086 INIT_WORK(&ioc->mptscsih_persistTask, 2504 INIT_WORK(&ioc->sas_persist_task,
2087 mptscsih_sas_persist_clear_table, 2505 mptsas_persist_clear_table,
2088 (void *)ioc); 2506 (void *)ioc);
2089 schedule_work(&ioc->mptscsih_persistTask); 2507 schedule_work(&ioc->sas_persist_task);
2090 break; 2508 break;
2091 case MPI_EVENT_SAS_DISCOVERY: 2509 case MPI_EVENT_SAS_DISCOVERY:
2092 mptscsih_send_discovery(ioc, 2510 mptsas_send_discovery_event(ioc,
2093 (EVENT_DATA_SAS_DISCOVERY *)reply->Data); 2511 (EVENT_DATA_SAS_DISCOVERY *)reply->Data);
2094 break; 2512 break;
2095 default: 2513 default:
@@ -2279,7 +2697,6 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2279 hd->timer.data = (unsigned long) hd; 2697 hd->timer.data = (unsigned long) hd;
2280 hd->timer.function = mptscsih_timer_expired; 2698 hd->timer.function = mptscsih_timer_expired;
2281 2699
2282 hd->mpt_pq_filter = mpt_pq_filter;
2283 ioc->sas_data.ptClear = mpt_pt_clear; 2700 ioc->sas_data.ptClear = mpt_pt_clear;
2284 2701
2285 if (ioc->sas_data.ptClear==1) { 2702 if (ioc->sas_data.ptClear==1) {
@@ -2287,12 +2704,6 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2287 ioc, MPI_SAS_OP_CLEAR_ALL_PERSISTENT); 2704 ioc, MPI_SAS_OP_CLEAR_ALL_PERSISTENT);
2288 } 2705 }
2289 2706
2290 ddvprintk((MYIOC_s_INFO_FMT
2291 "mpt_pq_filter %x mpt_pq_filter %x\n",
2292 ioc->name,
2293 mpt_pq_filter,
2294 mpt_pq_filter));
2295
2296 init_waitqueue_head(&hd->scandv_waitq); 2707 init_waitqueue_head(&hd->scandv_waitq);
2297 hd->scandv_wait_done = 0; 2708 hd->scandv_wait_done = 0;
2298 hd->last_queue_full = 0; 2709 hd->last_queue_full = 0;
@@ -2308,7 +2719,7 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2308 2719
2309 return 0; 2720 return 0;
2310 2721
2311out_mptsas_probe: 2722 out_mptsas_probe:
2312 2723
2313 mptscsih_remove(pdev); 2724 mptscsih_remove(pdev);
2314 return error; 2725 return error;
@@ -2318,6 +2729,7 @@ static void __devexit mptsas_remove(struct pci_dev *pdev)
2318{ 2729{
2319 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 2730 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
2320 struct mptsas_portinfo *p, *n; 2731 struct mptsas_portinfo *p, *n;
2732 int i;
2321 2733
2322 ioc->sas_discovery_ignore_events=1; 2734 ioc->sas_discovery_ignore_events=1;
2323 sas_remove_host(ioc->sh); 2735 sas_remove_host(ioc->sh);
@@ -2325,8 +2737,9 @@ static void __devexit mptsas_remove(struct pci_dev *pdev)
2325 mutex_lock(&ioc->sas_topology_mutex); 2737 mutex_lock(&ioc->sas_topology_mutex);
2326 list_for_each_entry_safe(p, n, &ioc->sas_topology, list) { 2738 list_for_each_entry_safe(p, n, &ioc->sas_topology, list) {
2327 list_del(&p->list); 2739 list_del(&p->list);
2328 if (p->phy_info) 2740 for (i = 0 ; i < p->num_phys ; i++)
2329 kfree(p->phy_info); 2741 mptsas_port_delete(p->phy_info[i].port_details);
2742 kfree(p->phy_info);
2330 kfree(p); 2743 kfree(p);
2331 } 2744 }
2332 mutex_unlock(&ioc->sas_topology_mutex); 2745 mutex_unlock(&ioc->sas_topology_mutex);
@@ -2335,17 +2748,15 @@ static void __devexit mptsas_remove(struct pci_dev *pdev)
2335} 2748}
2336 2749
2337static struct pci_device_id mptsas_pci_table[] = { 2750static struct pci_device_id mptsas_pci_table[] = {
2338 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1064, 2751 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1064,
2339 PCI_ANY_ID, PCI_ANY_ID },
2340 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1066,
2341 PCI_ANY_ID, PCI_ANY_ID }, 2752 PCI_ANY_ID, PCI_ANY_ID },
2342 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1068, 2753 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1068,
2343 PCI_ANY_ID, PCI_ANY_ID }, 2754 PCI_ANY_ID, PCI_ANY_ID },
2344 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1064E, 2755 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1064E,
2345 PCI_ANY_ID, PCI_ANY_ID }, 2756 PCI_ANY_ID, PCI_ANY_ID },
2346 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1066E, 2757 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1068E,
2347 PCI_ANY_ID, PCI_ANY_ID }, 2758 PCI_ANY_ID, PCI_ANY_ID },
2348 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1068E, 2759 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1078,
2349 PCI_ANY_ID, PCI_ANY_ID }, 2760 PCI_ANY_ID, PCI_ANY_ID },
2350 {0} /* Terminating entry */ 2761 {0} /* Terminating entry */
2351}; 2762};
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);