aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/fusion/mptsas.c
diff options
context:
space:
mode:
authorMoore, Eric Dean <Eric.Moore@lsil.com>2005-11-16 20:54:25 -0500
committerJames Bottomley <jejb@mulgrave.(none)>2005-12-13 20:41:15 -0500
commitc7c82987b4844f555d309ccbd42abe95d46822ff (patch)
tree55eb2c02fa1ff25548b1cc673c47aaa19e380214 /drivers/message/fusion/mptsas.c
parentf2ea8671a8376e09cf759aa8cb3de8b8d3bced9e (diff)
[SCSI] mptfusion - mapping fixs required support for transport layers.
This utilizes the hostdata area that is hung off of scsi_target and scsi_device for saving unique firmware mapping. This will be required for supporting new Fibre and SPI transport support. This also fixs problems in error handling error code for SAS controllers, in which the incorrect mapping was passed to the firmware. Signed-off-by: Eric Moore <Eric.Moore@lsil.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/message/fusion/mptsas.c')
-rw-r--r--drivers/message/fusion/mptsas.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 282fb5ebbadf..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,8 +275,10 @@ 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
@@ -283,8 +289,10 @@ static struct scsi_host_template mptsas_driver_template = {
283 .name = "MPT SPI Host", 289 .name = "MPT SPI Host",
284 .info = mptscsih_info, 290 .info = mptscsih_info,
285 .queuecommand = mptscsih_qcmd, 291 .queuecommand = mptscsih_qcmd,
292 .target_alloc = mptscsih_target_alloc,
286 .slave_alloc = mptsas_slave_alloc, 293 .slave_alloc = mptsas_slave_alloc,
287 .slave_configure = mptscsih_slave_configure, 294 .slave_configure = mptscsih_slave_configure,
295 .target_destroy = mptscsih_target_destroy,
288 .slave_destroy = mptscsih_slave_destroy, 296 .slave_destroy = mptscsih_slave_destroy,
289 .change_queue_depth = mptscsih_change_queue_depth, 297 .change_queue_depth = mptscsih_change_queue_depth,
290 .eh_abort_handler = mptscsih_abort, 298 .eh_abort_handler = mptscsih_abort,
@@ -987,7 +995,6 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc, int *index)
987 goto out_free_port_info; 995 goto out_free_port_info;
988 996
989 list_add_tail(&port_info->list, &ioc->sas_topology); 997 list_add_tail(&port_info->list, &ioc->sas_topology);
990
991 for (i = 0; i < port_info->num_phys; i++) { 998 for (i = 0; i < port_info->num_phys; i++) {
992 mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i], 999 mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i],
993 (MPI_SAS_PHY_PGAD_FORM_PHY_NUMBER << 1000 (MPI_SAS_PHY_PGAD_FORM_PHY_NUMBER <<
@@ -1263,10 +1270,10 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1263 } 1270 }
1264 1271
1265 memset(mem, 0, sz); 1272 memset(mem, 0, sz);
1266 hd->Targets = (VirtDevice **) mem; 1273 hd->Targets = (VirtTarget **) mem;
1267 1274
1268 dprintk((KERN_INFO 1275 dprintk((KERN_INFO
1269 " Targets @ %p, sz=%d\n", hd->Targets, sz)); 1276 " vtarget @ %p, sz=%d\n", hd->Targets, sz));
1270 1277
1271 /* Clear the TM flags 1278 /* Clear the TM flags
1272 */ 1279 */