aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-01-04 19:30:12 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-04 19:30:12 -0500
commitf61ea1b0c825a20a1826bb43a226387091934586 (patch)
treefdedf0a2368f707e3fd5205db05bfcbac79606ec /drivers/message
parentd347da0deffa1d8f88f0d270eab040e4707c9916 (diff)
parent7b32b8e018d8f8cc94c808a5fa84a3f889441b91 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
Diffstat (limited to 'drivers/message')
-rw-r--r--drivers/message/fusion/mptbase.c14
-rw-r--r--drivers/message/fusion/mptbase.h34
-rw-r--r--drivers/message/fusion/mptctl.c4
-rw-r--r--drivers/message/fusion/mptfc.c24
-rw-r--r--drivers/message/fusion/mptsas.c55
-rw-r--r--drivers/message/fusion/mptscsih.c968
-rw-r--r--drivers/message/fusion/mptscsih.h2
-rw-r--r--drivers/message/fusion/mptspi.c24
8 files changed, 567 insertions, 558 deletions
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 4262a22adc22..537836068c49 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -313,13 +313,13 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
313 u32 log_info = le32_to_cpu(mr->u.reply.IOCLogInfo); 313 u32 log_info = le32_to_cpu(mr->u.reply.IOCLogInfo);
314 if (ioc->bus_type == FC) 314 if (ioc->bus_type == FC)
315 mpt_fc_log_info(ioc, log_info); 315 mpt_fc_log_info(ioc, log_info);
316 else if (ioc->bus_type == SCSI) 316 else if (ioc->bus_type == SPI)
317 mpt_sp_log_info(ioc, log_info); 317 mpt_sp_log_info(ioc, log_info);
318 else if (ioc->bus_type == SAS) 318 else if (ioc->bus_type == SAS)
319 mpt_sas_log_info(ioc, log_info); 319 mpt_sas_log_info(ioc, log_info);
320 } 320 }
321 if (ioc_stat & MPI_IOCSTATUS_MASK) { 321 if (ioc_stat & MPI_IOCSTATUS_MASK) {
322 if (ioc->bus_type == SCSI && 322 if (ioc->bus_type == SPI &&
323 cb_idx != mpt_stm_index && 323 cb_idx != mpt_stm_index &&
324 cb_idx != mpt_lan_index) 324 cb_idx != mpt_lan_index)
325 mpt_sp_ioc_info(ioc, (u32)ioc_stat, mf); 325 mpt_sp_ioc_info(ioc, (u32)ioc_stat, mf);
@@ -1376,7 +1376,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1376 } 1376 }
1377 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_53C1030) { 1377 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_53C1030) {
1378 ioc->prod_name = "LSI53C1030"; 1378 ioc->prod_name = "LSI53C1030";
1379 ioc->bus_type = SCSI; 1379 ioc->bus_type = SPI;
1380 /* 1030 Chip Fix. Disable Split transactions 1380 /* 1030 Chip Fix. Disable Split transactions
1381 * for PCIX. Set MOST bits to zero if Rev < C0( = 8). 1381 * for PCIX. Set MOST bits to zero if Rev < C0( = 8).
1382 */ 1382 */
@@ -1389,7 +1389,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1389 } 1389 }
1390 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_1030_53C1035) { 1390 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_1030_53C1035) {
1391 ioc->prod_name = "LSI53C1035"; 1391 ioc->prod_name = "LSI53C1035";
1392 ioc->bus_type = SCSI; 1392 ioc->bus_type = SPI;
1393 } 1393 }
1394 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1064) { 1394 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1064) {
1395 ioc->prod_name = "LSISAS1064"; 1395 ioc->prod_name = "LSISAS1064";
@@ -3042,7 +3042,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3042 /* Clear the internal flash bad bit - autoincrementing register, 3042 /* Clear the internal flash bad bit - autoincrementing register,
3043 * so must do two writes. 3043 * so must do two writes.
3044 */ 3044 */
3045 if (ioc->bus_type == SCSI) { 3045 if (ioc->bus_type == SPI) {
3046 /* 3046 /*
3047 * 1030 and 1035 H/W errata, workaround to access 3047 * 1030 and 1035 H/W errata, workaround to access
3048 * the ClearFlashBadSignatureBit 3048 * the ClearFlashBadSignatureBit
@@ -3152,7 +3152,7 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag)
3152 int cnt,cntdn; 3152 int cnt,cntdn;
3153 3153
3154 dinitprintk((KERN_WARNING MYNAM ": KickStarting %s!\n", ioc->name)); 3154 dinitprintk((KERN_WARNING MYNAM ": KickStarting %s!\n", ioc->name));
3155 if (ioc->bus_type == SCSI) { 3155 if (ioc->bus_type == SPI) {
3156 /* Always issue a Msg Unit Reset first. This will clear some 3156 /* Always issue a Msg Unit Reset first. This will clear some
3157 * SCSI bus hang conditions. 3157 * SCSI bus hang conditions.
3158 */ 3158 */
@@ -3580,7 +3580,7 @@ initChainBuffers(MPT_ADAPTER *ioc)
3580 dinitprintk((KERN_INFO MYNAM ": %s Now numSGE=%d num_sge=%d num_chain=%d\n", 3580 dinitprintk((KERN_INFO MYNAM ": %s Now numSGE=%d num_sge=%d num_chain=%d\n",
3581 ioc->name, numSGE, num_sge, num_chain)); 3581 ioc->name, numSGE, num_sge, num_chain));
3582 3582
3583 if (ioc->bus_type == SCSI) 3583 if (ioc->bus_type == SPI)
3584 num_chain *= MPT_SCSI_CAN_QUEUE; 3584 num_chain *= MPT_SCSI_CAN_QUEUE;
3585 else 3585 else
3586 num_chain *= MPT_FC_CAN_QUEUE; 3586 num_chain *= MPT_FC_CAN_QUEUE;
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index bac8eb4186d2..6c48d1f54ac9 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -76,8 +76,8 @@
76#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR 76#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR
77#endif 77#endif
78 78
79#define MPT_LINUX_VERSION_COMMON "3.03.04" 79#define MPT_LINUX_VERSION_COMMON "3.03.05"
80#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.04" 80#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.05"
81#define WHAT_MAGIC_STRING "@" "(" "#" ")" 81#define WHAT_MAGIC_STRING "@" "(" "#" ")"
82 82
83#define show_mptmod_ver(s,ver) \ 83#define show_mptmod_ver(s,ver) \
@@ -321,7 +321,7 @@ typedef struct _SYSIF_REGS
321 * Dynamic Multi-Pathing specific stuff... 321 * Dynamic Multi-Pathing specific stuff...
322 */ 322 */
323 323
324/* VirtDevice negoFlags field */ 324/* VirtTarget negoFlags field */
325#define MPT_TARGET_NO_NEGO_WIDE 0x01 325#define MPT_TARGET_NO_NEGO_WIDE 0x01
326#define MPT_TARGET_NO_NEGO_SYNC 0x02 326#define MPT_TARGET_NO_NEGO_SYNC 0x02
327#define MPT_TARGET_NO_NEGO_QAS 0x04 327#define MPT_TARGET_NO_NEGO_QAS 0x04
@@ -330,8 +330,7 @@ typedef struct _SYSIF_REGS
330/* 330/*
331 * VirtDevice - FC LUN device or SCSI target device 331 * VirtDevice - FC LUN device or SCSI target device
332 */ 332 */
333typedef struct _VirtDevice { 333typedef struct _VirtTarget {
334 struct scsi_device *device;
335 u8 tflags; 334 u8 tflags;
336 u8 ioc_id; 335 u8 ioc_id;
337 u8 target_id; 336 u8 target_id;
@@ -342,21 +341,18 @@ typedef struct _VirtDevice {
342 u8 negoFlags; /* bit field, see above */ 341 u8 negoFlags; /* bit field, see above */
343 u8 raidVolume; /* set, if RAID Volume */ 342 u8 raidVolume; /* set, if RAID Volume */
344 u8 type; /* byte 0 of Inquiry data */ 343 u8 type; /* byte 0 of Inquiry data */
345 u8 cflags; /* controller flags */
346 u8 rsvd1raid;
347 u16 fc_phys_lun;
348 u16 fc_xlat_lun;
349 u32 num_luns; 344 u32 num_luns;
350 u32 luns[8]; /* Max LUNs is 256 */ 345 u32 luns[8]; /* Max LUNs is 256 */
351 u8 pad[4];
352 u8 inq_data[8]; 346 u8 inq_data[8];
353 /* IEEE Registered Extended Identifier 347} VirtTarget;
354 obtained via INQUIRY VPD page 0x83 */ 348
355 /* NOTE: Do not separate uniq_prepad and uniq_data 349typedef struct _VirtDevice {
356 as they are treateed as a single entity in the code */ 350 VirtTarget *vtarget;
357 u8 uniq_prepad[8]; 351 u8 ioc_id;
358 u8 uniq_data[20]; 352 u8 bus_id;
359 u8 pad2[4]; 353 u8 target_id;
354 u8 configured_lun;
355 u32 lun;
360} VirtDevice; 356} VirtDevice;
361 357
362/* 358/*
@@ -903,7 +899,7 @@ typedef struct _MPT_LOCAL_REPLY {
903 899
904typedef enum { 900typedef enum {
905 FC, 901 FC,
906 SCSI, 902 SPI,
907 SAS 903 SAS
908} BUS_TYPE; 904} BUS_TYPE;
909 905
@@ -912,7 +908,7 @@ typedef struct _MPT_SCSI_HOST {
912 int port; 908 int port;
913 u32 pad0; 909 u32 pad0;
914 struct scsi_cmnd **ScsiLookup; 910 struct scsi_cmnd **ScsiLookup;
915 VirtDevice **Targets; 911 VirtTarget **Targets;
916 MPT_LOCAL_REPLY *pLocal; /* used for internal commands */ 912 MPT_LOCAL_REPLY *pLocal; /* used for internal commands */
917 struct timer_list timer; 913 struct timer_list timer;
918 /* Pool of memory for holding SCpnts before doing 914 /* Pool of memory for holding SCpnts before doing
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index 602138f8544d..959d2c5951b8 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -1245,7 +1245,7 @@ mptctl_gettargetinfo (unsigned long arg)
1245 MPT_ADAPTER *ioc; 1245 MPT_ADAPTER *ioc;
1246 struct Scsi_Host *sh; 1246 struct Scsi_Host *sh;
1247 MPT_SCSI_HOST *hd; 1247 MPT_SCSI_HOST *hd;
1248 VirtDevice *vdev; 1248 VirtTarget *vdev;
1249 char *pmem; 1249 char *pmem;
1250 int *pdata; 1250 int *pdata;
1251 IOCPage2_t *pIoc2; 1251 IOCPage2_t *pIoc2;
@@ -1822,7 +1822,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr)
1822 case MPI_FUNCTION_SCSI_IO_REQUEST: 1822 case MPI_FUNCTION_SCSI_IO_REQUEST:
1823 if (ioc->sh) { 1823 if (ioc->sh) {
1824 SCSIIORequest_t *pScsiReq = (SCSIIORequest_t *) mf; 1824 SCSIIORequest_t *pScsiReq = (SCSIIORequest_t *) mf;
1825 VirtDevice *pTarget = NULL; 1825 VirtTarget *pTarget = NULL;
1826 MPT_SCSI_HOST *hd = NULL; 1826 MPT_SCSI_HOST *hd = NULL;
1827 int qtag = MPI_SCSIIO_CONTROL_UNTAGGED; 1827 int qtag = MPI_SCSIIO_CONTROL_UNTAGGED;
1828 int scsidir = 0; 1828 int scsidir = 0;
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index a628be9bbbad..ba61e1828858 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -84,13 +84,16 @@ static int mptfcTaskCtx = -1;
84static int mptfcInternalCtx = -1; /* Used only for internal commands */ 84static int mptfcInternalCtx = -1; /* Used only for internal commands */
85 85
86static struct scsi_host_template mptfc_driver_template = { 86static struct scsi_host_template mptfc_driver_template = {
87 .module = THIS_MODULE,
87 .proc_name = "mptfc", 88 .proc_name = "mptfc",
88 .proc_info = mptscsih_proc_info, 89 .proc_info = mptscsih_proc_info,
89 .name = "MPT FC Host", 90 .name = "MPT FC Host",
90 .info = mptscsih_info, 91 .info = mptscsih_info,
91 .queuecommand = mptscsih_qcmd, 92 .queuecommand = mptscsih_qcmd,
93 .target_alloc = mptscsih_target_alloc,
92 .slave_alloc = mptscsih_slave_alloc, 94 .slave_alloc = mptscsih_slave_alloc,
93 .slave_configure = mptscsih_slave_configure, 95 .slave_configure = mptscsih_slave_configure,
96 .target_destroy = mptscsih_target_destroy,
94 .slave_destroy = mptscsih_slave_destroy, 97 .slave_destroy = mptscsih_slave_destroy,
95 .change_queue_depth = mptscsih_change_queue_depth, 98 .change_queue_depth = mptscsih_change_queue_depth,
96 .eh_abort_handler = mptscsih_abort, 99 .eh_abort_handler = mptscsih_abort,
@@ -167,13 +170,15 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
167 printk(MYIOC_s_WARN_FMT 170 printk(MYIOC_s_WARN_FMT
168 "Skipping because it's not operational!\n", 171 "Skipping because it's not operational!\n",
169 ioc->name); 172 ioc->name);
170 return -ENODEV; 173 error = -ENODEV;
174 goto out_mptfc_probe;
171 } 175 }
172 176
173 if (!ioc->active) { 177 if (!ioc->active) {
174 printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n", 178 printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n",
175 ioc->name); 179 ioc->name);
176 return -ENODEV; 180 error = -ENODEV;
181 goto out_mptfc_probe;
177 } 182 }
178 183
179 /* Sanity check - ensure at least 1 port is INITIATOR capable 184 /* Sanity check - ensure at least 1 port is INITIATOR capable
@@ -198,7 +203,8 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
198 printk(MYIOC_s_WARN_FMT 203 printk(MYIOC_s_WARN_FMT
199 "Unable to register controller with SCSI subsystem\n", 204 "Unable to register controller with SCSI subsystem\n",
200 ioc->name); 205 ioc->name);
201 return -1; 206 error = -1;
207 goto out_mptfc_probe;
202 } 208 }
203 209
204 spin_lock_irqsave(&ioc->FreeQlock, flags); 210 spin_lock_irqsave(&ioc->FreeQlock, flags);
@@ -266,7 +272,7 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
266 mem = kmalloc(sz, GFP_ATOMIC); 272 mem = kmalloc(sz, GFP_ATOMIC);
267 if (mem == NULL) { 273 if (mem == NULL) {
268 error = -ENOMEM; 274 error = -ENOMEM;
269 goto mptfc_probe_failed; 275 goto out_mptfc_probe;
270 } 276 }
271 277
272 memset(mem, 0, sz); 278 memset(mem, 0, sz);
@@ -284,14 +290,14 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
284 mem = kmalloc(sz, GFP_ATOMIC); 290 mem = kmalloc(sz, GFP_ATOMIC);
285 if (mem == NULL) { 291 if (mem == NULL) {
286 error = -ENOMEM; 292 error = -ENOMEM;
287 goto mptfc_probe_failed; 293 goto out_mptfc_probe;
288 } 294 }
289 295
290 memset(mem, 0, sz); 296 memset(mem, 0, sz);
291 hd->Targets = (VirtDevice **) mem; 297 hd->Targets = (VirtTarget **) mem;
292 298
293 dprintk((KERN_INFO 299 dprintk((KERN_INFO
294 " Targets @ %p, sz=%d\n", hd->Targets, sz)); 300 " vdev @ %p, sz=%d\n", hd->Targets, sz));
295 301
296 /* Clear the TM flags 302 /* Clear the TM flags
297 */ 303 */
@@ -330,13 +336,13 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
330 if(error) { 336 if(error) {
331 dprintk((KERN_ERR MYNAM 337 dprintk((KERN_ERR MYNAM
332 "scsi_add_host failed\n")); 338 "scsi_add_host failed\n"));
333 goto mptfc_probe_failed; 339 goto out_mptfc_probe;
334 } 340 }
335 341
336 scsi_scan_host(sh); 342 scsi_scan_host(sh);
337 return 0; 343 return 0;
338 344
339mptfc_probe_failed: 345out_mptfc_probe:
340 346
341 mptscsih_remove(pdev); 347 mptscsih_remove(pdev);
342 return error; 348 return error;
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index e0a8bb8ba7d8..17e9757e728b 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -228,31 +228,35 @@ static void mptsas_print_expander_pg1(SasExpanderPage1_t *pg1)
228 * implement ->target_alloc. 228 * implement ->target_alloc.
229 */ 229 */
230static int 230static int
231mptsas_slave_alloc(struct scsi_device *device) 231mptsas_slave_alloc(struct scsi_device *sdev)
232{ 232{
233 struct Scsi_Host *host = device->host; 233 struct Scsi_Host *host = sdev->host;
234 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 234 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
235 struct sas_rphy *rphy; 235 struct sas_rphy *rphy;
236 struct mptsas_portinfo *p; 236 struct mptsas_portinfo *p;
237 VirtTarget *vtarget;
237 VirtDevice *vdev; 238 VirtDevice *vdev;
238 uint target = device->id; 239 struct scsi_target *starget;
239 int i; 240 int i;
240 241
241 if ((vdev = hd->Targets[target]) != NULL)
242 goto out;
243
244 vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL); 242 vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL);
245 if (!vdev) { 243 if (!vdev) {
246 printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", 244 printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n",
247 hd->ioc->name, sizeof(VirtDevice)); 245 hd->ioc->name, sizeof(VirtDevice));
248 return -ENOMEM; 246 return -ENOMEM;
249 } 247 }
250
251 memset(vdev, 0, sizeof(VirtDevice)); 248 memset(vdev, 0, sizeof(VirtDevice));
252 vdev->tflags = MPT_TARGET_FLAGS_Q_YES|MPT_TARGET_FLAGS_VALID_INQUIRY;
253 vdev->ioc_id = hd->ioc->id; 249 vdev->ioc_id = hd->ioc->id;
250 sdev->hostdata = vdev;
251 starget = scsi_target(sdev);
252 vtarget = starget->hostdata;
253 vdev->vtarget = vtarget;
254 if (vtarget->num_luns == 0) {
255 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES|MPT_TARGET_FLAGS_VALID_INQUIRY;
256 hd->Targets[sdev->id] = vtarget;
257 }
254 258
255 rphy = dev_to_rphy(device->sdev_target->dev.parent); 259 rphy = dev_to_rphy(sdev->sdev_target->dev.parent);
256 list_for_each_entry(p, &hd->ioc->sas_topology, list) { 260 list_for_each_entry(p, &hd->ioc->sas_topology, list) {
257 for (i = 0; i < p->num_phys; i++) { 261 for (i = 0; i < p->num_phys; i++) {
258 if (p->phy_info[i].attached.sas_address == 262 if (p->phy_info[i].attached.sas_address ==
@@ -260,7 +264,7 @@ mptsas_slave_alloc(struct scsi_device *device)
260 vdev->target_id = 264 vdev->target_id =
261 p->phy_info[i].attached.target; 265 p->phy_info[i].attached.target;
262 vdev->bus_id = p->phy_info[i].attached.bus; 266 vdev->bus_id = p->phy_info[i].attached.bus;
263 hd->Targets[device->id] = vdev; 267 vdev->lun = sdev->lun;
264 goto out; 268 goto out;
265 } 269 }
266 } 270 }
@@ -271,19 +275,24 @@ mptsas_slave_alloc(struct scsi_device *device)
271 return -ENODEV; 275 return -ENODEV;
272 276
273 out: 277 out:
274 vdev->num_luns++; 278 vtarget->ioc_id = vdev->ioc_id;
275 device->hostdata = vdev; 279 vtarget->target_id = vdev->target_id;
280 vtarget->bus_id = vdev->bus_id;
281 vtarget->num_luns++;
276 return 0; 282 return 0;
277} 283}
278 284
279static struct scsi_host_template mptsas_driver_template = { 285static struct scsi_host_template mptsas_driver_template = {
286 .module = THIS_MODULE,
280 .proc_name = "mptsas", 287 .proc_name = "mptsas",
281 .proc_info = mptscsih_proc_info, 288 .proc_info = mptscsih_proc_info,
282 .name = "MPT SPI Host", 289 .name = "MPT SPI Host",
283 .info = mptscsih_info, 290 .info = mptscsih_info,
284 .queuecommand = mptscsih_qcmd, 291 .queuecommand = mptscsih_qcmd,
292 .target_alloc = mptscsih_target_alloc,
285 .slave_alloc = mptsas_slave_alloc, 293 .slave_alloc = mptsas_slave_alloc,
286 .slave_configure = mptscsih_slave_configure, 294 .slave_configure = mptscsih_slave_configure,
295 .target_destroy = mptscsih_target_destroy,
287 .slave_destroy = mptscsih_slave_destroy, 296 .slave_destroy = mptscsih_slave_destroy,
288 .change_queue_depth = mptscsih_change_queue_depth, 297 .change_queue_depth = mptscsih_change_queue_depth,
289 .eh_abort_handler = mptscsih_abort, 298 .eh_abort_handler = mptscsih_abort,
@@ -986,7 +995,6 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc, int *index)
986 goto out_free_port_info; 995 goto out_free_port_info;
987 996
988 list_add_tail(&port_info->list, &ioc->sas_topology); 997 list_add_tail(&port_info->list, &ioc->sas_topology);
989
990 for (i = 0; i < port_info->num_phys; i++) { 998 for (i = 0; i < port_info->num_phys; i++) {
991 mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i], 999 mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i],
992 (MPI_SAS_PHY_PGAD_FORM_PHY_NUMBER << 1000 (MPI_SAS_PHY_PGAD_FORM_PHY_NUMBER <<
@@ -1133,13 +1141,15 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1133 printk(MYIOC_s_WARN_FMT 1141 printk(MYIOC_s_WARN_FMT
1134 "Skipping because it's not operational!\n", 1142 "Skipping because it's not operational!\n",
1135 ioc->name); 1143 ioc->name);
1136 return -ENODEV; 1144 error = -ENODEV;
1145 goto out_mptsas_probe;
1137 } 1146 }
1138 1147
1139 if (!ioc->active) { 1148 if (!ioc->active) {
1140 printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n", 1149 printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n",
1141 ioc->name); 1150 ioc->name);
1142 return -ENODEV; 1151 error = -ENODEV;
1152 goto out_mptsas_probe;
1143 } 1153 }
1144 1154
1145 /* Sanity check - ensure at least 1 port is INITIATOR capable 1155 /* Sanity check - ensure at least 1 port is INITIATOR capable
@@ -1163,7 +1173,8 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1163 printk(MYIOC_s_WARN_FMT 1173 printk(MYIOC_s_WARN_FMT
1164 "Unable to register controller with SCSI subsystem\n", 1174 "Unable to register controller with SCSI subsystem\n",
1165 ioc->name); 1175 ioc->name);
1166 return -1; 1176 error = -1;
1177 goto out_mptsas_probe;
1167 } 1178 }
1168 1179
1169 spin_lock_irqsave(&ioc->FreeQlock, flags); 1180 spin_lock_irqsave(&ioc->FreeQlock, flags);
@@ -1237,7 +1248,7 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1237 mem = kmalloc(sz, GFP_ATOMIC); 1248 mem = kmalloc(sz, GFP_ATOMIC);
1238 if (mem == NULL) { 1249 if (mem == NULL) {
1239 error = -ENOMEM; 1250 error = -ENOMEM;
1240 goto mptsas_probe_failed; 1251 goto out_mptsas_probe;
1241 } 1252 }
1242 1253
1243 memset(mem, 0, sz); 1254 memset(mem, 0, sz);
@@ -1255,14 +1266,14 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1255 mem = kmalloc(sz, GFP_ATOMIC); 1266 mem = kmalloc(sz, GFP_ATOMIC);
1256 if (mem == NULL) { 1267 if (mem == NULL) {
1257 error = -ENOMEM; 1268 error = -ENOMEM;
1258 goto mptsas_probe_failed; 1269 goto out_mptsas_probe;
1259 } 1270 }
1260 1271
1261 memset(mem, 0, sz); 1272 memset(mem, 0, sz);
1262 hd->Targets = (VirtDevice **) mem; 1273 hd->Targets = (VirtTarget **) mem;
1263 1274
1264 dprintk((KERN_INFO 1275 dprintk((KERN_INFO
1265 " Targets @ %p, sz=%d\n", hd->Targets, sz)); 1276 " vtarget @ %p, sz=%d\n", hd->Targets, sz));
1266 1277
1267 /* Clear the TM flags 1278 /* Clear the TM flags
1268 */ 1279 */
@@ -1308,14 +1319,14 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1308 if (error) { 1319 if (error) {
1309 dprintk((KERN_ERR MYNAM 1320 dprintk((KERN_ERR MYNAM
1310 "scsi_add_host failed\n")); 1321 "scsi_add_host failed\n"));
1311 goto mptsas_probe_failed; 1322 goto out_mptsas_probe;
1312 } 1323 }
1313 1324
1314 mptsas_scan_sas_topology(ioc); 1325 mptsas_scan_sas_topology(ioc);
1315 1326
1316 return 0; 1327 return 0;
1317 1328
1318mptsas_probe_failed: 1329out_mptsas_probe:
1319 1330
1320 mptscsih_remove(pdev); 1331 mptscsih_remove(pdev);
1321 return error; 1332 return error;
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index b7b9846ff3fd..93a16fa3c4ba 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -150,28 +150,29 @@ static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 tar
150int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset); 150int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset);
151int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply); 151int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply);
152 152
153static void mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *data, int dlen); 153static void mptscsih_initTarget(MPT_SCSI_HOST *hd, VirtTarget *vtarget, u8 lun, char *data, int dlen);
154static void mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56); 154static void mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *vtarget, char byte56);
155static void mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq);
156static void mptscsih_setDevicePage1Flags (u8 width, u8 factor, u8 offset, int *requestedPtr, int *configurationPtr, u8 flags); 155static void mptscsih_setDevicePage1Flags (u8 width, u8 factor, u8 offset, int *requestedPtr, int *configurationPtr, u8 flags);
157static void mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id); 156static void mptscsih_no_negotiate(MPT_SCSI_HOST *hd, struct scsi_cmnd *sc);
158static int mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target, int flags); 157static int mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target, int flags);
159static int mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus); 158static int mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus);
160int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); 159int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
161static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd); 160static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd);
162static int mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum); 161static void mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice);
162static void mptscsih_negotiate_to_asyn_narrow(MPT_SCSI_HOST *hd, VirtTarget *vtarget);
163static int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id);
163 164
164static struct work_struct mptscsih_persistTask; 165static struct work_struct mptscsih_persistTask;
165 166
166#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION 167#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
167static int mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io); 168static int mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io);
168static void mptscsih_domainValidation(void *hd); 169static void mptscsih_domainValidation(void *hd);
169static int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id);
170static void mptscsih_qas_check(MPT_SCSI_HOST *hd, int id); 170static void mptscsih_qas_check(MPT_SCSI_HOST *hd, int id);
171static int mptscsih_doDv(MPT_SCSI_HOST *hd, int channel, int target); 171static int mptscsih_doDv(MPT_SCSI_HOST *hd, int channel, int target);
172static void mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage); 172static void mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage);
173static void mptscsih_fillbuf(char *buffer, int size, int index, int width); 173static void mptscsih_fillbuf(char *buffer, int size, int index, int width);
174static void mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id); 174static void mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id);
175static void mptscsih_set_dvflags(MPT_SCSI_HOST *hd, struct scsi_cmnd *sc);
175#endif 176#endif
176 177
177void mptscsih_remove(struct pci_dev *); 178void mptscsih_remove(struct pci_dev *);
@@ -627,7 +628,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
627 dreplyprintk((KERN_NOTICE "Reply ha=%d id=%d lun=%d:\n" 628 dreplyprintk((KERN_NOTICE "Reply ha=%d id=%d lun=%d:\n"
628 "IOCStatus=%04xh SCSIState=%02xh SCSIStatus=%02xh\n" 629 "IOCStatus=%04xh SCSIState=%02xh SCSIStatus=%02xh\n"
629 "resid=%d bufflen=%d xfer_cnt=%d\n", 630 "resid=%d bufflen=%d xfer_cnt=%d\n",
630 ioc->id, pScsiReq->TargetID, pScsiReq->LUN[1], 631 ioc->id, sc->device->id, sc->device->lun,
631 status, scsi_state, scsi_status, sc->resid, 632 status, scsi_state, scsi_status, sc->resid,
632 sc->request_bufflen, xfer_cnt)); 633 sc->request_bufflen, xfer_cnt));
633 634
@@ -641,7 +642,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
641 pScsiReply->ResponseInfo) { 642 pScsiReply->ResponseInfo) {
642 printk(KERN_NOTICE "ha=%d id=%d lun=%d: " 643 printk(KERN_NOTICE "ha=%d id=%d lun=%d: "
643 "FCP_ResponseInfo=%08xh\n", 644 "FCP_ResponseInfo=%08xh\n",
644 ioc->id, pScsiReq->TargetID, pScsiReq->LUN[1], 645 ioc->id, sc->device->id, sc->device->lun,
645 le32_to_cpu(pScsiReply->ResponseInfo)); 646 le32_to_cpu(pScsiReply->ResponseInfo));
646 } 647 }
647 648
@@ -677,8 +678,8 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
677 sc->result = DID_RESET << 16; 678 sc->result = DID_RESET << 16;
678 679
679 /* GEM Workaround. */ 680 /* GEM Workaround. */
680 if (ioc->bus_type == SCSI) 681 if (ioc->bus_type == SPI)
681 mptscsih_no_negotiate(hd, sc->device->id); 682 mptscsih_no_negotiate(hd, sc);
682 break; 683 break;
683 684
684 case MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH: /* 0x0049 */ 685 case MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH: /* 0x0049 */
@@ -892,16 +893,15 @@ mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd)
892 * when a lun is disable by mid-layer. 893 * when a lun is disable by mid-layer.
893 * Do NOT access the referenced scsi_cmnd structure or 894 * Do NOT access the referenced scsi_cmnd structure or
894 * members. Will cause either a paging or NULL ptr error. 895 * members. Will cause either a paging or NULL ptr error.
895 * @hd: Pointer to a SCSI HOST structure 896 * @hd: Pointer to a SCSI HOST structure
896 * @target: target id 897 * @vdevice: per device private data
897 * @lun: lun
898 * 898 *
899 * Returns: None. 899 * Returns: None.
900 * 900 *
901 * Called from slave_destroy. 901 * Called from slave_destroy.
902 */ 902 */
903static void 903static void
904mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, uint target, uint lun) 904mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
905{ 905{
906 SCSIIORequest_t *mf = NULL; 906 SCSIIORequest_t *mf = NULL;
907 int ii; 907 int ii;
@@ -909,7 +909,7 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, uint target, uint lun)
909 struct scsi_cmnd *sc; 909 struct scsi_cmnd *sc;
910 910
911 dsprintk((KERN_INFO MYNAM ": search_running target %d lun %d max %d\n", 911 dsprintk((KERN_INFO MYNAM ": search_running target %d lun %d max %d\n",
912 target, lun, max)); 912 vdevice->target_id, vdevice->lun, max));
913 913
914 for (ii=0; ii < max; ii++) { 914 for (ii=0; ii < max; ii++) {
915 if ((sc = hd->ScsiLookup[ii]) != NULL) { 915 if ((sc = hd->ScsiLookup[ii]) != NULL) {
@@ -919,7 +919,7 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, uint target, uint lun)
919 dsprintk(( "search_running: found (sc=%p, mf = %p) target %d, lun %d \n", 919 dsprintk(( "search_running: found (sc=%p, mf = %p) target %d, lun %d \n",
920 hd->ScsiLookup[ii], mf, mf->TargetID, mf->LUN[1])); 920 hd->ScsiLookup[ii], mf, mf->TargetID, mf->LUN[1]));
921 921
922 if ((mf->TargetID != ((u8)target)) || (mf->LUN[1] != ((u8) lun))) 922 if ((mf->TargetID != ((u8)vdevice->target_id)) || (mf->LUN[1] != ((u8) vdevice->lun)))
923 continue; 923 continue;
924 924
925 /* Cleanup 925 /* Cleanup
@@ -993,8 +993,10 @@ mptscsih_remove(struct pci_dev *pdev)
993 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 993 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
994 struct Scsi_Host *host = ioc->sh; 994 struct Scsi_Host *host = ioc->sh;
995 MPT_SCSI_HOST *hd; 995 MPT_SCSI_HOST *hd;
996#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
996 int count; 997 int count;
997 unsigned long flags; 998 unsigned long flags;
999#endif
998 int sz1; 1000 int sz1;
999 1001
1000 if(!host) { 1002 if(!host) {
@@ -1075,11 +1077,6 @@ mptscsih_shutdown(struct pci_dev *pdev)
1075 1077
1076 hd = (MPT_SCSI_HOST *)host->hostdata; 1078 hd = (MPT_SCSI_HOST *)host->hostdata;
1077 1079
1078 /* Flush the cache of this adapter
1079 */
1080 if(hd != NULL)
1081 mptscsih_synchronize_cache(hd, 0);
1082
1083} 1080}
1084 1081
1085#ifdef CONFIG_PM 1082#ifdef CONFIG_PM
@@ -1286,7 +1283,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1286 MPT_SCSI_HOST *hd; 1283 MPT_SCSI_HOST *hd;
1287 MPT_FRAME_HDR *mf; 1284 MPT_FRAME_HDR *mf;
1288 SCSIIORequest_t *pScsiReq; 1285 SCSIIORequest_t *pScsiReq;
1289 VirtDevice *pTarget = SCpnt->device->hostdata; 1286 VirtDevice *vdev = SCpnt->device->hostdata;
1290 int lun; 1287 int lun;
1291 u32 datalen; 1288 u32 datalen;
1292 u32 scsictl; 1289 u32 scsictl;
@@ -1341,8 +1338,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1341 /* Default to untagged. Once a target structure has been allocated, 1338 /* Default to untagged. Once a target structure has been allocated,
1342 * use the Inquiry data to determine if device supports tagged. 1339 * use the Inquiry data to determine if device supports tagged.
1343 */ 1340 */
1344 if (pTarget 1341 if (vdev
1345 && (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES) 1342 && (vdev->vtarget->tflags & MPT_TARGET_FLAGS_Q_YES)
1346 && (SCpnt->device->tagged_supported)) { 1343 && (SCpnt->device->tagged_supported)) {
1347 scsictl = scsidir | MPI_SCSIIO_CONTROL_SIMPLEQ; 1344 scsictl = scsidir | MPI_SCSIIO_CONTROL_SIMPLEQ;
1348 } else { 1345 } else {
@@ -1351,8 +1348,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1351 1348
1352 /* Use the above information to set up the message frame 1349 /* Use the above information to set up the message frame
1353 */ 1350 */
1354 pScsiReq->TargetID = (u8) pTarget->target_id; 1351 pScsiReq->TargetID = (u8) vdev->target_id;
1355 pScsiReq->Bus = pTarget->bus_id; 1352 pScsiReq->Bus = vdev->bus_id;
1356 pScsiReq->ChainOffset = 0; 1353 pScsiReq->ChainOffset = 0;
1357 pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST; 1354 pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST;
1358 pScsiReq->CDBLength = SCpnt->cmd_len; 1355 pScsiReq->CDBLength = SCpnt->cmd_len;
@@ -1403,8 +1400,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1403 SCpnt->host_scribble = NULL; 1400 SCpnt->host_scribble = NULL;
1404 1401
1405#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION 1402#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
1406 if (hd->ioc->bus_type == SCSI) { 1403 if (hd->ioc->bus_type == SPI) {
1407 int dvStatus = hd->ioc->spi_data.dvStatus[pTarget->target_id]; 1404 int dvStatus = hd->ioc->spi_data.dvStatus[vdev->target_id];
1408 int issueCmd = 1; 1405 int issueCmd = 1;
1409 1406
1410 if (dvStatus || hd->ioc->spi_data.forceDv) { 1407 if (dvStatus || hd->ioc->spi_data.forceDv) {
@@ -1437,7 +1434,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1437 /* Set the DV flags. 1434 /* Set the DV flags.
1438 */ 1435 */
1439 if (dvStatus & MPT_SCSICFG_DV_NOT_DONE) 1436 if (dvStatus & MPT_SCSICFG_DV_NOT_DONE)
1440 mptscsih_set_dvflags(hd, pScsiReq); 1437 mptscsih_set_dvflags(hd, SCpnt);
1441 1438
1442 if (!issueCmd) 1439 if (!issueCmd)
1443 goto fail; 1440 goto fail;
@@ -1741,6 +1738,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1741 u32 ctx2abort; 1738 u32 ctx2abort;
1742 int scpnt_idx; 1739 int scpnt_idx;
1743 int retval; 1740 int retval;
1741 VirtDevice *vdev;
1744 1742
1745 /* If we can't locate our host adapter structure, return FAILED status. 1743 /* If we can't locate our host adapter structure, return FAILED status.
1746 */ 1744 */
@@ -1790,8 +1788,9 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1790 1788
1791 hd->abortSCpnt = SCpnt; 1789 hd->abortSCpnt = SCpnt;
1792 1790
1791 vdev = SCpnt->device->hostdata;
1793 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK, 1792 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK,
1794 SCpnt->device->channel, SCpnt->device->id, SCpnt->device->lun, 1793 vdev->bus_id, vdev->target_id, vdev->lun,
1795 ctx2abort, 2 /* 2 second timeout */); 1794 ctx2abort, 2 /* 2 second timeout */);
1796 1795
1797 printk (KERN_WARNING MYNAM ": %s: task abort: %s (sc=%p)\n", 1796 printk (KERN_WARNING MYNAM ": %s: task abort: %s (sc=%p)\n",
@@ -1822,6 +1821,7 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
1822{ 1821{
1823 MPT_SCSI_HOST *hd; 1822 MPT_SCSI_HOST *hd;
1824 int retval; 1823 int retval;
1824 VirtDevice *vdev;
1825 1825
1826 /* If we can't locate our host adapter structure, return FAILED status. 1826 /* If we can't locate our host adapter structure, return FAILED status.
1827 */ 1827 */
@@ -1839,8 +1839,9 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
1839 hd->ioc->name, SCpnt); 1839 hd->ioc->name, SCpnt);
1840 scsi_print_command(SCpnt); 1840 scsi_print_command(SCpnt);
1841 1841
1842 vdev = SCpnt->device->hostdata;
1842 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 1843 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
1843 SCpnt->device->channel, SCpnt->device->id, 1844 vdev->bus_id, vdev->target_id,
1844 0, 0, 5 /* 5 second timeout */); 1845 0, 0, 5 /* 5 second timeout */);
1845 1846
1846 printk (KERN_WARNING MYNAM ": %s: target reset: %s (sc=%p)\n", 1847 printk (KERN_WARNING MYNAM ": %s: target reset: %s (sc=%p)\n",
@@ -1871,6 +1872,7 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
1871{ 1872{
1872 MPT_SCSI_HOST *hd; 1873 MPT_SCSI_HOST *hd;
1873 int retval; 1874 int retval;
1875 VirtDevice *vdev;
1874 1876
1875 /* If we can't locate our host adapter structure, return FAILED status. 1877 /* If we can't locate our host adapter structure, return FAILED status.
1876 */ 1878 */
@@ -1888,8 +1890,9 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
1888 if (hd->timeouts < -1) 1890 if (hd->timeouts < -1)
1889 hd->timeouts++; 1891 hd->timeouts++;
1890 1892
1893 vdev = SCpnt->device->hostdata;
1891 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, 1894 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS,
1892 SCpnt->device->channel, 0, 0, 0, 5 /* 5 second timeout */); 1895 vdev->bus_id, 0, 0, 0, 5 /* 5 second timeout */);
1893 1896
1894 printk (KERN_WARNING MYNAM ": %s: bus reset: %s (sc=%p)\n", 1897 printk (KERN_WARNING MYNAM ": %s: bus reset: %s (sc=%p)\n",
1895 hd->ioc->name, 1898 hd->ioc->name,
@@ -2151,23 +2154,36 @@ mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev,
2151/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2154/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2152/* 2155/*
2153 * OS entry point to allow host driver to alloc memory 2156 * OS entry point to allow host driver to alloc memory
2157 * for each scsi target. Called once per device the bus scan.
2158 * Return non-zero if allocation fails.
2159 */
2160int
2161mptscsih_target_alloc(struct scsi_target *starget)
2162{
2163 VirtTarget *vtarget;
2164
2165 vtarget = kmalloc(sizeof(VirtTarget), GFP_KERNEL);
2166 if (!vtarget)
2167 return -ENOMEM;
2168 memset(vtarget, 0, sizeof(VirtTarget));
2169 starget->hostdata = vtarget;
2170 return 0;
2171}
2172
2173/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2174/*
2175 * OS entry point to allow host driver to alloc memory
2154 * for each scsi device. Called once per device the bus scan. 2176 * for each scsi device. Called once per device the bus scan.
2155 * Return non-zero if allocation fails. 2177 * Return non-zero if allocation fails.
2156 * Init memory once per id (not LUN).
2157 */ 2178 */
2158int 2179int
2159mptscsih_slave_alloc(struct scsi_device *device) 2180mptscsih_slave_alloc(struct scsi_device *sdev)
2160{ 2181{
2161 struct Scsi_Host *host = device->host; 2182 struct Scsi_Host *host = sdev->host;
2162 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 2183 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
2184 VirtTarget *vtarget;
2163 VirtDevice *vdev; 2185 VirtDevice *vdev;
2164 uint target = device->id; 2186 struct scsi_target *starget;
2165
2166 if (hd == NULL)
2167 return -ENODEV;
2168
2169 if ((vdev = hd->Targets[target]) != NULL)
2170 goto out;
2171 2187
2172 vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL); 2188 vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL);
2173 if (!vdev) { 2189 if (!vdev) {
@@ -2177,25 +2193,33 @@ mptscsih_slave_alloc(struct scsi_device *device)
2177 } 2193 }
2178 2194
2179 memset(vdev, 0, sizeof(VirtDevice)); 2195 memset(vdev, 0, sizeof(VirtDevice));
2180 vdev->tflags = MPT_TARGET_FLAGS_Q_YES;
2181 vdev->ioc_id = hd->ioc->id; 2196 vdev->ioc_id = hd->ioc->id;
2182 vdev->target_id = device->id; 2197 vdev->target_id = sdev->id;
2183 vdev->bus_id = device->channel; 2198 vdev->bus_id = sdev->channel;
2184 vdev->raidVolume = 0; 2199 vdev->lun = sdev->lun;
2185 hd->Targets[device->id] = vdev; 2200 sdev->hostdata = vdev;
2186 if (hd->ioc->bus_type == SCSI) { 2201
2187 if (hd->ioc->raid_data.isRaid & (1 << device->id)) { 2202 starget = scsi_target(sdev);
2188 vdev->raidVolume = 1; 2203 vtarget = starget->hostdata;
2189 ddvtprintk((KERN_INFO 2204 vdev->vtarget = vtarget;
2190 "RAID Volume @ id %d\n", device->id)); 2205
2206 if (vtarget->num_luns == 0) {
2207 hd->Targets[sdev->id] = vtarget;
2208 vtarget->ioc_id = hd->ioc->id;
2209 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES;
2210 vtarget->target_id = sdev->id;
2211 vtarget->bus_id = sdev->channel;
2212 if (hd->ioc->bus_type == SPI) {
2213 if (hd->ioc->raid_data.isRaid & (1 << sdev->id)) {
2214 vtarget->raidVolume = 1;
2215 ddvtprintk((KERN_INFO
2216 "RAID Volume @ id %d\n", sdev->id));
2217 }
2218 } else {
2219 vtarget->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY;
2191 } 2220 }
2192 } else {
2193 vdev->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY;
2194 } 2221 }
2195 2222 vtarget->num_luns++;
2196 out:
2197 vdev->num_luns++;
2198 device->hostdata = vdev;
2199 return 0; 2223 return 0;
2200} 2224}
2201 2225
@@ -2204,40 +2228,52 @@ mptscsih_slave_alloc(struct scsi_device *device)
2204 * Called if no device present or device being unloaded 2228 * Called if no device present or device being unloaded
2205 */ 2229 */
2206void 2230void
2207mptscsih_slave_destroy(struct scsi_device *device) 2231mptscsih_target_destroy(struct scsi_target *starget)
2208{ 2232{
2209 struct Scsi_Host *host = device->host; 2233 if (starget->hostdata)
2210 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 2234 kfree(starget->hostdata);
2211 VirtDevice *vdev; 2235 starget->hostdata = NULL;
2212 uint target = device->id; 2236}
2213 uint lun = device->lun;
2214
2215 if (hd == NULL)
2216 return;
2217
2218 mptscsih_search_running_cmds(hd, target, lun);
2219
2220 vdev = hd->Targets[target];
2221 vdev->luns[0] &= ~(1 << lun);
2222 if (--vdev->num_luns)
2223 return;
2224
2225 kfree(hd->Targets[target]);
2226 hd->Targets[target] = NULL;
2227
2228 if (hd->ioc->bus_type == SCSI) {
2229 if (mptscsih_is_phys_disk(hd->ioc, target)) {
2230 hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3;
2231 } else {
2232 hd->ioc->spi_data.dvStatus[target] =
2233 MPT_SCSICFG_NEGOTIATE;
2234 2237
2235 if (!hd->negoNvram) { 2238/*
2236 hd->ioc->spi_data.dvStatus[target] |= 2239 * OS entry point to allow for host driver to free allocated memory
2237 MPT_SCSICFG_DV_NOT_DONE; 2240 * Called if no device present or device being unloaded
2241 */
2242void
2243mptscsih_slave_destroy(struct scsi_device *sdev)
2244{
2245 struct Scsi_Host *host = sdev->host;
2246 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
2247 VirtTarget *vtarget;
2248 VirtDevice *vdevice;
2249 struct scsi_target *starget;
2250
2251 starget = scsi_target(sdev);
2252 vtarget = starget->hostdata;
2253 vdevice = sdev->hostdata;
2254
2255 mptscsih_search_running_cmds(hd, vdevice);
2256 vtarget->luns[0] &= ~(1 << vdevice->lun);
2257 vtarget->num_luns--;
2258 if (vtarget->num_luns == 0) {
2259 mptscsih_negotiate_to_asyn_narrow(hd, vtarget);
2260 if (hd->ioc->bus_type == SPI) {
2261 if (mptscsih_is_phys_disk(hd->ioc, vtarget->target_id)) {
2262 hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3;
2263 } else {
2264 hd->ioc->spi_data.dvStatus[vtarget->target_id] =
2265 MPT_SCSICFG_NEGOTIATE;
2266 if (!hd->negoNvram) {
2267 hd->ioc->spi_data.dvStatus[vtarget->target_id] |=
2268 MPT_SCSICFG_DV_NOT_DONE;
2269 }
2238 } 2270 }
2239 } 2271 }
2272 hd->Targets[sdev->id] = NULL;
2240 } 2273 }
2274 mptscsih_synchronize_cache(hd, vdevice);
2275 kfree(vdevice);
2276 sdev->hostdata = NULL;
2241} 2277}
2242 2278
2243/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2279/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -2251,22 +2287,21 @@ mptscsih_slave_destroy(struct scsi_device *device)
2251int 2287int
2252mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth) 2288mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
2253{ 2289{
2254 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sdev->host->hostdata; 2290 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sdev->host->hostdata;
2255 VirtDevice *pTarget; 2291 VirtTarget *vtarget;
2256 int max_depth; 2292 struct scsi_target *starget;
2257 int tagged; 2293 int max_depth;
2258 2294 int tagged;
2259 if (hd == NULL) 2295
2260 return 0; 2296 starget = scsi_target(sdev);
2261 if (!(pTarget = hd->Targets[sdev->id])) 2297 vtarget = starget->hostdata;
2262 return 0; 2298
2263 2299 if (hd->ioc->bus_type == SPI) {
2264 if (hd->ioc->bus_type == SCSI) { 2300 if (vtarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY) {
2265 if (pTarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY) { 2301 if (!(vtarget->tflags & MPT_TARGET_FLAGS_Q_YES))
2266 if (!(pTarget->tflags & MPT_TARGET_FLAGS_Q_YES))
2267 max_depth = 1; 2302 max_depth = 1;
2268 else if (((pTarget->inq_data[0] & 0x1f) == 0x00) && 2303 else if (((vtarget->inq_data[0] & 0x1f) == 0x00) &&
2269 (pTarget->minSyncFactor <= MPT_ULTRA160 )) 2304 (vtarget->minSyncFactor <= MPT_ULTRA160 ))
2270 max_depth = MPT_SCSI_CMD_PER_DEV_HIGH; 2305 max_depth = MPT_SCSI_CMD_PER_DEV_HIGH;
2271 else 2306 else
2272 max_depth = MPT_SCSI_CMD_PER_DEV_LOW; 2307 max_depth = MPT_SCSI_CMD_PER_DEV_LOW;
@@ -2295,64 +2330,58 @@ mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
2295 * Return non-zero if fails. 2330 * Return non-zero if fails.
2296 */ 2331 */
2297int 2332int
2298mptscsih_slave_configure(struct scsi_device *device) 2333mptscsih_slave_configure(struct scsi_device *sdev)
2299{ 2334{
2300 struct Scsi_Host *sh = device->host; 2335 struct Scsi_Host *sh = sdev->host;
2301 VirtDevice *pTarget; 2336 VirtTarget *vtarget;
2337 VirtDevice *vdevice;
2338 struct scsi_target *starget;
2302 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sh->hostdata; 2339 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sh->hostdata;
2340 int indexed_lun, lun_index;
2303 2341
2304 if ((hd == NULL) || (hd->Targets == NULL)) { 2342 starget = scsi_target(sdev);
2305 return 0; 2343 vtarget = starget->hostdata;
2306 } 2344 vdevice = sdev->hostdata;
2307 2345
2308 dsprintk((MYIOC_s_INFO_FMT 2346 dsprintk((MYIOC_s_INFO_FMT
2309 "device @ %p, id=%d, LUN=%d, channel=%d\n", 2347 "device @ %p, id=%d, LUN=%d, channel=%d\n",
2310 hd->ioc->name, device, device->id, device->lun, device->channel)); 2348 hd->ioc->name, sdev, sdev->id, sdev->lun, sdev->channel));
2311 dsprintk((MYIOC_s_INFO_FMT 2349 if (hd->ioc->bus_type == SPI)
2312 "sdtr %d wdtr %d ppr %d inq length=%d\n", 2350 dsprintk((MYIOC_s_INFO_FMT
2313 hd->ioc->name, device->sdtr, device->wdtr, 2351 "sdtr %d wdtr %d ppr %d inq length=%d\n",
2314 device->ppr, device->inquiry_len)); 2352 hd->ioc->name, sdev->sdtr, sdev->wdtr,
2315 2353 sdev->ppr, sdev->inquiry_len));
2316 if (device->id > sh->max_id) { 2354
2355 if (sdev->id > sh->max_id) {
2317 /* error case, should never happen */ 2356 /* error case, should never happen */
2318 scsi_adjust_queue_depth(device, 0, 1); 2357 scsi_adjust_queue_depth(sdev, 0, 1);
2319 goto slave_configure_exit;
2320 }
2321
2322 pTarget = hd->Targets[device->id];
2323
2324 if (pTarget == NULL) {
2325 /* Driver doesn't know about this device.
2326 * Kernel may generate a "Dummy Lun 0" which
2327 * may become a real Lun if a
2328 * "scsi add-single-device" command is executed
2329 * while the driver is active (hot-plug a
2330 * device). LSI Raid controllers need
2331 * queue_depth set to DEV_HIGH for this reason.
2332 */
2333 scsi_adjust_queue_depth(device, MSG_SIMPLE_TAG,
2334 MPT_SCSI_CMD_PER_DEV_HIGH);
2335 goto slave_configure_exit; 2358 goto slave_configure_exit;
2336 } 2359 }
2337 2360
2338 mptscsih_initTarget(hd, device->channel, device->id, device->lun, 2361 vdevice->configured_lun=1;
2339 device->inquiry, device->inquiry_len ); 2362 lun_index = (vdevice->lun >> 5); /* 32 luns per lun_index */
2340 mptscsih_change_queue_depth(device, MPT_SCSI_CMD_PER_DEV_HIGH); 2363 indexed_lun = (vdevice->lun % 32);
2364 vtarget->luns[lun_index] |= (1 << indexed_lun);
2365 mptscsih_initTarget(hd, vtarget, sdev->lun, sdev->inquiry,
2366 sdev->inquiry_len );
2367 mptscsih_change_queue_depth(sdev, MPT_SCSI_CMD_PER_DEV_HIGH);
2341 2368
2342 dsprintk((MYIOC_s_INFO_FMT 2369 dsprintk((MYIOC_s_INFO_FMT
2343 "Queue depth=%d, tflags=%x\n", 2370 "Queue depth=%d, tflags=%x\n",
2344 hd->ioc->name, device->queue_depth, pTarget->tflags)); 2371 hd->ioc->name, sdev->queue_depth, vtarget->tflags));
2345 2372
2346 dsprintk((MYIOC_s_INFO_FMT 2373 if (hd->ioc->bus_type == SPI)
2347 "negoFlags=%x, maxOffset=%x, SyncFactor=%x\n", 2374 dsprintk((MYIOC_s_INFO_FMT
2348 hd->ioc->name, pTarget->negoFlags, pTarget->maxOffset, pTarget->minSyncFactor)); 2375 "negoFlags=%x, maxOffset=%x, SyncFactor=%x\n",
2376 hd->ioc->name, vtarget->negoFlags, vtarget->maxOffset,
2377 vtarget->minSyncFactor));
2349 2378
2350slave_configure_exit: 2379slave_configure_exit:
2351 2380
2352 dsprintk((MYIOC_s_INFO_FMT 2381 dsprintk((MYIOC_s_INFO_FMT
2353 "tagged %d, simple %d, ordered %d\n", 2382 "tagged %d, simple %d, ordered %d\n",
2354 hd->ioc->name,device->tagged_supported, device->simple_tags, 2383 hd->ioc->name,sdev->tagged_supported, sdev->simple_tags,
2355 device->ordered_tags)); 2384 sdev->ordered_tags));
2356 2385
2357 return 0; 2386 return 0;
2358} 2387}
@@ -2370,16 +2399,14 @@ slave_configure_exit:
2370static void 2399static void
2371mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply) 2400mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply)
2372{ 2401{
2373 VirtDevice *target; 2402 VirtDevice *vdev;
2374 SCSIIORequest_t *pReq; 2403 SCSIIORequest_t *pReq;
2375 u32 sense_count = le32_to_cpu(pScsiReply->SenseCount); 2404 u32 sense_count = le32_to_cpu(pScsiReply->SenseCount);
2376 int index;
2377 2405
2378 /* Get target structure 2406 /* Get target structure
2379 */ 2407 */
2380 pReq = (SCSIIORequest_t *) mf; 2408 pReq = (SCSIIORequest_t *) mf;
2381 index = (int) pReq->TargetID; 2409 vdev = sc->device->hostdata;
2382 target = hd->Targets[index];
2383 2410
2384 if (sense_count) { 2411 if (sense_count) {
2385 u8 *sense_data; 2412 u8 *sense_data;
@@ -2393,7 +2420,7 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
2393 /* Log SMART data (asc = 0x5D, non-IM case only) if required. 2420 /* Log SMART data (asc = 0x5D, non-IM case only) if required.
2394 */ 2421 */
2395 if ((hd->ioc->events) && (hd->ioc->eventTypes & (1 << MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE))) { 2422 if ((hd->ioc->events) && (hd->ioc->eventTypes & (1 << MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE))) {
2396 if ((sense_data[12] == 0x5D) && (target->raidVolume == 0)) { 2423 if ((sense_data[12] == 0x5D) && (vdev->vtarget->raidVolume == 0)) {
2397 int idx; 2424 int idx;
2398 MPT_ADAPTER *ioc = hd->ioc; 2425 MPT_ADAPTER *ioc = hd->ioc;
2399 2426
@@ -2403,7 +2430,7 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
2403 2430
2404 ioc->events[idx].data[0] = (pReq->LUN[1] << 24) || 2431 ioc->events[idx].data[0] = (pReq->LUN[1] << 24) ||
2405 (MPI_EVENT_SCSI_DEV_STAT_RC_SMART_DATA << 16) || 2432 (MPI_EVENT_SCSI_DEV_STAT_RC_SMART_DATA << 16) ||
2406 (pReq->Bus << 8) || pReq->TargetID; 2433 (sc->device->channel << 8) || sc->device->id;
2407 2434
2408 ioc->events[idx].data[1] = (sense_data[13] << 8) || sense_data[12]; 2435 ioc->events[idx].data[1] = (sense_data[13] << 8) || sense_data[12];
2409 2436
@@ -2503,9 +2530,9 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2503 /* 2. Chain Buffer initialization 2530 /* 2. Chain Buffer initialization
2504 */ 2531 */
2505 2532
2506 /* 4. Renegotiate to all devices, if SCSI 2533 /* 4. Renegotiate to all devices, if SPI
2507 */ 2534 */
2508 if (ioc->bus_type == SCSI) { 2535 if (ioc->bus_type == SPI) {
2509 dnegoprintk(("writeSDP1: ALL_IDS USE_NVRAM\n")); 2536 dnegoprintk(("writeSDP1: ALL_IDS USE_NVRAM\n"));
2510 mptscsih_writeSDP1(hd, 0, 0, MPT_SCSICFG_ALL_IDS | MPT_SCSICFG_USE_NVRAM); 2537 mptscsih_writeSDP1(hd, 0, 0, MPT_SCSICFG_ALL_IDS | MPT_SCSICFG_USE_NVRAM);
2511 } 2538 }
@@ -2534,7 +2561,7 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2534 2561
2535 /* 7. Set flag to force DV and re-read IOC Page 3 2562 /* 7. Set flag to force DV and re-read IOC Page 3
2536 */ 2563 */
2537 if (ioc->bus_type == SCSI) { 2564 if (ioc->bus_type == SPI) {
2538 ioc->spi_data.forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3; 2565 ioc->spi_data.forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3;
2539 ddvtprintk(("Set reload IOC Pg3 Flag\n")); 2566 ddvtprintk(("Set reload IOC Pg3 Flag\n"));
2540 } 2567 }
@@ -2576,7 +2603,7 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2576 break; 2603 break;
2577 case MPI_EVENT_IOC_BUS_RESET: /* 04 */ 2604 case MPI_EVENT_IOC_BUS_RESET: /* 04 */
2578 case MPI_EVENT_EXT_BUS_RESET: /* 05 */ 2605 case MPI_EVENT_EXT_BUS_RESET: /* 05 */
2579 if (hd && (ioc->bus_type == SCSI) && (hd->soft_resets < -1)) 2606 if (hd && (ioc->bus_type == SPI) && (hd->soft_resets < -1))
2580 hd->soft_resets++; 2607 hd->soft_resets++;
2581 break; 2608 break;
2582 case MPI_EVENT_LOGOUT: /* 09 */ 2609 case MPI_EVENT_LOGOUT: /* 09 */
@@ -2597,11 +2624,11 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2597 2624
2598 case MPI_EVENT_INTEGRATED_RAID: /* 0B */ 2625 case MPI_EVENT_INTEGRATED_RAID: /* 0B */
2599 { 2626 {
2627#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
2600 pMpiEventDataRaid_t pRaidEventData = 2628 pMpiEventDataRaid_t pRaidEventData =
2601 (pMpiEventDataRaid_t) pEvReply->Data; 2629 (pMpiEventDataRaid_t) pEvReply->Data;
2602#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
2603 /* Domain Validation Needed */ 2630 /* Domain Validation Needed */
2604 if (ioc->bus_type == SCSI && 2631 if (ioc->bus_type == SPI &&
2605 pRaidEventData->ReasonCode == 2632 pRaidEventData->ReasonCode ==
2606 MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED) 2633 MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED)
2607 mptscsih_set_dvflags_raid(hd, pRaidEventData->PhysDiskNum); 2634 mptscsih_set_dvflags_raid(hd, pRaidEventData->PhysDiskNum);
@@ -2632,8 +2659,7 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2632/* 2659/*
2633 * mptscsih_initTarget - Target, LUN alloc/free functionality. 2660 * mptscsih_initTarget - Target, LUN alloc/free functionality.
2634 * @hd: Pointer to MPT_SCSI_HOST structure 2661 * @hd: Pointer to MPT_SCSI_HOST structure
2635 * @bus_id: Bus number (?) 2662 * @vtarget: per target private data
2636 * @target_id: SCSI target id
2637 * @lun: SCSI LUN id 2663 * @lun: SCSI LUN id
2638 * @data: Pointer to data 2664 * @data: Pointer to data
2639 * @dlen: Number of INQUIRY bytes 2665 * @dlen: Number of INQUIRY bytes
@@ -2646,15 +2672,14 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2646 * 2672 *
2647 */ 2673 */
2648static void 2674static void
2649mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *data, int dlen) 2675mptscsih_initTarget(MPT_SCSI_HOST *hd, VirtTarget *vtarget, u8 lun, char *data, int dlen)
2650{ 2676{
2651 int indexed_lun, lun_index;
2652 VirtDevice *vdev;
2653 SpiCfgData *pSpi; 2677 SpiCfgData *pSpi;
2654 char data_56; 2678 char data_56;
2679 int inq_len;
2655 2680
2656 dinitprintk((MYIOC_s_INFO_FMT "initTarget bus=%d id=%d lun=%d hd=%p\n", 2681 dinitprintk((MYIOC_s_INFO_FMT "initTarget bus=%d id=%d lun=%d hd=%p\n",
2657 hd->ioc->name, bus_id, target_id, lun, hd)); 2682 hd->ioc->name, vtarget->bus_id, vtarget->target_id, lun, hd));
2658 2683
2659 /* 2684 /*
2660 * If the peripheral qualifier filter is enabled then if the target reports a 0x1 2685 * If the peripheral qualifier filter is enabled then if the target reports a 0x1
@@ -2674,75 +2699,68 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *
2674 if (data[0] & 0xe0) 2699 if (data[0] & 0xe0)
2675 return; 2700 return;
2676 2701
2677 if ((vdev = hd->Targets[target_id]) == NULL) { 2702 if (vtarget == NULL)
2678 return; 2703 return;
2679 }
2680 2704
2681 lun_index = (lun >> 5); /* 32 luns per lun_index */ 2705 if (data)
2682 indexed_lun = (lun % 32); 2706 vtarget->type = data[0];
2683 vdev->luns[lun_index] |= (1 << indexed_lun); 2707
2684 2708 if (hd->ioc->bus_type != SPI)
2685 if (hd->ioc->bus_type == SCSI) { 2709 return;
2686 if ((data[0] == TYPE_PROCESSOR) && (hd->ioc->spi_data.Saf_Te)) { 2710
2687 /* Treat all Processors as SAF-TE if 2711 if ((data[0] == TYPE_PROCESSOR) && (hd->ioc->spi_data.Saf_Te)) {
2688 * command line option is set */ 2712 /* Treat all Processors as SAF-TE if
2689 vdev->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED; 2713 * command line option is set */
2690 mptscsih_writeIOCPage4(hd, target_id, bus_id); 2714 vtarget->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED;
2691 }else if ((data[0] == TYPE_PROCESSOR) && 2715 mptscsih_writeIOCPage4(hd, vtarget->target_id, vtarget->bus_id);
2692 !(vdev->tflags & MPT_TARGET_FLAGS_SAF_TE_ISSUED )) { 2716 }else if ((data[0] == TYPE_PROCESSOR) &&
2693 if ( dlen > 49 ) { 2717 !(vtarget->tflags & MPT_TARGET_FLAGS_SAF_TE_ISSUED )) {
2694 vdev->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY; 2718 if ( dlen > 49 ) {
2695 if ( data[44] == 'S' && 2719 vtarget->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY;
2696 data[45] == 'A' && 2720 if ( data[44] == 'S' &&
2697 data[46] == 'F' && 2721 data[45] == 'A' &&
2698 data[47] == '-' && 2722 data[46] == 'F' &&
2699 data[48] == 'T' && 2723 data[47] == '-' &&
2700 data[49] == 'E' ) { 2724 data[48] == 'T' &&
2701 vdev->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED; 2725 data[49] == 'E' ) {
2702 mptscsih_writeIOCPage4(hd, target_id, bus_id); 2726 vtarget->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED;
2703 } 2727 mptscsih_writeIOCPage4(hd, vtarget->target_id, vtarget->bus_id);
2704 } 2728 }
2705 } 2729 }
2706 if (!(vdev->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY)) { 2730 }
2707 if ( dlen > 8 ) { 2731 if (!(vtarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY)) {
2708 memcpy (vdev->inq_data, data, 8); 2732 inq_len = dlen < 8 ? dlen : 8;
2709 } else { 2733 memcpy (vtarget->inq_data, data, inq_len);
2710 memcpy (vdev->inq_data, data, dlen); 2734 /* If have not done DV, set the DV flag.
2711 } 2735 */
2736 pSpi = &hd->ioc->spi_data;
2737 if ((data[0] == TYPE_TAPE) || (data[0] == TYPE_PROCESSOR)) {
2738 if (pSpi->dvStatus[vtarget->target_id] & MPT_SCSICFG_DV_NOT_DONE)
2739 pSpi->dvStatus[vtarget->target_id] |= MPT_SCSICFG_NEED_DV;
2740 }
2741 vtarget->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY;
2712 2742
2713 /* If have not done DV, set the DV flag. 2743 data_56 = 0x0F; /* Default to full capabilities if Inq data length is < 57 */
2744 if (dlen > 56) {
2745 if ( (!(vtarget->tflags & MPT_TARGET_FLAGS_VALID_56))) {
2746 /* Update the target capabilities
2714 */ 2747 */
2715 pSpi = &hd->ioc->spi_data; 2748 data_56 = data[56];
2716 if ((data[0] == TYPE_TAPE) || (data[0] == TYPE_PROCESSOR)) { 2749 vtarget->tflags |= MPT_TARGET_FLAGS_VALID_56;
2717 if (pSpi->dvStatus[target_id] & MPT_SCSICFG_DV_NOT_DONE)
2718 pSpi->dvStatus[target_id] |= MPT_SCSICFG_NEED_DV;
2719 }
2720
2721 vdev->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY;
2722
2723
2724 data_56 = 0x0F; /* Default to full capabilities if Inq data length is < 57 */
2725 if (dlen > 56) {
2726 if ( (!(vdev->tflags & MPT_TARGET_FLAGS_VALID_56))) {
2727 /* Update the target capabilities
2728 */
2729 data_56 = data[56];
2730 vdev->tflags |= MPT_TARGET_FLAGS_VALID_56;
2731 }
2732 } 2750 }
2733 mptscsih_setTargetNegoParms(hd, vdev, data_56); 2751 }
2734 } else { 2752 mptscsih_setTargetNegoParms(hd, vtarget, data_56);
2735 /* Initial Inquiry may not request enough data bytes to 2753 } else {
2736 * obtain byte 57. DV will; if target doesn't return 2754 /* Initial Inquiry may not request enough data bytes to
2737 * at least 57 bytes, data[56] will be zero. */ 2755 * obtain byte 57. DV will; if target doesn't return
2738 if (dlen > 56) { 2756 * at least 57 bytes, data[56] will be zero. */
2739 if ( (!(vdev->tflags & MPT_TARGET_FLAGS_VALID_56))) { 2757 if (dlen > 56) {
2740 /* Update the target capabilities 2758 if ( (!(vtarget->tflags & MPT_TARGET_FLAGS_VALID_56))) {
2741 */ 2759 /* Update the target capabilities
2742 data_56 = data[56]; 2760 */
2743 vdev->tflags |= MPT_TARGET_FLAGS_VALID_56; 2761 data_56 = data[56];
2744 mptscsih_setTargetNegoParms(hd, vdev, data_56); 2762 vtarget->tflags |= MPT_TARGET_FLAGS_VALID_56;
2745 } 2763 mptscsih_setTargetNegoParms(hd, vtarget, data_56);
2746 } 2764 }
2747 } 2765 }
2748 } 2766 }
@@ -2755,12 +2773,12 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *
2755 * 2773 *
2756 */ 2774 */
2757static void 2775static void
2758mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56) 2776mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target, char byte56)
2759{ 2777{
2760 SpiCfgData *pspi_data = &hd->ioc->spi_data; 2778 SpiCfgData *pspi_data = &hd->ioc->spi_data;
2761 int id = (int) target->target_id; 2779 int id = (int) target->target_id;
2762 int nvram; 2780 int nvram;
2763 VirtDevice *vdev; 2781 VirtTarget *vtarget;
2764 int ii; 2782 int ii;
2765 u8 width = MPT_NARROW; 2783 u8 width = MPT_NARROW;
2766 u8 factor = MPT_ASYNC; 2784 u8 factor = MPT_ASYNC;
@@ -2905,9 +2923,9 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56)
2905 2923
2906 ddvtprintk((KERN_INFO "Disabling QAS due to noQas=%02x on id=%d!\n", noQas, id)); 2924 ddvtprintk((KERN_INFO "Disabling QAS due to noQas=%02x on id=%d!\n", noQas, id));
2907 for (ii = 0; ii < id; ii++) { 2925 for (ii = 0; ii < id; ii++) {
2908 if ( (vdev = hd->Targets[ii]) ) { 2926 if ( (vtarget = hd->Targets[ii]) ) {
2909 vdev->negoFlags |= MPT_TARGET_NO_NEGO_QAS; 2927 vtarget->negoFlags |= MPT_TARGET_NO_NEGO_QAS;
2910 mptscsih_writeSDP1(hd, 0, ii, vdev->negoFlags); 2928 mptscsih_writeSDP1(hd, 0, ii, vtarget->negoFlags);
2911 } 2929 }
2912 } 2930 }
2913 } 2931 }
@@ -2926,105 +2944,17 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56)
2926} 2944}
2927 2945
2928/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2946/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2929/* If DV disabled (negoNvram set to USE_NVARM) or if not LUN 0, return.
2930 * Else set the NEED_DV flag after Read Capacity Issued (disks)
2931 * or Mode Sense (cdroms).
2932 *
2933 * Tapes, initTarget will set this flag on completion of Inquiry command.
2934 * Called only if DV_NOT_DONE flag is set
2935 */
2936static void
2937mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq)
2938{
2939 MPT_ADAPTER *ioc = hd->ioc;
2940 u8 cmd;
2941 SpiCfgData *pSpi;
2942
2943 ddvtprintk((MYIOC_s_NOTE_FMT
2944 " set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n",
2945 hd->ioc->name, pReq->TargetID, pReq->LUN[1], hd->negoNvram, pReq->CDB[0]));
2946
2947 if ((pReq->LUN[1] != 0) || (hd->negoNvram != 0))
2948 return;
2949
2950 cmd = pReq->CDB[0];
2951
2952 if ((cmd == READ_CAPACITY) || (cmd == MODE_SENSE)) {
2953 pSpi = &ioc->spi_data;
2954 if ((ioc->raid_data.isRaid & (1 << pReq->TargetID)) && ioc->raid_data.pIocPg3) {
2955 /* Set NEED_DV for all hidden disks
2956 */
2957 Ioc3PhysDisk_t *pPDisk = ioc->raid_data.pIocPg3->PhysDisk;
2958 int numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks;
2959
2960 while (numPDisk) {
2961 pSpi->dvStatus[pPDisk->PhysDiskID] |= MPT_SCSICFG_NEED_DV;
2962 ddvtprintk(("NEED_DV set for phys disk id %d\n", pPDisk->PhysDiskID));
2963 pPDisk++;
2964 numPDisk--;
2965 }
2966 }
2967 pSpi->dvStatus[pReq->TargetID] |= MPT_SCSICFG_NEED_DV;
2968 ddvtprintk(("NEED_DV set for visible disk id %d\n", pReq->TargetID));
2969 }
2970}
2971
2972/* mptscsih_raid_set_dv_flags()
2973 *
2974 * New or replaced disk. Set DV flag and schedule DV.
2975 */
2976static void
2977mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id)
2978{
2979 MPT_ADAPTER *ioc = hd->ioc;
2980 SpiCfgData *pSpi = &ioc->spi_data;
2981 Ioc3PhysDisk_t *pPDisk;
2982 int numPDisk;
2983
2984 if (hd->negoNvram != 0)
2985 return;
2986
2987 ddvtprintk(("DV requested for phys disk id %d\n", id));
2988 if (ioc->raid_data.pIocPg3) {
2989 pPDisk = ioc->raid_data.pIocPg3->PhysDisk;
2990 numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks;
2991 while (numPDisk) {
2992 if (id == pPDisk->PhysDiskNum) {
2993 pSpi->dvStatus[pPDisk->PhysDiskID] =
2994 (MPT_SCSICFG_NEED_DV | MPT_SCSICFG_DV_NOT_DONE);
2995 pSpi->forceDv = MPT_SCSICFG_NEED_DV;
2996 ddvtprintk(("NEED_DV set for phys disk id %d\n",
2997 pPDisk->PhysDiskID));
2998 break;
2999 }
3000 pPDisk++;
3001 numPDisk--;
3002 }
3003
3004 if (numPDisk == 0) {
3005 /* The physical disk that needs DV was not found
3006 * in the stored IOC Page 3. The driver must reload
3007 * this page. DV routine will set the NEED_DV flag for
3008 * all phys disks that have DV_NOT_DONE set.
3009 */
3010 pSpi->forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3;
3011 ddvtprintk(("phys disk %d not found. Setting reload IOC Pg3 Flag\n",id));
3012 }
3013 }
3014}
3015
3016/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3017/* 2947/*
3018 * If no Target, bus reset on 1st I/O. Set the flag to 2948 * If no Target, bus reset on 1st I/O. Set the flag to
3019 * prevent any future negotiations to this device. 2949 * prevent any future negotiations to this device.
3020 */ 2950 */
3021static void 2951static void
3022mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id) 2952mptscsih_no_negotiate(MPT_SCSI_HOST *hd, struct scsi_cmnd *sc)
3023{ 2953{
2954 VirtDevice *vdev;
3024 2955
3025 if ((hd->Targets) && (hd->Targets[target_id] == NULL)) 2956 if ((vdev = sc->device->hostdata) != NULL)
3026 hd->ioc->spi_data.dvStatus[target_id] |= MPT_SCSICFG_BLK_NEGO; 2957 hd->ioc->spi_data.dvStatus[vdev->target_id] |= MPT_SCSICFG_BLK_NEGO;
3027
3028 return; 2958 return;
3029} 2959}
3030 2960
@@ -3100,7 +3030,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
3100 MPT_ADAPTER *ioc = hd->ioc; 3030 MPT_ADAPTER *ioc = hd->ioc;
3101 Config_t *pReq; 3031 Config_t *pReq;
3102 SCSIDevicePage1_t *pData; 3032 SCSIDevicePage1_t *pData;
3103 VirtDevice *pTarget=NULL; 3033 VirtTarget *vtarget=NULL;
3104 MPT_FRAME_HDR *mf; 3034 MPT_FRAME_HDR *mf;
3105 dma_addr_t dataDma; 3035 dma_addr_t dataDma;
3106 u16 req_idx; 3036 u16 req_idx;
@@ -3180,11 +3110,11 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
3180 /* If id is not a raid volume, get the updated 3110 /* If id is not a raid volume, get the updated
3181 * transmission settings from the target structure. 3111 * transmission settings from the target structure.
3182 */ 3112 */
3183 if (hd->Targets && (pTarget = hd->Targets[id]) && !pTarget->raidVolume) { 3113 if (hd->Targets && (vtarget = hd->Targets[id]) && !vtarget->raidVolume) {
3184 width = pTarget->maxWidth; 3114 width = vtarget->maxWidth;
3185 factor = pTarget->minSyncFactor; 3115 factor = vtarget->minSyncFactor;
3186 offset = pTarget->maxOffset; 3116 offset = vtarget->maxOffset;
3187 negoFlags = pTarget->negoFlags; 3117 negoFlags = vtarget->negoFlags;
3188 } 3118 }
3189 3119
3190#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION 3120#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
@@ -3904,149 +3834,139 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3904 3834
3905/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3835/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3906/** 3836/**
3907 * mptscsih_synchronize_cache - Send SYNCHRONIZE_CACHE to all disks. 3837 * mptscsih_negotiate_to_asyn_narrow - Restore devices to default state
3908 * @hd: Pointer to MPT_SCSI_HOST structure 3838 * @hd: Pointer to a SCSI HOST structure
3909 * @portnum: IOC port number 3839 * @vtarget: per device private data
3910 * 3840 *
3911 * Uses the ISR, but with special processing. 3841 * Uses the ISR, but with special processing.
3912 * MUST be single-threaded. 3842 * MUST be single-threaded.
3913 * 3843 *
3914 * Return: 0 on completion
3915 */ 3844 */
3916static int 3845static void
3917mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum) 3846mptscsih_negotiate_to_asyn_narrow(MPT_SCSI_HOST *hd, VirtTarget *vtarget)
3918{ 3847{
3919 MPT_ADAPTER *ioc= hd->ioc; 3848 MPT_ADAPTER *ioc= hd->ioc;
3920 VirtDevice *pTarget; 3849 SCSIDevicePage1_t *pcfg1Data;
3921 SCSIDevicePage1_t *pcfg1Data = NULL;
3922 INTERNAL_CMD iocmd;
3923 CONFIGPARMS cfg; 3850 CONFIGPARMS cfg;
3924 dma_addr_t cfg1_dma_addr = -1; 3851 dma_addr_t cfg1_dma_addr;
3925 ConfigPageHeader_t header1; 3852 ConfigPageHeader_t header;
3926 int bus = 0; 3853 int id;
3927 int id = 0; 3854 int requested, configuration, data,i;
3928 int lun;
3929 int indexed_lun, lun_index;
3930 int hostId = ioc->pfacts[portnum].PortSCSIID;
3931 int max_id;
3932 int requested, configuration, data;
3933 int doConfig = 0;
3934 u8 flags, factor; 3855 u8 flags, factor;
3935 3856
3936 max_id = ioc->sh->max_id - 1; 3857 if (ioc->bus_type != SPI)
3937 3858 return;
3938 /* Following parameters will not change
3939 * in this routine.
3940 */
3941 iocmd.cmd = SYNCHRONIZE_CACHE;
3942 iocmd.flags = 0;
3943 iocmd.physDiskNum = -1;
3944 iocmd.data = NULL;
3945 iocmd.data_dma = -1;
3946 iocmd.size = 0;
3947 iocmd.rsvd = iocmd.rsvd2 = 0;
3948
3949 /* No SCSI hosts
3950 */
3951 if (hd->Targets == NULL)
3952 return 0;
3953
3954 /* Skip the host
3955 */
3956 if (id == hostId)
3957 id++;
3958
3959 /* Write SDP1 for all SCSI devices
3960 * Alloc memory and set up config buffer
3961 */
3962 if (ioc->bus_type == SCSI) {
3963 if (ioc->spi_data.sdp1length > 0) {
3964 pcfg1Data = (SCSIDevicePage1_t *)pci_alloc_consistent(ioc->pcidev,
3965 ioc->spi_data.sdp1length * 4, &cfg1_dma_addr);
3966
3967 if (pcfg1Data != NULL) {
3968 doConfig = 1;
3969 header1.PageVersion = ioc->spi_data.sdp1version;
3970 header1.PageLength = ioc->spi_data.sdp1length;
3971 header1.PageNumber = 1;
3972 header1.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE;
3973 cfg.cfghdr.hdr = &header1;
3974 cfg.physAddr = cfg1_dma_addr;
3975 cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;
3976 cfg.dir = 1;
3977 cfg.timeout = 0;
3978 }
3979 }
3980 }
3981 3859
3982 /* loop through all devices on this port 3860 if (!ioc->spi_data.sdp1length)
3983 */ 3861 return;
3984 while (bus < MPT_MAX_BUS) {
3985 iocmd.bus = bus;
3986 iocmd.id = id;
3987 pTarget = hd->Targets[(int)id];
3988 3862
3989 if (doConfig) { 3863 pcfg1Data = (SCSIDevicePage1_t *)pci_alloc_consistent(ioc->pcidev,
3864 ioc->spi_data.sdp1length * 4, &cfg1_dma_addr);
3990 3865
3991 /* Set the negotiation flags */ 3866 if (pcfg1Data == NULL)
3992 if (pTarget && (pTarget = hd->Targets[id]) && !pTarget->raidVolume) { 3867 return;
3993 flags = pTarget->negoFlags;
3994 } else {
3995 flags = hd->ioc->spi_data.noQas;
3996 if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) {
3997 data = hd->ioc->spi_data.nvram[id];
3998 3868
3999 if (data & MPT_NVRAM_WIDE_DISABLE) 3869 header.PageVersion = ioc->spi_data.sdp1version;
4000 flags |= MPT_TARGET_NO_NEGO_WIDE; 3870 header.PageLength = ioc->spi_data.sdp1length;
3871 header.PageNumber = 1;
3872 header.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE;
3873 cfg.cfghdr.hdr = &header;
3874 cfg.physAddr = cfg1_dma_addr;
3875 cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;
3876 cfg.dir = 1;
3877 cfg.timeout = 0;
4001 3878
4002 factor = (data & MPT_NVRAM_SYNC_MASK) >> MPT_NVRAM_SYNC_SHIFT; 3879 if (vtarget->raidVolume && ioc->raid_data.pIocPg3) {
4003 if ((factor == 0) || (factor == MPT_ASYNC)) 3880 for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) {
4004 flags |= MPT_TARGET_NO_NEGO_SYNC; 3881 id = ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID;
4005 } 3882 flags = hd->ioc->spi_data.noQas;
3883 if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) {
3884 data = hd->ioc->spi_data.nvram[id];
3885 if (data & MPT_NVRAM_WIDE_DISABLE)
3886 flags |= MPT_TARGET_NO_NEGO_WIDE;
3887 factor = (data & MPT_NVRAM_SYNC_MASK) >> MPT_NVRAM_SYNC_SHIFT;
3888 if ((factor == 0) || (factor == MPT_ASYNC))
3889 flags |= MPT_TARGET_NO_NEGO_SYNC;
4006 } 3890 }
4007
4008 /* Force to async, narrow */
4009 mptscsih_setDevicePage1Flags(0, MPT_ASYNC, 0, &requested, 3891 mptscsih_setDevicePage1Flags(0, MPT_ASYNC, 0, &requested,
4010 &configuration, flags); 3892 &configuration, flags);
4011 dnegoprintk(("syncronize cache: id=%d width=0 factor=MPT_ASYNC " 3893 dnegoprintk(("syncronize cache: id=%d width=0 factor=MPT_ASYNC "
4012 "offset=0 negoFlags=%x request=%x config=%x\n", 3894 "offset=0 negoFlags=%x request=%x config=%x\n",
4013 id, flags, requested, configuration)); 3895 id, flags, requested, configuration));
4014 pcfg1Data->RequestedParameters = cpu_to_le32(requested); 3896 pcfg1Data->RequestedParameters = cpu_to_le32(requested);
4015 pcfg1Data->Reserved = 0; 3897 pcfg1Data->Reserved = 0;
4016 pcfg1Data->Configuration = cpu_to_le32(configuration); 3898 pcfg1Data->Configuration = cpu_to_le32(configuration);
4017 cfg.pageAddr = (bus<<8) | id; 3899 cfg.pageAddr = (vtarget->bus_id<<8) | id;
4018 mpt_config(hd->ioc, &cfg); 3900 mpt_config(hd->ioc, &cfg);
4019 } 3901 }
3902 } else {
3903 flags = vtarget->negoFlags;
3904 mptscsih_setDevicePage1Flags(0, MPT_ASYNC, 0, &requested,
3905 &configuration, flags);
3906 dnegoprintk(("syncronize cache: id=%d width=0 factor=MPT_ASYNC "
3907 "offset=0 negoFlags=%x request=%x config=%x\n",
3908 vtarget->target_id, flags, requested, configuration));
3909 pcfg1Data->RequestedParameters = cpu_to_le32(requested);
3910 pcfg1Data->Reserved = 0;
3911 pcfg1Data->Configuration = cpu_to_le32(configuration);
3912 cfg.pageAddr = (vtarget->bus_id<<8) | vtarget->target_id;
3913 mpt_config(hd->ioc, &cfg);
3914 }
4020 3915
4021 /* If target Ptr NULL or if this target is NOT a disk, skip. 3916 if (pcfg1Data)
4022 */ 3917 pci_free_consistent(ioc->pcidev, header.PageLength * 4, pcfg1Data, cfg1_dma_addr);
4023 if ((pTarget) && (pTarget->inq_data[0] == TYPE_DISK)){ 3918}
4024 for (lun=0; lun <= MPT_LAST_LUN; lun++) {
4025 /* If LUN present, issue the command
4026 */
4027 lun_index = (lun >> 5); /* 32 luns per lun_index */
4028 indexed_lun = (lun % 32);
4029 if (pTarget->luns[lun_index] & (1<<indexed_lun)) {
4030 iocmd.lun = lun;
4031 (void) mptscsih_do_cmd(hd, &iocmd);
4032 }
4033 }
4034 }
4035 3919
4036 /* get next relevant device */ 3920/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4037 id++; 3921/**
3922 * mptscsih_synchronize_cache - Send SYNCHRONIZE_CACHE to all disks.
3923 * @hd: Pointer to a SCSI HOST structure
3924 * @vtarget: per device private data
3925 * @lun: lun
3926 *
3927 * Uses the ISR, but with special processing.
3928 * MUST be single-threaded.
3929 *
3930 */
3931static void
3932mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
3933{
3934 INTERNAL_CMD iocmd;
4038 3935
4039 if (id == hostId) 3936 /* Following parameters will not change
4040 id++; 3937 * in this routine.
3938 */
3939 iocmd.cmd = SYNCHRONIZE_CACHE;
3940 iocmd.flags = 0;
3941 iocmd.physDiskNum = -1;
3942 iocmd.data = NULL;
3943 iocmd.data_dma = -1;
3944 iocmd.size = 0;
3945 iocmd.rsvd = iocmd.rsvd2 = 0;
3946 iocmd.bus = vdevice->bus_id;
3947 iocmd.id = vdevice->target_id;
3948 iocmd.lun = (u8)vdevice->lun;
4041 3949
4042 if (id > max_id) { 3950 if ((vdevice->vtarget->type & TYPE_DISK) &&
4043 id = 0; 3951 (vdevice->configured_lun))
4044 bus++; 3952 mptscsih_do_cmd(hd, &iocmd);
4045 } 3953}
4046 }
4047 3954
4048 if (pcfg1Data) { 3955/* Search IOC page 3 to determine if this is hidden physical disk
4049 pci_free_consistent(ioc->pcidev, header1.PageLength * 4, pcfg1Data, cfg1_dma_addr); 3956 */
3957/* Search IOC page 3 to determine if this is hidden physical disk
3958 */
3959static int
3960mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id)
3961{
3962 int i;
3963
3964 if (!ioc->raid_data.isRaid || !ioc->raid_data.pIocPg3)
3965 return 0;
3966
3967 for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) {
3968 if (id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID)
3969 return 1;
4050 } 3970 }
4051 3971
4052 return 0; 3972 return 0;
@@ -4101,8 +4021,8 @@ mptscsih_domainValidation(void *arg)
4101 4021
4102 msleep(250); 4022 msleep(250);
4103 4023
4104 /* DV only to SCSI adapters */ 4024 /* DV only to SPI adapters */
4105 if (ioc->bus_type != SCSI) 4025 if (ioc->bus_type != SPI)
4106 continue; 4026 continue;
4107 4027
4108 /* Make sure everything looks ok */ 4028 /* Make sure everything looks ok */
@@ -4205,32 +4125,12 @@ mptscsih_domainValidation(void *arg)
4205 return; 4125 return;
4206} 4126}
4207 4127
4208/* Search IOC page 3 to determine if this is hidden physical disk
4209 */
4210/* Search IOC page 3 to determine if this is hidden physical disk
4211 */
4212static int
4213mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id)
4214{
4215 int i;
4216
4217 if (!ioc->raid_data.isRaid || !ioc->raid_data.pIocPg3)
4218 return 0;
4219
4220 for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) {
4221 if (id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID)
4222 return 1;
4223 }
4224
4225 return 0;
4226}
4227
4228/* Write SDP1 if no QAS has been enabled 4128/* Write SDP1 if no QAS has been enabled
4229 */ 4129 */
4230static void 4130static void
4231mptscsih_qas_check(MPT_SCSI_HOST *hd, int id) 4131mptscsih_qas_check(MPT_SCSI_HOST *hd, int id)
4232{ 4132{
4233 VirtDevice *pTarget; 4133 VirtTarget *vtarget;
4234 int ii; 4134 int ii;
4235 4135
4236 if (hd->Targets == NULL) 4136 if (hd->Targets == NULL)
@@ -4243,11 +4143,11 @@ mptscsih_qas_check(MPT_SCSI_HOST *hd, int id)
4243 if ((hd->ioc->spi_data.dvStatus[ii] & MPT_SCSICFG_DV_NOT_DONE) != 0) 4143 if ((hd->ioc->spi_data.dvStatus[ii] & MPT_SCSICFG_DV_NOT_DONE) != 0)
4244 continue; 4144 continue;
4245 4145
4246 pTarget = hd->Targets[ii]; 4146 vtarget = hd->Targets[ii];
4247 4147
4248 if ((pTarget != NULL) && (!pTarget->raidVolume)) { 4148 if ((vtarget != NULL) && (!vtarget->raidVolume)) {
4249 if ((pTarget->negoFlags & hd->ioc->spi_data.noQas) == 0) { 4149 if ((vtarget->negoFlags & hd->ioc->spi_data.noQas) == 0) {
4250 pTarget->negoFlags |= hd->ioc->spi_data.noQas; 4150 vtarget->negoFlags |= hd->ioc->spi_data.noQas;
4251 dnegoprintk(("writeSDP1: id=%d flags=0\n", id)); 4151 dnegoprintk(("writeSDP1: id=%d flags=0\n", id));
4252 mptscsih_writeSDP1(hd, 0, ii, 0); 4152 mptscsih_writeSDP1(hd, 0, ii, 0);
4253 } 4153 }
@@ -4287,7 +4187,7 @@ static int
4287mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) 4187mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4288{ 4188{
4289 MPT_ADAPTER *ioc = hd->ioc; 4189 MPT_ADAPTER *ioc = hd->ioc;
4290 VirtDevice *pTarget; 4190 VirtTarget *vtarget;
4291 SCSIDevicePage1_t *pcfg1Data; 4191 SCSIDevicePage1_t *pcfg1Data;
4292 SCSIDevicePage0_t *pcfg0Data; 4192 SCSIDevicePage0_t *pcfg0Data;
4293 u8 *pbuf1; 4193 u8 *pbuf1;
@@ -4358,12 +4258,12 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4358 iocmd.physDiskNum = -1; 4258 iocmd.physDiskNum = -1;
4359 iocmd.rsvd = iocmd.rsvd2 = 0; 4259 iocmd.rsvd = iocmd.rsvd2 = 0;
4360 4260
4361 pTarget = hd->Targets[id]; 4261 vtarget = hd->Targets[id];
4362 4262
4363 /* Use tagged commands if possible. 4263 /* Use tagged commands if possible.
4364 */ 4264 */
4365 if (pTarget) { 4265 if (vtarget) {
4366 if (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES) 4266 if (vtarget->tflags & MPT_TARGET_FLAGS_Q_YES)
4367 iocmd.flags |= MPT_ICFLAG_TAGGED_CMD; 4267 iocmd.flags |= MPT_ICFLAG_TAGGED_CMD;
4368 else { 4268 else {
4369 if (hd->ioc->facts.FWVersion.Word < 0x01000600) 4269 if (hd->ioc->facts.FWVersion.Word < 0x01000600)
@@ -4579,7 +4479,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4579 /* Reset the size for disks 4479 /* Reset the size for disks
4580 */ 4480 */
4581 inq0 = (*pbuf1) & 0x1F; 4481 inq0 = (*pbuf1) & 0x1F;
4582 if ((inq0 == 0) && pTarget && !pTarget->raidVolume) { 4482 if ((inq0 == 0) && vtarget && !vtarget->raidVolume) {
4583 sz = 0x40; 4483 sz = 0x40;
4584 iocmd.size = sz; 4484 iocmd.size = sz;
4585 } 4485 }
@@ -4589,8 +4489,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4589 */ 4489 */
4590 if (inq0 == TYPE_PROCESSOR) { 4490 if (inq0 == TYPE_PROCESSOR) {
4591 mptscsih_initTarget(hd, 4491 mptscsih_initTarget(hd,
4592 bus, 4492 vtarget,
4593 id,
4594 lun, 4493 lun,
4595 pbuf1, 4494 pbuf1,
4596 sz); 4495 sz);
@@ -4604,22 +4503,22 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4604 goto target_done; 4503 goto target_done;
4605 4504
4606 if (sz == 0x40) { 4505 if (sz == 0x40) {
4607 if ((pTarget->maxWidth == 1) && (pTarget->maxOffset) && (nfactor < 0x0A) 4506 if ((vtarget->maxWidth == 1) && (vtarget->maxOffset) && (nfactor < 0x0A)
4608 && (pTarget->minSyncFactor > 0x09)) { 4507 && (vtarget->minSyncFactor > 0x09)) {
4609 if ((pbuf1[56] & 0x04) == 0) 4508 if ((pbuf1[56] & 0x04) == 0)
4610 ; 4509 ;
4611 else if ((pbuf1[56] & 0x01) == 1) { 4510 else if ((pbuf1[56] & 0x01) == 1) {
4612 pTarget->minSyncFactor = 4511 vtarget->minSyncFactor =
4613 nfactor > MPT_ULTRA320 ? nfactor : MPT_ULTRA320; 4512 nfactor > MPT_ULTRA320 ? nfactor : MPT_ULTRA320;
4614 } else { 4513 } else {
4615 pTarget->minSyncFactor = 4514 vtarget->minSyncFactor =
4616 nfactor > MPT_ULTRA160 ? nfactor : MPT_ULTRA160; 4515 nfactor > MPT_ULTRA160 ? nfactor : MPT_ULTRA160;
4617 } 4516 }
4618 4517
4619 dv.max.factor = pTarget->minSyncFactor; 4518 dv.max.factor = vtarget->minSyncFactor;
4620 4519
4621 if ((pbuf1[56] & 0x02) == 0) { 4520 if ((pbuf1[56] & 0x02) == 0) {
4622 pTarget->negoFlags |= MPT_TARGET_NO_NEGO_QAS; 4521 vtarget->negoFlags |= MPT_TARGET_NO_NEGO_QAS;
4623 hd->ioc->spi_data.noQas = MPT_TARGET_NO_NEGO_QAS; 4522 hd->ioc->spi_data.noQas = MPT_TARGET_NO_NEGO_QAS;
4624 ddvprintk((MYIOC_s_NOTE_FMT 4523 ddvprintk((MYIOC_s_NOTE_FMT
4625 "DV: Start Basic noQas on id=%d due to pbuf1[56]=%x\n", 4524 "DV: Start Basic noQas on id=%d due to pbuf1[56]=%x\n",
@@ -4702,8 +4601,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4702 "DV:Inquiry compared id=%d, calling initTarget\n", ioc->name, id)); 4601 "DV:Inquiry compared id=%d, calling initTarget\n", ioc->name, id));
4703 hd->ioc->spi_data.dvStatus[id] &= ~MPT_SCSICFG_DV_NOT_DONE; 4602 hd->ioc->spi_data.dvStatus[id] &= ~MPT_SCSICFG_DV_NOT_DONE;
4704 mptscsih_initTarget(hd, 4603 mptscsih_initTarget(hd,
4705 bus, 4604 vtarget,
4706 id,
4707 lun, 4605 lun,
4708 pbuf1, 4606 pbuf1,
4709 sz); 4607 sz);
@@ -5204,7 +5102,7 @@ target_done:
5204static void 5102static void
5205mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage) 5103mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage)
5206{ 5104{
5207 VirtDevice *pTarget; 5105 VirtTarget *vtarget;
5208 SCSIDevicePage0_t *pPage0; 5106 SCSIDevicePage0_t *pPage0;
5209 SCSIDevicePage1_t *pPage1; 5107 SCSIDevicePage1_t *pPage1;
5210 int val = 0, data, configuration; 5108 int val = 0, data, configuration;
@@ -5224,11 +5122,11 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage)
5224 * already throttled back. 5122 * already throttled back.
5225 */ 5123 */
5226 negoFlags = hd->ioc->spi_data.noQas; 5124 negoFlags = hd->ioc->spi_data.noQas;
5227 if ((hd->Targets)&&((pTarget = hd->Targets[(int)id]) != NULL) && !pTarget->raidVolume) { 5125 if ((hd->Targets)&&((vtarget = hd->Targets[(int)id]) != NULL) && !vtarget->raidVolume) {
5228 width = pTarget->maxWidth; 5126 width = vtarget->maxWidth;
5229 offset = pTarget->maxOffset; 5127 offset = vtarget->maxOffset;
5230 factor = pTarget->minSyncFactor; 5128 factor = vtarget->minSyncFactor;
5231 negoFlags |= pTarget->negoFlags; 5129 negoFlags |= vtarget->negoFlags;
5232 } else { 5130 } else {
5233 if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) { 5131 if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) {
5234 data = hd->ioc->spi_data.nvram[id]; 5132 data = hd->ioc->spi_data.nvram[id];
@@ -5430,11 +5328,11 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage)
5430 * or overwrite nvram (phys disks only). 5328 * or overwrite nvram (phys disks only).
5431 */ 5329 */
5432 5330
5433 if ((hd->Targets)&&((pTarget = hd->Targets[(int)id]) != NULL) && !pTarget->raidVolume ) { 5331 if ((hd->Targets)&&((vtarget = hd->Targets[(int)id]) != NULL) && !vtarget->raidVolume ) {
5434 pTarget->maxWidth = dv->now.width; 5332 vtarget->maxWidth = dv->now.width;
5435 pTarget->maxOffset = dv->now.offset; 5333 vtarget->maxOffset = dv->now.offset;
5436 pTarget->minSyncFactor = dv->now.factor; 5334 vtarget->minSyncFactor = dv->now.factor;
5437 pTarget->negoFlags = dv->now.flags; 5335 vtarget->negoFlags = dv->now.flags;
5438 } else { 5336 } else {
5439 /* Preserv all flags, use 5337 /* Preserv all flags, use
5440 * read-modify-write algorithm 5338 * read-modify-write algorithm
@@ -5588,6 +5486,94 @@ mptscsih_fillbuf(char *buffer, int size, int index, int width)
5588 break; 5486 break;
5589 } 5487 }
5590} 5488}
5489
5490/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5491/* If DV disabled (negoNvram set to USE_NVARM) or if not LUN 0, return.
5492 * Else set the NEED_DV flag after Read Capacity Issued (disks)
5493 * or Mode Sense (cdroms).
5494 *
5495 * Tapes, initTarget will set this flag on completion of Inquiry command.
5496 * Called only if DV_NOT_DONE flag is set
5497 */
5498static void
5499mptscsih_set_dvflags(MPT_SCSI_HOST *hd, struct scsi_cmnd *sc)
5500{
5501 MPT_ADAPTER *ioc = hd->ioc;
5502 u8 cmd;
5503 SpiCfgData *pSpi;
5504
5505 ddvtprintk((MYIOC_s_NOTE_FMT
5506 " set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n",
5507 hd->ioc->name, sc->device->id, sc->device->lun , hd->negoNvram, sc->cmnd[0]));
5508
5509 if ((sc->device->lun != 0) || (hd->negoNvram != 0))
5510 return;
5511
5512 cmd = sc->cmnd[0];
5513
5514 if ((cmd == READ_CAPACITY) || (cmd == MODE_SENSE)) {
5515 pSpi = &ioc->spi_data;
5516 if ((ioc->raid_data.isRaid & (1 << sc->device->id)) && ioc->raid_data.pIocPg3) {
5517 /* Set NEED_DV for all hidden disks
5518 */
5519 Ioc3PhysDisk_t *pPDisk = ioc->raid_data.pIocPg3->PhysDisk;
5520 int numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks;
5521
5522 while (numPDisk) {
5523 pSpi->dvStatus[pPDisk->PhysDiskID] |= MPT_SCSICFG_NEED_DV;
5524 ddvtprintk(("NEED_DV set for phys disk id %d\n", pPDisk->PhysDiskID));
5525 pPDisk++;
5526 numPDisk--;
5527 }
5528 }
5529 pSpi->dvStatus[sc->device->id] |= MPT_SCSICFG_NEED_DV;
5530 ddvtprintk(("NEED_DV set for visible disk id %d\n", sc->device->id));
5531 }
5532}
5533
5534/* mptscsih_raid_set_dv_flags()
5535 *
5536 * New or replaced disk. Set DV flag and schedule DV.
5537 */
5538static void
5539mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id)
5540{
5541 MPT_ADAPTER *ioc = hd->ioc;
5542 SpiCfgData *pSpi = &ioc->spi_data;
5543 Ioc3PhysDisk_t *pPDisk;
5544 int numPDisk;
5545
5546 if (hd->negoNvram != 0)
5547 return;
5548
5549 ddvtprintk(("DV requested for phys disk id %d\n", id));
5550 if (ioc->raid_data.pIocPg3) {
5551 pPDisk = ioc->raid_data.pIocPg3->PhysDisk;
5552 numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks;
5553 while (numPDisk) {
5554 if (id == pPDisk->PhysDiskNum) {
5555 pSpi->dvStatus[pPDisk->PhysDiskID] =
5556 (MPT_SCSICFG_NEED_DV | MPT_SCSICFG_DV_NOT_DONE);
5557 pSpi->forceDv = MPT_SCSICFG_NEED_DV;
5558 ddvtprintk(("NEED_DV set for phys disk id %d\n",
5559 pPDisk->PhysDiskID));
5560 break;
5561 }
5562 pPDisk++;
5563 numPDisk--;
5564 }
5565
5566 if (numPDisk == 0) {
5567 /* The physical disk that needs DV was not found
5568 * in the stored IOC Page 3. The driver must reload
5569 * this page. DV routine will set the NEED_DV flag for
5570 * all phys disks that have DV_NOT_DONE set.
5571 */
5572 pSpi->forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3;
5573 ddvtprintk(("phys disk %d not found. Setting reload IOC Pg3 Flag\n",id));
5574 }
5575 }
5576}
5591#endif /* ~MPTSCSIH_ENABLE_DOMAIN_VALIDATION */ 5577#endif /* ~MPTSCSIH_ENABLE_DOMAIN_VALIDATION */
5592 5578
5593EXPORT_SYMBOL(mptscsih_remove); 5579EXPORT_SYMBOL(mptscsih_remove);
@@ -5599,7 +5585,9 @@ EXPORT_SYMBOL(mptscsih_resume);
5599EXPORT_SYMBOL(mptscsih_proc_info); 5585EXPORT_SYMBOL(mptscsih_proc_info);
5600EXPORT_SYMBOL(mptscsih_info); 5586EXPORT_SYMBOL(mptscsih_info);
5601EXPORT_SYMBOL(mptscsih_qcmd); 5587EXPORT_SYMBOL(mptscsih_qcmd);
5588EXPORT_SYMBOL(mptscsih_target_alloc);
5602EXPORT_SYMBOL(mptscsih_slave_alloc); 5589EXPORT_SYMBOL(mptscsih_slave_alloc);
5590EXPORT_SYMBOL(mptscsih_target_destroy);
5603EXPORT_SYMBOL(mptscsih_slave_destroy); 5591EXPORT_SYMBOL(mptscsih_slave_destroy);
5604EXPORT_SYMBOL(mptscsih_slave_configure); 5592EXPORT_SYMBOL(mptscsih_slave_configure);
5605EXPORT_SYMBOL(mptscsih_abort); 5593EXPORT_SYMBOL(mptscsih_abort);
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index 971fda4b8b57..d3cba12f4bd9 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -91,7 +91,9 @@ extern int mptscsih_resume(struct pci_dev *pdev);
91extern int mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int func); 91extern int mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int func);
92extern const char * mptscsih_info(struct Scsi_Host *SChost); 92extern const char * mptscsih_info(struct Scsi_Host *SChost);
93extern int mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)); 93extern int mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *));
94extern int mptscsih_target_alloc(struct scsi_target *starget);
94extern int mptscsih_slave_alloc(struct scsi_device *device); 95extern int mptscsih_slave_alloc(struct scsi_device *device);
96extern void mptscsih_target_destroy(struct scsi_target *starget);
95extern void mptscsih_slave_destroy(struct scsi_device *device); 97extern void mptscsih_slave_destroy(struct scsi_device *device);
96extern int mptscsih_slave_configure(struct scsi_device *device); 98extern int mptscsih_slave_configure(struct scsi_device *device);
97extern int mptscsih_abort(struct scsi_cmnd * SCpnt); 99extern int mptscsih_abort(struct scsi_cmnd * SCpnt);
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index 5c0e307d1d5d..ce332a6085e5 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -103,13 +103,16 @@ static int mptspiTaskCtx = -1;
103static int mptspiInternalCtx = -1; /* Used only for internal commands */ 103static int mptspiInternalCtx = -1; /* Used only for internal commands */
104 104
105static struct scsi_host_template mptspi_driver_template = { 105static struct scsi_host_template mptspi_driver_template = {
106 .module = THIS_MODULE,
106 .proc_name = "mptspi", 107 .proc_name = "mptspi",
107 .proc_info = mptscsih_proc_info, 108 .proc_info = mptscsih_proc_info,
108 .name = "MPT SPI Host", 109 .name = "MPT SPI Host",
109 .info = mptscsih_info, 110 .info = mptscsih_info,
110 .queuecommand = mptscsih_qcmd, 111 .queuecommand = mptscsih_qcmd,
112 .target_alloc = mptscsih_target_alloc,
111 .slave_alloc = mptscsih_slave_alloc, 113 .slave_alloc = mptscsih_slave_alloc,
112 .slave_configure = mptscsih_slave_configure, 114 .slave_configure = mptscsih_slave_configure,
115 .target_destroy = mptscsih_target_destroy,
113 .slave_destroy = mptscsih_slave_destroy, 116 .slave_destroy = mptscsih_slave_destroy,
114 .change_queue_depth = mptscsih_change_queue_depth, 117 .change_queue_depth = mptscsih_change_queue_depth,
115 .eh_abort_handler = mptscsih_abort, 118 .eh_abort_handler = mptscsih_abort,
@@ -177,13 +180,15 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
177 printk(MYIOC_s_WARN_FMT 180 printk(MYIOC_s_WARN_FMT
178 "Skipping because it's not operational!\n", 181 "Skipping because it's not operational!\n",
179 ioc->name); 182 ioc->name);
180 return -ENODEV; 183 error = -ENODEV;
184 goto out_mptspi_probe;
181 } 185 }
182 186
183 if (!ioc->active) { 187 if (!ioc->active) {
184 printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n", 188 printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n",
185 ioc->name); 189 ioc->name);
186 return -ENODEV; 190 error = -ENODEV;
191 goto out_mptspi_probe;
187 } 192 }
188 193
189 /* Sanity check - ensure at least 1 port is INITIATOR capable 194 /* Sanity check - ensure at least 1 port is INITIATOR capable
@@ -208,7 +213,8 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
208 printk(MYIOC_s_WARN_FMT 213 printk(MYIOC_s_WARN_FMT
209 "Unable to register controller with SCSI subsystem\n", 214 "Unable to register controller with SCSI subsystem\n",
210 ioc->name); 215 ioc->name);
211 return -1; 216 error = -1;
217 goto out_mptspi_probe;
212 } 218 }
213 219
214 spin_lock_irqsave(&ioc->FreeQlock, flags); 220 spin_lock_irqsave(&ioc->FreeQlock, flags);
@@ -286,7 +292,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
286 mem = kmalloc(sz, GFP_ATOMIC); 292 mem = kmalloc(sz, GFP_ATOMIC);
287 if (mem == NULL) { 293 if (mem == NULL) {
288 error = -ENOMEM; 294 error = -ENOMEM;
289 goto mptspi_probe_failed; 295 goto out_mptspi_probe;
290 } 296 }
291 297
292 memset(mem, 0, sz); 298 memset(mem, 0, sz);
@@ -304,14 +310,14 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
304 mem = kmalloc(sz, GFP_ATOMIC); 310 mem = kmalloc(sz, GFP_ATOMIC);
305 if (mem == NULL) { 311 if (mem == NULL) {
306 error = -ENOMEM; 312 error = -ENOMEM;
307 goto mptspi_probe_failed; 313 goto out_mptspi_probe;
308 } 314 }
309 315
310 memset(mem, 0, sz); 316 memset(mem, 0, sz);
311 hd->Targets = (VirtDevice **) mem; 317 hd->Targets = (VirtTarget **) mem;
312 318
313 dprintk((KERN_INFO 319 dprintk((KERN_INFO
314 " Targets @ %p, sz=%d\n", hd->Targets, sz)); 320 " vdev @ %p, sz=%d\n", hd->Targets, sz));
315 321
316 /* Clear the TM flags 322 /* Clear the TM flags
317 */ 323 */
@@ -385,13 +391,13 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
385 if(error) { 391 if(error) {
386 dprintk((KERN_ERR MYNAM 392 dprintk((KERN_ERR MYNAM
387 "scsi_add_host failed\n")); 393 "scsi_add_host failed\n"));
388 goto mptspi_probe_failed; 394 goto out_mptspi_probe;
389 } 395 }
390 396
391 scsi_scan_host(sh); 397 scsi_scan_host(sh);
392 return 0; 398 return 0;
393 399
394mptspi_probe_failed: 400out_mptspi_probe:
395 401
396 mptscsih_remove(pdev); 402 mptscsih_remove(pdev);
397 return error; 403 return error;