aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/fusion/mptsas.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/message/fusion/mptsas.c')
-rw-r--r--drivers/message/fusion/mptsas.c468
1 files changed, 199 insertions, 269 deletions
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index b9c69bff218c..e4c94f93de16 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -1,11 +1,10 @@
1/* 1/*
2 * linux/drivers/message/fusion/mptsas.c 2 * linux/drivers/message/fusion/mptsas.c
3 * For use with LSI Logic PCI chip/adapter(s) 3 * For use with LSI PCI chip/adapter(s)
4 * running LSI Logic Fusion MPT (Message Passing Technology) firmware. 4 * running LSI Fusion MPT (Message Passing Technology) firmware.
5 * 5 *
6 * Copyright (c) 1999-2007 LSI Logic Corporation 6 * Copyright (c) 1999-2007 LSI Corporation
7 * (mailto:DL-MPTFusionLinux@lsi.com) 7 * (mailto:DL-MPTFusionLinux@lsi.com)
8 * Copyright (c) 2005-2007 Dell
9 */ 8 */
10/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 9/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
11/* 10/*
@@ -61,6 +60,7 @@
61 60
62#include "mptbase.h" 61#include "mptbase.h"
63#include "mptscsih.h" 62#include "mptscsih.h"
63#include "mptsas.h"
64 64
65 65
66#define my_NAME "Fusion MPT SAS Host driver" 66#define my_NAME "Fusion MPT SAS Host driver"
@@ -89,134 +89,35 @@ static int max_lun = MPTSAS_MAX_LUN;
89module_param(max_lun, int, 0); 89module_param(max_lun, int, 0);
90MODULE_PARM_DESC(max_lun, " max lun, default=16895 "); 90MODULE_PARM_DESC(max_lun, " max lun, default=16895 ");
91 91
92static int mptsasDoneCtx = -1; 92static u8 mptsasDoneCtx = MPT_MAX_PROTOCOL_DRIVERS;
93static int mptsasTaskCtx = -1; 93static u8 mptsasTaskCtx = MPT_MAX_PROTOCOL_DRIVERS;
94static int mptsasInternalCtx = -1; /* Used only for internal commands */ 94static u8 mptsasInternalCtx = MPT_MAX_PROTOCOL_DRIVERS; /* Used only for internal commands */
95static int mptsasMgmtCtx = -1; 95static u8 mptsasMgmtCtx = MPT_MAX_PROTOCOL_DRIVERS;
96 96
97static void mptsas_hotplug_work(struct work_struct *work); 97static void mptsas_hotplug_work(struct work_struct *work);
98 98
99struct mptsas_target_reset_event {
100 struct list_head list;
101 EVENT_DATA_SAS_DEVICE_STATUS_CHANGE sas_event_data;
102 u8 target_reset_issued;
103};
104
105enum mptsas_hotplug_action {
106 MPTSAS_ADD_DEVICE,
107 MPTSAS_DEL_DEVICE,
108 MPTSAS_ADD_RAID,
109 MPTSAS_DEL_RAID,
110 MPTSAS_ADD_INACTIVE_VOLUME,
111 MPTSAS_IGNORE_EVENT,
112};
113
114struct mptsas_hotplug_event {
115 struct work_struct work;
116 MPT_ADAPTER *ioc;
117 enum mptsas_hotplug_action event_type;
118 u64 sas_address;
119 u8 channel;
120 u8 id;
121 u32 device_info;
122 u16 handle;
123 u16 parent_handle;
124 u8 phy_id;
125 u8 phys_disk_num_valid; /* hrc (hidden raid component) */
126 u8 phys_disk_num; /* hrc - unique index*/
127 u8 hidden_raid_component; /* hrc - don't expose*/
128};
129
130struct mptsas_discovery_event {
131 struct work_struct work;
132 MPT_ADAPTER *ioc;
133};
134
135/*
136 * SAS topology structures
137 *
138 * The MPT Fusion firmware interface spreads information about the
139 * SAS topology over many manufacture pages, thus we need some data
140 * structure to collect it and process it for the SAS transport class.
141 */
142
143struct mptsas_devinfo {
144 u16 handle; /* unique id to address this device */
145 u16 handle_parent; /* unique id to address parent device */
146 u16 handle_enclosure; /* enclosure identifier of the enclosure */
147 u16 slot; /* physical slot in enclosure */
148 u8 phy_id; /* phy number of parent device */
149 u8 port_id; /* sas physical port this device
150 is assoc'd with */
151 u8 id; /* logical target id of this device */
152 u32 phys_disk_num; /* phys disk id, for csmi-ioctls */
153 u8 channel; /* logical bus number of this device */
154 u64 sas_address; /* WWN of this device,
155 SATA is assigned by HBA,expander */
156 u32 device_info; /* bitfield detailed info about this device */
157};
158
159/*
160 * Specific details on ports, wide/narrow
161 */
162struct mptsas_portinfo_details{
163 u16 num_phys; /* number of phys belong to this port */
164 u64 phy_bitmask; /* TODO, extend support for 255 phys */
165 struct sas_rphy *rphy; /* transport layer rphy object */
166 struct sas_port *port; /* transport layer port object */
167 struct scsi_target *starget;
168 struct mptsas_portinfo *port_info;
169};
170
171struct mptsas_phyinfo {
172 u16 handle; /* unique id to address this */
173 u8 phy_id; /* phy index */
174 u8 port_id; /* firmware port identifier */
175 u8 negotiated_link_rate; /* nego'd link rate for this phy */
176 u8 hw_link_rate; /* hardware max/min phys link rate */
177 u8 programmed_link_rate; /* programmed max/min phy link rate */
178 u8 sas_port_add_phy; /* flag to request sas_port_add_phy*/
179 struct mptsas_devinfo identify; /* point to phy device info */
180 struct mptsas_devinfo attached; /* point to attached device info */
181 struct sas_phy *phy; /* transport layer phy object */
182 struct mptsas_portinfo *portinfo;
183 struct mptsas_portinfo_details * port_details;
184};
185
186struct mptsas_portinfo {
187 struct list_head list;
188 u16 num_phys; /* number of phys */
189 struct mptsas_phyinfo *phy_info;
190};
191
192struct mptsas_enclosure {
193 u64 enclosure_logical_id; /* The WWN for the enclosure */
194 u16 enclosure_handle; /* unique id to address this */
195 u16 flags; /* details enclosure management */
196 u16 num_slot; /* num slots */
197 u16 start_slot; /* first slot */
198 u8 start_id; /* starting logical target id */
199 u8 start_channel; /* starting logical channel id */
200 u8 sep_id; /* SEP device logical target id */
201 u8 sep_channel; /* SEP channel logical channel id */
202};
203
204static void mptsas_print_phy_data(MPT_ADAPTER *ioc, 99static void mptsas_print_phy_data(MPT_ADAPTER *ioc,
205 MPI_SAS_IO_UNIT0_PHY_DATA *phy_data) 100 MPI_SAS_IO_UNIT0_PHY_DATA *phy_data)
206{ 101{
207 dsasprintk(ioc, printk(KERN_DEBUG "---- IO UNIT PAGE 0 ------------\n")); 102 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
208 dsasprintk(ioc, printk(KERN_DEBUG "Handle=0x%X\n", 103 "---- IO UNIT PAGE 0 ------------\n", ioc->name));
209 le16_to_cpu(phy_data->AttachedDeviceHandle))); 104 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Handle=0x%X\n",
210 dsasprintk(ioc, printk(KERN_DEBUG "Controller Handle=0x%X\n", 105 ioc->name, le16_to_cpu(phy_data->AttachedDeviceHandle)));
211 le16_to_cpu(phy_data->ControllerDevHandle))); 106 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Controller Handle=0x%X\n",
212 dsasprintk(ioc, printk(KERN_DEBUG "Port=0x%X\n", phy_data->Port)); 107 ioc->name, le16_to_cpu(phy_data->ControllerDevHandle)));
213 dsasprintk(ioc, printk(KERN_DEBUG "Port Flags=0x%X\n", phy_data->PortFlags)); 108 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Port=0x%X\n",
214 dsasprintk(ioc, printk(KERN_DEBUG "PHY Flags=0x%X\n", phy_data->PhyFlags)); 109 ioc->name, phy_data->Port));
215 dsasprintk(ioc, printk(KERN_DEBUG "Negotiated Link Rate=0x%X\n", phy_data->NegotiatedLinkRate)); 110 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Port Flags=0x%X\n",
216 dsasprintk(ioc, printk(KERN_DEBUG "Controller PHY Device Info=0x%X\n", 111 ioc->name, phy_data->PortFlags));
217 le32_to_cpu(phy_data->ControllerPhyDeviceInfo))); 112 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PHY Flags=0x%X\n",
218 dsasprintk(ioc, printk(KERN_DEBUG "DiscoveryStatus=0x%X\n\n", 113 ioc->name, phy_data->PhyFlags));
219 le32_to_cpu(phy_data->DiscoveryStatus))); 114 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Negotiated Link Rate=0x%X\n",
115 ioc->name, phy_data->NegotiatedLinkRate));
116 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
117 "Controller PHY Device Info=0x%X\n", ioc->name,
118 le32_to_cpu(phy_data->ControllerPhyDeviceInfo)));
119 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "DiscoveryStatus=0x%X\n\n",
120 ioc->name, le32_to_cpu(phy_data->DiscoveryStatus)));
220} 121}
221 122
222static void mptsas_print_phy_pg0(MPT_ADAPTER *ioc, SasPhyPage0_t *pg0) 123static void mptsas_print_phy_pg0(MPT_ADAPTER *ioc, SasPhyPage0_t *pg0)
@@ -225,27 +126,41 @@ static void mptsas_print_phy_pg0(MPT_ADAPTER *ioc, SasPhyPage0_t *pg0)
225 126
226 memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64)); 127 memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64));
227 128
228 dsasprintk(ioc, printk(KERN_DEBUG "---- SAS PHY PAGE 0 ------------\n")); 129 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
229 dsasprintk(ioc, printk(KERN_DEBUG "Attached Device Handle=0x%X\n", 130 "---- SAS PHY PAGE 0 ------------\n", ioc->name));
230 le16_to_cpu(pg0->AttachedDevHandle))); 131 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
231 dsasprintk(ioc, printk(KERN_DEBUG "SAS Address=0x%llX\n", 132 "Attached Device Handle=0x%X\n", ioc->name,
232 (unsigned long long)le64_to_cpu(sas_address))); 133 le16_to_cpu(pg0->AttachedDevHandle)));
233 dsasprintk(ioc, printk(KERN_DEBUG "Attached PHY Identifier=0x%X\n", pg0->AttachedPhyIdentifier)); 134 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "SAS Address=0x%llX\n",
234 dsasprintk(ioc, printk(KERN_DEBUG "Attached Device Info=0x%X\n", 135 ioc->name, (unsigned long long)le64_to_cpu(sas_address)));
235 le32_to_cpu(pg0->AttachedDeviceInfo))); 136 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
236 dsasprintk(ioc, printk(KERN_DEBUG "Programmed Link Rate=0x%X\n", pg0->ProgrammedLinkRate)); 137 "Attached PHY Identifier=0x%X\n", ioc->name,
237 dsasprintk(ioc, printk(KERN_DEBUG "Change Count=0x%X\n", pg0->ChangeCount)); 138 pg0->AttachedPhyIdentifier));
238 dsasprintk(ioc, printk(KERN_DEBUG "PHY Info=0x%X\n\n", le32_to_cpu(pg0->PhyInfo))); 139 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Attached Device Info=0x%X\n",
140 ioc->name, le32_to_cpu(pg0->AttachedDeviceInfo)));
141 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Programmed Link Rate=0x%X\n",
142 ioc->name, pg0->ProgrammedLinkRate));
143 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Change Count=0x%X\n",
144 ioc->name, pg0->ChangeCount));
145 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PHY Info=0x%X\n\n",
146 ioc->name, le32_to_cpu(pg0->PhyInfo)));
239} 147}
240 148
241static void mptsas_print_phy_pg1(MPT_ADAPTER *ioc, SasPhyPage1_t *pg1) 149static void mptsas_print_phy_pg1(MPT_ADAPTER *ioc, SasPhyPage1_t *pg1)
242{ 150{
243 dsasprintk(ioc, printk(KERN_DEBUG "---- SAS PHY PAGE 1 ------------\n")); 151 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
244 dsasprintk(ioc, printk(KERN_DEBUG "Invalid Dword Count=0x%x\n", pg1->InvalidDwordCount)); 152 "---- SAS PHY PAGE 1 ------------\n", ioc->name));
245 dsasprintk(ioc, printk(KERN_DEBUG "Running Disparity Error Count=0x%x\n", 153 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Invalid Dword Count=0x%x\n",
246 pg1->RunningDisparityErrorCount)); 154 ioc->name, pg1->InvalidDwordCount));
247 dsasprintk(ioc, printk(KERN_DEBUG "Loss Dword Synch Count=0x%x\n", pg1->LossDwordSynchCount)); 155 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
248 dsasprintk(ioc, printk(KERN_DEBUG "PHY Reset Problem Count=0x%x\n\n", pg1->PhyResetProblemCount)); 156 "Running Disparity Error Count=0x%x\n", ioc->name,
157 pg1->RunningDisparityErrorCount));
158 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
159 "Loss Dword Synch Count=0x%x\n", ioc->name,
160 pg1->LossDwordSynchCount));
161 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
162 "PHY Reset Problem Count=0x%x\n\n", ioc->name,
163 pg1->PhyResetProblemCount));
249} 164}
250 165
251static void mptsas_print_device_pg0(MPT_ADAPTER *ioc, SasDevicePage0_t *pg0) 166static void mptsas_print_device_pg0(MPT_ADAPTER *ioc, SasDevicePage0_t *pg0)
@@ -254,37 +169,53 @@ static void mptsas_print_device_pg0(MPT_ADAPTER *ioc, SasDevicePage0_t *pg0)
254 169
255 memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64)); 170 memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64));
256 171
257 dsasprintk(ioc, printk(KERN_DEBUG "---- SAS DEVICE PAGE 0 ---------\n")); 172 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
258 dsasprintk(ioc, printk(KERN_DEBUG "Handle=0x%X\n" ,le16_to_cpu(pg0->DevHandle))); 173 "---- SAS DEVICE PAGE 0 ---------\n", ioc->name));
259 dsasprintk(ioc, printk(KERN_DEBUG "Parent Handle=0x%X\n" ,le16_to_cpu(pg0->ParentDevHandle))); 174 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Handle=0x%X\n",
260 dsasprintk(ioc, printk(KERN_DEBUG "Enclosure Handle=0x%X\n", le16_to_cpu(pg0->EnclosureHandle))); 175 ioc->name, le16_to_cpu(pg0->DevHandle)));
261 dsasprintk(ioc, printk(KERN_DEBUG "Slot=0x%X\n", le16_to_cpu(pg0->Slot))); 176 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Parent Handle=0x%X\n",
262 dsasprintk(ioc, printk(KERN_DEBUG "SAS Address=0x%llX\n", (unsigned long long) 177 ioc->name, le16_to_cpu(pg0->ParentDevHandle)));
263 le64_to_cpu(sas_address))); 178 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Enclosure Handle=0x%X\n",
264 dsasprintk(ioc, printk(KERN_DEBUG "Target ID=0x%X\n", pg0->TargetID)); 179 ioc->name, le16_to_cpu(pg0->EnclosureHandle)));
265 dsasprintk(ioc, printk(KERN_DEBUG "Bus=0x%X\n", pg0->Bus)); 180 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Slot=0x%X\n",
266 /* The PhyNum field specifies the PHY number of the parent 181 ioc->name, le16_to_cpu(pg0->Slot)));
267 * device this device is linked to 182 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "SAS Address=0x%llX\n",
268 */ 183 ioc->name, (unsigned long long)le64_to_cpu(sas_address)));
269 dsasprintk(ioc, printk(KERN_DEBUG "Parent Phy Num=0x%X\n", pg0->PhyNum)); 184 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Target ID=0x%X\n",
270 dsasprintk(ioc, printk(KERN_DEBUG "Access Status=0x%X\n", le16_to_cpu(pg0->AccessStatus))); 185 ioc->name, pg0->TargetID));
271 dsasprintk(ioc, printk(KERN_DEBUG "Device Info=0x%X\n", le32_to_cpu(pg0->DeviceInfo))); 186 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Bus=0x%X\n",
272 dsasprintk(ioc, printk(KERN_DEBUG "Flags=0x%X\n", le16_to_cpu(pg0->Flags))); 187 ioc->name, pg0->Bus));
273 dsasprintk(ioc, printk(KERN_DEBUG "Physical Port=0x%X\n\n", pg0->PhysicalPort)); 188 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Parent Phy Num=0x%X\n",
189 ioc->name, pg0->PhyNum));
190 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Access Status=0x%X\n",
191 ioc->name, le16_to_cpu(pg0->AccessStatus)));
192 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Device Info=0x%X\n",
193 ioc->name, le32_to_cpu(pg0->DeviceInfo)));
194 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Flags=0x%X\n",
195 ioc->name, le16_to_cpu(pg0->Flags)));
196 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Physical Port=0x%X\n\n",
197 ioc->name, pg0->PhysicalPort));
274} 198}
275 199
276static void mptsas_print_expander_pg1(MPT_ADAPTER *ioc, SasExpanderPage1_t *pg1) 200static void mptsas_print_expander_pg1(MPT_ADAPTER *ioc, SasExpanderPage1_t *pg1)
277{ 201{
278 dsasprintk(ioc, printk(KERN_DEBUG "---- SAS EXPANDER PAGE 1 ------------\n")); 202 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
279 dsasprintk(ioc, printk(KERN_DEBUG "Physical Port=0x%X\n", pg1->PhysicalPort)); 203 "---- SAS EXPANDER PAGE 1 ------------\n", ioc->name));
280 dsasprintk(ioc, printk(KERN_DEBUG "PHY Identifier=0x%X\n", pg1->PhyIdentifier)); 204 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Physical Port=0x%X\n",
281 dsasprintk(ioc, printk(KERN_DEBUG "Negotiated Link Rate=0x%X\n", pg1->NegotiatedLinkRate)); 205 ioc->name, pg1->PhysicalPort));
282 dsasprintk(ioc, printk(KERN_DEBUG "Programmed Link Rate=0x%X\n", pg1->ProgrammedLinkRate)); 206 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PHY Identifier=0x%X\n",
283 dsasprintk(ioc, printk(KERN_DEBUG "Hardware Link Rate=0x%X\n", pg1->HwLinkRate)); 207 ioc->name, pg1->PhyIdentifier));
284 dsasprintk(ioc, printk(KERN_DEBUG "Owner Device Handle=0x%X\n", 208 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Negotiated Link Rate=0x%X\n",
285 le16_to_cpu(pg1->OwnerDevHandle))); 209 ioc->name, pg1->NegotiatedLinkRate));
286 dsasprintk(ioc, printk(KERN_DEBUG "Attached Device Handle=0x%X\n\n", 210 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Programmed Link Rate=0x%X\n",
287 le16_to_cpu(pg1->AttachedDevHandle))); 211 ioc->name, pg1->ProgrammedLinkRate));
212 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Hardware Link Rate=0x%X\n",
213 ioc->name, pg1->HwLinkRate));
214 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Owner Device Handle=0x%X\n",
215 ioc->name, le16_to_cpu(pg1->OwnerDevHandle)));
216 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
217 "Attached Device Handle=0x%X\n\n", ioc->name,
218 le16_to_cpu(pg1->AttachedDevHandle)));
288} 219}
289 220
290static inline MPT_ADAPTER *phy_to_ioc(struct sas_phy *phy) 221static inline MPT_ADAPTER *phy_to_ioc(struct sas_phy *phy)
@@ -354,8 +285,8 @@ mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_detai
354 port_info = port_details->port_info; 285 port_info = port_details->port_info;
355 phy_info = port_info->phy_info; 286 phy_info = port_info->phy_info;
356 287
357 dsaswideprintk(ioc, printk(KERN_DEBUG "%s: [%p]: num_phys=%02d " 288 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: [%p]: num_phys=%02d "
358 "bitmask=0x%016llX\n", __FUNCTION__, port_details, 289 "bitmask=0x%016llX\n", ioc->name, __FUNCTION__, port_details,
359 port_details->num_phys, (unsigned long long) 290 port_details->num_phys, (unsigned long long)
360 port_details->phy_bitmask)); 291 port_details->phy_bitmask));
361 292
@@ -382,14 +313,15 @@ mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rp
382{ 313{
383 if (phy_info->port_details) { 314 if (phy_info->port_details) {
384 phy_info->port_details->rphy = rphy; 315 phy_info->port_details->rphy = rphy;
385 dsaswideprintk(ioc, printk(KERN_DEBUG "sas_rphy_add: rphy=%p\n", rphy)); 316 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
317 ioc->name, rphy));
386 } 318 }
387 319
388 if (rphy) { 320 if (rphy) {
389 dsaswideprintk(ioc, dev_printk(KERN_DEBUG, 321 dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
390 &rphy->dev, "add:")); 322 &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
391 dsaswideprintk(ioc, printk(KERN_DEBUG "rphy=%p release=%p\n", 323 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
392 rphy, rphy->dev.release)); 324 ioc->name, rphy, rphy->dev.release));
393 } 325 }
394} 326}
395 327
@@ -410,9 +342,9 @@ mptsas_set_port(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_po
410 342
411 if (port) { 343 if (port) {
412 dsaswideprintk(ioc, dev_printk(KERN_DEBUG, 344 dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
413 &port->dev, "add:")); 345 &port->dev, MYIOC_s_FMT "add:", ioc->name));
414 dsaswideprintk(ioc, printk(KERN_DEBUG "port=%p release=%p\n", 346 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "port=%p release=%p\n",
415 port, port->dev.release)); 347 ioc->name, port, port->dev.release));
416 } 348 }
417} 349}
418 350
@@ -463,9 +395,9 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
463 * Removing a phy from a port, letting the last 395 * Removing a phy from a port, letting the last
464 * phy be removed by firmware events. 396 * phy be removed by firmware events.
465 */ 397 */
466 dsaswideprintk(ioc, printk(KERN_DEBUG 398 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT
467 "%s: [%p]: deleting phy = %d\n", 399 "%s: [%p]: deleting phy = %d\n",
468 __FUNCTION__, port_details, i)); 400 ioc->name, __FUNCTION__, port_details, i));
469 port_details->num_phys--; 401 port_details->num_phys--;
470 port_details->phy_bitmask &= ~ (1 << phy_info->phy_id); 402 port_details->phy_bitmask &= ~ (1 << phy_info->phy_id);
471 memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo)); 403 memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo));
@@ -479,8 +411,8 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
479 phy_info = port_info->phy_info; 411 phy_info = port_info->phy_info;
480 for (i = 0 ; i < port_info->num_phys ; i++, phy_info++) { 412 for (i = 0 ; i < port_info->num_phys ; i++, phy_info++) {
481 sas_address = phy_info->attached.sas_address; 413 sas_address = phy_info->attached.sas_address;
482 dsaswideprintk(ioc, printk(KERN_DEBUG "phy_id=%d sas_address=0x%018llX\n", 414 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "phy_id=%d sas_address=0x%018llX\n",
483 i, (unsigned long long)sas_address)); 415 ioc->name, i, (unsigned long long)sas_address));
484 if (!sas_address) 416 if (!sas_address)
485 continue; 417 continue;
486 port_details = phy_info->port_details; 418 port_details = phy_info->port_details;
@@ -498,9 +430,9 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
498 port_details->phy_bitmask |= 430 port_details->phy_bitmask |=
499 (1 << phy_info->phy_id); 431 (1 << phy_info->phy_id);
500 phy_info->sas_port_add_phy=1; 432 phy_info->sas_port_add_phy=1;
501 dsaswideprintk(ioc, printk(KERN_DEBUG "\t\tForming port\n\t\t" 433 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\t\tForming port\n\t\t"
502 "phy_id=%d sas_address=0x%018llX\n", 434 "phy_id=%d sas_address=0x%018llX\n",
503 i, (unsigned long long)sas_address)); 435 ioc->name, i, (unsigned long long)sas_address));
504 phy_info->port_details = port_details; 436 phy_info->port_details = port_details;
505 } 437 }
506 438
@@ -515,9 +447,9 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
515 continue; 447 continue;
516 if (phy_info_cmp->port_details == port_details ) 448 if (phy_info_cmp->port_details == port_details )
517 continue; 449 continue;
518 dsaswideprintk(ioc, printk(KERN_DEBUG 450 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT
519 "\t\tphy_id=%d sas_address=0x%018llX\n", 451 "\t\tphy_id=%d sas_address=0x%018llX\n",
520 j, (unsigned long long) 452 ioc->name, j, (unsigned long long)
521 phy_info_cmp->attached.sas_address)); 453 phy_info_cmp->attached.sas_address));
522 if (phy_info_cmp->port_details) { 454 if (phy_info_cmp->port_details) {
523 port_details->rphy = 455 port_details->rphy =
@@ -549,15 +481,15 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
549 port_details = port_info->phy_info[i].port_details; 481 port_details = port_info->phy_info[i].port_details;
550 if (!port_details) 482 if (!port_details)
551 continue; 483 continue;
552 dsaswideprintk(ioc, printk(KERN_DEBUG 484 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT
553 "%s: [%p]: phy_id=%02d num_phys=%02d " 485 "%s: [%p]: phy_id=%02d num_phys=%02d "
554 "bitmask=0x%016llX\n", __FUNCTION__, 486 "bitmask=0x%016llX\n", ioc->name, __FUNCTION__,
555 port_details, i, port_details->num_phys, 487 port_details, i, port_details->num_phys,
556 (unsigned long long)port_details->phy_bitmask)); 488 (unsigned long long)port_details->phy_bitmask));
557 dsaswideprintk(ioc, printk(KERN_DEBUG"\t\tport = %p rphy=%p\n", 489 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\t\tport = %p rphy=%p\n",
558 port_details->port, port_details->rphy)); 490 ioc->name, port_details->port, port_details->rphy));
559 } 491 }
560 dsaswideprintk(ioc, printk(KERN_DEBUG"\n")); 492 dsaswideprintk(ioc, printk("\n"));
561 mutex_unlock(&ioc->sas_topology_mutex); 493 mutex_unlock(&ioc->sas_topology_mutex);
562} 494}
563 495
@@ -573,15 +505,15 @@ static VirtTarget *
573mptsas_find_vtarget(MPT_ADAPTER *ioc, u8 channel, u8 id) 505mptsas_find_vtarget(MPT_ADAPTER *ioc, u8 channel, u8 id)
574{ 506{
575 struct scsi_device *sdev; 507 struct scsi_device *sdev;
576 VirtDevice *vdev; 508 VirtDevice *vdevice;
577 VirtTarget *vtarget = NULL; 509 VirtTarget *vtarget = NULL;
578 510
579 shost_for_each_device(sdev, ioc->sh) { 511 shost_for_each_device(sdev, ioc->sh) {
580 if ((vdev = sdev->hostdata) == NULL) 512 if ((vdevice = sdev->hostdata) == NULL)
581 continue; 513 continue;
582 if (vdev->vtarget->id == id && 514 if (vdevice->vtarget->id == id &&
583 vdev->vtarget->channel == channel) 515 vdevice->vtarget->channel == channel)
584 vtarget = vdev->vtarget; 516 vtarget = vdevice->vtarget;
585 } 517 }
586 return vtarget; 518 return vtarget;
587} 519}
@@ -623,13 +555,7 @@ mptsas_target_reset(MPT_ADAPTER *ioc, u8 channel, u8 id)
623 555
624 DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf); 556 DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf);
625 557
626 if (mpt_send_handshake_request(ioc->TaskCtx, ioc, 558 mpt_put_msg_frame_hi_pri(ioc->TaskCtx, ioc, mf);
627 sizeof(SCSITaskMgmt_t), (u32 *)mf, NO_SLEEP)) {
628 mpt_free_msg_frame(ioc, mf);
629 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, tm handshake failed @%d!!\n",
630 ioc->name,__FUNCTION__, __LINE__));
631 return 0;
632 }
633 559
634 return 1; 560 return 1;
635} 561}
@@ -649,7 +575,7 @@ static void
649mptsas_target_reset_queue(MPT_ADAPTER *ioc, 575mptsas_target_reset_queue(MPT_ADAPTER *ioc,
650 EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *sas_event_data) 576 EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *sas_event_data)
651{ 577{
652 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; 578 MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
653 VirtTarget *vtarget = NULL; 579 VirtTarget *vtarget = NULL;
654 struct mptsas_target_reset_event *target_reset_list; 580 struct mptsas_target_reset_event *target_reset_list;
655 u8 id, channel; 581 u8 id, channel;
@@ -696,7 +622,7 @@ mptsas_target_reset_queue(MPT_ADAPTER *ioc,
696static void 622static void
697mptsas_dev_reset_complete(MPT_ADAPTER *ioc) 623mptsas_dev_reset_complete(MPT_ADAPTER *ioc)
698{ 624{
699 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; 625 MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
700 struct list_head *head = &hd->target_reset_list; 626 struct list_head *head = &hd->target_reset_list;
701 struct mptsas_target_reset_event *target_reset_list; 627 struct mptsas_target_reset_event *target_reset_list;
702 struct mptsas_hotplug_event *ev; 628 struct mptsas_hotplug_event *ev;
@@ -813,7 +739,7 @@ mptsas_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
813 739
814 if (!ioc->sh || !ioc->sh->hostdata) 740 if (!ioc->sh || !ioc->sh->hostdata)
815 goto out; 741 goto out;
816 hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; 742 hd = shost_priv(ioc->sh);
817 if (!hd->ioc) 743 if (!hd->ioc)
818 goto out; 744 goto out;
819 745
@@ -913,19 +839,20 @@ static int
913mptsas_target_alloc(struct scsi_target *starget) 839mptsas_target_alloc(struct scsi_target *starget)
914{ 840{
915 struct Scsi_Host *host = dev_to_shost(&starget->dev); 841 struct Scsi_Host *host = dev_to_shost(&starget->dev);
916 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 842 MPT_SCSI_HOST *hd = shost_priv(host);
917 VirtTarget *vtarget; 843 VirtTarget *vtarget;
918 u8 id, channel; 844 u8 id, channel;
919 struct sas_rphy *rphy; 845 struct sas_rphy *rphy;
920 struct mptsas_portinfo *p; 846 struct mptsas_portinfo *p;
921 int i; 847 int i;
848 MPT_ADAPTER *ioc = hd->ioc;
922 849
923 vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL); 850 vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL);
924 if (!vtarget) 851 if (!vtarget)
925 return -ENOMEM; 852 return -ENOMEM;
926 853
927 vtarget->starget = starget; 854 vtarget->starget = starget;
928 vtarget->ioc_id = hd->ioc->id; 855 vtarget->ioc_id = ioc->id;
929 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES; 856 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES;
930 id = starget->id; 857 id = starget->id;
931 channel = 0; 858 channel = 0;
@@ -934,15 +861,15 @@ mptsas_target_alloc(struct scsi_target *starget)
934 * RAID volumes placed beyond the last expected port. 861 * RAID volumes placed beyond the last expected port.
935 */ 862 */
936 if (starget->channel == MPTSAS_RAID_CHANNEL) { 863 if (starget->channel == MPTSAS_RAID_CHANNEL) {
937 for (i=0; i < hd->ioc->raid_data.pIocPg2->NumActiveVolumes; i++) 864 for (i=0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++)
938 if (id == hd->ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID) 865 if (id == ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID)
939 channel = hd->ioc->raid_data.pIocPg2->RaidVolume[i].VolumeBus; 866 channel = ioc->raid_data.pIocPg2->RaidVolume[i].VolumeBus;
940 goto out; 867 goto out;
941 } 868 }
942 869
943 rphy = dev_to_rphy(starget->dev.parent); 870 rphy = dev_to_rphy(starget->dev.parent);
944 mutex_lock(&hd->ioc->sas_topology_mutex); 871 mutex_lock(&ioc->sas_topology_mutex);
945 list_for_each_entry(p, &hd->ioc->sas_topology, list) { 872 list_for_each_entry(p, &ioc->sas_topology, list) {
946 for (i = 0; i < p->num_phys; i++) { 873 for (i = 0; i < p->num_phys; i++) {
947 if (p->phy_info[i].attached.sas_address != 874 if (p->phy_info[i].attached.sas_address !=
948 rphy->identify.sas_address) 875 rphy->identify.sas_address)
@@ -954,18 +881,18 @@ mptsas_target_alloc(struct scsi_target *starget)
954 /* 881 /*
955 * Exposing hidden raid components 882 * Exposing hidden raid components
956 */ 883 */
957 if (mptscsih_is_phys_disk(hd->ioc, channel, id)) { 884 if (mptscsih_is_phys_disk(ioc, channel, id)) {
958 id = mptscsih_raid_id_to_num(hd->ioc, 885 id = mptscsih_raid_id_to_num(ioc,
959 channel, id); 886 channel, id);
960 vtarget->tflags |= 887 vtarget->tflags |=
961 MPT_TARGET_FLAGS_RAID_COMPONENT; 888 MPT_TARGET_FLAGS_RAID_COMPONENT;
962 p->phy_info[i].attached.phys_disk_num = id; 889 p->phy_info[i].attached.phys_disk_num = id;
963 } 890 }
964 mutex_unlock(&hd->ioc->sas_topology_mutex); 891 mutex_unlock(&ioc->sas_topology_mutex);
965 goto out; 892 goto out;
966 } 893 }
967 } 894 }
968 mutex_unlock(&hd->ioc->sas_topology_mutex); 895 mutex_unlock(&ioc->sas_topology_mutex);
969 896
970 kfree(vtarget); 897 kfree(vtarget);
971 return -ENXIO; 898 return -ENXIO;
@@ -981,10 +908,11 @@ static void
981mptsas_target_destroy(struct scsi_target *starget) 908mptsas_target_destroy(struct scsi_target *starget)
982{ 909{
983 struct Scsi_Host *host = dev_to_shost(&starget->dev); 910 struct Scsi_Host *host = dev_to_shost(&starget->dev);
984 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 911 MPT_SCSI_HOST *hd = shost_priv(host);
985 struct sas_rphy *rphy; 912 struct sas_rphy *rphy;
986 struct mptsas_portinfo *p; 913 struct mptsas_portinfo *p;
987 int i; 914 int i;
915 MPT_ADAPTER *ioc = hd->ioc;
988 916
989 if (!starget->hostdata) 917 if (!starget->hostdata)
990 return; 918 return;
@@ -993,7 +921,7 @@ mptsas_target_destroy(struct scsi_target *starget)
993 goto out; 921 goto out;
994 922
995 rphy = dev_to_rphy(starget->dev.parent); 923 rphy = dev_to_rphy(starget->dev.parent);
996 list_for_each_entry(p, &hd->ioc->sas_topology, list) { 924 list_for_each_entry(p, &ioc->sas_topology, list) {
997 for (i = 0; i < p->num_phys; i++) { 925 for (i = 0; i < p->num_phys; i++) {
998 if (p->phy_info[i].attached.sas_address != 926 if (p->phy_info[i].attached.sas_address !=
999 rphy->identify.sas_address) 927 rphy->identify.sas_address)
@@ -1013,61 +941,62 @@ static int
1013mptsas_slave_alloc(struct scsi_device *sdev) 941mptsas_slave_alloc(struct scsi_device *sdev)
1014{ 942{
1015 struct Scsi_Host *host = sdev->host; 943 struct Scsi_Host *host = sdev->host;
1016 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 944 MPT_SCSI_HOST *hd = shost_priv(host);
1017 struct sas_rphy *rphy; 945 struct sas_rphy *rphy;
1018 struct mptsas_portinfo *p; 946 struct mptsas_portinfo *p;
1019 VirtDevice *vdev; 947 VirtDevice *vdevice;
1020 struct scsi_target *starget; 948 struct scsi_target *starget;
1021 int i; 949 int i;
950 MPT_ADAPTER *ioc = hd->ioc;
1022 951
1023 vdev = kzalloc(sizeof(VirtDevice), GFP_KERNEL); 952 vdevice = kzalloc(sizeof(VirtDevice), GFP_KERNEL);
1024 if (!vdev) { 953 if (!vdevice) {
1025 printk(MYIOC_s_ERR_FMT "slave_alloc kzalloc(%zd) FAILED!\n", 954 printk(MYIOC_s_ERR_FMT "slave_alloc kzalloc(%zd) FAILED!\n",
1026 hd->ioc->name, sizeof(VirtDevice)); 955 ioc->name, sizeof(VirtDevice));
1027 return -ENOMEM; 956 return -ENOMEM;
1028 } 957 }
1029 starget = scsi_target(sdev); 958 starget = scsi_target(sdev);
1030 vdev->vtarget = starget->hostdata; 959 vdevice->vtarget = starget->hostdata;
1031 960
1032 if (sdev->channel == MPTSAS_RAID_CHANNEL) 961 if (sdev->channel == MPTSAS_RAID_CHANNEL)
1033 goto out; 962 goto out;
1034 963
1035 rphy = dev_to_rphy(sdev->sdev_target->dev.parent); 964 rphy = dev_to_rphy(sdev->sdev_target->dev.parent);
1036 mutex_lock(&hd->ioc->sas_topology_mutex); 965 mutex_lock(&ioc->sas_topology_mutex);
1037 list_for_each_entry(p, &hd->ioc->sas_topology, list) { 966 list_for_each_entry(p, &ioc->sas_topology, list) {
1038 for (i = 0; i < p->num_phys; i++) { 967 for (i = 0; i < p->num_phys; i++) {
1039 if (p->phy_info[i].attached.sas_address != 968 if (p->phy_info[i].attached.sas_address !=
1040 rphy->identify.sas_address) 969 rphy->identify.sas_address)
1041 continue; 970 continue;
1042 vdev->lun = sdev->lun; 971 vdevice->lun = sdev->lun;
1043 /* 972 /*
1044 * Exposing hidden raid components 973 * Exposing hidden raid components
1045 */ 974 */
1046 if (mptscsih_is_phys_disk(hd->ioc, 975 if (mptscsih_is_phys_disk(ioc,
1047 p->phy_info[i].attached.channel, 976 p->phy_info[i].attached.channel,
1048 p->phy_info[i].attached.id)) 977 p->phy_info[i].attached.id))
1049 sdev->no_uld_attach = 1; 978 sdev->no_uld_attach = 1;
1050 mutex_unlock(&hd->ioc->sas_topology_mutex); 979 mutex_unlock(&ioc->sas_topology_mutex);
1051 goto out; 980 goto out;
1052 } 981 }
1053 } 982 }
1054 mutex_unlock(&hd->ioc->sas_topology_mutex); 983 mutex_unlock(&ioc->sas_topology_mutex);
1055 984
1056 kfree(vdev); 985 kfree(vdevice);
1057 return -ENXIO; 986 return -ENXIO;
1058 987
1059 out: 988 out:
1060 vdev->vtarget->num_luns++; 989 vdevice->vtarget->num_luns++;
1061 sdev->hostdata = vdev; 990 sdev->hostdata = vdevice;
1062 return 0; 991 return 0;
1063} 992}
1064 993
1065static int 994static int
1066mptsas_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 995mptsas_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1067{ 996{
1068 VirtDevice *vdev = SCpnt->device->hostdata; 997 VirtDevice *vdevice = SCpnt->device->hostdata;
1069 998
1070 if (!vdev || !vdev->vtarget || vdev->vtarget->deleted) { 999 if (!vdevice || !vdevice->vtarget || vdevice->vtarget->deleted) {
1071 SCpnt->result = DID_NO_CONNECT << 16; 1000 SCpnt->result = DID_NO_CONNECT << 16;
1072 done(SCpnt); 1001 done(SCpnt);
1073 return 0; 1002 return 0;
@@ -1239,10 +1168,8 @@ static int mptsas_phy_reset(struct sas_phy *phy, int hard_reset)
1239 /* process the completed Reply Message Frame */ 1168 /* process the completed Reply Message Frame */
1240 reply = (SasIoUnitControlReply_t *)ioc->sas_mgmt.reply; 1169 reply = (SasIoUnitControlReply_t *)ioc->sas_mgmt.reply;
1241 if (reply->IOCStatus != MPI_IOCSTATUS_SUCCESS) { 1170 if (reply->IOCStatus != MPI_IOCSTATUS_SUCCESS) {
1242 printk("%s: IOCStatus=0x%X IOCLogInfo=0x%X\n", 1171 printk(MYIOC_s_INFO_FMT "%s: IOCStatus=0x%X IOCLogInfo=0x%X\n",
1243 __FUNCTION__, 1172 ioc->name, __FUNCTION__, reply->IOCStatus, reply->IOCLogInfo);
1244 reply->IOCStatus,
1245 reply->IOCLogInfo);
1246 error = -ENXIO; 1173 error = -ENXIO;
1247 goto out_unlock; 1174 goto out_unlock;
1248 } 1175 }
@@ -1328,16 +1255,16 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
1328 u64 sas_address = 0; 1255 u64 sas_address = 0;
1329 1256
1330 if (!rsp) { 1257 if (!rsp) {
1331 printk(KERN_ERR "%s: the smp response space is missing\n", 1258 printk(MYIOC_s_ERR_FMT "%s: the smp response space is missing\n",
1332 __FUNCTION__); 1259 ioc->name, __FUNCTION__);
1333 return -EINVAL; 1260 return -EINVAL;
1334 } 1261 }
1335 1262
1336 /* do we need to support multiple segments? */ 1263 /* do we need to support multiple segments? */
1337 if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) { 1264 if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) {
1338 printk(KERN_ERR "%s: multiple segments req %u %u, rsp %u %u\n", 1265 printk(MYIOC_s_ERR_FMT "%s: multiple segments req %u %u, rsp %u %u\n",
1339 __FUNCTION__, req->bio->bi_vcnt, req->data_len, 1266 ioc->name, __FUNCTION__, req->bio->bi_vcnt, req->data_len,
1340 rsp->bio->bi_vcnt, rsp->data_len); 1267 rsp->bio->bi_vcnt, rsp->data_len);
1341 return -EINVAL; 1268 return -EINVAL;
1342 } 1269 }
1343 1270
@@ -1402,7 +1329,7 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
1402 1329
1403 timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, 10 * HZ); 1330 timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, 10 * HZ);
1404 if (!timeleft) { 1331 if (!timeleft) {
1405 printk(KERN_ERR "%s: smp timeout!\n", __FUNCTION__); 1332 printk(MYIOC_s_ERR_FMT "%s: smp timeout!\n", ioc->name, __FUNCTION__);
1406 /* On timeout reset the board */ 1333 /* On timeout reset the board */
1407 mpt_HardResetHandler(ioc, CAN_SLEEP); 1334 mpt_HardResetHandler(ioc, CAN_SLEEP);
1408 ret = -ETIMEDOUT; 1335 ret = -ETIMEDOUT;
@@ -1417,8 +1344,8 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
1417 memcpy(req->sense, smprep, sizeof(*smprep)); 1344 memcpy(req->sense, smprep, sizeof(*smprep));
1418 req->sense_len = sizeof(*smprep); 1345 req->sense_len = sizeof(*smprep);
1419 } else { 1346 } else {
1420 printk(KERN_ERR "%s: smp passthru reply failed to be returned\n", 1347 printk(MYIOC_s_ERR_FMT "%s: smp passthru reply failed to be returned\n",
1421 __FUNCTION__); 1348 ioc->name, __FUNCTION__);
1422 ret = -ENXIO; 1349 ret = -ENXIO;
1423 } 1350 }
1424unmap: 1351unmap:
@@ -2062,12 +1989,12 @@ static int mptsas_probe_one_phy(struct device *dev,
2062 goto out; 1989 goto out;
2063 } 1990 }
2064 mptsas_set_port(ioc, phy_info, port); 1991 mptsas_set_port(ioc, phy_info, port);
2065 dsaswideprintk(ioc, printk(KERN_DEBUG 1992 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2066 "sas_port_alloc: port=%p dev=%p port_id=%d\n", 1993 "sas_port_alloc: port=%p dev=%p port_id=%d\n",
2067 port, dev, port->port_identifier)); 1994 ioc->name, port, dev, port->port_identifier));
2068 } 1995 }
2069 dsaswideprintk(ioc, printk(KERN_DEBUG "sas_port_add_phy: phy_id=%d\n", 1996 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_port_add_phy: phy_id=%d\n",
2070 phy_info->phy_id)); 1997 ioc->name, phy_info->phy_id));
2071 sas_port_add_phy(port, phy_info->phy); 1998 sas_port_add_phy(port, phy_info->phy);
2072 phy_info->sas_port_add_phy = 0; 1999 phy_info->sas_port_add_phy = 0;
2073 } 2000 }
@@ -2369,8 +2296,9 @@ mptsas_delete_expander_phys(MPT_ADAPTER *ioc)
2369 expander_sas_address) 2296 expander_sas_address)
2370 continue; 2297 continue;
2371 dsaswideprintk(ioc, 2298 dsaswideprintk(ioc,
2372 dev_printk(KERN_DEBUG, &port->dev, 2299 dev_printk(KERN_DEBUG, &port->dev,
2373 "delete port (%d)\n", port->port_identifier)); 2300 MYIOC_s_FMT "delete port (%d)\n", ioc->name,
2301 port->port_identifier));
2374 sas_port_delete(port); 2302 sas_port_delete(port);
2375 mptsas_port_delete(ioc, phy_info->port_details); 2303 mptsas_port_delete(ioc, phy_info->port_details);
2376 } 2304 }
@@ -2613,7 +2541,7 @@ mptsas_adding_inactive_raid_components(MPT_ADAPTER *ioc, u8 channel, u8 id)
2613 2541
2614 ev = kzalloc(sizeof(*ev), GFP_ATOMIC); 2542 ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
2615 if (!ev) { 2543 if (!ev) {
2616 printk(KERN_WARNING "mptsas: lost hotplug event\n"); 2544 printk(MYIOC_s_WARN_FMT "mptsas: lost hotplug event\n", ioc->name);
2617 goto out; 2545 goto out;
2618 } 2546 }
2619 2547
@@ -2754,8 +2682,8 @@ mptsas_hotplug_work(struct work_struct *work)
2754 printk(MYIOC_s_INFO_FMT 2682 printk(MYIOC_s_INFO_FMT
2755 "removing %s device, channel %d, id %d, phy %d\n", 2683 "removing %s device, channel %d, id %d, phy %d\n",
2756 ioc->name, ds, ev->channel, ev->id, phy_info->phy_id); 2684 ioc->name, ds, ev->channel, ev->id, phy_info->phy_id);
2757 dev_printk(KERN_DEBUG, &port->dev, 2685 dev_printk(KERN_DEBUG, &port->dev, MYIOC_s_FMT
2758 "delete port (%d)\n", port->port_identifier); 2686 "delete port (%d)\n", ioc->name, port->port_identifier);
2759 sas_port_delete(port); 2687 sas_port_delete(port);
2760 mptsas_port_delete(ioc, phy_info->port_details); 2688 mptsas_port_delete(ioc, phy_info->port_details);
2761 break; 2689 break;
@@ -2796,8 +2724,8 @@ mptsas_hotplug_work(struct work_struct *work)
2796 2724
2797 if (!vtarget) { 2725 if (!vtarget) {
2798 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2726 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2799 "%s: exit at line=%d\n", ioc->name, 2727 "%s: exit at line=%d\n", ioc->name,
2800 __FUNCTION__, __LINE__)); 2728 __FUNCTION__, __LINE__));
2801 break; 2729 break;
2802 } 2730 }
2803 /* 2731 /*
@@ -2930,7 +2858,7 @@ mptsas_send_sas_event(MPT_ADAPTER *ioc,
2930 case MPI_EVENT_SAS_DEV_STAT_RC_ADDED: 2858 case MPI_EVENT_SAS_DEV_STAT_RC_ADDED:
2931 ev = kzalloc(sizeof(*ev), GFP_ATOMIC); 2859 ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
2932 if (!ev) { 2860 if (!ev) {
2933 printk(KERN_WARNING "mptsas: lost hotplug event\n"); 2861 printk(MYIOC_s_WARN_FMT "lost hotplug event\n", ioc->name);
2934 break; 2862 break;
2935 } 2863 }
2936 2864
@@ -2989,7 +2917,7 @@ mptsas_send_raid_event(MPT_ADAPTER *ioc,
2989 2917
2990 ev = kzalloc(sizeof(*ev), GFP_ATOMIC); 2918 ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
2991 if (!ev) { 2919 if (!ev) {
2992 printk(KERN_WARNING "mptsas: lost hotplug event\n"); 2920 printk(MYIOC_s_WARN_FMT "lost hotplug event\n", ioc->name);
2993 return; 2921 return;
2994 } 2922 }
2995 2923
@@ -3288,20 +3216,22 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
3288 sh->sg_tablesize = numSGE; 3216 sh->sg_tablesize = numSGE;
3289 } 3217 }
3290 3218
3291 hd = (MPT_SCSI_HOST *) sh->hostdata; 3219 hd = shost_priv(sh);
3292 hd->ioc = ioc; 3220 hd->ioc = ioc;
3293 3221
3294 /* SCSI needs scsi_cmnd lookup table! 3222 /* SCSI needs scsi_cmnd lookup table!
3295 * (with size equal to req_depth*PtrSz!) 3223 * (with size equal to req_depth*PtrSz!)
3296 */ 3224 */
3297 hd->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC); 3225 ioc->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC);
3298 if (!hd->ScsiLookup) { 3226 if (!ioc->ScsiLookup) {
3299 error = -ENOMEM; 3227 error = -ENOMEM;
3228 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
3300 goto out_mptsas_probe; 3229 goto out_mptsas_probe;
3301 } 3230 }
3231 spin_lock_init(&ioc->scsi_lookup_lock);
3302 3232
3303 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScsiLookup @ %p\n", 3233 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScsiLookup @ %p\n",
3304 ioc->name, hd->ScsiLookup)); 3234 ioc->name, ioc->ScsiLookup));
3305 3235
3306 /* Clear the TM flags 3236 /* Clear the TM flags
3307 */ 3237 */
@@ -3340,8 +3270,8 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
3340 3270
3341 error = scsi_add_host(sh, &ioc->pcidev->dev); 3271 error = scsi_add_host(sh, &ioc->pcidev->dev);
3342 if (error) { 3272 if (error) {
3343 dprintk(ioc, printk(KERN_ERR MYNAM 3273 dprintk(ioc, printk(MYIOC_s_ERR_FMT
3344 "scsi_add_host failed\n")); 3274 "scsi_add_host failed\n", ioc->name));
3345 goto out_mptsas_probe; 3275 goto out_mptsas_probe;
3346 } 3276 }
3347 3277