Skip to content

Commit

Permalink
scsi: ibmvfc: Add size parameter to ibmvfc_init_event_pool()
Browse files Browse the repository at this point in the history
With the upcoming addition of Sub-CRQs the event pool size may vary
per-queue.

Add a size parameter to ibmvfc_init_event_pool() such that different size
event pools can be requested by ibmvfc_alloc_queue().

Link: https://lore.kernel.org/r/20210114203148.246656-5-tyreld@linux.ibm.com
Reviewed-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Tyrel Datwyler authored and Martin K. Petersen committed Jan 15, 2021
1 parent 003d91a commit bb35ecb
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions drivers/scsi/ibmvscsi/ibmvfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,19 +723,23 @@ static int ibmvfc_send_crq_init_complete(struct ibmvfc_host *vhost)
* Returns zero on success.
**/
static int ibmvfc_init_event_pool(struct ibmvfc_host *vhost,
struct ibmvfc_queue *queue)
struct ibmvfc_queue *queue,
unsigned int size)
{
int i;
struct ibmvfc_event_pool *pool = &queue->evt_pool;

ENTER;
pool->size = max_requests + IBMVFC_NUM_INTERNAL_REQ;
pool->events = kcalloc(pool->size, sizeof(*pool->events), GFP_KERNEL);
if (!size)
return 0;

pool->size = size;
pool->events = kcalloc(size, sizeof(*pool->events), GFP_KERNEL);
if (!pool->events)
return -ENOMEM;

pool->iu_storage = dma_alloc_coherent(vhost->dev,
pool->size * sizeof(*pool->iu_storage),
size * sizeof(*pool->iu_storage),
&pool->iu_token, 0);

if (!pool->iu_storage) {
Expand All @@ -747,7 +751,7 @@ static int ibmvfc_init_event_pool(struct ibmvfc_host *vhost,
INIT_LIST_HEAD(&queue->free);
spin_lock_init(&queue->l_lock);

for (i = 0; i < pool->size; ++i) {
for (i = 0; i < size; ++i) {
struct ibmvfc_event *evt = &pool->events[i];

atomic_set(&evt->free, 1);
Expand Down Expand Up @@ -5013,6 +5017,7 @@ static int ibmvfc_alloc_queue(struct ibmvfc_host *vhost,
{
struct device *dev = vhost->dev;
size_t fmt_size;
unsigned int pool_size = 0;

ENTER;
spin_lock_init(&queue->_lock);
Expand All @@ -5021,10 +5026,7 @@ static int ibmvfc_alloc_queue(struct ibmvfc_host *vhost,
switch (fmt) {
case IBMVFC_CRQ_FMT:
fmt_size = sizeof(*queue->msgs.crq);
if (ibmvfc_init_event_pool(vhost, queue)) {
dev_err(dev, "Couldn't initialize event pool.\n");
return -ENOMEM;
}
pool_size = max_requests + IBMVFC_NUM_INTERNAL_REQ;
break;
case IBMVFC_ASYNC_FMT:
fmt_size = sizeof(*queue->msgs.async);
Expand All @@ -5034,6 +5036,11 @@ static int ibmvfc_alloc_queue(struct ibmvfc_host *vhost,
return -EINVAL;
}

if (ibmvfc_init_event_pool(vhost, queue, pool_size)) {
dev_err(dev, "Couldn't initialize event pool.\n");
return -ENOMEM;
}

queue->msgs.handle = (void *)get_zeroed_page(GFP_KERNEL);
if (!queue->msgs.handle)
return -ENOMEM;
Expand Down

0 comments on commit bb35ecb

Please sign in to comment.