aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/aacraid/aachba.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/aacraid/aachba.c')
-rw-r--r--drivers/scsi/aacraid/aachba.c165
1 files changed, 113 insertions, 52 deletions
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index f3fc35386060..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
@@ -562,10 +565,10 @@ static void setinqstr(int devtype, void *data, int tindex)
562 inqstrcpy ("V1.0", str->prl); 565 inqstrcpy ("V1.0", str->prl);
563} 566}
564 567
565void set_sense(u8 *sense_buf, u8 sense_key, u8 sense_code, 568static void set_sense(u8 *sense_buf, u8 sense_key, u8 sense_code,
566 u8 a_sense_code, u8 incorrect_length, 569 u8 a_sense_code, u8 incorrect_length,
567 u8 bit_pointer, u16 field_pointer, 570 u8 bit_pointer, u16 field_pointer,
568 u32 residue) 571 u32 residue)
569{ 572{
570 sense_buf[0] = 0xF0; /* Sense data valid, err code 70h (current error) */ 573 sense_buf[0] = 0xF0; /* Sense data valid, err code 70h (current error) */
571 sense_buf[1] = 0; /* Segment number, always zero */ 574 sense_buf[1] = 0; /* Segment number, always zero */
@@ -605,35 +608,63 @@ 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));
636
637 if (dev->adapter_info.options & AAC_OPT_SUPPLEMENT_ADAPTER_INFO) {
638 struct aac_supplement_adapter_info * info;
626 639
627 memcpy(&dev->adapter_info, info, sizeof(struct aac_adapter_info)); 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,
@@ -813,7 +878,7 @@ static void write_callback(void *context, struct fib * fibptr)
813 aac_io_done(scsicmd); 878 aac_io_done(scsicmd);
814} 879}
815 880
816int aac_read(struct scsi_cmnd * scsicmd, int cid) 881static int aac_read(struct scsi_cmnd * scsicmd, int cid)
817{ 882{
818 u32 lba; 883 u32 lba;
819 u32 count; 884 u32 count;
@@ -842,7 +907,8 @@ 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 @@ 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 @@ 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 /*
@@ -1893,7 +1951,9 @@ static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* psg)
1893 } 1951 }
1894 /* hba wants the size to be exact */ 1952 /* hba wants the size to be exact */
1895 if(byte_count > scsicmd->request_bufflen){ 1953 if(byte_count > scsicmd->request_bufflen){
1896 psg->sg[i-1].count -= (byte_count - scsicmd->request_bufflen); 1954 u32 temp = le32_to_cpu(psg->sg[i-1].count) -
1955 (byte_count - scsicmd->request_bufflen);
1956 psg->sg[i-1].count = cpu_to_le32(temp);
1897 byte_count = scsicmd->request_bufflen; 1957 byte_count = scsicmd->request_bufflen;
1898 } 1958 }
1899 /* Check for command underflow */ 1959 /* Check for command underflow */
@@ -1922,7 +1982,7 @@ static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* p
1922{ 1982{
1923 struct aac_dev *dev; 1983 struct aac_dev *dev;
1924 unsigned long byte_count = 0; 1984 unsigned long byte_count = 0;
1925 u64 le_addr; 1985 u64 addr;
1926 1986
1927 dev = (struct aac_dev *)scsicmd->device->host->hostdata; 1987 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
1928 // Get rid of old data 1988 // Get rid of old data
@@ -1943,16 +2003,18 @@ static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* p
1943 byte_count = 0; 2003 byte_count = 0;
1944 2004
1945 for (i = 0; i < sg_count; i++) { 2005 for (i = 0; i < sg_count; i++) {
1946 le_addr = cpu_to_le64(sg_dma_address(sg)); 2006 addr = sg_dma_address(sg);
1947 psg->sg[i].addr[1] = (u32)(le_addr>>32); 2007 psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff);
1948 psg->sg[i].addr[0] = (u32)(le_addr & 0xffffffff); 2008 psg->sg[i].addr[1] = cpu_to_le32(addr>>32);
1949 psg->sg[i].count = cpu_to_le32(sg_dma_len(sg)); 2009 psg->sg[i].count = cpu_to_le32(sg_dma_len(sg));
1950 byte_count += sg_dma_len(sg); 2010 byte_count += sg_dma_len(sg);
1951 sg++; 2011 sg++;
1952 } 2012 }
1953 /* hba wants the size to be exact */ 2013 /* hba wants the size to be exact */
1954 if(byte_count > scsicmd->request_bufflen){ 2014 if(byte_count > scsicmd->request_bufflen){
1955 psg->sg[i-1].count -= (byte_count - scsicmd->request_bufflen); 2015 u32 temp = le32_to_cpu(psg->sg[i-1].count) -
2016 (byte_count - scsicmd->request_bufflen);
2017 psg->sg[i-1].count = cpu_to_le32(temp);
1956 byte_count = scsicmd->request_bufflen; 2018 byte_count = scsicmd->request_bufflen;
1957 } 2019 }
1958 /* Check for command underflow */ 2020 /* Check for command underflow */
@@ -1962,15 +2024,14 @@ static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* p
1962 } 2024 }
1963 } 2025 }
1964 else if(scsicmd->request_bufflen) { 2026 else if(scsicmd->request_bufflen) {
1965 dma_addr_t addr; 2027 u64 addr;
1966 addr = pci_map_single(dev->pdev, 2028 addr = pci_map_single(dev->pdev,
1967 scsicmd->request_buffer, 2029 scsicmd->request_buffer,
1968 scsicmd->request_bufflen, 2030 scsicmd->request_bufflen,
1969 scsicmd->sc_data_direction); 2031 scsicmd->sc_data_direction);
1970 psg->count = cpu_to_le32(1); 2032 psg->count = cpu_to_le32(1);
1971 le_addr = cpu_to_le64(addr); 2033 psg->sg[0].addr[0] = cpu_to_le32(addr & 0xffffffff);
1972 psg->sg[0].addr[1] = (u32)(le_addr>>32); 2034 psg->sg[0].addr[1] = cpu_to_le32(addr >> 32);
1973 psg->sg[0].addr[0] = (u32)(le_addr & 0xffffffff);
1974 psg->sg[0].count = cpu_to_le32(scsicmd->request_bufflen); 2035 psg->sg[0].count = cpu_to_le32(scsicmd->request_bufflen);
1975 scsicmd->SCp.dma_handle = addr; 2036 scsicmd->SCp.dma_handle = addr;
1976 byte_count = scsicmd->request_bufflen; 2037 byte_count = scsicmd->request_bufflen;