Lines Matching defs:a

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)
85 struct esas2r_sas_nvram *nvr = a->nvram;
89 clear_bit(AF_DISC_IN_PROG, &a->flags);
90 clear_bit(AF2_DEV_SCAN, &a->flags2);
91 clear_bit(AF2_DEV_CNT_OK, &a->flags2);
93 a->disc_start_time = jiffies_to_msecs(jiffies);
94 a->disc_wait_time = nvr->dev_wait_time * 1000;
95 a->disc_wait_cnt = nvr->dev_wait_count;
97 if (a->disc_wait_cnt > ESAS2R_MAX_TARGETS)
98 a->disc_wait_cnt = ESAS2R_MAX_TARGETS;
108 a->general_req.interrupt_cx = NULL;
110 if (test_bit(AF_CHPRST_DETECTED, &a->flags) ||
111 test_bit(AF_POWER_MGT, &a->flags)) {
112 if (a->prev_dev_cnt == 0) {
116 a->disc_wait_time = 0;
121 * a time because we know the exact count to wait for.
125 a->disc_wait_cnt = a->prev_dev_cnt;
132 if (a->disc_wait_time < 15000)
133 a->disc_wait_time = 15000;
137 esas2r_trace("disc wait count: %d", a->disc_wait_cnt);
138 esas2r_trace("disc wait time: %d", a->disc_wait_time);
140 if (a->disc_wait_time == 0)
141 esas2r_disc_check_complete(a);
146 void esas2r_disc_start_waiting(struct esas2r_adapter *a)
150 spin_lock_irqsave(&a->mem_lock, flags);
152 if (a->disc_ctx.disc_evt)
153 esas2r_disc_start_port(a);
155 spin_unlock_irqrestore(&a->mem_lock, flags);
158 void esas2r_disc_check_for_work(struct esas2r_adapter *a)
160 struct esas2r_request *rq = &a->general_req;
164 esas2r_polled_interrupt(a);
167 * now, interrupt processing may have queued up a discovery event. go
169 * polled discovery would cause a deadlock.
172 esas2r_disc_start_waiting(a);
180 esas2r_wait_request(a, rq);
183 esas2r_disc_abort(a, rq);
184 esas2r_local_reset_adapter(a);
193 esas2r_disc_continue(a, rq);
196 void esas2r_disc_check_complete(struct esas2r_adapter *a)
203 if (a->disc_wait_time) {
205 u32 time = currtime - a->disc_start_time;
211 if (time < a->disc_wait_time
212 && (esas2r_targ_db_get_tgt_cnt(a) < a->disc_wait_cnt
213 || a->disc_wait_cnt == 0)) {
214 /* After three seconds of waiting, schedule a scan. */
216 && !test_and_set_bit(AF2_DEV_SCAN, &a->flags2)) {
217 spin_lock_irqsave(&a->mem_lock, flags);
218 esas2r_disc_queue_event(a, DCDE_DEV_SCAN);
219 spin_unlock_irqrestore(&a->mem_lock, flags);
230 if (!test_and_set_bit(AF2_DEV_CNT_OK, &a->flags2))
231 a->disc_wait_time = time + 3000;
233 /* If we haven't done a full scan yet, do it now. */
234 if (!test_and_set_bit(AF2_DEV_SCAN, &a->flags2)) {
235 spin_lock_irqsave(&a->mem_lock, flags);
236 esas2r_disc_queue_event(a, DCDE_DEV_SCAN);
237 spin_unlock_irqrestore(&a->mem_lock, flags);
246 if (time < a->disc_wait_time) {
251 if (!test_and_set_bit(AF2_DEV_SCAN, &a->flags2)) {
252 spin_lock_irqsave(&a->mem_lock, flags);
253 esas2r_disc_queue_event(a, DCDE_DEV_SCAN);
254 spin_unlock_irqrestore(&a->mem_lock, flags);
259 a->disc_wait_time = 0;
261 if (test_bit(AF_DISC_POLLED, &a->flags) &&
262 test_bit(AF_DISC_IN_PROG, &a->flags)) {
275 esas2r_disc_fix_curr_requests(a);
276 clear_bit(AF_DISC_PENDING, &a->flags);
283 set_bit(AF_PORT_CHANGE, &a->flags);
289 void esas2r_disc_queue_event(struct esas2r_adapter *a, u8 disc_evt)
291 struct esas2r_disc_context *dc = &a->disc_ctx;
302 * we would have a deadlock if we are in the ISR already.
304 if (!test_bit(AF_CHPRST_PENDING, &a->flags) &&
305 !test_bit(AF_DISC_POLLED, &a->flags))
306 esas2r_disc_start_port(a);
311 bool esas2r_disc_start_port(struct esas2r_adapter *a)
313 struct esas2r_request *rq = &a->general_req;
314 struct esas2r_disc_context *dc = &a->disc_ctx;
319 if (test_bit(AF_DISC_IN_PROG, &a->flags)) {
325 /* If there is a discovery waiting, process it. */
327 if (test_bit(AF_DISC_POLLED, &a->flags)
328 && a->disc_wait_time == 0) {
344 set_bit(AF_PORT_CHANGE, &a->flags);
353 set_bit(AF_DISC_IN_PROG, &a->flags);
356 if (test_bit(AF_DISC_POLLED, &a->flags))
376 if (!test_bit(AF_DISC_POLLED, &a->flags))
377 ret = esas2r_disc_continue(a, rq);
386 static bool esas2r_disc_continue(struct esas2r_adapter *a,
400 rslt = esas2r_disc_dev_remove(a, rq);
405 rslt = esas2r_disc_dev_add(a, rq);
410 rslt = esas2r_disc_block_dev_scan(a, rq);
415 rslt = esas2r_disc_raid_grp_info(a, rq);
420 rslt = esas2r_disc_part_info(a, rq);
425 rslt = esas2r_disc_passthru_dev_info(a, rq);
429 rslt = esas2r_disc_passthru_dev_addr(a, rq);
450 if (!test_bit(AF_DISC_PENDING, &a->flags))
451 esas2r_disc_fix_curr_requests(a);
453 clear_bit(AF_DISC_IN_PROG, &a->flags);
456 return esas2r_disc_start_port(a);
459 static bool esas2r_disc_start_request(struct esas2r_adapter *a,
464 /* Set the timeout to a minimum value. */
475 spin_lock_irqsave(&a->queue_lock, flags);
477 if (!test_bit(AF_CHPRST_PENDING, &a->flags) &&
478 !test_bit(AF_FLASHING, &a->flags))
479 esas2r_disc_local_start_request(a, rq);
481 list_add_tail(&rq->req_list, &a->defer_list);
483 spin_unlock_irqrestore(&a->queue_lock, flags);
488 void esas2r_disc_local_start_request(struct esas2r_adapter *a,
493 list_add_tail(&rq->req_list, &a->active_list);
495 esas2r_start_vda_request(a, rq);
502 static void esas2r_disc_abort(struct esas2r_adapter *a,
517 static bool esas2r_disc_block_dev_scan(struct esas2r_adapter *a,
526 esas2r_rq_init_request(rq, a);
528 esas2r_build_mgt_req(a,
541 rslt = esas2r_disc_start_request(a, rq);
548 static void esas2r_disc_block_dev_scan_cb(struct esas2r_adapter *a,
557 spin_lock_irqsave(&a->mem_lock, flags);
565 esas2r_rq_destroy_request(rq, a);
570 esas2r_disc_continue(a, rq);
572 spin_unlock_irqrestore(&a->mem_lock, flags);
577 static bool esas2r_disc_raid_grp_info(struct esas2r_adapter *a,
597 esas2r_rq_init_request(rq, a);
603 esas2r_build_mgt_req(a,
617 rslt = esas2r_disc_start_request(a, rq);
624 static void esas2r_disc_raid_grp_info_cb(struct esas2r_adapter *a,
634 spin_lock_irqsave(&a->mem_lock, flags);
675 esas2r_rq_destroy_request(rq, a);
680 esas2r_disc_continue(a, rq);
682 spin_unlock_irqrestore(&a->mem_lock, flags);
687 static bool esas2r_disc_part_info(struct esas2r_adapter *a,
708 esas2r_rq_init_request(rq, a);
714 esas2r_build_mgt_req(a,
732 rslt = esas2r_disc_start_request(a, rq);
739 static void esas2r_disc_part_info_cb(struct esas2r_adapter *a,
749 spin_lock_irqsave(&a->mem_lock, flags);
762 esas2r_targ_db_add_raid(a, dc);
776 esas2r_rq_destroy_request(rq, a);
781 esas2r_disc_continue(a, rq);
783 spin_unlock_irqrestore(&a->mem_lock, flags);
788 static bool esas2r_disc_passthru_dev_info(struct esas2r_adapter *a,
800 esas2r_rq_init_request(rq, a);
806 esas2r_build_mgt_req(a,
818 rslt = esas2r_disc_start_request(a, rq);
825 static void esas2r_disc_passthru_dev_info_cb(struct esas2r_adapter *a,
835 spin_lock_irqsave(&a->mem_lock, flags);
869 esas2r_rq_destroy_request(rq, a);
874 esas2r_disc_continue(a, rq);
876 spin_unlock_irqrestore(&a->mem_lock, flags);
881 static bool esas2r_disc_passthru_dev_addr(struct esas2r_adapter *a,
892 esas2r_rq_init_request(rq, a);
901 esas2r_sgc_init(&sgc, a, rq, rq->vrq->ioctl.sge);
903 esas2r_build_ioctl_req(a, rq, sgc.length, VDA_IOCTL_HBA);
905 if (!esas2r_build_sg_list(a, rq, &sgc)) {
906 esas2r_rq_destroy_request(rq, a);
919 hi = (struct atto_ioctl *)a->disc_buffer;
921 memset(a->disc_buffer, 0, ESAS2R_DISC_BUF_LEN);
932 rslt = esas2r_disc_start_request(a, rq);
939 static void esas2r_disc_passthru_dev_addr_cb(struct esas2r_adapter *a,
951 spin_lock_irqsave(&a->mem_lock, flags);
953 hi = (struct atto_ioctl *)a->disc_buffer;
974 t = esas2r_targ_db_add_pthru(a,
1018 esas2r_rq_destroy_request(rq, a);
1023 esas2r_disc_continue(a, rq);
1025 spin_unlock_irqrestore(&a->mem_lock, flags);
1032 struct esas2r_adapter *a = sgc->adapter;
1038 *addr = a->uncached_phys
1039 + (u64)((u8 *)a->disc_buffer - a->uncached);
1044 static bool esas2r_disc_dev_remove(struct esas2r_adapter *a,
1056 for (t = a->targetdb; t < a->targetdb_end; t++) {
1065 esas2r_targ_db_find_by_virt_id(a,
1067 a));
1070 esas2r_targ_db_remove(a, t2);
1076 dc->curr_targ = a->targetdb;
1083 static bool esas2r_disc_dev_add(struct esas2r_adapter *a,
1090 if (t >= a->targetdb_end) {
1105 dc->curr_virt_id = esas2r_targ_get_id(t, a);
1133 esas2r_targ_db_add_raid(a, dc);
1154 * test if they need to be modified. If a target is no longer present
1156 * target_id since after a hibernate it can be a different value.
1159 static void esas2r_disc_fix_curr_requests(struct esas2r_adapter *a)
1168 spin_lock_irqsave(&a->queue_lock, flags);
1170 list_for_each(element, &a->defer_list) {
1173 t = a->targetdb + rq->target_id;
1184 spin_unlock_irqrestore(&a->queue_lock, flags);