diff options
author | Jan Glauber <jang@linux.vnet.ibm.com> | 2012-10-24 06:38:35 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2012-11-23 05:14:27 -0500 |
commit | ce1d801462ce75f9ba84e0bb32a05e1a7c881efe (patch) | |
tree | fdab3b1e70d52c61f6ad055300fa32d580a44efe /drivers/s390/cio/qdio_main.c | |
parent | 773bab4a468b856a8c3b6626e76589d81d8d4e07 (diff) |
s390/qdio: rework BUG's and WARN_ON's
Remove or replace BUG/BUG_ON where possible and convert WARN_ON
to WARN_ON_ONCE if they can occur freqeuently as pointed out by:
https://lkml.org/lkml/2012/9/27/461
Checks have been removed if:
- the error condition leads to a hardware error which gets logged
and in most cases stops the device
- the error condition is a null pointer access
- the error condition is just pointless or already handled at
another location
Signed-off-by: Jan Glauber <jang@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/cio/qdio_main.c')
-rw-r--r-- | drivers/s390/cio/qdio_main.c | 52 |
1 files changed, 11 insertions, 41 deletions
diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c index e06fa03ea1e4..1671d3461f29 100644 --- a/drivers/s390/cio/qdio_main.c +++ b/drivers/s390/cio/qdio_main.c | |||
@@ -129,7 +129,6 @@ static int qdio_do_eqbs(struct qdio_q *q, unsigned char *state, | |||
129 | int rc, tmp_count = count, tmp_start = start, nr = q->nr, retried = 0; | 129 | int rc, tmp_count = count, tmp_start = start, nr = q->nr, retried = 0; |
130 | unsigned int ccq = 0; | 130 | unsigned int ccq = 0; |
131 | 131 | ||
132 | BUG_ON(!q->irq_ptr->sch_token); | ||
133 | qperf_inc(q, eqbs); | 132 | qperf_inc(q, eqbs); |
134 | 133 | ||
135 | if (!q->is_input_q) | 134 | if (!q->is_input_q) |
@@ -147,7 +146,6 @@ again: | |||
147 | } | 146 | } |
148 | 147 | ||
149 | if (rc == 2) { | 148 | if (rc == 2) { |
150 | BUG_ON(tmp_count == count); | ||
151 | qperf_inc(q, eqbs_partial); | 149 | qperf_inc(q, eqbs_partial); |
152 | DBF_DEV_EVENT(DBF_WARN, q->irq_ptr, "EQBS part:%02x", | 150 | DBF_DEV_EVENT(DBF_WARN, q->irq_ptr, "EQBS part:%02x", |
153 | tmp_count); | 151 | tmp_count); |
@@ -189,8 +187,6 @@ static int qdio_do_sqbs(struct qdio_q *q, unsigned char state, int start, | |||
189 | 187 | ||
190 | if (!count) | 188 | if (!count) |
191 | return 0; | 189 | return 0; |
192 | |||
193 | BUG_ON(!q->irq_ptr->sch_token); | ||
194 | qperf_inc(q, sqbs); | 190 | qperf_inc(q, sqbs); |
195 | 191 | ||
196 | if (!q->is_input_q) | 192 | if (!q->is_input_q) |
@@ -199,7 +195,7 @@ again: | |||
199 | ccq = do_sqbs(q->irq_ptr->sch_token, state, nr, &tmp_start, &tmp_count); | 195 | ccq = do_sqbs(q->irq_ptr->sch_token, state, nr, &tmp_start, &tmp_count); |
200 | rc = qdio_check_ccq(q, ccq); | 196 | rc = qdio_check_ccq(q, ccq); |
201 | if (!rc) { | 197 | if (!rc) { |
202 | WARN_ON(tmp_count); | 198 | WARN_ON_ONCE(tmp_count); |
203 | return count - tmp_count; | 199 | return count - tmp_count; |
204 | } | 200 | } |
205 | 201 | ||
@@ -224,9 +220,6 @@ static inline int get_buf_states(struct qdio_q *q, unsigned int bufnr, | |||
224 | unsigned char __state = 0; | 220 | unsigned char __state = 0; |
225 | int i; | 221 | int i; |
226 | 222 | ||
227 | BUG_ON(bufnr > QDIO_MAX_BUFFERS_MASK); | ||
228 | BUG_ON(count > QDIO_MAX_BUFFERS_PER_Q); | ||
229 | |||
230 | if (is_qebsm(q)) | 223 | if (is_qebsm(q)) |
231 | return qdio_do_eqbs(q, state, bufnr, count, auto_ack); | 224 | return qdio_do_eqbs(q, state, bufnr, count, auto_ack); |
232 | 225 | ||
@@ -258,9 +251,6 @@ static inline int set_buf_states(struct qdio_q *q, int bufnr, | |||
258 | { | 251 | { |
259 | int i; | 252 | int i; |
260 | 253 | ||
261 | BUG_ON(bufnr > QDIO_MAX_BUFFERS_MASK); | ||
262 | BUG_ON(count > QDIO_MAX_BUFFERS_PER_Q); | ||
263 | |||
264 | if (is_qebsm(q)) | 254 | if (is_qebsm(q)) |
265 | return qdio_do_sqbs(q, state, bufnr, count); | 255 | return qdio_do_sqbs(q, state, bufnr, count); |
266 | 256 | ||
@@ -345,7 +335,6 @@ again: | |||
345 | 335 | ||
346 | /* hipersocket busy condition */ | 336 | /* hipersocket busy condition */ |
347 | if (unlikely(*busy_bit)) { | 337 | if (unlikely(*busy_bit)) { |
348 | WARN_ON(queue_type(q) != QDIO_IQDIO_QFMT || cc != 2); | ||
349 | retries++; | 338 | retries++; |
350 | 339 | ||
351 | if (!start_time) { | 340 | if (!start_time) { |
@@ -559,7 +548,7 @@ static int get_inbound_buffer_frontier(struct qdio_q *q) | |||
559 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "in nop"); | 548 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "in nop"); |
560 | break; | 549 | break; |
561 | default: | 550 | default: |
562 | BUG(); | 551 | WARN_ON_ONCE(1); |
563 | } | 552 | } |
564 | out: | 553 | out: |
565 | return q->first_to_check; | 554 | return q->first_to_check; |
@@ -678,12 +667,10 @@ static inline void qdio_handle_aobs(struct qdio_q *q, int start, int count) | |||
678 | if (aob == NULL) | 667 | if (aob == NULL) |
679 | continue; | 668 | continue; |
680 | 669 | ||
681 | BUG_ON(q->u.out.sbal_state == NULL); | ||
682 | q->u.out.sbal_state[b].flags |= | 670 | q->u.out.sbal_state[b].flags |= |
683 | QDIO_OUTBUF_STATE_FLAG_PENDING; | 671 | QDIO_OUTBUF_STATE_FLAG_PENDING; |
684 | q->u.out.aobs[b] = NULL; | 672 | q->u.out.aobs[b] = NULL; |
685 | } else if (state == SLSB_P_OUTPUT_EMPTY) { | 673 | } else if (state == SLSB_P_OUTPUT_EMPTY) { |
686 | BUG_ON(q->u.out.sbal_state == NULL); | ||
687 | q->u.out.sbal_state[b].aob = NULL; | 674 | q->u.out.sbal_state[b].aob = NULL; |
688 | } | 675 | } |
689 | b = next_buf(b); | 676 | b = next_buf(b); |
@@ -703,12 +690,11 @@ static inline unsigned long qdio_aob_for_buffer(struct qdio_output_q *q, | |||
703 | q->aobs[bufnr] = aob; | 690 | q->aobs[bufnr] = aob; |
704 | } | 691 | } |
705 | if (q->aobs[bufnr]) { | 692 | if (q->aobs[bufnr]) { |
706 | BUG_ON(q->sbal_state == NULL); | ||
707 | q->sbal_state[bufnr].flags = QDIO_OUTBUF_STATE_FLAG_NONE; | 693 | q->sbal_state[bufnr].flags = QDIO_OUTBUF_STATE_FLAG_NONE; |
708 | q->sbal_state[bufnr].aob = q->aobs[bufnr]; | 694 | q->sbal_state[bufnr].aob = q->aobs[bufnr]; |
709 | q->aobs[bufnr]->user1 = (u64) q->sbal_state[bufnr].user; | 695 | q->aobs[bufnr]->user1 = (u64) q->sbal_state[bufnr].user; |
710 | phys_aob = virt_to_phys(q->aobs[bufnr]); | 696 | phys_aob = virt_to_phys(q->aobs[bufnr]); |
711 | BUG_ON(phys_aob & 0xFF); | 697 | WARN_ON_ONCE(phys_aob & 0xFF); |
712 | } | 698 | } |
713 | 699 | ||
714 | out: | 700 | out: |
@@ -809,8 +795,6 @@ static int get_outbound_buffer_frontier(struct qdio_q *q) | |||
809 | goto out; | 795 | goto out; |
810 | 796 | ||
811 | switch (state) { | 797 | switch (state) { |
812 | case SLSB_P_OUTPUT_PENDING: | ||
813 | BUG(); | ||
814 | case SLSB_P_OUTPUT_EMPTY: | 798 | case SLSB_P_OUTPUT_EMPTY: |
815 | /* the adapter got it */ | 799 | /* the adapter got it */ |
816 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, | 800 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, |
@@ -840,7 +824,7 @@ static int get_outbound_buffer_frontier(struct qdio_q *q) | |||
840 | case SLSB_P_OUTPUT_HALTED: | 824 | case SLSB_P_OUTPUT_HALTED: |
841 | break; | 825 | break; |
842 | default: | 826 | default: |
843 | BUG(); | 827 | WARN_ON_ONCE(1); |
844 | } | 828 | } |
845 | 829 | ||
846 | out: | 830 | out: |
@@ -912,7 +896,7 @@ retry: | |||
912 | static void __qdio_outbound_processing(struct qdio_q *q) | 896 | static void __qdio_outbound_processing(struct qdio_q *q) |
913 | { | 897 | { |
914 | qperf_inc(q, tasklet_outbound); | 898 | qperf_inc(q, tasklet_outbound); |
915 | BUG_ON(atomic_read(&q->nr_buf_used) < 0); | 899 | WARN_ON_ONCE(atomic_read(&q->nr_buf_used) < 0); |
916 | 900 | ||
917 | if (qdio_outbound_q_moved(q)) | 901 | if (qdio_outbound_q_moved(q)) |
918 | qdio_kick_handler(q); | 902 | qdio_kick_handler(q); |
@@ -1138,16 +1122,10 @@ void qdio_int_handler(struct ccw_device *cdev, unsigned long intparm, | |||
1138 | irq_ptr->perf_stat.qdio_int++; | 1122 | irq_ptr->perf_stat.qdio_int++; |
1139 | 1123 | ||
1140 | if (IS_ERR(irb)) { | 1124 | if (IS_ERR(irb)) { |
1141 | switch (PTR_ERR(irb)) { | 1125 | DBF_ERROR("%4x IO error", irq_ptr->schid.sch_no); |
1142 | case -EIO: | 1126 | qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); |
1143 | DBF_ERROR("%4x IO error", irq_ptr->schid.sch_no); | 1127 | wake_up(&cdev->private->wait_q); |
1144 | qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); | 1128 | return; |
1145 | wake_up(&cdev->private->wait_q); | ||
1146 | return; | ||
1147 | default: | ||
1148 | WARN_ON(1); | ||
1149 | return; | ||
1150 | } | ||
1151 | } | 1129 | } |
1152 | qdio_irq_check_sense(irq_ptr, irb); | 1130 | qdio_irq_check_sense(irq_ptr, irb); |
1153 | cstat = irb->scsw.cmd.cstat; | 1131 | cstat = irb->scsw.cmd.cstat; |
@@ -1173,7 +1151,7 @@ void qdio_int_handler(struct ccw_device *cdev, unsigned long intparm, | |||
1173 | case QDIO_IRQ_STATE_STOPPED: | 1151 | case QDIO_IRQ_STATE_STOPPED: |
1174 | break; | 1152 | break; |
1175 | default: | 1153 | default: |
1176 | WARN_ON(1); | 1154 | WARN_ON_ONCE(1); |
1177 | } | 1155 | } |
1178 | wake_up(&cdev->private->wait_q); | 1156 | wake_up(&cdev->private->wait_q); |
1179 | } | 1157 | } |
@@ -1227,7 +1205,7 @@ int qdio_shutdown(struct ccw_device *cdev, int how) | |||
1227 | if (!irq_ptr) | 1205 | if (!irq_ptr) |
1228 | return -ENODEV; | 1206 | return -ENODEV; |
1229 | 1207 | ||
1230 | BUG_ON(irqs_disabled()); | 1208 | WARN_ON_ONCE(irqs_disabled()); |
1231 | DBF_EVENT("qshutdown:%4x", cdev->private->schid.sch_no); | 1209 | DBF_EVENT("qshutdown:%4x", cdev->private->schid.sch_no); |
1232 | 1210 | ||
1233 | mutex_lock(&irq_ptr->setup_mutex); | 1211 | mutex_lock(&irq_ptr->setup_mutex); |
@@ -1358,7 +1336,6 @@ int qdio_allocate(struct qdio_initialize *init_data) | |||
1358 | irq_ptr->qdr = (struct qdr *) get_zeroed_page(GFP_KERNEL | GFP_DMA); | 1336 | irq_ptr->qdr = (struct qdr *) get_zeroed_page(GFP_KERNEL | GFP_DMA); |
1359 | if (!irq_ptr->qdr) | 1337 | if (!irq_ptr->qdr) |
1360 | goto out_rel; | 1338 | goto out_rel; |
1361 | WARN_ON((unsigned long)irq_ptr->qdr & 0xfff); | ||
1362 | 1339 | ||
1363 | if (qdio_allocate_qs(irq_ptr, init_data->no_input_qs, | 1340 | if (qdio_allocate_qs(irq_ptr, init_data->no_input_qs, |
1364 | init_data->no_output_qs)) | 1341 | init_data->no_output_qs)) |
@@ -1597,9 +1574,7 @@ static int handle_inbound(struct qdio_q *q, unsigned int callflags, | |||
1597 | 1574 | ||
1598 | set: | 1575 | set: |
1599 | count = set_buf_states(q, bufnr, SLSB_CU_INPUT_EMPTY, count); | 1576 | count = set_buf_states(q, bufnr, SLSB_CU_INPUT_EMPTY, count); |
1600 | |||
1601 | used = atomic_add_return(count, &q->nr_buf_used) - count; | 1577 | used = atomic_add_return(count, &q->nr_buf_used) - count; |
1602 | BUG_ON(used + count > QDIO_MAX_BUFFERS_PER_Q); | ||
1603 | 1578 | ||
1604 | if (need_siga_in(q)) | 1579 | if (need_siga_in(q)) |
1605 | return qdio_siga_input(q); | 1580 | return qdio_siga_input(q); |
@@ -1624,7 +1599,6 @@ static int handle_outbound(struct qdio_q *q, unsigned int callflags, | |||
1624 | 1599 | ||
1625 | count = set_buf_states(q, bufnr, SLSB_CU_OUTPUT_PRIMED, count); | 1600 | count = set_buf_states(q, bufnr, SLSB_CU_OUTPUT_PRIMED, count); |
1626 | used = atomic_add_return(count, &q->nr_buf_used); | 1601 | used = atomic_add_return(count, &q->nr_buf_used); |
1627 | BUG_ON(used > QDIO_MAX_BUFFERS_PER_Q); | ||
1628 | 1602 | ||
1629 | if (used == QDIO_MAX_BUFFERS_PER_Q) | 1603 | if (used == QDIO_MAX_BUFFERS_PER_Q) |
1630 | qperf_inc(q, outbound_queue_full); | 1604 | qperf_inc(q, outbound_queue_full); |
@@ -1678,7 +1652,6 @@ int do_QDIO(struct ccw_device *cdev, unsigned int callflags, | |||
1678 | { | 1652 | { |
1679 | struct qdio_irq *irq_ptr; | 1653 | struct qdio_irq *irq_ptr; |
1680 | 1654 | ||
1681 | |||
1682 | if (bufnr >= QDIO_MAX_BUFFERS_PER_Q || count > QDIO_MAX_BUFFERS_PER_Q) | 1655 | if (bufnr >= QDIO_MAX_BUFFERS_PER_Q || count > QDIO_MAX_BUFFERS_PER_Q) |
1683 | return -EINVAL; | 1656 | return -EINVAL; |
1684 | 1657 | ||
@@ -1721,8 +1694,6 @@ int qdio_start_irq(struct ccw_device *cdev, int nr) | |||
1721 | return -ENODEV; | 1694 | return -ENODEV; |
1722 | q = irq_ptr->input_qs[nr]; | 1695 | q = irq_ptr->input_qs[nr]; |
1723 | 1696 | ||
1724 | WARN_ON(queue_irqs_enabled(q)); | ||
1725 | |||
1726 | clear_nonshared_ind(irq_ptr); | 1697 | clear_nonshared_ind(irq_ptr); |
1727 | qdio_stop_polling(q); | 1698 | qdio_stop_polling(q); |
1728 | clear_bit(QDIO_QUEUE_IRQS_DISABLED, &q->u.in.queue_irq_state); | 1699 | clear_bit(QDIO_QUEUE_IRQS_DISABLED, &q->u.in.queue_irq_state); |
@@ -1769,7 +1740,6 @@ int qdio_get_next_buffers(struct ccw_device *cdev, int nr, int *bufnr, | |||
1769 | if (!irq_ptr) | 1740 | if (!irq_ptr) |
1770 | return -ENODEV; | 1741 | return -ENODEV; |
1771 | q = irq_ptr->input_qs[nr]; | 1742 | q = irq_ptr->input_qs[nr]; |
1772 | WARN_ON(queue_irqs_enabled(q)); | ||
1773 | 1743 | ||
1774 | /* | 1744 | /* |
1775 | * Cannot rely on automatic sync after interrupt since queues may | 1745 | * Cannot rely on automatic sync after interrupt since queues may |