aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/aacraid/aachba.c
diff options
context:
space:
mode:
authorMark Haverkamp <markh@osdl.org>2005-05-16 21:28:42 -0400
committerJames Bottomley <jejb@mulgrave.(none)>2005-05-20 16:48:00 -0400
commit7c00ffa314bf0fb0e23858bbebad33b48b6abbb9 (patch)
tree4d6b65bb5a2c8fecf48a8c6402c2cc867aa2fe6c /drivers/scsi/aacraid/aachba.c
parent672b2d38da4fff4c4452685a25fb88b65243d1a6 (diff)
[SCSI] 2.6 aacraid: Variable FIB size (updated patch)
New code from the Adaptec driver. Performance enhancement for newer adapters. I hope that this isn't too big for a single patch. I believe that other than the few small cleanups mentioned, that the changes are all related. - Added Variable FIB size negotiation for new adapters. - Added support to maximize scatter gather tables and thus permit requests larger than 64KB/each. - Limit Scatter Gather to 34 elements for ROMB platforms. - aac_printf is only enabled with AAC_QUIRK_34SG - Large FIB ioctl support - some minor cleanup Passes sparse check. I have tested it on x86 and ppc64 machines. Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/aacraid/aachba.c')
-rw-r--r--drivers/scsi/aacraid/aachba.c132
1 files changed, 95 insertions, 37 deletions
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 9946e305055b..f02c99641467 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -53,10 +53,6 @@
53#define INQD_PDT_DMASK 0x1F /* Peripheral Device Type Mask */ 53#define INQD_PDT_DMASK 0x1F /* Peripheral Device Type Mask */
54#define INQD_PDT_QMASK 0xE0 /* Peripheral Device Qualifer Mask */ 54#define INQD_PDT_QMASK 0xE0 /* Peripheral Device Qualifer Mask */
55 55
56#define MAX_FIB_DATA (sizeof(struct hw_fib) - sizeof(FIB_HEADER))
57
58#define MAX_DRIVER_SG_SEGMENT_COUNT 17
59
60/* 56/*
61 * Sense codes 57 * Sense codes
62 */ 58 */
@@ -158,6 +154,13 @@ MODULE_PARM_DESC(dacmode, "Control whether dma addressing is using 64 bit DAC. 0
158module_param(commit, int, 0); 154module_param(commit, int, 0);
159MODULE_PARM_DESC(commit, "Control whether a COMMIT_CONFIG is issued to the adapter for foreign arrays.\nThis is typically needed in systems that do not have a BIOS. 0=off, 1=on"); 155MODULE_PARM_DESC(commit, "Control whether a COMMIT_CONFIG is issued to the adapter for foreign arrays.\nThis is typically needed in systems that do not have a BIOS. 0=off, 1=on");
160 156
157int numacb = -1;
158module_param(numacb, int, S_IRUGO|S_IWUSR);
159MODULE_PARM_DESC(numacb, "Request a limit to the number of adapter control blocks (FIB) allocated. Valid\nvalues are 512 and down. Default is to use suggestion from Firmware.");
160
161int acbsize = -1;
162module_param(acbsize, int, S_IRUGO|S_IWUSR);
163MODULE_PARM_DESC(acbsize, "Request a specific adapter control block (FIB) size. Valid values are 512,\n2048, 4096 and 8192. Default is to use suggestion from Firmware.");
161/** 164/**
162 * aac_get_config_status - check the adapter configuration 165 * aac_get_config_status - check the adapter configuration
163 * @common: adapter to query 166 * @common: adapter to query
@@ -462,7 +465,7 @@ static int probe_container(struct aac_dev *dev, int cid)
462 1, 1, 465 1, 1,
463 NULL, NULL); 466 NULL, NULL);
464 if (status < 0) { 467 if (status < 0) {
465 printk(KERN_WARNING "aacraid: probe_containers query failed.\n"); 468 printk(KERN_WARNING "aacraid: probe_container query failed.\n");
466 goto error; 469 goto error;
467 } 470 }
468 471
@@ -605,35 +608,63 @@ static void set_sense(u8 *sense_buf, u8 sense_key, u8 sense_code,
605int aac_get_adapter_info(struct aac_dev* dev) 608int aac_get_adapter_info(struct aac_dev* dev)
606{ 609{
607 struct fib* fibptr; 610 struct fib* fibptr;
608 struct aac_adapter_info* info;
609 int rcode; 611 int rcode;
610 u32 tmp; 612 u32 tmp;
613 struct aac_adapter_info * info;
614
611 if (!(fibptr = fib_alloc(dev))) 615 if (!(fibptr = fib_alloc(dev)))
612 return -ENOMEM; 616 return -ENOMEM;
613 617
614 fib_init(fibptr); 618 fib_init(fibptr);
615 info = (struct aac_adapter_info*) fib_data(fibptr); 619 info = (struct aac_adapter_info *) fib_data(fibptr);
616 620 memset(info,0,sizeof(*info));
617 memset(info,0,sizeof(struct aac_adapter_info));
618 621
619 rcode = fib_send(RequestAdapterInfo, 622 rcode = fib_send(RequestAdapterInfo,
620 fibptr, 623 fibptr,
621 sizeof(struct aac_adapter_info), 624 sizeof(*info),
622 FsaNormal, 625 FsaNormal,
623 1, 1, 626 1, 1,
624 NULL, 627 NULL,
625 NULL); 628 NULL);
629
630 if (rcode < 0) {
631 fib_complete(fibptr);
632 fib_free(fibptr);
633 return rcode;
634 }
635 memcpy(&dev->adapter_info, info, sizeof(*info));
626 636
627 memcpy(&dev->adapter_info, info, sizeof(struct aac_adapter_info)); 637 if (dev->adapter_info.options & AAC_OPT_SUPPLEMENT_ADAPTER_INFO) {
638 struct aac_supplement_adapter_info * info;
639
640 fib_init(fibptr);
641
642 info = (struct aac_supplement_adapter_info *) fib_data(fibptr);
643
644 memset(info,0,sizeof(*info));
645
646 rcode = fib_send(RequestSupplementAdapterInfo,
647 fibptr,
648 sizeof(*info),
649 FsaNormal,
650 1, 1,
651 NULL,
652 NULL);
653
654 if (rcode >= 0)
655 memcpy(&dev->supplement_adapter_info, info, sizeof(*info));
656 }
628 657
629 tmp = le32_to_cpu(dev->adapter_info.kernelrev); 658 tmp = le32_to_cpu(dev->adapter_info.kernelrev);
630 printk(KERN_INFO "%s%d: kernel %d.%d-%d[%d]\n", 659 printk(KERN_INFO "%s%d: kernel %d.%d-%d[%d] %.*s\n",
631 dev->name, 660 dev->name,
632 dev->id, 661 dev->id,
633 tmp>>24, 662 tmp>>24,
634 (tmp>>16)&0xff, 663 (tmp>>16)&0xff,
635 tmp&0xff, 664 tmp&0xff,
636 le32_to_cpu(dev->adapter_info.kernelbuild)); 665 le32_to_cpu(dev->adapter_info.kernelbuild),
666 (int)sizeof(dev->supplement_adapter_info.BuildDate),
667 dev->supplement_adapter_info.BuildDate);
637 tmp = le32_to_cpu(dev->adapter_info.monitorrev); 668 tmp = le32_to_cpu(dev->adapter_info.monitorrev);
638 printk(KERN_INFO "%s%d: monitor %d.%d-%d[%d]\n", 669 printk(KERN_INFO "%s%d: monitor %d.%d-%d[%d]\n",
639 dev->name, dev->id, 670 dev->name, dev->id,
@@ -707,6 +738,38 @@ int aac_get_adapter_info(struct aac_dev* dev)
707 rcode = -ENOMEM; 738 rcode = -ENOMEM;
708 } 739 }
709 } 740 }
741 /*
742 * 57 scatter gather elements
743 */
744 dev->scsi_host_ptr->sg_tablesize = (dev->max_fib_size -
745 sizeof(struct aac_fibhdr) -
746 sizeof(struct aac_write) + sizeof(struct sgmap)) /
747 sizeof(struct sgmap);
748 if (dev->dac_support) {
749 /*
750 * 38 scatter gather elements
751 */
752 dev->scsi_host_ptr->sg_tablesize =
753 (dev->max_fib_size -
754 sizeof(struct aac_fibhdr) -
755 sizeof(struct aac_write64) +
756 sizeof(struct sgmap64)) /
757 sizeof(struct sgmap64);
758 }
759 dev->scsi_host_ptr->max_sectors = AAC_MAX_32BIT_SGBCOUNT;
760 if(!(dev->adapter_info.options & AAC_OPT_NEW_COMM)) {
761 /*
762 * Worst case size that could cause sg overflow when
763 * we break up SG elements that are larger than 64KB.
764 * Would be nice if we could tell the SCSI layer what
765 * the maximum SG element size can be. Worst case is
766 * (sg_tablesize-1) 4KB elements with one 64KB
767 * element.
768 * 32bit -> 468 or 238KB 64bit -> 424 or 212KB
769 */
770 dev->scsi_host_ptr->max_sectors =
771 (dev->scsi_host_ptr->sg_tablesize * 8) + 112;
772 }
710 773
711 fib_complete(fibptr); 774 fib_complete(fibptr);
712 fib_free(fibptr); 775 fib_free(fibptr);
@@ -747,8 +810,10 @@ static void read_callback(void *context, struct fib * fibptr)
747 if (le32_to_cpu(readreply->status) == ST_OK) 810 if (le32_to_cpu(readreply->status) == ST_OK)
748 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; 811 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
749 else { 812 else {
750 printk(KERN_WARNING "read_callback: read failed, status = %d\n", 813#ifdef AAC_DETAILED_STATUS_INFO
751 le32_to_cpu(readreply->status)); 814 printk(KERN_WARNING "read_callback: io failed, status = %d\n",
815 le32_to_cpu(readreply->status));
816#endif
752 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; 817 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
753 set_sense((u8 *) &dev->fsa_dev[cid].sense_data, 818 set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
754 HARDWARE_ERROR, 819 HARDWARE_ERROR,
@@ -842,7 +907,8 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
842 lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; 907 lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
843 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8]; 908 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
844 } 909 }
845 dprintk((KERN_DEBUG "aac_read[cpu %d]: lba = %u, t = %ld.\n", smp_processor_id(), lba, jiffies)); 910 dprintk((KERN_DEBUG "aac_read[cpu %d]: lba = %u, t = %ld.\n",
911 smp_processor_id(), (unsigned long long)lba, jiffies));
846 /* 912 /*
847 * Alocate and initialize a Fib 913 * Alocate and initialize a Fib
848 */ 914 */
@@ -852,7 +918,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
852 918
853 fib_init(cmd_fibcontext); 919 fib_init(cmd_fibcontext);
854 920
855 if(dev->dac_support == 1) { 921 if (dev->dac_support == 1) {
856 struct aac_read64 *readcmd; 922 struct aac_read64 *readcmd;
857 readcmd = (struct aac_read64 *) fib_data(cmd_fibcontext); 923 readcmd = (struct aac_read64 *) fib_data(cmd_fibcontext);
858 readcmd->command = cpu_to_le32(VM_CtHostRead64); 924 readcmd->command = cpu_to_le32(VM_CtHostRead64);
@@ -886,14 +952,11 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
886 readcmd->block = cpu_to_le32(lba); 952 readcmd->block = cpu_to_le32(lba);
887 readcmd->count = cpu_to_le32(count * 512); 953 readcmd->count = cpu_to_le32(count * 512);
888 954
889 if (count * 512 > (64 * 1024))
890 BUG();
891
892 aac_build_sg(scsicmd, &readcmd->sg); 955 aac_build_sg(scsicmd, &readcmd->sg);
893 fibsize = sizeof(struct aac_read) + 956 fibsize = sizeof(struct aac_read) +
894 ((le32_to_cpu(readcmd->sg.count) - 1) * 957 ((le32_to_cpu(readcmd->sg.count) - 1) *
895 sizeof (struct sgentry)); 958 sizeof (struct sgentry));
896 BUG_ON (fibsize > (sizeof(struct hw_fib) - 959 BUG_ON (fibsize > (dev->max_fib_size -
897 sizeof(struct aac_fibhdr))); 960 sizeof(struct aac_fibhdr)));
898 /* 961 /*
899 * Now send the Fib to the adapter 962 * Now send the Fib to the adapter
@@ -976,7 +1039,7 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid)
976 fibsize = sizeof(struct aac_write64) + 1039 fibsize = sizeof(struct aac_write64) +
977 ((le32_to_cpu(writecmd->sg.count) - 1) * 1040 ((le32_to_cpu(writecmd->sg.count) - 1) *
978 sizeof (struct sgentry64)); 1041 sizeof (struct sgentry64));
979 BUG_ON (fibsize > (sizeof(struct hw_fib) - 1042 BUG_ON (fibsize > (dev->max_fib_size -
980 sizeof(struct aac_fibhdr))); 1043 sizeof(struct aac_fibhdr)));
981 /* 1044 /*
982 * Now send the Fib to the adapter 1045 * Now send the Fib to the adapter
@@ -998,15 +1061,11 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid)
998 writecmd->sg.count = cpu_to_le32(1); 1061 writecmd->sg.count = cpu_to_le32(1);
999 /* ->stable is not used - it did mean which type of write */ 1062 /* ->stable is not used - it did mean which type of write */
1000 1063
1001 if (count * 512 > (64 * 1024)) {
1002 BUG();
1003 }
1004
1005 aac_build_sg(scsicmd, &writecmd->sg); 1064 aac_build_sg(scsicmd, &writecmd->sg);
1006 fibsize = sizeof(struct aac_write) + 1065 fibsize = sizeof(struct aac_write) +
1007 ((le32_to_cpu(writecmd->sg.count) - 1) * 1066 ((le32_to_cpu(writecmd->sg.count) - 1) *
1008 sizeof (struct sgentry)); 1067 sizeof (struct sgentry));
1009 BUG_ON (fibsize > (sizeof(struct hw_fib) - 1068 BUG_ON (fibsize > (dev->max_fib_size -
1010 sizeof(struct aac_fibhdr))); 1069 sizeof(struct aac_fibhdr)));
1011 /* 1070 /*
1012 * Now send the Fib to the adapter 1071 * Now send the Fib to the adapter
@@ -1025,7 +1084,6 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid)
1025 */ 1084 */
1026 if (status == -EINPROGRESS) 1085 if (status == -EINPROGRESS)
1027 { 1086 {
1028 dprintk("write queued.\n");
1029 return 0; 1087 return 0;
1030 } 1088 }
1031 1089
@@ -1111,7 +1169,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd, int cid)
1111 return SCSI_MLQUEUE_DEVICE_BUSY; 1169 return SCSI_MLQUEUE_DEVICE_BUSY;
1112 1170
1113 /* 1171 /*
1114 * Alocate and initialize a Fib 1172 * Allocate and initialize a Fib
1115 */ 1173 */
1116 if (!(cmd_fibcontext = 1174 if (!(cmd_fibcontext =
1117 fib_alloc((struct aac_dev *)scsicmd->device->host->hostdata))) 1175 fib_alloc((struct aac_dev *)scsicmd->device->host->hostdata)))
@@ -1403,7 +1461,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1403 /* 1461 /*
1404 * Unhandled commands 1462 * Unhandled commands
1405 */ 1463 */
1406 printk(KERN_WARNING "Unhandled SCSI Command: 0x%x.\n", scsicmd->cmnd[0]); 1464 dprintk((KERN_WARNING "Unhandled SCSI Command: 0x%x.\n", scsicmd->cmnd[0]));
1407 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; 1465 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
1408 set_sense((u8 *) &dev->fsa_dev[cid].sense_data, 1466 set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
1409 ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND, 1467 ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND,
@@ -1818,7 +1876,7 @@ static int aac_send_srb_fib(struct scsi_cmnd* scsicmd)
1818 fibsize = sizeof (struct aac_srb) - sizeof (struct sgentry) + 1876 fibsize = sizeof (struct aac_srb) - sizeof (struct sgentry) +
1819 ((le32_to_cpu(srbcmd->sg.count) & 0xff) * 1877 ((le32_to_cpu(srbcmd->sg.count) & 0xff) *
1820 sizeof (struct sgentry64)); 1878 sizeof (struct sgentry64));
1821 BUG_ON (fibsize > (sizeof(struct hw_fib) - 1879 BUG_ON (fibsize > (dev->max_fib_size -
1822 sizeof(struct aac_fibhdr))); 1880 sizeof(struct aac_fibhdr)));
1823 1881
1824 /* 1882 /*
@@ -1840,7 +1898,7 @@ static int aac_send_srb_fib(struct scsi_cmnd* scsicmd)
1840 fibsize = sizeof (struct aac_srb) + 1898 fibsize = sizeof (struct aac_srb) +
1841 (((le32_to_cpu(srbcmd->sg.count) & 0xff) - 1) * 1899 (((le32_to_cpu(srbcmd->sg.count) & 0xff) - 1) *
1842 sizeof (struct sgentry)); 1900 sizeof (struct sgentry));
1843 BUG_ON (fibsize > (sizeof(struct hw_fib) - 1901 BUG_ON (fibsize > (dev->max_fib_size -
1844 sizeof(struct aac_fibhdr))); 1902 sizeof(struct aac_fibhdr)));
1845 1903
1846 /* 1904 /*