From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f181.google.com (mail-wr0-f181.google.com [209.85.128.181]) by dpdk.org (Postfix) with ESMTP id 611DA1B899 for ; Tue, 15 May 2018 15:53:42 +0200 (CEST) Received: by mail-wr0-f181.google.com with SMTP id v60-v6so235457wrc.7 for ; Tue, 15 May 2018 06:53:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oqMb2U4GwFhLj+0/qRAg6AvSiVoGaXElSGS/C7OwhnM=; b=IvOTA8qM5XYYwOfpaklxRzeQZkOlYiNAD/AsRDhW7AiWYQR5GsNmLBp+UEY0Ax9Za0 8STQ4zvjOI/XDvyJAUpQGIQv35DjgFvqiOjqNBtGvnTFH+WpSrpgFOmFBUZLPvrhsOPZ A6IDlzg1E4TUzxV/Ya2r1af1wlsfQl0K3a6DbDvxCi4yVgzROYZorld7hSDLPvM0GWT8 dX9QdC4UpitIj0CfDEC30oJaJq25HfMZTkVrqhxzwt1A42cram0EhgYCUYJSXlHAYx3y lBKToHAyaZm22JCjh3s4KouBvJDrBparuRrWrEKdFKHEbJ8DrUe8SG2AgEblsQRsm7sv hB1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oqMb2U4GwFhLj+0/qRAg6AvSiVoGaXElSGS/C7OwhnM=; b=XrrF2pLEYu2aqRTB00Fi0g8nyaL1boazMzDDcRQYmCDit/E5OwS39563RQlvizXjHJ yh8lRPuJiuhoaMy8uZjAwYePfqyaUopKRdCdI3wAo4hvlADGTH7Sqjggprb+VIcA5aJa jierZ+zm1CeHn0FBT86CcGplYgCNFD3zHBf+pErrxAcq+THzK47Qxfn9JQ3VPq2Q6qxw rYcxuhfjn/6TLULEp8TV5s+vykv2PGVOAG6SA7tYYKKOw+MwwB3mOY6V0t9eWCP+JVFQ sMmzLzNrm+Gh3ASik8SjNcN38wEDTthIBrVKm3XO2IANVDxPSjPEQf4Ev9qyXdlrrael WbOA== X-Gm-Message-State: ALKqPwcBk/6KS8vHW7BoIE6fEPg120d2Bsvpq1NVkB6l10eJYwO0LEj6 E9o+Qoi/6PVBaAj5aqZge4E= X-Google-Smtp-Source: AB8JxZrnzSvOkBob5/J+ZV/oz69QtnlRUtLfH448Gpdkcj0JXGUWLaJe6q/qyHDQ5r4IcUh6qSFQpg== X-Received: by 2002:adf:8b08:: with SMTP id n8-v6mr9829587wra.189.1526392422052; Tue, 15 May 2018 06:53:42 -0700 (PDT) Received: from localhost (slip139-92-244-193.lon.uk.prserv.net. [139.92.244.193]) by smtp.gmail.com with ESMTPSA id p7-v6sm94496wrj.85.2018.05.15.06.53.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 May 2018 06:53:41 -0700 (PDT) From: luca.boccassi@gmail.com To: Andy Green Cc: Hemant Agrawal , dpdk stable Date: Tue, 15 May 2018 14:53:30 +0100 Message-Id: <20180515135335.10459-3-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180515135335.10459-1-luca.boccassi@gmail.com> References: <20180515134731.9337-72-luca.boccassi@gmail.com> <20180515135335.10459-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'bus/dpaa: fix inconsistent struct alignment' has been queued to stable release 18.02.2 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 May 2018 13:53:42 -0000 Hi, FYI, your patch has been queued to stable release 18.02.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/16/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From d33b0a1efb0866391b06f43aa0bf6525890f5dc5 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Mon, 14 May 2018 13:00:12 +0800 Subject: [PATCH] bus/dpaa: fix inconsistent struct alignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ upstream commit dd6f8d712e927397da27f2a3d90a759eeac4f694 ] 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: drivers/bus/dpaa/include/fsl_qman.h:354:3: error: alignment 1 of ‘struct ’ 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. Fixes: c47ff048b99a ("bus/dpaa: add QMAN driver core routines") Fixes: f6fadc3e6310 ("bus/dpaa: add QMAN interface driver") Signed-off-by: Andy Green Acked-by: Hemant Agrawal Tested-by: Hemant Agrawal --- drivers/bus/dpaa/base/qbman/qman.c | 14 +++++++------- drivers/bus/dpaa/include/fsl_qman.h | 24 +++++++++++++----------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/bus/dpaa/base/qbman/qman.c b/drivers/bus/dpaa/base/qbman/qman.c index 2810fdd26..27d98cc10 100644 --- a/drivers/bus/dpaa/base/qbman/qman.c +++ b/drivers/bus/dpaa/base/qbman/qman.c @@ -314,9 +314,9 @@ loop: if (!msg) return 0; } - if ((msg->verb & QM_MR_VERB_TYPE_MASK) != QM_MR_VERB_FQRNI) { + if ((msg->ern.verb & QM_MR_VERB_TYPE_MASK) != QM_MR_VERB_FQRNI) { /* We aren't draining anything but FQRNIs */ - pr_err("Found verb 0x%x in MR\n", msg->verb); + pr_err("Found verb 0x%x in MR\n", msg->ern.verb); return -1; } qm_mr_next(p); @@ -483,7 +483,7 @@ static inline void qm_mr_pvb_update(struct qm_portal *portal) /* when accessing 'verb', use __raw_readb() to ensure that compiler * inlining doesn't try to optimise out "excess reads". */ - if ((__raw_readb(&res->verb) & QM_MR_VERB_VBIT) == mr->vbit) { + if ((__raw_readb(&res->ern.verb) & QM_MR_VERB_VBIT) == mr->vbit) { mr->pi = (mr->pi + 1) & (QM_MR_SIZE - 1); if (!mr->pi) mr->vbit ^= QM_MR_VERB_VBIT; @@ -832,7 +832,7 @@ mr_loop: goto mr_done; swapped_msg = *msg; hw_fd_to_cpu(&swapped_msg.ern.fd); - verb = msg->verb & QM_MR_VERB_TYPE_MASK; + verb = msg->ern.verb & QM_MR_VERB_TYPE_MASK; /* The message is a software ERN iff the 0x20 bit is set */ if (verb & 0x20) { switch (verb) { @@ -1666,7 +1666,7 @@ int qman_retire_fq(struct qman_fq *fq, u32 *flags) */ struct qm_mr_entry msg; - msg.verb = QM_MR_VERB_FQRNI; + msg.ern.verb = QM_MR_VERB_FQRNI; msg.fq.fqs = mcr->alterfq.fqs; msg.fq.fqid = fq->fqid; #ifdef CONFIG_FSL_QMAN_FQ_LOOKUP @@ -2643,7 +2643,7 @@ int qman_shutdown_fq(u32 fqid) qm_mr_pvb_update(low_p); msg = qm_mr_current(low_p); while (msg) { - if ((msg->verb & + if ((msg->ern.verb & QM_MR_VERB_TYPE_MASK) == QM_MR_VERB_FQRN) found_fqrn = 1; @@ -2711,7 +2711,7 @@ int qman_shutdown_fq(u32 fqid) qm_mr_pvb_update(low_p); msg = qm_mr_current(low_p); while (msg) { - if ((msg->verb & QM_MR_VERB_TYPE_MASK) == + if ((msg->ern.verb & QM_MR_VERB_TYPE_MASK) == QM_MR_VERB_FQRL) orl_empty = 1; qm_mr_next(low_p); diff --git a/drivers/bus/dpaa/include/fsl_qman.h b/drivers/bus/dpaa/include/fsl_qman.h index e9793f30d..e4ad7ae48 100644 --- a/drivers/bus/dpaa/include/fsl_qman.h +++ b/drivers/bus/dpaa/include/fsl_qman.h @@ -284,20 +284,20 @@ static inline dma_addr_t qm_sg_addr(const struct qm_sg_entry *sg) } while (0) /* See 1.5.8.1: "Enqueue Command" */ -struct qm_eqcr_entry { +struct __rte_aligned(8) qm_eqcr_entry { u8 __dont_write_directly__verb; u8 dca; u16 seqnum; u32 orp; /* 24-bit */ u32 fqid; /* 24-bit */ u32 tag; - struct qm_fd fd; + struct qm_fd fd; /* this has alignment 8 */ u8 __reserved3[32]; } __packed; /* "Frame Dequeue Response" */ -struct qm_dqrr_entry { +struct __rte_aligned(8) qm_dqrr_entry { u8 verb; u8 stat; u16 seqnum; /* 15-bit */ @@ -305,7 +305,7 @@ struct qm_dqrr_entry { u8 __reserved2[3]; u32 fqid; /* 24-bit */ u32 contextB; - struct qm_fd fd; + struct qm_fd fd; /* this has alignment 8 */ u8 __reserved4[32]; }; @@ -323,18 +323,19 @@ struct qm_dqrr_entry { /* "ERN Message Response" */ /* "FQ State Change Notification" */ struct qm_mr_entry { - u8 verb; union { struct { + u8 verb; u8 dca; u16 seqnum; u8 rc; /* Rejection Code */ u32 orp:24; u32 fqid; /* 24-bit */ u32 tag; - struct qm_fd fd; - } __packed ern; + struct qm_fd fd; /* this has alignment 8 */ + } __packed __rte_aligned(8) ern; struct { + u8 verb; #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ u8 colour:2; /* See QM_MR_DCERN_COLOUR_* */ u8 __reserved1:4; @@ -349,18 +350,19 @@ struct qm_mr_entry { u32 __reserved3:24; u32 fqid; /* 24-bit */ u32 tag; - struct qm_fd fd; - } __packed dcern; + struct qm_fd fd; /* this has alignment 8 */ + } __packed __rte_aligned(8) dcern; struct { + u8 verb; u8 fqs; /* Frame Queue Status */ u8 __reserved1[6]; u32 fqid; /* 24-bit */ u32 contextB; u8 __reserved2[16]; - } __packed fq; /* FQRN/FQRNI/FQRL/FQPN */ + } __packed __rte_aligned(8) fq; /* FQRN/FQRNI/FQRL/FQPN */ }; u8 __reserved2[32]; -} __packed; +} __packed __rte_aligned(8); #define QM_MR_VERB_VBIT 0x80 /* * ERNs originating from direct-connect portals ("dcern") use 0x20 as a verb -- 2.14.2