s390/zfcp: use qdio buffer helpers
Use qdio buffer helpers to manage the buffers used for the request and response queues. No functional change. Reviewed-by: Steffen Maier <maier@linux.vnet.ibm.com> Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
parent
d445a4e28c
commit
852eb1aa2b
1 changed files with 21 additions and 28 deletions
|
@ -14,27 +14,10 @@
|
|||
#include "zfcp_ext.h"
|
||||
#include "zfcp_qdio.h"
|
||||
|
||||
#define QBUFF_PER_PAGE (PAGE_SIZE / sizeof(struct qdio_buffer))
|
||||
|
||||
static bool enable_multibuffer = 1;
|
||||
module_param_named(datarouter, enable_multibuffer, bool, 0400);
|
||||
MODULE_PARM_DESC(datarouter, "Enable hardware data router support (default on)");
|
||||
|
||||
static int zfcp_qdio_buffers_enqueue(struct qdio_buffer **sbal)
|
||||
{
|
||||
int pos;
|
||||
|
||||
for (pos = 0; pos < QDIO_MAX_BUFFERS_PER_Q; pos += QBUFF_PER_PAGE) {
|
||||
sbal[pos] = (struct qdio_buffer *) get_zeroed_page(GFP_KERNEL);
|
||||
if (!sbal[pos])
|
||||
return -ENOMEM;
|
||||
}
|
||||
for (pos = 0; pos < QDIO_MAX_BUFFERS_PER_Q; pos++)
|
||||
if (pos % QBUFF_PER_PAGE)
|
||||
sbal[pos] = sbal[pos - 1] + 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void zfcp_qdio_handler_error(struct zfcp_qdio *qdio, char *id,
|
||||
unsigned int qdio_err)
|
||||
{
|
||||
|
@ -326,15 +309,30 @@ static void zfcp_qdio_setup_init_data(struct qdio_initialize *id,
|
|||
static int zfcp_qdio_allocate(struct zfcp_qdio *qdio)
|
||||
{
|
||||
struct qdio_initialize init_data;
|
||||
int ret;
|
||||
|
||||
if (zfcp_qdio_buffers_enqueue(qdio->req_q) ||
|
||||
zfcp_qdio_buffers_enqueue(qdio->res_q))
|
||||
ret = qdio_alloc_buffers(qdio->req_q, QDIO_MAX_BUFFERS_PER_Q);
|
||||
if (ret)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = qdio_alloc_buffers(qdio->res_q, QDIO_MAX_BUFFERS_PER_Q);
|
||||
if (ret)
|
||||
goto free_req_q;
|
||||
|
||||
zfcp_qdio_setup_init_data(&init_data, qdio);
|
||||
init_waitqueue_head(&qdio->req_q_wq);
|
||||
|
||||
return qdio_allocate(&init_data);
|
||||
ret = qdio_allocate(&init_data);
|
||||
if (ret)
|
||||
goto free_res_q;
|
||||
|
||||
return 0;
|
||||
|
||||
free_res_q:
|
||||
qdio_free_buffers(qdio->res_q, QDIO_MAX_BUFFERS_PER_Q);
|
||||
free_req_q:
|
||||
qdio_free_buffers(qdio->req_q, QDIO_MAX_BUFFERS_PER_Q);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -448,19 +446,14 @@ int zfcp_qdio_open(struct zfcp_qdio *qdio)
|
|||
|
||||
void zfcp_qdio_destroy(struct zfcp_qdio *qdio)
|
||||
{
|
||||
int p;
|
||||
|
||||
if (!qdio)
|
||||
return;
|
||||
|
||||
if (qdio->adapter->ccw_device)
|
||||
qdio_free(qdio->adapter->ccw_device);
|
||||
|
||||
for (p = 0; p < QDIO_MAX_BUFFERS_PER_Q; p += QBUFF_PER_PAGE) {
|
||||
free_page((unsigned long) qdio->req_q[p]);
|
||||
free_page((unsigned long) qdio->res_q[p]);
|
||||
}
|
||||
|
||||
qdio_free_buffers(qdio->req_q, QDIO_MAX_BUFFERS_PER_Q);
|
||||
qdio_free_buffers(qdio->res_q, QDIO_MAX_BUFFERS_PER_Q);
|
||||
kfree(qdio);
|
||||
}
|
||||
|
||||
|
@ -475,7 +468,7 @@ int zfcp_qdio_setup(struct zfcp_adapter *adapter)
|
|||
qdio->adapter = adapter;
|
||||
|
||||
if (zfcp_qdio_allocate(qdio)) {
|
||||
zfcp_qdio_destroy(qdio);
|
||||
kfree(qdio);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue