aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/dpt_i2o.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/dpt_i2o.c')
-rw-r--r--drivers/scsi/dpt_i2o.c65
1 files changed, 29 insertions, 36 deletions
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 53c9b93013f1..9cc0015b717d 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -113,7 +113,6 @@ static struct i2o_sys_tbl *sys_tbl = NULL;
113static int sys_tbl_ind = 0; 113static int sys_tbl_ind = 0;
114static int sys_tbl_len = 0; 114static int sys_tbl_len = 0;
115 115
116static adpt_hba* hbas[DPTI_MAX_HBA];
117static adpt_hba* hba_chain = NULL; 116static adpt_hba* hba_chain = NULL;
118static int hba_count = 0; 117static int hba_count = 0;
119 118
@@ -691,7 +690,7 @@ static int adpt_device_reset(struct scsi_cmnd* cmd)
691 u32 msg[4]; 690 u32 msg[4];
692 u32 rcode; 691 u32 rcode;
693 int old_state; 692 int old_state;
694 struct adpt_device* d = (void*) cmd->device->hostdata; 693 struct adpt_device* d = cmd->device->hostdata;
695 694
696 pHba = (void*) cmd->device->host->hostdata[0]; 695 pHba = (void*) cmd->device->host->hostdata[0];
697 printk(KERN_INFO"%s: Trying to reset device\n",pHba->name); 696 printk(KERN_INFO"%s: Trying to reset device\n",pHba->name);
@@ -707,7 +706,7 @@ static int adpt_device_reset(struct scsi_cmnd* cmd)
707 706
708 old_state = d->state; 707 old_state = d->state;
709 d->state |= DPTI_DEV_RESET; 708 d->state |= DPTI_DEV_RESET;
710 if( (rcode = adpt_i2o_post_wait(pHba, (void*)msg,sizeof(msg), FOREVER)) ){ 709 if( (rcode = adpt_i2o_post_wait(pHba, msg,sizeof(msg), FOREVER)) ){
711 d->state = old_state; 710 d->state = old_state;
712 if(rcode == -EOPNOTSUPP ){ 711 if(rcode == -EOPNOTSUPP ){
713 printk(KERN_INFO"%s: Device reset not supported\n",pHba->name); 712 printk(KERN_INFO"%s: Device reset not supported\n",pHba->name);
@@ -737,7 +736,7 @@ static int adpt_bus_reset(struct scsi_cmnd* cmd)
737 msg[1] = (I2O_HBA_BUS_RESET<<24|HOST_TID<<12|pHba->channel[cmd->device->channel].tid); 736 msg[1] = (I2O_HBA_BUS_RESET<<24|HOST_TID<<12|pHba->channel[cmd->device->channel].tid);
738 msg[2] = 0; 737 msg[2] = 0;
739 msg[3] = 0; 738 msg[3] = 0;
740 if(adpt_i2o_post_wait(pHba, (void*)msg,sizeof(msg), FOREVER) ){ 739 if(adpt_i2o_post_wait(pHba, msg,sizeof(msg), FOREVER) ){
741 printk(KERN_WARNING"%s: Bus reset failed.\n",pHba->name); 740 printk(KERN_WARNING"%s: Bus reset failed.\n",pHba->name);
742 return FAILED; 741 return FAILED;
743 } else { 742 } else {
@@ -747,7 +746,7 @@ static int adpt_bus_reset(struct scsi_cmnd* cmd)
747} 746}
748 747
749// This version of reset is called by the eh_error_handler 748// This version of reset is called by the eh_error_handler
750static int adpt_reset(struct scsi_cmnd* cmd) 749static int __adpt_reset(struct scsi_cmnd* cmd)
751{ 750{
752 adpt_hba* pHba; 751 adpt_hba* pHba;
753 int rcode; 752 int rcode;
@@ -763,6 +762,17 @@ static int adpt_reset(struct scsi_cmnd* cmd)
763 } 762 }
764} 763}
765 764
765static int adpt_reset(struct scsi_cmnd* cmd)
766{
767 int rc;
768
769 spin_lock_irq(cmd->device->host->host_lock);
770 rc = __adpt_reset(cmd);
771 spin_unlock_irq(cmd->device->host->host_lock);
772
773 return rc;
774}
775
766// This version of reset is called by the ioctls and indirectly from eh_error_handler via adpt_reset 776// This version of reset is called by the ioctls and indirectly from eh_error_handler via adpt_reset
767static int adpt_hba_reset(adpt_hba* pHba) 777static int adpt_hba_reset(adpt_hba* pHba)
768{ 778{
@@ -875,7 +885,6 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev
875 void __iomem *msg_addr_virt = NULL; 885 void __iomem *msg_addr_virt = NULL;
876 886
877 int raptorFlag = FALSE; 887 int raptorFlag = FALSE;
878 int i;
879 888
880 if(pci_enable_device(pDev)) { 889 if(pci_enable_device(pDev)) {
881 return -EINVAL; 890 return -EINVAL;
@@ -935,12 +944,6 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev
935 memset(pHba, 0, sizeof(adpt_hba)); 944 memset(pHba, 0, sizeof(adpt_hba));
936 945
937 down(&adpt_configuration_lock); 946 down(&adpt_configuration_lock);
938 for(i=0;i<DPTI_MAX_HBA;i++) {
939 if(hbas[i]==NULL) {
940 hbas[i]=pHba;
941 break;
942 }
943 }
944 947
945 if(hba_chain != NULL){ 948 if(hba_chain != NULL){
946 for(p = hba_chain; p->next; p = p->next); 949 for(p = hba_chain; p->next; p = p->next);
@@ -950,7 +953,7 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev
950 } 953 }
951 pHba->next = NULL; 954 pHba->next = NULL;
952 pHba->unit = hba_count; 955 pHba->unit = hba_count;
953 sprintf(pHba->name, "dpti%d", i); 956 sprintf(pHba->name, "dpti%d", hba_count);
954 hba_count++; 957 hba_count++;
955 958
956 up(&adpt_configuration_lock); 959 up(&adpt_configuration_lock);
@@ -1015,11 +1018,6 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba)
1015 if(pHba->host){ 1018 if(pHba->host){
1016 free_irq(pHba->host->irq, pHba); 1019 free_irq(pHba->host->irq, pHba);
1017 } 1020 }
1018 for(i=0;i<DPTI_MAX_HBA;i++) {
1019 if(hbas[i]==pHba) {
1020 hbas[i] = NULL;
1021 }
1022 }
1023 p2 = NULL; 1021 p2 = NULL;
1024 for( p1 = hba_chain; p1; p2 = p1,p1=p1->next){ 1022 for( p1 = hba_chain; p1; p2 = p1,p1=p1->next){
1025 if(p1 == pHba) { 1023 if(p1 == pHba) {
@@ -1076,12 +1074,7 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba)
1076 1074
1077static int adpt_init(void) 1075static int adpt_init(void)
1078{ 1076{
1079 int i;
1080
1081 printk("Loading Adaptec I2O RAID: Version " DPT_I2O_VERSION "\n"); 1077 printk("Loading Adaptec I2O RAID: Version " DPT_I2O_VERSION "\n");
1082 for (i = 0; i < DPTI_MAX_HBA; i++) {
1083 hbas[i] = NULL;
1084 }
1085#ifdef REBOOT_NOTIFIER 1078#ifdef REBOOT_NOTIFIER
1086 register_reboot_notifier(&adpt_reboot_notifier); 1079 register_reboot_notifier(&adpt_reboot_notifier);
1087#endif 1080#endif
@@ -1454,7 +1447,7 @@ static int adpt_i2o_parse_lct(adpt_hba* pHba)
1454 return -ENOMEM; 1447 return -ENOMEM;
1455 } 1448 }
1456 1449
1457 d->controller = (void*)pHba; 1450 d->controller = pHba;
1458 d->next = NULL; 1451 d->next = NULL;
1459 1452
1460 memcpy(&d->lct_data, &lct->lct_entry[i], sizeof(i2o_lct_entry)); 1453 memcpy(&d->lct_data, &lct->lct_entry[i], sizeof(i2o_lct_entry));
@@ -2000,7 +1993,7 @@ static irqreturn_t adpt_isr(int irq, void *dev_id, struct pt_regs *regs)
2000 struct scsi_cmnd* cmd; 1993 struct scsi_cmnd* cmd;
2001 adpt_hba* pHba = dev_id; 1994 adpt_hba* pHba = dev_id;
2002 u32 m; 1995 u32 m;
2003 ulong reply; 1996 void __iomem *reply;
2004 u32 status=0; 1997 u32 status=0;
2005 u32 context; 1998 u32 context;
2006 ulong flags = 0; 1999 ulong flags = 0;
@@ -2025,11 +2018,11 @@ static irqreturn_t adpt_isr(int irq, void *dev_id, struct pt_regs *regs)
2025 goto out; 2018 goto out;
2026 } 2019 }
2027 } 2020 }
2028 reply = (ulong)bus_to_virt(m); 2021 reply = bus_to_virt(m);
2029 2022
2030 if (readl(reply) & MSG_FAIL) { 2023 if (readl(reply) & MSG_FAIL) {
2031 u32 old_m = readl(reply+28); 2024 u32 old_m = readl(reply+28);
2032 ulong msg; 2025 void __iomem *msg;
2033 u32 old_context; 2026 u32 old_context;
2034 PDEBUG("%s: Failed message\n",pHba->name); 2027 PDEBUG("%s: Failed message\n",pHba->name);
2035 if(old_m >= 0x100000){ 2028 if(old_m >= 0x100000){
@@ -2038,16 +2031,16 @@ static irqreturn_t adpt_isr(int irq, void *dev_id, struct pt_regs *regs)
2038 continue; 2031 continue;
2039 } 2032 }
2040 // Transaction context is 0 in failed reply frame 2033 // Transaction context is 0 in failed reply frame
2041 msg = (ulong)(pHba->msg_addr_virt + old_m); 2034 msg = pHba->msg_addr_virt + old_m;
2042 old_context = readl(msg+12); 2035 old_context = readl(msg+12);
2043 writel(old_context, reply+12); 2036 writel(old_context, reply+12);
2044 adpt_send_nop(pHba, old_m); 2037 adpt_send_nop(pHba, old_m);
2045 } 2038 }
2046 context = readl(reply+8); 2039 context = readl(reply+8);
2047 if(context & 0x40000000){ // IOCTL 2040 if(context & 0x40000000){ // IOCTL
2048 ulong p = (ulong)(readl(reply+12)); 2041 void *p = (void *)readl(reply+12);
2049 if( p != 0) { 2042 if( p != NULL) {
2050 memcpy((void*)p, (void*)reply, REPLY_FRAME_SIZE * 4); 2043 memcpy_fromio(p, reply, REPLY_FRAME_SIZE * 4);
2051 } 2044 }
2052 // All IOCTLs will also be post wait 2045 // All IOCTLs will also be post wait
2053 } 2046 }
@@ -2231,7 +2224,7 @@ static s32 adpt_scsi_register(adpt_hba* pHba,struct scsi_host_template * sht)
2231} 2224}
2232 2225
2233 2226
2234static s32 adpt_i2o_to_scsi(ulong reply, struct scsi_cmnd* cmd) 2227static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd)
2235{ 2228{
2236 adpt_hba* pHba; 2229 adpt_hba* pHba;
2237 u32 hba_status; 2230 u32 hba_status;
@@ -2323,7 +2316,7 @@ static s32 adpt_i2o_to_scsi(ulong reply, struct scsi_cmnd* cmd)
2323 u32 len = sizeof(cmd->sense_buffer); 2316 u32 len = sizeof(cmd->sense_buffer);
2324 len = (len > 40) ? 40 : len; 2317 len = (len > 40) ? 40 : len;
2325 // Copy over the sense data 2318 // Copy over the sense data
2326 memcpy(cmd->sense_buffer, (void*)(reply+28) , len); 2319 memcpy_fromio(cmd->sense_buffer, (reply+28) , len);
2327 if(cmd->sense_buffer[0] == 0x70 /* class 7 */ && 2320 if(cmd->sense_buffer[0] == 0x70 /* class 7 */ &&
2328 cmd->sense_buffer[2] == DATA_PROTECT ){ 2321 cmd->sense_buffer[2] == DATA_PROTECT ){
2329 /* This is to handle an array failed */ 2322 /* This is to handle an array failed */
@@ -2438,7 +2431,7 @@ static s32 adpt_i2o_reparse_lct(adpt_hba* pHba)
2438 return -ENOMEM; 2431 return -ENOMEM;
2439 } 2432 }
2440 2433
2441 d->controller = (void*)pHba; 2434 d->controller = pHba;
2442 d->next = NULL; 2435 d->next = NULL;
2443 2436
2444 memcpy(&d->lct_data, &lct->lct_entry[i], sizeof(i2o_lct_entry)); 2437 memcpy(&d->lct_data, &lct->lct_entry[i], sizeof(i2o_lct_entry));
@@ -2985,8 +2978,8 @@ static int adpt_i2o_build_sys_table(void)
2985 sys_tbl->iops[count].frame_size = pHba->status_block->inbound_frame_size; 2978 sys_tbl->iops[count].frame_size = pHba->status_block->inbound_frame_size;
2986 sys_tbl->iops[count].last_changed = sys_tbl_ind - 1; // ?? 2979 sys_tbl->iops[count].last_changed = sys_tbl_ind - 1; // ??
2987 sys_tbl->iops[count].iop_capabilities = pHba->status_block->iop_capabilities; 2980 sys_tbl->iops[count].iop_capabilities = pHba->status_block->iop_capabilities;
2988 sys_tbl->iops[count].inbound_low = (u32)virt_to_bus((void*)pHba->post_port); 2981 sys_tbl->iops[count].inbound_low = (u32)virt_to_bus(pHba->post_port);
2989 sys_tbl->iops[count].inbound_high = (u32)((u64)virt_to_bus((void*)pHba->post_port)>>32); 2982 sys_tbl->iops[count].inbound_high = (u32)((u64)virt_to_bus(pHba->post_port)>>32);
2990 2983
2991 count++; 2984 count++;
2992 } 2985 }