aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/aacraid
diff options
context:
space:
mode:
authorJames Bottomley <jejb@titanic.(none)>2005-06-17 20:04:18 -0400
committerJames Bottomley <jejb@titanic.(none)>2005-06-17 20:04:18 -0400
commit3afa294c40013be5d8180005002e3f648d04d942 (patch)
tree8a8b7464fd8ee4901288afb3e9e8d761ef45647d /drivers/scsi/aacraid
parenta1541d5af66d02426655b1498f814c52347dd7d3 (diff)
parent3237ee78fc00f786d5f5aec6f9310b0e39069f15 (diff)
merge by hand (qla_os.c mismerge)
Diffstat (limited to 'drivers/scsi/aacraid')
-rw-r--r--drivers/scsi/aacraid/aachba.c165
-rw-r--r--drivers/scsi/aacraid/aacraid.h468
-rw-r--r--drivers/scsi/aacraid/commctrl.c221
-rw-r--r--drivers/scsi/aacraid/comminit.c92
-rw-r--r--drivers/scsi/aacraid/commsup.c100
-rw-r--r--drivers/scsi/aacraid/dpcsup.c6
-rw-r--r--drivers/scsi/aacraid/linit.c179
-rw-r--r--drivers/scsi/aacraid/rkt.c43
-rw-r--r--drivers/scsi/aacraid/rx.c46
-rw-r--r--drivers/scsi/aacraid/sa.c35
10 files changed, 920 insertions, 435 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;
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index 700d90331c1c..42484417cef7 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -8,12 +8,18 @@
8 8
9#define MAXIMUM_NUM_CONTAINERS 32 9#define MAXIMUM_NUM_CONTAINERS 32
10 10
11#define AAC_NUM_FIB (256 + 64) 11#define AAC_NUM_MGT_FIB 8
12#define AAC_NUM_IO_FIB 100 12#define AAC_NUM_IO_FIB (512 - AAC_NUM_MGT_FIB)
13#define AAC_NUM_FIB (AAC_NUM_IO_FIB + AAC_NUM_MGT_FIB)
13 14
14#define AAC_MAX_LUN (8) 15#define AAC_MAX_LUN (8)
15 16
16#define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff) 17#define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff)
18/*
19 * max_sectors is an unsigned short, otherwise limit is 0x100000000 / 512
20 * Linux has starvation problems if we permit larger than 4MB I/O ...
21 */
22#define AAC_MAX_32BIT_SGBCOUNT ((unsigned short)8192)
17 23
18/* 24/*
19 * These macros convert from physical channels to virtual channels 25 * These macros convert from physical channels to virtual channels
@@ -89,11 +95,21 @@ struct diskparm
89 * on 64 bit systems not all cards support the 64 bit version 95 * on 64 bit systems not all cards support the 64 bit version
90 */ 96 */
91struct sgentry { 97struct sgentry {
98 __le32 addr; /* 32-bit address. */
99 __le32 count; /* Length. */
100};
101
102struct user_sgentry {
92 u32 addr; /* 32-bit address. */ 103 u32 addr; /* 32-bit address. */
93 u32 count; /* Length. */ 104 u32 count; /* Length. */
94}; 105};
95 106
96struct sgentry64 { 107struct sgentry64 {
108 __le32 addr[2]; /* 64-bit addr. 2 pieces for data alignment */
109 __le32 count; /* Length. */
110};
111
112struct user_sgentry64 {
97 u32 addr[2]; /* 64-bit addr. 2 pieces for data alignment */ 113 u32 addr[2]; /* 64-bit addr. 2 pieces for data alignment */
98 u32 count; /* Length. */ 114 u32 count; /* Length. */
99}; 115};
@@ -106,15 +122,25 @@ struct sgentry64 {
106 */ 122 */
107 123
108struct sgmap { 124struct sgmap {
109 u32 count; 125 __le32 count;
110 struct sgentry sg[1]; 126 struct sgentry sg[1];
111}; 127};
112 128
113struct sgmap64 { 129struct user_sgmap {
114 u32 count; 130 u32 count;
131 struct user_sgentry sg[1];
132};
133
134struct sgmap64 {
135 __le32 count;
115 struct sgentry64 sg[1]; 136 struct sgentry64 sg[1];
116}; 137};
117 138
139struct user_sgmap64 {
140 u32 count;
141 struct user_sgentry64 sg[1];
142};
143
118struct creation_info 144struct creation_info
119{ 145{
120 u8 buildnum; /* e.g., 588 */ 146 u8 buildnum; /* e.g., 588 */
@@ -123,14 +149,14 @@ struct creation_info
123 * 2 = API 149 * 2 = API
124 */ 150 */
125 u8 year; /* e.g., 1997 = 97 */ 151 u8 year; /* e.g., 1997 = 97 */
126 u32 date; /* 152 __le32 date; /*
127 * unsigned Month :4; // 1 - 12 153 * unsigned Month :4; // 1 - 12
128 * unsigned Day :6; // 1 - 32 154 * unsigned Day :6; // 1 - 32
129 * unsigned Hour :6; // 0 - 23 155 * unsigned Hour :6; // 0 - 23
130 * unsigned Minute :6; // 0 - 60 156 * unsigned Minute :6; // 0 - 60
131 * unsigned Second :6; // 0 - 60 157 * unsigned Second :6; // 0 - 60
132 */ 158 */
133 u32 serial[2]; /* e.g., 0x1DEADB0BFAFAF001 */ 159 __le32 serial[2]; /* e.g., 0x1DEADB0BFAFAF001 */
134}; 160};
135 161
136 162
@@ -175,8 +201,8 @@ struct creation_info
175 */ 201 */
176 202
177struct aac_entry { 203struct aac_entry {
178 u32 size; /* Size in bytes of Fib which this QE points to */ 204 __le32 size; /* Size in bytes of Fib which this QE points to */
179 u32 addr; /* Receiver address of the FIB */ 205 __le32 addr; /* Receiver address of the FIB */
180}; 206};
181 207
182/* 208/*
@@ -185,9 +211,10 @@ struct aac_entry {
185 */ 211 */
186 212
187struct aac_qhdr { 213struct aac_qhdr {
188 u64 header_addr; /* Address to hand the adapter to access to this queue head */ 214 __le64 header_addr;/* Address to hand the adapter to access
189 u32 *producer; /* The producer index for this queue (host address) */ 215 to this queue head */
190 u32 *consumer; /* The consumer index for this queue (host address) */ 216 __le32 *producer; /* The producer index for this queue (host address) */
217 __le32 *consumer; /* The consumer index for this queue (host address) */
191}; 218};
192 219
193/* 220/*
@@ -261,29 +288,30 @@ enum aac_queue_types {
261 */ 288 */
262 289
263struct aac_fibhdr { 290struct aac_fibhdr {
264 u32 XferState; // Current transfer state for this CCB 291 __le32 XferState; /* Current transfer state for this CCB */
265 u16 Command; // Routing information for the destination 292 __le16 Command; /* Routing information for the destination */
266 u8 StructType; // Type FIB 293 u8 StructType; /* Type FIB */
267 u8 Flags; // Flags for FIB 294 u8 Flags; /* Flags for FIB */
268 u16 Size; // Size of this FIB in bytes 295 __le16 Size; /* Size of this FIB in bytes */
269 u16 SenderSize; // Size of the FIB in the sender (for response sizing) 296 __le16 SenderSize; /* Size of the FIB in the sender
270 u32 SenderFibAddress; // Host defined data in the FIB 297 (for response sizing) */
271 u32 ReceiverFibAddress; // Logical address of this FIB for the adapter 298 __le32 SenderFibAddress; /* Host defined data in the FIB */
272 u32 SenderData; // Place holder for the sender to store data 299 __le32 ReceiverFibAddress;/* Logical address of this FIB for
300 the adapter */
301 u32 SenderData; /* Place holder for the sender to store data */
273 union { 302 union {
274 struct { 303 struct {
275 u32 _ReceiverTimeStart; // Timestamp for receipt of fib 304 __le32 _ReceiverTimeStart; /* Timestamp for
276 u32 _ReceiverTimeDone; // Timestamp for completion of fib 305 receipt of fib */
306 __le32 _ReceiverTimeDone; /* Timestamp for
307 completion of fib */
277 } _s; 308 } _s;
278 } _u; 309 } _u;
279}; 310};
280 311
281#define FIB_DATA_SIZE_IN_BYTES (512 - sizeof(struct aac_fibhdr))
282
283
284struct hw_fib { 312struct hw_fib {
285 struct aac_fibhdr header; 313 struct aac_fibhdr header;
286 u8 data[FIB_DATA_SIZE_IN_BYTES]; // Command specific data 314 u8 data[512-sizeof(struct aac_fibhdr)]; // Command specific data
287}; 315};
288 316
289/* 317/*
@@ -345,11 +373,12 @@ struct hw_fib {
345#define RequestAdapterInfo 703 373#define RequestAdapterInfo 703
346#define IsAdapterPaused 704 374#define IsAdapterPaused 704
347#define SendHostTime 705 375#define SendHostTime 705
348#define LastMiscCommand 706 376#define RequestSupplementAdapterInfo 706
377#define LastMiscCommand 707
349 378
350// 379/*
351// Commands that will target the failover level on the FSA adapter 380 * Commands that will target the failover level on the FSA adapter
352// 381 */
353 382
354enum fib_xfer_state { 383enum fib_xfer_state {
355 HostOwned = (1<<0), 384 HostOwned = (1<<0),
@@ -382,22 +411,32 @@ enum fib_xfer_state {
382 */ 411 */
383 412
384#define ADAPTER_INIT_STRUCT_REVISION 3 413#define ADAPTER_INIT_STRUCT_REVISION 3
414#define ADAPTER_INIT_STRUCT_REVISION_4 4 // rocket science
385 415
386struct aac_init 416struct aac_init
387{ 417{
388 u32 InitStructRevision; 418 __le32 InitStructRevision;
389 u32 MiniPortRevision; 419 __le32 MiniPortRevision;
390 u32 fsrev; 420 __le32 fsrev;
391 u32 CommHeaderAddress; 421 __le32 CommHeaderAddress;
392 u32 FastIoCommAreaAddress; 422 __le32 FastIoCommAreaAddress;
393 u32 AdapterFibsPhysicalAddress; 423 __le32 AdapterFibsPhysicalAddress;
394 u32 AdapterFibsVirtualAddress; 424 __le32 AdapterFibsVirtualAddress;
395 u32 AdapterFibsSize; 425 __le32 AdapterFibsSize;
396 u32 AdapterFibAlign; 426 __le32 AdapterFibAlign;
397 u32 printfbuf; 427 __le32 printfbuf;
398 u32 printfbufsiz; 428 __le32 printfbufsiz;
399 u32 HostPhysMemPages; // number of 4k pages of host physical memory 429 __le32 HostPhysMemPages; /* number of 4k pages of host
400 u32 HostElapsedSeconds; // number of seconds since 1970. 430 physical memory */
431 __le32 HostElapsedSeconds; /* number of seconds since 1970. */
432 /*
433 * ADAPTER_INIT_STRUCT_REVISION_4 begins here
434 */
435 __le32 InitFlags; /* flags for supported features */
436#define INITFLAGS_NEW_COMM_SUPPORTED 0x00000001
437 __le32 MaxIoCommands; /* max outstanding commands */
438 __le32 MaxIoSize; /* largest I/O command */
439 __le32 MaxFibSize; /* largest FIB to adapter */
401}; 440};
402 441
403enum aac_log_level { 442enum aac_log_level {
@@ -421,7 +460,7 @@ struct adapter_ops
421{ 460{
422 void (*adapter_interrupt)(struct aac_dev *dev); 461 void (*adapter_interrupt)(struct aac_dev *dev);
423 void (*adapter_notify)(struct aac_dev *dev, u32 event); 462 void (*adapter_notify)(struct aac_dev *dev, u32 event);
424 int (*adapter_sync_cmd)(struct aac_dev *dev, u32 command, u32 p1, u32 *status); 463 int (*adapter_sync_cmd)(struct aac_dev *dev, u32 command, u32 p1, u32 p2, u32 p3, u32 p4, u32 p5, u32 p6, u32 *status, u32 *r1, u32 *r2, u32 *r3, u32 *r4);
425 int (*adapter_check_health)(struct aac_dev *dev); 464 int (*adapter_check_health)(struct aac_dev *dev);
426}; 465};
427 466
@@ -541,6 +580,7 @@ struct sa_drawbridge_CSR {
541#define Mailbox3 SaDbCSR.MAILBOX3 580#define Mailbox3 SaDbCSR.MAILBOX3
542#define Mailbox4 SaDbCSR.MAILBOX4 581#define Mailbox4 SaDbCSR.MAILBOX4
543#define Mailbox5 SaDbCSR.MAILBOX5 582#define Mailbox5 SaDbCSR.MAILBOX5
583#define Mailbox6 SaDbCSR.MAILBOX6
544#define Mailbox7 SaDbCSR.MAILBOX7 584#define Mailbox7 SaDbCSR.MAILBOX7
545 585
546#define DoorbellReg_p SaDbCSR.PRISETIRQ 586#define DoorbellReg_p SaDbCSR.PRISETIRQ
@@ -763,29 +803,48 @@ struct fib {
763 803
764struct aac_adapter_info 804struct aac_adapter_info
765{ 805{
766 u32 platform; 806 __le32 platform;
767 u32 cpu; 807 __le32 cpu;
768 u32 subcpu; 808 __le32 subcpu;
769 u32 clock; 809 __le32 clock;
770 u32 execmem; 810 __le32 execmem;
771 u32 buffermem; 811 __le32 buffermem;
772 u32 totalmem; 812 __le32 totalmem;
773 u32 kernelrev; 813 __le32 kernelrev;
774 u32 kernelbuild; 814 __le32 kernelbuild;
775 u32 monitorrev; 815 __le32 monitorrev;
776 u32 monitorbuild; 816 __le32 monitorbuild;
777 u32 hwrev; 817 __le32 hwrev;
778 u32 hwbuild; 818 __le32 hwbuild;
779 u32 biosrev; 819 __le32 biosrev;
780 u32 biosbuild; 820 __le32 biosbuild;
781 u32 cluster; 821 __le32 cluster;
782 u32 clusterchannelmask; 822 __le32 clusterchannelmask;
783 u32 serial[2]; 823 __le32 serial[2];
784 u32 battery; 824 __le32 battery;
785 u32 options; 825 __le32 options;
786 u32 OEM; 826 __le32 OEM;
787}; 827};
788 828
829struct aac_supplement_adapter_info
830{
831 u8 AdapterTypeText[17+1];
832 u8 Pad[2];
833 __le32 FlashMemoryByteSize;
834 __le32 FlashImageId;
835 __le32 MaxNumberPorts;
836 __le32 Version;
837 __le32 FeatureBits;
838 u8 SlotNumber;
839 u8 ReservedPad0[0];
840 u8 BuildDate[12];
841 __le32 CurrentNumberPorts;
842 __le32 ReservedGrowth[24];
843};
844#define AAC_FEATURE_FALCON 0x00000010
845#define AAC_SIS_VERSION_V3 3
846#define AAC_SIS_SLOT_UNKNOWN 0xFF
847
789/* 848/*
790 * Battery platforms 849 * Battery platforms
791 */ 850 */
@@ -831,6 +890,12 @@ struct aac_dev
831 890
832 u16 irq_mask; 891 u16 irq_mask;
833 /* 892 /*
893 * negotiated FIB settings
894 */
895 unsigned max_fib_size;
896 unsigned sg_tablesize;
897
898 /*
834 * Map for 128 fib objects (64k) 899 * Map for 128 fib objects (64k)
835 */ 900 */
836 dma_addr_t hw_fib_pa; 901 dma_addr_t hw_fib_pa;
@@ -889,12 +954,14 @@ struct aac_dev
889 u32 aif_thread; 954 u32 aif_thread;
890 struct completion aif_completion; 955 struct completion aif_completion;
891 struct aac_adapter_info adapter_info; 956 struct aac_adapter_info adapter_info;
957 struct aac_supplement_adapter_info supplement_adapter_info;
892 /* These are in adapter info but they are in the io flow so 958 /* These are in adapter info but they are in the io flow so
893 * lets break them out so we don't have to do an AND to check them 959 * lets break them out so we don't have to do an AND to check them
894 */ 960 */
895 u8 nondasd_support; 961 u8 nondasd_support;
896 u8 dac_support; 962 u8 dac_support;
897 u8 raid_scsi_mode; 963 u8 raid_scsi_mode;
964 u8 printf_enabled;
898}; 965};
899 966
900#define aac_adapter_interrupt(dev) \ 967#define aac_adapter_interrupt(dev) \
@@ -903,6 +970,8 @@ struct aac_dev
903#define aac_adapter_notify(dev, event) \ 970#define aac_adapter_notify(dev, event) \
904 (dev)->a_ops.adapter_notify(dev, event) 971 (dev)->a_ops.adapter_notify(dev, event)
905 972
973#define aac_adapter_sync_cmd(dev, command, p1, p2, p3, p4, p5, p6, status, r1, r2, r3, r4) \
974 (dev)->a_ops.adapter_sync_cmd(dev, command, p1, p2, p3, p4, p5, p6, status, r1, r2, r3, r4)
906 975
907#define aac_adapter_check_health(dev) \ 976#define aac_adapter_check_health(dev) \
908 (dev)->a_ops.adapter_check_health(dev) 977 (dev)->a_ops.adapter_check_health(dev)
@@ -1016,83 +1085,102 @@ struct aac_dev
1016 1085
1017struct aac_read 1086struct aac_read
1018{ 1087{
1019 u32 command; 1088 __le32 command;
1020 u32 cid; 1089 __le32 cid;
1021 u32 block; 1090 __le32 block;
1022 u32 count; 1091 __le32 count;
1023 struct sgmap sg; // Must be last in struct because it is variable 1092 struct sgmap sg; // Must be last in struct because it is variable
1024}; 1093};
1025 1094
1026struct aac_read64 1095struct aac_read64
1027{ 1096{
1028 u32 command; 1097 __le32 command;
1029 u16 cid; 1098 __le16 cid;
1030 u16 sector_count; 1099 __le16 sector_count;
1031 u32 block; 1100 __le32 block;
1032 u16 pad; 1101 __le16 pad;
1033 u16 flags; 1102 __le16 flags;
1034 struct sgmap64 sg; // Must be last in struct because it is variable 1103 struct sgmap64 sg; // Must be last in struct because it is variable
1035}; 1104};
1036 1105
1037struct aac_read_reply 1106struct aac_read_reply
1038{ 1107{
1039 u32 status; 1108 __le32 status;
1040 u32 count; 1109 __le32 count;
1041}; 1110};
1042 1111
1043struct aac_write 1112struct aac_write
1044{ 1113{
1045 u32 command; 1114 __le32 command;
1046 u32 cid; 1115 __le32 cid;
1047 u32 block; 1116 __le32 block;
1048 u32 count; 1117 __le32 count;
1049 u32 stable; // Not used 1118 __le32 stable; // Not used
1050 struct sgmap sg; // Must be last in struct because it is variable 1119 struct sgmap sg; // Must be last in struct because it is variable
1051}; 1120};
1052 1121
1053struct aac_write64 1122struct aac_write64
1054{ 1123{
1055 u32 command; 1124 __le32 command;
1056 u16 cid; 1125 __le16 cid;
1057 u16 sector_count; 1126 __le16 sector_count;
1058 u32 block; 1127 __le32 block;
1059 u16 pad; 1128 __le16 pad;
1060 u16 flags; 1129 __le16 flags;
1061 struct sgmap64 sg; // Must be last in struct because it is variable 1130 struct sgmap64 sg; // Must be last in struct because it is variable
1062}; 1131};
1063struct aac_write_reply 1132struct aac_write_reply
1064{ 1133{
1065 u32 status; 1134 __le32 status;
1066 u32 count; 1135 __le32 count;
1067 u32 committed; 1136 __le32 committed;
1068}; 1137};
1069 1138
1070#define CT_FLUSH_CACHE 129 1139#define CT_FLUSH_CACHE 129
1071struct aac_synchronize { 1140struct aac_synchronize {
1072 u32 command; /* VM_ContainerConfig */ 1141 __le32 command; /* VM_ContainerConfig */
1073 u32 type; /* CT_FLUSH_CACHE */ 1142 __le32 type; /* CT_FLUSH_CACHE */
1074 u32 cid; 1143 __le32 cid;
1075 u32 parm1; 1144 __le32 parm1;
1076 u32 parm2; 1145 __le32 parm2;
1077 u32 parm3; 1146 __le32 parm3;
1078 u32 parm4; 1147 __le32 parm4;
1079 u32 count; /* sizeof(((struct aac_synchronize_reply *)NULL)->data) */ 1148 __le32 count; /* sizeof(((struct aac_synchronize_reply *)NULL)->data) */
1080}; 1149};
1081 1150
1082struct aac_synchronize_reply { 1151struct aac_synchronize_reply {
1083 u32 dummy0; 1152 __le32 dummy0;
1084 u32 dummy1; 1153 __le32 dummy1;
1085 u32 status; /* CT_OK */ 1154 __le32 status; /* CT_OK */
1086 u32 parm1; 1155 __le32 parm1;
1087 u32 parm2; 1156 __le32 parm2;
1088 u32 parm3; 1157 __le32 parm3;
1089 u32 parm4; 1158 __le32 parm4;
1090 u32 parm5; 1159 __le32 parm5;
1091 u8 data[16]; 1160 u8 data[16];
1092}; 1161};
1093 1162
1094struct aac_srb 1163struct aac_srb
1095{ 1164{
1165 __le32 function;
1166 __le32 channel;
1167 __le32 id;
1168 __le32 lun;
1169 __le32 timeout;
1170 __le32 flags;
1171 __le32 count; // Data xfer size
1172 __le32 retry_limit;
1173 __le32 cdb_size;
1174 u8 cdb[16];
1175 struct sgmap sg;
1176};
1177
1178/*
1179 * This and assocated data structs are used by the
1180 * ioctl caller and are in cpu order.
1181 */
1182struct user_aac_srb
1183{
1096 u32 function; 1184 u32 function;
1097 u32 channel; 1185 u32 channel;
1098 u32 id; 1186 u32 id;
@@ -1103,20 +1191,18 @@ struct aac_srb
1103 u32 retry_limit; 1191 u32 retry_limit;
1104 u32 cdb_size; 1192 u32 cdb_size;
1105 u8 cdb[16]; 1193 u8 cdb[16];
1106 struct sgmap sg; 1194 struct user_sgmap sg;
1107}; 1195};
1108 1196
1109
1110
1111#define AAC_SENSE_BUFFERSIZE 30 1197#define AAC_SENSE_BUFFERSIZE 30
1112 1198
1113struct aac_srb_reply 1199struct aac_srb_reply
1114{ 1200{
1115 u32 status; 1201 __le32 status;
1116 u32 srb_status; 1202 __le32 srb_status;
1117 u32 scsi_status; 1203 __le32 scsi_status;
1118 u32 data_xfer_length; 1204 __le32 data_xfer_length;
1119 u32 sense_data_size; 1205 __le32 sense_data_size;
1120 u8 sense_data[AAC_SENSE_BUFFERSIZE]; // Can this be SCSI_SENSE_BUFFERSIZE 1206 u8 sense_data[AAC_SENSE_BUFFERSIZE]; // Can this be SCSI_SENSE_BUFFERSIZE
1121}; 1207};
1122/* 1208/*
@@ -1223,14 +1309,14 @@ struct aac_srb_reply
1223 */ 1309 */
1224 1310
1225struct aac_fsinfo { 1311struct aac_fsinfo {
1226 u32 fsTotalSize; /* Consumed by fs, incl. metadata */ 1312 __le32 fsTotalSize; /* Consumed by fs, incl. metadata */
1227 u32 fsBlockSize; 1313 __le32 fsBlockSize;
1228 u32 fsFragSize; 1314 __le32 fsFragSize;
1229 u32 fsMaxExtendSize; 1315 __le32 fsMaxExtendSize;
1230 u32 fsSpaceUnits; 1316 __le32 fsSpaceUnits;
1231 u32 fsMaxNumFiles; 1317 __le32 fsMaxNumFiles;
1232 u32 fsNumFreeFiles; 1318 __le32 fsNumFreeFiles;
1233 u32 fsInodeDensity; 1319 __le32 fsInodeDensity;
1234}; /* valid iff ObjType == FT_FILESYS && !(ContentState & FSCS_NOTCLEAN) */ 1320}; /* valid iff ObjType == FT_FILESYS && !(ContentState & FSCS_NOTCLEAN) */
1235 1321
1236union aac_contentinfo { 1322union aac_contentinfo {
@@ -1243,32 +1329,32 @@ union aac_contentinfo {
1243 1329
1244#define CT_GET_CONFIG_STATUS 147 1330#define CT_GET_CONFIG_STATUS 147
1245struct aac_get_config_status { 1331struct aac_get_config_status {
1246 u32 command; /* VM_ContainerConfig */ 1332 __le32 command; /* VM_ContainerConfig */
1247 u32 type; /* CT_GET_CONFIG_STATUS */ 1333 __le32 type; /* CT_GET_CONFIG_STATUS */
1248 u32 parm1; 1334 __le32 parm1;
1249 u32 parm2; 1335 __le32 parm2;
1250 u32 parm3; 1336 __le32 parm3;
1251 u32 parm4; 1337 __le32 parm4;
1252 u32 parm5; 1338 __le32 parm5;
1253 u32 count; /* sizeof(((struct aac_get_config_status_resp *)NULL)->data) */ 1339 __le32 count; /* sizeof(((struct aac_get_config_status_resp *)NULL)->data) */
1254}; 1340};
1255 1341
1256#define CFACT_CONTINUE 0 1342#define CFACT_CONTINUE 0
1257#define CFACT_PAUSE 1 1343#define CFACT_PAUSE 1
1258#define CFACT_ABORT 2 1344#define CFACT_ABORT 2
1259struct aac_get_config_status_resp { 1345struct aac_get_config_status_resp {
1260 u32 response; /* ST_OK */ 1346 __le32 response; /* ST_OK */
1261 u32 dummy0; 1347 __le32 dummy0;
1262 u32 status; /* CT_OK */ 1348 __le32 status; /* CT_OK */
1263 u32 parm1; 1349 __le32 parm1;
1264 u32 parm2; 1350 __le32 parm2;
1265 u32 parm3; 1351 __le32 parm3;
1266 u32 parm4; 1352 __le32 parm4;
1267 u32 parm5; 1353 __le32 parm5;
1268 struct { 1354 struct {
1269 u32 action; /* CFACT_CONTINUE, CFACT_PAUSE or CFACT_ABORT */ 1355 __le32 action; /* CFACT_CONTINUE, CFACT_PAUSE or CFACT_ABORT */
1270 u16 flags; 1356 __le16 flags;
1271 s16 count; 1357 __le16 count;
1272 } data; 1358 } data;
1273}; 1359};
1274 1360
@@ -1279,26 +1365,26 @@ struct aac_get_config_status_resp {
1279#define CT_COMMIT_CONFIG 152 1365#define CT_COMMIT_CONFIG 152
1280 1366
1281struct aac_commit_config { 1367struct aac_commit_config {
1282 u32 command; /* VM_ContainerConfig */ 1368 __le32 command; /* VM_ContainerConfig */
1283 u32 type; /* CT_COMMIT_CONFIG */ 1369 __le32 type; /* CT_COMMIT_CONFIG */
1284}; 1370};
1285 1371
1286/* 1372/*
1287 * Query for Container Configuration Count 1373 * Query for Container Configuration Status
1288 */ 1374 */
1289 1375
1290#define CT_GET_CONTAINER_COUNT 4 1376#define CT_GET_CONTAINER_COUNT 4
1291struct aac_get_container_count { 1377struct aac_get_container_count {
1292 u32 command; /* VM_ContainerConfig */ 1378 __le32 command; /* VM_ContainerConfig */
1293 u32 type; /* CT_GET_CONTAINER_COUNT */ 1379 __le32 type; /* CT_GET_CONTAINER_COUNT */
1294}; 1380};
1295 1381
1296struct aac_get_container_count_resp { 1382struct aac_get_container_count_resp {
1297 u32 response; /* ST_OK */ 1383 __le32 response; /* ST_OK */
1298 u32 dummy0; 1384 __le32 dummy0;
1299 u32 MaxContainers; 1385 __le32 MaxContainers;
1300 u32 ContainerSwitchEntries; 1386 __le32 ContainerSwitchEntries;
1301 u32 MaxPartitions; 1387 __le32 MaxPartitions;
1302}; 1388};
1303 1389
1304 1390
@@ -1308,15 +1394,19 @@ struct aac_get_container_count_resp {
1308 */ 1394 */
1309 1395
1310struct aac_mntent { 1396struct aac_mntent {
1311 u32 oid; 1397 __le32 oid;
1312 u8 name[16]; // if applicable 1398 u8 name[16]; /* if applicable */
1313 struct creation_info create_info; // if applicable 1399 struct creation_info create_info; /* if applicable */
1314 u32 capacity; 1400 __le32 capacity;
1315 u32 vol; // substrate structure 1401 __le32 vol; /* substrate structure */
1316 u32 obj; // FT_FILESYS, FT_DATABASE, etc. 1402 __le32 obj; /* FT_FILESYS,
1317 u32 state; // unready for mounting, readonly, etc. 1403 FT_DATABASE, etc. */
1318 union aac_contentinfo fileinfo; // Info specific to content manager (eg, filesystem) 1404 __le32 state; /* unready for mounting,
1319 u32 altoid; // != oid <==> snapshot or broken mirror exists 1405 readonly, etc. */
1406 union aac_contentinfo fileinfo; /* Info specific to content
1407 manager (eg, filesystem) */
1408 __le32 altoid; /* != oid <==> snapshot or
1409 broken mirror exists */
1320}; 1410};
1321 1411
1322#define FSCS_NOTCLEAN 0x0001 /* fsck is neccessary before mounting */ 1412#define FSCS_NOTCLEAN 0x0001 /* fsck is neccessary before mounting */
@@ -1324,40 +1414,40 @@ struct aac_mntent {
1324#define FSCS_HIDDEN 0x0004 /* should be ignored - set during a clear */ 1414#define FSCS_HIDDEN 0x0004 /* should be ignored - set during a clear */
1325 1415
1326struct aac_query_mount { 1416struct aac_query_mount {
1327 u32 command; 1417 __le32 command;
1328 u32 type; 1418 __le32 type;
1329 u32 count; 1419 __le32 count;
1330}; 1420};
1331 1421
1332struct aac_mount { 1422struct aac_mount {
1333 u32 status; 1423 __le32 status;
1334 u32 type; /* should be same as that requested */ 1424 __le32 type; /* should be same as that requested */
1335 u32 count; 1425 __le32 count;
1336 struct aac_mntent mnt[1]; 1426 struct aac_mntent mnt[1];
1337}; 1427};
1338 1428
1339#define CT_READ_NAME 130 1429#define CT_READ_NAME 130
1340struct aac_get_name { 1430struct aac_get_name {
1341 u32 command; /* VM_ContainerConfig */ 1431 __le32 command; /* VM_ContainerConfig */
1342 u32 type; /* CT_READ_NAME */ 1432 __le32 type; /* CT_READ_NAME */
1343 u32 cid; 1433 __le32 cid;
1344 u32 parm1; 1434 __le32 parm1;
1345 u32 parm2; 1435 __le32 parm2;
1346 u32 parm3; 1436 __le32 parm3;
1347 u32 parm4; 1437 __le32 parm4;
1348 u32 count; /* sizeof(((struct aac_get_name_resp *)NULL)->data) */ 1438 __le32 count; /* sizeof(((struct aac_get_name_resp *)NULL)->data) */
1349}; 1439};
1350 1440
1351#define CT_OK 218 1441#define CT_OK 218
1352struct aac_get_name_resp { 1442struct aac_get_name_resp {
1353 u32 dummy0; 1443 __le32 dummy0;
1354 u32 dummy1; 1444 __le32 dummy1;
1355 u32 status; /* CT_OK */ 1445 __le32 status; /* CT_OK */
1356 u32 parm1; 1446 __le32 parm1;
1357 u32 parm2; 1447 __le32 parm2;
1358 u32 parm3; 1448 __le32 parm3;
1359 u32 parm4; 1449 __le32 parm4;
1360 u32 parm5; 1450 __le32 parm5;
1361 u8 data[16]; 1451 u8 data[16];
1362}; 1452};
1363 1453
@@ -1366,8 +1456,8 @@ struct aac_get_name_resp {
1366 */ 1456 */
1367 1457
1368struct aac_close { 1458struct aac_close {
1369 u32 command; 1459 __le32 command;
1370 u32 cid; 1460 __le32 cid;
1371}; 1461};
1372 1462
1373struct aac_query_disk 1463struct aac_query_disk
@@ -1434,6 +1524,7 @@ struct revision
1434#define FSACTL_GET_PCI_INFO CTL_CODE(2119, METHOD_BUFFERED) 1524#define FSACTL_GET_PCI_INFO CTL_CODE(2119, METHOD_BUFFERED)
1435#define FSACTL_FORCE_DELETE_DISK CTL_CODE(2120, METHOD_NEITHER) 1525#define FSACTL_FORCE_DELETE_DISK CTL_CODE(2120, METHOD_NEITHER)
1436#define FSACTL_GET_CONTAINERS 2131 1526#define FSACTL_GET_CONTAINERS 2131
1527#define FSACTL_SEND_LARGE_FIB CTL_CODE(2138, METHOD_BUFFERED)
1437 1528
1438 1529
1439struct aac_common 1530struct aac_common
@@ -1573,8 +1664,8 @@ extern struct aac_common aac_config;
1573 */ 1664 */
1574 1665
1575struct aac_aifcmd { 1666struct aac_aifcmd {
1576 u32 command; /* Tell host what type of notify this is */ 1667 __le32 command; /* Tell host what type of notify this is */
1577 u32 seqnum; /* To allow ordering of reports (if necessary) */ 1668 __le32 seqnum; /* To allow ordering of reports (if necessary) */
1578 u8 data[1]; /* Undefined length (from kernel viewpoint) */ 1669 u8 data[1]; /* Undefined length (from kernel viewpoint) */
1579}; 1670};
1580 1671
@@ -1597,7 +1688,6 @@ int fib_setup(struct aac_dev *dev);
1597void fib_map_free(struct aac_dev *dev); 1688void fib_map_free(struct aac_dev *dev);
1598void fib_free(struct fib * context); 1689void fib_free(struct fib * context);
1599void fib_init(struct fib * context); 1690void fib_init(struct fib * context);
1600void fib_dealloc(struct fib * context);
1601void aac_printf(struct aac_dev *dev, u32 val); 1691void aac_printf(struct aac_dev *dev, u32 val);
1602int fib_send(u16 command, struct fib * context, unsigned long size, int priority, int wait, int reply, fib_callback callback, void *ctxt); 1692int fib_send(u16 command, struct fib * context, unsigned long size, int priority, int wait, int reply, fib_callback callback, void *ctxt);
1603int aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entry **entry); 1693int aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entry **entry);
@@ -1621,3 +1711,5 @@ int fib_adapter_complete(struct fib * fibptr, unsigned short size);
1621struct aac_driver_ident* aac_get_driver_ident(int devtype); 1711struct aac_driver_ident* aac_get_driver_ident(int devtype);
1622int aac_get_adapter_info(struct aac_dev* dev); 1712int aac_get_adapter_info(struct aac_dev* dev);
1623int aac_send_shutdown(struct aac_dev *dev); 1713int aac_send_shutdown(struct aac_dev *dev);
1714extern int numacb;
1715extern int acbsize;
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index 30dd1f7120f4..fc268a410c27 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -51,15 +51,22 @@
51 * This routine sends a fib to the adapter on behalf of a user level 51 * This routine sends a fib to the adapter on behalf of a user level
52 * program. 52 * program.
53 */ 53 */
54# define AAC_DEBUG_PREAMBLE KERN_INFO
55# define AAC_DEBUG_POSTAMBLE
54 56
55static int ioctl_send_fib(struct aac_dev * dev, void __user *arg) 57static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
56{ 58{
57 struct hw_fib * kfib; 59 struct hw_fib * kfib;
58 struct fib *fibptr; 60 struct fib *fibptr;
61 struct hw_fib * hw_fib = (struct hw_fib *)0;
62 dma_addr_t hw_fib_pa = (dma_addr_t)0LL;
63 unsigned size;
64 int retval;
59 65
60 fibptr = fib_alloc(dev); 66 fibptr = fib_alloc(dev);
61 if(fibptr == NULL) 67 if(fibptr == NULL) {
62 return -ENOMEM; 68 return -ENOMEM;
69 }
63 70
64 kfib = fibptr->hw_fib; 71 kfib = fibptr->hw_fib;
65 /* 72 /*
@@ -74,19 +81,24 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
74 * will not overrun the buffer when we copy the memory. Return 81 * will not overrun the buffer when we copy the memory. Return
75 * an error if we would. 82 * an error if we would.
76 */ 83 */
77 if (le16_to_cpu(kfib->header.Size) > 84 size = le16_to_cpu(kfib->header.Size) + sizeof(struct aac_fibhdr);
78 sizeof(struct hw_fib) - sizeof(struct aac_fibhdr)) { 85 if (size < le16_to_cpu(kfib->header.SenderSize))
79 fib_free(fibptr); 86 size = le16_to_cpu(kfib->header.SenderSize);
80 return -EINVAL; 87 if (size > dev->max_fib_size) {
88 /* Highjack the hw_fib */
89 hw_fib = fibptr->hw_fib;
90 hw_fib_pa = fibptr->hw_fib_pa;
91 fibptr->hw_fib = kfib = pci_alloc_consistent(dev->pdev, size, &fibptr->hw_fib_pa);
92 memset(((char *)kfib) + dev->max_fib_size, 0, size - dev->max_fib_size);
93 memcpy(kfib, hw_fib, dev->max_fib_size);
81 } 94 }
82 95
83 if (copy_from_user(kfib, arg, le16_to_cpu(kfib->header.Size) + 96 if (copy_from_user(kfib, arg, size)) {
84 sizeof(struct aac_fibhdr))) { 97 retval = -EFAULT;
85 fib_free(fibptr); 98 goto cleanup;
86 return -EFAULT;
87 } 99 }
88 100
89 if (kfib->header.Command == cpu_to_le32(TakeABreakPt)) { 101 if (kfib->header.Command == cpu_to_le16(TakeABreakPt)) {
90 aac_adapter_interrupt(dev); 102 aac_adapter_interrupt(dev);
91 /* 103 /*
92 * Since we didn't really send a fib, zero out the state to allow 104 * Since we didn't really send a fib, zero out the state to allow
@@ -94,16 +106,15 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
94 */ 106 */
95 kfib->header.XferState = 0; 107 kfib->header.XferState = 0;
96 } else { 108 } else {
97 int retval = fib_send(kfib->header.Command, fibptr, 109 retval = fib_send(le16_to_cpu(kfib->header.Command), fibptr,
98 le16_to_cpu(kfib->header.Size) , FsaNormal, 110 le16_to_cpu(kfib->header.Size) , FsaNormal,
99 1, 1, NULL, NULL); 111 1, 1, NULL, NULL);
100 if (retval) { 112 if (retval) {
101 fib_free(fibptr); 113 goto cleanup;
102 return retval;
103 } 114 }
104 if (fib_complete(fibptr) != 0) { 115 if (fib_complete(fibptr) != 0) {
105 fib_free(fibptr); 116 retval = -EINVAL;
106 return -EINVAL; 117 goto cleanup;
107 } 118 }
108 } 119 }
109 /* 120 /*
@@ -114,12 +125,17 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
114 * was already included by the adapter.) 125 * was already included by the adapter.)
115 */ 126 */
116 127
117 if (copy_to_user(arg, (void *)kfib, kfib->header.Size)) { 128 retval = 0;
118 fib_free(fibptr); 129 if (copy_to_user(arg, (void *)kfib, size))
119 return -EFAULT; 130 retval = -EFAULT;
131cleanup:
132 if (hw_fib) {
133 pci_free_consistent(dev->pdev, size, kfib, fibptr->hw_fib_pa);
134 fibptr->hw_fib_pa = hw_fib_pa;
135 fibptr->hw_fib = hw_fib;
120 } 136 }
121 fib_free(fibptr); 137 fib_free(fibptr);
122 return 0; 138 return retval;
123} 139}
124 140
125/** 141/**
@@ -391,26 +407,28 @@ static int check_revision(struct aac_dev *dev, void __user *arg)
391 struct revision response; 407 struct revision response;
392 408
393 response.compat = 1; 409 response.compat = 1;
394 response.version = dev->adapter_info.kernelrev; 410 response.version = le32_to_cpu(dev->adapter_info.kernelrev);
395 response.build = dev->adapter_info.kernelbuild; 411 response.build = le32_to_cpu(dev->adapter_info.kernelbuild);
396 412
397 if (copy_to_user(arg, &response, sizeof(response))) 413 if (copy_to_user(arg, &response, sizeof(response)))
398 return -EFAULT; 414 return -EFAULT;
399 return 0; 415 return 0;
400} 416}
401 417
418
402/** 419/**
403 * 420 *
404 * aac_send_raw_scb 421 * aac_send_raw_scb
405 * 422 *
406 */ 423 */
407 424
408int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) 425static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
409{ 426{
410 struct fib* srbfib; 427 struct fib* srbfib;
411 int status; 428 int status;
412 struct aac_srb *srbcmd; 429 struct aac_srb *srbcmd = NULL;
413 struct aac_srb __user *user_srb = arg; 430 struct user_aac_srb *user_srbcmd = NULL;
431 struct user_aac_srb __user *user_srb = arg;
414 struct aac_srb_reply __user *user_reply; 432 struct aac_srb_reply __user *user_reply;
415 struct aac_srb_reply* reply; 433 struct aac_srb_reply* reply;
416 u32 fibsize = 0; 434 u32 fibsize = 0;
@@ -426,7 +444,7 @@ int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
426 444
427 445
428 if (!capable(CAP_SYS_ADMIN)){ 446 if (!capable(CAP_SYS_ADMIN)){
429 printk(KERN_DEBUG"aacraid: No permission to send raw srb\n"); 447 dprintk((KERN_DEBUG"aacraid: No permission to send raw srb\n"));
430 return -EPERM; 448 return -EPERM;
431 } 449 }
432 /* 450 /*
@@ -439,37 +457,45 @@ int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
439 457
440 srbcmd = (struct aac_srb*) fib_data(srbfib); 458 srbcmd = (struct aac_srb*) fib_data(srbfib);
441 459
460 memset(sg_list, 0, sizeof(sg_list)); /* cleanup may take issue */
442 if(copy_from_user(&fibsize, &user_srb->count,sizeof(u32))){ 461 if(copy_from_user(&fibsize, &user_srb->count,sizeof(u32))){
443 printk(KERN_DEBUG"aacraid: Could not copy data size from user\n"); 462 dprintk((KERN_DEBUG"aacraid: Could not copy data size from user\n"));
444 rcode = -EFAULT; 463 rcode = -EFAULT;
445 goto cleanup; 464 goto cleanup;
446 } 465 }
447 466
448 if (fibsize > FIB_DATA_SIZE_IN_BYTES) { 467 if (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr))) {
449 rcode = -EINVAL; 468 rcode = -EINVAL;
450 goto cleanup; 469 goto cleanup;
451 } 470 }
452 471
453 if(copy_from_user(srbcmd, user_srb,fibsize)){ 472 user_srbcmd = kmalloc(GFP_KERNEL, fibsize);
454 printk(KERN_DEBUG"aacraid: Could not copy srb from user\n"); 473 if (!user_srbcmd) {
474 dprintk((KERN_DEBUG"aacraid: Could not make a copy of the srb\n"));
475 rcode = -ENOMEM;
476 goto cleanup;
477 }
478 if(copy_from_user(user_srbcmd, user_srb,fibsize)){
479 dprintk((KERN_DEBUG"aacraid: Could not copy srb from user\n"));
455 rcode = -EFAULT; 480 rcode = -EFAULT;
456 goto cleanup; 481 goto cleanup;
457 } 482 }
458 483
459 user_reply = arg+fibsize; 484 user_reply = arg+fibsize;
460 485
461 flags = srbcmd->flags; 486 flags = user_srbcmd->flags; /* from user in cpu order */
462 // Fix up srb for endian and force some values 487 // Fix up srb for endian and force some values
488
463 srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi); // Force this 489 srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi); // Force this
464 srbcmd->channel = cpu_to_le32(srbcmd->channel); 490 srbcmd->channel = cpu_to_le32(user_srbcmd->channel);
465 srbcmd->id = cpu_to_le32(srbcmd->id); 491 srbcmd->id = cpu_to_le32(user_srbcmd->id);
466 srbcmd->lun = cpu_to_le32(srbcmd->lun); 492 srbcmd->lun = cpu_to_le32(user_srbcmd->lun);
467 srbcmd->flags = cpu_to_le32(srbcmd->flags); 493 srbcmd->flags = cpu_to_le32(flags);
468 srbcmd->timeout = cpu_to_le32(srbcmd->timeout); 494 srbcmd->timeout = cpu_to_le32(user_srbcmd->timeout);
469 srbcmd->retry_limit =cpu_to_le32(0); // Obsolete parameter 495 srbcmd->retry_limit =cpu_to_le32(0); // Obsolete parameter
470 srbcmd->cdb_size = cpu_to_le32(srbcmd->cdb_size); 496 srbcmd->cdb_size = cpu_to_le32(user_srbcmd->cdb_size);
471 497
472 switch (srbcmd->flags & (SRB_DataIn | SRB_DataOut)) { 498 switch (flags & (SRB_DataIn | SRB_DataOut)) {
473 case SRB_DataOut: 499 case SRB_DataOut:
474 data_dir = DMA_TO_DEVICE; 500 data_dir = DMA_TO_DEVICE;
475 break; 501 break;
@@ -482,118 +508,148 @@ int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
482 default: 508 default:
483 data_dir = DMA_NONE; 509 data_dir = DMA_NONE;
484 } 510 }
511 if (le32_to_cpu(srbcmd->sg.count) > (sizeof(sg_list)/sizeof(sg_list[0]))) {
512 dprintk((KERN_DEBUG"aacraid: too many sg entries %d\n",
513 le32_to_cpu(srbcmd->sg.count)));
514 rcode = -EINVAL;
515 goto cleanup;
516 }
485 if (dev->dac_support == 1) { 517 if (dev->dac_support == 1) {
486 struct sgmap64* psg = (struct sgmap64*)&srbcmd->sg; 518 struct user_sgmap64* upsg = (struct user_sgmap64*)&user_srbcmd->sg;
519 struct sgmap64* psg = (struct sgmap64*)&user_srbcmd->sg;
520 struct user_sgmap* usg;
487 byte_count = 0; 521 byte_count = 0;
488 522
489 /* 523 /*
490 * This should also catch if user used the 32 bit sgmap 524 * This should also catch if user used the 32 bit sgmap
491 */ 525 */
492 actual_fibsize = sizeof(struct aac_srb) - 526 actual_fibsize = sizeof(struct aac_srb) -
493 sizeof(struct sgentry) + ((srbcmd->sg.count & 0xff) * 527 sizeof(struct sgentry) +
494 sizeof(struct sgentry64)); 528 ((upsg->count & 0xff) *
529 sizeof(struct sgentry));
495 if(actual_fibsize != fibsize){ // User made a mistake - should not continue 530 if(actual_fibsize != fibsize){ // User made a mistake - should not continue
496 printk(KERN_DEBUG"aacraid: Bad Size specified in Raw SRB command\n"); 531 dprintk((KERN_DEBUG"aacraid: Bad Size specified in Raw SRB command\n"));
497 rcode = -EINVAL; 532 rcode = -EINVAL;
498 goto cleanup; 533 goto cleanup;
499 } 534 }
500 if ((data_dir == DMA_NONE) && psg->count) { 535 usg = kmalloc(actual_fibsize - sizeof(struct aac_srb)
501 printk(KERN_DEBUG"aacraid: SG with no direction specified in Raw SRB command\n"); 536 + sizeof(struct sgmap), GFP_KERNEL);
537 if (!usg) {
538 dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n"));
539 rcode = -ENOMEM;
540 goto cleanup;
541 }
542 memcpy (usg, upsg, actual_fibsize - sizeof(struct aac_srb)
543 + sizeof(struct sgmap));
544 actual_fibsize = sizeof(struct aac_srb) -
545 sizeof(struct sgentry) + ((usg->count & 0xff) *
546 sizeof(struct sgentry64));
547 if ((data_dir == DMA_NONE) && upsg->count) {
548 kfree (usg);
549 dprintk((KERN_DEBUG"aacraid: SG with no direction specified in Raw SRB command\n"));
502 rcode = -EINVAL; 550 rcode = -EINVAL;
503 goto cleanup; 551 goto cleanup;
504 } 552 }
505 553
506 for (i = 0; i < psg->count; i++) { 554 for (i = 0; i < usg->count; i++) {
507 dma_addr_t addr; 555 u64 addr;
508 u64 le_addr;
509 void* p; 556 void* p;
510 p = kmalloc(psg->sg[i].count,GFP_KERNEL|__GFP_DMA); 557 /* Does this really need to be GFP_DMA? */
558 p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA);
511 if(p == 0) { 559 if(p == 0) {
512 printk(KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", 560 kfree (usg);
513 psg->sg[i].count,i,psg->count); 561 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
562 usg->sg[i].count,i,usg->count));
514 rcode = -ENOMEM; 563 rcode = -ENOMEM;
515 goto cleanup; 564 goto cleanup;
516 } 565 }
517 sg_user[i] = (void __user *)psg->sg[i].addr; 566 sg_user[i] = (void __user *)usg->sg[i].addr;
518 sg_list[i] = p; // save so we can clean up later 567 sg_list[i] = p; // save so we can clean up later
519 sg_indx = i; 568 sg_indx = i;
520 569
521 if( flags & SRB_DataOut ){ 570 if( flags & SRB_DataOut ){
522 if(copy_from_user(p,sg_user[i],psg->sg[i].count)){ 571 if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){
523 printk(KERN_DEBUG"aacraid: Could not copy sg data from user\n"); 572 kfree (usg);
573 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
524 rcode = -EFAULT; 574 rcode = -EFAULT;
525 goto cleanup; 575 goto cleanup;
526 } 576 }
527 } 577 }
528 addr = pci_map_single(dev->pdev, p, psg->sg[i].count, data_dir); 578 addr = pci_map_single(dev->pdev, p, usg->sg[i].count, data_dir);
529 579
530 le_addr = cpu_to_le64(addr); 580 psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff);
531 psg->sg[i].addr[1] = (u32)(le_addr>>32); 581 psg->sg[i].addr[1] = cpu_to_le32(addr>>32);
532 psg->sg[i].addr[0] = (u32)(le_addr & 0xffffffff); 582 psg->sg[i].count = cpu_to_le32(usg->sg[i].count);
533 psg->sg[i].count = cpu_to_le32(psg->sg[i].count); 583 byte_count += usg->sg[i].count;
534 byte_count += psg->sg[i].count;
535 } 584 }
585 kfree (usg);
536 586
537 srbcmd->count = cpu_to_le32(byte_count); 587 srbcmd->count = cpu_to_le32(byte_count);
588 psg->count = cpu_to_le32(sg_indx+1);
538 status = fib_send(ScsiPortCommand64, srbfib, actual_fibsize, FsaNormal, 1, 1,NULL,NULL); 589 status = fib_send(ScsiPortCommand64, srbfib, actual_fibsize, FsaNormal, 1, 1,NULL,NULL);
539 } else { 590 } else {
591 struct user_sgmap* upsg = &user_srbcmd->sg;
540 struct sgmap* psg = &srbcmd->sg; 592 struct sgmap* psg = &srbcmd->sg;
541 byte_count = 0; 593 byte_count = 0;
542 594
543 actual_fibsize = sizeof (struct aac_srb) + 595 actual_fibsize = sizeof (struct aac_srb) + (((le32_to_cpu(srbcmd->sg.count) & 0xff) - 1) * sizeof (struct sgentry));
544 (((le32_to_cpu(srbcmd->sg.count) & 0xff) - 1) *
545 sizeof (struct sgentry));
546 if(actual_fibsize != fibsize){ // User made a mistake - should not continue 596 if(actual_fibsize != fibsize){ // User made a mistake - should not continue
547 printk(KERN_DEBUG"aacraid: Bad Size specified in Raw SRB command\n"); 597 dprintk((KERN_DEBUG"aacraid: Bad Size specified in Raw SRB command\n"));
548 rcode = -EINVAL; 598 rcode = -EINVAL;
549 goto cleanup; 599 goto cleanup;
550 } 600 }
551 if ((data_dir == DMA_NONE) && psg->count) { 601 if ((data_dir == DMA_NONE) && upsg->count) {
552 printk(KERN_DEBUG"aacraid: SG with no direction specified in Raw SRB command\n"); 602 dprintk((KERN_DEBUG"aacraid: SG with no direction specified in Raw SRB command\n"));
553 rcode = -EINVAL; 603 rcode = -EINVAL;
554 goto cleanup; 604 goto cleanup;
555 } 605 }
556 for (i = 0; i < psg->count; i++) { 606 for (i = 0; i < upsg->count; i++) {
557 dma_addr_t addr; 607 dma_addr_t addr;
558 void* p; 608 void* p;
559 p = kmalloc(psg->sg[i].count,GFP_KERNEL); 609 p = kmalloc(upsg->sg[i].count, GFP_KERNEL);
560 if(p == 0) { 610 if(p == 0) {
561 printk(KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", 611 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
562 psg->sg[i].count,i,psg->count); 612 upsg->sg[i].count, i, upsg->count));
563 rcode = -ENOMEM; 613 rcode = -ENOMEM;
564 goto cleanup; 614 goto cleanup;
565 } 615 }
566 sg_user[i] = (void __user *)(psg->sg[i].addr); 616 sg_user[i] = (void __user *)upsg->sg[i].addr;
567 sg_list[i] = p; // save so we can clean up later 617 sg_list[i] = p; // save so we can clean up later
568 sg_indx = i; 618 sg_indx = i;
569 619
570 if( flags & SRB_DataOut ){ 620 if( flags & SRB_DataOut ){
571 if(copy_from_user(p,sg_user[i],psg->sg[i].count)){ 621 if(copy_from_user(p, sg_user[i],
572 printk(KERN_DEBUG"aacraid: Could not copy sg data from user\n"); 622 upsg->sg[i].count)) {
623 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
573 rcode = -EFAULT; 624 rcode = -EFAULT;
574 goto cleanup; 625 goto cleanup;
575 } 626 }
576 } 627 }
577 addr = pci_map_single(dev->pdev, p, psg->sg[i].count, data_dir); 628 addr = pci_map_single(dev->pdev, p,
629 upsg->sg[i].count, data_dir);
578 630
579 psg->sg[i].addr = cpu_to_le32(addr); 631 psg->sg[i].addr = cpu_to_le32(addr);
580 psg->sg[i].count = cpu_to_le32(psg->sg[i].count); 632 psg->sg[i].count = cpu_to_le32(upsg->sg[i].count);
581 byte_count += psg->sg[i].count; 633 byte_count += upsg->sg[i].count;
582 } 634 }
583 srbcmd->count = cpu_to_le32(byte_count); 635 srbcmd->count = cpu_to_le32(byte_count);
636 psg->count = cpu_to_le32(sg_indx+1);
584 status = fib_send(ScsiPortCommand, srbfib, actual_fibsize, FsaNormal, 1, 1, NULL, NULL); 637 status = fib_send(ScsiPortCommand, srbfib, actual_fibsize, FsaNormal, 1, 1, NULL, NULL);
585 } 638 }
586 639
587 if (status != 0){ 640 if (status != 0){
588 printk(KERN_DEBUG"aacraid: Could not send raw srb fib to hba\n"); 641 dprintk((KERN_DEBUG"aacraid: Could not send raw srb fib to hba\n"));
589 rcode = -1; 642 rcode = -1;
590 goto cleanup; 643 goto cleanup;
591 } 644 }
592 645
593 if( flags & SRB_DataIn ) { 646 if( flags & SRB_DataIn ) {
594 for(i = 0 ; i <= sg_indx; i++){ 647 for(i = 0 ; i <= sg_indx; i++){
595 if(copy_to_user(sg_user[i],sg_list[i],le32_to_cpu(srbcmd->sg.sg[i].count))){ 648 byte_count = le32_to_cpu((dev->dac_support == 1)
596 printk(KERN_DEBUG"aacraid: Could not copy sg data to user\n"); 649 ? ((struct sgmap64*)&srbcmd->sg)->sg[i].count
650 : srbcmd->sg.sg[i].count);
651 if(copy_to_user(sg_user[i], sg_list[i], byte_count)){
652 dprintk((KERN_DEBUG"aacraid: Could not copy sg data to user\n"));
597 rcode = -EFAULT; 653 rcode = -EFAULT;
598 goto cleanup; 654 goto cleanup;
599 655
@@ -603,12 +659,13 @@ int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
603 659
604 reply = (struct aac_srb_reply *) fib_data(srbfib); 660 reply = (struct aac_srb_reply *) fib_data(srbfib);
605 if(copy_to_user(user_reply,reply,sizeof(struct aac_srb_reply))){ 661 if(copy_to_user(user_reply,reply,sizeof(struct aac_srb_reply))){
606 printk(KERN_DEBUG"aacraid: Could not copy reply to user\n"); 662 dprintk((KERN_DEBUG"aacraid: Could not copy reply to user\n"));
607 rcode = -EFAULT; 663 rcode = -EFAULT;
608 goto cleanup; 664 goto cleanup;
609 } 665 }
610 666
611cleanup: 667cleanup:
668 kfree(user_srbcmd);
612 for(i=0; i <= sg_indx; i++){ 669 for(i=0; i <= sg_indx; i++){
613 kfree(sg_list[i]); 670 kfree(sg_list[i]);
614 } 671 }
@@ -618,14 +675,13 @@ cleanup:
618 return rcode; 675 return rcode;
619} 676}
620 677
621
622struct aac_pci_info { 678struct aac_pci_info {
623 u32 bus; 679 u32 bus;
624 u32 slot; 680 u32 slot;
625}; 681};
626 682
627 683
628int aac_get_pci_info(struct aac_dev* dev, void __user *arg) 684static int aac_get_pci_info(struct aac_dev* dev, void __user *arg)
629{ 685{
630 struct aac_pci_info pci_info; 686 struct aac_pci_info pci_info;
631 687
@@ -633,11 +689,11 @@ int aac_get_pci_info(struct aac_dev* dev, void __user *arg)
633 pci_info.slot = PCI_SLOT(dev->pdev->devfn); 689 pci_info.slot = PCI_SLOT(dev->pdev->devfn);
634 690
635 if (copy_to_user(arg, &pci_info, sizeof(struct aac_pci_info))) { 691 if (copy_to_user(arg, &pci_info, sizeof(struct aac_pci_info))) {
636 printk(KERN_DEBUG "aacraid: Could not copy pci info\n"); 692 dprintk((KERN_DEBUG "aacraid: Could not copy pci info\n"));
637 return -EFAULT; 693 return -EFAULT;
638 } 694 }
639 return 0; 695 return 0;
640 } 696}
641 697
642 698
643int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg) 699int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg)
@@ -656,6 +712,7 @@ int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg)
656 case FSACTL_MINIPORT_REV_CHECK: 712 case FSACTL_MINIPORT_REV_CHECK:
657 status = check_revision(dev, arg); 713 status = check_revision(dev, arg);
658 break; 714 break;
715 case FSACTL_SEND_LARGE_FIB:
659 case FSACTL_SENDFIB: 716 case FSACTL_SENDFIB:
660 status = ioctl_send_fib(dev, arg); 717 status = ioctl_send_fib(dev, arg);
661 break; 718 break;
diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
index 6832a55ca907..43557bf661f6 100644
--- a/drivers/scsi/aacraid/comminit.c
+++ b/drivers/scsi/aacraid/comminit.c
@@ -39,6 +39,7 @@
39#include <linux/blkdev.h> 39#include <linux/blkdev.h>
40#include <linux/completion.h> 40#include <linux/completion.h>
41#include <linux/mm.h> 41#include <linux/mm.h>
42#include <scsi/scsi_host.h>
42#include <asm/semaphore.h> 43#include <asm/semaphore.h>
43 44
44#include "aacraid.h" 45#include "aacraid.h"
@@ -49,8 +50,8 @@ static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long co
49{ 50{
50 unsigned char *base; 51 unsigned char *base;
51 unsigned long size, align; 52 unsigned long size, align;
52 unsigned long fibsize = 4096; 53 const unsigned long fibsize = 4096;
53 unsigned long printfbufsiz = 256; 54 const unsigned long printfbufsiz = 256;
54 struct aac_init *init; 55 struct aac_init *init;
55 dma_addr_t phys; 56 dma_addr_t phys;
56 57
@@ -74,6 +75,8 @@ static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long co
74 init = dev->init; 75 init = dev->init;
75 76
76 init->InitStructRevision = cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION); 77 init->InitStructRevision = cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION);
78 if (dev->max_fib_size != sizeof(struct hw_fib))
79 init->InitStructRevision = cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION_4);
77 init->MiniPortRevision = cpu_to_le32(Sa_MINIPORT_REVISION); 80 init->MiniPortRevision = cpu_to_le32(Sa_MINIPORT_REVISION);
78 init->fsrev = cpu_to_le32(dev->fsrev); 81 init->fsrev = cpu_to_le32(dev->fsrev);
79 82
@@ -110,6 +113,10 @@ static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long co
110 init->HostPhysMemPages = cpu_to_le32(AAC_MAX_HOSTPHYSMEMPAGES); 113 init->HostPhysMemPages = cpu_to_le32(AAC_MAX_HOSTPHYSMEMPAGES);
111 } 114 }
112 115
116 init->InitFlags = 0;
117 init->MaxIoCommands = cpu_to_le32(dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB);
118 init->MaxIoSize = cpu_to_le32(dev->scsi_host_ptr->max_sectors << 9);
119 init->MaxFibSize = cpu_to_le32(dev->max_fib_size);
113 120
114 /* 121 /*
115 * Increment the base address by the amount already used 122 * Increment the base address by the amount already used
@@ -152,8 +159,8 @@ static void aac_queue_init(struct aac_dev * dev, struct aac_queue * q, u32 *mem,
152 init_waitqueue_head(&q->qfull); 159 init_waitqueue_head(&q->qfull);
153 spin_lock_init(&q->lockdata); 160 spin_lock_init(&q->lockdata);
154 q->lock = &q->lockdata; 161 q->lock = &q->lockdata;
155 q->headers.producer = mem; 162 q->headers.producer = (__le32 *)mem;
156 q->headers.consumer = mem+1; 163 q->headers.consumer = (__le32 *)(mem+1);
157 *(q->headers.producer) = cpu_to_le32(qsize); 164 *(q->headers.producer) = cpu_to_le32(qsize);
158 *(q->headers.consumer) = cpu_to_le32(qsize); 165 *(q->headers.consumer) = cpu_to_le32(qsize);
159 q->entries = qsize; 166 q->entries = qsize;
@@ -173,6 +180,8 @@ int aac_send_shutdown(struct aac_dev * dev)
173 int status; 180 int status;
174 181
175 fibctx = fib_alloc(dev); 182 fibctx = fib_alloc(dev);
183 if (!fibctx)
184 return -ENOMEM;
176 fib_init(fibctx); 185 fib_init(fibctx);
177 186
178 cmd = (struct aac_close *) fib_data(fibctx); 187 cmd = (struct aac_close *) fib_data(fibctx);
@@ -204,7 +213,7 @@ int aac_send_shutdown(struct aac_dev * dev)
204 * 0 - If there were errors initing. This is a fatal error. 213 * 0 - If there were errors initing. This is a fatal error.
205 */ 214 */
206 215
207int aac_comm_init(struct aac_dev * dev) 216static int aac_comm_init(struct aac_dev * dev)
208{ 217{
209 unsigned long hdrsize = (sizeof(u32) * NUMBER_OF_COMM_QUEUES) * 2; 218 unsigned long hdrsize = (sizeof(u32) * NUMBER_OF_COMM_QUEUES) * 2;
210 unsigned long queuesize = sizeof(struct aac_entry) * TOTAL_QUEUE_ENTRIES; 219 unsigned long queuesize = sizeof(struct aac_entry) * TOTAL_QUEUE_ENTRIES;
@@ -293,6 +302,79 @@ int aac_comm_init(struct aac_dev * dev)
293 302
294struct aac_dev *aac_init_adapter(struct aac_dev *dev) 303struct aac_dev *aac_init_adapter(struct aac_dev *dev)
295{ 304{
305 u32 status[5];
306 struct Scsi_Host * host = dev->scsi_host_ptr;
307
308 /*
309 * Check the preferred comm settings, defaults from template.
310 */
311 dev->max_fib_size = sizeof(struct hw_fib);
312 dev->sg_tablesize = host->sg_tablesize = (dev->max_fib_size
313 - sizeof(struct aac_fibhdr)
314 - sizeof(struct aac_write) + sizeof(struct sgmap))
315 / sizeof(struct sgmap);
316 if ((!aac_adapter_sync_cmd(dev, GET_COMM_PREFERRED_SETTINGS,
317 0, 0, 0, 0, 0, 0,
318 status+0, status+1, status+2, status+3, status+4))
319 && (status[0] == 0x00000001)) {
320 /*
321 * status[1] >> 16 maximum command size in KB
322 * status[1] & 0xFFFF maximum FIB size
323 * status[2] >> 16 maximum SG elements to driver
324 * status[2] & 0xFFFF maximum SG elements from driver
325 * status[3] & 0xFFFF maximum number FIBs outstanding
326 */
327 host->max_sectors = (status[1] >> 16) << 1;
328 dev->max_fib_size = status[1] & 0xFFFF;
329 host->sg_tablesize = status[2] >> 16;
330 dev->sg_tablesize = status[2] & 0xFFFF;
331 host->can_queue = (status[3] & 0xFFFF) - AAC_NUM_MGT_FIB;
332 /*
333 * NOTE:
334 * All these overrides are based on a fixed internal
335 * knowledge and understanding of existing adapters,
336 * acbsize should be set with caution.
337 */
338 if (acbsize == 512) {
339 host->max_sectors = AAC_MAX_32BIT_SGBCOUNT;
340 dev->max_fib_size = 512;
341 dev->sg_tablesize = host->sg_tablesize
342 = (512 - sizeof(struct aac_fibhdr)
343 - sizeof(struct aac_write) + sizeof(struct sgmap))
344 / sizeof(struct sgmap);
345 host->can_queue = AAC_NUM_IO_FIB;
346 } else if (acbsize == 2048) {
347 host->max_sectors = 512;
348 dev->max_fib_size = 2048;
349 host->sg_tablesize = 65;
350 dev->sg_tablesize = 81;
351 host->can_queue = 512 - AAC_NUM_MGT_FIB;
352 } else if (acbsize == 4096) {
353 host->max_sectors = 1024;
354 dev->max_fib_size = 4096;
355 host->sg_tablesize = 129;
356 dev->sg_tablesize = 166;
357 host->can_queue = 256 - AAC_NUM_MGT_FIB;
358 } else if (acbsize == 8192) {
359 host->max_sectors = 2048;
360 dev->max_fib_size = 8192;
361 host->sg_tablesize = 257;
362 dev->sg_tablesize = 337;
363 host->can_queue = 128 - AAC_NUM_MGT_FIB;
364 } else if (acbsize > 0) {
365 printk("Illegal acbsize=%d ignored\n", acbsize);
366 }
367 }
368 {
369
370 if (numacb > 0) {
371 if (numacb < host->can_queue)
372 host->can_queue = numacb;
373 else
374 printk("numacb=%d ignored\n", numacb);
375 }
376 }
377
296 /* 378 /*
297 * Ok now init the communication subsystem 379 * Ok now init the communication subsystem
298 */ 380 */
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index 3f36dbaa2bb3..5322865942e2 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -25,7 +25,7 @@
25 * commsup.c 25 * commsup.c
26 * 26 *
27 * Abstract: Contain all routines that are required for FSA host/adapter 27 * Abstract: Contain all routines that are required for FSA host/adapter
28 * commuication. 28 * communication.
29 * 29 *
30 */ 30 */
31 31
@@ -38,6 +38,7 @@
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/completion.h> 39#include <linux/completion.h>
40#include <linux/blkdev.h> 40#include <linux/blkdev.h>
41#include <scsi/scsi_host.h>
41#include <asm/semaphore.h> 42#include <asm/semaphore.h>
42 43
43#include "aacraid.h" 44#include "aacraid.h"
@@ -52,7 +53,13 @@
52 53
53static int fib_map_alloc(struct aac_dev *dev) 54static int fib_map_alloc(struct aac_dev *dev)
54{ 55{
55 if((dev->hw_fib_va = pci_alloc_consistent(dev->pdev, sizeof(struct hw_fib) * AAC_NUM_FIB, &dev->hw_fib_pa))==NULL) 56 dprintk((KERN_INFO
57 "allocate hardware fibs pci_alloc_consistent(%p, %d * (%d + %d), %p)\n",
58 dev->pdev, dev->max_fib_size, dev->scsi_host_ptr->can_queue,
59 AAC_NUM_MGT_FIB, &dev->hw_fib_pa));
60 if((dev->hw_fib_va = pci_alloc_consistent(dev->pdev, dev->max_fib_size
61 * (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB),
62 &dev->hw_fib_pa))==NULL)
56 return -ENOMEM; 63 return -ENOMEM;
57 return 0; 64 return 0;
58} 65}
@@ -67,7 +74,7 @@ static int fib_map_alloc(struct aac_dev *dev)
67 74
68void fib_map_free(struct aac_dev *dev) 75void fib_map_free(struct aac_dev *dev)
69{ 76{
70 pci_free_consistent(dev->pdev, sizeof(struct hw_fib) * AAC_NUM_FIB, dev->hw_fib_va, dev->hw_fib_pa); 77 pci_free_consistent(dev->pdev, dev->max_fib_size * (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB), dev->hw_fib_va, dev->hw_fib_pa);
71} 78}
72 79
73/** 80/**
@@ -84,17 +91,22 @@ int fib_setup(struct aac_dev * dev)
84 struct hw_fib *hw_fib_va; 91 struct hw_fib *hw_fib_va;
85 dma_addr_t hw_fib_pa; 92 dma_addr_t hw_fib_pa;
86 int i; 93 int i;
87 94
88 if(fib_map_alloc(dev)<0) 95 while (((i = fib_map_alloc(dev)) == -ENOMEM)
96 && (dev->scsi_host_ptr->can_queue > (64 - AAC_NUM_MGT_FIB))) {
97 dev->init->MaxIoCommands = cpu_to_le32((dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB) >> 1);
98 dev->scsi_host_ptr->can_queue = le32_to_cpu(dev->init->MaxIoCommands) - AAC_NUM_MGT_FIB;
99 }
100 if (i<0)
89 return -ENOMEM; 101 return -ENOMEM;
90 102
91 hw_fib_va = dev->hw_fib_va; 103 hw_fib_va = dev->hw_fib_va;
92 hw_fib_pa = dev->hw_fib_pa; 104 hw_fib_pa = dev->hw_fib_pa;
93 memset(hw_fib_va, 0, sizeof(struct hw_fib) * AAC_NUM_FIB); 105 memset(hw_fib_va, 0, dev->max_fib_size * (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB));
94 /* 106 /*
95 * Initialise the fibs 107 * Initialise the fibs
96 */ 108 */
97 for (i = 0, fibptr = &dev->fibs[i]; i < AAC_NUM_FIB; i++, fibptr++) 109 for (i = 0, fibptr = &dev->fibs[i]; i < (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); i++, fibptr++)
98 { 110 {
99 fibptr->dev = dev; 111 fibptr->dev = dev;
100 fibptr->hw_fib = hw_fib_va; 112 fibptr->hw_fib = hw_fib_va;
@@ -102,16 +114,16 @@ int fib_setup(struct aac_dev * dev)
102 fibptr->next = fibptr+1; /* Forward chain the fibs */ 114 fibptr->next = fibptr+1; /* Forward chain the fibs */
103 init_MUTEX_LOCKED(&fibptr->event_wait); 115 init_MUTEX_LOCKED(&fibptr->event_wait);
104 spin_lock_init(&fibptr->event_lock); 116 spin_lock_init(&fibptr->event_lock);
105 hw_fib_va->header.XferState = 0xffffffff; 117 hw_fib_va->header.XferState = cpu_to_le32(0xffffffff);
106 hw_fib_va->header.SenderSize = cpu_to_le16(sizeof(struct hw_fib)); 118 hw_fib_va->header.SenderSize = cpu_to_le16(dev->max_fib_size);
107 fibptr->hw_fib_pa = hw_fib_pa; 119 fibptr->hw_fib_pa = hw_fib_pa;
108 hw_fib_va = (struct hw_fib *)((unsigned char *)hw_fib_va + sizeof(struct hw_fib)); 120 hw_fib_va = (struct hw_fib *)((unsigned char *)hw_fib_va + dev->max_fib_size);
109 hw_fib_pa = hw_fib_pa + sizeof(struct hw_fib); 121 hw_fib_pa = hw_fib_pa + dev->max_fib_size;
110 } 122 }
111 /* 123 /*
112 * Add the fib chain to the free list 124 * Add the fib chain to the free list
113 */ 125 */
114 dev->fibs[AAC_NUM_FIB-1].next = NULL; 126 dev->fibs[dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB - 1].next = NULL;
115 /* 127 /*
116 * Enable this to debug out of queue space 128 * Enable this to debug out of queue space
117 */ 129 */
@@ -124,7 +136,7 @@ int fib_setup(struct aac_dev * dev)
124 * @dev: Adapter to allocate the fib for 136 * @dev: Adapter to allocate the fib for
125 * 137 *
126 * Allocate a fib from the adapter fib pool. If the pool is empty we 138 * Allocate a fib from the adapter fib pool. If the pool is empty we
127 * wait for fibs to become free. 139 * return NULL.
128 */ 140 */
129 141
130struct fib * fib_alloc(struct aac_dev *dev) 142struct fib * fib_alloc(struct aac_dev *dev)
@@ -133,10 +145,10 @@ struct fib * fib_alloc(struct aac_dev *dev)
133 unsigned long flags; 145 unsigned long flags;
134 spin_lock_irqsave(&dev->fib_lock, flags); 146 spin_lock_irqsave(&dev->fib_lock, flags);
135 fibptr = dev->free_fib; 147 fibptr = dev->free_fib;
136 /* Cannot sleep here or you get hangs. Instead we did the 148 if(!fibptr){
137 maths at compile time. */ 149 spin_unlock_irqrestore(&dev->fib_lock, flags);
138 if(!fibptr) 150 return fibptr;
139 BUG(); 151 }
140 dev->free_fib = fibptr->next; 152 dev->free_fib = fibptr->next;
141 spin_unlock_irqrestore(&dev->fib_lock, flags); 153 spin_unlock_irqrestore(&dev->fib_lock, flags);
142 /* 154 /*
@@ -196,11 +208,11 @@ void fib_init(struct fib *fibptr)
196 struct hw_fib *hw_fib = fibptr->hw_fib; 208 struct hw_fib *hw_fib = fibptr->hw_fib;
197 209
198 hw_fib->header.StructType = FIB_MAGIC; 210 hw_fib->header.StructType = FIB_MAGIC;
199 hw_fib->header.Size = cpu_to_le16(sizeof(struct hw_fib)); 211 hw_fib->header.Size = cpu_to_le16(fibptr->dev->max_fib_size);
200 hw_fib->header.XferState = cpu_to_le32(HostOwned | FibInitialized | FibEmpty | FastResponseCapable); 212 hw_fib->header.XferState = cpu_to_le32(HostOwned | FibInitialized | FibEmpty | FastResponseCapable);
201 hw_fib->header.SenderFibAddress = cpu_to_le32(fibptr->hw_fib_pa); 213 hw_fib->header.SenderFibAddress = cpu_to_le32(fibptr->hw_fib_pa);
202 hw_fib->header.ReceiverFibAddress = cpu_to_le32(fibptr->hw_fib_pa); 214 hw_fib->header.ReceiverFibAddress = cpu_to_le32(fibptr->hw_fib_pa);
203 hw_fib->header.SenderSize = cpu_to_le16(sizeof(struct hw_fib)); 215 hw_fib->header.SenderSize = cpu_to_le16(fibptr->dev->max_fib_size);
204} 216}
205 217
206/** 218/**
@@ -211,7 +223,7 @@ void fib_init(struct fib *fibptr)
211 * caller. 223 * caller.
212 */ 224 */
213 225
214void fib_dealloc(struct fib * fibptr) 226static void fib_dealloc(struct fib * fibptr)
215{ 227{
216 struct hw_fib *hw_fib = fibptr->hw_fib; 228 struct hw_fib *hw_fib = fibptr->hw_fib;
217 if(hw_fib->header.StructType != FIB_MAGIC) 229 if(hw_fib->header.StructType != FIB_MAGIC)
@@ -279,7 +291,7 @@ static int aac_get_entry (struct aac_dev * dev, u32 qid, struct aac_entry **entr
279 } 291 }
280 292
281 if ((*index + 1) == le32_to_cpu(*(q->headers.consumer))) { /* Queue is full */ 293 if ((*index + 1) == le32_to_cpu(*(q->headers.consumer))) { /* Queue is full */
282 printk(KERN_WARNING "Queue %d full, %d outstanding.\n", 294 printk(KERN_WARNING "Queue %d full, %u outstanding.\n",
283 qid, q->numpending); 295 qid, q->numpending);
284 return 0; 296 return 0;
285 } else { 297 } else {
@@ -658,9 +670,8 @@ int fib_adapter_complete(struct fib * fibptr, unsigned short size)
658 } 670 }
659 if (aac_insert_entry(dev, index, AdapHighRespQueue, (nointr & (int)aac_config.irq_mod)) != 0) { 671 if (aac_insert_entry(dev, index, AdapHighRespQueue, (nointr & (int)aac_config.irq_mod)) != 0) {
660 } 672 }
661 } 673 } else if (hw_fib->header.XferState &
662 else if (hw_fib->header.XferState & NormalPriority) 674 cpu_to_le32(NormalPriority)) {
663 {
664 u32 index; 675 u32 index;
665 676
666 if (size) { 677 if (size) {
@@ -744,22 +755,25 @@ int fib_complete(struct fib * fibptr)
744 755
745void aac_printf(struct aac_dev *dev, u32 val) 756void aac_printf(struct aac_dev *dev, u32 val)
746{ 757{
747 int length = val & 0xffff;
748 int level = (val >> 16) & 0xffff;
749 char *cp = dev->printfbuf; 758 char *cp = dev->printfbuf;
750 759 if (dev->printf_enabled)
751 /* 760 {
752 * The size of the printfbuf is set in port.c 761 int length = val & 0xffff;
753 * There is no variable or define for it 762 int level = (val >> 16) & 0xffff;
754 */ 763
755 if (length > 255) 764 /*
756 length = 255; 765 * The size of the printfbuf is set in port.c
757 if (cp[length] != 0) 766 * There is no variable or define for it
758 cp[length] = 0; 767 */
759 if (level == LOG_AAC_HIGH_ERROR) 768 if (length > 255)
760 printk(KERN_WARNING "aacraid:%s", cp); 769 length = 255;
761 else 770 if (cp[length] != 0)
762 printk(KERN_INFO "aacraid:%s", cp); 771 cp[length] = 0;
772 if (level == LOG_AAC_HIGH_ERROR)
773 printk(KERN_WARNING "aacraid:%s", cp);
774 else
775 printk(KERN_INFO "aacraid:%s", cp);
776 }
763 memset(cp, 0, 256); 777 memset(cp, 0, 256);
764} 778}
765 779
@@ -832,8 +846,8 @@ int aac_command_thread(struct aac_dev * dev)
832 aifcmd = (struct aac_aifcmd *) hw_fib->data; 846 aifcmd = (struct aac_aifcmd *) hw_fib->data;
833 if (aifcmd->command == cpu_to_le32(AifCmdDriverNotify)) { 847 if (aifcmd->command == cpu_to_le32(AifCmdDriverNotify)) {
834 /* Handle Driver Notify Events */ 848 /* Handle Driver Notify Events */
835 *(u32 *)hw_fib->data = cpu_to_le32(ST_OK); 849 *(__le32 *)hw_fib->data = cpu_to_le32(ST_OK);
836 fib_adapter_complete(fib, sizeof(u32)); 850 fib_adapter_complete(fib, (u16)sizeof(u32));
837 } else { 851 } else {
838 struct list_head *entry; 852 struct list_head *entry;
839 /* The u32 here is important and intended. We are using 853 /* The u32 here is important and intended. We are using
@@ -916,7 +930,7 @@ int aac_command_thread(struct aac_dev * dev)
916 /* 930 /*
917 * Set the status of this FIB 931 * Set the status of this FIB
918 */ 932 */
919 *(u32 *)hw_fib->data = cpu_to_le32(ST_OK); 933 *(__le32 *)hw_fib->data = cpu_to_le32(ST_OK);
920 fib_adapter_complete(fib, sizeof(u32)); 934 fib_adapter_complete(fib, sizeof(u32));
921 spin_unlock_irqrestore(&dev->fib_lock, flagv); 935 spin_unlock_irqrestore(&dev->fib_lock, flagv);
922 } 936 }
diff --git a/drivers/scsi/aacraid/dpcsup.c b/drivers/scsi/aacraid/dpcsup.c
index 8480b427a6d9..be2e98de9fab 100644
--- a/drivers/scsi/aacraid/dpcsup.c
+++ b/drivers/scsi/aacraid/dpcsup.c
@@ -99,7 +99,7 @@ unsigned int aac_response_normal(struct aac_queue * q)
99 /* 99 /*
100 * Doctor the fib 100 * Doctor the fib
101 */ 101 */
102 *(u32 *)hwfib->data = cpu_to_le32(ST_OK); 102 *(__le32 *)hwfib->data = cpu_to_le32(ST_OK);
103 hwfib->header.XferState |= cpu_to_le32(AdapterProcessed); 103 hwfib->header.XferState |= cpu_to_le32(AdapterProcessed);
104 } 104 }
105 105
@@ -107,7 +107,7 @@ unsigned int aac_response_normal(struct aac_queue * q)
107 107
108 if (hwfib->header.Command == cpu_to_le16(NuFileSystem)) 108 if (hwfib->header.Command == cpu_to_le16(NuFileSystem))
109 { 109 {
110 u32 *pstatus = (u32 *)hwfib->data; 110 __le32 *pstatus = (__le32 *)hwfib->data;
111 if (*pstatus & cpu_to_le32(0xffff0000)) 111 if (*pstatus & cpu_to_le32(0xffff0000))
112 *pstatus = cpu_to_le32(ST_OK); 112 *pstatus = cpu_to_le32(ST_OK);
113 } 113 }
@@ -205,7 +205,7 @@ unsigned int aac_command_normal(struct aac_queue *q)
205 /* 205 /*
206 * Set the status of this FIB 206 * Set the status of this FIB
207 */ 207 */
208 *(u32 *)hw_fib->data = cpu_to_le32(ST_OK); 208 *(__le32 *)hw_fib->data = cpu_to_le32(ST_OK);
209 fib_adapter_complete(fib, sizeof(u32)); 209 fib_adapter_complete(fib, sizeof(u32));
210 spin_lock_irqsave(q->lock, flags); 210 spin_lock_irqsave(q->lock, flags);
211 } 211 }
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 242fa77513f5..f7e9c89c4915 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -215,7 +215,7 @@ static int aac_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd
215 * Returns a static string describing the device in question 215 * Returns a static string describing the device in question
216 */ 216 */
217 217
218const char *aac_info(struct Scsi_Host *shost) 218static const char *aac_info(struct Scsi_Host *shost)
219{ 219{
220 struct aac_dev *dev = (struct aac_dev *)shost->hostdata; 220 struct aac_dev *dev = (struct aac_dev *)shost->hostdata;
221 return aac_drivers[dev->cardtype].name; 221 return aac_drivers[dev->cardtype].name;
@@ -288,7 +288,7 @@ static int aac_biosparm(struct scsi_device *sdev, struct block_device *bdev,
288 * translations ( 64/32, 128/32, 255/63 ). 288 * translations ( 64/32, 128/32, 255/63 ).
289 */ 289 */
290 buf = scsi_bios_ptable(bdev); 290 buf = scsi_bios_ptable(bdev);
291 if(*(unsigned short *)(buf + 0x40) == cpu_to_le16(0xaa55)) { 291 if(*(__le16 *)(buf + 0x40) == cpu_to_le16(0xaa55)) {
292 struct partition *first = (struct partition * )buf; 292 struct partition *first = (struct partition * )buf;
293 struct partition *entry = first; 293 struct partition *entry = first;
294 int saved_cylinders = param->cylinders; 294 int saved_cylinders = param->cylinders;
@@ -347,10 +347,16 @@ static int aac_biosparm(struct scsi_device *sdev, struct block_device *bdev,
347 347
348static int aac_slave_configure(struct scsi_device *sdev) 348static int aac_slave_configure(struct scsi_device *sdev)
349{ 349{
350 struct Scsi_Host *host = sdev->host;
351
350 if (sdev->tagged_supported) 352 if (sdev->tagged_supported)
351 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, 128); 353 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, 128);
352 else 354 else
353 scsi_adjust_queue_depth(sdev, 0, 1); 355 scsi_adjust_queue_depth(sdev, 0, 1);
356
357 if (host->max_sectors < AAC_MAX_32BIT_SGBCOUNT)
358 blk_queue_max_segment_size(sdev->request_queue, 65536);
359
354 return 0; 360 return 0;
355} 361}
356 362
@@ -361,14 +367,6 @@ static int aac_ioctl(struct scsi_device *sdev, int cmd, void __user * arg)
361} 367}
362 368
363/* 369/*
364 * XXX: does aac really need no error handling??
365 */
366static int aac_eh_abort(struct scsi_cmnd *cmd)
367{
368 return FAILED;
369}
370
371/*
372 * aac_eh_reset - Reset command handling 370 * aac_eh_reset - Reset command handling
373 * @scsi_cmd: SCSI command block causing the reset 371 * @scsi_cmd: SCSI command block causing the reset
374 * 372 *
@@ -386,10 +384,13 @@ static int aac_eh_reset(struct scsi_cmnd* cmd)
386 AAC_DRIVERNAME); 384 AAC_DRIVERNAME);
387 385
388 386
387 spin_lock_irq(host->host_lock);
388
389 aac = (struct aac_dev *)host->hostdata; 389 aac = (struct aac_dev *)host->hostdata;
390 if (aac_adapter_check_health(aac)) { 390 if (aac_adapter_check_health(aac)) {
391 printk(KERN_ERR "%s: Host adapter appears dead\n", 391 printk(KERN_ERR "%s: Host adapter appears dead\n",
392 AAC_DRIVERNAME); 392 AAC_DRIVERNAME);
393 spin_unlock_irq(host->host_lock);
393 return -ENODEV; 394 return -ENODEV;
394 } 395 }
395 /* 396 /*
@@ -420,6 +421,7 @@ static int aac_eh_reset(struct scsi_cmnd* cmd)
420 ssleep(1); 421 ssleep(1);
421 spin_lock_irq(host->host_lock); 422 spin_lock_irq(host->host_lock);
422 } 423 }
424 spin_unlock_irq(host->host_lock);
423 printk(KERN_ERR "%s: SCSI bus appears hung\n", AAC_DRIVERNAME); 425 printk(KERN_ERR "%s: SCSI bus appears hung\n", AAC_DRIVERNAME);
424 return -ETIMEDOUT; 426 return -ETIMEDOUT;
425} 427}
@@ -439,11 +441,11 @@ static int aac_eh_reset(struct scsi_cmnd* cmd)
439static int aac_cfg_open(struct inode *inode, struct file *file) 441static int aac_cfg_open(struct inode *inode, struct file *file)
440{ 442{
441 struct aac_dev *aac; 443 struct aac_dev *aac;
442 unsigned minor = iminor(inode); 444 unsigned minor_number = iminor(inode);
443 int err = -ENODEV; 445 int err = -ENODEV;
444 446
445 list_for_each_entry(aac, &aac_devices, entry) { 447 list_for_each_entry(aac, &aac_devices, entry) {
446 if (aac->id == minor) { 448 if (aac->id == minor_number) {
447 file->private_data = aac; 449 file->private_data = aac;
448 err = 0; 450 err = 0;
449 break; 451 break;
@@ -489,6 +491,7 @@ static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long
489 case FSACTL_DELETE_DISK: 491 case FSACTL_DELETE_DISK:
490 case FSACTL_FORCE_DELETE_DISK: 492 case FSACTL_FORCE_DELETE_DISK:
491 case FSACTL_GET_CONTAINERS: 493 case FSACTL_GET_CONTAINERS:
494 case FSACTL_SEND_LARGE_FIB:
492 ret = aac_do_ioctl(dev, cmd, (void __user *)arg); 495 ret = aac_do_ioctl(dev, cmd, (void __user *)arg);
493 break; 496 break;
494 497
@@ -526,6 +529,134 @@ static long aac_compat_cfg_ioctl(struct file *file, unsigned cmd, unsigned long
526} 529}
527#endif 530#endif
528 531
532static ssize_t aac_show_model(struct class_device *class_dev,
533 char *buf)
534{
535 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
536 int len;
537
538 len = snprintf(buf, PAGE_SIZE, "%s\n",
539 aac_drivers[dev->cardtype].model);
540 return len;
541}
542
543static ssize_t aac_show_vendor(struct class_device *class_dev,
544 char *buf)
545{
546 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
547 int len;
548
549 len = snprintf(buf, PAGE_SIZE, "%s\n",
550 aac_drivers[dev->cardtype].vname);
551 return len;
552}
553
554static ssize_t aac_show_kernel_version(struct class_device *class_dev,
555 char *buf)
556{
557 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
558 int len, tmp;
559
560 tmp = le32_to_cpu(dev->adapter_info.kernelrev);
561 len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n",
562 tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff,
563 le32_to_cpu(dev->adapter_info.kernelbuild));
564 return len;
565}
566
567static ssize_t aac_show_monitor_version(struct class_device *class_dev,
568 char *buf)
569{
570 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
571 int len, tmp;
572
573 tmp = le32_to_cpu(dev->adapter_info.monitorrev);
574 len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n",
575 tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff,
576 le32_to_cpu(dev->adapter_info.monitorbuild));
577 return len;
578}
579
580static ssize_t aac_show_bios_version(struct class_device *class_dev,
581 char *buf)
582{
583 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
584 int len, tmp;
585
586 tmp = le32_to_cpu(dev->adapter_info.biosrev);
587 len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n",
588 tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff,
589 le32_to_cpu(dev->adapter_info.biosbuild));
590 return len;
591}
592
593static ssize_t aac_show_serial_number(struct class_device *class_dev,
594 char *buf)
595{
596 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
597 int len = 0;
598
599 if (le32_to_cpu(dev->adapter_info.serial[0]) != 0xBAD0)
600 len = snprintf(buf, PAGE_SIZE, "%x\n",
601 le32_to_cpu(dev->adapter_info.serial[0]));
602 return len;
603}
604
605
606static struct class_device_attribute aac_model = {
607 .attr = {
608 .name = "model",
609 .mode = S_IRUGO,
610 },
611 .show = aac_show_model,
612};
613static struct class_device_attribute aac_vendor = {
614 .attr = {
615 .name = "vendor",
616 .mode = S_IRUGO,
617 },
618 .show = aac_show_vendor,
619};
620static struct class_device_attribute aac_kernel_version = {
621 .attr = {
622 .name = "hba_kernel_version",
623 .mode = S_IRUGO,
624 },
625 .show = aac_show_kernel_version,
626};
627static struct class_device_attribute aac_monitor_version = {
628 .attr = {
629 .name = "hba_monitor_version",
630 .mode = S_IRUGO,
631 },
632 .show = aac_show_monitor_version,
633};
634static struct class_device_attribute aac_bios_version = {
635 .attr = {
636 .name = "hba_bios_version",
637 .mode = S_IRUGO,
638 },
639 .show = aac_show_bios_version,
640};
641static struct class_device_attribute aac_serial_number = {
642 .attr = {
643 .name = "serial_number",
644 .mode = S_IRUGO,
645 },
646 .show = aac_show_serial_number,
647};
648
649static struct class_device_attribute *aac_attrs[] = {
650 &aac_model,
651 &aac_vendor,
652 &aac_kernel_version,
653 &aac_monitor_version,
654 &aac_bios_version,
655 &aac_serial_number,
656 NULL
657};
658
659
529static struct file_operations aac_cfg_fops = { 660static struct file_operations aac_cfg_fops = {
530 .owner = THIS_MODULE, 661 .owner = THIS_MODULE,
531 .ioctl = aac_cfg_ioctl, 662 .ioctl = aac_cfg_ioctl,
@@ -538,7 +669,7 @@ static struct file_operations aac_cfg_fops = {
538static struct scsi_host_template aac_driver_template = { 669static struct scsi_host_template aac_driver_template = {
539 .module = THIS_MODULE, 670 .module = THIS_MODULE,
540 .name = "AAC", 671 .name = "AAC",
541 .proc_name = "aacraid", 672 .proc_name = AAC_DRIVERNAME,
542 .info = aac_info, 673 .info = aac_info,
543 .ioctl = aac_ioctl, 674 .ioctl = aac_ioctl,
544#ifdef CONFIG_COMPAT 675#ifdef CONFIG_COMPAT
@@ -546,8 +677,8 @@ static struct scsi_host_template aac_driver_template = {
546#endif 677#endif
547 .queuecommand = aac_queuecommand, 678 .queuecommand = aac_queuecommand,
548 .bios_param = aac_biosparm, 679 .bios_param = aac_biosparm,
680 .shost_attrs = aac_attrs,
549 .slave_configure = aac_slave_configure, 681 .slave_configure = aac_slave_configure,
550 .eh_abort_handler = aac_eh_abort,
551 .eh_host_reset_handler = aac_eh_reset, 682 .eh_host_reset_handler = aac_eh_reset,
552 .can_queue = AAC_NUM_IO_FIB, 683 .can_queue = AAC_NUM_IO_FIB,
553 .this_id = 16, 684 .this_id = 16,
@@ -612,7 +743,7 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
612 aac->cardtype = index; 743 aac->cardtype = index;
613 INIT_LIST_HEAD(&aac->entry); 744 INIT_LIST_HEAD(&aac->entry);
614 745
615 aac->fibs = kmalloc(sizeof(struct fib) * AAC_NUM_FIB, GFP_KERNEL); 746 aac->fibs = kmalloc(sizeof(struct fib) * (shost->can_queue + AAC_NUM_MGT_FIB), GFP_KERNEL);
616 if (!aac->fibs) 747 if (!aac->fibs)
617 goto out_free_host; 748 goto out_free_host;
618 spin_lock_init(&aac->fib_lock); 749 spin_lock_init(&aac->fib_lock);
@@ -632,6 +763,24 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
632 aac_get_adapter_info(aac); 763 aac_get_adapter_info(aac);
633 764
634 /* 765 /*
766 * Lets override negotiations and drop the maximum SG limit to 34
767 */
768 if ((aac_drivers[index].quirks & AAC_QUIRK_34SG) &&
769 (aac->scsi_host_ptr->sg_tablesize > 34)) {
770 aac->scsi_host_ptr->sg_tablesize = 34;
771 aac->scsi_host_ptr->max_sectors
772 = (aac->scsi_host_ptr->sg_tablesize * 8) + 112;
773 }
774
775 /*
776 * Firware printf works only with older firmware.
777 */
778 if (aac_drivers[index].quirks & AAC_QUIRK_34SG)
779 aac->printf_enabled = 1;
780 else
781 aac->printf_enabled = 0;
782
783 /*
635 * max channel will be the physical channels plus 1 virtual channel 784 * max channel will be the physical channels plus 1 virtual channel
636 * all containers are on the virtual channel 0 785 * all containers are on the virtual channel 0
637 * physical channels are address by their actual physical number+1 786 * physical channels are address by their actual physical number+1
diff --git a/drivers/scsi/aacraid/rkt.c b/drivers/scsi/aacraid/rkt.c
index 1b8ed47cfe30..7d68b7825137 100644
--- a/drivers/scsi/aacraid/rkt.c
+++ b/drivers/scsi/aacraid/rkt.c
@@ -98,7 +98,9 @@ static irqreturn_t aac_rkt_intr(int irq, void *dev_id, struct pt_regs *regs)
98 * for its completion. 98 * for its completion.
99 */ 99 */
100 100
101static int rkt_sync_cmd(struct aac_dev *dev, u32 command, u32 p1, u32 *status) 101static int rkt_sync_cmd(struct aac_dev *dev, u32 command,
102 u32 p1, u32 p2, u32 p3, u32 p4, u32 p5, u32 p6,
103 u32 *status, u32 *r1, u32 *r2, u32 *r3, u32 *r4)
102{ 104{
103 unsigned long start; 105 unsigned long start;
104 int ok; 106 int ok;
@@ -107,12 +109,12 @@ static int rkt_sync_cmd(struct aac_dev *dev, u32 command, u32 p1, u32 *status)
107 */ 109 */
108 rkt_writel(dev, InboundMailbox0, command); 110 rkt_writel(dev, InboundMailbox0, command);
109 /* 111 /*
110 * Write the parameters into Mailboxes 1 - 4 112 * Write the parameters into Mailboxes 1 - 6
111 */ 113 */
112 rkt_writel(dev, InboundMailbox1, p1); 114 rkt_writel(dev, InboundMailbox1, p1);
113 rkt_writel(dev, InboundMailbox2, 0); 115 rkt_writel(dev, InboundMailbox2, p2);
114 rkt_writel(dev, InboundMailbox3, 0); 116 rkt_writel(dev, InboundMailbox3, p3);
115 rkt_writel(dev, InboundMailbox4, 0); 117 rkt_writel(dev, InboundMailbox4, p4);
116 /* 118 /*
117 * Clear the synch command doorbell to start on a clean slate. 119 * Clear the synch command doorbell to start on a clean slate.
118 */ 120 */
@@ -169,6 +171,14 @@ static int rkt_sync_cmd(struct aac_dev *dev, u32 command, u32 p1, u32 *status)
169 */ 171 */
170 if (status) 172 if (status)
171 *status = rkt_readl(dev, IndexRegs.Mailbox[0]); 173 *status = rkt_readl(dev, IndexRegs.Mailbox[0]);
174 if (r1)
175 *r1 = rkt_readl(dev, IndexRegs.Mailbox[1]);
176 if (r2)
177 *r2 = rkt_readl(dev, IndexRegs.Mailbox[2]);
178 if (r3)
179 *r3 = rkt_readl(dev, IndexRegs.Mailbox[3]);
180 if (r4)
181 *r4 = rkt_readl(dev, IndexRegs.Mailbox[4]);
172 /* 182 /*
173 * Clear the synch command doorbell. 183 * Clear the synch command doorbell.
174 */ 184 */
@@ -190,8 +200,8 @@ static int rkt_sync_cmd(struct aac_dev *dev, u32 command, u32 p1, u32 *status)
190 200
191static void aac_rkt_interrupt_adapter(struct aac_dev *dev) 201static void aac_rkt_interrupt_adapter(struct aac_dev *dev)
192{ 202{
193 u32 ret; 203 rkt_sync_cmd(dev, BREAKPOINT_REQUEST, 0, 0, 0, 0, 0, 0,
194 rkt_sync_cmd(dev, BREAKPOINT_REQUEST, 0, &ret); 204 NULL, NULL, NULL, NULL, NULL);
195} 205}
196 206
197/** 207/**
@@ -220,7 +230,8 @@ static void aac_rkt_notify_adapter(struct aac_dev *dev, u32 event)
220 rkt_writel(dev, MUnit.IDR,INBOUNDDOORBELL_3); 230 rkt_writel(dev, MUnit.IDR,INBOUNDDOORBELL_3);
221 break; 231 break;
222 case HostShutdown: 232 case HostShutdown:
223// rkt_sync_cmd(dev, HOST_CRASHING, 0, 0, 0, 0, &ret); 233// rkt_sync_cmd(dev, HOST_CRASHING, 0, 0, 0, 0, 0, 0,
234// NULL, NULL, NULL, NULL, NULL);
224 break; 235 break;
225 case FastIo: 236 case FastIo:
226 rkt_writel(dev, MUnit.IDR,INBOUNDDOORBELL_6); 237 rkt_writel(dev, MUnit.IDR,INBOUNDDOORBELL_6);
@@ -243,17 +254,11 @@ static void aac_rkt_notify_adapter(struct aac_dev *dev, u32 event)
243 254
244static void aac_rkt_start_adapter(struct aac_dev *dev) 255static void aac_rkt_start_adapter(struct aac_dev *dev)
245{ 256{
246 u32 status;
247 struct aac_init *init; 257 struct aac_init *init;
248 258
249 init = dev->init; 259 init = dev->init;
250 init->HostElapsedSeconds = cpu_to_le32(get_seconds()); 260 init->HostElapsedSeconds = cpu_to_le32(get_seconds());
251 /* 261 /*
252 * Tell the adapter we are back and up and running so it will scan
253 * its command queues and enable our interrupts
254 */
255 dev->irq_mask = (DoorBellPrintfReady | OUTBOUNDDOORBELL_1 | OUTBOUNDDOORBELL_2 | OUTBOUNDDOORBELL_3 | OUTBOUNDDOORBELL_4);
256 /*
257 * First clear out all interrupts. Then enable the one's that we 262 * First clear out all interrupts. Then enable the one's that we
258 * can handle. 263 * can handle.
259 */ 264 */
@@ -263,7 +268,8 @@ static void aac_rkt_start_adapter(struct aac_dev *dev)
263 rkt_writeb(dev, MUnit.OIMR, dev->OIMR = 0xfb); 268 rkt_writeb(dev, MUnit.OIMR, dev->OIMR = 0xfb);
264 269
265 // We can only use a 32 bit address here 270 // We can only use a 32 bit address here
266 rkt_sync_cmd(dev, INIT_STRUCT_BASE_ADDRESS, (u32)(ulong)dev->init_pa, &status); 271 rkt_sync_cmd(dev, INIT_STRUCT_BASE_ADDRESS, (u32)(ulong)dev->init_pa,
272 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL);
267} 273}
268 274
269/** 275/**
@@ -288,8 +294,8 @@ static int aac_rkt_check_health(struct aac_dev *dev)
288 if (status & KERNEL_PANIC) { 294 if (status & KERNEL_PANIC) {
289 char * buffer; 295 char * buffer;
290 struct POSTSTATUS { 296 struct POSTSTATUS {
291 u32 Post_Command; 297 __le32 Post_Command;
292 u32 Post_Address; 298 __le32 Post_Address;
293 } * post; 299 } * post;
294 dma_addr_t paddr, baddr; 300 dma_addr_t paddr, baddr;
295 int ret; 301 int ret;
@@ -310,7 +316,8 @@ static int aac_rkt_check_health(struct aac_dev *dev)
310 post->Post_Command = cpu_to_le32(COMMAND_POST_RESULTS); 316 post->Post_Command = cpu_to_le32(COMMAND_POST_RESULTS);
311 post->Post_Address = cpu_to_le32(baddr); 317 post->Post_Address = cpu_to_le32(baddr);
312 rkt_writel(dev, MUnit.IMRx[0], paddr); 318 rkt_writel(dev, MUnit.IMRx[0], paddr);
313 rkt_sync_cmd(dev, COMMAND_POST_RESULTS, baddr, &status); 319 rkt_sync_cmd(dev, COMMAND_POST_RESULTS, baddr, 0, 0, 0, 0, 0,
320 NULL, NULL, NULL, NULL, NULL);
314 pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS), 321 pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS),
315 post, paddr); 322 post, paddr);
316 if ((buffer[0] == '0') && (buffer[1] == 'x')) { 323 if ((buffer[0] == '0') && (buffer[1] == 'x')) {
diff --git a/drivers/scsi/aacraid/rx.c b/drivers/scsi/aacraid/rx.c
index 630b99e1fe83..1ff25f49fada 100644
--- a/drivers/scsi/aacraid/rx.c
+++ b/drivers/scsi/aacraid/rx.c
@@ -63,7 +63,7 @@ static irqreturn_t aac_rx_intr(int irq, void *dev_id, struct pt_regs *regs)
63 { 63 {
64 bellbits = rx_readl(dev, OutboundDoorbellReg); 64 bellbits = rx_readl(dev, OutboundDoorbellReg);
65 if (bellbits & DoorBellPrintfReady) { 65 if (bellbits & DoorBellPrintfReady) {
66 aac_printf(dev, le32_to_cpu(rx_readl (dev, IndexRegs.Mailbox[5]))); 66 aac_printf(dev, rx_readl(dev, IndexRegs.Mailbox[5]));
67 rx_writel(dev, MUnit.ODR,DoorBellPrintfReady); 67 rx_writel(dev, MUnit.ODR,DoorBellPrintfReady);
68 rx_writel(dev, InboundDoorbellReg,DoorBellPrintfDone); 68 rx_writel(dev, InboundDoorbellReg,DoorBellPrintfDone);
69 } 69 }
@@ -98,7 +98,9 @@ static irqreturn_t aac_rx_intr(int irq, void *dev_id, struct pt_regs *regs)
98 * for its completion. 98 * for its completion.
99 */ 99 */
100 100
101static int rx_sync_cmd(struct aac_dev *dev, u32 command, u32 p1, u32 *status) 101static int rx_sync_cmd(struct aac_dev *dev, u32 command,
102 u32 p1, u32 p2, u32 p3, u32 p4, u32 p5, u32 p6,
103 u32 *status, u32 * r1, u32 * r2, u32 * r3, u32 * r4)
102{ 104{
103 unsigned long start; 105 unsigned long start;
104 int ok; 106 int ok;
@@ -107,12 +109,12 @@ static int rx_sync_cmd(struct aac_dev *dev, u32 command, u32 p1, u32 *status)
107 */ 109 */
108 rx_writel(dev, InboundMailbox0, command); 110 rx_writel(dev, InboundMailbox0, command);
109 /* 111 /*
110 * Write the parameters into Mailboxes 1 - 4 112 * Write the parameters into Mailboxes 1 - 6
111 */ 113 */
112 rx_writel(dev, InboundMailbox1, p1); 114 rx_writel(dev, InboundMailbox1, p1);
113 rx_writel(dev, InboundMailbox2, 0); 115 rx_writel(dev, InboundMailbox2, p2);
114 rx_writel(dev, InboundMailbox3, 0); 116 rx_writel(dev, InboundMailbox3, p3);
115 rx_writel(dev, InboundMailbox4, 0); 117 rx_writel(dev, InboundMailbox4, p4);
116 /* 118 /*
117 * Clear the synch command doorbell to start on a clean slate. 119 * Clear the synch command doorbell to start on a clean slate.
118 */ 120 */
@@ -120,7 +122,7 @@ static int rx_sync_cmd(struct aac_dev *dev, u32 command, u32 p1, u32 *status)
120 /* 122 /*
121 * Disable doorbell interrupts 123 * Disable doorbell interrupts
122 */ 124 */
123 rx_writeb(dev, MUnit.OIMR, dev->OIMR |= 0x04); 125 rx_writeb(dev, MUnit.OIMR, dev->OIMR = 0xff);
124 /* 126 /*
125 * Force the completion of the mask register write before issuing 127 * Force the completion of the mask register write before issuing
126 * the interrupt. 128 * the interrupt.
@@ -169,6 +171,14 @@ static int rx_sync_cmd(struct aac_dev *dev, u32 command, u32 p1, u32 *status)
169 */ 171 */
170 if (status) 172 if (status)
171 *status = rx_readl(dev, IndexRegs.Mailbox[0]); 173 *status = rx_readl(dev, IndexRegs.Mailbox[0]);
174 if (r1)
175 *r1 = rx_readl(dev, IndexRegs.Mailbox[1]);
176 if (r2)
177 *r2 = rx_readl(dev, IndexRegs.Mailbox[2]);
178 if (r3)
179 *r3 = rx_readl(dev, IndexRegs.Mailbox[3]);
180 if (r4)
181 *r4 = rx_readl(dev, IndexRegs.Mailbox[4]);
172 /* 182 /*
173 * Clear the synch command doorbell. 183 * Clear the synch command doorbell.
174 */ 184 */
@@ -190,8 +200,7 @@ static int rx_sync_cmd(struct aac_dev *dev, u32 command, u32 p1, u32 *status)
190 200
191static void aac_rx_interrupt_adapter(struct aac_dev *dev) 201static void aac_rx_interrupt_adapter(struct aac_dev *dev)
192{ 202{
193 u32 ret; 203 rx_sync_cmd(dev, BREAKPOINT_REQUEST, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL);
194 rx_sync_cmd(dev, BREAKPOINT_REQUEST, 0, &ret);
195} 204}
196 205
197/** 206/**
@@ -220,7 +229,8 @@ static void aac_rx_notify_adapter(struct aac_dev *dev, u32 event)
220 rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_3); 229 rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_3);
221 break; 230 break;
222 case HostShutdown: 231 case HostShutdown:
223// rx_sync_cmd(dev, HOST_CRASHING, 0, 0, 0, 0, &ret); 232// rx_sync_cmd(dev, HOST_CRASHING, 0, 0, 0, 0, 0, 0,
233// NULL, NULL, NULL, NULL, NULL);
224 break; 234 break;
225 case FastIo: 235 case FastIo:
226 rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_6); 236 rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_6);
@@ -243,17 +253,11 @@ static void aac_rx_notify_adapter(struct aac_dev *dev, u32 event)
243 253
244static void aac_rx_start_adapter(struct aac_dev *dev) 254static void aac_rx_start_adapter(struct aac_dev *dev)
245{ 255{
246 u32 status;
247 struct aac_init *init; 256 struct aac_init *init;
248 257
249 init = dev->init; 258 init = dev->init;
250 init->HostElapsedSeconds = cpu_to_le32(get_seconds()); 259 init->HostElapsedSeconds = cpu_to_le32(get_seconds());
251 /* 260 /*
252 * Tell the adapter we are back and up and running so it will scan
253 * its command queues and enable our interrupts
254 */
255 dev->irq_mask = (DoorBellPrintfReady | OUTBOUNDDOORBELL_1 | OUTBOUNDDOORBELL_2 | OUTBOUNDDOORBELL_3 | OUTBOUNDDOORBELL_4);
256 /*
257 * First clear out all interrupts. Then enable the one's that we 261 * First clear out all interrupts. Then enable the one's that we
258 * can handle. 262 * can handle.
259 */ 263 */
@@ -263,7 +267,8 @@ static void aac_rx_start_adapter(struct aac_dev *dev)
263 rx_writeb(dev, MUnit.OIMR, dev->OIMR = 0xfb); 267 rx_writeb(dev, MUnit.OIMR, dev->OIMR = 0xfb);
264 268
265 // We can only use a 32 bit address here 269 // We can only use a 32 bit address here
266 rx_sync_cmd(dev, INIT_STRUCT_BASE_ADDRESS, (u32)(ulong)dev->init_pa, &status); 270 rx_sync_cmd(dev, INIT_STRUCT_BASE_ADDRESS, (u32)(ulong)dev->init_pa,
271 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL);
267} 272}
268 273
269/** 274/**
@@ -288,8 +293,8 @@ static int aac_rx_check_health(struct aac_dev *dev)
288 if (status & KERNEL_PANIC) { 293 if (status & KERNEL_PANIC) {
289 char * buffer; 294 char * buffer;
290 struct POSTSTATUS { 295 struct POSTSTATUS {
291 u32 Post_Command; 296 __le32 Post_Command;
292 u32 Post_Address; 297 __le32 Post_Address;
293 } * post; 298 } * post;
294 dma_addr_t paddr, baddr; 299 dma_addr_t paddr, baddr;
295 int ret; 300 int ret;
@@ -310,7 +315,8 @@ static int aac_rx_check_health(struct aac_dev *dev)
310 post->Post_Command = cpu_to_le32(COMMAND_POST_RESULTS); 315 post->Post_Command = cpu_to_le32(COMMAND_POST_RESULTS);
311 post->Post_Address = cpu_to_le32(baddr); 316 post->Post_Address = cpu_to_le32(baddr);
312 rx_writel(dev, MUnit.IMRx[0], paddr); 317 rx_writel(dev, MUnit.IMRx[0], paddr);
313 rx_sync_cmd(dev, COMMAND_POST_RESULTS, baddr, &status); 318 rx_sync_cmd(dev, COMMAND_POST_RESULTS, baddr, 0, 0, 0, 0, 0,
319 NULL, NULL, NULL, NULL, NULL);
314 pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS), 320 pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS),
315 post, paddr); 321 post, paddr);
316 if ((buffer[0] == '0') && (buffer[1] == 'x')) { 322 if ((buffer[0] == '0') && (buffer[1] == 'x')) {
diff --git a/drivers/scsi/aacraid/sa.c b/drivers/scsi/aacraid/sa.c
index bd6c30723fba..0680249ab861 100644
--- a/drivers/scsi/aacraid/sa.c
+++ b/drivers/scsi/aacraid/sa.c
@@ -89,7 +89,7 @@ static irqreturn_t aac_sa_intr(int irq, void *dev_id, struct pt_regs *regs)
89 * Notify the adapter of an event 89 * Notify the adapter of an event
90 */ 90 */
91 91
92void aac_sa_notify_adapter(struct aac_dev *dev, u32 event) 92static void aac_sa_notify_adapter(struct aac_dev *dev, u32 event)
93{ 93{
94 switch (event) { 94 switch (event) {
95 95
@@ -106,7 +106,10 @@ void aac_sa_notify_adapter(struct aac_dev *dev, u32 event)
106 sa_writew(dev, DoorbellReg_s,DOORBELL_3); 106 sa_writew(dev, DoorbellReg_s,DOORBELL_3);
107 break; 107 break;
108 case HostShutdown: 108 case HostShutdown:
109 //sa_sync_cmd(dev, HOST_CRASHING, 0, &ret); 109 /*
110 sa_sync_cmd(dev, HOST_CRASHING, 0, 0, 0, 0, 0, 0,
111 NULL, NULL, NULL, NULL, NULL);
112 */
110 break; 113 break;
111 case FastIo: 114 case FastIo:
112 sa_writew(dev, DoorbellReg_s,DOORBELL_6); 115 sa_writew(dev, DoorbellReg_s,DOORBELL_6);
@@ -132,7 +135,9 @@ void aac_sa_notify_adapter(struct aac_dev *dev, u32 event)
132 * for its completion. 135 * for its completion.
133 */ 136 */
134 137
135static int sa_sync_cmd(struct aac_dev *dev, u32 command, u32 p1, u32 *ret) 138static int sa_sync_cmd(struct aac_dev *dev, u32 command,
139 u32 p1, u32 p2, u32 p3, u32 p4, u32 p5, u32 p6,
140 u32 *ret, u32 *r1, u32 *r2, u32 *r3, u32 *r4)
136{ 141{
137 unsigned long start; 142 unsigned long start;
138 int ok; 143 int ok;
@@ -144,9 +149,10 @@ static int sa_sync_cmd(struct aac_dev *dev, u32 command, u32 p1, u32 *ret)
144 * Write the parameters into Mailboxes 1 - 4 149 * Write the parameters into Mailboxes 1 - 4
145 */ 150 */
146 sa_writel(dev, Mailbox1, p1); 151 sa_writel(dev, Mailbox1, p1);
147 sa_writel(dev, Mailbox2, 0); 152 sa_writel(dev, Mailbox2, p2);
148 sa_writel(dev, Mailbox3, 0); 153 sa_writel(dev, Mailbox3, p3);
149 sa_writel(dev, Mailbox4, 0); 154 sa_writel(dev, Mailbox4, p4);
155
150 /* 156 /*
151 * Clear the synch command doorbell to start on a clean slate. 157 * Clear the synch command doorbell to start on a clean slate.
152 */ 158 */
@@ -188,6 +194,14 @@ static int sa_sync_cmd(struct aac_dev *dev, u32 command, u32 p1, u32 *ret)
188 */ 194 */
189 if (ret) 195 if (ret)
190 *ret = sa_readl(dev, Mailbox0); 196 *ret = sa_readl(dev, Mailbox0);
197 if (r1)
198 *r1 = sa_readl(dev, Mailbox1);
199 if (r2)
200 *r2 = sa_readl(dev, Mailbox2);
201 if (r3)
202 *r3 = sa_readl(dev, Mailbox3);
203 if (r4)
204 *r4 = sa_readl(dev, Mailbox4);
191 return 0; 205 return 0;
192} 206}
193 207
@@ -201,7 +215,8 @@ static int sa_sync_cmd(struct aac_dev *dev, u32 command, u32 p1, u32 *ret)
201static void aac_sa_interrupt_adapter (struct aac_dev *dev) 215static void aac_sa_interrupt_adapter (struct aac_dev *dev)
202{ 216{
203 u32 ret; 217 u32 ret;
204 sa_sync_cmd(dev, BREAKPOINT_REQUEST, 0, &ret); 218 sa_sync_cmd(dev, BREAKPOINT_REQUEST, 0, 0, 0, 0, 0, 0,
219 &ret, NULL, NULL, NULL, NULL);
205} 220}
206 221
207/** 222/**
@@ -230,10 +245,12 @@ static void aac_sa_start_adapter(struct aac_dev *dev)
230 * First clear out all interrupts. Then enable the one's that 245 * First clear out all interrupts. Then enable the one's that
231 * we can handle. 246 * we can handle.
232 */ 247 */
233 sa_writew(dev, SaDbCSR.PRISETIRQMASK, cpu_to_le16(0xffff)); 248 sa_writew(dev, SaDbCSR.PRISETIRQMASK, 0xffff);
234 sa_writew(dev, SaDbCSR.PRICLEARIRQMASK, (PrintfReady | DOORBELL_1 | DOORBELL_2 | DOORBELL_3 | DOORBELL_4)); 249 sa_writew(dev, SaDbCSR.PRICLEARIRQMASK, (PrintfReady | DOORBELL_1 | DOORBELL_2 | DOORBELL_3 | DOORBELL_4));
235 /* We can only use a 32 bit address here */ 250 /* We can only use a 32 bit address here */
236 sa_sync_cmd(dev, INIT_STRUCT_BASE_ADDRESS, (u32)(ulong)dev->init_pa, &ret); 251 sa_sync_cmd(dev, INIT_STRUCT_BASE_ADDRESS,
252 (u32)(ulong)dev->init_pa, 0, 0, 0, 0, 0,
253 &ret, NULL, NULL, NULL, NULL);
237} 254}
238 255
239/** 256/**