Lines Matching full:a

16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
39 * You should have received a copy of the GNU General Public License
48 static void esas2r_disc_abort(struct esas2r_adapter *a,
50 static bool esas2r_disc_continue(struct esas2r_adapter *a,
52 static void esas2r_disc_fix_curr_requests(struct esas2r_adapter *a);
54 static bool esas2r_disc_start_request(struct esas2r_adapter *a,
58 static bool esas2r_disc_block_dev_scan(struct esas2r_adapter *a,
60 static void esas2r_disc_block_dev_scan_cb(struct esas2r_adapter *a,
62 static bool esas2r_disc_dev_add(struct esas2r_adapter *a,
64 static bool esas2r_disc_dev_remove(struct esas2r_adapter *a,
66 static bool esas2r_disc_part_info(struct esas2r_adapter *a,
68 static void esas2r_disc_part_info_cb(struct esas2r_adapter *a,
70 static bool esas2r_disc_passthru_dev_info(struct esas2r_adapter *a,
72 static void esas2r_disc_passthru_dev_info_cb(struct esas2r_adapter *a,
74 static bool esas2r_disc_passthru_dev_addr(struct esas2r_adapter *a,
76 static void esas2r_disc_passthru_dev_addr_cb(struct esas2r_adapter *a,
78 static bool esas2r_disc_raid_grp_info(struct esas2r_adapter *a,
80 static void esas2r_disc_raid_grp_info_cb(struct esas2r_adapter *a,
83 void esas2r_disc_initialize(struct esas2r_adapter *a) in esas2r_disc_initialize() argument
85 struct esas2r_sas_nvram *nvr = a->nvram; in esas2r_disc_initialize()
89 clear_bit(AF_DISC_IN_PROG, &a->flags); in esas2r_disc_initialize()
90 clear_bit(AF2_DEV_SCAN, &a->flags2); in esas2r_disc_initialize()
91 clear_bit(AF2_DEV_CNT_OK, &a->flags2); in esas2r_disc_initialize()
93 a->disc_start_time = jiffies_to_msecs(jiffies); in esas2r_disc_initialize()
94 a->disc_wait_time = nvr->dev_wait_time * 1000; in esas2r_disc_initialize()
95 a->disc_wait_cnt = nvr->dev_wait_count; in esas2r_disc_initialize()
97 if (a->disc_wait_cnt > ESAS2R_MAX_TARGETS) in esas2r_disc_initialize()
98 a->disc_wait_cnt = ESAS2R_MAX_TARGETS; in esas2r_disc_initialize()
108 a->general_req.interrupt_cx = NULL; in esas2r_disc_initialize()
110 if (test_bit(AF_CHPRST_DETECTED, &a->flags) || in esas2r_disc_initialize()
111 test_bit(AF_POWER_MGT, &a->flags)) { in esas2r_disc_initialize()
112 if (a->prev_dev_cnt == 0) { in esas2r_disc_initialize()
116 a->disc_wait_time = 0; in esas2r_disc_initialize()
121 * a time because we know the exact count to wait for. in esas2r_disc_initialize()
125 a->disc_wait_cnt = a->prev_dev_cnt; in esas2r_disc_initialize()
132 if (a->disc_wait_time < 15000) in esas2r_disc_initialize()
133 a->disc_wait_time = 15000; in esas2r_disc_initialize()
137 esas2r_trace("disc wait count: %d", a->disc_wait_cnt); in esas2r_disc_initialize()
138 esas2r_trace("disc wait time: %d", a->disc_wait_time); in esas2r_disc_initialize()
140 if (a->disc_wait_time == 0) in esas2r_disc_initialize()
141 esas2r_disc_check_complete(a); in esas2r_disc_initialize()
146 void esas2r_disc_start_waiting(struct esas2r_adapter *a) in esas2r_disc_start_waiting() argument
150 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_start_waiting()
152 if (a->disc_ctx.disc_evt) in esas2r_disc_start_waiting()
153 esas2r_disc_start_port(a); in esas2r_disc_start_waiting()
155 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_start_waiting()
158 void esas2r_disc_check_for_work(struct esas2r_adapter *a) in esas2r_disc_check_for_work() argument
160 struct esas2r_request *rq = &a->general_req; in esas2r_disc_check_for_work()
164 esas2r_polled_interrupt(a); in esas2r_disc_check_for_work()
167 * now, interrupt processing may have queued up a discovery event. go in esas2r_disc_check_for_work()
169 * polled discovery would cause a deadlock. in esas2r_disc_check_for_work()
172 esas2r_disc_start_waiting(a); in esas2r_disc_check_for_work()
180 esas2r_wait_request(a, rq); in esas2r_disc_check_for_work()
183 esas2r_disc_abort(a, rq); in esas2r_disc_check_for_work()
184 esas2r_local_reset_adapter(a); in esas2r_disc_check_for_work()
193 esas2r_disc_continue(a, rq); in esas2r_disc_check_for_work()
196 void esas2r_disc_check_complete(struct esas2r_adapter *a) in esas2r_disc_check_complete() argument
203 if (a->disc_wait_time) { in esas2r_disc_check_complete()
205 u32 time = currtime - a->disc_start_time; in esas2r_disc_check_complete()
211 if (time < a->disc_wait_time in esas2r_disc_check_complete()
212 && (esas2r_targ_db_get_tgt_cnt(a) < a->disc_wait_cnt in esas2r_disc_check_complete()
213 || a->disc_wait_cnt == 0)) { in esas2r_disc_check_complete()
214 /* After three seconds of waiting, schedule a scan. */ in esas2r_disc_check_complete()
216 && !test_and_set_bit(AF2_DEV_SCAN, &a->flags2)) { in esas2r_disc_check_complete()
217 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_check_complete()
218 esas2r_disc_queue_event(a, DCDE_DEV_SCAN); in esas2r_disc_check_complete()
219 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_check_complete()
230 if (!test_and_set_bit(AF2_DEV_CNT_OK, &a->flags2)) in esas2r_disc_check_complete()
231 a->disc_wait_time = time + 3000; in esas2r_disc_check_complete()
233 /* If we haven't done a full scan yet, do it now. */ in esas2r_disc_check_complete()
234 if (!test_and_set_bit(AF2_DEV_SCAN, &a->flags2)) { in esas2r_disc_check_complete()
235 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_check_complete()
236 esas2r_disc_queue_event(a, DCDE_DEV_SCAN); in esas2r_disc_check_complete()
237 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_check_complete()
246 if (time < a->disc_wait_time) { in esas2r_disc_check_complete()
251 if (!test_and_set_bit(AF2_DEV_SCAN, &a->flags2)) { in esas2r_disc_check_complete()
252 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_check_complete()
253 esas2r_disc_queue_event(a, DCDE_DEV_SCAN); in esas2r_disc_check_complete()
254 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_check_complete()
259 a->disc_wait_time = 0; in esas2r_disc_check_complete()
261 if (test_bit(AF_DISC_POLLED, &a->flags) && in esas2r_disc_check_complete()
262 test_bit(AF_DISC_IN_PROG, &a->flags)) { in esas2r_disc_check_complete()
275 esas2r_disc_fix_curr_requests(a); in esas2r_disc_check_complete()
276 clear_bit(AF_DISC_PENDING, &a->flags); in esas2r_disc_check_complete()
283 set_bit(AF_PORT_CHANGE, &a->flags); in esas2r_disc_check_complete()
289 void esas2r_disc_queue_event(struct esas2r_adapter *a, u8 disc_evt) in esas2r_disc_queue_event() argument
291 struct esas2r_disc_context *dc = &a->disc_ctx; in esas2r_disc_queue_event()
302 * we would have a deadlock if we are in the ISR already. in esas2r_disc_queue_event()
304 if (!test_bit(AF_CHPRST_PENDING, &a->flags) && in esas2r_disc_queue_event()
305 !test_bit(AF_DISC_POLLED, &a->flags)) in esas2r_disc_queue_event()
306 esas2r_disc_start_port(a); in esas2r_disc_queue_event()
311 bool esas2r_disc_start_port(struct esas2r_adapter *a) in esas2r_disc_start_port() argument
313 struct esas2r_request *rq = &a->general_req; in esas2r_disc_start_port()
314 struct esas2r_disc_context *dc = &a->disc_ctx; in esas2r_disc_start_port()
319 if (test_bit(AF_DISC_IN_PROG, &a->flags)) { in esas2r_disc_start_port()
325 /* If there is a discovery waiting, process it. */ in esas2r_disc_start_port()
327 if (test_bit(AF_DISC_POLLED, &a->flags) in esas2r_disc_start_port()
328 && a->disc_wait_time == 0) { in esas2r_disc_start_port()
344 set_bit(AF_PORT_CHANGE, &a->flags); in esas2r_disc_start_port()
353 set_bit(AF_DISC_IN_PROG, &a->flags); in esas2r_disc_start_port()
356 if (test_bit(AF_DISC_POLLED, &a->flags)) in esas2r_disc_start_port()
376 if (!test_bit(AF_DISC_POLLED, &a->flags)) in esas2r_disc_start_port()
377 ret = esas2r_disc_continue(a, rq); in esas2r_disc_start_port()
386 static bool esas2r_disc_continue(struct esas2r_adapter *a, in esas2r_disc_continue() argument
400 rslt = esas2r_disc_dev_remove(a, rq); in esas2r_disc_continue()
405 rslt = esas2r_disc_dev_add(a, rq); in esas2r_disc_continue()
410 rslt = esas2r_disc_block_dev_scan(a, rq); in esas2r_disc_continue()
415 rslt = esas2r_disc_raid_grp_info(a, rq); in esas2r_disc_continue()
420 rslt = esas2r_disc_part_info(a, rq); in esas2r_disc_continue()
425 rslt = esas2r_disc_passthru_dev_info(a, rq); in esas2r_disc_continue()
429 rslt = esas2r_disc_passthru_dev_addr(a, rq); in esas2r_disc_continue()
450 if (!test_bit(AF_DISC_PENDING, &a->flags)) in esas2r_disc_continue()
451 esas2r_disc_fix_curr_requests(a); in esas2r_disc_continue()
453 clear_bit(AF_DISC_IN_PROG, &a->flags); in esas2r_disc_continue()
456 return esas2r_disc_start_port(a); in esas2r_disc_continue()
459 static bool esas2r_disc_start_request(struct esas2r_adapter *a, in esas2r_disc_start_request() argument
464 /* Set the timeout to a minimum value. */ in esas2r_disc_start_request()
475 spin_lock_irqsave(&a->queue_lock, flags); in esas2r_disc_start_request()
477 if (!test_bit(AF_CHPRST_PENDING, &a->flags) && in esas2r_disc_start_request()
478 !test_bit(AF_FLASHING, &a->flags)) in esas2r_disc_start_request()
479 esas2r_disc_local_start_request(a, rq); in esas2r_disc_start_request()
481 list_add_tail(&rq->req_list, &a->defer_list); in esas2r_disc_start_request()
483 spin_unlock_irqrestore(&a->queue_lock, flags); in esas2r_disc_start_request()
488 void esas2r_disc_local_start_request(struct esas2r_adapter *a, in esas2r_disc_local_start_request() argument
493 list_add_tail(&rq->req_list, &a->active_list); in esas2r_disc_local_start_request()
495 esas2r_start_vda_request(a, rq); in esas2r_disc_local_start_request()
502 static void esas2r_disc_abort(struct esas2r_adapter *a, in esas2r_disc_abort() argument
517 static bool esas2r_disc_block_dev_scan(struct esas2r_adapter *a, in esas2r_disc_block_dev_scan() argument
526 esas2r_rq_init_request(rq, a); in esas2r_disc_block_dev_scan()
528 esas2r_build_mgt_req(a, in esas2r_disc_block_dev_scan()
541 rslt = esas2r_disc_start_request(a, rq); in esas2r_disc_block_dev_scan()
548 static void esas2r_disc_block_dev_scan_cb(struct esas2r_adapter *a, in esas2r_disc_block_dev_scan_cb() argument
557 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_block_dev_scan_cb()
565 esas2r_rq_destroy_request(rq, a); in esas2r_disc_block_dev_scan_cb()
570 esas2r_disc_continue(a, rq); in esas2r_disc_block_dev_scan_cb()
572 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_block_dev_scan_cb()
577 static bool esas2r_disc_raid_grp_info(struct esas2r_adapter *a, in esas2r_disc_raid_grp_info() argument
597 esas2r_rq_init_request(rq, a); in esas2r_disc_raid_grp_info()
603 esas2r_build_mgt_req(a, in esas2r_disc_raid_grp_info()
617 rslt = esas2r_disc_start_request(a, rq); in esas2r_disc_raid_grp_info()
624 static void esas2r_disc_raid_grp_info_cb(struct esas2r_adapter *a, in esas2r_disc_raid_grp_info_cb() argument
634 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_raid_grp_info_cb()
664 "A request for RAID group info failed - " in esas2r_disc_raid_grp_info_cb()
675 esas2r_rq_destroy_request(rq, a); in esas2r_disc_raid_grp_info_cb()
680 esas2r_disc_continue(a, rq); in esas2r_disc_raid_grp_info_cb()
682 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_raid_grp_info_cb()
687 static bool esas2r_disc_part_info(struct esas2r_adapter *a, in esas2r_disc_part_info() argument
708 esas2r_rq_init_request(rq, a); in esas2r_disc_part_info()
714 esas2r_build_mgt_req(a, in esas2r_disc_part_info()
732 rslt = esas2r_disc_start_request(a, rq); in esas2r_disc_part_info()
739 static void esas2r_disc_part_info_cb(struct esas2r_adapter *a, in esas2r_disc_part_info_cb() argument
749 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_part_info_cb()
762 esas2r_targ_db_add_raid(a, dc); in esas2r_disc_part_info_cb()
768 "A request for RAID group partition info " in esas2r_disc_part_info_cb()
776 esas2r_rq_destroy_request(rq, a); in esas2r_disc_part_info_cb()
781 esas2r_disc_continue(a, rq); in esas2r_disc_part_info_cb()
783 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_part_info_cb()
788 static bool esas2r_disc_passthru_dev_info(struct esas2r_adapter *a, in esas2r_disc_passthru_dev_info() argument
800 esas2r_rq_init_request(rq, a); in esas2r_disc_passthru_dev_info()
806 esas2r_build_mgt_req(a, in esas2r_disc_passthru_dev_info()
818 rslt = esas2r_disc_start_request(a, rq); in esas2r_disc_passthru_dev_info()
825 static void esas2r_disc_passthru_dev_info_cb(struct esas2r_adapter *a, in esas2r_disc_passthru_dev_info_cb() argument
835 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_passthru_dev_info_cb()
862 "A request for device information failed - " in esas2r_disc_passthru_dev_info_cb()
869 esas2r_rq_destroy_request(rq, a); in esas2r_disc_passthru_dev_info_cb()
874 esas2r_disc_continue(a, rq); in esas2r_disc_passthru_dev_info_cb()
876 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_passthru_dev_info_cb()
881 static bool esas2r_disc_passthru_dev_addr(struct esas2r_adapter *a, in esas2r_disc_passthru_dev_addr() argument
892 esas2r_rq_init_request(rq, a); in esas2r_disc_passthru_dev_addr()
901 esas2r_sgc_init(&sgc, a, rq, rq->vrq->ioctl.sge); in esas2r_disc_passthru_dev_addr()
903 esas2r_build_ioctl_req(a, rq, sgc.length, VDA_IOCTL_HBA); in esas2r_disc_passthru_dev_addr()
905 if (!esas2r_build_sg_list(a, rq, &sgc)) { in esas2r_disc_passthru_dev_addr()
906 esas2r_rq_destroy_request(rq, a); in esas2r_disc_passthru_dev_addr()
919 hi = (struct atto_ioctl *)a->disc_buffer; in esas2r_disc_passthru_dev_addr()
921 memset(a->disc_buffer, 0, ESAS2R_DISC_BUF_LEN); in esas2r_disc_passthru_dev_addr()
932 rslt = esas2r_disc_start_request(a, rq); in esas2r_disc_passthru_dev_addr()
939 static void esas2r_disc_passthru_dev_addr_cb(struct esas2r_adapter *a, in esas2r_disc_passthru_dev_addr_cb() argument
951 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_passthru_dev_addr_cb()
953 hi = (struct atto_ioctl *)a->disc_buffer; in esas2r_disc_passthru_dev_addr_cb()
974 t = esas2r_targ_db_add_pthru(a, in esas2r_disc_passthru_dev_addr_cb()
1018 esas2r_rq_destroy_request(rq, a); in esas2r_disc_passthru_dev_addr_cb()
1023 esas2r_disc_continue(a, rq); in esas2r_disc_passthru_dev_addr_cb()
1025 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_passthru_dev_addr_cb()
1032 struct esas2r_adapter *a = sgc->adapter; in esas2r_disc_get_phys_addr() local
1037 *addr = a->uncached_phys in esas2r_disc_get_phys_addr()
1038 + (u64)((u8 *)a->disc_buffer - a->uncached); in esas2r_disc_get_phys_addr()
1043 static bool esas2r_disc_dev_remove(struct esas2r_adapter *a, in esas2r_disc_dev_remove() argument
1055 for (t = a->targetdb; t < a->targetdb_end; t++) { in esas2r_disc_dev_remove()
1064 esas2r_targ_db_find_by_virt_id(a, in esas2r_disc_dev_remove()
1066 a)); in esas2r_disc_dev_remove()
1069 esas2r_targ_db_remove(a, t2); in esas2r_disc_dev_remove()
1075 dc->curr_targ = a->targetdb; in esas2r_disc_dev_remove()
1082 static bool esas2r_disc_dev_add(struct esas2r_adapter *a, in esas2r_disc_dev_add() argument
1089 if (t >= a->targetdb_end) { in esas2r_disc_dev_add()
1104 dc->curr_virt_id = esas2r_targ_get_id(t, a); in esas2r_disc_dev_add()
1132 esas2r_targ_db_add_raid(a, dc); in esas2r_disc_dev_add()
1153 * test if they need to be modified. If a target is no longer present
1155 * target_id since after a hibernate it can be a different value.
1158 static void esas2r_disc_fix_curr_requests(struct esas2r_adapter *a) in esas2r_disc_fix_curr_requests() argument
1167 spin_lock_irqsave(&a->queue_lock, flags); in esas2r_disc_fix_curr_requests()
1169 list_for_each(element, &a->defer_list) { in esas2r_disc_fix_curr_requests()
1172 t = a->targetdb + rq->target_id; in esas2r_disc_fix_curr_requests()
1183 spin_unlock_irqrestore(&a->queue_lock, flags); in esas2r_disc_fix_curr_requests()