aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/arcmsr/arcmsr_hba.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/arcmsr/arcmsr_hba.c')
-rw-r--r--drivers/scsi/arcmsr/arcmsr_hba.c114
1 files changed, 41 insertions, 73 deletions
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index 1cadcd6b7da6..984bd527c6c9 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -2,7 +2,7 @@
2******************************************************************************* 2*******************************************************************************
3** O.S : Linux 3** O.S : Linux
4** FILE NAME : arcmsr_hba.c 4** FILE NAME : arcmsr_hba.c
5** BY : Erich Chen 5** BY : Nick Cheng
6** Description: SCSI RAID Device Driver for 6** Description: SCSI RAID Device Driver for
7** ARECA RAID Host adapter 7** ARECA RAID Host adapter
8******************************************************************************* 8*******************************************************************************
@@ -76,7 +76,7 @@ MODULE_DESCRIPTION("ARECA (ARC11xx/12xx/16xx/1880) SATA/SAS RAID Host Bus Adapte
76MODULE_LICENSE("Dual BSD/GPL"); 76MODULE_LICENSE("Dual BSD/GPL");
77MODULE_VERSION(ARCMSR_DRIVER_VERSION); 77MODULE_VERSION(ARCMSR_DRIVER_VERSION);
78static int sleeptime = 10; 78static int sleeptime = 10;
79static int retrycount = 30; 79static int retrycount = 12;
80wait_queue_head_t wait_q; 80wait_queue_head_t wait_q;
81static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, 81static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb,
82 struct scsi_cmnd *cmd); 82 struct scsi_cmnd *cmd);
@@ -187,7 +187,6 @@ int arcmsr_sleep_for_bus_reset(struct scsi_cmnd *cmd)
187 if (isleep > 0) { 187 if (isleep > 0) {
188 msleep(isleep*1000); 188 msleep(isleep*1000);
189 } 189 }
190 printk(KERN_NOTICE "wake-up\n");
191 return 0; 190 return 0;
192} 191}
193 192
@@ -921,7 +920,6 @@ static void arcmsr_report_ccb_state(struct AdapterControlBlock *acb,
921} 920}
922 921
923static void arcmsr_drain_donequeue(struct AdapterControlBlock *acb, struct CommandControlBlock *pCCB, bool error) 922static void arcmsr_drain_donequeue(struct AdapterControlBlock *acb, struct CommandControlBlock *pCCB, bool error)
924
925{ 923{
926 int id, lun; 924 int id, lun;
927 if ((pCCB->acb != acb) || (pCCB->startdone != ARCMSR_CCB_START)) { 925 if ((pCCB->acb != acb) || (pCCB->startdone != ARCMSR_CCB_START)) {
@@ -948,7 +946,7 @@ static void arcmsr_drain_donequeue(struct AdapterControlBlock *acb, struct Comma
948 , pCCB->startdone 946 , pCCB->startdone
949 , atomic_read(&acb->ccboutstandingcount)); 947 , atomic_read(&acb->ccboutstandingcount));
950 return; 948 return;
951 } 949 }
952 arcmsr_report_ccb_state(acb, pCCB, error); 950 arcmsr_report_ccb_state(acb, pCCB, error);
953} 951}
954 952
@@ -981,7 +979,7 @@ static void arcmsr_done4abort_postqueue(struct AdapterControlBlock *acb)
981 case ACB_ADAPTER_TYPE_B: { 979 case ACB_ADAPTER_TYPE_B: {
982 struct MessageUnit_B *reg = acb->pmuB; 980 struct MessageUnit_B *reg = acb->pmuB;
983 /*clear all outbound posted Q*/ 981 /*clear all outbound posted Q*/
984 writel(ARCMSR_DOORBELL_INT_CLEAR_PATTERN, &reg->iop2drv_doorbell); /* clear doorbell interrupt */ 982 writel(ARCMSR_DOORBELL_INT_CLEAR_PATTERN, reg->iop2drv_doorbell); /* clear doorbell interrupt */
985 for (i = 0; i < ARCMSR_MAX_HBB_POSTQUEUE; i++) { 983 for (i = 0; i < ARCMSR_MAX_HBB_POSTQUEUE; i++) {
986 if ((flag_ccb = readl(&reg->done_qbuffer[i])) != 0) { 984 if ((flag_ccb = readl(&reg->done_qbuffer[i])) != 0) {
987 writel(0, &reg->done_qbuffer[i]); 985 writel(0, &reg->done_qbuffer[i]);
@@ -1511,7 +1509,6 @@ static void arcmsr_hba_postqueue_isr(struct AdapterControlBlock *acb)
1511 arcmsr_drain_donequeue(acb, pCCB, error); 1509 arcmsr_drain_donequeue(acb, pCCB, error);
1512 } 1510 }
1513} 1511}
1514
1515static void arcmsr_hbb_postqueue_isr(struct AdapterControlBlock *acb) 1512static void arcmsr_hbb_postqueue_isr(struct AdapterControlBlock *acb)
1516{ 1513{
1517 uint32_t index; 1514 uint32_t index;
@@ -2106,10 +2103,6 @@ static int arcmsr_queue_command_lck(struct scsi_cmnd *cmd,
2106 if (atomic_read(&acb->ccboutstandingcount) >= 2103 if (atomic_read(&acb->ccboutstandingcount) >=
2107 ARCMSR_MAX_OUTSTANDING_CMD) 2104 ARCMSR_MAX_OUTSTANDING_CMD)
2108 return SCSI_MLQUEUE_HOST_BUSY; 2105 return SCSI_MLQUEUE_HOST_BUSY;
2109 if ((scsicmd == SCSI_CMD_ARECA_SPECIFIC)) {
2110 printk(KERN_NOTICE "Receiveing SCSI_CMD_ARECA_SPECIFIC command..\n");
2111 return 0;
2112 }
2113 ccb = arcmsr_get_freeccb(acb); 2106 ccb = arcmsr_get_freeccb(acb);
2114 if (!ccb) 2107 if (!ccb)
2115 return SCSI_MLQUEUE_HOST_BUSY; 2108 return SCSI_MLQUEUE_HOST_BUSY;
@@ -2393,6 +2386,7 @@ static int arcmsr_polling_hbb_ccbdone(struct AdapterControlBlock *acb,
2393 int index, rtn; 2386 int index, rtn;
2394 bool error; 2387 bool error;
2395 polling_hbb_ccb_retry: 2388 polling_hbb_ccb_retry:
2389
2396 poll_count++; 2390 poll_count++;
2397 /* clear doorbell interrupt */ 2391 /* clear doorbell interrupt */
2398 writel(ARCMSR_DOORBELL_INT_CLEAR_PATTERN, reg->iop2drv_doorbell); 2392 writel(ARCMSR_DOORBELL_INT_CLEAR_PATTERN, reg->iop2drv_doorbell);
@@ -2663,6 +2657,7 @@ static void arcmsr_request_hba_device_map(struct AdapterControlBlock *acb)
2663{ 2657{
2664 struct MessageUnit_A __iomem *reg = acb->pmuA; 2658 struct MessageUnit_A __iomem *reg = acb->pmuA;
2665 if (unlikely(atomic_read(&acb->rq_map_token) == 0) || ((acb->acb_flags & ACB_F_BUS_RESET) != 0 ) || ((acb->acb_flags & ACB_F_ABORT) != 0 )){ 2659 if (unlikely(atomic_read(&acb->rq_map_token) == 0) || ((acb->acb_flags & ACB_F_BUS_RESET) != 0 ) || ((acb->acb_flags & ACB_F_ABORT) != 0 )){
2660 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ));
2666 return; 2661 return;
2667 } else { 2662 } else {
2668 acb->fw_flag = FW_NORMAL; 2663 acb->fw_flag = FW_NORMAL;
@@ -2670,8 +2665,10 @@ static void arcmsr_request_hba_device_map(struct AdapterControlBlock *acb)
2670 atomic_set(&acb->rq_map_token, 16); 2665 atomic_set(&acb->rq_map_token, 16);
2671 } 2666 }
2672 atomic_set(&acb->ante_token_value, atomic_read(&acb->rq_map_token)); 2667 atomic_set(&acb->ante_token_value, atomic_read(&acb->rq_map_token));
2673 if (atomic_dec_and_test(&acb->rq_map_token)) 2668 if (atomic_dec_and_test(&acb->rq_map_token)) {
2669 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ));
2674 return; 2670 return;
2671 }
2675 writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, &reg->inbound_msgaddr0); 2672 writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, &reg->inbound_msgaddr0);
2676 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ)); 2673 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ));
2677 } 2674 }
@@ -2682,15 +2679,18 @@ static void arcmsr_request_hbb_device_map(struct AdapterControlBlock *acb)
2682{ 2679{
2683 struct MessageUnit_B __iomem *reg = acb->pmuB; 2680 struct MessageUnit_B __iomem *reg = acb->pmuB;
2684 if (unlikely(atomic_read(&acb->rq_map_token) == 0) || ((acb->acb_flags & ACB_F_BUS_RESET) != 0 ) || ((acb->acb_flags & ACB_F_ABORT) != 0 )){ 2681 if (unlikely(atomic_read(&acb->rq_map_token) == 0) || ((acb->acb_flags & ACB_F_BUS_RESET) != 0 ) || ((acb->acb_flags & ACB_F_ABORT) != 0 )){
2682 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ));
2685 return; 2683 return;
2686 } else { 2684 } else {
2687 acb->fw_flag = FW_NORMAL; 2685 acb->fw_flag = FW_NORMAL;
2688 if (atomic_read(&acb->ante_token_value) == atomic_read(&acb->rq_map_token)) { 2686 if (atomic_read(&acb->ante_token_value) == atomic_read(&acb->rq_map_token)) {
2689 atomic_set(&acb->rq_map_token,16); 2687 atomic_set(&acb->rq_map_token, 16);
2690 } 2688 }
2691 atomic_set(&acb->ante_token_value, atomic_read(&acb->rq_map_token)); 2689 atomic_set(&acb->ante_token_value, atomic_read(&acb->rq_map_token));
2692 if(atomic_dec_and_test(&acb->rq_map_token)) 2690 if (atomic_dec_and_test(&acb->rq_map_token)) {
2691 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ));
2693 return; 2692 return;
2693 }
2694 writel(ARCMSR_MESSAGE_GET_CONFIG, reg->drv2iop_doorbell); 2694 writel(ARCMSR_MESSAGE_GET_CONFIG, reg->drv2iop_doorbell);
2695 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ)); 2695 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ));
2696 } 2696 }
@@ -2701,6 +2701,7 @@ static void arcmsr_request_hbc_device_map(struct AdapterControlBlock *acb)
2701{ 2701{
2702 struct MessageUnit_C __iomem *reg = acb->pmuC; 2702 struct MessageUnit_C __iomem *reg = acb->pmuC;
2703 if (unlikely(atomic_read(&acb->rq_map_token) == 0) || ((acb->acb_flags & ACB_F_BUS_RESET) != 0) || ((acb->acb_flags & ACB_F_ABORT) != 0)) { 2703 if (unlikely(atomic_read(&acb->rq_map_token) == 0) || ((acb->acb_flags & ACB_F_BUS_RESET) != 0) || ((acb->acb_flags & ACB_F_ABORT) != 0)) {
2704 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ));
2704 return; 2705 return;
2705 } else { 2706 } else {
2706 acb->fw_flag = FW_NORMAL; 2707 acb->fw_flag = FW_NORMAL;
@@ -2708,8 +2709,10 @@ static void arcmsr_request_hbc_device_map(struct AdapterControlBlock *acb)
2708 atomic_set(&acb->rq_map_token, 16); 2709 atomic_set(&acb->rq_map_token, 16);
2709 } 2710 }
2710 atomic_set(&acb->ante_token_value, atomic_read(&acb->rq_map_token)); 2711 atomic_set(&acb->ante_token_value, atomic_read(&acb->rq_map_token));
2711 if (atomic_dec_and_test(&acb->rq_map_token)) 2712 if (atomic_dec_and_test(&acb->rq_map_token)) {
2713 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ));
2712 return; 2714 return;
2715 }
2713 writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, &reg->inbound_msgaddr0); 2716 writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, &reg->inbound_msgaddr0);
2714 writel(ARCMSR_HBCMU_DRV2IOP_MESSAGE_CMD_DONE, &reg->inbound_doorbell); 2717 writel(ARCMSR_HBCMU_DRV2IOP_MESSAGE_CMD_DONE, &reg->inbound_doorbell);
2715 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ)); 2718 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ));
@@ -2897,6 +2900,8 @@ static uint8_t arcmsr_iop_reset(struct AdapterControlBlock *acb)
2897 uint32_t intmask_org; 2900 uint32_t intmask_org;
2898 uint8_t rtnval = 0x00; 2901 uint8_t rtnval = 0x00;
2899 int i = 0; 2902 int i = 0;
2903 unsigned long flags;
2904
2900 if (atomic_read(&acb->ccboutstandingcount) != 0) { 2905 if (atomic_read(&acb->ccboutstandingcount) != 0) {
2901 /* disable all outbound interrupt */ 2906 /* disable all outbound interrupt */
2902 intmask_org = arcmsr_disable_outbound_ints(acb); 2907 intmask_org = arcmsr_disable_outbound_ints(acb);
@@ -2907,7 +2912,12 @@ static uint8_t arcmsr_iop_reset(struct AdapterControlBlock *acb)
2907 for (i = 0; i < ARCMSR_MAX_FREECCB_NUM; i++) { 2912 for (i = 0; i < ARCMSR_MAX_FREECCB_NUM; i++) {
2908 ccb = acb->pccb_pool[i]; 2913 ccb = acb->pccb_pool[i];
2909 if (ccb->startdone == ARCMSR_CCB_START) { 2914 if (ccb->startdone == ARCMSR_CCB_START) {
2910 arcmsr_ccb_complete(ccb); 2915 scsi_dma_unmap(ccb->pcmd);
2916 ccb->startdone = ARCMSR_CCB_DONE;
2917 ccb->ccb_flags = 0;
2918 spin_lock_irqsave(&acb->ccblist_lock, flags);
2919 list_add_tail(&ccb->list, &acb->ccb_free_list);
2920 spin_unlock_irqrestore(&acb->ccblist_lock, flags);
2911 } 2921 }
2912 } 2922 }
2913 atomic_set(&acb->ccboutstandingcount, 0); 2923 atomic_set(&acb->ccboutstandingcount, 0);
@@ -2920,8 +2930,7 @@ static uint8_t arcmsr_iop_reset(struct AdapterControlBlock *acb)
2920 2930
2921static int arcmsr_bus_reset(struct scsi_cmnd *cmd) 2931static int arcmsr_bus_reset(struct scsi_cmnd *cmd)
2922{ 2932{
2923 struct AdapterControlBlock *acb = 2933 struct AdapterControlBlock *acb;
2924 (struct AdapterControlBlock *)cmd->device->host->hostdata;
2925 uint32_t intmask_org, outbound_doorbell; 2934 uint32_t intmask_org, outbound_doorbell;
2926 int retry_count = 0; 2935 int retry_count = 0;
2927 int rtn = FAILED; 2936 int rtn = FAILED;
@@ -2971,31 +2980,16 @@ sleep_again:
2971 atomic_set(&acb->rq_map_token, 16); 2980 atomic_set(&acb->rq_map_token, 16);
2972 atomic_set(&acb->ante_token_value, 16); 2981 atomic_set(&acb->ante_token_value, 16);
2973 acb->fw_flag = FW_NORMAL; 2982 acb->fw_flag = FW_NORMAL;
2974 init_timer(&acb->eternal_timer); 2983 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ));
2975 acb->eternal_timer.expires = jiffies + msecs_to_jiffies(6*HZ);
2976 acb->eternal_timer.data = (unsigned long) acb;
2977 acb->eternal_timer.function = &arcmsr_request_device_map;
2978 add_timer(&acb->eternal_timer);
2979 acb->acb_flags &= ~ACB_F_BUS_RESET; 2984 acb->acb_flags &= ~ACB_F_BUS_RESET;
2980 rtn = SUCCESS; 2985 rtn = SUCCESS;
2981 printk(KERN_ERR "arcmsr: scsi bus reset eh returns with success\n"); 2986 printk(KERN_ERR "arcmsr: scsi bus reset eh returns with success\n");
2982 } else { 2987 } else {
2983 acb->acb_flags &= ~ACB_F_BUS_RESET; 2988 acb->acb_flags &= ~ACB_F_BUS_RESET;
2984 if (atomic_read(&acb->rq_map_token) == 0) { 2989 atomic_set(&acb->rq_map_token, 16);
2985 atomic_set(&acb->rq_map_token, 16); 2990 atomic_set(&acb->ante_token_value, 16);
2986 atomic_set(&acb->ante_token_value, 16); 2991 acb->fw_flag = FW_NORMAL;
2987 acb->fw_flag = FW_NORMAL; 2992 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6*HZ));
2988 init_timer(&acb->eternal_timer);
2989 acb->eternal_timer.expires = jiffies + msecs_to_jiffies(6*HZ);
2990 acb->eternal_timer.data = (unsigned long) acb;
2991 acb->eternal_timer.function = &arcmsr_request_device_map;
2992 add_timer(&acb->eternal_timer);
2993 } else {
2994 atomic_set(&acb->rq_map_token, 16);
2995 atomic_set(&acb->ante_token_value, 16);
2996 acb->fw_flag = FW_NORMAL;
2997 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6*HZ));
2998 }
2999 rtn = SUCCESS; 2993 rtn = SUCCESS;
3000 } 2994 }
3001 break; 2995 break;
@@ -3007,21 +3001,10 @@ sleep_again:
3007 rtn = FAILED; 3001 rtn = FAILED;
3008 } else { 3002 } else {
3009 acb->acb_flags &= ~ACB_F_BUS_RESET; 3003 acb->acb_flags &= ~ACB_F_BUS_RESET;
3010 if (atomic_read(&acb->rq_map_token) == 0) { 3004 atomic_set(&acb->rq_map_token, 16);
3011 atomic_set(&acb->rq_map_token, 16); 3005 atomic_set(&acb->ante_token_value, 16);
3012 atomic_set(&acb->ante_token_value, 16); 3006 acb->fw_flag = FW_NORMAL;
3013 acb->fw_flag = FW_NORMAL; 3007 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ));
3014 init_timer(&acb->eternal_timer);
3015 acb->eternal_timer.expires = jiffies + msecs_to_jiffies(6*HZ);
3016 acb->eternal_timer.data = (unsigned long) acb;
3017 acb->eternal_timer.function = &arcmsr_request_device_map;
3018 add_timer(&acb->eternal_timer);
3019 } else {
3020 atomic_set(&acb->rq_map_token, 16);
3021 atomic_set(&acb->ante_token_value, 16);
3022 acb->fw_flag = FW_NORMAL;
3023 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6*HZ));
3024 }
3025 rtn = SUCCESS; 3008 rtn = SUCCESS;
3026 } 3009 }
3027 break; 3010 break;
@@ -3067,31 +3050,16 @@ sleep:
3067 atomic_set(&acb->rq_map_token, 16); 3050 atomic_set(&acb->rq_map_token, 16);
3068 atomic_set(&acb->ante_token_value, 16); 3051 atomic_set(&acb->ante_token_value, 16);
3069 acb->fw_flag = FW_NORMAL; 3052 acb->fw_flag = FW_NORMAL;
3070 init_timer(&acb->eternal_timer); 3053 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ));
3071 acb->eternal_timer.expires = jiffies + msecs_to_jiffies(6 * HZ);
3072 acb->eternal_timer.data = (unsigned long) acb;
3073 acb->eternal_timer.function = &arcmsr_request_device_map;
3074 add_timer(&acb->eternal_timer);
3075 acb->acb_flags &= ~ACB_F_BUS_RESET; 3054 acb->acb_flags &= ~ACB_F_BUS_RESET;
3076 rtn = SUCCESS; 3055 rtn = SUCCESS;
3077 printk(KERN_ERR "arcmsr: scsi bus reset eh returns with success\n"); 3056 printk(KERN_ERR "arcmsr: scsi bus reset eh returns with success\n");
3078 } else { 3057 } else {
3079 acb->acb_flags &= ~ACB_F_BUS_RESET; 3058 acb->acb_flags &= ~ACB_F_BUS_RESET;
3080 if (atomic_read(&acb->rq_map_token) == 0) { 3059 atomic_set(&acb->rq_map_token, 16);
3081 atomic_set(&acb->rq_map_token, 16); 3060 atomic_set(&acb->ante_token_value, 16);
3082 atomic_set(&acb->ante_token_value, 16); 3061 acb->fw_flag = FW_NORMAL;
3083 acb->fw_flag = FW_NORMAL; 3062 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6*HZ));
3084 init_timer(&acb->eternal_timer);
3085 acb->eternal_timer.expires = jiffies + msecs_to_jiffies(6*HZ);
3086 acb->eternal_timer.data = (unsigned long) acb;
3087 acb->eternal_timer.function = &arcmsr_request_device_map;
3088 add_timer(&acb->eternal_timer);
3089 } else {
3090 atomic_set(&acb->rq_map_token, 16);
3091 atomic_set(&acb->ante_token_value, 16);
3092 acb->fw_flag = FW_NORMAL;
3093 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6*HZ));
3094 }
3095 rtn = SUCCESS; 3063 rtn = SUCCESS;
3096 } 3064 }
3097 break; 3065 break;