Commit ce1d8014 authored by Jan Glauber's avatar Jan Glauber Committed by Martin Schwidefsky

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: default avatarJan Glauber <jang@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 773bab4a
...@@ -129,7 +129,6 @@ static int qdio_do_eqbs(struct qdio_q *q, unsigned char *state, ...@@ -129,7 +129,6 @@ static int qdio_do_eqbs(struct qdio_q *q, unsigned char *state,
int rc, tmp_count = count, tmp_start = start, nr = q->nr, retried = 0; int rc, tmp_count = count, tmp_start = start, nr = q->nr, retried = 0;
unsigned int ccq = 0; unsigned int ccq = 0;
BUG_ON(!q->irq_ptr->sch_token);
qperf_inc(q, eqbs); qperf_inc(q, eqbs);
if (!q->is_input_q) if (!q->is_input_q)
...@@ -147,7 +146,6 @@ static int qdio_do_eqbs(struct qdio_q *q, unsigned char *state, ...@@ -147,7 +146,6 @@ static int qdio_do_eqbs(struct qdio_q *q, unsigned char *state,
} }
if (rc == 2) { if (rc == 2) {
BUG_ON(tmp_count == count);
qperf_inc(q, eqbs_partial); qperf_inc(q, eqbs_partial);
DBF_DEV_EVENT(DBF_WARN, q->irq_ptr, "EQBS part:%02x", DBF_DEV_EVENT(DBF_WARN, q->irq_ptr, "EQBS part:%02x",
tmp_count); tmp_count);
...@@ -189,8 +187,6 @@ static int qdio_do_sqbs(struct qdio_q *q, unsigned char state, int start, ...@@ -189,8 +187,6 @@ static int qdio_do_sqbs(struct qdio_q *q, unsigned char state, int start,
if (!count) if (!count)
return 0; return 0;
BUG_ON(!q->irq_ptr->sch_token);
qperf_inc(q, sqbs); qperf_inc(q, sqbs);
if (!q->is_input_q) if (!q->is_input_q)
...@@ -199,7 +195,7 @@ static int qdio_do_sqbs(struct qdio_q *q, unsigned char state, int start, ...@@ -199,7 +195,7 @@ static int qdio_do_sqbs(struct qdio_q *q, unsigned char state, int start,
ccq = do_sqbs(q->irq_ptr->sch_token, state, nr, &tmp_start, &tmp_count); ccq = do_sqbs(q->irq_ptr->sch_token, state, nr, &tmp_start, &tmp_count);
rc = qdio_check_ccq(q, ccq); rc = qdio_check_ccq(q, ccq);
if (!rc) { if (!rc) {
WARN_ON(tmp_count); WARN_ON_ONCE(tmp_count);
return count - tmp_count; return count - tmp_count;
} }
...@@ -224,9 +220,6 @@ static inline int get_buf_states(struct qdio_q *q, unsigned int bufnr, ...@@ -224,9 +220,6 @@ static inline int get_buf_states(struct qdio_q *q, unsigned int bufnr,
unsigned char __state = 0; unsigned char __state = 0;
int i; int i;
BUG_ON(bufnr > QDIO_MAX_BUFFERS_MASK);
BUG_ON(count > QDIO_MAX_BUFFERS_PER_Q);
if (is_qebsm(q)) if (is_qebsm(q))
return qdio_do_eqbs(q, state, bufnr, count, auto_ack); return qdio_do_eqbs(q, state, bufnr, count, auto_ack);
...@@ -258,9 +251,6 @@ static inline int set_buf_states(struct qdio_q *q, int bufnr, ...@@ -258,9 +251,6 @@ static inline int set_buf_states(struct qdio_q *q, int bufnr,
{ {
int i; int i;
BUG_ON(bufnr > QDIO_MAX_BUFFERS_MASK);
BUG_ON(count > QDIO_MAX_BUFFERS_PER_Q);
if (is_qebsm(q)) if (is_qebsm(q))
return qdio_do_sqbs(q, state, bufnr, count); return qdio_do_sqbs(q, state, bufnr, count);
...@@ -345,7 +335,6 @@ static int qdio_siga_output(struct qdio_q *q, unsigned int *busy_bit, ...@@ -345,7 +335,6 @@ static int qdio_siga_output(struct qdio_q *q, unsigned int *busy_bit,
/* hipersocket busy condition */ /* hipersocket busy condition */
if (unlikely(*busy_bit)) { if (unlikely(*busy_bit)) {
WARN_ON(queue_type(q) != QDIO_IQDIO_QFMT || cc != 2);
retries++; retries++;
if (!start_time) { if (!start_time) {
...@@ -559,7 +548,7 @@ static int get_inbound_buffer_frontier(struct qdio_q *q) ...@@ -559,7 +548,7 @@ static int get_inbound_buffer_frontier(struct qdio_q *q)
DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "in nop"); DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "in nop");
break; break;
default: default:
BUG(); WARN_ON_ONCE(1);
} }
out: out:
return q->first_to_check; return q->first_to_check;
...@@ -678,12 +667,10 @@ static inline void qdio_handle_aobs(struct qdio_q *q, int start, int count) ...@@ -678,12 +667,10 @@ static inline void qdio_handle_aobs(struct qdio_q *q, int start, int count)
if (aob == NULL) if (aob == NULL)
continue; continue;
BUG_ON(q->u.out.sbal_state == NULL);
q->u.out.sbal_state[b].flags |= q->u.out.sbal_state[b].flags |=
QDIO_OUTBUF_STATE_FLAG_PENDING; QDIO_OUTBUF_STATE_FLAG_PENDING;
q->u.out.aobs[b] = NULL; q->u.out.aobs[b] = NULL;
} else if (state == SLSB_P_OUTPUT_EMPTY) { } else if (state == SLSB_P_OUTPUT_EMPTY) {
BUG_ON(q->u.out.sbal_state == NULL);
q->u.out.sbal_state[b].aob = NULL; q->u.out.sbal_state[b].aob = NULL;
} }
b = next_buf(b); b = next_buf(b);
...@@ -703,12 +690,11 @@ static inline unsigned long qdio_aob_for_buffer(struct qdio_output_q *q, ...@@ -703,12 +690,11 @@ static inline unsigned long qdio_aob_for_buffer(struct qdio_output_q *q,
q->aobs[bufnr] = aob; q->aobs[bufnr] = aob;
} }
if (q->aobs[bufnr]) { if (q->aobs[bufnr]) {
BUG_ON(q->sbal_state == NULL);
q->sbal_state[bufnr].flags = QDIO_OUTBUF_STATE_FLAG_NONE; q->sbal_state[bufnr].flags = QDIO_OUTBUF_STATE_FLAG_NONE;
q->sbal_state[bufnr].aob = q->aobs[bufnr]; q->sbal_state[bufnr].aob = q->aobs[bufnr];
q->aobs[bufnr]->user1 = (u64) q->sbal_state[bufnr].user; q->aobs[bufnr]->user1 = (u64) q->sbal_state[bufnr].user;
phys_aob = virt_to_phys(q->aobs[bufnr]); phys_aob = virt_to_phys(q->aobs[bufnr]);
BUG_ON(phys_aob & 0xFF); WARN_ON_ONCE(phys_aob & 0xFF);
} }
out: out:
...@@ -809,8 +795,6 @@ static int get_outbound_buffer_frontier(struct qdio_q *q) ...@@ -809,8 +795,6 @@ static int get_outbound_buffer_frontier(struct qdio_q *q)
goto out; goto out;
switch (state) { switch (state) {
case SLSB_P_OUTPUT_PENDING:
BUG();
case SLSB_P_OUTPUT_EMPTY: case SLSB_P_OUTPUT_EMPTY:
/* the adapter got it */ /* the adapter got it */
DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, DBF_DEV_EVENT(DBF_INFO, q->irq_ptr,
...@@ -840,7 +824,7 @@ static int get_outbound_buffer_frontier(struct qdio_q *q) ...@@ -840,7 +824,7 @@ static int get_outbound_buffer_frontier(struct qdio_q *q)
case SLSB_P_OUTPUT_HALTED: case SLSB_P_OUTPUT_HALTED:
break; break;
default: default:
BUG(); WARN_ON_ONCE(1);
} }
out: out:
...@@ -912,7 +896,7 @@ static int qdio_kick_outbound_q(struct qdio_q *q, unsigned long aob) ...@@ -912,7 +896,7 @@ static int qdio_kick_outbound_q(struct qdio_q *q, unsigned long aob)
static void __qdio_outbound_processing(struct qdio_q *q) static void __qdio_outbound_processing(struct qdio_q *q)
{ {
qperf_inc(q, tasklet_outbound); qperf_inc(q, tasklet_outbound);
BUG_ON(atomic_read(&q->nr_buf_used) < 0); WARN_ON_ONCE(atomic_read(&q->nr_buf_used) < 0);
if (qdio_outbound_q_moved(q)) if (qdio_outbound_q_moved(q))
qdio_kick_handler(q); qdio_kick_handler(q);
...@@ -1138,16 +1122,10 @@ void qdio_int_handler(struct ccw_device *cdev, unsigned long intparm, ...@@ -1138,16 +1122,10 @@ void qdio_int_handler(struct ccw_device *cdev, unsigned long intparm,
irq_ptr->perf_stat.qdio_int++; irq_ptr->perf_stat.qdio_int++;
if (IS_ERR(irb)) { if (IS_ERR(irb)) {
switch (PTR_ERR(irb)) {
case -EIO:
DBF_ERROR("%4x IO error", irq_ptr->schid.sch_no); DBF_ERROR("%4x IO error", irq_ptr->schid.sch_no);
qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR);
wake_up(&cdev->private->wait_q); wake_up(&cdev->private->wait_q);
return; return;
default:
WARN_ON(1);
return;
}
} }
qdio_irq_check_sense(irq_ptr, irb); qdio_irq_check_sense(irq_ptr, irb);
cstat = irb->scsw.cmd.cstat; cstat = irb->scsw.cmd.cstat;
...@@ -1173,7 +1151,7 @@ void qdio_int_handler(struct ccw_device *cdev, unsigned long intparm, ...@@ -1173,7 +1151,7 @@ void qdio_int_handler(struct ccw_device *cdev, unsigned long intparm,
case QDIO_IRQ_STATE_STOPPED: case QDIO_IRQ_STATE_STOPPED:
break; break;
default: default:
WARN_ON(1); WARN_ON_ONCE(1);
} }
wake_up(&cdev->private->wait_q); wake_up(&cdev->private->wait_q);
} }
...@@ -1227,7 +1205,7 @@ int qdio_shutdown(struct ccw_device *cdev, int how) ...@@ -1227,7 +1205,7 @@ int qdio_shutdown(struct ccw_device *cdev, int how)
if (!irq_ptr) if (!irq_ptr)
return -ENODEV; return -ENODEV;
BUG_ON(irqs_disabled()); WARN_ON_ONCE(irqs_disabled());
DBF_EVENT("qshutdown:%4x", cdev->private->schid.sch_no); DBF_EVENT("qshutdown:%4x", cdev->private->schid.sch_no);
mutex_lock(&irq_ptr->setup_mutex); mutex_lock(&irq_ptr->setup_mutex);
...@@ -1358,7 +1336,6 @@ int qdio_allocate(struct qdio_initialize *init_data) ...@@ -1358,7 +1336,6 @@ int qdio_allocate(struct qdio_initialize *init_data)
irq_ptr->qdr = (struct qdr *) get_zeroed_page(GFP_KERNEL | GFP_DMA); irq_ptr->qdr = (struct qdr *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
if (!irq_ptr->qdr) if (!irq_ptr->qdr)
goto out_rel; goto out_rel;
WARN_ON((unsigned long)irq_ptr->qdr & 0xfff);
if (qdio_allocate_qs(irq_ptr, init_data->no_input_qs, if (qdio_allocate_qs(irq_ptr, init_data->no_input_qs,
init_data->no_output_qs)) init_data->no_output_qs))
...@@ -1597,9 +1574,7 @@ static int handle_inbound(struct qdio_q *q, unsigned int callflags, ...@@ -1597,9 +1574,7 @@ static int handle_inbound(struct qdio_q *q, unsigned int callflags,
set: set:
count = set_buf_states(q, bufnr, SLSB_CU_INPUT_EMPTY, count); count = set_buf_states(q, bufnr, SLSB_CU_INPUT_EMPTY, count);
used = atomic_add_return(count, &q->nr_buf_used) - count; used = atomic_add_return(count, &q->nr_buf_used) - count;
BUG_ON(used + count > QDIO_MAX_BUFFERS_PER_Q);
if (need_siga_in(q)) if (need_siga_in(q))
return qdio_siga_input(q); return qdio_siga_input(q);
...@@ -1624,7 +1599,6 @@ static int handle_outbound(struct qdio_q *q, unsigned int callflags, ...@@ -1624,7 +1599,6 @@ static int handle_outbound(struct qdio_q *q, unsigned int callflags,
count = set_buf_states(q, bufnr, SLSB_CU_OUTPUT_PRIMED, count); count = set_buf_states(q, bufnr, SLSB_CU_OUTPUT_PRIMED, count);
used = atomic_add_return(count, &q->nr_buf_used); used = atomic_add_return(count, &q->nr_buf_used);
BUG_ON(used > QDIO_MAX_BUFFERS_PER_Q);
if (used == QDIO_MAX_BUFFERS_PER_Q) if (used == QDIO_MAX_BUFFERS_PER_Q)
qperf_inc(q, outbound_queue_full); qperf_inc(q, outbound_queue_full);
...@@ -1678,7 +1652,6 @@ int do_QDIO(struct ccw_device *cdev, unsigned int callflags, ...@@ -1678,7 +1652,6 @@ int do_QDIO(struct ccw_device *cdev, unsigned int callflags,
{ {
struct qdio_irq *irq_ptr; struct qdio_irq *irq_ptr;
if (bufnr >= QDIO_MAX_BUFFERS_PER_Q || count > QDIO_MAX_BUFFERS_PER_Q) if (bufnr >= QDIO_MAX_BUFFERS_PER_Q || count > QDIO_MAX_BUFFERS_PER_Q)
return -EINVAL; return -EINVAL;
...@@ -1721,8 +1694,6 @@ int qdio_start_irq(struct ccw_device *cdev, int nr) ...@@ -1721,8 +1694,6 @@ int qdio_start_irq(struct ccw_device *cdev, int nr)
return -ENODEV; return -ENODEV;
q = irq_ptr->input_qs[nr]; q = irq_ptr->input_qs[nr];
WARN_ON(queue_irqs_enabled(q));
clear_nonshared_ind(irq_ptr); clear_nonshared_ind(irq_ptr);
qdio_stop_polling(q); qdio_stop_polling(q);
clear_bit(QDIO_QUEUE_IRQS_DISABLED, &q->u.in.queue_irq_state); 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,7 +1740,6 @@ int qdio_get_next_buffers(struct ccw_device *cdev, int nr, int *bufnr,
if (!irq_ptr) if (!irq_ptr)
return -ENODEV; return -ENODEV;
q = irq_ptr->input_qs[nr]; q = irq_ptr->input_qs[nr];
WARN_ON(queue_irqs_enabled(q));
/* /*
* Cannot rely on automatic sync after interrupt since queues may * Cannot rely on automatic sync after interrupt since queues may
......
...@@ -140,10 +140,8 @@ static void setup_storage_lists(struct qdio_q *q, struct qdio_irq *irq_ptr, ...@@ -140,10 +140,8 @@ static void setup_storage_lists(struct qdio_q *q, struct qdio_irq *irq_ptr,
q->sl = (struct sl *)((char *)q->slib + PAGE_SIZE / 2); q->sl = (struct sl *)((char *)q->slib + PAGE_SIZE / 2);
/* fill in sbal */ /* fill in sbal */
for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; j++) { for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; j++)
q->sbal[j] = *sbals_array++; q->sbal[j] = *sbals_array++;
BUG_ON((unsigned long)q->sbal[j] & 0xff);
}
/* fill in slib */ /* fill in slib */
if (i > 0) { if (i > 0) {
......
...@@ -73,7 +73,6 @@ static void put_indicator(u32 *addr) ...@@ -73,7 +73,6 @@ static void put_indicator(u32 *addr)
void tiqdio_add_input_queues(struct qdio_irq *irq_ptr) void tiqdio_add_input_queues(struct qdio_irq *irq_ptr)
{ {
mutex_lock(&tiq_list_lock); mutex_lock(&tiq_list_lock);
BUG_ON(irq_ptr->nr_input_qs < 1);
list_add_rcu(&irq_ptr->input_qs[0]->entry, &tiq_list); list_add_rcu(&irq_ptr->input_qs[0]->entry, &tiq_list);
mutex_unlock(&tiq_list_lock); mutex_unlock(&tiq_list_lock);
xchg(irq_ptr->dsci, 1 << 7); xchg(irq_ptr->dsci, 1 << 7);
...@@ -83,7 +82,6 @@ void tiqdio_remove_input_queues(struct qdio_irq *irq_ptr) ...@@ -83,7 +82,6 @@ void tiqdio_remove_input_queues(struct qdio_irq *irq_ptr)
{ {
struct qdio_q *q; struct qdio_q *q;
BUG_ON(irq_ptr->nr_input_qs < 1);
q = irq_ptr->input_qs[0]; q = irq_ptr->input_qs[0];
/* if establish triggered an error */ /* if establish triggered an error */
if (!q || !q->entry.prev || !q->entry.next) if (!q || !q->entry.prev || !q->entry.next)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment