Commit 3b346c18 authored by Julian Wiedmann's avatar Julian Wiedmann Committed by David S. Miller

s390/qeth: various buffer management cleanups

Use the new qeth_scrub_qdio_buffer() helper, remove an extra parameter
from qeth_clear_output_buffer(), init the bufstates.user field just once
(in qeth_flush_buffers()) and remove some noisy trace messages.
Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0761680d
...@@ -1267,8 +1267,7 @@ static void qeth_release_skbs(struct qeth_qdio_out_buffer *buf) ...@@ -1267,8 +1267,7 @@ static void qeth_release_skbs(struct qeth_qdio_out_buffer *buf)
} }
static void qeth_clear_output_buffer(struct qeth_qdio_out_q *queue, static void qeth_clear_output_buffer(struct qeth_qdio_out_q *queue,
struct qeth_qdio_out_buffer *buf, struct qeth_qdio_out_buffer *buf)
enum qeth_qdio_buffer_states newbufstate)
{ {
int i; int i;
...@@ -1276,23 +1275,19 @@ static void qeth_clear_output_buffer(struct qeth_qdio_out_q *queue, ...@@ -1276,23 +1275,19 @@ static void qeth_clear_output_buffer(struct qeth_qdio_out_q *queue,
if (buf->buffer->element[0].sflags & SBAL_SFLAGS0_PCI_REQ) if (buf->buffer->element[0].sflags & SBAL_SFLAGS0_PCI_REQ)
atomic_dec(&queue->set_pci_flags_count); atomic_dec(&queue->set_pci_flags_count);
if (newbufstate == QETH_QDIO_BUF_EMPTY) {
qeth_release_skbs(buf); qeth_release_skbs(buf);
}
for (i = 0; i < QETH_MAX_BUFFER_ELEMENTS(queue->card); ++i) { for (i = 0; i < QETH_MAX_BUFFER_ELEMENTS(queue->card); ++i) {
if (buf->buffer->element[i].addr && buf->is_header[i]) if (buf->buffer->element[i].addr && buf->is_header[i])
kmem_cache_free(qeth_core_header_cache, kmem_cache_free(qeth_core_header_cache,
buf->buffer->element[i].addr); buf->buffer->element[i].addr);
buf->is_header[i] = 0; buf->is_header[i] = 0;
buf->buffer->element[i].length = 0;
buf->buffer->element[i].addr = NULL;
buf->buffer->element[i].eflags = 0;
buf->buffer->element[i].sflags = 0;
} }
buf->buffer->element[15].eflags = 0;
buf->buffer->element[15].sflags = 0; qeth_scrub_qdio_buffer(buf->buffer,
QETH_MAX_BUFFER_ELEMENTS(queue->card));
buf->next_element_to_fill = 0; buf->next_element_to_fill = 0;
atomic_set(&buf->state, newbufstate); atomic_set(&buf->state, QETH_QDIO_BUF_EMPTY);
} }
static void qeth_clear_outq_buffers(struct qeth_qdio_out_q *q, int free) static void qeth_clear_outq_buffers(struct qeth_qdio_out_q *q, int free)
...@@ -1303,7 +1298,7 @@ static void qeth_clear_outq_buffers(struct qeth_qdio_out_q *q, int free) ...@@ -1303,7 +1298,7 @@ static void qeth_clear_outq_buffers(struct qeth_qdio_out_q *q, int free)
if (!q->bufs[j]) if (!q->bufs[j])
continue; continue;
qeth_cleanup_handled_pending(q, j, 1); qeth_cleanup_handled_pending(q, j, 1);
qeth_clear_output_buffer(q, q->bufs[j], QETH_QDIO_BUF_EMPTY); qeth_clear_output_buffer(q, q->bufs[j]);
if (free) { if (free) {
kmem_cache_free(qeth_qdio_outbuf_cache, q->bufs[j]); kmem_cache_free(qeth_qdio_outbuf_cache, q->bufs[j]);
q->bufs[j] = NULL; q->bufs[j] = NULL;
...@@ -2473,15 +2468,12 @@ static int qeth_ulp_setup(struct qeth_card *card) ...@@ -2473,15 +2468,12 @@ static int qeth_ulp_setup(struct qeth_card *card)
static int qeth_init_qdio_out_buf(struct qeth_qdio_out_q *q, int bidx) static int qeth_init_qdio_out_buf(struct qeth_qdio_out_q *q, int bidx)
{ {
int rc;
struct qeth_qdio_out_buffer *newbuf; struct qeth_qdio_out_buffer *newbuf;
rc = 0;
newbuf = kmem_cache_zalloc(qeth_qdio_outbuf_cache, GFP_ATOMIC); newbuf = kmem_cache_zalloc(qeth_qdio_outbuf_cache, GFP_ATOMIC);
if (!newbuf) { if (!newbuf)
rc = -ENOMEM; return -ENOMEM;
goto out;
}
newbuf->buffer = q->qdio_bufs[bidx]; newbuf->buffer = q->qdio_bufs[bidx];
skb_queue_head_init(&newbuf->skb_list); skb_queue_head_init(&newbuf->skb_list);
lockdep_set_class(&newbuf->skb_list.lock, &qdio_out_skb_queue_key); lockdep_set_class(&newbuf->skb_list.lock, &qdio_out_skb_queue_key);
...@@ -2490,15 +2482,7 @@ static int qeth_init_qdio_out_buf(struct qeth_qdio_out_q *q, int bidx) ...@@ -2490,15 +2482,7 @@ static int qeth_init_qdio_out_buf(struct qeth_qdio_out_q *q, int bidx)
newbuf->next_pending = q->bufs[bidx]; newbuf->next_pending = q->bufs[bidx];
atomic_set(&newbuf->state, QETH_QDIO_BUF_EMPTY); atomic_set(&newbuf->state, QETH_QDIO_BUF_EMPTY);
q->bufs[bidx] = newbuf; q->bufs[bidx] = newbuf;
if (q->bufstates) { return 0;
q->bufstates[bidx].user = newbuf;
QETH_CARD_TEXT_(q->card, 2, "nbs%d", bidx);
QETH_CARD_TEXT_(q->card, 2, "%lx", (long) newbuf);
QETH_CARD_TEXT_(q->card, 2, "%lx",
(long) newbuf->next_pending);
}
out:
return rc;
} }
static void qeth_free_qdio_out_buf(struct qeth_qdio_out_q *q) static void qeth_free_qdio_out_buf(struct qeth_qdio_out_q *q)
...@@ -2908,8 +2892,7 @@ int qeth_init_qdio_queues(struct qeth_card *card) ...@@ -2908,8 +2892,7 @@ int qeth_init_qdio_queues(struct qeth_card *card)
QDIO_MAX_BUFFERS_PER_Q); QDIO_MAX_BUFFERS_PER_Q);
for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j) { for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j) {
qeth_clear_output_buffer(card->qdio.out_qs[i], qeth_clear_output_buffer(card->qdio.out_qs[i],
card->qdio.out_qs[i]->bufs[j], card->qdio.out_qs[i]->bufs[j]);
QETH_QDIO_BUF_EMPTY);
} }
card->qdio.out_qs[i]->card = card; card->qdio.out_qs[i]->card = card;
card->qdio.out_qs[i]->next_buf_to_fill = 0; card->qdio.out_qs[i]->next_buf_to_fill = 0;
...@@ -3634,10 +3617,10 @@ int qeth_configure_cq(struct qeth_card *card, enum qeth_cq cq) ...@@ -3634,10 +3617,10 @@ int qeth_configure_cq(struct qeth_card *card, enum qeth_cq cq)
} }
EXPORT_SYMBOL_GPL(qeth_configure_cq); EXPORT_SYMBOL_GPL(qeth_configure_cq);
static void qeth_qdio_cq_handler(struct qeth_card *card, unsigned int qdio_err,
static void qeth_qdio_cq_handler(struct qeth_card *card, unsigned int queue, int first_element,
unsigned int qdio_err, int count)
unsigned int queue, int first_element, int count) { {
struct qeth_qdio_q *cq = card->qdio.c_q; struct qeth_qdio_q *cq = card->qdio.c_q;
int i; int i;
int rc; int rc;
...@@ -3663,25 +3646,17 @@ static void qeth_qdio_cq_handler(struct qeth_card *card, ...@@ -3663,25 +3646,17 @@ static void qeth_qdio_cq_handler(struct qeth_card *card,
for (i = first_element; i < first_element + count; ++i) { for (i = first_element; i < first_element + count; ++i) {
int bidx = i % QDIO_MAX_BUFFERS_PER_Q; int bidx = i % QDIO_MAX_BUFFERS_PER_Q;
struct qdio_buffer *buffer = cq->qdio_bufs[bidx]; struct qdio_buffer *buffer = cq->qdio_bufs[bidx];
int e; int e = 0;
e = 0;
while ((e < QDIO_MAX_ELEMENTS_PER_BUFFER) && while ((e < QDIO_MAX_ELEMENTS_PER_BUFFER) &&
buffer->element[e].addr) { buffer->element[e].addr) {
unsigned long phys_aob_addr; unsigned long phys_aob_addr;
phys_aob_addr = (unsigned long) buffer->element[e].addr; phys_aob_addr = (unsigned long) buffer->element[e].addr;
qeth_qdio_handle_aob(card, phys_aob_addr); qeth_qdio_handle_aob(card, phys_aob_addr);
buffer->element[e].addr = NULL;
buffer->element[e].eflags = 0;
buffer->element[e].sflags = 0;
buffer->element[e].length = 0;
++e; ++e;
} }
qeth_scrub_qdio_buffer(buffer, QDIO_MAX_ELEMENTS_PER_BUFFER);
buffer->element[15].eflags = 0;
buffer->element[15].sflags = 0;
} }
rc = do_QDIO(CARD_DDEV(card), QDIO_FLAG_SYNC_INPUT, queue, rc = do_QDIO(CARD_DDEV(card), QDIO_FLAG_SYNC_INPUT, queue,
card->qdio.c_q->next_buf_to_init, card->qdio.c_q->next_buf_to_init,
...@@ -3782,8 +3757,7 @@ static void qeth_qdio_output_handler(struct ccw_device *ccwdev, ...@@ -3782,8 +3757,7 @@ static void qeth_qdio_output_handler(struct ccw_device *ccwdev,
qeth_notify_skbs(queue, buffer, n); qeth_notify_skbs(queue, buffer, n);
} }
qeth_clear_output_buffer(queue, buffer, qeth_clear_output_buffer(queue, buffer);
QETH_QDIO_BUF_EMPTY);
} }
qeth_cleanup_handled_pending(queue, bidx, 0); qeth_cleanup_handled_pending(queue, bidx, 0);
} }
......
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