Commit 166e6045 authored by Ganesh Goudar's avatar Ganesh Goudar Committed by David S. Miller

cxgb4: Fix error handling in alloc_uld_rxqs().

Fix to release resources properly in error handling path of
alloc_uld_rxqs(), This patch also removes unwanted arguments
and avoids calling the same function twice.

Fixes: 94cdb8bb (cxgb4: Add support for dynamic allocation
       of resources for ULD
Signed-off-by: default avatarGanesh Goudar <ganeshgr@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a4256bc9
...@@ -135,15 +135,17 @@ static int uldrx_handler(struct sge_rspq *q, const __be64 *rsp, ...@@ -135,15 +135,17 @@ static int uldrx_handler(struct sge_rspq *q, const __be64 *rsp,
} }
static int alloc_uld_rxqs(struct adapter *adap, static int alloc_uld_rxqs(struct adapter *adap,
struct sge_uld_rxq_info *rxq_info, struct sge_uld_rxq_info *rxq_info, bool lro)
unsigned int nq, unsigned int offset, bool lro)
{ {
struct sge *s = &adap->sge; struct sge *s = &adap->sge;
struct sge_ofld_rxq *q = rxq_info->uldrxq + offset; unsigned int nq = rxq_info->nrxq + rxq_info->nciq;
unsigned short *ids = rxq_info->rspq_id + offset; struct sge_ofld_rxq *q = rxq_info->uldrxq;
unsigned int per_chan = nq / adap->params.nports; unsigned short *ids = rxq_info->rspq_id;
unsigned int bmap_idx = 0; unsigned int bmap_idx = 0;
int i, err, msi_idx; unsigned int per_chan;
int i, err, msi_idx, que_idx = 0;
per_chan = rxq_info->nrxq / adap->params.nports;
if (adap->flags & USING_MSIX) if (adap->flags & USING_MSIX)
msi_idx = 1; msi_idx = 1;
...@@ -151,12 +153,18 @@ static int alloc_uld_rxqs(struct adapter *adap, ...@@ -151,12 +153,18 @@ static int alloc_uld_rxqs(struct adapter *adap,
msi_idx = -((int)s->intrq.abs_id + 1); msi_idx = -((int)s->intrq.abs_id + 1);
for (i = 0; i < nq; i++, q++) { for (i = 0; i < nq; i++, q++) {
if (i == rxq_info->nrxq) {
/* start allocation of concentrator queues */
per_chan = rxq_info->nciq / adap->params.nports;
que_idx = 0;
}
if (msi_idx >= 0) { if (msi_idx >= 0) {
bmap_idx = get_msix_idx_from_bmap(adap); bmap_idx = get_msix_idx_from_bmap(adap);
msi_idx = adap->msix_info_ulds[bmap_idx].idx; msi_idx = adap->msix_info_ulds[bmap_idx].idx;
} }
err = t4_sge_alloc_rxq(adap, &q->rspq, false, err = t4_sge_alloc_rxq(adap, &q->rspq, false,
adap->port[i / per_chan], adap->port[que_idx++ / per_chan],
msi_idx, msi_idx,
q->fl.size ? &q->fl : NULL, q->fl.size ? &q->fl : NULL,
uldrx_handler, uldrx_handler,
...@@ -165,29 +173,19 @@ static int alloc_uld_rxqs(struct adapter *adap, ...@@ -165,29 +173,19 @@ static int alloc_uld_rxqs(struct adapter *adap,
if (err) if (err)
goto freeout; goto freeout;
if (msi_idx >= 0) if (msi_idx >= 0)
rxq_info->msix_tbl[i + offset] = bmap_idx; rxq_info->msix_tbl[i] = bmap_idx;
memset(&q->stats, 0, sizeof(q->stats)); memset(&q->stats, 0, sizeof(q->stats));
if (ids) if (ids)
ids[i] = q->rspq.abs_id; ids[i] = q->rspq.abs_id;
} }
return 0; return 0;
freeout: freeout:
q = rxq_info->uldrxq + offset; q = rxq_info->uldrxq;
for ( ; i; i--, q++) { for ( ; i; i--, q++) {
if (q->rspq.desc) if (q->rspq.desc)
free_rspq_fl(adap, &q->rspq, free_rspq_fl(adap, &q->rspq,
q->fl.size ? &q->fl : NULL); q->fl.size ? &q->fl : NULL);
} }
/* We need to free rxq also in case of ciq allocation failure */
if (offset) {
q = rxq_info->uldrxq + offset;
for ( ; i; i--, q++) {
if (q->rspq.desc)
free_rspq_fl(adap, &q->rspq,
q->fl.size ? &q->fl : NULL);
}
}
return err; return err;
} }
...@@ -205,9 +203,7 @@ setup_sge_queues_uld(struct adapter *adap, unsigned int uld_type, bool lro) ...@@ -205,9 +203,7 @@ setup_sge_queues_uld(struct adapter *adap, unsigned int uld_type, bool lro)
return -ENOMEM; return -ENOMEM;
} }
ret = !(!alloc_uld_rxqs(adap, rxq_info, rxq_info->nrxq, 0, lro) && ret = !(!alloc_uld_rxqs(adap, rxq_info, lro));
!alloc_uld_rxqs(adap, rxq_info, rxq_info->nciq,
rxq_info->nrxq, lro));
/* Tell uP to route control queue completions to rdma rspq */ /* Tell uP to route control queue completions to rdma rspq */
if (adap->flags & FULL_INIT_DONE && if (adap->flags & FULL_INIT_DONE &&
......
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