From: Shijith Thotton <sthotton@marvell.com>
To: <jerinj@marvell.com>
Cc: Shijith Thotton <sthotton@marvell.com>, <dev@dpdk.org>,
<pbhagavatula@marvell.com>
Subject: [PATCH] common/cnxk: alloc link map array if HWS is available
Date: Fri, 3 Jun 2022 10:40:45 +0530 [thread overview]
Message-ID: <764fb382f2934807b8e6e0ba15c37a606a98d9d2.1654232597.git.sthotton@marvell.com> (raw)
Link map array is required only if work slots are available.
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
drivers/common/cnxk/roc_sso.c | 45 +++++++++++++++++++----------------
1 file changed, 25 insertions(+), 20 deletions(-)
diff --git a/drivers/common/cnxk/roc_sso.c b/drivers/common/cnxk/roc_sso.c
index 358d37a9f2..34b9896d5f 100644
--- a/drivers/common/cnxk/roc_sso.c
+++ b/drivers/common/cnxk/roc_sso.c
@@ -784,29 +784,34 @@ roc_sso_dev_init(struct roc_sso *roc_sso)
}
rc = -ENOMEM;
- sso->link_map =
- plt_zmalloc(sizeof(struct plt_bitmap *) * roc_sso->max_hws, 0);
- if (sso->link_map == NULL) {
- plt_err("Failed to allocate memory for link_map array");
- goto rsrc_fail;
- }
+ if (roc_sso->max_hws) {
+ sso->link_map = plt_zmalloc(
+ sizeof(struct plt_bitmap *) * roc_sso->max_hws, 0);
+ if (sso->link_map == NULL) {
+ plt_err("Failed to allocate memory for link_map array");
+ goto rsrc_fail;
+ }
- link_map_sz = plt_bitmap_get_memory_footprint(roc_sso->max_hwgrp);
- sso->link_map_mem = plt_zmalloc(link_map_sz * roc_sso->max_hws, 0);
- if (sso->link_map_mem == NULL) {
- plt_err("Failed to get link_map memory");
- goto rsrc_fail;
- }
+ link_map_sz =
+ plt_bitmap_get_memory_footprint(roc_sso->max_hwgrp);
+ sso->link_map_mem =
+ plt_zmalloc(link_map_sz * roc_sso->max_hws, 0);
+ if (sso->link_map_mem == NULL) {
+ plt_err("Failed to get link_map memory");
+ goto rsrc_fail;
+ }
- link_mem = sso->link_map_mem;
- for (i = 0; i < roc_sso->max_hws; i++) {
- sso->link_map[i] = plt_bitmap_init(roc_sso->max_hwgrp, link_mem,
- link_map_sz);
- if (sso->link_map[i] == NULL) {
- plt_err("Failed to allocate link map");
- goto link_mem_free;
+ link_mem = sso->link_map_mem;
+
+ for (i = 0; i < roc_sso->max_hws; i++) {
+ sso->link_map[i] = plt_bitmap_init(
+ roc_sso->max_hwgrp, link_mem, link_map_sz);
+ if (sso->link_map[i] == NULL) {
+ plt_err("Failed to allocate link map");
+ goto link_mem_free;
+ }
+ link_mem = PLT_PTR_ADD(link_mem, link_map_sz);
}
- link_mem = PLT_PTR_ADD(link_mem, link_map_sz);
}
idev_sso_pffunc_set(sso->dev.pf_func);
idev_sso_set(roc_sso);
--
2.25.1
next reply other threads:[~2022-06-03 5:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-03 5:10 Shijith Thotton [this message]
2022-06-13 7:19 ` Jerin Jacob
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=764fb382f2934807b8e6e0ba15c37a606a98d9d2.1654232597.git.sthotton@marvell.com \
--to=sthotton@marvell.com \
--cc=dev@dpdk.org \
--cc=jerinj@marvell.com \
--cc=pbhagavatula@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).