Skip to content

Commit

Permalink
bus/dpaa: fix build with musl
Browse files Browse the repository at this point in the history
[ upstream commit e9fd4b8 ]

The header files argp.h and error.h do not exist in musl libc.

Fix build with musl libc by using err(3) instead of
the GNU-specific error(3).

We could have used the identical errx("...: %s", strerror(ret))` but
strerror(3) is not thread-safe and the strerror_r variant has two
incompatible versions, one GNU specific and one XSI-compliant.
Avoid the mess by letting "err" use the thread-local errno.

This also fixes error message for kzmalloc failures which previously
would always have given "Unknown error -1", since that is what
strerror(-1) returns. Let "err" use the proper error message from errno
which is set by kzalloc.

Fixes: 9d32ef0 ("bus/dpaa: support creating dynamic HW portal")
Fixes: f09ede6 ("bus/dpaa: add BMAN driver core")
Fixes: 5b22cf7 ("bus/dpaa: introducing FMan configurations")
Fixes: 39f373c ("bus/dpaa: add compatibility and helper macros")

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
  • Loading branch information
ncopa authored and cpaelzer committed May 11, 2021
1 parent ff200e0 commit 4b72771
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
4 changes: 2 additions & 2 deletions drivers/bus/dpaa/base/fman/netcfg_layer.c
Expand Up @@ -8,7 +8,7 @@
#include <dpaa_of.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <error.h>
#include <err.h>
#include <net/if_arp.h>
#include <assert.h>
#include <unistd.h>
Expand Down Expand Up @@ -89,7 +89,7 @@ netcfg_acquire(void)
*/
skfd = socket(AF_PACKET, SOCK_RAW, 0);
if (unlikely(skfd < 0)) {
error(0, errno, "%s(): open(SOCK_RAW)", __func__);
err(0, "%s(): open(SOCK_RAW)", __func__);
return NULL;
}

Expand Down
13 changes: 9 additions & 4 deletions drivers/bus/dpaa/base/qbman/bman_driver.c
Expand Up @@ -11,6 +11,7 @@
#include <process.h>
#include "bman_priv.h"
#include <sys/ioctl.h>
#include <err.h>

/*
* Global variables of the max portal/pool number this bman version supported
Expand Down Expand Up @@ -40,7 +41,8 @@ static int fsl_bman_portal_init(uint32_t idx, int is_shared)
ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
&cpuset);
if (ret) {
error(0, ret, "pthread_getaffinity_np()");
errno = ret;
err(0, "pthread_getaffinity_np()");
return ret;
}
pcfg.cpu = -1;
Expand All @@ -60,7 +62,8 @@ static int fsl_bman_portal_init(uint32_t idx, int is_shared)
map.index = idx;
ret = process_portal_map(&map);
if (ret) {
error(0, ret, "process_portal_map()");
errno = ret;
err(0, "process_portal_map()");
return ret;
}
/* Make the portal's cache-[enabled|inhibited] regions */
Expand Down Expand Up @@ -104,8 +107,10 @@ static int fsl_bman_portal_finish(void)
cfg = bman_destroy_affine_portal();
DPAA_BUG_ON(cfg != &pcfg);
ret = process_portal_unmap(&map.addr);
if (ret)
error(0, ret, "process_portal_unmap()");
if (ret) {
errno = ret;
err(0, "process_portal_unmap()");
}
return ret;
}

Expand Down
17 changes: 12 additions & 5 deletions drivers/bus/dpaa/base/qbman/qman_driver.c
Expand Up @@ -9,6 +9,8 @@
#include <process.h>
#include "qman_priv.h"
#include <sys/ioctl.h>
#include <err.h>

#include <rte_branch_prediction.h>

/* Global variable containing revision id (even on non-control plane systems
Expand Down Expand Up @@ -40,7 +42,8 @@ static int fsl_qman_portal_init(uint32_t index, int is_shared)
map.index = index;
ret = process_portal_map(&map);
if (ret) {
error(0, ret, "process_portal_map()");
errno = ret;
err(0, "process_portal_map()");
return ret;
}
qpcfg.channel = map.channel;
Expand Down Expand Up @@ -86,8 +89,10 @@ static int fsl_qman_portal_finish(void)
cfg = qman_destroy_affine_portal(NULL);
DPAA_BUG_ON(cfg != &qpcfg);
ret = process_portal_unmap(&map.addr);
if (ret)
error(0, ret, "process_portal_unmap()");
if (ret) {
errno = ret;
err(0, "process_portal_unmap()");
}
return ret;
}

Expand Down Expand Up @@ -136,7 +141,8 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)

q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0);
if (!q_pcfg) {
error(0, -1, "q_pcfg kzalloc failed");
/* kzalloc sets errno */
err(0, "q_pcfg kzalloc failed");
return NULL;
}

Expand All @@ -145,7 +151,8 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
q_map.index = QBMAN_ANY_PORTAL_IDX;
ret = process_portal_map(&q_map);
if (ret) {
error(0, ret, "process_portal_map()");
errno = ret;
err(0, "process_portal_map()");
kfree(q_pcfg);
return NULL;
}
Expand Down
1 change: 0 additions & 1 deletion drivers/bus/dpaa/include/netcfg.h
Expand Up @@ -9,7 +9,6 @@
#define __NETCFG_H

#include <fman.h>
#include <argp.h>

/* Configuration information related to a specific ethernet port */
struct fm_eth_port_cfg {
Expand Down
1 change: 0 additions & 1 deletion drivers/common/dpaax/compat.h
Expand Up @@ -34,7 +34,6 @@
#include <assert.h>
#include <dirent.h>
#include <inttypes.h>
#include <error.h>
#include <rte_byteorder.h>
#include <rte_atomic.h>
#include <rte_spinlock.h>
Expand Down

0 comments on commit 4b72771

Please sign in to comment.