All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver O'Halloran <oohall@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Oliver O'Halloran <oohall@gmail.com>,
	Haren Myneni <haren@linux.vnet.ibm.com>,
	Dan Streetman <ddstreet@ieee.org>
Subject: [PATCH 6/6] powerpc/nx: Don't pack struct coprocessor_request_block
Date: Tue,  4 Aug 2020 10:54:10 +1000	[thread overview]
Message-ID: <20200804005410.146094-7-oohall@gmail.com> (raw)
In-Reply-To: <20200804005410.146094-1-oohall@gmail.com>

Building with W=1 results in the following warning:

In file included from arch/powerpc/platforms/powernv/vas-fault.c:16:
./arch/powerpc/include/asm/icswx.h:159:1: error: alignment 1 of ‘struct
	coprocessor_request_block’ is less than 16 [-Werror=packed-not-aligned]
  159 | } __packed;
      | ^
./arch/powerpc/include/asm/icswx.h:159:1: error: alignment 1 of ‘struct
	coprocessor_request_block’ is less than 16 [-Werror=packed-not-aligned]
./arch/powerpc/include/asm/icswx.h:159:1: error: alignment 1 of ‘struct
	coprocessor_request_block’ is less than 16 [-Werror=packed-not-aligned]
./arch/powerpc/include/asm/icswx.h:159:1: error: alignment 1 of ‘struct
	coprocessor_request_block’ is less than 16 [-Werror=packed-not-aligned]
cc1: all warnings being treated as errors

This happens because coprocessor_request_block includes several
sub-structures with an alignment specified using the __aligned(XX)
attribute. The problem comes from coprocessor_request_block having the
__packed attribute. Packing the structure causes the preferred alignment of
the nested structures to be ignored and we get the warnings as a result.

This isn't a problem in practice since the struct is defined with explicit
padding in the form of reserved fields, but we'd like to get rid of the
spurious warnings. The simplest solution is to remove the packed attribute
and use a BUILD_BUG_ON() to ensure the struct is the correct (expected by
HW) size compile time.

Also add a __aligned(128) to the request block structure since Book4 for P8
suggests the HW requires it to be aligned to a 128 byte boundary. There's a
similar requirement for P9 since the COPY and PASTE instructions used to
invoke VAS/NX accelerators operates on a cache line boundary.

Cc: Dan Streetman <ddstreet@ieee.org>
Cc: Haren Myneni <haren@linux.vnet.ibm.com>
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 arch/powerpc/include/asm/icswx.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/icswx.h b/arch/powerpc/include/asm/icswx.h
index b0c70a35fd0e..f6599ccb3012 100644
--- a/arch/powerpc/include/asm/icswx.h
+++ b/arch/powerpc/include/asm/icswx.h
@@ -156,8 +156,7 @@ struct coprocessor_request_block {
 	u8 reserved[32];
 
 	struct coprocessor_status_block csb;
-} __packed;
-
+} __aligned(128);
 
 /* RFC02167 Initiate Coprocessor Instructions document
  * Chapter 8.2.1.1.1 RS
@@ -188,6 +187,9 @@ static inline int icswx(__be32 ccw, struct coprocessor_request_block *crb)
 	__be64 ccw_reg = ccw;
 	u32 cr;
 
+	/* NB: the same structures are used by VAS-NX */
+	BUILD_BUG_ON(sizeof(*crb) != 128);
+
 	__asm__ __volatile__(
 	PPC_ICSWX(%1,0,%2) "\n"
 	"mfcr %0\n"
-- 
2.26.2


      parent reply	other threads:[~2020-08-04  1:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-04  0:54 Clean up W=1 for the powernv platform Oliver O'Halloran
2020-08-04  0:54 ` [PATCH 1/6] powerpc/powernv/smp: Fix spurious DBG() warning Oliver O'Halloran
2020-08-04  2:07   ` Joel Stanley
2020-08-04  6:58     ` Oliver O'Halloran
2020-08-04 12:05     ` Michael Ellerman
2020-09-09 13:37   ` Michael Ellerman
2020-08-04  0:54 ` [PATCH 2/6] powerpc/powernv: Include asm/powernv.h from the local powernv.h Oliver O'Halloran
2020-08-04  0:54 ` [PATCH 3/6] powerpc/powernv: Staticify functions without prototypes Oliver O'Halloran
2020-08-04  2:17   ` Joel Stanley
2020-08-04  0:54 ` [PATCH 4/6] powerpc/powernv: Fix spurious kerneldoc warnings in opal-prd.c Oliver O'Halloran
2020-08-04  2:18   ` Joel Stanley
2020-08-04  0:54 ` [PATCH 5/6] powerpc/powernv/pci: Drop unused parent variable Oliver O'Halloran
2020-08-04  2:19   ` Joel Stanley
2020-08-04  0:54 ` Oliver O'Halloran [this message]

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=20200804005410.146094-7-oohall@gmail.com \
    --to=oohall@gmail.com \
    --cc=ddstreet@ieee.org \
    --cc=haren@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.