diff options
Diffstat (limited to 'drivers/scsi/isci/host.c')
-rw-r--r-- | drivers/scsi/isci/host.c | 88 |
1 files changed, 32 insertions, 56 deletions
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c index 343655bd1a6a..3c7042b8bc0e 100644 --- a/drivers/scsi/isci/host.c +++ b/drivers/scsi/isci/host.c | |||
@@ -284,23 +284,16 @@ static void scic_sds_controller_task_completion(struct scic_sds_controller *scic | |||
284 | u32 completion_entry) | 284 | u32 completion_entry) |
285 | { | 285 | { |
286 | u32 index; | 286 | u32 index; |
287 | struct scic_sds_request *io_request; | 287 | struct scic_sds_request *sci_req; |
288 | 288 | ||
289 | index = SCU_GET_COMPLETION_INDEX(completion_entry); | 289 | index = SCU_GET_COMPLETION_INDEX(completion_entry); |
290 | io_request = scic->io_request_table[index]; | 290 | sci_req = scic->io_request_table[index]; |
291 | 291 | ||
292 | /* Make sure that we really want to process this IO request */ | 292 | /* Make sure that we really want to process this IO request */ |
293 | if ( | 293 | if (sci_req && sci_req->io_tag != SCI_CONTROLLER_INVALID_IO_TAG && |
294 | (io_request != NULL) | 294 | ISCI_TAG_SEQ(sci_req->io_tag) == scic->io_request_sequence[index]) |
295 | && (io_request->io_tag != SCI_CONTROLLER_INVALID_IO_TAG) | ||
296 | && ( | ||
297 | scic_sds_io_tag_get_sequence(io_request->io_tag) | ||
298 | == scic->io_request_sequence[index] | ||
299 | ) | ||
300 | ) { | ||
301 | /* Yep this is a valid io request pass it along to the io request handler */ | 295 | /* Yep this is a valid io request pass it along to the io request handler */ |
302 | scic_sds_io_request_tc_completion(io_request, completion_entry); | 296 | scic_sds_io_request_tc_completion(sci_req, completion_entry); |
303 | } | ||
304 | } | 297 | } |
305 | 298 | ||
306 | static void scic_sds_controller_sdma_completion(struct scic_sds_controller *scic, | 299 | static void scic_sds_controller_sdma_completion(struct scic_sds_controller *scic, |
@@ -2682,37 +2675,28 @@ void scic_sds_controller_copy_task_context( | |||
2682 | sci_req->task_context_buffer = task_context_buffer; | 2675 | sci_req->task_context_buffer = task_context_buffer; |
2683 | } | 2676 | } |
2684 | 2677 | ||
2685 | /** | 2678 | struct scu_task_context *scic_sds_controller_get_task_context_buffer(struct scic_sds_controller *scic, |
2686 | * This method returns the task context buffer for the given io tag. | 2679 | u16 io_tag) |
2687 | * @scic: | 2680 | { |
2688 | * @io_tag: | 2681 | u16 tci = ISCI_TAG_TCI(io_tag); |
2689 | * | ||
2690 | * struct scu_task_context* | ||
2691 | */ | ||
2692 | struct scu_task_context *scic_sds_controller_get_task_context_buffer( | ||
2693 | struct scic_sds_controller *scic, | ||
2694 | u16 io_tag | ||
2695 | ) { | ||
2696 | u16 task_index = scic_sds_io_tag_get_index(io_tag); | ||
2697 | 2682 | ||
2698 | if (task_index < scic->task_context_entries) { | 2683 | if (tci < scic->task_context_entries) { |
2699 | return &scic->task_context_table[task_index]; | 2684 | return &scic->task_context_table[tci]; |
2700 | } | 2685 | } |
2701 | 2686 | ||
2702 | return NULL; | 2687 | return NULL; |
2703 | } | 2688 | } |
2704 | 2689 | ||
2705 | struct scic_sds_request *scic_request_by_tag(struct scic_sds_controller *scic, | 2690 | struct scic_sds_request *scic_request_by_tag(struct scic_sds_controller *scic, u16 io_tag) |
2706 | u16 io_tag) | ||
2707 | { | 2691 | { |
2708 | u16 task_index; | 2692 | u16 task_index; |
2709 | u16 task_sequence; | 2693 | u16 task_sequence; |
2710 | 2694 | ||
2711 | task_index = scic_sds_io_tag_get_index(io_tag); | 2695 | task_index = ISCI_TAG_TCI(io_tag); |
2712 | 2696 | ||
2713 | if (task_index < scic->task_context_entries) { | 2697 | if (task_index < scic->task_context_entries) { |
2714 | if (scic->io_request_table[task_index] != NULL) { | 2698 | if (scic->io_request_table[task_index] != NULL) { |
2715 | task_sequence = scic_sds_io_tag_get_sequence(io_tag); | 2699 | task_sequence = ISCI_TAG_SEQ(io_tag); |
2716 | 2700 | ||
2717 | if (task_sequence == scic->io_request_sequence[task_index]) { | 2701 | if (task_sequence == scic->io_request_sequence[task_index]) { |
2718 | return scic->io_request_table[task_index]; | 2702 | return scic->io_request_table[task_index]; |
@@ -2875,11 +2859,10 @@ void scic_sds_controller_release_frame( | |||
2875 | * successfully started the IO request. SCI_SUCCESS if the IO request was | 2859 | * successfully started the IO request. SCI_SUCCESS if the IO request was |
2876 | * successfully started. Determine the failure situations and return values. | 2860 | * successfully started. Determine the failure situations and return values. |
2877 | */ | 2861 | */ |
2878 | enum sci_status scic_controller_start_io( | 2862 | enum sci_status scic_controller_start_io(struct scic_sds_controller *scic, |
2879 | struct scic_sds_controller *scic, | 2863 | struct scic_sds_remote_device *rdev, |
2880 | struct scic_sds_remote_device *rdev, | 2864 | struct scic_sds_request *req, |
2881 | struct scic_sds_request *req, | 2865 | u16 io_tag) |
2882 | u16 io_tag) | ||
2883 | { | 2866 | { |
2884 | enum sci_status status; | 2867 | enum sci_status status; |
2885 | 2868 | ||
@@ -2892,7 +2875,7 @@ enum sci_status scic_controller_start_io( | |||
2892 | if (status != SCI_SUCCESS) | 2875 | if (status != SCI_SUCCESS) |
2893 | return status; | 2876 | return status; |
2894 | 2877 | ||
2895 | scic->io_request_table[scic_sds_io_tag_get_index(req->io_tag)] = req; | 2878 | scic->io_request_table[ISCI_TAG_TCI(req->io_tag)] = req; |
2896 | scic_sds_controller_post_request(scic, scic_sds_request_get_post_context(req)); | 2879 | scic_sds_controller_post_request(scic, scic_sds_request_get_post_context(req)); |
2897 | return SCI_SUCCESS; | 2880 | return SCI_SUCCESS; |
2898 | } | 2881 | } |
@@ -2979,7 +2962,7 @@ enum sci_status scic_controller_complete_io( | |||
2979 | if (status != SCI_SUCCESS) | 2962 | if (status != SCI_SUCCESS) |
2980 | return status; | 2963 | return status; |
2981 | 2964 | ||
2982 | index = scic_sds_io_tag_get_index(request->io_tag); | 2965 | index = ISCI_TAG_TCI(request->io_tag); |
2983 | scic->io_request_table[index] = NULL; | 2966 | scic->io_request_table[index] = NULL; |
2984 | return SCI_SUCCESS; | 2967 | return SCI_SUCCESS; |
2985 | default: | 2968 | default: |
@@ -2998,7 +2981,7 @@ enum sci_status scic_controller_continue_io(struct scic_sds_request *sci_req) | |||
2998 | return SCI_FAILURE_INVALID_STATE; | 2981 | return SCI_FAILURE_INVALID_STATE; |
2999 | } | 2982 | } |
3000 | 2983 | ||
3001 | scic->io_request_table[scic_sds_io_tag_get_index(sci_req->io_tag)] = sci_req; | 2984 | scic->io_request_table[ISCI_TAG_TCI(sci_req->io_tag)] = sci_req; |
3002 | scic_sds_controller_post_request(scic, scic_sds_request_get_post_context(sci_req)); | 2985 | scic_sds_controller_post_request(scic, scic_sds_request_get_post_context(sci_req)); |
3003 | return SCI_SUCCESS; | 2986 | return SCI_SUCCESS; |
3004 | } | 2987 | } |
@@ -3050,7 +3033,7 @@ enum sci_task_status scic_controller_start_task( | |||
3050 | status = scic_sds_remote_device_start_task(scic, rdev, req); | 3033 | status = scic_sds_remote_device_start_task(scic, rdev, req); |
3051 | switch (status) { | 3034 | switch (status) { |
3052 | case SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS: | 3035 | case SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS: |
3053 | scic->io_request_table[scic_sds_io_tag_get_index(req->io_tag)] = req; | 3036 | scic->io_request_table[ISCI_TAG_TCI(req->io_tag)] = req; |
3054 | 3037 | ||
3055 | /* | 3038 | /* |
3056 | * We will let framework know this task request started successfully, | 3039 | * We will let framework know this task request started successfully, |
@@ -3059,7 +3042,7 @@ enum sci_task_status scic_controller_start_task( | |||
3059 | */ | 3042 | */ |
3060 | return SCI_SUCCESS; | 3043 | return SCI_SUCCESS; |
3061 | case SCI_SUCCESS: | 3044 | case SCI_SUCCESS: |
3062 | scic->io_request_table[scic_sds_io_tag_get_index(req->io_tag)] = req; | 3045 | scic->io_request_table[ISCI_TAG_TCI(req->io_tag)] = req; |
3063 | 3046 | ||
3064 | scic_sds_controller_post_request(scic, | 3047 | scic_sds_controller_post_request(scic, |
3065 | scic_sds_request_get_post_context(req)); | 3048 | scic_sds_request_get_post_context(req)); |
@@ -3096,14 +3079,12 @@ enum sci_task_status scic_controller_start_task( | |||
3096 | u16 scic_controller_allocate_io_tag(struct scic_sds_controller *scic) | 3079 | u16 scic_controller_allocate_io_tag(struct scic_sds_controller *scic) |
3097 | { | 3080 | { |
3098 | struct isci_host *ihost = scic_to_ihost(scic); | 3081 | struct isci_host *ihost = scic_to_ihost(scic); |
3099 | u16 tci; | ||
3100 | u16 seq; | ||
3101 | 3082 | ||
3102 | if (isci_tci_space(ihost)) { | 3083 | if (isci_tci_space(ihost)) { |
3103 | tci = isci_tci_alloc(ihost); | 3084 | u16 tci = isci_tci_alloc(ihost); |
3104 | seq = scic->io_request_sequence[tci]; | 3085 | u8 seq = scic->io_request_sequence[tci]; |
3105 | 3086 | ||
3106 | return scic_sds_io_tag_construct(seq, tci); | 3087 | return ISCI_TAG(seq, tci); |
3107 | } | 3088 | } |
3108 | 3089 | ||
3109 | return SCI_CONTROLLER_INVALID_IO_TAG; | 3090 | return SCI_CONTROLLER_INVALID_IO_TAG; |
@@ -3138,22 +3119,17 @@ enum sci_status scic_controller_free_io_tag(struct scic_sds_controller *scic, | |||
3138 | u16 io_tag) | 3119 | u16 io_tag) |
3139 | { | 3120 | { |
3140 | struct isci_host *ihost = scic_to_ihost(scic); | 3121 | struct isci_host *ihost = scic_to_ihost(scic); |
3141 | u16 sequence; | 3122 | u16 tci = ISCI_TAG_TCI(io_tag); |
3142 | u16 index; | 3123 | u16 seq = ISCI_TAG_SEQ(io_tag); |
3143 | |||
3144 | BUG_ON(io_tag == SCI_CONTROLLER_INVALID_IO_TAG); | ||
3145 | |||
3146 | sequence = scic_sds_io_tag_get_sequence(io_tag); | ||
3147 | index = scic_sds_io_tag_get_index(io_tag); | ||
3148 | 3124 | ||
3149 | /* prevent tail from passing head */ | 3125 | /* prevent tail from passing head */ |
3150 | if (isci_tci_active(ihost) == 0) | 3126 | if (isci_tci_active(ihost) == 0) |
3151 | return SCI_FAILURE_INVALID_IO_TAG; | 3127 | return SCI_FAILURE_INVALID_IO_TAG; |
3152 | 3128 | ||
3153 | if (sequence == scic->io_request_sequence[index]) { | 3129 | if (seq == scic->io_request_sequence[tci]) { |
3154 | scic_sds_io_sequence_increment(scic->io_request_sequence[index]); | 3130 | scic->io_request_sequence[tci] = (seq+1) & (SCI_MAX_SEQ-1); |
3155 | 3131 | ||
3156 | isci_tci_free(ihost, index); | 3132 | isci_tci_free(ihost, ISCI_TAG_TCI(io_tag)); |
3157 | 3133 | ||
3158 | return SCI_SUCCESS; | 3134 | return SCI_SUCCESS; |
3159 | } | 3135 | } |