[PATCH v3 08/30] baseband/acc100: allocate ring/queue mem when NULL
Maxime Coquelin
maxime.coquelin at redhat.com
Fri Oct 14 11:55:57 CEST 2022
On 10/12/22 04:53, Hernan Vargas wrote:
> Allocate info ring, tail pointers and HARQ layout memory for a device
> only if it hasn't already been allocated.
>
> Fixes: 06531464151 ("baseband/acc100: support interrupt")
> Cc: stable at dpdk.org
>
> Signed-off-by: Hernan Vargas <hernan.vargas at intel.com>
> ---
> drivers/baseband/acc/rte_acc100_pmd.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/baseband/acc/rte_acc100_pmd.c b/drivers/baseband/acc/rte_acc100_pmd.c
> index c1446b3721..c0184b8174 100644
> --- a/drivers/baseband/acc/rte_acc100_pmd.c
> +++ b/drivers/baseband/acc/rte_acc100_pmd.c
> @@ -406,7 +406,8 @@ allocate_info_ring(struct rte_bbdev *dev)
> else
> reg_addr = &vf_reg_addr;
> /* Allocate InfoRing */
> - d->info_ring = rte_zmalloc_socket("Info Ring",
> + if (d->info_ring == NULL)
Isn't there a check already in the function entry that returns early if
already allocated?
> + d->info_ring = rte_zmalloc_socket("Info Ring",
> ACC_INFO_RING_NUM_ENTRIES *
> sizeof(*d->info_ring), RTE_CACHE_LINE_SIZE,
> dev->data->socket_id);
> @@ -498,7 +499,8 @@ acc100_setup_queues(struct rte_bbdev *dev, uint16_t num_queues, int socket_id)
> acc_reg_write(d, reg_addr->ring_size, value);
>
> /* Configure tail pointer for use when SDONE enabled */
> - d->tail_ptrs = rte_zmalloc_socket(
> + if (d->tail_ptrs == NULL)
> + d->tail_ptrs = rte_zmalloc_socket(
> dev->device->driver->name,
> ACC100_NUM_QGRPS * ACC100_NUM_AQS * sizeof(uint32_t),
> RTE_CACHE_LINE_SIZE, socket_id);
In case of tail_ptrs, sw_rings is freed, but not set to NULL.
At the function entry, we check sw_rings is non-NULL before proceeding
to allocation.
It would be better to have a proper error path using gotos.
> @@ -530,7 +532,8 @@ acc100_setup_queues(struct rte_bbdev *dev, uint16_t num_queues, int socket_id)
> /* Continue */
> }
>
> - d->harq_layout = rte_zmalloc_socket("HARQ Layout",
> + if (d->harq_layout == NULL)
> + d->harq_layout = rte_zmalloc_socket("HARQ Layout",
> ACC_HARQ_LAYOUT * sizeof(*d->harq_layout),
> RTE_CACHE_LINE_SIZE, dev->data->socket_id);
> if (d->harq_layout == NULL) {
Same comment here.
More information about the stable
mailing list