aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c575
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.h15
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_proc.c21
3 files changed, 218 insertions, 393 deletions
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index c13e56320010..57d22c4f0081 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -122,8 +122,6 @@
122#include "aic7xxx_osm.h" 122#include "aic7xxx_osm.h"
123#include "aic7xxx_inline.h" 123#include "aic7xxx_inline.h"
124#include <scsi/scsicam.h> 124#include <scsi/scsicam.h>
125#include <scsi/scsi_transport.h>
126#include <scsi/scsi_transport_spi.h>
127 125
128static struct scsi_transport_template *ahc_linux_transport_template = NULL; 126static struct scsi_transport_template *ahc_linux_transport_template = NULL;
129 127
@@ -423,7 +421,7 @@ MODULE_PARM_DESC(aic7xxx,
423); 421);
424 422
425static void ahc_linux_handle_scsi_status(struct ahc_softc *, 423static void ahc_linux_handle_scsi_status(struct ahc_softc *,
426 struct ahc_linux_device *, 424 struct scsi_device *,
427 struct scb *); 425 struct scb *);
428static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, 426static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc,
429 struct scsi_cmnd *cmd); 427 struct scsi_cmnd *cmd);
@@ -434,17 +432,7 @@ static int ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag);
434static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc); 432static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc);
435static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc, 433static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc,
436 struct ahc_devinfo *devinfo); 434 struct ahc_devinfo *devinfo);
437static void ahc_linux_device_queue_depth(struct ahc_softc *ahc, 435static void ahc_linux_device_queue_depth(struct scsi_device *);
438 struct ahc_linux_device *dev);
439static struct ahc_linux_target* ahc_linux_alloc_target(struct ahc_softc*,
440 u_int, u_int);
441static void ahc_linux_free_target(struct ahc_softc*,
442 struct ahc_linux_target*);
443static struct ahc_linux_device* ahc_linux_alloc_device(struct ahc_softc*,
444 struct ahc_linux_target*,
445 u_int);
446static void ahc_linux_free_device(struct ahc_softc*,
447 struct ahc_linux_device*);
448static int ahc_linux_run_command(struct ahc_softc*, 436static int ahc_linux_run_command(struct ahc_softc*,
449 struct ahc_linux_device *, 437 struct ahc_linux_device *,
450 struct scsi_cmnd *); 438 struct scsi_cmnd *);
@@ -454,32 +442,12 @@ static int aic7xxx_setup(char *s);
454static int ahc_linux_next_unit(void); 442static int ahc_linux_next_unit(void);
455 443
456/********************************* Inlines ************************************/ 444/********************************* Inlines ************************************/
457static __inline struct ahc_linux_device*
458 ahc_linux_get_device(struct ahc_softc *ahc, u_int channel,
459 u_int target, u_int lun);
460static __inline void ahc_linux_unmap_scb(struct ahc_softc*, struct scb*); 445static __inline void ahc_linux_unmap_scb(struct ahc_softc*, struct scb*);
461 446
462static __inline int ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb, 447static __inline int ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb,
463 struct ahc_dma_seg *sg, 448 struct ahc_dma_seg *sg,
464 dma_addr_t addr, bus_size_t len); 449 dma_addr_t addr, bus_size_t len);
465 450
466static __inline struct ahc_linux_device*
467ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, u_int target,
468 u_int lun)
469{
470 struct ahc_linux_target *targ;
471 struct ahc_linux_device *dev;
472 u_int target_offset;
473
474 target_offset = target;
475 if (channel != 0)
476 target_offset += 8;
477 targ = ahc->platform_data->targets[target_offset];
478 BUG_ON(targ == NULL);
479 dev = targ->devices[lun];
480 return dev;
481}
482
483static __inline void 451static __inline void
484ahc_linux_unmap_scb(struct ahc_softc *ahc, struct scb *scb) 452ahc_linux_unmap_scb(struct ahc_softc *ahc, struct scb *scb)
485{ 453{
@@ -611,7 +579,7 @@ static int
611ahc_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *)) 579ahc_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *))
612{ 580{
613 struct ahc_softc *ahc; 581 struct ahc_softc *ahc;
614 struct ahc_linux_device *dev; 582 struct ahc_linux_device *dev = scsi_transport_device_data(cmd->device);
615 583
616 ahc = *(struct ahc_softc **)cmd->device->host->hostdata; 584 ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
617 585
@@ -629,132 +597,162 @@ ahc_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *))
629 if (ahc->platform_data->qfrozen != 0) 597 if (ahc->platform_data->qfrozen != 0)
630 return SCSI_MLQUEUE_HOST_BUSY; 598 return SCSI_MLQUEUE_HOST_BUSY;
631 599
632 dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id,
633 cmd->device->lun);
634 BUG_ON(dev == NULL);
635
636 cmd->result = CAM_REQ_INPROG << 16; 600 cmd->result = CAM_REQ_INPROG << 16;
637 601
638 return ahc_linux_run_command(ahc, dev, cmd); 602 return ahc_linux_run_command(ahc, dev, cmd);
639} 603}
640 604
641static int 605static inline struct scsi_target **
642ahc_linux_slave_alloc(struct scsi_device *device) 606ahc_linux_target_in_softc(struct scsi_target *starget)
643{ 607{
644 struct ahc_softc *ahc; 608 struct ahc_softc *ahc =
645 struct ahc_linux_target *targ; 609 *((struct ahc_softc **)dev_to_shost(&starget->dev)->hostdata);
646 struct scsi_target *starget = device->sdev_target;
647 struct ahc_linux_device *dev;
648 unsigned int target_offset; 610 unsigned int target_offset;
611
612 target_offset = starget->id;
613 if (starget->channel != 0)
614 target_offset += 8;
615
616 return &ahc->platform_data->starget[target_offset];
617}
618
619static int
620ahc_linux_target_alloc(struct scsi_target *starget)
621{
622 struct ahc_softc *ahc =
623 *((struct ahc_softc **)dev_to_shost(&starget->dev)->hostdata);
624 struct seeprom_config *sc = ahc->seep_config;
649 unsigned long flags; 625 unsigned long flags;
650 int retval = -ENOMEM; 626 struct scsi_target **ahc_targp = ahc_linux_target_in_softc(starget);
627 struct ahc_linux_target *targ = scsi_transport_target_data(starget);
628 unsigned short scsirate;
629 struct ahc_devinfo devinfo;
630 struct ahc_initiator_tinfo *tinfo;
631 struct ahc_tmode_tstate *tstate;
632 char channel = starget->channel + 'A';
633 unsigned int our_id = ahc->our_id;
634 unsigned int target_offset;
651 635
652 target_offset = starget->id; 636 target_offset = starget->id;
653 if (starget->channel != 0) 637 if (starget->channel != 0)
654 target_offset += 8; 638 target_offset += 8;
639
640 if (starget->channel)
641 our_id = ahc->our_id_b;
655 642
656 ahc = *((struct ahc_softc **)device->host->hostdata);
657 if (bootverbose)
658 printf("%s: Slave Alloc %d\n", ahc_name(ahc), device->id);
659 ahc_lock(ahc, &flags); 643 ahc_lock(ahc, &flags);
660 targ = ahc->platform_data->targets[target_offset];
661 if (targ == NULL) {
662 struct seeprom_config *sc;
663
664 targ = ahc_linux_alloc_target(ahc, starget->channel,
665 starget->id);
666 sc = ahc->seep_config;
667 if (targ == NULL)
668 goto out;
669 644
670 if (sc) { 645 BUG_ON(*ahc_targp != NULL);
671 unsigned short scsirate;
672 struct ahc_devinfo devinfo;
673 struct ahc_initiator_tinfo *tinfo;
674 struct ahc_tmode_tstate *tstate;
675 char channel = starget->channel + 'A';
676 unsigned int our_id = ahc->our_id;
677 646
678 if (starget->channel) 647 *ahc_targp = starget;
679 our_id = ahc->our_id_b; 648 memset(targ, 0, sizeof(*targ));
680 649
681 if ((ahc->features & AHC_ULTRA2) != 0) { 650 if (sc) {
682 scsirate = sc->device_flags[target_offset] & CFXFER; 651 if ((ahc->features & AHC_ULTRA2) != 0) {
683 } else { 652 scsirate = sc->device_flags[target_offset] & CFXFER;
684 scsirate = (sc->device_flags[target_offset] & CFXFER) << 4; 653 } else {
685 if (sc->device_flags[target_offset] & CFSYNCH) 654 scsirate = (sc->device_flags[target_offset] & CFXFER) << 4;
686 scsirate |= SOFS; 655 if (sc->device_flags[target_offset] & CFSYNCH)
687 } 656 scsirate |= SOFS;
688 if (sc->device_flags[target_offset] & CFWIDEB) {
689 scsirate |= WIDEXFER;
690 spi_max_width(starget) = 1;
691 } else
692 spi_max_width(starget) = 0;
693 spi_min_period(starget) =
694 ahc_find_period(ahc, scsirate, AHC_SYNCRATE_DT);
695 tinfo = ahc_fetch_transinfo(ahc, channel, ahc->our_id,
696 targ->target, &tstate);
697 ahc_compile_devinfo(&devinfo, our_id, targ->target,
698 CAM_LUN_WILDCARD, channel,
699 ROLE_INITIATOR);
700 ahc_set_syncrate(ahc, &devinfo, NULL, 0, 0, 0,
701 AHC_TRANS_GOAL, /*paused*/FALSE);
702 ahc_set_width(ahc, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
703 AHC_TRANS_GOAL, /*paused*/FALSE);
704 } 657 }
705 658 if (sc->device_flags[target_offset] & CFWIDEB) {
706 } 659 scsirate |= WIDEXFER;
707 dev = targ->devices[device->lun]; 660 spi_max_width(starget) = 1;
708 if (dev == NULL) { 661 } else
709 dev = ahc_linux_alloc_device(ahc, targ, device->lun); 662 spi_max_width(starget) = 0;
710 if (dev == NULL) 663 spi_min_period(starget) =
711 goto out; 664 ahc_find_period(ahc, scsirate, AHC_SYNCRATE_DT);
665 tinfo = ahc_fetch_transinfo(ahc, channel, ahc->our_id,
666 starget->id, &tstate);
712 } 667 }
713 retval = 0; 668 ahc_compile_devinfo(&devinfo, our_id, starget->id,
714 669 CAM_LUN_WILDCARD, channel,
715 out: 670 ROLE_INITIATOR);
671 ahc_set_syncrate(ahc, &devinfo, NULL, 0, 0, 0,
672 AHC_TRANS_GOAL, /*paused*/FALSE);
673 ahc_set_width(ahc, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
674 AHC_TRANS_GOAL, /*paused*/FALSE);
716 ahc_unlock(ahc, &flags); 675 ahc_unlock(ahc, &flags);
717 return retval; 676
677 return 0;
678}
679
680static void
681ahc_linux_target_destroy(struct scsi_target *starget)
682{
683 struct scsi_target **ahc_targp = ahc_linux_target_in_softc(starget);
684
685 *ahc_targp = NULL;
686}
687
688static int
689ahc_linux_slave_alloc(struct scsi_device *sdev)
690{
691 struct ahc_softc *ahc =
692 *((struct ahc_softc **)sdev->host->hostdata);
693 struct scsi_target *starget = sdev->sdev_target;
694 struct ahc_linux_target *targ = scsi_transport_target_data(starget);
695 struct ahc_linux_device *dev;
696
697 if (bootverbose)
698 printf("%s: Slave Alloc %d\n", ahc_name(ahc), sdev->id);
699
700 BUG_ON(targ->sdev[sdev->lun] != NULL);
701
702 dev = scsi_transport_device_data(sdev);
703 memset(dev, 0, sizeof(*dev));
704
705 /*
706 * We start out life using untagged
707 * transactions of which we allow one.
708 */
709 dev->openings = 1;
710
711 /*
712 * Set maxtags to 0. This will be changed if we
713 * later determine that we are dealing with
714 * a tagged queuing capable device.
715 */
716 dev->maxtags = 0;
717
718 targ->sdev[sdev->lun] = sdev;
719
720 return 0;
718} 721}
719 722
720static int 723static int
721ahc_linux_slave_configure(struct scsi_device *device) 724ahc_linux_slave_configure(struct scsi_device *sdev)
722{ 725{
723 struct ahc_softc *ahc; 726 struct ahc_softc *ahc;
724 struct ahc_linux_device *dev;
725 727
726 ahc = *((struct ahc_softc **)device->host->hostdata); 728 ahc = *((struct ahc_softc **)sdev->host->hostdata);
727 729
728 if (bootverbose) 730 if (bootverbose)
729 printf("%s: Slave Configure %d\n", ahc_name(ahc), device->id); 731 printf("%s: Slave Configure %d\n", ahc_name(ahc), sdev->id);
730 732
731 dev = ahc_linux_get_device(ahc, device->channel, device->id, 733 ahc_linux_device_queue_depth(sdev);
732 device->lun);
733 dev->scsi_device = device;
734 ahc_linux_device_queue_depth(ahc, dev);
735 734
736 /* Initial Domain Validation */ 735 /* Initial Domain Validation */
737 if (!spi_initial_dv(device->sdev_target)) 736 if (!spi_initial_dv(sdev->sdev_target))
738 spi_dv_device(device); 737 spi_dv_device(sdev);
739 738
740 return 0; 739 return 0;
741} 740}
742 741
743static void 742static void
744ahc_linux_slave_destroy(struct scsi_device *device) 743ahc_linux_slave_destroy(struct scsi_device *sdev)
745{ 744{
746 struct ahc_softc *ahc; 745 struct ahc_softc *ahc;
747 struct ahc_linux_device *dev; 746 struct ahc_linux_device *dev = scsi_transport_device_data(sdev);
747 struct ahc_linux_target *targ = scsi_transport_target_data(sdev->sdev_target);
748 748
749 ahc = *((struct ahc_softc **)device->host->hostdata); 749 ahc = *((struct ahc_softc **)sdev->host->hostdata);
750 if (bootverbose) 750 if (bootverbose)
751 printf("%s: Slave Destroy %d\n", ahc_name(ahc), device->id); 751 printf("%s: Slave Destroy %d\n", ahc_name(ahc), sdev->id);
752 dev = ahc_linux_get_device(ahc, device->channel,
753 device->id, device->lun);
754 752
755 BUG_ON(dev->active); 753 BUG_ON(dev->active);
756 754
757 ahc_linux_free_device(ahc, dev); 755 targ->sdev[sdev->lun] = NULL;
758} 756}
759 757
760#if defined(__i386__) 758#if defined(__i386__)
@@ -874,6 +872,8 @@ struct scsi_host_template aic7xxx_driver_template = {
874 .slave_alloc = ahc_linux_slave_alloc, 872 .slave_alloc = ahc_linux_slave_alloc,
875 .slave_configure = ahc_linux_slave_configure, 873 .slave_configure = ahc_linux_slave_configure,
876 .slave_destroy = ahc_linux_slave_destroy, 874 .slave_destroy = ahc_linux_slave_destroy,
875 .target_alloc = ahc_linux_target_alloc,
876 .target_destroy = ahc_linux_target_destroy,
877}; 877};
878 878
879/**************************** Tasklet Handler *********************************/ 879/**************************** Tasklet Handler *********************************/
@@ -1335,8 +1335,7 @@ ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg)
1335void 1335void
1336ahc_platform_free(struct ahc_softc *ahc) 1336ahc_platform_free(struct ahc_softc *ahc)
1337{ 1337{
1338 struct ahc_linux_target *targ; 1338 struct scsi_target *starget;
1339 struct ahc_linux_device *dev;
1340 int i, j; 1339 int i, j;
1341 1340
1342 if (ahc->platform_data != NULL) { 1341 if (ahc->platform_data != NULL) {
@@ -1347,22 +1346,17 @@ ahc_platform_free(struct ahc_softc *ahc)
1347 1346
1348 /* destroy all of the device and target objects */ 1347 /* destroy all of the device and target objects */
1349 for (i = 0; i < AHC_NUM_TARGETS; i++) { 1348 for (i = 0; i < AHC_NUM_TARGETS; i++) {
1350 targ = ahc->platform_data->targets[i]; 1349 starget = ahc->platform_data->starget[i];
1351 if (targ != NULL) { 1350 if (starget != NULL) {
1352 /* Keep target around through the loop. */
1353 targ->refcount++;
1354 for (j = 0; j < AHC_NUM_LUNS; j++) { 1351 for (j = 0; j < AHC_NUM_LUNS; j++) {
1352 struct ahc_linux_target *targ =
1353 scsi_transport_target_data(starget);
1355 1354
1356 if (targ->devices[j] == NULL) 1355 if (targ->sdev[j] == NULL)
1357 continue; 1356 continue;
1358 dev = targ->devices[j]; 1357 targ->sdev[j] = NULL;
1359 ahc_linux_free_device(ahc, dev);
1360 } 1358 }
1361 /* 1359 ahc->platform_data->starget[i] = NULL;
1362 * Forcibly free the target now that
1363 * all devices are gone.
1364 */
1365 ahc_linux_free_target(ahc, targ);
1366 } 1360 }
1367 } 1361 }
1368 1362
@@ -1395,15 +1389,25 @@ void
1395ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, 1389ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
1396 ahc_queue_alg alg) 1390 ahc_queue_alg alg)
1397{ 1391{
1392 struct scsi_target *starget;
1393 struct ahc_linux_target *targ;
1398 struct ahc_linux_device *dev; 1394 struct ahc_linux_device *dev;
1395 struct scsi_device *sdev;
1396 u_int target_offset;
1399 int was_queuing; 1397 int was_queuing;
1400 int now_queuing; 1398 int now_queuing;
1401 1399
1402 dev = ahc_linux_get_device(ahc, devinfo->channel - 'A', 1400 target_offset = devinfo->target;
1403 devinfo->target, 1401 if (devinfo->channel != 'A')
1404 devinfo->lun); 1402 target_offset += 8;
1405 if (dev == NULL) 1403 starget = ahc->platform_data->starget[target_offset];
1404 targ = scsi_transport_target_data(starget);
1405 BUG_ON(targ == NULL);
1406 sdev = targ->sdev[devinfo->lun];
1407 if (sdev == NULL)
1406 return; 1408 return;
1409 dev = scsi_transport_device_data(sdev);
1410
1407 was_queuing = dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED); 1411 was_queuing = dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED);
1408 switch (alg) { 1412 switch (alg) {
1409 default: 1413 default:
@@ -1454,30 +1458,28 @@ ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
1454 dev->maxtags = 0; 1458 dev->maxtags = 0;
1455 dev->openings = 1 - dev->active; 1459 dev->openings = 1 - dev->active;
1456 } 1460 }
1457 if (dev->scsi_device != NULL) { 1461 switch ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED))) {
1458 switch ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED))) { 1462 case AHC_DEV_Q_BASIC:
1459 case AHC_DEV_Q_BASIC: 1463 scsi_adjust_queue_depth(sdev,
1460 scsi_adjust_queue_depth(dev->scsi_device, 1464 MSG_SIMPLE_TASK,
1461 MSG_SIMPLE_TASK, 1465 dev->openings + dev->active);
1462 dev->openings + dev->active); 1466 break;
1463 break; 1467 case AHC_DEV_Q_TAGGED:
1464 case AHC_DEV_Q_TAGGED: 1468 scsi_adjust_queue_depth(sdev,
1465 scsi_adjust_queue_depth(dev->scsi_device, 1469 MSG_ORDERED_TASK,
1466 MSG_ORDERED_TASK, 1470 dev->openings + dev->active);
1467 dev->openings + dev->active); 1471 break;
1468 break; 1472 default:
1469 default: 1473 /*
1470 /* 1474 * We allow the OS to queue 2 untagged transactions to
1471 * We allow the OS to queue 2 untagged transactions to 1475 * us at any time even though we can only execute them
1472 * us at any time even though we can only execute them 1476 * serially on the controller/device. This should
1473 * serially on the controller/device. This should 1477 * remove some latency.
1474 * remove some latency. 1478 */
1475 */ 1479 scsi_adjust_queue_depth(sdev,
1476 scsi_adjust_queue_depth(dev->scsi_device, 1480 /*NON-TAGGED*/0,
1477 /*NON-TAGGED*/0, 1481 /*queue depth*/2);
1478 /*queue depth*/2); 1482 break;
1479 break;
1480 }
1481 } 1483 }
1482} 1484}
1483 1485
@@ -1523,22 +1525,20 @@ ahc_linux_user_tagdepth(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
1523 * Determines the queue depth for a given device. 1525 * Determines the queue depth for a given device.
1524 */ 1526 */
1525static void 1527static void
1526ahc_linux_device_queue_depth(struct ahc_softc *ahc, 1528ahc_linux_device_queue_depth(struct scsi_device *sdev)
1527 struct ahc_linux_device *dev)
1528{ 1529{
1529 struct ahc_devinfo devinfo; 1530 struct ahc_devinfo devinfo;
1530 u_int tags; 1531 u_int tags;
1532 struct ahc_softc *ahc = *((struct ahc_softc **)sdev->host->hostdata);
1531 1533
1532 ahc_compile_devinfo(&devinfo, 1534 ahc_compile_devinfo(&devinfo,
1533 dev->target->channel == 0 1535 sdev->sdev_target->channel == 0
1534 ? ahc->our_id : ahc->our_id_b, 1536 ? ahc->our_id : ahc->our_id_b,
1535 dev->target->target, dev->lun, 1537 sdev->sdev_target->id, sdev->lun,
1536 dev->target->channel == 0 ? 'A' : 'B', 1538 sdev->sdev_target->channel == 0 ? 'A' : 'B',
1537 ROLE_INITIATOR); 1539 ROLE_INITIATOR);
1538 tags = ahc_linux_user_tagdepth(ahc, &devinfo); 1540 tags = ahc_linux_user_tagdepth(ahc, &devinfo);
1539 if (tags != 0 1541 if (tags != 0 && sdev->tagged_supported != 0) {
1540 && dev->scsi_device != NULL
1541 && dev->scsi_device->tagged_supported != 0) {
1542 1542
1543 ahc_set_tags(ahc, &devinfo, AHC_QUEUE_TAGGED); 1543 ahc_set_tags(ahc, &devinfo, AHC_QUEUE_TAGGED);
1544 ahc_print_devinfo(ahc, &devinfo); 1544 ahc_print_devinfo(ahc, &devinfo);
@@ -1767,106 +1767,6 @@ ahc_platform_flushwork(struct ahc_softc *ahc)
1767 1767
1768} 1768}
1769 1769
1770static struct ahc_linux_target*
1771ahc_linux_alloc_target(struct ahc_softc *ahc, u_int channel, u_int target)
1772{
1773 struct ahc_linux_target *targ;
1774 u_int target_offset;
1775
1776 target_offset = target;
1777 if (channel != 0)
1778 target_offset += 8;
1779
1780 targ = malloc(sizeof(*targ), M_DEVBUG, M_NOWAIT);
1781 if (targ == NULL)
1782 return (NULL);
1783 memset(targ, 0, sizeof(*targ));
1784 targ->channel = channel;
1785 targ->target = target;
1786 targ->ahc = ahc;
1787 ahc->platform_data->targets[target_offset] = targ;
1788 return (targ);
1789}
1790
1791static void
1792ahc_linux_free_target(struct ahc_softc *ahc, struct ahc_linux_target *targ)
1793{
1794 struct ahc_devinfo devinfo;
1795 struct ahc_initiator_tinfo *tinfo;
1796 struct ahc_tmode_tstate *tstate;
1797 u_int our_id;
1798 u_int target_offset;
1799 char channel;
1800
1801 /*
1802 * Force a negotiation to async/narrow on any
1803 * future command to this device unless a bus
1804 * reset occurs between now and that command.
1805 */
1806 channel = 'A' + targ->channel;
1807 our_id = ahc->our_id;
1808 target_offset = targ->target;
1809 if (targ->channel != 0) {
1810 target_offset += 8;
1811 our_id = ahc->our_id_b;
1812 }
1813 tinfo = ahc_fetch_transinfo(ahc, channel, our_id,
1814 targ->target, &tstate);
1815 ahc_compile_devinfo(&devinfo, our_id, targ->target, CAM_LUN_WILDCARD,
1816 channel, ROLE_INITIATOR);
1817 ahc_set_syncrate(ahc, &devinfo, NULL, 0, 0, 0,
1818 AHC_TRANS_GOAL, /*paused*/FALSE);
1819 ahc_set_width(ahc, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
1820 AHC_TRANS_GOAL, /*paused*/FALSE);
1821 ahc_update_neg_request(ahc, &devinfo, tstate, tinfo, AHC_NEG_ALWAYS);
1822 ahc->platform_data->targets[target_offset] = NULL;
1823 free(targ, M_DEVBUF);
1824}
1825
1826static struct ahc_linux_device*
1827ahc_linux_alloc_device(struct ahc_softc *ahc,
1828 struct ahc_linux_target *targ, u_int lun)
1829{
1830 struct ahc_linux_device *dev;
1831
1832 dev = malloc(sizeof(*dev), M_DEVBUG, M_NOWAIT);
1833 if (dev == NULL)
1834 return (NULL);
1835 memset(dev, 0, sizeof(*dev));
1836 dev->lun = lun;
1837 dev->target = targ;
1838
1839 /*
1840 * We start out life using untagged
1841 * transactions of which we allow one.
1842 */
1843 dev->openings = 1;
1844
1845 /*
1846 * Set maxtags to 0. This will be changed if we
1847 * later determine that we are dealing with
1848 * a tagged queuing capable device.
1849 */
1850 dev->maxtags = 0;
1851
1852 targ->refcount++;
1853 targ->devices[lun] = dev;
1854 return (dev);
1855}
1856
1857static void
1858ahc_linux_free_device(struct ahc_softc *ahc, struct ahc_linux_device *dev)
1859{
1860 struct ahc_linux_target *targ;
1861
1862 targ = dev->target;
1863 targ->devices[dev->lun] = NULL;
1864 free(dev, M_DEVBUF);
1865 targ->refcount--;
1866 if (targ->refcount == 0)
1867 ahc_linux_free_target(ahc, targ);
1868}
1869
1870void 1770void
1871ahc_send_async(struct ahc_softc *ahc, char channel, 1771ahc_send_async(struct ahc_softc *ahc, char channel,
1872 u_int target, u_int lun, ac_code code, void *arg) 1772 u_int target, u_int lun, ac_code code, void *arg)
@@ -1875,11 +1775,15 @@ ahc_send_async(struct ahc_softc *ahc, char channel,
1875 case AC_TRANSFER_NEG: 1775 case AC_TRANSFER_NEG:
1876 { 1776 {
1877 char buf[80]; 1777 char buf[80];
1778 struct scsi_target *starget;
1878 struct ahc_linux_target *targ; 1779 struct ahc_linux_target *targ;
1879 struct info_str info; 1780 struct info_str info;
1880 struct ahc_initiator_tinfo *tinfo; 1781 struct ahc_initiator_tinfo *tinfo;
1881 struct ahc_tmode_tstate *tstate; 1782 struct ahc_tmode_tstate *tstate;
1882 int target_offset; 1783 int target_offset;
1784 unsigned int target_ppr_options;
1785
1786 BUG_ON(target == CAM_TARGET_WILDCARD);
1883 1787
1884 info.buffer = buf; 1788 info.buffer = buf;
1885 info.length = sizeof(buf); 1789 info.length = sizeof(buf);
@@ -1908,32 +1812,30 @@ ahc_send_async(struct ahc_softc *ahc, char channel,
1908 target_offset = target; 1812 target_offset = target;
1909 if (channel == 'B') 1813 if (channel == 'B')
1910 target_offset += 8; 1814 target_offset += 8;
1911 targ = ahc->platform_data->targets[target_offset]; 1815 starget = ahc->platform_data->starget[target_offset];
1816 targ = scsi_transport_target_data(starget);
1912 if (targ == NULL) 1817 if (targ == NULL)
1913 break; 1818 break;
1914 if (tinfo->curr.period == targ->last_tinfo.period 1819
1915 && tinfo->curr.width == targ->last_tinfo.width 1820 target_ppr_options =
1916 && tinfo->curr.offset == targ->last_tinfo.offset 1821 (spi_dt(starget) ? MSG_EXT_PPR_DT_REQ : 0)
1917 && tinfo->curr.ppr_options == targ->last_tinfo.ppr_options) 1822 + (spi_qas(starget) ? MSG_EXT_PPR_QAS_REQ : 0)
1823 + (spi_iu(starget) ? MSG_EXT_PPR_IU_REQ : 0);
1824
1825 if (tinfo->curr.period == spi_period(starget)
1826 && tinfo->curr.width == spi_width(starget)
1827 && tinfo->curr.offset == spi_offset(starget)
1828 && tinfo->curr.ppr_options == target_ppr_options)
1918 if (bootverbose == 0) 1829 if (bootverbose == 0)
1919 break; 1830 break;
1920 1831
1921 targ->last_tinfo.period = tinfo->curr.period; 1832 spi_period(starget) = tinfo->curr.period;
1922 targ->last_tinfo.width = tinfo->curr.width; 1833 spi_width(starget) = tinfo->curr.width;
1923 targ->last_tinfo.offset = tinfo->curr.offset; 1834 spi_offset(starget) = tinfo->curr.offset;
1924 targ->last_tinfo.ppr_options = tinfo->curr.ppr_options; 1835 spi_dt(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_DT_REQ;
1925 1836 spi_qas(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_QAS_REQ;
1926 printf("(%s:%c:", ahc_name(ahc), channel); 1837 spi_iu(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ;
1927 if (target == CAM_TARGET_WILDCARD) 1838 spi_display_xfer_agreement(starget);
1928 printf("*): ");
1929 else
1930 printf("%d): ", target);
1931 ahc_format_transinfo(&info, &tinfo->curr);
1932 if (info.pos < info.length)
1933 *info.buffer = '\0';
1934 else
1935 buf[info.length - 1] = '\0';
1936 printf("%s", buf);
1937 break; 1839 break;
1938 } 1840 }
1939 case AC_SENT_BDR: 1841 case AC_SENT_BDR:
@@ -2038,7 +1940,7 @@ ahc_done(struct ahc_softc *ahc, struct scb *scb)
2038 ahc_set_transaction_status(scb, CAM_REQ_CMP); 1940 ahc_set_transaction_status(scb, CAM_REQ_CMP);
2039 } 1941 }
2040 } else if (ahc_get_transaction_status(scb) == CAM_SCSI_STATUS_ERROR) { 1942 } else if (ahc_get_transaction_status(scb) == CAM_SCSI_STATUS_ERROR) {
2041 ahc_linux_handle_scsi_status(ahc, dev, scb); 1943 ahc_linux_handle_scsi_status(ahc, cmd->device, scb);
2042 } 1944 }
2043 1945
2044 if (dev->openings == 1 1946 if (dev->openings == 1
@@ -2077,14 +1979,15 @@ ahc_done(struct ahc_softc *ahc, struct scb *scb)
2077 1979
2078static void 1980static void
2079ahc_linux_handle_scsi_status(struct ahc_softc *ahc, 1981ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
2080 struct ahc_linux_device *dev, struct scb *scb) 1982 struct scsi_device *sdev, struct scb *scb)
2081{ 1983{
2082 struct ahc_devinfo devinfo; 1984 struct ahc_devinfo devinfo;
1985 struct ahc_linux_device *dev = scsi_transport_device_data(sdev);
2083 1986
2084 ahc_compile_devinfo(&devinfo, 1987 ahc_compile_devinfo(&devinfo,
2085 ahc->our_id, 1988 ahc->our_id,
2086 dev->target->target, dev->lun, 1989 sdev->sdev_target->id, sdev->lun,
2087 dev->target->channel == 0 ? 'A' : 'B', 1990 sdev->sdev_target->channel == 0 ? 'A' : 'B',
2088 ROLE_INITIATOR); 1991 ROLE_INITIATOR);
2089 1992
2090 /* 1993 /*
@@ -2368,8 +2271,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2368 * at all, and the system wanted us to just abort the 2271 * at all, and the system wanted us to just abort the
2369 * command, return success. 2272 * command, return success.
2370 */ 2273 */
2371 dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id, 2274 dev = scsi_transport_device_data(cmd->device);
2372 cmd->device->lun);
2373 2275
2374 if (dev == NULL) { 2276 if (dev == NULL) {
2375 /* 2277 /*
@@ -2626,18 +2528,6 @@ ahc_platform_dump_card_state(struct ahc_softc *ahc)
2626 2528
2627static void ahc_linux_exit(void); 2529static void ahc_linux_exit(void);
2628 2530
2629static void ahc_linux_get_width(struct scsi_target *starget)
2630{
2631 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
2632 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2633 struct ahc_tmode_tstate *tstate;
2634 struct ahc_initiator_tinfo *tinfo
2635 = ahc_fetch_transinfo(ahc,
2636 starget->channel + 'A',
2637 shost->this_id, starget->id, &tstate);
2638 spi_width(starget) = tinfo->curr.width;
2639}
2640
2641static void ahc_linux_set_width(struct scsi_target *starget, int width) 2531static void ahc_linux_set_width(struct scsi_target *starget, int width)
2642{ 2532{
2643 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 2533 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
@@ -2652,18 +2542,6 @@ static void ahc_linux_set_width(struct scsi_target *starget, int width)
2652 ahc_unlock(ahc, &flags); 2542 ahc_unlock(ahc, &flags);
2653} 2543}
2654 2544
2655static void ahc_linux_get_period(struct scsi_target *starget)
2656{
2657 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
2658 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2659 struct ahc_tmode_tstate *tstate;
2660 struct ahc_initiator_tinfo *tinfo
2661 = ahc_fetch_transinfo(ahc,
2662 starget->channel + 'A',
2663 shost->this_id, starget->id, &tstate);
2664 spi_period(starget) = tinfo->curr.period;
2665}
2666
2667static void ahc_linux_set_period(struct scsi_target *starget, int period) 2545static void ahc_linux_set_period(struct scsi_target *starget, int period)
2668{ 2546{
2669 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 2547 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
@@ -2692,7 +2570,6 @@ static void ahc_linux_set_period(struct scsi_target *starget, int period)
2692 2570
2693 /* all PPR requests apart from QAS require wide transfers */ 2571 /* all PPR requests apart from QAS require wide transfers */
2694 if (ppr_options & ~MSG_EXT_PPR_QAS_REQ) { 2572 if (ppr_options & ~MSG_EXT_PPR_QAS_REQ) {
2695 ahc_linux_get_width(starget);
2696 if (spi_width(starget) == 0) 2573 if (spi_width(starget) == 0)
2697 ppr_options &= MSG_EXT_PPR_QAS_REQ; 2574 ppr_options &= MSG_EXT_PPR_QAS_REQ;
2698 } 2575 }
@@ -2704,18 +2581,6 @@ static void ahc_linux_set_period(struct scsi_target *starget, int period)
2704 ahc_unlock(ahc, &flags); 2581 ahc_unlock(ahc, &flags);
2705} 2582}
2706 2583
2707static void ahc_linux_get_offset(struct scsi_target *starget)
2708{
2709 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
2710 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2711 struct ahc_tmode_tstate *tstate;
2712 struct ahc_initiator_tinfo *tinfo
2713 = ahc_fetch_transinfo(ahc,
2714 starget->channel + 'A',
2715 shost->this_id, starget->id, &tstate);
2716 spi_offset(starget) = tinfo->curr.offset;
2717}
2718
2719static void ahc_linux_set_offset(struct scsi_target *starget, int offset) 2584static void ahc_linux_set_offset(struct scsi_target *starget, int offset)
2720{ 2585{
2721 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 2586 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
@@ -2744,18 +2609,6 @@ static void ahc_linux_set_offset(struct scsi_target *starget, int offset)
2744 ahc_unlock(ahc, &flags); 2609 ahc_unlock(ahc, &flags);
2745} 2610}
2746 2611
2747static void ahc_linux_get_dt(struct scsi_target *starget)
2748{
2749 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
2750 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2751 struct ahc_tmode_tstate *tstate;
2752 struct ahc_initiator_tinfo *tinfo
2753 = ahc_fetch_transinfo(ahc,
2754 starget->channel + 'A',
2755 shost->this_id, starget->id, &tstate);
2756 spi_dt(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_DT_REQ;
2757}
2758
2759static void ahc_linux_set_dt(struct scsi_target *starget, int dt) 2612static void ahc_linux_set_dt(struct scsi_target *starget, int dt)
2760{ 2613{
2761 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 2614 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
@@ -2787,18 +2640,6 @@ static void ahc_linux_set_dt(struct scsi_target *starget, int dt)
2787 ahc_unlock(ahc, &flags); 2640 ahc_unlock(ahc, &flags);
2788} 2641}
2789 2642
2790static void ahc_linux_get_qas(struct scsi_target *starget)
2791{
2792 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
2793 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2794 struct ahc_tmode_tstate *tstate;
2795 struct ahc_initiator_tinfo *tinfo
2796 = ahc_fetch_transinfo(ahc,
2797 starget->channel + 'A',
2798 shost->this_id, starget->id, &tstate);
2799 spi_dt(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_QAS_REQ;
2800}
2801
2802static void ahc_linux_set_qas(struct scsi_target *starget, int qas) 2643static void ahc_linux_set_qas(struct scsi_target *starget, int qas)
2803{ 2644{
2804 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 2645 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
@@ -2827,18 +2668,6 @@ static void ahc_linux_set_qas(struct scsi_target *starget, int qas)
2827 ahc_unlock(ahc, &flags); 2668 ahc_unlock(ahc, &flags);
2828} 2669}
2829 2670
2830static void ahc_linux_get_iu(struct scsi_target *starget)
2831{
2832 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
2833 struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata);
2834 struct ahc_tmode_tstate *tstate;
2835 struct ahc_initiator_tinfo *tinfo
2836 = ahc_fetch_transinfo(ahc,
2837 starget->channel + 'A',
2838 shost->this_id, starget->id, &tstate);
2839 spi_dt(starget) = tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ;
2840}
2841
2842static void ahc_linux_set_iu(struct scsi_target *starget, int iu) 2671static void ahc_linux_set_iu(struct scsi_target *starget, int iu)
2843{ 2672{
2844 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 2673 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
@@ -2868,22 +2697,16 @@ static void ahc_linux_set_iu(struct scsi_target *starget, int iu)
2868} 2697}
2869 2698
2870static struct spi_function_template ahc_linux_transport_functions = { 2699static struct spi_function_template ahc_linux_transport_functions = {
2871 .get_offset = ahc_linux_get_offset,
2872 .set_offset = ahc_linux_set_offset, 2700 .set_offset = ahc_linux_set_offset,
2873 .show_offset = 1, 2701 .show_offset = 1,
2874 .get_period = ahc_linux_get_period,
2875 .set_period = ahc_linux_set_period, 2702 .set_period = ahc_linux_set_period,
2876 .show_period = 1, 2703 .show_period = 1,
2877 .get_width = ahc_linux_get_width,
2878 .set_width = ahc_linux_set_width, 2704 .set_width = ahc_linux_set_width,
2879 .show_width = 1, 2705 .show_width = 1,
2880 .get_dt = ahc_linux_get_dt,
2881 .set_dt = ahc_linux_set_dt, 2706 .set_dt = ahc_linux_set_dt,
2882 .show_dt = 1, 2707 .show_dt = 1,
2883 .get_iu = ahc_linux_get_iu,
2884 .set_iu = ahc_linux_set_iu, 2708 .set_iu = ahc_linux_set_iu,
2885 .show_iu = 1, 2709 .show_iu = 1,
2886 .get_qas = ahc_linux_get_qas,
2887 .set_qas = ahc_linux_set_qas, 2710 .set_qas = ahc_linux_set_qas,
2888 .show_qas = 1, 2711 .show_qas = 1,
2889}; 2712};
@@ -2896,6 +2719,10 @@ ahc_linux_init(void)
2896 ahc_linux_transport_template = spi_attach_transport(&ahc_linux_transport_functions); 2719 ahc_linux_transport_template = spi_attach_transport(&ahc_linux_transport_functions);
2897 if (!ahc_linux_transport_template) 2720 if (!ahc_linux_transport_template)
2898 return -ENODEV; 2721 return -ENODEV;
2722 scsi_transport_reserve_target(ahc_linux_transport_template,
2723 sizeof(struct ahc_linux_target));
2724 scsi_transport_reserve_device(ahc_linux_transport_template,
2725 sizeof(struct ahc_linux_device));
2899 if (ahc_linux_detect(&aic7xxx_driver_template)) 2726 if (ahc_linux_detect(&aic7xxx_driver_template))
2900 return 0; 2727 return 0;
2901 spi_release_transport(ahc_linux_transport_template); 2728 spi_release_transport(ahc_linux_transport_template);
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h
index 30c200d5bcd5..b135c8c787bb 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.h
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h
@@ -79,6 +79,8 @@
79#include <scsi/scsi_device.h> 79#include <scsi/scsi_device.h>
80#include <scsi/scsi_host.h> 80#include <scsi/scsi_host.h>
81#include <scsi/scsi_tcq.h> 81#include <scsi/scsi_tcq.h>
82#include <scsi/scsi_transport.h>
83#include <scsi/scsi_transport_spi.h>
82 84
83/* Core SCSI definitions */ 85/* Core SCSI definitions */
84#define AIC_LIB_PREFIX ahc 86#define AIC_LIB_PREFIX ahc
@@ -330,8 +332,6 @@ typedef enum {
330 332
331struct ahc_linux_target; 333struct ahc_linux_target;
332struct ahc_linux_device { 334struct ahc_linux_device {
333 TAILQ_ENTRY(ahc_linux_device) links;
334
335 /* 335 /*
336 * The number of transactions currently 336 * The number of transactions currently
337 * queued to the device. 337 * queued to the device.
@@ -401,17 +401,10 @@ struct ahc_linux_device {
401 */ 401 */
402 u_int commands_since_idle_or_otag; 402 u_int commands_since_idle_or_otag;
403#define AHC_OTAG_THRESH 500 403#define AHC_OTAG_THRESH 500
404
405 int lun;
406 struct scsi_device *scsi_device;
407 struct ahc_linux_target *target;
408}; 404};
409 405
410struct ahc_linux_target { 406struct ahc_linux_target {
411 struct ahc_linux_device *devices[AHC_NUM_LUNS]; 407 struct scsi_device *sdev[AHC_NUM_LUNS];
412 int channel;
413 int target;
414 int refcount;
415 struct ahc_transinfo last_tinfo; 408 struct ahc_transinfo last_tinfo;
416 struct ahc_softc *ahc; 409 struct ahc_softc *ahc;
417}; 410};
@@ -445,7 +438,7 @@ struct ahc_platform_data {
445 /* 438 /*
446 * Fields accessed from interrupt context. 439 * Fields accessed from interrupt context.
447 */ 440 */
448 struct ahc_linux_target *targets[AHC_NUM_TARGETS]; 441 struct scsi_target *starget[AHC_NUM_TARGETS];
449 442
450 spinlock_t spin_lock; 443 spinlock_t spin_lock;
451 u_int qfrozen; 444 u_int qfrozen;
diff --git a/drivers/scsi/aic7xxx/aic7xxx_proc.c b/drivers/scsi/aic7xxx/aic7xxx_proc.c
index 5fece859fbd9..9c7f1056710d 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_proc.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_proc.c
@@ -50,7 +50,7 @@ static void ahc_dump_target_state(struct ahc_softc *ahc,
50 u_int our_id, char channel, 50 u_int our_id, char channel,
51 u_int target_id, u_int target_offset); 51 u_int target_id, u_int target_offset);
52static void ahc_dump_device_state(struct info_str *info, 52static void ahc_dump_device_state(struct info_str *info,
53 struct ahc_linux_device *dev); 53 struct scsi_device *dev);
54static int ahc_proc_write_seeprom(struct ahc_softc *ahc, 54static int ahc_proc_write_seeprom(struct ahc_softc *ahc,
55 char *buffer, int length); 55 char *buffer, int length);
56 56
@@ -142,6 +142,7 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info,
142 u_int target_offset) 142 u_int target_offset)
143{ 143{
144 struct ahc_linux_target *targ; 144 struct ahc_linux_target *targ;
145 struct scsi_target *starget;
145 struct ahc_initiator_tinfo *tinfo; 146 struct ahc_initiator_tinfo *tinfo;
146 struct ahc_tmode_tstate *tstate; 147 struct ahc_tmode_tstate *tstate;
147 int lun; 148 int lun;
@@ -153,7 +154,8 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info,
153 copy_info(info, "Target %d Negotiation Settings\n", target_id); 154 copy_info(info, "Target %d Negotiation Settings\n", target_id);
154 copy_info(info, "\tUser: "); 155 copy_info(info, "\tUser: ");
155 ahc_format_transinfo(info, &tinfo->user); 156 ahc_format_transinfo(info, &tinfo->user);
156 targ = ahc->platform_data->targets[target_offset]; 157 starget = ahc->platform_data->starget[target_offset];
158 targ = scsi_transport_target_data(starget);
157 if (targ == NULL) 159 if (targ == NULL)
158 return; 160 return;
159 161
@@ -163,22 +165,25 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info,
163 ahc_format_transinfo(info, &tinfo->curr); 165 ahc_format_transinfo(info, &tinfo->curr);
164 166
165 for (lun = 0; lun < AHC_NUM_LUNS; lun++) { 167 for (lun = 0; lun < AHC_NUM_LUNS; lun++) {
166 struct ahc_linux_device *dev; 168 struct scsi_device *sdev;
167 169
168 dev = targ->devices[lun]; 170 sdev = targ->sdev[lun];
169 171
170 if (dev == NULL) 172 if (sdev == NULL)
171 continue; 173 continue;
172 174
173 ahc_dump_device_state(info, dev); 175 ahc_dump_device_state(info, sdev);
174 } 176 }
175} 177}
176 178
177static void 179static void
178ahc_dump_device_state(struct info_str *info, struct ahc_linux_device *dev) 180ahc_dump_device_state(struct info_str *info, struct scsi_device *sdev)
179{ 181{
182 struct ahc_linux_device *dev = scsi_transport_device_data(sdev);
183
180 copy_info(info, "\tChannel %c Target %d Lun %d Settings\n", 184 copy_info(info, "\tChannel %c Target %d Lun %d Settings\n",
181 dev->target->channel + 'A', dev->target->target, dev->lun); 185 sdev->sdev_target->channel + 'A',
186 sdev->sdev_target->id, sdev->lun);
182 187
183 copy_info(info, "\t\tCommands Queued %ld\n", dev->commands_issued); 188 copy_info(info, "\t\tCommands Queued %ld\n", dev->commands_issued);
184 copy_info(info, "\t\tCommands Active %d\n", dev->active); 189 copy_info(info, "\t\tCommands Active %d\n", dev->active);