[dpdk-dev] [PATCH v2 03/18] drivers/bus/dpaa: fix inconsistent struct alignment

Hemant Agrawal hemant.agrawal at nxp.com
Wed May 9 10:06:31 CEST 2018


On 5/9/2018 7:01 AM, Andy Green wrote:
> The actual descriptor for qm_mr_entry is 64-byte aligned.
>
> But the original code plays a trick, and puts a u8 common
> to the three descriptor subtypes in the union afterwards
> outside their structure definitions.
>
> Unfortunately since they compose a struct qm_fd with
> alignment 8, this trick destroys the ability of the compiler
> to understand what has happened, resulting in this kind of
> problem:
>
> /home/agreen/projects/dpdk/drivers/bus/dpaa/include/
> fsl_qman.h:354:3: error: alignment 1 of ‘struct <anonymous>’
> is less than 8 [-Werror=packed-not-aligned]
>    } __packed dcern;
>
> on gcc 8 / Fedora 28 out of the box.
>
> This patch moves the u8 verb into the structure definitions
> composed into the union, so the alignment of the parent struct
> containing the alignment 8 object can also be seen to be
> alignment 8 by the compiler.  Uses of .verb are fixed up to use
> .ern.verb (the same offset of +0 inside all the structs in
> the union).
>
> The final struct layout should be unchanged.
>
> Signed-off-by: Andy Green <andy at warmcat.com>
> ---
>  drivers/bus/dpaa/base/qbman/qman.c  |   14 +++++++-------
>  drivers/bus/dpaa/include/fsl_qman.h |   24 +++++++++++++-----------
>  2 files changed, 20 insertions(+), 18 deletions(-)

Acked-by: Hemant Agrawal <hemant.agrawal at nxp.com>
Tested on ubuntu 18.04 with GCC 8.1.0


More information about the dev mailing list